@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/cli.js CHANGED
@@ -87,6 +87,7 @@ __export(api_exports, {
87
87
  TooManyRequestsError: () => TooManyRequestsError,
88
88
  TruncationWarningEvent: () => TruncationWarningEvent,
89
89
  UnauthorizedError: () => UnauthorizedError,
90
+ UserExistsResponse: () => UserExistsResponse,
90
91
  UserRequest: () => UserRequest,
91
92
  UserResponse: () => UserResponse,
92
93
  auth: () => auth_exports,
@@ -763,6 +764,14 @@ var TruncationWarningEvent;
763
764
  ContextWindowBudget: "context_window_budget"
764
765
  };
765
766
  })(TruncationWarningEvent || (TruncationWarningEvent = {}));
767
+ var UserExistsResponse;
768
+ ((UserExistsResponse2) => {
769
+ UserExistsResponse2.Status = {
770
+ Active: "ACTIVE",
771
+ Suspended: "SUSPENDED",
772
+ Pending: "PENDING"
773
+ };
774
+ })(UserExistsResponse || (UserExistsResponse = {}));
766
775
  var UserRequest;
767
776
  ((UserRequest2) => {
768
777
  UserRequest2.Status = {
@@ -2506,7 +2515,7 @@ var AuthClient = class {
2506
2515
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/admin/keys/scoped");
2507
2516
  }
2508
2517
  /**
2509
- * 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.
2518
+ * Creates a scoped API key (an `ssk_*` secret) that inherits its permissions from an existing access profile in your account. The call is idempotent on the combination of tenant, context, user, and key name: re-issuing the same request returns the existing key WITHOUT re-disclosing its raw secret. The raw key is returned ONLY in this response — store it securely, as it cannot be retrieved again. Requires the `keys:c` scope. If you use a scoped credential, `keys:c` alone is not sufficient: because the minted key is durably bound to the profile you name, the profile's effective scopes may not exceed your own, and you may only mint against a profile whose `identityOverrides` values your own identity holds. A root API key (`sk_`) is exempt from both bounds.
2510
2519
  *
2511
2520
  * @param {Vectros.CreateScopedKeyRequest} request
2512
2521
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -2838,7 +2847,7 @@ var AuthClient = class {
2838
2847
  );
2839
2848
  }
2840
2849
  /**
2841
- * 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.
2850
+ * 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.
2842
2851
  *
2843
2852
  * @param {Vectros.CreateAccessProfileRequest} request
2844
2853
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3256,11 +3265,12 @@ var AuthClient = class {
3256
3265
  );
3257
3266
  }
3258
3267
  /**
3259
- * 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.
3268
+ * 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.
3260
3269
  *
3261
3270
  * @param {Vectros.UpdateAccessProfileRequest} request
3262
3271
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
3263
3272
  *
3273
+ * @throws {@link Vectros.BadRequestError}
3264
3274
  * @throws {@link Vectros.ForbiddenError}
3265
3275
  * @throws {@link Vectros.NotFoundError}
3266
3276
  * @throws {@link Vectros.TooManyRequestsError}
@@ -3307,6 +3317,8 @@ var AuthClient = class {
3307
3317
  }
3308
3318
  if (_response.error.reason === "status-code") {
3309
3319
  switch (_response.error.statusCode) {
3320
+ case 400:
3321
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
3310
3322
  case 403:
3311
3323
  throw new ForbiddenError(_response.error.body, _response.rawResponse);
3312
3324
  case 404:
@@ -3936,7 +3948,7 @@ var AuthClient = class {
3936
3948
  );
3937
3949
  }
3938
3950
  /**
3939
- * 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.
3951
+ * Returns full usage detail for the requested calendar month, broken down by category (search, documents, and records) with per-category credit estimates and a split between your live and test environments. Defaults to the current month when `year` and `month` are omitted. Requires the `billing:r` scope on scoped tokens; API keys always have access. **A token confined to a single app context sees only that context's usage**: totals, the environment split, and the `contexts` breakdown narrow to it, and the environment your context is not bound to is omitted (`null`), not zeroed. Only a token with cross-context reach sees your full account-wide totals. Two exceptions to the narrowing, since they have no per-context breakdown to narrow to: `reads.calls.used`/`reads.dataOut.bytes` (metered per account, not per context) read as `0` for a confined token rather than a narrowed figure — the corresponding overage-credit charge fields narrow correctly; and `credits.limit` stays your whole plan's ceiling, so `credits.remaining` may overstate the account's true remaining room.
3940
3952
  *
3941
3953
  * @param {Vectros.GetUsageRequest} request
3942
3954
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -3998,6 +4010,257 @@ var AuthClient = class {
3998
4010
  }
3999
4011
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/usage");
4000
4012
  }
4013
+ /**
4014
+ * 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.
4015
+ *
4016
+ * @param {Vectros.GetIssuerRequest} request
4017
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4018
+ *
4019
+ * @throws {@link Vectros.ForbiddenError}
4020
+ * @throws {@link Vectros.NotFoundError}
4021
+ *
4022
+ * @example
4023
+ * await client.auth.getIssuer({
4024
+ * issuerId: "auth0-prod"
4025
+ * })
4026
+ */
4027
+ getIssuer(request, requestOptions) {
4028
+ return HttpResponsePromise.fromPromise(this.__getIssuer(request, requestOptions));
4029
+ }
4030
+ async __getIssuer(request, requestOptions) {
4031
+ const { issuerId } = request;
4032
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4033
+ const _headers = mergeHeaders(
4034
+ _authRequest.headers,
4035
+ this._options?.headers,
4036
+ requestOptions?.headers
4037
+ );
4038
+ const _response = await fetcher({
4039
+ url: url_exports.join(
4040
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4041
+ `v1/auth/issuers/${url_exports.encodePathParam(issuerId)}`
4042
+ ),
4043
+ method: "GET",
4044
+ headers: _headers,
4045
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4046
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4047
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4048
+ abortSignal: requestOptions?.abortSignal,
4049
+ fetchFn: this._options?.fetch,
4050
+ logging: this._options.logging
4051
+ });
4052
+ if (_response.ok) {
4053
+ return { data: _response.body, rawResponse: _response.rawResponse };
4054
+ }
4055
+ if (_response.error.reason === "status-code") {
4056
+ switch (_response.error.statusCode) {
4057
+ case 403:
4058
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4059
+ case 404:
4060
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
4061
+ default:
4062
+ throw new VectrosError({
4063
+ statusCode: _response.error.statusCode,
4064
+ body: _response.error.body,
4065
+ rawResponse: _response.rawResponse
4066
+ });
4067
+ }
4068
+ }
4069
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/auth/issuers/{issuerId}");
4070
+ }
4071
+ /**
4072
+ * 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.
4073
+ *
4074
+ * @param {Vectros.DeleteIssuerRequest} request
4075
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4076
+ *
4077
+ * @throws {@link Vectros.ForbiddenError}
4078
+ * @throws {@link Vectros.NotFoundError}
4079
+ * @throws {@link Vectros.ConflictError}
4080
+ * @throws {@link Vectros.TooManyRequestsError}
4081
+ *
4082
+ * @example
4083
+ * await client.auth.deleteIssuer({
4084
+ * issuerId: "auth0-prod"
4085
+ * })
4086
+ */
4087
+ deleteIssuer(request, requestOptions) {
4088
+ return HttpResponsePromise.fromPromise(this.__deleteIssuer(request, requestOptions));
4089
+ }
4090
+ async __deleteIssuer(request, requestOptions) {
4091
+ const { issuerId } = request;
4092
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4093
+ const _headers = mergeHeaders(
4094
+ _authRequest.headers,
4095
+ this._options?.headers,
4096
+ requestOptions?.headers
4097
+ );
4098
+ const _response = await fetcher({
4099
+ url: url_exports.join(
4100
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4101
+ `v1/auth/issuers/${url_exports.encodePathParam(issuerId)}`
4102
+ ),
4103
+ method: "DELETE",
4104
+ headers: _headers,
4105
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4106
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4107
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4108
+ abortSignal: requestOptions?.abortSignal,
4109
+ fetchFn: this._options?.fetch,
4110
+ logging: this._options.logging
4111
+ });
4112
+ if (_response.ok) {
4113
+ return { data: void 0, rawResponse: _response.rawResponse };
4114
+ }
4115
+ if (_response.error.reason === "status-code") {
4116
+ switch (_response.error.statusCode) {
4117
+ case 403:
4118
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4119
+ case 404:
4120
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
4121
+ case 409:
4122
+ throw new ConflictError(_response.error.body, _response.rawResponse);
4123
+ case 429:
4124
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
4125
+ default:
4126
+ throw new VectrosError({
4127
+ statusCode: _response.error.statusCode,
4128
+ body: _response.error.body,
4129
+ rawResponse: _response.rawResponse
4130
+ });
4131
+ }
4132
+ }
4133
+ return handleNonStatusCodeError(
4134
+ _response.error,
4135
+ _response.rawResponse,
4136
+ "DELETE",
4137
+ "/v1/auth/issuers/{issuerId}"
4138
+ );
4139
+ }
4140
+ /**
4141
+ * 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.
4142
+ *
4143
+ * @param {Vectros.ListIssuersRequest} request
4144
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4145
+ *
4146
+ * @throws {@link Vectros.ForbiddenError}
4147
+ *
4148
+ * @example
4149
+ * await client.auth.listIssuers()
4150
+ */
4151
+ listIssuers(request = {}, requestOptions) {
4152
+ return HttpResponsePromise.fromPromise(this.__listIssuers(request, requestOptions));
4153
+ }
4154
+ async __listIssuers(request = {}, requestOptions) {
4155
+ const { startFrom, limit } = request;
4156
+ const _queryParams = {
4157
+ startFrom,
4158
+ limit
4159
+ };
4160
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4161
+ const _headers = mergeHeaders(
4162
+ _authRequest.headers,
4163
+ this._options?.headers,
4164
+ requestOptions?.headers
4165
+ );
4166
+ const _response = await fetcher({
4167
+ url: url_exports.join(
4168
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4169
+ "v1/auth/issuers"
4170
+ ),
4171
+ method: "GET",
4172
+ headers: _headers,
4173
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
4174
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4175
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4176
+ abortSignal: requestOptions?.abortSignal,
4177
+ fetchFn: this._options?.fetch,
4178
+ logging: this._options.logging
4179
+ });
4180
+ if (_response.ok) {
4181
+ return { data: _response.body, rawResponse: _response.rawResponse };
4182
+ }
4183
+ if (_response.error.reason === "status-code") {
4184
+ switch (_response.error.statusCode) {
4185
+ case 403:
4186
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4187
+ default:
4188
+ throw new VectrosError({
4189
+ statusCode: _response.error.statusCode,
4190
+ body: _response.error.body,
4191
+ rawResponse: _response.rawResponse
4192
+ });
4193
+ }
4194
+ }
4195
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/auth/issuers");
4196
+ }
4197
+ /**
4198
+ * 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`.
4199
+ *
4200
+ * @param {Vectros.IssuerRequest} request
4201
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4202
+ *
4203
+ * @throws {@link Vectros.BadRequestError}
4204
+ * @throws {@link Vectros.ForbiddenError}
4205
+ * @throws {@link Vectros.TooManyRequestsError}
4206
+ *
4207
+ * @example
4208
+ * await client.auth.registerIssuer({
4209
+ * issuerId: "auth0-prod",
4210
+ * issuer: "https://your-tenant.us.auth0.com/",
4211
+ * jwksUri: "https://your-tenant.us.auth0.com/.well-known/jwks.json",
4212
+ * audience: "https://api.your-app.example.com",
4213
+ * contextId: "casework"
4214
+ * })
4215
+ */
4216
+ registerIssuer(request, requestOptions) {
4217
+ return HttpResponsePromise.fromPromise(this.__registerIssuer(request, requestOptions));
4218
+ }
4219
+ async __registerIssuer(request, requestOptions) {
4220
+ const _authRequest = await this._options.authProvider.getAuthRequest();
4221
+ const _headers = mergeHeaders(
4222
+ _authRequest.headers,
4223
+ this._options?.headers,
4224
+ requestOptions?.headers
4225
+ );
4226
+ const _response = await fetcher({
4227
+ url: url_exports.join(
4228
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4229
+ "v1/auth/issuers"
4230
+ ),
4231
+ method: "POST",
4232
+ headers: _headers,
4233
+ contentType: "application/json",
4234
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4235
+ requestType: "json",
4236
+ body: request,
4237
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4238
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4239
+ abortSignal: requestOptions?.abortSignal,
4240
+ fetchFn: this._options?.fetch,
4241
+ logging: this._options.logging
4242
+ });
4243
+ if (_response.ok) {
4244
+ return { data: _response.body, rawResponse: _response.rawResponse };
4245
+ }
4246
+ if (_response.error.reason === "status-code") {
4247
+ switch (_response.error.statusCode) {
4248
+ case 400:
4249
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
4250
+ case 403:
4251
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4252
+ case 429:
4253
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
4254
+ default:
4255
+ throw new VectrosError({
4256
+ statusCode: _response.error.statusCode,
4257
+ body: _response.error.body,
4258
+ rawResponse: _response.rawResponse
4259
+ });
4260
+ }
4261
+ }
4262
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/issuers");
4263
+ }
4001
4264
  /**
4002
4265
  * 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.
4003
4266
  *
@@ -4043,7 +4306,7 @@ var AuthClient = class {
4043
4306
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/ping");
4044
4307
  }
4045
4308
  /**
4046
- * 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.
4309
+ * 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.
4047
4310
  *
4048
4311
  * @param {Vectros.ListProfilesForPrincipalRequest} request
4049
4312
  * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -4321,6 +4584,72 @@ var AuthClient = class {
4321
4584
  }
4322
4585
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/users/invite/resend");
4323
4586
  }
4587
+ /**
4588
+ * 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.
4589
+ *
4590
+ * @param {Vectros.TokenExchangeRequest} request
4591
+ * @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
4592
+ *
4593
+ * @throws {@link Vectros.BadRequestError}
4594
+ * @throws {@link Vectros.UnauthorizedError}
4595
+ * @throws {@link Vectros.ForbiddenError}
4596
+ * @throws {@link Vectros.NotFoundError}
4597
+ * @throws {@link Vectros.TooManyRequestsError}
4598
+ *
4599
+ * @example
4600
+ * await client.auth.exchangeToken({
4601
+ * grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
4602
+ * subject_token: "subject_token",
4603
+ * subject_token_type: "urn:ietf:params:oauth:token-type:jwt"
4604
+ * })
4605
+ */
4606
+ exchangeToken(request, requestOptions) {
4607
+ return HttpResponsePromise.fromPromise(this.__exchangeToken(request, requestOptions));
4608
+ }
4609
+ async __exchangeToken(request, requestOptions) {
4610
+ const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
4611
+ const _response = await fetcher({
4612
+ url: url_exports.join(
4613
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
4614
+ "v1/auth/token/exchange"
4615
+ ),
4616
+ method: "POST",
4617
+ headers: _headers,
4618
+ contentType: "application/json",
4619
+ queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
4620
+ requestType: "json",
4621
+ body: request,
4622
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
4623
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
4624
+ abortSignal: requestOptions?.abortSignal,
4625
+ fetchFn: this._options?.fetch,
4626
+ logging: this._options.logging
4627
+ });
4628
+ if (_response.ok) {
4629
+ return { data: _response.body, rawResponse: _response.rawResponse };
4630
+ }
4631
+ if (_response.error.reason === "status-code") {
4632
+ switch (_response.error.statusCode) {
4633
+ case 400:
4634
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
4635
+ case 401:
4636
+ throw new UnauthorizedError(_response.error.body, _response.rawResponse);
4637
+ case 403:
4638
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
4639
+ case 404:
4640
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
4641
+ case 429:
4642
+ throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
4643
+ default:
4644
+ throw new VectrosError({
4645
+ statusCode: _response.error.statusCode,
4646
+ body: _response.error.body,
4647
+ rawResponse: _response.rawResponse
4648
+ });
4649
+ }
4650
+ }
4651
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/token/exchange");
4652
+ }
4324
4653
  };
4325
4654
  var ComplianceClient = class {
4326
4655
  constructor(options) {
@@ -5798,6 +6127,7 @@ var IdentityClient = class {
5798
6127
  * @example
5799
6128
  * await client.identity.listEntities({
5800
6129
  * namespace: "team",
6130
+ * contextId: "myapp",
5801
6131
  * startFrom: "b3BhcXVlLWN1cnNvci1mcm9tLXRoZS1wcmV2aW91cy1wYWdl"
5802
6132
  * })
5803
6133
  */
@@ -5807,6 +6137,7 @@ var IdentityClient = class {
5807
6137
  async __listEntities(request, requestOptions) {
5808
6138
  const {
5809
6139
  namespace,
6140
+ contextId,
5810
6141
  userId,
5811
6142
  externalId,
5812
6143
  scope,
@@ -5821,6 +6152,7 @@ var IdentityClient = class {
5821
6152
  limit
5822
6153
  } = request;
5823
6154
  const _queryParams = {
6155
+ contextId,
5824
6156
  userId,
5825
6157
  externalId,
5826
6158
  scope,
@@ -5879,6 +6211,7 @@ var IdentityClient = class {
5879
6211
  * @example
5880
6212
  * await client.identity.createEntity({
5881
6213
  * namespace: "team",
6214
+ * contextId: "myapp",
5882
6215
  * body: {
5883
6216
  * externalId: "team_eng_platform"
5884
6217
  * }
@@ -5888,9 +6221,10 @@ var IdentityClient = class {
5888
6221
  return HttpResponsePromise.fromPromise(this.__createEntity(request, requestOptions));
5889
6222
  }
5890
6223
  async __createEntity(request, requestOptions) {
5891
- const { namespace, upsert, body: _body } = request;
6224
+ const { namespace, upsert, contextId, body: _body } = request;
5892
6225
  const _queryParams = {
5893
- upsert
6226
+ upsert,
6227
+ contextId
5894
6228
  };
5895
6229
  const _authRequest = await this._options.authProvider.getAuthRequest();
5896
6230
  const _headers = mergeHeaders(
@@ -5947,14 +6281,18 @@ var IdentityClient = class {
5947
6281
  * @example
5948
6282
  * await client.identity.getEntity({
5949
6283
  * namespace: "team",
5950
- * id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
6284
+ * id: "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
6285
+ * contextId: "myapp"
5951
6286
  * })
5952
6287
  */
5953
6288
  getEntity(request, requestOptions) {
5954
6289
  return HttpResponsePromise.fromPromise(this.__getEntity(request, requestOptions));
5955
6290
  }
5956
6291
  async __getEntity(request, requestOptions) {
5957
- const { namespace, id } = request;
6292
+ const { namespace, id, contextId } = request;
6293
+ const _queryParams = {
6294
+ contextId
6295
+ };
5958
6296
  const _authRequest = await this._options.authProvider.getAuthRequest();
5959
6297
  const _headers = mergeHeaders(
5960
6298
  _authRequest.headers,
@@ -5968,7 +6306,7 @@ var IdentityClient = class {
5968
6306
  ),
5969
6307
  method: "GET",
5970
6308
  headers: _headers,
5971
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6309
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
5972
6310
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
5973
6311
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
5974
6312
  abortSignal: requestOptions?.abortSignal,
@@ -6005,6 +6343,7 @@ var IdentityClient = class {
6005
6343
  * await client.identity.updateEntity({
6006
6344
  * namespace: "team",
6007
6345
  * id: "id",
6346
+ * contextId: "myapp",
6008
6347
  * body: {
6009
6348
  * externalId: "team_eng_platform"
6010
6349
  * }
@@ -6014,7 +6353,10 @@ var IdentityClient = class {
6014
6353
  return HttpResponsePromise.fromPromise(this.__updateEntity(request, requestOptions));
6015
6354
  }
6016
6355
  async __updateEntity(request, requestOptions) {
6017
- const { namespace, id, body: _body } = request;
6356
+ const { namespace, id, contextId, body: _body } = request;
6357
+ const _queryParams = {
6358
+ contextId
6359
+ };
6018
6360
  const _authRequest = await this._options.authProvider.getAuthRequest();
6019
6361
  const _headers = mergeHeaders(
6020
6362
  _authRequest.headers,
@@ -6029,7 +6371,7 @@ var IdentityClient = class {
6029
6371
  method: "PUT",
6030
6372
  headers: _headers,
6031
6373
  contentType: "application/json",
6032
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6374
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6033
6375
  requestType: "json",
6034
6376
  body: _body,
6035
6377
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -6069,14 +6411,18 @@ var IdentityClient = class {
6069
6411
  * @example
6070
6412
  * await client.identity.deleteEntity({
6071
6413
  * namespace: "team",
6072
- * id: "id"
6414
+ * id: "id",
6415
+ * contextId: "myapp"
6073
6416
  * })
6074
6417
  */
6075
6418
  deleteEntity(request, requestOptions) {
6076
6419
  return HttpResponsePromise.fromPromise(this.__deleteEntity(request, requestOptions));
6077
6420
  }
6078
6421
  async __deleteEntity(request, requestOptions) {
6079
- const { namespace, id } = request;
6422
+ const { namespace, id, contextId } = request;
6423
+ const _queryParams = {
6424
+ contextId
6425
+ };
6080
6426
  const _authRequest = await this._options.authProvider.getAuthRequest();
6081
6427
  const _headers = mergeHeaders(
6082
6428
  _authRequest.headers,
@@ -6090,7 +6436,7 @@ var IdentityClient = class {
6090
6436
  ),
6091
6437
  method: "DELETE",
6092
6438
  headers: _headers,
6093
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6439
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6094
6440
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6095
6441
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6096
6442
  abortSignal: requestOptions?.abortSignal,
@@ -6133,6 +6479,7 @@ var IdentityClient = class {
6133
6479
  * @example
6134
6480
  * await client.identity.lookupEntities({
6135
6481
  * namespace: "team",
6482
+ * contextId: "myapp",
6136
6483
  * body: {
6137
6484
  * type: "person_v1",
6138
6485
  * field: "ssn"
@@ -6143,7 +6490,10 @@ var IdentityClient = class {
6143
6490
  return HttpResponsePromise.fromPromise(this.__lookupEntities(request, requestOptions));
6144
6491
  }
6145
6492
  async __lookupEntities(request, requestOptions) {
6146
- const { namespace, body: _body } = request;
6493
+ const { namespace, contextId, body: _body } = request;
6494
+ const _queryParams = {
6495
+ contextId
6496
+ };
6147
6497
  const _authRequest = await this._options.authProvider.getAuthRequest();
6148
6498
  const _headers = mergeHeaders(
6149
6499
  _authRequest.headers,
@@ -6158,7 +6508,7 @@ var IdentityClient = class {
6158
6508
  method: "POST",
6159
6509
  headers: _headers,
6160
6510
  contentType: "application/json",
6161
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6511
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6162
6512
  requestType: "json",
6163
6513
  body: _body,
6164
6514
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -6202,15 +6552,17 @@ var IdentityClient = class {
6202
6552
  * @example
6203
6553
  * await client.identity.getEntityVersions({
6204
6554
  * namespace: "team",
6205
- * id: "id"
6555
+ * id: "id",
6556
+ * contextId: "myapp"
6206
6557
  * })
6207
6558
  */
6208
6559
  getEntityVersions(request, requestOptions) {
6209
6560
  return HttpResponsePromise.fromPromise(this.__getEntityVersions(request, requestOptions));
6210
6561
  }
6211
6562
  async __getEntityVersions(request, requestOptions) {
6212
- const { namespace, id, startFrom } = request;
6563
+ const { namespace, id, contextId, startFrom } = request;
6213
6564
  const _queryParams = {
6565
+ contextId,
6214
6566
  startFrom
6215
6567
  };
6216
6568
  const _authRequest = await this._options.authProvider.getAuthRequest();
@@ -6272,7 +6624,10 @@ var IdentityClient = class {
6272
6624
  return HttpResponsePromise.fromPromise(this.__getNamespace(request, requestOptions));
6273
6625
  }
6274
6626
  async __getNamespace(request, requestOptions) {
6275
- const { namespace } = request;
6627
+ const { namespace, contextId } = request;
6628
+ const _queryParams = {
6629
+ contextId
6630
+ };
6276
6631
  const _authRequest = await this._options.authProvider.getAuthRequest();
6277
6632
  const _headers = mergeHeaders(
6278
6633
  _authRequest.headers,
@@ -6286,7 +6641,7 @@ var IdentityClient = class {
6286
6641
  ),
6287
6642
  method: "GET",
6288
6643
  headers: _headers,
6289
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6644
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6290
6645
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6291
6646
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6292
6647
  abortSignal: requestOptions?.abortSignal,
@@ -6311,7 +6666,7 @@ var IdentityClient = class {
6311
6666
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces/{namespace}");
6312
6667
  }
6313
6668
  /**
6314
- * 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.
6669
+ * 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.
6315
6670
  *
6316
6671
  * @param {Vectros.UpdateNamespaceRequest} request
6317
6672
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6333,7 +6688,10 @@ var IdentityClient = class {
6333
6688
  return HttpResponsePromise.fromPromise(this.__updateNamespace(request, requestOptions));
6334
6689
  }
6335
6690
  async __updateNamespace(request, requestOptions) {
6336
- const { namespace, body: _body } = request;
6691
+ const { namespace, contextId, body: _body } = request;
6692
+ const _queryParams = {
6693
+ contextId
6694
+ };
6337
6695
  const _authRequest = await this._options.authProvider.getAuthRequest();
6338
6696
  const _headers = mergeHeaders(
6339
6697
  _authRequest.headers,
@@ -6348,7 +6706,7 @@ var IdentityClient = class {
6348
6706
  method: "PUT",
6349
6707
  headers: _headers,
6350
6708
  contentType: "application/json",
6351
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6709
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6352
6710
  requestType: "json",
6353
6711
  body: _body,
6354
6712
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
@@ -6379,7 +6737,7 @@ var IdentityClient = class {
6379
6737
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/namespaces/{namespace}");
6380
6738
  }
6381
6739
  /**
6382
- * 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.
6740
+ * 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.
6383
6741
  *
6384
6742
  * @param {Vectros.DeleteNamespaceRequest} request
6385
6743
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6397,7 +6755,10 @@ var IdentityClient = class {
6397
6755
  return HttpResponsePromise.fromPromise(this.__deleteNamespace(request, requestOptions));
6398
6756
  }
6399
6757
  async __deleteNamespace(request, requestOptions) {
6400
- const { namespace } = request;
6758
+ const { namespace, contextId } = request;
6759
+ const _queryParams = {
6760
+ contextId
6761
+ };
6401
6762
  const _authRequest = await this._options.authProvider.getAuthRequest();
6402
6763
  const _headers = mergeHeaders(
6403
6764
  _authRequest.headers,
@@ -6411,7 +6772,7 @@ var IdentityClient = class {
6411
6772
  ),
6412
6773
  method: "DELETE",
6413
6774
  headers: _headers,
6414
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6775
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6415
6776
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6416
6777
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6417
6778
  abortSignal: requestOptions?.abortSignal,
@@ -6440,7 +6801,7 @@ var IdentityClient = class {
6440
6801
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/namespaces/{namespace}");
6441
6802
  }
6442
6803
  /**
6443
- * Returns the scope namespaces registered in your account, with the reserved built-ins `org` and `client` listed first. Returns a `{data, nextCursor}` envelope.
6804
+ * 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.
6444
6805
  *
6445
6806
  * @param {Vectros.ListNamespacesRequest} request
6446
6807
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -6452,10 +6813,11 @@ var IdentityClient = class {
6452
6813
  return HttpResponsePromise.fromPromise(this.__listNamespaces(request, requestOptions));
6453
6814
  }
6454
6815
  async __listNamespaces(request = {}, requestOptions) {
6455
- const { startFrom, limit } = request;
6816
+ const { startFrom, limit, contextId } = request;
6456
6817
  const _queryParams = {
6457
6818
  startFrom,
6458
- limit
6819
+ limit,
6820
+ contextId
6459
6821
  };
6460
6822
  const _authRequest = await this._options.authProvider.getAuthRequest();
6461
6823
  const _headers = mergeHeaders(
@@ -6490,9 +6852,9 @@ var IdentityClient = class {
6490
6852
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/namespaces");
6491
6853
  }
6492
6854
  /**
6493
- * 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.
6855
+ * 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.
6494
6856
  *
6495
- * @param {Vectros.NamespaceRequest} request
6857
+ * @param {Vectros.RegisterNamespaceRequest} request
6496
6858
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6497
6859
  *
6498
6860
  * @throws {@link Vectros.BadRequestError}
@@ -6501,14 +6863,20 @@ var IdentityClient = class {
6501
6863
  *
6502
6864
  * @example
6503
6865
  * await client.identity.registerNamespace({
6504
- * namespace: "team",
6505
- * specificityRank: 1500
6866
+ * body: {
6867
+ * namespace: "team",
6868
+ * specificityRank: 1500
6869
+ * }
6506
6870
  * })
6507
6871
  */
6508
6872
  registerNamespace(request, requestOptions) {
6509
6873
  return HttpResponsePromise.fromPromise(this.__registerNamespace(request, requestOptions));
6510
6874
  }
6511
6875
  async __registerNamespace(request, requestOptions) {
6876
+ const { contextId, body: _body } = request;
6877
+ const _queryParams = {
6878
+ contextId
6879
+ };
6512
6880
  const _authRequest = await this._options.authProvider.getAuthRequest();
6513
6881
  const _headers = mergeHeaders(
6514
6882
  _authRequest.headers,
@@ -6523,9 +6891,9 @@ var IdentityClient = class {
6523
6891
  method: "POST",
6524
6892
  headers: _headers,
6525
6893
  contentType: "application/json",
6526
- queryString: url_exports.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
6894
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
6527
6895
  requestType: "json",
6528
- body: request,
6896
+ body: _body,
6529
6897
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
6530
6898
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
6531
6899
  abortSignal: requestOptions?.abortSignal,
@@ -6810,12 +7178,13 @@ var IdentityClient = class {
6810
7178
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v1/users/{id}");
6811
7179
  }
6812
7180
  /**
6813
- * 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.
7181
+ * 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.
6814
7182
  *
6815
7183
  * @param {Vectros.DeleteUserRequest} request
6816
7184
  * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
6817
7185
  *
6818
7186
  * @throws {@link Vectros.NotFoundError}
7187
+ * @throws {@link Vectros.ConflictError}
6819
7188
  * @throws {@link Vectros.TooManyRequestsError}
6820
7189
  *
6821
7190
  * @example
@@ -6855,6 +7224,8 @@ var IdentityClient = class {
6855
7224
  switch (_response.error.statusCode) {
6856
7225
  case 404:
6857
7226
  throw new NotFoundError(_response.error.body, _response.rawResponse);
7227
+ case 409:
7228
+ throw new ConflictError(_response.error.body, _response.rawResponse);
6858
7229
  case 429:
6859
7230
  throw new TooManyRequestsError(_response.error.body, _response.rawResponse);
6860
7231
  default:
@@ -6928,6 +7299,69 @@ var IdentityClient = class {
6928
7299
  }
6929
7300
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/users/lookup");
6930
7301
  }
7302
+ /**
7303
+ * 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.
7304
+ *
7305
+ * @param {Vectros.UserExistsByEmailRequest} request
7306
+ * @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
7307
+ *
7308
+ * @throws {@link Vectros.BadRequestError}
7309
+ * @throws {@link Vectros.ForbiddenError}
7310
+ *
7311
+ * @example
7312
+ * await client.identity.userExistsByEmail({
7313
+ * email: "user@example.com",
7314
+ * contextId: "myapp"
7315
+ * })
7316
+ */
7317
+ userExistsByEmail(request = {}, requestOptions) {
7318
+ return HttpResponsePromise.fromPromise(this.__userExistsByEmail(request, requestOptions));
7319
+ }
7320
+ async __userExistsByEmail(request = {}, requestOptions) {
7321
+ const { email, contextId } = request;
7322
+ const _queryParams = {
7323
+ email,
7324
+ contextId
7325
+ };
7326
+ const _authRequest = await this._options.authProvider.getAuthRequest();
7327
+ const _headers = mergeHeaders(
7328
+ _authRequest.headers,
7329
+ this._options?.headers,
7330
+ requestOptions?.headers
7331
+ );
7332
+ const _response = await fetcher({
7333
+ url: url_exports.join(
7334
+ await Supplier.get(this._options.baseUrl) ?? await Supplier.get(this._options.environment),
7335
+ "v1/users/exists-by-email"
7336
+ ),
7337
+ method: "GET",
7338
+ headers: _headers,
7339
+ queryString: url_exports.queryBuilder().addMany(_queryParams).mergeAdditional(requestOptions?.queryParams).build(),
7340
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
7341
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
7342
+ abortSignal: requestOptions?.abortSignal,
7343
+ fetchFn: this._options?.fetch,
7344
+ logging: this._options.logging
7345
+ });
7346
+ if (_response.ok) {
7347
+ return { data: _response.body, rawResponse: _response.rawResponse };
7348
+ }
7349
+ if (_response.error.reason === "status-code") {
7350
+ switch (_response.error.statusCode) {
7351
+ case 400:
7352
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
7353
+ case 403:
7354
+ throw new ForbiddenError(_response.error.body, _response.rawResponse);
7355
+ default:
7356
+ throw new VectrosError({
7357
+ statusCode: _response.error.statusCode,
7358
+ body: _response.error.body,
7359
+ rawResponse: _response.rawResponse
7360
+ });
7361
+ }
7362
+ }
7363
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/users/exists-by-email");
7364
+ }
6931
7365
  /**
6932
7366
  * 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.
6933
7367
  *
@@ -8684,15 +9118,15 @@ function warnOnSuboptimalKey(key, log) {
8684
9118
  } else if (key.prefix === "st") {
8685
9119
  log.warn(
8686
9120
  { prefix: key.prefix, env: key.env },
8687
- "short-lived token (st_*) will expire mid-session (1h default, 24h max). For long-running MCP installs, prefer a long-lived ssk_* key."
9121
+ "short-lived token (st_*) will expire mid-session (1h max). For long-running MCP installs, prefer a long-lived ssk_* key."
8688
9122
  );
8689
9123
  }
8690
9124
  }
8691
9125
 
8692
9126
  // src/build-info.ts
8693
9127
  var BUILD_INFO = {
8694
- mcpServer: true ? "0.13.0" : "dev",
8695
- sdk: true ? "0.38.0" : "dev"
9128
+ mcpServer: true ? "0.15.0" : "dev",
9129
+ sdk: true ? "0.40.0" : "dev"
8696
9130
  };
8697
9131
  function formatBuildInfo() {
8698
9132
  return `vectros-mcp-server ${BUILD_INFO.mcpServer} (sdk ${BUILD_INFO.sdk})`;
@@ -9003,7 +9437,7 @@ var inputSchema = {
9003
9437
  // Ownership.
9004
9438
  userId: import_zod.z.string().optional().describe("Restrict to content owned by this user (Vectros UUID)."),
9005
9439
  scope: import_zod.z.string().optional().describe(
9006
- '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.'
9440
+ '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.'
9007
9441
  ),
9008
9442
  // Date window.
9009
9443
  createdAfter: import_zod.z.string().optional().describe("Restrict to content created at/after this ISO 8601 UTC timestamp."),
@@ -9143,7 +9577,7 @@ var inputSchema2 = {
9143
9577
  // List-mode args:
9144
9578
  userId: import_zod2.z.string().optional().describe("List mode: scope to records owned by this user."),
9145
9579
  scope: import_zod2.z.string().optional().describe(
9146
- '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.'
9580
+ '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.'
9147
9581
  ),
9148
9582
  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."),
9149
9583
  limit: import_zod2.z.number().int().min(1).max(MCP_MAX_LIMIT2).optional().describe(
@@ -9394,7 +9828,7 @@ var inputSchema4 = {
9394
9828
  folderId: import_zod4.z.string().optional().describe("Group this record into a folder."),
9395
9829
  userId: import_zod4.z.string().optional().describe("Owning user id."),
9396
9830
  scopes: import_zod4.z.array(import_zod4.z.string()).optional().describe(
9397
- '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.'
9831
+ '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.'
9398
9832
  )
9399
9833
  };
9400
9834
  var recordCreate = ({ client, log }) => ({
@@ -9518,7 +9952,7 @@ var inputSchema7 = {
9518
9952
  // whole-tenant corpus.
9519
9953
  userId: import_zod7.z.string().optional().describe("Restrict retrieval to content owned by this user (Vectros UUID)."),
9520
9954
  scope: import_zod7.z.string().optional().describe(
9521
- '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.'
9955
+ '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.'
9522
9956
  ),
9523
9957
  folderId: import_zod7.z.string().optional().describe("Restrict retrieval to this exact folder."),
9524
9958
  rootFolderId: import_zod7.z.string().optional().describe("Restrict retrieval to this folder and all its descendants."),
@@ -9692,7 +10126,7 @@ var inputSchema9 = {
9692
10126
  "Filter to schemas visible to a specific user. Optional; default returns all schemas the credential can see."
9693
10127
  ),
9694
10128
  scope: import_zod9.z.string().optional().describe(
9695
- '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.'
10129
+ '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.'
9696
10130
  ),
9697
10131
  surface: import_zod9.z.enum(["record", "document", "user", "entity"]).optional().describe(
9698
10132
  "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."
@@ -9842,7 +10276,7 @@ var inputSchema11 = {
9842
10276
  folderId: import_zod11.z.string().optional().describe("List mode: only documents in this folder (Vectros folder id)."),
9843
10277
  userId: import_zod11.z.string().optional().describe("List mode: scope to documents owned by this user."),
9844
10278
  scope: import_zod11.z.string().optional().describe(
9845
- '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.'
10279
+ '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.'
9846
10280
  ),
9847
10281
  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."),
9848
10282
  limit: import_zod11.z.number().int().min(1).max(MCP_MAX_LIMIT3).optional().describe(
@@ -9953,7 +10387,7 @@ var inputSchema12 = {
9953
10387
  ),
9954
10388
  userId: import_zod12.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
9955
10389
  scopes: import_zod12.z.array(import_zod12.z.string()).optional().describe(
9956
- '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).'
10390
+ '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).'
9957
10391
  ),
9958
10392
  expectedVersion: import_zod12.z.number().int().optional().describe(
9959
10393
  "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."
@@ -10037,7 +10471,7 @@ var inputSchema14 = {
10037
10471
  parentId: import_zod14.z.string().optional().describe("List mode: direct children of this folder (tree navigation). Omit for a flat tenant list."),
10038
10472
  userId: import_zod14.z.string().optional().describe("List mode: scope to folders owned by this user."),
10039
10473
  scope: import_zod14.z.string().optional().describe(
10040
- '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.'
10474
+ '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.'
10041
10475
  ),
10042
10476
  startFrom: import_zod14.z.string().optional().describe("List mode: pagination cursor \u2014 pass the `nextCursor` from the previous page to fetch the next."),
10043
10477
  limit: import_zod14.z.number().int().min(1).max(MCP_MAX_LIMIT4).optional().describe(
@@ -10086,7 +10520,7 @@ var inputSchema15 = {
10086
10520
  slug: import_zod15.z.string().optional().describe("Optional stable slug (sibling-unique; idempotency key). Lowercase letters/digits/hyphens. Derived from name when omitted."),
10087
10521
  userId: import_zod15.z.string().optional().describe("Owning user (Vectros UUID)."),
10088
10522
  scopes: import_zod15.z.array(import_zod15.z.string()).optional().describe(
10089
- '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.'
10523
+ '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.'
10090
10524
  )
10091
10525
  };
10092
10526
  var folderCreate = ({ client, log }) => ({
@@ -10124,7 +10558,7 @@ var inputSchema16 = {
10124
10558
  description: import_zod16.z.string().optional().describe("New description. Omit to leave unchanged."),
10125
10559
  userId: import_zod16.z.string().optional().describe("Reassign the owning user (Vectros UUID)."),
10126
10560
  scopes: import_zod16.z.array(import_zod16.z.string()).optional().describe(
10127
- '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).'
10561
+ '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).'
10128
10562
  ),
10129
10563
  expectedVersion: import_zod16.z.number().int().optional().describe(
10130
10564
  "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."
@@ -10191,7 +10625,7 @@ var inputSchema18 = {
10191
10625
  var currentIdentity = ({ log, apiKey, environment }) => ({
10192
10626
  name: "current_identity",
10193
10627
  title: "Current identity (tenant + principal scope)",
10194
- 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.",
10628
+ 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.",
10195
10629
  inputSchema: inputSchema18,
10196
10630
  handler: async () => {
10197
10631
  try {
@@ -10314,7 +10748,7 @@ var inputSchema19 = {
10314
10748
  folderId: import_zod18.z.string().optional().describe("Optional folder to ingest into. Default: tenant root."),
10315
10749
  userId: import_zod18.z.string().optional().describe("Owning user ID. Optional."),
10316
10750
  scopes: import_zod18.z.array(import_zod18.z.string()).optional().describe(
10317
- "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."
10751
+ "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."
10318
10752
  )
10319
10753
  };
10320
10754
  var documentIngest = ({ client, log, transport, ingestRoot }) => ({
@@ -10478,11 +10912,14 @@ var MCP_DEFAULT_LIMIT5 = 10;
10478
10912
  var MCP_MAX_LIMIT5 = 100;
10479
10913
  var inputSchema20 = {
10480
10914
  kind: import_zod19.z.string().describe(
10481
- 'Which principal to look up: "user" (the fixed principal surface), or an entity namespace \u2014 "org", "client" (built in), or a namespace you registered.'
10915
+ '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.'
10482
10916
  ),
10483
10917
  externalId: import_zod19.z.string().optional().describe(
10484
10918
  "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."
10485
10919
  ),
10920
+ contextId: import_zod19.z.string().optional().describe(
10921
+ "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."
10922
+ ),
10486
10923
  // Lookup-mode args — provide `field` plus EXACTLY ONE of: value | from+to | prefix.
10487
10924
  type: import_zod19.z.string().optional().describe('Lookup mode: the identity schema\'s record type (e.g. "person_v1"). Required with `field`.'),
10488
10925
  field: import_zod19.z.string().optional().describe('Lookup mode: name of the schema-declared lookup field to query by (e.g. "email").'),
@@ -10499,13 +10936,14 @@ var inputSchema20 = {
10499
10936
  var lookupPrincipal = ({ client, log }) => ({
10500
10937
  name: "lookup_principal",
10501
10938
  title: "Look up a user identity or a namespaced identity entity",
10502
- 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.",
10939
+ 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.",
10503
10940
  inputSchema: inputSchema20,
10504
10941
  handler: async (args) => {
10505
10942
  const kind = args.kind;
10506
10943
  const isUser = kind === "user";
10507
10944
  const limit = args.limit ?? MCP_DEFAULT_LIMIT5;
10508
10945
  const externalId = args.externalId;
10946
+ const contextId = args.contextId;
10509
10947
  const type = args.type;
10510
10948
  const field = args.field;
10511
10949
  const value = args.value;
@@ -10514,11 +10952,18 @@ var lookupPrincipal = ({ client, log }) => ({
10514
10952
  const prefix = args.prefix;
10515
10953
  const order = args.order;
10516
10954
  const startFrom = args.startFrom;
10955
+ if (contextId !== void 0 && isUser) {
10956
+ return toolError(
10957
+ "lookup_principal",
10958
+ new Error("'contextId' does not apply to kind 'user' \u2014 the user surface is always tenant-wide.")
10959
+ );
10960
+ }
10961
+ const contextIdArg = contextId !== void 0 ? { contextId } : {};
10517
10962
  try {
10518
10963
  let page;
10519
10964
  if (externalId !== void 0) {
10520
- page = isUser ? await client.identity.listUsers({ externalId, limit }) : await client.identity.listEntities({ namespace: kind, externalId, limit });
10521
- log.debug({ tool: "lookup_principal", mode: "resolve", kind }, "lookup_principal resolve ok");
10965
+ page = isUser ? await client.identity.listUsers({ externalId, limit }) : await client.identity.listEntities({ namespace: kind, ...contextIdArg, externalId, limit });
10966
+ log.debug({ tool: "lookup_principal", mode: "resolve", kind, contextId }, "lookup_principal resolve ok");
10522
10967
  } else if (field !== void 0) {
10523
10968
  const hasEquality = value !== void 0;
10524
10969
  const hasRange = from !== void 0 || to !== void 0;
@@ -10546,8 +10991,8 @@ var lookupPrincipal = ({ client, log }) => ({
10546
10991
  );
10547
10992
  }
10548
10993
  const req = { type, field, value, from, to, prefix, order, startFrom, limit };
10549
- page = isUser ? await client.identity.lookupUsers(req) : await client.identity.lookupEntities({ namespace: kind, body: req });
10550
- log.debug({ tool: "lookup_principal", mode: "lookup", kind, type, field }, "lookup_principal lookup ok");
10994
+ page = isUser ? await client.identity.lookupUsers(req) : await client.identity.lookupEntities({ namespace: kind, ...contextIdArg, body: req });
10995
+ log.debug({ tool: "lookup_principal", mode: "lookup", kind, type, field, contextId }, "lookup_principal lookup ok");
10551
10996
  } else {
10552
10997
  return toolError(
10553
10998
  "lookup_principal",
@@ -10558,7 +11003,7 @@ var lookupPrincipal = ({ client, log }) => ({
10558
11003
  const nextCursor = page.nextCursor ?? null;
10559
11004
  return { content: [{ type: "text", text: JSON.stringify({ data: principals, nextCursor }, null, 2) }] };
10560
11005
  } catch (err) {
10561
- log.warn({ tool: "lookup_principal", kind, err: String(err) }, "lookup_principal failed");
11006
+ log.warn({ tool: "lookup_principal", kind, contextId, err: String(err) }, "lookup_principal failed");
10562
11007
  return toolError("lookup_principal", err);
10563
11008
  }
10564
11009
  }
@@ -10669,7 +11114,7 @@ var identityResource = ({ log, apiKey, environment }) => ({
10669
11114
  name: "identity",
10670
11115
  uri: "vectros://identity",
10671
11116
  title: "Current identity (tenant + principal scope)",
10672
- 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.",
11117
+ 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.",
10673
11118
  mimeType: "application/json",
10674
11119
  read: async () => {
10675
11120
  const identity = await resolveIdentity({ log, apiKey, environment });