@opengeni/config 2.1.0 → 2.1.1-canary.36079201993001

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 CHANGED
@@ -5,6 +5,7 @@ export declare const DEFAULT_OPENROUTER_MODEL_ID: "openrouter/nvidia/nemotron-3-
5
5
  export declare const DEFAULT_MODEL_COST_POLICY_JSON: string;
6
6
  export declare const SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS: number;
7
7
  export declare const SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS = 10000;
8
+ export declare const SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS = 120000;
8
9
  export declare const SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS: number;
9
10
  export declare const GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS = 60000;
10
11
  export declare const GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS = 60000;
@@ -143,6 +144,7 @@ declare const SettingsSchema: z.ZodObject<{
143
144
  disabled: "disabled";
144
145
  stripe: "stripe";
145
146
  }>>;
147
+ verifiedSignupTrialCreditsEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
146
148
  entitlementsMode: z.ZodDefault<z.ZodEnum<{
147
149
  managed: "managed";
148
150
  none: "none";
@@ -177,6 +179,8 @@ declare const SettingsSchema: z.ZodObject<{
177
179
  browser_observe: "browser_observe";
178
180
  browser_open: "browser_open";
179
181
  browser_publish: "browser_publish";
182
+ browser_read: "browser_read";
183
+ browser_screenshot: "browser_screenshot";
180
184
  browser_tabs: "browser_tabs";
181
185
  capability_authorization_request: "capability_authorization_request";
182
186
  capability_catalog_search: "capability_catalog_search";
@@ -192,6 +196,7 @@ declare const SettingsSchema: z.ZodObject<{
192
196
  computer_targets: "computer_targets";
193
197
  connected_machine_enroll_token: "connected_machine_enroll_token";
194
198
  connected_machine_remove: "connected_machine_remove";
199
+ custom_mcp_setup_request: "custom_mcp_setup_request";
195
200
  editable_artifact_apply: "editable_artifact_apply";
196
201
  editable_artifact_create: "editable_artifact_create";
197
202
  editable_artifact_export: "editable_artifact_export";
@@ -347,6 +352,8 @@ declare const SettingsSchema: z.ZodObject<{
347
352
  browser_observe: "browser_observe";
348
353
  browser_open: "browser_open";
349
354
  browser_publish: "browser_publish";
355
+ browser_read: "browser_read";
356
+ browser_screenshot: "browser_screenshot";
350
357
  browser_tabs: "browser_tabs";
351
358
  capability_authorization_request: "capability_authorization_request";
352
359
  capability_catalog_search: "capability_catalog_search";
@@ -362,6 +369,7 @@ declare const SettingsSchema: z.ZodObject<{
362
369
  computer_targets: "computer_targets";
363
370
  connected_machine_enroll_token: "connected_machine_enroll_token";
364
371
  connected_machine_remove: "connected_machine_remove";
372
+ custom_mcp_setup_request: "custom_mcp_setup_request";
365
373
  editable_artifact_apply: "editable_artifact_apply";
366
374
  editable_artifact_create: "editable_artifact_create";
367
375
  editable_artifact_export: "editable_artifact_export";
@@ -788,6 +796,11 @@ declare const SettingsSchema: z.ZodObject<{
788
796
  workspaceControlLockTimeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
789
797
  rigSetupTimeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
790
798
  sandboxWarmRateMicrosPerSecondJson: z.ZodDefault<z.ZodString>;
799
+ sandboxWarmBillingMode: z.ZodDefault<z.ZodEnum<{
800
+ credits: "credits";
801
+ shadow: "shadow";
802
+ usage_only: "usage_only";
803
+ }>>;
791
804
  sandboxMaxWarmSecondsPerWorkspace: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
792
805
  sandboxPreparationProfiles: z.ZodDefault<z.ZodString>;
793
806
  sandboxEnvAllowlist: z.ZodDefault<z.ZodString>;
@@ -825,6 +838,13 @@ declare const SettingsSchema: z.ZodObject<{
825
838
  documentEmbeddingDimensions: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
826
839
  documentEmbeddingApiKey: z.ZodOptional<z.ZodString>;
827
840
  documentEmbeddingBaseUrl: z.ZodOptional<z.ZodString>;
841
+ documentEmbeddingBillingMode: z.ZodDefault<z.ZodEnum<{
842
+ credits: "credits";
843
+ shadow: "shadow";
844
+ usage_only: "usage_only";
845
+ }>>;
846
+ documentEmbeddingCreditsActivatedAt: z.ZodOptional<z.ZodISODateTime>;
847
+ documentEmbeddingRateMicrosPerMillionBytes: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
828
848
  documentCurationProvider: z.ZodDefault<z.ZodEnum<{
829
849
  heuristic: "heuristic";
830
850
  none: "none";
@@ -2705,6 +2725,11 @@ export declare function resolveModelProviderForTurn(settings: Settings, modelId:
2705
2725
  * neither proves readiness nor chooses, decrypts, leases, or exposes an account.
2706
2726
  */
2707
2727
  export declare function resolveTurnExecutionPolicyV1(settings: Settings, input: ResolveTurnExecutionPolicyV1Input): TurnExecutionPolicyV1;
2728
+ /** Explicit accepted execution identity matches, but its definition digest differs. */
2729
+ export declare class TurnExecutionPolicyDefinitionMismatchError extends Error {
2730
+ readonly code = "turn_execution_policy_definition_mismatch";
2731
+ constructor();
2732
+ }
2708
2733
  /**
2709
2734
  * Parse-time validation lives in @opengeni/contracts; this verifier binds a
2710
2735
  * present snapshot to the current executable definition and exact turn row.
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ var DEFAULT_MODEL_COST_POLICY_JSON = JSON.stringify({
53
53
  });
54
54
  var SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS = 60 * 6e4;
55
55
  var SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS = 1e4;
56
+ var SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS = 12e4;
56
57
  var SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS = SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS - SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS;
57
58
  var GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS = 6e4;
58
59
  var GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS = 6e4;
@@ -272,6 +273,9 @@ var SettingsSchema = z.object({
272
273
  // variable out to disable it).
273
274
  organizationTenancyCanonicalActivationEnabled: EnvBoolean.default(false),
274
275
  billingMode: BillingMode.default("disabled"),
276
+ // Explicit launch gate for the one-time $10 verified self-service signup grant.
277
+ // A migration or deployment alone must not start issuing live credits.
278
+ verifiedSignupTrialCreditsEnabled: EnvBoolean.default(false),
275
279
  entitlementsMode: EntitlementsMode.default("none"),
276
280
  usageLimitsMode: UsageLimitsMode.default("none"),
277
281
  staticEntitlementsJson: z.string().default("{}"),
@@ -1012,6 +1016,7 @@ var SettingsSchema = z.object({
1012
1016
  // Shape: { "modal": 5, "runloop": 4, ... }. Backends absent here meter
1013
1017
  // warm-seconds but accrue NO warm_cost / debit (rate 0).
1014
1018
  sandboxWarmRateMicrosPerSecondJson: z.string().default("{}"),
1019
+ sandboxWarmBillingMode: z.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
1015
1020
  // Per-workspace warm cap (cumulative warm-seconds since the start of the UTC
1016
1021
  // month, summed over sandbox.warm_seconds). 0 = unbounded. A workspace over the
1017
1022
  // cap force-drains its VIEWER-ONLY boxes (guarded AND turn_holders=0 — a paying
@@ -1045,6 +1050,13 @@ var SettingsSchema = z.object({
1045
1050
  documentEmbeddingDimensions: z.coerce.number().int().positive().default(3072),
1046
1051
  documentEmbeddingApiKey: z.string().optional(),
1047
1052
  documentEmbeddingBaseUrl: z.string().url().optional(),
1053
+ documentEmbeddingBillingMode: z.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
1054
+ // Explicit commercial cutover. Existing queued revisions remain unpriced;
1055
+ // only jobs created at or after this instant may enter the paid rail.
1056
+ documentEmbeddingCreditsActivatedAt: z.iso.datetime().optional(),
1057
+ // Customer tariff for the exact UTF-8 bytes sent to the embedder. Zero leaves
1058
+ // the paid mode unavailable; no commercial rate is selected by this PR.
1059
+ documentEmbeddingRateMicrosPerMillionBytes: z.coerce.number().int().nonnegative().default(0),
1048
1060
  documentCurationProvider: z.enum(["openai", "heuristic", "none"]).default("openai"),
1049
1061
  documentCurationModel: z.string().min(1).default("gpt-4o-mini"),
1050
1062
  documentCurationApiKey: z.string().optional(),
@@ -2376,6 +2388,7 @@ function getSettings(source = process.env) {
2376
2388
  "OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED"
2377
2389
  ),
2378
2390
  billingMode: optional("OPENGENI_BILLING_MODE"),
2391
+ verifiedSignupTrialCreditsEnabled: optional("OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED"),
2379
2392
  entitlementsMode: optional("OPENGENI_ENTITLEMENTS_MODE"),
2380
2393
  usageLimitsMode: optional("OPENGENI_USAGE_LIMITS_MODE"),
2381
2394
  staticEntitlementsJson: optional("OPENGENI_STATIC_ENTITLEMENTS_JSON"),
@@ -2662,6 +2675,7 @@ function getSettings(source = process.env) {
2662
2675
  sandboxWarmRateMicrosPerSecondJson: optional(
2663
2676
  "OPENGENI_SANDBOX_WARM_RATE_MICROS_PER_SECOND_JSON"
2664
2677
  ),
2678
+ sandboxWarmBillingMode: optional("OPENGENI_SANDBOX_WARM_BILLING_MODE"),
2665
2679
  sandboxMaxWarmSecondsPerWorkspace: optional("OPENGENI_SANDBOX_MAX_WARM_SECONDS_PER_WORKSPACE"),
2666
2680
  sandboxPreparationProfiles: optional("OPENGENI_SANDBOX_PREPARATION_PROFILES"),
2667
2681
  sandboxEnvAllowlist: optional("OPENGENI_SANDBOX_ENV_ALLOWLIST"),
@@ -2691,6 +2705,13 @@ function getSettings(source = process.env) {
2691
2705
  documentEmbeddingDimensions: optional("OPENGENI_DOCUMENT_EMBEDDING_DIMENSIONS"),
2692
2706
  documentEmbeddingApiKey: optional("OPENGENI_DOCUMENT_EMBEDDING_API_KEY"),
2693
2707
  documentEmbeddingBaseUrl: optional("OPENGENI_DOCUMENT_EMBEDDING_BASE_URL"),
2708
+ documentEmbeddingBillingMode: optional("OPENGENI_DOCUMENT_EMBEDDING_BILLING_MODE"),
2709
+ documentEmbeddingCreditsActivatedAt: optional(
2710
+ "OPENGENI_DOCUMENT_EMBEDDING_CREDITS_ACTIVATED_AT"
2711
+ ),
2712
+ documentEmbeddingRateMicrosPerMillionBytes: optional(
2713
+ "OPENGENI_DOCUMENT_EMBEDDING_RATE_MICROS_PER_MILLION_BYTES"
2714
+ ),
2694
2715
  documentCurationProvider: optional("OPENGENI_DOCUMENT_CURATION_PROVIDER"),
2695
2716
  documentCurationModel: optional("OPENGENI_DOCUMENT_CURATION_MODEL"),
2696
2717
  documentCurationApiKey: optional("OPENGENI_DOCUMENT_CURATION_API_KEY"),
@@ -2744,7 +2765,18 @@ function getSettings(source = process.env) {
2744
2765
  const settings = {
2745
2766
  ...parsed,
2746
2767
  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(36e5, Math.floor(parsed.modalTimeoutSeconds * 1e3 / 2)) : parsed.sandboxRotationLeadMs,
2768
+ sandboxRotationLeadMs: raw.sandboxRotationLeadMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(
2769
+ 36e5,
2770
+ Math.max(
2771
+ Math.floor(parsed.modalTimeoutSeconds * 1e3 / 2),
2772
+ SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS + sandboxArchiveCaptureTimeoutMs({
2773
+ sandboxSnapshotTimeoutMs: Math.max(
2774
+ parsed.sandboxSnapshotTimeoutMs,
2775
+ parsed.sandboxDrainSnapshotTimeoutMs ?? parsed.sandboxSnapshotTimeoutMs
2776
+ )
2777
+ }) + 2 * parsed.sandboxLeaseReaperPeriodMs + 1
2778
+ )
2779
+ ) : parsed.sandboxRotationLeadMs,
2748
2780
  mcpServers: ensureBuiltInMcpServers(parsed)
2749
2781
  };
2750
2782
  validateSettings(settings, source);
@@ -3611,6 +3643,14 @@ function legacyImplicitOpenAiDefinitionVersionFor(model, provider) {
3611
3643
  includeWireProfile: false
3612
3644
  });
3613
3645
  }
3646
+ function legacyCodexAstraImplicitCachingDefinitionVersionFor(model, provider) {
3647
+ 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" })) {
3648
+ return null;
3649
+ }
3650
+ const { definitionVersion: _definitionVersion, ...modelWithoutVersion } = model;
3651
+ const { promptCaching: _promptCaching, ...capabilities } = model.capabilities;
3652
+ return definitionVersionFor({ ...modelWithoutVersion, capabilities }, provider);
3653
+ }
3614
3654
  function builtinProviderId(settings) {
3615
3655
  return settings.openaiProvider === "azure" ? "azure" : "openai";
3616
3656
  }
@@ -4071,6 +4111,13 @@ function resolveTurnExecutionPolicyV1(settings, input) {
4071
4111
  definitionVersion: resolved.model.definitionVersion
4072
4112
  });
4073
4113
  }
4114
+ var TurnExecutionPolicyDefinitionMismatchError = class extends Error {
4115
+ code = "turn_execution_policy_definition_mismatch";
4116
+ constructor() {
4117
+ super("Turn execution policy does not match the current provider definition");
4118
+ this.name = "TurnExecutionPolicyDefinitionMismatchError";
4119
+ }
4120
+ };
4074
4121
  function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
4075
4122
  const parsed = TurnExecutionPolicyV1.parse(policy);
4076
4123
  const catalogSettings = settingsForTurnExecutionPolicy(settings, parsed.productModelId);
@@ -4093,11 +4140,14 @@ function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
4093
4140
  resolved.model,
4094
4141
  resolved.provider
4095
4142
  );
4096
- const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion;
4097
- const mismatched = parsed.providerId !== resolved.provider.id || parsed.upstreamModelId !== resolved.model.upstreamModelId || parsed.wireApi !== resolved.model.api || !definitionVersionMatches || canonicalJson(parsed.credentialSource) !== canonicalJson(resolved.model.credentialSource) || canonicalJson(parsed.billing) !== canonicalJson(resolved.model.billing);
4098
- if (mismatched) {
4143
+ const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion || parsed.definitionVersion === legacyCodexAstraImplicitCachingDefinitionVersionFor(resolved.model, resolved.provider);
4144
+ 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);
4145
+ if (identityMismatched) {
4099
4146
  throw new Error("Turn execution policy does not match the current provider definition");
4100
4147
  }
4148
+ if (!definitionVersionMatches) {
4149
+ throw new TurnExecutionPolicyDefinitionMismatchError();
4150
+ }
4101
4151
  return { policy: parsed, provider: resolved.provider, model: resolved.model };
4102
4152
  }
4103
4153
  function configuredModelPricingSchedules(settings) {
@@ -5203,7 +5253,22 @@ function validateSettings(settings, source = process.env) {
5203
5253
  parseExposedPorts(settings.dockerExposedPorts);
5204
5254
  sandboxEnvironmentVariableNames(settings);
5205
5255
  sandboxLifecycleHookIds(settings);
5206
- parseSandboxWarmRateJson(settings.sandboxWarmRateMicrosPerSecondJson);
5256
+ const warmRates = parseSandboxWarmRateJson(settings.sandboxWarmRateMicrosPerSecondJson);
5257
+ if (settings.sandboxWarmBillingMode === "credits" && Object.values(warmRates).some((rate) => !Number.isSafeInteger(rate))) {
5258
+ throw new Error(
5259
+ "OPENGENI_SANDBOX_WARM_RATE_MICROS_PER_SECOND_JSON paid rates must be safe integers"
5260
+ );
5261
+ }
5262
+ if (settings.documentEmbeddingBillingMode === "credits" && settings.documentEmbeddingProvider === "openai" && settings.documentEmbeddingRateMicrosPerMillionBytes <= 0) {
5263
+ throw new Error(
5264
+ "OPENGENI_DOCUMENT_EMBEDDING_RATE_MICROS_PER_MILLION_BYTES must be positive when paid OpenAI embedding billing is enabled"
5265
+ );
5266
+ }
5267
+ if (settings.documentEmbeddingBillingMode === "credits" && settings.documentEmbeddingProvider === "openai" && !settings.documentEmbeddingCreditsActivatedAt) {
5268
+ throw new Error(
5269
+ "OPENGENI_DOCUMENT_EMBEDDING_CREDITS_ACTIVATED_AT is required for paid OpenAI embeddings"
5270
+ );
5271
+ }
5207
5272
  if (settings.sandboxBackend === "opensandbox") {
5208
5273
  if (!/@sha256:[0-9a-f]{64}$/i.test(settings.openSandboxImage ?? "")) {
5209
5274
  throw new Error(
@@ -5262,9 +5327,10 @@ function validateSettings(settings, source = process.env) {
5262
5327
  ordinaryCaptureTimeoutMs,
5263
5328
  drainCaptureTimeoutMs
5264
5329
  );
5265
- if (!(rotationLeadMs > providerDeadlineCaptureTimeoutMs + reaperPeriod)) {
5330
+ const requiredRotationLeadMs = SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS + providerDeadlineCaptureTimeoutMs + 2 * reaperPeriod;
5331
+ if (!(rotationLeadMs > requiredRotationLeadMs)) {
5266
5332
  throw new Error(
5267
- `OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}) must exceed the largest durable snapshot or drain capture timeout plus one reaper period (${providerDeadlineCaptureTimeoutMs + reaperPeriod}), including for persisted Modal leases after a default-backend rollout.`
5333
+ `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
5334
  );
5269
5335
  }
5270
5336
  if (settings.sandboxBackend === "modal") {
@@ -5588,12 +5654,14 @@ export {
5588
5654
  RegistryProviderKind,
5589
5655
  SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS,
5590
5656
  SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS,
5657
+ SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS,
5591
5658
  SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS,
5592
5659
  SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS,
5593
5660
  SANDBOX_REQUIRED_ENV,
5594
5661
  SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS,
5595
5662
  SUPERGROK_REALTIME_MODEL_ID,
5596
5663
  SocialOAuthClientConfigSchema,
5664
+ TurnExecutionPolicyDefinitionMismatchError,
5597
5665
  VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
5598
5666
  VERCEL_AI_GATEWAY_BASE_URL,
5599
5667
  VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,