@vellumai/assistant 0.10.5-dev.202607051933.b756a91 → 0.10.5-dev.202607052127.b26cd90

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/Dockerfile CHANGED
@@ -109,6 +109,7 @@ RUN apt-get update && apt-get install -y \
109
109
  sqlite3 \
110
110
  sudo \
111
111
  util-linux \
112
+ util-linux-extra \
112
113
  unzip \
113
114
  uuid-runtime \
114
115
  vim \
package/openapi.yaml CHANGED
@@ -19651,6 +19651,43 @@ paths:
19651
19651
  - workingsetRefaultFile
19652
19652
  additionalProperties: false
19653
19653
  - type: "null"
19654
+ cpu:
19655
+ anyOf:
19656
+ - type: object
19657
+ properties:
19658
+ usageUsec:
19659
+ anyOf:
19660
+ - type: number
19661
+ - type: "null"
19662
+ userUsec:
19663
+ anyOf:
19664
+ - type: number
19665
+ - type: "null"
19666
+ systemUsec:
19667
+ anyOf:
19668
+ - type: number
19669
+ - type: "null"
19670
+ nrPeriods:
19671
+ anyOf:
19672
+ - type: number
19673
+ - type: "null"
19674
+ nrThrottled:
19675
+ anyOf:
19676
+ - type: number
19677
+ - type: "null"
19678
+ throttledUsec:
19679
+ anyOf:
19680
+ - type: number
19681
+ - type: "null"
19682
+ required:
19683
+ - usageUsec
19684
+ - userUsec
19685
+ - systemUsec
19686
+ - nrPeriods
19687
+ - nrThrottled
19688
+ - throttledUsec
19689
+ additionalProperties: false
19690
+ - type: "null"
19654
19691
  events:
19655
19692
  anyOf:
19656
19693
  - type: object
@@ -19731,9 +19768,47 @@ paths:
19731
19768
  - workingsetRefaultFile
19732
19769
  additionalProperties: false
19733
19770
  - type: "null"
19771
+ cpu:
19772
+ anyOf:
19773
+ - type: object
19774
+ properties:
19775
+ usageUsec:
19776
+ anyOf:
19777
+ - type: number
19778
+ - type: "null"
19779
+ userUsec:
19780
+ anyOf:
19781
+ - type: number
19782
+ - type: "null"
19783
+ systemUsec:
19784
+ anyOf:
19785
+ - type: number
19786
+ - type: "null"
19787
+ nrPeriods:
19788
+ anyOf:
19789
+ - type: number
19790
+ - type: "null"
19791
+ nrThrottled:
19792
+ anyOf:
19793
+ - type: number
19794
+ - type: "null"
19795
+ throttledUsec:
19796
+ anyOf:
19797
+ - type: number
19798
+ - type: "null"
19799
+ required:
19800
+ - usageUsec
19801
+ - userUsec
19802
+ - systemUsec
19803
+ - nrPeriods
19804
+ - nrThrottled
19805
+ - throttledUsec
19806
+ additionalProperties: false
19807
+ - type: "null"
19734
19808
  required:
19735
19809
  - events
19736
19810
  - reclaim
19811
+ - cpu
19737
19812
  additionalProperties: false
19738
19813
  - type: "null"
19739
19814
  disk:
@@ -19760,6 +19835,7 @@ paths:
19760
19835
  - memory
19761
19836
  - memoryStat
19762
19837
  - reclaim
19838
+ - cpu
19763
19839
  - events
19764
19840
  - deltas
19765
19841
  - disk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.5-dev.202607051933.b756a91",
3
+ "version": "0.10.5-dev.202607052127.b26cd90",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,28 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { getAllDefaultPlugins } from "../plugins/defaults/index.js";
4
+ import { getAllDefaultPluginNames } from "../plugins/defaults/main.js";
5
+
6
+ /**
7
+ * Guard: the filesystem-backed default-plugin registry (`defaults/main.ts`)
8
+ * and the import-backed barrel (`defaults/index.ts`) must agree on the
9
+ * plugin set. `main.ts` is the barrel's eventual replacement; while both
10
+ * exist, a plugin added to one but not the other would silently diverge the
11
+ * consumers (e.g. per-chat plugin scoping reads names from `main.ts`, while
12
+ * bootstrap registers plugins from the barrel).
13
+ */
14
+ describe("default plugin names", () => {
15
+ test("the filesystem registry matches the barrel's manifests exactly", () => {
16
+ const fromFs = [...getAllDefaultPluginNames()].sort();
17
+ const fromBarrel = getAllDefaultPlugins()
18
+ .map((p) => p.manifest.name)
19
+ .sort();
20
+ expect(fromFs).toEqual(fromBarrel);
21
+ });
22
+
23
+ test("every name uses the default- prefix convention", () => {
24
+ for (const name of getAllDefaultPluginNames()) {
25
+ expect(name).toMatch(/^default-[a-z0-9-]+$/);
26
+ }
27
+ });
28
+ });
@@ -0,0 +1,445 @@
1
+ /**
2
+ * Tests for the `assistant memory items` CLI subgroup (item CRUD).
3
+ *
4
+ * Validates:
5
+ * - Verb registration (list/get/create/update/delete) under `memory items`.
6
+ * - Each verb maps to the right `cliIpcCall` method with the right
7
+ * pathParams/queryParams/body shape.
8
+ * - Local validation (missing update flags, invalid --importance, blank ID)
9
+ * fails before any IPC call.
10
+ * - `delete` refuses to run non-interactively without --force.
11
+ * - IPC error paths return a non-zero exit code without throwing.
12
+ */
13
+
14
+ import { beforeEach, describe, expect, mock, test } from "bun:test";
15
+
16
+ import { Command } from "commander";
17
+
18
+ // ---------------------------------------------------------------------------
19
+ // Mock state
20
+ // ---------------------------------------------------------------------------
21
+
22
+ /** The last `cliIpcCall` invocation captured for assertions. */
23
+ let lastIpcCall: {
24
+ method: string;
25
+
26
+ params?: any;
27
+ } | null = null;
28
+
29
+ /** The result that cliIpcCall will return. */
30
+ let mockIpcResult: {
31
+ ok: boolean;
32
+ result?: unknown;
33
+ error?: string;
34
+ statusCode?: number;
35
+ } = { ok: true, result: {} };
36
+
37
+ /** Captured log output for assertion. */
38
+ let logOutput: string[] = [];
39
+
40
+ // ---------------------------------------------------------------------------
41
+ // Mocks
42
+ // ---------------------------------------------------------------------------
43
+
44
+ mock.module("../../../../ipc/cli-client.js", () => ({
45
+ cliIpcCall: async (method: string, params?: unknown) => {
46
+ lastIpcCall = { method, params };
47
+ return mockIpcResult;
48
+ },
49
+ exitFromIpcResult: (r: { error?: string; statusCode?: number }) => {
50
+ process.exitCode =
51
+ r.statusCode === undefined
52
+ ? 10
53
+ : r.statusCode >= 500
54
+ ? 3
55
+ : r.statusCode >= 400
56
+ ? 2
57
+ : 1;
58
+ throw new Error(r.error ?? "Unknown error");
59
+ },
60
+ }));
61
+
62
+ const capture = (...args: unknown[]) => {
63
+ logOutput.push(args.map(String).join(" "));
64
+ };
65
+ const fakeLogger = {
66
+ info: capture,
67
+ warn: capture,
68
+ error: capture,
69
+ debug: () => {},
70
+ };
71
+ mock.module("../../../logger.js", () => ({
72
+ log: fakeLogger,
73
+ getCliLogger: () => fakeLogger,
74
+ }));
75
+
76
+ // ---------------------------------------------------------------------------
77
+ // Import module under test (after mocks)
78
+ // ---------------------------------------------------------------------------
79
+
80
+ const { registerMemoryItemsCommand } = await import("../items.js");
81
+
82
+ // ---------------------------------------------------------------------------
83
+ // Test helpers
84
+ // ---------------------------------------------------------------------------
85
+
86
+ function buildProgram(): Command {
87
+ const program = new Command();
88
+ program.exitOverride();
89
+ program.configureOutput({
90
+ writeErr: () => {},
91
+ writeOut: () => {},
92
+ });
93
+ const memory = program.command("memory");
94
+ registerMemoryItemsCommand(memory);
95
+ return program;
96
+ }
97
+
98
+ async function runCommand(
99
+ args: string[],
100
+ ): Promise<{ stdout: string; exitCode: number }> {
101
+ const originalStdoutWrite = process.stdout.write.bind(process.stdout);
102
+ const originalStderrWrite = process.stderr.write.bind(process.stderr);
103
+ const stdoutChunks: string[] = [];
104
+
105
+ process.stdout.write = ((chunk: unknown) => {
106
+ stdoutChunks.push(typeof chunk === "string" ? chunk : String(chunk));
107
+ return true;
108
+ }) as typeof process.stdout.write;
109
+
110
+ process.stderr.write = (() => true) as typeof process.stderr.write;
111
+
112
+ process.exitCode = 0;
113
+
114
+ try {
115
+ const program = buildProgram();
116
+ await program.parseAsync(["node", "assistant", ...args]);
117
+ } catch {
118
+ if (process.exitCode === 0) {
119
+ process.exitCode = 1;
120
+ }
121
+ } finally {
122
+ process.stdout.write = originalStdoutWrite;
123
+ process.stderr.write = originalStderrWrite;
124
+ }
125
+
126
+ const exitCode = process.exitCode ?? 0;
127
+ process.exitCode = 0;
128
+
129
+ return { exitCode, stdout: stdoutChunks.join("") };
130
+ }
131
+
132
+ const ITEM = {
133
+ id: "9f2c4f3a-3f1a-41e4-88e7-abc123def456",
134
+ kind: "semantic",
135
+ subject: "Coffee preference",
136
+ statement: "Prefers oat-milk lattes",
137
+ status: "active",
138
+ confidence: 0.95,
139
+ importance: 0.8,
140
+ firstSeenAt: 1_700_000_000_000,
141
+ lastSeenAt: 1_700_000_000_000,
142
+ };
143
+
144
+ // ---------------------------------------------------------------------------
145
+ // Setup
146
+ // ---------------------------------------------------------------------------
147
+
148
+ beforeEach(() => {
149
+ lastIpcCall = null;
150
+ mockIpcResult = { ok: true, result: { item: ITEM } };
151
+ logOutput = [];
152
+ process.exitCode = 0;
153
+ });
154
+
155
+ // ---------------------------------------------------------------------------
156
+ // Registration
157
+ // ---------------------------------------------------------------------------
158
+
159
+ describe("verb registration", () => {
160
+ test("registers items under memory with the CRUD verbs", () => {
161
+ const program = buildProgram();
162
+ const memory = program.commands.find((c) => c.name() === "memory");
163
+ expect(memory).toBeDefined();
164
+ const items = memory!.commands.find((c) => c.name() === "items");
165
+ expect(items).toBeDefined();
166
+ const names = items!.commands.map((c) => c.name());
167
+ for (const verb of ["list", "get", "create", "update", "delete"]) {
168
+ expect(names).toContain(verb);
169
+ }
170
+ });
171
+ });
172
+
173
+ // ---------------------------------------------------------------------------
174
+ // list
175
+ // ---------------------------------------------------------------------------
176
+
177
+ describe("memory items list", () => {
178
+ test("calls listMemoryItems with only the provided filters", async () => {
179
+ mockIpcResult = {
180
+ ok: true,
181
+ result: { items: [ITEM], total: 1, kindCounts: { semantic: 1 } },
182
+ };
183
+ const { exitCode } = await runCommand([
184
+ "memory",
185
+ "items",
186
+ "list",
187
+ "--kind",
188
+ "semantic",
189
+ "--limit",
190
+ "20",
191
+ ]);
192
+ expect(exitCode).toBe(0);
193
+ expect(lastIpcCall?.method).toBe("listMemoryItems");
194
+ expect(lastIpcCall?.params).toEqual({
195
+ queryParams: { kind: "semantic", limit: "20" },
196
+ });
197
+ });
198
+
199
+ test("--json emits the raw response", async () => {
200
+ mockIpcResult = {
201
+ ok: true,
202
+ result: { items: [ITEM], total: 1, kindCounts: { semantic: 1 } },
203
+ };
204
+ const { exitCode, stdout } = await runCommand([
205
+ "memory",
206
+ "items",
207
+ "list",
208
+ "--json",
209
+ ]);
210
+ expect(exitCode).toBe(0);
211
+ const parsed = JSON.parse(stdout);
212
+ expect(parsed.total).toBe(1);
213
+ expect(parsed.items[0].id).toBe(ITEM.id);
214
+ });
215
+
216
+ test("IPC failure exits non-zero", async () => {
217
+ mockIpcResult = { ok: false, error: "boom", statusCode: 500 };
218
+ const { exitCode } = await runCommand(["memory", "items", "list"]);
219
+ expect(exitCode).toBe(3);
220
+ });
221
+ });
222
+
223
+ // ---------------------------------------------------------------------------
224
+ // get
225
+ // ---------------------------------------------------------------------------
226
+
227
+ describe("memory items get", () => {
228
+ test("calls getMemoryItem with pathParams.id", async () => {
229
+ const { exitCode } = await runCommand(["memory", "items", "get", ITEM.id]);
230
+ expect(exitCode).toBe(0);
231
+ expect(lastIpcCall?.method).toBe("getMemoryItem");
232
+ expect(lastIpcCall?.params).toEqual({ pathParams: { id: ITEM.id } });
233
+ });
234
+
235
+ test("blank ID fails without an IPC call", async () => {
236
+ const { exitCode } = await runCommand(["memory", "items", "get", " "]);
237
+ expect(exitCode).toBe(1);
238
+ expect(lastIpcCall).toBeNull();
239
+ });
240
+
241
+ test("not-found error exits with 4xx code", async () => {
242
+ mockIpcResult = {
243
+ ok: false,
244
+ error: "Memory item not found",
245
+ statusCode: 404,
246
+ };
247
+ const { exitCode } = await runCommand(["memory", "items", "get", ITEM.id]);
248
+ expect(exitCode).toBe(2);
249
+ });
250
+ });
251
+
252
+ // ---------------------------------------------------------------------------
253
+ // create
254
+ // ---------------------------------------------------------------------------
255
+
256
+ describe("memory items create", () => {
257
+ test("calls createMemoryItem with the assembled body", async () => {
258
+ const { exitCode } = await runCommand([
259
+ "memory",
260
+ "items",
261
+ "create",
262
+ "--kind",
263
+ "semantic",
264
+ "--statement",
265
+ "Prefers oat-milk lattes",
266
+ "--subject",
267
+ "Coffee preference",
268
+ "--importance",
269
+ "0.9",
270
+ ]);
271
+ expect(exitCode).toBe(0);
272
+ expect(lastIpcCall?.method).toBe("createMemoryItem");
273
+ expect(lastIpcCall?.params).toEqual({
274
+ body: {
275
+ kind: "semantic",
276
+ statement: "Prefers oat-milk lattes",
277
+ subject: "Coffee preference",
278
+ importance: 0.9,
279
+ },
280
+ });
281
+ expect(logOutput.join("\n")).toContain(ITEM.id);
282
+ });
283
+
284
+ test("rejects out-of-range --importance before IPC", async () => {
285
+ const { exitCode } = await runCommand([
286
+ "memory",
287
+ "items",
288
+ "create",
289
+ "--kind",
290
+ "semantic",
291
+ "--statement",
292
+ "x",
293
+ "--importance",
294
+ "3",
295
+ ]);
296
+ expect(exitCode).toBe(1);
297
+ expect(lastIpcCall).toBeNull();
298
+ });
299
+
300
+ test("missing required --statement fails parse", async () => {
301
+ const { exitCode } = await runCommand([
302
+ "memory",
303
+ "items",
304
+ "create",
305
+ "--kind",
306
+ "semantic",
307
+ ]);
308
+ expect(exitCode).toBe(1);
309
+ expect(lastIpcCall).toBeNull();
310
+ });
311
+ });
312
+
313
+ // ---------------------------------------------------------------------------
314
+ // update
315
+ // ---------------------------------------------------------------------------
316
+
317
+ describe("memory items update", () => {
318
+ test("calls updateMemoryItem with pathParams and partial body", async () => {
319
+ const { exitCode } = await runCommand([
320
+ "memory",
321
+ "items",
322
+ "update",
323
+ ITEM.id,
324
+ "--statement",
325
+ "Prefers tea",
326
+ "--importance",
327
+ "0.5",
328
+ ]);
329
+ expect(exitCode).toBe(0);
330
+ expect(lastIpcCall?.method).toBe("updateMemoryItem");
331
+ expect(lastIpcCall?.params).toEqual({
332
+ pathParams: { id: ITEM.id },
333
+ body: { statement: "Prefers tea", importance: 0.5 },
334
+ });
335
+ });
336
+
337
+ test("requires at least one update flag", async () => {
338
+ const { exitCode } = await runCommand([
339
+ "memory",
340
+ "items",
341
+ "update",
342
+ ITEM.id,
343
+ ]);
344
+ expect(exitCode).toBe(1);
345
+ expect(lastIpcCall).toBeNull();
346
+ expect(logOutput.join("\n")).toContain("At least one update flag");
347
+ });
348
+
349
+ test("--status active is forwarded (restore path)", async () => {
350
+ const { exitCode } = await runCommand([
351
+ "memory",
352
+ "items",
353
+ "update",
354
+ ITEM.id,
355
+ "--status",
356
+ "active",
357
+ ]);
358
+ expect(exitCode).toBe(0);
359
+ expect(lastIpcCall?.params).toEqual({
360
+ pathParams: { id: ITEM.id },
361
+ body: { status: "active" },
362
+ });
363
+ });
364
+
365
+ test("conflict error exits with 4xx code", async () => {
366
+ mockIpcResult = {
367
+ ok: false,
368
+ error: "Another memory item with this content already exists",
369
+ statusCode: 409,
370
+ };
371
+ const { exitCode } = await runCommand([
372
+ "memory",
373
+ "items",
374
+ "update",
375
+ ITEM.id,
376
+ "--statement",
377
+ "dupe",
378
+ ]);
379
+ expect(exitCode).toBe(2);
380
+ });
381
+ });
382
+
383
+ // ---------------------------------------------------------------------------
384
+ // delete
385
+ // ---------------------------------------------------------------------------
386
+
387
+ describe("memory items delete", () => {
388
+ test("--force calls deleteMemoryItem without prompting", async () => {
389
+ mockIpcResult = { ok: true, result: null };
390
+ const { exitCode } = await runCommand([
391
+ "memory",
392
+ "items",
393
+ "delete",
394
+ ITEM.id,
395
+ "--force",
396
+ ]);
397
+ expect(exitCode).toBe(0);
398
+ expect(lastIpcCall?.method).toBe("deleteMemoryItem");
399
+ expect(lastIpcCall?.params).toEqual({ pathParams: { id: ITEM.id } });
400
+ expect(logOutput.join("\n")).toContain(`Deleted memory item: ${ITEM.id}`);
401
+ });
402
+
403
+ test("refuses non-interactive delete without --force", async () => {
404
+ // Tests run with stdin not a TTY, so the confirm prompt refuses.
405
+ mockIpcResult = { ok: true, result: null };
406
+ const { exitCode } = await runCommand([
407
+ "memory",
408
+ "items",
409
+ "delete",
410
+ ITEM.id,
411
+ ]);
412
+ expect(exitCode).toBe(1);
413
+ expect(lastIpcCall).toBeNull();
414
+ });
415
+
416
+ test("--force --json emits a deletion envelope", async () => {
417
+ mockIpcResult = { ok: true, result: null };
418
+ const { exitCode, stdout } = await runCommand([
419
+ "memory",
420
+ "items",
421
+ "delete",
422
+ ITEM.id,
423
+ "--force",
424
+ "--json",
425
+ ]);
426
+ expect(exitCode).toBe(0);
427
+ expect(JSON.parse(stdout)).toEqual({ deleted: true, id: ITEM.id });
428
+ });
429
+
430
+ test("IPC failure exits non-zero", async () => {
431
+ mockIpcResult = {
432
+ ok: false,
433
+ error: "Memory item not found",
434
+ statusCode: 404,
435
+ };
436
+ const { exitCode } = await runCommand([
437
+ "memory",
438
+ "items",
439
+ "delete",
440
+ ITEM.id,
441
+ "--force",
442
+ ]);
443
+ expect(exitCode).toBe(2);
444
+ });
445
+ });
@@ -1,6 +1,7 @@
1
1
  import type { Command } from "commander";
2
2
 
3
3
  import { registerCommand } from "../../lib/register-command.js";
4
+ import { registerMemoryItemsCommand } from "./items.js";
4
5
  import { registerMemoryRetrospectiveCommand } from "./memory-retrospective.js";
5
6
  import { registerMemoryV2Command } from "./memory-v2.js";
6
7
  import { registerMemoryV3Command } from "./memory-v3.js";
@@ -10,21 +11,29 @@ export function registerMemoryCommand(program: Command): void {
10
11
  registerCommand(program, {
11
12
  name: "memory",
12
13
  transport: "ipc",
13
- description: "Inspect and maintain the assistant memory subsystem",
14
+ description:
15
+ "Manage memory items and maintain the assistant memory subsystem",
14
16
  build: (memory) => {
15
17
  memory.addHelpText(
16
18
  "after",
17
19
  `
20
+ The 'items' subgroup exposes full CRUD over individual memory items
21
+ (remembered facts) — list, get, create, update, delete.
22
+
18
23
  The memory subsystem retrieves concept pages two ways: the v2 concept-page
19
24
  activation model (prose pages with directed edges) and the v3 section-lane
20
25
  model (section-grain lanes cached as live shadow state). Each subgroup exposes
21
26
  operator-facing maintenance verbs — reindexing, backfills, validation, and evals.
22
27
 
23
28
  Examples:
29
+ $ assistant memory items list --search "coffee"
30
+ $ assistant memory items update 9f2c4f3a-3f1a-41e4-88e7-abc123 --statement "Prefers tea"
31
+ $ assistant memory items delete 9f2c4f3a-3f1a-41e4-88e7-abc123
24
32
  $ assistant memory v2 validate
25
33
  $ assistant memory v3 rebuild-index`,
26
34
  );
27
35
 
36
+ registerMemoryItemsCommand(memory);
28
37
  registerMemoryV2Command(memory);
29
38
  registerMemoryV3Command(memory);
30
39
  registerMemoryRetrospectiveCommand(memory);