@opengeni/config 0.13.2 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,12 +2,15 @@
2
2
  import {
3
3
  BillingMode,
4
4
  CAPABILITY_DESCRIPTORS,
5
+ DEFAULT_FIRST_PARTY_MCP_TOOLS,
5
6
  Entitlements,
6
7
  EntitlementsMode,
7
8
  LatencyMode,
8
9
  MAX_NESTED_AGENT_DEPTH,
9
10
  ProductAccessMode,
10
11
  ReasoningEffort,
12
+ FIRST_PARTY_MCP_TOOL_NAMES,
13
+ FirstPartyMcpToolName,
11
14
  SandboxBackend,
12
15
  SessionMcpApprovalPolicy,
13
16
  SEEDANCE_2_5_MODEL_ID,
@@ -25,6 +28,16 @@ import {
25
28
  CODEX_PROVIDER_BASE_URL,
26
29
  CODEX_PROVIDER_ID
27
30
  } from "@opengeni/codex/constants";
31
+ import {
32
+ XAI_SUBSCRIPTION_MODEL_SLUGS,
33
+ XAI_SUBSCRIPTION_MODEL_AUTO_COMPACT_TOKEN_LIMIT,
34
+ XAI_SUBSCRIPTION_MODEL_CONTEXT_WINDOW_TOKENS,
35
+ XAI_SUBSCRIPTION_MODEL_EFFECTIVE_CONTEXT_WINDOW_TOKENS,
36
+ XAI_SUBSCRIPTION_MODEL_ID_PREFIX,
37
+ XAI_SUBSCRIPTION_PROVIDER_ID,
38
+ XAI_SUBSCRIPTION_PROXY_BASE_URL
39
+ } from "@opengeni/xai-subscription";
40
+ import { XAI_SUBSCRIPTION_MODEL_ID_PREFIX as XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 } from "@opengeni/xai-subscription";
28
41
  import { createHash } from "crypto";
29
42
  import { z } from "zod";
30
43
  var envName = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -47,6 +60,34 @@ var EnvBoolean = z.preprocess((value) => {
47
60
  }
48
61
  return value;
49
62
  }, z.boolean());
63
+ var EnvFirstPartyMcpTools = z.preprocess(
64
+ (value) => {
65
+ if (typeof value !== "string") return value;
66
+ const source = value.trim();
67
+ if (!source) return void 0;
68
+ if (source.startsWith("[")) {
69
+ try {
70
+ return JSON.parse(source);
71
+ } catch {
72
+ return value;
73
+ }
74
+ }
75
+ return source.split(",").map((entry) => entry.trim());
76
+ },
77
+ z.array(FirstPartyMcpToolName).superRefine((tools, context) => {
78
+ const seen = /* @__PURE__ */ new Set();
79
+ for (const [index, tool] of tools.entries()) {
80
+ if (seen.has(tool)) {
81
+ context.addIssue({
82
+ code: "custom",
83
+ message: "first-party MCP tool lists must not contain duplicates",
84
+ path: [index]
85
+ });
86
+ }
87
+ seen.add(tool);
88
+ }
89
+ }).optional()
90
+ );
50
91
  var sandboxPreparationProfiles = {
51
92
  none: {
52
93
  env: [],
@@ -86,7 +127,7 @@ var DEFAULT_AGENT_INSTRUCTIONS = [
86
127
  "Repository resources are mounted under repos/<host>/<owner>/<repo> unless the session specifies another collision-free mount path.",
87
128
  "File resources are mounted under .opengeni/files/<file-id>/ unless the session specifies another mount path.",
88
129
  "Attached files are mounted read-only; copy them before modifying.",
89
- "Bundled skills are under .agents/ and can include infrastructure, marketing, or other role-specific guidance.",
130
+ "Installed and selected Skills are indexed under .agents/ and may include role-specific guidance.",
90
131
  "Use Checkov, Terraform, Azure CLI, git provider CLIs, and repository tools when relevant; gh, glab, and az repos are pre-authenticated when the host brokers matching git credentials.",
91
132
  "When the Azure sandbox preparation profile is enabled and service-principal variables are present, the sandbox is pre-authenticated with normal Azure CLI before work starts.",
92
133
  "Treat code-changing work as GitOps work: create a focused branch/commit/PR when git provider credentials are available; otherwise report exact commands and blockers.",
@@ -215,6 +256,8 @@ var SettingsSchema = z.object({
215
256
  staticEntitlementsJson: z.string().default("{}"),
216
257
  staticUsageLimitsJson: z.string().default("{}"),
217
258
  delegationSecret: z.string().optional(),
259
+ defaultFirstPartyMcpTools: EnvFirstPartyMcpTools,
260
+ allowedFirstPartyMcpTools: EnvFirstPartyMcpTools,
218
261
  // sandbox workspace scoped stream-token HMAC secret (sandbox contract §C.3 / stream-token availability contract).
219
262
  // When unset, the API falls back to `delegationSecret` (the same HMAC envelope
220
263
  // family, `ogs_` vs `ogd_` prefix). REQUIRED-WHEN-DESKTOP, but the absence of
@@ -241,6 +284,8 @@ var SettingsSchema = z.object({
241
284
  slackSigningSecret: z.string().optional(),
242
285
  googleDriveClientId: z.string().optional(),
243
286
  googleDriveClientSecret: z.string().optional(),
287
+ fikenClientId: z.string().optional(),
288
+ fikenClientSecret: z.string().optional(),
244
289
  googleDriveWorkspaceEventsEnabled: EnvBoolean.optional(),
245
290
  atlassianClientId: z.string().optional(),
246
291
  atlassianClientSecret: z.string().optional(),
@@ -344,10 +389,10 @@ var SettingsSchema = z.object({
344
389
  voiceInputResumableRetentionSeconds: z.coerce.number().int().positive().max(7 * 24 * 60 * 60).default(24 * 60 * 60),
345
390
  voiceInputFfmpegPath: z.string().trim().min(1).max(1024).default("ffmpeg"),
346
391
  // Preferred provider order (comma-separated ids). First configured+ready wins.
347
- // Codex subscription STT is preferred by default when subscription routing is
348
- // enabled; operators can put openai/azure-openai first explicitly.
349
- // Supported: openai, azure-openai, codex-subscription.
350
- voiceInputProviderOrder: z.string().default("codex-subscription,openai,azure-openai"),
392
+ // Connected subscription STT is preferred by default; operators can put
393
+ // openai/azure-openai first explicitly.
394
+ // Supported: supergrok-subscription, codex-subscription, openai, azure-openai.
395
+ voiceInputProviderOrder: z.string().default("supergrok-subscription,codex-subscription,openai,azure-openai"),
351
396
  // OpenAI public /v1/audio/transcriptions path. Reuses OPENGENI_OPENAI_API_KEY
352
397
  // when voiceInputOpenaiApiKey is unset. Default model is gpt-transcribe.
353
398
  voiceInputOpenaiEnabled: EnvBoolean.default(true),
@@ -380,6 +425,10 @@ var SettingsSchema = z.object({
380
425
  // provider whose models route through the ChatGPT backend (@opengeni/codex).
381
426
  codexSubscriptionEnabled: EnvBoolean.default(false),
382
427
  // OPENGENI_CODEX_SUBSCRIPTION_ENABLED
428
+ // SuperGrok/xAI connected subscription. This is a workspace-scoped OAuth
429
+ // account pool and a distinct rail from the existing xai/* API-key provider.
430
+ supergrokSubscriptionEnabled: EnvBoolean.default(false),
431
+ // OPENGENI_SUPERGROK_SUBSCRIPTION_ENABLED
383
432
  // Expose the connected apps attached to a Codex subscription through the
384
433
  // synthetic codex_apps MCP server. Independent from subscription routing so
385
434
  // operators can use Codex models without exposing ChatGPT connectors.
@@ -479,7 +528,7 @@ var SettingsSchema = z.object({
479
528
  // never asks Modal to parse or import the registry ref. The logical ref is
480
529
  // still persisted on the sandbox lease for provenance and conflict fencing;
481
530
  // the Modal session envelope persists the actual image ID.
482
- modalImageId: z.string().regex(/^im-[A-Za-z0-9]{22}$/).optional(),
531
+ modalImageId: z.string().min(4).max(128).regex(/^im-[A-Za-z0-9]+$/).optional(),
483
532
  // Name of a Modal Secret (containing REGISTRY_USERNAME + REGISTRY_PASSWORD) used
484
533
  // to authenticate the pull of `modalImageRef` from a PRIVATE registry. When UNSET
485
534
  // (the default), the sandbox image is pulled UNAUTHENTICATED — i.e. it must be a
@@ -524,8 +573,9 @@ var SettingsSchema = z.object({
524
573
  // /workspace FILE PERSISTENCE across warm/cold cycles. Directory snapshots
525
574
  // preserve only the durable user workspace, so provider recovery does not
526
575
  // restore an entire machine image or replace the selected rig/base image.
527
- // Existing serialized sessions retain their original persistence mode and
528
- // remain recoverable; this default governs newly created Modal sandboxes.
576
+ // Cold restore derives the mode from its verified native artifact, so existing
577
+ // serialized sessions remain recoverable; this default governs archive-free
578
+ // Modal creations only.
529
579
  // `snapshot_filesystem` remains available for explicit compatibility and
530
580
  // immutable rig-image materialization. `tar` is the portable fallback.
531
581
  modalWorkspacePersistence: z.enum(["tar", "snapshot_filesystem", "snapshot_directory"]).default("snapshot_directory"),
@@ -610,6 +660,14 @@ var SettingsSchema = z.object({
610
660
  // --- cloudflare (headless) ---
611
661
  cloudflareWorkerUrl: z.string().url().optional(),
612
662
  cloudflareApiKey: z.string().optional(),
663
+ // --- remote browser placements ---
664
+ // Provider credentials are injected only into the placement-resident
665
+ // browserd launch. They never enter session contracts, journals, or sandboxes.
666
+ browserbaseApiKey: z.string().min(1).max(8192).optional(),
667
+ kernelApiKey: z.string().min(1).max(8192).optional(),
668
+ kernelEndpoint: z.string().url().optional(),
669
+ kernelBrowserTimeoutSeconds: z.coerce.number().int().positive().max(86400).default(3600),
670
+ kernelBrowserStealth: EnvBoolean.default(false),
613
671
  // --- vercel (headless) ---
614
672
  vercelToken: z.string().optional(),
615
673
  vercelProjectId: z.string().optional(),
@@ -896,7 +954,7 @@ function isUsableVoiceInputSecret(value) {
896
954
  }
897
955
  function resolveVoiceInputProviderRegistry(settings) {
898
956
  const order = settings.voiceInputProviderOrder.split(",").map((part) => part.trim()).filter(
899
- (part) => part === "openai" || part === "azure-openai" || part === "codex-subscription"
957
+ (part) => part === "openai" || part === "azure-openai" || part === "codex-subscription" || part === "supergrok-subscription"
900
958
  );
901
959
  const seen = /* @__PURE__ */ new Set();
902
960
  const providers = [];
@@ -950,13 +1008,22 @@ function resolveVoiceInputProviderRegistry(settings) {
950
1008
  kind: "codex-subscription",
951
1009
  experimental: true
952
1010
  });
1011
+ continue;
1012
+ }
1013
+ if (id === "supergrok-subscription") {
1014
+ if (!settings.supergrokSubscriptionEnabled) continue;
1015
+ providers.push({
1016
+ id: "supergrok-subscription",
1017
+ kind: "supergrok-subscription",
1018
+ experimental: true
1019
+ });
953
1020
  }
954
1021
  }
955
1022
  return providers;
956
1023
  }
957
1024
  function voiceInputDeploymentConfigured(settings) {
958
1025
  return resolveVoiceInputProviderRegistry(settings).some(
959
- (provider) => provider.kind !== "codex-subscription"
1026
+ (provider) => provider.kind !== "codex-subscription" && provider.kind !== "supergrok-subscription"
960
1027
  );
961
1028
  }
962
1029
  var ModelPricingSchema = z.object({
@@ -1093,6 +1160,7 @@ var ModelProviderApi = z.enum(["responses", "chat"]);
1093
1160
  var RegistryProviderKind = z.enum([
1094
1161
  "api-key",
1095
1162
  "codex-subscription",
1163
+ "xai-subscription",
1096
1164
  "vercel-gateway-managed",
1097
1165
  "vercel-gateway-workspace"
1098
1166
  ]);
@@ -1173,6 +1241,7 @@ var WORKSPACE_GATEWAY_MODEL_ID_PREFIX = "workspace-gateway/";
1173
1241
  var VERCEL_AI_GATEWAY_CONNECTION_DOMAIN = "ai-gateway.vercel.sh";
1174
1242
  var VERCEL_AI_GATEWAY_CONNECTION_ROLE = "vercel_ai_gateway";
1175
1243
  var CODEX_REALTIME_MODEL_ID = "gpt-live-1-boulder-alpha";
1244
+ var SUPERGROK_REALTIME_MODEL_ID = "supergrok/grok-voice-think-fast-2.0";
1176
1245
  var OPENGENI_REALTIME_MODEL_ID_PREFIX = "opengeni-gateway/";
1177
1246
  var WORKSPACE_REALTIME_MODEL_ID_PREFIX = "workspace-gateway/";
1178
1247
  var AI_GATEWAY_REALTIME_MODELS = {
@@ -1410,6 +1479,8 @@ function getSettings() {
1410
1479
  staticEntitlementsJson: optional("OPENGENI_STATIC_ENTITLEMENTS_JSON"),
1411
1480
  staticUsageLimitsJson: optional("OPENGENI_STATIC_USAGE_LIMITS_JSON"),
1412
1481
  delegationSecret: optional("OPENGENI_DELEGATION_SECRET"),
1482
+ defaultFirstPartyMcpTools: optional("OPENGENI_DEFAULT_FIRST_PARTY_MCP_TOOLS"),
1483
+ allowedFirstPartyMcpTools: optional("OPENGENI_ALLOWED_FIRST_PARTY_MCP_TOOLS"),
1413
1484
  streamTokenSecret: optional("OPENGENI_STREAM_TOKEN_SECRET"),
1414
1485
  streamControlEnabled: optional("OPENGENI_STREAM_CONTROL_ENABLED"),
1415
1486
  codemodeMaxCallsPerTurn: optional("OPENGENI_CODEMODE_MAX_CALLS_PER_TURN"),
@@ -1427,6 +1498,8 @@ function getSettings() {
1427
1498
  slackSigningSecret: optional("OPENGENI_SLACK_SIGNING_SECRET"),
1428
1499
  googleDriveClientId: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_ID"),
1429
1500
  googleDriveClientSecret: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_SECRET"),
1501
+ fikenClientId: optional("OPENGENI_FIKEN_OAUTH_CLIENT_ID"),
1502
+ fikenClientSecret: optional("OPENGENI_FIKEN_OAUTH_CLIENT_SECRET"),
1430
1503
  googleDriveWorkspaceEventsEnabled: optional("OPENGENI_GOOGLE_DRIVE_WORKSPACE_EVENTS_ENABLED"),
1431
1504
  atlassianClientId: optional("OPENGENI_ATLASSIAN_CLIENT_ID"),
1432
1505
  atlassianClientSecret: optional("OPENGENI_ATLASSIAN_CLIENT_SECRET"),
@@ -1503,6 +1576,7 @@ function getSettings() {
1503
1576
  modelPricingJson: optional("OPENGENI_MODEL_PRICING_JSON"),
1504
1577
  modelProvidersJson: optional("OPENGENI_MODEL_PROVIDERS_JSON"),
1505
1578
  codexSubscriptionEnabled: optional("OPENGENI_CODEX_SUBSCRIPTION_ENABLED"),
1579
+ supergrokSubscriptionEnabled: optional("OPENGENI_SUPERGROK_SUBSCRIPTION_ENABLED"),
1506
1580
  codexConnectedAppsEnabled: optional("OPENGENI_CODEX_CONNECTED_APPS_ENABLED"),
1507
1581
  codexToolSearchEnabled: optional("OPENGENI_CODEX_TOOL_SEARCH_ENABLED"),
1508
1582
  lazyToolSearchEnabled: optional("OPENGENI_LAZY_TOOL_SEARCH_ENABLED"),
@@ -1583,6 +1657,11 @@ function getSettings() {
1583
1657
  blaxelTtl: optional("OPENGENI_BLAXEL_TTL"),
1584
1658
  cloudflareWorkerUrl: optional("OPENGENI_CLOUDFLARE_WORKER_URL"),
1585
1659
  cloudflareApiKey: optional("OPENGENI_CLOUDFLARE_API_KEY"),
1660
+ browserbaseApiKey: optional("OPENGENI_BROWSERBASE_API_KEY"),
1661
+ kernelApiKey: optional("OPENGENI_KERNEL_API_KEY"),
1662
+ kernelEndpoint: optional("OPENGENI_KERNEL_ENDPOINT"),
1663
+ kernelBrowserTimeoutSeconds: optional("OPENGENI_KERNEL_BROWSER_TIMEOUT_SECONDS"),
1664
+ kernelBrowserStealth: optional("OPENGENI_KERNEL_BROWSER_STEALTH"),
1586
1665
  vercelToken: optional("OPENGENI_VERCEL_TOKEN"),
1587
1666
  vercelProjectId: optional("OPENGENI_VERCEL_PROJECT_ID"),
1588
1667
  vercelTeamId: optional("OPENGENI_VERCEL_TEAM_ID"),
@@ -1693,8 +1772,26 @@ var LOCAL_FIRST_PARTY_DELEGATION_SECRET = "opengeni-local-first-party-delegation
1693
1772
  function resolveFirstPartyDelegationSecret(settings) {
1694
1773
  const explicit = settings.delegationSecret?.trim();
1695
1774
  if (explicit) return explicit;
1775
+ const configuredAccessKey = settings.accessKey?.trim();
1776
+ if (settings.productAccessMode === "configured" && settings.authRequired && configuredAccessKey) {
1777
+ return configuredAccessKey;
1778
+ }
1696
1779
  return settings.productAccessMode === "local" && (settings.environment === "local" || settings.environment === "test") ? LOCAL_FIRST_PARTY_DELEGATION_SECRET : void 0;
1697
1780
  }
1781
+ function resolveFirstPartyMcpToolPolicy(settings) {
1782
+ const allowed = settings.allowedFirstPartyMcpTools ?? [...FIRST_PARTY_MCP_TOOL_NAMES];
1783
+ const allowedSet = new Set(allowed);
1784
+ const defaults = settings.defaultFirstPartyMcpTools ?? [...DEFAULT_FIRST_PARTY_MCP_TOOLS];
1785
+ return {
1786
+ default: defaults.filter((tool) => allowedSet.has(tool)),
1787
+ allowed: [...allowed]
1788
+ };
1789
+ }
1790
+ function allowedFirstPartyMcpToolsForSession(settings, selected) {
1791
+ const policy = resolveFirstPartyMcpToolPolicy(settings);
1792
+ const allowed = new Set(policy.allowed);
1793
+ return [...selected ?? policy.default].filter((tool) => allowed.has(tool));
1794
+ }
1698
1795
  function effectiveModalIdleTimeoutSeconds(settings) {
1699
1796
  return settings.modalIdleTimeoutSeconds ?? settings.modalTimeoutSeconds;
1700
1797
  }
@@ -2070,6 +2167,10 @@ function withWorkspaceGatewayCredential(settings, apiKey) {
2070
2167
  var GPT56_FAST_BILLING_MULTIPLIER_BPS = 2e4;
2071
2168
  function productLabelForModelId(modelId) {
2072
2169
  const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
2170
+ const grokMatch = /^grok-(\d+(?:\.\d+)?)$/i.exec(slug);
2171
+ if (grokMatch) {
2172
+ return `Grok ${grokMatch[1]}`;
2173
+ }
2073
2174
  const match = /^(gpt-\d+(?:\.\d+)?)(?:-(.+))?$/i.exec(slug);
2074
2175
  if (!match) {
2075
2176
  return slug;
@@ -2085,6 +2186,8 @@ function productLabelForModelId(modelId) {
2085
2186
  function productShortLabelForModelId(modelId) {
2086
2187
  const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
2087
2188
  switch (slug) {
2189
+ case "grok-4.6":
2190
+ return "4.6";
2088
2191
  case "gpt-5.6-sol":
2089
2192
  return "5.6 Sol";
2090
2193
  case "gpt-5.6-terra":
@@ -2129,7 +2232,7 @@ function serviceTierForLatencyMode(providerId, latencyMode) {
2129
2232
  if (latencyMode === "standard") {
2130
2233
  return void 0;
2131
2234
  }
2132
- if (providerId === "azure" || providerId === CODEX_PROVIDER_ID) {
2235
+ if (providerId === "azure" || providerId === CODEX_PROVIDER_ID || providerId === XAI_SUBSCRIPTION_PROVIDER_ID) {
2133
2236
  return "priority";
2134
2237
  }
2135
2238
  return "fast";
@@ -2162,13 +2265,16 @@ function registryCredentialSource(provider) {
2162
2265
  if (provider.kind === "codex-subscription") {
2163
2266
  return { kind: "connected_subscription", provider: "codex" };
2164
2267
  }
2268
+ if (provider.kind === "xai-subscription") {
2269
+ return { kind: "connected_subscription", provider: "xai" };
2270
+ }
2165
2271
  if (provider.kind === "vercel-gateway-workspace") {
2166
2272
  return { kind: "workspace_connection", mechanism: "api_key" };
2167
2273
  }
2168
2274
  return { kind: "deployment", mechanism: "api_key" };
2169
2275
  }
2170
2276
  function registryBilling(provider) {
2171
- if (provider.kind === "codex-subscription") {
2277
+ if (provider.kind === "codex-subscription" || provider.kind === "xai-subscription") {
2172
2278
  return { upstreamPayer: "connected_subscription", metering: "external" };
2173
2279
  }
2174
2280
  if (provider.kind === "vercel-gateway-workspace") {
@@ -2327,11 +2433,55 @@ function withCodexCatalogProvider(settings) {
2327
2433
  modelProvidersJson: JSON.stringify([...providers, provider])
2328
2434
  };
2329
2435
  }
2436
+ function withXaiSubscriptionCatalogProvider(settings) {
2437
+ const providers = parseModelProvidersJson(settings.modelProvidersJson);
2438
+ if (providers.some((provider2) => provider2.id === XAI_SUBSCRIPTION_PROVIDER_ID)) {
2439
+ return settings;
2440
+ }
2441
+ const provider = {
2442
+ kind: "xai-subscription",
2443
+ id: XAI_SUBSCRIPTION_PROVIDER_ID,
2444
+ label: "SuperGrok (xAI subscription)",
2445
+ api: "responses",
2446
+ baseUrl: XAI_SUBSCRIPTION_PROXY_BASE_URL,
2447
+ models: XAI_SUBSCRIPTION_MODEL_SLUGS.map((slug) => {
2448
+ const capabilities = legacyModelCapabilities(settings, {
2449
+ reasoningEffort: true,
2450
+ hostedWebSearch: true
2451
+ });
2452
+ capabilities.reasoning.efforts = ["low", "medium", "high", "xhigh"];
2453
+ capabilities.reasoning.defaultEffort = "high";
2454
+ capabilities.latencyModes = [
2455
+ { id: "standard", upstream: "supported", runnable: true },
2456
+ { id: "fast", upstream: "supported", runnable: true }
2457
+ ];
2458
+ capabilities.hostedTools.xSearch = { upstream: "supported", runnable: true };
2459
+ capabilities.hostedTools.imageGeneration = { upstream: "supported", runnable: true };
2460
+ return {
2461
+ id: `${XAI_SUBSCRIPTION_MODEL_ID_PREFIX}${slug}`,
2462
+ upstreamModelId: slug,
2463
+ label: productLabelForModelId(slug),
2464
+ ...productShortLabelForModelId(slug) ? { shortLabel: productShortLabelForModelId(slug) } : {},
2465
+ reasoningEffort: true,
2466
+ hostedWebSearch: true,
2467
+ capabilities,
2468
+ contextWindowTokens: XAI_SUBSCRIPTION_MODEL_CONTEXT_WINDOW_TOKENS,
2469
+ effectiveContextWindowTokens: XAI_SUBSCRIPTION_MODEL_EFFECTIVE_CONTEXT_WINDOW_TOKENS,
2470
+ autoCompactTokenLimit: XAI_SUBSCRIPTION_MODEL_AUTO_COMPACT_TOKEN_LIMIT,
2471
+ toolOutputTruncationTokens: settings.modelToolOutputTruncationTokens
2472
+ };
2473
+ })
2474
+ };
2475
+ return { ...settings, modelProvidersJson: JSON.stringify([...providers, provider]) };
2476
+ }
2330
2477
  function policyProviderIdForModel(settings, modelId) {
2331
2478
  const canonicalModelId = canonicalizeConfiguredModelId(settings, modelId);
2332
2479
  if (canonicalModelId.startsWith(CODEX_MODEL_ID_PREFIX)) {
2333
2480
  return CODEX_PROVIDER_ID;
2334
2481
  }
2482
+ if (canonicalModelId.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX)) {
2483
+ return XAI_SUBSCRIPTION_PROVIDER_ID;
2484
+ }
2335
2485
  if (canonicalModelId.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX)) {
2336
2486
  return WORKSPACE_GATEWAY_PROVIDER_ID;
2337
2487
  }
@@ -2403,7 +2553,7 @@ function configuredModels(settings) {
2403
2553
  const registryAliases = new Set(
2404
2554
  parsedRegistry.flatMap((provider) => provider.models.flatMap((model) => model.aliases ?? []))
2405
2555
  );
2406
- const isRegistryNamespaced = (id) => id.startsWith(CODEX_MODEL_ID_PREFIX) || registryAliases.has(id) || id.includes("/") && registryOwnedIds.has(id);
2556
+ const isRegistryNamespaced = (id) => id.startsWith(CODEX_MODEL_ID_PREFIX) || id.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX) || registryAliases.has(id) || id.includes("/") && registryOwnedIds.has(id);
2407
2557
  const builtinProvider = providerById.get(builtinId);
2408
2558
  if (!builtinProvider) {
2409
2559
  throw new Error(`Built-in model provider ${builtinId} is not configured`);
@@ -2513,6 +2663,9 @@ function settingsForTurnExecutionPolicy(settings, modelId) {
2513
2663
  if (settings.codexSubscriptionEnabled && modelId.startsWith(CODEX_MODEL_ID_PREFIX)) {
2514
2664
  return withCodexCatalogProvider(settings);
2515
2665
  }
2666
+ if (settings.supergrokSubscriptionEnabled && modelId.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX)) {
2667
+ return withXaiSubscriptionCatalogProvider(settings);
2668
+ }
2516
2669
  if (modelId.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX)) {
2517
2670
  return withWorkspaceGatewayCatalogProvider(settings);
2518
2671
  }
@@ -3242,6 +3395,8 @@ function ensureBuiltInMcpServers(settings) {
3242
3395
  "list_document_bases",
3243
3396
  "list_indexed_documents",
3244
3397
  "knowledge_search",
3398
+ "knowledge_get",
3399
+ "knowledge_browse",
3245
3400
  "knowledge_fetch",
3246
3401
  "memory_search",
3247
3402
  "memory_propose"
@@ -3267,11 +3422,19 @@ function firstPartyMcpWorkspaceUrl(settings, workspaceId) {
3267
3422
  return url.toString();
3268
3423
  }
3269
3424
  function codemodeWorkspaceUrl(settings, workspaceId) {
3270
- const url = new URL(firstPartyMcpWorkspaceUrl(settings, workspaceId));
3271
- if (!url.pathname.endsWith("/mcp")) {
3272
- throw new Error("First-party MCP URL cannot be projected to the Codemode endpoint");
3425
+ if (settings.opengeniMcpUrl) {
3426
+ const url2 = new URL(firstPartyMcpWorkspaceUrl(settings, workspaceId));
3427
+ if (!url2.pathname.endsWith("/mcp")) {
3428
+ throw new Error("First-party MCP URL cannot be projected to the Codemode endpoint");
3429
+ }
3430
+ url2.pathname = `${url2.pathname.slice(0, -4)}/codemode`;
3431
+ return url2.toString();
3273
3432
  }
3274
- url.pathname = `${url.pathname.slice(0, -4)}/codemode`;
3433
+ const executionOrigin = settings.sandboxBackend === "docker" ? `http://host.docker.internal:${settings.apiPort}` : settings.sandboxBackend === "local" ? `http://127.0.0.1:${settings.apiPort}` : settings.publicBaseUrl ?? `http://127.0.0.1:${settings.apiPort}`;
3434
+ const url = new URL(executionOrigin);
3435
+ url.pathname = `${url.pathname.replace(/\/+$/u, "")}/v1/workspaces/${workspaceId}/codemode`;
3436
+ url.search = "";
3437
+ url.hash = "";
3275
3438
  return url.toString();
3276
3439
  }
3277
3440
  function firstPartyMcpServerUrl(settings) {
@@ -3285,6 +3448,17 @@ function firstPartyFilesMcpServerUrl(mcpUrl) {
3285
3448
  }
3286
3449
  function validateSettings(settings) {
3287
3450
  temporalConnectionOptions(settings);
3451
+ const allowedFirstPartyMcpTools = new Set(
3452
+ settings.allowedFirstPartyMcpTools ?? FIRST_PARTY_MCP_TOOL_NAMES
3453
+ );
3454
+ const disallowedDefaults = (settings.defaultFirstPartyMcpTools ?? []).filter(
3455
+ (tool) => !allowedFirstPartyMcpTools.has(tool)
3456
+ );
3457
+ if (disallowedDefaults.length > 0) {
3458
+ throw new Error(
3459
+ `OPENGENI_DEFAULT_FIRST_PARTY_MCP_TOOLS must be a subset of OPENGENI_ALLOWED_FIRST_PARTY_MCP_TOOLS: ${disallowedDefaults.join(", ")}`
3460
+ );
3461
+ }
3288
3462
  if (settings.productAccessMode === "managed") {
3289
3463
  if (!settings.publicBaseUrl) {
3290
3464
  throw new Error(
@@ -3355,6 +3529,28 @@ function validateSettings(settings) {
3355
3529
  "OPENGENI_GOOGLE_DRIVE_CLIENT_ID and OPENGENI_GOOGLE_DRIVE_CLIENT_SECRET must be configured together"
3356
3530
  );
3357
3531
  }
3532
+ if (Boolean(settings.fikenClientId) !== Boolean(settings.fikenClientSecret)) {
3533
+ throw new Error(
3534
+ "OPENGENI_FIKEN_OAUTH_CLIENT_ID and OPENGENI_FIKEN_OAUTH_CLIENT_SECRET must be configured together"
3535
+ );
3536
+ }
3537
+ if (settings.fikenClientId) {
3538
+ if (!settings.publicBaseUrl) {
3539
+ throw new Error(
3540
+ "OPENGENI_PUBLIC_BASE_URL is required when the Fiken OAuth integration is configured"
3541
+ );
3542
+ }
3543
+ if (!settings.publicBaseUrl.startsWith("https://") && !["local", "test"].includes(settings.environment)) {
3544
+ throw new Error(
3545
+ "OPENGENI_PUBLIC_BASE_URL must use https when the Fiken OAuth integration is configured outside local/test"
3546
+ );
3547
+ }
3548
+ if (!settings.integrationsStateSecret) {
3549
+ throw new Error(
3550
+ "OPENGENI_INTEGRATIONS_STATE_SECRET is required when the Fiken OAuth integration is configured"
3551
+ );
3552
+ }
3553
+ }
3358
3554
  if (settings.googleDriveClientId) {
3359
3555
  if (!settings.publicBaseUrl) {
3360
3556
  throw new Error(
@@ -3601,9 +3797,9 @@ function validateSettings(settings) {
3601
3797
  const builtinId = builtinProviderId(settings);
3602
3798
  const providerIds = /* @__PURE__ */ new Set();
3603
3799
  for (const provider of registryProviders) {
3604
- if (provider.kind === "vercel-gateway-managed" || provider.kind === "vercel-gateway-workspace") {
3800
+ if (provider.kind === "vercel-gateway-managed" || provider.kind === "vercel-gateway-workspace" || provider.kind === "xai-subscription") {
3605
3801
  throw new Error(
3606
- `OPENGENI_MODEL_PROVIDERS_JSON provider kind ${provider.kind} is reserved for the reviewed AI Gateway broker`
3802
+ `OPENGENI_MODEL_PROVIDERS_JSON provider kind ${provider.kind} is reserved for a reviewed OpenGeni credential broker`
3607
3803
  );
3608
3804
  }
3609
3805
  if (provider.id === builtinId) {
@@ -3728,6 +3924,7 @@ export {
3728
3924
  SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS,
3729
3925
  SANDBOX_REQUIRED_ENV,
3730
3926
  SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS,
3927
+ SUPERGROK_REALTIME_MODEL_ID,
3731
3928
  SocialOAuthClientConfigSchema,
3732
3929
  VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
3733
3930
  VERCEL_AI_GATEWAY_BASE_URL,
@@ -3736,6 +3933,8 @@ export {
3736
3933
  WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
3737
3934
  WORKSPACE_GATEWAY_PROVIDER_ID,
3738
3935
  WORKSPACE_REALTIME_MODEL_ID_PREFIX,
3936
+ XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 as XAI_SUBSCRIPTION_MODEL_ID_PREFIX,
3937
+ allowedFirstPartyMcpToolsForSession,
3739
3938
  applyGitAuthPointerEnvironment,
3740
3939
  assertTurnExecutionPolicyMatchesConfigV1,
3741
3940
  builtinProviderId,
@@ -3785,6 +3984,7 @@ export {
3785
3984
  resolveAiGatewayRealtimeModel,
3786
3985
  resolveEnrollmentSigningSecret,
3787
3986
  resolveFirstPartyDelegationSecret,
3987
+ resolveFirstPartyMcpToolPolicy,
3788
3988
  resolveModelProvider,
3789
3989
  resolveNatsCalloutConfig,
3790
3990
  resolveNatsControlPlaneAuth,
@@ -3812,6 +4012,7 @@ export {
3812
4012
  voiceInputDeploymentConfigured,
3813
4013
  withCodexCatalogProvider,
3814
4014
  withWorkspaceGatewayCatalogProvider,
3815
- withWorkspaceGatewayCredential
4015
+ withWorkspaceGatewayCredential,
4016
+ withXaiSubscriptionCatalogProvider
3816
4017
  };
3817
4018
  //# sourceMappingURL=index.js.map