@opengeni/config 0.12.1 → 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.d.ts +362 -12
- package/dist/index.js +433 -63
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +616 -69
package/dist/index.js
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
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,
|
|
16
|
+
SEEDANCE_2_5_MODEL_ID,
|
|
13
17
|
StaticUsageLimits,
|
|
14
18
|
TurnExecutionPolicyV1,
|
|
15
19
|
UsageLimitsMode
|
|
@@ -24,10 +28,25 @@ import {
|
|
|
24
28
|
CODEX_PROVIDER_BASE_URL,
|
|
25
29
|
CODEX_PROVIDER_ID
|
|
26
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";
|
|
27
41
|
import { createHash } from "crypto";
|
|
28
42
|
import { z } from "zod";
|
|
29
43
|
var envName = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
30
44
|
var registryId = /^[A-Za-z0-9_-]+$/;
|
|
45
|
+
var SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS = 60 * 6e4;
|
|
46
|
+
var SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS = 1e4;
|
|
47
|
+
var SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS = SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS - SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS;
|
|
48
|
+
var SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS = 60 * 6e4;
|
|
49
|
+
var SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS = 1e4;
|
|
31
50
|
var EnvBoolean = z.preprocess((value) => {
|
|
32
51
|
if (typeof value !== "string") {
|
|
33
52
|
return value;
|
|
@@ -41,6 +60,34 @@ var EnvBoolean = z.preprocess((value) => {
|
|
|
41
60
|
}
|
|
42
61
|
return value;
|
|
43
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
|
+
);
|
|
44
91
|
var sandboxPreparationProfiles = {
|
|
45
92
|
none: {
|
|
46
93
|
env: [],
|
|
@@ -80,7 +127,7 @@ var DEFAULT_AGENT_INSTRUCTIONS = [
|
|
|
80
127
|
"Repository resources are mounted under repos/<host>/<owner>/<repo> unless the session specifies another collision-free mount path.",
|
|
81
128
|
"File resources are mounted under .opengeni/files/<file-id>/ unless the session specifies another mount path.",
|
|
82
129
|
"Attached files are mounted read-only; copy them before modifying.",
|
|
83
|
-
"
|
|
130
|
+
"Installed and selected Skills are indexed under .agents/ and may include role-specific guidance.",
|
|
84
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.",
|
|
85
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.",
|
|
86
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.",
|
|
@@ -171,6 +218,12 @@ var SettingsSchema = z.object({
|
|
|
171
218
|
turnWorkerMaxConcurrentTurns: z.coerce.number().int().positive().max(2e3).default(16),
|
|
172
219
|
turnWorkerTargetCpuUsage: z.coerce.number().positive().max(1).default(0.8),
|
|
173
220
|
turnWorkerTargetMemoryUsage: z.coerce.number().positive().max(0.8).default(0.75),
|
|
221
|
+
// Admission and emergency recovery are deliberately separate control loops.
|
|
222
|
+
// The Temporal tuner stops polling at the lower target; only genuine danger
|
|
223
|
+
// may invoke the disruptive graceful-drain fallback.
|
|
224
|
+
turnWorkerEmergencyMemoryUsage: z.coerce.number().min(0.85).max(0.95).default(0.9),
|
|
225
|
+
turnWorkerMemoryGuardIntervalMs: z.coerce.number().int().min(1e3).max(6e4).default(5e3),
|
|
226
|
+
turnWorkerMemoryGuardSustainMs: z.coerce.number().int().min(5e3).max(3e5).default(3e4),
|
|
174
227
|
observabilityStructuredLogs: EnvBoolean.default(false),
|
|
175
228
|
observabilityMetricsEnabled: EnvBoolean.default(true),
|
|
176
229
|
observabilityOtlpEndpoint: z.string().url().optional(),
|
|
@@ -192,7 +245,7 @@ var SettingsSchema = z.object({
|
|
|
192
245
|
// Explicit operator-controlled promotion pointer for `/agent/latest/*`.
|
|
193
246
|
// Versioned agent releases are immutable; changing this setting promotes or
|
|
194
247
|
// rolls back the stable channel without moving or deleting a provider tag.
|
|
195
|
-
agentStableVersion: z.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).default("0.1.
|
|
248
|
+
agentStableVersion: z.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).default("0.1.14"),
|
|
196
249
|
// Optional independent beta-channel pointer. When unset, the beta update
|
|
197
250
|
// manifest route is unavailable rather than silently serving stable.
|
|
198
251
|
agentBetaVersion: z.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).optional(),
|
|
@@ -203,6 +256,8 @@ var SettingsSchema = z.object({
|
|
|
203
256
|
staticEntitlementsJson: z.string().default("{}"),
|
|
204
257
|
staticUsageLimitsJson: z.string().default("{}"),
|
|
205
258
|
delegationSecret: z.string().optional(),
|
|
259
|
+
defaultFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
260
|
+
allowedFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
206
261
|
// sandbox workspace scoped stream-token HMAC secret (sandbox contract §C.3 / stream-token availability contract).
|
|
207
262
|
// When unset, the API falls back to `delegationSecret` (the same HMAC envelope
|
|
208
263
|
// family, `ogs_` vs `ogd_` prefix). REQUIRED-WHEN-DESKTOP, but the absence of
|
|
@@ -213,8 +268,7 @@ var SettingsSchema = z.object({
|
|
|
213
268
|
// holder of stream:control gets 403 until this flips. Keeps stream:control a
|
|
214
269
|
// declared-but-inert permission so later hardening is a flag flip.
|
|
215
270
|
streamControlEnabled: EnvBoolean.default(false),
|
|
216
|
-
|
|
217
|
-
toolspaceMaxCallsPerTurn: z.coerce.number().int().positive().default(200),
|
|
271
|
+
codemodeMaxCallsPerTurn: z.coerce.number().int().positive().default(200),
|
|
218
272
|
// Optional release-coherent bootstrap hint for custom rigs/connected machines
|
|
219
273
|
// that do not carry the stock-image ogtool binary. Exact stable versions only:
|
|
220
274
|
// the agent must never guess a tag or silently install `latest`.
|
|
@@ -224,11 +278,17 @@ var SettingsSchema = z.object({
|
|
|
224
278
|
integrationsStateSecret: z.string().optional(),
|
|
225
279
|
integrationsAllowPrivateNetworkTargets: EnvBoolean.default(false),
|
|
226
280
|
integrationsOauthClientsJson: z.string().default("{}"),
|
|
281
|
+
gmailRestAdapterEnabled: EnvBoolean.default(false),
|
|
227
282
|
slackClientId: z.string().optional(),
|
|
228
283
|
slackClientSecret: z.string().optional(),
|
|
229
284
|
slackSigningSecret: z.string().optional(),
|
|
230
285
|
googleDriveClientId: z.string().optional(),
|
|
231
286
|
googleDriveClientSecret: z.string().optional(),
|
|
287
|
+
fikenClientId: z.string().optional(),
|
|
288
|
+
fikenClientSecret: z.string().optional(),
|
|
289
|
+
googleDriveWorkspaceEventsEnabled: EnvBoolean.optional(),
|
|
290
|
+
atlassianClientId: z.string().optional(),
|
|
291
|
+
atlassianClientSecret: z.string().optional(),
|
|
232
292
|
// Undefined is meaningful: the migration boundary persists the product
|
|
233
293
|
// default of 3 when no deployment override is supplied.
|
|
234
294
|
maxNestedAgentDepth: z.coerce.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH).optional(),
|
|
@@ -299,6 +359,20 @@ var SettingsSchema = z.object({
|
|
|
299
359
|
// Gateway models below are added to the managed-credit catalog. Workspace
|
|
300
360
|
// Gateway keys use the encrypted connection broker and never this secret.
|
|
301
361
|
vercelAiGatewayApiKey: z.string().optional(),
|
|
362
|
+
/** Image adapter route; native hosted providers ignore this model. */
|
|
363
|
+
imageGenerationModel: z.string().trim().min(1).max(256).default("openai/gpt-image-2"),
|
|
364
|
+
/** Durable video generation uses the workspace-owned Gateway credential. */
|
|
365
|
+
videoGenerationPollIntervalMs: z.coerce.number().int().min(1e3).max(6e4).default(5e3),
|
|
366
|
+
videoGenerationRecoveryDeadlineMs: z.coerce.number().int().min(6e4).max(24 * 60 * 6e4).default(2 * 60 * 6e4),
|
|
367
|
+
videoGenerationReferenceUrlTtlSeconds: z.coerce.number().int().min(300).max(6 * 60 * 60).default(60 * 60),
|
|
368
|
+
videoGenerationMaxConcurrentPerWorkspace: z.coerce.number().int().min(1).max(16).default(2),
|
|
369
|
+
videoGenerationWorkspaceQuotaBytes: z.coerce.number().int().positive().max(Number.MAX_SAFE_INTEGER).default(20 * 1024 * 1024 * 1024),
|
|
370
|
+
videoGenerationTempDirectory: z.string().trim().min(1).max(1024).default("/tmp/opengeni-video"),
|
|
371
|
+
videoGenerationFfprobePath: z.string().trim().min(1).max(1024).default("ffprobe"),
|
|
372
|
+
// OpenGeni's customer price, not a claim about the provider's delayed cost report.
|
|
373
|
+
// The durable operation freezes the exact resulting price before provider submit.
|
|
374
|
+
videoGenerationCredit480pMicrosPerSecond: z.coerce.number().int().positive().max(1e7).default(155e3),
|
|
375
|
+
videoGenerationCredit720pMicrosPerSecond: z.coerce.number().int().positive().max(1e7).default(35e4),
|
|
302
376
|
// Native composer voice input (browser MediaRecorder → API transcription).
|
|
303
377
|
// Provider credentials stay server-side; ClientConfig only projects availability
|
|
304
378
|
// and hard ceilings. Selection happens once before audio is sent — never retry
|
|
@@ -315,10 +389,10 @@ var SettingsSchema = z.object({
|
|
|
315
389
|
voiceInputResumableRetentionSeconds: z.coerce.number().int().positive().max(7 * 24 * 60 * 60).default(24 * 60 * 60),
|
|
316
390
|
voiceInputFfmpegPath: z.string().trim().min(1).max(1024).default("ffmpeg"),
|
|
317
391
|
// Preferred provider order (comma-separated ids). First configured+ready wins.
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
// Supported:
|
|
321
|
-
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"),
|
|
322
396
|
// OpenAI public /v1/audio/transcriptions path. Reuses OPENGENI_OPENAI_API_KEY
|
|
323
397
|
// when voiceInputOpenaiApiKey is unset. Default model is gpt-transcribe.
|
|
324
398
|
voiceInputOpenaiEnabled: EnvBoolean.default(true),
|
|
@@ -351,6 +425,10 @@ var SettingsSchema = z.object({
|
|
|
351
425
|
// provider whose models route through the ChatGPT backend (@opengeni/codex).
|
|
352
426
|
codexSubscriptionEnabled: EnvBoolean.default(false),
|
|
353
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
|
|
354
432
|
// Expose the connected apps attached to a Codex subscription through the
|
|
355
433
|
// synthetic codex_apps MCP server. Independent from subscription routing so
|
|
356
434
|
// operators can use Codex models without exposing ChatGPT connectors.
|
|
@@ -367,6 +445,11 @@ var SettingsSchema = z.object({
|
|
|
367
445
|
// compatibility diagnosis.
|
|
368
446
|
// OPENGENI_CODEX_TOOL_SEARCH_ENABLED
|
|
369
447
|
codexToolSearchEnabled: EnvBoolean.default(true),
|
|
448
|
+
// Provider-neutral progressive disclosure for direct OpenAI/Azure native
|
|
449
|
+
// client search and ordinary-function generic dispatch. Kept separate from
|
|
450
|
+
// the Codex rollout so an emergency Codex opt-out cannot disable every model.
|
|
451
|
+
// OPENGENI_LAZY_TOOL_SEARCH_ENABLED
|
|
452
|
+
lazyToolSearchEnabled: EnvBoolean.default(true),
|
|
370
453
|
// credential allocator atomic, workspace-local credential allocation. Default OFF is a
|
|
371
454
|
// deliberate rolling-deploy fence: migrate + roll every worker first, then
|
|
372
455
|
// enable. Turning it off restores the legacy sticky selector without a schema
|
|
@@ -424,6 +507,13 @@ var SettingsSchema = z.object({
|
|
|
424
507
|
disableOpenaiTracing: EnvBoolean.default(false),
|
|
425
508
|
sandboxBackend: SandboxBackend.default("docker"),
|
|
426
509
|
dockerImage: z.string().default("opengeni-sandbox:local"),
|
|
510
|
+
// Explicit deployment contract: the configured base sandbox image contains
|
|
511
|
+
// the verified, self-contained native artifact runtime at its fixed image
|
|
512
|
+
// paths. Disabled by default so arbitrary/custom provider images never make
|
|
513
|
+
// document/spreadsheet/presentation skills appear when their runtime is
|
|
514
|
+
// absent. Per-pack/per-rig image overrides fail closed in the worker even
|
|
515
|
+
// when this base-image contract is enabled.
|
|
516
|
+
sandboxArtifactRuntimeEnabled: EnvBoolean.default(false),
|
|
427
517
|
dockerExposedPorts: z.string().default(""),
|
|
428
518
|
dockerNetwork: z.string().optional(),
|
|
429
519
|
// When the worker itself runs in a container and talks to a host Docker daemon,
|
|
@@ -438,7 +528,7 @@ var SettingsSchema = z.object({
|
|
|
438
528
|
// never asks Modal to parse or import the registry ref. The logical ref is
|
|
439
529
|
// still persisted on the sandbox lease for provenance and conflict fencing;
|
|
440
530
|
// the Modal session envelope persists the actual image ID.
|
|
441
|
-
modalImageId: z.string().regex(/^im-[A-Za-z0-9]
|
|
531
|
+
modalImageId: z.string().min(4).max(128).regex(/^im-[A-Za-z0-9]+$/).optional(),
|
|
442
532
|
// Name of a Modal Secret (containing REGISTRY_USERNAME + REGISTRY_PASSWORD) used
|
|
443
533
|
// to authenticate the pull of `modalImageRef` from a PRIVATE registry. When UNSET
|
|
444
534
|
// (the default), the sandbox image is pulled UNAUTHENTICATED — i.e. it must be a
|
|
@@ -480,15 +570,15 @@ var SettingsSchema = z.object({
|
|
|
480
570
|
// SOONER than the hard lifetime; the boot invariant forbids a value that would
|
|
481
571
|
// reap before reaperPeriod + idleGrace elapses.
|
|
482
572
|
modalIdleTimeoutSeconds: z.coerce.number().int().positive().optional(),
|
|
483
|
-
// /workspace FILE PERSISTENCE across warm/cold cycles.
|
|
484
|
-
//
|
|
485
|
-
//
|
|
486
|
-
//
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
//
|
|
491
|
-
modalWorkspacePersistence: z.enum(["tar", "snapshot_filesystem", "snapshot_directory"]).default("
|
|
573
|
+
// /workspace FILE PERSISTENCE across warm/cold cycles. Directory snapshots
|
|
574
|
+
// preserve only the durable user workspace, so provider recovery does not
|
|
575
|
+
// restore an entire machine image or replace the selected rig/base image.
|
|
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.
|
|
579
|
+
// `snapshot_filesystem` remains available for explicit compatibility and
|
|
580
|
+
// immutable rig-image materialization. `tar` is the portable fallback.
|
|
581
|
+
modalWorkspacePersistence: z.enum(["tar", "snapshot_filesystem", "snapshot_directory"]).default("snapshot_directory"),
|
|
492
582
|
// Shared desktop toggle: this module reads it for the 6080 port-merge; the
|
|
493
583
|
// owner module (P4.x) acts on it to launch the display stack.
|
|
494
584
|
sandboxDesktopEnabled: EnvBoolean.default(false),
|
|
@@ -570,6 +660,14 @@ var SettingsSchema = z.object({
|
|
|
570
660
|
// --- cloudflare (headless) ---
|
|
571
661
|
cloudflareWorkerUrl: z.string().url().optional(),
|
|
572
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),
|
|
573
671
|
// --- vercel (headless) ---
|
|
574
672
|
vercelToken: z.string().optional(),
|
|
575
673
|
vercelProjectId: z.string().optional(),
|
|
@@ -699,6 +797,10 @@ var SettingsSchema = z.object({
|
|
|
699
797
|
// snapshotted before the box dies (sandbox-file-persistence).
|
|
700
798
|
sandboxLeaseReaperPeriodMs: z.coerce.number().int().positive().default(3e4),
|
|
701
799
|
sandboxViewerHolderTtlMs: z.coerce.number().int().positive().default(9e4),
|
|
800
|
+
// A BrowserSession controller refreshes its durable resource and exact
|
|
801
|
+
// interaction lease holder together. This longer crash horizon tolerates API
|
|
802
|
+
// replacement while still releasing a placement whose controller died.
|
|
803
|
+
sandboxInteractionHolderTtlMs: z.coerce.number().int().positive().default(18e4),
|
|
702
804
|
// The DRAIN grace: how long a refcount-0 (draining) lease stays WARM before the
|
|
703
805
|
// reaper resume-by-ids the box and terminates it. This is the cost-vs-snappiness
|
|
704
806
|
// dial — when the user navigates away the box keeps refcount 0, but it survives
|
|
@@ -724,7 +826,7 @@ var SettingsSchema = z.object({
|
|
|
724
826
|
// graceful shutdown, or become permission to GC an older archive. Timeout is
|
|
725
827
|
// treated exactly like a failed best-effort snapshot. Knob:
|
|
726
828
|
// OPENGENI_SANDBOX_SNAPSHOT_TIMEOUT_MS. Default 60s.
|
|
727
|
-
sandboxSnapshotTimeoutMs: z.coerce.number().int().positive().default(6e4),
|
|
829
|
+
sandboxSnapshotTimeoutMs: z.coerce.number().int().positive().max(SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS).default(6e4),
|
|
728
830
|
// Begin a controlled snapshot/quiesce/drain/rematerialize transition this far
|
|
729
831
|
// ahead of a finite provider deadline. Modal's 24h creation clock cannot be
|
|
730
832
|
// extended; the logical sandbox outlives it by moving to one successor box.
|
|
@@ -734,13 +836,12 @@ var SettingsSchema = z.object({
|
|
|
734
836
|
// an operator deliberately wants more rotation headroom; the boot invariant
|
|
735
837
|
// still requires it to remain below the provider lifetime.
|
|
736
838
|
sandboxRotationLeadMs: z.coerce.number().int().positive().default(36e5),
|
|
737
|
-
// Bound
|
|
738
|
-
//
|
|
739
|
-
//
|
|
740
|
-
//
|
|
741
|
-
//
|
|
742
|
-
|
|
743
|
-
sandboxRotationBatchSize: z.coerce.number().int().positive().max(500).default(1),
|
|
839
|
+
// Bound provider-deadline rotation admission independently of execution.
|
|
840
|
+
// Every admitted box receives its own durable drain child; the control worker
|
|
841
|
+
// limits provider I/O to 32 concurrent activities. Matching that bound avoids
|
|
842
|
+
// both the old one-box-per-tick deadline backlog and an unbounded provider/API
|
|
843
|
+
// burst. Operators may tune this for a differently-sized worker pool.
|
|
844
|
+
sandboxRotationBatchSize: z.coerce.number().int().positive().max(500).default(32),
|
|
744
845
|
// expires_at refresh window for a held lease (>> the turn 10s heartbeat so a
|
|
745
846
|
// single missed heartbeat never TTL-reaps a live turn). The warming TTL is the
|
|
746
847
|
// window a cold->warming spawner has to commit warm before a reaper resets it.
|
|
@@ -853,7 +954,7 @@ function isUsableVoiceInputSecret(value) {
|
|
|
853
954
|
}
|
|
854
955
|
function resolveVoiceInputProviderRegistry(settings) {
|
|
855
956
|
const order = settings.voiceInputProviderOrder.split(",").map((part) => part.trim()).filter(
|
|
856
|
-
(part) => part === "openai" || part === "azure-openai" || part === "codex-subscription"
|
|
957
|
+
(part) => part === "openai" || part === "azure-openai" || part === "codex-subscription" || part === "supergrok-subscription"
|
|
857
958
|
);
|
|
858
959
|
const seen = /* @__PURE__ */ new Set();
|
|
859
960
|
const providers = [];
|
|
@@ -907,13 +1008,22 @@ function resolveVoiceInputProviderRegistry(settings) {
|
|
|
907
1008
|
kind: "codex-subscription",
|
|
908
1009
|
experimental: true
|
|
909
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
|
+
});
|
|
910
1020
|
}
|
|
911
1021
|
}
|
|
912
1022
|
return providers;
|
|
913
1023
|
}
|
|
914
1024
|
function voiceInputDeploymentConfigured(settings) {
|
|
915
1025
|
return resolveVoiceInputProviderRegistry(settings).some(
|
|
916
|
-
(provider) => provider.kind !== "codex-subscription"
|
|
1026
|
+
(provider) => provider.kind !== "codex-subscription" && provider.kind !== "supergrok-subscription"
|
|
917
1027
|
);
|
|
918
1028
|
}
|
|
919
1029
|
var ModelPricingSchema = z.object({
|
|
@@ -969,7 +1079,11 @@ var ModelCapabilitiesV1Schema = z.object({
|
|
|
969
1079
|
hostedTools: z.object({
|
|
970
1080
|
webSearch: CapabilityStateV1Schema,
|
|
971
1081
|
xSearch: CapabilityStateV1Schema,
|
|
972
|
-
codeExecution: CapabilityStateV1Schema
|
|
1082
|
+
codeExecution: CapabilityStateV1Schema,
|
|
1083
|
+
imageGeneration: CapabilityStateV1Schema.default({
|
|
1084
|
+
upstream: "unknown",
|
|
1085
|
+
runnable: false
|
|
1086
|
+
})
|
|
973
1087
|
}),
|
|
974
1088
|
inputModalities: z.array(ModelModalityV1).min(1),
|
|
975
1089
|
/** Exact MIME types accepted as typed `input_file`; `text/*` is allowed. */
|
|
@@ -1046,6 +1160,7 @@ var ModelProviderApi = z.enum(["responses", "chat"]);
|
|
|
1046
1160
|
var RegistryProviderKind = z.enum([
|
|
1047
1161
|
"api-key",
|
|
1048
1162
|
"codex-subscription",
|
|
1163
|
+
"xai-subscription",
|
|
1049
1164
|
"vercel-gateway-managed",
|
|
1050
1165
|
"vercel-gateway-workspace"
|
|
1051
1166
|
]);
|
|
@@ -1126,6 +1241,7 @@ var WORKSPACE_GATEWAY_MODEL_ID_PREFIX = "workspace-gateway/";
|
|
|
1126
1241
|
var VERCEL_AI_GATEWAY_CONNECTION_DOMAIN = "ai-gateway.vercel.sh";
|
|
1127
1242
|
var VERCEL_AI_GATEWAY_CONNECTION_ROLE = "vercel_ai_gateway";
|
|
1128
1243
|
var CODEX_REALTIME_MODEL_ID = "gpt-live-1-boulder-alpha";
|
|
1244
|
+
var SUPERGROK_REALTIME_MODEL_ID = "supergrok/grok-voice-think-fast-2.0";
|
|
1129
1245
|
var OPENGENI_REALTIME_MODEL_ID_PREFIX = "opengeni-gateway/";
|
|
1130
1246
|
var WORKSPACE_REALTIME_MODEL_ID_PREFIX = "workspace-gateway/";
|
|
1131
1247
|
var AI_GATEWAY_REALTIME_MODELS = {
|
|
@@ -1338,6 +1454,9 @@ function getSettings() {
|
|
|
1338
1454
|
turnWorkerMaxConcurrentTurns: optional("OPENGENI_TURN_WORKER_MAX_CONCURRENT_TURNS"),
|
|
1339
1455
|
turnWorkerTargetCpuUsage: optional("OPENGENI_TURN_WORKER_TARGET_CPU_USAGE"),
|
|
1340
1456
|
turnWorkerTargetMemoryUsage: optional("OPENGENI_TURN_WORKER_TARGET_MEMORY_USAGE"),
|
|
1457
|
+
turnWorkerEmergencyMemoryUsage: optional("OPENGENI_TURN_WORKER_EMERGENCY_MEMORY_USAGE"),
|
|
1458
|
+
turnWorkerMemoryGuardIntervalMs: optional("OPENGENI_TURN_WORKER_MEMORY_GUARD_INTERVAL_MS"),
|
|
1459
|
+
turnWorkerMemoryGuardSustainMs: optional("OPENGENI_TURN_WORKER_MEMORY_GUARD_SUSTAIN_MS"),
|
|
1341
1460
|
observabilityStructuredLogs: optional("OPENGENI_OBSERVABILITY_STRUCTURED_LOGS"),
|
|
1342
1461
|
observabilityMetricsEnabled: optional("OPENGENI_OBSERVABILITY_METRICS_ENABLED"),
|
|
1343
1462
|
observabilityOtlpEndpoint: optional("OPENGENI_OTEL_EXPORTER_OTLP_ENDPOINT") ?? optional("OTEL_EXPORTER_OTLP_ENDPOINT"),
|
|
@@ -1360,10 +1479,11 @@ function getSettings() {
|
|
|
1360
1479
|
staticEntitlementsJson: optional("OPENGENI_STATIC_ENTITLEMENTS_JSON"),
|
|
1361
1480
|
staticUsageLimitsJson: optional("OPENGENI_STATIC_USAGE_LIMITS_JSON"),
|
|
1362
1481
|
delegationSecret: optional("OPENGENI_DELEGATION_SECRET"),
|
|
1482
|
+
defaultFirstPartyMcpTools: optional("OPENGENI_DEFAULT_FIRST_PARTY_MCP_TOOLS"),
|
|
1483
|
+
allowedFirstPartyMcpTools: optional("OPENGENI_ALLOWED_FIRST_PARTY_MCP_TOOLS"),
|
|
1363
1484
|
streamTokenSecret: optional("OPENGENI_STREAM_TOKEN_SECRET"),
|
|
1364
1485
|
streamControlEnabled: optional("OPENGENI_STREAM_CONTROL_ENABLED"),
|
|
1365
|
-
|
|
1366
|
-
toolspaceMaxCallsPerTurn: optional("OPENGENI_TOOLSPACE_MAX_CALLS_PER_TURN"),
|
|
1486
|
+
codemodeMaxCallsPerTurn: optional("OPENGENI_CODEMODE_MAX_CALLS_PER_TURN"),
|
|
1367
1487
|
ogtoolPackageSpec: optional("OPENGENI_OGTOOL_PACKAGE_SPEC"),
|
|
1368
1488
|
environmentsEncryptionKey: optional("OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY"),
|
|
1369
1489
|
integrationsEnabled: optional("OPENGENI_INTEGRATIONS_ENABLED"),
|
|
@@ -1372,11 +1492,17 @@ function getSettings() {
|
|
|
1372
1492
|
"OPENGENI_INTEGRATIONS_ALLOW_PRIVATE_NETWORK_TARGETS"
|
|
1373
1493
|
),
|
|
1374
1494
|
integrationsOauthClientsJson: optional("OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON"),
|
|
1495
|
+
gmailRestAdapterEnabled: optional("OPENGENI_GMAIL_REST_ADAPTER_ENABLED"),
|
|
1375
1496
|
slackClientId: optional("OPENGENI_SLACK_CLIENT_ID"),
|
|
1376
1497
|
slackClientSecret: optional("OPENGENI_SLACK_CLIENT_SECRET"),
|
|
1377
1498
|
slackSigningSecret: optional("OPENGENI_SLACK_SIGNING_SECRET"),
|
|
1378
1499
|
googleDriveClientId: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_ID"),
|
|
1379
1500
|
googleDriveClientSecret: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_SECRET"),
|
|
1501
|
+
fikenClientId: optional("OPENGENI_FIKEN_OAUTH_CLIENT_ID"),
|
|
1502
|
+
fikenClientSecret: optional("OPENGENI_FIKEN_OAUTH_CLIENT_SECRET"),
|
|
1503
|
+
googleDriveWorkspaceEventsEnabled: optional("OPENGENI_GOOGLE_DRIVE_WORKSPACE_EVENTS_ENABLED"),
|
|
1504
|
+
atlassianClientId: optional("OPENGENI_ATLASSIAN_CLIENT_ID"),
|
|
1505
|
+
atlassianClientSecret: optional("OPENGENI_ATLASSIAN_CLIENT_SECRET"),
|
|
1380
1506
|
maxNestedAgentDepth: optional("OPENGENI_MAX_NESTED_AGENT_DEPTH"),
|
|
1381
1507
|
socialOauthClientsJson: optional("OPENGENI_SOCIAL_OAUTH_CLIENTS_JSON"),
|
|
1382
1508
|
goalMaxAutoContinuations: optional("OPENGENI_GOAL_MAX_AUTO_CONTINUATIONS"),
|
|
@@ -1403,6 +1529,24 @@ function getSettings() {
|
|
|
1403
1529
|
openaiModel: optional("OPENGENI_OPENAI_MODEL"),
|
|
1404
1530
|
openaiAllowedModels: optional("OPENGENI_OPENAI_ALLOWED_MODELS"),
|
|
1405
1531
|
vercelAiGatewayApiKey: optional("OPENGENI_VERCEL_AI_GATEWAY_API_KEY"),
|
|
1532
|
+
imageGenerationModel: optional("OPENGENI_IMAGE_GENERATION_MODEL"),
|
|
1533
|
+
videoGenerationPollIntervalMs: optional("OPENGENI_VIDEO_GENERATION_POLL_INTERVAL_MS"),
|
|
1534
|
+
videoGenerationRecoveryDeadlineMs: optional("OPENGENI_VIDEO_GENERATION_RECOVERY_DEADLINE_MS"),
|
|
1535
|
+
videoGenerationReferenceUrlTtlSeconds: optional(
|
|
1536
|
+
"OPENGENI_VIDEO_GENERATION_REFERENCE_URL_TTL_SECONDS"
|
|
1537
|
+
),
|
|
1538
|
+
videoGenerationMaxConcurrentPerWorkspace: optional(
|
|
1539
|
+
"OPENGENI_VIDEO_GENERATION_MAX_CONCURRENT_PER_WORKSPACE"
|
|
1540
|
+
),
|
|
1541
|
+
videoGenerationWorkspaceQuotaBytes: optional("OPENGENI_VIDEO_GENERATION_WORKSPACE_QUOTA_BYTES"),
|
|
1542
|
+
videoGenerationTempDirectory: optional("OPENGENI_VIDEO_GENERATION_TEMP_DIRECTORY"),
|
|
1543
|
+
videoGenerationFfprobePath: optional("OPENGENI_VIDEO_GENERATION_FFPROBE_PATH"),
|
|
1544
|
+
videoGenerationCredit480pMicrosPerSecond: optional(
|
|
1545
|
+
"OPENGENI_VIDEO_GENERATION_CREDIT_480P_MICROS_PER_SECOND"
|
|
1546
|
+
),
|
|
1547
|
+
videoGenerationCredit720pMicrosPerSecond: optional(
|
|
1548
|
+
"OPENGENI_VIDEO_GENERATION_CREDIT_720P_MICROS_PER_SECOND"
|
|
1549
|
+
),
|
|
1406
1550
|
voiceInputMaxDurationSeconds: optional("OPENGENI_VOICE_INPUT_MAX_DURATION_SECONDS"),
|
|
1407
1551
|
voiceInputMaxSizeBytes: optional("OPENGENI_VOICE_INPUT_MAX_SIZE_BYTES"),
|
|
1408
1552
|
voiceInputResumableEnabled: optional("OPENGENI_VOICE_INPUT_RESUMABLE_ENABLED"),
|
|
@@ -1432,8 +1576,10 @@ function getSettings() {
|
|
|
1432
1576
|
modelPricingJson: optional("OPENGENI_MODEL_PRICING_JSON"),
|
|
1433
1577
|
modelProvidersJson: optional("OPENGENI_MODEL_PROVIDERS_JSON"),
|
|
1434
1578
|
codexSubscriptionEnabled: optional("OPENGENI_CODEX_SUBSCRIPTION_ENABLED"),
|
|
1579
|
+
supergrokSubscriptionEnabled: optional("OPENGENI_SUPERGROK_SUBSCRIPTION_ENABLED"),
|
|
1435
1580
|
codexConnectedAppsEnabled: optional("OPENGENI_CODEX_CONNECTED_APPS_ENABLED"),
|
|
1436
1581
|
codexToolSearchEnabled: optional("OPENGENI_CODEX_TOOL_SEARCH_ENABLED"),
|
|
1582
|
+
lazyToolSearchEnabled: optional("OPENGENI_LAZY_TOOL_SEARCH_ENABLED"),
|
|
1437
1583
|
codexCredentialLeasingEnabled: optional("OPENGENI_CODEX_CREDENTIAL_LEASING_ENABLED"),
|
|
1438
1584
|
codexFleetPolicyShadowEnabled: optional("OPENGENI_CODEX_FLEET_POLICY_SHADOW_ENABLED"),
|
|
1439
1585
|
codexProductSku: optional("OPENGENI_CODEX_PRODUCT_SKU"),
|
|
@@ -1454,6 +1600,7 @@ function getSettings() {
|
|
|
1454
1600
|
disableOpenaiTracing: optional("OPENGENI_DISABLE_OPENAI_TRACING"),
|
|
1455
1601
|
sandboxBackend: optional("OPENGENI_SANDBOX_BACKEND"),
|
|
1456
1602
|
dockerImage: optional("OPENGENI_DOCKER_IMAGE"),
|
|
1603
|
+
sandboxArtifactRuntimeEnabled: optional("OPENGENI_SANDBOX_ARTIFACT_RUNTIME_ENABLED"),
|
|
1457
1604
|
dockerExposedPorts: optional("OPENGENI_DOCKER_EXPOSED_PORTS"),
|
|
1458
1605
|
dockerNetwork: optional("OPENGENI_DOCKER_NETWORK"),
|
|
1459
1606
|
dockerWorkspaceBaseDir: optional("OPENGENI_DOCKER_WORKSPACE_BASE_DIR"),
|
|
@@ -1510,6 +1657,11 @@ function getSettings() {
|
|
|
1510
1657
|
blaxelTtl: optional("OPENGENI_BLAXEL_TTL"),
|
|
1511
1658
|
cloudflareWorkerUrl: optional("OPENGENI_CLOUDFLARE_WORKER_URL"),
|
|
1512
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"),
|
|
1513
1665
|
vercelToken: optional("OPENGENI_VERCEL_TOKEN"),
|
|
1514
1666
|
vercelProjectId: optional("OPENGENI_VERCEL_PROJECT_ID"),
|
|
1515
1667
|
vercelTeamId: optional("OPENGENI_VERCEL_TEAM_ID"),
|
|
@@ -1536,6 +1688,7 @@ function getSettings() {
|
|
|
1536
1688
|
sandboxSelfhostedControlTimeoutMs: optional("OPENGENI_SANDBOX_SELFHOSTED_CONTROL_TIMEOUT_MS"),
|
|
1537
1689
|
sandboxLeaseReaperPeriodMs: optional("OPENGENI_SANDBOX_LEASE_REAPER_PERIOD_MS"),
|
|
1538
1690
|
sandboxViewerHolderTtlMs: optional("OPENGENI_SANDBOX_VIEWER_HOLDER_TTL_MS"),
|
|
1691
|
+
sandboxInteractionHolderTtlMs: optional("OPENGENI_SANDBOX_INTERACTION_HOLDER_TTL_MS"),
|
|
1539
1692
|
sandboxIdleGraceMs: optional("OPENGENI_SANDBOX_IDLE_GRACE_MS"),
|
|
1540
1693
|
sandboxSnapshotIntervalMs: optional("OPENGENI_SANDBOX_SNAPSHOT_INTERVAL_MS"),
|
|
1541
1694
|
sandboxSnapshotTimeoutMs: optional("OPENGENI_SANDBOX_SNAPSHOT_TIMEOUT_MS"),
|
|
@@ -1619,15 +1772,40 @@ var LOCAL_FIRST_PARTY_DELEGATION_SECRET = "opengeni-local-first-party-delegation
|
|
|
1619
1772
|
function resolveFirstPartyDelegationSecret(settings) {
|
|
1620
1773
|
const explicit = settings.delegationSecret?.trim();
|
|
1621
1774
|
if (explicit) return explicit;
|
|
1775
|
+
const configuredAccessKey = settings.accessKey?.trim();
|
|
1776
|
+
if (settings.productAccessMode === "configured" && settings.authRequired && configuredAccessKey) {
|
|
1777
|
+
return configuredAccessKey;
|
|
1778
|
+
}
|
|
1622
1779
|
return settings.productAccessMode === "local" && (settings.environment === "local" || settings.environment === "test") ? LOCAL_FIRST_PARTY_DELEGATION_SECRET : void 0;
|
|
1623
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
|
+
}
|
|
1624
1795
|
function effectiveModalIdleTimeoutSeconds(settings) {
|
|
1625
1796
|
return settings.modalIdleTimeoutSeconds ?? settings.modalTimeoutSeconds;
|
|
1626
1797
|
}
|
|
1627
1798
|
function sandboxArchiveCaptureTimeoutMs(settings) {
|
|
1628
1799
|
return Math.min(
|
|
1629
|
-
|
|
1630
|
-
|
|
1800
|
+
SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS,
|
|
1801
|
+
settings.sandboxSnapshotTimeoutMs + SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS
|
|
1802
|
+
);
|
|
1803
|
+
}
|
|
1804
|
+
function sandboxLifecycleTransitionWaitMs(settings) {
|
|
1805
|
+
const captureTimeoutMs = sandboxArchiveCaptureTimeoutMs(settings);
|
|
1806
|
+
return Math.min(
|
|
1807
|
+
SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS,
|
|
1808
|
+
settings.sandboxLeaseReaperPeriodMs + captureTimeoutMs + SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS
|
|
1631
1809
|
);
|
|
1632
1810
|
}
|
|
1633
1811
|
function collectSandboxEnvironment(settings, source = process.env) {
|
|
@@ -1855,7 +2033,11 @@ function legacyModelCapabilities(settings, input) {
|
|
|
1855
2033
|
runnable: input.hostedWebSearch
|
|
1856
2034
|
},
|
|
1857
2035
|
xSearch: { upstream: "unknown", runnable: false },
|
|
1858
|
-
codeExecution: { upstream: "unknown", runnable: false }
|
|
2036
|
+
codeExecution: { upstream: "unknown", runnable: false },
|
|
2037
|
+
imageGeneration: {
|
|
2038
|
+
upstream: input.hostedImageGeneration ? "supported" : "unknown",
|
|
2039
|
+
runnable: input.hostedImageGeneration ?? false
|
|
2040
|
+
}
|
|
1859
2041
|
},
|
|
1860
2042
|
inputModalities: input.vision ? ["text", "image"] : ["text"],
|
|
1861
2043
|
inputFileMediaTypes: [
|
|
@@ -1985,6 +2167,10 @@ function withWorkspaceGatewayCredential(settings, apiKey) {
|
|
|
1985
2167
|
var GPT56_FAST_BILLING_MULTIPLIER_BPS = 2e4;
|
|
1986
2168
|
function productLabelForModelId(modelId) {
|
|
1987
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
|
+
}
|
|
1988
2174
|
const match = /^(gpt-\d+(?:\.\d+)?)(?:-(.+))?$/i.exec(slug);
|
|
1989
2175
|
if (!match) {
|
|
1990
2176
|
return slug;
|
|
@@ -2000,6 +2186,8 @@ function productLabelForModelId(modelId) {
|
|
|
2000
2186
|
function productShortLabelForModelId(modelId) {
|
|
2001
2187
|
const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
|
|
2002
2188
|
switch (slug) {
|
|
2189
|
+
case "grok-4.6":
|
|
2190
|
+
return "4.6";
|
|
2003
2191
|
case "gpt-5.6-sol":
|
|
2004
2192
|
return "5.6 Sol";
|
|
2005
2193
|
case "gpt-5.6-terra":
|
|
@@ -2028,11 +2216,23 @@ function builtinPromptCachingForModel(modelId) {
|
|
|
2028
2216
|
const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
|
|
2029
2217
|
return slug.startsWith("gpt-5.6-") ? { upstream: "supported", runnable: true, mode: "implicit" } : void 0;
|
|
2030
2218
|
}
|
|
2219
|
+
function builtinHostedImageGenerationForModel(settings, modelId) {
|
|
2220
|
+
return settings.openaiProvider === "openai" && isDirectOpenAiApiBaseUrl(settings.openaiBaseUrl) && ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"].includes(modelId);
|
|
2221
|
+
}
|
|
2222
|
+
function isDirectOpenAiApiBaseUrl(baseUrl) {
|
|
2223
|
+
if (baseUrl === void 0) return true;
|
|
2224
|
+
try {
|
|
2225
|
+
const parsed = new URL(baseUrl);
|
|
2226
|
+
return parsed.protocol === "https:" && parsed.hostname === "api.openai.com" && parsed.port === "" && parsed.username === "" && parsed.password === "" && parsed.search === "" && parsed.hash === "" && parsed.pathname.replace(/\/+$/, "") === "/v1";
|
|
2227
|
+
} catch {
|
|
2228
|
+
return false;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2031
2231
|
function serviceTierForLatencyMode(providerId, latencyMode) {
|
|
2032
2232
|
if (latencyMode === "standard") {
|
|
2033
2233
|
return void 0;
|
|
2034
2234
|
}
|
|
2035
|
-
if (providerId === "azure" || providerId === CODEX_PROVIDER_ID) {
|
|
2235
|
+
if (providerId === "azure" || providerId === CODEX_PROVIDER_ID || providerId === XAI_SUBSCRIPTION_PROVIDER_ID) {
|
|
2036
2236
|
return "priority";
|
|
2037
2237
|
}
|
|
2038
2238
|
return "fast";
|
|
@@ -2065,13 +2265,16 @@ function registryCredentialSource(provider) {
|
|
|
2065
2265
|
if (provider.kind === "codex-subscription") {
|
|
2066
2266
|
return { kind: "connected_subscription", provider: "codex" };
|
|
2067
2267
|
}
|
|
2268
|
+
if (provider.kind === "xai-subscription") {
|
|
2269
|
+
return { kind: "connected_subscription", provider: "xai" };
|
|
2270
|
+
}
|
|
2068
2271
|
if (provider.kind === "vercel-gateway-workspace") {
|
|
2069
2272
|
return { kind: "workspace_connection", mechanism: "api_key" };
|
|
2070
2273
|
}
|
|
2071
2274
|
return { kind: "deployment", mechanism: "api_key" };
|
|
2072
2275
|
}
|
|
2073
2276
|
function registryBilling(provider) {
|
|
2074
|
-
if (provider.kind === "codex-subscription") {
|
|
2277
|
+
if (provider.kind === "codex-subscription" || provider.kind === "xai-subscription") {
|
|
2075
2278
|
return { upstreamPayer: "connected_subscription", metering: "external" };
|
|
2076
2279
|
}
|
|
2077
2280
|
if (provider.kind === "vercel-gateway-workspace") {
|
|
@@ -2230,11 +2433,55 @@ function withCodexCatalogProvider(settings) {
|
|
|
2230
2433
|
modelProvidersJson: JSON.stringify([...providers, provider])
|
|
2231
2434
|
};
|
|
2232
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
|
+
}
|
|
2233
2477
|
function policyProviderIdForModel(settings, modelId) {
|
|
2234
2478
|
const canonicalModelId = canonicalizeConfiguredModelId(settings, modelId);
|
|
2235
2479
|
if (canonicalModelId.startsWith(CODEX_MODEL_ID_PREFIX)) {
|
|
2236
2480
|
return CODEX_PROVIDER_ID;
|
|
2237
2481
|
}
|
|
2482
|
+
if (canonicalModelId.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX)) {
|
|
2483
|
+
return XAI_SUBSCRIPTION_PROVIDER_ID;
|
|
2484
|
+
}
|
|
2238
2485
|
if (canonicalModelId.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX)) {
|
|
2239
2486
|
return WORKSPACE_GATEWAY_PROVIDER_ID;
|
|
2240
2487
|
}
|
|
@@ -2306,7 +2553,7 @@ function configuredModels(settings) {
|
|
|
2306
2553
|
const registryAliases = new Set(
|
|
2307
2554
|
parsedRegistry.flatMap((provider) => provider.models.flatMap((model) => model.aliases ?? []))
|
|
2308
2555
|
);
|
|
2309
|
-
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);
|
|
2310
2557
|
const builtinProvider = providerById.get(builtinId);
|
|
2311
2558
|
if (!builtinProvider) {
|
|
2312
2559
|
throw new Error(`Built-in model provider ${builtinId} is not configured`);
|
|
@@ -2319,6 +2566,7 @@ function configuredModels(settings) {
|
|
|
2319
2566
|
...legacyModelCapabilities(settings, {
|
|
2320
2567
|
reasoningEffort: true,
|
|
2321
2568
|
hostedWebSearch: settings.webSearchEnabled,
|
|
2569
|
+
hostedImageGeneration: builtinHostedImageGenerationForModel(settings, id),
|
|
2322
2570
|
vision: id.startsWith("gpt-5.6-")
|
|
2323
2571
|
}),
|
|
2324
2572
|
...builtinPromptCachingForModel(id) ? { promptCaching: builtinPromptCachingForModel(id) } : {},
|
|
@@ -2415,6 +2663,9 @@ function settingsForTurnExecutionPolicy(settings, modelId) {
|
|
|
2415
2663
|
if (settings.codexSubscriptionEnabled && modelId.startsWith(CODEX_MODEL_ID_PREFIX)) {
|
|
2416
2664
|
return withCodexCatalogProvider(settings);
|
|
2417
2665
|
}
|
|
2666
|
+
if (settings.supergrokSubscriptionEnabled && modelId.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX)) {
|
|
2667
|
+
return withXaiSubscriptionCatalogProvider(settings);
|
|
2668
|
+
}
|
|
2418
2669
|
if (modelId.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX)) {
|
|
2419
2670
|
return withWorkspaceGatewayCatalogProvider(settings);
|
|
2420
2671
|
}
|
|
@@ -2562,6 +2813,9 @@ function configuredEntitlements(settings) {
|
|
|
2562
2813
|
};
|
|
2563
2814
|
}
|
|
2564
2815
|
function calculateModelUsageCostMicros(settings, model, usage, options) {
|
|
2816
|
+
return calculateModelUsageCostBreakdown(settings, model, usage, options).creditCostMicros;
|
|
2817
|
+
}
|
|
2818
|
+
function calculateModelUsageCostBreakdown(settings, model, usage, options) {
|
|
2565
2819
|
const schedule = configuredModelPricingSchedules(settings)[model];
|
|
2566
2820
|
if (!schedule) {
|
|
2567
2821
|
throw new Error(`Missing model pricing for ${model}`);
|
|
@@ -2575,10 +2829,12 @@ function calculateModelUsageCostMicros(settings, model, usage, options) {
|
|
|
2575
2829
|
(rawCostByPricing.get(pricing) ?? 0) + calculateEntryCostMicros(pricing, entry)
|
|
2576
2830
|
);
|
|
2577
2831
|
}
|
|
2578
|
-
let
|
|
2832
|
+
let providerCostMicros = 0;
|
|
2833
|
+
let creditCostMicros = 0;
|
|
2579
2834
|
for (const [pricing, rawCost] of rawCostByPricing) {
|
|
2580
2835
|
const marginBps = pricing.marginBps ?? 0;
|
|
2581
|
-
|
|
2836
|
+
providerCostMicros += rawCost;
|
|
2837
|
+
creditCostMicros += Math.ceil(rawCost * (1e4 + marginBps) / 1e4);
|
|
2582
2838
|
}
|
|
2583
2839
|
const latencyMode = options?.latencyMode ?? "standard";
|
|
2584
2840
|
if (latencyMode !== "standard") {
|
|
@@ -2591,12 +2847,16 @@ function calculateModelUsageCostMicros(settings, model, usage, options) {
|
|
|
2591
2847
|
(mode) => mode.id === latencyMode && mode.runnable
|
|
2592
2848
|
)?.billingMultiplierBps;
|
|
2593
2849
|
if (multiplierBps && multiplierBps > 0) {
|
|
2594
|
-
|
|
2850
|
+
providerCostMicros = Math.ceil(providerCostMicros * multiplierBps / 1e4);
|
|
2851
|
+
creditCostMicros = Math.ceil(creditCostMicros * multiplierBps / 1e4);
|
|
2595
2852
|
}
|
|
2596
2853
|
}
|
|
2597
|
-
return
|
|
2854
|
+
return { providerCostMicros, creditCostMicros };
|
|
2598
2855
|
}
|
|
2599
2856
|
function calculateGatewayReportedCostMicros(settings, model, inferenceCostUsd, options) {
|
|
2857
|
+
return calculateGatewayReportedCostBreakdown(settings, model, inferenceCostUsd, options).creditCostMicros;
|
|
2858
|
+
}
|
|
2859
|
+
function calculateGatewayReportedCostBreakdown(settings, model, inferenceCostUsd, options) {
|
|
2600
2860
|
const schedule = configuredModelPricingSchedules(settings)[model];
|
|
2601
2861
|
if (!schedule) {
|
|
2602
2862
|
throw new Error(`Missing model pricing for ${model}`);
|
|
@@ -2609,14 +2869,33 @@ function calculateGatewayReportedCostMicros(settings, model, inferenceCostUsd, o
|
|
|
2609
2869
|
const fraction = match[2] ?? "";
|
|
2610
2870
|
const decimalDigits = BigInt(`${match[1]}${fraction}`);
|
|
2611
2871
|
const decimalScale = 10n ** BigInt(fraction.length);
|
|
2872
|
+
const providerNumerator = decimalDigits * 1000000n;
|
|
2873
|
+
const providerMicros = (providerNumerator + decimalScale - 1n) / decimalScale;
|
|
2612
2874
|
const marginBps = BigInt(1e4 + (pricing.marginBps ?? 0));
|
|
2613
|
-
const numerator =
|
|
2875
|
+
const numerator = providerNumerator * marginBps;
|
|
2614
2876
|
const denominator = decimalScale * 10000n;
|
|
2615
|
-
const
|
|
2616
|
-
if (
|
|
2877
|
+
const creditMicros = (numerator + denominator - 1n) / denominator;
|
|
2878
|
+
if (providerMicros > BigInt(Number.MAX_SAFE_INTEGER) || creditMicros > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
2617
2879
|
throw new Error("AI Gateway inference cost exceeds the supported billing range");
|
|
2618
2880
|
}
|
|
2619
|
-
return
|
|
2881
|
+
return {
|
|
2882
|
+
providerCostMicros: Number(providerMicros),
|
|
2883
|
+
creditCostMicros: Number(creditMicros)
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2886
|
+
function calculateVideoGenerationCreditCostMicros(settings, input) {
|
|
2887
|
+
if (input.modelId !== SEEDANCE_2_5_MODEL_ID) {
|
|
2888
|
+
throw new Error(`Missing video generation credit pricing for ${input.modelId}`);
|
|
2889
|
+
}
|
|
2890
|
+
if (!Number.isSafeInteger(input.durationSeconds) || input.durationSeconds < 1) {
|
|
2891
|
+
throw new Error("Video generation duration is invalid for credit pricing");
|
|
2892
|
+
}
|
|
2893
|
+
const rate = input.resolution === "480p" ? settings.videoGenerationCredit480pMicrosPerSecond : settings.videoGenerationCredit720pMicrosPerSecond;
|
|
2894
|
+
const cost = rate * input.durationSeconds;
|
|
2895
|
+
if (!Number.isSafeInteger(cost) || cost <= 0 || cost > 1e9) {
|
|
2896
|
+
throw new Error("Video generation credit price exceeds the supported range");
|
|
2897
|
+
}
|
|
2898
|
+
return cost;
|
|
2620
2899
|
}
|
|
2621
2900
|
function configuredAllowedReasoningEfforts(settings) {
|
|
2622
2901
|
return uniqueValues([
|
|
@@ -2734,16 +3013,13 @@ function stableSandboxEnvironmentForRun(settings, workspaceEnvironment = {}, opt
|
|
|
2734
3013
|
environment.OPENGENI_GIT_CLI_WRAPPER_DIR ??= `${home}/.opengeni/bin`;
|
|
2735
3014
|
environment.PATH = prependPathEntry(environment.PATH, environment.OPENGENI_GIT_CLI_WRAPPER_DIR);
|
|
2736
3015
|
}
|
|
2737
|
-
if (settings.
|
|
2738
|
-
environment.
|
|
3016
|
+
if (settings.sandboxBackend !== "selfhosted" && resolveFirstPartyDelegationSecret(settings)) {
|
|
3017
|
+
environment.OPENGENI_CODEMODE_TOKEN_FILE ??= `${environment.HOME ?? descriptor.workspaceRoot}/.opengeni/codemode-token`;
|
|
2739
3018
|
if (settings.ogtoolPackageSpec) {
|
|
2740
3019
|
environment.OPENGENI_OGTOOL_PACKAGE_SPEC ??= settings.ogtoolPackageSpec;
|
|
2741
3020
|
}
|
|
2742
3021
|
if (options.workspaceId) {
|
|
2743
|
-
environment.
|
|
2744
|
-
settings,
|
|
2745
|
-
options.workspaceId
|
|
2746
|
-
);
|
|
3022
|
+
environment.OPENGENI_CODEMODE_URL ??= codemodeWorkspaceUrl(settings, options.workspaceId);
|
|
2747
3023
|
}
|
|
2748
3024
|
}
|
|
2749
3025
|
return environment;
|
|
@@ -3117,7 +3393,10 @@ function ensureBuiltInMcpServers(settings) {
|
|
|
3117
3393
|
"search_documents",
|
|
3118
3394
|
"fetch_document_chunk",
|
|
3119
3395
|
"list_document_bases",
|
|
3396
|
+
"list_indexed_documents",
|
|
3120
3397
|
"knowledge_search",
|
|
3398
|
+
"knowledge_get",
|
|
3399
|
+
"knowledge_browse",
|
|
3121
3400
|
"knowledge_fetch",
|
|
3122
3401
|
"memory_search",
|
|
3123
3402
|
"memory_propose"
|
|
@@ -3142,6 +3421,22 @@ function firstPartyMcpWorkspaceUrl(settings, workspaceId) {
|
|
|
3142
3421
|
url.hash = "";
|
|
3143
3422
|
return url.toString();
|
|
3144
3423
|
}
|
|
3424
|
+
function codemodeWorkspaceUrl(settings, workspaceId) {
|
|
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();
|
|
3432
|
+
}
|
|
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 = "";
|
|
3438
|
+
return url.toString();
|
|
3439
|
+
}
|
|
3145
3440
|
function firstPartyMcpServerUrl(settings) {
|
|
3146
3441
|
return firstPartyMcpBaseUrl(settings);
|
|
3147
3442
|
}
|
|
@@ -3153,8 +3448,16 @@ function firstPartyFilesMcpServerUrl(mcpUrl) {
|
|
|
3153
3448
|
}
|
|
3154
3449
|
function validateSettings(settings) {
|
|
3155
3450
|
temporalConnectionOptions(settings);
|
|
3156
|
-
|
|
3157
|
-
|
|
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
|
+
);
|
|
3158
3461
|
}
|
|
3159
3462
|
if (settings.productAccessMode === "managed") {
|
|
3160
3463
|
if (!settings.publicBaseUrl) {
|
|
@@ -3205,11 +3508,6 @@ function validateSettings(settings) {
|
|
|
3205
3508
|
);
|
|
3206
3509
|
}
|
|
3207
3510
|
if (settings.slackClientId) {
|
|
3208
|
-
if (!settings.slackSigningSecret) {
|
|
3209
|
-
throw new Error(
|
|
3210
|
-
"OPENGENI_SLACK_SIGNING_SECRET is required when the OpenGeni Slack app is configured"
|
|
3211
|
-
);
|
|
3212
|
-
}
|
|
3213
3511
|
if (!settings.publicBaseUrl) {
|
|
3214
3512
|
throw new Error(
|
|
3215
3513
|
"OPENGENI_PUBLIC_BASE_URL is required when the OpenGeni Slack app is configured"
|
|
@@ -3231,6 +3529,28 @@ function validateSettings(settings) {
|
|
|
3231
3529
|
"OPENGENI_GOOGLE_DRIVE_CLIENT_ID and OPENGENI_GOOGLE_DRIVE_CLIENT_SECRET must be configured together"
|
|
3232
3530
|
);
|
|
3233
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
|
+
}
|
|
3234
3554
|
if (settings.googleDriveClientId) {
|
|
3235
3555
|
if (!settings.publicBaseUrl) {
|
|
3236
3556
|
throw new Error(
|
|
@@ -3248,6 +3568,28 @@ function validateSettings(settings) {
|
|
|
3248
3568
|
);
|
|
3249
3569
|
}
|
|
3250
3570
|
}
|
|
3571
|
+
if (Boolean(settings.atlassianClientId) !== Boolean(settings.atlassianClientSecret)) {
|
|
3572
|
+
throw new Error(
|
|
3573
|
+
"OPENGENI_ATLASSIAN_CLIENT_ID and OPENGENI_ATLASSIAN_CLIENT_SECRET must be configured together"
|
|
3574
|
+
);
|
|
3575
|
+
}
|
|
3576
|
+
if (settings.atlassianClientId) {
|
|
3577
|
+
if (!settings.publicBaseUrl) {
|
|
3578
|
+
throw new Error(
|
|
3579
|
+
"OPENGENI_PUBLIC_BASE_URL is required when the Atlassian integration is configured"
|
|
3580
|
+
);
|
|
3581
|
+
}
|
|
3582
|
+
if (!settings.publicBaseUrl.startsWith("https://") && !["local", "test"].includes(settings.environment)) {
|
|
3583
|
+
throw new Error(
|
|
3584
|
+
"OPENGENI_PUBLIC_BASE_URL must use https when the Atlassian integration is configured outside local/test"
|
|
3585
|
+
);
|
|
3586
|
+
}
|
|
3587
|
+
if (!settings.integrationsStateSecret) {
|
|
3588
|
+
throw new Error(
|
|
3589
|
+
"OPENGENI_INTEGRATIONS_STATE_SECRET is required when the Atlassian integration is configured"
|
|
3590
|
+
);
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3251
3593
|
parseIntegrationsOauthClientsJson(settings.integrationsOauthClientsJson);
|
|
3252
3594
|
parseSocialOauthClientsJson(settings.socialOauthClientsJson);
|
|
3253
3595
|
if (settings.productAccessMode === "configured" && !["local", "test"].includes(settings.environment) && !settings.delegationSecret && !settings.authRequired) {
|
|
@@ -3399,6 +3741,7 @@ function validateSettings(settings) {
|
|
|
3399
3741
|
{
|
|
3400
3742
|
const reaperPeriod = settings.sandboxLeaseReaperPeriodMs;
|
|
3401
3743
|
const viewerTtl = settings.sandboxViewerHolderTtlMs;
|
|
3744
|
+
const interactionTtl = settings.sandboxInteractionHolderTtlMs;
|
|
3402
3745
|
const idleGraceMs = settings.sandboxIdleGraceMs;
|
|
3403
3746
|
const providerLifetimeMs = settings.modalTimeoutSeconds * 1e3;
|
|
3404
3747
|
const rotationLeadMs = settings.sandboxRotationLeadMs;
|
|
@@ -3408,6 +3751,11 @@ function validateSettings(settings) {
|
|
|
3408
3751
|
`OPENGENI_SANDBOX_LEASE_REAPER_PERIOD_MS (${reaperPeriod}) must be strictly less than OPENGENI_SANDBOX_VIEWER_HOLDER_TTL_MS (${viewerTtl}): the reaper must run more often than the TTL it polices, or stale viewer holders outlive a full reaper period.`
|
|
3409
3752
|
);
|
|
3410
3753
|
}
|
|
3754
|
+
if (!(reaperPeriod < interactionTtl)) {
|
|
3755
|
+
throw new Error(
|
|
3756
|
+
`OPENGENI_SANDBOX_LEASE_REAPER_PERIOD_MS (${reaperPeriod}) must be strictly less than OPENGENI_SANDBOX_INTERACTION_HOLDER_TTL_MS (${interactionTtl}): the reaper must run more often than the controller-heartbeat horizon.`
|
|
3757
|
+
);
|
|
3758
|
+
}
|
|
3411
3759
|
if (!(idleTimeoutMs <= providerLifetimeMs)) {
|
|
3412
3760
|
throw new Error(
|
|
3413
3761
|
`OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS*1000 (${idleTimeoutMs}) must not exceed the hard provider lifetime (OPENGENI_MODAL_TIMEOUT_SECONDS*1000 = ${providerLifetimeMs}): the idle timeout is a floor under the hard lifetime, not above it.`
|
|
@@ -3418,9 +3766,10 @@ function validateSettings(settings) {
|
|
|
3418
3766
|
`OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}) must be strictly less than OPENGENI_MODAL_TIMEOUT_SECONDS*1000 (${providerLifetimeMs}).`
|
|
3419
3767
|
);
|
|
3420
3768
|
}
|
|
3421
|
-
|
|
3769
|
+
const captureTimeoutMs = sandboxArchiveCaptureTimeoutMs(settings);
|
|
3770
|
+
if (!(rotationLeadMs > captureTimeoutMs + reaperPeriod)) {
|
|
3422
3771
|
throw new Error(
|
|
3423
|
-
`OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}) must exceed the
|
|
3772
|
+
`OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}) must exceed the durable capture timeout plus one reaper period (${captureTimeoutMs + reaperPeriod}).`
|
|
3424
3773
|
);
|
|
3425
3774
|
}
|
|
3426
3775
|
if (!(viewerTtl < idleTimeoutMs)) {
|
|
@@ -3428,6 +3777,11 @@ function validateSettings(settings) {
|
|
|
3428
3777
|
`OPENGENI_SANDBOX_VIEWER_HOLDER_TTL_MS (${viewerTtl}) must be strictly less than the effective box idle timeout (${idleTimeoutMs}): a viewer holder must be reapable before the box idles out from under it (the provider idle-timeout is the backstop).`
|
|
3429
3778
|
);
|
|
3430
3779
|
}
|
|
3780
|
+
if (!(interactionTtl < idleTimeoutMs)) {
|
|
3781
|
+
throw new Error(
|
|
3782
|
+
`OPENGENI_SANDBOX_INTERACTION_HOLDER_TTL_MS (${interactionTtl}) must be strictly less than the effective box idle timeout (${idleTimeoutMs}): a dead browser controller must be reapable before the provider reclaims its placement.`
|
|
3783
|
+
);
|
|
3784
|
+
}
|
|
3431
3785
|
if (!(reaperPeriod + idleGraceMs < idleTimeoutMs)) {
|
|
3432
3786
|
throw new Error(
|
|
3433
3787
|
`OPENGENI_SANDBOX_LEASE_REAPER_PERIOD_MS + OPENGENI_SANDBOX_IDLE_GRACE_MS (${reaperPeriod} + ${idleGraceMs} = ${reaperPeriod + idleGraceMs}) must be strictly less than the effective box idle timeout (${idleTimeoutMs}): a drained box must SURVIVE its full warm window so the reaper can resume + snapshot /workspace + terminate it on the sweep AFTER the drain grace elapses \u2014 Modal's idle-reap must NOT fire first (or /workspace is lost). Raise OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS (defaults to OPENGENI_MODAL_TIMEOUT_SECONDS) or lower OPENGENI_SANDBOX_IDLE_GRACE_MS.`
|
|
@@ -3443,9 +3797,9 @@ function validateSettings(settings) {
|
|
|
3443
3797
|
const builtinId = builtinProviderId(settings);
|
|
3444
3798
|
const providerIds = /* @__PURE__ */ new Set();
|
|
3445
3799
|
for (const provider of registryProviders) {
|
|
3446
|
-
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") {
|
|
3447
3801
|
throw new Error(
|
|
3448
|
-
`OPENGENI_MODEL_PROVIDERS_JSON provider kind ${provider.kind} is reserved for
|
|
3802
|
+
`OPENGENI_MODEL_PROVIDERS_JSON provider kind ${provider.kind} is reserved for a reviewed OpenGeni credential broker`
|
|
3449
3803
|
);
|
|
3450
3804
|
}
|
|
3451
3805
|
if (provider.id === builtinId) {
|
|
@@ -3564,7 +3918,13 @@ export {
|
|
|
3564
3918
|
OPENGENI_GATEWAY_PROVIDER_ID,
|
|
3565
3919
|
OPENGENI_REALTIME_MODEL_ID_PREFIX,
|
|
3566
3920
|
RegistryProviderKind,
|
|
3921
|
+
SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS,
|
|
3922
|
+
SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS,
|
|
3923
|
+
SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS,
|
|
3924
|
+
SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS,
|
|
3567
3925
|
SANDBOX_REQUIRED_ENV,
|
|
3926
|
+
SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS,
|
|
3927
|
+
SUPERGROK_REALTIME_MODEL_ID,
|
|
3568
3928
|
SocialOAuthClientConfigSchema,
|
|
3569
3929
|
VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
|
|
3570
3930
|
VERCEL_AI_GATEWAY_BASE_URL,
|
|
@@ -3573,12 +3933,18 @@ export {
|
|
|
3573
3933
|
WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
|
|
3574
3934
|
WORKSPACE_GATEWAY_PROVIDER_ID,
|
|
3575
3935
|
WORKSPACE_REALTIME_MODEL_ID_PREFIX,
|
|
3936
|
+
XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 as XAI_SUBSCRIPTION_MODEL_ID_PREFIX,
|
|
3937
|
+
allowedFirstPartyMcpToolsForSession,
|
|
3576
3938
|
applyGitAuthPointerEnvironment,
|
|
3577
3939
|
assertTurnExecutionPolicyMatchesConfigV1,
|
|
3578
3940
|
builtinProviderId,
|
|
3941
|
+
calculateGatewayReportedCostBreakdown,
|
|
3579
3942
|
calculateGatewayReportedCostMicros,
|
|
3943
|
+
calculateModelUsageCostBreakdown,
|
|
3580
3944
|
calculateModelUsageCostMicros,
|
|
3945
|
+
calculateVideoGenerationCreditCostMicros,
|
|
3581
3946
|
canonicalizeConfiguredModelId,
|
|
3947
|
+
codemodeWorkspaceUrl,
|
|
3582
3948
|
collectGitIdentityEnvironment,
|
|
3583
3949
|
collectSandboxEnvironment,
|
|
3584
3950
|
configuredAllowedModels,
|
|
@@ -3600,6 +3966,7 @@ export {
|
|
|
3600
3966
|
getSettings,
|
|
3601
3967
|
hasGitCredentialRepositorySelection,
|
|
3602
3968
|
hasGitHubRepositorySelection,
|
|
3969
|
+
isDirectOpenAiApiBaseUrl,
|
|
3603
3970
|
isUsableVoiceInputSecret,
|
|
3604
3971
|
parseExposedPorts,
|
|
3605
3972
|
parseIntegrationsOauthClientsJson,
|
|
@@ -3617,6 +3984,7 @@ export {
|
|
|
3617
3984
|
resolveAiGatewayRealtimeModel,
|
|
3618
3985
|
resolveEnrollmentSigningSecret,
|
|
3619
3986
|
resolveFirstPartyDelegationSecret,
|
|
3987
|
+
resolveFirstPartyMcpToolPolicy,
|
|
3620
3988
|
resolveModelProvider,
|
|
3621
3989
|
resolveNatsCalloutConfig,
|
|
3622
3990
|
resolveNatsControlPlaneAuth,
|
|
@@ -3631,6 +3999,7 @@ export {
|
|
|
3631
3999
|
sandboxArchiveCaptureTimeoutMs,
|
|
3632
4000
|
sandboxEnvironmentVariableNames,
|
|
3633
4001
|
sandboxLifecycleHookIds,
|
|
4002
|
+
sandboxLifecycleTransitionWaitMs,
|
|
3634
4003
|
sandboxPreparationProfiles,
|
|
3635
4004
|
sandboxWarmRateMicrosPerSecond,
|
|
3636
4005
|
selectModelPricing,
|
|
@@ -3643,6 +4012,7 @@ export {
|
|
|
3643
4012
|
voiceInputDeploymentConfigured,
|
|
3644
4013
|
withCodexCatalogProvider,
|
|
3645
4014
|
withWorkspaceGatewayCatalogProvider,
|
|
3646
|
-
withWorkspaceGatewayCredential
|
|
4015
|
+
withWorkspaceGatewayCredential,
|
|
4016
|
+
withXaiSubscriptionCatalogProvider
|
|
3647
4017
|
};
|
|
3648
4018
|
//# sourceMappingURL=index.js.map
|