@vectros-ai/mcp-server 0.16.1 → 0.17.1

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/index.js CHANGED
@@ -76,6 +76,7 @@ __export2(api_exports, {
76
76
  FieldDef: () => FieldDef,
77
77
  FileUploadRequest: () => FileUploadRequest,
78
78
  ForbiddenError: () => ForbiddenError,
79
+ GatewayTimeoutError: () => GatewayTimeoutError,
79
80
  IdentityLookupRequest: () => IdentityLookupRequest,
80
81
  IndexFailure: () => IndexFailure,
81
82
  InternalServerError: () => InternalServerError,
@@ -100,9 +101,12 @@ __export2(api_exports, {
100
101
  SearchRequest: () => SearchRequest,
101
102
  SearchResult: () => SearchResult,
102
103
  SearchResultsEvent: () => SearchResultsEvent,
104
+ ServiceUnavailableError: () => ServiceUnavailableError,
103
105
  TooManyRequestsError: () => TooManyRequestsError,
106
+ TriggerFailureResponse: () => TriggerFailureResponse,
104
107
  TruncationWarningEvent: () => TruncationWarningEvent,
105
108
  UnauthorizedError: () => UnauthorizedError,
109
+ UnprocessableEntityError: () => UnprocessableEntityError,
106
110
  UserExistsResponse: () => UserExistsResponse,
107
111
  UserRequest: () => UserRequest,
108
112
  UserResponse: () => UserResponse,
@@ -114,7 +118,9 @@ __export2(api_exports, {
114
118
  inference: () => inference_exports,
115
119
  records: () => records_exports,
116
120
  schemas: () => schemas_exports,
117
- search: () => search_exports
121
+ scripts: () => scripts_exports,
122
+ search: () => search_exports,
123
+ triggers: () => triggers_exports
118
124
  });
119
125
  var toJson = (value, replacer, space) => {
120
126
  return JSON.stringify(value, replacer, space);
@@ -234,6 +240,21 @@ var ForbiddenError = class extends VectrosError {
234
240
  this.name = this.constructor.name;
235
241
  }
236
242
  };
243
+ var GatewayTimeoutError = class extends VectrosError {
244
+ constructor(body, rawResponse) {
245
+ super({
246
+ message: "GatewayTimeoutError",
247
+ statusCode: 504,
248
+ body,
249
+ rawResponse
250
+ });
251
+ Object.setPrototypeOf(this, new.target.prototype);
252
+ if (Error.captureStackTrace) {
253
+ Error.captureStackTrace(this, this.constructor);
254
+ }
255
+ this.name = this.constructor.name;
256
+ }
257
+ };
237
258
  var InternalServerError = class extends VectrosError {
238
259
  constructor(body, rawResponse) {
239
260
  super({
@@ -294,6 +315,21 @@ var PaymentRequiredError = class extends VectrosError {
294
315
  this.name = this.constructor.name;
295
316
  }
296
317
  };
318
+ var ServiceUnavailableError = class extends VectrosError {
319
+ constructor(body, rawResponse) {
320
+ super({
321
+ message: "ServiceUnavailableError",
322
+ statusCode: 503,
323
+ body,
324
+ rawResponse
325
+ });
326
+ Object.setPrototypeOf(this, new.target.prototype);
327
+ if (Error.captureStackTrace) {
328
+ Error.captureStackTrace(this, this.constructor);
329
+ }
330
+ this.name = this.constructor.name;
331
+ }
332
+ };
297
333
  var TooManyRequestsError = class extends VectrosError {
298
334
  constructor(body, rawResponse) {
299
335
  super({
@@ -324,6 +360,21 @@ var UnauthorizedError = class extends VectrosError {
324
360
  this.name = this.constructor.name;
325
361
  }
326
362
  };
363
+ var UnprocessableEntityError = class extends VectrosError {
364
+ constructor(body, rawResponse) {
365
+ super({
366
+ message: "UnprocessableEntityError",
367
+ statusCode: 422,
368
+ body,
369
+ rawResponse
370
+ });
371
+ Object.setPrototypeOf(this, new.target.prototype);
372
+ if (Error.captureStackTrace) {
373
+ Error.captureStackTrace(this, this.constructor);
374
+ }
375
+ this.name = this.constructor.name;
376
+ }
377
+ };
327
378
  var auth_exports = {};
328
379
  var ErasureRequest;
329
380
  ((ErasureRequest2) => {
@@ -413,6 +464,7 @@ var LookupRecordsRequestOrder = {
413
464
  Desc: "desc"
414
465
  };
415
466
  var schemas_exports = {};
467
+ var scripts_exports = {};
416
468
  var SearchRequest;
417
469
  ((SearchRequest2) => {
418
470
  SearchRequest2.Mode = {
@@ -438,6 +490,7 @@ var search_exports = {};
438
490
  __export2(search_exports, {
439
491
  SearchRequest: () => SearchRequest
440
492
  });
493
+ var triggers_exports = {};
441
494
  var AccessProfileRequest;
442
495
  ((AccessProfileRequest2) => {
443
496
  AccessProfileRequest2.Status = {
@@ -467,7 +520,9 @@ var BatchWriteResult;
467
520
  Created: "created",
468
521
  Updated: "updated",
469
522
  Conflict: "conflict",
470
- Invalid: "invalid"
523
+ Invalid: "invalid",
524
+ Forbidden: "forbidden",
525
+ NotCommitted: "not_committed"
471
526
  };
472
527
  })(BatchWriteResult || (BatchWriteResult = {}));
473
528
  var ChatMessage;
@@ -771,13 +826,23 @@ var SearchResultsEvent;
771
826
  SearchResults: "search_results"
772
827
  };
773
828
  })(SearchResultsEvent || (SearchResultsEvent = {}));
829
+ var TriggerFailureResponse;
830
+ ((TriggerFailureResponse2) => {
831
+ TriggerFailureResponse2.Event = {
832
+ Create: "CREATE",
833
+ Update: "UPDATE",
834
+ Delete: "DELETE"
835
+ };
836
+ })(TriggerFailureResponse || (TriggerFailureResponse = {}));
774
837
  var TruncationWarningEvent;
775
838
  ((TruncationWarningEvent2) => {
776
839
  TruncationWarningEvent2.Event = {
777
840
  TruncationWarning: "truncation_warning"
778
841
  };
779
842
  TruncationWarningEvent2.Reason = {
780
- ContextWindowBudget: "context_window_budget"
843
+ ContextWindowBudget: "context_window_budget",
844
+ NoGroundableContent: "no_groundable_content",
845
+ ContextWindowBudgetAndNoContent: "context_window_budget_and_no_content"
781
846
  };
782
847
  })(TruncationWarningEvent || (TruncationWarningEvent = {}));
783
848
  var UserExistsResponse;
@@ -792,8 +857,7 @@ var UserRequest;
792
857
  ((UserRequest2) => {
793
858
  UserRequest2.Status = {
794
859
  Active: "ACTIVE",
795
- Suspended: "SUSPENDED",
796
- Pending: "PENDING"
860
+ Suspended: "SUSPENDED"
797
861
  };
798
862
  UserRequest2.Type = {
799
863
  Human: "HUMAN",
@@ -2261,6 +2325,16 @@ function mergeHeaders(...headersArray) {
2261
2325
  }
2262
2326
  return result;
2263
2327
  }
2328
+ function mergeOnlyDefinedHeaders(...headersArray) {
2329
+ const result = {};
2330
+ for (const [key, value] of headersArray.filter((headers) => headers != null).flatMap((headers) => Object.entries(headers))) {
2331
+ const insensitiveKey = key.toLowerCase();
2332
+ if (value != null) {
2333
+ result[insensitiveKey] = value;
2334
+ }
2335
+ }
2336
+ return result;
2337
+ }
2264
2338
  function normalizeClientOptions(options) {
2265
2339
  const headers = mergeHeaders(
2266
2340
  {
@@ -2531,7 +2605,7 @@ var AuthClient = class {
2531
2605
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/admin/keys/scoped");
2532
2606
  }
2533
2607
  /**
2534
- * 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.
2608
+ * 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.
2535
2609
  *
2536
2610
  * @param {Vectros.CreateScopedKeyRequest} request
2537
2611
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -2539,6 +2613,7 @@ var AuthClient = class {
2539
2613
  * @throws {@link Vectros.BadRequestError}
2540
2614
  * @throws {@link Vectros.ForbiddenError}
2541
2615
  * @throws {@link Vectros.NotFoundError}
2616
+ * @throws {@link Vectros.ConflictError}
2542
2617
  * @throws {@link Vectros.TooManyRequestsError}
2543
2618
  *
2544
2619
  * @example
@@ -2587,6 +2662,8 @@ var AuthClient = class {
2587
2662
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
2588
2663
  case 404:
2589
2664
  throw new NotFoundError(_response.error.body, _response.rawResponse);
2665
+ case 409:
2666
+ throw new ConflictError(_response.error.body, _response.rawResponse);
2590
2667
  case 429:
2591
2668
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
2592
2669
  default:
@@ -2998,7 +3075,7 @@ var AuthClient = class {
2998
3075
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/app-contexts");
2999
3076
  }
3000
3077
  /**
3001
- * 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.
3078
+ * 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.
3002
3079
  *
3003
3080
  * @param {Vectros.CreateAppContextRequest} request
3004
3081
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3364,6 +3441,7 @@ var AuthClient = class {
3364
3441
  *
3365
3442
  * @throws {@link Vectros.ForbiddenError}
3366
3443
  * @throws {@link Vectros.NotFoundError}
3444
+ * @throws {@link Vectros.ConflictError}
3367
3445
  * @throws {@link Vectros.TooManyRequestsError}
3368
3446
  *
3369
3447
  * @example
@@ -3406,6 +3484,8 @@ var AuthClient = class {
3406
3484
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
3407
3485
  case 404:
3408
3486
  throw new NotFoundError(_response.error.body, _response.rawResponse);
3487
+ case 409:
3488
+ throw new ConflictError(_response.error.body, _response.rawResponse);
3409
3489
  case 429:
3410
3490
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
3411
3491
  default:
@@ -3482,7 +3562,7 @@ var AuthClient = class {
3482
3562
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/app-contexts/{contextId}");
3483
3563
  }
3484
3564
  /**
3485
- * 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.
3565
+ * 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.
3486
3566
  *
3487
3567
  * @param {Vectros.UpdateAppContextRequest} request
3488
3568
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3550,7 +3630,7 @@ var AuthClient = class {
3550
3630
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/app-contexts/{contextId}");
3551
3631
  }
3552
3632
  /**
3553
- * Permanently deletes an app context and everything in it — every record, document, folder, schema, role, and access profile belonging to the context. This is irreversible. The deletion runs asynchronously: the call returns 202 immediately and the context's data drains in the background. Poll the context's `status` field to observe when the teardown completes (`purging` while draining, then `deleted`). To guard against accidental deletion, you must echo the contextId back in the `confirm` query parameter (`?confirm={contextId}`). The reserved `default` and `vectros-admin` contexts cannot be deleted. This operation requires a root API key (one beginning with `sk_`): no scoped credential, not even one with full wildcard (`*`) scope, can trigger this teardown.
3633
+ * Permanently deletes an app context and everything in it — every record, document, folder, schema, role, access profile, and trusted-issuer registration belonging to the context. This is irreversible. The deletion runs asynchronously: the call returns 202 immediately and the context's data drains in the background. Poll the context's `status` field to observe when the teardown completes (`purging` while draining, then `deleted`). To guard against accidental deletion, you must echo the contextId back in the `confirm` query parameter (`?confirm={contextId}`). The reserved `default` and `vectros-admin` contexts cannot be deleted. This operation requires a root API key (one beginning with `sk_`): no scoped credential, not even one with full wildcard (`*`) scope, can trigger this teardown.
3554
3634
  *
3555
3635
  * @param {Vectros.DeleteAppContextRequest} request
3556
3636
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3964,7 +4044,7 @@ var AuthClient = class {
3964
4044
  );
3965
4045
  }
3966
4046
  /**
3967
- * 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.
4047
+ * 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`.
3968
4048
  *
3969
4049
  * @param {Vectros.GetUsageRequest} request
3970
4050
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4085,7 +4165,7 @@ var AuthClient = class {
4085
4165
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/auth/issuers/{issuerId}");
4086
4166
  }
4087
4167
  /**
4088
- * Updates the mutable fields of a registered issuer: `subClaim`, `emailClaim`, `status` (`active`/`suspended` — a suspended issuer's tokens are rejected identically to an unregistered issuer at exchange time), and `selfSignupPolicies`. Fields omitted from the body are left unchanged (partial update). `issuer`, `jwksUri`, `audience`, and `contextId` are trust-anchor / routing-pin fields and are immutable via this route — supplying a value that differs from the current registration is rejected with 400; supplying the current value back is a no-op. Rotating a trust anchor requires deleting and re-registering the issuer, which is itself refused while any user is bound through it. Requires a root API key or the bootstrap's provisioning capability, gated identically to every other operation on this surface. A credential confined to one app context may only update an issuer registered in that context; naming one registered in another context returns 404, identically to a nonexistent issuerId. A root API key may update any issuer.
4168
+ * Updates the mutable fields of a registered issuer: `subClaim`, `emailClaim`, `userinfoUri`, `capturedClaims`, `restrictedToDomain` (a new non-blank value must already be a VERIFIED domain for your account; an empty string clears it back to domain-less; see `IssuerUpdateRequest.restrictedToDomain` for the full semantics), `status` (`active`/`suspended` — a suspended issuer's tokens are rejected identically to an unregistered issuer at exchange time), and `selfSignupPolicies`. Fields omitted from the body are left unchanged (partial update). `issuer`, `jwksUri`, `audience`, and `contextId` are trust-anchor / routing-pin fields and are immutable via this route — supplying a value that differs from the current registration is rejected with 400; supplying the current value back is a no-op. Rotating a trust anchor requires deleting and re-registering the issuer, which is itself refused while any user is bound through it. **`subClaim` is identity-determining, not merely cosmetic**: it names which verified JWT claim is read as the federated user's identifier, so changing it on an issuer that already has bound users would silently re-identify (or, under self-signup, orphan) every one of them — changing it is therefore refused once any user has bound through this issuer, the same guard `DELETE` already applies, and is only free before the first real login. Requires a root API key or the bootstrap's provisioning capability, gated identically to every other operation on this surface. A credential confined to one app context may only update an issuer registered in that context; naming one registered in another context returns 404, identically to a nonexistent issuerId. A root API key may update any issuer.
4089
4169
  *
4090
4170
  * @param {Vectros.IssuerUpdateRequest} request
4091
4171
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4152,7 +4232,7 @@ var AuthClient = class {
4152
4232
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/auth/issuers/{issuerId}");
4153
4233
  }
4154
4234
  /**
4155
- * Deregisters a trusted third-party IdP issuer. Requires a root API key or the bootstrap's provisioning capability. A credential confined to one app context may only deregister an issuer registered in that context; naming one registered in another context returns 404, identically to a nonexistent issuerId. A root API key may deregister any issuer. Refused if any user account was ever created or matched via this issuer (by a prior self-signup or accepted invite, through `POST /v1/auth/token/exchange`) — that access cannot be silently orphaned. Deactivate the affected users first if you intend to cut off their access, or register a replacement issuer before removing this one. An issuer that has never been used for an exchange (no bound users yet) can always be deregistered.
4235
+ * Deregisters a trusted third-party IdP issuer. Requires a root API key or the bootstrap's provisioning capability. A credential confined to one app context may only deregister an issuer registered in that context; naming one registered in another context returns 404, identically to a nonexistent issuerId. A root API key may deregister any issuer. Refused if any user account was ever created or matched via this issuer (by a prior self-signup or accepted invite, through `POST /v1/auth/token/exchange`) — that access cannot be silently orphaned. This is unconditional on the affected users' `status`: suspending them first does not lift the refusal. **A bound registration cannot be replaced, self-service, within its own app context**: registering a replacement issuer under a different issuerId in the SAME context also fails, because the context's one-active-issuer claim is released only when THIS registration is deleted. Two real options: suspend this issuer (stops new exchanges immediately) and register a replacement under a DIFFERENT app context — note that targets a different context, so this context's existing users/roles/access profiles are not carried over; or contact your platform operator, who can force-release this registration so a replacement may be registered in the SAME context under a new issuerId. **The operator path is not a lighter-weight alternative to the first — it PERMANENTLY RETIRES this issuerId and leaves every bound user unable to ever exchange through it again; it does not preserve continuity for them any better than registering under a different context does.** An issuer that has never been used for an exchange (no bound users yet) can always be deregistered.
4156
4236
  *
4157
4237
  * @param {Vectros.DeleteIssuerRequest} request
4158
4238
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4278,7 +4358,7 @@ var AuthClient = class {
4278
4358
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/auth/issuers");
4279
4359
  }
4280
4360
  /**
4281
- * Registers a trusted third-party IdP issuer that BYO-IdP token exchange (`POST /v1/auth/token/exchange`) may accept a `subject_token` from. Requires a root API key or the CLI bootstrap's provisioning capability — never an ordinary partner-grantable scope. A credential authorized only via the provisioning capability may register only against the app context it is bound to; naming a different one returns 403. A root API key is unaffected and may register against any of its contexts. Idempotent by `issuerId` within your tenant; the `(issuer, audience)` pair must not already be registered by a different issuerId/tenant. If `issuerId` collides with a registration owned by a different app context than the one you're confined to, the request fails with 400 rather than returning that context's configuration. An app context may have at most one active issuer — deregister the existing one first if you need to replace it. One issuer MAY serve several contexts today, each via its own registration row with a distinct `audience`.
4361
+ * Registers a trusted third-party IdP issuer that BYO-IdP token exchange (`POST /v1/auth/token/exchange`) may accept a `subject_token` from. Requires a root API key or the CLI bootstrap's provisioning capability — never an ordinary partner-grantable scope. A credential authorized only via the provisioning capability may register only against the app context it is bound to; naming a different one returns 403. A root API key is unaffected and may register against any of its contexts. Idempotent by `issuerId` within your tenant; the `(issuer, audience)` pair must not already be registered by a different issuerId/tenant. If `issuerId` collides with a registration owned by a different app context than the one you're confined to, the request fails with 400 rather than returning that context's configuration. An app context may have at most one active issuer — deregister the existing one first if you need to replace it. One issuer MAY serve several contexts today, each via its own registration row with a distinct `audience`. Optionally name `restrictedToDomain` to scope this registration's (issuer, audience) uniqueness to a specific VERIFIED domain rather than the bare pair — see that field's own description for the full contract, including why it does NOT protect a shared/consumer-IdP registration with no company-domain population.
4282
4362
  *
4283
4363
  * @param {Vectros.IssuerRequest} request
4284
4364
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -5776,7 +5856,7 @@ var DocumentsClient = class {
5776
5856
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/documents/{id}/versions");
5777
5857
  }
5778
5858
  /**
5779
- * Starts a file-based document by returning a short-lived presigned S3 PUT URL. Upload the file bytes directly to `uploadUrl`; the document is then automatically queued for text extraction and asynchronous indexing. Supplying an `externalId` makes this idempotent — re-initiating an upload with the same `externalId` re-issues a fresh presigned URL to the SAME existing document/object (so a re-upload inherently replaces the file body) rather than creating a duplicate. The response's `created` field (and the HTTP status — 201 when a new document was minted, 200 when an existing one was matched) tells the two apart. With `?upsert=true`, the submitted `payload`/`title` are also applied to the matched document (file-body divergence cannot be diffed at upload-init — the bytes have not arrived yet — so the re-upload itself replaces the body). Creating a NEW document requires the `documents:c` scope. Re-uploading over an EXISTING document overwrites (and re-indexes) its body, so it is an update: it requires the `documents:u` scope (as does `?upsert=true` for the metadata).
5859
+ * Starts a file-based document by returning a short-lived presigned S3 PUT URL. Upload the file bytes directly to `uploadUrl`; the document is then automatically queued for text extraction and asynchronous indexing. Supplying an `externalId` makes this idempotent — re-initiating an upload with the same `externalId` re-issues a fresh presigned URL for the SAME existing document, targeting a newly-staged object rather than the document's current one — your PUT lands there first, and the document only adopts it once the upload is validated (so a re-upload inherently replaces the file body) rather than creating a duplicate. The response's `created` field (and the HTTP status — 201 when a new document was minted, 200 when an existing one was matched) tells the two apart. With `?upsert=true`, the submitted `payload`/`title` are also applied to the matched document (file-body divergence cannot be diffed at upload-init — the bytes have not arrived yet — so the re-upload itself replaces the body). Creating a NEW document requires the `documents:c` scope. Re-uploading over an EXISTING document overwrites (and re-indexes) its body, so it is an update: it requires the `documents:u` scope (as does `?upsert=true` for the metadata). **Your PUT to `uploadUrl` MUST include the header named in the response's `requiredHeaderName`, set to `requiredHeaderValue` exactly.** It is a signed part of the presigned request — the PUT never reaches this service either way, so neither failure uses this API's JSON error shape. Omitting it, or sending a different value, invalidates the request's signature and S3 rejects it with a 403 `SignatureDoesNotMatch`. Sending it correctly makes the URL single-use: `requiredHeaderName` is always `If-None-Match` and `requiredHeaderValue` is always `*` — a create, a recovery upload for a document whose earlier file is missing, and a re-upload ALL target a freshly-minted, never-written key, so the same S3 conditional-write precondition applies uniformly (S3's own documented conditional-write behavior): a replay after the object already exists (from your own completed PUT, or anyone else's) fails with `412 Precondition Failed`; a replay after the object was deleted and never re-created finds an absent key again and can succeed — single-use is a property of the object's existence, not a one-time token. **Either precondition can also fail with `409 Conflict` if your PUT genuinely races a concurrent delete on the same object.** Whichever of `412` or `409` you receive, the remedy is the same: call this endpoint again for a fresh URL rather than retrying the same PUT — a fresh call always targets a new key, so it is never subject to whatever raced the previous one.
5780
5860
  *
5781
5861
  * @param {Vectros.FileUploadRequest} request
5782
5862
  * @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6098,7 +6178,7 @@ var FoldersClient = class {
6098
6178
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/folders/{id}");
6099
6179
  }
6100
6180
  /**
6101
- * 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.
6181
+ * 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.
6102
6182
  *
6103
6183
  * @param {Vectros.DeleteFolderRequest} request
6104
6184
  * @param {FoldersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6507,11 +6587,12 @@ var IdentityClient = class {
6507
6587
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/entities/{namespace}/{id}");
6508
6588
  }
6509
6589
  /**
6510
- * 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.
6590
+ * 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.
6511
6591
  *
6512
6592
  * @param {Vectros.UpdateEntityRequest} request
6513
6593
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6514
6594
  *
6595
+ * @throws {@link Vectros.BadRequestError}
6515
6596
  * @throws {@link Vectros.NotFoundError}
6516
6597
  * @throws {@link Vectros.TooManyRequestsError}
6517
6598
  *
@@ -6561,6 +6642,8 @@ var IdentityClient = class {
6561
6642
  }
6562
6643
  if (_response.error.reason === "status-code") {
6563
6644
  switch (_response.error.statusCode) {
6645
+ case 400:
6646
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
6564
6647
  case 404:
6565
6648
  throw new NotFoundError(_response.error.body, _response.rawResponse);
6566
6649
  case 429:
@@ -7539,7 +7622,7 @@ var IdentityClient = class {
7539
7622
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/users/exists-by-email");
7540
7623
  }
7541
7624
  /**
7542
- * Returns the audit trail of changes to a user, most recent first. Identity history is always recorded and always available. Sensitive field values are redacted in every historical version. Returns a page in the `{data, nextCursor}` envelope. Requires the `users:r` scope.
7625
+ * Returns the audit trail of changes to a user, most recent first, including after the user has been deleted. Identity history is always recorded. Post-delete, this is readable by an account-level (root) API key only — a context-confined credential 404s after the delete, the same response it would get for a nonexistent id. Sensitive field values are redacted in every historical version. Returns a page in the `{data, nextCursor}` envelope. Requires the `users:r` scope.
7543
7626
  *
7544
7627
  * @param {Vectros.GetUserVersionsRequest} request
7545
7628
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -7785,7 +7868,7 @@ var InferenceClient = class {
7785
7868
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/documents/{id}/ask");
7786
7869
  }
7787
7870
  /**
7788
- * 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.
7871
+ * 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.
7789
7872
  */
7790
7873
  ragInference(request, requestOptions) {
7791
7874
  return HttpResponsePromise.fromPromise(this.__ragInference(request, requestOptions));
@@ -7980,14 +8063,18 @@ var RecordsClient = class {
7980
8063
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/records/lookup/batch");
7981
8064
  }
7982
8065
  /**
7983
- * 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.
8066
+ * 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.
8067
+ *
8068
+ * `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.
8069
+ *
8070
+ * 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.
7984
8071
  *
7985
8072
  * @param {Vectros.BatchWriteRequest} request
7986
8073
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
7987
8074
  *
8075
+ * @throws {@link Vectros.BadRequestError}
7988
8076
  * @throws {@link Vectros.ForbiddenError}
7989
8077
  * @throws {@link Vectros.TooManyRequestsError}
7990
- * @throws {@link Vectros.NotImplementedError}
7991
8078
  *
7992
8079
  * @example
7993
8080
  * await client.records.batchWriteRecords()
@@ -7996,6 +8083,11 @@ var RecordsClient = class {
7996
8083
  return HttpResponsePromise.fromPromise(this.__batchWriteRecords(request, requestOptions));
7997
8084
  }
7998
8085
  async __batchWriteRecords(request = {}, requestOptions) {
8086
+ const { upsert, allowClear, ..._body } = request;
8087
+ const _queryParams = {
8088
+ upsert,
8089
+ allowClear
8090
+ };
7999
8091
  const _authRequest = await this._options.authProvider.getAuthRequest();
8000
8092
  const _headers = mergeHeaders(
8001
8093
  _authRequest.headers,
@@ -8010,9 +8102,9 @@ var RecordsClient = class {
8010
8102
  method: "POST",
8011
8103
  headers: _headers,
8012
8104
  contentType: "application/json",
8013
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
8105
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
8014
8106
  requestType: "json",
8015
- body: request,
8107
+ body: _body,
8016
8108
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
8017
8109
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
8018
8110
  abortSignal: requestOptions?.abortSignal,
@@ -8024,12 +8116,12 @@ var RecordsClient = class {
8024
8116
  }
8025
8117
  if (_response.error.reason === "status-code") {
8026
8118
  switch (_response.error.statusCode) {
8119
+ case 400:
8120
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
8027
8121
  case 403:
8028
8122
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
8029
8123
  case 429:
8030
8124
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
8031
- case 501:
8032
- throw new NotImplementedError(_response.error.body, _response.rawResponse);
8033
8125
  default:
8034
8126
  throw new VectrosError({
8035
8127
  statusCode: _response.error.statusCode,
@@ -8600,7 +8692,7 @@ var RecordsClient = class {
8600
8692
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/records/lookup");
8601
8693
  }
8602
8694
  /**
8603
- * Returns the tombstone left behind when a record was hard-deleted, confirming the deletion and recording when it happened. Look it up using the deleted record's original ID. Requires the `records:r:<type>` scope.
8695
+ * Returns the tombstone left behind when a record was hard-deleted, confirming the deletion and recording when it happened. Look it up using the deleted record's original ID. Requires the `records:r:<type>` scope, granted without a `data_scope` restriction: the owner of a deleted record cannot be checked, so a credential confined to an ownership compartment (e.g. `data_scope: {scope:org: [org_A]}`) cannot read tombstones, including for records it owned.
8604
8696
  *
8605
8697
  * @param {Vectros.GetRecordTombstoneRequest} request
8606
8698
  * @param {RecordsClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8932,7 +9024,7 @@ var SchemasClient = class {
8932
9024
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}");
8933
9025
  }
8934
9026
  /**
8935
- * 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.
9027
+ * 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.
8936
9028
  *
8937
9029
  * @param {Vectros.UpdateSchemaRequest} request
8938
9030
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -8940,6 +9032,7 @@ var SchemasClient = class {
8940
9032
  * @throws {@link Vectros.BadRequestError}
8941
9033
  * @throws {@link Vectros.ForbiddenError}
8942
9034
  * @throws {@link Vectros.NotFoundError}
9035
+ * @throws {@link Vectros.ConflictError}
8943
9036
  * @throws {@link Vectros.TooManyRequestsError}
8944
9037
  *
8945
9038
  * @example
@@ -8991,6 +9084,8 @@ var SchemasClient = class {
8991
9084
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
8992
9085
  case 404:
8993
9086
  throw new NotFoundError(_response.error.body, _response.rawResponse);
9087
+ case 409:
9088
+ throw new ConflictError(_response.error.body, _response.rawResponse);
8994
9089
  case 429:
8995
9090
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
8996
9091
  default:
@@ -9004,7 +9099,7 @@ var SchemasClient = class {
9004
9099
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/schemas/{id}");
9005
9100
  }
9006
9101
  /**
9007
- * 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.
9102
+ * 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. The same applies to documents bound to this schema (for a schema declaring the `document` surface) — delete those documents first. 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.
9008
9103
  *
9009
9104
  * @param {Vectros.DeleteSchemaRequest} request
9010
9105
  * @param {SchemasClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -9126,46 +9221,70 @@ var SchemasClient = class {
9126
9221
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/schemas/{id}/versions");
9127
9222
  }
9128
9223
  };
9129
- var SearchClient = class {
9224
+ var ScriptsClient = class {
9130
9225
  constructor(options) {
9131
9226
  this._options = normalizeClientOptionsWithAuth(options);
9132
9227
  }
9133
9228
  /**
9134
- * 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.
9229
+ * 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.
9135
9230
  *
9136
- * @param {Vectros.SearchRequest} request
9137
- * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
9231
+ * **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.
9232
+ *
9233
+ * **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.
9234
+ *
9235
+ * **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`).
9236
+ *
9237
+ * **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 show a row it created — you hold that row's id from `create()`.
9238
+ *
9239
+ * **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.
9240
+ *
9241
+ * @param {Vectros.ScriptExecuteRequest} request
9242
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9138
9243
  *
9139
9244
  * @throws {@link Vectros.BadRequestError}
9245
+ * @throws {@link Vectros.PaymentRequiredError}
9140
9246
  * @throws {@link Vectros.ForbiddenError}
9247
+ * @throws {@link Vectros.NotFoundError}
9248
+ * @throws {@link Vectros.ConflictError}
9249
+ * @throws {@link Vectros.ContentTooLargeError}
9250
+ * @throws {@link Vectros.UnprocessableEntityError}
9141
9251
  * @throws {@link Vectros.TooManyRequestsError}
9252
+ * @throws {@link Vectros.InternalServerError}
9253
+ * @throws {@link Vectros.ServiceUnavailableError}
9254
+ * @throws {@link Vectros.GatewayTimeoutError}
9142
9255
  *
9143
9256
  * @example
9144
- * await client.search.content({
9145
- * query: "patient intake form diabetes"
9257
+ * await client.scripts.executeScript({
9258
+ * "Idempotency-Key": "order-8412-attempt",
9259
+ * scriptRef: {
9260
+ * name: "notify-assignee",
9261
+ * version: "3"
9262
+ * }
9146
9263
  * })
9147
9264
  */
9148
- content(request, requestOptions) {
9149
- return HttpResponsePromise.fromPromise(this.__content(request, requestOptions));
9265
+ executeScript(request, requestOptions) {
9266
+ return HttpResponsePromise.fromPromise(this.__executeScript(request, requestOptions));
9150
9267
  }
9151
- async __content(request, requestOptions) {
9268
+ async __executeScript(request, requestOptions) {
9269
+ const { "Idempotency-Key": idempotencyKey, ..._body } = request;
9152
9270
  const _authRequest = await this._options.authProvider.getAuthRequest();
9153
9271
  const _headers = mergeHeaders(
9154
9272
  _authRequest.headers,
9155
9273
  this._options?.headers,
9274
+ mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey }),
9156
9275
  requestOptions?.headers
9157
9276
  );
9158
9277
  const _response = await fetcher({
9159
9278
  url: url_exports.join(
9160
9279
  await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9161
- "v1/search"
9280
+ "v1/scripts/execute"
9162
9281
  ),
9163
9282
  method: "POST",
9164
9283
  headers: _headers,
9165
9284
  contentType: "application/json",
9166
9285
  queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9167
9286
  requestType: "json",
9168
- body: request,
9287
+ body: _body,
9169
9288
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9170
9289
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9171
9290
  abortSignal: requestOptions?.abortSignal,
@@ -9179,10 +9298,26 @@ var SearchClient = class {
9179
9298
  switch (_response.error.statusCode) {
9180
9299
  case 400:
9181
9300
  throw new BadRequestError(_response.error.body, _response.rawResponse);
9301
+ case 402:
9302
+ throw new PaymentRequiredError(_response.error.body, _response.rawResponse);
9182
9303
  case 403:
9183
9304
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
9305
+ case 404:
9306
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9307
+ case 409:
9308
+ throw new ConflictError(_response.error.body, _response.rawResponse);
9309
+ case 413:
9310
+ throw new ContentTooLargeError(_response.error.body, _response.rawResponse);
9311
+ case 422:
9312
+ throw new UnprocessableEntityError(_response.error.body, _response.rawResponse);
9184
9313
  case 429:
9185
9314
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9315
+ case 500:
9316
+ throw new InternalServerError(_response.error.body, _response.rawResponse);
9317
+ case 503:
9318
+ throw new ServiceUnavailableError(_response.error.body, _response.rawResponse);
9319
+ case 504:
9320
+ throw new GatewayTimeoutError(_response.error.body, _response.rawResponse);
9186
9321
  default:
9187
9322
  throw new VectrosError({
9188
9323
  statusCode: _response.error.statusCode,
@@ -9191,102 +9326,880 @@ var SearchClient = class {
9191
9326
  });
9192
9327
  }
9193
9328
  }
9194
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/search");
9195
- }
9196
- };
9197
- var VectrosClient = class {
9198
- constructor(options) {
9199
- this._options = normalizeClientOptionsWithAuth(options);
9200
- }
9201
- get auth() {
9202
- return this._auth ?? (this._auth = new AuthClient(this._options));
9203
- }
9204
- get documents() {
9205
- return this._documents ?? (this._documents = new DocumentsClient(this._options));
9206
- }
9207
- get identity() {
9208
- return this._identity ?? (this._identity = new IdentityClient(this._options));
9209
- }
9210
- get compliance() {
9211
- return this._compliance ?? (this._compliance = new ComplianceClient(this._options));
9212
- }
9213
- get folders() {
9214
- return this._folders ?? (this._folders = new FoldersClient(this._options));
9215
- }
9216
- get inference() {
9217
- return this._inference ?? (this._inference = new InferenceClient(this._options));
9218
- }
9219
- get records() {
9220
- return this._records ?? (this._records = new RecordsClient(this._options));
9221
- }
9222
- get schemas() {
9223
- return this._schemas ?? (this._schemas = new SchemasClient(this._options));
9224
- }
9225
- get search() {
9226
- return this._search ?? (this._search = new SearchClient(this._options));
9329
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/scripts/execute");
9227
9330
  }
9228
9331
  /**
9229
- * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
9230
- * This is useful for making requests to endpoints not yet supported in the SDK.
9231
- * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
9332
+ * 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. **Each row's `source` is omitted by default** (`sourceOmitted: true`) — scripts are immutable per version, so a name's version history can otherwise carry every version's complete source in one response. Pass `?includeSource=true` to get it back inline, or fetch one version's full source with a by-id GET. **`?name=<n>&latest=true`** answers "what is the current version of this name" in one bounded call — a single `ScriptResponse` object (not a page), instead of draining every page of the name's version history to find the newest yourself.
9232
9333
  *
9233
- * @param {Request | string | URL} input - The URL, path, or Request object.
9234
- * @param {RequestInit} init - Standard fetch RequestInit options.
9235
- * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
9236
- * @returns {Promise<Response>} A standard Response object.
9334
+ * @param {Vectros.ListScriptsRequest} request
9335
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9336
+ *
9337
+ * @throws {@link Vectros.BadRequestError}
9338
+ * @throws {@link Vectros.NotFoundError}
9339
+ *
9340
+ * @example
9341
+ * await client.scripts.listScripts({
9342
+ * name: "notify-assignee",
9343
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9344
+ * })
9237
9345
  */
9238
- async fetch(input, init, requestOptions) {
9239
- return makePassthroughRequest(
9240
- input,
9241
- init,
9242
- {
9243
- baseUrl: this._options.baseUrl ?? this._options.environment,
9244
- headers: this._options.headers,
9245
- timeoutInSeconds: this._options.timeoutInSeconds,
9246
- maxRetries: this._options.maxRetries,
9247
- fetch: this._options.fetch,
9248
- logging: this._options.logging,
9249
- getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers
9250
- },
9251
- requestOptions
9252
- );
9253
- }
9254
- };
9255
- var logging;
9256
- ((logging2) => {
9257
- logging2.LogLevel = LogLevel;
9258
- logging2.ConsoleLogger = ConsoleLogger;
9259
- })(logging || (logging = {}));
9260
-
9261
- // src/server.ts
9262
- var import_types3 = require("@modelcontextprotocol/sdk/types.js");
9263
- var import_zod23 = require("zod");
9264
-
9265
- // src/auth.ts
9266
- var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
9267
- var InvalidApiKeyError = class extends Error {
9268
- constructor(reason) {
9269
- super(`Invalid VECTROS_API_KEY: ${reason}`);
9270
- this.name = "InvalidApiKeyError";
9346
+ listScripts(request = {}, requestOptions) {
9347
+ return HttpResponsePromise.fromPromise(this.__listScripts(request, requestOptions));
9271
9348
  }
9272
- };
9273
- function parseApiKey(raw) {
9274
- if (!raw || raw.trim().length === 0) {
9275
- throw new InvalidApiKeyError(
9276
- "env var is missing or empty. Set VECTROS_API_KEY to a Vectros key (recommended: ssk_live_... or ssk_test_...)."
9349
+ async __listScripts(request = {}, requestOptions) {
9350
+ const { name, startFrom, limit, includeSource, latest } = request;
9351
+ const _queryParams = {
9352
+ name,
9353
+ startFrom,
9354
+ limit,
9355
+ includeSource,
9356
+ latest
9357
+ };
9358
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9359
+ const _headers = mergeHeaders(
9360
+ _authRequest.headers,
9361
+ this._options?.headers,
9362
+ requestOptions?.headers
9277
9363
  );
9364
+ const _response = await fetcher({
9365
+ url: url_exports.join(
9366
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9367
+ "v1/scripts"
9368
+ ),
9369
+ method: "GET",
9370
+ headers: _headers,
9371
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9372
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9373
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9374
+ abortSignal: requestOptions?.abortSignal,
9375
+ fetchFn: this._options?.fetch,
9376
+ logging: this._options.logging
9377
+ });
9378
+ if (_response.ok) {
9379
+ return { data: _response.body, rawResponse: _response.rawResponse };
9380
+ }
9381
+ if (_response.error.reason === "status-code") {
9382
+ switch (_response.error.statusCode) {
9383
+ case 400:
9384
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9385
+ case 404:
9386
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9387
+ default:
9388
+ throw new VectrosError({
9389
+ statusCode: _response.error.statusCode,
9390
+ body: _response.error.body,
9391
+ rawResponse: _response.rawResponse
9392
+ });
9393
+ }
9394
+ }
9395
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/scripts");
9278
9396
  }
9279
- const match = raw.match(KEY_RE);
9280
- if (!match) {
9281
- throw new InvalidApiKeyError(
9282
- `key must start with sk_, ssk_, or st_ followed by "live_" or "test_". Got prefix "${raw.slice(0, 12)}...".`
9283
- );
9397
+ /**
9398
+ * 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. `provisionedBy` MAY BE SET ON ABSENT, NEVER CHANGED, evaluated against the CURRENT LATEST version of this `name` at push time: if the latest version has no marker recorded, this push may set any value; if the latest version already has one, an omitted value inherits it forward and a DIFFERENT value is refused — a live comparison against whichever version is newest at push time, not a value fixed for the name's whole history. Pushing onto an EXISTING name with no `provisionedBy` recorded on its current latest version additionally requires that you were the caller who pushed that latest version — a name carrying a `provisionedBy` marker is exempt from this check (proving you can supply or inherit the matching marker is itself the ownership proof there). Requires the `scripts:c` scope.
9399
+ *
9400
+ * @param {Vectros.ScriptRequest} request
9401
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9402
+ *
9403
+ * @throws {@link Vectros.BadRequestError}
9404
+ * @throws {@link Vectros.ForbiddenError}
9405
+ * @throws {@link Vectros.ConflictError}
9406
+ * @throws {@link Vectros.TooManyRequestsError}
9407
+ *
9408
+ * @example
9409
+ * await client.scripts.createScript({
9410
+ * name: "notify-assignee",
9411
+ * source: "export default function(input) { return { ok: true }; }"
9412
+ * })
9413
+ */
9414
+ createScript(request, requestOptions) {
9415
+ return HttpResponsePromise.fromPromise(this.__createScript(request, requestOptions));
9284
9416
  }
9285
- return {
9286
- prefix: match[1],
9287
- env: match[2],
9288
- raw
9289
- };
9417
+ async __createScript(request, requestOptions) {
9418
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9419
+ const _headers = mergeHeaders(
9420
+ _authRequest.headers,
9421
+ this._options?.headers,
9422
+ requestOptions?.headers
9423
+ );
9424
+ const _response = await fetcher({
9425
+ url: url_exports.join(
9426
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9427
+ "v1/scripts"
9428
+ ),
9429
+ method: "POST",
9430
+ headers: _headers,
9431
+ contentType: "application/json",
9432
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9433
+ requestType: "json",
9434
+ body: request,
9435
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9436
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9437
+ abortSignal: requestOptions?.abortSignal,
9438
+ fetchFn: this._options?.fetch,
9439
+ logging: this._options.logging
9440
+ });
9441
+ if (_response.ok) {
9442
+ return { data: _response.body, rawResponse: _response.rawResponse };
9443
+ }
9444
+ if (_response.error.reason === "status-code") {
9445
+ switch (_response.error.statusCode) {
9446
+ case 400:
9447
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9448
+ case 403:
9449
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9450
+ case 409:
9451
+ throw new ConflictError(_response.error.body, _response.rawResponse);
9452
+ case 429:
9453
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9454
+ default:
9455
+ throw new VectrosError({
9456
+ statusCode: _response.error.statusCode,
9457
+ body: _response.error.body,
9458
+ rawResponse: _response.rawResponse
9459
+ });
9460
+ }
9461
+ }
9462
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/scripts");
9463
+ }
9464
+ /**
9465
+ * Retrieves a single script version by its ID. Requires the `scripts:r` scope.
9466
+ *
9467
+ * @param {Vectros.GetScriptRequest} request
9468
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9469
+ *
9470
+ * @throws {@link Vectros.NotFoundError}
9471
+ *
9472
+ * @example
9473
+ * await client.scripts.getScript({
9474
+ * id: "id"
9475
+ * })
9476
+ */
9477
+ getScript(request, requestOptions) {
9478
+ return HttpResponsePromise.fromPromise(this.__getScript(request, requestOptions));
9479
+ }
9480
+ async __getScript(request, requestOptions) {
9481
+ const { id } = request;
9482
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9483
+ const _headers = mergeHeaders(
9484
+ _authRequest.headers,
9485
+ this._options?.headers,
9486
+ requestOptions?.headers
9487
+ );
9488
+ const _response = await fetcher({
9489
+ url: url_exports.join(
9490
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9491
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9492
+ ),
9493
+ method: "GET",
9494
+ headers: _headers,
9495
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9496
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9497
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9498
+ abortSignal: requestOptions?.abortSignal,
9499
+ fetchFn: this._options?.fetch,
9500
+ logging: this._options.logging
9501
+ });
9502
+ if (_response.ok) {
9503
+ return { data: _response.body, rawResponse: _response.rawResponse };
9504
+ }
9505
+ if (_response.error.reason === "status-code") {
9506
+ switch (_response.error.statusCode) {
9507
+ case 404:
9508
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9509
+ default:
9510
+ throw new VectrosError({
9511
+ statusCode: _response.error.statusCode,
9512
+ body: _response.error.body,
9513
+ rawResponse: _response.rawResponse
9514
+ });
9515
+ }
9516
+ }
9517
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/scripts/{id}");
9518
+ }
9519
+ /**
9520
+ * 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.
9521
+ *
9522
+ * @param {Vectros.UpdateScriptRequest} request
9523
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9524
+ *
9525
+ * @throws {@link Vectros.BadRequestError}
9526
+ * @throws {@link Vectros.TooManyRequestsError}
9527
+ *
9528
+ * @example
9529
+ * await client.scripts.updateScript({
9530
+ * id: "id",
9531
+ * body: {
9532
+ * name: "notify-assignee",
9533
+ * source: "export default function(input) { return { ok: true }; }"
9534
+ * }
9535
+ * })
9536
+ */
9537
+ updateScript(request, requestOptions) {
9538
+ return HttpResponsePromise.fromPromise(this.__updateScript(request, requestOptions));
9539
+ }
9540
+ async __updateScript(request, requestOptions) {
9541
+ const { id, body: _body } = request;
9542
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9543
+ const _headers = mergeHeaders(
9544
+ _authRequest.headers,
9545
+ this._options?.headers,
9546
+ requestOptions?.headers
9547
+ );
9548
+ const _response = await fetcher({
9549
+ url: url_exports.join(
9550
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9551
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9552
+ ),
9553
+ method: "PUT",
9554
+ headers: _headers,
9555
+ contentType: "application/json",
9556
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9557
+ requestType: "json",
9558
+ body: _body,
9559
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9560
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9561
+ abortSignal: requestOptions?.abortSignal,
9562
+ fetchFn: this._options?.fetch,
9563
+ logging: this._options.logging
9564
+ });
9565
+ if (_response.ok) {
9566
+ return { data: void 0, rawResponse: _response.rawResponse };
9567
+ }
9568
+ if (_response.error.reason === "status-code") {
9569
+ switch (_response.error.statusCode) {
9570
+ case 400:
9571
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9572
+ case 429:
9573
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9574
+ default:
9575
+ throw new VectrosError({
9576
+ statusCode: _response.error.statusCode,
9577
+ body: _response.error.body,
9578
+ rawResponse: _response.rawResponse
9579
+ });
9580
+ }
9581
+ }
9582
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/scripts/{id}");
9583
+ }
9584
+ /**
9585
+ * 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. Refused with 409 if a live trigger rule still references this version — either directly (a pinned `scriptRef`), or via `"latest"` when this IS the newest version of its name. Delete or re-point those rules first.
9586
+ *
9587
+ * @param {Vectros.DeleteScriptRequest} request
9588
+ * @param {ScriptsClient.RequestOptions} requestOptions - Request-specific configuration.
9589
+ *
9590
+ * @throws {@link Vectros.NotFoundError}
9591
+ * @throws {@link Vectros.ConflictError}
9592
+ * @throws {@link Vectros.TooManyRequestsError}
9593
+ *
9594
+ * @example
9595
+ * await client.scripts.deleteScript({
9596
+ * id: "id"
9597
+ * })
9598
+ */
9599
+ deleteScript(request, requestOptions) {
9600
+ return HttpResponsePromise.fromPromise(this.__deleteScript(request, requestOptions));
9601
+ }
9602
+ async __deleteScript(request, requestOptions) {
9603
+ const { id } = request;
9604
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9605
+ const _headers = mergeHeaders(
9606
+ _authRequest.headers,
9607
+ this._options?.headers,
9608
+ requestOptions?.headers
9609
+ );
9610
+ const _response = await fetcher({
9611
+ url: url_exports.join(
9612
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9613
+ `v1/scripts/${url_exports.encodePathParam(id)}`
9614
+ ),
9615
+ method: "DELETE",
9616
+ headers: _headers,
9617
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9618
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9619
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9620
+ abortSignal: requestOptions?.abortSignal,
9621
+ fetchFn: this._options?.fetch,
9622
+ logging: this._options.logging
9623
+ });
9624
+ if (_response.ok) {
9625
+ return { data: void 0, rawResponse: _response.rawResponse };
9626
+ }
9627
+ if (_response.error.reason === "status-code") {
9628
+ switch (_response.error.statusCode) {
9629
+ case 404:
9630
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9631
+ case 409:
9632
+ throw new ConflictError(_response.error.body, _response.rawResponse);
9633
+ case 429:
9634
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9635
+ default:
9636
+ throw new VectrosError({
9637
+ statusCode: _response.error.statusCode,
9638
+ body: _response.error.body,
9639
+ rawResponse: _response.rawResponse
9640
+ });
9641
+ }
9642
+ }
9643
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/scripts/{id}");
9644
+ }
9645
+ };
9646
+ var SearchClient = class {
9647
+ constructor(options) {
9648
+ this._options = normalizeClientOptionsWithAuth(options);
9649
+ }
9650
+ /**
9651
+ * 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.
9652
+ *
9653
+ * @param {Vectros.SearchRequest} request
9654
+ * @param {SearchClient.RequestOptions} requestOptions - Request-specific configuration.
9655
+ *
9656
+ * @throws {@link Vectros.BadRequestError}
9657
+ * @throws {@link Vectros.ForbiddenError}
9658
+ * @throws {@link Vectros.TooManyRequestsError}
9659
+ *
9660
+ * @example
9661
+ * await client.search.content({
9662
+ * query: "patient intake form diabetes"
9663
+ * })
9664
+ */
9665
+ content(request, requestOptions) {
9666
+ return HttpResponsePromise.fromPromise(this.__content(request, requestOptions));
9667
+ }
9668
+ async __content(request, requestOptions) {
9669
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9670
+ const _headers = mergeHeaders(
9671
+ _authRequest.headers,
9672
+ this._options?.headers,
9673
+ requestOptions?.headers
9674
+ );
9675
+ const _response = await fetcher({
9676
+ url: url_exports.join(
9677
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9678
+ "v1/search"
9679
+ ),
9680
+ method: "POST",
9681
+ headers: _headers,
9682
+ contentType: "application/json",
9683
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9684
+ requestType: "json",
9685
+ body: request,
9686
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9687
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9688
+ abortSignal: requestOptions?.abortSignal,
9689
+ fetchFn: this._options?.fetch,
9690
+ logging: this._options.logging
9691
+ });
9692
+ if (_response.ok) {
9693
+ return { data: _response.body, rawResponse: _response.rawResponse };
9694
+ }
9695
+ if (_response.error.reason === "status-code") {
9696
+ switch (_response.error.statusCode) {
9697
+ case 400:
9698
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9699
+ case 403:
9700
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9701
+ case 429:
9702
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9703
+ default:
9704
+ throw new VectrosError({
9705
+ statusCode: _response.error.statusCode,
9706
+ body: _response.error.body,
9707
+ rawResponse: _response.rawResponse
9708
+ });
9709
+ }
9710
+ }
9711
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/search");
9712
+ }
9713
+ };
9714
+ var TriggersClient = class {
9715
+ constructor(options) {
9716
+ this._options = normalizeClientOptionsWithAuth(options);
9717
+ }
9718
+ /**
9719
+ * 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.
9720
+ *
9721
+ * 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.
9722
+ *
9723
+ * `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.
9724
+ *
9725
+ * Scoped to your account and app context, derived from your token — never from input. Requires the `triggers:r` scope.
9726
+ *
9727
+ * @param {Vectros.ListTriggerFailuresRequest} request
9728
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9729
+ *
9730
+ * @example
9731
+ * await client.triggers.listTriggerFailures({
9732
+ * ruleId: "3b1c9f2e7a5d8410f6c2e9a1b7d4038f5e6a91c2d7f0b3a4586c9e2f1d0a7b3c",
9733
+ * category: "SCRIPT_ERROR",
9734
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9735
+ * })
9736
+ */
9737
+ listTriggerFailures(request = {}, requestOptions) {
9738
+ return HttpResponsePromise.fromPromise(this.__listTriggerFailures(request, requestOptions));
9739
+ }
9740
+ async __listTriggerFailures(request = {}, requestOptions) {
9741
+ const { ruleId, category, retryable, from: from_, to, startFrom, limit } = request;
9742
+ const _queryParams = {
9743
+ ruleId,
9744
+ category,
9745
+ retryable,
9746
+ from: from_,
9747
+ to,
9748
+ startFrom,
9749
+ limit
9750
+ };
9751
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9752
+ const _headers = mergeHeaders(
9753
+ _authRequest.headers,
9754
+ this._options?.headers,
9755
+ requestOptions?.headers
9756
+ );
9757
+ const _response = await fetcher({
9758
+ url: url_exports.join(
9759
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9760
+ "v1/trigger-failures"
9761
+ ),
9762
+ method: "GET",
9763
+ headers: _headers,
9764
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9765
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9766
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9767
+ abortSignal: requestOptions?.abortSignal,
9768
+ fetchFn: this._options?.fetch,
9769
+ logging: this._options.logging
9770
+ });
9771
+ if (_response.ok) {
9772
+ return { data: _response.body, rawResponse: _response.rawResponse };
9773
+ }
9774
+ if (_response.error.reason === "status-code") {
9775
+ throw new VectrosError({
9776
+ statusCode: _response.error.statusCode,
9777
+ body: _response.error.body,
9778
+ rawResponse: _response.rawResponse
9779
+ });
9780
+ }
9781
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/trigger-failures");
9782
+ }
9783
+ /**
9784
+ * 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.
9785
+ *
9786
+ * @param {Vectros.ListTriggersRequest} request
9787
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9788
+ *
9789
+ * @example
9790
+ * await client.triggers.listTriggers({
9791
+ * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
9792
+ * })
9793
+ */
9794
+ listTriggers(request = {}, requestOptions) {
9795
+ return HttpResponsePromise.fromPromise(this.__listTriggers(request, requestOptions));
9796
+ }
9797
+ async __listTriggers(request = {}, requestOptions) {
9798
+ const { startFrom, limit } = request;
9799
+ const _queryParams = {
9800
+ startFrom,
9801
+ limit
9802
+ };
9803
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9804
+ const _headers = mergeHeaders(
9805
+ _authRequest.headers,
9806
+ this._options?.headers,
9807
+ requestOptions?.headers
9808
+ );
9809
+ const _response = await fetcher({
9810
+ url: url_exports.join(
9811
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9812
+ "v1/triggers"
9813
+ ),
9814
+ method: "GET",
9815
+ headers: _headers,
9816
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9817
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9818
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9819
+ abortSignal: requestOptions?.abortSignal,
9820
+ fetchFn: this._options?.fetch,
9821
+ logging: this._options.logging
9822
+ });
9823
+ if (_response.ok) {
9824
+ return { data: _response.body, rawResponse: _response.rawResponse };
9825
+ }
9826
+ if (_response.error.reason === "status-code") {
9827
+ throw new VectrosError({
9828
+ statusCode: _response.error.statusCode,
9829
+ body: _response.error.body,
9830
+ rawResponse: _response.rawResponse
9831
+ });
9832
+ }
9833
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/triggers");
9834
+ }
9835
+ /**
9836
+ * 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).
9837
+ *
9838
+ * @param {Vectros.CreateTriggerRequest} request
9839
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9840
+ *
9841
+ * @throws {@link Vectros.BadRequestError}
9842
+ * @throws {@link Vectros.ForbiddenError}
9843
+ * @throws {@link Vectros.TooManyRequestsError}
9844
+ *
9845
+ * @example
9846
+ * await client.triggers.createTrigger({
9847
+ * body: {
9848
+ * name: "on-intake-create",
9849
+ * firingSource: {
9850
+ * schemaId: "sch_9f8e7d6c",
9851
+ * event: "CREATE"
9852
+ * },
9853
+ * scriptRef: {
9854
+ * name: "notify-assignee",
9855
+ * version: "3"
9856
+ * }
9857
+ * }
9858
+ * })
9859
+ */
9860
+ createTrigger(request, requestOptions) {
9861
+ return HttpResponsePromise.fromPromise(this.__createTrigger(request, requestOptions));
9862
+ }
9863
+ async __createTrigger(request, requestOptions) {
9864
+ const { upsert, body: _body } = request;
9865
+ const _queryParams = {
9866
+ upsert
9867
+ };
9868
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9869
+ const _headers = mergeHeaders(
9870
+ _authRequest.headers,
9871
+ this._options?.headers,
9872
+ requestOptions?.headers
9873
+ );
9874
+ const _response = await fetcher({
9875
+ url: url_exports.join(
9876
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9877
+ "v1/triggers"
9878
+ ),
9879
+ method: "POST",
9880
+ headers: _headers,
9881
+ contentType: "application/json",
9882
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
9883
+ requestType: "json",
9884
+ body: _body,
9885
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9886
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9887
+ abortSignal: requestOptions?.abortSignal,
9888
+ fetchFn: this._options?.fetch,
9889
+ logging: this._options.logging
9890
+ });
9891
+ if (_response.ok) {
9892
+ return { data: _response.body, rawResponse: _response.rawResponse };
9893
+ }
9894
+ if (_response.error.reason === "status-code") {
9895
+ switch (_response.error.statusCode) {
9896
+ case 400:
9897
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
9898
+ case 403:
9899
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
9900
+ case 429:
9901
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
9902
+ default:
9903
+ throw new VectrosError({
9904
+ statusCode: _response.error.statusCode,
9905
+ body: _response.error.body,
9906
+ rawResponse: _response.rawResponse
9907
+ });
9908
+ }
9909
+ }
9910
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/triggers");
9911
+ }
9912
+ /**
9913
+ * Retrieves a single trigger rule by its ID. Requires the `triggers:r` scope.
9914
+ *
9915
+ * @param {Vectros.GetTriggerRequest} request
9916
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9917
+ *
9918
+ * @throws {@link Vectros.NotFoundError}
9919
+ *
9920
+ * @example
9921
+ * await client.triggers.getTrigger({
9922
+ * id: "id"
9923
+ * })
9924
+ */
9925
+ getTrigger(request, requestOptions) {
9926
+ return HttpResponsePromise.fromPromise(this.__getTrigger(request, requestOptions));
9927
+ }
9928
+ async __getTrigger(request, requestOptions) {
9929
+ const { id } = request;
9930
+ const _authRequest = await this._options.authProvider.getAuthRequest();
9931
+ const _headers = mergeHeaders(
9932
+ _authRequest.headers,
9933
+ this._options?.headers,
9934
+ requestOptions?.headers
9935
+ );
9936
+ const _response = await fetcher({
9937
+ url: url_exports.join(
9938
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
9939
+ `v1/triggers/${url_exports.encodePathParam(id)}`
9940
+ ),
9941
+ method: "GET",
9942
+ headers: _headers,
9943
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
9944
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
9945
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
9946
+ abortSignal: requestOptions?.abortSignal,
9947
+ fetchFn: this._options?.fetch,
9948
+ logging: this._options.logging
9949
+ });
9950
+ if (_response.ok) {
9951
+ return { data: _response.body, rawResponse: _response.rawResponse };
9952
+ }
9953
+ if (_response.error.reason === "status-code") {
9954
+ switch (_response.error.statusCode) {
9955
+ case 404:
9956
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
9957
+ default:
9958
+ throw new VectrosError({
9959
+ statusCode: _response.error.statusCode,
9960
+ body: _response.error.body,
9961
+ rawResponse: _response.rawResponse
9962
+ });
9963
+ }
9964
+ }
9965
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/triggers/{id}");
9966
+ }
9967
+ /**
9968
+ * 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.
9969
+ *
9970
+ * @param {Vectros.UpdateTriggerRequest} request
9971
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
9972
+ *
9973
+ * @throws {@link Vectros.BadRequestError}
9974
+ * @throws {@link Vectros.ForbiddenError}
9975
+ * @throws {@link Vectros.NotFoundError}
9976
+ * @throws {@link Vectros.TooManyRequestsError}
9977
+ *
9978
+ * @example
9979
+ * await client.triggers.updateTrigger({
9980
+ * id: "id",
9981
+ * body: {
9982
+ * name: "on-intake-create",
9983
+ * firingSource: {
9984
+ * schemaId: "sch_9f8e7d6c",
9985
+ * event: "CREATE"
9986
+ * },
9987
+ * scriptRef: {
9988
+ * name: "notify-assignee",
9989
+ * version: "3"
9990
+ * }
9991
+ * }
9992
+ * })
9993
+ */
9994
+ updateTrigger(request, requestOptions) {
9995
+ return HttpResponsePromise.fromPromise(this.__updateTrigger(request, requestOptions));
9996
+ }
9997
+ async __updateTrigger(request, requestOptions) {
9998
+ const { id, body: _body } = request;
9999
+ const _authRequest = await this._options.authProvider.getAuthRequest();
10000
+ const _headers = mergeHeaders(
10001
+ _authRequest.headers,
10002
+ this._options?.headers,
10003
+ requestOptions?.headers
10004
+ );
10005
+ const _response = await fetcher({
10006
+ url: url_exports.join(
10007
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
10008
+ `v1/triggers/${url_exports.encodePathParam(id)}`
10009
+ ),
10010
+ method: "PUT",
10011
+ headers: _headers,
10012
+ contentType: "application/json",
10013
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
10014
+ requestType: "json",
10015
+ body: _body,
10016
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
10017
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
10018
+ abortSignal: requestOptions?.abortSignal,
10019
+ fetchFn: this._options?.fetch,
10020
+ logging: this._options.logging
10021
+ });
10022
+ if (_response.ok) {
10023
+ return { data: _response.body, rawResponse: _response.rawResponse };
10024
+ }
10025
+ if (_response.error.reason === "status-code") {
10026
+ switch (_response.error.statusCode) {
10027
+ case 400:
10028
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
10029
+ case 403:
10030
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
10031
+ case 404:
10032
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
10033
+ case 429:
10034
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
10035
+ default:
10036
+ throw new VectrosError({
10037
+ statusCode: _response.error.statusCode,
10038
+ body: _response.error.body,
10039
+ rawResponse: _response.rawResponse
10040
+ });
10041
+ }
10042
+ }
10043
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/triggers/{id}");
10044
+ }
10045
+ /**
10046
+ * Permanently deletes one trigger rule by ID. Requires the `triggers:d` scope.
10047
+ *
10048
+ * @param {Vectros.DeleteTriggerRequest} request
10049
+ * @param {TriggersClient.RequestOptions} requestOptions - Request-specific configuration.
10050
+ *
10051
+ * @throws {@link Vectros.NotFoundError}
10052
+ * @throws {@link Vectros.TooManyRequestsError}
10053
+ *
10054
+ * @example
10055
+ * await client.triggers.deleteTrigger({
10056
+ * id: "id"
10057
+ * })
10058
+ */
10059
+ deleteTrigger(request, requestOptions) {
10060
+ return HttpResponsePromise.fromPromise(this.__deleteTrigger(request, requestOptions));
10061
+ }
10062
+ async __deleteTrigger(request, requestOptions) {
10063
+ const { id } = request;
10064
+ const _authRequest = await this._options.authProvider.getAuthRequest();
10065
+ const _headers = mergeHeaders(
10066
+ _authRequest.headers,
10067
+ this._options?.headers,
10068
+ requestOptions?.headers
10069
+ );
10070
+ const _response = await fetcher({
10071
+ url: url_exports.join(
10072
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
10073
+ `v1/triggers/${url_exports.encodePathParam(id)}`
10074
+ ),
10075
+ method: "DELETE",
10076
+ headers: _headers,
10077
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
10078
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
10079
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
10080
+ abortSignal: requestOptions?.abortSignal,
10081
+ fetchFn: this._options?.fetch,
10082
+ logging: this._options.logging
10083
+ });
10084
+ if (_response.ok) {
10085
+ return { data: void 0, rawResponse: _response.rawResponse };
10086
+ }
10087
+ if (_response.error.reason === "status-code") {
10088
+ switch (_response.error.statusCode) {
10089
+ case 404:
10090
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
10091
+ case 429:
10092
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
10093
+ default:
10094
+ throw new VectrosError({
10095
+ statusCode: _response.error.statusCode,
10096
+ body: _response.error.body,
10097
+ rawResponse: _response.rawResponse
10098
+ });
10099
+ }
10100
+ }
10101
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/triggers/{id}");
10102
+ }
10103
+ };
10104
+ var VectrosClient = class {
10105
+ constructor(options) {
10106
+ this._options = normalizeClientOptionsWithAuth(options);
10107
+ }
10108
+ get auth() {
10109
+ return this._auth ?? (this._auth = new AuthClient(this._options));
10110
+ }
10111
+ get documents() {
10112
+ return this._documents ?? (this._documents = new DocumentsClient(this._options));
10113
+ }
10114
+ get identity() {
10115
+ return this._identity ?? (this._identity = new IdentityClient(this._options));
10116
+ }
10117
+ get compliance() {
10118
+ return this._compliance ?? (this._compliance = new ComplianceClient(this._options));
10119
+ }
10120
+ get folders() {
10121
+ return this._folders ?? (this._folders = new FoldersClient(this._options));
10122
+ }
10123
+ get inference() {
10124
+ return this._inference ?? (this._inference = new InferenceClient(this._options));
10125
+ }
10126
+ get records() {
10127
+ return this._records ?? (this._records = new RecordsClient(this._options));
10128
+ }
10129
+ get schemas() {
10130
+ return this._schemas ?? (this._schemas = new SchemasClient(this._options));
10131
+ }
10132
+ get scripts() {
10133
+ return this._scripts ?? (this._scripts = new ScriptsClient(this._options));
10134
+ }
10135
+ get search() {
10136
+ return this._search ?? (this._search = new SearchClient(this._options));
10137
+ }
10138
+ get triggers() {
10139
+ return this._triggers ?? (this._triggers = new TriggersClient(this._options));
10140
+ }
10141
+ /**
10142
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
10143
+ * This is useful for making requests to endpoints not yet supported in the SDK.
10144
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
10145
+ *
10146
+ * @param {Request | string | URL} input - The URL, path, or Request object.
10147
+ * @param {RequestInit} init - Standard fetch RequestInit options.
10148
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
10149
+ * @returns {Promise<Response>} A standard Response object.
10150
+ */
10151
+ async fetch(input, init, requestOptions) {
10152
+ return makePassthroughRequest(
10153
+ input,
10154
+ init,
10155
+ {
10156
+ baseUrl: this._options.baseUrl ?? this._options.environment,
10157
+ headers: this._options.headers,
10158
+ timeoutInSeconds: this._options.timeoutInSeconds,
10159
+ maxRetries: this._options.maxRetries,
10160
+ fetch: this._options.fetch,
10161
+ logging: this._options.logging,
10162
+ getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers
10163
+ },
10164
+ requestOptions
10165
+ );
10166
+ }
10167
+ };
10168
+ var logging;
10169
+ ((logging2) => {
10170
+ logging2.LogLevel = LogLevel;
10171
+ logging2.ConsoleLogger = ConsoleLogger;
10172
+ })(logging || (logging = {}));
10173
+
10174
+ // src/server.ts
10175
+ var import_types3 = require("@modelcontextprotocol/sdk/types.js");
10176
+ var import_zod24 = require("zod");
10177
+
10178
+ // src/auth.ts
10179
+ var KEY_RE = /^(sk|ssk|st)_(live|test)_/;
10180
+ var InvalidApiKeyError = class extends Error {
10181
+ constructor(reason) {
10182
+ super(`Invalid VECTROS_API_KEY: ${reason}`);
10183
+ this.name = "InvalidApiKeyError";
10184
+ }
10185
+ };
10186
+ function parseApiKey(raw) {
10187
+ if (!raw || raw.trim().length === 0) {
10188
+ throw new InvalidApiKeyError(
10189
+ "env var is missing or empty. Set VECTROS_API_KEY to a Vectros key (recommended: ssk_live_... or ssk_test_...)."
10190
+ );
10191
+ }
10192
+ const match = raw.match(KEY_RE);
10193
+ if (!match) {
10194
+ throw new InvalidApiKeyError(
10195
+ `key must start with sk_, ssk_, or st_ followed by "live_" or "test_". Got prefix "${raw.slice(0, 12)}...".`
10196
+ );
10197
+ }
10198
+ return {
10199
+ prefix: match[1],
10200
+ env: match[2],
10201
+ raw
10202
+ };
9290
10203
  }
9291
10204
  function warnOnSuboptimalKey(key, log) {
9292
10205
  if (key.prefix === "sk") {
@@ -9304,8 +10217,8 @@ function warnOnSuboptimalKey(key, log) {
9304
10217
 
9305
10218
  // src/build-info.ts
9306
10219
  var BUILD_INFO = {
9307
- mcpServer: true ? "0.16.1" : "dev",
9308
- sdk: true ? "0.42.0" : "dev"
10220
+ mcpServer: true ? "0.17.1" : "dev",
10221
+ sdk: true ? "0.44.0" : "dev"
9309
10222
  };
9310
10223
 
9311
10224
  // src/log.ts
@@ -9613,11 +10526,18 @@ var inputSchema = {
9613
10526
  // Ownership.
9614
10527
  userId: import_zod.z.string().optional().describe("Restrict to content owned by this user (Vectros UUID)."),
9615
10528
  scope: import_zod.z.string().optional().describe(
9616
- '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.'
10529
+ '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.'
10530
+ ),
10531
+ scopeFilters: import_zod.z.array(import_zod.z.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
10532
+ '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.'
9617
10533
  ),
9618
10534
  // Date window.
9619
- createdAfter: import_zod.z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
9620
- createdBefore: import_zod.z.string().optional().describe("Restrict to content created at/before this ISO 8601 UTC timestamp."),
10535
+ createdAfter: import_zod.z.string().optional().describe(
10536
+ "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."
10537
+ ),
10538
+ createdBefore: import_zod.z.string().optional().describe(
10539
+ "Restrict to content CREATED at/before this ISO 8601 UTC timestamp \u2014 same creation-time basis, and the same first-index allowance, as createdAfter."
10540
+ ),
9621
10541
  // Relevance tuning.
9622
10542
  minSimilarity: import_zod.z.number().min(0).max(1).optional().describe("Minimum semantic similarity (0.0\u20131.0); results below are excluded."),
9623
10543
  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."),
@@ -9632,11 +10552,21 @@ var inputSchema = {
9632
10552
  var hybridSearch = ({ client, log }) => ({
9633
10553
  name: "hybrid_search",
9634
10554
  title: "Hybrid search",
9635
- 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).',
10555
+ 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).',
9636
10556
  inputSchema,
10557
+ // A pure read — never creates, modifies, or deletes anything server-side.
10558
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
9637
10559
  handler: async (args) => {
9638
10560
  const limit = args.limit ?? MCP_DEFAULT_LIMIT;
9639
10561
  const mode = args.mode ?? "HYBRID";
10562
+ if (args.scope !== void 0 && args.scopeFilters !== void 0) {
10563
+ return toolError(
10564
+ "hybrid_search",
10565
+ new Error(
10566
+ "'scope' and 'scopeFilters' are mutually exclusive \u2014 pass 'scope' for a single ownership dimension, or 'scopeFilters' for more than one, not both."
10567
+ )
10568
+ );
10569
+ }
9640
10570
  try {
9641
10571
  const result = await client.search.content({
9642
10572
  query: args.query,
@@ -9651,6 +10581,7 @@ var hybridSearch = ({ client, log }) => ({
9651
10581
  filters: args.filters,
9652
10582
  userId: args.userId,
9653
10583
  scope: args.scope,
10584
+ scopeFilters: args.scopeFilters,
9654
10585
  createdAfter: args.createdAfter,
9655
10586
  createdBefore: args.createdBefore,
9656
10587
  minSimilarity: args.minSimilarity,
@@ -9729,7 +10660,9 @@ async function drainPages(fetchPage) {
9729
10660
  var MCP_DEFAULT_LIMIT2 = 3;
9730
10661
  var MCP_MAX_LIMIT2 = 100;
9731
10662
  var inputSchema2 = {
9732
- type: import_zod2.z.string().min(1, "type (record type) is required").describe('Record type / schema name (e.g. "patient", "clinical_note").'),
10663
+ type: import_zod2.z.string().min(1, "type must be non-empty when supplied").optional().describe(
10664
+ '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.'
10665
+ ),
9733
10666
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | values | from+to | prefix.
9734
10667
  field: import_zod2.z.string().optional().describe(
9735
10668
  '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.'
@@ -9751,6 +10684,12 @@ var inputSchema2 = {
9751
10684
  "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."
9752
10685
  ),
9753
10686
  // List-mode args:
10687
+ folderId: import_zod2.z.string().optional().describe(
10688
+ "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."
10689
+ ),
10690
+ recent: import_zod2.z.boolean().optional().describe(
10691
+ "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."
10692
+ ),
9754
10693
  userId: import_zod2.z.string().optional().describe("List mode: scope to records owned by this user."),
9755
10694
  scope: import_zod2.z.string().optional().describe(
9756
10695
  '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.'
@@ -9763,11 +10702,15 @@ var inputSchema2 = {
9763
10702
  var recordQuery = ({ client, log }) => ({
9764
10703
  name: "record_query",
9765
10704
  title: "Record query (list or lookup)",
9766
- 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.",
10705
+ 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.",
9767
10706
  inputSchema: inputSchema2,
10707
+ // A pure read — never creates, modifies, or deletes anything server-side.
10708
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
9768
10709
  handler: async (args) => {
9769
10710
  const limit = args.limit ?? MCP_DEFAULT_LIMIT2;
9770
10711
  const type = args.type;
10712
+ const folderId = args.folderId;
10713
+ const recent = args.recent;
9771
10714
  const field = args.field;
9772
10715
  const value = args.value;
9773
10716
  const values = args.values;
@@ -9785,6 +10728,48 @@ var recordQuery = ({ client, log }) => ({
9785
10728
  )
9786
10729
  );
9787
10730
  }
10731
+ if (field && (folderId !== void 0 || recent !== void 0)) {
10732
+ return toolError(
10733
+ "record_query",
10734
+ new Error(
10735
+ "'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."
10736
+ )
10737
+ );
10738
+ }
10739
+ if (field && !type) {
10740
+ return toolError(
10741
+ "record_query",
10742
+ new Error(
10743
+ "a lookup ('field') is always within one record type \u2014 pass 'type'. To read across types, use list mode with 'folderId' or 'recent'."
10744
+ )
10745
+ );
10746
+ }
10747
+ if (!field) {
10748
+ if (recent && (type !== void 0 || folderId !== void 0)) {
10749
+ return toolError(
10750
+ "record_query",
10751
+ new Error(
10752
+ "'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."
10753
+ )
10754
+ );
10755
+ }
10756
+ if (recent && (args.userId !== void 0 || args.scope !== void 0)) {
10757
+ return toolError(
10758
+ "record_query",
10759
+ new Error(
10760
+ "'recent' ignores the owner filters \u2014 'userId'/'scope' would be silently dropped. List by 'type' or 'folderId' to filter by owner."
10761
+ )
10762
+ );
10763
+ }
10764
+ if (!recent && type === void 0 && folderId === void 0) {
10765
+ return toolError(
10766
+ "record_query",
10767
+ new Error(
10768
+ "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."
10769
+ )
10770
+ );
10771
+ }
10772
+ }
9788
10773
  try {
9789
10774
  let page;
9790
10775
  if (field) {
@@ -9848,6 +10833,7 @@ var recordQuery = ({ client, log }) => ({
9848
10833
  }
9849
10834
  }
9850
10835
  page = await client.records.lookupRecordsByBody({
10836
+ // Non-null: the `field && !type` guard above returns before reaching lookup mode.
9851
10837
  type,
9852
10838
  field: normalizedField,
9853
10839
  value,
@@ -9868,13 +10854,22 @@ var recordQuery = ({ client, log }) => ({
9868
10854
  } else {
9869
10855
  page = await client.records.listRecords({
9870
10856
  type,
10857
+ folderId,
10858
+ ...recent ? { recent: "true" } : {},
9871
10859
  userId: args.userId,
9872
10860
  scope: args.scope,
9873
10861
  startFrom,
9874
10862
  limit
9875
10863
  });
9876
10864
  log.debug(
9877
- { tool: "record_query", mode: "list", type, limit, returned: pageItems(page).length },
10865
+ {
10866
+ tool: "record_query",
10867
+ mode: recent ? "list:recent" : folderId ? "list:folder" : "list:type",
10868
+ type,
10869
+ folderId,
10870
+ limit,
10871
+ returned: pageItems(page).length
10872
+ },
9878
10873
  "record_query list ok"
9879
10874
  );
9880
10875
  }
@@ -9956,6 +10951,8 @@ var recordGet = ({ client, log }) => ({
9956
10951
  title: "Get a record by id or externalId",
9957
10952
  description: "Fetch a single structured record, including the full payload. Select it EITHER by its Vectros `id` (e.g. from record_query / hybrid_search) OR by your own `externalId` + `type` \u2014 the same key you passed to record_create, resolved for you (no manual record_query lookup needed). Very large payloads are truncated to protect the agent context window. The response carries the record's processing `indexStatus`; when it is FAILED an `indexFailure.code` explains whether the content is still searchable (e.g. VECTOR_LIMIT_EXCEEDED keeps keyword search vs INDEXING_FAILED = not findable at all) \u2014 branch on the `code`, not the message.",
9958
10953
  inputSchema: inputSchema3,
10954
+ // A pure read — never creates, modifies, or deletes anything server-side.
10955
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
9959
10956
  handler: async (args) => {
9960
10957
  const id = args.id;
9961
10958
  const externalId = args.externalId;
@@ -10001,6 +10998,8 @@ var recordBatchGet = ({ client, log }) => ({
10001
10998
  title: "Get multiple records by id in one call",
10002
10999
  description: "Fetch several structured records by id in a single call (1-100 ids), each with its full payload \u2014 the same hydration record_get gives a single id. Use this instead of N record_get calls when you already hold several ids (e.g. a page of record_query/hybrid_search results). Any id you can't access is silently omitted from `data`; the response also returns `missingIds` \u2014 every requested id not present in `data` \u2014 so you can tell a partial result from a complete one. As with record_get, an oversized payload is truncated into a labelled `payloadPreview` rather than shipped whole.",
10003
11000
  inputSchema: inputSchema4,
11001
+ // A pure read — never creates, modifies, or deletes anything server-side.
11002
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
10004
11003
  handler: async (args) => {
10005
11004
  const ids = args.ids;
10006
11005
  try {
@@ -10051,7 +11050,7 @@ var inputSchema5 = {
10051
11050
  folderId: import_zod5.z.string().optional().describe("Group this record into a folder."),
10052
11051
  userId: import_zod5.z.string().optional().describe("Owning user id."),
10053
11052
  scopes: import_zod5.z.array(import_zod5.z.string()).optional().describe(
10054
- '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.'
11053
+ '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.'
10055
11054
  )
10056
11055
  };
10057
11056
  var recordCreate = ({ client, log }) => ({
@@ -10059,6 +11058,13 @@ var recordCreate = ({ client, log }) => ({
10059
11058
  title: "Create a record",
10060
11059
  description: "Create a structured record of a given type. Provide `type` and `fields` (the payload, validated against the type schema \u2014 call list_schemas first to learn required fields and enums). Idempotent by `externalId`. Requires the key to allow records:c (and records:r to receive the existing record on a collision).",
10061
11060
  inputSchema: inputSchema5,
11061
+ // Creates, never modifies or deletes an existing record. Idempotent ONLY when the caller
11062
+ // supplies `externalId` (optional, per the doc comment above) — re-creating with the same
11063
+ // one returns the existing record rather than duplicating it. `externalId` is not required,
11064
+ // so annotated for the less-safe default (omit it, and a retry creates a second record),
11065
+ // not the safer opt-in — same standard applied to record_batch_write, which has the
11066
+ // identical optional-externalId shape.
11067
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
10062
11068
  handler: async (args) => {
10063
11069
  const type = args.type;
10064
11070
  try {
@@ -10084,19 +11090,110 @@ var recordCreate = ({ client, log }) => ({
10084
11090
  });
10085
11091
  var record_create_default = recordCreate;
10086
11092
 
10087
- // src/tools/record_update.ts
11093
+ // src/tools/record_batch_write.ts
10088
11094
  var import_zod6 = require("zod");
10089
- var inputSchema6 = {
10090
- id: import_zod6.z.string().optional().describe("The Vectros record id to update. Provide this OR externalId+type."),
11095
+ var MCP_MAX_ITEMS = 50;
11096
+ var itemSchema = import_zod6.z.strictObject({
11097
+ 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.'),
11098
+ fields: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).describe(
11099
+ "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)."
11100
+ ),
10091
11101
  externalId: import_zod6.z.string().optional().describe(
11102
+ '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.'
11103
+ ),
11104
+ indexMode: import_zod6.z.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
11105
+ "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."
11106
+ ),
11107
+ status: import_zod6.z.string().optional().describe("Record lifecycle status. Defaults to ACTIVE server-side."),
11108
+ folderId: import_zod6.z.string().optional().describe("Group this record into a folder."),
11109
+ userId: import_zod6.z.string().optional().describe("Owning user id."),
11110
+ scopes: import_zod6.z.array(import_zod6.z.string()).optional().describe(
11111
+ "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."
11112
+ )
11113
+ });
11114
+ var inputSchema6 = {
11115
+ items: import_zod6.z.array(itemSchema).min(1).max(MCP_MAX_ITEMS).describe(
11116
+ `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.`
11117
+ ),
11118
+ atomicity: import_zod6.z.enum(["best_effort", "all_or_nothing"]).optional().describe(
11119
+ '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).'
11120
+ ),
11121
+ upsert: import_zod6.z.boolean().optional().describe(
11122
+ "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."
11123
+ ),
11124
+ allowClear: import_zod6.z.boolean().optional().describe(
11125
+ "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."
11126
+ )
11127
+ };
11128
+ var recordBatchWrite = ({ client, log }) => ({
11129
+ name: "record_batch_write",
11130
+ title: "Create or upsert multiple records in one call",
11131
+ 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).',
11132
+ inputSchema: inputSchema6,
11133
+ // Creates by default, and can overwrite existing records as a FULL replacement when
11134
+ // `upsert:true` is passed (destructive to whatever fields the old version carried and
11135
+ // this call omits). Idempotent ONLY when every item supplies `externalId` (optional,
11136
+ // per its own field doc above) — re-submitting then converges, with or without
11137
+ // `upsert:true`. `externalId` is not required, so annotated for the less-safe default:
11138
+ // an item with no `externalId` at all has no dedup key, and a resubmit creates a second
11139
+ // record for it regardless of `upsert`. Same standard applied to record_create/
11140
+ // document_ingest's identical optional-externalId shape.
11141
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
11142
+ handler: async (args) => {
11143
+ const items = args.items;
11144
+ const atomicity = args.atomicity;
11145
+ try {
11146
+ const body = {
11147
+ items: items.map((item) => ({
11148
+ typeName: item.type,
11149
+ payload: item.fields,
11150
+ externalId: item.externalId,
11151
+ indexMode: item.indexMode,
11152
+ status: item.status,
11153
+ folderId: item.folderId,
11154
+ userId: item.userId,
11155
+ scopes: item.scopes
11156
+ })),
11157
+ atomicity,
11158
+ upsert: args.upsert,
11159
+ allowClear: args.allowClear
11160
+ };
11161
+ const response = await client.records.batchWriteRecords(body, { maxRetries: 0 });
11162
+ log.debug(
11163
+ {
11164
+ tool: "record_batch_write",
11165
+ submitted: items.length,
11166
+ atomicity: atomicity ?? "best_effort",
11167
+ succeeded: response.succeeded,
11168
+ failed: response.failed
11169
+ },
11170
+ "record_batch_write ok"
11171
+ );
11172
+ return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
11173
+ } catch (err) {
11174
+ log.warn(
11175
+ { tool: "record_batch_write", itemCount: items?.length, err: String(err) },
11176
+ "record_batch_write failed"
11177
+ );
11178
+ return toolError("record_batch_write", err);
11179
+ }
11180
+ }
11181
+ });
11182
+ var record_batch_write_default = recordBatchWrite;
11183
+
11184
+ // src/tools/record_update.ts
11185
+ var import_zod7 = require("zod");
11186
+ var inputSchema7 = {
11187
+ id: import_zod7.z.string().optional().describe("The Vectros record id to update. Provide this OR externalId+type."),
11188
+ externalId: import_zod7.z.string().optional().describe(
10092
11189
  "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."
10093
11190
  ),
10094
- type: import_zod6.z.string().optional().describe("Record type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10095
- fields: import_zod6.z.record(import_zod6.z.string(), import_zod6.z.unknown()).describe(
11191
+ type: import_zod7.z.string().optional().describe("Record type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11192
+ fields: import_zod7.z.record(import_zod7.z.string(), import_zod7.z.unknown()).describe(
10096
11193
  "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."
10097
11194
  ),
10098
- status: import_zod6.z.string().optional().describe("Set the record lifecycle status (e.g. ARCHIVED) \u2014 archive/workflow without physical deletion."),
10099
- expectedVersion: import_zod6.z.number().int().optional().describe(
11195
+ status: import_zod7.z.string().optional().describe("Set the record lifecycle status (e.g. ARCHIVED) \u2014 archive/workflow without physical deletion."),
11196
+ expectedVersion: import_zod7.z.number().int().optional().describe(
10100
11197
  "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."
10101
11198
  )
10102
11199
  };
@@ -10104,7 +11201,11 @@ var recordUpdate = ({ client, log }) => ({
10104
11201
  name: "record_update",
10105
11202
  title: "Update a record by id or externalId",
10106
11203
  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.",
10107
- inputSchema: inputSchema6,
11204
+ inputSchema: inputSchema7,
11205
+ // A JSON Merge Patch — overwrites the fields it names, so it can destroy a prior field
11206
+ // value the caller did not mean to lose. Re-applying the same patch converges to the
11207
+ // same state, so it is idempotent.
11208
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
10108
11209
  handler: async (args) => {
10109
11210
  const id = args.id;
10110
11211
  const externalId = args.externalId;
@@ -10130,15 +11231,19 @@ var recordUpdate = ({ client, log }) => ({
10130
11231
  var record_update_default = recordUpdate;
10131
11232
 
10132
11233
  // src/tools/record_delete.ts
10133
- var import_zod7 = require("zod");
10134
- var inputSchema7 = {
10135
- id: import_zod7.z.string().min(1, "id is required").describe("The Vectros record id to delete.")
11234
+ var import_zod8 = require("zod");
11235
+ var inputSchema8 = {
11236
+ id: import_zod8.z.string().min(1, "id is required").describe("The Vectros record id to delete.")
10136
11237
  };
10137
11238
  var recordDelete = ({ client, log }) => ({
10138
11239
  name: "record_delete",
10139
11240
  title: "Delete a record",
10140
11241
  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.",
10141
- inputSchema: inputSchema7,
11242
+ inputSchema: inputSchema8,
11243
+ // Deletes (leaves a tombstone server-side, but the record is gone from every normal
11244
+ // read path). Idempotent in the standard REST sense: the end state ("this id no longer
11245
+ // resolves") is the same whether this is the first delete or a repeat of one.
11246
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
10142
11247
  handler: async (args) => {
10143
11248
  const id = args.id;
10144
11249
  try {
@@ -10154,49 +11259,72 @@ var recordDelete = ({ client, log }) => ({
10154
11259
  var record_delete_default = recordDelete;
10155
11260
 
10156
11261
  // src/tools/rag_ask.ts
10157
- var import_zod8 = require("zod");
11262
+ var import_zod9 = require("zod");
10158
11263
  var SEARCH_MCP_DEFAULT_LIMIT = 5;
10159
11264
  var SEARCH_MCP_MAX_LIMIT = 50;
10160
- var inputSchema8 = {
10161
- query: import_zod8.z.string().min(1, "query must be non-empty").describe("Question to ground against retrieved content."),
10162
- instructions: import_zod8.z.string().optional().describe(
11265
+ var inputSchema9 = {
11266
+ query: import_zod9.z.string().min(1, "query must be non-empty").describe("Question to ground against retrieved content."),
11267
+ instructions: import_zod9.z.string().optional().describe(
10163
11268
  '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.'
10164
11269
  ),
10165
- model: import_zod8.z.string().optional().describe(
11270
+ model: import_zod9.z.string().optional().describe(
10166
11271
  "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."
10167
11272
  ),
10168
- search: import_zod8.z.object({
10169
- mode: import_zod8.z.enum(["HYBRID", "TEXT", "SEMANTIC"]).optional().describe("Retrieval mode. Default HYBRID."),
10170
- limit: import_zod8.z.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(
11273
+ search: import_zod9.z.object({
11274
+ mode: import_zod9.z.enum(["HYBRID", "TEXT", "SEMANTIC"]).optional().describe("Retrieval mode. Default HYBRID."),
11275
+ limit: import_zod9.z.number().int().min(1).max(SEARCH_MCP_MAX_LIMIT).optional().describe(
10171
11276
  `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.`
10172
11277
  ),
10173
11278
  // Retrieval scoping — parity with hybrid_search so an agent can ground the
10174
11279
  // answer on a specific owner / folder / type / metadata subset, not just the
10175
11280
  // whole-tenant corpus.
10176
- userId: import_zod8.z.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
10177
- scope: import_zod8.z.string().optional().describe(
10178
- '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.'
11281
+ userId: import_zod9.z.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
11282
+ scope: import_zod9.z.string().optional().describe(
11283
+ '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.'
11284
+ ),
11285
+ scopeFilters: import_zod9.z.array(import_zod9.z.string()).min(1, "scopeFilters must name at least one dimension when supplied").optional().describe(
11286
+ '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`.'
10179
11287
  ),
10180
- folderId: import_zod8.z.string().optional().describe("Restrict retrieval to this exact folder."),
10181
- rootFolderId: import_zod8.z.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
10182
- typeName: import_zod8.z.string().optional().describe("Restrict record retrieval to this schema type."),
10183
- contentTypes: import_zod8.z.array(import_zod8.z.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
10184
- filters: import_zod8.z.record(import_zod8.z.unknown()).optional().describe(
11288
+ folderId: import_zod9.z.string().optional().describe("Restrict retrieval to this exact folder."),
11289
+ rootFolderId: import_zod9.z.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
11290
+ typeName: import_zod9.z.string().optional().describe("Restrict record retrieval to this schema type."),
11291
+ contentTypes: import_zod9.z.array(import_zod9.z.enum(["documents", "records"])).optional().describe('Narrow retrieval to content types. ["documents"] or ["records"]; omit for both.'),
11292
+ filters: import_zod9.z.record(import_zod9.z.unknown()).optional().describe(
10185
11293
  '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"}.'
10186
11294
  ),
10187
- createdAfter: import_zod8.z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
10188
- createdBefore: import_zod8.z.string().optional().describe("Restrict to content created at/before this ISO 8601 UTC timestamp."),
10189
- requireComplete: import_zod8.z.boolean().optional().describe("Fail closed (503) on a degraded search backend instead of grounding on partial results. Default false.")
11295
+ createdAfter: import_zod9.z.string().optional().describe(
11296
+ "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."
11297
+ ),
11298
+ createdBefore: import_zod9.z.string().optional().describe("Same creation-time basis as createdAfter, bounding at/before this ISO 8601 UTC value."),
11299
+ requireComplete: import_zod9.z.boolean().optional().describe("Fail closed (503) on a degraded search backend instead of grounding on partial results. Default false.")
10190
11300
  }).optional().describe("Retrieval params + scoping. Default mode HYBRID, limit " + SEARCH_MCP_DEFAULT_LIMIT + "."),
10191
- maxTokens: import_zod8.z.number().int().min(1).optional().describe("Max output tokens."),
10192
- 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.")
11301
+ maxTokens: import_zod9.z.number().int().min(1).optional().describe("Max output tokens."),
11302
+ 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.")
10193
11303
  };
10194
11304
  var ragAsk = ({ client, log }) => ({
10195
11305
  name: "rag_ask",
10196
11306
  title: "RAG ask (corpus-wide)",
10197
- 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.",
10198
- inputSchema: inputSchema8,
11307
+ 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.",
11308
+ inputSchema: inputSchema9,
11309
+ // NOT a pure read: this call reserves an atomic hold against the caller's prepaid inference
11310
+ // balance before generation starts, then debits it on completion — a real financial side
11311
+ // effect that can trigger a configured auto-recharge against the tenant's card.
11312
+ // `readOnlyHint:true` would let a host
11313
+ // skip a confirmation prompt on a call with real, unbounded-under-retry spend; ordinary reads
11314
+ // that merely meter usage stay `readOnlyHint:true` (hybrid_search has no inference-cost leg),
11315
+ // but a call that can debit a balance and possibly charge a card is a different class. Not
11316
+ // idempotent either: every repeat charges again, and generation is non-deterministic.
11317
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
10199
11318
  handler: async (args, extra) => {
11319
+ const rawSearch = args.search ?? {};
11320
+ if (rawSearch.scope !== void 0 && rawSearch.scopeFilters !== void 0) {
11321
+ return toolError(
11322
+ "rag_ask",
11323
+ new Error(
11324
+ "search.scope and search.scopeFilters are mutually exclusive \u2014 pass 'scope' for a single ownership dimension, or 'scopeFilters' for more than one, not both."
11325
+ )
11326
+ );
11327
+ }
10200
11328
  try {
10201
11329
  const searchArg = args.search ?? {};
10202
11330
  const search = {
@@ -10204,6 +11332,7 @@ var ragAsk = ({ client, log }) => ({
10204
11332
  limit: searchArg.limit ?? SEARCH_MCP_DEFAULT_LIMIT,
10205
11333
  userId: searchArg.userId,
10206
11334
  scope: searchArg.scope,
11335
+ scopeFilters: searchArg.scopeFilters,
10207
11336
  folderId: searchArg.folderId,
10208
11337
  rootFolderId: searchArg.rootFolderId,
10209
11338
  typeName: searchArg.typeName,
@@ -10271,20 +11400,29 @@ var ragAsk = ({ client, log }) => ({
10271
11400
  var rag_ask_default = ragAsk;
10272
11401
 
10273
11402
  // src/tools/document_ask.ts
10274
- var import_zod9 = require("zod");
10275
- var inputSchema9 = {
10276
- documentId: import_zod9.z.string().min(1, "documentId is required").describe("ID of the document to ask against."),
10277
- prompt: import_zod9.z.string().min(1, "prompt is required").describe("Question to ask about the document."),
10278
- model: import_zod9.z.string().optional().describe(
11403
+ var import_zod10 = require("zod");
11404
+ var inputSchema10 = {
11405
+ documentId: import_zod10.z.string().min(1, "documentId is required").describe("ID of the document to ask against."),
11406
+ prompt: import_zod10.z.string().min(1, "prompt is required").describe("Question to ask about the document."),
11407
+ model: import_zod10.z.string().optional().describe(
10279
11408
  "Inference model alias. Default = tier-appropriate Haiku. See GET /v1/models for the catalog the calling key can reach."
10280
11409
  ),
10281
- maxTokens: import_zod9.z.number().int().min(1).optional().describe("Max output tokens.")
11410
+ maxTokens: import_zod10.z.number().int().min(1).optional().describe("Max output tokens.")
10282
11411
  };
10283
11412
  var documentAsk = ({ client, log }) => ({
10284
11413
  name: "document_ask",
10285
11414
  title: "Document ask (single-document)",
10286
11415
  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.",
10287
- inputSchema: inputSchema9,
11416
+ inputSchema: inputSchema10,
11417
+ // NOT a pure read: this call reserves an atomic hold against the caller's prepaid inference
11418
+ // balance before generation starts, then debits it on completion — a real financial side
11419
+ // effect that can trigger a configured auto-recharge against the tenant's card.
11420
+ // `readOnlyHint:true` would let a host
11421
+ // skip a confirmation prompt on a call with real, unbounded-under-retry spend; ordinary reads
11422
+ // that merely meter usage stay `readOnlyHint:true` (hybrid_search has no inference-cost leg),
11423
+ // but a call that can debit a balance and possibly charge a card is a different class. Not
11424
+ // idempotent either: every repeat charges again, and generation is non-deterministic.
11425
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
10288
11426
  handler: async (args, extra) => {
10289
11427
  try {
10290
11428
  const stream = await client.inference.documentAsk({
@@ -10343,18 +11481,18 @@ var documentAsk = ({ client, log }) => ({
10343
11481
  var document_ask_default = documentAsk;
10344
11482
 
10345
11483
  // src/tools/list_schemas.ts
10346
- var import_zod10 = require("zod");
10347
- var inputSchema10 = {
10348
- userId: import_zod10.z.string().optional().describe(
11484
+ var import_zod11 = require("zod");
11485
+ var inputSchema11 = {
11486
+ userId: import_zod11.z.string().optional().describe(
10349
11487
  "Filter to schemas visible to a specific user. Optional; default returns all schemas the credential can see."
10350
11488
  ),
10351
- scope: import_zod10.z.string().optional().describe(
11489
+ scope: import_zod11.z.string().optional().describe(
10352
11490
  '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.'
10353
11491
  ),
10354
- surface: import_zod10.z.enum(["record", "document", "user", "entity"]).optional().describe(
11492
+ surface: import_zod11.z.enum(["record", "document", "user", "entity"]).optional().describe(
10355
11493
  "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."
10356
11494
  ),
10357
- recordType: import_zod10.z.string().optional().describe(
11495
+ recordType: import_zod11.z.string().optional().describe(
10358
11496
  '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.'
10359
11497
  )
10360
11498
  };
@@ -10362,7 +11500,9 @@ var listSchemas = ({ client, log }) => ({
10362
11500
  name: "list_schemas",
10363
11501
  title: "List record schemas",
10364
11502
  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.',
10365
- inputSchema: inputSchema10,
11503
+ inputSchema: inputSchema11,
11504
+ // A pure read — never creates, modifies, or deletes anything server-side.
11505
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
10366
11506
  handler: async (args) => {
10367
11507
  const userId = args.userId;
10368
11508
  const scope = args.scope;
@@ -10388,18 +11528,18 @@ var listSchemas = ({ client, log }) => ({
10388
11528
  var list_schemas_default = listSchemas;
10389
11529
 
10390
11530
  // src/tools/document_get.ts
10391
- var import_zod11 = require("zod");
11531
+ var import_zod12 = require("zod");
10392
11532
  var MAX_TEXT_CHARS = 32e3;
10393
- var inputSchema11 = {
10394
- documentId: import_zod11.z.string().optional().describe("The document ID returned by document_ingest or hybrid_search. Provide this OR externalId+type."),
10395
- externalId: import_zod11.z.string().optional().describe(
11533
+ var inputSchema12 = {
11534
+ documentId: import_zod12.z.string().optional().describe("The document ID returned by document_ingest or hybrid_search. Provide this OR externalId+type."),
11535
+ externalId: import_zod12.z.string().optional().describe(
10396
11536
  "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."
10397
11537
  ),
10398
- type: import_zod11.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10399
- includeText: import_zod11.z.boolean().optional().describe(
11538
+ type: import_zod12.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11539
+ includeText: import_zod12.z.boolean().optional().describe(
10400
11540
  "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."
10401
11541
  ),
10402
- includeDownloadUrl: import_zod11.z.boolean().optional().describe(
11542
+ includeDownloadUrl: import_zod12.z.boolean().optional().describe(
10403
11543
  "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."
10404
11544
  )
10405
11545
  };
@@ -10416,7 +11556,9 @@ var documentGet = ({ client, log }) => ({
10416
11556
  name: "document_get",
10417
11557
  title: "Get document metadata (and optionally text)",
10418
11558
  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.",
10419
- inputSchema: inputSchema11,
11559
+ inputSchema: inputSchema12,
11560
+ // A pure read — never creates, modifies, or deletes anything server-side.
11561
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
10420
11562
  handler: async (args) => {
10421
11563
  const documentId = args.documentId;
10422
11564
  const externalId = args.externalId;
@@ -10481,28 +11623,28 @@ var documentGet = ({ client, log }) => ({
10481
11623
  var document_get_default = documentGet;
10482
11624
 
10483
11625
  // src/tools/document_query.ts
10484
- var import_zod12 = require("zod");
11626
+ var import_zod13 = require("zod");
10485
11627
  var MCP_DEFAULT_LIMIT3 = 3;
10486
11628
  var MCP_MAX_LIMIT3 = 100;
10487
- var inputSchema12 = {
11629
+ var inputSchema13 = {
10488
11630
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
10489
- field: import_zod12.z.string().optional().describe("Lookup mode: name of the lookup-indexed field to query by."),
10490
- value: import_zod12.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields too."),
10491
- from: import_zod12.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Range-enabled, non-sensitive fields only."),
10492
- to: import_zod12.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
10493
- prefix: import_zod12.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
10494
- order: import_zod12.z.enum(["asc", "desc"]).optional().describe(
11631
+ field: import_zod13.z.string().optional().describe("Lookup mode: name of the lookup-indexed field to query by."),
11632
+ value: import_zod13.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields too."),
11633
+ from: import_zod13.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Range-enabled, non-sensitive fields only."),
11634
+ to: import_zod13.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
11635
+ prefix: import_zod13.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
11636
+ order: import_zod13.z.enum(["asc", "desc"]).optional().describe(
10495
11637
  "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."
10496
11638
  ),
10497
- type: import_zod12.z.string().optional().describe("Lookup mode: the document type (the bound schema's type). Required with `field`."),
11639
+ type: import_zod13.z.string().optional().describe("Lookup mode: the document type (the bound schema's type). Required with `field`."),
10498
11640
  // List-mode args:
10499
- folderId: import_zod12.z.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
10500
- userId: import_zod12.z.string().optional().describe("List mode: scope to documents owned by this user."),
10501
- scope: import_zod12.z.string().optional().describe(
11641
+ folderId: import_zod13.z.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
11642
+ userId: import_zod13.z.string().optional().describe("List mode: scope to documents owned by this user."),
11643
+ scope: import_zod13.z.string().optional().describe(
10502
11644
  '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.'
10503
11645
  ),
10504
- 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."),
10505
- limit: import_zod12.z.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
11646
+ 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."),
11647
+ limit: import_zod13.z.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
10506
11648
  `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.`
10507
11649
  )
10508
11650
  };
@@ -10510,7 +11652,9 @@ var documentQuery = ({ client, log }) => ({
10510
11652
  name: "document_query",
10511
11653
  title: "Document query (list or lookup)",
10512
11654
  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.",
10513
- inputSchema: inputSchema12,
11655
+ inputSchema: inputSchema13,
11656
+ // A pure read — never creates, modifies, or deletes anything server-side.
11657
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
10514
11658
  handler: async (args) => {
10515
11659
  const limit = args.limit ?? MCP_DEFAULT_LIMIT3;
10516
11660
  const field = args.field;
@@ -10590,29 +11734,29 @@ var documentQuery = ({ client, log }) => ({
10590
11734
  var document_query_default = documentQuery;
10591
11735
 
10592
11736
  // src/tools/document_update.ts
10593
- var import_zod13 = require("zod");
10594
- var inputSchema13 = {
10595
- documentId: import_zod13.z.string().optional().describe("The Vectros document id to update. Provide this OR externalId+type."),
10596
- externalId: import_zod13.z.string().optional().describe(
11737
+ var import_zod14 = require("zod");
11738
+ var inputSchema14 = {
11739
+ documentId: import_zod14.z.string().optional().describe("The Vectros document id to update. Provide this OR externalId+type."),
11740
+ externalId: import_zod14.z.string().optional().describe(
10597
11741
  "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."
10598
11742
  ),
10599
- type: import_zod13.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
10600
- title: import_zod13.z.string().optional().describe("New title. Omit to keep the current title."),
10601
- fields: import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown()).optional().describe(
11743
+ type: import_zod14.z.string().optional().describe("Document type \u2014 REQUIRED when selecting by `externalId` (externalId is unique within a type)."),
11744
+ title: import_zod14.z.string().optional().describe("New title. Omit to keep the current title."),
11745
+ fields: import_zod14.z.record(import_zod14.z.string(), import_zod14.z.unknown()).optional().describe(
10602
11746
  "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."
10603
11747
  ),
10604
- text: import_zod13.z.string().optional().describe(
11748
+ text: import_zod14.z.string().optional().describe(
10605
11749
  "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."
10606
11750
  ),
10607
- folderId: import_zod13.z.string().optional().describe("Move the document into this folder (cannot be cleared once set)."),
10608
- status: import_zod13.z.enum(["ACTIVE", "ARCHIVED"]).optional().describe(
11751
+ folderId: import_zod14.z.string().optional().describe("Move the document into this folder (cannot be cleared once set)."),
11752
+ status: import_zod14.z.enum(["ACTIVE", "ARCHIVED"]).optional().describe(
10609
11753
  "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."
10610
11754
  ),
10611
- userId: import_zod13.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10612
- scopes: import_zod13.z.array(import_zod13.z.string()).optional().describe(
11755
+ userId: import_zod14.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
11756
+ scopes: import_zod14.z.array(import_zod14.z.string()).optional().describe(
10613
11757
  '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).'
10614
11758
  ),
10615
- expectedVersion: import_zod13.z.number().int().optional().describe(
11759
+ expectedVersion: import_zod14.z.number().int().optional().describe(
10616
11760
  "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."
10617
11761
  )
10618
11762
  };
@@ -10620,7 +11764,11 @@ var documentUpdate = ({ client, log }) => ({
10620
11764
  name: "document_update",
10621
11765
  title: "Update a document",
10622
11766
  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.',
10623
- inputSchema: inputSchema13,
11767
+ inputSchema: inputSchema14,
11768
+ // A JSON Merge Patch — overwrites the fields it names, so it can destroy a prior field
11769
+ // value the caller did not mean to lose. Re-applying the same patch converges to the
11770
+ // same state, so it is idempotent.
11771
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
10624
11772
  handler: async (args) => {
10625
11773
  const documentId = args.documentId;
10626
11774
  const externalId = args.externalId;
@@ -10660,15 +11808,18 @@ var documentUpdate = ({ client, log }) => ({
10660
11808
  var document_update_default = documentUpdate;
10661
11809
 
10662
11810
  // src/tools/document_delete.ts
10663
- var import_zod14 = require("zod");
10664
- var inputSchema14 = {
10665
- documentId: import_zod14.z.string().min(1, "documentId is required").describe("The Vectros document id to delete.")
11811
+ var import_zod15 = require("zod");
11812
+ var inputSchema15 = {
11813
+ documentId: import_zod15.z.string().min(1, "documentId is required").describe("The Vectros document id to delete.")
10666
11814
  };
10667
11815
  var documentDelete = ({ client, log }) => ({
10668
11816
  name: "document_delete",
10669
11817
  title: "Delete a document",
10670
11818
  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).',
10671
- inputSchema: inputSchema14,
11819
+ inputSchema: inputSchema15,
11820
+ // Deletes. Idempotent in the standard REST sense: the end state ("this id no longer
11821
+ // resolves") is the same whether this is the first delete or a repeat of one.
11822
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
10672
11823
  handler: async (args) => {
10673
11824
  const documentId = args.documentId;
10674
11825
  try {
@@ -10686,18 +11837,18 @@ var documentDelete = ({ client, log }) => ({
10686
11837
  var document_delete_default = documentDelete;
10687
11838
 
10688
11839
  // src/tools/folder_query.ts
10689
- var import_zod15 = require("zod");
11840
+ var import_zod16 = require("zod");
10690
11841
  var MCP_DEFAULT_LIMIT4 = 10;
10691
11842
  var MCP_MAX_LIMIT4 = 100;
10692
- var inputSchema15 = {
10693
- id: import_zod15.z.string().optional().describe("Get mode: fetch this single folder by id."),
10694
- parentId: import_zod15.z.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
10695
- userId: import_zod15.z.string().optional().describe("List mode: scope to folders owned by this user."),
10696
- scope: import_zod15.z.string().optional().describe(
11843
+ var inputSchema16 = {
11844
+ id: import_zod16.z.string().optional().describe("Get mode: fetch this single folder by id."),
11845
+ parentId: import_zod16.z.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
11846
+ userId: import_zod16.z.string().optional().describe("List mode: scope to folders owned by this user."),
11847
+ scope: import_zod16.z.string().optional().describe(
10697
11848
  '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.'
10698
11849
  ),
10699
- startFrom: import_zod15.z.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
10700
- limit: import_zod15.z.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
11850
+ startFrom: import_zod16.z.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
11851
+ limit: import_zod16.z.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
10701
11852
  `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\`.`
10702
11853
  )
10703
11854
  };
@@ -10705,7 +11856,9 @@ var folderQuery = ({ client, log }) => ({
10705
11856
  name: "folder_query",
10706
11857
  title: "Folder query (list or get)",
10707
11858
  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.",
10708
- inputSchema: inputSchema15,
11859
+ inputSchema: inputSchema16,
11860
+ // A pure read — never creates, modifies, or deletes anything server-side.
11861
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
10709
11862
  handler: async (args) => {
10710
11863
  const id = args.id;
10711
11864
  try {
@@ -10735,22 +11888,34 @@ var folderQuery = ({ client, log }) => ({
10735
11888
  var folder_query_default = folderQuery;
10736
11889
 
10737
11890
  // src/tools/folder_create.ts
10738
- var import_zod16 = require("zod");
10739
- var inputSchema16 = {
10740
- name: import_zod16.z.string().min(1, "name is required").describe("Folder display name."),
10741
- description: import_zod16.z.string().optional().describe("Optional description of the folder's purpose."),
10742
- 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."),
10743
- slug: import_zod16.z.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
10744
- userId: import_zod16.z.string().optional().describe("Owning user (Vectros UUID)."),
10745
- scopes: import_zod16.z.array(import_zod16.z.string()).optional().describe(
11891
+ var import_zod17 = require("zod");
11892
+ var inputSchema17 = {
11893
+ name: import_zod17.z.string().min(1, "name is required").describe("Folder display name."),
11894
+ description: import_zod17.z.string().optional().describe("Optional description of the folder's purpose."),
11895
+ 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."),
11896
+ slug: import_zod17.z.string().optional().describe(
11897
+ "Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. SUPPLY THIS to make a retry safe \u2014 if omitted, a derived slug is only ever a freshly-proved-free one, so a redelivered call creates a new sibling folder every time rather than matching the first."
11898
+ ),
11899
+ userId: import_zod17.z.string().optional().describe("Owning user (Vectros UUID)."),
11900
+ scopes: import_zod17.z.array(import_zod17.z.string()).optional().describe(
10746
11901
  '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.'
10747
11902
  )
10748
11903
  };
10749
11904
  var folderCreate = ({ client, log }) => ({
10750
11905
  name: "folder_create",
10751
11906
  title: "Create a folder",
10752
- 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).",
10753
- inputSchema: inputSchema16,
11907
+ 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 ONLY when you pass `slug` explicitly \u2014 omitting it derives a fresh, always-free slug on every call, so a retry creates a new sibling folder rather than matching the first. Requires the key to allow folders:c (and folders:r to receive the existing folder on a collision).",
11908
+ inputSchema: inputSchema17,
11909
+ // Idempotent ONLY when the caller supplies `slug` explicitly (see the doc comment above): an
11910
+ // omitted slug is derived through a collision-probing suffix loop that returns only a
11911
+ // freshly-proved-free value, so the idempotency check running after that derivation can never
11912
+ // match on the default path. `slug` is optional, so this is annotated for the less-safe default —
11913
+ // the same standard applied to record_create/document_ingest/record_batch_write's identical
11914
+ // optional-dedupe-key shape. (A prior version of this annotation claimed unconditional
11915
+ // idempotency, reasoning that the derived slug made this tool "genuinely structurally different"
11916
+ // from the optional-externalId tools — that reasoning was wrong: the derivation is unconditional,
11917
+ // but it is unconditionally NON-colliding by construction, which is the opposite property.)
11918
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
10754
11919
  handler: async (args) => {
10755
11920
  try {
10756
11921
  const folder = await client.folders.createFolder({
@@ -10774,16 +11939,16 @@ var folderCreate = ({ client, log }) => ({
10774
11939
  var folder_create_default = folderCreate;
10775
11940
 
10776
11941
  // src/tools/folder_update.ts
10777
- var import_zod17 = require("zod");
10778
- var inputSchema17 = {
10779
- id: import_zod17.z.string().min(1, "id is required").describe("The Vectros folder id to update."),
10780
- name: import_zod17.z.string().optional().describe("New folder name. Omit to keep the current name."),
10781
- description: import_zod17.z.string().optional().describe("New description. Omit to leave unchanged."),
10782
- userId: import_zod17.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10783
- scopes: import_zod17.z.array(import_zod17.z.string()).optional().describe(
11942
+ var import_zod18 = require("zod");
11943
+ var inputSchema18 = {
11944
+ id: import_zod18.z.string().min(1, "id is required").describe("The Vectros folder id to update."),
11945
+ name: import_zod18.z.string().optional().describe("New folder name. Omit to keep the current name."),
11946
+ description: import_zod18.z.string().optional().describe("New description. Omit to leave unchanged."),
11947
+ userId: import_zod18.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
11948
+ scopes: import_zod18.z.array(import_zod18.z.string()).optional().describe(
10784
11949
  '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).'
10785
11950
  ),
10786
- expectedVersion: import_zod17.z.number().int().optional().describe(
11951
+ expectedVersion: import_zod18.z.number().int().optional().describe(
10787
11952
  "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."
10788
11953
  )
10789
11954
  };
@@ -10791,7 +11956,11 @@ var folderUpdate = ({ client, log }) => ({
10791
11956
  name: "folder_update",
10792
11957
  title: "Update a folder",
10793
11958
  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.",
10794
- inputSchema: inputSchema17,
11959
+ inputSchema: inputSchema18,
11960
+ // A JSON Merge Patch — overwrites the fields it names, so it can destroy a prior field
11961
+ // value the caller did not mean to lose. Re-applying the same patch converges to the
11962
+ // same state, so it is idempotent.
11963
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
10795
11964
  handler: async (args) => {
10796
11965
  const id = args.id;
10797
11966
  const name = args.name;
@@ -10818,15 +11987,18 @@ var folderUpdate = ({ client, log }) => ({
10818
11987
  var folder_update_default = folderUpdate;
10819
11988
 
10820
11989
  // src/tools/folder_delete.ts
10821
- var import_zod18 = require("zod");
10822
- var inputSchema18 = {
10823
- id: import_zod18.z.string().min(1, "id is required").describe("The Vectros folder id to delete.")
11990
+ var import_zod19 = require("zod");
11991
+ var inputSchema19 = {
11992
+ id: import_zod19.z.string().min(1, "id is required").describe("The Vectros folder id to delete.")
10824
11993
  };
10825
11994
  var folderDelete = ({ client, log }) => ({
10826
11995
  name: "folder_delete",
10827
11996
  title: "Delete a folder",
10828
- 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.",
10829
- inputSchema: inputSchema18,
11997
+ 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.',
11998
+ inputSchema: inputSchema19,
11999
+ // Deletes. Idempotent in the standard REST sense: the end state ("this id no longer
12000
+ // resolves") is the same whether this is the first delete or a repeat of one.
12001
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true },
10830
12002
  handler: async (args) => {
10831
12003
  const id = args.id;
10832
12004
  try {
@@ -10842,14 +12014,16 @@ var folderDelete = ({ client, log }) => ({
10842
12014
  var folder_delete_default = folderDelete;
10843
12015
 
10844
12016
  // src/tools/current_identity.ts
10845
- var inputSchema19 = {
12017
+ var inputSchema20 = {
10846
12018
  // No args — current_identity describes the current credential.
10847
12019
  };
10848
12020
  var currentIdentity = ({ log, apiKey, environment }) => ({
10849
12021
  name: "current_identity",
10850
12022
  title: "Current identity (tenant + principal scope)",
10851
12023
  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.",
10852
- inputSchema: inputSchema19,
12024
+ inputSchema: inputSchema20,
12025
+ // A pure read (/v1/ping) — never creates, modifies, or deletes anything server-side.
12026
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
10853
12027
  handler: async () => {
10854
12028
  try {
10855
12029
  const identity = await resolveIdentity({ log, apiKey, environment });
@@ -10865,7 +12039,7 @@ var currentIdentity = ({ log, apiKey, environment }) => ({
10865
12039
  var current_identity_default = currentIdentity;
10866
12040
 
10867
12041
  // src/tools/document_ingest.ts
10868
- var import_zod19 = require("zod");
12042
+ var import_zod20 = require("zod");
10869
12043
  var import_promises = require("fs/promises");
10870
12044
  var import_node_path = require("path");
10871
12045
  var IngestPathError = class extends Error {
@@ -10940,37 +12114,37 @@ function inferMimeType(filePath) {
10940
12114
  const ext = (0, import_node_path.extname)(filePath).toLowerCase();
10941
12115
  return EXT_TO_MIME[ext] ?? "application/octet-stream";
10942
12116
  }
10943
- var inputSchema20 = {
10944
- title: import_zod19.z.string().min(1, "title is required").describe("Human-readable document title \u2014 appears in search results and the UI."),
10945
- indexMode: import_zod19.z.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
12117
+ var inputSchema21 = {
12118
+ title: import_zod20.z.string().min(1, "title is required").describe("Human-readable document title \u2014 appears in search results and the UI."),
12119
+ indexMode: import_zod20.z.enum(["HYBRID", "SEMANTIC", "TEXT", "NONE"]).optional().describe(
10946
12120
  "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."
10947
12121
  ),
10948
- externalId: import_zod19.z.string().optional().describe(
12122
+ externalId: import_zod20.z.string().optional().describe(
10949
12123
  '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.'
10950
12124
  ),
10951
- upsert: import_zod19.z.boolean().optional().describe(
12125
+ upsert: import_zod20.z.boolean().optional().describe(
10952
12126
  "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)."
10953
12127
  ),
10954
- schemaId: import_zod19.z.string().optional().describe(
12128
+ schemaId: import_zod20.z.string().optional().describe(
10955
12129
  "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."
10956
12130
  ),
10957
- payload: import_zod19.z.record(import_zod19.z.string(), import_zod19.z.unknown()).optional().describe(
12131
+ payload: import_zod20.z.record(import_zod20.z.string(), import_zod20.z.unknown()).optional().describe(
10958
12132
  "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."
10959
12133
  ),
10960
12134
  // Inline text mode (mutually exclusive with filePath):
10961
- text: import_zod19.z.string().min(1).optional().describe("Text body to ingest inline. Mutually exclusive with filePath. Either text or filePath is required."),
10962
- storeText: import_zod19.z.boolean().optional().describe(
12135
+ text: import_zod20.z.string().min(1).optional().describe("Text body to ingest inline. Mutually exclusive with filePath. Either text or filePath is required."),
12136
+ storeText: import_zod20.z.boolean().optional().describe(
10963
12137
  "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."
10964
12138
  ),
10965
12139
  // File upload mode (mutually exclusive with text; stdio-transport-only):
10966
- filePath: import_zod19.z.string().min(1).optional().describe(
12140
+ filePath: import_zod20.z.string().min(1).optional().describe(
10967
12141
  "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."
10968
12142
  ),
10969
- fileType: import_zod19.z.string().optional().describe('MIME type of the file (e.g. "application/pdf"). Inferred from filePath extension if omitted.'),
12143
+ fileType: import_zod20.z.string().optional().describe('MIME type of the file (e.g. "application/pdf"). Inferred from filePath extension if omitted.'),
10970
12144
  // Common (both modes):
10971
- folderId: import_zod19.z.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
10972
- userId: import_zod19.z.string().optional().describe("Owning user ID. Optional."),
10973
- scopes: import_zod19.z.array(import_zod19.z.string()).optional().describe(
12145
+ folderId: import_zod20.z.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
12146
+ userId: import_zod20.z.string().optional().describe("Owning user ID. Optional."),
12147
+ scopes: import_zod20.z.array(import_zod20.z.string()).optional().describe(
10974
12148
  "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."
10975
12149
  )
10976
12150
  };
@@ -10978,7 +12152,17 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
10978
12152
  name: "document_ingest",
10979
12153
  title: "Ingest a new document (text body or file upload)",
10980
12154
  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`.",
10981
- inputSchema: inputSchema20,
12155
+ inputSchema: inputSchema21,
12156
+ // Creates by default, idempotent ONLY when the caller supplies `externalId` (optional,
12157
+ // per the doc comment above) — re-ingest then returns the existing document rather than
12158
+ // duplicating it. `externalId` is not required, so annotated for the less-safe default
12159
+ // (omit it, and every call creates a new document), same standard applied to
12160
+ // record_create/record_batch_write's identical optional-externalId shape. `upsert:true`
12161
+ // is a further, real, named capability of this tool that OVERWRITES an existing
12162
+ // document's content and re-indexes it — that path is destructive to the prior body, so
12163
+ // this is flagged destructive rather than claiming create-only safety a caller can
12164
+ // invoke past.
12165
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },
10982
12166
  handler: async (args) => {
10983
12167
  const title = args.title;
10984
12168
  const text = args.text;
@@ -11089,7 +12273,7 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
11089
12273
  }
11090
12274
  const putRes = await fetch(uploadUrl, {
11091
12275
  method: "PUT",
11092
- headers: { "Content-Type": fileType },
12276
+ headers: { "Content-Type": fileType, ...presignedUploadHeaders(upload) },
11093
12277
  body: bytes
11094
12278
  });
11095
12279
  if (!putRes.ok) {
@@ -11128,31 +12312,38 @@ var documentIngest = ({ client, log, transport, ingestRoot }) => ({
11128
12312
  }
11129
12313
  });
11130
12314
  var document_ingest_default = documentIngest;
12315
+ function presignedUploadHeaders(response) {
12316
+ if (typeof response !== "object" || response === null) return {};
12317
+ const { requiredHeaderName, requiredHeaderValue } = response;
12318
+ if (typeof requiredHeaderName !== "string" || requiredHeaderName === "") return {};
12319
+ if (typeof requiredHeaderValue !== "string") return {};
12320
+ return { [requiredHeaderName]: requiredHeaderValue };
12321
+ }
11131
12322
 
11132
12323
  // src/tools/lookup_principal.ts
11133
- var import_zod20 = require("zod");
12324
+ var import_zod21 = require("zod");
11134
12325
  var MCP_DEFAULT_LIMIT5 = 10;
11135
12326
  var MCP_MAX_LIMIT5 = 100;
11136
- var inputSchema21 = {
11137
- kind: import_zod20.z.string().describe(
12327
+ var inputSchema22 = {
12328
+ kind: import_zod21.z.string().describe(
11138
12329
  '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.'
11139
12330
  ),
11140
- externalId: import_zod20.z.string().optional().describe(
12331
+ externalId: import_zod21.z.string().optional().describe(
11141
12332
  "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."
11142
12333
  ),
11143
- contextId: import_zod20.z.string().optional().describe(
12334
+ contextId: import_zod21.z.string().optional().describe(
11144
12335
  "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."
11145
12336
  ),
11146
12337
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
11147
- type: import_zod20.z.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
11148
- field: import_zod20.z.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
11149
- value: import_zod20.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields."),
11150
- from: import_zod20.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Non-sensitive fields only."),
11151
- to: import_zod20.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
11152
- prefix: import_zod20.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
11153
- order: import_zod20.z.enum(["asc", "desc"]).optional().describe("Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc`."),
11154
- startFrom: import_zod20.z.string().optional().describe("Lookup mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
11155
- limit: import_zod20.z.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(
12338
+ type: import_zod21.z.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
12339
+ field: import_zod21.z.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
12340
+ value: import_zod21.z.string().optional().describe("Lookup mode (equality): exact-match value for `field`. Works on sensitive fields."),
12341
+ from: import_zod21.z.string().optional().describe("Lookup mode (range): inclusive lower bound; requires `to`. Non-sensitive fields only."),
12342
+ to: import_zod21.z.string().optional().describe("Lookup mode (range): inclusive upper bound; requires `from`."),
12343
+ prefix: import_zod21.z.string().optional().describe("Lookup mode (prefix): match values starting with this. Range-enabled string fields only."),
12344
+ order: import_zod21.z.enum(["asc", "desc"]).optional().describe("Lookup mode: sort direction by the looked-up field. `asc` (default) or `desc`."),
12345
+ startFrom: import_zod21.z.string().optional().describe("Lookup mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
12346
+ limit: import_zod21.z.number().int().min(1).max(MCP_MAX_LIMIT5).optional().describe(
11156
12347
  `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\`.`
11157
12348
  )
11158
12349
  };
@@ -11160,7 +12351,9 @@ var lookupPrincipal = ({ client, log }) => ({
11160
12351
  name: "lookup_principal",
11161
12352
  title: "Look up a user identity or a namespaced identity entity",
11162
12353
  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.",
11163
- inputSchema: inputSchema21,
12354
+ inputSchema: inputSchema22,
12355
+ // A pure read — never creates, modifies, or deletes anything server-side.
12356
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
11164
12357
  handler: async (args) => {
11165
12358
  const kind = args.kind;
11166
12359
  const isUser = kind === "user";
@@ -11234,17 +12427,19 @@ var lookupPrincipal = ({ client, log }) => ({
11234
12427
  var lookup_principal_default = lookupPrincipal;
11235
12428
 
11236
12429
  // src/tools/version_history.ts
11237
- var import_zod21 = require("zod");
11238
- var inputSchema22 = {
11239
- resourceType: import_zod21.z.enum(["record", "document"]).describe("Which kind of entity the id refers to: a record or a document."),
11240
- id: import_zod21.z.string().min(1, "id is required").describe("The Vectros id of the record or document whose history you want."),
11241
- startFrom: import_zod21.z.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch older entries.")
12430
+ var import_zod22 = require("zod");
12431
+ var inputSchema23 = {
12432
+ resourceType: import_zod22.z.enum(["record", "document"]).describe("Which kind of entity the id refers to: a record or a document."),
12433
+ id: import_zod22.z.string().min(1, "id is required").describe("The Vectros id of the record or document whose history you want."),
12434
+ startFrom: import_zod22.z.string().optional().describe("Pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch older entries.")
11242
12435
  };
11243
12436
  var versionHistory = ({ client, log }) => ({
11244
12437
  name: "version_history",
11245
12438
  title: "Version history (record or document)",
11246
12439
  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.",
11247
- inputSchema: inputSchema22,
12440
+ inputSchema: inputSchema23,
12441
+ // A pure read — never creates, modifies, or deletes anything server-side.
12442
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
11248
12443
  handler: async (args) => {
11249
12444
  const resourceType = args.resourceType;
11250
12445
  const id = args.id;
@@ -11273,6 +12468,7 @@ var TOOL_NAMES = [
11273
12468
  "record_get",
11274
12469
  "record_batch_get",
11275
12470
  "record_create",
12471
+ "record_batch_write",
11276
12472
  "record_update",
11277
12473
  "record_delete",
11278
12474
  "rag_ask",
@@ -11299,6 +12495,7 @@ var ALL_TOOL_FACTORIES = {
11299
12495
  record_get: record_get_default,
11300
12496
  record_batch_get: record_batch_get_default,
11301
12497
  record_create: record_create_default,
12498
+ record_batch_write: record_batch_write_default,
11302
12499
  record_update: record_update_default,
11303
12500
  record_delete: record_delete_default,
11304
12501
  rag_ask: rag_ask_default,
@@ -11358,7 +12555,7 @@ var ALL_RESOURCE_FACTORIES = {
11358
12555
  };
11359
12556
 
11360
12557
  // src/zod-to-json-schema.ts
11361
- var import_zod22 = require("zod");
12558
+ var import_zod23 = require("zod");
11362
12559
  function zodShapeToJsonSchema(shape) {
11363
12560
  const properties = {};
11364
12561
  const required = [];
@@ -11373,40 +12570,40 @@ function zodShapeToJsonSchema(shape) {
11373
12570
  function zodTypeToJsonSchema(schema) {
11374
12571
  const description = schema.description;
11375
12572
  let current = schema;
11376
- while (current instanceof import_zod22.z.ZodOptional || current instanceof import_zod22.z.ZodDefault || current instanceof import_zod22.z.ZodNullable) {
12573
+ while (current instanceof import_zod23.z.ZodOptional || current instanceof import_zod23.z.ZodDefault || current instanceof import_zod23.z.ZodNullable) {
11377
12574
  current = current._def.innerType;
11378
12575
  }
11379
12576
  const base = description ? { description } : {};
11380
- if (current instanceof import_zod22.z.ZodString) {
12577
+ if (current instanceof import_zod23.z.ZodString) {
11381
12578
  return { ...base, type: "string" };
11382
12579
  }
11383
- if (current instanceof import_zod22.z.ZodNumber) {
12580
+ if (current instanceof import_zod23.z.ZodNumber) {
11384
12581
  return { ...base, type: "number" };
11385
12582
  }
11386
- if (current instanceof import_zod22.z.ZodBoolean) {
12583
+ if (current instanceof import_zod23.z.ZodBoolean) {
11387
12584
  return { ...base, type: "boolean" };
11388
12585
  }
11389
- if (current instanceof import_zod22.z.ZodEnum) {
12586
+ if (current instanceof import_zod23.z.ZodEnum) {
11390
12587
  return {
11391
12588
  ...base,
11392
12589
  type: "string",
11393
12590
  enum: current.options
11394
12591
  };
11395
12592
  }
11396
- if (current instanceof import_zod22.z.ZodArray) {
12593
+ if (current instanceof import_zod23.z.ZodArray) {
11397
12594
  return {
11398
12595
  ...base,
11399
12596
  type: "array",
11400
12597
  items: zodTypeToJsonSchema(current.element)
11401
12598
  };
11402
12599
  }
11403
- if (current instanceof import_zod22.z.ZodObject) {
12600
+ if (current instanceof import_zod23.z.ZodObject) {
11404
12601
  return {
11405
12602
  ...base,
11406
12603
  ...zodShapeToJsonSchema(current.shape)
11407
12604
  };
11408
12605
  }
11409
- if (current instanceof import_zod22.z.ZodRecord) {
12606
+ if (current instanceof import_zod23.z.ZodRecord) {
11410
12607
  const valueType = current._def.valueType;
11411
12608
  return {
11412
12609
  ...base,
@@ -11520,7 +12717,12 @@ var VectrosMCPServer = class {
11520
12717
  // MCP client (a well-behaved client rejects an unknown key before the call).
11521
12718
  // The server enforces it too (z.object(...).strict() below) so a raw JSON-RPC
11522
12719
  // call that skips client validation is still rejected — belt and suspenders.
11523
- inputSchema: { ...zodShapeToJsonSchema(t.inputSchema), additionalProperties: false }
12720
+ inputSchema: { ...zodShapeToJsonSchema(t.inputSchema), additionalProperties: false },
12721
+ // Forwarded from the tool's own definition, not hand-copied here: adding an
12722
+ // annotation to a tool factory does nothing for a client unless it also reaches
12723
+ // this emitted list — the actual `tools/list` response a host reads, not the
12724
+ // source that builds it.
12725
+ ...t.annotations ? { annotations: t.annotations } : {}
11524
12726
  }))
11525
12727
  })
11526
12728
  );
@@ -11530,7 +12732,7 @@ var VectrosMCPServer = class {
11530
12732
  if (!tool) {
11531
12733
  result = toolError(req.params.name ?? "unknown", new Error("No such tool."));
11532
12734
  } else {
11533
- const parsed = import_zod23.z.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
12735
+ const parsed = import_zod24.z.object(tool.inputSchema).strict().safeParse(req.params.arguments ?? {});
11534
12736
  if (!parsed.success) {
11535
12737
  result = toolError(tool.name, new Error(formatArgError(tool, parsed.error)));
11536
12738
  } else {