@vellumai/assistant 0.10.7-dev.202607100313.fffdfea → 0.10.7-dev.202607100720.fba456e
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 +846 -27
- package/package.json +1 -1
- package/src/__tests__/config-watcher-skill-reseed.test.ts +1 -0
- package/src/__tests__/config-watcher.test.ts +22 -4
- package/src/__tests__/credential-security-invariants.test.ts +1 -1
- package/src/__tests__/plugin-import-boundary-guard.test.ts +6 -9
- package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +0 -2
- package/src/cli/commands/__tests__/inference-models.test.ts +86 -0
- package/src/cli/commands/__tests__/inference-profiles.test.ts +254 -0
- package/src/cli/commands/__tests__/inference-providers.test.ts +171 -0
- package/src/cli/commands/__tests__/schedules.test.ts +133 -1
- package/src/cli/commands/__tests__/usage.test.ts +131 -0
- package/src/cli/commands/inference-callsites.ts +158 -0
- package/src/cli/commands/inference-models.ts +84 -0
- package/src/cli/commands/inference-profiles.ts +371 -0
- package/src/cli/commands/inference-providers-default.ts +89 -0
- package/src/cli/commands/inference-providers.ts +87 -16
- package/src/cli/commands/inference.ts +6 -0
- package/src/cli/commands/memory/nodes.ts +90 -50
- package/src/cli/commands/schedules.ts +17 -2
- package/src/cli/commands/usage.ts +59 -21
- package/src/cli/lib/__tests__/cli-output.test.ts +20 -0
- package/src/cli/lib/cli-output.ts +55 -0
- package/src/config/__tests__/loader-last-known-good.test.ts +229 -0
- package/src/config/__tests__/loader-sparse-array-cleanup.test.ts +166 -0
- package/src/config/default-profile-catalog.ts +28 -0
- package/src/config/loader.ts +276 -46
- package/src/daemon/config-watcher.ts +65 -20
- package/src/daemon/message-types/sync.ts +1 -0
- package/src/oauth/byo-connection.test.ts +1 -1
- package/src/oauth/connection-resolver.test.ts +140 -0
- package/src/oauth/connection-resolver.ts +48 -12
- package/src/plugins/defaults/memory/anisotropy.ts +1 -1
- package/src/plugins/defaults/memory/config.ts +1 -1
- package/src/plugins/defaults/memory/context-search/agent-protocol.ts +1 -1
- package/src/plugins/defaults/memory/context-search/search.ts +1 -1
- package/src/plugins/defaults/memory/graph/bootstrap.ts +1 -1
- package/src/plugins/defaults/memory/graph/consolidation.ts +1 -1
- package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +11 -1
- package/src/plugins/defaults/memory/graph/extraction.ts +1 -1
- package/src/plugins/defaults/memory/graph/narrative.ts +1 -1
- package/src/plugins/defaults/memory/graph/pattern-scan.ts +1 -1
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +1 -1
- package/src/plugins/defaults/memory/graph/tools.ts +1 -1
- package/src/plugins/defaults/memory/graph-topology/build-memory-graph.ts +43 -16
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +1 -1
- package/src/plugins/defaults/memory/host-utils.ts +80 -0
- package/src/plugins/defaults/memory/identity-context.ts +1 -1
- package/src/plugins/defaults/memory/injectors.ts +1 -1
- package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +2 -2
- package/src/plugins/defaults/memory/jobs-worker.ts +2 -9
- package/src/plugins/defaults/memory/memory-retrospective-state.ts +1 -1
- package/src/plugins/defaults/memory/paths.ts +48 -0
- package/src/plugins/defaults/memory/pkb/autoinject.ts +1 -1
- package/src/plugins/defaults/memory/pkb/context.ts +2 -2
- package/src/plugins/defaults/memory/pkb/types.ts +1 -1
- package/src/plugins/defaults/memory/pkb-schedule.ts +2 -2
- package/src/plugins/defaults/memory/rerank-local.ts +2 -3
- package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +149 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.ts +144 -1
- package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +1 -1
- package/src/plugins/defaults/memory/startup.ts +1 -1
- package/src/plugins/defaults/memory/v2/backfill-jobs.ts +1 -1
- package/src/plugins/defaults/memory/v2/consolidation-job.ts +2 -2
- package/src/plugins/defaults/memory/v2/injection.ts +1 -1
- package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +1 -1
- package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +1 -1
- package/src/plugins/defaults/memory/v2/qdrant.ts +1 -1
- package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
- package/src/plugins/defaults/memory/v2/static-context.ts +1 -1
- package/src/plugins/defaults/memory/v2/sweep-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
- package/src/plugins/defaults/memory/v3/maintain-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/page-content.ts +1 -1
- package/src/plugins/defaults/memory/v3/pool-select.ts +1 -2
- package/src/plugins/defaults/memory/v3/selection-log-store.ts +1 -1
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +2 -5
- package/src/plugins/defaults/memory/worker.ts +1 -1
- package/src/plugins/defaults/workspace/injectors.ts +17 -15
- package/src/plugins/types.ts +9 -14
- package/src/providers/inference/connection-availability.ts +193 -0
- package/src/runtime/routes/__tests__/inference-callsites-routes.test.ts +54 -0
- package/src/runtime/routes/__tests__/inference-models-routes.test.ts +54 -0
- package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +405 -0
- package/src/runtime/routes/__tests__/inference-routes-registration.test.ts +42 -0
- package/src/runtime/routes/__tests__/theme-routes.test.ts +66 -0
- package/src/runtime/routes/conversation-query-routes.ts +5 -3
- package/src/runtime/routes/default-provider-routes.ts +5 -152
- package/src/runtime/routes/index.ts +8 -0
- package/src/runtime/routes/inference-callsites-routes.ts +211 -0
- package/src/runtime/routes/inference-models-routes.ts +104 -0
- package/src/runtime/routes/inference-profiles-routes.ts +717 -0
- package/src/runtime/routes/theme-routes.ts +36 -0
- package/src/runtime/sync/resource-sync-events.ts +4 -0
- package/src/theme/workspace-theme.test.ts +269 -0
- package/src/theme/workspace-theme.ts +304 -0
- package/src/watcher/__tests__/engine-auth-notify.test.ts +316 -0
- package/src/watcher/engine.ts +87 -2
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the inference-profile route handlers' write-time validation.
|
|
3
|
+
*
|
|
4
|
+
* Covers the guardrails that distinguish these routes from the generic
|
|
5
|
+
* `config set llm.profiles.*` path:
|
|
6
|
+
* - bad provider (not in the LLMProvider enum)
|
|
7
|
+
* - uncataloged model without --allow-unlisted
|
|
8
|
+
* - missing provider connection
|
|
9
|
+
* - managed-profile create / update / delete rejection
|
|
10
|
+
*
|
|
11
|
+
* The happy-path write is intentionally not exercised here — it flows through
|
|
12
|
+
* `commitConfigWrite` (disk write + provider reinit), which is covered by the
|
|
13
|
+
* config-write tests.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
17
|
+
|
|
18
|
+
// ── Module mocks (must come before imports) ──────────────────────────────────
|
|
19
|
+
|
|
20
|
+
let fakeConfig: Record<string, unknown> = { llm: {} };
|
|
21
|
+
let savedRawConfig: Record<string, unknown> | null = null;
|
|
22
|
+
let initializeProvidersCalls = 0;
|
|
23
|
+
mock.module("../../../config/loader.js", () => ({
|
|
24
|
+
getConfig: () => structuredClone(savedRawConfig ?? fakeConfig),
|
|
25
|
+
getConfigReadOnly: () => structuredClone(fakeConfig),
|
|
26
|
+
loadRawConfig: () => structuredClone(fakeConfig),
|
|
27
|
+
saveRawConfig: (raw: Record<string, unknown>) => {
|
|
28
|
+
savedRawConfig = raw;
|
|
29
|
+
},
|
|
30
|
+
invalidateConfigCache: () => {},
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
// commitConfigWrite (reached by the happy-path delete/active-set) reinitializes
|
|
34
|
+
// the provider registry and clears the embedding backend cache; stub both.
|
|
35
|
+
mock.module("../../../providers/registry.js", () => ({
|
|
36
|
+
initializeProviders: async () => {
|
|
37
|
+
initializeProvidersCalls += 1;
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
mock.module("../../../persistence/embeddings/embedding-backend.js", () => ({
|
|
42
|
+
clearEmbeddingBackendCache: () => {},
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
mock.module("../../../util/logger.js", () => ({
|
|
46
|
+
getLogger: () =>
|
|
47
|
+
new Proxy({} as Record<string, unknown>, { get: () => () => {} }),
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
// ── Real imports (after mocks) ────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
import { getDb } from "../../../persistence/db-connection.js";
|
|
53
|
+
import { initializeDb } from "../../../persistence/db-init.js";
|
|
54
|
+
import { providerConnections } from "../../../persistence/schema/inference.js";
|
|
55
|
+
import { BadRequestError, ConflictError, NotFoundError } from "../errors.js";
|
|
56
|
+
import {
|
|
57
|
+
collectProfileReferences,
|
|
58
|
+
ROUTES,
|
|
59
|
+
} from "../inference-profiles-routes.js";
|
|
60
|
+
import type { RouteDefinition, RouteHandlerArgs } from "../types.js";
|
|
61
|
+
|
|
62
|
+
await initializeDb();
|
|
63
|
+
|
|
64
|
+
function handler(operationId: string): RouteDefinition["handler"] {
|
|
65
|
+
const route = ROUTES.find((r) => r.operationId === operationId);
|
|
66
|
+
if (!route) {
|
|
67
|
+
throw new Error(`Route ${operationId} not found`);
|
|
68
|
+
}
|
|
69
|
+
return route.handler;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function call(operationId: string, args: RouteHandlerArgs): Promise<unknown> {
|
|
73
|
+
return Promise.resolve(handler(operationId)(args));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function seedConnection(name: string, provider: string): void {
|
|
77
|
+
const now = Date.now();
|
|
78
|
+
getDb()
|
|
79
|
+
.insert(providerConnections)
|
|
80
|
+
.values({
|
|
81
|
+
name,
|
|
82
|
+
provider,
|
|
83
|
+
auth: JSON.stringify({ type: "none" }),
|
|
84
|
+
createdAt: now,
|
|
85
|
+
updatedAt: now,
|
|
86
|
+
})
|
|
87
|
+
.run();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
beforeEach(() => {
|
|
91
|
+
getDb().delete(providerConnections).run();
|
|
92
|
+
fakeConfig = { llm: {} };
|
|
93
|
+
savedRawConfig = null;
|
|
94
|
+
initializeProvidersCalls = 0;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// ── create validation ─────────────────────────────────────────────────────────
|
|
98
|
+
|
|
99
|
+
describe("POST inference/profiles (create) validation", () => {
|
|
100
|
+
test("rejects an unknown provider", async () => {
|
|
101
|
+
await expect(
|
|
102
|
+
call("inference_profiles_create", {
|
|
103
|
+
body: {
|
|
104
|
+
name: "my-profile",
|
|
105
|
+
provider: "bogus",
|
|
106
|
+
model: "claude-opus-4-8",
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
).rejects.toBeInstanceOf(BadRequestError);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("rejects an uncataloged model without allowUnlisted", async () => {
|
|
113
|
+
await expect(
|
|
114
|
+
call("inference_profiles_create", {
|
|
115
|
+
body: {
|
|
116
|
+
name: "my-profile",
|
|
117
|
+
provider: "anthropic",
|
|
118
|
+
model: "totally-made-up-model",
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
).rejects.toThrow(/not in the catalog/);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("rejects a missing provider connection", async () => {
|
|
125
|
+
await expect(
|
|
126
|
+
call("inference_profiles_create", {
|
|
127
|
+
body: {
|
|
128
|
+
name: "my-profile",
|
|
129
|
+
provider: "anthropic",
|
|
130
|
+
model: "claude-opus-4-8",
|
|
131
|
+
connection: "does-not-exist",
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
).rejects.toThrow(/does not exist/);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("rejects creating a managed default name", async () => {
|
|
138
|
+
await expect(
|
|
139
|
+
call("inference_profiles_create", {
|
|
140
|
+
body: {
|
|
141
|
+
name: "balanced",
|
|
142
|
+
provider: "anthropic",
|
|
143
|
+
model: "claude-opus-4-8",
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
).rejects.toThrow(/reserved for a code-defined default/);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// ── update validation ─────────────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
describe("PATCH inference/profiles/:name (update) validation", () => {
|
|
153
|
+
test("rejects editing a managed default profile", async () => {
|
|
154
|
+
fakeConfig = {
|
|
155
|
+
llm: {
|
|
156
|
+
profiles: {
|
|
157
|
+
balanced: {
|
|
158
|
+
source: "managed",
|
|
159
|
+
provider: "fireworks",
|
|
160
|
+
model: "accounts/fireworks/models/glm-5p2",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
await expect(
|
|
166
|
+
call("inference_profiles_update", {
|
|
167
|
+
pathParams: { name: "balanced" },
|
|
168
|
+
body: { effort: "low" },
|
|
169
|
+
}),
|
|
170
|
+
).rejects.toThrow(/managed profile/);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("404s an unknown profile", async () => {
|
|
174
|
+
await expect(
|
|
175
|
+
call("inference_profiles_update", {
|
|
176
|
+
pathParams: { name: "ghost" },
|
|
177
|
+
body: { effort: "low" },
|
|
178
|
+
}),
|
|
179
|
+
).rejects.toBeInstanceOf(NotFoundError);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// ── delete protection ───────────────────────────────────────────────────────
|
|
184
|
+
|
|
185
|
+
describe("DELETE inference/profiles/:name protection", () => {
|
|
186
|
+
test("rejects deleting a managed default profile", async () => {
|
|
187
|
+
fakeConfig = {
|
|
188
|
+
llm: { profiles: { balanced: { source: "managed" } } },
|
|
189
|
+
};
|
|
190
|
+
await expect(
|
|
191
|
+
call("inference_profiles_delete", { pathParams: { name: "balanced" } }),
|
|
192
|
+
).rejects.toThrow(/managed profile/);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("404s an unknown profile", async () => {
|
|
196
|
+
fakeConfig = { llm: { profiles: {} } };
|
|
197
|
+
await expect(
|
|
198
|
+
call("inference_profiles_delete", { pathParams: { name: "ghost" } }),
|
|
199
|
+
).rejects.toBeInstanceOf(NotFoundError);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// ── duplicate create ──────────────────────────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
describe("POST inference/profiles create conflict", () => {
|
|
206
|
+
test("409s when a profile with the name already exists", async () => {
|
|
207
|
+
seedConnection("anthropic-personal", "anthropic");
|
|
208
|
+
fakeConfig = {
|
|
209
|
+
llm: {
|
|
210
|
+
profiles: { existing: { source: "user", provider: "anthropic" } },
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
await expect(
|
|
214
|
+
call("inference_profiles_create", {
|
|
215
|
+
body: {
|
|
216
|
+
name: "existing",
|
|
217
|
+
provider: "anthropic",
|
|
218
|
+
model: "claude-opus-4-8",
|
|
219
|
+
connection: "anthropic-personal",
|
|
220
|
+
},
|
|
221
|
+
}),
|
|
222
|
+
).rejects.toBeInstanceOf(ConflictError);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// ── delete reference guard (Finding 1) ────────────────────────────────────────
|
|
227
|
+
|
|
228
|
+
describe("collectProfileReferences", () => {
|
|
229
|
+
test("detects each reference kind", () => {
|
|
230
|
+
const llm = {
|
|
231
|
+
activeProfile: "my-fast",
|
|
232
|
+
advisorProfile: "my-fast",
|
|
233
|
+
callSites: {
|
|
234
|
+
memoryExtraction: { profile: "my-fast" },
|
|
235
|
+
recall: { profile: "other" },
|
|
236
|
+
},
|
|
237
|
+
profiles: {
|
|
238
|
+
"my-fast": { source: "user", provider: "anthropic" },
|
|
239
|
+
"my-mix": {
|
|
240
|
+
source: "user",
|
|
241
|
+
mix: [{ profile: "my-fast", weight: 1 }],
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
expect(collectProfileReferences(llm, "my-fast").sort()).toEqual(
|
|
246
|
+
[
|
|
247
|
+
"llm.activeProfile",
|
|
248
|
+
"llm.advisorProfile",
|
|
249
|
+
"llm.callSites.memoryExtraction",
|
|
250
|
+
"llm.profiles.my-mix.mix",
|
|
251
|
+
].sort(),
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test("returns empty for an unreferenced profile", () => {
|
|
256
|
+
const llm = {
|
|
257
|
+
activeProfile: "balanced",
|
|
258
|
+
callSites: { recall: { profile: "balanced" } },
|
|
259
|
+
profiles: { "my-fast": { source: "user", provider: "anthropic" } },
|
|
260
|
+
};
|
|
261
|
+
expect(collectProfileReferences(llm, "my-fast")).toEqual([]);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe("DELETE inference/profiles/:name reference guard", () => {
|
|
266
|
+
test("rejects deletion referenced by activeProfile with the reference list", async () => {
|
|
267
|
+
fakeConfig = {
|
|
268
|
+
llm: {
|
|
269
|
+
activeProfile: "my-fast",
|
|
270
|
+
profiles: { "my-fast": { source: "user", provider: "anthropic" } },
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
const promise = call("inference_profiles_delete", {
|
|
274
|
+
pathParams: { name: "my-fast" },
|
|
275
|
+
});
|
|
276
|
+
await expect(promise).rejects.toBeInstanceOf(ConflictError);
|
|
277
|
+
await expect(promise).rejects.toThrow(/llm\.activeProfile/);
|
|
278
|
+
expect(initializeProvidersCalls).toBe(0);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("rejects deletion referenced by a mix arm", async () => {
|
|
282
|
+
fakeConfig = {
|
|
283
|
+
llm: {
|
|
284
|
+
profiles: {
|
|
285
|
+
"my-fast": { source: "user", provider: "anthropic" },
|
|
286
|
+
"my-mix": { source: "user", mix: [{ profile: "my-fast", weight: 1 }] },
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
await expect(
|
|
291
|
+
call("inference_profiles_delete", { pathParams: { name: "my-fast" } }),
|
|
292
|
+
).rejects.toThrow(/llm\.profiles\.my-mix\.mix/);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test("rejects deletion referenced by a call site", async () => {
|
|
296
|
+
fakeConfig = {
|
|
297
|
+
llm: {
|
|
298
|
+
callSites: { memoryExtraction: { profile: "my-fast" } },
|
|
299
|
+
profiles: { "my-fast": { source: "user", provider: "anthropic" } },
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
await expect(
|
|
303
|
+
call("inference_profiles_delete", { pathParams: { name: "my-fast" } }),
|
|
304
|
+
).rejects.toThrow(/llm\.callSites\.memoryExtraction/);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test("deletes an unreferenced custom profile", async () => {
|
|
308
|
+
fakeConfig = {
|
|
309
|
+
llm: {
|
|
310
|
+
activeProfile: "balanced",
|
|
311
|
+
profiles: { "my-fast": { source: "user", provider: "anthropic" } },
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
const result = (await call("inference_profiles_delete", {
|
|
315
|
+
pathParams: { name: "my-fast" },
|
|
316
|
+
})) as { ok: true; name: string };
|
|
317
|
+
expect(result).toEqual({ ok: true, name: "my-fast" });
|
|
318
|
+
expect(savedRawConfig?.llm).toBeDefined();
|
|
319
|
+
expect(
|
|
320
|
+
(savedRawConfig?.llm as { profiles?: Record<string, unknown> }).profiles,
|
|
321
|
+
).toEqual({});
|
|
322
|
+
expect(initializeProvidersCalls).toBe(1);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// ── provider-aware list/get (Finding 2) ───────────────────────────────────────
|
|
327
|
+
|
|
328
|
+
describe("GET inference/profiles honors llm.defaultProvider", () => {
|
|
329
|
+
test("expands balanced through a BYOK default provider, not the vellum column", async () => {
|
|
330
|
+
fakeConfig = {
|
|
331
|
+
llm: {
|
|
332
|
+
defaultProvider: { provider: "anthropic" },
|
|
333
|
+
profiles: {},
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
const listed = (await call("inference_profiles_list", {})) as {
|
|
337
|
+
profiles: Array<{ name: string; provider: string | null }>;
|
|
338
|
+
};
|
|
339
|
+
const balanced = listed.profiles.find((p) => p.name === "balanced");
|
|
340
|
+
expect(balanced).toBeDefined();
|
|
341
|
+
// The vellum column implements `balanced` on fireworks; with a BYOK
|
|
342
|
+
// anthropic default provider the CLI must report anthropic instead.
|
|
343
|
+
expect(balanced!.provider).toBe("anthropic");
|
|
344
|
+
|
|
345
|
+
const got = (await call("inference_profiles_get", {
|
|
346
|
+
pathParams: { name: "balanced" },
|
|
347
|
+
})) as { entry: { provider?: string } };
|
|
348
|
+
expect(got.entry.provider).toBe("anthropic");
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// ── active-profile setter validation (Finding 3) ──────────────────────────────
|
|
353
|
+
|
|
354
|
+
describe("PUT inference/active-profile validation", () => {
|
|
355
|
+
test("sets a valid profile", async () => {
|
|
356
|
+
fakeConfig = {
|
|
357
|
+
llm: {
|
|
358
|
+
profiles: {
|
|
359
|
+
"my-fast": {
|
|
360
|
+
source: "user",
|
|
361
|
+
provider: "anthropic",
|
|
362
|
+
model: "claude-opus-4-8",
|
|
363
|
+
status: "active",
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
const result = (await call("inference_profiles_set_active", {
|
|
369
|
+
body: { name: "my-fast" },
|
|
370
|
+
})) as { ok: true; activeProfile: string };
|
|
371
|
+
expect(result).toEqual({ ok: true, activeProfile: "my-fast" });
|
|
372
|
+
expect(
|
|
373
|
+
(savedRawConfig?.llm as { activeProfile?: string }).activeProfile,
|
|
374
|
+
).toBe("my-fast");
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
test("rejects a typo'd name with the valid-name list", async () => {
|
|
378
|
+
fakeConfig = { llm: { profiles: {} } };
|
|
379
|
+
const promise = call("inference_profiles_set_active", {
|
|
380
|
+
body: { name: "balancd" },
|
|
381
|
+
});
|
|
382
|
+
await expect(promise).rejects.toBeInstanceOf(BadRequestError);
|
|
383
|
+
// The error names the real defaults so the user can correct the typo.
|
|
384
|
+
await expect(promise).rejects.toThrow(/balanced/);
|
|
385
|
+
expect(initializeProvidersCalls).toBe(0);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
test("rejects a disabled profile", async () => {
|
|
389
|
+
fakeConfig = {
|
|
390
|
+
llm: {
|
|
391
|
+
profiles: {
|
|
392
|
+
"my-fast": {
|
|
393
|
+
source: "user",
|
|
394
|
+
provider: "anthropic",
|
|
395
|
+
model: "claude-opus-4-8",
|
|
396
|
+
status: "disabled",
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
await expect(
|
|
402
|
+
call("inference_profiles_set_active", { body: { name: "my-fast" } }),
|
|
403
|
+
).rejects.toThrow(/disabled/);
|
|
404
|
+
});
|
|
405
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registration guard for the inference model/profile/call-site routes.
|
|
3
|
+
*
|
|
4
|
+
* A route module that exports ROUTES but is never spread into the aggregator
|
|
5
|
+
* (`routes/index.ts`) compiles, unit-tests green, and is silently unreachable
|
|
6
|
+
* over both HTTP and IPC. This test pins every inference operationId to the
|
|
7
|
+
* aggregated array and to the IPC method mapping the CLI depends on.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, expect, test } from "bun:test";
|
|
11
|
+
|
|
12
|
+
import { routeDefinitionsToIpcMethods } from "../../../ipc/routes/route-adapter.js";
|
|
13
|
+
import { ROUTES } from "../index.js";
|
|
14
|
+
|
|
15
|
+
const EXPECTED_OPERATION_IDS = [
|
|
16
|
+
"inference_models_list",
|
|
17
|
+
"inference_profiles_list",
|
|
18
|
+
"inference_profiles_get",
|
|
19
|
+
"inference_profiles_create",
|
|
20
|
+
"inference_profiles_update",
|
|
21
|
+
"inference_profiles_delete",
|
|
22
|
+
"inference_callsites_list",
|
|
23
|
+
"inference_callsites_get",
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
describe("inference route registration", () => {
|
|
27
|
+
test("every inference operationId is registered in the aggregated ROUTES array", () => {
|
|
28
|
+
const registered = new Set(ROUTES.map((r) => r.operationId));
|
|
29
|
+
for (const operationId of EXPECTED_OPERATION_IDS) {
|
|
30
|
+
expect(registered.has(operationId)).toBe(true);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("every inference operationId is exposed as an IPC method (CLI transport)", () => {
|
|
35
|
+
const ipcMethods = new Set(
|
|
36
|
+
routeDefinitionsToIpcMethods(ROUTES).map((r) => r.operationId),
|
|
37
|
+
);
|
|
38
|
+
for (const operationId of EXPECTED_OPERATION_IDS) {
|
|
39
|
+
expect(ipcMethods.has(operationId)).toBe(true);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
5
|
+
|
|
6
|
+
import type { WorkspaceThemeReadResult } from "../../../theme/workspace-theme.js";
|
|
7
|
+
import { ROUTES } from "../theme-routes.js";
|
|
8
|
+
|
|
9
|
+
function getThemeHandler() {
|
|
10
|
+
const route = ROUTES.find((r) => r.operationId === "workspace_theme_get");
|
|
11
|
+
if (!route) {
|
|
12
|
+
throw new Error("workspace_theme_get route not registered");
|
|
13
|
+
}
|
|
14
|
+
expect(route.endpoint).toBe("workspace/theme");
|
|
15
|
+
expect(route.method).toBe("GET");
|
|
16
|
+
return route.handler as () => WorkspaceThemeReadResult;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe("GET /workspace/theme", () => {
|
|
20
|
+
let workspaceDir: string;
|
|
21
|
+
let prevWorkspaceDir: string | undefined;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
workspaceDir = mkdtempSync(join(tmpdir(), "theme-route-test-"));
|
|
25
|
+
prevWorkspaceDir = process.env.VELLUM_WORKSPACE_DIR;
|
|
26
|
+
process.env.VELLUM_WORKSPACE_DIR = workspaceDir;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
if (prevWorkspaceDir === undefined) {
|
|
31
|
+
delete process.env.VELLUM_WORKSPACE_DIR;
|
|
32
|
+
} else {
|
|
33
|
+
process.env.VELLUM_WORKSPACE_DIR = prevWorkspaceDir;
|
|
34
|
+
}
|
|
35
|
+
rmSync(workspaceDir, { recursive: true, force: true });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("returns source none when no theme file exists", () => {
|
|
39
|
+
const result = getThemeHandler()();
|
|
40
|
+
expect(result).toEqual({ theme: null, source: "none", issues: [] });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("returns the validated theme when the file is valid", () => {
|
|
44
|
+
mkdirSync(join(workspaceDir, "ui"), { recursive: true });
|
|
45
|
+
writeFileSync(
|
|
46
|
+
join(workspaceDir, "ui", "theme.json"),
|
|
47
|
+
JSON.stringify({ version: 1, base: "velvet" }),
|
|
48
|
+
);
|
|
49
|
+
const result = getThemeHandler()();
|
|
50
|
+
expect(result.source).toBe("workspace");
|
|
51
|
+
expect(result.theme).toEqual({ version: 1, base: "velvet" });
|
|
52
|
+
expect(result.issues).toEqual([]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("returns null theme plus issues when the file is rejected", () => {
|
|
56
|
+
mkdirSync(join(workspaceDir, "ui"), { recursive: true });
|
|
57
|
+
writeFileSync(
|
|
58
|
+
join(workspaceDir, "ui", "theme.json"),
|
|
59
|
+
JSON.stringify({ version: 1, tokens: { accent: "not-a-color" } }),
|
|
60
|
+
);
|
|
61
|
+
const result = getThemeHandler()();
|
|
62
|
+
expect(result.source).toBe("invalid");
|
|
63
|
+
expect(result.theme).toBeNull();
|
|
64
|
+
expect(result.issues.length).toBeGreaterThan(0);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -914,7 +914,7 @@ function stripWireOnlyProfileKeys(patch: unknown): void {
|
|
|
914
914
|
* `handleSetConfig`'s `raw` write, which shares object references with the
|
|
915
915
|
* inspected patch shape.
|
|
916
916
|
*/
|
|
917
|
-
function normalizeManagedProfileWrites(patch: unknown): void {
|
|
917
|
+
export function normalizeManagedProfileWrites(patch: unknown): void {
|
|
918
918
|
const root = readPlainObject(patch);
|
|
919
919
|
const llm = readPlainObject(root?.llm);
|
|
920
920
|
const profiles = readPlainObject(llm?.profiles);
|
|
@@ -1086,7 +1086,9 @@ function handleGetConfigSchema({ queryParams = {} }: RouteHandlerArgs) {
|
|
|
1086
1086
|
};
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
|
-
function rejectManagedProfileDeletion(
|
|
1089
|
+
export function rejectManagedProfileDeletion(
|
|
1090
|
+
body: Record<string, unknown>,
|
|
1091
|
+
): void {
|
|
1090
1092
|
const llm = asMutablePlainObject(body.llm);
|
|
1091
1093
|
if (!llm) {
|
|
1092
1094
|
return;
|
|
@@ -1296,7 +1298,7 @@ function completeChangedCustomProfiles(
|
|
|
1296
1298
|
* Shared by `handlePatchConfig` and `handleSetConfig` so both write paths get
|
|
1297
1299
|
* identical post-write side effects.
|
|
1298
1300
|
*/
|
|
1299
|
-
async function commitConfigWrite(
|
|
1301
|
+
export async function commitConfigWrite(
|
|
1300
1302
|
raw: Record<string, unknown>,
|
|
1301
1303
|
opLabel: string,
|
|
1302
1304
|
): Promise<void> {
|