@vellumai/assistant 0.9.0-dev.202606191605.b512a80 → 0.9.0-dev.202606191617.bbf9de9
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/package.json +1 -1
- package/src/__tests__/config-loader-backfill.test.ts +75 -1
- package/src/__tests__/gateway-flag-listener.test.ts +110 -1
- package/src/__tests__/llm-catalog-parity.test.ts +30 -1
- package/src/__tests__/managed-profile-guard.test.ts +109 -3
- package/src/__tests__/weak-open-model.test.ts +1 -0
- package/src/config/__tests__/sync-gated-profiles.test.ts +368 -0
- package/src/config/assistant-feature-flags.ts +22 -7
- package/src/config/feature-flag-registry.json +8 -0
- package/src/config/seed-inference-profiles.ts +42 -5
- package/src/config/sync-gated-profiles.ts +220 -0
- package/src/daemon/lifecycle.ts +21 -2
- package/src/ipc/gateway-flag-listener.ts +18 -2
- package/src/providers/model-catalog.ts +17 -0
- package/src/providers/weak-open-model.ts +2 -2
- package/src/runtime/routes/conversation-query-routes.ts +25 -2
package/package.json
CHANGED
|
@@ -75,7 +75,12 @@ import {
|
|
|
75
75
|
loadConfig,
|
|
76
76
|
mergeDefaultWorkspaceConfig,
|
|
77
77
|
} from "../config/loader.js";
|
|
78
|
-
import {
|
|
78
|
+
import {
|
|
79
|
+
MANAGED_PROFILE_NAMES,
|
|
80
|
+
materializeProfile,
|
|
81
|
+
OS_BETA_PROFILE_TEMPLATE,
|
|
82
|
+
seedInferenceProfiles,
|
|
83
|
+
} from "../config/seed-inference-profiles.js";
|
|
79
84
|
import type { DrizzleDb } from "../memory/db-connection.js";
|
|
80
85
|
import { migrateCreateProviderConnections } from "../memory/migrations/243-provider-connections.js";
|
|
81
86
|
import { migrateProviderConnectionStatusLabel } from "../memory/migrations/244-provider-connection-status-label.js";
|
|
@@ -1450,3 +1455,72 @@ describe("seedInferenceProfiles BYOK-mode managed profile labels", () => {
|
|
|
1450
1455
|
expect(config.llm.profiles.balanced?.label).toBe("Balanced (Managed)");
|
|
1451
1456
|
});
|
|
1452
1457
|
});
|
|
1458
|
+
|
|
1459
|
+
// ---------------------------------------------------------------------------
|
|
1460
|
+
// Tests: OS Beta flag-gated managed profile. The template is defined but
|
|
1461
|
+
// intentionally NOT part of MANAGED_PROFILE_TEMPLATES, so seedInferenceProfiles
|
|
1462
|
+
// must never create it. A later PR reconciles it in/out based on the `os-beta`
|
|
1463
|
+
// feature flag.
|
|
1464
|
+
// ---------------------------------------------------------------------------
|
|
1465
|
+
|
|
1466
|
+
describe("OS Beta managed profile template", () => {
|
|
1467
|
+
beforeEach(() => {
|
|
1468
|
+
ensureTestDir();
|
|
1469
|
+
const resetPaths = [
|
|
1470
|
+
CONFIG_PATH,
|
|
1471
|
+
join(WORKSPACE_DIR, "default-config.json"),
|
|
1472
|
+
join(WORKSPACE_DIR, "hatch-overlay.json"),
|
|
1473
|
+
join(WORKSPACE_DIR, "keys.enc"),
|
|
1474
|
+
join(WORKSPACE_DIR, "data"),
|
|
1475
|
+
join(WORKSPACE_DIR, "data", "memory"),
|
|
1476
|
+
];
|
|
1477
|
+
for (const path of resetPaths) {
|
|
1478
|
+
if (existsSync(path)) {
|
|
1479
|
+
rmSync(path, { recursive: true, force: true });
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
ensureTestDir();
|
|
1483
|
+
setStorePathForTesting(join(WORKSPACE_DIR, "keys.enc"));
|
|
1484
|
+
delete process.env.VELLUM_DEFAULT_WORKSPACE_CONFIG_PATH;
|
|
1485
|
+
delete process.env.IS_PLATFORM;
|
|
1486
|
+
invalidateConfigCache();
|
|
1487
|
+
});
|
|
1488
|
+
|
|
1489
|
+
afterEach(() => {
|
|
1490
|
+
setStorePathForTesting(null);
|
|
1491
|
+
delete process.env.VELLUM_DEFAULT_WORKSPACE_CONFIG_PATH;
|
|
1492
|
+
delete process.env.IS_PLATFORM;
|
|
1493
|
+
invalidateConfigCache();
|
|
1494
|
+
});
|
|
1495
|
+
|
|
1496
|
+
test("seedInferenceProfiles does not create an os-beta profile", () => {
|
|
1497
|
+
writeConfig({ llm: { default: { provider: "anthropic" } } });
|
|
1498
|
+
|
|
1499
|
+
mergeDefaultConfigAndSeedInferenceProfiles();
|
|
1500
|
+
const raw = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
1501
|
+
|
|
1502
|
+
expect(raw.llm.profiles["os-beta"]).toBeUndefined();
|
|
1503
|
+
expect((raw.llm.profileOrder as string[]).includes("os-beta")).toBe(false);
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
test("MANAGED_PROFILE_NAMES contains os-beta", () => {
|
|
1507
|
+
expect(MANAGED_PROFILE_NAMES.has("os-beta")).toBe(true);
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
test("materializeProfile honors the explicit OS Beta model", () => {
|
|
1511
|
+
const entry = materializeProfile(
|
|
1512
|
+
OS_BETA_PROFILE_TEMPLATE,
|
|
1513
|
+
"fireworks",
|
|
1514
|
+
"fireworks-managed",
|
|
1515
|
+
);
|
|
1516
|
+
|
|
1517
|
+
expect(entry.model).toBe("accounts/fireworks/models/glm-5p2");
|
|
1518
|
+
expect(entry.provider_connection).toBe("fireworks-managed");
|
|
1519
|
+
expect(entry.provider).toBe("fireworks");
|
|
1520
|
+
expect(entry.label).toBe("OS Beta");
|
|
1521
|
+
expect(entry.source).toBe("managed");
|
|
1522
|
+
expect(entry.maxTokens).toBe(32000);
|
|
1523
|
+
expect(entry.effort).toBe("high");
|
|
1524
|
+
expect(entry.thinking?.enabled).toBe(true);
|
|
1525
|
+
});
|
|
1526
|
+
});
|
|
@@ -25,12 +25,14 @@ mock.module("../ipc/socket-path.js", () => ({
|
|
|
25
25
|
// Track calls to refreshOverridesFromGateway
|
|
26
26
|
// ---------------------------------------------------------------------------
|
|
27
27
|
let refreshCallCount = 0;
|
|
28
|
+
let refreshReturnsLoaded = true;
|
|
28
29
|
|
|
29
30
|
mock.module("../config/assistant-feature-flags.js", () => ({
|
|
30
31
|
refreshOverridesFromGateway: async () => {
|
|
31
32
|
refreshCallCount++;
|
|
33
|
+
return refreshReturnsLoaded;
|
|
32
34
|
},
|
|
33
|
-
initFeatureFlagOverrides: async () =>
|
|
35
|
+
initFeatureFlagOverrides: async () => true,
|
|
34
36
|
clearFeatureFlagOverridesCache: () => {},
|
|
35
37
|
isAssistantFeatureFlagEnabled: () => true,
|
|
36
38
|
}));
|
|
@@ -60,6 +62,32 @@ mock.module("../tools/registry.js", () => ({
|
|
|
60
62
|
},
|
|
61
63
|
}));
|
|
62
64
|
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Track reconcileFlagGatedProfiles calls and let each test control whether it
|
|
67
|
+
// reports a config change, so we can assert the listener broadcasts only when
|
|
68
|
+
// the managed profile set actually changes.
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
let reconcileCallCount = 0;
|
|
71
|
+
let reconcileReturns = false;
|
|
72
|
+
|
|
73
|
+
mock.module("../config/sync-gated-profiles.js", () => ({
|
|
74
|
+
reconcileFlagGatedProfiles: () => {
|
|
75
|
+
reconcileCallCount++;
|
|
76
|
+
return reconcileReturns;
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Track publishConfigChanged so we can assert the picker-refresh broadcast.
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
let configChangedCount = 0;
|
|
84
|
+
|
|
85
|
+
mock.module("../runtime/sync/resource-sync-events.js", () => ({
|
|
86
|
+
publishConfigChanged: () => {
|
|
87
|
+
configChangedCount++;
|
|
88
|
+
},
|
|
89
|
+
}));
|
|
90
|
+
|
|
63
91
|
// ---------------------------------------------------------------------------
|
|
64
92
|
// Dynamic imports (after mock.module)
|
|
65
93
|
// ---------------------------------------------------------------------------
|
|
@@ -115,8 +143,12 @@ describe("gateway-flag-listener", () => {
|
|
|
115
143
|
beforeEach(() => {
|
|
116
144
|
mkdirSync(testRoot, { recursive: true });
|
|
117
145
|
refreshCallCount = 0;
|
|
146
|
+
refreshReturnsLoaded = true;
|
|
118
147
|
syncToolsCallCount = 0;
|
|
119
148
|
publishedTagSets = [];
|
|
149
|
+
reconcileCallCount = 0;
|
|
150
|
+
reconcileReturns = false;
|
|
151
|
+
configChangedCount = 0;
|
|
120
152
|
testServer = createTestServer();
|
|
121
153
|
});
|
|
122
154
|
|
|
@@ -180,6 +212,83 @@ describe("gateway-flag-listener", () => {
|
|
|
180
212
|
]);
|
|
181
213
|
});
|
|
182
214
|
|
|
215
|
+
test("reconciles flag-gated profiles and broadcasts config_changed when the profile set changes", async () => {
|
|
216
|
+
reconcileReturns = true;
|
|
217
|
+
await new Promise<void>((resolve) => {
|
|
218
|
+
testServer.server.listen(socketPath, resolve);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
startGatewayFlagListener();
|
|
222
|
+
await testServer.waitForClient();
|
|
223
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
224
|
+
|
|
225
|
+
// Connect path reconciles once and, since it reports a change, broadcasts.
|
|
226
|
+
expect(reconcileCallCount).toBe(1);
|
|
227
|
+
expect(configChangedCount).toBe(1);
|
|
228
|
+
|
|
229
|
+
testServer.emit("feature_flags_changed");
|
|
230
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
231
|
+
|
|
232
|
+
expect(reconcileCallCount).toBe(2);
|
|
233
|
+
expect(configChangedCount).toBe(2);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("reconciles but does not broadcast config_changed when the profile set is unchanged", async () => {
|
|
237
|
+
reconcileReturns = false;
|
|
238
|
+
await new Promise<void>((resolve) => {
|
|
239
|
+
testServer.server.listen(socketPath, resolve);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
startGatewayFlagListener();
|
|
243
|
+
await testServer.waitForClient();
|
|
244
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
245
|
+
|
|
246
|
+
testServer.emit("feature_flags_changed");
|
|
247
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
248
|
+
|
|
249
|
+
expect(reconcileCallCount).toBeGreaterThanOrEqual(2);
|
|
250
|
+
expect(configChangedCount).toBe(0);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test("does not reconcile profiles when the refresh reports flags did not load", async () => {
|
|
254
|
+
reconcileReturns = true;
|
|
255
|
+
refreshReturnsLoaded = false;
|
|
256
|
+
await new Promise<void>((resolve) => {
|
|
257
|
+
testServer.server.listen(socketPath, resolve);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
startGatewayFlagListener();
|
|
261
|
+
await testServer.waitForClient();
|
|
262
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
263
|
+
|
|
264
|
+
// Tool sync stays unconditional; the profile reconcile/broadcast are gated.
|
|
265
|
+
expect(syncToolsCallCount).toBe(1);
|
|
266
|
+
expect(reconcileCallCount).toBe(0);
|
|
267
|
+
expect(configChangedCount).toBe(0);
|
|
268
|
+
|
|
269
|
+
testServer.emit("feature_flags_changed");
|
|
270
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
271
|
+
|
|
272
|
+
expect(syncToolsCallCount).toBe(2);
|
|
273
|
+
expect(reconcileCallCount).toBe(0);
|
|
274
|
+
expect(configChangedCount).toBe(0);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test("reconciles profiles when the refresh reports flags loaded", async () => {
|
|
278
|
+
reconcileReturns = true;
|
|
279
|
+
refreshReturnsLoaded = true;
|
|
280
|
+
await new Promise<void>((resolve) => {
|
|
281
|
+
testServer.server.listen(socketPath, resolve);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
startGatewayFlagListener();
|
|
285
|
+
await testServer.waitForClient();
|
|
286
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
287
|
+
|
|
288
|
+
expect(reconcileCallCount).toBe(1);
|
|
289
|
+
expect(configChangedCount).toBe(1);
|
|
290
|
+
});
|
|
291
|
+
|
|
183
292
|
test("ignores non-flag events", async () => {
|
|
184
293
|
await new Promise<void>((resolve) => {
|
|
185
294
|
testServer.server.listen(socketPath, resolve);
|
|
@@ -2,7 +2,10 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { describe, expect, test } from "bun:test";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
isModelInCatalog,
|
|
7
|
+
PROVIDER_CATALOG,
|
|
8
|
+
} from "../providers/model-catalog.js";
|
|
6
9
|
import { PLATFORM_PROVIDER_META } from "../providers/platform-proxy/constants.js";
|
|
7
10
|
import { resolvePricing, resolvePricingForUsage } from "../util/pricing.js";
|
|
8
11
|
|
|
@@ -302,6 +305,32 @@ describe("LLM catalog parity: daemon vs client", () => {
|
|
|
302
305
|
});
|
|
303
306
|
});
|
|
304
307
|
|
|
308
|
+
test("Fireworks catalog includes GLM 5.2", () => {
|
|
309
|
+
expect(
|
|
310
|
+
isModelInCatalog("fireworks", "accounts/fireworks/models/glm-5p2"),
|
|
311
|
+
).toBe(true);
|
|
312
|
+
|
|
313
|
+
const fireworks = PROVIDER_CATALOG.find(
|
|
314
|
+
(entry) => entry.id === "fireworks",
|
|
315
|
+
);
|
|
316
|
+
expect(
|
|
317
|
+
fireworks?.models.find(
|
|
318
|
+
(model) => model.id === "accounts/fireworks/models/glm-5p2",
|
|
319
|
+
),
|
|
320
|
+
).toMatchObject({
|
|
321
|
+
displayName: "GLM 5.2",
|
|
322
|
+
contextWindowTokens: 1040000,
|
|
323
|
+
maxOutputTokens: 131072,
|
|
324
|
+
supportsToolUse: true,
|
|
325
|
+
supportsVision: false,
|
|
326
|
+
pricing: {
|
|
327
|
+
inputPer1mTokens: 1.4,
|
|
328
|
+
outputPer1mTokens: 4.4,
|
|
329
|
+
cacheReadPer1mTokens: 0.26,
|
|
330
|
+
},
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
305
334
|
test("MiniMax catalog includes MiniMax M3", () => {
|
|
306
335
|
const minimax = PROVIDER_CATALOG.find((entry) => entry.id === "minimax");
|
|
307
336
|
expect(
|
|
@@ -22,10 +22,19 @@ function makeDefaultRawConfig(): Record<string, unknown> {
|
|
|
22
22
|
"quality-optimized": {
|
|
23
23
|
provider: "anthropic",
|
|
24
24
|
model: "claude-sonnet",
|
|
25
|
+
source: "managed",
|
|
25
26
|
},
|
|
26
|
-
balanced: {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
balanced: {
|
|
28
|
+
provider: "anthropic",
|
|
29
|
+
model: "claude-sonnet",
|
|
30
|
+
source: "managed",
|
|
31
|
+
},
|
|
32
|
+
"cost-optimized": {
|
|
33
|
+
provider: "anthropic",
|
|
34
|
+
model: "claude-haiku",
|
|
35
|
+
source: "managed",
|
|
36
|
+
},
|
|
37
|
+
"my-custom": { provider: "openai", model: "gpt-4o", source: "user" },
|
|
29
38
|
},
|
|
30
39
|
},
|
|
31
40
|
};
|
|
@@ -327,6 +336,65 @@ describe("PUT /v1/config/llm/profiles/:name — managed profile guard", () => {
|
|
|
327
336
|
expect(profile.model).toBe("claude-sonnet");
|
|
328
337
|
});
|
|
329
338
|
|
|
339
|
+
test("allows edits to a user-owned profile sharing a managed name (os-beta)", async () => {
|
|
340
|
+
savedRaw = null;
|
|
341
|
+
rawConfig = {
|
|
342
|
+
llm: {
|
|
343
|
+
profiles: {
|
|
344
|
+
"os-beta": {
|
|
345
|
+
provider: "anthropic",
|
|
346
|
+
model: "claude-sonnet",
|
|
347
|
+
source: "user",
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
const result = await replaceRoute.handler({
|
|
353
|
+
pathParams: { name: "os-beta" },
|
|
354
|
+
body: { provider: "openai", model: "gpt-4o" },
|
|
355
|
+
});
|
|
356
|
+
expect(result).toEqual({ ok: true });
|
|
357
|
+
const profile = (savedRaw as unknown as Record<string, any>)?.llm
|
|
358
|
+
?.profiles?.["os-beta"] as Record<string, unknown>;
|
|
359
|
+
expect(profile.provider).toBe("openai");
|
|
360
|
+
expect(profile.model).toBe("gpt-4o");
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
test("rejects edits to a managed os-beta profile", async () => {
|
|
364
|
+
rawConfig = {
|
|
365
|
+
llm: {
|
|
366
|
+
profiles: {
|
|
367
|
+
"os-beta": {
|
|
368
|
+
provider: "fireworks",
|
|
369
|
+
model: "accounts/fireworks/models/glm-5p2",
|
|
370
|
+
source: "managed",
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
await expect(
|
|
376
|
+
replaceRoute.handler({
|
|
377
|
+
pathParams: { name: "os-beta" },
|
|
378
|
+
body: { provider: "openai", model: "gpt-4o" },
|
|
379
|
+
}),
|
|
380
|
+
).rejects.toThrow(BadRequestError);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
test("rejects PUT to os-beta when no os-beta profile exists, writing no stub", async () => {
|
|
384
|
+
savedRaw = null;
|
|
385
|
+
rawConfig = { llm: { profiles: {} } };
|
|
386
|
+
await expect(
|
|
387
|
+
replaceRoute.handler({
|
|
388
|
+
pathParams: { name: "os-beta" },
|
|
389
|
+
body: { label: "My OS Beta" },
|
|
390
|
+
}),
|
|
391
|
+
).rejects.toThrow("not currently available");
|
|
392
|
+
expect(savedRaw).toBeNull();
|
|
393
|
+
expect(
|
|
394
|
+
(rawConfig as Record<string, any>)?.llm?.profiles?.["os-beta"],
|
|
395
|
+
).toBeUndefined();
|
|
396
|
+
});
|
|
397
|
+
|
|
330
398
|
test("PUT { label: '' } on managed profile still rejected by `.min(1)`", async () => {
|
|
331
399
|
// `.nullable()` only widens the type to accept null — empty strings
|
|
332
400
|
// still fail the min-length check, which is correct: an empty string
|
|
@@ -428,6 +496,44 @@ describe("PATCH /v1/config — managed profile deletion guard", () => {
|
|
|
428
496
|
expect(result).toHaveProperty("llm");
|
|
429
497
|
});
|
|
430
498
|
|
|
499
|
+
test("allows deletion of a user-owned profile sharing a managed name (os-beta)", async () => {
|
|
500
|
+
savedRaw = null;
|
|
501
|
+
rawConfig = {
|
|
502
|
+
llm: {
|
|
503
|
+
profiles: {
|
|
504
|
+
"os-beta": {
|
|
505
|
+
provider: "anthropic",
|
|
506
|
+
model: "claude-sonnet",
|
|
507
|
+
source: "user",
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
};
|
|
512
|
+
const result = await patchRoute.handler({
|
|
513
|
+
body: { llm: { profiles: { "os-beta": null } } },
|
|
514
|
+
});
|
|
515
|
+
expect(result).toHaveProperty("llm");
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
test("rejects deletion of a managed os-beta profile", async () => {
|
|
519
|
+
rawConfig = {
|
|
520
|
+
llm: {
|
|
521
|
+
profiles: {
|
|
522
|
+
"os-beta": {
|
|
523
|
+
provider: "fireworks",
|
|
524
|
+
model: "accounts/fireworks/models/glm-5p2",
|
|
525
|
+
source: "managed",
|
|
526
|
+
},
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
await expect(
|
|
531
|
+
patchRoute.handler({
|
|
532
|
+
body: { llm: { profiles: { "os-beta": null } } },
|
|
533
|
+
}),
|
|
534
|
+
).rejects.toThrow('Cannot delete managed profile "os-beta".');
|
|
535
|
+
});
|
|
536
|
+
|
|
431
537
|
test("rejects nulling the entire profiles map", async () => {
|
|
432
538
|
await expect(
|
|
433
539
|
patchRoute.handler({
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
rmSync,
|
|
6
|
+
writeFileSync,
|
|
7
|
+
} from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import {
|
|
10
|
+
afterAll,
|
|
11
|
+
afterEach,
|
|
12
|
+
beforeEach,
|
|
13
|
+
describe,
|
|
14
|
+
expect,
|
|
15
|
+
mock,
|
|
16
|
+
test,
|
|
17
|
+
} from "bun:test";
|
|
18
|
+
|
|
19
|
+
const WORKSPACE_DIR = process.env.VELLUM_WORKSPACE_DIR!;
|
|
20
|
+
const CONFIG_PATH = join(WORKSPACE_DIR, "config.json");
|
|
21
|
+
|
|
22
|
+
function ensureTestDir(): void {
|
|
23
|
+
const dirs = [
|
|
24
|
+
WORKSPACE_DIR,
|
|
25
|
+
join(WORKSPACE_DIR, "data"),
|
|
26
|
+
join(WORKSPACE_DIR, "data", "memory"),
|
|
27
|
+
join(WORKSPACE_DIR, "data", "logs"),
|
|
28
|
+
];
|
|
29
|
+
for (const dir of dirs) {
|
|
30
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function makeLoggerStub(): Record<string, unknown> {
|
|
35
|
+
const stub: Record<string, unknown> = {};
|
|
36
|
+
for (const m of [
|
|
37
|
+
"info",
|
|
38
|
+
"warn",
|
|
39
|
+
"error",
|
|
40
|
+
"debug",
|
|
41
|
+
"trace",
|
|
42
|
+
"fatal",
|
|
43
|
+
"silent",
|
|
44
|
+
"child",
|
|
45
|
+
]) {
|
|
46
|
+
stub[m] = m === "child" ? () => makeLoggerStub() : () => {};
|
|
47
|
+
}
|
|
48
|
+
return stub;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
mock.module("../../util/logger.js", () => ({
|
|
52
|
+
getLogger: () => makeLoggerStub(),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
afterAll(() => {
|
|
56
|
+
mock.restore();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
import { setOverridesForTesting } from "../../__tests__/feature-flag-test-helpers.js";
|
|
60
|
+
import { invalidateConfigCache } from "../loader.js";
|
|
61
|
+
import { LLMSchema } from "../schemas/llm.js";
|
|
62
|
+
import { seedInferenceProfiles } from "../seed-inference-profiles.js";
|
|
63
|
+
import { reconcileFlagGatedProfiles } from "../sync-gated-profiles.js";
|
|
64
|
+
|
|
65
|
+
type RawConfig = {
|
|
66
|
+
llm: {
|
|
67
|
+
profiles: Record<string, Record<string, unknown>>;
|
|
68
|
+
profileOrder: string[];
|
|
69
|
+
activeProfile?: string;
|
|
70
|
+
advisorProfile?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function writeConfig(obj: unknown): void {
|
|
75
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(obj, null, 2) + "\n");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function readConfig(): RawConfig {
|
|
79
|
+
return JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function seedBalancedConfig(): void {
|
|
83
|
+
writeConfig({ llm: { default: { provider: "anthropic" } } });
|
|
84
|
+
invalidateConfigCache();
|
|
85
|
+
seedInferenceProfiles({});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
describe("reconcileFlagGatedProfiles", () => {
|
|
89
|
+
beforeEach(() => {
|
|
90
|
+
ensureTestDir();
|
|
91
|
+
if (existsSync(CONFIG_PATH)) rmSync(CONFIG_PATH, { force: true });
|
|
92
|
+
delete process.env.IS_PLATFORM;
|
|
93
|
+
setOverridesForTesting({});
|
|
94
|
+
invalidateConfigCache();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
afterEach(() => {
|
|
98
|
+
delete process.env.IS_PLATFORM;
|
|
99
|
+
setOverridesForTesting({});
|
|
100
|
+
invalidateConfigCache();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("flag on materializes the managed os-beta profile after balanced", () => {
|
|
104
|
+
process.env.IS_PLATFORM = "true";
|
|
105
|
+
seedBalancedConfig();
|
|
106
|
+
setOverridesForTesting({ "os-beta": true });
|
|
107
|
+
|
|
108
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
109
|
+
|
|
110
|
+
const raw = readConfig();
|
|
111
|
+
const osBeta = raw.llm.profiles["os-beta"]!;
|
|
112
|
+
expect(osBeta.model).toBe("accounts/fireworks/models/glm-5p2");
|
|
113
|
+
expect(osBeta.provider_connection).toBe("fireworks-managed");
|
|
114
|
+
expect(osBeta.source).toBe("managed");
|
|
115
|
+
expect(osBeta.label).toBe("OS Beta");
|
|
116
|
+
|
|
117
|
+
const order = raw.llm.profileOrder;
|
|
118
|
+
expect(order.indexOf("os-beta")).toBe(order.indexOf("balanced") + 1);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("flag on in BYOK mode seeds the os-beta profile disabled", () => {
|
|
122
|
+
seedBalancedConfig();
|
|
123
|
+
setOverridesForTesting({ "os-beta": true });
|
|
124
|
+
|
|
125
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
126
|
+
|
|
127
|
+
const osBeta = readConfig().llm.profiles["os-beta"]!;
|
|
128
|
+
expect(osBeta.status).toBe("disabled");
|
|
129
|
+
expect(osBeta.label).toBe("OS Beta (Managed)");
|
|
130
|
+
expect(osBeta.source).toBe("managed");
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("flag on is idempotent across repeated runs", () => {
|
|
134
|
+
process.env.IS_PLATFORM = "true";
|
|
135
|
+
seedBalancedConfig();
|
|
136
|
+
setOverridesForTesting({ "os-beta": true });
|
|
137
|
+
|
|
138
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
139
|
+
invalidateConfigCache();
|
|
140
|
+
expect(reconcileFlagGatedProfiles()).toBe(false);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("flag on preserves user overrides on the managed profile", () => {
|
|
144
|
+
process.env.IS_PLATFORM = "true";
|
|
145
|
+
seedBalancedConfig();
|
|
146
|
+
setOverridesForTesting({ "os-beta": true });
|
|
147
|
+
reconcileFlagGatedProfiles();
|
|
148
|
+
|
|
149
|
+
const raw = readConfig();
|
|
150
|
+
raw.llm.profiles["os-beta"]!.label = "My OS Beta";
|
|
151
|
+
raw.llm.profiles["os-beta"]!.status = "disabled";
|
|
152
|
+
raw.llm.profiles["os-beta"]!.advisorEnabled = true;
|
|
153
|
+
writeConfig(raw);
|
|
154
|
+
invalidateConfigCache();
|
|
155
|
+
|
|
156
|
+
reconcileFlagGatedProfiles();
|
|
157
|
+
|
|
158
|
+
const after = readConfig().llm.profiles["os-beta"]!;
|
|
159
|
+
expect(after.label).toBe("My OS Beta");
|
|
160
|
+
expect(after.status).toBe("disabled");
|
|
161
|
+
expect(after.advisorEnabled).toBe(true);
|
|
162
|
+
expect(after.model).toBe("accounts/fireworks/models/glm-5p2");
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test("flag off removes a managed os-beta and applies fallbacks", () => {
|
|
166
|
+
process.env.IS_PLATFORM = "true";
|
|
167
|
+
seedBalancedConfig();
|
|
168
|
+
setOverridesForTesting({ "os-beta": true });
|
|
169
|
+
reconcileFlagGatedProfiles();
|
|
170
|
+
|
|
171
|
+
const raw = readConfig();
|
|
172
|
+
raw.llm.activeProfile = "os-beta";
|
|
173
|
+
raw.llm.advisorProfile = "os-beta";
|
|
174
|
+
writeConfig(raw);
|
|
175
|
+
invalidateConfigCache();
|
|
176
|
+
|
|
177
|
+
setOverridesForTesting({ "os-beta": false });
|
|
178
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
179
|
+
|
|
180
|
+
const after = readConfig();
|
|
181
|
+
expect(after.llm.profiles["os-beta"]).toBeUndefined();
|
|
182
|
+
expect(after.llm.profileOrder.includes("os-beta")).toBe(false);
|
|
183
|
+
expect(after.llm.activeProfile).toBe("balanced");
|
|
184
|
+
expect(after.llm.advisorProfile).toBe("quality-optimized");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("flag off with no os-beta present is a no-op", () => {
|
|
188
|
+
process.env.IS_PLATFORM = "true";
|
|
189
|
+
seedBalancedConfig();
|
|
190
|
+
setOverridesForTesting({ "os-beta": false });
|
|
191
|
+
|
|
192
|
+
expect(reconcileFlagGatedProfiles()).toBe(false);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("flag off scrubs os-beta from user mix arms, keeping >= 2-arm mixes", () => {
|
|
196
|
+
process.env.IS_PLATFORM = "true";
|
|
197
|
+
seedBalancedConfig();
|
|
198
|
+
setOverridesForTesting({ "os-beta": true });
|
|
199
|
+
reconcileFlagGatedProfiles();
|
|
200
|
+
|
|
201
|
+
const raw = readConfig();
|
|
202
|
+
raw.llm.profiles["my-mix"] = {
|
|
203
|
+
source: "user",
|
|
204
|
+
label: "My Mix",
|
|
205
|
+
mix: [
|
|
206
|
+
{ profile: "balanced", weight: 70 },
|
|
207
|
+
{ profile: "quality-optimized", weight: 20 },
|
|
208
|
+
{ profile: "os-beta", weight: 30 },
|
|
209
|
+
],
|
|
210
|
+
};
|
|
211
|
+
raw.llm.profileOrder.push("my-mix");
|
|
212
|
+
writeConfig(raw);
|
|
213
|
+
invalidateConfigCache();
|
|
214
|
+
|
|
215
|
+
setOverridesForTesting({ "os-beta": false });
|
|
216
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
217
|
+
|
|
218
|
+
const after = readConfig();
|
|
219
|
+
expect(after.llm.profiles["os-beta"]).toBeUndefined();
|
|
220
|
+
const mix = after.llm.profiles["my-mix"]!;
|
|
221
|
+
expect(mix.mix).toEqual([
|
|
222
|
+
{ profile: "balanced", weight: 70 },
|
|
223
|
+
{ profile: "quality-optimized", weight: 20 },
|
|
224
|
+
]);
|
|
225
|
+
expect(mix.source).toBe("user");
|
|
226
|
+
expect(mix.label).toBe("My Mix");
|
|
227
|
+
|
|
228
|
+
invalidateConfigCache();
|
|
229
|
+
expect(reconcileFlagGatedProfiles()).toBe(false);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("flag off removes a two-arm mix that loses os-beta and repoints refs", () => {
|
|
233
|
+
process.env.IS_PLATFORM = "true";
|
|
234
|
+
seedBalancedConfig();
|
|
235
|
+
setOverridesForTesting({ "os-beta": true });
|
|
236
|
+
reconcileFlagGatedProfiles();
|
|
237
|
+
|
|
238
|
+
const raw = readConfig();
|
|
239
|
+
raw.llm.profiles["experiment"] = {
|
|
240
|
+
source: "user",
|
|
241
|
+
label: "Experiment",
|
|
242
|
+
mix: [
|
|
243
|
+
{ profile: "balanced", weight: 50 },
|
|
244
|
+
{ profile: "os-beta", weight: 50 },
|
|
245
|
+
],
|
|
246
|
+
};
|
|
247
|
+
raw.llm.profileOrder.push("experiment");
|
|
248
|
+
raw.llm.activeProfile = "experiment";
|
|
249
|
+
raw.llm.advisorProfile = "os-beta";
|
|
250
|
+
(raw.llm as Record<string, unknown>).callSites = {
|
|
251
|
+
mainAgent: { profile: "experiment" },
|
|
252
|
+
};
|
|
253
|
+
writeConfig(raw);
|
|
254
|
+
invalidateConfigCache();
|
|
255
|
+
|
|
256
|
+
setOverridesForTesting({ "os-beta": false });
|
|
257
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
258
|
+
|
|
259
|
+
const after = readConfig();
|
|
260
|
+
expect(after.llm.profiles["os-beta"]).toBeUndefined();
|
|
261
|
+
expect(after.llm.profiles["experiment"]).toBeUndefined();
|
|
262
|
+
expect(after.llm.profileOrder.includes("os-beta")).toBe(false);
|
|
263
|
+
expect(after.llm.profileOrder.includes("experiment")).toBe(false);
|
|
264
|
+
expect(after.llm.activeProfile).toBe("balanced");
|
|
265
|
+
expect(after.llm.advisorProfile).toBe("quality-optimized");
|
|
266
|
+
expect(
|
|
267
|
+
(
|
|
268
|
+
after.llm as unknown as Record<
|
|
269
|
+
string,
|
|
270
|
+
Record<string, Record<string, unknown>>
|
|
271
|
+
>
|
|
272
|
+
).callSites.mainAgent.profile,
|
|
273
|
+
).toBeUndefined();
|
|
274
|
+
|
|
275
|
+
expect(LLMSchema.safeParse(after.llm).success).toBe(true);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test("flag off shortens a three-arm mix to two surviving arms", () => {
|
|
279
|
+
process.env.IS_PLATFORM = "true";
|
|
280
|
+
seedBalancedConfig();
|
|
281
|
+
setOverridesForTesting({ "os-beta": true });
|
|
282
|
+
reconcileFlagGatedProfiles();
|
|
283
|
+
|
|
284
|
+
const raw = readConfig();
|
|
285
|
+
raw.llm.profiles["blend"] = {
|
|
286
|
+
source: "user",
|
|
287
|
+
label: "Blend",
|
|
288
|
+
mix: [
|
|
289
|
+
{ profile: "balanced", weight: 40 },
|
|
290
|
+
{ profile: "os-beta", weight: 30 },
|
|
291
|
+
{ profile: "quality-optimized", weight: 30 },
|
|
292
|
+
],
|
|
293
|
+
};
|
|
294
|
+
raw.llm.profileOrder.push("blend");
|
|
295
|
+
writeConfig(raw);
|
|
296
|
+
invalidateConfigCache();
|
|
297
|
+
|
|
298
|
+
setOverridesForTesting({ "os-beta": false });
|
|
299
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
300
|
+
|
|
301
|
+
const after = readConfig();
|
|
302
|
+
expect(after.llm.profiles["os-beta"]).toBeUndefined();
|
|
303
|
+
expect(after.llm.profiles["blend"]!.mix).toEqual([
|
|
304
|
+
{ profile: "balanced", weight: 40 },
|
|
305
|
+
{ profile: "quality-optimized", weight: 30 },
|
|
306
|
+
]);
|
|
307
|
+
|
|
308
|
+
expect(LLMSchema.safeParse(after.llm).success).toBe(true);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("flag off clears a call-site profile reference to os-beta", () => {
|
|
312
|
+
process.env.IS_PLATFORM = "true";
|
|
313
|
+
seedBalancedConfig();
|
|
314
|
+
setOverridesForTesting({ "os-beta": true });
|
|
315
|
+
reconcileFlagGatedProfiles();
|
|
316
|
+
|
|
317
|
+
const raw = readConfig();
|
|
318
|
+
(raw.llm as Record<string, unknown>).callSites = {
|
|
319
|
+
advisor: { profile: "os-beta", temperature: 0.3 },
|
|
320
|
+
};
|
|
321
|
+
writeConfig(raw);
|
|
322
|
+
invalidateConfigCache();
|
|
323
|
+
|
|
324
|
+
setOverridesForTesting({ "os-beta": false });
|
|
325
|
+
expect(reconcileFlagGatedProfiles()).toBe(true);
|
|
326
|
+
|
|
327
|
+
const after = readConfig();
|
|
328
|
+
const advisor = (
|
|
329
|
+
after.llm as unknown as Record<
|
|
330
|
+
string,
|
|
331
|
+
Record<string, Record<string, unknown>>
|
|
332
|
+
>
|
|
333
|
+
).callSites.advisor;
|
|
334
|
+
expect(advisor.profile).toBeUndefined();
|
|
335
|
+
expect(advisor.temperature).toBe(0.3);
|
|
336
|
+
|
|
337
|
+
expect(LLMSchema.safeParse(after.llm).success).toBe(true);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
test("a user-owned os-beta profile is never touched", () => {
|
|
341
|
+
process.env.IS_PLATFORM = "true";
|
|
342
|
+
writeConfig({
|
|
343
|
+
llm: {
|
|
344
|
+
default: { provider: "anthropic" },
|
|
345
|
+
profiles: {
|
|
346
|
+
"os-beta": {
|
|
347
|
+
source: "user",
|
|
348
|
+
label: "Mine",
|
|
349
|
+
provider: "anthropic",
|
|
350
|
+
model: "claude-x",
|
|
351
|
+
provider_connection: "anthropic-personal",
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
profileOrder: ["os-beta"],
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
invalidateConfigCache();
|
|
358
|
+
const before = readFileSync(CONFIG_PATH, "utf-8");
|
|
359
|
+
|
|
360
|
+
setOverridesForTesting({ "os-beta": true });
|
|
361
|
+
expect(reconcileFlagGatedProfiles()).toBe(false);
|
|
362
|
+
expect(readFileSync(CONFIG_PATH, "utf-8")).toBe(before);
|
|
363
|
+
|
|
364
|
+
setOverridesForTesting({ "os-beta": false });
|
|
365
|
+
expect(reconcileFlagGatedProfiles()).toBe(false);
|
|
366
|
+
expect(readFileSync(CONFIG_PATH, "utf-8")).toBe(before);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
@@ -103,7 +103,11 @@ function parseRegistryToDefaults(parsed: unknown): FeatureFlagDefaultsRegistry {
|
|
|
103
103
|
const entry = flag as Record<string, unknown>;
|
|
104
104
|
if (entry.scope !== "assistant" && entry.scope !== "both") continue;
|
|
105
105
|
if (typeof entry.key !== "string") continue;
|
|
106
|
-
if (
|
|
106
|
+
if (
|
|
107
|
+
typeof entry.defaultEnabled !== "boolean" &&
|
|
108
|
+
typeof entry.defaultEnabled !== "string"
|
|
109
|
+
)
|
|
110
|
+
continue;
|
|
107
111
|
|
|
108
112
|
result[entry.key as string] = {
|
|
109
113
|
defaultEnabled: entry.defaultEnabled,
|
|
@@ -178,6 +182,12 @@ const DEFAULT_INIT_RETRY_BACKOFFS_MS: readonly number[] = [
|
|
|
178
182
|
* tests preseed flag state via `setOverridesForTesting()` (in
|
|
179
183
|
* `__tests__/feature-flag-test-helpers.ts`) without the gateway IPC call
|
|
180
184
|
* clobbering their setup.
|
|
185
|
+
*
|
|
186
|
+
* Resolves `true` when the override cache is populated from the gateway and
|
|
187
|
+
* `false` when the cache is left unset (exhausted retries / unreachable
|
|
188
|
+
* gateway). Callers that mutate persisted state from flag values gate that
|
|
189
|
+
* work on a `true` result so a failed fetch never resolves a flag to its
|
|
190
|
+
* registry default and drops user state.
|
|
181
191
|
*/
|
|
182
192
|
export async function initFeatureFlagOverrides(options?: {
|
|
183
193
|
retryBackoffsMs?: readonly number[];
|
|
@@ -188,8 +198,8 @@ export async function initFeatureFlagOverrides(options?: {
|
|
|
188
198
|
* instead of blocking startup.
|
|
189
199
|
*/
|
|
190
200
|
callTimeoutMs?: number;
|
|
191
|
-
}): Promise<
|
|
192
|
-
if (isCachedFromGateway()) return;
|
|
201
|
+
}): Promise<boolean> {
|
|
202
|
+
if (isCachedFromGateway()) return true;
|
|
193
203
|
|
|
194
204
|
const backoffs = options?.retryBackoffsMs ?? DEFAULT_INIT_RETRY_BACKOFFS_MS;
|
|
195
205
|
const callTimeoutMs = options?.callTimeoutMs;
|
|
@@ -205,7 +215,7 @@ export async function initFeatureFlagOverrides(options?: {
|
|
|
205
215
|
// Re-check after the wait: a concurrent caller (e.g. a test using
|
|
206
216
|
// `setOverridesForTesting`) may have populated the cache while we
|
|
207
217
|
// were sleeping. Bail out so we don't clobber their setup.
|
|
208
|
-
if (isCachedFromGateway()) return;
|
|
218
|
+
if (isCachedFromGateway()) return true;
|
|
209
219
|
}
|
|
210
220
|
|
|
211
221
|
const gatewayOverrides = await fetchOverridesFromGateway(callTimeoutMs);
|
|
@@ -217,7 +227,7 @@ export async function initFeatureFlagOverrides(options?: {
|
|
|
217
227
|
"Feature flag overrides loaded from gateway after retry",
|
|
218
228
|
);
|
|
219
229
|
}
|
|
220
|
-
return;
|
|
230
|
+
return true;
|
|
221
231
|
}
|
|
222
232
|
}
|
|
223
233
|
|
|
@@ -230,6 +240,7 @@ export async function initFeatureFlagOverrides(options?: {
|
|
|
230
240
|
"Feature flag overrides empty after all retries; falling back to registry defaults and fail-closed undeclared flags",
|
|
231
241
|
);
|
|
232
242
|
}
|
|
243
|
+
return false;
|
|
233
244
|
}
|
|
234
245
|
|
|
235
246
|
/**
|
|
@@ -262,10 +273,14 @@ export function clearFeatureFlagOverridesCache(): void {
|
|
|
262
273
|
* retries (the gateway is known to be up because it just pushed an event).
|
|
263
274
|
* Called by the gateway flag listener when a `feature_flags_changed` event
|
|
264
275
|
* arrives.
|
|
276
|
+
*
|
|
277
|
+
* Resolves `true` when the cache was repopulated from the gateway, `false`
|
|
278
|
+
* when the fetch came back empty/failed — callers gate persisted-state
|
|
279
|
+
* reconciliation on a `true` result.
|
|
265
280
|
*/
|
|
266
|
-
export async function refreshOverridesFromGateway(): Promise<
|
|
281
|
+
export async function refreshOverridesFromGateway(): Promise<boolean> {
|
|
267
282
|
clearFeatureFlagOverridesCache();
|
|
268
|
-
|
|
283
|
+
return initFeatureFlagOverrides({ retryBackoffsMs: [] });
|
|
269
284
|
}
|
|
270
285
|
|
|
271
286
|
// ---------------------------------------------------------------------------
|
|
@@ -425,6 +425,14 @@
|
|
|
425
425
|
"label": "MCP Settings",
|
|
426
426
|
"description": "Show the MCP page in Settings for managing Model Context Protocol server connections: view status, enable/disable, configure, and inspect registered tools per server.",
|
|
427
427
|
"defaultEnabled": false
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
"id": "os-beta",
|
|
431
|
+
"scope": "assistant",
|
|
432
|
+
"key": "os-beta",
|
|
433
|
+
"label": "OS Beta",
|
|
434
|
+
"description": "Enable the OS Beta model profile (GLM 5.2 / Fireworks) in the assistant's model profile selection.",
|
|
435
|
+
"defaultEnabled": false
|
|
428
436
|
}
|
|
429
437
|
]
|
|
430
438
|
}
|
|
@@ -27,7 +27,10 @@ type ManagedProfileTemplate = Omit<
|
|
|
27
27
|
ProfileEntry,
|
|
28
28
|
"provider" | "model" | "provider_connection"
|
|
29
29
|
> & {
|
|
30
|
-
intent
|
|
30
|
+
// Exactly one of `intent` or `model` must be set. `intent` resolves the
|
|
31
|
+
// model from the catalog at seed time; `model` pins an explicit model id.
|
|
32
|
+
intent?: ModelIntent;
|
|
33
|
+
model?: string;
|
|
31
34
|
provider: NonNullable<ProfileEntry["provider"]>;
|
|
32
35
|
connectionName: string;
|
|
33
36
|
};
|
|
@@ -136,8 +139,37 @@ const USER_PROFILE_TEMPLATES: Record<string, ManagedProfileTemplate> = {
|
|
|
136
139
|
*/
|
|
137
140
|
export const AUTO_PROFILE_KEY = "auto";
|
|
138
141
|
|
|
142
|
+
export const OS_BETA_PROFILE_KEY = "os-beta";
|
|
143
|
+
export const OS_BETA_FEATURE_FLAG_KEY = "os-beta";
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Flag-gated managed profile. NOT in MANAGED_PROFILE_TEMPLATES, so the
|
|
147
|
+
* unconditional boot seed never creates it. Reconciled in/out by
|
|
148
|
+
* the flag-gated profile reconcile based on the `os-beta` feature flag.
|
|
149
|
+
* Balanced-parity defaults; GLM 5.2 pinned explicitly via `model`.
|
|
150
|
+
*/
|
|
151
|
+
export const OS_BETA_PROFILE_TEMPLATE: ManagedProfileTemplate = {
|
|
152
|
+
model: "accounts/fireworks/models/glm-5p2",
|
|
153
|
+
provider: "fireworks",
|
|
154
|
+
connectionName: "fireworks-managed",
|
|
155
|
+
source: "managed",
|
|
156
|
+
label: "OS Beta",
|
|
157
|
+
description: "Open-source frontier model (GLM 5.2), in beta",
|
|
158
|
+
maxTokens: 32000,
|
|
159
|
+
effort: "high",
|
|
160
|
+
thinking: { enabled: true, streamThinking: true },
|
|
161
|
+
contextWindow: { maxInputTokens: DEFAULT_CONTEXT_WINDOW_MAX_INPUT_TOKENS },
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// Membership here marks a name as managed. The route layer applies managed
|
|
165
|
+
// restrictions (blocking model/provider edits and deletion) only to entries
|
|
166
|
+
// whose on-disk `source` is `managed`, so a user-owned profile sharing one of
|
|
167
|
+
// these names is not locked. `OS_BETA_PROFILE_KEY` is flag-gated: it is
|
|
168
|
+
// materialized by the flag-gated profile reconcile, which refuses to touch a
|
|
169
|
+
// same-named user profile.
|
|
139
170
|
export const MANAGED_PROFILE_NAMES = new Set([
|
|
140
171
|
...Object.keys(MANAGED_PROFILE_TEMPLATES),
|
|
172
|
+
OS_BETA_PROFILE_KEY,
|
|
141
173
|
AUTO_PROFILE_KEY,
|
|
142
174
|
]);
|
|
143
175
|
|
|
@@ -433,21 +465,26 @@ export function seedInferenceProfiles(
|
|
|
433
465
|
saveRawConfig(config);
|
|
434
466
|
}
|
|
435
467
|
|
|
436
|
-
function materializeProfile(
|
|
468
|
+
export function materializeProfile(
|
|
437
469
|
template: ManagedProfileTemplate,
|
|
438
470
|
provider: NonNullable<ProfileEntry["provider"]>,
|
|
439
471
|
connectionName: string,
|
|
440
472
|
): ProfileEntry {
|
|
441
|
-
const { intent, provider: _p, connectionName: _c, ...rest } = template;
|
|
473
|
+
const { intent, model, provider: _p, connectionName: _c, ...rest } = template;
|
|
474
|
+
const resolvedModel =
|
|
475
|
+
model ?? (intent ? resolveModelIntent(provider, intent) : undefined);
|
|
476
|
+
if (!resolvedModel) {
|
|
477
|
+
throw new Error("ManagedProfileTemplate requires `intent` or `model`");
|
|
478
|
+
}
|
|
442
479
|
return {
|
|
443
480
|
...rest,
|
|
444
481
|
provider,
|
|
445
482
|
provider_connection: connectionName,
|
|
446
|
-
model:
|
|
483
|
+
model: resolvedModel,
|
|
447
484
|
};
|
|
448
485
|
}
|
|
449
486
|
|
|
450
|
-
function readObject(value: unknown): Record<string, unknown> | null {
|
|
487
|
+
export function readObject(value: unknown): Record<string, unknown> | null {
|
|
451
488
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
452
489
|
? (value as Record<string, unknown>)
|
|
453
490
|
: null;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
2
|
+
|
|
3
|
+
import { getLogger } from "../util/logger.js";
|
|
4
|
+
import { isAssistantFeatureFlagEnabled } from "./assistant-feature-flags.js";
|
|
5
|
+
import {
|
|
6
|
+
getConfigReadOnly,
|
|
7
|
+
invalidateConfigCache,
|
|
8
|
+
loadRawConfig,
|
|
9
|
+
saveRawConfig,
|
|
10
|
+
} from "./loader.js";
|
|
11
|
+
import type { ProfileEntry } from "./schemas/llm.js";
|
|
12
|
+
import {
|
|
13
|
+
materializeProfile,
|
|
14
|
+
OS_BETA_FEATURE_FLAG_KEY,
|
|
15
|
+
OS_BETA_PROFILE_KEY,
|
|
16
|
+
OS_BETA_PROFILE_TEMPLATE,
|
|
17
|
+
readObject,
|
|
18
|
+
} from "./seed-inference-profiles.js";
|
|
19
|
+
|
|
20
|
+
const log = getLogger("sync-gated-profiles");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Reconcile flag-gated managed profiles against the current feature-flag state.
|
|
24
|
+
*
|
|
25
|
+
* `seedInferenceProfiles()` runs synchronously at boot before feature flags are
|
|
26
|
+
* available, so the OS Beta profile (GLM 5.2 / fireworks-managed) is materialized
|
|
27
|
+
* here once flags have loaded. When the `os-beta` flag is on, the managed profile
|
|
28
|
+
* is created (ordered right after `balanced`); when it is off, a previously
|
|
29
|
+
* managed entry is removed with `profileOrder` / `activeProfile` / `advisorProfile`
|
|
30
|
+
* fallbacks. The reconcile is idempotent and never touches a user-owned profile of
|
|
31
|
+
* the same name.
|
|
32
|
+
*
|
|
33
|
+
* Returns whether the on-disk config changed.
|
|
34
|
+
*/
|
|
35
|
+
export function reconcileFlagGatedProfiles(): boolean {
|
|
36
|
+
const config = loadRawConfig();
|
|
37
|
+
|
|
38
|
+
if (config.llm == null || typeof config.llm !== "object") {
|
|
39
|
+
config.llm = {};
|
|
40
|
+
}
|
|
41
|
+
const llm = config.llm as Record<string, unknown>;
|
|
42
|
+
|
|
43
|
+
if (llm.profiles == null || typeof llm.profiles !== "object") {
|
|
44
|
+
llm.profiles = {};
|
|
45
|
+
}
|
|
46
|
+
const profiles = llm.profiles as Record<string, Record<string, unknown>>;
|
|
47
|
+
|
|
48
|
+
const profileOrder = Array.isArray(llm.profileOrder)
|
|
49
|
+
? (llm.profileOrder as string[])
|
|
50
|
+
: [];
|
|
51
|
+
llm.profileOrder = profileOrder;
|
|
52
|
+
|
|
53
|
+
// The resolver reads flag state from the gateway-populated override cache and
|
|
54
|
+
// ignores the config argument; pass the read-only config for signature parity
|
|
55
|
+
// without mutating disk before the reconcile decision is made.
|
|
56
|
+
const enabled = isAssistantFeatureFlagEnabled(
|
|
57
|
+
OS_BETA_FEATURE_FLAG_KEY,
|
|
58
|
+
getConfigReadOnly(),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const isPlatform =
|
|
62
|
+
process.env.IS_PLATFORM === "true" || process.env.IS_PLATFORM === "1";
|
|
63
|
+
const isByokMode = !isPlatform;
|
|
64
|
+
|
|
65
|
+
const previous = readObject(profiles[OS_BETA_PROFILE_KEY]);
|
|
66
|
+
|
|
67
|
+
// Never clobber a user-owned profile that happens to be named `os-beta`. The
|
|
68
|
+
// entry is ours to manage only when it is absent or already managed; a
|
|
69
|
+
// user-sourced entry of the same name is left untouched on every path.
|
|
70
|
+
const isOursToManage = previous == null || previous.source === "managed";
|
|
71
|
+
if (!isOursToManage) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const changed = enabled
|
|
76
|
+
? enableProfile(profiles, profileOrder, previous, isByokMode)
|
|
77
|
+
: disableProfile(llm, profiles, profileOrder, previous);
|
|
78
|
+
|
|
79
|
+
if (changed) {
|
|
80
|
+
saveRawConfig(config);
|
|
81
|
+
invalidateConfigCache();
|
|
82
|
+
log.info(
|
|
83
|
+
{ profile: OS_BETA_PROFILE_KEY, enabled },
|
|
84
|
+
"Reconciled flag-gated profile",
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return changed;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function enableProfile(
|
|
91
|
+
profiles: Record<string, Record<string, unknown>>,
|
|
92
|
+
profileOrder: string[],
|
|
93
|
+
previous: Record<string, unknown> | null,
|
|
94
|
+
isByokMode: boolean,
|
|
95
|
+
): boolean {
|
|
96
|
+
const effectiveTemplate = isByokMode
|
|
97
|
+
? {
|
|
98
|
+
...OS_BETA_PROFILE_TEMPLATE,
|
|
99
|
+
label: `${OS_BETA_PROFILE_TEMPLATE.label} (Managed)`,
|
|
100
|
+
}
|
|
101
|
+
: OS_BETA_PROFILE_TEMPLATE;
|
|
102
|
+
const next = materializeProfile(
|
|
103
|
+
effectiveTemplate,
|
|
104
|
+
OS_BETA_PROFILE_TEMPLATE.provider,
|
|
105
|
+
OS_BETA_PROFILE_TEMPLATE.connectionName,
|
|
106
|
+
) as Record<string, unknown>;
|
|
107
|
+
|
|
108
|
+
// BYOK installs seed managed profiles disabled: the platform-auth
|
|
109
|
+
// `fireworks-managed` connection backing this profile isn't usable until the
|
|
110
|
+
// user enables it, so a fresh OS Beta entry starts disabled to avoid offering
|
|
111
|
+
// an unusable route. A user's own status override (preserved below) wins on
|
|
112
|
+
// later reconciles.
|
|
113
|
+
if (isByokMode && !previous) {
|
|
114
|
+
next.status = "disabled";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (previous) {
|
|
118
|
+
// The only fields a user may override on a managed profile. Carry `label`
|
|
119
|
+
// by key-presence so an explicit null (user cleared it) survives too.
|
|
120
|
+
if ("label" in previous) next.label = previous.label;
|
|
121
|
+
if ("status" in previous) next.status = previous.status;
|
|
122
|
+
if ("advisorEnabled" in previous) {
|
|
123
|
+
next.advisorEnabled = previous.advisorEnabled;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let changed = false;
|
|
128
|
+
if (!previous || !isDeepStrictEqual(previous, next)) {
|
|
129
|
+
profiles[OS_BETA_PROFILE_KEY] = next as ProfileEntry;
|
|
130
|
+
changed = true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!profileOrder.includes(OS_BETA_PROFILE_KEY)) {
|
|
134
|
+
const balancedIndex = profileOrder.indexOf("balanced");
|
|
135
|
+
if (balancedIndex >= 0) {
|
|
136
|
+
profileOrder.splice(balancedIndex + 1, 0, OS_BETA_PROFILE_KEY);
|
|
137
|
+
} else {
|
|
138
|
+
profileOrder.push(OS_BETA_PROFILE_KEY);
|
|
139
|
+
}
|
|
140
|
+
changed = true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return changed;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// `MixSchema = z.array(MixArmSchema).min(2)` in schemas/llm.ts: mixes require
|
|
147
|
+
// >= 2 arms. A mix that drops below this is invalid and cannot be kept.
|
|
148
|
+
const MIX_MIN_ARMS = 2;
|
|
149
|
+
|
|
150
|
+
function disableProfile(
|
|
151
|
+
llm: Record<string, unknown>,
|
|
152
|
+
profiles: Record<string, Record<string, unknown>>,
|
|
153
|
+
profileOrder: string[],
|
|
154
|
+
previous: Record<string, unknown> | null,
|
|
155
|
+
): boolean {
|
|
156
|
+
if (!previous) return false;
|
|
157
|
+
|
|
158
|
+
delete profiles[OS_BETA_PROFILE_KEY];
|
|
159
|
+
|
|
160
|
+
// The removal closure: every name here is absent from `profiles` once the
|
|
161
|
+
// closure settles, so the written config can never reference one. A mix that
|
|
162
|
+
// loses arms below the >= 2 minimum is itself invalid, so it joins the set
|
|
163
|
+
// and the loop runs to a fixpoint to resolve any references that cascade.
|
|
164
|
+
const removed = new Set<string>([OS_BETA_PROFILE_KEY]);
|
|
165
|
+
let cascading = true;
|
|
166
|
+
while (cascading) {
|
|
167
|
+
cascading = false;
|
|
168
|
+
for (const [name, profile] of Object.entries(profiles)) {
|
|
169
|
+
if (removed.has(name)) continue;
|
|
170
|
+
if (!Array.isArray(profile.mix)) continue;
|
|
171
|
+
const arms = profile.mix as unknown[];
|
|
172
|
+
const kept = arms.filter((arm) => {
|
|
173
|
+
const armProfile = readObject(arm)?.profile;
|
|
174
|
+
return typeof armProfile !== "string" || !removed.has(armProfile);
|
|
175
|
+
});
|
|
176
|
+
if (kept.length === arms.length) continue;
|
|
177
|
+
if (kept.length >= MIX_MIN_ARMS) {
|
|
178
|
+
profile.mix = kept;
|
|
179
|
+
} else {
|
|
180
|
+
delete profiles[name];
|
|
181
|
+
removed.add(name);
|
|
182
|
+
}
|
|
183
|
+
cascading = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
llm.profileOrder = profileOrder.filter((name) => !removed.has(name));
|
|
188
|
+
|
|
189
|
+
if (typeof llm.activeProfile === "string" && removed.has(llm.activeProfile)) {
|
|
190
|
+
llm.activeProfile = "balanced";
|
|
191
|
+
}
|
|
192
|
+
if (
|
|
193
|
+
typeof llm.advisorProfile === "string" &&
|
|
194
|
+
removed.has(llm.advisorProfile)
|
|
195
|
+
) {
|
|
196
|
+
if (readObject(profiles["quality-optimized"]) !== null) {
|
|
197
|
+
llm.advisorProfile = "quality-optimized";
|
|
198
|
+
} else {
|
|
199
|
+
delete llm.advisorProfile;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Clear any call-site `profile` reference to a removed profile; other override
|
|
204
|
+
// fields on the entry stay intact (an empty override object is valid).
|
|
205
|
+
const callSites = readObject(llm.callSites);
|
|
206
|
+
if (callSites) {
|
|
207
|
+
for (const entry of Object.values(callSites)) {
|
|
208
|
+
const site = readObject(entry);
|
|
209
|
+
if (
|
|
210
|
+
site &&
|
|
211
|
+
typeof site.profile === "string" &&
|
|
212
|
+
removed.has(site.profile)
|
|
213
|
+
) {
|
|
214
|
+
delete site.profile;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return true;
|
|
220
|
+
}
|
package/src/daemon/lifecycle.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import { loadConfig, mergeDefaultWorkspaceConfig } from "../config/loader.js";
|
|
21
21
|
import type { AssistantConfig } from "../config/schema.js";
|
|
22
22
|
import { seedInferenceProfiles } from "../config/seed-inference-profiles.js";
|
|
23
|
+
import { reconcileFlagGatedProfiles } from "../config/sync-gated-profiles.js";
|
|
23
24
|
import type { CesClient } from "../credential-execution/client.js";
|
|
24
25
|
import { createCesClient } from "../credential-execution/client.js";
|
|
25
26
|
import { refreshManagedConnectionCache } from "../credential-execution/managed-catalog.js";
|
|
@@ -75,7 +76,10 @@ import {
|
|
|
75
76
|
import { RuntimeHttpServer } from "../runtime/http-server.js";
|
|
76
77
|
import { recoverInterruptedImport } from "../runtime/migrations/vbundle-streaming-importer.js";
|
|
77
78
|
import { registerSecretsDeps } from "../runtime/routes/secrets-deps.js";
|
|
78
|
-
import {
|
|
79
|
+
import {
|
|
80
|
+
publishConfigChanged,
|
|
81
|
+
publishConversationListChanged,
|
|
82
|
+
} from "../runtime/sync/resource-sync-events.js";
|
|
79
83
|
import { recoverStaleSchedules } from "../schedule/schedule-recovery.js";
|
|
80
84
|
import { startScheduler } from "../schedule/scheduler.js";
|
|
81
85
|
import {
|
|
@@ -371,8 +375,23 @@ export async function runDaemon(): Promise<void> {
|
|
|
371
375
|
// this fetch completes, so without this follow-up sync a flag-enabled
|
|
372
376
|
// assistant would not expose the gated tools until a restart (which can lose
|
|
373
377
|
// the same race). Enable-direction only; chained so it sees the fresh cache.
|
|
378
|
+
// Then reconcile flag-gated managed profiles (OS Beta): `seedInferenceProfiles()`
|
|
379
|
+
// runs synchronously earlier in boot before flags are available, so this lands
|
|
380
|
+
// the profile on the same boot once the flag cache is populated. When this
|
|
381
|
+
// reconcile is the call that mutates config (it raced ahead of the gateway
|
|
382
|
+
// flag listener), publish the config invalidation so any client that already
|
|
383
|
+
// fetched `GET /v1/config` refreshes its profile picker.
|
|
384
|
+
// Profiles are reconciled only when flags actually loaded from the gateway:
|
|
385
|
+
// a failed fetch leaves the cache unset and resolves `os-beta` to its
|
|
386
|
+
// registry default `false`, which would remove the user's profile and reset
|
|
387
|
+
// their selection. Tool sync tolerates the default and stays unconditional.
|
|
374
388
|
void initFeatureFlagOverrides()
|
|
375
|
-
.then(() =>
|
|
389
|
+
.then(async (loaded) => {
|
|
390
|
+
await syncFlagGatedTools();
|
|
391
|
+
if (loaded && reconcileFlagGatedProfiles()) {
|
|
392
|
+
publishConfigChanged();
|
|
393
|
+
}
|
|
394
|
+
})
|
|
376
395
|
.catch((err) => log.warn({ err }, "Background feature flag init failed"));
|
|
377
396
|
|
|
378
397
|
startGatewayFlagListener();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { connect, type Socket } from "node:net";
|
|
2
2
|
|
|
3
3
|
import { refreshOverridesFromGateway } from "../config/assistant-feature-flags.js";
|
|
4
|
+
import { reconcileFlagGatedProfiles } from "../config/sync-gated-profiles.js";
|
|
4
5
|
import { SYNC_TAGS } from "../daemon/message-types/sync.js";
|
|
6
|
+
import { publishConfigChanged } from "../runtime/sync/resource-sync-events.js";
|
|
5
7
|
import { publishSyncInvalidation } from "../runtime/sync/sync-publisher.js";
|
|
6
8
|
import { syncFlagGatedTools } from "../tools/registry.js";
|
|
7
9
|
import { getLogger } from "../util/logger.js";
|
|
@@ -19,11 +21,25 @@ const log = getLogger("gateway-flag-listener");
|
|
|
19
21
|
* they live in a flag-gated bundled skill surfaced via `skill_load` against the
|
|
20
22
|
* live flag cache, so they need no registry sync here. `syncFlagGatedTools` is
|
|
21
23
|
* idempotent and enable-only, so re-running it on every refresh is safe; it also
|
|
22
|
-
* never throws (it logs internally).
|
|
24
|
+
* never throws (it logs internally). After tools sync, `reconcileFlagGatedProfiles`
|
|
25
|
+
* adds or removes the flag-gated managed profile (OS Beta); when it reports a
|
|
26
|
+
* change a `config_changed` broadcast refreshes the profile picker on clients.
|
|
27
|
+
* The profile reconcile runs only when the refresh confirmed flags loaded from
|
|
28
|
+
* the gateway — a transient IPC failure leaves the cache unset and resolves
|
|
29
|
+
* `os-beta` to its registry default `false`, which would remove the user's
|
|
30
|
+
* profile and reset their selection. Tool sync tolerates the default and stays
|
|
31
|
+
* unconditional.
|
|
23
32
|
*/
|
|
24
33
|
function refreshFlagsAndSyncTools(context: string): void {
|
|
25
34
|
refreshOverridesFromGateway()
|
|
26
|
-
.then(() =>
|
|
35
|
+
.then(async (loaded) => {
|
|
36
|
+
await syncFlagGatedTools();
|
|
37
|
+
if (loaded && reconcileFlagGatedProfiles()) {
|
|
38
|
+
// Reuse the config-changed broadcast clients already consume so the
|
|
39
|
+
// profile picker reflects the added/removed managed profile.
|
|
40
|
+
publishConfigChanged();
|
|
41
|
+
}
|
|
42
|
+
})
|
|
27
43
|
.catch((err) => {
|
|
28
44
|
log.warn(
|
|
29
45
|
{ err },
|
|
@@ -677,6 +677,23 @@ const RAW_PROVIDER_CATALOG: ProviderCatalogEntry[] = [
|
|
|
677
677
|
cacheReadPer1mTokens: 0.16,
|
|
678
678
|
},
|
|
679
679
|
},
|
|
680
|
+
{
|
|
681
|
+
id: "accounts/fireworks/models/glm-5p2",
|
|
682
|
+
displayName: "GLM 5.2",
|
|
683
|
+
// Fireworks serves GLM 5.2 with a 1,040K input window.
|
|
684
|
+
contextWindowTokens: 1040000,
|
|
685
|
+
maxOutputTokens: 131072,
|
|
686
|
+
supportsThinking: true,
|
|
687
|
+
supportsCaching: true,
|
|
688
|
+
supportsVision: false,
|
|
689
|
+
supportsToolUse: true,
|
|
690
|
+
maxEffort: "max",
|
|
691
|
+
pricing: {
|
|
692
|
+
inputPer1mTokens: 1.4,
|
|
693
|
+
outputPer1mTokens: 4.4,
|
|
694
|
+
cacheReadPer1mTokens: 0.26,
|
|
695
|
+
},
|
|
696
|
+
},
|
|
680
697
|
{
|
|
681
698
|
id: "accounts/fireworks/models/kimi-k2p5",
|
|
682
699
|
displayName: "Kimi K2.5",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Family-level classification of "weak open models" — open-weight models
|
|
3
|
-
* (Kimi, DeepSeek, MiniMax) that disregard static instructions and have
|
|
3
|
+
* (Kimi, DeepSeek, MiniMax, GLM) that disregard static instructions and have
|
|
4
4
|
* capability gaps that capable models (Claude, GPT) do not. Used by harness
|
|
5
5
|
* levers that coach or redirect these models without touching capable-model
|
|
6
6
|
* behavior: the task-progress-nudge plugin and the empty-dynamic_page surface
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Distinct from exploration-drift's narrower `LOOP_PRONE_MODEL_PATTERN`, which
|
|
15
15
|
* targets specific loop-prone versions rather than the whole capability family.
|
|
16
16
|
*/
|
|
17
|
-
export const WEAK_OPEN_MODEL_PATTERN = /kimi|deepseek|minimax/i;
|
|
17
|
+
export const WEAK_OPEN_MODEL_PATTERN = /kimi|deepseek|minimax|glm/i;
|
|
18
18
|
|
|
19
19
|
/** True when `model` is a weak open model (see {@link WEAK_OPEN_MODEL_PATTERN}). */
|
|
20
20
|
export function isWeakOpenModel(model: string | null | undefined): boolean {
|
|
@@ -755,8 +755,14 @@ function rejectManagedProfileDeletion(body: Record<string, unknown>): void {
|
|
|
755
755
|
}
|
|
756
756
|
const profiles = asMutablePlainObject(llm.profiles);
|
|
757
757
|
if (!profiles) return;
|
|
758
|
+
const existingProfiles = asMutablePlainObject(getConfig().llm.profiles) ?? {};
|
|
758
759
|
for (const name of Object.keys(profiles)) {
|
|
759
|
-
if (profiles[name]
|
|
760
|
+
if (profiles[name] !== null || !MANAGED_PROFILE_NAMES.has(name)) continue;
|
|
761
|
+
// Only block deletion when the on-disk entry is Vellum-managed. A
|
|
762
|
+
// user-owned profile sharing a managed name carries a non-managed `source`
|
|
763
|
+
// and is freely deletable.
|
|
764
|
+
const existing = asMutablePlainObject(existingProfiles[name]);
|
|
765
|
+
if (existing?.source === "managed") {
|
|
760
766
|
throw new BadRequestError(`Cannot delete managed profile "${name}".`);
|
|
761
767
|
}
|
|
762
768
|
}
|
|
@@ -929,7 +935,24 @@ async function handleReplaceInferenceProfile({
|
|
|
929
935
|
const detail = parsed.error.issues.map((issue) => issue.message).join("; ");
|
|
930
936
|
throw new BadRequestError(`Invalid profile fragment: ${detail}`);
|
|
931
937
|
}
|
|
932
|
-
|
|
938
|
+
// A managed name with no existing entry stays protected so users can't
|
|
939
|
+
// shadow a seeded managed profile. An existing entry carrying a non-managed
|
|
940
|
+
// `source` is user-owned and remains fully editable.
|
|
941
|
+
const existingProfile = asMutablePlainObject(
|
|
942
|
+
getConfig().llm.profiles?.[name],
|
|
943
|
+
);
|
|
944
|
+
const isManaged =
|
|
945
|
+
MANAGED_PROFILE_NAMES.has(name) &&
|
|
946
|
+
(existingProfile == null || existingProfile.source === "managed");
|
|
947
|
+
// A managed profile name with no materialized entry (e.g. a flag-gated profile
|
|
948
|
+
// whose flag is off) cannot be patched: writing label/status here would persist
|
|
949
|
+
// a source-less stub that later blocks the real managed profile from being
|
|
950
|
+
// seeded. Reject rather than create a placeholder.
|
|
951
|
+
if (MANAGED_PROFILE_NAMES.has(name) && existingProfile == null) {
|
|
952
|
+
throw new BadRequestError(
|
|
953
|
+
`Profile "${name}" is not currently available and cannot be edited.`,
|
|
954
|
+
);
|
|
955
|
+
}
|
|
933
956
|
if (isManaged) {
|
|
934
957
|
// Managed profiles are daemon-seeded — provider, model, and the
|
|
935
958
|
// connection binding all belong to the seed contract and can't be
|