@qoder-ai/qmind-cli 2.0.0 → 3.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/CHANGELOG.md +27 -1
- package/CHANGELOG.zh-CN.md +70 -0
- package/README.md +44 -63
- package/README.zh-CN.md +91 -0
- package/dist/cards-2J6ebaI0.js +75 -0
- package/dist/imports-Da88W09Q.js +126 -0
- package/dist/management-xYuUDFtg.js +312 -0
- package/dist/qmind.js +731 -1048
- package/dist/shared-DwycozMA.js +1147 -0
- package/package.json +7 -13
package/dist/qmind.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { $ as executeStream, A as retrieveResultSchema, B as sourceTreeSchema, C as chatSessionListSchema, E as imageUrlsSchema, F as sourceImportResultsSchema, G as streamWireEventSchema, H as sourceUploadTicketSchema, I as sourceListSchema, J as voidResponseSchema, K as taskRunListSchema, L as sourcePreviewSchema, M as sourceActionAccessSchema, N as sourceChildrenCountsSchema, O as notebookListSchema, P as sourceContentSchema, Q as assertCapability, R as sourceRawContentSchema, S as chatMessageListSchema, T as imageUploadTicketSchema, U as sourceWebOfficeSessionSchema, V as sourceUploadCapabilitiesSchema, W as sourceWebOfficeTokenSchema, X as QMIND_MULTIPART_UPLOAD_MAX_BYTES, Y as wikiBranchListSchema, Z as QMIND_SOURCE_UPLOAD_MAX_BYTES, a as invalidArgument$1, c as optionalRecord, d as pagination$1, et as executeUnary, f as positiveInteger$1, h as stringList, i as httpUrl, j as sharedNotebookListSchema, k as notebookSchema, l as optionalString$1, m as requiredString$2, n as call, o as nonNegativeInteger$1, p as queryPath, q as taskRunSchema, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, tt as QMindError, u as optionalTrimmedString, v as batchMutationResultSchema, w as chatSessionSchema, y as cancelQuestionResultSchema, z as sourceSchema } from "./shared-DwycozMA.js";
|
|
1
2
|
import { createInterface } from "node:readline/promises";
|
|
3
|
+
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
2
4
|
import { z } from "zod";
|
|
3
|
-
import { Command, CommanderError, Option } from "commander";
|
|
4
5
|
import { createHash, randomBytes } from "node:crypto";
|
|
5
6
|
import { chmod, copyFile, link, lstat, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
6
7
|
import { homedir } from "node:os";
|
|
7
|
-
import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
8
8
|
import lockfile from "proper-lockfile";
|
|
9
9
|
import open from "open";
|
|
10
10
|
import { createReadStream, createWriteStream } from "node:fs";
|
|
@@ -12,782 +12,10 @@ import { Readable } from "node:stream";
|
|
|
12
12
|
import { pipeline } from "node:stream/promises";
|
|
13
13
|
import { createParser } from "eventsource-parser";
|
|
14
14
|
import { Agent, EnvHttpProxyAgent, request } from "undici";
|
|
15
|
+
import { Command, CommanderError, Option } from "commander";
|
|
15
16
|
import pLimit from "p-limit";
|
|
16
17
|
import picomatch from "picomatch";
|
|
17
18
|
import { decodeHTML } from "entities";
|
|
18
|
-
//#region ../sdk/src/errors.ts
|
|
19
|
-
var QMindError = class extends Error {
|
|
20
|
-
access;
|
|
21
|
-
code;
|
|
22
|
-
details;
|
|
23
|
-
operation;
|
|
24
|
-
rawBody;
|
|
25
|
-
requestId;
|
|
26
|
-
status;
|
|
27
|
-
upstreamCode;
|
|
28
|
-
constructor(code, message, options = {}) {
|
|
29
|
-
super(message, { cause: options.cause });
|
|
30
|
-
this.name = "QMindError";
|
|
31
|
-
this.access = options.access;
|
|
32
|
-
this.code = code;
|
|
33
|
-
this.details = options.details;
|
|
34
|
-
this.operation = options.operation;
|
|
35
|
-
this.rawBody = options.rawBody;
|
|
36
|
-
this.requestId = options.requestId;
|
|
37
|
-
this.status = options.status;
|
|
38
|
-
this.upstreamCode = options.upstreamCode;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region ../sdk/src/execution.ts
|
|
43
|
-
const credentialHeaders = /* @__PURE__ */ new Set([
|
|
44
|
-
"authorization",
|
|
45
|
-
"cookie",
|
|
46
|
-
"proxy-authorization",
|
|
47
|
-
"x-csrf-token",
|
|
48
|
-
"x-xsrf-token"
|
|
49
|
-
]);
|
|
50
|
-
function isRecord$5(value) {
|
|
51
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
52
|
-
}
|
|
53
|
-
function nestedRecord(value, key) {
|
|
54
|
-
const nested = value[key];
|
|
55
|
-
return isRecord$5(nested) ? nested : void 0;
|
|
56
|
-
}
|
|
57
|
-
function firstString(records, keys) {
|
|
58
|
-
for (const record of records) {
|
|
59
|
-
if (record === void 0) continue;
|
|
60
|
-
for (const key of keys) {
|
|
61
|
-
const value = record[key];
|
|
62
|
-
if (typeof value === "string" && value.length > 0) return value;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function headerValue(headers, name) {
|
|
67
|
-
const normalizedName = name.toLowerCase();
|
|
68
|
-
for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === normalizedName && value.length > 0) return value;
|
|
69
|
-
}
|
|
70
|
-
function errorCodeForStatus$1(status) {
|
|
71
|
-
if (status === 401) return "AUTH_REQUIRED";
|
|
72
|
-
if (status === 403) return "FORBIDDEN";
|
|
73
|
-
if (status === 404) return "NOT_FOUND";
|
|
74
|
-
if (status === 409) return "CONFLICT";
|
|
75
|
-
if (status === 429) return "RATE_LIMITED";
|
|
76
|
-
if (status >= 400 && status < 500) return "INVALID_ARGUMENT";
|
|
77
|
-
return "REMOTE_ERROR";
|
|
78
|
-
}
|
|
79
|
-
function httpError(access, operation, profile, response) {
|
|
80
|
-
const body = profile.unwrapError(response.body);
|
|
81
|
-
const root = isRecord$5(body) ? body : void 0;
|
|
82
|
-
const records = [
|
|
83
|
-
root,
|
|
84
|
-
root === void 0 ? void 0 : nestedRecord(root, "error"),
|
|
85
|
-
root === void 0 ? void 0 : nestedRecord(root, "details")
|
|
86
|
-
];
|
|
87
|
-
const upstreamCode = firstString(records, [
|
|
88
|
-
"errorCode",
|
|
89
|
-
"error_code",
|
|
90
|
-
"code"
|
|
91
|
-
]);
|
|
92
|
-
const requestId = firstString(records, ["requestId", "request_id"]) ?? headerValue(response.headers, "x-request-id") ?? headerValue(response.headers, "request-id");
|
|
93
|
-
const message = firstString(records, [
|
|
94
|
-
"message",
|
|
95
|
-
"errorMessage",
|
|
96
|
-
"error_message"
|
|
97
|
-
]) ?? `QMind request failed with HTTP ${response.status}`;
|
|
98
|
-
return new QMindError(errorCodeForStatus$1(response.status), message, {
|
|
99
|
-
access,
|
|
100
|
-
details: body,
|
|
101
|
-
operation,
|
|
102
|
-
...response.rawBody === void 0 ? {} : { rawBody: response.rawBody },
|
|
103
|
-
...requestId === void 0 ? {} : { requestId },
|
|
104
|
-
status: response.status,
|
|
105
|
-
...upstreamCode === void 0 ? {} : { upstreamCode }
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function isAbortLike(cause) {
|
|
109
|
-
return isRecord$5(cause) && (cause.name === "AbortError" && typeof cause.name === "string" || cause.code === "ABORT_ERR");
|
|
110
|
-
}
|
|
111
|
-
function transportError(access, operation, request, cause) {
|
|
112
|
-
if (cause instanceof QMindError) return cause;
|
|
113
|
-
const aborted = request.signal?.aborted === true || isAbortLike(cause);
|
|
114
|
-
return new QMindError(aborted ? "ABORTED" : "NETWORK_ERROR", aborted ? "QMind request was aborted" : "QMind transport failed", {
|
|
115
|
-
access,
|
|
116
|
-
cause,
|
|
117
|
-
operation
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
function requestWasAborted(request) {
|
|
121
|
-
return request.signal?.aborted === true;
|
|
122
|
-
}
|
|
123
|
-
function assertWireRequestInvariant(request) {
|
|
124
|
-
for (const [field, value] of [
|
|
125
|
-
["connectTimeoutMs", request.connectTimeoutMs],
|
|
126
|
-
["idleTimeoutMs", request.idleTimeoutMs],
|
|
127
|
-
["timeoutMs", request.timeoutMs]
|
|
128
|
-
]) if (!Number.isFinite(value ?? 1) || (value ?? 1) <= 0) throw new QMindError("INVALID_ARGUMENT", `${field} must be a positive finite number`, { details: { field } });
|
|
129
|
-
if (request.destination.kind === "host") {
|
|
130
|
-
if (!request.destination.path.startsWith("/") || request.destination.path.startsWith("//")) throw new QMindError("HOST_POLICY_ERROR", "host destination must be a root-relative path", { details: { destination: request.destination.kind } });
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
let url;
|
|
134
|
-
try {
|
|
135
|
-
url = new URL(request.destination.url);
|
|
136
|
-
} catch (cause) {
|
|
137
|
-
throw new QMindError("HOST_POLICY_ERROR", "signed destination must be a valid HTTPS URL", {
|
|
138
|
-
cause,
|
|
139
|
-
details: { destination: request.destination.kind }
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
if (url.protocol !== "https:" || url.username.length > 0 || url.password.length > 0) throw new QMindError("HOST_POLICY_ERROR", "signed destination must be credential-free HTTPS", { details: { destination: request.destination.kind } });
|
|
143
|
-
for (const header of Object.keys(request.headers ?? {})) if (credentialHeaders.has(header.toLowerCase())) throw new QMindError("HOST_POLICY_ERROR", "host credentials must never be sent to a signed destination", { details: {
|
|
144
|
-
destination: request.destination.kind,
|
|
145
|
-
header: header.toLowerCase()
|
|
146
|
-
} });
|
|
147
|
-
}
|
|
148
|
-
function assertCapability(profile, capability, operation) {
|
|
149
|
-
if (profile.capabilities[capability]) return;
|
|
150
|
-
throw new QMindError("UNSUPPORTED_OPERATION", `${operation} is not supported by the ${profile.access} access profile`, {
|
|
151
|
-
access: profile.access,
|
|
152
|
-
details: { capability },
|
|
153
|
-
operation
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
async function executeUnary(options) {
|
|
157
|
-
const { capability, operation, profile, request, schema, transport } = options;
|
|
158
|
-
assertCapability(profile, capability, operation);
|
|
159
|
-
assertWireRequestInvariant(request);
|
|
160
|
-
if (requestWasAborted(request)) throw new QMindError("ABORTED", "QMind request was aborted", {
|
|
161
|
-
access: profile.access,
|
|
162
|
-
operation
|
|
163
|
-
});
|
|
164
|
-
let response;
|
|
165
|
-
try {
|
|
166
|
-
response = await transport.request(request);
|
|
167
|
-
} catch (cause) {
|
|
168
|
-
throw transportError(profile.access, operation, request, cause);
|
|
169
|
-
}
|
|
170
|
-
if (response.status < 200 || response.status >= 300) throw httpError(profile.access, operation, profile, response);
|
|
171
|
-
const body = profile.unwrapSuccess(operation, response.body);
|
|
172
|
-
const parsed = schema.safeParse(body);
|
|
173
|
-
if (!parsed.success) throw new QMindError("PROTOCOL_ERROR", "server response does not match the QMind contract", {
|
|
174
|
-
access: profile.access,
|
|
175
|
-
details: { issues: parsed.error.issues },
|
|
176
|
-
operation,
|
|
177
|
-
...response.rawBody === void 0 ? {} : { rawBody: response.rawBody },
|
|
178
|
-
status: response.status
|
|
179
|
-
});
|
|
180
|
-
return parsed.data;
|
|
181
|
-
}
|
|
182
|
-
function streamContractError(profile, operation, message, details) {
|
|
183
|
-
return new QMindError("STREAM_ERROR", message, {
|
|
184
|
-
access: profile.access,
|
|
185
|
-
...details === void 0 ? {} : { details },
|
|
186
|
-
operation
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
function streamFailureResponse(response) {
|
|
190
|
-
return {
|
|
191
|
-
body: response.body,
|
|
192
|
-
headers: response.headers,
|
|
193
|
-
...response.rawBody === void 0 ? {} : { rawBody: response.rawBody },
|
|
194
|
-
status: response.status
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
async function* executeStream(options) {
|
|
198
|
-
const { capability, operation, profile, request, transport } = options;
|
|
199
|
-
assertCapability(profile, capability, operation);
|
|
200
|
-
assertWireRequestInvariant(request);
|
|
201
|
-
if (requestWasAborted(request)) throw new QMindError("ABORTED", "QMind request was aborted", {
|
|
202
|
-
access: profile.access,
|
|
203
|
-
operation
|
|
204
|
-
});
|
|
205
|
-
let response;
|
|
206
|
-
try {
|
|
207
|
-
response = await transport.stream(request);
|
|
208
|
-
} catch (cause) {
|
|
209
|
-
throw transportError(profile.access, operation, request, cause);
|
|
210
|
-
}
|
|
211
|
-
if (response.kind === "response") {
|
|
212
|
-
if (response.status >= 200 && response.status < 300) throw streamContractError(profile, operation, "stream handshake returned no event stream", { status: response.status });
|
|
213
|
-
throw httpError(profile.access, operation, profile, streamFailureResponse(response));
|
|
214
|
-
}
|
|
215
|
-
if (response.status < 200 || response.status >= 300) throw streamContractError(profile, operation, "stream handshake returned events for a failure status", { status: response.status });
|
|
216
|
-
let doneMarkerSeen = false;
|
|
217
|
-
let started = false;
|
|
218
|
-
let terminal = false;
|
|
219
|
-
try {
|
|
220
|
-
for await (const payload of response.events) {
|
|
221
|
-
if (requestWasAborted(request)) throw new QMindError("ABORTED", "QMind request was aborted", {
|
|
222
|
-
access: profile.access,
|
|
223
|
-
operation
|
|
224
|
-
});
|
|
225
|
-
if (payload.trim() === "[DONE]") {
|
|
226
|
-
if (doneMarkerSeen) throw streamContractError(profile, operation, "stream emitted more than one [DONE] marker");
|
|
227
|
-
doneMarkerSeen = true;
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
if (doneMarkerSeen) throw streamContractError(profile, operation, "stream emitted an event after [DONE]");
|
|
231
|
-
if (terminal) throw streamContractError(profile, operation, "stream emitted an event after messageComplete");
|
|
232
|
-
const event = profile.decodeStreamPayload(payload);
|
|
233
|
-
if (event.type === "error") throw streamContractError(profile, operation, event.message, { event });
|
|
234
|
-
if (event.type === "messageStart") {
|
|
235
|
-
if (started) throw streamContractError(profile, operation, "stream emitted duplicate messageStart");
|
|
236
|
-
started = true;
|
|
237
|
-
} else if (!started) throw streamContractError(profile, operation, "stream event arrived before messageStart", { eventType: event.type });
|
|
238
|
-
if (event.type === "messageComplete") terminal = true;
|
|
239
|
-
yield event;
|
|
240
|
-
}
|
|
241
|
-
} catch (cause) {
|
|
242
|
-
throw transportError(profile.access, operation, request, cause);
|
|
243
|
-
}
|
|
244
|
-
if (requestWasAborted(request)) throw new QMindError("ABORTED", "QMind request was aborted", {
|
|
245
|
-
access: profile.access,
|
|
246
|
-
operation
|
|
247
|
-
});
|
|
248
|
-
if (!terminal) throw streamContractError(profile, operation, "stream ended before messageComplete", {
|
|
249
|
-
doneMarkerSeen,
|
|
250
|
-
started
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
//#endregion
|
|
254
|
-
//#region ../sdk/src/workflows.ts
|
|
255
|
-
const QMIND_MULTIPART_UPLOAD_MAX_BYTES = 52428800;
|
|
256
|
-
const QMIND_SOURCE_UPLOAD_MAX_BYTES = 524288e3;
|
|
257
|
-
Object.freeze({
|
|
258
|
-
canceled: {
|
|
259
|
-
order: 2,
|
|
260
|
-
outcome: "canceled",
|
|
261
|
-
phase: "terminal",
|
|
262
|
-
terminal: true
|
|
263
|
-
},
|
|
264
|
-
failed: {
|
|
265
|
-
order: 2,
|
|
266
|
-
outcome: "failure",
|
|
267
|
-
phase: "terminal",
|
|
268
|
-
terminal: true
|
|
269
|
-
},
|
|
270
|
-
partial: {
|
|
271
|
-
order: 2,
|
|
272
|
-
outcome: "partial",
|
|
273
|
-
phase: "terminal",
|
|
274
|
-
terminal: true
|
|
275
|
-
},
|
|
276
|
-
pending: {
|
|
277
|
-
order: 0,
|
|
278
|
-
outcome: "none",
|
|
279
|
-
phase: "queued",
|
|
280
|
-
terminal: false
|
|
281
|
-
},
|
|
282
|
-
running: {
|
|
283
|
-
order: 1,
|
|
284
|
-
outcome: "none",
|
|
285
|
-
phase: "active",
|
|
286
|
-
terminal: false
|
|
287
|
-
},
|
|
288
|
-
success: {
|
|
289
|
-
order: 2,
|
|
290
|
-
outcome: "success",
|
|
291
|
-
phase: "terminal",
|
|
292
|
-
terminal: true
|
|
293
|
-
},
|
|
294
|
-
unknown: {
|
|
295
|
-
order: -1,
|
|
296
|
-
outcome: "none",
|
|
297
|
-
phase: "unknown",
|
|
298
|
-
terminal: false
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
function normalizeQMindTaskRunStatus(status) {
|
|
302
|
-
switch (status.trim().toLowerCase()) {
|
|
303
|
-
case "pending":
|
|
304
|
-
case "running":
|
|
305
|
-
case "success":
|
|
306
|
-
case "partial":
|
|
307
|
-
case "failed":
|
|
308
|
-
case "canceled": return status.trim().toLowerCase();
|
|
309
|
-
default: return "unknown";
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
//#endregion
|
|
313
|
-
//#region ../sdk/src/schemas.ts
|
|
314
|
-
function isRecord$4(value) {
|
|
315
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
316
|
-
}
|
|
317
|
-
const wirePageNumberSchema = z.number().int().nonnegative().optional();
|
|
318
|
-
const timestampSchema = z.union([z.string(), z.object({
|
|
319
|
-
nanos: z.number().int().optional(),
|
|
320
|
-
seconds: z.union([z.number(), z.string()])
|
|
321
|
-
})]).nullable();
|
|
322
|
-
const notebookOverviewSchema = z.object({
|
|
323
|
-
status: z.string().default("empty"),
|
|
324
|
-
summary: z.string().default(""),
|
|
325
|
-
topics: z.array(z.string()).nullish().transform((topics) => topics ?? [])
|
|
326
|
-
});
|
|
327
|
-
const notebookMaintenanceSchema = z.object({
|
|
328
|
-
lastRunAt: timestampSchema.optional(),
|
|
329
|
-
lastRunId: z.string().optional(),
|
|
330
|
-
status: z.string().default("idle")
|
|
331
|
-
});
|
|
332
|
-
const notebookAccessInfoSchema = z.object({
|
|
333
|
-
canDeleteNotebook: z.boolean(),
|
|
334
|
-
canEdit: z.boolean(),
|
|
335
|
-
canManageMembers: z.boolean(),
|
|
336
|
-
canManageTasks: z.boolean(),
|
|
337
|
-
currentUserPermission: z.string(),
|
|
338
|
-
memberCount: z.number().int().nonnegative()
|
|
339
|
-
});
|
|
340
|
-
const notebookSchema = z.object({
|
|
341
|
-
access: notebookAccessInfoSchema.nullable().optional(),
|
|
342
|
-
client: z.string().optional(),
|
|
343
|
-
createdAt: timestampSchema.optional(),
|
|
344
|
-
description: z.string().default(""),
|
|
345
|
-
id: z.string().min(1),
|
|
346
|
-
maintenance: notebookMaintenanceSchema.optional(),
|
|
347
|
-
materialCount: z.number().int().nonnegative().default(0),
|
|
348
|
-
orgId: z.string().default(""),
|
|
349
|
-
overview: notebookOverviewSchema.optional(),
|
|
350
|
-
settings: z.record(z.string(), z.unknown()).optional(),
|
|
351
|
-
sourceCount: z.number().int().nonnegative().default(0),
|
|
352
|
-
status: z.string().default("active"),
|
|
353
|
-
title: z.string(),
|
|
354
|
-
updatedAt: timestampSchema.optional(),
|
|
355
|
-
userId: z.string().default("")
|
|
356
|
-
});
|
|
357
|
-
const notebookListSchema = z.object({
|
|
358
|
-
currentPage: wirePageNumberSchema,
|
|
359
|
-
notebooks: z.array(notebookSchema).nullish().transform((notebooks) => notebooks ?? []),
|
|
360
|
-
pageSize: wirePageNumberSchema,
|
|
361
|
-
totalSize: z.number().int().nonnegative().default(0)
|
|
362
|
-
});
|
|
363
|
-
const wikiDocumentSchema = z.preprocess((value) => isRecord$4(value) ? {
|
|
364
|
-
...value,
|
|
365
|
-
contentHash: value.contentHash ?? value.content_hash,
|
|
366
|
-
contentUrl: value.contentUrl ?? value.content_url
|
|
367
|
-
} : value, z.object({
|
|
368
|
-
contentHash: z.string().default(""),
|
|
369
|
-
contentUrl: z.string().min(1),
|
|
370
|
-
language: z.string().default("")
|
|
371
|
-
}));
|
|
372
|
-
const wikiBranchSchema = z.preprocess((value) => isRecord$4(value) ? {
|
|
373
|
-
...value,
|
|
374
|
-
commitTimestamp: value.commitTimestamp ?? value.commit_timestamp,
|
|
375
|
-
knowledgeCount: value.knowledgeCount ?? value.knowledge_count,
|
|
376
|
-
repoUrl: value.repoUrl ?? value.repo_url,
|
|
377
|
-
resultVersion: value.resultVersion ?? value.result_version,
|
|
378
|
-
updatedAt: value.updatedAt ?? value.updated_at
|
|
379
|
-
} : value, z.object({
|
|
380
|
-
branch: z.string().min(1),
|
|
381
|
-
commitTimestamp: z.number().optional(),
|
|
382
|
-
documents: z.array(wikiDocumentSchema).nullish().transform((documents) => documents ?? []),
|
|
383
|
-
exists: z.boolean().optional(),
|
|
384
|
-
knowledgeCount: z.number().int().nonnegative().default(0),
|
|
385
|
-
repo: z.string().min(1),
|
|
386
|
-
repoUrl: z.string().optional(),
|
|
387
|
-
resultVersion: z.string().default(""),
|
|
388
|
-
updatedAt: timestampSchema.optional()
|
|
389
|
-
}));
|
|
390
|
-
const wikiBranchListSchema = z.object({ branches: z.array(wikiBranchSchema).nullish().transform((branches) => branches ?? []) });
|
|
391
|
-
const cardLinkSchema = z.object({
|
|
392
|
-
description: z.string().optional(),
|
|
393
|
-
linkType: z.string().default(""),
|
|
394
|
-
targetId: z.string().min(1),
|
|
395
|
-
targetTitle: z.string().optional()
|
|
396
|
-
});
|
|
397
|
-
const cardSchema = z.object({
|
|
398
|
-
branch: z.string().optional(),
|
|
399
|
-
cardType: z.string().optional(),
|
|
400
|
-
category: z.string().optional(),
|
|
401
|
-
content: z.string().default(""),
|
|
402
|
-
createdAt: timestampSchema.optional(),
|
|
403
|
-
extra: z.string().optional(),
|
|
404
|
-
id: z.string().min(1),
|
|
405
|
-
keywords: z.array(z.string()).default([]),
|
|
406
|
-
knowledgeId: z.string().optional(),
|
|
407
|
-
language: z.string().optional(),
|
|
408
|
-
links: z.array(cardLinkSchema).default([]),
|
|
409
|
-
notebookId: z.string().optional(),
|
|
410
|
-
orgId: z.string().optional(),
|
|
411
|
-
repo: z.string().optional(),
|
|
412
|
-
score: z.number().optional(),
|
|
413
|
-
source: z.string().optional(),
|
|
414
|
-
title: z.string().default(""),
|
|
415
|
-
updatedAt: timestampSchema.optional()
|
|
416
|
-
});
|
|
417
|
-
const cardCategoryCountSchema = z.object({
|
|
418
|
-
category: z.string(),
|
|
419
|
-
count: z.number().int().nonnegative()
|
|
420
|
-
});
|
|
421
|
-
const cardLanguageCountSchema = z.object({
|
|
422
|
-
count: z.number().int().nonnegative(),
|
|
423
|
-
language: z.string()
|
|
424
|
-
});
|
|
425
|
-
const cardAppliedFiltersSchema = z.object({
|
|
426
|
-
branch: z.string().optional(),
|
|
427
|
-
category: z.string().optional(),
|
|
428
|
-
language: z.string().optional(),
|
|
429
|
-
query: z.string().optional(),
|
|
430
|
-
repo: z.string().optional(),
|
|
431
|
-
source: z.string().optional()
|
|
432
|
-
});
|
|
433
|
-
const cardListSchema = z.object({
|
|
434
|
-
appliedFilters: cardAppliedFiltersSchema.optional(),
|
|
435
|
-
cards: z.array(cardSchema).nullish().transform((cards) => cards ?? []),
|
|
436
|
-
categoryCounts: z.array(cardCategoryCountSchema).nullish().transform((counts) => counts ?? []),
|
|
437
|
-
currentPage: wirePageNumberSchema,
|
|
438
|
-
languageCounts: z.array(cardLanguageCountSchema).nullish().transform((counts) => counts ?? []),
|
|
439
|
-
pageSize: wirePageNumberSchema,
|
|
440
|
-
totalSize: z.number().int().nonnegative().default(0)
|
|
441
|
-
});
|
|
442
|
-
const sourcePageInfoSchema = z.object({
|
|
443
|
-
currentPage: wirePageNumberSchema,
|
|
444
|
-
lastPage: wirePageNumberSchema,
|
|
445
|
-
nextPage: wirePageNumberSchema,
|
|
446
|
-
nextToken: z.string().optional(),
|
|
447
|
-
pageSize: wirePageNumberSchema,
|
|
448
|
-
prevPage: wirePageNumberSchema,
|
|
449
|
-
totalSize: z.number().int().nonnegative().optional()
|
|
450
|
-
});
|
|
451
|
-
const sourceSchema = z.object({
|
|
452
|
-
childrenCount: z.number().int().nonnegative().optional(),
|
|
453
|
-
createdAt: timestampSchema.optional(),
|
|
454
|
-
errorMessage: z.string().default(""),
|
|
455
|
-
filename: z.string().optional(),
|
|
456
|
-
hasChildren: z.boolean().optional(),
|
|
457
|
-
id: z.string().min(1),
|
|
458
|
-
isDir: z.boolean().default(false),
|
|
459
|
-
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
460
|
-
mimeType: z.string().optional(),
|
|
461
|
-
name: z.string().optional(),
|
|
462
|
-
notebookId: z.string().default(""),
|
|
463
|
-
orgId: z.string().default(""),
|
|
464
|
-
originUrl: z.string().optional(),
|
|
465
|
-
parentSourceId: z.string().default(""),
|
|
466
|
-
path: z.string().default(""),
|
|
467
|
-
sourceType: z.string().default(""),
|
|
468
|
-
size: z.number().int().nonnegative().optional(),
|
|
469
|
-
status: z.string().default(""),
|
|
470
|
-
title: z.string().default(""),
|
|
471
|
-
updatedAt: timestampSchema.optional(),
|
|
472
|
-
uri: z.string().default(""),
|
|
473
|
-
userId: z.string().default("")
|
|
474
|
-
});
|
|
475
|
-
const sourceListSchema = z.object({
|
|
476
|
-
currentPage: wirePageNumberSchema,
|
|
477
|
-
pageSize: wirePageNumberSchema,
|
|
478
|
-
pages: sourcePageInfoSchema.optional(),
|
|
479
|
-
sources: z.array(sourceSchema).nullish().transform((sources) => sources ?? []),
|
|
480
|
-
totalSize: z.number().int().nonnegative().optional()
|
|
481
|
-
});
|
|
482
|
-
const sourceTreeNodeSchema = z.lazy(() => z.object({
|
|
483
|
-
files: z.array(sourceTreeNodeSchema).default([]),
|
|
484
|
-
id: z.string().min(1),
|
|
485
|
-
name: z.string().default(""),
|
|
486
|
-
path: z.string().default(""),
|
|
487
|
-
sourceType: z.string().default(""),
|
|
488
|
-
status: z.string().default(""),
|
|
489
|
-
type: z.enum(["file", "directory"])
|
|
490
|
-
}));
|
|
491
|
-
const sourceTreeSchema = z.object({
|
|
492
|
-
totalSize: z.number().int().nonnegative().default(0),
|
|
493
|
-
tree: z.array(sourceTreeNodeSchema)
|
|
494
|
-
});
|
|
495
|
-
const sourceContentSchema = z.object({
|
|
496
|
-
content: z.string(),
|
|
497
|
-
contentType: z.string().default("text/markdown"),
|
|
498
|
-
size: z.number().int().nonnegative().optional(),
|
|
499
|
-
sourceId: z.string().default("")
|
|
500
|
-
});
|
|
501
|
-
const sourceImportResultSchema = z.object({
|
|
502
|
-
error: z.string().optional(),
|
|
503
|
-
source: sourceSchema.optional(),
|
|
504
|
-
url: z.string().default("")
|
|
505
|
-
});
|
|
506
|
-
const sourceImportResultsSchema = z.object({ results: z.array(sourceImportResultSchema) }).transform((value) => value.results);
|
|
507
|
-
const batchMutationResultSchema = z.object({
|
|
508
|
-
failureCount: z.number().int().nonnegative().default(0),
|
|
509
|
-
successCount: z.number().int().nonnegative().default(0)
|
|
510
|
-
});
|
|
511
|
-
const voidResponseSchema = z.unknown().transform(() => void 0);
|
|
512
|
-
const httpsUrlSchema = z.string().url().refine((value) => new URL(value).protocol === "https:", "expected an HTTPS URL");
|
|
513
|
-
const imageUploadTicketSchema = z.object({
|
|
514
|
-
expiresAt: z.string().optional(),
|
|
515
|
-
headers: z.record(z.string(), z.string()).default({}),
|
|
516
|
-
method: z.literal("PUT").default("PUT"),
|
|
517
|
-
ossKey: z.string().min(1),
|
|
518
|
-
uploadUrl: httpsUrlSchema
|
|
519
|
-
});
|
|
520
|
-
const imageUrlsSchema = z.object({
|
|
521
|
-
expiresAt: z.string().optional(),
|
|
522
|
-
urls: z.record(z.string(), httpsUrlSchema)
|
|
523
|
-
});
|
|
524
|
-
const notebookCitationSchema = z.preprocess((value) => isRecord$4(value) ? {
|
|
525
|
-
...value,
|
|
526
|
-
chunkId: value.chunkId ?? value.chunk_id,
|
|
527
|
-
chunkIndex: value.chunkIndex ?? value.chunk_index,
|
|
528
|
-
originUrl: value.originUrl ?? value.origin_url,
|
|
529
|
-
sourceId: value.sourceId ?? value.source_id,
|
|
530
|
-
sourceTitle: value.sourceTitle ?? value.source_title,
|
|
531
|
-
sourceUri: value.sourceUri ?? value.source_uri
|
|
532
|
-
} : value, z.object({
|
|
533
|
-
chunkId: z.string().default(""),
|
|
534
|
-
chunkIndex: z.number().int().nonnegative().default(0),
|
|
535
|
-
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
536
|
-
originUrl: z.string().optional(),
|
|
537
|
-
snippet: z.string().default(""),
|
|
538
|
-
sourceId: z.string().default(""),
|
|
539
|
-
sourceTitle: z.string().default(""),
|
|
540
|
-
sourceUri: z.string().default("")
|
|
541
|
-
}));
|
|
542
|
-
const chatMessageSchema = z.object({
|
|
543
|
-
chatSessionId: z.string().optional(),
|
|
544
|
-
citations: z.array(notebookCitationSchema).nullish().transform((citations) => citations === null ? [] : citations),
|
|
545
|
-
content: z.string().default(""),
|
|
546
|
-
createdAt: timestampSchema.optional(),
|
|
547
|
-
id: z.string().min(1),
|
|
548
|
-
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
549
|
-
model: z.string().optional(),
|
|
550
|
-
notebookId: z.string().optional(),
|
|
551
|
-
orgId: z.string().optional(),
|
|
552
|
-
role: z.string().default(""),
|
|
553
|
-
sceneType: z.string().optional(),
|
|
554
|
-
sequence: z.number().int().nonnegative().optional(),
|
|
555
|
-
updatedAt: timestampSchema.optional(),
|
|
556
|
-
userId: z.string().optional()
|
|
557
|
-
});
|
|
558
|
-
const streamWireEventSchema = z.object({
|
|
559
|
-
assistantMessage: chatMessageSchema.optional(),
|
|
560
|
-
assistantMessageId: z.string().optional(),
|
|
561
|
-
cancelReason: z.string().optional(),
|
|
562
|
-
canceled: z.boolean().optional(),
|
|
563
|
-
citations: z.array(z.string()).optional(),
|
|
564
|
-
delta: z.string().optional(),
|
|
565
|
-
errorMessage: z.string().optional(),
|
|
566
|
-
error: z.string().optional(),
|
|
567
|
-
eventType: z.string().optional(),
|
|
568
|
-
event_type: z.string().optional(),
|
|
569
|
-
metadata: z.record(z.string(), z.string()).optional(),
|
|
570
|
-
promptContext: z.string().optional(),
|
|
571
|
-
reranked: z.boolean().optional(),
|
|
572
|
-
step: z.number().int().optional(),
|
|
573
|
-
toolArguments: z.string().optional(),
|
|
574
|
-
toolDisplayName: z.string().optional(),
|
|
575
|
-
toolName: z.string().optional(),
|
|
576
|
-
toolResult: z.string().optional(),
|
|
577
|
-
totalContextChunks: z.number().int().nonnegative().optional(),
|
|
578
|
-
type: z.string().optional(),
|
|
579
|
-
userMessage: chatMessageSchema.optional()
|
|
580
|
-
});
|
|
581
|
-
const sourceUploadTicketSchema = z.object({
|
|
582
|
-
expiresAt: z.string().optional(),
|
|
583
|
-
headers: z.record(z.string(), z.string()).default({}),
|
|
584
|
-
method: z.literal("PUT").default("PUT"),
|
|
585
|
-
uploadUrl: httpsUrlSchema,
|
|
586
|
-
uri: z.string().min(1)
|
|
587
|
-
});
|
|
588
|
-
const chatSessionSchema = z.object({
|
|
589
|
-
createdAt: timestampSchema.optional(),
|
|
590
|
-
id: z.string().min(1),
|
|
591
|
-
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
592
|
-
modelOverride: z.string().default(""),
|
|
593
|
-
notebookId: z.string().default(""),
|
|
594
|
-
orgId: z.string().default(""),
|
|
595
|
-
sceneType: z.string().default("rag"),
|
|
596
|
-
status: z.string().default("active"),
|
|
597
|
-
title: z.string().default(""),
|
|
598
|
-
updatedAt: timestampSchema.optional(),
|
|
599
|
-
userId: z.string().default("")
|
|
600
|
-
});
|
|
601
|
-
const notebookContextChunkSchema = z.object({
|
|
602
|
-
chunkId: z.string().default(""),
|
|
603
|
-
chunkIndex: z.number().int().nonnegative().default(0),
|
|
604
|
-
content: z.string().default(""),
|
|
605
|
-
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
606
|
-
originUrl: z.string().optional(),
|
|
607
|
-
score: z.number().finite().default(0),
|
|
608
|
-
sourceId: z.string().default(""),
|
|
609
|
-
sourceTitle: z.string().default(""),
|
|
610
|
-
sourceUri: z.string().default(""),
|
|
611
|
-
tokenCount: z.number().int().nonnegative().default(0)
|
|
612
|
-
});
|
|
613
|
-
const retrievedCardLinkSchema = z.object({
|
|
614
|
-
description: z.string().optional(),
|
|
615
|
-
linkType: z.string().default(""),
|
|
616
|
-
targetId: z.string().min(1),
|
|
617
|
-
targetTitle: z.string().optional()
|
|
618
|
-
});
|
|
619
|
-
const retrievedCardSchema = z.object({
|
|
620
|
-
cardType: z.string().optional(),
|
|
621
|
-
category: z.string().optional(),
|
|
622
|
-
content: z.string().default(""),
|
|
623
|
-
depth: z.number().int().nonnegative().default(0),
|
|
624
|
-
id: z.string().min(1),
|
|
625
|
-
keywords: z.array(z.string()).default([]),
|
|
626
|
-
links: z.array(retrievedCardLinkSchema).default([]),
|
|
627
|
-
score: z.number().finite().default(0),
|
|
628
|
-
title: z.string().default("")
|
|
629
|
-
});
|
|
630
|
-
const retrieveResultSchema = z.object({
|
|
631
|
-
cards: z.array(retrievedCardSchema).default([]),
|
|
632
|
-
chunks: z.array(notebookContextChunkSchema).default([]),
|
|
633
|
-
citations: z.array(notebookCitationSchema).default([]),
|
|
634
|
-
promptContext: z.string().default(""),
|
|
635
|
-
reranked: z.boolean().default(false),
|
|
636
|
-
total: z.number().int().nonnegative().default(0)
|
|
637
|
-
});
|
|
638
|
-
const cancelQuestionResultSchema = z.object({ accepted: z.boolean() });
|
|
639
|
-
const taskRunSchema = z.object({
|
|
640
|
-
assistantMessageId: z.string().optional(),
|
|
641
|
-
chatSessionId: z.string().optional(),
|
|
642
|
-
config: z.record(z.string(), z.unknown()).optional(),
|
|
643
|
-
createdAt: timestampSchema.optional(),
|
|
644
|
-
durationMs: z.number().int().nonnegative().optional(),
|
|
645
|
-
errorMessage: z.string().optional(),
|
|
646
|
-
finishedAt: timestampSchema.optional(),
|
|
647
|
-
id: z.string().min(1),
|
|
648
|
-
message: chatMessageSchema.optional(),
|
|
649
|
-
notebookId: z.string().default(""),
|
|
650
|
-
orgId: z.string().default(""),
|
|
651
|
-
parentRunId: z.string().optional(),
|
|
652
|
-
reportMarkdown: z.string().optional(),
|
|
653
|
-
sceneType: z.string().default(""),
|
|
654
|
-
scheduledTaskId: z.string().optional(),
|
|
655
|
-
sourceId: z.string().optional(),
|
|
656
|
-
startedAt: timestampSchema.optional(),
|
|
657
|
-
stats: z.record(z.string(), z.unknown()).optional(),
|
|
658
|
-
status: z.string().default(""),
|
|
659
|
-
trigger: z.string().default(""),
|
|
660
|
-
updatedAt: timestampSchema.optional(),
|
|
661
|
-
userId: z.string().default("")
|
|
662
|
-
}).transform((value) => ({
|
|
663
|
-
...value,
|
|
664
|
-
rawStatus: value.status,
|
|
665
|
-
status: normalizeQMindTaskRunStatus(value.status)
|
|
666
|
-
}));
|
|
667
|
-
const taskRunListSchema = z.object({
|
|
668
|
-
currentPage: wirePageNumberSchema,
|
|
669
|
-
pageSize: wirePageNumberSchema,
|
|
670
|
-
runs: z.array(taskRunSchema).nullish().transform((runs) => runs ?? []),
|
|
671
|
-
totalSize: z.number().int().nonnegative().default(0)
|
|
672
|
-
});
|
|
673
|
-
//#endregion
|
|
674
|
-
//#region ../sdk/src/operations/shared.ts
|
|
675
|
-
function invalidArgument$1(message, field, details) {
|
|
676
|
-
return new QMindError("INVALID_ARGUMENT", message, { details: details ?? { field } });
|
|
677
|
-
}
|
|
678
|
-
function requiredString$2(value, field) {
|
|
679
|
-
if (typeof value !== "string" || value.trim().length === 0) throw invalidArgument$1(`${field} must be a non-empty string`, field);
|
|
680
|
-
return value.trim();
|
|
681
|
-
}
|
|
682
|
-
function optionalString$1(value, field) {
|
|
683
|
-
if (value === void 0) return void 0;
|
|
684
|
-
if (typeof value !== "string") throw invalidArgument$1(`${field} must be a string`, field);
|
|
685
|
-
return value;
|
|
686
|
-
}
|
|
687
|
-
function optionalTrimmedString(value, field) {
|
|
688
|
-
const string = optionalString$1(value, field)?.trim();
|
|
689
|
-
return string === "" ? void 0 : string;
|
|
690
|
-
}
|
|
691
|
-
function optionalRecord(value, field) {
|
|
692
|
-
if (value === void 0) return void 0;
|
|
693
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw invalidArgument$1(`${field} must be an object`, field);
|
|
694
|
-
return value;
|
|
695
|
-
}
|
|
696
|
-
function optionalBoolean(value, field) {
|
|
697
|
-
if (value === void 0) return void 0;
|
|
698
|
-
if (typeof value !== "boolean") throw invalidArgument$1(`${field} must be a boolean`, field);
|
|
699
|
-
return value;
|
|
700
|
-
}
|
|
701
|
-
function positiveInteger$1(value, field) {
|
|
702
|
-
if (value === void 0) return void 0;
|
|
703
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) throw invalidArgument$1(`${field} must be a positive integer`, field);
|
|
704
|
-
return value;
|
|
705
|
-
}
|
|
706
|
-
function nonNegativeInteger$1(value, field) {
|
|
707
|
-
if (value === void 0) return void 0;
|
|
708
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) throw invalidArgument$1(`${field} must be a non-negative integer`, field);
|
|
709
|
-
return value;
|
|
710
|
-
}
|
|
711
|
-
function pagination$1(input) {
|
|
712
|
-
const page = positiveInteger$1(input.page, "page");
|
|
713
|
-
const pageSize = positiveInteger$1(input.pageSize, "pageSize");
|
|
714
|
-
return {
|
|
715
|
-
...page === void 0 ? {} : { page },
|
|
716
|
-
...pageSize === void 0 ? {} : { pageSize }
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
function stringList(value, field, options = {}) {
|
|
720
|
-
if (!Array.isArray(value)) throw invalidArgument$1(`${field} must be an array`, field);
|
|
721
|
-
const result = [];
|
|
722
|
-
const seen = /* @__PURE__ */ new Set();
|
|
723
|
-
for (const item of value) {
|
|
724
|
-
if (typeof item !== "string") throw invalidArgument$1(`${field} must contain only strings`, field);
|
|
725
|
-
const normalized = item.trim();
|
|
726
|
-
if (normalized.length === 0 || seen.has(normalized)) continue;
|
|
727
|
-
seen.add(normalized);
|
|
728
|
-
result.push(normalized);
|
|
729
|
-
}
|
|
730
|
-
if (options.min !== void 0 && result.length < options.min) throw invalidArgument$1(`${field} must contain at least ${options.min} item(s)`, field);
|
|
731
|
-
if (options.max !== void 0 && result.length > options.max) throw invalidArgument$1(`${field} must contain at most ${options.max} item(s)`, field);
|
|
732
|
-
return result;
|
|
733
|
-
}
|
|
734
|
-
function httpUrl(value, field) {
|
|
735
|
-
const raw = requiredString$2(value, field);
|
|
736
|
-
let url;
|
|
737
|
-
try {
|
|
738
|
-
url = new URL(raw);
|
|
739
|
-
} catch (cause) {
|
|
740
|
-
throw invalidArgument$1(`${field} must be a valid HTTP(S) URL`, field, {
|
|
741
|
-
cause,
|
|
742
|
-
field
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
if (url.protocol !== "http:" && url.protocol !== "https:" || url.host.length === 0) throw invalidArgument$1(`${field} must be a valid HTTP(S) URL`, field);
|
|
746
|
-
url.hash = "";
|
|
747
|
-
return url.toString();
|
|
748
|
-
}
|
|
749
|
-
function compactUndefined(value) {
|
|
750
|
-
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== void 0));
|
|
751
|
-
}
|
|
752
|
-
function assertNonEmptyPatch(patch, field) {
|
|
753
|
-
if (Object.keys(patch).length > 0) return;
|
|
754
|
-
throw invalidArgument$1(`${field} must contain at least one change`, field);
|
|
755
|
-
}
|
|
756
|
-
function queryPath(path, entries) {
|
|
757
|
-
const query = new URLSearchParams();
|
|
758
|
-
for (const [key, value] of entries) if (value !== void 0 && value !== "") query.set(key, String(value));
|
|
759
|
-
const suffix = query.toString();
|
|
760
|
-
return suffix.length === 0 ? path : `${path}?${suffix}`;
|
|
761
|
-
}
|
|
762
|
-
function wireRequest(options) {
|
|
763
|
-
const timeoutMs = options.callOptions?.timeoutMs;
|
|
764
|
-
if (timeoutMs !== void 0 && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) throw invalidArgument$1("timeoutMs must be a positive finite number", "timeoutMs");
|
|
765
|
-
return {
|
|
766
|
-
...options.body === void 0 ? {} : { body: {
|
|
767
|
-
kind: "json",
|
|
768
|
-
value: options.body
|
|
769
|
-
} },
|
|
770
|
-
destination: {
|
|
771
|
-
kind: "host",
|
|
772
|
-
path: options.path
|
|
773
|
-
},
|
|
774
|
-
idempotent: options.idempotent,
|
|
775
|
-
method: options.method,
|
|
776
|
-
...options.callOptions?.signal === void 0 ? {} : { signal: options.callOptions.signal },
|
|
777
|
-
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
778
|
-
};
|
|
779
|
-
}
|
|
780
|
-
function call(context, options) {
|
|
781
|
-
return executeUnary({
|
|
782
|
-
capability: options.capability,
|
|
783
|
-
operation: options.operation,
|
|
784
|
-
profile: context.profile,
|
|
785
|
-
request: wireRequest(options),
|
|
786
|
-
schema: options.schema,
|
|
787
|
-
transport: context.transport
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
//#endregion
|
|
791
19
|
//#region ../sdk/src/operations/agents.ts
|
|
792
20
|
const workflowPrompt = "Follow the system prompt strictly: use the provided tools to discover, process and prepare the result, then emit the final report. Do NOT greet, do NOT ask for clarification — act immediately.";
|
|
793
21
|
function isRecord$3(value) {
|
|
@@ -931,25 +159,27 @@ function streamCallOptions(options) {
|
|
|
931
159
|
};
|
|
932
160
|
}
|
|
933
161
|
function createAgentOperations(context) {
|
|
934
|
-
const
|
|
162
|
+
const createChatSessionFor = (notebookId, input, options, featured) => {
|
|
935
163
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
936
164
|
return call(context, {
|
|
937
165
|
body: chatSessionBody(input),
|
|
938
166
|
callOptions: options,
|
|
939
|
-
capability: "chat",
|
|
167
|
+
capability: featured ? "featuredNotebooks.read" : "chat",
|
|
940
168
|
idempotent: false,
|
|
941
169
|
method: "POST",
|
|
942
|
-
operation: "chatSessions.create",
|
|
943
|
-
path: context.profile.apiPath("notebooks", notebook, "chat-sessions"),
|
|
170
|
+
operation: featured ? "featuredChatSessions.create" : "chatSessions.create",
|
|
171
|
+
path: context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions"),
|
|
944
172
|
schema: chatSessionSchema
|
|
945
173
|
});
|
|
946
174
|
};
|
|
947
|
-
const
|
|
175
|
+
const createChatSession = (notebookId, input, options) => createChatSessionFor(notebookId, input, options, false);
|
|
176
|
+
const createFeaturedChatSession = (notebookId, input, options) => createChatSessionFor(notebookId, input, options, true);
|
|
177
|
+
const streamQuestionFor = (notebookId, sessionId, input, options, featured) => {
|
|
948
178
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
949
179
|
const session = requiredString$2(sessionId, "sessionId");
|
|
950
180
|
return executeStream({
|
|
951
|
-
capability: "chat",
|
|
952
|
-
operation: "chat.stream",
|
|
181
|
+
capability: featured ? "featuredNotebooks.read" : "chat",
|
|
182
|
+
operation: featured ? "featuredChat.stream" : "chat.stream",
|
|
953
183
|
profile: context.profile,
|
|
954
184
|
request: {
|
|
955
185
|
body: {
|
|
@@ -958,7 +188,7 @@ function createAgentOperations(context) {
|
|
|
958
188
|
},
|
|
959
189
|
destination: {
|
|
960
190
|
kind: "host",
|
|
961
|
-
path: queryPath(context.profile.apiPath("notebooks", notebook, "chat-sessions", session, "messages", "stream"), [["client", context.client]])
|
|
191
|
+
path: queryPath(context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages", "stream"), [["client", context.client]])
|
|
962
192
|
},
|
|
963
193
|
idempotent: false,
|
|
964
194
|
method: "POST",
|
|
@@ -967,23 +197,94 @@ function createAgentOperations(context) {
|
|
|
967
197
|
transport: context.transport
|
|
968
198
|
});
|
|
969
199
|
};
|
|
200
|
+
const streamQuestion = (notebookId, sessionId, input, options) => streamQuestionFor(notebookId, sessionId, input, options, false);
|
|
201
|
+
const streamFeaturedQuestion = (notebookId, sessionId, input, options) => streamQuestionFor(notebookId, sessionId, input, options, true);
|
|
202
|
+
const cancelQuestionFor = (notebookId, sessionId, input = {}, options, featured = false) => {
|
|
203
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
204
|
+
const session = requiredString$2(sessionId, "sessionId");
|
|
205
|
+
if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
|
|
206
|
+
return call(context, {
|
|
207
|
+
body: compactUndefined({ reason: optionalTrimmedString(input.reason, "reason") }),
|
|
208
|
+
callOptions: options,
|
|
209
|
+
capability: featured ? "featuredNotebooks.read" : "chat",
|
|
210
|
+
idempotent: false,
|
|
211
|
+
method: "POST",
|
|
212
|
+
operation: featured ? "featuredChat.cancel" : "chat.cancel",
|
|
213
|
+
path: context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages", "cancel"),
|
|
214
|
+
schema: cancelQuestionResultSchema
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
const listChatSessionsFor = (notebookId, input = {}, options, featured = false) => {
|
|
218
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
219
|
+
const normalizedPage = pagination$1({
|
|
220
|
+
page: input.page ?? 1,
|
|
221
|
+
pageSize: input.pageSize ?? 20
|
|
222
|
+
});
|
|
223
|
+
return call(context, {
|
|
224
|
+
callOptions: options,
|
|
225
|
+
capability: featured ? "featuredNotebooks.read" : "chat",
|
|
226
|
+
idempotent: true,
|
|
227
|
+
method: "GET",
|
|
228
|
+
operation: featured ? "featuredChatSessions.list" : "chatSessions.list",
|
|
229
|
+
path: queryPath(context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions"), [["page", normalizedPage.page], ["page_size", normalizedPage.pageSize]]),
|
|
230
|
+
schema: chatSessionListSchema
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
const listChatMessagesFor = (notebookId, sessionId, input = {}, options, featured = false) => {
|
|
234
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
235
|
+
const session = requiredString$2(sessionId, "sessionId");
|
|
236
|
+
const normalizedPage = pagination$1({
|
|
237
|
+
page: input.page ?? 1,
|
|
238
|
+
pageSize: input.pageSize ?? 100
|
|
239
|
+
});
|
|
240
|
+
return call(context, {
|
|
241
|
+
callOptions: options,
|
|
242
|
+
capability: featured ? "featuredNotebooks.read" : "chat",
|
|
243
|
+
idempotent: true,
|
|
244
|
+
method: "GET",
|
|
245
|
+
operation: featured ? "featuredChatMessages.list" : "chatMessages.list",
|
|
246
|
+
path: queryPath(context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages"), [["page", normalizedPage.page], ["page_size", normalizedPage.pageSize]]),
|
|
247
|
+
schema: chatMessageListSchema
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
const deleteChatSessionFor = (notebookId, sessionId, options, featured = false) => {
|
|
251
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
252
|
+
const session = requiredString$2(sessionId, "sessionId");
|
|
253
|
+
return call(context, {
|
|
254
|
+
callOptions: options,
|
|
255
|
+
capability: featured ? "featuredNotebooks.read" : "chat",
|
|
256
|
+
idempotent: false,
|
|
257
|
+
method: "DELETE",
|
|
258
|
+
operation: featured ? "featuredChatSessions.delete" : "chatSessions.delete",
|
|
259
|
+
path: context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session),
|
|
260
|
+
schema: voidResponseSchema
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
const startAgentRunFor = async (notebookId, input, options, featured) => {
|
|
264
|
+
if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
|
|
265
|
+
if (input.scene !== "rag" && input.scene !== "compilation" && input.scene !== "lint") throw invalidArgument$1("scene must be rag, compilation or lint", "scene");
|
|
266
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
267
|
+
const scene = input.scene;
|
|
268
|
+
const modelOverride = optionalTrimmedString(input.modelOverride, "modelOverride");
|
|
269
|
+
const title = optionalString$1(input.title, "title");
|
|
270
|
+
const session = await (featured ? createFeaturedChatSession : createChatSession)(notebook, {
|
|
271
|
+
...modelOverride === void 0 ? {} : { modelOverride },
|
|
272
|
+
sceneType: scene,
|
|
273
|
+
...title === void 0 ? {} : { title }
|
|
274
|
+
}, options);
|
|
275
|
+
return {
|
|
276
|
+
events: (featured ? streamFeaturedQuestion : streamQuestion)(notebook, session.id, agentContent(input), options),
|
|
277
|
+
scene,
|
|
278
|
+
session
|
|
279
|
+
};
|
|
280
|
+
};
|
|
970
281
|
return {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
const session = requiredString$2(sessionId, "sessionId");
|
|
974
|
-
if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
|
|
975
|
-
return call(context, {
|
|
976
|
-
body: compactUndefined({ reason: optionalTrimmedString(input.reason, "reason") }),
|
|
977
|
-
callOptions: options,
|
|
978
|
-
capability: "chat",
|
|
979
|
-
idempotent: false,
|
|
980
|
-
method: "POST",
|
|
981
|
-
operation: "chat.cancel",
|
|
982
|
-
path: context.profile.apiPath("notebooks", notebook, "chat-sessions", session, "messages", "cancel"),
|
|
983
|
-
schema: cancelQuestionResultSchema
|
|
984
|
-
});
|
|
985
|
-
},
|
|
282
|
+
cancelFeaturedQuestion: (notebookId, sessionId, input, options) => cancelQuestionFor(notebookId, sessionId, input, options, true),
|
|
283
|
+
cancelQuestion: (notebookId, sessionId, input, options) => cancelQuestionFor(notebookId, sessionId, input, options),
|
|
986
284
|
createChatSession,
|
|
285
|
+
createFeaturedChatSession,
|
|
286
|
+
deleteChatSession: (notebookId, sessionId, options) => deleteChatSessionFor(notebookId, sessionId, options),
|
|
287
|
+
deleteFeaturedChatSession: (notebookId, sessionId, options) => deleteChatSessionFor(notebookId, sessionId, options, true),
|
|
987
288
|
async createTaskRun(notebookId, input, options) {
|
|
988
289
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
989
290
|
return call(context, {
|
|
@@ -1011,16 +312,21 @@ function createAgentOperations(context) {
|
|
|
1011
312
|
});
|
|
1012
313
|
},
|
|
1013
314
|
async listTaskRuns(notebookId, input, options) {
|
|
315
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1014
316
|
return call(context, {
|
|
1015
317
|
callOptions: options,
|
|
1016
318
|
capability: "taskRuns.read",
|
|
1017
319
|
idempotent: true,
|
|
1018
320
|
method: "GET",
|
|
1019
321
|
operation: "taskRuns.list",
|
|
1020
|
-
path: taskRunListPath(context,
|
|
322
|
+
path: taskRunListPath(context, notebook, input),
|
|
1021
323
|
schema: taskRunListSchema
|
|
1022
324
|
});
|
|
1023
325
|
},
|
|
326
|
+
listChatMessages: (notebookId, sessionId, input, options) => listChatMessagesFor(notebookId, sessionId, input, options),
|
|
327
|
+
listChatSessions: (notebookId, input, options) => listChatSessionsFor(notebookId, input, options),
|
|
328
|
+
listFeaturedChatMessages: (notebookId, sessionId, input, options) => listChatMessagesFor(notebookId, sessionId, input, options, true),
|
|
329
|
+
listFeaturedChatSessions: (notebookId, input, options) => listChatSessionsFor(notebookId, input, options, true),
|
|
1024
330
|
async retrieve(notebookId, input, options) {
|
|
1025
331
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1026
332
|
return call(context, {
|
|
@@ -1034,93 +340,13 @@ function createAgentOperations(context) {
|
|
|
1034
340
|
schema: retrieveResultSchema
|
|
1035
341
|
});
|
|
1036
342
|
},
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1041
|
-
const scene = input.scene;
|
|
1042
|
-
const modelOverride = optionalTrimmedString(input.modelOverride, "modelOverride");
|
|
1043
|
-
const title = optionalString$1(input.title, "title");
|
|
1044
|
-
const session = await createChatSession(notebook, {
|
|
1045
|
-
...modelOverride === void 0 ? {} : { modelOverride },
|
|
1046
|
-
sceneType: scene,
|
|
1047
|
-
...title === void 0 ? {} : { title }
|
|
1048
|
-
}, options);
|
|
1049
|
-
return {
|
|
1050
|
-
events: streamQuestion(notebook, session.id, agentContent(input), options),
|
|
1051
|
-
scene,
|
|
1052
|
-
session
|
|
1053
|
-
};
|
|
1054
|
-
},
|
|
343
|
+
startAgentRun: (notebookId, input, options) => startAgentRunFor(notebookId, input, options, false),
|
|
344
|
+
startFeaturedAgentRun: (notebookId, input, options) => startAgentRunFor(notebookId, input, options, true),
|
|
345
|
+
streamFeaturedQuestion,
|
|
1055
346
|
streamQuestion
|
|
1056
347
|
};
|
|
1057
348
|
}
|
|
1058
349
|
//#endregion
|
|
1059
|
-
//#region ../sdk/src/operations/cards.ts
|
|
1060
|
-
function createCardOperations(context) {
|
|
1061
|
-
return {
|
|
1062
|
-
async batchDeleteCards(notebookId, cardIds, options) {
|
|
1063
|
-
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1064
|
-
return call(context, {
|
|
1065
|
-
body: { cardIds: stringList(cardIds, "cardIds", { min: 1 }) },
|
|
1066
|
-
callOptions: options,
|
|
1067
|
-
capability: "cards.write",
|
|
1068
|
-
idempotent: false,
|
|
1069
|
-
method: "POST",
|
|
1070
|
-
operation: "cards.batchDelete",
|
|
1071
|
-
path: context.profile.apiPath("notebooks", notebook, "cards", "batch-delete"),
|
|
1072
|
-
schema: batchMutationResultSchema
|
|
1073
|
-
});
|
|
1074
|
-
},
|
|
1075
|
-
async deleteCard(notebookId, cardId, options) {
|
|
1076
|
-
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1077
|
-
const card = requiredString$2(cardId, "cardId");
|
|
1078
|
-
return call(context, {
|
|
1079
|
-
callOptions: options,
|
|
1080
|
-
capability: "cards.write",
|
|
1081
|
-
idempotent: false,
|
|
1082
|
-
method: "DELETE",
|
|
1083
|
-
operation: "cards.delete",
|
|
1084
|
-
path: context.profile.apiPath("notebooks", notebook, "cards", card),
|
|
1085
|
-
schema: batchMutationResultSchema
|
|
1086
|
-
});
|
|
1087
|
-
},
|
|
1088
|
-
async getCard(notebookId, cardId, options) {
|
|
1089
|
-
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1090
|
-
const card = requiredString$2(cardId, "cardId");
|
|
1091
|
-
return call(context, {
|
|
1092
|
-
callOptions: options,
|
|
1093
|
-
capability: "cards.read",
|
|
1094
|
-
idempotent: true,
|
|
1095
|
-
method: "GET",
|
|
1096
|
-
operation: "cards.get",
|
|
1097
|
-
path: context.profile.apiPath("notebooks", notebook, "cards", card),
|
|
1098
|
-
schema: cardSchema
|
|
1099
|
-
});
|
|
1100
|
-
},
|
|
1101
|
-
async listCards(notebookId, input = {}, options) {
|
|
1102
|
-
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1103
|
-
const normalizedPage = pagination$1(input);
|
|
1104
|
-
const category = optionalTrimmedString(input.category, "category");
|
|
1105
|
-
const query = optionalTrimmedString(input.query, "query");
|
|
1106
|
-
return call(context, {
|
|
1107
|
-
callOptions: options,
|
|
1108
|
-
capability: "cards.read",
|
|
1109
|
-
idempotent: true,
|
|
1110
|
-
method: "GET",
|
|
1111
|
-
operation: "cards.list",
|
|
1112
|
-
path: queryPath(context.profile.apiPath("notebooks", notebook, "cards"), [
|
|
1113
|
-
["category", category],
|
|
1114
|
-
["query", query],
|
|
1115
|
-
["page", normalizedPage.page],
|
|
1116
|
-
["page_size", normalizedPage.pageSize]
|
|
1117
|
-
]),
|
|
1118
|
-
schema: cardListSchema
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
};
|
|
1122
|
-
}
|
|
1123
|
-
//#endregion
|
|
1124
350
|
//#region ../sdk/src/operations/notebooks.ts
|
|
1125
351
|
function createNotebookOperations(context) {
|
|
1126
352
|
return {
|
|
@@ -1168,6 +394,30 @@ function createNotebookOperations(context) {
|
|
|
1168
394
|
schema: notebookSchema
|
|
1169
395
|
});
|
|
1170
396
|
},
|
|
397
|
+
async getFeaturedNotebook(notebookId, options) {
|
|
398
|
+
const id = requiredString$2(notebookId, "notebookId");
|
|
399
|
+
return call(context, {
|
|
400
|
+
callOptions: options,
|
|
401
|
+
capability: "featuredNotebooks.read",
|
|
402
|
+
idempotent: true,
|
|
403
|
+
method: "GET",
|
|
404
|
+
operation: "featuredNotebooks.get",
|
|
405
|
+
path: context.profile.featuredNotebookPath(id),
|
|
406
|
+
schema: notebookSchema
|
|
407
|
+
});
|
|
408
|
+
},
|
|
409
|
+
async listFeaturedNotebooks(input = {}, options) {
|
|
410
|
+
const normalized = pagination$1(input);
|
|
411
|
+
return call(context, {
|
|
412
|
+
callOptions: options,
|
|
413
|
+
capability: "featuredNotebooks.read",
|
|
414
|
+
idempotent: true,
|
|
415
|
+
method: "GET",
|
|
416
|
+
operation: "featuredNotebooks.list",
|
|
417
|
+
path: context.profile.listFeaturedNotebooksPath(normalized),
|
|
418
|
+
schema: notebookListSchema
|
|
419
|
+
});
|
|
420
|
+
},
|
|
1171
421
|
async listNotebooks(input = {}, options) {
|
|
1172
422
|
const normalizedPage = pagination$1(input);
|
|
1173
423
|
const client = optionalTrimmedString(input.client, "client");
|
|
@@ -1186,6 +436,18 @@ function createNotebookOperations(context) {
|
|
|
1186
436
|
schema: notebookListSchema
|
|
1187
437
|
});
|
|
1188
438
|
},
|
|
439
|
+
async listSharedNotebooks(input = {}, options) {
|
|
440
|
+
const normalized = pagination$1(input);
|
|
441
|
+
return call(context, {
|
|
442
|
+
callOptions: options,
|
|
443
|
+
capability: "sharedNotebooks.read",
|
|
444
|
+
idempotent: true,
|
|
445
|
+
method: "GET",
|
|
446
|
+
operation: "sharedNotebooks.list",
|
|
447
|
+
path: context.profile.listSharedNotebooksPath(normalized),
|
|
448
|
+
schema: sharedNotebookListSchema
|
|
449
|
+
});
|
|
450
|
+
},
|
|
1189
451
|
async listWikiBranches(notebookId, options) {
|
|
1190
452
|
const id = requiredString$2(notebookId, "notebookId");
|
|
1191
453
|
return (await call(context, {
|
|
@@ -1246,6 +508,7 @@ function createsSourceCycle(source, sourcesById) {
|
|
|
1246
508
|
}
|
|
1247
509
|
function buildSourceTree(sources) {
|
|
1248
510
|
const sourcesById = new Map(sources.map((source) => [source.id, source]));
|
|
511
|
+
const parentIds = new Set(sources.filter((source) => sourcesById.has(source.parentSourceId) && !createsSourceCycle(source, sourcesById)).map((source) => source.parentSourceId));
|
|
1249
512
|
const nodesById = /* @__PURE__ */ new Map();
|
|
1250
513
|
for (const source of sources) nodesById.set(source.id, {
|
|
1251
514
|
files: [],
|
|
@@ -1254,7 +517,7 @@ function buildSourceTree(sources) {
|
|
|
1254
517
|
path: source.path,
|
|
1255
518
|
sourceType: source.sourceType,
|
|
1256
519
|
status: source.status,
|
|
1257
|
-
type: source.isDir ? "directory" : "file"
|
|
520
|
+
type: source.isDir || parentIds.has(source.id) ? "directory" : "file"
|
|
1258
521
|
});
|
|
1259
522
|
const tree = [];
|
|
1260
523
|
for (const source of sources) {
|
|
@@ -1304,9 +567,10 @@ function siteBody(input) {
|
|
|
1304
567
|
const includePaths = stringList(input?.includePaths ?? [], "includePaths");
|
|
1305
568
|
const excludePaths = stringList(input?.excludePaths ?? [], "excludePaths");
|
|
1306
569
|
const sitemap = optionalTrimmedString(input?.sitemapUrl, "sitemapUrl");
|
|
570
|
+
const compileAfterRefresh = optionalBoolean(input?.compileAfterRefresh, "compileAfterRefresh");
|
|
1307
571
|
return compactUndefined({
|
|
1308
572
|
config: compactUndefined({
|
|
1309
|
-
compileAfterRefresh
|
|
573
|
+
compileAfterRefresh,
|
|
1310
574
|
excludePaths,
|
|
1311
575
|
includePaths,
|
|
1312
576
|
maxPages,
|
|
@@ -1358,24 +622,49 @@ function createSourceOperations(context) {
|
|
|
1358
622
|
if (view === "children") assertCapability(context.profile, "sources.children", "sources.list");
|
|
1359
623
|
if (query !== void 0) assertCapability(context.profile, "sources.search", "sources.list");
|
|
1360
624
|
if (parentSourceId !== void 0 && view !== "children") throw invalidArgument$1("parentSourceId requires view=\"children\"", "parentSourceId");
|
|
625
|
+
const path = queryPath(context.profile.apiPath("notebooks", notebook, "sources"), [
|
|
626
|
+
["view", view === "list" ? void 0 : view],
|
|
627
|
+
["is_dir", isDir === void 0 ? void 0 : String(isDir)],
|
|
628
|
+
["parent_source_id", parentSourceId],
|
|
629
|
+
["page", normalizedPage.page],
|
|
630
|
+
["page_size", normalizedPage.pageSize],
|
|
631
|
+
["query", query]
|
|
632
|
+
]);
|
|
1361
633
|
return call(context, {
|
|
1362
634
|
callOptions: options,
|
|
1363
635
|
capability: "sources.read",
|
|
1364
636
|
idempotent: true,
|
|
1365
637
|
method: "GET",
|
|
1366
638
|
operation,
|
|
1367
|
-
path
|
|
639
|
+
path,
|
|
640
|
+
schema: sourceListSchema
|
|
641
|
+
});
|
|
642
|
+
};
|
|
643
|
+
const listSources = (notebookId, input, options) => readSourcePage(notebookId, input, options);
|
|
644
|
+
const listFeaturedSources = async (notebookId, input = {}, options) => {
|
|
645
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
646
|
+
const normalizedPage = pagination$1({
|
|
647
|
+
page: input.page ?? 1,
|
|
648
|
+
pageSize: input.pageSize ?? 200
|
|
649
|
+
});
|
|
650
|
+
const parentSourceId = optionalString$1(input.parentSourceId, "parentSourceId");
|
|
651
|
+
const view = input.view ?? "list";
|
|
652
|
+
if (view !== "list" && view !== "children") throw invalidArgument$1("view must be either \"list\" or \"children\"", "view");
|
|
653
|
+
return call(context, {
|
|
654
|
+
callOptions: options,
|
|
655
|
+
capability: "featuredNotebooks.read",
|
|
656
|
+
idempotent: true,
|
|
657
|
+
method: "GET",
|
|
658
|
+
operation: "featuredSources.list",
|
|
659
|
+
path: queryPath(context.profile.apiPath("featured-notebooks", notebook, "sources"), [
|
|
1368
660
|
["view", view === "list" ? void 0 : view],
|
|
1369
|
-
["is_dir", isDir === void 0 ? void 0 : String(isDir)],
|
|
1370
661
|
["parent_source_id", parentSourceId],
|
|
1371
662
|
["page", normalizedPage.page],
|
|
1372
|
-
["page_size", normalizedPage.pageSize]
|
|
1373
|
-
["query", query]
|
|
663
|
+
["page_size", normalizedPage.pageSize]
|
|
1374
664
|
]),
|
|
1375
665
|
schema: sourceListSchema
|
|
1376
666
|
});
|
|
1377
667
|
};
|
|
1378
|
-
const listSources = (notebookId, input, options) => readSourcePage(notebookId, input, options);
|
|
1379
668
|
const collectAllSources = async (notebookId, input = {}, options, operation) => {
|
|
1380
669
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1381
670
|
const pageSize = positiveInteger$1(input.pageSize, "pageSize") ?? 200;
|
|
@@ -1418,8 +707,9 @@ function createSourceOperations(context) {
|
|
|
1418
707
|
return {
|
|
1419
708
|
async batchDeleteSources(notebookId, sourceIds, options) {
|
|
1420
709
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
710
|
+
const ids = stringList(sourceIds, "sourceIds", { min: 1 });
|
|
1421
711
|
return call(context, {
|
|
1422
|
-
body: { sourceIds:
|
|
712
|
+
body: { sourceIds: ids },
|
|
1423
713
|
callOptions: options,
|
|
1424
714
|
capability: "sources.write",
|
|
1425
715
|
idempotent: false,
|
|
@@ -1429,28 +719,114 @@ function createSourceOperations(context) {
|
|
|
1429
719
|
schema: batchMutationResultSchema
|
|
1430
720
|
});
|
|
1431
721
|
},
|
|
1432
|
-
async
|
|
1433
|
-
const
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
722
|
+
async countSourceChildren(notebookId, parentIds, options) {
|
|
723
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
724
|
+
const ids = stringList(parentIds, "parentIds", {
|
|
725
|
+
max: 200,
|
|
726
|
+
min: 1
|
|
727
|
+
});
|
|
728
|
+
assertCapability(context.profile, "sources.childrenCount", "sources.childrenCount");
|
|
729
|
+
const path = context.profile.mindPath("notebooks", notebook, "sources", "children-count");
|
|
730
|
+
const query = new URLSearchParams();
|
|
731
|
+
for (const id of ids) query.append("parent_ids", id);
|
|
732
|
+
return call(context, {
|
|
733
|
+
callOptions: options,
|
|
734
|
+
capability: "sources.childrenCount",
|
|
735
|
+
idempotent: true,
|
|
736
|
+
method: "GET",
|
|
737
|
+
operation: "sources.childrenCount",
|
|
738
|
+
path: `${path}?${query.toString()}`,
|
|
739
|
+
schema: sourceChildrenCountsSchema
|
|
740
|
+
});
|
|
741
|
+
},
|
|
742
|
+
async createDirectory(notebookId, input, options) {
|
|
743
|
+
const title = requiredString$2(input?.title, "title");
|
|
744
|
+
return createSource(notebookId, {
|
|
745
|
+
isDir: true,
|
|
746
|
+
parentSourceId: input?.parentSourceId,
|
|
747
|
+
path: input?.path,
|
|
748
|
+
status: "ready",
|
|
749
|
+
title
|
|
750
|
+
}, options);
|
|
751
|
+
},
|
|
752
|
+
createSource,
|
|
753
|
+
async createSourceWebOfficeSession(notebookId, sourceId, options) {
|
|
754
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
755
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
756
|
+
assertCapability(context.profile, "sources.webOffice", "sources.webOffice.create");
|
|
757
|
+
return call(context, {
|
|
758
|
+
callOptions: options,
|
|
759
|
+
capability: "sources.webOffice",
|
|
760
|
+
idempotent: false,
|
|
761
|
+
method: "POST",
|
|
762
|
+
operation: "sources.webOffice.create",
|
|
763
|
+
path: context.profile.apiPath("notebooks", notebook, "sources", source, "weboffice", "session"),
|
|
764
|
+
schema: sourceWebOfficeSessionSchema
|
|
765
|
+
});
|
|
766
|
+
},
|
|
767
|
+
async deleteSource(notebookId, sourceId, options) {
|
|
768
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
769
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
770
|
+
return call(context, {
|
|
771
|
+
callOptions: options,
|
|
772
|
+
capability: "sources.write",
|
|
773
|
+
idempotent: false,
|
|
774
|
+
method: "DELETE",
|
|
775
|
+
operation: "sources.delete",
|
|
776
|
+
path: context.profile.apiPath("notebooks", notebook, "sources", source),
|
|
777
|
+
schema: voidResponseSchema
|
|
778
|
+
});
|
|
779
|
+
},
|
|
780
|
+
async getFeaturedSource(notebookId, sourceId, options) {
|
|
781
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
782
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
783
|
+
return call(context, {
|
|
784
|
+
callOptions: options,
|
|
785
|
+
capability: "featuredNotebooks.read",
|
|
786
|
+
idempotent: true,
|
|
787
|
+
method: "GET",
|
|
788
|
+
operation: "featuredSources.get",
|
|
789
|
+
path: context.profile.apiPath("featured-notebooks", notebook, "sources", source),
|
|
790
|
+
schema: sourceSchema
|
|
791
|
+
});
|
|
792
|
+
},
|
|
793
|
+
async getFeaturedSourceContent(notebookId, sourceId, options) {
|
|
794
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
795
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
796
|
+
return call(context, {
|
|
797
|
+
callOptions: options,
|
|
798
|
+
capability: "featuredNotebooks.read",
|
|
799
|
+
idempotent: true,
|
|
800
|
+
method: "GET",
|
|
801
|
+
operation: "featuredSources.content",
|
|
802
|
+
path: context.profile.apiPath("featured-notebooks", notebook, "sources", source, "content"),
|
|
803
|
+
schema: sourceContentSchema
|
|
804
|
+
});
|
|
805
|
+
},
|
|
806
|
+
async getFeaturedSourcePreview(notebookId, sourceId, options) {
|
|
807
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
808
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
809
|
+
return call(context, {
|
|
810
|
+
callOptions: options,
|
|
811
|
+
capability: "featuredNotebooks.read",
|
|
812
|
+
idempotent: true,
|
|
813
|
+
method: "GET",
|
|
814
|
+
operation: "featuredSources.preview",
|
|
815
|
+
path: context.profile.apiPath("featured-notebooks", notebook, "sources", source, "preview"),
|
|
816
|
+
schema: sourcePreviewSchema
|
|
817
|
+
});
|
|
818
|
+
},
|
|
819
|
+
async getFeaturedSourceRawContent(notebookId, sourceId, options) {
|
|
1444
820
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1445
821
|
const source = requiredString$2(sourceId, "sourceId");
|
|
1446
822
|
return call(context, {
|
|
1447
823
|
callOptions: options,
|
|
1448
|
-
capability: "
|
|
1449
|
-
idempotent:
|
|
1450
|
-
method: "
|
|
1451
|
-
operation: "
|
|
1452
|
-
path: context.profile.apiPath("notebooks", notebook, "sources", source),
|
|
1453
|
-
schema:
|
|
824
|
+
capability: "featuredNotebooks.read",
|
|
825
|
+
idempotent: true,
|
|
826
|
+
method: "GET",
|
|
827
|
+
operation: "featuredSources.rawContent",
|
|
828
|
+
path: context.profile.apiPath("featured-notebooks", notebook, "sources", source, "raw-content"),
|
|
829
|
+
schema: sourceRawContentSchema
|
|
1454
830
|
});
|
|
1455
831
|
},
|
|
1456
832
|
async getSource(notebookId, sourceId, options) {
|
|
@@ -1479,6 +855,60 @@ function createSourceOperations(context) {
|
|
|
1479
855
|
schema: sourceContentSchema
|
|
1480
856
|
});
|
|
1481
857
|
},
|
|
858
|
+
async getSourceActionAccess(options) {
|
|
859
|
+
return call(context, {
|
|
860
|
+
callOptions: options,
|
|
861
|
+
capability: "sources.actionAccess",
|
|
862
|
+
idempotent: true,
|
|
863
|
+
method: "GET",
|
|
864
|
+
operation: "sources.actionAccess",
|
|
865
|
+
path: context.profile.mindPath("source-actions", "access"),
|
|
866
|
+
schema: sourceActionAccessSchema
|
|
867
|
+
});
|
|
868
|
+
},
|
|
869
|
+
async getSourcePreview(notebookId, sourceId, options) {
|
|
870
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
871
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
872
|
+
return call(context, {
|
|
873
|
+
callOptions: options,
|
|
874
|
+
capability: "sources.preview",
|
|
875
|
+
idempotent: true,
|
|
876
|
+
method: "GET",
|
|
877
|
+
operation: "sources.preview",
|
|
878
|
+
path: context.profile.apiPath("notebooks", notebook, "sources", source, "preview"),
|
|
879
|
+
schema: sourcePreviewSchema
|
|
880
|
+
});
|
|
881
|
+
},
|
|
882
|
+
async getSourceRawContent(notebookId, sourceId, options) {
|
|
883
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
884
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
885
|
+
return call(context, {
|
|
886
|
+
callOptions: options,
|
|
887
|
+
capability: "sources.rawContent",
|
|
888
|
+
idempotent: true,
|
|
889
|
+
method: "GET",
|
|
890
|
+
operation: "sources.rawContent",
|
|
891
|
+
path: context.profile.apiPath("notebooks", notebook, "sources", source, "raw-content"),
|
|
892
|
+
schema: sourceRawContentSchema
|
|
893
|
+
});
|
|
894
|
+
},
|
|
895
|
+
async getSourceUploadCapabilities(options) {
|
|
896
|
+
return call(context, {
|
|
897
|
+
callOptions: options,
|
|
898
|
+
capability: "sources.write",
|
|
899
|
+
idempotent: true,
|
|
900
|
+
method: "GET",
|
|
901
|
+
operation: "sources.uploadCapabilities",
|
|
902
|
+
path: context.profile.mindPath("source-upload", "capabilities"),
|
|
903
|
+
schema: sourceUploadCapabilitiesSchema
|
|
904
|
+
});
|
|
905
|
+
},
|
|
906
|
+
async getFeaturedSourceTree(notebookId, options) {
|
|
907
|
+
return buildSourceTree((await listFeaturedSources(notebookId, {
|
|
908
|
+
page: 1,
|
|
909
|
+
pageSize: 200
|
|
910
|
+
}, options)).sources);
|
|
911
|
+
},
|
|
1482
912
|
getSourceTree,
|
|
1483
913
|
async importSite(notebookId, input, options) {
|
|
1484
914
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
@@ -1503,6 +933,7 @@ function createSourceOperations(context) {
|
|
|
1503
933
|
body: compactUndefined({
|
|
1504
934
|
parentSourceId: optionalString$1(input?.parentSourceId, "parentSourceId"),
|
|
1505
935
|
path: optionalString$1(input?.path, "path"),
|
|
936
|
+
sourceType: "url",
|
|
1506
937
|
urls
|
|
1507
938
|
}),
|
|
1508
939
|
callOptions: options,
|
|
@@ -1514,7 +945,30 @@ function createSourceOperations(context) {
|
|
|
1514
945
|
schema: sourceImportResultsSchema
|
|
1515
946
|
});
|
|
1516
947
|
},
|
|
948
|
+
async importWikiDocuments(notebookId, input, options) {
|
|
949
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
950
|
+
const urls = stringList(input?.urls ?? [], "urls", {
|
|
951
|
+
max: 5,
|
|
952
|
+
min: 1
|
|
953
|
+
});
|
|
954
|
+
return call(context, {
|
|
955
|
+
body: compactUndefined({
|
|
956
|
+
parentSourceId: optionalString$1(input?.parentSourceId, "parentSourceId"),
|
|
957
|
+
path: "/repowiki",
|
|
958
|
+
sourceType: "repowiki",
|
|
959
|
+
urls
|
|
960
|
+
}),
|
|
961
|
+
callOptions: options,
|
|
962
|
+
capability: "sources.write",
|
|
963
|
+
idempotent: false,
|
|
964
|
+
method: "POST",
|
|
965
|
+
operation: "sources.importWiki",
|
|
966
|
+
path: context.profile.apiPath("notebooks", notebook, "sources"),
|
|
967
|
+
schema: sourceImportResultsSchema
|
|
968
|
+
});
|
|
969
|
+
},
|
|
1517
970
|
listAllSources,
|
|
971
|
+
listFeaturedSources,
|
|
1518
972
|
listSources,
|
|
1519
973
|
async moveSource(notebookId, sourceId, input, options) {
|
|
1520
974
|
const parentSourceId = optionalString$1(input?.parentSourceId, "parentSourceId");
|
|
@@ -1553,13 +1007,31 @@ function createSourceOperations(context) {
|
|
|
1553
1007
|
schema: imageUploadTicketSchema
|
|
1554
1008
|
});
|
|
1555
1009
|
},
|
|
1010
|
+
async refreshSourceWebOfficeSession(notebookId, sourceId, input, options) {
|
|
1011
|
+
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1012
|
+
const source = requiredString$2(sourceId, "sourceId");
|
|
1013
|
+
const sessionId = requiredString$2(input?.sessionId, "sessionId");
|
|
1014
|
+
const tokenVersion = nonNegativeInteger$1(input?.tokenVersion, "tokenVersion") ?? 0;
|
|
1015
|
+
assertCapability(context.profile, "sources.webOffice", "sources.webOffice.refresh");
|
|
1016
|
+
return call(context, {
|
|
1017
|
+
body: { tokenVersion },
|
|
1018
|
+
callOptions: options,
|
|
1019
|
+
capability: "sources.webOffice",
|
|
1020
|
+
idempotent: false,
|
|
1021
|
+
method: "POST",
|
|
1022
|
+
operation: "sources.webOffice.refresh",
|
|
1023
|
+
path: context.profile.apiPath("notebooks", notebook, "sources", source, "weboffice", "session", sessionId, "refresh"),
|
|
1024
|
+
schema: sourceWebOfficeTokenSchema
|
|
1025
|
+
});
|
|
1026
|
+
},
|
|
1556
1027
|
async presignImageUrls(notebookId, ossKeys, options) {
|
|
1557
1028
|
const notebook = requiredString$2(notebookId, "notebookId");
|
|
1029
|
+
const keys = stringList(ossKeys, "ossKeys", {
|
|
1030
|
+
max: 100,
|
|
1031
|
+
min: 1
|
|
1032
|
+
});
|
|
1558
1033
|
return call(context, {
|
|
1559
|
-
body: { ossKeys:
|
|
1560
|
-
max: 100,
|
|
1561
|
-
min: 1
|
|
1562
|
-
}) },
|
|
1034
|
+
body: { ossKeys: keys },
|
|
1563
1035
|
callOptions: options,
|
|
1564
1036
|
capability: "images.presignUrls",
|
|
1565
1037
|
idempotent: false,
|
|
@@ -1662,12 +1134,14 @@ function transferCall(context, operation, request, schema) {
|
|
|
1662
1134
|
});
|
|
1663
1135
|
}
|
|
1664
1136
|
function hostRequest(path, method, idempotent, options, body) {
|
|
1137
|
+
const authorization = options.authorization?.trim();
|
|
1665
1138
|
return {
|
|
1666
1139
|
body,
|
|
1667
1140
|
destination: {
|
|
1668
1141
|
kind: "host",
|
|
1669
1142
|
path
|
|
1670
1143
|
},
|
|
1144
|
+
...authorization === void 0 || authorization.length === 0 ? {} : { headers: { authorization: `Bearer ${authorization}` } },
|
|
1671
1145
|
idempotent,
|
|
1672
1146
|
method,
|
|
1673
1147
|
...requestOptions(options)
|
|
@@ -1788,22 +1262,31 @@ const dashboardCapabilities = Object.freeze({
|
|
|
1788
1262
|
"cards.read": true,
|
|
1789
1263
|
"cards.write": true,
|
|
1790
1264
|
chat: true,
|
|
1791
|
-
|
|
1265
|
+
compilation: true,
|
|
1266
|
+
"featuredNotebooks.read": true,
|
|
1792
1267
|
"images.presignUpload": false,
|
|
1793
1268
|
"images.presignUrls": false,
|
|
1794
|
-
|
|
1269
|
+
"imports.aliDing": true,
|
|
1270
|
+
"imports.discover": true,
|
|
1271
|
+
members: true,
|
|
1795
1272
|
"notebooks.filterByClient": false,
|
|
1796
1273
|
"notebooks.read": true,
|
|
1797
1274
|
"notebooks.write": true,
|
|
1798
1275
|
"notes.read": false,
|
|
1799
1276
|
"notes.write": false,
|
|
1800
1277
|
retrieval: true,
|
|
1801
|
-
scheduledTasks:
|
|
1278
|
+
scheduledTasks: true,
|
|
1279
|
+
"sharedNotebooks.read": true,
|
|
1802
1280
|
"sources.children": true,
|
|
1281
|
+
"sources.childrenCount": true,
|
|
1282
|
+
"sources.actionAccess": true,
|
|
1803
1283
|
"sources.importWeb": true,
|
|
1284
|
+
"sources.preview": true,
|
|
1285
|
+
"sources.rawContent": true,
|
|
1804
1286
|
"sources.read": true,
|
|
1805
1287
|
"sources.search": true,
|
|
1806
1288
|
"sources.tree": true,
|
|
1289
|
+
"sources.webOffice": true,
|
|
1807
1290
|
"sources.write": true,
|
|
1808
1291
|
"taskRuns.read": true,
|
|
1809
1292
|
"taskRuns.write": true,
|
|
@@ -1815,9 +1298,12 @@ const sashCapabilities = Object.freeze({
|
|
|
1815
1298
|
"cards.read": true,
|
|
1816
1299
|
"cards.write": true,
|
|
1817
1300
|
chat: true,
|
|
1301
|
+
compilation: false,
|
|
1818
1302
|
"featuredNotebooks.read": false,
|
|
1819
1303
|
"images.presignUpload": true,
|
|
1820
1304
|
"images.presignUrls": true,
|
|
1305
|
+
"imports.aliDing": false,
|
|
1306
|
+
"imports.discover": false,
|
|
1821
1307
|
members: false,
|
|
1822
1308
|
"notebooks.filterByClient": true,
|
|
1823
1309
|
"notebooks.read": true,
|
|
@@ -1826,11 +1312,17 @@ const sashCapabilities = Object.freeze({
|
|
|
1826
1312
|
"notes.write": false,
|
|
1827
1313
|
retrieval: true,
|
|
1828
1314
|
scheduledTasks: false,
|
|
1829
|
-
"
|
|
1830
|
-
"sources.
|
|
1315
|
+
"sharedNotebooks.read": false,
|
|
1316
|
+
"sources.children": true,
|
|
1317
|
+
"sources.childrenCount": false,
|
|
1318
|
+
"sources.actionAccess": true,
|
|
1319
|
+
"sources.importWeb": true,
|
|
1320
|
+
"sources.preview": true,
|
|
1321
|
+
"sources.rawContent": true,
|
|
1831
1322
|
"sources.read": true,
|
|
1832
1323
|
"sources.search": false,
|
|
1833
1324
|
"sources.tree": true,
|
|
1325
|
+
"sources.webOffice": true,
|
|
1834
1326
|
"sources.write": true,
|
|
1835
1327
|
"taskRuns.read": true,
|
|
1836
1328
|
"taskRuns.write": true,
|
|
@@ -1993,6 +1485,12 @@ function createProfile(access, apiPrefix) {
|
|
|
1993
1485
|
decodeStreamPayload(payload) {
|
|
1994
1486
|
return decodeStreamPayload(access, payload);
|
|
1995
1487
|
},
|
|
1488
|
+
featuredNotebookPath(notebookId) {
|
|
1489
|
+
return notebookId === void 0 ? apiPath("featured-notebooks") : apiPath("featured-notebooks", notebookId);
|
|
1490
|
+
},
|
|
1491
|
+
listFeaturedNotebooksPath(input) {
|
|
1492
|
+
return appendQuery(`${apiPrefix}/featured-notebooks`, [["page", input.page], ["page_size", input.pageSize]]);
|
|
1493
|
+
},
|
|
1996
1494
|
listNotebooksPath(input) {
|
|
1997
1495
|
return appendQuery(`${apiPrefix}/notebooks`, [
|
|
1998
1496
|
["page", input.page],
|
|
@@ -2000,6 +1498,12 @@ function createProfile(access, apiPrefix) {
|
|
|
2000
1498
|
["client", input.client]
|
|
2001
1499
|
]);
|
|
2002
1500
|
},
|
|
1501
|
+
listSharedNotebooksPath(input) {
|
|
1502
|
+
return appendQuery(`${apiPrefix}/notebooks/shared`, [["page", input.page], ["page_size", input.pageSize]]);
|
|
1503
|
+
},
|
|
1504
|
+
mindPath(...segments) {
|
|
1505
|
+
return `/api/v1/mind/${segments.map((segment) => encodeId(segment)).join("/")}`;
|
|
1506
|
+
},
|
|
2003
1507
|
notebookPath(notebookId) {
|
|
2004
1508
|
return notebookId === void 0 ? apiPath("notebooks") : apiPath("notebooks", notebookId);
|
|
2005
1509
|
},
|
|
@@ -2031,6 +1535,58 @@ function isQMindTransport(value) {
|
|
|
2031
1535
|
if (!isRecord(value)) return false;
|
|
2032
1536
|
return typeof value.request === "function" && typeof value.stream === "function";
|
|
2033
1537
|
}
|
|
1538
|
+
const managementOperationNames = [
|
|
1539
|
+
"addMember",
|
|
1540
|
+
"createScheduledTask",
|
|
1541
|
+
"deleteScheduledTask",
|
|
1542
|
+
"getCompilationSettings",
|
|
1543
|
+
"getCompilationStatus",
|
|
1544
|
+
"listMembers",
|
|
1545
|
+
"listScheduledTasks",
|
|
1546
|
+
"removeMember",
|
|
1547
|
+
"saveCompilationSettings",
|
|
1548
|
+
"startCompilation",
|
|
1549
|
+
"updateMemberPermission",
|
|
1550
|
+
"updateScheduledTask"
|
|
1551
|
+
];
|
|
1552
|
+
const cardOperationNames = [
|
|
1553
|
+
"batchDeleteCards",
|
|
1554
|
+
"deleteCard",
|
|
1555
|
+
"getCard",
|
|
1556
|
+
"listCards",
|
|
1557
|
+
"listFeaturedCards"
|
|
1558
|
+
];
|
|
1559
|
+
const importOperationNames = [
|
|
1560
|
+
"getAliDingImportRun",
|
|
1561
|
+
"listAliDingImportRunItems",
|
|
1562
|
+
"listImportProviders",
|
|
1563
|
+
"startAliDingKnowledgeBaseImport",
|
|
1564
|
+
"startAliDingNodeSubtreeImport"
|
|
1565
|
+
];
|
|
1566
|
+
function createLazyCardOperations(context) {
|
|
1567
|
+
let operations;
|
|
1568
|
+
const load = () => {
|
|
1569
|
+
operations ??= import("./cards-2J6ebaI0.js").then(({ createCardOperations }) => createCardOperations(context));
|
|
1570
|
+
return operations;
|
|
1571
|
+
};
|
|
1572
|
+
return Object.fromEntries(cardOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
1573
|
+
}
|
|
1574
|
+
function createLazyImportOperations(context) {
|
|
1575
|
+
let operations;
|
|
1576
|
+
const load = () => {
|
|
1577
|
+
operations ??= import("./imports-Da88W09Q.js").then(({ createImportOperations }) => createImportOperations(context));
|
|
1578
|
+
return operations;
|
|
1579
|
+
};
|
|
1580
|
+
return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
1581
|
+
}
|
|
1582
|
+
function createLazyManagementOperations(context) {
|
|
1583
|
+
let operations;
|
|
1584
|
+
const load = () => {
|
|
1585
|
+
operations ??= import("./management-xYuUDFtg.js").then(({ createManagementOperations }) => createManagementOperations(context));
|
|
1586
|
+
return operations;
|
|
1587
|
+
};
|
|
1588
|
+
return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
|
|
1589
|
+
}
|
|
2034
1590
|
function createQMindClient(options) {
|
|
2035
1591
|
if (!isRecord(options)) throw invalidArgument$1("client options must be an object", "options");
|
|
2036
1592
|
if (!isQMindAccess(options.access)) throw invalidArgument$1("access must be either \"sash\" or \"dashboard\"", "access");
|
|
@@ -2045,8 +1601,10 @@ function createQMindClient(options) {
|
|
|
2045
1601
|
access: profile.access,
|
|
2046
1602
|
capabilities: profile.capabilities,
|
|
2047
1603
|
...createNotebookOperations(context),
|
|
2048
|
-
...
|
|
1604
|
+
...createLazyCardOperations(context),
|
|
2049
1605
|
...createSourceOperations(context),
|
|
1606
|
+
...createLazyImportOperations(context),
|
|
1607
|
+
...createLazyManagementOperations(context),
|
|
2050
1608
|
...createTransferOperations(context),
|
|
2051
1609
|
...createAgentOperations(context),
|
|
2052
1610
|
supports(capability) {
|
|
@@ -2055,65 +1613,6 @@ function createQMindClient(options) {
|
|
|
2055
1613
|
});
|
|
2056
1614
|
}
|
|
2057
1615
|
//#endregion
|
|
2058
|
-
//#region src/argv.ts
|
|
2059
|
-
const SHORT_OPTIONS = /* @__PURE__ */ new Set([
|
|
2060
|
-
"-h",
|
|
2061
|
-
"-V",
|
|
2062
|
-
"-o",
|
|
2063
|
-
"-q"
|
|
2064
|
-
]);
|
|
2065
|
-
/**
|
|
2066
|
-
* Preserve the historical Go CLI spelling where long options used one dash.
|
|
2067
|
-
* The delimiter is an intentional hard boundary: everything after `--` is a
|
|
2068
|
-
* positional value and must remain byte-for-byte unchanged.
|
|
2069
|
-
*/
|
|
2070
|
-
function normalizeLegacyArgv(argv) {
|
|
2071
|
-
let positionalOnly = false;
|
|
2072
|
-
return argv.map((argument) => {
|
|
2073
|
-
if (argument === "--") {
|
|
2074
|
-
positionalOnly = true;
|
|
2075
|
-
return argument;
|
|
2076
|
-
}
|
|
2077
|
-
if (positionalOnly || SHORT_OPTIONS.has(argument) || argument.startsWith("--")) return argument;
|
|
2078
|
-
if (/^-[A-Za-z][A-Za-z0-9-]+(?:=.*)?$/.test(argument)) return `-${argument}`;
|
|
2079
|
-
return argument;
|
|
2080
|
-
});
|
|
2081
|
-
}
|
|
2082
|
-
/** Runtime errors use the JSON error envelope only when the caller explicitly
|
|
2083
|
-
* selected JSON, except folder sync whose compatibility default is JSON. */
|
|
2084
|
-
function requestsJsonOutput(argv) {
|
|
2085
|
-
let explicitFormat;
|
|
2086
|
-
let positionalOnly = false;
|
|
2087
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
2088
|
-
const argument = argv[index];
|
|
2089
|
-
if (argument === "--") {
|
|
2090
|
-
positionalOnly = true;
|
|
2091
|
-
continue;
|
|
2092
|
-
}
|
|
2093
|
-
if (positionalOnly) continue;
|
|
2094
|
-
if (argument === "--format" || argument === "-format") {
|
|
2095
|
-
explicitFormat = argv[index + 1];
|
|
2096
|
-
index += 1;
|
|
2097
|
-
continue;
|
|
2098
|
-
}
|
|
2099
|
-
const match = argument?.match(/^--?format=(.*)$/);
|
|
2100
|
-
if (match !== null && match !== void 0) explicitFormat = match[1];
|
|
2101
|
-
}
|
|
2102
|
-
if (explicitFormat !== void 0) return explicitFormat === "json";
|
|
2103
|
-
return argv[0] === "upload-folder" || argv[0] === "sync";
|
|
2104
|
-
}
|
|
2105
|
-
//#endregion
|
|
2106
|
-
//#region src/build-info.ts
|
|
2107
|
-
const QMIND_CLI_VERSION = "2.0.0";
|
|
2108
|
-
const QMIND_CLI_BUILD_TIME = "development";
|
|
2109
|
-
const QMIND_CLI_UPDATE_BASE_URL = typeof __QMIND_CLI_UPDATE_BASE_URL__ === "string" ? __QMIND_CLI_UPDATE_BASE_URL__ : "https://qoder-ide-cn.oss-cn-hangzhou.aliyuncs.com/qmind/cli/";
|
|
2110
|
-
function qmindCliPlatform() {
|
|
2111
|
-
return process.platform === "win32" ? "windows" : process.platform;
|
|
2112
|
-
}
|
|
2113
|
-
function qmindCliArchitecture() {
|
|
2114
|
-
return process.arch === "x64" ? "amd64" : process.arch;
|
|
2115
|
-
}
|
|
2116
|
-
//#endregion
|
|
2117
1616
|
//#region ../node-host/src/auth.ts
|
|
2118
1617
|
const responseRecordSchema = z.record(z.string(), z.unknown());
|
|
2119
1618
|
const personalTokenExchangeSchema = z.object({ token: z.string().min(1) });
|
|
@@ -2336,7 +1835,7 @@ function createQMindCliAuthManager(options) {
|
|
|
2336
1835
|
if (token.length > 0) return token;
|
|
2337
1836
|
const candidate = explicitToken || credentials?.deviceToken || "";
|
|
2338
1837
|
if (candidate.length === 0) {
|
|
2339
|
-
if (options.config.nonInteractive) throw new QMindError("AUTH_REQUIRED",
|
|
1838
|
+
if (options.config.nonInteractive) throw new QMindError("AUTH_REQUIRED", `no credentials found; run '${options.loginCommand ?? "qmind login"}' in an interactive terminal`);
|
|
2340
1839
|
await login();
|
|
2341
1840
|
return token;
|
|
2342
1841
|
}
|
|
@@ -2372,18 +1871,32 @@ function createQMindCliAuthManager(options) {
|
|
|
2372
1871
|
//#endregion
|
|
2373
1872
|
//#region ../node-host/src/authenticated-transport.ts
|
|
2374
1873
|
function withBearer(request, token) {
|
|
1874
|
+
const headers = Object.fromEntries(Object.entries(request.headers ?? {}).filter(([name]) => name.toLowerCase() !== "authorization"));
|
|
2375
1875
|
return {
|
|
2376
1876
|
...request,
|
|
2377
1877
|
headers: {
|
|
2378
|
-
...
|
|
1878
|
+
...headers,
|
|
2379
1879
|
authorization: `Bearer ${token}`
|
|
2380
1880
|
}
|
|
2381
1881
|
};
|
|
2382
1882
|
}
|
|
2383
|
-
|
|
1883
|
+
/** A caller-supplied per-request bearer wins over process-level auth and skips refresh. */
|
|
1884
|
+
function hasRequestAuthorization(request) {
|
|
1885
|
+
const headers = request.headers;
|
|
1886
|
+
if (headers === void 0) return false;
|
|
1887
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === "authorization");
|
|
1888
|
+
}
|
|
1889
|
+
function hostCredentialRequired() {
|
|
1890
|
+
return new QMindError("AUTH_REQUIRED", "The embedding host did not provide a credential for this request.");
|
|
1891
|
+
}
|
|
1892
|
+
function createAuthenticatedQMindTransport(transport, auth, requestCredential) {
|
|
2384
1893
|
return Object.freeze({
|
|
2385
1894
|
async request(request) {
|
|
2386
1895
|
if (request.destination.kind === "signed") return await transport.request(request);
|
|
1896
|
+
const providedToken = (await requestCredential?.())?.trim();
|
|
1897
|
+
if (providedToken) return await transport.request(withBearer(request, providedToken));
|
|
1898
|
+
if (hasRequestAuthorization(request)) return await transport.request(request);
|
|
1899
|
+
if (requestCredential !== void 0) throw hostCredentialRequired();
|
|
2387
1900
|
const token = await auth.getToken();
|
|
2388
1901
|
const response = await transport.request(withBearer(request, token));
|
|
2389
1902
|
if (response.status !== 401) return response;
|
|
@@ -2391,6 +1904,10 @@ function createAuthenticatedQMindTransport(transport, auth) {
|
|
|
2391
1904
|
return await transport.request(withBearer(request, refreshed));
|
|
2392
1905
|
},
|
|
2393
1906
|
async stream(request) {
|
|
1907
|
+
const providedToken = (await requestCredential?.())?.trim();
|
|
1908
|
+
if (providedToken) return await transport.stream(withBearer(request, providedToken));
|
|
1909
|
+
if (hasRequestAuthorization(request)) return await transport.stream(request);
|
|
1910
|
+
if (requestCredential !== void 0) throw hostCredentialRequired();
|
|
2394
1911
|
const token = await auth.getToken();
|
|
2395
1912
|
const response = await transport.stream(withBearer(request, token));
|
|
2396
1913
|
if (response.kind !== "response" || response.status !== 401) return response;
|
|
@@ -2426,10 +1943,31 @@ const PRESETS = Object.freeze({
|
|
|
2426
1943
|
sashOrigin: "https://test-openapi.qoder.sh"
|
|
2427
1944
|
}
|
|
2428
1945
|
});
|
|
1946
|
+
/**
|
|
1947
|
+
* Embedding product identity → that product's backends per environment. Two products share neither
|
|
1948
|
+
* dashboard nor Sash, so a host that declares its identity must be routed by it; falling back to the
|
|
1949
|
+
* environment table alone would send the second product's requests to the first product's backend,
|
|
1950
|
+
* which is indistinguishable from a correct call on the wire.
|
|
1951
|
+
*
|
|
1952
|
+
* Cells that no backend exists for yet are absent rather than borrowed: resolving one throws.
|
|
1953
|
+
*/
|
|
1954
|
+
const PRODUCT_PRESETS = Object.freeze({
|
|
1955
|
+
qoder: PRESETS,
|
|
1956
|
+
"qoder-cn": Object.freeze({
|
|
1957
|
+
prod: {
|
|
1958
|
+
dashboardOrigin: "https://qoder.cn",
|
|
1959
|
+
sashOrigin: "https://openapi.qoder.com.cn"
|
|
1960
|
+
},
|
|
1961
|
+
test: {
|
|
1962
|
+
dashboardOrigin: "https://test.qoder.com.cn",
|
|
1963
|
+
sashOrigin: "https://test-openapi.qoder.com.cn"
|
|
1964
|
+
}
|
|
1965
|
+
})
|
|
1966
|
+
});
|
|
2429
1967
|
function invalidConfig(message, field) {
|
|
2430
1968
|
return new QMindError("INVALID_ARGUMENT", message, { ...field === void 0 ? {} : { details: { field } } });
|
|
2431
1969
|
}
|
|
2432
|
-
function
|
|
1970
|
+
function normalizeQMindOrigin(rawValue, field) {
|
|
2433
1971
|
let url;
|
|
2434
1972
|
try {
|
|
2435
1973
|
url = new URL(rawValue);
|
|
@@ -2439,6 +1977,17 @@ function normalizeOrigin$1(rawValue, field) {
|
|
|
2439
1977
|
if (url.protocol !== "http:" && url.protocol !== "https:" || url.username.length > 0 || url.password.length > 0 || url.pathname !== "/" || url.search.length > 0 || url.hash.length > 0) throw invalidConfig(`${field} must contain only an HTTP(S) scheme and authority`, field);
|
|
2440
1978
|
return url.origin;
|
|
2441
1979
|
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Resolves one registered product/environment without fallback. The default Host config loader
|
|
1982
|
+
* invokes this lazily after explicit overrides; fixed-product callers select the target up front.
|
|
1983
|
+
*/
|
|
1984
|
+
function resolveQMindProductEndpoints(productId, presetName, field = "env") {
|
|
1985
|
+
const presets = Object.hasOwn(PRODUCT_PRESETS, productId) ? PRODUCT_PRESETS[productId] : void 0;
|
|
1986
|
+
if (presets === void 0) throw invalidConfig(`no QMind endpoints are registered for product ${JSON.stringify(productId)}`, field);
|
|
1987
|
+
const preset = Object.hasOwn(presets, presetName) ? presets[presetName] : void 0;
|
|
1988
|
+
if (preset === void 0) throw invalidConfig(`product ${JSON.stringify(productId)} has no ${JSON.stringify(presetName)} endpoints; set ${field} explicitly`, field);
|
|
1989
|
+
return { ...preset };
|
|
1990
|
+
}
|
|
2442
1991
|
function optionalTrimmed(value) {
|
|
2443
1992
|
const trimmed = value?.trim();
|
|
2444
1993
|
return trimmed === void 0 || trimmed.length === 0 ? void 0 : trimmed;
|
|
@@ -2487,31 +2036,73 @@ async function mergedEnvironment(environment, legacyEnvironmentPath) {
|
|
|
2487
2036
|
}
|
|
2488
2037
|
return merged;
|
|
2489
2038
|
}
|
|
2490
|
-
async function fileConfiguration(homeDirectory) {
|
|
2039
|
+
async function fileConfiguration(homeDirectory, fixedEndpoints = false) {
|
|
2491
2040
|
try {
|
|
2492
2041
|
return fileConfigSchema.parse(JSON.parse(await readFile(join(homeDirectory, "config.json"), "utf8")));
|
|
2493
2042
|
} catch (error) {
|
|
2494
2043
|
if (error.code === "ENOENT") return {};
|
|
2044
|
+
if (fixedEndpoints && error instanceof z.ZodError) {
|
|
2045
|
+
const field = error.issues.find((issue) => issue.path[0] === "sash_url" || issue.path[0] === "dashboard_url")?.path[0];
|
|
2046
|
+
if (field !== void 0) throw invalidEndpointHint(`config.json ${String(field)}`);
|
|
2047
|
+
}
|
|
2495
2048
|
throw invalidConfig("stored QMind configuration is invalid");
|
|
2496
2049
|
}
|
|
2497
2050
|
}
|
|
2498
2051
|
function defaultProcessEnvironment() {
|
|
2499
2052
|
return process.env;
|
|
2500
2053
|
}
|
|
2054
|
+
function invalidEndpointHint(field) {
|
|
2055
|
+
return invalidConfig(`${field} is invalid or conflicts with the selected target; remove ${field} and select the target with --env or paired --sash/--dashboard`, field);
|
|
2056
|
+
}
|
|
2057
|
+
function validateFixedEndpoints(options, environment, file) {
|
|
2058
|
+
const target = options.fixedEndpoints;
|
|
2059
|
+
if (target === void 0) return;
|
|
2060
|
+
const checkOrigin = (raw, expected, field, deprecated = true) => {
|
|
2061
|
+
if (raw === void 0) return;
|
|
2062
|
+
let normalized;
|
|
2063
|
+
try {
|
|
2064
|
+
normalized = normalizeQMindOrigin(raw.trim(), field);
|
|
2065
|
+
} catch {
|
|
2066
|
+
throw invalidEndpointHint(field);
|
|
2067
|
+
}
|
|
2068
|
+
if (normalized !== expected) throw invalidEndpointHint(field);
|
|
2069
|
+
if (deprecated) options.reporter?.warn(`warning: ${field} is deprecated and does not select a target; remove ${field}`);
|
|
2070
|
+
};
|
|
2071
|
+
checkOrigin(environment.QMIND_SASH_URL, target.sashOrigin, "QMIND_SASH_URL");
|
|
2072
|
+
checkOrigin(environment.QMIND_DASHBOARD_URL, target.dashboardOrigin, "QMIND_DASHBOARD_URL");
|
|
2073
|
+
checkOrigin(file.sash_url, target.sashOrigin, "config.json sash_url");
|
|
2074
|
+
checkOrigin(file.dashboard_url, target.dashboardOrigin, "config.json dashboard_url");
|
|
2075
|
+
checkOrigin(options.credentialSashOrigin, target.sashOrigin, "credentials.json sash_url", false);
|
|
2076
|
+
if (environment.QMIND_ENV !== void 0) {
|
|
2077
|
+
let legacy;
|
|
2078
|
+
try {
|
|
2079
|
+
legacy = resolveQMindProductEndpoints(options.productId ?? "", environment.QMIND_ENV.trim());
|
|
2080
|
+
} catch {
|
|
2081
|
+
throw invalidEndpointHint("QMIND_ENV");
|
|
2082
|
+
}
|
|
2083
|
+
if (legacy.sashOrigin !== target.sashOrigin || legacy.dashboardOrigin !== target.dashboardOrigin) throw invalidEndpointHint("QMIND_ENV");
|
|
2084
|
+
options.reporter?.warn("warning: QMIND_ENV is deprecated and does not select a target; remove QMIND_ENV");
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2501
2087
|
async function loadQMindCliConfig(options = {}) {
|
|
2502
2088
|
const initialEnvironment = options.environment ?? defaultProcessEnvironment();
|
|
2503
2089
|
const baseHome = options.homeDirectory ?? homedir();
|
|
2504
2090
|
const environment = await mergedEnvironment(initialEnvironment, options.legacyEnvironmentPath === void 0 ? join(baseHome, ".qmind-env") : options.legacyEnvironmentPath);
|
|
2505
2091
|
const configuredHome = optionalTrimmed(environment.QMIND_HOME);
|
|
2506
2092
|
const homeDirectory = resolve(options.homeDirectory ?? configuredHome ?? join(baseHome, ".qmind"));
|
|
2507
|
-
const file = await fileConfiguration(homeDirectory);
|
|
2093
|
+
const file = await fileConfiguration(homeDirectory, options.fixedEndpoints !== void 0);
|
|
2094
|
+
validateFixedEndpoints(options, environment, file);
|
|
2508
2095
|
const flags = options.flags ?? {};
|
|
2509
2096
|
const stdinIsTTY = options.stdinIsTTY ?? process.stdin.isTTY === true;
|
|
2510
2097
|
const presetName = optionalTrimmed(environment.QMIND_ENV) ?? "prod";
|
|
2511
|
-
const
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2098
|
+
const productId = optionalTrimmed(options.productId);
|
|
2099
|
+
const defaultOrigin = (field) => {
|
|
2100
|
+
const preset = productId === void 0 ? PRESETS[presetName] ?? PRESETS.prod : resolveQMindProductEndpoints(productId, presetName, field);
|
|
2101
|
+
return field === "sash" ? preset.sashOrigin : preset.dashboardOrigin;
|
|
2102
|
+
};
|
|
2103
|
+
if (options.fixedEndpoints === void 0 && productId === void 0 && !(presetName in PRESETS)) options.reporter?.warn(`warning: unknown QMIND_ENV ${JSON.stringify(presetName)}, falling back to prod`);
|
|
2104
|
+
const sashOrigin = normalizeQMindOrigin(options.fixedEndpoints?.sashOrigin ?? optionalTrimmed(flags.sash) ?? optionalTrimmed(environment.QMIND_SASH_URL) ?? optionalTrimmed(file.sash_url) ?? optionalTrimmed(options.credentialSashOrigin) ?? defaultOrigin("sash"), "sash");
|
|
2105
|
+
const dashboardOrigin = normalizeQMindOrigin(options.fixedEndpoints?.dashboardOrigin ?? optionalTrimmed(flags.dashboard) ?? optionalTrimmed(environment.QMIND_DASHBOARD_URL) ?? optionalTrimmed(file.dashboard_url) ?? defaultOrigin("dashboard"), "dashboard");
|
|
2515
2106
|
const runtime = Object.freeze({
|
|
2516
2107
|
client: optionalTrimmed(flags.client) ?? optionalTrimmed(environment.QMIND_CLIENT) ?? optionalTrimmed(file.client) ?? "qmind",
|
|
2517
2108
|
dashboardOrigin,
|
|
@@ -2631,27 +2222,17 @@ async function optionalSecret(operation, fallback) {
|
|
|
2631
2222
|
return fallback;
|
|
2632
2223
|
}
|
|
2633
2224
|
}
|
|
2634
|
-
function
|
|
2635
|
-
const entry = async () => {
|
|
2636
|
-
const { Entry } = await import("@napi-rs/keyring");
|
|
2637
|
-
return new Entry("qmind-cli", "device-token");
|
|
2638
|
-
};
|
|
2225
|
+
function createNoopQMindSecretStore() {
|
|
2639
2226
|
return Object.freeze({
|
|
2640
|
-
async delete() {
|
|
2641
|
-
|
|
2642
|
-
}
|
|
2643
|
-
async get() {
|
|
2644
|
-
return await optionalSecret(async () => (await entry()).getPassword() ?? void 0, void 0);
|
|
2645
|
-
},
|
|
2646
|
-
async set(token) {
|
|
2647
|
-
await optionalSecret(async () => void (await entry()).setPassword(token), void 0);
|
|
2648
|
-
}
|
|
2227
|
+
async delete() {},
|
|
2228
|
+
async get() {},
|
|
2229
|
+
async set(_token) {}
|
|
2649
2230
|
});
|
|
2650
2231
|
}
|
|
2651
2232
|
function createFileCredentialVault(options) {
|
|
2652
2233
|
const credentialsPath = join(options.homeDirectory, "credentials.json");
|
|
2653
2234
|
const legacyBackupPath = `${credentialsPath}.v1.bak`;
|
|
2654
|
-
const secretStore = options.secretStore ??
|
|
2235
|
+
const secretStore = options.secretStore ?? createNoopQMindSecretStore();
|
|
2655
2236
|
const now = options.now ?? Date.now;
|
|
2656
2237
|
const loadUnlocked = async () => {
|
|
2657
2238
|
let serialized;
|
|
@@ -2890,6 +2471,11 @@ function headersToRecord(headers) {
|
|
|
2890
2471
|
}
|
|
2891
2472
|
return result;
|
|
2892
2473
|
}
|
|
2474
|
+
function normalizedRequestHeaders(headers) {
|
|
2475
|
+
const result = {};
|
|
2476
|
+
for (const [name, value] of Object.entries(headers ?? {})) result[name.toLowerCase()] = value;
|
|
2477
|
+
return result;
|
|
2478
|
+
}
|
|
2893
2479
|
function parseRawBody(rawBody) {
|
|
2894
2480
|
if (rawBody.trim().length === 0) return void 0;
|
|
2895
2481
|
try {
|
|
@@ -2958,7 +2544,7 @@ function byteLength(value) {
|
|
|
2958
2544
|
return Buffer.byteLength(value, "utf8");
|
|
2959
2545
|
}
|
|
2960
2546
|
function encodeBody(request, boundary) {
|
|
2961
|
-
const initialHeaders =
|
|
2547
|
+
const initialHeaders = normalizedRequestHeaders(request.headers);
|
|
2962
2548
|
const body = request.body;
|
|
2963
2549
|
if (body === void 0) return { headers: initialHeaders };
|
|
2964
2550
|
if (body.kind === "json") {
|
|
@@ -3323,8 +2909,10 @@ function configurationOptions(options, reporter) {
|
|
|
3323
2909
|
...options.credentialSashOrigin === void 0 ? {} : { credentialSashOrigin: options.credentialSashOrigin },
|
|
3324
2910
|
...options.environment === void 0 ? {} : { environment: options.environment },
|
|
3325
2911
|
...options.flags === void 0 ? {} : { flags: options.flags },
|
|
2912
|
+
...options.fixedEndpoints === void 0 ? {} : { fixedEndpoints: options.fixedEndpoints },
|
|
3326
2913
|
...options.homeDirectory === void 0 ? {} : { homeDirectory: options.homeDirectory },
|
|
3327
2914
|
...options.legacyEnvironmentPath === void 0 ? {} : { legacyEnvironmentPath: options.legacyEnvironmentPath },
|
|
2915
|
+
...options.productId === void 0 ? {} : { productId: options.productId },
|
|
3328
2916
|
...reporter === void 0 ? {} : { reporter },
|
|
3329
2917
|
...options.stdinIsTTY === void 0 ? {} : { stdinIsTTY: options.stdinIsTTY }
|
|
3330
2918
|
};
|
|
@@ -3335,7 +2923,7 @@ async function createQMindCliHost(options = {}) {
|
|
|
3335
2923
|
const vault = createFileCredentialVault({
|
|
3336
2924
|
homeDirectory: (await loadQMindCliConfig(configurationOptions(options))).runtime.homeDirectory,
|
|
3337
2925
|
now: () => clock.now(),
|
|
3338
|
-
secretStore: options.adapters?.secretStore ??
|
|
2926
|
+
secretStore: options.adapters?.secretStore ?? createNoopQMindSecretStore()
|
|
3339
2927
|
});
|
|
3340
2928
|
let credentials;
|
|
3341
2929
|
try {
|
|
@@ -3347,7 +2935,7 @@ async function createQMindCliHost(options = {}) {
|
|
|
3347
2935
|
}
|
|
3348
2936
|
const resolved = await loadQMindCliConfig({
|
|
3349
2937
|
...configurationOptions(options, reporter),
|
|
3350
|
-
...credentials?.sashOrigin ? { credentialSashOrigin: credentials.sashOrigin } : {},
|
|
2938
|
+
...options.adapters?.requestCredential === void 0 && credentials?.sashOrigin ? { credentialSashOrigin: credentials.sashOrigin } : {},
|
|
3351
2939
|
reporter
|
|
3352
2940
|
});
|
|
3353
2941
|
const ca = await tlsAuthority(resolved.tlsCaFile);
|
|
@@ -3374,6 +2962,7 @@ async function createQMindCliHost(options = {}) {
|
|
|
3374
2962
|
config: resolved.runtime,
|
|
3375
2963
|
credentials,
|
|
3376
2964
|
explicitToken: resolved.token,
|
|
2965
|
+
...options.loginCommand === void 0 ? {} : { loginCommand: options.loginCommand },
|
|
3377
2966
|
reporter,
|
|
3378
2967
|
transport: rawTransport,
|
|
3379
2968
|
vault
|
|
@@ -3381,7 +2970,7 @@ async function createQMindCliHost(options = {}) {
|
|
|
3381
2970
|
const client = createQMindClient({
|
|
3382
2971
|
access: "sash",
|
|
3383
2972
|
client: resolved.runtime.client,
|
|
3384
|
-
transport: createAuthenticatedQMindTransport(rawTransport, auth)
|
|
2973
|
+
transport: createAuthenticatedQMindTransport(rawTransport, auth, options.adapters?.requestCredential)
|
|
3385
2974
|
});
|
|
3386
2975
|
return Object.freeze({
|
|
3387
2976
|
client,
|
|
@@ -3400,6 +2989,120 @@ async function createQMindCliHost(options = {}) {
|
|
|
3400
2989
|
});
|
|
3401
2990
|
}
|
|
3402
2991
|
//#endregion
|
|
2992
|
+
//#region src/argv.ts
|
|
2993
|
+
const SHORT_OPTIONS = /* @__PURE__ */ new Set([
|
|
2994
|
+
"-h",
|
|
2995
|
+
"-V",
|
|
2996
|
+
"-o",
|
|
2997
|
+
"-q"
|
|
2998
|
+
]);
|
|
2999
|
+
/**
|
|
3000
|
+
* Preserve the historical Go CLI spelling where long options used one dash.
|
|
3001
|
+
* The delimiter is an intentional hard boundary: everything after `--` is a
|
|
3002
|
+
* positional value and must remain byte-for-byte unchanged.
|
|
3003
|
+
*/
|
|
3004
|
+
function normalizeLegacyArgv(argv) {
|
|
3005
|
+
let positionalOnly = false;
|
|
3006
|
+
return argv.map((argument) => {
|
|
3007
|
+
if (argument === "--") {
|
|
3008
|
+
positionalOnly = true;
|
|
3009
|
+
return argument;
|
|
3010
|
+
}
|
|
3011
|
+
if (positionalOnly || SHORT_OPTIONS.has(argument) || argument.startsWith("--")) return argument;
|
|
3012
|
+
if (/^-[A-Za-z][A-Za-z0-9-]+(?:=.*)?$/.test(argument)) return `-${argument}`;
|
|
3013
|
+
return argument;
|
|
3014
|
+
});
|
|
3015
|
+
}
|
|
3016
|
+
/** Runtime errors use the JSON error envelope only when the caller explicitly
|
|
3017
|
+
* selected JSON, except folder sync whose compatibility default is JSON. */
|
|
3018
|
+
function requestsJsonOutput(argv) {
|
|
3019
|
+
let explicitFormat;
|
|
3020
|
+
let positionalOnly = false;
|
|
3021
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
3022
|
+
const argument = argv[index];
|
|
3023
|
+
if (argument === "--") {
|
|
3024
|
+
positionalOnly = true;
|
|
3025
|
+
continue;
|
|
3026
|
+
}
|
|
3027
|
+
if (positionalOnly) continue;
|
|
3028
|
+
if (argument === "--format" || argument === "-format") {
|
|
3029
|
+
explicitFormat = argv[index + 1];
|
|
3030
|
+
index += 1;
|
|
3031
|
+
continue;
|
|
3032
|
+
}
|
|
3033
|
+
const match = argument?.match(/^--?format=(.*)$/);
|
|
3034
|
+
if (match !== null && match !== void 0) explicitFormat = match[1];
|
|
3035
|
+
}
|
|
3036
|
+
if (explicitFormat !== void 0) return explicitFormat === "json";
|
|
3037
|
+
return argv[0] === "upload-folder" || argv[0] === "sync";
|
|
3038
|
+
}
|
|
3039
|
+
//#endregion
|
|
3040
|
+
//#region src/build-info.ts
|
|
3041
|
+
/** Bundled identity, never inferred from argv, environment, or an endpoint. */
|
|
3042
|
+
const QMIND_CLI_DISTRIBUTION = "global";
|
|
3043
|
+
const QMIND_CLI_VERSION = "3.0.0";
|
|
3044
|
+
const QMIND_CLI_BUILD_TIME = "2026-09-01T07:33:25.000Z";
|
|
3045
|
+
function qmindCliPlatform() {
|
|
3046
|
+
return process.platform === "win32" ? "windows" : process.platform;
|
|
3047
|
+
}
|
|
3048
|
+
function qmindCliArchitecture() {
|
|
3049
|
+
return process.arch === "x64" ? "amd64" : process.arch;
|
|
3050
|
+
}
|
|
3051
|
+
//#endregion
|
|
3052
|
+
//#region src/distributions.ts
|
|
3053
|
+
/** Canonical runtime and release identity for every public CLI distribution. */
|
|
3054
|
+
const CLI_DISTRIBUTIONS = Object.freeze({
|
|
3055
|
+
global: {
|
|
3056
|
+
id: "global",
|
|
3057
|
+
command: "qmind",
|
|
3058
|
+
package: "@qoder-ai/qmind-cli",
|
|
3059
|
+
productId: "qoder",
|
|
3060
|
+
gitTagSlug: "qmind-cli",
|
|
3061
|
+
readmeDirectory: ".",
|
|
3062
|
+
productNames: {
|
|
3063
|
+
en: "Qoder Global",
|
|
3064
|
+
zhCN: "Qoder Global"
|
|
3065
|
+
}
|
|
3066
|
+
},
|
|
3067
|
+
cn: {
|
|
3068
|
+
id: "cn",
|
|
3069
|
+
command: "qmind-cn",
|
|
3070
|
+
package: "@qodercn-ai/qmind-cli",
|
|
3071
|
+
productId: "qoder-cn",
|
|
3072
|
+
gitTagSlug: "qmind-cli-cn",
|
|
3073
|
+
readmeDirectory: "readmes/cn",
|
|
3074
|
+
productNames: {
|
|
3075
|
+
en: "Qoder China",
|
|
3076
|
+
zhCN: "Qoder 中国版"
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
});
|
|
3080
|
+
//#endregion
|
|
3081
|
+
//#region src/config.ts
|
|
3082
|
+
function cliHostConfiguration(distribution, flags, environment, stateRoot) {
|
|
3083
|
+
const { productId, command } = CLI_DISTRIBUTIONS[distribution];
|
|
3084
|
+
const custom = flags.sash !== void 0 || flags.dashboard !== void 0;
|
|
3085
|
+
if (custom && (typeof flags.sash !== "string" || typeof flags.dashboard !== "string" || flags.env !== void 0)) throw new QMindError("INVALID_ARGUMENT", "--sash and --dashboard must be supplied together and cannot be combined with --env");
|
|
3086
|
+
const preset = typeof flags.env === "string" ? flags.env.trim() : "prod";
|
|
3087
|
+
const endpoints = custom ? {
|
|
3088
|
+
dashboardOrigin: normalizeQMindOrigin(String(flags.dashboard).trim(), "--dashboard"),
|
|
3089
|
+
sashOrigin: normalizeQMindOrigin(String(flags.sash).trim(), "--sash")
|
|
3090
|
+
} : resolveQMindProductEndpoints(productId, preset);
|
|
3091
|
+
const target = custom ? `custom-${createHash("sha256").update(JSON.stringify([endpoints.dashboardOrigin, endpoints.sashOrigin])).digest("hex")}` : preset;
|
|
3092
|
+
return {
|
|
3093
|
+
environment: {
|
|
3094
|
+
...environment,
|
|
3095
|
+
QMIND_TOKEN: target === "prod" ? environment.QMIND_TOKEN : environment.QMIND_DEBUG_TOKEN
|
|
3096
|
+
},
|
|
3097
|
+
flags,
|
|
3098
|
+
fixedEndpoints: endpoints,
|
|
3099
|
+
homeDirectory: join(resolve(stateRoot ?? (environment.QMIND_HOME?.trim() || join(homedir(), ".qmind"))), "cli", distribution, target),
|
|
3100
|
+
legacyEnvironmentPath: false,
|
|
3101
|
+
loginCommand: `${command} login${custom ? ` --sash ${endpoints.sashOrigin} --dashboard ${endpoints.dashboardOrigin}` : target === "prod" ? "" : ` --env ${target}`}`,
|
|
3102
|
+
productId
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
//#endregion
|
|
3403
3106
|
//#region src/folder-sync.ts
|
|
3404
3107
|
const QMIND_FOLDER_SYNC_DEFAULT_EXTENSIONS = Object.freeze([
|
|
3405
3108
|
".mdx",
|
|
@@ -3761,13 +3464,6 @@ function table(writer, headers, rows, widths, separatorWidth) {
|
|
|
3761
3464
|
}
|
|
3762
3465
|
function goTimestamp(value) {
|
|
3763
3466
|
if (value === void 0 || value === null || value === "") return null;
|
|
3764
|
-
if (typeof value === "object") {
|
|
3765
|
-
const source = record(value);
|
|
3766
|
-
return {
|
|
3767
|
-
nanos: numberValue(source.nanos),
|
|
3768
|
-
seconds: numberValue(source.seconds)
|
|
3769
|
-
};
|
|
3770
|
-
}
|
|
3771
3467
|
const text = stringValue(value);
|
|
3772
3468
|
const milliseconds = Date.parse(text);
|
|
3773
3469
|
if (!Number.isFinite(milliseconds)) return null;
|
|
@@ -4488,6 +4184,7 @@ function createQMindCliStreamRenderer(format) {
|
|
|
4488
4184
|
}
|
|
4489
4185
|
//#endregion
|
|
4490
4186
|
//#region src/application.ts
|
|
4187
|
+
const distribution = CLI_DISTRIBUTIONS[QMIND_CLI_DISTRIBUTION];
|
|
4491
4188
|
function processIO() {
|
|
4492
4189
|
return Object.freeze({
|
|
4493
4190
|
stdinIsTTY: process.stdin.isTTY === true,
|
|
@@ -4548,25 +4245,25 @@ function formatOf(options) {
|
|
|
4548
4245
|
}
|
|
4549
4246
|
function commonFlags(options) {
|
|
4550
4247
|
const client = optionalString(options, "client");
|
|
4551
|
-
const dashboard =
|
|
4552
|
-
const sash =
|
|
4248
|
+
const dashboard = stringOption(options, "dashboard");
|
|
4249
|
+
const sash = stringOption(options, "sash");
|
|
4250
|
+
const env = stringOption(options, "env");
|
|
4553
4251
|
const token = optionalString(options, "token");
|
|
4554
4252
|
return {
|
|
4555
4253
|
...client === void 0 ? {} : { client },
|
|
4254
|
+
...env === void 0 ? {} : { env },
|
|
4556
4255
|
...dashboard === void 0 ? {} : { dashboard },
|
|
4557
4256
|
...options.nonInteractive === true ? { nonInteractive: true } : {},
|
|
4558
4257
|
...sash === void 0 ? {} : { sash },
|
|
4559
4258
|
...token === void 0 ? {} : { token }
|
|
4560
4259
|
};
|
|
4561
4260
|
}
|
|
4562
|
-
async function hostFor(context, options
|
|
4261
|
+
async function hostFor(context, options) {
|
|
4563
4262
|
if (context.host !== void 0) return context.host;
|
|
4564
|
-
const
|
|
4565
|
-
...context.hostOptions.environment ?? process.env,
|
|
4566
|
-
...environmentOverrides
|
|
4567
|
-
};
|
|
4263
|
+
const configuration = cliHostConfiguration(QMIND_CLI_DISTRIBUTION, commonFlags(options), context.hostOptions.environment ?? process.env, context.hostOptions.homeDirectory);
|
|
4568
4264
|
const adapters = {
|
|
4569
4265
|
...context.hostOptions.adapters,
|
|
4266
|
+
secretStore: createNoopQMindSecretStore(),
|
|
4570
4267
|
reporter: context.hostOptions.adapters?.reporter ?? {
|
|
4571
4268
|
info(message) {
|
|
4572
4269
|
context.io.stderr(`${message}\n`);
|
|
@@ -4578,9 +4275,8 @@ async function hostFor(context, options, environmentOverrides = {}) {
|
|
|
4578
4275
|
};
|
|
4579
4276
|
context.host = await context.hostFactory({
|
|
4580
4277
|
...context.hostOptions,
|
|
4278
|
+
...configuration,
|
|
4581
4279
|
adapters,
|
|
4582
|
-
environment,
|
|
4583
|
-
flags: commonFlags(options),
|
|
4584
4280
|
stdinIsTTY: context.io.stdinIsTTY
|
|
4585
4281
|
});
|
|
4586
4282
|
return context.host;
|
|
@@ -4589,7 +4285,7 @@ function render(context, options, presentation) {
|
|
|
4589
4285
|
context.io.stdout(renderQMindCliPresentation(presentation, formatOf(options)));
|
|
4590
4286
|
}
|
|
4591
4287
|
function withCommon(command, output = true) {
|
|
4592
|
-
command.option("--token <token>", "Bearer access token").option("--sash <url>", "Sash
|
|
4288
|
+
command.option("--token <token>", "Bearer access token").option("--env <name>", "product environment: prod (default), test, or daily where supported").option("--sash <url>", "custom debug Sash origin (requires --dashboard; excludes --env)").option("--dashboard <url>", "custom debug Dashboard origin (requires --sash; excludes --env)").option("--org <id>", "organization ID (deprecated and ignored)").option("--client <name>", "originating client identifier").option("--non-interactive", "never open a browser when credentials are missing");
|
|
4593
4289
|
if (output) command.option("--format <format>", "output format: table | json | agent | ndjson", "table");
|
|
4594
4290
|
return command;
|
|
4595
4291
|
}
|
|
@@ -4800,7 +4496,7 @@ function registerSourceCommands(context, program) {
|
|
|
4800
4496
|
kind: "source",
|
|
4801
4497
|
value
|
|
4802
4498
|
});
|
|
4803
|
-
else context.io.stdout(`Site source created: ${value.id}\n title : ${value.title}\n status: ${value.status}\n site : ${rootUrl}\n\nSite import is running asynchronously. Use '
|
|
4499
|
+
else context.io.stdout(`Site source created: ${value.id}\n title : ${value.title}\n status: ${value.status}\n site : ${rootUrl}\n\nSite import is running asynchronously. Use '${distribution.command} source list' to check imported pages.\n`);
|
|
4804
4500
|
});
|
|
4805
4501
|
const image = program.command("image").description("Notebook image presign operations");
|
|
4806
4502
|
withCommon(image.command("presign-upload").description("Presign or upload a notebook image"), false).option("--nb <id>", "notebook ID (required)").option("--source <id>", "source ID (required)").option("--filename <name>", "image filename (required unless --file is set)").option("--mime <type>", "MIME type (required unless --file is set)").option("--size <bytes>", "file size", integer, 0).option("--file <path>", "local image to upload").action(async (raw) => {
|
|
@@ -4897,19 +4593,19 @@ function syncText(stats) {
|
|
|
4897
4593
|
return `[upload-folder] 完成: 创建目录 ${stats.dirs_created} (复用 ${stats.dirs_reused}, 失败 ${stats.dirs_failed}), 上传文件 ${stats.files_uploaded}, 已存在跳过 ${stats.files_already_exist}, 不支持或忽略 ${stats.files_skipped}, 失败 ${stats.files_failed}, 时间戳刷新失败 ${stats.dirs_refresh_failed}` + (stats.files_deleted === void 0 ? "" : `, 删除文件 ${stats.files_deleted}, 删除目录 ${stats.dirs_deleted ?? 0}, 删除失败 ${stats.delete_failed ?? 0}`) + "\n";
|
|
4898
4594
|
}
|
|
4899
4595
|
function registerSyncCommand(context, program) {
|
|
4900
|
-
withCommon(program.command("upload-folder").alias("sync").description("Synchronize a local folder"), false).option("--nb <id>", "notebook ID (required)").option("--dir <path>", "local directory (required)").option("--
|
|
4596
|
+
withCommon(program.command("upload-folder").alias("sync").description("Synchronize a local folder"), false).option("--nb <id>", "notebook ID (required)").option("--dir <path>", "local directory (required)").option("--extensions <list>", "comma-separated extensions").option("--dir-ids <path>", "existing directory ID mapping").option("--skip-upload", "only refresh directory timestamps").option("--concurrency <number>", "parallel uploads", integer, 3).option("--save-dir-ids <path>", "directory ID mapping output").option("--ignore <patterns...>", "glob patterns to exclude").option("--delete", "delete remote entries absent from the local mirror").option("--dry-run", "calculate changes without mutating remote or local state").option("--format <format>", "summary output format: json | text", "json").addOption(new Option("--mode <mode>", "existing-file behavior").choices([
|
|
4901
4597
|
"skip",
|
|
4902
4598
|
"overwrite",
|
|
4903
4599
|
"if-changed"
|
|
4904
4600
|
]).default("skip")).action(async (raw) => {
|
|
4905
|
-
const
|
|
4906
|
-
const host = await hostFor(context, raw, environment === void 0 ? {} : { QMIND_ENV: environment });
|
|
4601
|
+
const host = await hostFor(context, raw);
|
|
4907
4602
|
const ignoreValues = Array.isArray(raw.ignore) ? raw.ignore.flatMap((value) => splitCsv(String(value))) : [];
|
|
4908
4603
|
const directoryIdsPath = optionalString(raw, "dirIds");
|
|
4909
4604
|
const saveDirectoryIdsPath = optionalString(raw, "saveDirIds");
|
|
4910
4605
|
const extensions = splitCsv(optionalString(raw, "extensions"));
|
|
4911
4606
|
const result = await synchronizeQMindFolder(host, {
|
|
4912
4607
|
baseDirectory: requiredString(raw.dir, "--dir"),
|
|
4608
|
+
cacheDirectory: join(host.config.homeDirectory, "cache"),
|
|
4913
4609
|
concurrency: Math.max(1, numberOption(raw, "concurrency", 3)),
|
|
4914
4610
|
delete: raw.delete === true,
|
|
4915
4611
|
dryRun: raw.dryRun === true,
|
|
@@ -4930,42 +4626,30 @@ function registerSyncCommand(context, program) {
|
|
|
4930
4626
|
if (result.exitCode === 1) context.exitCode = 1;
|
|
4931
4627
|
});
|
|
4932
4628
|
}
|
|
4933
|
-
function registerUpdateCommand(
|
|
4934
|
-
program.command("self-update").description("Show the supported qmind CLI upgrade path").option("--url <url>", "
|
|
4629
|
+
function registerUpdateCommand(program) {
|
|
4630
|
+
program.command("self-update").description("Show the supported qmind CLI upgrade path").option("--url <url>", "legacy update URL (ignored)").addOption(new Option("--channel <channel>", "legacy release channel (ignored)").choices([
|
|
4935
4631
|
"stable",
|
|
4936
4632
|
"beta",
|
|
4937
4633
|
"daily"
|
|
4938
|
-
]).default("stable")).option("--public-key <key>", "
|
|
4939
|
-
|
|
4940
|
-
const result = await context.selfUpdater.update({
|
|
4941
|
-
allowDowngrade: raw.allowDowngrade === true,
|
|
4942
|
-
baseUrl: String(raw.url),
|
|
4943
|
-
channel: String(raw.channel),
|
|
4944
|
-
check: raw.check === true,
|
|
4945
|
-
currentVersion: QMIND_CLI_VERSION,
|
|
4946
|
-
force: raw.force === true,
|
|
4947
|
-
publicKey: String(raw.publicKey ?? "")
|
|
4948
|
-
});
|
|
4949
|
-
if (result.updated) context.io.stdout(`[self-update] updated ${QMIND_CLI_VERSION} -> ${result.version}\n`);
|
|
4950
|
-
else if (result.version === "2.0.0".replace(/^v/, "")) context.io.stdout(`[self-update] already current: ${result.version}\n`);
|
|
4951
|
-
else context.io.stdout(`[self-update] verified available version: ${result.version}\n`);
|
|
4634
|
+
]).default("stable")).option("--public-key <key>", "legacy public key (ignored)").option("--check", "legacy check mode (ignored)").option("--force", "legacy reinstall mode (ignored)").option("--allow-downgrade", "legacy downgrade mode (ignored)").action(() => {
|
|
4635
|
+
throw new QMindError("UNSUPPORTED_OPERATION", `self-update is unavailable for npm installs; run npm update --global ${distribution.package}`);
|
|
4952
4636
|
});
|
|
4953
4637
|
}
|
|
4954
4638
|
/** Internal parser adapter. Product consumers should call runQMindCli(). */
|
|
4955
4639
|
function createQMindCliProgram(context) {
|
|
4956
|
-
const program = new Command().name(
|
|
4640
|
+
const program = new Command().name(distribution.command).description("QMind knowledge CLI").version(QMIND_CLI_VERSION).showHelpAfterError().exitOverride().configureOutput({
|
|
4957
4641
|
writeErr: (value) => context.io.stderr(value),
|
|
4958
4642
|
writeOut: (value) => context.io.stdout(value)
|
|
4959
4643
|
});
|
|
4960
4644
|
program.command("version").description("Print version and build information").action(() => {
|
|
4961
|
-
context.io.stdout(
|
|
4645
|
+
context.io.stdout(`${distribution.command} ${QMIND_CLI_VERSION} (built ${QMIND_CLI_BUILD_TIME}, ${qmindCliPlatform()}/${qmindCliArchitecture()})\n`);
|
|
4962
4646
|
});
|
|
4963
4647
|
registerCoreCommands(context, program);
|
|
4964
4648
|
registerSourceCommands(context, program);
|
|
4965
4649
|
registerSceneCommands(context, program);
|
|
4966
4650
|
registerTaskCommands(context, program);
|
|
4967
4651
|
registerSyncCommand(context, program);
|
|
4968
|
-
registerUpdateCommand(
|
|
4652
|
+
registerUpdateCommand(program);
|
|
4969
4653
|
return program;
|
|
4970
4654
|
}
|
|
4971
4655
|
async function runQMindCli(argv, options = {}) {
|
|
@@ -4976,8 +4660,7 @@ async function runQMindCli(argv, options = {}) {
|
|
|
4976
4660
|
host: void 0,
|
|
4977
4661
|
hostFactory: options.hostFactory ?? createQMindCliHost,
|
|
4978
4662
|
hostOptions: options.hostOptions ?? {},
|
|
4979
|
-
io
|
|
4980
|
-
...options.selfUpdater === void 0 ? {} : { selfUpdater: options.selfUpdater }
|
|
4663
|
+
io
|
|
4981
4664
|
};
|
|
4982
4665
|
const normalized = normalizeLegacyArgv(argv);
|
|
4983
4666
|
const requiresLegacyAction = normalized.length === 0 || normalized.length === 1 && (/* @__PURE__ */ new Set([
|