@vectros-ai/mcp-server 0.7.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/server.ts
4
4
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
5
 
6
- // ../../node_modules/@vectros-ai/sdk/dist/index.mjs
6
+ // node_modules/@vectros-ai/sdk/dist/index.mjs
7
7
  var __defProp = Object.defineProperty;
8
8
  var __export = (target, all) => {
9
9
  for (var name in all)
@@ -18,7 +18,6 @@ __export(api_exports, {
18
18
  BatchWriteRequest: () => BatchWriteRequest,
19
19
  BatchWriteResult: () => BatchWriteResult,
20
20
  ChatMessage: () => ChatMessage,
21
- ClientRequest: () => ClientRequest,
22
21
  ConflictError: () => ConflictError,
23
22
  ContentDeltaEvent: () => ContentDeltaEvent,
24
23
  ContentTooLargeError: () => ContentTooLargeError,
@@ -27,6 +26,7 @@ __export(api_exports, {
27
26
  DocumentRequest: () => DocumentRequest,
28
27
  DocumentResponse: () => DocumentResponse,
29
28
  DoneEvent: () => DoneEvent,
29
+ EntityRequest: () => EntityRequest,
30
30
  ErasureCertificate: () => ErasureCertificate,
31
31
  ErasureRequest: () => ErasureRequest,
32
32
  ErasureRequestResponse: () => ErasureRequestResponse,
@@ -39,15 +39,13 @@ __export(api_exports, {
39
39
  ForbiddenError: () => ForbiddenError,
40
40
  IdentityLookupRequest: () => IdentityLookupRequest,
41
41
  InternalServerError: () => InternalServerError,
42
- ListClientsRequestOrder: () => ListClientsRequestOrder,
43
- ListOrgsRequestOrder: () => ListOrgsRequestOrder,
42
+ ListEntitiesRequestOrder: () => ListEntitiesRequestOrder,
44
43
  ListUsersRequestOrder: () => ListUsersRequestOrder,
45
44
  LookupDocumentsRequestOrder: () => LookupDocumentsRequestOrder,
46
45
  LookupRecordsRequestOrder: () => LookupRecordsRequestOrder,
47
46
  ModelDataVersionResponse: () => ModelDataVersionResponse,
48
47
  NotFoundError: () => NotFoundError,
49
48
  NotImplementedError: () => NotImplementedError,
50
- OrgRequest: () => OrgRequest,
51
49
  PaymentRequiredError: () => PaymentRequiredError,
52
50
  PingResponse: () => PingResponse,
53
51
  RagSearch: () => RagSearch,
@@ -288,11 +286,6 @@ var UnauthorizedError = class extends VectrosError {
288
286
  var auth_exports = {};
289
287
  var ErasureRequest;
290
288
  ((ErasureRequest2) => {
291
- ErasureRequest2.SubjectType = {
292
- User: "user",
293
- Client: "client",
294
- Org: "org"
295
- };
296
289
  ErasureRequest2.AuditDisposition = {
297
290
  RetainRedacted: "retain-redacted",
298
291
  Purge: "purge"
@@ -304,11 +297,6 @@ var ExportRequest;
304
297
  Tenant: "tenant",
305
298
  Subject: "subject"
306
299
  };
307
- ExportRequest2.SubjectType = {
308
- User: "user",
309
- Client: "client",
310
- Org: "org"
311
- };
312
300
  ExportRequest2.Format = {
313
301
  Ndjson: "ndjson"
314
302
  };
@@ -347,15 +335,10 @@ var LookupDocumentsRequestOrder = {
347
335
  var folders_exports = {};
348
336
  var identity_exports = {};
349
337
  __export(identity_exports, {
350
- ListClientsRequestOrder: () => ListClientsRequestOrder,
351
- ListOrgsRequestOrder: () => ListOrgsRequestOrder,
338
+ ListEntitiesRequestOrder: () => ListEntitiesRequestOrder,
352
339
  ListUsersRequestOrder: () => ListUsersRequestOrder
353
340
  });
354
- var ListClientsRequestOrder = {
355
- Asc: "asc",
356
- Desc: "desc"
357
- };
358
- var ListOrgsRequestOrder = {
341
+ var ListEntitiesRequestOrder = {
359
342
  Asc: "asc",
360
343
  Desc: "desc"
361
344
  };
@@ -454,13 +437,6 @@ var ChatMessage;
454
437
  Assistant: "assistant"
455
438
  };
456
439
  })(ChatMessage || (ChatMessage = {}));
457
- var ClientRequest;
458
- ((ClientRequest2) => {
459
- ClientRequest2.Status = {
460
- Active: "ACTIVE",
461
- Suspended: "SUSPENDED"
462
- };
463
- })(ClientRequest || (ClientRequest = {}));
464
440
  var ContentDeltaEvent;
465
441
  ((ContentDeltaEvent2) => {
466
442
  ContentDeltaEvent2.Event = {
@@ -515,6 +491,13 @@ var DoneEvent;
515
491
  Done: "done"
516
492
  };
517
493
  })(DoneEvent || (DoneEvent = {}));
494
+ var EntityRequest;
495
+ ((EntityRequest2) => {
496
+ EntityRequest2.Status = {
497
+ Active: "ACTIVE",
498
+ Suspended: "SUSPENDED"
499
+ };
500
+ })(EntityRequest || (EntityRequest = {}));
518
501
  var ErasureCertificate;
519
502
  ((ErasureCertificate2) => {
520
503
  ErasureCertificate2.AuditDisposition = {
@@ -530,11 +513,6 @@ var ErasureRequestResponse;
530
513
  Completed: "completed",
531
514
  Failed: "failed"
532
515
  };
533
- ErasureRequestResponse2.SubjectType = {
534
- User: "user",
535
- Client: "client",
536
- Org: "org"
537
- };
538
516
  })(ErasureRequestResponse || (ErasureRequestResponse = {}));
539
517
  var ErrorEvent;
540
518
  ((ErrorEvent2) => {
@@ -560,11 +538,6 @@ var ExportRequestResponse;
560
538
  Tenant: "tenant",
561
539
  Subject: "subject"
562
540
  };
563
- ExportRequestResponse2.SubjectType = {
564
- User: "user",
565
- Client: "client",
566
- Org: "org"
567
- };
568
541
  })(ExportRequestResponse || (ExportRequestResponse = {}));
569
542
  var FieldDef;
570
543
  ((FieldDef2) => {
@@ -578,13 +551,6 @@ var FieldDef;
578
551
  Object: "object",
579
552
  Reference: "reference"
580
553
  };
581
- FieldDef2.TargetSurface = {
582
- Record: "record",
583
- Document: "document",
584
- User: "user",
585
- Org: "org",
586
- Client: "client"
587
- };
588
554
  })(FieldDef || (FieldDef = {}));
589
555
  var IdentityLookupRequest;
590
556
  ((IdentityLookupRequest2) => {
@@ -601,13 +567,6 @@ var ModelDataVersionResponse;
601
567
  Delete: "DELETE"
602
568
  };
603
569
  })(ModelDataVersionResponse || (ModelDataVersionResponse = {}));
604
- var OrgRequest;
605
- ((OrgRequest2) => {
606
- OrgRequest2.Status = {
607
- Active: "ACTIVE",
608
- Suspended: "SUSPENDED"
609
- };
610
- })(OrgRequest || (OrgRequest = {}));
611
570
  var PingResponse;
612
571
  ((PingResponse2) => {
613
572
  PingResponse2.Environment = {
@@ -637,11 +596,6 @@ var RagSearch;
637
596
  })(RagSearch || (RagSearch = {}));
638
597
  var ReadAccessLogResponse;
639
598
  ((ReadAccessLogResponse2) => {
640
- ReadAccessLogResponse2.SubjectType = {
641
- User: "user",
642
- Client: "client",
643
- Org: "org"
644
- };
645
599
  ReadAccessLogResponse2.Action = {
646
600
  Read: "read",
647
601
  List: "list",
@@ -652,6 +606,10 @@ var ReadAccessLogResponse;
652
606
  })(ReadAccessLogResponse || (ReadAccessLogResponse = {}));
653
607
  var RecordRequest;
654
608
  ((RecordRequest2) => {
609
+ RecordRequest2.Status = {
610
+ Active: "ACTIVE",
611
+ Archived: "ARCHIVED"
612
+ };
655
613
  RecordRequest2.IndexMode = {
656
614
  Hybrid: "HYBRID",
657
615
  Semantic: "SEMANTIC",
@@ -661,6 +619,10 @@ var RecordRequest;
661
619
  })(RecordRequest || (RecordRequest = {}));
662
620
  var RecordResponse;
663
621
  ((RecordResponse2) => {
622
+ RecordResponse2.Status = {
623
+ Active: "ACTIVE",
624
+ Archived: "ARCHIVED"
625
+ };
664
626
  RecordResponse2.IndexStatus = {
665
627
  PendingIndex: "PENDING_INDEX",
666
628
  Indexed: "INDEXED",
@@ -703,8 +665,7 @@ var SchemaRequest;
703
665
  Record: "record",
704
666
  Document: "document",
705
667
  User: "user",
706
- Org: "org",
707
- Client: "client"
668
+ Entity: "entity"
708
669
  };
709
670
  })(AllowedSurfaces = SchemaRequest2.AllowedSurfaces || (SchemaRequest2.AllowedSurfaces = {}));
710
671
  })(SchemaRequest || (SchemaRequest = {}));
@@ -727,8 +688,7 @@ var SchemaResponse;
727
688
  Record: "record",
728
689
  Document: "document",
729
690
  User: "user",
730
- Org: "org",
731
- Client: "client"
691
+ Entity: "entity"
732
692
  };
733
693
  })(AllowedSurfaces = SchemaResponse2.AllowedSurfaces || (SchemaResponse2.AllowedSurfaces = {}));
734
694
  })(SchemaResponse || (SchemaResponse = {}));
@@ -2283,7 +2243,7 @@ function withNoOpAuthProvider(options) {
2283
2243
  authProvider: new NoOpAuthProvider()
2284
2244
  };
2285
2245
  }
2286
- function handleNonStatusCodeError(error, rawResponse, method, path) {
2246
+ function handleNonStatusCodeError(error, rawResponse, method, path2) {
2287
2247
  switch (error.reason) {
2288
2248
  case "non-json":
2289
2249
  throw new VectrosError({
@@ -2297,7 +2257,7 @@ function handleNonStatusCodeError(error, rawResponse, method, path) {
2297
2257
  rawResponse
2298
2258
  });
2299
2259
  case "timeout":
2300
- throw new VectrosTimeoutError(`Timeout exceeded when calling ${method} ${path}.`, {
2260
+ throw new VectrosTimeoutError(`Timeout exceeded when calling ${method} ${path2}.`, {
2301
2261
  cause: error.cause
2302
2262
  });
2303
2263
  case "unknown":
@@ -2369,7 +2329,7 @@ var AuthClient = class {
2369
2329
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/auth/jwks");
2370
2330
  }
2371
2331
  /**
2372
- * Returns a page of per-subject PHI read-access rows: who read which subject's PHI, when, against which record, and whether any sensitive value was actually revealed in plaintext. Metadata only — never the PHI itself. This is the disclosure-accounting surface from which a covered entity derives its HIPAA §164.528 accounting of disclosures. Provide at least one query axis: a subject (`subjectType` + `subjectId`, plus optional `clientId`) within a `contextId` for the primary accounting query; `resourceId` within a `contextId` for 'who read this record'; `callerKeyId` for 'what did this credential read' (account-wide forensic); or `contextId` alone to enumerate a whole context. `from`/`to` bound the time window. Results are scoped to your account, derived from your token — never from input. Requires the `access-log:r` scope.
2332
+ * Returns a page of per-subject PHI read-access rows: who read which subject's PHI, when, against which record, and whether any sensitive value was actually revealed in plaintext. Metadata only — never the PHI itself. This is the disclosure-accounting surface from which a covered entity derives its HIPAA §164.528 accounting of disclosures. Provide at least one query axis: a subject (`subjectType` + `subjectId`) within a `contextId` for the primary accounting query; `resourceId` within a `contextId` for 'who read this record'; `callerKeyId` for 'what did this credential read' (account-wide forensic); or `contextId` alone to enumerate a whole context. `from`/`to` bound the time window. Results are scoped to your account, derived from your token — never from input. Requires the `access-log:r` scope.
2373
2333
  *
2374
2334
  * @param {Vectros.GetAccessLogRequest} request
2375
2335
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -2382,7 +2342,6 @@ var AuthClient = class {
2382
2342
  * subjectType: "user",
2383
2343
  * subjectId: "user_abc123",
2384
2344
  * contextId: "ctx_intake",
2385
- * clientId: "client_xyz789",
2386
2345
  * action: "read",
2387
2346
  * callerKeyId: "key_abc123",
2388
2347
  * resourceType: "intake_form",
@@ -2397,7 +2356,6 @@ var AuthClient = class {
2397
2356
  subjectType,
2398
2357
  subjectId,
2399
2358
  contextId,
2400
- clientId,
2401
2359
  from: from_,
2402
2360
  to,
2403
2361
  action,
@@ -2412,7 +2370,6 @@ var AuthClient = class {
2412
2370
  subjectType,
2413
2371
  subjectId,
2414
2372
  contextId,
2415
- clientId,
2416
2373
  from: from_,
2417
2374
  to,
2418
2375
  action,
@@ -2846,7 +2803,7 @@ var AuthClient = class {
2846
2803
  );
2847
2804
  }
2848
2805
  /**
2849
- * Creates a new access profile under the given app context. This call is idempotent by `principalId`: if a profile with the same `principalId` already exists, the existing profile is returned (with status 200) instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing profile was returned) tells the two apart. To overwrite an existing profile's `scopes`/`roleId`, `identityOverrides`, and `status` instead of returning it unchanged, set `?upsert=true` (this also requires the `profiles:u` scope). You must provide exactly one of `scopes` (an inline list of scopes) or `roleId` (a reference to a role); supplying both, or neither, is rejected. `identityOverrides` may set only `orgId` and `clientId`; any other key (including the account identifier or `userId`) is rejected. If you use a scoped credential, the profile's effective scopes may not exceed your own; a root API key (`sk_`) is exempt. Requires the `profiles:c` scope.
2806
+ * Creates a new access profile under the given app context. This call is idempotent by `principalId`: if a profile with the same `principalId` already exists, the existing profile is returned (with status 200) instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing profile was returned) tells the two apart. To overwrite an existing profile's `scopes`/`roleId`, `identityOverrides`, and `status` instead of returning it unchanged, set `?upsert=true` (this also requires the `profiles:u` scope). You must provide exactly one of `scopes` (an inline list of scopes) or `roleId` (a reference to a role); supplying both, or neither, is rejected. `identityOverrides` is keyed by ownership namespace in `scope:<namespace>` form — `scope:org` and `scope:client` for the reserved namespaces, or any namespace you have registered — and may name at most two; any other key (including the account identifier or `userId`) is rejected. If you use a scoped credential, the profile's effective scopes may not exceed your own; a root API key (`sk_`) is exempt. Requires the `profiles:c` scope.
2850
2807
  *
2851
2808
  * @param {Vectros.CreateAccessProfileRequest} request
2852
2809
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3135,7 +3092,7 @@ var AuthClient = class {
3135
3092
  * roleId: "engineering-member",
3136
3093
  * name: "Engineering Team Member",
3137
3094
  * scopes: [{
3138
- * allowed_actions: ["read", "write"]
3095
+ * allowed_actions: ["records:cru", "search:r"]
3139
3096
  * }]
3140
3097
  * }
3141
3098
  * })
@@ -3683,7 +3640,7 @@ var AuthClient = class {
3683
3640
  * roleId: "engineering-member",
3684
3641
  * name: "Engineering Team Member",
3685
3642
  * scopes: [{
3686
- * allowed_actions: ["read", "write"]
3643
+ * allowed_actions: ["records:cru", "search:r"]
3687
3644
  * }]
3688
3645
  * }
3689
3646
  * })
@@ -4136,7 +4093,7 @@ var AuthClient = class {
4136
4093
  * "userId": "550e8400-e29b-41d4-a716-446655440000"
4137
4094
  * },
4138
4095
  * dataScope: {
4139
- * "orgId": ["6ba7b810-9dad-11d1-80b4-00c04fd430c8"]
4096
+ * "scope:org": ["6ba7b810-9dad-11d1-80b4-00c04fd430c8"]
4140
4097
  * }
4141
4098
  * },
4142
4099
  * expiresInSeconds: 3600
@@ -4586,7 +4543,7 @@ var DocumentsClient = class {
4586
4543
  this._options = normalizeClientOptionsWithAuth(options);
4587
4544
  }
4588
4545
  /**
4589
- * Returns a paginated list of your documents, optionally filtered by folder (`folderId`) and/or owner (`userId`, `orgId`, or `clientId`). The response is a `{data, nextCursor}` envelope; pass `nextCursor` back as `startFrom` to fetch the next page. Requires the `documents:r` scope.
4546
+ * Returns a paginated list of your documents, optionally filtered by folder (`folderId`) and/or owner (`userId` or `scope`). The response is a `{data, nextCursor}` envelope; pass `nextCursor` back as `startFrom` to fetch the next page. Requires the `documents:r` scope.
4590
4547
  *
4591
4548
  * @param {Vectros.ListDocumentsRequest} request
4592
4549
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4594,8 +4551,7 @@ var DocumentsClient = class {
4594
4551
  * @example
4595
4552
  * await client.documents.listDocuments({
4596
4553
  * userId: "550e8400-e29b-41d4-a716-446655440000",
4597
- * orgId: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
4598
- * clientId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
4554
+ * scope: "group:eng-team",
4599
4555
  * folderId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
4600
4556
  * startFrom: "doc_prev123"
4601
4557
  * })
@@ -4604,11 +4560,10 @@ var DocumentsClient = class {
4604
4560
  return HttpResponsePromise.fromPromise(this.__listDocuments(request, requestOptions));
4605
4561
  }
4606
4562
  async __listDocuments(request = {}, requestOptions) {
4607
- const { userId, orgId, clientId, folderId, startFrom, limit } = request;
4563
+ const { userId, scope, folderId, startFrom, limit } = request;
4608
4564
  const _queryParams = {
4609
4565
  userId,
4610
- orgId,
4611
- clientId,
4566
+ scope,
4612
4567
  folderId,
4613
4568
  startFrom,
4614
4569
  limit
@@ -4666,9 +4621,10 @@ var DocumentsClient = class {
4666
4621
  return HttpResponsePromise.fromPromise(this.__ingestDocument(request, requestOptions));
4667
4622
  }
4668
4623
  async __ingestDocument(request, requestOptions) {
4669
- const { upsert, body: _body } = request;
4624
+ const { upsert, allowClear, body: _body } = request;
4670
4625
  const _queryParams = {
4671
- upsert
4626
+ upsert,
4627
+ allowClear
4672
4628
  };
4673
4629
  const _authRequest = await this._options.authProvider.getAuthRequest();
4674
4630
  const _headers = mergeHeaders(
@@ -4792,7 +4748,10 @@ var DocumentsClient = class {
4792
4748
  return HttpResponsePromise.fromPromise(this.__updateDocument(request, requestOptions));
4793
4749
  }
4794
4750
  async __updateDocument(request, requestOptions) {
4795
- const { id, body: _body } = request;
4751
+ const { id, allowClear, body: _body } = request;
4752
+ const _queryParams = {
4753
+ allowClear
4754
+ };
4796
4755
  const _authRequest = await this._options.authProvider.getAuthRequest();
4797
4756
  const _headers = mergeHeaders(
4798
4757
  _authRequest.headers,
@@ -4807,7 +4766,7 @@ var DocumentsClient = class {
4807
4766
  method: "PUT",
4808
4767
  headers: _headers,
4809
4768
  contentType: "application/json",
4810
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4769
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
4811
4770
  requestType: "json",
4812
4771
  body: _body,
4813
4772
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -5336,7 +5295,7 @@ var FoldersClient = class {
5336
5295
  this._options = normalizeClientOptionsWithAuth(options);
5337
5296
  }
5338
5297
  /**
5339
- * Returns a paginated list of your folders. Pass `parentFolderId` to list the direct children of a specific folder (tree navigation); omit it for a flat list across your account. You can also filter by owner using `userId`, `orgId`, or `clientId`. Results are returned as a `{data, nextCursor}` envelope — pass `nextCursor` as `startFrom` to fetch the next page. Requires the `folders:r` scope.
5298
+ * Returns a paginated list of your folders. Pass `parentFolderId` to list the direct children of a specific folder (tree navigation); omit it for a flat list across your account. You can also filter by owner using `userId` or `scope`. Results are returned as a `{data, nextCursor}` envelope — pass `nextCursor` as `startFrom` to fetch the next page. Requires the `folders:r` scope.
5340
5299
  *
5341
5300
  * @param {Vectros.ListFoldersRequest} request
5342
5301
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -5344,9 +5303,8 @@ var FoldersClient = class {
5344
5303
  * @example
5345
5304
  * await client.folders.listFolders({
5346
5305
  * parentFolderId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
5347
- * orgId: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
5348
5306
  * userId: "550e8400-e29b-41d4-a716-446655440000",
5349
- * clientId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
5307
+ * scope: "group:eng-team",
5350
5308
  * startFrom: "fld_prev123"
5351
5309
  * })
5352
5310
  */
@@ -5354,12 +5312,11 @@ var FoldersClient = class {
5354
5312
  return HttpResponsePromise.fromPromise(this.__listFolders(request, requestOptions));
5355
5313
  }
5356
5314
  async __listFolders(request = {}, requestOptions) {
5357
- const { parentFolderId, orgId, userId, clientId, startFrom, limit } = request;
5315
+ const { parentFolderId, userId, scope, startFrom, limit } = request;
5358
5316
  const _queryParams = {
5359
5317
  parentFolderId,
5360
- orgId,
5361
5318
  userId,
5362
- clientId,
5319
+ scope,
5363
5320
  startFrom,
5364
5321
  limit
5365
5322
  };
@@ -5645,7 +5602,7 @@ var FoldersClient = class {
5645
5602
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/folders/{id}");
5646
5603
  }
5647
5604
  /**
5648
- * Partially updates a folder using an RFC 7386 JSON Merge Patch. The `name`, `description`, and ownership fields (`userId`, `orgId`, `clientId`) are applied when present and left unchanged when omitted; sending any of these as null is rejected, because clearing a field is not supported in this release (omit it instead). `slug` and `parentFolderId` are immutable — a folder cannot be re-slugged or moved via the API — and the request is rejected if either is present. Pass `expectedVersion` for optimistic concurrency (you get a 409 if the folder changed since you last read it). Requires the `folders:u` scope.
5605
+ * Partially updates a folder using an RFC 7386 JSON Merge Patch. The `name`, `description`, and ownership fields (`userId`, `scopes`) are applied when present and left unchanged when omitted; sending any of these as null is rejected, because clearing a field is not supported in this release (omit it instead). `slug` and `parentFolderId` are immutable — a folder cannot be re-slugged or moved via the API — and the request is rejected if either is present. Pass `expectedVersion` for optimistic concurrency (you get a 409 if the folder changed since you last read it). Requires the `folders:u` scope.
5649
5606
  *
5650
5607
  * @param {Vectros.PatchFolderRequest} request
5651
5608
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -5778,54 +5735,48 @@ var IdentityClient = class {
5778
5735
  this._options = normalizeClientOptionsWithAuth(options);
5779
5736
  }
5780
5737
  /**
5781
- * Returns a paginated list of clients in your account. Narrow the results with `orgId` or `userId`, or use `externalId` for an exact lookup by your own identifier. For schema-bound clients, you can also query by a schema-declared lookup field using `type`, `field`, and one lookup mode (`value` for equality, `from`/`to` for a range, or `prefix`). The response is a `{data, nextCursor}` envelope; pass `nextCursor` back as `startFrom` to fetch the next page. Requires the `clients:r` scope.
5738
+ * Returns a paginated list of entities in a namespace. Filter by `userId` (entities owned by a user), by `externalId` (exact lookup by your own identifier), or by `scope` (`scope=<namespace>:<value>` — entities that have that value as a parent, e.g. `scope=org:6ba7...`). Naming this namespace's own name in `scope` resolves the entity itself (`scope=team:6ba7...` on `/v1/entities/team` returns that team), since an entity is always in its own scope. `userId` and `scope` can be combined to narrow on both dimensions at once; `externalId` identifies a single entity and cannot be combined with either. Requires the `entities:r:<namespace>` scope.
5782
5739
  *
5783
- * @param {Vectros.ListClientsRequest} request
5740
+ * @param {Vectros.ListEntitiesRequest} request
5784
5741
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
5785
5742
  *
5786
5743
  * @example
5787
- * await client.identity.listClients({
5788
- * orgId: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
5789
- * userId: "550e8400-e29b-41d4-a716-446655440000",
5790
- * externalId: "patient_789",
5791
- * startFrom: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
5792
- * type: "client_v1",
5793
- * field: "industry",
5794
- * value: "healthcare",
5795
- * prefix: "health"
5744
+ * await client.identity.listEntities({
5745
+ * namespace: "team"
5796
5746
  * })
5797
5747
  */
5798
- listClients(request = {}, requestOptions) {
5799
- return HttpResponsePromise.fromPromise(this.__listClients(request, requestOptions));
5748
+ listEntities(request, requestOptions) {
5749
+ return HttpResponsePromise.fromPromise(this.__listEntities(request, requestOptions));
5800
5750
  }
5801
- async __listClients(request = {}, requestOptions) {
5751
+ async __listEntities(request, requestOptions) {
5802
5752
  const {
5803
- orgId,
5753
+ namespace,
5804
5754
  userId,
5805
5755
  externalId,
5806
- startFrom,
5807
- limit,
5756
+ scope,
5808
5757
  type: type_,
5809
5758
  field,
5810
5759
  value,
5811
5760
  from: from_,
5812
5761
  to,
5813
5762
  prefix,
5814
- order
5763
+ order,
5764
+ startFrom,
5765
+ limit
5815
5766
  } = request;
5816
5767
  const _queryParams = {
5817
- orgId,
5818
5768
  userId,
5819
5769
  externalId,
5820
- startFrom,
5821
- limit,
5770
+ scope,
5822
5771
  type: type_,
5823
5772
  field,
5824
5773
  value,
5825
5774
  from: from_,
5826
5775
  to,
5827
5776
  prefix,
5828
- order: order != null ? order : void 0
5777
+ order: order != null ? order : void 0,
5778
+ startFrom,
5779
+ limit
5829
5780
  };
5830
5781
  const _authRequest = await this._options.authProvider.getAuthRequest();
5831
5782
  const _headers = mergeHeaders(
@@ -5836,7 +5787,7 @@ var IdentityClient = class {
5836
5787
  const _response = await fetcher({
5837
5788
  url: url_exports.join(
5838
5789
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
5839
- "v1/clients"
5790
+ `v1/entities/${url_exports.encodePathParam(namespace)}`
5840
5791
  ),
5841
5792
  method: "GET",
5842
5793
  headers: _headers,
@@ -5857,12 +5808,12 @@ var IdentityClient = class {
5857
5808
  rawResponse: _response.rawResponse
5858
5809
  });
5859
5810
  }
5860
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/clients");
5811
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}");
5861
5812
  }
5862
5813
  /**
5863
- * Creates a new client identity in your account. This call is idempotent on `externalId`: if a client with the same `externalId` already exists, the existing record is returned instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing client was returned) tells the two apart. To overwrite an existing client's content instead of returning it unchanged, set `?upsert=true` (this also requires the `clients:u` scope). Requires the `clients:c` scope.
5814
+ * Creates a new entity in the given namespace. This call is idempotent on `externalId` within the namespace: if an entity with the same `externalId` already exists, the existing record is returned instead of creating a duplicate (`created: false`, HTTP 200). To overwrite an existing entity's content instead of returning it unchanged, set `?upsert=true` (also requires the `entities:u:<namespace>` scope). The namespace must be entity-backed (`org`/`client`, or registered via `POST /v1/namespaces`). Requires the `entities:c:<namespace>` scope.
5864
5815
  *
5865
- * @param {Vectros.CreateClientRequest} request
5816
+ * @param {Vectros.CreateEntityRequest} request
5866
5817
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
5867
5818
  *
5868
5819
  * @throws {@link Vectros.BadRequestError}
@@ -5870,17 +5821,18 @@ var IdentityClient = class {
5870
5821
  * @throws {@link Vectros.TooManyRequestsError}
5871
5822
  *
5872
5823
  * @example
5873
- * await client.identity.createClient({
5824
+ * await client.identity.createEntity({
5825
+ * namespace: "team",
5874
5826
  * body: {
5875
- * externalId: "patient_789"
5827
+ * externalId: "team_eng_platform"
5876
5828
  * }
5877
5829
  * })
5878
5830
  */
5879
- createClient(request, requestOptions) {
5880
- return HttpResponsePromise.fromPromise(this.__createClient(request, requestOptions));
5831
+ createEntity(request, requestOptions) {
5832
+ return HttpResponsePromise.fromPromise(this.__createEntity(request, requestOptions));
5881
5833
  }
5882
- async __createClient(request, requestOptions) {
5883
- const { upsert, body: _body } = request;
5834
+ async __createEntity(request, requestOptions) {
5835
+ const { namespace, upsert, body: _body } = request;
5884
5836
  const _queryParams = {
5885
5837
  upsert
5886
5838
  };
@@ -5893,7 +5845,7 @@ var IdentityClient = class {
5893
5845
  const _response = await fetcher({
5894
5846
  url: url_exports.join(
5895
5847
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
5896
- "v1/clients"
5848
+ `v1/entities/${url_exports.encodePathParam(namespace)}`
5897
5849
  ),
5898
5850
  method: "POST",
5899
5851
  headers: _headers,
@@ -5926,26 +5878,27 @@ var IdentityClient = class {
5926
5878
  });
5927
5879
  }
5928
5880
  }
5929
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/clients");
5881
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/entities/{namespace}");
5930
5882
  }
5931
5883
  /**
5932
- * Returns a single client by its Vectros-assigned UUID. Requires the `clients:r` scope.
5884
+ * Retrieves a single entity by its namespace and Vectros-assigned ID. Requires the `entities:r:<namespace>` scope.
5933
5885
  *
5934
- * @param {Vectros.GetClientRequest} request
5886
+ * @param {Vectros.GetEntityRequest} request
5935
5887
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
5936
5888
  *
5937
5889
  * @throws {@link Vectros.NotFoundError}
5938
5890
  *
5939
5891
  * @example
5940
- * await client.identity.getClient({
5941
- * id: "f47ac10b-58cc-4372-a567-0e02b2c3d479"
5892
+ * await client.identity.getEntity({
5893
+ * namespace: "team",
5894
+ * id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
5942
5895
  * })
5943
5896
  */
5944
- getClient(request, requestOptions) {
5945
- return HttpResponsePromise.fromPromise(this.__getClient(request, requestOptions));
5897
+ getEntity(request, requestOptions) {
5898
+ return HttpResponsePromise.fromPromise(this.__getEntity(request, requestOptions));
5946
5899
  }
5947
- async __getClient(request, requestOptions) {
5948
- const { id } = request;
5900
+ async __getEntity(request, requestOptions) {
5901
+ const { namespace, id } = request;
5949
5902
  const _authRequest = await this._options.authProvider.getAuthRequest();
5950
5903
  const _headers = mergeHeaders(
5951
5904
  _authRequest.headers,
@@ -5955,7 +5908,7 @@ var IdentityClient = class {
5955
5908
  const _response = await fetcher({
5956
5909
  url: url_exports.join(
5957
5910
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
5958
- `v1/clients/${url_exports.encodePathParam(id)}`
5911
+ `v1/entities/${url_exports.encodePathParam(namespace)}/${url_exports.encodePathParam(id)}`
5959
5912
  ),
5960
5913
  method: "GET",
5961
5914
  headers: _headers,
@@ -5981,30 +5934,31 @@ var IdentityClient = class {
5981
5934
  });
5982
5935
  }
5983
5936
  }
5984
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/clients/{id}");
5937
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}/{id}");
5985
5938
  }
5986
5939
  /**
5987
- * Updates mutable fields on an existing client. Omitted fields are preserved (a null does not clear a field); when `payload` is supplied it replaces the stored payload in full rather than being deep-merged. Requires the `clients:u` scope.
5940
+ * Updates the mutable fields of an entity. Omitted fields are preserved (a null value does not clear a field), and the `payload` object is replaced in full when supplied. Providing `scopes` replaces the entity's parent edges. Requires the `entities:u:<namespace>` scope.
5988
5941
  *
5989
- * @param {Vectros.UpdateClientRequest} request
5942
+ * @param {Vectros.UpdateEntityRequest} request
5990
5943
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
5991
5944
  *
5992
5945
  * @throws {@link Vectros.NotFoundError}
5993
5946
  * @throws {@link Vectros.TooManyRequestsError}
5994
5947
  *
5995
5948
  * @example
5996
- * await client.identity.updateClient({
5949
+ * await client.identity.updateEntity({
5950
+ * namespace: "team",
5997
5951
  * id: "id",
5998
5952
  * body: {
5999
- * externalId: "patient_789"
5953
+ * externalId: "team_eng_platform"
6000
5954
  * }
6001
5955
  * })
6002
5956
  */
6003
- updateClient(request, requestOptions) {
6004
- return HttpResponsePromise.fromPromise(this.__updateClient(request, requestOptions));
5957
+ updateEntity(request, requestOptions) {
5958
+ return HttpResponsePromise.fromPromise(this.__updateEntity(request, requestOptions));
6005
5959
  }
6006
- async __updateClient(request, requestOptions) {
6007
- const { id, body: _body } = request;
5960
+ async __updateEntity(request, requestOptions) {
5961
+ const { namespace, id, body: _body } = request;
6008
5962
  const _authRequest = await this._options.authProvider.getAuthRequest();
6009
5963
  const _headers = mergeHeaders(
6010
5964
  _authRequest.headers,
@@ -6014,7 +5968,7 @@ var IdentityClient = class {
6014
5968
  const _response = await fetcher({
6015
5969
  url: url_exports.join(
6016
5970
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6017
- `v1/clients/${url_exports.encodePathParam(id)}`
5971
+ `v1/entities/${url_exports.encodePathParam(namespace)}/${url_exports.encodePathParam(id)}`
6018
5972
  ),
6019
5973
  method: "PUT",
6020
5974
  headers: _headers,
@@ -6045,27 +5999,28 @@ var IdentityClient = class {
6045
5999
  });
6046
6000
  }
6047
6001
  }
6048
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/clients/{id}");
6002
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/entities/{namespace}/{id}");
6049
6003
  }
6050
6004
  /**
6051
- * Permanently deletes the client. This action cannot be undone. Requires the `clients:d` scope.
6005
+ * Permanently deletes an entity. This action cannot be undone. Requires the `entities:d:<namespace>` scope.
6052
6006
  *
6053
- * @param {Vectros.DeleteClientRequest} request
6007
+ * @param {Vectros.DeleteEntityRequest} request
6054
6008
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6055
6009
  *
6056
6010
  * @throws {@link Vectros.NotFoundError}
6057
6011
  * @throws {@link Vectros.TooManyRequestsError}
6058
6012
  *
6059
6013
  * @example
6060
- * await client.identity.deleteClient({
6014
+ * await client.identity.deleteEntity({
6015
+ * namespace: "team",
6061
6016
  * id: "id"
6062
6017
  * })
6063
6018
  */
6064
- deleteClient(request, requestOptions) {
6065
- return HttpResponsePromise.fromPromise(this.__deleteClient(request, requestOptions));
6019
+ deleteEntity(request, requestOptions) {
6020
+ return HttpResponsePromise.fromPromise(this.__deleteEntity(request, requestOptions));
6066
6021
  }
6067
- async __deleteClient(request, requestOptions) {
6068
- const { id } = request;
6022
+ async __deleteEntity(request, requestOptions) {
6023
+ const { namespace, id } = request;
6069
6024
  const _authRequest = await this._options.authProvider.getAuthRequest();
6070
6025
  const _headers = mergeHeaders(
6071
6026
  _authRequest.headers,
@@ -6075,7 +6030,7 @@ var IdentityClient = class {
6075
6030
  const _response = await fetcher({
6076
6031
  url: url_exports.join(
6077
6032
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6078
- `v1/clients/${url_exports.encodePathParam(id)}`
6033
+ `v1/entities/${url_exports.encodePathParam(namespace)}/${url_exports.encodePathParam(id)}`
6079
6034
  ),
6080
6035
  method: "DELETE",
6081
6036
  headers: _headers,
@@ -6103,27 +6058,36 @@ var IdentityClient = class {
6103
6058
  });
6104
6059
  }
6105
6060
  }
6106
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/clients/{id}");
6061
+ return handleNonStatusCodeError(
6062
+ _response.error,
6063
+ _response.rawResponse,
6064
+ "DELETE",
6065
+ "/v1/entities/{namespace}/{id}"
6066
+ );
6107
6067
  }
6108
6068
  /**
6109
- * Body-based equivalent of the `type`/`field`/`value` lookup on `GET /v1/clients`. Use this when looking up by a sensitive (blind-indexed) field: the value travels in the request body rather than the URL. The `GET` list rejects a sensitive field's value and directs you here. The response is a `{data, nextCursor}` envelope. Requires the `clients:r` scope.
6069
+ * Looks up entities in a namespace by a schema-declared field value, with the criteria in the request body instead of the URL. Use this for a sensitive field: the value travels in the body and never appears in the URL. Body equivalent of the `type`/`field`/`value` lookup on `GET /v1/entities/{namespace}`, which rejects sensitive-field values and directs you here. Requires the `entities:r:<namespace>` scope.
6110
6070
  *
6111
- * @param {Vectros.IdentityLookupRequest} request
6071
+ * @param {Vectros.LookupEntitiesRequest} request
6112
6072
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6113
6073
  *
6114
6074
  * @throws {@link Vectros.BadRequestError}
6115
6075
  * @throws {@link Vectros.TooManyRequestsError}
6116
6076
  *
6117
6077
  * @example
6118
- * await client.identity.lookupClients({
6119
- * type: "person_v1",
6120
- * field: "ssn"
6078
+ * await client.identity.lookupEntities({
6079
+ * namespace: "team",
6080
+ * body: {
6081
+ * type: "person_v1",
6082
+ * field: "ssn"
6083
+ * }
6121
6084
  * })
6122
6085
  */
6123
- lookupClients(request, requestOptions) {
6124
- return HttpResponsePromise.fromPromise(this.__lookupClients(request, requestOptions));
6086
+ lookupEntities(request, requestOptions) {
6087
+ return HttpResponsePromise.fromPromise(this.__lookupEntities(request, requestOptions));
6125
6088
  }
6126
- async __lookupClients(request, requestOptions) {
6089
+ async __lookupEntities(request, requestOptions) {
6090
+ const { namespace, body: _body } = request;
6127
6091
  const _authRequest = await this._options.authProvider.getAuthRequest();
6128
6092
  const _headers = mergeHeaders(
6129
6093
  _authRequest.headers,
@@ -6133,14 +6097,14 @@ var IdentityClient = class {
6133
6097
  const _response = await fetcher({
6134
6098
  url: url_exports.join(
6135
6099
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6136
- "v1/clients/lookup"
6100
+ `v1/entities/${url_exports.encodePathParam(namespace)}/lookup`
6137
6101
  ),
6138
6102
  method: "POST",
6139
6103
  headers: _headers,
6140
6104
  contentType: "application/json",
6141
6105
  queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6142
6106
  requestType: "json",
6143
- body: request,
6107
+ body: _body,
6144
6108
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6145
6109
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6146
6110
  abortSignal: requestOptions?.abortSignal,
@@ -6164,26 +6128,32 @@ var IdentityClient = class {
6164
6128
  });
6165
6129
  }
6166
6130
  }
6167
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/clients/lookup");
6131
+ return handleNonStatusCodeError(
6132
+ _response.error,
6133
+ _response.rawResponse,
6134
+ "POST",
6135
+ "/v1/entities/{namespace}/lookup"
6136
+ );
6168
6137
  }
6169
6138
  /**
6170
- * Returns the audit trail of changes to a client, newest first. Identity auditing is always on, so this history is always available; sensitive field values are redacted in each version. The response is a `{data, nextCursor}` envelope. Requires the `clients:r` scope.
6139
+ * Returns the audit trail of changes made to an entity, newest first. Sensitive field values are redacted in the history. Requires the `entities:r:<namespace>` scope.
6171
6140
  *
6172
- * @param {Vectros.GetClientVersionsRequest} request
6141
+ * @param {Vectros.GetEntityVersionsRequest} request
6173
6142
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6174
6143
  *
6175
6144
  * @throws {@link Vectros.NotFoundError}
6176
6145
  *
6177
6146
  * @example
6178
- * await client.identity.getClientVersions({
6147
+ * await client.identity.getEntityVersions({
6148
+ * namespace: "team",
6179
6149
  * id: "id"
6180
6150
  * })
6181
6151
  */
6182
- getClientVersions(request, requestOptions) {
6183
- return HttpResponsePromise.fromPromise(this.__getClientVersions(request, requestOptions));
6152
+ getEntityVersions(request, requestOptions) {
6153
+ return HttpResponsePromise.fromPromise(this.__getEntityVersions(request, requestOptions));
6184
6154
  }
6185
- async __getClientVersions(request, requestOptions) {
6186
- const { id, startFrom } = request;
6155
+ async __getEntityVersions(request, requestOptions) {
6156
+ const { namespace, id, startFrom } = request;
6187
6157
  const _queryParams = {
6188
6158
  startFrom
6189
6159
  };
@@ -6196,7 +6166,7 @@ var IdentityClient = class {
6196
6166
  const _response = await fetcher({
6197
6167
  url: url_exports.join(
6198
6168
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6199
- `v1/clients/${url_exports.encodePathParam(id)}/versions`
6169
+ `v1/entities/${url_exports.encodePathParam(namespace)}/${url_exports.encodePathParam(id)}/versions`
6200
6170
  ),
6201
6171
  method: "GET",
6202
6172
  headers: _headers,
@@ -6222,174 +6192,31 @@ var IdentityClient = class {
6222
6192
  });
6223
6193
  }
6224
6194
  }
6225
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/clients/{id}/versions");
6226
- }
6227
- /**
6228
- * Returns a paginated list of organizations in your account. Filter by `userId` to return only the organizations owned by a specific user, or by `externalId` for an exact lookup using your own identifier. You can also query schema-declared lookup fields by supplying `type` and `field` together with one lookup mode (`value` for equality, `from`/`to` for a range, or `prefix`). Requires the `orgs:r` scope.
6229
- *
6230
- * @param {Vectros.ListOrgsRequest} request
6231
- * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6232
- *
6233
- * @example
6234
- * await client.identity.listOrgs({
6235
- * userId: "550e8400-e29b-41d4-a716-446655440000",
6236
- * externalId: "clinic_001",
6237
- * startFrom: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
6238
- * type: "org_v1",
6239
- * field: "region",
6240
- * value: "us-east",
6241
- * prefix: "us-"
6242
- * })
6243
- */
6244
- listOrgs(request = {}, requestOptions) {
6245
- return HttpResponsePromise.fromPromise(this.__listOrgs(request, requestOptions));
6246
- }
6247
- async __listOrgs(request = {}, requestOptions) {
6248
- const {
6249
- userId,
6250
- externalId,
6251
- startFrom,
6252
- limit,
6253
- type: type_,
6254
- field,
6255
- value,
6256
- from: from_,
6257
- to,
6258
- prefix,
6259
- order
6260
- } = request;
6261
- const _queryParams = {
6262
- userId,
6263
- externalId,
6264
- startFrom,
6265
- limit,
6266
- type: type_,
6267
- field,
6268
- value,
6269
- from: from_,
6270
- to,
6271
- prefix,
6272
- order: order != null ? order : void 0
6273
- };
6274
- const _authRequest = await this._options.authProvider.getAuthRequest();
6275
- const _headers = mergeHeaders(
6276
- _authRequest.headers,
6277
- this._options?.headers,
6278
- requestOptions?.headers
6195
+ return handleNonStatusCodeError(
6196
+ _response.error,
6197
+ _response.rawResponse,
6198
+ "GET",
6199
+ "/v1/entities/{namespace}/{id}/versions"
6279
6200
  );
6280
- const _response = await fetcher({
6281
- url: url_exports.join(
6282
- await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6283
- "v1/orgs"
6284
- ),
6285
- method: "GET",
6286
- headers: _headers,
6287
- queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6288
- timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6289
- maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6290
- abortSignal: requestOptions?.abortSignal,
6291
- fetchFn: this._options?.fetch,
6292
- logging: this._options.logging
6293
- });
6294
- if (_response.ok) {
6295
- return { data: _response.body, rawResponse: _response.rawResponse };
6296
- }
6297
- if (_response.error.reason === "status-code") {
6298
- throw new VectrosError({
6299
- statusCode: _response.error.statusCode,
6300
- body: _response.error.body,
6301
- rawResponse: _response.rawResponse
6302
- });
6303
- }
6304
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/orgs");
6305
6201
  }
6306
6202
  /**
6307
- * Creates a new organization in your account. This call is idempotent on `externalId`: if an organization with the same `externalId` already exists, the existing record is returned instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing organization was returned) tells the two apart. To overwrite an existing organization's content instead of returning it unchanged, set `?upsert=true` (this also requires the `orgs:u` scope). Requires the `orgs:c` scope.
6203
+ * Retrieves a single scope-namespace registration by name. The reserved built-ins `org` and `client` are always resolvable.
6308
6204
  *
6309
- * @param {Vectros.CreateOrgRequest} request
6310
- * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6311
- *
6312
- * @throws {@link Vectros.BadRequestError}
6313
- * @throws {@link Vectros.ForbiddenError}
6314
- * @throws {@link Vectros.TooManyRequestsError}
6315
- *
6316
- * @example
6317
- * await client.identity.createOrg({
6318
- * body: {
6319
- * externalId: "clinic_001"
6320
- * }
6321
- * })
6322
- */
6323
- createOrg(request, requestOptions) {
6324
- return HttpResponsePromise.fromPromise(this.__createOrg(request, requestOptions));
6325
- }
6326
- async __createOrg(request, requestOptions) {
6327
- const { upsert, body: _body } = request;
6328
- const _queryParams = {
6329
- upsert
6330
- };
6331
- const _authRequest = await this._options.authProvider.getAuthRequest();
6332
- const _headers = mergeHeaders(
6333
- _authRequest.headers,
6334
- this._options?.headers,
6335
- requestOptions?.headers
6336
- );
6337
- const _response = await fetcher({
6338
- url: url_exports.join(
6339
- await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6340
- "v1/orgs"
6341
- ),
6342
- method: "POST",
6343
- headers: _headers,
6344
- contentType: "application/json",
6345
- queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6346
- requestType: "json",
6347
- body: _body,
6348
- timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6349
- maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6350
- abortSignal: requestOptions?.abortSignal,
6351
- fetchFn: this._options?.fetch,
6352
- logging: this._options.logging
6353
- });
6354
- if (_response.ok) {
6355
- return { data: _response.body, rawResponse: _response.rawResponse };
6356
- }
6357
- if (_response.error.reason === "status-code") {
6358
- switch (_response.error.statusCode) {
6359
- case 400:
6360
- throw new BadRequestError(_response.error.body, _response.rawResponse);
6361
- case 403:
6362
- throw new ForbiddenError(_response.error.body, _response.rawResponse);
6363
- case 429:
6364
- throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
6365
- default:
6366
- throw new VectrosError({
6367
- statusCode: _response.error.statusCode,
6368
- body: _response.error.body,
6369
- rawResponse: _response.rawResponse
6370
- });
6371
- }
6372
- }
6373
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/orgs");
6374
- }
6375
- /**
6376
- * Retrieves a single organization by its Vectros-assigned ID, returning its current name, status, payload, and schema binding. Requires the `orgs:r` scope.
6377
- *
6378
- * @param {Vectros.GetOrgRequest} request
6205
+ * @param {Vectros.GetNamespaceRequest} request
6379
6206
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6380
6207
  *
6381
6208
  * @throws {@link Vectros.NotFoundError}
6382
6209
  *
6383
6210
  * @example
6384
- * await client.identity.getOrg({
6385
- * id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
6211
+ * await client.identity.getNamespace({
6212
+ * namespace: "team"
6386
6213
  * })
6387
6214
  */
6388
- getOrg(request, requestOptions) {
6389
- return HttpResponsePromise.fromPromise(this.__getOrg(request, requestOptions));
6215
+ getNamespace(request, requestOptions) {
6216
+ return HttpResponsePromise.fromPromise(this.__getNamespace(request, requestOptions));
6390
6217
  }
6391
- async __getOrg(request, requestOptions) {
6392
- const { id } = request;
6218
+ async __getNamespace(request, requestOptions) {
6219
+ const { namespace } = request;
6393
6220
  const _authRequest = await this._options.authProvider.getAuthRequest();
6394
6221
  const _headers = mergeHeaders(
6395
6222
  _authRequest.headers,
@@ -6399,7 +6226,7 @@ var IdentityClient = class {
6399
6226
  const _response = await fetcher({
6400
6227
  url: url_exports.join(
6401
6228
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6402
- `v1/orgs/${url_exports.encodePathParam(id)}`
6229
+ `v1/namespaces/${url_exports.encodePathParam(namespace)}`
6403
6230
  ),
6404
6231
  method: "GET",
6405
6232
  headers: _headers,
@@ -6425,30 +6252,31 @@ var IdentityClient = class {
6425
6252
  });
6426
6253
  }
6427
6254
  }
6428
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/orgs/{id}");
6255
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces/{namespace}");
6429
6256
  }
6430
6257
  /**
6431
- * Updates the mutable fields of an organization. Omitted fields are preserved (a null value does not clear a field), and the `payload` object is replaced in full when supplied rather than deep-merged. Requires the `orgs:u` scope.
6258
+ * Updates the mutable fields (`entityBacked`, `defaultSchemaId`) of a registered namespace. The namespace name itself is immutable. Requires a root API key. The reserved built-ins cannot be updated.
6432
6259
  *
6433
- * @param {Vectros.UpdateOrgRequest} request
6260
+ * @param {Vectros.UpdateNamespaceRequest} request
6434
6261
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6435
6262
  *
6263
+ * @throws {@link Vectros.ForbiddenError}
6436
6264
  * @throws {@link Vectros.NotFoundError}
6437
6265
  * @throws {@link Vectros.TooManyRequestsError}
6438
6266
  *
6439
6267
  * @example
6440
- * await client.identity.updateOrg({
6441
- * id: "id",
6268
+ * await client.identity.updateNamespace({
6269
+ * namespace: "team",
6442
6270
  * body: {
6443
- * externalId: "clinic_001"
6271
+ * namespace: "team"
6444
6272
  * }
6445
6273
  * })
6446
6274
  */
6447
- updateOrg(request, requestOptions) {
6448
- return HttpResponsePromise.fromPromise(this.__updateOrg(request, requestOptions));
6275
+ updateNamespace(request, requestOptions) {
6276
+ return HttpResponsePromise.fromPromise(this.__updateNamespace(request, requestOptions));
6449
6277
  }
6450
- async __updateOrg(request, requestOptions) {
6451
- const { id, body: _body } = request;
6278
+ async __updateNamespace(request, requestOptions) {
6279
+ const { namespace, body: _body } = request;
6452
6280
  const _authRequest = await this._options.authProvider.getAuthRequest();
6453
6281
  const _headers = mergeHeaders(
6454
6282
  _authRequest.headers,
@@ -6458,7 +6286,7 @@ var IdentityClient = class {
6458
6286
  const _response = await fetcher({
6459
6287
  url: url_exports.join(
6460
6288
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6461
- `v1/orgs/${url_exports.encodePathParam(id)}`
6289
+ `v1/namespaces/${url_exports.encodePathParam(namespace)}`
6462
6290
  ),
6463
6291
  method: "PUT",
6464
6292
  headers: _headers,
@@ -6477,6 +6305,8 @@ var IdentityClient = class {
6477
6305
  }
6478
6306
  if (_response.error.reason === "status-code") {
6479
6307
  switch (_response.error.statusCode) {
6308
+ case 403:
6309
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
6480
6310
  case 404:
6481
6311
  throw new NotFoundError(_response.error.body, _response.rawResponse);
6482
6312
  case 429:
@@ -6489,27 +6319,28 @@ var IdentityClient = class {
6489
6319
  });
6490
6320
  }
6491
6321
  }
6492
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/orgs/{id}");
6322
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/namespaces/{namespace}");
6493
6323
  }
6494
6324
  /**
6495
- * Permanently deletes an organization. This action cannot be undone. Requires the `orgs:d` scope.
6325
+ * Deletes a registered scope namespace. Requires a root API key. The reserved built-ins cannot be deleted. A namespace that still has entities cannot be deleted (409) — delete its entities first; this keeps them reachable by the account-teardown and erasure sweeps.
6496
6326
  *
6497
- * @param {Vectros.DeleteOrgRequest} request
6327
+ * @param {Vectros.DeleteNamespaceRequest} request
6498
6328
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6499
6329
  *
6330
+ * @throws {@link Vectros.ForbiddenError}
6500
6331
  * @throws {@link Vectros.NotFoundError}
6501
6332
  * @throws {@link Vectros.TooManyRequestsError}
6502
6333
  *
6503
6334
  * @example
6504
- * await client.identity.deleteOrg({
6505
- * id: "id"
6335
+ * await client.identity.deleteNamespace({
6336
+ * namespace: "team"
6506
6337
  * })
6507
6338
  */
6508
- deleteOrg(request, requestOptions) {
6509
- return HttpResponsePromise.fromPromise(this.__deleteOrg(request, requestOptions));
6339
+ deleteNamespace(request, requestOptions) {
6340
+ return HttpResponsePromise.fromPromise(this.__deleteNamespace(request, requestOptions));
6510
6341
  }
6511
- async __deleteOrg(request, requestOptions) {
6512
- const { id } = request;
6342
+ async __deleteNamespace(request, requestOptions) {
6343
+ const { namespace } = request;
6513
6344
  const _authRequest = await this._options.authProvider.getAuthRequest();
6514
6345
  const _headers = mergeHeaders(
6515
6346
  _authRequest.headers,
@@ -6519,7 +6350,7 @@ var IdentityClient = class {
6519
6350
  const _response = await fetcher({
6520
6351
  url: url_exports.join(
6521
6352
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6522
- `v1/orgs/${url_exports.encodePathParam(id)}`
6353
+ `v1/namespaces/${url_exports.encodePathParam(namespace)}`
6523
6354
  ),
6524
6355
  method: "DELETE",
6525
6356
  headers: _headers,
@@ -6535,6 +6366,8 @@ var IdentityClient = class {
6535
6366
  }
6536
6367
  if (_response.error.reason === "status-code") {
6537
6368
  switch (_response.error.statusCode) {
6369
+ case 403:
6370
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
6538
6371
  case 404:
6539
6372
  throw new NotFoundError(_response.error.body, _response.rawResponse);
6540
6373
  case 429:
@@ -6547,27 +6380,26 @@ var IdentityClient = class {
6547
6380
  });
6548
6381
  }
6549
6382
  }
6550
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/orgs/{id}");
6383
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/namespaces/{namespace}");
6551
6384
  }
6552
6385
  /**
6553
- * Looks up organizations by a schema-declared field value, with the search criteria sent in the request body instead of the URL. Use this when looking up by a sensitive field: the value travels in the body and is never exposed in the URL. This is the body-based equivalent of the `type`/`field`/`value` lookup on `GET /v1/orgs`, which rejects sensitive-field values and directs you here. Returns a `{data, nextCursor}` envelope. Requires the `orgs:r` scope.
6386
+ * Returns the scope namespaces registered in your account, with the reserved built-ins `org` and `client` listed first. Returns a `{data, nextCursor}` envelope.
6554
6387
  *
6555
- * @param {Vectros.IdentityLookupRequest} request
6388
+ * @param {Vectros.ListNamespacesRequest} request
6556
6389
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6557
6390
  *
6558
- * @throws {@link Vectros.BadRequestError}
6559
- * @throws {@link Vectros.TooManyRequestsError}
6560
- *
6561
6391
  * @example
6562
- * await client.identity.lookupOrgs({
6563
- * type: "person_v1",
6564
- * field: "ssn"
6565
- * })
6392
+ * await client.identity.listNamespaces()
6566
6393
  */
6567
- lookupOrgs(request, requestOptions) {
6568
- return HttpResponsePromise.fromPromise(this.__lookupOrgs(request, requestOptions));
6394
+ listNamespaces(request = {}, requestOptions) {
6395
+ return HttpResponsePromise.fromPromise(this.__listNamespaces(request, requestOptions));
6569
6396
  }
6570
- async __lookupOrgs(request, requestOptions) {
6397
+ async __listNamespaces(request = {}, requestOptions) {
6398
+ const { startFrom, limit } = request;
6399
+ const _queryParams = {
6400
+ startFrom,
6401
+ limit
6402
+ };
6571
6403
  const _authRequest = await this._options.authProvider.getAuthRequest();
6572
6404
  const _headers = mergeHeaders(
6573
6405
  _authRequest.headers,
@@ -6577,14 +6409,11 @@ var IdentityClient = class {
6577
6409
  const _response = await fetcher({
6578
6410
  url: url_exports.join(
6579
6411
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6580
- "v1/orgs/lookup"
6412
+ "v1/namespaces"
6581
6413
  ),
6582
- method: "POST",
6414
+ method: "GET",
6583
6415
  headers: _headers,
6584
- contentType: "application/json",
6585
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6586
- requestType: "json",
6587
- body: request,
6416
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6588
6417
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6589
6418
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6590
6419
  abortSignal: requestOptions?.abortSignal,
@@ -6595,42 +6424,33 @@ var IdentityClient = class {
6595
6424
  return { data: _response.body, rawResponse: _response.rawResponse };
6596
6425
  }
6597
6426
  if (_response.error.reason === "status-code") {
6598
- switch (_response.error.statusCode) {
6599
- case 400:
6600
- throw new BadRequestError(_response.error.body, _response.rawResponse);
6601
- case 429:
6602
- throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
6603
- default:
6604
- throw new VectrosError({
6605
- statusCode: _response.error.statusCode,
6606
- body: _response.error.body,
6607
- rawResponse: _response.rawResponse
6608
- });
6609
- }
6427
+ throw new VectrosError({
6428
+ statusCode: _response.error.statusCode,
6429
+ body: _response.error.body,
6430
+ rawResponse: _response.rawResponse
6431
+ });
6610
6432
  }
6611
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/orgs/lookup");
6433
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces");
6612
6434
  }
6613
6435
  /**
6614
- * Returns the audit trail of changes made to an organization, newest first. Version history is always recorded for identity entities, and sensitive field values are redacted in the history. Requires the `orgs:r` scope.
6436
+ * Registers a new scope namespace and declares whether its values resolve to identity entities (`entityBacked`). Requires a root API key. The reserved names `org` and `client` are built in and cannot be registered.
6615
6437
  *
6616
- * @param {Vectros.GetOrgVersionsRequest} request
6438
+ * @param {Vectros.NamespaceRequest} request
6617
6439
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6618
6440
  *
6619
- * @throws {@link Vectros.NotFoundError}
6441
+ * @throws {@link Vectros.BadRequestError}
6442
+ * @throws {@link Vectros.ForbiddenError}
6443
+ * @throws {@link Vectros.TooManyRequestsError}
6620
6444
  *
6621
6445
  * @example
6622
- * await client.identity.getOrgVersions({
6623
- * id: "id"
6446
+ * await client.identity.registerNamespace({
6447
+ * namespace: "team"
6624
6448
  * })
6625
6449
  */
6626
- getOrgVersions(request, requestOptions) {
6627
- return HttpResponsePromise.fromPromise(this.__getOrgVersions(request, requestOptions));
6450
+ registerNamespace(request, requestOptions) {
6451
+ return HttpResponsePromise.fromPromise(this.__registerNamespace(request, requestOptions));
6628
6452
  }
6629
- async __getOrgVersions(request, requestOptions) {
6630
- const { id, startFrom } = request;
6631
- const _queryParams = {
6632
- startFrom
6633
- };
6453
+ async __registerNamespace(request, requestOptions) {
6634
6454
  const _authRequest = await this._options.authProvider.getAuthRequest();
6635
6455
  const _headers = mergeHeaders(
6636
6456
  _authRequest.headers,
@@ -6640,11 +6460,14 @@ var IdentityClient = class {
6640
6460
  const _response = await fetcher({
6641
6461
  url: url_exports.join(
6642
6462
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
6643
- `v1/orgs/${url_exports.encodePathParam(id)}/versions`
6463
+ "v1/namespaces"
6644
6464
  ),
6645
- method: "GET",
6465
+ method: "POST",
6646
6466
  headers: _headers,
6647
- queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6467
+ contentType: "application/json",
6468
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6469
+ requestType: "json",
6470
+ body: request,
6648
6471
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6649
6472
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6650
6473
  abortSignal: requestOptions?.abortSignal,
@@ -6656,8 +6479,12 @@ var IdentityClient = class {
6656
6479
  }
6657
6480
  if (_response.error.reason === "status-code") {
6658
6481
  switch (_response.error.statusCode) {
6659
- case 404:
6660
- throw new NotFoundError(_response.error.body, _response.rawResponse);
6482
+ case 400:
6483
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
6484
+ case 403:
6485
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
6486
+ case 429:
6487
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
6661
6488
  default:
6662
6489
  throw new VectrosError({
6663
6490
  statusCode: _response.error.statusCode,
@@ -6666,7 +6493,7 @@ var IdentityClient = class {
6666
6493
  });
6667
6494
  }
6668
6495
  }
6669
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/orgs/{id}/versions");
6496
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/namespaces");
6670
6497
  }
6671
6498
  /**
6672
6499
  * Returns a paginated list of the users in your account. Pass `externalId` to look up a single user by your own identifier. To filter on schema-declared lookup fields, supply `type` and `field` together with one lookup mode: `value` (exact match), `from`+`to` (range), or `prefix`. Requires the `users:r` scope.
@@ -7543,7 +7370,7 @@ var RecordsClient = class {
7543
7370
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/records/batch");
7544
7371
  }
7545
7372
  /**
7546
- * Returns a paginated list of records in your account as a `{data, nextCursor}` page. Supply exactly one of `type`, `folderId`, or `recent=true` to choose the mode: `type` lists all records of a single type; `folderId` lists all records in a folder (any type); and `recent=true` returns the account-wide recently-updated feed across all types, newest first. You may combine `type` with `folderId` to list a single type within a folder. The owner filters (`userId`, `orgId`, `clientId`) further narrow the type and folder modes; the `recent` feed is standalone and ignores all filters. Each token only sees the record types it is scoped to read. Requires the `records:r` scope. By default the response returns the indexed projection of each record; set `includePayload=true` to include full payloads.
7373
+ * Returns a paginated list of records in your account as a `{data, nextCursor}` page. Supply exactly one of `type`, `folderId`, or `recent=true` to choose the mode: `type` lists all records of a single type; `folderId` lists all records in a folder (any type); and `recent=true` returns the account-wide recently-updated feed across all types, newest first. You may combine `type` with `folderId` to list a single type within a folder. The owner filters (`userId`, `scope`) further narrow the type and folder modes; the `recent` feed is standalone and ignores all filters. Each token only sees the record types it is scoped to read. Requires the `records:r` scope. By default the response returns the indexed projection of each record; set `includePayload=true` to include full payloads.
7547
7374
  *
7548
7375
  * @param {Vectros.ListRecordsRequest} request
7549
7376
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -7553,8 +7380,7 @@ var RecordsClient = class {
7553
7380
  * type: "intake_form",
7554
7381
  * folderId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
7555
7382
  * userId: "550e8400-e29b-41d4-a716-446655440000",
7556
- * orgId: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
7557
- * clientId: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
7383
+ * scope: "group:eng-team",
7558
7384
  * startFrom: "550e8400-e29b-41d4-a716-446655440000"
7559
7385
  * })
7560
7386
  */
@@ -7562,13 +7388,12 @@ var RecordsClient = class {
7562
7388
  return HttpResponsePromise.fromPromise(this.__listRecords(request, requestOptions));
7563
7389
  }
7564
7390
  async __listRecords(request = {}, requestOptions) {
7565
- const { type: type_, folderId, userId, orgId, clientId, startFrom, limit, includePayload, recent } = request;
7391
+ const { type: type_, folderId, userId, scope, startFrom, limit, includePayload, recent } = request;
7566
7392
  const _queryParams = {
7567
7393
  type: type_,
7568
7394
  folderId,
7569
7395
  userId,
7570
- orgId,
7571
- clientId,
7396
+ scope,
7572
7397
  startFrom,
7573
7398
  limit,
7574
7399
  includePayload,
@@ -7633,9 +7458,10 @@ var RecordsClient = class {
7633
7458
  return HttpResponsePromise.fromPromise(this.__createRecord(request, requestOptions));
7634
7459
  }
7635
7460
  async __createRecord(request, requestOptions) {
7636
- const { upsert, body: _body } = request;
7461
+ const { upsert, allowClear, body: _body } = request;
7637
7462
  const _queryParams = {
7638
- upsert
7463
+ upsert,
7464
+ allowClear
7639
7465
  };
7640
7466
  const _authRequest = await this._options.authProvider.getAuthRequest();
7641
7467
  const _headers = mergeHeaders(
@@ -7757,7 +7583,10 @@ var RecordsClient = class {
7757
7583
  return HttpResponsePromise.fromPromise(this.__updateRecord(request, requestOptions));
7758
7584
  }
7759
7585
  async __updateRecord(request, requestOptions) {
7760
- const { id, body: _body } = request;
7586
+ const { id, allowClear, body: _body } = request;
7587
+ const _queryParams = {
7588
+ allowClear
7589
+ };
7761
7590
  const _authRequest = await this._options.authProvider.getAuthRequest();
7762
7591
  const _headers = mergeHeaders(
7763
7592
  _authRequest.headers,
@@ -7772,7 +7601,7 @@ var RecordsClient = class {
7772
7601
  method: "PUT",
7773
7602
  headers: _headers,
7774
7603
  contentType: "application/json",
7775
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
7604
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
7776
7605
  requestType: "json",
7777
7606
  body: _body,
7778
7607
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -7863,7 +7692,7 @@ var RecordsClient = class {
7863
7692
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/records/{id}");
7864
7693
  }
7865
7694
  /**
7866
- * Partially updates a record using an RFC 7386 JSON Merge Patch. The `payload` object is deep-merged into the existing payload: keys you send overwrite (recursing into nested objects), a key set to null is deleted, and keys you omit are left unchanged — so you can change a single field without re-sending the rest (unlike the full-replacement PUT). Top-level fields (`status`, `folderId`, `userId`, `orgId`, `clientId`) are set when present and left unchanged when omitted; sending a top-level field as null is rejected (clearing a top-level field is not supported in this release — omit it instead). `typeName`, `schemaId`, `externalId`, and `indexMode` are immutable and rejected if present. The merged result is validated against the schema. Pass `expectedVersion` to make the patch conditional (optimistic concurrency, 409 on conflict). Requires the `records:u:<type>` scope.
7695
+ * Partially updates a record using an RFC 7386 JSON Merge Patch. The `payload` object is deep-merged into the existing payload: keys you send overwrite (recursing into nested objects), a key set to null is deleted, and keys you omit are left unchanged — so you can change a single field without re-sending the rest (unlike the full-replacement PUT). Top-level fields (`status`, `folderId`, `userId`, `scopes`) are set when present and left unchanged when omitted; sending a top-level field as null is rejected (clearing a top-level field is not supported in this release — omit it instead). `typeName`, `schemaId`, `externalId`, and `indexMode` are immutable and rejected if present. The merged result is validated against the schema. Pass `expectedVersion` to make the patch conditional (optimistic concurrency, 409 on conflict). Requires the `records:u:<type>` scope.
7867
7696
  *
7868
7697
  * @param {Vectros.PatchRecordRequest} request
7869
7698
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8189,7 +8018,7 @@ var SchemasClient = class {
8189
8018
  this._options = normalizeClientOptionsWithAuth(options);
8190
8019
  }
8191
8020
  /**
8192
- * Returns a paginated list of the record schemas defined in your account. Filter by `userId` or `orgId` to scope to an owner, by `surface` to list the types bindable to one surface, or by `recordType` to resolve the single schema for a type directly. Filtering by an identity surface (user, org, or client) lists your account-wide identity schemas regardless of the calling context; filtering by record or document lists within the calling context. Requires the `schemas:r` scope.
8021
+ * Returns a paginated list of the record schemas defined in your account. Filter by `userId` or `scope` to scope to an owner, by `surface` to list the types bindable to one surface, or by `recordType` to resolve the single schema for a type directly. Filtering by an identity surface (`user` or `entity`) lists your account-wide identity schemas regardless of the calling context; filtering by record or document lists within the calling context. Requires the `schemas:r` scope.
8193
8022
  *
8194
8023
  * @param {Vectros.ListSchemasRequest} request
8195
8024
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8197,7 +8026,7 @@ var SchemasClient = class {
8197
8026
  * @example
8198
8027
  * await client.schemas.listSchemas({
8199
8028
  * userId: "550e8400-e29b-41d4-a716-446655440000",
8200
- * orgId: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
8029
+ * scope: "org:6ba7b810-9dad-11d1-80b4-00c04fd430c8",
8201
8030
  * surface: "document",
8202
8031
  * recordType: "intake_form",
8203
8032
  * startFrom: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
@@ -8207,10 +8036,10 @@ var SchemasClient = class {
8207
8036
  return HttpResponsePromise.fromPromise(this.__listSchemas(request, requestOptions));
8208
8037
  }
8209
8038
  async __listSchemas(request = {}, requestOptions) {
8210
- const { userId, orgId, surface, recordType, startFrom, limit } = request;
8039
+ const { userId, scope, surface, recordType, startFrom, limit } = request;
8211
8040
  const _queryParams = {
8212
8041
  userId,
8213
- orgId,
8042
+ scope,
8214
8043
  surface,
8215
8044
  recordType,
8216
8045
  startFrom,
@@ -8656,12 +8485,12 @@ var VectrosClient = class {
8656
8485
  get auth() {
8657
8486
  return this._auth ?? (this._auth = new AuthClient(this._options));
8658
8487
  }
8659
- get identity() {
8660
- return this._identity ?? (this._identity = new IdentityClient(this._options));
8661
- }
8662
8488
  get documents() {
8663
8489
  return this._documents ?? (this._documents = new DocumentsClient(this._options));
8664
8490
  }
8491
+ get identity() {
8492
+ return this._identity ?? (this._identity = new IdentityClient(this._options));
8493
+ }
8665
8494
  get compliance() {
8666
8495
  return this._compliance ?? (this._compliance = new ComplianceClient(this._options));
8667
8496
  }
@@ -8764,8 +8593,8 @@ function warnOnSuboptimalKey(key, log) {
8764
8593
 
8765
8594
  // src/build-info.ts
8766
8595
  var BUILD_INFO = {
8767
- mcpServer: true ? "0.7.0" : "dev",
8768
- sdk: true ? "0.33.0" : "dev"
8596
+ mcpServer: true ? "0.10.0" : "dev",
8597
+ sdk: true ? "0.35.0" : "dev"
8769
8598
  };
8770
8599
  function formatBuildInfo() {
8771
8600
  return `vectros-mcp-server ${BUILD_INFO.mcpServer} (sdk ${BUILD_INFO.sdk})`;
@@ -9004,7 +8833,7 @@ ${detail}${pointer}`
9004
8833
 
9005
8834
  // src/tools/hybrid_search.ts
9006
8835
  var MCP_DEFAULT_LIMIT = 3;
9007
- var MCP_MAX_LIMIT = 10;
8836
+ var MCP_MAX_LIMIT = 50;
9008
8837
  var MCP_RESPONSE_CHAR_BUDGET = 24e3;
9009
8838
  var SNIPPET_MAX_CHARS = 160;
9010
8839
  var INTERNAL_METADATA_KEYS = /* @__PURE__ */ new Set(["tenantId", "owner_id", "model_type", "rootFolderId", "folderId"]);
@@ -9038,9 +8867,9 @@ var inputSchema = {
9038
8867
  "Keyword-match precision for the BM25 leg (TEXT/HYBRID modes). OR = any term (broad recall), AND = all terms (higher precision), PHRASE = contiguous phrase. Default: PHRASE (slop 3) in HYBRID, OR in TEXT. (The advanced raw-query COMPLEX mode is intentionally not exposed here.)"
9039
8868
  ),
9040
8869
  limit: z.number().int().min(1).max(MCP_MAX_LIMIT).optional().describe(
9041
- `Max hits to return. MCP-specific cap of ${MCP_MAX_LIMIT} (vs API max of 50) to protect the agent context window. Default 3. Use offset for pagination.`
8870
+ `Max hits per page. Defaults to a low ${MCP_DEFAULT_LIMIT} to protect the agent context window; raise up to ${MCP_MAX_LIMIT} (the most a single search returns) in one call when you can accept the larger result, or page with \`offset\` instead.`
9042
8871
  ),
9043
- offset: z.number().int().min(0).optional().describe("Skip the first N hits \u2014 for pagination."),
8872
+ offset: z.number().int().min(0).max(200).optional().describe("Skip the first N hits \u2014 for pagination (0\u2013200)."),
9044
8873
  folderId: z.string().optional().describe("Scope to content in this EXACT folder (Vectros folder id)."),
9045
8874
  rootFolderId: z.string().optional().describe("Scope to content under this folder AND all its descendants (subtree-root folder id)."),
9046
8875
  // Content narrowing.
@@ -9053,8 +8882,9 @@ var inputSchema = {
9053
8882
  ),
9054
8883
  // Ownership.
9055
8884
  userId: z.string().optional().describe("Restrict to content owned by this user (Vectros UUID)."),
9056
- orgId: z.string().optional().describe("Restrict to content belonging to this org (Vectros UUID)."),
9057
- clientId: z.string().optional().describe("Restrict to content associated with this client (Vectros UUID)."),
8885
+ scope: z.string().optional().describe(
8886
+ 'Restrict to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
8887
+ ),
9058
8888
  // Date window.
9059
8889
  createdAfter: z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
9060
8890
  createdBefore: z.string().optional().describe("Restrict to content created at/before this ISO 8601 UTC timestamp."),
@@ -9072,7 +8902,7 @@ var inputSchema = {
9072
8902
  var hybridSearch = ({ client, log }) => ({
9073
8903
  name: "hybrid_search",
9074
8904
  title: "Hybrid search",
9075
- description: `Search the partner tenant's indexed content (documents + structured records) using hybrid BM25 + dense ranking. Returns up to 10 results (default 3) with citations and surrounding context for grounding follow-up reasoning. Narrow with contentTypes/typeName/filters, ownership (userId/orgId/clientId), folder scope, a created date window, keyword precision (textMode OR/AND/PHRASE), relevance floors (minSimilarity/minTextRelevance), uniqueDocuments, and requireComplete (fail closed on a degraded backend). Tenant-isolated; the caller's scoped key fully constrains which content is visible. ARCHIVED (soft-retracted) documents never appear in results \u2014 fetch them by id via document_get, or restore them via document_update. To stay within the agent context window each hit returns its matched chunkText + a short snippet by default; set includeContext:true for the broader surrounding passage. If the whole result would be too large it is truncated to the top hits (truncated:true). textLegEmpty:true flags that the keyword leg matched nothing (all textScores 0) \u2014 usually a too-long PHRASE query; retry with textMode:"OR".`,
8905
+ description: "Search your tenant's indexed content (documents + structured records) using hybrid BM25 + dense ranking. Returns up to `limit` results (default 3, max 50 \u2014 raise it in one call when you can accept the larger result) with citations and surrounding context for grounding follow-up reasoning. Narrow with contentTypes/typeName/filters, ownership (userId/scope), folder scope, a created date window, keyword precision (textMode OR/AND/PHRASE), relevance floors (minSimilarity/minTextRelevance), uniqueDocuments, and requireComplete (fail closed on a degraded backend). Tenant-isolated; the caller's scoped key fully constrains which content is visible. ARCHIVED (soft-retracted) documents never appear in results \u2014 fetch them by id via document_get, or restore them via document_update. To stay within the agent context window each hit returns its matched chunkText + a short snippet by default; set includeContext:true for the broader surrounding passage. If the whole result would be too large it is truncated to the top hits (truncated:true). totalResults is the full matching pool and hasMore:true means results remain past this page \u2014 raise limit or advance offset to fetch them. textLegEmpty:true flags that the keyword leg matched nothing (all textScores 0) \u2014 usually a too-long PHRASE query; retry with textMode:\"OR\".",
9076
8906
  inputSchema,
9077
8907
  handler: async (args) => {
9078
8908
  const limit = args.limit ?? MCP_DEFAULT_LIMIT;
@@ -9090,8 +8920,7 @@ var hybridSearch = ({ client, log }) => ({
9090
8920
  typeName: args.typeName,
9091
8921
  filters: args.filters,
9092
8922
  userId: args.userId,
9093
- orgId: args.orgId,
9094
- clientId: args.clientId,
8923
+ scope: args.scope,
9095
8924
  createdAfter: args.createdAfter,
9096
8925
  createdBefore: args.createdBefore,
9097
8926
  minSimilarity: args.minSimilarity,
@@ -9118,6 +8947,12 @@ var hybridSearch = ({ client, log }) => ({
9118
8947
  envelope.returnedResults = shaped.length;
9119
8948
  text = JSON.stringify(envelope, null, 2);
9120
8949
  }
8950
+ const offset = args.offset ?? 0;
8951
+ const totalResults = result.totalResults;
8952
+ if (typeof totalResults === "number" && offset + shaped.length < totalResults) {
8953
+ envelope.hasMore = true;
8954
+ text = JSON.stringify(envelope, null, 2);
8955
+ }
9121
8956
  log.debug(
9122
8957
  { tool: "hybrid_search", mode, limit, returned: shaped.length, textLegEmpty },
9123
8958
  "hybrid_search ok"
@@ -9153,7 +8988,7 @@ async function drainPages(fetchPage) {
9153
8988
 
9154
8989
  // src/tools/record_query.ts
9155
8990
  var MCP_DEFAULT_LIMIT2 = 3;
9156
- var MCP_MAX_LIMIT2 = 10;
8991
+ var MCP_MAX_LIMIT2 = 100;
9157
8992
  var inputSchema2 = {
9158
8993
  type: z2.string().min(1, "type (record type) is required").describe('Record type / schema name (e.g. "patient", "clinical_note").'),
9159
8994
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
@@ -9169,16 +9004,18 @@ var inputSchema2 = {
9169
9004
  ),
9170
9005
  // List-mode args:
9171
9006
  userId: z2.string().optional().describe("List mode: scope to records owned by this user."),
9172
- orgId: z2.string().optional().describe("List mode: scope to records owned by this org."),
9173
- clientId: z2.string().optional().describe("List mode: scope to records associated with this client."),
9007
+ scope: z2.string().optional().describe(
9008
+ 'List mode: filter to records carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
9009
+ ),
9010
+ startFrom: z2.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next. Works in both list and lookup mode."),
9174
9011
  limit: z2.number().int().min(1).max(MCP_MAX_LIMIT2).optional().describe(
9175
- `Max records to return. MCP-specific cap of ${MCP_MAX_LIMIT2} (vs API max of 100) to protect the agent context window. Default 3.`
9012
+ `Max records per page. Defaults to a low ${MCP_DEFAULT_LIMIT2} to protect the agent context window; raise up to ${MCP_MAX_LIMIT2} (the records API max) in one call when you can accept the larger payload, or page with \`startFrom\` instead.`
9176
9013
  )
9177
9014
  };
9178
9015
  var recordQuery = ({ client, log }) => ({
9179
9016
  name: "record_query",
9180
9017
  title: "Record query (list or lookup)",
9181
- description: "Query structured records of a given type. Two modes:\n \u2022 Lookup on a lookup-indexed field: pass `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Works on sensitive fields too.\n \u2022 List by type: omit `field`; optionally filter by `userId`/`orgId`/`clientId`.\nReturns up to 10 records (default 3). Mode is auto-detected from the arguments present.",
9018
+ description: "Query structured records of a given type. Two modes:\n \u2022 Lookup on a lookup-indexed field: pass `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Works on sensitive fields too.\n \u2022 List by type: omit `field`; optionally filter by `userId` or `scope` (`namespace:value`).\nReturns a `{ data, nextCursor }` page: `data` holds up to `limit` records (default 3, max 100 \u2014 raise it in one call when you can accept the payload), and a non-null `nextCursor` means more remain \u2014 pass it back as `startFrom` to page. Mode is auto-detected from the arguments present.",
9182
9019
  inputSchema: inputSchema2,
9183
9020
  handler: async (args) => {
9184
9021
  const limit = args.limit ?? MCP_DEFAULT_LIMIT2;
@@ -9188,8 +9025,9 @@ var recordQuery = ({ client, log }) => ({
9188
9025
  const from = args.from;
9189
9026
  const to = args.to;
9190
9027
  const prefix = args.prefix;
9028
+ const startFrom = args.startFrom;
9191
9029
  try {
9192
- let records;
9030
+ let page;
9193
9031
  if (field) {
9194
9032
  const hasEquality = value !== void 0;
9195
9033
  const hasRange = from !== void 0 || to !== void 0;
@@ -9212,7 +9050,7 @@ var recordQuery = ({ client, log }) => ({
9212
9050
  if (hasRange && !(from !== void 0 && to !== void 0)) {
9213
9051
  return toolError("record_query", new Error("range lookup requires both 'from' and 'to'."));
9214
9052
  }
9215
- const page = await client.records.lookupRecordsByBody({
9053
+ page = await client.records.lookupRecordsByBody({
9216
9054
  type,
9217
9055
  field,
9218
9056
  value,
@@ -9220,29 +9058,30 @@ var recordQuery = ({ client, log }) => ({
9220
9058
  to,
9221
9059
  prefix,
9222
9060
  order: args.order,
9061
+ startFrom,
9223
9062
  limit
9224
9063
  });
9225
- records = pageItems(page);
9226
9064
  log.debug(
9227
- { tool: "record_query", mode: "lookup", type, field, returned: records.length },
9065
+ { tool: "record_query", mode: "lookup", type, field, returned: pageItems(page).length },
9228
9066
  "record_query lookup ok"
9229
9067
  );
9230
9068
  } else {
9231
- const page = await client.records.listRecords({
9069
+ page = await client.records.listRecords({
9232
9070
  type,
9233
9071
  userId: args.userId,
9234
- orgId: args.orgId,
9235
- clientId: args.clientId,
9072
+ scope: args.scope,
9073
+ startFrom,
9236
9074
  limit
9237
9075
  });
9238
- records = pageItems(page);
9239
9076
  log.debug(
9240
- { tool: "record_query", mode: "list", type, limit, returned: records.length },
9077
+ { tool: "record_query", mode: "list", type, limit, returned: pageItems(page).length },
9241
9078
  "record_query list ok"
9242
9079
  );
9243
9080
  }
9081
+ const records = pageItems(page);
9082
+ const nextCursor = page.nextCursor ?? null;
9244
9083
  return {
9245
- content: [{ type: "text", text: JSON.stringify(records, null, 2) }]
9084
+ content: [{ type: "text", text: JSON.stringify({ data: records, nextCursor }, null, 2) }]
9246
9085
  };
9247
9086
  } catch (err) {
9248
9087
  log.warn({ tool: "record_query", err: String(err) }, "record_query failed");
@@ -9364,8 +9203,9 @@ var inputSchema4 = {
9364
9203
  status: z4.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
9365
9204
  folderId: z4.string().optional().describe("Group this record into a folder."),
9366
9205
  userId: z4.string().optional().describe("Owning user id."),
9367
- orgId: z4.string().optional().describe("Owning organization id."),
9368
- clientId: z4.string().optional().describe("Associated client id.")
9206
+ scopes: z4.array(z4.string()).optional().describe(
9207
+ 'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are built-in namespaces; others are custom scopes you define. This is the record\'s COMPLETE scope declaration and values must come from the credential\'s own identity. An empty array `[]` creates a PRIVATE record owned by the calling user alone. Omit to stamp the credential\'s full identity \u2014 the default.'
9208
+ )
9369
9209
  };
9370
9210
  var recordCreate = ({ client, log }) => ({
9371
9211
  name: "record_create",
@@ -9384,8 +9224,7 @@ var recordCreate = ({ client, log }) => ({
9384
9224
  status: args.status,
9385
9225
  folderId: args.folderId,
9386
9226
  userId: args.userId,
9387
- orgId: args.orgId,
9388
- clientId: args.clientId
9227
+ scopes: args.scopes
9389
9228
  }
9390
9229
  });
9391
9230
  log.debug({ tool: "record_create", type, id: created.id }, "record_create ok");
@@ -9470,24 +9309,27 @@ var record_delete_default = recordDelete;
9470
9309
  // src/tools/rag_ask.ts
9471
9310
  import { z as z7 } from "zod";
9472
9311
  var SEARCH_MCP_DEFAULT_LIMIT = 5;
9473
- var SEARCH_MCP_MAX_LIMIT = 10;
9312
+ var SEARCH_MCP_MAX_LIMIT = 50;
9474
9313
  var inputSchema7 = {
9475
9314
  query: z7.string().min(1, "query must be non-empty").describe("Question to ground against retrieved content."),
9476
9315
  instructions: z7.string().optional().describe(
9477
9316
  'System prompt that overrides the default for the generation step \u2014 e.g. "answer only from the provided context, cite sources, be concise". Default: a generic answer-from-context instruction.'
9478
9317
  ),
9479
9318
  model: z7.string().optional().describe(
9480
- "Inference model alias (e.g. claude-haiku-4-5, claude-sonnet-4-6, claude-opus-4-8). Default = tier-appropriate Haiku. See GET /v1/models for the catalog the calling key can reach."
9319
+ "Inference model alias (e.g. claude-haiku-4-5, claude-sonnet-5, claude-opus-4-8). Default = tier-appropriate Haiku. See GET /v1/models for the catalog the calling key can reach."
9481
9320
  ),
9482
9321
  search: z7.object({
9483
9322
  mode: z7.enum(["HYBRID", "TEXT", "SEMANTIC"]).optional().describe("Retrieval mode. Default HYBRID."),
9484
- limit: z7.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(`Passages to retrieve before generating. Default ${SEARCH_MCP_DEFAULT_LIMIT}, max ${SEARCH_MCP_MAX_LIMIT}.`),
9323
+ limit: z7.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(
9324
+ `Passages to retrieve before generating (the grounding-corpus size). Default ${SEARCH_MCP_DEFAULT_LIMIT}; raise up to ${SEARCH_MCP_MAX_LIMIT} (the RAG search API max) for a broader corpus when the extra grounding is worth the larger prompt.`
9325
+ ),
9485
9326
  // Retrieval scoping — parity with hybrid_search so an agent can ground the
9486
9327
  // answer on a specific owner / folder / type / metadata subset, not just the
9487
9328
  // whole-tenant corpus.
9488
9329
  userId: z7.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
9489
- orgId: z7.string().optional().describe("Restrict retrieval to content owned by this org (Vectros UUID)."),
9490
- clientId: z7.string().optional().describe("Restrict retrieval to content tagged with this client (Vectros UUID)."),
9330
+ scope: z7.string().optional().describe(
9331
+ 'Restrict retrieval to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
9332
+ ),
9491
9333
  folderId: z7.string().optional().describe("Restrict retrieval to this exact folder."),
9492
9334
  rootFolderId: z7.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
9493
9335
  typeName: z7.string().optional().describe("Restrict record retrieval to this schema type."),
@@ -9505,7 +9347,7 @@ var inputSchema7 = {
9505
9347
  var ragAsk = ({ client, log }) => ({
9506
9348
  name: "rag_ask",
9507
9349
  title: "RAG ask (corpus-wide)",
9508
- description: "Ask a question grounded against the partner tenant's indexed content. Vectros performs a hybrid search, injects the top-K passages into the prompt, and streams a model answer back. Scope retrieval with `search` (ownership, folder, type, metadata filters, date window) to ground on a subset \u2014 e.g. one patient or one folder \u2014 and steer generation with `instructions` / `temperature`. The full answer is returned as a single response; progress notifications keep the call alive during the 30-45s generation window. Inference runs in-perimeter against AWS Bedrock \u2014 PHI never leaves the BAA boundary.",
9350
+ description: "Ask a question grounded against your tenant's indexed content. Vectros performs a hybrid search, injects the top-K passages into the prompt, and streams a model answer back. Scope retrieval with `search` (ownership, folder, type, metadata filters, date window) to ground on a subset \u2014 e.g. one patient or one folder \u2014 and steer generation with `instructions` / `temperature`. The full answer is returned as a single response; progress notifications keep the call alive during the 30-45s generation window. Inference runs in-perimeter against AWS Bedrock \u2014 PHI never leaves the BAA boundary.",
9509
9351
  inputSchema: inputSchema7,
9510
9352
  handler: async (args, extra) => {
9511
9353
  try {
@@ -9514,8 +9356,7 @@ var ragAsk = ({ client, log }) => ({
9514
9356
  mode: searchArg.mode ?? "HYBRID",
9515
9357
  limit: searchArg.limit ?? SEARCH_MCP_DEFAULT_LIMIT,
9516
9358
  userId: searchArg.userId,
9517
- orgId: searchArg.orgId,
9518
- clientId: searchArg.clientId,
9359
+ scope: searchArg.scope,
9519
9360
  folderId: searchArg.folderId,
9520
9361
  rootFolderId: searchArg.rootFolderId,
9521
9362
  typeName: searchArg.typeName,
@@ -9660,32 +9501,32 @@ var inputSchema9 = {
9660
9501
  userId: z9.string().optional().describe(
9661
9502
  "Filter to schemas visible to a specific user. Optional; default returns all schemas the credential can see."
9662
9503
  ),
9663
- orgId: z9.string().optional().describe(
9664
- "Filter to schemas visible to a specific org. Optional; default returns all schemas the credential can see."
9504
+ scope: z9.string().optional().describe(
9505
+ 'Filter to schemas carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces. Optional; default returns all schemas the credential can see.'
9665
9506
  ),
9666
- surface: z9.enum(["record", "document", "user", "org", "client"]).optional().describe(
9667
- "Filter to schemas bindable to this surface \u2014 e.g. `document` to list only document types, or `record` for record types. The identity surfaces (user/org/client) are account-wide. Optional."
9507
+ surface: z9.enum(["record", "document", "user", "entity"]).optional().describe(
9508
+ "Filter to schemas bindable to this surface \u2014 e.g. `document` to list only document types, or `record` for record types. Identity entities in any namespace (org/client/one you registered) bind under the single `entity` surface; `user` and `entity` are account-wide. Optional."
9668
9509
  ),
9669
9510
  recordType: z9.string().optional().describe(
9670
- 'Resolve the single schema for this record type (its natural handle, e.g. "patient") instead of listing \u2014 returns a one-element result, or empty if none. Combine with `surface=user|org|client` for an identity schema. Takes precedence over userId/orgId. Optional.'
9511
+ 'Resolve the single schema for this record type (its natural handle, e.g. "patient") instead of listing \u2014 returns a one-element result, or empty if none. Combine with `surface=user|entity` for an identity schema. Takes precedence over userId. Optional.'
9671
9512
  )
9672
9513
  };
9673
9514
  var listSchemas = ({ client, log }) => ({
9674
9515
  name: "list_schemas",
9675
9516
  title: "List record schemas",
9676
- description: 'List the structured-record schema catalog for the partner tenant. Each schema describes a record type (e.g. "patient", "clinical_note") \u2014 its fields, lookup-indexed fields, and capabilities. Use this to discover what record types exist before calling `record_query`. Filter with `surface` (record/document/user/org/client \u2014 e.g. only document types), `recordType` (resolve one schema by its type name), or `userId`/`orgId`; default returns everything the credential can see.',
9517
+ description: 'List the structured-record schema catalog for your tenant. Each schema describes a record type (e.g. "patient", "clinical_note") \u2014 its fields, lookup-indexed fields, and capabilities. Use this to discover what record types exist before calling `record_query`. Filter with `surface` (record/document/user/entity \u2014 e.g. only document types), `recordType` (resolve one schema by its type name), or `userId`/`scope`; default returns everything the credential can see.',
9677
9518
  inputSchema: inputSchema9,
9678
9519
  handler: async (args) => {
9679
9520
  const userId = args.userId;
9680
- const orgId = args.orgId;
9521
+ const scope = args.scope;
9681
9522
  const surface = args.surface;
9682
9523
  const recordType = args.recordType;
9683
9524
  try {
9684
9525
  const schemas = await drainPages(
9685
- (startFrom) => client.schemas.listSchemas({ userId, orgId, surface, recordType, startFrom })
9526
+ (startFrom) => client.schemas.listSchemas({ userId, scope, surface, recordType, startFrom })
9686
9527
  );
9687
9528
  log.debug(
9688
- { tool: "list_schemas", userId, orgId, surface, recordType, returned: schemas.length },
9529
+ { tool: "list_schemas", userId, scope, surface, recordType, returned: schemas.length },
9689
9530
  "list_schemas ok"
9690
9531
  );
9691
9532
  return {
@@ -9795,7 +9636,7 @@ var document_get_default = documentGet;
9795
9636
  // src/tools/document_query.ts
9796
9637
  import { z as z11 } from "zod";
9797
9638
  var MCP_DEFAULT_LIMIT3 = 3;
9798
- var MCP_MAX_LIMIT3 = 10;
9639
+ var MCP_MAX_LIMIT3 = 100;
9799
9640
  var inputSchema11 = {
9800
9641
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
9801
9642
  field: z11.string().optional().describe("Lookup mode: name of the lookup-indexed field to query by."),
@@ -9810,16 +9651,18 @@ var inputSchema11 = {
9810
9651
  // List-mode args:
9811
9652
  folderId: z11.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
9812
9653
  userId: z11.string().optional().describe("List mode: scope to documents owned by this user."),
9813
- orgId: z11.string().optional().describe("List mode: scope to documents belonging to this org."),
9814
- clientId: z11.string().optional().describe("List mode: scope to documents associated with this client."),
9654
+ scope: z11.string().optional().describe(
9655
+ 'List mode: filter to documents carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
9656
+ ),
9657
+ startFrom: z11.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next. Works in both list and lookup mode."),
9815
9658
  limit: z11.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
9816
- `Max documents to return. MCP-specific cap of ${MCP_MAX_LIMIT3} (vs API max of 100) to protect the agent context window. Default 3.`
9659
+ `Max documents per page. Defaults to a low ${MCP_DEFAULT_LIMIT3} to protect the agent context window; raise up to ${MCP_MAX_LIMIT3} (the documents API max) in one call when you can accept the larger payload, or page with \`startFrom\` instead.`
9817
9660
  )
9818
9661
  };
9819
9662
  var documentQuery = ({ client, log }) => ({
9820
9663
  name: "document_query",
9821
9664
  title: "Document query (list or lookup)",
9822
- description: "Query document metadata. Two modes:\n \u2022 Lookup on a lookup-indexed field: pass `type` and `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Works on sensitive fields (equality only there); range/prefix need a range-enabled field.\n \u2022 List: omit `field`; optionally filter by `folderId`/`userId`/`orgId`/`clientId`.\nReturns up to 10 documents (default 3) as a bare array. Mode is auto-detected. Use document_get for the full text/download URL of one document.",
9665
+ description: "Query document metadata. Two modes:\n \u2022 Lookup on a lookup-indexed field: pass `type` and `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Works on sensitive fields (equality only there); range/prefix need a range-enabled field.\n \u2022 List: omit `field`; optionally filter by `folderId`/`userId`/`scope` (`namespace:value`).\nReturns a `{ data, nextCursor }` page: `data` holds up to `limit` documents (default 3, max 100 \u2014 raise it in one call when you can accept the payload), and a non-null `nextCursor` means more remain \u2014 pass it back as `startFrom` to page. Mode is auto-detected. Use document_get for the full text/download URL of one document.",
9823
9666
  inputSchema: inputSchema11,
9824
9667
  handler: async (args) => {
9825
9668
  const limit = args.limit ?? MCP_DEFAULT_LIMIT3;
@@ -9829,8 +9672,9 @@ var documentQuery = ({ client, log }) => ({
9829
9672
  const to = args.to;
9830
9673
  const prefix = args.prefix;
9831
9674
  const type = args.type;
9675
+ const startFrom = args.startFrom;
9832
9676
  try {
9833
- let documents;
9677
+ let page;
9834
9678
  if (field) {
9835
9679
  const hasEquality = value !== void 0;
9836
9680
  const hasRange = from !== void 0 || to !== void 0;
@@ -9859,7 +9703,7 @@ var documentQuery = ({ client, log }) => ({
9859
9703
  new Error("lookup requires 'type' (the document's bound schema type) alongside 'field'.")
9860
9704
  );
9861
9705
  }
9862
- const page = await client.documents.lookupDocumentsByBody({
9706
+ page = await client.documents.lookupDocumentsByBody({
9863
9707
  type,
9864
9708
  field,
9865
9709
  value,
@@ -9867,28 +9711,29 @@ var documentQuery = ({ client, log }) => ({
9867
9711
  to,
9868
9712
  prefix,
9869
9713
  order: args.order,
9714
+ startFrom,
9870
9715
  limit
9871
9716
  });
9872
- documents = pageItems(page);
9873
9717
  log.debug(
9874
- { tool: "document_query", mode: "lookup", type, field, returned: documents.length },
9718
+ { tool: "document_query", mode: "lookup", type, field, returned: pageItems(page).length },
9875
9719
  "document_query lookup ok"
9876
9720
  );
9877
9721
  } else {
9878
- const page = await client.documents.listDocuments({
9722
+ page = await client.documents.listDocuments({
9879
9723
  folderId: args.folderId,
9880
9724
  userId: args.userId,
9881
- orgId: args.orgId,
9882
- clientId: args.clientId,
9725
+ scope: args.scope,
9726
+ startFrom,
9883
9727
  limit
9884
9728
  });
9885
- documents = pageItems(page);
9886
9729
  log.debug(
9887
- { tool: "document_query", mode: "list", limit, returned: documents.length },
9730
+ { tool: "document_query", mode: "list", limit, returned: pageItems(page).length },
9888
9731
  "document_query list ok"
9889
9732
  );
9890
9733
  }
9891
- return { content: [{ type: "text", text: JSON.stringify(documents, null, 2) }] };
9734
+ const documents = pageItems(page);
9735
+ const nextCursor = page.nextCursor ?? null;
9736
+ return { content: [{ type: "text", text: JSON.stringify({ data: documents, nextCursor }, null, 2) }] };
9892
9737
  } catch (err) {
9893
9738
  log.warn({ tool: "document_query", err: String(err) }, "document_query failed");
9894
9739
  return toolError("document_query", err);
@@ -9917,8 +9762,9 @@ var inputSchema12 = {
9917
9762
  "Lifecycle status. `ARCHIVED` soft-retracts the document \u2014 it is pulled from search and recall but kept and recoverable; set it back to `ACTIVE` to re-index and restore it. The way to retire superseded content when the credential has no delete authority. Omit to leave unchanged."
9918
9763
  ),
9919
9764
  userId: z12.string().optional().describe("Reassign the owning user (Vectros UUID)."),
9920
- orgId: z12.string().optional().describe("Reassign the owning org (Vectros UUID)."),
9921
- clientId: z12.string().optional().describe("Reassign the associated client (Vectros UUID)."),
9765
+ scopes: z12.array(z12.string()).optional().describe(
9766
+ 'Reassign scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]) \u2014 the COMPLETE new parent set. `org`/`client` are built-in namespaces. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
9767
+ ),
9922
9768
  expectedVersion: z12.number().int().optional().describe(
9923
9769
  "Optimistic concurrency: the version you last read. If the document changed since, the update is refused as a conflict (re-read and retry). Omit for last-write-wins."
9924
9770
  )
@@ -9938,8 +9784,7 @@ var documentUpdate = ({ client, log }) => ({
9938
9784
  const folderId = args.folderId;
9939
9785
  const status = args.status;
9940
9786
  const userId = args.userId;
9941
- const orgId = args.orgId;
9942
- const clientId = args.clientId;
9787
+ const scopes = args.scopes;
9943
9788
  const expectedVersion = args.expectedVersion;
9944
9789
  try {
9945
9790
  const resolved = await resolveDocumentIdByExternalId(client, { id: documentId, externalId, type });
@@ -9951,8 +9796,7 @@ var documentUpdate = ({ client, log }) => ({
9951
9796
  if (folderId !== void 0) body.folderId = folderId;
9952
9797
  if (status !== void 0) body.status = status;
9953
9798
  if (userId !== void 0) body.userId = userId;
9954
- if (orgId !== void 0) body.orgId = orgId;
9955
- if (clientId !== void 0) body.clientId = clientId;
9799
+ if (scopes !== void 0) body.scopes = scopes;
9956
9800
  if (expectedVersion !== void 0) body.expectedVersion = expectedVersion;
9957
9801
  const updated = await client.documents.patchDocument({
9958
9802
  id: resolved.id,
@@ -9997,20 +9841,23 @@ var document_delete_default = documentDelete;
9997
9841
  // src/tools/folder_query.ts
9998
9842
  import { z as z14 } from "zod";
9999
9843
  var MCP_DEFAULT_LIMIT4 = 10;
10000
- var MCP_MAX_LIMIT4 = 50;
9844
+ var MCP_MAX_LIMIT4 = 100;
10001
9845
  var inputSchema14 = {
10002
9846
  id: z14.string().optional().describe("Get mode: fetch this single folder by id."),
10003
9847
  parentId: z14.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
10004
9848
  userId: z14.string().optional().describe("List mode: scope to folders owned by this user."),
10005
- orgId: z14.string().optional().describe("List mode: scope to folders belonging to this org."),
10006
- clientId: z14.string().optional().describe("List mode: scope to folders associated with this client."),
9849
+ scope: z14.string().optional().describe(
9850
+ 'List mode: filter to folders carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
9851
+ ),
10007
9852
  startFrom: z14.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
10008
- limit: z14.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(`List mode: max folders to return. MCP cap of ${MCP_MAX_LIMIT4} (vs API 100). Default 10.`)
9853
+ limit: z14.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
9854
+ `List mode: max folders per page. Default 10; raise up to ${MCP_MAX_LIMIT4} (the folders API max) in one call when you can accept the larger page, or page with \`startFrom\`.`
9855
+ )
10009
9856
  };
10010
9857
  var folderQuery = ({ client, log }) => ({
10011
9858
  name: "folder_query",
10012
9859
  title: "Folder query (list or get)",
10013
- description: "Read folders. Two modes:\n \u2022 Get: pass `id` \u2192 returns the single folder.\n \u2022 List: omit `id`; pass `parentId` for a folder's direct children (tree navigation) or omit for a flat tenant list. Optionally filter by `userId`/`orgId`/`clientId`.\nList mode returns `{ data, nextCursor }` (default 10, max 50 per page); pass `nextCursor` back as `startFrom` to page through all folders. Get mode returns the single folder object.",
9860
+ description: "Read folders. Two modes:\n \u2022 Get: pass `id` \u2192 returns the single folder.\n \u2022 List: omit `id`; pass `parentId` for a folder's direct children (tree navigation) or omit for a flat tenant list. Optionally filter by `userId` or `scope` (`namespace:value`).\nList mode returns `{ data, nextCursor }` (default 10, max 100 per page \u2014 raise it in one call when you can accept the larger page); a non-null `nextCursor` means more remain \u2014 pass it back as `startFrom` to page through all folders. Get mode returns the single folder object.",
10014
9861
  inputSchema: inputSchema14,
10015
9862
  handler: async (args) => {
10016
9863
  const id = args.id;
@@ -10024,8 +9871,7 @@ var folderQuery = ({ client, log }) => ({
10024
9871
  const page = await client.folders.listFolders({
10025
9872
  parentFolderId: args.parentId,
10026
9873
  userId: args.userId,
10027
- orgId: args.orgId,
10028
- clientId: args.clientId,
9874
+ scope: args.scope,
10029
9875
  startFrom: args.startFrom,
10030
9876
  limit
10031
9877
  });
@@ -10049,8 +9895,9 @@ var inputSchema15 = {
10049
9895
  parentId: z15.string().optional().describe("Parent folder id \u2014 places the folder under this parent. Omit for the context default root. Create-only."),
10050
9896
  slug: z15.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
10051
9897
  userId: z15.string().optional().describe("Owning user (Vectros UUID)."),
10052
- orgId: z15.string().optional().describe("Owning org (Vectros UUID)."),
10053
- clientId: z15.string().optional().describe("Associated client (Vectros UUID).")
9898
+ scopes: z15.array(z15.string()).optional().describe(
9899
+ 'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are built-in namespaces; others are custom scopes you define. This is the folder\'s COMPLETE scope declaration and values must come from the credential\'s own identity. An empty array `[]` creates a PRIVATE folder owned by the calling user alone. Omit to stamp the credential\'s full identity \u2014 the default.'
9900
+ )
10054
9901
  };
10055
9902
  var folderCreate = ({ client, log }) => ({
10056
9903
  name: "folder_create",
@@ -10066,8 +9913,7 @@ var folderCreate = ({ client, log }) => ({
10066
9913
  parentFolderId: args.parentId,
10067
9914
  slug: args.slug,
10068
9915
  userId: args.userId,
10069
- orgId: args.orgId,
10070
- clientId: args.clientId
9916
+ scopes: args.scopes
10071
9917
  }
10072
9918
  });
10073
9919
  log.debug({ tool: "folder_create", id: folder.id, name: folder.name }, "folder_create ok");
@@ -10087,8 +9933,9 @@ var inputSchema16 = {
10087
9933
  name: z16.string().optional().describe("New folder name. Omit to keep the current name."),
10088
9934
  description: z16.string().optional().describe("New description. Omit to leave unchanged."),
10089
9935
  userId: z16.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10090
- orgId: z16.string().optional().describe("Reassign the owning org (Vectros UUID)."),
10091
- clientId: z16.string().optional().describe("Reassign the associated client (Vectros UUID)."),
9936
+ scopes: z16.array(z16.string()).optional().describe(
9937
+ 'Reassign scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]) \u2014 the COMPLETE new parent set. `org`/`client` are built-in namespaces. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
9938
+ ),
10092
9939
  expectedVersion: z16.number().int().optional().describe(
10093
9940
  "Optimistic concurrency: the version you last read. If the folder changed since, the update is refused as a conflict (re-read and retry). Omit for last-write-wins."
10094
9941
  )
@@ -10103,16 +9950,14 @@ var folderUpdate = ({ client, log }) => ({
10103
9950
  const name = args.name;
10104
9951
  const description = args.description;
10105
9952
  const userId = args.userId;
10106
- const orgId = args.orgId;
10107
- const clientId = args.clientId;
9953
+ const scopes = args.scopes;
10108
9954
  const expectedVersion = args.expectedVersion;
10109
9955
  try {
10110
9956
  const body = {};
10111
9957
  if (name !== void 0) body.name = name;
10112
9958
  if (description !== void 0) body.description = description;
10113
9959
  if (userId !== void 0) body.userId = userId;
10114
- if (orgId !== void 0) body.orgId = orgId;
10115
- if (clientId !== void 0) body.clientId = clientId;
9960
+ if (scopes !== void 0) body.scopes = scopes;
10116
9961
  if (expectedVersion !== void 0) body.expectedVersion = expectedVersion;
10117
9962
  const updated = await client.folders.patchFolder({ id, body });
10118
9963
  log.debug({ tool: "folder_update", id }, "folder_update ok");
@@ -10278,8 +10123,9 @@ var inputSchema19 = {
10278
10123
  // Common (both modes):
10279
10124
  folderId: z18.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
10280
10125
  userId: z18.string().optional().describe("Owning user ID. Optional."),
10281
- orgId: z18.string().optional().describe("Owning org ID. Optional."),
10282
- clientId: z18.string().optional().describe("Owning client ID. Optional.")
10126
+ scopes: z18.array(z18.string()).optional().describe(
10127
+ "TEXT MODE ONLY. Scope ownership as `namespace:value` entries, at most 2 (e.g. [\"org:<uuid>\", \"group:eng-team\"]). `org` and `client` are built-in namespaces; others are custom scopes you define. This is the document's COMPLETE scope declaration and values must come from the credential's own identity. An empty array `[]` creates a PRIVATE document owned by the calling user alone. Omit to stamp the credential's full identity \u2014 the default. Rejected with `filePath` (file uploads do not accept a scope declaration): a file-uploaded document is stamped with the credential's full identity."
10128
+ )
10283
10129
  };
10284
10130
  var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10285
10131
  name: "document_ingest",
@@ -10313,14 +10159,20 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10313
10159
  )
10314
10160
  );
10315
10161
  }
10162
+ if (filePath && args.scopes !== void 0) {
10163
+ return toolError(
10164
+ "document_ingest",
10165
+ new Error(
10166
+ "`scopes` is not supported with `filePath` \u2014 file uploads do not accept a scope declaration, and silently ignoring it could make an intended-private document team-visible. Use `text` mode to declare scopes, or omit `scopes` (the upload is stamped with the credential's full identity)."
10167
+ )
10168
+ );
10169
+ }
10316
10170
  const common = {
10317
10171
  folderId: args.folderId,
10318
10172
  payload: args.payload,
10319
10173
  schemaId,
10320
10174
  externalId: args.externalId,
10321
- userId: args.userId,
10322
- orgId: args.orgId,
10323
- clientId: args.clientId
10175
+ userId: args.userId
10324
10176
  };
10325
10177
  try {
10326
10178
  if (text) {
@@ -10330,6 +10182,9 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10330
10182
  title,
10331
10183
  text,
10332
10184
  indexMode,
10185
+ // Scope ownership is a TEXT-mode contract only (the upload-init
10186
+ // endpoint has no scopes field — see the gate above).
10187
+ scopes: args.scopes,
10333
10188
  ...common
10334
10189
  }
10335
10190
  });
@@ -10422,9 +10277,11 @@ var document_ingest_default = documentIngest;
10422
10277
  // src/tools/lookup_principal.ts
10423
10278
  import { z as z19 } from "zod";
10424
10279
  var MCP_DEFAULT_LIMIT5 = 10;
10425
- var MCP_MAX_LIMIT5 = 50;
10280
+ var MCP_MAX_LIMIT5 = 100;
10426
10281
  var inputSchema20 = {
10427
- kind: z19.enum(["user", "org", "client"]).describe("Which principal to look up: a user, an organization, or a client."),
10282
+ kind: z19.string().describe(
10283
+ 'Which principal to look up: "user" (the fixed principal surface), or an entity namespace \u2014 "org", "client" (built in), or a namespace you registered.'
10284
+ ),
10428
10285
  externalId: z19.string().optional().describe(
10429
10286
  "Resolve mode: your own stable identifier for the principal. Returns the single matching principal (with its Vectros UUID), or an empty array if none. The fastest path to the UUID the ownership filters need. Takes precedence if both this and a `field` lookup are supplied."
10430
10287
  ),
@@ -10436,15 +10293,19 @@ var inputSchema20 = {
10436
10293
  to: z19.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
10437
10294
  prefix: z19.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
10438
10295
  order: z19.enum(["asc", "desc"]).optional().describe("Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc`."),
10439
- limit: z19.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(`Max principals to return. MCP cap of ${MCP_MAX_LIMIT5} (vs API 100). Default ${MCP_DEFAULT_LIMIT5}.`)
10296
+ startFrom: z19.string().optional().describe("Lookup mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
10297
+ limit: z19.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(
10298
+ `Max principals per page. Defaults to ${MCP_DEFAULT_LIMIT5}; raise up to ${MCP_MAX_LIMIT5} (the principals API max) in one call when you can accept the payload, or page with \`startFrom\`.`
10299
+ )
10440
10300
  };
10441
10301
  var lookupPrincipal = ({ client, log }) => ({
10442
10302
  name: "lookup_principal",
10443
- title: "Look up a user / org / client identity",
10444
- description: "Resolve a user, org, or client identity. Two modes:\n \u2022 Resolve by your own id: pass `externalId` \u2192 the matching principal incl. its Vectros UUID (the id the ownership filters on record_query / hybrid_search / rag_ask expect).\n \u2022 Lookup by a schema field: pass `type` and `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Sensitive-field-safe. (If both `externalId` and a `field` lookup are given, `externalId` wins.) Returns up to 50 principals (default 10) as a bare array. Read-only \u2014 does not create or modify identities.",
10303
+ title: "Look up a user identity or a namespaced identity entity",
10304
+ description: "Resolve a user, or an identity entity in a namespace (org/client/one you registered). Two modes:\n \u2022 Resolve by your own id: pass `externalId` \u2192 the matching principal incl. its Vectros UUID (the id the ownership filters on record_query / hybrid_search / rag_ask expect).\n \u2022 Lookup by a schema field: pass `type` and `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Sensitive-field-safe. (If both `externalId` and a `field` lookup are given, `externalId` wins.) Returns a `{ data, nextCursor }` page (default 10, max 100 \u2014 raise it in one call when you can accept the payload); a non-null `nextCursor` means more remain \u2014 pass it back as `startFrom`. Read-only \u2014 does not create or modify identities.",
10445
10305
  inputSchema: inputSchema20,
10446
10306
  handler: async (args) => {
10447
10307
  const kind = args.kind;
10308
+ const isUser = kind === "user";
10448
10309
  const limit = args.limit ?? MCP_DEFAULT_LIMIT5;
10449
10310
  const externalId = args.externalId;
10450
10311
  const type = args.type;
@@ -10454,16 +10315,11 @@ var lookupPrincipal = ({ client, log }) => ({
10454
10315
  const to = args.to;
10455
10316
  const prefix = args.prefix;
10456
10317
  const order = args.order;
10318
+ const startFrom = args.startFrom;
10457
10319
  try {
10458
10320
  let page;
10459
10321
  if (externalId !== void 0) {
10460
- if (kind === "user") {
10461
- page = await client.identity.listUsers({ externalId, limit });
10462
- } else if (kind === "org") {
10463
- page = await client.identity.listOrgs({ externalId, limit });
10464
- } else {
10465
- page = await client.identity.listClients({ externalId, limit });
10466
- }
10322
+ page = isUser ? await client.identity.listUsers({ externalId, limit }) : await client.identity.listEntities({ namespace: kind, externalId, limit });
10467
10323
  log.debug({ tool: "lookup_principal", mode: "resolve", kind }, "lookup_principal resolve ok");
10468
10324
  } else if (field !== void 0) {
10469
10325
  const hasEquality = value !== void 0;
@@ -10491,14 +10347,8 @@ var lookupPrincipal = ({ client, log }) => ({
10491
10347
  new Error("lookup requires 'type' (the identity schema's record type) alongside 'field'.")
10492
10348
  );
10493
10349
  }
10494
- const req = { type, field, value, from, to, prefix, order, limit };
10495
- if (kind === "user") {
10496
- page = await client.identity.lookupUsers(req);
10497
- } else if (kind === "org") {
10498
- page = await client.identity.lookupOrgs(req);
10499
- } else {
10500
- page = await client.identity.lookupClients(req);
10501
- }
10350
+ const req = { type, field, value, from, to, prefix, order, startFrom, limit };
10351
+ page = isUser ? await client.identity.lookupUsers(req) : await client.identity.lookupEntities({ namespace: kind, body: req });
10502
10352
  log.debug({ tool: "lookup_principal", mode: "lookup", kind, type, field }, "lookup_principal lookup ok");
10503
10353
  } else {
10504
10354
  return toolError(
@@ -10507,7 +10357,8 @@ var lookupPrincipal = ({ client, log }) => ({
10507
10357
  );
10508
10358
  }
10509
10359
  const principals = pageItems(page);
10510
- return { content: [{ type: "text", text: JSON.stringify(principals, null, 2) }] };
10360
+ const nextCursor = page.nextCursor ?? null;
10361
+ return { content: [{ type: "text", text: JSON.stringify({ data: principals, nextCursor }, null, 2) }] };
10511
10362
  } catch (err) {
10512
10363
  log.warn({ tool: "lookup_principal", kind, err: String(err) }, "lookup_principal failed");
10513
10364
  return toolError("lookup_principal", err);
@@ -10953,6 +10804,133 @@ function parseToolsEnv(value) {
10953
10804
  return requested;
10954
10805
  }
10955
10806
 
10807
+ // src/resolve-key.ts
10808
+ import { execFile } from "child_process";
10809
+ import { statSync } from "fs";
10810
+ import path from "path";
10811
+ var HELPER_COMMAND = "vectros";
10812
+ var HELPER_TIMEOUT_MS = 1e4;
10813
+ var HELPER_MAX_BUFFER = 64 * 1024;
10814
+ var ALIAS_RE = /^[A-Za-z0-9._-]+$/;
10815
+ var SECRET_RE = /(?:ssk|sk|st)_(?:live|test)_[A-Za-z0-9._-]+/gi;
10816
+ var DETAIL_MAX_CHARS = 200;
10817
+ async function resolveApiKey(deps = {}) {
10818
+ const env = deps.env ?? process.env;
10819
+ const envKey = env.VECTROS_API_KEY;
10820
+ if (envKey && envKey.trim().length > 0) {
10821
+ return { key: envKey.trim(), source: "env" };
10822
+ }
10823
+ const alias = env.VECTROS_KEYRING_ALIAS?.trim() || void 0;
10824
+ if (alias !== void 0 && !ALIAS_RE.test(alias)) {
10825
+ return {
10826
+ source: "none",
10827
+ reason: "bad-alias",
10828
+ detail: "VECTROS_KEYRING_ALIAS must be letters, digits, dot, dash, or underscore."
10829
+ };
10830
+ }
10831
+ const runHelper = deps.runHelper ?? defaultRunHelper;
10832
+ const outcome = await runHelper({ alias, env });
10833
+ switch (outcome.status) {
10834
+ case "ok":
10835
+ return { key: outcome.secret, source: "keyring", alias };
10836
+ case "cli-absent":
10837
+ return { source: "none", reason: "cli-absent", alias };
10838
+ // Redact HERE as well as in mapExecResult: `runHelper` is a public injectable
10839
+ // seam, so redacting only inside the default implementation would leave any
10840
+ // other implementation's text to reach the fatal log raw. Belongs at the sink.
10841
+ case "no-usable-key":
10842
+ return {
10843
+ source: "none",
10844
+ reason: "no-usable-key",
10845
+ alias,
10846
+ detail: outcome.detail ? redactDetail(outcome.detail) : void 0
10847
+ };
10848
+ case "error":
10849
+ return { source: "none", reason: "helper-failed", alias, detail: redactDetail(outcome.detail) };
10850
+ }
10851
+ }
10852
+ function noKeyMessage(resolved) {
10853
+ const setEnv = "set VECTROS_API_KEY to a Vectros key (recommended: ssk_live_\u2026)";
10854
+ switch (resolved.reason) {
10855
+ case "cli-absent":
10856
+ return `no API key: VECTROS_API_KEY is unset and the \`vectros\` CLI is not on PATH. Either ${setEnv}, or install @vectros-ai/cli and run \`vectros switch <alias>\`.`;
10857
+ case "no-usable-key":
10858
+ return `no API key: VECTROS_API_KEY is unset and \`vectros keyring show\` returned no key${resolved.detail ? ` \u2014 ${resolved.detail}` : ""}. Run \`vectros switch <alias>\` to pick an identity, \`vectros keyring doctor\` to inspect the keyring (CLI 0.10.0+), upgrade @vectros-ai/cli if it predates the keyring (0.9.0), or ${setEnv}.`;
10859
+ case "bad-alias":
10860
+ return `invalid VECTROS_KEYRING_ALIAS: ${resolved.detail ?? "not a valid keyring alias"} Run \`vectros keyring list\` to see the entry names, unset it to use the active identity, or ${setEnv}.`;
10861
+ case "helper-failed":
10862
+ return `no API key: VECTROS_API_KEY is unset and the \`vectros keyring show\` helper failed (${resolved.detail ?? "unknown error"}). Upgrade @vectros-ai/cli if it is an old build, or ${setEnv} to bypass the keyring.`;
10863
+ default:
10864
+ return `no API key: ${setEnv}.`;
10865
+ }
10866
+ }
10867
+ function keyringNotice(resolved) {
10868
+ if (resolved.source !== "keyring") return void 0;
10869
+ if (resolved.alias !== void 0) {
10870
+ return { level: "info", alias: resolved.alias, message: "resolved API key from the vectros CLI keyring" };
10871
+ }
10872
+ return {
10873
+ level: "warn",
10874
+ alias: "(active)",
10875
+ message: "resolved API key from the vectros CLI keyring: no entry was named, so this server is running as whatever identity `vectros switch` last made active. Set VECTROS_API_KEY, or VECTROS_KEYRING_ALIAS, to choose deliberately \u2014 `vectros keyring doctor` shows which entry is active and whether it holds a live key."
10876
+ };
10877
+ }
10878
+ function redactDetail(message) {
10879
+ const redacted = message.replace(/\s+/g, " ").trim().replace(SECRET_RE, "[redacted]");
10880
+ return redacted.length > DETAIL_MAX_CHARS ? `${redacted.slice(0, DETAIL_MAX_CHARS)}\u2026` : redacted;
10881
+ }
10882
+ function resolveCommandPath(command, env, platform = process.platform) {
10883
+ const pathVar = env.PATH ?? env.Path ?? env.path ?? "";
10884
+ if (!pathVar) return void 0;
10885
+ const exts = platform === "win32" ? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").map((e) => e.trim()).filter(Boolean) : [""];
10886
+ for (const rawDir of pathVar.split(path.delimiter)) {
10887
+ const dir = rawDir.trim().replace(/^"(.*)"$/, "$1");
10888
+ if (!dir || !path.isAbsolute(dir)) continue;
10889
+ for (const ext of exts) {
10890
+ const candidate = path.join(dir, command + ext);
10891
+ try {
10892
+ if (statSync(candidate).isFile()) return candidate;
10893
+ } catch {
10894
+ }
10895
+ }
10896
+ }
10897
+ return void 0;
10898
+ }
10899
+ function mapExecResult(err, stdout, stderr = "") {
10900
+ if (!err) {
10901
+ const secret = stdout.trim();
10902
+ return secret ? { status: "ok", secret } : { status: "no-usable-key" };
10903
+ }
10904
+ const code = err.code;
10905
+ if (code === "ENOENT") return { status: "cli-absent" };
10906
+ const detail = redactDetail(stderr.trim() || err.message);
10907
+ if (code === 1 || code === 2) return { status: "no-usable-key", detail: detail || void 0 };
10908
+ return { status: "error", detail };
10909
+ }
10910
+ function defaultRunHelper({ alias, env }, deps = {}) {
10911
+ const platform = deps.platform ?? process.platform;
10912
+ const exec = deps.execFileImpl ?? execFile;
10913
+ const resolved = resolveCommandPath(HELPER_COMMAND, env, platform);
10914
+ if (!resolved) return Promise.resolve({ status: "cli-absent" });
10915
+ const isWindows = platform === "win32";
10916
+ const args = ["keyring", "show", "--format", "raw", ...alias ? ["--alias", alias] : []];
10917
+ const file = isWindows ? `"${resolved}"` : resolved;
10918
+ return new Promise((resolve2) => {
10919
+ exec(
10920
+ file,
10921
+ args,
10922
+ {
10923
+ env,
10924
+ timeout: HELPER_TIMEOUT_MS,
10925
+ maxBuffer: HELPER_MAX_BUFFER,
10926
+ windowsHide: true,
10927
+ shell: isWindows
10928
+ },
10929
+ (err, stdout, stderr) => resolve2(mapExecResult(err, String(stdout ?? ""), String(stderr ?? "")))
10930
+ );
10931
+ });
10932
+ }
10933
+
10956
10934
  // src/cli.ts
10957
10935
  async function main() {
10958
10936
  if (process.argv.includes("--version") || process.argv.includes("-v")) {
@@ -10961,7 +10939,14 @@ async function main() {
10961
10939
  process.exit(0);
10962
10940
  }
10963
10941
  const log = createLogger2();
10964
- const apiKey = process.env.VECTROS_API_KEY;
10942
+ const resolved = await resolveApiKey();
10943
+ const apiKey = resolved.key;
10944
+ const notice = keyringNotice(resolved);
10945
+ if (notice) log[notice.level]({ alias: notice.alias }, notice.message);
10946
+ if (!apiKey) {
10947
+ log.fatal({ reason: resolved.reason }, noKeyMessage(resolved));
10948
+ process.exit(1);
10949
+ }
10965
10950
  const apiBaseUrl = process.env.VECTROS_API_BASE_URL;
10966
10951
  if (apiBaseUrl !== void 0) {
10967
10952
  try {