@opengeni/config 2.1.0 → 2.1.1-canary.36199476632001
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 +99 -1
- package/dist/index.js +231 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +366 -12
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
BillingMode,
|
|
4
4
|
CAPABILITY_DESCRIPTORS,
|
|
5
5
|
DEFAULT_FIRST_PARTY_MCP_TOOLS,
|
|
6
|
+
DEFAULT_OPENGENI_DOCUMENTATION_URL,
|
|
6
7
|
currentAgentLearningToolSelection,
|
|
7
8
|
Entitlements,
|
|
8
9
|
EntitlementsMode,
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
} from "@opengeni/xai-subscription";
|
|
45
46
|
import { XAI_SUBSCRIPTION_MODEL_ID_PREFIX as XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 } from "@opengeni/xai-subscription";
|
|
46
47
|
import { createHash } from "crypto";
|
|
48
|
+
import { isIP } from "net";
|
|
47
49
|
import { z } from "zod";
|
|
48
50
|
var envName = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
49
51
|
var registryId = /^[A-Za-z0-9_-]+$/;
|
|
@@ -53,6 +55,7 @@ var DEFAULT_MODEL_COST_POLICY_JSON = JSON.stringify({
|
|
|
53
55
|
});
|
|
54
56
|
var SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS = 60 * 6e4;
|
|
55
57
|
var SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS = 1e4;
|
|
58
|
+
var SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS = 12e4;
|
|
56
59
|
var SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS = SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS - SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS;
|
|
57
60
|
var GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS = 6e4;
|
|
58
61
|
var GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS = 6e4;
|
|
@@ -230,12 +233,26 @@ var SettingsSchema = z.object({
|
|
|
230
233
|
analyticsPosthogHost: z.string().url().max(2048).optional(),
|
|
231
234
|
analyticsGa4MeasurementId: z.string().max(32).regex(/^G-[A-Z0-9]+$/u).optional(),
|
|
232
235
|
publicBaseUrl: z.string().url().optional(),
|
|
236
|
+
// Product documentation the web console links from its Help menu. Absent
|
|
237
|
+
// means the public OpenGeni docs; `none` hides the link for deployments that
|
|
238
|
+
// publish no documentation of their own.
|
|
239
|
+
documentationUrl: z.preprocess(
|
|
240
|
+
(value) => typeof value === "string" ? value.trim().toLowerCase() === "none" ? null : value.trim() : value,
|
|
241
|
+
z.url({ protocol: /^https?$/u, error: "must be an absolute http(s) URL or none" }).nullable().default(DEFAULT_OPENGENI_DOCUMENTATION_URL)
|
|
242
|
+
),
|
|
233
243
|
// Standards-based OAuth authorization server for external workspace MCP
|
|
234
244
|
// clients. Opt-in because it creates a new public authentication surface.
|
|
235
245
|
mcpOauthEnabled: EnvBoolean.default(false),
|
|
236
|
-
//
|
|
246
|
+
// Client source address for every API rate limit, abuse quota, and auth
|
|
247
|
+
// session record (Better Auth, MCP OAuth registration, enrollment, account
|
|
248
|
+
// setup, login transactions). Forwarded client addresses are ignored by
|
|
249
|
+
// default so a caller cannot choose its own bucket. Operators may trust an
|
|
237
250
|
// exact number of proxy hops only when direct access to the API is blocked.
|
|
238
|
-
|
|
251
|
+
apiTrustedProxyHops: z.coerce.number().int().min(0).max(16).default(0),
|
|
252
|
+
// Optional comma-separated CIDRs (or single addresses) of the proxy that
|
|
253
|
+
// connects to the API. When set, forwarded client addresses are honored
|
|
254
|
+
// only for requests whose transport peer is inside one of them.
|
|
255
|
+
apiTrustedProxyCidrs: z.string().default(""),
|
|
239
256
|
// Browser origin when the web app and API use separate origins in local
|
|
240
257
|
// development. Production normally leaves this unset and uses publicBaseUrl.
|
|
241
258
|
webBaseUrl: z.string().url().optional(),
|
|
@@ -272,6 +289,9 @@ var SettingsSchema = z.object({
|
|
|
272
289
|
// variable out to disable it).
|
|
273
290
|
organizationTenancyCanonicalActivationEnabled: EnvBoolean.default(false),
|
|
274
291
|
billingMode: BillingMode.default("disabled"),
|
|
292
|
+
// Explicit launch gate for the one-time $10 verified self-service signup grant.
|
|
293
|
+
// A migration or deployment alone must not start issuing live credits.
|
|
294
|
+
verifiedSignupTrialCreditsEnabled: EnvBoolean.default(false),
|
|
275
295
|
entitlementsMode: EntitlementsMode.default("none"),
|
|
276
296
|
usageLimitsMode: UsageLimitsMode.default("none"),
|
|
277
297
|
staticEntitlementsJson: z.string().default("{}"),
|
|
@@ -424,6 +444,9 @@ var SettingsSchema = z.object({
|
|
|
424
444
|
authAllowMetrics: EnvBoolean.default(false),
|
|
425
445
|
apiHost: z.string().default("0.0.0.0"),
|
|
426
446
|
apiPort: z.coerce.number().int().positive().default(8e3),
|
|
447
|
+
// When set, GET /metrics is served only on this dedicated internal listener
|
|
448
|
+
// and never on the public API port that an ingress forwards to.
|
|
449
|
+
apiMetricsPort: z.coerce.number().int().positive().optional(),
|
|
427
450
|
workerHttpPort: z.coerce.number().int().positive().default(8001),
|
|
428
451
|
// Worker-side first-party MCP traffic stays on the deployment's internal
|
|
429
452
|
// network. OPENGENI_MCP_URL remains the sandbox/external route used by
|
|
@@ -434,6 +457,11 @@ var SettingsSchema = z.object({
|
|
|
434
457
|
// call the public API with bearer credentials, but never receive credentialed
|
|
435
458
|
// CORS responses.
|
|
436
459
|
corsAllowOriginRegex: z.string().default(String.raw`^https?://(localhost|127\.0\.0\.1)(:\d+)?$`),
|
|
460
|
+
// Local development only (`local` access mode in the `local` environment):
|
|
461
|
+
// extra exact browser origins, comma-separated, that may call the
|
|
462
|
+
// unauthenticated API besides this stack's own web origin. The local browser
|
|
463
|
+
// boundary ignores `corsAllowOriginRegex`.
|
|
464
|
+
localAllowedOrigins: z.string().optional(),
|
|
437
465
|
openaiProvider: z.enum(["openai", "azure"]).default("openai"),
|
|
438
466
|
openaiApiKey: z.string().optional(),
|
|
439
467
|
openaiBaseUrl: z.string().optional(),
|
|
@@ -568,6 +596,18 @@ var SettingsSchema = z.object({
|
|
|
568
596
|
reasoningConfigurationUpdatesEnabled: EnvBoolean.default(false),
|
|
569
597
|
openaiReasoningEffort: ReasoningEffort.default("low"),
|
|
570
598
|
openaiAllowedReasoningEfforts: z.string().default("low,medium,high,xhigh,max"),
|
|
599
|
+
// Default for new chats and scheduled tasks when the workspace has an
|
|
600
|
+
// OpenGeni credit balance, no saved workspace default, and no usable
|
|
601
|
+
// connected subscription, and the deployment default is not already a
|
|
602
|
+
// credits-billed model. Selected only when this model is selectable in the
|
|
603
|
+
// workspace catalog; otherwise the first selectable credits model is used.
|
|
604
|
+
// OPENGENI_CREDITS_DEFAULT_MODEL / OPENGENI_CREDITS_DEFAULT_REASONING_EFFORT.
|
|
605
|
+
creditsDefaultModel: z.string().trim().min(1).max(256).refine((value) => !/[\u000A\u000D|]/u.test(value), {
|
|
606
|
+
message: "credits default model must not contain newlines or the | field separator"
|
|
607
|
+
}).default("gpt-6-luna"),
|
|
608
|
+
// Preferred effort for the credits default. Clamped to the highest effort
|
|
609
|
+
// the selected model supports at or below this value.
|
|
610
|
+
creditsDefaultReasoningEffort: ReasoningEffort.default("xhigh"),
|
|
571
611
|
openaiResponsesTransport: z.enum(["http", "websocket"]).default("http"),
|
|
572
612
|
// Provider-assigned item ids (rs_/msg_/fc_…) in Responses API input are
|
|
573
613
|
// resolved against the provider's server-side response store. That store is
|
|
@@ -593,6 +633,19 @@ var SettingsSchema = z.object({
|
|
|
593
633
|
// merged with the MCP-server tools (getAllTools = [...mcpTools, ...tools])
|
|
594
634
|
// and the sandbox capability tools, never replacing them.
|
|
595
635
|
webSearchEnabled: EnvBoolean.default(true),
|
|
636
|
+
// Jev (TypeSafe's fast judge model) for worker-side agent tools. Without a
|
|
637
|
+
// usable key every Jev-backed feature is off. The key stays on the server
|
|
638
|
+
// (API and worker) and never reaches a sandbox or Connected Machine.
|
|
639
|
+
jevApiKey: z.string().optional(),
|
|
640
|
+
jevBaseUrl: z.string().url().default("https://api.typesafe.ai"),
|
|
641
|
+
jevModel: z.string().trim().min(1).max(128).default("jev-latest"),
|
|
642
|
+
jevRequestTimeoutMs: z.coerce.number().int().positive().max(12e4).default(1e4),
|
|
643
|
+
// Jev-backed `code_search` agent tool. `off` never offers it, `opt_in` offers
|
|
644
|
+
// it only where workspace settings enable it, `default_on` offers it
|
|
645
|
+
// everywhere except workspaces that disable it, and `experiment` gives it to
|
|
646
|
+
// a fixed half of sessions in workspaces without their own setting, for
|
|
647
|
+
// comparison. It also needs jevApiKey.
|
|
648
|
+
codeSearchMode: z.enum(["off", "opt_in", "default_on", "experiment"]).default("off"),
|
|
596
649
|
// Deployment-default agent persona template (the white-label surface). The
|
|
597
650
|
// runtime resolves the effective template per turn as
|
|
598
651
|
// per-session-override > per-workspace override > this default, substitutes
|
|
@@ -1012,6 +1065,7 @@ var SettingsSchema = z.object({
|
|
|
1012
1065
|
// Shape: { "modal": 5, "runloop": 4, ... }. Backends absent here meter
|
|
1013
1066
|
// warm-seconds but accrue NO warm_cost / debit (rate 0).
|
|
1014
1067
|
sandboxWarmRateMicrosPerSecondJson: z.string().default("{}"),
|
|
1068
|
+
sandboxWarmBillingMode: z.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
|
|
1015
1069
|
// Per-workspace warm cap (cumulative warm-seconds since the start of the UTC
|
|
1016
1070
|
// month, summed over sandbox.warm_seconds). 0 = unbounded. A workspace over the
|
|
1017
1071
|
// cap force-drains its VIEWER-ONLY boxes (guarded AND turn_holders=0 — a paying
|
|
@@ -1045,6 +1099,13 @@ var SettingsSchema = z.object({
|
|
|
1045
1099
|
documentEmbeddingDimensions: z.coerce.number().int().positive().default(3072),
|
|
1046
1100
|
documentEmbeddingApiKey: z.string().optional(),
|
|
1047
1101
|
documentEmbeddingBaseUrl: z.string().url().optional(),
|
|
1102
|
+
documentEmbeddingBillingMode: z.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
|
|
1103
|
+
// Explicit commercial cutover. Existing queued revisions remain unpriced;
|
|
1104
|
+
// only jobs created at or after this instant may enter the paid rail.
|
|
1105
|
+
documentEmbeddingCreditsActivatedAt: z.iso.datetime().optional(),
|
|
1106
|
+
// Customer tariff for the exact UTF-8 bytes sent to the embedder. Zero leaves
|
|
1107
|
+
// the paid mode unavailable; no commercial rate is selected by this PR.
|
|
1108
|
+
documentEmbeddingRateMicrosPerMillionBytes: z.coerce.number().int().nonnegative().default(0),
|
|
1048
1109
|
documentCurationProvider: z.enum(["openai", "heuristic", "none"]).default("openai"),
|
|
1049
1110
|
documentCurationModel: z.string().min(1).default("gpt-4o-mini"),
|
|
1050
1111
|
documentCurationApiKey: z.string().optional(),
|
|
@@ -1260,6 +1321,15 @@ function personalGitHubOAuthCallbackUrl(publicBaseUrl) {
|
|
|
1260
1321
|
function usableDeploymentSecret(value) {
|
|
1261
1322
|
return isUsableVoiceInputSecret(value) ? value : void 0;
|
|
1262
1323
|
}
|
|
1324
|
+
function usableJevApiKey(settings) {
|
|
1325
|
+
return usableDeploymentSecret(settings.jevApiKey);
|
|
1326
|
+
}
|
|
1327
|
+
function codeSearchDeploymentPolicy(settings) {
|
|
1328
|
+
const available = settings.codeSearchMode !== "off" && usableJevApiKey(settings) !== void 0;
|
|
1329
|
+
if (!available) return { available: false, workspaceDefault: "off" };
|
|
1330
|
+
const workspaceDefault = settings.codeSearchMode === "default_on" ? "on" : settings.codeSearchMode === "experiment" ? "split" : "off";
|
|
1331
|
+
return { available, workspaceDefault };
|
|
1332
|
+
}
|
|
1263
1333
|
function isUsableVoiceInputSecret(value) {
|
|
1264
1334
|
if (value == null) return false;
|
|
1265
1335
|
const trimmed = value.trim();
|
|
@@ -1927,6 +1997,9 @@ var IntegrationOAuthClientConfigSchema = z.object({
|
|
|
1927
1997
|
clientSecret: z.string().min(1).optional(),
|
|
1928
1998
|
tokenEndpointAuthMethod: z.enum(["none", "client_secret_post", "client_secret_basic"]).default("none")
|
|
1929
1999
|
});
|
|
2000
|
+
function isManagedOpenRouterFreeRoute(route) {
|
|
2001
|
+
return route.provider.kind === "openrouter-managed" && route.configured.upstreamModelId.endsWith(":free");
|
|
2002
|
+
}
|
|
1930
2003
|
var VERCEL_AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh/v1";
|
|
1931
2004
|
var VERCEL_AI_GATEWAY_AI_SDK_BASE_URL = "https://ai-gateway.vercel.sh/v4/ai";
|
|
1932
2005
|
var VERCEL_AI_GATEWAY_CONNECTION_DOMAIN = "ai-gateway.vercel.sh";
|
|
@@ -2365,8 +2438,10 @@ function getSettings(source = process.env) {
|
|
|
2365
2438
|
analyticsPosthogHost: optional("OPENGENI_ANALYTICS_POSTHOG_HOST"),
|
|
2366
2439
|
analyticsGa4MeasurementId: optional("OPENGENI_ANALYTICS_GA4_MEASUREMENT_ID"),
|
|
2367
2440
|
publicBaseUrl: optional("OPENGENI_PUBLIC_BASE_URL"),
|
|
2441
|
+
documentationUrl: optional("OPENGENI_DOCUMENTATION_URL"),
|
|
2368
2442
|
mcpOauthEnabled: optional("OPENGENI_MCP_OAUTH_ENABLED"),
|
|
2369
|
-
|
|
2443
|
+
apiTrustedProxyHops: optional("OPENGENI_API_TRUSTED_PROXY_HOPS"),
|
|
2444
|
+
apiTrustedProxyCidrs: optional("OPENGENI_API_TRUSTED_PROXY_CIDRS"),
|
|
2370
2445
|
webBaseUrl: optional("OPENGENI_WEB_BASE_URL"),
|
|
2371
2446
|
agentReleasesBaseUrl: optional("OPENGENI_AGENT_RELEASES_BASE_URL"),
|
|
2372
2447
|
agentStableVersion: optional("OPENGENI_AGENT_STABLE_VERSION"),
|
|
@@ -2376,6 +2451,7 @@ function getSettings(source = process.env) {
|
|
|
2376
2451
|
"OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED"
|
|
2377
2452
|
),
|
|
2378
2453
|
billingMode: optional("OPENGENI_BILLING_MODE"),
|
|
2454
|
+
verifiedSignupTrialCreditsEnabled: optional("OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED"),
|
|
2379
2455
|
entitlementsMode: optional("OPENGENI_ENTITLEMENTS_MODE"),
|
|
2380
2456
|
usageLimitsMode: optional("OPENGENI_USAGE_LIMITS_MODE"),
|
|
2381
2457
|
staticEntitlementsJson: optional("OPENGENI_STATIC_ENTITLEMENTS_JSON"),
|
|
@@ -2453,10 +2529,12 @@ function getSettings(source = process.env) {
|
|
|
2453
2529
|
authAllowMetrics: optional("OPENGENI_AUTH_ALLOW_METRICS"),
|
|
2454
2530
|
apiHost: optional("OPENGENI_API_HOST"),
|
|
2455
2531
|
apiPort: optional("OPENGENI_API_PORT"),
|
|
2532
|
+
apiMetricsPort: optional("OPENGENI_API_METRICS_PORT"),
|
|
2456
2533
|
workerHttpPort: optional("OPENGENI_WORKER_HTTP_PORT"),
|
|
2457
2534
|
opengeniMcpInternalUrl: optional("OPENGENI_MCP_INTERNAL_URL"),
|
|
2458
2535
|
opengeniMcpUrl: optional("OPENGENI_MCP_URL"),
|
|
2459
2536
|
corsAllowOriginRegex: optional("OPENGENI_CORS_ALLOW_ORIGIN_REGEX"),
|
|
2537
|
+
localAllowedOrigins: optional("OPENGENI_LOCAL_ALLOWED_ORIGINS"),
|
|
2460
2538
|
openaiProvider: optional("OPENGENI_OPENAI_PROVIDER"),
|
|
2461
2539
|
openaiApiKey: optional("OPENGENI_OPENAI_API_KEY") ?? optional("OPENAI_API_KEY"),
|
|
2462
2540
|
openaiBaseUrl: optional("OPENGENI_OPENAI_BASE_URL") ?? optional("OPENAI_BASE_URL"),
|
|
@@ -2528,11 +2606,18 @@ function getSettings(source = process.env) {
|
|
|
2528
2606
|
),
|
|
2529
2607
|
openaiReasoningEffort: optional("OPENGENI_OPENAI_REASONING_EFFORT"),
|
|
2530
2608
|
openaiAllowedReasoningEfforts: optional("OPENGENI_OPENAI_ALLOWED_REASONING_EFFORTS"),
|
|
2609
|
+
creditsDefaultModel: optional("OPENGENI_CREDITS_DEFAULT_MODEL"),
|
|
2610
|
+
creditsDefaultReasoningEffort: optional("OPENGENI_CREDITS_DEFAULT_REASONING_EFFORT"),
|
|
2531
2611
|
openaiResponsesTransport: optional("OPENGENI_OPENAI_RESPONSES_TRANSPORT"),
|
|
2532
2612
|
openaiProviderItemIds: optional("OPENGENI_OPENAI_PROVIDER_ITEM_IDS"),
|
|
2533
2613
|
openaiReasoningEncryptedContent: optional("OPENGENI_OPENAI_REASONING_ENCRYPTED_CONTENT"),
|
|
2534
2614
|
openaiMaxRetries: optional("OPENGENI_OPENAI_MAX_RETRIES"),
|
|
2535
2615
|
webSearchEnabled: optional("OPENGENI_WEB_SEARCH_ENABLED"),
|
|
2616
|
+
jevApiKey: optional("OPENGENI_JEV_API_KEY"),
|
|
2617
|
+
jevBaseUrl: optional("OPENGENI_JEV_BASE_URL"),
|
|
2618
|
+
jevModel: optional("OPENGENI_JEV_MODEL"),
|
|
2619
|
+
jevRequestTimeoutMs: optional("OPENGENI_JEV_REQUEST_TIMEOUT_MS"),
|
|
2620
|
+
codeSearchMode: optional("OPENGENI_CODE_SEARCH_MODE"),
|
|
2536
2621
|
agentInstructionsTemplate: optional("OPENGENI_AGENT_INSTRUCTIONS_TEMPLATE"),
|
|
2537
2622
|
azureOpenaiBaseUrl: optional("OPENGENI_AZURE_OPENAI_BASE_URL"),
|
|
2538
2623
|
azureOpenaiEndpoint: optional("OPENGENI_AZURE_OPENAI_ENDPOINT"),
|
|
@@ -2662,6 +2747,7 @@ function getSettings(source = process.env) {
|
|
|
2662
2747
|
sandboxWarmRateMicrosPerSecondJson: optional(
|
|
2663
2748
|
"OPENGENI_SANDBOX_WARM_RATE_MICROS_PER_SECOND_JSON"
|
|
2664
2749
|
),
|
|
2750
|
+
sandboxWarmBillingMode: optional("OPENGENI_SANDBOX_WARM_BILLING_MODE"),
|
|
2665
2751
|
sandboxMaxWarmSecondsPerWorkspace: optional("OPENGENI_SANDBOX_MAX_WARM_SECONDS_PER_WORKSPACE"),
|
|
2666
2752
|
sandboxPreparationProfiles: optional("OPENGENI_SANDBOX_PREPARATION_PROFILES"),
|
|
2667
2753
|
sandboxEnvAllowlist: optional("OPENGENI_SANDBOX_ENV_ALLOWLIST"),
|
|
@@ -2691,6 +2777,13 @@ function getSettings(source = process.env) {
|
|
|
2691
2777
|
documentEmbeddingDimensions: optional("OPENGENI_DOCUMENT_EMBEDDING_DIMENSIONS"),
|
|
2692
2778
|
documentEmbeddingApiKey: optional("OPENGENI_DOCUMENT_EMBEDDING_API_KEY"),
|
|
2693
2779
|
documentEmbeddingBaseUrl: optional("OPENGENI_DOCUMENT_EMBEDDING_BASE_URL"),
|
|
2780
|
+
documentEmbeddingBillingMode: optional("OPENGENI_DOCUMENT_EMBEDDING_BILLING_MODE"),
|
|
2781
|
+
documentEmbeddingCreditsActivatedAt: optional(
|
|
2782
|
+
"OPENGENI_DOCUMENT_EMBEDDING_CREDITS_ACTIVATED_AT"
|
|
2783
|
+
),
|
|
2784
|
+
documentEmbeddingRateMicrosPerMillionBytes: optional(
|
|
2785
|
+
"OPENGENI_DOCUMENT_EMBEDDING_RATE_MICROS_PER_MILLION_BYTES"
|
|
2786
|
+
),
|
|
2694
2787
|
documentCurationProvider: optional("OPENGENI_DOCUMENT_CURATION_PROVIDER"),
|
|
2695
2788
|
documentCurationModel: optional("OPENGENI_DOCUMENT_CURATION_MODEL"),
|
|
2696
2789
|
documentCurationApiKey: optional("OPENGENI_DOCUMENT_CURATION_API_KEY"),
|
|
@@ -2744,7 +2837,18 @@ function getSettings(source = process.env) {
|
|
|
2744
2837
|
const settings = {
|
|
2745
2838
|
...parsed,
|
|
2746
2839
|
sandboxIdleGraceMs: raw.sandboxIdleGraceMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(9e5, Math.floor(parsed.modalTimeoutSeconds * 1e3 / 2)) : parsed.sandboxIdleGraceMs,
|
|
2747
|
-
sandboxRotationLeadMs: raw.sandboxRotationLeadMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(
|
|
2840
|
+
sandboxRotationLeadMs: raw.sandboxRotationLeadMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(
|
|
2841
|
+
36e5,
|
|
2842
|
+
Math.max(
|
|
2843
|
+
Math.floor(parsed.modalTimeoutSeconds * 1e3 / 2),
|
|
2844
|
+
SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS + sandboxArchiveCaptureTimeoutMs({
|
|
2845
|
+
sandboxSnapshotTimeoutMs: Math.max(
|
|
2846
|
+
parsed.sandboxSnapshotTimeoutMs,
|
|
2847
|
+
parsed.sandboxDrainSnapshotTimeoutMs ?? parsed.sandboxSnapshotTimeoutMs
|
|
2848
|
+
)
|
|
2849
|
+
}) + 2 * parsed.sandboxLeaseReaperPeriodMs + 1
|
|
2850
|
+
)
|
|
2851
|
+
) : parsed.sandboxRotationLeadMs,
|
|
2748
2852
|
mcpServers: ensureBuiltInMcpServers(parsed)
|
|
2749
2853
|
};
|
|
2750
2854
|
validateSettings(settings, source);
|
|
@@ -3611,6 +3715,14 @@ function legacyImplicitOpenAiDefinitionVersionFor(model, provider) {
|
|
|
3611
3715
|
includeWireProfile: false
|
|
3612
3716
|
});
|
|
3613
3717
|
}
|
|
3718
|
+
function legacyCodexAstraImplicitCachingDefinitionVersionFor(model, provider) {
|
|
3719
|
+
if (model.id !== "codex/gpt-6-astra" || model.upstreamModelId !== "gpt-6-astra" || provider.id !== CODEX_PROVIDER_ID || provider.kind !== "codex-subscription" || provider.api !== "responses" || provider.wireProfile !== "openai" || canonicalJson(model.capabilities.promptCaching) !== canonicalJson({ upstream: "supported", runnable: true, mode: "implicit" })) {
|
|
3720
|
+
return null;
|
|
3721
|
+
}
|
|
3722
|
+
const { definitionVersion: _definitionVersion, ...modelWithoutVersion } = model;
|
|
3723
|
+
const { promptCaching: _promptCaching, ...capabilities } = model.capabilities;
|
|
3724
|
+
return definitionVersionFor({ ...modelWithoutVersion, capabilities }, provider);
|
|
3725
|
+
}
|
|
3614
3726
|
function builtinProviderId(settings) {
|
|
3615
3727
|
return settings.openaiProvider === "azure" ? "azure" : "openai";
|
|
3616
3728
|
}
|
|
@@ -4071,6 +4183,13 @@ function resolveTurnExecutionPolicyV1(settings, input) {
|
|
|
4071
4183
|
definitionVersion: resolved.model.definitionVersion
|
|
4072
4184
|
});
|
|
4073
4185
|
}
|
|
4186
|
+
var TurnExecutionPolicyDefinitionMismatchError = class extends Error {
|
|
4187
|
+
code = "turn_execution_policy_definition_mismatch";
|
|
4188
|
+
constructor() {
|
|
4189
|
+
super("Turn execution policy does not match the current provider definition");
|
|
4190
|
+
this.name = "TurnExecutionPolicyDefinitionMismatchError";
|
|
4191
|
+
}
|
|
4192
|
+
};
|
|
4074
4193
|
function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
4075
4194
|
const parsed = TurnExecutionPolicyV1.parse(policy);
|
|
4076
4195
|
const catalogSettings = settingsForTurnExecutionPolicy(settings, parsed.productModelId);
|
|
@@ -4093,11 +4212,14 @@ function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
|
4093
4212
|
resolved.model,
|
|
4094
4213
|
resolved.provider
|
|
4095
4214
|
);
|
|
4096
|
-
const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion;
|
|
4097
|
-
const
|
|
4098
|
-
if (
|
|
4215
|
+
const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion || parsed.definitionVersion === legacyCodexAstraImplicitCachingDefinitionVersionFor(resolved.model, resolved.provider);
|
|
4216
|
+
const identityMismatched = parsed.providerId !== resolved.provider.id || parsed.upstreamModelId !== resolved.model.upstreamModelId || parsed.wireApi !== resolved.model.api || canonicalJson(parsed.credentialSource) !== canonicalJson(resolved.model.credentialSource) || canonicalJson(parsed.billing) !== canonicalJson(resolved.model.billing);
|
|
4217
|
+
if (identityMismatched) {
|
|
4099
4218
|
throw new Error("Turn execution policy does not match the current provider definition");
|
|
4100
4219
|
}
|
|
4220
|
+
if (!definitionVersionMatches) {
|
|
4221
|
+
throw new TurnExecutionPolicyDefinitionMismatchError();
|
|
4222
|
+
}
|
|
4101
4223
|
return { policy: parsed, provider: resolved.provider, model: resolved.model };
|
|
4102
4224
|
}
|
|
4103
4225
|
function configuredModelPricingSchedules(settings) {
|
|
@@ -4850,8 +4972,61 @@ function isDigestPinnedModalDesktopImage(settings) {
|
|
|
4850
4972
|
if (settings.modalImageId) return true;
|
|
4851
4973
|
return typeof settings.modalImageRef === "string" && MODAL_DESKTOP_IMAGE_DIGEST_REF.test(settings.modalImageRef);
|
|
4852
4974
|
}
|
|
4975
|
+
function trustedProxyCidrEntries(raw) {
|
|
4976
|
+
const entries = [];
|
|
4977
|
+
for (const entry of raw.split(",")) {
|
|
4978
|
+
const value = entry.trim();
|
|
4979
|
+
if (!value) continue;
|
|
4980
|
+
const slash = value.indexOf("/");
|
|
4981
|
+
const address = slash < 0 ? value : value.slice(0, slash);
|
|
4982
|
+
const version = isIP(address);
|
|
4983
|
+
const family = version === 4 ? "ipv4" : version === 6 ? "ipv6" : null;
|
|
4984
|
+
const maxPrefix = family === "ipv4" ? 32 : 128;
|
|
4985
|
+
const prefixText = slash < 0 ? String(maxPrefix) : value.slice(slash + 1);
|
|
4986
|
+
const prefix = /^\d{1,3}$/u.test(prefixText) ? Number(prefixText) : Number.NaN;
|
|
4987
|
+
if (!family || !Number.isInteger(prefix) || prefix < 0 || prefix > maxPrefix) {
|
|
4988
|
+
throw new Error(
|
|
4989
|
+
`OPENGENI_API_TRUSTED_PROXY_CIDRS entry "${value.slice(0, 64)}" is not an IP address or CIDR range`
|
|
4990
|
+
);
|
|
4991
|
+
}
|
|
4992
|
+
entries.push({ address, prefix, family });
|
|
4993
|
+
}
|
|
4994
|
+
return entries;
|
|
4995
|
+
}
|
|
4996
|
+
function localAllowedOriginEntries(raw) {
|
|
4997
|
+
const origins = [];
|
|
4998
|
+
for (const entry of (raw ?? "").split(",")) {
|
|
4999
|
+
const value = entry.trim();
|
|
5000
|
+
if (!value) continue;
|
|
5001
|
+
let url = null;
|
|
5002
|
+
try {
|
|
5003
|
+
url = new URL(value);
|
|
5004
|
+
} catch {
|
|
5005
|
+
url = null;
|
|
5006
|
+
}
|
|
5007
|
+
if (!url || url.protocol !== "http:" && url.protocol !== "https:" || url.username || url.password || url.hostname.includes("*") || url.pathname !== "/" || url.search || url.hash || value.endsWith("?") || value.endsWith("#")) {
|
|
5008
|
+
throw new Error(
|
|
5009
|
+
`OPENGENI_LOCAL_ALLOWED_ORIGINS entry "${value.slice(0, 64)}" is not an exact http(s) origin such as http://127.0.0.1:5173`
|
|
5010
|
+
);
|
|
5011
|
+
}
|
|
5012
|
+
origins.push(url.origin);
|
|
5013
|
+
}
|
|
5014
|
+
return origins;
|
|
5015
|
+
}
|
|
5016
|
+
var LOCAL_SANDBOX_API_ROUTES = [
|
|
5017
|
+
// Codemode calls, journal reads, catalog, and the Site/SDK proxy.
|
|
5018
|
+
/^\/v1\/workspaces\/[^/]+\/codemode(?:\/|$)/u,
|
|
5019
|
+
// First-party MCP, including its /docs and /files servers.
|
|
5020
|
+
/^\/v1\/workspaces\/[^/]+\/mcp(?:\/|$)/u,
|
|
5021
|
+
// The personal GitHub HTTPS smart-Git broker.
|
|
5022
|
+
/^\/v1\/git\/personal\/[A-Za-z0-9_-]{43}\/(?:info\/refs|git-upload-pack|git-receive-pack)$/u
|
|
5023
|
+
];
|
|
5024
|
+
function localSandboxApiRouteAllowed(pathname) {
|
|
5025
|
+
return LOCAL_SANDBOX_API_ROUTES.some((route) => route.test(pathname));
|
|
5026
|
+
}
|
|
4853
5027
|
function validateSettings(settings, source = process.env) {
|
|
4854
5028
|
temporalConnectionOptions(settings);
|
|
5029
|
+
localAllowedOriginEntries(settings.localAllowedOrigins);
|
|
4855
5030
|
if (settings.organizationUserSetupEmailTokenTransport === "query" && !settings.organizationUserSetupQueryEdgeSanitizationConfirmed) {
|
|
4856
5031
|
throw new Error(
|
|
4857
5032
|
"OPENGENI_ORGANIZATION_USER_SETUP_QUERY_EDGE_SANITIZATION_CONFIRMED=true is required when OPENGENI_ORGANIZATION_USER_SETUP_EMAIL_TOKEN_TRANSPORT=query"
|
|
@@ -4934,6 +5109,18 @@ function validateSettings(settings, source = process.env) {
|
|
|
4934
5109
|
);
|
|
4935
5110
|
}
|
|
4936
5111
|
}
|
|
5112
|
+
const retiredTrustedProxyHops = source.OPENGENI_MCP_OAUTH_TRUSTED_PROXY_HOPS?.trim();
|
|
5113
|
+
if (retiredTrustedProxyHops && retiredTrustedProxyHops !== "0") {
|
|
5114
|
+
throw new Error(
|
|
5115
|
+
"OPENGENI_MCP_OAUTH_TRUSTED_PROXY_HOPS was renamed to OPENGENI_API_TRUSTED_PROXY_HOPS, which now sets the client address for every API rate limit and auth session; rename the variable"
|
|
5116
|
+
);
|
|
5117
|
+
}
|
|
5118
|
+
const trustedProxyCidrs = trustedProxyCidrEntries(settings.apiTrustedProxyCidrs);
|
|
5119
|
+
if (trustedProxyCidrs.length > 0 && settings.apiTrustedProxyHops === 0) {
|
|
5120
|
+
throw new Error(
|
|
5121
|
+
"OPENGENI_API_TRUSTED_PROXY_CIDRS requires OPENGENI_API_TRUSTED_PROXY_HOPS greater than 0"
|
|
5122
|
+
);
|
|
5123
|
+
}
|
|
4937
5124
|
if (settings.mcpOauthEnabled) {
|
|
4938
5125
|
if (settings.productAccessMode === "configured") {
|
|
4939
5126
|
throw new Error(
|
|
@@ -5203,7 +5390,22 @@ function validateSettings(settings, source = process.env) {
|
|
|
5203
5390
|
parseExposedPorts(settings.dockerExposedPorts);
|
|
5204
5391
|
sandboxEnvironmentVariableNames(settings);
|
|
5205
5392
|
sandboxLifecycleHookIds(settings);
|
|
5206
|
-
parseSandboxWarmRateJson(settings.sandboxWarmRateMicrosPerSecondJson);
|
|
5393
|
+
const warmRates = parseSandboxWarmRateJson(settings.sandboxWarmRateMicrosPerSecondJson);
|
|
5394
|
+
if (settings.sandboxWarmBillingMode === "credits" && Object.values(warmRates).some((rate) => !Number.isSafeInteger(rate))) {
|
|
5395
|
+
throw new Error(
|
|
5396
|
+
"OPENGENI_SANDBOX_WARM_RATE_MICROS_PER_SECOND_JSON paid rates must be safe integers"
|
|
5397
|
+
);
|
|
5398
|
+
}
|
|
5399
|
+
if (settings.documentEmbeddingBillingMode === "credits" && settings.documentEmbeddingProvider === "openai" && settings.documentEmbeddingRateMicrosPerMillionBytes <= 0) {
|
|
5400
|
+
throw new Error(
|
|
5401
|
+
"OPENGENI_DOCUMENT_EMBEDDING_RATE_MICROS_PER_MILLION_BYTES must be positive when paid OpenAI embedding billing is enabled"
|
|
5402
|
+
);
|
|
5403
|
+
}
|
|
5404
|
+
if (settings.documentEmbeddingBillingMode === "credits" && settings.documentEmbeddingProvider === "openai" && !settings.documentEmbeddingCreditsActivatedAt) {
|
|
5405
|
+
throw new Error(
|
|
5406
|
+
"OPENGENI_DOCUMENT_EMBEDDING_CREDITS_ACTIVATED_AT is required for paid OpenAI embeddings"
|
|
5407
|
+
);
|
|
5408
|
+
}
|
|
5207
5409
|
if (settings.sandboxBackend === "opensandbox") {
|
|
5208
5410
|
if (!/@sha256:[0-9a-f]{64}$/i.test(settings.openSandboxImage ?? "")) {
|
|
5209
5411
|
throw new Error(
|
|
@@ -5262,9 +5464,10 @@ function validateSettings(settings, source = process.env) {
|
|
|
5262
5464
|
ordinaryCaptureTimeoutMs,
|
|
5263
5465
|
drainCaptureTimeoutMs
|
|
5264
5466
|
);
|
|
5265
|
-
|
|
5467
|
+
const requiredRotationLeadMs = SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS + providerDeadlineCaptureTimeoutMs + 2 * reaperPeriod;
|
|
5468
|
+
if (!(rotationLeadMs > requiredRotationLeadMs)) {
|
|
5266
5469
|
throw new Error(
|
|
5267
|
-
`OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}) must exceed the largest durable snapshot or drain capture timeout
|
|
5470
|
+
`OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}) must exceed the legacy command stop grace, largest durable snapshot or drain capture timeout, and two reaper periods (${requiredRotationLeadMs}), including for persisted Modal leases after a default-backend rollout.`
|
|
5268
5471
|
);
|
|
5269
5472
|
}
|
|
5270
5473
|
if (settings.sandboxBackend === "modal") {
|
|
@@ -5366,6 +5569,16 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
5366
5569
|
`The default model ${settings.openaiModel} is not executable in the resolved model catalog`
|
|
5367
5570
|
);
|
|
5368
5571
|
}
|
|
5572
|
+
const explicitCreditsDefault = source.OPENGENI_CREDITS_DEFAULT_MODEL?.trim();
|
|
5573
|
+
if (explicitCreditsDefault && settings.modelCatalogSource === "code" && settings.billingMode === "stripe") {
|
|
5574
|
+
const creditsDefaultId = canonicalizeConfiguredModelId(settings, settings.creditsDefaultModel);
|
|
5575
|
+
const creditsDefault = models.find((model) => model.id === creditsDefaultId);
|
|
5576
|
+
if (creditsDefault?.cost !== "credits") {
|
|
5577
|
+
throw new Error(
|
|
5578
|
+
`OPENGENI_CREDITS_DEFAULT_MODEL ${settings.creditsDefaultModel} is not a credits-billed model in the resolved model catalog`
|
|
5579
|
+
);
|
|
5580
|
+
}
|
|
5581
|
+
}
|
|
5369
5582
|
const deploymentProductIds = new Set(
|
|
5370
5583
|
models.filter((model) => model.credentialSource.kind === "deployment").map((model) => model.id)
|
|
5371
5584
|
);
|
|
@@ -5588,12 +5801,14 @@ export {
|
|
|
5588
5801
|
RegistryProviderKind,
|
|
5589
5802
|
SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS,
|
|
5590
5803
|
SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS,
|
|
5804
|
+
SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS,
|
|
5591
5805
|
SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS,
|
|
5592
5806
|
SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS,
|
|
5593
5807
|
SANDBOX_REQUIRED_ENV,
|
|
5594
5808
|
SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS,
|
|
5595
5809
|
SUPERGROK_REALTIME_MODEL_ID,
|
|
5596
5810
|
SocialOAuthClientConfigSchema,
|
|
5811
|
+
TurnExecutionPolicyDefinitionMismatchError,
|
|
5597
5812
|
VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
|
|
5598
5813
|
VERCEL_AI_GATEWAY_BASE_URL,
|
|
5599
5814
|
VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
|
|
@@ -5619,6 +5834,7 @@ export {
|
|
|
5619
5834
|
calculateVideoGenerationCreditCostMicros,
|
|
5620
5835
|
canonicalPublicOrigin,
|
|
5621
5836
|
canonicalizeConfiguredModelId,
|
|
5837
|
+
codeSearchDeploymentPolicy,
|
|
5622
5838
|
codemodeWorkspaceUrl,
|
|
5623
5839
|
collectGitIdentityEnvironment,
|
|
5624
5840
|
collectSandboxEnvironment,
|
|
@@ -5659,8 +5875,11 @@ export {
|
|
|
5659
5875
|
hasGitCredentialRepositorySelection,
|
|
5660
5876
|
hasGitHubRepositorySelection,
|
|
5661
5877
|
isDirectOpenAiApiBaseUrl,
|
|
5878
|
+
isManagedOpenRouterFreeRoute,
|
|
5662
5879
|
isModelAvailableForNewSelection,
|
|
5663
5880
|
isUsableVoiceInputSecret,
|
|
5881
|
+
localAllowedOriginEntries,
|
|
5882
|
+
localSandboxApiRouteAllowed,
|
|
5664
5883
|
modelCostClassForConfiguredModel,
|
|
5665
5884
|
parseExposedPorts,
|
|
5666
5885
|
parseIntegrationsOauthClientsJson,
|
|
@@ -5709,6 +5928,8 @@ export {
|
|
|
5709
5928
|
startupRetryOptions,
|
|
5710
5929
|
streamTokenDegraded,
|
|
5711
5930
|
temporalConnectionOptions,
|
|
5931
|
+
trustedProxyCidrEntries,
|
|
5932
|
+
usableJevApiKey,
|
|
5712
5933
|
validateModelCatalogSettings,
|
|
5713
5934
|
voiceInputDeploymentConfigured,
|
|
5714
5935
|
withCodexCatalogProvider,
|