@vellumai/assistant 0.9.0-dev.202606191410.d7a0797 → 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/openapi.yaml +84 -0
- 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/api/responses/conversation-message.ts +26 -0
- package/src/cli/commands/db/status.ts +37 -3
- 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/memory/__tests__/db-logs-attach.test.ts +122 -0
- package/src/memory/db-async-query.ts +20 -2
- package/src/memory/db-connection.ts +49 -5
- package/src/permissions/question-prompter.test.ts +27 -0
- package/src/permissions/question-prompter.ts +4 -0
- package/src/providers/model-catalog.ts +17 -0
- package/src/providers/weak-open-model.ts +2 -2
- package/src/runtime/pending-interactions.ts +15 -0
- package/src/runtime/routes/conversation-query-routes.ts +25 -2
- package/src/runtime/routes/conversation-routes.ts +12 -4
- package/src/runtime/routes/tool-call-question-enrichment.test.ts +146 -0
- package/src/runtime/routes/tool-call-question-enrichment.ts +66 -0
- package/src/util/logs-db-path.ts +22 -0
package/openapi.yaml
CHANGED
|
@@ -16408,6 +16408,48 @@ paths:
|
|
|
16408
16408
|
required:
|
|
16409
16409
|
- requestId
|
|
16410
16410
|
additionalProperties: false
|
|
16411
|
+
pendingQuestion:
|
|
16412
|
+
type: object
|
|
16413
|
+
properties:
|
|
16414
|
+
requestId:
|
|
16415
|
+
type: string
|
|
16416
|
+
entries:
|
|
16417
|
+
type: array
|
|
16418
|
+
items:
|
|
16419
|
+
type: object
|
|
16420
|
+
properties:
|
|
16421
|
+
id:
|
|
16422
|
+
type: string
|
|
16423
|
+
question:
|
|
16424
|
+
type: string
|
|
16425
|
+
description:
|
|
16426
|
+
type: string
|
|
16427
|
+
options:
|
|
16428
|
+
type: array
|
|
16429
|
+
items:
|
|
16430
|
+
type: object
|
|
16431
|
+
properties:
|
|
16432
|
+
id:
|
|
16433
|
+
type: string
|
|
16434
|
+
label:
|
|
16435
|
+
type: string
|
|
16436
|
+
description:
|
|
16437
|
+
type: string
|
|
16438
|
+
required:
|
|
16439
|
+
- id
|
|
16440
|
+
- label
|
|
16441
|
+
additionalProperties: false
|
|
16442
|
+
freeTextPlaceholder:
|
|
16443
|
+
type: string
|
|
16444
|
+
required:
|
|
16445
|
+
- id
|
|
16446
|
+
- question
|
|
16447
|
+
- options
|
|
16448
|
+
additionalProperties: false
|
|
16449
|
+
required:
|
|
16450
|
+
- requestId
|
|
16451
|
+
- entries
|
|
16452
|
+
additionalProperties: false
|
|
16411
16453
|
required:
|
|
16412
16454
|
- name
|
|
16413
16455
|
- input
|
|
@@ -16796,6 +16838,48 @@ paths:
|
|
|
16796
16838
|
required:
|
|
16797
16839
|
- requestId
|
|
16798
16840
|
additionalProperties: false
|
|
16841
|
+
pendingQuestion:
|
|
16842
|
+
type: object
|
|
16843
|
+
properties:
|
|
16844
|
+
requestId:
|
|
16845
|
+
type: string
|
|
16846
|
+
entries:
|
|
16847
|
+
type: array
|
|
16848
|
+
items:
|
|
16849
|
+
type: object
|
|
16850
|
+
properties:
|
|
16851
|
+
id:
|
|
16852
|
+
type: string
|
|
16853
|
+
question:
|
|
16854
|
+
type: string
|
|
16855
|
+
description:
|
|
16856
|
+
type: string
|
|
16857
|
+
options:
|
|
16858
|
+
type: array
|
|
16859
|
+
items:
|
|
16860
|
+
type: object
|
|
16861
|
+
properties:
|
|
16862
|
+
id:
|
|
16863
|
+
type: string
|
|
16864
|
+
label:
|
|
16865
|
+
type: string
|
|
16866
|
+
description:
|
|
16867
|
+
type: string
|
|
16868
|
+
required:
|
|
16869
|
+
- id
|
|
16870
|
+
- label
|
|
16871
|
+
additionalProperties: false
|
|
16872
|
+
freeTextPlaceholder:
|
|
16873
|
+
type: string
|
|
16874
|
+
required:
|
|
16875
|
+
- id
|
|
16876
|
+
- question
|
|
16877
|
+
- options
|
|
16878
|
+
additionalProperties: false
|
|
16879
|
+
required:
|
|
16880
|
+
- requestId
|
|
16881
|
+
- entries
|
|
16882
|
+
additionalProperties: false
|
|
16799
16883
|
required:
|
|
16800
16884
|
- name
|
|
16801
16885
|
- input
|
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({
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
DirectoryScopeOptionSchema,
|
|
31
31
|
ScopeOptionSchema,
|
|
32
32
|
} from "../events/confirmation-request.js";
|
|
33
|
+
import { QuestionEntrySchema } from "../events/question-request.js";
|
|
33
34
|
import { ToolActivityMetadataSchema } from "../events/tool-result.js";
|
|
34
35
|
|
|
35
36
|
// ---------------------------------------------------------------------------
|
|
@@ -104,6 +105,25 @@ export type PendingToolConfirmation = z.infer<
|
|
|
104
105
|
typeof PendingToolConfirmationSchema
|
|
105
106
|
>;
|
|
106
107
|
|
|
108
|
+
/**
|
|
109
|
+
* In-flight `ask_question` prompt awaiting a user answer, mirrored onto the
|
|
110
|
+
* history tool call that raised it so a cold reconnect (or a conversation
|
|
111
|
+
* reopened after the event-buffer window has elapsed) can restore the inline
|
|
112
|
+
* question card without replaying the live `question_request` SSE event.
|
|
113
|
+
*
|
|
114
|
+
* Stamped at render time from the in-memory `pending-interactions` registry
|
|
115
|
+
* (the authoritative store of unresolved prompts) — not persisted to the
|
|
116
|
+
* database, so it appears only while the prompt is genuinely outstanding and
|
|
117
|
+
* disappears once the interaction resolves. `entries` mirrors the
|
|
118
|
+
* `question_request` event's `questions[]`, so both paths hydrate the same
|
|
119
|
+
* client state.
|
|
120
|
+
*/
|
|
121
|
+
export const PendingToolQuestionSchema = z.object({
|
|
122
|
+
requestId: z.string(),
|
|
123
|
+
entries: z.array(QuestionEntrySchema),
|
|
124
|
+
});
|
|
125
|
+
export type PendingToolQuestion = z.infer<typeof PendingToolQuestionSchema>;
|
|
126
|
+
|
|
107
127
|
/**
|
|
108
128
|
* Closed set of confirmation outcomes recorded for a tool call. The daemon
|
|
109
129
|
* only ever persists one of these three values (the outcome map is gated to
|
|
@@ -190,6 +210,12 @@ export const ConversationMessageToolCallSchema = z.object({
|
|
|
190
210
|
* Guaranteed present for outstanding prompts as of daemon v0.8.8.
|
|
191
211
|
*/
|
|
192
212
|
pendingConfirmation: PendingToolConfirmationSchema.optional(),
|
|
213
|
+
/**
|
|
214
|
+
* In-flight `ask_question` prompt, present only while the tool call is
|
|
215
|
+
* awaiting a user answer (read from the `pending-interactions` registry at
|
|
216
|
+
* render time). Lets a cold reconnect restore the inline question card.
|
|
217
|
+
*/
|
|
218
|
+
pendingQuestion: PendingToolQuestionSchema.optional(),
|
|
193
219
|
});
|
|
194
220
|
export type ConversationMessageToolCall = z.infer<
|
|
195
221
|
typeof ConversationMessageToolCallSchema
|
|
@@ -28,6 +28,7 @@ import { Database } from "bun:sqlite";
|
|
|
28
28
|
|
|
29
29
|
import type { Command } from "commander";
|
|
30
30
|
|
|
31
|
+
import { getLogsDbPath } from "../../../util/logs-db-path.js";
|
|
31
32
|
import { getDbPath } from "../../../util/platform.js";
|
|
32
33
|
import { red } from "../../lib/cli-colors.js";
|
|
33
34
|
import { shouldOutputJson, writeOutput } from "../../output.js";
|
|
@@ -74,6 +75,14 @@ interface DbFacts {
|
|
|
74
75
|
interface StatusReport {
|
|
75
76
|
file: FileFacts;
|
|
76
77
|
db: DbFacts | null;
|
|
78
|
+
/**
|
|
79
|
+
* The secondary append-only database (`assistant-logs.db`). Omitted from the
|
|
80
|
+
* report when the file does not exist yet — it is created the first time the
|
|
81
|
+
* daemon opens (and ATTACHes) the DB, so a fresh install that has never run
|
|
82
|
+
* the daemon won't have one.
|
|
83
|
+
*/
|
|
84
|
+
logsFile?: FileFacts;
|
|
85
|
+
logsDb?: DbFacts | null;
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
// ---------------------------------------------------------------------------
|
|
@@ -242,8 +251,7 @@ function row(label: string, value: string): string {
|
|
|
242
251
|
return `${label.padEnd(LABEL_WIDTH)}${value}\n`;
|
|
243
252
|
}
|
|
244
253
|
|
|
245
|
-
function
|
|
246
|
-
const { file, db } = report;
|
|
254
|
+
function renderDbBlock(file: FileFacts, db: DbFacts | null): string {
|
|
247
255
|
let out = "";
|
|
248
256
|
|
|
249
257
|
out += row("Path", file.path);
|
|
@@ -302,6 +310,19 @@ function renderHuman(report: StatusReport): string {
|
|
|
302
310
|
return out;
|
|
303
311
|
}
|
|
304
312
|
|
|
313
|
+
function renderHuman(report: StatusReport): string {
|
|
314
|
+
let out = renderDbBlock(report.file, report.db);
|
|
315
|
+
|
|
316
|
+
// The secondary append-only file is only reported once it exists on disk.
|
|
317
|
+
if (report.logsFile?.exists) {
|
|
318
|
+
out += "\n";
|
|
319
|
+
out += "Logs database (append-only tables)\n";
|
|
320
|
+
out += renderDbBlock(report.logsFile, report.logsDb ?? null);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return out;
|
|
324
|
+
}
|
|
325
|
+
|
|
305
326
|
function renderMissing(path: string): string {
|
|
306
327
|
return (
|
|
307
328
|
`${red("ERROR")} Database not found at ${path}\n\n` +
|
|
@@ -356,7 +377,20 @@ export function registerDbStatus(parent: Command): void {
|
|
|
356
377
|
process.exit(1);
|
|
357
378
|
}
|
|
358
379
|
|
|
359
|
-
|
|
380
|
+
// Best-effort probe of the secondary append-only DB. It may not exist
|
|
381
|
+
// yet (fresh install that has never started the daemon), and a probe
|
|
382
|
+
// failure must never mask the main-DB report.
|
|
383
|
+
const logsFile = readFileFacts(getLogsDbPath());
|
|
384
|
+
let logsDb: DbFacts | null = null;
|
|
385
|
+
if (logsFile.exists) {
|
|
386
|
+
try {
|
|
387
|
+
logsDb = readDbFacts(logsFile.path);
|
|
388
|
+
} catch {
|
|
389
|
+
logsDb = null;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const report: StatusReport = { file, db, logsFile, logsDb };
|
|
360
394
|
if (shouldOutputJson(this)) {
|
|
361
395
|
writeOutput(this, report);
|
|
362
396
|
} else {
|