@vectros-ai/mcp-server 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -103,6 +103,7 @@ __export2(api_exports, {
103
103
  TooManyRequestsError: () => TooManyRequestsError,
104
104
  TruncationWarningEvent: () => TruncationWarningEvent,
105
105
  UnauthorizedError: () => UnauthorizedError,
106
+ UserExistsResponse: () => UserExistsResponse,
106
107
  UserRequest: () => UserRequest,
107
108
  UserResponse: () => UserResponse,
108
109
  auth: () => auth_exports,
@@ -779,6 +780,14 @@ var TruncationWarningEvent;
779
780
  ContextWindowBudget: "context_window_budget"
780
781
  };
781
782
  })(TruncationWarningEvent || (TruncationWarningEvent = {}));
783
+ var UserExistsResponse;
784
+ ((UserExistsResponse2) => {
785
+ UserExistsResponse2.Status = {
786
+ Active: "ACTIVE",
787
+ Suspended: "SUSPENDED",
788
+ Pending: "PENDING"
789
+ };
790
+ })(UserExistsResponse || (UserExistsResponse = {}));
782
791
  var UserRequest;
783
792
  ((UserRequest2) => {
784
793
  UserRequest2.Status = {
@@ -2522,7 +2531,7 @@ var AuthClient = class {
2522
2531
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/admin/keys/scoped");
2523
2532
  }
2524
2533
  /**
2525
- * 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.
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. A root API key (`sk_`) is exempt from both bounds.
2526
2535
  *
2527
2536
  * @param {Vectros.CreateScopedKeyRequest} request
2528
2537
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -2854,7 +2863,7 @@ var AuthClient = class {
2854
2863
  );
2855
2864
  }
2856
2865
  /**
2857
- * Creates a new access profile under the given app context. This call is idempotent by `principalId`: if a profile with the same `principalId` already exists, the existing profile is returned (with status 200) instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing profile was returned) tells the two apart. To overwrite an existing profile's `scopes`/`roleId`, `identityOverrides`, and `status` instead of returning it unchanged, set `?upsert=true` (this also requires the `profiles:u` scope, and applies the same `identityOverrides` bounds the update endpoint documents — a scoped credential may not repoint or clear an identity value it does not itself hold). You must provide exactly one of `scopes` (an inline list of scopes) or `roleId` (a reference to a role); supplying both, or neither, is rejected. `identityOverrides` is keyed by ownership namespace in `scope:<namespace>` form — `scope:org` and `scope:client` for the reserved namespaces, or any namespace you have registered — and may name at most two; any other key (including the account identifier or `userId`) is rejected. If you use a scoped credential, the profile's effective scopes may not exceed your own; a root API key (`sk_`) is exempt. Requires the `profiles:c` scope.
2866
+ * Creates a new access profile under the given app context. This call is idempotent by `principalId`: if a profile with the same `principalId` already exists, the existing profile is returned (with status 200) instead of creating a duplicate. The response's `created` field (and the HTTP status — 201 when created, 200 when an existing profile was returned) tells the two apart. To overwrite an existing profile's `scopes`/`roleId`, `identityOverrides`, and `status` instead of returning it unchanged, set `?upsert=true` (this also requires the `profiles:u` scope, and applies the same `identityOverrides` bounds the update endpoint documents — a scoped credential may not repoint or clear an identity value it does not itself hold). The `principalId` must name a principal that already exists: a `usr_` principal must be a live user in your tenant, so create the user before granting it a profile. A `usr_` id that names no such user is rejected, and no profile is created. `key_` principals are not checked this way. You must provide exactly one of `scopes` (an inline list of scopes) or `roleId` (a reference to a role); supplying both, or neither, is rejected. `identityOverrides` is keyed by ownership namespace in `scope:<namespace>` form — `scope:org` and `scope:client` for the reserved namespaces, or any namespace you have registered — and may name at most two; any other key (including the account identifier or `userId`) is rejected. If you use a scoped credential, the profile's effective scopes may not exceed your own; a root API key (`sk_`) is exempt. Requires the `profiles:c` scope.
2858
2867
  *
2859
2868
  * @param {Vectros.CreateAccessProfileRequest} request
2860
2869
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3272,11 +3281,12 @@ var AuthClient = class {
3272
3281
  );
3273
3282
  }
3274
3283
  /**
3275
- * Updates an access profile. This is a partial update: any field you omit (or send as null) keeps its existing value. A profile must reference either inline `scopes` or a `roleId`, never both — so setting `scopes` clears any `roleId`, and setting `roleId` clears any inline `scopes`. The `contextId` and `principalId` are immutable. Status changes (for example active to suspended) take effect within about five minutes. If you use a scoped credential, the profile's effective scopes may not exceed your own, and its `identityOverrides` are bounded twice: you may only set a value your own identity holds, and you may only change or clear a value the profile already holds if that value is yours as well. Repointing or clearing another principal's established identity therefore returns 403. A root API key (`sk_`) is exempt. Requires the `profiles:u` scope.
3284
+ * Updates an access profile. This is a partial update: any field you omit (or send as null) keeps its existing value. A profile must reference either inline `scopes` or a `roleId`, never both — so setting `scopes` clears any `roleId`, and setting `roleId` clears any inline `scopes`. The `contextId` and `principalId` are immutable. Status changes (for example active to suspended) take effect within about five minutes. If you use a scoped credential, the profile's effective scopes may not exceed your own, and its `identityOverrides` are bounded twice: you may only set a value your own identity holds, and you may only change or clear a value the profile already holds if that value is yours as well. Repointing or clearing another principal's established identity therefore returns 403. A root API key (`sk_`) is exempt. If you set `roleId`, it must reference a role that already exists in this context. Requires the `profiles:u` scope.
3276
3285
  *
3277
3286
  * @param {Vectros.UpdateAccessProfileRequest} request
3278
3287
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
3279
3288
  *
3289
+ * @throws {@link Vectros.BadRequestError}
3280
3290
  * @throws {@link Vectros.ForbiddenError}
3281
3291
  * @throws {@link Vectros.NotFoundError}
3282
3292
  * @throws {@link Vectros.TooManyRequestsError}
@@ -3323,6 +3333,8 @@ var AuthClient = class {
3323
3333
  }
3324
3334
  if (_response.error.reason === "status-code") {
3325
3335
  switch (_response.error.statusCode) {
3336
+ case 400:
3337
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
3326
3338
  case 403:
3327
3339
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
3328
3340
  case 404:
@@ -3952,7 +3964,7 @@ var AuthClient = class {
3952
3964
  );
3953
3965
  }
3954
3966
  /**
3955
- * 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.
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.
3956
3968
  *
3957
3969
  * @param {Vectros.GetUsageRequest} request
3958
3970
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4014,6 +4026,257 @@ var AuthClient = class {
4014
4026
  }
4015
4027
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/usage");
4016
4028
  }
4029
+ /**
4030
+ * Retrieves a single registered issuer by issuerId. Requires a root API key or the bootstrap's provisioning capability. A credential confined to one app context sees only an issuer registered in that context; naming one registered in another context returns 404, identically to a nonexistent issuerId. A root API key sees every context.
4031
+ *
4032
+ * @param {Vectros.GetIssuerRequest} request
4033
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4034
+ *
4035
+ * @throws {@link Vectros.ForbiddenError}
4036
+ * @throws {@link Vectros.NotFoundError}
4037
+ *
4038
+ * @example
4039
+ * await client.auth.getIssuer({
4040
+ * issuerId: "auth0-prod"
4041
+ * })
4042
+ */
4043
+ getIssuer(request, requestOptions) {
4044
+ return HttpResponsePromise.fromPromise(this.__getIssuer(request, requestOptions));
4045
+ }
4046
+ async __getIssuer(request, requestOptions) {
4047
+ const { issuerId } = request;
4048
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4049
+ const _headers = mergeHeaders(
4050
+ _authRequest.headers,
4051
+ this._options?.headers,
4052
+ requestOptions?.headers
4053
+ );
4054
+ const _response = await fetcher({
4055
+ url: url_exports.join(
4056
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4057
+ `v1/auth/issuers/${url_exports.encodePathParam(issuerId)}`
4058
+ ),
4059
+ method: "GET",
4060
+ headers: _headers,
4061
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4062
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4063
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4064
+ abortSignal: requestOptions?.abortSignal,
4065
+ fetchFn: this._options?.fetch,
4066
+ logging: this._options.logging
4067
+ });
4068
+ if (_response.ok) {
4069
+ return { data: _response.body, rawResponse: _response.rawResponse };
4070
+ }
4071
+ if (_response.error.reason === "status-code") {
4072
+ switch (_response.error.statusCode) {
4073
+ case 403:
4074
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4075
+ case 404:
4076
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
4077
+ default:
4078
+ throw new VectrosError({
4079
+ statusCode: _response.error.statusCode,
4080
+ body: _response.error.body,
4081
+ rawResponse: _response.rawResponse
4082
+ });
4083
+ }
4084
+ }
4085
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/auth/issuers/{issuerId}");
4086
+ }
4087
+ /**
4088
+ * 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.
4089
+ *
4090
+ * @param {Vectros.DeleteIssuerRequest} request
4091
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4092
+ *
4093
+ * @throws {@link Vectros.ForbiddenError}
4094
+ * @throws {@link Vectros.NotFoundError}
4095
+ * @throws {@link Vectros.ConflictError}
4096
+ * @throws {@link Vectros.TooManyRequestsError}
4097
+ *
4098
+ * @example
4099
+ * await client.auth.deleteIssuer({
4100
+ * issuerId: "auth0-prod"
4101
+ * })
4102
+ */
4103
+ deleteIssuer(request, requestOptions) {
4104
+ return HttpResponsePromise.fromPromise(this.__deleteIssuer(request, requestOptions));
4105
+ }
4106
+ async __deleteIssuer(request, requestOptions) {
4107
+ const { issuerId } = request;
4108
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4109
+ const _headers = mergeHeaders(
4110
+ _authRequest.headers,
4111
+ this._options?.headers,
4112
+ requestOptions?.headers
4113
+ );
4114
+ const _response = await fetcher({
4115
+ url: url_exports.join(
4116
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4117
+ `v1/auth/issuers/${url_exports.encodePathParam(issuerId)}`
4118
+ ),
4119
+ method: "DELETE",
4120
+ headers: _headers,
4121
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4122
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4123
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4124
+ abortSignal: requestOptions?.abortSignal,
4125
+ fetchFn: this._options?.fetch,
4126
+ logging: this._options.logging
4127
+ });
4128
+ if (_response.ok) {
4129
+ return { data: void 0, rawResponse: _response.rawResponse };
4130
+ }
4131
+ if (_response.error.reason === "status-code") {
4132
+ switch (_response.error.statusCode) {
4133
+ case 403:
4134
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4135
+ case 404:
4136
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
4137
+ case 409:
4138
+ throw new ConflictError(_response.error.body, _response.rawResponse);
4139
+ case 429:
4140
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
4141
+ default:
4142
+ throw new VectrosError({
4143
+ statusCode: _response.error.statusCode,
4144
+ body: _response.error.body,
4145
+ rawResponse: _response.rawResponse
4146
+ });
4147
+ }
4148
+ }
4149
+ return handleNonStatusCodeError(
4150
+ _response.error,
4151
+ _response.rawResponse,
4152
+ "DELETE",
4153
+ "/v1/auth/issuers/{issuerId}"
4154
+ );
4155
+ }
4156
+ /**
4157
+ * Returns the issuers registered in your tenant. Requires a root API key or the bootstrap's provisioning capability. A credential confined to one app context sees only the issuers registered in that context; a root API key sees every context. Returns a `{data, nextCursor}` envelope.
4158
+ *
4159
+ * @param {Vectros.ListIssuersRequest} request
4160
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4161
+ *
4162
+ * @throws {@link Vectros.ForbiddenError}
4163
+ *
4164
+ * @example
4165
+ * await client.auth.listIssuers()
4166
+ */
4167
+ listIssuers(request = {}, requestOptions) {
4168
+ return HttpResponsePromise.fromPromise(this.__listIssuers(request, requestOptions));
4169
+ }
4170
+ async __listIssuers(request = {}, requestOptions) {
4171
+ const { startFrom, limit } = request;
4172
+ const _queryParams = {
4173
+ startFrom,
4174
+ limit
4175
+ };
4176
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4177
+ const _headers = mergeHeaders(
4178
+ _authRequest.headers,
4179
+ this._options?.headers,
4180
+ requestOptions?.headers
4181
+ );
4182
+ const _response = await fetcher({
4183
+ url: url_exports.join(
4184
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4185
+ "v1/auth/issuers"
4186
+ ),
4187
+ method: "GET",
4188
+ headers: _headers,
4189
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
4190
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4191
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4192
+ abortSignal: requestOptions?.abortSignal,
4193
+ fetchFn: this._options?.fetch,
4194
+ logging: this._options.logging
4195
+ });
4196
+ if (_response.ok) {
4197
+ return { data: _response.body, rawResponse: _response.rawResponse };
4198
+ }
4199
+ if (_response.error.reason === "status-code") {
4200
+ switch (_response.error.statusCode) {
4201
+ case 403:
4202
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4203
+ default:
4204
+ throw new VectrosError({
4205
+ statusCode: _response.error.statusCode,
4206
+ body: _response.error.body,
4207
+ rawResponse: _response.rawResponse
4208
+ });
4209
+ }
4210
+ }
4211
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/auth/issuers");
4212
+ }
4213
+ /**
4214
+ * 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. Idempotent by `issuerId` within your tenant; the `(issuer, audience)` pair must not already be registered by a different issuerId/tenant. 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`.
4215
+ *
4216
+ * @param {Vectros.IssuerRequest} request
4217
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4218
+ *
4219
+ * @throws {@link Vectros.BadRequestError}
4220
+ * @throws {@link Vectros.ForbiddenError}
4221
+ * @throws {@link Vectros.TooManyRequestsError}
4222
+ *
4223
+ * @example
4224
+ * await client.auth.registerIssuer({
4225
+ * issuerId: "auth0-prod",
4226
+ * issuer: "https://your-tenant.us.auth0.com/",
4227
+ * jwksUri: "https://your-tenant.us.auth0.com/.well-known/jwks.json",
4228
+ * audience: "https://api.your-app.example.com",
4229
+ * contextId: "casework"
4230
+ * })
4231
+ */
4232
+ registerIssuer(request, requestOptions) {
4233
+ return HttpResponsePromise.fromPromise(this.__registerIssuer(request, requestOptions));
4234
+ }
4235
+ async __registerIssuer(request, requestOptions) {
4236
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4237
+ const _headers = mergeHeaders(
4238
+ _authRequest.headers,
4239
+ this._options?.headers,
4240
+ requestOptions?.headers
4241
+ );
4242
+ const _response = await fetcher({
4243
+ url: url_exports.join(
4244
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4245
+ "v1/auth/issuers"
4246
+ ),
4247
+ method: "POST",
4248
+ headers: _headers,
4249
+ contentType: "application/json",
4250
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4251
+ requestType: "json",
4252
+ body: request,
4253
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4254
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4255
+ abortSignal: requestOptions?.abortSignal,
4256
+ fetchFn: this._options?.fetch,
4257
+ logging: this._options.logging
4258
+ });
4259
+ if (_response.ok) {
4260
+ return { data: _response.body, rawResponse: _response.rawResponse };
4261
+ }
4262
+ if (_response.error.reason === "status-code") {
4263
+ switch (_response.error.statusCode) {
4264
+ case 400:
4265
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
4266
+ case 403:
4267
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4268
+ case 429:
4269
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
4270
+ default:
4271
+ throw new VectrosError({
4272
+ statusCode: _response.error.statusCode,
4273
+ body: _response.error.body,
4274
+ rawResponse: _response.rawResponse
4275
+ });
4276
+ }
4277
+ }
4278
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/issuers");
4279
+ }
4017
4280
  /**
4018
4281
  * Returns the identity bound to your credential — your account, principal type, key id, and scope details — so you can confirm who you are authenticated as and that the credential is valid. MCP clients use this to render "signed in as ..." in a chat UI without a separate identity endpoint.
4019
4282
  *
@@ -4059,7 +4322,7 @@ var AuthClient = class {
4059
4322
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/ping");
4060
4323
  }
4061
4324
  /**
4062
- * Returns the access profiles for the given principal across all of your contexts. Use this to answer questions like "which apps does this user have access to?" — for example, to build a member-access summary. Results are confined to your account. Requires the `profiles:r` scope.
4325
+ * Returns the access profiles for the given principal. Looking up your OWN principal — or holding the `context-directory-read` capability — returns the profiles across ALL of your contexts, letting you answer questions like "which apps does this user have access to?". A context-bound credential looking up a DIFFERENT principal instead sees only that principal's profile in your credential's own context (at most one result), never across contexts it has no authority over. Results are always confined to your account. Requires the `profiles:r` scope.
4063
4326
  *
4064
4327
  * @param {Vectros.ListProfilesForPrincipalRequest} request
4065
4328
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4337,6 +4600,72 @@ var AuthClient = class {
4337
4600
  }
4338
4601
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/users/invite/resend");
4339
4602
  }
4603
+ /**
4604
+ * RFC 8693 OAuth 2.0 Token Exchange. Trades a JWT issued by a third-party identity provider you've registered (`POST /v1/auth/issuers`) for a Vectros `st_*` scoped bearer token — no Vectros credential required to call this endpoint. The exchanged token's scope is resolved entirely server-side from the matched user's access profile; this endpoint accepts no caller-supplied scope, resource, or audience parameter (RFC 8693 §2.1's `resource`/`audience`/`scope` are not used in v1 — the registered `(issuer, audience)` pair alone pins the target tenant and app context). On a first-time login (no existing Vectros identity for this subject), two opt-in binding paths exist: `invite_token` (a `PENDING` sub-user invitation), and — if the registration declares one or more self-signup policies — `signup_type` (a brand-new user is created and bound to the policy's configured role). If `invite_token` is present at all, it is the ONLY path tried — a failed invite never falls through to self-signup. Neither field is required for a subject with an existing identity. If your issuer is registered against more than one app context (each via its own audience), `context_id` selects which one to target; omit it when your token's `aud` claim matches only one registered context — the common case, unaffected by this field. Uses the OAuth-standard error envelope (`{"error":..., "error_description":...}`, RFC 6749 §5.2), NOT this API's usual `{"message":...}` shape — its client is generic OAuth tooling, not the Vectros SDK.
4605
+ *
4606
+ * @param {Vectros.TokenExchangeRequest} request
4607
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4608
+ *
4609
+ * @throws {@link Vectros.BadRequestError}
4610
+ * @throws {@link Vectros.UnauthorizedError}
4611
+ * @throws {@link Vectros.ForbiddenError}
4612
+ * @throws {@link Vectros.NotFoundError}
4613
+ * @throws {@link Vectros.TooManyRequestsError}
4614
+ *
4615
+ * @example
4616
+ * await client.auth.exchangeToken({
4617
+ * grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
4618
+ * subject_token: "subject_token",
4619
+ * subject_token_type: "urn:ietf:params:oauth:token-type:jwt"
4620
+ * })
4621
+ */
4622
+ exchangeToken(request, requestOptions) {
4623
+ return HttpResponsePromise.fromPromise(this.__exchangeToken(request, requestOptions));
4624
+ }
4625
+ async __exchangeToken(request, requestOptions) {
4626
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
4627
+ const _response = await fetcher({
4628
+ url: url_exports.join(
4629
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4630
+ "v1/auth/token/exchange"
4631
+ ),
4632
+ method: "POST",
4633
+ headers: _headers,
4634
+ contentType: "application/json",
4635
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4636
+ requestType: "json",
4637
+ body: request,
4638
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4639
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4640
+ abortSignal: requestOptions?.abortSignal,
4641
+ fetchFn: this._options?.fetch,
4642
+ logging: this._options.logging
4643
+ });
4644
+ if (_response.ok) {
4645
+ return { data: _response.body, rawResponse: _response.rawResponse };
4646
+ }
4647
+ if (_response.error.reason === "status-code") {
4648
+ switch (_response.error.statusCode) {
4649
+ case 400:
4650
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
4651
+ case 401:
4652
+ throw new UnauthorizedError(_response.error.body, _response.rawResponse);
4653
+ case 403:
4654
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4655
+ case 404:
4656
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
4657
+ case 429:
4658
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
4659
+ default:
4660
+ throw new VectrosError({
4661
+ statusCode: _response.error.statusCode,
4662
+ body: _response.error.body,
4663
+ rawResponse: _response.rawResponse
4664
+ });
4665
+ }
4666
+ }
4667
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/token/exchange");
4668
+ }
4340
4669
  };
4341
4670
  var ComplianceClient = class {
4342
4671
  constructor(options) {
@@ -5814,6 +6143,7 @@ var IdentityClient = class {
5814
6143
  * @example
5815
6144
  * await client.identity.listEntities({
5816
6145
  * namespace: "team",
6146
+ * contextId: "myapp",
5817
6147
  * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
5818
6148
  * })
5819
6149
  */
@@ -5823,6 +6153,7 @@ var IdentityClient = class {
5823
6153
  async __listEntities(request, requestOptions) {
5824
6154
  const {
5825
6155
  namespace,
6156
+ contextId,
5826
6157
  userId,
5827
6158
  externalId,
5828
6159
  scope,
@@ -5837,6 +6168,7 @@ var IdentityClient = class {
5837
6168
  limit
5838
6169
  } = request;
5839
6170
  const _queryParams = {
6171
+ contextId,
5840
6172
  userId,
5841
6173
  externalId,
5842
6174
  scope,
@@ -5895,6 +6227,7 @@ var IdentityClient = class {
5895
6227
  * @example
5896
6228
  * await client.identity.createEntity({
5897
6229
  * namespace: "team",
6230
+ * contextId: "myapp",
5898
6231
  * body: {
5899
6232
  * externalId: "team_eng_platform"
5900
6233
  * }
@@ -5904,9 +6237,10 @@ var IdentityClient = class {
5904
6237
  return HttpResponsePromise.fromPromise(this.__createEntity(request, requestOptions));
5905
6238
  }
5906
6239
  async __createEntity(request, requestOptions) {
5907
- const { namespace, upsert, body: _body } = request;
6240
+ const { namespace, upsert, contextId, body: _body } = request;
5908
6241
  const _queryParams = {
5909
- upsert
6242
+ upsert,
6243
+ contextId
5910
6244
  };
5911
6245
  const _authRequest = await this._options.authProvider.getAuthRequest();
5912
6246
  const _headers = mergeHeaders(
@@ -5963,14 +6297,18 @@ var IdentityClient = class {
5963
6297
  * @example
5964
6298
  * await client.identity.getEntity({
5965
6299
  * namespace: "team",
5966
- * id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
6300
+ * id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
6301
+ * contextId: "myapp"
5967
6302
  * })
5968
6303
  */
5969
6304
  getEntity(request, requestOptions) {
5970
6305
  return HttpResponsePromise.fromPromise(this.__getEntity(request, requestOptions));
5971
6306
  }
5972
6307
  async __getEntity(request, requestOptions) {
5973
- const { namespace, id } = request;
6308
+ const { namespace, id, contextId } = request;
6309
+ const _queryParams = {
6310
+ contextId
6311
+ };
5974
6312
  const _authRequest = await this._options.authProvider.getAuthRequest();
5975
6313
  const _headers = mergeHeaders(
5976
6314
  _authRequest.headers,
@@ -5984,7 +6322,7 @@ var IdentityClient = class {
5984
6322
  ),
5985
6323
  method: "GET",
5986
6324
  headers: _headers,
5987
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6325
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
5988
6326
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
5989
6327
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
5990
6328
  abortSignal: requestOptions?.abortSignal,
@@ -6021,6 +6359,7 @@ var IdentityClient = class {
6021
6359
  * await client.identity.updateEntity({
6022
6360
  * namespace: "team",
6023
6361
  * id: "id",
6362
+ * contextId: "myapp",
6024
6363
  * body: {
6025
6364
  * externalId: "team_eng_platform"
6026
6365
  * }
@@ -6030,7 +6369,10 @@ var IdentityClient = class {
6030
6369
  return HttpResponsePromise.fromPromise(this.__updateEntity(request, requestOptions));
6031
6370
  }
6032
6371
  async __updateEntity(request, requestOptions) {
6033
- const { namespace, id, body: _body } = request;
6372
+ const { namespace, id, contextId, body: _body } = request;
6373
+ const _queryParams = {
6374
+ contextId
6375
+ };
6034
6376
  const _authRequest = await this._options.authProvider.getAuthRequest();
6035
6377
  const _headers = mergeHeaders(
6036
6378
  _authRequest.headers,
@@ -6045,7 +6387,7 @@ var IdentityClient = class {
6045
6387
  method: "PUT",
6046
6388
  headers: _headers,
6047
6389
  contentType: "application/json",
6048
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6390
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6049
6391
  requestType: "json",
6050
6392
  body: _body,
6051
6393
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -6085,14 +6427,18 @@ var IdentityClient = class {
6085
6427
  * @example
6086
6428
  * await client.identity.deleteEntity({
6087
6429
  * namespace: "team",
6088
- * id: "id"
6430
+ * id: "id",
6431
+ * contextId: "myapp"
6089
6432
  * })
6090
6433
  */
6091
6434
  deleteEntity(request, requestOptions) {
6092
6435
  return HttpResponsePromise.fromPromise(this.__deleteEntity(request, requestOptions));
6093
6436
  }
6094
6437
  async __deleteEntity(request, requestOptions) {
6095
- const { namespace, id } = request;
6438
+ const { namespace, id, contextId } = request;
6439
+ const _queryParams = {
6440
+ contextId
6441
+ };
6096
6442
  const _authRequest = await this._options.authProvider.getAuthRequest();
6097
6443
  const _headers = mergeHeaders(
6098
6444
  _authRequest.headers,
@@ -6106,7 +6452,7 @@ var IdentityClient = class {
6106
6452
  ),
6107
6453
  method: "DELETE",
6108
6454
  headers: _headers,
6109
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6455
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6110
6456
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6111
6457
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6112
6458
  abortSignal: requestOptions?.abortSignal,
@@ -6149,6 +6495,7 @@ var IdentityClient = class {
6149
6495
  * @example
6150
6496
  * await client.identity.lookupEntities({
6151
6497
  * namespace: "team",
6498
+ * contextId: "myapp",
6152
6499
  * body: {
6153
6500
  * type: "person_v1",
6154
6501
  * field: "ssn"
@@ -6159,7 +6506,10 @@ var IdentityClient = class {
6159
6506
  return HttpResponsePromise.fromPromise(this.__lookupEntities(request, requestOptions));
6160
6507
  }
6161
6508
  async __lookupEntities(request, requestOptions) {
6162
- const { namespace, body: _body } = request;
6509
+ const { namespace, contextId, body: _body } = request;
6510
+ const _queryParams = {
6511
+ contextId
6512
+ };
6163
6513
  const _authRequest = await this._options.authProvider.getAuthRequest();
6164
6514
  const _headers = mergeHeaders(
6165
6515
  _authRequest.headers,
@@ -6174,7 +6524,7 @@ var IdentityClient = class {
6174
6524
  method: "POST",
6175
6525
  headers: _headers,
6176
6526
  contentType: "application/json",
6177
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6527
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6178
6528
  requestType: "json",
6179
6529
  body: _body,
6180
6530
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -6218,15 +6568,17 @@ var IdentityClient = class {
6218
6568
  * @example
6219
6569
  * await client.identity.getEntityVersions({
6220
6570
  * namespace: "team",
6221
- * id: "id"
6571
+ * id: "id",
6572
+ * contextId: "myapp"
6222
6573
  * })
6223
6574
  */
6224
6575
  getEntityVersions(request, requestOptions) {
6225
6576
  return HttpResponsePromise.fromPromise(this.__getEntityVersions(request, requestOptions));
6226
6577
  }
6227
6578
  async __getEntityVersions(request, requestOptions) {
6228
- const { namespace, id, startFrom } = request;
6579
+ const { namespace, id, contextId, startFrom } = request;
6229
6580
  const _queryParams = {
6581
+ contextId,
6230
6582
  startFrom
6231
6583
  };
6232
6584
  const _authRequest = await this._options.authProvider.getAuthRequest();
@@ -6288,7 +6640,10 @@ var IdentityClient = class {
6288
6640
  return HttpResponsePromise.fromPromise(this.__getNamespace(request, requestOptions));
6289
6641
  }
6290
6642
  async __getNamespace(request, requestOptions) {
6291
- const { namespace } = request;
6643
+ const { namespace, contextId } = request;
6644
+ const _queryParams = {
6645
+ contextId
6646
+ };
6292
6647
  const _authRequest = await this._options.authProvider.getAuthRequest();
6293
6648
  const _headers = mergeHeaders(
6294
6649
  _authRequest.headers,
@@ -6302,7 +6657,7 @@ var IdentityClient = class {
6302
6657
  ),
6303
6658
  method: "GET",
6304
6659
  headers: _headers,
6305
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6660
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6306
6661
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6307
6662
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6308
6663
  abortSignal: requestOptions?.abortSignal,
@@ -6327,7 +6682,7 @@ var IdentityClient = class {
6327
6682
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces/{namespace}");
6328
6683
  }
6329
6684
  /**
6330
- * Updates the mutable fields (`entityBacked`, `defaultSchemaId`, `specificityRank`) of a registered namespace. The namespace name itself is immutable. Requires a root API key. The reserved built-ins cannot be updated.
6685
+ * Updates the mutable fields (`entityBacked`, `defaultSchemaId`, `specificityRank`) of a registered namespace. The namespace name and its `contextId` (which row is selected) are both immutable. Requires a root API key. `org` and `client` are updatable like any other namespace — there is no reserved-built-in exception.
6331
6686
  *
6332
6687
  * @param {Vectros.UpdateNamespaceRequest} request
6333
6688
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6349,7 +6704,10 @@ var IdentityClient = class {
6349
6704
  return HttpResponsePromise.fromPromise(this.__updateNamespace(request, requestOptions));
6350
6705
  }
6351
6706
  async __updateNamespace(request, requestOptions) {
6352
- const { namespace, body: _body } = request;
6707
+ const { namespace, contextId, body: _body } = request;
6708
+ const _queryParams = {
6709
+ contextId
6710
+ };
6353
6711
  const _authRequest = await this._options.authProvider.getAuthRequest();
6354
6712
  const _headers = mergeHeaders(
6355
6713
  _authRequest.headers,
@@ -6364,7 +6722,7 @@ var IdentityClient = class {
6364
6722
  method: "PUT",
6365
6723
  headers: _headers,
6366
6724
  contentType: "application/json",
6367
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6725
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6368
6726
  requestType: "json",
6369
6727
  body: _body,
6370
6728
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -6395,7 +6753,7 @@ var IdentityClient = class {
6395
6753
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/namespaces/{namespace}");
6396
6754
  }
6397
6755
  /**
6398
- * Deletes a registered scope namespace. Requires a root API key. The reserved built-ins cannot be deleted. A namespace that still has entities cannot be deleted (409) — delete its entities first; this keeps them reachable by the account-teardown and erasure sweeps.
6756
+ * Deletes a registered scope namespace. Requires a root API key. `org` and `client` are deletable like any other namespace — there is no reserved-built-in exception. A namespace that still has entities cannot be deleted (409) — delete its entities first; this keeps them reachable by the account-teardown and erasure sweeps.
6399
6757
  *
6400
6758
  * @param {Vectros.DeleteNamespaceRequest} request
6401
6759
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6413,7 +6771,10 @@ var IdentityClient = class {
6413
6771
  return HttpResponsePromise.fromPromise(this.__deleteNamespace(request, requestOptions));
6414
6772
  }
6415
6773
  async __deleteNamespace(request, requestOptions) {
6416
- const { namespace } = request;
6774
+ const { namespace, contextId } = request;
6775
+ const _queryParams = {
6776
+ contextId
6777
+ };
6417
6778
  const _authRequest = await this._options.authProvider.getAuthRequest();
6418
6779
  const _headers = mergeHeaders(
6419
6780
  _authRequest.headers,
@@ -6427,7 +6788,7 @@ var IdentityClient = class {
6427
6788
  ),
6428
6789
  method: "DELETE",
6429
6790
  headers: _headers,
6430
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6791
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6431
6792
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6432
6793
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6433
6794
  abortSignal: requestOptions?.abortSignal,
@@ -6456,7 +6817,7 @@ var IdentityClient = class {
6456
6817
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/namespaces/{namespace}");
6457
6818
  }
6458
6819
  /**
6459
- * Returns the scope namespaces registered in your account, with the reserved built-ins `org` and `client` listed first. Returns a `{data, nextCursor}` envelope.
6820
+ * Returns the scope namespaces in your account, including `org` and `client`, which are provisioned for you when the account is created. Returns a `{data, nextCursor}` envelope.
6460
6821
  *
6461
6822
  * @param {Vectros.ListNamespacesRequest} request
6462
6823
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6468,10 +6829,11 @@ var IdentityClient = class {
6468
6829
  return HttpResponsePromise.fromPromise(this.__listNamespaces(request, requestOptions));
6469
6830
  }
6470
6831
  async __listNamespaces(request = {}, requestOptions) {
6471
- const { startFrom, limit } = request;
6832
+ const { startFrom, limit, contextId } = request;
6472
6833
  const _queryParams = {
6473
6834
  startFrom,
6474
- limit
6835
+ limit,
6836
+ contextId
6475
6837
  };
6476
6838
  const _authRequest = await this._options.authProvider.getAuthRequest();
6477
6839
  const _headers = mergeHeaders(
@@ -6506,9 +6868,9 @@ var IdentityClient = class {
6506
6868
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces");
6507
6869
  }
6508
6870
  /**
6509
- * Registers a new scope namespace and declares whether its values resolve to identity entities (`entityBacked`). Also requires `specificityRank`, an explicit, account-unique position in the specificity order used to break recordType schema-resolution ties. Requires a root API key. The reserved names `org` and `client` are built in and cannot be registered.
6871
+ * Registers a new scope namespace and declares whether its values resolve to identity entities (`entityBacked`). Also requires `specificityRank`, an explicit, account-unique position in the specificity order used to break recordType schema-resolution ties. Requires a root API key or the CLI bootstrap's provisioning capability — never an ordinary partner-grantable scope. `org` and `client` are provisioned when your account is created, so registering either returns the already-registered error.
6510
6872
  *
6511
- * @param {Vectros.NamespaceRequest} request
6873
+ * @param {Vectros.RegisterNamespaceRequest} request
6512
6874
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6513
6875
  *
6514
6876
  * @throws {@link Vectros.BadRequestError}
@@ -6517,14 +6879,20 @@ var IdentityClient = class {
6517
6879
  *
6518
6880
  * @example
6519
6881
  * await client.identity.registerNamespace({
6520
- * namespace: "team",
6521
- * specificityRank: 1500
6882
+ * body: {
6883
+ * namespace: "team",
6884
+ * specificityRank: 1500
6885
+ * }
6522
6886
  * })
6523
6887
  */
6524
6888
  registerNamespace(request, requestOptions) {
6525
6889
  return HttpResponsePromise.fromPromise(this.__registerNamespace(request, requestOptions));
6526
6890
  }
6527
6891
  async __registerNamespace(request, requestOptions) {
6892
+ const { contextId, body: _body } = request;
6893
+ const _queryParams = {
6894
+ contextId
6895
+ };
6528
6896
  const _authRequest = await this._options.authProvider.getAuthRequest();
6529
6897
  const _headers = mergeHeaders(
6530
6898
  _authRequest.headers,
@@ -6539,9 +6907,9 @@ var IdentityClient = class {
6539
6907
  method: "POST",
6540
6908
  headers: _headers,
6541
6909
  contentType: "application/json",
6542
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6910
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6543
6911
  requestType: "json",
6544
- body: request,
6912
+ body: _body,
6545
6913
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6546
6914
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6547
6915
  abortSignal: requestOptions?.abortSignal,
@@ -6826,12 +7194,13 @@ var IdentityClient = class {
6826
7194
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/users/{id}");
6827
7195
  }
6828
7196
  /**
6829
- * Permanently deletes a user identity. This cannot be undone. If the user is a pending invitation, the associated access profile created for that invitation is also removed. Requires the `users:d` scope.
7197
+ * Permanently deletes a user identity. This cannot be undone. If the user is a pending invitation, the associated access profile created for that invitation is also removed. Requires the `users:d` scope. Deleting your account's last OWNER is refused (409) — an account must always retain at least one owner.
6830
7198
  *
6831
7199
  * @param {Vectros.DeleteUserRequest} request
6832
7200
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6833
7201
  *
6834
7202
  * @throws {@link Vectros.NotFoundError}
7203
+ * @throws {@link Vectros.ConflictError}
6835
7204
  * @throws {@link Vectros.TooManyRequestsError}
6836
7205
  *
6837
7206
  * @example
@@ -6871,6 +7240,8 @@ var IdentityClient = class {
6871
7240
  switch (_response.error.statusCode) {
6872
7241
  case 404:
6873
7242
  throw new NotFoundError(_response.error.body, _response.rawResponse);
7243
+ case 409:
7244
+ throw new ConflictError(_response.error.body, _response.rawResponse);
6874
7245
  case 429:
6875
7246
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
6876
7247
  default:
@@ -6944,6 +7315,69 @@ var IdentityClient = class {
6944
7315
  }
6945
7316
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/users/lookup");
6946
7317
  }
7318
+ /**
7319
+ * Answers "does a user with this email hold an ACTIVE access profile in this app context" — a narrow existence check, not a general lookup. `exists` is false for a member whose access to this context has been suspended, not only for a member who was never granted it. The answer is scoped to the `contextId` you supply: it does not reveal whether the email exists elsewhere in your tenant or account, only whether it belongs to an active member of the named context. Returns `{exists, userId, status}` — never the full user record — so a caller asking "does X exist" cannot receive that user's payload/schema binding/etc. as a side effect. Useful for resolving an email you were handed (for example, by an org-admin adding an existing member to another org) to a `userId`, without paging through the full context membership. Requires the `users:r` scope.
7320
+ *
7321
+ * @param {Vectros.UserExistsByEmailRequest} request
7322
+ * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
7323
+ *
7324
+ * @throws {@link Vectros.BadRequestError}
7325
+ * @throws {@link Vectros.ForbiddenError}
7326
+ *
7327
+ * @example
7328
+ * await client.identity.userExistsByEmail({
7329
+ * email: "user@example.com",
7330
+ * contextId: "myapp"
7331
+ * })
7332
+ */
7333
+ userExistsByEmail(request = {}, requestOptions) {
7334
+ return HttpResponsePromise.fromPromise(this.__userExistsByEmail(request, requestOptions));
7335
+ }
7336
+ async __userExistsByEmail(request = {}, requestOptions) {
7337
+ const { email, contextId } = request;
7338
+ const _queryParams = {
7339
+ email,
7340
+ contextId
7341
+ };
7342
+ const _authRequest = await this._options.authProvider.getAuthRequest();
7343
+ const _headers = mergeHeaders(
7344
+ _authRequest.headers,
7345
+ this._options?.headers,
7346
+ requestOptions?.headers
7347
+ );
7348
+ const _response = await fetcher({
7349
+ url: url_exports.join(
7350
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
7351
+ "v1/users/exists-by-email"
7352
+ ),
7353
+ method: "GET",
7354
+ headers: _headers,
7355
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
7356
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
7357
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
7358
+ abortSignal: requestOptions?.abortSignal,
7359
+ fetchFn: this._options?.fetch,
7360
+ logging: this._options.logging
7361
+ });
7362
+ if (_response.ok) {
7363
+ return { data: _response.body, rawResponse: _response.rawResponse };
7364
+ }
7365
+ if (_response.error.reason === "status-code") {
7366
+ switch (_response.error.statusCode) {
7367
+ case 400:
7368
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
7369
+ case 403:
7370
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
7371
+ default:
7372
+ throw new VectrosError({
7373
+ statusCode: _response.error.statusCode,
7374
+ body: _response.error.body,
7375
+ rawResponse: _response.rawResponse
7376
+ });
7377
+ }
7378
+ }
7379
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/users/exists-by-email");
7380
+ }
6947
7381
  /**
6948
7382
  * 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.
6949
7383
  *
@@ -8700,15 +9134,15 @@ function warnOnSuboptimalKey(key, log) {
8700
9134
  } else if (key.prefix === "st") {
8701
9135
  log.warn(
8702
9136
  { prefix: key.prefix, env: key.env },
8703
- "short-lived token (st_*) will expire mid-session (1h default, 24h max). For long-running MCP installs, prefer a long-lived ssk_* key."
9137
+ "short-lived token (st_*) will expire mid-session (1h max). For long-running MCP installs, prefer a long-lived ssk_* key."
8704
9138
  );
8705
9139
  }
8706
9140
  }
8707
9141
 
8708
9142
  // src/build-info.ts
8709
9143
  var BUILD_INFO = {
8710
- mcpServer: true ? "0.13.0" : "dev",
8711
- sdk: true ? "0.38.0" : "dev"
9144
+ mcpServer: true ? "0.15.0" : "dev",
9145
+ sdk: true ? "0.40.0" : "dev"
8712
9146
  };
8713
9147
 
8714
9148
  // src/log.ts
@@ -9016,7 +9450,7 @@ var inputSchema = {
9016
9450
  // Ownership.
9017
9451
  userId: import_zod.z.string().optional().describe("Restrict to content owned by this user (Vectros UUID)."),
9018
9452
  scope: import_zod.z.string().optional().describe(
9019
- 'Restrict to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
9453
+ '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.'
9020
9454
  ),
9021
9455
  // Date window.
9022
9456
  createdAfter: import_zod.z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
@@ -9156,7 +9590,7 @@ var inputSchema2 = {
9156
9590
  // List-mode args:
9157
9591
  userId: import_zod2.z.string().optional().describe("List mode: scope to records owned by this user."),
9158
9592
  scope: import_zod2.z.string().optional().describe(
9159
- 'List mode: filter to records carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
9593
+ '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.'
9160
9594
  ),
9161
9595
  startFrom: import_zod2.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."),
9162
9596
  limit: import_zod2.z.number().int().min(1).max(MCP_MAX_LIMIT2).optional().describe(
@@ -9407,7 +9841,7 @@ var inputSchema4 = {
9407
9841
  folderId: import_zod4.z.string().optional().describe("Group this record into a folder."),
9408
9842
  userId: import_zod4.z.string().optional().describe("Owning user id."),
9409
9843
  scopes: import_zod4.z.array(import_zod4.z.string()).optional().describe(
9410
- 'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are built-in namespaces; others are custom scopes you define. This is the record\'s COMPLETE scope declaration and values must come from the credential\'s own identity. An empty array `[]` creates a PRIVATE record owned by the calling user alone. Omit to stamp the credential\'s full identity \u2014 the default.'
9844
+ '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.'
9411
9845
  )
9412
9846
  };
9413
9847
  var recordCreate = ({ client, log }) => ({
@@ -9531,7 +9965,7 @@ var inputSchema7 = {
9531
9965
  // whole-tenant corpus.
9532
9966
  userId: import_zod7.z.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
9533
9967
  scope: import_zod7.z.string().optional().describe(
9534
- 'Restrict retrieval to content carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
9968
+ '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.'
9535
9969
  ),
9536
9970
  folderId: import_zod7.z.string().optional().describe("Restrict retrieval to this exact folder."),
9537
9971
  rootFolderId: import_zod7.z.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
@@ -9705,7 +10139,7 @@ var inputSchema9 = {
9705
10139
  "Filter to schemas visible to a specific user. Optional; default returns all schemas the credential can see."
9706
10140
  ),
9707
10141
  scope: import_zod9.z.string().optional().describe(
9708
- 'Filter to schemas carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces. Optional; default returns all schemas the credential can see.'
10142
+ '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.'
9709
10143
  ),
9710
10144
  surface: import_zod9.z.enum(["record", "document", "user", "entity"]).optional().describe(
9711
10145
  "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."
@@ -9855,7 +10289,7 @@ var inputSchema11 = {
9855
10289
  folderId: import_zod11.z.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
9856
10290
  userId: import_zod11.z.string().optional().describe("List mode: scope to documents owned by this user."),
9857
10291
  scope: import_zod11.z.string().optional().describe(
9858
- 'List mode: filter to documents carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
10292
+ '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.'
9859
10293
  ),
9860
10294
  startFrom: import_zod11.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."),
9861
10295
  limit: import_zod11.z.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
@@ -9966,7 +10400,7 @@ var inputSchema12 = {
9966
10400
  ),
9967
10401
  userId: import_zod12.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
9968
10402
  scopes: import_zod12.z.array(import_zod12.z.string()).optional().describe(
9969
- 'Reassign scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]) \u2014 the COMPLETE new parent set. `org`/`client` are built-in namespaces. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
10403
+ '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).'
9970
10404
  ),
9971
10405
  expectedVersion: import_zod12.z.number().int().optional().describe(
9972
10406
  "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."
@@ -10050,7 +10484,7 @@ var inputSchema14 = {
10050
10484
  parentId: import_zod14.z.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
10051
10485
  userId: import_zod14.z.string().optional().describe("List mode: scope to folders owned by this user."),
10052
10486
  scope: import_zod14.z.string().optional().describe(
10053
- 'List mode: filter to folders carrying this scope value, in `namespace:value` form (e.g. "org:<uuid>", "client:<uuid>", "group:eng-team"). `org` and `client` are built-in namespaces; others are custom scopes you define.'
10487
+ '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.'
10054
10488
  ),
10055
10489
  startFrom: import_zod14.z.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
10056
10490
  limit: import_zod14.z.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
@@ -10099,7 +10533,7 @@ var inputSchema15 = {
10099
10533
  slug: import_zod15.z.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
10100
10534
  userId: import_zod15.z.string().optional().describe("Owning user (Vectros UUID)."),
10101
10535
  scopes: import_zod15.z.array(import_zod15.z.string()).optional().describe(
10102
- 'Scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]). `org` and `client` are built-in namespaces; others are custom scopes you define. This is the folder\'s COMPLETE scope declaration and values must come from the credential\'s own identity. An empty array `[]` creates a PRIVATE folder owned by the calling user alone. Omit to stamp the credential\'s full identity \u2014 the default.'
10536
+ '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.'
10103
10537
  )
10104
10538
  };
10105
10539
  var folderCreate = ({ client, log }) => ({
@@ -10137,7 +10571,7 @@ var inputSchema16 = {
10137
10571
  description: import_zod16.z.string().optional().describe("New description. Omit to leave unchanged."),
10138
10572
  userId: import_zod16.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10139
10573
  scopes: import_zod16.z.array(import_zod16.z.string()).optional().describe(
10140
- 'Reassign scope ownership as `namespace:value` entries, at most 2 (e.g. ["org:<uuid>", "group:eng-team"]) \u2014 the COMPLETE new parent set. `org`/`client` are built-in namespaces. Omit to leave ownership unchanged; `[]` clears it (private to the owning user).'
10574
+ '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).'
10141
10575
  ),
10142
10576
  expectedVersion: import_zod16.z.number().int().optional().describe(
10143
10577
  "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."
@@ -10204,7 +10638,7 @@ var inputSchema18 = {
10204
10638
  var currentIdentity = ({ log, apiKey, environment }) => ({
10205
10639
  name: "current_identity",
10206
10640
  title: "Current identity (tenant + principal scope)",
10207
- 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 reach as { userId, scopes[] }, where each scope is a `namespace:value` string (e.g. \"org:<uuid>\"). 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.",
10641
+ description: "Describe the credential the MCP server is operating under. Returns tenantId, environment (staging|production), principalType (root_key|scoped_key|token), principalKeyId, principalLabel, and (for scoped credentials) allowedActions plus dataScope \u2014 the credential's verb+ownership reach as { userId, scopes[] }, where each scope is a `namespace:value` string (e.g. \"org:<uuid>\"). Note: this does not yet include granted_capabilities (member-lifecycle / forensic-read / context-directory-read / delegate-mint) \u2014 a separate reach dimension a scope clause can carry as of API 0.40.0 that /v1/ping does not report yet, so allowedActions+dataScope may understate a credential's true reach. Also reports mcpServerVersion (this server's own package version) and sdkVersion (the bundled @vectros-ai/sdk version) so a caller can tell what build it's talking to. Use this when the user asks 'what can you do here?', 'what tenant am I in?', or 'what version is this?'. Calls GET /v1/ping under the hood.",
10208
10642
  inputSchema: inputSchema18,
10209
10643
  handler: async () => {
10210
10644
  try {
@@ -10327,7 +10761,7 @@ var inputSchema19 = {
10327
10761
  folderId: import_zod18.z.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
10328
10762
  userId: import_zod18.z.string().optional().describe("Owning user ID. Optional."),
10329
10763
  scopes: import_zod18.z.array(import_zod18.z.string()).optional().describe(
10330
- "TEXT MODE ONLY. Scope ownership as `namespace:value` entries, at most 2 (e.g. [\"org:<uuid>\", \"group:eng-team\"]). `org` and `client` are built-in namespaces; others are custom scopes you define. This is the document's COMPLETE scope declaration and values must come from the credential's own identity. An empty array `[]` creates a PRIVATE document owned by the calling user alone. Omit to stamp the credential's full identity \u2014 the default. Rejected with `filePath` (file uploads do not accept a scope declaration): a file-uploaded document is stamped with the credential's full identity."
10764
+ "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."
10331
10765
  )
10332
10766
  };
10333
10767
  var documentIngest = ({ client, log, transport, ingestRoot }) => ({
@@ -10491,11 +10925,14 @@ var MCP_DEFAULT_LIMIT5 = 10;
10491
10925
  var MCP_MAX_LIMIT5 = 100;
10492
10926
  var inputSchema20 = {
10493
10927
  kind: import_zod19.z.string().describe(
10494
- 'Which principal to look up: "user" (the fixed principal surface), or an entity namespace \u2014 "org", "client" (built in), or a namespace you registered.'
10928
+ '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.'
10495
10929
  ),
10496
10930
  externalId: import_zod19.z.string().optional().describe(
10497
10931
  "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."
10498
10932
  ),
10933
+ contextId: import_zod19.z.string().optional().describe(
10934
+ "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."
10935
+ ),
10499
10936
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
10500
10937
  type: import_zod19.z.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
10501
10938
  field: import_zod19.z.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
@@ -10512,13 +10949,14 @@ var inputSchema20 = {
10512
10949
  var lookupPrincipal = ({ client, log }) => ({
10513
10950
  name: "lookup_principal",
10514
10951
  title: "Look up a user identity or a namespaced identity entity",
10515
- description: "Resolve a user, or an identity entity in a namespace (org/client/one you registered). Two modes:\n \u2022 Resolve by your own id: pass `externalId` \u2192 the matching principal incl. its Vectros UUID (the id the ownership filters on record_query / hybrid_search / rag_ask expect).\n \u2022 Lookup by a schema field: pass `type` and `field` plus exactly one of `value` (exact), `from`+`to` (range), or `prefix`. Sensitive-field-safe. (If both `externalId` and a `field` lookup are given, `externalId` wins.) Returns a `{ data, nextCursor }` page (default 10, max 100 \u2014 raise it in one call when you can accept the payload); a non-null `nextCursor` means more remain \u2014 pass it back as `startFrom`. Read-only \u2014 does not create or modify identities.",
10952
+ 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.",
10516
10953
  inputSchema: inputSchema20,
10517
10954
  handler: async (args) => {
10518
10955
  const kind = args.kind;
10519
10956
  const isUser = kind === "user";
10520
10957
  const limit = args.limit ?? MCP_DEFAULT_LIMIT5;
10521
10958
  const externalId = args.externalId;
10959
+ const contextId = args.contextId;
10522
10960
  const type = args.type;
10523
10961
  const field = args.field;
10524
10962
  const value = args.value;
@@ -10527,11 +10965,18 @@ var lookupPrincipal = ({ client, log }) => ({
10527
10965
  const prefix = args.prefix;
10528
10966
  const order = args.order;
10529
10967
  const startFrom = args.startFrom;
10968
+ if (contextId !== void 0 && isUser) {
10969
+ return toolError(
10970
+ "lookup_principal",
10971
+ new Error("'contextId' does not apply to kind 'user' \u2014 the user surface is always tenant-wide.")
10972
+ );
10973
+ }
10974
+ const contextIdArg = contextId !== void 0 ? { contextId } : {};
10530
10975
  try {
10531
10976
  let page;
10532
10977
  if (externalId !== void 0) {
10533
- page = isUser ? await client.identity.listUsers({ externalId, limit }) : await client.identity.listEntities({ namespace: kind, externalId, limit });
10534
- log.debug({ tool: "lookup_principal", mode: "resolve", kind }, "lookup_principal resolve ok");
10978
+ page = isUser ? await client.identity.listUsers({ externalId, limit }) : await client.identity.listEntities({ namespace: kind, ...contextIdArg, externalId, limit });
10979
+ log.debug({ tool: "lookup_principal", mode: "resolve", kind, contextId }, "lookup_principal resolve ok");
10535
10980
  } else if (field !== void 0) {
10536
10981
  const hasEquality = value !== void 0;
10537
10982
  const hasRange = from !== void 0 || to !== void 0;
@@ -10559,8 +11004,8 @@ var lookupPrincipal = ({ client, log }) => ({
10559
11004
  );
10560
11005
  }
10561
11006
  const req = { type, field, value, from, to, prefix, order, startFrom, limit };
10562
- page = isUser ? await client.identity.lookupUsers(req) : await client.identity.lookupEntities({ namespace: kind, body: req });
10563
- log.debug({ tool: "lookup_principal", mode: "lookup", kind, type, field }, "lookup_principal lookup ok");
11007
+ page = isUser ? await client.identity.lookupUsers(req) : await client.identity.lookupEntities({ namespace: kind, ...contextIdArg, body: req });
11008
+ log.debug({ tool: "lookup_principal", mode: "lookup", kind, type, field, contextId }, "lookup_principal lookup ok");
10564
11009
  } else {
10565
11010
  return toolError(
10566
11011
  "lookup_principal",
@@ -10571,7 +11016,7 @@ var lookupPrincipal = ({ client, log }) => ({
10571
11016
  const nextCursor = page.nextCursor ?? null;
10572
11017
  return { content: [{ type: "text", text: JSON.stringify({ data: principals, nextCursor }, null, 2) }] };
10573
11018
  } catch (err) {
10574
- log.warn({ tool: "lookup_principal", kind, err: String(err) }, "lookup_principal failed");
11019
+ log.warn({ tool: "lookup_principal", kind, contextId, err: String(err) }, "lookup_principal failed");
10575
11020
  return toolError("lookup_principal", err);
10576
11021
  }
10577
11022
  }
@@ -10682,7 +11127,7 @@ var identityResource = ({ log, apiKey, environment }) => ({
10682
11127
  name: "identity",
10683
11128
  uri: "vectros://identity",
10684
11129
  title: "Current identity (tenant + principal scope)",
10685
- description: "The tenant + principal scope the MCP server is authenticated as. Returns the same payload as the `current_identity` tool: status, tenantId, environment, principalType, principalKeyId, principalLabel, (for scoped credentials) allowedActions + dataScope ({ userId, scopes[] }), plus mcpServerVersion and sdkVersion (this build's own version and the bundled @vectros-ai/sdk version). The /v1/ping backing call ships the extended shape today; the version fields are always client-derived.",
11130
+ description: "The tenant + principal scope the MCP server is authenticated as. Returns the same payload as the `current_identity` tool: status, tenantId, environment, principalType, principalKeyId, principalLabel, (for scoped credentials) allowedActions + dataScope ({ userId, scopes[] }). Note: this does not yet include granted_capabilities (member-lifecycle / forensic-read / context-directory-read / delegate-mint) \u2014 a separate reach dimension a scope clause can carry as of API 0.40.0 that /v1/ping does not report yet, so allowedActions+dataScope may understate a credential's true reach. Also reports mcpServerVersion and sdkVersion (this build's own version and the bundled @vectros-ai/sdk version). The /v1/ping backing call ships the extended shape today; the version fields are always client-derived.",
10686
11131
  mimeType: "application/json",
10687
11132
  read: async () => {
10688
11133
  const identity = await resolveIdentity({ log, apiKey, environment });