@vellumai/assistant 0.10.7-dev.202607091742.1ef1be3 → 0.10.7-dev.202607091922.eeb94f9
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/eslint-rules/cli-no-daemon-internals.js +4 -0
- package/knip.json +2 -1
- package/openapi.yaml +8 -0
- package/package.json +1 -1
- package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
- package/src/__tests__/openrouter-provider-only.test.ts +6 -6
- package/src/__tests__/openrouter-token-estimation.test.ts +2 -2
- package/src/__tests__/pricing.test.ts +2 -2
- package/src/__tests__/process-message-background-slack.test.ts +4 -0
- package/src/__tests__/scheduler-reuse-conversation.test.ts +57 -3
- package/src/__tests__/server-history-render.test.ts +33 -3
- package/src/__tests__/task-scheduler.test.ts +40 -2
- package/src/__tests__/turn-outcome-read.test.ts +81 -0
- package/src/__tests__/workspace-migration-128-repair-stale-openrouter-grok-model-ids.test.ts +135 -0
- package/src/api/responses/conversation-message.ts +9 -0
- package/src/cli/commands/memory/index.ts +8 -0
- package/src/cli/commands/memory/nodes.ts +261 -0
- package/src/daemon/handlers/shared.ts +14 -5
- package/src/daemon/message-types/conversations.ts +2 -0
- package/src/daemon/process-message.ts +22 -2
- package/src/persistence/db-init.ts +1 -15
- package/src/persistence/embeddings/plugin-facade.ts +37 -0
- package/src/persistence/jobs-store.ts +46 -0
- package/src/plugin-api/index.ts +8 -0
- package/src/plugins/defaults/memory/__tests__/jobs-worker-pkb-schedule.test.ts +7 -0
- package/src/plugins/defaults/memory/__tests__/jobs-worker-v2-schedule.test.ts +7 -0
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +44 -7
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +261 -6
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-trigger-check.test.ts +30 -0
- package/src/plugins/defaults/memory/embeddings.ts +8 -40
- package/src/plugins/defaults/memory/graph/graph-search.ts +32 -13
- package/src/plugins/defaults/memory/graph/retriever.test.ts +27 -9
- package/src/plugins/defaults/memory/graph/retriever.ts +75 -27
- package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +328 -0
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +246 -0
- package/src/plugins/defaults/memory/indexer.ts +10 -4
- package/src/plugins/defaults/memory/job-handlers/embedding.ts +28 -10
- package/src/plugins/defaults/memory/job-handlers/index-maintenance.ts +4 -2
- package/src/plugins/defaults/memory/job-handlers.ts +5 -0
- package/src/plugins/defaults/memory/memory-retrospective-job.ts +80 -17
- package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +241 -82
- package/src/plugins/defaults/memory/memory-retrospective-state.ts +13 -9
- package/src/plugins/defaults/memory/pkb/pkb-index.ts +17 -6
- package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +14 -4
- package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +20 -6
- package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +2 -0
- package/src/providers/__tests__/registry-native-web-search.test.ts +4 -7
- package/src/providers/model-catalog.ts +112 -12
- package/src/runtime/__tests__/background-job-runner.test.ts +43 -1
- package/src/runtime/background-job-runner.ts +34 -1
- package/src/runtime/routes/__tests__/consolidation-routes.test.ts +7 -0
- package/src/schedule/scheduler.ts +54 -18
- package/src/telemetry/turn-outcome.ts +57 -1
- package/src/tools/skills/skill-script-runner.ts +15 -26
- package/src/workspace/migrations/128-repair-stale-openrouter-grok-model-ids.ts +112 -0
- package/src/workspace/migrations/registry.ts +2 -0
- package/scripts/generate-bundled-tool-registry.ts +0 -223
- package/src/__tests__/workspace-fixtures.ts +0 -45
- package/src/config/__tests__/bundled-tool-registry-guard.test.ts +0 -120
- package/src/config/bundled-tool-registry.ts +0 -281
|
@@ -67,6 +67,10 @@ const ALLOWED_PREFIXES = {
|
|
|
67
67
|
// commands/memory/ nesting.
|
|
68
68
|
"../../plugins/defaults/memory/memory-retrospective-job",
|
|
69
69
|
"../../../plugins/defaults/memory/memory-retrospective-job",
|
|
70
|
+
// Memory nodes CRUD — `memory nodes list/delete/update` invoke the graph
|
|
71
|
+
// tool-handlers directly in-process (no IPC, no daemon dependency).
|
|
72
|
+
// Depth-3 for commands/memory/ nesting.
|
|
73
|
+
"../../../plugins/defaults/memory/graph/tool-handlers",
|
|
70
74
|
// Standalone tool execution — `tools run` executes a single tool
|
|
71
75
|
// in-process from the filesystem (no daemon, no IPC), so it imports the
|
|
72
76
|
// standalone runner directly. Depth-2 for commands/ nesting.
|
package/knip.json
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
"scripts/**/*.ts",
|
|
6
6
|
"src/daemon/main.ts!",
|
|
7
7
|
"src/plugin-api/index.ts!",
|
|
8
|
-
"src/api/index.ts!"
|
|
8
|
+
"src/api/index.ts!",
|
|
9
|
+
"src/config/bundled-skills/**/tools/**/*.ts!"
|
|
9
10
|
],
|
|
10
11
|
"project": ["src/**/*.ts!", "src/**/*.tsx!", "scripts/**/*.ts"],
|
|
11
12
|
"ignore": ["src/config/preloaded-apps/**"],
|
package/openapi.yaml
CHANGED
|
@@ -17542,6 +17542,10 @@ paths:
|
|
|
17542
17542
|
type: array
|
|
17543
17543
|
items:
|
|
17544
17544
|
type: string
|
|
17545
|
+
imageAttachmentIds:
|
|
17546
|
+
type: array
|
|
17547
|
+
items:
|
|
17548
|
+
type: string
|
|
17545
17549
|
startedAt:
|
|
17546
17550
|
type: number
|
|
17547
17551
|
previewStartedAt:
|
|
@@ -17974,6 +17978,10 @@ paths:
|
|
|
17974
17978
|
type: array
|
|
17975
17979
|
items:
|
|
17976
17980
|
type: string
|
|
17981
|
+
imageAttachmentIds:
|
|
17982
|
+
type: array
|
|
17983
|
+
items:
|
|
17984
|
+
type: string
|
|
17977
17985
|
startedAt:
|
|
17978
17986
|
type: number
|
|
17979
17987
|
previewStartedAt:
|
package/package.json
CHANGED
|
@@ -95,7 +95,7 @@ describe("OpenRouter provider.only plumbing", () => {
|
|
|
95
95
|
test("emits provider.only in extras when config has openrouter.only", () => {
|
|
96
96
|
const provider = new ProbeOpenRouterProvider(
|
|
97
97
|
"fake-key",
|
|
98
|
-
"x-ai/grok-4.20
|
|
98
|
+
"x-ai/grok-4.20",
|
|
99
99
|
);
|
|
100
100
|
const extras = provider.probeExtras({
|
|
101
101
|
config: { openrouter: { only: ["xAI"] } },
|
|
@@ -108,7 +108,7 @@ describe("OpenRouter provider.only plumbing", () => {
|
|
|
108
108
|
test("omits reasoning and provider when config is empty", () => {
|
|
109
109
|
const provider = new ProbeOpenRouterProvider(
|
|
110
110
|
"fake-key",
|
|
111
|
-
"x-ai/grok-4.20
|
|
111
|
+
"x-ai/grok-4.20",
|
|
112
112
|
);
|
|
113
113
|
const extras = provider.probeExtras({ config: {} });
|
|
114
114
|
expect(extras).toEqual({});
|
|
@@ -119,7 +119,7 @@ describe("OpenRouter provider.only plumbing", () => {
|
|
|
119
119
|
test("enables thinking with default detailed summary alongside provider.only", () => {
|
|
120
120
|
const provider = new ProbeOpenRouterProvider(
|
|
121
121
|
"fake-key",
|
|
122
|
-
"x-ai/grok-4.20
|
|
122
|
+
"x-ai/grok-4.20",
|
|
123
123
|
);
|
|
124
124
|
const extras = provider.probeExtras({
|
|
125
125
|
config: {
|
|
@@ -136,7 +136,7 @@ describe("OpenRouter provider.only plumbing", () => {
|
|
|
136
136
|
test("disabled thinking omits reasoning entirely", () => {
|
|
137
137
|
const provider = new ProbeOpenRouterProvider(
|
|
138
138
|
"fake-key",
|
|
139
|
-
"x-ai/grok-4.20
|
|
139
|
+
"x-ai/grok-4.20",
|
|
140
140
|
);
|
|
141
141
|
const extras = provider.probeExtras({
|
|
142
142
|
config: {
|
|
@@ -185,7 +185,7 @@ describe("OpenRouter provider.only plumbing", () => {
|
|
|
185
185
|
test("effort without thinking does not emit reasoning", () => {
|
|
186
186
|
const provider = new ProbeOpenRouterProvider(
|
|
187
187
|
"fake-key",
|
|
188
|
-
"x-ai/grok-4.20
|
|
188
|
+
"x-ai/grok-4.20",
|
|
189
189
|
);
|
|
190
190
|
const extras = provider.probeExtras({
|
|
191
191
|
config: { thinking: { type: "disabled" }, effort: "low" },
|
|
@@ -196,7 +196,7 @@ describe("OpenRouter provider.only plumbing", () => {
|
|
|
196
196
|
test("disabled thinking with effort none leaves the opt-out to the flat reasoning_effort field", () => {
|
|
197
197
|
const provider = new ProbeOpenRouterProvider(
|
|
198
198
|
"fake-key",
|
|
199
|
-
"x-ai/grok-4.20
|
|
199
|
+
"x-ai/grok-4.20",
|
|
200
200
|
);
|
|
201
201
|
const extras = provider.probeExtras({
|
|
202
202
|
config: { thinking: { type: "disabled" }, effort: "none" },
|
|
@@ -40,7 +40,7 @@ describe("OpenRouterProvider token estimation routing", () => {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
test("reports its own name for non-Anthropic default models", () => {
|
|
43
|
-
const provider = new OpenRouterProvider("fake-key", "x-ai/grok-4.20
|
|
43
|
+
const provider = new OpenRouterProvider("fake-key", "x-ai/grok-4.20");
|
|
44
44
|
expect(provider.tokenEstimationProvider).toBe(provider.name);
|
|
45
45
|
expect(provider.tokenEstimationProvider).toBe("openrouter");
|
|
46
46
|
});
|
|
@@ -81,7 +81,7 @@ describe("OpenRouterProvider token estimation routing", () => {
|
|
|
81
81
|
// window fills. Vision models on OpenRouter — both anthropic/* and
|
|
82
82
|
// non-Anthropic (Kimi K2.6, Grok, etc.) — must use the dimension-based
|
|
83
83
|
// formula.
|
|
84
|
-
for (const model of ["moonshotai/kimi-k2.6", "x-ai/grok-4.20
|
|
84
|
+
for (const model of ["moonshotai/kimi-k2.6", "x-ai/grok-4.20"]) {
|
|
85
85
|
const provider = new OpenRouterProvider("fake-key", model);
|
|
86
86
|
const messages: Message[] = [
|
|
87
87
|
{
|
|
@@ -785,12 +785,12 @@ describe("Anthropic models on OpenRouter", () => {
|
|
|
785
785
|
test("prices non-Anthropic OpenRouter model from catalog", () => {
|
|
786
786
|
const result = resolvePricing(
|
|
787
787
|
"openrouter",
|
|
788
|
-
"x-ai/grok-4.20
|
|
788
|
+
"x-ai/grok-4.20",
|
|
789
789
|
1_000_000,
|
|
790
790
|
1_000_000,
|
|
791
791
|
);
|
|
792
792
|
expect(result.pricingStatus).toBe("priced");
|
|
793
|
-
expect(result.estimatedCostUsd).toBe(
|
|
793
|
+
expect(result.estimatedCostUsd).toBe(1.25 + 2.5);
|
|
794
794
|
});
|
|
795
795
|
|
|
796
796
|
test("returns unpriced for unknown non-Anthropic OpenRouter model", () => {
|
|
@@ -23,6 +23,7 @@ mock.module("../persistence/conversation-crud.js", () => ({
|
|
|
23
23
|
isConversationProcessing: () => false,
|
|
24
24
|
addMessage: async () => ({ id: "message-id" }),
|
|
25
25
|
getConversation: () => null,
|
|
26
|
+
getMessageById: () => null,
|
|
26
27
|
provenanceFromTrustContext: () => ({}),
|
|
27
28
|
setConversationOriginChannelIfUnset: () => {},
|
|
28
29
|
setConversationOriginInterfaceIfUnset: () => {},
|
|
@@ -313,8 +314,11 @@ describe("processMessageInBackground Slack option propagation", () => {
|
|
|
313
314
|
expect(observedMessages).toEqual([delta]);
|
|
314
315
|
|
|
315
316
|
activeConversation.__loopDeferred.resolve();
|
|
317
|
+
// processMessage now also reports the turn's failure outcome, read back
|
|
318
|
+
// from the stamped metadata — null here since the turn replied normally.
|
|
316
319
|
await expect(processing).resolves.toEqual({
|
|
317
320
|
messageId: "persisted-user-message-id",
|
|
321
|
+
turnFailure: null,
|
|
318
322
|
});
|
|
319
323
|
});
|
|
320
324
|
|
|
@@ -80,17 +80,24 @@ mock.module("../runtime/background-job-runner.js", () => ({
|
|
|
80
80
|
|
|
81
81
|
// The scheduler's reuse path dispatches into the existing conversation through
|
|
82
82
|
// `processMessage`; capture those calls into the same shared log as the
|
|
83
|
-
// fresh-bootstrap runner so assertions don't need to know which path ran.
|
|
83
|
+
// fresh-bootstrap runner so assertions don't need to know which path ran. The
|
|
84
|
+
// real `processMessage` resolves to `{ messageId, turnFailure? }`, so the mock
|
|
85
|
+
// mirrors that shape — the scheduler destructures `turnFailure` off it.
|
|
86
|
+
type ProcessMessageResult = {
|
|
87
|
+
messageId: string;
|
|
88
|
+
turnFailure?: { failureCode?: string };
|
|
89
|
+
};
|
|
84
90
|
const captureProcessedMessage = async (
|
|
85
91
|
conversationId: string,
|
|
86
92
|
message: string,
|
|
87
|
-
): Promise<
|
|
93
|
+
): Promise<ProcessMessageResult> => {
|
|
88
94
|
processedMessages.push({ conversationId, message });
|
|
95
|
+
return { messageId: "test-message-id" };
|
|
89
96
|
};
|
|
90
97
|
let processMessageImpl: (
|
|
91
98
|
conversationId: string,
|
|
92
99
|
message: string,
|
|
93
|
-
) => Promise<
|
|
100
|
+
) => Promise<ProcessMessageResult> = captureProcessedMessage;
|
|
94
101
|
mock.module("../daemon/process-message.js", () => ({
|
|
95
102
|
processMessage: (conversationId: string, message: string) =>
|
|
96
103
|
processMessageImpl(conversationId, message),
|
|
@@ -369,6 +376,7 @@ describe("scheduler conversation reuse", () => {
|
|
|
369
376
|
processMessageImpl = async (conversationId, message) => {
|
|
370
377
|
processedMessages.push({ conversationId, message });
|
|
371
378
|
if (shouldFail) throw new Error("Simulated failure");
|
|
379
|
+
return { messageId: "test-message-id" };
|
|
372
380
|
};
|
|
373
381
|
|
|
374
382
|
await runScheduleDueWorkOnce();
|
|
@@ -400,6 +408,52 @@ describe("scheduler conversation reuse", () => {
|
|
|
400
408
|
expect(processedMessages).toHaveLength(1);
|
|
401
409
|
expect(processedMessages[0].conversationId).toBe(successConversationId);
|
|
402
410
|
});
|
|
411
|
+
|
|
412
|
+
test("reuse path records an error when the turn fails without throwing", async () => {
|
|
413
|
+
/**
|
|
414
|
+
* Regression: an execute-mode LLM call that fails (e.g. an invalid
|
|
415
|
+
* provider) ends the turn without throwing — `processMessage` resolves
|
|
416
|
+
* normally and reports the failure via `turnFailure`. The scheduler must
|
|
417
|
+
* record the run as an error, not "ok".
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
// GIVEN a recurring reuse schedule whose first run succeeds
|
|
421
|
+
const rruleExpr = buildEveryMinuteRrule();
|
|
422
|
+
const schedule = await createSchedule({
|
|
423
|
+
name: "Turn Failure Reuse",
|
|
424
|
+
cronExpression: rruleExpr,
|
|
425
|
+
message: "Do the thing",
|
|
426
|
+
syntax: "rrule",
|
|
427
|
+
expression: rruleExpr,
|
|
428
|
+
reuseConversation: true,
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
forceScheduleDue(schedule.id);
|
|
432
|
+
await runScheduleDueWorkOnce();
|
|
433
|
+
|
|
434
|
+
const runs1 = getScheduleRuns(schedule.id);
|
|
435
|
+
expect(runs1[0].status).toBe("ok");
|
|
436
|
+
|
|
437
|
+
// WHEN the next run's turn fails at the LLM call (reported via turnFailure,
|
|
438
|
+
// no exception thrown)
|
|
439
|
+
forceScheduleDue(schedule.id);
|
|
440
|
+
processedMessages.length = 0;
|
|
441
|
+
processMessageImpl = async (conversationId, message) => {
|
|
442
|
+
processedMessages.push({ conversationId, message });
|
|
443
|
+
return {
|
|
444
|
+
messageId: "test-message-id",
|
|
445
|
+
turnFailure: { failureCode: "provider_error" },
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
await runScheduleDueWorkOnce();
|
|
450
|
+
|
|
451
|
+
// THEN the run is recorded as an error (not "ok") and carries the code
|
|
452
|
+
const runs2 = getScheduleRuns(schedule.id);
|
|
453
|
+
expect(runs2.length).toBe(2);
|
|
454
|
+
expect(runs2[0].status).toBe("error");
|
|
455
|
+
expect(runs2[0].error).toContain("provider_error");
|
|
456
|
+
});
|
|
403
457
|
});
|
|
404
458
|
|
|
405
459
|
describe("scheduler talk-mode runner option propagation", () => {
|
|
@@ -257,7 +257,7 @@ describe("renderHistoryContent", () => {
|
|
|
257
257
|
]);
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
test("
|
|
260
|
+
test("emits the attachment id for a workspace_ref tool-result image", () => {
|
|
261
261
|
// "aGVsbG8=" = "hello" — a stand-in for screenshot bytes.
|
|
262
262
|
const stored = uploadAttachment("shot.png", "image/png", "aGVsbG8=");
|
|
263
263
|
const output = renderHistoryContent([
|
|
@@ -281,10 +281,40 @@ describe("renderHistoryContent", () => {
|
|
|
281
281
|
},
|
|
282
282
|
]);
|
|
283
283
|
|
|
284
|
-
//
|
|
285
|
-
//
|
|
284
|
+
// Referenced media emits its attachment id so clients fetch the bytes by
|
|
285
|
+
// id on render instead of inlining base64 into the history wire; the
|
|
286
|
+
// base64 fields stay empty for referenced images.
|
|
287
|
+
expect(output.toolCalls[0].imageAttachmentIds).toEqual([stored.id]);
|
|
288
|
+
expect(output.toolCalls[0].imageDataList).toBeUndefined();
|
|
289
|
+
expect(output.toolCalls[0].imageData).toBeUndefined();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test("resolves an inline base64 tool-result image without an id", () => {
|
|
293
|
+
const output = renderHistoryContent([
|
|
294
|
+
{ type: "tool_use", id: "tu_1", name: "browser_screenshot", input: {} },
|
|
295
|
+
{
|
|
296
|
+
type: "tool_result",
|
|
297
|
+
tool_use_id: "tu_1",
|
|
298
|
+
content: "captured",
|
|
299
|
+
is_error: false,
|
|
300
|
+
contentBlocks: [
|
|
301
|
+
{
|
|
302
|
+
type: "image",
|
|
303
|
+
source: {
|
|
304
|
+
type: "base64",
|
|
305
|
+
media_type: "image/png",
|
|
306
|
+
data: "aGVsbG8=",
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
]);
|
|
312
|
+
|
|
313
|
+
// Legacy inline base64 (no workspace reference) still resolves to the
|
|
314
|
+
// base64 wire fields and carries no attachment id.
|
|
286
315
|
expect(output.toolCalls[0].imageDataList).toEqual(["aGVsbG8="]);
|
|
287
316
|
expect(output.toolCalls[0].imageData).toBe("aGVsbG8=");
|
|
317
|
+
expect(output.toolCalls[0].imageAttachmentIds).toBeUndefined();
|
|
288
318
|
});
|
|
289
319
|
|
|
290
320
|
test("marks error tool results", () => {
|
|
@@ -95,11 +95,17 @@ let processMessageImpl: (
|
|
|
95
95
|
options?: unknown,
|
|
96
96
|
) => Promise<unknown> = async () => {};
|
|
97
97
|
mock.module("../daemon/process-message.js", () => ({
|
|
98
|
-
processMessage:
|
|
98
|
+
// Normalize to the real `processMessage` contract: it always resolves to
|
|
99
|
+
// `{ messageId, turnFailure? }`. The scheduler destructures `turnFailure`
|
|
100
|
+
// off it, so a test impl that returns nothing still yields a valid object.
|
|
101
|
+
processMessage: async (
|
|
99
102
|
conversationId: string,
|
|
100
103
|
message: string,
|
|
101
104
|
options?: unknown,
|
|
102
|
-
) =>
|
|
105
|
+
) => {
|
|
106
|
+
const res = await processMessageImpl(conversationId, message, options);
|
|
107
|
+
return res ?? { messageId: "test-message-id" };
|
|
108
|
+
},
|
|
103
109
|
}));
|
|
104
110
|
|
|
105
111
|
import { loadRawConfig, saveRawConfig } from "../config/loader.js";
|
|
@@ -428,6 +434,38 @@ describe("scheduler run_task detection", () => {
|
|
|
428
434
|
});
|
|
429
435
|
});
|
|
430
436
|
|
|
437
|
+
test("records a task run as error when the turn fails without throwing", async () => {
|
|
438
|
+
// A run_task:<id> schedule whose LLM call fails (e.g. an invalid provider)
|
|
439
|
+
// ends the turn without throwing — processMessage resolves and reports the
|
|
440
|
+
// failure via turnFailure. The task callback must turn that into a failed
|
|
441
|
+
// task result so the run is recorded as error, not ok.
|
|
442
|
+
const task = createTask({
|
|
443
|
+
title: "Bad Creds Task",
|
|
444
|
+
template: "Spend scheduled tokens",
|
|
445
|
+
});
|
|
446
|
+
const schedule = await scheduleTask({
|
|
447
|
+
taskId: task.id,
|
|
448
|
+
name: "Bad Creds Schedule",
|
|
449
|
+
cronExpression: "* * * * *",
|
|
450
|
+
});
|
|
451
|
+
forceScheduleDue(schedule.id);
|
|
452
|
+
|
|
453
|
+
processMessageImpl = async () => ({
|
|
454
|
+
messageId: "test-message-id",
|
|
455
|
+
turnFailure: { failureCode: "provider_error" },
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
const result = await runScheduleDueWorkOnce();
|
|
459
|
+
|
|
460
|
+
expect(result.completed).toBe(0);
|
|
461
|
+
expect(result.failed).toBe(1);
|
|
462
|
+
|
|
463
|
+
const runs = getScheduleRuns(schedule.id);
|
|
464
|
+
expect(runs).toHaveLength(1);
|
|
465
|
+
expect(runs[0].status).toBe("error");
|
|
466
|
+
expect(runs[0].error).toContain("provider_error");
|
|
467
|
+
});
|
|
468
|
+
|
|
431
469
|
test("opens a normal execute schedule run before fresh background processing and records the conversation id", async () => {
|
|
432
470
|
const schedule = await createSchedule({
|
|
433
471
|
name: "Usage Attribution Message Schedule",
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Round-trip tests for `stampTurnOutcome` + `readTurnFailure`.
|
|
3
|
+
*
|
|
4
|
+
* `readTurnFailure` is the single reader of the turn-outcome stamp that
|
|
5
|
+
* non-interactive callers (the scheduler's execute mode) use to tell a
|
|
6
|
+
* genuinely failed turn from a normal reply — a failed LLM call ends the turn
|
|
7
|
+
* without throwing, so the stamped metadata is the only signal. These tests
|
|
8
|
+
* pin that the reader reflects exactly what the stamp wrote, with no parallel
|
|
9
|
+
* copy of the outcome.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
13
|
+
|
|
14
|
+
import { makeMockLogger } from "./helpers/mock-logger.js";
|
|
15
|
+
|
|
16
|
+
mock.module("../util/logger.js", () => ({
|
|
17
|
+
getLogger: () => makeMockLogger(),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
addMessage,
|
|
22
|
+
createConversation,
|
|
23
|
+
} from "../persistence/conversation-crud.js";
|
|
24
|
+
import { getDb } from "../persistence/db-connection.js";
|
|
25
|
+
import { initializeDb } from "../persistence/db-init.js";
|
|
26
|
+
import {
|
|
27
|
+
readTurnFailure,
|
|
28
|
+
stampTurnOutcome,
|
|
29
|
+
} from "../telemetry/turn-outcome.js";
|
|
30
|
+
|
|
31
|
+
await initializeDb();
|
|
32
|
+
|
|
33
|
+
function purge(): void {
|
|
34
|
+
const db = getDb();
|
|
35
|
+
db.run("DELETE FROM messages");
|
|
36
|
+
db.run("DELETE FROM conversations");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
purge();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("readTurnFailure", () => {
|
|
44
|
+
test("returns the failure with its code after a failed stamp", async () => {
|
|
45
|
+
const conv = createConversation({ conversationType: "scheduled" });
|
|
46
|
+
const msg = await addMessage(conv.id, "user", "run the job");
|
|
47
|
+
|
|
48
|
+
stampTurnOutcome(msg.id, "failed", { failureCode: "provider_error" });
|
|
49
|
+
|
|
50
|
+
expect(readTurnFailure(msg.id)).toEqual({ failureCode: "provider_error" });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("returns an empty failure when a failed turn carried no code", async () => {
|
|
54
|
+
const conv = createConversation({ conversationType: "scheduled" });
|
|
55
|
+
const msg = await addMessage(conv.id, "user", "run the job");
|
|
56
|
+
|
|
57
|
+
stampTurnOutcome(msg.id, "failed");
|
|
58
|
+
|
|
59
|
+
expect(readTurnFailure(msg.id)).toEqual({});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("returns null for a normally-replied turn (no stamp)", async () => {
|
|
63
|
+
const conv = createConversation({ conversationType: "scheduled" });
|
|
64
|
+
const msg = await addMessage(conv.id, "user", "run the job");
|
|
65
|
+
|
|
66
|
+
expect(readTurnFailure(msg.id)).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("returns null for a cancelled turn (not a failure)", async () => {
|
|
70
|
+
const conv = createConversation({ conversationType: "scheduled" });
|
|
71
|
+
const msg = await addMessage(conv.id, "user", "run the job");
|
|
72
|
+
|
|
73
|
+
stampTurnOutcome(msg.id, "cancelled");
|
|
74
|
+
|
|
75
|
+
expect(readTurnFailure(msg.id)).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("returns null for an unknown message id", () => {
|
|
79
|
+
expect(readTurnFailure("does-not-exist")).toBeNull();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
rmSync,
|
|
6
|
+
writeFileSync,
|
|
7
|
+
} from "node:fs";
|
|
8
|
+
import { tmpdir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
11
|
+
|
|
12
|
+
import { repairStaleOpenrouterGrokModelIdsMigration } from "../workspace/migrations/128-repair-stale-openrouter-grok-model-ids.js";
|
|
13
|
+
import { WORKSPACE_MIGRATIONS } from "../workspace/migrations/registry.js";
|
|
14
|
+
|
|
15
|
+
let workspaceDir: string;
|
|
16
|
+
|
|
17
|
+
function freshWorkspace(): void {
|
|
18
|
+
workspaceDir = join(
|
|
19
|
+
tmpdir(),
|
|
20
|
+
`vellum-migration-128-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
21
|
+
);
|
|
22
|
+
mkdirSync(workspaceDir, { recursive: true });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function writeConfig(data: Record<string, unknown>): void {
|
|
26
|
+
writeFileSync(
|
|
27
|
+
join(workspaceDir, "config.json"),
|
|
28
|
+
JSON.stringify(data, null, 2) + "\n",
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function readConfig(): Record<string, unknown> {
|
|
33
|
+
return JSON.parse(readFileSync(join(workspaceDir, "config.json"), "utf-8"));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
freshWorkspace();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
if (existsSync(workspaceDir)) {
|
|
42
|
+
rmSync(workspaceDir, { recursive: true, force: true });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("128-repair-stale-openrouter-grok-model-ids migration", () => {
|
|
47
|
+
test("has correct migration id and is registered", () => {
|
|
48
|
+
expect(repairStaleOpenrouterGrokModelIdsMigration.id).toBe(
|
|
49
|
+
"128-repair-stale-openrouter-grok-model-ids",
|
|
50
|
+
);
|
|
51
|
+
expect(WORKSPACE_MIGRATIONS.map((m) => m.id)).toContain(
|
|
52
|
+
"128-repair-stale-openrouter-grok-model-ids",
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("repairs stale IDs in default, call sites, and profiles", () => {
|
|
57
|
+
writeConfig({
|
|
58
|
+
llm: {
|
|
59
|
+
default: { provider: "openrouter", model: "x-ai/grok-4.20-beta" },
|
|
60
|
+
callSites: {
|
|
61
|
+
recall: { model: "x-ai/grok-4", maxTokens: 4096 },
|
|
62
|
+
commitMessage: { model: "x-ai/grok-4.20-beta-tuned" },
|
|
63
|
+
malformed: "x-ai/grok-4.20-beta",
|
|
64
|
+
},
|
|
65
|
+
profiles: {
|
|
66
|
+
fast: { provider: "openrouter", model: "x-ai/grok-4.20-beta" },
|
|
67
|
+
legacy: { model: "x-ai/grok-4" },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
repairStaleOpenrouterGrokModelIdsMigration.run(workspaceDir);
|
|
73
|
+
|
|
74
|
+
const llm = readConfig().llm as Record<string, any>;
|
|
75
|
+
expect(llm.default.model).toBe("x-ai/grok-4.20");
|
|
76
|
+
expect(llm.callSites.recall.model).toBe("x-ai/grok-4.5");
|
|
77
|
+
expect(llm.callSites.recall.maxTokens).toBe(4096);
|
|
78
|
+
// Non-exact matches and malformed leaves are untouched.
|
|
79
|
+
expect(llm.callSites.commitMessage.model).toBe("x-ai/grok-4.20-beta-tuned");
|
|
80
|
+
expect(llm.callSites.malformed).toBe("x-ai/grok-4.20-beta");
|
|
81
|
+
expect(llm.profiles.fast.model).toBe("x-ai/grok-4.20");
|
|
82
|
+
expect(llm.profiles.legacy.model).toBe("x-ai/grok-4.5");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test("leaves fragments with an explicit non-OpenRouter provider untouched", () => {
|
|
86
|
+
writeConfig({
|
|
87
|
+
llm: {
|
|
88
|
+
default: { provider: "openai-compatible", model: "x-ai/grok-4" },
|
|
89
|
+
profiles: {
|
|
90
|
+
byo: { provider: "openai-compatible", model: "x-ai/grok-4.20-beta" },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
repairStaleOpenrouterGrokModelIdsMigration.run(workspaceDir);
|
|
96
|
+
|
|
97
|
+
const llm = readConfig().llm as Record<string, any>;
|
|
98
|
+
expect(llm.default.model).toBe("x-ai/grok-4");
|
|
99
|
+
expect(llm.profiles.byo.model).toBe("x-ai/grok-4.20-beta");
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("is idempotent and a no-op without stale IDs", () => {
|
|
103
|
+
writeConfig({
|
|
104
|
+
llm: {
|
|
105
|
+
default: { provider: "openrouter", model: "x-ai/grok-4.20-beta" },
|
|
106
|
+
profiles: { fine: { provider: "openrouter", model: "x-ai/grok-4.5" } },
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
repairStaleOpenrouterGrokModelIdsMigration.run(workspaceDir);
|
|
111
|
+
const first = readConfig();
|
|
112
|
+
repairStaleOpenrouterGrokModelIdsMigration.run(workspaceDir);
|
|
113
|
+
expect(readConfig()).toEqual(first);
|
|
114
|
+
|
|
115
|
+
const llm = first.llm as Record<string, any>;
|
|
116
|
+
expect(llm.default.model).toBe("x-ai/grok-4.20");
|
|
117
|
+
expect(llm.profiles.fine.model).toBe("x-ai/grok-4.5");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test("handles missing config, missing llm block, and invalid JSON", () => {
|
|
121
|
+
// No config.json at all.
|
|
122
|
+
expect(() =>
|
|
123
|
+
repairStaleOpenrouterGrokModelIdsMigration.run(workspaceDir),
|
|
124
|
+
).not.toThrow();
|
|
125
|
+
|
|
126
|
+
writeConfig({ theme: "dark" });
|
|
127
|
+
repairStaleOpenrouterGrokModelIdsMigration.run(workspaceDir);
|
|
128
|
+
expect(readConfig()).toEqual({ theme: "dark" });
|
|
129
|
+
|
|
130
|
+
writeFileSync(join(workspaceDir, "config.json"), "{not json");
|
|
131
|
+
expect(() =>
|
|
132
|
+
repairStaleOpenrouterGrokModelIdsMigration.run(workspaceDir),
|
|
133
|
+
).not.toThrow();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -153,6 +153,15 @@ export const ConversationMessageToolCallSchema = z.object({
|
|
|
153
153
|
imageData: z.string().optional(),
|
|
154
154
|
/** Base64-encoded image data from tool contentBlocks (e.g. browser_screenshot, image generation). */
|
|
155
155
|
imageDataList: z.array(z.string()).optional(),
|
|
156
|
+
/**
|
|
157
|
+
* Workspace attachment ids for tool-result images persisted as workspace
|
|
158
|
+
* references. When present, clients fetch the image bytes by id on render
|
|
159
|
+
* (lazy) rather than embedding base64 in the history wire. Positionally
|
|
160
|
+
* aligned with the tool's rendered images; a row emits either these ids
|
|
161
|
+
* (referenced media) or `imageDataList` (legacy inline base64), not both for
|
|
162
|
+
* the same image.
|
|
163
|
+
*/
|
|
164
|
+
imageAttachmentIds: z.array(z.string()).optional(),
|
|
156
165
|
/** Unix ms when the tool started executing (the `tool_use_start` time). */
|
|
157
166
|
startedAt: z.number().optional(),
|
|
158
167
|
/**
|
|
@@ -5,6 +5,7 @@ import { registerMemoryItemsCommand } from "./items.js";
|
|
|
5
5
|
import { registerMemoryRetrospectiveCommand } from "./memory-retrospective.js";
|
|
6
6
|
import { registerMemoryV2Command } from "./memory-v2.js";
|
|
7
7
|
import { registerMemoryV3Command } from "./memory-v3.js";
|
|
8
|
+
import { registerMemoryNodesCommand } from "./nodes.js";
|
|
8
9
|
import { registerMemoryWorkerCommand } from "./worker.js";
|
|
9
10
|
|
|
10
11
|
export function registerMemoryCommand(program: Command): void {
|
|
@@ -17,6 +18,9 @@ export function registerMemoryCommand(program: Command): void {
|
|
|
17
18
|
memory.addHelpText(
|
|
18
19
|
"after",
|
|
19
20
|
`
|
|
21
|
+
The 'nodes' subgroup provides content-based list, delete, and update over
|
|
22
|
+
memory v2 graph nodes — address facts by text, not UUID (requires memory v2).
|
|
23
|
+
|
|
20
24
|
The 'items' subgroup exposes full CRUD over individual memory items
|
|
21
25
|
(remembered facts) — list, get, create, update, delete.
|
|
22
26
|
|
|
@@ -26,6 +30,9 @@ model (section-grain lanes cached as live shadow state). Each subgroup exposes
|
|
|
26
30
|
operator-facing maintenance verbs — reindexing, backfills, validation, and evals.
|
|
27
31
|
|
|
28
32
|
Examples:
|
|
33
|
+
$ assistant memory nodes list --search "coffee"
|
|
34
|
+
$ assistant memory nodes delete "User prefers TypeScript"
|
|
35
|
+
$ assistant memory nodes update "User prefers TypeScript" "User prefers TypeScript and Bun"
|
|
29
36
|
$ assistant memory items list --search "coffee"
|
|
30
37
|
$ assistant memory items update 9f2c4f3a-3f1a-41e4-88e7-abc123 --statement "Prefers tea"
|
|
31
38
|
$ assistant memory items delete 9f2c4f3a-3f1a-41e4-88e7-abc123
|
|
@@ -33,6 +40,7 @@ Examples:
|
|
|
33
40
|
$ assistant memory v3 rebuild-index`,
|
|
34
41
|
);
|
|
35
42
|
|
|
43
|
+
registerMemoryNodesCommand(memory);
|
|
36
44
|
registerMemoryItemsCommand(memory);
|
|
37
45
|
registerMemoryV2Command(memory);
|
|
38
46
|
registerMemoryV3Command(memory);
|