@khanglvm/outline-cli 0.1.7 → 0.2.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.
@@ -1,5 +1,7 @@
1
1
  import { CliError } from "./errors.js";
2
2
 
3
+ const MEMORY_ENTITY_TYPES = ["document", "collection", "user", "group", "template"];
4
+
3
5
  const TYPES = {
4
6
  string: (v) => typeof v === "string",
5
7
  number: (v) => typeof v === "number" && Number.isFinite(v),
@@ -155,6 +157,447 @@ function buildValidationDetails(tool, spec, issues, args = undefined) {
155
157
  };
156
158
  }
157
159
 
160
+ const ACCESS_RESOLVE_COMMON_PROPERTIES = {
161
+ refs: { type: "string[]" },
162
+ queries: { type: "string[]" },
163
+ documentQueries: { type: "string[]" },
164
+ profile: { type: "string" },
165
+ resolveLimit: { type: "number", min: 1 },
166
+ minScore: { type: "number", min: 0 },
167
+ maxAgeHours: { type: "number", min: 0 },
168
+ refresh: { type: "boolean" },
169
+ strict: { type: "boolean" },
170
+ strictThreshold: { type: "number", min: 0 },
171
+ fallbackSearch: { type: "boolean" },
172
+ fallbackMinScore: { type: "number", min: 0 },
173
+ fallbackLimit: { type: "number", min: 1 },
174
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
175
+ resolveConcurrency: { type: "number", min: 1 },
176
+ resolveHydrateConcurrency: { type: "number", min: 1 },
177
+ };
178
+
179
+ const DOCUMENT_ACCESS_RESOLVE_PROPERTIES = {
180
+ id: { type: "string" },
181
+ documentId: { type: "string" },
182
+ query: { type: "string" },
183
+ documentQuery: { type: "string" },
184
+ shareId: { type: "string" },
185
+ shareIds: { type: "string[]" },
186
+ urlId: { type: "string" },
187
+ urlIds: { type: "string[]" },
188
+ url: { type: "string" },
189
+ urls: { type: "string[]" },
190
+ resolveCollectionId: { type: "string" },
191
+ snippetMinWords: { type: "number", min: 1 },
192
+ snippetMaxWords: { type: "number", min: 1 },
193
+ ...ACCESS_RESOLVE_COMMON_PROPERTIES,
194
+ };
195
+
196
+ const COLLECTION_ACCESS_RESOLVE_PROPERTIES = {
197
+ id: { type: "string" },
198
+ collectionId: { type: "string" },
199
+ query: { type: "string" },
200
+ urlId: { type: "string" },
201
+ urlIds: { type: "string[]" },
202
+ url: { type: "string" },
203
+ urls: { type: "string[]" },
204
+ ...ACCESS_RESOLVE_COMMON_PROPERTIES,
205
+ };
206
+
207
+ const PRINCIPAL_RESOLVE_PROPERTIES = {
208
+ query: { type: "string" },
209
+ refs: { type: "string[]" },
210
+ queries: { type: "string[]" },
211
+ profile: { type: "string" },
212
+ resolveLimit: { type: "number", min: 1 },
213
+ minScore: { type: "number", min: 0 },
214
+ maxAgeHours: { type: "number", min: 0 },
215
+ refresh: { type: "boolean" },
216
+ strict: { type: "boolean" },
217
+ strictThreshold: { type: "number", min: 0 },
218
+ fallbackSearch: { type: "boolean" },
219
+ fallbackMinScore: { type: "number", min: 0 },
220
+ fallbackLimit: { type: "number", min: 1 },
221
+ resolveConcurrency: { type: "number", min: 1 },
222
+ resolveHydrateConcurrency: { type: "number", min: 1 },
223
+ };
224
+
225
+ const PRINCIPAL_RESOLVE_OPTION_PROPERTIES = {
226
+ profile: { type: "string" },
227
+ resolveLimit: { type: "number", min: 1 },
228
+ minScore: { type: "number", min: 0 },
229
+ maxAgeHours: { type: "number", min: 0 },
230
+ refresh: { type: "boolean" },
231
+ strict: { type: "boolean" },
232
+ strictThreshold: { type: "number", min: 0 },
233
+ fallbackSearch: { type: "boolean" },
234
+ fallbackMinScore: { type: "number", min: 0 },
235
+ fallbackLimit: { type: "number", min: 1 },
236
+ resolveConcurrency: { type: "number", min: 1 },
237
+ resolveHydrateConcurrency: { type: "number", min: 1 },
238
+ };
239
+
240
+ const USER_PRINCIPAL_RESOLVE_PROPERTIES = {
241
+ userQuery: { type: "string" },
242
+ userRef: { type: "string" },
243
+ userQueries: { type: "string[]" },
244
+ userRefs: { type: "string[]" },
245
+ ...PRINCIPAL_RESOLVE_OPTION_PROPERTIES,
246
+ };
247
+
248
+ const GROUP_PRINCIPAL_RESOLVE_PROPERTIES = {
249
+ groupQuery: { type: "string" },
250
+ groupRef: { type: "string" },
251
+ groupQueries: { type: "string[]" },
252
+ groupRefs: { type: "string[]" },
253
+ ...PRINCIPAL_RESOLVE_OPTION_PROPERTIES,
254
+ };
255
+
256
+ const TEMPLATE_RESOLVE_PROPERTIES = {
257
+ templateQuery: { type: "string" },
258
+ templateRef: { type: "string" },
259
+ templateQueries: { type: "string[]" },
260
+ templateRefs: { type: "string[]" },
261
+ refs: { type: "string[]" },
262
+ queries: { type: "string[]" },
263
+ profile: { type: "string" },
264
+ resolveLimit: { type: "number", min: 1 },
265
+ minScore: { type: "number", min: 0 },
266
+ maxAgeHours: { type: "number", min: 0 },
267
+ refresh: { type: "boolean" },
268
+ strict: { type: "boolean" },
269
+ strictThreshold: { type: "number", min: 0 },
270
+ fallbackSearch: { type: "boolean" },
271
+ fallbackMinScore: { type: "number", min: 0 },
272
+ fallbackLimit: { type: "number", min: 1 },
273
+ resolveConcurrency: { type: "number", min: 1 },
274
+ resolveHydrateConcurrency: { type: "number", min: 1 },
275
+ };
276
+
277
+ const DOCUMENT_TARGET_RESOLVE_PROPERTIES = {
278
+ documentId: { type: "string" },
279
+ query: { type: "string" },
280
+ documentQuery: { type: "string" },
281
+ documentRef: { type: "string" },
282
+ queries: { type: "string[]" },
283
+ documentQueries: { type: "string[]" },
284
+ documentRefs: { type: "string[]" },
285
+ refs: { type: "string[]" },
286
+ shareId: { type: "string" },
287
+ shareIds: { type: "string[]" },
288
+ urlId: { type: "string" },
289
+ urlIds: { type: "string[]" },
290
+ url: { type: "string" },
291
+ urls: { type: "string[]" },
292
+ profile: { type: "string" },
293
+ resolveLimit: { type: "number", min: 1 },
294
+ minScore: { type: "number", min: 0 },
295
+ maxAgeHours: { type: "number", min: 0 },
296
+ refresh: { type: "boolean" },
297
+ strict: { type: "boolean" },
298
+ strictThreshold: { type: "number", min: 0 },
299
+ fallbackSearch: { type: "boolean" },
300
+ fallbackMinScore: { type: "number", min: 0 },
301
+ fallbackLimit: { type: "number", min: 1 },
302
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
303
+ resolveCollectionId: { type: "string" },
304
+ resolveConcurrency: { type: "number", min: 1 },
305
+ resolveHydrateConcurrency: { type: "number", min: 1 },
306
+ snippetMinWords: { type: "number", min: 1 },
307
+ snippetMaxWords: { type: "number", min: 1 },
308
+ };
309
+
310
+ const DOCUMENT_MUTATION_TARGET_RESOLVE_PROPERTIES = {
311
+ id: { type: "string" },
312
+ ...DOCUMENT_TARGET_RESOLVE_PROPERTIES,
313
+ };
314
+
315
+ function hasNonEmptyString(value) {
316
+ return typeof value === "string" && value.trim().length > 0;
317
+ }
318
+
319
+ function hasNonEmptyStringArray(value) {
320
+ return Array.isArray(value) && value.some((item) => hasNonEmptyString(item));
321
+ }
322
+
323
+ function validateAccessResolveConcurrency(args, issues) {
324
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
325
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
326
+ }
327
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
328
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
329
+ }
330
+ }
331
+
332
+ function validateDocumentAccessSelector(args, issues) {
333
+ const hasScalar = ["id", "documentId", "query", "documentQuery", "shareId", "urlId", "url"].some((key) =>
334
+ hasNonEmptyString(args[key])
335
+ );
336
+ const hasArray = ["refs", "queries", "documentQueries", "shareIds", "urlIds", "urls"].some((key) =>
337
+ hasNonEmptyStringArray(args[key])
338
+ );
339
+ if (!hasScalar && !hasArray) {
340
+ issues.push({ path: "args.id", message: "or args.documentId, args.query, args.refs, args.shareId, args.urlId, or args.url is required" });
341
+ }
342
+ if (args.id && args.documentId) {
343
+ issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
344
+ }
345
+ validateAccessResolveConcurrency(args, issues);
346
+ }
347
+
348
+ function hasDocumentResolveSelector(args, { includeQuery = true } = {}) {
349
+ const scalarKeys = [
350
+ "documentId",
351
+ "documentQuery",
352
+ "documentRef",
353
+ "shareId",
354
+ "urlId",
355
+ "url",
356
+ ...(includeQuery ? ["query"] : []),
357
+ ];
358
+ const arrayKeys = [
359
+ "refs",
360
+ "documentRefs",
361
+ "documentQueries",
362
+ "shareIds",
363
+ "urlIds",
364
+ "urls",
365
+ ...(includeQuery ? ["queries"] : []),
366
+ ];
367
+ return scalarKeys.some((key) => hasNonEmptyString(args[key]))
368
+ || arrayKeys.some((key) => hasNonEmptyStringArray(args[key]));
369
+ }
370
+
371
+ function validateOptionalDocumentResolveArgs(args, issues) {
372
+ validateAccessResolveConcurrency(args, issues);
373
+ }
374
+
375
+ function validateRequiredDocumentResolveArgs(args, issues) {
376
+ if (!hasDocumentResolveSelector(args)) {
377
+ issues.push({ path: "args.documentId", message: "or args.query, args.documentQuery, args.refs, args.shareId, args.urlId, or args.url is required" });
378
+ }
379
+ const hasExact = hasNonEmptyString(args.documentId);
380
+ const hasRef = [
381
+ "query",
382
+ "documentQuery",
383
+ "documentRef",
384
+ "shareId",
385
+ "urlId",
386
+ "url",
387
+ ].some((key) => hasNonEmptyString(args[key]))
388
+ || ["refs", "queries", "documentQueries", "documentRefs", "shareIds", "urlIds", "urls"].some((key) => hasNonEmptyStringArray(args[key]));
389
+ if (hasExact && hasRef) {
390
+ issues.push({ path: "args.documentQuery", message: "cannot be combined with args.documentId" });
391
+ }
392
+ validateAccessResolveConcurrency(args, issues);
393
+ }
394
+
395
+ function validateRequiredDocumentMutationTargetArgs(args, issues) {
396
+ const hasId = hasNonEmptyString(args.id);
397
+ const hasDocumentId = hasNonEmptyString(args.documentId);
398
+ const hasRef = [
399
+ "query",
400
+ "documentQuery",
401
+ "documentRef",
402
+ "shareId",
403
+ "urlId",
404
+ "url",
405
+ ].some((key) => hasNonEmptyString(args[key]))
406
+ || ["refs", "queries", "documentQueries", "documentRefs", "shareIds", "urlIds", "urls"].some((key) => hasNonEmptyStringArray(args[key]));
407
+
408
+ if (!hasId && !hasDocumentId && !hasRef) {
409
+ issues.push({ path: "args.id", message: "or args.documentId, args.query, args.refs, args.shareId, args.urlId, or args.url is required" });
410
+ }
411
+ if (hasId && hasDocumentId) {
412
+ issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
413
+ }
414
+ if ((hasId || hasDocumentId) && hasRef) {
415
+ issues.push({ path: "args.query", message: "cannot be combined with args.id or args.documentId" });
416
+ }
417
+ validateAccessResolveConcurrency(args, issues);
418
+ }
419
+
420
+ function validateExpectedRevisionGuard(args, issues) {
421
+ if (typeof args.expectedRevision === "string" && args.expectedRevision.trim().toLowerCase() !== "latest") {
422
+ issues.push({ path: "args.expectedRevision", message: "must be a number or latest" });
423
+ }
424
+ }
425
+
426
+ function validateRequiredDocumentMutationTargetAndExpectedRevision(args, issues) {
427
+ validateRequiredDocumentMutationTargetArgs(args, issues);
428
+ validateExpectedRevisionGuard(args, issues);
429
+ }
430
+
431
+ function validateBatchUpdateDocumentTarget(update, issues, path) {
432
+ const hasId = hasNonEmptyString(update.id);
433
+ const hasDocumentId = hasNonEmptyString(update.documentId);
434
+ const hasRef = [
435
+ "query",
436
+ "documentQuery",
437
+ "documentRef",
438
+ "shareId",
439
+ "urlId",
440
+ "url",
441
+ ].some((key) => hasNonEmptyString(update[key]))
442
+ || ["refs", "queries", "documentQueries", "documentRefs", "shareIds", "urlIds", "urls"].some((key) => hasNonEmptyStringArray(update[key]));
443
+
444
+ if (!hasId && !hasDocumentId && !hasRef) {
445
+ issues.push({ path: `${path}.id`, message: "or document refs are required" });
446
+ }
447
+ if (hasId && hasDocumentId) {
448
+ issues.push({ path: `${path}.documentId`, message: "cannot be combined with id" });
449
+ }
450
+ if ((hasId || hasDocumentId) && hasRef) {
451
+ issues.push({ path: `${path}.query`, message: "cannot be combined with id or documentId" });
452
+ }
453
+ if (hasRef && !Object.prototype.hasOwnProperty.call(update, "expectedRevision")) {
454
+ issues.push({ path: `${path}.expectedRevision`, message: "is required when using document refs" });
455
+ }
456
+ }
457
+
458
+ function validateEventsListResolveSelectors(args, issues) {
459
+ const hasDocumentRef = ["documentQuery", "documentRef", "shareId", "urlId", "url"].some((key) => hasNonEmptyString(args[key]))
460
+ || ["documentQueries", "documentRefs", "refs", "shareIds", "urlIds", "urls"].some((key) => hasNonEmptyStringArray(args[key]));
461
+ if (hasNonEmptyString(args.documentId) && hasDocumentRef) {
462
+ issues.push({ path: "args.documentQuery", message: "cannot be combined with args.documentId" });
463
+ }
464
+ if (hasNonEmptyString(args.collectionId) && hasDocumentFilterResolveSelector(args, "collection")) {
465
+ issues.push({ path: "args.collectionQuery", message: "cannot be combined with args.collectionId" });
466
+ }
467
+ if (hasNonEmptyString(args.actorId) && hasDocumentFilterResolveSelector(args, "user")) {
468
+ issues.push({ path: "args.userQuery", message: "cannot be combined with args.actorId" });
469
+ }
470
+ validateAccessResolveConcurrency(args, issues);
471
+ }
472
+
473
+ function validateOptionalCollectionFilterResolveArgs(args, issues) {
474
+ if (hasNonEmptyString(args.collectionId) && hasDocumentFilterResolveSelector(args, "collection")) {
475
+ issues.push({ path: "args.collectionQuery", message: "cannot be combined with args.collectionId" });
476
+ }
477
+ validateAccessResolveConcurrency(args, issues);
478
+ }
479
+
480
+ function validateShareInfoSelector(args, issues) {
481
+ const hasShareId = hasNonEmptyString(args.id);
482
+ const hasDocumentRef = hasDocumentResolveSelector(args);
483
+ if (!hasShareId && !hasDocumentRef) {
484
+ issues.push({ path: "args.id", message: "or args.documentId, args.query, args.documentQuery, args.refs, args.urlId, or args.url is required" });
485
+ }
486
+ if (hasShareId && hasDocumentRef) {
487
+ issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
488
+ }
489
+ validateAccessResolveConcurrency(args, issues);
490
+ }
491
+
492
+ function validateCollectionAccessSelector(args, issues) {
493
+ const hasScalar = ["id", "collectionId", "query", "urlId", "url"].some((key) =>
494
+ hasNonEmptyString(args[key])
495
+ );
496
+ const hasArray = ["refs", "queries", "urlIds", "urls"].some((key) =>
497
+ hasNonEmptyStringArray(args[key])
498
+ );
499
+ if (!hasScalar && !hasArray) {
500
+ issues.push({ path: "args.id", message: "or args.collectionId, args.query, args.refs, args.urlId, or args.url is required" });
501
+ }
502
+ if (args.id && args.collectionId) {
503
+ issues.push({ path: "args.collectionId", message: "cannot be combined with args.id" });
504
+ }
505
+ validateAccessResolveConcurrency(args, issues);
506
+ }
507
+
508
+ function hasPrincipalResolveSelector(args) {
509
+ return ["query"].some((key) => hasNonEmptyString(args[key]))
510
+ || ["refs", "queries"].some((key) => hasNonEmptyStringArray(args[key]));
511
+ }
512
+
513
+ function validatePrincipalResolveConcurrency(args, issues) {
514
+ validateAccessResolveConcurrency(args, issues);
515
+ }
516
+
517
+ function hasNamedPrincipalSelector(args, type) {
518
+ const prefix = type === "group" ? "group" : "user";
519
+ return [`${prefix}Query`, `${prefix}Ref`].some((key) => hasNonEmptyString(args[key]))
520
+ || [`${prefix}Queries`, `${prefix}Refs`].some((key) => hasNonEmptyStringArray(args[key]));
521
+ }
522
+
523
+ function validateNamedPrincipalSelector(args, issues, type) {
524
+ const idKey = type === "group" ? "groupId" : "userId";
525
+ const prefix = type === "group" ? "group" : "user";
526
+ const hasId = hasNonEmptyString(args[idKey]);
527
+ const hasResolvedRef = hasNamedPrincipalSelector(args, type);
528
+ if (!hasId && !hasResolvedRef) {
529
+ issues.push({ path: `args.${idKey}`, message: `or args.${prefix}Query/args.${prefix}Refs is required` });
530
+ }
531
+ if (hasId && hasResolvedRef) {
532
+ issues.push({ path: `args.${prefix}Query`, message: `cannot be combined with args.${idKey}` });
533
+ }
534
+ validatePrincipalResolveConcurrency(args, issues);
535
+ }
536
+
537
+ function hasGroupTargetSelector(args) {
538
+ return ["id", "groupId", "groupQuery", "groupRef"].some((key) => hasNonEmptyString(args[key]))
539
+ || ["groupQueries", "groupRefs"].some((key) => hasNonEmptyStringArray(args[key]));
540
+ }
541
+
542
+ function hasTemplateResolveSelector(args, { includeQuery = true } = {}) {
543
+ return ["templateQuery", "templateRef", ...(includeQuery ? ["query"] : [])].some((key) => hasNonEmptyString(args[key]))
544
+ || ["templateQueries", "templateRefs", "refs", ...(includeQuery ? ["queries"] : [])].some((key) => hasNonEmptyStringArray(args[key]));
545
+ }
546
+
547
+ function validateTemplateTargetSelector(args, issues, options = {}) {
548
+ const idKeys = options.idKeys || ["id"];
549
+ const hasId = idKeys.some((key) => hasNonEmptyString(args[key]));
550
+ const hasIds = hasNonEmptyStringArray(args.ids);
551
+ const hasResolvedRef = hasTemplateResolveSelector(args, { includeQuery: options.includeQuery !== false });
552
+ if (!hasId && !hasIds && !hasResolvedRef) {
553
+ issues.push({ path: `args.${idKeys[0]}`, message: "or args.templateQuery/args.templateRefs is required" });
554
+ }
555
+ if ((hasId || hasIds) && hasResolvedRef) {
556
+ issues.push({ path: "args.templateQuery", message: `cannot be combined with args.${hasIds ? "ids" : idKeys[0]}` });
557
+ }
558
+ validatePrincipalResolveConcurrency(args, issues);
559
+ }
560
+
561
+ function validateGroupTargetSelector(args, issues) {
562
+ if (!hasGroupTargetSelector(args)) {
563
+ issues.push({ path: "args.id", message: "or args.groupId/args.groupQuery/args.groupRefs is required" });
564
+ }
565
+ const hasId = hasNonEmptyString(args.id) || hasNonEmptyString(args.groupId);
566
+ const hasResolvedRef = hasNamedPrincipalSelector(args, "group");
567
+ if (hasNonEmptyString(args.id) && hasNonEmptyString(args.groupId)) {
568
+ issues.push({ path: "args.groupId", message: "cannot be combined with args.id" });
569
+ }
570
+ if (hasId && hasResolvedRef) {
571
+ issues.push({ path: "args.groupQuery", message: "cannot be combined with args.id or args.groupId" });
572
+ }
573
+ validatePrincipalResolveConcurrency(args, issues);
574
+ }
575
+
576
+ function validateGroupUserMutationSelector(args, issues) {
577
+ validateGroupTargetSelector(args, issues);
578
+ validateNamedPrincipalSelector(args, issues, "user");
579
+ }
580
+
581
+ function validateCollectionUserMutationSelector(args, issues) {
582
+ validateCollectionAccessSelector(args, issues);
583
+ validateNamedPrincipalSelector(args, issues, "user");
584
+ }
585
+
586
+ function validateCollectionGroupMutationSelector(args, issues) {
587
+ validateCollectionAccessSelector(args, issues);
588
+ validateNamedPrincipalSelector(args, issues, "group");
589
+ }
590
+
591
+ function validateDocumentUserMutationSelector(args, issues) {
592
+ validateDocumentAccessSelector(args, issues);
593
+ validateNamedPrincipalSelector(args, issues, "user");
594
+ }
595
+
596
+ function validateDocumentGroupMutationSelector(args, issues) {
597
+ validateDocumentAccessSelector(args, issues);
598
+ validateNamedPrincipalSelector(args, issues, "group");
599
+ }
600
+
158
601
  function looksNumeric(value) {
159
602
  return /^-?(?:\d+|\d+\.\d+)$/.test(String(value || "").trim());
160
603
  }
@@ -331,11 +774,58 @@ function validateSpec(tool, args, spec) {
331
774
 
332
775
  const SHARED_DOC_COMMON = {
333
776
  collectionId: { type: "string" },
777
+ collectionQuery: { type: "string" },
778
+ collectionRef: { type: "string" },
779
+ collectionQueries: { type: "string[]" },
780
+ collectionRefs: { type: "string[]" },
334
781
  userId: { type: "string" },
782
+ userQuery: { type: "string" },
783
+ userRef: { type: "string" },
784
+ userQueries: { type: "string[]" },
785
+ userRefs: { type: "string[]" },
786
+ profile: { type: "string" },
787
+ resolveLimit: { type: "number", min: 1 },
788
+ minScore: { type: "number", min: 0 },
789
+ maxAgeHours: { type: "number", min: 0 },
790
+ refresh: { type: "boolean" },
791
+ strict: { type: "boolean" },
792
+ strictThreshold: { type: "number", min: 0 },
793
+ fallbackSearch: { type: "boolean" },
794
+ fallbackMinScore: { type: "number", min: 0 },
795
+ fallbackLimit: { type: "number", min: 1 },
335
796
  statusFilter: { type: ["string", "string[]"] },
336
797
  view: { type: "string", enum: ["ids", "summary", "full"] },
337
798
  };
338
799
 
800
+ function hasDocumentFilterResolveSelector(args, prefix) {
801
+ return [`${prefix}Query`, `${prefix}Ref`].some((key) => hasNonEmptyString(args[key]))
802
+ || [`${prefix}Queries`, `${prefix}Refs`].some((key) => hasNonEmptyStringArray(args[key]));
803
+ }
804
+
805
+ function validateDocumentFilterSelectors(args, issues) {
806
+ if (hasNonEmptyString(args.collectionId) && hasDocumentFilterResolveSelector(args, "collection")) {
807
+ issues.push({ path: "args.collectionQuery", message: "cannot be combined with args.collectionId" });
808
+ }
809
+ if (hasNonEmptyString(args.userId) && hasDocumentFilterResolveSelector(args, "user")) {
810
+ issues.push({ path: "args.userQuery", message: "cannot be combined with args.userId" });
811
+ }
812
+ }
813
+
814
+ function hasAnswerDocumentResolveSelector(args) {
815
+ return ["documentQuery", "documentRef", "shareId", "urlId", "url"].some((key) => hasNonEmptyString(args[key]))
816
+ || ["documentQueries", "documentRefs", "refs", "shareIds", "urlIds", "urls"].some((key) => hasNonEmptyStringArray(args[key]));
817
+ }
818
+
819
+ function validateAnswerScopeSelectors(args, issues) {
820
+ validateDocumentFilterSelectors(args, issues);
821
+ if (hasNonEmptyString(args.id) && hasNonEmptyString(args.documentId)) {
822
+ issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
823
+ }
824
+ if ((hasNonEmptyString(args.id) || hasNonEmptyString(args.documentId)) && hasAnswerDocumentResolveSelector(args)) {
825
+ issues.push({ path: "args.documentQuery", message: "cannot be combined with args.id or args.documentId" });
826
+ }
827
+ }
828
+
339
829
  const DATA_ATTRIBUTE_DATA_TYPES = ["string", "number", "boolean", "list"];
340
830
  const USER_ROLE_TYPES = ["admin", "member", "viewer", "guest"];
341
831
 
@@ -385,6 +875,7 @@ export const TOOL_ARG_SCHEMAS = {
385
875
  if (!args.query && !args.queries) {
386
876
  issues.push({ path: "args.query", message: "or args.queries[] is required" });
387
877
  }
878
+ validateDocumentFilterSelectors(args, issues);
388
879
  },
389
880
  },
390
881
  "documents.list": {
@@ -406,12 +897,28 @@ export const TOOL_ARG_SCHEMAS = {
406
897
  message: "cannot be combined with a non-null args.parentDocumentId",
407
898
  });
408
899
  }
900
+ validateDocumentFilterSelectors(args, issues);
409
901
  },
410
902
  },
411
903
  "documents.backlinks": {
412
- required: ["id"],
413
904
  properties: {
414
905
  id: { type: "string" },
906
+ query: { type: "string" },
907
+ shareId: { type: "string" },
908
+ urlId: { type: "string" },
909
+ url: { type: "string" },
910
+ profile: { type: "string" },
911
+ resolveLimit: { type: "number", min: 1 },
912
+ minScore: { type: "number", min: 0 },
913
+ maxAgeHours: { type: "number", min: 0 },
914
+ refresh: { type: "boolean" },
915
+ strict: { type: "boolean" },
916
+ strictThreshold: { type: "number", min: 0 },
917
+ fallbackSearch: { type: "boolean" },
918
+ fallbackMinScore: { type: "number", min: 0 },
919
+ fallbackLimit: { type: "number", min: 1 },
920
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
921
+ resolveCollectionId: { type: "string" },
415
922
  limit: { type: "number", min: 1 },
416
923
  offset: { type: "number", min: 0 },
417
924
  sort: { type: "string" },
@@ -421,8 +928,12 @@ export const TOOL_ARG_SCHEMAS = {
421
928
  maxAttempts: { type: "number", min: 1 },
422
929
  },
423
930
  custom(args, issues) {
424
- if (typeof args.id === "string" && args.id.trim().length === 0) {
425
- issues.push({ path: "args.id", message: "must be a non-empty string" });
931
+ const refs = ["id", "query", "shareId", "urlId", "url"].filter((key) => args[key]);
932
+ if (refs.length === 0) {
933
+ issues.push({ path: "args.id", message: "or args.query, args.shareId, args.urlId, or args.url is required" });
934
+ }
935
+ if (refs.length > 1) {
936
+ issues.push({ path: "args.id", message: "provide only one of args.id, args.query, args.shareId, args.urlId, or args.url" });
426
937
  }
427
938
  if (typeof args.limit === "number" && args.limit > 250) {
428
939
  issues.push({ path: "args.limit", message: "must be <= 250" });
@@ -433,6 +944,29 @@ export const TOOL_ARG_SCHEMAS = {
433
944
  properties: {
434
945
  id: { type: "string" },
435
946
  ids: { type: "string[]" },
947
+ refs: { type: "string[]" },
948
+ query: { type: "string" },
949
+ queries: { type: "string[]" },
950
+ shareId: { type: "string" },
951
+ shareIds: { type: "string[]" },
952
+ urlId: { type: "string" },
953
+ urlIds: { type: "string[]" },
954
+ url: { type: "string" },
955
+ urls: { type: "string[]" },
956
+ profile: { type: "string" },
957
+ resolveLimit: { type: "number", min: 1 },
958
+ minScore: { type: "number", min: 0 },
959
+ maxAgeHours: { type: "number", min: 0 },
960
+ refresh: { type: "boolean" },
961
+ strict: { type: "boolean" },
962
+ strictThreshold: { type: "number", min: 0 },
963
+ fallbackSearch: { type: "boolean" },
964
+ fallbackMinScore: { type: "number", min: 0 },
965
+ fallbackLimit: { type: "number", min: 1 },
966
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
967
+ resolveCollectionId: { type: "string" },
968
+ resolveConcurrency: { type: "number", min: 1 },
969
+ resolveHydrateConcurrency: { type: "number", min: 1 },
436
970
  includeBacklinks: { type: "boolean" },
437
971
  includeSearchNeighbors: { type: "boolean" },
438
972
  searchQueries: { type: "string[]" },
@@ -443,9 +977,15 @@ export const TOOL_ARG_SCHEMAS = {
443
977
  custom(args, issues) {
444
978
  const hasId = typeof args.id === "string" && args.id.trim().length > 0;
445
979
  const hasIds = Array.isArray(args.ids) && args.ids.length > 0;
980
+ const hasRefs = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
981
+ Array.isArray(args[key]) && args[key].length > 0
982
+ );
983
+ const hasSingularRef = ["query", "shareId", "urlId", "url"].some((key) =>
984
+ typeof args[key] === "string" && args[key].trim().length > 0
985
+ );
446
986
 
447
- if (!hasId && !hasIds) {
448
- issues.push({ path: "args.id", message: "or args.ids[] is required" });
987
+ if (!hasId && !hasIds && !hasRefs && !hasSingularRef) {
988
+ issues.push({ path: "args.id", message: "or args.ids[], args.refs[], args.query, args.queries[], args.shareId(s), args.urlId(s), or args.url(s) is required" });
449
989
  }
450
990
  if (Array.isArray(args.ids) && args.ids.length === 0) {
451
991
  issues.push({ path: "args.ids", message: "must be a non-empty string[] when provided" });
@@ -478,12 +1018,40 @@ export const TOOL_ARG_SCHEMAS = {
478
1018
  if (typeof args.limitPerSource === "number" && args.limitPerSource > 100) {
479
1019
  issues.push({ path: "args.limitPerSource", message: "must be <= 100" });
480
1020
  }
1021
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
1022
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
1023
+ }
1024
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
1025
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
1026
+ }
481
1027
  },
482
1028
  },
483
1029
  "documents.graph_report": {
484
- required: ["seedIds"],
485
1030
  properties: {
486
1031
  seedIds: { type: "string[]" },
1032
+ seedRefs: { type: "string[]" },
1033
+ seedQuery: { type: "string" },
1034
+ seedQueries: { type: "string[]" },
1035
+ seedShareId: { type: "string" },
1036
+ seedShareIds: { type: "string[]" },
1037
+ seedUrlId: { type: "string" },
1038
+ seedUrlIds: { type: "string[]" },
1039
+ seedUrl: { type: "string" },
1040
+ seedUrls: { type: "string[]" },
1041
+ profile: { type: "string" },
1042
+ resolveLimit: { type: "number", min: 1 },
1043
+ minScore: { type: "number", min: 0 },
1044
+ maxAgeHours: { type: "number", min: 0 },
1045
+ refresh: { type: "boolean" },
1046
+ strict: { type: "boolean" },
1047
+ strictThreshold: { type: "number", min: 0 },
1048
+ fallbackSearch: { type: "boolean" },
1049
+ fallbackMinScore: { type: "number", min: 0 },
1050
+ fallbackLimit: { type: "number", min: 1 },
1051
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
1052
+ resolveCollectionId: { type: "string" },
1053
+ resolveConcurrency: { type: "number", min: 1 },
1054
+ resolveHydrateConcurrency: { type: "number", min: 1 },
487
1055
  depth: { type: "number", min: 0 },
488
1056
  maxNodes: { type: "number", min: 1 },
489
1057
  includeBacklinks: { type: "boolean" },
@@ -493,6 +1061,17 @@ export const TOOL_ARG_SCHEMAS = {
493
1061
  maxAttempts: { type: "number", min: 1 },
494
1062
  },
495
1063
  custom(args, issues) {
1064
+ const hasSeedIds = Array.isArray(args.seedIds) && args.seedIds.length > 0;
1065
+ const hasSeedArrays = ["seedRefs", "seedQueries", "seedShareIds", "seedUrlIds", "seedUrls"].some((key) =>
1066
+ Array.isArray(args[key]) && args[key].length > 0
1067
+ );
1068
+ const hasSeedSingle = ["seedQuery", "seedShareId", "seedUrlId", "seedUrl"].some((key) =>
1069
+ typeof args[key] === "string" && args[key].trim().length > 0
1070
+ );
1071
+
1072
+ if (!hasSeedIds && !hasSeedArrays && !hasSeedSingle) {
1073
+ issues.push({ path: "args.seedIds", message: "or args.seedRefs[], args.seedQuery, args.seedQueries[], args.seedShareId(s), args.seedUrlId(s), or args.seedUrl(s) is required" });
1074
+ }
496
1075
  if (Array.isArray(args.seedIds) && args.seedIds.length === 0) {
497
1076
  issues.push({ path: "args.seedIds", message: "must be a non-empty string[]" });
498
1077
  }
@@ -512,6 +1091,12 @@ export const TOOL_ARG_SCHEMAS = {
512
1091
  if (typeof args.limitPerSource === "number" && args.limitPerSource > 100) {
513
1092
  issues.push({ path: "args.limitPerSource", message: "must be <= 100" });
514
1093
  }
1094
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
1095
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
1096
+ }
1097
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
1098
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
1099
+ }
515
1100
  if (args.includeBacklinks === false && args.includeSearchNeighbors === false) {
516
1101
  issues.push({
517
1102
  path: "args.includeBacklinks",
@@ -524,6 +1109,29 @@ export const TOOL_ARG_SCHEMAS = {
524
1109
  properties: {
525
1110
  id: { type: "string" },
526
1111
  ids: { type: "string[]" },
1112
+ refs: { type: "string[]" },
1113
+ query: { type: "string" },
1114
+ queries: { type: "string[]" },
1115
+ shareId: { type: "string" },
1116
+ shareIds: { type: "string[]" },
1117
+ urlId: { type: "string" },
1118
+ urlIds: { type: "string[]" },
1119
+ url: { type: "string" },
1120
+ urls: { type: "string[]" },
1121
+ profile: { type: "string" },
1122
+ resolveLimit: { type: "number", min: 1 },
1123
+ minScore: { type: "number", min: 0 },
1124
+ maxAgeHours: { type: "number", min: 0 },
1125
+ refresh: { type: "boolean" },
1126
+ strict: { type: "boolean" },
1127
+ strictThreshold: { type: "number", min: 0 },
1128
+ fallbackSearch: { type: "boolean" },
1129
+ fallbackMinScore: { type: "number", min: 0 },
1130
+ fallbackLimit: { type: "number", min: 1 },
1131
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
1132
+ resolveCollectionId: { type: "string" },
1133
+ resolveConcurrency: { type: "number", min: 1 },
1134
+ resolveHydrateConcurrency: { type: "number", min: 1 },
527
1135
  issueDomains: { type: "string[]" },
528
1136
  keyPattern: { type: "string" },
529
1137
  view: { type: "string", enum: ["ids", "summary", "full"] },
@@ -532,9 +1140,15 @@ export const TOOL_ARG_SCHEMAS = {
532
1140
  custom(args, issues) {
533
1141
  const hasId = typeof args.id === "string" && args.id.trim().length > 0;
534
1142
  const hasIds = Array.isArray(args.ids) && args.ids.length > 0;
1143
+ const hasRefs = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
1144
+ Array.isArray(args[key]) && args[key].length > 0
1145
+ );
1146
+ const hasSingularRef = ["query", "shareId", "urlId", "url"].some((key) =>
1147
+ typeof args[key] === "string" && args[key].trim().length > 0
1148
+ );
535
1149
 
536
- if (!hasId && !hasIds) {
537
- issues.push({ path: "args.id", message: "or args.ids[] is required" });
1150
+ if (!hasId && !hasIds && !hasRefs && !hasSingularRef) {
1151
+ issues.push({ path: "args.id", message: "or args.ids[], args.refs[], args.query, args.queries[], args.shareId(s), args.urlId(s), or args.url(s) is required" });
538
1152
  }
539
1153
  if (typeof args.id === "string" && args.id.trim().length === 0) {
540
1154
  issues.push({ path: "args.id", message: "must be a non-empty string" });
@@ -562,6 +1176,12 @@ export const TOOL_ARG_SCHEMAS = {
562
1176
  }
563
1177
  }
564
1178
  }
1179
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
1180
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
1181
+ }
1182
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
1183
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
1184
+ }
565
1185
  if (typeof args.keyPattern === "string") {
566
1186
  if (args.keyPattern.trim().length === 0) {
567
1187
  issues.push({ path: "args.keyPattern", message: "must be a non-empty string when provided" });
@@ -644,13 +1264,46 @@ export const TOOL_ARG_SCHEMAS = {
644
1264
  properties: {
645
1265
  id: { type: "string" },
646
1266
  documentId: { type: "string" },
1267
+ refs: { type: "string[]" },
1268
+ query: { type: "string" },
1269
+ queries: { type: "string[]" },
647
1270
  url: { type: "string" },
1271
+ urlId: { type: "string" },
1272
+ urlIds: { type: "string[]" },
1273
+ urls: { type: "string[]" },
648
1274
  shareId: { type: "string" },
1275
+ shareIds: { type: "string[]" },
1276
+ profile: { type: "string" },
1277
+ resolveLimit: { type: "number", min: 1 },
1278
+ minScore: { type: "number", min: 0 },
1279
+ maxAgeHours: { type: "number", min: 0 },
1280
+ refresh: { type: "boolean" },
1281
+ strict: { type: "boolean" },
1282
+ strictThreshold: { type: "number", min: 0 },
1283
+ fallbackSearch: { type: "boolean" },
1284
+ fallbackMinScore: { type: "number", min: 0 },
1285
+ fallbackLimit: { type: "number", min: 1 },
1286
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
1287
+ resolveCollectionId: { type: "string" },
1288
+ resolveConcurrency: { type: "number", min: 1 },
1289
+ resolveHydrateConcurrency: { type: "number", min: 1 },
649
1290
  maxAttempts: { type: "number", min: 1 },
650
1291
  },
651
1292
  custom(args, issues) {
652
- if (!args.id && !args.documentId && !args.url && !args.shareId) {
653
- issues.push({ path: "args.id", message: "or args.documentId, args.url, or args.shareId is required" });
1293
+ const hasArrays = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
1294
+ Array.isArray(args[key]) && args[key].length > 0
1295
+ );
1296
+ const hasSingle = ["query", "urlId"].some((key) =>
1297
+ typeof args[key] === "string" && args[key].trim().length > 0
1298
+ );
1299
+ if (!args.id && !args.documentId && !args.url && !args.shareId && !hasArrays && !hasSingle) {
1300
+ issues.push({ path: "args.id", message: "or args.documentId, args.url, args.shareId, or document refs are required" });
1301
+ }
1302
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
1303
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
1304
+ }
1305
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
1306
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
654
1307
  }
655
1308
  },
656
1309
  },
@@ -679,20 +1332,53 @@ export const TOOL_ARG_SCHEMAS = {
679
1332
  properties: {
680
1333
  id: { type: "string" },
681
1334
  documentId: { type: "string" },
1335
+ refs: { type: "string[]" },
1336
+ query: { type: "string" },
1337
+ queries: { type: "string[]" },
682
1338
  url: { type: "string" },
1339
+ urlId: { type: "string" },
1340
+ urlIds: { type: "string[]" },
1341
+ urls: { type: "string[]" },
683
1342
  shareId: { type: "string" },
1343
+ shareIds: { type: "string[]" },
1344
+ profile: { type: "string" },
1345
+ resolveLimit: { type: "number", min: 1 },
1346
+ minScore: { type: "number", min: 0 },
1347
+ maxAgeHours: { type: "number", min: 0 },
1348
+ refresh: { type: "boolean" },
1349
+ strict: { type: "boolean" },
1350
+ strictThreshold: { type: "number", min: 0 },
1351
+ fallbackSearch: { type: "boolean" },
1352
+ fallbackMinScore: { type: "number", min: 0 },
1353
+ fallbackLimit: { type: "number", min: 1 },
1354
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
1355
+ resolveCollectionId: { type: "string" },
1356
+ resolveConcurrency: { type: "number", min: 1 },
1357
+ resolveHydrateConcurrency: { type: "number", min: 1 },
684
1358
  outputDir: { type: "string" },
685
1359
  overwrite: { type: "boolean" },
686
1360
  concurrency: { type: "number", min: 1 },
687
1361
  maxAttempts: { type: "number", min: 1 },
688
1362
  },
689
1363
  custom(args, issues) {
690
- if (!args.id && !args.documentId && !args.url && !args.shareId) {
691
- issues.push({ path: "args.id", message: "or args.documentId, args.url, or args.shareId is required" });
1364
+ const hasArrays = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
1365
+ Array.isArray(args[key]) && args[key].length > 0
1366
+ );
1367
+ const hasSingle = ["query", "urlId"].some((key) =>
1368
+ typeof args[key] === "string" && args[key].trim().length > 0
1369
+ );
1370
+ if (!args.id && !args.documentId && !args.url && !args.shareId && !hasArrays && !hasSingle) {
1371
+ issues.push({ path: "args.id", message: "or args.documentId, args.url, args.shareId, or document refs are required" });
692
1372
  }
693
1373
  if (typeof args.concurrency === "number" && args.concurrency > 8) {
694
1374
  issues.push({ path: "args.concurrency", message: "must be <= 8" });
695
1375
  }
1376
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
1377
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
1378
+ }
1379
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
1380
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
1381
+ }
696
1382
  },
697
1383
  },
698
1384
  "documents.info": {
@@ -712,6 +1398,84 @@ export const TOOL_ARG_SCHEMAS = {
712
1398
  }
713
1399
  },
714
1400
  },
1401
+ "documents.open": {
1402
+ properties: {
1403
+ query: { type: "string" },
1404
+ id: { type: "string" },
1405
+ shareId: { type: "string" },
1406
+ urlId: { type: "string" },
1407
+ url: { type: "string" },
1408
+ profile: { type: "string" },
1409
+ limit: { type: "number", min: 1 },
1410
+ minScore: { type: "number", min: 0 },
1411
+ maxAgeHours: { type: "number", min: 0 },
1412
+ refresh: { type: "boolean" },
1413
+ strict: { type: "boolean" },
1414
+ strictThreshold: { type: "number", min: 0 },
1415
+ fallbackSearch: { type: "boolean" },
1416
+ fallbackMinScore: { type: "number", min: 0 },
1417
+ fallbackLimit: { type: "number", min: 1 },
1418
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
1419
+ collectionId: { type: "string" },
1420
+ snippetMinWords: { type: "number", min: 1 },
1421
+ snippetMaxWords: { type: "number", min: 1 },
1422
+ includePolicies: { type: "boolean" },
1423
+ view: { type: "string", enum: ["summary", "full"] },
1424
+ maxAttempts: { type: "number", min: 1 },
1425
+ },
1426
+ custom(args, issues) {
1427
+ const refs = ["query", "id", "shareId", "urlId", "url"].filter((key) => args[key]);
1428
+ if (refs.length === 0) {
1429
+ issues.push({ path: "args.query", message: "or args.id, args.shareId, args.urlId, or args.url is required" });
1430
+ }
1431
+ if (refs.length > 1) {
1432
+ issues.push({ path: "args.query", message: "provide only one of args.query, args.id, args.shareId, args.urlId, or args.url" });
1433
+ }
1434
+ },
1435
+ },
1436
+ "documents.open_batch": {
1437
+ properties: {
1438
+ refs: { type: "string[]" },
1439
+ queries: { type: "string[]" },
1440
+ ids: { type: "string[]" },
1441
+ shareIds: { type: "string[]" },
1442
+ urlIds: { type: "string[]" },
1443
+ urls: { type: "string[]" },
1444
+ profile: { type: "string" },
1445
+ limit: { type: "number", min: 1 },
1446
+ minScore: { type: "number", min: 0 },
1447
+ maxAgeHours: { type: "number", min: 0 },
1448
+ refresh: { type: "boolean" },
1449
+ strict: { type: "boolean" },
1450
+ strictThreshold: { type: "number", min: 0 },
1451
+ fallbackSearch: { type: "boolean" },
1452
+ fallbackMinScore: { type: "number", min: 0 },
1453
+ fallbackLimit: { type: "number", min: 1 },
1454
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
1455
+ collectionId: { type: "string" },
1456
+ snippetMinWords: { type: "number", min: 1 },
1457
+ snippetMaxWords: { type: "number", min: 1 },
1458
+ includePolicies: { type: "boolean" },
1459
+ view: { type: "string", enum: ["summary", "full"] },
1460
+ concurrency: { type: "number", min: 1 },
1461
+ hydrateConcurrency: { type: "number", min: 1 },
1462
+ maxAttempts: { type: "number", min: 1 },
1463
+ },
1464
+ custom(args, issues) {
1465
+ const hasRef = ["refs", "queries", "ids", "shareIds", "urlIds", "urls"].some((key) =>
1466
+ Array.isArray(args[key]) && args[key].length > 0
1467
+ );
1468
+ if (!hasRef) {
1469
+ issues.push({ path: "args.refs", message: "or args.queries, args.ids, args.shareIds, args.urlIds, or args.urls must include at least one value" });
1470
+ }
1471
+ if (typeof args.concurrency === "number" && args.concurrency > 8) {
1472
+ issues.push({ path: "args.concurrency", message: "must be <= 8" });
1473
+ }
1474
+ if (typeof args.hydrateConcurrency === "number" && args.hydrateConcurrency > 8) {
1475
+ issues.push({ path: "args.hydrateConcurrency", message: "must be <= 8" });
1476
+ }
1477
+ },
1478
+ },
715
1479
  "documents.create": {
716
1480
  properties: {
717
1481
  id: { type: "string" },
@@ -773,6 +1537,74 @@ export const TOOL_ARG_SCHEMAS = {
773
1537
  }
774
1538
  },
775
1539
  },
1540
+ "collections.open": {
1541
+ properties: {
1542
+ query: { type: "string" },
1543
+ id: { type: "string" },
1544
+ urlId: { type: "string" },
1545
+ url: { type: "string" },
1546
+ profile: { type: "string" },
1547
+ limit: { type: "number", min: 1 },
1548
+ minScore: { type: "number", min: 0 },
1549
+ maxAgeHours: { type: "number", min: 0 },
1550
+ refresh: { type: "boolean" },
1551
+ strict: { type: "boolean" },
1552
+ strictThreshold: { type: "number", min: 0 },
1553
+ fallbackSearch: { type: "boolean" },
1554
+ fallbackMinScore: { type: "number", min: 0 },
1555
+ fallbackLimit: { type: "number", min: 1 },
1556
+ includePolicies: { type: "boolean" },
1557
+ view: { type: "string", enum: ["summary", "full"] },
1558
+ maxAttempts: { type: "number", min: 1 },
1559
+ },
1560
+ custom(args, issues) {
1561
+ const refs = ["query", "id", "urlId", "url"].filter((key) => args[key]);
1562
+ if (refs.length === 0) {
1563
+ issues.push({ path: "args.query", message: "or args.id, args.urlId, or args.url is required" });
1564
+ }
1565
+ if (refs.length > 1) {
1566
+ issues.push({ path: "args.query", message: "provide only one of args.query, args.id, args.urlId, or args.url" });
1567
+ }
1568
+ },
1569
+ },
1570
+ "collections.open_batch": {
1571
+ properties: {
1572
+ refs: { type: "string[]" },
1573
+ queries: { type: "string[]" },
1574
+ ids: { type: "string[]" },
1575
+ urlIds: { type: "string[]" },
1576
+ urls: { type: "string[]" },
1577
+ profile: { type: "string" },
1578
+ limit: { type: "number", min: 1 },
1579
+ minScore: { type: "number", min: 0 },
1580
+ maxAgeHours: { type: "number", min: 0 },
1581
+ refresh: { type: "boolean" },
1582
+ strict: { type: "boolean" },
1583
+ strictThreshold: { type: "number", min: 0 },
1584
+ fallbackSearch: { type: "boolean" },
1585
+ fallbackMinScore: { type: "number", min: 0 },
1586
+ fallbackLimit: { type: "number", min: 1 },
1587
+ includePolicies: { type: "boolean" },
1588
+ view: { type: "string", enum: ["summary", "full"] },
1589
+ concurrency: { type: "number", min: 1 },
1590
+ hydrateConcurrency: { type: "number", min: 1 },
1591
+ maxAttempts: { type: "number", min: 1 },
1592
+ },
1593
+ custom(args, issues) {
1594
+ const hasRef = ["refs", "queries", "ids", "urlIds", "urls"].some((key) =>
1595
+ Array.isArray(args[key]) && args[key].length > 0
1596
+ );
1597
+ if (!hasRef) {
1598
+ issues.push({ path: "args.refs", message: "or args.queries, args.ids, args.urlIds, or args.urls must include at least one value" });
1599
+ }
1600
+ if (typeof args.concurrency === "number" && args.concurrency > 8) {
1601
+ issues.push({ path: "args.concurrency", message: "must be <= 8" });
1602
+ }
1603
+ if (typeof args.hydrateConcurrency === "number" && args.hydrateConcurrency > 8) {
1604
+ issues.push({ path: "args.hydrateConcurrency", message: "must be <= 8" });
1605
+ }
1606
+ },
1607
+ },
776
1608
  "collections.create": {
777
1609
  required: ["name"],
778
1610
  properties: {
@@ -804,6 +1636,25 @@ export const TOOL_ARG_SCHEMAS = {
804
1636
  query: { type: "string" },
805
1637
  queries: { type: "string[]" },
806
1638
  collectionId: { type: "string" },
1639
+ collectionQuery: { type: "string" },
1640
+ collectionRef: { type: "string" },
1641
+ collectionQueries: { type: "string[]" },
1642
+ collectionRefs: { type: "string[]" },
1643
+ userId: { type: "string" },
1644
+ userQuery: { type: "string" },
1645
+ userRef: { type: "string" },
1646
+ userQueries: { type: "string[]" },
1647
+ userRefs: { type: "string[]" },
1648
+ profile: { type: "string" },
1649
+ memory: { type: "boolean" },
1650
+ memoryMinScore: { type: "number", min: 0 },
1651
+ minScore: { type: "number", min: 0 },
1652
+ maxAgeHours: { type: "number", min: 0 },
1653
+ refresh: { type: "boolean" },
1654
+ fallbackSearch: { type: "boolean" },
1655
+ fallbackLimit: { type: "number", min: 1 },
1656
+ fallbackMinScore: { type: "number", min: 0 },
1657
+ resolveLimit: { type: "number", min: 1 },
807
1658
  limit: { type: "number", min: 1 },
808
1659
  strict: { type: "boolean" },
809
1660
  strictThreshold: { type: "number", min: 0 },
@@ -819,6 +1670,7 @@ export const TOOL_ARG_SCHEMAS = {
819
1670
  if (!args.query && !args.queries) {
820
1671
  issues.push({ path: "args.query", message: "or args.queries[] is required" });
821
1672
  }
1673
+ validateDocumentFilterSelectors(args, issues);
822
1674
  if (typeof args.strictThreshold === "number" && args.strictThreshold > 1) {
823
1675
  issues.push({ path: "args.strictThreshold", message: "must be <= 1" });
824
1676
  }
@@ -829,6 +1681,25 @@ export const TOOL_ARG_SCHEMAS = {
829
1681
  url: { type: "string" },
830
1682
  urls: { type: "string[]" },
831
1683
  collectionId: { type: "string" },
1684
+ collectionQuery: { type: "string" },
1685
+ collectionRef: { type: "string" },
1686
+ collectionQueries: { type: "string[]" },
1687
+ collectionRefs: { type: "string[]" },
1688
+ userId: { type: "string" },
1689
+ userQuery: { type: "string" },
1690
+ userRef: { type: "string" },
1691
+ userQueries: { type: "string[]" },
1692
+ userRefs: { type: "string[]" },
1693
+ profile: { type: "string" },
1694
+ memory: { type: "boolean" },
1695
+ memoryMinScore: { type: "number", min: 0 },
1696
+ minScore: { type: "number", min: 0 },
1697
+ maxAgeHours: { type: "number", min: 0 },
1698
+ refresh: { type: "boolean" },
1699
+ fallbackSearch: { type: "boolean" },
1700
+ fallbackLimit: { type: "number", min: 1 },
1701
+ fallbackMinScore: { type: "number", min: 0 },
1702
+ resolveLimit: { type: "number", min: 1 },
832
1703
  limit: { type: "number", min: 1 },
833
1704
  strict: { type: "boolean" },
834
1705
  strictHost: { type: "boolean" },
@@ -845,6 +1716,7 @@ export const TOOL_ARG_SCHEMAS = {
845
1716
  if (!args.url && !args.urls) {
846
1717
  issues.push({ path: "args.url", message: "or args.urls[] is required" });
847
1718
  }
1719
+ validateDocumentFilterSelectors(args, issues);
848
1720
  if (typeof args.strictThreshold === "number" && args.strictThreshold > 1) {
849
1721
  issues.push({ path: "args.strictThreshold", message: "must be <= 1" });
850
1722
  }
@@ -884,9 +1756,22 @@ export const TOOL_ARG_SCHEMAS = {
884
1756
  },
885
1757
  },
886
1758
  "collections.tree": {
887
- required: ["collectionId"],
888
1759
  properties: {
889
1760
  collectionId: { type: "string" },
1761
+ id: { type: "string" },
1762
+ query: { type: "string" },
1763
+ urlId: { type: "string" },
1764
+ url: { type: "string" },
1765
+ profile: { type: "string" },
1766
+ resolveLimit: { type: "number", min: 1 },
1767
+ minScore: { type: "number", min: 0 },
1768
+ maxAgeHours: { type: "number", min: 0 },
1769
+ refresh: { type: "boolean" },
1770
+ strict: { type: "boolean" },
1771
+ strictThreshold: { type: "number", min: 0 },
1772
+ fallbackSearch: { type: "boolean" },
1773
+ fallbackMinScore: { type: "number", min: 0 },
1774
+ fallbackLimit: { type: "number", min: 1 },
890
1775
  includeDrafts: { type: "boolean" },
891
1776
  maxDepth: { type: "number", min: 0 },
892
1777
  view: { type: "string", enum: ["summary", "full"] },
@@ -897,6 +1782,15 @@ export const TOOL_ARG_SCHEMAS = {
897
1782
  direction: { type: "string", enum: ["ASC", "DESC"] },
898
1783
  maxAttempts: { type: "number", min: 1 },
899
1784
  },
1785
+ custom(args, issues) {
1786
+ const refs = ["collectionId", "id", "query", "urlId", "url"].filter((key) => args[key]);
1787
+ if (refs.length === 0) {
1788
+ issues.push({ path: "args.collectionId", message: "or args.id, args.query, args.urlId, or args.url is required" });
1789
+ }
1790
+ if (refs.length > 1) {
1791
+ issues.push({ path: "args.collectionId", message: "provide only one of args.collectionId, args.id, args.query, args.urlId, or args.url" });
1792
+ }
1793
+ },
900
1794
  },
901
1795
  "search.expand": {
902
1796
  properties: {
@@ -910,8 +1804,25 @@ export const TOOL_ARG_SCHEMAS = {
910
1804
  concurrency: { type: "number", min: 1 },
911
1805
  hydrateConcurrency: { type: "number", min: 1 },
912
1806
  collectionId: { type: "string" },
1807
+ collectionQuery: { type: "string" },
1808
+ collectionRef: { type: "string" },
1809
+ collectionQueries: { type: "string[]" },
1810
+ collectionRefs: { type: "string[]" },
913
1811
  documentId: { type: "string" },
914
1812
  userId: { type: "string" },
1813
+ userQuery: { type: "string" },
1814
+ userRef: { type: "string" },
1815
+ userQueries: { type: "string[]" },
1816
+ userRefs: { type: "string[]" },
1817
+ profile: { type: "string" },
1818
+ resolveLimit: { type: "number", min: 1 },
1819
+ maxAgeHours: { type: "number", min: 0 },
1820
+ refresh: { type: "boolean" },
1821
+ strict: { type: "boolean" },
1822
+ strictThreshold: { type: "number", min: 0 },
1823
+ fallbackSearch: { type: "boolean" },
1824
+ fallbackMinScore: { type: "number", min: 0 },
1825
+ fallbackLimit: { type: "number", min: 1 },
915
1826
  sort: { type: "string" },
916
1827
  direction: { type: "string", enum: ["ASC", "DESC"] },
917
1828
  snippetMinWords: { type: "number", min: 1 },
@@ -925,6 +1836,7 @@ export const TOOL_ARG_SCHEMAS = {
925
1836
  if (!args.query && !args.queries) {
926
1837
  issues.push({ path: "args.query", message: "or args.queries[] is required" });
927
1838
  }
1839
+ validateDocumentFilterSelectors(args, issues);
928
1840
  },
929
1841
  },
930
1842
  "search.research": {
@@ -933,6 +1845,24 @@ export const TOOL_ARG_SCHEMAS = {
933
1845
  query: { type: "string" },
934
1846
  queries: { type: "string[]" },
935
1847
  collectionId: { type: "string" },
1848
+ collectionQuery: { type: "string" },
1849
+ collectionRef: { type: "string" },
1850
+ collectionQueries: { type: "string[]" },
1851
+ collectionRefs: { type: "string[]" },
1852
+ userId: { type: "string" },
1853
+ userQuery: { type: "string" },
1854
+ userRef: { type: "string" },
1855
+ userQueries: { type: "string[]" },
1856
+ userRefs: { type: "string[]" },
1857
+ profile: { type: "string" },
1858
+ resolveLimit: { type: "number", min: 1 },
1859
+ maxAgeHours: { type: "number", min: 0 },
1860
+ refresh: { type: "boolean" },
1861
+ strict: { type: "boolean" },
1862
+ strictThreshold: { type: "number", min: 0 },
1863
+ fallbackSearch: { type: "boolean" },
1864
+ fallbackMinScore: { type: "number", min: 0 },
1865
+ fallbackLimit: { type: "number", min: 1 },
936
1866
  limitPerQuery: { type: "number", min: 1 },
937
1867
  offset: { type: "number", min: 0 },
938
1868
  includeTitleSearch: { type: "boolean" },
@@ -968,6 +1898,7 @@ export const TOOL_ARG_SCHEMAS = {
968
1898
  if (!args.question && !args.query && !args.queries) {
969
1899
  issues.push({ path: "args.question", message: "or args.query or args.queries[] is required" });
970
1900
  }
1901
+ validateDocumentFilterSelectors(args, issues);
971
1902
  if (args.includeTitleSearch === false && args.includeSemanticSearch === false) {
972
1903
  issues.push({
973
1904
  path: "args.includeTitleSearch",
@@ -983,10 +1914,10 @@ export const TOOL_ARG_SCHEMAS = {
983
1914
  },
984
1915
  },
985
1916
  "documents.safe_update": {
986
- required: ["id", "expectedRevision"],
1917
+ required: ["expectedRevision"],
987
1918
  properties: {
988
- id: { type: "string" },
989
- expectedRevision: { type: "number", min: 0 },
1919
+ ...DOCUMENT_MUTATION_TARGET_RESOLVE_PROPERTIES,
1920
+ expectedRevision: { type: ["number", "string"], min: 0 },
990
1921
  title: { type: "string" },
991
1922
  text: { type: "string" },
992
1923
  icon: { type: "string" },
@@ -1003,24 +1934,71 @@ export const TOOL_ARG_SCHEMAS = {
1003
1934
  maxAttempts: { type: "number", min: 1 },
1004
1935
  performAction: { type: "boolean" },
1005
1936
  },
1937
+ custom: validateRequiredDocumentMutationTargetAndExpectedRevision,
1006
1938
  },
1007
1939
  "documents.diff": {
1008
- required: ["id", "proposedText"],
1940
+ required: ["proposedText"],
1009
1941
  properties: {
1010
1942
  id: { type: "string" },
1943
+ documentId: { type: "string" },
1944
+ refs: { type: "string[]" },
1945
+ query: { type: "string" },
1946
+ queries: { type: "string[]" },
1947
+ shareId: { type: "string" },
1948
+ shareIds: { type: "string[]" },
1949
+ urlId: { type: "string" },
1950
+ urlIds: { type: "string[]" },
1951
+ url: { type: "string" },
1952
+ urls: { type: "string[]" },
1953
+ profile: { type: "string" },
1954
+ resolveLimit: { type: "number", min: 1 },
1955
+ minScore: { type: "number", min: 0 },
1956
+ maxAgeHours: { type: "number", min: 0 },
1957
+ refresh: { type: "boolean" },
1958
+ strict: { type: "boolean" },
1959
+ strictThreshold: { type: "number", min: 0 },
1960
+ fallbackSearch: { type: "boolean" },
1961
+ fallbackMinScore: { type: "number", min: 0 },
1962
+ fallbackLimit: { type: "number", min: 1 },
1963
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
1964
+ resolveCollectionId: { type: "string" },
1965
+ resolveConcurrency: { type: "number", min: 1 },
1966
+ resolveHydrateConcurrency: { type: "number", min: 1 },
1011
1967
  proposedText: { type: "string" },
1012
1968
  includeFullHunks: { type: "boolean" },
1013
1969
  hunkLimit: { type: "number", min: 1 },
1014
1970
  hunkLineLimit: { type: "number", min: 1 },
1015
1971
  maxAttempts: { type: "number", min: 1 },
1016
1972
  },
1973
+ custom(args, issues) {
1974
+ const hasId = typeof args.id === "string" && args.id.trim().length > 0;
1975
+ const hasDocumentId = typeof args.documentId === "string" && args.documentId.trim().length > 0;
1976
+ const hasArrays = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
1977
+ Array.isArray(args[key]) && args[key].length > 0
1978
+ );
1979
+ const hasSingle = ["query", "shareId", "urlId", "url"].some((key) =>
1980
+ typeof args[key] === "string" && args[key].trim().length > 0
1981
+ );
1982
+ if (!hasId && !hasDocumentId && !hasArrays && !hasSingle) {
1983
+ issues.push({ path: "args.id", message: "or document refs are required" });
1984
+ }
1985
+ if (hasId && hasDocumentId) {
1986
+ issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
1987
+ }
1988
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
1989
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
1990
+ }
1991
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
1992
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
1993
+ }
1994
+ },
1017
1995
  },
1018
1996
  "documents.apply_patch": {
1019
- required: ["id", "patch"],
1997
+ required: ["patch"],
1020
1998
  properties: {
1021
- id: { type: "string" },
1999
+ ...DOCUMENT_MUTATION_TARGET_RESOLVE_PROPERTIES,
1022
2000
  patch: { type: "string" },
1023
- expectedRevision: { type: "number", min: 0 },
2001
+ expectedRevision: { type: ["number", "string"], min: 0 },
1024
2002
  mode: { type: "string", enum: ["unified", "replace"] },
1025
2003
  title: { type: "string" },
1026
2004
  view: { type: "string", enum: ["summary", "full"] },
@@ -1028,13 +2006,17 @@ export const TOOL_ARG_SCHEMAS = {
1028
2006
  maxAttempts: { type: "number", min: 1 },
1029
2007
  performAction: { type: "boolean" },
1030
2008
  },
2009
+ custom(args, issues) {
2010
+ validateRequiredDocumentMutationTargetArgs(args, issues);
2011
+ validateExpectedRevisionGuard(args, issues);
2012
+ },
1031
2013
  },
1032
2014
  "documents.apply_patch_safe": {
1033
- required: ["id", "expectedRevision", "patch"],
2015
+ required: ["expectedRevision", "patch"],
1034
2016
  properties: {
1035
- id: { type: "string" },
2017
+ ...DOCUMENT_MUTATION_TARGET_RESOLVE_PROPERTIES,
1036
2018
  patch: { type: "string" },
1037
- expectedRevision: { type: "number", min: 0 },
2019
+ expectedRevision: { type: ["number", "string"], min: 0 },
1038
2020
  mode: { type: "string", enum: ["unified", "replace"] },
1039
2021
  title: { type: "string" },
1040
2022
  view: { type: "string", enum: ["summary", "full"] },
@@ -1042,6 +2024,7 @@ export const TOOL_ARG_SCHEMAS = {
1042
2024
  maxAttempts: { type: "number", min: 1 },
1043
2025
  performAction: { type: "boolean" },
1044
2026
  },
2027
+ custom: validateRequiredDocumentMutationTargetAndExpectedRevision,
1045
2028
  },
1046
2029
  "documents.batch_update": {
1047
2030
  required: ["updates"],
@@ -1063,14 +2046,15 @@ export const TOOL_ARG_SCHEMAS = {
1063
2046
  issues.push({ path: `args.updates[${i}]`, message: "must be an object" });
1064
2047
  continue;
1065
2048
  }
1066
- if (!update.id || typeof update.id !== "string") {
1067
- issues.push({ path: `args.updates[${i}].id`, message: "is required and must be a string" });
1068
- }
2049
+ validateBatchUpdateDocumentTarget(update, issues, `args.updates[${i}]`);
1069
2050
  if (
1070
2051
  Object.prototype.hasOwnProperty.call(update, "expectedRevision") &&
1071
- !(typeof update.expectedRevision === "number" && Number.isFinite(update.expectedRevision))
2052
+ !(
2053
+ (typeof update.expectedRevision === "number" && Number.isFinite(update.expectedRevision)) ||
2054
+ (typeof update.expectedRevision === "string" && update.expectedRevision.trim().toLowerCase() === "latest")
2055
+ )
1072
2056
  ) {
1073
- issues.push({ path: `args.updates[${i}].expectedRevision`, message: "must be a number" });
2057
+ issues.push({ path: `args.updates[${i}].expectedRevision`, message: "must be a number or latest" });
1074
2058
  }
1075
2059
  if (
1076
2060
  Object.prototype.hasOwnProperty.call(update, "editMode") &&
@@ -1157,9 +2141,32 @@ export const TOOL_ARG_SCHEMAS = {
1157
2141
  },
1158
2142
  },
1159
2143
  "revisions.list": {
1160
- required: ["documentId"],
1161
2144
  properties: {
2145
+ id: { type: "string" },
1162
2146
  documentId: { type: "string" },
2147
+ refs: { type: "string[]" },
2148
+ query: { type: "string" },
2149
+ queries: { type: "string[]" },
2150
+ shareId: { type: "string" },
2151
+ shareIds: { type: "string[]" },
2152
+ urlId: { type: "string" },
2153
+ urlIds: { type: "string[]" },
2154
+ url: { type: "string" },
2155
+ urls: { type: "string[]" },
2156
+ profile: { type: "string" },
2157
+ resolveLimit: { type: "number", min: 1 },
2158
+ minScore: { type: "number", min: 0 },
2159
+ maxAgeHours: { type: "number", min: 0 },
2160
+ refresh: { type: "boolean" },
2161
+ strict: { type: "boolean" },
2162
+ strictThreshold: { type: "number", min: 0 },
2163
+ fallbackSearch: { type: "boolean" },
2164
+ fallbackMinScore: { type: "number", min: 0 },
2165
+ fallbackLimit: { type: "number", min: 1 },
2166
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
2167
+ resolveCollectionId: { type: "string" },
2168
+ resolveConcurrency: { type: "number", min: 1 },
2169
+ resolveHydrateConcurrency: { type: "number", min: 1 },
1163
2170
  limit: { type: "number", min: 1 },
1164
2171
  offset: { type: "number", min: 0 },
1165
2172
  sort: { type: "string" },
@@ -1167,19 +2174,102 @@ export const TOOL_ARG_SCHEMAS = {
1167
2174
  view: { type: "string", enum: ["summary", "full"] },
1168
2175
  maxAttempts: { type: "number", min: 1 },
1169
2176
  },
2177
+ custom(args, issues) {
2178
+ const hasId = typeof args.id === "string" && args.id.trim().length > 0;
2179
+ const hasDocumentId = typeof args.documentId === "string" && args.documentId.trim().length > 0;
2180
+ const hasArrays = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
2181
+ Array.isArray(args[key]) && args[key].length > 0
2182
+ );
2183
+ const hasSingle = ["query", "shareId", "urlId", "url"].some((key) =>
2184
+ typeof args[key] === "string" && args[key].trim().length > 0
2185
+ );
2186
+ if (!hasId && !hasDocumentId && !hasArrays && !hasSingle) {
2187
+ issues.push({ path: "args.documentId", message: "or document refs are required" });
2188
+ }
2189
+ if (hasId && hasDocumentId) {
2190
+ issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
2191
+ }
2192
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
2193
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
2194
+ }
2195
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
2196
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
2197
+ }
2198
+ },
1170
2199
  },
1171
2200
  "revisions.diff": {
1172
- required: ["id", "baseRevisionId", "targetRevisionId"],
1173
2201
  properties: {
1174
2202
  id: { type: "string" },
2203
+ documentId: { type: "string" },
2204
+ refs: { type: "string[]" },
2205
+ query: { type: "string" },
2206
+ queries: { type: "string[]" },
2207
+ shareId: { type: "string" },
2208
+ shareIds: { type: "string[]" },
2209
+ urlId: { type: "string" },
2210
+ urlIds: { type: "string[]" },
2211
+ url: { type: "string" },
2212
+ urls: { type: "string[]" },
2213
+ profile: { type: "string" },
2214
+ resolveLimit: { type: "number", min: 1 },
2215
+ minScore: { type: "number", min: 0 },
2216
+ maxAgeHours: { type: "number", min: 0 },
2217
+ refresh: { type: "boolean" },
2218
+ strict: { type: "boolean" },
2219
+ strictThreshold: { type: "number", min: 0 },
2220
+ fallbackSearch: { type: "boolean" },
2221
+ fallbackMinScore: { type: "number", min: 0 },
2222
+ fallbackLimit: { type: "number", min: 1 },
2223
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
2224
+ resolveCollectionId: { type: "string" },
2225
+ resolveConcurrency: { type: "number", min: 1 },
2226
+ resolveHydrateConcurrency: { type: "number", min: 1 },
1175
2227
  baseRevisionId: { type: "string" },
1176
2228
  targetRevisionId: { type: "string" },
2229
+ revisionPair: { type: "string", enum: ["latest"] },
2230
+ revisionLimit: { type: "number", min: 2 },
2231
+ sort: { type: "string" },
2232
+ direction: { type: "string", enum: ["ASC", "DESC"] },
1177
2233
  includeFullHunks: { type: "boolean" },
1178
2234
  hunkLimit: { type: "number", min: 1 },
1179
2235
  hunkLineLimit: { type: "number", min: 1 },
1180
2236
  view: { type: "string", enum: ["summary", "full"] },
1181
2237
  maxAttempts: { type: "number", min: 1 },
1182
2238
  },
2239
+ custom(args, issues) {
2240
+ const hasId = typeof args.id === "string" && args.id.trim().length > 0;
2241
+ const hasDocumentId = typeof args.documentId === "string" && args.documentId.trim().length > 0;
2242
+ const hasArrays = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
2243
+ Array.isArray(args[key]) && args[key].length > 0
2244
+ );
2245
+ const hasSingle = ["query", "shareId", "urlId", "url"].some((key) =>
2246
+ typeof args[key] === "string" && args[key].trim().length > 0
2247
+ );
2248
+ const hasBase = typeof args.baseRevisionId === "string" && args.baseRevisionId.trim().length > 0;
2249
+ const hasTarget = typeof args.targetRevisionId === "string" && args.targetRevisionId.trim().length > 0;
2250
+
2251
+ if (!hasId && !hasDocumentId && !hasArrays && !hasSingle) {
2252
+ issues.push({ path: "args.documentId", message: "or document refs are required" });
2253
+ }
2254
+ if (hasId && hasDocumentId) {
2255
+ issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
2256
+ }
2257
+ if (hasBase !== hasTarget) {
2258
+ issues.push({ path: hasBase ? "args.targetRevisionId" : "args.baseRevisionId", message: "must be provided with the other revision id" });
2259
+ }
2260
+ if ((hasBase || hasTarget) && args.revisionPair) {
2261
+ issues.push({ path: "args.revisionPair", message: "cannot be combined with explicit revision IDs" });
2262
+ }
2263
+ if (typeof args.revisionLimit === "number" && args.revisionLimit > 20) {
2264
+ issues.push({ path: "args.revisionLimit", message: "must be <= 20" });
2265
+ }
2266
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
2267
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
2268
+ }
2269
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
2270
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
2271
+ }
2272
+ },
1183
2273
  },
1184
2274
  "revisions.restore": {
1185
2275
  required: ["id", "revisionId"],
@@ -1206,6 +2296,31 @@ export const TOOL_ARG_SCHEMAS = {
1206
2296
  properties: {
1207
2297
  query: { type: "string" },
1208
2298
  documentId: { type: "string" },
2299
+ documentQuery: { type: "string" },
2300
+ documentQueries: { type: "string[]" },
2301
+ refs: { type: "string[]" },
2302
+ shareId: { type: "string" },
2303
+ shareIds: { type: "string[]" },
2304
+ urlId: { type: "string" },
2305
+ urlIds: { type: "string[]" },
2306
+ url: { type: "string" },
2307
+ urls: { type: "string[]" },
2308
+ profile: { type: "string" },
2309
+ resolveLimit: { type: "number", min: 1 },
2310
+ minScore: { type: "number", min: 0 },
2311
+ maxAgeHours: { type: "number", min: 0 },
2312
+ refresh: { type: "boolean" },
2313
+ strict: { type: "boolean" },
2314
+ strictThreshold: { type: "number", min: 0 },
2315
+ fallbackSearch: { type: "boolean" },
2316
+ fallbackMinScore: { type: "number", min: 0 },
2317
+ fallbackLimit: { type: "number", min: 1 },
2318
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
2319
+ resolveCollectionId: { type: "string" },
2320
+ resolveConcurrency: { type: "number", min: 1 },
2321
+ resolveHydrateConcurrency: { type: "number", min: 1 },
2322
+ snippetMinWords: { type: "number", min: 1 },
2323
+ snippetMaxWords: { type: "number", min: 1 },
1209
2324
  limit: { type: "number", min: 1 },
1210
2325
  offset: { type: "number", min: 0 },
1211
2326
  sort: { type: "string" },
@@ -1214,28 +2329,48 @@ export const TOOL_ARG_SCHEMAS = {
1214
2329
  view: { type: "string", enum: ["ids", "summary", "full"] },
1215
2330
  maxAttempts: { type: "number", min: 1 },
1216
2331
  },
2332
+ custom: validateOptionalDocumentResolveArgs,
1217
2333
  },
1218
2334
  "shares.info": {
1219
2335
  properties: {
1220
2336
  id: { type: "string" },
1221
2337
  documentId: { type: "string" },
2338
+ query: { type: "string" },
2339
+ documentQuery: { type: "string" },
2340
+ queries: { type: "string[]" },
2341
+ documentQueries: { type: "string[]" },
2342
+ refs: { type: "string[]" },
2343
+ shareId: { type: "string" },
2344
+ shareIds: { type: "string[]" },
2345
+ urlId: { type: "string" },
2346
+ urlIds: { type: "string[]" },
2347
+ url: { type: "string" },
2348
+ urls: { type: "string[]" },
2349
+ profile: { type: "string" },
2350
+ resolveLimit: { type: "number", min: 1 },
2351
+ minScore: { type: "number", min: 0 },
2352
+ maxAgeHours: { type: "number", min: 0 },
2353
+ refresh: { type: "boolean" },
2354
+ strict: { type: "boolean" },
2355
+ strictThreshold: { type: "number", min: 0 },
2356
+ fallbackSearch: { type: "boolean" },
2357
+ fallbackMinScore: { type: "number", min: 0 },
2358
+ fallbackLimit: { type: "number", min: 1 },
2359
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
2360
+ resolveCollectionId: { type: "string" },
2361
+ resolveConcurrency: { type: "number", min: 1 },
2362
+ resolveHydrateConcurrency: { type: "number", min: 1 },
2363
+ snippetMinWords: { type: "number", min: 1 },
2364
+ snippetMaxWords: { type: "number", min: 1 },
1222
2365
  includePolicies: { type: "boolean" },
1223
2366
  view: { type: "string", enum: ["summary", "full"] },
1224
2367
  maxAttempts: { type: "number", min: 1 },
1225
2368
  },
1226
- custom(args, issues) {
1227
- if (!args.id && !args.documentId) {
1228
- issues.push({ path: "args.id", message: "or args.documentId is required" });
1229
- }
1230
- if (args.id && args.documentId) {
1231
- issues.push({ path: "args.documentId", message: "cannot be combined with args.id" });
1232
- }
1233
- },
2369
+ custom: validateShareInfoSelector,
1234
2370
  },
1235
2371
  "shares.create": {
1236
- required: ["documentId"],
1237
2372
  properties: {
1238
- documentId: { type: "string" },
2373
+ ...DOCUMENT_TARGET_RESOLVE_PROPERTIES,
1239
2374
  includeChildDocuments: { type: "boolean" },
1240
2375
  published: { type: "boolean" },
1241
2376
  includePolicies: { type: "boolean" },
@@ -1243,6 +2378,7 @@ export const TOOL_ARG_SCHEMAS = {
1243
2378
  maxAttempts: { type: "number", min: 1 },
1244
2379
  performAction: { type: "boolean" },
1245
2380
  },
2381
+ custom: validateRequiredDocumentResolveArgs,
1246
2382
  },
1247
2383
  "shares.update": {
1248
2384
  required: ["id", "published"],
@@ -1267,7 +2403,12 @@ export const TOOL_ARG_SCHEMAS = {
1267
2403
  "templates.list": {
1268
2404
  properties: {
1269
2405
  collectionId: { type: "string" },
2406
+ collectionQuery: { type: "string" },
2407
+ collectionRef: { type: "string" },
2408
+ collectionQueries: { type: "string[]" },
2409
+ collectionRefs: { type: "string[]" },
1270
2410
  query: { type: "string" },
2411
+ ...PRINCIPAL_RESOLVE_OPTION_PROPERTIES,
1271
2412
  limit: { type: "number", min: 1 },
1272
2413
  offset: { type: "number", min: 0 },
1273
2414
  sort: { type: "string" },
@@ -1276,32 +2417,33 @@ export const TOOL_ARG_SCHEMAS = {
1276
2417
  view: { type: "string", enum: ["ids", "summary", "full"] },
1277
2418
  maxAttempts: { type: "number", min: 1 },
1278
2419
  },
2420
+ custom: validateOptionalCollectionFilterResolveArgs,
1279
2421
  },
1280
2422
  "templates.info": {
1281
2423
  properties: {
1282
2424
  id: { type: "string" },
1283
2425
  ids: { type: "string[]" },
2426
+ query: { type: "string" },
2427
+ ...TEMPLATE_RESOLVE_PROPERTIES,
1284
2428
  includePolicies: { type: "boolean" },
1285
2429
  concurrency: { type: "number", min: 1 },
1286
2430
  view: { type: "string", enum: ["summary", "full"] },
1287
2431
  maxAttempts: { type: "number", min: 1 },
1288
2432
  },
1289
- custom(args, issues) {
1290
- if (!args.id && !args.ids) {
1291
- issues.push({ path: "args.id", message: "or args.ids[] is required" });
1292
- }
1293
- },
2433
+ custom: validateTemplateTargetSelector,
1294
2434
  },
1295
2435
  "templates.extract_placeholders": {
1296
- required: ["id"],
1297
2436
  properties: {
1298
2437
  id: { type: "string" },
2438
+ query: { type: "string" },
2439
+ ...TEMPLATE_RESOLVE_PROPERTIES,
1299
2440
  maxAttempts: { type: "number", min: 1 },
1300
2441
  },
1301
2442
  custom(args, issues) {
1302
2443
  if (typeof args.id === "string" && args.id.trim().length === 0) {
1303
2444
  issues.push({ path: "args.id", message: "must be a non-empty string" });
1304
2445
  }
2446
+ validateTemplateTargetSelector(args, issues);
1305
2447
  },
1306
2448
  },
1307
2449
  "templates.create": {
@@ -1320,9 +2462,9 @@ export const TOOL_ARG_SCHEMAS = {
1320
2462
  },
1321
2463
  },
1322
2464
  "templates.update": {
1323
- required: ["id"],
1324
2465
  properties: {
1325
2466
  id: { type: "string" },
2467
+ ...TEMPLATE_RESOLVE_PROPERTIES,
1326
2468
  title: { type: "string" },
1327
2469
  data: { type: "object" },
1328
2470
  icon: { type: ["string", "null"] },
@@ -1334,29 +2476,38 @@ export const TOOL_ARG_SCHEMAS = {
1334
2476
  maxAttempts: { type: "number", min: 1 },
1335
2477
  performAction: { type: "boolean" },
1336
2478
  },
2479
+ custom(args, issues) {
2480
+ validateTemplateTargetSelector(args, issues, { includeQuery: false });
2481
+ },
1337
2482
  },
1338
2483
  "templates.delete": {
1339
- required: ["id"],
1340
2484
  properties: {
1341
2485
  id: { type: "string" },
2486
+ ...TEMPLATE_RESOLVE_PROPERTIES,
1342
2487
  maxAttempts: { type: "number", min: 1 },
1343
2488
  performAction: { type: "boolean" },
1344
2489
  },
2490
+ custom(args, issues) {
2491
+ validateTemplateTargetSelector(args, issues, { includeQuery: false });
2492
+ },
1345
2493
  },
1346
2494
  "templates.restore": {
1347
- required: ["id"],
1348
2495
  properties: {
1349
2496
  id: { type: "string" },
2497
+ ...TEMPLATE_RESOLVE_PROPERTIES,
1350
2498
  includePolicies: { type: "boolean" },
1351
2499
  view: { type: "string", enum: ["summary", "full"] },
1352
2500
  maxAttempts: { type: "number", min: 1 },
1353
2501
  performAction: { type: "boolean" },
1354
2502
  },
2503
+ custom(args, issues) {
2504
+ validateTemplateTargetSelector(args, issues, { includeQuery: false });
2505
+ },
1355
2506
  },
1356
2507
  "templates.duplicate": {
1357
- required: ["id"],
1358
2508
  properties: {
1359
2509
  id: { type: "string" },
2510
+ ...TEMPLATE_RESOLVE_PROPERTIES,
1360
2511
  title: { type: "string" },
1361
2512
  collectionId: { type: ["string", "null"] },
1362
2513
  includePolicies: { type: "boolean" },
@@ -1364,6 +2515,9 @@ export const TOOL_ARG_SCHEMAS = {
1364
2515
  maxAttempts: { type: "number", min: 1 },
1365
2516
  performAction: { type: "boolean" },
1366
2517
  },
2518
+ custom(args, issues) {
2519
+ validateTemplateTargetSelector(args, issues, { includeQuery: false });
2520
+ },
1367
2521
  },
1368
2522
  "documents.templatize": {
1369
2523
  required: ["id"],
@@ -1699,9 +2853,10 @@ export const TOOL_ARG_SCHEMAS = {
1699
2853
  },
1700
2854
  },
1701
2855
  "documents.create_from_template": {
1702
- required: ["templateId"],
1703
2856
  properties: {
1704
2857
  templateId: { type: "string" },
2858
+ query: { type: "string" },
2859
+ ...TEMPLATE_RESOLVE_PROPERTIES,
1705
2860
  title: { type: "string" },
1706
2861
  collectionId: { type: "string" },
1707
2862
  parentDocumentId: { type: "string" },
@@ -1717,6 +2872,7 @@ export const TOOL_ARG_SCHEMAS = {
1717
2872
  if (typeof args.templateId === "string" && args.templateId.trim().length === 0) {
1718
2873
  issues.push({ path: "args.templateId", message: "must be a non-empty string" });
1719
2874
  }
2875
+ validateTemplateTargetSelector(args, issues, { idKeys: ["templateId"] });
1720
2876
 
1721
2877
  for (const key of ["title", "collectionId", "parentDocumentId"]) {
1722
2878
  if (typeof args[key] === "string" && args[key].trim().length === 0) {
@@ -1743,6 +2899,33 @@ export const TOOL_ARG_SCHEMAS = {
1743
2899
  "comments.list": {
1744
2900
  properties: {
1745
2901
  documentId: { type: "string" },
2902
+ query: { type: "string" },
2903
+ documentQuery: { type: "string" },
2904
+ queries: { type: "string[]" },
2905
+ documentQueries: { type: "string[]" },
2906
+ refs: { type: "string[]" },
2907
+ shareId: { type: "string" },
2908
+ shareIds: { type: "string[]" },
2909
+ urlId: { type: "string" },
2910
+ urlIds: { type: "string[]" },
2911
+ url: { type: "string" },
2912
+ urls: { type: "string[]" },
2913
+ profile: { type: "string" },
2914
+ resolveLimit: { type: "number", min: 1 },
2915
+ minScore: { type: "number", min: 0 },
2916
+ maxAgeHours: { type: "number", min: 0 },
2917
+ refresh: { type: "boolean" },
2918
+ strict: { type: "boolean" },
2919
+ strictThreshold: { type: "number", min: 0 },
2920
+ fallbackSearch: { type: "boolean" },
2921
+ fallbackMinScore: { type: "number", min: 0 },
2922
+ fallbackLimit: { type: "number", min: 1 },
2923
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
2924
+ resolveCollectionId: { type: "string" },
2925
+ resolveConcurrency: { type: "number", min: 1 },
2926
+ resolveHydrateConcurrency: { type: "number", min: 1 },
2927
+ snippetMinWords: { type: "number", min: 1 },
2928
+ snippetMaxWords: { type: "number", min: 1 },
1746
2929
  collectionId: { type: "string" },
1747
2930
  parentCommentId: { type: "string" },
1748
2931
  includeAnchorText: { type: "boolean" },
@@ -1755,6 +2938,7 @@ export const TOOL_ARG_SCHEMAS = {
1755
2938
  view: { type: "string", enum: ["ids", "summary", "full"] },
1756
2939
  maxAttempts: { type: "number", min: 1 },
1757
2940
  },
2941
+ custom: validateOptionalDocumentResolveArgs,
1758
2942
  },
1759
2943
  "comments.info": {
1760
2944
  required: ["id"],
@@ -1767,10 +2951,10 @@ export const TOOL_ARG_SCHEMAS = {
1767
2951
  },
1768
2952
  },
1769
2953
  "comments.create": {
1770
- required: ["documentId"],
1771
2954
  properties: {
1772
- documentId: { type: "string" },
2955
+ ...DOCUMENT_TARGET_RESOLVE_PROPERTIES,
1773
2956
  text: { type: "string" },
2957
+ mentions: { type: "string[]" },
1774
2958
  data: { type: "object" },
1775
2959
  parentCommentId: { type: "string" },
1776
2960
  includePolicies: { type: "boolean" },
@@ -1779,8 +2963,30 @@ export const TOOL_ARG_SCHEMAS = {
1779
2963
  performAction: { type: "boolean" },
1780
2964
  },
1781
2965
  custom(args, issues) {
1782
- if (!args.text && !args.data) {
1783
- issues.push({ path: "args.text", message: "or args.data is required" });
2966
+ validateRequiredDocumentResolveArgs(args, issues);
2967
+ const hasMentions = Array.isArray(args.mentions) && args.mentions.length > 0;
2968
+ if (!args.text && !args.data && !hasMentions) {
2969
+ issues.push({ path: "args.text", message: "or args.data or args.mentions is required" });
2970
+ }
2971
+ },
2972
+ },
2973
+ "comments.post": {
2974
+ properties: {
2975
+ ...DOCUMENT_TARGET_RESOLVE_PROPERTIES,
2976
+ text: { type: "string" },
2977
+ mentions: { type: "string[]" },
2978
+ data: { type: "object" },
2979
+ parentCommentId: { type: "string" },
2980
+ includePolicies: { type: "boolean" },
2981
+ view: { type: "string", enum: ["summary", "full"] },
2982
+ maxAttempts: { type: "number", min: 1 },
2983
+ performAction: { type: "boolean" },
2984
+ },
2985
+ custom(args, issues) {
2986
+ validateRequiredDocumentResolveArgs(args, issues);
2987
+ const hasMentions = Array.isArray(args.mentions) && args.mentions.length > 0;
2988
+ if (!args.text && !args.data && !hasMentions) {
2989
+ issues.push({ path: "args.text", message: "or args.data or args.mentions is required" });
1784
2990
  }
1785
2991
  },
1786
2992
  },
@@ -1882,8 +3088,42 @@ export const TOOL_ARG_SCHEMAS = {
1882
3088
  },
1883
3089
  "comments.review_queue": {
1884
3090
  properties: {
3091
+ documentId: { type: "string" },
1885
3092
  documentIds: { type: "string[]" },
3093
+ refs: { type: "string[]" },
3094
+ query: { type: "string" },
3095
+ queries: { type: "string[]" },
3096
+ shareId: { type: "string" },
3097
+ shareIds: { type: "string[]" },
3098
+ urlId: { type: "string" },
3099
+ urlIds: { type: "string[]" },
3100
+ url: { type: "string" },
3101
+ urls: { type: "string[]" },
3102
+ profile: { type: "string" },
3103
+ resolveLimit: { type: "number", min: 1 },
3104
+ minScore: { type: "number", min: 0 },
3105
+ maxAgeHours: { type: "number", min: 0 },
3106
+ refresh: { type: "boolean" },
3107
+ strict: { type: "boolean" },
3108
+ strictThreshold: { type: "number", min: 0 },
3109
+ fallbackSearch: { type: "boolean" },
3110
+ fallbackMinScore: { type: "number", min: 0 },
3111
+ fallbackLimit: { type: "number", min: 1 },
3112
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
3113
+ resolveCollectionId: { type: "string" },
3114
+ resolveConcurrency: { type: "number", min: 1 },
3115
+ resolveHydrateConcurrency: { type: "number", min: 1 },
1886
3116
  collectionId: { type: "string" },
3117
+ collectionQuery: { type: "string" },
3118
+ collectionRefId: { type: "string" },
3119
+ collectionUrlId: { type: "string" },
3120
+ collectionUrl: { type: "string" },
3121
+ collectionResolveLimit: { type: "number", min: 1 },
3122
+ collectionMinScore: { type: "number", min: 0 },
3123
+ collectionMaxAgeHours: { type: "number", min: 0 },
3124
+ collectionStrictThreshold: { type: "number", min: 0 },
3125
+ collectionFallbackMinScore: { type: "number", min: 0 },
3126
+ collectionFallbackLimit: { type: "number", min: 1 },
1887
3127
  includeAnchorText: { type: "boolean" },
1888
3128
  includeReplies: { type: "boolean" },
1889
3129
  limitPerDocument: { type: "number", min: 1 },
@@ -1892,13 +3132,29 @@ export const TOOL_ARG_SCHEMAS = {
1892
3132
  },
1893
3133
  custom(args, issues) {
1894
3134
  const hasDocumentIds = Array.isArray(args.documentIds) && args.documentIds.length > 0;
3135
+ const hasDocumentId = typeof args.documentId === "string" && args.documentId.trim().length > 0;
3136
+ const hasDocumentArrays = ["refs", "queries", "shareIds", "urlIds", "urls"].some((key) =>
3137
+ Array.isArray(args[key]) && args[key].length > 0
3138
+ );
3139
+ const hasDocumentSingle = ["query", "shareId", "urlId", "url"].some((key) =>
3140
+ typeof args[key] === "string" && args[key].trim().length > 0
3141
+ );
1895
3142
  const hasCollectionId = typeof args.collectionId === "string" && args.collectionId.length > 0;
1896
- if (!hasDocumentIds && !hasCollectionId) {
1897
- issues.push({ path: "args.documentIds", message: "or args.collectionId is required" });
3143
+ const hasCollectionRef = ["collectionQuery", "collectionRefId", "collectionUrlId", "collectionUrl"].some((key) =>
3144
+ typeof args[key] === "string" && args[key].trim().length > 0
3145
+ );
3146
+ if (!hasDocumentIds && !hasDocumentId && !hasDocumentArrays && !hasDocumentSingle && !hasCollectionId && !hasCollectionRef) {
3147
+ issues.push({ path: "args.documentIds", message: "or document refs, args.collectionId, or collection refs are required" });
1898
3148
  }
1899
3149
  if (Array.isArray(args.documentIds) && args.documentIds.length === 0) {
1900
3150
  issues.push({ path: "args.documentIds", message: "must be a non-empty string[] when provided" });
1901
3151
  }
3152
+ if (typeof args.resolveConcurrency === "number" && args.resolveConcurrency > 8) {
3153
+ issues.push({ path: "args.resolveConcurrency", message: "must be <= 8" });
3154
+ }
3155
+ if (typeof args.resolveHydrateConcurrency === "number" && args.resolveHydrateConcurrency > 8) {
3156
+ issues.push({ path: "args.resolveHydrateConcurrency", message: "must be <= 8" });
3157
+ }
1902
3158
  },
1903
3159
  },
1904
3160
  "federated.sync_manifest": {
@@ -2068,11 +3324,46 @@ export const TOOL_ARG_SCHEMAS = {
2068
3324
  "events.list": {
2069
3325
  properties: {
2070
3326
  actorId: { type: "string" },
3327
+ userQuery: { type: "string" },
3328
+ userRef: { type: "string" },
3329
+ userQueries: { type: "string[]" },
3330
+ userRefs: { type: "string[]" },
2071
3331
  documentId: { type: "string" },
3332
+ documentQuery: { type: "string" },
3333
+ documentRef: { type: "string" },
3334
+ documentQueries: { type: "string[]" },
3335
+ documentRefs: { type: "string[]" },
3336
+ refs: { type: "string[]" },
3337
+ shareId: { type: "string" },
3338
+ shareIds: { type: "string[]" },
3339
+ urlId: { type: "string" },
3340
+ urlIds: { type: "string[]" },
3341
+ url: { type: "string" },
3342
+ urls: { type: "string[]" },
2072
3343
  collectionId: { type: "string" },
3344
+ collectionQuery: { type: "string" },
3345
+ collectionRef: { type: "string" },
3346
+ collectionQueries: { type: "string[]" },
3347
+ collectionRefs: { type: "string[]" },
2073
3348
  name: { type: "string" },
2074
3349
  auditLog: { type: "boolean" },
2075
3350
  ip: { type: "string" },
3351
+ profile: { type: "string" },
3352
+ resolveLimit: { type: "number", min: 1 },
3353
+ minScore: { type: "number", min: 0 },
3354
+ maxAgeHours: { type: "number", min: 0 },
3355
+ refresh: { type: "boolean" },
3356
+ strict: { type: "boolean" },
3357
+ strictThreshold: { type: "number", min: 0 },
3358
+ fallbackSearch: { type: "boolean" },
3359
+ fallbackMinScore: { type: "number", min: 0 },
3360
+ fallbackLimit: { type: "number", min: 1 },
3361
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
3362
+ resolveCollectionId: { type: "string" },
3363
+ resolveConcurrency: { type: "number", min: 1 },
3364
+ resolveHydrateConcurrency: { type: "number", min: 1 },
3365
+ snippetMinWords: { type: "number", min: 1 },
3366
+ snippetMaxWords: { type: "number", min: 1 },
2076
3367
  limit: { type: "number", min: 1 },
2077
3368
  offset: { type: "number", min: 0 },
2078
3369
  sort: { type: "string" },
@@ -2081,10 +3372,33 @@ export const TOOL_ARG_SCHEMAS = {
2081
3372
  view: { type: "string", enum: ["ids", "summary", "full"] },
2082
3373
  maxAttempts: { type: "number", min: 1 },
2083
3374
  },
3375
+ custom: validateEventsListResolveSelectors,
2084
3376
  },
2085
3377
  "documents.archived": {
2086
3378
  properties: {
2087
3379
  collectionId: { type: "string" },
3380
+ collectionQuery: { type: "string" },
3381
+ collectionRef: { type: "string" },
3382
+ collectionQueries: { type: "string[]" },
3383
+ collectionRefs: { type: "string[]" },
3384
+ refs: { type: "string[]" },
3385
+ urlId: { type: "string" },
3386
+ urlIds: { type: "string[]" },
3387
+ url: { type: "string" },
3388
+ urls: { type: "string[]" },
3389
+ profile: { type: "string" },
3390
+ resolveLimit: { type: "number", min: 1 },
3391
+ minScore: { type: "number", min: 0 },
3392
+ maxAgeHours: { type: "number", min: 0 },
3393
+ refresh: { type: "boolean" },
3394
+ strict: { type: "boolean" },
3395
+ strictThreshold: { type: "number", min: 0 },
3396
+ fallbackSearch: { type: "boolean" },
3397
+ fallbackMinScore: { type: "number", min: 0 },
3398
+ fallbackLimit: { type: "number", min: 1 },
3399
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
3400
+ resolveConcurrency: { type: "number", min: 1 },
3401
+ resolveHydrateConcurrency: { type: "number", min: 1 },
2088
3402
  limit: { type: "number", min: 1 },
2089
3403
  offset: { type: "number", min: 0 },
2090
3404
  sort: { type: "string" },
@@ -2093,9 +3407,33 @@ export const TOOL_ARG_SCHEMAS = {
2093
3407
  view: { type: "string", enum: ["ids", "summary", "full"] },
2094
3408
  maxAttempts: { type: "number", min: 1 },
2095
3409
  },
3410
+ custom: validateOptionalCollectionFilterResolveArgs,
2096
3411
  },
2097
3412
  "documents.deleted": {
2098
3413
  properties: {
3414
+ collectionId: { type: "string" },
3415
+ collectionQuery: { type: "string" },
3416
+ collectionRef: { type: "string" },
3417
+ collectionQueries: { type: "string[]" },
3418
+ collectionRefs: { type: "string[]" },
3419
+ refs: { type: "string[]" },
3420
+ urlId: { type: "string" },
3421
+ urlIds: { type: "string[]" },
3422
+ url: { type: "string" },
3423
+ urls: { type: "string[]" },
3424
+ profile: { type: "string" },
3425
+ resolveLimit: { type: "number", min: 1 },
3426
+ minScore: { type: "number", min: 0 },
3427
+ maxAgeHours: { type: "number", min: 0 },
3428
+ refresh: { type: "boolean" },
3429
+ strict: { type: "boolean" },
3430
+ strictThreshold: { type: "number", min: 0 },
3431
+ fallbackSearch: { type: "boolean" },
3432
+ fallbackMinScore: { type: "number", min: 0 },
3433
+ fallbackLimit: { type: "number", min: 1 },
3434
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
3435
+ resolveConcurrency: { type: "number", min: 1 },
3436
+ resolveHydrateConcurrency: { type: "number", min: 1 },
2099
3437
  limit: { type: "number", min: 1 },
2100
3438
  offset: { type: "number", min: 0 },
2101
3439
  sort: { type: "string" },
@@ -2104,6 +3442,7 @@ export const TOOL_ARG_SCHEMAS = {
2104
3442
  view: { type: "string", enum: ["ids", "summary", "full"] },
2105
3443
  maxAttempts: { type: "number", min: 1 },
2106
3444
  },
3445
+ custom: validateOptionalCollectionFilterResolveArgs,
2107
3446
  },
2108
3447
  "documents.archive": {
2109
3448
  required: ["id"],
@@ -2234,6 +3573,7 @@ export const TOOL_ARG_SCHEMAS = {
2234
3573
  id: { type: "string" },
2235
3574
  ids: { type: "string[]" },
2236
3575
  email: { type: "string" },
3576
+ ...PRINCIPAL_RESOLVE_PROPERTIES,
2237
3577
  includePolicies: { type: "boolean" },
2238
3578
  concurrency: { type: "number", min: 1 },
2239
3579
  view: { type: "string", enum: ["summary", "full"] },
@@ -2242,9 +3582,10 @@ export const TOOL_ARG_SCHEMAS = {
2242
3582
  custom(args, issues) {
2243
3583
  const hasId = typeof args.id === "string" && args.id.length > 0;
2244
3584
  const hasIds = Array.isArray(args.ids) && args.ids.length > 0;
3585
+ const hasResolvedRef = hasPrincipalResolveSelector(args);
2245
3586
 
2246
- if (!hasId && !hasIds && !args.email) {
2247
- issues.push({ path: "args.id", message: "or args.ids[] or args.email is required" });
3587
+ if (!hasId && !hasIds && !args.email && !hasResolvedRef) {
3588
+ issues.push({ path: "args.id", message: "or args.ids[], args.email, args.query, or args.refs is required" });
2248
3589
  }
2249
3590
  if (Array.isArray(args.ids) && args.ids.length === 0) {
2250
3591
  issues.push({ path: "args.ids", message: "must be a non-empty string[] when provided" });
@@ -2252,6 +3593,10 @@ export const TOOL_ARG_SCHEMAS = {
2252
3593
  if (hasId && Array.isArray(args.ids)) {
2253
3594
  issues.push({ path: "args.ids", message: "cannot be combined with args.id" });
2254
3595
  }
3596
+ if (hasResolvedRef && (hasId || hasIds || args.email)) {
3597
+ issues.push({ path: "args.query", message: "cannot be combined with args.id, args.ids, or args.email" });
3598
+ }
3599
+ validatePrincipalResolveConcurrency(args, issues);
2255
3600
  },
2256
3601
  },
2257
3602
  "users.invite": {
@@ -2318,6 +3663,7 @@ export const TOOL_ARG_SCHEMAS = {
2318
3663
  properties: {
2319
3664
  id: { type: "string" },
2320
3665
  ids: { type: "string[]" },
3666
+ ...PRINCIPAL_RESOLVE_PROPERTIES,
2321
3667
  includePolicies: { type: "boolean" },
2322
3668
  concurrency: { type: "number", min: 1 },
2323
3669
  view: { type: "string", enum: ["summary", "full"] },
@@ -2326,9 +3672,10 @@ export const TOOL_ARG_SCHEMAS = {
2326
3672
  custom(args, issues) {
2327
3673
  const hasId = typeof args.id === "string" && args.id.length > 0;
2328
3674
  const hasIds = Array.isArray(args.ids) && args.ids.length > 0;
3675
+ const hasResolvedRef = hasPrincipalResolveSelector(args);
2329
3676
 
2330
- if (!hasId && !hasIds) {
2331
- issues.push({ path: "args.id", message: "or args.ids[] is required" });
3677
+ if (!hasId && !hasIds && !hasResolvedRef) {
3678
+ issues.push({ path: "args.id", message: "or args.ids[], args.query, or args.refs is required" });
2332
3679
  }
2333
3680
  if (Array.isArray(args.ids) && args.ids.length === 0) {
2334
3681
  issues.push({ path: "args.ids", message: "must be a non-empty string[] when provided" });
@@ -2336,12 +3683,16 @@ export const TOOL_ARG_SCHEMAS = {
2336
3683
  if (hasId && Array.isArray(args.ids)) {
2337
3684
  issues.push({ path: "args.ids", message: "cannot be combined with args.id" });
2338
3685
  }
3686
+ if (hasResolvedRef && (hasId || hasIds)) {
3687
+ issues.push({ path: "args.query", message: "cannot be combined with args.id or args.ids" });
3688
+ }
3689
+ validatePrincipalResolveConcurrency(args, issues);
2339
3690
  },
2340
3691
  },
2341
3692
  "groups.memberships": {
2342
- required: ["id"],
2343
3693
  properties: {
2344
3694
  id: { type: "string" },
3695
+ ...PRINCIPAL_RESOLVE_PROPERTIES,
2345
3696
  limit: { type: "number", min: 1 },
2346
3697
  offset: { type: "number", min: 0 },
2347
3698
  sort: { type: "string" },
@@ -2350,6 +3701,17 @@ export const TOOL_ARG_SCHEMAS = {
2350
3701
  view: { type: "string", enum: ["ids", "summary", "full"] },
2351
3702
  maxAttempts: { type: "number", min: 1 },
2352
3703
  },
3704
+ custom(args, issues) {
3705
+ const hasId = hasNonEmptyString(args.id);
3706
+ const hasResolvedRef = hasPrincipalResolveSelector(args);
3707
+ if (!hasId && !hasResolvedRef) {
3708
+ issues.push({ path: "args.id", message: "or args.query or args.refs is required" });
3709
+ }
3710
+ if (hasId && hasResolvedRef) {
3711
+ issues.push({ path: "args.query", message: "cannot be combined with args.id" });
3712
+ }
3713
+ validatePrincipalResolveConcurrency(args, issues);
3714
+ },
2353
3715
  },
2354
3716
  "groups.create": {
2355
3717
  required: ["name"],
@@ -2387,27 +3749,32 @@ export const TOOL_ARG_SCHEMAS = {
2387
3749
  },
2388
3750
  },
2389
3751
  "groups.add_user": {
2390
- required: ["id", "userId"],
2391
3752
  properties: {
2392
3753
  id: { type: "string" },
3754
+ groupId: { type: "string" },
2393
3755
  userId: { type: "string" },
3756
+ ...GROUP_PRINCIPAL_RESOLVE_PROPERTIES,
3757
+ ...USER_PRINCIPAL_RESOLVE_PROPERTIES,
2394
3758
  maxAttempts: { type: "number", min: 1 },
2395
3759
  performAction: { type: "boolean" },
2396
3760
  },
3761
+ custom: validateGroupUserMutationSelector,
2397
3762
  },
2398
3763
  "groups.remove_user": {
2399
- required: ["id", "userId"],
2400
3764
  properties: {
2401
3765
  id: { type: "string" },
3766
+ groupId: { type: "string" },
2402
3767
  userId: { type: "string" },
3768
+ ...GROUP_PRINCIPAL_RESOLVE_PROPERTIES,
3769
+ ...USER_PRINCIPAL_RESOLVE_PROPERTIES,
2403
3770
  maxAttempts: { type: "number", min: 1 },
2404
3771
  performAction: { type: "boolean" },
2405
3772
  },
3773
+ custom: validateGroupUserMutationSelector,
2406
3774
  },
2407
3775
  "collections.memberships": {
2408
- required: ["id"],
2409
3776
  properties: {
2410
- id: { type: "string" },
3777
+ ...COLLECTION_ACCESS_RESOLVE_PROPERTIES,
2411
3778
  limit: { type: "number", min: 1 },
2412
3779
  offset: { type: "number", min: 0 },
2413
3780
  sort: { type: "string" },
@@ -2416,11 +3783,11 @@ export const TOOL_ARG_SCHEMAS = {
2416
3783
  view: { type: "string", enum: ["ids", "summary", "full"] },
2417
3784
  maxAttempts: { type: "number", min: 1 },
2418
3785
  },
3786
+ custom: validateCollectionAccessSelector,
2419
3787
  },
2420
3788
  "collections.group_memberships": {
2421
- required: ["id"],
2422
3789
  properties: {
2423
- id: { type: "string" },
3790
+ ...COLLECTION_ACCESS_RESOLVE_PROPERTIES,
2424
3791
  limit: { type: "number", min: 1 },
2425
3792
  offset: { type: "number", min: 0 },
2426
3793
  sort: { type: "string" },
@@ -2429,47 +3796,53 @@ export const TOOL_ARG_SCHEMAS = {
2429
3796
  view: { type: "string", enum: ["ids", "summary", "full"] },
2430
3797
  maxAttempts: { type: "number", min: 1 },
2431
3798
  },
3799
+ custom: validateCollectionAccessSelector,
2432
3800
  },
2433
3801
  "collections.add_user": {
2434
- required: ["id", "userId"],
2435
3802
  properties: {
2436
- id: { type: "string" },
3803
+ ...COLLECTION_ACCESS_RESOLVE_PROPERTIES,
2437
3804
  userId: { type: "string" },
3805
+ ...USER_PRINCIPAL_RESOLVE_PROPERTIES,
3806
+ permission: { type: "string" },
2438
3807
  maxAttempts: { type: "number", min: 1 },
2439
3808
  performAction: { type: "boolean" },
2440
3809
  },
3810
+ custom: validateCollectionUserMutationSelector,
2441
3811
  },
2442
3812
  "collections.remove_user": {
2443
- required: ["id", "userId"],
2444
3813
  properties: {
2445
- id: { type: "string" },
3814
+ ...COLLECTION_ACCESS_RESOLVE_PROPERTIES,
2446
3815
  userId: { type: "string" },
3816
+ ...USER_PRINCIPAL_RESOLVE_PROPERTIES,
2447
3817
  maxAttempts: { type: "number", min: 1 },
2448
3818
  performAction: { type: "boolean" },
2449
3819
  },
3820
+ custom: validateCollectionUserMutationSelector,
2450
3821
  },
2451
3822
  "collections.add_group": {
2452
- required: ["id", "groupId"],
2453
3823
  properties: {
2454
- id: { type: "string" },
3824
+ ...COLLECTION_ACCESS_RESOLVE_PROPERTIES,
2455
3825
  groupId: { type: "string" },
3826
+ ...GROUP_PRINCIPAL_RESOLVE_PROPERTIES,
3827
+ permission: { type: "string" },
2456
3828
  maxAttempts: { type: "number", min: 1 },
2457
3829
  performAction: { type: "boolean" },
2458
3830
  },
3831
+ custom: validateCollectionGroupMutationSelector,
2459
3832
  },
2460
3833
  "collections.remove_group": {
2461
- required: ["id", "groupId"],
2462
3834
  properties: {
2463
- id: { type: "string" },
3835
+ ...COLLECTION_ACCESS_RESOLVE_PROPERTIES,
2464
3836
  groupId: { type: "string" },
3837
+ ...GROUP_PRINCIPAL_RESOLVE_PROPERTIES,
2465
3838
  maxAttempts: { type: "number", min: 1 },
2466
3839
  performAction: { type: "boolean" },
2467
3840
  },
3841
+ custom: validateCollectionGroupMutationSelector,
2468
3842
  },
2469
3843
  "documents.memberships": {
2470
- required: ["id"],
2471
3844
  properties: {
2472
- id: { type: "string" },
3845
+ ...DOCUMENT_ACCESS_RESOLVE_PROPERTIES,
2473
3846
  limit: { type: "number", min: 1 },
2474
3847
  offset: { type: "number", min: 0 },
2475
3848
  sort: { type: "string" },
@@ -2478,11 +3851,11 @@ export const TOOL_ARG_SCHEMAS = {
2478
3851
  view: { type: "string", enum: ["ids", "summary", "full"] },
2479
3852
  maxAttempts: { type: "number", min: 1 },
2480
3853
  },
3854
+ custom: validateDocumentAccessSelector,
2481
3855
  },
2482
3856
  "documents.users": {
2483
- required: ["id"],
2484
3857
  properties: {
2485
- id: { type: "string" },
3858
+ ...DOCUMENT_ACCESS_RESOLVE_PROPERTIES,
2486
3859
  limit: { type: "number", min: 1 },
2487
3860
  offset: { type: "number", min: 0 },
2488
3861
  sort: { type: "string" },
@@ -2491,11 +3864,11 @@ export const TOOL_ARG_SCHEMAS = {
2491
3864
  view: { type: "string", enum: ["ids", "summary", "full"] },
2492
3865
  maxAttempts: { type: "number", min: 1 },
2493
3866
  },
3867
+ custom: validateDocumentAccessSelector,
2494
3868
  },
2495
3869
  "documents.group_memberships": {
2496
- required: ["id"],
2497
3870
  properties: {
2498
- id: { type: "string" },
3871
+ ...DOCUMENT_ACCESS_RESOLVE_PROPERTIES,
2499
3872
  limit: { type: "number", min: 1 },
2500
3873
  offset: { type: "number", min: 0 },
2501
3874
  sort: { type: "string" },
@@ -2504,56 +3877,102 @@ export const TOOL_ARG_SCHEMAS = {
2504
3877
  view: { type: "string", enum: ["ids", "summary", "full"] },
2505
3878
  maxAttempts: { type: "number", min: 1 },
2506
3879
  },
3880
+ custom: validateDocumentAccessSelector,
2507
3881
  },
2508
3882
  "documents.add_user": {
2509
- required: ["id", "userId"],
2510
3883
  properties: {
2511
- id: { type: "string" },
3884
+ ...DOCUMENT_ACCESS_RESOLVE_PROPERTIES,
2512
3885
  userId: { type: "string" },
3886
+ ...USER_PRINCIPAL_RESOLVE_PROPERTIES,
3887
+ permission: { type: "string" },
2513
3888
  maxAttempts: { type: "number", min: 1 },
2514
3889
  performAction: { type: "boolean" },
2515
3890
  },
3891
+ custom: validateDocumentUserMutationSelector,
2516
3892
  },
2517
3893
  "documents.remove_user": {
2518
- required: ["id", "userId"],
2519
3894
  properties: {
2520
- id: { type: "string" },
3895
+ ...DOCUMENT_ACCESS_RESOLVE_PROPERTIES,
2521
3896
  userId: { type: "string" },
3897
+ ...USER_PRINCIPAL_RESOLVE_PROPERTIES,
2522
3898
  maxAttempts: { type: "number", min: 1 },
2523
3899
  performAction: { type: "boolean" },
2524
3900
  },
3901
+ custom: validateDocumentUserMutationSelector,
2525
3902
  },
2526
3903
  "documents.add_group": {
2527
- required: ["id", "groupId"],
2528
3904
  properties: {
2529
- id: { type: "string" },
3905
+ ...DOCUMENT_ACCESS_RESOLVE_PROPERTIES,
2530
3906
  groupId: { type: "string" },
3907
+ ...GROUP_PRINCIPAL_RESOLVE_PROPERTIES,
3908
+ permission: { type: "string" },
2531
3909
  maxAttempts: { type: "number", min: 1 },
2532
3910
  performAction: { type: "boolean" },
2533
3911
  },
3912
+ custom: validateDocumentGroupMutationSelector,
2534
3913
  },
2535
3914
  "documents.remove_group": {
2536
- required: ["id", "groupId"],
2537
3915
  properties: {
2538
- id: { type: "string" },
3916
+ ...DOCUMENT_ACCESS_RESOLVE_PROPERTIES,
2539
3917
  groupId: { type: "string" },
3918
+ ...GROUP_PRINCIPAL_RESOLVE_PROPERTIES,
2540
3919
  maxAttempts: { type: "number", min: 1 },
2541
3920
  performAction: { type: "boolean" },
2542
3921
  },
3922
+ custom: validateDocumentGroupMutationSelector,
2543
3923
  },
2544
3924
  "documents.answer": {
2545
3925
  properties: {
2546
3926
  question: { type: "string" },
2547
3927
  query: { type: "string" },
2548
- collectionId: { type: "string" },
3928
+ id: { type: "string" },
2549
3929
  documentId: { type: "string" },
3930
+ documentQuery: { type: "string" },
3931
+ documentRef: { type: "string" },
3932
+ documentQueries: { type: "string[]" },
3933
+ documentRefs: { type: "string[]" },
3934
+ refs: { type: "string[]" },
3935
+ shareId: { type: "string" },
3936
+ shareIds: { type: "string[]" },
3937
+ urlId: { type: "string" },
3938
+ urlIds: { type: "string[]" },
3939
+ url: { type: "string" },
3940
+ urls: { type: "string[]" },
3941
+ collectionId: { type: "string" },
3942
+ collectionQuery: { type: "string" },
3943
+ collectionRef: { type: "string" },
3944
+ collectionQueries: { type: "string[]" },
3945
+ collectionRefs: { type: "string[]" },
2550
3946
  userId: { type: "string" },
3947
+ userQuery: { type: "string" },
3948
+ userRef: { type: "string" },
3949
+ userQueries: { type: "string[]" },
3950
+ userRefs: { type: "string[]" },
3951
+ profile: { type: "string" },
3952
+ resolveLimit: { type: "number", min: 1 },
3953
+ minScore: { type: "number", min: 0 },
3954
+ maxAgeHours: { type: "number", min: 0 },
3955
+ refresh: { type: "boolean" },
3956
+ strict: { type: "boolean" },
3957
+ strictThreshold: { type: "number", min: 0 },
3958
+ fallbackSearch: { type: "boolean" },
3959
+ fallbackMinScore: { type: "number", min: 0 },
3960
+ fallbackLimit: { type: "number", min: 1 },
3961
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
3962
+ resolveCollectionId: { type: "string" },
3963
+ resolveConcurrency: { type: "number", min: 1 },
3964
+ resolveHydrateConcurrency: { type: "number", min: 1 },
3965
+ hydrateConcurrency: { type: "number", min: 1 },
2551
3966
  statusFilter: { type: ["string", "string[]"] },
2552
3967
  dateFilter: { type: "string", enum: ["day", "week", "month", "year"] },
2553
3968
  includePolicies: { type: "boolean" },
2554
3969
  includeEvidenceDocs: { type: "boolean" },
2555
3970
  limit: { type: "number", min: 1 },
2556
3971
  view: { type: "string", enum: ["summary", "full"] },
3972
+ contextChars: { type: "number", min: 1 },
3973
+ excerptChars: { type: "number", min: 1 },
3974
+ snippetMinWords: { type: "number", min: 1 },
3975
+ snippetMaxWords: { type: "number", min: 1 },
2557
3976
  maxAttempts: { type: "number", min: 1 },
2558
3977
  },
2559
3978
  custom(args, issues) {
@@ -2561,6 +3980,7 @@ export const TOOL_ARG_SCHEMAS = {
2561
3980
  if (typeof selected !== "string" || selected.trim().length === 0) {
2562
3981
  issues.push({ path: "args.question", message: "or args.query is required and must be non-empty" });
2563
3982
  }
3983
+ validateAnswerScopeSelectors(args, issues);
2564
3984
  },
2565
3985
  },
2566
3986
  "documents.answer_batch": {
@@ -2568,15 +3988,54 @@ export const TOOL_ARG_SCHEMAS = {
2568
3988
  question: { type: "string" },
2569
3989
  query: { type: "string" },
2570
3990
  questions: { type: "array" },
2571
- collectionId: { type: "string" },
3991
+ id: { type: "string" },
2572
3992
  documentId: { type: "string" },
3993
+ documentQuery: { type: "string" },
3994
+ documentRef: { type: "string" },
3995
+ documentQueries: { type: "string[]" },
3996
+ documentRefs: { type: "string[]" },
3997
+ refs: { type: "string[]" },
3998
+ shareId: { type: "string" },
3999
+ shareIds: { type: "string[]" },
4000
+ urlId: { type: "string" },
4001
+ urlIds: { type: "string[]" },
4002
+ url: { type: "string" },
4003
+ urls: { type: "string[]" },
4004
+ collectionId: { type: "string" },
4005
+ collectionQuery: { type: "string" },
4006
+ collectionRef: { type: "string" },
4007
+ collectionQueries: { type: "string[]" },
4008
+ collectionRefs: { type: "string[]" },
2573
4009
  userId: { type: "string" },
4010
+ userQuery: { type: "string" },
4011
+ userRef: { type: "string" },
4012
+ userQueries: { type: "string[]" },
4013
+ userRefs: { type: "string[]" },
4014
+ profile: { type: "string" },
4015
+ resolveLimit: { type: "number", min: 1 },
4016
+ minScore: { type: "number", min: 0 },
4017
+ maxAgeHours: { type: "number", min: 0 },
4018
+ refresh: { type: "boolean" },
4019
+ strict: { type: "boolean" },
4020
+ strictThreshold: { type: "number", min: 0 },
4021
+ fallbackSearch: { type: "boolean" },
4022
+ fallbackMinScore: { type: "number", min: 0 },
4023
+ fallbackLimit: { type: "number", min: 1 },
4024
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
4025
+ resolveCollectionId: { type: "string" },
4026
+ resolveConcurrency: { type: "number", min: 1 },
4027
+ resolveHydrateConcurrency: { type: "number", min: 1 },
4028
+ hydrateConcurrency: { type: "number", min: 1 },
2574
4029
  statusFilter: { type: ["string", "string[]"] },
2575
4030
  dateFilter: { type: "string", enum: ["day", "week", "month", "year"] },
2576
4031
  includePolicies: { type: "boolean" },
2577
4032
  includeEvidenceDocs: { type: "boolean" },
2578
4033
  limit: { type: "number", min: 1 },
2579
4034
  view: { type: "string", enum: ["summary", "full"] },
4035
+ contextChars: { type: "number", min: 1 },
4036
+ excerptChars: { type: "number", min: 1 },
4037
+ snippetMinWords: { type: "number", min: 1 },
4038
+ snippetMaxWords: { type: "number", min: 1 },
2580
4039
  concurrency: { type: "number", min: 1 },
2581
4040
  maxAttempts: { type: "number", min: 1 },
2582
4041
  },
@@ -2593,6 +4052,8 @@ export const TOOL_ARG_SCHEMAS = {
2593
4052
  issues.push({ path: "args.questions", message: "or args.question or args.query is required" });
2594
4053
  }
2595
4054
 
4055
+ validateAnswerScopeSelectors(args, issues);
4056
+
2596
4057
  if (args.questions === undefined) {
2597
4058
  return;
2598
4059
  }
@@ -2628,6 +4089,123 @@ export const TOOL_ARG_SCHEMAS = {
2628
4089
  includeRaw: { type: "boolean" },
2629
4090
  },
2630
4091
  },
4092
+ "memory.lookup": {
4093
+ properties: {
4094
+ query: { type: "string" },
4095
+ id: { type: "string" },
4096
+ urlId: { type: "string" },
4097
+ url: { type: "string" },
4098
+ type: { type: "string", enum: MEMORY_ENTITY_TYPES },
4099
+ profile: { type: "string" },
4100
+ limit: { type: "number", min: 1 },
4101
+ minScore: { type: "number", min: 0 },
4102
+ maxAgeHours: { type: "number", min: 0 },
4103
+ },
4104
+ custom(args, issues) {
4105
+ if (!args.query && !args.id && !args.urlId && !args.url) {
4106
+ issues.push({ path: "args.query", message: "or args.id, args.urlId, or args.url is required" });
4107
+ }
4108
+ },
4109
+ },
4110
+ "memory.resolve": {
4111
+ properties: {
4112
+ query: { type: "string" },
4113
+ id: { type: "string" },
4114
+ urlId: { type: "string" },
4115
+ url: { type: "string" },
4116
+ type: { type: "string", enum: MEMORY_ENTITY_TYPES },
4117
+ profile: { type: "string" },
4118
+ limit: { type: "number", min: 1 },
4119
+ minScore: { type: "number", min: 0 },
4120
+ maxAgeHours: { type: "number", min: 0 },
4121
+ refresh: { type: "boolean" },
4122
+ hydrateLimit: { type: "number", min: 1 },
4123
+ fallbackSearch: { type: "boolean" },
4124
+ fallbackMinScore: { type: "number", min: 0 },
4125
+ fallbackLimit: { type: "number", min: 1 },
4126
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
4127
+ collectionId: { type: "string" },
4128
+ snippetMinWords: { type: "number", min: 1 },
4129
+ snippetMaxWords: { type: "number", min: 1 },
4130
+ view: { type: "string", enum: ["ids", "summary", "full"] },
4131
+ maxAttempts: { type: "number", min: 1 },
4132
+ },
4133
+ custom(args, issues) {
4134
+ if (!args.query && !args.id && !args.urlId && !args.url) {
4135
+ issues.push({ path: "args.query", message: "or args.id, args.urlId, or args.url is required" });
4136
+ }
4137
+ },
4138
+ },
4139
+ "memory.resolve_batch": {
4140
+ properties: {
4141
+ queries: { type: "string[]" },
4142
+ ids: { type: "string[]" },
4143
+ urlIds: { type: "string[]" },
4144
+ urls: { type: "string[]" },
4145
+ type: { type: "string", enum: MEMORY_ENTITY_TYPES },
4146
+ profile: { type: "string" },
4147
+ limit: { type: "number", min: 1 },
4148
+ minScore: { type: "number", min: 0 },
4149
+ maxAgeHours: { type: "number", min: 0 },
4150
+ refresh: { type: "boolean" },
4151
+ hydrateLimit: { type: "number", min: 1 },
4152
+ fallbackSearch: { type: "boolean" },
4153
+ fallbackMinScore: { type: "number", min: 0 },
4154
+ fallbackLimit: { type: "number", min: 1 },
4155
+ fallbackMode: { type: "string", enum: ["titles", "semantic", "both"] },
4156
+ collectionId: { type: "string" },
4157
+ snippetMinWords: { type: "number", min: 1 },
4158
+ snippetMaxWords: { type: "number", min: 1 },
4159
+ view: { type: "string", enum: ["ids", "summary", "full"] },
4160
+ concurrency: { type: "number", min: 1 },
4161
+ hydrateConcurrency: { type: "number", min: 1 },
4162
+ maxAttempts: { type: "number", min: 1 },
4163
+ },
4164
+ custom(args, issues) {
4165
+ const hasRef = ["queries", "ids", "urlIds", "urls"].some((key) =>
4166
+ Array.isArray(args[key]) && args[key].length > 0
4167
+ );
4168
+ if (!hasRef) {
4169
+ issues.push({ path: "args.queries", message: "or args.ids, args.urlIds, or args.urls must include at least one value" });
4170
+ }
4171
+ },
4172
+ },
4173
+ "memory.recent": {
4174
+ properties: {
4175
+ type: { type: "string", enum: MEMORY_ENTITY_TYPES },
4176
+ profile: { type: "string" },
4177
+ limit: { type: "number", min: 1 },
4178
+ maxAgeHours: { type: "number", min: 0 },
4179
+ includeDeleted: { type: "boolean" },
4180
+ },
4181
+ },
4182
+ "memory.remember": {
4183
+ required: ["type", "id"],
4184
+ properties: {
4185
+ type: { type: "string", enum: MEMORY_ENTITY_TYPES },
4186
+ id: { type: "string" },
4187
+ title: { type: "string" },
4188
+ name: { type: "string" },
4189
+ email: { type: "string" },
4190
+ urlId: { type: "string" },
4191
+ url: { type: "string" },
4192
+ aliases: { type: "string[]" },
4193
+ query: { type: "string" },
4194
+ queries: { type: "string[]" },
4195
+ profile: { type: "string" },
4196
+ performAction: { type: "boolean" },
4197
+ },
4198
+ },
4199
+ "memory.stats": {
4200
+ properties: {},
4201
+ },
4202
+ "memory.clear": {
4203
+ properties: {
4204
+ profile: { type: "string" },
4205
+ allProfiles: { type: "boolean" },
4206
+ performAction: { type: "boolean" },
4207
+ },
4208
+ },
2631
4209
  "documents.cleanup_test": {
2632
4210
  properties: {
2633
4211
  markerPrefix: { type: "string" },