@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,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery ladder for a config.json that fails schema validation even after
|
|
3
|
+
* per-key cleanup. Rather than discarding the user's entire configuration and
|
|
4
|
+
* loading schema defaults, the loader keeps the last-known-good config from
|
|
5
|
+
* this process, or (on first load) salvages the config section-by-section.
|
|
6
|
+
*
|
|
7
|
+
* The strip-and-reparse cleanup (including sparse-array compaction) repairs
|
|
8
|
+
* every known real-world config shape, so no config.json fixture reliably
|
|
9
|
+
* reaches the ladder through `loadConfig` — the ladder is defense-in-depth
|
|
10
|
+
* for schema shapes the cleanup does not anticipate. The ladder tests here
|
|
11
|
+
* therefore drive `_recoverFromInvalidConfigForTests` directly, while the
|
|
12
|
+
* file-based tests assert the cleanup's healing behavior end-to-end.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import {
|
|
18
|
+
afterAll,
|
|
19
|
+
afterEach,
|
|
20
|
+
beforeEach,
|
|
21
|
+
describe,
|
|
22
|
+
expect,
|
|
23
|
+
mock,
|
|
24
|
+
test,
|
|
25
|
+
} from "bun:test";
|
|
26
|
+
|
|
27
|
+
const WORKSPACE_DIR = process.env.VELLUM_WORKSPACE_DIR!;
|
|
28
|
+
const CONFIG_PATH = join(WORKSPACE_DIR, "config.json");
|
|
29
|
+
|
|
30
|
+
function ensureTestDir(): void {
|
|
31
|
+
const dirs = [
|
|
32
|
+
WORKSPACE_DIR,
|
|
33
|
+
join(WORKSPACE_DIR, "data"),
|
|
34
|
+
join(WORKSPACE_DIR, "data", "memory"),
|
|
35
|
+
join(WORKSPACE_DIR, "data", "logs"),
|
|
36
|
+
];
|
|
37
|
+
for (const dir of dirs) {
|
|
38
|
+
if (!existsSync(dir)) {
|
|
39
|
+
mkdirSync(dir, { recursive: true });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function makeLoggerStub(): Record<string, unknown> {
|
|
45
|
+
const stub: Record<string, unknown> = {};
|
|
46
|
+
for (const m of [
|
|
47
|
+
"info",
|
|
48
|
+
"warn",
|
|
49
|
+
"error",
|
|
50
|
+
"debug",
|
|
51
|
+
"trace",
|
|
52
|
+
"fatal",
|
|
53
|
+
"silent",
|
|
54
|
+
"child",
|
|
55
|
+
]) {
|
|
56
|
+
stub[m] = m === "child" ? () => makeLoggerStub() : () => {};
|
|
57
|
+
}
|
|
58
|
+
return stub;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
mock.module("../../util/logger.js", () => ({
|
|
62
|
+
getLogger: () => makeLoggerStub(),
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
afterAll(() => {
|
|
66
|
+
mock.restore();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
import {
|
|
70
|
+
_recoverFromInvalidConfigForTests,
|
|
71
|
+
_resetLastKnownGoodConfigForTests,
|
|
72
|
+
getConfigReadOnly,
|
|
73
|
+
invalidateConfigCache,
|
|
74
|
+
loadConfig,
|
|
75
|
+
} from "../loader.js";
|
|
76
|
+
|
|
77
|
+
function writeConfig(obj: unknown): void {
|
|
78
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(obj, null, 2) + "\n");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Write raw bytes to config.json without JSON-stringifying them. */
|
|
82
|
+
function writeRawConfig(contents: string): void {
|
|
83
|
+
writeFileSync(CONFIG_PATH, contents);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** A synthetic irreparable-issue set for driving the ladder directly. */
|
|
87
|
+
const IRREPARABLE_ISSUES = [
|
|
88
|
+
{ path: [] as PropertyKey[], message: "synthetic irreparable issue" },
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
describe("config recovery ladder for cleanup-resistant invalid config", () => {
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
ensureTestDir();
|
|
94
|
+
if (existsSync(CONFIG_PATH)) {
|
|
95
|
+
rmSync(CONFIG_PATH, { force: true });
|
|
96
|
+
}
|
|
97
|
+
delete process.env.IS_PLATFORM;
|
|
98
|
+
invalidateConfigCache();
|
|
99
|
+
_resetLastKnownGoodConfigForTests();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
afterEach(() => {
|
|
103
|
+
delete process.env.IS_PLATFORM;
|
|
104
|
+
if (existsSync(CONFIG_PATH)) {
|
|
105
|
+
rmSync(CONFIG_PATH, { force: true });
|
|
106
|
+
}
|
|
107
|
+
invalidateConfigCache();
|
|
108
|
+
_resetLastKnownGoodConfigForTests();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("keeps the last-known-good config when recovery runs after a good load", () => {
|
|
112
|
+
// A valid load captures the last-known-good snapshot for this process.
|
|
113
|
+
writeConfig({ maxStepsPerSession: 123 });
|
|
114
|
+
expect(loadConfig().maxStepsPerSession).toBe(123);
|
|
115
|
+
|
|
116
|
+
// Recovery for an irreparable config returns the snapshot — the whole
|
|
117
|
+
// config is NOT reset to schema defaults (which would be 50).
|
|
118
|
+
const recovered = _recoverFromInvalidConfigForTests(
|
|
119
|
+
{},
|
|
120
|
+
IRREPARABLE_ISSUES,
|
|
121
|
+
[""],
|
|
122
|
+
);
|
|
123
|
+
expect(recovered.maxStepsPerSession).toBe(123);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("salvages valid sections on first load and defaults only the invalid one", () => {
|
|
127
|
+
// No last-known-good config exists (fresh process). One section is valid
|
|
128
|
+
// and distinctive; another cannot validate on its own.
|
|
129
|
+
const recovered = _recoverFromInvalidConfigForTests(
|
|
130
|
+
{ maxStepsPerSession: 123, tools: "not-an-object" },
|
|
131
|
+
IRREPARABLE_ISSUES,
|
|
132
|
+
["tools"],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// The valid section survives untouched...
|
|
136
|
+
expect(recovered.maxStepsPerSession).toBe(123);
|
|
137
|
+
// ...while only the invalid section is reset to its schema default.
|
|
138
|
+
expect(recovered.tools.exclude).toEqual([]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("a single invalid leaf key falls back to default for that key only", () => {
|
|
142
|
+
// `maxStepsPerSession` is out of range (max 200) but `tools.exclude` is a
|
|
143
|
+
// valid distinctive value. Per-key cleanup strips only the invalid leaf, so
|
|
144
|
+
// the sibling value is preserved and the recovery ladder is never reached.
|
|
145
|
+
writeConfig({ maxStepsPerSession: 9999, tools: { exclude: ["keep-me"] } });
|
|
146
|
+
|
|
147
|
+
const config = loadConfig();
|
|
148
|
+
|
|
149
|
+
expect(config.maxStepsPerSession).toBe(50);
|
|
150
|
+
expect(config.tools.exclude).toEqual(["keep-me"]);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("an invalid array element heals in place across a reload — valid siblings and sections survive", () => {
|
|
154
|
+
// A non-string element inside `tools.exclude` is stripped and the array
|
|
155
|
+
// compacted, so the cleaned config re-parses successfully: no recovery
|
|
156
|
+
// rung runs, the valid element survives, and sibling sections keep their
|
|
157
|
+
// values from the file (not from the last-known-good snapshot).
|
|
158
|
+
writeConfig({ maxStepsPerSession: 42 });
|
|
159
|
+
expect(loadConfig().maxStepsPerSession).toBe(42);
|
|
160
|
+
|
|
161
|
+
writeConfig({
|
|
162
|
+
maxStepsPerSession: 123,
|
|
163
|
+
tools: { exclude: ["valid-tool", 456] },
|
|
164
|
+
});
|
|
165
|
+
invalidateConfigCache();
|
|
166
|
+
const healed = loadConfig();
|
|
167
|
+
|
|
168
|
+
expect(healed.maxStepsPerSession).toBe(123);
|
|
169
|
+
expect(healed.tools.exclude).toEqual(["valid-tool"]);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("invalidateConfigCache does not clear the last-known-good safety net", () => {
|
|
173
|
+
writeConfig({ maxStepsPerSession: 77 });
|
|
174
|
+
expect(loadConfig().maxStepsPerSession).toBe(77);
|
|
175
|
+
|
|
176
|
+
// A bare cache invalidation must not drop the safety net.
|
|
177
|
+
invalidateConfigCache();
|
|
178
|
+
|
|
179
|
+
const recovered = _recoverFromInvalidConfigForTests(
|
|
180
|
+
{},
|
|
181
|
+
IRREPARABLE_ISSUES,
|
|
182
|
+
[""],
|
|
183
|
+
);
|
|
184
|
+
expect(recovered.maxStepsPerSession).toBe(77);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("getConfigReadOnly returns schema defaults for a top-level `null` config without throwing", () => {
|
|
188
|
+
// `JSON.parse("null")` is valid JSON, so it reaches validateWithSchema as a
|
|
189
|
+
// non-object top-level value. `loadConfig` quarantines non-object files
|
|
190
|
+
// before validation, so `getConfigReadOnly` (which validates the parsed
|
|
191
|
+
// value directly) is the path that exercises the recovery ladder's
|
|
192
|
+
// non-object guard. It must degrade to schema defaults, not throw on
|
|
193
|
+
// `Object.entries(null)`.
|
|
194
|
+
writeRawConfig("null");
|
|
195
|
+
|
|
196
|
+
const config = getConfigReadOnly();
|
|
197
|
+
|
|
198
|
+
expect(config.maxStepsPerSession).toBe(50);
|
|
199
|
+
expect(config.tools.exclude).toEqual([]);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("getConfigReadOnly returns schema defaults for a top-level array config without throwing", () => {
|
|
203
|
+
writeRawConfig("[]");
|
|
204
|
+
|
|
205
|
+
const config = getConfigReadOnly();
|
|
206
|
+
|
|
207
|
+
expect(config.maxStepsPerSession).toBe(50);
|
|
208
|
+
expect(config.tools.exclude).toEqual([]);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test("recovery on a platform daemon returns the context-filled effective config", () => {
|
|
212
|
+
process.env.IS_PLATFORM = "true";
|
|
213
|
+
|
|
214
|
+
// First load with no config.json seeds the file and fills the
|
|
215
|
+
// deployment-context managed OAuth service modes in memory; the
|
|
216
|
+
// last-known-good snapshot is refreshed AFTER that fill.
|
|
217
|
+
const seeded = loadConfig();
|
|
218
|
+
expect(seeded.services["outlook-oauth"].mode).toBe("managed");
|
|
219
|
+
|
|
220
|
+
// Recovery keeps the last-known-good EFFECTIVE config, so the managed mode
|
|
221
|
+
// survives rather than reverting to the schema default ("your-own").
|
|
222
|
+
const recovered = _recoverFromInvalidConfigForTests(
|
|
223
|
+
{},
|
|
224
|
+
IRREPARABLE_ISSUES,
|
|
225
|
+
[""],
|
|
226
|
+
);
|
|
227
|
+
expect(recovered.services["outlook-oauth"].mode).toBe("managed");
|
|
228
|
+
});
|
|
229
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
afterAll,
|
|
5
|
+
afterEach,
|
|
6
|
+
beforeEach,
|
|
7
|
+
describe,
|
|
8
|
+
expect,
|
|
9
|
+
mock,
|
|
10
|
+
test,
|
|
11
|
+
} from "bun:test";
|
|
12
|
+
|
|
13
|
+
const WORKSPACE_DIR = process.env.VELLUM_WORKSPACE_DIR!;
|
|
14
|
+
const CONFIG_PATH = join(WORKSPACE_DIR, "config.json");
|
|
15
|
+
|
|
16
|
+
function ensureTestDir(): void {
|
|
17
|
+
const dirs = [
|
|
18
|
+
WORKSPACE_DIR,
|
|
19
|
+
join(WORKSPACE_DIR, "data"),
|
|
20
|
+
join(WORKSPACE_DIR, "data", "memory"),
|
|
21
|
+
join(WORKSPACE_DIR, "data", "logs"),
|
|
22
|
+
];
|
|
23
|
+
for (const dir of dirs) {
|
|
24
|
+
if (!existsSync(dir)) {
|
|
25
|
+
mkdirSync(dir, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function makeLoggerStub(): Record<string, unknown> {
|
|
31
|
+
const stub: Record<string, unknown> = {};
|
|
32
|
+
for (const m of [
|
|
33
|
+
"info",
|
|
34
|
+
"warn",
|
|
35
|
+
"error",
|
|
36
|
+
"debug",
|
|
37
|
+
"trace",
|
|
38
|
+
"fatal",
|
|
39
|
+
"silent",
|
|
40
|
+
"child",
|
|
41
|
+
]) {
|
|
42
|
+
stub[m] = m === "child" ? () => makeLoggerStub() : () => {};
|
|
43
|
+
}
|
|
44
|
+
return stub;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
mock.module("../../util/logger.js", () => ({
|
|
48
|
+
getLogger: () => makeLoggerStub(),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
afterAll(() => {
|
|
52
|
+
mock.restore();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
import { invalidateConfigCache, loadConfig } from "../loader.js";
|
|
56
|
+
|
|
57
|
+
function writeConfig(obj: unknown): void {
|
|
58
|
+
writeFileSync(CONFIG_PATH, JSON.stringify(obj, null, 2) + "\n");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
describe("config recovery compacts arrays after stripping invalid elements", () => {
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
ensureTestDir();
|
|
64
|
+
if (existsSync(CONFIG_PATH)) {
|
|
65
|
+
rmSync(CONFIG_PATH, { force: true });
|
|
66
|
+
}
|
|
67
|
+
delete process.env.IS_PLATFORM;
|
|
68
|
+
invalidateConfigCache();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
afterEach(() => {
|
|
72
|
+
delete process.env.IS_PLATFORM;
|
|
73
|
+
if (existsSync(CONFIG_PATH)) {
|
|
74
|
+
rmSync(CONFIG_PATH, { force: true });
|
|
75
|
+
}
|
|
76
|
+
invalidateConfigCache();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("one invalid array element is dropped and the valid elements survive", () => {
|
|
80
|
+
// `tools.exclude` is z.array(z.string()); the numeric element is invalid.
|
|
81
|
+
// Stripping it leaves a sparse hole, which re-parse reads as `undefined`
|
|
82
|
+
// and rejects unless the array is compacted first.
|
|
83
|
+
writeConfig({
|
|
84
|
+
tools: { exclude: ["tool-a", 123, "tool-b"] },
|
|
85
|
+
maxStepsPerSession: 77,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const config = loadConfig();
|
|
89
|
+
|
|
90
|
+
expect(config.tools.exclude).toEqual(["tool-a", "tool-b"]);
|
|
91
|
+
// The rest of the config survives — cleanup succeeded, so recovery never
|
|
92
|
+
// reaches the drop-everything fallbacks.
|
|
93
|
+
expect(config.maxStepsPerSession).toBe(77);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("multiple invalid elements in one array are all dropped", () => {
|
|
97
|
+
writeConfig({
|
|
98
|
+
tools: { exclude: [1, "tool-a", 2, "tool-b", 3] },
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const config = loadConfig();
|
|
102
|
+
|
|
103
|
+
expect(config.tools.exclude).toEqual(["tool-a", "tool-b"]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("an array emptied by stripping all invalid elements reverts to its schema default", () => {
|
|
107
|
+
// `tools.exclude` defaults to `[]`, so a fully-invalid array reverting to
|
|
108
|
+
// the default still resolves to `[]` — but it must not parse-fail, and the
|
|
109
|
+
// rest of the config must survive.
|
|
110
|
+
writeConfig({
|
|
111
|
+
tools: { exclude: [1, 2] },
|
|
112
|
+
maxStepsPerSession: 66,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const config = loadConfig();
|
|
116
|
+
|
|
117
|
+
expect(config.tools.exclude).toEqual([]);
|
|
118
|
+
expect(config.maxStepsPerSession).toBe(66);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test("emptied-by-compaction array reverts to a non-empty schema default (backup.offsite.destinations)", () => {
|
|
122
|
+
// `backup.offsite.destinations` defaults to `null`, where `null` means "use
|
|
123
|
+
// the iCloud default destination" and `[]` means "no offsite destinations".
|
|
124
|
+
// Stripping the sole invalid element must NOT leave an explicit `[]` that
|
|
125
|
+
// overrides the default — it must fall back to the schema default `null`.
|
|
126
|
+
writeConfig({
|
|
127
|
+
backup: { offsite: { destinations: [123] } },
|
|
128
|
+
maxStepsPerSession: 66,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const config = loadConfig();
|
|
132
|
+
|
|
133
|
+
expect(config.backup.offsite.destinations).toBeNull();
|
|
134
|
+
expect(config.maxStepsPerSession).toBe(66);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("emptied-by-compaction array reverts to a non-empty schema default (skills.allowBundled)", () => {
|
|
138
|
+
// `skills.allowBundled` defaults to `null` (load all bundled skills); an
|
|
139
|
+
// explicit `[]` would exclude ALL bundled skills. Stripping every invalid
|
|
140
|
+
// element must revert to the default, not silently disable all skills.
|
|
141
|
+
writeConfig({
|
|
142
|
+
skills: { allowBundled: [1, 2] },
|
|
143
|
+
maxStepsPerSession: 66,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const config = loadConfig();
|
|
147
|
+
|
|
148
|
+
expect(config.skills.allowBundled).toBeNull();
|
|
149
|
+
expect(config.maxStepsPerSession).toBe(66);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("an explicitly-empty array on disk is preserved as the user's choice", () => {
|
|
153
|
+
// `backup.offsite.destinations: []` has no invalid elements to strip, so it
|
|
154
|
+
// is never touched by compaction. An unrelated invalid field forces the
|
|
155
|
+
// cleanup path to run over the whole tree; the empty array must survive as
|
|
156
|
+
// the user's explicit "no offsite destinations" choice.
|
|
157
|
+
writeConfig({
|
|
158
|
+
backup: { offsite: { destinations: [] } },
|
|
159
|
+
maxStepsPerSession: "not-a-number",
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const config = loadConfig();
|
|
163
|
+
|
|
164
|
+
expect(config.backup.offsite.destinations).toEqual([]);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
@@ -451,3 +451,31 @@ export function getEffectiveProfiles(
|
|
|
451
451
|
}
|
|
452
452
|
return effective;
|
|
453
453
|
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Like `getEffectiveProfiles`, but resolves each default profile key through
|
|
457
|
+
* the same `llm.defaultProvider`-aware path the runtime resolver uses
|
|
458
|
+
* (`resolveDefaultProfileForProvider`) rather than always the `vellum` column.
|
|
459
|
+
* On BYOK installs this is what makes the reported provider/model/availability
|
|
460
|
+
* for `balanced`/`quality-optimized`/`cost-optimized` match what actually runs.
|
|
461
|
+
* A `null` defaultProvider reduces to `getEffectiveProfiles`.
|
|
462
|
+
*/
|
|
463
|
+
export function getEffectiveProfilesForProvider(
|
|
464
|
+
workspaceProfiles: Record<string, ProfileEntry> | undefined,
|
|
465
|
+
defaultProvider: DefaultProviderConfig | null,
|
|
466
|
+
): Record<string, ProfileEntry> {
|
|
467
|
+
const effective: Record<string, ProfileEntry> = {
|
|
468
|
+
...(workspaceProfiles ?? {}),
|
|
469
|
+
};
|
|
470
|
+
for (const name of Object.keys(CODE_DEFAULT_PROFILE_ENTRIES)) {
|
|
471
|
+
const entry = resolveDefaultProfileForProvider(
|
|
472
|
+
workspaceProfiles,
|
|
473
|
+
name,
|
|
474
|
+
defaultProvider,
|
|
475
|
+
);
|
|
476
|
+
if (entry != null) {
|
|
477
|
+
effective[name] = entry;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return effective;
|
|
481
|
+
}
|