@qoder-ai/qmind-cli 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/CHANGELOG.zh-CN.md +12 -0
- package/README.md +16 -0
- package/README.zh-CN.md +16 -0
- package/dist/{bot-gateway-C0KmAiBy.js → bot-gateway-eajGWyYA.js} +1 -1
- package/dist/{imports-CkLS3Vqu.js → imports-CebWSRju.js} +58 -1
- package/dist/{management-BqqR6Ihj.js → management-Avpo7nTn.js} +67 -4
- package/dist/{notes-B9mcsP2n.js → notes-PwqGFJvk.js} +1 -1
- package/dist/qmind.js +366 -188
- package/dist/{shared-BFU7amCH.js → shared-DsqZroGJ.js} +63 -107
- package/dist/{source-upload-D3rcA1v1.js → source-upload-DdZ0J4gC.js} +1 -1
- package/dist/{transfers-CzWL9766.js → transfers-SJE97RLg.js} +2 -2
- package/dist/wiki-branches-CNLpYYCl.js +80 -0
- package/package.json +3 -3
- package/dist/cards-YqfPPr12.js +0 -132
package/dist/qmind.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as notebookSchema, B as
|
|
2
|
-
import { t as preflightSourceUpload } from "./source-upload-
|
|
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-DsqZroGJ.js";
|
|
2
|
+
import { t as preflightSourceUpload } from "./source-upload-DdZ0J4gC.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";
|
|
@@ -346,6 +346,36 @@ function createAgentOperations(context) {
|
|
|
346
346
|
listChatSessions: (notebookId, input, options) => listChatSessionsFor(notebookId, input, options),
|
|
347
347
|
listFeaturedChatMessages: (notebookId, sessionId, input, options) => listChatMessagesFor(notebookId, sessionId, input, options, true),
|
|
348
348
|
listFeaturedChatSessions: (notebookId, input, options) => listChatSessionsFor(notebookId, input, options, true),
|
|
349
|
+
async retrieveNotebooks(input, options) {
|
|
350
|
+
if (!isRecord$3(input) || !Array.isArray(input.targets) || input.targets.length === 0) throw invalidArgument$1("targets must be a non-empty array", "targets");
|
|
351
|
+
const seen = /* @__PURE__ */ new Set();
|
|
352
|
+
const targets = input.targets.map((target) => {
|
|
353
|
+
if (!isRecord$3(target)) throw invalidArgument$1("target must be an object", "targets");
|
|
354
|
+
const notebookId = requiredString$2(target.notebookId, "notebookId");
|
|
355
|
+
if (seen.has(notebookId)) throw invalidArgument$1("targets must be unique", "targets");
|
|
356
|
+
seen.add(notebookId);
|
|
357
|
+
if (target.preference !== void 0 && target.preference !== "default" && target.preference !== "preferred") throw invalidArgument$1("preference must be default or preferred", "preference");
|
|
358
|
+
return compactUndefined({
|
|
359
|
+
notebookId,
|
|
360
|
+
sourceIds: stringList(target.sourceIds ?? [], "sourceIds"),
|
|
361
|
+
preference: target.preference
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
const { sourceIds: _sourceIds, ...body } = retrieveBody(input);
|
|
365
|
+
return call(context, {
|
|
366
|
+
body: {
|
|
367
|
+
...body,
|
|
368
|
+
targets
|
|
369
|
+
},
|
|
370
|
+
callOptions: options,
|
|
371
|
+
capability: "retrieval",
|
|
372
|
+
idempotent: false,
|
|
373
|
+
method: "POST",
|
|
374
|
+
operation: "retrieval.retrieveNotebooks",
|
|
375
|
+
path: context.profile.apiPath("notebooks", "retrieve"),
|
|
376
|
+
schema: retrieveNotebooksResultSchema
|
|
377
|
+
});
|
|
378
|
+
},
|
|
349
379
|
async retrieve(notebookId, input, options) {
|
|
350
380
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
351
381
|
return call(context, {
|
|
@@ -368,6 +398,8 @@ function createAgentOperations(context) {
|
|
|
368
398
|
//#endregion
|
|
369
399
|
//#region ../sdk/src/operations/notebooks.ts
|
|
370
400
|
function createNotebookOperations(context) {
|
|
401
|
+
let wikiOperations;
|
|
402
|
+
const loadWiki = () => wikiOperations ??= import("./wiki-branches-CNLpYYCl.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
|
|
371
403
|
return {
|
|
372
404
|
async copyFeaturedNotebook(notebookId, options) {
|
|
373
405
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
@@ -479,18 +511,8 @@ function createNotebookOperations(context) {
|
|
|
479
511
|
schema: sharedNotebookListSchema
|
|
480
512
|
});
|
|
481
513
|
},
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
return (await call(context, {
|
|
485
|
-
callOptions: options,
|
|
486
|
-
capability: "wikiBranches.read",
|
|
487
|
-
idempotent: true,
|
|
488
|
-
method: "GET",
|
|
489
|
-
operation: "wikiBranches.list",
|
|
490
|
-
path: context.profile.apiPath("notebooks", id, "wiki-branches"),
|
|
491
|
-
schema: wikiBranchListSchema
|
|
492
|
-
})).branches;
|
|
493
|
-
},
|
|
514
|
+
listWikiBranches: (...args) => loadWiki().then((loaded) => loaded.listWikiBranches(...args)),
|
|
515
|
+
listWikiBranchesPage: (...args) => loadWiki().then((loaded) => loaded.listWikiBranchesPage(...args)),
|
|
494
516
|
async updateNotebook(notebookId, input, options) {
|
|
495
517
|
const id = requiredString$2(notebookId, "notebookId");
|
|
496
518
|
const body = compactUndefined({
|
|
@@ -514,6 +536,57 @@ function createNotebookOperations(context) {
|
|
|
514
536
|
};
|
|
515
537
|
}
|
|
516
538
|
//#endregion
|
|
539
|
+
//#region ../sdk/src/source-format.ts
|
|
540
|
+
const mimeTypes = Object.freeze({
|
|
541
|
+
pdf: "application/pdf",
|
|
542
|
+
doc: "application/msword",
|
|
543
|
+
xls: "application/vnd.ms-excel",
|
|
544
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
545
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
546
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
547
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
548
|
+
jpg: "image/jpeg",
|
|
549
|
+
jpeg: "image/jpeg",
|
|
550
|
+
png: "image/png",
|
|
551
|
+
gif: "image/gif",
|
|
552
|
+
bmp: "image/bmp",
|
|
553
|
+
webp: "image/webp",
|
|
554
|
+
svg: "image/svg+xml"
|
|
555
|
+
});
|
|
556
|
+
const mimeFormats = new Map(Object.entries(mimeTypes).map(([format, mime]) => [mime, format]));
|
|
557
|
+
function isQMindSourceBinaryFormat(value) {
|
|
558
|
+
return typeof value === "string" && Object.hasOwn(mimeTypes, value);
|
|
559
|
+
}
|
|
560
|
+
function normalize(value) {
|
|
561
|
+
const format = value?.trim().toLowerCase().replace(/^\./u, "") ?? "";
|
|
562
|
+
if ([
|
|
563
|
+
"markdown",
|
|
564
|
+
"mdown",
|
|
565
|
+
"mdx"
|
|
566
|
+
].includes(format)) return "md";
|
|
567
|
+
return format === "htm" ? "html" : format;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* An explicit format is authoritative, including unknown formats. Legacy compatibility is limited
|
|
571
|
+
* to original binary formats; filenames/MIME never authorize HTML, email, or a private viewer.
|
|
572
|
+
* Callers must pass the original filename, never a user's renamed title.
|
|
573
|
+
*/
|
|
574
|
+
function normalizeQMindSourceFormat(input) {
|
|
575
|
+
const declared = normalize(input.sourceFormat);
|
|
576
|
+
if (declared) return declared;
|
|
577
|
+
const mime = input.mimeType?.split(";", 1)[0]?.trim().toLowerCase();
|
|
578
|
+
const fromMime = mime ? mimeFormats.get(mime) : void 0;
|
|
579
|
+
if (fromMime) return fromMime;
|
|
580
|
+
const extension = normalize(input.extension);
|
|
581
|
+
if (isQMindSourceBinaryFormat(extension)) return extension;
|
|
582
|
+
const filename = input.filename ?? "";
|
|
583
|
+
const fromName = filename.includes(".") ? normalize(filename.slice(filename.lastIndexOf(".") + 1)) : "";
|
|
584
|
+
if (isQMindSourceBinaryFormat(fromName)) return fromName;
|
|
585
|
+
const type = normalize(input.sourceType);
|
|
586
|
+
if (isQMindSourceBinaryFormat(type)) return type;
|
|
587
|
+
return type === "word" ? "docx" : type === "excel" ? "xlsx" : type === "powerpoint" ? "pptx" : "";
|
|
588
|
+
}
|
|
589
|
+
//#endregion
|
|
517
590
|
//#region ../sdk/src/source-email-folder.ts
|
|
518
591
|
/** The email aggregate directory marker shared by tree projection and source readers. */
|
|
519
592
|
function isQMindEmailFolder(source) {
|
|
@@ -544,9 +617,12 @@ function metadataText(source, ...keys) {
|
|
|
544
617
|
* because one MIME type can back several formats.
|
|
545
618
|
*/
|
|
546
619
|
function qmindSourceFormat(source) {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
620
|
+
return normalizeQMindSourceFormat({
|
|
621
|
+
sourceFormat: metadataText(source, "sourceFormat", "source_format"),
|
|
622
|
+
filename: source?.filename,
|
|
623
|
+
mimeType: source?.mimeType,
|
|
624
|
+
sourceType: source?.sourceType
|
|
625
|
+
});
|
|
550
626
|
}
|
|
551
627
|
function isQMindEmailSource(source) {
|
|
552
628
|
return source?.sourceType.toLowerCase() === "email" && qmindSourceFormat(source) === "eml";
|
|
@@ -588,12 +664,12 @@ function qmindSourceProvider(source) {
|
|
|
588
664
|
* do not project the binding yet.
|
|
589
665
|
*/
|
|
590
666
|
function isQMindExternalSource(source) {
|
|
591
|
-
|
|
667
|
+
const provider = qmindSourceProvider(source);
|
|
668
|
+
return source?.externalBinding !== void 0 || provider === "aliding" || provider === "repowiki";
|
|
592
669
|
}
|
|
593
670
|
[.../* @__PURE__ */ new Set(["axls", "alxs"])];
|
|
594
671
|
//#endregion
|
|
595
|
-
//#region ../sdk/src/
|
|
596
|
-
const maxImageBytes = 52428800;
|
|
672
|
+
//#region ../sdk/src/source-tree.ts
|
|
597
673
|
function sourceTreeNodeOrder(left, right) {
|
|
598
674
|
if (left.type !== right.type) return left.type === "directory" ? -1 : 1;
|
|
599
675
|
if (left.name !== right.name) return left.name < right.name ? -1 : 1;
|
|
@@ -615,24 +691,12 @@ function createsSourceCycle(source, sourcesById) {
|
|
|
615
691
|
}
|
|
616
692
|
return false;
|
|
617
693
|
}
|
|
618
|
-
function
|
|
694
|
+
function buildQMindSourceTree(sources) {
|
|
619
695
|
const sourcesById = new Map(sources.map((source) => [source.id, source]));
|
|
620
|
-
const parentIds = new Set(sources.filter((source) => sourcesById.has(source.parentSourceId) && !createsSourceCycle(source, sourcesById)).map((source) => source.parentSourceId));
|
|
621
696
|
const nodesById = /* @__PURE__ */ new Map();
|
|
622
697
|
for (const source of sources) nodesById.set(source.id, {
|
|
623
|
-
...source
|
|
624
|
-
|
|
625
|
-
isEmailFolder: isQMindEmailFolder(source),
|
|
626
|
-
isEmailAggregateMember: isQMindEmailAggregateMember(source, sources),
|
|
627
|
-
isExternalSource: isQMindExternalSource(source),
|
|
628
|
-
files: [],
|
|
629
|
-
hasChildren: source.hasChildren ?? (source.childrenCount === void 0 ? source.isDir : source.childrenCount > 0),
|
|
630
|
-
id: source.id,
|
|
631
|
-
name: source.title,
|
|
632
|
-
path: source.path,
|
|
633
|
-
sourceType: source.sourceType,
|
|
634
|
-
status: source.status,
|
|
635
|
-
type: source.isDir || parentIds.has(source.id) ? "directory" : "file"
|
|
698
|
+
...projectQMindSourceTreeNode(source, sources),
|
|
699
|
+
files: []
|
|
636
700
|
});
|
|
637
701
|
const tree = [];
|
|
638
702
|
for (const source of sources) {
|
|
@@ -645,9 +709,35 @@ function buildSourceTree(sources) {
|
|
|
645
709
|
sortSourceTree(tree);
|
|
646
710
|
return {
|
|
647
711
|
totalSize: sources.length,
|
|
648
|
-
tree
|
|
712
|
+
tree,
|
|
713
|
+
sources
|
|
649
714
|
};
|
|
650
715
|
}
|
|
716
|
+
/** A document can have children without losing its file identity or preview capability. */
|
|
717
|
+
function projectQMindSourceTreeNode(source, sources, files = []) {
|
|
718
|
+
return {
|
|
719
|
+
...source.learningStatus === void 0 ? {} : { learningStatus: source.learningStatus },
|
|
720
|
+
...source.learningErrorCode === void 0 ? {} : { learningErrorCode: source.learningErrorCode },
|
|
721
|
+
...source.externalBinding === void 0 ? {} : { externalBinding: source.externalBinding },
|
|
722
|
+
...source.originUrl === void 0 ? {} : { originUrl: source.originUrl },
|
|
723
|
+
...source.metadata === void 0 ? {} : { metadata: source.metadata },
|
|
724
|
+
isEmailFolder: isQMindEmailFolder(source),
|
|
725
|
+
isEmailAggregateMember: isQMindEmailAggregateMember(source, sources),
|
|
726
|
+
isExternalSource: isQMindExternalSource(source),
|
|
727
|
+
files,
|
|
728
|
+
hasChildren: source.hasChildren ?? (source.childrenCount === void 0 ? source.isDir : source.childrenCount > 0),
|
|
729
|
+
id: source.id,
|
|
730
|
+
name: source.title,
|
|
731
|
+
path: source.path,
|
|
732
|
+
sourceType: source.sourceType,
|
|
733
|
+
status: source.status,
|
|
734
|
+
type: source.isDir ? "directory" : "file",
|
|
735
|
+
...source.updatedAt === void 0 ? {} : { updatedAt: source.updatedAt }
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region ../sdk/src/operations/sources.ts
|
|
740
|
+
const maxImageBytes = 52428800;
|
|
651
741
|
function sourceBody(input) {
|
|
652
742
|
return compactUndefined({
|
|
653
743
|
isDir: optionalBoolean(input?.isDir, "isDir"),
|
|
@@ -853,7 +943,7 @@ function createSourceOperations(context) {
|
|
|
853
943
|
const getSourceTree = async (notebookId, options) => {
|
|
854
944
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
855
945
|
assertCapability(context.profile, "sources.tree", "sources.tree");
|
|
856
|
-
if (context.profile.access === "sash") return
|
|
946
|
+
if (context.profile.access === "sash") return buildQMindSourceTree(await collectAllSources(notebook, {}, options, "sources.tree"));
|
|
857
947
|
return call(context, {
|
|
858
948
|
callOptions: options,
|
|
859
949
|
capability: "sources.tree",
|
|
@@ -876,7 +966,7 @@ function createSourceOperations(context) {
|
|
|
876
966
|
method: "POST",
|
|
877
967
|
operation: "sources.batchDelete",
|
|
878
968
|
path: context.profile.apiPath("notebooks", notebook, "sources", "batch-delete"),
|
|
879
|
-
schema:
|
|
969
|
+
schema: batchDeleteResultSchema
|
|
880
970
|
});
|
|
881
971
|
},
|
|
882
972
|
async countSourceChildren(notebookId, parentIds, options) {
|
|
@@ -1002,6 +1092,22 @@ function createSourceOperations(context) {
|
|
|
1002
1092
|
schema: sourceSchema
|
|
1003
1093
|
});
|
|
1004
1094
|
},
|
|
1095
|
+
async retrySourceIngestion(notebookId, sourceId, input, options) {
|
|
1096
|
+
return call(context, {
|
|
1097
|
+
callOptions: options,
|
|
1098
|
+
capability: "sources.write",
|
|
1099
|
+
idempotent: true,
|
|
1100
|
+
method: "POST",
|
|
1101
|
+
operation: "sources.retryIngestion",
|
|
1102
|
+
path: context.profile.apiPath("notebooks", requiredString$2(notebookId, "notebookId"), "sources", requiredString$2(sourceId, "sourceId"), "retry"),
|
|
1103
|
+
body: {
|
|
1104
|
+
retryKey: requiredString$2(input.retryKey, "retryKey"),
|
|
1105
|
+
expectedUpdatedAt: requiredString$2(input.expectedUpdatedAt, "expectedUpdatedAt"),
|
|
1106
|
+
...input.expectedVectorRetryAt !== void 0 ? { expectedVectorRetryAt: input.expectedVectorRetryAt } : {}
|
|
1107
|
+
},
|
|
1108
|
+
schema: sourceSchema
|
|
1109
|
+
});
|
|
1110
|
+
},
|
|
1005
1111
|
async getSourceContent(notebookId, sourceId, options) {
|
|
1006
1112
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1007
1113
|
const source = requiredString$2(sourceId, "sourceId");
|
|
@@ -1052,6 +1158,17 @@ function createSourceOperations(context) {
|
|
|
1052
1158
|
schema: sourceRawContentSchema
|
|
1053
1159
|
});
|
|
1054
1160
|
},
|
|
1161
|
+
async getSourceQuota(options) {
|
|
1162
|
+
return call(context, {
|
|
1163
|
+
callOptions: options,
|
|
1164
|
+
capability: "sources.quota",
|
|
1165
|
+
idempotent: true,
|
|
1166
|
+
method: "GET",
|
|
1167
|
+
operation: "sources.quota",
|
|
1168
|
+
path: context.profile.mindPath("source-quota"),
|
|
1169
|
+
schema: sourceQuotaSchema
|
|
1170
|
+
});
|
|
1171
|
+
},
|
|
1055
1172
|
async getSourceUploadCapabilities(options) {
|
|
1056
1173
|
return call(context, {
|
|
1057
1174
|
callOptions: options,
|
|
@@ -1067,7 +1184,7 @@ function createSourceOperations(context) {
|
|
|
1067
1184
|
return preflightSourceUpload(context, notebookId, options);
|
|
1068
1185
|
},
|
|
1069
1186
|
async getFeaturedSourceTree(notebookId, options) {
|
|
1070
|
-
return
|
|
1187
|
+
return buildQMindSourceTree((await listFeaturedSources(notebookId, {
|
|
1071
1188
|
page: 1,
|
|
1072
1189
|
pageSize: 200
|
|
1073
1190
|
}, options)).sources);
|
|
@@ -1213,9 +1330,6 @@ function createSourceOperations(context) {
|
|
|
1213
1330
|
//#region ../sdk/src/capabilities.ts
|
|
1214
1331
|
const dashboardCapabilities = Object.freeze({
|
|
1215
1332
|
botGateway: true,
|
|
1216
|
-
"cards.read": true,
|
|
1217
|
-
"cards.write": true,
|
|
1218
|
-
"cards.saveResults": true,
|
|
1219
1333
|
chat: true,
|
|
1220
1334
|
"featuredChat.delete": false,
|
|
1221
1335
|
compilation: true,
|
|
@@ -1225,7 +1339,10 @@ const dashboardCapabilities = Object.freeze({
|
|
|
1225
1339
|
"images.presignUrls": false,
|
|
1226
1340
|
"imports.aliDing": true,
|
|
1227
1341
|
"imports.discover": true,
|
|
1342
|
+
"imports.fullSiteURL": true,
|
|
1228
1343
|
members: true,
|
|
1344
|
+
"members.search": true,
|
|
1345
|
+
"members.resolve": true,
|
|
1229
1346
|
"notebooks.filterByClient": false,
|
|
1230
1347
|
"notebooks.read": true,
|
|
1231
1348
|
"notebooks.write": true,
|
|
@@ -1242,6 +1359,7 @@ const dashboardCapabilities = Object.freeze({
|
|
|
1242
1359
|
"sources.preview": true,
|
|
1243
1360
|
"sources.rawContent": true,
|
|
1244
1361
|
"sources.read": true,
|
|
1362
|
+
"sources.quota": true,
|
|
1245
1363
|
"sources.search": true,
|
|
1246
1364
|
"sources.tree": true,
|
|
1247
1365
|
"sources.webOffice": true,
|
|
@@ -1249,13 +1367,11 @@ const dashboardCapabilities = Object.freeze({
|
|
|
1249
1367
|
"taskRuns.read": true,
|
|
1250
1368
|
"taskRuns.write": true,
|
|
1251
1369
|
transfers: true,
|
|
1252
|
-
"wikiBranches.read": true
|
|
1370
|
+
"wikiBranches.read": true,
|
|
1371
|
+
"wikiBranches.page": true
|
|
1253
1372
|
});
|
|
1254
1373
|
const sashCapabilities = Object.freeze({
|
|
1255
1374
|
botGateway: false,
|
|
1256
|
-
"cards.read": true,
|
|
1257
|
-
"cards.write": true,
|
|
1258
|
-
"cards.saveResults": false,
|
|
1259
1375
|
chat: true,
|
|
1260
1376
|
"featuredChat.delete": false,
|
|
1261
1377
|
compilation: false,
|
|
@@ -1265,7 +1381,10 @@ const sashCapabilities = Object.freeze({
|
|
|
1265
1381
|
"images.presignUrls": true,
|
|
1266
1382
|
"imports.aliDing": false,
|
|
1267
1383
|
"imports.discover": false,
|
|
1384
|
+
"imports.fullSiteURL": false,
|
|
1268
1385
|
members: false,
|
|
1386
|
+
"members.search": false,
|
|
1387
|
+
"members.resolve": false,
|
|
1269
1388
|
"notebooks.filterByClient": true,
|
|
1270
1389
|
"notebooks.read": true,
|
|
1271
1390
|
"notebooks.write": true,
|
|
@@ -1282,6 +1401,7 @@ const sashCapabilities = Object.freeze({
|
|
|
1282
1401
|
"sources.preview": true,
|
|
1283
1402
|
"sources.rawContent": true,
|
|
1284
1403
|
"sources.read": true,
|
|
1404
|
+
"sources.quota": false,
|
|
1285
1405
|
"sources.search": false,
|
|
1286
1406
|
"sources.tree": true,
|
|
1287
1407
|
"sources.webOffice": true,
|
|
@@ -1289,7 +1409,8 @@ const sashCapabilities = Object.freeze({
|
|
|
1289
1409
|
"taskRuns.read": true,
|
|
1290
1410
|
"taskRuns.write": true,
|
|
1291
1411
|
transfers: true,
|
|
1292
|
-
"wikiBranches.read": true
|
|
1412
|
+
"wikiBranches.read": true,
|
|
1413
|
+
"wikiBranches.page": true
|
|
1293
1414
|
});
|
|
1294
1415
|
function capabilitiesFor(access) {
|
|
1295
1416
|
return access === "sash" ? sashCapabilities : dashboardCapabilities;
|
|
@@ -1324,22 +1445,9 @@ function firstResultSource(access, operation, body) {
|
|
|
1324
1445
|
status: 200
|
|
1325
1446
|
});
|
|
1326
1447
|
}
|
|
1327
|
-
function dashboardBatchMutation(body) {
|
|
1328
|
-
if (!isRecord$1(body)) return body;
|
|
1329
|
-
const successCount = typeof body.successCount === "number" ? body.successCount : body.success_count;
|
|
1330
|
-
const failureCount = typeof body.failureCount === "number" ? body.failureCount : body.failure_count;
|
|
1331
|
-
if (typeof successCount !== "number" && typeof failureCount !== "number") return body;
|
|
1332
|
-
return {
|
|
1333
|
-
...body,
|
|
1334
|
-
failureCount: typeof failureCount === "number" ? failureCount : 0,
|
|
1335
|
-
successCount: typeof successCount === "number" ? successCount : 0
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
1448
|
function normalizeSuccess(access, operation, body) {
|
|
1339
1449
|
const unwrapped = access === "dashboard" ? dashboardEnvelope(body) : body;
|
|
1340
1450
|
if (access !== "dashboard") return unwrapped;
|
|
1341
|
-
if (operation === "cards.get" && isRecord$1(unwrapped) && "card" in unwrapped) return unwrapped.card;
|
|
1342
|
-
if (operation === "cards.delete" || operation === "cards.batchDelete") return dashboardBatchMutation(unwrapped);
|
|
1343
1451
|
if (operation === "sources.create" || operation === "sources.importSite") return firstResultSource(access, operation, unwrapped);
|
|
1344
1452
|
if (operation === "transfers.source.multipart" || operation === "transfers.source.register") return firstResultSource(access, operation, unwrapped);
|
|
1345
1453
|
return unwrapped;
|
|
@@ -1506,20 +1614,16 @@ const managementOperationNames = [
|
|
|
1506
1614
|
"listMembers",
|
|
1507
1615
|
"listScheduledTasks",
|
|
1508
1616
|
"removeMember",
|
|
1617
|
+
"resolveMemberCandidate",
|
|
1509
1618
|
"saveCompilationSettings",
|
|
1619
|
+
"searchMemberCandidates",
|
|
1510
1620
|
"startCompilation",
|
|
1511
1621
|
"updateMemberPermission",
|
|
1512
1622
|
"updateScheduledTask"
|
|
1513
1623
|
];
|
|
1514
|
-
const cardOperationNames = [
|
|
1515
|
-
"batchDeleteCards",
|
|
1516
|
-
"deleteCard",
|
|
1517
|
-
"getCard",
|
|
1518
|
-
"listCards",
|
|
1519
|
-
"listFeaturedCards",
|
|
1520
|
-
"saveCompilationResult"
|
|
1521
|
-
];
|
|
1522
1624
|
const importOperationNames = [
|
|
1625
|
+
"confirmFullSiteURLImport",
|
|
1626
|
+
"discoverFullSiteURLImport",
|
|
1523
1627
|
"getAliDingImportRun",
|
|
1524
1628
|
"listAliDingImportRunItems",
|
|
1525
1629
|
"listImportProviders",
|
|
@@ -1552,7 +1656,7 @@ const botGatewayOperationNames = [
|
|
|
1552
1656
|
function createLazyTransferOperations(context) {
|
|
1553
1657
|
let operations;
|
|
1554
1658
|
const load = () => {
|
|
1555
|
-
operations ??= import("./transfers-
|
|
1659
|
+
operations ??= import("./transfers-SJE97RLg.js").then(({ createTransferOperations }) => createTransferOperations(context));
|
|
1556
1660
|
return operations;
|
|
1557
1661
|
};
|
|
1558
1662
|
return {
|
|
@@ -1563,7 +1667,7 @@ function createLazyTransferOperations(context) {
|
|
|
1563
1667
|
function createLazyBotGatewayOperations(context) {
|
|
1564
1668
|
let operations;
|
|
1565
1669
|
const load = () => {
|
|
1566
|
-
operations ??= import("./bot-gateway-
|
|
1670
|
+
operations ??= import("./bot-gateway-eajGWyYA.js").then(({ createBotGatewayOperations }) => createBotGatewayOperations(context));
|
|
1567
1671
|
return operations;
|
|
1568
1672
|
};
|
|
1569
1673
|
return Object.fromEntries(botGatewayOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1571,23 +1675,15 @@ function createLazyBotGatewayOperations(context) {
|
|
|
1571
1675
|
function createLazyNoteOperations(context) {
|
|
1572
1676
|
let operations;
|
|
1573
1677
|
const load = () => {
|
|
1574
|
-
operations ??= import("./notes-
|
|
1678
|
+
operations ??= import("./notes-PwqGFJvk.js").then(({ createNoteOperations }) => createNoteOperations(context));
|
|
1575
1679
|
return operations;
|
|
1576
1680
|
};
|
|
1577
1681
|
return Object.fromEntries(noteOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
1578
1682
|
}
|
|
1579
|
-
function createLazyCardOperations(context) {
|
|
1580
|
-
let operations;
|
|
1581
|
-
const load = () => {
|
|
1582
|
-
operations ??= import("./cards-YqfPPr12.js").then(({ createCardOperations }) => createCardOperations(context));
|
|
1583
|
-
return operations;
|
|
1584
|
-
};
|
|
1585
|
-
return Object.fromEntries(cardOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
1586
|
-
}
|
|
1587
1683
|
function createLazyImportOperations(context) {
|
|
1588
1684
|
let operations;
|
|
1589
1685
|
const load = () => {
|
|
1590
|
-
operations ??= import("./imports-
|
|
1686
|
+
operations ??= import("./imports-CebWSRju.js").then(({ createImportOperations }) => createImportOperations(context));
|
|
1591
1687
|
return operations;
|
|
1592
1688
|
};
|
|
1593
1689
|
return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1595,7 +1691,7 @@ function createLazyImportOperations(context) {
|
|
|
1595
1691
|
function createLazyManagementOperations(context) {
|
|
1596
1692
|
let operations;
|
|
1597
1693
|
const load = () => {
|
|
1598
|
-
operations ??= import("./management-
|
|
1694
|
+
operations ??= import("./management-Avpo7nTn.js").then(({ createManagementOperations }) => createManagementOperations(context));
|
|
1599
1695
|
return operations;
|
|
1600
1696
|
};
|
|
1601
1697
|
return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
@@ -1614,7 +1710,6 @@ function createQMindClient(options) {
|
|
|
1614
1710
|
access: profile.access,
|
|
1615
1711
|
capabilities: profile.capabilities,
|
|
1616
1712
|
...createNotebookOperations(context),
|
|
1617
|
-
...createLazyCardOperations(context),
|
|
1618
1713
|
...createSourceOperations(context),
|
|
1619
1714
|
...createLazyImportOperations(context),
|
|
1620
1715
|
...createLazyManagementOperations(context),
|
|
@@ -1932,18 +2027,7 @@ function createAuthenticatedQMindTransport(transport, auth, requestCredential) {
|
|
|
1932
2027
|
});
|
|
1933
2028
|
}
|
|
1934
2029
|
//#endregion
|
|
1935
|
-
//#region ../node-host/src/
|
|
1936
|
-
const fileConfigSchema = z.object({
|
|
1937
|
-
client: z.string().optional(),
|
|
1938
|
-
dashboard_url: z.string().optional(),
|
|
1939
|
-
proxy_from_env: z.boolean().optional(),
|
|
1940
|
-
request_timeout_ms: z.number().int().positive().optional(),
|
|
1941
|
-
sash_url: z.string().optional(),
|
|
1942
|
-
stream_idle_timeout_ms: z.number().int().positive().optional(),
|
|
1943
|
-
tls_ca_file: z.string().optional(),
|
|
1944
|
-
tls_reject_unauthorized: z.boolean().optional(),
|
|
1945
|
-
update_public_key: z.string().optional()
|
|
1946
|
-
}).passthrough();
|
|
2030
|
+
//#region ../node-host/src/endpoints.ts
|
|
1947
2031
|
const PRESETS = Object.freeze({
|
|
1948
2032
|
daily: {
|
|
1949
2033
|
dashboardOrigin: "https://daily.qoder.ai",
|
|
@@ -2003,6 +2087,19 @@ function resolveQMindProductEndpoints(productId, presetName, field = "env") {
|
|
|
2003
2087
|
if (preset === void 0) throw invalidConfig(`product ${JSON.stringify(productId)} has no ${JSON.stringify(presetName)} endpoints; set ${field} explicitly`, field);
|
|
2004
2088
|
return { ...preset };
|
|
2005
2089
|
}
|
|
2090
|
+
//#endregion
|
|
2091
|
+
//#region ../node-host/src/config.ts
|
|
2092
|
+
const fileConfigSchema = z.object({
|
|
2093
|
+
client: z.string().optional(),
|
|
2094
|
+
dashboard_url: z.string().optional(),
|
|
2095
|
+
proxy_from_env: z.boolean().optional(),
|
|
2096
|
+
request_timeout_ms: z.number().int().positive().optional(),
|
|
2097
|
+
sash_url: z.string().optional(),
|
|
2098
|
+
stream_idle_timeout_ms: z.number().int().positive().optional(),
|
|
2099
|
+
tls_ca_file: z.string().optional(),
|
|
2100
|
+
tls_reject_unauthorized: z.boolean().optional(),
|
|
2101
|
+
update_public_key: z.string().optional()
|
|
2102
|
+
}).passthrough();
|
|
2006
2103
|
function optionalTrimmed(value) {
|
|
2007
2104
|
const trimmed = value?.trim();
|
|
2008
2105
|
return trimmed === void 0 || trimmed.length === 0 ? void 0 : trimmed;
|
|
@@ -2413,6 +2510,62 @@ function createRequestBudgetTransport(transport, budget) {
|
|
|
2413
2510
|
};
|
|
2414
2511
|
}
|
|
2415
2512
|
//#endregion
|
|
2513
|
+
//#region ../node-host/src/networkProxy.ts
|
|
2514
|
+
/** 跨进程配置只保留受支持字段,错误中不包含可能带凭据的代理地址。 */
|
|
2515
|
+
function parseQMindNodeNetworkProxy(value) {
|
|
2516
|
+
const invalid = () => {
|
|
2517
|
+
throw new QMindError("HOST_POLICY_ERROR", "Invalid host network proxy configuration");
|
|
2518
|
+
};
|
|
2519
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return invalid();
|
|
2520
|
+
const input = value;
|
|
2521
|
+
if (input.mode === "direct" && Object.keys(input).length === 1) return { mode: "direct" };
|
|
2522
|
+
if (input.mode !== "manual" || Object.keys(input).length !== 2 || typeof input.url !== "string") return invalid();
|
|
2523
|
+
if (input.url.length > 2048 || /[\\\s?#\x00-\x1f\x7f]/.test(input.url)) return invalid();
|
|
2524
|
+
try {
|
|
2525
|
+
const url = new URL(input.url);
|
|
2526
|
+
if (!["http:", "https:"].includes(url.protocol) || !url.hostname || url.pathname !== "/" || url.search || url.hash) return invalid();
|
|
2527
|
+
return {
|
|
2528
|
+
mode: "manual",
|
|
2529
|
+
url: input.url
|
|
2530
|
+
};
|
|
2531
|
+
} catch {
|
|
2532
|
+
return invalid();
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
//#endregion
|
|
2536
|
+
//#region ../node-host/src/networkFailureCause.ts
|
|
2537
|
+
const NETWORK_CODES = /* @__PURE__ */ new Set([
|
|
2538
|
+
"ECONNREFUSED",
|
|
2539
|
+
"ECONNRESET",
|
|
2540
|
+
"ENOTFOUND",
|
|
2541
|
+
"EAI_AGAIN",
|
|
2542
|
+
"ETIMEDOUT",
|
|
2543
|
+
"ENETUNREACH",
|
|
2544
|
+
"EHOSTUNREACH",
|
|
2545
|
+
"EPIPE",
|
|
2546
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
2547
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
2548
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
2549
|
+
"UND_ERR_SOCKET",
|
|
2550
|
+
"UND_ERR_ABORTED",
|
|
2551
|
+
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
2552
|
+
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
2553
|
+
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
2554
|
+
"CERT_HAS_EXPIRED",
|
|
2555
|
+
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
2556
|
+
"ERR_TLS_CERT_ALTNAME_INVALID",
|
|
2557
|
+
"QMIND_REQUEST_TIMEOUT"
|
|
2558
|
+
]);
|
|
2559
|
+
/** Preserve only a bounded network code before discarding the original transport exception. */
|
|
2560
|
+
function networkFailureCause(cause) {
|
|
2561
|
+
for (let depth = 0; depth < 4 && typeof cause === "object" && cause !== null; depth += 1) {
|
|
2562
|
+
const record = cause;
|
|
2563
|
+
if (typeof record.code === "string" && NETWORK_CODES.has(record.code)) return { code: record.code };
|
|
2564
|
+
cause = record.cause;
|
|
2565
|
+
}
|
|
2566
|
+
return {};
|
|
2567
|
+
}
|
|
2568
|
+
//#endregion
|
|
2416
2569
|
//#region ../node-host/src/node-transport.ts
|
|
2417
2570
|
const RETRYABLE_STATUS = /* @__PURE__ */ new Set([
|
|
2418
2571
|
408,
|
|
@@ -2460,9 +2613,8 @@ function environmentValue(environment, ...keys) {
|
|
|
2460
2613
|
if (value !== void 0 && value.length > 0) return value;
|
|
2461
2614
|
}
|
|
2462
2615
|
}
|
|
2463
|
-
function tlsConnectOptions(options
|
|
2616
|
+
function tlsConnectOptions(options) {
|
|
2464
2617
|
const timeout = positiveInteger(options.connectTimeoutMs, 1e4, "connectTimeoutMs");
|
|
2465
|
-
if (!withTls) return { timeout };
|
|
2466
2618
|
const ca = options.tls?.ca;
|
|
2467
2619
|
return {
|
|
2468
2620
|
...ca === void 0 ? {} : { ca: typeof ca === "string" ? ca : [...ca] },
|
|
@@ -2471,17 +2623,34 @@ function tlsConnectOptions(options, withTls) {
|
|
|
2471
2623
|
};
|
|
2472
2624
|
}
|
|
2473
2625
|
function createDispatchers(options) {
|
|
2626
|
+
const connect = tlsConnectOptions(options);
|
|
2627
|
+
const networkProxy = options.networkProxy === void 0 ? void 0 : parseQMindNodeNetworkProxy(options.networkProxy);
|
|
2628
|
+
if (networkProxy?.mode === "manual") {
|
|
2629
|
+
const createAgent = () => new Agent({ factory(origin) {
|
|
2630
|
+
const hostname = new URL(origin).hostname.replace(/\.$/, "");
|
|
2631
|
+
return hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "[::1]" || /^127\.\d+\.\d+\.\d+$/.test(hostname) ? new Pool(origin, { connect }) : new ProxyAgent({
|
|
2632
|
+
uri: networkProxy.url,
|
|
2633
|
+
requestTls: connect,
|
|
2634
|
+
proxyTls: connect,
|
|
2635
|
+
proxyTunnel: true
|
|
2636
|
+
});
|
|
2637
|
+
} });
|
|
2638
|
+
return {
|
|
2639
|
+
host: createAgent(),
|
|
2640
|
+
signed: createAgent()
|
|
2641
|
+
};
|
|
2642
|
+
}
|
|
2474
2643
|
const environment = options.environment ?? process.env;
|
|
2475
|
-
if (options.proxyFromEnvironment === false) return {
|
|
2476
|
-
host: new Agent({ connect
|
|
2477
|
-
signed: new Agent({ connect
|
|
2644
|
+
if (networkProxy?.mode === "direct" || options.proxyFromEnvironment === false) return {
|
|
2645
|
+
host: new Agent({ connect }),
|
|
2646
|
+
signed: new Agent({ connect })
|
|
2478
2647
|
};
|
|
2479
2648
|
const httpProxy = environmentValue(environment, "HTTP_PROXY", "http_proxy");
|
|
2480
2649
|
const httpsProxy = environmentValue(environment, "HTTPS_PROXY", "https_proxy");
|
|
2481
2650
|
const noProxy = environmentValue(environment, "NO_PROXY", "no_proxy");
|
|
2482
2651
|
if (httpProxy === void 0 && httpsProxy === void 0) return {
|
|
2483
|
-
host: new Agent({ connect
|
|
2484
|
-
signed: new Agent({ connect
|
|
2652
|
+
host: new Agent({ connect }),
|
|
2653
|
+
signed: new Agent({ connect })
|
|
2485
2654
|
};
|
|
2486
2655
|
const proxy = {
|
|
2487
2656
|
httpProxy: httpProxy ?? "",
|
|
@@ -2491,11 +2660,11 @@ function createDispatchers(options) {
|
|
|
2491
2660
|
return {
|
|
2492
2661
|
host: new EnvHttpProxyAgent({
|
|
2493
2662
|
...proxy,
|
|
2494
|
-
requestTls:
|
|
2663
|
+
requestTls: connect
|
|
2495
2664
|
}),
|
|
2496
2665
|
signed: new EnvHttpProxyAgent({
|
|
2497
2666
|
...proxy,
|
|
2498
|
-
requestTls:
|
|
2667
|
+
requestTls: connect
|
|
2499
2668
|
})
|
|
2500
2669
|
};
|
|
2501
2670
|
}
|
|
@@ -2638,22 +2807,15 @@ function encodeBody(request, boundary) {
|
|
|
2638
2807
|
};
|
|
2639
2808
|
}
|
|
2640
2809
|
function isTimeoutCause(cause) {
|
|
2641
|
-
const code = cause.code;
|
|
2642
|
-
const name = cause.name;
|
|
2810
|
+
const code = networkFailureCause(cause).code;
|
|
2811
|
+
const name = typeof cause === "object" && cause !== null && "name" in cause ? cause.name : void 0;
|
|
2643
2812
|
return code === "QMIND_REQUEST_TIMEOUT" || code === "UND_ERR_CONNECT_TIMEOUT" || code === "UND_ERR_HEADERS_TIMEOUT" || code === "UND_ERR_BODY_TIMEOUT" || name === "TimeoutError";
|
|
2644
2813
|
}
|
|
2645
|
-
function safeCause(cause) {
|
|
2646
|
-
const record = cause;
|
|
2647
|
-
return {
|
|
2648
|
-
...typeof record.name === "string" ? { name: record.name } : {},
|
|
2649
|
-
...typeof record.code === "string" ? { code: record.code } : {}
|
|
2650
|
-
};
|
|
2651
|
-
}
|
|
2652
2814
|
function transportFailure(request, cause, deadlineExpired = false) {
|
|
2653
2815
|
if (cause instanceof QMindError) return cause;
|
|
2654
2816
|
if (request.signal?.aborted === true) return new QMindError("ABORTED", "QMind request was aborted");
|
|
2655
|
-
if (deadlineExpired || isTimeoutCause(cause)) return new QMindError("TIMEOUT", "QMind request timed out", { cause:
|
|
2656
|
-
return new QMindError("NETWORK_ERROR", "QMind network request failed", { cause:
|
|
2817
|
+
if (deadlineExpired || isTimeoutCause(cause)) return new QMindError("TIMEOUT", "QMind request timed out", { cause: networkFailureCause(cause) });
|
|
2818
|
+
return new QMindError("NETWORK_ERROR", "QMind network request failed", { cause: networkFailureCause(cause) });
|
|
2657
2819
|
}
|
|
2658
2820
|
function requestDeadline(signal, milliseconds) {
|
|
2659
2821
|
const controller = new AbortController();
|
|
@@ -2741,8 +2903,8 @@ async function* decodedEvents(body, request, disposeSignal) {
|
|
|
2741
2903
|
} catch (cause) {
|
|
2742
2904
|
if (cause instanceof QMindError) throw cause;
|
|
2743
2905
|
if (request.signal?.aborted === true) throw new QMindError("ABORTED", "QMind stream was aborted");
|
|
2744
|
-
if (isTimeoutCause(cause)) throw new QMindError("TIMEOUT", "QMind stream timed out", { cause:
|
|
2745
|
-
throw new QMindError("STREAM_ERROR", "QMind SSE stream failed", { cause:
|
|
2906
|
+
if (isTimeoutCause(cause)) throw new QMindError("TIMEOUT", "QMind stream timed out", { cause: networkFailureCause(cause) });
|
|
2907
|
+
throw new QMindError("STREAM_ERROR", "QMind SSE stream failed", { cause: networkFailureCause(cause) });
|
|
2746
2908
|
} finally {
|
|
2747
2909
|
disposeSignal();
|
|
2748
2910
|
body.destroy();
|
|
@@ -2756,6 +2918,35 @@ function createQMindNodeTransport(options) {
|
|
|
2756
2918
|
const dispatchers = createDispatchers(options);
|
|
2757
2919
|
const dispatcherFor = (request) => request.destination.kind === "host" ? dispatchers.host : dispatchers.signed;
|
|
2758
2920
|
return Object.freeze({
|
|
2921
|
+
async fetchSigned(url, signal) {
|
|
2922
|
+
let destination = url;
|
|
2923
|
+
for (let redirects = 0;; redirects++) {
|
|
2924
|
+
assertWireRequest({
|
|
2925
|
+
destination: {
|
|
2926
|
+
kind: "signed",
|
|
2927
|
+
url: destination
|
|
2928
|
+
},
|
|
2929
|
+
method: "GET",
|
|
2930
|
+
idempotent: true
|
|
2931
|
+
});
|
|
2932
|
+
const response = await fetch$1(destination, {
|
|
2933
|
+
dispatcher: dispatchers.signed,
|
|
2934
|
+
signal,
|
|
2935
|
+
redirect: "manual"
|
|
2936
|
+
});
|
|
2937
|
+
if (![
|
|
2938
|
+
301,
|
|
2939
|
+
302,
|
|
2940
|
+
303,
|
|
2941
|
+
307,
|
|
2942
|
+
308
|
|
2943
|
+
].includes(response.status)) return response;
|
|
2944
|
+
const location = response.headers.get("location");
|
|
2945
|
+
await response.body?.cancel();
|
|
2946
|
+
if (!location || redirects >= 3) throw invalidArgument("Invalid signed response redirect", "url");
|
|
2947
|
+
destination = new URL(location, destination).href;
|
|
2948
|
+
}
|
|
2949
|
+
},
|
|
2759
2950
|
async close() {
|
|
2760
2951
|
const unique = /* @__PURE__ */ new Set([dispatchers.host, dispatchers.signed]);
|
|
2761
2952
|
await Promise.all([...unique].map(async (dispatcher) => dispatcher.close()));
|
|
@@ -3009,6 +3200,7 @@ async function createQMindCliHost(options = {}) {
|
|
|
3009
3200
|
...options.maxRetries === void 0 ? {} : { maxRetries: options.maxRetries },
|
|
3010
3201
|
origin: resolved.runtime.sashOrigin,
|
|
3011
3202
|
proxyFromEnvironment: resolved.proxyFromEnvironment,
|
|
3203
|
+
...options.networkProxy === void 0 ? {} : { networkProxy: options.networkProxy },
|
|
3012
3204
|
requestTimeoutMs: resolved.requestTimeoutMs,
|
|
3013
3205
|
streamIdleTimeoutMs: resolved.streamIdleTimeoutMs,
|
|
3014
3206
|
tls: {
|
|
@@ -3104,8 +3296,8 @@ function requestsJsonOutput(argv) {
|
|
|
3104
3296
|
//#region src/build-info.ts
|
|
3105
3297
|
/** Bundled identity, never inferred from argv, environment, or an endpoint. */
|
|
3106
3298
|
const QMIND_CLI_DISTRIBUTION = "global";
|
|
3107
|
-
const QMIND_CLI_VERSION = "3.
|
|
3108
|
-
const QMIND_CLI_BUILD_TIME = "2026-09-
|
|
3299
|
+
const QMIND_CLI_VERSION = "3.5.0";
|
|
3300
|
+
const QMIND_CLI_BUILD_TIME = "2026-09-28T09:35:44.000Z";
|
|
3109
3301
|
function qmindCliPlatform() {
|
|
3110
3302
|
return process.platform === "win32" ? "windows" : process.platform;
|
|
3111
3303
|
}
|
|
@@ -3656,18 +3848,7 @@ function goRetrieve(value) {
|
|
|
3656
3848
|
})),
|
|
3657
3849
|
promptContext: value.promptContext,
|
|
3658
3850
|
total: value.total,
|
|
3659
|
-
reranked: value.reranked
|
|
3660
|
-
cards: value.cards.map((card) => ({
|
|
3661
|
-
id: card.id,
|
|
3662
|
-
title: card.title,
|
|
3663
|
-
content: card.content,
|
|
3664
|
-
...card.category === void 0 ? {} : { category: card.category },
|
|
3665
|
-
...card.cardType === void 0 ? {} : { cardType: card.cardType },
|
|
3666
|
-
keywords: card.keywords,
|
|
3667
|
-
...card.links.length === 0 ? {} : { links: card.links },
|
|
3668
|
-
score: card.score,
|
|
3669
|
-
depth: card.depth
|
|
3670
|
-
}))
|
|
3851
|
+
reranked: value.reranked
|
|
3671
3852
|
};
|
|
3672
3853
|
}
|
|
3673
3854
|
function agentField(writer, name, value) {
|
|
@@ -3832,15 +4013,12 @@ function renderSourceList(value, format) {
|
|
|
3832
4013
|
}
|
|
3833
4014
|
return writer.toString();
|
|
3834
4015
|
}
|
|
3835
|
-
function renderRetrieve(value, format) {
|
|
3836
|
-
if (format === "json") return json(goRetrieve(value), true);
|
|
3837
|
-
if (format === "ndjson") return
|
|
4016
|
+
function renderRetrieve(value, format, multiNotebook = false) {
|
|
4017
|
+
if (format === "json") return json(multiNotebook ? value : goRetrieve(value), true);
|
|
4018
|
+
if (format === "ndjson") return value.chunks.map((item) => json({
|
|
3838
4019
|
kind: "chunk",
|
|
3839
4020
|
...item
|
|
3840
|
-
}))
|
|
3841
|
-
kind: "card",
|
|
3842
|
-
...item
|
|
3843
|
-
}))].map((item) => json(item, false)).join("");
|
|
4021
|
+
}, false)).join("");
|
|
3844
4022
|
const writer = new TextWriter();
|
|
3845
4023
|
if (format === "agent") {
|
|
3846
4024
|
agentHeader(writer, "notebookContext", value.total);
|
|
@@ -3848,6 +4026,10 @@ function renderRetrieve(value, format) {
|
|
|
3848
4026
|
value.chunks.forEach((chunk, index) => {
|
|
3849
4027
|
writer.line("---");
|
|
3850
4028
|
agentField(writer, "type", "chunk");
|
|
4029
|
+
if ("notebookId" in chunk && "notebookTitle" in chunk) {
|
|
4030
|
+
agentField(writer, "notebookId", chunk.notebookId);
|
|
4031
|
+
agentField(writer, "notebookTitle", chunk.notebookTitle);
|
|
4032
|
+
}
|
|
3851
4033
|
agentField(writer, "index", index + 1);
|
|
3852
4034
|
agentField(writer, "chunkId", chunk.chunkId);
|
|
3853
4035
|
agentField(writer, "chunkIndex", chunk.chunkIndex);
|
|
@@ -3858,22 +4040,13 @@ function renderRetrieve(value, format) {
|
|
|
3858
4040
|
agentField(writer, "tokenCount", chunk.tokenCount);
|
|
3859
4041
|
agentText(writer, "content", unescapeText(chunk.content));
|
|
3860
4042
|
});
|
|
3861
|
-
value.cards.forEach((card, index) => {
|
|
3862
|
-
writer.line("---");
|
|
3863
|
-
agentField(writer, "type", "retrievedCard");
|
|
3864
|
-
agentField(writer, "index", index + 1);
|
|
3865
|
-
agentField(writer, "id", card.id);
|
|
3866
|
-
agentField(writer, "title", card.title);
|
|
3867
|
-
agentField(writer, "category", card.category);
|
|
3868
|
-
agentField(writer, "cardType", card.cardType);
|
|
3869
|
-
agentField(writer, "score", card.score.toFixed(4));
|
|
3870
|
-
agentField(writer, "depth", card.depth);
|
|
3871
|
-
if (card.keywords.length > 0) agentField(writer, "keywords", card.keywords.join(", "));
|
|
3872
|
-
agentText(writer, "content", unescapeText(card.content));
|
|
3873
|
-
});
|
|
3874
4043
|
value.citations.forEach((citation, index) => {
|
|
3875
4044
|
writer.line("---");
|
|
3876
4045
|
agentField(writer, "type", "citation");
|
|
4046
|
+
if ("notebookId" in citation && "notebookTitle" in citation) {
|
|
4047
|
+
agentField(writer, "notebookId", citation.notebookId);
|
|
4048
|
+
agentField(writer, "notebookTitle", citation.notebookTitle);
|
|
4049
|
+
}
|
|
3877
4050
|
agentField(writer, "index", index + 1);
|
|
3878
4051
|
agentField(writer, "sourceId", citation.sourceId);
|
|
3879
4052
|
agentField(writer, "sourceTitle", citation.sourceTitle);
|
|
@@ -3889,18 +4062,21 @@ function renderRetrieve(value, format) {
|
|
|
3889
4062
|
writer.line("== Chunks ==");
|
|
3890
4063
|
table(writer, [
|
|
3891
4064
|
"SCORE",
|
|
4065
|
+
...multiNotebook ? ["NOTEBOOK"] : [],
|
|
3892
4066
|
"CHUNK_ID",
|
|
3893
4067
|
"IDX",
|
|
3894
4068
|
"SOURCE",
|
|
3895
4069
|
"CONTENT"
|
|
3896
4070
|
], value.chunks.map((chunk) => [
|
|
3897
4071
|
chunk.score.toFixed(2),
|
|
4072
|
+
..."notebookId" in chunk ? [truncate(chunk.notebookTitle || chunk.notebookId, 30)] : [],
|
|
3898
4073
|
truncate(chunk.chunkId, 36),
|
|
3899
4074
|
chunk.chunkIndex,
|
|
3900
4075
|
truncate(chunk.sourceTitle, 30),
|
|
3901
4076
|
truncate(unescapeText(chunk.content).replace(/\n/g, " "), 50)
|
|
3902
4077
|
]), [
|
|
3903
4078
|
6,
|
|
4079
|
+
...multiNotebook ? [30] : [],
|
|
3904
4080
|
36,
|
|
3905
4081
|
6,
|
|
3906
4082
|
30,
|
|
@@ -3909,41 +4085,17 @@ function renderRetrieve(value, format) {
|
|
|
3909
4085
|
writer.line();
|
|
3910
4086
|
value.chunks.forEach((chunk, index) => {
|
|
3911
4087
|
writer.line(`[${index + 1}] chunkId=${chunk.chunkId} sourceId=${chunk.sourceId} sourceTitle=${chunk.sourceTitle} score=${chunk.score.toFixed(4)} tokens=${chunk.tokenCount}`);
|
|
4088
|
+
if ("notebookId" in chunk && "notebookTitle" in chunk) writer.line(` notebookId: ${oneLine(chunk.notebookId)} notebookTitle: ${oneLine(chunk.notebookTitle)}`);
|
|
3912
4089
|
if (chunk.sourceUri.length > 0) writer.line(` uri: ${chunk.sourceUri}`);
|
|
3913
4090
|
if (chunk.content.length > 0) writer.line(` content: ${unescapeText(chunk.content)}`);
|
|
3914
4091
|
writer.line();
|
|
3915
4092
|
});
|
|
3916
4093
|
}
|
|
3917
|
-
if (value.cards.length > 0) {
|
|
3918
|
-
writer.line("== Cards ==");
|
|
3919
|
-
table(writer, [
|
|
3920
|
-
"SCORE",
|
|
3921
|
-
"DEPTH",
|
|
3922
|
-
"ID",
|
|
3923
|
-
"CATEGORY",
|
|
3924
|
-
"TITLE",
|
|
3925
|
-
"CONTENT"
|
|
3926
|
-
], value.cards.map((card) => [
|
|
3927
|
-
card.score.toFixed(2),
|
|
3928
|
-
card.depth,
|
|
3929
|
-
truncate(card.id, 36),
|
|
3930
|
-
truncate(card.category, 20),
|
|
3931
|
-
truncate(card.title, 30),
|
|
3932
|
-
truncate(unescapeText(card.content).replace(/\n/g, " "), 30)
|
|
3933
|
-
]), [
|
|
3934
|
-
6,
|
|
3935
|
-
5,
|
|
3936
|
-
36,
|
|
3937
|
-
20,
|
|
3938
|
-
30,
|
|
3939
|
-
30
|
|
3940
|
-
], 130);
|
|
3941
|
-
writer.line();
|
|
3942
|
-
}
|
|
3943
4094
|
if (value.citations.length > 0) {
|
|
3944
4095
|
writer.line("== Citations ==");
|
|
3945
4096
|
value.citations.forEach((citation, index) => {
|
|
3946
4097
|
writer.line(`[${index + 1}] sourceId=${citation.sourceId} sourceTitle=${citation.sourceTitle} chunkId=${citation.chunkId}`);
|
|
4098
|
+
if ("notebookId" in citation && "notebookTitle" in citation) writer.line(` notebookId: ${oneLine(citation.notebookId)} notebookTitle: ${oneLine(citation.notebookTitle)}`);
|
|
3947
4099
|
if (citation.snippet.length > 0) writer.line(` snippet: ${oneLine(unescapeText(citation.snippet))}`);
|
|
3948
4100
|
});
|
|
3949
4101
|
writer.line();
|
|
@@ -3965,6 +4117,7 @@ function renderQMindCliPresentation(presentation, format) {
|
|
|
3965
4117
|
case "source": return renderSource(presentation.value, format);
|
|
3966
4118
|
case "sourceList": return renderSourceList(presentation.value, format);
|
|
3967
4119
|
case "retrieve": return renderRetrieve(presentation.value, format);
|
|
4120
|
+
case "multiRetrieve": return renderRetrieve(presentation.value, format, true);
|
|
3968
4121
|
case "imageUpload": return json({
|
|
3969
4122
|
uploadUrl: presentation.value.uploadUrl,
|
|
3970
4123
|
method: presentation.value.method,
|
|
@@ -4094,10 +4247,10 @@ function batchProgress(metadata) {
|
|
|
4094
4247
|
};
|
|
4095
4248
|
switch (metadata.phase) {
|
|
4096
4249
|
case "plan": return `[compile] 📋 plan: ${value("totalBatches")} batches, ${value("totalSources")} sources, ${value("totalBytes")} bytes`;
|
|
4097
|
-
case "batch_start": return `[compile] ▶ batch ${index()}/${value("totalBatches")} start (sources=${value("batchSources")}, bytes=${value("batchBytes")}
|
|
4098
|
-
case "batch_done": return `[compile] ✔ batch ${index()}/${value("totalBatches")} done (
|
|
4250
|
+
case "batch_start": return `[compile] ▶ batch ${index()}/${value("totalBatches")} start (sources=${value("batchSources")}, bytes=${value("batchBytes")})`;
|
|
4251
|
+
case "batch_done": return `[compile] ✔ batch ${index()}/${value("totalBatches")} done (steps=${value("batchStepsUsed")}, ${value("elapsedMs")}ms)`;
|
|
4099
4252
|
case "persist_start": return `[compile] 💾 persist start (drafts=${value("draftsTotal")})`;
|
|
4100
|
-
case "persist_done": return metadata.saved === "true" ? `[compile] ✅ persisted
|
|
4253
|
+
case "persist_done": return metadata.saved === "true" ? `[compile] ✅ persisted results` : `[compile] ⚠️ persist failed: ${metadata.persistError || "not persisted"} (drafts retained for fallback save)`;
|
|
4101
4254
|
default: return;
|
|
4102
4255
|
}
|
|
4103
4256
|
}
|
|
@@ -4396,6 +4549,11 @@ function positiveNumberOption(options, key, fallback) {
|
|
|
4396
4549
|
function splitCsv(value) {
|
|
4397
4550
|
return value?.split(",").map((item) => item.trim()).filter(Boolean) ?? [];
|
|
4398
4551
|
}
|
|
4552
|
+
function collectNotebookIds(value, previous) {
|
|
4553
|
+
const ids = value.split(",").map((id) => id.trim());
|
|
4554
|
+
if (ids.some((id) => id.length === 0)) throw new QMindError("INVALID_ARGUMENT", "--nb must contain non-empty notebook IDs");
|
|
4555
|
+
return [.../* @__PURE__ */ new Set([...previous, ...ids])];
|
|
4556
|
+
}
|
|
4399
4557
|
function formatOf(options) {
|
|
4400
4558
|
return parseQMindCliOutputFormat(String(options.format ?? "table"));
|
|
4401
4559
|
}
|
|
@@ -4495,14 +4653,34 @@ function registerCoreCommands(context, program) {
|
|
|
4495
4653
|
await (await hostFor(context, raw)).client.deleteNotebook(notebookId);
|
|
4496
4654
|
context.io.stdout("deleted\n");
|
|
4497
4655
|
});
|
|
4498
|
-
withCommon(program.command("retrieve [query]").description("Retrieve
|
|
4656
|
+
withCommon(program.command("retrieve [query]").description("Retrieve context from one or more notebooks without an LLM call")).option("--nb <ids>", "notebook IDs (required, comma-separated or repeatable, maximum 5)", collectNotebookIds, []).option("-q, --query <query>", "retrieval query").option("--sources <ids>", "comma-separated source IDs (single notebook only)", "").option("--top-k <number>", "joint recall candidate limit", integer, 0).option("--max-results <number>", "maximum context results across selected notebooks", integer, 0).action(async (query, raw) => {
|
|
4657
|
+
const notebookIds = raw.nb;
|
|
4658
|
+
const [notebookId] = notebookIds;
|
|
4659
|
+
if (notebookId === void 0) throw new QMindError("INVALID_ARGUMENT", "--nb is required");
|
|
4660
|
+
if (notebookIds.length > 5) throw new QMindError("INVALID_ARGUMENT", "--nb accepts at most 5 distinct notebook IDs");
|
|
4661
|
+
const input = {
|
|
4662
|
+
maxResults: numberOption(raw, "maxResults", 0),
|
|
4663
|
+
query: requiredString(raw.query || query, "--query or positional query"),
|
|
4664
|
+
sourceIds: splitCsv(stringOption(raw, "sources")),
|
|
4665
|
+
topK: numberOption(raw, "topK", 0)
|
|
4666
|
+
};
|
|
4667
|
+
if (input.maxResults < 0 || input.topK < 0) throw new QMindError("INVALID_ARGUMENT", "--top-k and --max-results must be non-negative");
|
|
4668
|
+
if (notebookIds.length > 1 && input.sourceIds.length > 0) throw new QMindError("INVALID_ARGUMENT", "--sources requires a single notebook");
|
|
4669
|
+
const host = await hostFor(context, raw);
|
|
4670
|
+
if (notebookIds.length === 1) {
|
|
4671
|
+
render(context, raw, {
|
|
4672
|
+
kind: "retrieve",
|
|
4673
|
+
value: await host.client.retrieve(notebookId, input)
|
|
4674
|
+
});
|
|
4675
|
+
return;
|
|
4676
|
+
}
|
|
4499
4677
|
render(context, raw, {
|
|
4500
|
-
kind: "
|
|
4501
|
-
value: await
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4678
|
+
kind: "multiRetrieve",
|
|
4679
|
+
value: await host.client.retrieveNotebooks({
|
|
4680
|
+
query: input.query,
|
|
4681
|
+
topK: input.topK,
|
|
4682
|
+
maxResults: input.maxResults,
|
|
4683
|
+
targets: notebookIds.map((notebookId) => ({ notebookId }))
|
|
4506
4684
|
})
|
|
4507
4685
|
});
|
|
4508
4686
|
});
|
|
@@ -4812,7 +4990,7 @@ async function runQMindCli(argv, options = {}) {
|
|
|
4812
4990
|
updater: options.updater ?? createQMindCliUpdater({ identity: {
|
|
4813
4991
|
artifactKind: "npm",
|
|
4814
4992
|
command: distribution.command,
|
|
4815
|
-
currentVersion: "3.
|
|
4993
|
+
currentVersion: "3.5.0",
|
|
4816
4994
|
distribution: distribution.id,
|
|
4817
4995
|
executablePath: process.execPath,
|
|
4818
4996
|
package: distribution.package,
|