@qoder-ai/qmind-cli 3.4.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/qmind.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A as imageUrlsSchema, B as sourceImportResultsSchema, E as chatSessionSchema, F as retrieveResultSchema, G as sourceTreeSchema, H as sourcePreviewSchema, I as sharedNotebookListSchema, J as sourceWebOfficeSessionSchema, K as sourceUploadCapabilitiesSchema, L as sourceActionAccessSchema, M as notebookListSchema, N as notebookSchema, P as retrieveNotebooksResultSchema, Q as taskRunSchema, R as sourceChildrenCountsSchema, T as chatSessionListSchema, U as sourceRawContentSchema, V as sourceListSchema, W as sourceSchema, X as streamWireEventSchema, Y as sourceWebOfficeTokenSchema, Z as taskRunListSchema, a as invalidArgument$1, at as executeStream, c as optionalRecord, d as pagination$1, et as voidResponseSchema, f as positiveInteger$1, g as stringList, i as httpUrl, it as assertCapability, k as imageUploadTicketSchema, l as optionalString$1, m as requiredString$2, n as call, o as nonNegativeInteger$1, p as queryPath, r as compactUndefined, s as optionalBoolean, st as QMindError, t as assertNonEmptyPatch, u as optionalTrimmedString, w as chatMessageListSchema, x as cancelQuestionResultSchema, y as batchDeleteResultSchema, z as sourceContentSchema } from "./shared-DBGAKppE.js";
2
- import { t as preflightSourceUpload } from "./source-upload-CCasR8MW.js";
1
+ import { A as notebookSchema, B as sourceQuotaSchema, C as chatSessionSchema, D as imageUrlsSchema, E as imageUploadTicketSchema, F as sourceChildrenCountsSchema, H as sourceSchema, I as sourceContentSchema, J as streamWireEventSchema, K as sourceWebOfficeSessionSchema, L as sourceImportResultsSchema, M as retrieveResultSchema, N as sharedNotebookListSchema, P as sourceActionAccessSchema, Q as voidResponseSchema, R as sourceListSchema, S as chatSessionListSchema, U as sourceTreeSchema, V as sourceRawContentSchema, W as sourceUploadCapabilitiesSchema, X as taskRunSchema, Y as taskRunListSchema, a as invalidArgument$1, at as QMindError, b as cancelQuestionResultSchema, c as optionalRecord, d as pagination$1, f as positiveInteger$1, g as stringList, i as httpUrl, j as retrieveNotebooksResultSchema, k as notebookListSchema, l as optionalString$1, m as requiredString$2, n as call, nt as assertCapability, o as nonNegativeInteger$1, p as queryPath, q as sourceWebOfficeTokenSchema, r as compactUndefined, rt as executeStream, s as optionalBoolean, t as assertNonEmptyPatch, u as optionalTrimmedString, x as chatMessageListSchema, y as batchDeleteResultSchema, z as sourcePreviewSchema } from "./shared-53S5tNf6.js";
2
+ import { t as preflightSourceUpload } from "./source-upload-DlOLtECT.js";
3
3
  import { createInterface } from "node:readline/promises";
4
4
  import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
5
5
  import { z } from "zod";
@@ -12,7 +12,7 @@ import { createReadStream, createWriteStream } from "node:fs";
12
12
  import { Readable } from "node:stream";
13
13
  import { pipeline } from "node:stream/promises";
14
14
  import { createParser } from "eventsource-parser";
15
- import { Agent, EnvHttpProxyAgent, request } from "undici";
15
+ import { Agent, EnvHttpProxyAgent, Pool, ProxyAgent, fetch as fetch$1, request } from "undici";
16
16
  import { Command, CommanderError, Option } from "commander";
17
17
  import pLimit from "p-limit";
18
18
  import picomatch from "picomatch";
@@ -399,7 +399,7 @@ function createAgentOperations(context) {
399
399
  //#region ../sdk/src/operations/notebooks.ts
400
400
  function createNotebookOperations(context) {
401
401
  let wikiOperations;
402
- const loadWiki = () => wikiOperations ??= import("./wiki-branches-BfIfXeN9.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
402
+ const loadWiki = () => wikiOperations ??= import("./wiki-branches-DmgHlIxc.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
403
403
  return {
404
404
  async copyFeaturedNotebook(notebookId, options) {
405
405
  const notebook = requiredString$2(notebookId, "notebookId");
@@ -483,10 +483,12 @@ function createNotebookOperations(context) {
483
483
  },
484
484
  async listNotebooks(input = {}, options) {
485
485
  const normalizedPage = pagination$1(input);
486
+ const retrievalEligibleOnly = optionalBoolean(input.retrievalEligibleOnly, "retrievalEligibleOnly");
486
487
  const client = optionalTrimmedString(input.client, "client");
487
488
  if (client !== void 0 && !context.profile.capabilities["notebooks.filterByClient"]) assertCapability(context.profile, "notebooks.filterByClient", "notebooks.list");
488
489
  const normalized = {
489
490
  ...normalizedPage,
491
+ ...retrievalEligibleOnly === void 0 ? {} : { retrievalEligibleOnly },
490
492
  ...client === void 0 ? {} : { client }
491
493
  };
492
494
  return call(context, {
@@ -500,7 +502,11 @@ function createNotebookOperations(context) {
500
502
  });
501
503
  },
502
504
  async listSharedNotebooks(input = {}, options) {
503
- const normalized = pagination$1(input);
505
+ const retrievalEligibleOnly = optionalBoolean(input.retrievalEligibleOnly, "retrievalEligibleOnly");
506
+ const normalized = {
507
+ ...pagination$1(input),
508
+ ...retrievalEligibleOnly === void 0 ? {} : { retrievalEligibleOnly }
509
+ };
504
510
  return call(context, {
505
511
  callOptions: options,
506
512
  capability: "sharedNotebooks.read",
@@ -669,8 +675,7 @@ function isQMindExternalSource(source) {
669
675
  }
670
676
  [.../* @__PURE__ */ new Set(["axls", "alxs"])];
671
677
  //#endregion
672
- //#region ../sdk/src/operations/sources.ts
673
- const maxImageBytes = 52428800;
678
+ //#region ../sdk/src/source-tree.ts
674
679
  function sourceTreeNodeOrder(left, right) {
675
680
  if (left.type !== right.type) return left.type === "directory" ? -1 : 1;
676
681
  if (left.name !== right.name) return left.name < right.name ? -1 : 1;
@@ -692,41 +697,53 @@ function createsSourceCycle(source, sourcesById) {
692
697
  }
693
698
  return false;
694
699
  }
695
- function buildSourceTree(sources) {
700
+ function buildQMindSourceTree(sources) {
696
701
  const sourcesById = new Map(sources.map((source) => [source.id, source]));
697
- const parentIds = new Set(sources.filter((source) => sourcesById.has(source.parentSourceId) && !createsSourceCycle(source, sourcesById)).map((source) => source.parentSourceId));
698
702
  const nodesById = /* @__PURE__ */ new Map();
699
703
  for (const source of sources) nodesById.set(source.id, {
704
+ ...projectQMindSourceTreeNode(source, sources),
705
+ files: []
706
+ });
707
+ const tree = [];
708
+ for (const source of sources) {
709
+ const node = nodesById.get(source.id);
710
+ if (node === void 0) continue;
711
+ const parent = nodesById.get(source.parentSourceId);
712
+ if (parent === void 0 || createsSourceCycle(source, sourcesById)) tree.push(node);
713
+ else parent.files.push(node);
714
+ }
715
+ sortSourceTree(tree);
716
+ return {
717
+ totalSize: sources.length,
718
+ tree,
719
+ sources
720
+ };
721
+ }
722
+ /** A document can have children without losing its file identity or preview capability. */
723
+ function projectQMindSourceTreeNode(source, sources, files = []) {
724
+ return {
725
+ ...source.learningStatus === void 0 ? {} : { learningStatus: source.learningStatus },
726
+ ...source.learningErrorCode === void 0 ? {} : { learningErrorCode: source.learningErrorCode },
700
727
  ...source.externalBinding === void 0 ? {} : { externalBinding: source.externalBinding },
701
728
  ...source.originUrl === void 0 ? {} : { originUrl: source.originUrl },
702
729
  ...source.metadata === void 0 ? {} : { metadata: source.metadata },
703
730
  isEmailFolder: isQMindEmailFolder(source),
704
731
  isEmailAggregateMember: isQMindEmailAggregateMember(source, sources),
705
732
  isExternalSource: isQMindExternalSource(source),
706
- files: [],
733
+ files,
707
734
  hasChildren: source.hasChildren ?? (source.childrenCount === void 0 ? source.isDir : source.childrenCount > 0),
708
735
  id: source.id,
709
736
  name: source.title,
710
737
  path: source.path,
711
738
  sourceType: source.sourceType,
712
739
  status: source.status,
713
- type: source.isDir || parentIds.has(source.id) ? "directory" : "file",
740
+ type: source.isDir ? "directory" : "file",
714
741
  ...source.updatedAt === void 0 ? {} : { updatedAt: source.updatedAt }
715
- });
716
- const tree = [];
717
- for (const source of sources) {
718
- const node = nodesById.get(source.id);
719
- if (node === void 0) continue;
720
- const parent = nodesById.get(source.parentSourceId);
721
- if (parent === void 0 || createsSourceCycle(source, sourcesById)) tree.push(node);
722
- else parent.files.push(node);
723
- }
724
- sortSourceTree(tree);
725
- return {
726
- totalSize: sources.length,
727
- tree
728
742
  };
729
743
  }
744
+ //#endregion
745
+ //#region ../sdk/src/operations/sources.ts
746
+ const maxImageBytes = 52428800;
730
747
  function sourceBody(input) {
731
748
  return compactUndefined({
732
749
  isDir: optionalBoolean(input?.isDir, "isDir"),
@@ -932,7 +949,7 @@ function createSourceOperations(context) {
932
949
  const getSourceTree = async (notebookId, options) => {
933
950
  const notebook = requiredString$2(notebookId, "notebookId");
934
951
  assertCapability(context.profile, "sources.tree", "sources.tree");
935
- if (context.profile.access === "sash") return buildSourceTree(await collectAllSources(notebook, {}, options, "sources.tree"));
952
+ if (context.profile.access === "sash") return buildQMindSourceTree(await collectAllSources(notebook, {}, options, "sources.tree"));
936
953
  return call(context, {
937
954
  callOptions: options,
938
955
  capability: "sources.tree",
@@ -1091,7 +1108,8 @@ function createSourceOperations(context) {
1091
1108
  path: context.profile.apiPath("notebooks", requiredString$2(notebookId, "notebookId"), "sources", requiredString$2(sourceId, "sourceId"), "retry"),
1092
1109
  body: {
1093
1110
  retryKey: requiredString$2(input.retryKey, "retryKey"),
1094
- expectedUpdatedAt: requiredString$2(input.expectedUpdatedAt, "expectedUpdatedAt")
1111
+ expectedUpdatedAt: requiredString$2(input.expectedUpdatedAt, "expectedUpdatedAt"),
1112
+ ...input.expectedVectorRetryAt !== void 0 ? { expectedVectorRetryAt: input.expectedVectorRetryAt } : {}
1095
1113
  },
1096
1114
  schema: sourceSchema
1097
1115
  });
@@ -1146,6 +1164,17 @@ function createSourceOperations(context) {
1146
1164
  schema: sourceRawContentSchema
1147
1165
  });
1148
1166
  },
1167
+ async getSourceQuota(options) {
1168
+ return call(context, {
1169
+ callOptions: options,
1170
+ capability: "sources.quota",
1171
+ idempotent: true,
1172
+ method: "GET",
1173
+ operation: "sources.quota",
1174
+ path: context.profile.mindPath("source-quota"),
1175
+ schema: sourceQuotaSchema
1176
+ });
1177
+ },
1149
1178
  async getSourceUploadCapabilities(options) {
1150
1179
  return call(context, {
1151
1180
  callOptions: options,
@@ -1161,7 +1190,7 @@ function createSourceOperations(context) {
1161
1190
  return preflightSourceUpload(context, notebookId, options);
1162
1191
  },
1163
1192
  async getFeaturedSourceTree(notebookId, options) {
1164
- return buildSourceTree((await listFeaturedSources(notebookId, {
1193
+ return buildQMindSourceTree((await listFeaturedSources(notebookId, {
1165
1194
  page: 1,
1166
1195
  pageSize: 200
1167
1196
  }, options)).sources);
@@ -1307,9 +1336,6 @@ function createSourceOperations(context) {
1307
1336
  //#region ../sdk/src/capabilities.ts
1308
1337
  const dashboardCapabilities = Object.freeze({
1309
1338
  botGateway: true,
1310
- "cards.read": true,
1311
- "cards.write": true,
1312
- "cards.saveResults": true,
1313
1339
  chat: true,
1314
1340
  "featuredChat.delete": false,
1315
1341
  compilation: true,
@@ -1339,6 +1365,7 @@ const dashboardCapabilities = Object.freeze({
1339
1365
  "sources.preview": true,
1340
1366
  "sources.rawContent": true,
1341
1367
  "sources.read": true,
1368
+ "sources.quota": true,
1342
1369
  "sources.search": true,
1343
1370
  "sources.tree": true,
1344
1371
  "sources.webOffice": true,
@@ -1351,9 +1378,6 @@ const dashboardCapabilities = Object.freeze({
1351
1378
  });
1352
1379
  const sashCapabilities = Object.freeze({
1353
1380
  botGateway: false,
1354
- "cards.read": true,
1355
- "cards.write": true,
1356
- "cards.saveResults": false,
1357
1381
  chat: true,
1358
1382
  "featuredChat.delete": false,
1359
1383
  compilation: false,
@@ -1374,7 +1398,7 @@ const sashCapabilities = Object.freeze({
1374
1398
  "notes.write": true,
1375
1399
  "notes.saveCondensation": false,
1376
1400
  retrieval: true,
1377
- scheduledTasks: false,
1401
+ scheduledTasks: true,
1378
1402
  "sharedNotebooks.read": true,
1379
1403
  "sources.children": true,
1380
1404
  "sources.childrenCount": false,
@@ -1383,6 +1407,7 @@ const sashCapabilities = Object.freeze({
1383
1407
  "sources.preview": true,
1384
1408
  "sources.rawContent": true,
1385
1409
  "sources.read": true,
1410
+ "sources.quota": true,
1386
1411
  "sources.search": false,
1387
1412
  "sources.tree": true,
1388
1413
  "sources.webOffice": true,
@@ -1426,22 +1451,9 @@ function firstResultSource(access, operation, body) {
1426
1451
  status: 200
1427
1452
  });
1428
1453
  }
1429
- function dashboardBatchMutation(body) {
1430
- if (!isRecord$1(body)) return body;
1431
- const successCount = typeof body.successCount === "number" ? body.successCount : body.success_count;
1432
- const failureCount = typeof body.failureCount === "number" ? body.failureCount : body.failure_count;
1433
- if (typeof successCount !== "number" && typeof failureCount !== "number") return body;
1434
- return {
1435
- ...body,
1436
- failureCount: typeof failureCount === "number" ? failureCount : 0,
1437
- successCount: typeof successCount === "number" ? successCount : 0
1438
- };
1439
- }
1440
1454
  function normalizeSuccess(access, operation, body) {
1441
1455
  const unwrapped = access === "dashboard" ? dashboardEnvelope(body) : body;
1442
1456
  if (access !== "dashboard") return unwrapped;
1443
- if (operation === "cards.get" && isRecord$1(unwrapped) && "card" in unwrapped) return unwrapped.card;
1444
- if (operation === "cards.delete" || operation === "cards.batchDelete") return dashboardBatchMutation(unwrapped);
1445
1457
  if (operation === "sources.create" || operation === "sources.importSite") return firstResultSource(access, operation, unwrapped);
1446
1458
  if (operation === "transfers.source.multipart" || operation === "transfers.source.register") return firstResultSource(access, operation, unwrapped);
1447
1459
  return unwrapped;
@@ -1559,11 +1571,16 @@ function createProfile(access, apiPrefix) {
1559
1571
  return appendQuery(`${apiPrefix}/notebooks`, [
1560
1572
  ["page", input.page],
1561
1573
  ["page_size", input.pageSize],
1562
- ["client", input.client]
1574
+ ["client", input.client],
1575
+ ["retrieval_eligible_only", input.retrievalEligibleOnly]
1563
1576
  ]);
1564
1577
  },
1565
1578
  listSharedNotebooksPath(input) {
1566
- return appendQuery(`${apiPrefix}/notebooks/shared`, [["page", input.page], ["page_size", input.pageSize]]);
1579
+ return appendQuery(`${apiPrefix}/notebooks/shared`, [
1580
+ ["page", input.page],
1581
+ ["page_size", input.pageSize],
1582
+ ["retrieval_eligible_only", input.retrievalEligibleOnly]
1583
+ ]);
1567
1584
  },
1568
1585
  mindPath(...segments) {
1569
1586
  return `/api/v1/mind/${segments.map((segment) => encodeId(segment)).join("/")}`;
@@ -1615,14 +1632,6 @@ const managementOperationNames = [
1615
1632
  "updateMemberPermission",
1616
1633
  "updateScheduledTask"
1617
1634
  ];
1618
- const cardOperationNames = [
1619
- "batchDeleteCards",
1620
- "deleteCard",
1621
- "getCard",
1622
- "listCards",
1623
- "listFeaturedCards",
1624
- "saveCompilationResult"
1625
- ];
1626
1635
  const importOperationNames = [
1627
1636
  "confirmFullSiteURLImport",
1628
1637
  "discoverFullSiteURLImport",
@@ -1658,7 +1667,7 @@ const botGatewayOperationNames = [
1658
1667
  function createLazyTransferOperations(context) {
1659
1668
  let operations;
1660
1669
  const load = () => {
1661
- operations ??= import("./transfers-DnuncvOY.js").then(({ createTransferOperations }) => createTransferOperations(context));
1670
+ operations ??= import("./transfers-cf1MXHdB.js").then(({ createTransferOperations }) => createTransferOperations(context));
1662
1671
  return operations;
1663
1672
  };
1664
1673
  return {
@@ -1669,7 +1678,7 @@ function createLazyTransferOperations(context) {
1669
1678
  function createLazyBotGatewayOperations(context) {
1670
1679
  let operations;
1671
1680
  const load = () => {
1672
- operations ??= import("./bot-gateway-B5oq12FF.js").then(({ createBotGatewayOperations }) => createBotGatewayOperations(context));
1681
+ operations ??= import("./bot-gateway-B5cW3ErV.js").then(({ createBotGatewayOperations }) => createBotGatewayOperations(context));
1673
1682
  return operations;
1674
1683
  };
1675
1684
  return Object.fromEntries(botGatewayOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1677,23 +1686,15 @@ function createLazyBotGatewayOperations(context) {
1677
1686
  function createLazyNoteOperations(context) {
1678
1687
  let operations;
1679
1688
  const load = () => {
1680
- operations ??= import("./notes-BcyIDQG5.js").then(({ createNoteOperations }) => createNoteOperations(context));
1689
+ operations ??= import("./notes-BRnv_Z10.js").then(({ createNoteOperations }) => createNoteOperations(context));
1681
1690
  return operations;
1682
1691
  };
1683
1692
  return Object.fromEntries(noteOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
1684
1693
  }
1685
- function createLazyCardOperations(context) {
1686
- let operations;
1687
- const load = () => {
1688
- operations ??= import("./cards-CfhvlNeF.js").then(({ createCardOperations }) => createCardOperations(context));
1689
- return operations;
1690
- };
1691
- return Object.fromEntries(cardOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
1692
- }
1693
1694
  function createLazyImportOperations(context) {
1694
1695
  let operations;
1695
1696
  const load = () => {
1696
- operations ??= import("./imports-CUruHsu_.js").then(({ createImportOperations }) => createImportOperations(context));
1697
+ operations ??= import("./imports-Cmd6ys9g.js").then(({ createImportOperations }) => createImportOperations(context));
1697
1698
  return operations;
1698
1699
  };
1699
1700
  return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1701,7 +1702,7 @@ function createLazyImportOperations(context) {
1701
1702
  function createLazyManagementOperations(context) {
1702
1703
  let operations;
1703
1704
  const load = () => {
1704
- operations ??= import("./management-Dr8uPYN9.js").then(({ createManagementOperations }) => createManagementOperations(context));
1705
+ operations ??= import("./management-CgWDLle_.js").then(({ createManagementOperations }) => createManagementOperations(context));
1705
1706
  return operations;
1706
1707
  };
1707
1708
  return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1720,7 +1721,6 @@ function createQMindClient(options) {
1720
1721
  access: profile.access,
1721
1722
  capabilities: profile.capabilities,
1722
1723
  ...createNotebookOperations(context),
1723
- ...createLazyCardOperations(context),
1724
1724
  ...createSourceOperations(context),
1725
1725
  ...createLazyImportOperations(context),
1726
1726
  ...createLazyManagementOperations(context),
@@ -2038,18 +2038,7 @@ function createAuthenticatedQMindTransport(transport, auth, requestCredential) {
2038
2038
  });
2039
2039
  }
2040
2040
  //#endregion
2041
- //#region ../node-host/src/config.ts
2042
- const fileConfigSchema = z.object({
2043
- client: z.string().optional(),
2044
- dashboard_url: z.string().optional(),
2045
- proxy_from_env: z.boolean().optional(),
2046
- request_timeout_ms: z.number().int().positive().optional(),
2047
- sash_url: z.string().optional(),
2048
- stream_idle_timeout_ms: z.number().int().positive().optional(),
2049
- tls_ca_file: z.string().optional(),
2050
- tls_reject_unauthorized: z.boolean().optional(),
2051
- update_public_key: z.string().optional()
2052
- }).passthrough();
2041
+ //#region ../node-host/src/endpoints.ts
2053
2042
  const PRESETS = Object.freeze({
2054
2043
  daily: {
2055
2044
  dashboardOrigin: "https://daily.qoder.ai",
@@ -2109,6 +2098,19 @@ function resolveQMindProductEndpoints(productId, presetName, field = "env") {
2109
2098
  if (preset === void 0) throw invalidConfig(`product ${JSON.stringify(productId)} has no ${JSON.stringify(presetName)} endpoints; set ${field} explicitly`, field);
2110
2099
  return { ...preset };
2111
2100
  }
2101
+ //#endregion
2102
+ //#region ../node-host/src/config.ts
2103
+ const fileConfigSchema = z.object({
2104
+ client: z.string().optional(),
2105
+ dashboard_url: z.string().optional(),
2106
+ proxy_from_env: z.boolean().optional(),
2107
+ request_timeout_ms: z.number().int().positive().optional(),
2108
+ sash_url: z.string().optional(),
2109
+ stream_idle_timeout_ms: z.number().int().positive().optional(),
2110
+ tls_ca_file: z.string().optional(),
2111
+ tls_reject_unauthorized: z.boolean().optional(),
2112
+ update_public_key: z.string().optional()
2113
+ }).passthrough();
2112
2114
  function optionalTrimmed(value) {
2113
2115
  const trimmed = value?.trim();
2114
2116
  return trimmed === void 0 || trimmed.length === 0 ? void 0 : trimmed;
@@ -2519,6 +2521,29 @@ function createRequestBudgetTransport(transport, budget) {
2519
2521
  };
2520
2522
  }
2521
2523
  //#endregion
2524
+ //#region ../node-host/src/networkProxy.ts
2525
+ /** 跨进程配置只保留受支持字段,错误中不包含可能带凭据的代理地址。 */
2526
+ function parseQMindNodeNetworkProxy(value) {
2527
+ const invalid = () => {
2528
+ throw new QMindError("HOST_POLICY_ERROR", "Invalid host network proxy configuration");
2529
+ };
2530
+ if (!value || typeof value !== "object" || Array.isArray(value)) return invalid();
2531
+ const input = value;
2532
+ if (input.mode === "direct" && Object.keys(input).length === 1) return { mode: "direct" };
2533
+ if (input.mode !== "manual" || Object.keys(input).length !== 2 || typeof input.url !== "string") return invalid();
2534
+ if (input.url.length > 2048 || /[\\\s?#\x00-\x1f\x7f]/.test(input.url)) return invalid();
2535
+ try {
2536
+ const url = new URL(input.url);
2537
+ if (!["http:", "https:"].includes(url.protocol) || !url.hostname || url.pathname !== "/" || url.search || url.hash) return invalid();
2538
+ return {
2539
+ mode: "manual",
2540
+ url: input.url
2541
+ };
2542
+ } catch {
2543
+ return invalid();
2544
+ }
2545
+ }
2546
+ //#endregion
2522
2547
  //#region ../node-host/src/networkFailureCause.ts
2523
2548
  const NETWORK_CODES = /* @__PURE__ */ new Set([
2524
2549
  "ECONNREFUSED",
@@ -2599,9 +2624,8 @@ function environmentValue(environment, ...keys) {
2599
2624
  if (value !== void 0 && value.length > 0) return value;
2600
2625
  }
2601
2626
  }
2602
- function tlsConnectOptions(options, withTls) {
2627
+ function tlsConnectOptions(options) {
2603
2628
  const timeout = positiveInteger(options.connectTimeoutMs, 1e4, "connectTimeoutMs");
2604
- if (!withTls) return { timeout };
2605
2629
  const ca = options.tls?.ca;
2606
2630
  return {
2607
2631
  ...ca === void 0 ? {} : { ca: typeof ca === "string" ? ca : [...ca] },
@@ -2610,17 +2634,53 @@ function tlsConnectOptions(options, withTls) {
2610
2634
  };
2611
2635
  }
2612
2636
  function createDispatchers(options) {
2637
+ const connect = tlsConnectOptions(options);
2638
+ const networkProxy = options.networkProxy === void 0 ? void 0 : parseQMindNodeNetworkProxy(options.networkProxy);
2639
+ if (networkProxy?.mode === "manual") {
2640
+ const createAgent = () => new Agent({
2641
+ allowH2: false,
2642
+ factory(origin) {
2643
+ const hostname = new URL(origin).hostname.replace(/\.$/, "");
2644
+ return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "[::1]" || /^127\.\d+\.\d+\.\d+$/.test(hostname) ? new Pool(origin, {
2645
+ allowH2: false,
2646
+ connect
2647
+ }) : new ProxyAgent({
2648
+ allowH2: false,
2649
+ uri: networkProxy.url,
2650
+ requestTls: connect,
2651
+ proxyTls: connect,
2652
+ proxyTunnel: true
2653
+ });
2654
+ }
2655
+ });
2656
+ return {
2657
+ host: createAgent(),
2658
+ signed: createAgent()
2659
+ };
2660
+ }
2613
2661
  const environment = options.environment ?? process.env;
2614
- if (options.proxyFromEnvironment === false) return {
2615
- host: new Agent({ connect: tlsConnectOptions(options, true) }),
2616
- signed: new Agent({ connect: tlsConnectOptions(options, true) })
2662
+ if (networkProxy?.mode === "direct" || options.proxyFromEnvironment === false) return {
2663
+ host: new Agent({
2664
+ allowH2: false,
2665
+ connect
2666
+ }),
2667
+ signed: new Agent({
2668
+ allowH2: false,
2669
+ connect
2670
+ })
2617
2671
  };
2618
2672
  const httpProxy = environmentValue(environment, "HTTP_PROXY", "http_proxy");
2619
2673
  const httpsProxy = environmentValue(environment, "HTTPS_PROXY", "https_proxy");
2620
2674
  const noProxy = environmentValue(environment, "NO_PROXY", "no_proxy");
2621
2675
  if (httpProxy === void 0 && httpsProxy === void 0) return {
2622
- host: new Agent({ connect: tlsConnectOptions(options, true) }),
2623
- signed: new Agent({ connect: tlsConnectOptions(options, true) })
2676
+ host: new Agent({
2677
+ allowH2: false,
2678
+ connect
2679
+ }),
2680
+ signed: new Agent({
2681
+ allowH2: false,
2682
+ connect
2683
+ })
2624
2684
  };
2625
2685
  const proxy = {
2626
2686
  httpProxy: httpProxy ?? "",
@@ -2630,11 +2690,13 @@ function createDispatchers(options) {
2630
2690
  return {
2631
2691
  host: new EnvHttpProxyAgent({
2632
2692
  ...proxy,
2633
- requestTls: tlsConnectOptions(options, true)
2693
+ allowH2: false,
2694
+ requestTls: connect
2634
2695
  }),
2635
2696
  signed: new EnvHttpProxyAgent({
2636
2697
  ...proxy,
2637
- requestTls: tlsConnectOptions(options, true)
2698
+ allowH2: false,
2699
+ requestTls: connect
2638
2700
  })
2639
2701
  };
2640
2702
  }
@@ -2888,6 +2950,35 @@ function createQMindNodeTransport(options) {
2888
2950
  const dispatchers = createDispatchers(options);
2889
2951
  const dispatcherFor = (request) => request.destination.kind === "host" ? dispatchers.host : dispatchers.signed;
2890
2952
  return Object.freeze({
2953
+ async fetchSigned(url, signal) {
2954
+ let destination = url;
2955
+ for (let redirects = 0;; redirects++) {
2956
+ assertWireRequest({
2957
+ destination: {
2958
+ kind: "signed",
2959
+ url: destination
2960
+ },
2961
+ method: "GET",
2962
+ idempotent: true
2963
+ });
2964
+ const response = await fetch$1(destination, {
2965
+ dispatcher: dispatchers.signed,
2966
+ signal,
2967
+ redirect: "manual"
2968
+ });
2969
+ if (![
2970
+ 301,
2971
+ 302,
2972
+ 303,
2973
+ 307,
2974
+ 308
2975
+ ].includes(response.status)) return response;
2976
+ const location = response.headers.get("location");
2977
+ await response.body?.cancel();
2978
+ if (!location || redirects >= 3) throw invalidArgument("Invalid signed response redirect", "url");
2979
+ destination = new URL(location, destination).href;
2980
+ }
2981
+ },
2891
2982
  async close() {
2892
2983
  const unique = /* @__PURE__ */ new Set([dispatchers.host, dispatchers.signed]);
2893
2984
  await Promise.all([...unique].map(async (dispatcher) => dispatcher.close()));
@@ -3141,6 +3232,7 @@ async function createQMindCliHost(options = {}) {
3141
3232
  ...options.maxRetries === void 0 ? {} : { maxRetries: options.maxRetries },
3142
3233
  origin: resolved.runtime.sashOrigin,
3143
3234
  proxyFromEnvironment: resolved.proxyFromEnvironment,
3235
+ ...options.networkProxy === void 0 ? {} : { networkProxy: options.networkProxy },
3144
3236
  requestTimeoutMs: resolved.requestTimeoutMs,
3145
3237
  streamIdleTimeoutMs: resolved.streamIdleTimeoutMs,
3146
3238
  tls: {
@@ -3236,8 +3328,8 @@ function requestsJsonOutput(argv) {
3236
3328
  //#region src/build-info.ts
3237
3329
  /** Bundled identity, never inferred from argv, environment, or an endpoint. */
3238
3330
  const QMIND_CLI_DISTRIBUTION = "global";
3239
- const QMIND_CLI_VERSION = "3.4.0";
3240
- const QMIND_CLI_BUILD_TIME = "2026-09-20T03:45:50.000Z";
3331
+ const QMIND_CLI_VERSION = "4.0.0";
3332
+ const QMIND_CLI_BUILD_TIME = "2026-10-19T13:00:47.000Z";
3241
3333
  function qmindCliPlatform() {
3242
3334
  return process.platform === "win32" ? "windows" : process.platform;
3243
3335
  }
@@ -3270,8 +3362,8 @@ const CLI_DISTRIBUTIONS = Object.freeze({
3270
3362
  gitTagSlug: "qmind-cli-cn",
3271
3363
  readmeDirectory: "readmes/cn",
3272
3364
  productNames: {
3273
- en: "Qoder China",
3274
- zhCN: "Qoder 中国版"
3365
+ en: "Qoder CN",
3366
+ zhCN: "Qoder CN"
3275
3367
  }
3276
3368
  }
3277
3369
  });
@@ -3788,18 +3880,7 @@ function goRetrieve(value) {
3788
3880
  })),
3789
3881
  promptContext: value.promptContext,
3790
3882
  total: value.total,
3791
- reranked: value.reranked,
3792
- cards: value.cards.map((card) => ({
3793
- id: card.id,
3794
- title: card.title,
3795
- content: card.content,
3796
- ...card.category === void 0 ? {} : { category: card.category },
3797
- ...card.cardType === void 0 ? {} : { cardType: card.cardType },
3798
- keywords: card.keywords,
3799
- ...card.links.length === 0 ? {} : { links: card.links },
3800
- score: card.score,
3801
- depth: card.depth
3802
- }))
3883
+ reranked: value.reranked
3803
3884
  };
3804
3885
  }
3805
3886
  function agentField(writer, name, value) {
@@ -3964,16 +4045,12 @@ function renderSourceList(value, format) {
3964
4045
  }
3965
4046
  return writer.toString();
3966
4047
  }
3967
- function renderRetrieve(value, format) {
3968
- const cards = "cards" in value ? value.cards : [];
3969
- if (format === "json") return json("cards" in value ? goRetrieve(value) : value, true);
3970
- if (format === "ndjson") return [...value.chunks.map((item) => ({
4048
+ function renderRetrieve(value, format, multiNotebook = false) {
4049
+ if (format === "json") return json(multiNotebook ? value : goRetrieve(value), true);
4050
+ if (format === "ndjson") return value.chunks.map((item) => json({
3971
4051
  kind: "chunk",
3972
4052
  ...item
3973
- })), ...cards.map((item) => ({
3974
- kind: "card",
3975
- ...item
3976
- }))].map((item) => json(item, false)).join("");
4053
+ }, false)).join("");
3977
4054
  const writer = new TextWriter();
3978
4055
  if (format === "agent") {
3979
4056
  agentHeader(writer, "notebookContext", value.total);
@@ -3995,19 +4072,6 @@ function renderRetrieve(value, format) {
3995
4072
  agentField(writer, "tokenCount", chunk.tokenCount);
3996
4073
  agentText(writer, "content", unescapeText(chunk.content));
3997
4074
  });
3998
- cards.forEach((card, index) => {
3999
- writer.line("---");
4000
- agentField(writer, "type", "retrievedCard");
4001
- agentField(writer, "index", index + 1);
4002
- agentField(writer, "id", card.id);
4003
- agentField(writer, "title", card.title);
4004
- agentField(writer, "category", card.category);
4005
- agentField(writer, "cardType", card.cardType);
4006
- agentField(writer, "score", card.score.toFixed(4));
4007
- agentField(writer, "depth", card.depth);
4008
- if (card.keywords.length > 0) agentField(writer, "keywords", card.keywords.join(", "));
4009
- agentText(writer, "content", unescapeText(card.content));
4010
- });
4011
4075
  value.citations.forEach((citation, index) => {
4012
4076
  writer.line("---");
4013
4077
  agentField(writer, "type", "citation");
@@ -4030,7 +4094,7 @@ function renderRetrieve(value, format) {
4030
4094
  writer.line("== Chunks ==");
4031
4095
  table(writer, [
4032
4096
  "SCORE",
4033
- ..."cards" in value ? [] : ["NOTEBOOK"],
4097
+ ...multiNotebook ? ["NOTEBOOK"] : [],
4034
4098
  "CHUNK_ID",
4035
4099
  "IDX",
4036
4100
  "SOURCE",
@@ -4044,7 +4108,7 @@ function renderRetrieve(value, format) {
4044
4108
  truncate(unescapeText(chunk.content).replace(/\n/g, " "), 50)
4045
4109
  ]), [
4046
4110
  6,
4047
- ..."cards" in value ? [] : [30],
4111
+ ...multiNotebook ? [30] : [],
4048
4112
  36,
4049
4113
  6,
4050
4114
  30,
@@ -4059,32 +4123,6 @@ function renderRetrieve(value, format) {
4059
4123
  writer.line();
4060
4124
  });
4061
4125
  }
4062
- if (cards.length > 0) {
4063
- writer.line("== Cards ==");
4064
- table(writer, [
4065
- "SCORE",
4066
- "DEPTH",
4067
- "ID",
4068
- "CATEGORY",
4069
- "TITLE",
4070
- "CONTENT"
4071
- ], cards.map((card) => [
4072
- card.score.toFixed(2),
4073
- card.depth,
4074
- truncate(card.id, 36),
4075
- truncate(card.category, 20),
4076
- truncate(card.title, 30),
4077
- truncate(unescapeText(card.content).replace(/\n/g, " "), 30)
4078
- ]), [
4079
- 6,
4080
- 5,
4081
- 36,
4082
- 20,
4083
- 30,
4084
- 30
4085
- ], 130);
4086
- writer.line();
4087
- }
4088
4126
  if (value.citations.length > 0) {
4089
4127
  writer.line("== Citations ==");
4090
4128
  value.citations.forEach((citation, index) => {
@@ -4111,7 +4149,7 @@ function renderQMindCliPresentation(presentation, format) {
4111
4149
  case "source": return renderSource(presentation.value, format);
4112
4150
  case "sourceList": return renderSourceList(presentation.value, format);
4113
4151
  case "retrieve": return renderRetrieve(presentation.value, format);
4114
- case "multiRetrieve": return renderRetrieve(presentation.value, format);
4152
+ case "multiRetrieve": return renderRetrieve(presentation.value, format, true);
4115
4153
  case "imageUpload": return json({
4116
4154
  uploadUrl: presentation.value.uploadUrl,
4117
4155
  method: presentation.value.method,
@@ -4241,10 +4279,10 @@ function batchProgress(metadata) {
4241
4279
  };
4242
4280
  switch (metadata.phase) {
4243
4281
  case "plan": return `[compile] 📋 plan: ${value("totalBatches")} batches, ${value("totalSources")} sources, ${value("totalBytes")} bytes`;
4244
- case "batch_start": return `[compile] ▶ batch ${index()}/${value("totalBatches")} start (sources=${value("batchSources")}, bytes=${value("batchBytes")}, prepared=${value("preparedCardsTotal", "0")})`;
4245
- case "batch_done": return `[compile] ✔ batch ${index()}/${value("totalBatches")} done (+${value("preparedCardsDelta", "0")} cards, total=${value("preparedCardsTotal", "0")}, steps=${value("batchStepsUsed")}, ${value("elapsedMs")}ms)`;
4282
+ case "batch_start": return `[compile] ▶ batch ${index()}/${value("totalBatches")} start (sources=${value("batchSources")}, bytes=${value("batchBytes")})`;
4283
+ case "batch_done": return `[compile] ✔ batch ${index()}/${value("totalBatches")} done (steps=${value("batchStepsUsed")}, ${value("elapsedMs")}ms)`;
4246
4284
  case "persist_start": return `[compile] 💾 persist start (drafts=${value("draftsTotal")})`;
4247
- case "persist_done": return metadata.saved === "true" ? `[compile] ✅ persisted ${value("upsertedCards", "0")} cards (failed=${value("failedCards", "0")})` : `[compile] ⚠️ persist failed: ${metadata.persistError || "not persisted"} (drafts retained for fallback save)`;
4285
+ case "persist_done": return metadata.saved === "true" ? `[compile] ✅ persisted results` : `[compile] ⚠️ persist failed: ${metadata.persistError || "not persisted"} (drafts retained for fallback save)`;
4248
4286
  default: return;
4249
4287
  }
4250
4288
  }
@@ -4984,7 +5022,7 @@ async function runQMindCli(argv, options = {}) {
4984
5022
  updater: options.updater ?? createQMindCliUpdater({ identity: {
4985
5023
  artifactKind: "npm",
4986
5024
  command: distribution.command,
4987
- currentVersion: "3.4.0",
5025
+ currentVersion: "4.0.0",
4988
5026
  distribution: distribution.id,
4989
5027
  executablePath: process.execPath,
4990
5028
  package: distribution.package,