@opengeni/config 0.4.0 → 0.5.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 CHANGED
@@ -25,10 +25,10 @@ declare const AGENT_INSTRUCTIONS_CORE_PLACEHOLDER = "{{core}}";
25
25
  * baked into this overridable string.
26
26
  *
27
27
  * INVARIANT: with no per-workspace override and an empty environment, the
28
- * runtime's composed instructions are BYTE-IDENTICAL to the historical
29
- * hardcoded preamble. The template below is exactly the historical lines 1–11
30
- * joined by " ", followed by " " + the placeholder. Changing a single
31
- * character here changes that default; a runtime test pins it.
28
+ * runtime's composed instructions are byte-for-byte pinned by a runtime test.
29
+ * The template below is joined by " ", followed by " " + the placeholder.
30
+ * Changing a single character here changes that default; update the pin
31
+ * intentionally.
32
32
  */
33
33
  declare const DEFAULT_AGENT_INSTRUCTIONS: string;
34
34
  declare const McpServerConnectionRefSchema: z.ZodObject<{
@@ -106,24 +106,11 @@ declare const SettingsSchema: z.ZodObject<{
106
106
  goalMaxAutoContinuations: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
107
107
  goalNoProgressLimit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
108
108
  agentMaxModelCallsPerTurn: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
109
- sessionHistorySource: z.ZodDefault<z.ZodEnum<{
110
- run_state: "run_state";
111
- items: "items";
112
- }>>;
113
- contextCompactionMode: z.ZodDefault<z.ZodEnum<{
114
- auto: "auto";
115
- server: "server";
116
- client: "client";
117
- off: "off";
118
- }>>;
119
109
  contextWindowTokens: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
110
+ contextEffectiveWindowTokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
120
111
  contextCompactionThresholdRatio: z.ZodPipe<z.ZodDefault<z.ZodCoercedNumber<unknown>>, z.ZodTransform<number, number>>;
121
112
  contextReservedOutputTokens: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
122
- contextServerCompactThresholdTokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
123
- contextCompactSoftFraction: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
124
- contextCompactHardFraction: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
125
- contextKeepRecentTokens: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
126
- contextSummaryMaxTokens: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
113
+ contextAutoCompactThresholdTokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
127
114
  authRequired: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
128
115
  accessKey: z.ZodOptional<z.ZodString>;
129
116
  authAllowHealth: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
@@ -146,6 +133,7 @@ declare const SettingsSchema: z.ZodObject<{
146
133
  codexSubscriptionEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
147
134
  codexProductSku: z.ZodOptional<z.ZodString>;
148
135
  codexToolSearchEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
136
+ codexCredentialLeasingEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
149
137
  codexRotationNearExhaustionPct: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
150
138
  openaiReasoningEffort: z.ZodDefault<z.ZodEnum<{
151
139
  none: "none";
@@ -217,6 +205,7 @@ declare const SettingsSchema: z.ZodObject<{
217
205
  "h264-mp4": "h264-mp4";
218
206
  "vp9-webm": "vp9-webm";
219
207
  }>>;
208
+ workspaceCaptureEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
220
209
  recordingFramerate: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
221
210
  recordingMaxSeconds: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
222
211
  recordingMaxBytes: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -261,7 +250,9 @@ declare const SettingsSchema: z.ZodObject<{
261
250
  vercelTeamId: z.ZodOptional<z.ZodString>;
262
251
  vercelRuntime: z.ZodOptional<z.ZodString>;
263
252
  sandboxOwnershipEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
253
+ sandboxLazyProvisionEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
264
254
  sandboxSelfhostedEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
255
+ agentOpStreamEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
265
256
  enrollmentSigningSecret: z.ZodOptional<z.ZodString>;
266
257
  selfhostedNatsUrl: z.ZodOptional<z.ZodString>;
267
258
  selfhostedRelayUrl: z.ZodOptional<z.ZodString>;
@@ -273,12 +264,17 @@ declare const SettingsSchema: z.ZodObject<{
273
264
  selfhostedNatsCalloutPassword: z.ZodOptional<z.ZodString>;
274
265
  selfhostedNatsControlUser: z.ZodOptional<z.ZodString>;
275
266
  selfhostedNatsControlPassword: z.ZodOptional<z.ZodString>;
267
+ sandboxSelfhostedExecTimeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
268
+ sandboxSelfhostedControlTimeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
276
269
  sandboxLeaseReaperPeriodMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
277
270
  sandboxViewerHolderTtlMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
278
271
  sandboxIdleGraceMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
272
+ sandboxSnapshotIntervalMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
273
+ sandboxSnapshotTimeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
279
274
  sandboxLeaseTtlMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
280
275
  sandboxLeaseWarmingTtlMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
281
276
  sandboxWarmingTimeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
277
+ rigSetupTimeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
282
278
  sandboxWarmRateMicrosPerSecondJson: z.ZodDefault<z.ZodString>;
283
279
  sandboxMaxWarmSecondsPerWorkspace: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
284
280
  sandboxPreparationProfiles: z.ZodDefault<z.ZodString>;
@@ -425,6 +421,8 @@ declare const RegistryProviderSchema: z.ZodObject<{
425
421
  id: z.ZodString;
426
422
  label: z.ZodOptional<z.ZodString>;
427
423
  contextWindowTokens: z.ZodOptional<z.ZodNumber>;
424
+ effectiveContextWindowTokens: z.ZodOptional<z.ZodNumber>;
425
+ autoCompactTokenLimit: z.ZodOptional<z.ZodNumber>;
428
426
  reasoningEffort: z.ZodOptional<z.ZodBoolean>;
429
427
  hostedWebSearch: z.ZodOptional<z.ZodBoolean>;
430
428
  pricing: z.ZodOptional<z.ZodObject<{
@@ -449,9 +447,9 @@ type IntegrationOAuthClientConfig = z.infer<typeof IntegrationOAuthClientConfigS
449
447
  /**
450
448
  * Runtime-resolved provider (built-in or registry), client-construction-ready.
451
449
  * The built-in OpenAI/Azure provider is always present and always "responses";
452
- * registry providers carry their own base URL / key / wire API. compactionMode
453
- * is "server" only for the built-in OpenAI platform provider (its Responses API
454
- * honors server-side context_management) and "client" for everything else.
450
+ * registry providers carry their own base URL / key / wire API. Compaction is
451
+ * not a provider capability: all providers use the same durable plaintext
452
+ * replacement.
455
453
  */
456
454
  interface ResolvedModelProvider {
457
455
  id: string;
@@ -463,7 +461,6 @@ interface ResolvedModelProvider {
463
461
  apiKey?: string | undefined;
464
462
  defaultQuery?: Record<string, string> | undefined;
465
463
  defaultHeaders?: Record<string, string> | undefined;
466
- compactionMode: ContextCompactionMode;
467
464
  }
468
465
  /** A single exposed model + the provider that serves it. */
469
466
  interface ConfiguredModel {
@@ -473,6 +470,8 @@ interface ConfiguredModel {
473
470
  providerLabel: string;
474
471
  api: ModelProviderApi;
475
472
  contextWindowTokens?: number | undefined;
473
+ effectiveContextWindowTokens?: number | undefined;
474
+ autoCompactTokenLimit?: number | undefined;
476
475
  reasoningEffort: boolean;
477
476
  hostedWebSearch: boolean;
478
477
  }
@@ -506,16 +505,37 @@ declare function collectSandboxEnvironment(settings: Settings, source?: NodeJS.P
506
505
  * explicit environment in tests.
507
506
  */
508
507
  declare function resolveProviderApiKey(provider: Pick<RegistryProvider, "apiKey" | "apiKeyEnv">, source?: NodeJS.ProcessEnv): string | undefined;
508
+ /**
509
+ * The built-in provider's stable id: "openai" on the OpenAI platform, "azure"
510
+ * on Azure. Exported because the workspace model-policy gate must attribute
511
+ * the legacy resolveTurnModel-null fallback (which routes to this built-in
512
+ * client) to the SAME identity the router uses — otherwise a policy blocking
513
+ * the built-in could be bypassed through the null-resolution path.
514
+ */
515
+ declare function builtinProviderId(settings: Pick<Settings, "openaiProvider">): string;
509
516
  /**
510
517
  * Every provider a client may route to: the built-in OpenAI/Azure provider
511
- * first (id "openai"/"azure", always "responses", compactionMode from
512
- * resolveContextCompactionMode), then each registry provider in declaration
513
- * order (compactionMode "client"). Client-construction inputs are filled from
518
+ * first (id "openai"/"azure", always "responses"), then each registry provider
519
+ * in declaration order. Client-construction inputs are filled from
514
520
  * the existing flat openai/azure settings for the built-in, and from the
515
521
  * registry entry for the rest. Registry ids may not collide with the built-in
516
522
  * id — validateSettings rejects that at boot.
517
523
  */
518
524
  declare function configuredProviders(settings: Settings): ResolvedModelProvider[];
525
+ /**
526
+ * The provider identity a model id resolves to, for workspace model-policy
527
+ * evaluation — MUST agree with the real router (resolveTurnModel /
528
+ * MultiProviderModelProvider) on every case:
529
+ * - `codex/<slug>` → the codex-subscription provider id, ALWAYS. With no
530
+ * active subscription the router fails loud (CodexSubscriptionUnavailableError),
531
+ * never the built-in — so attributing by prefix is exact even against BASE
532
+ * settings where the overlay provider is not injected.
533
+ * - a configured model id → its configuredModels providerId (registry or built-in).
534
+ * - anything else → the built-in id: an unknown id is the legacy
535
+ * resolveTurnModel-null fallback, which the built-in OpenAI/Azure client
536
+ * serves. A policy blocking the built-in must block this path too.
537
+ */
538
+ declare function policyProviderIdForModel(settings: Settings, modelId: string): string;
519
539
  /**
520
540
  * Every model a client may use, the built-in provider's models first
521
541
  * (configuredAllowedModels-from-openai, mapped to "responses" with
@@ -550,28 +570,16 @@ declare function resolveModelProvider(settings: Settings, modelId: string): {
550
570
  */
551
571
  declare function configuredModelPricing(settings: Settings): Record<string, ModelPricing>;
552
572
  /**
553
- * Resolved conversation-context compaction path for a run.
554
- * - "server": let the OpenAI platform Responses API compact server-side (the
555
- * SDK emits context_management; we pass the correct gpt-5.5 threshold).
556
- * - "client": run OpenGeni's own client-side compaction (Azure and any other
557
- * backend that rejects/ignores context_management).
558
- * - "off": neither (legacy unbounded growth; escape hatch).
559
- *
560
- * "auto" maps to "server" on the OpenAI platform provider and "client"
561
- * otherwise — Azure's Responses API returns 400 unsupported_parameter for
562
- * context_management, so it must never take the server path.
573
+ * Usable input-token budget: an explicit model-catalog effective window when
574
+ * available, otherwise the deployment window minus its output reserve.
563
575
  */
564
- type ContextCompactionMode = "server" | "client" | "off";
565
- declare function resolveContextCompactionMode(settings: Pick<Settings, "contextCompactionMode" | "openaiProvider">): ContextCompactionMode;
566
- /** Usable input-token budget B = window - reserved output. */
567
- declare function contextInputBudgetTokens(settings: Pick<Settings, "contextWindowTokens" | "contextReservedOutputTokens">): number;
576
+ declare function contextInputBudgetTokens(settings: Pick<Settings, "contextWindowTokens" | "contextEffectiveWindowTokens" | "contextReservedOutputTokens">): number;
568
577
  /**
569
- * Server-path compact_threshold (tokens) handed to the SDK's
570
- * StaticCompactionPolicy: the explicit override when set, else
571
- * floor(B * softFraction). This is what sidesteps the SDK's wrong 240k
572
- * fallback for gpt-5.5 (which is absent from its hardcoded window map).
578
+ * Apply the resolved provider/model's context policy to one turn. Registry
579
+ * metadata is authoritative when present; deployment defaults remain the
580
+ * fallback for models that do not declare their own limits.
573
581
  */
574
- declare function contextServerCompactThreshold(settings: Pick<Settings, "contextWindowTokens" | "contextReservedOutputTokens" | "contextServerCompactThresholdTokens" | "contextCompactSoftFraction" | "contextCompactionThresholdRatio">): number;
582
+ declare function settingsWithResolvedModelContext(settings: Settings, model: Pick<ConfiguredModel, "contextWindowTokens" | "effectiveContextWindowTokens" | "autoCompactTokenLimit">): Settings;
575
583
  declare function configuredStaticUsageLimits(settings: Settings): StaticUsageLimitsConfig;
576
584
  declare function configuredEntitlements(settings: Settings): EntitlementsConfig;
577
585
  declare function calculateModelUsageCostMicros(settings: Settings, model: string, usage: ModelUsageInput): number;
@@ -609,20 +617,22 @@ declare function collectGitIdentityEnvironment(settings: Settings): Record<strin
609
617
  * workspace environment < the backend-aware HOME default. Reserved-name validation
610
618
  * at write time keeps workspace values from colliding with platform entries.
611
619
  *
612
- * DELIBERATELY EXCLUDES the per-run, ROTATING GitHub App installation token
613
- * VALUE that `sandboxEnvironmentForRun` mints when a repository resource is
620
+ * DELIBERATELY EXCLUDES the per-run, ROTATING git provider token VALUES that
621
+ * `sandboxEnvironmentForRun` mints when a repository resource is
614
622
  * attached: that token is minted FRESH per call, so it is not a stable, attach-
615
623
  * reproducible value and must not be part of the shared base. Under the token-
616
- * broker (B1) the token VALUE never rides the manifest at all — it is seeded to a
617
- * FILE inside the box (agent-managed, refreshable mid-turn via the `github_token`
618
- * MCP tool) and git auth flows through GIT_ASKPASS -> that file. What IS stable and
619
- * lives here is the token FILE PATH (`OPENGENI_GIT_TOKEN_FILE`): a constant derived
620
- * from HOME, so it appears IDENTICALLY on BOTH the turn AND every attach manifest
621
- * (the SDK's per-turn provided-session env delta stays empty even as the token
622
- * rotates). The attach surfaces have only the `Session` (no repo resources) and so
623
- * never seed a token, but the file-path pointer is harmless (an unwritten file
624
- * simply yields no auth); the BLOCKING attach-vs-turn error this helper fixes is
625
- * for the common (no-repo) and workspace-environment-attached cases.
624
+ * broker (B1) token VALUES never ride the manifest at all — they are seeded to
625
+ * FILES inside the box and git/provider CLI auth reads those files. What IS stable
626
+ * and lives here for provisioned boxes are the token directory / GitHub alias
627
+ * FILE PATH and wrapper PATH entries: constants derived from HOME, so they
628
+ * appear IDENTICALLY on BOTH the turn AND every attach manifest (the SDK's
629
+ * per-turn provided-session env delta stays empty even as tokens rotate). These
630
+ * helper pointers are deliberately not added for selfhosted/local/none because
631
+ * the platform never mints or seeds git provider tokens there. The attach
632
+ * surfaces have only the `Session` (no repo resources) and so never seed a token,
633
+ * but unwritten files simply yield no auth; the BLOCKING attach-vs-turn error
634
+ * this helper fixes is for the common (no-repo) and workspace-environment-attached
635
+ * provisioned-box cases.
626
636
  */
627
637
  declare function stableSandboxEnvironmentForRun(settings: Settings, workspaceEnvironment?: Record<string, string>, options?: {
628
638
  workspaceId?: string;
@@ -636,6 +646,15 @@ declare function stableSandboxEnvironmentForRun(settings: Settings, workspaceEnv
636
646
  */
637
647
  declare function hasGitHubRepositorySelection(resources: ReadonlyArray<{
638
648
  kind: string;
649
+ provider?: unknown;
650
+ installationId?: unknown;
651
+ repositoryId?: unknown;
652
+ githubInstallationId?: unknown;
653
+ githubRepositoryId?: unknown;
654
+ }>): boolean;
655
+ declare function hasGitCredentialRepositorySelection(resources: ReadonlyArray<{
656
+ kind: string;
657
+ provider?: unknown;
639
658
  githubInstallationId?: unknown;
640
659
  githubRepositoryId?: unknown;
641
660
  }>): boolean;
@@ -777,4 +796,4 @@ interface NatsControlPlaneAuth {
777
796
  }
778
797
  declare function resolveNatsControlPlaneAuth(settings: Settings): NatsControlPlaneAuth | null;
779
798
 
780
- export { AGENT_INSTRUCTIONS_CORE_PLACEHOLDER, type ConfiguredModel, type ContextCompactionMode, DEFAULT_AGENT_INSTRUCTIONS, type EntitlementsConfig, type IntegrationOAuthClientConfig, IntegrationOAuthClientConfigSchema, type McpServerConfig, type McpServerConnectionRef, McpServerConnectionRefSchema, type ModelPricing, ModelProviderApi, type ModelUsageInput, type NatsCalloutConfig, type NatsControlPlaneAuth, type RegistryProvider, RegistryProviderKind, type ResolvedModelProvider, SANDBOX_REQUIRED_ENV, type SandboxRequiredEnv, type Settings, type StartupRetryOptions, type StaticUsageLimitsConfig, applyGitAuthPointerEnvironment, calculateModelUsageCostMicros, collectGitIdentityEnvironment, collectSandboxEnvironment, configuredAllowedModels, configuredAllowedReasoningEfforts, configuredEntitlements, configuredModelPricing, configuredModels, configuredProviders, configuredStaticUsageLimits, contextInputBudgetTokens, contextServerCompactThreshold, dbSearchPath, defaultModelPricing, effectiveModalIdleTimeoutSeconds, environmentsEncryptionKeyBytes, firstPartyMcpBaseUrl, firstPartyMcpWorkspaceUrl, getSettings, hasGitHubRepositorySelection, parseExposedPorts, parseIntegrationsOauthClientsJson, parseMcpServers, parseModelPricingJson, parseModelProvidersJson, parseSandboxWarmRateJson, parseStaticEntitlementsJson, parseStaticUsageLimitsJson, requiredSandboxEnvForBackend, resolveContextCompactionMode, resolveEnrollmentSigningSecret, resolveModelProvider, resolveNatsCalloutConfig, resolveNatsControlPlaneAuth, resolveProviderApiKey, resolveRelayTokenSecret, resolveStreamTokenSecret, retryStartupDependency, sandboxEnvironmentVariableNames, sandboxLifecycleHookIds, sandboxPreparationProfiles, sandboxWarmRateMicrosPerSecond, stableSandboxEnvironmentForRun, startupRetryOptions, streamTokenDegraded };
799
+ export { AGENT_INSTRUCTIONS_CORE_PLACEHOLDER, type ConfiguredModel, DEFAULT_AGENT_INSTRUCTIONS, type EntitlementsConfig, type IntegrationOAuthClientConfig, IntegrationOAuthClientConfigSchema, type McpServerConfig, type McpServerConnectionRef, McpServerConnectionRefSchema, type ModelPricing, ModelProviderApi, type ModelUsageInput, type NatsCalloutConfig, type NatsControlPlaneAuth, type RegistryProvider, RegistryProviderKind, type ResolvedModelProvider, SANDBOX_REQUIRED_ENV, type SandboxRequiredEnv, type Settings, type StartupRetryOptions, type StaticUsageLimitsConfig, applyGitAuthPointerEnvironment, builtinProviderId, calculateModelUsageCostMicros, collectGitIdentityEnvironment, collectSandboxEnvironment, configuredAllowedModels, configuredAllowedReasoningEfforts, configuredEntitlements, configuredModelPricing, configuredModels, configuredProviders, configuredStaticUsageLimits, contextInputBudgetTokens, dbSearchPath, defaultModelPricing, effectiveModalIdleTimeoutSeconds, environmentsEncryptionKeyBytes, firstPartyMcpBaseUrl, firstPartyMcpWorkspaceUrl, getSettings, hasGitCredentialRepositorySelection, hasGitHubRepositorySelection, parseExposedPorts, parseIntegrationsOauthClientsJson, parseMcpServers, parseModelPricingJson, parseModelProvidersJson, parseSandboxWarmRateJson, parseStaticEntitlementsJson, parseStaticUsageLimitsJson, policyProviderIdForModel, requiredSandboxEnvForBackend, resolveEnrollmentSigningSecret, resolveModelProvider, resolveNatsCalloutConfig, resolveNatsControlPlaneAuth, resolveProviderApiKey, resolveRelayTokenSecret, resolveStreamTokenSecret, retryStartupDependency, sandboxEnvironmentVariableNames, sandboxLifecycleHookIds, sandboxPreparationProfiles, sandboxWarmRateMicrosPerSecond, settingsWithResolvedModelContext, stableSandboxEnvironmentForRun, startupRetryOptions, streamTokenDegraded };