@opengeni/config 0.2.5 → 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Cloudgeni-ai
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/dist/index.d.ts CHANGED
@@ -31,6 +31,23 @@ declare const AGENT_INSTRUCTIONS_CORE_PLACEHOLDER = "{{core}}";
31
31
  * character here changes that default; a runtime test pins it.
32
32
  */
33
33
  declare const DEFAULT_AGENT_INSTRUCTIONS: string;
34
+ declare const McpServerConnectionRefSchema: z.ZodObject<{
35
+ connectionId: z.ZodOptional<z.ZodString>;
36
+ providerDomain: z.ZodString;
37
+ kind: z.ZodOptional<z.ZodEnum<{
38
+ oauth2: "oauth2";
39
+ api_key: "api_key";
40
+ app_install: "app_install";
41
+ delegated: "delegated";
42
+ }>>;
43
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
+ resource: z.ZodOptional<z.ZodString>;
45
+ subjectScope: z.ZodOptional<z.ZodEnum<{
46
+ workspace: "workspace";
47
+ subject: "subject";
48
+ }>>;
49
+ }, z.core.$strict>;
50
+ type McpServerConnectionRef = z.infer<typeof McpServerConnectionRefSchema>;
34
51
  declare const SettingsSchema: z.ZodObject<{
35
52
  serviceName: z.ZodDefault<z.ZodString>;
36
53
  environment: z.ZodDefault<z.ZodString>;
@@ -79,7 +96,13 @@ declare const SettingsSchema: z.ZodObject<{
79
96
  delegationSecret: z.ZodOptional<z.ZodString>;
80
97
  streamTokenSecret: z.ZodOptional<z.ZodString>;
81
98
  streamControlEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
99
+ toolspaceEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
100
+ toolspaceMaxCallsPerTurn: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
82
101
  environmentsEncryptionKey: z.ZodOptional<z.ZodString>;
102
+ integrationsEnabled: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
103
+ integrationsStateSecret: z.ZodOptional<z.ZodString>;
104
+ integrationsAllowPrivateNetworkTargets: z.ZodDefault<z.ZodPreprocess<z.ZodBoolean>>;
105
+ integrationsOauthClientsJson: z.ZodDefault<z.ZodString>;
83
106
  goalMaxAutoContinuations: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
84
107
  goalNoProgressLimit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
85
108
  agentMaxModelCallsPerTurn: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -94,6 +117,7 @@ declare const SettingsSchema: z.ZodObject<{
94
117
  off: "off";
95
118
  }>>;
96
119
  contextWindowTokens: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
120
+ contextCompactionThresholdRatio: z.ZodPipe<z.ZodDefault<z.ZodCoercedNumber<unknown>>, z.ZodTransform<number, number>>;
97
121
  contextReservedOutputTokens: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
98
122
  contextServerCompactThresholdTokens: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
99
123
  contextCompactSoftFraction: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -169,6 +193,7 @@ declare const SettingsSchema: z.ZodObject<{
169
193
  dockerNetwork: z.ZodOptional<z.ZodString>;
170
194
  modalAppName: z.ZodDefault<z.ZodString>;
171
195
  modalImageRef: z.ZodOptional<z.ZodString>;
196
+ modalImageRegistrySecret: z.ZodOptional<z.ZodString>;
172
197
  modalTimeoutSeconds: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
173
198
  modalTokenId: z.ZodOptional<z.ZodString>;
174
199
  modalTokenSecret: z.ZodOptional<z.ZodString>;
@@ -320,7 +345,24 @@ declare const SettingsSchema: z.ZodObject<{
320
345
  allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
321
346
  timeoutMs: z.ZodOptional<z.ZodNumber>;
322
347
  cacheToolsList: z.ZodDefault<z.ZodBoolean>;
348
+ requireApproval: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
323
349
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
350
+ connectionRef: z.ZodOptional<z.ZodObject<{
351
+ connectionId: z.ZodOptional<z.ZodString>;
352
+ providerDomain: z.ZodString;
353
+ kind: z.ZodOptional<z.ZodEnum<{
354
+ oauth2: "oauth2";
355
+ api_key: "api_key";
356
+ app_install: "app_install";
357
+ delegated: "delegated";
358
+ }>>;
359
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
360
+ resource: z.ZodOptional<z.ZodString>;
361
+ subjectScope: z.ZodOptional<z.ZodEnum<{
362
+ workspace: "workspace";
363
+ subject: "subject";
364
+ }>>;
365
+ }, z.core.$strict>>;
324
366
  }, z.core.$strip>>>;
325
367
  }, z.core.$strip>;
326
368
  type Settings = z.infer<typeof SettingsSchema>;
@@ -394,6 +436,16 @@ declare const RegistryProviderSchema: z.ZodObject<{
394
436
  }, z.core.$strip>>;
395
437
  }, z.core.$strip>;
396
438
  type RegistryProvider = z.infer<typeof RegistryProviderSchema>;
439
+ declare const IntegrationOAuthClientConfigSchema: z.ZodObject<{
440
+ clientId: z.ZodString;
441
+ clientSecret: z.ZodOptional<z.ZodString>;
442
+ tokenEndpointAuthMethod: z.ZodDefault<z.ZodEnum<{
443
+ none: "none";
444
+ client_secret_post: "client_secret_post";
445
+ client_secret_basic: "client_secret_basic";
446
+ }>>;
447
+ }, z.core.$strip>;
448
+ type IntegrationOAuthClientConfig = z.infer<typeof IntegrationOAuthClientConfigSchema>;
397
449
  /**
398
450
  * Runtime-resolved provider (built-in or registry), client-construction-ready.
399
451
  * The built-in OpenAI/Azure provider is always present and always "responses";
@@ -519,7 +571,7 @@ declare function contextInputBudgetTokens(settings: Pick<Settings, "contextWindo
519
571
  * floor(B * softFraction). This is what sidesteps the SDK's wrong 240k
520
572
  * fallback for gpt-5.5 (which is absent from its hardcoded window map).
521
573
  */
522
- declare function contextServerCompactThreshold(settings: Pick<Settings, "contextWindowTokens" | "contextReservedOutputTokens" | "contextServerCompactThresholdTokens" | "contextCompactSoftFraction">): number;
574
+ declare function contextServerCompactThreshold(settings: Pick<Settings, "contextWindowTokens" | "contextReservedOutputTokens" | "contextServerCompactThresholdTokens" | "contextCompactSoftFraction" | "contextCompactionThresholdRatio">): number;
523
575
  declare function configuredStaticUsageLimits(settings: Settings): StaticUsageLimitsConfig;
524
576
  declare function configuredEntitlements(settings: Settings): EntitlementsConfig;
525
577
  declare function calculateModelUsageCostMicros(settings: Settings, model: string, usage: ModelUsageInput): number;
@@ -572,7 +624,9 @@ declare function collectGitIdentityEnvironment(settings: Settings): Record<strin
572
624
  * simply yields no auth); the BLOCKING attach-vs-turn error this helper fixes is
573
625
  * for the common (no-repo) and workspace-environment-attached cases.
574
626
  */
575
- declare function stableSandboxEnvironmentForRun(settings: Settings, workspaceEnvironment?: Record<string, string>): Record<string, string>;
627
+ declare function stableSandboxEnvironmentForRun(settings: Settings, workspaceEnvironment?: Record<string, string>, options?: {
628
+ workspaceId?: string;
629
+ }): Record<string, string>;
576
630
  /**
577
631
  * Whether a resource set carries a GitHub-App-connected repository (installation
578
632
  * + repository ids present) — the SAME predicate the worker turn uses to decide
@@ -633,6 +687,7 @@ declare function sandboxWarmRateMicrosPerSecond(settings: Settings, backend: str
633
687
  * name so a malformed registry fails fast at boot (validateSettings calls this).
634
688
  */
635
689
  declare function parseModelProvidersJson(raw: string): RegistryProvider[];
690
+ declare function parseIntegrationsOauthClientsJson(raw: string | undefined): Record<string, IntegrationOAuthClientConfig>;
636
691
  declare function parseStaticUsageLimitsJson(raw: string): StaticUsageLimitsConfig;
637
692
  declare function parseStaticEntitlementsJson(raw: string): EntitlementsConfig;
638
693
  /**
@@ -657,6 +712,7 @@ declare function parseStaticEntitlementsJson(raw: string): EntitlementsConfig;
657
712
  * the one binding a mounted embed cannot leave unset.
658
713
  */
659
714
  declare function firstPartyMcpBaseUrl(settings: Settings): string;
715
+ declare function firstPartyMcpWorkspaceUrl(settings: Settings, workspaceId: string): string;
660
716
  /**
661
717
  * Resolve the secret used to sign/verify scoped stream tokens (master-spine
662
718
  * §C.3). Falls back to `delegationSecret` (the same HMAC envelope family —
@@ -721,4 +777,4 @@ interface NatsControlPlaneAuth {
721
777
  }
722
778
  declare function resolveNatsControlPlaneAuth(settings: Settings): NatsControlPlaneAuth | null;
723
779
 
724
- export { AGENT_INSTRUCTIONS_CORE_PLACEHOLDER, type ConfiguredModel, type ContextCompactionMode, DEFAULT_AGENT_INSTRUCTIONS, type EntitlementsConfig, type McpServerConfig, 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, getSettings, hasGitHubRepositorySelection, parseExposedPorts, parseMcpServers, parseModelPricingJson, parseModelProvidersJson, parseSandboxWarmRateJson, parseStaticEntitlementsJson, parseStaticUsageLimitsJson, requiredSandboxEnvForBackend, resolveContextCompactionMode, resolveEnrollmentSigningSecret, resolveModelProvider, resolveNatsCalloutConfig, resolveNatsControlPlaneAuth, resolveProviderApiKey, resolveRelayTokenSecret, resolveStreamTokenSecret, retryStartupDependency, sandboxEnvironmentVariableNames, sandboxLifecycleHookIds, sandboxPreparationProfiles, sandboxWarmRateMicrosPerSecond, stableSandboxEnvironmentForRun, startupRetryOptions, streamTokenDegraded };
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 };
package/dist/index.js CHANGED
@@ -73,6 +73,14 @@ var DEFAULT_AGENT_INSTRUCTIONS = [
73
73
  "Return concise, factual summaries with files changed, commands run, and remaining blockers.",
74
74
  AGENT_INSTRUCTIONS_CORE_PLACEHOLDER
75
75
  ].join(" ");
76
+ var McpServerConnectionRefSchema = z.object({
77
+ connectionId: z.string().uuid().optional(),
78
+ providerDomain: z.string().min(1),
79
+ kind: z.enum(["oauth2", "api_key", "app_install", "delegated"]).optional(),
80
+ scopes: z.array(z.string().min(1)).optional(),
81
+ resource: z.string().min(1).optional(),
82
+ subjectScope: z.enum(["workspace", "subject"]).optional()
83
+ }).strict();
76
84
  var SettingsSchema = z.object({
77
85
  serviceName: z.string().default("opengeni"),
78
86
  environment: z.string().default("local"),
@@ -124,7 +132,13 @@ var SettingsSchema = z.object({
124
132
  // holder of stream:control gets 403 until this flips. Keeps stream:control a
125
133
  // declared-but-inert permission so later hardening is a flag flip.
126
134
  streamControlEnabled: EnvBoolean.default(false),
135
+ toolspaceEnabled: EnvBoolean.default(false),
136
+ toolspaceMaxCallsPerTurn: z.coerce.number().int().positive().default(200),
127
137
  environmentsEncryptionKey: z.string().optional(),
138
+ integrationsEnabled: EnvBoolean.default(false),
139
+ integrationsStateSecret: z.string().optional(),
140
+ integrationsAllowPrivateNetworkTargets: EnvBoolean.default(false),
141
+ integrationsOauthClientsJson: z.string().default("{}"),
128
142
  // Session goal guard rails. Goals are designed for runs that legitimately
129
143
  // span days, so length is bounded by pathology detection (no-progress
130
144
  // streaks, budget exhaustion), never by count. goalMaxAutoContinuations is
@@ -161,15 +175,26 @@ var SettingsSchema = z.object({
161
175
  // derived from these settings on the server path, and use the same numbers to
162
176
  // budget the client path.
163
177
  contextWindowTokens: z.coerce.number().int().positive().default(105e4),
178
+ // Proactive compaction threshold as a ratio of the model context window.
179
+ // Defaults to 60% and is clamped to [0.3, 0.9] so deployments can tune the
180
+ // trigger without accidentally disabling compaction or waiting until the
181
+ // provider is already at the cliff.
182
+ contextCompactionThresholdRatio: z.coerce.number().default(0.6).transform((value) => {
183
+ if (!Number.isFinite(value)) {
184
+ return 0.6;
185
+ }
186
+ return Math.min(0.9, Math.max(0.3, value));
187
+ }),
164
188
  // Tokens reserved for model output; subtracted from the window to get the
165
189
  // usable input budget B = contextWindowTokens - contextReservedOutputTokens.
166
190
  contextReservedOutputTokens: z.coerce.number().int().nonnegative().default(128e3),
167
191
  // Server path only: explicit compact_threshold (tokens) handed to the SDK's
168
- // StaticCompactionPolicy. Defaults to floor(B * contextCompactSoftFraction)
169
- // when unset.
192
+ // StaticCompactionPolicy. Defaults to floor(contextWindowTokens *
193
+ // contextCompactionThresholdRatio) when unset.
170
194
  contextServerCompactThresholdTokens: z.coerce.number().int().positive().optional(),
171
- // Server path/back-compat knobs. The client compaction path ignores these:
172
- // it uses Codex-parity 0.9 * (window - reserved output - 20k summary buffer).
195
+ // Deprecated back-compat knobs. The threshold is now controlled by
196
+ // contextCompactionThresholdRatio; these remain parsed so older deployments do
197
+ // not fail boot when their env still contains them.
173
198
  contextCompactSoftFraction: z.coerce.number().positive().max(1).default(0.7),
174
199
  contextCompactHardFraction: z.coerce.number().positive().max(1).default(0.85),
175
200
  // Deprecated for the client path; parsed for env/back-compat only.
@@ -264,6 +289,15 @@ var SettingsSchema = z.object({
264
289
  dockerNetwork: z.string().optional(),
265
290
  modalAppName: z.string().default("opengeni-sandbox"),
266
291
  modalImageRef: z.string().optional(),
292
+ // Name of a Modal Secret (containing REGISTRY_USERNAME + REGISTRY_PASSWORD) used
293
+ // to authenticate the pull of `modalImageRef` from a PRIVATE registry. When UNSET
294
+ // (the default), the sandbox image is pulled UNAUTHENTICATED — i.e. it must be a
295
+ // PUBLIC registry tag, which is the only shape the Agents-extension Modal backend
296
+ // supports out of the box (`Image.fromRegistry(tag)` with no secret). Set this to
297
+ // run a private image (e.g. a cloud-hosted ACR/ECR/GCR digest): the runtime resolves
298
+ // the named Secret and builds the image via `fromRegistry(tag, secret)` before the
299
+ // first sandbox is created. Knob: OPENGENI_MODAL_IMAGE_REGISTRY_SECRET.
300
+ modalImageRegistrySecret: z.string().optional(),
267
301
  // Modal's hard sandbox lifetime (timeoutMs = this * 1000), counted from each
268
302
  // create/resume — it is the BACKSTOP that reclaims a box if the reaper/worker is
269
303
  // down, NOT the warm-window controller (that's sandboxIdleGraceMs). It must
@@ -559,13 +593,22 @@ var SettingsSchema = z.object({
559
593
  allowedTools: z.array(z.string().min(1)).optional(),
560
594
  timeoutMs: z.number().int().positive().optional(),
561
595
  cacheToolsList: z.boolean().default(false),
596
+ /**
597
+ * Human-approval policy for this server's tools, overlaid per-run from a
598
+ * session MCP server row (never from OPENGENI_MCP_SERVERS). `true` = all
599
+ * tools require approval; a string[] = only the listed UNPREFIXED tool
600
+ * names do; absent = auto-run (the historical default). Enforced in the
601
+ * runtime by attaching `needsApproval` to the matching MCP tools.
602
+ */
603
+ requireApproval: z.union([z.boolean(), z.array(z.string().min(1))]).optional(),
562
604
  /**
563
605
  * Extra request headers sent to this MCP server (credential injection
564
606
  * for workspace-enabled capability MCPs). Populated at runtime from
565
607
  * encrypted capability-installation credentials; do not put secrets in
566
608
  * OPENGENI_MCP_SERVERS.
567
609
  */
568
- headers: z.record(z.string(), z.string()).optional()
610
+ headers: z.record(z.string(), z.string()).optional(),
611
+ connectionRef: McpServerConnectionRefSchema.optional()
569
612
  })).default([])
570
613
  });
571
614
  var ModelPricingSchema = z.object({
@@ -604,6 +647,11 @@ var RegistryProviderSchema = z.object({
604
647
  defaultHeaders: z.record(z.string(), z.string()).optional(),
605
648
  models: z.array(RegistryModelSchema).min(1)
606
649
  });
650
+ var IntegrationOAuthClientConfigSchema = z.object({
651
+ clientId: z.string().min(1),
652
+ clientSecret: z.string().min(1).optional(),
653
+ tokenEndpointAuthMethod: z.enum(["none", "client_secret_post", "client_secret_basic"]).default("none")
654
+ });
607
655
  var defaultModelPricing = {
608
656
  "gpt-5.5": {
609
657
  inputMicrosPerMillionTokens: 5e6,
@@ -749,13 +797,20 @@ function getSettings() {
749
797
  delegationSecret: optional("OPENGENI_DELEGATION_SECRET"),
750
798
  streamTokenSecret: optional("OPENGENI_STREAM_TOKEN_SECRET"),
751
799
  streamControlEnabled: optional("OPENGENI_STREAM_CONTROL_ENABLED"),
800
+ toolspaceEnabled: optional("OPENGENI_TOOLSPACE_ENABLED"),
801
+ toolspaceMaxCallsPerTurn: optional("OPENGENI_TOOLSPACE_MAX_CALLS_PER_TURN"),
752
802
  environmentsEncryptionKey: optional("OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY"),
803
+ integrationsEnabled: optional("OPENGENI_INTEGRATIONS_ENABLED"),
804
+ integrationsStateSecret: optional("OPENGENI_INTEGRATIONS_STATE_SECRET"),
805
+ integrationsAllowPrivateNetworkTargets: optional("OPENGENI_INTEGRATIONS_ALLOW_PRIVATE_NETWORK_TARGETS"),
806
+ integrationsOauthClientsJson: optional("OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON"),
753
807
  goalMaxAutoContinuations: optional("OPENGENI_GOAL_MAX_AUTO_CONTINUATIONS"),
754
808
  goalNoProgressLimit: optional("OPENGENI_GOAL_NO_PROGRESS_LIMIT"),
755
809
  agentMaxModelCallsPerTurn: optional("OPENGENI_AGENT_MAX_MODEL_CALLS_PER_TURN"),
756
810
  sessionHistorySource: optional("OPENGENI_SESSION_HISTORY_SOURCE"),
757
811
  contextCompactionMode: optional("OPENGENI_CONTEXT_COMPACTION_MODE"),
758
812
  contextWindowTokens: optional("OPENGENI_CONTEXT_WINDOW_TOKENS"),
813
+ contextCompactionThresholdRatio: optional("OPENGENI_COMPACTION_THRESHOLD_RATIO"),
759
814
  contextReservedOutputTokens: optional("OPENGENI_CONTEXT_RESERVED_OUTPUT_TOKENS"),
760
815
  contextServerCompactThresholdTokens: optional("OPENGENI_CONTEXT_SERVER_COMPACT_THRESHOLD_TOKENS"),
761
816
  contextCompactSoftFraction: optional("OPENGENI_CONTEXT_COMPACT_SOFT_FRACTION"),
@@ -803,6 +858,7 @@ function getSettings() {
803
858
  dockerNetwork: optional("OPENGENI_DOCKER_NETWORK"),
804
859
  modalAppName: optional("OPENGENI_MODAL_APP_NAME"),
805
860
  modalImageRef: optional("OPENGENI_MODAL_IMAGE_REF"),
861
+ modalImageRegistrySecret: optional("OPENGENI_MODAL_IMAGE_REGISTRY_SECRET"),
806
862
  modalTimeoutSeconds: optional("OPENGENI_MODAL_TIMEOUT_SECONDS"),
807
863
  modalTokenId: optional("OPENGENI_MODAL_TOKEN_ID"),
808
864
  modalTokenSecret: optional("OPENGENI_MODAL_TOKEN_SECRET"),
@@ -1086,7 +1142,7 @@ function contextServerCompactThreshold(settings) {
1086
1142
  if (settings.contextServerCompactThresholdTokens) {
1087
1143
  return settings.contextServerCompactThresholdTokens;
1088
1144
  }
1089
- return Math.floor(contextInputBudgetTokens(settings) * settings.contextCompactSoftFraction);
1145
+ return Math.floor(settings.contextWindowTokens * settings.contextCompactionThresholdRatio);
1090
1146
  }
1091
1147
  function configuredStaticUsageLimits(settings) {
1092
1148
  return parseStaticUsageLimitsJson(settings.staticUsageLimitsJson);
@@ -1149,7 +1205,7 @@ function collectGitIdentityEnvironment(settings) {
1149
1205
  GIT_COMMITTER_EMAIL: settings.gitCommitterEmail ?? settings.gitAuthorEmail
1150
1206
  }).filter((entry) => typeof entry[1] === "string" && entry[1].trim().length > 0));
1151
1207
  }
1152
- function stableSandboxEnvironmentForRun(settings, workspaceEnvironment = {}) {
1208
+ function stableSandboxEnvironmentForRun(settings, workspaceEnvironment = {}, options = {}) {
1153
1209
  const environment = {
1154
1210
  ...collectSandboxEnvironment(settings),
1155
1211
  ...collectGitIdentityEnvironment(settings),
@@ -1160,6 +1216,12 @@ function stableSandboxEnvironmentForRun(settings, workspaceEnvironment = {}) {
1160
1216
  environment.HOME ??= descriptor.workspaceRoot;
1161
1217
  }
1162
1218
  environment.OPENGENI_GIT_TOKEN_FILE ??= `${environment.HOME ?? descriptor.workspaceRoot}/.opengeni/git-token`;
1219
+ if (settings.toolspaceEnabled) {
1220
+ environment.OPENGENI_TOOLSPACE_TOKEN_FILE ??= `${environment.HOME ?? descriptor.workspaceRoot}/.opengeni/toolspace-token`;
1221
+ if (options.workspaceId) {
1222
+ environment.OPENGENI_TOOLSPACE_URL ??= firstPartyMcpWorkspaceUrl(settings, options.workspaceId);
1223
+ }
1224
+ }
1163
1225
  return environment;
1164
1226
  }
1165
1227
  function hasGitHubRepositorySelection(resources) {
@@ -1333,6 +1395,33 @@ function parseModelProvidersJson(raw) {
1333
1395
  return result.data;
1334
1396
  });
1335
1397
  }
1398
+ function parseIntegrationsOauthClientsJson(raw) {
1399
+ if (!raw?.trim() || raw.trim() === "{}") {
1400
+ return {};
1401
+ }
1402
+ let parsed;
1403
+ try {
1404
+ parsed = JSON.parse(raw);
1405
+ } catch (error) {
1406
+ const message = error instanceof Error ? error.message : String(error);
1407
+ throw new Error(`OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON must be valid JSON: ${message}`);
1408
+ }
1409
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1410
+ throw new Error("OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON must be a JSON object keyed by authorization-server issuer or URL");
1411
+ }
1412
+ const out = {};
1413
+ for (const [key, value] of Object.entries(parsed)) {
1414
+ if (!key.trim()) {
1415
+ throw new Error("OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON contains an empty issuer key");
1416
+ }
1417
+ const result = IntegrationOAuthClientConfigSchema.safeParse(value);
1418
+ if (!result.success) {
1419
+ throw new Error(`OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON client for ${key} is invalid: ${result.error.message}`);
1420
+ }
1421
+ out[key] = result.data;
1422
+ }
1423
+ return out;
1424
+ }
1336
1425
  function parseStaticUsageLimitsJson(raw) {
1337
1426
  if (!raw.trim() || raw.trim() === "{}") {
1338
1427
  return {};
@@ -1413,7 +1502,7 @@ function ensureBuiltInMcpServers(settings) {
1413
1502
  id: "docs",
1414
1503
  name: "Document Search",
1415
1504
  url: firstPartyDocsMcpUrl,
1416
- allowedTools: ["search_documents", "fetch_document_chunk", "list_document_bases"],
1505
+ allowedTools: ["search_documents", "fetch_document_chunk", "list_document_bases", "knowledge_search", "knowledge_fetch", "memory_search", "memory_propose"],
1417
1506
  cacheToolsList: false
1418
1507
  }],
1419
1508
  ...existing
@@ -1422,6 +1511,17 @@ function ensureBuiltInMcpServers(settings) {
1422
1511
  function firstPartyMcpBaseUrl(settings) {
1423
1512
  return settings.opengeniMcpUrl ?? `http://127.0.0.1:${settings.apiPort}/v1/workspaces/{workspaceId}/mcp`;
1424
1513
  }
1514
+ function firstPartyMcpWorkspaceUrl(settings, workspaceId) {
1515
+ const raw = firstPartyMcpBaseUrl(settings);
1516
+ if (raw.includes("{workspaceId}")) {
1517
+ return raw.replaceAll("{workspaceId}", workspaceId);
1518
+ }
1519
+ const url = new URL(raw);
1520
+ url.pathname = `/v1/workspaces/${workspaceId}/mcp`;
1521
+ url.search = "";
1522
+ url.hash = "";
1523
+ return url.toString();
1524
+ }
1425
1525
  function firstPartyMcpServerUrl(settings) {
1426
1526
  return firstPartyMcpBaseUrl(settings);
1427
1527
  }
@@ -1429,6 +1529,9 @@ function firstPartyDocumentsMcpServerUrl(mcpUrl) {
1429
1529
  return `${mcpUrl.replace(/\/+$/, "")}/docs`;
1430
1530
  }
1431
1531
  function validateSettings(settings) {
1532
+ if (settings.toolspaceEnabled && !settings.delegationSecret) {
1533
+ throw new Error("OPENGENI_DELEGATION_SECRET is required when OPENGENI_TOOLSPACE_ENABLED=true");
1534
+ }
1432
1535
  if (settings.productAccessMode === "managed") {
1433
1536
  if (!settings.publicBaseUrl) {
1434
1537
  throw new Error("OPENGENI_PUBLIC_BASE_URL is required when OPENGENI_PRODUCT_ACCESS_MODE=managed");
@@ -1447,6 +1550,18 @@ function validateSettings(settings) {
1447
1550
  }
1448
1551
  }
1449
1552
  environmentsEncryptionKeyBytes(settings);
1553
+ if (settings.integrationsEnabled) {
1554
+ if (settings.productAccessMode === "managed" && !settings.publicBaseUrl) {
1555
+ throw new Error("OPENGENI_PUBLIC_BASE_URL is required when OPENGENI_INTEGRATIONS_ENABLED=true and OPENGENI_PRODUCT_ACCESS_MODE=managed");
1556
+ }
1557
+ if (settings.publicBaseUrl && !settings.publicBaseUrl.startsWith("https://") && !["local", "test"].includes(settings.environment)) {
1558
+ throw new Error("OPENGENI_PUBLIC_BASE_URL must use https when OPENGENI_INTEGRATIONS_ENABLED=true outside local/test");
1559
+ }
1560
+ if (!settings.integrationsStateSecret && !["local", "test"].includes(settings.environment)) {
1561
+ throw new Error("OPENGENI_INTEGRATIONS_STATE_SECRET is required when OPENGENI_INTEGRATIONS_ENABLED=true outside local/test");
1562
+ }
1563
+ }
1564
+ parseIntegrationsOauthClientsJson(settings.integrationsOauthClientsJson);
1450
1565
  if (settings.productAccessMode === "configured" && !["local", "test"].includes(settings.environment) && !settings.delegationSecret && !settings.authRequired) {
1451
1566
  throw new Error("OPENGENI_PRODUCT_ACCESS_MODE=configured requires OPENGENI_DELEGATION_SECRET or OPENGENI_AUTH_REQUIRED=true outside local/test");
1452
1567
  }
@@ -1688,6 +1803,8 @@ function delay(ms) {
1688
1803
  export {
1689
1804
  AGENT_INSTRUCTIONS_CORE_PLACEHOLDER,
1690
1805
  DEFAULT_AGENT_INSTRUCTIONS,
1806
+ IntegrationOAuthClientConfigSchema,
1807
+ McpServerConnectionRefSchema,
1691
1808
  ModelProviderApi,
1692
1809
  RegistryProviderKind,
1693
1810
  SANDBOX_REQUIRED_ENV,
@@ -1709,9 +1826,11 @@ export {
1709
1826
  effectiveModalIdleTimeoutSeconds,
1710
1827
  environmentsEncryptionKeyBytes,
1711
1828
  firstPartyMcpBaseUrl,
1829
+ firstPartyMcpWorkspaceUrl,
1712
1830
  getSettings,
1713
1831
  hasGitHubRepositorySelection,
1714
1832
  parseExposedPorts,
1833
+ parseIntegrationsOauthClientsJson,
1715
1834
  parseMcpServers,
1716
1835
  parseModelPricingJson,
1717
1836
  parseModelProvidersJson,