@vellumai/assistant 0.10.7-dev.202607091842.693dcca → 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.
Files changed (53) hide show
  1. package/eslint-rules/cli-no-daemon-internals.js +4 -0
  2. package/knip.json +2 -1
  3. package/openapi.yaml +8 -0
  4. package/package.json +1 -1
  5. package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
  6. package/src/__tests__/process-message-background-slack.test.ts +4 -0
  7. package/src/__tests__/scheduler-reuse-conversation.test.ts +57 -3
  8. package/src/__tests__/server-history-render.test.ts +33 -3
  9. package/src/__tests__/task-scheduler.test.ts +40 -2
  10. package/src/__tests__/turn-outcome-read.test.ts +81 -0
  11. package/src/api/responses/conversation-message.ts +9 -0
  12. package/src/cli/commands/memory/index.ts +8 -0
  13. package/src/cli/commands/memory/nodes.ts +261 -0
  14. package/src/daemon/handlers/shared.ts +14 -5
  15. package/src/daemon/message-types/conversations.ts +2 -0
  16. package/src/daemon/process-message.ts +22 -2
  17. package/src/persistence/db-init.ts +1 -15
  18. package/src/persistence/embeddings/plugin-facade.ts +37 -0
  19. package/src/persistence/jobs-store.ts +46 -0
  20. package/src/plugin-api/index.ts +8 -0
  21. package/src/plugins/defaults/memory/__tests__/jobs-worker-pkb-schedule.test.ts +7 -0
  22. package/src/plugins/defaults/memory/__tests__/jobs-worker-v2-schedule.test.ts +7 -0
  23. package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +44 -7
  24. package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +261 -6
  25. package/src/plugins/defaults/memory/__tests__/memory-retrospective-trigger-check.test.ts +30 -0
  26. package/src/plugins/defaults/memory/embeddings.ts +8 -40
  27. package/src/plugins/defaults/memory/graph/graph-search.ts +32 -13
  28. package/src/plugins/defaults/memory/graph/retriever.test.ts +27 -9
  29. package/src/plugins/defaults/memory/graph/retriever.ts +75 -27
  30. package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +328 -0
  31. package/src/plugins/defaults/memory/graph/tool-handlers.ts +246 -0
  32. package/src/plugins/defaults/memory/indexer.ts +10 -4
  33. package/src/plugins/defaults/memory/job-handlers/embedding.ts +28 -10
  34. package/src/plugins/defaults/memory/job-handlers/index-maintenance.ts +4 -2
  35. package/src/plugins/defaults/memory/job-handlers.ts +5 -0
  36. package/src/plugins/defaults/memory/memory-retrospective-job.ts +80 -17
  37. package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +241 -82
  38. package/src/plugins/defaults/memory/memory-retrospective-state.ts +13 -9
  39. package/src/plugins/defaults/memory/pkb/pkb-index.ts +17 -6
  40. package/src/plugins/defaults/memory/v3/__tests__/live-integration.test.ts +14 -4
  41. package/src/plugins/defaults/memory/v3/__tests__/orchestrate.test.ts +20 -6
  42. package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +2 -0
  43. package/src/providers/model-catalog.ts +81 -0
  44. package/src/runtime/__tests__/background-job-runner.test.ts +43 -1
  45. package/src/runtime/background-job-runner.ts +34 -1
  46. package/src/runtime/routes/__tests__/consolidation-routes.test.ts +7 -0
  47. package/src/schedule/scheduler.ts +54 -18
  48. package/src/telemetry/turn-outcome.ts +57 -1
  49. package/src/tools/skills/skill-script-runner.ts +15 -26
  50. package/scripts/generate-bundled-tool-registry.ts +0 -223
  51. package/src/__tests__/workspace-fixtures.ts +0 -45
  52. package/src/config/__tests__/bundled-tool-registry-guard.test.ts +0 -120
  53. 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.7-dev.202607091842.693dcca",
3
+ "version": "0.10.7-dev.202607091922.eeb94f9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -32,6 +32,7 @@ const MEMORY_JOB_TYPES = [
32
32
  "memory_v2_activation_recompute",
33
33
  "memory_v3_maintain",
34
34
  "memory_retrospective",
35
+ "skill_card_insert",
35
36
  "pkb_filing",
36
37
  "pkb_compaction",
37
38
  ].sort();
@@ -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<void> => {
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<void> = captureProcessedMessage;
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("resolves a workspace_ref tool-result image back to base64", () => {
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
- // The persisted reference is resolved to base64 so the wire contract
285
- // (imageDataList base64) is unchanged for the client.
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
- ) => processMessageImpl(conversationId, message, options),
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
+ });
@@ -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);
@@ -0,0 +1,261 @@
1
+ /**
2
+ * `assistant memory nodes` CLI subgroup.
3
+ *
4
+ * Content-based CRUD over the memory v2 graph nodes. Handlers are invoked
5
+ * directly in-process (no IPC, no daemon dependency) — exactly the same
6
+ * functions the daemon would call, but run here without routing through the
7
+ * main thread:
8
+ *
9
+ * - `list` → handleListMemory
10
+ * - `delete` → handleDeleteMemory
11
+ * - `update` → handleUpdateMemory
12
+ *
13
+ * Unlike `memory items`, which addresses nodes by UUID, these commands address
14
+ * nodes by content text — matching the way an operator or agent naturally
15
+ * refers to a remembered fact without first running a list.
16
+ */
17
+
18
+ import type { Command } from "commander";
19
+
20
+ import { getConfig } from "../../../config/loader.js";
21
+ import {
22
+ handleDeleteMemory,
23
+ handleListMemory,
24
+ handleUpdateMemory,
25
+ } from "../../../plugins/defaults/memory/graph/tool-handlers.js";
26
+ import { registerCommand } from "../../lib/register-command.js";
27
+ import { log } from "../../logger.js";
28
+ import { writeOutput } from "../../output.js";
29
+
30
+ export function registerMemoryNodesCommand(memory: Command): void {
31
+ registerCommand(memory, {
32
+ name: "nodes",
33
+ transport: "local",
34
+ description: "Content-based list, delete, and update of memory graph nodes",
35
+ build: (nodes) => {
36
+ nodes.addHelpText(
37
+ "after",
38
+ `
39
+ Memory nodes are raw graph records (content, type, fidelity) produced by the
40
+ memory v2 subsystem. Unlike 'memory items', which addresses nodes by UUID, these
41
+ commands address nodes by content text — matching the way an operator refers to
42
+ a remembered fact without first looking up its ID.
43
+
44
+ All subcommands require memory v2 to be enabled on the assistant.
45
+
46
+ Examples:
47
+ $ assistant memory nodes list
48
+ $ assistant memory nodes list --search "TypeScript" --limit 20
49
+ $ assistant memory nodes delete "User prefers TypeScript"
50
+ $ assistant memory nodes update "User prefers TypeScript" "User prefers TypeScript and Bun"`,
51
+ );
52
+
53
+ // ── list ──────────────────────────────────────────────────────────────
54
+
55
+ nodes
56
+ .command("list")
57
+ .alias("ls")
58
+ .description("List active memory graph nodes")
59
+ .option(
60
+ "--search <query>",
61
+ "Filter nodes whose content contains <query>",
62
+ )
63
+ .option("--limit <n>", "Max results (default 50, max 200)")
64
+ .option("--json", "Machine-readable compact JSON output")
65
+ .addHelpText(
66
+ "after",
67
+ `
68
+ Behavior:
69
+ Returns active (non-deleted) memory graph nodes ordered by significance.
70
+ With --search, all nodes are scanned so the filter is exhaustive regardless
71
+ of graph size. Without --search the query is capped at --limit rows at the
72
+ DB level for efficiency.
73
+
74
+ Examples:
75
+ $ assistant memory nodes list
76
+ $ assistant memory nodes list --search "coffee" --limit 10
77
+ $ assistant memory nodes list --json`,
78
+ )
79
+ .action(
80
+ (
81
+ opts: { search?: string; limit?: string; json?: boolean },
82
+ cmd: Command,
83
+ ) => {
84
+ const result = handleListMemory(
85
+ {
86
+ search: opts.search,
87
+ limit: opts.limit ? parseInt(opts.limit, 10) : undefined,
88
+ },
89
+ getConfig(),
90
+ );
91
+
92
+ if (!result.success) {
93
+ log.error(result.message);
94
+ process.exitCode = 1;
95
+ return;
96
+ }
97
+
98
+ if (opts.json) {
99
+ writeOutput(cmd, { nodes: result.nodes, total: result.total });
100
+ return;
101
+ }
102
+
103
+ if (result.nodes.length === 0) {
104
+ log.info(
105
+ opts.search
106
+ ? `No memory nodes found matching "${opts.search}".`
107
+ : "No memory nodes found. The memory graph is empty.",
108
+ );
109
+ return;
110
+ }
111
+
112
+ const CONTENT_WIDTH = 60;
113
+ const truncate = (s: string) =>
114
+ s.length > CONTENT_WIDTH
115
+ ? s.slice(0, CONTENT_WIDTH - 1) + "…"
116
+ : s;
117
+
118
+ const typeWidth = Math.max(
119
+ 4,
120
+ ...result.nodes.map((n) => n.type.length),
121
+ );
122
+ const fidelityWidth = Math.max(
123
+ 7,
124
+ ...result.nodes.map((n) => n.fidelity.length),
125
+ );
126
+
127
+ console.log(
128
+ `${"CONTENT".padEnd(CONTENT_WIDTH)} ${"TYPE".padEnd(typeWidth)} ${"FIDELITY".padEnd(fidelityWidth)} CREATED`,
129
+ );
130
+
131
+ for (const n of result.nodes) {
132
+ const created = new Date(n.created).toLocaleString("en-US", {
133
+ month: "short",
134
+ day: "numeric",
135
+ hour: "numeric",
136
+ minute: "2-digit",
137
+ });
138
+ console.log(
139
+ `${truncate(n.content).padEnd(CONTENT_WIDTH)} ${n.type.padEnd(typeWidth)} ${n.fidelity.padEnd(fidelityWidth)} ${created}`,
140
+ );
141
+ }
142
+
143
+ console.log(
144
+ `\n${result.total} node${result.total === 1 ? "" : "s"}${opts.search ? ` matching "${opts.search}"` : ""}`,
145
+ );
146
+ },
147
+ );
148
+
149
+ // ── delete ────────────────────────────────────────────────────────────
150
+
151
+ nodes
152
+ .command("delete <content>")
153
+ .alias("rm")
154
+ .description("Delete a memory node by content match")
155
+ .option("--json", "Machine-readable compact JSON output")
156
+ .addHelpText(
157
+ "after",
158
+ `
159
+ Arguments:
160
+ <content> The text of the memory to delete. Exact match (case-insensitive)
161
+ takes priority; if no exact match exists, a substring match is
162
+ tried. Fails when 0 or more than 1 nodes match — use
163
+ 'assistant memory nodes list --search <query>' to find exact text.
164
+
165
+ Behavior:
166
+ Hard-deletes the graph node and removes it from the recall index. This
167
+ operation is permanent; use 'assistant memory nodes update' to correct
168
+ content instead of deleting it.
169
+
170
+ Examples:
171
+ $ assistant memory nodes delete "User prefers TypeScript"
172
+ $ assistant memory nodes delete "User prefers TypeScript" --json`,
173
+ )
174
+ .action((content: string, opts: { json?: boolean }, cmd: Command) => {
175
+ if (!content.trim()) {
176
+ log.error(
177
+ "content is required. Run 'assistant memory nodes list' to find the exact text.",
178
+ );
179
+ process.exitCode = 1;
180
+ return;
181
+ }
182
+
183
+ const result = handleDeleteMemory({ content }, getConfig());
184
+
185
+ if (!result.success) {
186
+ log.error(result.message);
187
+ process.exitCode = 1;
188
+ return;
189
+ }
190
+
191
+ if (opts.json) {
192
+ writeOutput(cmd, result);
193
+ return;
194
+ }
195
+
196
+ log.info(result.message);
197
+ });
198
+
199
+ // ── update ────────────────────────────────────────────────────────────
200
+
201
+ nodes
202
+ .command("update <old-content> <new-content>")
203
+ .description("Update a memory node's content in place")
204
+ .option("--json", "Machine-readable compact JSON output")
205
+ .addHelpText(
206
+ "after",
207
+ `
208
+ Arguments:
209
+ <old-content> Text of the memory to update. Exact match (case-insensitive)
210
+ takes priority over substring match. Fails when 0 or more than
211
+ 1 nodes match.
212
+ <new-content> Replacement text. Fails if another active node already has
213
+ this content (prevents duplicates).
214
+
215
+ Behavior:
216
+ Replaces the node's content and re-embeds it so recall stays consistent.
217
+ Use this to correct a fact rather than deleting and re-adding it — the edit
218
+ history is preserved on the node.
219
+
220
+ Examples:
221
+ $ assistant memory nodes update "User prefers TypeScript" "User prefers TypeScript and Bun"
222
+ $ assistant memory nodes update "old fact" "corrected fact" --json`,
223
+ )
224
+ .action(
225
+ (
226
+ oldContent: string,
227
+ newContent: string,
228
+ opts: { json?: boolean },
229
+ cmd: Command,
230
+ ) => {
231
+ if (!oldContent.trim() || !newContent.trim()) {
232
+ log.error(
233
+ "Both <old-content> and <new-content> are required. Run 'assistant memory nodes list' to find the exact text.",
234
+ );
235
+ process.exitCode = 1;
236
+ return;
237
+ }
238
+
239
+ const result = handleUpdateMemory(
240
+ { old_content: oldContent, new_content: newContent },
241
+ "cli",
242
+ getConfig(),
243
+ );
244
+
245
+ if (!result.success) {
246
+ log.error(result.message);
247
+ process.exitCode = 1;
248
+ return;
249
+ }
250
+
251
+ if (opts.json) {
252
+ writeOutput(cmd, result);
253
+ return;
254
+ }
255
+
256
+ log.info(result.message);
257
+ },
258
+ );
259
+ },
260
+ });
261
+ }