@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-http.js CHANGED
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  // src/server.ts
27
27
  var import_server = require("@modelcontextprotocol/sdk/server/index.js");
28
28
 
29
- // node_modules/@vectros-ai/sdk/dist/index.mjs
29
+ // ../../node_modules/@vectros-ai/sdk/dist/index.mjs
30
30
  var __defProp2 = Object.defineProperty;
31
31
  var __export = (target, all) => {
32
32
  for (var name in all)
@@ -60,6 +60,7 @@ __export(api_exports, {
60
60
  FieldDef: () => FieldDef,
61
61
  FileUploadRequest: () => FileUploadRequest,
62
62
  ForbiddenError: () => ForbiddenError,
63
+ GatewayTimeoutError: () => GatewayTimeoutError,
63
64
  IdentityLookupRequest: () => IdentityLookupRequest,
64
65
  IndexFailure: () => IndexFailure,
65
66
  InternalServerError: () => InternalServerError,
@@ -84,9 +85,12 @@ __export(api_exports, {
84
85
  SearchRequest: () => SearchRequest,
85
86
  SearchResult: () => SearchResult,
86
87
  SearchResultsEvent: () => SearchResultsEvent,
88
+ ServiceUnavailableError: () => ServiceUnavailableError,
87
89
  TooManyRequestsError: () => TooManyRequestsError,
90
+ TriggerFailureResponse: () => TriggerFailureResponse,
88
91
  TruncationWarningEvent: () => TruncationWarningEvent,
89
92
  UnauthorizedError: () => UnauthorizedError,
93
+ UnprocessableEntityError: () => UnprocessableEntityError,
90
94
  UserExistsResponse: () => UserExistsResponse,
91
95
  UserRequest: () => UserRequest,
92
96
  UserResponse: () => UserResponse,
@@ -98,7 +102,9 @@ __export(api_exports, {
98
102
  inference: () => inference_exports,
99
103
  records: () => records_exports,
100
104
  schemas: () => schemas_exports,
101
- search: () => search_exports
105
+ scripts: () => scripts_exports,
106
+ search: () => search_exports,
107
+ triggers: () => triggers_exports
102
108
  });
103
109
  var toJson = (value, replacer, space) => {
104
110
  return JSON.stringify(value, replacer, space);
@@ -218,6 +224,21 @@ var ForbiddenError = class extends VectrosError {
218
224
  this.name = this.constructor.name;
219
225
  }
220
226
  };
227
+ var GatewayTimeoutError = class extends VectrosError {
228
+ constructor(body, rawResponse) {
229
+ super({
230
+ message: "GatewayTimeoutError",
231
+ statusCode: 504,
232
+ body,
233
+ rawResponse
234
+ });
235
+ Object.setPrototypeOf(this, new.target.prototype);
236
+ if (Error.captureStackTrace) {
237
+ Error.captureStackTrace(this, this.constructor);
238
+ }
239
+ this.name = this.constructor.name;
240
+ }
241
+ };
221
242
  var InternalServerError = class extends VectrosError {
222
243
  constructor(body, rawResponse) {
223
244
  super({
@@ -278,6 +299,21 @@ var PaymentRequiredError = class extends VectrosError {
278
299
  this.name = this.constructor.name;
279
300
  }
280
301
  };
302
+ var ServiceUnavailableError = class extends VectrosError {
303
+ constructor(body, rawResponse) {
304
+ super({
305
+ message: "ServiceUnavailableError",
306
+ statusCode: 503,
307
+ body,
308
+ rawResponse
309
+ });
310
+ Object.setPrototypeOf(this, new.target.prototype);
311
+ if (Error.captureStackTrace) {
312
+ Error.captureStackTrace(this, this.constructor);
313
+ }
314
+ this.name = this.constructor.name;
315
+ }
316
+ };
281
317
  var TooManyRequestsError = class extends VectrosError {
282
318
  constructor(body, rawResponse) {
283
319
  super({
@@ -308,6 +344,21 @@ var UnauthorizedError = class extends VectrosError {
308
344
  this.name = this.constructor.name;
309
345
  }
310
346
  };
347
+ var UnprocessableEntityError = class extends VectrosError {
348
+ constructor(body, rawResponse) {
349
+ super({
350
+ message: "UnprocessableEntityError",
351
+ statusCode: 422,
352
+ body,
353
+ rawResponse
354
+ });
355
+ Object.setPrototypeOf(this, new.target.prototype);
356
+ if (Error.captureStackTrace) {
357
+ Error.captureStackTrace(this, this.constructor);
358
+ }
359
+ this.name = this.constructor.name;
360
+ }
361
+ };
311
362
  var auth_exports = {};
312
363
  var ErasureRequest;
313
364
  ((ErasureRequest2) => {
@@ -397,6 +448,7 @@ var LookupRecordsRequestOrder = {
397
448
  Desc: "desc"
398
449
  };
399
450
  var schemas_exports = {};
451
+ var scripts_exports = {};
400
452
  var SearchRequest;
401
453
  ((SearchRequest2) => {
402
454
  SearchRequest2.Mode = {
@@ -422,6 +474,7 @@ var search_exports = {};
422
474
  __export(search_exports, {
423
475
  SearchRequest: () => SearchRequest
424
476
  });
477
+ var triggers_exports = {};
425
478
  var AccessProfileRequest;
426
479
  ((AccessProfileRequest2) => {
427
480
  AccessProfileRequest2.Status = {
@@ -451,7 +504,9 @@ var BatchWriteResult;
451
504
  Created: "created",
452
505
  Updated: "updated",
453
506
  Conflict: "conflict",
454
- Invalid: "invalid"
507
+ Invalid: "invalid",
508
+ Forbidden: "forbidden",
509
+ NotCommitted: "not_committed"
455
510
  };
456
511
  })(BatchWriteResult || (BatchWriteResult = {}));
457
512
  var ChatMessage;
@@ -755,13 +810,23 @@ var SearchResultsEvent;
755
810
  SearchResults: "search_results"
756
811
  };
757
812
  })(SearchResultsEvent || (SearchResultsEvent = {}));
813
+ var TriggerFailureResponse;
814
+ ((TriggerFailureResponse2) => {
815
+ TriggerFailureResponse2.Event = {
816
+ Create: "CREATE",
817
+ Update: "UPDATE",
818
+ Delete: "DELETE"
819
+ };
820
+ })(TriggerFailureResponse || (TriggerFailureResponse = {}));
758
821
  var TruncationWarningEvent;
759
822
  ((TruncationWarningEvent2) => {
760
823
  TruncationWarningEvent2.Event = {
761
824
  TruncationWarning: "truncation_warning"
762
825
  };
763
826
  TruncationWarningEvent2.Reason = {
764
- ContextWindowBudget: "context_window_budget"
827
+ ContextWindowBudget: "context_window_budget",
828
+ NoGroundableContent: "no_groundable_content",
829
+ ContextWindowBudgetAndNoContent: "context_window_budget_and_no_content"
765
830
  };
766
831
  })(TruncationWarningEvent || (TruncationWarningEvent = {}));
767
832
  var UserExistsResponse;
@@ -776,8 +841,7 @@ var UserRequest;
776
841
  ((UserRequest2) => {
777
842
  UserRequest2.Status = {
778
843
  Active: "ACTIVE",
779
- Suspended: "SUSPENDED",
780
- Pending: "PENDING"
844
+ Suspended: "SUSPENDED"
781
845
  };
782
846
  UserRequest2.Type = {
783
847
  Human: "HUMAN",
@@ -2245,6 +2309,16 @@ function mergeHeaders(...headersArray) {
2245
2309
  }
2246
2310
  return result;
2247
2311
  }
2312
+ function mergeOnlyDefinedHeaders(...headersArray) {
2313
+ const result = {};
2314
+ for (const [key, value] of headersArray.filter((headers) => headers != null).flatMap((headers) => Object.entries(headers))) {
2315
+ const insensitiveKey = key.toLowerCase();
2316
+ if (value != null) {
2317
+ result[insensitiveKey] = value;
2318
+ }
2319
+ }
2320
+ return result;
2321
+ }
2248
2322
  function normalizeClientOptions(options) {
2249
2323
  const headers = mergeHeaders(
2250
2324
  {
@@ -2515,7 +2589,7 @@ var AuthClient = class {
2515
2589
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/admin/keys/scoped");
2516
2590
  }
2517
2591
  /**
2518
- * 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.
2592
+ * 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.
2519
2593
  *
2520
2594
  * @param {Vectros.CreateScopedKeyRequest} request
2521
2595
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -2523,6 +2597,7 @@ var AuthClient = class {
2523
2597
  * @throws {@link Vectros.BadRequestError}
2524
2598
  * @throws {@link Vectros.ForbiddenError}
2525
2599
  * @throws {@link Vectros.NotFoundError}
2600
+ * @throws {@link Vectros.ConflictError}
2526
2601
  * @throws {@link Vectros.TooManyRequestsError}
2527
2602
  *
2528
2603
  * @example
@@ -2571,6 +2646,8 @@ var AuthClient = class {
2571
2646
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
2572
2647
  case 404:
2573
2648
  throw new NotFoundError(_response.error.body, _response.rawResponse);
2649
+ case 409:
2650
+ throw new ConflictError(_response.error.body, _response.rawResponse);
2574
2651
  case 429:
2575
2652
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
2576
2653
  default:
@@ -2982,7 +3059,7 @@ var AuthClient = class {
2982
3059
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/app-contexts");
2983
3060
  }
2984
3061
  /**
2985
- * 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.
3062
+ * 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.
2986
3063
  *
2987
3064
  * @param {Vectros.CreateAppContextRequest} request
2988
3065
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3466,7 +3543,7 @@ var AuthClient = class {
3466
3543
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/app-contexts/{contextId}");
3467
3544
  }
3468
3545
  /**
3469
- * 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.
3546
+ * 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.
3470
3547
  *
3471
3548
  * @param {Vectros.UpdateAppContextRequest} request
3472
3549
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3948,7 +4025,7 @@ var AuthClient = class {
3948
4025
  );
3949
4026
  }
3950
4027
  /**
3951
- * 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.
4028
+ * 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`.
3952
4029
  *
3953
4030
  * @param {Vectros.GetUsageRequest} request
3954
4031
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4516,7 +4593,7 @@ var AuthClient = class {
4516
4593
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/token");
4517
4594
  }
4518
4595
  /**
4519
- * 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.
4596
+ * 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.
4520
4597
  *
4521
4598
  * @param {Vectros.CreateInviteRequest} request
4522
4599
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4587,7 +4664,7 @@ var AuthClient = class {
4587
4664
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/users/invite");
4588
4665
  }
4589
4666
  /**
4590
- * 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.
4667
+ * 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.
4591
4668
  *
4592
4669
  * @param {Vectros.CreateInviteRequest} request
4593
4670
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -5460,7 +5537,21 @@ var DocumentsClient = class {
5460
5537
  return HttpResponsePromise.fromPromise(this.__lookupDocuments(request, requestOptions));
5461
5538
  }
5462
5539
  async __lookupDocuments(request, requestOptions) {
5463
- const { type: type_, field, value, from: from_, to, prefix, startFrom, limit, order, userId, scope } = request;
5540
+ const {
5541
+ type: type_,
5542
+ field,
5543
+ value,
5544
+ from: from_,
5545
+ to,
5546
+ prefix,
5547
+ sortFrom,
5548
+ sortTo,
5549
+ startFrom,
5550
+ limit,
5551
+ order,
5552
+ userId,
5553
+ scope
5554
+ } = request;
5464
5555
  const _queryParams = {
5465
5556
  type: type_,
5466
5557
  field,
@@ -5468,6 +5559,8 @@ var DocumentsClient = class {
5468
5559
  from: from_,
5469
5560
  to,
5470
5561
  prefix,
5562
+ sortFrom,
5563
+ sortTo,
5471
5564
  startFrom,
5472
5565
  limit,
5473
5566
  order: order != null ? order : void 0,
@@ -6066,7 +6159,7 @@ var FoldersClient = class {
6066
6159
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/folders/{id}");
6067
6160
  }
6068
6161
  /**
6069
- * 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.
6162
+ * 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.
6070
6163
  *
6071
6164
  * @param {Vectros.DeleteFolderRequest} request
6072
6165
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6475,11 +6568,12 @@ var IdentityClient = class {
6475
6568
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}/{id}");
6476
6569
  }
6477
6570
  /**
6478
- * 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.
6571
+ * 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.
6479
6572
  *
6480
6573
  * @param {Vectros.UpdateEntityRequest} request
6481
6574
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6482
6575
  *
6576
+ * @throws {@link Vectros.BadRequestError}
6483
6577
  * @throws {@link Vectros.NotFoundError}
6484
6578
  * @throws {@link Vectros.TooManyRequestsError}
6485
6579
  *
@@ -6529,6 +6623,8 @@ var IdentityClient = class {
6529
6623
  }
6530
6624
  if (_response.error.reason === "status-code") {
6531
6625
  switch (_response.error.statusCode) {
6626
+ case 400:
6627
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
6532
6628
  case 404:
6533
6629
  throw new NotFoundError(_response.error.body, _response.rawResponse);
6534
6630
  case 429:
@@ -7753,7 +7849,7 @@ var InferenceClient = class {
7753
7849
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/documents/{id}/ask");
7754
7850
  }
7755
7851
  /**
7756
- * 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.
7852
+ * 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.
7757
7853
  */
7758
7854
  ragInference(request, requestOptions) {
7759
7855
  return HttpResponsePromise.fromPromise(this.__ragInference(request, requestOptions));
@@ -7948,14 +8044,18 @@ var RecordsClient = class {
7948
8044
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/records/lookup/batch");
7949
8045
  }
7950
8046
  /**
7951
- * 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.
8047
+ * 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.
8048
+ *
8049
+ * `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.
8050
+ *
8051
+ * 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.
7952
8052
  *
7953
8053
  * @param {Vectros.BatchWriteRequest} request
7954
8054
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
7955
8055
  *
8056
+ * @throws {@link Vectros.BadRequestError}
7956
8057
  * @throws {@link Vectros.ForbiddenError}
7957
8058
  * @throws {@link Vectros.TooManyRequestsError}
7958
- * @throws {@link Vectros.NotImplementedError}
7959
8059
  *
7960
8060
  * @example
7961
8061
  * await client.records.batchWriteRecords()
@@ -7964,6 +8064,11 @@ var RecordsClient = class {
7964
8064
  return HttpResponsePromise.fromPromise(this.__batchWriteRecords(request, requestOptions));
7965
8065
  }
7966
8066
  async __batchWriteRecords(request = {}, requestOptions) {
8067
+ const { upsert, allowClear, ..._body } = request;
8068
+ const _queryParams = {
8069
+ upsert,
8070
+ allowClear
8071
+ };
7967
8072
  const _authRequest = await this._options.authProvider.getAuthRequest();
7968
8073
  const _headers = mergeHeaders(
7969
8074
  _authRequest.headers,
@@ -7978,9 +8083,9 @@ var RecordsClient = class {
7978
8083
  method: "POST",
7979
8084
  headers: _headers,
7980
8085
  contentType: "application/json",
7981
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
8086
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
7982
8087
  requestType: "json",
7983
- body: request,
8088
+ body: _body,
7984
8089
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
7985
8090
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
7986
8091
  abortSignal: requestOptions?.abortSignal,
@@ -7992,12 +8097,12 @@ var RecordsClient = class {
7992
8097
  }
7993
8098
  if (_response.error.reason === "status-code") {
7994
8099
  switch (_response.error.statusCode) {
8100
+ case 400:
8101
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
7995
8102
  case 403:
7996
8103
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
7997
8104
  case 429:
7998
8105
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
7999
- case 501:
8000
- throw new NotImplementedError(_response.error.body, _response.rawResponse);
8001
8106
  default:
8002
8107
  throw new VectrosError({
8003
8108
  statusCode: _response.error.statusCode,
@@ -8900,7 +9005,7 @@ var SchemasClient = class {
8900
9005
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}");
8901
9006
  }
8902
9007
  /**
8903
- * 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.
9008
+ * 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.
8904
9009
  *
8905
9010
  * @param {Vectros.UpdateSchemaRequest} request
8906
9011
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8908,6 +9013,7 @@ var SchemasClient = class {
8908
9013
  * @throws {@link Vectros.BadRequestError}
8909
9014
  * @throws {@link Vectros.ForbiddenError}
8910
9015
  * @throws {@link Vectros.NotFoundError}
9016
+ * @throws {@link Vectros.ConflictError}
8911
9017
  * @throws {@link Vectros.TooManyRequestsError}
8912
9018
  *
8913
9019
  * @example
@@ -8959,6 +9065,8 @@ var SchemasClient = class {
8959
9065
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
8960
9066
  case 404:
8961
9067
  throw new NotFoundError(_response.error.body, _response.rawResponse);
9068
+ case 409:
9069
+ throw new ConflictError(_response.error.body, _response.rawResponse);
8962
9070
  case 429:
8963
9071
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
8964
9072
  default:
@@ -8972,7 +9080,7 @@ var SchemasClient = class {
8972
9080
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/schemas/{id}");
8973
9081
  }
8974
9082
  /**
8975
- * 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.
9083
+ * 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.
8976
9084
  *
8977
9085
  * @param {Vectros.DeleteSchemaRequest} request
8978
9086
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -9094,46 +9202,70 @@ var SchemasClient = class {
9094
9202
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}/versions");
9095
9203
  }
9096
9204
  };
9097
- var SearchClient = class {
9205
+ var ScriptsClient = class {
9098
9206
  constructor(options) {
9099
9207
  this._options = normalizeClientOptionsWithAuth(options);
9100
9208
  }
9101
9209
  /**
9102
- * 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.
9210
+ * 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.
9103
9211
  *
9104
- * @param {Vectros.SearchRequest} request
9105
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
9212
+ * **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.
9213
+ *
9214
+ * **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.
9215
+ *
9216
+ * **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`).
9217
+ *
9218
+ * **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()`.
9219
+ *
9220
+ * **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.
9221
+ *
9222
+ * @param {Vectros.ScriptExecuteRequest} request
9223
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9106
9224
  *
9107
9225
  * @throws {@link Vectros.BadRequestError}
9226
+ * @throws {@link Vectros.PaymentRequiredError}
9108
9227
  * @throws {@link Vectros.ForbiddenError}
9228
+ * @throws {@link Vectros.NotFoundError}
9229
+ * @throws {@link Vectros.ConflictError}
9230
+ * @throws {@link Vectros.ContentTooLargeError}
9231
+ * @throws {@link Vectros.UnprocessableEntityError}
9109
9232
  * @throws {@link Vectros.TooManyRequestsError}
9233
+ * @throws {@link Vectros.InternalServerError}
9234
+ * @throws {@link Vectros.ServiceUnavailableError}
9235
+ * @throws {@link Vectros.GatewayTimeoutError}
9110
9236
  *
9111
9237
  * @example
9112
- * await client.search.content({
9113
- * query: "patient intake form diabetes"
9238
+ * await client.scripts.executeScript({
9239
+ * "Idempotency-Key": "order-8412-attempt",
9240
+ * scriptRef: {
9241
+ * name: "notify-assignee",
9242
+ * version: "3"
9243
+ * }
9114
9244
  * })
9115
9245
  */
9116
- content(request, requestOptions) {
9117
- return HttpResponsePromise.fromPromise(this.__content(request, requestOptions));
9246
+ executeScript(request, requestOptions) {
9247
+ return HttpResponsePromise.fromPromise(this.__executeScript(request, requestOptions));
9118
9248
  }
9119
- async __content(request, requestOptions) {
9249
+ async __executeScript(request, requestOptions) {
9250
+ const { "Idempotency-Key": idempotencyKey, ..._body } = request;
9120
9251
  const _authRequest = await this._options.authProvider.getAuthRequest();
9121
9252
  const _headers = mergeHeaders(
9122
9253
  _authRequest.headers,
9123
9254
  this._options?.headers,
9255
+ mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey }),
9124
9256
  requestOptions?.headers
9125
9257
  );
9126
9258
  const _response = await fetcher({
9127
9259
  url: url_exports.join(
9128
9260
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9129
- "v1/search"
9261
+ "v1/scripts/execute"
9130
9262
  ),
9131
9263
  method: "POST",
9132
9264
  headers: _headers,
9133
9265
  contentType: "application/json",
9134
9266
  queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9135
9267
  requestType: "json",
9136
- body: request,
9268
+ body: _body,
9137
9269
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9138
9270
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9139
9271
  abortSignal: requestOptions?.abortSignal,
@@ -9147,10 +9279,26 @@ var SearchClient = class {
9147
9279
  switch (_response.error.statusCode) {
9148
9280
  case 400:
9149
9281
  throw new BadRequestError(_response.error.body, _response.rawResponse);
9282
+ case 402:
9283
+ throw new PaymentRequiredError(_response.error.body, _response.rawResponse);
9150
9284
  case 403:
9151
9285
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
9286
+ case 404:
9287
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9288
+ case 409:
9289
+ throw new ConflictError(_response.error.body, _response.rawResponse);
9290
+ case 413:
9291
+ throw new ContentTooLargeError(_response.error.body, _response.rawResponse);
9292
+ case 422:
9293
+ throw new UnprocessableEntityError(_response.error.body, _response.rawResponse);
9152
9294
  case 429:
9153
9295
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9296
+ case 500:
9297
+ throw new InternalServerError(_response.error.body, _response.rawResponse);
9298
+ case 503:
9299
+ throw new ServiceUnavailableError(_response.error.body, _response.rawResponse);
9300
+ case 504:
9301
+ throw new GatewayTimeoutError(_response.error.body, _response.rawResponse);
9154
9302
  default:
9155
9303
  throw new VectrosError({
9156
9304
  statusCode: _response.error.statusCode,
@@ -9159,98 +9307,861 @@ var SearchClient = class {
9159
9307
  });
9160
9308
  }
9161
9309
  }
9162
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/search");
9163
- }
9164
- };
9165
- var VectrosClient = class {
9166
- constructor(options) {
9167
- this._options = normalizeClientOptionsWithAuth(options);
9168
- }
9169
- get auth() {
9170
- return this._auth ?? (this._auth = new AuthClient(this._options));
9171
- }
9172
- get documents() {
9173
- return this._documents ?? (this._documents = new DocumentsClient(this._options));
9174
- }
9175
- get identity() {
9176
- return this._identity ?? (this._identity = new IdentityClient(this._options));
9177
- }
9178
- get compliance() {
9179
- return this._compliance ?? (this._compliance = new ComplianceClient(this._options));
9180
- }
9181
- get folders() {
9182
- return this._folders ?? (this._folders = new FoldersClient(this._options));
9183
- }
9184
- get inference() {
9185
- return this._inference ?? (this._inference = new InferenceClient(this._options));
9186
- }
9187
- get records() {
9188
- return this._records ?? (this._records = new RecordsClient(this._options));
9189
- }
9190
- get schemas() {
9191
- return this._schemas ?? (this._schemas = new SchemasClient(this._options));
9192
- }
9193
- get search() {
9194
- return this._search ?? (this._search = new SearchClient(this._options));
9310
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/scripts/execute");
9195
9311
  }
9196
9312
  /**
9197
- * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
9198
- * This is useful for making requests to endpoints not yet supported in the SDK.
9199
- * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
9313
+ * 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.
9200
9314
  *
9201
- * @param {Request | string | URL} input - The URL, path, or Request object.
9202
- * @param {RequestInit} init - Standard fetch RequestInit options.
9203
- * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
9204
- * @returns {Promise<Response>} A standard Response object.
9315
+ * @param {Vectros.ListScriptsRequest} request
9316
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9317
+ *
9318
+ * @example
9319
+ * await client.scripts.listScripts({
9320
+ * name: "notify-assignee",
9321
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9322
+ * })
9205
9323
  */
9206
- async fetch(input, init, requestOptions) {
9207
- return makePassthroughRequest(
9208
- input,
9209
- init,
9210
- {
9211
- baseUrl: this._options.baseUrl ?? this._options.environment,
9212
- headers: this._options.headers,
9213
- timeoutInSeconds: this._options.timeoutInSeconds,
9214
- maxRetries: this._options.maxRetries,
9215
- fetch: this._options.fetch,
9216
- logging: this._options.logging,
9217
- getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers
9218
- },
9219
- requestOptions
9220
- );
9221
- }
9222
- };
9223
- var logging;
9224
- ((logging2) => {
9225
- logging2.LogLevel = LogLevel;
9226
- logging2.ConsoleLogger = ConsoleLogger;
9227
- })(logging || (logging = {}));
9228
-
9229
- // src/server.ts
9230
- var import_types3 = require("@modelcontextprotocol/sdk/types.js");
9231
- var import_zod23 = require("zod");
9232
-
9233
- // src/auth.ts
9234
- var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
9235
- var InvalidApiKeyError = class extends Error {
9236
- constructor(reason) {
9237
- super(`Invalid VECTROS_API_KEY: ${reason}`);
9238
- this.name = "InvalidApiKeyError";
9324
+ listScripts(request = {}, requestOptions) {
9325
+ return HttpResponsePromise.fromPromise(this.__listScripts(request, requestOptions));
9239
9326
  }
9240
- };
9241
- function parseApiKey(raw) {
9242
- if (!raw || raw.trim().length === 0) {
9243
- throw new InvalidApiKeyError(
9244
- "env var is missing or empty. Set VECTROS_API_KEY to a Vectros key (recommended: ssk_live_... or ssk_test_...)."
9327
+ async __listScripts(request = {}, requestOptions) {
9328
+ const { name, startFrom, limit } = request;
9329
+ const _queryParams = {
9330
+ name,
9331
+ startFrom,
9332
+ limit
9333
+ };
9334
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9335
+ const _headers = mergeHeaders(
9336
+ _authRequest.headers,
9337
+ this._options?.headers,
9338
+ requestOptions?.headers
9245
9339
  );
9340
+ const _response = await fetcher({
9341
+ url: url_exports.join(
9342
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9343
+ "v1/scripts"
9344
+ ),
9345
+ method: "GET",
9346
+ headers: _headers,
9347
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9348
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9349
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9350
+ abortSignal: requestOptions?.abortSignal,
9351
+ fetchFn: this._options?.fetch,
9352
+ logging: this._options.logging
9353
+ });
9354
+ if (_response.ok) {
9355
+ return { data: _response.body, rawResponse: _response.rawResponse };
9356
+ }
9357
+ if (_response.error.reason === "status-code") {
9358
+ throw new VectrosError({
9359
+ statusCode: _response.error.statusCode,
9360
+ body: _response.error.body,
9361
+ rawResponse: _response.rawResponse
9362
+ });
9363
+ }
9364
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/scripts");
9246
9365
  }
9247
- const match = raw.match(KEY_RE);
9248
- if (!match) {
9249
- throw new InvalidApiKeyError(
9250
- `key must start with sk_, ssk_, or st_ followed by "live_" or "test_". Got prefix "${raw.slice(0, 12)}...".`
9251
- );
9366
+ /**
9367
+ * 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.
9368
+ *
9369
+ * @param {Vectros.ScriptRequest} request
9370
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9371
+ *
9372
+ * @throws {@link Vectros.BadRequestError}
9373
+ * @throws {@link Vectros.ForbiddenError}
9374
+ * @throws {@link Vectros.ConflictError}
9375
+ * @throws {@link Vectros.TooManyRequestsError}
9376
+ *
9377
+ * @example
9378
+ * await client.scripts.createScript({
9379
+ * name: "notify-assignee",
9380
+ * source: "export default function(input) { return { ok: true }; }"
9381
+ * })
9382
+ */
9383
+ createScript(request, requestOptions) {
9384
+ return HttpResponsePromise.fromPromise(this.__createScript(request, requestOptions));
9252
9385
  }
9253
- return {
9386
+ async __createScript(request, requestOptions) {
9387
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9388
+ const _headers = mergeHeaders(
9389
+ _authRequest.headers,
9390
+ this._options?.headers,
9391
+ requestOptions?.headers
9392
+ );
9393
+ const _response = await fetcher({
9394
+ url: url_exports.join(
9395
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9396
+ "v1/scripts"
9397
+ ),
9398
+ method: "POST",
9399
+ headers: _headers,
9400
+ contentType: "application/json",
9401
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9402
+ requestType: "json",
9403
+ body: request,
9404
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9405
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9406
+ abortSignal: requestOptions?.abortSignal,
9407
+ fetchFn: this._options?.fetch,
9408
+ logging: this._options.logging
9409
+ });
9410
+ if (_response.ok) {
9411
+ return { data: _response.body, rawResponse: _response.rawResponse };
9412
+ }
9413
+ if (_response.error.reason === "status-code") {
9414
+ switch (_response.error.statusCode) {
9415
+ case 400:
9416
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9417
+ case 403:
9418
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9419
+ case 409:
9420
+ throw new ConflictError(_response.error.body, _response.rawResponse);
9421
+ case 429:
9422
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9423
+ default:
9424
+ throw new VectrosError({
9425
+ statusCode: _response.error.statusCode,
9426
+ body: _response.error.body,
9427
+ rawResponse: _response.rawResponse
9428
+ });
9429
+ }
9430
+ }
9431
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/scripts");
9432
+ }
9433
+ /**
9434
+ * Retrieves a single script version by its ID. Requires the `scripts:r` scope.
9435
+ *
9436
+ * @param {Vectros.GetScriptRequest} request
9437
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9438
+ *
9439
+ * @throws {@link Vectros.NotFoundError}
9440
+ *
9441
+ * @example
9442
+ * await client.scripts.getScript({
9443
+ * id: "id"
9444
+ * })
9445
+ */
9446
+ getScript(request, requestOptions) {
9447
+ return HttpResponsePromise.fromPromise(this.__getScript(request, requestOptions));
9448
+ }
9449
+ async __getScript(request, requestOptions) {
9450
+ const { id } = request;
9451
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9452
+ const _headers = mergeHeaders(
9453
+ _authRequest.headers,
9454
+ this._options?.headers,
9455
+ requestOptions?.headers
9456
+ );
9457
+ const _response = await fetcher({
9458
+ url: url_exports.join(
9459
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9460
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9461
+ ),
9462
+ method: "GET",
9463
+ headers: _headers,
9464
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9465
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9466
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9467
+ abortSignal: requestOptions?.abortSignal,
9468
+ fetchFn: this._options?.fetch,
9469
+ logging: this._options.logging
9470
+ });
9471
+ if (_response.ok) {
9472
+ return { data: _response.body, rawResponse: _response.rawResponse };
9473
+ }
9474
+ if (_response.error.reason === "status-code") {
9475
+ switch (_response.error.statusCode) {
9476
+ case 404:
9477
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9478
+ default:
9479
+ throw new VectrosError({
9480
+ statusCode: _response.error.statusCode,
9481
+ body: _response.error.body,
9482
+ rawResponse: _response.rawResponse
9483
+ });
9484
+ }
9485
+ }
9486
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/scripts/{id}");
9487
+ }
9488
+ /**
9489
+ * 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.
9490
+ *
9491
+ * @param {Vectros.UpdateScriptRequest} request
9492
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9493
+ *
9494
+ * @throws {@link Vectros.BadRequestError}
9495
+ * @throws {@link Vectros.TooManyRequestsError}
9496
+ *
9497
+ * @example
9498
+ * await client.scripts.updateScript({
9499
+ * id: "id",
9500
+ * body: {
9501
+ * name: "notify-assignee",
9502
+ * source: "export default function(input) { return { ok: true }; }"
9503
+ * }
9504
+ * })
9505
+ */
9506
+ updateScript(request, requestOptions) {
9507
+ return HttpResponsePromise.fromPromise(this.__updateScript(request, requestOptions));
9508
+ }
9509
+ async __updateScript(request, requestOptions) {
9510
+ const { id, body: _body } = request;
9511
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9512
+ const _headers = mergeHeaders(
9513
+ _authRequest.headers,
9514
+ this._options?.headers,
9515
+ requestOptions?.headers
9516
+ );
9517
+ const _response = await fetcher({
9518
+ url: url_exports.join(
9519
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9520
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9521
+ ),
9522
+ method: "PUT",
9523
+ headers: _headers,
9524
+ contentType: "application/json",
9525
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9526
+ requestType: "json",
9527
+ body: _body,
9528
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9529
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9530
+ abortSignal: requestOptions?.abortSignal,
9531
+ fetchFn: this._options?.fetch,
9532
+ logging: this._options.logging
9533
+ });
9534
+ if (_response.ok) {
9535
+ return { data: void 0, rawResponse: _response.rawResponse };
9536
+ }
9537
+ if (_response.error.reason === "status-code") {
9538
+ switch (_response.error.statusCode) {
9539
+ case 400:
9540
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9541
+ case 429:
9542
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9543
+ default:
9544
+ throw new VectrosError({
9545
+ statusCode: _response.error.statusCode,
9546
+ body: _response.error.body,
9547
+ rawResponse: _response.rawResponse
9548
+ });
9549
+ }
9550
+ }
9551
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/scripts/{id}");
9552
+ }
9553
+ /**
9554
+ * 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.
9555
+ *
9556
+ * @param {Vectros.DeleteScriptRequest} request
9557
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9558
+ *
9559
+ * @throws {@link Vectros.NotFoundError}
9560
+ * @throws {@link Vectros.TooManyRequestsError}
9561
+ *
9562
+ * @example
9563
+ * await client.scripts.deleteScript({
9564
+ * id: "id"
9565
+ * })
9566
+ */
9567
+ deleteScript(request, requestOptions) {
9568
+ return HttpResponsePromise.fromPromise(this.__deleteScript(request, requestOptions));
9569
+ }
9570
+ async __deleteScript(request, requestOptions) {
9571
+ const { id } = request;
9572
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9573
+ const _headers = mergeHeaders(
9574
+ _authRequest.headers,
9575
+ this._options?.headers,
9576
+ requestOptions?.headers
9577
+ );
9578
+ const _response = await fetcher({
9579
+ url: url_exports.join(
9580
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9581
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9582
+ ),
9583
+ method: "DELETE",
9584
+ headers: _headers,
9585
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9586
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9587
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9588
+ abortSignal: requestOptions?.abortSignal,
9589
+ fetchFn: this._options?.fetch,
9590
+ logging: this._options.logging
9591
+ });
9592
+ if (_response.ok) {
9593
+ return { data: void 0, rawResponse: _response.rawResponse };
9594
+ }
9595
+ if (_response.error.reason === "status-code") {
9596
+ switch (_response.error.statusCode) {
9597
+ case 404:
9598
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9599
+ case 429:
9600
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9601
+ default:
9602
+ throw new VectrosError({
9603
+ statusCode: _response.error.statusCode,
9604
+ body: _response.error.body,
9605
+ rawResponse: _response.rawResponse
9606
+ });
9607
+ }
9608
+ }
9609
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/scripts/{id}");
9610
+ }
9611
+ };
9612
+ var SearchClient = class {
9613
+ constructor(options) {
9614
+ this._options = normalizeClientOptionsWithAuth(options);
9615
+ }
9616
+ /**
9617
+ * 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.
9618
+ *
9619
+ * @param {Vectros.SearchRequest} request
9620
+ * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
9621
+ *
9622
+ * @throws {@link Vectros.BadRequestError}
9623
+ * @throws {@link Vectros.ForbiddenError}
9624
+ * @throws {@link Vectros.TooManyRequestsError}
9625
+ *
9626
+ * @example
9627
+ * await client.search.content({
9628
+ * query: "patient intake form diabetes"
9629
+ * })
9630
+ */
9631
+ content(request, requestOptions) {
9632
+ return HttpResponsePromise.fromPromise(this.__content(request, requestOptions));
9633
+ }
9634
+ async __content(request, requestOptions) {
9635
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9636
+ const _headers = mergeHeaders(
9637
+ _authRequest.headers,
9638
+ this._options?.headers,
9639
+ requestOptions?.headers
9640
+ );
9641
+ const _response = await fetcher({
9642
+ url: url_exports.join(
9643
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9644
+ "v1/search"
9645
+ ),
9646
+ method: "POST",
9647
+ headers: _headers,
9648
+ contentType: "application/json",
9649
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9650
+ requestType: "json",
9651
+ body: request,
9652
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9653
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9654
+ abortSignal: requestOptions?.abortSignal,
9655
+ fetchFn: this._options?.fetch,
9656
+ logging: this._options.logging
9657
+ });
9658
+ if (_response.ok) {
9659
+ return { data: _response.body, rawResponse: _response.rawResponse };
9660
+ }
9661
+ if (_response.error.reason === "status-code") {
9662
+ switch (_response.error.statusCode) {
9663
+ case 400:
9664
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9665
+ case 403:
9666
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9667
+ case 429:
9668
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9669
+ default:
9670
+ throw new VectrosError({
9671
+ statusCode: _response.error.statusCode,
9672
+ body: _response.error.body,
9673
+ rawResponse: _response.rawResponse
9674
+ });
9675
+ }
9676
+ }
9677
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/search");
9678
+ }
9679
+ };
9680
+ var TriggersClient = class {
9681
+ constructor(options) {
9682
+ this._options = normalizeClientOptionsWithAuth(options);
9683
+ }
9684
+ /**
9685
+ * 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.
9686
+ *
9687
+ * 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.
9688
+ *
9689
+ * `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.
9690
+ *
9691
+ * Scoped to your account and app context, derived from your token — never from input. Requires the `triggers:r` scope.
9692
+ *
9693
+ * @param {Vectros.ListTriggerFailuresRequest} request
9694
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9695
+ *
9696
+ * @example
9697
+ * await client.triggers.listTriggerFailures({
9698
+ * ruleId: "3b1c9f2e7a5d8410f6c2e9a1b7d4038f5e6a91c2d7f0b3a4586c9e2f1d0a7b3c",
9699
+ * category: "SCRIPT_ERROR",
9700
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9701
+ * })
9702
+ */
9703
+ listTriggerFailures(request = {}, requestOptions) {
9704
+ return HttpResponsePromise.fromPromise(this.__listTriggerFailures(request, requestOptions));
9705
+ }
9706
+ async __listTriggerFailures(request = {}, requestOptions) {
9707
+ const { ruleId, category, retryable, from: from_, to, startFrom, limit } = request;
9708
+ const _queryParams = {
9709
+ ruleId,
9710
+ category,
9711
+ retryable,
9712
+ from: from_,
9713
+ to,
9714
+ startFrom,
9715
+ limit
9716
+ };
9717
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9718
+ const _headers = mergeHeaders(
9719
+ _authRequest.headers,
9720
+ this._options?.headers,
9721
+ requestOptions?.headers
9722
+ );
9723
+ const _response = await fetcher({
9724
+ url: url_exports.join(
9725
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9726
+ "v1/trigger-failures"
9727
+ ),
9728
+ method: "GET",
9729
+ headers: _headers,
9730
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9731
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9732
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9733
+ abortSignal: requestOptions?.abortSignal,
9734
+ fetchFn: this._options?.fetch,
9735
+ logging: this._options.logging
9736
+ });
9737
+ if (_response.ok) {
9738
+ return { data: _response.body, rawResponse: _response.rawResponse };
9739
+ }
9740
+ if (_response.error.reason === "status-code") {
9741
+ throw new VectrosError({
9742
+ statusCode: _response.error.statusCode,
9743
+ body: _response.error.body,
9744
+ rawResponse: _response.rawResponse
9745
+ });
9746
+ }
9747
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/trigger-failures");
9748
+ }
9749
+ /**
9750
+ * 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.
9751
+ *
9752
+ * @param {Vectros.ListTriggersRequest} request
9753
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9754
+ *
9755
+ * @example
9756
+ * await client.triggers.listTriggers({
9757
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9758
+ * })
9759
+ */
9760
+ listTriggers(request = {}, requestOptions) {
9761
+ return HttpResponsePromise.fromPromise(this.__listTriggers(request, requestOptions));
9762
+ }
9763
+ async __listTriggers(request = {}, requestOptions) {
9764
+ const { startFrom, limit } = request;
9765
+ const _queryParams = {
9766
+ startFrom,
9767
+ limit
9768
+ };
9769
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9770
+ const _headers = mergeHeaders(
9771
+ _authRequest.headers,
9772
+ this._options?.headers,
9773
+ requestOptions?.headers
9774
+ );
9775
+ const _response = await fetcher({
9776
+ url: url_exports.join(
9777
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9778
+ "v1/triggers"
9779
+ ),
9780
+ method: "GET",
9781
+ headers: _headers,
9782
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9783
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9784
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9785
+ abortSignal: requestOptions?.abortSignal,
9786
+ fetchFn: this._options?.fetch,
9787
+ logging: this._options.logging
9788
+ });
9789
+ if (_response.ok) {
9790
+ return { data: _response.body, rawResponse: _response.rawResponse };
9791
+ }
9792
+ if (_response.error.reason === "status-code") {
9793
+ throw new VectrosError({
9794
+ statusCode: _response.error.statusCode,
9795
+ body: _response.error.body,
9796
+ rawResponse: _response.rawResponse
9797
+ });
9798
+ }
9799
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/triggers");
9800
+ }
9801
+ /**
9802
+ * 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).
9803
+ *
9804
+ * @param {Vectros.CreateTriggerRequest} request
9805
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9806
+ *
9807
+ * @throws {@link Vectros.BadRequestError}
9808
+ * @throws {@link Vectros.ForbiddenError}
9809
+ * @throws {@link Vectros.TooManyRequestsError}
9810
+ *
9811
+ * @example
9812
+ * await client.triggers.createTrigger({
9813
+ * body: {
9814
+ * name: "on-intake-create",
9815
+ * firingSource: {
9816
+ * schemaId: "sch_9f8e7d6c",
9817
+ * event: "CREATE"
9818
+ * },
9819
+ * scriptRef: {
9820
+ * name: "notify-assignee",
9821
+ * version: "3"
9822
+ * }
9823
+ * }
9824
+ * })
9825
+ */
9826
+ createTrigger(request, requestOptions) {
9827
+ return HttpResponsePromise.fromPromise(this.__createTrigger(request, requestOptions));
9828
+ }
9829
+ async __createTrigger(request, requestOptions) {
9830
+ const { upsert, body: _body } = request;
9831
+ const _queryParams = {
9832
+ upsert
9833
+ };
9834
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9835
+ const _headers = mergeHeaders(
9836
+ _authRequest.headers,
9837
+ this._options?.headers,
9838
+ requestOptions?.headers
9839
+ );
9840
+ const _response = await fetcher({
9841
+ url: url_exports.join(
9842
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9843
+ "v1/triggers"
9844
+ ),
9845
+ method: "POST",
9846
+ headers: _headers,
9847
+ contentType: "application/json",
9848
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9849
+ requestType: "json",
9850
+ body: _body,
9851
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9852
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9853
+ abortSignal: requestOptions?.abortSignal,
9854
+ fetchFn: this._options?.fetch,
9855
+ logging: this._options.logging
9856
+ });
9857
+ if (_response.ok) {
9858
+ return { data: _response.body, rawResponse: _response.rawResponse };
9859
+ }
9860
+ if (_response.error.reason === "status-code") {
9861
+ switch (_response.error.statusCode) {
9862
+ case 400:
9863
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9864
+ case 403:
9865
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9866
+ case 429:
9867
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9868
+ default:
9869
+ throw new VectrosError({
9870
+ statusCode: _response.error.statusCode,
9871
+ body: _response.error.body,
9872
+ rawResponse: _response.rawResponse
9873
+ });
9874
+ }
9875
+ }
9876
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/triggers");
9877
+ }
9878
+ /**
9879
+ * Retrieves a single trigger rule by its ID. Requires the `triggers:r` scope.
9880
+ *
9881
+ * @param {Vectros.GetTriggerRequest} request
9882
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9883
+ *
9884
+ * @throws {@link Vectros.NotFoundError}
9885
+ *
9886
+ * @example
9887
+ * await client.triggers.getTrigger({
9888
+ * id: "id"
9889
+ * })
9890
+ */
9891
+ getTrigger(request, requestOptions) {
9892
+ return HttpResponsePromise.fromPromise(this.__getTrigger(request, requestOptions));
9893
+ }
9894
+ async __getTrigger(request, requestOptions) {
9895
+ const { id } = request;
9896
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9897
+ const _headers = mergeHeaders(
9898
+ _authRequest.headers,
9899
+ this._options?.headers,
9900
+ requestOptions?.headers
9901
+ );
9902
+ const _response = await fetcher({
9903
+ url: url_exports.join(
9904
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9905
+ `v1/triggers/${url_exports.encodePathParam(id)}`
9906
+ ),
9907
+ method: "GET",
9908
+ headers: _headers,
9909
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9910
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9911
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9912
+ abortSignal: requestOptions?.abortSignal,
9913
+ fetchFn: this._options?.fetch,
9914
+ logging: this._options.logging
9915
+ });
9916
+ if (_response.ok) {
9917
+ return { data: _response.body, rawResponse: _response.rawResponse };
9918
+ }
9919
+ if (_response.error.reason === "status-code") {
9920
+ switch (_response.error.statusCode) {
9921
+ case 404:
9922
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9923
+ default:
9924
+ throw new VectrosError({
9925
+ statusCode: _response.error.statusCode,
9926
+ body: _response.error.body,
9927
+ rawResponse: _response.rawResponse
9928
+ });
9929
+ }
9930
+ }
9931
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/triggers/{id}");
9932
+ }
9933
+ /**
9934
+ * 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.
9935
+ *
9936
+ * @param {Vectros.UpdateTriggerRequest} request
9937
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9938
+ *
9939
+ * @throws {@link Vectros.BadRequestError}
9940
+ * @throws {@link Vectros.ForbiddenError}
9941
+ * @throws {@link Vectros.NotFoundError}
9942
+ * @throws {@link Vectros.TooManyRequestsError}
9943
+ *
9944
+ * @example
9945
+ * await client.triggers.updateTrigger({
9946
+ * id: "id",
9947
+ * body: {
9948
+ * name: "on-intake-create",
9949
+ * firingSource: {
9950
+ * schemaId: "sch_9f8e7d6c",
9951
+ * event: "CREATE"
9952
+ * },
9953
+ * scriptRef: {
9954
+ * name: "notify-assignee",
9955
+ * version: "3"
9956
+ * }
9957
+ * }
9958
+ * })
9959
+ */
9960
+ updateTrigger(request, requestOptions) {
9961
+ return HttpResponsePromise.fromPromise(this.__updateTrigger(request, requestOptions));
9962
+ }
9963
+ async __updateTrigger(request, requestOptions) {
9964
+ const { id, body: _body } = request;
9965
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9966
+ const _headers = mergeHeaders(
9967
+ _authRequest.headers,
9968
+ this._options?.headers,
9969
+ requestOptions?.headers
9970
+ );
9971
+ const _response = await fetcher({
9972
+ url: url_exports.join(
9973
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9974
+ `v1/triggers/${url_exports.encodePathParam(id)}`
9975
+ ),
9976
+ method: "PUT",
9977
+ headers: _headers,
9978
+ contentType: "application/json",
9979
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9980
+ requestType: "json",
9981
+ body: _body,
9982
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9983
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9984
+ abortSignal: requestOptions?.abortSignal,
9985
+ fetchFn: this._options?.fetch,
9986
+ logging: this._options.logging
9987
+ });
9988
+ if (_response.ok) {
9989
+ return { data: _response.body, rawResponse: _response.rawResponse };
9990
+ }
9991
+ if (_response.error.reason === "status-code") {
9992
+ switch (_response.error.statusCode) {
9993
+ case 400:
9994
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9995
+ case 403:
9996
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9997
+ case 404:
9998
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9999
+ case 429:
10000
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
10001
+ default:
10002
+ throw new VectrosError({
10003
+ statusCode: _response.error.statusCode,
10004
+ body: _response.error.body,
10005
+ rawResponse: _response.rawResponse
10006
+ });
10007
+ }
10008
+ }
10009
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/triggers/{id}");
10010
+ }
10011
+ /**
10012
+ * Permanently deletes one trigger rule by ID. Requires the `triggers:d` scope.
10013
+ *
10014
+ * @param {Vectros.DeleteTriggerRequest} request
10015
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
10016
+ *
10017
+ * @throws {@link Vectros.NotFoundError}
10018
+ * @throws {@link Vectros.TooManyRequestsError}
10019
+ *
10020
+ * @example
10021
+ * await client.triggers.deleteTrigger({
10022
+ * id: "id"
10023
+ * })
10024
+ */
10025
+ deleteTrigger(request, requestOptions) {
10026
+ return HttpResponsePromise.fromPromise(this.__deleteTrigger(request, requestOptions));
10027
+ }
10028
+ async __deleteTrigger(request, requestOptions) {
10029
+ const { id } = request;
10030
+ const _authRequest = await this._options.authProvider.getAuthRequest();
10031
+ const _headers = mergeHeaders(
10032
+ _authRequest.headers,
10033
+ this._options?.headers,
10034
+ requestOptions?.headers
10035
+ );
10036
+ const _response = await fetcher({
10037
+ url: url_exports.join(
10038
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
10039
+ `v1/triggers/${url_exports.encodePathParam(id)}`
10040
+ ),
10041
+ method: "DELETE",
10042
+ headers: _headers,
10043
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
10044
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
10045
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
10046
+ abortSignal: requestOptions?.abortSignal,
10047
+ fetchFn: this._options?.fetch,
10048
+ logging: this._options.logging
10049
+ });
10050
+ if (_response.ok) {
10051
+ return { data: void 0, rawResponse: _response.rawResponse };
10052
+ }
10053
+ if (_response.error.reason === "status-code") {
10054
+ switch (_response.error.statusCode) {
10055
+ case 404:
10056
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
10057
+ case 429:
10058
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
10059
+ default:
10060
+ throw new VectrosError({
10061
+ statusCode: _response.error.statusCode,
10062
+ body: _response.error.body,
10063
+ rawResponse: _response.rawResponse
10064
+ });
10065
+ }
10066
+ }
10067
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/triggers/{id}");
10068
+ }
10069
+ };
10070
+ var VectrosClient = class {
10071
+ constructor(options) {
10072
+ this._options = normalizeClientOptionsWithAuth(options);
10073
+ }
10074
+ get auth() {
10075
+ return this._auth ?? (this._auth = new AuthClient(this._options));
10076
+ }
10077
+ get documents() {
10078
+ return this._documents ?? (this._documents = new DocumentsClient(this._options));
10079
+ }
10080
+ get identity() {
10081
+ return this._identity ?? (this._identity = new IdentityClient(this._options));
10082
+ }
10083
+ get compliance() {
10084
+ return this._compliance ?? (this._compliance = new ComplianceClient(this._options));
10085
+ }
10086
+ get folders() {
10087
+ return this._folders ?? (this._folders = new FoldersClient(this._options));
10088
+ }
10089
+ get inference() {
10090
+ return this._inference ?? (this._inference = new InferenceClient(this._options));
10091
+ }
10092
+ get records() {
10093
+ return this._records ?? (this._records = new RecordsClient(this._options));
10094
+ }
10095
+ get schemas() {
10096
+ return this._schemas ?? (this._schemas = new SchemasClient(this._options));
10097
+ }
10098
+ get scripts() {
10099
+ return this._scripts ?? (this._scripts = new ScriptsClient(this._options));
10100
+ }
10101
+ get search() {
10102
+ return this._search ?? (this._search = new SearchClient(this._options));
10103
+ }
10104
+ get triggers() {
10105
+ return this._triggers ?? (this._triggers = new TriggersClient(this._options));
10106
+ }
10107
+ /**
10108
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
10109
+ * This is useful for making requests to endpoints not yet supported in the SDK.
10110
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
10111
+ *
10112
+ * @param {Request | string | URL} input - The URL, path, or Request object.
10113
+ * @param {RequestInit} init - Standard fetch RequestInit options.
10114
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
10115
+ * @returns {Promise<Response>} A standard Response object.
10116
+ */
10117
+ async fetch(input, init, requestOptions) {
10118
+ return makePassthroughRequest(
10119
+ input,
10120
+ init,
10121
+ {
10122
+ baseUrl: this._options.baseUrl ?? this._options.environment,
10123
+ headers: this._options.headers,
10124
+ timeoutInSeconds: this._options.timeoutInSeconds,
10125
+ maxRetries: this._options.maxRetries,
10126
+ fetch: this._options.fetch,
10127
+ logging: this._options.logging,
10128
+ getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers
10129
+ },
10130
+ requestOptions
10131
+ );
10132
+ }
10133
+ };
10134
+ var logging;
10135
+ ((logging2) => {
10136
+ logging2.LogLevel = LogLevel;
10137
+ logging2.ConsoleLogger = ConsoleLogger;
10138
+ })(logging || (logging = {}));
10139
+
10140
+ // src/server.ts
10141
+ var import_types3 = require("@modelcontextprotocol/sdk/types.js");
10142
+ var import_zod24 = require("zod");
10143
+
10144
+ // src/auth.ts
10145
+ var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
10146
+ var InvalidApiKeyError = class extends Error {
10147
+ constructor(reason) {
10148
+ super(`Invalid VECTROS_API_KEY: ${reason}`);
10149
+ this.name = "InvalidApiKeyError";
10150
+ }
10151
+ };
10152
+ function parseApiKey(raw) {
10153
+ if (!raw || raw.trim().length === 0) {
10154
+ throw new InvalidApiKeyError(
10155
+ "env var is missing or empty. Set VECTROS_API_KEY to a Vectros key (recommended: ssk_live_... or ssk_test_...)."
10156
+ );
10157
+ }
10158
+ const match = raw.match(KEY_RE);
10159
+ if (!match) {
10160
+ throw new InvalidApiKeyError(
10161
+ `key must start with sk_, ssk_, or st_ followed by "live_" or "test_". Got prefix "${raw.slice(0, 12)}...".`
10162
+ );
10163
+ }
10164
+ return {
9254
10165
  prefix: match[1],
9255
10166
  env: match[2],
9256
10167
  raw
@@ -9272,8 +10183,8 @@ function warnOnSuboptimalKey(key, log) {
9272
10183
 
9273
10184
  // src/build-info.ts
9274
10185
  var BUILD_INFO = {
9275
- mcpServer: true ? "0.16.0" : "dev",
9276
- sdk: true ? "0.41.0" : "dev"
10186
+ mcpServer: true ? "0.17.0" : "dev",
10187
+ sdk: true ? "0.43.0" : "dev"
9277
10188
  };
9278
10189
 
9279
10190
  // src/log.ts
@@ -9581,11 +10492,18 @@ var inputSchema = {
9581
10492
  // Ownership.
9582
10493
  userId: import_zod.z.string().optional().describe("Restrict to content owned by this user (Vectros UUID)."),
9583
10494
  scope: import_zod.z.string().optional().describe(
9584
- '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.'
10495
+ '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.'
10496
+ ),
10497
+ scopeFilters: import_zod.z.array(import_zod.z.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
10498
+ '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.'
9585
10499
  ),
9586
10500
  // Date window.
9587
- createdAfter: import_zod.z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
9588
- createdBefore: import_zod.z.string().optional().describe("Restrict to content created at/before this ISO 8601 UTC timestamp."),
10501
+ createdAfter: import_zod.z.string().optional().describe(
10502
+ "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."
10503
+ ),
10504
+ createdBefore: import_zod.z.string().optional().describe(
10505
+ "Restrict to content CREATED at/before this ISO 8601 UTC timestamp \u2014 same creation-time basis, and the same first-index allowance, as createdAfter."
10506
+ ),
9589
10507
  // Relevance tuning.
9590
10508
  minSimilarity: import_zod.z.number().min(0).max(1).optional().describe("Minimum semantic similarity (0.0\u20131.0); results below are excluded."),
9591
10509
  minTextRelevance: import_zod.z.number().min(0).max(1).optional().describe("Minimum relative keyword (BM25) relevance (0.0\u20131.0); the keyword-leg analogue of minSimilarity."),
@@ -9600,11 +10518,19 @@ var inputSchema = {
9600
10518
  var hybridSearch = ({ client, log }) => ({
9601
10519
  name: "hybrid_search",
9602
10520
  title: "Hybrid search",
9603
- 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).',
10521
+ 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).',
9604
10522
  inputSchema,
9605
10523
  handler: async (args) => {
9606
10524
  const limit = args.limit ?? MCP_DEFAULT_LIMIT;
9607
10525
  const mode = args.mode ?? "HYBRID";
10526
+ if (args.scope !== void 0 && args.scopeFilters !== void 0) {
10527
+ return toolError(
10528
+ "hybrid_search",
10529
+ new Error(
10530
+ "'scope' and 'scopeFilters' are mutually exclusive \u2014 pass 'scope' for a single ownership dimension, or 'scopeFilters' for more than one, not both."
10531
+ )
10532
+ );
10533
+ }
9608
10534
  try {
9609
10535
  const result = await client.search.content({
9610
10536
  query: args.query,
@@ -9619,6 +10545,7 @@ var hybridSearch = ({ client, log }) => ({
9619
10545
  filters: args.filters,
9620
10546
  userId: args.userId,
9621
10547
  scope: args.scope,
10548
+ scopeFilters: args.scopeFilters,
9622
10549
  createdAfter: args.createdAfter,
9623
10550
  createdBefore: args.createdBefore,
9624
10551
  minSimilarity: args.minSimilarity,
@@ -9697,7 +10624,9 @@ async function drainPages(fetchPage) {
9697
10624
  var MCP_DEFAULT_LIMIT2 = 3;
9698
10625
  var MCP_MAX_LIMIT2 = 100;
9699
10626
  var inputSchema2 = {
9700
- type: import_zod2.z.string().min(1, "type (record type) is required").describe('Record type / schema name (e.g. "patient", "clinical_note").'),
10627
+ type: import_zod2.z.string().min(1, "type must be non-empty when supplied").optional().describe(
10628
+ '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.'
10629
+ ),
9701
10630
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | values | from+to | prefix.
9702
10631
  field: import_zod2.z.string().optional().describe(
9703
10632
  '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.'
@@ -9719,6 +10648,12 @@ var inputSchema2 = {
9719
10648
  "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."
9720
10649
  ),
9721
10650
  // List-mode args:
10651
+ folderId: import_zod2.z.string().optional().describe(
10652
+ "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."
10653
+ ),
10654
+ recent: import_zod2.z.boolean().optional().describe(
10655
+ "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."
10656
+ ),
9722
10657
  userId: import_zod2.z.string().optional().describe("List mode: scope to records owned by this user."),
9723
10658
  scope: import_zod2.z.string().optional().describe(
9724
10659
  '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.'
@@ -9731,11 +10666,13 @@ var inputSchema2 = {
9731
10666
  var recordQuery = ({ client, log }) => ({
9732
10667
  name: "record_query",
9733
10668
  title: "Record query (list or lookup)",
9734
- 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.",
10669
+ 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.",
9735
10670
  inputSchema: inputSchema2,
9736
10671
  handler: async (args) => {
9737
10672
  const limit = args.limit ?? MCP_DEFAULT_LIMIT2;
9738
10673
  const type = args.type;
10674
+ const folderId = args.folderId;
10675
+ const recent = args.recent;
9739
10676
  const field = args.field;
9740
10677
  const value = args.value;
9741
10678
  const values = args.values;
@@ -9753,6 +10690,48 @@ var recordQuery = ({ client, log }) => ({
9753
10690
  )
9754
10691
  );
9755
10692
  }
10693
+ if (field && (folderId !== void 0 || recent !== void 0)) {
10694
+ return toolError(
10695
+ "record_query",
10696
+ new Error(
10697
+ "'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."
10698
+ )
10699
+ );
10700
+ }
10701
+ if (field && !type) {
10702
+ return toolError(
10703
+ "record_query",
10704
+ new Error(
10705
+ "a lookup ('field') is always within one record type \u2014 pass 'type'. To read across types, use list mode with 'folderId' or 'recent'."
10706
+ )
10707
+ );
10708
+ }
10709
+ if (!field) {
10710
+ if (recent && (type !== void 0 || folderId !== void 0)) {
10711
+ return toolError(
10712
+ "record_query",
10713
+ new Error(
10714
+ "'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."
10715
+ )
10716
+ );
10717
+ }
10718
+ if (recent && (args.userId !== void 0 || args.scope !== void 0)) {
10719
+ return toolError(
10720
+ "record_query",
10721
+ new Error(
10722
+ "'recent' ignores the owner filters \u2014 'userId'/'scope' would be silently dropped. List by 'type' or 'folderId' to filter by owner."
10723
+ )
10724
+ );
10725
+ }
10726
+ if (!recent && type === void 0 && folderId === void 0) {
10727
+ return toolError(
10728
+ "record_query",
10729
+ new Error(
10730
+ "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."
10731
+ )
10732
+ );
10733
+ }
10734
+ }
9756
10735
  try {
9757
10736
  let page;
9758
10737
  if (field) {
@@ -9816,6 +10795,7 @@ var recordQuery = ({ client, log }) => ({
9816
10795
  }
9817
10796
  }
9818
10797
  page = await client.records.lookupRecordsByBody({
10798
+ // Non-null: the `field && !type` guard above returns before reaching lookup mode.
9819
10799
  type,
9820
10800
  field: normalizedField,
9821
10801
  value,
@@ -9836,13 +10816,22 @@ var recordQuery = ({ client, log }) => ({
9836
10816
  } else {
9837
10817
  page = await client.records.listRecords({
9838
10818
  type,
10819
+ folderId,
10820
+ ...recent ? { recent: "true" } : {},
9839
10821
  userId: args.userId,
9840
10822
  scope: args.scope,
9841
10823
  startFrom,
9842
10824
  limit
9843
10825
  });
9844
10826
  log.debug(
9845
- { tool: "record_query", mode: "list", type, limit, returned: pageItems(page).length },
10827
+ {
10828
+ tool: "record_query",
10829
+ mode: recent ? "list:recent" : folderId ? "list:folder" : "list:type",
10830
+ type,
10831
+ folderId,
10832
+ limit,
10833
+ returned: pageItems(page).length
10834
+ },
9846
10835
  "record_query list ok"
9847
10836
  );
9848
10837
  }
@@ -10019,7 +11008,7 @@ var inputSchema5 = {
10019
11008
  folderId: import_zod5.z.string().optional().describe("Group this record into a folder."),
10020
11009
  userId: import_zod5.z.string().optional().describe("Owning user id."),
10021
11010
  scopes: import_zod5.z.array(import_zod5.z.string()).optional().describe(
10022
- '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.'
11011
+ '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.'
10023
11012
  )
10024
11013
  };
10025
11014
  var recordCreate = ({ client, log }) => ({
@@ -10052,19 +11041,101 @@ var recordCreate = ({ client, log }) => ({
10052
11041
  });
10053
11042
  var record_create_default = recordCreate;
10054
11043
 
10055
- // src/tools/record_update.ts
11044
+ // src/tools/record_batch_write.ts
10056
11045
  var import_zod6 = require("zod");
10057
- var inputSchema6 = {
10058
- id: import_zod6.z.string().optional().describe("The Vectros record id to update. Provide this OR externalId+type."),
11046
+ var MCP_MAX_ITEMS = 50;
11047
+ var itemSchema = import_zod6.z.strictObject({
11048
+ type: import_zod6.z.string().min(1, "type is required").describe('Record type / schema name (e.g. "task"). Must match an existing schema \u2014 see list_schemas.'),
11049
+ fields: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).describe(
11050
+ "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)."
11051
+ ),
10059
11052
  externalId: import_zod6.z.string().optional().describe(
11053
+ '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.'
11054
+ ),
11055
+ indexMode: import_zod6.z.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
11056
+ "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."
11057
+ ),
11058
+ status: import_zod6.z.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
11059
+ folderId: import_zod6.z.string().optional().describe("Group this record into a folder."),
11060
+ userId: import_zod6.z.string().optional().describe("Owning user id."),
11061
+ scopes: import_zod6.z.array(import_zod6.z.string()).optional().describe(
11062
+ "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."
11063
+ )
11064
+ });
11065
+ var inputSchema6 = {
11066
+ items: import_zod6.z.array(itemSchema).min(1).max(MCP_MAX_ITEMS).describe(
11067
+ `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.`
11068
+ ),
11069
+ atomicity: import_zod6.z.enum(["best_effort", "all_or_nothing"]).optional().describe(
11070
+ '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).'
11071
+ ),
11072
+ upsert: import_zod6.z.boolean().optional().describe(
11073
+ "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."
11074
+ ),
11075
+ allowClear: import_zod6.z.boolean().optional().describe(
11076
+ "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."
11077
+ )
11078
+ };
11079
+ var recordBatchWrite = ({ client, log }) => ({
11080
+ name: "record_batch_write",
11081
+ title: "Create or upsert multiple records in one call",
11082
+ 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).',
11083
+ inputSchema: inputSchema6,
11084
+ handler: async (args) => {
11085
+ const items = args.items;
11086
+ const atomicity = args.atomicity;
11087
+ try {
11088
+ const body = {
11089
+ items: items.map((item) => ({
11090
+ typeName: item.type,
11091
+ payload: item.fields,
11092
+ externalId: item.externalId,
11093
+ indexMode: item.indexMode,
11094
+ status: item.status,
11095
+ folderId: item.folderId,
11096
+ userId: item.userId,
11097
+ scopes: item.scopes
11098
+ })),
11099
+ atomicity,
11100
+ upsert: args.upsert,
11101
+ allowClear: args.allowClear
11102
+ };
11103
+ const response = await client.records.batchWriteRecords(body, { maxRetries: 0 });
11104
+ log.debug(
11105
+ {
11106
+ tool: "record_batch_write",
11107
+ submitted: items.length,
11108
+ atomicity: atomicity ?? "best_effort",
11109
+ succeeded: response.succeeded,
11110
+ failed: response.failed
11111
+ },
11112
+ "record_batch_write ok"
11113
+ );
11114
+ return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
11115
+ } catch (err) {
11116
+ log.warn(
11117
+ { tool: "record_batch_write", itemCount: items?.length, err: String(err) },
11118
+ "record_batch_write failed"
11119
+ );
11120
+ return toolError("record_batch_write", err);
11121
+ }
11122
+ }
11123
+ });
11124
+ var record_batch_write_default = recordBatchWrite;
11125
+
11126
+ // src/tools/record_update.ts
11127
+ var import_zod7 = require("zod");
11128
+ var inputSchema7 = {
11129
+ id: import_zod7.z.string().optional().describe("The Vectros record id to update. Provide this OR externalId+type."),
11130
+ externalId: import_zod7.z.string().optional().describe(
10060
11131
  "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."
10061
11132
  ),
10062
- type: import_zod6.z.string().optional().describe("Record type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10063
- fields: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).describe(
11133
+ type: import_zod7.z.string().optional().describe("Record type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11134
+ fields: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown()).describe(
10064
11135
  "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."
10065
11136
  ),
10066
- status: import_zod6.z.string().optional().describe("Set the record lifecycle status (e.g. ARCHIVED) \u2014 archive/workflow without physical deletion."),
10067
- expectedVersion: import_zod6.z.number().int().optional().describe(
11137
+ status: import_zod7.z.string().optional().describe("Set the record lifecycle status (e.g. ARCHIVED) \u2014 archive/workflow without physical deletion."),
11138
+ expectedVersion: import_zod7.z.number().int().optional().describe(
10068
11139
  "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."
10069
11140
  )
10070
11141
  };
@@ -10072,7 +11143,7 @@ var recordUpdate = ({ client, log }) => ({
10072
11143
  name: "record_update",
10073
11144
  title: "Update a record by id or externalId",
10074
11145
  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.",
10075
- inputSchema: inputSchema6,
11146
+ inputSchema: inputSchema7,
10076
11147
  handler: async (args) => {
10077
11148
  const id = args.id;
10078
11149
  const externalId = args.externalId;
@@ -10098,15 +11169,15 @@ var recordUpdate = ({ client, log }) => ({
10098
11169
  var record_update_default = recordUpdate;
10099
11170
 
10100
11171
  // src/tools/record_delete.ts
10101
- var import_zod7 = require("zod");
10102
- var inputSchema7 = {
10103
- id: import_zod7.z.string().min(1, "id is required").describe("The Vectros record id to delete.")
11172
+ var import_zod8 = require("zod");
11173
+ var inputSchema8 = {
11174
+ id: import_zod8.z.string().min(1, "id is required").describe("The Vectros record id to delete.")
10104
11175
  };
10105
11176
  var recordDelete = ({ client, log }) => ({
10106
11177
  name: "record_delete",
10107
11178
  title: "Delete a record",
10108
11179
  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.",
10109
- inputSchema: inputSchema7,
11180
+ inputSchema: inputSchema8,
10110
11181
  handler: async (args) => {
10111
11182
  const id = args.id;
10112
11183
  try {
@@ -10122,49 +11193,63 @@ var recordDelete = ({ client, log }) => ({
10122
11193
  var record_delete_default = recordDelete;
10123
11194
 
10124
11195
  // src/tools/rag_ask.ts
10125
- var import_zod8 = require("zod");
11196
+ var import_zod9 = require("zod");
10126
11197
  var SEARCH_MCP_DEFAULT_LIMIT = 5;
10127
11198
  var SEARCH_MCP_MAX_LIMIT = 50;
10128
- var inputSchema8 = {
10129
- query: import_zod8.z.string().min(1, "query must be non-empty").describe("Question to ground against retrieved content."),
10130
- instructions: import_zod8.z.string().optional().describe(
11199
+ var inputSchema9 = {
11200
+ query: import_zod9.z.string().min(1, "query must be non-empty").describe("Question to ground against retrieved content."),
11201
+ instructions: import_zod9.z.string().optional().describe(
10131
11202
  '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.'
10132
11203
  ),
10133
- model: import_zod8.z.string().optional().describe(
11204
+ model: import_zod9.z.string().optional().describe(
10134
11205
  "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."
10135
11206
  ),
10136
- search: import_zod8.z.object({
10137
- mode: import_zod8.z.enum(["HYBRID", "TEXT", "SEMANTIC"]).optional().describe("Retrieval mode. Default HYBRID."),
10138
- limit: import_zod8.z.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(
11207
+ search: import_zod9.z.object({
11208
+ mode: import_zod9.z.enum(["HYBRID", "TEXT", "SEMANTIC"]).optional().describe("Retrieval mode. Default HYBRID."),
11209
+ limit: import_zod9.z.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(
10139
11210
  `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.`
10140
11211
  ),
10141
11212
  // Retrieval scoping — parity with hybrid_search so an agent can ground the
10142
11213
  // answer on a specific owner / folder / type / metadata subset, not just the
10143
11214
  // whole-tenant corpus.
10144
- userId: import_zod8.z.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
10145
- scope: import_zod8.z.string().optional().describe(
10146
- '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.'
11215
+ userId: import_zod9.z.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
11216
+ scope: import_zod9.z.string().optional().describe(
11217
+ '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.'
11218
+ ),
11219
+ scopeFilters: import_zod9.z.array(import_zod9.z.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
11220
+ '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`.'
10147
11221
  ),
10148
- folderId: import_zod8.z.string().optional().describe("Restrict retrieval to this exact folder."),
10149
- rootFolderId: import_zod8.z.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
10150
- typeName: import_zod8.z.string().optional().describe("Restrict record retrieval to this schema type."),
10151
- contentTypes: import_zod8.z.array(import_zod8.z.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
10152
- filters: import_zod8.z.record(import_zod8.z.unknown()).optional().describe(
11222
+ folderId: import_zod9.z.string().optional().describe("Restrict retrieval to this exact folder."),
11223
+ rootFolderId: import_zod9.z.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
11224
+ typeName: import_zod9.z.string().optional().describe("Restrict record retrieval to this schema type."),
11225
+ contentTypes: import_zod9.z.array(import_zod9.z.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
11226
+ filters: import_zod9.z.record(import_zod9.z.unknown()).optional().describe(
10153
11227
  '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"}.'
10154
11228
  ),
10155
- createdAfter: import_zod8.z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
10156
- createdBefore: import_zod8.z.string().optional().describe("Restrict to content created at/before this ISO 8601 UTC timestamp."),
10157
- requireComplete: import_zod8.z.boolean().optional().describe("Fail closed (503) on a degraded search backend instead of grounding on partial results. Default false.")
11229
+ createdAfter: import_zod9.z.string().optional().describe(
11230
+ "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."
11231
+ ),
11232
+ createdBefore: import_zod9.z.string().optional().describe("Same creation-time basis as createdAfter, bounding at/before this ISO 8601 UTC value."),
11233
+ requireComplete: import_zod9.z.boolean().optional().describe("Fail closed (503) on a degraded search backend instead of grounding on partial results. Default false.")
10158
11234
  }).optional().describe("Retrieval params + scoping. Default mode HYBRID, limit " + SEARCH_MCP_DEFAULT_LIMIT + "."),
10159
- maxTokens: import_zod8.z.number().int().min(1).optional().describe("Max output tokens."),
10160
- temperature: import_zod8.z.number().min(0).max(1).optional().describe("Sampling temperature (0.0\u20131.0). Default 0.3 \u2014 lower favors deterministic, retrieval-grounded answers.")
11235
+ maxTokens: import_zod9.z.number().int().min(1).optional().describe("Max output tokens."),
11236
+ temperature: import_zod9.z.number().min(0).max(1).optional().describe("Sampling temperature (0.0\u20131.0). Default 0.3 \u2014 lower favors deterministic, retrieval-grounded answers.")
10161
11237
  };
10162
11238
  var ragAsk = ({ client, log }) => ({
10163
11239
  name: "rag_ask",
10164
11240
  title: "RAG ask (corpus-wide)",
10165
- 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.",
10166
- inputSchema: inputSchema8,
11241
+ 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.",
11242
+ inputSchema: inputSchema9,
10167
11243
  handler: async (args, extra) => {
11244
+ const rawSearch = args.search ?? {};
11245
+ if (rawSearch.scope !== void 0 && rawSearch.scopeFilters !== void 0) {
11246
+ return toolError(
11247
+ "rag_ask",
11248
+ new Error(
11249
+ "search.scope and search.scopeFilters are mutually exclusive \u2014 pass 'scope' for a single ownership dimension, or 'scopeFilters' for more than one, not both."
11250
+ )
11251
+ );
11252
+ }
10168
11253
  try {
10169
11254
  const searchArg = args.search ?? {};
10170
11255
  const search = {
@@ -10172,6 +11257,7 @@ var ragAsk = ({ client, log }) => ({
10172
11257
  limit: searchArg.limit ?? SEARCH_MCP_DEFAULT_LIMIT,
10173
11258
  userId: searchArg.userId,
10174
11259
  scope: searchArg.scope,
11260
+ scopeFilters: searchArg.scopeFilters,
10175
11261
  folderId: searchArg.folderId,
10176
11262
  rootFolderId: searchArg.rootFolderId,
10177
11263
  typeName: searchArg.typeName,
@@ -10239,20 +11325,20 @@ var ragAsk = ({ client, log }) => ({
10239
11325
  var rag_ask_default = ragAsk;
10240
11326
 
10241
11327
  // src/tools/document_ask.ts
10242
- var import_zod9 = require("zod");
10243
- var inputSchema9 = {
10244
- documentId: import_zod9.z.string().min(1, "documentId is required").describe("ID of the document to ask against."),
10245
- prompt: import_zod9.z.string().min(1, "prompt is required").describe("Question to ask about the document."),
10246
- model: import_zod9.z.string().optional().describe(
11328
+ var import_zod10 = require("zod");
11329
+ var inputSchema10 = {
11330
+ documentId: import_zod10.z.string().min(1, "documentId is required").describe("ID of the document to ask against."),
11331
+ prompt: import_zod10.z.string().min(1, "prompt is required").describe("Question to ask about the document."),
11332
+ model: import_zod10.z.string().optional().describe(
10247
11333
  "Inference model alias. Default = tier-appropriate Haiku. See GET /v1/models for the catalog the calling key can reach."
10248
11334
  ),
10249
- maxTokens: import_zod9.z.number().int().min(1).optional().describe("Max output tokens.")
11335
+ maxTokens: import_zod10.z.number().int().min(1).optional().describe("Max output tokens.")
10250
11336
  };
10251
11337
  var documentAsk = ({ client, log }) => ({
10252
11338
  name: "document_ask",
10253
11339
  title: "Document ask (single-document)",
10254
11340
  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.",
10255
- inputSchema: inputSchema9,
11341
+ inputSchema: inputSchema10,
10256
11342
  handler: async (args, extra) => {
10257
11343
  try {
10258
11344
  const stream = await client.inference.documentAsk({
@@ -10311,18 +11397,18 @@ var documentAsk = ({ client, log }) => ({
10311
11397
  var document_ask_default = documentAsk;
10312
11398
 
10313
11399
  // src/tools/list_schemas.ts
10314
- var import_zod10 = require("zod");
10315
- var inputSchema10 = {
10316
- userId: import_zod10.z.string().optional().describe(
11400
+ var import_zod11 = require("zod");
11401
+ var inputSchema11 = {
11402
+ userId: import_zod11.z.string().optional().describe(
10317
11403
  "Filter to schemas visible to a specific user. Optional; default returns all schemas the credential can see."
10318
11404
  ),
10319
- scope: import_zod10.z.string().optional().describe(
11405
+ scope: import_zod11.z.string().optional().describe(
10320
11406
  '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.'
10321
11407
  ),
10322
- surface: import_zod10.z.enum(["record", "document", "user", "entity"]).optional().describe(
11408
+ surface: import_zod11.z.enum(["record", "document", "user", "entity"]).optional().describe(
10323
11409
  "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."
10324
11410
  ),
10325
- recordType: import_zod10.z.string().optional().describe(
11411
+ recordType: import_zod11.z.string().optional().describe(
10326
11412
  '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.'
10327
11413
  )
10328
11414
  };
@@ -10330,7 +11416,7 @@ var listSchemas = ({ client, log }) => ({
10330
11416
  name: "list_schemas",
10331
11417
  title: "List record schemas",
10332
11418
  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.',
10333
- inputSchema: inputSchema10,
11419
+ inputSchema: inputSchema11,
10334
11420
  handler: async (args) => {
10335
11421
  const userId = args.userId;
10336
11422
  const scope = args.scope;
@@ -10356,18 +11442,18 @@ var listSchemas = ({ client, log }) => ({
10356
11442
  var list_schemas_default = listSchemas;
10357
11443
 
10358
11444
  // src/tools/document_get.ts
10359
- var import_zod11 = require("zod");
11445
+ var import_zod12 = require("zod");
10360
11446
  var MAX_TEXT_CHARS = 32e3;
10361
- var inputSchema11 = {
10362
- documentId: import_zod11.z.string().optional().describe("The document ID returned by document_ingest or hybrid_search. Provide this OR externalId+type."),
10363
- externalId: import_zod11.z.string().optional().describe(
11447
+ var inputSchema12 = {
11448
+ documentId: import_zod12.z.string().optional().describe("The document ID returned by document_ingest or hybrid_search. Provide this OR externalId+type."),
11449
+ externalId: import_zod12.z.string().optional().describe(
10364
11450
  "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."
10365
11451
  ),
10366
- type: import_zod11.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10367
- includeText: import_zod11.z.boolean().optional().describe(
11452
+ type: import_zod12.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11453
+ includeText: import_zod12.z.boolean().optional().describe(
10368
11454
  "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."
10369
11455
  ),
10370
- includeDownloadUrl: import_zod11.z.boolean().optional().describe(
11456
+ includeDownloadUrl: import_zod12.z.boolean().optional().describe(
10371
11457
  "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."
10372
11458
  )
10373
11459
  };
@@ -10384,7 +11470,7 @@ var documentGet = ({ client, log }) => ({
10384
11470
  name: "document_get",
10385
11471
  title: "Get document metadata (and optionally text)",
10386
11472
  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.",
10387
- inputSchema: inputSchema11,
11473
+ inputSchema: inputSchema12,
10388
11474
  handler: async (args) => {
10389
11475
  const documentId = args.documentId;
10390
11476
  const externalId = args.externalId;
@@ -10449,28 +11535,28 @@ var documentGet = ({ client, log }) => ({
10449
11535
  var document_get_default = documentGet;
10450
11536
 
10451
11537
  // src/tools/document_query.ts
10452
- var import_zod12 = require("zod");
11538
+ var import_zod13 = require("zod");
10453
11539
  var MCP_DEFAULT_LIMIT3 = 3;
10454
11540
  var MCP_MAX_LIMIT3 = 100;
10455
- var inputSchema12 = {
11541
+ var inputSchema13 = {
10456
11542
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
10457
- field: import_zod12.z.string().optional().describe("Lookup mode: name of the lookup-indexed field to query by."),
10458
- value: import_zod12.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields too."),
10459
- from: import_zod12.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Range-enabled, non-sensitive fields only."),
10460
- to: import_zod12.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
10461
- prefix: import_zod12.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
10462
- order: import_zod12.z.enum(["asc", "desc"]).optional().describe(
11543
+ field: import_zod13.z.string().optional().describe("Lookup mode: name of the lookup-indexed field to query by."),
11544
+ value: import_zod13.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields too."),
11545
+ from: import_zod13.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Range-enabled, non-sensitive fields only."),
11546
+ to: import_zod13.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
11547
+ prefix: import_zod13.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
11548
+ order: import_zod13.z.enum(["asc", "desc"]).optional().describe(
10463
11549
  "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."
10464
11550
  ),
10465
- type: import_zod12.z.string().optional().describe("Lookup mode: the document type (the bound schema's type). Required with `field`."),
11551
+ type: import_zod13.z.string().optional().describe("Lookup mode: the document type (the bound schema's type). Required with `field`."),
10466
11552
  // List-mode args:
10467
- folderId: import_zod12.z.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
10468
- userId: import_zod12.z.string().optional().describe("List mode: scope to documents owned by this user."),
10469
- scope: import_zod12.z.string().optional().describe(
11553
+ folderId: import_zod13.z.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
11554
+ userId: import_zod13.z.string().optional().describe("List mode: scope to documents owned by this user."),
11555
+ scope: import_zod13.z.string().optional().describe(
10470
11556
  '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.'
10471
11557
  ),
10472
- startFrom: import_zod12.z.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next. Works in both list and lookup mode."),
10473
- limit: import_zod12.z.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
11558
+ startFrom: import_zod13.z.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next. Works in both list and lookup mode."),
11559
+ limit: import_zod13.z.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
10474
11560
  `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.`
10475
11561
  )
10476
11562
  };
@@ -10478,7 +11564,7 @@ var documentQuery = ({ client, log }) => ({
10478
11564
  name: "document_query",
10479
11565
  title: "Document query (list or lookup)",
10480
11566
  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.",
10481
- inputSchema: inputSchema12,
11567
+ inputSchema: inputSchema13,
10482
11568
  handler: async (args) => {
10483
11569
  const limit = args.limit ?? MCP_DEFAULT_LIMIT3;
10484
11570
  const field = args.field;
@@ -10558,29 +11644,29 @@ var documentQuery = ({ client, log }) => ({
10558
11644
  var document_query_default = documentQuery;
10559
11645
 
10560
11646
  // src/tools/document_update.ts
10561
- var import_zod13 = require("zod");
10562
- var inputSchema13 = {
10563
- documentId: import_zod13.z.string().optional().describe("The Vectros document id to update. Provide this OR externalId+type."),
10564
- externalId: import_zod13.z.string().optional().describe(
11647
+ var import_zod14 = require("zod");
11648
+ var inputSchema14 = {
11649
+ documentId: import_zod14.z.string().optional().describe("The Vectros document id to update. Provide this OR externalId+type."),
11650
+ externalId: import_zod14.z.string().optional().describe(
10565
11651
  "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."
10566
11652
  ),
10567
- type: import_zod13.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10568
- title: import_zod13.z.string().optional().describe("New title. Omit to keep the current title."),
10569
- fields: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown()).optional().describe(
11653
+ type: import_zod14.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11654
+ title: import_zod14.z.string().optional().describe("New title. Omit to keep the current title."),
11655
+ fields: import_zod14.z.record(import_zod14.z.string(), import_zod14.z.unknown()).optional().describe(
10570
11656
  "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."
10571
11657
  ),
10572
- text: import_zod13.z.string().optional().describe(
11658
+ text: import_zod14.z.string().optional().describe(
10573
11659
  "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."
10574
11660
  ),
10575
- folderId: import_zod13.z.string().optional().describe("Move the document into this folder (cannot be cleared once set)."),
10576
- status: import_zod13.z.enum(["ACTIVE", "ARCHIVED"]).optional().describe(
11661
+ folderId: import_zod14.z.string().optional().describe("Move the document into this folder (cannot be cleared once set)."),
11662
+ status: import_zod14.z.enum(["ACTIVE", "ARCHIVED"]).optional().describe(
10577
11663
  "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."
10578
11664
  ),
10579
- userId: import_zod13.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10580
- scopes: import_zod13.z.array(import_zod13.z.string()).optional().describe(
11665
+ userId: import_zod14.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
11666
+ scopes: import_zod14.z.array(import_zod14.z.string()).optional().describe(
10581
11667
  '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).'
10582
11668
  ),
10583
- expectedVersion: import_zod13.z.number().int().optional().describe(
11669
+ expectedVersion: import_zod14.z.number().int().optional().describe(
10584
11670
  "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."
10585
11671
  )
10586
11672
  };
@@ -10588,7 +11674,7 @@ var documentUpdate = ({ client, log }) => ({
10588
11674
  name: "document_update",
10589
11675
  title: "Update a document",
10590
11676
  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.',
10591
- inputSchema: inputSchema13,
11677
+ inputSchema: inputSchema14,
10592
11678
  handler: async (args) => {
10593
11679
  const documentId = args.documentId;
10594
11680
  const externalId = args.externalId;
@@ -10628,15 +11714,15 @@ var documentUpdate = ({ client, log }) => ({
10628
11714
  var document_update_default = documentUpdate;
10629
11715
 
10630
11716
  // src/tools/document_delete.ts
10631
- var import_zod14 = require("zod");
10632
- var inputSchema14 = {
10633
- documentId: import_zod14.z.string().min(1, "documentId is required").describe("The Vectros document id to delete.")
11717
+ var import_zod15 = require("zod");
11718
+ var inputSchema15 = {
11719
+ documentId: import_zod15.z.string().min(1, "documentId is required").describe("The Vectros document id to delete.")
10634
11720
  };
10635
11721
  var documentDelete = ({ client, log }) => ({
10636
11722
  name: "document_delete",
10637
11723
  title: "Delete a document",
10638
11724
  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).',
10639
- inputSchema: inputSchema14,
11725
+ inputSchema: inputSchema15,
10640
11726
  handler: async (args) => {
10641
11727
  const documentId = args.documentId;
10642
11728
  try {
@@ -10654,18 +11740,18 @@ var documentDelete = ({ client, log }) => ({
10654
11740
  var document_delete_default = documentDelete;
10655
11741
 
10656
11742
  // src/tools/folder_query.ts
10657
- var import_zod15 = require("zod");
11743
+ var import_zod16 = require("zod");
10658
11744
  var MCP_DEFAULT_LIMIT4 = 10;
10659
11745
  var MCP_MAX_LIMIT4 = 100;
10660
- var inputSchema15 = {
10661
- id: import_zod15.z.string().optional().describe("Get mode: fetch this single folder by id."),
10662
- parentId: import_zod15.z.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
10663
- userId: import_zod15.z.string().optional().describe("List mode: scope to folders owned by this user."),
10664
- scope: import_zod15.z.string().optional().describe(
11746
+ var inputSchema16 = {
11747
+ id: import_zod16.z.string().optional().describe("Get mode: fetch this single folder by id."),
11748
+ parentId: import_zod16.z.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
11749
+ userId: import_zod16.z.string().optional().describe("List mode: scope to folders owned by this user."),
11750
+ scope: import_zod16.z.string().optional().describe(
10665
11751
  '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.'
10666
11752
  ),
10667
- startFrom: import_zod15.z.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
10668
- limit: import_zod15.z.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
11753
+ startFrom: import_zod16.z.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
11754
+ limit: import_zod16.z.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
10669
11755
  `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\`.`
10670
11756
  )
10671
11757
  };
@@ -10673,7 +11759,7 @@ var folderQuery = ({ client, log }) => ({
10673
11759
  name: "folder_query",
10674
11760
  title: "Folder query (list or get)",
10675
11761
  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.",
10676
- inputSchema: inputSchema15,
11762
+ inputSchema: inputSchema16,
10677
11763
  handler: async (args) => {
10678
11764
  const id = args.id;
10679
11765
  try {
@@ -10703,14 +11789,14 @@ var folderQuery = ({ client, log }) => ({
10703
11789
  var folder_query_default = folderQuery;
10704
11790
 
10705
11791
  // src/tools/folder_create.ts
10706
- var import_zod16 = require("zod");
10707
- var inputSchema16 = {
10708
- name: import_zod16.z.string().min(1, "name is required").describe("Folder display name."),
10709
- description: import_zod16.z.string().optional().describe("Optional description of the folder's purpose."),
10710
- parentId: import_zod16.z.string().optional().describe("Parent folder id \u2014 places the folder under this parent. Omit for the context default root. Create-only."),
10711
- slug: import_zod16.z.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
10712
- userId: import_zod16.z.string().optional().describe("Owning user (Vectros UUID)."),
10713
- scopes: import_zod16.z.array(import_zod16.z.string()).optional().describe(
11792
+ var import_zod17 = require("zod");
11793
+ var inputSchema17 = {
11794
+ name: import_zod17.z.string().min(1, "name is required").describe("Folder display name."),
11795
+ description: import_zod17.z.string().optional().describe("Optional description of the folder's purpose."),
11796
+ parentId: import_zod17.z.string().optional().describe("Parent folder id \u2014 places the folder under this parent. Omit for the context default root. Create-only."),
11797
+ slug: import_zod17.z.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
11798
+ userId: import_zod17.z.string().optional().describe("Owning user (Vectros UUID)."),
11799
+ scopes: import_zod17.z.array(import_zod17.z.string()).optional().describe(
10714
11800
  '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.'
10715
11801
  )
10716
11802
  };
@@ -10718,7 +11804,7 @@ var folderCreate = ({ client, log }) => ({
10718
11804
  name: "folder_create",
10719
11805
  title: "Create a folder",
10720
11806
  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).",
10721
- inputSchema: inputSchema16,
11807
+ inputSchema: inputSchema17,
10722
11808
  handler: async (args) => {
10723
11809
  try {
10724
11810
  const folder = await client.folders.createFolder({
@@ -10742,16 +11828,16 @@ var folderCreate = ({ client, log }) => ({
10742
11828
  var folder_create_default = folderCreate;
10743
11829
 
10744
11830
  // src/tools/folder_update.ts
10745
- var import_zod17 = require("zod");
10746
- var inputSchema17 = {
10747
- id: import_zod17.z.string().min(1, "id is required").describe("The Vectros folder id to update."),
10748
- name: import_zod17.z.string().optional().describe("New folder name. Omit to keep the current name."),
10749
- description: import_zod17.z.string().optional().describe("New description. Omit to leave unchanged."),
10750
- userId: import_zod17.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10751
- scopes: import_zod17.z.array(import_zod17.z.string()).optional().describe(
11831
+ var import_zod18 = require("zod");
11832
+ var inputSchema18 = {
11833
+ id: import_zod18.z.string().min(1, "id is required").describe("The Vectros folder id to update."),
11834
+ name: import_zod18.z.string().optional().describe("New folder name. Omit to keep the current name."),
11835
+ description: import_zod18.z.string().optional().describe("New description. Omit to leave unchanged."),
11836
+ userId: import_zod18.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
11837
+ scopes: import_zod18.z.array(import_zod18.z.string()).optional().describe(
10752
11838
  '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).'
10753
11839
  ),
10754
- expectedVersion: import_zod17.z.number().int().optional().describe(
11840
+ expectedVersion: import_zod18.z.number().int().optional().describe(
10755
11841
  "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."
10756
11842
  )
10757
11843
  };
@@ -10759,7 +11845,7 @@ var folderUpdate = ({ client, log }) => ({
10759
11845
  name: "folder_update",
10760
11846
  title: "Update a folder",
10761
11847
  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.",
10762
- inputSchema: inputSchema17,
11848
+ inputSchema: inputSchema18,
10763
11849
  handler: async (args) => {
10764
11850
  const id = args.id;
10765
11851
  const name = args.name;
@@ -10786,15 +11872,15 @@ var folderUpdate = ({ client, log }) => ({
10786
11872
  var folder_update_default = folderUpdate;
10787
11873
 
10788
11874
  // src/tools/folder_delete.ts
10789
- var import_zod18 = require("zod");
10790
- var inputSchema18 = {
10791
- id: import_zod18.z.string().min(1, "id is required").describe("The Vectros folder id to delete.")
11875
+ var import_zod19 = require("zod");
11876
+ var inputSchema19 = {
11877
+ id: import_zod19.z.string().min(1, "id is required").describe("The Vectros folder id to delete.")
10792
11878
  };
10793
11879
  var folderDelete = ({ client, log }) => ({
10794
11880
  name: "folder_delete",
10795
11881
  title: "Delete a folder",
10796
- 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.",
10797
- inputSchema: inputSchema18,
11882
+ 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.',
11883
+ inputSchema: inputSchema19,
10798
11884
  handler: async (args) => {
10799
11885
  const id = args.id;
10800
11886
  try {
@@ -10810,14 +11896,14 @@ var folderDelete = ({ client, log }) => ({
10810
11896
  var folder_delete_default = folderDelete;
10811
11897
 
10812
11898
  // src/tools/current_identity.ts
10813
- var inputSchema19 = {
11899
+ var inputSchema20 = {
10814
11900
  // No args — current_identity describes the current credential.
10815
11901
  };
10816
11902
  var currentIdentity = ({ log, apiKey, environment }) => ({
10817
11903
  name: "current_identity",
10818
11904
  title: "Current identity (tenant + principal scope)",
10819
- 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.",
10820
- inputSchema: inputSchema19,
11905
+ 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.",
11906
+ inputSchema: inputSchema20,
10821
11907
  handler: async () => {
10822
11908
  try {
10823
11909
  const identity = await resolveIdentity({ log, apiKey, environment });
@@ -10833,7 +11919,7 @@ var currentIdentity = ({ log, apiKey, environment }) => ({
10833
11919
  var current_identity_default = currentIdentity;
10834
11920
 
10835
11921
  // src/tools/document_ingest.ts
10836
- var import_zod19 = require("zod");
11922
+ var import_zod20 = require("zod");
10837
11923
  var import_promises = require("fs/promises");
10838
11924
  var import_node_path = require("path");
10839
11925
  var IngestPathError = class extends Error {
@@ -10908,37 +11994,37 @@ function inferMimeType(filePath) {
10908
11994
  const ext = (0, import_node_path.extname)(filePath).toLowerCase();
10909
11995
  return EXT_TO_MIME[ext] ?? "application/octet-stream";
10910
11996
  }
10911
- var inputSchema20 = {
10912
- title: import_zod19.z.string().min(1, "title is required").describe("Human-readable document title \u2014 appears in search results and the UI."),
10913
- indexMode: import_zod19.z.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
11997
+ var inputSchema21 = {
11998
+ title: import_zod20.z.string().min(1, "title is required").describe("Human-readable document title \u2014 appears in search results and the UI."),
11999
+ indexMode: import_zod20.z.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
10914
12000
  "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."
10915
12001
  ),
10916
- externalId: import_zod19.z.string().optional().describe(
12002
+ externalId: import_zod20.z.string().optional().describe(
10917
12003
  '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.'
10918
12004
  ),
10919
- upsert: import_zod19.z.boolean().optional().describe(
12005
+ upsert: import_zod20.z.boolean().optional().describe(
10920
12006
  "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)."
10921
12007
  ),
10922
- schemaId: import_zod19.z.string().optional().describe(
12008
+ schemaId: import_zod20.z.string().optional().describe(
10923
12009
  "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."
10924
12010
  ),
10925
- payload: import_zod19.z.record(import_zod19.z.string(), import_zod19.z.unknown()).optional().describe(
12011
+ payload: import_zod20.z.record(import_zod20.z.string(), import_zod20.z.unknown()).optional().describe(
10926
12012
  "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."
10927
12013
  ),
10928
12014
  // Inline text mode (mutually exclusive with filePath):
10929
- text: import_zod19.z.string().min(1).optional().describe("Text body to ingest inline. Mutually exclusive with filePath. Either text or filePath is required."),
10930
- storeText: import_zod19.z.boolean().optional().describe(
12015
+ text: import_zod20.z.string().min(1).optional().describe("Text body to ingest inline. Mutually exclusive with filePath. Either text or filePath is required."),
12016
+ storeText: import_zod20.z.boolean().optional().describe(
10931
12017
  "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."
10932
12018
  ),
10933
12019
  // File upload mode (mutually exclusive with text; stdio-transport-only):
10934
- filePath: import_zod19.z.string().min(1).optional().describe(
12020
+ filePath: import_zod20.z.string().min(1).optional().describe(
10935
12021
  "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."
10936
12022
  ),
10937
- fileType: import_zod19.z.string().optional().describe('MIME type of the file (e.g. "application/pdf"). Inferred from filePath extension if omitted.'),
12023
+ fileType: import_zod20.z.string().optional().describe('MIME type of the file (e.g. "application/pdf"). Inferred from filePath extension if omitted.'),
10938
12024
  // Common (both modes):
10939
- folderId: import_zod19.z.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
10940
- userId: import_zod19.z.string().optional().describe("Owning user ID. Optional."),
10941
- scopes: import_zod19.z.array(import_zod19.z.string()).optional().describe(
12025
+ folderId: import_zod20.z.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
12026
+ userId: import_zod20.z.string().optional().describe("Owning user ID. Optional."),
12027
+ scopes: import_zod20.z.array(import_zod20.z.string()).optional().describe(
10942
12028
  "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."
10943
12029
  )
10944
12030
  };
@@ -10946,7 +12032,7 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10946
12032
  name: "document_ingest",
10947
12033
  title: "Ingest a new document (text body or file upload)",
10948
12034
  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`.",
10949
- inputSchema: inputSchema20,
12035
+ inputSchema: inputSchema21,
10950
12036
  handler: async (args) => {
10951
12037
  const title = args.title;
10952
12038
  const text = args.text;
@@ -11098,29 +12184,29 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
11098
12184
  var document_ingest_default = documentIngest;
11099
12185
 
11100
12186
  // src/tools/lookup_principal.ts
11101
- var import_zod20 = require("zod");
12187
+ var import_zod21 = require("zod");
11102
12188
  var MCP_DEFAULT_LIMIT5 = 10;
11103
12189
  var MCP_MAX_LIMIT5 = 100;
11104
- var inputSchema21 = {
11105
- kind: import_zod20.z.string().describe(
12190
+ var inputSchema22 = {
12191
+ kind: import_zod21.z.string().describe(
11106
12192
  '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.'
11107
12193
  ),
11108
- externalId: import_zod20.z.string().optional().describe(
12194
+ externalId: import_zod21.z.string().optional().describe(
11109
12195
  "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."
11110
12196
  ),
11111
- contextId: import_zod20.z.string().optional().describe(
12197
+ contextId: import_zod21.z.string().optional().describe(
11112
12198
  "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."
11113
12199
  ),
11114
12200
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
11115
- type: import_zod20.z.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
11116
- field: import_zod20.z.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
11117
- value: import_zod20.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields."),
11118
- from: import_zod20.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Non-sensitive fields only."),
11119
- to: import_zod20.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
11120
- prefix: import_zod20.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
11121
- order: import_zod20.z.enum(["asc", "desc"]).optional().describe("Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc`."),
11122
- startFrom: import_zod20.z.string().optional().describe("Lookup mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
11123
- limit: import_zod20.z.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(
12201
+ type: import_zod21.z.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
12202
+ field: import_zod21.z.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
12203
+ value: import_zod21.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields."),
12204
+ from: import_zod21.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Non-sensitive fields only."),
12205
+ to: import_zod21.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
12206
+ prefix: import_zod21.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
12207
+ order: import_zod21.z.enum(["asc", "desc"]).optional().describe("Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc`."),
12208
+ startFrom: import_zod21.z.string().optional().describe("Lookup mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
12209
+ limit: import_zod21.z.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(
11124
12210
  `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\`.`
11125
12211
  )
11126
12212
  };
@@ -11128,7 +12214,7 @@ var lookupPrincipal = ({ client, log }) => ({
11128
12214
  name: "lookup_principal",
11129
12215
  title: "Look up a user identity or a namespaced identity entity",
11130
12216
  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.",
11131
- inputSchema: inputSchema21,
12217
+ inputSchema: inputSchema22,
11132
12218
  handler: async (args) => {
11133
12219
  const kind = args.kind;
11134
12220
  const isUser = kind === "user";
@@ -11202,17 +12288,17 @@ var lookupPrincipal = ({ client, log }) => ({
11202
12288
  var lookup_principal_default = lookupPrincipal;
11203
12289
 
11204
12290
  // src/tools/version_history.ts
11205
- var import_zod21 = require("zod");
11206
- var inputSchema22 = {
11207
- resourceType: import_zod21.z.enum(["record", "document"]).describe("Which kind of entity the id refers to: a record or a document."),
11208
- id: import_zod21.z.string().min(1, "id is required").describe("The Vectros id of the record or document whose history you want."),
11209
- startFrom: import_zod21.z.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch older entries.")
12291
+ var import_zod22 = require("zod");
12292
+ var inputSchema23 = {
12293
+ resourceType: import_zod22.z.enum(["record", "document"]).describe("Which kind of entity the id refers to: a record or a document."),
12294
+ id: import_zod22.z.string().min(1, "id is required").describe("The Vectros id of the record or document whose history you want."),
12295
+ startFrom: import_zod22.z.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch older entries.")
11210
12296
  };
11211
12297
  var versionHistory = ({ client, log }) => ({
11212
12298
  name: "version_history",
11213
12299
  title: "Version history (record or document)",
11214
12300
  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.",
11215
- inputSchema: inputSchema22,
12301
+ inputSchema: inputSchema23,
11216
12302
  handler: async (args) => {
11217
12303
  const resourceType = args.resourceType;
11218
12304
  const id = args.id;
@@ -11241,6 +12327,7 @@ var TOOL_NAMES = [
11241
12327
  "record_get",
11242
12328
  "record_batch_get",
11243
12329
  "record_create",
12330
+ "record_batch_write",
11244
12331
  "record_update",
11245
12332
  "record_delete",
11246
12333
  "rag_ask",
@@ -11267,6 +12354,7 @@ var ALL_TOOL_FACTORIES = {
11267
12354
  record_get: record_get_default,
11268
12355
  record_batch_get: record_batch_get_default,
11269
12356
  record_create: record_create_default,
12357
+ record_batch_write: record_batch_write_default,
11270
12358
  record_update: record_update_default,
11271
12359
  record_delete: record_delete_default,
11272
12360
  rag_ask: rag_ask_default,
@@ -11307,7 +12395,7 @@ var identityResource = ({ log, apiKey, environment }) => ({
11307
12395
  name: "identity",
11308
12396
  uri: "vectros://identity",
11309
12397
  title: "Current identity (tenant + principal scope)",
11310
- 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.",
12398
+ 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.",
11311
12399
  mimeType: "application/json",
11312
12400
  read: async () => {
11313
12401
  const identity = await resolveIdentity({ log, apiKey, environment });
@@ -11326,7 +12414,7 @@ var ALL_RESOURCE_FACTORIES = {
11326
12414
  };
11327
12415
 
11328
12416
  // src/zod-to-json-schema.ts
11329
- var import_zod22 = require("zod");
12417
+ var import_zod23 = require("zod");
11330
12418
  function zodShapeToJsonSchema(shape) {
11331
12419
  const properties = {};
11332
12420
  const required = [];
@@ -11341,40 +12429,40 @@ function zodShapeToJsonSchema(shape) {
11341
12429
  function zodTypeToJsonSchema(schema) {
11342
12430
  const description = schema.description;
11343
12431
  let current = schema;
11344
- while (current instanceof import_zod22.z.ZodOptional || current instanceof import_zod22.z.ZodDefault || current instanceof import_zod22.z.ZodNullable) {
12432
+ while (current instanceof import_zod23.z.ZodOptional || current instanceof import_zod23.z.ZodDefault || current instanceof import_zod23.z.ZodNullable) {
11345
12433
  current = current._def.innerType;
11346
12434
  }
11347
12435
  const base = description ? { description } : {};
11348
- if (current instanceof import_zod22.z.ZodString) {
12436
+ if (current instanceof import_zod23.z.ZodString) {
11349
12437
  return { ...base, type: "string" };
11350
12438
  }
11351
- if (current instanceof import_zod22.z.ZodNumber) {
12439
+ if (current instanceof import_zod23.z.ZodNumber) {
11352
12440
  return { ...base, type: "number" };
11353
12441
  }
11354
- if (current instanceof import_zod22.z.ZodBoolean) {
12442
+ if (current instanceof import_zod23.z.ZodBoolean) {
11355
12443
  return { ...base, type: "boolean" };
11356
12444
  }
11357
- if (current instanceof import_zod22.z.ZodEnum) {
12445
+ if (current instanceof import_zod23.z.ZodEnum) {
11358
12446
  return {
11359
12447
  ...base,
11360
12448
  type: "string",
11361
12449
  enum: current.options
11362
12450
  };
11363
12451
  }
11364
- if (current instanceof import_zod22.z.ZodArray) {
12452
+ if (current instanceof import_zod23.z.ZodArray) {
11365
12453
  return {
11366
12454
  ...base,
11367
12455
  type: "array",
11368
12456
  items: zodTypeToJsonSchema(current.element)
11369
12457
  };
11370
12458
  }
11371
- if (current instanceof import_zod22.z.ZodObject) {
12459
+ if (current instanceof import_zod23.z.ZodObject) {
11372
12460
  return {
11373
12461
  ...base,
11374
12462
  ...zodShapeToJsonSchema(current.shape)
11375
12463
  };
11376
12464
  }
11377
- if (current instanceof import_zod22.z.ZodRecord) {
12465
+ if (current instanceof import_zod23.z.ZodRecord) {
11378
12466
  const valueType = current._def.valueType;
11379
12467
  return {
11380
12468
  ...base,
@@ -11498,7 +12586,7 @@ var VectrosMCPServer = class {
11498
12586
  if (!tool) {
11499
12587
  result = toolError(req.params.name ?? "unknown", new Error("No such tool."));
11500
12588
  } else {
11501
- const parsed = import_zod23.z.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
12589
+ const parsed = import_zod24.z.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
11502
12590
  if (!parsed.success) {
11503
12591
  result = toolError(tool.name, new Error(formatArgError(tool, parsed.error)));
11504
12592
  } else {