@opengeni/config 1.4.0 → 1.4.4
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 +34 -0
- package/dist/index.js +38 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +89 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/config",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "OpenGeni runtime configuration: settings resolution, deployment knobs, and config validation shared across the server packages.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"prepublishOnly": "bash ../../scripts/prepublish-guard"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@opengeni/codex": "1.4.
|
|
37
|
-
"@opengeni/contracts": "1.4.
|
|
38
|
-
"@opengeni/xai-subscription": "1.4.
|
|
36
|
+
"@opengeni/codex": "1.4.4",
|
|
37
|
+
"@opengeni/contracts": "1.4.4",
|
|
38
|
+
"@opengeni/xai-subscription": "1.4.4",
|
|
39
39
|
"zod": "^4.2.1"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export { managedUserEmailAllowed } from "./managed-user-admission";
|
|
2
|
-
import {
|
|
3
|
-
parseRealtimeVoicePricingJson,
|
|
4
|
-
parseRealtimeVoicePricingTableJson,
|
|
5
|
-
} from "./realtime-voice-pricing";
|
|
6
2
|
export * from "./realtime-voice-pricing";
|
|
7
3
|
export * from "./web-search";
|
|
8
4
|
import { EnvCreditPromotionPolicy } from "./credit-promotions";
|
|
@@ -71,6 +67,24 @@ import { createHash } from "node:crypto";
|
|
|
71
67
|
import { isIP } from "node:net";
|
|
72
68
|
import { z } from "zod";
|
|
73
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Default maximum provider silence on a generic OpenAI-compatible model stream
|
|
72
|
+
* while the worker is waiting for the next chunk. Matches the Codex transport
|
|
73
|
+
* and SuperGrok idle defaults (5 minutes): long enough for a reasoning model's
|
|
74
|
+
* silent thinking gaps, short enough that a wedged stream recovers the same
|
|
75
|
+
* turn instead of hanging until a worker roll.
|
|
76
|
+
*/
|
|
77
|
+
export const DEFAULT_MODEL_STREAM_IDLE_TIMEOUT_MS = 300_000;
|
|
78
|
+
/**
|
|
79
|
+
* Default maximum wait across keepalive-only traffic (SSE comments, `ping` /
|
|
80
|
+
* `keepalive` events, repeated `response.in_progress`) for the next
|
|
81
|
+
* model-progress event on a generic model stream. A provider can keep a
|
|
82
|
+
* connection alive while its generation is wedged; this bounds that case.
|
|
83
|
+
* Ten minutes leaves room for a reasoning model's longest silent thinking
|
|
84
|
+
* window (reasoning summaries stream as progress).
|
|
85
|
+
*/
|
|
86
|
+
export const DEFAULT_MODEL_STREAM_PROGRESS_TIMEOUT_MS = 600_000;
|
|
87
|
+
|
|
74
88
|
const envName = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
75
89
|
const registryId = /^[A-Za-z0-9_-]+$/;
|
|
76
90
|
export const DEFAULT_OPENROUTER_MODEL_ID =
|
|
@@ -813,6 +827,29 @@ const SettingsSchema = z.object({
|
|
|
813
827
|
.positive()
|
|
814
828
|
.max(24 * 60 * 60_000)
|
|
815
829
|
.default(XAI_RESPONSE_STREAM_IDLE_TIMEOUT_MS),
|
|
830
|
+
// Maximum silence between response bytes on a generic OpenAI-compatible
|
|
831
|
+
// model stream (built-in OpenAI/Azure and registry chat/responses providers).
|
|
832
|
+
// Not a request/run duration cap: every received byte resets the timer, and
|
|
833
|
+
// it measures only time spent waiting on the provider for the next chunk. A
|
|
834
|
+
// stalled stream fails as a retryable provider failure so finite same-turn
|
|
835
|
+
// recovery replaces it. A registry provider may override it with
|
|
836
|
+
// `streamIdleTimeoutMs`. Codex, SuperGrok, and Anthropic Messages own their
|
|
837
|
+
// transport-specific idle timers.
|
|
838
|
+
modelStreamIdleTimeoutMs: z.coerce
|
|
839
|
+
.number()
|
|
840
|
+
.int()
|
|
841
|
+
.positive()
|
|
842
|
+
.max(24 * 60 * 60_000)
|
|
843
|
+
.default(DEFAULT_MODEL_STREAM_IDLE_TIMEOUT_MS),
|
|
844
|
+
// Maximum wait across keepalive-only stream traffic for the next
|
|
845
|
+
// model-progress event (registry override: `streamProgressTimeoutMs`).
|
|
846
|
+
// Never shorter than modelStreamIdleTimeoutMs.
|
|
847
|
+
modelStreamProgressTimeoutMs: z.coerce
|
|
848
|
+
.number()
|
|
849
|
+
.int()
|
|
850
|
+
.positive()
|
|
851
|
+
.max(24 * 60 * 60_000)
|
|
852
|
+
.default(DEFAULT_MODEL_STREAM_PROGRESS_TIMEOUT_MS),
|
|
816
853
|
// Expose the connected apps attached to a Codex subscription through the
|
|
817
854
|
// synthetic codex_apps MCP server. Independent from subscription routing so
|
|
818
855
|
// operators can use Codex models without exposing ChatGPT connectors.
|
|
@@ -2686,6 +2723,20 @@ const RegistryProviderSchema = z
|
|
|
2686
2723
|
label: z.string().min(1).optional(),
|
|
2687
2724
|
api: ModelProviderApi.default("chat"),
|
|
2688
2725
|
anthropic: AnthropicProviderOptions.optional(),
|
|
2726
|
+
// Generic OpenAI-compatible stream silence bound; overrides the deployment
|
|
2727
|
+
// `modelStreamIdleTimeoutMs` for this provider only.
|
|
2728
|
+
streamIdleTimeoutMs: z
|
|
2729
|
+
.number()
|
|
2730
|
+
.int()
|
|
2731
|
+
.positive()
|
|
2732
|
+
.max(24 * 60 * 60_000)
|
|
2733
|
+
.optional(),
|
|
2734
|
+
streamProgressTimeoutMs: z
|
|
2735
|
+
.number()
|
|
2736
|
+
.int()
|
|
2737
|
+
.positive()
|
|
2738
|
+
.max(24 * 60 * 60_000)
|
|
2739
|
+
.optional(),
|
|
2689
2740
|
wireProfile: ModelProviderWireProfile.default("openai"),
|
|
2690
2741
|
baseUrl: z.string().url(),
|
|
2691
2742
|
apiKey: z.string().optional(), // inline key (pragmatic) ...
|
|
@@ -3178,6 +3229,10 @@ export interface ResolvedModelProvider {
|
|
|
3178
3229
|
defaultHeaders?: Record<string, string> | undefined;
|
|
3179
3230
|
publicDefaultQueryNames?: string[] | undefined;
|
|
3180
3231
|
publicDefaultHeaderNames?: string[] | undefined;
|
|
3232
|
+
/** Generic OpenAI-compatible stream silence bound override (ms). */
|
|
3233
|
+
streamIdleTimeoutMs?: number | undefined;
|
|
3234
|
+
/** Generic OpenAI-compatible keepalive-only progress bound override (ms). */
|
|
3235
|
+
streamProgressTimeoutMs?: number | undefined;
|
|
3181
3236
|
credentialSource: CredentialSourceV1;
|
|
3182
3237
|
billing: BillingAttributionV1;
|
|
3183
3238
|
}
|
|
@@ -4053,6 +4108,8 @@ export function getSettings(source: NodeJS.ProcessEnv = process.env): Settings {
|
|
|
4053
4108
|
supergrokResponseStreamIdleTimeoutMs: optional(
|
|
4054
4109
|
"OPENGENI_SUPERGROK_RESPONSE_STREAM_IDLE_TIMEOUT_MS",
|
|
4055
4110
|
),
|
|
4111
|
+
modelStreamIdleTimeoutMs: optional("OPENGENI_MODEL_STREAM_IDLE_TIMEOUT_MS"),
|
|
4112
|
+
modelStreamProgressTimeoutMs: optional("OPENGENI_MODEL_STREAM_PROGRESS_TIMEOUT_MS"),
|
|
4056
4113
|
codexConnectedAppsEnabled: optional("OPENGENI_CODEX_CONNECTED_APPS_ENABLED"),
|
|
4057
4114
|
codexToolSearchEnabled: optional("OPENGENI_CODEX_TOOL_SEARCH_ENABLED"),
|
|
4058
4115
|
lazyToolSearchEnabled: optional("OPENGENI_LAZY_TOOL_SEARCH_ENABLED"),
|
|
@@ -6010,6 +6067,12 @@ export function configuredProviders(
|
|
|
6010
6067
|
defaultHeaders: provider.defaultHeaders,
|
|
6011
6068
|
publicDefaultQueryNames: provider.publicDefaultQueryNames,
|
|
6012
6069
|
publicDefaultHeaderNames: provider.publicDefaultHeaderNames,
|
|
6070
|
+
...(provider.streamIdleTimeoutMs !== undefined
|
|
6071
|
+
? { streamIdleTimeoutMs: provider.streamIdleTimeoutMs }
|
|
6072
|
+
: {}),
|
|
6073
|
+
...(provider.streamProgressTimeoutMs !== undefined
|
|
6074
|
+
? { streamProgressTimeoutMs: provider.streamProgressTimeoutMs }
|
|
6075
|
+
: {}),
|
|
6013
6076
|
credentialSource: registryCredentialSource(provider),
|
|
6014
6077
|
billing: registryBilling(provider),
|
|
6015
6078
|
}),
|
|
@@ -8103,6 +8166,28 @@ export function parseIntegrationsOauthClientsJson(
|
|
|
8103
8166
|
return out;
|
|
8104
8167
|
}
|
|
8105
8168
|
|
|
8169
|
+
/**
|
|
8170
|
+
* The operator-registered client for one authorization server, matched by
|
|
8171
|
+
* exact issuer/URL key first and then trailing-slash-insensitively. The OAuth
|
|
8172
|
+
* start flow and the connector catalog's connectability projection share this
|
|
8173
|
+
* so a catalog row is offered exactly when a start would find a client.
|
|
8174
|
+
*/
|
|
8175
|
+
export function findIntegrationsOauthClient(
|
|
8176
|
+
configured: Readonly<Record<string, IntegrationOAuthClientConfig>>,
|
|
8177
|
+
candidates: readonly string[],
|
|
8178
|
+
): IntegrationOAuthClientConfig | null {
|
|
8179
|
+
const normalize = (value: string) => value.replace(/\/+$/, "");
|
|
8180
|
+
for (const key of new Set(candidates.flatMap((candidate) => [candidate, normalize(candidate)]))) {
|
|
8181
|
+
const entry = configured[key];
|
|
8182
|
+
if (entry) return entry;
|
|
8183
|
+
}
|
|
8184
|
+
const normalizedCandidates = new Set(candidates.map(normalize));
|
|
8185
|
+
for (const [key, entry] of Object.entries(configured)) {
|
|
8186
|
+
if (normalizedCandidates.has(normalize(key))) return entry;
|
|
8187
|
+
}
|
|
8188
|
+
return null;
|
|
8189
|
+
}
|
|
8190
|
+
|
|
8106
8191
|
export const SocialOAuthClientConfigSchema = z.object({
|
|
8107
8192
|
clientId: z.string().min(1),
|
|
8108
8193
|
clientSecret: z.string().min(1).optional(),
|
|
@@ -8900,11 +8985,6 @@ function validateSettings(settings: Settings, source: NodeJS.ProcessEnv = proces
|
|
|
8900
8985
|
// Malformed voice-input pricing deliberately does not fail boot: every
|
|
8901
8986
|
// process shares this config, and a voice-only typo must not crash-loop
|
|
8902
8987
|
// workers. The provider is withheld and the API logs voiceInputPricingIssues.
|
|
8903
|
-
parseRealtimeVoicePricingJson(settings.azureLivePricingJson, "OPENGENI_AZURE_LIVE_PRICING_JSON");
|
|
8904
|
-
parseRealtimeVoicePricingTableJson(
|
|
8905
|
-
settings.aiGatewayRealtimePricingJson,
|
|
8906
|
-
"OPENGENI_AI_GATEWAY_REALTIME_PRICING_JSON",
|
|
8907
|
-
);
|
|
8908
8988
|
sandboxEnvironmentVariableNames(settings);
|
|
8909
8989
|
sandboxLifecycleHookIds(settings);
|
|
8910
8990
|
// Fail fast on a malformed warm-rate table (P2.1).
|