@alfe.ai/gateway 0.9.11 → 0.9.13

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.
Files changed (2) hide show
  1. package/dist/health.js +297 -187
  2. package/package.json +4 -4
package/dist/health.js CHANGED
@@ -287,190 +287,6 @@ function pluginConnectionId() {
287
287
  return createId(ID_PREFIXES.pluginConnection);
288
288
  }
289
289
  //#endregion
290
- //#region ../../packages-internal/api-client/dist/client.js
291
- /**
292
- * @alfe/api-client — Typed HTTP client for Alfe services.
293
- *
294
- * Platform-agnostic: works in React Native and browser environments.
295
- * Uses standard fetch() API — no Node.js dependencies.
296
- */
297
- var AlfeApiClient = class {
298
- apiBaseUrl;
299
- getToken;
300
- onAuthFailure;
301
- constructor(options) {
302
- this.apiBaseUrl = options.apiBaseUrl.replace(/\/+$/, "");
303
- this.getToken = options.getToken;
304
- this.onAuthFailure = options.onAuthFailure;
305
- }
306
- /**
307
- * Shared fetch logic — handles auth, 401, and network errors.
308
- *
309
- * `skipAuth` callers (public endpoints like OAuth device-code) opt out of
310
- * the auth-header injection AND the synthetic 401 short-circuit. Without
311
- * this opt-out, a CLI calling /auth/device-code (no token yet by design)
312
- * would never reach the network — the `getToken: () => null` path would
313
- * synthesize a 401 and fire onAuthFailure, breaking the entire flow.
314
- */
315
- async _fetchResponse(path, options, skipAuth = false) {
316
- try {
317
- const url = `${this.apiBaseUrl}${path}`;
318
- const headers = new Headers(options?.headers);
319
- if (typeof options?.body === "string" && !headers.has("Content-Type")) headers.set("Content-Type", "application/json");
320
- headers.set("x-correlation-id", correlationId());
321
- if (!skipAuth) {
322
- const token = await this.getToken();
323
- if (!token) {
324
- this.onAuthFailure?.();
325
- return {
326
- ok: false,
327
- result: {
328
- ok: false,
329
- error: "No auth token available",
330
- status: 401
331
- }
332
- };
333
- }
334
- headers.set("Authorization", `Bearer ${token}`);
335
- }
336
- const res = await fetch(url, {
337
- ...options,
338
- headers
339
- });
340
- if (res.status === 401 && !skipAuth) {
341
- this.onAuthFailure?.();
342
- return {
343
- ok: false,
344
- result: {
345
- ok: false,
346
- error: "Session expired",
347
- status: 401
348
- }
349
- };
350
- }
351
- if (!res.ok) {
352
- const text = res.status === 204 ? "" : await res.text();
353
- let body;
354
- if (text) try {
355
- body = JSON.parse(text);
356
- } catch {
357
- body = text;
358
- }
359
- const errBody = body;
360
- return {
361
- ok: false,
362
- result: {
363
- ok: false,
364
- error: (typeof errBody === "object" ? errBody.message : void 0) ?? (typeof body === "string" ? body : `API error: ${String(res.status)}`),
365
- status: res.status
366
- }
367
- };
368
- }
369
- return {
370
- ok: true,
371
- res
372
- };
373
- } catch (err) {
374
- return {
375
- ok: false,
376
- result: {
377
- ok: false,
378
- error: err instanceof Error ? err.message : "Network error"
379
- }
380
- };
381
- }
382
- }
383
- async _fetch(path, options, skipAuth = false) {
384
- const response = await this._fetchResponse(path, options, skipAuth);
385
- if (!response.ok) return response;
386
- const text = response.res.status === 204 ? "" : await response.res.text();
387
- let body;
388
- if (text) try {
389
- body = JSON.parse(text);
390
- } catch {
391
- body = text;
392
- }
393
- return {
394
- ok: true,
395
- res: response.res,
396
- body
397
- };
398
- }
399
- /**
400
- * Make an authenticated request to an Alfe API endpoint.
401
- * Unwraps the @auriclabs/api-core `{ data, timestamp, requestId }` envelope.
402
- */
403
- async request(path, options) {
404
- const result = await this._fetch(path, options);
405
- if (!result.ok) return result.result;
406
- if (result.body === void 0) return {
407
- ok: true,
408
- data: void 0
409
- };
410
- return {
411
- ok: true,
412
- data: result.body.data
413
- };
414
- }
415
- /**
416
- * Make a request to a PUBLIC endpoint that does not require authentication.
417
- * Skips both the Authorization header injection AND the onAuthFailure
418
- * callback. Use for endpoints like /auth/device-code that the CLI hits
419
- * before it has a token.
420
- */
421
- async publicRequest(path, options) {
422
- const result = await this._fetch(path, options, true);
423
- if (!result.ok) return result.result;
424
- if (result.body === void 0) return {
425
- ok: true,
426
- data: void 0
427
- };
428
- return {
429
- ok: true,
430
- data: result.body.data
431
- };
432
- }
433
- /**
434
- * Make an authenticated request that returns the body directly (no envelope unwrap).
435
- * Use for APIs that don't use the @auriclabs/api-core response format (e.g. gateway).
436
- */
437
- async rawRequest(path, options) {
438
- const result = await this._fetch(path, options);
439
- if (!result.ok) return result.result;
440
- return {
441
- ok: true,
442
- data: result.body
443
- };
444
- }
445
- /**
446
- * Make an authenticated request without attempting text/JSON decoding.
447
- * Use for downloads such as a Teams app ZIP where UTF-8 conversion would
448
- * corrupt the payload.
449
- */
450
- async binaryRequest(path, options) {
451
- const result = await this._fetchResponse(path, options);
452
- if (!result.ok) return result.result;
453
- try {
454
- return {
455
- ok: true,
456
- data: {
457
- body: await result.res.arrayBuffer(),
458
- contentType: result.res.headers.get("Content-Type") ?? void 0,
459
- contentDisposition: result.res.headers.get("Content-Disposition") ?? void 0
460
- }
461
- };
462
- } catch (err) {
463
- return {
464
- ok: false,
465
- error: err instanceof Error ? err.message : "Failed to read binary response"
466
- };
467
- }
468
- }
469
- getApiBaseUrl() {
470
- return this.apiBaseUrl;
471
- }
472
- };
473
- //#endregion
474
290
  //#region ../../packages-internal/types/dist/lib/enum-values.js
475
291
  /**
476
292
  * Converts a const enum object into a non-empty readonly tuple.
@@ -4193,7 +4009,8 @@ enumValues({
4193
4009
  ClaudeMax: "claude-max",
4194
4010
  OpenAICodexMax: "openai-codex-max",
4195
4011
  OpenAICodexSubscription: "openai-codex-subscription",
4196
- GeminiMax: "gemini-max"
4012
+ GeminiMax: "gemini-max",
4013
+ AlfeAws: "alfe-aws"
4197
4014
  });
4198
4015
  enumValues({
4199
4016
  Month: "month",
@@ -4347,6 +4164,7 @@ const PERMISSION_CATALOG = {
4347
4164
  org_file: ["read", "write"],
4348
4165
  org_knowledge: ["read", "write"],
4349
4166
  model_policy: ["read", "manage"],
4167
+ data_boundary: ["read", "manage"],
4350
4168
  secret: [
4351
4169
  "create",
4352
4170
  "read",
@@ -4379,7 +4197,8 @@ const PERMISSION_CATALOG = {
4379
4197
  discounts: ["manage"],
4380
4198
  stats: ["read"],
4381
4199
  mobile: ["read", "manage"],
4382
- impersonation: ["manage"]
4200
+ impersonation: ["manage"],
4201
+ partner: ["manage"]
4383
4202
  };
4384
4203
  /**
4385
4204
  * Subjects a tenant may grant via a custom role.
@@ -4400,6 +4219,7 @@ const TENANT_ALLOWED_SUBJECTS = [
4400
4219
  "team",
4401
4220
  "project",
4402
4221
  "model_policy",
4222
+ "data_boundary",
4403
4223
  "role_management",
4404
4224
  "billing",
4405
4225
  "identity",
@@ -4447,6 +4267,11 @@ enumValues({
4447
4267
  Public: "public",
4448
4268
  Hidden: "hidden"
4449
4269
  });
4270
+ enumValues({
4271
+ Connection: "connection",
4272
+ Channel: "channel",
4273
+ Integration: "integration"
4274
+ });
4450
4275
  enumValues({
4451
4276
  Active: "active",
4452
4277
  Removed: "removed"
@@ -4562,6 +4387,26 @@ enumValues({
4562
4387
  Demo: "demo",
4563
4388
  Live: "live"
4564
4389
  });
4390
+ function createClerkReverificationResponse(afterMinutes) {
4391
+ if (!Number.isInteger(afterMinutes) || afterMinutes < 1) throw new TypeError("afterMinutes must be a positive integer");
4392
+ return { clerk_error: {
4393
+ type: "forbidden",
4394
+ reason: "reverification-error",
4395
+ metadata: { reverification: {
4396
+ level: "second_factor",
4397
+ afterMinutes
4398
+ } }
4399
+ } };
4400
+ }
4401
+ /** Strictly identify the only authorization hint the API client may expose. */
4402
+ function isClerkReverificationResponse(value) {
4403
+ if (!value || typeof value !== "object") return false;
4404
+ const clerkError = value.clerk_error;
4405
+ if (!clerkError || typeof clerkError !== "object") return false;
4406
+ const error = clerkError;
4407
+ const reverification = error.metadata?.reverification;
4408
+ return error.type === "forbidden" && error.reason === "reverification-error" && reverification?.level === "second_factor" && Number.isInteger(reverification.afterMinutes) && reverification.afterMinutes >= 1;
4409
+ }
4565
4410
  //#endregion
4566
4411
  //#region ../../packages-internal/types/dist/models.js
4567
4412
  const AnthropicModel = {
@@ -4689,6 +4534,35 @@ _enum(QWEN_MODELS);
4689
4534
  string().trim().min(1);
4690
4535
  AnthropicModel.Opus5, AnthropicModel.Opus48, AnthropicModel.Opus47, AnthropicModel.Opus46, AnthropicModel.Sonnet5, AnthropicModel.Sonnet46, AnthropicModel.Haiku45, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3, OpenAIModel.GPT41, OpenAIModel.GPT41Mini, OpenAIModel.GPT41Nano, OpenAIModel.GPT54, OpenAIModel.GPT54Mini, OpenAIModel.GPT54Nano, OpenAIModel.GPT54Pro, OpenAIModel.GPT55, OpenAIModel.GPT55Pro, OpenAIModel.GPT56Sol, OpenAIModel.GPT56Terra, OpenAIModel.GPT56Luna, OpenAIModel.O3Mini, OpenAIModel.O4Mini, OpenAIModel.TextEmbedding3Small, OpenAIModel.TextEmbedding3Large, DeepSeekModel.Chat, DeepSeekModel.Reasoner, DeepSeekModel.V4Flash, DeepSeekModel.V4Pro, GoogleModel.Gemini35Flash, GoogleModel.Gemini31Pro, GoogleModel.Gemini31FlashLite, GoogleModel.Gemini25Pro, GoogleModel.Gemini25Flash, GoogleModel.Gemini25FlashLite, GoogleModel.Gemini20Flash, MiniMaxModel.M3, MiniMaxModel.M27, MiniMaxModel.M27HighSpeed, MiniMaxModel.M25, MiniMaxModel.M21, MiniMaxModel.M2, MistralModel.Large, MistralModel.Medium, MistralModel.Small, MistralModel.Codestral, MistralModel.Ministral8b, MistralModel.Ministral3b, MistralModel.MagistralMedium, MistralModel.MagistralSmall, MistralModel.DevstralMedium, XAIModel.Grok45, XAIModel.Grok43, XAIModel.Grok4, XAIModel.Grok41Fast, ZhipuModel.GLM52, ZhipuModel.GLM51, ZhipuModel.GLM46, ZhipuModel.GLM45, ZhipuModel.GLM45Air, MoonshotModel.K3, MoonshotModel.K26, MoonshotModel.K27Code, MoonshotModel.K27CodeHighSpeed, QwenModel.Qwen37Max, QwenModel.Qwen37Plus, QwenModel.Qwen36Flash, QwenModel.Qwen35Flash;
4691
4536
  AnthropicModel.Opus5, AnthropicModel.Opus48, AnthropicModel.Opus47, AnthropicModel.Opus46, AnthropicModel.Sonnet5, AnthropicModel.Sonnet46, AnthropicModel.Haiku45, OpenAIModel.GPT4o, OpenAIModel.GPT4oMini, OpenAIModel.O3, OpenAIModel.GPT41, OpenAIModel.GPT41Mini, OpenAIModel.GPT41Nano, OpenAIModel.GPT54, OpenAIModel.GPT54Mini, OpenAIModel.GPT54Nano, OpenAIModel.GPT54Pro, OpenAIModel.GPT55, OpenAIModel.GPT55Pro, OpenAIModel.GPT56Sol, OpenAIModel.GPT56Terra, OpenAIModel.GPT56Luna, OpenAIModel.O3Mini, OpenAIModel.O4Mini, OpenAIModel.TextEmbedding3Small, OpenAIModel.TextEmbedding3Large, DeepSeekModel.Chat, DeepSeekModel.Reasoner, DeepSeekModel.V4Flash, DeepSeekModel.V4Pro, GoogleModel.Gemini35Flash, GoogleModel.Gemini31Pro, GoogleModel.Gemini31FlashLite, GoogleModel.Gemini25Pro, GoogleModel.Gemini25Flash, GoogleModel.Gemini25FlashLite, GoogleModel.Gemini20Flash, MiniMaxModel.M3, MiniMaxModel.M27, MiniMaxModel.M27HighSpeed, MiniMaxModel.M25, MiniMaxModel.M21, MiniMaxModel.M2, MistralModel.Large, MistralModel.Medium, MistralModel.Small, MistralModel.Codestral, MistralModel.Ministral8b, MistralModel.Ministral3b, MistralModel.MagistralMedium, MistralModel.MagistralSmall, MistralModel.DevstralMedium, XAIModel.Grok45, XAIModel.Grok43, XAIModel.Grok4, XAIModel.Grok41Fast, ZhipuModel.GLM52, ZhipuModel.GLM51, ZhipuModel.GLM46, ZhipuModel.GLM45, ZhipuModel.GLM45Air, MoonshotModel.K3, MoonshotModel.K26, MoonshotModel.K27Code, MoonshotModel.K27CodeHighSpeed, QwenModel.Qwen37Max, QwenModel.Qwen37Plus, QwenModel.Qwen36Flash, QwenModel.Qwen35Flash;
4537
+ enumValues({
4538
+ Standard: "standard",
4539
+ AwsPrivate: "aws_private"
4540
+ });
4541
+ enumValues({ ApSoutheast2: "ap-southeast-2" });
4542
+ enumValues({
4543
+ Standard: "standard",
4544
+ Requested: "requested",
4545
+ Provisioning: "provisioning",
4546
+ Ready: "ready",
4547
+ CuttingOver: "cutting_over",
4548
+ Active: "active",
4549
+ Failing: "failing",
4550
+ Decommissioning: "decommissioning"
4551
+ });
4552
+ enumValues({
4553
+ RegionalShared: "regional_shared",
4554
+ Dedicated: "dedicated"
4555
+ });
4556
+ enumValues({
4557
+ Inference: "inference",
4558
+ AuthProjection: "auth_projection",
4559
+ ChatGateway: "chat_gateway",
4560
+ AgentCompute: "agent_compute",
4561
+ Attachments: "attachments",
4562
+ Memory: "memory",
4563
+ CapabilityPolicy: "capability_policy",
4564
+ Observability: "observability"
4565
+ });
4692
4566
  enumValues({
4693
4567
  PendingChallenge: "pending_challenge",
4694
4568
  Creating: "creating",
@@ -4777,6 +4651,9 @@ const NotificationType = {
4777
4651
  BrowserTakeoverRequested: "browser_takeover_requested",
4778
4652
  InviteCreated: "onboarding.invite.created",
4779
4653
  OrgClaimed: "onboarding.org.claimed",
4654
+ PartnerApplicationInvitation: "partner.application.invitation",
4655
+ ElevatedSupportRequested: "partner.elevated_support.requested",
4656
+ ElevatedSupportStarted: "partner.elevated_support.started",
4780
4657
  TeamMemberAdded: "team.member.added",
4781
4658
  ProjectMemberAdded: "project.member.added",
4782
4659
  IntegrationInstalled: "integration.installed",
@@ -4791,7 +4668,213 @@ const RecipientStrategy = {
4791
4668
  TenantAdmins: "tenant_admins",
4792
4669
  SpecificUser: "specific_user"
4793
4670
  };
4794
- NotificationType.PaymentSucceeded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.PaymentFailed, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.TopUpCompleted, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AutoRechargeCompleted, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.AutoRechargeFailed, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.SubscriptionCreated, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.SubscriptionCancelled, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.StartupGrantEnded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.GrantEnded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.EnterpriseGrantEnded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.SubscriptionPastDue, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.BalanceThresholdWarning, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.PlatformTierPriceIncrease, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.AgentCreated, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentProvisionFailed, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentBillingSuspended, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentDisconnectedExtended, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Push, NotificationType.BrowserTakeoverRequested, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.InviteCreated, NotificationCategory.System, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.OrgClaimed, NotificationCategory.System, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.TeamMemberAdded, NotificationCategory.Team, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationChannel.Push, NotificationType.ProjectMemberAdded, NotificationCategory.Team, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationChannel.Push, NotificationType.IntegrationInstalled, NotificationCategory.Integrations, RecipientStrategy.TenantAdmins, NotificationChannel.Push, NotificationType.IntegrationRemoved, NotificationCategory.Integrations, RecipientStrategy.TenantAdmins, NotificationChannel.Push;
4671
+ NotificationType.PaymentSucceeded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.PaymentFailed, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.TopUpCompleted, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AutoRechargeCompleted, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.AutoRechargeFailed, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.SubscriptionCreated, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.SubscriptionCancelled, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.StartupGrantEnded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.GrantEnded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.EnterpriseGrantEnded, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.SubscriptionPastDue, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationChannel.Sms, NotificationType.BalanceThresholdWarning, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.PlatformTierPriceIncrease, NotificationCategory.Billing, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.AgentCreated, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentProvisionFailed, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentBillingSuspended, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.AgentDisconnectedExtended, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Push, NotificationType.BrowserTakeoverRequested, NotificationCategory.Agents, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.InviteCreated, NotificationCategory.System, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationType.OrgClaimed, NotificationCategory.System, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.PartnerApplicationInvitation, NotificationCategory.System, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationType.ElevatedSupportRequested, NotificationCategory.System, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.ElevatedSupportStarted, NotificationCategory.System, RecipientStrategy.TenantAdmins, NotificationChannel.Email, NotificationChannel.Push, NotificationType.TeamMemberAdded, NotificationCategory.Team, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationChannel.Push, NotificationType.ProjectMemberAdded, NotificationCategory.Team, RecipientStrategy.SpecificUser, NotificationChannel.Email, NotificationChannel.Push, NotificationType.IntegrationInstalled, NotificationCategory.Integrations, RecipientStrategy.TenantAdmins, NotificationChannel.Push, NotificationType.IntegrationRemoved, NotificationCategory.Integrations, RecipientStrategy.TenantAdmins, NotificationChannel.Push;
4672
+ //#endregion
4673
+ //#region ../../packages-internal/api-client/dist/client.js
4674
+ /**
4675
+ * @alfe/api-client — Typed HTTP client for Alfe services.
4676
+ *
4677
+ * Platform-agnostic: works in React Native and browser environments.
4678
+ * Uses standard fetch() API — no Node.js dependencies.
4679
+ */
4680
+ var AlfeApiClient = class {
4681
+ apiBaseUrl;
4682
+ getToken;
4683
+ onAuthFailure;
4684
+ constructor(options) {
4685
+ this.apiBaseUrl = options.apiBaseUrl.replace(/\/+$/, "");
4686
+ this.getToken = options.getToken;
4687
+ this.onAuthFailure = options.onAuthFailure;
4688
+ }
4689
+ /**
4690
+ * Shared fetch logic — handles auth, 401, and network errors.
4691
+ *
4692
+ * `skipAuth` callers (public endpoints like OAuth device-code) opt out of
4693
+ * the auth-header injection AND the synthetic 401 short-circuit. Without
4694
+ * this opt-out, a CLI calling /auth/device-code (no token yet by design)
4695
+ * would never reach the network — the `getToken: () => null` path would
4696
+ * synthesize a 401 and fire onAuthFailure, breaking the entire flow.
4697
+ */
4698
+ async _fetchResponse(path, options, skipAuth = false) {
4699
+ try {
4700
+ const url = `${this.apiBaseUrl}${path}`;
4701
+ const headers = new Headers(options?.headers);
4702
+ if (typeof options?.body === "string" && !headers.has("Content-Type")) headers.set("Content-Type", "application/json");
4703
+ headers.set("x-correlation-id", correlationId());
4704
+ if (!skipAuth) {
4705
+ const token = await this.getToken();
4706
+ if (!token) {
4707
+ this.onAuthFailure?.();
4708
+ return {
4709
+ ok: false,
4710
+ result: {
4711
+ ok: false,
4712
+ error: "No auth token available",
4713
+ status: 401
4714
+ }
4715
+ };
4716
+ }
4717
+ headers.set("Authorization", `Bearer ${token}`);
4718
+ }
4719
+ const res = await fetch(url, {
4720
+ ...options,
4721
+ headers
4722
+ });
4723
+ if (res.status === 401 && !skipAuth) {
4724
+ this.onAuthFailure?.();
4725
+ return {
4726
+ ok: false,
4727
+ result: {
4728
+ ok: false,
4729
+ error: "Session expired",
4730
+ status: 401
4731
+ }
4732
+ };
4733
+ }
4734
+ if (!res.ok) {
4735
+ const text = res.status === 204 ? "" : await res.text();
4736
+ let body;
4737
+ if (text) try {
4738
+ body = JSON.parse(text);
4739
+ } catch {
4740
+ body = text;
4741
+ }
4742
+ const errBody = body;
4743
+ const errorMessage = typeof errBody === "object" ? errBody.message : void 0;
4744
+ return {
4745
+ ok: false,
4746
+ body,
4747
+ result: {
4748
+ ok: false,
4749
+ error: errorMessage ?? (typeof body === "string" ? body : `API error: ${String(res.status)}`),
4750
+ status: res.status
4751
+ }
4752
+ };
4753
+ }
4754
+ return {
4755
+ ok: true,
4756
+ res
4757
+ };
4758
+ } catch (err) {
4759
+ return {
4760
+ ok: false,
4761
+ result: {
4762
+ ok: false,
4763
+ error: err instanceof Error ? err.message : "Network error"
4764
+ }
4765
+ };
4766
+ }
4767
+ }
4768
+ async _fetch(path, options, skipAuth = false) {
4769
+ const response = await this._fetchResponse(path, options, skipAuth);
4770
+ if (!response.ok) return response;
4771
+ const text = response.res.status === 204 ? "" : await response.res.text();
4772
+ let body;
4773
+ if (text) try {
4774
+ body = JSON.parse(text);
4775
+ } catch {
4776
+ body = text;
4777
+ }
4778
+ return {
4779
+ ok: true,
4780
+ res: response.res,
4781
+ body
4782
+ };
4783
+ }
4784
+ /**
4785
+ * Make an authenticated request to an Alfe API endpoint.
4786
+ * Unwraps the @auriclabs/api-core `{ data, timestamp, requestId }` envelope.
4787
+ */
4788
+ async request(path, options) {
4789
+ const result = await this._fetch(path, options);
4790
+ if (!result.ok) return result.result;
4791
+ if (result.body === void 0) return {
4792
+ ok: true,
4793
+ data: void 0
4794
+ };
4795
+ return {
4796
+ ok: true,
4797
+ data: result.body.data
4798
+ };
4799
+ }
4800
+ /**
4801
+ * Make an authenticated request whose 403 response may ask Clerk to
4802
+ * reverify the current session. Unlike `request`, this preserves only the
4803
+ * strictly validated Clerk hint; all ordinary failures retain `ApiResult`.
4804
+ */
4805
+ async reverifiableRequest(path, options) {
4806
+ const result = await this._fetch(path, options);
4807
+ if (!result.ok) {
4808
+ if (isClerkReverificationResponse(result.body)) return createClerkReverificationResponse(result.body.clerk_error.metadata.reverification.afterMinutes);
4809
+ return result.result;
4810
+ }
4811
+ if (result.body === void 0) return {
4812
+ ok: true,
4813
+ data: void 0
4814
+ };
4815
+ return {
4816
+ ok: true,
4817
+ data: result.body.data
4818
+ };
4819
+ }
4820
+ /**
4821
+ * Make a request to a PUBLIC endpoint that does not require authentication.
4822
+ * Skips both the Authorization header injection AND the onAuthFailure
4823
+ * callback. Use for endpoints like /auth/device-code that the CLI hits
4824
+ * before it has a token.
4825
+ */
4826
+ async publicRequest(path, options) {
4827
+ const result = await this._fetch(path, options, true);
4828
+ if (!result.ok) return result.result;
4829
+ if (result.body === void 0) return {
4830
+ ok: true,
4831
+ data: void 0
4832
+ };
4833
+ return {
4834
+ ok: true,
4835
+ data: result.body.data
4836
+ };
4837
+ }
4838
+ /**
4839
+ * Make an authenticated request that returns the body directly (no envelope unwrap).
4840
+ * Use for APIs that don't use the @auriclabs/api-core response format (e.g. gateway).
4841
+ */
4842
+ async rawRequest(path, options) {
4843
+ const result = await this._fetch(path, options);
4844
+ if (!result.ok) return result.result;
4845
+ return {
4846
+ ok: true,
4847
+ data: result.body
4848
+ };
4849
+ }
4850
+ /**
4851
+ * Make an authenticated request without attempting text/JSON decoding.
4852
+ * Use for downloads such as a Teams app ZIP where UTF-8 conversion would
4853
+ * corrupt the payload.
4854
+ */
4855
+ async binaryRequest(path, options) {
4856
+ const result = await this._fetchResponse(path, options);
4857
+ if (!result.ok) return result.result;
4858
+ try {
4859
+ return {
4860
+ ok: true,
4861
+ data: {
4862
+ body: await result.res.arrayBuffer(),
4863
+ contentType: result.res.headers.get("Content-Type") ?? void 0,
4864
+ contentDisposition: result.res.headers.get("Content-Disposition") ?? void 0
4865
+ }
4866
+ };
4867
+ } catch (err) {
4868
+ return {
4869
+ ok: false,
4870
+ error: err instanceof Error ? err.message : "Failed to read binary response"
4871
+ };
4872
+ }
4873
+ }
4874
+ getApiBaseUrl() {
4875
+ return this.apiBaseUrl;
4876
+ }
4877
+ };
4795
4878
  //#endregion
4796
4879
  //#region ../../packages-internal/api-client/dist/services/auth.js
4797
4880
  var AuthService = class {
@@ -4818,6 +4901,24 @@ var AuthService = class {
4818
4901
  deleteToken(tokenId) {
4819
4902
  return this.client.request(`${this.prefix}/tokens/${encodeURIComponent(tokenId)}`, { method: "DELETE" });
4820
4903
  }
4904
+ mintPartnerDelegation(input) {
4905
+ return this.client.request(`${this.prefix}/partner-delegations`, {
4906
+ method: "POST",
4907
+ body: JSON.stringify(input)
4908
+ });
4909
+ }
4910
+ mintPartnerElevatedDelegation(input) {
4911
+ return this.client.request(`${this.prefix}/partner-delegations/elevated`, {
4912
+ method: "POST",
4913
+ body: JSON.stringify(input)
4914
+ });
4915
+ }
4916
+ refreshPartnerDelegation(delegationId) {
4917
+ return this.client.request(`${this.prefix}/partner-delegations/${encodeURIComponent(delegationId)}/refresh`, { method: "POST" });
4918
+ }
4919
+ revokePartnerDelegation(delegationId) {
4920
+ return this.client.request(`${this.prefix}/partner-delegations/${encodeURIComponent(delegationId)}`, { method: "DELETE" });
4921
+ }
4821
4922
  /**
4822
4923
  * Start a device-code flow. Called by the CLI when the user runs
4823
4924
  * `alfe login` and picks the browser path. The returned `device_code`
@@ -5138,6 +5239,15 @@ var IntegrationsService = class {
5138
5239
  const query = new URLSearchParams({ agentId });
5139
5240
  return this.client.request(`/discord/guilds/${encodeURIComponent(guildId)}/channels?${query}`);
5140
5241
  }
5242
+ getDiscordAppSetup(agentId) {
5243
+ return this.client.request(`/discord/agents/${encodeURIComponent(agentId)}/app`);
5244
+ }
5245
+ configureDiscordApp(agentId, input) {
5246
+ return this.client.request(`/discord/agents/${encodeURIComponent(agentId)}/app`, {
5247
+ method: "PUT",
5248
+ body: JSON.stringify(input)
5249
+ });
5250
+ }
5141
5251
  searchMobileNumbers(country, query) {
5142
5252
  const params = new URLSearchParams();
5143
5253
  if (country !== void 0) params.set("country", country);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/gateway",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "description": "Alfe local gateway daemon — persistent control plane for agent integrations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,11 +23,11 @@
23
23
  "pino-roll": "^1.2.0",
24
24
  "smol-toml": ">=1.6.1",
25
25
  "ws": "^8.18.0",
26
- "@alfe.ai/agent-api-client": "^0.16.1",
26
+ "@alfe.ai/agent-api-client": "^0.17.0",
27
27
  "@alfe.ai/ai-proxy-local": "^0.0.16",
28
28
  "@alfe.ai/config": "^0.4.1",
29
- "@alfe.ai/integration-manifest": "^0.3.6",
30
- "@alfe.ai/integrations": "^0.6.3",
29
+ "@alfe.ai/integration-manifest": "^0.4.0",
30
+ "@alfe.ai/integrations": "^0.6.4",
31
31
  "@alfe.ai/mcp-bundler": "^0.4.1"
32
32
  },
33
33
  "license": "UNLICENSED",