@opengeni/config 1.2.0-canary.1 → 1.2.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 +815 -22
- package/dist/index.js +2378 -669
- 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 +2237 -343
- package/src/managed-user-admission.ts +11 -0
- package/src/subscription-account-selection.ts +36 -0
package/dist/index.js
CHANGED
|
@@ -1,13 +1,73 @@
|
|
|
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,
|
|
64
|
+
currentAgentLearningToolSelection,
|
|
6
65
|
Entitlements,
|
|
7
66
|
EntitlementsMode,
|
|
8
67
|
KnowledgeSourceSyncLimits,
|
|
9
68
|
LatencyMode,
|
|
10
69
|
MAX_NESTED_AGENT_DEPTH,
|
|
70
|
+
McpServerConnectionRef as PublicMcpServerConnectionRef,
|
|
11
71
|
ProductAccessMode,
|
|
12
72
|
ReasoningEffort,
|
|
13
73
|
FIRST_PARTY_MCP_TOOL_NAMES,
|
|
@@ -42,7 +102,365 @@ import {
|
|
|
42
102
|
} from "@opengeni/xai-subscription";
|
|
43
103
|
import { XAI_SUBSCRIPTION_MODEL_ID_PREFIX as XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 } from "@opengeni/xai-subscription";
|
|
44
104
|
import { createHash } from "crypto";
|
|
45
|
-
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
|
|
46
464
|
var envName = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
47
465
|
var registryId = /^[A-Za-z0-9_-]+$/;
|
|
48
466
|
var DEFAULT_OPENROUTER_MODEL_ID = "openrouter/nvidia/nemotron-3-super-120b-a12b:free";
|
|
@@ -51,12 +469,13 @@ var DEFAULT_MODEL_COST_POLICY_JSON = JSON.stringify({
|
|
|
51
469
|
});
|
|
52
470
|
var SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS = 60 * 6e4;
|
|
53
471
|
var SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS = 1e4;
|
|
472
|
+
var SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS = 12e4;
|
|
54
473
|
var SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS = SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS - SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS;
|
|
55
474
|
var GOOGLE_DRIVE_PROVIDER_REQUEST_TIMEOUT_MAX_MS = 6e4;
|
|
56
475
|
var GOOGLE_DRIVE_PROVIDER_RETRY_DELAY_MAX_MS = 6e4;
|
|
57
476
|
var SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS = 60 * 6e4;
|
|
58
477
|
var SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS = 1e4;
|
|
59
|
-
var EnvBoolean =
|
|
478
|
+
var EnvBoolean = z3.preprocess((value) => {
|
|
60
479
|
if (typeof value !== "string") {
|
|
61
480
|
return value;
|
|
62
481
|
}
|
|
@@ -68,10 +487,11 @@ var EnvBoolean = z.preprocess((value) => {
|
|
|
68
487
|
return false;
|
|
69
488
|
}
|
|
70
489
|
return value;
|
|
71
|
-
},
|
|
490
|
+
}, z3.boolean());
|
|
491
|
+
var PublicHttpUrl = z3.string().url().max(2048).refine((value) => /^https?:\/\//iu.test(value), "must be an http(s) URL");
|
|
72
492
|
var DEFAULT_GOAL_IDLE_BACKOFF_MS = [3e3, 3e4, 12e4, 3e5];
|
|
73
493
|
var DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS = 6e5;
|
|
74
|
-
var EnvGoalIdleBackoffMs =
|
|
494
|
+
var EnvGoalIdleBackoffMs = z3.preprocess((value) => {
|
|
75
495
|
if (typeof value !== "string") return value;
|
|
76
496
|
const source = value.trim();
|
|
77
497
|
if (!source) return void 0;
|
|
@@ -79,8 +499,8 @@ var EnvGoalIdleBackoffMs = z.preprocess((value) => {
|
|
|
79
499
|
const trimmed = entry.trim();
|
|
80
500
|
return trimmed === "" ? Number.NaN : Number(trimmed);
|
|
81
501
|
});
|
|
82
|
-
},
|
|
83
|
-
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(
|
|
84
504
|
(value) => {
|
|
85
505
|
if (typeof value !== "string") return value;
|
|
86
506
|
const source = value.trim();
|
|
@@ -94,7 +514,7 @@ var EnvFirstPartyMcpTools = z.preprocess(
|
|
|
94
514
|
}
|
|
95
515
|
return source.split(",").map((entry) => entry.trim());
|
|
96
516
|
},
|
|
97
|
-
|
|
517
|
+
z3.array(FirstPartyMcpToolName).superRefine((tools, context) => {
|
|
98
518
|
const seen = /* @__PURE__ */ new Set();
|
|
99
519
|
for (const [index, tool] of tools.entries()) {
|
|
100
520
|
if (seen.has(tool)) {
|
|
@@ -141,82 +561,23 @@ var sandboxPreparationProfiles = {
|
|
|
141
561
|
};
|
|
142
562
|
var AGENT_INSTRUCTIONS_CORE_PLACEHOLDER = "{{core}}";
|
|
143
563
|
var DEFAULT_AGENT_INSTRUCTIONS = [
|
|
144
|
-
"You are an OpenGeni workspace agent.",
|
|
145
|
-
"Follow the user's task and
|
|
146
|
-
"
|
|
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.",
|
|
147
567
|
"Repository resources are mounted under repos/<host>/<owner>/<repo> unless the session specifies another collision-free mount path.",
|
|
148
568
|
"File resources are mounted under .opengeni/files/<file-id>/ unless the session specifies another mount path.",
|
|
149
569
|
"Attached files are mounted read-only; copy them before modifying.",
|
|
150
570
|
"Installed and selected Skills appear in the session Skill index; follow its reading instructions and any role-specific guidance.",
|
|
151
|
-
"
|
|
152
|
-
"When the
|
|
153
|
-
"
|
|
154
|
-
"
|
|
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.",
|
|
155
575
|
AGENT_INSTRUCTIONS_CORE_PLACEHOLDER
|
|
156
576
|
].join(" ");
|
|
157
|
-
var McpServerConnectionRefSchema =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
providerDomain: z.string().min(1),
|
|
162
|
-
kind: z.enum(["oauth2", "api_key", "app_install", "delegated"]).optional(),
|
|
163
|
-
scopes: z.array(z.string().min(1)).optional(),
|
|
164
|
-
resource: z.string().min(1).optional(),
|
|
165
|
-
selectedResources: z.array(
|
|
166
|
-
z.object({
|
|
167
|
-
id: z.string().min(1).max(512),
|
|
168
|
-
kind: z.literal("repository")
|
|
169
|
-
}).strict()
|
|
170
|
-
).min(1).max(256).superRefine((resources, context) => {
|
|
171
|
-
const seen = /* @__PURE__ */ new Set();
|
|
172
|
-
for (const [index, resource] of resources.entries()) {
|
|
173
|
-
const key = `${resource.kind}\0${resource.id}`;
|
|
174
|
-
if (seen.has(key)) {
|
|
175
|
-
context.addIssue({
|
|
176
|
-
code: "custom",
|
|
177
|
-
message: "selectedResources must not contain duplicates",
|
|
178
|
-
path: [index]
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
seen.add(key);
|
|
182
|
-
}
|
|
183
|
-
}).optional(),
|
|
184
|
-
authoritySource: z.literal("host").optional(),
|
|
185
|
-
hostBinding: z.object({ bindingId: z.string().uuid(), generation: z.number().int().positive().safe() }).strict().optional(),
|
|
186
|
-
subjectScope: z.enum(["workspace", "subject"]).optional()
|
|
187
|
-
}).strict().superRefine((reference, context) => {
|
|
188
|
-
if (reference.authoritySource === "host" && !reference.connectionId) {
|
|
189
|
-
context.addIssue({
|
|
190
|
-
code: "custom",
|
|
191
|
-
message: "host authority requires connectionId",
|
|
192
|
-
path: ["connectionId"]
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
if (reference.hostBinding && reference.authoritySource !== "host")
|
|
196
|
-
context.addIssue({
|
|
197
|
-
code: "custom",
|
|
198
|
-
path: ["hostBinding"],
|
|
199
|
-
message: "Durable binding requires host authority"
|
|
200
|
-
});
|
|
201
|
-
if (!reference.selectedResources) return;
|
|
202
|
-
if (!reference.connectionId) {
|
|
203
|
-
context.addIssue({
|
|
204
|
-
code: "custom",
|
|
205
|
-
message: "selectedResources requires connectionId",
|
|
206
|
-
path: ["connectionId"]
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
if (!reference.provider) {
|
|
210
|
-
context.addIssue({
|
|
211
|
-
code: "custom",
|
|
212
|
-
message: "selectedResources requires provider",
|
|
213
|
-
path: ["provider"]
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
var McpOperationRecoverySchema = z.record(
|
|
218
|
-
z.string().min(1).max(512).regex(/^\S+$/u),
|
|
219
|
-
z.object({ observerTool: z.string().min(1).max(512).regex(/^\S+$/u) }).strict()
|
|
577
|
+
var McpServerConnectionRefSchema = PublicMcpServerConnectionRef;
|
|
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()
|
|
220
581
|
).superRefine((bindings, context) => {
|
|
221
582
|
for (const [originalTool, binding] of Object.entries(bindings)) {
|
|
222
583
|
if (originalTool === binding.observerTool) {
|
|
@@ -228,110 +589,126 @@ var McpOperationRecoverySchema = z.record(
|
|
|
228
589
|
}
|
|
229
590
|
}
|
|
230
591
|
});
|
|
231
|
-
var DEFAULT_MODAL_IMAGE_REF = "opengenipublicneuacr.azurecr.io/opengeni-desktop@sha256:
|
|
232
|
-
var SettingsSchema =
|
|
233
|
-
serviceName:
|
|
234
|
-
environment:
|
|
235
|
-
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"),
|
|
236
597
|
// The release-train version baked into official images (OPENGENI_SERVER_VERSION).
|
|
237
598
|
// Absent on dev/source builds — consumers must treat it as optional.
|
|
238
|
-
serverVersion:
|
|
239
|
-
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),
|
|
240
605
|
// Step I (§7.8 runtime half). Dedicated Postgres schema for the EMBEDDED
|
|
241
606
|
// topology. Default "" → standalone: no search_path scoping, server default
|
|
242
607
|
// (`public`). When set (e.g. "opengeni"), the db handle + the managed-auth
|
|
243
608
|
// pool send `search_path = "<dbSchema>","opengeni_private","public"` so every
|
|
244
609
|
// query resolves into the dedicated schema with NO query rewrite (schema-isolation contract F1).
|
|
245
|
-
dbSchema:
|
|
610
|
+
dbSchema: z3.string().default(""),
|
|
246
611
|
// Step I (§7.7). RLS posture. "force" (default) = today's FORCE-RLS via the
|
|
247
612
|
// non-owner `opengeni_app` role. "scoped" = the embedded owner-role path (the
|
|
248
613
|
// GUC is still emitted defensively, so the query path is identical).
|
|
249
|
-
rlsStrategy:
|
|
614
|
+
rlsStrategy: z3.enum(["force", "scoped"]).default("force"),
|
|
250
615
|
// Exact PostgreSQL login identity required by the standalone FORCE-RLS
|
|
251
616
|
// startup/readiness assertion. Embedded `scoped` hosts own their role model
|
|
252
617
|
// and are deliberately not constrained to this name.
|
|
253
|
-
runtimeDatabaseRole:
|
|
254
|
-
natsUrl:
|
|
255
|
-
temporalHost:
|
|
256
|
-
temporalNamespace:
|
|
257
|
-
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"),
|
|
258
623
|
temporalTlsEnabled: EnvBoolean.default(false),
|
|
259
|
-
temporalApiKey:
|
|
260
|
-
temporalTlsServerName:
|
|
261
|
-
temporalTlsRootCaCertificateBase64:
|
|
262
|
-
temporalTlsClientCertificateBase64:
|
|
263
|
-
temporalTlsClientPrivateKeyBase64:
|
|
264
|
-
startupDependencyRetryAttempts:
|
|
265
|
-
startupDependencyRetryInitialDelayMs:
|
|
266
|
-
startupDependencyRetryMaxDelayMs:
|
|
267
|
-
turnWorkerConcurrencyMode:
|
|
268
|
-
turnWorkerMaxConcurrentTurns:
|
|
269
|
-
turnWorkerTargetCpuUsage:
|
|
270
|
-
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),
|
|
271
636
|
// Admission and emergency recovery are deliberately separate control loops.
|
|
272
637
|
// The Temporal tuner stops polling at the lower target; only genuine danger
|
|
273
638
|
// may invoke the disruptive graceful-drain fallback.
|
|
274
|
-
turnWorkerEmergencyMemoryUsage:
|
|
275
|
-
turnWorkerMemoryGuardIntervalMs:
|
|
276
|
-
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),
|
|
277
642
|
observabilityStructuredLogs: EnvBoolean.default(false),
|
|
278
643
|
observabilityMetricsEnabled: EnvBoolean.default(true),
|
|
279
|
-
observabilityOtlpEndpoint:
|
|
280
|
-
observabilityOtlpHeaders:
|
|
644
|
+
observabilityOtlpEndpoint: z3.string().url().optional(),
|
|
645
|
+
observabilityOtlpHeaders: z3.string().default(""),
|
|
646
|
+
observabilityDiagnosticsEndpoint: z3.string().url().optional(),
|
|
647
|
+
observabilityDiagnosticsHeaders: z3.string().default(""),
|
|
281
648
|
analyticsEnabled: EnvBoolean.default(false),
|
|
282
649
|
analyticsConsentRequired: EnvBoolean.default(true),
|
|
283
|
-
analyticsReoClientId:
|
|
284
|
-
analyticsPosthogProjectKey:
|
|
285
|
-
analyticsPosthogHost:
|
|
286
|
-
analyticsGa4MeasurementId:
|
|
287
|
-
|
|
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
|
+
),
|
|
288
671
|
// Standards-based OAuth authorization server for external workspace MCP
|
|
289
672
|
// clients. Opt-in because it creates a new public authentication surface.
|
|
290
673
|
mcpOauthEnabled: EnvBoolean.default(false),
|
|
291
|
-
//
|
|
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
|
|
292
678
|
// exact number of proxy hops only when direct access to the API is blocked.
|
|
293
|
-
|
|
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(""),
|
|
294
684
|
// Browser origin when the web app and API use separate origins in local
|
|
295
685
|
// development. Production normally leaves this unset and uses publicBaseUrl.
|
|
296
|
-
webBaseUrl:
|
|
686
|
+
webBaseUrl: z3.string().url().optional(),
|
|
297
687
|
// Base URL for the bring-your-own-compute agent release assets the get.<domain>
|
|
298
688
|
// install routes redirect to. Defaults to this repo's GitHub Releases. The route
|
|
299
689
|
// appends `/download/agent-v<ver>/<asset>`.
|
|
300
|
-
agentReleasesBaseUrl:
|
|
690
|
+
agentReleasesBaseUrl: z3.string().url().default("https://github.com/Cloudgeni-ai/opengeni/releases"),
|
|
301
691
|
// Explicit operator-controlled promotion pointer for `/agent/latest/*`.
|
|
302
692
|
// Versioned agent releases are immutable; changing this setting promotes or
|
|
303
693
|
// rolls back the stable channel without moving or deleting a provider tag.
|
|
304
|
-
agentStableVersion:
|
|
694
|
+
agentStableVersion: z3.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).default("0.1.16"),
|
|
305
695
|
// Optional independent beta-channel pointer. When unset, the beta update
|
|
306
696
|
// manifest route is unavailable rather than silently serving stable.
|
|
307
|
-
agentBetaVersion:
|
|
697
|
+
agentBetaVersion: z3.string().regex(/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u).optional(),
|
|
308
698
|
productAccessMode: ProductAccessMode.default("local"),
|
|
309
|
-
// --- canonical organization-tenancy authority activation, default OFF ---
|
|
310
|
-
// The named PRE-ACTIVATION opt-out for the organization-tenancy program. FALSE (the
|
|
311
|
-
// default, and the value an operator leaves in place to decline or defer) means
|
|
312
|
-
// this deployment stays on the reversible legacy workspace-owned lane: no phase-F
|
|
313
|
-
// subsystem may switch its access decision to organization/membership authority
|
|
314
|
-
// ids. TRUE is an operator's explicit statement that the activation preconditions
|
|
315
|
-
// in docs/organization-tenancy.md have been proven for this deployment and that
|
|
316
|
-
// the one-way boundary is accepted.
|
|
317
|
-
//
|
|
318
|
-
// This is NOT a kill switch and NOT a rollback: once an activation migration has
|
|
319
|
-
// committed, setting it back to false does not restore the legacy authority - only
|
|
320
|
-
// forward recovery is available. It also grants and revokes nothing by itself;
|
|
321
|
-
// every individual authorization decision keeps its own fences.
|
|
322
|
-
//
|
|
323
|
-
// No runtime path reads it yet: canonical activation (phase F) is unshipped, so
|
|
324
|
-
// the flag exists to reserve the name, pin the safe default, and give every future
|
|
325
|
-
// activation slice one gate to consult. EnvBoolean (NOT z.coerce.boolean(), which
|
|
326
|
-
// coerces "false" -> true and would activate the moment an operator wrote the
|
|
327
|
-
// variable out to disable it).
|
|
328
|
-
organizationTenancyCanonicalActivationEnabled: EnvBoolean.default(false),
|
|
329
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,
|
|
330
704
|
entitlementsMode: EntitlementsMode.default("none"),
|
|
331
705
|
usageLimitsMode: UsageLimitsMode.default("none"),
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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(),
|
|
335
712
|
defaultFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
336
713
|
allowedFirstPartyMcpTools: EnvFirstPartyMcpTools,
|
|
337
714
|
// sandbox workspace scoped stream-token HMAC secret (sandbox contract §C.3 / stream-token availability contract).
|
|
@@ -339,7 +716,7 @@ var SettingsSchema = z.object({
|
|
|
339
716
|
// family, `ogs_` vs `ogd_` prefix). REQUIRED-WHEN-DESKTOP, but the absence of
|
|
340
717
|
// BOTH while sandboxDesktopEnabled=true is a GRACEFUL DEGRADE (DesktopStream
|
|
341
718
|
// transport:null + a loud boot warning), NOT a hard boot-fail (stream-token availability contract).
|
|
342
|
-
streamTokenSecret:
|
|
719
|
+
streamTokenSecret: z3.string().optional(),
|
|
343
720
|
// The desktop input plane (raw stream:control writes) is OFF in v1: even a
|
|
344
721
|
// holder of stream:control gets 403 until this flips. Keeps stream:control a
|
|
345
722
|
// declared-but-inert permission so later hardening is a flag flip.
|
|
@@ -362,47 +739,51 @@ var SettingsSchema = z.object({
|
|
|
362
739
|
// Optional release-coherent bootstrap hint for custom rigs/connected machines
|
|
363
740
|
// that do not carry the stock-image ogtool binary. Exact stable versions only:
|
|
364
741
|
// the agent must never guess a tag or silently install `latest`.
|
|
365
|
-
ogtoolPackageSpec:
|
|
366
|
-
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(),
|
|
367
744
|
integrationsEnabled: EnvBoolean.default(false),
|
|
368
|
-
integrationsStateSecret:
|
|
745
|
+
integrationsStateSecret: z3.string().optional(),
|
|
746
|
+
integrationsOauthShortStateEnabled: EnvBoolean.default(false),
|
|
369
747
|
integrationsAllowPrivateNetworkTargets: EnvBoolean.default(false),
|
|
370
|
-
integrationsOauthClientsJson:
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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"),
|
|
374
755
|
slackBotDisplayName: OpenGeniSlackBotDisplayName.default("OpenGeni"),
|
|
375
|
-
slackCommand:
|
|
376
|
-
googleDriveClientId:
|
|
377
|
-
googleDriveClientSecret:
|
|
378
|
-
googleDriveSyncMaxItems:
|
|
379
|
-
googleDriveSyncMaxBytes:
|
|
380
|
-
googleDriveSyncMaxFileBytes:
|
|
381
|
-
googleDriveSyncMaxProviderRequests:
|
|
382
|
-
googleDriveSyncMaxElapsedSeconds:
|
|
383
|
-
googleDriveSyncMaxFailureDetails:
|
|
384
|
-
googleDriveProviderRequestTimeoutMs:
|
|
385
|
-
googleDriveProviderRetryAttempts:
|
|
386
|
-
googleDriveProviderRetryInitialDelayMs:
|
|
387
|
-
googleDriveProviderRetryMaxDelayMs:
|
|
388
|
-
googleDriveProviderRetryBudgetMs:
|
|
389
|
-
fikenClientId:
|
|
390
|
-
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(),
|
|
391
772
|
googleDriveWorkspaceEventsEnabled: EnvBoolean.optional(),
|
|
392
|
-
atlassianClientId:
|
|
393
|
-
atlassianClientSecret:
|
|
773
|
+
atlassianClientId: z3.string().optional(),
|
|
774
|
+
atlassianClientSecret: z3.string().optional(),
|
|
394
775
|
// Undefined is meaningful: the migration boundary persists the product
|
|
395
776
|
// default of 3 when no deployment override is supplied.
|
|
396
|
-
maxNestedAgentDepth:
|
|
777
|
+
maxNestedAgentDepth: z3.coerce.number().int().nonnegative().max(MAX_NESTED_AGENT_DEPTH).optional(),
|
|
397
778
|
// Operator OAuth apps for first-party social connectors, keyed by provider
|
|
398
779
|
// id ("x", "reddit"): {"x":{"clientId":"...","clientSecret":"..."}}.
|
|
399
|
-
socialOauthClientsJson:
|
|
780
|
+
socialOauthClientsJson: z3.string().default("{}"),
|
|
400
781
|
// Session goal guard rails. Goals are designed for runs that legitimately
|
|
401
782
|
// span days, so length is bounded by explicit completion/pause and budget
|
|
402
783
|
// exhaustion, never by count. goalMaxAutoContinuations is therefore UNSET
|
|
403
784
|
// by default (no cap); deployments may configure one, and it then acts as a
|
|
404
785
|
// hard ceiling that per-goal overrides can only lower.
|
|
405
|
-
goalMaxAutoContinuations:
|
|
786
|
+
goalMaxAutoContinuations: z3.coerce.number().int().positive().optional(),
|
|
406
787
|
// Idle backoff between CONSECUTIVE no-input goal continuations. This is
|
|
407
788
|
// pacing, not a cap: the first continuation after a turn that consumed any
|
|
408
789
|
// external input is immediate, the n-th consecutive no-input continuation
|
|
@@ -410,7 +791,7 @@ var SettingsSchema = z.object({
|
|
|
410
791
|
// any new input (machine input, human/API prompt, Steer) wakes the session
|
|
411
792
|
// immediately. The delay never exceeds goalIdleBackoffMaxMs.
|
|
412
793
|
goalIdleBackoffMs: EnvGoalIdleBackoffMs.default(DEFAULT_GOAL_IDLE_BACKOFF_MS),
|
|
413
|
-
goalIdleBackoffMaxMs:
|
|
794
|
+
goalIdleBackoffMaxMs: z3.coerce.number().int().positive().default(DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS),
|
|
414
795
|
// Child lifecycle notices: a child session's requires_action freeze, its
|
|
415
796
|
// resolution, a direct Pause, a provider-capacity wait, and goal progress
|
|
416
797
|
// become typed `session_system_updates` rows for the parent (in addition to
|
|
@@ -424,16 +805,6 @@ var SettingsSchema = z.object({
|
|
|
424
805
|
// into @opengeni/db once at boot.
|
|
425
806
|
// Env: OPENGENI_CHILD_LIFECYCLE_NOTICES_ENABLED.
|
|
426
807
|
childLifecycleNoticesEnabled: EnvBoolean.default(false),
|
|
427
|
-
// Explicit host-owned MCP connection authority is a rolling protocol
|
|
428
|
-
// activation. Keep it off while any API, worker, or browser bundle predates
|
|
429
|
-
// the authority discriminator; enable it only after the whole fleet runs an
|
|
430
|
-
// image that understands host refs. Legacy markerless non-UUID refs remain a
|
|
431
|
-
// separate compatibility lane for already-persisted embedding integrations.
|
|
432
|
-
// Env: OPENGENI_HOST_MCP_AUTHORITY_SOURCE_ADMISSION_ENABLED.
|
|
433
|
-
hostMcpAuthoritySourceAdmissionEnabled: EnvBoolean.default(false),
|
|
434
|
-
// Server-owned per-organization remote MCP resolver configuration. Optional;
|
|
435
|
-
// inline credentials and native provider OAuth do not require this service.
|
|
436
|
-
hostMcpCredentialResolversJson: z.string().optional(),
|
|
437
808
|
// Per-channel and per-DM Slack workspace routing. Default ON. A channel does
|
|
438
809
|
// not count a personal workspace as a candidate, so an organization with one
|
|
439
810
|
// shared workspace resolves it as the sole candidate and never asks; the
|
|
@@ -448,17 +819,17 @@ var SettingsSchema = z.object({
|
|
|
448
819
|
// session turn. Effectively unbounded by default for the same reason as
|
|
449
820
|
// above; the graceful max-turns valve (idle + goal continuation, never a
|
|
450
821
|
// session failure) remains as inert safety should a deployment set a cap.
|
|
451
|
-
agentMaxModelCallsPerTurn:
|
|
822
|
+
agentMaxModelCallsPerTurn: z3.coerce.number().int().positive().default(1e6),
|
|
452
823
|
// Deployment fallback for models that do not declare their own window.
|
|
453
824
|
// Built-in billed GPT-5.6 Sol/Terra/Luna pin Codex's 272k catalog instead.
|
|
454
825
|
// OpenGeni always performs one durable, portable plaintext compaction
|
|
455
826
|
// transition; there is no provider/server/off mode ladder.
|
|
456
|
-
contextWindowTokens:
|
|
827
|
+
contextWindowTokens: z3.coerce.number().int().positive().default(105e4),
|
|
457
828
|
// Optional model-catalog effective input ceiling. Codex and billed GPT-5.6
|
|
458
829
|
// models expose this as raw context_window * effective_context_window_percent;
|
|
459
830
|
// when absent, retain the deployment-level window-minus-reserved-output
|
|
460
831
|
// behavior.
|
|
461
|
-
contextEffectiveWindowTokens:
|
|
832
|
+
contextEffectiveWindowTokens: z3.coerce.number().int().positive().optional(),
|
|
462
833
|
// Proactive compaction threshold as a ratio of the model context window.
|
|
463
834
|
// Defaults to 90%: compact as late as possible — retained context beats early
|
|
464
835
|
// headroom now that per-model windows are declared honestly (input-effective,
|
|
@@ -466,7 +837,7 @@ var SettingsSchema = z.object({
|
|
|
466
837
|
// absorbs any overshoot as one retried call rather than a dead session.
|
|
467
838
|
// Clamped to [0.3, 0.9] so deployments can tune the trigger without
|
|
468
839
|
// accidentally disabling compaction.
|
|
469
|
-
contextCompactionThresholdRatio:
|
|
840
|
+
contextCompactionThresholdRatio: z3.coerce.number().default(0.9).transform((value) => {
|
|
470
841
|
if (!Number.isFinite(value)) {
|
|
471
842
|
return 0.9;
|
|
472
843
|
}
|
|
@@ -474,118 +845,127 @@ var SettingsSchema = z.object({
|
|
|
474
845
|
}),
|
|
475
846
|
// Tokens reserved for model output; subtracted from the window to get the
|
|
476
847
|
// usable input budget B = contextWindowTokens - contextReservedOutputTokens.
|
|
477
|
-
contextReservedOutputTokens:
|
|
848
|
+
contextReservedOutputTokens: z3.coerce.number().int().nonnegative().default(128e3),
|
|
478
849
|
// Model-catalog auto-compact limit. When present it is clamped to
|
|
479
850
|
// 90% of the raw window, matching Codex core's auto_compact_token_limit().
|
|
480
|
-
contextAutoCompactThresholdTokens:
|
|
851
|
+
contextAutoCompactThresholdTokens: z3.coerce.number().int().positive().optional(),
|
|
481
852
|
// Provider-neutral fallback for canonical model-facing tool-result text.
|
|
482
853
|
// The current stable Codex catalog policy is 10k tokens; the truncator adds
|
|
483
854
|
// Codex's 1.2x JSON serialization allowance when applying it.
|
|
484
|
-
modelToolOutputTruncationTokens:
|
|
855
|
+
modelToolOutputTruncationTokens: z3.coerce.number().int().positive().default(1e4),
|
|
485
856
|
authRequired: EnvBoolean.default(false),
|
|
486
|
-
accessKey:
|
|
857
|
+
accessKey: z3.string().optional(),
|
|
487
858
|
authAllowHealth: EnvBoolean.default(true),
|
|
488
859
|
authAllowMetrics: EnvBoolean.default(false),
|
|
489
|
-
apiHost:
|
|
490
|
-
apiPort:
|
|
491
|
-
|
|
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),
|
|
492
866
|
// Worker-side first-party MCP traffic stays on the deployment's internal
|
|
493
867
|
// network. OPENGENI_MCP_URL remains the sandbox/external route used by
|
|
494
868
|
// Codemode and remote placements.
|
|
495
|
-
opengeniMcpInternalUrl:
|
|
496
|
-
opengeniMcpUrl:
|
|
869
|
+
opengeniMcpInternalUrl: z3.string().url().optional(),
|
|
870
|
+
opengeniMcpUrl: z3.string().url().optional(),
|
|
497
871
|
// Origins allowed to send browser cookies cross-origin. Other origins may
|
|
498
872
|
// call the public API with bearer credentials, but never receive credentialed
|
|
499
873
|
// CORS responses.
|
|
500
|
-
corsAllowOriginRegex:
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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"),
|
|
506
885
|
// OpenGeni-managed Vercel AI Gateway. When configured, the two reviewed
|
|
507
886
|
// Gateway models below are added to the managed-credit catalog. Workspace
|
|
508
887
|
// Gateway keys use the encrypted connection broker and never this secret.
|
|
509
|
-
vercelAiGatewayApiKey:
|
|
888
|
+
vercelAiGatewayApiKey: z3.string().optional(),
|
|
510
889
|
/** Image adapter route; native hosted providers ignore this model. */
|
|
511
|
-
imageGenerationModel:
|
|
890
|
+
imageGenerationModel: z3.string().trim().min(1).max(256).default("openai/gpt-image-2"),
|
|
512
891
|
/** Durable video generation uses the workspace-owned Gateway credential. */
|
|
513
|
-
videoGenerationPollIntervalMs:
|
|
514
|
-
videoGenerationRecoveryDeadlineMs:
|
|
515
|
-
videoGenerationReferenceUrlTtlSeconds:
|
|
516
|
-
videoGenerationMaxConcurrentPerWorkspace:
|
|
517
|
-
videoGenerationWorkspaceQuotaBytes:
|
|
518
|
-
videoGenerationTempDirectory:
|
|
519
|
-
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"),
|
|
520
899
|
// OpenGeni's customer price, not a claim about the provider's delayed cost report.
|
|
521
900
|
// The durable operation freezes the exact resulting price before provider submit.
|
|
522
|
-
videoGenerationCredit480pMicrosPerSecond:
|
|
523
|
-
videoGenerationCredit720pMicrosPerSecond:
|
|
901
|
+
videoGenerationCredit480pMicrosPerSecond: z3.coerce.number().int().positive().max(1e7).default(155e3),
|
|
902
|
+
videoGenerationCredit720pMicrosPerSecond: z3.coerce.number().int().positive().max(1e7).default(35e4),
|
|
524
903
|
// Native composer voice input (browser MediaRecorder → API transcription).
|
|
525
904
|
// Provider credentials stay server-side; ClientConfig only projects availability
|
|
526
905
|
// and hard ceilings. Selection happens once before audio is sent — never retry
|
|
527
906
|
// the same clip across vendors after an upstream request may have started.
|
|
528
|
-
voiceInputMaxDurationSeconds:
|
|
529
|
-
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),
|
|
530
909
|
// Durable long-form capture uploads bounded chunks to object storage, then
|
|
531
910
|
// normalizes them into provider-safe segments. It is advertised only when
|
|
532
911
|
// object storage and the configured ffmpeg executable are both available.
|
|
533
912
|
voiceInputResumableEnabled: EnvBoolean.default(true),
|
|
534
|
-
voiceInputResumableMaxDurationSeconds:
|
|
535
|
-
voiceInputResumableMaxSizeBytes:
|
|
536
|
-
voiceInputResumableMaxChunkSizeBytes:
|
|
537
|
-
voiceInputResumableRetentionSeconds:
|
|
538
|
-
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"),
|
|
539
918
|
// Preferred provider order (comma-separated ids). First configured+ready wins.
|
|
540
919
|
// Connected subscription STT is preferred by default; operators can put
|
|
541
920
|
// openai/azure-openai first explicitly.
|
|
542
921
|
// Supported: supergrok-subscription, codex-subscription, openai, azure-openai.
|
|
543
|
-
voiceInputProviderOrder:
|
|
922
|
+
voiceInputProviderOrder: z3.string().default("supergrok-subscription,codex-subscription,openai,azure-openai"),
|
|
544
923
|
// OpenAI public /v1/audio/transcriptions path. Reuses OPENGENI_OPENAI_API_KEY
|
|
545
924
|
// when voiceInputOpenaiApiKey is unset. Default model is gpt-transcribe.
|
|
546
925
|
voiceInputOpenaiEnabled: EnvBoolean.default(true),
|
|
547
|
-
voiceInputOpenaiApiKey:
|
|
548
|
-
voiceInputOpenaiBaseUrl:
|
|
549
|
-
voiceInputOpenaiModel:
|
|
926
|
+
voiceInputOpenaiApiKey: z3.string().optional(),
|
|
927
|
+
voiceInputOpenaiBaseUrl: z3.string().optional(),
|
|
928
|
+
voiceInputOpenaiModel: z3.string().default("gpt-transcribe"),
|
|
550
929
|
// Azure OpenAI deployment-scoped audio transcriptions. Reuses the turn-model
|
|
551
930
|
// Azure endpoint/key/AD token when voice-specific overrides are unset.
|
|
552
931
|
voiceInputAzureEnabled: EnvBoolean.default(true),
|
|
553
|
-
voiceInputAzureEndpoint:
|
|
554
|
-
voiceInputAzureDeployment:
|
|
555
|
-
voiceInputAzureApiVersion:
|
|
556
|
-
voiceInputAzureApiKey:
|
|
557
|
-
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(),
|
|
558
937
|
// Legacy opt-in for undocumented ChatGPT /backend-api/transcribe. When
|
|
559
938
|
// OPENGENI_CODEX_SUBSCRIPTION_ENABLED is true, Codex STT is included without
|
|
560
939
|
// this flag. Set false and omit codex-subscription from PROVIDER_ORDER to
|
|
561
940
|
// keep subscription model routing while disabling Codex voice input.
|
|
562
941
|
voiceInputCodexExperimentalEnabled: EnvBoolean.default(false),
|
|
563
|
-
modelPricingJson:
|
|
942
|
+
modelPricingJson: z3.string().default("{}"),
|
|
564
943
|
// Supported-model membership source. Database mode is resolved by the async
|
|
565
944
|
// core overlay; getSettings remains synchronous and env-only.
|
|
566
|
-
modelCatalogSource:
|
|
945
|
+
modelCatalogSource: z3.enum(["code", "database"]).default("code"),
|
|
567
946
|
// Deployment-owned workspace-facing price policy. This is deliberately
|
|
568
947
|
// separate from catalog membership and upstream credential ownership.
|
|
569
948
|
// Shape: { "product/model-id": "free" | "credits" }.
|
|
570
|
-
modelCostPolicyJson:
|
|
949
|
+
modelCostPolicyJson: z3.string().default("{}"),
|
|
571
950
|
// Optional per-product agent guidance. Database mode replaces this with the
|
|
572
951
|
// singleton document's validated modelNotes map.
|
|
573
|
-
modelNotesJson:
|
|
952
|
+
modelNotesJson: z3.string().default("{}"),
|
|
574
953
|
// Managed OpenRouter credential. The curated model table is injected in
|
|
575
954
|
// code/catalog-document resolution and never read from host provider JSON.
|
|
576
|
-
openrouterApiKey:
|
|
955
|
+
openrouterApiKey: z3.string().optional(),
|
|
577
956
|
// Internal, secret-free catalog overlays populated only by
|
|
578
957
|
// applyModelCatalogDocument. They intentionally have no OPENGENI_* env
|
|
579
958
|
// binding so database mode cannot be bypassed with a second source.
|
|
580
|
-
resolvedGatewayModelsJson:
|
|
581
|
-
resolvedOpenRouterModelsJson:
|
|
959
|
+
resolvedGatewayModelsJson: z3.string().optional(),
|
|
960
|
+
resolvedOpenRouterModelsJson: z3.string().optional(),
|
|
961
|
+
resolvedCodexModelsJson: z3.string().optional(),
|
|
582
962
|
// Extra (non-built-in) model providers, declared by the host as a JSON
|
|
583
963
|
// provider registry. Each entry carries its own base URL, API key, wire API
|
|
584
964
|
// ("responses" | "chat") and the models it exposes. The models a client may
|
|
585
965
|
// use are the UNION of the built-in provider's allowed models and every
|
|
586
966
|
// registry provider's models. validateSettings parses this at boot so a
|
|
587
967
|
// malformed registry / unresolvable key / id collision fails fast.
|
|
588
|
-
modelProvidersJson:
|
|
968
|
+
modelProvidersJson: z3.string().default("[]"),
|
|
589
969
|
// Codex (ChatGPT) subscription: when enabled, a per-workspace connected
|
|
590
970
|
// subscription is injected as a synthetic "codex-subscription" registry
|
|
591
971
|
// provider whose models route through the ChatGPT backend (@opengeni/codex).
|
|
@@ -595,15 +975,17 @@ var SettingsSchema = z.object({
|
|
|
595
975
|
// account pool and a distinct rail from the existing xai/* API-key provider.
|
|
596
976
|
supergrokSubscriptionEnabled: EnvBoolean.default(false),
|
|
597
977
|
// OPENGENI_SUPERGROK_SUBSCRIPTION_ENABLED
|
|
978
|
+
claudeSubscriptionEnabled: EnvBoolean.default(false),
|
|
979
|
+
// OPENGENI_CLAUDE_SUBSCRIPTION_ENABLED
|
|
598
980
|
// Maximum silence between complete, valid SuperGrok SSE data events. This is
|
|
599
981
|
// not a request/run duration cap; every valid event resets the timer.
|
|
600
|
-
supergrokResponseStreamIdleTimeoutMs:
|
|
982
|
+
supergrokResponseStreamIdleTimeoutMs: z3.coerce.number().int().positive().max(24 * 60 * 6e4).default(XAI_RESPONSE_STREAM_IDLE_TIMEOUT_MS),
|
|
601
983
|
// Expose the connected apps attached to a Codex subscription through the
|
|
602
984
|
// synthetic codex_apps MCP server. Independent from subscription routing so
|
|
603
985
|
// operators can use Codex models without exposing ChatGPT connectors.
|
|
604
986
|
codexConnectedAppsEnabled: EnvBoolean.default(false),
|
|
605
987
|
// OPENGENI_CODEX_CONNECTED_APPS_ENABLED
|
|
606
|
-
codexProductSku:
|
|
988
|
+
codexProductSku: z3.string().optional(),
|
|
607
989
|
// OPENGENI_CODEX_PRODUCT_SKU (X-OpenAI-Product-Sku, apps only)
|
|
608
990
|
// Progressive MCP disclosure (Codex-CLI-style tool_search): on a codex turn,
|
|
609
991
|
// flag non-eager selected MCP tools `defer_loading:true` (dropping their
|
|
@@ -627,10 +1009,23 @@ var SettingsSchema = z.object({
|
|
|
627
1009
|
// Multi-account P3 (auto-rotation): an account is "near exhaustion" — ineligible to be
|
|
628
1010
|
// rotated TO — when EITHER usage window (5h/weekly) is at/over this percent. Default 90 to
|
|
629
1011
|
// match the UI danger flip (UsageBar danger at pct >= 90). OPENGENI_CODEX_ROTATION_NEAR_EXHAUSTION_PCT.
|
|
630
|
-
codexRotationNearExhaustionPct:
|
|
1012
|
+
codexRotationNearExhaustionPct: z3.coerce.number().int().min(1).max(100).default(90),
|
|
1013
|
+
reasoningConfigurationUpdatesEnabled: EnvBoolean.default(false),
|
|
631
1014
|
openaiReasoningEffort: ReasoningEffort.default("low"),
|
|
632
|
-
openaiAllowedReasoningEfforts:
|
|
633
|
-
|
|
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"),
|
|
634
1029
|
// Provider-assigned item ids (rs_/msg_/fc_…) in Responses API input are
|
|
635
1030
|
// resolved against the provider's server-side response store. That store is
|
|
636
1031
|
// not durable enough to anchor long runs on: a response that streamed fine
|
|
@@ -639,7 +1034,7 @@ var SettingsSchema = z.object({
|
|
|
639
1034
|
// every model-call input so requests are self-contained — conversation
|
|
640
1035
|
// truth already lives client-side in session_history_items. "preserve"
|
|
641
1036
|
// keeps the SDK's pass-through behavior.
|
|
642
|
-
openaiProviderItemIds:
|
|
1037
|
+
openaiProviderItemIds: z3.enum(["strip", "preserve"]).default("strip"),
|
|
643
1038
|
// With ids stripped the provider cannot resolve prior reasoning server-side,
|
|
644
1039
|
// so request reasoning.encrypted_content and send it back with each call:
|
|
645
1040
|
// reasoning continuity without depending on provider-side storage.
|
|
@@ -647,7 +1042,7 @@ var SettingsSchema = z.object({
|
|
|
647
1042
|
// Model-call retry budget for transient provider failures (429s and friends).
|
|
648
1043
|
// The openai client default of 2 retries is too small for sustained TPM
|
|
649
1044
|
// backpressure during long autonomous runs.
|
|
650
|
-
openaiMaxRetries:
|
|
1045
|
+
openaiMaxRetries: z3.coerce.number().int().nonnegative().default(5),
|
|
651
1046
|
// Native hosted web search. The live Azure Responses path executes the
|
|
652
1047
|
// hosted web_search tool, so this is provider-unconditional: ON by default
|
|
653
1048
|
// on every provider, exposed only so operators can disable it. When true,
|
|
@@ -655,6 +1050,19 @@ var SettingsSchema = z.object({
|
|
|
655
1050
|
// merged with the MCP-server tools (getAllTools = [...mcpTools, ...tools])
|
|
656
1051
|
// and the sandbox capability tools, never replacing them.
|
|
657
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"),
|
|
658
1066
|
// Deployment-default agent persona template (the white-label surface). The
|
|
659
1067
|
// runtime resolves the effective template per turn as
|
|
660
1068
|
// per-session-override > per-workspace override > this default, substitutes
|
|
@@ -662,38 +1070,40 @@ var SettingsSchema = z.object({
|
|
|
662
1070
|
// it when the template omits the marker), and uses the result as the agent's
|
|
663
1071
|
// instructions. Defaulting to DEFAULT_AGENT_INSTRUCTIONS keeps the composed
|
|
664
1072
|
// default pinned by runtime tests.
|
|
665
|
-
agentInstructionsTemplate:
|
|
666
|
-
azureOpenaiBaseUrl:
|
|
667
|
-
azureOpenaiEndpoint:
|
|
668
|
-
azureOpenaiDeployment:
|
|
669
|
-
azureOpenaiApiVersion:
|
|
670
|
-
azureOpenaiApiKey:
|
|
671
|
-
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(),
|
|
672
1080
|
disableOpenaiTracing: EnvBoolean.default(false),
|
|
673
1081
|
sandboxBackend: SandboxBackend.default("docker"),
|
|
674
|
-
dockerImage:
|
|
1082
|
+
dockerImage: z3.string().default("opengeni-sandbox:local"),
|
|
675
1083
|
// Explicit deployment contract: the configured base sandbox image contains
|
|
676
1084
|
// the verified, self-contained native artifact runtime at its fixed image
|
|
677
1085
|
// paths. Disabled by default so arbitrary/custom provider images never make
|
|
678
1086
|
// document/spreadsheet/presentation skills appear when their runtime is
|
|
679
|
-
// absent. Per-pack/per-rig image overrides fail closed in the worker even
|
|
680
1087
|
// when this base-image contract is enabled.
|
|
681
1088
|
sandboxArtifactRuntimeEnabled: EnvBoolean.default(false),
|
|
682
|
-
dockerExposedPorts:
|
|
683
|
-
dockerNetwork:
|
|
1089
|
+
dockerExposedPorts: z3.string().default(""),
|
|
1090
|
+
dockerNetwork: z3.string().optional(),
|
|
684
1091
|
// When the worker itself runs in a container and talks to a host Docker daemon,
|
|
685
1092
|
// this directory must be bind-mounted at the exact same absolute path on both
|
|
686
1093
|
// sides. The Agents SDK materializes the workspace here before bind-mounting it
|
|
687
1094
|
// into the sandbox container.
|
|
688
|
-
dockerWorkspaceBaseDir:
|
|
689
|
-
modalAppName:
|
|
690
|
-
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),
|
|
691
1101
|
// Provider-native immutable Modal image ID for the exact logical
|
|
692
1102
|
// `modalImageRef`. When set, the runtime uses ModalImageSelector.fromId and
|
|
693
1103
|
// never asks Modal to parse or import the registry ref. The logical ref is
|
|
694
1104
|
// still persisted on the sandbox lease for provenance and conflict fencing;
|
|
695
1105
|
// the Modal session envelope persists the actual image ID.
|
|
696
|
-
modalImageId:
|
|
1106
|
+
modalImageId: z3.string().min(4).max(128).regex(/^im-[A-Za-z0-9]+$/).optional(),
|
|
697
1107
|
// Name of a Modal Secret (containing REGISTRY_USERNAME + REGISTRY_PASSWORD) used
|
|
698
1108
|
// to authenticate the pull of `modalImageRef` from a PRIVATE registry. When UNSET
|
|
699
1109
|
// (the default), the sandbox image is pulled UNAUTHENTICATED — i.e. it must be a
|
|
@@ -702,7 +1112,7 @@ var SettingsSchema = z.object({
|
|
|
702
1112
|
// run a private image (e.g. a cloud-hosted ACR/ECR/GCR digest): the runtime resolves
|
|
703
1113
|
// the named Secret and builds the image via `fromRegistry(tag, secret)` before the
|
|
704
1114
|
// first sandbox is created. Knob: OPENGENI_MODAL_IMAGE_REGISTRY_SECRET.
|
|
705
|
-
modalImageRegistrySecret:
|
|
1115
|
+
modalImageRegistrySecret: z3.string().optional(),
|
|
706
1116
|
// Modal's hard sandbox lifetime (timeoutMs = this * 1000), counted from box
|
|
707
1117
|
// creation. A resume-by-id does NOT reset that provider clock. It is the
|
|
708
1118
|
// BACKSTOP that reclaims a box if the reaper/worker is down, NOT the warm-window
|
|
@@ -713,17 +1123,17 @@ var SettingsSchema = z.object({
|
|
|
713
1123
|
// deadline-aware snapshot/rematerialization transition. The transition—not a
|
|
714
1124
|
// larger timeout—is what lets a session outlive one finite provider box.
|
|
715
1125
|
// Knob: OPENGENI_MODAL_TIMEOUT_SECONDS.
|
|
716
|
-
modalTimeoutSeconds:
|
|
1126
|
+
modalTimeoutSeconds: z3.coerce.number().int().positive().max(86400).default(86400),
|
|
717
1127
|
// Optional provider reservations for every new Modal sandbox. CPU is measured
|
|
718
1128
|
// in physical cores and may be fractional; memory is measured in MiB. Leave
|
|
719
1129
|
// both unset to preserve Modal's provider defaults. The Agents adapter stores
|
|
720
1130
|
// the resolved values in its session state so snapshot replacement and exact
|
|
721
1131
|
// resume cannot silently change the reservation.
|
|
722
|
-
modalSandboxCpu:
|
|
723
|
-
modalSandboxMemoryMiB:
|
|
724
|
-
modalTokenId:
|
|
725
|
-
modalTokenSecret:
|
|
726
|
-
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(),
|
|
727
1137
|
// modal gap-fill: idleTimeoutMs + workspacePersistence were unmapped (module 03 §4.1).
|
|
728
1138
|
//
|
|
729
1139
|
// CRITICAL (sandbox-file-persistence): when this is UNSET the Modal SDK sends
|
|
@@ -741,7 +1151,7 @@ var SettingsSchema = z.object({
|
|
|
741
1151
|
// explicitly (OPENGENI_MODAL_IDLE_TIMEOUT_SECONDS) only to deliberately idle-reap
|
|
742
1152
|
// SOONER than the hard lifetime; the boot invariant forbids a value that would
|
|
743
1153
|
// reap before reaperPeriod + idleGrace elapses.
|
|
744
|
-
modalIdleTimeoutSeconds:
|
|
1154
|
+
modalIdleTimeoutSeconds: z3.coerce.number().int().positive().optional(),
|
|
745
1155
|
// /workspace FILE PERSISTENCE across warm/cold cycles. Directory snapshots
|
|
746
1156
|
// preserve only the durable user workspace, so provider recovery does not
|
|
747
1157
|
// restore an entire machine image or replace the selected rig/base image.
|
|
@@ -750,16 +1160,14 @@ var SettingsSchema = z.object({
|
|
|
750
1160
|
// Modal creations only.
|
|
751
1161
|
// `snapshot_filesystem` remains available for explicit compatibility and
|
|
752
1162
|
// immutable rig-image materialization. `tar` is the portable fallback.
|
|
753
|
-
modalWorkspacePersistence:
|
|
1163
|
+
modalWorkspacePersistence: z3.enum(["tar", "snapshot_filesystem", "snapshot_directory"]).default("snapshot_directory"),
|
|
754
1164
|
// Shared desktop toggle: this module reads it for the 6080 port-merge; the
|
|
755
1165
|
// owner module (P4.x) acts on it to launch the display stack.
|
|
756
1166
|
sandboxDesktopEnabled: EnvBoolean.default(false),
|
|
757
|
-
// Human
|
|
758
|
-
//
|
|
759
|
-
//
|
|
760
|
-
//
|
|
761
|
-
// "Take control" affordance. This gates the HUMAN viewer plane; agent
|
|
762
|
-
// 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.
|
|
763
1171
|
sandboxDesktopInteractive: EnvBoolean.default(true),
|
|
764
1172
|
// REAL PTY terminal toggle (P5.t): gates the ttyd pty-ws plane (7681) the API
|
|
765
1173
|
// mints over the SAME tunnel as the desktop. Defaults ON — the interactive
|
|
@@ -771,13 +1179,13 @@ var SettingsSchema = z.object({
|
|
|
771
1179
|
// The desktop framebuffer geometry the pixel plane advertises + launches the
|
|
772
1180
|
// display stack with (P4.2). v1 has no live RANDR resize; a change is a full
|
|
773
1181
|
// down→up restart. Defaults match the proven spike geometry (1280x800).
|
|
774
|
-
streamResolutionWidth:
|
|
775
|
-
streamResolutionHeight:
|
|
1182
|
+
streamResolutionWidth: z3.coerce.number().int().positive().default(1280),
|
|
1183
|
+
streamResolutionHeight: z3.coerce.number().int().positive().default(800),
|
|
776
1184
|
// Recording loop: ffmpeg x11grab of :0 → mp4/webm → @opengeni/storage.
|
|
777
1185
|
// recordingMaxBytes caps the in-memory finalize buffer (≤ storage single-PUT);
|
|
778
1186
|
// recordingMaxSeconds is the ffmpeg -t hard ceiling (bounds a multi-day turn).
|
|
779
1187
|
recordingEnabled: EnvBoolean.default(true),
|
|
780
|
-
recordingDefaultCodec:
|
|
1188
|
+
recordingDefaultCodec: z3.enum(["h264-mp4", "vp9-webm"]).default("h264-mp4"),
|
|
781
1189
|
// Workbench v2 turn-end workspace capture. When on, the turn
|
|
782
1190
|
// activity probes the box's changed files off the live box at turn end and
|
|
783
1191
|
// persists a capture revision (blobs in @opengeni/storage) so the workbench
|
|
@@ -785,85 +1193,86 @@ var SettingsSchema = z.object({
|
|
|
785
1193
|
// fully behind this flag: off ⇒ capture is skipped and reads fall back to the
|
|
786
1194
|
// live/wake path (status-quo behavior). Default on; explicit per environment.
|
|
787
1195
|
workspaceCaptureEnabled: EnvBoolean.default(true),
|
|
788
|
-
recordingFramerate:
|
|
789
|
-
recordingMaxSeconds:
|
|
790
|
-
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),
|
|
791
1199
|
// 256 MB
|
|
792
1200
|
// --- daytona ---
|
|
793
|
-
daytonaApiKey:
|
|
794
|
-
daytonaApiUrl:
|
|
795
|
-
daytonaTarget:
|
|
796
|
-
daytonaImage:
|
|
797
|
-
daytonaSnapshotName:
|
|
798
|
-
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(),
|
|
799
1207
|
// 0 disables idle-kill
|
|
800
|
-
daytonaTimeoutSeconds:
|
|
801
|
-
daytonaExposedPortUrlTtlSeconds:
|
|
1208
|
+
daytonaTimeoutSeconds: z3.coerce.number().int().positive().optional(),
|
|
1209
|
+
daytonaExposedPortUrlTtlSeconds: z3.coerce.number().int().positive().optional(),
|
|
802
1210
|
// --- runloop ---
|
|
803
|
-
runloopApiKey:
|
|
804
|
-
runloopBaseUrl:
|
|
805
|
-
runloopBlueprintName:
|
|
806
|
-
runloopBlueprintId:
|
|
1211
|
+
runloopApiKey: z3.string().optional(),
|
|
1212
|
+
runloopBaseUrl: z3.string().url().optional(),
|
|
1213
|
+
runloopBlueprintName: z3.string().optional(),
|
|
1214
|
+
runloopBlueprintId: z3.string().optional(),
|
|
807
1215
|
runloopTunnel: EnvBoolean.default(true),
|
|
808
|
-
runloopKeepAliveSeconds:
|
|
1216
|
+
runloopKeepAliveSeconds: z3.coerce.number().int().positive().optional(),
|
|
809
1217
|
// --- e2b (SDK reads E2B_API_KEY from env; mirrored for validation + forwarding) ---
|
|
810
|
-
e2bApiKey:
|
|
811
|
-
e2bTemplate:
|
|
812
|
-
e2bTimeoutSeconds:
|
|
813
|
-
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(),
|
|
814
1222
|
e2bAllowInternetAccess: EnvBoolean.optional(),
|
|
815
1223
|
e2bAutoResume: EnvBoolean.optional(),
|
|
816
|
-
e2bWorkspacePersistence:
|
|
1224
|
+
e2bWorkspacePersistence: z3.enum(["tar", "snapshot"]).optional(),
|
|
817
1225
|
// --- blaxel ---
|
|
818
|
-
blaxelApiKey:
|
|
819
|
-
blaxelImage:
|
|
820
|
-
blaxelRegion:
|
|
1226
|
+
blaxelApiKey: z3.string().optional(),
|
|
1227
|
+
blaxelImage: z3.string().optional(),
|
|
1228
|
+
blaxelRegion: z3.string().optional(),
|
|
821
1229
|
blaxelExposedPortPublic: EnvBoolean.optional(),
|
|
822
1230
|
// public vs bl_preview_token
|
|
823
|
-
blaxelExposedPortUrlTtlSeconds:
|
|
824
|
-
blaxelMemoryMb:
|
|
825
|
-
blaxelTtl:
|
|
1231
|
+
blaxelExposedPortUrlTtlSeconds: z3.coerce.number().int().positive().optional(),
|
|
1232
|
+
blaxelMemoryMb: z3.coerce.number().int().positive().optional(),
|
|
1233
|
+
blaxelTtl: z3.string().optional(),
|
|
826
1234
|
// --- cloudflare (headless) ---
|
|
827
|
-
cloudflareWorkerUrl:
|
|
828
|
-
cloudflareApiKey:
|
|
1235
|
+
cloudflareWorkerUrl: z3.string().url().optional(),
|
|
1236
|
+
cloudflareApiKey: z3.string().optional(),
|
|
1237
|
+
experimentalBrowserContextPoolEnabled: EnvBoolean.default(false),
|
|
829
1238
|
// --- remote browser placements ---
|
|
830
1239
|
// Provider credentials are injected only into the placement-resident
|
|
831
1240
|
// browserd launch. They never enter session contracts, journals, or sandboxes.
|
|
832
|
-
browserbaseApiKey:
|
|
833
|
-
kernelApiKey:
|
|
834
|
-
kernelEndpoint:
|
|
835
|
-
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),
|
|
836
1245
|
kernelBrowserStealth: EnvBoolean.default(false),
|
|
837
1246
|
// --- vercel (headless) ---
|
|
838
|
-
vercelToken:
|
|
839
|
-
vercelProjectId:
|
|
840
|
-
vercelTeamId:
|
|
841
|
-
vercelRuntime:
|
|
1247
|
+
vercelToken: z3.string().optional(),
|
|
1248
|
+
vercelProjectId: z3.string().optional(),
|
|
1249
|
+
vercelTeamId: z3.string().optional(),
|
|
1250
|
+
vercelRuntime: z3.string().optional(),
|
|
842
1251
|
// --- OpenSandbox (optional Kubernetes-native provisioned sandbox) ---
|
|
843
|
-
openSandboxBaseUrl:
|
|
844
|
-
openSandboxApiKey:
|
|
1252
|
+
openSandboxBaseUrl: z3.string().url().optional(),
|
|
1253
|
+
openSandboxApiKey: z3.string().min(1).optional(),
|
|
845
1254
|
// Release and preview profiles must provide an immutable OCI digest. The
|
|
846
1255
|
// adapter refuses tag-only references when this backend is active.
|
|
847
|
-
openSandboxImage:
|
|
1256
|
+
openSandboxImage: z3.string().min(1).optional(),
|
|
848
1257
|
// Renewable provider TTL is a leak/backstop clock, not OpenGeni's idle
|
|
849
1258
|
// policy. The pinned server accepts a one-minute minimum; ordinary
|
|
850
1259
|
// deployments default to one hour.
|
|
851
|
-
openSandboxTtlSeconds:
|
|
1260
|
+
openSandboxTtlSeconds: z3.coerce.number().int().min(60).max(86400).default(3600),
|
|
852
1261
|
openSandboxUseServerProxy: EnvBoolean.default(true),
|
|
853
1262
|
// Channel B (browserd / noVNC / ttyd) uses OSEP-0011 signed URI-mode ingress.
|
|
854
1263
|
// Exec/files stay on the private lifecycle server-proxy regardless of this flag.
|
|
855
1264
|
openSandboxSignedEndpoints: EnvBoolean.default(false),
|
|
856
|
-
openSandboxSignedEndpointTtlSeconds:
|
|
857
|
-
openSandboxChannelBPublicBaseUrl:
|
|
1265
|
+
openSandboxSignedEndpointTtlSeconds: z3.coerce.number().int().min(60).max(3600).default(600),
|
|
1266
|
+
openSandboxChannelBPublicBaseUrl: z3.string().url().optional(),
|
|
858
1267
|
// Emergency hatch only: force JPEG/RFB through the API frame-proxy even when
|
|
859
1268
|
// signed endpoints are on (M2 subprotocol failure). Unset means OpenSandbox
|
|
860
1269
|
// uses the frame-proxy unless signed endpoints are on.
|
|
861
1270
|
openSandboxInteractionFrameProxy: EnvBoolean.optional(),
|
|
862
|
-
openSandboxPoolRef:
|
|
1271
|
+
openSandboxPoolRef: z3.string().regex(/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/).optional(),
|
|
863
1272
|
// Optional same-cluster, read-only observability projection. The application
|
|
864
1273
|
// chart sets this only on the control worker and mounts a dedicated projected
|
|
865
1274
|
// service-account token; non-Kubernetes and remote-provider deployments omit it.
|
|
866
|
-
openSandboxKubernetesInventoryNamespace:
|
|
1275
|
+
openSandboxKubernetesInventoryNamespace: z3.string().min(1).max(63).regex(/^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$/).optional(),
|
|
867
1276
|
// --- sandbox ownership inversion (P1.2 rollout flag, default OFF) ---
|
|
868
1277
|
// The keystone flag for the stateless resume-by-id model. When FALSE the
|
|
869
1278
|
// agent-turn path is BYTE-FOR-BYTE today's build-and-discard behavior (no
|
|
@@ -917,13 +1326,13 @@ var SettingsSchema = z.object({
|
|
|
917
1326
|
// when ABSENT and sandboxSelfhostedEnabled is on, the poll route reports the
|
|
918
1327
|
// credential plane disabled (graceful degrade, mirrors streamTokenSecret). NEVER
|
|
919
1328
|
// logged. Lives in the opengeni-runtime secret (Helm-clobbered configmap avoided).
|
|
920
|
-
enrollmentSigningSecret:
|
|
1329
|
+
enrollmentSigningSecret: z3.string().optional(),
|
|
921
1330
|
// Connect-info the EnrollmentCredentials hand the agent: the NATS server URL(s)
|
|
922
1331
|
// the agent dials for the control plane, and the relay edge base URL for streams.
|
|
923
1332
|
// The per-workspace NATS Account creds binding is infra-deferred (M4/relay
|
|
924
1333
|
// milestone) — the poll returns these endpoints + a placeholder creds field.
|
|
925
|
-
selfhostedNatsUrl:
|
|
926
|
-
selfhostedRelayUrl:
|
|
1334
|
+
selfhostedNatsUrl: z3.string().optional(),
|
|
1335
|
+
selfhostedRelayUrl: z3.string().optional(),
|
|
927
1336
|
// The HMAC secret the control plane signs the agent's relay PRODUCER token with
|
|
928
1337
|
// (the `ogr_` envelope threaded into EnrollmentCredentials.relayToken; M8b/design
|
|
929
1338
|
// §10.5). The relay verifies the producer token with the SAME secret. Optional:
|
|
@@ -931,10 +1340,10 @@ var SettingsSchema = z.object({
|
|
|
931
1340
|
// plane is simply unavailable until configured). Falls back to streamTokenSecret /
|
|
932
1341
|
// delegationSecret (same HMAC family) so a deployment with a stream-token secret
|
|
933
1342
|
// needs no second one. NEVER logged. Lives in the opengeni-runtime secret.
|
|
934
|
-
selfhostedRelayTokenSecret:
|
|
1343
|
+
selfhostedRelayTokenSecret: z3.string().optional(),
|
|
935
1344
|
// The minisign PUBLIC key the agent pins for self-update verification (handed to
|
|
936
1345
|
// the agent in EnrollmentCredentials; the SECRET key lives only in CI).
|
|
937
|
-
agentUpdatePublicKey:
|
|
1346
|
+
agentUpdatePublicKey: z3.string().optional(),
|
|
938
1347
|
// --- NATS auth-callout tenancy boundary (bring-your-own-compute M-AUTH; design
|
|
939
1348
|
// §10.1 NATS Accounts per workspace + §17 the isolation smoke) -------------
|
|
940
1349
|
// nats-server is configured with AUTH CALLOUT: an external agent connects
|
|
@@ -951,24 +1360,24 @@ var SettingsSchema = z.object({
|
|
|
951
1360
|
// The callout account SIGNING SEED (`SA...`). Both the user JWT and the
|
|
952
1361
|
// authorization-response JWT are signed by this account key; its public key
|
|
953
1362
|
// (`A...`) is the `auth_callout.issuer` in the server config. NEVER logged.
|
|
954
|
-
selfhostedNatsCalloutAccountSeed:
|
|
1363
|
+
selfhostedNatsCalloutAccountSeed: z3.string().optional(),
|
|
955
1364
|
// The TARGET ACCOUNT NAME the minted user is placed into (the server-config-mode
|
|
956
1365
|
// `auth_callout.account`, e.g. "APP"). The responder writes it as the minted user
|
|
957
1366
|
// JWT `aud` so nats-server binds the agent to this account — the SAME account the
|
|
958
1367
|
// privileged control plane connects into, so exact process request/reply
|
|
959
1368
|
// routes. Optional; resolveNatsCalloutConfig defaults it to "APP".
|
|
960
|
-
selfhostedNatsCalloutAccountName:
|
|
1369
|
+
selfhostedNatsCalloutAccountName: z3.string().optional(),
|
|
961
1370
|
// The callout RESPONDER's own NATS login (one of the `auth_callout.auth_users`
|
|
962
1371
|
// in the AUTH account) — the responder connects with this to subscribe
|
|
963
1372
|
// $SYS.REQ.USER.AUTH. Username/password.
|
|
964
|
-
selfhostedNatsCalloutUser:
|
|
965
|
-
selfhostedNatsCalloutPassword:
|
|
1373
|
+
selfhostedNatsCalloutUser: z3.string().optional(),
|
|
1374
|
+
selfhostedNatsCalloutPassword: z3.string().optional(),
|
|
966
1375
|
// The PRIVILEGED control-plane login (api/worker): a static account user that may
|
|
967
1376
|
// request exact process RPC subjects + receive their inbox replies. The event bus + the
|
|
968
1377
|
// selfhosted control RPC ride THIS connection. Username/password; when unset the
|
|
969
1378
|
// bus connects anonymously (local dev / a NATS with no auth_callout).
|
|
970
|
-
selfhostedNatsControlUser:
|
|
971
|
-
selfhostedNatsControlPassword:
|
|
1379
|
+
selfhostedNatsControlUser: z3.string().optional(),
|
|
1380
|
+
selfhostedNatsControlPassword: z3.string().optional(),
|
|
972
1381
|
// --- selfhosted (Connected Machine) control/exec op deadlines ---------------
|
|
973
1382
|
// CONTROL ops (ping / fs / git / desktop / pty) keep a short request timeout so
|
|
974
1383
|
// liveness failures surface promptly. EXEC duration is a different concern: by
|
|
@@ -978,8 +1387,8 @@ var SettingsSchema = z.object({
|
|
|
978
1387
|
// process deadline by setting a positive value; 0 never schedules a process kill.
|
|
979
1388
|
// Knobs: OPENGENI_SANDBOX_SELFHOSTED_EXEC_TIMEOUT_MS (default 0 = none) and
|
|
980
1389
|
// OPENGENI_SANDBOX_SELFHOSTED_CONTROL_TIMEOUT_MS (default 30s).
|
|
981
|
-
sandboxSelfhostedExecTimeoutMs:
|
|
982
|
-
sandboxSelfhostedControlTimeoutMs:
|
|
1390
|
+
sandboxSelfhostedExecTimeoutMs: z3.coerce.number().int().nonnegative().default(0),
|
|
1391
|
+
sandboxSelfhostedControlTimeoutMs: z3.coerce.number().int().positive().default(3e4),
|
|
983
1392
|
// --- sandbox lease cadences (cadence invariant validated at boot below) ---
|
|
984
1393
|
// reaperPeriod < viewerHolderTTL, and reaperPeriod + idleGrace < the EFFECTIVE
|
|
985
1394
|
// box idle timeout (effectiveModalIdleTimeoutSeconds, which defaults to the hard
|
|
@@ -987,12 +1396,12 @@ var SettingsSchema = z.object({
|
|
|
987
1396
|
// idle timeout — which we pin high enough (via the idle-timeout default) that
|
|
988
1397
|
// OpenGeni's reaper, not Modal's idle-reap, governs teardown so /workspace is
|
|
989
1398
|
// snapshotted before the box dies (sandbox-file-persistence).
|
|
990
|
-
sandboxLeaseReaperPeriodMs:
|
|
991
|
-
sandboxViewerHolderTtlMs:
|
|
1399
|
+
sandboxLeaseReaperPeriodMs: z3.coerce.number().int().positive().default(3e4),
|
|
1400
|
+
sandboxViewerHolderTtlMs: z3.coerce.number().int().positive().default(9e4),
|
|
992
1401
|
// A BrowserSession controller refreshes its durable resource and exact
|
|
993
1402
|
// interaction lease holder together. This longer crash horizon tolerates API
|
|
994
1403
|
// replacement while still releasing a placement whose controller died.
|
|
995
|
-
sandboxInteractionHolderTtlMs:
|
|
1404
|
+
sandboxInteractionHolderTtlMs: z3.coerce.number().int().positive().default(18e4),
|
|
996
1405
|
// The DRAIN grace: how long a refcount-0 (draining) lease stays WARM before the
|
|
997
1406
|
// reaper resume-by-ids the box and terminates it. This is the cost-vs-snappiness
|
|
998
1407
|
// dial — when the user navigates away the box keeps refcount 0, but it survives
|
|
@@ -1002,7 +1411,29 @@ var SettingsSchema = z.object({
|
|
|
1002
1411
|
// fresh EMPTY box; lower it to trade warm cost for a snappier reclaim.
|
|
1003
1412
|
// getSettings caps the default at half a shorter configured Modal lifetime so
|
|
1004
1413
|
// the entire reaper window always fits. Knob: OPENGENI_SANDBOX_IDLE_GRACE_MS.
|
|
1005
|
-
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),
|
|
1006
1437
|
// MID-SESSION /workspace snapshot cadence (sandbox-file-persistence). The
|
|
1007
1438
|
// reaper's drain-persist only protects boxes the reaper itself kills; a box
|
|
1008
1439
|
// that dies any other way (Modal's hard creation-time timeout on a session
|
|
@@ -1012,20 +1443,20 @@ var SettingsSchema = z.object({
|
|
|
1012
1443
|
// one (same epoch-fenced fold-onto-lease seam as the drain), bounding the
|
|
1013
1444
|
// worst-case loss of ANY unclean box death to this window. 0 disables.
|
|
1014
1445
|
// Knob: OPENGENI_SANDBOX_SNAPSHOT_INTERVAL_MS. Default 15min.
|
|
1015
|
-
sandboxSnapshotIntervalMs:
|
|
1446
|
+
sandboxSnapshotIntervalMs: z3.coerce.number().int().min(0).default(9e5),
|
|
1016
1447
|
// Maximum time a best-effort /workspace snapshot capture may hold turn/reaper
|
|
1017
1448
|
// cleanup. A hung provider snapshot must never pin a lease holder, block
|
|
1018
1449
|
// graceful shutdown, or become permission to GC an older archive. Timeout is
|
|
1019
1450
|
// treated exactly like a failed best-effort snapshot. Knob:
|
|
1020
1451
|
// OPENGENI_SANDBOX_SNAPSHOT_TIMEOUT_MS. Default 60s.
|
|
1021
|
-
sandboxSnapshotTimeoutMs:
|
|
1452
|
+
sandboxSnapshotTimeoutMs: z3.coerce.number().int().positive().max(SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS).default(6e4),
|
|
1022
1453
|
// A zero-holder drain may need substantially longer than a best-effort
|
|
1023
1454
|
// mid-turn/turn-end snapshot for a very large workspace. Keep that provider
|
|
1024
1455
|
// budget independent so increasing drain recovery headroom cannot pin an
|
|
1025
1456
|
// ordinary turn finalizer for the same duration. Unset preserves the legacy
|
|
1026
1457
|
// single-budget behavior. Knob:
|
|
1027
1458
|
// OPENGENI_SANDBOX_DRAIN_SNAPSHOT_TIMEOUT_MS.
|
|
1028
|
-
sandboxDrainSnapshotTimeoutMs:
|
|
1459
|
+
sandboxDrainSnapshotTimeoutMs: z3.coerce.number().int().positive().max(SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS).optional(),
|
|
1029
1460
|
// Begin a controlled snapshot/quiesce/drain/rematerialize transition this far
|
|
1030
1461
|
// ahead of a finite provider deadline. Modal's 24h creation clock cannot be
|
|
1031
1462
|
// extended; the logical sandbox outlives it by moving to one successor box.
|
|
@@ -1034,22 +1465,22 @@ var SettingsSchema = z.object({
|
|
|
1034
1465
|
// an extra coupled environment override. An explicit value may be larger when
|
|
1035
1466
|
// an operator deliberately wants more rotation headroom; the boot invariant
|
|
1036
1467
|
// still requires it to remain below the provider lifetime.
|
|
1037
|
-
sandboxRotationLeadMs:
|
|
1468
|
+
sandboxRotationLeadMs: z3.coerce.number().int().positive().default(36e5),
|
|
1038
1469
|
// Bound provider-deadline rotation admission independently of execution.
|
|
1039
1470
|
// Every admitted box receives its own durable drain child; the control worker
|
|
1040
1471
|
// limits provider I/O to 32 concurrent activities. Matching that bound avoids
|
|
1041
1472
|
// both the old one-box-per-tick deadline backlog and an unbounded provider/API
|
|
1042
1473
|
// burst. Operators may tune this for a differently-sized worker pool.
|
|
1043
|
-
sandboxRotationBatchSize:
|
|
1474
|
+
sandboxRotationBatchSize: z3.coerce.number().int().positive().max(500).default(32),
|
|
1044
1475
|
// expires_at refresh window for a held lease (>> the turn 10s heartbeat so a
|
|
1045
1476
|
// single missed heartbeat never TTL-reaps a live turn). The warming TTL is the
|
|
1046
1477
|
// window a cold->warming spawner has to commit warm before a reaper resets it.
|
|
1047
|
-
sandboxLeaseTtlMs:
|
|
1048
|
-
sandboxLeaseWarmingTtlMs:
|
|
1478
|
+
sandboxLeaseTtlMs: z3.coerce.number().int().positive().default(9e4),
|
|
1479
|
+
sandboxLeaseWarmingTtlMs: z3.coerce.number().int().positive().default(12e4),
|
|
1049
1480
|
// Overall user-facing budget for warming a sandbox lease. Unlike the lease TTL
|
|
1050
1481
|
// (a liveness/reaper cadence), this bounds how long one turn waits for capacity
|
|
1051
1482
|
// or provider creation before surfacing a clear turn.failed error.
|
|
1052
|
-
sandboxWarmingTimeoutMs:
|
|
1483
|
+
sandboxWarmingTimeoutMs: z3.coerce.number().int().positive().default(6e5),
|
|
1053
1484
|
// Request-scoped workspace control-prefix budget: how long one HTTP-originated
|
|
1054
1485
|
// session/workspace mutation (Send, Steer, Pause/Resume/Cancel, queue
|
|
1055
1486
|
// move/edit/delete, composer draft, settings narrowing, quiescent tree
|
|
@@ -1058,114 +1489,132 @@ var SettingsSchema = z.object({
|
|
|
1058
1489
|
// settlement and claims never use it. The API installs the validated value
|
|
1059
1490
|
// into @opengeni/db once at app construction; nothing reads the env per
|
|
1060
1491
|
// request. Env: OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS. Default 20 s.
|
|
1061
|
-
workspaceControlLockTimeoutMs:
|
|
1492
|
+
workspaceControlLockTimeoutMs: z3.coerce.number({
|
|
1062
1493
|
message: "OPENGENI_WORKSPACE_CONTROL_LOCK_TIMEOUT_MS must be a positive integer (ms)"
|
|
1063
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),
|
|
1064
1495
|
// Rig setup-script budget (M3): the wall-clock timeout the rig-setup lifecycle
|
|
1065
1496
|
// hook runs its script under, distinct from the 120s per-command lifecycle
|
|
1066
1497
|
// default (a rig may compile/install heavy tooling on first cold create).
|
|
1067
1498
|
// Env: OPENGENI_RIG_SETUP_TIMEOUT_MS. Default 10min.
|
|
1068
|
-
rigSetupTimeoutMs:
|
|
1499
|
+
rigSetupTimeoutMs: z3.coerce.number().int().positive().default(6e5),
|
|
1069
1500
|
// --- sandbox warm-time billing (P2.1) ---
|
|
1070
1501
|
// Per-backend warm rate (usd_micros/sec), like modelPricingJson: an empty {}
|
|
1071
1502
|
// means warm-cost is not debited (warm-seconds are still metered for audit).
|
|
1072
1503
|
// Shape: { "modal": 5, "runloop": 4, ... }. Backends absent here meter
|
|
1073
1504
|
// warm-seconds but accrue NO warm_cost / debit (rate 0).
|
|
1074
|
-
sandboxWarmRateMicrosPerSecondJson:
|
|
1505
|
+
sandboxWarmRateMicrosPerSecondJson: z3.string().default("{}"),
|
|
1506
|
+
sandboxWarmBillingMode: z3.enum(["usage_only", "shadow", "credits"]).default("usage_only"),
|
|
1075
1507
|
// Per-workspace warm cap (cumulative warm-seconds since the start of the UTC
|
|
1076
1508
|
// month, summed over sandbox.warm_seconds). 0 = unbounded. A workspace over the
|
|
1077
1509
|
// cap force-drains its VIEWER-ONLY boxes (guarded AND turn_holders=0 — a paying
|
|
1078
1510
|
// turn is never killed); the reaper then stop()s at refcount 0.
|
|
1079
|
-
sandboxMaxWarmSecondsPerWorkspace:
|
|
1080
|
-
sandboxPreparationProfiles:
|
|
1081
|
-
sandboxEnvAllowlist:
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
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(),
|
|
1091
1526
|
objectStorageForcePathStyle: EnvBoolean.default(true),
|
|
1092
|
-
objectStorageAzureConnectionString:
|
|
1093
|
-
objectStorageAzureAccountName:
|
|
1094
|
-
objectStorageAzureAccountKey:
|
|
1095
|
-
objectStorageAzureEndpoint:
|
|
1096
|
-
objectStorageGcsProjectId:
|
|
1097
|
-
objectStorageGcsCredentialsJson:
|
|
1098
|
-
objectStorageGcsKeyFilename:
|
|
1099
|
-
objectStorageGcsApiEndpoint:
|
|
1100
|
-
documentParser:
|
|
1101
|
-
documentChunkSize:
|
|
1102
|
-
documentChunkOverlap:
|
|
1103
|
-
documentEmbeddingProvider:
|
|
1104
|
-
documentEmbeddingModel:
|
|
1105
|
-
documentEmbeddingDimensions:
|
|
1106
|
-
documentEmbeddingApiKey:
|
|
1107
|
-
documentEmbeddingBaseUrl:
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
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(),
|
|
1121
1563
|
/** Default-off rollout for the in-process GitHub repository API tool surface. */
|
|
1122
1564
|
githubRestMcpEnabled: EnvBoolean.default(false),
|
|
1123
1565
|
githubPersonalOauthEnabled: EnvBoolean.default(false),
|
|
1124
|
-
githubPersonalOauthClientId:
|
|
1125
|
-
githubPersonalOauthClientSecret:
|
|
1126
|
-
githubAppSlug:
|
|
1127
|
-
githubWebhookSecret:
|
|
1128
|
-
githubAppPrivateKey:
|
|
1129
|
-
prReviewGithubAppId:
|
|
1130
|
-
prReviewGithubClientId:
|
|
1131
|
-
prReviewGithubClientSecret:
|
|
1132
|
-
prReviewGithubAppSlug:
|
|
1133
|
-
prReviewGithubWebhookSecret:
|
|
1134
|
-
prReviewGithubAppPrivateKey:
|
|
1135
|
-
betterAuthSecret:
|
|
1136
|
-
betterAuthAllowedHosts:
|
|
1137
|
-
betterAuthCookieDomain:
|
|
1138
|
-
betterAuthTrustedOrigins:
|
|
1139
|
-
managedAuthGoogleClientId:
|
|
1140
|
-
managedAuthGoogleClientSecret:
|
|
1141
|
-
managedAuthGithubClientId:
|
|
1142
|
-
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(),
|
|
1143
1585
|
// Rolling browser login-slot compatibility. Repository/deployment default is
|
|
1144
1586
|
// deliberately legacy; changing to broker is an operator-authorized rollout.
|
|
1145
|
-
|
|
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),
|
|
1146
1595
|
// Query transport is an explicit second-stage rollout. A pre-compatibility
|
|
1147
1596
|
// web image understands only fragment bearers, so API replicas must keep
|
|
1148
1597
|
// generating fragment links until the compatible web fleet has converged.
|
|
1149
|
-
organizationUserSetupEmailTokenTransport:
|
|
1598
|
+
organizationUserSetupEmailTokenTransport: z3.enum(["fragment", "query"]).default("fragment"),
|
|
1150
1599
|
// Query-bearing setup links may appear in controller/edge error logs even
|
|
1151
1600
|
// when access logs and request tracing are disabled. This explicit operator
|
|
1152
1601
|
// confirmation keeps query transport fail closed until that separate sink is
|
|
1153
1602
|
// proven sanitized.
|
|
1154
1603
|
organizationUserSetupQueryEdgeSanitizationConfirmed: EnvBoolean.default(false),
|
|
1155
|
-
resendApiKey:
|
|
1156
|
-
emailFrom:
|
|
1157
|
-
stripeSecretKey:
|
|
1158
|
-
stripePublishableKey:
|
|
1159
|
-
stripeWebhookSecret:
|
|
1160
|
-
stripeCreditsProductId:
|
|
1161
|
-
mcpServers:
|
|
1162
|
-
|
|
1163
|
-
id:
|
|
1164
|
-
name:
|
|
1165
|
-
url:
|
|
1166
|
-
allowedTools:
|
|
1167
|
-
timeoutMs:
|
|
1168
|
-
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),
|
|
1169
1618
|
/** Runtime approval policy, overlaid from an attempt-frozen session snapshot. */
|
|
1170
1619
|
requireApproval: SessionMcpApprovalPolicy.optional(),
|
|
1171
1620
|
/**
|
|
@@ -1174,12 +1623,109 @@ var SettingsSchema = z.object({
|
|
|
1174
1623
|
* encrypted capability-installation credentials; do not put secrets in
|
|
1175
1624
|
* OPENGENI_MCP_SERVERS.
|
|
1176
1625
|
*/
|
|
1177
|
-
headers:
|
|
1626
|
+
headers: z3.record(z3.string(), z3.string()).optional(),
|
|
1178
1627
|
connectionRef: McpServerConnectionRefSchema.optional(),
|
|
1179
1628
|
operationRecovery: McpOperationRecoverySchema.optional()
|
|
1180
1629
|
})
|
|
1181
1630
|
).default([])
|
|
1182
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
|
+
}
|
|
1183
1729
|
function configuredGoogleDriveSyncLimits(settings) {
|
|
1184
1730
|
return KnowledgeSourceSyncLimits.parse({
|
|
1185
1731
|
maxItems: settings.googleDriveSyncMaxItems,
|
|
@@ -1220,6 +1766,24 @@ function personalGitHubOAuthCallbackUrl(publicBaseUrl) {
|
|
|
1220
1766
|
const origin = canonicalPublicOrigin(publicBaseUrl);
|
|
1221
1767
|
return origin ? `${origin}/v1/integrations/github-personal/oauth/callback` : null;
|
|
1222
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
|
+
}
|
|
1223
1787
|
function isUsableVoiceInputSecret(value) {
|
|
1224
1788
|
if (value == null) return false;
|
|
1225
1789
|
const trimmed = value.trim();
|
|
@@ -1304,18 +1868,18 @@ function voiceInputDeploymentConfigured(settings) {
|
|
|
1304
1868
|
(provider) => provider.kind !== "codex-subscription" && provider.kind !== "supergrok-subscription"
|
|
1305
1869
|
);
|
|
1306
1870
|
}
|
|
1307
|
-
var ModelPricingSchema =
|
|
1308
|
-
inputMicrosPerMillionTokens:
|
|
1309
|
-
cachedInputMicrosPerMillionTokens:
|
|
1310
|
-
cacheWriteMicrosPerMillionTokens:
|
|
1311
|
-
outputMicrosPerMillionTokens:
|
|
1312
|
-
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()
|
|
1313
1877
|
});
|
|
1314
|
-
var ModelPricingScheduleSchema =
|
|
1878
|
+
var ModelPricingScheduleSchema = z3.object({
|
|
1315
1879
|
default: ModelPricingSchema,
|
|
1316
|
-
inputTokenTiers:
|
|
1317
|
-
|
|
1318
|
-
minimumInputTokens:
|
|
1880
|
+
inputTokenTiers: z3.array(
|
|
1881
|
+
z3.object({
|
|
1882
|
+
minimumInputTokens: z3.number().int().nonnegative(),
|
|
1319
1883
|
pricing: ModelPricingSchema
|
|
1320
1884
|
})
|
|
1321
1885
|
).optional()
|
|
@@ -1332,10 +1896,10 @@ var ModelPricingScheduleSchema = z.object({
|
|
|
1332
1896
|
previous = tier.minimumInputTokens;
|
|
1333
1897
|
}
|
|
1334
1898
|
});
|
|
1335
|
-
var CapabilitySupportV1 =
|
|
1336
|
-
var CapabilityStateV1Schema =
|
|
1899
|
+
var CapabilitySupportV1 = z3.enum(["supported", "unsupported", "unknown"]);
|
|
1900
|
+
var CapabilityStateV1Schema = z3.object({
|
|
1337
1901
|
upstream: CapabilitySupportV1,
|
|
1338
|
-
runnable:
|
|
1902
|
+
runnable: z3.boolean()
|
|
1339
1903
|
}).superRefine((state, ctx) => {
|
|
1340
1904
|
if (state.upstream === "unsupported" && state.runnable) {
|
|
1341
1905
|
ctx.addIssue({
|
|
@@ -1345,17 +1909,17 @@ var CapabilityStateV1Schema = z.object({
|
|
|
1345
1909
|
});
|
|
1346
1910
|
}
|
|
1347
1911
|
});
|
|
1348
|
-
var ModelModalityV1 =
|
|
1349
|
-
var ModelLatencyModeV1 =
|
|
1350
|
-
var ModelCapabilitiesV1Schema =
|
|
1912
|
+
var ModelModalityV1 = z3.enum(["text", "image", "audio"]);
|
|
1913
|
+
var ModelLatencyModeV1 = z3.enum(["standard", "priority", "fast"]);
|
|
1914
|
+
var ModelCapabilitiesV1Schema = z3.object({
|
|
1351
1915
|
reasoning: CapabilityStateV1Schema.extend({
|
|
1352
|
-
efforts:
|
|
1916
|
+
efforts: z3.array(ReasoningEffort),
|
|
1353
1917
|
defaultEffort: ReasoningEffort.nullable(),
|
|
1354
|
-
required:
|
|
1918
|
+
required: z3.boolean()
|
|
1355
1919
|
}),
|
|
1356
1920
|
functionCalling: CapabilityStateV1Schema,
|
|
1357
1921
|
structuredOutput: CapabilityStateV1Schema,
|
|
1358
|
-
hostedTools:
|
|
1922
|
+
hostedTools: z3.object({
|
|
1359
1923
|
webSearch: CapabilityStateV1Schema,
|
|
1360
1924
|
xSearch: CapabilityStateV1Schema,
|
|
1361
1925
|
codeExecution: CapabilityStateV1Schema,
|
|
@@ -1364,24 +1928,24 @@ var ModelCapabilitiesV1Schema = z.object({
|
|
|
1364
1928
|
runnable: false
|
|
1365
1929
|
})
|
|
1366
1930
|
}),
|
|
1367
|
-
inputModalities:
|
|
1931
|
+
inputModalities: z3.array(ModelModalityV1).min(1),
|
|
1368
1932
|
/** Exact MIME types accepted as typed `input_file`; `text/*` is allowed. */
|
|
1369
|
-
inputFileMediaTypes:
|
|
1370
|
-
outputModalities:
|
|
1371
|
-
transports:
|
|
1933
|
+
inputFileMediaTypes: z3.array(z3.string()).default([]),
|
|
1934
|
+
outputModalities: z3.array(ModelModalityV1).min(1),
|
|
1935
|
+
transports: z3.object({
|
|
1372
1936
|
sse: CapabilityStateV1Schema,
|
|
1373
1937
|
responsesWebSocket: CapabilityStateV1Schema,
|
|
1374
1938
|
realtimeAudio: CapabilityStateV1Schema
|
|
1375
1939
|
}),
|
|
1376
1940
|
promptCaching: CapabilityStateV1Schema.extend({
|
|
1377
|
-
mode:
|
|
1941
|
+
mode: z3.enum(["implicit", "automatic", "none"])
|
|
1378
1942
|
}).optional(),
|
|
1379
|
-
latencyModes:
|
|
1380
|
-
|
|
1943
|
+
latencyModes: z3.array(
|
|
1944
|
+
z3.object({
|
|
1381
1945
|
id: ModelLatencyModeV1,
|
|
1382
1946
|
upstream: CapabilitySupportV1,
|
|
1383
|
-
runnable:
|
|
1384
|
-
billingMultiplierBps:
|
|
1947
|
+
runnable: z3.boolean(),
|
|
1948
|
+
billingMultiplierBps: z3.number().int().positive().optional()
|
|
1385
1949
|
})
|
|
1386
1950
|
).min(1)
|
|
1387
1951
|
}).superRefine((capabilities, ctx) => {
|
|
@@ -1435,9 +1999,9 @@ var ModelCapabilitiesV1Schema = z.object({
|
|
|
1435
1999
|
}
|
|
1436
2000
|
}
|
|
1437
2001
|
});
|
|
1438
|
-
var ModelProviderApi =
|
|
1439
|
-
var ModelProviderWireProfile =
|
|
1440
|
-
var RegistryProviderKind =
|
|
2002
|
+
var ModelProviderApi = z3.enum(["responses", "chat", "anthropic-messages"]);
|
|
2003
|
+
var ModelProviderWireProfile = z3.enum(["openai", "azure-openai"]);
|
|
2004
|
+
var RegistryProviderKind = z3.enum([
|
|
1441
2005
|
"api-key",
|
|
1442
2006
|
"anonymous",
|
|
1443
2007
|
"codex-subscription",
|
|
@@ -1445,36 +2009,47 @@ var RegistryProviderKind = z.enum([
|
|
|
1445
2009
|
"vercel-gateway-managed",
|
|
1446
2010
|
"vercel-gateway-workspace",
|
|
1447
2011
|
"vercel-gateway-organization",
|
|
2012
|
+
"direct-openai-workspace",
|
|
2013
|
+
"direct-azure-workspace",
|
|
1448
2014
|
"openrouter-workspace",
|
|
1449
|
-
"openrouter-organization"
|
|
2015
|
+
"openrouter-organization",
|
|
2016
|
+
"anthropic-organization",
|
|
2017
|
+
"claude-subscription-organization",
|
|
2018
|
+
"anthropic-workspace",
|
|
2019
|
+
"claude-subscription-workspace"
|
|
1450
2020
|
]);
|
|
1451
|
-
var
|
|
1452
|
-
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),
|
|
1453
2027
|
// canonical OpenGeni product id
|
|
1454
|
-
upstreamModelId:
|
|
2028
|
+
upstreamModelId: z3.string().min(1).optional(),
|
|
1455
2029
|
// exact provider slug; defaults to id
|
|
1456
|
-
aliases:
|
|
2030
|
+
aliases: z3.array(z3.string().min(1)).optional(),
|
|
1457
2031
|
// accepted input only; never sent upstream
|
|
1458
|
-
label:
|
|
2032
|
+
label: z3.string().min(1).optional(),
|
|
1459
2033
|
// display name; defaults to id
|
|
1460
|
-
shortLabel:
|
|
2034
|
+
shortLabel: z3.string().min(1).max(64).optional(),
|
|
1461
2035
|
// compact UI label; optional
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
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(),
|
|
1465
2040
|
// Canonical model-facing function/tool-result policy. The runtime applies
|
|
1466
2041
|
// the same 1.2x serialization allowance as Codex when materializing output.
|
|
1467
|
-
toolOutputTruncationTokens:
|
|
1468
|
-
reasoningEffort:
|
|
2042
|
+
toolOutputTruncationTokens: z3.number().int().positive().optional(),
|
|
2043
|
+
reasoningEffort: z3.boolean().optional(),
|
|
1469
2044
|
// legacy compatibility input/projection
|
|
1470
|
-
hostedWebSearch:
|
|
2045
|
+
hostedWebSearch: z3.boolean().optional(),
|
|
1471
2046
|
// legacy compatibility input/projection
|
|
1472
2047
|
capabilities: ModelCapabilitiesV1Schema.optional(),
|
|
1473
|
-
pricing:
|
|
2048
|
+
pricing: z3.union([ModelPricingSchema, ModelPricingScheduleSchema]).optional(),
|
|
1474
2049
|
// Reserved normalized contracts are derived by OpenGeni in V1. Generic
|
|
1475
2050
|
// registry JSON must not opt itself into workspace BYOK or reattribute cost.
|
|
1476
|
-
credentialSource:
|
|
1477
|
-
billing:
|
|
2051
|
+
credentialSource: z3.never().optional(),
|
|
2052
|
+
billing: z3.never().optional()
|
|
1478
2053
|
}).superRefine((model, ctx) => {
|
|
1479
2054
|
if (model.capabilities && model.reasoningEffort !== void 0 && model.reasoningEffort !== model.capabilities.reasoning.runnable) {
|
|
1480
2055
|
ctx.addIssue({
|
|
@@ -1491,27 +2066,54 @@ var RegistryModelSchema = z.object({
|
|
|
1491
2066
|
});
|
|
1492
2067
|
}
|
|
1493
2068
|
});
|
|
1494
|
-
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({
|
|
1495
2096
|
kind: RegistryProviderKind.default("api-key"),
|
|
1496
|
-
id:
|
|
2097
|
+
id: z3.string().min(1).regex(registryId),
|
|
1497
2098
|
// stable provider id, e.g. "fireworks"
|
|
1498
|
-
label:
|
|
2099
|
+
label: z3.string().min(1).optional(),
|
|
1499
2100
|
api: ModelProviderApi.default("chat"),
|
|
2101
|
+
anthropic: AnthropicProviderOptions.optional(),
|
|
1500
2102
|
wireProfile: ModelProviderWireProfile.default("openai"),
|
|
1501
|
-
baseUrl:
|
|
1502
|
-
apiKey:
|
|
2103
|
+
baseUrl: z3.string().url(),
|
|
2104
|
+
apiKey: z3.string().optional(),
|
|
1503
2105
|
// inline key (pragmatic) ...
|
|
1504
|
-
apiKeyEnv:
|
|
2106
|
+
apiKeyEnv: z3.string().optional(),
|
|
1505
2107
|
// ... OR name of the env var holding the key (preferred)
|
|
1506
|
-
defaultQuery:
|
|
1507
|
-
defaultHeaders:
|
|
1508
|
-
publicDefaultQueryNames:
|
|
1509
|
-
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(),
|
|
1510
2112
|
// V1 derives these from provider kind. Workspace BYOK is deliberately not a
|
|
1511
2113
|
// registry switch and requires a separately reviewed encrypted broker.
|
|
1512
|
-
credentialSource:
|
|
1513
|
-
billing:
|
|
1514
|
-
models:
|
|
2114
|
+
credentialSource: z3.never().optional(),
|
|
2115
|
+
billing: z3.never().optional(),
|
|
2116
|
+
models: z3.array(RegistryModelSchema).min(1)
|
|
1515
2117
|
}).superRefine((provider, ctx) => {
|
|
1516
2118
|
if (provider.kind !== "anonymous") {
|
|
1517
2119
|
return;
|
|
@@ -1581,17 +2183,21 @@ var RESERVED_MODEL_PROVIDER_IDS = /* @__PURE__ */ new Set([
|
|
|
1581
2183
|
ORGANIZATION_GATEWAY_PROVIDER_ID,
|
|
1582
2184
|
OPENROUTER_PROVIDER_ID,
|
|
1583
2185
|
WORKSPACE_OPENROUTER_PROVIDER_ID,
|
|
1584
|
-
ORGANIZATION_OPENROUTER_PROVIDER_ID
|
|
2186
|
+
ORGANIZATION_OPENROUTER_PROVIDER_ID,
|
|
2187
|
+
"organization-anthropic",
|
|
2188
|
+
"organization-claude-subscription",
|
|
2189
|
+
"workspace-anthropic",
|
|
2190
|
+
"workspace-claude-subscription"
|
|
1585
2191
|
]);
|
|
1586
|
-
var ModelCostClass =
|
|
1587
|
-
var ConfiguredModelCostClass =
|
|
2192
|
+
var ModelCostClass = z3.enum(["free", "credits"]);
|
|
2193
|
+
var ConfiguredModelCostClass = z3.enum([
|
|
1588
2194
|
"free",
|
|
1589
2195
|
"credits",
|
|
1590
2196
|
"subscription",
|
|
1591
2197
|
"workspace",
|
|
1592
2198
|
"organization"
|
|
1593
2199
|
]);
|
|
1594
|
-
var ModelNote =
|
|
2200
|
+
var ModelNote = z3.string().max(500).refine((value) => !/[\r\n|]/u.test(value), {
|
|
1595
2201
|
message: "model notes must not contain newlines or the | field separator"
|
|
1596
2202
|
});
|
|
1597
2203
|
function parseModelCostPolicyJson(raw) {
|
|
@@ -1604,7 +2210,7 @@ function parseModelCostPolicyJson(raw) {
|
|
|
1604
2210
|
{ cause: error }
|
|
1605
2211
|
);
|
|
1606
2212
|
}
|
|
1607
|
-
return
|
|
2213
|
+
return z3.record(z3.string().min(1), ModelCostClass).parse(parsed);
|
|
1608
2214
|
}
|
|
1609
2215
|
function parseModelNotesJson(raw) {
|
|
1610
2216
|
let parsed;
|
|
@@ -1616,45 +2222,47 @@ function parseModelNotesJson(raw) {
|
|
|
1616
2222
|
{ cause: error }
|
|
1617
2223
|
);
|
|
1618
2224
|
}
|
|
1619
|
-
return
|
|
2225
|
+
return z3.record(z3.string().min(1), ModelNote).parse(parsed);
|
|
1620
2226
|
}
|
|
1621
2227
|
function configuredModelNotes(settings) {
|
|
1622
2228
|
return parseModelNotesJson(settings.modelNotesJson);
|
|
1623
2229
|
}
|
|
1624
|
-
var GatewayCatalogModel =
|
|
1625
|
-
productId:
|
|
1626
|
-
workspaceProductId:
|
|
1627
|
-
upstreamModelId:
|
|
1628
|
-
label:
|
|
1629
|
-
shortLabel:
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
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()
|
|
1641
2248
|
}).strict();
|
|
1642
|
-
var OpenRouterCatalogModel =
|
|
1643
|
-
upstreamModelId:
|
|
1644
|
-
label:
|
|
1645
|
-
shortLabel:
|
|
1646
|
-
|
|
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([]),
|
|
1647
2255
|
capabilities: ModelCapabilitiesV1Schema,
|
|
1648
|
-
contextWindowTokens:
|
|
1649
|
-
effectiveContextWindowTokens:
|
|
1650
|
-
autoCompactTokenLimit:
|
|
1651
|
-
toolOutputTruncationTokens:
|
|
1652
|
-
credentialSource:
|
|
1653
|
-
billing:
|
|
1654
|
-
pricing:
|
|
1655
|
-
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()
|
|
1656
2264
|
}).strict();
|
|
1657
|
-
var DeploymentRegistryBaseUrl =
|
|
2265
|
+
var DeploymentRegistryBaseUrl = z3.string().url().superRefine((value, context) => {
|
|
1658
2266
|
const url = new URL(value);
|
|
1659
2267
|
if (url.username || url.password) {
|
|
1660
2268
|
context.addIssue({
|
|
@@ -1675,40 +2283,66 @@ var DeploymentRegistryBaseUrl = z.string().url().superRefine((value, context) =>
|
|
|
1675
2283
|
});
|
|
1676
2284
|
}
|
|
1677
2285
|
});
|
|
1678
|
-
var DeploymentRegistryProviderKind =
|
|
2286
|
+
var DeploymentRegistryProviderKind = z3.enum(["api-key", "anonymous"]);
|
|
1679
2287
|
var DeploymentRegistryModelSchema = RegistryModelSchema.safeExtend({
|
|
1680
|
-
pricing:
|
|
2288
|
+
pricing: z3.never().optional()
|
|
1681
2289
|
}).strict();
|
|
1682
2290
|
var DeploymentRegistryProviderSchema = RegistryProviderSchema.safeExtend({
|
|
1683
2291
|
kind: DeploymentRegistryProviderKind.default("api-key"),
|
|
1684
2292
|
baseUrl: DeploymentRegistryBaseUrl,
|
|
1685
|
-
models:
|
|
1686
|
-
apiKey:
|
|
1687
|
-
apiKeyEnv:
|
|
1688
|
-
defaultHeaders:
|
|
1689
|
-
defaultQuery:
|
|
1690
|
-
publicDefaultHeaderNames:
|
|
1691
|
-
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()
|
|
1692
2300
|
}).strict();
|
|
1693
2301
|
var DeploymentGatewayCatalogModelSchema = GatewayCatalogModel.safeExtend({
|
|
1694
|
-
pricing:
|
|
2302
|
+
pricing: z3.never().optional()
|
|
1695
2303
|
}).strict();
|
|
1696
|
-
var
|
|
1697
|
-
|
|
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),
|
|
1698
2324
|
/** Canonical deployment default. Omission preserves the V1 first-built-in
|
|
1699
2325
|
* fallback for existing documents; operators should set this explicitly
|
|
1700
2326
|
* when cutting over a registry or connected-subscription default. */
|
|
1701
|
-
defaultModel:
|
|
1702
|
-
builtInModels:
|
|
1703
|
-
registryProviders:
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
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()
|
|
1711
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
|
+
}
|
|
1712
2346
|
const productIds = /* @__PURE__ */ new Set();
|
|
1713
2347
|
const providerIds = /* @__PURE__ */ new Set();
|
|
1714
2348
|
const gatewayUpstreamIds = /* @__PURE__ */ new Set();
|
|
@@ -1730,8 +2364,16 @@ var ModelCatalogDocument = z.object({
|
|
|
1730
2364
|
productIds.add(id);
|
|
1731
2365
|
};
|
|
1732
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
|
+
}
|
|
1733
2375
|
document.registryProviders.forEach((provider, providerIndex) => {
|
|
1734
|
-
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-")) {
|
|
1735
2377
|
context.addIssue({
|
|
1736
2378
|
code: "custom",
|
|
1737
2379
|
path: ["registryProviders", providerIndex, "id"],
|
|
@@ -1776,7 +2418,7 @@ var ModelCatalogDocument = z.object({
|
|
|
1776
2418
|
message: "catalog default model must not contain newlines or the | field separator"
|
|
1777
2419
|
});
|
|
1778
2420
|
}
|
|
1779
|
-
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)) {
|
|
1780
2422
|
context.addIssue({
|
|
1781
2423
|
code: "custom",
|
|
1782
2424
|
path: ["defaultModel"],
|
|
@@ -1846,15 +2488,19 @@ function applyModelCatalogDocument(settings, rawDocument) {
|
|
|
1846
2488
|
),
|
|
1847
2489
|
resolvedGatewayModelsJson: JSON.stringify(document.gatewayModels),
|
|
1848
2490
|
resolvedOpenRouterModelsJson: JSON.stringify(document.openrouterModels),
|
|
2491
|
+
resolvedCodexModelsJson: document.codexModels === void 0 ? void 0 : JSON.stringify(document.codexModels),
|
|
1849
2492
|
modelNotesJson: JSON.stringify(document.modelNotes)
|
|
1850
2493
|
};
|
|
1851
2494
|
return resolved;
|
|
1852
2495
|
}
|
|
1853
|
-
var IntegrationOAuthClientConfigSchema =
|
|
1854
|
-
clientId:
|
|
1855
|
-
clientSecret:
|
|
1856
|
-
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")
|
|
1857
2500
|
});
|
|
2501
|
+
function isManagedOpenRouterFreeRoute(route) {
|
|
2502
|
+
return route.provider.kind === "openrouter-managed" && route.configured.upstreamModelId.endsWith(":free");
|
|
2503
|
+
}
|
|
1858
2504
|
var VERCEL_AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh/v1";
|
|
1859
2505
|
var VERCEL_AI_GATEWAY_AI_SDK_BASE_URL = "https://ai-gateway.vercel.sh/v4/ai";
|
|
1860
2506
|
var VERCEL_AI_GATEWAY_CONNECTION_DOMAIN = "ai-gateway.vercel.sh";
|
|
@@ -1981,7 +2627,7 @@ function configuredGatewayCatalogModels(settings) {
|
|
|
1981
2627
|
if (settings.resolvedGatewayModelsJson === void 0) {
|
|
1982
2628
|
return defaultGatewayCatalogModels();
|
|
1983
2629
|
}
|
|
1984
|
-
return
|
|
2630
|
+
return z3.array(GatewayCatalogModel).parse(JSON.parse(settings.resolvedGatewayModelsJson));
|
|
1985
2631
|
}
|
|
1986
2632
|
function configuredGatewayUpstreamModelIds(settings) {
|
|
1987
2633
|
return configuredGatewayCatalogModels(settings).map((model) => model.upstreamModelId);
|
|
@@ -2000,7 +2646,7 @@ function configuredOpenRouterCatalogModels(settings) {
|
|
|
2000
2646
|
if (settings.resolvedOpenRouterModelsJson === void 0) {
|
|
2001
2647
|
return [...OPENGENI_OPENROUTER_MODELS];
|
|
2002
2648
|
}
|
|
2003
|
-
return
|
|
2649
|
+
return z3.array(OpenRouterCatalogModel).parse(JSON.parse(settings.resolvedOpenRouterModelsJson));
|
|
2004
2650
|
}
|
|
2005
2651
|
function configuredOpenRouterUpstreamModelIds(settings) {
|
|
2006
2652
|
return configuredOpenRouterCatalogModels(settings).map((model) => model.upstreamModelId);
|
|
@@ -2018,6 +2664,73 @@ function configuredOpenRouterOrganizationProductModelIds(settings) {
|
|
|
2018
2664
|
return [];
|
|
2019
2665
|
}
|
|
2020
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
|
+
},
|
|
2021
2734
|
"gpt-5.6-sol": {
|
|
2022
2735
|
default: {
|
|
2023
2736
|
// Promotional OpenAI pricing, guaranteed through at least 2026-11-21.
|
|
@@ -2117,6 +2830,103 @@ var defaultModelPricing = {
|
|
|
2117
2830
|
}
|
|
2118
2831
|
}
|
|
2119
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
|
+
};
|
|
2120
2930
|
var SANDBOX_REQUIRED_ENV = {
|
|
2121
2931
|
// docker/local/none need no credentials (local dev container / in-process / off).
|
|
2122
2932
|
docker: [],
|
|
@@ -2176,6 +2986,7 @@ function optionalEnvironmentValue(name, source) {
|
|
|
2176
2986
|
const value = source[name];
|
|
2177
2987
|
return value && value.trim().length > 0 ? value : void 0;
|
|
2178
2988
|
}
|
|
2989
|
+
var idleCommandContainmentDisabledWarned = false;
|
|
2179
2990
|
function getSettings(source = process.env) {
|
|
2180
2991
|
const optional = (name) => optionalEnvironmentValue(name, source);
|
|
2181
2992
|
const modelCatalogSource = optional("OPENGENI_MODEL_CATALOG_SOURCE");
|
|
@@ -2186,6 +2997,7 @@ function getSettings(source = process.env) {
|
|
|
2186
2997
|
deploymentRevision: optional("OPENGENI_DEPLOYMENT_REVISION") ?? optional("SOURCE_VERSION") ?? optional("GITHUB_SHA"),
|
|
2187
2998
|
serverVersion: optional("OPENGENI_SERVER_VERSION"),
|
|
2188
2999
|
databaseUrl: optional("OPENGENI_DATABASE_URL"),
|
|
3000
|
+
apiDatabasePoolMax: optional("OPENGENI_API_DATABASE_POOL_MAX"),
|
|
2189
3001
|
dbSchema: optional("OPENGENI_DB_SCHEMA"),
|
|
2190
3002
|
rlsStrategy: optional("OPENGENI_RLS_STRATEGY"),
|
|
2191
3003
|
runtimeDatabaseRole: optional("OPENGENI_RUNTIME_DATABASE_ROLE"),
|
|
@@ -2217,26 +3029,33 @@ function getSettings(source = process.env) {
|
|
|
2217
3029
|
observabilityMetricsEnabled: optional("OPENGENI_OBSERVABILITY_METRICS_ENABLED"),
|
|
2218
3030
|
observabilityOtlpEndpoint: optional("OPENGENI_OTEL_EXPORTER_OTLP_ENDPOINT") ?? optional("OTEL_EXPORTER_OTLP_ENDPOINT"),
|
|
2219
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"),
|
|
2220
3034
|
analyticsEnabled: optional("OPENGENI_ANALYTICS_ENABLED"),
|
|
2221
3035
|
analyticsConsentRequired: optional("OPENGENI_ANALYTICS_CONSENT_REQUIRED"),
|
|
2222
3036
|
analyticsReoClientId: optional("OPENGENI_ANALYTICS_REO_CLIENT_ID"),
|
|
2223
3037
|
analyticsPosthogProjectKey: optional("OPENGENI_ANALYTICS_POSTHOG_PROJECT_KEY"),
|
|
2224
3038
|
analyticsPosthogHost: optional("OPENGENI_ANALYTICS_POSTHOG_HOST"),
|
|
2225
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"),
|
|
2226
3043
|
publicBaseUrl: optional("OPENGENI_PUBLIC_BASE_URL"),
|
|
3044
|
+
documentationUrl: optional("OPENGENI_DOCUMENTATION_URL"),
|
|
2227
3045
|
mcpOauthEnabled: optional("OPENGENI_MCP_OAUTH_ENABLED"),
|
|
2228
|
-
|
|
3046
|
+
apiTrustedProxyHops: optional("OPENGENI_API_TRUSTED_PROXY_HOPS"),
|
|
3047
|
+
apiTrustedProxyCidrs: optional("OPENGENI_API_TRUSTED_PROXY_CIDRS"),
|
|
2229
3048
|
webBaseUrl: optional("OPENGENI_WEB_BASE_URL"),
|
|
2230
3049
|
agentReleasesBaseUrl: optional("OPENGENI_AGENT_RELEASES_BASE_URL"),
|
|
2231
3050
|
agentStableVersion: optional("OPENGENI_AGENT_STABLE_VERSION"),
|
|
2232
3051
|
agentBetaVersion: optional("OPENGENI_AGENT_BETA_VERSION"),
|
|
2233
3052
|
productAccessMode: optional("OPENGENI_PRODUCT_ACCESS_MODE"),
|
|
2234
|
-
organizationTenancyCanonicalActivationEnabled: optional(
|
|
2235
|
-
"OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED"
|
|
2236
|
-
),
|
|
2237
3053
|
billingMode: optional("OPENGENI_BILLING_MODE"),
|
|
3054
|
+
verifiedSignupTrialCreditsEnabled: optional("OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED"),
|
|
3055
|
+
creditPromotionPolicy: optional("OPENGENI_CREDIT_PROMOTION_POLICY_JSON"),
|
|
2238
3056
|
entitlementsMode: optional("OPENGENI_ENTITLEMENTS_MODE"),
|
|
2239
3057
|
usageLimitsMode: optional("OPENGENI_USAGE_LIMITS_MODE"),
|
|
3058
|
+
usageAllowancesEnabled: optional("OPENGENI_USAGE_ALLOWANCES_ENABLED"),
|
|
2240
3059
|
staticEntitlementsJson: optional("OPENGENI_STATIC_ENTITLEMENTS_JSON"),
|
|
2241
3060
|
staticUsageLimitsJson: optional("OPENGENI_STATIC_USAGE_LIMITS_JSON"),
|
|
2242
3061
|
delegationSecret: optional("OPENGENI_DELEGATION_SECRET"),
|
|
@@ -2256,13 +3075,16 @@ function getSettings(source = process.env) {
|
|
|
2256
3075
|
environmentsEncryptionKey: optional("OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY"),
|
|
2257
3076
|
integrationsEnabled: optional("OPENGENI_INTEGRATIONS_ENABLED"),
|
|
2258
3077
|
integrationsStateSecret: optional("OPENGENI_INTEGRATIONS_STATE_SECRET"),
|
|
3078
|
+
integrationsOauthShortStateEnabled: optional("OPENGENI_INTEGRATIONS_OAUTH_SHORT_STATE_ENABLED"),
|
|
2259
3079
|
integrationsAllowPrivateNetworkTargets: optional(
|
|
2260
3080
|
"OPENGENI_INTEGRATIONS_ALLOW_PRIVATE_NETWORK_TARGETS"
|
|
2261
3081
|
),
|
|
2262
3082
|
integrationsOauthClientsJson: optional("OPENGENI_INTEGRATIONS_OAUTH_CLIENTS_JSON"),
|
|
3083
|
+
gmailWatchTopicName: optional("OPENGENI_GMAIL_WATCH_TOPIC_NAME"),
|
|
2263
3084
|
slackClientId: optional("OPENGENI_SLACK_CLIENT_ID"),
|
|
2264
3085
|
slackClientSecret: optional("OPENGENI_SLACK_CLIENT_SECRET"),
|
|
2265
3086
|
slackSigningSecret: optional("OPENGENI_SLACK_SIGNING_SECRET"),
|
|
3087
|
+
slackAccessMode: optional("OPENGENI_SLACK_ACCESS_MODE"),
|
|
2266
3088
|
slackBotDisplayName: optional("OPENGENI_SLACK_BOT_DISPLAY_NAME"),
|
|
2267
3089
|
slackCommand: optional("OPENGENI_SLACK_COMMAND"),
|
|
2268
3090
|
googleDriveClientId: optional("OPENGENI_GOOGLE_DRIVE_CLIENT_ID"),
|
|
@@ -2297,10 +3119,6 @@ function getSettings(source = process.env) {
|
|
|
2297
3119
|
goalIdleBackoffMs: optional("OPENGENI_GOAL_IDLE_BACKOFF_MS"),
|
|
2298
3120
|
goalIdleBackoffMaxMs: optional("OPENGENI_GOAL_IDLE_BACKOFF_MAX_MS"),
|
|
2299
3121
|
childLifecycleNoticesEnabled: optional("OPENGENI_CHILD_LIFECYCLE_NOTICES_ENABLED"),
|
|
2300
|
-
hostMcpAuthoritySourceAdmissionEnabled: optional(
|
|
2301
|
-
"OPENGENI_HOST_MCP_AUTHORITY_SOURCE_ADMISSION_ENABLED"
|
|
2302
|
-
),
|
|
2303
|
-
hostMcpCredentialResolversJson: optional("OPENGENI_HOST_MCP_CREDENTIAL_RESOLVERS_JSON"),
|
|
2304
3122
|
slackWorkspaceRoutingEnabled: optional("OPENGENI_SLACK_WORKSPACE_ROUTING_ENABLED"),
|
|
2305
3123
|
agentMaxModelCallsPerTurn: optional("OPENGENI_AGENT_MAX_MODEL_CALLS_PER_TURN"),
|
|
2306
3124
|
contextWindowTokens: optional("OPENGENI_CONTEXT_WINDOW_TOKENS"),
|
|
@@ -2315,10 +3133,12 @@ function getSettings(source = process.env) {
|
|
|
2315
3133
|
authAllowMetrics: optional("OPENGENI_AUTH_ALLOW_METRICS"),
|
|
2316
3134
|
apiHost: optional("OPENGENI_API_HOST"),
|
|
2317
3135
|
apiPort: optional("OPENGENI_API_PORT"),
|
|
3136
|
+
apiMetricsPort: optional("OPENGENI_API_METRICS_PORT"),
|
|
2318
3137
|
workerHttpPort: optional("OPENGENI_WORKER_HTTP_PORT"),
|
|
2319
3138
|
opengeniMcpInternalUrl: optional("OPENGENI_MCP_INTERNAL_URL"),
|
|
2320
3139
|
opengeniMcpUrl: optional("OPENGENI_MCP_URL"),
|
|
2321
3140
|
corsAllowOriginRegex: optional("OPENGENI_CORS_ALLOW_ORIGIN_REGEX"),
|
|
3141
|
+
localAllowedOrigins: optional("OPENGENI_LOCAL_ALLOWED_ORIGINS"),
|
|
2322
3142
|
openaiProvider: optional("OPENGENI_OPENAI_PROVIDER"),
|
|
2323
3143
|
openaiApiKey: optional("OPENGENI_OPENAI_API_KEY") ?? optional("OPENAI_API_KEY"),
|
|
2324
3144
|
openaiBaseUrl: optional("OPENGENI_OPENAI_BASE_URL") ?? optional("OPENAI_BASE_URL"),
|
|
@@ -2377,6 +3197,7 @@ function getSettings(source = process.env) {
|
|
|
2377
3197
|
modelProvidersJson: optional("OPENGENI_MODEL_PROVIDERS_JSON"),
|
|
2378
3198
|
codexSubscriptionEnabled: optional("OPENGENI_CODEX_SUBSCRIPTION_ENABLED"),
|
|
2379
3199
|
supergrokSubscriptionEnabled: optional("OPENGENI_SUPERGROK_SUBSCRIPTION_ENABLED"),
|
|
3200
|
+
claudeSubscriptionEnabled: optional("OPENGENI_CLAUDE_SUBSCRIPTION_ENABLED"),
|
|
2380
3201
|
supergrokResponseStreamIdleTimeoutMs: optional(
|
|
2381
3202
|
"OPENGENI_SUPERGROK_RESPONSE_STREAM_IDLE_TIMEOUT_MS"
|
|
2382
3203
|
),
|
|
@@ -2385,13 +3206,23 @@ function getSettings(source = process.env) {
|
|
|
2385
3206
|
lazyToolSearchEnabled: optional("OPENGENI_LAZY_TOOL_SEARCH_ENABLED"),
|
|
2386
3207
|
codexFleetPolicyShadowEnabled: optional("OPENGENI_CODEX_FLEET_POLICY_SHADOW_ENABLED"),
|
|
2387
3208
|
codexProductSku: optional("OPENGENI_CODEX_PRODUCT_SKU"),
|
|
3209
|
+
reasoningConfigurationUpdatesEnabled: optional(
|
|
3210
|
+
"OPENGENI_REASONING_CONFIGURATION_UPDATES_ENABLED"
|
|
3211
|
+
),
|
|
2388
3212
|
openaiReasoningEffort: optional("OPENGENI_OPENAI_REASONING_EFFORT"),
|
|
2389
3213
|
openaiAllowedReasoningEfforts: optional("OPENGENI_OPENAI_ALLOWED_REASONING_EFFORTS"),
|
|
3214
|
+
creditsDefaultModel: optional("OPENGENI_CREDITS_DEFAULT_MODEL"),
|
|
3215
|
+
creditsDefaultReasoningEffort: optional("OPENGENI_CREDITS_DEFAULT_REASONING_EFFORT"),
|
|
2390
3216
|
openaiResponsesTransport: optional("OPENGENI_OPENAI_RESPONSES_TRANSPORT"),
|
|
2391
3217
|
openaiProviderItemIds: optional("OPENGENI_OPENAI_PROVIDER_ITEM_IDS"),
|
|
2392
3218
|
openaiReasoningEncryptedContent: optional("OPENGENI_OPENAI_REASONING_ENCRYPTED_CONTENT"),
|
|
2393
3219
|
openaiMaxRetries: optional("OPENGENI_OPENAI_MAX_RETRIES"),
|
|
2394
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"),
|
|
2395
3226
|
agentInstructionsTemplate: optional("OPENGENI_AGENT_INSTRUCTIONS_TEMPLATE"),
|
|
2396
3227
|
azureOpenaiBaseUrl: optional("OPENGENI_AZURE_OPENAI_BASE_URL"),
|
|
2397
3228
|
azureOpenaiEndpoint: optional("OPENGENI_AZURE_OPENAI_ENDPOINT"),
|
|
@@ -2408,6 +3239,7 @@ function getSettings(source = process.env) {
|
|
|
2408
3239
|
dockerWorkspaceBaseDir: optional("OPENGENI_DOCKER_WORKSPACE_BASE_DIR"),
|
|
2409
3240
|
modalAppName: optional("OPENGENI_MODAL_APP_NAME"),
|
|
2410
3241
|
modalImageRef: optional("OPENGENI_MODAL_IMAGE_REF") ?? DEFAULT_MODAL_IMAGE_REF,
|
|
3242
|
+
modalCommandSupervisionEnabled: optional("OPENGENI_MODAL_COMMAND_SUPERVISION_ENABLED"),
|
|
2411
3243
|
modalImageId: optional("OPENGENI_MODAL_IMAGE_ID"),
|
|
2412
3244
|
modalImageRegistrySecret: optional("OPENGENI_MODAL_IMAGE_REGISTRY_SECRET"),
|
|
2413
3245
|
modalTimeoutSeconds: optional("OPENGENI_MODAL_TIMEOUT_SECONDS"),
|
|
@@ -2459,6 +3291,9 @@ function getSettings(source = process.env) {
|
|
|
2459
3291
|
blaxelTtl: optional("OPENGENI_BLAXEL_TTL"),
|
|
2460
3292
|
cloudflareWorkerUrl: optional("OPENGENI_CLOUDFLARE_WORKER_URL"),
|
|
2461
3293
|
cloudflareApiKey: optional("OPENGENI_CLOUDFLARE_API_KEY"),
|
|
3294
|
+
experimentalBrowserContextPoolEnabled: optional(
|
|
3295
|
+
"OPENGENI_EXPERIMENTAL_BROWSER_CONTEXT_POOL_ENABLED"
|
|
3296
|
+
),
|
|
2462
3297
|
browserbaseApiKey: optional("OPENGENI_BROWSERBASE_API_KEY"),
|
|
2463
3298
|
kernelApiKey: optional("OPENGENI_KERNEL_API_KEY"),
|
|
2464
3299
|
kernelEndpoint: optional("OPENGENI_KERNEL_ENDPOINT"),
|
|
@@ -2507,6 +3342,7 @@ function getSettings(source = process.env) {
|
|
|
2507
3342
|
sandboxViewerHolderTtlMs: optional("OPENGENI_SANDBOX_VIEWER_HOLDER_TTL_MS"),
|
|
2508
3343
|
sandboxInteractionHolderTtlMs: optional("OPENGENI_SANDBOX_INTERACTION_HOLDER_TTL_MS"),
|
|
2509
3344
|
sandboxIdleGraceMs: optional("OPENGENI_SANDBOX_IDLE_GRACE_MS"),
|
|
3345
|
+
sandboxIdleCommandContainmentMs: optional("OPENGENI_SANDBOX_IDLE_COMMAND_CONTAINMENT_MS"),
|
|
2510
3346
|
sandboxSnapshotIntervalMs: optional("OPENGENI_SANDBOX_SNAPSHOT_INTERVAL_MS"),
|
|
2511
3347
|
sandboxSnapshotTimeoutMs: optional("OPENGENI_SANDBOX_SNAPSHOT_TIMEOUT_MS"),
|
|
2512
3348
|
sandboxDrainSnapshotTimeoutMs: optional("OPENGENI_SANDBOX_DRAIN_SNAPSHOT_TIMEOUT_MS"),
|
|
@@ -2520,9 +3356,11 @@ function getSettings(source = process.env) {
|
|
|
2520
3356
|
sandboxWarmRateMicrosPerSecondJson: optional(
|
|
2521
3357
|
"OPENGENI_SANDBOX_WARM_RATE_MICROS_PER_SECOND_JSON"
|
|
2522
3358
|
),
|
|
3359
|
+
sandboxWarmBillingMode: optional("OPENGENI_SANDBOX_WARM_BILLING_MODE"),
|
|
2523
3360
|
sandboxMaxWarmSecondsPerWorkspace: optional("OPENGENI_SANDBOX_MAX_WARM_SECONDS_PER_WORKSPACE"),
|
|
2524
3361
|
sandboxPreparationProfiles: optional("OPENGENI_SANDBOX_PREPARATION_PROFILES"),
|
|
2525
3362
|
sandboxEnvAllowlist: optional("OPENGENI_SANDBOX_ENV_ALLOWLIST"),
|
|
3363
|
+
sandboxImageAllowlist: optional("OPENGENI_SANDBOX_IMAGE_ALLOWLIST"),
|
|
2526
3364
|
objectStorageEndpoint: optional("OPENGENI_OBJECT_STORAGE_ENDPOINT"),
|
|
2527
3365
|
objectStorageInternalEndpoint: optional("OPENGENI_OBJECT_STORAGE_INTERNAL_ENDPOINT"),
|
|
2528
3366
|
objectStorageSandboxEndpoint: optional("OPENGENI_OBJECT_STORAGE_SANDBOX_ENDPOINT"),
|
|
@@ -2549,6 +3387,13 @@ function getSettings(source = process.env) {
|
|
|
2549
3387
|
documentEmbeddingDimensions: optional("OPENGENI_DOCUMENT_EMBEDDING_DIMENSIONS"),
|
|
2550
3388
|
documentEmbeddingApiKey: optional("OPENGENI_DOCUMENT_EMBEDDING_API_KEY"),
|
|
2551
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
|
+
),
|
|
2552
3397
|
documentCurationProvider: optional("OPENGENI_DOCUMENT_CURATION_PROVIDER"),
|
|
2553
3398
|
documentCurationModel: optional("OPENGENI_DOCUMENT_CURATION_MODEL"),
|
|
2554
3399
|
documentCurationApiKey: optional("OPENGENI_DOCUMENT_CURATION_API_KEY"),
|
|
@@ -2583,7 +3428,9 @@ function getSettings(source = process.env) {
|
|
|
2583
3428
|
managedAuthGoogleClientSecret: optional("OPENGENI_MANAGED_AUTH_GOOGLE_CLIENT_SECRET"),
|
|
2584
3429
|
managedAuthGithubClientId: optional("OPENGENI_MANAGED_AUTH_GITHUB_CLIENT_ID"),
|
|
2585
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()),
|
|
2586
3432
|
managedAuthSessionSetMode: optional("OPENGENI_MANAGED_AUTH_SESSION_SET_MODE"),
|
|
3433
|
+
managedAuthNewSignupsEnabled: optional("OPENGENI_MANAGED_AUTH_NEW_SIGNUPS_ENABLED"),
|
|
2587
3434
|
organizationUserSetupEmailTokenTransport: optional(
|
|
2588
3435
|
"OPENGENI_ORGANIZATION_USER_SETUP_EMAIL_TOKEN_TRANSPORT"
|
|
2589
3436
|
),
|
|
@@ -2602,11 +3449,53 @@ function getSettings(source = process.env) {
|
|
|
2602
3449
|
const settings = {
|
|
2603
3450
|
...parsed,
|
|
2604
3451
|
sandboxIdleGraceMs: raw.sandboxIdleGraceMs === void 0 && parsed.sandboxBackend === "modal" ? Math.min(9e5, Math.floor(parsed.modalTimeoutSeconds * 1e3 / 2)) : parsed.sandboxIdleGraceMs,
|
|
2605
|
-
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,
|
|
2606
3464
|
mcpServers: ensureBuiltInMcpServers(parsed)
|
|
2607
3465
|
};
|
|
2608
|
-
|
|
2609
|
-
|
|
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);
|
|
3488
|
+
validateSettings(settings, source);
|
|
3489
|
+
return settings;
|
|
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
|
+
);
|
|
2610
3499
|
}
|
|
2611
3500
|
var LOCAL_FIRST_PARTY_DELEGATION_SECRET = "opengeni-local-first-party-delegation-secret-v1";
|
|
2612
3501
|
function resolveFirstPartyDelegationSecret(settings) {
|
|
@@ -2619,20 +3508,24 @@ function resolveFirstPartyDelegationSecret(settings) {
|
|
|
2619
3508
|
return settings.productAccessMode === "local" && (settings.environment === "local" || settings.environment === "test") ? LOCAL_FIRST_PARTY_DELEGATION_SECRET : void 0;
|
|
2620
3509
|
}
|
|
2621
3510
|
function resolveFirstPartyMcpToolPolicy(settings) {
|
|
2622
|
-
const
|
|
2623
|
-
|
|
2624
|
-
|
|
3511
|
+
const allowed2 = currentAgentLearningToolSelection(
|
|
3512
|
+
settings.allowedFirstPartyMcpTools ?? [...FIRST_PARTY_MCP_TOOL_NAMES]
|
|
3513
|
+
).filter((tool) => !isRetiredNativeAtlassianTool(tool));
|
|
3514
|
+
const allowedSet = new Set(allowed2);
|
|
3515
|
+
const defaults = currentAgentLearningToolSelection(
|
|
3516
|
+
settings.defaultFirstPartyMcpTools ?? [...DEFAULT_FIRST_PARTY_MCP_TOOLS]
|
|
3517
|
+
);
|
|
2625
3518
|
return {
|
|
2626
3519
|
default: defaults.filter((tool) => allowedSet.has(tool)),
|
|
2627
|
-
allowed: [...
|
|
3520
|
+
allowed: [...allowed2]
|
|
2628
3521
|
};
|
|
2629
3522
|
}
|
|
2630
3523
|
function allowedFirstPartyMcpToolsForSession(settings, selected) {
|
|
2631
3524
|
const policy = resolveFirstPartyMcpToolPolicy(settings);
|
|
2632
|
-
const
|
|
2633
|
-
const tools = new Set(selected ?? policy.default);
|
|
3525
|
+
const allowed2 = new Set(policy.allowed);
|
|
3526
|
+
const tools = new Set(currentAgentLearningToolSelection(selected ?? policy.default));
|
|
2634
3527
|
if (tools.has("goal_pause")) tools.add("goal_resume");
|
|
2635
|
-
return [...tools].filter((tool) =>
|
|
3528
|
+
return [...tools].filter((tool) => allowed2.has(tool));
|
|
2636
3529
|
}
|
|
2637
3530
|
function effectiveModalIdleTimeoutSeconds(settings) {
|
|
2638
3531
|
return settings.modalIdleTimeoutSeconds ?? settings.modalTimeoutSeconds;
|
|
@@ -2998,6 +3891,7 @@ function gatewayRegistryProvider(settings, input) {
|
|
|
2998
3891
|
upstreamModelId: model.upstreamModelId,
|
|
2999
3892
|
label: model.label,
|
|
3000
3893
|
...model.shortLabel ? { shortLabel: model.shortLabel } : {},
|
|
3894
|
+
...model.logoUrl ? { logoUrl: model.logoUrl } : {},
|
|
3001
3895
|
capabilities: gatewayModelCapabilities(settings, {
|
|
3002
3896
|
implicitCaching: model.implicitCaching,
|
|
3003
3897
|
vision: model.vision,
|
|
@@ -3070,6 +3964,7 @@ function openRouterRegistryProvider(settings, input) {
|
|
|
3070
3964
|
aliases,
|
|
3071
3965
|
label: model.label,
|
|
3072
3966
|
...model.shortLabel ? { shortLabel: model.shortLabel } : {},
|
|
3967
|
+
...model.logoUrl ? { logoUrl: model.logoUrl } : {},
|
|
3073
3968
|
capabilities: model.capabilities,
|
|
3074
3969
|
...model.contextWindowTokens === void 0 ? {} : { contextWindowTokens: model.contextWindowTokens },
|
|
3075
3970
|
...model.effectiveContextWindowTokens === void 0 ? {} : { effectiveContextWindowTokens: model.effectiveContextWindowTokens },
|
|
@@ -3113,7 +4008,9 @@ function openRouterRegistryProvider(settings, input) {
|
|
|
3113
4008
|
}
|
|
3114
4009
|
function configuredRegistryProviders(settings) {
|
|
3115
4010
|
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
3116
|
-
const injected =
|
|
4011
|
+
const injected = providers.filter(
|
|
4012
|
+
(provider) => settings.claudeSubscriptionEnabled || !(provider.api === "anthropic-messages" && provider.anthropic?.auth === "oauth")
|
|
4013
|
+
);
|
|
3117
4014
|
if (settings.vercelAiGatewayApiKey && configuredGatewayCatalogModels(settings).length > 0) {
|
|
3118
4015
|
injected.push(
|
|
3119
4016
|
gatewayRegistryProvider(settings, {
|
|
@@ -3129,6 +4026,37 @@ function configuredRegistryProviders(settings) {
|
|
|
3129
4026
|
if (openrouter) injected.push(openrouter);
|
|
3130
4027
|
return injected;
|
|
3131
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
|
+
}
|
|
3132
4060
|
function withWorkspaceGatewayCatalogProvider(settings, customModels = []) {
|
|
3133
4061
|
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
3134
4062
|
const withoutWorkspace = providers.filter(
|
|
@@ -3241,8 +4169,8 @@ function productLabelForModelId(modelId) {
|
|
|
3241
4169
|
function productShortLabelForModelId(modelId) {
|
|
3242
4170
|
const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
|
|
3243
4171
|
switch (slug) {
|
|
3244
|
-
case "grok-4.
|
|
3245
|
-
return "4.
|
|
4172
|
+
case "grok-4.7":
|
|
4173
|
+
return "4.7";
|
|
3246
4174
|
case "gpt-5.6-sol":
|
|
3247
4175
|
return "5.6 Sol";
|
|
3248
4176
|
case "gpt-5.6-terra":
|
|
@@ -3251,6 +4179,10 @@ function productShortLabelForModelId(modelId) {
|
|
|
3251
4179
|
return "5.6 Luna";
|
|
3252
4180
|
case "gpt-6-astra":
|
|
3253
4181
|
return "6 Astra";
|
|
4182
|
+
case "gpt-6-sol":
|
|
4183
|
+
return "6 Sol";
|
|
4184
|
+
case "gpt-6-luna":
|
|
4185
|
+
return "6 Luna";
|
|
3254
4186
|
default:
|
|
3255
4187
|
return null;
|
|
3256
4188
|
}
|
|
@@ -3270,7 +4202,7 @@ function builtinContextLimitsForModel(settings, modelId) {
|
|
|
3270
4202
|
return { contextWindowTokens: settings.contextWindowTokens };
|
|
3271
4203
|
}
|
|
3272
4204
|
function builtinLatencyModesForModel(modelId) {
|
|
3273
|
-
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)) {
|
|
3274
4206
|
return [
|
|
3275
4207
|
{ id: "standard", upstream: "supported", runnable: true },
|
|
3276
4208
|
{
|
|
@@ -3283,12 +4215,26 @@ function builtinLatencyModesForModel(modelId) {
|
|
|
3283
4215
|
}
|
|
3284
4216
|
return [{ id: "standard", upstream: "unknown", runnable: true }];
|
|
3285
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
|
+
}
|
|
3286
4232
|
function builtinPromptCachingForModel(modelId) {
|
|
3287
4233
|
const slug = modelId.startsWith(CODEX_MODEL_ID_PREFIX) ? modelId.slice(CODEX_MODEL_ID_PREFIX.length) : modelId;
|
|
3288
|
-
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;
|
|
3289
4235
|
}
|
|
3290
4236
|
function builtinHostedImageGenerationForModel(settings, modelId) {
|
|
3291
|
-
return settings.openaiProvider === "openai" && isDirectOpenAiApiBaseUrl(settings.openaiBaseUrl) && isBuiltinGpt56ModelId(modelId);
|
|
4237
|
+
return settings.openaiProvider === "openai" && isDirectOpenAiApiBaseUrl(settings.openaiBaseUrl) && (isBuiltinGpt56ModelId(modelId) || modelId.startsWith("gpt-6-"));
|
|
3292
4238
|
}
|
|
3293
4239
|
function isDirectOpenAiApiBaseUrl(baseUrl) {
|
|
3294
4240
|
if (baseUrl === void 0) return true;
|
|
@@ -3327,11 +4273,21 @@ function runnableLatencyModesForModel(settings, modelId) {
|
|
|
3327
4273
|
function assertLatencyModeRunnable(settings, modelId, latencyMode) {
|
|
3328
4274
|
const runnable = runnableLatencyModesForModel(settings, modelId);
|
|
3329
4275
|
if (!runnable.includes(latencyMode)) {
|
|
3330
|
-
throw new
|
|
3331
|
-
`latency mode ${latencyMode} is not runnable for model ${modelId} (allowed: ${runnable.join(", ")})`
|
|
3332
|
-
);
|
|
4276
|
+
throw new UnsupportedLatencyModeError(modelId, latencyMode, runnable);
|
|
3333
4277
|
}
|
|
3334
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
|
+
};
|
|
3335
4291
|
function registryCredentialSource(provider) {
|
|
3336
4292
|
switch (provider.kind) {
|
|
3337
4293
|
case "anonymous":
|
|
@@ -3340,10 +4296,17 @@ function registryCredentialSource(provider) {
|
|
|
3340
4296
|
return { kind: "connected_subscription", provider: "codex" };
|
|
3341
4297
|
case "xai-subscription":
|
|
3342
4298
|
return { kind: "connected_subscription", provider: "xai" };
|
|
4299
|
+
case "claude-subscription-workspace":
|
|
4300
|
+
case "claude-subscription-organization":
|
|
4301
|
+
return { kind: "connected_subscription", provider: "claude" };
|
|
3343
4302
|
case "vercel-gateway-workspace":
|
|
4303
|
+
case "direct-openai-workspace":
|
|
4304
|
+
case "direct-azure-workspace":
|
|
3344
4305
|
case "openrouter-workspace":
|
|
4306
|
+
case "anthropic-workspace":
|
|
3345
4307
|
return { kind: "workspace_connection", mechanism: "api_key" };
|
|
3346
4308
|
case "vercel-gateway-organization":
|
|
4309
|
+
case "anthropic-organization":
|
|
3347
4310
|
case "openrouter-organization":
|
|
3348
4311
|
return { kind: "organization_connection", mechanism: "api_key" };
|
|
3349
4312
|
case "api-key":
|
|
@@ -3363,11 +4326,17 @@ function registryBilling(provider) {
|
|
|
3363
4326
|
return { upstreamPayer: "deployment", metering: "external" };
|
|
3364
4327
|
case "codex-subscription":
|
|
3365
4328
|
case "xai-subscription":
|
|
4329
|
+
case "claude-subscription-workspace":
|
|
4330
|
+
case "claude-subscription-organization":
|
|
3366
4331
|
return { upstreamPayer: "connected_subscription", metering: "external" };
|
|
3367
4332
|
case "vercel-gateway-workspace":
|
|
4333
|
+
case "direct-openai-workspace":
|
|
4334
|
+
case "direct-azure-workspace":
|
|
3368
4335
|
case "openrouter-workspace":
|
|
4336
|
+
case "anthropic-workspace":
|
|
3369
4337
|
return { upstreamPayer: "workspace", metering: "external" };
|
|
3370
4338
|
case "vercel-gateway-organization":
|
|
4339
|
+
case "anthropic-organization":
|
|
3371
4340
|
case "openrouter-organization":
|
|
3372
4341
|
return { upstreamPayer: "organization", metering: "external" };
|
|
3373
4342
|
case "api-key":
|
|
@@ -3398,6 +4367,9 @@ function staticRequestMetadataForDigest(provider) {
|
|
|
3398
4367
|
const publicHeaders = new Set(provider.publicDefaultHeaderNames ?? []);
|
|
3399
4368
|
const publicQuery = new Set(provider.publicDefaultQueryNames ?? []);
|
|
3400
4369
|
return {
|
|
4370
|
+
...provider.anthropic ? {
|
|
4371
|
+
anthropic: (({ identity: _identity, credentialBinding: _binding, ...options }) => options)(provider.anthropic)
|
|
4372
|
+
} : {},
|
|
3401
4373
|
headers: Object.entries(provider.defaultHeaders ?? {}).sort(([left], [right]) => left.localeCompare(right)).map(
|
|
3402
4374
|
([name, value]) => publicHeaders.has(name) ? { name, classification: "public", value } : { name, classification: "secret" }
|
|
3403
4375
|
),
|
|
@@ -3439,7 +4411,8 @@ function definitionVersionFor(model, provider, options = {}) {
|
|
|
3439
4411
|
...includeWireProfile ? { wireProfile: provider.wireProfile } : {},
|
|
3440
4412
|
baseUrl: provider.baseUrl ?? null,
|
|
3441
4413
|
defaultHeaders: requestMetadata.headers,
|
|
3442
|
-
defaultQuery: requestMetadata.query
|
|
4414
|
+
defaultQuery: requestMetadata.query,
|
|
4415
|
+
...requestMetadata.anthropic ? { anthropic: requestMetadata.anthropic } : {}
|
|
3443
4416
|
},
|
|
3444
4417
|
credentialSource: model.credentialSource,
|
|
3445
4418
|
billing: model.billing,
|
|
@@ -3461,6 +4434,39 @@ function legacyImplicitOpenAiDefinitionVersionFor(model, provider) {
|
|
|
3461
4434
|
includeWireProfile: false
|
|
3462
4435
|
});
|
|
3463
4436
|
}
|
|
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
|
+
}
|
|
3464
4470
|
function builtinProviderId(settings) {
|
|
3465
4471
|
return settings.openaiProvider === "azure" ? "azure" : "openai";
|
|
3466
4472
|
}
|
|
@@ -3482,10 +4488,10 @@ function configuredProviders(settings, source = process.env) {
|
|
|
3482
4488
|
if (settings.openaiProvider === "azure") {
|
|
3483
4489
|
const baseUrl = settings.azureOpenaiBaseUrl ?? settings.azureOpenaiEndpoint;
|
|
3484
4490
|
builtin.baseUrl = baseUrl ? normalizeRegistryBaseUrl(baseUrl, builtin.id) : void 0;
|
|
3485
|
-
builtin.apiKey = settings.azureOpenaiApiKey ?? settings.azureOpenaiAdToken;
|
|
4491
|
+
builtin.apiKey = usableDeploymentSecret(settings.azureOpenaiApiKey) ?? settings.azureOpenaiAdToken;
|
|
3486
4492
|
} else {
|
|
3487
4493
|
builtin.baseUrl = settings.openaiBaseUrl ? normalizeRegistryBaseUrl(settings.openaiBaseUrl, builtin.id) : void 0;
|
|
3488
|
-
builtin.apiKey = settings.openaiApiKey;
|
|
4494
|
+
builtin.apiKey = usableDeploymentSecret(settings.openaiApiKey);
|
|
3489
4495
|
}
|
|
3490
4496
|
const registry = configuredRegistryProviders(settings).map(
|
|
3491
4497
|
(provider) => ({
|
|
@@ -3493,6 +4499,7 @@ function configuredProviders(settings, source = process.env) {
|
|
|
3493
4499
|
label: provider.label ?? provider.id,
|
|
3494
4500
|
kind: provider.kind,
|
|
3495
4501
|
api: provider.api,
|
|
4502
|
+
anthropic: provider.anthropic,
|
|
3496
4503
|
wireProfile: provider.wireProfile,
|
|
3497
4504
|
builtin: false,
|
|
3498
4505
|
baseUrl: provider.baseUrl,
|
|
@@ -3507,11 +4514,17 @@ function configuredProviders(settings, source = process.env) {
|
|
|
3507
4514
|
);
|
|
3508
4515
|
return [builtin, ...registry];
|
|
3509
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
|
+
}
|
|
3510
4521
|
function withCodexCatalogProvider(settings) {
|
|
3511
4522
|
const providers = parseModelProvidersJson(settings.modelProvidersJson);
|
|
3512
4523
|
if (providers.some((provider2) => provider2.id === CODEX_PROVIDER_ID)) {
|
|
3513
4524
|
return settings;
|
|
3514
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;
|
|
3515
4528
|
const provider = {
|
|
3516
4529
|
kind: "codex-subscription",
|
|
3517
4530
|
id: CODEX_PROVIDER_ID,
|
|
@@ -3519,12 +4532,12 @@ function withCodexCatalogProvider(settings) {
|
|
|
3519
4532
|
api: "responses",
|
|
3520
4533
|
wireProfile: "openai",
|
|
3521
4534
|
baseUrl: CODEX_PROVIDER_BASE_URL,
|
|
3522
|
-
models: CODEX_FALLBACK_MODEL_SLUGS.map((slug) => {
|
|
4535
|
+
models: catalogModels ?? CODEX_FALLBACK_MODEL_SLUGS.map((slug) => {
|
|
3523
4536
|
const capabilities = {
|
|
3524
4537
|
...legacyModelCapabilities(settings, {
|
|
3525
4538
|
reasoningEffort: true,
|
|
3526
4539
|
hostedWebSearch: true,
|
|
3527
|
-
vision: slug
|
|
4540
|
+
vision: isReviewedGptVisionModel(slug)
|
|
3528
4541
|
}),
|
|
3529
4542
|
...builtinPromptCachingForModel(`${CODEX_MODEL_ID_PREFIX}${slug}`) ? {
|
|
3530
4543
|
promptCaching: builtinPromptCachingForModel(`${CODEX_MODEL_ID_PREFIX}${slug}`)
|
|
@@ -3707,7 +4720,7 @@ function configuredModels(settings, source = process.env) {
|
|
|
3707
4720
|
reasoningEffort: true,
|
|
3708
4721
|
hostedWebSearch: settings.webSearchEnabled,
|
|
3709
4722
|
hostedImageGeneration: builtinHostedImageGenerationForModel(settings, id),
|
|
3710
|
-
vision: id
|
|
4723
|
+
vision: isReviewedGptVisionModel(id)
|
|
3711
4724
|
}),
|
|
3712
4725
|
...builtinPromptCachingForModel(id) ? { promptCaching: builtinPromptCachingForModel(id) } : {},
|
|
3713
4726
|
latencyModes: builtinLatencyModesForModel(id)
|
|
@@ -3749,6 +4762,7 @@ function configuredModels(settings, source = process.env) {
|
|
|
3749
4762
|
id: model.id,
|
|
3750
4763
|
aliases: [...model.aliases ?? []],
|
|
3751
4764
|
label: model.label ?? productLabelForModelId(model.id),
|
|
4765
|
+
...model.logoUrl ? { logoUrl: model.logoUrl } : {},
|
|
3752
4766
|
...model.shortLabel ? { shortLabel: model.shortLabel } : productShortLabelForModelId(model.id) ? { shortLabel: productShortLabelForModelId(model.id) } : {},
|
|
3753
4767
|
providerId: provider.id,
|
|
3754
4768
|
providerLabel,
|
|
@@ -3786,7 +4800,57 @@ function canonicalizeConfiguredModelId(settings, modelId) {
|
|
|
3786
4800
|
return models.find((model) => model.aliases.includes(modelId))?.id ?? modelId;
|
|
3787
4801
|
}
|
|
3788
4802
|
function configuredAllowedModels(settings) {
|
|
3789
|
-
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;
|
|
3790
4854
|
}
|
|
3791
4855
|
function resolveModelProvider(settings, modelId) {
|
|
3792
4856
|
const canonicalModelId = canonicalizeConfiguredModelId(settings, modelId);
|
|
@@ -3836,12 +4900,25 @@ function resolveModelProviderForTurn(settings, modelId) {
|
|
|
3836
4900
|
canonicalizeConfiguredModelId(catalogSettings, modelId)
|
|
3837
4901
|
);
|
|
3838
4902
|
}
|
|
4903
|
+
var TurnExecutionPolicyModelUnavailableError = class extends Error {
|
|
4904
|
+
constructor(message) {
|
|
4905
|
+
super(message);
|
|
4906
|
+
this.name = "TurnExecutionPolicyModelUnavailableError";
|
|
4907
|
+
}
|
|
4908
|
+
};
|
|
3839
4909
|
function resolveTurnExecutionPolicyV1(settings, input) {
|
|
3840
4910
|
const catalogSettings = settingsForTurnExecutionPolicy(settings, input.modelId);
|
|
3841
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
|
+
}
|
|
3842
4917
|
const resolved = resolveModelProvider(catalogSettings, productModelId);
|
|
3843
4918
|
if (!resolved) {
|
|
3844
|
-
throw new
|
|
4919
|
+
throw new TurnExecutionPolicyModelUnavailableError(
|
|
4920
|
+
"Turn execution policy model is not present in the configured catalog"
|
|
4921
|
+
);
|
|
3845
4922
|
}
|
|
3846
4923
|
if (input.requestedModelId !== null && canonicalizeConfiguredModelId(catalogSettings, input.requestedModelId) !== productModelId) {
|
|
3847
4924
|
throw new Error("Turn execution policy requested model does not canonicalize to its product");
|
|
@@ -3866,6 +4943,13 @@ function resolveTurnExecutionPolicyV1(settings, input) {
|
|
|
3866
4943
|
definitionVersion: resolved.model.definitionVersion
|
|
3867
4944
|
});
|
|
3868
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
|
+
};
|
|
3869
4953
|
function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
3870
4954
|
const parsed = TurnExecutionPolicyV1.parse(policy);
|
|
3871
4955
|
const catalogSettings = settingsForTurnExecutionPolicy(settings, parsed.productModelId);
|
|
@@ -3884,15 +4968,33 @@ function assertTurnExecutionPolicyMatchesConfigV1(settings, policy, expected) {
|
|
|
3884
4968
|
if (!resolved) {
|
|
3885
4969
|
throw new Error("Turn execution policy model is no longer configured");
|
|
3886
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
|
+
);
|
|
3887
4986
|
const legacyImplicitOpenAiDefinitionVersion = legacyImplicitOpenAiDefinitionVersionFor(
|
|
3888
4987
|
resolved.model,
|
|
3889
4988
|
resolved.provider
|
|
3890
4989
|
);
|
|
3891
|
-
const definitionVersionMatches = parsed.definitionVersion === resolved.model.definitionVersion || parsed.definitionVersion === legacyImplicitOpenAiDefinitionVersion;
|
|
3892
|
-
const
|
|
3893
|
-
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) {
|
|
3894
4993
|
throw new Error("Turn execution policy does not match the current provider definition");
|
|
3895
4994
|
}
|
|
4995
|
+
if (!definitionVersionMatches && !legacyClaudeAccountingMatches) {
|
|
4996
|
+
throw new TurnExecutionPolicyDefinitionMismatchError();
|
|
4997
|
+
}
|
|
3896
4998
|
return { policy: parsed, provider: resolved.provider, model: resolved.model };
|
|
3897
4999
|
}
|
|
3898
5000
|
function configuredModelPricingSchedules(settings) {
|
|
@@ -3922,6 +5024,103 @@ function configuredModelPricingSchedules(settings) {
|
|
|
3922
5024
|
...configured
|
|
3923
5025
|
};
|
|
3924
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
|
+
}
|
|
3925
5124
|
function configuredModelPricing(settings) {
|
|
3926
5125
|
return Object.fromEntries(
|
|
3927
5126
|
Object.entries(configuredModelPricingSchedules(settings)).map(([model, schedule]) => [
|
|
@@ -3987,6 +5186,216 @@ function calculateModelUsageCostMicros(settings, model, usage, options) {
|
|
|
3987
5186
|
}
|
|
3988
5187
|
function calculateModelUsageCostBreakdown(settings, model, usage, options) {
|
|
3989
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) {
|
|
3990
5399
|
if (!schedule) {
|
|
3991
5400
|
throw new Error(`Missing model pricing for ${model}`);
|
|
3992
5401
|
}
|
|
@@ -4245,7 +5654,7 @@ async function retryStartupDependency(label, operation, options = {}) {
|
|
|
4245
5654
|
try {
|
|
4246
5655
|
return await operation();
|
|
4247
5656
|
} catch (error) {
|
|
4248
|
-
if (attempt >= attempts) {
|
|
5657
|
+
if (attempt >= attempts || options.shouldRetry?.(error) === false) {
|
|
4249
5658
|
throw error;
|
|
4250
5659
|
}
|
|
4251
5660
|
const delayMs = Math.min(maxDelayMs, initialDelayMs * 2 ** (attempt - 1));
|
|
@@ -4335,7 +5744,7 @@ function parseModelPricingJson(raw) {
|
|
|
4335
5744
|
if (!model.trim()) {
|
|
4336
5745
|
throw new Error("OPENGENI_MODEL_PRICING_JSON contains an empty model name");
|
|
4337
5746
|
}
|
|
4338
|
-
out[model] =
|
|
5747
|
+
out[model] = z3.union([ModelPricingSchema, ModelPricingScheduleSchema]).parse(value);
|
|
4339
5748
|
}
|
|
4340
5749
|
return out;
|
|
4341
5750
|
}
|
|
@@ -4445,9 +5854,9 @@ function parseIntegrationsOauthClientsJson(raw) {
|
|
|
4445
5854
|
}
|
|
4446
5855
|
return out;
|
|
4447
5856
|
}
|
|
4448
|
-
var SocialOAuthClientConfigSchema =
|
|
4449
|
-
clientId:
|
|
4450
|
-
clientSecret:
|
|
5857
|
+
var SocialOAuthClientConfigSchema = z3.object({
|
|
5858
|
+
clientId: z3.string().min(1),
|
|
5859
|
+
clientSecret: z3.string().min(1).optional()
|
|
4451
5860
|
});
|
|
4452
5861
|
var SOCIAL_OAUTH_PROVIDER_IDS = ["x", "reddit"];
|
|
4453
5862
|
function parseSocialOauthClientsJson(raw) {
|
|
@@ -4584,20 +5993,9 @@ function ensureBuiltInMcpServers(settings) {
|
|
|
4584
5993
|
...hasDocs ? [] : [
|
|
4585
5994
|
{
|
|
4586
5995
|
id: "docs",
|
|
4587
|
-
name: "
|
|
5996
|
+
name: "Knowledge",
|
|
4588
5997
|
url: firstPartyDocsMcpUrl,
|
|
4589
|
-
allowedTools: [
|
|
4590
|
-
"search_documents",
|
|
4591
|
-
"fetch_document_chunk",
|
|
4592
|
-
"list_document_bases",
|
|
4593
|
-
"list_indexed_documents",
|
|
4594
|
-
"knowledge_search",
|
|
4595
|
-
"knowledge_get",
|
|
4596
|
-
"knowledge_browse",
|
|
4597
|
-
"knowledge_fetch",
|
|
4598
|
-
"memory_search",
|
|
4599
|
-
"memory_propose"
|
|
4600
|
-
],
|
|
5998
|
+
allowedTools: ["knowledge_search", "knowledge_get", "knowledge_browse"],
|
|
4601
5999
|
cacheToolsList: false
|
|
4602
6000
|
}
|
|
4603
6001
|
],
|
|
@@ -4656,8 +6054,61 @@ function isDigestPinnedModalDesktopImage(settings) {
|
|
|
4656
6054
|
if (settings.modalImageId) return true;
|
|
4657
6055
|
return typeof settings.modalImageRef === "string" && MODAL_DESKTOP_IMAGE_DIGEST_REF.test(settings.modalImageRef);
|
|
4658
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
|
+
}
|
|
4659
6109
|
function validateSettings(settings, source = process.env) {
|
|
4660
6110
|
temporalConnectionOptions(settings);
|
|
6111
|
+
localAllowedOriginEntries(settings.localAllowedOrigins);
|
|
4661
6112
|
if (settings.organizationUserSetupEmailTokenTransport === "query" && !settings.organizationUserSetupQueryEdgeSanitizationConfirmed) {
|
|
4662
6113
|
throw new Error(
|
|
4663
6114
|
"OPENGENI_ORGANIZATION_USER_SETUP_QUERY_EDGE_SANITIZATION_CONFIRMED=true is required when OPENGENI_ORGANIZATION_USER_SETUP_EMAIL_TOKEN_TRANSPORT=query"
|
|
@@ -4740,6 +6191,18 @@ function validateSettings(settings, source = process.env) {
|
|
|
4740
6191
|
);
|
|
4741
6192
|
}
|
|
4742
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
|
+
}
|
|
4743
6206
|
if (settings.mcpOauthEnabled) {
|
|
4744
6207
|
if (settings.productAccessMode === "configured") {
|
|
4745
6208
|
throw new Error(
|
|
@@ -5000,60 +6463,7 @@ function validateSettings(settings, source = process.env) {
|
|
|
5000
6463
|
);
|
|
5001
6464
|
}
|
|
5002
6465
|
}
|
|
5003
|
-
|
|
5004
|
-
if (Boolean(settings.objectStorageAccessKeyId) !== Boolean(settings.objectStorageSecretAccessKey)) {
|
|
5005
|
-
throw new Error(
|
|
5006
|
-
"OPENGENI_OBJECT_STORAGE_ACCESS_KEY_ID and OPENGENI_OBJECT_STORAGE_SECRET_ACCESS_KEY must both be set or both omitted"
|
|
5007
|
-
);
|
|
5008
|
-
}
|
|
5009
|
-
if (settings.objectStorageBackend === "s3-compatible" && (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint) && (!settings.objectStorageAccessKeyId || !settings.objectStorageSecretAccessKey)) {
|
|
5010
|
-
throw new Error(
|
|
5011
|
-
"S3-compatible object storage endpoints require OPENGENI_OBJECT_STORAGE_ACCESS_KEY_ID and OPENGENI_OBJECT_STORAGE_SECRET_ACCESS_KEY"
|
|
5012
|
-
);
|
|
5013
|
-
}
|
|
5014
|
-
if (settings.objectStorageAzureConnectionString || settings.objectStorageAzureAccountName || settings.objectStorageAzureAccountKey || settings.objectStorageAzureEndpoint) {
|
|
5015
|
-
throw new Error(
|
|
5016
|
-
"S3 object storage uses OPENGENI_OBJECT_STORAGE_* S3 settings, not OPENGENI_OBJECT_STORAGE_AZURE_* settings"
|
|
5017
|
-
);
|
|
5018
|
-
}
|
|
5019
|
-
if (settings.objectStorageGcsProjectId || settings.objectStorageGcsCredentialsJson || settings.objectStorageGcsKeyFilename || settings.objectStorageGcsApiEndpoint) {
|
|
5020
|
-
throw new Error(
|
|
5021
|
-
"S3 object storage uses OPENGENI_OBJECT_STORAGE_* S3 settings, not OPENGENI_OBJECT_STORAGE_GCS_* settings"
|
|
5022
|
-
);
|
|
5023
|
-
}
|
|
5024
|
-
} else if (settings.objectStorageBackend === "azure-blob") {
|
|
5025
|
-
if (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint || settings.objectStorageAccessKeyId || settings.objectStorageSecretAccessKey) {
|
|
5026
|
-
throw new Error(
|
|
5027
|
-
"Azure Blob storage uses OPENGENI_OBJECT_STORAGE_AZURE_* settings, not S3-compatible object storage settings"
|
|
5028
|
-
);
|
|
5029
|
-
}
|
|
5030
|
-
if (settings.objectStorageGcsProjectId || settings.objectStorageGcsCredentialsJson || settings.objectStorageGcsKeyFilename || settings.objectStorageGcsApiEndpoint) {
|
|
5031
|
-
throw new Error(
|
|
5032
|
-
"Azure Blob storage uses OPENGENI_OBJECT_STORAGE_AZURE_* settings, not OPENGENI_OBJECT_STORAGE_GCS_* settings"
|
|
5033
|
-
);
|
|
5034
|
-
}
|
|
5035
|
-
const hasConnectionString = Boolean(settings.objectStorageAzureConnectionString);
|
|
5036
|
-
const hasSharedKey = Boolean(settings.objectStorageAzureAccountName) && Boolean(settings.objectStorageAzureAccountKey);
|
|
5037
|
-
if (!hasConnectionString && !hasSharedKey) {
|
|
5038
|
-
throw new Error(
|
|
5039
|
-
"Azure Blob storage requires OPENGENI_OBJECT_STORAGE_AZURE_CONNECTION_STRING or OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_NAME plus OPENGENI_OBJECT_STORAGE_AZURE_ACCOUNT_KEY"
|
|
5040
|
-
);
|
|
5041
|
-
}
|
|
5042
|
-
} else {
|
|
5043
|
-
if (settings.objectStorageEndpoint || settings.objectStorageInternalEndpoint || settings.objectStorageSandboxEndpoint || settings.objectStorageAccessKeyId || settings.objectStorageSecretAccessKey) {
|
|
5044
|
-
throw new Error(
|
|
5045
|
-
"GCS object storage uses OPENGENI_OBJECT_STORAGE_GCS_* settings, not S3-compatible object storage settings"
|
|
5046
|
-
);
|
|
5047
|
-
}
|
|
5048
|
-
if (settings.objectStorageAzureConnectionString || settings.objectStorageAzureAccountName || settings.objectStorageAzureAccountKey || settings.objectStorageAzureEndpoint) {
|
|
5049
|
-
throw new Error(
|
|
5050
|
-
"GCS object storage uses OPENGENI_OBJECT_STORAGE_GCS_* settings, not OPENGENI_OBJECT_STORAGE_AZURE_* settings"
|
|
5051
|
-
);
|
|
5052
|
-
}
|
|
5053
|
-
if (settings.objectStorageGcsCredentialsJson) {
|
|
5054
|
-
parseGcsCredentialsJson(settings.objectStorageGcsCredentialsJson);
|
|
5055
|
-
}
|
|
5056
|
-
}
|
|
6466
|
+
validateObjectStorageSettings(settings);
|
|
5057
6467
|
if (settings.documentChunkOverlap >= settings.documentChunkSize) {
|
|
5058
6468
|
throw new Error(
|
|
5059
6469
|
"OPENGENI_DOCUMENT_CHUNK_OVERLAP must be smaller than OPENGENI_DOCUMENT_CHUNK_SIZE"
|
|
@@ -5062,7 +6472,22 @@ function validateSettings(settings, source = process.env) {
|
|
|
5062
6472
|
parseExposedPorts(settings.dockerExposedPorts);
|
|
5063
6473
|
sandboxEnvironmentVariableNames(settings);
|
|
5064
6474
|
sandboxLifecycleHookIds(settings);
|
|
5065
|
-
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
|
+
}
|
|
5066
6491
|
if (settings.sandboxBackend === "opensandbox") {
|
|
5067
6492
|
if (!/@sha256:[0-9a-f]{64}$/i.test(settings.openSandboxImage ?? "")) {
|
|
5068
6493
|
throw new Error(
|
|
@@ -5081,9 +6506,9 @@ function validateSettings(settings, source = process.env) {
|
|
|
5081
6506
|
throw new Error(`OPENGENI_MCP_SERVERS contains duplicate id ${server.id}`);
|
|
5082
6507
|
}
|
|
5083
6508
|
serverIds.add(server.id);
|
|
5084
|
-
if (server.connectionRef?.authoritySource === "host"
|
|
6509
|
+
if (server.connectionRef?.authoritySource === "host") {
|
|
5085
6510
|
throw new Error(
|
|
5086
|
-
"OPENGENI_MCP_SERVERS host-owned connection refs
|
|
6511
|
+
"OPENGENI_MCP_SERVERS host-owned connection refs are no longer supported; select ordinary native connections"
|
|
5087
6512
|
);
|
|
5088
6513
|
}
|
|
5089
6514
|
}
|
|
@@ -5121,9 +6546,21 @@ function validateSettings(settings, source = process.env) {
|
|
|
5121
6546
|
ordinaryCaptureTimeoutMs,
|
|
5122
6547
|
drainCaptureTimeoutMs
|
|
5123
6548
|
);
|
|
5124
|
-
|
|
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)) {
|
|
5125
6562
|
throw new Error(
|
|
5126
|
-
`
|
|
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.`
|
|
5127
6564
|
);
|
|
5128
6565
|
}
|
|
5129
6566
|
if (settings.sandboxBackend === "modal") {
|
|
@@ -5156,6 +6593,11 @@ function validateSettings(settings, source = process.env) {
|
|
|
5156
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.`
|
|
5157
6594
|
);
|
|
5158
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
|
+
}
|
|
5159
6601
|
}
|
|
5160
6602
|
}
|
|
5161
6603
|
if (settings.sandboxDesktopEnabled && settings.sandboxBackend === "modal" && !["local", "test"].includes(settings.environment)) {
|
|
@@ -5183,7 +6625,7 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
5183
6625
|
const builtinId = builtinProviderId(settings);
|
|
5184
6626
|
const providerIds = /* @__PURE__ */ new Set();
|
|
5185
6627
|
for (const provider of registryProviders) {
|
|
5186
|
-
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") {
|
|
5187
6629
|
throw new Error(
|
|
5188
6630
|
`OPENGENI_MODEL_PROVIDERS_JSON provider kind ${provider.kind} is reserved for a reviewed OpenGeni credential broker`
|
|
5189
6631
|
);
|
|
@@ -5212,6 +6654,19 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
5212
6654
|
}
|
|
5213
6655
|
const models = configuredModels(settings, source);
|
|
5214
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
|
+
}
|
|
5215
6670
|
const defaultCatalogModels = defaultCatalogSettings === settings ? models : configuredModels(defaultCatalogSettings, source);
|
|
5216
6671
|
if (models.length === 0 && defaultCatalogModels.length === 0) {
|
|
5217
6672
|
throw new Error("The resolved model catalog contains no executable models");
|
|
@@ -5225,10 +6680,25 @@ function validateModelCatalogSettings(settings, source = process.env) {
|
|
|
5225
6680
|
`The default model ${settings.openaiModel} is not executable in the resolved model catalog`
|
|
5226
6681
|
);
|
|
5227
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
|
+
}
|
|
5228
6693
|
const deploymentProductIds = new Set(
|
|
5229
6694
|
models.filter((model) => model.credentialSource.kind === "deployment").map((model) => model.id)
|
|
5230
6695
|
);
|
|
5231
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
|
+
}
|
|
5232
6702
|
for (const model of configuredGatewayCatalogModels(settings)) {
|
|
5233
6703
|
deploymentProductIds.add(model.productId);
|
|
5234
6704
|
noteProductIds.add(model.productId);
|
|
@@ -5306,6 +6776,62 @@ function resolveNatsCalloutConfig(settings) {
|
|
|
5306
6776
|
}
|
|
5307
6777
|
return { accountSeed, accountName, user, password };
|
|
5308
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
|
+
}
|
|
5309
6835
|
function resolveNatsControlPlaneAuth(settings) {
|
|
5310
6836
|
const user = settings.selfhostedNatsControlUser?.trim();
|
|
5311
6837
|
const password = settings.selfhostedNatsControlPassword?.trim();
|
|
@@ -5317,6 +6843,9 @@ function resolveNatsControlPlaneAuth(settings) {
|
|
|
5317
6843
|
function splitCsv(raw) {
|
|
5318
6844
|
return raw.split(",").map((value) => value.trim()).filter(Boolean);
|
|
5319
6845
|
}
|
|
6846
|
+
function sandboxImageAllowlist(settings) {
|
|
6847
|
+
return [...new Set(splitCsv(settings.sandboxImageAllowlist ?? ""))];
|
|
6848
|
+
}
|
|
5320
6849
|
function uniqueEnvNames(raw, fieldName) {
|
|
5321
6850
|
const seen = /* @__PURE__ */ new Set();
|
|
5322
6851
|
const out = [];
|
|
@@ -5347,13 +6876,155 @@ function parseGcsCredentialsJson(raw) {
|
|
|
5347
6876
|
function delay(ms) {
|
|
5348
6877
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5349
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
|
+
}
|
|
5350
7011
|
export {
|
|
5351
7012
|
AGENT_INSTRUCTIONS_CORE_PLACEHOLDER,
|
|
5352
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,
|
|
5353
7020
|
CODEX_REALTIME_MODEL_ID,
|
|
5354
7021
|
CapabilityStateV1Schema,
|
|
5355
7022
|
CapabilitySupportV1,
|
|
7023
|
+
ClaudeOAuthTokenResponse,
|
|
7024
|
+
ClaudeSubscriptionCredential,
|
|
7025
|
+
ClaudeSubscriptionIdentity,
|
|
5356
7026
|
ConfiguredModelCostClass,
|
|
7027
|
+
CreditPromotionPolicy,
|
|
5357
7028
|
DEFAULT_AGENT_INSTRUCTIONS,
|
|
5358
7029
|
DEFAULT_GOAL_IDLE_BACKOFF_MAX_MS,
|
|
5359
7030
|
DEFAULT_GOAL_IDLE_BACKOFF_MS,
|
|
@@ -5386,12 +7057,16 @@ export {
|
|
|
5386
7057
|
RegistryProviderKind,
|
|
5387
7058
|
SANDBOX_ARCHIVE_CAPTURE_MAX_TIMEOUT_MS,
|
|
5388
7059
|
SANDBOX_ARCHIVE_CAPTURE_SETTLEMENT_GRACE_MS,
|
|
7060
|
+
SANDBOX_DEADLINE_COMMAND_STOP_GRACE_MS,
|
|
5389
7061
|
SANDBOX_LIFECYCLE_RETRY_HANDOFF_GRACE_MS,
|
|
5390
7062
|
SANDBOX_LIFECYCLE_TRANSITION_MAX_WAIT_MS,
|
|
5391
7063
|
SANDBOX_REQUIRED_ENV,
|
|
5392
7064
|
SANDBOX_SNAPSHOT_MAX_TIMEOUT_MS,
|
|
5393
7065
|
SUPERGROK_REALTIME_MODEL_ID,
|
|
5394
7066
|
SocialOAuthClientConfigSchema,
|
|
7067
|
+
TurnExecutionPolicyDefinitionMismatchError,
|
|
7068
|
+
TurnExecutionPolicyModelUnavailableError,
|
|
7069
|
+
UnsupportedLatencyModeError,
|
|
5395
7070
|
VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
|
|
5396
7071
|
VERCEL_AI_GATEWAY_BASE_URL,
|
|
5397
7072
|
VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
|
|
@@ -5404,6 +7079,8 @@ export {
|
|
|
5404
7079
|
WORKSPACE_OPENROUTER_PROVIDER_ID,
|
|
5405
7080
|
WORKSPACE_REALTIME_MODEL_ID_PREFIX,
|
|
5406
7081
|
XAI_SUBSCRIPTION_MODEL_ID_PREFIX2 as XAI_SUBSCRIPTION_MODEL_ID_PREFIX,
|
|
7082
|
+
agentConfigDeploymentPolicy,
|
|
7083
|
+
allocateRecordedModelListCostByClass,
|
|
5407
7084
|
allowedFirstPartyMcpToolsForSession,
|
|
5408
7085
|
applyGitAuthPointerEnvironment,
|
|
5409
7086
|
applyModelCatalogDocument,
|
|
@@ -5412,12 +7089,20 @@ export {
|
|
|
5412
7089
|
calculateGatewayReportedCostBreakdown,
|
|
5413
7090
|
calculateGatewayReportedCostMicros,
|
|
5414
7091
|
calculateGatewayReportedProviderCostMicros,
|
|
7092
|
+
calculateModelListUsageCostBreakdown,
|
|
7093
|
+
calculateModelListUsageCostSnapshot,
|
|
5415
7094
|
calculateModelUsageCostBreakdown,
|
|
5416
7095
|
calculateModelUsageCostMicros,
|
|
5417
7096
|
calculateVideoGenerationCreditCostMicros,
|
|
5418
7097
|
canonicalPublicOrigin,
|
|
5419
7098
|
canonicalizeConfiguredModelId,
|
|
7099
|
+
claudeAuthorizationUrl,
|
|
7100
|
+
claudeNativeModelProfile,
|
|
7101
|
+
claudeProviderId,
|
|
7102
|
+
claudeSubscriptionCapacity,
|
|
7103
|
+
codeSearchDeploymentPolicy,
|
|
5420
7104
|
codemodeWorkspaceUrl,
|
|
7105
|
+
codexUpstreamModelSlugs,
|
|
5421
7106
|
collectGitIdentityEnvironment,
|
|
5422
7107
|
collectSandboxEnvironment,
|
|
5423
7108
|
configuredAllowedModels,
|
|
@@ -5428,6 +7113,7 @@ export {
|
|
|
5428
7113
|
configuredGatewayWorkspaceProductModelIds,
|
|
5429
7114
|
configuredGoogleDriveSyncLimits,
|
|
5430
7115
|
configuredModelInputIdentities,
|
|
7116
|
+
configuredModelListPricingSchedules,
|
|
5431
7117
|
configuredModelNotes,
|
|
5432
7118
|
configuredModelPricing,
|
|
5433
7119
|
configuredModelPricingSchedules,
|
|
@@ -5443,20 +7129,31 @@ export {
|
|
|
5443
7129
|
effectiveModalIdleTimeoutSeconds,
|
|
5444
7130
|
effectiveSandboxDrainSnapshotTimeoutMs,
|
|
5445
7131
|
effectiveSandboxLifecycle,
|
|
7132
|
+
emptyClaudeUsage,
|
|
5446
7133
|
environmentsEncryptionKeyBytes,
|
|
5447
7134
|
firstPartyMcpBaseUrl,
|
|
5448
7135
|
firstPartyMcpInternalBaseUrl,
|
|
5449
7136
|
firstPartyMcpInternalWorkspaceUrl,
|
|
5450
7137
|
firstPartyMcpWorkspaceUrl,
|
|
5451
7138
|
gatewayRequestPolicyForUpstreamModel,
|
|
7139
|
+
getArtifactMaterializerSettings,
|
|
7140
|
+
getArtifactOutboxSettings,
|
|
5452
7141
|
getSettings,
|
|
5453
7142
|
googleDriveOAuthCallbackUrl,
|
|
5454
7143
|
googleDriveProviderRetryOptions,
|
|
5455
7144
|
hasGitCredentialRepositorySelection,
|
|
5456
7145
|
hasGitHubRepositorySelection,
|
|
5457
7146
|
isDirectOpenAiApiBaseUrl,
|
|
7147
|
+
isManagedOpenRouterFreeRoute,
|
|
7148
|
+
isModelAvailableForNewSelection,
|
|
5458
7149
|
isUsableVoiceInputSecret,
|
|
7150
|
+
localAllowedOriginEntries,
|
|
7151
|
+
localSandboxApiRouteAllowed,
|
|
7152
|
+
managedUserEmailAllowed,
|
|
7153
|
+
mergeClaudeUsage,
|
|
5459
7154
|
modelCostClassForConfiguredModel,
|
|
7155
|
+
parseClaudeUsageHeaders,
|
|
7156
|
+
parseClaudeUsageResponse,
|
|
5460
7157
|
parseExposedPorts,
|
|
5461
7158
|
parseIntegrationsOauthClientsJson,
|
|
5462
7159
|
parseMcpServers,
|
|
@@ -5473,6 +7170,7 @@ export {
|
|
|
5473
7170
|
policyProviderIdForModel,
|
|
5474
7171
|
productLabelForModelId,
|
|
5475
7172
|
productShortLabelForModelId,
|
|
7173
|
+
promotionalCreditScope,
|
|
5476
7174
|
requiredSandboxEnvForBackend,
|
|
5477
7175
|
resolveAiGatewayRealtimeModel,
|
|
5478
7176
|
resolveEnrollmentSigningSecret,
|
|
@@ -5489,23 +7187,34 @@ export {
|
|
|
5489
7187
|
resolveVoiceInputProviderRegistry,
|
|
5490
7188
|
responseSatisfiesLatencyMode,
|
|
5491
7189
|
retryStartupDependency,
|
|
7190
|
+
reviewedModelListPricing,
|
|
5492
7191
|
runnableLatencyModesForModel,
|
|
5493
7192
|
sandboxArchiveCaptureTimeoutMs,
|
|
5494
7193
|
sandboxEnvironmentVariableNames,
|
|
7194
|
+
sandboxImageAllowlist,
|
|
5495
7195
|
sandboxLifecycleHookIds,
|
|
5496
7196
|
sandboxLifecycleTransitionWaitMs,
|
|
5497
7197
|
sandboxPreparationProfiles,
|
|
5498
7198
|
sandboxWarmRateMicrosPerSecond,
|
|
5499
7199
|
selectModelPricing,
|
|
7200
|
+
selectSubscriptionAccount,
|
|
5500
7201
|
serviceTierForLatencyMode,
|
|
7202
|
+
settingsForAcceptedSubscriptionTurn,
|
|
5501
7203
|
settingsWithResolvedModelContext,
|
|
7204
|
+
signupCreditModelIds,
|
|
5502
7205
|
stableSandboxEnvironmentForRun,
|
|
5503
7206
|
startupRetryOptions,
|
|
5504
7207
|
streamTokenDegraded,
|
|
7208
|
+
subscriptionAccountShardIndex,
|
|
5505
7209
|
temporalConnectionOptions,
|
|
7210
|
+
trustedProxyCidrEntries,
|
|
7211
|
+
usableJevApiKey,
|
|
5506
7212
|
validateModelCatalogSettings,
|
|
5507
7213
|
voiceInputDeploymentConfigured,
|
|
7214
|
+
withClaudeConnectionCatalog,
|
|
7215
|
+
withClaudeConnectionCredential,
|
|
5508
7216
|
withCodexCatalogProvider,
|
|
7217
|
+
withDirectModelProviders,
|
|
5509
7218
|
withOrganizationGatewayCatalogProvider,
|
|
5510
7219
|
withOrganizationGatewayCredential,
|
|
5511
7220
|
withOrganizationOpenRouterCatalogProvider,
|