@opengeni/config 1.2.2 → 1.3.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/claude-subscription-capacity.d.ts +9 -0
- package/dist/claude-subscription-oauth.d.ts +17 -0
- package/dist/claude-subscription-usage.d.ts +13 -0
- package/dist/credit-promotions.d.ts +25 -0
- package/dist/index.d.ts +783 -12
- package/dist/index.js +2368 -595
- package/dist/index.js.map +1 -1
- package/dist/managed-user-admission.d.ts +2 -0
- package/dist/subscription-account-selection.d.ts +17 -0
- package/package.json +4 -4
- package/src/claude-subscription-capacity.ts +129 -0
- package/src/claude-subscription-oauth.ts +33 -0
- package/src/claude-subscription-usage.ts +328 -0
- package/src/credit-promotions.ts +68 -0
- package/src/index.ts +2248 -278
- package/src/managed-user-admission.ts +11 -0
- package/src/subscription-account-selection.ts +36 -0
package/dist/index.js
CHANGED
|
@@ -1,8 +1,66 @@
|
|
|
1
|
+
// src/managed-user-admission.ts
|
|
2
|
+
function managedUserEmailAllowed(allowedUserEmails, email) {
|
|
3
|
+
return allowedUserEmails === void 0 || typeof email === "string" && allowedUserEmails.some((allowed2) => allowed2.toLowerCase() === email.trim().toLowerCase());
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/credit-promotions.ts
|
|
7
|
+
import { PromotionalCreditScope } from "@opengeni/contracts";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
var ModelIds = PromotionalCreditScope.shape.eligibleModelIds.transform((ids) => [
|
|
10
|
+
...new Set(ids)
|
|
11
|
+
]);
|
|
12
|
+
var CreditPromotionPolicy = z.object({
|
|
13
|
+
defaultModelIds: ModelIds.optional(),
|
|
14
|
+
signupModelIds: ModelIds.optional(),
|
|
15
|
+
offers: z.record(
|
|
16
|
+
z.string().min(1),
|
|
17
|
+
z.object({
|
|
18
|
+
label: PromotionalCreditScope.shape.label,
|
|
19
|
+
eligibleModelIds: ModelIds.optional()
|
|
20
|
+
}).strict()
|
|
21
|
+
).default({})
|
|
22
|
+
}).strict().superRefine((policy, ctx) => {
|
|
23
|
+
for (const [id, offer] of Object.entries(policy.offers)) {
|
|
24
|
+
if (!offer.eligibleModelIds && !policy.defaultModelIds) {
|
|
25
|
+
ctx.addIssue({
|
|
26
|
+
code: "custom",
|
|
27
|
+
path: ["offers", id],
|
|
28
|
+
message: "Offer requires eligibleModelIds or defaultModelIds"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var EnvCreditPromotionPolicy = z.preprocess(
|
|
34
|
+
(value) => {
|
|
35
|
+
if (typeof value !== "string") return value;
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(value);
|
|
38
|
+
} catch {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
CreditPromotionPolicy.default({ offers: {} })
|
|
43
|
+
);
|
|
44
|
+
function signupCreditModelIds(settings) {
|
|
45
|
+
return settings.creditPromotionPolicy.signupModelIds ?? settings.creditPromotionPolicy.defaultModelIds;
|
|
46
|
+
}
|
|
47
|
+
function promotionalCreditScope(settings, couponId) {
|
|
48
|
+
const policy = settings.creditPromotionPolicy;
|
|
49
|
+
const offer = policy.offers[couponId];
|
|
50
|
+
const eligibleModelIds = offer?.eligibleModelIds ?? policy.defaultModelIds;
|
|
51
|
+
return eligibleModelIds ? { label: offer?.label ?? "Promotional credits", eligibleModelIds } : void 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
1
54
|
// src/index.ts
|
|
55
|
+
import { isRetiredNativeAtlassianTool } from "@opengeni/contracts/atlassian-native-retirement";
|
|
56
|
+
import { modelLogoUrl } from "@opengeni/contracts/model-display";
|
|
2
57
|
import {
|
|
58
|
+
directModelConnectionSpec,
|
|
3
59
|
BillingMode,
|
|
4
60
|
CAPABILITY_DESCRIPTORS,
|
|
61
|
+
agentConfigDeploymentLimitsFromAllowlist,
|
|
5
62
|
DEFAULT_FIRST_PARTY_MCP_TOOLS,
|
|
63
|
+
DEFAULT_OPENGENI_DOCUMENTATION_URL,
|
|
6
64
|
currentAgentLearningToolSelection,
|
|
7
65
|
Entitlements,
|
|
8
66
|
EntitlementsMode,
|
|
@@ -44,7 +102,365 @@ import {
|
|
|
44
102
|
} from "@opengeni/xai-subscription";
|
|
45
103
|
import { XAI_SUBSCRIPTION_MODEL_ID_PREFIX as XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 } from "@opengeni/xai-subscription";
|
|
46
104
|
import { createHash } from "crypto";
|
|
47
|
-
import {
|
|
105
|
+
import { isIP } from "net";
|
|
106
|
+
import { z as z3 } from "zod";
|
|
107
|
+
|
|
108
|
+
// src/claude-subscription-usage.ts
|
|
109
|
+
import {
|
|
110
|
+
ClaudeUsageWindowId
|
|
111
|
+
} from "@opengeni/contracts";
|
|
112
|
+
var prefixes = {
|
|
113
|
+
five_hour: ["5h"],
|
|
114
|
+
seven_day: ["7d"],
|
|
115
|
+
seven_day_opus: ["7d-opus"],
|
|
116
|
+
seven_day_sonnet: ["7d-sonnet"],
|
|
117
|
+
seven_day_overage_included: ["7d_oi", "7d-overage-included"],
|
|
118
|
+
overage: ["overage"]
|
|
119
|
+
};
|
|
120
|
+
function percent(value, scale) {
|
|
121
|
+
if (typeof value !== "number" && (typeof value !== "string" || !value.trim())) return null;
|
|
122
|
+
const number = Number(value) * scale;
|
|
123
|
+
return Number.isFinite(number) && number >= 0 ? number : null;
|
|
124
|
+
}
|
|
125
|
+
function epoch(value) {
|
|
126
|
+
if (!value || !/^\d+(?:\.\d+)?$/.test(value)) return null;
|
|
127
|
+
const time = Number(value) * 1e3;
|
|
128
|
+
return Number.isFinite(time) && time > 0 && time < 864e13 ? new Date(time).toISOString() : null;
|
|
129
|
+
}
|
|
130
|
+
function status(value) {
|
|
131
|
+
return value === "allowed" || value === "allowed_warning" || value === "rejected" ? value : null;
|
|
132
|
+
}
|
|
133
|
+
function latestReset(left, right, observedAt) {
|
|
134
|
+
return new Date(
|
|
135
|
+
Math.max(
|
|
136
|
+
left ? Date.parse(left) : Date.parse(observedAt) + 6e4,
|
|
137
|
+
right ? Date.parse(right) : Date.parse(observedAt) + 6e4
|
|
138
|
+
)
|
|
139
|
+
).toISOString();
|
|
140
|
+
}
|
|
141
|
+
function evidenceKey(item) {
|
|
142
|
+
return JSON.stringify([
|
|
143
|
+
item.upstreamModelId,
|
|
144
|
+
item.upstreamModelId ? null : item.representativeClaim,
|
|
145
|
+
item.source === "provider"
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
function tiedRequest(left, right) {
|
|
149
|
+
const denied = left.status === "rejected" ? left : right.status === "rejected" ? right : null;
|
|
150
|
+
return {
|
|
151
|
+
...denied ?? left,
|
|
152
|
+
resetsAt: denied ? latestReset(
|
|
153
|
+
left.status === "rejected" ? left.resetsAt : denied.resetsAt,
|
|
154
|
+
right.status === "rejected" ? right.resetsAt : denied.resetsAt,
|
|
155
|
+
left.observedAt
|
|
156
|
+
) : null,
|
|
157
|
+
representativeClaim: left.representativeClaim === right.representativeClaim ? left.representativeClaim : null,
|
|
158
|
+
status: denied ? "rejected" : null,
|
|
159
|
+
overageStatus: null,
|
|
160
|
+
overageResetsAt: null
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function parseClaudeUsageHeaders(headers, now = /* @__PURE__ */ new Date(), upstreamModelId) {
|
|
164
|
+
const observedAt = now.toISOString();
|
|
165
|
+
const claim = ClaudeUsageWindowId.safeParse(
|
|
166
|
+
headers.get("anthropic-ratelimit-unified-representative-claim")
|
|
167
|
+
);
|
|
168
|
+
const claimedStatus = status(headers.get("anthropic-ratelimit-unified-status"));
|
|
169
|
+
const claimedReset = epoch(headers.get("anthropic-ratelimit-unified-reset"));
|
|
170
|
+
const overageStatus = status(headers.get("anthropic-ratelimit-unified-overage-status"));
|
|
171
|
+
const overageResetsAt = epoch(headers.get("anthropic-ratelimit-unified-overage-reset"));
|
|
172
|
+
const windows = ClaudeUsageWindowId.options.flatMap((id) => {
|
|
173
|
+
const header = (suffix) => prefixes[id].map(
|
|
174
|
+
(prefix) => headers.get(`anthropic-ratelimit-unified-${prefix}-${suffix}`)
|
|
175
|
+
).find((value) => value !== null) ?? null;
|
|
176
|
+
const representative = claim.success && claim.data === id;
|
|
177
|
+
const usedPercent = percent(header("utilization"), 100);
|
|
178
|
+
const resetsAt = epoch(header("reset")) ?? (representative ? claimedReset : null);
|
|
179
|
+
const windowStatus = status(header("status")) ?? (representative ? claimedStatus : null);
|
|
180
|
+
if (usedPercent === null && resetsAt === null && windowStatus === null) return [];
|
|
181
|
+
return [{ id, usedPercent, resetsAt, status: windowStatus, observedAt }];
|
|
182
|
+
});
|
|
183
|
+
return windows.length || claimedStatus || overageStatus ? {
|
|
184
|
+
windows,
|
|
185
|
+
observedAt,
|
|
186
|
+
source: "response_headers",
|
|
187
|
+
requestStatus: {
|
|
188
|
+
status: claimedStatus,
|
|
189
|
+
resetsAt: claimedReset,
|
|
190
|
+
representativeClaim: claim.success ? claim.data : null,
|
|
191
|
+
overageStatus,
|
|
192
|
+
overageResetsAt,
|
|
193
|
+
upstreamModelId: upstreamModelId ?? null,
|
|
194
|
+
observedAt
|
|
195
|
+
}
|
|
196
|
+
} : null;
|
|
197
|
+
}
|
|
198
|
+
function parseClaudeUsageResponse(value, now = /* @__PURE__ */ new Date()) {
|
|
199
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
200
|
+
const observedAt = now.toISOString();
|
|
201
|
+
const windows = ClaudeUsageWindowId.options.flatMap((id) => {
|
|
202
|
+
const window = value[id];
|
|
203
|
+
if (!window || typeof window !== "object" || Array.isArray(window)) return [];
|
|
204
|
+
const fields = window;
|
|
205
|
+
const usedPercent = percent(fields.utilization, 1);
|
|
206
|
+
const time = typeof fields.resets_at === "string" ? Date.parse(fields.resets_at) : NaN;
|
|
207
|
+
const resetsAt = Number.isFinite(time) ? new Date(time).toISOString() : null;
|
|
208
|
+
if (usedPercent === null && resetsAt === null) return [];
|
|
209
|
+
return [{ id, usedPercent, resetsAt, status: null, observedAt }];
|
|
210
|
+
});
|
|
211
|
+
return windows.length ? { windows, observedAt, source: "provider" } : null;
|
|
212
|
+
}
|
|
213
|
+
function emptyClaudeUsage(credentialVersion) {
|
|
214
|
+
return {
|
|
215
|
+
connected: credentialVersion !== null,
|
|
216
|
+
credentialVersion,
|
|
217
|
+
windows: [],
|
|
218
|
+
observedAt: null,
|
|
219
|
+
source: null,
|
|
220
|
+
refreshStatus: "not_checked",
|
|
221
|
+
refreshCheckedAt: null
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function mergeClaudeUsage(current, observation) {
|
|
225
|
+
const windows = new Map(current.windows.map((window) => [window.id, window]));
|
|
226
|
+
for (const incomingWindow of observation.windows) {
|
|
227
|
+
const window = { ...incomingWindow, source: incomingWindow.source ?? observation.source };
|
|
228
|
+
const previous = windows.get(window.id);
|
|
229
|
+
if (!previous || previous.observedAt < window.observedAt) windows.set(window.id, window);
|
|
230
|
+
else if (previous.observedAt === window.observedAt && JSON.stringify(previous) !== JSON.stringify(window)) {
|
|
231
|
+
const rejected = previous.status === "rejected" || window.status === "rejected";
|
|
232
|
+
const full = (previous.usedPercent ?? 0) >= 100 || (window.usedPercent ?? 0) >= 100;
|
|
233
|
+
windows.set(window.id, {
|
|
234
|
+
...previous,
|
|
235
|
+
usedPercent: previous.usedPercent === null ? window.usedPercent : window.usedPercent === null ? previous.usedPercent : Math.max(previous.usedPercent, window.usedPercent),
|
|
236
|
+
status: rejected ? "rejected" : previous.status === window.status ? previous.status : null,
|
|
237
|
+
resetsAt: rejected || full ? latestReset(previous.resetsAt, window.resetsAt, window.observedAt) : previous.resetsAt === window.resetsAt ? previous.resetsAt : null,
|
|
238
|
+
source: previous.source === "response_headers" || window.source === "response_headers" ? "response_headers" : "provider"
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const incoming = observation.requestStatus;
|
|
243
|
+
const restrictions = new Map(
|
|
244
|
+
(current.requestRestrictions ?? []).map((item) => [evidenceKey(item), item])
|
|
245
|
+
);
|
|
246
|
+
for (const item of [
|
|
247
|
+
current.requestStatus?.status ? current.requestStatus : null,
|
|
248
|
+
...observation.requestRestrictions ?? [],
|
|
249
|
+
incoming?.status ? incoming : null
|
|
250
|
+
]) {
|
|
251
|
+
if (!item) continue;
|
|
252
|
+
const key = evidenceKey(item);
|
|
253
|
+
const previous = restrictions.get(key);
|
|
254
|
+
const sanitized = {
|
|
255
|
+
...item,
|
|
256
|
+
overageStatus: null,
|
|
257
|
+
overageResetsAt: null
|
|
258
|
+
};
|
|
259
|
+
if (!previous || item.observedAt > previous.observedAt) restrictions.set(key, sanitized);
|
|
260
|
+
else if (item.observedAt === previous.observedAt && JSON.stringify(previous) !== JSON.stringify(sanitized))
|
|
261
|
+
restrictions.set(key, tiedRequest(previous, sanitized));
|
|
262
|
+
}
|
|
263
|
+
const directWindows = [
|
|
264
|
+
...current.windows.filter(
|
|
265
|
+
(window) => window.source === "provider" || !window.source && current.source === "provider" && current.observedAt === window.observedAt
|
|
266
|
+
),
|
|
267
|
+
...observation.windows.filter((window) => (window.source ?? observation.source) === "provider")
|
|
268
|
+
];
|
|
269
|
+
for (const window of directWindows) {
|
|
270
|
+
if (window.usedPercent === null || window.usedPercent >= 100) continue;
|
|
271
|
+
const proof = {
|
|
272
|
+
status: null,
|
|
273
|
+
resetsAt: null,
|
|
274
|
+
representativeClaim: window.id,
|
|
275
|
+
upstreamModelId: null,
|
|
276
|
+
overageStatus: null,
|
|
277
|
+
overageResetsAt: null,
|
|
278
|
+
observedAt: window.observedAt,
|
|
279
|
+
source: "provider"
|
|
280
|
+
};
|
|
281
|
+
const key = evidenceKey(proof);
|
|
282
|
+
if (!restrictions.has(key) || restrictions.get(key).observedAt < proof.observedAt)
|
|
283
|
+
restrictions.set(key, proof);
|
|
284
|
+
}
|
|
285
|
+
for (const [key, item] of restrictions) {
|
|
286
|
+
if (item.status !== "rejected") continue;
|
|
287
|
+
const proof = [...restrictions.values()].find(
|
|
288
|
+
(candidate) => candidate.source === "provider" && candidate.representativeClaim === item.representativeClaim && candidate.observedAt > item.observedAt && candidate.representativeClaim !== "overage" && candidate.representativeClaim !== "seven_day_overage_included"
|
|
289
|
+
);
|
|
290
|
+
if (proof)
|
|
291
|
+
restrictions.set(key, {
|
|
292
|
+
...item,
|
|
293
|
+
status: null,
|
|
294
|
+
resetsAt: null,
|
|
295
|
+
observedAt: proof.observedAt
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
let requestRestrictions = [...restrictions.values()];
|
|
299
|
+
const evidenceTime = requestRestrictions.reduce(
|
|
300
|
+
(value, item) => item.observedAt > value ? item.observedAt : value,
|
|
301
|
+
observation.observedAt
|
|
302
|
+
);
|
|
303
|
+
const liveDenials = requestRestrictions.filter(
|
|
304
|
+
(item) => item.status === "rejected" && (item.resetsAt ? Date.parse(item.resetsAt) : Date.parse(item.observedAt) + 6e4) > Date.parse(evidenceTime)
|
|
305
|
+
);
|
|
306
|
+
if (requestRestrictions.length > 64 && liveDenials.length === 0) {
|
|
307
|
+
requestRestrictions = requestRestrictions.sort((left, right) => right.observedAt.localeCompare(left.observedAt)).slice(0, 64);
|
|
308
|
+
} else if (requestRestrictions.length > 64) {
|
|
309
|
+
const observedAt = evidenceTime;
|
|
310
|
+
const resetsAt = new Date(
|
|
311
|
+
Math.max(
|
|
312
|
+
...liveDenials.map(
|
|
313
|
+
(item) => item.resetsAt ? Date.parse(item.resetsAt) : Date.parse(item.observedAt) + 6e4
|
|
314
|
+
),
|
|
315
|
+
Date.parse(observedAt) + 6e4
|
|
316
|
+
)
|
|
317
|
+
).toISOString();
|
|
318
|
+
requestRestrictions = [
|
|
319
|
+
{
|
|
320
|
+
status: "rejected",
|
|
321
|
+
resetsAt,
|
|
322
|
+
representativeClaim: null,
|
|
323
|
+
overageStatus: null,
|
|
324
|
+
overageResetsAt: null,
|
|
325
|
+
upstreamModelId: null,
|
|
326
|
+
observedAt
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
const newest = !current.observedAt || current.observedAt < observation.observedAt;
|
|
331
|
+
const tied = current.observedAt === observation.observedAt;
|
|
332
|
+
let requestStatus = current.requestStatus ?? null;
|
|
333
|
+
if (newest) requestStatus = incoming ?? null;
|
|
334
|
+
else if (tied && JSON.stringify(requestStatus) !== JSON.stringify(incoming ?? null)) {
|
|
335
|
+
requestStatus = incoming && requestStatus && evidenceKey(incoming) === evidenceKey(requestStatus) ? tiedRequest(requestStatus, incoming) : null;
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
...current,
|
|
339
|
+
requestRestrictions,
|
|
340
|
+
requestStatus,
|
|
341
|
+
windows: ClaudeUsageWindowId.options.flatMap(
|
|
342
|
+
(id) => windows.has(id) ? [windows.get(id)] : []
|
|
343
|
+
),
|
|
344
|
+
...newest ? {
|
|
345
|
+
observedAt: observation.observedAt,
|
|
346
|
+
source: observation.source
|
|
347
|
+
// A newer direct or partial observation cannot retain an older paid
|
|
348
|
+
// fallback authorization. Window readings remain independently merged.
|
|
349
|
+
} : {}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/claude-subscription-oauth.ts
|
|
354
|
+
import { z as z2 } from "zod";
|
|
355
|
+
var CLAUDE_OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
356
|
+
var CLAUDE_OAUTH_AUTHORIZE_URL = "https://claude.com/cai/oauth/authorize";
|
|
357
|
+
var CLAUDE_OAUTH_TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
358
|
+
var CLAUDE_OAUTH_REDIRECT_URL = "https://platform.claude.com/oauth/code/callback";
|
|
359
|
+
var CLAUDE_OAUTH_SCOPES = ["user:inference", "user:profile"];
|
|
360
|
+
var ClaudeOAuthTokenResponse = z2.object({
|
|
361
|
+
access_token: z2.string().max(16384).regex(/^sk-ant-oat[0-9]+-\S+$/),
|
|
362
|
+
refresh_token: z2.string().min(1).max(16384).optional(),
|
|
363
|
+
expires_in: z2.number().int().positive().max(31536e3),
|
|
364
|
+
scope: z2.string().min(1).max(8192)
|
|
365
|
+
}).passthrough();
|
|
366
|
+
function claudeAuthorizationUrl(input) {
|
|
367
|
+
const url = new URL(CLAUDE_OAUTH_AUTHORIZE_URL);
|
|
368
|
+
url.searchParams.set("code", "true");
|
|
369
|
+
url.searchParams.set("client_id", CLAUDE_OAUTH_CLIENT_ID);
|
|
370
|
+
url.searchParams.set("response_type", "code");
|
|
371
|
+
url.searchParams.set("redirect_uri", CLAUDE_OAUTH_REDIRECT_URL);
|
|
372
|
+
url.searchParams.set("scope", CLAUDE_OAUTH_SCOPES.join(" "));
|
|
373
|
+
url.searchParams.set("code_challenge", input.challenge);
|
|
374
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
375
|
+
url.searchParams.set("state", input.state);
|
|
376
|
+
return url.toString();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/subscription-account-selection.ts
|
|
380
|
+
function subscriptionAccountShardIndex(sessionId, candidateCount) {
|
|
381
|
+
if (!Number.isSafeInteger(candidateCount) || candidateCount <= 0)
|
|
382
|
+
throw new Error("Subscription shard candidate count must be positive");
|
|
383
|
+
let hash = 2166136261;
|
|
384
|
+
for (let index = 0; index < sessionId.length; index += 1) {
|
|
385
|
+
hash ^= sessionId.charCodeAt(index);
|
|
386
|
+
hash = Math.imul(hash, 16777619);
|
|
387
|
+
}
|
|
388
|
+
return (hash >>> 0) % candidateCount;
|
|
389
|
+
}
|
|
390
|
+
function selectSubscriptionAccount(input) {
|
|
391
|
+
const pinned = input.eligible.find((account) => account.id === input.pinnedCredentialId);
|
|
392
|
+
if (input.pinnedCredentialId && input.pinSource !== "policy") return pinned ?? null;
|
|
393
|
+
if (!input.rotationEnabled)
|
|
394
|
+
return input.eligible.find((account) => account.id === input.activeCredentialId) ?? null;
|
|
395
|
+
return pinned ?? (input.eligible.length ? input.eligible[subscriptionAccountShardIndex(input.sessionId, input.eligible.length)] : null);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// src/claude-subscription-capacity.ts
|
|
399
|
+
var UNKNOWN_RESET_RECHECK_MS = 6e4;
|
|
400
|
+
var allowed = (status2) => status2 === "allowed" || status2 === "allowed_warning";
|
|
401
|
+
function claudeSubscriptionCapacity(usage, upstreamModelId, now, options = {}) {
|
|
402
|
+
const available = { available: true, nextCheckAt: null, blockingWindows: [] };
|
|
403
|
+
if (!usage.connected || usage.refreshStatus === "reconnect")
|
|
404
|
+
return { ...available, available: false };
|
|
405
|
+
const relevant = (id) => {
|
|
406
|
+
if (id === "seven_day_opus") return /^claude-opus-/.test(upstreamModelId);
|
|
407
|
+
if (id === "seven_day_sonnet") return /^claude-sonnet-/.test(upstreamModelId);
|
|
408
|
+
return id === "five_hour" || id === "seven_day";
|
|
409
|
+
};
|
|
410
|
+
const applicable = usage.windows.filter((window) => relevant(window.id));
|
|
411
|
+
const relevantClaim = (id) => id === "seven_day_opus" || id === "seven_day_sonnet" ? relevant(id) : true;
|
|
412
|
+
const restrictions = (usage.requestRestrictions ?? []).filter(
|
|
413
|
+
(item) => item.status === "rejected" && (item.upstreamModelId === upstreamModelId || item.upstreamModelId === null && relevantClaim(item.representativeClaim)) && !applicable.some(
|
|
414
|
+
(window) => window.source === "provider" && window.usedPercent !== null && window.usedPercent < 100 && window.id === item.representativeClaim && window.observedAt > item.observedAt
|
|
415
|
+
) && (item.resetsAt ? Date.parse(item.resetsAt) : Date.parse(item.observedAt) + UNKNOWN_RESET_RECHECK_MS) > now.getTime()
|
|
416
|
+
);
|
|
417
|
+
const blocking = applicable.filter((window) => {
|
|
418
|
+
if ((window.resetsAt ? Date.parse(window.resetsAt) : Date.parse(window.observedAt) + UNKNOWN_RESET_RECHECK_MS) <= now.getTime())
|
|
419
|
+
return false;
|
|
420
|
+
return window.status === "rejected" || window.status === null && (window.usedPercent ?? 0) >= 100;
|
|
421
|
+
});
|
|
422
|
+
const request = usage.requestStatus;
|
|
423
|
+
const exactModel = request?.upstreamModelId === upstreamModelId;
|
|
424
|
+
const relevantRequest = request && (exactModel || request.upstreamModelId === null && relevantClaim(request.representativeClaim));
|
|
425
|
+
const freshRequest = relevantRequest && applicable.every((window) => window.observedAt <= request.observedAt) && restrictions.every((item) => item.observedAt <= request.observedAt);
|
|
426
|
+
const planResetElapsed = request && (request.resetsAt ? Date.parse(request.resetsAt) : Date.parse(request.observedAt) + UNKNOWN_RESET_RECHECK_MS) <= now.getTime();
|
|
427
|
+
const exactAllowance = (usage.requestRestrictions ?? []).find(
|
|
428
|
+
(item) => item.upstreamModelId === upstreamModelId && allowed(item.status) && blocking.every((window) => window.observedAt < item.observedAt) && restrictions.every((restriction) => restriction.observedAt < item.observedAt)
|
|
429
|
+
);
|
|
430
|
+
if (exactAllowance) return available;
|
|
431
|
+
if (freshRequest && exactModel && allowed(request.status) && !planResetElapsed) return available;
|
|
432
|
+
const mayUseOverage = options.allowOverage !== false;
|
|
433
|
+
const overageResetElapsed = request?.overageResetsAt && Date.parse(request.overageResetsAt) <= now.getTime();
|
|
434
|
+
if (freshRequest && request.status === "rejected" && mayUseOverage && allowed(request.overageStatus) && !overageResetElapsed)
|
|
435
|
+
return available;
|
|
436
|
+
const rejectedRequest = freshRequest && request.status === "rejected" && !planResetElapsed;
|
|
437
|
+
if (blocking.length === 0 && !rejectedRequest && restrictions.length === 0) return available;
|
|
438
|
+
const resets = blocking.map(
|
|
439
|
+
(window) => window.resetsAt ? Date.parse(window.resetsAt) : Date.parse(window.observedAt) + UNKNOWN_RESET_RECHECK_MS
|
|
440
|
+
);
|
|
441
|
+
if (rejectedRequest)
|
|
442
|
+
resets.push(
|
|
443
|
+
request.resetsAt ? Date.parse(request.resetsAt) : Date.parse(request.observedAt) + UNKNOWN_RESET_RECHECK_MS
|
|
444
|
+
);
|
|
445
|
+
resets.push(
|
|
446
|
+
...restrictions.map(
|
|
447
|
+
(item) => item.resetsAt ? Date.parse(item.resetsAt) : Date.parse(item.observedAt) + UNKNOWN_RESET_RECHECK_MS
|
|
448
|
+
)
|
|
449
|
+
);
|
|
450
|
+
let nextCheckAt = Math.max(...resets);
|
|
451
|
+
if (rejectedRequest && mayUseOverage && request.overageStatus === "rejected" && request.overageResetsAt) {
|
|
452
|
+
const overageReset = Date.parse(request.overageResetsAt);
|
|
453
|
+
if (overageReset <= now.getTime()) return available;
|
|
454
|
+
nextCheckAt = Math.min(nextCheckAt, overageReset);
|
|
455
|
+
}
|
|
456
|
+
return {
|
|
457
|
+
available: false,
|
|
458
|
+
nextCheckAt: new Date(nextCheckAt),
|
|
459
|
+
blockingWindows: blocking.map((window) => window.id)
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// src/index.ts
|
|
48
464
|
var envName = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
49
465
|
var registryId = /^[A-Za-z0-9_-]+$/;
|
|
50
466
|
var DEFAULT_OPENROUTER_MODEL_ID = "openrouter/nvidia/nemotron-3-super-120b-a12b:free";
|
|
@@ -53,12 +469,13 @@ var DEFAULT_MODEL_COST_POLICY_JSON = JSON.stringify({
|
|
|
53
469
|
});
|
|
54
470
|
var SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS = 60 * 6e4;
|
|
55
471
|
var SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS = 1e4;
|
|
472
|
+
var SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS = 12e4;
|
|
56
473
|
var SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS = SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS - SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS;
|
|
57
474
|
var GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS = 6e4;
|
|
58
475
|
var GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS = 6e4;
|
|
59
476
|
var SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS = 60 * 6e4;
|
|
60
477
|
var SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS = 1e4;
|
|
61
|
-
var EnvBoolean =
|
|
478
|
+
var EnvBoolean = z3.preprocess((value) => {
|
|
62
479
|
if (typeof value !== "string") {
|
|
63
480
|
return value;
|
|
64
481
|
}
|
|
@@ -70,10 +487,11 @@ var EnvBoolean = z.preprocess((value) => {
|
|
|
70
487
|
return false;
|
|
71
488
|
}
|
|
72
489
|
return value;
|
|
73
|
-
},
|
|
490
|
+
}, z3.boolean());
|
|
491
|
+
var PublicHttpUrl = z3.string().url().max(2048).refine((value) => /^https?:\/\//iu.test(value), "must be an http(s) URL");
|
|
74
492
|
var DEFAULT_GOAL_IDLE_BACKOFF_MS = [3e3, 3e4, 12e4, 3e5];
|
|
75
493
|
var DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS = 6e5;
|
|
76
|
-
var EnvGoalIdleBackoffMs =
|
|
494
|
+
var EnvGoalIdleBackoffMs = z3.preprocess((value) => {
|
|
77
495
|
if (typeof value !== "string") return value;
|
|
78
496
|
const source = value.trim();
|
|
79
497
|
if (!source) return void 0;
|
|
@@ -81,8 +499,8 @@ var EnvGoalIdleBackoffMs = z.preprocess((value) => {
|
|
|
81
499
|
const trimmed = entry.trim();
|
|
82
500
|
return trimmed === "" ? Number.NaN : Number(trimmed);
|
|
83
501
|
});
|
|
84
|
-
},
|
|
85
|
-
var EnvFirstPartyMcpTools =
|
|
502
|
+
}, z3.array(z3.number().int().nonnegative()).min(1, "OPENGENI_GOAL_IDLE_BACKOFF_MS must list at least one delay in milliseconds").readonly());
|
|
503
|
+
var EnvFirstPartyMcpTools = z3.preprocess(
|
|
86
504
|
(value) => {
|
|
87
505
|
if (typeof value !== "string") return value;
|
|
88
506
|
const source = value.trim();
|
|
@@ -96,7 +514,7 @@ var EnvFirstPartyMcpTools = z.preprocess(
|
|
|
96
514
|
}
|
|
97
515
|
return source.split(",").map((entry) => entry.trim());
|
|
98
516
|
},
|
|
99
|
-
|
|
517
|
+
z3.array(FirstPartyMcpToolName).superRefine((tools, context) => {
|
|
100
518
|
const seen = /* @__PURE__ */ new Set();
|
|
101
519
|
for (const [index, tool] of tools.entries()) {
|
|
102
520
|
if (seen.has(tool)) {
|
|
@@ -143,23 +561,23 @@ var sandboxPreparationProfiles = {
|
|
|
143
561
|
};
|
|
144
562
|
var AGENT_INSTRUCTIONS_CORE_PLACEHOLDER = "{{core}}";
|
|
145
563
|
var DEFAULT_AGENT_INSTRUCTIONS = [
|
|
146
|
-
"You are an OpenGeni workspace agent.",
|
|
147
|
-
"Follow the user's task and
|
|
148
|
-
"
|
|
564
|
+
"You are an OpenGeni workspace agent: a general assistant for questions, writing, research, analysis, and technical work.",
|
|
565
|
+
"Follow the user's task and the applicable Skill instructions for the current role.",
|
|
566
|
+
"When a task needs files or commands, work inside the sandbox workspace with the filesystem and shell tools.",
|
|
149
567
|
"Repository resources are mounted under repos/<host>/<owner>/<repo> unless the session specifies another collision-free mount path.",
|
|
150
568
|
"File resources are mounted under .opengeni/files/<file-id>/ unless the session specifies another mount path.",
|
|
151
569
|
"Attached files are mounted read-only; copy them before modifying.",
|
|
152
570
|
"Installed and selected Skills appear in the session Skill index; follow its reading instructions and any role-specific guidance.",
|
|
153
|
-
"
|
|
154
|
-
"When the
|
|
155
|
-
"
|
|
156
|
-
"
|
|
571
|
+
"Provider CLIs such as gh, glab, and az may be pre-authenticated by the host through brokered git credentials or a sandbox preparation profile; try them before asking for credentials.",
|
|
572
|
+
"When the Git repository you change has a remote and git provider credentials are available, work on a focused branch and open a pull request.",
|
|
573
|
+
"Otherwise leave changes in the working tree and do not create or mention branches, commits, or pull requests unless the user asks; if the repository has a remote, say the changes are not pushed, and if the user asks for something you cannot make, say what blocks it.",
|
|
574
|
+
"Answer questions directly and briefly; after making changes, say what changed, how you checked it, and anything still blocked.",
|
|
157
575
|
AGENT_INSTRUCTIONS_CORE_PLACEHOLDER
|
|
158
576
|
].join(" ");
|
|
159
577
|
var McpServerConnectionRefSchema = PublicMcpServerConnectionRef;
|
|
160
|
-
var McpOperationRecoverySchema =
|
|
161
|
-
|
|
162
|
-
|
|
578
|
+
var McpOperationRecoverySchema = z3.record(
|
|
579
|
+
z3.string().min(1).max(512).regex(/^\S+$/u),
|
|
580
|
+
z3.object({ observerTool: z3.string().min(1).max(512).regex(/^\S+$/u) }).strict()
|
|
163
581
|
).superRefine((bindings, context) => {
|
|
164
582
|
for (const [originalTool, binding] of Object.entries(bindings)) {
|
|
165
583
|
if (originalTool === binding.observerTool) {
|
|
@@ -171,110 +589,126 @@ var McpOperationRecoverySchema = z.record(
|
|
|
171
589
|
}
|
|
172
590
|
}
|
|
173
591
|
});
|
|
174
|
-
var DEFAULT_MODAL_IMAGE_REF = "opengenipublicneuacr.azurecr.io/opengeni-desktop@sha256:
|
|
175
|
-
var SettingsSchema =
|
|
176
|
-
serviceName:
|
|
177
|
-
environment:
|
|
178
|
-
deploymentRevision:
|
|
592
|
+
var DEFAULT_MODAL_IMAGE_REF = "opengenipublicneuacr.azurecr.io/opengeni-desktop@sha256:554d5b324a580071dd669e7c1190931e498eb1b397412a27c7de84a430ef393a";
|
|
593
|
+
var SettingsSchema = z3.object({
|
|
594
|
+
serviceName: z3.string().default("opengeni"),
|
|
595
|
+
environment: z3.string().default("local"),
|
|
596
|
+
deploymentRevision: z3.string().default("dev"),
|
|
179
597
|
// The release-train version baked into official images (OPENGENI_SERVER_VERSION).
|
|
180
598
|
// Absent on dev/source builds — consumers must treat it as optional.
|
|
181
|
-
serverVersion:
|
|
182
|
-
databaseUrl:
|
|
599
|
+
serverVersion: z3.string().optional(),
|
|
600
|
+
databaseUrl: z3.string().default("postgres://opengeni:opengeni@127.0.0.1:5432/opengeni"),
|
|
601
|
+
// API application pool only. Managed auth owns its separate pool; readiness
|
|
602
|
+
// reuses the application handle. Keep the historical default for existing
|
|
603
|
+
// deployments and let operators budget this per process with replica counts.
|
|
604
|
+
apiDatabasePoolMax: z3.coerce.number().int().positive().default(32),
|
|
183
605
|
// Step I (§7.8 runtime half). Dedicated Postgres schema for the EMBEDDED
|
|
184
606
|
// topology. Default "" → standalone: no search_path scoping, server default
|
|
185
607
|
// (`public`). When set (e.g. "opengeni"), the db handle + the managed-auth
|
|
186
608
|
// pool send `search_path = "<dbSchema>","opengeni_private","public"` so every
|
|
187
609
|
// query resolves into the dedicated schema with NO query rewrite (schema-isolation contract F1).
|
|
188
|
-
dbSchema:
|
|
610
|
+
dbSchema: z3.string().default(""),
|
|
189
611
|
// Step I (§7.7). RLS posture. "force" (default) = today's FORCE-RLS via the
|
|
190
612
|
// non-owner `opengeni_app` role. "scoped" = the embedded owner-role path (the
|
|
191
613
|
// GUC is still emitted defensively, so the query path is identical).
|
|
192
|
-
rlsStrategy:
|
|
614
|
+
rlsStrategy: z3.enum(["force", "scoped"]).default("force"),
|
|
193
615
|
// Exact PostgreSQL login identity required by the standalone FORCE-RLS
|
|
194
616
|
// startup/readiness assertion. Embedded `scoped` hosts own their role model
|
|
195
617
|
// and are deliberately not constrained to this name.
|
|
196
|
-
runtimeDatabaseRole:
|
|
197
|
-
natsUrl:
|
|
198
|
-
temporalHost:
|
|
199
|
-
temporalNamespace:
|
|
200
|
-
temporalTaskQueue:
|
|
618
|
+
runtimeDatabaseRole: z3.string().min(1).default("opengeni_app"),
|
|
619
|
+
natsUrl: z3.string().default("nats://127.0.0.1:4222"),
|
|
620
|
+
temporalHost: z3.string().default("127.0.0.1:7233"),
|
|
621
|
+
temporalNamespace: z3.string().default("default"),
|
|
622
|
+
temporalTaskQueue: z3.string().default("opengeni-runs-ts"),
|
|
201
623
|
temporalTlsEnabled: EnvBoolean.default(false),
|
|
202
|
-
temporalApiKey:
|
|
203
|
-
temporalTlsServerName:
|
|
204
|
-
temporalTlsRootCaCertificateBase64:
|
|
205
|
-
temporalTlsClientCertificateBase64:
|
|
206
|
-
temporalTlsClientPrivateKeyBase64:
|
|
207
|
-
startupDependencyRetryAttempts:
|
|
208
|
-
startupDependencyRetryInitialDelayMs:
|
|
209
|
-
startupDependencyRetryMaxDelayMs:
|
|
210
|
-
turnWorkerConcurrencyMode:
|
|
211
|
-
turnWorkerMaxConcurrentTurns:
|
|
212
|
-
turnWorkerTargetCpuUsage:
|
|
213
|
-
turnWorkerTargetMemoryUsage:
|
|
624
|
+
temporalApiKey: z3.string().optional(),
|
|
625
|
+
temporalTlsServerName: z3.string().optional(),
|
|
626
|
+
temporalTlsRootCaCertificateBase64: z3.string().optional(),
|
|
627
|
+
temporalTlsClientCertificateBase64: z3.string().optional(),
|
|
628
|
+
temporalTlsClientPrivateKeyBase64: z3.string().optional(),
|
|
629
|
+
startupDependencyRetryAttempts: z3.coerce.number().int().positive().default(30),
|
|
630
|
+
startupDependencyRetryInitialDelayMs: z3.coerce.number().int().positive().default(1e3),
|
|
631
|
+
startupDependencyRetryMaxDelayMs: z3.coerce.number().int().positive().default(5e3),
|
|
632
|
+
turnWorkerConcurrencyMode: z3.enum(["fixed", "resource-based"]).default("fixed"),
|
|
633
|
+
turnWorkerMaxConcurrentTurns: z3.coerce.number().int().positive().max(2e3).default(16),
|
|
634
|
+
turnWorkerTargetCpuUsage: z3.coerce.number().positive().max(1).default(0.8),
|
|
635
|
+
turnWorkerTargetMemoryUsage: z3.coerce.number().positive().max(0.8).default(0.75),
|
|
214
636
|
// Admission and emergency recovery are deliberately separate control loops.
|
|
215
637
|
// The Temporal tuner stops polling at the lower target; only genuine danger
|
|
216
638
|
// may invoke the disruptive graceful-drain fallback.
|
|
217
|
-
turnWorkerEmergencyMemoryUsage:
|
|
218
|
-
turnWorkerMemoryGuardIntervalMs:
|
|
219
|
-
turnWorkerMemoryGuardSustainMs:
|
|
639
|
+
turnWorkerEmergencyMemoryUsage: z3.coerce.number().min(0.85).max(0.95).default(0.9),
|
|
640
|
+
turnWorkerMemoryGuardIntervalMs: z3.coerce.number().int().min(1e3).max(6e4).default(5e3),
|
|
641
|
+
turnWorkerMemoryGuardSustainMs: z3.coerce.number().int().min(5e3).max(3e5).default(3e4),
|
|
220
642
|
observabilityStructuredLogs: EnvBoolean.default(false),
|
|
221
643
|
observabilityMetricsEnabled: EnvBoolean.default(true),
|
|
222
|
-
observabilityOtlpEndpoint:
|
|
223
|
-
observabilityOtlpHeaders:
|
|
644
|
+
observabilityOtlpEndpoint: z3.string().url().optional(),
|
|
645
|
+
observabilityOtlpHeaders: z3.string().default(""),
|
|
646
|
+
observabilityDiagnosticsEndpoint: z3.string().url().optional(),
|
|
647
|
+
observabilityDiagnosticsHeaders: z3.string().default(""),
|
|
224
648
|
analyticsEnabled: EnvBoolean.default(false),
|
|
225
649
|
analyticsConsentRequired: EnvBoolean.default(true),
|
|
226
|
-
analyticsReoClientId:
|
|
227
|
-
analyticsPosthogProjectKey:
|
|
228
|
-
analyticsPosthogHost:
|
|
229
|
-
analyticsGa4MeasurementId:
|
|
230
|
-
|
|
650
|
+
analyticsReoClientId: z3.string().max(128).regex(/^[A-Za-z0-9_-]+$/u).optional(),
|
|
651
|
+
analyticsPosthogProjectKey: z3.string().min(1).max(256).optional(),
|
|
652
|
+
analyticsPosthogHost: z3.string().url().max(2048).optional(),
|
|
653
|
+
analyticsGa4MeasurementId: z3.string().max(32).regex(/^G-[A-Z0-9]+$/u).optional(),
|
|
654
|
+
// Optional operator-owned legal documents linked from the signed-out console.
|
|
655
|
+
// Unset by default, so a self-hosted deployment never shows another operator's
|
|
656
|
+
// policies; the managed service points these at its own published pages.
|
|
657
|
+
legalPrivacyPolicyUrl: PublicHttpUrl.optional(),
|
|
658
|
+
legalTermsOfServiceUrl: PublicHttpUrl.optional(),
|
|
659
|
+
// Optional operator support address, shown as a "Contact support" mailto link
|
|
660
|
+
// on the signed-out page and in the Help menu. Unset by default for the same
|
|
661
|
+
// reason as the legal links.
|
|
662
|
+
supportEmail: z3.string().trim().email().max(254).optional(),
|
|
663
|
+
publicBaseUrl: z3.string().url().optional(),
|
|
664
|
+
// Product documentation the web console links from its Help menu. Absent
|
|
665
|
+
// means the public OpenGeni docs; `none` hides the link for deployments that
|
|
666
|
+
// publish no documentation of their own.
|
|
667
|
+
documentationUrl: z3.preprocess(
|
|
668
|
+
(value) => typeof value === "string" ? value.trim().toLowerCase() === "none" ? null : value.trim() : value,
|
|
669
|
+
z3.url({ protocol: /^https?$/u, error: "must be an absolute http(s) URL or none" }).nullable().default(DEFAULT_OPENGENI_DOCUMENTATION_URL)
|
|
670
|
+
),
|
|
231
671
|
// Standards-based OAuth authorization server for external workspace MCP
|
|
232
672
|
// clients. Opt-in because it creates a new public authentication surface.
|
|
233
673
|
mcpOauthEnabled: EnvBoolean.default(false),
|
|
234
|
-
//
|
|
674
|
+
// Client source address for every API rate limit, abuse quota, and auth
|
|
675
|
+
// session record (Better Auth, MCP OAuth registration, enrollment, account
|
|
676
|
+
// setup, login transactions). Forwarded client addresses are ignored by
|
|
677
|
+
// default so a caller cannot choose its own bucket. Operators may trust an
|
|
235
678
|
// exact number of proxy hops only when direct access to the API is blocked.
|
|
236
|
-
|
|
679
|
+
apiTrustedProxyHops: z3.coerce.number().int().min(0).max(16).default(0),
|
|
680
|
+
// Optional comma-separated CIDRs (or single addresses) of the proxy that
|
|
681
|
+
// connects to the API. When set, forwarded client addresses are honored
|
|
682
|
+
// only for requests whose transport peer is inside one of them.
|
|
683
|
+
apiTrustedProxyCidrs: z3.string().default(""),
|
|
237
684
|
// Browser origin when the web app and API use separate origins in local
|
|
238
685
|
// development. Production normally leaves this unset and uses publicBaseUrl.
|
|
239
|
-
webBaseUrl:
|
|
686
|
+
webBaseUrl: z3.string().url().optional(),
|
|
240
687
|
// Base URL for the bring-your-own-compute agent release assets the get.<domain>
|
|
241
688
|
// install routes redirect to. Defaults to this repo's GitHub Releases. The route
|
|
242
689
|
// appends `/download/agent-v<ver>/<asset>`.
|
|
243
|
-
agentReleasesBaseUrl:
|
|
690
|
+
agentReleasesBaseUrl: z3.string().url().default("https://github.com/Cloudgeni-ai/opengeni/releases"),
|
|
244
691
|
// Explicit operator-controlled promotion pointer for `/agent/latest/*`.
|
|
245
692
|
// Versioned agent releases are immutable; changing this setting promotes or
|
|
246
693
|
// rolls back the stable channel without moving or deleting a provider tag.
|
|
247
|
-
agentStableVersion:
|
|
694
|
+
agentStableVersion: z3.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).default("0.1.16"),
|
|
248
695
|
// Optional independent beta-channel pointer. When unset, the beta update
|
|
249
696
|
// manifest route is unavailable rather than silently serving stable.
|
|
250
|
-
agentBetaVersion:
|
|
697
|
+
agentBetaVersion: z3.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).optional(),
|
|
251
698
|
productAccessMode: ProductAccessMode.default("local"),
|
|
252
|
-
// --- canonical organization-tenancy authority activation, default OFF ---
|
|
253
|
-
// The named PRE-ACTIVATION opt-out for the organization-tenancy program. FALSE (the
|
|
254
|
-
// default, and the value an operator leaves in place to decline or defer) means
|
|
255
|
-
// this deployment stays on the reversible legacy workspace-owned lane: no phase-F
|
|
256
|
-
// subsystem may switch its access decision to organization/membership authority
|
|
257
|
-
// ids. TRUE is an operator's explicit statement that the activation preconditions
|
|
258
|
-
// in docs/organization-tenancy.md have been proven for this deployment and that
|
|
259
|
-
// the one-way boundary is accepted.
|
|
260
|
-
//
|
|
261
|
-
// This is NOT a kill switch and NOT a rollback: once an activation migration has
|
|
262
|
-
// committed, setting it back to false does not restore the legacy authority - only
|
|
263
|
-
// forward recovery is available. It also grants and revokes nothing by itself;
|
|
264
|
-
// every individual authorization decision keeps its own fences.
|
|
265
|
-
//
|
|
266
|
-
// No runtime path reads it yet: canonical activation (phase F) is unshipped, so
|
|
267
|
-
// the flag exists to reserve the name, pin the safe default, and give every future
|
|
268
|
-
// activation slice one gate to consult. EnvBoolean (NOT z.coerce.boolean(), which
|
|
269
|
-
// coerces "false" -> true and would activate the moment an operator wrote the
|
|
270
|
-
// variable out to disable it).
|
|
271
|
-
organizationTenancyCanonicalActivationEnabled: EnvBoolean.default(false),
|
|
272
699
|
billingMode: BillingMode.default("disabled"),
|
|
700
|
+
// Explicit launch gate for the one-time $10 verified self-service signup grant.
|
|
701
|
+
// A migration or deployment alone must not start issuing live credits.
|
|
702
|
+
verifiedSignupTrialCreditsEnabled: EnvBoolean.default(false),
|
|
703
|
+
creditPromotionPolicy: EnvCreditPromotionPolicy,
|
|
273
704
|
entitlementsMode: EntitlementsMode.default("none"),
|
|
274
705
|
usageLimitsMode: UsageLimitsMode.default("none"),
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
706
|
+
// Gate new allowance policies until every API/worker in the fleet enforces
|
|
707
|
+
// them. Persisted-policy enforcement and recovery reads/clears stay active.
|
|
708
|
+
usageAllowancesEnabled: EnvBoolean.default(false),
|
|
709
|
+
staticEntitlementsJson: z3.string().default("{}"),
|
|
710
|
+
staticUsageLimitsJson: z3.string().default("{}"),
|
|
711
|
+
delegationSecret: z3.string().optional(),
|
|
278
712
|
defaultFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
279
713
|
allowedFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
280
714
|
// sandbox workspace scoped stream-token HMAC secret (sandbox contract §C.3 / stream-token availability contract).
|
|
@@ -282,7 +716,7 @@ var SettingsSchema = z.object({
|
|
|
282
716
|
// family, `ogs_` vs `ogd_` prefix). REQUIRED-WHEN-DESKTOP, but the absence of
|
|
283
717
|
// BOTH while sandboxDesktopEnabled=true is a GRACEFUL DEGRADE (DesktopStream
|
|
284
718
|
// transport:null + a loud boot warning), NOT a hard boot-fail (stream-token availability contract).
|
|
285
|
-
streamTokenSecret:
|
|
719
|
+
streamTokenSecret: z3.string().optional(),
|
|
286
720
|
// The desktop input plane (raw stream:control writes) is OFF in v1: even a
|
|
287
721
|
// holder of stream:control gets 403 until this flips. Keeps stream:control a
|
|
288
722
|
// declared-but-inert permission so later hardening is a flag flip.
|
|
@@ -305,47 +739,51 @@ var SettingsSchema = z.object({
|
|
|
305
739
|
// Optional release-coherent bootstrap hint for custom rigs/connected machines
|
|
306
740
|
// that do not carry the stock-image ogtool binary. Exact stable versions only:
|
|
307
741
|
// the agent must never guess a tag or silently install `latest`.
|
|
308
|
-
ogtoolPackageSpec:
|
|
309
|
-
environmentsEncryptionKey:
|
|
742
|
+
ogtoolPackageSpec: z3.string().regex(/^@opengeni\/ogtool@(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).optional(),
|
|
743
|
+
environmentsEncryptionKey: z3.string().optional(),
|
|
310
744
|
integrationsEnabled: EnvBoolean.default(false),
|
|
311
|
-
integrationsStateSecret:
|
|
745
|
+
integrationsStateSecret: z3.string().optional(),
|
|
746
|
+
integrationsOauthShortStateEnabled: EnvBoolean.default(false),
|
|
312
747
|
integrationsAllowPrivateNetworkTargets: EnvBoolean.default(false),
|
|
313
|
-
integrationsOauthClientsJson:
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
748
|
+
integrationsOauthClientsJson: z3.string().default("{}"),
|
|
749
|
+
gmailWatchTopicName: z3.string().regex(/^projects\/[^/]+\/topics\/[^/]+$/u).optional(),
|
|
750
|
+
slackClientId: z3.string().optional(),
|
|
751
|
+
slackClientSecret: z3.string().optional(),
|
|
752
|
+
slackSigningSecret: z3.string().optional(),
|
|
753
|
+
// Unlisted apps share Slack’s restricted history/replies quota across all tokens.
|
|
754
|
+
slackAccessMode: z3.enum(["limited", "full"]).default("limited"),
|
|
317
755
|
slackBotDisplayName: OpenGeniSlackBotDisplayName.default("OpenGeni"),
|
|
318
|
-
slackCommand:
|
|
319
|
-
googleDriveClientId:
|
|
320
|
-
googleDriveClientSecret:
|
|
321
|
-
googleDriveSyncMaxItems:
|
|
322
|
-
googleDriveSyncMaxBytes:
|
|
323
|
-
googleDriveSyncMaxFileBytes:
|
|
324
|
-
googleDriveSyncMaxProviderRequests:
|
|
325
|
-
googleDriveSyncMaxElapsedSeconds:
|
|
326
|
-
googleDriveSyncMaxFailureDetails:
|
|
327
|
-
googleDriveProviderRequestTimeoutMs:
|
|
328
|
-
googleDriveProviderRetryAttempts:
|
|
329
|
-
googleDriveProviderRetryInitialDelayMs:
|
|
330
|
-
googleDriveProviderRetryMaxDelayMs:
|
|
331
|
-
googleDriveProviderRetryBudgetMs:
|
|
332
|
-
fikenClientId:
|
|
333
|
-
fikenClientSecret:
|
|
756
|
+
slackCommand: z3.string().trim().regex(/^\/[a-z0-9_-]{1,31}$/u).default("/opengeni"),
|
|
757
|
+
googleDriveClientId: z3.string().optional(),
|
|
758
|
+
googleDriveClientSecret: z3.string().optional(),
|
|
759
|
+
googleDriveSyncMaxItems: z3.coerce.number().int().positive().max(1e4).default(500),
|
|
760
|
+
googleDriveSyncMaxBytes: z3.coerce.number().int().positive().max(5e9).default(5e8),
|
|
761
|
+
googleDriveSyncMaxFileBytes: z3.coerce.number().int().positive().max(5e9).default(1e8),
|
|
762
|
+
googleDriveSyncMaxProviderRequests: z3.coerce.number().int().positive().max(1e4).default(1e3),
|
|
763
|
+
googleDriveSyncMaxElapsedSeconds: z3.coerce.number().int().positive().max(3600).default(300),
|
|
764
|
+
googleDriveSyncMaxFailureDetails: z3.coerce.number().int().positive().max(100).default(25),
|
|
765
|
+
googleDriveProviderRequestTimeoutMs: z3.coerce.number().int().min(1e3).max(GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS).default(3e4),
|
|
766
|
+
googleDriveProviderRetryAttempts: z3.coerce.number().int().min(1).max(5).default(3),
|
|
767
|
+
googleDriveProviderRetryInitialDelayMs: z3.coerce.number().int().positive().max(3e4).default(250),
|
|
768
|
+
googleDriveProviderRetryMaxDelayMs: z3.coerce.number().int().positive().max(GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS).default(5e3),
|
|
769
|
+
googleDriveProviderRetryBudgetMs: z3.coerce.number().int().positive().max(12e4).default(15e3),
|
|
770
|
+
fikenClientId: z3.string().optional(),
|
|
771
|
+
fikenClientSecret: z3.string().optional(),
|
|
334
772
|
googleDriveWorkspaceEventsEnabled: EnvBoolean.optional(),
|
|
335
|
-
atlassianClientId:
|
|
336
|
-
atlassianClientSecret:
|
|
773
|
+
atlassianClientId: z3.string().optional(),
|
|
774
|
+
atlassianClientSecret: z3.string().optional(),
|
|
337
775
|
// Undefined is meaningful: the migration boundary persists the product
|
|
338
776
|
// default of 3 when no deployment override is supplied.
|
|
339
|
-
maxNestedAgentDepth:
|
|
777
|
+
maxNestedAgentDepth: z3.coerce.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH).optional(),
|
|
340
778
|
// Operator OAuth apps for first-party social connectors, keyed by provider
|
|
341
779
|
// id ("x", "reddit"): {"x":{"clientId":"...","clientSecret":"..."}}.
|
|
342
|
-
socialOauthClientsJson:
|
|
780
|
+
socialOauthClientsJson: z3.string().default("{}"),
|
|
343
781
|
// Session goal guard rails. Goals are designed for runs that legitimately
|
|
344
782
|
// span days, so length is bounded by explicit completion/pause and budget
|
|
345
783
|
// exhaustion, never by count. goalMaxAutoContinuations is therefore UNSET
|
|
346
784
|
// by default (no cap); deployments may configure one, and it then acts as a
|
|
347
785
|
// hard ceiling that per-goal overrides can only lower.
|
|
348
|
-
goalMaxAutoContinuations:
|
|
786
|
+
goalMaxAutoContinuations: z3.coerce.number().int().positive().optional(),
|
|
349
787
|
// Idle backoff between CONSECUTIVE no-input goal continuations. This is
|
|
350
788
|
// pacing, not a cap: the first continuation after a turn that consumed any
|
|
351
789
|
// external input is immediate, the n-th consecutive no-input continuation
|
|
@@ -353,7 +791,7 @@ var SettingsSchema = z.object({
|
|
|
353
791
|
// any new input (machine input, human/API prompt, Steer) wakes the session
|
|
354
792
|
// immediately. The delay never exceeds goalIdleBackoffMaxMs.
|
|
355
793
|
goalIdleBackoffMs: EnvGoalIdleBackoffMs.default(DEFAULT_GOAL_IDLE_BACKOFF_MS),
|
|
356
|
-
goalIdleBackoffMaxMs:
|
|
794
|
+
goalIdleBackoffMaxMs: z3.coerce.number().int().positive().default(DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS),
|
|
357
795
|
// Child lifecycle notices: a child session's requires_action freeze, its
|
|
358
796
|
// resolution, a direct Pause, a provider-capacity wait, and goal progress
|
|
359
797
|
// become typed `session_system_updates` rows for the parent (in addition to
|
|
@@ -367,16 +805,6 @@ var SettingsSchema = z.object({
|
|
|
367
805
|
// into @opengeni/db once at boot.
|
|
368
806
|
// Env: OPENGENI_CHILD_LIFECYCLE_NOTICES_ENABLED.
|
|
369
807
|
childLifecycleNoticesEnabled: EnvBoolean.default(false),
|
|
370
|
-
// Explicit host-owned MCP connection authority is a rolling protocol
|
|
371
|
-
// activation. Keep it off while any API, worker, or browser bundle predates
|
|
372
|
-
// the authority discriminator; enable it only after the whole fleet runs an
|
|
373
|
-
// image that understands host refs. Legacy markerless non-UUID refs remain a
|
|
374
|
-
// separate compatibility lane for already-persisted embedding integrations.
|
|
375
|
-
// Env: OPENGENI_HOST_MCP_AUTHORITY_SOURCE_ADMISSION_ENABLED.
|
|
376
|
-
hostMcpAuthoritySourceAdmissionEnabled: EnvBoolean.default(false),
|
|
377
|
-
// Server-owned per-organization remote MCP resolver configuration. Optional;
|
|
378
|
-
// inline credentials and native provider OAuth do not require this service.
|
|
379
|
-
hostMcpCredentialResolversJson: z.string().optional(),
|
|
380
808
|
// Per-channel and per-DM Slack workspace routing. Default ON. A channel does
|
|
381
809
|
// not count a personal workspace as a candidate, so an organization with one
|
|
382
810
|
// shared workspace resolves it as the sole candidate and never asks; the
|
|
@@ -391,17 +819,17 @@ var SettingsSchema = z.object({
|
|
|
391
819
|
// session turn. Effectively unbounded by default for the same reason as
|
|
392
820
|
// above; the graceful max-turns valve (idle + goal continuation, never a
|
|
393
821
|
// session failure) remains as inert safety should a deployment set a cap.
|
|
394
|
-
agentMaxModelCallsPerTurn:
|
|
822
|
+
agentMaxModelCallsPerTurn: z3.coerce.number().int().positive().default(1e6),
|
|
395
823
|
// Deployment fallback for models that do not declare their own window.
|
|
396
824
|
// Built-in billed GPT-5.6 Sol/Terra/Luna pin Codex's 272k catalog instead.
|
|
397
825
|
// OpenGeni always performs one durable, portable plaintext compaction
|
|
398
826
|
// transition; there is no provider/server/off mode ladder.
|
|
399
|
-
contextWindowTokens:
|
|
827
|
+
contextWindowTokens: z3.coerce.number().int().positive().default(105e4),
|
|
400
828
|
// Optional model-catalog effective input ceiling. Codex and billed GPT-5.6
|
|
401
829
|
// models expose this as raw context_window * effective_context_window_percent;
|
|
402
830
|
// when absent, retain the deployment-level window-minus-reserved-output
|
|
403
831
|
// behavior.
|
|
404
|
-
contextEffectiveWindowTokens:
|
|
832
|
+
contextEffectiveWindowTokens: z3.coerce.number().int().positive().optional(),
|
|
405
833
|
// Proactive compaction threshold as a ratio of the model context window.
|
|
406
834
|
// Defaults to 90%: compact as late as possible — retained context beats early
|
|
407
835
|
// headroom now that per-model windows are declared honestly (input-effective,
|
|
@@ -409,7 +837,7 @@ var SettingsSchema = z.object({
|
|
|
409
837
|
// absorbs any overshoot as one retried call rather than a dead session.
|
|
410
838
|
// Clamped to [0.3, 0.9] so deployments can tune the trigger without
|
|
411
839
|
// accidentally disabling compaction.
|
|
412
|
-
contextCompactionThresholdRatio:
|
|
840
|
+
contextCompactionThresholdRatio: z3.coerce.number().default(0.9).transform((value) => {
|
|
413
841
|
if (!Number.isFinite(value)) {
|
|
414
842
|
return 0.9;
|
|
415
843
|
}
|
|
@@ -417,118 +845,127 @@ var SettingsSchema = z.object({
|
|
|
417
845
|
}),
|
|
418
846
|
// Tokens reserved for model output; subtracted from the window to get the
|
|
419
847
|
// usable input budget B = contextWindowTokens - contextReservedOutputTokens.
|
|
420
|
-
contextReservedOutputTokens:
|
|
848
|
+
contextReservedOutputTokens: z3.coerce.number().int().nonnegative().default(128e3),
|
|
421
849
|
// Model-catalog auto-compact limit. When present it is clamped to
|
|
422
850
|
// 90% of the raw window, matching Codex core's auto_compact_token_limit().
|
|
423
|
-
contextAutoCompactThresholdTokens:
|
|
851
|
+
contextAutoCompactThresholdTokens: z3.coerce.number().int().positive().optional(),
|
|
424
852
|
// Provider-neutral fallback for canonical model-facing tool-result text.
|
|
425
853
|
// The current stable Codex catalog policy is 10k tokens; the truncator adds
|
|
426
854
|
// Codex's 1.2x JSON serialization allowance when applying it.
|
|
427
|
-
modelToolOutputTruncationTokens:
|
|
855
|
+
modelToolOutputTruncationTokens: z3.coerce.number().int().positive().default(1e4),
|
|
428
856
|
authRequired: EnvBoolean.default(false),
|
|
429
|
-
accessKey:
|
|
857
|
+
accessKey: z3.string().optional(),
|
|
430
858
|
authAllowHealth: EnvBoolean.default(true),
|
|
431
859
|
authAllowMetrics: EnvBoolean.default(false),
|
|
432
|
-
apiHost:
|
|
433
|
-
apiPort:
|
|
434
|
-
|
|
860
|
+
apiHost: z3.string().default("0.0.0.0"),
|
|
861
|
+
apiPort: z3.coerce.number().int().positive().default(8e3),
|
|
862
|
+
// When set, GET /metrics is served only on this dedicated internal listener
|
|
863
|
+
// and never on the public API port that an ingress forwards to.
|
|
864
|
+
apiMetricsPort: z3.coerce.number().int().positive().optional(),
|
|
865
|
+
workerHttpPort: z3.coerce.number().int().positive().default(8001),
|
|
435
866
|
// Worker-side first-party MCP traffic stays on the deployment's internal
|
|
436
867
|
// network. OPENGENI_MCP_URL remains the sandbox/external route used by
|
|
437
868
|
// Codemode and remote placements.
|
|
438
|
-
opengeniMcpInternalUrl:
|
|
439
|
-
opengeniMcpUrl:
|
|
869
|
+
opengeniMcpInternalUrl: z3.string().url().optional(),
|
|
870
|
+
opengeniMcpUrl: z3.string().url().optional(),
|
|
440
871
|
// Origins allowed to send browser cookies cross-origin. Other origins may
|
|
441
872
|
// call the public API with bearer credentials, but never receive credentialed
|
|
442
873
|
// CORS responses.
|
|
443
|
-
corsAllowOriginRegex:
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
874
|
+
corsAllowOriginRegex: z3.string().default(String.raw`^https?://(localhost|127\.0\.0\.1)(:\d+)?$`),
|
|
875
|
+
// Local development only (`local` access mode in the `local` environment):
|
|
876
|
+
// extra exact browser origins, comma-separated, that may call the
|
|
877
|
+
// unauthenticated API besides this stack's own web origin. The local browser
|
|
878
|
+
// boundary ignores `corsAllowOriginRegex`.
|
|
879
|
+
localAllowedOrigins: z3.string().optional(),
|
|
880
|
+
openaiProvider: z3.enum(["openai", "azure"]).default("openai"),
|
|
881
|
+
openaiApiKey: z3.string().optional(),
|
|
882
|
+
openaiBaseUrl: z3.string().optional(),
|
|
883
|
+
openaiModel: z3.string().default("gpt-6-astra"),
|
|
884
|
+
openaiAllowedModels: z3.string().default("gpt-6-astra,gpt-6-sol,gpt-6-luna"),
|
|
449
885
|
// OpenGeni-managed Vercel AI Gateway. When configured, the two reviewed
|
|
450
886
|
// Gateway models below are added to the managed-credit catalog. Workspace
|
|
451
887
|
// Gateway keys use the encrypted connection broker and never this secret.
|
|
452
|
-
vercelAiGatewayApiKey:
|
|
888
|
+
vercelAiGatewayApiKey: z3.string().optional(),
|
|
453
889
|
/** Image adapter route; native hosted providers ignore this model. */
|
|
454
|
-
imageGenerationModel:
|
|
890
|
+
imageGenerationModel: z3.string().trim().min(1).max(256).default("openai/gpt-image-2"),
|
|
455
891
|
/** Durable video generation uses the workspace-owned Gateway credential. */
|
|
456
|
-
videoGenerationPollIntervalMs:
|
|
457
|
-
videoGenerationRecoveryDeadlineMs:
|
|
458
|
-
videoGenerationReferenceUrlTtlSeconds:
|
|
459
|
-
videoGenerationMaxConcurrentPerWorkspace:
|
|
460
|
-
videoGenerationWorkspaceQuotaBytes:
|
|
461
|
-
videoGenerationTempDirectory:
|
|
462
|
-
videoGenerationFfprobePath:
|
|
892
|
+
videoGenerationPollIntervalMs: z3.coerce.number().int().min(1e3).max(6e4).default(5e3),
|
|
893
|
+
videoGenerationRecoveryDeadlineMs: z3.coerce.number().int().min(6e4).max(24 * 60 * 6e4).default(2 * 60 * 6e4),
|
|
894
|
+
videoGenerationReferenceUrlTtlSeconds: z3.coerce.number().int().min(300).max(6 * 60 * 60).default(60 * 60),
|
|
895
|
+
videoGenerationMaxConcurrentPerWorkspace: z3.coerce.number().int().min(1).max(16).default(2),
|
|
896
|
+
videoGenerationWorkspaceQuotaBytes: z3.coerce.number().int().positive().max(Number.MAX_SAFE_INTEGER).default(20 * 1024 * 1024 * 1024),
|
|
897
|
+
videoGenerationTempDirectory: z3.string().trim().min(1).max(1024).default("/tmp/opengeni-video"),
|
|
898
|
+
videoGenerationFfprobePath: z3.string().trim().min(1).max(1024).default("ffprobe"),
|
|
463
899
|
// OpenGeni's customer price, not a claim about the provider's delayed cost report.
|
|
464
900
|
// The durable operation freezes the exact resulting price before provider submit.
|
|
465
|
-
videoGenerationCredit480pMicrosPerSecond:
|
|
466
|
-
videoGenerationCredit720pMicrosPerSecond:
|
|
901
|
+
videoGenerationCredit480pMicrosPerSecond: z3.coerce.number().int().positive().max(1e7).default(155e3),
|
|
902
|
+
videoGenerationCredit720pMicrosPerSecond: z3.coerce.number().int().positive().max(1e7).default(35e4),
|
|
467
903
|
// Native composer voice input (browser MediaRecorder → API transcription).
|
|
468
904
|
// Provider credentials stay server-side; ClientConfig only projects availability
|
|
469
905
|
// and hard ceilings. Selection happens once before audio is sent — never retry
|
|
470
906
|
// the same clip across vendors after an upstream request may have started.
|
|
471
|
-
voiceInputMaxDurationSeconds:
|
|
472
|
-
voiceInputMaxSizeBytes:
|
|
907
|
+
voiceInputMaxDurationSeconds: z3.coerce.number().int().positive().max(600).default(60),
|
|
908
|
+
voiceInputMaxSizeBytes: z3.coerce.number().int().positive().max(25 * 1024 * 1024).default(25 * 1024 * 1024),
|
|
473
909
|
// Durable long-form capture uploads bounded chunks to object storage, then
|
|
474
910
|
// normalizes them into provider-safe segments. It is advertised only when
|
|
475
911
|
// object storage and the configured ffmpeg executable are both available.
|
|
476
912
|
voiceInputResumableEnabled: EnvBoolean.default(true),
|
|
477
|
-
voiceInputResumableMaxDurationSeconds:
|
|
478
|
-
voiceInputResumableMaxSizeBytes:
|
|
479
|
-
voiceInputResumableMaxChunkSizeBytes:
|
|
480
|
-
voiceInputResumableRetentionSeconds:
|
|
481
|
-
voiceInputFfmpegPath:
|
|
913
|
+
voiceInputResumableMaxDurationSeconds: z3.coerce.number().int().positive().max(8 * 60 * 60).default(2 * 60 * 60),
|
|
914
|
+
voiceInputResumableMaxSizeBytes: z3.coerce.number().int().positive().max(512 * 1024 * 1024).default(512 * 1024 * 1024),
|
|
915
|
+
voiceInputResumableMaxChunkSizeBytes: z3.coerce.number().int().positive().max(25 * 1024 * 1024).default(8 * 1024 * 1024),
|
|
916
|
+
voiceInputResumableRetentionSeconds: z3.coerce.number().int().positive().max(7 * 24 * 60 * 60).default(24 * 60 * 60),
|
|
917
|
+
voiceInputFfmpegPath: z3.string().trim().min(1).max(1024).default("ffmpeg"),
|
|
482
918
|
// Preferred provider order (comma-separated ids). First configured+ready wins.
|
|
483
919
|
// Connected subscription STT is preferred by default; operators can put
|
|
484
920
|
// openai/azure-openai first explicitly.
|
|
485
921
|
// Supported: supergrok-subscription, codex-subscription, openai, azure-openai.
|
|
486
|
-
voiceInputProviderOrder:
|
|
922
|
+
voiceInputProviderOrder: z3.string().default("supergrok-subscription,codex-subscription,openai,azure-openai"),
|
|
487
923
|
// OpenAI public /v1/audio/transcriptions path. Reuses OPENGENI_OPENAI_API_KEY
|
|
488
924
|
// when voiceInputOpenaiApiKey is unset. Default model is gpt-transcribe.
|
|
489
925
|
voiceInputOpenaiEnabled: EnvBoolean.default(true),
|
|
490
|
-
voiceInputOpenaiApiKey:
|
|
491
|
-
voiceInputOpenaiBaseUrl:
|
|
492
|
-
voiceInputOpenaiModel:
|
|
926
|
+
voiceInputOpenaiApiKey: z3.string().optional(),
|
|
927
|
+
voiceInputOpenaiBaseUrl: z3.string().optional(),
|
|
928
|
+
voiceInputOpenaiModel: z3.string().default("gpt-transcribe"),
|
|
493
929
|
// Azure OpenAI deployment-scoped audio transcriptions. Reuses the turn-model
|
|
494
930
|
// Azure endpoint/key/AD token when voice-specific overrides are unset.
|
|
495
931
|
voiceInputAzureEnabled: EnvBoolean.default(true),
|
|
496
|
-
voiceInputAzureEndpoint:
|
|
497
|
-
voiceInputAzureDeployment:
|
|
498
|
-
voiceInputAzureApiVersion:
|
|
499
|
-
voiceInputAzureApiKey:
|
|
500
|
-
voiceInputAzureAdToken:
|
|
932
|
+
voiceInputAzureEndpoint: z3.string().optional(),
|
|
933
|
+
voiceInputAzureDeployment: z3.string().optional(),
|
|
934
|
+
voiceInputAzureApiVersion: z3.string().optional(),
|
|
935
|
+
voiceInputAzureApiKey: z3.string().optional(),
|
|
936
|
+
voiceInputAzureAdToken: z3.string().optional(),
|
|
501
937
|
// Legacy opt-in for undocumented ChatGPT /backend-api/transcribe. When
|
|
502
938
|
// OPENGENI_CODEX_SUBSCRIPTION_ENABLED is true, Codex STT is included without
|
|
503
939
|
// this flag. Set false and omit codex-subscription from PROVIDER_ORDER to
|
|
504
940
|
// keep subscription model routing while disabling Codex voice input.
|
|
505
941
|
voiceInputCodexExperimentalEnabled: EnvBoolean.default(false),
|
|
506
|
-
modelPricingJson:
|
|
942
|
+
modelPricingJson: z3.string().default("{}"),
|
|
507
943
|
// Supported-model membership source. Database mode is resolved by the async
|
|
508
944
|
// core overlay; getSettings remains synchronous and env-only.
|
|
509
|
-
modelCatalogSource:
|
|
945
|
+
modelCatalogSource: z3.enum(["code", "database"]).default("code"),
|
|
510
946
|
// Deployment-owned workspace-facing price policy. This is deliberately
|
|
511
947
|
// separate from catalog membership and upstream credential ownership.
|
|
512
948
|
// Shape: { "product/model-id": "free" | "credits" }.
|
|
513
|
-
modelCostPolicyJson:
|
|
949
|
+
modelCostPolicyJson: z3.string().default("{}"),
|
|
514
950
|
// Optional per-product agent guidance. Database mode replaces this with the
|
|
515
951
|
// singleton document's validated modelNotes map.
|
|
516
|
-
modelNotesJson:
|
|
952
|
+
modelNotesJson: z3.string().default("{}"),
|
|
517
953
|
// Managed OpenRouter credential. The curated model table is injected in
|
|
518
954
|
// code/catalog-document resolution and never read from host provider JSON.
|
|
519
|
-
openrouterApiKey:
|
|
955
|
+
openrouterApiKey: z3.string().optional(),
|
|
520
956
|
// Internal, secret-free catalog overlays populated only by
|
|
521
957
|
// applyModelCatalogDocument. They intentionally have no OPENGENI_* env
|
|
522
958
|
// binding so database mode cannot be bypassed with a second source.
|
|
523
|
-
resolvedGatewayModelsJson:
|
|
524
|
-
resolvedOpenRouterModelsJson:
|
|
959
|
+
resolvedGatewayModelsJson: z3.string().optional(),
|
|
960
|
+
resolvedOpenRouterModelsJson: z3.string().optional(),
|
|
961
|
+
resolvedCodexModelsJson: z3.string().optional(),
|
|
525
962
|
// Extra (non-built-in) model providers, declared by the host as a JSON
|
|
526
963
|
// provider registry. Each entry carries its own base URL, API key, wire API
|
|
527
964
|
// ("responses" | "chat") and the models it exposes. The models a client may
|
|
528
965
|
// use are the UNION of the built-in provider's allowed models and every
|
|
529
966
|
// registry provider's models. validateSettings parses this at boot so a
|
|
530
967
|
// malformed registry / unresolvable key / id collision fails fast.
|
|
531
|
-
modelProvidersJson:
|
|
968
|
+
modelProvidersJson: z3.string().default("[]"),
|
|
532
969
|
// Codex (ChatGPT) subscription: when enabled, a per-workspace connected
|
|
533
970
|
// subscription is injected as a synthetic "codex-subscription" registry
|
|
534
971
|
// provider whose models route through the ChatGPT backend (@opengeni/codex).
|
|
@@ -538,15 +975,17 @@ var SettingsSchema = z.object({
|
|
|
538
975
|
// account pool and a distinct rail from the existing xai/* API-key provider.
|
|
539
976
|
supergrokSubscriptionEnabled: EnvBoolean.default(false),
|
|
540
977
|
// OPENGENI_SUPERGROK_SUBSCRIPTION_ENABLED
|
|
978
|
+
claudeSubscriptionEnabled: EnvBoolean.default(false),
|
|
979
|
+
// OPENGENI_CLAUDE_SUBSCRIPTION_ENABLED
|
|
541
980
|
// Maximum silence between complete, valid SuperGrok SSE data events. This is
|
|
542
981
|
// not a request/run duration cap; every valid event resets the timer.
|
|
543
|
-
supergrokResponseStreamIdleTimeoutMs:
|
|
982
|
+
supergrokResponseStreamIdleTimeoutMs: z3.coerce.number().int().positive().max(24 * 60 * 6e4).default(XAI_RESPONSE_STREAM_IDLE_TIMEOUT_MS),
|
|
544
983
|
// Expose the connected apps attached to a Codex subscription through the
|
|
545
984
|
// synthetic codex_apps MCP server. Independent from subscription routing so
|
|
546
985
|
// operators can use Codex models without exposing ChatGPT connectors.
|
|
547
986
|
codexConnectedAppsEnabled: EnvBoolean.default(false),
|
|
548
987
|
// OPENGENI_CODEX_CONNECTED_APPS_ENABLED
|
|
549
|
-
codexProductSku:
|
|
988
|
+
codexProductSku: z3.string().optional(),
|
|
550
989
|
// OPENGENI_CODEX_PRODUCT_SKU (X-OpenAI-Product-Sku, apps only)
|
|
551
990
|
// Progressive MCP disclosure (Codex-CLI-style tool_search): on a codex turn,
|
|
552
991
|
// flag non-eager selected MCP tools `defer_loading:true` (dropping their
|
|
@@ -570,10 +1009,23 @@ var SettingsSchema = z.object({
|
|
|
570
1009
|
// Multi-account P3 (auto-rotation): an account is "near exhaustion" — ineligible to be
|
|
571
1010
|
// rotated TO — when EITHER usage window (5h/weekly) is at/over this percent. Default 90 to
|
|
572
1011
|
// match the UI danger flip (UsageBar danger at pct >= 90). OPENGENI_CODEX_ROTATION_NEAR_EXHAUSTION_PCT.
|
|
573
|
-
codexRotationNearExhaustionPct:
|
|
1012
|
+
codexRotationNearExhaustionPct: z3.coerce.number().int().min(1).max(100).default(90),
|
|
1013
|
+
reasoningConfigurationUpdatesEnabled: EnvBoolean.default(false),
|
|
574
1014
|
openaiReasoningEffort: ReasoningEffort.default("low"),
|
|
575
|
-
openaiAllowedReasoningEfforts:
|
|
576
|
-
|
|
1015
|
+
openaiAllowedReasoningEfforts: z3.string().default("low,medium,high,xhigh,max"),
|
|
1016
|
+
// Default for new chats and scheduled tasks when the workspace has an
|
|
1017
|
+
// OpenGeni credit balance, no saved workspace default, and no usable
|
|
1018
|
+
// connected subscription, and the deployment default is not already a
|
|
1019
|
+
// credits-billed model. Selected only when this model is selectable in the
|
|
1020
|
+
// workspace catalog; otherwise the first selectable credits model is used.
|
|
1021
|
+
// OPENGENI_CREDITS_DEFAULT_MODEL / OPENGENI_CREDITS_DEFAULT_REASONING_EFFORT.
|
|
1022
|
+
creditsDefaultModel: z3.string().trim().min(1).max(256).refine((value) => !/[\u000A\u000D|]/u.test(value), {
|
|
1023
|
+
message: "credits default model must not contain newlines or the | field separator"
|
|
1024
|
+
}).default("gpt-6-luna"),
|
|
1025
|
+
// Preferred effort for the credits default. Clamped to the highest effort
|
|
1026
|
+
// the selected model supports at or below this value.
|
|
1027
|
+
creditsDefaultReasoningEffort: ReasoningEffort.default("xhigh"),
|
|
1028
|
+
openaiResponsesTransport: z3.enum(["http", "websocket"]).default("http"),
|
|
577
1029
|
// Provider-assigned item ids (rs_/msg_/fc_…) in Responses API input are
|
|
578
1030
|
// resolved against the provider's server-side response store. That store is
|
|
579
1031
|
// not durable enough to anchor long runs on: a response that streamed fine
|
|
@@ -582,7 +1034,7 @@ var SettingsSchema = z.object({
|
|
|
582
1034
|
// every model-call input so requests are self-contained — conversation
|
|
583
1035
|
// truth already lives client-side in session_history_items. "preserve"
|
|
584
1036
|
// keeps the SDK's pass-through behavior.
|
|
585
|
-
openaiProviderItemIds:
|
|
1037
|
+
openaiProviderItemIds: z3.enum(["strip", "preserve"]).default("strip"),
|
|
586
1038
|
// With ids stripped the provider cannot resolve prior reasoning server-side,
|
|
587
1039
|
// so request reasoning.encrypted_content and send it back with each call:
|
|
588
1040
|
// reasoning continuity without depending on provider-side storage.
|
|
@@ -590,7 +1042,7 @@ var SettingsSchema = z.object({
|
|
|
590
1042
|
// Model-call retry budget for transient provider failures (429s and friends).
|
|
591
1043
|
// The openai client default of 2 retries is too small for sustained TPM
|
|
592
1044
|
// backpressure during long autonomous runs.
|
|
593
|
-
openaiMaxRetries:
|
|
1045
|
+
openaiMaxRetries: z3.coerce.number().int().nonnegative().default(5),
|
|
594
1046
|
// Native hosted web search. The live Azure Responses path executes the
|
|
595
1047
|
// hosted web_search tool, so this is provider-unconditional: ON by default
|
|
596
1048
|
// on every provider, exposed only so operators can disable it. When true,
|
|
@@ -598,6 +1050,19 @@ var SettingsSchema = z.object({
|
|
|
598
1050
|
// merged with the MCP-server tools (getAllTools = [...mcpTools, ...tools])
|
|
599
1051
|
// and the sandbox capability tools, never replacing them.
|
|
600
1052
|
webSearchEnabled: EnvBoolean.default(true),
|
|
1053
|
+
// Jev (TypeSafe's fast judge model) for worker-side agent tools. Without a
|
|
1054
|
+
// usable key every Jev-backed feature is off. The key stays on the server
|
|
1055
|
+
// (API and worker) and never reaches a sandbox or Connected Machine.
|
|
1056
|
+
jevApiKey: z3.string().optional(),
|
|
1057
|
+
jevBaseUrl: z3.string().url().default("https://api.typesafe.ai"),
|
|
1058
|
+
jevModel: z3.string().trim().min(1).max(128).default("jev-latest"),
|
|
1059
|
+
jevRequestTimeoutMs: z3.coerce.number().int().positive().max(12e4).default(1e4),
|
|
1060
|
+
// Jev-backed `code_search` agent tool. `off` never offers it, `opt_in` offers
|
|
1061
|
+
// it only where workspace settings enable it, `default_on` offers it
|
|
1062
|
+
// everywhere except workspaces that disable it, and `experiment` gives it to
|
|
1063
|
+
// a fixed half of sessions in workspaces without their own setting, for
|
|
1064
|
+
// comparison. It also needs jevApiKey.
|
|
1065
|
+
codeSearchMode: z3.enum(["off", "opt_in", "default_on", "experiment"]).default("off"),
|
|
601
1066
|
// Deployment-default agent persona template (the white-label surface). The
|
|
602
1067
|
// runtime resolves the effective template per turn as
|
|
603
1068
|
// per-session-override > per-workspace override > this default, substitutes
|
|
@@ -605,38 +1070,40 @@ var SettingsSchema = z.object({
|
|
|
605
1070
|
// it when the template omits the marker), and uses the result as the agent's
|
|
606
1071
|
// instructions. Defaulting to DEFAULT_AGENT_INSTRUCTIONS keeps the composed
|
|
607
1072
|
// default pinned by runtime tests.
|
|
608
|
-
agentInstructionsTemplate:
|
|
609
|
-
azureOpenaiBaseUrl:
|
|
610
|
-
azureOpenaiEndpoint:
|
|
611
|
-
azureOpenaiDeployment:
|
|
612
|
-
azureOpenaiApiVersion:
|
|
613
|
-
azureOpenaiApiKey:
|
|
614
|
-
azureOpenaiAdToken:
|
|
1073
|
+
agentInstructionsTemplate: z3.string().default(DEFAULT_AGENT_INSTRUCTIONS),
|
|
1074
|
+
azureOpenaiBaseUrl: z3.string().optional(),
|
|
1075
|
+
azureOpenaiEndpoint: z3.string().optional(),
|
|
1076
|
+
azureOpenaiDeployment: z3.string().optional(),
|
|
1077
|
+
azureOpenaiApiVersion: z3.string().optional(),
|
|
1078
|
+
azureOpenaiApiKey: z3.string().optional(),
|
|
1079
|
+
azureOpenaiAdToken: z3.string().optional(),
|
|
615
1080
|
disableOpenaiTracing: EnvBoolean.default(false),
|
|
616
1081
|
sandboxBackend: SandboxBackend.default("docker"),
|
|
617
|
-
dockerImage:
|
|
1082
|
+
dockerImage: z3.string().default("opengeni-sandbox:local"),
|
|
618
1083
|
// Explicit deployment contract: the configured base sandbox image contains
|
|
619
1084
|
// the verified, self-contained native artifact runtime at its fixed image
|
|
620
1085
|
// paths. Disabled by default so arbitrary/custom provider images never make
|
|
621
1086
|
// document/spreadsheet/presentation skills appear when their runtime is
|
|
622
|
-
// absent. Per-pack/per-rig image overrides fail closed in the worker even
|
|
623
1087
|
// when this base-image contract is enabled.
|
|
624
1088
|
sandboxArtifactRuntimeEnabled: EnvBoolean.default(false),
|
|
625
|
-
dockerExposedPorts:
|
|
626
|
-
dockerNetwork:
|
|
1089
|
+
dockerExposedPorts: z3.string().default(""),
|
|
1090
|
+
dockerNetwork: z3.string().optional(),
|
|
627
1091
|
// When the worker itself runs in a container and talks to a host Docker daemon,
|
|
628
1092
|
// this directory must be bind-mounted at the exact same absolute path on both
|
|
629
1093
|
// sides. The Agents SDK materializes the workspace here before bind-mounting it
|
|
630
1094
|
// into the sandbox container.
|
|
631
|
-
dockerWorkspaceBaseDir:
|
|
632
|
-
modalAppName:
|
|
633
|
-
modalImageRef:
|
|
1095
|
+
dockerWorkspaceBaseDir: z3.string().min(1).optional(),
|
|
1096
|
+
modalAppName: z3.string().default("opengeni-sandbox"),
|
|
1097
|
+
modalImageRef: z3.string().optional(),
|
|
1098
|
+
// Activate only after descriptor-aware readers, DB fences and the exact
|
|
1099
|
+
// native image have passed the supervised-command rollout canary.
|
|
1100
|
+
modalCommandSupervisionEnabled: EnvBoolean.default(false),
|
|
634
1101
|
// Provider-native immutable Modal image ID for the exact logical
|
|
635
1102
|
// `modalImageRef`. When set, the runtime uses ModalImageSelector.fromId and
|
|
636
1103
|
// never asks Modal to parse or import the registry ref. The logical ref is
|
|
637
1104
|
// still persisted on the sandbox lease for provenance and conflict fencing;
|
|
638
1105
|
// the Modal session envelope persists the actual image ID.
|
|
639
|
-
modalImageId:
|
|
1106
|
+
modalImageId: z3.string().min(4).max(128).regex(/^im-[A-Za-z0-9]+$/).optional(),
|
|
640
1107
|
// Name of a Modal Secret (containing REGISTRY_USERNAME + REGISTRY_PASSWORD) used
|
|
641
1108
|
// to authenticate the pull of `modalImageRef` from a PRIVATE registry. When UNSET
|
|
642
1109
|
// (the default), the sandbox image is pulled UNAUTHENTICATED — i.e. it must be a
|
|
@@ -645,7 +1112,7 @@ var SettingsSchema = z.object({
|
|
|
645
1112
|
// run a private image (e.g. a cloud-hosted ACR/ECR/GCR digest): the runtime resolves
|
|
646
1113
|
// the named Secret and builds the image via `fromRegistry(tag, secret)` before the
|
|
647
1114
|
// first sandbox is created. Knob: OPENGENI_MODAL_IMAGE_REGISTRY_SECRET.
|
|
648
|
-
modalImageRegistrySecret:
|
|
1115
|
+
modalImageRegistrySecret: z3.string().optional(),
|
|
649
1116
|
// Modal's hard sandbox lifetime (timeoutMs = this * 1000), counted from box
|
|
650
1117
|
// creation. A resume-by-id does NOT reset that provider clock. It is the
|
|
651
1118
|
// BACKSTOP that reclaims a box if the reaper/worker is down, NOT the warm-window
|
|
@@ -656,17 +1123,17 @@ var SettingsSchema = z.object({
|
|
|
656
1123
|
// deadline-aware snapshot/rematerialization transition. The transition—not a
|
|
657
1124
|
// larger timeout—is what lets a session outlive one finite provider box.
|
|
658
1125
|
// Knob: OPENGENI_MODAL_TIMEOUT_SECONDS.
|
|
659
|
-
modalTimeoutSeconds:
|
|
1126
|
+
modalTimeoutSeconds: z3.coerce.number().int().positive().max(86400).default(86400),
|
|
660
1127
|
// Optional provider reservations for every new Modal sandbox. CPU is measured
|
|
661
1128
|
// in physical cores and may be fractional; memory is measured in MiB. Leave
|
|
662
1129
|
// both unset to preserve Modal's provider defaults. The Agents adapter stores
|
|
663
1130
|
// the resolved values in its session state so snapshot replacement and exact
|
|
664
1131
|
// resume cannot silently change the reservation.
|
|
665
|
-
modalSandboxCpu:
|
|
666
|
-
modalSandboxMemoryMiB:
|
|
667
|
-
modalTokenId:
|
|
668
|
-
modalTokenSecret:
|
|
669
|
-
modalEnvironment:
|
|
1132
|
+
modalSandboxCpu: z3.coerce.number().positive().optional(),
|
|
1133
|
+
modalSandboxMemoryMiB: z3.coerce.number().int().positive().optional(),
|
|
1134
|
+
modalTokenId: z3.string().optional(),
|
|
1135
|
+
modalTokenSecret: z3.string().optional(),
|
|
1136
|
+
modalEnvironment: z3.string().optional(),
|
|
670
1137
|
// modal gap-fill: idleTimeoutMs + workspacePersistence were unmapped (module 03 §4.1).
|
|
671
1138
|
//
|
|
672
1139
|
// CRITICAL (sandbox-file-persistence): when this is UNSET the Modal SDK sends
|
|
@@ -684,7 +1151,7 @@ var SettingsSchema = z.object({
|
|
|
684
1151
|
// explicitly (OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS) only to deliberately idle-reap
|
|
685
1152
|
// SOONER than the hard lifetime; the boot invariant forbids a value that would
|
|
686
1153
|
// reap before reaperPeriod + idleGrace elapses.
|
|
687
|
-
modalIdleTimeoutSeconds:
|
|
1154
|
+
modalIdleTimeoutSeconds: z3.coerce.number().int().positive().optional(),
|
|
688
1155
|
// /workspace FILE PERSISTENCE across warm/cold cycles. Directory snapshots
|
|
689
1156
|
// preserve only the durable user workspace, so provider recovery does not
|
|
690
1157
|
// restore an entire machine image or replace the selected rig/base image.
|
|
@@ -693,16 +1160,14 @@ var SettingsSchema = z.object({
|
|
|
693
1160
|
// Modal creations only.
|
|
694
1161
|
// `snapshot_filesystem` remains available for explicit compatibility and
|
|
695
1162
|
// immutable rig-image materialization. `tar` is the portable fallback.
|
|
696
|
-
modalWorkspacePersistence:
|
|
1163
|
+
modalWorkspacePersistence: z3.enum(["tar", "snapshot_filesystem", "snapshot_directory"]).default("snapshot_directory"),
|
|
697
1164
|
// Shared desktop toggle: this module reads it for the 6080 port-merge; the
|
|
698
1165
|
// owner module (P4.x) acts on it to launch the display stack.
|
|
699
1166
|
sandboxDesktopEnabled: EnvBoolean.default(false),
|
|
700
|
-
// Human
|
|
701
|
-
//
|
|
702
|
-
//
|
|
703
|
-
//
|
|
704
|
-
// "Take control" affordance. This gates the HUMAN viewer plane; agent
|
|
705
|
-
// interaction is authorized through managed ComputerSession tools.
|
|
1167
|
+
// Human sandbox input policy. Canonical ComputerSession attachments reflect
|
|
1168
|
+
// it and /actions enforces it independently of the client. The legacy
|
|
1169
|
+
// DesktopStream adapter also reports read-only when disabled. Agent tools
|
|
1170
|
+
// retain their separate session-control authority.
|
|
706
1171
|
sandboxDesktopInteractive: EnvBoolean.default(true),
|
|
707
1172
|
// REAL PTY terminal toggle (P5.t): gates the ttyd pty-ws plane (7681) the API
|
|
708
1173
|
// mints over the SAME tunnel as the desktop. Defaults ON — the interactive
|
|
@@ -714,13 +1179,13 @@ var SettingsSchema = z.object({
|
|
|
714
1179
|
// The desktop framebuffer geometry the pixel plane advertises + launches the
|
|
715
1180
|
// display stack with (P4.2). v1 has no live RANDR resize; a change is a full
|
|
716
1181
|
// down→up restart. Defaults match the proven spike geometry (1280x800).
|
|
717
|
-
streamResolutionWidth:
|
|
718
|
-
streamResolutionHeight:
|
|
1182
|
+
streamResolutionWidth: z3.coerce.number().int().positive().default(1280),
|
|
1183
|
+
streamResolutionHeight: z3.coerce.number().int().positive().default(800),
|
|
719
1184
|
// Recording loop: ffmpeg x11grab of :0 → mp4/webm → @opengeni/storage.
|
|
720
1185
|
// recordingMaxBytes caps the in-memory finalize buffer (≤ storage single-PUT);
|
|
721
1186
|
// recordingMaxSeconds is the ffmpeg -t hard ceiling (bounds a multi-day turn).
|
|
722
1187
|
recordingEnabled: EnvBoolean.default(true),
|
|
723
|
-
recordingDefaultCodec:
|
|
1188
|
+
recordingDefaultCodec: z3.enum(["h264-mp4", "vp9-webm"]).default("h264-mp4"),
|
|
724
1189
|
// Workbench v2 turn-end workspace capture. When on, the turn
|
|
725
1190
|
// activity probes the box's changed files off the live box at turn end and
|
|
726
1191
|
// persists a capture revision (blobs in @opengeni/storage) so the workbench
|
|
@@ -728,85 +1193,86 @@ var SettingsSchema = z.object({
|
|
|
728
1193
|
// fully behind this flag: off ⇒ capture is skipped and reads fall back to the
|
|
729
1194
|
// live/wake path (status-quo behavior). Default on; explicit per environment.
|
|
730
1195
|
workspaceCaptureEnabled: EnvBoolean.default(true),
|
|
731
|
-
recordingFramerate:
|
|
732
|
-
recordingMaxSeconds:
|
|
733
|
-
recordingMaxBytes:
|
|
1196
|
+
recordingFramerate: z3.coerce.number().int().positive().default(15),
|
|
1197
|
+
recordingMaxSeconds: z3.coerce.number().int().positive().default(600),
|
|
1198
|
+
recordingMaxBytes: z3.coerce.number().int().positive().default(268435456),
|
|
734
1199
|
// 256 MB
|
|
735
1200
|
// --- daytona ---
|
|
736
|
-
daytonaApiKey:
|
|
737
|
-
daytonaApiUrl:
|
|
738
|
-
daytonaTarget:
|
|
739
|
-
daytonaImage:
|
|
740
|
-
daytonaSnapshotName:
|
|
741
|
-
daytonaAutoStopInterval:
|
|
1201
|
+
daytonaApiKey: z3.string().optional(),
|
|
1202
|
+
daytonaApiUrl: z3.string().url().optional(),
|
|
1203
|
+
daytonaTarget: z3.string().optional(),
|
|
1204
|
+
daytonaImage: z3.string().optional(),
|
|
1205
|
+
daytonaSnapshotName: z3.string().optional(),
|
|
1206
|
+
daytonaAutoStopInterval: z3.coerce.number().int().nonnegative().optional(),
|
|
742
1207
|
// 0 disables idle-kill
|
|
743
|
-
daytonaTimeoutSeconds:
|
|
744
|
-
daytonaExposedPortUrlTtlSeconds:
|
|
1208
|
+
daytonaTimeoutSeconds: z3.coerce.number().int().positive().optional(),
|
|
1209
|
+
daytonaExposedPortUrlTtlSeconds: z3.coerce.number().int().positive().optional(),
|
|
745
1210
|
// --- runloop ---
|
|
746
|
-
runloopApiKey:
|
|
747
|
-
runloopBaseUrl:
|
|
748
|
-
runloopBlueprintName:
|
|
749
|
-
runloopBlueprintId:
|
|
1211
|
+
runloopApiKey: z3.string().optional(),
|
|
1212
|
+
runloopBaseUrl: z3.string().url().optional(),
|
|
1213
|
+
runloopBlueprintName: z3.string().optional(),
|
|
1214
|
+
runloopBlueprintId: z3.string().optional(),
|
|
750
1215
|
runloopTunnel: EnvBoolean.default(true),
|
|
751
|
-
runloopKeepAliveSeconds:
|
|
1216
|
+
runloopKeepAliveSeconds: z3.coerce.number().int().positive().optional(),
|
|
752
1217
|
// --- e2b (SDK reads E2B_API_KEY from env; mirrored for validation + forwarding) ---
|
|
753
|
-
e2bApiKey:
|
|
754
|
-
e2bTemplate:
|
|
755
|
-
e2bTimeoutSeconds:
|
|
756
|
-
e2bTimeoutAction:
|
|
1218
|
+
e2bApiKey: z3.string().optional(),
|
|
1219
|
+
e2bTemplate: z3.string().optional(),
|
|
1220
|
+
e2bTimeoutSeconds: z3.coerce.number().int().positive().optional(),
|
|
1221
|
+
e2bTimeoutAction: z3.enum(["pause", "kill"]).optional(),
|
|
757
1222
|
e2bAllowInternetAccess: EnvBoolean.optional(),
|
|
758
1223
|
e2bAutoResume: EnvBoolean.optional(),
|
|
759
|
-
e2bWorkspacePersistence:
|
|
1224
|
+
e2bWorkspacePersistence: z3.enum(["tar", "snapshot"]).optional(),
|
|
760
1225
|
// --- blaxel ---
|
|
761
|
-
blaxelApiKey:
|
|
762
|
-
blaxelImage:
|
|
763
|
-
blaxelRegion:
|
|
1226
|
+
blaxelApiKey: z3.string().optional(),
|
|
1227
|
+
blaxelImage: z3.string().optional(),
|
|
1228
|
+
blaxelRegion: z3.string().optional(),
|
|
764
1229
|
blaxelExposedPortPublic: EnvBoolean.optional(),
|
|
765
1230
|
// public vs bl_preview_token
|
|
766
|
-
blaxelExposedPortUrlTtlSeconds:
|
|
767
|
-
blaxelMemoryMb:
|
|
768
|
-
blaxelTtl:
|
|
1231
|
+
blaxelExposedPortUrlTtlSeconds: z3.coerce.number().int().positive().optional(),
|
|
1232
|
+
blaxelMemoryMb: z3.coerce.number().int().positive().optional(),
|
|
1233
|
+
blaxelTtl: z3.string().optional(),
|
|
769
1234
|
// --- cloudflare (headless) ---
|
|
770
|
-
cloudflareWorkerUrl:
|
|
771
|
-
cloudflareApiKey:
|
|
1235
|
+
cloudflareWorkerUrl: z3.string().url().optional(),
|
|
1236
|
+
cloudflareApiKey: z3.string().optional(),
|
|
1237
|
+
experimentalBrowserContextPoolEnabled: EnvBoolean.default(false),
|
|
772
1238
|
// --- remote browser placements ---
|
|
773
1239
|
// Provider credentials are injected only into the placement-resident
|
|
774
1240
|
// browserd launch. They never enter session contracts, journals, or sandboxes.
|
|
775
|
-
browserbaseApiKey:
|
|
776
|
-
kernelApiKey:
|
|
777
|
-
kernelEndpoint:
|
|
778
|
-
kernelBrowserTimeoutSeconds:
|
|
1241
|
+
browserbaseApiKey: z3.string().min(1).max(8192).optional(),
|
|
1242
|
+
kernelApiKey: z3.string().min(1).max(8192).optional(),
|
|
1243
|
+
kernelEndpoint: z3.string().url().optional(),
|
|
1244
|
+
kernelBrowserTimeoutSeconds: z3.coerce.number().int().positive().max(86400).default(3600),
|
|
779
1245
|
kernelBrowserStealth: EnvBoolean.default(false),
|
|
780
1246
|
// --- vercel (headless) ---
|
|
781
|
-
vercelToken:
|
|
782
|
-
vercelProjectId:
|
|
783
|
-
vercelTeamId:
|
|
784
|
-
vercelRuntime:
|
|
1247
|
+
vercelToken: z3.string().optional(),
|
|
1248
|
+
vercelProjectId: z3.string().optional(),
|
|
1249
|
+
vercelTeamId: z3.string().optional(),
|
|
1250
|
+
vercelRuntime: z3.string().optional(),
|
|
785
1251
|
// --- OpenSandbox (optional Kubernetes-native provisioned sandbox) ---
|
|
786
|
-
openSandboxBaseUrl:
|
|
787
|
-
openSandboxApiKey:
|
|
1252
|
+
openSandboxBaseUrl: z3.string().url().optional(),
|
|
1253
|
+
openSandboxApiKey: z3.string().min(1).optional(),
|
|
788
1254
|
// Release and preview profiles must provide an immutable OCI digest. The
|
|
789
1255
|
// adapter refuses tag-only references when this backend is active.
|
|
790
|
-
openSandboxImage:
|
|
1256
|
+
openSandboxImage: z3.string().min(1).optional(),
|
|
791
1257
|
// Renewable provider TTL is a leak/backstop clock, not OpenGeni's idle
|
|
792
1258
|
// policy. The pinned server accepts a one-minute minimum; ordinary
|
|
793
1259
|
// deployments default to one hour.
|
|
794
|
-
openSandboxTtlSeconds:
|
|
1260
|
+
openSandboxTtlSeconds: z3.coerce.number().int().min(60).max(86400).default(3600),
|
|
795
1261
|
openSandboxUseServerProxy: EnvBoolean.default(true),
|
|
796
1262
|
// Channel B (browserd / noVNC / ttyd) uses OSEP-0011 signed URI-mode ingress.
|
|
797
1263
|
// Exec/files stay on the private lifecycle server-proxy regardless of this flag.
|
|
798
1264
|
openSandboxSignedEndpoints: EnvBoolean.default(false),
|
|
799
|
-
openSandboxSignedEndpointTtlSeconds:
|
|
800
|
-
openSandboxChannelBPublicBaseUrl:
|
|
1265
|
+
openSandboxSignedEndpointTtlSeconds: z3.coerce.number().int().min(60).max(3600).default(600),
|
|
1266
|
+
openSandboxChannelBPublicBaseUrl: z3.string().url().optional(),
|
|
801
1267
|
// Emergency hatch only: force JPEG/RFB through the API frame-proxy even when
|
|
802
1268
|
// signed endpoints are on (M2 subprotocol failure). Unset means OpenSandbox
|
|
803
1269
|
// uses the frame-proxy unless signed endpoints are on.
|
|
804
1270
|
openSandboxInteractionFrameProxy: EnvBoolean.optional(),
|
|
805
|
-
openSandboxPoolRef:
|
|
1271
|
+
openSandboxPoolRef: z3.string().regex(/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/).optional(),
|
|
806
1272
|
// Optional same-cluster, read-only observability projection. The application
|
|
807
1273
|
// chart sets this only on the control worker and mounts a dedicated projected
|
|
808
1274
|
// service-account token; non-Kubernetes and remote-provider deployments omit it.
|
|
809
|
-
openSandboxKubernetesInventoryNamespace:
|
|
1275
|
+
openSandboxKubernetesInventoryNamespace: z3.string().min(1).max(63).regex(/^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$/).optional(),
|
|
810
1276
|
// --- sandbox ownership inversion (P1.2 rollout flag, default OFF) ---
|
|
811
1277
|
// The keystone flag for the stateless resume-by-id model. When FALSE the
|
|
812
1278
|
// agent-turn path is BYTE-FOR-BYTE today's build-and-discard behavior (no
|
|
@@ -860,13 +1326,13 @@ var SettingsSchema = z.object({
|
|
|
860
1326
|
// when ABSENT and sandboxSelfhostedEnabled is on, the poll route reports the
|
|
861
1327
|
// credential plane disabled (graceful degrade, mirrors streamTokenSecret). NEVER
|
|
862
1328
|
// logged. Lives in the opengeni-runtime secret (Helm-clobbered configmap avoided).
|
|
863
|
-
enrollmentSigningSecret:
|
|
1329
|
+
enrollmentSigningSecret: z3.string().optional(),
|
|
864
1330
|
// Connect-info the EnrollmentCredentials hand the agent: the NATS server URL(s)
|
|
865
1331
|
// the agent dials for the control plane, and the relay edge base URL for streams.
|
|
866
1332
|
// The per-workspace NATS Account creds binding is infra-deferred (M4/relay
|
|
867
1333
|
// milestone) — the poll returns these endpoints + a placeholder creds field.
|
|
868
|
-
selfhostedNatsUrl:
|
|
869
|
-
selfhostedRelayUrl:
|
|
1334
|
+
selfhostedNatsUrl: z3.string().optional(),
|
|
1335
|
+
selfhostedRelayUrl: z3.string().optional(),
|
|
870
1336
|
// The HMAC secret the control plane signs the agent's relay PRODUCER token with
|
|
871
1337
|
// (the `ogr_` envelope threaded into EnrollmentCredentials.relayToken; M8b/design
|
|
872
1338
|
// §10.5). The relay verifies the producer token with the SAME secret. Optional:
|
|
@@ -874,10 +1340,10 @@ var SettingsSchema = z.object({
|
|
|
874
1340
|
// plane is simply unavailable until configured). Falls back to streamTokenSecret /
|
|
875
1341
|
// delegationSecret (same HMAC family) so a deployment with a stream-token secret
|
|
876
1342
|
// needs no second one. NEVER logged. Lives in the opengeni-runtime secret.
|
|
877
|
-
selfhostedRelayTokenSecret:
|
|
1343
|
+
selfhostedRelayTokenSecret: z3.string().optional(),
|
|
878
1344
|
// The minisign PUBLIC key the agent pins for self-update verification (handed to
|
|
879
1345
|
// the agent in EnrollmentCredentials; the SECRET key lives only in CI).
|
|
880
|
-
agentUpdatePublicKey:
|
|
1346
|
+
agentUpdatePublicKey: z3.string().optional(),
|
|
881
1347
|
// --- NATS auth-callout tenancy boundary (bring-your-own-compute M-AUTH; design
|
|
882
1348
|
// §10.1 NATS Accounts per workspace + §17 the isolation smoke) -------------
|
|
883
1349
|
// nats-server is configured with AUTH CALLOUT: an external agent connects
|
|
@@ -894,24 +1360,24 @@ var SettingsSchema = z.object({
|
|
|
894
1360
|
// The callout account SIGNING SEED (`SA...`). Both the user JWT and the
|
|
895
1361
|
// authorization-response JWT are signed by this account key; its public key
|
|
896
1362
|
// (`A...`) is the `auth_callout.issuer` in the server config. NEVER logged.
|
|
897
|
-
selfhostedNatsCalloutAccountSeed:
|
|
1363
|
+
selfhostedNatsCalloutAccountSeed: z3.string().optional(),
|
|
898
1364
|
// The TARGET ACCOUNT NAME the minted user is placed into (the server-config-mode
|
|
899
1365
|
// `auth_callout.account`, e.g. "APP"). The responder writes it as the minted user
|
|
900
1366
|
// JWT `aud` so nats-server binds the agent to this account — the SAME account the
|
|
901
1367
|
// privileged control plane connects into, so exact process request/reply
|
|
902
1368
|
// routes. Optional; resolveNatsCalloutConfig defaults it to "APP".
|
|
903
|
-
selfhostedNatsCalloutAccountName:
|
|
1369
|
+
selfhostedNatsCalloutAccountName: z3.string().optional(),
|
|
904
1370
|
// The callout RESPONDER's own NATS login (one of the `auth_callout.auth_users`
|
|
905
1371
|
// in the AUTH account) — the responder connects with this to subscribe
|
|
906
1372
|
// $SYS.REQ.USER.AUTH. Username/password.
|
|
907
|
-
selfhostedNatsCalloutUser:
|
|
908
|
-
selfhostedNatsCalloutPassword:
|
|
1373
|
+
selfhostedNatsCalloutUser: z3.string().optional(),
|
|
1374
|
+
selfhostedNatsCalloutPassword: z3.string().optional(),
|
|
909
1375
|
// The PRIVILEGED control-plane login (api/worker): a static account user that may
|
|
910
1376
|
// request exact process RPC subjects + receive their inbox replies. The event bus + the
|
|
911
1377
|
// selfhosted control RPC ride THIS connection. Username/password; when unset the
|
|
912
1378
|
// bus connects anonymously (local dev / a NATS with no auth_callout).
|
|
913
|
-
selfhostedNatsControlUser:
|
|
914
|
-
selfhostedNatsControlPassword:
|
|
1379
|
+
selfhostedNatsControlUser: z3.string().optional(),
|
|
1380
|
+
selfhostedNatsControlPassword: z3.string().optional(),
|
|
915
1381
|
// --- selfhosted (Connected Machine) control/exec op deadlines ---------------
|
|
916
1382
|
// CONTROL ops (ping / fs / git / desktop / pty) keep a short request timeout so
|
|
917
1383
|
// liveness failures surface promptly. EXEC duration is a different concern: by
|
|
@@ -921,8 +1387,8 @@ var SettingsSchema = z.object({
|
|
|
921
1387
|
// process deadline by setting a positive value; 0 never schedules a process kill.
|
|
922
1388
|
// Knobs: OPENGENI_SANDBOX_SELFHOSTED_EXEC_TIMEOUT_MS (default 0 = none) and
|
|
923
1389
|
// OPENGENI_SANDBOX_SELFHOSTED_CONTROL_TIMEOUT_MS (default 30s).
|
|
924
|
-
sandboxSelfhostedExecTimeoutMs:
|
|
925
|
-
sandboxSelfhostedControlTimeoutMs:
|
|
1390
|
+
sandboxSelfhostedExecTimeoutMs: z3.coerce.number().int().nonnegative().default(0),
|
|
1391
|
+
sandboxSelfhostedControlTimeoutMs: z3.coerce.number().int().positive().default(3e4),
|
|
926
1392
|
// --- sandbox lease cadences (cadence invariant validated at boot below) ---
|
|
927
1393
|
// reaperPeriod < viewerHolderTTL, and reaperPeriod + idleGrace < the EFFECTIVE
|
|
928
1394
|
// box idle timeout (effectiveModalIdleTimeoutSeconds, which defaults to the hard
|
|
@@ -930,12 +1396,12 @@ var SettingsSchema = z.object({
|
|
|
930
1396
|
// idle timeout — which we pin high enough (via the idle-timeout default) that
|
|
931
1397
|
// OpenGeni's reaper, not Modal's idle-reap, governs teardown so /workspace is
|
|
932
1398
|
// snapshotted before the box dies (sandbox-file-persistence).
|
|
933
|
-
sandboxLeaseReaperPeriodMs:
|
|
934
|
-
sandboxViewerHolderTtlMs:
|
|
1399
|
+
sandboxLeaseReaperPeriodMs: z3.coerce.number().int().positive().default(3e4),
|
|
1400
|
+
sandboxViewerHolderTtlMs: z3.coerce.number().int().positive().default(9e4),
|
|
935
1401
|
// A BrowserSession controller refreshes its durable resource and exact
|
|
936
1402
|
// interaction lease holder together. This longer crash horizon tolerates API
|
|
937
1403
|
// replacement while still releasing a placement whose controller died.
|
|
938
|
-
sandboxInteractionHolderTtlMs:
|
|
1404
|
+
sandboxInteractionHolderTtlMs: z3.coerce.number().int().positive().default(18e4),
|
|
939
1405
|
// The DRAIN grace: how long a refcount-0 (draining) lease stays WARM before the
|
|
940
1406
|
// reaper resume-by-ids the box and terminates it. This is the cost-vs-snappiness
|
|
941
1407
|
// dial — when the user navigates away the box keeps refcount 0, but it survives
|
|
@@ -945,7 +1411,29 @@ var SettingsSchema = z.object({
|
|
|
945
1411
|
// fresh EMPTY box; lower it to trade warm cost for a snappier reclaim.
|
|
946
1412
|
// getSettings caps the default at half a shorter configured Modal lifetime so
|
|
947
1413
|
// the entire reaper window always fits. Knob: OPENGENI_SANDBOX_IDLE_GRACE_MS.
|
|
948
|
-
sandboxIdleGraceMs:
|
|
1414
|
+
sandboxIdleGraceMs: z3.coerce.number().int().positive().default(9e5),
|
|
1415
|
+
// Idle command containment. A legacy retained background command (a dev
|
|
1416
|
+
// server, a command whose output is still draining, a stopped command the
|
|
1417
|
+
// provider no longer answers for) keeps its box warm through a non-expiring
|
|
1418
|
+
// process holder, so the zero-holder drain never runs and the box would stay
|
|
1419
|
+
// up until the provider deadline kills it uncaptured. Once every session of
|
|
1420
|
+
// the sandbox group has been unused this long - no open turn or pending
|
|
1421
|
+
// request, no held wait_for_input, no other holder or writer, measured from
|
|
1422
|
+
// durable turn/holder/admission facts - the reaper checkpoints the workspace,
|
|
1423
|
+
// stops the box and settles those commands `lost` with reason
|
|
1424
|
+
// `idle_containment`. Default 30min: twice the default
|
|
1425
|
+
// idle grace, so a lease that is only waiting for a "glanced away" user is
|
|
1426
|
+
// never contained earlier than an idle lease would drain, and well inside
|
|
1427
|
+
// the 1h provider-deadline rotation lead, so an idle box is saved long before
|
|
1428
|
+
// the deadline path has to act. Set 0 to disable new idle enrollments without
|
|
1429
|
+
// disabling provider-deadline containment or cancelling an enrolled drain.
|
|
1430
|
+
// A positive window must exceed OPENGENI_SANDBOX_IDLE_GRACE_MS;
|
|
1431
|
+
// an explicit positive value must also stay below OPENGENI_SANDBOX_ROTATION_LEAD_MS,
|
|
1432
|
+
// and with an explicit OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS the reaper period
|
|
1433
|
+
// plus this window plus the drain capture budget must fit before it.
|
|
1434
|
+
// getSettings derives the unset default between those two for short-lived
|
|
1435
|
+
// provider lifetimes. Knob: OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS.
|
|
1436
|
+
sandboxIdleCommandContainmentMs: z3.coerce.number().int().nonnegative().optional().transform((value) => value === 0 ? void 0 : value),
|
|
949
1437
|
// MID-SESSION /workspace snapshot cadence (sandbox-file-persistence). The
|
|
950
1438
|
// reaper's drain-persist only protects boxes the reaper itself kills; a box
|
|
951
1439
|
// that dies any other way (Modal's hard creation-time timeout on a session
|
|
@@ -955,20 +1443,20 @@ var SettingsSchema = z.object({
|
|
|
955
1443
|
// one (same epoch-fenced fold-onto-lease seam as the drain), bounding the
|
|
956
1444
|
// worst-case loss of ANY unclean box death to this window. 0 disables.
|
|
957
1445
|
// Knob: OPENGENI_SANDBOX_SNAPSHOT_INTERVAL_MS. Default 15min.
|
|
958
|
-
sandboxSnapshotIntervalMs:
|
|
1446
|
+
sandboxSnapshotIntervalMs: z3.coerce.number().int().min(0).default(9e5),
|
|
959
1447
|
// Maximum time a best-effort /workspace snapshot capture may hold turn/reaper
|
|
960
1448
|
// cleanup. A hung provider snapshot must never pin a lease holder, block
|
|
961
1449
|
// graceful shutdown, or become permission to GC an older archive. Timeout is
|
|
962
1450
|
// treated exactly like a failed best-effort snapshot. Knob:
|
|
963
1451
|
// OPENGENI_SANDBOX_SNAPSHOT_TIMEOUT_MS. Default 60s.
|
|
964
|
-
sandboxSnapshotTimeoutMs:
|
|
1452
|
+
sandboxSnapshotTimeoutMs: z3.coerce.number().int().positive().max(SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS).default(6e4),
|
|
965
1453
|
// A zero-holder drain may need substantially longer than a best-effort
|
|
966
1454
|
// mid-turn/turn-end snapshot for a very large workspace. Keep that provider
|
|
967
1455
|
// budget independent so increasing drain recovery headroom cannot pin an
|
|
968
1456
|
// ordinary turn finalizer for the same duration. Unset preserves the legacy
|
|
969
1457
|
// single-budget behavior. Knob:
|
|
970
1458
|
// OPENGENI_SANDBOX_DRAIN_SNAPSHOT_TIMEOUT_MS.
|
|
971
|
-
sandboxDrainSnapshotTimeoutMs:
|
|
1459
|
+
sandboxDrainSnapshotTimeoutMs: z3.coerce.number().int().positive().max(SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS).optional(),
|
|
972
1460
|
// Begin a controlled snapshot/quiesce/drain/rematerialize transition this far
|
|
973
1461
|
// ahead of a finite provider deadline. Modal's 24h creation clock cannot be
|
|
974
1462
|
// extended; the logical sandbox outlives it by moving to one successor box.
|
|
@@ -977,22 +1465,22 @@ var SettingsSchema = z.object({
|
|
|
977
1465
|
// an extra coupled environment override. An explicit value may be larger when
|
|
978
1466
|
// an operator deliberately wants more rotation headroom; the boot invariant
|
|
979
1467
|
// still requires it to remain below the provider lifetime.
|
|
980
|
-
sandboxRotationLeadMs:
|
|
1468
|
+
sandboxRotationLeadMs: z3.coerce.number().int().positive().default(36e5),
|
|
981
1469
|
// Bound provider-deadline rotation admission independently of execution.
|
|
982
1470
|
// Every admitted box receives its own durable drain child; the control worker
|
|
983
1471
|
// limits provider I/O to 32 concurrent activities. Matching that bound avoids
|
|
984
1472
|
// both the old one-box-per-tick deadline backlog and an unbounded provider/API
|
|
985
1473
|
// burst. Operators may tune this for a differently-sized worker pool.
|
|
986
|
-
sandboxRotationBatchSize:
|
|
1474
|
+
sandboxRotationBatchSize: z3.coerce.number().int().positive().max(500).default(32),
|
|
987
1475
|
// expires_at refresh window for a held lease (>> the turn 10s heartbeat so a
|
|
988
1476
|
// single missed heartbeat never TTL-reaps a live turn). The warming TTL is the
|
|
989
1477
|
// window a cold->warming spawner has to commit warm before a reaper resets it.
|
|
990
|
-
sandboxLeaseTtlMs:
|
|
991
|
-
sandboxLeaseWarmingTtlMs:
|
|
1478
|
+
sandboxLeaseTtlMs: z3.coerce.number().int().positive().default(9e4),
|
|
1479
|
+
sandboxLeaseWarmingTtlMs: z3.coerce.number().int().positive().default(12e4),
|
|
992
1480
|
// Overall user-facing budget for warming a sandbox lease. Unlike the lease TTL
|
|
993
1481
|
// (a liveness/reaper cadence), this bounds how long one turn waits for capacity
|
|
994
1482
|
// or provider creation before surfacing a clear turn.failed error.
|
|
995
|
-
sandboxWarmingTimeoutMs:
|
|
1483
|
+
sandboxWarmingTimeoutMs: z3.coerce.number().int().positive().default(6e5),
|
|
996
1484
|
// Request-scoped workspace control-prefix budget: how long one HTTP-originated
|
|
997
1485
|
// session/workspace mutation (Send, Steer, Pause/Resume/Cancel, queue
|
|
998
1486
|
// move/edit/delete, composer draft, settings narrowing, quiescent tree
|
|
@@ -1001,114 +1489,132 @@ var SettingsSchema = z.object({
|
|
|
1001
1489
|
// settlement and claims never use it. The API installs the validated value
|
|
1002
1490
|
// into @opengeni/db once at app construction; nothing reads the env per
|
|
1003
1491
|
// request. Env: OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS. Default 20 s.
|
|
1004
|
-
workspaceControlLockTimeoutMs:
|
|
1492
|
+
workspaceControlLockTimeoutMs: z3.coerce.number({
|
|
1005
1493
|
message: "OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS must be a positive integer (ms)"
|
|
1006
1494
|
}).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),
|
|
1007
1495
|
// Rig setup-script budget (M3): the wall-clock timeout the rig-setup lifecycle
|
|
1008
1496
|
// hook runs its script under, distinct from the 120s per-command lifecycle
|
|
1009
1497
|
// default (a rig may compile/install heavy tooling on first cold create).
|
|
1010
1498
|
// Env: OPENGENI_RIG_SETUP_TIMEOUT_MS. Default 10min.
|
|
1011
|
-
rigSetupTimeoutMs:
|
|
1499
|
+
rigSetupTimeoutMs: z3.coerce.number().int().positive().default(6e5),
|
|
1012
1500
|
// --- sandbox warm-time billing (P2.1) ---
|
|
1013
1501
|
// Per-backend warm rate (usd_micros/sec), like modelPricingJson: an empty {}
|
|
1014
1502
|
// means warm-cost is not debited (warm-seconds are still metered for audit).
|
|
1015
1503
|
// Shape: { "modal": 5, "runloop": 4, ... }. Backends absent here meter
|
|
1016
1504
|
// warm-seconds but accrue NO warm_cost / debit (rate 0).
|
|
1017
|
-
sandboxWarmRateMicrosPerSecondJson:
|
|
1505
|
+
sandboxWarmRateMicrosPerSecondJson: z3.string().default("{}"),
|
|
1506
|
+
sandboxWarmBillingMode: z3.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
|
|
1018
1507
|
// Per-workspace warm cap (cumulative warm-seconds since the start of the UTC
|
|
1019
1508
|
// month, summed over sandbox.warm_seconds). 0 = unbounded. A workspace over the
|
|
1020
1509
|
// cap force-drains its VIEWER-ONLY boxes (guarded AND turn_holders=0 — a paying
|
|
1021
1510
|
// turn is never killed); the reaper then stop()s at refcount 0.
|
|
1022
|
-
sandboxMaxWarmSecondsPerWorkspace:
|
|
1023
|
-
sandboxPreparationProfiles:
|
|
1024
|
-
sandboxEnvAllowlist:
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1511
|
+
sandboxMaxWarmSecondsPerWorkspace: z3.coerce.number().int().nonnegative().default(0),
|
|
1512
|
+
sandboxPreparationProfiles: z3.string().default("none"),
|
|
1513
|
+
sandboxEnvAllowlist: z3.string().default(""),
|
|
1514
|
+
// Comma-separated image references a workspace may select as its default
|
|
1515
|
+
// sandbox image. Empty keeps every workspace on the deployment image.
|
|
1516
|
+
sandboxImageAllowlist: z3.string().default(""),
|
|
1517
|
+
objectStorageEndpoint: z3.string().url().optional(),
|
|
1518
|
+
objectStorageInternalEndpoint: z3.string().url().optional(),
|
|
1519
|
+
objectStorageSandboxEndpoint: z3.string().url().optional(),
|
|
1520
|
+
objectStorageBackend: z3.enum(["s3-compatible", "aws-s3", "azure-blob", "gcs"]).default("s3-compatible"),
|
|
1521
|
+
objectStorageBucket: z3.string().min(1).default("opengeni-files"),
|
|
1522
|
+
objectStorageRegion: z3.string().min(1).default("us-east-1"),
|
|
1523
|
+
objectStorageS3Provider: z3.string().min(1).default("Minio"),
|
|
1524
|
+
objectStorageAccessKeyId: z3.string().optional(),
|
|
1525
|
+
objectStorageSecretAccessKey: z3.string().optional(),
|
|
1034
1526
|
objectStorageForcePathStyle: EnvBoolean.default(true),
|
|
1035
|
-
objectStorageAzureConnectionString:
|
|
1036
|
-
objectStorageAzureAccountName:
|
|
1037
|
-
objectStorageAzureAccountKey:
|
|
1038
|
-
objectStorageAzureEndpoint:
|
|
1039
|
-
objectStorageGcsProjectId:
|
|
1040
|
-
objectStorageGcsCredentialsJson:
|
|
1041
|
-
objectStorageGcsKeyFilename:
|
|
1042
|
-
objectStorageGcsApiEndpoint:
|
|
1043
|
-
documentParser:
|
|
1044
|
-
documentChunkSize:
|
|
1045
|
-
documentChunkOverlap:
|
|
1046
|
-
documentEmbeddingProvider:
|
|
1047
|
-
documentEmbeddingModel:
|
|
1048
|
-
documentEmbeddingDimensions:
|
|
1049
|
-
documentEmbeddingApiKey:
|
|
1050
|
-
documentEmbeddingBaseUrl:
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1527
|
+
objectStorageAzureConnectionString: z3.string().optional(),
|
|
1528
|
+
objectStorageAzureAccountName: z3.string().optional(),
|
|
1529
|
+
objectStorageAzureAccountKey: z3.string().optional(),
|
|
1530
|
+
objectStorageAzureEndpoint: z3.string().url().optional(),
|
|
1531
|
+
objectStorageGcsProjectId: z3.string().optional(),
|
|
1532
|
+
objectStorageGcsCredentialsJson: z3.string().optional(),
|
|
1533
|
+
objectStorageGcsKeyFilename: z3.string().optional(),
|
|
1534
|
+
objectStorageGcsApiEndpoint: z3.string().url().optional(),
|
|
1535
|
+
documentParser: z3.string().min(1).default("liteparse"),
|
|
1536
|
+
documentChunkSize: z3.coerce.number().int().positive().default(1200),
|
|
1537
|
+
documentChunkOverlap: z3.coerce.number().int().nonnegative().default(160),
|
|
1538
|
+
documentEmbeddingProvider: z3.enum(["openai", "deterministic"]).default("openai"),
|
|
1539
|
+
documentEmbeddingModel: z3.string().min(1).default("text-embedding-3-large"),
|
|
1540
|
+
documentEmbeddingDimensions: z3.coerce.number().int().positive().default(3072),
|
|
1541
|
+
documentEmbeddingApiKey: z3.string().optional(),
|
|
1542
|
+
documentEmbeddingBaseUrl: z3.string().url().optional(),
|
|
1543
|
+
documentEmbeddingBillingMode: z3.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
|
|
1544
|
+
// Explicit commercial cutover. Existing queued revisions remain unpriced;
|
|
1545
|
+
// only jobs created at or after this instant may enter the paid rail.
|
|
1546
|
+
documentEmbeddingCreditsActivatedAt: z3.iso.datetime().optional(),
|
|
1547
|
+
// Customer tariff for the exact UTF-8 bytes sent to the embedder. Zero leaves
|
|
1548
|
+
// the paid mode unavailable; no commercial rate is selected by this PR.
|
|
1549
|
+
documentEmbeddingRateMicrosPerMillionBytes: z3.coerce.number().int().nonnegative().default(0),
|
|
1550
|
+
documentCurationProvider: z3.enum(["openai", "heuristic", "none"]).default("openai"),
|
|
1551
|
+
documentCurationModel: z3.string().min(1).default("gpt-4o-mini"),
|
|
1552
|
+
documentCurationApiKey: z3.string().optional(),
|
|
1553
|
+
documentCurationBaseUrl: z3.string().url().optional(),
|
|
1554
|
+
gitAuthorName: z3.string().optional(),
|
|
1555
|
+
gitAuthorEmail: z3.string().optional(),
|
|
1556
|
+
gitCommitterName: z3.string().optional(),
|
|
1557
|
+
gitCommitterEmail: z3.string().optional(),
|
|
1558
|
+
githubAppManifestBaseUrl: z3.string().optional(),
|
|
1559
|
+
githubAppManifestStateSecret: z3.string().optional(),
|
|
1560
|
+
githubAppId: z3.string().optional(),
|
|
1561
|
+
githubClientId: z3.string().optional(),
|
|
1562
|
+
githubClientSecret: z3.string().optional(),
|
|
1064
1563
|
/** Default-off rollout for the in-process GitHub repository API tool surface. */
|
|
1065
1564
|
githubRestMcpEnabled: EnvBoolean.default(false),
|
|
1066
1565
|
githubPersonalOauthEnabled: EnvBoolean.default(false),
|
|
1067
|
-
githubPersonalOauthClientId:
|
|
1068
|
-
githubPersonalOauthClientSecret:
|
|
1069
|
-
githubAppSlug:
|
|
1070
|
-
githubWebhookSecret:
|
|
1071
|
-
githubAppPrivateKey:
|
|
1072
|
-
prReviewGithubAppId:
|
|
1073
|
-
prReviewGithubClientId:
|
|
1074
|
-
prReviewGithubClientSecret:
|
|
1075
|
-
prReviewGithubAppSlug:
|
|
1076
|
-
prReviewGithubWebhookSecret:
|
|
1077
|
-
prReviewGithubAppPrivateKey:
|
|
1078
|
-
betterAuthSecret:
|
|
1079
|
-
betterAuthAllowedHosts:
|
|
1080
|
-
betterAuthCookieDomain:
|
|
1081
|
-
betterAuthTrustedOrigins:
|
|
1082
|
-
managedAuthGoogleClientId:
|
|
1083
|
-
managedAuthGoogleClientSecret:
|
|
1084
|
-
managedAuthGithubClientId:
|
|
1085
|
-
managedAuthGithubClientSecret:
|
|
1566
|
+
githubPersonalOauthClientId: z3.string().optional(),
|
|
1567
|
+
githubPersonalOauthClientSecret: z3.string().optional(),
|
|
1568
|
+
githubAppSlug: z3.string().optional(),
|
|
1569
|
+
githubWebhookSecret: z3.string().optional(),
|
|
1570
|
+
githubAppPrivateKey: z3.string().optional(),
|
|
1571
|
+
prReviewGithubAppId: z3.string().optional(),
|
|
1572
|
+
prReviewGithubClientId: z3.string().optional(),
|
|
1573
|
+
prReviewGithubClientSecret: z3.string().optional(),
|
|
1574
|
+
prReviewGithubAppSlug: z3.string().optional(),
|
|
1575
|
+
prReviewGithubWebhookSecret: z3.string().optional(),
|
|
1576
|
+
prReviewGithubAppPrivateKey: z3.string().optional(),
|
|
1577
|
+
betterAuthSecret: z3.string().optional(),
|
|
1578
|
+
betterAuthAllowedHosts: z3.string().default(""),
|
|
1579
|
+
betterAuthCookieDomain: z3.string().optional(),
|
|
1580
|
+
betterAuthTrustedOrigins: z3.string().default(""),
|
|
1581
|
+
managedAuthGoogleClientId: z3.string().optional(),
|
|
1582
|
+
managedAuthGoogleClientSecret: z3.string().optional(),
|
|
1583
|
+
managedAuthGithubClientId: z3.string().optional(),
|
|
1584
|
+
managedAuthGithubClientSecret: z3.string().optional(),
|
|
1086
1585
|
// Rolling browser login-slot compatibility. Repository/deployment default is
|
|
1087
1586
|
// deliberately legacy; changing to broker is an operator-authorized rollout.
|
|
1088
|
-
|
|
1587
|
+
allowedUserEmails: z3.array(z3.email().transform((email) => email.toLowerCase())).min(1).optional(),
|
|
1588
|
+
managedAuthSessionSetMode: z3.enum(["legacy", "dual", "broker"]).default("legacy"),
|
|
1589
|
+
// Deployment ceiling for new managed accounts. When false, managed auth
|
|
1590
|
+
// refuses every new Better Auth account (email/password sign-up and implicit
|
|
1591
|
+
// Google/GitHub sign-up) while existing sign-in, sessions, password reset,
|
|
1592
|
+
// email verification, and invitation-bound account setup keep working. Read
|
|
1593
|
+
// at startup; the 0585 runtime switch pauses sign-ups without a restart.
|
|
1594
|
+
managedAuthNewSignupsEnabled: EnvBoolean.default(true),
|
|
1089
1595
|
// Query transport is an explicit second-stage rollout. A pre-compatibility
|
|
1090
1596
|
// web image understands only fragment bearers, so API replicas must keep
|
|
1091
1597
|
// generating fragment links until the compatible web fleet has converged.
|
|
1092
|
-
organizationUserSetupEmailTokenTransport:
|
|
1598
|
+
organizationUserSetupEmailTokenTransport: z3.enum(["fragment", "query"]).default("fragment"),
|
|
1093
1599
|
// Query-bearing setup links may appear in controller/edge error logs even
|
|
1094
1600
|
// when access logs and request tracing are disabled. This explicit operator
|
|
1095
1601
|
// confirmation keeps query transport fail closed until that separate sink is
|
|
1096
1602
|
// proven sanitized.
|
|
1097
1603
|
organizationUserSetupQueryEdgeSanitizationConfirmed: EnvBoolean.default(false),
|
|
1098
|
-
resendApiKey:
|
|
1099
|
-
emailFrom:
|
|
1100
|
-
stripeSecretKey:
|
|
1101
|
-
stripePublishableKey:
|
|
1102
|
-
stripeWebhookSecret:
|
|
1103
|
-
stripeCreditsProductId:
|
|
1104
|
-
mcpServers:
|
|
1105
|
-
|
|
1106
|
-
id:
|
|
1107
|
-
name:
|
|
1108
|
-
url:
|
|
1109
|
-
allowedTools:
|
|
1110
|
-
timeoutMs:
|
|
1111
|
-
cacheToolsList:
|
|
1604
|
+
resendApiKey: z3.string().optional(),
|
|
1605
|
+
emailFrom: z3.string().default("OpenGeni <auth@mail.opengeni.ai>"),
|
|
1606
|
+
stripeSecretKey: z3.string().optional(),
|
|
1607
|
+
stripePublishableKey: z3.string().optional(),
|
|
1608
|
+
stripeWebhookSecret: z3.string().optional(),
|
|
1609
|
+
stripeCreditsProductId: z3.string().optional(),
|
|
1610
|
+
mcpServers: z3.array(
|
|
1611
|
+
z3.object({
|
|
1612
|
+
id: z3.string().min(1).regex(registryId),
|
|
1613
|
+
name: z3.string().min(1).optional(),
|
|
1614
|
+
url: z3.string().url(),
|
|
1615
|
+
allowedTools: z3.array(z3.string().min(1)).optional(),
|
|
1616
|
+
timeoutMs: z3.number().int().positive().optional(),
|
|
1617
|
+
cacheToolsList: z3.boolean().default(false),
|
|
1112
1618
|
/** Runtime approval policy, overlaid from an attempt-frozen session snapshot. */
|
|
1113
1619
|
requireApproval: SessionMcpApprovalPolicy.optional(),
|
|
1114
1620
|
/**
|
|
@@ -1117,12 +1623,109 @@ var SettingsSchema = z.object({
|
|
|
1117
1623
|
* encrypted capability-installation credentials; do not put secrets in
|
|
1118
1624
|
* OPENGENI_MCP_SERVERS.
|
|
1119
1625
|
*/
|
|
1120
|
-
headers:
|
|
1626
|
+
headers: z3.record(z3.string(), z3.string()).optional(),
|
|
1121
1627
|
connectionRef: McpServerConnectionRefSchema.optional(),
|
|
1122
1628
|
operationRecovery: McpOperationRecoverySchema.optional()
|
|
1123
1629
|
})
|
|
1124
1630
|
).default([])
|
|
1125
1631
|
});
|
|
1632
|
+
var ArtifactServiceSettingsSchema = SettingsSchema.pick({
|
|
1633
|
+
serviceName: true,
|
|
1634
|
+
environment: true,
|
|
1635
|
+
deploymentRevision: true,
|
|
1636
|
+
dbSchema: true,
|
|
1637
|
+
rlsStrategy: true,
|
|
1638
|
+
observabilityStructuredLogs: true,
|
|
1639
|
+
observabilityMetricsEnabled: true,
|
|
1640
|
+
observabilityOtlpEndpoint: true,
|
|
1641
|
+
observabilityOtlpHeaders: true
|
|
1642
|
+
});
|
|
1643
|
+
var ArtifactOutboxSettingsSchema = ArtifactServiceSettingsSchema.extend({
|
|
1644
|
+
natsUrl: SettingsSchema.shape.natsUrl,
|
|
1645
|
+
selfhostedNatsControlUser: SettingsSchema.shape.selfhostedNatsControlUser,
|
|
1646
|
+
selfhostedNatsControlPassword: SettingsSchema.shape.selfhostedNatsControlPassword
|
|
1647
|
+
});
|
|
1648
|
+
var ObjectStorageSettingsSchema = SettingsSchema.pick({
|
|
1649
|
+
objectStorageBackend: true,
|
|
1650
|
+
objectStorageEndpoint: true,
|
|
1651
|
+
objectStorageInternalEndpoint: true,
|
|
1652
|
+
objectStorageSandboxEndpoint: true,
|
|
1653
|
+
objectStorageBucket: true,
|
|
1654
|
+
objectStorageRegion: true,
|
|
1655
|
+
objectStorageAccessKeyId: true,
|
|
1656
|
+
objectStorageSecretAccessKey: true,
|
|
1657
|
+
objectStorageForcePathStyle: true,
|
|
1658
|
+
objectStorageAzureConnectionString: true,
|
|
1659
|
+
objectStorageAzureAccountName: true,
|
|
1660
|
+
objectStorageAzureAccountKey: true,
|
|
1661
|
+
objectStorageAzureEndpoint: true,
|
|
1662
|
+
objectStorageGcsProjectId: true,
|
|
1663
|
+
objectStorageGcsCredentialsJson: true,
|
|
1664
|
+
objectStorageGcsKeyFilename: true,
|
|
1665
|
+
objectStorageGcsApiEndpoint: true
|
|
1666
|
+
});
|
|
1667
|
+
var ArtifactMaterializerSettingsSchema = ArtifactServiceSettingsSchema.extend(
|
|
1668
|
+
ObjectStorageSettingsSchema.shape
|
|
1669
|
+
);
|
|
1670
|
+
function artifactServiceEnvironment(source) {
|
|
1671
|
+
const optional = (name) => optionalEnvironmentValue(name, source);
|
|
1672
|
+
return {
|
|
1673
|
+
serviceName: optional("OPENGENI_SERVICE_NAME"),
|
|
1674
|
+
environment: optional("OPENGENI_ENVIRONMENT"),
|
|
1675
|
+
deploymentRevision: optional("OPENGENI_DEPLOYMENT_REVISION") ?? optional("SOURCE_VERSION") ?? optional("GITHUB_SHA"),
|
|
1676
|
+
dbSchema: optional("OPENGENI_DB_SCHEMA"),
|
|
1677
|
+
rlsStrategy: optional("OPENGENI_RLS_STRATEGY"),
|
|
1678
|
+
observabilityStructuredLogs: optional("OPENGENI_OBSERVABILITY_STRUCTURED_LOGS"),
|
|
1679
|
+
observabilityMetricsEnabled: optional("OPENGENI_OBSERVABILITY_METRICS_ENABLED"),
|
|
1680
|
+
observabilityOtlpEndpoint: optional("OPENGENI_OTEL_EXPORTER_OTLP_ENDPOINT") ?? optional("OTEL_EXPORTER_OTLP_ENDPOINT"),
|
|
1681
|
+
observabilityOtlpHeaders: optional("OPENGENI_OTEL_EXPORTER_OTLP_HEADERS") ?? optional("OTEL_EXPORTER_OTLP_HEADERS")
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
function getArtifactOutboxSettings(source = process.env) {
|
|
1685
|
+
const settings = ArtifactOutboxSettingsSchema.parse({
|
|
1686
|
+
...artifactServiceEnvironment(source),
|
|
1687
|
+
natsUrl: optionalEnvironmentValue("OPENGENI_NATS_URL", source),
|
|
1688
|
+
selfhostedNatsControlUser: optionalEnvironmentValue(
|
|
1689
|
+
"OPENGENI_SELFHOSTED_NATS_CONTROL_USER",
|
|
1690
|
+
source
|
|
1691
|
+
),
|
|
1692
|
+
selfhostedNatsControlPassword: optionalEnvironmentValue(
|
|
1693
|
+
"OPENGENI_SELFHOSTED_NATS_CONTROL_PASSWORD",
|
|
1694
|
+
source
|
|
1695
|
+
)
|
|
1696
|
+
});
|
|
1697
|
+
dbSearchPath(settings);
|
|
1698
|
+
if (Boolean(settings.selfhostedNatsControlUser) !== Boolean(settings.selfhostedNatsControlPassword)) {
|
|
1699
|
+
throw new Error("Artifact outbox NATS control user and password must be configured together");
|
|
1700
|
+
}
|
|
1701
|
+
return settings;
|
|
1702
|
+
}
|
|
1703
|
+
function getArtifactMaterializerSettings(source = process.env) {
|
|
1704
|
+
const optional = (name) => optionalEnvironmentValue(name, source);
|
|
1705
|
+
const settings = ArtifactMaterializerSettingsSchema.parse({
|
|
1706
|
+
...artifactServiceEnvironment(source),
|
|
1707
|
+
objectStorageEndpoint: optional("OPENGENI_OBJECT_STORAGE_ENDPOINT"),
|
|
1708
|
+
objectStorageInternalEndpoint: optional("OPENGENI_OBJECT_STORAGE_INTERNAL_ENDPOINT"),
|
|
1709
|
+
objectStorageSandboxEndpoint: optional("OPENGENI_OBJECT_STORAGE_SANDBOX_ENDPOINT"),
|
|
1710
|
+
objectStorageBackend: optional("OPENGENI_OBJECT_STORAGE_BACKEND"),
|
|
1711
|
+
objectStorageBucket: optional("OPENGENI_OBJECT_STORAGE_BUCKET"),
|
|
1712
|
+
objectStorageRegion: optional("OPENGENI_OBJECT_STORAGE_REGION"),
|
|
1713
|
+
objectStorageAccessKeyId: optional("OPENGENI_OBJECT_STORAGE_ACCESS_KEY_ID"),
|
|
1714
|
+
objectStorageSecretAccessKey: optional("OPENGENI_OBJECT_STORAGE_SECRET_ACCESS_KEY"),
|
|
1715
|
+
objectStorageForcePathStyle: optional("OPENGENI_OBJECT_STORAGE_FORCE_PATH_STYLE"),
|
|
1716
|
+
objectStorageAzureConnectionString: optional("OPENGENI_OBJECT_STORAGE_AZURE_CONNECTION_STRING"),
|
|
1717
|
+
objectStorageAzureAccountName: optional("OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_NAME"),
|
|
1718
|
+
objectStorageAzureAccountKey: optional("OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_KEY"),
|
|
1719
|
+
objectStorageAzureEndpoint: optional("OPENGENI_OBJECT_STORAGE_AZURE_ENDPOINT"),
|
|
1720
|
+
objectStorageGcsProjectId: optional("OPENGENI_OBJECT_STORAGE_GCS_PROJECT_ID"),
|
|
1721
|
+
objectStorageGcsCredentialsJson: optional("OPENGENI_OBJECT_STORAGE_GCS_CREDENTIALS_JSON"),
|
|
1722
|
+
objectStorageGcsKeyFilename: optional("OPENGENI_OBJECT_STORAGE_GCS_KEY_FILENAME"),
|
|
1723
|
+
objectStorageGcsApiEndpoint: optional("OPENGENI_OBJECT_STORAGE_GCS_API_ENDPOINT")
|
|
1724
|
+
});
|
|
1725
|
+
dbSearchPath(settings);
|
|
1726
|
+
validateObjectStorageSettings(settings);
|
|
1727
|
+
return settings;
|
|
1728
|
+
}
|
|
1126
1729
|
function configuredGoogleDriveSyncLimits(settings) {
|
|
1127
1730
|
return KnowledgeSourceSyncLimits.parse({
|
|
1128
1731
|
maxItems: settings.googleDriveSyncMaxItems,
|
|
@@ -1163,6 +1766,24 @@ function personalGitHubOAuthCallbackUrl(publicBaseUrl) {
|
|
|
1163
1766
|
const origin = canonicalPublicOrigin(publicBaseUrl);
|
|
1164
1767
|
return origin ? `${origin}/v1/integrations/github-personal/oauth/callback` : null;
|
|
1165
1768
|
}
|
|
1769
|
+
function usableDeploymentSecret(value) {
|
|
1770
|
+
return isUsableVoiceInputSecret(value) ? value : void 0;
|
|
1771
|
+
}
|
|
1772
|
+
function usableJevApiKey(settings) {
|
|
1773
|
+
return usableDeploymentSecret(settings.jevApiKey);
|
|
1774
|
+
}
|
|
1775
|
+
function agentConfigDeploymentPolicy(settings) {
|
|
1776
|
+
return agentConfigDeploymentLimitsFromAllowlist(
|
|
1777
|
+
resolveFirstPartyMcpToolPolicy(settings).allowed,
|
|
1778
|
+
settings.webSearchEnabled ? {} : { webSearch: "web search is turned off on this server" }
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1781
|
+
function codeSearchDeploymentPolicy(settings) {
|
|
1782
|
+
const available = settings.codeSearchMode !== "off" && usableJevApiKey(settings) !== void 0;
|
|
1783
|
+
if (!available) return { available: false, workspaceDefault: "off" };
|
|
1784
|
+
const workspaceDefault = settings.codeSearchMode === "default_on" ? "on" : settings.codeSearchMode === "experiment" ? "split" : "off";
|
|
1785
|
+
return { available, workspaceDefault };
|
|
1786
|
+
}
|
|
1166
1787
|
function isUsableVoiceInputSecret(value) {
|
|
1167
1788
|
if (value == null) return false;
|
|
1168
1789
|
const trimmed = value.trim();
|
|
@@ -1247,18 +1868,18 @@ function voiceInputDeploymentConfigured(settings) {
|
|
|
1247
1868
|
(provider) => provider.kind !== "codex-subscription" && provider.kind !== "supergrok-subscription"
|
|
1248
1869
|
);
|
|
1249
1870
|
}
|
|
1250
|
-
var ModelPricingSchema =
|
|
1251
|
-
inputMicrosPerMillionTokens:
|
|
1252
|
-
cachedInputMicrosPerMillionTokens:
|
|
1253
|
-
cacheWriteMicrosPerMillionTokens:
|
|
1254
|
-
outputMicrosPerMillionTokens:
|
|
1255
|
-
marginBps:
|
|
1871
|
+
var ModelPricingSchema = z3.object({
|
|
1872
|
+
inputMicrosPerMillionTokens: z3.number().int().nonnegative(),
|
|
1873
|
+
cachedInputMicrosPerMillionTokens: z3.number().int().nonnegative().optional(),
|
|
1874
|
+
cacheWriteMicrosPerMillionTokens: z3.number().int().nonnegative().optional(),
|
|
1875
|
+
outputMicrosPerMillionTokens: z3.number().int().nonnegative(),
|
|
1876
|
+
marginBps: z3.number().int().min(0).max(1e5).optional()
|
|
1256
1877
|
});
|
|
1257
|
-
var ModelPricingScheduleSchema =
|
|
1878
|
+
var ModelPricingScheduleSchema = z3.object({
|
|
1258
1879
|
default: ModelPricingSchema,
|
|
1259
|
-
inputTokenTiers:
|
|
1260
|
-
|
|
1261
|
-
minimumInputTokens:
|
|
1880
|
+
inputTokenTiers: z3.array(
|
|
1881
|
+
z3.object({
|
|
1882
|
+
minimumInputTokens: z3.number().int().nonnegative(),
|
|
1262
1883
|
pricing: ModelPricingSchema
|
|
1263
1884
|
})
|
|
1264
1885
|
).optional()
|
|
@@ -1275,10 +1896,10 @@ var ModelPricingScheduleSchema = z.object({
|
|
|
1275
1896
|
previous = tier.minimumInputTokens;
|
|
1276
1897
|
}
|
|
1277
1898
|
});
|
|
1278
|
-
var CapabilitySupportV1 =
|
|
1279
|
-
var CapabilityStateV1Schema =
|
|
1899
|
+
var CapabilitySupportV1 = z3.enum(["supported", "unsupported", "unknown"]);
|
|
1900
|
+
var CapabilityStateV1Schema = z3.object({
|
|
1280
1901
|
upstream: CapabilitySupportV1,
|
|
1281
|
-
runnable:
|
|
1902
|
+
runnable: z3.boolean()
|
|
1282
1903
|
}).superRefine((state, ctx) => {
|
|
1283
1904
|
if (state.upstream === "unsupported" && state.runnable) {
|
|
1284
1905
|
ctx.addIssue({
|
|
@@ -1288,17 +1909,17 @@ var CapabilityStateV1Schema = z.object({
|
|
|
1288
1909
|
});
|
|
1289
1910
|
}
|
|
1290
1911
|
});
|
|
1291
|
-
var ModelModalityV1 =
|
|
1292
|
-
var ModelLatencyModeV1 =
|
|
1293
|
-
var ModelCapabilitiesV1Schema =
|
|
1912
|
+
var ModelModalityV1 = z3.enum(["text", "image", "audio"]);
|
|
1913
|
+
var ModelLatencyModeV1 = z3.enum(["standard", "priority", "fast"]);
|
|
1914
|
+
var ModelCapabilitiesV1Schema = z3.object({
|
|
1294
1915
|
reasoning: CapabilityStateV1Schema.extend({
|
|
1295
|
-
efforts:
|
|
1916
|
+
efforts: z3.array(ReasoningEffort),
|
|
1296
1917
|
defaultEffort: ReasoningEffort.nullable(),
|
|
1297
|
-
required:
|
|
1918
|
+
required: z3.boolean()
|
|
1298
1919
|
}),
|
|
1299
1920
|
functionCalling: CapabilityStateV1Schema,
|
|
1300
1921
|
structuredOutput: CapabilityStateV1Schema,
|
|
1301
|
-
hostedTools:
|
|
1922
|
+
hostedTools: z3.object({
|
|
1302
1923
|
webSearch: CapabilityStateV1Schema,
|
|
1303
1924
|
xSearch: CapabilityStateV1Schema,
|
|
1304
1925
|
codeExecution: CapabilityStateV1Schema,
|
|
@@ -1307,24 +1928,24 @@ var ModelCapabilitiesV1Schema = z.object({
|
|
|
1307
1928
|
runnable: false
|
|
1308
1929
|
})
|
|
1309
1930
|
}),
|
|
1310
|
-
inputModalities:
|
|
1931
|
+
inputModalities: z3.array(ModelModalityV1).min(1),
|
|
1311
1932
|
/** Exact MIME types accepted as typed `input_file`; `text/*` is allowed. */
|
|
1312
|
-
inputFileMediaTypes:
|
|
1313
|
-
outputModalities:
|
|
1314
|
-
transports:
|
|
1933
|
+
inputFileMediaTypes: z3.array(z3.string()).default([]),
|
|
1934
|
+
outputModalities: z3.array(ModelModalityV1).min(1),
|
|
1935
|
+
transports: z3.object({
|
|
1315
1936
|
sse: CapabilityStateV1Schema,
|
|
1316
1937
|
responsesWebSocket: CapabilityStateV1Schema,
|
|
1317
1938
|
realtimeAudio: CapabilityStateV1Schema
|
|
1318
1939
|
}),
|
|
1319
1940
|
promptCaching: CapabilityStateV1Schema.extend({
|
|
1320
|
-
mode:
|
|
1941
|
+
mode: z3.enum(["implicit", "automatic", "none"])
|
|
1321
1942
|
}).optional(),
|
|
1322
|
-
latencyModes:
|
|
1323
|
-
|
|
1943
|
+
latencyModes: z3.array(
|
|
1944
|
+
z3.object({
|
|
1324
1945
|
id: ModelLatencyModeV1,
|
|
1325
1946
|
upstream: CapabilitySupportV1,
|
|
1326
|
-
runnable:
|
|
1327
|
-
billingMultiplierBps:
|
|
1947
|
+
runnable: z3.boolean(),
|
|
1948
|
+
billingMultiplierBps: z3.number().int().positive().optional()
|
|
1328
1949
|
})
|
|
1329
1950
|
).min(1)
|
|
1330
1951
|
}).superRefine((capabilities, ctx) => {
|
|
@@ -1378,9 +1999,9 @@ var ModelCapabilitiesV1Schema = z.object({
|
|
|
1378
1999
|
}
|
|
1379
2000
|
}
|
|
1380
2001
|
});
|
|
1381
|
-
var ModelProviderApi =
|
|
1382
|
-
var ModelProviderWireProfile =
|
|
1383
|
-
var RegistryProviderKind =
|
|
2002
|
+
var ModelProviderApi = z3.enum(["responses", "chat", "anthropic-messages"]);
|
|
2003
|
+
var ModelProviderWireProfile = z3.enum(["openai", "azure-openai"]);
|
|
2004
|
+
var RegistryProviderKind = z3.enum([
|
|
1384
2005
|
"api-key",
|
|
1385
2006
|
"anonymous",
|
|
1386
2007
|
"codex-subscription",
|
|
@@ -1388,36 +2009,47 @@ var RegistryProviderKind = z.enum([
|
|
|
1388
2009
|
"vercel-gateway-managed",
|
|
1389
2010
|
"vercel-gateway-workspace",
|
|
1390
2011
|
"vercel-gateway-organization",
|
|
2012
|
+
"direct-openai-workspace",
|
|
2013
|
+
"direct-azure-workspace",
|
|
1391
2014
|
"openrouter-workspace",
|
|
1392
|
-
"openrouter-organization"
|
|
2015
|
+
"openrouter-organization",
|
|
2016
|
+
"anthropic-organization",
|
|
2017
|
+
"claude-subscription-organization",
|
|
2018
|
+
"anthropic-workspace",
|
|
2019
|
+
"claude-subscription-workspace"
|
|
1393
2020
|
]);
|
|
1394
|
-
var
|
|
1395
|
-
id:
|
|
2021
|
+
var ModelLogoUrlSchema = z3.string().refine(
|
|
2022
|
+
(value) => modelLogoUrl({ id: "", logoUrl: value }) !== null,
|
|
2023
|
+
"model logoUrl must be an HTTPS URL without embedded credentials, at most 2048 characters"
|
|
2024
|
+
);
|
|
2025
|
+
var RegistryModelSchema = z3.object({
|
|
2026
|
+
id: z3.string().min(1),
|
|
1396
2027
|
// canonical OpenGeni product id
|
|
1397
|
-
upstreamModelId:
|
|
2028
|
+
upstreamModelId: z3.string().min(1).optional(),
|
|
1398
2029
|
// exact provider slug; defaults to id
|
|
1399
|
-
aliases:
|
|
2030
|
+
aliases: z3.array(z3.string().min(1)).optional(),
|
|
1400
2031
|
// accepted input only; never sent upstream
|
|
1401
|
-
label:
|
|
2032
|
+
label: z3.string().min(1).optional(),
|
|
1402
2033
|
// display name; defaults to id
|
|
1403
|
-
shortLabel:
|
|
2034
|
+
shortLabel: z3.string().min(1).max(64).optional(),
|
|
1404
2035
|
// compact UI label; optional
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
2036
|
+
logoUrl: ModelLogoUrlSchema.optional(),
|
|
2037
|
+
contextWindowTokens: z3.number().int().positive().optional(),
|
|
2038
|
+
effectiveContextWindowTokens: z3.number().int().positive().optional(),
|
|
2039
|
+
autoCompactTokenLimit: z3.number().int().positive().optional(),
|
|
1408
2040
|
// Canonical model-facing function/tool-result policy. The runtime applies
|
|
1409
2041
|
// the same 1.2x serialization allowance as Codex when materializing output.
|
|
1410
|
-
toolOutputTruncationTokens:
|
|
1411
|
-
reasoningEffort:
|
|
2042
|
+
toolOutputTruncationTokens: z3.number().int().positive().optional(),
|
|
2043
|
+
reasoningEffort: z3.boolean().optional(),
|
|
1412
2044
|
// legacy compatibility input/projection
|
|
1413
|
-
hostedWebSearch:
|
|
2045
|
+
hostedWebSearch: z3.boolean().optional(),
|
|
1414
2046
|
// legacy compatibility input/projection
|
|
1415
2047
|
capabilities: ModelCapabilitiesV1Schema.optional(),
|
|
1416
|
-
pricing:
|
|
2048
|
+
pricing: z3.union([ModelPricingSchema, ModelPricingScheduleSchema]).optional(),
|
|
1417
2049
|
// Reserved normalized contracts are derived by OpenGeni in V1. Generic
|
|
1418
2050
|
// registry JSON must not opt itself into workspace BYOK or reattribute cost.
|
|
1419
|
-
credentialSource:
|
|
1420
|
-
billing:
|
|
2051
|
+
credentialSource: z3.never().optional(),
|
|
2052
|
+
billing: z3.never().optional()
|
|
1421
2053
|
}).superRefine((model, ctx) => {
|
|
1422
2054
|
if (model.capabilities && model.reasoningEffort !== void 0 && model.reasoningEffort !== model.capabilities.reasoning.runnable) {
|
|
1423
2055
|
ctx.addIssue({
|
|
@@ -1434,27 +2066,54 @@ var RegistryModelSchema = z.object({
|
|
|
1434
2066
|
});
|
|
1435
2067
|
}
|
|
1436
2068
|
});
|
|
1437
|
-
var
|
|
2069
|
+
var ClaudeSubscriptionIdentity = z3.object({
|
|
2070
|
+
accountUuid: z3.union([z3.string().uuid(), z3.literal("")]),
|
|
2071
|
+
deviceId: z3.string().regex(/^[a-f0-9]{64}$/)
|
|
2072
|
+
}).strict();
|
|
2073
|
+
var ClaudeSubscriptionCredential = z3.object({
|
|
2074
|
+
version: z3.literal(1),
|
|
2075
|
+
token: z3.string().regex(/^sk-ant-oat[0-9]+-\S+$/),
|
|
2076
|
+
identity: ClaudeSubscriptionIdentity,
|
|
2077
|
+
oauth: z3.object({
|
|
2078
|
+
refreshToken: z3.string().min(1).max(16384),
|
|
2079
|
+
expiresAt: z3.string().datetime(),
|
|
2080
|
+
scopes: z3.array(z3.string().min(1).max(256)).min(1).max(32)
|
|
2081
|
+
}).strict().optional()
|
|
2082
|
+
}).strict();
|
|
2083
|
+
var AnthropicProviderOptions = z3.object({
|
|
2084
|
+
identity: ClaudeSubscriptionIdentity.optional(),
|
|
2085
|
+
// Native connection provenance only; never included in Anthropic request bodies.
|
|
2086
|
+
credentialBinding: z3.object({
|
|
2087
|
+
connectionId: z3.string().uuid(),
|
|
2088
|
+
credentialVersion: z3.number().int().positive()
|
|
2089
|
+
}).strict().optional(),
|
|
2090
|
+
auth: z3.enum(["api-key", "oauth"]).default("api-key"),
|
|
2091
|
+
cacheTtl: z3.enum(["5m", "1h", "off"]).default("5m"),
|
|
2092
|
+
maxOutputTokens: z3.number().int().positive().default(32e3),
|
|
2093
|
+
streamIdleTimeoutMs: z3.number().int().positive().default(6e5)
|
|
2094
|
+
});
|
|
2095
|
+
var RegistryProviderSchema = z3.object({
|
|
1438
2096
|
kind: RegistryProviderKind.default("api-key"),
|
|
1439
|
-
id:
|
|
2097
|
+
id: z3.string().min(1).regex(registryId),
|
|
1440
2098
|
// stable provider id, e.g. "fireworks"
|
|
1441
|
-
label:
|
|
2099
|
+
label: z3.string().min(1).optional(),
|
|
1442
2100
|
api: ModelProviderApi.default("chat"),
|
|
2101
|
+
anthropic: AnthropicProviderOptions.optional(),
|
|
1443
2102
|
wireProfile: ModelProviderWireProfile.default("openai"),
|
|
1444
|
-
baseUrl:
|
|
1445
|
-
apiKey:
|
|
2103
|
+
baseUrl: z3.string().url(),
|
|
2104
|
+
apiKey: z3.string().optional(),
|
|
1446
2105
|
// inline key (pragmatic) ...
|
|
1447
|
-
apiKeyEnv:
|
|
2106
|
+
apiKeyEnv: z3.string().optional(),
|
|
1448
2107
|
// ... OR name of the env var holding the key (preferred)
|
|
1449
|
-
defaultQuery:
|
|
1450
|
-
defaultHeaders:
|
|
1451
|
-
publicDefaultQueryNames:
|
|
1452
|
-
publicDefaultHeaderNames:
|
|
2108
|
+
defaultQuery: z3.record(z3.string(), z3.string()).optional(),
|
|
2109
|
+
defaultHeaders: z3.record(z3.string(), z3.string()).optional(),
|
|
2110
|
+
publicDefaultQueryNames: z3.array(z3.string().min(1)).optional(),
|
|
2111
|
+
publicDefaultHeaderNames: z3.array(z3.string().min(1)).optional(),
|
|
1453
2112
|
// V1 derives these from provider kind. Workspace BYOK is deliberately not a
|
|
1454
2113
|
// registry switch and requires a separately reviewed encrypted broker.
|
|
1455
|
-
credentialSource:
|
|
1456
|
-
billing:
|
|
1457
|
-
models:
|
|
2114
|
+
credentialSource: z3.never().optional(),
|
|
2115
|
+
billing: z3.never().optional(),
|
|
2116
|
+
models: z3.array(RegistryModelSchema).min(1)
|
|
1458
2117
|
}).superRefine((provider, ctx) => {
|
|
1459
2118
|
if (provider.kind !== "anonymous") {
|
|
1460
2119
|
return;
|
|
@@ -1524,17 +2183,21 @@ var RESERVED_MODEL_PROVIDER_IDS = /* @__PURE__ */ new Set([
|
|
|
1524
2183
|
ORGANIZATION_GATEWAY_PROVIDER_ID,
|
|
1525
2184
|
OPENROUTER_PROVIDER_ID,
|
|
1526
2185
|
WORKSPACE_OPENROUTER_PROVIDER_ID,
|
|
1527
|
-
ORGANIZATION_OPENROUTER_PROVIDER_ID
|
|
2186
|
+
ORGANIZATION_OPENROUTER_PROVIDER_ID,
|
|
2187
|
+
"organization-anthropic",
|
|
2188
|
+
"organization-claude-subscription",
|
|
2189
|
+
"workspace-anthropic",
|
|
2190
|
+
"workspace-claude-subscription"
|
|
1528
2191
|
]);
|
|
1529
|
-
var ModelCostClass =
|
|
1530
|
-
var ConfiguredModelCostClass =
|
|
2192
|
+
var ModelCostClass = z3.enum(["free", "credits"]);
|
|
2193
|
+
var ConfiguredModelCostClass = z3.enum([
|
|
1531
2194
|
"free",
|
|
1532
2195
|
"credits",
|
|
1533
2196
|
"subscription",
|
|
1534
2197
|
"workspace",
|
|
1535
2198
|
"organization"
|
|
1536
2199
|
]);
|
|
1537
|
-
var ModelNote =
|
|
2200
|
+
var ModelNote = z3.string().max(500).refine((value) => !/[\r\n|]/u.test(value), {
|
|
1538
2201
|
message: "model notes must not contain newlines or the | field separator"
|
|
1539
2202
|
});
|
|
1540
2203
|
function parseModelCostPolicyJson(raw) {
|
|
@@ -1547,7 +2210,7 @@ function parseModelCostPolicyJson(raw) {
|
|
|
1547
2210
|
{ cause: error }
|
|
1548
2211
|
);
|
|
1549
2212
|
}
|
|
1550
|
-
return
|
|
2213
|
+
return z3.record(z3.string().min(1), ModelCostClass).parse(parsed);
|
|
1551
2214
|
}
|
|
1552
2215
|
function parseModelNotesJson(raw) {
|
|
1553
2216
|
let parsed;
|
|
@@ -1559,45 +2222,47 @@ function parseModelNotesJson(raw) {
|
|
|
1559
2222
|
{ cause: error }
|
|
1560
2223
|
);
|
|
1561
2224
|
}
|
|
1562
|
-
return
|
|
2225
|
+
return z3.record(z3.string().min(1), ModelNote).parse(parsed);
|
|
1563
2226
|
}
|
|
1564
2227
|
function configuredModelNotes(settings) {
|
|
1565
2228
|
return parseModelNotesJson(settings.modelNotesJson);
|
|
1566
2229
|
}
|
|
1567
|
-
var GatewayCatalogModel =
|
|
1568
|
-
productId:
|
|
1569
|
-
workspaceProductId:
|
|
1570
|
-
upstreamModelId:
|
|
1571
|
-
label:
|
|
1572
|
-
shortLabel:
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
2230
|
+
var GatewayCatalogModel = z3.object({
|
|
2231
|
+
productId: z3.string().min(1),
|
|
2232
|
+
workspaceProductId: z3.string().min(1).startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX),
|
|
2233
|
+
upstreamModelId: z3.string().min(1),
|
|
2234
|
+
label: z3.string().min(1),
|
|
2235
|
+
shortLabel: z3.string().min(1).max(64).optional(),
|
|
2236
|
+
logoUrl: ModelLogoUrlSchema.optional(),
|
|
2237
|
+
providers: z3.array(z3.string().min(1)).min(1),
|
|
2238
|
+
implicitCaching: z3.boolean().default(false),
|
|
2239
|
+
vision: z3.boolean().default(false),
|
|
2240
|
+
inputFileMediaTypes: z3.array(z3.string().min(1)).default([]),
|
|
2241
|
+
contextWindowTokens: z3.number().int().positive().default(1e6),
|
|
2242
|
+
effectiveContextWindowTokens: z3.number().int().positive().default(9e5),
|
|
2243
|
+
autoCompactTokenLimit: z3.number().int().positive().default(85e4),
|
|
2244
|
+
pricing: z3.union([ModelPricingSchema, ModelPricingScheduleSchema]).optional(),
|
|
2245
|
+
credentialSource: z3.never().optional(),
|
|
2246
|
+
billing: z3.never().optional(),
|
|
2247
|
+
apiKey: z3.never().optional()
|
|
1584
2248
|
}).strict();
|
|
1585
|
-
var OpenRouterCatalogModel =
|
|
1586
|
-
upstreamModelId:
|
|
1587
|
-
label:
|
|
1588
|
-
shortLabel:
|
|
1589
|
-
|
|
2249
|
+
var OpenRouterCatalogModel = z3.object({
|
|
2250
|
+
upstreamModelId: z3.string().min(1).endsWith(":free"),
|
|
2251
|
+
label: z3.string().min(1),
|
|
2252
|
+
shortLabel: z3.string().min(1).max(64).optional(),
|
|
2253
|
+
logoUrl: ModelLogoUrlSchema.optional(),
|
|
2254
|
+
aliases: z3.array(z3.string().min(1)).default([]),
|
|
1590
2255
|
capabilities: ModelCapabilitiesV1Schema,
|
|
1591
|
-
contextWindowTokens:
|
|
1592
|
-
effectiveContextWindowTokens:
|
|
1593
|
-
autoCompactTokenLimit:
|
|
1594
|
-
toolOutputTruncationTokens:
|
|
1595
|
-
credentialSource:
|
|
1596
|
-
billing:
|
|
1597
|
-
pricing:
|
|
1598
|
-
apiKey:
|
|
2256
|
+
contextWindowTokens: z3.number().int().positive().optional(),
|
|
2257
|
+
effectiveContextWindowTokens: z3.number().int().positive().optional(),
|
|
2258
|
+
autoCompactTokenLimit: z3.number().int().positive().optional(),
|
|
2259
|
+
toolOutputTruncationTokens: z3.number().int().positive().optional(),
|
|
2260
|
+
credentialSource: z3.never().optional(),
|
|
2261
|
+
billing: z3.never().optional(),
|
|
2262
|
+
pricing: z3.never().optional(),
|
|
2263
|
+
apiKey: z3.never().optional()
|
|
1599
2264
|
}).strict();
|
|
1600
|
-
var DeploymentRegistryBaseUrl =
|
|
2265
|
+
var DeploymentRegistryBaseUrl = z3.string().url().superRefine((value, context) => {
|
|
1601
2266
|
const url = new URL(value);
|
|
1602
2267
|
if (url.username || url.password) {
|
|
1603
2268
|
context.addIssue({
|
|
@@ -1618,40 +2283,66 @@ var DeploymentRegistryBaseUrl = z.string().url().superRefine((value, context) =>
|
|
|
1618
2283
|
});
|
|
1619
2284
|
}
|
|
1620
2285
|
});
|
|
1621
|
-
var DeploymentRegistryProviderKind =
|
|
2286
|
+
var DeploymentRegistryProviderKind = z3.enum(["api-key", "anonymous"]);
|
|
1622
2287
|
var DeploymentRegistryModelSchema = RegistryModelSchema.safeExtend({
|
|
1623
|
-
pricing:
|
|
2288
|
+
pricing: z3.never().optional()
|
|
1624
2289
|
}).strict();
|
|
1625
2290
|
var DeploymentRegistryProviderSchema = RegistryProviderSchema.safeExtend({
|
|
1626
2291
|
kind: DeploymentRegistryProviderKind.default("api-key"),
|
|
1627
2292
|
baseUrl: DeploymentRegistryBaseUrl,
|
|
1628
|
-
models:
|
|
1629
|
-
apiKey:
|
|
1630
|
-
apiKeyEnv:
|
|
1631
|
-
defaultHeaders:
|
|
1632
|
-
defaultQuery:
|
|
1633
|
-
publicDefaultHeaderNames:
|
|
1634
|
-
publicDefaultQueryNames:
|
|
2293
|
+
models: z3.array(DeploymentRegistryModelSchema).min(1),
|
|
2294
|
+
apiKey: z3.never().optional(),
|
|
2295
|
+
apiKeyEnv: z3.never().optional(),
|
|
2296
|
+
defaultHeaders: z3.never().optional(),
|
|
2297
|
+
defaultQuery: z3.never().optional(),
|
|
2298
|
+
publicDefaultHeaderNames: z3.never().optional(),
|
|
2299
|
+
publicDefaultQueryNames: z3.never().optional()
|
|
1635
2300
|
}).strict();
|
|
1636
2301
|
var DeploymentGatewayCatalogModelSchema = GatewayCatalogModel.safeExtend({
|
|
1637
|
-
pricing:
|
|
2302
|
+
pricing: z3.never().optional()
|
|
1638
2303
|
}).strict();
|
|
1639
|
-
var
|
|
1640
|
-
|
|
2304
|
+
var CodexCatalogModelSchema = RegistryModelSchema.safeExtend({
|
|
2305
|
+
retired: z3.boolean().optional(),
|
|
2306
|
+
id: z3.string().regex(/^codex\/[a-zA-Z0-9][a-zA-Z0-9._-]*$/),
|
|
2307
|
+
upstreamModelId: z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/),
|
|
2308
|
+
capabilities: ModelCapabilitiesV1Schema,
|
|
2309
|
+
pricing: z3.never().optional()
|
|
2310
|
+
}).strict().superRefine((model, context) => {
|
|
2311
|
+
if (model.id !== `${CODEX_MODEL_ID_PREFIX}${model.upstreamModelId}`) {
|
|
2312
|
+
context.addIssue({
|
|
2313
|
+
code: "custom",
|
|
2314
|
+
path: ["id"],
|
|
2315
|
+
message: "Codex product id must match its upstream model slug"
|
|
2316
|
+
});
|
|
2317
|
+
}
|
|
2318
|
+
}).transform((model) => ({
|
|
2319
|
+
...model,
|
|
2320
|
+
capabilities: reviewedCodexCatalogCapabilities(model.upstreamModelId, model.capabilities)
|
|
2321
|
+
}));
|
|
2322
|
+
var ModelCatalogDocument = z3.object({
|
|
2323
|
+
schemaVersion: z3.literal(1),
|
|
1641
2324
|
/** Canonical deployment default. Omission preserves the V1 first-built-in
|
|
1642
2325
|
* fallback for existing documents; operators should set this explicitly
|
|
1643
2326
|
* when cutting over a registry or connected-subscription default. */
|
|
1644
|
-
defaultModel:
|
|
1645
|
-
builtInModels:
|
|
1646
|
-
registryProviders:
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
2327
|
+
defaultModel: z3.string().min(1).optional(),
|
|
2328
|
+
builtInModels: z3.array(z3.string().min(1)),
|
|
2329
|
+
registryProviders: z3.array(DeploymentRegistryProviderSchema).default([]),
|
|
2330
|
+
codexModels: z3.array(CodexCatalogModelSchema).optional(),
|
|
2331
|
+
gatewayModels: z3.array(DeploymentGatewayCatalogModelSchema).default([]),
|
|
2332
|
+
openrouterModels: z3.array(OpenRouterCatalogModel).default([]),
|
|
2333
|
+
modelNotes: z3.record(z3.string().min(1), ModelNote).default({}),
|
|
2334
|
+
billing: z3.never().optional(),
|
|
2335
|
+
enabled: z3.never().optional(),
|
|
2336
|
+
apiKey: z3.never().optional(),
|
|
2337
|
+
bands: z3.never().optional()
|
|
1654
2338
|
}).strict().superRefine((document, context) => {
|
|
2339
|
+
if (document.builtInModels.length === 0 && !document.defaultModel) {
|
|
2340
|
+
context.addIssue({
|
|
2341
|
+
code: "custom",
|
|
2342
|
+
path: ["defaultModel"],
|
|
2343
|
+
message: "catalogs without built-in models require an explicit default model"
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
1655
2346
|
const productIds = /* @__PURE__ */ new Set();
|
|
1656
2347
|
const providerIds = /* @__PURE__ */ new Set();
|
|
1657
2348
|
const gatewayUpstreamIds = /* @__PURE__ */ new Set();
|
|
@@ -1673,8 +2364,16 @@ var ModelCatalogDocument = z.object({
|
|
|
1673
2364
|
productIds.add(id);
|
|
1674
2365
|
};
|
|
1675
2366
|
document.builtInModels.forEach((id, index) => add(id, ["builtInModels", index]));
|
|
2367
|
+
document.codexModels?.forEach((model, index) => add(model.id, ["codexModels", index, "id"]));
|
|
2368
|
+
if (document.codexModels?.some((model) => model.retired && model.id === document.defaultModel)) {
|
|
2369
|
+
context.addIssue({
|
|
2370
|
+
code: "custom",
|
|
2371
|
+
path: ["defaultModel"],
|
|
2372
|
+
message: "a retired model cannot be the deployment default"
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
1676
2375
|
document.registryProviders.forEach((provider, providerIndex) => {
|
|
1677
|
-
if (RESERVED_MODEL_PROVIDER_IDS.has(provider.id)) {
|
|
2376
|
+
if (RESERVED_MODEL_PROVIDER_IDS.has(provider.id) || provider.id.startsWith("workspace-openai-") || provider.id.startsWith("workspace-azure-openai-")) {
|
|
1678
2377
|
context.addIssue({
|
|
1679
2378
|
code: "custom",
|
|
1680
2379
|
path: ["registryProviders", providerIndex, "id"],
|
|
@@ -1719,7 +2418,7 @@ var ModelCatalogDocument = z.object({
|
|
|
1719
2418
|
message: "catalog default model must not contain newlines or the | field separator"
|
|
1720
2419
|
});
|
|
1721
2420
|
}
|
|
1722
|
-
if (document.defaultModel && !productIds.has(document.defaultModel) && !document.defaultModel.startsWith(CODEX_MODEL_ID_PREFIX) && !document.defaultModel.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX)) {
|
|
2421
|
+
if (document.defaultModel && !productIds.has(document.defaultModel) && !(document.codexModels === void 0 && document.defaultModel.startsWith(CODEX_MODEL_ID_PREFIX)) && !document.defaultModel.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX)) {
|
|
1723
2422
|
context.addIssue({
|
|
1724
2423
|
code: "custom",
|
|
1725
2424
|
path: ["defaultModel"],
|
|
@@ -1789,15 +2488,19 @@ function applyModelCatalogDocument(settings, rawDocument) {
|
|
|
1789
2488
|
),
|
|
1790
2489
|
resolvedGatewayModelsJson: JSON.stringify(document.gatewayModels),
|
|
1791
2490
|
resolvedOpenRouterModelsJson: JSON.stringify(document.openrouterModels),
|
|
2491
|
+
resolvedCodexModelsJson: document.codexModels === void 0 ? void 0 : JSON.stringify(document.codexModels),
|
|
1792
2492
|
modelNotesJson: JSON.stringify(document.modelNotes)
|
|
1793
2493
|
};
|
|
1794
2494
|
return resolved;
|
|
1795
2495
|
}
|
|
1796
|
-
var IntegrationOAuthClientConfigSchema =
|
|
1797
|
-
clientId:
|
|
1798
|
-
clientSecret:
|
|
1799
|
-
tokenEndpointAuthMethod:
|
|
2496
|
+
var IntegrationOAuthClientConfigSchema = z3.object({
|
|
2497
|
+
clientId: z3.string().min(1),
|
|
2498
|
+
clientSecret: z3.string().min(1).optional(),
|
|
2499
|
+
tokenEndpointAuthMethod: z3.enum(["none", "client_secret_post", "client_secret_basic"]).default("none")
|
|
1800
2500
|
});
|
|
2501
|
+
function isManagedOpenRouterFreeRoute(route) {
|
|
2502
|
+
return route.provider.kind === "openrouter-managed" && route.configured.upstreamModelId.endsWith(":free");
|
|
2503
|
+
}
|
|
1801
2504
|
var VERCEL_AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh/v1";
|
|
1802
2505
|
var VERCEL_AI_GATEWAY_AI_SDK_BASE_URL = "https://ai-gateway.vercel.sh/v4/ai";
|
|
1803
2506
|
var VERCEL_AI_GATEWAY_CONNECTION_DOMAIN = "ai-gateway.vercel.sh";
|
|
@@ -1924,7 +2627,7 @@ function configuredGatewayCatalogModels(settings) {
|
|
|
1924
2627
|
if (settings.resolvedGatewayModelsJson === void 0) {
|
|
1925
2628
|
return defaultGatewayCatalogModels();
|
|
1926
2629
|
}
|
|
1927
|
-
return
|
|
2630
|
+
return z3.array(GatewayCatalogModel).parse(JSON.parse(settings.resolvedGatewayModelsJson));
|
|
1928
2631
|
}
|
|
1929
2632
|
function configuredGatewayUpstreamModelIds(settings) {
|
|
1930
2633
|
return configuredGatewayCatalogModels(settings).map((model) => model.upstreamModelId);
|
|
@@ -1943,7 +2646,7 @@ function configuredOpenRouterCatalogModels(settings) {
|
|
|
1943
2646
|
if (settings.resolvedOpenRouterModelsJson === void 0) {
|
|
1944
2647
|
return [...OPENGENI_OPENROUTER_MODELS];
|
|
1945
2648
|
}
|
|
1946
|
-
return
|
|
2649
|
+
return z3.array(OpenRouterCatalogModel).parse(JSON.parse(settings.resolvedOpenRouterModelsJson));
|
|
1947
2650
|
}
|
|
1948
2651
|
function configuredOpenRouterUpstreamModelIds(settings) {
|
|
1949
2652
|
return configuredOpenRouterCatalogModels(settings).map((model) => model.upstreamModelId);
|
|
@@ -1961,6 +2664,73 @@ function configuredOpenRouterOrganizationProductModelIds(settings) {
|
|
|
1961
2664
|
return [];
|
|
1962
2665
|
}
|
|
1963
2666
|
var defaultModelPricing = {
|
|
2667
|
+
"gpt-6-astra": {
|
|
2668
|
+
default: {
|
|
2669
|
+
// OpenAI list price: $10 / $1 cached / $12.50 cache write / $50 output.
|
|
2670
|
+
inputMicrosPerMillionTokens: 1e7,
|
|
2671
|
+
cachedInputMicrosPerMillionTokens: 1e6,
|
|
2672
|
+
cacheWriteMicrosPerMillionTokens: 125e5,
|
|
2673
|
+
outputMicrosPerMillionTokens: 5e7,
|
|
2674
|
+
marginBps: 500
|
|
2675
|
+
},
|
|
2676
|
+
inputTokenTiers: [
|
|
2677
|
+
{
|
|
2678
|
+
// Prompts with more than 272K input tokens use 2x input and 1.5x output.
|
|
2679
|
+
minimumInputTokens: 272001,
|
|
2680
|
+
pricing: {
|
|
2681
|
+
inputMicrosPerMillionTokens: 2e7,
|
|
2682
|
+
cachedInputMicrosPerMillionTokens: 2e6,
|
|
2683
|
+
cacheWriteMicrosPerMillionTokens: 25e6,
|
|
2684
|
+
outputMicrosPerMillionTokens: 75e6,
|
|
2685
|
+
marginBps: 500
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
]
|
|
2689
|
+
},
|
|
2690
|
+
"gpt-6-sol": {
|
|
2691
|
+
default: {
|
|
2692
|
+
// OpenAI list price: $2 / $0.20 cached / $2.50 cache write / $10 output.
|
|
2693
|
+
inputMicrosPerMillionTokens: 2e6,
|
|
2694
|
+
cachedInputMicrosPerMillionTokens: 2e5,
|
|
2695
|
+
cacheWriteMicrosPerMillionTokens: 25e5,
|
|
2696
|
+
outputMicrosPerMillionTokens: 1e7,
|
|
2697
|
+
marginBps: 500
|
|
2698
|
+
},
|
|
2699
|
+
inputTokenTiers: [
|
|
2700
|
+
{
|
|
2701
|
+
minimumInputTokens: 272001,
|
|
2702
|
+
pricing: {
|
|
2703
|
+
inputMicrosPerMillionTokens: 4e6,
|
|
2704
|
+
cachedInputMicrosPerMillionTokens: 4e5,
|
|
2705
|
+
cacheWriteMicrosPerMillionTokens: 5e6,
|
|
2706
|
+
outputMicrosPerMillionTokens: 15e6,
|
|
2707
|
+
marginBps: 500
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
]
|
|
2711
|
+
},
|
|
2712
|
+
"gpt-6-luna": {
|
|
2713
|
+
default: {
|
|
2714
|
+
// OpenAI list price: $0.10 / $0.01 cached / $0.125 cache write / $0.50 output.
|
|
2715
|
+
inputMicrosPerMillionTokens: 1e5,
|
|
2716
|
+
cachedInputMicrosPerMillionTokens: 1e4,
|
|
2717
|
+
cacheWriteMicrosPerMillionTokens: 125e3,
|
|
2718
|
+
outputMicrosPerMillionTokens: 5e5,
|
|
2719
|
+
marginBps: 500
|
|
2720
|
+
},
|
|
2721
|
+
inputTokenTiers: [
|
|
2722
|
+
{
|
|
2723
|
+
minimumInputTokens: 272001,
|
|
2724
|
+
pricing: {
|
|
2725
|
+
inputMicrosPerMillionTokens: 2e5,
|
|
2726
|
+
cachedInputMicrosPerMillionTokens: 2e4,
|
|
2727
|
+
cacheWriteMicrosPerMillionTokens: 25e4,
|
|
2728
|
+
outputMicrosPerMillionTokens: 75e4,
|
|
2729
|
+
marginBps: 500
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
]
|
|
2733
|
+
},
|
|
1964
2734
|
"gpt-5.6-sol": {
|
|
1965
2735
|
default: {
|
|
1966
2736
|
// Promotional OpenAI pricing, guaranteed through at least 2026-11-21.
|
|
@@ -2060,6 +2830,103 @@ var defaultModelPricing = {
|
|
|
2060
2830
|
}
|
|
2061
2831
|
}
|
|
2062
2832
|
};
|
|
2833
|
+
var reviewedModelListPricing = {
|
|
2834
|
+
// Reviewed 2026-10-03 against https://developers.openai.com/api/docs/pricing
|
|
2835
|
+
// and https://ai-gateway.vercel.sh/v1/models. GPT-6.1 Sol's cache-read rate
|
|
2836
|
+
// is 5% of input, not GPT-6 Sol's 10%. The long-context boundary is >272K.
|
|
2837
|
+
"gpt-6.1-sol": {
|
|
2838
|
+
default: {
|
|
2839
|
+
inputMicrosPerMillionTokens: 2e6,
|
|
2840
|
+
cachedInputMicrosPerMillionTokens: 1e5,
|
|
2841
|
+
cacheWriteMicrosPerMillionTokens: 25e5,
|
|
2842
|
+
outputMicrosPerMillionTokens: 1e7,
|
|
2843
|
+
marginBps: 500
|
|
2844
|
+
},
|
|
2845
|
+
inputTokenTiers: [
|
|
2846
|
+
{
|
|
2847
|
+
minimumInputTokens: 272001,
|
|
2848
|
+
pricing: {
|
|
2849
|
+
inputMicrosPerMillionTokens: 4e6,
|
|
2850
|
+
cachedInputMicrosPerMillionTokens: 2e5,
|
|
2851
|
+
cacheWriteMicrosPerMillionTokens: 5e6,
|
|
2852
|
+
outputMicrosPerMillionTokens: 15e6,
|
|
2853
|
+
marginBps: 500
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
]
|
|
2857
|
+
},
|
|
2858
|
+
// xAI Standard API list rates, reviewed 2026-10-03:
|
|
2859
|
+
// https://docs.x.ai/developers/models/grok-4.5 (and grok-4.6 / grok-4.7).
|
|
2860
|
+
// Preserve the native API's established >=200K boundary. Gateway's separately
|
|
2861
|
+
// configured >200K schedule is not interchangeable with this native schedule.
|
|
2862
|
+
// xAI's automatic caching has no separate cache-write surcharge.
|
|
2863
|
+
...Object.fromEntries(
|
|
2864
|
+
[
|
|
2865
|
+
["grok-4.5", 3e5],
|
|
2866
|
+
["grok-4.6", 5e5],
|
|
2867
|
+
["grok-4.7", 5e5]
|
|
2868
|
+
].map(([model, cachedInput]) => [
|
|
2869
|
+
model,
|
|
2870
|
+
{
|
|
2871
|
+
default: {
|
|
2872
|
+
inputMicrosPerMillionTokens: 2e6,
|
|
2873
|
+
cachedInputMicrosPerMillionTokens: cachedInput,
|
|
2874
|
+
outputMicrosPerMillionTokens: 6e6,
|
|
2875
|
+
marginBps: 500
|
|
2876
|
+
},
|
|
2877
|
+
inputTokenTiers: [
|
|
2878
|
+
{
|
|
2879
|
+
minimumInputTokens: 2e5,
|
|
2880
|
+
pricing: {
|
|
2881
|
+
inputMicrosPerMillionTokens: 4e6,
|
|
2882
|
+
cachedInputMicrosPerMillionTokens: cachedInput * 2,
|
|
2883
|
+
outputMicrosPerMillionTokens: 12e6,
|
|
2884
|
+
marginBps: 500
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
]
|
|
2888
|
+
}
|
|
2889
|
+
])
|
|
2890
|
+
),
|
|
2891
|
+
// Every reviewed native Claude profile. Standard/global prices include
|
|
2892
|
+
// 5-minute cache writes; 1-hour native routes are projected separately.
|
|
2893
|
+
// https://platform.claude.com/docs/en/about-claude/pricing (2026-10-03).
|
|
2894
|
+
// Opus 5.5 cache reads are 5%, unlike the older models' 10%; none of these
|
|
2895
|
+
// models has a long-context premium.
|
|
2896
|
+
...Object.fromEntries(
|
|
2897
|
+
[
|
|
2898
|
+
["claude-opus-5-5", 4e6, 2e5, 5e6, 2e7],
|
|
2899
|
+
["claude-sonnet-5-5", 2e6, 2e5, 25e5, 1e7],
|
|
2900
|
+
["claude-opus-5", 5e6, 5e5, 625e4, 25e6],
|
|
2901
|
+
["claude-sonnet-5", 2e6, 2e5, 25e5, 1e7],
|
|
2902
|
+
["claude-opus-4-8", 5e6, 5e5, 625e4, 25e6],
|
|
2903
|
+
["claude-opus-4-7", 5e6, 5e5, 625e4, 25e6],
|
|
2904
|
+
["claude-opus-4-6", 5e6, 5e5, 625e4, 25e6],
|
|
2905
|
+
["claude-sonnet-4-6", 3e6, 3e5, 375e4, 15e6],
|
|
2906
|
+
["claude-haiku-4-5-20251001", 1e6, 1e5, 125e4, 5e6]
|
|
2907
|
+
].map(([model, input, cachedInput, cacheWrite, output]) => [
|
|
2908
|
+
model,
|
|
2909
|
+
{
|
|
2910
|
+
default: {
|
|
2911
|
+
inputMicrosPerMillionTokens: input,
|
|
2912
|
+
cachedInputMicrosPerMillionTokens: cachedInput,
|
|
2913
|
+
cacheWriteMicrosPerMillionTokens: cacheWrite,
|
|
2914
|
+
outputMicrosPerMillionTokens: output,
|
|
2915
|
+
marginBps: 500
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
])
|
|
2919
|
+
)
|
|
2920
|
+
};
|
|
2921
|
+
var reviewedFreeOpenRouterListPricing = {
|
|
2922
|
+
default: {
|
|
2923
|
+
inputMicrosPerMillionTokens: 0,
|
|
2924
|
+
cachedInputMicrosPerMillionTokens: 0,
|
|
2925
|
+
cacheWriteMicrosPerMillionTokens: 0,
|
|
2926
|
+
outputMicrosPerMillionTokens: 0,
|
|
2927
|
+
marginBps: 500
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2063
2930
|
var SANDBOX_REQUIRED_ENV = {
|
|
2064
2931
|
// docker/local/none need no credentials (local dev container / in-process / off).
|
|
2065
2932
|
docker: [],
|
|
@@ -2119,6 +2986,7 @@ function optionalEnvironmentValue(name, source) {
|
|
|
2119
2986
|
const value = source[name];
|
|
2120
2987
|
return value && value.trim().length > 0 ? value : void 0;
|
|
2121
2988
|
}
|
|
2989
|
+
var idleCommandContainmentDisabledWarned = false;
|
|
2122
2990
|
function getSettings(source = process.env) {
|
|
2123
2991
|
const optional = (name) => optionalEnvironmentValue(name, source);
|
|
2124
2992
|
const modelCatalogSource = optional("OPENGENI_MODEL_CATALOG_SOURCE");
|
|
@@ -2129,6 +2997,7 @@ function getSettings(source = process.env) {
|
|
|
2129
2997
|
deploymentRevision: optional("OPENGENI_DEPLOYMENT_REVISION") ?? optional("SOURCE_VERSION") ?? optional("GITHUB_SHA"),
|
|
2130
2998
|
serverVersion: optional("OPENGENI_SERVER_VERSION"),
|
|
2131
2999
|
databaseUrl: optional("OPENGENI_DATABASE_URL"),
|
|
3000
|
+
apiDatabasePoolMax: optional("OPENGENI_API_DATABASE_POOL_MAX"),
|
|
2132
3001
|
dbSchema: optional("OPENGENI_DB_SCHEMA"),
|
|
2133
3002
|
rlsStrategy: optional("OPENGENI_RLS_STRATEGY"),
|
|
2134
3003
|
runtimeDatabaseRole: optional("OPENGENI_RUNTIME_DATABASE_ROLE"),
|
|
@@ -2160,26 +3029,33 @@ function getSettings(source = process.env) {
|
|
|
2160
3029
|
observabilityMetricsEnabled: optional("OPENGENI_OBSERVABILITY_METRICS_ENABLED"),
|
|
2161
3030
|
observabilityOtlpEndpoint: optional("OPENGENI_OTEL_EXPORTER_OTLP_ENDPOINT") ?? optional("OTEL_EXPORTER_OTLP_ENDPOINT"),
|
|
2162
3031
|
observabilityOtlpHeaders: optional("OPENGENI_OTEL_EXPORTER_OTLP_HEADERS") ?? optional("OTEL_EXPORTER_OTLP_HEADERS"),
|
|
3032
|
+
observabilityDiagnosticsEndpoint: optional("OPENGENI_OBSERVABILITY_DIAGNOSTICS_ENDPOINT"),
|
|
3033
|
+
observabilityDiagnosticsHeaders: optional("OPENGENI_OBSERVABILITY_DIAGNOSTICS_HEADERS"),
|
|
2163
3034
|
analyticsEnabled: optional("OPENGENI_ANALYTICS_ENABLED"),
|
|
2164
3035
|
analyticsConsentRequired: optional("OPENGENI_ANALYTICS_CONSENT_REQUIRED"),
|
|
2165
3036
|
analyticsReoClientId: optional("OPENGENI_ANALYTICS_REO_CLIENT_ID"),
|
|
2166
3037
|
analyticsPosthogProjectKey: optional("OPENGENI_ANALYTICS_POSTHOG_PROJECT_KEY"),
|
|
2167
3038
|
analyticsPosthogHost: optional("OPENGENI_ANALYTICS_POSTHOG_HOST"),
|
|
2168
3039
|
analyticsGa4MeasurementId: optional("OPENGENI_ANALYTICS_GA4_MEASUREMENT_ID"),
|
|
3040
|
+
legalPrivacyPolicyUrl: optional("OPENGENI_LEGAL_PRIVACY_POLICY_URL"),
|
|
3041
|
+
legalTermsOfServiceUrl: optional("OPENGENI_LEGAL_TERMS_OF_SERVICE_URL"),
|
|
3042
|
+
supportEmail: optional("OPENGENI_SUPPORT_EMAIL"),
|
|
2169
3043
|
publicBaseUrl: optional("OPENGENI_PUBLIC_BASE_URL"),
|
|
3044
|
+
documentationUrl: optional("OPENGENI_DOCUMENTATION_URL"),
|
|
2170
3045
|
mcpOauthEnabled: optional("OPENGENI_MCP_OAUTH_ENABLED"),
|
|
2171
|
-
|
|
3046
|
+
apiTrustedProxyHops: optional("OPENGENI_API_TRUSTED_PROXY_HOPS"),
|
|
3047
|
+
apiTrustedProxyCidrs: optional("OPENGENI_API_TRUSTED_PROXY_CIDRS"),
|
|
2172
3048
|
webBaseUrl: optional("OPENGENI_WEB_BASE_URL"),
|
|
2173
3049
|
agentReleasesBaseUrl: optional("OPENGENI_AGENT_RELEASES_BASE_URL"),
|
|
2174
3050
|
agentStableVersion: optional("OPENGENI_AGENT_STABLE_VERSION"),
|
|
2175
3051
|
agentBetaVersion: optional("OPENGENI_AGENT_BETA_VERSION"),
|
|
2176
3052
|
productAccessMode: optional("OPENGENI_PRODUCT_ACCESS_MODE"),
|
|
2177
|
-
organizationTenancyCanonicalActivationEnabled: optional(
|
|
2178
|
-
"OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED"
|
|
2179
|
-
),
|
|
2180
3053
|
billingMode: optional("OPENGENI_BILLING_MODE"),
|
|
3054
|
+
verifiedSignupTrialCreditsEnabled: optional("OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED"),
|
|
3055
|
+
creditPromotionPolicy: optional("OPENGENI_CREDIT_PROMOTION_POLICY_JSON"),
|
|
2181
3056
|
entitlementsMode: optional("OPENGENI_ENTITLEMENTS_MODE"),
|
|
2182
3057
|
usageLimitsMode: optional("OPENGENI_USAGE_LIMITS_MODE"),
|
|
3058
|
+
usageAllowancesEnabled: optional("OPENGENI_USAGE_ALLOWANCES_ENABLED"),
|
|
2183
3059
|
staticEntitlementsJson: optional("OPENGENI_STATIC_ENTITLEMENTS_JSON"),
|
|
2184
3060
|
staticUsageLimitsJson: optional("OPENGENI_STATIC_USAGE_LIMITS_JSON"),
|
|
2185
3061
|
delegationSecret: optional("OPENGENI_DELEGATION_SECRET"),
|
|
@@ -2199,13 +3075,16 @@ function getSettings(source = process.env) {
|
|
|
2199
3075
|
environmentsEncryptionKey: optional("OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY"),
|
|
2200
3076
|
integrationsEnabled: optional("OPENGENI_INTEGRATIONS_ENABLED"),
|
|
2201
3077
|
integrationsStateSecret: optional("OPENGENI_INTEGRATIONS_STATE_SECRET"),
|
|
3078
|
+
integrationsOauthShortStateEnabled: optional("OPENGENI_INTEGRATIONS_OAUTH_SHORT_STATE_ENABLED"),
|
|
2202
3079
|
integrationsAllowPrivateNetworkTargets: optional(
|
|
2203
3080
|
"OPENGENI_INTEGRATIONS_ALLOW_PRIVATE_NETWORK_TARGETS"
|
|
2204
3081
|
),
|
|
2205
3082
|
integrationsOauthClientsJson: optional("OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON"),
|
|
3083
|
+
gmailWatchTopicName: optional("OPENGENI_GMAIL_WATCH_TOPIC_NAME"),
|
|
2206
3084
|
slackClientId: optional("OPENGENI_SLACK_CLIENT_ID"),
|
|
2207
3085
|
slackClientSecret: optional("OPENGENI_SLACK_CLIENT_SECRET"),
|
|
2208
3086
|
slackSigningSecret: optional("OPENGENI_SLACK_SIGNING_SECRET"),
|
|
3087
|
+
slackAccessMode: optional("OPENGENI_SLACK_ACCESS_MODE"),
|
|
2209
3088
|
slackBotDisplayName: optional("OPENGENI_SLACK_BOT_DISPLAY_NAME"),
|
|
2210
3089
|
slackCommand: optional("OPENGENI_SLACK_COMMAND"),
|
|
2211
3090
|
googleDriveClientId: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_ID"),
|
|
@@ -2240,10 +3119,6 @@ function getSettings(source = process.env) {
|
|
|
2240
3119
|
goalIdleBackoffMs: optional("OPENGENI_GOAL_IDLE_BACKOFF_MS"),
|
|
2241
3120
|
goalIdleBackoffMaxMs: optional("OPENGENI_GOAL_IDLE_BACKOFF_MAX_MS"),
|
|
2242
3121
|
childLifecycleNoticesEnabled: optional("OPENGENI_CHILD_LIFECYCLE_NOTICES_ENABLED"),
|
|
2243
|
-
hostMcpAuthoritySourceAdmissionEnabled: optional(
|
|
2244
|
-
"OPENGENI_HOST_MCP_AUTHORITY_SOURCE_ADMISSION_ENABLED"
|
|
2245
|
-
),
|
|
2246
|
-
hostMcpCredentialResolversJson: optional("OPENGENI_HOST_MCP_CREDENTIAL_RESOLVERS_JSON"),
|
|
2247
3122
|
slackWorkspaceRoutingEnabled: optional("OPENGENI_SLACK_WORKSPACE_ROUTING_ENABLED"),
|
|
2248
3123
|
agentMaxModelCallsPerTurn: optional("OPENGENI_AGENT_MAX_MODEL_CALLS_PER_TURN"),
|
|
2249
3124
|
contextWindowTokens: optional("OPENGENI_CONTEXT_WINDOW_TOKENS"),
|
|
@@ -2258,10 +3133,12 @@ function getSettings(source = process.env) {
|
|
|
2258
3133
|
authAllowMetrics: optional("OPENGENI_AUTH_ALLOW_METRICS"),
|
|
2259
3134
|
apiHost: optional("OPENGENI_API_HOST"),
|
|
2260
3135
|
apiPort: optional("OPENGENI_API_PORT"),
|
|
3136
|
+
apiMetricsPort: optional("OPENGENI_API_METRICS_PORT"),
|
|
2261
3137
|
workerHttpPort: optional("OPENGENI_WORKER_HTTP_PORT"),
|
|
2262
3138
|
opengeniMcpInternalUrl: optional("OPENGENI_MCP_INTERNAL_URL"),
|
|
2263
3139
|
opengeniMcpUrl: optional("OPENGENI_MCP_URL"),
|
|
2264
3140
|
corsAllowOriginRegex: optional("OPENGENI_CORS_ALLOW_ORIGIN_REGEX"),
|
|
3141
|
+
localAllowedOrigins: optional("OPENGENI_LOCAL_ALLOWED_ORIGINS"),
|
|
2265
3142
|
openaiProvider: optional("OPENGENI_OPENAI_PROVIDER"),
|
|
2266
3143
|
openaiApiKey: optional("OPENGENI_OPENAI_API_KEY") ?? optional("OPENAI_API_KEY"),
|
|
2267
3144
|
openaiBaseUrl: optional("OPENGENI_OPENAI_BASE_URL") ?? optional("OPENAI_BASE_URL"),
|
|
@@ -2320,6 +3197,7 @@ function getSettings(source = process.env) {
|
|
|
2320
3197
|
modelProvidersJson: optional("OPENGENI_MODEL_PROVIDERS_JSON"),
|
|
2321
3198
|
codexSubscriptionEnabled: optional("OPENGENI_CODEX_SUBSCRIPTION_ENABLED"),
|
|
2322
3199
|
supergrokSubscriptionEnabled: optional("OPENGENI_SUPERGROK_SUBSCRIPTION_ENABLED"),
|
|
3200
|
+
claudeSubscriptionEnabled: optional("OPENGENI_CLAUDE_SUBSCRIPTION_ENABLED"),
|
|
2323
3201
|
supergrokResponseStreamIdleTimeoutMs: optional(
|
|
2324
3202
|
"OPENGENI_SUPERGROK_RESPONSE_STREAM_IDLE_TIMEOUT_MS"
|
|
2325
3203
|
),
|
|
@@ -2328,13 +3206,23 @@ function getSettings(source = process.env) {
|
|
|
2328
3206
|
lazyToolSearchEnabled: optional("OPENGENI_LAZY_TOOL_SEARCH_ENABLED"),
|
|
2329
3207
|
codexFleetPolicyShadowEnabled: optional("OPENGENI_CODEX_FLEET_POLICY_SHADOW_ENABLED"),
|
|
2330
3208
|
codexProductSku: optional("OPENGENI_CODEX_PRODUCT_SKU"),
|
|
3209
|
+
reasoningConfigurationUpdatesEnabled: optional(
|
|
3210
|
+
"OPENGENI_REASONING_CONFIGURATION_UPDATES_ENABLED"
|
|
3211
|
+
),
|
|
2331
3212
|
openaiReasoningEffort: optional("OPENGENI_OPENAI_REASONING_EFFORT"),
|
|
2332
3213
|
openaiAllowedReasoningEfforts: optional("OPENGENI_OPENAI_ALLOWED_REASONING_EFFORTS"),
|
|
3214
|
+
creditsDefaultModel: optional("OPENGENI_CREDITS_DEFAULT_MODEL"),
|
|
3215
|
+
creditsDefaultReasoningEffort: optional("OPENGENI_CREDITS_DEFAULT_REASONING_EFFORT"),
|
|
2333
3216
|
openaiResponsesTransport: optional("OPENGENI_OPENAI_RESPONSES_TRANSPORT"),
|
|
2334
3217
|
openaiProviderItemIds: optional("OPENGENI_OPENAI_PROVIDER_ITEM_IDS"),
|
|
2335
3218
|
openaiReasoningEncryptedContent: optional("OPENGENI_OPENAI_REASONING_ENCRYPTED_CONTENT"),
|
|
2336
3219
|
openaiMaxRetries: optional("OPENGENI_OPENAI_MAX_RETRIES"),
|
|
2337
3220
|
webSearchEnabled: optional("OPENGENI_WEB_SEARCH_ENABLED"),
|
|
3221
|
+
jevApiKey: optional("OPENGENI_JEV_API_KEY"),
|
|
3222
|
+
jevBaseUrl: optional("OPENGENI_JEV_BASE_URL"),
|
|
3223
|
+
jevModel: optional("OPENGENI_JEV_MODEL"),
|
|
3224
|
+
jevRequestTimeoutMs: optional("OPENGENI_JEV_REQUEST_TIMEOUT_MS"),
|
|
3225
|
+
codeSearchMode: optional("OPENGENI_CODE_SEARCH_MODE"),
|
|
2338
3226
|
agentInstructionsTemplate: optional("OPENGENI_AGENT_INSTRUCTIONS_TEMPLATE"),
|
|
2339
3227
|
azureOpenaiBaseUrl: optional("OPENGENI_AZURE_OPENAI_BASE_URL"),
|
|
2340
3228
|
azureOpenaiEndpoint: optional("OPENGENI_AZURE_OPENAI_ENDPOINT"),
|
|
@@ -2351,6 +3239,7 @@ function getSettings(source = process.env) {
|
|
|
2351
3239
|
dockerWorkspaceBaseDir: optional("OPENGENI_DOCKER_WORKSPACE_BASE_DIR"),
|
|
2352
3240
|
modalAppName: optional("OPENGENI_MODAL_APP_NAME"),
|
|
2353
3241
|
modalImageRef: optional("OPENGENI_MODAL_IMAGE_REF") ?? DEFAULT_MODAL_IMAGE_REF,
|
|
3242
|
+
modalCommandSupervisionEnabled: optional("OPENGENI_MODAL_COMMAND_SUPERVISION_ENABLED"),
|
|
2354
3243
|
modalImageId: optional("OPENGENI_MODAL_IMAGE_ID"),
|
|
2355
3244
|
modalImageRegistrySecret: optional("OPENGENI_MODAL_IMAGE_REGISTRY_SECRET"),
|
|
2356
3245
|
modalTimeoutSeconds: optional("OPENGENI_MODAL_TIMEOUT_SECONDS"),
|
|
@@ -2402,6 +3291,9 @@ function getSettings(source = process.env) {
|
|
|
2402
3291
|
blaxelTtl: optional("OPENGENI_BLAXEL_TTL"),
|
|
2403
3292
|
cloudflareWorkerUrl: optional("OPENGENI_CLOUDFLARE_WORKER_URL"),
|
|
2404
3293
|
cloudflareApiKey: optional("OPENGENI_CLOUDFLARE_API_KEY"),
|
|
3294
|
+
experimentalBrowserContextPoolEnabled: optional(
|
|
3295
|
+
"OPENGENI_EXPERIMENTAL_BROWSER_CONTEXT_POOL_ENABLED"
|
|
3296
|
+
),
|
|
2405
3297
|
browserbaseApiKey: optional("OPENGENI_BROWSERBASE_API_KEY"),
|
|
2406
3298
|
kernelApiKey: optional("OPENGENI_KERNEL_API_KEY"),
|
|
2407
3299
|
kernelEndpoint: optional("OPENGENI_KERNEL_ENDPOINT"),
|
|
@@ -2450,6 +3342,7 @@ function getSettings(source = process.env) {
|
|
|
2450
3342
|
sandboxViewerHolderTtlMs: optional("OPENGENI_SANDBOX_VIEWER_HOLDER_TTL_MS"),
|
|
2451
3343
|
sandboxInteractionHolderTtlMs: optional("OPENGENI_SANDBOX_INTERACTION_HOLDER_TTL_MS"),
|
|
2452
3344
|
sandboxIdleGraceMs: optional("OPENGENI_SANDBOX_IDLE_GRACE_MS"),
|
|
3345
|
+
sandboxIdleCommandContainmentMs: optional("OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS"),
|
|
2453
3346
|
sandboxSnapshotIntervalMs: optional("OPENGENI_SANDBOX_SNAPSHOT_INTERVAL_MS"),
|
|
2454
3347
|
sandboxSnapshotTimeoutMs: optional("OPENGENI_SANDBOX_SNAPSHOT_TIMEOUT_MS"),
|
|
2455
3348
|
sandboxDrainSnapshotTimeoutMs: optional("OPENGENI_SANDBOX_DRAIN_SNAPSHOT_TIMEOUT_MS"),
|
|
@@ -2463,9 +3356,11 @@ function getSettings(source = process.env) {
|
|
|
2463
3356
|
sandboxWarmRateMicrosPerSecondJson: optional(
|
|
2464
3357
|
"OPENGENI_SANDBOX_WARM_RATE_MICROS_PER_SECOND_JSON"
|
|
2465
3358
|
),
|
|
3359
|
+
sandboxWarmBillingMode: optional("OPENGENI_SANDBOX_WARM_BILLING_MODE"),
|
|
2466
3360
|
sandboxMaxWarmSecondsPerWorkspace: optional("OPENGENI_SANDBOX_MAX_WARM_SECONDS_PER_WORKSPACE"),
|
|
2467
3361
|
sandboxPreparationProfiles: optional("OPENGENI_SANDBOX_PREPARATION_PROFILES"),
|
|
2468
3362
|
sandboxEnvAllowlist: optional("OPENGENI_SANDBOX_ENV_ALLOWLIST"),
|
|
3363
|
+
sandboxImageAllowlist: optional("OPENGENI_SANDBOX_IMAGE_ALLOWLIST"),
|
|
2469
3364
|
objectStorageEndpoint: optional("OPENGENI_OBJECT_STORAGE_ENDPOINT"),
|
|
2470
3365
|
objectStorageInternalEndpoint: optional("OPENGENI_OBJECT_STORAGE_INTERNAL_ENDPOINT"),
|
|
2471
3366
|
objectStorageSandboxEndpoint: optional("OPENGENI_OBJECT_STORAGE_SANDBOX_ENDPOINT"),
|
|
@@ -2492,6 +3387,13 @@ function getSettings(source = process.env) {
|
|
|
2492
3387
|
documentEmbeddingDimensions: optional("OPENGENI_DOCUMENT_EMBEDDING_DIMENSIONS"),
|
|
2493
3388
|
documentEmbeddingApiKey: optional("OPENGENI_DOCUMENT_EMBEDDING_API_KEY"),
|
|
2494
3389
|
documentEmbeddingBaseUrl: optional("OPENGENI_DOCUMENT_EMBEDDING_BASE_URL"),
|
|
3390
|
+
documentEmbeddingBillingMode: optional("OPENGENI_DOCUMENT_EMBEDDING_BILLING_MODE"),
|
|
3391
|
+
documentEmbeddingCreditsActivatedAt: optional(
|
|
3392
|
+
"OPENGENI_DOCUMENT_EMBEDDING_CREDITS_ACTIVATED_AT"
|
|
3393
|
+
),
|
|
3394
|
+
documentEmbeddingRateMicrosPerMillionBytes: optional(
|
|
3395
|
+
"OPENGENI_DOCUMENT_EMBEDDING_RATE_MICROS_PER_MILLION_BYTES"
|
|
3396
|
+
),
|
|
2495
3397
|
documentCurationProvider: optional("OPENGENI_DOCUMENT_CURATION_PROVIDER"),
|
|
2496
3398
|
documentCurationModel: optional("OPENGENI_DOCUMENT_CURATION_MODEL"),
|
|
2497
3399
|
documentCurationApiKey: optional("OPENGENI_DOCUMENT_CURATION_API_KEY"),
|
|
@@ -2526,7 +3428,9 @@ function getSettings(source = process.env) {
|
|
|
2526
3428
|
managedAuthGoogleClientSecret: optional("OPENGENI_MANAGED_AUTH_GOOGLE_CLIENT_SECRET"),
|
|
2527
3429
|
managedAuthGithubClientId: optional("OPENGENI_MANAGED_AUTH_GITHUB_CLIENT_ID"),
|
|
2528
3430
|
managedAuthGithubClientSecret: optional("OPENGENI_MANAGED_AUTH_GITHUB_CLIENT_SECRET"),
|
|
3431
|
+
allowedUserEmails: source.OPENGENI_ALLOWED_USER_EMAILS === void 0 ? void 0 : source.OPENGENI_ALLOWED_USER_EMAILS.split(",").map((email) => email.trim()),
|
|
2529
3432
|
managedAuthSessionSetMode: optional("OPENGENI_MANAGED_AUTH_SESSION_SET_MODE"),
|
|
3433
|
+
managedAuthNewSignupsEnabled: optional("OPENGENI_MANAGED_AUTH_NEW_SIGNUPS_ENABLED"),
|
|
2530
3434
|
organizationUserSetupEmailTokenTransport: optional(
|
|
2531
3435
|
"OPENGENI_ORGANIZATION_USER_SETUP_EMAIL_TOKEN_TRANSPORT"
|
|
2532
3436
|
),
|
|
@@ -2545,12 +3449,54 @@ function getSettings(source = process.env) {
|
|
|
2545
3449
|
const settings = {
|
|
2546
3450
|
...parsed,
|
|
2547
3451
|
sandboxIdleGraceMs: raw.sandboxIdleGraceMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(9e5, Math.floor(parsed.modalTimeoutSeconds * 1e3 / 2)) : parsed.sandboxIdleGraceMs,
|
|
2548
|
-
sandboxRotationLeadMs: raw.sandboxRotationLeadMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(
|
|
3452
|
+
sandboxRotationLeadMs: raw.sandboxRotationLeadMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(
|
|
3453
|
+
36e5,
|
|
3454
|
+
Math.max(
|
|
3455
|
+
Math.floor(parsed.modalTimeoutSeconds * 1e3 / 2),
|
|
3456
|
+
SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS + sandboxArchiveCaptureTimeoutMs({
|
|
3457
|
+
sandboxSnapshotTimeoutMs: Math.max(
|
|
3458
|
+
parsed.sandboxSnapshotTimeoutMs,
|
|
3459
|
+
parsed.sandboxDrainSnapshotTimeoutMs ?? parsed.sandboxSnapshotTimeoutMs
|
|
3460
|
+
)
|
|
3461
|
+
}) + 2 * parsed.sandboxLeaseReaperPeriodMs + 1
|
|
3462
|
+
)
|
|
3463
|
+
) : parsed.sandboxRotationLeadMs,
|
|
2549
3464
|
mcpServers: ensureBuiltInMcpServers(parsed)
|
|
2550
3465
|
};
|
|
3466
|
+
if (raw.sandboxIdleCommandContainmentMs === void 0) {
|
|
3467
|
+
const modalIdleCeilingMs = settings.sandboxBackend === "modal" && settings.modalIdleTimeoutSeconds !== void 0 ? settings.modalIdleTimeoutSeconds * 1e3 - settings.sandboxLeaseReaperPeriodMs - sandboxArchiveCaptureTimeoutMs({
|
|
3468
|
+
sandboxSnapshotTimeoutMs: effectiveSandboxDrainSnapshotTimeoutMs(settings)
|
|
3469
|
+
}) - 1 : Number.POSITIVE_INFINITY;
|
|
3470
|
+
const derived = Math.min(
|
|
3471
|
+
18e5,
|
|
3472
|
+
Math.floor((settings.sandboxIdleGraceMs + settings.sandboxRotationLeadMs) / 2),
|
|
3473
|
+
modalIdleCeilingMs
|
|
3474
|
+
);
|
|
3475
|
+
if (derived > settings.sandboxIdleGraceMs) {
|
|
3476
|
+
settings.sandboxIdleCommandContainmentMs = derived;
|
|
3477
|
+
} else {
|
|
3478
|
+
settings.sandboxIdleCommandContainmentMs = void 0;
|
|
3479
|
+
if (!idleCommandContainmentDisabledWarned) {
|
|
3480
|
+
idleCommandContainmentDisabledWarned = true;
|
|
3481
|
+
console.warn(
|
|
3482
|
+
`[config] idle command containment disabled: no window fits between OPENGENI_SANDBOX_IDLE_GRACE_MS (${settings.sandboxIdleGraceMs}) and the Modal idle timeout / rotation lead ceiling; set OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS to override.`
|
|
3483
|
+
);
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
warnRetiredOrganizationTenancyActivationSwitch(source);
|
|
2551
3488
|
validateSettings(settings, source);
|
|
2552
3489
|
return settings;
|
|
2553
3490
|
}
|
|
3491
|
+
var retiredOrganizationTenancyActivationSwitchWarned = false;
|
|
3492
|
+
function warnRetiredOrganizationTenancyActivationSwitch(source) {
|
|
3493
|
+
if (retiredOrganizationTenancyActivationSwitchWarned) return;
|
|
3494
|
+
if (source.OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED === void 0) return;
|
|
3495
|
+
retiredOrganizationTenancyActivationSwitchWarned = true;
|
|
3496
|
+
console.warn(
|
|
3497
|
+
"[config] OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED is retired and ignored: every organization is session-tenancy activated (migration 0611). Remove it from the deployment."
|
|
3498
|
+
);
|
|
3499
|
+
}
|
|
2554
3500
|
var LOCAL_FIRST_PARTY_DELEGATION_SECRET = "opengeni-local-first-party-delegation-secret-v1";
|
|
2555
3501
|
function resolveFirstPartyDelegationSecret(settings) {
|
|
2556
3502
|
const explicit = settings.delegationSecret?.trim();
|
|
@@ -2562,24 +3508,24 @@ function resolveFirstPartyDelegationSecret(settings) {
|
|
|
2562
3508
|
return settings.productAccessMode === "local" && (settings.environment === "local" || settings.environment === "test") ? LOCAL_FIRST_PARTY_DELEGATION_SECRET : void 0;
|
|
2563
3509
|
}
|
|
2564
3510
|
function resolveFirstPartyMcpToolPolicy(settings) {
|
|
2565
|
-
const
|
|
3511
|
+
const allowed2 = currentAgentLearningToolSelection(
|
|
2566
3512
|
settings.allowedFirstPartyMcpTools ?? [...FIRST_PARTY_MCP_TOOL_NAMES]
|
|
2567
|
-
);
|
|
2568
|
-
const allowedSet = new Set(
|
|
3513
|
+
).filter((tool) => !isRetiredNativeAtlassianTool(tool));
|
|
3514
|
+
const allowedSet = new Set(allowed2);
|
|
2569
3515
|
const defaults = currentAgentLearningToolSelection(
|
|
2570
3516
|
settings.defaultFirstPartyMcpTools ?? [...DEFAULT_FIRST_PARTY_MCP_TOOLS]
|
|
2571
3517
|
);
|
|
2572
3518
|
return {
|
|
2573
3519
|
default: defaults.filter((tool) => allowedSet.has(tool)),
|
|
2574
|
-
allowed: [...
|
|
3520
|
+
allowed: [...allowed2]
|
|
2575
3521
|
};
|
|
2576
3522
|
}
|
|
2577
3523
|
function allowedFirstPartyMcpToolsForSession(settings, selected) {
|
|
2578
3524
|
const policy = resolveFirstPartyMcpToolPolicy(settings);
|
|
2579
|
-
const
|
|
3525
|
+
const allowed2 = new Set(policy.allowed);
|
|
2580
3526
|
const tools = new Set(currentAgentLearningToolSelection(selected ?? policy.default));
|
|
2581
3527
|
if (tools.has("goal_pause")) tools.add("goal_resume");
|
|
2582
|
-
return [...tools].filter((tool) =>
|
|
3528
|
+
return [...tools].filter((tool) => allowed2.has(tool));
|
|
2583
3529
|
}
|
|
2584
3530
|
function effectiveModalIdleTimeoutSeconds(settings) {
|
|
2585
3531
|
return settings.modalIdleTimeoutSeconds ?? settings.modalTimeoutSeconds;
|
|
@@ -2945,6 +3891,7 @@ function gatewayRegistryProvider(settings, input) {
|
|
|
2945
3891
|
upstreamModelId: model.upstreamModelId,
|
|
2946
3892
|
label: model.label,
|
|
2947
3893
|
...model.shortLabel ? { shortLabel: model.shortLabel } : {},
|
|
3894
|
+
...model.logoUrl ? { logoUrl: model.logoUrl } : {},
|
|
2948
3895
|
capabilities: gatewayModelCapabilities(settings, {
|
|
2949
3896
|
implicitCaching: model.implicitCaching,
|
|
2950
3897
|
vision: model.vision,
|
|
@@ -3017,6 +3964,7 @@ function openRouterRegistryProvider(settings, input) {
|
|
|
3017
3964
|
aliases,
|
|
3018
3965
|
label: model.label,
|
|
3019
3966
|
...model.shortLabel ? { shortLabel: model.shortLabel } : {},
|
|
3967
|
+
...model.logoUrl ? { logoUrl: model.logoUrl } : {},
|
|
3020
3968
|
capabilities: model.capabilities,
|
|
3021
3969
|
...model.contextWindowTokens === void 0 ? {} : { contextWindowTokens: model.contextWindowTokens },
|
|
3022
3970
|
...model.effectiveContextWindowTokens === void 0 ? {} : { effectiveContextWindowTokens: model.effectiveContextWindowTokens },
|
|
@@ -3060,7 +4008,9 @@ function openRouterRegistryProvider(settings, input) {
|
|
|
3060
4008
|
}
|
|
3061
4009
|
function configuredRegistryProviders(settings) {
|
|
3062
4010
|
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
3063
|
-
const injected =
|
|
4011
|
+
const injected = providers.filter(
|
|
4012
|
+
(provider) => settings.claudeSubscriptionEnabled || !(provider.api === "anthropic-messages" && provider.anthropic?.auth === "oauth")
|
|
4013
|
+
);
|
|
3064
4014
|
if (settings.vercelAiGatewayApiKey && configuredGatewayCatalogModels(settings).length > 0) {
|
|
3065
4015
|
injected.push(
|
|
3066
4016
|
gatewayRegistryProvider(settings, {
|
|
@@ -3076,6 +4026,37 @@ function configuredRegistryProviders(settings) {
|
|
|
3076
4026
|
if (openrouter) injected.push(openrouter);
|
|
3077
4027
|
return injected;
|
|
3078
4028
|
}
|
|
4029
|
+
function withDirectModelProviders(settings, connections) {
|
|
4030
|
+
const providers = parseModelProvidersJson(settings.modelProvidersJson).filter(
|
|
4031
|
+
(provider) => !provider.id.startsWith("workspace-openai-") && !provider.id.startsWith("workspace-azure-openai-")
|
|
4032
|
+
);
|
|
4033
|
+
for (const connection of connections) {
|
|
4034
|
+
const spec = directModelConnectionSpec(connection);
|
|
4035
|
+
if (!spec) continue;
|
|
4036
|
+
providers.push({
|
|
4037
|
+
kind: spec.provider === "openai" ? "direct-openai-workspace" : "direct-azure-workspace",
|
|
4038
|
+
id: spec.providerId,
|
|
4039
|
+
label: spec.provider === "openai" ? "Your OpenAI" : "Your Azure OpenAI",
|
|
4040
|
+
api: "responses",
|
|
4041
|
+
wireProfile: spec.provider === "openai" ? "openai" : "azure-openai",
|
|
4042
|
+
baseUrl: spec.baseUrl,
|
|
4043
|
+
...connection.apiKey ? { apiKey: connection.apiKey } : {},
|
|
4044
|
+
models: [
|
|
4045
|
+
{
|
|
4046
|
+
id: spec.modelId,
|
|
4047
|
+
upstreamModelId: spec.model,
|
|
4048
|
+
label: spec.model,
|
|
4049
|
+
capabilities: legacyModelCapabilities(settings, {
|
|
4050
|
+
reasoningEffort: false,
|
|
4051
|
+
hostedWebSearch: false
|
|
4052
|
+
}),
|
|
4053
|
+
toolOutputTruncationTokens: settings.modelToolOutputTruncationTokens
|
|
4054
|
+
}
|
|
4055
|
+
]
|
|
4056
|
+
});
|
|
4057
|
+
}
|
|
4058
|
+
return { ...settings, modelProvidersJson: JSON.stringify(providers) };
|
|
4059
|
+
}
|
|
3079
4060
|
function withWorkspaceGatewayCatalogProvider(settings, customModels = []) {
|
|
3080
4061
|
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
3081
4062
|
const withoutWorkspace = providers.filter(
|
|
@@ -3188,8 +4169,8 @@ function productLabelForModelId(modelId) {
|
|
|
3188
4169
|
function productShortLabelForModelId(modelId) {
|
|
3189
4170
|
const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
|
|
3190
4171
|
switch (slug) {
|
|
3191
|
-
case "grok-4.
|
|
3192
|
-
return "4.
|
|
4172
|
+
case "grok-4.7":
|
|
4173
|
+
return "4.7";
|
|
3193
4174
|
case "gpt-5.6-sol":
|
|
3194
4175
|
return "5.6 Sol";
|
|
3195
4176
|
case "gpt-5.6-terra":
|
|
@@ -3198,6 +4179,10 @@ function productShortLabelForModelId(modelId) {
|
|
|
3198
4179
|
return "5.6 Luna";
|
|
3199
4180
|
case "gpt-6-astra":
|
|
3200
4181
|
return "6 Astra";
|
|
4182
|
+
case "gpt-6-sol":
|
|
4183
|
+
return "6 Sol";
|
|
4184
|
+
case "gpt-6-luna":
|
|
4185
|
+
return "6 Luna";
|
|
3201
4186
|
default:
|
|
3202
4187
|
return null;
|
|
3203
4188
|
}
|
|
@@ -3217,7 +4202,7 @@ function builtinContextLimitsForModel(settings, modelId) {
|
|
|
3217
4202
|
return { contextWindowTokens: settings.contextWindowTokens };
|
|
3218
4203
|
}
|
|
3219
4204
|
function builtinLatencyModesForModel(modelId) {
|
|
3220
|
-
if (isBuiltinGpt56ModelId(modelId) || modelId.startsWith("codex/gpt-5.6-") ||
|
|
4205
|
+
if (isBuiltinGpt56ModelId(modelId) || /^gpt-6(?:\.\d+)?-/u.test(modelId) || modelId.startsWith("codex/gpt-5.6-") || /^codex\/gpt-6(?:\.\d+)?-/u.test(modelId)) {
|
|
3221
4206
|
return [
|
|
3222
4207
|
{ id: "standard", upstream: "supported", runnable: true },
|
|
3223
4208
|
{
|
|
@@ -3230,12 +4215,26 @@ function builtinLatencyModesForModel(modelId) {
|
|
|
3230
4215
|
}
|
|
3231
4216
|
return [{ id: "standard", upstream: "unknown", runnable: true }];
|
|
3232
4217
|
}
|
|
4218
|
+
function isReviewedGptVisionModel(slug) {
|
|
4219
|
+
return slug.startsWith("gpt-5.6-") || /^gpt-6(?:\.\d+)?-/u.test(slug);
|
|
4220
|
+
}
|
|
4221
|
+
function reviewedCodexCatalogCapabilities(slug, capabilities) {
|
|
4222
|
+
if (!/^gpt-6(?:\.\d+)?-/u.test(slug)) return capabilities;
|
|
4223
|
+
const fast = builtinLatencyModesForModel(`${CODEX_MODEL_ID_PREFIX}${slug}`).find(
|
|
4224
|
+
(mode) => mode.id === "fast"
|
|
4225
|
+
);
|
|
4226
|
+
return normalizeCapabilities({
|
|
4227
|
+
...capabilities,
|
|
4228
|
+
inputModalities: [.../* @__PURE__ */ new Set([...capabilities.inputModalities, "image"])],
|
|
4229
|
+
latencyModes: fast && !capabilities.latencyModes.some((mode) => mode.id === "fast") ? [...capabilities.latencyModes, fast] : capabilities.latencyModes
|
|
4230
|
+
});
|
|
4231
|
+
}
|
|
3233
4232
|
function builtinPromptCachingForModel(modelId) {
|
|
3234
4233
|
const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
|
|
3235
|
-
return slug.startsWith("gpt-5.6-") ? { upstream: "supported", runnable: true, mode: "implicit" } : void 0;
|
|
4234
|
+
return slug.startsWith("gpt-5.6-") || slug.startsWith("gpt-6-") ? { upstream: "supported", runnable: true, mode: "implicit" } : void 0;
|
|
3236
4235
|
}
|
|
3237
4236
|
function builtinHostedImageGenerationForModel(settings, modelId) {
|
|
3238
|
-
return settings.openaiProvider === "openai" && isDirectOpenAiApiBaseUrl(settings.openaiBaseUrl) && isBuiltinGpt56ModelId(modelId);
|
|
4237
|
+
return settings.openaiProvider === "openai" && isDirectOpenAiApiBaseUrl(settings.openaiBaseUrl) && (isBuiltinGpt56ModelId(modelId) || modelId.startsWith("gpt-6-"));
|
|
3239
4238
|
}
|
|
3240
4239
|
function isDirectOpenAiApiBaseUrl(baseUrl) {
|
|
3241
4240
|
if (baseUrl === void 0) return true;
|
|
@@ -3274,11 +4273,21 @@ function runnableLatencyModesForModel(settings, modelId) {
|
|
|
3274
4273
|
function assertLatencyModeRunnable(settings, modelId, latencyMode) {
|
|
3275
4274
|
const runnable = runnableLatencyModesForModel(settings, modelId);
|
|
3276
4275
|
if (!runnable.includes(latencyMode)) {
|
|
3277
|
-
throw new
|
|
3278
|
-
`latency mode ${latencyMode} is not runnable for model ${modelId} (allowed: ${runnable.join(", ")})`
|
|
3279
|
-
);
|
|
4276
|
+
throw new UnsupportedLatencyModeError(modelId, latencyMode, runnable);
|
|
3280
4277
|
}
|
|
3281
4278
|
}
|
|
4279
|
+
var UnsupportedLatencyModeError = class extends Error {
|
|
4280
|
+
constructor(modelId, latencyMode, allowedLatencyModes) {
|
|
4281
|
+
super(
|
|
4282
|
+
`latency mode ${latencyMode} is not runnable for model ${modelId} (allowed: ${allowedLatencyModes.join(", ")})`
|
|
4283
|
+
);
|
|
4284
|
+
this.modelId = modelId;
|
|
4285
|
+
this.latencyMode = latencyMode;
|
|
4286
|
+
this.allowedLatencyModes = allowedLatencyModes;
|
|
4287
|
+
this.name = "UnsupportedLatencyModeError";
|
|
4288
|
+
}
|
|
4289
|
+
code = "UNSUPPORTED_LATENCY_MODE";
|
|
4290
|
+
};
|
|
3282
4291
|
function registryCredentialSource(provider) {
|
|
3283
4292
|
switch (provider.kind) {
|
|
3284
4293
|
case "anonymous":
|
|
@@ -3287,10 +4296,17 @@ function registryCredentialSource(provider) {
|
|
|
3287
4296
|
return { kind: "connected_subscription", provider: "codex" };
|
|
3288
4297
|
case "xai-subscription":
|
|
3289
4298
|
return { kind: "connected_subscription", provider: "xai" };
|
|
4299
|
+
case "claude-subscription-workspace":
|
|
4300
|
+
case "claude-subscription-organization":
|
|
4301
|
+
return { kind: "connected_subscription", provider: "claude" };
|
|
3290
4302
|
case "vercel-gateway-workspace":
|
|
4303
|
+
case "direct-openai-workspace":
|
|
4304
|
+
case "direct-azure-workspace":
|
|
3291
4305
|
case "openrouter-workspace":
|
|
4306
|
+
case "anthropic-workspace":
|
|
3292
4307
|
return { kind: "workspace_connection", mechanism: "api_key" };
|
|
3293
4308
|
case "vercel-gateway-organization":
|
|
4309
|
+
case "anthropic-organization":
|
|
3294
4310
|
case "openrouter-organization":
|
|
3295
4311
|
return { kind: "organization_connection", mechanism: "api_key" };
|
|
3296
4312
|
case "api-key":
|
|
@@ -3310,11 +4326,17 @@ function registryBilling(provider) {
|
|
|
3310
4326
|
return { upstreamPayer: "deployment", metering: "external" };
|
|
3311
4327
|
case "codex-subscription":
|
|
3312
4328
|
case "xai-subscription":
|
|
4329
|
+
case "claude-subscription-workspace":
|
|
4330
|
+
case "claude-subscription-organization":
|
|
3313
4331
|
return { upstreamPayer: "connected_subscription", metering: "external" };
|
|
3314
4332
|
case "vercel-gateway-workspace":
|
|
4333
|
+
case "direct-openai-workspace":
|
|
4334
|
+
case "direct-azure-workspace":
|
|
3315
4335
|
case "openrouter-workspace":
|
|
4336
|
+
case "anthropic-workspace":
|
|
3316
4337
|
return { upstreamPayer: "workspace", metering: "external" };
|
|
3317
4338
|
case "vercel-gateway-organization":
|
|
4339
|
+
case "anthropic-organization":
|
|
3318
4340
|
case "openrouter-organization":
|
|
3319
4341
|
return { upstreamPayer: "organization", metering: "external" };
|
|
3320
4342
|
case "api-key":
|
|
@@ -3345,6 +4367,9 @@ function staticRequestMetadataForDigest(provider) {
|
|
|
3345
4367
|
const publicHeaders = new Set(provider.publicDefaultHeaderNames ?? []);
|
|
3346
4368
|
const publicQuery = new Set(provider.publicDefaultQueryNames ?? []);
|
|
3347
4369
|
return {
|
|
4370
|
+
...provider.anthropic ? {
|
|
4371
|
+
anthropic: (({ identity: _identity, credentialBinding: _binding, ...options }) => options)(provider.anthropic)
|
|
4372
|
+
} : {},
|
|
3348
4373
|
headers: Object.entries(provider.defaultHeaders ?? {}).sort(([left], [right]) => left.localeCompare(right)).map(
|
|
3349
4374
|
([name, value]) => publicHeaders.has(name) ? { name, classification: "public", value } : { name, classification: "secret" }
|
|
3350
4375
|
),
|
|
@@ -3386,7 +4411,8 @@ function definitionVersionFor(model, provider, options = {}) {
|
|
|
3386
4411
|
...includeWireProfile ? { wireProfile: provider.wireProfile } : {},
|
|
3387
4412
|
baseUrl: provider.baseUrl ?? null,
|
|
3388
4413
|
defaultHeaders: requestMetadata.headers,
|
|
3389
|
-
defaultQuery: requestMetadata.query
|
|
4414
|
+
defaultQuery: requestMetadata.query,
|
|
4415
|
+
...requestMetadata.anthropic ? { anthropic: requestMetadata.anthropic } : {}
|
|
3390
4416
|
},
|
|
3391
4417
|
credentialSource: model.credentialSource,
|
|
3392
4418
|
billing: model.billing,
|
|
@@ -3408,8 +4434,41 @@ function legacyImplicitOpenAiDefinitionVersionFor(model, provider) {
|
|
|
3408
4434
|
includeWireProfile: false
|
|
3409
4435
|
});
|
|
3410
4436
|
}
|
|
3411
|
-
function
|
|
3412
|
-
|
|
4437
|
+
function legacyCodexAstraImplicitCachingDefinitionVersionFor(model, provider) {
|
|
4438
|
+
if (model.id !== "codex/gpt-6-astra" || model.upstreamModelId !== "gpt-6-astra" || provider.id !== CODEX_PROVIDER_ID || provider.kind !== "codex-subscription" || provider.api !== "responses" || provider.wireProfile !== "openai" || canonicalJson(model.capabilities.promptCaching) !== canonicalJson({ upstream: "supported", runnable: true, mode: "implicit" })) {
|
|
4439
|
+
return null;
|
|
4440
|
+
}
|
|
4441
|
+
const { definitionVersion: _definitionVersion, ...modelWithoutVersion } = model;
|
|
4442
|
+
const { promptCaching: _promptCaching, ...capabilities } = model.capabilities;
|
|
4443
|
+
return definitionVersionFor({ ...modelWithoutVersion, capabilities }, provider);
|
|
4444
|
+
}
|
|
4445
|
+
function matchesAdditiveCapabilityDefinitionVersion(model, provider, policy) {
|
|
4446
|
+
const { definitionVersion: _definitionVersion, ...modelWithoutVersion } = model;
|
|
4447
|
+
const { latencyModes, inputModalities } = model.capabilities;
|
|
4448
|
+
for (let latencyMask = 1; latencyMask < 1 << latencyModes.length; latencyMask += 1) {
|
|
4449
|
+
const retainedModes = latencyModes.filter((_mode, index) => latencyMask & 1 << index);
|
|
4450
|
+
if (!retainedModes.some((mode) => mode.id === policy.latencyMode && mode.runnable)) {
|
|
4451
|
+
continue;
|
|
4452
|
+
}
|
|
4453
|
+
for (let inputMask = 1; inputMask < 1 << inputModalities.length; inputMask += 1) {
|
|
4454
|
+
const retainedInputs = inputModalities.filter((_modality, index) => inputMask & 1 << index);
|
|
4455
|
+
if (retainedModes.length === latencyModes.length && retainedInputs.length === inputModalities.length) {
|
|
4456
|
+
continue;
|
|
4457
|
+
}
|
|
4458
|
+
const capabilities = {
|
|
4459
|
+
...model.capabilities,
|
|
4460
|
+
latencyModes: retainedModes,
|
|
4461
|
+
inputModalities: retainedInputs
|
|
4462
|
+
};
|
|
4463
|
+
if (policy.definitionVersion === definitionVersionFor({ ...modelWithoutVersion, capabilities }, provider)) {
|
|
4464
|
+
return true;
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
return false;
|
|
4469
|
+
}
|
|
4470
|
+
function builtinProviderId(settings) {
|
|
4471
|
+
return settings.openaiProvider === "azure" ? "azure" : "openai";
|
|
3413
4472
|
}
|
|
3414
4473
|
function builtinProviderLabel(settings) {
|
|
3415
4474
|
return settings.openaiProvider === "azure" ? "Azure OpenAI" : "OpenAI";
|
|
@@ -3429,10 +4488,10 @@ function configuredProviders(settings, source = process.env) {
|
|
|
3429
4488
|
if (settings.openaiProvider === "azure") {
|
|
3430
4489
|
const baseUrl = settings.azureOpenaiBaseUrl ?? settings.azureOpenaiEndpoint;
|
|
3431
4490
|
builtin.baseUrl = baseUrl ? normalizeRegistryBaseUrl(baseUrl, builtin.id) : void 0;
|
|
3432
|
-
builtin.apiKey = settings.azureOpenaiApiKey ?? settings.azureOpenaiAdToken;
|
|
4491
|
+
builtin.apiKey = usableDeploymentSecret(settings.azureOpenaiApiKey) ?? settings.azureOpenaiAdToken;
|
|
3433
4492
|
} else {
|
|
3434
4493
|
builtin.baseUrl = settings.openaiBaseUrl ? normalizeRegistryBaseUrl(settings.openaiBaseUrl, builtin.id) : void 0;
|
|
3435
|
-
builtin.apiKey = settings.openaiApiKey;
|
|
4494
|
+
builtin.apiKey = usableDeploymentSecret(settings.openaiApiKey);
|
|
3436
4495
|
}
|
|
3437
4496
|
const registry = configuredRegistryProviders(settings).map(
|
|
3438
4497
|
(provider) => ({
|
|
@@ -3440,6 +4499,7 @@ function configuredProviders(settings, source = process.env) {
|
|
|
3440
4499
|
label: provider.label ?? provider.id,
|
|
3441
4500
|
kind: provider.kind,
|
|
3442
4501
|
api: provider.api,
|
|
4502
|
+
anthropic: provider.anthropic,
|
|
3443
4503
|
wireProfile: provider.wireProfile,
|
|
3444
4504
|
builtin: false,
|
|
3445
4505
|
baseUrl: provider.baseUrl,
|
|
@@ -3454,11 +4514,17 @@ function configuredProviders(settings, source = process.env) {
|
|
|
3454
4514
|
);
|
|
3455
4515
|
return [builtin, ...registry];
|
|
3456
4516
|
}
|
|
4517
|
+
function codexUpstreamModelSlugs(settings) {
|
|
4518
|
+
if (settings.resolvedCodexModelsJson === void 0) return [...CODEX_FALLBACK_MODEL_SLUGS];
|
|
4519
|
+
return z3.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson)).filter((model) => !model.retired).map((model) => model.upstreamModelId);
|
|
4520
|
+
}
|
|
3457
4521
|
function withCodexCatalogProvider(settings) {
|
|
3458
4522
|
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
3459
4523
|
if (providers.some((provider2) => provider2.id === CODEX_PROVIDER_ID)) {
|
|
3460
4524
|
return settings;
|
|
3461
4525
|
}
|
|
4526
|
+
const catalogModels = settings.resolvedCodexModelsJson === void 0 ? void 0 : z3.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson)).filter((model) => !model.retired).map(({ retired: _retired, ...model }) => model);
|
|
4527
|
+
if (catalogModels?.length === 0) return settings;
|
|
3462
4528
|
const provider = {
|
|
3463
4529
|
kind: "codex-subscription",
|
|
3464
4530
|
id: CODEX_PROVIDER_ID,
|
|
@@ -3466,12 +4532,12 @@ function withCodexCatalogProvider(settings) {
|
|
|
3466
4532
|
api: "responses",
|
|
3467
4533
|
wireProfile: "openai",
|
|
3468
4534
|
baseUrl: CODEX_PROVIDER_BASE_URL,
|
|
3469
|
-
models: CODEX_FALLBACK_MODEL_SLUGS.map((slug) => {
|
|
4535
|
+
models: catalogModels ?? CODEX_FALLBACK_MODEL_SLUGS.map((slug) => {
|
|
3470
4536
|
const capabilities = {
|
|
3471
4537
|
...legacyModelCapabilities(settings, {
|
|
3472
4538
|
reasoningEffort: true,
|
|
3473
4539
|
hostedWebSearch: true,
|
|
3474
|
-
vision: slug
|
|
4540
|
+
vision: isReviewedGptVisionModel(slug)
|
|
3475
4541
|
}),
|
|
3476
4542
|
...builtinPromptCachingForModel(`${CODEX_MODEL_ID_PREFIX}${slug}`) ? {
|
|
3477
4543
|
promptCaching: builtinPromptCachingForModel(`${CODEX_MODEL_ID_PREFIX}${slug}`)
|
|
@@ -3654,7 +4720,7 @@ function configuredModels(settings, source = process.env) {
|
|
|
3654
4720
|
reasoningEffort: true,
|
|
3655
4721
|
hostedWebSearch: settings.webSearchEnabled,
|
|
3656
4722
|
hostedImageGeneration: builtinHostedImageGenerationForModel(settings, id),
|
|
3657
|
-
vision: id
|
|
4723
|
+
vision: isReviewedGptVisionModel(id)
|
|
3658
4724
|
}),
|
|
3659
4725
|
...builtinPromptCachingForModel(id) ? { promptCaching: builtinPromptCachingForModel(id) } : {},
|
|
3660
4726
|
latencyModes: builtinLatencyModesForModel(id)
|
|
@@ -3696,6 +4762,7 @@ function configuredModels(settings, source = process.env) {
|
|
|
3696
4762
|
id: model.id,
|
|
3697
4763
|
aliases: [...model.aliases ?? []],
|
|
3698
4764
|
label: model.label ?? productLabelForModelId(model.id),
|
|
4765
|
+
...model.logoUrl ? { logoUrl: model.logoUrl } : {},
|
|
3699
4766
|
...model.shortLabel ? { shortLabel: model.shortLabel } : productShortLabelForModelId(model.id) ? { shortLabel: productShortLabelForModelId(model.id) } : {},
|
|
3700
4767
|
providerId: provider.id,
|
|
3701
4768
|
providerLabel,
|
|
@@ -3733,7 +4800,57 @@ function canonicalizeConfiguredModelId(settings, modelId) {
|
|
|
3733
4800
|
return models.find((model) => model.aliases.includes(modelId))?.id ?? modelId;
|
|
3734
4801
|
}
|
|
3735
4802
|
function configuredAllowedModels(settings) {
|
|
3736
|
-
return configuredModels(settings).map((model) => model.id);
|
|
4803
|
+
return configuredModels(settings).filter((model) => isModelAvailableForNewSelection(settings, model.id)).map((model) => model.id);
|
|
4804
|
+
}
|
|
4805
|
+
function isModelAvailableForNewSelection(settings, modelId) {
|
|
4806
|
+
if (!modelId.startsWith(CODEX_MODEL_ID_PREFIX) || settings.resolvedCodexModelsJson === void 0)
|
|
4807
|
+
return true;
|
|
4808
|
+
const models = z3.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson));
|
|
4809
|
+
return models.some((model) => model.id === modelId && !model.retired);
|
|
4810
|
+
}
|
|
4811
|
+
function settingsForAcceptedSubscriptionTurn(settings, policy, expected) {
|
|
4812
|
+
const parsed = TurnExecutionPolicyV1.parse(policy);
|
|
4813
|
+
if (!parsed.productModelId.startsWith(CODEX_MODEL_ID_PREFIX)) return settings;
|
|
4814
|
+
if (!settings.codexSubscriptionEnabled) throw new Error("Codex subscription is disabled");
|
|
4815
|
+
const models = settings.resolvedCodexModelsJson === void 0 ? [] : z3.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson));
|
|
4816
|
+
const retained = models.find((model2) => model2.id === parsed.productModelId && model2.retired);
|
|
4817
|
+
if (!retained) {
|
|
4818
|
+
assertTurnExecutionPolicyMatchesConfigV1(settings, parsed, expected);
|
|
4819
|
+
return settings;
|
|
4820
|
+
}
|
|
4821
|
+
const { retired: _retired, ...model } = retained;
|
|
4822
|
+
const withoutCodex = {
|
|
4823
|
+
...settings,
|
|
4824
|
+
modelProvidersJson: JSON.stringify(
|
|
4825
|
+
parseModelProvidersJson(settings.modelProvidersJson).filter(
|
|
4826
|
+
(provider) => provider.id !== CODEX_PROVIDER_ID
|
|
4827
|
+
)
|
|
4828
|
+
)
|
|
4829
|
+
};
|
|
4830
|
+
const providerSettings = withCodexCatalogProvider({
|
|
4831
|
+
...withoutCodex,
|
|
4832
|
+
resolvedCodexModelsJson: JSON.stringify([model])
|
|
4833
|
+
});
|
|
4834
|
+
const retainedProvider = parseModelProvidersJson(providerSettings.modelProvidersJson).find(
|
|
4835
|
+
(provider) => provider.id === CODEX_PROVIDER_ID
|
|
4836
|
+
);
|
|
4837
|
+
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
4838
|
+
const current = providers.find((provider) => provider.id === CODEX_PROVIDER_ID);
|
|
4839
|
+
const restored = {
|
|
4840
|
+
...settings,
|
|
4841
|
+
modelProvidersJson: JSON.stringify([
|
|
4842
|
+
...providers.filter((provider) => provider.id !== CODEX_PROVIDER_ID),
|
|
4843
|
+
{
|
|
4844
|
+
...retainedProvider,
|
|
4845
|
+
models: [
|
|
4846
|
+
...(current?.models ?? []).filter((candidate) => candidate.id !== model.id),
|
|
4847
|
+
model
|
|
4848
|
+
]
|
|
4849
|
+
}
|
|
4850
|
+
])
|
|
4851
|
+
};
|
|
4852
|
+
assertTurnExecutionPolicyMatchesConfigV1(restored, parsed, expected);
|
|
4853
|
+
return restored;
|
|
3737
4854
|
}
|
|
3738
4855
|
function resolveModelProvider(settings, modelId) {
|
|
3739
4856
|
const canonicalModelId = canonicalizeConfiguredModelId(settings, modelId);
|
|
@@ -3783,12 +4900,25 @@ function resolveModelProviderForTurn(settings, modelId) {
|
|
|
3783
4900
|
canonicalizeConfiguredModelId(catalogSettings, modelId)
|
|
3784
4901
|
);
|
|
3785
4902
|
}
|
|
4903
|
+
var TurnExecutionPolicyModelUnavailableError = class extends Error {
|
|
4904
|
+
constructor(message) {
|
|
4905
|
+
super(message);
|
|
4906
|
+
this.name = "TurnExecutionPolicyModelUnavailableError";
|
|
4907
|
+
}
|
|
4908
|
+
};
|
|
3786
4909
|
function resolveTurnExecutionPolicyV1(settings, input) {
|
|
3787
4910
|
const catalogSettings = settingsForTurnExecutionPolicy(settings, input.modelId);
|
|
3788
4911
|
const productModelId = canonicalizeConfiguredModelId(catalogSettings, input.modelId);
|
|
4912
|
+
if (!isModelAvailableForNewSelection(catalogSettings, productModelId)) {
|
|
4913
|
+
throw new TurnExecutionPolicyModelUnavailableError(
|
|
4914
|
+
"Turn execution policy model is retired from new selection"
|
|
4915
|
+
);
|
|
4916
|
+
}
|
|
3789
4917
|
const resolved = resolveModelProvider(catalogSettings, productModelId);
|
|
3790
4918
|
if (!resolved) {
|
|
3791
|
-
throw new
|
|
4919
|
+
throw new TurnExecutionPolicyModelUnavailableError(
|
|
4920
|
+
"Turn execution policy model is not present in the configured catalog"
|
|
4921
|
+
);
|
|
3792
4922
|
}
|
|
3793
4923
|
if (input.requestedModelId !== null && canonicalizeConfiguredModelId(catalogSettings, input.requestedModelId) !== productModelId) {
|
|
3794
4924
|
throw new Error("Turn execution policy requested model does not canonicalize to its product");
|
|
@@ -3813,6 +4943,13 @@ function resolveTurnExecutionPolicyV1(settings, input) {
|
|
|
3813
4943
|
definitionVersion: resolved.model.definitionVersion
|
|
3814
4944
|
});
|
|
3815
4945
|
}
|
|
4946
|
+
var TurnExecutionPolicyDefinitionMismatchError = class extends Error {
|
|
4947
|
+
code = "turn_execution_policy_definition_mismatch";
|
|
4948
|
+
constructor() {
|
|
4949
|
+
super("Turn execution policy does not match the current provider definition");
|
|
4950
|
+
this.name = "TurnExecutionPolicyDefinitionMismatchError";
|
|
4951
|
+
}
|
|
4952
|
+
};
|
|
3816
4953
|
function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
3817
4954
|
const parsed = TurnExecutionPolicyV1.parse(policy);
|
|
3818
4955
|
const catalogSettings = settingsForTurnExecutionPolicy(settings, parsed.productModelId);
|
|
@@ -3831,15 +4968,33 @@ function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
|
3831
4968
|
if (!resolved) {
|
|
3832
4969
|
throw new Error("Turn execution policy model is no longer configured");
|
|
3833
4970
|
}
|
|
4971
|
+
const legacyClaudeScope = resolved.provider.kind === "claude-subscription-workspace" ? "workspace" : resolved.provider.kind === "claude-subscription-organization" ? "organization" : null;
|
|
4972
|
+
const legacyClaudeAccountingMatches = legacyClaudeScope !== null && parsed.providerId === resolved.provider.id && parsed.upstreamModelId === resolved.model.upstreamModelId && parsed.wireApi === resolved.model.api && canonicalJson(parsed.credentialSource) === canonicalJson({
|
|
4973
|
+
kind: `${legacyClaudeScope}_connection`,
|
|
4974
|
+
mechanism: "api_key"
|
|
4975
|
+
}) && canonicalJson(parsed.billing) === canonicalJson({
|
|
4976
|
+
upstreamPayer: legacyClaudeScope,
|
|
4977
|
+
metering: "external"
|
|
4978
|
+
}) && parsed.definitionVersion === definitionVersionFor(
|
|
4979
|
+
{
|
|
4980
|
+
...resolved.model,
|
|
4981
|
+
credentialSource: parsed.credentialSource,
|
|
4982
|
+
billing: parsed.billing
|
|
4983
|
+
},
|
|
4984
|
+
resolved.provider
|
|
4985
|
+
);
|
|
3834
4986
|
const legacyImplicitOpenAiDefinitionVersion = legacyImplicitOpenAiDefinitionVersionFor(
|
|
3835
4987
|
resolved.model,
|
|
3836
4988
|
resolved.provider
|
|
3837
4989
|
);
|
|
3838
|
-
const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion;
|
|
3839
|
-
const
|
|
3840
|
-
if (
|
|
4990
|
+
const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion || parsed.definitionVersion === legacyCodexAstraImplicitCachingDefinitionVersionFor(resolved.model, resolved.provider) || matchesAdditiveCapabilityDefinitionVersion(resolved.model, resolved.provider, parsed);
|
|
4991
|
+
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
|
+
if (identityMismatched && !legacyClaudeAccountingMatches) {
|
|
3841
4993
|
throw new Error("Turn execution policy does not match the current provider definition");
|
|
3842
4994
|
}
|
|
4995
|
+
if (!definitionVersionMatches && !legacyClaudeAccountingMatches) {
|
|
4996
|
+
throw new TurnExecutionPolicyDefinitionMismatchError();
|
|
4997
|
+
}
|
|
3843
4998
|
return { policy: parsed, provider: resolved.provider, model: resolved.model };
|
|
3844
4999
|
}
|
|
3845
5000
|
function configuredModelPricingSchedules(settings) {
|
|
@@ -3869,6 +5024,103 @@ function configuredModelPricingSchedules(settings) {
|
|
|
3869
5024
|
...configured
|
|
3870
5025
|
};
|
|
3871
5026
|
}
|
|
5027
|
+
function configuredModelListPricingSchedules(settings) {
|
|
5028
|
+
const prices = configuredModelPricingSchedules(settings);
|
|
5029
|
+
const configured = Object.fromEntries(
|
|
5030
|
+
Object.entries(parseModelPricingJson(settings.modelPricingJson)).map(([model, pricing]) => [
|
|
5031
|
+
model,
|
|
5032
|
+
normalizeModelPricingSchedule(pricing)
|
|
5033
|
+
])
|
|
5034
|
+
);
|
|
5035
|
+
if (settings.openaiProvider === "openai" && isDirectOpenAiApiBaseUrl(settings.openaiBaseUrl ?? "https://api.openai.com/v1")) {
|
|
5036
|
+
for (const model of configuredModels(settings)) {
|
|
5037
|
+
if (model.providerId !== builtinProviderId(settings) || !model.upstreamModelId.startsWith("gpt-") || prices[model.id] !== void 0)
|
|
5038
|
+
continue;
|
|
5039
|
+
const reviewed = reviewedModelListPricing[model.upstreamModelId];
|
|
5040
|
+
if (reviewed) prices[model.id] = reviewed;
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
for (const provider of configuredRegistryProviders(settings)) {
|
|
5044
|
+
for (const model of provider.models) {
|
|
5045
|
+
if (prices[model.id] !== void 0) continue;
|
|
5046
|
+
const reviewed = reviewedProviderModelPricing(settings, provider, model, configured);
|
|
5047
|
+
if (reviewed) prices[model.id] = reviewed;
|
|
5048
|
+
}
|
|
5049
|
+
}
|
|
5050
|
+
return prices;
|
|
5051
|
+
}
|
|
5052
|
+
function reviewedProviderModelPricing(settings, provider, model, configured) {
|
|
5053
|
+
const upstream = model.upstreamModelId ?? model.id;
|
|
5054
|
+
let priceId;
|
|
5055
|
+
let nativeClaude = false;
|
|
5056
|
+
switch (provider.kind) {
|
|
5057
|
+
case "anonymous":
|
|
5058
|
+
if (provider.baseUrl.replace(/\/$/u, "") === OPENROUTER_BASE_URL && upstream === DEFAULT_OPENROUTER_MODEL_ID.slice(OPENROUTER_MODEL_ID_PREFIX.length)) {
|
|
5059
|
+
priceId = DEFAULT_OPENROUTER_MODEL_ID;
|
|
5060
|
+
}
|
|
5061
|
+
break;
|
|
5062
|
+
case "codex-subscription":
|
|
5063
|
+
if (upstream.startsWith("gpt-")) priceId = upstream;
|
|
5064
|
+
break;
|
|
5065
|
+
case "xai-subscription":
|
|
5066
|
+
if (upstream.startsWith("grok-")) priceId = upstream;
|
|
5067
|
+
break;
|
|
5068
|
+
case "anthropic-workspace":
|
|
5069
|
+
case "anthropic-organization":
|
|
5070
|
+
case "claude-subscription-workspace":
|
|
5071
|
+
case "claude-subscription-organization":
|
|
5072
|
+
if (claudeNativeModelProfile(upstream)) {
|
|
5073
|
+
priceId = upstream;
|
|
5074
|
+
nativeClaude = true;
|
|
5075
|
+
}
|
|
5076
|
+
break;
|
|
5077
|
+
case "direct-openai-workspace":
|
|
5078
|
+
if (isDirectOpenAiApiBaseUrl(provider.baseUrl) && upstream.startsWith("gpt-")) {
|
|
5079
|
+
priceId = upstream;
|
|
5080
|
+
}
|
|
5081
|
+
break;
|
|
5082
|
+
case "vercel-gateway-managed":
|
|
5083
|
+
case "vercel-gateway-workspace":
|
|
5084
|
+
case "vercel-gateway-organization":
|
|
5085
|
+
priceId = configuredGatewayCatalogModels(settings).find(
|
|
5086
|
+
(candidate) => candidate.upstreamModelId === upstream && Object.values(OPENGENI_GATEWAY_MODELS).some(
|
|
5087
|
+
(reviewed) => reviewed.upstreamModelId === candidate.upstreamModelId
|
|
5088
|
+
)
|
|
5089
|
+
)?.productId;
|
|
5090
|
+
break;
|
|
5091
|
+
case "openrouter-workspace":
|
|
5092
|
+
case "openrouter-organization":
|
|
5093
|
+
case "openrouter-managed":
|
|
5094
|
+
if (upstream === DEFAULT_OPENROUTER_MODEL_ID.slice(OPENROUTER_MODEL_ID_PREFIX.length)) {
|
|
5095
|
+
priceId = DEFAULT_OPENROUTER_MODEL_ID;
|
|
5096
|
+
}
|
|
5097
|
+
break;
|
|
5098
|
+
case "api-key":
|
|
5099
|
+
if (isDirectOpenAiApiBaseUrl(provider.baseUrl) && upstream.startsWith("gpt-")) {
|
|
5100
|
+
priceId = upstream;
|
|
5101
|
+
} else if (provider.baseUrl.replace(/\/$/u, "") === "https://api.x.ai/v1") {
|
|
5102
|
+
if (upstream.startsWith("grok-")) priceId = upstream;
|
|
5103
|
+
} else if (provider.api === "anthropic-messages" && provider.baseUrl.replace(/\/$/u, "") === "https://api.anthropic.com/v1" && claudeNativeModelProfile(upstream)) {
|
|
5104
|
+
priceId = upstream;
|
|
5105
|
+
nativeClaude = true;
|
|
5106
|
+
}
|
|
5107
|
+
break;
|
|
5108
|
+
default:
|
|
5109
|
+
return void 0;
|
|
5110
|
+
}
|
|
5111
|
+
if (!priceId) return void 0;
|
|
5112
|
+
if (configured[priceId]) return configured[priceId];
|
|
5113
|
+
const schedule = reviewedModelListPricing[priceId] ?? defaultModelPricing[priceId] ?? (priceId === DEFAULT_OPENROUTER_MODEL_ID ? reviewedFreeOpenRouterListPricing : void 0);
|
|
5114
|
+
if (!schedule) return void 0;
|
|
5115
|
+
if (!nativeClaude || provider.anthropic?.cacheTtl !== "1h") return schedule;
|
|
5116
|
+
return {
|
|
5117
|
+
...schedule,
|
|
5118
|
+
default: {
|
|
5119
|
+
...schedule.default,
|
|
5120
|
+
cacheWriteMicrosPerMillionTokens: schedule.default.inputMicrosPerMillionTokens * 2
|
|
5121
|
+
}
|
|
5122
|
+
};
|
|
5123
|
+
}
|
|
3872
5124
|
function configuredModelPricing(settings) {
|
|
3873
5125
|
return Object.fromEntries(
|
|
3874
5126
|
Object.entries(configuredModelPricingSchedules(settings)).map(([model, schedule]) => [
|
|
@@ -3934,6 +5186,216 @@ function calculateModelUsageCostMicros(settings, model, usage, options) {
|
|
|
3934
5186
|
}
|
|
3935
5187
|
function calculateModelUsageCostBreakdown(settings, model, usage, options) {
|
|
3936
5188
|
const schedule = configuredModelPricingSchedules(settings)[model];
|
|
5189
|
+
return calculateUsageCostBreakdown(settings, model, usage, schedule, options);
|
|
5190
|
+
}
|
|
5191
|
+
function calculateModelListUsageCostBreakdown(settings, model, usage, options) {
|
|
5192
|
+
const schedule = configuredModelListPricingSchedules(settings)[model];
|
|
5193
|
+
return calculateUsageCostBreakdown(settings, model, usage, schedule, options);
|
|
5194
|
+
}
|
|
5195
|
+
function calculateModelListUsageCostSnapshot(settings, model, usage, options) {
|
|
5196
|
+
const schedule = configuredModelListPricingSchedules(settings)[model];
|
|
5197
|
+
const fallback = calculateUsageCostBreakdown(settings, model, usage, schedule, options);
|
|
5198
|
+
const unknown = { ...fallback, listByClassMicros: null, listByClassApprox: false };
|
|
5199
|
+
if (!schedule || !options?.priceContextKnown) return unknown;
|
|
5200
|
+
const entries = usage.requestUsageEntries?.length ? usage.requestUsageEntries : [usage];
|
|
5201
|
+
const classes = {
|
|
5202
|
+
uncachedInput: 0,
|
|
5203
|
+
cacheRead: 0,
|
|
5204
|
+
cacheWrite: 0,
|
|
5205
|
+
output: 0
|
|
5206
|
+
};
|
|
5207
|
+
const rawCostByPricing = /* @__PURE__ */ new Map();
|
|
5208
|
+
const native = nativeClaudeListWriteContext(settings, model);
|
|
5209
|
+
for (const entry of entries) {
|
|
5210
|
+
if (!knownTokenCounter(entry.inputTokens) || !knownTokenCounter(entry.outputTokens))
|
|
5211
|
+
return unknown;
|
|
5212
|
+
const cached = knownDetailTokenCounter(entry, [
|
|
5213
|
+
"cached_tokens",
|
|
5214
|
+
"cachedInputTokens",
|
|
5215
|
+
"cached_input_tokens"
|
|
5216
|
+
]);
|
|
5217
|
+
const writes = knownDetailTokenCounter(entry, ["cache_write_tokens", "cacheWriteTokens"], true);
|
|
5218
|
+
if (cached === void 0 || writes === void 0 || cached + writes > entry.inputTokens)
|
|
5219
|
+
return unknown;
|
|
5220
|
+
const pricing = selectModelPricing(schedule, entry.inputTokens);
|
|
5221
|
+
if (cached > 0 && pricing.cachedInputMicrosPerMillionTokens === void 0) return unknown;
|
|
5222
|
+
if (writes > 0 && pricing.cacheWriteMicrosPerMillionTokens === void 0) return unknown;
|
|
5223
|
+
const costs = {
|
|
5224
|
+
uncachedInput: Math.ceil(
|
|
5225
|
+
(entry.inputTokens - cached - writes) * pricing.inputMicrosPerMillionTokens / 1e6
|
|
5226
|
+
),
|
|
5227
|
+
cacheRead: Math.ceil(cached * (pricing.cachedInputMicrosPerMillionTokens ?? 0) / 1e6),
|
|
5228
|
+
cacheWrite: Math.ceil(writes * (pricing.cacheWriteMicrosPerMillionTokens ?? 0) / 1e6),
|
|
5229
|
+
output: Math.ceil(entry.outputTokens * pricing.outputMicrosPerMillionTokens / 1e6)
|
|
5230
|
+
};
|
|
5231
|
+
if (native && writes > 0) {
|
|
5232
|
+
const fiveMinute = knownDetailTokenCounter(entry, ["cache_write_tokens_5m"]);
|
|
5233
|
+
const oneHour = knownDetailTokenCounter(entry, ["cache_write_tokens_1h"]);
|
|
5234
|
+
if (fiveMinute === void 0 || oneHour === void 0 || fiveMinute + oneHour !== writes)
|
|
5235
|
+
return unknown;
|
|
5236
|
+
if (native.publishedRates) {
|
|
5237
|
+
costs.cacheWrite = Math.ceil(fiveMinute * native.publishedRates.fiveMinute / 1e6) + Math.ceil(oneHour * native.publishedRates.oneHour / 1e6);
|
|
5238
|
+
} else if (!(native.declaredTtl === "5m" && oneHour === 0 || native.declaredTtl === "1h" && fiveMinute === 0)) {
|
|
5239
|
+
return unknown;
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
const raw = sumListCostClasses(costs);
|
|
5243
|
+
rawCostByPricing.set(pricing, (rawCostByPricing.get(pricing) ?? 0) + raw);
|
|
5244
|
+
for (const key of MODEL_LIST_COST_CLASS_KEYS) classes[key] += costs[key];
|
|
5245
|
+
}
|
|
5246
|
+
let providerCostMicros = sumListCostClasses(classes);
|
|
5247
|
+
let creditCostMicros = 0;
|
|
5248
|
+
for (const [pricing, raw] of rawCostByPricing) {
|
|
5249
|
+
creditCostMicros += Math.ceil(raw * (1e4 + (pricing.marginBps ?? 0)) / 1e4);
|
|
5250
|
+
}
|
|
5251
|
+
let listByClassApprox = false;
|
|
5252
|
+
const latencyMode = options.latencyMode ?? "standard";
|
|
5253
|
+
if (latencyMode !== "standard") {
|
|
5254
|
+
const catalogSettings = settingsForTurnExecutionPolicy(settings, model);
|
|
5255
|
+
const resolved = resolveModelProvider(
|
|
5256
|
+
catalogSettings,
|
|
5257
|
+
canonicalizeConfiguredModelId(catalogSettings, model)
|
|
5258
|
+
);
|
|
5259
|
+
const multiplier = resolved?.model.capabilities.latencyModes.find(
|
|
5260
|
+
(mode) => mode.id === latencyMode && mode.runnable
|
|
5261
|
+
)?.billingMultiplierBps;
|
|
5262
|
+
if (multiplier === void 0 || multiplier <= 0) return unknown;
|
|
5263
|
+
providerCostMicros = Math.ceil(providerCostMicros * multiplier / 1e4);
|
|
5264
|
+
creditCostMicros = Math.ceil(creditCostMicros * multiplier / 1e4);
|
|
5265
|
+
const scaled = allocateLatencyListCostClasses(classes, multiplier, providerCostMicros);
|
|
5266
|
+
if (!scaled) return unknown;
|
|
5267
|
+
Object.assign(classes, scaled.classes);
|
|
5268
|
+
listByClassApprox = scaled.approximate;
|
|
5269
|
+
}
|
|
5270
|
+
if (![providerCostMicros, creditCostMicros, ...Object.values(classes)].every(knownTokenCounter))
|
|
5271
|
+
return unknown;
|
|
5272
|
+
return { providerCostMicros, creditCostMicros, listByClassMicros: classes, listByClassApprox };
|
|
5273
|
+
}
|
|
5274
|
+
function allocateRecordedModelListCostByClass(settings, model, usage, recordedProviderCostMicros) {
|
|
5275
|
+
const unknown = {
|
|
5276
|
+
listByClassMicros: null,
|
|
5277
|
+
listByClassApprox: false
|
|
5278
|
+
};
|
|
5279
|
+
if (!knownTokenCounter(recordedProviderCostMicros)) return unknown;
|
|
5280
|
+
const schedule = configuredModelListPricingSchedules(settings)[model];
|
|
5281
|
+
if (!schedule) return unknown;
|
|
5282
|
+
const weights = { uncachedInput: 0n, cacheRead: 0n, cacheWrite: 0n, output: 0n };
|
|
5283
|
+
const entries = usage.requestUsageEntries?.length ? usage.requestUsageEntries : [usage];
|
|
5284
|
+
for (const entry of entries) {
|
|
5285
|
+
if (!knownTokenCounter(entry.inputTokens) || !knownTokenCounter(entry.outputTokens))
|
|
5286
|
+
return unknown;
|
|
5287
|
+
const cached = knownDetailTokenCounter(entry, [
|
|
5288
|
+
"cached_tokens",
|
|
5289
|
+
"cachedInputTokens",
|
|
5290
|
+
"cached_input_tokens"
|
|
5291
|
+
]);
|
|
5292
|
+
const writes = knownDetailTokenCounter(entry, ["cache_write_tokens", "cacheWriteTokens"], true);
|
|
5293
|
+
if (cached === void 0 || writes === void 0 || cached + writes > entry.inputTokens)
|
|
5294
|
+
return unknown;
|
|
5295
|
+
const pricing = selectModelPricing(schedule, entry.inputTokens);
|
|
5296
|
+
const counters = {
|
|
5297
|
+
uncachedInput: entry.inputTokens - cached - writes,
|
|
5298
|
+
cacheRead: cached,
|
|
5299
|
+
cacheWrite: writes,
|
|
5300
|
+
output: entry.outputTokens
|
|
5301
|
+
};
|
|
5302
|
+
const rates = {
|
|
5303
|
+
uncachedInput: pricing.inputMicrosPerMillionTokens,
|
|
5304
|
+
cacheRead: pricing.cachedInputMicrosPerMillionTokens,
|
|
5305
|
+
cacheWrite: pricing.cacheWriteMicrosPerMillionTokens,
|
|
5306
|
+
output: pricing.outputMicrosPerMillionTokens
|
|
5307
|
+
};
|
|
5308
|
+
for (const key of MODEL_LIST_COST_CLASS_KEYS) {
|
|
5309
|
+
if (counters[key] === 0) continue;
|
|
5310
|
+
const rate = rates[key];
|
|
5311
|
+
if (!knownTokenCounter(rate)) return unknown;
|
|
5312
|
+
weights[key] += BigInt(counters[key]) * BigInt(rate);
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
const classes = allocateRecordedListCostWeights(weights, recordedProviderCostMicros);
|
|
5316
|
+
return classes ? { listByClassMicros: classes, listByClassApprox: true } : unknown;
|
|
5317
|
+
}
|
|
5318
|
+
var MODEL_LIST_COST_CLASS_KEYS = ["uncachedInput", "cacheRead", "cacheWrite", "output"];
|
|
5319
|
+
function sumListCostClasses(costs) {
|
|
5320
|
+
return MODEL_LIST_COST_CLASS_KEYS.reduce((total, key) => total + costs[key], 0);
|
|
5321
|
+
}
|
|
5322
|
+
function allocateRecordedListCostWeights(weights, target) {
|
|
5323
|
+
const denominator = MODEL_LIST_COST_CLASS_KEYS.reduce((total, key) => total + weights[key], 0n);
|
|
5324
|
+
if (denominator === 0n) {
|
|
5325
|
+
return target === 0 ? { uncachedInput: 0, cacheRead: 0, cacheWrite: 0, output: 0 } : void 0;
|
|
5326
|
+
}
|
|
5327
|
+
const rows = MODEL_LIST_COST_CLASS_KEYS.map((key, index) => {
|
|
5328
|
+
const numerator = BigInt(target) * weights[key];
|
|
5329
|
+
return { key, index, value: numerator / denominator, remainder: numerator % denominator };
|
|
5330
|
+
});
|
|
5331
|
+
const remaining = BigInt(target) - rows.reduce((total, row) => total + row.value, 0n);
|
|
5332
|
+
const ranked = [...rows].sort(
|
|
5333
|
+
(a, b) => a.remainder === b.remainder ? a.index - b.index : a.remainder > b.remainder ? -1 : 1
|
|
5334
|
+
);
|
|
5335
|
+
for (let index = 0; index < Number(remaining); index++) ranked[index].value += 1n;
|
|
5336
|
+
return Object.fromEntries(
|
|
5337
|
+
rows.map((row) => [row.key, Number(row.value)])
|
|
5338
|
+
);
|
|
5339
|
+
}
|
|
5340
|
+
function knownTokenCounter(value) {
|
|
5341
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
5342
|
+
}
|
|
5343
|
+
function knownDetailTokenCounter(entry, keys, firstOnly = false) {
|
|
5344
|
+
const details = Array.isArray(entry.inputTokensDetails) ? entry.inputTokensDetails : entry.inputTokensDetails ? [entry.inputTokensDetails] : [];
|
|
5345
|
+
if (details.length === 0) return void 0;
|
|
5346
|
+
let total = 0;
|
|
5347
|
+
for (const detail of details) {
|
|
5348
|
+
const present = keys.filter((key) => detail[key] !== void 0);
|
|
5349
|
+
if (present.length === 0) return void 0;
|
|
5350
|
+
for (const key of firstOnly ? present.slice(0, 1) : present) {
|
|
5351
|
+
if (!knownTokenCounter(detail[key])) return void 0;
|
|
5352
|
+
total += detail[key];
|
|
5353
|
+
}
|
|
5354
|
+
}
|
|
5355
|
+
return knownTokenCounter(total) ? total : void 0;
|
|
5356
|
+
}
|
|
5357
|
+
function nativeClaudeListWriteContext(settings, modelId) {
|
|
5358
|
+
for (const provider of configuredRegistryProviders(settings)) {
|
|
5359
|
+
const model = provider.models.find((candidate) => candidate.id === modelId);
|
|
5360
|
+
if (!model || provider.api !== "anthropic-messages") continue;
|
|
5361
|
+
const result = { declaredTtl: provider.anthropic?.cacheTtl };
|
|
5362
|
+
const upstream = model.upstreamModelId ?? model.id;
|
|
5363
|
+
const overrides = parseModelPricingJson(settings.modelPricingJson);
|
|
5364
|
+
const official = provider.kind === "anthropic-workspace" || provider.kind === "anthropic-organization" || provider.kind === "claude-subscription-workspace" || provider.kind === "claude-subscription-organization" || provider.kind === "api-key" && provider.baseUrl.replace(/\/$/u, "") === "https://api.anthropic.com/v1";
|
|
5365
|
+
const published = reviewedModelListPricing[upstream]?.default;
|
|
5366
|
+
if (!official || !claudeNativeModelProfile(upstream) || !published?.cacheWriteMicrosPerMillionTokens || model.pricing || overrides[modelId] !== void 0 || overrides[upstream] !== void 0)
|
|
5367
|
+
return result;
|
|
5368
|
+
return {
|
|
5369
|
+
...result,
|
|
5370
|
+
publishedRates: {
|
|
5371
|
+
fiveMinute: published.cacheWriteMicrosPerMillionTokens,
|
|
5372
|
+
oneHour: published.inputMicrosPerMillionTokens * 2
|
|
5373
|
+
}
|
|
5374
|
+
};
|
|
5375
|
+
}
|
|
5376
|
+
return void 0;
|
|
5377
|
+
}
|
|
5378
|
+
function allocateLatencyListCostClasses(classes, multiplier, target) {
|
|
5379
|
+
if (!knownTokenCounter(multiplier) || !knownTokenCounter(target) || !Object.values(classes).every(knownTokenCounter))
|
|
5380
|
+
return void 0;
|
|
5381
|
+
const rows = MODEL_LIST_COST_CLASS_KEYS.map((key, index) => {
|
|
5382
|
+
const numerator = BigInt(classes[key]) * BigInt(multiplier);
|
|
5383
|
+
return { key, index, value: Number(numerator / 10000n), remainder: numerator % 10000n };
|
|
5384
|
+
});
|
|
5385
|
+
const remaining = target - rows.reduce((total, row) => total + row.value, 0);
|
|
5386
|
+
if (remaining < 0 || remaining > rows.length) return void 0;
|
|
5387
|
+
const ranked = [...rows].sort(
|
|
5388
|
+
(a, b) => a.remainder === b.remainder ? a.index - b.index : a.remainder > b.remainder ? -1 : 1
|
|
5389
|
+
);
|
|
5390
|
+
for (let index = 0; index < remaining; index++) ranked[index].value += 1;
|
|
5391
|
+
return {
|
|
5392
|
+
classes: Object.fromEntries(
|
|
5393
|
+
rows.map((row) => [row.key, row.value])
|
|
5394
|
+
),
|
|
5395
|
+
approximate: rows.some((row) => row.remainder !== 0n)
|
|
5396
|
+
};
|
|
5397
|
+
}
|
|
5398
|
+
function calculateUsageCostBreakdown(settings, model, usage, schedule, options) {
|
|
3937
5399
|
if (!schedule) {
|
|
3938
5400
|
throw new Error(`Missing model pricing for ${model}`);
|
|
3939
5401
|
}
|
|
@@ -4192,7 +5654,7 @@ async function retryStartupDependency(label, operation, options = {}) {
|
|
|
4192
5654
|
try {
|
|
4193
5655
|
return await operation();
|
|
4194
5656
|
} catch (error) {
|
|
4195
|
-
if (attempt >= attempts) {
|
|
5657
|
+
if (attempt >= attempts || options.shouldRetry?.(error) === false) {
|
|
4196
5658
|
throw error;
|
|
4197
5659
|
}
|
|
4198
5660
|
const delayMs = Math.min(maxDelayMs, initialDelayMs * 2 ** (attempt - 1));
|
|
@@ -4282,7 +5744,7 @@ function parseModelPricingJson(raw) {
|
|
|
4282
5744
|
if (!model.trim()) {
|
|
4283
5745
|
throw new Error("OPENGENI_MODEL_PRICING_JSON contains an empty model name");
|
|
4284
5746
|
}
|
|
4285
|
-
out[model] =
|
|
5747
|
+
out[model] = z3.union([ModelPricingSchema, ModelPricingScheduleSchema]).parse(value);
|
|
4286
5748
|
}
|
|
4287
5749
|
return out;
|
|
4288
5750
|
}
|
|
@@ -4392,9 +5854,9 @@ function parseIntegrationsOauthClientsJson(raw) {
|
|
|
4392
5854
|
}
|
|
4393
5855
|
return out;
|
|
4394
5856
|
}
|
|
4395
|
-
var SocialOAuthClientConfigSchema =
|
|
4396
|
-
clientId:
|
|
4397
|
-
clientSecret:
|
|
5857
|
+
var SocialOAuthClientConfigSchema = z3.object({
|
|
5858
|
+
clientId: z3.string().min(1),
|
|
5859
|
+
clientSecret: z3.string().min(1).optional()
|
|
4398
5860
|
});
|
|
4399
5861
|
var SOCIAL_OAUTH_PROVIDER_IDS = ["x", "reddit"];
|
|
4400
5862
|
function parseSocialOauthClientsJson(raw) {
|
|
@@ -4592,8 +6054,61 @@ function isDigestPinnedModalDesktopImage(settings) {
|
|
|
4592
6054
|
if (settings.modalImageId) return true;
|
|
4593
6055
|
return typeof settings.modalImageRef === "string" && MODAL_DESKTOP_IMAGE_DIGEST_REF.test(settings.modalImageRef);
|
|
4594
6056
|
}
|
|
6057
|
+
function trustedProxyCidrEntries(raw) {
|
|
6058
|
+
const entries = [];
|
|
6059
|
+
for (const entry of raw.split(",")) {
|
|
6060
|
+
const value = entry.trim();
|
|
6061
|
+
if (!value) continue;
|
|
6062
|
+
const slash = value.indexOf("/");
|
|
6063
|
+
const address = slash < 0 ? value : value.slice(0, slash);
|
|
6064
|
+
const version = isIP(address);
|
|
6065
|
+
const family = version === 4 ? "ipv4" : version === 6 ? "ipv6" : null;
|
|
6066
|
+
const maxPrefix = family === "ipv4" ? 32 : 128;
|
|
6067
|
+
const prefixText = slash < 0 ? String(maxPrefix) : value.slice(slash + 1);
|
|
6068
|
+
const prefix = /^\d{1,3}$/u.test(prefixText) ? Number(prefixText) : Number.NaN;
|
|
6069
|
+
if (!family || !Number.isInteger(prefix) || prefix < 0 || prefix > maxPrefix) {
|
|
6070
|
+
throw new Error(
|
|
6071
|
+
`OPENGENI_API_TRUSTED_PROXY_CIDRS entry "${value.slice(0, 64)}" is not an IP address or CIDR range`
|
|
6072
|
+
);
|
|
6073
|
+
}
|
|
6074
|
+
entries.push({ address, prefix, family });
|
|
6075
|
+
}
|
|
6076
|
+
return entries;
|
|
6077
|
+
}
|
|
6078
|
+
function localAllowedOriginEntries(raw) {
|
|
6079
|
+
const origins = [];
|
|
6080
|
+
for (const entry of (raw ?? "").split(",")) {
|
|
6081
|
+
const value = entry.trim();
|
|
6082
|
+
if (!value) continue;
|
|
6083
|
+
let url = null;
|
|
6084
|
+
try {
|
|
6085
|
+
url = new URL(value);
|
|
6086
|
+
} catch {
|
|
6087
|
+
url = null;
|
|
6088
|
+
}
|
|
6089
|
+
if (!url || url.protocol !== "http:" && url.protocol !== "https:" || url.username || url.password || url.hostname.includes("*") || url.pathname !== "/" || url.search || url.hash || value.endsWith("?") || value.endsWith("#")) {
|
|
6090
|
+
throw new Error(
|
|
6091
|
+
`OPENGENI_LOCAL_ALLOWED_ORIGINS entry "${value.slice(0, 64)}" is not an exact http(s) origin such as http://127.0.0.1:5173`
|
|
6092
|
+
);
|
|
6093
|
+
}
|
|
6094
|
+
origins.push(url.origin);
|
|
6095
|
+
}
|
|
6096
|
+
return origins;
|
|
6097
|
+
}
|
|
6098
|
+
var LOCAL_SANDBOX_API_ROUTES = [
|
|
6099
|
+
// Codemode calls, journal reads, catalog, and the Site/SDK proxy.
|
|
6100
|
+
/^\/v1\/workspaces\/[^/]+\/codemode(?:\/|$)/u,
|
|
6101
|
+
// First-party MCP, including its /docs and /files servers.
|
|
6102
|
+
/^\/v1\/workspaces\/[^/]+\/mcp(?:\/|$)/u,
|
|
6103
|
+
// The personal GitHub HTTPS smart-Git broker.
|
|
6104
|
+
/^\/v1\/git\/personal\/[A-Za-z0-9_-]{43}\/(?:info\/refs|git-upload-pack|git-receive-pack)$/u
|
|
6105
|
+
];
|
|
6106
|
+
function localSandboxApiRouteAllowed(pathname) {
|
|
6107
|
+
return LOCAL_SANDBOX_API_ROUTES.some((route) => route.test(pathname));
|
|
6108
|
+
}
|
|
4595
6109
|
function validateSettings(settings, source = process.env) {
|
|
4596
6110
|
temporalConnectionOptions(settings);
|
|
6111
|
+
localAllowedOriginEntries(settings.localAllowedOrigins);
|
|
4597
6112
|
if (settings.organizationUserSetupEmailTokenTransport === "query" && !settings.organizationUserSetupQueryEdgeSanitizationConfirmed) {
|
|
4598
6113
|
throw new Error(
|
|
4599
6114
|
"OPENGENI_ORGANIZATION_USER_SETUP_QUERY_EDGE_SANITIZATION_CONFIRMED=true is required when OPENGENI_ORGANIZATION_USER_SETUP_EMAIL_TOKEN_TRANSPORT=query"
|
|
@@ -4676,6 +6191,18 @@ function validateSettings(settings, source = process.env) {
|
|
|
4676
6191
|
);
|
|
4677
6192
|
}
|
|
4678
6193
|
}
|
|
6194
|
+
const retiredTrustedProxyHops = source.OPENGENI_MCP_OAUTH_TRUSTED_PROXY_HOPS?.trim();
|
|
6195
|
+
if (retiredTrustedProxyHops && retiredTrustedProxyHops !== "0") {
|
|
6196
|
+
throw new Error(
|
|
6197
|
+
"OPENGENI_MCP_OAUTH_TRUSTED_PROXY_HOPS was renamed to OPENGENI_API_TRUSTED_PROXY_HOPS, which now sets the client address for every API rate limit and auth session; rename the variable"
|
|
6198
|
+
);
|
|
6199
|
+
}
|
|
6200
|
+
const trustedProxyCidrs = trustedProxyCidrEntries(settings.apiTrustedProxyCidrs);
|
|
6201
|
+
if (trustedProxyCidrs.length > 0 && settings.apiTrustedProxyHops === 0) {
|
|
6202
|
+
throw new Error(
|
|
6203
|
+
"OPENGENI_API_TRUSTED_PROXY_CIDRS requires OPENGENI_API_TRUSTED_PROXY_HOPS greater than 0"
|
|
6204
|
+
);
|
|
6205
|
+
}
|
|
4679
6206
|
if (settings.mcpOauthEnabled) {
|
|
4680
6207
|
if (settings.productAccessMode === "configured") {
|
|
4681
6208
|
throw new Error(
|
|
@@ -4936,60 +6463,7 @@ function validateSettings(settings, source = process.env) {
|
|
|
4936
6463
|
);
|
|
4937
6464
|
}
|
|
4938
6465
|
}
|
|
4939
|
-
|
|
4940
|
-
if (Boolean(settings.objectStorageAccessKeyId) !== Boolean(settings.objectStorageSecretAccessKey)) {
|
|
4941
|
-
throw new Error(
|
|
4942
|
-
"OPENGENI_OBJECT_STORAGE_ACCESS_KEY_ID and OPENGENI_OBJECT_STORAGE_SECRET_ACCESS_KEY must both be set or both omitted"
|
|
4943
|
-
);
|
|
4944
|
-
}
|
|
4945
|
-
if (settings.objectStorageBackend === "s3-compatible" && (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint) && (!settings.objectStorageAccessKeyId || !settings.objectStorageSecretAccessKey)) {
|
|
4946
|
-
throw new Error(
|
|
4947
|
-
"S3-compatible object storage endpoints require OPENGENI_OBJECT_STORAGE_ACCESS_KEY_ID and OPENGENI_OBJECT_STORAGE_SECRET_ACCESS_KEY"
|
|
4948
|
-
);
|
|
4949
|
-
}
|
|
4950
|
-
if (settings.objectStorageAzureConnectionString || settings.objectStorageAzureAccountName || settings.objectStorageAzureAccountKey || settings.objectStorageAzureEndpoint) {
|
|
4951
|
-
throw new Error(
|
|
4952
|
-
"S3 object storage uses OPENGENI_OBJECT_STORAGE_* S3 settings, not OPENGENI_OBJECT_STORAGE_AZURE_* settings"
|
|
4953
|
-
);
|
|
4954
|
-
}
|
|
4955
|
-
if (settings.objectStorageGcsProjectId || settings.objectStorageGcsCredentialsJson || settings.objectStorageGcsKeyFilename || settings.objectStorageGcsApiEndpoint) {
|
|
4956
|
-
throw new Error(
|
|
4957
|
-
"S3 object storage uses OPENGENI_OBJECT_STORAGE_* S3 settings, not OPENGENI_OBJECT_STORAGE_GCS_* settings"
|
|
4958
|
-
);
|
|
4959
|
-
}
|
|
4960
|
-
} else if (settings.objectStorageBackend === "azure-blob") {
|
|
4961
|
-
if (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint || settings.objectStorageAccessKeyId || settings.objectStorageSecretAccessKey) {
|
|
4962
|
-
throw new Error(
|
|
4963
|
-
"Azure Blob storage uses OPENGENI_OBJECT_STORAGE_AZURE_* settings, not S3-compatible object storage settings"
|
|
4964
|
-
);
|
|
4965
|
-
}
|
|
4966
|
-
if (settings.objectStorageGcsProjectId || settings.objectStorageGcsCredentialsJson || settings.objectStorageGcsKeyFilename || settings.objectStorageGcsApiEndpoint) {
|
|
4967
|
-
throw new Error(
|
|
4968
|
-
"Azure Blob storage uses OPENGENI_OBJECT_STORAGE_AZURE_* settings, not OPENGENI_OBJECT_STORAGE_GCS_* settings"
|
|
4969
|
-
);
|
|
4970
|
-
}
|
|
4971
|
-
const hasConnectionString = Boolean(settings.objectStorageAzureConnectionString);
|
|
4972
|
-
const hasSharedKey = Boolean(settings.objectStorageAzureAccountName) && Boolean(settings.objectStorageAzureAccountKey);
|
|
4973
|
-
if (!hasConnectionString && !hasSharedKey) {
|
|
4974
|
-
throw new Error(
|
|
4975
|
-
"Azure Blob storage requires OPENGENI_OBJECT_STORAGE_AZURE_CONNECTION_STRING or OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_NAME plus OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_KEY"
|
|
4976
|
-
);
|
|
4977
|
-
}
|
|
4978
|
-
} else {
|
|
4979
|
-
if (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint || settings.objectStorageAccessKeyId || settings.objectStorageSecretAccessKey) {
|
|
4980
|
-
throw new Error(
|
|
4981
|
-
"GCS object storage uses OPENGENI_OBJECT_STORAGE_GCS_* settings, not S3-compatible object storage settings"
|
|
4982
|
-
);
|
|
4983
|
-
}
|
|
4984
|
-
if (settings.objectStorageAzureConnectionString || settings.objectStorageAzureAccountName || settings.objectStorageAzureAccountKey || settings.objectStorageAzureEndpoint) {
|
|
4985
|
-
throw new Error(
|
|
4986
|
-
"GCS object storage uses OPENGENI_OBJECT_STORAGE_GCS_* settings, not OPENGENI_OBJECT_STORAGE_AZURE_* settings"
|
|
4987
|
-
);
|
|
4988
|
-
}
|
|
4989
|
-
if (settings.objectStorageGcsCredentialsJson) {
|
|
4990
|
-
parseGcsCredentialsJson(settings.objectStorageGcsCredentialsJson);
|
|
4991
|
-
}
|
|
4992
|
-
}
|
|
6466
|
+
validateObjectStorageSettings(settings);
|
|
4993
6467
|
if (settings.documentChunkOverlap >= settings.documentChunkSize) {
|
|
4994
6468
|
throw new Error(
|
|
4995
6469
|
"OPENGENI_DOCUMENT_CHUNK_OVERLAP must be smaller than OPENGENI_DOCUMENT_CHUNK_SIZE"
|
|
@@ -4998,7 +6472,22 @@ function validateSettings(settings, source = process.env) {
|
|
|
4998
6472
|
parseExposedPorts(settings.dockerExposedPorts);
|
|
4999
6473
|
sandboxEnvironmentVariableNames(settings);
|
|
5000
6474
|
sandboxLifecycleHookIds(settings);
|
|
5001
|
-
parseSandboxWarmRateJson(settings.sandboxWarmRateMicrosPerSecondJson);
|
|
6475
|
+
const warmRates = parseSandboxWarmRateJson(settings.sandboxWarmRateMicrosPerSecondJson);
|
|
6476
|
+
if (settings.sandboxWarmBillingMode === "credits" && Object.values(warmRates).some((rate) => !Number.isSafeInteger(rate))) {
|
|
6477
|
+
throw new Error(
|
|
6478
|
+
"OPENGENI_SANDBOX_WARM_RATE_MICROS_PER_SECOND_JSON paid rates must be safe integers"
|
|
6479
|
+
);
|
|
6480
|
+
}
|
|
6481
|
+
if (settings.documentEmbeddingBillingMode === "credits" && settings.documentEmbeddingProvider === "openai" && settings.documentEmbeddingRateMicrosPerMillionBytes <= 0) {
|
|
6482
|
+
throw new Error(
|
|
6483
|
+
"OPENGENI_DOCUMENT_EMBEDDING_RATE_MICROS_PER_MILLION_BYTES must be positive when paid OpenAI embedding billing is enabled"
|
|
6484
|
+
);
|
|
6485
|
+
}
|
|
6486
|
+
if (settings.documentEmbeddingBillingMode === "credits" && settings.documentEmbeddingProvider === "openai" && !settings.documentEmbeddingCreditsActivatedAt) {
|
|
6487
|
+
throw new Error(
|
|
6488
|
+
"OPENGENI_DOCUMENT_EMBEDDING_CREDITS_ACTIVATED_AT is required for paid OpenAI embeddings"
|
|
6489
|
+
);
|
|
6490
|
+
}
|
|
5002
6491
|
if (settings.sandboxBackend === "opensandbox") {
|
|
5003
6492
|
if (!/@sha256:[0-9a-f]{64}$/i.test(settings.openSandboxImage ?? "")) {
|
|
5004
6493
|
throw new Error(
|
|
@@ -5017,9 +6506,9 @@ function validateSettings(settings, source = process.env) {
|
|
|
5017
6506
|
throw new Error(`OPENGENI_MCP_SERVERS contains duplicate id ${server.id}`);
|
|
5018
6507
|
}
|
|
5019
6508
|
serverIds.add(server.id);
|
|
5020
|
-
if (server.connectionRef?.authoritySource === "host"
|
|
6509
|
+
if (server.connectionRef?.authoritySource === "host") {
|
|
5021
6510
|
throw new Error(
|
|
5022
|
-
"OPENGENI_MCP_SERVERS host-owned connection refs
|
|
6511
|
+
"OPENGENI_MCP_SERVERS host-owned connection refs are no longer supported; select ordinary native connections"
|
|
5023
6512
|
);
|
|
5024
6513
|
}
|
|
5025
6514
|
}
|
|
@@ -5057,9 +6546,21 @@ function validateSettings(settings, source = process.env) {
|
|
|
5057
6546
|
ordinaryCaptureTimeoutMs,
|
|
5058
6547
|
drainCaptureTimeoutMs
|
|
5059
6548
|
);
|
|
5060
|
-
|
|
6549
|
+
const requiredRotationLeadMs = SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS + providerDeadlineCaptureTimeoutMs + 2 * reaperPeriod;
|
|
6550
|
+
if (!(rotationLeadMs > requiredRotationLeadMs)) {
|
|
6551
|
+
throw new Error(
|
|
6552
|
+
`OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}) must exceed the legacy command stop grace, largest durable snapshot or drain capture timeout, and two reaper periods (${requiredRotationLeadMs}), including for persisted Modal leases after a default-backend rollout.`
|
|
6553
|
+
);
|
|
6554
|
+
}
|
|
6555
|
+
const containmentMs = settings.sandboxIdleCommandContainmentMs;
|
|
6556
|
+
if (containmentMs !== void 0 && !(containmentMs > settings.sandboxIdleGraceMs)) {
|
|
6557
|
+
throw new Error(
|
|
6558
|
+
`OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS (${containmentMs}) must exceed OPENGENI_SANDBOX_IDLE_GRACE_MS (${settings.sandboxIdleGraceMs}): a box kept warm only by retained commands must stay available at least as long as an idle box awaiting drain.`
|
|
6559
|
+
);
|
|
6560
|
+
}
|
|
6561
|
+
if (containmentMs !== void 0 && optionalEnvironmentValue("OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS", source) !== void 0 && !(containmentMs < rotationLeadMs)) {
|
|
5061
6562
|
throw new Error(
|
|
5062
|
-
`
|
|
6563
|
+
`OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS (${containmentMs}) must be strictly less than OPENGENI_SANDBOX_ROTATION_LEAD_MS (${rotationLeadMs}): an idle box must be checkpointed and stopped well before its provider deadline.`
|
|
5063
6564
|
);
|
|
5064
6565
|
}
|
|
5065
6566
|
if (settings.sandboxBackend === "modal") {
|
|
@@ -5092,6 +6593,11 @@ function validateSettings(settings, source = process.env) {
|
|
|
5092
6593
|
`OPENGENI_SANDBOX_LEASE_REAPER_PERIOD_MS + OPENGENI_SANDBOX_IDLE_GRACE_MS (${reaperPeriod} + ${idleGraceMs} = ${reaperPeriod + idleGraceMs}) must be strictly less than the effective box idle timeout (${idleTimeoutMs}): a drained box must SURVIVE its full warm window so the reaper can resume + snapshot /workspace + terminate it on the sweep AFTER the drain grace elapses \u2014 Modal's idle-reap must NOT fire first (or /workspace is lost). Raise OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS (defaults to OPENGENI_MODAL_TIMEOUT_SECONDS) or lower OPENGENI_SANDBOX_IDLE_GRACE_MS.`
|
|
5093
6594
|
);
|
|
5094
6595
|
}
|
|
6596
|
+
if (settings.modalIdleTimeoutSeconds !== void 0 && containmentMs !== void 0 && !(reaperPeriod + containmentMs + drainCaptureTimeoutMs < idleTimeoutMs)) {
|
|
6597
|
+
throw new Error(
|
|
6598
|
+
`OPENGENI_SANDBOX_LEASE_REAPER_PERIOD_MS + OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS + drain capture timeout (${reaperPeriod} + ${containmentMs} + ${drainCaptureTimeoutMs}) must be strictly less than OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS*1000 (${idleTimeoutMs}): idle command containment must checkpoint a box before Modal's own idle reaper stops it. Lower OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS or raise the Modal idle timeout.`
|
|
6599
|
+
);
|
|
6600
|
+
}
|
|
5095
6601
|
}
|
|
5096
6602
|
}
|
|
5097
6603
|
if (settings.sandboxDesktopEnabled && settings.sandboxBackend === "modal" && !["local", "test"].includes(settings.environment)) {
|
|
@@ -5119,7 +6625,7 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
5119
6625
|
const builtinId = builtinProviderId(settings);
|
|
5120
6626
|
const providerIds = /* @__PURE__ */ new Set();
|
|
5121
6627
|
for (const provider of registryProviders) {
|
|
5122
|
-
if (provider.kind === "vercel-gateway-managed" || provider.kind === "vercel-gateway-workspace" || provider.kind === "vercel-gateway-organization" || provider.kind === "openrouter-workspace" || provider.kind === "openrouter-organization" || provider.kind === "xai-subscription") {
|
|
6628
|
+
if (provider.kind === "vercel-gateway-managed" || provider.kind === "vercel-gateway-workspace" || provider.kind === "vercel-gateway-organization" || provider.kind === "direct-openai-workspace" || provider.kind === "direct-azure-workspace" || provider.kind === "openrouter-workspace" || provider.kind === "openrouter-organization" || provider.kind === "anthropic-organization" || provider.kind === "anthropic-workspace" || provider.kind === "claude-subscription-workspace" || provider.kind === "claude-subscription-organization" || provider.kind === "xai-subscription") {
|
|
5123
6629
|
throw new Error(
|
|
5124
6630
|
`OPENGENI_MODEL_PROVIDERS_JSON provider kind ${provider.kind} is reserved for a reviewed OpenGeni credential broker`
|
|
5125
6631
|
);
|
|
@@ -5148,6 +6654,19 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
5148
6654
|
}
|
|
5149
6655
|
const models = configuredModels(settings, source);
|
|
5150
6656
|
const defaultCatalogSettings = settingsForTurnExecutionPolicy(settings, settings.openaiModel);
|
|
6657
|
+
const policy = settings.creditPromotionPolicy;
|
|
6658
|
+
const promotionalModelIds = /* @__PURE__ */ new Set([
|
|
6659
|
+
...policy.defaultModelIds ?? [],
|
|
6660
|
+
...policy.signupModelIds ?? [],
|
|
6661
|
+
...Object.values(policy.offers).flatMap((offer) => offer.eligibleModelIds ?? [])
|
|
6662
|
+
]);
|
|
6663
|
+
for (const modelId of promotionalModelIds) {
|
|
6664
|
+
if (!models.some((model) => model.id === modelId && model.cost === "credits")) {
|
|
6665
|
+
throw new Error(
|
|
6666
|
+
`Promotional credit model ${modelId} must be a canonical credits-billed model in the catalog`
|
|
6667
|
+
);
|
|
6668
|
+
}
|
|
6669
|
+
}
|
|
5151
6670
|
const defaultCatalogModels = defaultCatalogSettings === settings ? models : configuredModels(defaultCatalogSettings, source);
|
|
5152
6671
|
if (models.length === 0 && defaultCatalogModels.length === 0) {
|
|
5153
6672
|
throw new Error("The resolved model catalog contains no executable models");
|
|
@@ -5161,10 +6680,25 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
5161
6680
|
`The default model ${settings.openaiModel} is not executable in the resolved model catalog`
|
|
5162
6681
|
);
|
|
5163
6682
|
}
|
|
6683
|
+
const explicitCreditsDefault = source.OPENGENI_CREDITS_DEFAULT_MODEL?.trim();
|
|
6684
|
+
if (explicitCreditsDefault && settings.modelCatalogSource === "code" && settings.billingMode === "stripe") {
|
|
6685
|
+
const creditsDefaultId = canonicalizeConfiguredModelId(settings, settings.creditsDefaultModel);
|
|
6686
|
+
const creditsDefault = models.find((model) => model.id === creditsDefaultId);
|
|
6687
|
+
if (creditsDefault?.cost !== "credits") {
|
|
6688
|
+
throw new Error(
|
|
6689
|
+
`OPENGENI_CREDITS_DEFAULT_MODEL ${settings.creditsDefaultModel} is not a credits-billed model in the resolved model catalog`
|
|
6690
|
+
);
|
|
6691
|
+
}
|
|
6692
|
+
}
|
|
5164
6693
|
const deploymentProductIds = new Set(
|
|
5165
6694
|
models.filter((model) => model.credentialSource.kind === "deployment").map((model) => model.id)
|
|
5166
6695
|
);
|
|
5167
6696
|
const noteProductIds = new Set(models.map((model) => model.id));
|
|
6697
|
+
if (settings.resolvedCodexModelsJson !== void 0) {
|
|
6698
|
+
for (const model of z3.array(CodexCatalogModelSchema).parse(JSON.parse(settings.resolvedCodexModelsJson))) {
|
|
6699
|
+
noteProductIds.add(model.id);
|
|
6700
|
+
}
|
|
6701
|
+
}
|
|
5168
6702
|
for (const model of configuredGatewayCatalogModels(settings)) {
|
|
5169
6703
|
deploymentProductIds.add(model.productId);
|
|
5170
6704
|
noteProductIds.add(model.productId);
|
|
@@ -5242,6 +6776,62 @@ function resolveNatsCalloutConfig(settings) {
|
|
|
5242
6776
|
}
|
|
5243
6777
|
return { accountSeed, accountName, user, password };
|
|
5244
6778
|
}
|
|
6779
|
+
function validateObjectStorageSettings(settings) {
|
|
6780
|
+
if (settings.objectStorageBackend === "s3-compatible" || settings.objectStorageBackend === "aws-s3") {
|
|
6781
|
+
if (Boolean(settings.objectStorageAccessKeyId) !== Boolean(settings.objectStorageSecretAccessKey)) {
|
|
6782
|
+
throw new Error(
|
|
6783
|
+
"OPENGENI_OBJECT_STORAGE_ACCESS_KEY_ID and OPENGENI_OBJECT_STORAGE_SECRET_ACCESS_KEY must both be set or both omitted"
|
|
6784
|
+
);
|
|
6785
|
+
}
|
|
6786
|
+
if (settings.objectStorageBackend === "s3-compatible" && (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint) && (!settings.objectStorageAccessKeyId || !settings.objectStorageSecretAccessKey)) {
|
|
6787
|
+
throw new Error(
|
|
6788
|
+
"S3-compatible object storage endpoints require OPENGENI_OBJECT_STORAGE_ACCESS_KEY_ID and OPENGENI_OBJECT_STORAGE_SECRET_ACCESS_KEY"
|
|
6789
|
+
);
|
|
6790
|
+
}
|
|
6791
|
+
if (settings.objectStorageAzureConnectionString || settings.objectStorageAzureAccountName || settings.objectStorageAzureAccountKey || settings.objectStorageAzureEndpoint) {
|
|
6792
|
+
throw new Error(
|
|
6793
|
+
"S3 object storage uses OPENGENI_OBJECT_STORAGE_* S3 settings, not OPENGENI_OBJECT_STORAGE_AZURE_* settings"
|
|
6794
|
+
);
|
|
6795
|
+
}
|
|
6796
|
+
if (settings.objectStorageGcsProjectId || settings.objectStorageGcsCredentialsJson || settings.objectStorageGcsKeyFilename || settings.objectStorageGcsApiEndpoint) {
|
|
6797
|
+
throw new Error(
|
|
6798
|
+
"S3 object storage uses OPENGENI_OBJECT_STORAGE_* S3 settings, not OPENGENI_OBJECT_STORAGE_GCS_* settings"
|
|
6799
|
+
);
|
|
6800
|
+
}
|
|
6801
|
+
} else if (settings.objectStorageBackend === "azure-blob") {
|
|
6802
|
+
if (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint || settings.objectStorageAccessKeyId || settings.objectStorageSecretAccessKey) {
|
|
6803
|
+
throw new Error(
|
|
6804
|
+
"Azure Blob storage uses OPENGENI_OBJECT_STORAGE_AZURE_* settings, not S3-compatible object storage settings"
|
|
6805
|
+
);
|
|
6806
|
+
}
|
|
6807
|
+
if (settings.objectStorageGcsProjectId || settings.objectStorageGcsCredentialsJson || settings.objectStorageGcsKeyFilename || settings.objectStorageGcsApiEndpoint) {
|
|
6808
|
+
throw new Error(
|
|
6809
|
+
"Azure Blob storage uses OPENGENI_OBJECT_STORAGE_AZURE_* settings, not OPENGENI_OBJECT_STORAGE_GCS_* settings"
|
|
6810
|
+
);
|
|
6811
|
+
}
|
|
6812
|
+
const hasConnectionString = Boolean(settings.objectStorageAzureConnectionString);
|
|
6813
|
+
const hasSharedKey = Boolean(settings.objectStorageAzureAccountName) && Boolean(settings.objectStorageAzureAccountKey);
|
|
6814
|
+
if (!hasConnectionString && !hasSharedKey) {
|
|
6815
|
+
throw new Error(
|
|
6816
|
+
"Azure Blob storage requires OPENGENI_OBJECT_STORAGE_AZURE_CONNECTION_STRING or OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_NAME plus OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_KEY"
|
|
6817
|
+
);
|
|
6818
|
+
}
|
|
6819
|
+
} else {
|
|
6820
|
+
if (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint || settings.objectStorageAccessKeyId || settings.objectStorageSecretAccessKey) {
|
|
6821
|
+
throw new Error(
|
|
6822
|
+
"GCS object storage uses OPENGENI_OBJECT_STORAGE_GCS_* settings, not S3-compatible object storage settings"
|
|
6823
|
+
);
|
|
6824
|
+
}
|
|
6825
|
+
if (settings.objectStorageAzureConnectionString || settings.objectStorageAzureAccountName || settings.objectStorageAzureAccountKey || settings.objectStorageAzureEndpoint) {
|
|
6826
|
+
throw new Error(
|
|
6827
|
+
"GCS object storage uses OPENGENI_OBJECT_STORAGE_GCS_* settings, not OPENGENI_OBJECT_STORAGE_AZURE_* settings"
|
|
6828
|
+
);
|
|
6829
|
+
}
|
|
6830
|
+
if (settings.objectStorageGcsCredentialsJson) {
|
|
6831
|
+
parseGcsCredentialsJson(settings.objectStorageGcsCredentialsJson);
|
|
6832
|
+
}
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
5245
6835
|
function resolveNatsControlPlaneAuth(settings) {
|
|
5246
6836
|
const user = settings.selfhostedNatsControlUser?.trim();
|
|
5247
6837
|
const password = settings.selfhostedNatsControlPassword?.trim();
|
|
@@ -5253,6 +6843,9 @@ function resolveNatsControlPlaneAuth(settings) {
|
|
|
5253
6843
|
function splitCsv(raw) {
|
|
5254
6844
|
return raw.split(",").map((value) => value.trim()).filter(Boolean);
|
|
5255
6845
|
}
|
|
6846
|
+
function sandboxImageAllowlist(settings) {
|
|
6847
|
+
return [...new Set(splitCsv(settings.sandboxImageAllowlist ?? ""))];
|
|
6848
|
+
}
|
|
5256
6849
|
function uniqueEnvNames(raw, fieldName) {
|
|
5257
6850
|
const seen = /* @__PURE__ */ new Set();
|
|
5258
6851
|
const out = [];
|
|
@@ -5283,13 +6876,155 @@ function parseGcsCredentialsJson(raw) {
|
|
|
5283
6876
|
function delay(ms) {
|
|
5284
6877
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5285
6878
|
}
|
|
6879
|
+
var CLAUDE_CONNECTION_KINDS = ["anthropic", "claude_subscription"];
|
|
6880
|
+
var CLAUDE_NATIVE_MODEL_PROFILES = Object.fromEntries([
|
|
6881
|
+
...[
|
|
6882
|
+
["claude-opus-5-5", "medium"],
|
|
6883
|
+
["claude-sonnet-5-5", "medium"],
|
|
6884
|
+
["claude-opus-5", "high"],
|
|
6885
|
+
["claude-sonnet-5", "high"],
|
|
6886
|
+
["claude-opus-4-8", "high"],
|
|
6887
|
+
["claude-opus-4-7", "xhigh"]
|
|
6888
|
+
].map(([id, defaultEffort]) => [
|
|
6889
|
+
id,
|
|
6890
|
+
{
|
|
6891
|
+
efforts: ["low", "medium", "high", "xhigh", "max"],
|
|
6892
|
+
defaultEffort,
|
|
6893
|
+
contextWindowTokens: 1e6,
|
|
6894
|
+
maxOutputTokens: 128e3
|
|
6895
|
+
}
|
|
6896
|
+
]),
|
|
6897
|
+
...["claude-opus-4-6", "claude-sonnet-4-6"].map((id) => [
|
|
6898
|
+
id,
|
|
6899
|
+
{
|
|
6900
|
+
efforts: ["low", "medium", "high", "max"],
|
|
6901
|
+
defaultEffort: "high",
|
|
6902
|
+
contextWindowTokens: 1e6,
|
|
6903
|
+
maxOutputTokens: 128e3
|
|
6904
|
+
}
|
|
6905
|
+
]),
|
|
6906
|
+
[
|
|
6907
|
+
"claude-haiku-4-5-20251001",
|
|
6908
|
+
{
|
|
6909
|
+
efforts: [],
|
|
6910
|
+
defaultEffort: null,
|
|
6911
|
+
contextWindowTokens: 2e5,
|
|
6912
|
+
maxOutputTokens: 64e3
|
|
6913
|
+
}
|
|
6914
|
+
]
|
|
6915
|
+
]);
|
|
6916
|
+
function claudeNativeModelProfile(upstreamModelId) {
|
|
6917
|
+
return Object.hasOwn(CLAUDE_NATIVE_MODEL_PROFILES, upstreamModelId) ? CLAUDE_NATIVE_MODEL_PROFILES[upstreamModelId] : void 0;
|
|
6918
|
+
}
|
|
6919
|
+
function claudeProviderId(kind, scope = "organization") {
|
|
6920
|
+
return `${scope}-${kind === "anthropic" ? "anthropic" : "claude-subscription"}`;
|
|
6921
|
+
}
|
|
6922
|
+
function withClaudeConnectionCatalog(settings, connections, scope = "organization") {
|
|
6923
|
+
let providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
6924
|
+
for (const kind of CLAUDE_CONNECTION_KINDS) {
|
|
6925
|
+
if (kind === "claude_subscription" && !settings.claudeSubscriptionEnabled) {
|
|
6926
|
+
providers = providers.filter((provider) => provider.id !== claudeProviderId(kind, scope));
|
|
6927
|
+
continue;
|
|
6928
|
+
}
|
|
6929
|
+
const connection = connections[kind];
|
|
6930
|
+
if (!connection) continue;
|
|
6931
|
+
const id = claudeProviderId(kind, scope);
|
|
6932
|
+
providers = providers.filter((provider) => provider.id !== id);
|
|
6933
|
+
if (!connection.models.length) continue;
|
|
6934
|
+
providers.push({
|
|
6935
|
+
id,
|
|
6936
|
+
label: kind === "anthropic" ? "Anthropic API" : "Claude subscription",
|
|
6937
|
+
kind: kind === "anthropic" ? `anthropic-${scope}` : `claude-subscription-${scope}`,
|
|
6938
|
+
api: "anthropic-messages",
|
|
6939
|
+
wireProfile: "openai",
|
|
6940
|
+
baseUrl: "https://api.anthropic.com/v1",
|
|
6941
|
+
anthropic: {
|
|
6942
|
+
auth: kind === "anthropic" ? "api-key" : "oauth",
|
|
6943
|
+
cacheTtl: "5m",
|
|
6944
|
+
maxOutputTokens: 128e3,
|
|
6945
|
+
streamIdleTimeoutMs: 6e5
|
|
6946
|
+
},
|
|
6947
|
+
models: connection.models.map((model) => {
|
|
6948
|
+
const profile = claudeNativeModelProfile(model.upstreamModelId);
|
|
6949
|
+
const adaptiveThinking = Boolean(profile?.efforts.length);
|
|
6950
|
+
const contextWindowTokens = profile?.contextWindowTokens ?? 2e5;
|
|
6951
|
+
const outputReserve = profile?.maxOutputTokens ?? 32e3;
|
|
6952
|
+
return {
|
|
6953
|
+
contextWindowTokens,
|
|
6954
|
+
effectiveContextWindowTokens: contextWindowTokens - outputReserve,
|
|
6955
|
+
autoCompactTokenLimit: contextWindowTokens === 1e6 ? 8e5 : Math.min(15e4, contextWindowTokens - outputReserve - 18e3),
|
|
6956
|
+
id: id + "/" + model.upstreamModelId,
|
|
6957
|
+
upstreamModelId: model.upstreamModelId,
|
|
6958
|
+
label: model.label ?? (model.upstreamModelId === "claude-opus-5-5" ? "Claude Opus 5.5" : model.upstreamModelId === "claude-sonnet-5-5" ? "Claude Sonnet 5.5" : model.upstreamModelId),
|
|
6959
|
+
reasoningEffort: adaptiveThinking,
|
|
6960
|
+
hostedWebSearch: false,
|
|
6961
|
+
capabilities: {
|
|
6962
|
+
...legacyModelCapabilities(settings, {
|
|
6963
|
+
reasoningEffort: adaptiveThinking,
|
|
6964
|
+
hostedWebSearch: false,
|
|
6965
|
+
vision: true
|
|
6966
|
+
}),
|
|
6967
|
+
inputFileMediaTypes: [],
|
|
6968
|
+
reasoning: {
|
|
6969
|
+
upstream: adaptiveThinking ? "supported" : "unknown",
|
|
6970
|
+
runnable: adaptiveThinking,
|
|
6971
|
+
efforts: [...profile?.efforts ?? []],
|
|
6972
|
+
defaultEffort: profile?.defaultEffort ?? null,
|
|
6973
|
+
required: false
|
|
6974
|
+
},
|
|
6975
|
+
functionCalling: { upstream: "supported", runnable: true },
|
|
6976
|
+
promptCaching: { upstream: "supported", runnable: true, mode: "automatic" }
|
|
6977
|
+
}
|
|
6978
|
+
};
|
|
6979
|
+
})
|
|
6980
|
+
});
|
|
6981
|
+
}
|
|
6982
|
+
return { ...settings, modelProvidersJson: JSON.stringify(providers) };
|
|
6983
|
+
}
|
|
6984
|
+
function withClaudeConnectionCredential(settings, kind, credential, scope = "organization", credentialBinding) {
|
|
6985
|
+
if (kind === "claude_subscription" && !settings.claudeSubscriptionEnabled)
|
|
6986
|
+
throw new Error("Claude subscriptions are not enabled on this deployment");
|
|
6987
|
+
if (!credential.trim()) throw new Error("Claude credential is empty");
|
|
6988
|
+
const bundle = kind === "claude_subscription" && credential.trim().startsWith("{") ? ClaudeSubscriptionCredential.parse(JSON.parse(credential)) : null;
|
|
6989
|
+
return {
|
|
6990
|
+
...settings,
|
|
6991
|
+
modelProvidersJson: JSON.stringify(
|
|
6992
|
+
parseModelProvidersJson(settings.modelProvidersJson).map(
|
|
6993
|
+
(provider) => provider.id === claudeProviderId(kind, scope) ? {
|
|
6994
|
+
...provider,
|
|
6995
|
+
apiKey: bundle?.token ?? credential,
|
|
6996
|
+
...kind === "claude_subscription" && provider.anthropic ? {
|
|
6997
|
+
anthropic: {
|
|
6998
|
+
...provider.anthropic,
|
|
6999
|
+
identity: bundle?.identity,
|
|
7000
|
+
credentialBinding: credentialBinding ? {
|
|
7001
|
+
connectionId: credentialBinding.connectionId,
|
|
7002
|
+
credentialVersion: credentialBinding.credentialVersion
|
|
7003
|
+
} : void 0
|
|
7004
|
+
}
|
|
7005
|
+
} : {}
|
|
7006
|
+
} : provider
|
|
7007
|
+
)
|
|
7008
|
+
)
|
|
7009
|
+
};
|
|
7010
|
+
}
|
|
5286
7011
|
export {
|
|
5287
7012
|
AGENT_INSTRUCTIONS_CORE_PLACEHOLDER,
|
|
5288
7013
|
AI_GATEWAY_REALTIME_MODELS,
|
|
7014
|
+
CLAUDE_CONNECTION_KINDS,
|
|
7015
|
+
CLAUDE_OAUTH_AUTHORIZE_URL,
|
|
7016
|
+
CLAUDE_OAUTH_CLIENT_ID,
|
|
7017
|
+
CLAUDE_OAUTH_REDIRECT_URL,
|
|
7018
|
+
CLAUDE_OAUTH_SCOPES,
|
|
7019
|
+
CLAUDE_OAUTH_TOKEN_URL,
|
|
5289
7020
|
CODEX_REALTIME_MODEL_ID,
|
|
5290
7021
|
CapabilityStateV1Schema,
|
|
5291
7022
|
CapabilitySupportV1,
|
|
7023
|
+
ClaudeOAuthTokenResponse,
|
|
7024
|
+
ClaudeSubscriptionCredential,
|
|
7025
|
+
ClaudeSubscriptionIdentity,
|
|
5292
7026
|
ConfiguredModelCostClass,
|
|
7027
|
+
CreditPromotionPolicy,
|
|
5293
7028
|
DEFAULT_AGENT_INSTRUCTIONS,
|
|
5294
7029
|
DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS,
|
|
5295
7030
|
DEFAULT_GOAL_IDLE_BACKOFF_MS,
|
|
@@ -5322,12 +7057,16 @@ export {
|
|
|
5322
7057
|
RegistryProviderKind,
|
|
5323
7058
|
SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS,
|
|
5324
7059
|
SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS,
|
|
7060
|
+
SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS,
|
|
5325
7061
|
SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS,
|
|
5326
7062
|
SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS,
|
|
5327
7063
|
SANDBOX_REQUIRED_ENV,
|
|
5328
7064
|
SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS,
|
|
5329
7065
|
SUPERGROK_REALTIME_MODEL_ID,
|
|
5330
7066
|
SocialOAuthClientConfigSchema,
|
|
7067
|
+
TurnExecutionPolicyDefinitionMismatchError,
|
|
7068
|
+
TurnExecutionPolicyModelUnavailableError,
|
|
7069
|
+
UnsupportedLatencyModeError,
|
|
5331
7070
|
VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
|
|
5332
7071
|
VERCEL_AI_GATEWAY_BASE_URL,
|
|
5333
7072
|
VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
|
|
@@ -5340,6 +7079,8 @@ export {
|
|
|
5340
7079
|
WORKSPACE_OPENROUTER_PROVIDER_ID,
|
|
5341
7080
|
WORKSPACE_REALTIME_MODEL_ID_PREFIX,
|
|
5342
7081
|
XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 as XAI_SUBSCRIPTION_MODEL_ID_PREFIX,
|
|
7082
|
+
agentConfigDeploymentPolicy,
|
|
7083
|
+
allocateRecordedModelListCostByClass,
|
|
5343
7084
|
allowedFirstPartyMcpToolsForSession,
|
|
5344
7085
|
applyGitAuthPointerEnvironment,
|
|
5345
7086
|
applyModelCatalogDocument,
|
|
@@ -5348,12 +7089,20 @@ export {
|
|
|
5348
7089
|
calculateGatewayReportedCostBreakdown,
|
|
5349
7090
|
calculateGatewayReportedCostMicros,
|
|
5350
7091
|
calculateGatewayReportedProviderCostMicros,
|
|
7092
|
+
calculateModelListUsageCostBreakdown,
|
|
7093
|
+
calculateModelListUsageCostSnapshot,
|
|
5351
7094
|
calculateModelUsageCostBreakdown,
|
|
5352
7095
|
calculateModelUsageCostMicros,
|
|
5353
7096
|
calculateVideoGenerationCreditCostMicros,
|
|
5354
7097
|
canonicalPublicOrigin,
|
|
5355
7098
|
canonicalizeConfiguredModelId,
|
|
7099
|
+
claudeAuthorizationUrl,
|
|
7100
|
+
claudeNativeModelProfile,
|
|
7101
|
+
claudeProviderId,
|
|
7102
|
+
claudeSubscriptionCapacity,
|
|
7103
|
+
codeSearchDeploymentPolicy,
|
|
5356
7104
|
codemodeWorkspaceUrl,
|
|
7105
|
+
codexUpstreamModelSlugs,
|
|
5357
7106
|
collectGitIdentityEnvironment,
|
|
5358
7107
|
collectSandboxEnvironment,
|
|
5359
7108
|
configuredAllowedModels,
|
|
@@ -5364,6 +7113,7 @@ export {
|
|
|
5364
7113
|
configuredGatewayWorkspaceProductModelIds,
|
|
5365
7114
|
configuredGoogleDriveSyncLimits,
|
|
5366
7115
|
configuredModelInputIdentities,
|
|
7116
|
+
configuredModelListPricingSchedules,
|
|
5367
7117
|
configuredModelNotes,
|
|
5368
7118
|
configuredModelPricing,
|
|
5369
7119
|
configuredModelPricingSchedules,
|
|
@@ -5379,20 +7129,31 @@ export {
|
|
|
5379
7129
|
effectiveModalIdleTimeoutSeconds,
|
|
5380
7130
|
effectiveSandboxDrainSnapshotTimeoutMs,
|
|
5381
7131
|
effectiveSandboxLifecycle,
|
|
7132
|
+
emptyClaudeUsage,
|
|
5382
7133
|
environmentsEncryptionKeyBytes,
|
|
5383
7134
|
firstPartyMcpBaseUrl,
|
|
5384
7135
|
firstPartyMcpInternalBaseUrl,
|
|
5385
7136
|
firstPartyMcpInternalWorkspaceUrl,
|
|
5386
7137
|
firstPartyMcpWorkspaceUrl,
|
|
5387
7138
|
gatewayRequestPolicyForUpstreamModel,
|
|
7139
|
+
getArtifactMaterializerSettings,
|
|
7140
|
+
getArtifactOutboxSettings,
|
|
5388
7141
|
getSettings,
|
|
5389
7142
|
googleDriveOAuthCallbackUrl,
|
|
5390
7143
|
googleDriveProviderRetryOptions,
|
|
5391
7144
|
hasGitCredentialRepositorySelection,
|
|
5392
7145
|
hasGitHubRepositorySelection,
|
|
5393
7146
|
isDirectOpenAiApiBaseUrl,
|
|
7147
|
+
isManagedOpenRouterFreeRoute,
|
|
7148
|
+
isModelAvailableForNewSelection,
|
|
5394
7149
|
isUsableVoiceInputSecret,
|
|
7150
|
+
localAllowedOriginEntries,
|
|
7151
|
+
localSandboxApiRouteAllowed,
|
|
7152
|
+
managedUserEmailAllowed,
|
|
7153
|
+
mergeClaudeUsage,
|
|
5395
7154
|
modelCostClassForConfiguredModel,
|
|
7155
|
+
parseClaudeUsageHeaders,
|
|
7156
|
+
parseClaudeUsageResponse,
|
|
5396
7157
|
parseExposedPorts,
|
|
5397
7158
|
parseIntegrationsOauthClientsJson,
|
|
5398
7159
|
parseMcpServers,
|
|
@@ -5409,6 +7170,7 @@ export {
|
|
|
5409
7170
|
policyProviderIdForModel,
|
|
5410
7171
|
productLabelForModelId,
|
|
5411
7172
|
productShortLabelForModelId,
|
|
7173
|
+
promotionalCreditScope,
|
|
5412
7174
|
requiredSandboxEnvForBackend,
|
|
5413
7175
|
resolveAiGatewayRealtimeModel,
|
|
5414
7176
|
resolveEnrollmentSigningSecret,
|
|
@@ -5425,23 +7187,34 @@ export {
|
|
|
5425
7187
|
resolveVoiceInputProviderRegistry,
|
|
5426
7188
|
responseSatisfiesLatencyMode,
|
|
5427
7189
|
retryStartupDependency,
|
|
7190
|
+
reviewedModelListPricing,
|
|
5428
7191
|
runnableLatencyModesForModel,
|
|
5429
7192
|
sandboxArchiveCaptureTimeoutMs,
|
|
5430
7193
|
sandboxEnvironmentVariableNames,
|
|
7194
|
+
sandboxImageAllowlist,
|
|
5431
7195
|
sandboxLifecycleHookIds,
|
|
5432
7196
|
sandboxLifecycleTransitionWaitMs,
|
|
5433
7197
|
sandboxPreparationProfiles,
|
|
5434
7198
|
sandboxWarmRateMicrosPerSecond,
|
|
5435
7199
|
selectModelPricing,
|
|
7200
|
+
selectSubscriptionAccount,
|
|
5436
7201
|
serviceTierForLatencyMode,
|
|
7202
|
+
settingsForAcceptedSubscriptionTurn,
|
|
5437
7203
|
settingsWithResolvedModelContext,
|
|
7204
|
+
signupCreditModelIds,
|
|
5438
7205
|
stableSandboxEnvironmentForRun,
|
|
5439
7206
|
startupRetryOptions,
|
|
5440
7207
|
streamTokenDegraded,
|
|
7208
|
+
subscriptionAccountShardIndex,
|
|
5441
7209
|
temporalConnectionOptions,
|
|
7210
|
+
trustedProxyCidrEntries,
|
|
7211
|
+
usableJevApiKey,
|
|
5442
7212
|
validateModelCatalogSettings,
|
|
5443
7213
|
voiceInputDeploymentConfigured,
|
|
7214
|
+
withClaudeConnectionCatalog,
|
|
7215
|
+
withClaudeConnectionCredential,
|
|
5444
7216
|
withCodexCatalogProvider,
|
|
7217
|
+
withDirectModelProviders,
|
|
5445
7218
|
withOrganizationGatewayCatalogProvider,
|
|
5446
7219
|
withOrganizationGatewayCredential,
|
|
5447
7220
|
withOrganizationOpenRouterCatalogProvider,
|