@qoder-ai/qmind-cli 4.3.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/qmind.js CHANGED
@@ -1,6 +1,6 @@
1
- import { A as sourceWebOfficeSessionSchema, C as sourcePreviewSchema, D as sourceTreeSchema, E as sourceSchema, I as voidResponseSchema, M as streamWireEventSchema, N as taskRunListSchema, O as sourceUploadCapabilitiesSchema, P as taskRunSchema, S as sourceListSchema, T as sourceRawContentSchema, _ as sharedNotebookListSchema, a as chatMessageListSchema, b as sourceContentSchema, d as imageUrlsSchema, g as retrieveResultSchema, h as retrieveNotebooksResultSchema, i as cancelQuestionResultSchema, j as sourceWebOfficeTokenSchema, m as notebookSchema, o as chatSessionListSchema, p as notebookListSchema, r as batchDeleteResultSchema, s as chatSessionSchema, u as imageUploadTicketSchema, v as sourceActionAccessSchema, w as sourceQuotaSchema, x as sourceImportResultsSchema, y as sourceChildrenCountsSchema } from "./schemas-DG7vaJMR.js";
2
- import { _ as assertCapability, a as invalidArgument$1, b as QMindError, c as optionalRecord, d as pagination$1, f as positiveInteger$1, g as stringList, i as httpUrl, l as optionalString$1, m as requiredString$2, n as call, o as nonNegativeInteger$1, p as queryPath, r as compactUndefined, s as optionalBoolean, t as assertNonEmptyPatch, u as optionalTrimmedString, v as executeStream } from "./shared-CbvrtGyv.js";
3
- import { t as preflightSourceUpload } from "./source-upload-XrNG4_4V.js";
1
+ import { $ as sourceRawContentSchema, D as qmindPath, F as chatSessionSchema, G as sharedNotebookListSchema, H as notebookSchema, J as sourceContentSchema, K as sourceActionAccessSchema, M as cancelQuestionResultSchema, N as chatMessageListSchema, O as qmindRoutes, P as chatSessionListSchema, Q as sourceQuotaSchema, R as imageUploadTicketSchema, U as retrieveNotebooksResultSchema, V as notebookListSchema, W as retrieveResultSchema, X as sourceListSchema, Y as sourceImportResultsSchema, Z as sourcePreviewSchema, _ as assertCapability, a as invalidArgument$1, at as taskRunListSchema, c as optionalRecord, ct as voidResponseSchema, d as pagination$1, et as sourceSchema, f as positiveInteger$1, g as stringList, i as httpUrl, it as sourceWebOfficeTokenSchema, j as batchDeleteResultSchema, l as optionalString$1, m as requiredString$1, n as call, o as nonNegativeInteger$1, ot as taskRunSchema, p as queryPath, q as sourceChildrenCountsSchema, r as compactUndefined, rt as sourceWebOfficeSessionSchema, s as optionalBoolean, t as assertNonEmptyPatch, tt as sourceUploadCapabilitiesSchema, u as optionalTrimmedString, ut as QMindError, v as executeStream, z as imageUrlsSchema } from "./shared-evTnu_EB.js";
2
+ import { n as nezhaWebOfficePath } from "./nezha-B_SP8BvK.js";
3
+ import { t as preflightSourceUpload } from "./source-upload-DckYHoRo.js";
4
4
  import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
5
5
  import { z } from "zod";
6
6
  import { createHash, randomBytes, randomUUID } from "node:crypto";
@@ -23,13 +23,16 @@ import semver from "semver";
23
23
  import { createInterface } from "node:readline/promises";
24
24
  //#region ../agent-core/src/scheduled-task-inputs.ts
25
25
  const id = z.string().trim().min(1).max(512);
26
- const scheduledTaskScene = z.enum([
27
- "compilation",
26
+ const writableScene$1 = z.enum([
28
27
  "condensation",
29
- "lint",
30
28
  "source_refresh",
31
29
  "source_binding_sync"
32
30
  ]);
31
+ const scheduledTaskScene = z.enum([
32
+ ...writableScene$1.options,
33
+ "compilation",
34
+ "lint"
35
+ ]);
33
36
  const schedule = z.string().trim().min(1).max(512).refine((value) => {
34
37
  const fields = value.split(/\s+/u);
35
38
  const zone = /^(?:CRON_TZ|TZ)=(.+)$/u.exec(fields[0] ?? "")?.[1];
@@ -43,7 +46,7 @@ const schedule = z.string().trim().min(1).max(512).refine((value) => {
43
46
  }, "schedule requires an explicit CRON_TZ/TZ IANA zone and five or six cron fields");
44
47
  const createScheduledTaskInputSchema = z.object({
45
48
  notebookId: id,
46
- sceneType: scheduledTaskScene,
49
+ sceneType: writableScene$1,
47
50
  schedule
48
51
  }).strict();
49
52
  const updateScheduledTaskInputSchema = z.object({
@@ -66,77 +69,117 @@ const listScheduledTasksInputSchema = z.object({
66
69
  }).strict();
67
70
  //#endregion
68
71
  //#region ../sdk/src/operations/office-preview.ts
69
- const secret = /^[A-Za-z0-9_-]{32,128}$/;
70
- const ticketSchema = z.object({
71
- sessionId: z.string().regex(secret),
72
- ticket: z.string().regex(secret),
73
- orgId: z.string(),
74
- expiresAt: z.iso.datetime({ offset: true })
75
- });
76
- function origin(value, field) {
72
+ const secret = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
73
+ const grantSchema = z.object({
74
+ sessionId: secret,
75
+ ticket: secret,
76
+ previewUrl: z.string(),
77
+ expiresAt: z.iso.datetime({ offset: true }),
78
+ authorizationExpiresAt: z.iso.datetime({ offset: true })
79
+ }).refine((grant) => {
77
80
  try {
78
- const url = new URL(value);
79
- if (url.protocol === "https:" && url.origin === value) return value;
80
- } catch {}
81
- throw invalidArgument$1("Office preview requires an exact HTTPS origin", field);
82
- }
83
- function opaque(value, field) {
84
- if (typeof value !== "string" || !secret.test(value)) throw invalidArgument$1("Invalid preview binding", field);
85
- return value;
86
- }
81
+ const url = new URL(grant.previewUrl);
82
+ return url.protocol === "https:" && !url.username && !url.password && !url.search && !url.hash && url.pathname === `/algo/api/mind-preview/${grant.sessionId}/gate` && Date.parse(grant.authorizationExpiresAt) <= Date.parse(grant.expiresAt);
83
+ } catch {
84
+ return false;
85
+ }
86
+ });
87
87
  function createOfficePreviewOperations(context) {
88
- const path = (notebookId, sourceId) => context.profile.apiPath("notebooks", requiredString$2(notebookId, "notebookId"), "sources", requiredString$2(sourceId, "sourceId"), "weboffice", "preview");
89
- return {
90
- async createOfficePreview(notebookId, sourceId, input, options) {
91
- const audience = origin(input?.audience, "audience");
92
- const parentOrigin = origin(input?.parentOrigin, "parentOrigin");
93
- if (new URL(audience).hostname === new URL(parentOrigin).hostname) throw invalidArgument$1("Preview requires a separate hostname", "audience");
94
- return call(context, {
95
- capability: "sources.officeProxy",
96
- operation: "sources.officeProxy.create",
97
- method: "POST",
98
- idempotent: false,
99
- path: path(notebookId, sourceId),
100
- body: {
101
- nonce: opaque(input?.nonce, "nonce"),
102
- audience,
103
- parentOrigin
104
- },
105
- schema: ticketSchema,
106
- callOptions: options
107
- });
108
- },
109
- async revokeOfficePreview(notebookId, sourceId, sessionId, orgId, options) {
110
- if (typeof orgId !== "string") throw invalidArgument$1("Resource organization is required", "orgId");
111
- return call(context, {
112
- capability: "sources.officeProxy",
113
- operation: "sources.officeProxy.revoke",
114
- method: "POST",
115
- idempotent: false,
116
- path: `${path(notebookId, sourceId)}/${opaque(sessionId, "sessionId")}/revoke`,
117
- body: { orgId },
118
- schema: voidResponseSchema,
119
- callOptions: options
120
- });
121
- },
122
- async revokeAllOfficePreviews(options) {
123
- return call(context, {
124
- capability: "sources.officeProxy",
125
- operation: "sources.officeProxy.revokeAll",
126
- method: "POST",
127
- idempotent: false,
128
- path: context.profile.apiPath("weboffice", "previews", "revoke"),
129
- body: {},
130
- schema: voidResponseSchema,
131
- callOptions: options
132
- });
88
+ async function grant(notebookId, sourceId, sessionId, options) {
89
+ const operation = sessionId === void 0 ? "sources.officeProxy.create" : "sources.officeProxy.renew";
90
+ assertCapability(context.capabilities, "sources.officeProxy", operation);
91
+ const nonce = btoa(String.fromCharCode(...crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)))).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
92
+ const notebook = requiredString$1(notebookId, "notebookId");
93
+ const source = requiredString$1(sourceId, "sourceId");
94
+ const segments = ["preview"];
95
+ if (sessionId !== void 0) {
96
+ if (!secret.safeParse(sessionId).success) throw invalidArgument$1("sessionId must be a valid Office preview session ID", "sessionId");
97
+ segments.push(sessionId, "renew");
133
98
  }
99
+ const result = await call(context, {
100
+ capability: "sources.officeProxy",
101
+ operation,
102
+ method: "POST",
103
+ idempotent: false,
104
+ path: nezhaWebOfficePath(context.webOffice, notebook, source, ...segments),
105
+ body: { nonce },
106
+ schema: grantSchema,
107
+ callOptions: options
108
+ });
109
+ if (sessionId !== void 0 && result.sessionId !== sessionId) throw new QMindError("PROTOCOL_ERROR", "Office preview session mismatch");
110
+ return {
111
+ ...result,
112
+ nonce
113
+ };
114
+ }
115
+ return {
116
+ createOfficePreview: (notebookId, sourceId, options) => grant(notebookId, sourceId, void 0, options),
117
+ renewOfficePreviewAuthorization: (notebookId, sourceId, sessionId, options) => grant(notebookId, sourceId, sessionId, options)
134
118
  };
135
119
  }
136
120
  //#endregion
121
+ //#region ../sdk/src/capabilities.ts
122
+ const notebookCapabilities = Object.freeze({
123
+ dataSources: true,
124
+ "wiki.read": false,
125
+ chat: true,
126
+ "featuredChat.delete": false,
127
+ "featuredNotebooks.read": true,
128
+ "featuredNotebooks.copy": true,
129
+ "images.presignUpload": true,
130
+ "images.presignUrls": true,
131
+ "imports.aliDing": true,
132
+ "imports.discover": true,
133
+ "imports.fullSiteURL": true,
134
+ members: true,
135
+ "members.search": false,
136
+ "members.resolve": true,
137
+ "notebooks.filterByClient": true,
138
+ "notebooks.read": true,
139
+ "notebooks.write": true,
140
+ "notes.read": true,
141
+ "notes.write": true,
142
+ "notes.saveCondensation": true,
143
+ retrieval: true,
144
+ scheduledTasks: true,
145
+ "sharedNotebooks.read": true,
146
+ "sources.children": true,
147
+ "sources.childrenCount": true,
148
+ "sources.actionAccess": true,
149
+ "sources.importWeb": true,
150
+ "sources.preview": true,
151
+ "sources.rawContent": true,
152
+ "sources.read": true,
153
+ "sources.quota": true,
154
+ "sources.search": true,
155
+ "sources.tree": true,
156
+ "sources.webOffice": false,
157
+ "sources.officeProxy": false,
158
+ "sources.write": true,
159
+ "taskRuns.read": true,
160
+ "taskRuns.write": true,
161
+ transfers: true,
162
+ "wikiBranches.read": true,
163
+ "wikiBranches.page": true
164
+ });
165
+ function createCapabilities(nezha) {
166
+ const webOffice = nezha.webOffice !== void 0;
167
+ return Object.freeze({
168
+ ...notebookCapabilities,
169
+ "sources.webOffice": webOffice,
170
+ "sources.officeProxy": webOffice,
171
+ "wiki.read": nezha.repoWiki === true
172
+ });
173
+ }
174
+ //#endregion
175
+ //#region ../sdk/src/management.ts
176
+ /** Retired scenes remain readable in historical sessions, task runs and schedules. */
177
+ function isQMindRetiredScene(scene) {
178
+ return scene === "compilation" || scene === "lint";
179
+ }
180
+ //#endregion
137
181
  //#region ../sdk/src/operations/agents.ts
138
- 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.";
139
- function isRecord$3(value) {
182
+ function isRecord$2(value) {
140
183
  return typeof value === "object" && value !== null && !Array.isArray(value);
141
184
  }
142
185
  function finiteNumber(value, field) {
@@ -180,52 +223,56 @@ function billingContext(value) {
180
223
  });
181
224
  }
182
225
  function retrieveBody(input) {
183
- if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
226
+ if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
184
227
  return compactUndefined({
185
228
  billingContext: billingContext(input.billingContext),
186
229
  maxResults: nonNegativeInteger$1(input.maxResults, "maxResults"),
187
- query: requiredString$2(input.query, "query"),
230
+ query: requiredString$1(input.query, "query"),
188
231
  queryHints: queryHints(input.queryHints),
189
232
  scoreThreshold: finiteNumber(input.scoreThreshold, "scoreThreshold"),
190
233
  sourceIds: stringList(input.sourceIds ?? [], "sourceIds"),
191
234
  topK: nonNegativeInteger$1(input.topK, "topK")
192
235
  });
193
236
  }
237
+ function writableScene(value) {
238
+ if (isQMindRetiredScene(value)) throw invalidArgument$1("This Notebook scene has been retired", "sceneType");
239
+ return value;
240
+ }
194
241
  function chatSessionBody(input = {}) {
195
- if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
242
+ if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
196
243
  return compactUndefined({
197
244
  metadata: optionalRecord(input.metadata, "metadata"),
198
245
  modelOverride: optionalTrimmedString(input.modelOverride, "modelOverride"),
199
- sceneType: optionalTrimmedString(input.sceneType, "sceneType") ?? "rag",
246
+ sceneType: writableScene(optionalTrimmedString(input.sceneType, "sceneType")) ?? "rag",
200
247
  status: optionalTrimmedString(input.status, "status"),
201
248
  title: optionalString$1(input.title, "title")
202
249
  });
203
250
  }
204
251
  function streamBody(input) {
205
- if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
252
+ if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
206
253
  return compactUndefined({
207
- content: requiredString$2(input.content, "content"),
254
+ content: requiredString$1(input.content, "content"),
208
255
  maxResults: nonNegativeInteger$1(input.maxResults, "maxResults"),
209
256
  modelOverride: optionalTrimmedString(input.modelOverride, "modelOverride"),
210
- sceneType: optionalTrimmedString(input.sceneType, "sceneType"),
257
+ sceneType: writableScene(optionalTrimmedString(input.sceneType, "sceneType")),
211
258
  sourceIds: stringList(input.sourceIds ?? [], "sourceIds"),
212
259
  topK: nonNegativeInteger$1(input.topK, "topK")
213
260
  });
214
261
  }
215
262
  function taskRunBody(input) {
216
- if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
263
+ if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
217
264
  return compactUndefined({
218
265
  chatSessionId: optionalTrimmedString(input.chatSessionId, "chatSessionId"),
219
266
  config: optionalRecord(input.config, "config"),
220
267
  parentRunId: optionalTrimmedString(input.parentRunId, "parentRunId"),
221
- sceneType: requiredString$2(input.sceneType, "sceneType"),
268
+ sceneType: writableScene(requiredString$1(input.sceneType, "sceneType")),
222
269
  settings: optionalRecord(input.settings, "settings"),
223
270
  scheduledTaskId: optionalTrimmedString(input.scheduledTaskId, "scheduledTaskId"),
224
271
  trigger: optionalTrimmedString(input.trigger, "trigger")
225
272
  });
226
273
  }
227
- function taskRunListPath(context, notebookId, input = {}) {
228
- if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
274
+ function taskRunListPath(notebookId, input = {}) {
275
+ if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
229
276
  const normalizedPage = pagination$1(input);
230
277
  const status = optionalTrimmedString(input.status, "status");
231
278
  if (status !== void 0 && ![
@@ -236,7 +283,7 @@ function taskRunListPath(context, notebookId, input = {}) {
236
283
  "failed",
237
284
  "canceled"
238
285
  ].includes(status)) throw invalidArgument$1("status must be a known task run status", "status");
239
- return queryPath(context.profile.apiPath("notebooks", notebookId, "task-runs"), [
286
+ return queryPath(qmindPath("notebooks", notebookId, "task-runs"), [
240
287
  ["scheduled_task_id", optionalTrimmedString(input.scheduledTaskId, "scheduledTaskId")],
241
288
  ["parent_run_id", optionalTrimmedString(input.parentRunId, "parentRunId")],
242
289
  ["scene_type", optionalTrimmedString(input.sceneType, "sceneType")],
@@ -248,19 +295,14 @@ function taskRunListPath(context, notebookId, input = {}) {
248
295
  ]);
249
296
  }
250
297
  function agentContent(input) {
251
- if (input.scene === "rag") return {
252
- content: requiredString$2(input.question, "question"),
298
+ return {
299
+ content: requiredString$1(input.question, "question"),
253
300
  maxResults: input.maxResults,
254
301
  modelOverride: input.modelOverride,
255
302
  sceneType: "rag",
256
303
  sourceIds: input.sourceIds,
257
304
  topK: input.topK
258
305
  };
259
- return {
260
- content: `Begin the ${input.scene} workflow now for this notebook. ${workflowPrompt}`,
261
- modelOverride: input.modelOverride,
262
- sceneType: input.scene
263
- };
264
306
  }
265
307
  function callOptions$1(options) {
266
308
  return {
@@ -277,20 +319,20 @@ function streamCallOptions(options) {
277
319
  }
278
320
  function createAgentOperations(context) {
279
321
  const getChatSessionFor = (notebookId, sessionId, options, featured) => {
280
- const notebook = requiredString$2(notebookId, "notebookId");
281
- const session = requiredString$2(sessionId, "sessionId");
322
+ const notebook = requiredString$1(notebookId, "notebookId");
323
+ const session = requiredString$1(sessionId, "sessionId");
282
324
  return call(context, {
283
325
  callOptions: options,
284
326
  capability: featured ? "featuredNotebooks.read" : "chat",
285
327
  idempotent: true,
286
328
  method: "GET",
287
329
  operation: featured ? "featuredChatSessions.get" : "chatSessions.get",
288
- path: context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session),
330
+ path: qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session),
289
331
  schema: chatSessionSchema
290
332
  });
291
333
  };
292
334
  const createChatSessionFor = (notebookId, input, options, featured) => {
293
- const notebook = requiredString$2(notebookId, "notebookId");
335
+ const notebook = requiredString$1(notebookId, "notebookId");
294
336
  return call(context, {
295
337
  body: chatSessionBody(input),
296
338
  callOptions: options,
@@ -298,19 +340,19 @@ function createAgentOperations(context) {
298
340
  idempotent: false,
299
341
  method: "POST",
300
342
  operation: featured ? "featuredChatSessions.create" : "chatSessions.create",
301
- path: context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions"),
343
+ path: qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions"),
302
344
  schema: chatSessionSchema
303
345
  });
304
346
  };
305
347
  const createChatSession = (notebookId, input, options) => createChatSessionFor(notebookId, input, options, false);
306
348
  const createFeaturedChatSession = (notebookId, input, options) => createChatSessionFor(notebookId, input, options, true);
307
349
  const streamQuestionFor = (notebookId, sessionId, input, options, featured) => {
308
- const notebook = requiredString$2(notebookId, "notebookId");
309
- const session = requiredString$2(sessionId, "sessionId");
350
+ const notebook = requiredString$1(notebookId, "notebookId");
351
+ const session = requiredString$1(sessionId, "sessionId");
310
352
  return executeStream({
311
353
  capability: featured ? "featuredNotebooks.read" : "chat",
312
354
  operation: featured ? "featuredChat.stream" : "chat.stream",
313
- profile: context.profile,
355
+ capabilities: context.capabilities,
314
356
  request: {
315
357
  body: {
316
358
  kind: "json",
@@ -318,7 +360,7 @@ function createAgentOperations(context) {
318
360
  },
319
361
  destination: {
320
362
  kind: "host",
321
- path: queryPath(context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages", "stream"), [["client", context.client]])
363
+ path: queryPath(qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages", "stream"), [["client", context.client]])
322
364
  },
323
365
  idempotent: false,
324
366
  method: "POST",
@@ -330,9 +372,9 @@ function createAgentOperations(context) {
330
372
  const streamQuestion = (notebookId, sessionId, input, options) => streamQuestionFor(notebookId, sessionId, input, options, false);
331
373
  const streamFeaturedQuestion = (notebookId, sessionId, input, options) => streamQuestionFor(notebookId, sessionId, input, options, true);
332
374
  const cancelQuestionFor = (notebookId, sessionId, input = {}, options, featured = false) => {
333
- const notebook = requiredString$2(notebookId, "notebookId");
334
- const session = requiredString$2(sessionId, "sessionId");
335
- if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
375
+ const notebook = requiredString$1(notebookId, "notebookId");
376
+ const session = requiredString$1(sessionId, "sessionId");
377
+ if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
336
378
  return call(context, {
337
379
  body: compactUndefined({ reason: optionalTrimmedString(input.reason, "reason") }),
338
380
  callOptions: options,
@@ -340,12 +382,12 @@ function createAgentOperations(context) {
340
382
  idempotent: false,
341
383
  method: "POST",
342
384
  operation: featured ? "featuredChat.cancel" : "chat.cancel",
343
- path: context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages", "cancel"),
385
+ path: qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages", "cancel"),
344
386
  schema: cancelQuestionResultSchema
345
387
  });
346
388
  };
347
389
  const listChatSessionsFor = (notebookId, input = {}, options, featured = false) => {
348
- const notebook = requiredString$2(notebookId, "notebookId");
390
+ const notebook = requiredString$1(notebookId, "notebookId");
349
391
  const normalizedPage = pagination$1({
350
392
  page: input.page ?? 1,
351
393
  pageSize: input.pageSize ?? 20
@@ -356,13 +398,13 @@ function createAgentOperations(context) {
356
398
  idempotent: true,
357
399
  method: "GET",
358
400
  operation: featured ? "featuredChatSessions.list" : "chatSessions.list",
359
- path: queryPath(context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions"), [["page", normalizedPage.page], ["page_size", normalizedPage.pageSize]]),
401
+ path: queryPath(qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions"), [["page", normalizedPage.page], ["page_size", normalizedPage.pageSize]]),
360
402
  schema: chatSessionListSchema
361
403
  });
362
404
  };
363
405
  const listChatMessagesFor = (notebookId, sessionId, input = {}, options, featured = false) => {
364
- const notebook = requiredString$2(notebookId, "notebookId");
365
- const session = requiredString$2(sessionId, "sessionId");
406
+ const notebook = requiredString$1(notebookId, "notebookId");
407
+ const session = requiredString$1(sessionId, "sessionId");
366
408
  const normalizedPage = pagination$1({
367
409
  page: input.page ?? 1,
368
410
  pageSize: input.pageSize ?? 100
@@ -373,27 +415,27 @@ function createAgentOperations(context) {
373
415
  idempotent: true,
374
416
  method: "GET",
375
417
  operation: featured ? "featuredChatMessages.list" : "chatMessages.list",
376
- path: queryPath(context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages"), [["page", normalizedPage.page], ["page_size", normalizedPage.pageSize]]),
418
+ path: queryPath(qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session, "messages"), [["page", normalizedPage.page], ["page_size", normalizedPage.pageSize]]),
377
419
  schema: chatMessageListSchema
378
420
  });
379
421
  };
380
422
  const deleteChatSessionFor = (notebookId, sessionId, options, featured = false) => {
381
- const notebook = requiredString$2(notebookId, "notebookId");
382
- const session = requiredString$2(sessionId, "sessionId");
423
+ const notebook = requiredString$1(notebookId, "notebookId");
424
+ const session = requiredString$1(sessionId, "sessionId");
383
425
  return call(context, {
384
426
  callOptions: options,
385
427
  capability: featured ? "featuredChat.delete" : "chat",
386
428
  idempotent: false,
387
429
  method: "DELETE",
388
430
  operation: featured ? "featuredChatSessions.delete" : "chatSessions.delete",
389
- path: context.profile.apiPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session),
431
+ path: qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "chat-sessions", session),
390
432
  schema: voidResponseSchema
391
433
  });
392
434
  };
393
435
  const startAgentRunFor = async (notebookId, input, options, featured) => {
394
- if (!isRecord$3(input)) throw invalidArgument$1("input must be an object", "input");
395
- if (input.scene !== "rag" && input.scene !== "compilation" && input.scene !== "lint") throw invalidArgument$1("scene must be rag, compilation or lint", "scene");
396
- const notebook = requiredString$2(notebookId, "notebookId");
436
+ if (!isRecord$2(input)) throw invalidArgument$1("input must be an object", "input");
437
+ if (input.scene !== "rag") throw invalidArgument$1("scene must be rag", "scene");
438
+ const notebook = requiredString$1(notebookId, "notebookId");
397
439
  const scene = input.scene;
398
440
  const modelOverride = optionalTrimmedString(input.modelOverride, "modelOverride");
399
441
  const title = optionalString$1(input.title, "title");
@@ -418,7 +460,7 @@ function createAgentOperations(context) {
418
460
  deleteChatSession: (notebookId, sessionId, options) => deleteChatSessionFor(notebookId, sessionId, options),
419
461
  deleteFeaturedChatSession: (notebookId, sessionId, options) => deleteChatSessionFor(notebookId, sessionId, options, true),
420
462
  async createTaskRun(notebookId, input, options) {
421
- const notebook = requiredString$2(notebookId, "notebookId");
463
+ const notebook = requiredString$1(notebookId, "notebookId");
422
464
  const body = taskRunBody(input);
423
465
  if ("sourceId" in input) throw invalidArgument$1("Use refreshSource for a source-scoped refresh.", "sourceId");
424
466
  return call(context, {
@@ -428,25 +470,25 @@ function createAgentOperations(context) {
428
470
  idempotent: false,
429
471
  method: "POST",
430
472
  operation: "taskRuns.create",
431
- path: context.profile.apiPath("notebooks", notebook, "task-runs"),
473
+ path: qmindPath("notebooks", notebook, "task-runs"),
432
474
  schema: taskRunSchema
433
475
  });
434
476
  },
435
477
  async getTaskRun(notebookId, runId, options) {
436
- const notebook = requiredString$2(notebookId, "notebookId");
437
- const run = requiredString$2(runId, "runId");
478
+ const notebook = requiredString$1(notebookId, "notebookId");
479
+ const run = requiredString$1(runId, "runId");
438
480
  return call(context, {
439
481
  callOptions: options,
440
482
  capability: "taskRuns.read",
441
483
  idempotent: true,
442
484
  method: "GET",
443
485
  operation: "taskRuns.get",
444
- path: context.profile.apiPath("notebooks", notebook, "task-runs", run),
486
+ path: qmindPath("notebooks", notebook, "task-runs", run),
445
487
  schema: taskRunSchema
446
488
  });
447
489
  },
448
490
  async listTaskRuns(notebookId, input, options) {
449
- const notebook = requiredString$2(notebookId, "notebookId");
491
+ const notebook = requiredString$1(notebookId, "notebookId");
450
492
  const sourceId = optionalTrimmedString(input?.sourceId, "sourceId");
451
493
  const result = await call(context, {
452
494
  callOptions: options,
@@ -454,7 +496,7 @@ function createAgentOperations(context) {
454
496
  idempotent: true,
455
497
  method: "GET",
456
498
  operation: "taskRuns.list",
457
- path: taskRunListPath(context, notebook, input),
499
+ path: taskRunListPath(notebook, input),
458
500
  schema: taskRunListSchema
459
501
  });
460
502
  if (sourceId !== void 0 && result.runs.some((run) => run.sourceId !== sourceId || run.notebookId !== notebook)) throw new QMindError("UNSUPPORTED_OPERATION", "The server did not honor source-scoped task history.", { operation: "taskRuns.list" });
@@ -465,11 +507,11 @@ function createAgentOperations(context) {
465
507
  listFeaturedChatMessages: (notebookId, sessionId, input, options) => listChatMessagesFor(notebookId, sessionId, input, options, true),
466
508
  listFeaturedChatSessions: (notebookId, input, options) => listChatSessionsFor(notebookId, input, options, true),
467
509
  async retrieveNotebooks(input, options) {
468
- if (!isRecord$3(input) || !Array.isArray(input.targets) || input.targets.length === 0) throw invalidArgument$1("targets must be a non-empty array", "targets");
510
+ if (!isRecord$2(input) || !Array.isArray(input.targets) || input.targets.length === 0) throw invalidArgument$1("targets must be a non-empty array", "targets");
469
511
  const seen = /* @__PURE__ */ new Set();
470
512
  const targets = input.targets.map((target) => {
471
- if (!isRecord$3(target)) throw invalidArgument$1("target must be an object", "targets");
472
- const notebookId = requiredString$2(target.notebookId, "notebookId");
513
+ if (!isRecord$2(target)) throw invalidArgument$1("target must be an object", "targets");
514
+ const notebookId = requiredString$1(target.notebookId, "notebookId");
473
515
  if (seen.has(notebookId)) throw invalidArgument$1("targets must be unique", "targets");
474
516
  seen.add(notebookId);
475
517
  if (target.preference !== void 0 && target.preference !== "default" && target.preference !== "preferred") throw invalidArgument$1("preference must be default or preferred", "preference");
@@ -490,12 +532,12 @@ function createAgentOperations(context) {
490
532
  idempotent: false,
491
533
  method: "POST",
492
534
  operation: "retrieval.retrieveNotebooks",
493
- path: context.profile.apiPath("notebooks", "retrieve"),
535
+ path: qmindPath("notebooks", "retrieve"),
494
536
  schema: retrieveNotebooksResultSchema
495
537
  });
496
538
  },
497
539
  async retrieve(notebookId, input, options) {
498
- const notebook = requiredString$2(notebookId, "notebookId");
540
+ const notebook = requiredString$1(notebookId, "notebookId");
499
541
  return call(context, {
500
542
  body: retrieveBody(input),
501
543
  callOptions: options,
@@ -503,12 +545,12 @@ function createAgentOperations(context) {
503
545
  idempotent: false,
504
546
  method: "POST",
505
547
  operation: "retrieval.retrieve",
506
- path: context.profile.apiPath("notebooks", notebook, "retrieve"),
548
+ path: qmindPath("notebooks", notebook, "retrieve"),
507
549
  schema: retrieveResultSchema
508
550
  });
509
551
  },
510
552
  async retrieveFeatured(notebookId, input, options) {
511
- const notebook = requiredString$2(notebookId, "notebookId");
553
+ const notebook = requiredString$1(notebookId, "notebookId");
512
554
  return call(context, {
513
555
  body: retrieveBody(input),
514
556
  callOptions: options,
@@ -516,7 +558,7 @@ function createAgentOperations(context) {
516
558
  idempotent: false,
517
559
  method: "POST",
518
560
  operation: "retrieval.retrieveFeatured",
519
- path: context.profile.apiPath("featured-notebooks", notebook, "retrieve"),
561
+ path: qmindPath("featured-notebooks", notebook, "retrieve"),
520
562
  schema: retrieveResultSchema
521
563
  });
522
564
  },
@@ -530,22 +572,22 @@ function createAgentOperations(context) {
530
572
  //#region ../sdk/src/operations/notebooks.ts
531
573
  function createNotebookOperations(context) {
532
574
  let wikiOperations;
533
- const loadWiki = () => wikiOperations ??= import("./wiki-branches-BfEMuXDW.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
575
+ const loadWiki = () => wikiOperations ??= import("./wiki-branches-DViaqEOy.js").then(({ createWikiBranchOperations }) => createWikiBranchOperations(context));
534
576
  return {
535
577
  async copyFeaturedNotebook(notebookId, options) {
536
- const notebook = requiredString$2(notebookId, "notebookId");
578
+ const notebook = requiredString$1(notebookId, "notebookId");
537
579
  return call(context, {
538
580
  callOptions: options,
539
581
  capability: "featuredNotebooks.copy",
540
582
  idempotent: false,
541
583
  method: "POST",
542
584
  operation: "featuredNotebooks.copy",
543
- path: context.profile.apiPath("featured-notebooks", notebook, "copy"),
585
+ path: qmindPath("featured-notebooks", notebook, "copy"),
544
586
  schema: notebookSchema
545
587
  });
546
588
  },
547
589
  async createNotebook(input, options) {
548
- const title = requiredString$2(input?.title, "title");
590
+ const title = requiredString$1(input?.title, "title");
549
591
  const description = optionalString$1(input?.description, "description");
550
592
  const settings = optionalRecord(input?.settings, "settings");
551
593
  return call(context, {
@@ -560,43 +602,43 @@ function createNotebookOperations(context) {
560
602
  idempotent: false,
561
603
  method: "POST",
562
604
  operation: "notebooks.create",
563
- path: context.profile.apiPath("notebooks"),
605
+ path: qmindPath("notebooks"),
564
606
  schema: notebookSchema
565
607
  });
566
608
  },
567
609
  async deleteNotebook(notebookId, options) {
568
- const id = requiredString$2(notebookId, "notebookId");
610
+ const id = requiredString$1(notebookId, "notebookId");
569
611
  return call(context, {
570
612
  callOptions: options,
571
613
  capability: "notebooks.write",
572
614
  idempotent: false,
573
615
  method: "DELETE",
574
616
  operation: "notebooks.delete",
575
- path: context.profile.apiPath("notebooks", id),
617
+ path: qmindPath("notebooks", id),
576
618
  schema: voidResponseSchema
577
619
  });
578
620
  },
579
621
  async getNotebook(notebookId, options) {
580
- const id = requiredString$2(notebookId, "notebookId");
622
+ const id = requiredString$1(notebookId, "notebookId");
581
623
  return call(context, {
582
624
  callOptions: options,
583
625
  capability: "notebooks.read",
584
626
  idempotent: true,
585
627
  method: "GET",
586
628
  operation: "notebooks.get",
587
- path: context.profile.apiPath("notebooks", id),
629
+ path: qmindPath("notebooks", id),
588
630
  schema: notebookSchema
589
631
  });
590
632
  },
591
633
  async getFeaturedNotebook(notebookId, options) {
592
- const id = requiredString$2(notebookId, "notebookId");
634
+ const id = requiredString$1(notebookId, "notebookId");
593
635
  return call(context, {
594
636
  callOptions: options,
595
637
  capability: "featuredNotebooks.read",
596
638
  idempotent: true,
597
639
  method: "GET",
598
640
  operation: "featuredNotebooks.get",
599
- path: context.profile.featuredNotebookPath(id),
641
+ path: qmindRoutes.featuredNotebookPath(id),
600
642
  schema: notebookSchema
601
643
  });
602
644
  },
@@ -608,7 +650,7 @@ function createNotebookOperations(context) {
608
650
  idempotent: true,
609
651
  method: "GET",
610
652
  operation: "featuredNotebooks.list",
611
- path: context.profile.listFeaturedNotebooksPath(normalized),
653
+ path: qmindRoutes.listFeaturedNotebooksPath(normalized),
612
654
  schema: notebookListSchema
613
655
  });
614
656
  },
@@ -616,7 +658,7 @@ function createNotebookOperations(context) {
616
658
  const normalizedPage = pagination$1(input);
617
659
  const retrievalEligibleOnly = optionalBoolean(input.retrievalEligibleOnly, "retrievalEligibleOnly");
618
660
  const client = optionalTrimmedString(input.client, "client");
619
- if (client !== void 0 && !context.profile.capabilities["notebooks.filterByClient"]) assertCapability(context.profile, "notebooks.filterByClient", "notebooks.list");
661
+ if (client !== void 0 && !context.capabilities["notebooks.filterByClient"]) assertCapability(context.capabilities, "notebooks.filterByClient", "notebooks.list");
620
662
  const normalized = {
621
663
  ...normalizedPage,
622
664
  ...retrievalEligibleOnly === void 0 ? {} : { retrievalEligibleOnly },
@@ -628,7 +670,7 @@ function createNotebookOperations(context) {
628
670
  idempotent: true,
629
671
  method: "GET",
630
672
  operation: "notebooks.list",
631
- path: context.profile.listNotebooksPath(normalized),
673
+ path: qmindRoutes.listNotebooksPath(normalized),
632
674
  schema: notebookListSchema
633
675
  });
634
676
  },
@@ -644,19 +686,19 @@ function createNotebookOperations(context) {
644
686
  idempotent: true,
645
687
  method: "GET",
646
688
  operation: "sharedNotebooks.list",
647
- path: context.profile.listSharedNotebooksPath(normalized),
689
+ path: qmindRoutes.listSharedNotebooksPath(normalized),
648
690
  schema: sharedNotebookListSchema
649
691
  });
650
692
  },
651
693
  listWikiBranches: (...args) => loadWiki().then((loaded) => loaded.listWikiBranches(...args)),
652
694
  listWikiBranchesPage: (...args) => loadWiki().then((loaded) => loaded.listWikiBranchesPage(...args)),
653
695
  async updateNotebook(notebookId, input, options) {
654
- const id = requiredString$2(notebookId, "notebookId");
696
+ const id = requiredString$1(notebookId, "notebookId");
655
697
  const body = compactUndefined({
656
698
  description: optionalString$1(input?.description, "description"),
657
699
  settings: optionalRecord(input?.settings, "settings"),
658
700
  status: optionalString$1(input?.status, "status"),
659
- title: input?.title === void 0 ? void 0 : requiredString$2(input.title, "title")
701
+ title: input?.title === void 0 ? void 0 : requiredString$1(input.title, "title")
660
702
  });
661
703
  assertNonEmptyPatch(body, "input");
662
704
  return call(context, {
@@ -666,7 +708,7 @@ function createNotebookOperations(context) {
666
708
  idempotent: false,
667
709
  method: "PUT",
668
710
  operation: "notebooks.update",
669
- path: context.profile.apiPath("notebooks", id),
711
+ path: qmindPath("notebooks", id),
670
712
  schema: notebookSchema
671
713
  });
672
714
  }
@@ -735,7 +777,7 @@ function metadataOf(source) {
735
777
  const metadata = source?.metadata;
736
778
  return metadata !== null && typeof metadata === "object" ? metadata : {};
737
779
  }
738
- function isRecord$2(value) {
780
+ function isRecord$1(value) {
739
781
  return typeof value === "object" && value !== null && !Array.isArray(value);
740
782
  }
741
783
  function text(value) {
@@ -766,7 +808,7 @@ function isQMindEmailSource(source) {
766
808
  }
767
809
  function qmindEmailAttachmentRef(source) {
768
810
  const value = metadataOf(source).emailAttachment;
769
- if (!isRecord$2(value)) return null;
811
+ if (!isRecord$1(value)) return null;
770
812
  return Object.freeze({
771
813
  emailSourceId: text(value.emailSourceId),
772
814
  index: typeof value.index === "number" && Number.isFinite(value.index) ? Math.floor(value.index) : -1,
@@ -804,7 +846,7 @@ function isQMindEmailAggregateMember(source, siblings) {
804
846
  }
805
847
  /** The external provider that owns this source, lowercased, or '' when QMind owns it. */
806
848
  function qmindSourceProvider(source) {
807
- return (source?.externalBinding?.provider ?? metadataText(source, "externalProvider", "external_provider")).toLowerCase();
849
+ return (source?.dataSource?.provider ?? source?.externalBinding?.provider ?? metadataText(source, "externalProvider", "external_provider")).toLowerCase();
808
850
  }
809
851
  /**
810
852
  * `externalBinding` is authoritative; the metadata fallback keeps sources readable on gateways that
@@ -812,11 +854,22 @@ function qmindSourceProvider(source) {
812
854
  */
813
855
  function isQMindExternalSource(source) {
814
856
  const provider = qmindSourceProvider(source);
815
- return source?.externalBinding !== void 0 || provider === "aliding" || provider === "repowiki";
857
+ return source?.dataSource !== void 0 || source?.externalBinding !== void 0 || provider === "aliding" || provider === "repowiki";
816
858
  }
817
859
  [.../* @__PURE__ */ new Set(["axls", "alxs"])];
818
- /** Operations allowed by persisted ownership, independent of the visible tree position. */
860
+ /**
861
+ * Operations allowed by persisted ownership, independent of the visible tree position.
862
+ * Managed roots may be removed as a whole through their own entry; the managed tree
863
+ * below any root is only changed by provider synchronization.
864
+ */
819
865
  function qmindSourceOperationPolicy(source) {
866
+ if (source?.dataSource) return {
867
+ rename: !source.dataSource.readOnly,
868
+ move: !source.dataSource.readOnly,
869
+ addChildren: !source.dataSource.readOnly,
870
+ delete: source.dataSource.canDelete,
871
+ menu: "ordinary"
872
+ };
820
873
  const binding = source?.externalBinding;
821
874
  if (binding === void 0) return {
822
875
  rename: true,
@@ -825,7 +878,7 @@ function qmindSourceOperationPolicy(source) {
825
878
  addChildren: true,
826
879
  menu: "ordinary"
827
880
  };
828
- const menu = binding.isRoot && binding.provider === "site_catalog" ? "site" : binding.isRoot && binding.provider === "aliding" ? "aliding" : "none";
881
+ const menu = binding.isRoot && binding.provider === "site_catalog" ? "site" : binding.isRoot && binding.provider === "aliding" ? "aliding" : binding.isRoot && binding.provider === "repowiki" ? "repowiki" : "none";
829
882
  return {
830
883
  rename: false,
831
884
  move: false,
@@ -870,7 +923,10 @@ function buildQMindSourceTree(sources) {
870
923
  if (node === void 0) continue;
871
924
  const parent = nodesById.get(source.parentSourceId);
872
925
  if (parent === void 0 || createsSourceCycle(source, sourcesById)) tree.push(node);
873
- else parent.files.push(node);
926
+ else {
927
+ parent.files.push(node);
928
+ parent.hasChildren = true;
929
+ }
874
930
  }
875
931
  sortSourceTree(tree);
876
932
  return {
@@ -885,6 +941,7 @@ function projectQMindSourceTreeNode(source, sources, files = []) {
885
941
  ...source.learning === void 0 ? {} : { learning: source.learning },
886
942
  ...source.learningStatus === void 0 ? {} : { learningStatus: source.learningStatus },
887
943
  ...source.learningErrorCode === void 0 ? {} : { learningErrorCode: source.learningErrorCode },
944
+ ...source.dataSource === void 0 ? {} : { dataSource: source.dataSource },
888
945
  ...source.externalBinding === void 0 ? {} : { externalBinding: source.externalBinding },
889
946
  ...source.originUrl === void 0 ? {} : { originUrl: source.originUrl },
890
947
  ...source.metadata === void 0 ? {} : { metadata: source.metadata },
@@ -904,6 +961,7 @@ function projectQMindSourceTreeNode(source, sources, files = []) {
904
961
  }
905
962
  //#endregion
906
963
  //#region ../sdk/src/operations/sources.ts
964
+ var SourcePaginationDrift = class extends QMindError {};
907
965
  const maxImageBytes = 52428800;
908
966
  function sourceBody(input) {
909
967
  return compactUndefined({
@@ -913,7 +971,7 @@ function sourceBody(input) {
913
971
  path: optionalString$1(input?.path, "path"),
914
972
  sourceType: optionalTrimmedString(input?.sourceType, "sourceType"),
915
973
  status: optionalTrimmedString(input?.status, "status"),
916
- title: requiredString$2(input?.title, "title"),
974
+ title: requiredString$1(input?.title, "title"),
917
975
  uri: optionalString$1(input?.uri, "uri")
918
976
  });
919
977
  }
@@ -934,30 +992,34 @@ function sourcePatch(input) {
934
992
  return patch;
935
993
  }
936
994
  function siteBody(input) {
995
+ if (typeof input === "object" && input !== null) {
996
+ const removed = [
997
+ "parentSourceId",
998
+ "pathPrefix",
999
+ "compileAfterRefresh"
1000
+ ].find((field) => Reflect.get(input, field) !== void 0);
1001
+ if (removed !== void 0) throw invalidArgument$1(`${removed} is unsupported for site import`, removed);
1002
+ }
937
1003
  const maxPages = positiveInteger$1(input?.maxPages, "maxPages") ?? 50;
938
1004
  if (maxPages > 200) throw invalidArgument$1("maxPages must not exceed 200", "maxPages");
939
1005
  const includePaths = stringList(input?.includePaths ?? [], "includePaths");
940
1006
  const excludePaths = stringList(input?.excludePaths ?? [], "excludePaths");
941
1007
  const sitemap = optionalTrimmedString(input?.sitemapUrl, "sitemapUrl");
942
- const compileAfterRefresh = optionalBoolean(input?.compileAfterRefresh, "compileAfterRefresh");
943
1008
  return compactUndefined({
944
1009
  config: compactUndefined({
945
- compileAfterRefresh,
946
1010
  excludePaths,
947
1011
  includePaths,
948
1012
  maxPages,
949
1013
  rootUrl: httpUrl(input?.rootUrl, "rootUrl"),
950
1014
  sitemapUrl: sitemap === void 0 ? void 0 : httpUrl(sitemap, "sitemapUrl")
951
1015
  }),
952
- parentSourceId: optionalString$1(input?.parentSourceId, "parentSourceId"),
953
- path: optionalString$1(input?.pathPrefix, "pathPrefix"),
954
1016
  sourceType: "site_import",
955
1017
  title: optionalTrimmedString(input?.title, "title")
956
1018
  });
957
1019
  }
958
1020
  function createSourceOperations(context) {
959
1021
  const createSource = async (notebookId, input, options) => {
960
- const notebook = requiredString$2(notebookId, "notebookId");
1022
+ const notebook = requiredString$1(notebookId, "notebookId");
961
1023
  return call(context, {
962
1024
  body: sourceBody(input),
963
1025
  callOptions: options,
@@ -965,13 +1027,13 @@ function createSourceOperations(context) {
965
1027
  idempotent: false,
966
1028
  method: "POST",
967
1029
  operation: "sources.create",
968
- path: context.profile.apiPath("notebooks", notebook, "sources"),
1030
+ path: qmindPath("notebooks", notebook, "sources"),
969
1031
  schema: sourceSchema
970
1032
  });
971
1033
  };
972
1034
  const updateSource = async (notebookId, sourceId, input, options) => {
973
- const notebook = requiredString$2(notebookId, "notebookId");
974
- const source = requiredString$2(sourceId, "sourceId");
1035
+ const notebook = requiredString$1(notebookId, "notebookId");
1036
+ const source = requiredString$1(sourceId, "sourceId");
975
1037
  return call(context, {
976
1038
  body: sourcePatch(input),
977
1039
  callOptions: options,
@@ -979,22 +1041,26 @@ function createSourceOperations(context) {
979
1041
  idempotent: false,
980
1042
  method: "PUT",
981
1043
  operation: "sources.update",
982
- path: context.profile.apiPath("notebooks", notebook, "sources", source),
1044
+ path: qmindPath("notebooks", notebook, "sources", source),
983
1045
  schema: sourceSchema
984
1046
  });
985
1047
  };
986
1048
  const readSourcePage = async (notebookId, input = {}, options, operation = "sources.list") => {
987
- const notebook = requiredString$2(notebookId, "notebookId");
988
- const normalizedPage = pagination$1(input);
1049
+ const notebook = requiredString$1(notebookId, "notebookId");
1050
+ const featured = operation === "featuredSources.list" || operation === "featuredSources.children.list";
1051
+ const normalizedPage = pagination$1(featured ? {
1052
+ page: input.page ?? 1,
1053
+ pageSize: input.pageSize ?? 200
1054
+ } : input);
989
1055
  const isDir = optionalBoolean(input.isDir, "isDir");
990
1056
  const view = input.view ?? "list";
991
1057
  if (view !== "list" && view !== "children") throw invalidArgument$1("view must be either \"list\" or \"children\"", "view");
992
1058
  const parentSourceId = optionalString$1(input.parentSourceId, "parentSourceId");
993
1059
  const query = optionalTrimmedString(input.query, "query");
994
- if (view === "children") assertCapability(context.profile, "sources.children", "sources.list");
995
- if (query !== void 0) assertCapability(context.profile, "sources.search", "sources.list");
1060
+ if (!featured && view === "children") assertCapability(context.capabilities, "sources.children", operation);
1061
+ if (!featured && query !== void 0) assertCapability(context.capabilities, "sources.search", operation);
996
1062
  if (parentSourceId !== void 0 && view !== "children") throw invalidArgument$1("parentSourceId requires view=\"children\"", "parentSourceId");
997
- const path = queryPath(context.profile.apiPath("notebooks", notebook, "sources"), [
1063
+ const path = queryPath(qmindPath(featured ? "featured-notebooks" : "notebooks", notebook, "sources"), [
998
1064
  ["view", view === "list" ? void 0 : view],
999
1065
  ["is_dir", isDir === void 0 ? void 0 : String(isDir)],
1000
1066
  ["parent_source_id", parentSourceId],
@@ -1004,7 +1070,7 @@ function createSourceOperations(context) {
1004
1070
  ]);
1005
1071
  return call(context, {
1006
1072
  callOptions: options,
1007
- capability: "sources.read",
1073
+ capability: featured ? "featuredNotebooks.read" : "sources.read",
1008
1074
  idempotent: true,
1009
1075
  method: "GET",
1010
1076
  operation,
@@ -1013,6 +1079,7 @@ function createSourceOperations(context) {
1013
1079
  });
1014
1080
  };
1015
1081
  const listSources = (notebookId, input, options) => readSourcePage(notebookId, input, options);
1082
+ const listFeaturedSources = (notebookId, input, options) => readSourcePage(notebookId, input, options, "featuredSources.list");
1016
1083
  const normalizeChildrenPage = (page) => ({
1017
1084
  ...page,
1018
1085
  sources: page.sources.map((source) => ({
@@ -1020,85 +1087,69 @@ function createSourceOperations(context) {
1020
1087
  hasChildren: source.hasChildren ?? (source.childrenCount === void 0 ? source.isDir : source.childrenCount > 0)
1021
1088
  }))
1022
1089
  });
1023
- const isMissingChildrenRoute = (error) => error instanceof QMindError && (error.status === 404 || error.status === 405 || error.upstreamCode?.toLowerCase() === "routenotfound");
1024
- const listFeaturedSources = async (notebookId, input = {}, options) => {
1025
- const notebook = requiredString$2(notebookId, "notebookId");
1026
- const normalizedPage = pagination$1({
1027
- page: input.page ?? 1,
1028
- pageSize: input.pageSize ?? 200
1029
- });
1030
- const parentSourceId = optionalString$1(input.parentSourceId, "parentSourceId");
1031
- const view = input.view ?? "list";
1032
- if (view !== "list" && view !== "children") throw invalidArgument$1("view must be either \"list\" or \"children\"", "view");
1033
- return call(context, {
1034
- callOptions: options,
1035
- capability: "featuredNotebooks.read",
1036
- idempotent: true,
1037
- method: "GET",
1038
- operation: "featuredSources.list",
1039
- path: queryPath(context.profile.apiPath("featured-notebooks", notebook, "sources"), [
1040
- ["view", view === "list" ? void 0 : view],
1041
- ["parent_source_id", parentSourceId],
1042
- ["page", normalizedPage.page],
1043
- ["page_size", normalizedPage.pageSize]
1044
- ]),
1045
- schema: sourceListSchema
1046
- });
1047
- };
1048
- const listSourceChildrenPage = async (featured, notebookId, input, options) => {
1049
- const notebook = requiredString$2(notebookId, "notebookId");
1050
- const { page, pageSize } = pagination$1({
1051
- page: input.page ?? 1,
1052
- pageSize: input.pageSize ?? 100
1053
- });
1054
- const parentSourceId = optionalString$1(input.parentSourceId, "parentSourceId");
1055
- const collection = featured ? "featured-notebooks" : "notebooks";
1056
- const operation = featured ? "featuredSources.children.list" : "sources.children.list";
1057
- if (featured || context.profile.access !== "sash") try {
1058
- const result = await call(context, {
1059
- callOptions: options,
1060
- capability: featured ? "featuredNotebooks.read" : "sources.children",
1061
- idempotent: true,
1062
- method: "GET",
1063
- operation,
1064
- path: queryPath(context.profile.apiPath(collection, notebook, "source-tree", "children"), [
1065
- ["parent_source_id", parentSourceId],
1066
- ["page", page],
1067
- ["page_size", pageSize]
1068
- ]),
1069
- schema: sourceListSchema.nullable()
1070
- });
1071
- if (result !== null) return normalizeChildrenPage(result);
1072
- } catch (error) {
1073
- if (!isMissingChildrenRoute(error)) throw error;
1074
- }
1075
- const fallbackInput = {
1090
+ const listSourceChildrenPage = async (operation, notebookId, input, options) => {
1091
+ const page = input.page ?? 1;
1092
+ const pageSize = input.pageSize ?? 100;
1093
+ if (page > 2147483647 || pageSize > 500) throw invalidArgument$1("Source children pagination exceeds the supported range", "pagination");
1094
+ const result = await readSourcePage(notebookId, {
1095
+ parentSourceId: input.parentSourceId,
1096
+ isDir: input.isDir,
1076
1097
  page,
1077
1098
  pageSize,
1078
- parentSourceId,
1079
1099
  view: "children"
1080
- };
1081
- return normalizeChildrenPage(featured ? await listFeaturedSources(notebook, fallbackInput, options) : await readSourcePage(notebook, fallbackInput, options, "sources.children.list"));
1100
+ }, options, operation);
1101
+ return normalizeChildrenPage(result);
1082
1102
  };
1083
- const listSourceChildren = (notebookId, input = {}, options) => listSourceChildrenPage(false, notebookId, input, options);
1084
- const listFeaturedSourceChildren = (notebookId, input = {}, options) => listSourceChildrenPage(true, notebookId, input, options);
1085
- const collectAllSources = async (notebookId, input = {}, options, operation) => {
1086
- const notebook = requiredString$2(notebookId, "notebookId");
1103
+ const listSourceChildren = (notebookId, input = {}, options) => listSourceChildrenPage("sources.children.list", notebookId, input, options);
1104
+ const listFeaturedSourceChildren = (notebookId, input = {}, options) => listSourceChildrenPage("featuredSources.children.list", notebookId, input, options);
1105
+ const readAllSourcePages = async (notebookId, input, options, operation) => {
1106
+ const notebook = requiredString$1(notebookId, "notebookId");
1087
1107
  const pageSize = positiveInteger$1(input.pageSize, "pageSize") ?? 200;
1088
1108
  const maxPages = positiveInteger$1(input.maxPages, "maxPages") ?? 1e4;
1089
1109
  const sources = [];
1110
+ const seenOnPage = /* @__PURE__ */ new Map();
1111
+ let lastPage = 0;
1112
+ let totalSize = 0;
1090
1113
  for (let page = 1; page <= maxPages; page += 1) {
1091
1114
  const result = await readSourcePage(notebook, {
1092
1115
  page,
1093
- pageSize,
1094
- view: "list"
1116
+ pageSize
1095
1117
  }, options, operation);
1096
- sources.push(...result.sources);
1097
- const lastPage = result.pages?.lastPage;
1098
- if (result.sources.length < pageSize || lastPage !== void 0 && page >= lastPage) return sources;
1118
+ for (const source of result.sources) {
1119
+ const previousPage = seenOnPage.get(source.id);
1120
+ if (previousPage !== void 0) throw new (previousPage === page ? QMindError : SourcePaginationDrift)("PROTOCOL_ERROR", "source pagination returned a duplicate ID", {
1121
+ details: { page },
1122
+ operation
1123
+ });
1124
+ seenOnPage.set(source.id, page);
1125
+ sources.push(source);
1126
+ }
1127
+ lastPage = Math.max(lastPage, result.pages?.lastPage ?? 0);
1128
+ totalSize = Math.max(totalSize, result.totalSize ?? 0, result.pages?.totalSize ?? 0);
1129
+ const emptyPage = result.sources.length === 0;
1130
+ if (emptyPage || lastPage > 0 && page >= lastPage) {
1131
+ if (sources.length < totalSize || emptyPage && lastPage > 1 && page <= lastPage) throw new SourcePaginationDrift("PROTOCOL_ERROR", "source pagination ended before the declared end", {
1132
+ details: {
1133
+ page,
1134
+ lastPage,
1135
+ totalSize,
1136
+ received: sources.length
1137
+ },
1138
+ operation
1139
+ });
1140
+ return sources;
1141
+ }
1142
+ if (lastPage > page) continue;
1143
+ if (totalSize > 0) {
1144
+ if (sources.length >= totalSize) return sources;
1145
+ } else {
1146
+ const serverPageSize = result.pageSize || result.pages?.pageSize;
1147
+ const nextPage = result.pages?.nextPage;
1148
+ if (nextPage && nextPage > page) continue;
1149
+ if (nextPage === page || serverPageSize && result.sources.length < serverPageSize) return sources;
1150
+ }
1099
1151
  }
1100
1152
  throw new QMindError("PROTOCOL_ERROR", `source pagination exceeded ${maxPages} pages`, {
1101
- access: context.profile.access,
1102
1153
  details: {
1103
1154
  maxPages,
1104
1155
  pageSize
@@ -1106,24 +1157,19 @@ function createSourceOperations(context) {
1106
1157
  operation
1107
1158
  });
1108
1159
  };
1109
- const listAllSources = (notebookId, input, options) => collectAllSources(notebookId, input, options, "sources.list");
1110
- const getSourceTree = async (notebookId, options) => {
1111
- const notebook = requiredString$2(notebookId, "notebookId");
1112
- assertCapability(context.profile, "sources.tree", "sources.tree");
1113
- if (context.profile.access === "sash") return buildQMindSourceTree(await collectAllSources(notebook, {}, options, "sources.tree"));
1114
- return call(context, {
1115
- callOptions: options,
1116
- capability: "sources.tree",
1117
- idempotent: true,
1118
- method: "GET",
1119
- operation: "sources.tree",
1120
- path: queryPath(context.profile.apiPath("notebooks", notebook, "sources"), [["view", "filetree"]]),
1121
- schema: sourceTreeSchema
1122
- });
1160
+ const collectAllSources = async (notebookId, input, options, operation) => {
1161
+ try {
1162
+ return await readAllSourcePages(notebookId, input, options, operation);
1163
+ } catch (error) {
1164
+ if (!(error instanceof SourcePaginationDrift)) throw error;
1165
+ return readAllSourcePages(notebookId, input, options, operation);
1166
+ }
1123
1167
  };
1168
+ const listAllSources = (notebookId, input = {}, options) => collectAllSources(notebookId, input, options, "sources.list");
1169
+ const getSourceTree = async (notebookId, options) => buildQMindSourceTree(await collectAllSources(notebookId, {}, options, "sources.tree"));
1124
1170
  return {
1125
1171
  async batchDeleteSources(notebookId, sourceIds, options) {
1126
- const notebook = requiredString$2(notebookId, "notebookId");
1172
+ const notebook = requiredString$1(notebookId, "notebookId");
1127
1173
  const ids = stringList(sourceIds, "sourceIds", { min: 1 });
1128
1174
  return call(context, {
1129
1175
  body: { sourceIds: ids },
@@ -1132,18 +1178,19 @@ function createSourceOperations(context) {
1132
1178
  idempotent: false,
1133
1179
  method: "POST",
1134
1180
  operation: "sources.batchDelete",
1135
- path: context.profile.apiPath("notebooks", notebook, "sources", "batch-delete"),
1181
+ path: qmindPath("notebooks", notebook, "sources", "batch-delete"),
1136
1182
  schema: batchDeleteResultSchema
1137
1183
  });
1138
1184
  },
1139
1185
  async countSourceChildren(notebookId, parentIds, options) {
1140
- const notebook = requiredString$2(notebookId, "notebookId");
1186
+ const notebook = requiredString$1(notebookId, "notebookId");
1141
1187
  const ids = stringList(parentIds, "parentIds", {
1142
1188
  max: 200,
1143
- min: 1
1189
+ min: 1,
1190
+ keepEmptyString: true
1144
1191
  });
1145
- assertCapability(context.profile, "sources.childrenCount", "sources.childrenCount");
1146
- const path = context.profile.mindPath("notebooks", notebook, "sources", "children-count");
1192
+ assertCapability(context.capabilities, "sources.childrenCount", "sources.childrenCount");
1193
+ const path = qmindPath("notebooks", notebook, "sources", "children-count");
1147
1194
  const query = new URLSearchParams();
1148
1195
  for (const id of ids) query.append("parent_ids", id);
1149
1196
  return call(context, {
@@ -1157,7 +1204,7 @@ function createSourceOperations(context) {
1157
1204
  });
1158
1205
  },
1159
1206
  async createDirectory(notebookId, input, options) {
1160
- const title = requiredString$2(input?.title, "title");
1207
+ const title = requiredString$1(input?.title, "title");
1161
1208
  return createSource(notebookId, {
1162
1209
  isDir: true,
1163
1210
  parentSourceId: input?.parentSourceId,
@@ -1168,100 +1215,100 @@ function createSourceOperations(context) {
1168
1215
  },
1169
1216
  createSource,
1170
1217
  async createSourceWebOfficeSession(notebookId, sourceId, options) {
1171
- const notebook = requiredString$2(notebookId, "notebookId");
1172
- const source = requiredString$2(sourceId, "sourceId");
1173
- assertCapability(context.profile, "sources.webOffice", "sources.webOffice.create");
1218
+ const notebook = requiredString$1(notebookId, "notebookId");
1219
+ const source = requiredString$1(sourceId, "sourceId");
1220
+ assertCapability(context.capabilities, "sources.webOffice", "sources.webOffice.create");
1174
1221
  return call(context, {
1175
1222
  callOptions: options,
1176
1223
  capability: "sources.webOffice",
1177
1224
  idempotent: false,
1178
1225
  method: "POST",
1179
1226
  operation: "sources.webOffice.create",
1180
- path: context.profile.apiPath("notebooks", notebook, "sources", source, "weboffice", "session"),
1227
+ path: nezhaWebOfficePath(context.webOffice, notebook, source, "session"),
1181
1228
  schema: sourceWebOfficeSessionSchema
1182
1229
  });
1183
1230
  },
1184
1231
  async deleteSource(notebookId, sourceId, options) {
1185
- const notebook = requiredString$2(notebookId, "notebookId");
1186
- const source = requiredString$2(sourceId, "sourceId");
1232
+ const notebook = requiredString$1(notebookId, "notebookId");
1233
+ const source = requiredString$1(sourceId, "sourceId");
1187
1234
  return call(context, {
1188
1235
  callOptions: options,
1189
1236
  capability: "sources.write",
1190
1237
  idempotent: false,
1191
1238
  method: "DELETE",
1192
1239
  operation: "sources.delete",
1193
- path: context.profile.apiPath("notebooks", notebook, "sources", source),
1240
+ path: qmindPath("notebooks", notebook, "sources", source),
1194
1241
  schema: voidResponseSchema
1195
1242
  });
1196
1243
  },
1197
1244
  async getFeaturedSource(notebookId, sourceId, options) {
1198
- const notebook = requiredString$2(notebookId, "notebookId");
1199
- const source = requiredString$2(sourceId, "sourceId");
1245
+ const notebook = requiredString$1(notebookId, "notebookId");
1246
+ const source = requiredString$1(sourceId, "sourceId");
1200
1247
  return call(context, {
1201
1248
  callOptions: options,
1202
1249
  capability: "featuredNotebooks.read",
1203
1250
  idempotent: true,
1204
1251
  method: "GET",
1205
1252
  operation: "featuredSources.get",
1206
- path: context.profile.apiPath("featured-notebooks", notebook, "sources", source),
1253
+ path: qmindPath("featured-notebooks", notebook, "sources", source),
1207
1254
  schema: sourceSchema
1208
1255
  });
1209
1256
  },
1210
1257
  async getFeaturedSourceContent(notebookId, sourceId, options) {
1211
- const notebook = requiredString$2(notebookId, "notebookId");
1212
- const source = requiredString$2(sourceId, "sourceId");
1258
+ const notebook = requiredString$1(notebookId, "notebookId");
1259
+ const source = requiredString$1(sourceId, "sourceId");
1213
1260
  return call(context, {
1214
1261
  callOptions: options,
1215
1262
  capability: "featuredNotebooks.read",
1216
1263
  idempotent: true,
1217
1264
  method: "GET",
1218
1265
  operation: "featuredSources.content",
1219
- path: context.profile.apiPath("featured-notebooks", notebook, "sources", source, "content"),
1266
+ path: qmindPath("featured-notebooks", notebook, "sources", source, "content"),
1220
1267
  schema: sourceContentSchema
1221
1268
  });
1222
1269
  },
1223
1270
  async getFeaturedSourcePreview(notebookId, sourceId, options) {
1224
- const notebook = requiredString$2(notebookId, "notebookId");
1225
- const source = requiredString$2(sourceId, "sourceId");
1271
+ const notebook = requiredString$1(notebookId, "notebookId");
1272
+ const source = requiredString$1(sourceId, "sourceId");
1226
1273
  return call(context, {
1227
1274
  callOptions: options,
1228
1275
  capability: "featuredNotebooks.read",
1229
1276
  idempotent: true,
1230
1277
  method: "GET",
1231
1278
  operation: "featuredSources.preview",
1232
- path: context.profile.apiPath("featured-notebooks", notebook, "sources", source, "preview"),
1279
+ path: qmindPath("featured-notebooks", notebook, "sources", source, "preview"),
1233
1280
  schema: sourcePreviewSchema
1234
1281
  });
1235
1282
  },
1236
1283
  async getFeaturedSourceRawContent(notebookId, sourceId, options) {
1237
- const notebook = requiredString$2(notebookId, "notebookId");
1238
- const source = requiredString$2(sourceId, "sourceId");
1284
+ const notebook = requiredString$1(notebookId, "notebookId");
1285
+ const source = requiredString$1(sourceId, "sourceId");
1239
1286
  return call(context, {
1240
1287
  callOptions: options,
1241
1288
  capability: "featuredNotebooks.read",
1242
1289
  idempotent: true,
1243
1290
  method: "GET",
1244
1291
  operation: "featuredSources.rawContent",
1245
- path: context.profile.apiPath("featured-notebooks", notebook, "sources", source, "raw-content"),
1292
+ path: qmindPath("featured-notebooks", notebook, "sources", source, "raw-content"),
1246
1293
  schema: sourceRawContentSchema
1247
1294
  });
1248
1295
  },
1249
1296
  async getSource(notebookId, sourceId, options) {
1250
- const notebook = requiredString$2(notebookId, "notebookId");
1251
- const source = requiredString$2(sourceId, "sourceId");
1297
+ const notebook = requiredString$1(notebookId, "notebookId");
1298
+ const source = requiredString$1(sourceId, "sourceId");
1252
1299
  return call(context, {
1253
1300
  callOptions: options,
1254
1301
  capability: "sources.read",
1255
1302
  idempotent: true,
1256
1303
  method: "GET",
1257
1304
  operation: "sources.get",
1258
- path: context.profile.apiPath("notebooks", notebook, "sources", source),
1305
+ path: qmindPath("notebooks", notebook, "sources", source),
1259
1306
  schema: sourceSchema
1260
1307
  });
1261
1308
  },
1262
1309
  async refreshSource(notebookId, sourceId, options) {
1263
- const notebook = requiredString$2(notebookId, "notebookId");
1264
- const source = requiredString$2(sourceId, "sourceId");
1310
+ const notebook = requiredString$1(notebookId, "notebookId");
1311
+ const source = requiredString$1(sourceId, "sourceId");
1265
1312
  try {
1266
1313
  const run = await call(context, {
1267
1314
  callOptions: options,
@@ -1269,7 +1316,7 @@ function createSourceOperations(context) {
1269
1316
  idempotent: false,
1270
1317
  method: "POST",
1271
1318
  operation: "sources.refresh",
1272
- path: context.profile.apiPath("notebooks", notebook, "sources", source, "refresh"),
1319
+ path: qmindPath("notebooks", notebook, "sources", source, "refresh"),
1273
1320
  body: {},
1274
1321
  schema: taskRunSchema
1275
1322
  });
@@ -1290,25 +1337,25 @@ function createSourceOperations(context) {
1290
1337
  idempotent: true,
1291
1338
  method: "POST",
1292
1339
  operation: "sources.retryIngestion",
1293
- path: context.profile.apiPath("notebooks", requiredString$2(notebookId, "notebookId"), "sources", requiredString$2(sourceId, "sourceId"), "retry"),
1340
+ path: qmindPath("notebooks", requiredString$1(notebookId, "notebookId"), "sources", requiredString$1(sourceId, "sourceId"), "retry"),
1294
1341
  body: {
1295
- retryKey: requiredString$2(input.retryKey, "retryKey"),
1296
- expectedUpdatedAt: requiredString$2(input.expectedUpdatedAt, "expectedUpdatedAt"),
1342
+ retryKey: requiredString$1(input.retryKey, "retryKey"),
1343
+ expectedUpdatedAt: requiredString$1(input.expectedUpdatedAt, "expectedUpdatedAt"),
1297
1344
  ...input.expectedVectorRetryAt !== void 0 ? { expectedVectorRetryAt: input.expectedVectorRetryAt } : {}
1298
1345
  },
1299
1346
  schema: sourceSchema
1300
1347
  });
1301
1348
  },
1302
1349
  async getSourceContent(notebookId, sourceId, options) {
1303
- const notebook = requiredString$2(notebookId, "notebookId");
1304
- const source = requiredString$2(sourceId, "sourceId");
1350
+ const notebook = requiredString$1(notebookId, "notebookId");
1351
+ const source = requiredString$1(sourceId, "sourceId");
1305
1352
  return call(context, {
1306
1353
  callOptions: options,
1307
1354
  capability: "sources.read",
1308
1355
  idempotent: true,
1309
1356
  method: "GET",
1310
1357
  operation: "sources.content",
1311
- path: context.profile.apiPath("notebooks", notebook, "sources", source, "content"),
1358
+ path: qmindPath("notebooks", notebook, "sources", source, "content"),
1312
1359
  schema: sourceContentSchema
1313
1360
  });
1314
1361
  },
@@ -1319,33 +1366,33 @@ function createSourceOperations(context) {
1319
1366
  idempotent: true,
1320
1367
  method: "GET",
1321
1368
  operation: "sources.actionAccess",
1322
- path: context.profile.mindPath("source-actions", "access"),
1369
+ path: qmindPath("source-actions", "access"),
1323
1370
  schema: sourceActionAccessSchema
1324
1371
  });
1325
1372
  },
1326
1373
  async getSourcePreview(notebookId, sourceId, options) {
1327
- const notebook = requiredString$2(notebookId, "notebookId");
1328
- const source = requiredString$2(sourceId, "sourceId");
1374
+ const notebook = requiredString$1(notebookId, "notebookId");
1375
+ const source = requiredString$1(sourceId, "sourceId");
1329
1376
  return call(context, {
1330
1377
  callOptions: options,
1331
1378
  capability: "sources.preview",
1332
1379
  idempotent: true,
1333
1380
  method: "GET",
1334
1381
  operation: "sources.preview",
1335
- path: context.profile.apiPath("notebooks", notebook, "sources", source, "preview"),
1382
+ path: qmindPath("notebooks", notebook, "sources", source, "preview"),
1336
1383
  schema: sourcePreviewSchema
1337
1384
  });
1338
1385
  },
1339
1386
  async getSourceRawContent(notebookId, sourceId, options) {
1340
- const notebook = requiredString$2(notebookId, "notebookId");
1341
- const source = requiredString$2(sourceId, "sourceId");
1387
+ const notebook = requiredString$1(notebookId, "notebookId");
1388
+ const source = requiredString$1(sourceId, "sourceId");
1342
1389
  return call(context, {
1343
1390
  callOptions: options,
1344
1391
  capability: "sources.rawContent",
1345
1392
  idempotent: true,
1346
1393
  method: "GET",
1347
1394
  operation: "sources.rawContent",
1348
- path: context.profile.apiPath("notebooks", notebook, "sources", source, "raw-content"),
1395
+ path: qmindPath("notebooks", notebook, "sources", source, "raw-content"),
1349
1396
  schema: sourceRawContentSchema
1350
1397
  });
1351
1398
  },
@@ -1356,7 +1403,7 @@ function createSourceOperations(context) {
1356
1403
  idempotent: true,
1357
1404
  method: "GET",
1358
1405
  operation: "sources.quota",
1359
- path: context.profile.mindPath("source-quota"),
1406
+ path: qmindPath("source-quota"),
1360
1407
  schema: sourceQuotaSchema
1361
1408
  });
1362
1409
  },
@@ -1367,7 +1414,7 @@ function createSourceOperations(context) {
1367
1414
  idempotent: true,
1368
1415
  method: "GET",
1369
1416
  operation: "sources.uploadCapabilities",
1370
- path: context.profile.mindPath("source-upload", "capabilities"),
1417
+ path: qmindPath("source-upload", "capabilities"),
1371
1418
  schema: sourceUploadCapabilitiesSchema
1372
1419
  });
1373
1420
  },
@@ -1375,16 +1422,13 @@ function createSourceOperations(context) {
1375
1422
  return preflightSourceUpload(context, notebookId, options);
1376
1423
  },
1377
1424
  async getFeaturedSourceTree(notebookId, options) {
1378
- return buildQMindSourceTree((await listFeaturedSources(notebookId, {
1379
- page: 1,
1380
- pageSize: 200
1381
- }, options)).sources);
1425
+ return buildQMindSourceTree(await collectAllSources(notebookId, {}, options, "featuredSources.list"));
1382
1426
  },
1383
1427
  getSourceTree,
1384
1428
  listFeaturedSourceChildren,
1385
1429
  listSourceChildren,
1386
1430
  async importSite(notebookId, input, options) {
1387
- const notebook = requiredString$2(notebookId, "notebookId");
1431
+ const notebook = requiredString$1(notebookId, "notebookId");
1388
1432
  return call(context, {
1389
1433
  body: siteBody(input),
1390
1434
  callOptions: options,
@@ -1392,12 +1436,12 @@ function createSourceOperations(context) {
1392
1436
  idempotent: false,
1393
1437
  method: "POST",
1394
1438
  operation: "sources.importSite",
1395
- path: context.profile.apiPath("notebooks", notebook, "sources"),
1439
+ path: qmindPath("notebooks", notebook, "sources"),
1396
1440
  schema: sourceSchema
1397
1441
  });
1398
1442
  },
1399
1443
  async importWebLinks(notebookId, input, options) {
1400
- const notebook = requiredString$2(notebookId, "notebookId");
1444
+ const notebook = requiredString$1(notebookId, "notebookId");
1401
1445
  const urls = stringList(input?.urls ?? [], "urls", {
1402
1446
  max: 5,
1403
1447
  min: 1
@@ -1414,12 +1458,12 @@ function createSourceOperations(context) {
1414
1458
  idempotent: false,
1415
1459
  method: "POST",
1416
1460
  operation: "sources.importWeb",
1417
- path: context.profile.apiPath("notebooks", notebook, "sources"),
1461
+ path: qmindPath("notebooks", notebook, "sources"),
1418
1462
  schema: sourceImportResultsSchema
1419
1463
  });
1420
1464
  },
1421
1465
  async importWikiDocuments(notebookId, input, options) {
1422
- const notebook = requiredString$2(notebookId, "notebookId");
1466
+ const notebook = requiredString$1(notebookId, "notebookId");
1423
1467
  const urls = stringList(input?.urls ?? [], "urls", {
1424
1468
  max: 5,
1425
1469
  min: 1
@@ -1436,7 +1480,7 @@ function createSourceOperations(context) {
1436
1480
  idempotent: false,
1437
1481
  method: "POST",
1438
1482
  operation: "sources.importWiki",
1439
- path: context.profile.apiPath("notebooks", notebook, "sources"),
1483
+ path: qmindPath("notebooks", notebook, "sources"),
1440
1484
  schema: sourceImportResultsSchema
1441
1485
  });
1442
1486
  },
@@ -1458,10 +1502,10 @@ function createSourceOperations(context) {
1458
1502
  return updateSource(notebookId, sourceId, patch, options);
1459
1503
  },
1460
1504
  async presignImageUpload(notebookId, sourceId, input, options) {
1461
- const notebook = requiredString$2(notebookId, "notebookId");
1462
- const source = requiredString$2(sourceId, "sourceId");
1463
- const filename = requiredString$2(input?.filename, "filename");
1464
- const mimeType = requiredString$2(input?.mimeType, "mimeType");
1505
+ const notebook = requiredString$1(notebookId, "notebookId");
1506
+ const source = requiredString$1(sourceId, "sourceId");
1507
+ const filename = requiredString$1(input?.filename, "filename");
1508
+ const mimeType = requiredString$1(input?.mimeType, "mimeType");
1465
1509
  const size = nonNegativeInteger$1(input?.size, "size");
1466
1510
  if (size === void 0) throw invalidArgument$1("size must be a non-negative integer", "size");
1467
1511
  if (size > maxImageBytes) throw invalidArgument$1(`size must not exceed ${maxImageBytes} bytes`, "size");
@@ -1476,16 +1520,16 @@ function createSourceOperations(context) {
1476
1520
  idempotent: false,
1477
1521
  method: "POST",
1478
1522
  operation: "images.presignUpload",
1479
- path: context.profile.apiPath("notebooks", notebook, "sources", source, "images", "presign"),
1523
+ path: qmindPath("notebooks", notebook, "sources", source, "images", "presign"),
1480
1524
  schema: imageUploadTicketSchema
1481
1525
  });
1482
1526
  },
1483
1527
  async refreshSourceWebOfficeSession(notebookId, sourceId, input, options) {
1484
- const notebook = requiredString$2(notebookId, "notebookId");
1485
- const source = requiredString$2(sourceId, "sourceId");
1486
- const sessionId = requiredString$2(input?.sessionId, "sessionId");
1528
+ const notebook = requiredString$1(notebookId, "notebookId");
1529
+ const source = requiredString$1(sourceId, "sourceId");
1530
+ const sessionId = requiredString$1(input?.sessionId, "sessionId");
1487
1531
  const tokenVersion = nonNegativeInteger$1(input?.tokenVersion, "tokenVersion") ?? 0;
1488
- assertCapability(context.profile, "sources.webOffice", "sources.webOffice.refresh");
1532
+ assertCapability(context.capabilities, "sources.webOffice", "sources.webOffice.refresh");
1489
1533
  return call(context, {
1490
1534
  body: { tokenVersion },
1491
1535
  callOptions: options,
@@ -1493,12 +1537,12 @@ function createSourceOperations(context) {
1493
1537
  idempotent: false,
1494
1538
  method: "POST",
1495
1539
  operation: "sources.webOffice.refresh",
1496
- path: context.profile.apiPath("notebooks", notebook, "sources", source, "weboffice", "session", sessionId, "refresh"),
1540
+ path: nezhaWebOfficePath(context.webOffice, notebook, source, "session", sessionId, "refresh"),
1497
1541
  schema: sourceWebOfficeTokenSchema
1498
1542
  });
1499
1543
  },
1500
1544
  async presignImageUrls(notebookId, ossKeys, options) {
1501
- const notebook = requiredString$2(notebookId, "notebookId");
1545
+ const notebook = requiredString$1(notebookId, "notebookId");
1502
1546
  const keys = stringList(ossKeys, "ossKeys", {
1503
1547
  max: 100,
1504
1548
  min: 1
@@ -1510,7 +1554,7 @@ function createSourceOperations(context) {
1510
1554
  idempotent: false,
1511
1555
  method: "POST",
1512
1556
  operation: "images.presignUrls",
1513
- path: context.profile.apiPath("notebooks", notebook, "images", "presign-urls"),
1557
+ path: qmindPath("notebooks", notebook, "images", "presign-urls"),
1514
1558
  schema: imageUrlsSchema
1515
1559
  });
1516
1560
  },
@@ -1518,292 +1562,10 @@ function createSourceOperations(context) {
1518
1562
  };
1519
1563
  }
1520
1564
  //#endregion
1521
- //#region ../sdk/src/capabilities.ts
1522
- const dashboardCapabilities = Object.freeze({
1523
- "wiki.read": true,
1524
- botGateway: true,
1525
- chat: true,
1526
- "featuredChat.delete": false,
1527
- compilation: true,
1528
- "featuredNotebooks.read": true,
1529
- "featuredNotebooks.copy": true,
1530
- "images.presignUpload": false,
1531
- "images.presignUrls": false,
1532
- "imports.aliDing": true,
1533
- "imports.discover": true,
1534
- "imports.fullSiteURL": true,
1535
- members: true,
1536
- "members.search": true,
1537
- "members.resolve": true,
1538
- "notebooks.filterByClient": false,
1539
- "notebooks.read": true,
1540
- "notebooks.write": true,
1541
- "notes.read": true,
1542
- "notes.write": true,
1543
- "notes.saveCondensation": true,
1544
- retrieval: true,
1545
- scheduledTasks: true,
1546
- "sharedNotebooks.read": true,
1547
- "sources.children": true,
1548
- "sources.childrenCount": true,
1549
- "sources.actionAccess": false,
1550
- "sources.importWeb": true,
1551
- "sources.preview": true,
1552
- "sources.rawContent": true,
1553
- "sources.read": true,
1554
- "sources.quota": true,
1555
- "sources.search": true,
1556
- "sources.tree": true,
1557
- "sources.webOffice": true,
1558
- "sources.officeProxy": true,
1559
- "sources.write": true,
1560
- "taskRuns.read": true,
1561
- "taskRuns.write": true,
1562
- transfers: true,
1563
- "wikiBranches.read": true,
1564
- "wikiBranches.page": true
1565
- });
1566
- const sashCapabilities = Object.freeze({
1567
- "wiki.read": false,
1568
- botGateway: false,
1569
- chat: true,
1570
- "featuredChat.delete": false,
1571
- compilation: false,
1572
- "featuredNotebooks.read": true,
1573
- "featuredNotebooks.copy": true,
1574
- "images.presignUpload": true,
1575
- "images.presignUrls": true,
1576
- "imports.aliDing": true,
1577
- "imports.discover": true,
1578
- "imports.fullSiteURL": false,
1579
- members: true,
1580
- "members.search": false,
1581
- "members.resolve": true,
1582
- "notebooks.filterByClient": true,
1583
- "notebooks.read": true,
1584
- "notebooks.write": true,
1585
- "notes.read": true,
1586
- "notes.write": true,
1587
- "notes.saveCondensation": false,
1588
- retrieval: true,
1589
- scheduledTasks: true,
1590
- "sharedNotebooks.read": true,
1591
- "sources.children": true,
1592
- "sources.childrenCount": false,
1593
- "sources.actionAccess": true,
1594
- "sources.importWeb": true,
1595
- "sources.preview": true,
1596
- "sources.rawContent": true,
1597
- "sources.read": true,
1598
- "sources.quota": true,
1599
- "sources.search": false,
1600
- "sources.tree": true,
1601
- "sources.webOffice": true,
1602
- "sources.officeProxy": true,
1603
- "sources.write": true,
1604
- "taskRuns.read": true,
1605
- "taskRuns.write": true,
1606
- transfers: true,
1607
- "wikiBranches.read": true,
1608
- "wikiBranches.page": true
1609
- });
1610
- function capabilitiesFor(access) {
1611
- return access === "sash" ? sashCapabilities : dashboardCapabilities;
1612
- }
1613
- //#endregion
1614
- //#region ../sdk/src/profiles.ts
1615
- function isRecord$1(value) {
1616
- return typeof value === "object" && value !== null && !Array.isArray(value);
1617
- }
1618
- function encodeId(value) {
1619
- return encodeURIComponent(value);
1620
- }
1621
- function appendQuery(path, entries) {
1622
- const query = new URLSearchParams();
1623
- for (const [key, value] of entries) if (value !== void 0 && value !== "") query.set(key, String(value));
1624
- const suffix = query.toString();
1625
- return suffix ? `${path}?${suffix}` : path;
1626
- }
1627
- function dashboardEnvelope(body) {
1628
- if (!isRecord$1(body) || typeof body.status !== "number" || !("data" in body)) return body;
1629
- return body.data;
1630
- }
1631
- function firstResultSource(access, operation, body) {
1632
- if (!isRecord$1(body) || !Array.isArray(body.results)) return body;
1633
- const first = body.results[0];
1634
- if (!isRecord$1(first)) return void 0;
1635
- if ("source" in first) return first.source;
1636
- if (typeof first.error === "string" && first.error.length > 0) throw new QMindError("REMOTE_ERROR", first.error, {
1637
- access,
1638
- details: first,
1639
- operation,
1640
- status: 200
1641
- });
1642
- }
1643
- function normalizeSuccess(access, operation, body) {
1644
- const unwrapped = access === "dashboard" ? dashboardEnvelope(body) : body;
1645
- if (access !== "dashboard") return unwrapped;
1646
- if (operation === "sources.create" || operation === "sources.importSite") return firstResultSource(access, operation, unwrapped);
1647
- if (operation === "transfers.source.multipart" || operation === "transfers.source.register") return firstResultSource(access, operation, unwrapped);
1648
- return unwrapped;
1649
- }
1650
- function streamError(access, message, details) {
1651
- return new QMindError("STREAM_ERROR", message, {
1652
- access,
1653
- ...details === void 0 ? {} : { details },
1654
- operation: "chat.stream"
1655
- });
1656
- }
1657
- function requiredString$1(access, value, field) {
1658
- if (value !== void 0 && value.length > 0) return value;
1659
- throw streamError(access, `stream event is missing ${field}`, { field });
1660
- }
1661
- function stringValue$1(value) {
1662
- return value ?? "";
1663
- }
1664
- function presentString(access, value, field) {
1665
- if (value !== void 0) return value;
1666
- throw streamError(access, `stream event is missing ${field}`, { field });
1667
- }
1668
- function decodeStreamEvent(access, rawBody) {
1669
- const candidate = access === "dashboard" ? dashboardEnvelope(rawBody) : rawBody;
1670
- const parsed = streamWireEventSchema.safeParse(candidate);
1671
- if (!parsed.success) throw streamError(access, "stream event does not match the QMind contract", { issues: parsed.error.issues });
1672
- const event = parsed.data;
1673
- const eventType = event.eventType ?? event.event_type ?? event.type;
1674
- switch (eventType) {
1675
- case "message_start": return {
1676
- citations: event.citations ?? [],
1677
- reranked: event.reranked ?? false,
1678
- totalContextChunks: event.totalContextChunks ?? 0,
1679
- type: "messageStart",
1680
- ...event.assistantMessageId === void 0 ? {} : { assistantMessageId: event.assistantMessageId },
1681
- ...event.userMessage === void 0 ? {} : { userMessage: event.userMessage }
1682
- };
1683
- case "tool_call_start": return {
1684
- step: event.step ?? 0,
1685
- toolArguments: stringValue$1(event.toolArguments),
1686
- toolName: requiredString$1(access, event.toolName, "toolName"),
1687
- type: "toolCallStart",
1688
- ...event.toolDisplayName === void 0 ? {} : { toolDisplayName: event.toolDisplayName }
1689
- };
1690
- case "tool_call_result": return {
1691
- step: event.step ?? 0,
1692
- toolName: requiredString$1(access, event.toolName, "toolName"),
1693
- toolResult: stringValue$1(event.toolResult),
1694
- type: "toolCallResult",
1695
- ...event.toolDisplayName === void 0 ? {} : { toolDisplayName: event.toolDisplayName }
1696
- };
1697
- case "delta": return {
1698
- delta: presentString(access, event.delta, "delta"),
1699
- type: "delta"
1700
- };
1701
- case "batch_progress": return {
1702
- metadata: event.metadata ?? {},
1703
- type: "batchProgress"
1704
- };
1705
- case "heartbeat": return {
1706
- metadata: event.metadata ?? {},
1707
- type: "heartbeat"
1708
- };
1709
- case "cancel": return {
1710
- canceled: true,
1711
- type: "cancel",
1712
- ...event.cancelReason === void 0 ? {} : { cancelReason: event.cancelReason }
1713
- };
1714
- case "message_complete": return {
1715
- canceled: event.canceled ?? false,
1716
- citations: event.citations ?? [],
1717
- metadata: event.metadata ?? {},
1718
- promptContext: event.promptContext ?? "",
1719
- reranked: event.reranked ?? false,
1720
- totalContextChunks: event.totalContextChunks ?? 0,
1721
- type: "messageComplete",
1722
- ...event.assistantMessage === void 0 ? {} : { assistantMessage: event.assistantMessage },
1723
- ...event.cancelReason === void 0 ? {} : { cancelReason: event.cancelReason }
1724
- };
1725
- case "error": return {
1726
- message: requiredString$1(access, event.errorMessage ?? event.error, "errorMessage"),
1727
- type: "error"
1728
- };
1729
- default: throw streamError(access, "stream event has an unsupported event type", { eventType });
1730
- }
1731
- }
1732
- function decodeStreamPayload(access, payload) {
1733
- let value;
1734
- try {
1735
- value = JSON.parse(payload);
1736
- } catch (cause) {
1737
- throw streamError(access, "stream event is not valid JSON", { cause });
1738
- }
1739
- return decodeStreamEvent(access, value);
1740
- }
1741
- function createProfile(access, apiPrefix) {
1742
- const capabilities = capabilitiesFor(access);
1743
- const apiPath = (...segments) => {
1744
- return `${apiPrefix}/${segments.map((segment) => encodeId(segment)).join("/")}`;
1745
- };
1746
- return Object.freeze({
1747
- access,
1748
- capabilities,
1749
- apiPath,
1750
- wikiReadPath(organizationId, operation) {
1751
- return apiPath("organizations", organizationId, "knowledge", "wiki", operation);
1752
- },
1753
- decodeStreamPayload(payload) {
1754
- return decodeStreamPayload(access, payload);
1755
- },
1756
- featuredNotebookPath(notebookId) {
1757
- return notebookId === void 0 ? apiPath("featured-notebooks") : apiPath("featured-notebooks", notebookId);
1758
- },
1759
- listFeaturedNotebooksPath(input) {
1760
- return appendQuery(`${apiPrefix}/featured-notebooks`, [["page", input.page], ["page_size", input.pageSize]]);
1761
- },
1762
- listNotebooksPath(input) {
1763
- return appendQuery(`${apiPrefix}/notebooks`, [
1764
- ["page", input.page],
1765
- ["page_size", input.pageSize],
1766
- ["client", input.client],
1767
- ["retrieval_eligible_only", input.retrievalEligibleOnly]
1768
- ]);
1769
- },
1770
- listSharedNotebooksPath(input) {
1771
- return appendQuery(`${apiPrefix}/notebooks/shared`, [
1772
- ["page", input.page],
1773
- ["page_size", input.pageSize],
1774
- ["retrieval_eligible_only", input.retrievalEligibleOnly]
1775
- ]);
1776
- },
1777
- mindPath(...segments) {
1778
- return `/api/v1/mind/${segments.map((segment) => encodeId(segment)).join("/")}`;
1779
- },
1780
- notebookPath(notebookId) {
1781
- return notebookId === void 0 ? apiPath("notebooks") : apiPath("notebooks", notebookId);
1782
- },
1783
- unwrapError(body) {
1784
- return access === "dashboard" ? dashboardEnvelope(body) : body;
1785
- },
1786
- unwrapSuccess(operation, body) {
1787
- return normalizeSuccess(access, operation, body);
1788
- },
1789
- wikiBranchesPath(notebookId) {
1790
- return apiPath("notebooks", notebookId, "wiki-branches");
1791
- }
1792
- });
1793
- }
1794
- const dashboardProfile = createProfile("dashboard", "/api/v1");
1795
- const sashProfile = createProfile("sash", "/sash/api/v1");
1796
- function profileFor(access) {
1797
- return access === "sash" ? sashProfile : dashboardProfile;
1798
- }
1799
- //#endregion
1800
1565
  //#region ../sdk/src/client.ts
1801
1566
  function isRecord(value) {
1802
1567
  return typeof value === "object" && value !== null && !Array.isArray(value);
1803
1568
  }
1804
- function isQMindAccess(value) {
1805
- return value === "sash" || value === "dashboard";
1806
- }
1807
1569
  function isQMindTransport(value) {
1808
1570
  if (!isRecord(value)) return false;
1809
1571
  return typeof value.request === "function" && typeof value.stream === "function";
@@ -1812,15 +1574,11 @@ const managementOperationNames = [
1812
1574
  "addMember",
1813
1575
  "createScheduledTask",
1814
1576
  "deleteScheduledTask",
1815
- "getCompilationSettings",
1816
- "getCompilationStatus",
1817
1577
  "listMembers",
1818
1578
  "listScheduledTasks",
1819
1579
  "removeMember",
1820
1580
  "resolveMemberCandidate",
1821
- "saveCompilationSettings",
1822
1581
  "searchMemberCandidates",
1823
- "startCompilation",
1824
1582
  "updateMemberPermission",
1825
1583
  "updateScheduledTask"
1826
1584
  ];
@@ -1841,25 +1599,30 @@ const noteOperationNames = [
1841
1599
  "saveCondensationResult",
1842
1600
  "updateNote"
1843
1601
  ];
1844
- const botGatewayOperationNames = [
1845
- "listPlatformApps",
1846
- "createPlatformApp",
1847
- "updatePlatformApp",
1848
- "deletePlatformApp",
1849
- "listExpertBindings",
1850
- "updateExpertBinding",
1851
- "deleteExpertBinding",
1852
- "listGroupBindings",
1853
- "createGroupBinding",
1854
- "updateGroupBinding",
1855
- "deleteGroupBinding",
1856
- "publishDingTalk",
1857
- "inviteDingTalkExpert"
1858
- ];
1602
+ function createLazyDataSourceOperations(context) {
1603
+ let operations;
1604
+ const load = () => {
1605
+ operations ??= import("./data-sources-DItXSL_s.js").then(({ createDataSourceOperations }) => createDataSourceOperations(context));
1606
+ return operations;
1607
+ };
1608
+ return {
1609
+ listDataSources: (...args) => load().then((value) => value.listDataSources(...args)),
1610
+ getDataSource: (...args) => load().then((value) => value.getDataSource(...args)),
1611
+ createDataSource: (...args) => load().then((value) => value.createDataSource(...args)),
1612
+ updateDataSource: (...args) => load().then((value) => value.updateDataSource(...args)),
1613
+ setDataSourceCredentials: (...args) => load().then((value) => value.setDataSourceCredentials(...args)),
1614
+ deleteDataSource: (...args) => load().then((value) => value.deleteDataSource(...args)),
1615
+ previewDataSource: (...args) => load().then((value) => value.previewDataSource(...args)),
1616
+ validateDataSource: (...args) => load().then((value) => value.validateDataSource(...args)),
1617
+ listDataSourceResources: (...args) => load().then((value) => value.listDataSourceResources(...args)),
1618
+ requestDataSourceSync: (...args) => load().then((value) => value.requestDataSourceSync(...args)),
1619
+ listDataSourceRuns: (...args) => load().then((value) => value.listDataSourceRuns(...args))
1620
+ };
1621
+ }
1859
1622
  function createLazyTransferOperations(context) {
1860
1623
  let operations;
1861
1624
  const load = () => {
1862
- operations ??= import("./transfers-DONoEIKT.js").then(({ createTransferOperations }) => createTransferOperations(context));
1625
+ operations ??= import("./transfers-C0pXH5Qe.js").then(({ createTransferOperations }) => createTransferOperations(context));
1863
1626
  return operations;
1864
1627
  };
1865
1628
  return {
@@ -1870,7 +1633,7 @@ function createLazyTransferOperations(context) {
1870
1633
  function createLazyWikiOperations(context) {
1871
1634
  let operations;
1872
1635
  const load = () => {
1873
- operations ??= import("./wiki-DBT6JdyN.js").then(({ createWikiOperations }) => createWikiOperations(context));
1636
+ operations ??= import("./wiki-_a2EAozi.js").then(({ createWikiOperations }) => createWikiOperations(context));
1874
1637
  return operations;
1875
1638
  };
1876
1639
  return {
@@ -1879,18 +1642,10 @@ function createLazyWikiOperations(context) {
1879
1642
  searchWikiSections: (...args) => load().then((loaded) => loaded.searchWikiSections(...args))
1880
1643
  };
1881
1644
  }
1882
- function createLazyBotGatewayOperations(context) {
1883
- let operations;
1884
- const load = () => {
1885
- operations ??= import("./bot-gateway-C4c1bMi9.js").then(({ createBotGatewayOperations }) => createBotGatewayOperations(context));
1886
- return operations;
1887
- };
1888
- return Object.fromEntries(botGatewayOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
1889
- }
1890
1645
  function createLazyNoteOperations(context) {
1891
1646
  let operations;
1892
1647
  const load = () => {
1893
- operations ??= import("./notes-HS_N--cJ.js").then(({ createNoteOperations }) => createNoteOperations(context));
1648
+ operations ??= import("./notes-BUq1ciGO.js").then(({ createNoteOperations }) => createNoteOperations(context));
1894
1649
  return operations;
1895
1650
  };
1896
1651
  return Object.fromEntries(noteOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1898,7 +1653,7 @@ function createLazyNoteOperations(context) {
1898
1653
  function createLazyImportOperations(context) {
1899
1654
  let operations;
1900
1655
  const load = () => {
1901
- operations ??= import("./imports-Bb3NHsmd.js").then(({ createImportOperations }) => createImportOperations(context));
1656
+ operations ??= import("./imports-CSg7ebnN.js").then(({ createImportOperations }) => createImportOperations(context));
1902
1657
  return operations;
1903
1658
  };
1904
1659
  return Object.fromEntries(importOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
@@ -1906,24 +1661,27 @@ function createLazyImportOperations(context) {
1906
1661
  function createLazyManagementOperations(context) {
1907
1662
  let operations;
1908
1663
  const load = () => {
1909
- operations ??= import("./management-BYR88TwO.js").then(({ createManagementOperations }) => createManagementOperations(context));
1664
+ operations ??= import("./management-iTQ9-Osc.js").then(({ createManagementOperations }) => createManagementOperations(context));
1910
1665
  return operations;
1911
1666
  };
1912
1667
  return Object.fromEntries(managementOperationNames.map((name) => [name, (...args) => load().then((loaded) => Reflect.apply(loaded[name], loaded, args))]));
1913
1668
  }
1914
1669
  function createQMindClient(options) {
1915
1670
  if (!isRecord(options)) throw invalidArgument$1("client options must be an object", "options");
1916
- if (!isQMindAccess(options.access)) throw invalidArgument$1("access must be either \"sash\" or \"dashboard\"", "access");
1917
1671
  if (!isQMindTransport(options.transport)) throw invalidArgument$1("transport must implement request() and stream()", "transport");
1918
- const profile = profileFor(options.access);
1672
+ const nezha = options.nezha;
1673
+ const webOffice = nezha?.webOffice;
1674
+ if (nezha !== void 0 && (!isRecord(nezha) || webOffice !== void 0 && webOffice !== "sash" && webOffice !== "dashboard" || nezha.repoWiki !== void 0 && typeof nezha.repoWiki !== "boolean")) throw invalidArgument$1("invalid Nezha capability options", "nezha");
1675
+ const capabilities = createCapabilities(nezha ?? {});
1919
1676
  const context = {
1920
1677
  client: optionalTrimmedString(options.client, "client") ?? "qmind",
1921
- profile,
1678
+ capabilities,
1679
+ webOffice,
1922
1680
  transport: options.transport
1923
1681
  };
1924
1682
  return Object.freeze({
1925
- access: profile.access,
1926
- capabilities: profile.capabilities,
1683
+ capabilities,
1684
+ ...createLazyDataSourceOperations(context),
1927
1685
  ...createNotebookOperations(context),
1928
1686
  ...createLazyWikiOperations(context),
1929
1687
  ...createSourceOperations(context),
@@ -1931,11 +1689,10 @@ function createQMindClient(options) {
1931
1689
  ...createLazyImportOperations(context),
1932
1690
  ...createLazyManagementOperations(context),
1933
1691
  ...createLazyNoteOperations(context),
1934
- ...createLazyBotGatewayOperations(context),
1935
1692
  ...createLazyTransferOperations(context),
1936
1693
  ...createAgentOperations(context),
1937
1694
  supports(capability) {
1938
- return profile.capabilities[capability] === true;
1695
+ return capabilities[capability] === true;
1939
1696
  }
1940
1697
  });
1941
1698
  }
@@ -2003,7 +1760,7 @@ function canonicalize(object, seen = /* @__PURE__ */ new Set()) {
2003
1760
  }
2004
1761
  //#endregion
2005
1762
  //#region ../agent-core/src/contract.ts
2006
- const CONTRACT_VERSION = "7.0.0";
1763
+ const CONTRACT_VERSION = "8.0.0";
2007
1764
  const AGENT_ERROR_CODES = Object.freeze([
2008
1765
  "invalid_input",
2009
1766
  "selection_required",
@@ -2161,7 +1918,7 @@ const agentToolDefinitions = Object.freeze([
2161
1918
  intent: "write",
2162
1919
  destructive: true,
2163
1920
  deadlineMs: 12e4,
2164
- description: "Update source text using baseUpdatedAt from a fresh read and optionally a SHA-256 content snapshot. This preflight is not atomic compare-and-swap. The server automatically handles learning for the updated source; observe get_source/read_source for readiness. No separate task is created. Reconcile outcome_unknown before any new write."
1921
+ description: "Update source text and optional title without changing source type or original format, using baseUpdatedAt from a fresh read and optionally a SHA-256 content snapshot. Conflicting Markdown type and original format are rejected. This preflight is not atomic compare-and-swap. The server automatically handles learning for the updated source; observe get_source/read_source for readiness. No separate task is created. Reconcile outcome_unknown before any new write."
2165
1922
  },
2166
1923
  {
2167
1924
  id: "qmind.refresh_source",
@@ -2259,14 +2016,14 @@ const agentToolDefinitions = Object.freeze([
2259
2016
  },
2260
2017
  {
2261
2018
  deadlineMs: 3e4,
2262
- description: "Create an enabled built-in scheduled task in one QMind notebook. Requires manage permission. Use an explicit CRON_TZ/TZ IANA zone followed by five or six cron fields; the server validates cron syntax. No arbitrary prompt or config. source_binding_sync is AliDing-only, one active configuration per notebook (including paused tasks), five fields and at least five minutes apart. compilation may be retired by the server. Saving does not execute the task or prove ingestion completed. Never retry outcome_unknown automatically; list current tasks to reconcile, and do not treat an identical schedule as proof of creation.",
2019
+ description: "Create an enabled built-in scheduled task in one QMind notebook. Requires manage permission. Use an explicit CRON_TZ/TZ IANA zone followed by five or six cron fields; the server validates cron syntax. No arbitrary prompt or config. source_binding_sync is AliDing-only, one active configuration per notebook (including paused tasks), five fields and at least five minutes apart. Supported creation scenes are condensation, source_refresh and source_binding_sync. Saving does not execute the task or prove ingestion completed. Never retry outcome_unknown automatically; list current tasks to reconcile, and do not treat an identical schedule as proof of creation.",
2263
2020
  id: "qmind.create_scheduled_task",
2264
2021
  intent: "write",
2265
2022
  leaf: "create_scheduled_task"
2266
2023
  },
2267
2024
  {
2268
2025
  deadlineMs: 3e4,
2269
- description: "Update a scheduled task in one QMind notebook by taskId. Requires manage permission. Provide schedule and/or enabled; false pauses and true resumes. Schedule requires an explicit CRON_TZ/TZ IANA zone. Config and sceneType cannot be changed. Resuming an overdue task can dispatch at the next scheduler tick; it does not recalculate nextRunAt. Pausing cannot cancel work already dispatched or read by the scheduler. Never retry outcome_unknown automatically; list tasks to inspect current state first. Preflight and write are not atomic.",
2026
+ description: "Update a scheduled task in one QMind notebook by taskId. Requires manage permission. Provide schedule and/or enabled; false pauses and true resumes. Historical compilation and lint tasks accept only enabled=false. Schedule requires an explicit CRON_TZ/TZ IANA zone. Config and sceneType cannot be changed. Resuming an overdue task can dispatch at the next scheduler tick; it does not recalculate nextRunAt. Pausing cannot cancel work already dispatched or read by the scheduler. Never retry outcome_unknown automatically; list tasks to inspect current state first. Preflight and write are not atomic.",
2270
2027
  id: "qmind.update_scheduled_task",
2271
2028
  intent: "write",
2272
2029
  destructive: true,
@@ -2418,6 +2175,8 @@ const canonicalDescriptor = canonicalize(deepFreeze({
2418
2175
  {
2419
2176
  id: "qmind.update_source_content",
2420
2177
  intent: "write",
2178
+ writeFields: ["content", "title?"],
2179
+ sourceIdentity: "preserved; conflicting Markdown type and original format rejected",
2421
2180
  timeoutMs: 12e4,
2422
2181
  annotations: {
2423
2182
  destructiveHint: true,
@@ -2771,7 +2530,7 @@ const canonicalDescriptor = canonicalize(deepFreeze({
2771
2530
  intent: "write",
2772
2531
  input: {
2773
2532
  notebookId: "opaqueId",
2774
- sceneType: "ScheduledTask.sceneType",
2533
+ sceneType: "condensation|source_refresh|source_binding_sync",
2775
2534
  schedule: "explicit-IANA-zone-prefixed-cron:1..512; server validates syntax and scene interval"
2776
2535
  },
2777
2536
  output: "ScheduledTask; enabled=true",
@@ -2790,7 +2549,7 @@ const canonicalDescriptor = canonicalize(deepFreeze({
2790
2549
  notebookId: "opaqueId",
2791
2550
  taskId: "opaqueId",
2792
2551
  schedule: "explicit-IANA-zone-prefixed-cron:1..512?",
2793
- enabled: "boolean?; at least one patch field"
2552
+ enabled: "boolean?; at least one patch field; retired scenes accept only enabled=false"
2794
2553
  },
2795
2554
  output: "ScheduledTask",
2796
2555
  timeoutMs: 3e4
@@ -2979,6 +2738,7 @@ async function updateSourceContent(client, input, invocation) {
2979
2738
  if (!client.updateSource) return failure$1(invocation.operationId, "capability_unavailable", "Source writeback is unavailable.");
2980
2739
  const current = await client.getSource(input.notebookId, input.sourceId, callOptions(invocation));
2981
2740
  if (current.isDir) return failure$1(invocation.operationId, "invalid_input", "Directory content cannot be updated.");
2741
+ if (/^(md|markdown)$/iu.test(current.sourceType.trim()) && [current.metadata?.sourceFormat, current.metadata?.source_format].some((format) => format !== void 0 && format !== null && format !== "" && (typeof format !== "string" || !/^(md|markdown)$/iu.test(format.trim())))) return failure$1(invocation.operationId, "invalid_input", "Source type conflicts with its original format; resolve the source identity before editing.");
2982
2742
  if (current.updatedAt !== input.baseUpdatedAt) return failure$1(invocation.operationId, "source_conflict", "Source changed; read it before editing.");
2983
2743
  if (input.baseContentHash !== void 0) {
2984
2744
  const content = await client.getSourceContent(input.notebookId, input.sourceId, callOptions(invocation));
@@ -2990,7 +2750,6 @@ async function updateSourceContent(client, input, invocation) {
2990
2750
  try {
2991
2751
  updated = await client.updateSource(input.notebookId, input.sourceId, {
2992
2752
  content: input.content,
2993
- sourceType: "markdown",
2994
2753
  ...input.title === void 0 ? {} : { title: input.title }
2995
2754
  }, options);
2996
2755
  if (updated.id !== input.sourceId || updated.notebookId !== input.notebookId) throw new TypeError("Unconfirmed source update.");
@@ -3148,6 +2907,7 @@ async function runScheduledTask(client, tool, rawInput, invocation) {
3148
2907
  };
3149
2908
  }
3150
2909
  const update = rawInput;
2910
+ if (isQMindRetiredScene(current.sceneType) && (update.enabled !== false || update.schedule !== void 0)) return failure$1(invocation.operationId, "invalid_input", "A retired scheduled task can only be paused or deleted.");
3151
2911
  const patch = {
3152
2912
  ...update.schedule === void 0 ? {} : { schedule: update.schedule },
3153
2913
  ...update.enabled === void 0 ? {} : { enabled: update.enabled }
@@ -5710,7 +5470,7 @@ async function createQMindCliHost(options = {}) {
5710
5470
  vault
5711
5471
  });
5712
5472
  const client = createQMindClient({
5713
- access: "sash",
5473
+ nezha: { webOffice: "sash" },
5714
5474
  client: resolved.runtime.client,
5715
5475
  transport: createAuthenticatedQMindTransport(rawTransport, auth, options.adapters?.requestCredential)
5716
5476
  });
@@ -5788,8 +5548,8 @@ function requestsNdjsonOutput(argv) {
5788
5548
  //#region src/build-info.ts
5789
5549
  /** Bundled identity, never inferred from argv, environment, or an endpoint. */
5790
5550
  const QMIND_CLI_DISTRIBUTION = "global";
5791
- const QMIND_CLI_VERSION = "4.3.0";
5792
- const QMIND_CLI_BUILD_TIME = "2026-11-05T13:21:19.000Z";
5551
+ const QMIND_CLI_VERSION = "5.0.0";
5552
+ const QMIND_CLI_BUILD_TIME = "2026-11-20T14:12:45.000Z";
5793
5553
  function qmindCliPlatform() {
5794
5554
  return process.platform === "win32" ? "windows" : process.platform;
5795
5555
  }
@@ -7167,8 +6927,13 @@ function render(context, options, presentation) {
7167
6927
  context.io.stdout(renderQMindCliPresentation(presentation, formatOf(options)));
7168
6928
  }
7169
6929
  function withCommon(command, output = true) {
7170
- 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");
7171
- if (output) command.option("--format <format>", "output format: table | json | agent | ndjson", "table");
6930
+ 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("--client <name>", "originating client identifier").option("--non-interactive", "never open a browser when credentials are missing");
6931
+ if (output) command.addOption(new Option("--format <format>", "output format").choices([
6932
+ "table",
6933
+ "json",
6934
+ "agent",
6935
+ "ndjson"
6936
+ ]).default("table"));
7172
6937
  return command;
7173
6938
  }
7174
6939
  //#endregion
@@ -7214,7 +6979,7 @@ function notebookId(raw) {
7214
6979
  return requiredString(raw.nb, "--nb");
7215
6980
  }
7216
6981
  function registerCanonicalCommands(context, program) {
7217
- withCommon(program.commands.find((command) => command.name() === "notebook").command("discover").description("Discover retrieval-eligible notebooks with summaries")).option("--relationship <relationship>", "owned | shared | all", "all").option("--cursor <cursor>", "continuation cursor from the preceding result").option("--page-size <number>", "maximum results (1..50)", integer).action(async (raw) => {
6982
+ withCommon(program.commands.find((command) => command.name() === "notebook").command("discover").description("Discover retrieval-eligible notebooks with summaries")).option("--relationship <relationship>", "owned | shared | featured | all", "all").option("--cursor <cursor>", "continuation cursor from the preceding result").option("--page-size <number>", "maximum results (1..50)", integer).action(async (raw) => {
7218
6983
  await runCanonicalCommand(context, raw, "qmind.list_notebooks", {
7219
6984
  relationship: raw.relationship,
7220
6985
  cursor: raw.cursor,
@@ -7253,7 +7018,7 @@ function registerCanonicalCommands(context, program) {
7253
7018
  await runCanonicalCommand(context, raw, "qmind.delete_source", input);
7254
7019
  });
7255
7020
  const scheduled = program.command("scheduled-task").description("Manage notebook schedule configurations (not task runs)");
7256
- withCommon(scheduled.command("create").description("Create an enabled built-in scene schedule with empty config")).requiredOption("--nb <id>", "notebook ID").requiredOption("--scene <scene>", "built-in scheduled task scene").requiredOption("--schedule <cron>", "Cron with explicit IANA timezone, e.g. CRON_TZ=Asia/Shanghai 0 9 * * *").action(async (raw) => {
7021
+ withCommon(scheduled.command("create").description("Create an enabled built-in scene schedule with empty config")).requiredOption("--nb <id>", "notebook ID").requiredOption("--scene <scene>", "condensation, source_refresh or source_binding_sync").requiredOption("--schedule <cron>", "Cron with explicit IANA timezone, e.g. CRON_TZ=Asia/Shanghai 0 9 * * *").action(async (raw) => {
7257
7022
  await runCanonicalCommand(context, raw, "qmind.create_scheduled_task", {
7258
7023
  notebookId: notebookId(raw),
7259
7024
  sceneType: raw.scene,
@@ -7457,9 +7222,10 @@ function registerSourceCommands(context, program) {
7457
7222
  }))
7458
7223
  });
7459
7224
  });
7460
- withCommon(source.command("list").description("List sources")).option("--nb <id>", "notebook ID (required)").option("--page <number>", "page number", integer, 0).option("--page-size <number>", "page size", integer, 0).option("--all", "fetch and merge every page").addOption(new Option("--parent <id>", "list direct children of a directory").conflicts("all")).option("--max-pages <number>", "all-pages safety limit", integer, 1e4).action(async (raw) => {
7461
- const host = await hostFor(context, raw);
7225
+ withCommon(source.command("list").description("List sources")).option("--nb <id>", "notebook ID (required)").option("--page <number>", "page number", integer, 0).option("--page-size <number>", "page size", integer, 0).addOption(new Option("--all", "fetch and merge every page").conflicts("page")).addOption(new Option("--parent <id>", "list direct children of a directory").conflicts("all")).option("--max-pages <number>", "safety limit for --all (default: 10000)", integer).action(async (raw) => {
7462
7226
  const notebookId = requiredString(raw.nb, "--nb");
7227
+ if (raw.maxPages !== void 0 && raw.all !== true) throw new QMindError("INVALID_ARGUMENT", "--max-pages requires --all");
7228
+ const host = await hostFor(context, raw);
7463
7229
  let value;
7464
7230
  if (raw.all === true) {
7465
7231
  const pageSize = positiveNumberOption(raw, "pageSize", 0) ?? 100;
@@ -7550,8 +7316,9 @@ function registerSourceCommands(context, program) {
7550
7316
  });
7551
7317
  });
7552
7318
  withCommon(source.command("content <source_id>").description("Read parsed source content"), false).option("--nb <id>", "notebook ID (required)").option("--download <path>", "save content to a file").option("--no-overwrite", "refuse to replace an existing file").action(async (sourceId, raw) => {
7553
- const content = await (await hostFor(context, raw)).client.getSourceContent(requiredString(raw.nb, "--nb"), sourceId);
7554
7319
  const path = optionalString(raw, "download");
7320
+ if (raw.overwrite === false && path === void 0) throw new QMindError("INVALID_ARGUMENT", "--no-overwrite requires --download");
7321
+ const content = await (await hostFor(context, raw)).client.getSourceContent(requiredString(raw.nb, "--nb"), sourceId);
7555
7322
  if (path === void 0) context.io.stdout(content.content);
7556
7323
  else {
7557
7324
  await atomicQMindWrite(path, content.content, raw.overwrite !== false);
@@ -7580,15 +7347,13 @@ function registerSourceCommands(context, program) {
7580
7347
  });
7581
7348
  else context.io.stdout("deleted\n");
7582
7349
  });
7583
- withCommon(source.command("import-site").description("Import a complete web site")).option("--nb <id>", "notebook ID (required)").option("--url <url>", "site root URL (required)").option("--title <title>", "source title").option("--parent <id>", "parent source ID", "").option("--path-prefix <path>", "path prefix", "").option("--max-pages <number>", "maximum page count", integer, 50).option("--sitemap <url>", "sitemap URL", "").option("--include <patterns>", "comma-separated include patterns", "").option("--exclude <patterns>", "comma-separated exclude patterns", "").action(async (raw) => {
7350
+ withCommon(source.command("import-site").description("Import a website into the notebook root")).option("--nb <id>", "notebook ID (required)").option("--url <url>", "site root URL (required)").option("--title <title>", "source title").option("--max-pages <number>", "maximum page count (1..200)", integer, 50).option("--sitemap <url>", "sitemap URL", "").option("--include <patterns>", "comma-separated include patterns", "").option("--exclude <patterns>", "comma-separated exclude patterns", "").action(async (raw) => {
7584
7351
  const host = await hostFor(context, raw);
7585
7352
  const rootUrl = requiredString(raw.url, "--url");
7586
7353
  const value = await submitCliMutation(async () => host.client.importSite(requiredString(raw.nb, "--nb"), {
7587
7354
  excludePaths: splitCsv(stringOption(raw, "exclude")),
7588
7355
  includePaths: splitCsv(stringOption(raw, "include")),
7589
7356
  maxPages: numberOption(raw, "maxPages", 50),
7590
- parentSourceId: String(raw.parent ?? ""),
7591
- pathPrefix: String(raw.pathPrefix ?? ""),
7592
7357
  rootUrl,
7593
7358
  sitemapUrl: optionalString(raw, "sitemap"),
7594
7359
  title: optionalString(raw, "title")
@@ -7601,7 +7366,7 @@ function registerSourceCommands(context, program) {
7601
7366
  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`);
7602
7367
  });
7603
7368
  const image = program.command("image").description("Notebook image presign operations");
7604
- 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) => {
7369
+ 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)").addOption(new Option("--size <bytes>", "file size for presign mode").argParser(integer).conflicts("file")).option("--file <path>", "local image to upload").action(async (raw) => {
7605
7370
  const host = await hostFor(context, raw);
7606
7371
  const notebookId = requiredString(raw.nb, "--nb");
7607
7372
  const sourceId = requiredString(raw.source, "--source");
@@ -7653,17 +7418,17 @@ function registerSceneCommands(context, program) {
7653
7418
  }
7654
7419
  function registerTaskCommands(context, program) {
7655
7420
  const task = program.command("task").description("Manage notebook task runs");
7656
- withCommon(task.command("create").description("Create a notebook task run")).option("--nb <id>", "notebook ID (required)").option("--scene <scene>", "task scene (required)").option("--trigger <trigger>", "task trigger", "manual").option("--sources <ids>", "comma-separated source IDs", "").action(async (raw) => {
7421
+ withCommon(task.command("create").description("Create a notebook task run")).option("--nb <id>", "notebook ID (required)").option("--scene <scene>", "manual task scene: condensation or source_refresh (required)").action(async (raw) => {
7657
7422
  const scene = requiredString(raw.scene, "--scene").trim();
7658
7423
  if (scene === "compilation" || scene === "lint") throw new QMindError("INVALID_ARGUMENT", `task creation does not support scene ${JSON.stringify(scene)}`);
7424
+ if (scene === "source_binding_sync") throw new QMindError("INVALID_ARGUMENT", "source_binding_sync requires a scheduled task");
7425
+ const notebookId = requiredString(raw.nb, "--nb");
7659
7426
  const host = await hostFor(context, raw);
7660
- const sourceIds = splitCsv(stringOption(raw, "sources"));
7661
7427
  render(context, raw, {
7662
7428
  kind: "json",
7663
- value: await submitCliMutation(async () => host.client.createTaskRun(requiredString(raw.nb, "--nb"), {
7664
- ...sourceIds.length === 0 ? {} : { config: { sourceIds } },
7429
+ value: await submitCliMutation(async () => host.client.createTaskRun(notebookId, {
7665
7430
  sceneType: scene,
7666
- trigger: String(raw.trigger ?? "manual")
7431
+ trigger: "manual"
7667
7432
  }))
7668
7433
  });
7669
7434
  });
@@ -7694,7 +7459,7 @@ function syncText(stats) {
7694
7459
  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";
7695
7460
  }
7696
7461
  function registerSyncCommand(context, program) {
7697
- 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([
7462
+ 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").addOption(new Option("--format <format>", "summary output format").choices(["json", "text"]).default("json")).addOption(new Option("--mode <mode>", "existing-file behavior").choices([
7698
7463
  "skip",
7699
7464
  "overwrite",
7700
7465
  "if-changed"
@@ -7728,11 +7493,7 @@ function registerSyncCommand(context, program) {
7728
7493
  });
7729
7494
  }
7730
7495
  function registerUpdateCommand(context, program) {
7731
- program.command("update").alias("self-update").description("Update a Native CLI or show the npm upgrade path").option("--url <url>", "legacy update URL (ignored)").addOption(new Option("--channel <channel>", "legacy release channel (ignored)").choices([
7732
- "stable",
7733
- "beta",
7734
- "daily"
7735
- ]).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(async (raw) => {
7496
+ program.command("update").alias("self-update").description("Update a Native CLI or show the npm upgrade path").option("--check", "check the Native stable release without installing it").action(async (raw) => {
7736
7497
  const result = await context.updater.run({ check: raw.check === true });
7737
7498
  if (result.status === "unsupported") throw new QMindError("UNSUPPORTED_OPERATION", `self-update is unavailable for npm installs; run ${result.command}`);
7738
7499
  if (result.status === "up-to-date") context.io.stdout(`${distribution.command} ${result.currentVersion} is up to date\n`);
@@ -7771,7 +7532,7 @@ async function runQMindCli(argv, options = {}) {
7771
7532
  updater: options.updater ?? createQMindCliUpdater({ identity: {
7772
7533
  artifactKind: "npm",
7773
7534
  command: distribution.command,
7774
- currentVersion: "4.3.0",
7535
+ currentVersion: "5.0.0",
7775
7536
  distribution: distribution.id,
7776
7537
  executablePath: process.execPath,
7777
7538
  package: distribution.package,