@opengeni/config 1.3.0 → 1.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/dist/index.d.ts +146 -4
- package/dist/index.js +1150 -541
- package/dist/index.js.map +1 -1
- package/dist/realtime-voice-pricing.d.ts +30 -0
- package/dist/web-search.d.ts +127 -0
- package/package.json +4 -4
- package/src/index.ts +545 -10
- package/src/realtime-voice-pricing.ts +83 -0
- package/src/web-search.ts +353 -0
package/dist/index.js
CHANGED
|
@@ -3,18 +3,271 @@ function managedUserEmailAllowed(allowedUserEmails, email) {
|
|
|
3
3
|
return allowedUserEmails === void 0 || typeof email === "string" && allowedUserEmails.some((allowed2) => allowed2.toLowerCase() === email.trim().toLowerCase());
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
// src/realtime-voice-pricing.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var RealtimeVoicePricingSchema = z.object({
|
|
9
|
+
microsPerMinute: z.number().int().positive().max(1e8),
|
|
10
|
+
marginBps: z.number().int().min(0).max(1e5).optional()
|
|
11
|
+
}).strict();
|
|
12
|
+
var AZURE_LIVE_REALTIME_MODEL_ID = "opengeni-azure/gpt-live-1";
|
|
13
|
+
function parseJson(raw, env) {
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(raw);
|
|
16
|
+
} catch {
|
|
17
|
+
throw new Error(`${env} must be valid JSON`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function issues(error) {
|
|
21
|
+
return error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
|
|
22
|
+
}
|
|
23
|
+
function parseRealtimeVoicePricingJson(raw, env = "live voice pricing JSON") {
|
|
24
|
+
if (raw === void 0 || raw.trim() === "") return null;
|
|
25
|
+
const result = RealtimeVoicePricingSchema.safeParse(parseJson(raw, env));
|
|
26
|
+
if (!result.success) throw new Error(`${env} is invalid: ${issues(result.error)}`);
|
|
27
|
+
return result.data;
|
|
28
|
+
}
|
|
29
|
+
function parseRealtimeVoicePricingTableJson(raw, env = "live voice pricing table JSON") {
|
|
30
|
+
if (raw === void 0 || raw.trim() === "") return {};
|
|
31
|
+
const result = z.record(z.string().min(1).max(256), RealtimeVoicePricingSchema).safeParse(parseJson(raw, env));
|
|
32
|
+
if (!result.success) throw new Error(`${env} is invalid: ${issues(result.error)}`);
|
|
33
|
+
return result.data;
|
|
34
|
+
}
|
|
35
|
+
function realtimeVoiceMinuteCreditMicros(pricing) {
|
|
36
|
+
const provider = BigInt(pricing.microsPerMinute);
|
|
37
|
+
const credit = (provider * BigInt(1e4 + (pricing.marginBps ?? 0)) + 9999n) / 10000n;
|
|
38
|
+
return { providerCostMicros: Number(provider), creditCostMicros: Number(credit) };
|
|
39
|
+
}
|
|
40
|
+
function realtimeVoiceStartedMinutes(startedAt, observedUntil) {
|
|
41
|
+
const elapsed = Math.max(0, observedUntil.getTime() - startedAt.getTime());
|
|
42
|
+
return Math.max(1, Math.ceil(elapsed / 6e4));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/web-search.ts
|
|
46
|
+
import { z as z2 } from "zod";
|
|
47
|
+
var WEB_SEARCH_PROVIDER_IDS = [
|
|
48
|
+
"tinyfish",
|
|
49
|
+
"exa",
|
|
50
|
+
"tavily",
|
|
51
|
+
"firecrawl",
|
|
52
|
+
"brave",
|
|
53
|
+
"jina",
|
|
54
|
+
"searxng"
|
|
55
|
+
];
|
|
56
|
+
var WEB_SEARCH_TOOL_NAME = "web_search";
|
|
57
|
+
var WEB_FETCH_TOOL_NAME = "web_fetch";
|
|
58
|
+
var WebSearchProviderMode = z2.enum(["fallback", "replace"]);
|
|
59
|
+
var WEB_SEARCH_PROVIDER_TRAITS = {
|
|
60
|
+
tinyfish: { search: true, fetch: true, searchKey: true, fetchKey: true, baseUrl: false },
|
|
61
|
+
exa: { search: true, fetch: true, searchKey: true, fetchKey: true, baseUrl: false },
|
|
62
|
+
tavily: { search: true, fetch: true, searchKey: true, fetchKey: true, baseUrl: false },
|
|
63
|
+
firecrawl: { search: true, fetch: true, searchKey: true, fetchKey: true, baseUrl: false },
|
|
64
|
+
brave: { search: true, fetch: false, searchKey: true, fetchKey: false, baseUrl: false },
|
|
65
|
+
jina: { search: true, fetch: true, searchKey: true, fetchKey: false, baseUrl: false },
|
|
66
|
+
searxng: { search: true, fetch: false, searchKey: false, fetchKey: false, baseUrl: true }
|
|
67
|
+
};
|
|
68
|
+
var WebSearchPricingSchema = z2.object({
|
|
69
|
+
searchMicros: z2.number().int().nonnegative().max(1e7),
|
|
70
|
+
fetchMicros: z2.number().int().nonnegative().max(1e7),
|
|
71
|
+
marginBps: z2.number().int().min(0).max(1e5).optional()
|
|
72
|
+
}).strict();
|
|
73
|
+
var DEFAULT_WEB_SEARCH_PRICING = {
|
|
74
|
+
// Search and Fetch are free at any wallet balance.
|
|
75
|
+
tinyfish: { searchMicros: 0, fetchMicros: 0, marginBps: 500 },
|
|
76
|
+
// Auto search $7/1k + highlights $1/1k; contents text $1/1k pages.
|
|
77
|
+
exa: { searchMicros: 8e3, fetchMicros: 1e3, marginBps: 500 },
|
|
78
|
+
// Basic search 1 credit, basic extract 1 credit per 5 URLs; $0.008/credit.
|
|
79
|
+
tavily: { searchMicros: 8e3, fetchMicros: 1600, marginBps: 500 },
|
|
80
|
+
// 2 credits per 10 results, 1 credit per scrape, at Hobby-plan credit cost.
|
|
81
|
+
firecrawl: { searchMicros: 6400, fetchMicros: 3200, marginBps: 500 },
|
|
82
|
+
// $5 per 1k requests.
|
|
83
|
+
brave: { searchMicros: 5e3, fetchMicros: 0, marginBps: 500 },
|
|
84
|
+
// At least 10k tokens per search at $0.05/1M; reader billed per token.
|
|
85
|
+
jina: { searchMicros: 500, fetchMicros: 250, marginBps: 500 },
|
|
86
|
+
// Self-hosted.
|
|
87
|
+
searxng: { searchMicros: 0, fetchMicros: 0, marginBps: 500 }
|
|
88
|
+
};
|
|
89
|
+
var TAVILY_CREDIT_MICROS = 8e3;
|
|
90
|
+
function usableSecret(value) {
|
|
91
|
+
const trimmed = value?.trim();
|
|
92
|
+
if (!trimmed) return null;
|
|
93
|
+
if (/^(your[-_ ]|<|changeme|replace[-_ ]?me|xxx)/iu.test(trimmed)) return null;
|
|
94
|
+
return trimmed;
|
|
95
|
+
}
|
|
96
|
+
function normalizedBaseUrl(value) {
|
|
97
|
+
const trimmed = value?.trim();
|
|
98
|
+
if (!trimmed) return null;
|
|
99
|
+
let url;
|
|
100
|
+
try {
|
|
101
|
+
url = new URL(trimmed);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
throw new Error("must be an absolute http(s) URL", { cause: error });
|
|
104
|
+
}
|
|
105
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
106
|
+
throw new Error("must be an absolute http(s) URL");
|
|
107
|
+
}
|
|
108
|
+
if (url.username || url.password) throw new Error("must not embed credentials");
|
|
109
|
+
return url.toString().replace(/\/+$/u, "");
|
|
110
|
+
}
|
|
111
|
+
function providerId(value) {
|
|
112
|
+
const normalized = value.trim().toLowerCase();
|
|
113
|
+
return WEB_SEARCH_PROVIDER_IDS.includes(normalized) ? normalized : null;
|
|
114
|
+
}
|
|
115
|
+
function resolveWebSearchProvider(settings) {
|
|
116
|
+
const raw = settings.webSearchProvider?.trim() ?? "";
|
|
117
|
+
if (!settings.webSearchEnabled || raw === "" || raw.toLowerCase() === "none") {
|
|
118
|
+
return { status: "off" };
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const search = providerId(raw);
|
|
122
|
+
if (!search) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
`OPENGENI_WEB_SEARCH_PROVIDER must be one of none, ${WEB_SEARCH_PROVIDER_IDS.join(", ")}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const modeResult = WebSearchProviderMode.safeParse(
|
|
128
|
+
settings.webSearchProviderMode?.trim().toLowerCase() || "fallback"
|
|
129
|
+
);
|
|
130
|
+
if (!modeResult.success) {
|
|
131
|
+
throw new Error("OPENGENI_WEB_SEARCH_PROVIDER_MODE must be fallback or replace");
|
|
132
|
+
}
|
|
133
|
+
let searchBaseUrl;
|
|
134
|
+
try {
|
|
135
|
+
searchBaseUrl = normalizedBaseUrl(settings.webSearchBaseUrl);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
throw new Error(`OPENGENI_WEB_SEARCH_BASE_URL ${error.message}`, {
|
|
138
|
+
cause: error
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const searchTraits = WEB_SEARCH_PROVIDER_TRAITS[search];
|
|
142
|
+
const searchKey = usableSecret(settings.webSearchApiKey);
|
|
143
|
+
if (searchTraits.searchKey && !searchKey) {
|
|
144
|
+
throw new Error(`${search} search needs OPENGENI_WEB_SEARCH_API_KEY`);
|
|
145
|
+
}
|
|
146
|
+
if (searchTraits.baseUrl && !searchBaseUrl) {
|
|
147
|
+
throw new Error(`${search} search needs OPENGENI_WEB_SEARCH_BASE_URL`);
|
|
148
|
+
}
|
|
149
|
+
const searchEndpoint = {
|
|
150
|
+
provider: search,
|
|
151
|
+
apiKey: searchKey,
|
|
152
|
+
baseUrl: searchBaseUrl
|
|
153
|
+
};
|
|
154
|
+
const fetchRaw = settings.webFetchProvider?.trim() ?? "";
|
|
155
|
+
let fetch = null;
|
|
156
|
+
if (fetchRaw === "") {
|
|
157
|
+
if (searchTraits.fetch) fetch = searchEndpoint;
|
|
158
|
+
} else if (fetchRaw.toLowerCase() !== "none") {
|
|
159
|
+
const fetchProvider = providerId(fetchRaw);
|
|
160
|
+
if (!fetchProvider || !WEB_SEARCH_PROVIDER_TRAITS[fetchProvider].fetch) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
`OPENGENI_WEB_FETCH_PROVIDER must be none or one of ${WEB_SEARCH_PROVIDER_IDS.filter(
|
|
163
|
+
(id) => WEB_SEARCH_PROVIDER_TRAITS[id].fetch
|
|
164
|
+
).join(", ")}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
let fetchBaseUrl;
|
|
168
|
+
try {
|
|
169
|
+
fetchBaseUrl = normalizedBaseUrl(settings.webFetchBaseUrl);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
throw new Error(`OPENGENI_WEB_FETCH_BASE_URL ${error.message}`, {
|
|
172
|
+
cause: error
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const sameProvider = fetchProvider === search;
|
|
176
|
+
const fetchKey = usableSecret(settings.webFetchApiKey) ?? (sameProvider ? searchKey : null);
|
|
177
|
+
if (WEB_SEARCH_PROVIDER_TRAITS[fetchProvider].fetchKey && !fetchKey) {
|
|
178
|
+
throw new Error(`${fetchProvider} fetch needs OPENGENI_WEB_FETCH_API_KEY`);
|
|
179
|
+
}
|
|
180
|
+
fetch = {
|
|
181
|
+
provider: fetchProvider,
|
|
182
|
+
apiKey: fetchKey,
|
|
183
|
+
baseUrl: fetchBaseUrl ?? (sameProvider ? searchBaseUrl : null)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
let pricingOverride = null;
|
|
187
|
+
const pricingRaw = settings.webSearchPricingJson?.trim();
|
|
188
|
+
if (pricingRaw) {
|
|
189
|
+
let parsed;
|
|
190
|
+
try {
|
|
191
|
+
parsed = JSON.parse(pricingRaw);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
throw new Error("OPENGENI_WEB_SEARCH_PRICING_JSON must be valid JSON", { cause: error });
|
|
194
|
+
}
|
|
195
|
+
const result = WebSearchPricingSchema.safeParse(parsed);
|
|
196
|
+
if (!result.success) {
|
|
197
|
+
throw new Error(
|
|
198
|
+
`OPENGENI_WEB_SEARCH_PRICING_JSON is invalid: ${result.error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ")}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
pricingOverride = result.data;
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
status: "configured",
|
|
205
|
+
config: {
|
|
206
|
+
mode: modeResult.data,
|
|
207
|
+
search: searchEndpoint,
|
|
208
|
+
fetch,
|
|
209
|
+
pricingOverride,
|
|
210
|
+
timeoutMs: settings.webSearchRequestTimeoutMs ?? 2e4
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
} catch (error) {
|
|
214
|
+
return { status: "invalid", reason: error.message };
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function webSearchProviderConfig(settings) {
|
|
218
|
+
const resolution = resolveWebSearchProvider(settings);
|
|
219
|
+
return resolution.status === "configured" ? resolution.config : null;
|
|
220
|
+
}
|
|
221
|
+
function webSearchToolPlan(settings, turn) {
|
|
222
|
+
const config = webSearchProviderConfig(settings);
|
|
223
|
+
if (!config || turn.transportHostedSearch) {
|
|
224
|
+
return { hostedWebSearch: turn.hostedWebSearch, providerTools: [] };
|
|
225
|
+
}
|
|
226
|
+
if (config.mode === "fallback" && turn.hostedWebSearch) {
|
|
227
|
+
return { hostedWebSearch: true, providerTools: [] };
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
hostedWebSearch: false,
|
|
231
|
+
providerTools: config.fetch ? [WEB_SEARCH_TOOL_NAME, WEB_FETCH_TOOL_NAME] : [WEB_SEARCH_TOOL_NAME]
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function webSearchCallPricing(config, operation) {
|
|
235
|
+
const endpoint = operation === "search" ? config.search : config.fetch;
|
|
236
|
+
const provider = endpoint?.provider ?? config.search.provider;
|
|
237
|
+
if (config.pricingOverride) {
|
|
238
|
+
return {
|
|
239
|
+
providerMicros: operation === "search" ? config.pricingOverride.searchMicros : config.pricingOverride.fetchMicros,
|
|
240
|
+
marginBps: config.pricingOverride.marginBps ?? 500,
|
|
241
|
+
explicit: true
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const builtin = DEFAULT_WEB_SEARCH_PRICING[provider];
|
|
245
|
+
const free = !endpoint?.apiKey;
|
|
246
|
+
return {
|
|
247
|
+
providerMicros: free ? 0 : operation === "search" ? builtin.searchMicros : builtin.fetchMicros,
|
|
248
|
+
marginBps: builtin.marginBps ?? 500,
|
|
249
|
+
explicit: false
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function webSearchCreditMicros(providerMicros, marginBps) {
|
|
253
|
+
if (!Number.isSafeInteger(providerMicros) || providerMicros < 0) {
|
|
254
|
+
throw new Error("web search provider cost must be a non-negative safe integer");
|
|
255
|
+
}
|
|
256
|
+
return Number((BigInt(providerMicros) * BigInt(1e4 + marginBps) + 9999n) / 10000n);
|
|
257
|
+
}
|
|
258
|
+
|
|
6
259
|
// src/credit-promotions.ts
|
|
7
260
|
import { PromotionalCreditScope } from "@opengeni/contracts";
|
|
8
|
-
import { z } from "zod";
|
|
261
|
+
import { z as z3 } from "zod";
|
|
9
262
|
var ModelIds = PromotionalCreditScope.shape.eligibleModelIds.transform((ids) => [
|
|
10
263
|
...new Set(ids)
|
|
11
264
|
]);
|
|
12
|
-
var CreditPromotionPolicy =
|
|
265
|
+
var CreditPromotionPolicy = z3.object({
|
|
13
266
|
defaultModelIds: ModelIds.optional(),
|
|
14
267
|
signupModelIds: ModelIds.optional(),
|
|
15
|
-
offers:
|
|
16
|
-
|
|
17
|
-
|
|
268
|
+
offers: z3.record(
|
|
269
|
+
z3.string().min(1),
|
|
270
|
+
z3.object({
|
|
18
271
|
label: PromotionalCreditScope.shape.label,
|
|
19
272
|
eligibleModelIds: ModelIds.optional()
|
|
20
273
|
}).strict()
|
|
@@ -30,7 +283,7 @@ var CreditPromotionPolicy = z.object({
|
|
|
30
283
|
}
|
|
31
284
|
}
|
|
32
285
|
});
|
|
33
|
-
var EnvCreditPromotionPolicy =
|
|
286
|
+
var EnvCreditPromotionPolicy = z3.preprocess(
|
|
34
287
|
(value) => {
|
|
35
288
|
if (typeof value !== "string") return value;
|
|
36
289
|
try {
|
|
@@ -103,7 +356,7 @@ import {
|
|
|
103
356
|
import { XAI_SUBSCRIPTION_MODEL_ID_PREFIX as XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 } from "@opengeni/xai-subscription";
|
|
104
357
|
import { createHash } from "crypto";
|
|
105
358
|
import { isIP } from "net";
|
|
106
|
-
import { z as
|
|
359
|
+
import { z as z5 } from "zod";
|
|
107
360
|
|
|
108
361
|
// src/claude-subscription-usage.ts
|
|
109
362
|
import {
|
|
@@ -351,17 +604,17 @@ function mergeClaudeUsage(current, observation) {
|
|
|
351
604
|
}
|
|
352
605
|
|
|
353
606
|
// src/claude-subscription-oauth.ts
|
|
354
|
-
import { z as
|
|
607
|
+
import { z as z4 } from "zod";
|
|
355
608
|
var CLAUDE_OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
356
609
|
var CLAUDE_OAUTH_AUTHORIZE_URL = "https://claude.com/cai/oauth/authorize";
|
|
357
610
|
var CLAUDE_OAUTH_TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
358
611
|
var CLAUDE_OAUTH_REDIRECT_URL = "https://platform.claude.com/oauth/code/callback";
|
|
359
612
|
var CLAUDE_OAUTH_SCOPES = ["user:inference", "user:profile"];
|
|
360
|
-
var ClaudeOAuthTokenResponse =
|
|
361
|
-
access_token:
|
|
362
|
-
refresh_token:
|
|
363
|
-
expires_in:
|
|
364
|
-
scope:
|
|
613
|
+
var ClaudeOAuthTokenResponse = z4.object({
|
|
614
|
+
access_token: z4.string().max(16384).regex(/^sk-ant-oat[0-9]+-\S+$/),
|
|
615
|
+
refresh_token: z4.string().min(1).max(16384).optional(),
|
|
616
|
+
expires_in: z4.number().int().positive().max(31536e3),
|
|
617
|
+
scope: z4.string().min(1).max(8192)
|
|
365
618
|
}).passthrough();
|
|
366
619
|
function claudeAuthorizationUrl(input) {
|
|
367
620
|
const url = new URL(CLAUDE_OAUTH_AUTHORIZE_URL);
|
|
@@ -475,7 +728,7 @@ var GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS = 6e4;
|
|
|
475
728
|
var GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS = 6e4;
|
|
476
729
|
var SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS = 60 * 6e4;
|
|
477
730
|
var SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS = 1e4;
|
|
478
|
-
var EnvBoolean =
|
|
731
|
+
var EnvBoolean = z5.preprocess((value) => {
|
|
479
732
|
if (typeof value !== "string") {
|
|
480
733
|
return value;
|
|
481
734
|
}
|
|
@@ -487,11 +740,11 @@ var EnvBoolean = z3.preprocess((value) => {
|
|
|
487
740
|
return false;
|
|
488
741
|
}
|
|
489
742
|
return value;
|
|
490
|
-
},
|
|
491
|
-
var PublicHttpUrl =
|
|
743
|
+
}, z5.boolean());
|
|
744
|
+
var PublicHttpUrl = z5.string().url().max(2048).refine((value) => /^https?:\/\//iu.test(value), "must be an http(s) URL");
|
|
492
745
|
var DEFAULT_GOAL_IDLE_BACKOFF_MS = [3e3, 3e4, 12e4, 3e5];
|
|
493
746
|
var DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS = 6e5;
|
|
494
|
-
var EnvGoalIdleBackoffMs =
|
|
747
|
+
var EnvGoalIdleBackoffMs = z5.preprocess((value) => {
|
|
495
748
|
if (typeof value !== "string") return value;
|
|
496
749
|
const source = value.trim();
|
|
497
750
|
if (!source) return void 0;
|
|
@@ -499,8 +752,8 @@ var EnvGoalIdleBackoffMs = z3.preprocess((value) => {
|
|
|
499
752
|
const trimmed = entry.trim();
|
|
500
753
|
return trimmed === "" ? Number.NaN : Number(trimmed);
|
|
501
754
|
});
|
|
502
|
-
},
|
|
503
|
-
var EnvFirstPartyMcpTools =
|
|
755
|
+
}, z5.array(z5.number().int().nonnegative()).min(1, "OPENGENI_GOAL_IDLE_BACKOFF_MS must list at least one delay in milliseconds").readonly());
|
|
756
|
+
var EnvFirstPartyMcpTools = z5.preprocess(
|
|
504
757
|
(value) => {
|
|
505
758
|
if (typeof value !== "string") return value;
|
|
506
759
|
const source = value.trim();
|
|
@@ -514,7 +767,7 @@ var EnvFirstPartyMcpTools = z3.preprocess(
|
|
|
514
767
|
}
|
|
515
768
|
return source.split(",").map((entry) => entry.trim());
|
|
516
769
|
},
|
|
517
|
-
|
|
770
|
+
z5.array(FirstPartyMcpToolName).superRefine((tools, context) => {
|
|
518
771
|
const seen = /* @__PURE__ */ new Set();
|
|
519
772
|
for (const [index, tool] of tools.entries()) {
|
|
520
773
|
if (seen.has(tool)) {
|
|
@@ -575,9 +828,9 @@ var DEFAULT_AGENT_INSTRUCTIONS = [
|
|
|
575
828
|
AGENT_INSTRUCTIONS_CORE_PLACEHOLDER
|
|
576
829
|
].join(" ");
|
|
577
830
|
var McpServerConnectionRefSchema = PublicMcpServerConnectionRef;
|
|
578
|
-
var McpOperationRecoverySchema =
|
|
579
|
-
|
|
580
|
-
|
|
831
|
+
var McpOperationRecoverySchema = z5.record(
|
|
832
|
+
z5.string().min(1).max(512).regex(/^\S+$/u),
|
|
833
|
+
z5.object({ observerTool: z5.string().min(1).max(512).regex(/^\S+$/u) }).strict()
|
|
581
834
|
).superRefine((bindings, context) => {
|
|
582
835
|
for (const [originalTool, binding] of Object.entries(bindings)) {
|
|
583
836
|
if (originalTool === binding.observerTool) {
|
|
@@ -590,67 +843,67 @@ var McpOperationRecoverySchema = z3.record(
|
|
|
590
843
|
}
|
|
591
844
|
});
|
|
592
845
|
var DEFAULT_MODAL_IMAGE_REF = "opengenipublicneuacr.azurecr.io/opengeni-desktop@sha256:554d5b324a580071dd669e7c1190931e498eb1b397412a27c7de84a430ef393a";
|
|
593
|
-
var SettingsSchema =
|
|
594
|
-
serviceName:
|
|
595
|
-
environment:
|
|
596
|
-
deploymentRevision:
|
|
846
|
+
var SettingsSchema = z5.object({
|
|
847
|
+
serviceName: z5.string().default("opengeni"),
|
|
848
|
+
environment: z5.string().default("local"),
|
|
849
|
+
deploymentRevision: z5.string().default("dev"),
|
|
597
850
|
// The release-train version baked into official images (OPENGENI_SERVER_VERSION).
|
|
598
851
|
// Absent on dev/source builds — consumers must treat it as optional.
|
|
599
|
-
serverVersion:
|
|
600
|
-
databaseUrl:
|
|
852
|
+
serverVersion: z5.string().optional(),
|
|
853
|
+
databaseUrl: z5.string().default("postgres://opengeni:opengeni@127.0.0.1:5432/opengeni"),
|
|
601
854
|
// API application pool only. Managed auth owns its separate pool; readiness
|
|
602
855
|
// reuses the application handle. Keep the historical default for existing
|
|
603
856
|
// deployments and let operators budget this per process with replica counts.
|
|
604
|
-
apiDatabasePoolMax:
|
|
857
|
+
apiDatabasePoolMax: z5.coerce.number().int().positive().default(32),
|
|
605
858
|
// Step I (§7.8 runtime half). Dedicated Postgres schema for the EMBEDDED
|
|
606
859
|
// topology. Default "" → standalone: no search_path scoping, server default
|
|
607
860
|
// (`public`). When set (e.g. "opengeni"), the db handle + the managed-auth
|
|
608
861
|
// pool send `search_path = "<dbSchema>","opengeni_private","public"` so every
|
|
609
862
|
// query resolves into the dedicated schema with NO query rewrite (schema-isolation contract F1).
|
|
610
|
-
dbSchema:
|
|
863
|
+
dbSchema: z5.string().default(""),
|
|
611
864
|
// Step I (§7.7). RLS posture. "force" (default) = today's FORCE-RLS via the
|
|
612
865
|
// non-owner `opengeni_app` role. "scoped" = the embedded owner-role path (the
|
|
613
866
|
// GUC is still emitted defensively, so the query path is identical).
|
|
614
|
-
rlsStrategy:
|
|
867
|
+
rlsStrategy: z5.enum(["force", "scoped"]).default("force"),
|
|
615
868
|
// Exact PostgreSQL login identity required by the standalone FORCE-RLS
|
|
616
869
|
// startup/readiness assertion. Embedded `scoped` hosts own their role model
|
|
617
870
|
// and are deliberately not constrained to this name.
|
|
618
|
-
runtimeDatabaseRole:
|
|
619
|
-
natsUrl:
|
|
620
|
-
temporalHost:
|
|
621
|
-
temporalNamespace:
|
|
622
|
-
temporalTaskQueue:
|
|
871
|
+
runtimeDatabaseRole: z5.string().min(1).default("opengeni_app"),
|
|
872
|
+
natsUrl: z5.string().default("nats://127.0.0.1:4222"),
|
|
873
|
+
temporalHost: z5.string().default("127.0.0.1:7233"),
|
|
874
|
+
temporalNamespace: z5.string().default("default"),
|
|
875
|
+
temporalTaskQueue: z5.string().default("opengeni-runs-ts"),
|
|
623
876
|
temporalTlsEnabled: EnvBoolean.default(false),
|
|
624
|
-
temporalApiKey:
|
|
625
|
-
temporalTlsServerName:
|
|
626
|
-
temporalTlsRootCaCertificateBase64:
|
|
627
|
-
temporalTlsClientCertificateBase64:
|
|
628
|
-
temporalTlsClientPrivateKeyBase64:
|
|
629
|
-
startupDependencyRetryAttempts:
|
|
630
|
-
startupDependencyRetryInitialDelayMs:
|
|
631
|
-
startupDependencyRetryMaxDelayMs:
|
|
632
|
-
turnWorkerConcurrencyMode:
|
|
633
|
-
turnWorkerMaxConcurrentTurns:
|
|
634
|
-
turnWorkerTargetCpuUsage:
|
|
635
|
-
turnWorkerTargetMemoryUsage:
|
|
877
|
+
temporalApiKey: z5.string().optional(),
|
|
878
|
+
temporalTlsServerName: z5.string().optional(),
|
|
879
|
+
temporalTlsRootCaCertificateBase64: z5.string().optional(),
|
|
880
|
+
temporalTlsClientCertificateBase64: z5.string().optional(),
|
|
881
|
+
temporalTlsClientPrivateKeyBase64: z5.string().optional(),
|
|
882
|
+
startupDependencyRetryAttempts: z5.coerce.number().int().positive().default(30),
|
|
883
|
+
startupDependencyRetryInitialDelayMs: z5.coerce.number().int().positive().default(1e3),
|
|
884
|
+
startupDependencyRetryMaxDelayMs: z5.coerce.number().int().positive().default(5e3),
|
|
885
|
+
turnWorkerConcurrencyMode: z5.enum(["fixed", "resource-based"]).default("fixed"),
|
|
886
|
+
turnWorkerMaxConcurrentTurns: z5.coerce.number().int().positive().max(2e3).default(16),
|
|
887
|
+
turnWorkerTargetCpuUsage: z5.coerce.number().positive().max(1).default(0.8),
|
|
888
|
+
turnWorkerTargetMemoryUsage: z5.coerce.number().positive().max(0.8).default(0.75),
|
|
636
889
|
// Admission and emergency recovery are deliberately separate control loops.
|
|
637
890
|
// The Temporal tuner stops polling at the lower target; only genuine danger
|
|
638
891
|
// may invoke the disruptive graceful-drain fallback.
|
|
639
|
-
turnWorkerEmergencyMemoryUsage:
|
|
640
|
-
turnWorkerMemoryGuardIntervalMs:
|
|
641
|
-
turnWorkerMemoryGuardSustainMs:
|
|
892
|
+
turnWorkerEmergencyMemoryUsage: z5.coerce.number().min(0.85).max(0.95).default(0.9),
|
|
893
|
+
turnWorkerMemoryGuardIntervalMs: z5.coerce.number().int().min(1e3).max(6e4).default(5e3),
|
|
894
|
+
turnWorkerMemoryGuardSustainMs: z5.coerce.number().int().min(5e3).max(3e5).default(3e4),
|
|
642
895
|
observabilityStructuredLogs: EnvBoolean.default(false),
|
|
643
896
|
observabilityMetricsEnabled: EnvBoolean.default(true),
|
|
644
|
-
observabilityOtlpEndpoint:
|
|
645
|
-
observabilityOtlpHeaders:
|
|
646
|
-
observabilityDiagnosticsEndpoint:
|
|
647
|
-
observabilityDiagnosticsHeaders:
|
|
897
|
+
observabilityOtlpEndpoint: z5.string().url().optional(),
|
|
898
|
+
observabilityOtlpHeaders: z5.string().default(""),
|
|
899
|
+
observabilityDiagnosticsEndpoint: z5.string().url().optional(),
|
|
900
|
+
observabilityDiagnosticsHeaders: z5.string().default(""),
|
|
648
901
|
analyticsEnabled: EnvBoolean.default(false),
|
|
649
902
|
analyticsConsentRequired: EnvBoolean.default(true),
|
|
650
|
-
analyticsReoClientId:
|
|
651
|
-
analyticsPosthogProjectKey:
|
|
652
|
-
analyticsPosthogHost:
|
|
653
|
-
analyticsGa4MeasurementId:
|
|
903
|
+
analyticsReoClientId: z5.string().max(128).regex(/^[A-Za-z0-9_-]+$/u).optional(),
|
|
904
|
+
analyticsPosthogProjectKey: z5.string().min(1).max(256).optional(),
|
|
905
|
+
analyticsPosthogHost: z5.string().url().max(2048).optional(),
|
|
906
|
+
analyticsGa4MeasurementId: z5.string().max(32).regex(/^G-[A-Z0-9]+$/u).optional(),
|
|
654
907
|
// Optional operator-owned legal documents linked from the signed-out console.
|
|
655
908
|
// Unset by default, so a self-hosted deployment never shows another operator's
|
|
656
909
|
// policies; the managed service points these at its own published pages.
|
|
@@ -659,14 +912,14 @@ var SettingsSchema = z3.object({
|
|
|
659
912
|
// Optional operator support address, shown as a "Contact support" mailto link
|
|
660
913
|
// on the signed-out page and in the Help menu. Unset by default for the same
|
|
661
914
|
// reason as the legal links.
|
|
662
|
-
supportEmail:
|
|
663
|
-
publicBaseUrl:
|
|
915
|
+
supportEmail: z5.string().trim().email().max(254).optional(),
|
|
916
|
+
publicBaseUrl: z5.string().url().optional(),
|
|
664
917
|
// Product documentation the web console links from its Help menu. Absent
|
|
665
918
|
// means the public OpenGeni docs; `none` hides the link for deployments that
|
|
666
919
|
// publish no documentation of their own.
|
|
667
|
-
documentationUrl:
|
|
920
|
+
documentationUrl: z5.preprocess(
|
|
668
921
|
(value) => typeof value === "string" ? value.trim().toLowerCase() === "none" ? null : value.trim() : value,
|
|
669
|
-
|
|
922
|
+
z5.url({ protocol: /^https?$/u, error: "must be an absolute http(s) URL or none" }).nullable().default(DEFAULT_OPENGENI_DOCUMENTATION_URL)
|
|
670
923
|
),
|
|
671
924
|
// Standards-based OAuth authorization server for external workspace MCP
|
|
672
925
|
// clients. Opt-in because it creates a new public authentication surface.
|
|
@@ -676,25 +929,25 @@ var SettingsSchema = z3.object({
|
|
|
676
929
|
// setup, login transactions). Forwarded client addresses are ignored by
|
|
677
930
|
// default so a caller cannot choose its own bucket. Operators may trust an
|
|
678
931
|
// exact number of proxy hops only when direct access to the API is blocked.
|
|
679
|
-
apiTrustedProxyHops:
|
|
932
|
+
apiTrustedProxyHops: z5.coerce.number().int().min(0).max(16).default(0),
|
|
680
933
|
// Optional comma-separated CIDRs (or single addresses) of the proxy that
|
|
681
934
|
// connects to the API. When set, forwarded client addresses are honored
|
|
682
935
|
// only for requests whose transport peer is inside one of them.
|
|
683
|
-
apiTrustedProxyCidrs:
|
|
936
|
+
apiTrustedProxyCidrs: z5.string().default(""),
|
|
684
937
|
// Browser origin when the web app and API use separate origins in local
|
|
685
938
|
// development. Production normally leaves this unset and uses publicBaseUrl.
|
|
686
|
-
webBaseUrl:
|
|
939
|
+
webBaseUrl: z5.string().url().optional(),
|
|
687
940
|
// Base URL for the bring-your-own-compute agent release assets the get.<domain>
|
|
688
941
|
// install routes redirect to. Defaults to this repo's GitHub Releases. The route
|
|
689
942
|
// appends `/download/agent-v<ver>/<asset>`.
|
|
690
|
-
agentReleasesBaseUrl:
|
|
943
|
+
agentReleasesBaseUrl: z5.string().url().default("https://github.com/Cloudgeni-ai/opengeni/releases"),
|
|
691
944
|
// Explicit operator-controlled promotion pointer for `/agent/latest/*`.
|
|
692
945
|
// Versioned agent releases are immutable; changing this setting promotes or
|
|
693
946
|
// rolls back the stable channel without moving or deleting a provider tag.
|
|
694
|
-
agentStableVersion:
|
|
947
|
+
agentStableVersion: z5.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).default("0.1.16"),
|
|
695
948
|
// Optional independent beta-channel pointer. When unset, the beta update
|
|
696
949
|
// manifest route is unavailable rather than silently serving stable.
|
|
697
|
-
agentBetaVersion:
|
|
950
|
+
agentBetaVersion: z5.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).optional(),
|
|
698
951
|
productAccessMode: ProductAccessMode.default("local"),
|
|
699
952
|
billingMode: BillingMode.default("disabled"),
|
|
700
953
|
// Explicit launch gate for the one-time $10 verified self-service signup grant.
|
|
@@ -706,17 +959,22 @@ var SettingsSchema = z3.object({
|
|
|
706
959
|
// Gate new allowance policies until every API/worker in the fleet enforces
|
|
707
960
|
// them. Persisted-policy enforcement and recovery reads/clears stay active.
|
|
708
961
|
usageAllowancesEnabled: EnvBoolean.default(false),
|
|
709
|
-
staticEntitlementsJson:
|
|
710
|
-
staticUsageLimitsJson:
|
|
711
|
-
delegationSecret:
|
|
962
|
+
staticEntitlementsJson: z5.string().default("{}"),
|
|
963
|
+
staticUsageLimitsJson: z5.string().default("{}"),
|
|
964
|
+
delegationSecret: z5.string().optional(),
|
|
712
965
|
defaultFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
713
966
|
allowedFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
967
|
+
// Deployment fact: the isolated artifact materializer workload runs and
|
|
968
|
+
// drains export jobs. Without it an export is queued forever, so the export
|
|
969
|
+
// tools leave the first-party ceiling. Helm sets this from
|
|
970
|
+
// artifactMaterializer.enabled.
|
|
971
|
+
artifactMaterializerDeployed: EnvBoolean.default(false),
|
|
714
972
|
// sandbox workspace scoped stream-token HMAC secret (sandbox contract §C.3 / stream-token availability contract).
|
|
715
973
|
// When unset, the API falls back to `delegationSecret` (the same HMAC envelope
|
|
716
974
|
// family, `ogs_` vs `ogd_` prefix). REQUIRED-WHEN-DESKTOP, but the absence of
|
|
717
975
|
// BOTH while sandboxDesktopEnabled=true is a GRACEFUL DEGRADE (DesktopStream
|
|
718
976
|
// transport:null + a loud boot warning), NOT a hard boot-fail (stream-token availability contract).
|
|
719
|
-
streamTokenSecret:
|
|
977
|
+
streamTokenSecret: z5.string().optional(),
|
|
720
978
|
// The desktop input plane (raw stream:control writes) is OFF in v1: even a
|
|
721
979
|
// holder of stream:control gets 403 until this flips. Keeps stream:control a
|
|
722
980
|
// declared-but-inert permission so later hardening is a flag flip.
|
|
@@ -739,51 +997,51 @@ var SettingsSchema = z3.object({
|
|
|
739
997
|
// Optional release-coherent bootstrap hint for custom rigs/connected machines
|
|
740
998
|
// that do not carry the stock-image ogtool binary. Exact stable versions only:
|
|
741
999
|
// the agent must never guess a tag or silently install `latest`.
|
|
742
|
-
ogtoolPackageSpec:
|
|
743
|
-
environmentsEncryptionKey:
|
|
1000
|
+
ogtoolPackageSpec: z5.string().regex(/^@opengeni\/ogtool@(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).optional(),
|
|
1001
|
+
environmentsEncryptionKey: z5.string().optional(),
|
|
744
1002
|
integrationsEnabled: EnvBoolean.default(false),
|
|
745
|
-
integrationsStateSecret:
|
|
1003
|
+
integrationsStateSecret: z5.string().optional(),
|
|
746
1004
|
integrationsOauthShortStateEnabled: EnvBoolean.default(false),
|
|
747
1005
|
integrationsAllowPrivateNetworkTargets: EnvBoolean.default(false),
|
|
748
|
-
integrationsOauthClientsJson:
|
|
749
|
-
gmailWatchTopicName:
|
|
750
|
-
slackClientId:
|
|
751
|
-
slackClientSecret:
|
|
752
|
-
slackSigningSecret:
|
|
1006
|
+
integrationsOauthClientsJson: z5.string().default("{}"),
|
|
1007
|
+
gmailWatchTopicName: z5.string().regex(/^projects\/[^/]+\/topics\/[^/]+$/u).optional(),
|
|
1008
|
+
slackClientId: z5.string().optional(),
|
|
1009
|
+
slackClientSecret: z5.string().optional(),
|
|
1010
|
+
slackSigningSecret: z5.string().optional(),
|
|
753
1011
|
// Unlisted apps share Slack’s restricted history/replies quota across all tokens.
|
|
754
|
-
slackAccessMode:
|
|
1012
|
+
slackAccessMode: z5.enum(["limited", "full"]).default("limited"),
|
|
755
1013
|
slackBotDisplayName: OpenGeniSlackBotDisplayName.default("OpenGeni"),
|
|
756
|
-
slackCommand:
|
|
757
|
-
googleDriveClientId:
|
|
758
|
-
googleDriveClientSecret:
|
|
759
|
-
googleDriveSyncMaxItems:
|
|
760
|
-
googleDriveSyncMaxBytes:
|
|
761
|
-
googleDriveSyncMaxFileBytes:
|
|
762
|
-
googleDriveSyncMaxProviderRequests:
|
|
763
|
-
googleDriveSyncMaxElapsedSeconds:
|
|
764
|
-
googleDriveSyncMaxFailureDetails:
|
|
765
|
-
googleDriveProviderRequestTimeoutMs:
|
|
766
|
-
googleDriveProviderRetryAttempts:
|
|
767
|
-
googleDriveProviderRetryInitialDelayMs:
|
|
768
|
-
googleDriveProviderRetryMaxDelayMs:
|
|
769
|
-
googleDriveProviderRetryBudgetMs:
|
|
770
|
-
fikenClientId:
|
|
771
|
-
fikenClientSecret:
|
|
1014
|
+
slackCommand: z5.string().trim().regex(/^\/[a-z0-9_-]{1,31}$/u).default("/opengeni"),
|
|
1015
|
+
googleDriveClientId: z5.string().optional(),
|
|
1016
|
+
googleDriveClientSecret: z5.string().optional(),
|
|
1017
|
+
googleDriveSyncMaxItems: z5.coerce.number().int().positive().max(1e4).default(500),
|
|
1018
|
+
googleDriveSyncMaxBytes: z5.coerce.number().int().positive().max(5e9).default(5e8),
|
|
1019
|
+
googleDriveSyncMaxFileBytes: z5.coerce.number().int().positive().max(5e9).default(1e8),
|
|
1020
|
+
googleDriveSyncMaxProviderRequests: z5.coerce.number().int().positive().max(1e4).default(1e3),
|
|
1021
|
+
googleDriveSyncMaxElapsedSeconds: z5.coerce.number().int().positive().max(3600).default(300),
|
|
1022
|
+
googleDriveSyncMaxFailureDetails: z5.coerce.number().int().positive().max(100).default(25),
|
|
1023
|
+
googleDriveProviderRequestTimeoutMs: z5.coerce.number().int().min(1e3).max(GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS).default(3e4),
|
|
1024
|
+
googleDriveProviderRetryAttempts: z5.coerce.number().int().min(1).max(5).default(3),
|
|
1025
|
+
googleDriveProviderRetryInitialDelayMs: z5.coerce.number().int().positive().max(3e4).default(250),
|
|
1026
|
+
googleDriveProviderRetryMaxDelayMs: z5.coerce.number().int().positive().max(GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS).default(5e3),
|
|
1027
|
+
googleDriveProviderRetryBudgetMs: z5.coerce.number().int().positive().max(12e4).default(15e3),
|
|
1028
|
+
fikenClientId: z5.string().optional(),
|
|
1029
|
+
fikenClientSecret: z5.string().optional(),
|
|
772
1030
|
googleDriveWorkspaceEventsEnabled: EnvBoolean.optional(),
|
|
773
|
-
atlassianClientId:
|
|
774
|
-
atlassianClientSecret:
|
|
1031
|
+
atlassianClientId: z5.string().optional(),
|
|
1032
|
+
atlassianClientSecret: z5.string().optional(),
|
|
775
1033
|
// Undefined is meaningful: the migration boundary persists the product
|
|
776
1034
|
// default of 3 when no deployment override is supplied.
|
|
777
|
-
maxNestedAgentDepth:
|
|
1035
|
+
maxNestedAgentDepth: z5.coerce.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH).optional(),
|
|
778
1036
|
// Operator OAuth apps for first-party social connectors, keyed by provider
|
|
779
1037
|
// id ("x", "reddit"): {"x":{"clientId":"...","clientSecret":"..."}}.
|
|
780
|
-
socialOauthClientsJson:
|
|
1038
|
+
socialOauthClientsJson: z5.string().default("{}"),
|
|
781
1039
|
// Session goal guard rails. Goals are designed for runs that legitimately
|
|
782
1040
|
// span days, so length is bounded by explicit completion/pause and budget
|
|
783
1041
|
// exhaustion, never by count. goalMaxAutoContinuations is therefore UNSET
|
|
784
1042
|
// by default (no cap); deployments may configure one, and it then acts as a
|
|
785
1043
|
// hard ceiling that per-goal overrides can only lower.
|
|
786
|
-
goalMaxAutoContinuations:
|
|
1044
|
+
goalMaxAutoContinuations: z5.coerce.number().int().positive().optional(),
|
|
787
1045
|
// Idle backoff between CONSECUTIVE no-input goal continuations. This is
|
|
788
1046
|
// pacing, not a cap: the first continuation after a turn that consumed any
|
|
789
1047
|
// external input is immediate, the n-th consecutive no-input continuation
|
|
@@ -791,7 +1049,7 @@ var SettingsSchema = z3.object({
|
|
|
791
1049
|
// any new input (machine input, human/API prompt, Steer) wakes the session
|
|
792
1050
|
// immediately. The delay never exceeds goalIdleBackoffMaxMs.
|
|
793
1051
|
goalIdleBackoffMs: EnvGoalIdleBackoffMs.default(DEFAULT_GOAL_IDLE_BACKOFF_MS),
|
|
794
|
-
goalIdleBackoffMaxMs:
|
|
1052
|
+
goalIdleBackoffMaxMs: z5.coerce.number().int().positive().default(DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS),
|
|
795
1053
|
// Child lifecycle notices: a child session's requires_action freeze, its
|
|
796
1054
|
// resolution, a direct Pause, a provider-capacity wait, and goal progress
|
|
797
1055
|
// become typed `session_system_updates` rows for the parent (in addition to
|
|
@@ -819,17 +1077,17 @@ var SettingsSchema = z3.object({
|
|
|
819
1077
|
// session turn. Effectively unbounded by default for the same reason as
|
|
820
1078
|
// above; the graceful max-turns valve (idle + goal continuation, never a
|
|
821
1079
|
// session failure) remains as inert safety should a deployment set a cap.
|
|
822
|
-
agentMaxModelCallsPerTurn:
|
|
1080
|
+
agentMaxModelCallsPerTurn: z5.coerce.number().int().positive().default(1e6),
|
|
823
1081
|
// Deployment fallback for models that do not declare their own window.
|
|
824
1082
|
// Built-in billed GPT-5.6 Sol/Terra/Luna pin Codex's 272k catalog instead.
|
|
825
1083
|
// OpenGeni always performs one durable, portable plaintext compaction
|
|
826
1084
|
// transition; there is no provider/server/off mode ladder.
|
|
827
|
-
contextWindowTokens:
|
|
1085
|
+
contextWindowTokens: z5.coerce.number().int().positive().default(105e4),
|
|
828
1086
|
// Optional model-catalog effective input ceiling. Codex and billed GPT-5.6
|
|
829
1087
|
// models expose this as raw context_window * effective_context_window_percent;
|
|
830
1088
|
// when absent, retain the deployment-level window-minus-reserved-output
|
|
831
1089
|
// behavior.
|
|
832
|
-
contextEffectiveWindowTokens:
|
|
1090
|
+
contextEffectiveWindowTokens: z5.coerce.number().int().positive().optional(),
|
|
833
1091
|
// Proactive compaction threshold as a ratio of the model context window.
|
|
834
1092
|
// Defaults to 90%: compact as late as possible — retained context beats early
|
|
835
1093
|
// headroom now that per-model windows are declared honestly (input-effective,
|
|
@@ -837,7 +1095,7 @@ var SettingsSchema = z3.object({
|
|
|
837
1095
|
// absorbs any overshoot as one retried call rather than a dead session.
|
|
838
1096
|
// Clamped to [0.3, 0.9] so deployments can tune the trigger without
|
|
839
1097
|
// accidentally disabling compaction.
|
|
840
|
-
contextCompactionThresholdRatio:
|
|
1098
|
+
contextCompactionThresholdRatio: z5.coerce.number().default(0.9).transform((value) => {
|
|
841
1099
|
if (!Number.isFinite(value)) {
|
|
842
1100
|
return 0.9;
|
|
843
1101
|
}
|
|
@@ -845,127 +1103,156 @@ var SettingsSchema = z3.object({
|
|
|
845
1103
|
}),
|
|
846
1104
|
// Tokens reserved for model output; subtracted from the window to get the
|
|
847
1105
|
// usable input budget B = contextWindowTokens - contextReservedOutputTokens.
|
|
848
|
-
contextReservedOutputTokens:
|
|
1106
|
+
contextReservedOutputTokens: z5.coerce.number().int().nonnegative().default(128e3),
|
|
849
1107
|
// Model-catalog auto-compact limit. When present it is clamped to
|
|
850
1108
|
// 90% of the raw window, matching Codex core's auto_compact_token_limit().
|
|
851
|
-
contextAutoCompactThresholdTokens:
|
|
1109
|
+
contextAutoCompactThresholdTokens: z5.coerce.number().int().positive().optional(),
|
|
852
1110
|
// Provider-neutral fallback for canonical model-facing tool-result text.
|
|
853
1111
|
// The current stable Codex catalog policy is 10k tokens; the truncator adds
|
|
854
1112
|
// Codex's 1.2x JSON serialization allowance when applying it.
|
|
855
|
-
modelToolOutputTruncationTokens:
|
|
1113
|
+
modelToolOutputTruncationTokens: z5.coerce.number().int().positive().default(1e4),
|
|
856
1114
|
authRequired: EnvBoolean.default(false),
|
|
857
|
-
accessKey:
|
|
1115
|
+
accessKey: z5.string().optional(),
|
|
858
1116
|
authAllowHealth: EnvBoolean.default(true),
|
|
859
1117
|
authAllowMetrics: EnvBoolean.default(false),
|
|
860
|
-
apiHost:
|
|
861
|
-
apiPort:
|
|
1118
|
+
apiHost: z5.string().default("0.0.0.0"),
|
|
1119
|
+
apiPort: z5.coerce.number().int().positive().default(8e3),
|
|
862
1120
|
// When set, GET /metrics is served only on this dedicated internal listener
|
|
863
1121
|
// and never on the public API port that an ingress forwards to.
|
|
864
|
-
apiMetricsPort:
|
|
865
|
-
workerHttpPort:
|
|
1122
|
+
apiMetricsPort: z5.coerce.number().int().positive().optional(),
|
|
1123
|
+
workerHttpPort: z5.coerce.number().int().positive().default(8001),
|
|
866
1124
|
// Worker-side first-party MCP traffic stays on the deployment's internal
|
|
867
1125
|
// network. OPENGENI_MCP_URL remains the sandbox/external route used by
|
|
868
1126
|
// Codemode and remote placements.
|
|
869
|
-
opengeniMcpInternalUrl:
|
|
870
|
-
opengeniMcpUrl:
|
|
1127
|
+
opengeniMcpInternalUrl: z5.string().url().optional(),
|
|
1128
|
+
opengeniMcpUrl: z5.string().url().optional(),
|
|
871
1129
|
// Origins allowed to send browser cookies cross-origin. Other origins may
|
|
872
1130
|
// call the public API with bearer credentials, but never receive credentialed
|
|
873
1131
|
// CORS responses.
|
|
874
|
-
corsAllowOriginRegex:
|
|
1132
|
+
corsAllowOriginRegex: z5.string().default(String.raw`^https?://(localhost|127\.0\.0\.1)(:\d+)?$`),
|
|
875
1133
|
// Local development only (`local` access mode in the `local` environment):
|
|
876
1134
|
// extra exact browser origins, comma-separated, that may call the
|
|
877
1135
|
// unauthenticated API besides this stack's own web origin. The local browser
|
|
878
1136
|
// boundary ignores `corsAllowOriginRegex`.
|
|
879
|
-
localAllowedOrigins:
|
|
880
|
-
openaiProvider:
|
|
881
|
-
openaiApiKey:
|
|
882
|
-
openaiBaseUrl:
|
|
883
|
-
openaiModel:
|
|
884
|
-
openaiAllowedModels:
|
|
1137
|
+
localAllowedOrigins: z5.string().optional(),
|
|
1138
|
+
openaiProvider: z5.enum(["openai", "azure"]).default("openai"),
|
|
1139
|
+
openaiApiKey: z5.string().optional(),
|
|
1140
|
+
openaiBaseUrl: z5.string().optional(),
|
|
1141
|
+
openaiModel: z5.string().default("gpt-6-astra"),
|
|
1142
|
+
openaiAllowedModels: z5.string().default("gpt-6-astra,gpt-6-sol,gpt-6-luna"),
|
|
885
1143
|
// OpenGeni-managed Vercel AI Gateway. When configured, the two reviewed
|
|
886
1144
|
// Gateway models below are added to the managed-credit catalog. Workspace
|
|
887
1145
|
// Gateway keys use the encrypted connection broker and never this secret.
|
|
888
|
-
vercelAiGatewayApiKey:
|
|
1146
|
+
vercelAiGatewayApiKey: z5.string().optional(),
|
|
889
1147
|
/** Image adapter route; native hosted providers ignore this model. */
|
|
890
|
-
imageGenerationModel:
|
|
1148
|
+
imageGenerationModel: z5.string().trim().min(1).max(256).default("openai/gpt-image-2"),
|
|
891
1149
|
/** Durable video generation uses the workspace-owned Gateway credential. */
|
|
892
|
-
videoGenerationPollIntervalMs:
|
|
893
|
-
videoGenerationRecoveryDeadlineMs:
|
|
894
|
-
videoGenerationReferenceUrlTtlSeconds:
|
|
895
|
-
videoGenerationMaxConcurrentPerWorkspace:
|
|
896
|
-
videoGenerationWorkspaceQuotaBytes:
|
|
897
|
-
videoGenerationTempDirectory:
|
|
898
|
-
videoGenerationFfprobePath:
|
|
1150
|
+
videoGenerationPollIntervalMs: z5.coerce.number().int().min(1e3).max(6e4).default(5e3),
|
|
1151
|
+
videoGenerationRecoveryDeadlineMs: z5.coerce.number().int().min(6e4).max(24 * 60 * 6e4).default(2 * 60 * 6e4),
|
|
1152
|
+
videoGenerationReferenceUrlTtlSeconds: z5.coerce.number().int().min(300).max(6 * 60 * 60).default(60 * 60),
|
|
1153
|
+
videoGenerationMaxConcurrentPerWorkspace: z5.coerce.number().int().min(1).max(16).default(2),
|
|
1154
|
+
videoGenerationWorkspaceQuotaBytes: z5.coerce.number().int().positive().max(Number.MAX_SAFE_INTEGER).default(20 * 1024 * 1024 * 1024),
|
|
1155
|
+
videoGenerationTempDirectory: z5.string().trim().min(1).max(1024).default("/tmp/opengeni-video"),
|
|
1156
|
+
videoGenerationFfprobePath: z5.string().trim().min(1).max(1024).default("ffprobe"),
|
|
899
1157
|
// OpenGeni's customer price, not a claim about the provider's delayed cost report.
|
|
900
1158
|
// The durable operation freezes the exact resulting price before provider submit.
|
|
901
|
-
videoGenerationCredit480pMicrosPerSecond:
|
|
902
|
-
videoGenerationCredit720pMicrosPerSecond:
|
|
1159
|
+
videoGenerationCredit480pMicrosPerSecond: z5.coerce.number().int().positive().max(1e7).default(155e3),
|
|
1160
|
+
videoGenerationCredit720pMicrosPerSecond: z5.coerce.number().int().positive().max(1e7).default(35e4),
|
|
903
1161
|
// Native composer voice input (browser MediaRecorder → API transcription).
|
|
904
1162
|
// Provider credentials stay server-side; ClientConfig only projects availability
|
|
905
1163
|
// and hard ceilings. Selection happens once before audio is sent — never retry
|
|
906
1164
|
// the same clip across vendors after an upstream request may have started.
|
|
907
|
-
voiceInputMaxDurationSeconds:
|
|
908
|
-
voiceInputMaxSizeBytes:
|
|
1165
|
+
voiceInputMaxDurationSeconds: z5.coerce.number().int().positive().max(600).default(60),
|
|
1166
|
+
voiceInputMaxSizeBytes: z5.coerce.number().int().positive().max(25 * 1024 * 1024).default(25 * 1024 * 1024),
|
|
909
1167
|
// Durable long-form capture uploads bounded chunks to object storage, then
|
|
910
1168
|
// normalizes them into provider-safe segments. It is advertised only when
|
|
911
1169
|
// object storage and the configured ffmpeg executable are both available.
|
|
912
1170
|
voiceInputResumableEnabled: EnvBoolean.default(true),
|
|
913
|
-
voiceInputResumableMaxDurationSeconds:
|
|
914
|
-
voiceInputResumableMaxSizeBytes:
|
|
915
|
-
voiceInputResumableMaxChunkSizeBytes:
|
|
916
|
-
voiceInputResumableRetentionSeconds:
|
|
917
|
-
voiceInputFfmpegPath:
|
|
1171
|
+
voiceInputResumableMaxDurationSeconds: z5.coerce.number().int().positive().max(8 * 60 * 60).default(2 * 60 * 60),
|
|
1172
|
+
voiceInputResumableMaxSizeBytes: z5.coerce.number().int().positive().max(512 * 1024 * 1024).default(512 * 1024 * 1024),
|
|
1173
|
+
voiceInputResumableMaxChunkSizeBytes: z5.coerce.number().int().positive().max(25 * 1024 * 1024).default(8 * 1024 * 1024),
|
|
1174
|
+
voiceInputResumableRetentionSeconds: z5.coerce.number().int().positive().max(7 * 24 * 60 * 60).default(24 * 60 * 60),
|
|
1175
|
+
voiceInputFfmpegPath: z5.string().trim().min(1).max(1024).default("ffmpeg"),
|
|
918
1176
|
// Preferred provider order (comma-separated ids). First configured+ready wins.
|
|
919
1177
|
// Connected subscription STT is preferred by default; operators can put
|
|
920
1178
|
// openai/azure-openai first explicitly.
|
|
921
1179
|
// Supported: supergrok-subscription, codex-subscription, openai, azure-openai.
|
|
922
|
-
voiceInputProviderOrder:
|
|
1180
|
+
voiceInputProviderOrder: z5.string().default("supergrok-subscription,codex-subscription,openai,azure-openai"),
|
|
923
1181
|
// OpenAI public /v1/audio/transcriptions path. Reuses OPENGENI_OPENAI_API_KEY
|
|
924
1182
|
// when voiceInputOpenaiApiKey is unset. Default model is gpt-transcribe.
|
|
925
1183
|
voiceInputOpenaiEnabled: EnvBoolean.default(true),
|
|
926
|
-
voiceInputOpenaiApiKey:
|
|
927
|
-
voiceInputOpenaiBaseUrl:
|
|
928
|
-
voiceInputOpenaiModel:
|
|
1184
|
+
voiceInputOpenaiApiKey: z5.string().optional(),
|
|
1185
|
+
voiceInputOpenaiBaseUrl: z5.string().optional(),
|
|
1186
|
+
voiceInputOpenaiModel: z5.string().default("gpt-transcribe"),
|
|
929
1187
|
// Azure OpenAI deployment-scoped audio transcriptions. Reuses the turn-model
|
|
930
1188
|
// Azure endpoint/key/AD token when voice-specific overrides are unset.
|
|
931
1189
|
voiceInputAzureEnabled: EnvBoolean.default(true),
|
|
932
|
-
voiceInputAzureEndpoint:
|
|
933
|
-
voiceInputAzureDeployment:
|
|
934
|
-
voiceInputAzureApiVersion:
|
|
935
|
-
voiceInputAzureApiKey:
|
|
936
|
-
voiceInputAzureAdToken:
|
|
1190
|
+
voiceInputAzureEndpoint: z5.string().optional(),
|
|
1191
|
+
voiceInputAzureDeployment: z5.string().optional(),
|
|
1192
|
+
voiceInputAzureApiVersion: z5.string().optional(),
|
|
1193
|
+
voiceInputAzureApiKey: z5.string().optional(),
|
|
1194
|
+
voiceInputAzureAdToken: z5.string().optional(),
|
|
1195
|
+
// Hosted realtime voice is configured independently of dictation.
|
|
1196
|
+
azureLiveEndpoint: z5.string().url().optional(),
|
|
1197
|
+
azureLiveApiKey: z5.string().optional(),
|
|
1198
|
+
azureLiveDeployment: z5.string().default("gpt-live-1"),
|
|
1199
|
+
azureLiveVoice: z5.string().default("marin"),
|
|
1200
|
+
// Credit price of deployment-funded live voice (RealtimeVoicePricing JSON).
|
|
1201
|
+
// Required while credit billing is active, otherwise the model is withheld.
|
|
1202
|
+
azureLivePricingJson: z5.string().optional(),
|
|
1203
|
+
// Managed AI Gateway live voice prices keyed by upstream model id.
|
|
1204
|
+
aiGatewayRealtimePricingJson: z5.string().optional(),
|
|
1205
|
+
// Azure Speech credentials are explicit: a different resource can host MAI.
|
|
1206
|
+
voiceInputMaiEndpoint: z5.string().url().optional(),
|
|
1207
|
+
voiceInputMaiApiKey: z5.string().optional(),
|
|
1208
|
+
voiceInputMaiApiVersion: z5.string().default("2025-10-15"),
|
|
1209
|
+
voiceInputMaiPricingJson: z5.string().optional(),
|
|
1210
|
+
voiceInputMaiModel: z5.string().default("MAI-Transcribe-2"),
|
|
1211
|
+
// Underlying model of the Azure deployment (for example gpt-4o-transcribe or
|
|
1212
|
+
// whisper). Azure routes by deployment name, so this only selects built-in
|
|
1213
|
+
// pricing and the provider-reported usage shape (Whisper requests
|
|
1214
|
+
// verbose_json so Azure reports the billed audio duration). Defaults to the
|
|
1215
|
+
// deployment name.
|
|
1216
|
+
voiceInputAzureModel: z5.string().trim().min(1).max(256).optional(),
|
|
1217
|
+
// Opengeni credit pricing for deployment-funded voice input (`openai`,
|
|
1218
|
+
// `azure-openai`). JSON VoiceInputPricing; overrides the built-in list price
|
|
1219
|
+
// for the configured model. Validated at boot. When credit billing is active
|
|
1220
|
+
// (OPENGENI_BILLING_MODE=stripe or OPENGENI_USAGE_LIMITS_MODE=managed) a
|
|
1221
|
+
// deployment-funded provider without any pricing is not offered at all.
|
|
1222
|
+
voiceInputOpenaiPricingJson: z5.string().optional(),
|
|
1223
|
+
voiceInputAzurePricingJson: z5.string().optional(),
|
|
937
1224
|
// Legacy opt-in for undocumented ChatGPT /backend-api/transcribe. When
|
|
938
1225
|
// OPENGENI_CODEX_SUBSCRIPTION_ENABLED is true, Codex STT is included without
|
|
939
1226
|
// this flag. Set false and omit codex-subscription from PROVIDER_ORDER to
|
|
940
1227
|
// keep subscription model routing while disabling Codex voice input.
|
|
941
1228
|
voiceInputCodexExperimentalEnabled: EnvBoolean.default(false),
|
|
942
|
-
modelPricingJson:
|
|
1229
|
+
modelPricingJson: z5.string().default("{}"),
|
|
943
1230
|
// Supported-model membership source. Database mode is resolved by the async
|
|
944
1231
|
// core overlay; getSettings remains synchronous and env-only.
|
|
945
|
-
modelCatalogSource:
|
|
1232
|
+
modelCatalogSource: z5.enum(["code", "database"]).default("code"),
|
|
946
1233
|
// Deployment-owned workspace-facing price policy. This is deliberately
|
|
947
1234
|
// separate from catalog membership and upstream credential ownership.
|
|
948
1235
|
// Shape: { "product/model-id": "free" | "credits" }.
|
|
949
|
-
modelCostPolicyJson:
|
|
1236
|
+
modelCostPolicyJson: z5.string().default("{}"),
|
|
950
1237
|
// Optional per-product agent guidance. Database mode replaces this with the
|
|
951
1238
|
// singleton document's validated modelNotes map.
|
|
952
|
-
modelNotesJson:
|
|
1239
|
+
modelNotesJson: z5.string().default("{}"),
|
|
953
1240
|
// Managed OpenRouter credential. The curated model table is injected in
|
|
954
1241
|
// code/catalog-document resolution and never read from host provider JSON.
|
|
955
|
-
openrouterApiKey:
|
|
1242
|
+
openrouterApiKey: z5.string().optional(),
|
|
956
1243
|
// Internal, secret-free catalog overlays populated only by
|
|
957
1244
|
// applyModelCatalogDocument. They intentionally have no OPENGENI_* env
|
|
958
1245
|
// binding so database mode cannot be bypassed with a second source.
|
|
959
|
-
resolvedGatewayModelsJson:
|
|
960
|
-
resolvedOpenRouterModelsJson:
|
|
961
|
-
resolvedCodexModelsJson:
|
|
1246
|
+
resolvedGatewayModelsJson: z5.string().optional(),
|
|
1247
|
+
resolvedOpenRouterModelsJson: z5.string().optional(),
|
|
1248
|
+
resolvedCodexModelsJson: z5.string().optional(),
|
|
962
1249
|
// Extra (non-built-in) model providers, declared by the host as a JSON
|
|
963
1250
|
// provider registry. Each entry carries its own base URL, API key, wire API
|
|
964
1251
|
// ("responses" | "chat") and the models it exposes. The models a client may
|
|
965
1252
|
// use are the UNION of the built-in provider's allowed models and every
|
|
966
1253
|
// registry provider's models. validateSettings parses this at boot so a
|
|
967
1254
|
// malformed registry / unresolvable key / id collision fails fast.
|
|
968
|
-
modelProvidersJson:
|
|
1255
|
+
modelProvidersJson: z5.string().default("[]"),
|
|
969
1256
|
// Codex (ChatGPT) subscription: when enabled, a per-workspace connected
|
|
970
1257
|
// subscription is injected as a synthetic "codex-subscription" registry
|
|
971
1258
|
// provider whose models route through the ChatGPT backend (@opengeni/codex).
|
|
@@ -979,13 +1266,13 @@ var SettingsSchema = z3.object({
|
|
|
979
1266
|
// OPENGENI_CLAUDE_SUBSCRIPTION_ENABLED
|
|
980
1267
|
// Maximum silence between complete, valid SuperGrok SSE data events. This is
|
|
981
1268
|
// not a request/run duration cap; every valid event resets the timer.
|
|
982
|
-
supergrokResponseStreamIdleTimeoutMs:
|
|
1269
|
+
supergrokResponseStreamIdleTimeoutMs: z5.coerce.number().int().positive().max(24 * 60 * 6e4).default(XAI_RESPONSE_STREAM_IDLE_TIMEOUT_MS),
|
|
983
1270
|
// Expose the connected apps attached to a Codex subscription through the
|
|
984
1271
|
// synthetic codex_apps MCP server. Independent from subscription routing so
|
|
985
1272
|
// operators can use Codex models without exposing ChatGPT connectors.
|
|
986
1273
|
codexConnectedAppsEnabled: EnvBoolean.default(false),
|
|
987
1274
|
// OPENGENI_CODEX_CONNECTED_APPS_ENABLED
|
|
988
|
-
codexProductSku:
|
|
1275
|
+
codexProductSku: z5.string().optional(),
|
|
989
1276
|
// OPENGENI_CODEX_PRODUCT_SKU (X-OpenAI-Product-Sku, apps only)
|
|
990
1277
|
// Progressive MCP disclosure (Codex-CLI-style tool_search): on a codex turn,
|
|
991
1278
|
// flag non-eager selected MCP tools `defer_loading:true` (dropping their
|
|
@@ -1009,23 +1296,23 @@ var SettingsSchema = z3.object({
|
|
|
1009
1296
|
// Multi-account P3 (auto-rotation): an account is "near exhaustion" — ineligible to be
|
|
1010
1297
|
// rotated TO — when EITHER usage window (5h/weekly) is at/over this percent. Default 90 to
|
|
1011
1298
|
// match the UI danger flip (UsageBar danger at pct >= 90). OPENGENI_CODEX_ROTATION_NEAR_EXHAUSTION_PCT.
|
|
1012
|
-
codexRotationNearExhaustionPct:
|
|
1299
|
+
codexRotationNearExhaustionPct: z5.coerce.number().int().min(1).max(100).default(90),
|
|
1013
1300
|
reasoningConfigurationUpdatesEnabled: EnvBoolean.default(false),
|
|
1014
1301
|
openaiReasoningEffort: ReasoningEffort.default("low"),
|
|
1015
|
-
openaiAllowedReasoningEfforts:
|
|
1302
|
+
openaiAllowedReasoningEfforts: z5.string().default("low,medium,high,xhigh,max"),
|
|
1016
1303
|
// Default for new chats and scheduled tasks when the workspace has an
|
|
1017
1304
|
// OpenGeni credit balance, no saved workspace default, and no usable
|
|
1018
1305
|
// connected subscription, and the deployment default is not already a
|
|
1019
1306
|
// credits-billed model. Selected only when this model is selectable in the
|
|
1020
1307
|
// workspace catalog; otherwise the first selectable credits model is used.
|
|
1021
1308
|
// OPENGENI_CREDITS_DEFAULT_MODEL / OPENGENI_CREDITS_DEFAULT_REASONING_EFFORT.
|
|
1022
|
-
creditsDefaultModel:
|
|
1309
|
+
creditsDefaultModel: z5.string().trim().min(1).max(256).refine((value) => !/[\u000A\u000D|]/u.test(value), {
|
|
1023
1310
|
message: "credits default model must not contain newlines or the | field separator"
|
|
1024
1311
|
}).default("gpt-6-luna"),
|
|
1025
1312
|
// Preferred effort for the credits default. Clamped to the highest effort
|
|
1026
1313
|
// the selected model supports at or below this value.
|
|
1027
1314
|
creditsDefaultReasoningEffort: ReasoningEffort.default("xhigh"),
|
|
1028
|
-
openaiResponsesTransport:
|
|
1315
|
+
openaiResponsesTransport: z5.enum(["http", "websocket"]).default("http"),
|
|
1029
1316
|
// Provider-assigned item ids (rs_/msg_/fc_…) in Responses API input are
|
|
1030
1317
|
// resolved against the provider's server-side response store. That store is
|
|
1031
1318
|
// not durable enough to anchor long runs on: a response that streamed fine
|
|
@@ -1034,7 +1321,7 @@ var SettingsSchema = z3.object({
|
|
|
1034
1321
|
// every model-call input so requests are self-contained — conversation
|
|
1035
1322
|
// truth already lives client-side in session_history_items. "preserve"
|
|
1036
1323
|
// keeps the SDK's pass-through behavior.
|
|
1037
|
-
openaiProviderItemIds:
|
|
1324
|
+
openaiProviderItemIds: z5.enum(["strip", "preserve"]).default("strip"),
|
|
1038
1325
|
// With ids stripped the provider cannot resolve prior reasoning server-side,
|
|
1039
1326
|
// so request reasoning.encrypted_content and send it back with each call:
|
|
1040
1327
|
// reasoning continuity without depending on provider-side storage.
|
|
@@ -1042,7 +1329,7 @@ var SettingsSchema = z3.object({
|
|
|
1042
1329
|
// Model-call retry budget for transient provider failures (429s and friends).
|
|
1043
1330
|
// The openai client default of 2 retries is too small for sustained TPM
|
|
1044
1331
|
// backpressure during long autonomous runs.
|
|
1045
|
-
openaiMaxRetries:
|
|
1332
|
+
openaiMaxRetries: z5.coerce.number().int().nonnegative().default(5),
|
|
1046
1333
|
// Native hosted web search. The live Azure Responses path executes the
|
|
1047
1334
|
// hosted web_search tool, so this is provider-unconditional: ON by default
|
|
1048
1335
|
// on every provider, exposed only so operators can disable it. When true,
|
|
@@ -1050,19 +1337,31 @@ var SettingsSchema = z3.object({
|
|
|
1050
1337
|
// merged with the MCP-server tools (getAllTools = [...mcpTools, ...tools])
|
|
1051
1338
|
// and the sandbox capability tools, never replacing them.
|
|
1052
1339
|
webSearchEnabled: EnvBoolean.default(true),
|
|
1340
|
+
// Provider-agnostic web search (`web_search` / `web_fetch` agent tools,
|
|
1341
|
+
// see ./web-search.ts). Inert until a provider is named; validated lazily so
|
|
1342
|
+
// a misconfiguration withholds the tools instead of failing boot.
|
|
1343
|
+
webSearchProvider: z5.string().optional(),
|
|
1344
|
+
webSearchApiKey: z5.string().optional(),
|
|
1345
|
+
webSearchBaseUrl: z5.string().optional(),
|
|
1346
|
+
webFetchProvider: z5.string().optional(),
|
|
1347
|
+
webFetchApiKey: z5.string().optional(),
|
|
1348
|
+
webFetchBaseUrl: z5.string().optional(),
|
|
1349
|
+
webSearchProviderMode: z5.string().optional(),
|
|
1350
|
+
webSearchPricingJson: z5.string().optional(),
|
|
1351
|
+
webSearchRequestTimeoutMs: z5.coerce.number().int().positive().max(12e4).default(2e4),
|
|
1053
1352
|
// Jev (TypeSafe's fast judge model) for worker-side agent tools. Without a
|
|
1054
1353
|
// usable key every Jev-backed feature is off. The key stays on the server
|
|
1055
1354
|
// (API and worker) and never reaches a sandbox or Connected Machine.
|
|
1056
|
-
jevApiKey:
|
|
1057
|
-
jevBaseUrl:
|
|
1058
|
-
jevModel:
|
|
1059
|
-
jevRequestTimeoutMs:
|
|
1355
|
+
jevApiKey: z5.string().optional(),
|
|
1356
|
+
jevBaseUrl: z5.string().url().default("https://api.typesafe.ai"),
|
|
1357
|
+
jevModel: z5.string().trim().min(1).max(128).default("jev-latest"),
|
|
1358
|
+
jevRequestTimeoutMs: z5.coerce.number().int().positive().max(12e4).default(1e4),
|
|
1060
1359
|
// Jev-backed `code_search` agent tool. `off` never offers it, `opt_in` offers
|
|
1061
1360
|
// it only where workspace settings enable it, `default_on` offers it
|
|
1062
1361
|
// everywhere except workspaces that disable it, and `experiment` gives it to
|
|
1063
1362
|
// a fixed half of sessions in workspaces without their own setting, for
|
|
1064
1363
|
// comparison. It also needs jevApiKey.
|
|
1065
|
-
codeSearchMode:
|
|
1364
|
+
codeSearchMode: z5.enum(["off", "opt_in", "default_on", "experiment"]).default("off"),
|
|
1066
1365
|
// Deployment-default agent persona template (the white-label surface). The
|
|
1067
1366
|
// runtime resolves the effective template per turn as
|
|
1068
1367
|
// per-session-override > per-workspace override > this default, substitutes
|
|
@@ -1070,31 +1369,31 @@ var SettingsSchema = z3.object({
|
|
|
1070
1369
|
// it when the template omits the marker), and uses the result as the agent's
|
|
1071
1370
|
// instructions. Defaulting to DEFAULT_AGENT_INSTRUCTIONS keeps the composed
|
|
1072
1371
|
// default pinned by runtime tests.
|
|
1073
|
-
agentInstructionsTemplate:
|
|
1074
|
-
azureOpenaiBaseUrl:
|
|
1075
|
-
azureOpenaiEndpoint:
|
|
1076
|
-
azureOpenaiDeployment:
|
|
1077
|
-
azureOpenaiApiVersion:
|
|
1078
|
-
azureOpenaiApiKey:
|
|
1079
|
-
azureOpenaiAdToken:
|
|
1372
|
+
agentInstructionsTemplate: z5.string().default(DEFAULT_AGENT_INSTRUCTIONS),
|
|
1373
|
+
azureOpenaiBaseUrl: z5.string().optional(),
|
|
1374
|
+
azureOpenaiEndpoint: z5.string().optional(),
|
|
1375
|
+
azureOpenaiDeployment: z5.string().optional(),
|
|
1376
|
+
azureOpenaiApiVersion: z5.string().optional(),
|
|
1377
|
+
azureOpenaiApiKey: z5.string().optional(),
|
|
1378
|
+
azureOpenaiAdToken: z5.string().optional(),
|
|
1080
1379
|
disableOpenaiTracing: EnvBoolean.default(false),
|
|
1081
1380
|
sandboxBackend: SandboxBackend.default("docker"),
|
|
1082
|
-
dockerImage:
|
|
1381
|
+
dockerImage: z5.string().default("opengeni-sandbox:local"),
|
|
1083
1382
|
// Explicit deployment contract: the configured base sandbox image contains
|
|
1084
1383
|
// the verified, self-contained native artifact runtime at its fixed image
|
|
1085
1384
|
// paths. Disabled by default so arbitrary/custom provider images never make
|
|
1086
1385
|
// document/spreadsheet/presentation skills appear when their runtime is
|
|
1087
1386
|
// when this base-image contract is enabled.
|
|
1088
1387
|
sandboxArtifactRuntimeEnabled: EnvBoolean.default(false),
|
|
1089
|
-
dockerExposedPorts:
|
|
1090
|
-
dockerNetwork:
|
|
1388
|
+
dockerExposedPorts: z5.string().default(""),
|
|
1389
|
+
dockerNetwork: z5.string().optional(),
|
|
1091
1390
|
// When the worker itself runs in a container and talks to a host Docker daemon,
|
|
1092
1391
|
// this directory must be bind-mounted at the exact same absolute path on both
|
|
1093
1392
|
// sides. The Agents SDK materializes the workspace here before bind-mounting it
|
|
1094
1393
|
// into the sandbox container.
|
|
1095
|
-
dockerWorkspaceBaseDir:
|
|
1096
|
-
modalAppName:
|
|
1097
|
-
modalImageRef:
|
|
1394
|
+
dockerWorkspaceBaseDir: z5.string().min(1).optional(),
|
|
1395
|
+
modalAppName: z5.string().default("opengeni-sandbox"),
|
|
1396
|
+
modalImageRef: z5.string().optional(),
|
|
1098
1397
|
// Activate only after descriptor-aware readers, DB fences and the exact
|
|
1099
1398
|
// native image have passed the supervised-command rollout canary.
|
|
1100
1399
|
modalCommandSupervisionEnabled: EnvBoolean.default(false),
|
|
@@ -1103,7 +1402,7 @@ var SettingsSchema = z3.object({
|
|
|
1103
1402
|
// never asks Modal to parse or import the registry ref. The logical ref is
|
|
1104
1403
|
// still persisted on the sandbox lease for provenance and conflict fencing;
|
|
1105
1404
|
// the Modal session envelope persists the actual image ID.
|
|
1106
|
-
modalImageId:
|
|
1405
|
+
modalImageId: z5.string().min(4).max(128).regex(/^im-[A-Za-z0-9]+$/).optional(),
|
|
1107
1406
|
// Name of a Modal Secret (containing REGISTRY_USERNAME + REGISTRY_PASSWORD) used
|
|
1108
1407
|
// to authenticate the pull of `modalImageRef` from a PRIVATE registry. When UNSET
|
|
1109
1408
|
// (the default), the sandbox image is pulled UNAUTHENTICATED — i.e. it must be a
|
|
@@ -1112,7 +1411,7 @@ var SettingsSchema = z3.object({
|
|
|
1112
1411
|
// run a private image (e.g. a cloud-hosted ACR/ECR/GCR digest): the runtime resolves
|
|
1113
1412
|
// the named Secret and builds the image via `fromRegistry(tag, secret)` before the
|
|
1114
1413
|
// first sandbox is created. Knob: OPENGENI_MODAL_IMAGE_REGISTRY_SECRET.
|
|
1115
|
-
modalImageRegistrySecret:
|
|
1414
|
+
modalImageRegistrySecret: z5.string().optional(),
|
|
1116
1415
|
// Modal's hard sandbox lifetime (timeoutMs = this * 1000), counted from box
|
|
1117
1416
|
// creation. A resume-by-id does NOT reset that provider clock. It is the
|
|
1118
1417
|
// BACKSTOP that reclaims a box if the reaper/worker is down, NOT the warm-window
|
|
@@ -1123,17 +1422,17 @@ var SettingsSchema = z3.object({
|
|
|
1123
1422
|
// deadline-aware snapshot/rematerialization transition. The transition—not a
|
|
1124
1423
|
// larger timeout—is what lets a session outlive one finite provider box.
|
|
1125
1424
|
// Knob: OPENGENI_MODAL_TIMEOUT_SECONDS.
|
|
1126
|
-
modalTimeoutSeconds:
|
|
1425
|
+
modalTimeoutSeconds: z5.coerce.number().int().positive().max(86400).default(86400),
|
|
1127
1426
|
// Optional provider reservations for every new Modal sandbox. CPU is measured
|
|
1128
1427
|
// in physical cores and may be fractional; memory is measured in MiB. Leave
|
|
1129
1428
|
// both unset to preserve Modal's provider defaults. The Agents adapter stores
|
|
1130
1429
|
// the resolved values in its session state so snapshot replacement and exact
|
|
1131
1430
|
// resume cannot silently change the reservation.
|
|
1132
|
-
modalSandboxCpu:
|
|
1133
|
-
modalSandboxMemoryMiB:
|
|
1134
|
-
modalTokenId:
|
|
1135
|
-
modalTokenSecret:
|
|
1136
|
-
modalEnvironment:
|
|
1431
|
+
modalSandboxCpu: z5.coerce.number().positive().optional(),
|
|
1432
|
+
modalSandboxMemoryMiB: z5.coerce.number().int().positive().optional(),
|
|
1433
|
+
modalTokenId: z5.string().optional(),
|
|
1434
|
+
modalTokenSecret: z5.string().optional(),
|
|
1435
|
+
modalEnvironment: z5.string().optional(),
|
|
1137
1436
|
// modal gap-fill: idleTimeoutMs + workspacePersistence were unmapped (module 03 §4.1).
|
|
1138
1437
|
//
|
|
1139
1438
|
// CRITICAL (sandbox-file-persistence): when this is UNSET the Modal SDK sends
|
|
@@ -1151,7 +1450,7 @@ var SettingsSchema = z3.object({
|
|
|
1151
1450
|
// explicitly (OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS) only to deliberately idle-reap
|
|
1152
1451
|
// SOONER than the hard lifetime; the boot invariant forbids a value that would
|
|
1153
1452
|
// reap before reaperPeriod + idleGrace elapses.
|
|
1154
|
-
modalIdleTimeoutSeconds:
|
|
1453
|
+
modalIdleTimeoutSeconds: z5.coerce.number().int().positive().optional(),
|
|
1155
1454
|
// /workspace FILE PERSISTENCE across warm/cold cycles. Directory snapshots
|
|
1156
1455
|
// preserve only the durable user workspace, so provider recovery does not
|
|
1157
1456
|
// restore an entire machine image or replace the selected rig/base image.
|
|
@@ -1160,7 +1459,7 @@ var SettingsSchema = z3.object({
|
|
|
1160
1459
|
// Modal creations only.
|
|
1161
1460
|
// `snapshot_filesystem` remains available for explicit compatibility and
|
|
1162
1461
|
// immutable rig-image materialization. `tar` is the portable fallback.
|
|
1163
|
-
modalWorkspacePersistence:
|
|
1462
|
+
modalWorkspacePersistence: z5.enum(["tar", "snapshot_filesystem", "snapshot_directory"]).default("snapshot_directory"),
|
|
1164
1463
|
// Shared desktop toggle: this module reads it for the 6080 port-merge; the
|
|
1165
1464
|
// owner module (P4.x) acts on it to launch the display stack.
|
|
1166
1465
|
sandboxDesktopEnabled: EnvBoolean.default(false),
|
|
@@ -1179,13 +1478,13 @@ var SettingsSchema = z3.object({
|
|
|
1179
1478
|
// The desktop framebuffer geometry the pixel plane advertises + launches the
|
|
1180
1479
|
// display stack with (P4.2). v1 has no live RANDR resize; a change is a full
|
|
1181
1480
|
// down→up restart. Defaults match the proven spike geometry (1280x800).
|
|
1182
|
-
streamResolutionWidth:
|
|
1183
|
-
streamResolutionHeight:
|
|
1481
|
+
streamResolutionWidth: z5.coerce.number().int().positive().default(1280),
|
|
1482
|
+
streamResolutionHeight: z5.coerce.number().int().positive().default(800),
|
|
1184
1483
|
// Recording loop: ffmpeg x11grab of :0 → mp4/webm → @opengeni/storage.
|
|
1185
1484
|
// recordingMaxBytes caps the in-memory finalize buffer (≤ storage single-PUT);
|
|
1186
1485
|
// recordingMaxSeconds is the ffmpeg -t hard ceiling (bounds a multi-day turn).
|
|
1187
1486
|
recordingEnabled: EnvBoolean.default(true),
|
|
1188
|
-
recordingDefaultCodec:
|
|
1487
|
+
recordingDefaultCodec: z5.enum(["h264-mp4", "vp9-webm"]).default("h264-mp4"),
|
|
1189
1488
|
// Workbench v2 turn-end workspace capture. When on, the turn
|
|
1190
1489
|
// activity probes the box's changed files off the live box at turn end and
|
|
1191
1490
|
// persists a capture revision (blobs in @opengeni/storage) so the workbench
|
|
@@ -1193,86 +1492,86 @@ var SettingsSchema = z3.object({
|
|
|
1193
1492
|
// fully behind this flag: off ⇒ capture is skipped and reads fall back to the
|
|
1194
1493
|
// live/wake path (status-quo behavior). Default on; explicit per environment.
|
|
1195
1494
|
workspaceCaptureEnabled: EnvBoolean.default(true),
|
|
1196
|
-
recordingFramerate:
|
|
1197
|
-
recordingMaxSeconds:
|
|
1198
|
-
recordingMaxBytes:
|
|
1495
|
+
recordingFramerate: z5.coerce.number().int().positive().default(15),
|
|
1496
|
+
recordingMaxSeconds: z5.coerce.number().int().positive().default(600),
|
|
1497
|
+
recordingMaxBytes: z5.coerce.number().int().positive().default(268435456),
|
|
1199
1498
|
// 256 MB
|
|
1200
1499
|
// --- daytona ---
|
|
1201
|
-
daytonaApiKey:
|
|
1202
|
-
daytonaApiUrl:
|
|
1203
|
-
daytonaTarget:
|
|
1204
|
-
daytonaImage:
|
|
1205
|
-
daytonaSnapshotName:
|
|
1206
|
-
daytonaAutoStopInterval:
|
|
1500
|
+
daytonaApiKey: z5.string().optional(),
|
|
1501
|
+
daytonaApiUrl: z5.string().url().optional(),
|
|
1502
|
+
daytonaTarget: z5.string().optional(),
|
|
1503
|
+
daytonaImage: z5.string().optional(),
|
|
1504
|
+
daytonaSnapshotName: z5.string().optional(),
|
|
1505
|
+
daytonaAutoStopInterval: z5.coerce.number().int().nonnegative().optional(),
|
|
1207
1506
|
// 0 disables idle-kill
|
|
1208
|
-
daytonaTimeoutSeconds:
|
|
1209
|
-
daytonaExposedPortUrlTtlSeconds:
|
|
1507
|
+
daytonaTimeoutSeconds: z5.coerce.number().int().positive().optional(),
|
|
1508
|
+
daytonaExposedPortUrlTtlSeconds: z5.coerce.number().int().positive().optional(),
|
|
1210
1509
|
// --- runloop ---
|
|
1211
|
-
runloopApiKey:
|
|
1212
|
-
runloopBaseUrl:
|
|
1213
|
-
runloopBlueprintName:
|
|
1214
|
-
runloopBlueprintId:
|
|
1510
|
+
runloopApiKey: z5.string().optional(),
|
|
1511
|
+
runloopBaseUrl: z5.string().url().optional(),
|
|
1512
|
+
runloopBlueprintName: z5.string().optional(),
|
|
1513
|
+
runloopBlueprintId: z5.string().optional(),
|
|
1215
1514
|
runloopTunnel: EnvBoolean.default(true),
|
|
1216
|
-
runloopKeepAliveSeconds:
|
|
1515
|
+
runloopKeepAliveSeconds: z5.coerce.number().int().positive().optional(),
|
|
1217
1516
|
// --- e2b (SDK reads E2B_API_KEY from env; mirrored for validation + forwarding) ---
|
|
1218
|
-
e2bApiKey:
|
|
1219
|
-
e2bTemplate:
|
|
1220
|
-
e2bTimeoutSeconds:
|
|
1221
|
-
e2bTimeoutAction:
|
|
1517
|
+
e2bApiKey: z5.string().optional(),
|
|
1518
|
+
e2bTemplate: z5.string().optional(),
|
|
1519
|
+
e2bTimeoutSeconds: z5.coerce.number().int().positive().optional(),
|
|
1520
|
+
e2bTimeoutAction: z5.enum(["pause", "kill"]).optional(),
|
|
1222
1521
|
e2bAllowInternetAccess: EnvBoolean.optional(),
|
|
1223
1522
|
e2bAutoResume: EnvBoolean.optional(),
|
|
1224
|
-
e2bWorkspacePersistence:
|
|
1523
|
+
e2bWorkspacePersistence: z5.enum(["tar", "snapshot"]).optional(),
|
|
1225
1524
|
// --- blaxel ---
|
|
1226
|
-
blaxelApiKey:
|
|
1227
|
-
blaxelImage:
|
|
1228
|
-
blaxelRegion:
|
|
1525
|
+
blaxelApiKey: z5.string().optional(),
|
|
1526
|
+
blaxelImage: z5.string().optional(),
|
|
1527
|
+
blaxelRegion: z5.string().optional(),
|
|
1229
1528
|
blaxelExposedPortPublic: EnvBoolean.optional(),
|
|
1230
1529
|
// public vs bl_preview_token
|
|
1231
|
-
blaxelExposedPortUrlTtlSeconds:
|
|
1232
|
-
blaxelMemoryMb:
|
|
1233
|
-
blaxelTtl:
|
|
1530
|
+
blaxelExposedPortUrlTtlSeconds: z5.coerce.number().int().positive().optional(),
|
|
1531
|
+
blaxelMemoryMb: z5.coerce.number().int().positive().optional(),
|
|
1532
|
+
blaxelTtl: z5.string().optional(),
|
|
1234
1533
|
// --- cloudflare (headless) ---
|
|
1235
|
-
cloudflareWorkerUrl:
|
|
1236
|
-
cloudflareApiKey:
|
|
1534
|
+
cloudflareWorkerUrl: z5.string().url().optional(),
|
|
1535
|
+
cloudflareApiKey: z5.string().optional(),
|
|
1237
1536
|
experimentalBrowserContextPoolEnabled: EnvBoolean.default(false),
|
|
1238
1537
|
// --- remote browser placements ---
|
|
1239
1538
|
// Provider credentials are injected only into the placement-resident
|
|
1240
1539
|
// browserd launch. They never enter session contracts, journals, or sandboxes.
|
|
1241
|
-
browserbaseApiKey:
|
|
1242
|
-
kernelApiKey:
|
|
1243
|
-
kernelEndpoint:
|
|
1244
|
-
kernelBrowserTimeoutSeconds:
|
|
1540
|
+
browserbaseApiKey: z5.string().min(1).max(8192).optional(),
|
|
1541
|
+
kernelApiKey: z5.string().min(1).max(8192).optional(),
|
|
1542
|
+
kernelEndpoint: z5.string().url().optional(),
|
|
1543
|
+
kernelBrowserTimeoutSeconds: z5.coerce.number().int().positive().max(86400).default(3600),
|
|
1245
1544
|
kernelBrowserStealth: EnvBoolean.default(false),
|
|
1246
1545
|
// --- vercel (headless) ---
|
|
1247
|
-
vercelToken:
|
|
1248
|
-
vercelProjectId:
|
|
1249
|
-
vercelTeamId:
|
|
1250
|
-
vercelRuntime:
|
|
1546
|
+
vercelToken: z5.string().optional(),
|
|
1547
|
+
vercelProjectId: z5.string().optional(),
|
|
1548
|
+
vercelTeamId: z5.string().optional(),
|
|
1549
|
+
vercelRuntime: z5.string().optional(),
|
|
1251
1550
|
// --- OpenSandbox (optional Kubernetes-native provisioned sandbox) ---
|
|
1252
|
-
openSandboxBaseUrl:
|
|
1253
|
-
openSandboxApiKey:
|
|
1551
|
+
openSandboxBaseUrl: z5.string().url().optional(),
|
|
1552
|
+
openSandboxApiKey: z5.string().min(1).optional(),
|
|
1254
1553
|
// Release and preview profiles must provide an immutable OCI digest. The
|
|
1255
1554
|
// adapter refuses tag-only references when this backend is active.
|
|
1256
|
-
openSandboxImage:
|
|
1555
|
+
openSandboxImage: z5.string().min(1).optional(),
|
|
1257
1556
|
// Renewable provider TTL is a leak/backstop clock, not OpenGeni's idle
|
|
1258
1557
|
// policy. The pinned server accepts a one-minute minimum; ordinary
|
|
1259
1558
|
// deployments default to one hour.
|
|
1260
|
-
openSandboxTtlSeconds:
|
|
1559
|
+
openSandboxTtlSeconds: z5.coerce.number().int().min(60).max(86400).default(3600),
|
|
1261
1560
|
openSandboxUseServerProxy: EnvBoolean.default(true),
|
|
1262
1561
|
// Channel B (browserd / noVNC / ttyd) uses OSEP-0011 signed URI-mode ingress.
|
|
1263
1562
|
// Exec/files stay on the private lifecycle server-proxy regardless of this flag.
|
|
1264
1563
|
openSandboxSignedEndpoints: EnvBoolean.default(false),
|
|
1265
|
-
openSandboxSignedEndpointTtlSeconds:
|
|
1266
|
-
openSandboxChannelBPublicBaseUrl:
|
|
1564
|
+
openSandboxSignedEndpointTtlSeconds: z5.coerce.number().int().min(60).max(3600).default(600),
|
|
1565
|
+
openSandboxChannelBPublicBaseUrl: z5.string().url().optional(),
|
|
1267
1566
|
// Emergency hatch only: force JPEG/RFB through the API frame-proxy even when
|
|
1268
1567
|
// signed endpoints are on (M2 subprotocol failure). Unset means OpenSandbox
|
|
1269
1568
|
// uses the frame-proxy unless signed endpoints are on.
|
|
1270
1569
|
openSandboxInteractionFrameProxy: EnvBoolean.optional(),
|
|
1271
|
-
openSandboxPoolRef:
|
|
1570
|
+
openSandboxPoolRef: z5.string().regex(/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/).optional(),
|
|
1272
1571
|
// Optional same-cluster, read-only observability projection. The application
|
|
1273
1572
|
// chart sets this only on the control worker and mounts a dedicated projected
|
|
1274
1573
|
// service-account token; non-Kubernetes and remote-provider deployments omit it.
|
|
1275
|
-
openSandboxKubernetesInventoryNamespace:
|
|
1574
|
+
openSandboxKubernetesInventoryNamespace: z5.string().min(1).max(63).regex(/^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$/).optional(),
|
|
1276
1575
|
// --- sandbox ownership inversion (P1.2 rollout flag, default OFF) ---
|
|
1277
1576
|
// The keystone flag for the stateless resume-by-id model. When FALSE the
|
|
1278
1577
|
// agent-turn path is BYTE-FOR-BYTE today's build-and-discard behavior (no
|
|
@@ -1326,13 +1625,13 @@ var SettingsSchema = z3.object({
|
|
|
1326
1625
|
// when ABSENT and sandboxSelfhostedEnabled is on, the poll route reports the
|
|
1327
1626
|
// credential plane disabled (graceful degrade, mirrors streamTokenSecret). NEVER
|
|
1328
1627
|
// logged. Lives in the opengeni-runtime secret (Helm-clobbered configmap avoided).
|
|
1329
|
-
enrollmentSigningSecret:
|
|
1628
|
+
enrollmentSigningSecret: z5.string().optional(),
|
|
1330
1629
|
// Connect-info the EnrollmentCredentials hand the agent: the NATS server URL(s)
|
|
1331
1630
|
// the agent dials for the control plane, and the relay edge base URL for streams.
|
|
1332
1631
|
// The per-workspace NATS Account creds binding is infra-deferred (M4/relay
|
|
1333
1632
|
// milestone) — the poll returns these endpoints + a placeholder creds field.
|
|
1334
|
-
selfhostedNatsUrl:
|
|
1335
|
-
selfhostedRelayUrl:
|
|
1633
|
+
selfhostedNatsUrl: z5.string().optional(),
|
|
1634
|
+
selfhostedRelayUrl: z5.string().optional(),
|
|
1336
1635
|
// The HMAC secret the control plane signs the agent's relay PRODUCER token with
|
|
1337
1636
|
// (the `ogr_` envelope threaded into EnrollmentCredentials.relayToken; M8b/design
|
|
1338
1637
|
// §10.5). The relay verifies the producer token with the SAME secret. Optional:
|
|
@@ -1340,10 +1639,10 @@ var SettingsSchema = z3.object({
|
|
|
1340
1639
|
// plane is simply unavailable until configured). Falls back to streamTokenSecret /
|
|
1341
1640
|
// delegationSecret (same HMAC family) so a deployment with a stream-token secret
|
|
1342
1641
|
// needs no second one. NEVER logged. Lives in the opengeni-runtime secret.
|
|
1343
|
-
selfhostedRelayTokenSecret:
|
|
1642
|
+
selfhostedRelayTokenSecret: z5.string().optional(),
|
|
1344
1643
|
// The minisign PUBLIC key the agent pins for self-update verification (handed to
|
|
1345
1644
|
// the agent in EnrollmentCredentials; the SECRET key lives only in CI).
|
|
1346
|
-
agentUpdatePublicKey:
|
|
1645
|
+
agentUpdatePublicKey: z5.string().optional(),
|
|
1347
1646
|
// --- NATS auth-callout tenancy boundary (bring-your-own-compute M-AUTH; design
|
|
1348
1647
|
// §10.1 NATS Accounts per workspace + §17 the isolation smoke) -------------
|
|
1349
1648
|
// nats-server is configured with AUTH CALLOUT: an external agent connects
|
|
@@ -1360,24 +1659,24 @@ var SettingsSchema = z3.object({
|
|
|
1360
1659
|
// The callout account SIGNING SEED (`SA...`). Both the user JWT and the
|
|
1361
1660
|
// authorization-response JWT are signed by this account key; its public key
|
|
1362
1661
|
// (`A...`) is the `auth_callout.issuer` in the server config. NEVER logged.
|
|
1363
|
-
selfhostedNatsCalloutAccountSeed:
|
|
1662
|
+
selfhostedNatsCalloutAccountSeed: z5.string().optional(),
|
|
1364
1663
|
// The TARGET ACCOUNT NAME the minted user is placed into (the server-config-mode
|
|
1365
1664
|
// `auth_callout.account`, e.g. "APP"). The responder writes it as the minted user
|
|
1366
1665
|
// JWT `aud` so nats-server binds the agent to this account — the SAME account the
|
|
1367
1666
|
// privileged control plane connects into, so exact process request/reply
|
|
1368
1667
|
// routes. Optional; resolveNatsCalloutConfig defaults it to "APP".
|
|
1369
|
-
selfhostedNatsCalloutAccountName:
|
|
1668
|
+
selfhostedNatsCalloutAccountName: z5.string().optional(),
|
|
1370
1669
|
// The callout RESPONDER's own NATS login (one of the `auth_callout.auth_users`
|
|
1371
1670
|
// in the AUTH account) — the responder connects with this to subscribe
|
|
1372
1671
|
// $SYS.REQ.USER.AUTH. Username/password.
|
|
1373
|
-
selfhostedNatsCalloutUser:
|
|
1374
|
-
selfhostedNatsCalloutPassword:
|
|
1672
|
+
selfhostedNatsCalloutUser: z5.string().optional(),
|
|
1673
|
+
selfhostedNatsCalloutPassword: z5.string().optional(),
|
|
1375
1674
|
// The PRIVILEGED control-plane login (api/worker): a static account user that may
|
|
1376
1675
|
// request exact process RPC subjects + receive their inbox replies. The event bus + the
|
|
1377
1676
|
// selfhosted control RPC ride THIS connection. Username/password; when unset the
|
|
1378
1677
|
// bus connects anonymously (local dev / a NATS with no auth_callout).
|
|
1379
|
-
selfhostedNatsControlUser:
|
|
1380
|
-
selfhostedNatsControlPassword:
|
|
1678
|
+
selfhostedNatsControlUser: z5.string().optional(),
|
|
1679
|
+
selfhostedNatsControlPassword: z5.string().optional(),
|
|
1381
1680
|
// --- selfhosted (Connected Machine) control/exec op deadlines ---------------
|
|
1382
1681
|
// CONTROL ops (ping / fs / git / desktop / pty) keep a short request timeout so
|
|
1383
1682
|
// liveness failures surface promptly. EXEC duration is a different concern: by
|
|
@@ -1387,8 +1686,8 @@ var SettingsSchema = z3.object({
|
|
|
1387
1686
|
// process deadline by setting a positive value; 0 never schedules a process kill.
|
|
1388
1687
|
// Knobs: OPENGENI_SANDBOX_SELFHOSTED_EXEC_TIMEOUT_MS (default 0 = none) and
|
|
1389
1688
|
// OPENGENI_SANDBOX_SELFHOSTED_CONTROL_TIMEOUT_MS (default 30s).
|
|
1390
|
-
sandboxSelfhostedExecTimeoutMs:
|
|
1391
|
-
sandboxSelfhostedControlTimeoutMs:
|
|
1689
|
+
sandboxSelfhostedExecTimeoutMs: z5.coerce.number().int().nonnegative().default(0),
|
|
1690
|
+
sandboxSelfhostedControlTimeoutMs: z5.coerce.number().int().positive().default(3e4),
|
|
1392
1691
|
// --- sandbox lease cadences (cadence invariant validated at boot below) ---
|
|
1393
1692
|
// reaperPeriod < viewerHolderTTL, and reaperPeriod + idleGrace < the EFFECTIVE
|
|
1394
1693
|
// box idle timeout (effectiveModalIdleTimeoutSeconds, which defaults to the hard
|
|
@@ -1396,12 +1695,12 @@ var SettingsSchema = z3.object({
|
|
|
1396
1695
|
// idle timeout — which we pin high enough (via the idle-timeout default) that
|
|
1397
1696
|
// OpenGeni's reaper, not Modal's idle-reap, governs teardown so /workspace is
|
|
1398
1697
|
// snapshotted before the box dies (sandbox-file-persistence).
|
|
1399
|
-
sandboxLeaseReaperPeriodMs:
|
|
1400
|
-
sandboxViewerHolderTtlMs:
|
|
1698
|
+
sandboxLeaseReaperPeriodMs: z5.coerce.number().int().positive().default(3e4),
|
|
1699
|
+
sandboxViewerHolderTtlMs: z5.coerce.number().int().positive().default(9e4),
|
|
1401
1700
|
// A BrowserSession controller refreshes its durable resource and exact
|
|
1402
1701
|
// interaction lease holder together. This longer crash horizon tolerates API
|
|
1403
1702
|
// replacement while still releasing a placement whose controller died.
|
|
1404
|
-
sandboxInteractionHolderTtlMs:
|
|
1703
|
+
sandboxInteractionHolderTtlMs: z5.coerce.number().int().positive().default(18e4),
|
|
1405
1704
|
// The DRAIN grace: how long a refcount-0 (draining) lease stays WARM before the
|
|
1406
1705
|
// reaper resume-by-ids the box and terminates it. This is the cost-vs-snappiness
|
|
1407
1706
|
// dial — when the user navigates away the box keeps refcount 0, but it survives
|
|
@@ -1411,7 +1710,7 @@ var SettingsSchema = z3.object({
|
|
|
1411
1710
|
// fresh EMPTY box; lower it to trade warm cost for a snappier reclaim.
|
|
1412
1711
|
// getSettings caps the default at half a shorter configured Modal lifetime so
|
|
1413
1712
|
// the entire reaper window always fits. Knob: OPENGENI_SANDBOX_IDLE_GRACE_MS.
|
|
1414
|
-
sandboxIdleGraceMs:
|
|
1713
|
+
sandboxIdleGraceMs: z5.coerce.number().int().positive().default(9e5),
|
|
1415
1714
|
// Idle command containment. A legacy retained background command (a dev
|
|
1416
1715
|
// server, a command whose output is still draining, a stopped command the
|
|
1417
1716
|
// provider no longer answers for) keeps its box warm through a non-expiring
|
|
@@ -1433,7 +1732,7 @@ var SettingsSchema = z3.object({
|
|
|
1433
1732
|
// plus this window plus the drain capture budget must fit before it.
|
|
1434
1733
|
// getSettings derives the unset default between those two for short-lived
|
|
1435
1734
|
// provider lifetimes. Knob: OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS.
|
|
1436
|
-
sandboxIdleCommandContainmentMs:
|
|
1735
|
+
sandboxIdleCommandContainmentMs: z5.coerce.number().int().nonnegative().optional().transform((value) => value === 0 ? void 0 : value),
|
|
1437
1736
|
// MID-SESSION /workspace snapshot cadence (sandbox-file-persistence). The
|
|
1438
1737
|
// reaper's drain-persist only protects boxes the reaper itself kills; a box
|
|
1439
1738
|
// that dies any other way (Modal's hard creation-time timeout on a session
|
|
@@ -1443,20 +1742,20 @@ var SettingsSchema = z3.object({
|
|
|
1443
1742
|
// one (same epoch-fenced fold-onto-lease seam as the drain), bounding the
|
|
1444
1743
|
// worst-case loss of ANY unclean box death to this window. 0 disables.
|
|
1445
1744
|
// Knob: OPENGENI_SANDBOX_SNAPSHOT_INTERVAL_MS. Default 15min.
|
|
1446
|
-
sandboxSnapshotIntervalMs:
|
|
1745
|
+
sandboxSnapshotIntervalMs: z5.coerce.number().int().min(0).default(9e5),
|
|
1447
1746
|
// Maximum time a best-effort /workspace snapshot capture may hold turn/reaper
|
|
1448
1747
|
// cleanup. A hung provider snapshot must never pin a lease holder, block
|
|
1449
1748
|
// graceful shutdown, or become permission to GC an older archive. Timeout is
|
|
1450
1749
|
// treated exactly like a failed best-effort snapshot. Knob:
|
|
1451
1750
|
// OPENGENI_SANDBOX_SNAPSHOT_TIMEOUT_MS. Default 60s.
|
|
1452
|
-
sandboxSnapshotTimeoutMs:
|
|
1751
|
+
sandboxSnapshotTimeoutMs: z5.coerce.number().int().positive().max(SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS).default(6e4),
|
|
1453
1752
|
// A zero-holder drain may need substantially longer than a best-effort
|
|
1454
1753
|
// mid-turn/turn-end snapshot for a very large workspace. Keep that provider
|
|
1455
1754
|
// budget independent so increasing drain recovery headroom cannot pin an
|
|
1456
1755
|
// ordinary turn finalizer for the same duration. Unset preserves the legacy
|
|
1457
1756
|
// single-budget behavior. Knob:
|
|
1458
1757
|
// OPENGENI_SANDBOX_DRAIN_SNAPSHOT_TIMEOUT_MS.
|
|
1459
|
-
sandboxDrainSnapshotTimeoutMs:
|
|
1758
|
+
sandboxDrainSnapshotTimeoutMs: z5.coerce.number().int().positive().max(SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS).optional(),
|
|
1460
1759
|
// Begin a controlled snapshot/quiesce/drain/rematerialize transition this far
|
|
1461
1760
|
// ahead of a finite provider deadline. Modal's 24h creation clock cannot be
|
|
1462
1761
|
// extended; the logical sandbox outlives it by moving to one successor box.
|
|
@@ -1465,22 +1764,22 @@ var SettingsSchema = z3.object({
|
|
|
1465
1764
|
// an extra coupled environment override. An explicit value may be larger when
|
|
1466
1765
|
// an operator deliberately wants more rotation headroom; the boot invariant
|
|
1467
1766
|
// still requires it to remain below the provider lifetime.
|
|
1468
|
-
sandboxRotationLeadMs:
|
|
1767
|
+
sandboxRotationLeadMs: z5.coerce.number().int().positive().default(36e5),
|
|
1469
1768
|
// Bound provider-deadline rotation admission independently of execution.
|
|
1470
1769
|
// Every admitted box receives its own durable drain child; the control worker
|
|
1471
1770
|
// limits provider I/O to 32 concurrent activities. Matching that bound avoids
|
|
1472
1771
|
// both the old one-box-per-tick deadline backlog and an unbounded provider/API
|
|
1473
1772
|
// burst. Operators may tune this for a differently-sized worker pool.
|
|
1474
|
-
sandboxRotationBatchSize:
|
|
1773
|
+
sandboxRotationBatchSize: z5.coerce.number().int().positive().max(500).default(32),
|
|
1475
1774
|
// expires_at refresh window for a held lease (>> the turn 10s heartbeat so a
|
|
1476
1775
|
// single missed heartbeat never TTL-reaps a live turn). The warming TTL is the
|
|
1477
1776
|
// window a cold->warming spawner has to commit warm before a reaper resets it.
|
|
1478
|
-
sandboxLeaseTtlMs:
|
|
1479
|
-
sandboxLeaseWarmingTtlMs:
|
|
1777
|
+
sandboxLeaseTtlMs: z5.coerce.number().int().positive().default(9e4),
|
|
1778
|
+
sandboxLeaseWarmingTtlMs: z5.coerce.number().int().positive().default(12e4),
|
|
1480
1779
|
// Overall user-facing budget for warming a sandbox lease. Unlike the lease TTL
|
|
1481
1780
|
// (a liveness/reaper cadence), this bounds how long one turn waits for capacity
|
|
1482
1781
|
// or provider creation before surfacing a clear turn.failed error.
|
|
1483
|
-
sandboxWarmingTimeoutMs:
|
|
1782
|
+
sandboxWarmingTimeoutMs: z5.coerce.number().int().positive().default(6e5),
|
|
1484
1783
|
// Request-scoped workspace control-prefix budget: how long one HTTP-originated
|
|
1485
1784
|
// session/workspace mutation (Send, Steer, Pause/Resume/Cancel, queue
|
|
1486
1785
|
// move/edit/delete, composer draft, settings narrowing, quiescent tree
|
|
@@ -1489,103 +1788,103 @@ var SettingsSchema = z3.object({
|
|
|
1489
1788
|
// settlement and claims never use it. The API installs the validated value
|
|
1490
1789
|
// into @opengeni/db once at app construction; nothing reads the env per
|
|
1491
1790
|
// request. Env: OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS. Default 20 s.
|
|
1492
|
-
workspaceControlLockTimeoutMs:
|
|
1791
|
+
workspaceControlLockTimeoutMs: z5.coerce.number({
|
|
1493
1792
|
message: "OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS must be a positive integer (ms)"
|
|
1494
1793
|
}).int("OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS must be a positive integer (ms)").positive("OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS must be a positive integer (ms)").default(2e4),
|
|
1495
1794
|
// Rig setup-script budget (M3): the wall-clock timeout the rig-setup lifecycle
|
|
1496
1795
|
// hook runs its script under, distinct from the 120s per-command lifecycle
|
|
1497
1796
|
// default (a rig may compile/install heavy tooling on first cold create).
|
|
1498
1797
|
// Env: OPENGENI_RIG_SETUP_TIMEOUT_MS. Default 10min.
|
|
1499
|
-
rigSetupTimeoutMs:
|
|
1798
|
+
rigSetupTimeoutMs: z5.coerce.number().int().positive().default(6e5),
|
|
1500
1799
|
// --- sandbox warm-time billing (P2.1) ---
|
|
1501
1800
|
// Per-backend warm rate (usd_micros/sec), like modelPricingJson: an empty {}
|
|
1502
1801
|
// means warm-cost is not debited (warm-seconds are still metered for audit).
|
|
1503
1802
|
// Shape: { "modal": 5, "runloop": 4, ... }. Backends absent here meter
|
|
1504
1803
|
// warm-seconds but accrue NO warm_cost / debit (rate 0).
|
|
1505
|
-
sandboxWarmRateMicrosPerSecondJson:
|
|
1506
|
-
sandboxWarmBillingMode:
|
|
1804
|
+
sandboxWarmRateMicrosPerSecondJson: z5.string().default("{}"),
|
|
1805
|
+
sandboxWarmBillingMode: z5.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
|
|
1507
1806
|
// Per-workspace warm cap (cumulative warm-seconds since the start of the UTC
|
|
1508
1807
|
// month, summed over sandbox.warm_seconds). 0 = unbounded. A workspace over the
|
|
1509
1808
|
// cap force-drains its VIEWER-ONLY boxes (guarded AND turn_holders=0 — a paying
|
|
1510
1809
|
// turn is never killed); the reaper then stop()s at refcount 0.
|
|
1511
|
-
sandboxMaxWarmSecondsPerWorkspace:
|
|
1512
|
-
sandboxPreparationProfiles:
|
|
1513
|
-
sandboxEnvAllowlist:
|
|
1810
|
+
sandboxMaxWarmSecondsPerWorkspace: z5.coerce.number().int().nonnegative().default(0),
|
|
1811
|
+
sandboxPreparationProfiles: z5.string().default("none"),
|
|
1812
|
+
sandboxEnvAllowlist: z5.string().default(""),
|
|
1514
1813
|
// Comma-separated image references a workspace may select as its default
|
|
1515
1814
|
// sandbox image. Empty keeps every workspace on the deployment image.
|
|
1516
|
-
sandboxImageAllowlist:
|
|
1517
|
-
objectStorageEndpoint:
|
|
1518
|
-
objectStorageInternalEndpoint:
|
|
1519
|
-
objectStorageSandboxEndpoint:
|
|
1520
|
-
objectStorageBackend:
|
|
1521
|
-
objectStorageBucket:
|
|
1522
|
-
objectStorageRegion:
|
|
1523
|
-
objectStorageS3Provider:
|
|
1524
|
-
objectStorageAccessKeyId:
|
|
1525
|
-
objectStorageSecretAccessKey:
|
|
1815
|
+
sandboxImageAllowlist: z5.string().default(""),
|
|
1816
|
+
objectStorageEndpoint: z5.string().url().optional(),
|
|
1817
|
+
objectStorageInternalEndpoint: z5.string().url().optional(),
|
|
1818
|
+
objectStorageSandboxEndpoint: z5.string().url().optional(),
|
|
1819
|
+
objectStorageBackend: z5.enum(["s3-compatible", "aws-s3", "azure-blob", "gcs"]).default("s3-compatible"),
|
|
1820
|
+
objectStorageBucket: z5.string().min(1).default("opengeni-files"),
|
|
1821
|
+
objectStorageRegion: z5.string().min(1).default("us-east-1"),
|
|
1822
|
+
objectStorageS3Provider: z5.string().min(1).default("Minio"),
|
|
1823
|
+
objectStorageAccessKeyId: z5.string().optional(),
|
|
1824
|
+
objectStorageSecretAccessKey: z5.string().optional(),
|
|
1526
1825
|
objectStorageForcePathStyle: EnvBoolean.default(true),
|
|
1527
|
-
objectStorageAzureConnectionString:
|
|
1528
|
-
objectStorageAzureAccountName:
|
|
1529
|
-
objectStorageAzureAccountKey:
|
|
1530
|
-
objectStorageAzureEndpoint:
|
|
1531
|
-
objectStorageGcsProjectId:
|
|
1532
|
-
objectStorageGcsCredentialsJson:
|
|
1533
|
-
objectStorageGcsKeyFilename:
|
|
1534
|
-
objectStorageGcsApiEndpoint:
|
|
1535
|
-
documentParser:
|
|
1536
|
-
documentChunkSize:
|
|
1537
|
-
documentChunkOverlap:
|
|
1538
|
-
documentEmbeddingProvider:
|
|
1539
|
-
documentEmbeddingModel:
|
|
1540
|
-
documentEmbeddingDimensions:
|
|
1541
|
-
documentEmbeddingApiKey:
|
|
1542
|
-
documentEmbeddingBaseUrl:
|
|
1543
|
-
documentEmbeddingBillingMode:
|
|
1826
|
+
objectStorageAzureConnectionString: z5.string().optional(),
|
|
1827
|
+
objectStorageAzureAccountName: z5.string().optional(),
|
|
1828
|
+
objectStorageAzureAccountKey: z5.string().optional(),
|
|
1829
|
+
objectStorageAzureEndpoint: z5.string().url().optional(),
|
|
1830
|
+
objectStorageGcsProjectId: z5.string().optional(),
|
|
1831
|
+
objectStorageGcsCredentialsJson: z5.string().optional(),
|
|
1832
|
+
objectStorageGcsKeyFilename: z5.string().optional(),
|
|
1833
|
+
objectStorageGcsApiEndpoint: z5.string().url().optional(),
|
|
1834
|
+
documentParser: z5.string().min(1).default("liteparse"),
|
|
1835
|
+
documentChunkSize: z5.coerce.number().int().positive().default(1200),
|
|
1836
|
+
documentChunkOverlap: z5.coerce.number().int().nonnegative().default(160),
|
|
1837
|
+
documentEmbeddingProvider: z5.enum(["openai", "deterministic"]).default("openai"),
|
|
1838
|
+
documentEmbeddingModel: z5.string().min(1).default("text-embedding-3-large"),
|
|
1839
|
+
documentEmbeddingDimensions: z5.coerce.number().int().positive().default(3072),
|
|
1840
|
+
documentEmbeddingApiKey: z5.string().optional(),
|
|
1841
|
+
documentEmbeddingBaseUrl: z5.string().url().optional(),
|
|
1842
|
+
documentEmbeddingBillingMode: z5.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
|
|
1544
1843
|
// Explicit commercial cutover. Existing queued revisions remain unpriced;
|
|
1545
1844
|
// only jobs created at or after this instant may enter the paid rail.
|
|
1546
|
-
documentEmbeddingCreditsActivatedAt:
|
|
1845
|
+
documentEmbeddingCreditsActivatedAt: z5.iso.datetime().optional(),
|
|
1547
1846
|
// Customer tariff for the exact UTF-8 bytes sent to the embedder. Zero leaves
|
|
1548
1847
|
// the paid mode unavailable; no commercial rate is selected by this PR.
|
|
1549
|
-
documentEmbeddingRateMicrosPerMillionBytes:
|
|
1550
|
-
documentCurationProvider:
|
|
1551
|
-
documentCurationModel:
|
|
1552
|
-
documentCurationApiKey:
|
|
1553
|
-
documentCurationBaseUrl:
|
|
1554
|
-
gitAuthorName:
|
|
1555
|
-
gitAuthorEmail:
|
|
1556
|
-
gitCommitterName:
|
|
1557
|
-
gitCommitterEmail:
|
|
1558
|
-
githubAppManifestBaseUrl:
|
|
1559
|
-
githubAppManifestStateSecret:
|
|
1560
|
-
githubAppId:
|
|
1561
|
-
githubClientId:
|
|
1562
|
-
githubClientSecret:
|
|
1848
|
+
documentEmbeddingRateMicrosPerMillionBytes: z5.coerce.number().int().nonnegative().default(0),
|
|
1849
|
+
documentCurationProvider: z5.enum(["openai", "heuristic", "none"]).default("openai"),
|
|
1850
|
+
documentCurationModel: z5.string().min(1).default("gpt-4o-mini"),
|
|
1851
|
+
documentCurationApiKey: z5.string().optional(),
|
|
1852
|
+
documentCurationBaseUrl: z5.string().url().optional(),
|
|
1853
|
+
gitAuthorName: z5.string().optional(),
|
|
1854
|
+
gitAuthorEmail: z5.string().optional(),
|
|
1855
|
+
gitCommitterName: z5.string().optional(),
|
|
1856
|
+
gitCommitterEmail: z5.string().optional(),
|
|
1857
|
+
githubAppManifestBaseUrl: z5.string().optional(),
|
|
1858
|
+
githubAppManifestStateSecret: z5.string().optional(),
|
|
1859
|
+
githubAppId: z5.string().optional(),
|
|
1860
|
+
githubClientId: z5.string().optional(),
|
|
1861
|
+
githubClientSecret: z5.string().optional(),
|
|
1563
1862
|
/** Default-off rollout for the in-process GitHub repository API tool surface. */
|
|
1564
1863
|
githubRestMcpEnabled: EnvBoolean.default(false),
|
|
1565
1864
|
githubPersonalOauthEnabled: EnvBoolean.default(false),
|
|
1566
|
-
githubPersonalOauthClientId:
|
|
1567
|
-
githubPersonalOauthClientSecret:
|
|
1568
|
-
githubAppSlug:
|
|
1569
|
-
githubWebhookSecret:
|
|
1570
|
-
githubAppPrivateKey:
|
|
1571
|
-
prReviewGithubAppId:
|
|
1572
|
-
prReviewGithubClientId:
|
|
1573
|
-
prReviewGithubClientSecret:
|
|
1574
|
-
prReviewGithubAppSlug:
|
|
1575
|
-
prReviewGithubWebhookSecret:
|
|
1576
|
-
prReviewGithubAppPrivateKey:
|
|
1577
|
-
betterAuthSecret:
|
|
1578
|
-
betterAuthAllowedHosts:
|
|
1579
|
-
betterAuthCookieDomain:
|
|
1580
|
-
betterAuthTrustedOrigins:
|
|
1581
|
-
managedAuthGoogleClientId:
|
|
1582
|
-
managedAuthGoogleClientSecret:
|
|
1583
|
-
managedAuthGithubClientId:
|
|
1584
|
-
managedAuthGithubClientSecret:
|
|
1865
|
+
githubPersonalOauthClientId: z5.string().optional(),
|
|
1866
|
+
githubPersonalOauthClientSecret: z5.string().optional(),
|
|
1867
|
+
githubAppSlug: z5.string().optional(),
|
|
1868
|
+
githubWebhookSecret: z5.string().optional(),
|
|
1869
|
+
githubAppPrivateKey: z5.string().optional(),
|
|
1870
|
+
prReviewGithubAppId: z5.string().optional(),
|
|
1871
|
+
prReviewGithubClientId: z5.string().optional(),
|
|
1872
|
+
prReviewGithubClientSecret: z5.string().optional(),
|
|
1873
|
+
prReviewGithubAppSlug: z5.string().optional(),
|
|
1874
|
+
prReviewGithubWebhookSecret: z5.string().optional(),
|
|
1875
|
+
prReviewGithubAppPrivateKey: z5.string().optional(),
|
|
1876
|
+
betterAuthSecret: z5.string().optional(),
|
|
1877
|
+
betterAuthAllowedHosts: z5.string().default(""),
|
|
1878
|
+
betterAuthCookieDomain: z5.string().optional(),
|
|
1879
|
+
betterAuthTrustedOrigins: z5.string().default(""),
|
|
1880
|
+
managedAuthGoogleClientId: z5.string().optional(),
|
|
1881
|
+
managedAuthGoogleClientSecret: z5.string().optional(),
|
|
1882
|
+
managedAuthGithubClientId: z5.string().optional(),
|
|
1883
|
+
managedAuthGithubClientSecret: z5.string().optional(),
|
|
1585
1884
|
// Rolling browser login-slot compatibility. Repository/deployment default is
|
|
1586
1885
|
// deliberately legacy; changing to broker is an operator-authorized rollout.
|
|
1587
|
-
allowedUserEmails:
|
|
1588
|
-
managedAuthSessionSetMode:
|
|
1886
|
+
allowedUserEmails: z5.array(z5.email().transform((email) => email.toLowerCase())).min(1).optional(),
|
|
1887
|
+
managedAuthSessionSetMode: z5.enum(["legacy", "dual", "broker"]).default("legacy"),
|
|
1589
1888
|
// Deployment ceiling for new managed accounts. When false, managed auth
|
|
1590
1889
|
// refuses every new Better Auth account (email/password sign-up and implicit
|
|
1591
1890
|
// Google/GitHub sign-up) while existing sign-in, sessions, password reset,
|
|
@@ -1595,26 +1894,26 @@ var SettingsSchema = z3.object({
|
|
|
1595
1894
|
// Query transport is an explicit second-stage rollout. A pre-compatibility
|
|
1596
1895
|
// web image understands only fragment bearers, so API replicas must keep
|
|
1597
1896
|
// generating fragment links until the compatible web fleet has converged.
|
|
1598
|
-
organizationUserSetupEmailTokenTransport:
|
|
1897
|
+
organizationUserSetupEmailTokenTransport: z5.enum(["fragment", "query"]).default("fragment"),
|
|
1599
1898
|
// Query-bearing setup links may appear in controller/edge error logs even
|
|
1600
1899
|
// when access logs and request tracing are disabled. This explicit operator
|
|
1601
1900
|
// confirmation keeps query transport fail closed until that separate sink is
|
|
1602
1901
|
// proven sanitized.
|
|
1603
1902
|
organizationUserSetupQueryEdgeSanitizationConfirmed: EnvBoolean.default(false),
|
|
1604
|
-
resendApiKey:
|
|
1605
|
-
emailFrom:
|
|
1606
|
-
stripeSecretKey:
|
|
1607
|
-
stripePublishableKey:
|
|
1608
|
-
stripeWebhookSecret:
|
|
1609
|
-
stripeCreditsProductId:
|
|
1610
|
-
mcpServers:
|
|
1611
|
-
|
|
1612
|
-
id:
|
|
1613
|
-
name:
|
|
1614
|
-
url:
|
|
1615
|
-
allowedTools:
|
|
1616
|
-
timeoutMs:
|
|
1617
|
-
cacheToolsList:
|
|
1903
|
+
resendApiKey: z5.string().optional(),
|
|
1904
|
+
emailFrom: z5.string().default("OpenGeni <auth@mail.opengeni.ai>"),
|
|
1905
|
+
stripeSecretKey: z5.string().optional(),
|
|
1906
|
+
stripePublishableKey: z5.string().optional(),
|
|
1907
|
+
stripeWebhookSecret: z5.string().optional(),
|
|
1908
|
+
stripeCreditsProductId: z5.string().optional(),
|
|
1909
|
+
mcpServers: z5.array(
|
|
1910
|
+
z5.object({
|
|
1911
|
+
id: z5.string().min(1).regex(registryId),
|
|
1912
|
+
name: z5.string().min(1).optional(),
|
|
1913
|
+
url: z5.string().url(),
|
|
1914
|
+
allowedTools: z5.array(z5.string().min(1)).optional(),
|
|
1915
|
+
timeoutMs: z5.number().int().positive().optional(),
|
|
1916
|
+
cacheToolsList: z5.boolean().default(false),
|
|
1618
1917
|
/** Runtime approval policy, overlaid from an attempt-frozen session snapshot. */
|
|
1619
1918
|
requireApproval: SessionMcpApprovalPolicy.optional(),
|
|
1620
1919
|
/**
|
|
@@ -1623,7 +1922,7 @@ var SettingsSchema = z3.object({
|
|
|
1623
1922
|
* encrypted capability-installation credentials; do not put secrets in
|
|
1624
1923
|
* OPENGENI_MCP_SERVERS.
|
|
1625
1924
|
*/
|
|
1626
|
-
headers:
|
|
1925
|
+
headers: z5.record(z5.string(), z5.string()).optional(),
|
|
1627
1926
|
connectionRef: McpServerConnectionRefSchema.optional(),
|
|
1628
1927
|
operationRecovery: McpOperationRecoverySchema.optional()
|
|
1629
1928
|
})
|
|
@@ -1795,14 +2094,61 @@ function isUsableVoiceInputSecret(value) {
|
|
|
1795
2094
|
return true;
|
|
1796
2095
|
}
|
|
1797
2096
|
function resolveVoiceInputProviderRegistry(settings) {
|
|
2097
|
+
return voiceInputProviderRegistryWithIssues(settings).providers;
|
|
2098
|
+
}
|
|
2099
|
+
function voiceInputPricingIssues(settings) {
|
|
2100
|
+
return voiceInputProviderRegistryWithIssues(settings).issues;
|
|
2101
|
+
}
|
|
2102
|
+
function voiceInputProviderPricing(settings, issues2, providerId2, env, raw, model) {
|
|
2103
|
+
const resolved = safeResolveVoiceInputPricing(raw, model, env);
|
|
2104
|
+
if (!resolved.ok) {
|
|
2105
|
+
issues2.push({ providerId: providerId2, env, reason: "malformed", message: resolved.error });
|
|
2106
|
+
return { usable: false };
|
|
2107
|
+
}
|
|
2108
|
+
if (!resolved.pricing && voiceInputCreditBillingActive(settings)) {
|
|
2109
|
+
issues2.push({
|
|
2110
|
+
providerId: providerId2,
|
|
2111
|
+
env,
|
|
2112
|
+
reason: "unpriced",
|
|
2113
|
+
message: `${env} is required: credit billing is active and model "${model}" has no built-in voice price`
|
|
2114
|
+
});
|
|
2115
|
+
return { usable: false };
|
|
2116
|
+
}
|
|
2117
|
+
return { usable: true, pricing: resolved.pricing };
|
|
2118
|
+
}
|
|
2119
|
+
function voiceInputProviderRegistryWithIssues(settings) {
|
|
2120
|
+
const issues2 = [];
|
|
1798
2121
|
const order = settings.voiceInputProviderOrder.split(",").map((part) => part.trim()).filter(
|
|
1799
|
-
(part) => part === "openai" || part === "azure-openai" || part === "codex-subscription" || part === "supergrok-subscription"
|
|
2122
|
+
(part) => part === "openai" || part === "azure-openai" || part === "azure-mai" || part === "codex-subscription" || part === "supergrok-subscription"
|
|
1800
2123
|
);
|
|
1801
2124
|
const seen = /* @__PURE__ */ new Set();
|
|
1802
2125
|
const providers = [];
|
|
1803
2126
|
for (const id of order) {
|
|
1804
2127
|
if (seen.has(id)) continue;
|
|
1805
2128
|
seen.add(id);
|
|
2129
|
+
if (id === "azure-mai") {
|
|
2130
|
+
if (!settings.voiceInputMaiEndpoint || !isUsableVoiceInputSecret(settings.voiceInputMaiApiKey))
|
|
2131
|
+
continue;
|
|
2132
|
+
const priced = voiceInputProviderPricing(
|
|
2133
|
+
settings,
|
|
2134
|
+
issues2,
|
|
2135
|
+
"azure-mai",
|
|
2136
|
+
"OPENGENI_VOICE_INPUT_MAI_PRICING_JSON",
|
|
2137
|
+
settings.voiceInputMaiPricingJson,
|
|
2138
|
+
settings.voiceInputMaiModel
|
|
2139
|
+
);
|
|
2140
|
+
if (!priced.usable) continue;
|
|
2141
|
+
providers.push({
|
|
2142
|
+
id,
|
|
2143
|
+
kind: "azure-mai",
|
|
2144
|
+
pricing: priced.pricing,
|
|
2145
|
+
endpoint: settings.voiceInputMaiEndpoint.replace(/\/+$/, ""),
|
|
2146
|
+
apiKey: settings.voiceInputMaiApiKey,
|
|
2147
|
+
apiVersion: settings.voiceInputMaiApiVersion,
|
|
2148
|
+
model: settings.voiceInputMaiModel
|
|
2149
|
+
});
|
|
2150
|
+
continue;
|
|
2151
|
+
}
|
|
1806
2152
|
if (id === "openai") {
|
|
1807
2153
|
if (!settings.voiceInputOpenaiEnabled) continue;
|
|
1808
2154
|
const apiKey = settings.voiceInputOpenaiApiKey ?? settings.openaiApiKey;
|
|
@@ -1810,9 +2156,19 @@ function resolveVoiceInputProviderRegistry(settings) {
|
|
|
1810
2156
|
if (settings.openaiProvider === "azure" && !settings.voiceInputOpenaiApiKey && !settings.voiceInputOpenaiBaseUrl) {
|
|
1811
2157
|
continue;
|
|
1812
2158
|
}
|
|
2159
|
+
const priced = voiceInputProviderPricing(
|
|
2160
|
+
settings,
|
|
2161
|
+
issues2,
|
|
2162
|
+
"openai",
|
|
2163
|
+
"OPENGENI_VOICE_INPUT_OPENAI_PRICING_JSON",
|
|
2164
|
+
settings.voiceInputOpenaiPricingJson,
|
|
2165
|
+
settings.voiceInputOpenaiModel
|
|
2166
|
+
);
|
|
2167
|
+
if (!priced.usable) continue;
|
|
1813
2168
|
providers.push({
|
|
1814
2169
|
id: "openai",
|
|
1815
2170
|
kind: "openai",
|
|
2171
|
+
pricing: priced.pricing,
|
|
1816
2172
|
apiKey,
|
|
1817
2173
|
baseUrl: (settings.voiceInputOpenaiBaseUrl ?? settings.openaiBaseUrl ?? "https://api.openai.com/v1").replace(/\/+$/, ""),
|
|
1818
2174
|
model: settings.voiceInputOpenaiModel
|
|
@@ -1832,6 +2188,17 @@ function resolveVoiceInputProviderRegistry(settings) {
|
|
|
1832
2188
|
if (settings.openaiProvider !== "azure" && !settings.voiceInputAzureEndpoint && !settings.voiceInputAzureDeployment && !settings.voiceInputAzureApiKey && !settings.voiceInputAzureAdToken) {
|
|
1833
2189
|
continue;
|
|
1834
2190
|
}
|
|
2191
|
+
const model = settings.voiceInputAzureModel ?? deployment;
|
|
2192
|
+
const priced = voiceInputProviderPricing(
|
|
2193
|
+
settings,
|
|
2194
|
+
issues2,
|
|
2195
|
+
"azure-openai",
|
|
2196
|
+
"OPENGENI_VOICE_INPUT_AZURE_PRICING_JSON",
|
|
2197
|
+
settings.voiceInputAzurePricingJson,
|
|
2198
|
+
model
|
|
2199
|
+
);
|
|
2200
|
+
if (!priced.usable) continue;
|
|
2201
|
+
const pricing = priced.pricing;
|
|
1835
2202
|
providers.push({
|
|
1836
2203
|
id: "azure-openai",
|
|
1837
2204
|
kind: "azure-openai",
|
|
@@ -1839,7 +2206,9 @@ function resolveVoiceInputProviderRegistry(settings) {
|
|
|
1839
2206
|
deployment,
|
|
1840
2207
|
apiVersion,
|
|
1841
2208
|
apiKey: isUsableVoiceInputSecret(apiKey) ? apiKey : null,
|
|
1842
|
-
adToken: isUsableVoiceInputSecret(adToken) ? adToken : null
|
|
2209
|
+
adToken: isUsableVoiceInputSecret(adToken) ? adToken : null,
|
|
2210
|
+
model,
|
|
2211
|
+
pricing
|
|
1843
2212
|
});
|
|
1844
2213
|
continue;
|
|
1845
2214
|
}
|
|
@@ -1861,25 +2230,163 @@ function resolveVoiceInputProviderRegistry(settings) {
|
|
|
1861
2230
|
});
|
|
1862
2231
|
}
|
|
1863
2232
|
}
|
|
1864
|
-
return providers;
|
|
2233
|
+
return { providers, issues: issues2 };
|
|
2234
|
+
}
|
|
2235
|
+
var VoiceInputPricingSchema = z5.object({
|
|
2236
|
+
microsPerMinute: z5.number().int().positive().max(1e8),
|
|
2237
|
+
inputMicrosPerMillionTokens: z5.number().int().nonnegative().max(1e9).optional(),
|
|
2238
|
+
audioInputMicrosPerMillionTokens: z5.number().int().nonnegative().max(1e9).optional(),
|
|
2239
|
+
outputMicrosPerMillionTokens: z5.number().int().nonnegative().max(1e9).optional(),
|
|
2240
|
+
marginBps: z5.number().int().min(0).max(1e5).optional()
|
|
2241
|
+
}).strict().superRefine((pricing, ctx) => {
|
|
2242
|
+
const input = pricing.inputMicrosPerMillionTokens !== void 0;
|
|
2243
|
+
const output = pricing.outputMicrosPerMillionTokens !== void 0;
|
|
2244
|
+
if (input !== output) {
|
|
2245
|
+
ctx.addIssue({
|
|
2246
|
+
code: "custom",
|
|
2247
|
+
message: "inputMicrosPerMillionTokens and outputMicrosPerMillionTokens are set together"
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
if (pricing.audioInputMicrosPerMillionTokens !== void 0 && !input) {
|
|
2251
|
+
ctx.addIssue({
|
|
2252
|
+
code: "custom",
|
|
2253
|
+
message: "audioInputMicrosPerMillionTokens requires the token input/output rates"
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
});
|
|
2257
|
+
var defaultVoiceInputPricing = {
|
|
2258
|
+
// Audio tokens are listed separately from text tokens on the model pages;
|
|
2259
|
+
// set explicitly so the audio rate never silently follows a text-rate edit.
|
|
2260
|
+
"gpt-4o-transcribe": {
|
|
2261
|
+
microsPerMinute: 6e3,
|
|
2262
|
+
inputMicrosPerMillionTokens: 25e5,
|
|
2263
|
+
audioInputMicrosPerMillionTokens: 25e5,
|
|
2264
|
+
outputMicrosPerMillionTokens: 1e7,
|
|
2265
|
+
marginBps: 500
|
|
2266
|
+
},
|
|
2267
|
+
"gpt-4o-transcribe-diarize": {
|
|
2268
|
+
microsPerMinute: 6e3,
|
|
2269
|
+
inputMicrosPerMillionTokens: 25e5,
|
|
2270
|
+
audioInputMicrosPerMillionTokens: 25e5,
|
|
2271
|
+
outputMicrosPerMillionTokens: 1e7,
|
|
2272
|
+
marginBps: 500
|
|
2273
|
+
},
|
|
2274
|
+
"gpt-4o-mini-transcribe": {
|
|
2275
|
+
microsPerMinute: 3e3,
|
|
2276
|
+
inputMicrosPerMillionTokens: 125e4,
|
|
2277
|
+
audioInputMicrosPerMillionTokens: 125e4,
|
|
2278
|
+
outputMicrosPerMillionTokens: 5e6,
|
|
2279
|
+
marginBps: 500
|
|
2280
|
+
},
|
|
2281
|
+
"gpt-transcribe": { microsPerMinute: 4500, marginBps: 500 },
|
|
2282
|
+
whisper: { microsPerMinute: 6e3, marginBps: 500 },
|
|
2283
|
+
"whisper-1": { microsPerMinute: 6e3, marginBps: 500 }
|
|
2284
|
+
};
|
|
2285
|
+
function canonicalVoiceInputModel(model) {
|
|
2286
|
+
return model.trim().toLowerCase().replace(/-\d{4}-\d{2}-\d{2}$/, "");
|
|
2287
|
+
}
|
|
2288
|
+
function voiceInputModelReportsDurationOnly(model) {
|
|
2289
|
+
return canonicalVoiceInputModel(model).startsWith("whisper");
|
|
2290
|
+
}
|
|
2291
|
+
function parseVoiceInputPricingJson(raw, env = "voice-input pricing JSON") {
|
|
2292
|
+
if (raw === void 0 || raw.trim() === "") return null;
|
|
2293
|
+
let parsed;
|
|
2294
|
+
try {
|
|
2295
|
+
parsed = JSON.parse(raw);
|
|
2296
|
+
} catch {
|
|
2297
|
+
throw new Error(`${env} must be valid JSON`);
|
|
2298
|
+
}
|
|
2299
|
+
const result = VoiceInputPricingSchema.safeParse(parsed);
|
|
2300
|
+
if (!result.success) {
|
|
2301
|
+
throw new Error(
|
|
2302
|
+
`${env} is invalid: ${result.error.issues.map((issue) => issue.message).join("; ")}`
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
return result.data;
|
|
2306
|
+
}
|
|
2307
|
+
function resolveVoiceInputPricing(raw, model) {
|
|
2308
|
+
return parseVoiceInputPricingJson(raw) ?? defaultVoiceInputPricing[canonicalVoiceInputModel(model)] ?? null;
|
|
2309
|
+
}
|
|
2310
|
+
function safeResolveVoiceInputPricing(raw, model, env) {
|
|
2311
|
+
let explicit;
|
|
2312
|
+
try {
|
|
2313
|
+
explicit = parseVoiceInputPricingJson(raw, env);
|
|
2314
|
+
} catch (error) {
|
|
2315
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
2316
|
+
}
|
|
2317
|
+
return {
|
|
2318
|
+
ok: true,
|
|
2319
|
+
pricing: explicit ?? defaultVoiceInputPricing[canonicalVoiceInputModel(model)] ?? null
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
function voiceInputCreditBillingActive(settings) {
|
|
2323
|
+
return settings.billingMode === "stripe" || settings.usageLimitsMode === "managed";
|
|
2324
|
+
}
|
|
2325
|
+
function voiceInputPricingHasTokenRates(pricing) {
|
|
2326
|
+
return pricing.inputMicrosPerMillionTokens !== void 0 && pricing.outputMicrosPerMillionTokens !== void 0;
|
|
2327
|
+
}
|
|
2328
|
+
function calculateVoiceInputCost(pricing, usage) {
|
|
2329
|
+
let numerator;
|
|
2330
|
+
let denominator;
|
|
2331
|
+
if (usage.kind === "tokens") {
|
|
2332
|
+
if (pricing.inputMicrosPerMillionTokens === void 0 || pricing.outputMicrosPerMillionTokens === void 0) {
|
|
2333
|
+
throw new Error("voice-input token usage requires token pricing");
|
|
2334
|
+
}
|
|
2335
|
+
for (const value of [
|
|
2336
|
+
usage.inputTokens,
|
|
2337
|
+
usage.audioInputTokens,
|
|
2338
|
+
usage.textInputTokens,
|
|
2339
|
+
usage.outputTokens
|
|
2340
|
+
]) {
|
|
2341
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
2342
|
+
throw new Error("voice-input token usage must be non-negative integers");
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
const audioRate = pricing.audioInputMicrosPerMillionTokens ?? pricing.inputMicrosPerMillionTokens;
|
|
2346
|
+
const unattributed = Math.max(
|
|
2347
|
+
0,
|
|
2348
|
+
usage.inputTokens - usage.audioInputTokens - usage.textInputTokens
|
|
2349
|
+
);
|
|
2350
|
+
numerator = BigInt(usage.audioInputTokens + unattributed) * BigInt(audioRate) + BigInt(usage.textInputTokens) * BigInt(pricing.inputMicrosPerMillionTokens) + BigInt(usage.outputTokens) * BigInt(pricing.outputMicrosPerMillionTokens);
|
|
2351
|
+
denominator = 1000000n;
|
|
2352
|
+
} else {
|
|
2353
|
+
if (!Number.isFinite(usage.seconds) || usage.seconds < 0) {
|
|
2354
|
+
throw new Error("voice-input duration must be a non-negative number of seconds");
|
|
2355
|
+
}
|
|
2356
|
+
numerator = BigInt(Math.ceil(usage.seconds * 1e3)) * BigInt(pricing.microsPerMinute);
|
|
2357
|
+
denominator = 60000n;
|
|
2358
|
+
}
|
|
2359
|
+
const margin = BigInt(1e4 + (pricing.marginBps ?? 0));
|
|
2360
|
+
const provider = (numerator + denominator - 1n) / denominator;
|
|
2361
|
+
const scaled = denominator * 10000n;
|
|
2362
|
+
const credit = (numerator * margin + scaled - 1n) / scaled;
|
|
2363
|
+
if (credit > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
2364
|
+
throw new Error("voice-input cost exceeds the supported billing range");
|
|
2365
|
+
}
|
|
2366
|
+
return { providerCostMicros: Number(provider), creditCostMicros: Number(credit) };
|
|
2367
|
+
}
|
|
2368
|
+
function unpricedVoiceInputProviders(settings) {
|
|
2369
|
+
return voiceInputPricingIssues(settings).flatMap(
|
|
2370
|
+
(issue) => issue.reason === "unpriced" ? [issue.providerId] : []
|
|
2371
|
+
);
|
|
1865
2372
|
}
|
|
1866
2373
|
function voiceInputDeploymentConfigured(settings) {
|
|
1867
2374
|
return resolveVoiceInputProviderRegistry(settings).some(
|
|
1868
2375
|
(provider) => provider.kind !== "codex-subscription" && provider.kind !== "supergrok-subscription"
|
|
1869
2376
|
);
|
|
1870
2377
|
}
|
|
1871
|
-
var ModelPricingSchema =
|
|
1872
|
-
inputMicrosPerMillionTokens:
|
|
1873
|
-
cachedInputMicrosPerMillionTokens:
|
|
1874
|
-
cacheWriteMicrosPerMillionTokens:
|
|
1875
|
-
outputMicrosPerMillionTokens:
|
|
1876
|
-
marginBps:
|
|
2378
|
+
var ModelPricingSchema = z5.object({
|
|
2379
|
+
inputMicrosPerMillionTokens: z5.number().int().nonnegative(),
|
|
2380
|
+
cachedInputMicrosPerMillionTokens: z5.number().int().nonnegative().optional(),
|
|
2381
|
+
cacheWriteMicrosPerMillionTokens: z5.number().int().nonnegative().optional(),
|
|
2382
|
+
outputMicrosPerMillionTokens: z5.number().int().nonnegative(),
|
|
2383
|
+
marginBps: z5.number().int().min(0).max(1e5).optional()
|
|
1877
2384
|
});
|
|
1878
|
-
var ModelPricingScheduleSchema =
|
|
2385
|
+
var ModelPricingScheduleSchema = z5.object({
|
|
1879
2386
|
default: ModelPricingSchema,
|
|
1880
|
-
inputTokenTiers:
|
|
1881
|
-
|
|
1882
|
-
minimumInputTokens:
|
|
2387
|
+
inputTokenTiers: z5.array(
|
|
2388
|
+
z5.object({
|
|
2389
|
+
minimumInputTokens: z5.number().int().nonnegative(),
|
|
1883
2390
|
pricing: ModelPricingSchema
|
|
1884
2391
|
})
|
|
1885
2392
|
).optional()
|
|
@@ -1896,10 +2403,10 @@ var ModelPricingScheduleSchema = z3.object({
|
|
|
1896
2403
|
previous = tier.minimumInputTokens;
|
|
1897
2404
|
}
|
|
1898
2405
|
});
|
|
1899
|
-
var CapabilitySupportV1 =
|
|
1900
|
-
var CapabilityStateV1Schema =
|
|
2406
|
+
var CapabilitySupportV1 = z5.enum(["supported", "unsupported", "unknown"]);
|
|
2407
|
+
var CapabilityStateV1Schema = z5.object({
|
|
1901
2408
|
upstream: CapabilitySupportV1,
|
|
1902
|
-
runnable:
|
|
2409
|
+
runnable: z5.boolean()
|
|
1903
2410
|
}).superRefine((state, ctx) => {
|
|
1904
2411
|
if (state.upstream === "unsupported" && state.runnable) {
|
|
1905
2412
|
ctx.addIssue({
|
|
@@ -1909,17 +2416,17 @@ var CapabilityStateV1Schema = z3.object({
|
|
|
1909
2416
|
});
|
|
1910
2417
|
}
|
|
1911
2418
|
});
|
|
1912
|
-
var ModelModalityV1 =
|
|
1913
|
-
var ModelLatencyModeV1 =
|
|
1914
|
-
var ModelCapabilitiesV1Schema =
|
|
2419
|
+
var ModelModalityV1 = z5.enum(["text", "image", "audio"]);
|
|
2420
|
+
var ModelLatencyModeV1 = z5.enum(["standard", "priority", "fast"]);
|
|
2421
|
+
var ModelCapabilitiesV1Schema = z5.object({
|
|
1915
2422
|
reasoning: CapabilityStateV1Schema.extend({
|
|
1916
|
-
efforts:
|
|
2423
|
+
efforts: z5.array(ReasoningEffort),
|
|
1917
2424
|
defaultEffort: ReasoningEffort.nullable(),
|
|
1918
|
-
required:
|
|
2425
|
+
required: z5.boolean()
|
|
1919
2426
|
}),
|
|
1920
2427
|
functionCalling: CapabilityStateV1Schema,
|
|
1921
2428
|
structuredOutput: CapabilityStateV1Schema,
|
|
1922
|
-
hostedTools:
|
|
2429
|
+
hostedTools: z5.object({
|
|
1923
2430
|
webSearch: CapabilityStateV1Schema,
|
|
1924
2431
|
xSearch: CapabilityStateV1Schema,
|
|
1925
2432
|
codeExecution: CapabilityStateV1Schema,
|
|
@@ -1928,24 +2435,24 @@ var ModelCapabilitiesV1Schema = z3.object({
|
|
|
1928
2435
|
runnable: false
|
|
1929
2436
|
})
|
|
1930
2437
|
}),
|
|
1931
|
-
inputModalities:
|
|
2438
|
+
inputModalities: z5.array(ModelModalityV1).min(1),
|
|
1932
2439
|
/** Exact MIME types accepted as typed `input_file`; `text/*` is allowed. */
|
|
1933
|
-
inputFileMediaTypes:
|
|
1934
|
-
outputModalities:
|
|
1935
|
-
transports:
|
|
2440
|
+
inputFileMediaTypes: z5.array(z5.string()).default([]),
|
|
2441
|
+
outputModalities: z5.array(ModelModalityV1).min(1),
|
|
2442
|
+
transports: z5.object({
|
|
1936
2443
|
sse: CapabilityStateV1Schema,
|
|
1937
2444
|
responsesWebSocket: CapabilityStateV1Schema,
|
|
1938
2445
|
realtimeAudio: CapabilityStateV1Schema
|
|
1939
2446
|
}),
|
|
1940
2447
|
promptCaching: CapabilityStateV1Schema.extend({
|
|
1941
|
-
mode:
|
|
2448
|
+
mode: z5.enum(["implicit", "automatic", "none"])
|
|
1942
2449
|
}).optional(),
|
|
1943
|
-
latencyModes:
|
|
1944
|
-
|
|
2450
|
+
latencyModes: z5.array(
|
|
2451
|
+
z5.object({
|
|
1945
2452
|
id: ModelLatencyModeV1,
|
|
1946
2453
|
upstream: CapabilitySupportV1,
|
|
1947
|
-
runnable:
|
|
1948
|
-
billingMultiplierBps:
|
|
2454
|
+
runnable: z5.boolean(),
|
|
2455
|
+
billingMultiplierBps: z5.number().int().positive().optional()
|
|
1949
2456
|
})
|
|
1950
2457
|
).min(1)
|
|
1951
2458
|
}).superRefine((capabilities, ctx) => {
|
|
@@ -1999,9 +2506,9 @@ var ModelCapabilitiesV1Schema = z3.object({
|
|
|
1999
2506
|
}
|
|
2000
2507
|
}
|
|
2001
2508
|
});
|
|
2002
|
-
var ModelProviderApi =
|
|
2003
|
-
var ModelProviderWireProfile =
|
|
2004
|
-
var RegistryProviderKind =
|
|
2509
|
+
var ModelProviderApi = z5.enum(["responses", "chat", "anthropic-messages"]);
|
|
2510
|
+
var ModelProviderWireProfile = z5.enum(["openai", "azure-openai"]);
|
|
2511
|
+
var RegistryProviderKind = z5.enum([
|
|
2005
2512
|
"api-key",
|
|
2006
2513
|
"anonymous",
|
|
2007
2514
|
"codex-subscription",
|
|
@@ -2018,38 +2525,38 @@ var RegistryProviderKind = z3.enum([
|
|
|
2018
2525
|
"anthropic-workspace",
|
|
2019
2526
|
"claude-subscription-workspace"
|
|
2020
2527
|
]);
|
|
2021
|
-
var ModelLogoUrlSchema =
|
|
2528
|
+
var ModelLogoUrlSchema = z5.string().refine(
|
|
2022
2529
|
(value) => modelLogoUrl({ id: "", logoUrl: value }) !== null,
|
|
2023
2530
|
"model logoUrl must be an HTTPS URL without embedded credentials, at most 2048 characters"
|
|
2024
2531
|
);
|
|
2025
|
-
var RegistryModelSchema =
|
|
2026
|
-
id:
|
|
2532
|
+
var RegistryModelSchema = z5.object({
|
|
2533
|
+
id: z5.string().min(1),
|
|
2027
2534
|
// canonical OpenGeni product id
|
|
2028
|
-
upstreamModelId:
|
|
2535
|
+
upstreamModelId: z5.string().min(1).optional(),
|
|
2029
2536
|
// exact provider slug; defaults to id
|
|
2030
|
-
aliases:
|
|
2537
|
+
aliases: z5.array(z5.string().min(1)).optional(),
|
|
2031
2538
|
// accepted input only; never sent upstream
|
|
2032
|
-
label:
|
|
2539
|
+
label: z5.string().min(1).optional(),
|
|
2033
2540
|
// display name; defaults to id
|
|
2034
|
-
shortLabel:
|
|
2541
|
+
shortLabel: z5.string().min(1).max(64).optional(),
|
|
2035
2542
|
// compact UI label; optional
|
|
2036
2543
|
logoUrl: ModelLogoUrlSchema.optional(),
|
|
2037
|
-
contextWindowTokens:
|
|
2038
|
-
effectiveContextWindowTokens:
|
|
2039
|
-
autoCompactTokenLimit:
|
|
2544
|
+
contextWindowTokens: z5.number().int().positive().optional(),
|
|
2545
|
+
effectiveContextWindowTokens: z5.number().int().positive().optional(),
|
|
2546
|
+
autoCompactTokenLimit: z5.number().int().positive().optional(),
|
|
2040
2547
|
// Canonical model-facing function/tool-result policy. The runtime applies
|
|
2041
2548
|
// the same 1.2x serialization allowance as Codex when materializing output.
|
|
2042
|
-
toolOutputTruncationTokens:
|
|
2043
|
-
reasoningEffort:
|
|
2549
|
+
toolOutputTruncationTokens: z5.number().int().positive().optional(),
|
|
2550
|
+
reasoningEffort: z5.boolean().optional(),
|
|
2044
2551
|
// legacy compatibility input/projection
|
|
2045
|
-
hostedWebSearch:
|
|
2552
|
+
hostedWebSearch: z5.boolean().optional(),
|
|
2046
2553
|
// legacy compatibility input/projection
|
|
2047
2554
|
capabilities: ModelCapabilitiesV1Schema.optional(),
|
|
2048
|
-
pricing:
|
|
2555
|
+
pricing: z5.union([ModelPricingSchema, ModelPricingScheduleSchema]).optional(),
|
|
2049
2556
|
// Reserved normalized contracts are derived by OpenGeni in V1. Generic
|
|
2050
2557
|
// registry JSON must not opt itself into workspace BYOK or reattribute cost.
|
|
2051
|
-
credentialSource:
|
|
2052
|
-
billing:
|
|
2558
|
+
credentialSource: z5.never().optional(),
|
|
2559
|
+
billing: z5.never().optional()
|
|
2053
2560
|
}).superRefine((model, ctx) => {
|
|
2054
2561
|
if (model.capabilities && model.reasoningEffort !== void 0 && model.reasoningEffort !== model.capabilities.reasoning.runnable) {
|
|
2055
2562
|
ctx.addIssue({
|
|
@@ -2066,54 +2573,54 @@ var RegistryModelSchema = z3.object({
|
|
|
2066
2573
|
});
|
|
2067
2574
|
}
|
|
2068
2575
|
});
|
|
2069
|
-
var ClaudeSubscriptionIdentity =
|
|
2070
|
-
accountUuid:
|
|
2071
|
-
deviceId:
|
|
2576
|
+
var ClaudeSubscriptionIdentity = z5.object({
|
|
2577
|
+
accountUuid: z5.union([z5.string().uuid(), z5.literal("")]),
|
|
2578
|
+
deviceId: z5.string().regex(/^[a-f0-9]{64}$/)
|
|
2072
2579
|
}).strict();
|
|
2073
|
-
var ClaudeSubscriptionCredential =
|
|
2074
|
-
version:
|
|
2075
|
-
token:
|
|
2580
|
+
var ClaudeSubscriptionCredential = z5.object({
|
|
2581
|
+
version: z5.literal(1),
|
|
2582
|
+
token: z5.string().regex(/^sk-ant-oat[0-9]+-\S+$/),
|
|
2076
2583
|
identity: ClaudeSubscriptionIdentity,
|
|
2077
|
-
oauth:
|
|
2078
|
-
refreshToken:
|
|
2079
|
-
expiresAt:
|
|
2080
|
-
scopes:
|
|
2584
|
+
oauth: z5.object({
|
|
2585
|
+
refreshToken: z5.string().min(1).max(16384),
|
|
2586
|
+
expiresAt: z5.string().datetime(),
|
|
2587
|
+
scopes: z5.array(z5.string().min(1).max(256)).min(1).max(32)
|
|
2081
2588
|
}).strict().optional()
|
|
2082
2589
|
}).strict();
|
|
2083
|
-
var AnthropicProviderOptions =
|
|
2590
|
+
var AnthropicProviderOptions = z5.object({
|
|
2084
2591
|
identity: ClaudeSubscriptionIdentity.optional(),
|
|
2085
2592
|
// Native connection provenance only; never included in Anthropic request bodies.
|
|
2086
|
-
credentialBinding:
|
|
2087
|
-
connectionId:
|
|
2088
|
-
credentialVersion:
|
|
2593
|
+
credentialBinding: z5.object({
|
|
2594
|
+
connectionId: z5.string().uuid(),
|
|
2595
|
+
credentialVersion: z5.number().int().positive()
|
|
2089
2596
|
}).strict().optional(),
|
|
2090
|
-
auth:
|
|
2091
|
-
cacheTtl:
|
|
2092
|
-
maxOutputTokens:
|
|
2093
|
-
streamIdleTimeoutMs:
|
|
2597
|
+
auth: z5.enum(["api-key", "oauth"]).default("api-key"),
|
|
2598
|
+
cacheTtl: z5.enum(["5m", "1h", "off"]).default("5m"),
|
|
2599
|
+
maxOutputTokens: z5.number().int().positive().default(32e3),
|
|
2600
|
+
streamIdleTimeoutMs: z5.number().int().positive().default(6e5)
|
|
2094
2601
|
});
|
|
2095
|
-
var RegistryProviderSchema =
|
|
2602
|
+
var RegistryProviderSchema = z5.object({
|
|
2096
2603
|
kind: RegistryProviderKind.default("api-key"),
|
|
2097
|
-
id:
|
|
2604
|
+
id: z5.string().min(1).regex(registryId),
|
|
2098
2605
|
// stable provider id, e.g. "fireworks"
|
|
2099
|
-
label:
|
|
2606
|
+
label: z5.string().min(1).optional(),
|
|
2100
2607
|
api: ModelProviderApi.default("chat"),
|
|
2101
2608
|
anthropic: AnthropicProviderOptions.optional(),
|
|
2102
2609
|
wireProfile: ModelProviderWireProfile.default("openai"),
|
|
2103
|
-
baseUrl:
|
|
2104
|
-
apiKey:
|
|
2610
|
+
baseUrl: z5.string().url(),
|
|
2611
|
+
apiKey: z5.string().optional(),
|
|
2105
2612
|
// inline key (pragmatic) ...
|
|
2106
|
-
apiKeyEnv:
|
|
2613
|
+
apiKeyEnv: z5.string().optional(),
|
|
2107
2614
|
// ... OR name of the env var holding the key (preferred)
|
|
2108
|
-
defaultQuery:
|
|
2109
|
-
defaultHeaders:
|
|
2110
|
-
publicDefaultQueryNames:
|
|
2111
|
-
publicDefaultHeaderNames:
|
|
2615
|
+
defaultQuery: z5.record(z5.string(), z5.string()).optional(),
|
|
2616
|
+
defaultHeaders: z5.record(z5.string(), z5.string()).optional(),
|
|
2617
|
+
publicDefaultQueryNames: z5.array(z5.string().min(1)).optional(),
|
|
2618
|
+
publicDefaultHeaderNames: z5.array(z5.string().min(1)).optional(),
|
|
2112
2619
|
// V1 derives these from provider kind. Workspace BYOK is deliberately not a
|
|
2113
2620
|
// registry switch and requires a separately reviewed encrypted broker.
|
|
2114
|
-
credentialSource:
|
|
2115
|
-
billing:
|
|
2116
|
-
models:
|
|
2621
|
+
credentialSource: z5.never().optional(),
|
|
2622
|
+
billing: z5.never().optional(),
|
|
2623
|
+
models: z5.array(RegistryModelSchema).min(1)
|
|
2117
2624
|
}).superRefine((provider, ctx) => {
|
|
2118
2625
|
if (provider.kind !== "anonymous") {
|
|
2119
2626
|
return;
|
|
@@ -2189,15 +2696,15 @@ var RESERVED_MODEL_PROVIDER_IDS = /* @__PURE__ */ new Set([
|
|
|
2189
2696
|
"workspace-anthropic",
|
|
2190
2697
|
"workspace-claude-subscription"
|
|
2191
2698
|
]);
|
|
2192
|
-
var ModelCostClass =
|
|
2193
|
-
var ConfiguredModelCostClass =
|
|
2699
|
+
var ModelCostClass = z5.enum(["free", "credits"]);
|
|
2700
|
+
var ConfiguredModelCostClass = z5.enum([
|
|
2194
2701
|
"free",
|
|
2195
2702
|
"credits",
|
|
2196
2703
|
"subscription",
|
|
2197
2704
|
"workspace",
|
|
2198
2705
|
"organization"
|
|
2199
2706
|
]);
|
|
2200
|
-
var ModelNote =
|
|
2707
|
+
var ModelNote = z5.string().max(500).refine((value) => !/[\r\n|]/u.test(value), {
|
|
2201
2708
|
message: "model notes must not contain newlines or the | field separator"
|
|
2202
2709
|
});
|
|
2203
2710
|
function parseModelCostPolicyJson(raw) {
|
|
@@ -2210,7 +2717,7 @@ function parseModelCostPolicyJson(raw) {
|
|
|
2210
2717
|
{ cause: error }
|
|
2211
2718
|
);
|
|
2212
2719
|
}
|
|
2213
|
-
return
|
|
2720
|
+
return z5.record(z5.string().min(1), ModelCostClass).parse(parsed);
|
|
2214
2721
|
}
|
|
2215
2722
|
function parseModelNotesJson(raw) {
|
|
2216
2723
|
let parsed;
|
|
@@ -2222,47 +2729,47 @@ function parseModelNotesJson(raw) {
|
|
|
2222
2729
|
{ cause: error }
|
|
2223
2730
|
);
|
|
2224
2731
|
}
|
|
2225
|
-
return
|
|
2732
|
+
return z5.record(z5.string().min(1), ModelNote).parse(parsed);
|
|
2226
2733
|
}
|
|
2227
2734
|
function configuredModelNotes(settings) {
|
|
2228
2735
|
return parseModelNotesJson(settings.modelNotesJson);
|
|
2229
2736
|
}
|
|
2230
|
-
var GatewayCatalogModel =
|
|
2231
|
-
productId:
|
|
2232
|
-
workspaceProductId:
|
|
2233
|
-
upstreamModelId:
|
|
2234
|
-
label:
|
|
2235
|
-
shortLabel:
|
|
2737
|
+
var GatewayCatalogModel = z5.object({
|
|
2738
|
+
productId: z5.string().min(1),
|
|
2739
|
+
workspaceProductId: z5.string().min(1).startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX),
|
|
2740
|
+
upstreamModelId: z5.string().min(1),
|
|
2741
|
+
label: z5.string().min(1),
|
|
2742
|
+
shortLabel: z5.string().min(1).max(64).optional(),
|
|
2236
2743
|
logoUrl: ModelLogoUrlSchema.optional(),
|
|
2237
|
-
providers:
|
|
2238
|
-
implicitCaching:
|
|
2239
|
-
vision:
|
|
2240
|
-
inputFileMediaTypes:
|
|
2241
|
-
contextWindowTokens:
|
|
2242
|
-
effectiveContextWindowTokens:
|
|
2243
|
-
autoCompactTokenLimit:
|
|
2244
|
-
pricing:
|
|
2245
|
-
credentialSource:
|
|
2246
|
-
billing:
|
|
2247
|
-
apiKey:
|
|
2744
|
+
providers: z5.array(z5.string().min(1)).min(1),
|
|
2745
|
+
implicitCaching: z5.boolean().default(false),
|
|
2746
|
+
vision: z5.boolean().default(false),
|
|
2747
|
+
inputFileMediaTypes: z5.array(z5.string().min(1)).default([]),
|
|
2748
|
+
contextWindowTokens: z5.number().int().positive().default(1e6),
|
|
2749
|
+
effectiveContextWindowTokens: z5.number().int().positive().default(9e5),
|
|
2750
|
+
autoCompactTokenLimit: z5.number().int().positive().default(85e4),
|
|
2751
|
+
pricing: z5.union([ModelPricingSchema, ModelPricingScheduleSchema]).optional(),
|
|
2752
|
+
credentialSource: z5.never().optional(),
|
|
2753
|
+
billing: z5.never().optional(),
|
|
2754
|
+
apiKey: z5.never().optional()
|
|
2248
2755
|
}).strict();
|
|
2249
|
-
var OpenRouterCatalogModel =
|
|
2250
|
-
upstreamModelId:
|
|
2251
|
-
label:
|
|
2252
|
-
shortLabel:
|
|
2756
|
+
var OpenRouterCatalogModel = z5.object({
|
|
2757
|
+
upstreamModelId: z5.string().min(1).endsWith(":free"),
|
|
2758
|
+
label: z5.string().min(1),
|
|
2759
|
+
shortLabel: z5.string().min(1).max(64).optional(),
|
|
2253
2760
|
logoUrl: ModelLogoUrlSchema.optional(),
|
|
2254
|
-
aliases:
|
|
2761
|
+
aliases: z5.array(z5.string().min(1)).default([]),
|
|
2255
2762
|
capabilities: ModelCapabilitiesV1Schema,
|
|
2256
|
-
contextWindowTokens:
|
|
2257
|
-
effectiveContextWindowTokens:
|
|
2258
|
-
autoCompactTokenLimit:
|
|
2259
|
-
toolOutputTruncationTokens:
|
|
2260
|
-
credentialSource:
|
|
2261
|
-
billing:
|
|
2262
|
-
pricing:
|
|
2263
|
-
apiKey:
|
|
2763
|
+
contextWindowTokens: z5.number().int().positive().optional(),
|
|
2764
|
+
effectiveContextWindowTokens: z5.number().int().positive().optional(),
|
|
2765
|
+
autoCompactTokenLimit: z5.number().int().positive().optional(),
|
|
2766
|
+
toolOutputTruncationTokens: z5.number().int().positive().optional(),
|
|
2767
|
+
credentialSource: z5.never().optional(),
|
|
2768
|
+
billing: z5.never().optional(),
|
|
2769
|
+
pricing: z5.never().optional(),
|
|
2770
|
+
apiKey: z5.never().optional()
|
|
2264
2771
|
}).strict();
|
|
2265
|
-
var DeploymentRegistryBaseUrl =
|
|
2772
|
+
var DeploymentRegistryBaseUrl = z5.string().url().superRefine((value, context) => {
|
|
2266
2773
|
const url = new URL(value);
|
|
2267
2774
|
if (url.username || url.password) {
|
|
2268
2775
|
context.addIssue({
|
|
@@ -2283,30 +2790,30 @@ var DeploymentRegistryBaseUrl = z3.string().url().superRefine((value, context) =
|
|
|
2283
2790
|
});
|
|
2284
2791
|
}
|
|
2285
2792
|
});
|
|
2286
|
-
var DeploymentRegistryProviderKind =
|
|
2793
|
+
var DeploymentRegistryProviderKind = z5.enum(["api-key", "anonymous"]);
|
|
2287
2794
|
var DeploymentRegistryModelSchema = RegistryModelSchema.safeExtend({
|
|
2288
|
-
pricing:
|
|
2795
|
+
pricing: z5.never().optional()
|
|
2289
2796
|
}).strict();
|
|
2290
2797
|
var DeploymentRegistryProviderSchema = RegistryProviderSchema.safeExtend({
|
|
2291
2798
|
kind: DeploymentRegistryProviderKind.default("api-key"),
|
|
2292
2799
|
baseUrl: DeploymentRegistryBaseUrl,
|
|
2293
|
-
models:
|
|
2294
|
-
apiKey:
|
|
2295
|
-
apiKeyEnv:
|
|
2296
|
-
defaultHeaders:
|
|
2297
|
-
defaultQuery:
|
|
2298
|
-
publicDefaultHeaderNames:
|
|
2299
|
-
publicDefaultQueryNames:
|
|
2800
|
+
models: z5.array(DeploymentRegistryModelSchema).min(1),
|
|
2801
|
+
apiKey: z5.never().optional(),
|
|
2802
|
+
apiKeyEnv: z5.never().optional(),
|
|
2803
|
+
defaultHeaders: z5.never().optional(),
|
|
2804
|
+
defaultQuery: z5.never().optional(),
|
|
2805
|
+
publicDefaultHeaderNames: z5.never().optional(),
|
|
2806
|
+
publicDefaultQueryNames: z5.never().optional()
|
|
2300
2807
|
}).strict();
|
|
2301
2808
|
var DeploymentGatewayCatalogModelSchema = GatewayCatalogModel.safeExtend({
|
|
2302
|
-
pricing:
|
|
2809
|
+
pricing: z5.never().optional()
|
|
2303
2810
|
}).strict();
|
|
2304
2811
|
var CodexCatalogModelSchema = RegistryModelSchema.safeExtend({
|
|
2305
|
-
retired:
|
|
2306
|
-
id:
|
|
2307
|
-
upstreamModelId:
|
|
2812
|
+
retired: z5.boolean().optional(),
|
|
2813
|
+
id: z5.string().regex(/^codex\/[a-zA-Z0-9][a-zA-Z0-9._-]*$/),
|
|
2814
|
+
upstreamModelId: z5.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/),
|
|
2308
2815
|
capabilities: ModelCapabilitiesV1Schema,
|
|
2309
|
-
pricing:
|
|
2816
|
+
pricing: z5.never().optional()
|
|
2310
2817
|
}).strict().superRefine((model, context) => {
|
|
2311
2818
|
if (model.id !== `${CODEX_MODEL_ID_PREFIX}${model.upstreamModelId}`) {
|
|
2312
2819
|
context.addIssue({
|
|
@@ -2319,22 +2826,22 @@ var CodexCatalogModelSchema = RegistryModelSchema.safeExtend({
|
|
|
2319
2826
|
...model,
|
|
2320
2827
|
capabilities: reviewedCodexCatalogCapabilities(model.upstreamModelId, model.capabilities)
|
|
2321
2828
|
}));
|
|
2322
|
-
var ModelCatalogDocument =
|
|
2323
|
-
schemaVersion:
|
|
2829
|
+
var ModelCatalogDocument = z5.object({
|
|
2830
|
+
schemaVersion: z5.literal(1),
|
|
2324
2831
|
/** Canonical deployment default. Omission preserves the V1 first-built-in
|
|
2325
2832
|
* fallback for existing documents; operators should set this explicitly
|
|
2326
2833
|
* when cutting over a registry or connected-subscription default. */
|
|
2327
|
-
defaultModel:
|
|
2328
|
-
builtInModels:
|
|
2329
|
-
registryProviders:
|
|
2330
|
-
codexModels:
|
|
2331
|
-
gatewayModels:
|
|
2332
|
-
openrouterModels:
|
|
2333
|
-
modelNotes:
|
|
2334
|
-
billing:
|
|
2335
|
-
enabled:
|
|
2336
|
-
apiKey:
|
|
2337
|
-
bands:
|
|
2834
|
+
defaultModel: z5.string().min(1).optional(),
|
|
2835
|
+
builtInModels: z5.array(z5.string().min(1)),
|
|
2836
|
+
registryProviders: z5.array(DeploymentRegistryProviderSchema).default([]),
|
|
2837
|
+
codexModels: z5.array(CodexCatalogModelSchema).optional(),
|
|
2838
|
+
gatewayModels: z5.array(DeploymentGatewayCatalogModelSchema).default([]),
|
|
2839
|
+
openrouterModels: z5.array(OpenRouterCatalogModel).default([]),
|
|
2840
|
+
modelNotes: z5.record(z5.string().min(1), ModelNote).default({}),
|
|
2841
|
+
billing: z5.never().optional(),
|
|
2842
|
+
enabled: z5.never().optional(),
|
|
2843
|
+
apiKey: z5.never().optional(),
|
|
2844
|
+
bands: z5.never().optional()
|
|
2338
2845
|
}).strict().superRefine((document, context) => {
|
|
2339
2846
|
if (document.builtInModels.length === 0 && !document.defaultModel) {
|
|
2340
2847
|
context.addIssue({
|
|
@@ -2493,10 +3000,10 @@ function applyModelCatalogDocument(settings, rawDocument) {
|
|
|
2493
3000
|
};
|
|
2494
3001
|
return resolved;
|
|
2495
3002
|
}
|
|
2496
|
-
var IntegrationOAuthClientConfigSchema =
|
|
2497
|
-
clientId:
|
|
2498
|
-
clientSecret:
|
|
2499
|
-
tokenEndpointAuthMethod:
|
|
3003
|
+
var IntegrationOAuthClientConfigSchema = z5.object({
|
|
3004
|
+
clientId: z5.string().min(1),
|
|
3005
|
+
clientSecret: z5.string().min(1).optional(),
|
|
3006
|
+
tokenEndpointAuthMethod: z5.enum(["none", "client_secret_post", "client_secret_basic"]).default("none")
|
|
2500
3007
|
});
|
|
2501
3008
|
function isManagedOpenRouterFreeRoute(route) {
|
|
2502
3009
|
return route.provider.kind === "openrouter-managed" && route.configured.upstreamModelId.endsWith(":free");
|
|
@@ -2627,7 +3134,7 @@ function configuredGatewayCatalogModels(settings) {
|
|
|
2627
3134
|
if (settings.resolvedGatewayModelsJson === void 0) {
|
|
2628
3135
|
return defaultGatewayCatalogModels();
|
|
2629
3136
|
}
|
|
2630
|
-
return
|
|
3137
|
+
return z5.array(GatewayCatalogModel).parse(JSON.parse(settings.resolvedGatewayModelsJson));
|
|
2631
3138
|
}
|
|
2632
3139
|
function configuredGatewayUpstreamModelIds(settings) {
|
|
2633
3140
|
return configuredGatewayCatalogModels(settings).map((model) => model.upstreamModelId);
|
|
@@ -2646,7 +3153,7 @@ function configuredOpenRouterCatalogModels(settings) {
|
|
|
2646
3153
|
if (settings.resolvedOpenRouterModelsJson === void 0) {
|
|
2647
3154
|
return [...OPENGENI_OPENROUTER_MODELS];
|
|
2648
3155
|
}
|
|
2649
|
-
return
|
|
3156
|
+
return z5.array(OpenRouterCatalogModel).parse(JSON.parse(settings.resolvedOpenRouterModelsJson));
|
|
2650
3157
|
}
|
|
2651
3158
|
function configuredOpenRouterUpstreamModelIds(settings) {
|
|
2652
3159
|
return configuredOpenRouterCatalogModels(settings).map((model) => model.upstreamModelId);
|
|
@@ -3061,6 +3568,7 @@ function getSettings(source = process.env) {
|
|
|
3061
3568
|
delegationSecret: optional("OPENGENI_DELEGATION_SECRET"),
|
|
3062
3569
|
defaultFirstPartyMcpTools: optional("OPENGENI_DEFAULT_FIRST_PARTY_MCP_TOOLS"),
|
|
3063
3570
|
allowedFirstPartyMcpTools: optional("OPENGENI_ALLOWED_FIRST_PARTY_MCP_TOOLS"),
|
|
3571
|
+
artifactMaterializerDeployed: optional("OPENGENI_ARTIFACT_MATERIALIZER_DEPLOYED"),
|
|
3064
3572
|
streamTokenSecret: optional("OPENGENI_STREAM_TOKEN_SECRET"),
|
|
3065
3573
|
streamControlEnabled: optional("OPENGENI_STREAM_CONTROL_ENABLED"),
|
|
3066
3574
|
workDiscoveryEnabled: optional("OPENGENI_WORK_DISCOVERY_ENABLED"),
|
|
@@ -3188,6 +3696,20 @@ function getSettings(source = process.env) {
|
|
|
3188
3696
|
voiceInputAzureApiVersion: optional("OPENGENI_VOICE_INPUT_AZURE_API_VERSION"),
|
|
3189
3697
|
voiceInputAzureApiKey: optional("OPENGENI_VOICE_INPUT_AZURE_API_KEY"),
|
|
3190
3698
|
voiceInputAzureAdToken: optional("OPENGENI_VOICE_INPUT_AZURE_AD_TOKEN"),
|
|
3699
|
+
azureLiveEndpoint: optional("OPENGENI_AZURE_LIVE_ENDPOINT"),
|
|
3700
|
+
azureLiveApiKey: optional("OPENGENI_AZURE_LIVE_API_KEY"),
|
|
3701
|
+
azureLiveDeployment: optional("OPENGENI_AZURE_LIVE_DEPLOYMENT"),
|
|
3702
|
+
azureLiveVoice: optional("OPENGENI_AZURE_LIVE_VOICE"),
|
|
3703
|
+
azureLivePricingJson: optional("OPENGENI_AZURE_LIVE_PRICING_JSON"),
|
|
3704
|
+
aiGatewayRealtimePricingJson: optional("OPENGENI_AI_GATEWAY_REALTIME_PRICING_JSON"),
|
|
3705
|
+
voiceInputMaiEndpoint: optional("OPENGENI_VOICE_INPUT_MAI_ENDPOINT"),
|
|
3706
|
+
voiceInputMaiApiKey: optional("OPENGENI_VOICE_INPUT_MAI_API_KEY"),
|
|
3707
|
+
voiceInputMaiApiVersion: optional("OPENGENI_VOICE_INPUT_MAI_API_VERSION"),
|
|
3708
|
+
voiceInputMaiPricingJson: optional("OPENGENI_VOICE_INPUT_MAI_PRICING_JSON"),
|
|
3709
|
+
voiceInputMaiModel: optional("OPENGENI_VOICE_INPUT_MAI_MODEL"),
|
|
3710
|
+
voiceInputAzureModel: optional("OPENGENI_VOICE_INPUT_AZURE_MODEL"),
|
|
3711
|
+
voiceInputOpenaiPricingJson: optional("OPENGENI_VOICE_INPUT_OPENAI_PRICING_JSON"),
|
|
3712
|
+
voiceInputAzurePricingJson: optional("OPENGENI_VOICE_INPUT_AZURE_PRICING_JSON"),
|
|
3191
3713
|
voiceInputCodexExperimentalEnabled: optional("OPENGENI_VOICE_INPUT_CODEX_EXPERIMENTAL"),
|
|
3192
3714
|
modelPricingJson: optional("OPENGENI_MODEL_PRICING_JSON"),
|
|
3193
3715
|
modelCatalogSource,
|
|
@@ -3218,6 +3740,15 @@ function getSettings(source = process.env) {
|
|
|
3218
3740
|
openaiReasoningEncryptedContent: optional("OPENGENI_OPENAI_REASONING_ENCRYPTED_CONTENT"),
|
|
3219
3741
|
openaiMaxRetries: optional("OPENGENI_OPENAI_MAX_RETRIES"),
|
|
3220
3742
|
webSearchEnabled: optional("OPENGENI_WEB_SEARCH_ENABLED"),
|
|
3743
|
+
webSearchProvider: optional("OPENGENI_WEB_SEARCH_PROVIDER"),
|
|
3744
|
+
webSearchApiKey: optional("OPENGENI_WEB_SEARCH_API_KEY"),
|
|
3745
|
+
webSearchBaseUrl: optional("OPENGENI_WEB_SEARCH_BASE_URL"),
|
|
3746
|
+
webFetchProvider: optional("OPENGENI_WEB_FETCH_PROVIDER"),
|
|
3747
|
+
webFetchApiKey: optional("OPENGENI_WEB_FETCH_API_KEY"),
|
|
3748
|
+
webFetchBaseUrl: optional("OPENGENI_WEB_FETCH_BASE_URL"),
|
|
3749
|
+
webSearchProviderMode: optional("OPENGENI_WEB_SEARCH_PROVIDER_MODE"),
|
|
3750
|
+
webSearchPricingJson: optional("OPENGENI_WEB_SEARCH_PRICING_JSON"),
|
|
3751
|
+
webSearchRequestTimeoutMs: optional("OPENGENI_WEB_SEARCH_REQUEST_TIMEOUT_MS"),
|
|
3221
3752
|
jevApiKey: optional("OPENGENI_JEV_API_KEY"),
|
|
3222
3753
|
jevBaseUrl: optional("OPENGENI_JEV_BASE_URL"),
|
|
3223
3754
|
jevModel: optional("OPENGENI_JEV_MODEL"),
|
|
@@ -3507,10 +4038,18 @@ function resolveFirstPartyDelegationSecret(settings) {
|
|
|
3507
4038
|
}
|
|
3508
4039
|
return settings.productAccessMode === "local" && (settings.environment === "local" || settings.environment === "test") ? LOCAL_FIRST_PARTY_DELEGATION_SECRET : void 0;
|
|
3509
4040
|
}
|
|
4041
|
+
var EDITABLE_ARTIFACT_EXPORT_TOOLS = [
|
|
4042
|
+
"editable_artifact_export",
|
|
4043
|
+
"editable_artifact_export_status"
|
|
4044
|
+
];
|
|
4045
|
+
function deploymentUnavailableFirstPartyMcpTools(settings) {
|
|
4046
|
+
return new Set(settings.artifactMaterializerDeployed ? [] : EDITABLE_ARTIFACT_EXPORT_TOOLS);
|
|
4047
|
+
}
|
|
3510
4048
|
function resolveFirstPartyMcpToolPolicy(settings) {
|
|
4049
|
+
const unavailable = deploymentUnavailableFirstPartyMcpTools(settings);
|
|
3511
4050
|
const allowed2 = currentAgentLearningToolSelection(
|
|
3512
4051
|
settings.allowedFirstPartyMcpTools ?? [...FIRST_PARTY_MCP_TOOL_NAMES]
|
|
3513
|
-
).filter((tool) => !isRetiredNativeAtlassianTool(tool));
|
|
4052
|
+
).filter((tool) => !isRetiredNativeAtlassianTool(tool) && !unavailable.has(tool));
|
|
3514
4053
|
const allowedSet = new Set(allowed2);
|
|
3515
4054
|
const defaults = currentAgentLearningToolSelection(
|
|
3516
4055
|
settings.defaultFirstPartyMcpTools ?? [...DEFAULT_FIRST_PARTY_MCP_TOOLS]
|
|
@@ -3614,25 +4153,25 @@ var MODALITY_ORDER = new Map(["text", "image", "audio"].map((value, index) => [v
|
|
|
3614
4153
|
var LATENCY_MODE_ORDER = new Map(
|
|
3615
4154
|
["standard", "priority", "fast"].map((value, index) => [value, index])
|
|
3616
4155
|
);
|
|
3617
|
-
function normalizeRegistryBaseUrl(value,
|
|
4156
|
+
function normalizeRegistryBaseUrl(value, providerId2) {
|
|
3618
4157
|
const url = new URL(value);
|
|
3619
4158
|
if (url.username || url.password) {
|
|
3620
|
-
throw new Error(`provider ${
|
|
4159
|
+
throw new Error(`provider ${providerId2} baseUrl must not contain userinfo`);
|
|
3621
4160
|
}
|
|
3622
4161
|
if (url.search) {
|
|
3623
4162
|
throw new Error(
|
|
3624
|
-
`provider ${
|
|
4163
|
+
`provider ${providerId2} baseUrl must not contain a query; move query entries to defaultQuery`
|
|
3625
4164
|
);
|
|
3626
4165
|
}
|
|
3627
4166
|
if (url.hash) {
|
|
3628
|
-
throw new Error(`provider ${
|
|
4167
|
+
throw new Error(`provider ${providerId2} baseUrl must not contain a fragment`);
|
|
3629
4168
|
}
|
|
3630
4169
|
return url.toString();
|
|
3631
4170
|
}
|
|
3632
4171
|
function isCredentialLikeMetadataName(name) {
|
|
3633
4172
|
return name.toLowerCase().split(/[-_.]/u).some((part) => CREDENTIAL_LIKE_NAME_PARTS.has(part));
|
|
3634
4173
|
}
|
|
3635
|
-
function normalizeHeaderMap(
|
|
4174
|
+
function normalizeHeaderMap(providerId2, headers) {
|
|
3636
4175
|
if (!headers) {
|
|
3637
4176
|
return void 0;
|
|
3638
4177
|
}
|
|
@@ -3641,19 +4180,19 @@ function normalizeHeaderMap(providerId, headers) {
|
|
|
3641
4180
|
for (const [rawName, value] of Object.entries(headers)) {
|
|
3642
4181
|
if (!HTTP_FIELD_NAME.test(rawName)) {
|
|
3643
4182
|
throw new Error(
|
|
3644
|
-
`provider ${
|
|
4183
|
+
`provider ${providerId2} defaultHeaders contains invalid HTTP field name ${JSON.stringify(rawName)}`
|
|
3645
4184
|
);
|
|
3646
4185
|
}
|
|
3647
4186
|
const name = rawName.toLowerCase();
|
|
3648
4187
|
const previous = rawByNormalized.get(name);
|
|
3649
4188
|
if (previous !== void 0) {
|
|
3650
4189
|
throw new Error(
|
|
3651
|
-
`provider ${
|
|
4190
|
+
`provider ${providerId2} defaultHeaders names ${JSON.stringify(previous)} and ${JSON.stringify(rawName)} collide after lowercase normalization`
|
|
3652
4191
|
);
|
|
3653
4192
|
}
|
|
3654
4193
|
if (name === "authorization") {
|
|
3655
4194
|
throw new Error(
|
|
3656
|
-
`provider ${
|
|
4195
|
+
`provider ${providerId2} defaultHeaders must not override SDK-managed Authorization`
|
|
3657
4196
|
);
|
|
3658
4197
|
}
|
|
3659
4198
|
rawByNormalized.set(name, rawName);
|
|
@@ -3661,7 +4200,7 @@ function normalizeHeaderMap(providerId, headers) {
|
|
|
3661
4200
|
}
|
|
3662
4201
|
return normalized;
|
|
3663
4202
|
}
|
|
3664
|
-
function normalizePublicHeaderNames(
|
|
4203
|
+
function normalizePublicHeaderNames(providerId2, names, headers) {
|
|
3665
4204
|
if (!names) {
|
|
3666
4205
|
return void 0;
|
|
3667
4206
|
}
|
|
@@ -3670,23 +4209,23 @@ function normalizePublicHeaderNames(providerId, names, headers) {
|
|
|
3670
4209
|
for (const rawName of names) {
|
|
3671
4210
|
if (!HTTP_FIELD_NAME.test(rawName)) {
|
|
3672
4211
|
throw new Error(
|
|
3673
|
-
`provider ${
|
|
4212
|
+
`provider ${providerId2} publicDefaultHeaderNames contains invalid HTTP field name ${JSON.stringify(rawName)}`
|
|
3674
4213
|
);
|
|
3675
4214
|
}
|
|
3676
4215
|
const name = rawName.toLowerCase();
|
|
3677
4216
|
if (seen.has(name)) {
|
|
3678
4217
|
throw new Error(
|
|
3679
|
-
`provider ${
|
|
4218
|
+
`provider ${providerId2} publicDefaultHeaderNames contains duplicate normalized name ${JSON.stringify(name)}`
|
|
3680
4219
|
);
|
|
3681
4220
|
}
|
|
3682
4221
|
if (!(name in (headers ?? {}))) {
|
|
3683
4222
|
throw new Error(
|
|
3684
|
-
`provider ${
|
|
4223
|
+
`provider ${providerId2} publicDefaultHeaderNames declares absent defaultHeaders entry ${JSON.stringify(name)}`
|
|
3685
4224
|
);
|
|
3686
4225
|
}
|
|
3687
4226
|
if (isCredentialLikeMetadataName(name)) {
|
|
3688
4227
|
throw new Error(
|
|
3689
|
-
`provider ${
|
|
4228
|
+
`provider ${providerId2} publicDefaultHeaderNames cannot classify credential-like name ${JSON.stringify(name)} as public`
|
|
3690
4229
|
);
|
|
3691
4230
|
}
|
|
3692
4231
|
seen.add(name);
|
|
@@ -3694,18 +4233,18 @@ function normalizePublicHeaderNames(providerId, names, headers) {
|
|
|
3694
4233
|
}
|
|
3695
4234
|
return normalized;
|
|
3696
4235
|
}
|
|
3697
|
-
function normalizeQueryMap(
|
|
4236
|
+
function normalizeQueryMap(providerId2, query) {
|
|
3698
4237
|
if (!query) {
|
|
3699
4238
|
return void 0;
|
|
3700
4239
|
}
|
|
3701
4240
|
for (const name of Object.keys(query)) {
|
|
3702
4241
|
if (!name) {
|
|
3703
|
-
throw new Error(`provider ${
|
|
4242
|
+
throw new Error(`provider ${providerId2} defaultQuery contains an empty name`);
|
|
3704
4243
|
}
|
|
3705
4244
|
}
|
|
3706
4245
|
return { ...query };
|
|
3707
4246
|
}
|
|
3708
|
-
function normalizePublicQueryNames(
|
|
4247
|
+
function normalizePublicQueryNames(providerId2, names, query) {
|
|
3709
4248
|
if (!names) {
|
|
3710
4249
|
return void 0;
|
|
3711
4250
|
}
|
|
@@ -3713,17 +4252,17 @@ function normalizePublicQueryNames(providerId, names, query) {
|
|
|
3713
4252
|
for (const name of names) {
|
|
3714
4253
|
if (seen.has(name)) {
|
|
3715
4254
|
throw new Error(
|
|
3716
|
-
`provider ${
|
|
4255
|
+
`provider ${providerId2} publicDefaultQueryNames contains duplicate name ${JSON.stringify(name)}`
|
|
3717
4256
|
);
|
|
3718
4257
|
}
|
|
3719
4258
|
if (!(name in (query ?? {}))) {
|
|
3720
4259
|
throw new Error(
|
|
3721
|
-
`provider ${
|
|
4260
|
+
`provider ${providerId2} publicDefaultQueryNames declares absent defaultQuery entry ${JSON.stringify(name)}`
|
|
3722
4261
|
);
|
|
3723
4262
|
}
|
|
3724
4263
|
if (isCredentialLikeMetadataName(name)) {
|
|
3725
4264
|
throw new Error(
|
|
3726
|
-
`provider ${
|
|
4265
|
+
`provider ${providerId2} publicDefaultQueryNames cannot classify credential-like name ${JSON.stringify(name)} as public`
|
|
3727
4266
|
);
|
|
3728
4267
|
}
|
|
3729
4268
|
seen.add(name);
|
|
@@ -4245,11 +4784,11 @@ function isDirectOpenAiApiBaseUrl(baseUrl) {
|
|
|
4245
4784
|
return false;
|
|
4246
4785
|
}
|
|
4247
4786
|
}
|
|
4248
|
-
function serviceTierForLatencyMode(
|
|
4787
|
+
function serviceTierForLatencyMode(providerId2, latencyMode) {
|
|
4249
4788
|
if (latencyMode === "standard") {
|
|
4250
4789
|
return void 0;
|
|
4251
4790
|
}
|
|
4252
|
-
if (
|
|
4791
|
+
if (providerId2 === "azure" || providerId2 === CODEX_PROVIDER_ID || providerId2 === XAI_SUBSCRIPTION_PROVIDER_ID) {
|
|
4253
4792
|
return "priority";
|
|
4254
4793
|
}
|
|
4255
4794
|
return "fast";
|
|
@@ -4467,6 +5006,37 @@ function matchesAdditiveCapabilityDefinitionVersion(model, provider, policy) {
|
|
|
4467
5006
|
}
|
|
4468
5007
|
return false;
|
|
4469
5008
|
}
|
|
5009
|
+
function webSearchPreEnablementState() {
|
|
5010
|
+
return { upstream: "unknown", runnable: false };
|
|
5011
|
+
}
|
|
5012
|
+
function matchesWebSearchEnablementDefinitionVersion(model, provider, policy) {
|
|
5013
|
+
if (!model.capabilities.hostedTools.webSearch.runnable) return false;
|
|
5014
|
+
const { definitionVersion: _definitionVersion, ...modelWithoutVersion } = model;
|
|
5015
|
+
const capabilities = {
|
|
5016
|
+
...model.capabilities,
|
|
5017
|
+
hostedTools: { ...model.capabilities.hostedTools, webSearch: webSearchPreEnablementState() }
|
|
5018
|
+
};
|
|
5019
|
+
return policy.definitionVersion === definitionVersionFor({ ...modelWithoutVersion, capabilities }, provider);
|
|
5020
|
+
}
|
|
5021
|
+
function configuredModelForAcceptedTurnExecutionPolicy(model, provider, policy) {
|
|
5022
|
+
if (policy.definitionVersion === model.definitionVersion || // Runtime test doubles may resolve a partial shape; a model without a
|
|
5023
|
+
// runnable web-search declaration has nothing to withhold.
|
|
5024
|
+
model.capabilities?.hostedTools?.webSearch?.runnable !== true || !matchesWebSearchEnablementDefinitionVersion(model, provider, policy)) {
|
|
5025
|
+
return model;
|
|
5026
|
+
}
|
|
5027
|
+
return {
|
|
5028
|
+
...model,
|
|
5029
|
+
capabilities: {
|
|
5030
|
+
...model.capabilities,
|
|
5031
|
+
hostedTools: {
|
|
5032
|
+
...model.capabilities.hostedTools,
|
|
5033
|
+
webSearch: webSearchPreEnablementState()
|
|
5034
|
+
}
|
|
5035
|
+
},
|
|
5036
|
+
hostedWebSearch: false,
|
|
5037
|
+
definitionVersion: policy.definitionVersion
|
|
5038
|
+
};
|
|
5039
|
+
}
|
|
4470
5040
|
function builtinProviderId(settings) {
|
|
4471
5041
|
return settings.openaiProvider === "azure" ? "azure" : "openai";
|
|
4472
5042
|
}
|
|
@@ -4516,14 +5086,14 @@ function configuredProviders(settings, source = process.env) {
|
|
|
4516
5086
|
}
|
|
4517
5087
|
function codexUpstreamModelSlugs(settings) {
|
|
4518
5088
|
if (settings.resolvedCodexModelsJson === void 0) return [...CODEX_FALLBACK_MODEL_SLUGS];
|
|
4519
|
-
return
|
|
5089
|
+
return z5.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson)).filter((model) => !model.retired).map((model) => model.upstreamModelId);
|
|
4520
5090
|
}
|
|
4521
5091
|
function withCodexCatalogProvider(settings) {
|
|
4522
5092
|
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
4523
5093
|
if (providers.some((provider2) => provider2.id === CODEX_PROVIDER_ID)) {
|
|
4524
5094
|
return settings;
|
|
4525
5095
|
}
|
|
4526
|
-
const catalogModels = settings.resolvedCodexModelsJson === void 0 ? void 0 :
|
|
5096
|
+
const catalogModels = settings.resolvedCodexModelsJson === void 0 ? void 0 : z5.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson)).filter((model) => !model.retired).map(({ retired: _retired, ...model }) => model);
|
|
4527
5097
|
if (catalogModels?.length === 0) return settings;
|
|
4528
5098
|
const provider = {
|
|
4529
5099
|
kind: "codex-subscription",
|
|
@@ -4805,14 +5375,14 @@ function configuredAllowedModels(settings) {
|
|
|
4805
5375
|
function isModelAvailableForNewSelection(settings, modelId) {
|
|
4806
5376
|
if (!modelId.startsWith(CODEX_MODEL_ID_PREFIX) || settings.resolvedCodexModelsJson === void 0)
|
|
4807
5377
|
return true;
|
|
4808
|
-
const models =
|
|
5378
|
+
const models = z5.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson));
|
|
4809
5379
|
return models.some((model) => model.id === modelId && !model.retired);
|
|
4810
5380
|
}
|
|
4811
5381
|
function settingsForAcceptedSubscriptionTurn(settings, policy, expected) {
|
|
4812
5382
|
const parsed = TurnExecutionPolicyV1.parse(policy);
|
|
4813
5383
|
if (!parsed.productModelId.startsWith(CODEX_MODEL_ID_PREFIX)) return settings;
|
|
4814
5384
|
if (!settings.codexSubscriptionEnabled) throw new Error("Codex subscription is disabled");
|
|
4815
|
-
const models = settings.resolvedCodexModelsJson === void 0 ? [] :
|
|
5385
|
+
const models = settings.resolvedCodexModelsJson === void 0 ? [] : z5.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson));
|
|
4816
5386
|
const retained = models.find((model2) => model2.id === parsed.productModelId && model2.retired);
|
|
4817
5387
|
if (!retained) {
|
|
4818
5388
|
assertTurnExecutionPolicyMatchesConfigV1(settings, parsed, expected);
|
|
@@ -4987,7 +5557,7 @@ function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
|
4987
5557
|
resolved.model,
|
|
4988
5558
|
resolved.provider
|
|
4989
5559
|
);
|
|
4990
|
-
const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion || parsed.definitionVersion === legacyCodexAstraImplicitCachingDefinitionVersionFor(resolved.model, resolved.provider) || matchesAdditiveCapabilityDefinitionVersion(resolved.model, resolved.provider, parsed);
|
|
5560
|
+
const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion || parsed.definitionVersion === legacyCodexAstraImplicitCachingDefinitionVersionFor(resolved.model, resolved.provider) || matchesAdditiveCapabilityDefinitionVersion(resolved.model, resolved.provider, parsed) || matchesWebSearchEnablementDefinitionVersion(resolved.model, resolved.provider, parsed);
|
|
4991
5561
|
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);
|
|
4992
5562
|
if (identityMismatched && !legacyClaudeAccountingMatches) {
|
|
4993
5563
|
throw new Error("Turn execution policy does not match the current provider definition");
|
|
@@ -4995,7 +5565,11 @@ function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
|
4995
5565
|
if (!definitionVersionMatches && !legacyClaudeAccountingMatches) {
|
|
4996
5566
|
throw new TurnExecutionPolicyDefinitionMismatchError();
|
|
4997
5567
|
}
|
|
4998
|
-
return {
|
|
5568
|
+
return {
|
|
5569
|
+
policy: parsed,
|
|
5570
|
+
provider: resolved.provider,
|
|
5571
|
+
model: configuredModelForAcceptedTurnExecutionPolicy(resolved.model, resolved.provider, parsed)
|
|
5572
|
+
};
|
|
4999
5573
|
}
|
|
5000
5574
|
function configuredModelPricingSchedules(settings) {
|
|
5001
5575
|
const defaults = Object.fromEntries(
|
|
@@ -5744,7 +6318,7 @@ function parseModelPricingJson(raw) {
|
|
|
5744
6318
|
if (!model.trim()) {
|
|
5745
6319
|
throw new Error("OPENGENI_MODEL_PRICING_JSON contains an empty model name");
|
|
5746
6320
|
}
|
|
5747
|
-
out[model] =
|
|
6321
|
+
out[model] = z5.union([ModelPricingSchema, ModelPricingScheduleSchema]).parse(value);
|
|
5748
6322
|
}
|
|
5749
6323
|
return out;
|
|
5750
6324
|
}
|
|
@@ -5854,9 +6428,9 @@ function parseIntegrationsOauthClientsJson(raw) {
|
|
|
5854
6428
|
}
|
|
5855
6429
|
return out;
|
|
5856
6430
|
}
|
|
5857
|
-
var SocialOAuthClientConfigSchema =
|
|
5858
|
-
clientId:
|
|
5859
|
-
clientSecret:
|
|
6431
|
+
var SocialOAuthClientConfigSchema = z5.object({
|
|
6432
|
+
clientId: z5.string().min(1),
|
|
6433
|
+
clientSecret: z5.string().min(1).optional()
|
|
5860
6434
|
});
|
|
5861
6435
|
var SOCIAL_OAUTH_PROVIDER_IDS = ["x", "reddit"];
|
|
5862
6436
|
function parseSocialOauthClientsJson(raw) {
|
|
@@ -6470,6 +7044,11 @@ function validateSettings(settings, source = process.env) {
|
|
|
6470
7044
|
);
|
|
6471
7045
|
}
|
|
6472
7046
|
parseExposedPorts(settings.dockerExposedPorts);
|
|
7047
|
+
parseRealtimeVoicePricingJson(settings.azureLivePricingJson, "OPENGENI_AZURE_LIVE_PRICING_JSON");
|
|
7048
|
+
parseRealtimeVoicePricingTableJson(
|
|
7049
|
+
settings.aiGatewayRealtimePricingJson,
|
|
7050
|
+
"OPENGENI_AI_GATEWAY_REALTIME_PRICING_JSON"
|
|
7051
|
+
);
|
|
6473
7052
|
sandboxEnvironmentVariableNames(settings);
|
|
6474
7053
|
sandboxLifecycleHookIds(settings);
|
|
6475
7054
|
const warmRates = parseSandboxWarmRateJson(settings.sandboxWarmRateMicrosPerSecondJson);
|
|
@@ -6695,7 +7274,7 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
6695
7274
|
);
|
|
6696
7275
|
const noteProductIds = new Set(models.map((model) => model.id));
|
|
6697
7276
|
if (settings.resolvedCodexModelsJson !== void 0) {
|
|
6698
|
-
for (const model of
|
|
7277
|
+
for (const model of z5.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson))) {
|
|
6699
7278
|
noteProductIds.add(model.id);
|
|
6700
7279
|
}
|
|
6701
7280
|
}
|
|
@@ -7011,6 +7590,7 @@ function withClaudeConnectionCredential(settings, kind, credential, scope = "org
|
|
|
7011
7590
|
export {
|
|
7012
7591
|
AGENT_INSTRUCTIONS_CORE_PLACEHOLDER,
|
|
7013
7592
|
AI_GATEWAY_REALTIME_MODELS,
|
|
7593
|
+
AZURE_LIVE_REALTIME_MODEL_ID,
|
|
7014
7594
|
CLAUDE_CONNECTION_KINDS,
|
|
7015
7595
|
CLAUDE_OAUTH_AUTHORIZE_URL,
|
|
7016
7596
|
CLAUDE_OAUTH_CLIENT_ID,
|
|
@@ -7031,6 +7611,7 @@ export {
|
|
|
7031
7611
|
DEFAULT_MODAL_IMAGE_REF,
|
|
7032
7612
|
DEFAULT_MODEL_COST_POLICY_JSON,
|
|
7033
7613
|
DEFAULT_OPENROUTER_MODEL_ID,
|
|
7614
|
+
DEFAULT_WEB_SEARCH_PRICING,
|
|
7034
7615
|
GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS,
|
|
7035
7616
|
GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS,
|
|
7036
7617
|
GatewayCatalogModel,
|
|
@@ -7064,6 +7645,7 @@ export {
|
|
|
7064
7645
|
SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS,
|
|
7065
7646
|
SUPERGROK_REALTIME_MODEL_ID,
|
|
7066
7647
|
SocialOAuthClientConfigSchema,
|
|
7648
|
+
TAVILY_CREDIT_MICROS,
|
|
7067
7649
|
TurnExecutionPolicyDefinitionMismatchError,
|
|
7068
7650
|
TurnExecutionPolicyModelUnavailableError,
|
|
7069
7651
|
UnsupportedLatencyModeError,
|
|
@@ -7071,6 +7653,10 @@ export {
|
|
|
7071
7653
|
VERCEL_AI_GATEWAY_BASE_URL,
|
|
7072
7654
|
VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
|
|
7073
7655
|
VERCEL_AI_GATEWAY_CONNECTION_ROLE,
|
|
7656
|
+
WEB_FETCH_TOOL_NAME,
|
|
7657
|
+
WEB_SEARCH_PROVIDER_IDS,
|
|
7658
|
+
WEB_SEARCH_PROVIDER_TRAITS,
|
|
7659
|
+
WEB_SEARCH_TOOL_NAME,
|
|
7074
7660
|
WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
|
|
7075
7661
|
WORKSPACE_GATEWAY_PROVIDER_ID,
|
|
7076
7662
|
WORKSPACE_OPENROUTER_CONNECTION_DOMAIN,
|
|
@@ -7078,6 +7664,7 @@ export {
|
|
|
7078
7664
|
WORKSPACE_OPENROUTER_MODEL_ID_PREFIX,
|
|
7079
7665
|
WORKSPACE_OPENROUTER_PROVIDER_ID,
|
|
7080
7666
|
WORKSPACE_REALTIME_MODEL_ID_PREFIX,
|
|
7667
|
+
WebSearchProviderMode,
|
|
7081
7668
|
XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 as XAI_SUBSCRIPTION_MODEL_ID_PREFIX,
|
|
7082
7669
|
agentConfigDeploymentPolicy,
|
|
7083
7670
|
allocateRecordedModelListCostByClass,
|
|
@@ -7094,7 +7681,9 @@ export {
|
|
|
7094
7681
|
calculateModelUsageCostBreakdown,
|
|
7095
7682
|
calculateModelUsageCostMicros,
|
|
7096
7683
|
calculateVideoGenerationCreditCostMicros,
|
|
7684
|
+
calculateVoiceInputCost,
|
|
7097
7685
|
canonicalPublicOrigin,
|
|
7686
|
+
canonicalVoiceInputModel,
|
|
7098
7687
|
canonicalizeConfiguredModelId,
|
|
7099
7688
|
claudeAuthorizationUrl,
|
|
7100
7689
|
claudeNativeModelProfile,
|
|
@@ -7112,6 +7701,7 @@ export {
|
|
|
7112
7701
|
configuredGatewayUpstreamModelIds,
|
|
7113
7702
|
configuredGatewayWorkspaceProductModelIds,
|
|
7114
7703
|
configuredGoogleDriveSyncLimits,
|
|
7704
|
+
configuredModelForAcceptedTurnExecutionPolicy,
|
|
7115
7705
|
configuredModelInputIdentities,
|
|
7116
7706
|
configuredModelListPricingSchedules,
|
|
7117
7707
|
configuredModelNotes,
|
|
@@ -7126,6 +7716,8 @@ export {
|
|
|
7126
7716
|
contextInputBudgetTokens,
|
|
7127
7717
|
dbSearchPath,
|
|
7128
7718
|
defaultModelPricing,
|
|
7719
|
+
defaultVoiceInputPricing,
|
|
7720
|
+
deploymentUnavailableFirstPartyMcpTools,
|
|
7129
7721
|
effectiveModalIdleTimeoutSeconds,
|
|
7130
7722
|
effectiveSandboxDrainSnapshotTimeoutMs,
|
|
7131
7723
|
effectiveSandboxLifecycle,
|
|
@@ -7162,15 +7754,20 @@ export {
|
|
|
7162
7754
|
parseModelNotesJson,
|
|
7163
7755
|
parseModelPricingJson,
|
|
7164
7756
|
parseModelProvidersJson,
|
|
7757
|
+
parseRealtimeVoicePricingJson,
|
|
7758
|
+
parseRealtimeVoicePricingTableJson,
|
|
7165
7759
|
parseSandboxWarmRateJson,
|
|
7166
7760
|
parseSocialOauthClientsJson,
|
|
7167
7761
|
parseStaticEntitlementsJson,
|
|
7168
7762
|
parseStaticUsageLimitsJson,
|
|
7763
|
+
parseVoiceInputPricingJson,
|
|
7169
7764
|
personalGitHubOAuthCallbackUrl,
|
|
7170
7765
|
policyProviderIdForModel,
|
|
7171
7766
|
productLabelForModelId,
|
|
7172
7767
|
productShortLabelForModelId,
|
|
7173
7768
|
promotionalCreditScope,
|
|
7769
|
+
realtimeVoiceMinuteCreditMicros,
|
|
7770
|
+
realtimeVoiceStartedMinutes,
|
|
7174
7771
|
requiredSandboxEnvForBackend,
|
|
7175
7772
|
resolveAiGatewayRealtimeModel,
|
|
7176
7773
|
resolveEnrollmentSigningSecret,
|
|
@@ -7184,11 +7781,14 @@ export {
|
|
|
7184
7781
|
resolveRelayTokenSecret,
|
|
7185
7782
|
resolveStreamTokenSecret,
|
|
7186
7783
|
resolveTurnExecutionPolicyV1,
|
|
7784
|
+
resolveVoiceInputPricing,
|
|
7187
7785
|
resolveVoiceInputProviderRegistry,
|
|
7786
|
+
resolveWebSearchProvider,
|
|
7188
7787
|
responseSatisfiesLatencyMode,
|
|
7189
7788
|
retryStartupDependency,
|
|
7190
7789
|
reviewedModelListPricing,
|
|
7191
7790
|
runnableLatencyModesForModel,
|
|
7791
|
+
safeResolveVoiceInputPricing,
|
|
7192
7792
|
sandboxArchiveCaptureTimeoutMs,
|
|
7193
7793
|
sandboxEnvironmentVariableNames,
|
|
7194
7794
|
sandboxImageAllowlist,
|
|
@@ -7208,9 +7808,18 @@ export {
|
|
|
7208
7808
|
subscriptionAccountShardIndex,
|
|
7209
7809
|
temporalConnectionOptions,
|
|
7210
7810
|
trustedProxyCidrEntries,
|
|
7811
|
+
unpricedVoiceInputProviders,
|
|
7211
7812
|
usableJevApiKey,
|
|
7212
7813
|
validateModelCatalogSettings,
|
|
7814
|
+
voiceInputCreditBillingActive,
|
|
7213
7815
|
voiceInputDeploymentConfigured,
|
|
7816
|
+
voiceInputModelReportsDurationOnly,
|
|
7817
|
+
voiceInputPricingHasTokenRates,
|
|
7818
|
+
voiceInputPricingIssues,
|
|
7819
|
+
webSearchCallPricing,
|
|
7820
|
+
webSearchCreditMicros,
|
|
7821
|
+
webSearchProviderConfig,
|
|
7822
|
+
webSearchToolPlan,
|
|
7214
7823
|
withClaudeConnectionCatalog,
|
|
7215
7824
|
withClaudeConnectionCredential,
|
|
7216
7825
|
withCodexCatalogProvider,
|