@vectros-ai/mcp-server 0.16.0 → 0.17.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)
@@ -37,6 +37,7 @@ __export(api_exports, {
37
37
  FieldDef: () => FieldDef,
38
38
  FileUploadRequest: () => FileUploadRequest,
39
39
  ForbiddenError: () => ForbiddenError,
40
+ GatewayTimeoutError: () => GatewayTimeoutError,
40
41
  IdentityLookupRequest: () => IdentityLookupRequest,
41
42
  IndexFailure: () => IndexFailure,
42
43
  InternalServerError: () => InternalServerError,
@@ -61,9 +62,12 @@ __export(api_exports, {
61
62
  SearchRequest: () => SearchRequest,
62
63
  SearchResult: () => SearchResult,
63
64
  SearchResultsEvent: () => SearchResultsEvent,
65
+ ServiceUnavailableError: () => ServiceUnavailableError,
64
66
  TooManyRequestsError: () => TooManyRequestsError,
67
+ TriggerFailureResponse: () => TriggerFailureResponse,
65
68
  TruncationWarningEvent: () => TruncationWarningEvent,
66
69
  UnauthorizedError: () => UnauthorizedError,
70
+ UnprocessableEntityError: () => UnprocessableEntityError,
67
71
  UserExistsResponse: () => UserExistsResponse,
68
72
  UserRequest: () => UserRequest,
69
73
  UserResponse: () => UserResponse,
@@ -75,7 +79,9 @@ __export(api_exports, {
75
79
  inference: () => inference_exports,
76
80
  records: () => records_exports,
77
81
  schemas: () => schemas_exports,
78
- search: () => search_exports
82
+ scripts: () => scripts_exports,
83
+ search: () => search_exports,
84
+ triggers: () => triggers_exports
79
85
  });
80
86
  var toJson = (value, replacer, space) => {
81
87
  return JSON.stringify(value, replacer, space);
@@ -195,6 +201,21 @@ var ForbiddenError = class extends VectrosError {
195
201
  this.name = this.constructor.name;
196
202
  }
197
203
  };
204
+ var GatewayTimeoutError = class extends VectrosError {
205
+ constructor(body, rawResponse) {
206
+ super({
207
+ message: "GatewayTimeoutError",
208
+ statusCode: 504,
209
+ body,
210
+ rawResponse
211
+ });
212
+ Object.setPrototypeOf(this, new.target.prototype);
213
+ if (Error.captureStackTrace) {
214
+ Error.captureStackTrace(this, this.constructor);
215
+ }
216
+ this.name = this.constructor.name;
217
+ }
218
+ };
198
219
  var InternalServerError = class extends VectrosError {
199
220
  constructor(body, rawResponse) {
200
221
  super({
@@ -255,6 +276,21 @@ var PaymentRequiredError = class extends VectrosError {
255
276
  this.name = this.constructor.name;
256
277
  }
257
278
  };
279
+ var ServiceUnavailableError = class extends VectrosError {
280
+ constructor(body, rawResponse) {
281
+ super({
282
+ message: "ServiceUnavailableError",
283
+ statusCode: 503,
284
+ body,
285
+ rawResponse
286
+ });
287
+ Object.setPrototypeOf(this, new.target.prototype);
288
+ if (Error.captureStackTrace) {
289
+ Error.captureStackTrace(this, this.constructor);
290
+ }
291
+ this.name = this.constructor.name;
292
+ }
293
+ };
258
294
  var TooManyRequestsError = class extends VectrosError {
259
295
  constructor(body, rawResponse) {
260
296
  super({
@@ -285,6 +321,21 @@ var UnauthorizedError = class extends VectrosError {
285
321
  this.name = this.constructor.name;
286
322
  }
287
323
  };
324
+ var UnprocessableEntityError = class extends VectrosError {
325
+ constructor(body, rawResponse) {
326
+ super({
327
+ message: "UnprocessableEntityError",
328
+ statusCode: 422,
329
+ body,
330
+ rawResponse
331
+ });
332
+ Object.setPrototypeOf(this, new.target.prototype);
333
+ if (Error.captureStackTrace) {
334
+ Error.captureStackTrace(this, this.constructor);
335
+ }
336
+ this.name = this.constructor.name;
337
+ }
338
+ };
288
339
  var auth_exports = {};
289
340
  var ErasureRequest;
290
341
  ((ErasureRequest2) => {
@@ -374,6 +425,7 @@ var LookupRecordsRequestOrder = {
374
425
  Desc: "desc"
375
426
  };
376
427
  var schemas_exports = {};
428
+ var scripts_exports = {};
377
429
  var SearchRequest;
378
430
  ((SearchRequest2) => {
379
431
  SearchRequest2.Mode = {
@@ -399,6 +451,7 @@ var search_exports = {};
399
451
  __export(search_exports, {
400
452
  SearchRequest: () => SearchRequest
401
453
  });
454
+ var triggers_exports = {};
402
455
  var AccessProfileRequest;
403
456
  ((AccessProfileRequest2) => {
404
457
  AccessProfileRequest2.Status = {
@@ -428,7 +481,9 @@ var BatchWriteResult;
428
481
  Created: "created",
429
482
  Updated: "updated",
430
483
  Conflict: "conflict",
431
- Invalid: "invalid"
484
+ Invalid: "invalid",
485
+ Forbidden: "forbidden",
486
+ NotCommitted: "not_committed"
432
487
  };
433
488
  })(BatchWriteResult || (BatchWriteResult = {}));
434
489
  var ChatMessage;
@@ -732,13 +787,23 @@ var SearchResultsEvent;
732
787
  SearchResults: "search_results"
733
788
  };
734
789
  })(SearchResultsEvent || (SearchResultsEvent = {}));
790
+ var TriggerFailureResponse;
791
+ ((TriggerFailureResponse2) => {
792
+ TriggerFailureResponse2.Event = {
793
+ Create: "CREATE",
794
+ Update: "UPDATE",
795
+ Delete: "DELETE"
796
+ };
797
+ })(TriggerFailureResponse || (TriggerFailureResponse = {}));
735
798
  var TruncationWarningEvent;
736
799
  ((TruncationWarningEvent2) => {
737
800
  TruncationWarningEvent2.Event = {
738
801
  TruncationWarning: "truncation_warning"
739
802
  };
740
803
  TruncationWarningEvent2.Reason = {
741
- ContextWindowBudget: "context_window_budget"
804
+ ContextWindowBudget: "context_window_budget",
805
+ NoGroundableContent: "no_groundable_content",
806
+ ContextWindowBudgetAndNoContent: "context_window_budget_and_no_content"
742
807
  };
743
808
  })(TruncationWarningEvent || (TruncationWarningEvent = {}));
744
809
  var UserExistsResponse;
@@ -753,8 +818,7 @@ var UserRequest;
753
818
  ((UserRequest2) => {
754
819
  UserRequest2.Status = {
755
820
  Active: "ACTIVE",
756
- Suspended: "SUSPENDED",
757
- Pending: "PENDING"
821
+ Suspended: "SUSPENDED"
758
822
  };
759
823
  UserRequest2.Type = {
760
824
  Human: "HUMAN",
@@ -2222,6 +2286,16 @@ function mergeHeaders(...headersArray) {
2222
2286
  }
2223
2287
  return result;
2224
2288
  }
2289
+ function mergeOnlyDefinedHeaders(...headersArray) {
2290
+ const result = {};
2291
+ for (const [key, value] of headersArray.filter((headers) => headers != null).flatMap((headers) => Object.entries(headers))) {
2292
+ const insensitiveKey = key.toLowerCase();
2293
+ if (value != null) {
2294
+ result[insensitiveKey] = value;
2295
+ }
2296
+ }
2297
+ return result;
2298
+ }
2225
2299
  function normalizeClientOptions(options) {
2226
2300
  const headers = mergeHeaders(
2227
2301
  {
@@ -2492,7 +2566,7 @@ var AuthClient = class {
2492
2566
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/admin/keys/scoped");
2493
2567
  }
2494
2568
  /**
2495
- * Creates a scoped API key (an `ssk_*` secret) that inherits its permissions from an existing access profile in your account. The call is idempotent on the combination of tenant, context, user, and key name: re-issuing the same request returns the existing key WITHOUT re-disclosing its raw secret. The raw key is returned ONLY in this response — store it securely, as it cannot be retrieved again. Requires the `keys:c` scope. If you use a scoped credential, `keys:c` alone is not sufficient: because the minted key is durably bound to the profile you name, the profile's effective scopes may not exceed your own, and you may only mint against a profile whose `identityOverrides` values your own identity holds. Minting a key bound to your OWN principal needs nothing further; minting one bound to a DIFFERENT principal additionally requires the `delegate-mint` capability (`granted_capabilities`) on your credential — without it the request is refused. A root API key (`sk_`) is exempt from all three bounds.
2569
+ * Creates a scoped API key (an `ssk_*` secret) that inherits its permissions from an existing access profile in your account. The call is idempotent on the combination of tenant, context, user, and key name: re-issuing the same request returns the existing key WITHOUT re-disclosing its raw secret. The raw key is returned ONLY in this response — store it securely, as it cannot be retrieved again. Requires the `keys:c` scope. If you use a scoped credential, `keys:c` alone is not sufficient: because the minted key is durably bound to the profile you name, the profile's effective scopes may not exceed your own, and you may only mint against a profile whose `identityOverrides` values your own identity holds. Minting a key bound to your OWN principal needs nothing further; minting one bound to a DIFFERENT principal additionally requires the `delegate-mint` capability (`granted_capabilities`) on your credential — without it the request is refused. A root API key (`sk_`) is exempt from all three bounds. The profile you name must be `active` AND the user you name must not be `SUSPENDED`: either is refused with `409`, and no root exemption applies to that. Both refusals stop ISSUANCE only. Suspending the profile additionally stops credentials already bound to it, within about five minutes; suspending the user does not stop their existing keys at all. A `PENDING` user is fine.
2496
2570
  *
2497
2571
  * @param {Vectros.CreateScopedKeyRequest} request
2498
2572
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -2500,6 +2574,7 @@ var AuthClient = class {
2500
2574
  * @throws {@link Vectros.BadRequestError}
2501
2575
  * @throws {@link Vectros.ForbiddenError}
2502
2576
  * @throws {@link Vectros.NotFoundError}
2577
+ * @throws {@link Vectros.ConflictError}
2503
2578
  * @throws {@link Vectros.TooManyRequestsError}
2504
2579
  *
2505
2580
  * @example
@@ -2548,6 +2623,8 @@ var AuthClient = class {
2548
2623
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
2549
2624
  case 404:
2550
2625
  throw new NotFoundError(_response.error.body, _response.rawResponse);
2626
+ case 409:
2627
+ throw new ConflictError(_response.error.body, _response.rawResponse);
2551
2628
  case 429:
2552
2629
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
2553
2630
  default:
@@ -2959,7 +3036,7 @@ var AuthClient = class {
2959
3036
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/app-contexts");
2960
3037
  }
2961
3038
  /**
2962
- * Creates a new app context. This call is idempotent by `contextId`: if an app context with the same `contextId` already exists, the existing app context 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 context was returned) tells the two apart. To overwrite an existing context's `name`/`description` instead of returning it unchanged, set `?upsert=true` (this also requires the `app-contexts:u` scope). The reserved `contextId` value `vectros-admin` cannot be created through this endpoint; it is provisioned automatically for your account. Requires the `app-contexts:c` scope.
3039
+ * Creates a new app context. This call is idempotent by `contextId`: if an app context with the same `contextId` already exists, the existing app context 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 context was returned) tells the two apart. To overwrite an existing context's `name`/`description`/`companyName` instead of returning it unchanged, set `?upsert=true` (this also requires the `app-contexts:u` scope). The reserved `contextId` value `vectros-admin` cannot be created through this endpoint; it is provisioned automatically for your account. Requires the `app-contexts:c` scope.
2963
3040
  *
2964
3041
  * @param {Vectros.CreateAppContextRequest} request
2965
3042
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3443,7 +3520,7 @@ var AuthClient = class {
3443
3520
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/app-contexts/{contextId}");
3444
3521
  }
3445
3522
  /**
3446
- * Updates the name and/or description of an app context. This is a partial update: any field you omit (or send as null) keeps its existing value. The `contextId` is immutable and is taken from the URL path, so any `contextId` in the request body is ignored. Requires the `app-contexts:u` scope.
3523
+ * Updates the name, description, and/or companyName of an app context. This is a partial update: any field you omit (or send as null) keeps its existing value. The `contextId` is immutable and is taken from the URL path, so any `contextId` in the request body is ignored. Requires the `app-contexts:u` scope.
3447
3524
  *
3448
3525
  * @param {Vectros.UpdateAppContextRequest} request
3449
3526
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3925,7 +4002,7 @@ var AuthClient = class {
3925
4002
  );
3926
4003
  }
3927
4004
  /**
3928
- * Returns full usage detail for the requested calendar month, broken down by category (search, documents, and records) with per-category credit estimates and a split between your live and test environments. Defaults to the current month when `year` and `month` are omitted. Requires the `billing:r` scope on scoped tokens; API keys always have access. **A token confined to a single app context sees only that context's usage**: totals, the environment split, and the `contexts` breakdown narrow to it, and the environment your context is not bound to is omitted (`null`), not zeroed. Only a token with cross-context reach sees your full account-wide totals. Two exceptions to the narrowing, since they have no per-context breakdown to narrow to: `reads.calls.used`/`reads.dataOut.bytes` (metered per account, not per context) read as `0` for a confined token rather than a narrowed figure — the corresponding overage-credit charge fields narrow correctly; and `credits.limit` stays your whole plan's ceiling, so `credits.remaining` may overstate the account's true remaining room.
4005
+ * Returns full usage detail for the requested calendar month, broken down by category (search, documents, records, and trigger-script execution time) with per-category credit estimates and a split between your live and test environments. Defaults to the current month when `year` and `month` are omitted. Requires the `billing:r` scope on scoped tokens; API keys always have access. **A token confined to a single app context sees only that context's usage**: totals, the environment split, and the `contexts` breakdown narrow to it, and the environment your context is not bound to is omitted (`null`), not zeroed. Only a token with cross-context reach sees your full account-wide totals. Two exceptions to the narrowing, since they have no per-context breakdown to narrow to: `reads.calls.used`/`reads.dataOut.bytes` (metered per account, not per context) read as `0` for a confined token rather than a narrowed figure — the corresponding overage-credit charge fields narrow correctly; and `credits.limit` stays your whole plan's ceiling, so `credits.remaining` may overstate the account's true remaining room. The `execution` section narrows correctly for a confined token, like the other per-context charge fields — but note its credits carry sub-credit remainders forward across your whole account for the period, so compare `execution.creditsMilli` against your account-wide figure rather than recomputing it from one context's `billableMillis`.
3929
4006
  *
3930
4007
  * @param {Vectros.GetUsageRequest} request
3931
4008
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4493,7 +4570,7 @@ var AuthClient = class {
4493
4570
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/token");
4494
4571
  }
4495
4572
  /**
4496
- * Invite a new member to one of your app contexts by email. Creates a pending user with a pre-resolved access profile (their permissions on accept) and signs an invitation token. This call is idempotent on the combination of context and email: re-inviting the same email in the same context rotates the token and resends the invitation rather than creating a duplicate — this requires the `users:r` and `users:u` scopes in addition to `users:c`, because resending rotates a credential on an existing invitation and invalidates any link already sent. Without them the collision returns 409 instead, with no invitation details and no change to the outstanding invitation. Returns HTTP 201 on a new invite or a successful resend. Returns 409 if that email already belongs to an active or suspended member of the app context, or already has an identity elsewhere in your account (an email can currently belong to only one tenant per account, i.e. your test and live environments cannot share an email). When `sendEmail` is false, the response includes the raw token and a ready-to-use accept link so you can deliver the invitation through your own email provider. Requires the `users:c` scope.
4573
+ * Invite a new member to one of your app contexts by email, OR grant an existing member access to an additional app context by inviting their same email again. Idempotent on the combination of context and email: re-inviting the same email into the SAME context rotates the token and resends the invitation rather than creating a duplicate — this requires the `users:r` and `users:u` scopes in addition to `users:c`, because resending rotates a credential on an existing invitation and invalidates any link already sent. Without them the collision returns 409 instead, with no invitation details and no change to the outstanding invitation. Inviting the SAME email into a DIFFERENT app context in this tenant, where that email already resolves to an existing member: if that member is active AND already has (or, once accepted, will have) a credential that works for the new context's own identity provider, this immediately grants them access to the new context (no email is sent — there is nothing to accept, `emailSent` is false) — this additionally requires the `users:r` scope (no `users:u`, since nothing is mutated), because the response names the existing member's userId, a fact about them your credential could not otherwise learn through this endpoint. If that active member's ONLY existing credential is for a DIFFERENT identity provider than the one the new context uses, a normal, independent invitation is created instead (its own new member id, a real token/accept link) — attaching them silently would leave no way for them to ever actually sign in to that context. If the existing member's original invitation is still pending, this attaches the new context's access to that same outstanding invitation and rotates its token (`users:r`+`users:u`, same as an ordinary resend — both the disclosure and the credential rotation apply here). A SUSPENDED member's email does not get new-context access this way — reactivate them explicitly first. Returns HTTP 201 in every one of those cases. Returns 409 if that email already belongs to an active or suspended member of THIS specific app context, already has a PENDING invitation for THIS specific app context, or resolves to an existing member elsewhere in the tenant and your token lacks the additional scope the grant/attach requires (`users:r`, or `users:r`+`users:u` for the still-pending case). An email that already has an identity in your OTHER tenant (test vs. live) is not a collision either — it creates an additional, independent membership in this tenant for that same identity. When `sendEmail` is false, the response includes the raw token and a ready-to-use accept link so you can deliver the invitation through your own email provider. Requires the `users:c` scope — or, for a credential scoped to a single app context, the `member-lifecycle` capability plus the matching `profiles:c`/`profiles:r`/`profiles:u` grant(s) in that context, as an equally sufficient alternative to every `users:c`/`users:r`/`users:u` requirement in this description.
4497
4574
  *
4498
4575
  * @param {Vectros.CreateInviteRequest} request
4499
4576
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4564,7 +4641,7 @@ var AuthClient = class {
4564
4641
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/users/invite");
4565
4642
  }
4566
4643
  /**
4567
- * Resend an outstanding invitation, identified by its email and app context. Rotates the invitation token and extends its expiry, then (when `sendEmail` is true) re-delivers the email. Rotating the token invalidates any previously issued link for this invitation, so only the newest link works. The invitee's pending permissions are left unchanged. Because this rotates a credential on an existing invitation, it requires the `users:c`, `users:r` and `users:u` scopes.
4644
+ * Resend an outstanding invitation, identified by its email and app context. Rotates the invitation token and extends its expiry, then (when `sendEmail` is true) re-delivers the email. Rotating the token invalidates any previously issued link for this invitation, so only the newest link works. The invitee's pending permissions are left unchanged. Because this rotates a credential on an existing invitation, it requires the `users:c`, `users:r` and `users:u` scopes — or, for a credential scoped to a single app context, the `member-lifecycle` capability plus the matching `profiles:c`/`profiles:r`/`profiles:u` grant(s) in that context.
4568
4645
  *
4569
4646
  * @param {Vectros.CreateInviteRequest} request
4570
4647
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -5437,7 +5514,21 @@ var DocumentsClient = class {
5437
5514
  return HttpResponsePromise.fromPromise(this.__lookupDocuments(request, requestOptions));
5438
5515
  }
5439
5516
  async __lookupDocuments(request, requestOptions) {
5440
- const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order, userId, scope } = request;
5517
+ const {
5518
+ type: type_,
5519
+ field,
5520
+ value,
5521
+ from: from_,
5522
+ to,
5523
+ prefix,
5524
+ sortFrom,
5525
+ sortTo,
5526
+ startFrom,
5527
+ limit,
5528
+ order,
5529
+ userId,
5530
+ scope
5531
+ } = request;
5441
5532
  const _queryParams = {
5442
5533
  type: type_,
5443
5534
  field,
@@ -5445,6 +5536,8 @@ var DocumentsClient = class {
5445
5536
  from: from_,
5446
5537
  to,
5447
5538
  prefix,
5539
+ sortFrom,
5540
+ sortTo,
5448
5541
  startFrom,
5449
5542
  limit,
5450
5543
  order: order != null ? order : void 0,
@@ -6043,7 +6136,7 @@ var FoldersClient = class {
6043
6136
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/folders/{id}");
6044
6137
  }
6045
6138
  /**
6046
- * Permanently deletes a folder. The folder must be empty (contain no documents or sub-folders) and must not be protected. Your context's root folder is protected and cannot be deleted. Requires the `folders:d` scope.
6139
+ * Permanently deletes a folder. The folder must be empty — it must contain no documents, no records, and no sub-folders — and must not be protected. Your context's root folder is protected and cannot be deleted. Requires the `folders:d` scope.
6047
6140
  *
6048
6141
  * @param {Vectros.DeleteFolderRequest} request
6049
6142
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6452,11 +6545,12 @@ var IdentityClient = class {
6452
6545
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}/{id}");
6453
6546
  }
6454
6547
  /**
6455
- * 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.
6548
+ * 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. Supplying a different `externalId` re-points the entity's identifier; it must still be unused in this namespace and app context. Requires the `entities:u:<namespace>` scope.
6456
6549
  *
6457
6550
  * @param {Vectros.UpdateEntityRequest} request
6458
6551
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6459
6552
  *
6553
+ * @throws {@link Vectros.BadRequestError}
6460
6554
  * @throws {@link Vectros.NotFoundError}
6461
6555
  * @throws {@link Vectros.TooManyRequestsError}
6462
6556
  *
@@ -6506,6 +6600,8 @@ var IdentityClient = class {
6506
6600
  }
6507
6601
  if (_response.error.reason === "status-code") {
6508
6602
  switch (_response.error.statusCode) {
6603
+ case 400:
6604
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
6509
6605
  case 404:
6510
6606
  throw new NotFoundError(_response.error.body, _response.rawResponse);
6511
6607
  case 429:
@@ -7730,7 +7826,7 @@ var InferenceClient = class {
7730
7826
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/documents/{id}/ask");
7731
7827
  }
7732
7828
  /**
7733
- * Runs hybrid search over your indexed content, then streams a model answer grounded in the top results. The SSE stream emits a `search_results` event first (carrying the matched results and their metadata), an optional `truncation_warning` if lower-scoring results were dropped to fit the model's context window, then `content_delta` chunks, and finally a terminal `done` event. Requires the `inference:r` scope.
7829
+ * Runs hybrid search over your indexed content, then streams a model answer grounded in the top results. The SSE stream emits a `search_results` event first (carrying the matched results and their metadata), an optional `truncation_warning` if some retrieved results were dropped before the prompt was built — either because they didn't fit the model's context window or because a result had no groundable text to include — then `content_delta` chunks, and finally a terminal `done` event. Requires the `inference:r` scope.
7734
7830
  */
7735
7831
  ragInference(request, requestOptions) {
7736
7832
  return HttpResponsePromise.fromPromise(this.__ragInference(request, requestOptions));
@@ -7925,14 +8021,18 @@ var RecordsClient = class {
7925
8021
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/records/lookup/batch");
7926
8022
  }
7927
8023
  /**
7928
- * Reserved endpoint for bulk record writes. The published response shape includes a per-item partial-failure envelope and an atomicity flag. It currently returns 501 (not implemented). The documented 200 response schema is the stable shape this endpoint will use once available, published now so SDK integrations against it will not break when it ships. Requires the `records:c` scope.
8024
+ * Writes up to 50 records (or 50 with `atomicity: all_or_nothing`) in a single request. Each item in `items` has exactly the same shape, and goes through exactly the same validation, authorization and idempotency rules, as the body of a single `POST /v1/records` — including schema validation, `externalId` idempotency, unique-field enforcement, and the `records:c:<type>` scope check, which is applied per item against that item's own record type. A batch is not a way to write a type your credential could not write one at a time.
8025
+ *
8026
+ * `atomicity` selects how the batch commits. `best_effort` (the default) writes each item independently: some can succeed while others fail, and each item's own outcome is reported. `all_or_nothing` commits every item in one transaction — if any item fails, no record is created or updated at all, and every item that was itself fine reports `not_committed` while the ones that failed report why. Because the transaction is bounded by the number of underlying storage rows rather than by the number of records, a large `all_or_nothing` batch can be refused as too large to commit atomically even when it is within the item limit; the error says so, and nothing is written when it happens.
8027
+ *
8028
+ * The response is HTTP 200 whenever the batch was processed at all — including when every item failed — so always inspect `results` rather than relying on the status code. Match each result to the item you sent using its `index`. Requires the `records:c` scope.
7929
8029
  *
7930
8030
  * @param {Vectros.BatchWriteRequest} request
7931
8031
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
7932
8032
  *
8033
+ * @throws {@link Vectros.BadRequestError}
7933
8034
  * @throws {@link Vectros.ForbiddenError}
7934
8035
  * @throws {@link Vectros.TooManyRequestsError}
7935
- * @throws {@link Vectros.NotImplementedError}
7936
8036
  *
7937
8037
  * @example
7938
8038
  * await client.records.batchWriteRecords()
@@ -7941,6 +8041,11 @@ var RecordsClient = class {
7941
8041
  return HttpResponsePromise.fromPromise(this.__batchWriteRecords(request, requestOptions));
7942
8042
  }
7943
8043
  async __batchWriteRecords(request = {}, requestOptions) {
8044
+ const { upsert, allowClear, ..._body } = request;
8045
+ const _queryParams = {
8046
+ upsert,
8047
+ allowClear
8048
+ };
7944
8049
  const _authRequest = await this._options.authProvider.getAuthRequest();
7945
8050
  const _headers = mergeHeaders(
7946
8051
  _authRequest.headers,
@@ -7955,9 +8060,9 @@ var RecordsClient = class {
7955
8060
  method: "POST",
7956
8061
  headers: _headers,
7957
8062
  contentType: "application/json",
7958
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
8063
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
7959
8064
  requestType: "json",
7960
- body: request,
8065
+ body: _body,
7961
8066
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
7962
8067
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
7963
8068
  abortSignal: requestOptions?.abortSignal,
@@ -7969,12 +8074,12 @@ var RecordsClient = class {
7969
8074
  }
7970
8075
  if (_response.error.reason === "status-code") {
7971
8076
  switch (_response.error.statusCode) {
8077
+ case 400:
8078
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
7972
8079
  case 403:
7973
8080
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
7974
8081
  case 429:
7975
8082
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
7976
- case 501:
7977
- throw new NotImplementedError(_response.error.body, _response.rawResponse);
7978
8083
  default:
7979
8084
  throw new VectrosError({
7980
8085
  statusCode: _response.error.statusCode,
@@ -8877,7 +8982,7 @@ var SchemasClient = class {
8877
8982
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}");
8878
8983
  }
8879
8984
  /**
8880
- * Updates a record schema. Fields you omit are preserved; `typeName` is immutable and cannot be changed. Collection fields (`fields`, `lookupFields`, `renderHints`, `capabilities`) are replaced in full when supplied. Requires the `schemas:u` scope.
8985
+ * Updates a record schema. Fields you omit are preserved; `typeName` is immutable and cannot be changed. Collection fields (`fields`, `lookupFields`, `renderHints`, `capabilities`) are replaced in full when supplied. Because `capabilities` is replaced in full, omitting `triggersEnabled` clears it — the request is refused with 409 if that would disable triggers while trigger rules still fire off this schema, so delete those rules first. Requires the `schemas:u` scope.
8881
8986
  *
8882
8987
  * @param {Vectros.UpdateSchemaRequest} request
8883
8988
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8885,6 +8990,7 @@ var SchemasClient = class {
8885
8990
  * @throws {@link Vectros.BadRequestError}
8886
8991
  * @throws {@link Vectros.ForbiddenError}
8887
8992
  * @throws {@link Vectros.NotFoundError}
8993
+ * @throws {@link Vectros.ConflictError}
8888
8994
  * @throws {@link Vectros.TooManyRequestsError}
8889
8995
  *
8890
8996
  * @example
@@ -8936,6 +9042,8 @@ var SchemasClient = class {
8936
9042
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
8937
9043
  case 404:
8938
9044
  throw new NotFoundError(_response.error.body, _response.rawResponse);
9045
+ case 409:
9046
+ throw new ConflictError(_response.error.body, _response.rawResponse);
8939
9047
  case 429:
8940
9048
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
8941
9049
  default:
@@ -8949,7 +9057,7 @@ var SchemasClient = class {
8949
9057
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/schemas/{id}");
8950
9058
  }
8951
9059
  /**
8952
- * Permanently deletes a record schema. The request is refused with 409 if records of this type still exist — delete those records first, since every record must reference a live schema. A lineage base (a schema other schemas declare `basedOn`) also cannot be deleted while any such variant still exists — delete the variant schema(s) first. Requires the `schemas:d` scope.
9060
+ * Permanently deletes a record schema. The request is refused with 409 if records of this type still exist — delete those records first, since every record must reference a live schema. A lineage base (a schema other schemas declare `basedOn`) also cannot be deleted while any such variant still exists — delete the variant schema(s) first. It is likewise refused while any trigger rule fires off this schema — delete those trigger rules first. Requires the `schemas:d` scope.
8953
9061
  *
8954
9062
  * @param {Vectros.DeleteSchemaRequest} request
8955
9063
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -9071,46 +9179,70 @@ var SchemasClient = class {
9071
9179
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}/versions");
9072
9180
  }
9073
9181
  };
9074
- var SearchClient = class {
9182
+ var ScriptsClient = class {
9075
9183
  constructor(options) {
9076
9184
  this._options = normalizeClientOptionsWithAuth(options);
9077
9185
  }
9078
9186
  /**
9079
- * Runs a hybrid, semantic, or text search across the content you have indexed. By default it returns both documents and records in a single unified result set; pass `contentTypes` to narrow the results (for example `["documents"]`). Each result carries a `sourceType` discriminator (`PartnerDocument` or `GenericRecord`) so you can branch on the type. Requires the `search:r` scope.
9187
+ * Runs a script you previously pushed to `POST /v1/scripts`, under your own credential, and returns what it returned. Every write the script makes is buffered and committed as ONE transaction after the script finishes: either all of them land or none do, and the response is sent only after they have committed — so everything in `result` is committed state or the script's own computation over it. On any failure the body is the standard error envelope and nothing the script staged is committed: its rows are written only when the transaction commits, and a document body or a large payload is DECIDED at that point and WRITTEN to storage only after the commit, so an aborted execution leaves nothing behind. The one residual sits after a successful commit, outside this response: if storing a body fails then, the row exists and the body does not until the platform's repair lands — so a `200` guarantees the rows, and a document's text should be read before it is relied on.
9080
9188
  *
9081
- * @param {Vectros.SearchRequest} request
9082
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
9189
+ * **Permission.** Requires the `scripts:x` scope — the permission to *execute* — separate from the `scripts:c` permission to push scripts. Bare `scripts:x` grants every script in the context; `scripts:x:<name>` grants exactly that script name, every version of it. Execution discloses no source, so `scripts:r` is not needed. Inside the script, every read and write is enforced by your credential's data scopes exactly as the equivalent REST call would be — `scripts:x` alone can read and write nothing.
9190
+ *
9191
+ * **Input.** Your script sees `input.event` (the literal `"execute"`), `input.userId` (your credential's user id, or null), and `input.params` (the `input` object you sent, verbatim). That is the same `input` grammar a trigger rule uses, so one script can serve both by branching on `input.event`. `params` is not validated — a script that needs a shape checks for it and throws; the script's `declaredInputContract` is documentation for readers and is not enforced.
9192
+ *
9193
+ * **Budget.** Seconds of useful work: the script has 15 s of wall clock (never more than 16) and a bounded number of statements and host calls; a runaway script is stopped early with `RESOURCE_LIMIT_EXCEEDED`. The transaction is bounded by the number of underlying storage rows it writes — 100 rows after merging — rather than by the number of entities: creating a folder costs 3 rows; creating a plain text document or a record costs 1 row plus one per range-indexed lookup field plus one per `reference` field. So "create a folder and file N documents" holds up to 97 plain documents, 48 with one range field or one reference, 32 with both; if a script exceeds the limit the error says so (`WRITE_BUFFER_CAP_EXCEEDED`, with `total` and `limit`) and nothing is committed. This request takes the write-path limits (burst, credit ceiling, principal quota) once, before the script runs — there is no free-read allowance here, so an account over its credit ceiling is refused even for a read-only script. Reads the script performs are metered as reads, writes as writes, and execution time beyond what those operations include is charged as script execution time (see `GET /v1/usage`).
9194
+ *
9195
+ * **Reads inside the script.** A `get` sees the script's own staged writes. A list, query or lookup never shows a row the script has deleted, shows a row it re-saved with the updated content, and does not yet show a row it created — you hold that row's id from `create()`.
9196
+ *
9197
+ * **Retries.** Send an optional `Idempotency-Key` header (1–128 characters of letters, digits, `.`, `_`, `:` or `-`) to make a retry safe: a request repeated under the same key within 24 hours receives the same response as the first attempt without executing again — when that first attempt SUCCEEDED (a duplicate still in flight is refused with `409 IDEMPOTENCY_IN_PROGRESS`; the same key on a different request is refused with `422 IDEMPOTENCY_KEY_REUSED`). A first attempt that FAILED with any other status is not remembered: the same key is free to try again, so a retry after a `400` or a `429` executes. If an execution's outcome cannot be determined — the script did not finish inside the budget while its writes may have committed — the response is `500 EXECUTION_OUTCOME_UNKNOWN` carrying `execution.id`, and a keyed retry receives that same answer: inspect what the script would have written, then use a NEW key for a new attempt. When a key is present the serialised `result` is capped at 16 KB instead of 256 KB. Without a key, a lost response cannot be distinguished from a failed one; re-read before retrying.
9198
+ *
9199
+ * @param {Vectros.ScriptExecuteRequest} request
9200
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9083
9201
  *
9084
9202
  * @throws {@link Vectros.BadRequestError}
9203
+ * @throws {@link Vectros.PaymentRequiredError}
9085
9204
  * @throws {@link Vectros.ForbiddenError}
9205
+ * @throws {@link Vectros.NotFoundError}
9206
+ * @throws {@link Vectros.ConflictError}
9207
+ * @throws {@link Vectros.ContentTooLargeError}
9208
+ * @throws {@link Vectros.UnprocessableEntityError}
9086
9209
  * @throws {@link Vectros.TooManyRequestsError}
9210
+ * @throws {@link Vectros.InternalServerError}
9211
+ * @throws {@link Vectros.ServiceUnavailableError}
9212
+ * @throws {@link Vectros.GatewayTimeoutError}
9087
9213
  *
9088
9214
  * @example
9089
- * await client.search.content({
9090
- * query: "patient intake form diabetes"
9215
+ * await client.scripts.executeScript({
9216
+ * "Idempotency-Key": "order-8412-attempt",
9217
+ * scriptRef: {
9218
+ * name: "notify-assignee",
9219
+ * version: "3"
9220
+ * }
9091
9221
  * })
9092
9222
  */
9093
- content(request, requestOptions) {
9094
- return HttpResponsePromise.fromPromise(this.__content(request, requestOptions));
9223
+ executeScript(request, requestOptions) {
9224
+ return HttpResponsePromise.fromPromise(this.__executeScript(request, requestOptions));
9095
9225
  }
9096
- async __content(request, requestOptions) {
9226
+ async __executeScript(request, requestOptions) {
9227
+ const { "Idempotency-Key": idempotencyKey, ..._body } = request;
9097
9228
  const _authRequest = await this._options.authProvider.getAuthRequest();
9098
9229
  const _headers = mergeHeaders(
9099
9230
  _authRequest.headers,
9100
9231
  this._options?.headers,
9232
+ mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey }),
9101
9233
  requestOptions?.headers
9102
9234
  );
9103
9235
  const _response = await fetcher({
9104
9236
  url: url_exports.join(
9105
9237
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9106
- "v1/search"
9238
+ "v1/scripts/execute"
9107
9239
  ),
9108
9240
  method: "POST",
9109
9241
  headers: _headers,
9110
9242
  contentType: "application/json",
9111
9243
  queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9112
9244
  requestType: "json",
9113
- body: request,
9245
+ body: _body,
9114
9246
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9115
9247
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9116
9248
  abortSignal: requestOptions?.abortSignal,
@@ -9124,10 +9256,26 @@ var SearchClient = class {
9124
9256
  switch (_response.error.statusCode) {
9125
9257
  case 400:
9126
9258
  throw new BadRequestError(_response.error.body, _response.rawResponse);
9259
+ case 402:
9260
+ throw new PaymentRequiredError(_response.error.body, _response.rawResponse);
9127
9261
  case 403:
9128
9262
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
9263
+ case 404:
9264
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9265
+ case 409:
9266
+ throw new ConflictError(_response.error.body, _response.rawResponse);
9267
+ case 413:
9268
+ throw new ContentTooLargeError(_response.error.body, _response.rawResponse);
9269
+ case 422:
9270
+ throw new UnprocessableEntityError(_response.error.body, _response.rawResponse);
9129
9271
  case 429:
9130
9272
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9273
+ case 500:
9274
+ throw new InternalServerError(_response.error.body, _response.rawResponse);
9275
+ case 503:
9276
+ throw new ServiceUnavailableError(_response.error.body, _response.rawResponse);
9277
+ case 504:
9278
+ throw new GatewayTimeoutError(_response.error.body, _response.rawResponse);
9131
9279
  default:
9132
9280
  throw new VectrosError({
9133
9281
  statusCode: _response.error.statusCode,
@@ -9136,108 +9284,871 @@ var SearchClient = class {
9136
9284
  });
9137
9285
  }
9138
9286
  }
9139
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/search");
9140
- }
9141
- };
9142
- var VectrosClient = class {
9143
- constructor(options) {
9144
- this._options = normalizeClientOptionsWithAuth(options);
9145
- }
9146
- get auth() {
9147
- return this._auth ?? (this._auth = new AuthClient(this._options));
9148
- }
9149
- get documents() {
9150
- return this._documents ?? (this._documents = new DocumentsClient(this._options));
9151
- }
9152
- get identity() {
9153
- return this._identity ?? (this._identity = new IdentityClient(this._options));
9154
- }
9155
- get compliance() {
9156
- return this._compliance ?? (this._compliance = new ComplianceClient(this._options));
9157
- }
9158
- get folders() {
9159
- return this._folders ?? (this._folders = new FoldersClient(this._options));
9160
- }
9161
- get inference() {
9162
- return this._inference ?? (this._inference = new InferenceClient(this._options));
9163
- }
9164
- get records() {
9165
- return this._records ?? (this._records = new RecordsClient(this._options));
9166
- }
9167
- get schemas() {
9168
- return this._schemas ?? (this._schemas = new SchemasClient(this._options));
9169
- }
9170
- get search() {
9171
- return this._search ?? (this._search = new SearchClient(this._options));
9287
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/scripts/execute");
9172
9288
  }
9173
9289
  /**
9174
- * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
9175
- * This is useful for making requests to endpoints not yet supported in the SDK.
9176
- * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
9290
+ * Returns a paginated list of your scripts. Pass `name` to list every version of one script name (oldest first); omit it for a flat list across every name in your account (newest first). Results are returned as a `{data, nextCursor}` envelope — pass `nextCursor` as `startFrom` to fetch the next page. Requires the `scripts:r` scope.
9177
9291
  *
9178
- * @param {Request | string | URL} input - The URL, path, or Request object.
9179
- * @param {RequestInit} init - Standard fetch RequestInit options.
9180
- * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
9181
- * @returns {Promise<Response>} A standard Response object.
9292
+ * @param {Vectros.ListScriptsRequest} request
9293
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9294
+ *
9295
+ * @example
9296
+ * await client.scripts.listScripts({
9297
+ * name: "notify-assignee",
9298
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9299
+ * })
9182
9300
  */
9183
- async fetch(input, init, requestOptions) {
9184
- return makePassthroughRequest(
9185
- input,
9186
- init,
9187
- {
9188
- baseUrl: this._options.baseUrl ?? this._options.environment,
9189
- headers: this._options.headers,
9190
- timeoutInSeconds: this._options.timeoutInSeconds,
9191
- maxRetries: this._options.maxRetries,
9192
- fetch: this._options.fetch,
9193
- logging: this._options.logging,
9194
- getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers
9195
- },
9196
- requestOptions
9197
- );
9198
- }
9199
- };
9200
- var logging;
9201
- ((logging2) => {
9202
- logging2.LogLevel = LogLevel;
9203
- logging2.ConsoleLogger = ConsoleLogger;
9204
- })(logging || (logging = {}));
9205
-
9206
- // src/server.ts
9207
- import {
9208
- CallToolRequestSchema,
9209
- ListResourcesRequestSchema,
9210
- ListToolsRequestSchema,
9211
- ReadResourceRequestSchema
9212
- } from "@modelcontextprotocol/sdk/types.js";
9213
- import { z as z23 } from "zod";
9214
-
9215
- // src/auth.ts
9216
- var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
9217
- var InvalidApiKeyError = class extends Error {
9218
- constructor(reason) {
9219
- super(`Invalid VECTROS_API_KEY: ${reason}`);
9220
- this.name = "InvalidApiKeyError";
9221
- }
9222
- };
9223
- function parseApiKey(raw) {
9224
- if (!raw || raw.trim().length === 0) {
9225
- throw new InvalidApiKeyError(
9226
- "env var is missing or empty. Set VECTROS_API_KEY to a Vectros key (recommended: ssk_live_... or ssk_test_...)."
9227
- );
9301
+ listScripts(request = {}, requestOptions) {
9302
+ return HttpResponsePromise.fromPromise(this.__listScripts(request, requestOptions));
9228
9303
  }
9229
- const match = raw.match(KEY_RE);
9230
- if (!match) {
9231
- throw new InvalidApiKeyError(
9232
- `key must start with sk_, ssk_, or st_ followed by "live_" or "test_". Got prefix "${raw.slice(0, 12)}...".`
9304
+ async __listScripts(request = {}, requestOptions) {
9305
+ const { name, startFrom, limit } = request;
9306
+ const _queryParams = {
9307
+ name,
9308
+ startFrom,
9309
+ limit
9310
+ };
9311
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9312
+ const _headers = mergeHeaders(
9313
+ _authRequest.headers,
9314
+ this._options?.headers,
9315
+ requestOptions?.headers
9233
9316
  );
9317
+ const _response = await fetcher({
9318
+ url: url_exports.join(
9319
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9320
+ "v1/scripts"
9321
+ ),
9322
+ method: "GET",
9323
+ headers: _headers,
9324
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9325
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9326
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9327
+ abortSignal: requestOptions?.abortSignal,
9328
+ fetchFn: this._options?.fetch,
9329
+ logging: this._options.logging
9330
+ });
9331
+ if (_response.ok) {
9332
+ return { data: _response.body, rawResponse: _response.rawResponse };
9333
+ }
9334
+ if (_response.error.reason === "status-code") {
9335
+ throw new VectrosError({
9336
+ statusCode: _response.error.statusCode,
9337
+ body: _response.error.body,
9338
+ rawResponse: _response.rawResponse
9339
+ });
9340
+ }
9341
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/scripts");
9234
9342
  }
9235
- return {
9236
- prefix: match[1],
9237
- env: match[2],
9238
- raw
9239
- };
9240
- }
9343
+ /**
9344
+ * Stores a new version of a script object. Every POST creates a genuinely new version — this is NOT idempotent-by-name: pushing `name` again always creates a new row with `scriptVersion` auto-incremented (the first version pushed for a name is 1). `source` is stored as-is: nothing parses or validates it at push time. A version runs when a trigger rule references it (`POST /v1/triggers`) or when `POST /v1/scripts/execute` names it. Requires the `scripts:c` scope.
9345
+ *
9346
+ * @param {Vectros.ScriptRequest} request
9347
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9348
+ *
9349
+ * @throws {@link Vectros.BadRequestError}
9350
+ * @throws {@link Vectros.ForbiddenError}
9351
+ * @throws {@link Vectros.ConflictError}
9352
+ * @throws {@link Vectros.TooManyRequestsError}
9353
+ *
9354
+ * @example
9355
+ * await client.scripts.createScript({
9356
+ * name: "notify-assignee",
9357
+ * source: "export default function(input) { return { ok: true }; }"
9358
+ * })
9359
+ */
9360
+ createScript(request, requestOptions) {
9361
+ return HttpResponsePromise.fromPromise(this.__createScript(request, requestOptions));
9362
+ }
9363
+ async __createScript(request, requestOptions) {
9364
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9365
+ const _headers = mergeHeaders(
9366
+ _authRequest.headers,
9367
+ this._options?.headers,
9368
+ requestOptions?.headers
9369
+ );
9370
+ const _response = await fetcher({
9371
+ url: url_exports.join(
9372
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9373
+ "v1/scripts"
9374
+ ),
9375
+ method: "POST",
9376
+ headers: _headers,
9377
+ contentType: "application/json",
9378
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9379
+ requestType: "json",
9380
+ body: request,
9381
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9382
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9383
+ abortSignal: requestOptions?.abortSignal,
9384
+ fetchFn: this._options?.fetch,
9385
+ logging: this._options.logging
9386
+ });
9387
+ if (_response.ok) {
9388
+ return { data: _response.body, rawResponse: _response.rawResponse };
9389
+ }
9390
+ if (_response.error.reason === "status-code") {
9391
+ switch (_response.error.statusCode) {
9392
+ case 400:
9393
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9394
+ case 403:
9395
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9396
+ case 409:
9397
+ throw new ConflictError(_response.error.body, _response.rawResponse);
9398
+ case 429:
9399
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9400
+ default:
9401
+ throw new VectrosError({
9402
+ statusCode: _response.error.statusCode,
9403
+ body: _response.error.body,
9404
+ rawResponse: _response.rawResponse
9405
+ });
9406
+ }
9407
+ }
9408
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/scripts");
9409
+ }
9410
+ /**
9411
+ * Retrieves a single script version by its ID. Requires the `scripts:r` scope.
9412
+ *
9413
+ * @param {Vectros.GetScriptRequest} request
9414
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9415
+ *
9416
+ * @throws {@link Vectros.NotFoundError}
9417
+ *
9418
+ * @example
9419
+ * await client.scripts.getScript({
9420
+ * id: "id"
9421
+ * })
9422
+ */
9423
+ getScript(request, requestOptions) {
9424
+ return HttpResponsePromise.fromPromise(this.__getScript(request, requestOptions));
9425
+ }
9426
+ async __getScript(request, requestOptions) {
9427
+ const { id } = request;
9428
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9429
+ const _headers = mergeHeaders(
9430
+ _authRequest.headers,
9431
+ this._options?.headers,
9432
+ requestOptions?.headers
9433
+ );
9434
+ const _response = await fetcher({
9435
+ url: url_exports.join(
9436
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9437
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9438
+ ),
9439
+ method: "GET",
9440
+ headers: _headers,
9441
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9442
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9443
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9444
+ abortSignal: requestOptions?.abortSignal,
9445
+ fetchFn: this._options?.fetch,
9446
+ logging: this._options.logging
9447
+ });
9448
+ if (_response.ok) {
9449
+ return { data: _response.body, rawResponse: _response.rawResponse };
9450
+ }
9451
+ if (_response.error.reason === "status-code") {
9452
+ switch (_response.error.statusCode) {
9453
+ case 404:
9454
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9455
+ default:
9456
+ throw new VectrosError({
9457
+ statusCode: _response.error.statusCode,
9458
+ body: _response.error.body,
9459
+ rawResponse: _response.rawResponse
9460
+ });
9461
+ }
9462
+ }
9463
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/scripts/{id}");
9464
+ }
9465
+ /**
9466
+ * Scripts are immutable per version; this endpoint always returns a 400 regardless of scope or credential — push a new version via `POST /v1/scripts` instead.
9467
+ *
9468
+ * @param {Vectros.UpdateScriptRequest} request
9469
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9470
+ *
9471
+ * @throws {@link Vectros.BadRequestError}
9472
+ * @throws {@link Vectros.TooManyRequestsError}
9473
+ *
9474
+ * @example
9475
+ * await client.scripts.updateScript({
9476
+ * id: "id",
9477
+ * body: {
9478
+ * name: "notify-assignee",
9479
+ * source: "export default function(input) { return { ok: true }; }"
9480
+ * }
9481
+ * })
9482
+ */
9483
+ updateScript(request, requestOptions) {
9484
+ return HttpResponsePromise.fromPromise(this.__updateScript(request, requestOptions));
9485
+ }
9486
+ async __updateScript(request, requestOptions) {
9487
+ const { id, body: _body } = request;
9488
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9489
+ const _headers = mergeHeaders(
9490
+ _authRequest.headers,
9491
+ this._options?.headers,
9492
+ requestOptions?.headers
9493
+ );
9494
+ const _response = await fetcher({
9495
+ url: url_exports.join(
9496
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9497
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9498
+ ),
9499
+ method: "PUT",
9500
+ headers: _headers,
9501
+ contentType: "application/json",
9502
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9503
+ requestType: "json",
9504
+ body: _body,
9505
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9506
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9507
+ abortSignal: requestOptions?.abortSignal,
9508
+ fetchFn: this._options?.fetch,
9509
+ logging: this._options.logging
9510
+ });
9511
+ if (_response.ok) {
9512
+ return { data: void 0, rawResponse: _response.rawResponse };
9513
+ }
9514
+ if (_response.error.reason === "status-code") {
9515
+ switch (_response.error.statusCode) {
9516
+ case 400:
9517
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9518
+ case 429:
9519
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9520
+ default:
9521
+ throw new VectrosError({
9522
+ statusCode: _response.error.statusCode,
9523
+ body: _response.error.body,
9524
+ rawResponse: _response.rawResponse
9525
+ });
9526
+ }
9527
+ }
9528
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/scripts/{id}");
9529
+ }
9530
+ /**
9531
+ * Permanently deletes one script version by ID. Deleting one version does not affect any other version of the same name. Requires the `scripts:d` scope.
9532
+ *
9533
+ * @param {Vectros.DeleteScriptRequest} request
9534
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9535
+ *
9536
+ * @throws {@link Vectros.NotFoundError}
9537
+ * @throws {@link Vectros.TooManyRequestsError}
9538
+ *
9539
+ * @example
9540
+ * await client.scripts.deleteScript({
9541
+ * id: "id"
9542
+ * })
9543
+ */
9544
+ deleteScript(request, requestOptions) {
9545
+ return HttpResponsePromise.fromPromise(this.__deleteScript(request, requestOptions));
9546
+ }
9547
+ async __deleteScript(request, requestOptions) {
9548
+ const { id } = request;
9549
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9550
+ const _headers = mergeHeaders(
9551
+ _authRequest.headers,
9552
+ this._options?.headers,
9553
+ requestOptions?.headers
9554
+ );
9555
+ const _response = await fetcher({
9556
+ url: url_exports.join(
9557
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9558
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9559
+ ),
9560
+ method: "DELETE",
9561
+ headers: _headers,
9562
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9563
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9564
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9565
+ abortSignal: requestOptions?.abortSignal,
9566
+ fetchFn: this._options?.fetch,
9567
+ logging: this._options.logging
9568
+ });
9569
+ if (_response.ok) {
9570
+ return { data: void 0, rawResponse: _response.rawResponse };
9571
+ }
9572
+ if (_response.error.reason === "status-code") {
9573
+ switch (_response.error.statusCode) {
9574
+ case 404:
9575
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9576
+ case 429:
9577
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9578
+ default:
9579
+ throw new VectrosError({
9580
+ statusCode: _response.error.statusCode,
9581
+ body: _response.error.body,
9582
+ rawResponse: _response.rawResponse
9583
+ });
9584
+ }
9585
+ }
9586
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/scripts/{id}");
9587
+ }
9588
+ };
9589
+ var SearchClient = class {
9590
+ constructor(options) {
9591
+ this._options = normalizeClientOptionsWithAuth(options);
9592
+ }
9593
+ /**
9594
+ * Runs a hybrid, semantic, or text search across the content you have indexed. By default it returns both documents and records in a single unified result set; pass `contentTypes` to narrow the results (for example `["documents"]`). Each result carries a `sourceType` discriminator (`PartnerDocument` or `GenericRecord`) so you can branch on the type. Requires the `search:r` scope.
9595
+ *
9596
+ * @param {Vectros.SearchRequest} request
9597
+ * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
9598
+ *
9599
+ * @throws {@link Vectros.BadRequestError}
9600
+ * @throws {@link Vectros.ForbiddenError}
9601
+ * @throws {@link Vectros.TooManyRequestsError}
9602
+ *
9603
+ * @example
9604
+ * await client.search.content({
9605
+ * query: "patient intake form diabetes"
9606
+ * })
9607
+ */
9608
+ content(request, requestOptions) {
9609
+ return HttpResponsePromise.fromPromise(this.__content(request, requestOptions));
9610
+ }
9611
+ async __content(request, requestOptions) {
9612
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9613
+ const _headers = mergeHeaders(
9614
+ _authRequest.headers,
9615
+ this._options?.headers,
9616
+ requestOptions?.headers
9617
+ );
9618
+ const _response = await fetcher({
9619
+ url: url_exports.join(
9620
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9621
+ "v1/search"
9622
+ ),
9623
+ method: "POST",
9624
+ headers: _headers,
9625
+ contentType: "application/json",
9626
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9627
+ requestType: "json",
9628
+ body: request,
9629
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9630
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9631
+ abortSignal: requestOptions?.abortSignal,
9632
+ fetchFn: this._options?.fetch,
9633
+ logging: this._options.logging
9634
+ });
9635
+ if (_response.ok) {
9636
+ return { data: _response.body, rawResponse: _response.rawResponse };
9637
+ }
9638
+ if (_response.error.reason === "status-code") {
9639
+ switch (_response.error.statusCode) {
9640
+ case 400:
9641
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9642
+ case 403:
9643
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9644
+ case 429:
9645
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9646
+ default:
9647
+ throw new VectrosError({
9648
+ statusCode: _response.error.statusCode,
9649
+ body: _response.error.body,
9650
+ rawResponse: _response.rawResponse
9651
+ });
9652
+ }
9653
+ }
9654
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/search");
9655
+ }
9656
+ };
9657
+ var TriggersClient = class {
9658
+ constructor(options) {
9659
+ this._options = normalizeClientOptionsWithAuth(options);
9660
+ }
9661
+ /**
9662
+ * Returns a page of trigger executions that failed — what went wrong, whether the platform will retry it, and which of your records and rules were involved. Use this to find automation that has stopped running.
9663
+ *
9664
+ * A record appears once per FIRING, not once per attempt: if the platform retries a retryable failure, the same record's `attempts` count rises rather than a new record appearing. **If a retry later succeeds, the record is removed** — so this endpoint describes what is currently broken, not a permanent history. Records also expire 30 days after the firing first failed.
9665
+ *
9666
+ * `detail` is safe to surface to your own users: it carries only your own content (a script's own thrown message) or public API vocabulary, never platform internals. For `INTERNAL_ERROR` it is absent and a `correlationId` is returned instead — quote that to support.
9667
+ *
9668
+ * Scoped to your account and app context, derived from your token — never from input. Requires the `triggers:r` scope.
9669
+ *
9670
+ * @param {Vectros.ListTriggerFailuresRequest} request
9671
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9672
+ *
9673
+ * @example
9674
+ * await client.triggers.listTriggerFailures({
9675
+ * ruleId: "3b1c9f2e7a5d8410f6c2e9a1b7d4038f5e6a91c2d7f0b3a4586c9e2f1d0a7b3c",
9676
+ * category: "SCRIPT_ERROR",
9677
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9678
+ * })
9679
+ */
9680
+ listTriggerFailures(request = {}, requestOptions) {
9681
+ return HttpResponsePromise.fromPromise(this.__listTriggerFailures(request, requestOptions));
9682
+ }
9683
+ async __listTriggerFailures(request = {}, requestOptions) {
9684
+ const { ruleId, category, retryable, from: from_, to, startFrom, limit } = request;
9685
+ const _queryParams = {
9686
+ ruleId,
9687
+ category,
9688
+ retryable,
9689
+ from: from_,
9690
+ to,
9691
+ startFrom,
9692
+ limit
9693
+ };
9694
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9695
+ const _headers = mergeHeaders(
9696
+ _authRequest.headers,
9697
+ this._options?.headers,
9698
+ requestOptions?.headers
9699
+ );
9700
+ const _response = await fetcher({
9701
+ url: url_exports.join(
9702
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9703
+ "v1/trigger-failures"
9704
+ ),
9705
+ method: "GET",
9706
+ headers: _headers,
9707
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9708
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9709
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9710
+ abortSignal: requestOptions?.abortSignal,
9711
+ fetchFn: this._options?.fetch,
9712
+ logging: this._options.logging
9713
+ });
9714
+ if (_response.ok) {
9715
+ return { data: _response.body, rawResponse: _response.rawResponse };
9716
+ }
9717
+ if (_response.error.reason === "status-code") {
9718
+ throw new VectrosError({
9719
+ statusCode: _response.error.statusCode,
9720
+ body: _response.error.body,
9721
+ rawResponse: _response.rawResponse
9722
+ });
9723
+ }
9724
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/trigger-failures");
9725
+ }
9726
+ /**
9727
+ * Returns a paginated list of your trigger rules, newest first. Results are returned as a `{data, nextCursor}` envelope — pass `nextCursor` as `startFrom` to fetch the next page. Requires the `triggers:r` scope.
9728
+ *
9729
+ * @param {Vectros.ListTriggersRequest} request
9730
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9731
+ *
9732
+ * @example
9733
+ * await client.triggers.listTriggers({
9734
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9735
+ * })
9736
+ */
9737
+ listTriggers(request = {}, requestOptions) {
9738
+ return HttpResponsePromise.fromPromise(this.__listTriggers(request, requestOptions));
9739
+ }
9740
+ async __listTriggers(request = {}, requestOptions) {
9741
+ const { startFrom, limit } = request;
9742
+ const _queryParams = {
9743
+ startFrom,
9744
+ limit
9745
+ };
9746
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9747
+ const _headers = mergeHeaders(
9748
+ _authRequest.headers,
9749
+ this._options?.headers,
9750
+ requestOptions?.headers
9751
+ );
9752
+ const _response = await fetcher({
9753
+ url: url_exports.join(
9754
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9755
+ "v1/triggers"
9756
+ ),
9757
+ method: "GET",
9758
+ headers: _headers,
9759
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9760
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9761
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9762
+ abortSignal: requestOptions?.abortSignal,
9763
+ fetchFn: this._options?.fetch,
9764
+ logging: this._options.logging
9765
+ });
9766
+ if (_response.ok) {
9767
+ return { data: _response.body, rawResponse: _response.rawResponse };
9768
+ }
9769
+ if (_response.error.reason === "status-code") {
9770
+ throw new VectrosError({
9771
+ statusCode: _response.error.statusCode,
9772
+ body: _response.error.body,
9773
+ rawResponse: _response.rawResponse
9774
+ });
9775
+ }
9776
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/triggers");
9777
+ }
9778
+ /**
9779
+ * Declares a new trigger rule, or (with `?upsert=true`) reconciles an existing one of the same name to the submitted shape. Once declared, the rule fires: a record write on the named schema dispatches the referenced script, which runs asynchronously under this rule's own grant. Because that grant is executed, a scoped credential may not declare a trigger whose grant exceeds its own — such a request is rejected with a `403`, and a `roleIds` entry that does not resolve in this context with a `400`. Requires the `triggers:c` scope (also `triggers:u` when `?upsert=true` matches an existing row).
9780
+ *
9781
+ * @param {Vectros.CreateTriggerRequest} request
9782
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9783
+ *
9784
+ * @throws {@link Vectros.BadRequestError}
9785
+ * @throws {@link Vectros.ForbiddenError}
9786
+ * @throws {@link Vectros.TooManyRequestsError}
9787
+ *
9788
+ * @example
9789
+ * await client.triggers.createTrigger({
9790
+ * body: {
9791
+ * name: "on-intake-create",
9792
+ * firingSource: {
9793
+ * schemaId: "sch_9f8e7d6c",
9794
+ * event: "CREATE"
9795
+ * },
9796
+ * scriptRef: {
9797
+ * name: "notify-assignee",
9798
+ * version: "3"
9799
+ * }
9800
+ * }
9801
+ * })
9802
+ */
9803
+ createTrigger(request, requestOptions) {
9804
+ return HttpResponsePromise.fromPromise(this.__createTrigger(request, requestOptions));
9805
+ }
9806
+ async __createTrigger(request, requestOptions) {
9807
+ const { upsert, body: _body } = request;
9808
+ const _queryParams = {
9809
+ upsert
9810
+ };
9811
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9812
+ const _headers = mergeHeaders(
9813
+ _authRequest.headers,
9814
+ this._options?.headers,
9815
+ requestOptions?.headers
9816
+ );
9817
+ const _response = await fetcher({
9818
+ url: url_exports.join(
9819
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9820
+ "v1/triggers"
9821
+ ),
9822
+ method: "POST",
9823
+ headers: _headers,
9824
+ contentType: "application/json",
9825
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9826
+ requestType: "json",
9827
+ body: _body,
9828
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9829
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9830
+ abortSignal: requestOptions?.abortSignal,
9831
+ fetchFn: this._options?.fetch,
9832
+ logging: this._options.logging
9833
+ });
9834
+ if (_response.ok) {
9835
+ return { data: _response.body, rawResponse: _response.rawResponse };
9836
+ }
9837
+ if (_response.error.reason === "status-code") {
9838
+ switch (_response.error.statusCode) {
9839
+ case 400:
9840
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9841
+ case 403:
9842
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9843
+ case 429:
9844
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9845
+ default:
9846
+ throw new VectrosError({
9847
+ statusCode: _response.error.statusCode,
9848
+ body: _response.error.body,
9849
+ rawResponse: _response.rawResponse
9850
+ });
9851
+ }
9852
+ }
9853
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/triggers");
9854
+ }
9855
+ /**
9856
+ * Retrieves a single trigger rule by its ID. Requires the `triggers:r` scope.
9857
+ *
9858
+ * @param {Vectros.GetTriggerRequest} request
9859
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9860
+ *
9861
+ * @throws {@link Vectros.NotFoundError}
9862
+ *
9863
+ * @example
9864
+ * await client.triggers.getTrigger({
9865
+ * id: "id"
9866
+ * })
9867
+ */
9868
+ getTrigger(request, requestOptions) {
9869
+ return HttpResponsePromise.fromPromise(this.__getTrigger(request, requestOptions));
9870
+ }
9871
+ async __getTrigger(request, requestOptions) {
9872
+ const { id } = request;
9873
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9874
+ const _headers = mergeHeaders(
9875
+ _authRequest.headers,
9876
+ this._options?.headers,
9877
+ requestOptions?.headers
9878
+ );
9879
+ const _response = await fetcher({
9880
+ url: url_exports.join(
9881
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9882
+ `v1/triggers/${url_exports.encodePathParam(id)}`
9883
+ ),
9884
+ method: "GET",
9885
+ headers: _headers,
9886
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9887
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9888
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9889
+ abortSignal: requestOptions?.abortSignal,
9890
+ fetchFn: this._options?.fetch,
9891
+ logging: this._options.logging
9892
+ });
9893
+ if (_response.ok) {
9894
+ return { data: _response.body, rawResponse: _response.rawResponse };
9895
+ }
9896
+ if (_response.error.reason === "status-code") {
9897
+ switch (_response.error.statusCode) {
9898
+ case 404:
9899
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9900
+ default:
9901
+ throw new VectrosError({
9902
+ statusCode: _response.error.statusCode,
9903
+ body: _response.error.body,
9904
+ rawResponse: _response.rawResponse
9905
+ });
9906
+ }
9907
+ }
9908
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/triggers/{id}");
9909
+ }
9910
+ /**
9911
+ * Updates an existing trigger rule in place. The rule's resulting grant must be within your own granted scope — including a grant you did not change, because a trigger's other fields (its `scriptRef`, its `principalId`) determine what that grant executes. `name`, `principalId` and `provisionedBy` are immutable once set. Requires the `triggers:u` scope.
9912
+ *
9913
+ * @param {Vectros.UpdateTriggerRequest} request
9914
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9915
+ *
9916
+ * @throws {@link Vectros.BadRequestError}
9917
+ * @throws {@link Vectros.ForbiddenError}
9918
+ * @throws {@link Vectros.NotFoundError}
9919
+ * @throws {@link Vectros.TooManyRequestsError}
9920
+ *
9921
+ * @example
9922
+ * await client.triggers.updateTrigger({
9923
+ * id: "id",
9924
+ * body: {
9925
+ * name: "on-intake-create",
9926
+ * firingSource: {
9927
+ * schemaId: "sch_9f8e7d6c",
9928
+ * event: "CREATE"
9929
+ * },
9930
+ * scriptRef: {
9931
+ * name: "notify-assignee",
9932
+ * version: "3"
9933
+ * }
9934
+ * }
9935
+ * })
9936
+ */
9937
+ updateTrigger(request, requestOptions) {
9938
+ return HttpResponsePromise.fromPromise(this.__updateTrigger(request, requestOptions));
9939
+ }
9940
+ async __updateTrigger(request, requestOptions) {
9941
+ const { id, body: _body } = request;
9942
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9943
+ const _headers = mergeHeaders(
9944
+ _authRequest.headers,
9945
+ this._options?.headers,
9946
+ requestOptions?.headers
9947
+ );
9948
+ const _response = await fetcher({
9949
+ url: url_exports.join(
9950
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9951
+ `v1/triggers/${url_exports.encodePathParam(id)}`
9952
+ ),
9953
+ method: "PUT",
9954
+ headers: _headers,
9955
+ contentType: "application/json",
9956
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9957
+ requestType: "json",
9958
+ body: _body,
9959
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9960
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9961
+ abortSignal: requestOptions?.abortSignal,
9962
+ fetchFn: this._options?.fetch,
9963
+ logging: this._options.logging
9964
+ });
9965
+ if (_response.ok) {
9966
+ return { data: _response.body, rawResponse: _response.rawResponse };
9967
+ }
9968
+ if (_response.error.reason === "status-code") {
9969
+ switch (_response.error.statusCode) {
9970
+ case 400:
9971
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9972
+ case 403:
9973
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9974
+ case 404:
9975
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9976
+ case 429:
9977
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9978
+ default:
9979
+ throw new VectrosError({
9980
+ statusCode: _response.error.statusCode,
9981
+ body: _response.error.body,
9982
+ rawResponse: _response.rawResponse
9983
+ });
9984
+ }
9985
+ }
9986
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/triggers/{id}");
9987
+ }
9988
+ /**
9989
+ * Permanently deletes one trigger rule by ID. Requires the `triggers:d` scope.
9990
+ *
9991
+ * @param {Vectros.DeleteTriggerRequest} request
9992
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9993
+ *
9994
+ * @throws {@link Vectros.NotFoundError}
9995
+ * @throws {@link Vectros.TooManyRequestsError}
9996
+ *
9997
+ * @example
9998
+ * await client.triggers.deleteTrigger({
9999
+ * id: "id"
10000
+ * })
10001
+ */
10002
+ deleteTrigger(request, requestOptions) {
10003
+ return HttpResponsePromise.fromPromise(this.__deleteTrigger(request, requestOptions));
10004
+ }
10005
+ async __deleteTrigger(request, requestOptions) {
10006
+ const { id } = request;
10007
+ const _authRequest = await this._options.authProvider.getAuthRequest();
10008
+ const _headers = mergeHeaders(
10009
+ _authRequest.headers,
10010
+ this._options?.headers,
10011
+ requestOptions?.headers
10012
+ );
10013
+ const _response = await fetcher({
10014
+ url: url_exports.join(
10015
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
10016
+ `v1/triggers/${url_exports.encodePathParam(id)}`
10017
+ ),
10018
+ method: "DELETE",
10019
+ headers: _headers,
10020
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
10021
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
10022
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
10023
+ abortSignal: requestOptions?.abortSignal,
10024
+ fetchFn: this._options?.fetch,
10025
+ logging: this._options.logging
10026
+ });
10027
+ if (_response.ok) {
10028
+ return { data: void 0, rawResponse: _response.rawResponse };
10029
+ }
10030
+ if (_response.error.reason === "status-code") {
10031
+ switch (_response.error.statusCode) {
10032
+ case 404:
10033
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
10034
+ case 429:
10035
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
10036
+ default:
10037
+ throw new VectrosError({
10038
+ statusCode: _response.error.statusCode,
10039
+ body: _response.error.body,
10040
+ rawResponse: _response.rawResponse
10041
+ });
10042
+ }
10043
+ }
10044
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/triggers/{id}");
10045
+ }
10046
+ };
10047
+ var VectrosClient = class {
10048
+ constructor(options) {
10049
+ this._options = normalizeClientOptionsWithAuth(options);
10050
+ }
10051
+ get auth() {
10052
+ return this._auth ?? (this._auth = new AuthClient(this._options));
10053
+ }
10054
+ get documents() {
10055
+ return this._documents ?? (this._documents = new DocumentsClient(this._options));
10056
+ }
10057
+ get identity() {
10058
+ return this._identity ?? (this._identity = new IdentityClient(this._options));
10059
+ }
10060
+ get compliance() {
10061
+ return this._compliance ?? (this._compliance = new ComplianceClient(this._options));
10062
+ }
10063
+ get folders() {
10064
+ return this._folders ?? (this._folders = new FoldersClient(this._options));
10065
+ }
10066
+ get inference() {
10067
+ return this._inference ?? (this._inference = new InferenceClient(this._options));
10068
+ }
10069
+ get records() {
10070
+ return this._records ?? (this._records = new RecordsClient(this._options));
10071
+ }
10072
+ get schemas() {
10073
+ return this._schemas ?? (this._schemas = new SchemasClient(this._options));
10074
+ }
10075
+ get scripts() {
10076
+ return this._scripts ?? (this._scripts = new ScriptsClient(this._options));
10077
+ }
10078
+ get search() {
10079
+ return this._search ?? (this._search = new SearchClient(this._options));
10080
+ }
10081
+ get triggers() {
10082
+ return this._triggers ?? (this._triggers = new TriggersClient(this._options));
10083
+ }
10084
+ /**
10085
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
10086
+ * This is useful for making requests to endpoints not yet supported in the SDK.
10087
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
10088
+ *
10089
+ * @param {Request | string | URL} input - The URL, path, or Request object.
10090
+ * @param {RequestInit} init - Standard fetch RequestInit options.
10091
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
10092
+ * @returns {Promise<Response>} A standard Response object.
10093
+ */
10094
+ async fetch(input, init, requestOptions) {
10095
+ return makePassthroughRequest(
10096
+ input,
10097
+ init,
10098
+ {
10099
+ baseUrl: this._options.baseUrl ?? this._options.environment,
10100
+ headers: this._options.headers,
10101
+ timeoutInSeconds: this._options.timeoutInSeconds,
10102
+ maxRetries: this._options.maxRetries,
10103
+ fetch: this._options.fetch,
10104
+ logging: this._options.logging,
10105
+ getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers
10106
+ },
10107
+ requestOptions
10108
+ );
10109
+ }
10110
+ };
10111
+ var logging;
10112
+ ((logging2) => {
10113
+ logging2.LogLevel = LogLevel;
10114
+ logging2.ConsoleLogger = ConsoleLogger;
10115
+ })(logging || (logging = {}));
10116
+
10117
+ // src/server.ts
10118
+ import {
10119
+ CallToolRequestSchema,
10120
+ ListResourcesRequestSchema,
10121
+ ListToolsRequestSchema,
10122
+ ReadResourceRequestSchema
10123
+ } from "@modelcontextprotocol/sdk/types.js";
10124
+ import { z as z24 } from "zod";
10125
+
10126
+ // src/auth.ts
10127
+ var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
10128
+ var InvalidApiKeyError = class extends Error {
10129
+ constructor(reason) {
10130
+ super(`Invalid VECTROS_API_KEY: ${reason}`);
10131
+ this.name = "InvalidApiKeyError";
10132
+ }
10133
+ };
10134
+ function parseApiKey(raw) {
10135
+ if (!raw || raw.trim().length === 0) {
10136
+ throw new InvalidApiKeyError(
10137
+ "env var is missing or empty. Set VECTROS_API_KEY to a Vectros key (recommended: ssk_live_... or ssk_test_...)."
10138
+ );
10139
+ }
10140
+ const match = raw.match(KEY_RE);
10141
+ if (!match) {
10142
+ throw new InvalidApiKeyError(
10143
+ `key must start with sk_, ssk_, or st_ followed by "live_" or "test_". Got prefix "${raw.slice(0, 12)}...".`
10144
+ );
10145
+ }
10146
+ return {
10147
+ prefix: match[1],
10148
+ env: match[2],
10149
+ raw
10150
+ };
10151
+ }
9241
10152
  function warnOnSuboptimalKey(key, log) {
9242
10153
  if (key.prefix === "sk") {
9243
10154
  log.warn(
@@ -9254,8 +10165,8 @@ function warnOnSuboptimalKey(key, log) {
9254
10165
 
9255
10166
  // src/build-info.ts
9256
10167
  var BUILD_INFO = {
9257
- mcpServer: true ? "0.16.0" : "dev",
9258
- sdk: true ? "0.41.0" : "dev"
10168
+ mcpServer: true ? "0.17.0" : "dev",
10169
+ sdk: true ? "0.43.0" : "dev"
9259
10170
  };
9260
10171
  function formatBuildInfo() {
9261
10172
  return `vectros-mcp-server ${BUILD_INFO.mcpServer} (sdk ${BUILD_INFO.sdk})`;
@@ -9566,11 +10477,18 @@ var inputSchema = {
9566
10477
  // Ownership.
9567
10478
  userId: z.string().optional().describe("Restrict to content owned by this user (Vectros UUID)."),
9568
10479
  scope: z.string().optional().describe(
9569
- 'Restrict to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself.'
10480
+ 'Restrict to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. Mutually exclusive with `scopeFilters` \u2014 use this for ONE dimension.'
10481
+ ),
10482
+ scopeFilters: z.array(z.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
10483
+ 'Restrict to content matching ALL of these scope values \u2014 one per namespace \u2014 for a credential whose access spans more than one ownership dimension. e.g. ["org:<uuid>", "client:<uuid>"] narrows to one specific client WITHIN one specific org, which `scope` alone cannot express. Same `namespace:value` form as `scope`; naming the same namespace twice is rejected. Mutually exclusive with `scope` \u2014 use `scope` for a single dimension.'
9570
10484
  ),
9571
10485
  // Date window.
9572
- createdAfter: z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
9573
- createdBefore: z.string().optional().describe("Restrict to content created at/before this ISO 8601 UTC timestamp."),
10486
+ createdAfter: z.string().optional().describe(
10487
+ "Restrict to content CREATED at/after this ISO 8601 UTC timestamp \u2014 the item's own creation time, which does NOT move when the item is later re-indexed. One bounded exception: an item matched on its FIRST index may be checked against the moment it was indexed instead, a small allowance for clock skew between creating and indexing it. Do not confuse this with a hit's returned `createdAt`, which is the index timestamp and can be later \u2014 see the tool description."
10488
+ ),
10489
+ createdBefore: z.string().optional().describe(
10490
+ "Restrict to content CREATED at/before this ISO 8601 UTC timestamp \u2014 same creation-time basis, and the same first-index allowance, as createdAfter."
10491
+ ),
9574
10492
  // Relevance tuning.
9575
10493
  minSimilarity: z.number().min(0).max(1).optional().describe("Minimum semantic similarity (0.0\u20131.0); results below are excluded."),
9576
10494
  minTextRelevance: z.number().min(0).max(1).optional().describe("Minimum relative keyword (BM25) relevance (0.0\u20131.0); the keyword-leg analogue of minSimilarity."),
@@ -9585,11 +10503,19 @@ var inputSchema = {
9585
10503
  var hybridSearch = ({ client, log }) => ({
9586
10504
  name: "hybrid_search",
9587
10505
  title: "Hybrid search",
9588
- 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 (BM25) leg matched nothing (all textScores 0) \u2014 typically the default PHRASE mode finding no contiguous match for a long natural-language query. Loosen the keyword leg: shorten the query to its key terms, or set textMode "AND" (all terms, higher precision) or "OR" (any term, broad recall).',
10506
+ 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, and scope for ONE ownership dimension or scopeFilters for several at once \u2014 e.g. one client within one org), 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 AND records are excluded from results \u2014 fetch them by id via document_get/record_get, or restore them by setting status back to ACTIVE. One exception to know: an item archived before the platform enforced this can still be returned here until it is next written to, and nothing sweeps for those \u2014 if an archived item does come back as a hit, re-send status ARCHIVED on it (document_update / record_update) to re-assert the retraction. A hit\'s `createdAt` is when the item entered the search INDEX, which is the moment it was created in the common case but is later for anything re-indexed since \u2014 so do not report it to a user as the creation time; fetch the item with document_get/record_get and read its own createdAt for that. (The createdAfter/createdBefore filters are a separate thing and do filter on true creation time.) 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 (BM25) leg matched nothing (all textScores 0) \u2014 typically the default PHRASE mode finding no contiguous match for a long natural-language query. Loosen the keyword leg: shorten the query to its key terms, or set textMode "AND" (all terms, higher precision) or "OR" (any term, broad recall).',
9589
10507
  inputSchema,
9590
10508
  handler: async (args) => {
9591
10509
  const limit = args.limit ?? MCP_DEFAULT_LIMIT;
9592
10510
  const mode = args.mode ?? "HYBRID";
10511
+ if (args.scope !== void 0 && args.scopeFilters !== void 0) {
10512
+ return toolError(
10513
+ "hybrid_search",
10514
+ new Error(
10515
+ "'scope' and 'scopeFilters' are mutually exclusive \u2014 pass 'scope' for a single ownership dimension, or 'scopeFilters' for more than one, not both."
10516
+ )
10517
+ );
10518
+ }
9593
10519
  try {
9594
10520
  const result = await client.search.content({
9595
10521
  query: args.query,
@@ -9604,6 +10530,7 @@ var hybridSearch = ({ client, log }) => ({
9604
10530
  filters: args.filters,
9605
10531
  userId: args.userId,
9606
10532
  scope: args.scope,
10533
+ scopeFilters: args.scopeFilters,
9607
10534
  createdAfter: args.createdAfter,
9608
10535
  createdBefore: args.createdBefore,
9609
10536
  minSimilarity: args.minSimilarity,
@@ -9682,7 +10609,9 @@ async function drainPages(fetchPage) {
9682
10609
  var MCP_DEFAULT_LIMIT2 = 3;
9683
10610
  var MCP_MAX_LIMIT2 = 100;
9684
10611
  var inputSchema2 = {
9685
- type: z2.string().min(1, "type (record type) is required").describe('Record type / schema name (e.g. "patient", "clinical_note").'),
10612
+ type: z2.string().min(1, "type must be non-empty when supplied").optional().describe(
10613
+ 'Record type / schema name (e.g. "patient", "clinical_note"). REQUIRED for a lookup (`field`). In list mode it is one of three ways to choose what to list \u2014 supply `type`, `folderId`, or `recent` \u2014 and it may be combined with `folderId` to list one type within one folder.'
10614
+ ),
9686
10615
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | values | from+to | prefix.
9687
10616
  field: z2.string().optional().describe(
9688
10617
  'Lookup mode: name of the lookup-indexed field to query by. `externalId` is always queryable \u2014 e.g. `{type:"control", field:"externalId", value:"ctrl-scoped-key"}` finds the record you created under that externalId. (record_get / record_update also accept externalId directly.) For a SCHEMA-declared composite lookup \u2014 check list_schemas\' lookupFields for a fieldNames entry, not any two fields you pick \u2014 give those field names comma-joined in the declared order (e.g. "status,area"). Use `values` to match on several of those fields at once, or `value` to match on just the FIRST field named (equivalent to a one-element `values`); range/prefix are not valid on a composite field.'
@@ -9704,6 +10633,12 @@ var inputSchema2 = {
9704
10633
  "Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc` \u2014 use `desc` with a range/prefix lookup to get the most-recent / highest values first (e.g. latest-N). Ignored in list mode."
9705
10634
  ),
9706
10635
  // List-mode args:
10636
+ folderId: z2.string().optional().describe(
10637
+ "List mode: list the records filed in this folder (a Vectros folder UUID), regardless of type \u2014 the record-side counterpart of document_query's folderId. Combine with `type` to list a single type within the folder. Use this to see what a folder holds before deleting it: folder_delete refuses a folder that still contains records."
10638
+ ),
10639
+ recent: z2.boolean().optional().describe(
10640
+ "List mode: return the account-wide recently-updated feed across ALL record types, newest first \u2014 a type-agnostic activity view, and the one way to read records without naming a type. Standalone: it cannot be combined with `type`, `folderId`, `userId` or `scope` (the API ignores them here, so this tool rejects the combination rather than silently returning something else). You still see only the record types your credential may read."
10641
+ ),
9707
10642
  userId: z2.string().optional().describe("List mode: scope to records owned by this user."),
9708
10643
  scope: z2.string().optional().describe(
9709
10644
  '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 reserved namespace names, registered like any other; others are namespaces you registered yourself.'
@@ -9716,11 +10651,13 @@ var inputSchema2 = {
9716
10651
  var recordQuery = ({ client, log }) => ({
9717
10652
  name: "record_query",
9718
10653
  title: "Record query (list or lookup)",
9719
- 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), `values` (exact, composite \u2014 one value per field; a single-element array is the same as `value`), `from`+`to` (range), or `prefix`. `values` with more than one entry, or a comma-joined `field`, ONLY works for a lookup the schema itself declared over several fields together \u2014 check list_schemas' lookupFields for a fieldNames entry, then pass those field names comma-joined as `field`; `from`/`to`/`prefix` are not valid there. Works on sensitive fields too. Optionally narrow an exact match to a window with `sortFrom`/`sortTo`.\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. A composite lookup given fewer than its full field count returns records grouped by the unspecified fields, ordered within each group. Mode is auto-detected from the arguments present.",
10654
+ 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), `values` (exact, composite \u2014 one value per field; a single-element array is the same as `value`), `from`+`to` (range), or `prefix`. `values` with more than one entry, or a comma-joined `field`, ONLY works for a lookup the schema itself declared over several fields together \u2014 check list_schemas' lookupFields for a fieldNames entry, then pass those field names comma-joined as `field`; `from`/`to`/`prefix` are not valid there. Works on sensitive fields too. Optionally narrow an exact match to a window with `sortFrom`/`sortTo`.\n \u2022 List: omit `field`, then choose ONE of `type` (every record of a type), `folderId` (every record filed in a folder, any type \u2014 combine with `type` for one type within one folder), or `recent` (the account-wide recently-updated feed across every type, newest first \u2014 the only way to read records without naming a type, and standalone: no other filter applies to it). `userId`/`scope` further narrow the type and folder modes.\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. A composite lookup given fewer than its full field count returns records grouped by the unspecified fields, ordered within each group. Mode is auto-detected from the arguments present.",
9720
10655
  inputSchema: inputSchema2,
9721
10656
  handler: async (args) => {
9722
10657
  const limit = args.limit ?? MCP_DEFAULT_LIMIT2;
9723
10658
  const type = args.type;
10659
+ const folderId = args.folderId;
10660
+ const recent = args.recent;
9724
10661
  const field = args.field;
9725
10662
  const value = args.value;
9726
10663
  const values = args.values;
@@ -9738,6 +10675,48 @@ var recordQuery = ({ client, log }) => ({
9738
10675
  )
9739
10676
  );
9740
10677
  }
10678
+ if (field && (folderId !== void 0 || recent !== void 0)) {
10679
+ return toolError(
10680
+ "record_query",
10681
+ new Error(
10682
+ "'folderId' and 'recent' are list-mode selectors and do not apply to a lookup ('field') \u2014 a lookup runs within one `type` and would ignore them. Drop `field` to list, or drop these to look up."
10683
+ )
10684
+ );
10685
+ }
10686
+ if (field && !type) {
10687
+ return toolError(
10688
+ "record_query",
10689
+ new Error(
10690
+ "a lookup ('field') is always within one record type \u2014 pass 'type'. To read across types, use list mode with 'folderId' or 'recent'."
10691
+ )
10692
+ );
10693
+ }
10694
+ if (!field) {
10695
+ if (recent && (type !== void 0 || folderId !== void 0)) {
10696
+ return toolError(
10697
+ "record_query",
10698
+ new Error(
10699
+ "'recent' is the account-wide feed across all types and cannot be narrowed \u2014 it is mutually exclusive with 'type' and 'folderId'. Drop 'recent' to list by type/folder."
10700
+ )
10701
+ );
10702
+ }
10703
+ if (recent && (args.userId !== void 0 || args.scope !== void 0)) {
10704
+ return toolError(
10705
+ "record_query",
10706
+ new Error(
10707
+ "'recent' ignores the owner filters \u2014 'userId'/'scope' would be silently dropped. List by 'type' or 'folderId' to filter by owner."
10708
+ )
10709
+ );
10710
+ }
10711
+ if (!recent && type === void 0 && folderId === void 0) {
10712
+ return toolError(
10713
+ "record_query",
10714
+ new Error(
10715
+ "list mode needs one of 'type' (records of a type), 'folderId' (records in a folder, any type), or 'recent' (the account-wide recently-updated feed). Add 'field' to run a lookup."
10716
+ )
10717
+ );
10718
+ }
10719
+ }
9741
10720
  try {
9742
10721
  let page;
9743
10722
  if (field) {
@@ -9801,6 +10780,7 @@ var recordQuery = ({ client, log }) => ({
9801
10780
  }
9802
10781
  }
9803
10782
  page = await client.records.lookupRecordsByBody({
10783
+ // Non-null: the `field && !type` guard above returns before reaching lookup mode.
9804
10784
  type,
9805
10785
  field: normalizedField,
9806
10786
  value,
@@ -9821,13 +10801,22 @@ var recordQuery = ({ client, log }) => ({
9821
10801
  } else {
9822
10802
  page = await client.records.listRecords({
9823
10803
  type,
10804
+ folderId,
10805
+ ...recent ? { recent: "true" } : {},
9824
10806
  userId: args.userId,
9825
10807
  scope: args.scope,
9826
10808
  startFrom,
9827
10809
  limit
9828
10810
  });
9829
10811
  log.debug(
9830
- { tool: "record_query", mode: "list", type, limit, returned: pageItems(page).length },
10812
+ {
10813
+ tool: "record_query",
10814
+ mode: recent ? "list:recent" : folderId ? "list:folder" : "list:type",
10815
+ type,
10816
+ folderId,
10817
+ limit,
10818
+ returned: pageItems(page).length
10819
+ },
9831
10820
  "record_query list ok"
9832
10821
  );
9833
10822
  }
@@ -10004,7 +10993,7 @@ var inputSchema5 = {
10004
10993
  folderId: z5.string().optional().describe("Group this record into a folder."),
10005
10994
  userId: z5.string().optional().describe("Owning user id."),
10006
10995
  scopes: z5.array(z5.string()).optional().describe(
10007
- 'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. 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.'
10996
+ 'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. This is the record\'s COMPLETE scope declaration, and each entry must fall inside the `data_scope` of a single clause of your credential that also grants this write \u2014 your identity supplies the DEFAULT when you state none, it does not limit which value you may state. An empty array `[]` creates a PRIVATE record owned by the calling user alone. Omit to stamp the credential\'s full identity \u2014 the default.'
10008
10997
  )
10009
10998
  };
10010
10999
  var recordCreate = ({ client, log }) => ({
@@ -10037,19 +11026,101 @@ var recordCreate = ({ client, log }) => ({
10037
11026
  });
10038
11027
  var record_create_default = recordCreate;
10039
11028
 
10040
- // src/tools/record_update.ts
11029
+ // src/tools/record_batch_write.ts
10041
11030
  import { z as z6 } from "zod";
10042
- var inputSchema6 = {
10043
- id: z6.string().optional().describe("The Vectros record id to update. Provide this OR externalId+type."),
11031
+ var MCP_MAX_ITEMS = 50;
11032
+ var itemSchema = z6.strictObject({
11033
+ type: z6.string().min(1, "type is required").describe('Record type / schema name (e.g. "task"). Must match an existing schema \u2014 see list_schemas.'),
11034
+ fields: z6.record(z6.string(), z6.unknown()).describe(
11035
+ "The record payload \u2014 a JSON object of field\u2192value, validated against the type schema. Same rules as record_create, including the signed 64-bit range on numbers (send a larger whole number as a STRING)."
11036
+ ),
10044
11037
  externalId: z6.string().optional().describe(
11038
+ 'Stable caller-supplied id, unique per type \u2014 supply it to make a batch safely retryable, since without one a re-submitted item creates a second record. Without `upsert`, an item whose externalId already matches a COMMITTED record comes back `updated` (the idempotent repeat \u2014 nothing was overwritten) if your credential can read that type; a create-only credential gets `conflict` instead, because it may not be shown the existing record. \u26A0\uFE0F Two items sharing ONE externalId WITHIN a single batch are only refused as a `conflict` under atomicity:"all_or_nothing". Under the DEFAULT best_effort each item is written independently, so the second matches what the first just wrote and reports `updated` \u2014 a duplicate key in your input silently collapses two rows into one, counted in `succeeded`, not in `failed`. De-duplicate by externalId before sending, or use all_or_nothing if you need the batch to refuse. A result returns the record\'s `id`, not the record itself; fetch that with record_get/record_batch_get.'
11039
+ ),
11040
+ indexMode: z6.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
11041
+ "Search-index strategy for this record, set at create only and NOT changeable later. HYBRID (BM25 + dense), SEMANTIC (dense only), TEXT (BM25 only), NONE (store-only \u2014 the record never appears in hybrid_search/rag_ask, though it stays retrievable by id and by structured-field lookup). Omit to inherit the type schema's default; if that default is NONE and you want these records searchable, set it here, because it cannot be fixed after the write."
11042
+ ),
11043
+ status: z6.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
11044
+ folderId: z6.string().optional().describe("Group this record into a folder."),
11045
+ userId: z6.string().optional().describe("Owning user id."),
11046
+ scopes: z6.array(z6.string()).optional().describe(
11047
+ "Scope ownership as `namespace:value` entries, at most 2 namespaces. When supplied this is the record's COMPLETE scope declaration, and each entry must fall inside the `data_scope` of a single clause of your credential that also grants this write \u2014 your identity supplies the DEFAULT when you state none, it does not limit which value you may state. `[]` creates a PRIVATE record owned by the calling user alone. Omit to inherit the credential's full identity."
11048
+ )
11049
+ });
11050
+ var inputSchema6 = {
11051
+ items: z6.array(itemSchema).min(1).max(MCP_MAX_ITEMS).describe(
11052
+ `The records to write, 1-${MCP_MAX_ITEMS}. Each item is shaped like a record_create call (\`type\` + \`fields\`, plus the same optional externalId/indexMode/status/folderId/userId/scopes) and is validated and scope-checked individually against its OWN type \u2014 items may mix types.`
11053
+ ),
11054
+ atomicity: z6.enum(["best_effort", "all_or_nothing"]).optional().describe(
11055
+ 'How the batch commits. "best_effort" (the default) writes each item independently \u2014 some can succeed while others fail. "all_or_nothing" commits every item in ONE transaction: if any item fails nothing is written at all, and the items that were themselves fine report status "not_committed". Choose all_or_nothing when the records are interdependent or a half-written set would be worse than none; note it can still be refused as too large to commit atomically even within the item limit, because that transaction is bounded by underlying storage rows rather than by item count (nothing is written when that happens).'
11056
+ ),
11057
+ upsert: z6.boolean().optional().describe(
11058
+ "Applies to every item: when true, an item whose `externalId` already exists OVERWRITES that record instead of returning it unchanged. Needs records:u:<type> in addition to records:c:<type>, checked per item. Default false."
11059
+ ),
11060
+ allowClear: z6.boolean().optional().describe(
11061
+ "Only meaningful with upsert:true, which overwrites as a FULL replacement. If an item's `fields` omits (or nulls) a stored field that only comes back as an indexed projection \u2014 a large record whose payload is stored externally \u2014 the overwrite is refused unless you set this to true to confirm you mean to clear those fields. Default false. To change some fields without clearing the omitted ones, use record_update instead of an upserting batch."
11062
+ )
11063
+ };
11064
+ var recordBatchWrite = ({ client, log }) => ({
11065
+ name: "record_batch_write",
11066
+ title: "Create or upsert multiple records in one call",
11067
+ description: 'Write up to 50 structured records in a single call \u2014 use this instead of N record_create calls when you hold several records (e.g. filing a parsed table, or seeding a set of tasks). Items may mix types; each one is schema-validated, externalId-idempotent and scope-checked individually against its own type (records:c:<type> per item), so a batch cannot write a type you could not write one at a time. `atomicity` chooses the commit shape: "best_effort" (default) writes each item independently; "all_or_nothing" commits every item in one transaction, writing nothing at all if any item fails \u2014 prefer it when a half-written set would be worse than none. IMPORTANT: this call reports success whenever the batch was PROCESSED, including when every item failed \u2014 so always read the per-item `results` and the `succeeded`/`failed` counts rather than treating a non-error result as "all written". This differs from record_create, where a failure is an error result. Results are NOT guaranteed to arrive in the order you submitted: match each one to its item by its `index` (zero-based, the position in your `items` array). A result carries the written record\'s `id` (null on failure) and, when it failed, an `error` with a machine-readable `code` and a human-readable `message` \u2014 read it before resubmitting. It does NOT carry the record itself; fetch that with record_get/record_batch_get. A per-item `status` is created (new record written), updated (an existing record matched \u2014 overwritten only if you passed upsert:true, otherwise returned unchanged, so this is not by itself evidence of a write), conflict (uniqueness or version), invalid (validation \u2014 read `error.message` for which field), forbidden (your credential lacks the scope or ownership that item needed \u2014 fix the credential, not the item), or not_committed (this item was fine but an all_or_nothing batch was aborted by a different item, so resubmitting with that one fixed writes this one unchanged).',
11068
+ inputSchema: inputSchema6,
11069
+ handler: async (args) => {
11070
+ const items = args.items;
11071
+ const atomicity = args.atomicity;
11072
+ try {
11073
+ const body = {
11074
+ items: items.map((item) => ({
11075
+ typeName: item.type,
11076
+ payload: item.fields,
11077
+ externalId: item.externalId,
11078
+ indexMode: item.indexMode,
11079
+ status: item.status,
11080
+ folderId: item.folderId,
11081
+ userId: item.userId,
11082
+ scopes: item.scopes
11083
+ })),
11084
+ atomicity,
11085
+ upsert: args.upsert,
11086
+ allowClear: args.allowClear
11087
+ };
11088
+ const response = await client.records.batchWriteRecords(body, { maxRetries: 0 });
11089
+ log.debug(
11090
+ {
11091
+ tool: "record_batch_write",
11092
+ submitted: items.length,
11093
+ atomicity: atomicity ?? "best_effort",
11094
+ succeeded: response.succeeded,
11095
+ failed: response.failed
11096
+ },
11097
+ "record_batch_write ok"
11098
+ );
11099
+ return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
11100
+ } catch (err) {
11101
+ log.warn(
11102
+ { tool: "record_batch_write", itemCount: items?.length, err: String(err) },
11103
+ "record_batch_write failed"
11104
+ );
11105
+ return toolError("record_batch_write", err);
11106
+ }
11107
+ }
11108
+ });
11109
+ var record_batch_write_default = recordBatchWrite;
11110
+
11111
+ // src/tools/record_update.ts
11112
+ import { z as z7 } from "zod";
11113
+ var inputSchema7 = {
11114
+ id: z7.string().optional().describe("The Vectros record id to update. Provide this OR externalId+type."),
11115
+ externalId: z7.string().optional().describe(
10045
11116
  "Your caller-owned externalId \u2014 an alternative selector to `id` (requires `type`). Updates the record you created under that externalId without a manual record_query lookup first."
10046
11117
  ),
10047
- type: z6.string().optional().describe("Record type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10048
- fields: z6.record(z6.string(), z6.unknown()).describe(
11118
+ type: z7.string().optional().describe("Record type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11119
+ fields: z7.record(z7.string(), z7.unknown()).describe(
10049
11120
  "Field\u2192value changes DEEP-MERGED into the existing payload: keys you send overwrite (recursing into nested objects), a key set to `null` is deleted, and unspecified fields are preserved."
10050
11121
  ),
10051
- status: z6.string().optional().describe("Set the record lifecycle status (e.g. ARCHIVED) \u2014 archive/workflow without physical deletion."),
10052
- expectedVersion: z6.number().int().optional().describe(
11122
+ status: z7.string().optional().describe("Set the record lifecycle status (e.g. ARCHIVED) \u2014 archive/workflow without physical deletion."),
11123
+ expectedVersion: z7.number().int().optional().describe(
10053
11124
  "Optimistic concurrency: the version you last read. If the record changed since, the update is refused as a conflict (re-read and retry). Omit for last-write-wins."
10054
11125
  )
10055
11126
  };
@@ -10057,7 +11128,7 @@ var recordUpdate = ({ client, log }) => ({
10057
11128
  name: "record_update",
10058
11129
  title: "Update a record by id or externalId",
10059
11130
  description: "Update a record \u2014 select it by its Vectros `id` OR by your own `externalId` + `type` (the same key you passed to record_create, resolved for you). The provided `fields` are DEEP-MERGED into the existing payload (unspecified fields are preserved; a field set to `null` is deleted). Pass `expectedVersion` (the version you last read) for safe concurrent edits \u2014 a stale update is refused (409). Use `status` to archive without deleting. Requires the key to allow records:u.",
10060
- inputSchema: inputSchema6,
11131
+ inputSchema: inputSchema7,
10061
11132
  handler: async (args) => {
10062
11133
  const id = args.id;
10063
11134
  const externalId = args.externalId;
@@ -10083,15 +11154,15 @@ var recordUpdate = ({ client, log }) => ({
10083
11154
  var record_update_default = recordUpdate;
10084
11155
 
10085
11156
  // src/tools/record_delete.ts
10086
- import { z as z7 } from "zod";
10087
- var inputSchema7 = {
10088
- id: z7.string().min(1, "id is required").describe("The Vectros record id to delete.")
11157
+ import { z as z8 } from "zod";
11158
+ var inputSchema8 = {
11159
+ id: z8.string().min(1, "id is required").describe("The Vectros record id to delete.")
10089
11160
  };
10090
11161
  var recordDelete = ({ client, log }) => ({
10091
11162
  name: "record_delete",
10092
11163
  title: "Delete a record",
10093
11164
  description: "Permanently delete a record by id (leaves a tombstone). Requires the key to allow records:d \u2014 a key without it gets a permission error. To archive without deleting, use record_update to set status instead.",
10094
- inputSchema: inputSchema7,
11165
+ inputSchema: inputSchema8,
10095
11166
  handler: async (args) => {
10096
11167
  const id = args.id;
10097
11168
  try {
@@ -10107,49 +11178,63 @@ var recordDelete = ({ client, log }) => ({
10107
11178
  var record_delete_default = recordDelete;
10108
11179
 
10109
11180
  // src/tools/rag_ask.ts
10110
- import { z as z8 } from "zod";
11181
+ import { z as z9 } from "zod";
10111
11182
  var SEARCH_MCP_DEFAULT_LIMIT = 5;
10112
11183
  var SEARCH_MCP_MAX_LIMIT = 50;
10113
- var inputSchema8 = {
10114
- query: z8.string().min(1, "query must be non-empty").describe("Question to ground against retrieved content."),
10115
- instructions: z8.string().optional().describe(
11184
+ var inputSchema9 = {
11185
+ query: z9.string().min(1, "query must be non-empty").describe("Question to ground against retrieved content."),
11186
+ instructions: z9.string().optional().describe(
10116
11187
  '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.'
10117
11188
  ),
10118
- model: z8.string().optional().describe(
11189
+ model: z9.string().optional().describe(
10119
11190
  "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."
10120
11191
  ),
10121
- search: z8.object({
10122
- mode: z8.enum(["HYBRID", "TEXT", "SEMANTIC"]).optional().describe("Retrieval mode. Default HYBRID."),
10123
- limit: z8.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(
11192
+ search: z9.object({
11193
+ mode: z9.enum(["HYBRID", "TEXT", "SEMANTIC"]).optional().describe("Retrieval mode. Default HYBRID."),
11194
+ limit: z9.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(
10124
11195
  `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.`
10125
11196
  ),
10126
11197
  // Retrieval scoping — parity with hybrid_search so an agent can ground the
10127
11198
  // answer on a specific owner / folder / type / metadata subset, not just the
10128
11199
  // whole-tenant corpus.
10129
- userId: z8.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
10130
- scope: z8.string().optional().describe(
10131
- '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 reserved namespace names, registered like any other; others are namespaces you registered yourself.'
11200
+ userId: z9.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
11201
+ scope: z9.string().optional().describe(
11202
+ '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 reserved namespace names, registered like any other; others are namespaces you registered yourself. Mutually exclusive with `scopeFilters` \u2014 use this for ONE dimension.'
11203
+ ),
11204
+ scopeFilters: z9.array(z9.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
11205
+ 'Restrict retrieval to content matching ALL of these scope values \u2014 one per namespace \u2014 for a credential whose access spans more than one ownership dimension. e.g. ["org:<uuid>", "client:<uuid>"] grounds the answer on one specific client WITHIN one specific org, which `scope` alone cannot express. Naming the same namespace twice is rejected. Mutually exclusive with `scope`.'
10132
11206
  ),
10133
- folderId: z8.string().optional().describe("Restrict retrieval to this exact folder."),
10134
- rootFolderId: z8.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
10135
- typeName: z8.string().optional().describe("Restrict record retrieval to this schema type."),
10136
- contentTypes: z8.array(z8.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
10137
- filters: z8.record(z8.unknown()).optional().describe(
11207
+ folderId: z9.string().optional().describe("Restrict retrieval to this exact folder."),
11208
+ rootFolderId: z9.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
11209
+ typeName: z9.string().optional().describe("Restrict record retrieval to this schema type."),
11210
+ contentTypes: z9.array(z9.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
11211
+ filters: z9.record(z9.unknown()).optional().describe(
10138
11212
  'Field-level metadata filters (AND-combined). Value = scalar (equality), array (OR-set), or operator map ($eq/$ne/$gt/$gte/$lt/$lte, $in/$nin). e.g. {"status":"open"}.'
10139
11213
  ),
10140
- createdAfter: z8.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
10141
- createdBefore: z8.string().optional().describe("Restrict to content created at/before this ISO 8601 UTC timestamp."),
10142
- requireComplete: z8.boolean().optional().describe("Fail closed (503) on a degraded search backend instead of grounding on partial results. Default false.")
11214
+ createdAfter: z9.string().optional().describe(
11215
+ "Restrict retrieval to content CREATED at/after this ISO 8601 UTC timestamp \u2014 the item's own creation time, which does not move when it is re-indexed. An item matched on its FIRST index may be checked against its index time instead, a bounded clock-skew allowance."
11216
+ ),
11217
+ createdBefore: z9.string().optional().describe("Same creation-time basis as createdAfter, bounding at/before this ISO 8601 UTC value."),
11218
+ requireComplete: z9.boolean().optional().describe("Fail closed (503) on a degraded search backend instead of grounding on partial results. Default false.")
10143
11219
  }).optional().describe("Retrieval params + scoping. Default mode HYBRID, limit " + SEARCH_MCP_DEFAULT_LIMIT + "."),
10144
- maxTokens: z8.number().int().min(1).optional().describe("Max output tokens."),
10145
- temperature: z8.number().min(0).max(1).optional().describe("Sampling temperature (0.0\u20131.0). Default 0.3 \u2014 lower favors deterministic, retrieval-grounded answers.")
11220
+ maxTokens: z9.number().int().min(1).optional().describe("Max output tokens."),
11221
+ temperature: z9.number().min(0).max(1).optional().describe("Sampling temperature (0.0\u20131.0). Default 0.3 \u2014 lower favors deterministic, retrieval-grounded answers.")
10146
11222
  };
10147
11223
  var ragAsk = ({ client, log }) => ({
10148
11224
  name: "rag_ask",
10149
11225
  title: "RAG ask (corpus-wide)",
10150
- 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.",
10151
- inputSchema: inputSchema8,
11226
+ 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 \u2014 `scope` for one ownership dimension or `scopeFilters` for several at once, e.g. one client within one org \u2014 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.",
11227
+ inputSchema: inputSchema9,
10152
11228
  handler: async (args, extra) => {
11229
+ const rawSearch = args.search ?? {};
11230
+ if (rawSearch.scope !== void 0 && rawSearch.scopeFilters !== void 0) {
11231
+ return toolError(
11232
+ "rag_ask",
11233
+ new Error(
11234
+ "search.scope and search.scopeFilters are mutually exclusive \u2014 pass 'scope' for a single ownership dimension, or 'scopeFilters' for more than one, not both."
11235
+ )
11236
+ );
11237
+ }
10153
11238
  try {
10154
11239
  const searchArg = args.search ?? {};
10155
11240
  const search = {
@@ -10157,6 +11242,7 @@ var ragAsk = ({ client, log }) => ({
10157
11242
  limit: searchArg.limit ?? SEARCH_MCP_DEFAULT_LIMIT,
10158
11243
  userId: searchArg.userId,
10159
11244
  scope: searchArg.scope,
11245
+ scopeFilters: searchArg.scopeFilters,
10160
11246
  folderId: searchArg.folderId,
10161
11247
  rootFolderId: searchArg.rootFolderId,
10162
11248
  typeName: searchArg.typeName,
@@ -10224,20 +11310,20 @@ var ragAsk = ({ client, log }) => ({
10224
11310
  var rag_ask_default = ragAsk;
10225
11311
 
10226
11312
  // src/tools/document_ask.ts
10227
- import { z as z9 } from "zod";
10228
- var inputSchema9 = {
10229
- documentId: z9.string().min(1, "documentId is required").describe("ID of the document to ask against."),
10230
- prompt: z9.string().min(1, "prompt is required").describe("Question to ask about the document."),
10231
- model: z9.string().optional().describe(
11313
+ import { z as z10 } from "zod";
11314
+ var inputSchema10 = {
11315
+ documentId: z10.string().min(1, "documentId is required").describe("ID of the document to ask against."),
11316
+ prompt: z10.string().min(1, "prompt is required").describe("Question to ask about the document."),
11317
+ model: z10.string().optional().describe(
10232
11318
  "Inference model alias. Default = tier-appropriate Haiku. See GET /v1/models for the catalog the calling key can reach."
10233
11319
  ),
10234
- maxTokens: z9.number().int().min(1).optional().describe("Max output tokens.")
11320
+ maxTokens: z10.number().int().min(1).optional().describe("Max output tokens.")
10235
11321
  };
10236
11322
  var documentAsk = ({ client, log }) => ({
10237
11323
  name: "document_ask",
10238
11324
  title: "Document ask (single-document)",
10239
11325
  description: "Ask a question against a single indexed document. Returns a grounded answer with the document context that informed it. For documents exceeding the input-token cap, the API returns a structured 413 with `estimatedTokens` and `limitTokens`. Inference runs in-perimeter against AWS Bedrock \u2014 PHI never leaves the BAA boundary.",
10240
- inputSchema: inputSchema9,
11326
+ inputSchema: inputSchema10,
10241
11327
  handler: async (args, extra) => {
10242
11328
  try {
10243
11329
  const stream = await client.inference.documentAsk({
@@ -10296,18 +11382,18 @@ var documentAsk = ({ client, log }) => ({
10296
11382
  var document_ask_default = documentAsk;
10297
11383
 
10298
11384
  // src/tools/list_schemas.ts
10299
- import { z as z10 } from "zod";
10300
- var inputSchema10 = {
10301
- userId: z10.string().optional().describe(
11385
+ import { z as z11 } from "zod";
11386
+ var inputSchema11 = {
11387
+ userId: z11.string().optional().describe(
10302
11388
  "Filter to schemas visible to a specific user. Optional; default returns all schemas the credential can see."
10303
11389
  ),
10304
- scope: z10.string().optional().describe(
11390
+ scope: z11.string().optional().describe(
10305
11391
  'Filter to schemas carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "group:eng-team"). `org` and `client` are reserved namespace names, registered like any other. Optional; default returns all schemas the credential can see.'
10306
11392
  ),
10307
- surface: z10.enum(["record", "document", "user", "entity"]).optional().describe(
11393
+ surface: z11.enum(["record", "document", "user", "entity"]).optional().describe(
10308
11394
  "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."
10309
11395
  ),
10310
- recordType: z10.string().optional().describe(
11396
+ recordType: z11.string().optional().describe(
10311
11397
  '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.'
10312
11398
  )
10313
11399
  };
@@ -10315,7 +11401,7 @@ var listSchemas = ({ client, log }) => ({
10315
11401
  name: "list_schemas",
10316
11402
  title: "List record schemas",
10317
11403
  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.',
10318
- inputSchema: inputSchema10,
11404
+ inputSchema: inputSchema11,
10319
11405
  handler: async (args) => {
10320
11406
  const userId = args.userId;
10321
11407
  const scope = args.scope;
@@ -10341,18 +11427,18 @@ var listSchemas = ({ client, log }) => ({
10341
11427
  var list_schemas_default = listSchemas;
10342
11428
 
10343
11429
  // src/tools/document_get.ts
10344
- import { z as z11 } from "zod";
11430
+ import { z as z12 } from "zod";
10345
11431
  var MAX_TEXT_CHARS = 32e3;
10346
- var inputSchema11 = {
10347
- documentId: z11.string().optional().describe("The document ID returned by document_ingest or hybrid_search. Provide this OR externalId+type."),
10348
- externalId: z11.string().optional().describe(
11432
+ var inputSchema12 = {
11433
+ documentId: z12.string().optional().describe("The document ID returned by document_ingest or hybrid_search. Provide this OR externalId+type."),
11434
+ externalId: z12.string().optional().describe(
10349
11435
  "Your caller-owned externalId \u2014 an alternative selector to `documentId` (requires `type`). Fetches the document you ingested under that externalId without a manual lookup first."
10350
11436
  ),
10351
- type: z11.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10352
- includeText: z11.boolean().optional().describe(
11437
+ type: z12.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11438
+ includeText: z12.boolean().optional().describe(
10353
11439
  "If true, fetch and include the document text (capped at ~8K tokens, truncated: true flag if cut). Default false \u2014 metadata only. For larger documents, prefer `document_ask` over dumping text into context."
10354
11440
  ),
10355
- includeDownloadUrl: z11.boolean().optional().describe(
11441
+ includeDownloadUrl: z12.boolean().optional().describe(
10356
11442
  "If true, also return a short-lived presigned `downloadUrl` for the original file (file-backed documents only \u2014 the way to retrieve the raw bytes of a document ingested via file mode). Default false. Unavailable for text-only documents \u2014 `downloadAvailable: false` is set instead."
10357
11443
  )
10358
11444
  };
@@ -10369,7 +11455,7 @@ var documentGet = ({ client, log }) => ({
10369
11455
  name: "document_get",
10370
11456
  title: "Get document metadata (and optionally text)",
10371
11457
  description: "Fetch metadata for a single document \u2014 select it by its Vectros `documentId` OR by your own `externalId` + `type` (resolved for you). Pass `includeText: true` to also fetch the text body (capped at ~8K tokens; `truncated: true` flag if cut). Text is available for every text-ingested document and for file-ingested documents unless they were uploaded with `storeText: false` (extracted text discarded after indexing) \u2014 then `textAvailable: false` is set; the original file is still retrievable via `includeDownloadUrl`. Pass `includeDownloadUrl: true` to also get a short-lived presigned `downloadUrl` for the original file (file-backed documents only). Returns the full document metadata, including its lifecycle `status` (ACTIVE, or ARCHIVED when soft-retracted from search \u2014 restorable via document_update) and its processing `indexStatus`. When `indexStatus` is FAILED the response also carries `indexFailure` with a machine-readable `code` telling you whether the content is still findable \u2014 e.g. TEXT_INDEX_FAILED / VECTOR_LIMIT_EXCEEDED (one leg still serves it) vs INDEXING_FAILED (not findable by search at all). Branch on `code`, not on the message.",
10372
- inputSchema: inputSchema11,
11458
+ inputSchema: inputSchema12,
10373
11459
  handler: async (args) => {
10374
11460
  const documentId = args.documentId;
10375
11461
  const externalId = args.externalId;
@@ -10434,28 +11520,28 @@ var documentGet = ({ client, log }) => ({
10434
11520
  var document_get_default = documentGet;
10435
11521
 
10436
11522
  // src/tools/document_query.ts
10437
- import { z as z12 } from "zod";
11523
+ import { z as z13 } from "zod";
10438
11524
  var MCP_DEFAULT_LIMIT3 = 3;
10439
11525
  var MCP_MAX_LIMIT3 = 100;
10440
- var inputSchema12 = {
11526
+ var inputSchema13 = {
10441
11527
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
10442
- field: z12.string().optional().describe("Lookup mode: name of the lookup-indexed field to query by."),
10443
- value: z12.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields too."),
10444
- from: z12.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Range-enabled, non-sensitive fields only."),
10445
- to: z12.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
10446
- prefix: z12.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
10447
- order: z12.enum(["asc", "desc"]).optional().describe(
11528
+ field: z13.string().optional().describe("Lookup mode: name of the lookup-indexed field to query by."),
11529
+ value: z13.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields too."),
11530
+ from: z13.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Range-enabled, non-sensitive fields only."),
11531
+ to: z13.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
11532
+ prefix: z13.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
11533
+ order: z13.enum(["asc", "desc"]).optional().describe(
10448
11534
  "Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc` \u2014 use `desc` with a range/prefix lookup to get the most-recent / highest values first (e.g. latest-N). Ignored in list mode."
10449
11535
  ),
10450
- type: z12.string().optional().describe("Lookup mode: the document type (the bound schema's type). Required with `field`."),
11536
+ type: z13.string().optional().describe("Lookup mode: the document type (the bound schema's type). Required with `field`."),
10451
11537
  // List-mode args:
10452
- folderId: z12.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
10453
- userId: z12.string().optional().describe("List mode: scope to documents owned by this user."),
10454
- scope: z12.string().optional().describe(
11538
+ folderId: z13.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
11539
+ userId: z13.string().optional().describe("List mode: scope to documents owned by this user."),
11540
+ scope: z13.string().optional().describe(
10455
11541
  '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 reserved namespace names, registered like any other; others are namespaces you registered yourself.'
10456
11542
  ),
10457
- startFrom: z12.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next. Works in both list and lookup mode."),
10458
- limit: z12.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
11543
+ startFrom: z13.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next. Works in both list and lookup mode."),
11544
+ limit: z13.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
10459
11545
  `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.`
10460
11546
  )
10461
11547
  };
@@ -10463,7 +11549,7 @@ var documentQuery = ({ client, log }) => ({
10463
11549
  name: "document_query",
10464
11550
  title: "Document query (list or lookup)",
10465
11551
  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.",
10466
- inputSchema: inputSchema12,
11552
+ inputSchema: inputSchema13,
10467
11553
  handler: async (args) => {
10468
11554
  const limit = args.limit ?? MCP_DEFAULT_LIMIT3;
10469
11555
  const field = args.field;
@@ -10543,29 +11629,29 @@ var documentQuery = ({ client, log }) => ({
10543
11629
  var document_query_default = documentQuery;
10544
11630
 
10545
11631
  // src/tools/document_update.ts
10546
- import { z as z13 } from "zod";
10547
- var inputSchema13 = {
10548
- documentId: z13.string().optional().describe("The Vectros document id to update. Provide this OR externalId+type."),
10549
- externalId: z13.string().optional().describe(
11632
+ import { z as z14 } from "zod";
11633
+ var inputSchema14 = {
11634
+ documentId: z14.string().optional().describe("The Vectros document id to update. Provide this OR externalId+type."),
11635
+ externalId: z14.string().optional().describe(
10550
11636
  "Your caller-owned externalId \u2014 an alternative selector to `documentId` (requires `type`). Updates the document you ingested under that externalId without a manual lookup first."
10551
11637
  ),
10552
- type: z13.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10553
- title: z13.string().optional().describe("New title. Omit to keep the current title."),
10554
- fields: z13.record(z13.string(), z13.unknown()).optional().describe(
11638
+ type: z14.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11639
+ title: z14.string().optional().describe("New title. Omit to keep the current title."),
11640
+ fields: z14.record(z14.string(), z14.unknown()).optional().describe(
10555
11641
  "Typed-payload field\u2192value changes DEEP-MERGED into the existing payload (a field set to `null` is deleted; unspecified fields preserved). Omit to leave the payload unchanged."
10556
11642
  ),
10557
- text: z13.string().optional().describe(
11643
+ text: z14.string().optional().describe(
10558
11644
  "New raw text body. Supplying it re-ingests the document body and re-queues it for indexing, so the search index reflects the edit (text-ingested documents only \u2014 not file-backed ones). Omit to leave the stored text unchanged. This is the in-place alternative to re-ingesting with upsert:true."
10559
11645
  ),
10560
- folderId: z13.string().optional().describe("Move the document into this folder (cannot be cleared once set)."),
10561
- status: z13.enum(["ACTIVE", "ARCHIVED"]).optional().describe(
11646
+ folderId: z14.string().optional().describe("Move the document into this folder (cannot be cleared once set)."),
11647
+ status: z14.enum(["ACTIVE", "ARCHIVED"]).optional().describe(
10562
11648
  "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."
10563
11649
  ),
10564
- userId: z13.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10565
- scopes: z13.array(z13.string()).optional().describe(
11650
+ userId: z14.string().optional().describe("Reassign the owning user (Vectros UUID)."),
11651
+ scopes: z14.array(z14.string()).optional().describe(
10566
11652
  '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 reserved namespace names, registered like any other. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
10567
11653
  ),
10568
- expectedVersion: z13.number().int().optional().describe(
11654
+ expectedVersion: z14.number().int().optional().describe(
10569
11655
  "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."
10570
11656
  )
10571
11657
  };
@@ -10573,7 +11659,7 @@ var documentUpdate = ({ client, log }) => ({
10573
11659
  name: "document_update",
10574
11660
  title: "Update a document",
10575
11661
  description: 'Update a document \u2014 select it by its Vectros `documentId` OR by your own `externalId` + `type` (resolved for you). `fields` are DEEP-MERGED into the existing typed payload (unspecified fields preserved; a field set to `null` is deleted); title/folderId/status/ownership are updated when provided and preserved otherwise. Supply `text` to re-ingest and re-index the document body in place (text documents only). Set `status: "ARCHIVED"` to soft-retract a document (pulled from search, kept and recoverable) and `status: "ACTIVE"` to restore it. Pass `expectedVersion` (the version you last read) for safe concurrent edits \u2014 a stale update is refused (409). Requires the key to allow documents:u.',
10576
- inputSchema: inputSchema13,
11662
+ inputSchema: inputSchema14,
10577
11663
  handler: async (args) => {
10578
11664
  const documentId = args.documentId;
10579
11665
  const externalId = args.externalId;
@@ -10613,15 +11699,15 @@ var documentUpdate = ({ client, log }) => ({
10613
11699
  var document_update_default = documentUpdate;
10614
11700
 
10615
11701
  // src/tools/document_delete.ts
10616
- import { z as z14 } from "zod";
10617
- var inputSchema14 = {
10618
- documentId: z14.string().min(1, "documentId is required").describe("The Vectros document id to delete.")
11702
+ import { z as z15 } from "zod";
11703
+ var inputSchema15 = {
11704
+ documentId: z15.string().min(1, "documentId is required").describe("The Vectros document id to delete.")
10619
11705
  };
10620
11706
  var documentDelete = ({ client, log }) => ({
10621
11707
  name: "document_delete",
10622
11708
  title: "Delete a document",
10623
11709
  description: 'Permanently delete a document by id (removes it and its indexed content). Requires the key to allow documents:d \u2014 a key without it gets a permission error. To archive without deleting, use document_update to set status: "ARCHIVED" instead (recoverable, and needs no delete authority).',
10624
- inputSchema: inputSchema14,
11710
+ inputSchema: inputSchema15,
10625
11711
  handler: async (args) => {
10626
11712
  const documentId = args.documentId;
10627
11713
  try {
@@ -10639,18 +11725,18 @@ var documentDelete = ({ client, log }) => ({
10639
11725
  var document_delete_default = documentDelete;
10640
11726
 
10641
11727
  // src/tools/folder_query.ts
10642
- import { z as z15 } from "zod";
11728
+ import { z as z16 } from "zod";
10643
11729
  var MCP_DEFAULT_LIMIT4 = 10;
10644
11730
  var MCP_MAX_LIMIT4 = 100;
10645
- var inputSchema15 = {
10646
- id: z15.string().optional().describe("Get mode: fetch this single folder by id."),
10647
- parentId: z15.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
10648
- userId: z15.string().optional().describe("List mode: scope to folders owned by this user."),
10649
- scope: z15.string().optional().describe(
11731
+ var inputSchema16 = {
11732
+ id: z16.string().optional().describe("Get mode: fetch this single folder by id."),
11733
+ parentId: z16.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
11734
+ userId: z16.string().optional().describe("List mode: scope to folders owned by this user."),
11735
+ scope: z16.string().optional().describe(
10650
11736
  '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 reserved namespace names, registered like any other; others are namespaces you registered yourself.'
10651
11737
  ),
10652
- startFrom: z15.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
10653
- limit: z15.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
11738
+ startFrom: z16.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
11739
+ limit: z16.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
10654
11740
  `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\`.`
10655
11741
  )
10656
11742
  };
@@ -10658,7 +11744,7 @@ var folderQuery = ({ client, log }) => ({
10658
11744
  name: "folder_query",
10659
11745
  title: "Folder query (list or get)",
10660
11746
  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.",
10661
- inputSchema: inputSchema15,
11747
+ inputSchema: inputSchema16,
10662
11748
  handler: async (args) => {
10663
11749
  const id = args.id;
10664
11750
  try {
@@ -10688,14 +11774,14 @@ var folderQuery = ({ client, log }) => ({
10688
11774
  var folder_query_default = folderQuery;
10689
11775
 
10690
11776
  // src/tools/folder_create.ts
10691
- import { z as z16 } from "zod";
10692
- var inputSchema16 = {
10693
- name: z16.string().min(1, "name is required").describe("Folder display name."),
10694
- description: z16.string().optional().describe("Optional description of the folder's purpose."),
10695
- parentId: z16.string().optional().describe("Parent folder id \u2014 places the folder under this parent. Omit for the context default root. Create-only."),
10696
- slug: z16.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
10697
- userId: z16.string().optional().describe("Owning user (Vectros UUID)."),
10698
- scopes: z16.array(z16.string()).optional().describe(
11777
+ import { z as z17 } from "zod";
11778
+ var inputSchema17 = {
11779
+ name: z17.string().min(1, "name is required").describe("Folder display name."),
11780
+ description: z17.string().optional().describe("Optional description of the folder's purpose."),
11781
+ parentId: z17.string().optional().describe("Parent folder id \u2014 places the folder under this parent. Omit for the context default root. Create-only."),
11782
+ slug: z17.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
11783
+ userId: z17.string().optional().describe("Owning user (Vectros UUID)."),
11784
+ scopes: z17.array(z17.string()).optional().describe(
10699
11785
  'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. 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.'
10700
11786
  )
10701
11787
  };
@@ -10703,7 +11789,7 @@ var folderCreate = ({ client, log }) => ({
10703
11789
  name: "folder_create",
10704
11790
  title: "Create a folder",
10705
11791
  description: "Create a folder to organize documents and records. Pass `parentId` to nest it (create-only \u2014 folders cannot be moved later). Idempotent by `slug` within the parent. Requires the key to allow folders:c (and folders:r to receive the existing folder on a collision).",
10706
- inputSchema: inputSchema16,
11792
+ inputSchema: inputSchema17,
10707
11793
  handler: async (args) => {
10708
11794
  try {
10709
11795
  const folder = await client.folders.createFolder({
@@ -10727,16 +11813,16 @@ var folderCreate = ({ client, log }) => ({
10727
11813
  var folder_create_default = folderCreate;
10728
11814
 
10729
11815
  // src/tools/folder_update.ts
10730
- import { z as z17 } from "zod";
10731
- var inputSchema17 = {
10732
- id: z17.string().min(1, "id is required").describe("The Vectros folder id to update."),
10733
- name: z17.string().optional().describe("New folder name. Omit to keep the current name."),
10734
- description: z17.string().optional().describe("New description. Omit to leave unchanged."),
10735
- userId: z17.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10736
- scopes: z17.array(z17.string()).optional().describe(
11816
+ import { z as z18 } from "zod";
11817
+ var inputSchema18 = {
11818
+ id: z18.string().min(1, "id is required").describe("The Vectros folder id to update."),
11819
+ name: z18.string().optional().describe("New folder name. Omit to keep the current name."),
11820
+ description: z18.string().optional().describe("New description. Omit to leave unchanged."),
11821
+ userId: z18.string().optional().describe("Reassign the owning user (Vectros UUID)."),
11822
+ scopes: z18.array(z18.string()).optional().describe(
10737
11823
  '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 reserved namespace names, registered like any other. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
10738
11824
  ),
10739
- expectedVersion: z17.number().int().optional().describe(
11825
+ expectedVersion: z18.number().int().optional().describe(
10740
11826
  "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."
10741
11827
  )
10742
11828
  };
@@ -10744,7 +11830,7 @@ var folderUpdate = ({ client, log }) => ({
10744
11830
  name: "folder_update",
10745
11831
  title: "Update a folder",
10746
11832
  description: "Update a folder's name / description / ownership by id (RFC-7386 merge \u2014 omitted fields preserved). Pass `expectedVersion` (the version you last read) for safe concurrent edits \u2014 a stale update is refused (409). Folders cannot be moved (re-parenting is not supported by the API). Requires the key to allow folders:u.",
10747
- inputSchema: inputSchema17,
11833
+ inputSchema: inputSchema18,
10748
11834
  handler: async (args) => {
10749
11835
  const id = args.id;
10750
11836
  const name = args.name;
@@ -10771,15 +11857,15 @@ var folderUpdate = ({ client, log }) => ({
10771
11857
  var folder_update_default = folderUpdate;
10772
11858
 
10773
11859
  // src/tools/folder_delete.ts
10774
- import { z as z18 } from "zod";
10775
- var inputSchema18 = {
10776
- id: z18.string().min(1, "id is required").describe("The Vectros folder id to delete.")
11860
+ import { z as z19 } from "zod";
11861
+ var inputSchema19 = {
11862
+ id: z19.string().min(1, "id is required").describe("The Vectros folder id to delete.")
10777
11863
  };
10778
11864
  var folderDelete = ({ client, log }) => ({
10779
11865
  name: "folder_delete",
10780
11866
  title: "Delete a folder",
10781
- description: "Permanently delete a folder by id. Requires the key to allow folders:d \u2014 a key without it gets a permission error. Protected folders (e.g. a context root) cannot be deleted.",
10782
- inputSchema: inputSchema18,
11867
+ description: 'Permanently delete a folder by id. The folder must be EMPTY first \u2014 it must contain no documents, no records, and no sub-folders \u2014 and a non-empty folder is refused, which is the most common way this call fails. Use record_query with this folderId, and document_query, to see what is in it. Clearing it differs by content type: a document can be moved out (document_update with a different folderId) or deleted. A RECORD can also be re-filed into another folder \u2014 the API supports it \u2014 but THIS SERVER does not expose that yet: record_update has no folderId argument, so from here your only option is record_delete (needs records:d). Do NOT read that as "the record cannot be moved" and delete partner data on that basis: if the record should be kept, move it with the Vectros API/SDK directly rather than deleting it here. A sub-folder cannot be re-parented at all, so nested folders have to be emptied and deleted innermost-first. Note the emptiness check counts everything in the folder, INCLUDING items your credential cannot read \u2014 so a refusal you cannot account for from what you can list is expected behaviour, not a bug, and retrying will not clear it. Requires the key to allow folders:d \u2014 a key without it gets a permission error. Protected folders (e.g. a context root) cannot be deleted at all, however empty.',
11868
+ inputSchema: inputSchema19,
10783
11869
  handler: async (args) => {
10784
11870
  const id = args.id;
10785
11871
  try {
@@ -10795,14 +11881,14 @@ var folderDelete = ({ client, log }) => ({
10795
11881
  var folder_delete_default = folderDelete;
10796
11882
 
10797
11883
  // src/tools/current_identity.ts
10798
- var inputSchema19 = {
11884
+ var inputSchema20 = {
10799
11885
  // No args — current_identity describes the current credential.
10800
11886
  };
10801
11887
  var currentIdentity = ({ log, apiKey, environment }) => ({
10802
11888
  name: "current_identity",
10803
11889
  title: "Current identity (tenant + principal scope)",
10804
- description: "Describe the credential the MCP server is operating under. Returns tenantId, environment (staging|production), principalType (root_key|scoped_key|token), principalKeyId, principalLabel, and (for scoped credentials) allowedActions plus dataScope \u2014 the credential's verb+ownership reach as { userId, scopes[] }, where each scope is a `namespace:value` string (e.g. \"org:<uuid>\"). Note: this does not yet include granted_capabilities (member-lifecycle / forensic-read / context-directory-read / delegate-mint) \u2014 a separate reach dimension a scope clause can carry as of API 0.40.0 that /v1/ping does not report yet, so allowedActions+dataScope may understate a credential's true reach. Also reports mcpServerVersion (this server's own package version) and sdkVersion (the bundled @vectros-ai/sdk version) so a caller can tell what build it's talking to. Use this when the user asks 'what can you do here?', 'what tenant am I in?', or 'what version is this?'. Calls GET /v1/ping under the hood.",
10805
- inputSchema: inputSchema19,
11890
+ description: "Describe the credential the MCP server is operating under. Returns tenantId, environment (staging|production), principalType (root_key|scoped_key|token), principalKeyId, principalLabel, and (for scoped credentials) allowedActions plus dataScope \u2014 the credential's verb+ownership reach as { userId, scopes[] }, where each scope is a `namespace:value` string (e.g. \"org:<uuid>\"). Note: this does not yet include granted_capabilities (member-lifecycle / forensic-read / context-directory-read / delegate-mint, as of API 0.40.0, joined by delegate-principal-stamp in 0.42.0) \u2014 a separate reach dimension a scope clause can carry that /v1/ping does not report yet, so allowedActions+dataScope may understate a credential's true reach. Also reports mcpServerVersion (this server's own package version) and sdkVersion (the bundled @vectros-ai/sdk version) so a caller can tell what build it's talking to. Use this when the user asks 'what can you do here?', 'what tenant am I in?', or 'what version is this?'. Calls GET /v1/ping under the hood.",
11891
+ inputSchema: inputSchema20,
10806
11892
  handler: async () => {
10807
11893
  try {
10808
11894
  const identity = await resolveIdentity({ log, apiKey, environment });
@@ -10818,7 +11904,7 @@ var currentIdentity = ({ log, apiKey, environment }) => ({
10818
11904
  var current_identity_default = currentIdentity;
10819
11905
 
10820
11906
  // src/tools/document_ingest.ts
10821
- import { z as z19 } from "zod";
11907
+ import { z as z20 } from "zod";
10822
11908
  import { readFile, realpath } from "fs/promises";
10823
11909
  import { basename, extname, resolve, relative, isAbsolute } from "path";
10824
11910
  var IngestPathError = class extends Error {
@@ -10893,37 +11979,37 @@ function inferMimeType(filePath) {
10893
11979
  const ext = extname(filePath).toLowerCase();
10894
11980
  return EXT_TO_MIME[ext] ?? "application/octet-stream";
10895
11981
  }
10896
- var inputSchema20 = {
10897
- title: z19.string().min(1, "title is required").describe("Human-readable document title \u2014 appears in search results and the UI."),
10898
- indexMode: z19.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
11982
+ var inputSchema21 = {
11983
+ title: z20.string().min(1, "title is required").describe("Human-readable document title \u2014 appears in search results and the UI."),
11984
+ indexMode: z20.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
10899
11985
  "Index strategy. HYBRID (BM25 + dense, default; best for general retrieval), SEMANTIC (dense only; concept-driven queries), TEXT (BM25 only; exact-match / keyword), NONE (store-only / archival \u2014 retrievable by id and structured-field lookup but never in search results). Omit to inherit the bound schema's default."
10900
11986
  ),
10901
- externalId: z19.string().optional().describe(
11987
+ externalId: z20.string().optional().describe(
10902
11988
  'Stable caller-supplied id. Immutable; unique per type within your context. Re-ingesting with the same externalId returns the existing document (idempotent) instead of creating a duplicate \u2014 use it to make ingests safely retryable and as the key other records reference. Mirrors record_create. Receiving the existing document back is a read of it and needs documents:r in addition to documents:c; a create-only key gets an "already exists" error instead of the document.'
10903
11989
  ),
10904
- upsert: z19.boolean().optional().describe(
11990
+ upsert: z20.boolean().optional().describe(
10905
11991
  "When true, re-ingesting an existing externalId OVERWRITES that document and re-indexes the new body (text mode) / re-uploads and re-indexes the new file (file mode), instead of returning the existing one unchanged. This is the curation/re-sync primitive: edit a source, re-ingest with upsert:true, and the search index reflects the new content. Requires the documents:u scope. IMPORTANT: pass the SAME schemaId (and type) you used originally \u2014 externalId is unique WITHIN a type, so omitting schemaId resolves in the untyped namespace and mints a duplicate instead of updating. The response `created` flag confirms which happened (created:true = a new document was minted)."
10906
11992
  ),
10907
- schemaId: z19.string().optional().describe(
11993
+ schemaId: z20.string().optional().describe(
10908
11994
  "Bind this document to a record schema. When set, `payload` is validated against the schema and its lookup fields become directly queryable via document_query (records parity). Resolve a schema id from its type via list_schemas. Omit for an untyped document."
10909
11995
  ),
10910
- payload: z19.record(z19.string(), z19.unknown()).optional().describe(
11996
+ payload: z20.record(z20.string(), z20.unknown()).optional().describe(
10911
11997
  "The document's structured data \u2014 a flat key/value object. With `schemaId`, declared fields are validated and lookup fields indexed; undeclared keys pass through as free-form and are searchable via the hybrid_search `filters` param. Without a schema it is stored as free-form metadata. Every number must fall within the signed 64-bit range \u2014 send a larger whole number as a STRING (stored exactly, exact-match lookup), else the ingest is refused with a 400 naming the field."
10912
11998
  ),
10913
11999
  // Inline text mode (mutually exclusive with filePath):
10914
- text: z19.string().min(1).optional().describe("Text body to ingest inline. Mutually exclusive with filePath. Either text or filePath is required."),
10915
- storeText: z19.boolean().optional().describe(
12000
+ text: z20.string().min(1).optional().describe("Text body to ingest inline. Mutually exclusive with filePath. Either text or filePath is required."),
12001
+ storeText: z20.boolean().optional().describe(
10916
12002
  "FILE MODE ONLY. Whether the uploaded file's EXTRACTED text is retained after indexing (default true), fixed at ingest. true keeps the extracted text retrievable via document_get(includeText:true) and usable by document_ask; false discards it once indexing completes \u2014 search still works and the original file remains downloadable, but includeText returns textAvailable:false and document_ask is unavailable. NOT accepted with `text`: a text-ingested body is the document itself and is ALWAYS retained, so the backend has no storeText knob on the text path \u2014 passing it with `text` is rejected rather than silently ignored."
10917
12003
  ),
10918
12004
  // File upload mode (mutually exclusive with text; stdio-transport-only):
10919
- filePath: z19.string().min(1).optional().describe(
12005
+ filePath: z20.string().min(1).optional().describe(
10920
12006
  "Local filesystem path to upload. Mutually exclusive with text. STDIO TRANSPORT ONLY \u2014 rejected on HTTP transport (remote MCP servers can't read your filesystem; use text mode or call the SDK's uploadDocument directly). Must resolve INSIDE the configured ingest root (VECTROS_MCP_INGEST_ROOT, else the server's working directory); paths that escape it (traversal/absolute/symlink) or match a sensitive pattern are rejected."
10921
12007
  ),
10922
- fileType: z19.string().optional().describe('MIME type of the file (e.g. "application/pdf"). Inferred from filePath extension if omitted.'),
12008
+ fileType: z20.string().optional().describe('MIME type of the file (e.g. "application/pdf"). Inferred from filePath extension if omitted.'),
10923
12009
  // Common (both modes):
10924
- folderId: z19.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
10925
- userId: z19.string().optional().describe("Owning user ID. Optional."),
10926
- scopes: z19.array(z19.string()).optional().describe(
12010
+ folderId: z20.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
12011
+ userId: z20.string().optional().describe("Owning user ID. Optional."),
12012
+ scopes: z20.array(z20.string()).optional().describe(
10927
12013
  "TEXT MODE ONLY. Scope ownership as `namespace:value` entries, at most 2 (e.g. [\"org:<uuid>\", \"group:eng-team\"]). `org` and `client` are reserved namespace names, registered like any other; others are namespaces you registered yourself. 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."
10928
12014
  )
10929
12015
  };
@@ -10931,7 +12017,7 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10931
12017
  name: "document_ingest",
10932
12018
  title: "Ingest a new document (text body or file upload)",
10933
12019
  description: "Create a new document in your Vectros tenant. Two modes:\n \u2022 Text mode: pass `text` (string body). Single-call. Use for crawled content, notes, generated text.\n \u2022 File mode: pass `filePath` (local path on the MCP server's host machine). STDIO-TRANSPORT ONLY \u2014 rejected on HTTP transport. MCP server reads the bytes, requests a presigned upload URL, and PUTs them. Returns when the upload is accepted (indexStatus: PENDING_INDEX); poll with `document_get` until indexStatus is INDEXED.\nEither `text` or `filePath` must be present; both is an error. Idempotent by `externalId` (re-ingest returns the existing document, not a duplicate \u2014 requires documents:r in addition to documents:c, since being handed the existing document is a read of it). To UPDATE an existing document instead \u2014 re-index an edited body \u2014 pass `upsert:true` with the same `externalId` (and the same `schemaId`); this is the re-sync primitive for keeping a knowledge base current. Pass `schemaId` + `payload` for a typed, lookup-queryable document (records parity). indexMode defaults to HYBRID for untyped documents (omit to inherit a bound schema's default). storeText is a FILE-MODE knob (default true): false discards the uploaded file's extracted text after indexing (search + file download keep working; text retrieval and document_ask do not). Text-mode bodies are always retained, so storeText is not accepted with `text`.",
10934
- inputSchema: inputSchema20,
12020
+ inputSchema: inputSchema21,
10935
12021
  handler: async (args) => {
10936
12022
  const title = args.title;
10937
12023
  const text = args.text;
@@ -11083,29 +12169,29 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
11083
12169
  var document_ingest_default = documentIngest;
11084
12170
 
11085
12171
  // src/tools/lookup_principal.ts
11086
- import { z as z20 } from "zod";
12172
+ import { z as z21 } from "zod";
11087
12173
  var MCP_DEFAULT_LIMIT5 = 10;
11088
12174
  var MCP_MAX_LIMIT5 = 100;
11089
- var inputSchema21 = {
11090
- kind: z20.string().describe(
12175
+ var inputSchema22 = {
12176
+ kind: z21.string().describe(
11091
12177
  'Which principal to look up: "user" (the fixed principal surface), or an entity namespace \u2014 "org", "client" (reserved, registered like any other), or a namespace you registered.'
11092
12178
  ),
11093
- externalId: z20.string().optional().describe(
12179
+ externalId: z21.string().optional().describe(
11094
12180
  "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."
11095
12181
  ),
11096
- contextId: z20.string().optional().describe(
12182
+ contextId: z21.string().optional().describe(
11097
12183
  "Entity kinds only (not `user`, which is always tenant-wide): the app context to look up entities in, for a namespace registered as context-owned rather than tenant-wide. A context-confined credential's own context is used automatically without this; supply it to name a context explicitly (required for an unconfined/root credential to reach a context-owned namespace). Rejected if the namespace turns out to be tenant-wide."
11098
12184
  ),
11099
12185
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
11100
- type: z20.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
11101
- field: z20.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
11102
- value: z20.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields."),
11103
- from: z20.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Non-sensitive fields only."),
11104
- to: z20.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
11105
- prefix: z20.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
11106
- order: z20.enum(["asc", "desc"]).optional().describe("Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc`."),
11107
- startFrom: z20.string().optional().describe("Lookup mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
11108
- limit: z20.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(
12186
+ type: z21.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
12187
+ field: z21.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
12188
+ value: z21.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields."),
12189
+ from: z21.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Non-sensitive fields only."),
12190
+ to: z21.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
12191
+ prefix: z21.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
12192
+ order: z21.enum(["asc", "desc"]).optional().describe("Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc`."),
12193
+ startFrom: z21.string().optional().describe("Lookup mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
12194
+ limit: z21.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(
11109
12195
  `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\`.`
11110
12196
  )
11111
12197
  };
@@ -11113,7 +12199,7 @@ var lookupPrincipal = ({ client, log }) => ({
11113
12199
  name: "lookup_principal",
11114
12200
  title: "Look up a user identity or a namespaced identity entity",
11115
12201
  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.) For an entity kind, `contextId` names a specific app context when the namespace is context-owned rather than tenant-wide; a context-confined credential's own context is used automatically without it. 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.",
11116
- inputSchema: inputSchema21,
12202
+ inputSchema: inputSchema22,
11117
12203
  handler: async (args) => {
11118
12204
  const kind = args.kind;
11119
12205
  const isUser = kind === "user";
@@ -11187,17 +12273,17 @@ var lookupPrincipal = ({ client, log }) => ({
11187
12273
  var lookup_principal_default = lookupPrincipal;
11188
12274
 
11189
12275
  // src/tools/version_history.ts
11190
- import { z as z21 } from "zod";
11191
- var inputSchema22 = {
11192
- resourceType: z21.enum(["record", "document"]).describe("Which kind of entity the id refers to: a record or a document."),
11193
- id: z21.string().min(1, "id is required").describe("The Vectros id of the record or document whose history you want."),
11194
- startFrom: z21.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch older entries.")
12276
+ import { z as z22 } from "zod";
12277
+ var inputSchema23 = {
12278
+ resourceType: z22.enum(["record", "document"]).describe("Which kind of entity the id refers to: a record or a document."),
12279
+ id: z22.string().min(1, "id is required").describe("The Vectros id of the record or document whose history you want."),
12280
+ startFrom: z22.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch older entries.")
11195
12281
  };
11196
12282
  var versionHistory = ({ client, log }) => ({
11197
12283
  name: "version_history",
11198
12284
  title: "Version history (record or document)",
11199
12285
  description: "Read the audit/version trail (CREATE/UPDATE/DELETE, with actor, timestamp, and diff) for a single record or document. Pass `resourceType` (record|document) and `id`. Returns `{ data, nextCursor }`; pass `nextCursor` back as `startFrom` to page through older entries. Entities without audit history (untyped) return an empty trail. Read-only.",
11200
- inputSchema: inputSchema22,
12286
+ inputSchema: inputSchema23,
11201
12287
  handler: async (args) => {
11202
12288
  const resourceType = args.resourceType;
11203
12289
  const id = args.id;
@@ -11226,6 +12312,7 @@ var TOOL_NAMES = [
11226
12312
  "record_get",
11227
12313
  "record_batch_get",
11228
12314
  "record_create",
12315
+ "record_batch_write",
11229
12316
  "record_update",
11230
12317
  "record_delete",
11231
12318
  "rag_ask",
@@ -11252,6 +12339,7 @@ var ALL_TOOL_FACTORIES = {
11252
12339
  record_get: record_get_default,
11253
12340
  record_batch_get: record_batch_get_default,
11254
12341
  record_create: record_create_default,
12342
+ record_batch_write: record_batch_write_default,
11255
12343
  record_update: record_update_default,
11256
12344
  record_delete: record_delete_default,
11257
12345
  rag_ask: rag_ask_default,
@@ -11292,7 +12380,7 @@ var identityResource = ({ log, apiKey, environment }) => ({
11292
12380
  name: "identity",
11293
12381
  uri: "vectros://identity",
11294
12382
  title: "Current identity (tenant + principal scope)",
11295
- description: "The tenant + principal scope the MCP server is authenticated as. Returns the same payload as the `current_identity` tool: status, tenantId, environment, principalType, principalKeyId, principalLabel, (for scoped credentials) allowedActions + dataScope ({ userId, scopes[] }). Note: this does not yet include granted_capabilities (member-lifecycle / forensic-read / context-directory-read / delegate-mint) \u2014 a separate reach dimension a scope clause can carry as of API 0.40.0 that /v1/ping does not report yet, so allowedActions+dataScope may understate a credential's true reach. Also reports mcpServerVersion and sdkVersion (this build's own version and the bundled @vectros-ai/sdk version). The /v1/ping backing call ships the extended shape today; the version fields are always client-derived.",
12383
+ description: "The tenant + principal scope the MCP server is authenticated as. Returns the same payload as the `current_identity` tool: status, tenantId, environment, principalType, principalKeyId, principalLabel, (for scoped credentials) allowedActions + dataScope ({ userId, scopes[] }). Note: this does not yet include granted_capabilities (member-lifecycle / forensic-read / context-directory-read / delegate-mint, as of API 0.40.0, joined by delegate-principal-stamp in 0.42.0) \u2014 a separate reach dimension a scope clause can carry that /v1/ping does not report yet, so allowedActions+dataScope may understate a credential's true reach. Also reports mcpServerVersion and sdkVersion (this build's own version and the bundled @vectros-ai/sdk version). The /v1/ping backing call ships the extended shape today; the version fields are always client-derived.",
11296
12384
  mimeType: "application/json",
11297
12385
  read: async () => {
11298
12386
  const identity = await resolveIdentity({ log, apiKey, environment });
@@ -11311,7 +12399,7 @@ var ALL_RESOURCE_FACTORIES = {
11311
12399
  };
11312
12400
 
11313
12401
  // src/zod-to-json-schema.ts
11314
- import { z as z22 } from "zod";
12402
+ import { z as z23 } from "zod";
11315
12403
  function zodShapeToJsonSchema(shape) {
11316
12404
  const properties = {};
11317
12405
  const required = [];
@@ -11326,40 +12414,40 @@ function zodShapeToJsonSchema(shape) {
11326
12414
  function zodTypeToJsonSchema(schema) {
11327
12415
  const description = schema.description;
11328
12416
  let current = schema;
11329
- while (current instanceof z22.ZodOptional || current instanceof z22.ZodDefault || current instanceof z22.ZodNullable) {
12417
+ while (current instanceof z23.ZodOptional || current instanceof z23.ZodDefault || current instanceof z23.ZodNullable) {
11330
12418
  current = current._def.innerType;
11331
12419
  }
11332
12420
  const base = description ? { description } : {};
11333
- if (current instanceof z22.ZodString) {
12421
+ if (current instanceof z23.ZodString) {
11334
12422
  return { ...base, type: "string" };
11335
12423
  }
11336
- if (current instanceof z22.ZodNumber) {
12424
+ if (current instanceof z23.ZodNumber) {
11337
12425
  return { ...base, type: "number" };
11338
12426
  }
11339
- if (current instanceof z22.ZodBoolean) {
12427
+ if (current instanceof z23.ZodBoolean) {
11340
12428
  return { ...base, type: "boolean" };
11341
12429
  }
11342
- if (current instanceof z22.ZodEnum) {
12430
+ if (current instanceof z23.ZodEnum) {
11343
12431
  return {
11344
12432
  ...base,
11345
12433
  type: "string",
11346
12434
  enum: current.options
11347
12435
  };
11348
12436
  }
11349
- if (current instanceof z22.ZodArray) {
12437
+ if (current instanceof z23.ZodArray) {
11350
12438
  return {
11351
12439
  ...base,
11352
12440
  type: "array",
11353
12441
  items: zodTypeToJsonSchema(current.element)
11354
12442
  };
11355
12443
  }
11356
- if (current instanceof z22.ZodObject) {
12444
+ if (current instanceof z23.ZodObject) {
11357
12445
  return {
11358
12446
  ...base,
11359
12447
  ...zodShapeToJsonSchema(current.shape)
11360
12448
  };
11361
12449
  }
11362
- if (current instanceof z22.ZodRecord) {
12450
+ if (current instanceof z23.ZodRecord) {
11363
12451
  const valueType = current._def.valueType;
11364
12452
  return {
11365
12453
  ...base,
@@ -11483,7 +12571,7 @@ var VectrosMCPServer = class {
11483
12571
  if (!tool) {
11484
12572
  result = toolError(req.params.name ?? "unknown", new Error("No such tool."));
11485
12573
  } else {
11486
- const parsed = z23.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
12574
+ const parsed = z24.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
11487
12575
  if (!parsed.success) {
11488
12576
  result = toolError(tool.name, new Error(formatArgError(tool, parsed.error)));
11489
12577
  } else {