@vellumai/assistant 0.5.5 → 0.5.6

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 (102) hide show
  1. package/Dockerfile +3 -4
  2. package/package.json +1 -1
  3. package/src/__tests__/actor-token-service.test.ts +113 -0
  4. package/src/__tests__/config-schema.test.ts +2 -2
  5. package/src/__tests__/context-window-manager.test.ts +78 -0
  6. package/src/__tests__/conversation-title-service.test.ts +30 -1
  7. package/src/__tests__/docker-signing-key-bootstrap.test.ts +207 -0
  8. package/src/__tests__/memory-regressions.test.ts +8 -30
  9. package/src/__tests__/require-fresh-approval.test.ts +4 -0
  10. package/src/__tests__/tool-executor-lifecycle-events.test.ts +4 -0
  11. package/src/__tests__/tool-executor.test.ts +4 -0
  12. package/src/cli/commands/conversations.ts +0 -18
  13. package/src/config/env.ts +8 -2
  14. package/src/config/feature-flag-registry.json +0 -8
  15. package/src/config/schema.ts +0 -12
  16. package/src/config/schemas/memory.ts +0 -4
  17. package/src/config/schemas/platform.ts +1 -1
  18. package/src/config/schemas/security.ts +4 -0
  19. package/src/context/window-manager.ts +53 -2
  20. package/src/daemon/config-watcher.ts +1 -4
  21. package/src/daemon/conversation-agent-loop.ts +0 -60
  22. package/src/daemon/conversation-memory.ts +0 -117
  23. package/src/daemon/conversation-runtime-assembly.ts +0 -2
  24. package/src/daemon/handlers/conversations.ts +0 -11
  25. package/src/daemon/lifecycle.ts +3 -46
  26. package/src/followups/followup-store.ts +5 -2
  27. package/src/memory/conversation-crud.ts +0 -236
  28. package/src/memory/conversation-title-service.ts +26 -10
  29. package/src/memory/db-init.ts +5 -13
  30. package/src/memory/indexer.ts +15 -106
  31. package/src/memory/job-handlers/embedding.ts +0 -79
  32. package/src/memory/job-utils.ts +1 -1
  33. package/src/memory/jobs-store.ts +0 -8
  34. package/src/memory/jobs-worker.ts +0 -20
  35. package/src/memory/migrations/189-drop-simplified-memory.ts +42 -0
  36. package/src/memory/migrations/index.ts +1 -3
  37. package/src/memory/qdrant-client.ts +4 -6
  38. package/src/memory/schema/conversations.ts +0 -3
  39. package/src/memory/schema/index.ts +0 -2
  40. package/src/messaging/draft-store.ts +2 -2
  41. package/src/permissions/defaults.ts +3 -3
  42. package/src/permissions/trust-client.ts +2 -13
  43. package/src/permissions/trust-store.ts +8 -3
  44. package/src/runtime/auth/route-policy.ts +14 -0
  45. package/src/runtime/auth/token-service.ts +133 -0
  46. package/src/runtime/http-server.ts +2 -0
  47. package/src/runtime/routes/conversation-management-routes.ts +0 -36
  48. package/src/runtime/routes/conversation-query-routes.ts +44 -2
  49. package/src/runtime/routes/conversation-routes.ts +2 -1
  50. package/src/runtime/routes/memory-item-routes.test.ts +221 -3
  51. package/src/runtime/routes/memory-item-routes.ts +124 -2
  52. package/src/runtime/routes/upgrade-broadcast-routes.ts +151 -0
  53. package/src/schedule/schedule-store.ts +0 -21
  54. package/src/skills/inline-command-render.ts +5 -1
  55. package/src/skills/inline-command-runner.ts +30 -2
  56. package/src/tools/memory/handlers.ts +1 -129
  57. package/src/tools/permission-checker.ts +18 -0
  58. package/src/tools/skills/load.ts +9 -2
  59. package/src/util/platform.ts +5 -5
  60. package/src/util/xml.ts +8 -0
  61. package/src/workspace/heartbeat-service.ts +5 -24
  62. package/src/__tests__/archive-recall.test.ts +0 -560
  63. package/src/__tests__/conversation-memory-dirty-tail.test.ts +0 -150
  64. package/src/__tests__/conversation-switch-memory-reduction.test.ts +0 -474
  65. package/src/__tests__/db-memory-archive-migration.test.ts +0 -372
  66. package/src/__tests__/db-memory-brief-state-migration.test.ts +0 -213
  67. package/src/__tests__/db-memory-reducer-checkpoints.test.ts +0 -273
  68. package/src/__tests__/memory-brief-open-loops.test.ts +0 -530
  69. package/src/__tests__/memory-brief-time.test.ts +0 -285
  70. package/src/__tests__/memory-brief-wrapper.test.ts +0 -311
  71. package/src/__tests__/memory-chunk-archive.test.ts +0 -400
  72. package/src/__tests__/memory-chunk-dual-write.test.ts +0 -453
  73. package/src/__tests__/memory-episode-archive.test.ts +0 -370
  74. package/src/__tests__/memory-episode-dual-write.test.ts +0 -626
  75. package/src/__tests__/memory-observation-archive.test.ts +0 -375
  76. package/src/__tests__/memory-observation-dual-write.test.ts +0 -318
  77. package/src/__tests__/memory-reducer-job.test.ts +0 -538
  78. package/src/__tests__/memory-reducer-scheduling.test.ts +0 -473
  79. package/src/__tests__/memory-reducer-store.test.ts +0 -728
  80. package/src/__tests__/memory-reducer-types.test.ts +0 -707
  81. package/src/__tests__/memory-reducer.test.ts +0 -704
  82. package/src/__tests__/memory-simplified-config.test.ts +0 -281
  83. package/src/__tests__/simplified-memory-e2e.test.ts +0 -666
  84. package/src/__tests__/simplified-memory-runtime.test.ts +0 -616
  85. package/src/config/schemas/memory-simplified.ts +0 -101
  86. package/src/memory/archive-recall.ts +0 -516
  87. package/src/memory/archive-store.ts +0 -400
  88. package/src/memory/brief-formatting.ts +0 -33
  89. package/src/memory/brief-open-loops.ts +0 -266
  90. package/src/memory/brief-time.ts +0 -162
  91. package/src/memory/brief.ts +0 -75
  92. package/src/memory/job-handlers/backfill-simplified-memory.ts +0 -462
  93. package/src/memory/job-handlers/reduce-conversation-memory.ts +0 -229
  94. package/src/memory/migrations/185-memory-brief-state.ts +0 -52
  95. package/src/memory/migrations/186-memory-archive.ts +0 -109
  96. package/src/memory/migrations/187-memory-reducer-checkpoints.ts +0 -19
  97. package/src/memory/reducer-scheduler.ts +0 -242
  98. package/src/memory/reducer-store.ts +0 -271
  99. package/src/memory/reducer-types.ts +0 -106
  100. package/src/memory/reducer.ts +0 -467
  101. package/src/memory/schema/memory-archive.ts +0 -121
  102. package/src/memory/schema/memory-brief.ts +0 -55
@@ -1,273 +0,0 @@
1
- import { mkdtempSync, rmSync } from "node:fs";
2
- import { tmpdir } from "node:os";
3
- import { join } from "node:path";
4
- import { Database } from "bun:sqlite";
5
- import {
6
- afterAll,
7
- afterEach,
8
- beforeEach,
9
- describe,
10
- expect,
11
- mock,
12
- test,
13
- } from "bun:test";
14
-
15
- import { drizzle } from "drizzle-orm/bun-sqlite";
16
-
17
- const testDir = mkdtempSync(join(tmpdir(), "memory-reducer-checkpoints-"));
18
- const dbPath = join(testDir, "test.db");
19
- const originalBunTest = process.env.BUN_TEST;
20
-
21
- mock.module("../util/platform.js", () => ({
22
- getDataDir: () => testDir,
23
- isMacOS: () => process.platform === "darwin",
24
- isLinux: () => process.platform === "linux",
25
- isWindows: () => process.platform === "win32",
26
- getPidPath: () => join(testDir, "test.pid"),
27
- getDbPath: () => dbPath,
28
- getLogPath: () => join(testDir, "test.log"),
29
- ensureDataDir: () => {},
30
- getConversationsDir: () => join(testDir, "conversations"),
31
- }));
32
-
33
- mock.module("../util/logger.js", () => ({
34
- getLogger: () =>
35
- new Proxy({} as Record<string, unknown>, {
36
- get: () => () => {},
37
- }),
38
- }));
39
-
40
- import { initializeDb, resetDb } from "../memory/db.js";
41
- import { getSqliteFrom } from "../memory/db-connection.js";
42
- import { migrateMemoryReducerCheckpoints } from "../memory/migrations/187-memory-reducer-checkpoints.js";
43
- import * as schema from "../memory/schema.js";
44
-
45
- function createTestDb() {
46
- const sqlite = new Database(":memory:");
47
- sqlite.exec("PRAGMA journal_mode=WAL");
48
- sqlite.exec("PRAGMA foreign_keys = ON");
49
- return drizzle(sqlite, { schema });
50
- }
51
-
52
- function getColumnInfo(
53
- raw: Database,
54
- ): Array<{ name: string; notnull: number }> {
55
- return raw.query(`PRAGMA table_info(conversations)`).all() as Array<{
56
- name: string;
57
- notnull: number;
58
- }>;
59
- }
60
-
61
- function bootstrapPreCheckpointConversations(raw: Database): void {
62
- raw.exec(/*sql*/ `
63
- CREATE TABLE conversations (
64
- id TEXT PRIMARY KEY,
65
- title TEXT,
66
- created_at INTEGER NOT NULL,
67
- updated_at INTEGER NOT NULL,
68
- total_input_tokens INTEGER NOT NULL DEFAULT 0,
69
- total_output_tokens INTEGER NOT NULL DEFAULT 0,
70
- total_estimated_cost REAL NOT NULL DEFAULT 0,
71
- context_summary TEXT,
72
- context_compacted_message_count INTEGER NOT NULL DEFAULT 0,
73
- context_compacted_at INTEGER,
74
- conversation_type TEXT NOT NULL DEFAULT 'standard',
75
- source TEXT NOT NULL DEFAULT 'user',
76
- memory_scope_id TEXT NOT NULL DEFAULT 'default',
77
- origin_channel TEXT,
78
- origin_interface TEXT,
79
- fork_parent_conversation_id TEXT,
80
- fork_parent_message_id TEXT,
81
- is_auto_title INTEGER NOT NULL DEFAULT 1,
82
- schedule_job_id TEXT
83
- )
84
- `);
85
- }
86
-
87
- function removeTestDbFiles(): void {
88
- rmSync(dbPath, { force: true });
89
- rmSync(`${dbPath}-shm`, { force: true });
90
- rmSync(`${dbPath}-wal`, { force: true });
91
- }
92
-
93
- describe("memory reducer checkpoint columns migration", () => {
94
- beforeEach(() => {
95
- process.env.BUN_TEST = "0";
96
- resetDb();
97
- removeTestDbFiles();
98
- });
99
-
100
- afterEach(() => {
101
- resetDb();
102
- removeTestDbFiles();
103
- });
104
-
105
- afterAll(() => {
106
- if (originalBunTest === undefined) {
107
- delete process.env.BUN_TEST;
108
- } else {
109
- process.env.BUN_TEST = originalBunTest;
110
- }
111
- resetDb();
112
- removeTestDbFiles();
113
- try {
114
- rmSync(testDir, { recursive: true });
115
- } catch {
116
- /* best effort */
117
- }
118
- });
119
-
120
- test("fresh DB initialization includes nullable reducer checkpoint columns", () => {
121
- initializeDb();
122
-
123
- const raw = new Database(dbPath);
124
- const columns = getColumnInfo(raw);
125
-
126
- const checkpointColumns = columns.filter(
127
- (c) =>
128
- c.name === "memory_reduced_through_message_id" ||
129
- c.name === "memory_dirty_tail_since_message_id" ||
130
- c.name === "memory_last_reduced_at",
131
- );
132
-
133
- expect(checkpointColumns).toHaveLength(3);
134
- expect(checkpointColumns.every((c) => c.notnull === 0)).toBe(true);
135
-
136
- raw.close();
137
- });
138
-
139
- test("migration upgrades the pre-checkpoint schema without disturbing existing rows", () => {
140
- const db = createTestDb();
141
- const raw = getSqliteFrom(db);
142
- const now = Date.now();
143
-
144
- bootstrapPreCheckpointConversations(raw);
145
- raw.exec(/*sql*/ `
146
- INSERT INTO conversations (
147
- id,
148
- title,
149
- created_at,
150
- updated_at,
151
- conversation_type,
152
- source,
153
- memory_scope_id,
154
- is_auto_title
155
- ) VALUES (
156
- 'conv-upgrade',
157
- 'Existing conversation',
158
- ${now},
159
- ${now},
160
- 'standard',
161
- 'user',
162
- 'default',
163
- 1
164
- )
165
- `);
166
-
167
- migrateMemoryReducerCheckpoints(db);
168
-
169
- const columnNames = getColumnInfo(raw).map((c) => c.name);
170
- expect(columnNames).toContain("memory_reduced_through_message_id");
171
- expect(columnNames).toContain("memory_dirty_tail_since_message_id");
172
- expect(columnNames).toContain("memory_last_reduced_at");
173
-
174
- const row = raw
175
- .query(
176
- `SELECT id, title, memory_reduced_through_message_id, memory_dirty_tail_since_message_id, memory_last_reduced_at
177
- FROM conversations WHERE id = 'conv-upgrade'`,
178
- )
179
- .get() as {
180
- id: string;
181
- title: string | null;
182
- memory_reduced_through_message_id: string | null;
183
- memory_dirty_tail_since_message_id: string | null;
184
- memory_last_reduced_at: number | null;
185
- } | null;
186
-
187
- expect(row).toEqual({
188
- id: "conv-upgrade",
189
- title: "Existing conversation",
190
- memory_reduced_through_message_id: null,
191
- memory_dirty_tail_since_message_id: null,
192
- memory_last_reduced_at: null,
193
- });
194
-
195
- raw.close();
196
- });
197
-
198
- test("re-running the migration preserves populated checkpoint values", () => {
199
- const db = createTestDb();
200
- const raw = getSqliteFrom(db);
201
- const now = Date.now();
202
-
203
- bootstrapPreCheckpointConversations(raw);
204
- raw.exec(/*sql*/ `
205
- INSERT INTO conversations (
206
- id,
207
- title,
208
- created_at,
209
- updated_at,
210
- conversation_type,
211
- source,
212
- memory_scope_id,
213
- is_auto_title
214
- ) VALUES (
215
- 'conv-rerun',
216
- 'Reduced conversation',
217
- ${now},
218
- ${now},
219
- 'standard',
220
- 'user',
221
- 'default',
222
- 1
223
- )
224
- `);
225
-
226
- migrateMemoryReducerCheckpoints(db);
227
- raw.exec(/*sql*/ `
228
- UPDATE conversations
229
- SET memory_reduced_through_message_id = 'msg-100',
230
- memory_dirty_tail_since_message_id = 'msg-101',
231
- memory_last_reduced_at = ${now}
232
- WHERE id = 'conv-rerun'
233
- `);
234
-
235
- expect(() => migrateMemoryReducerCheckpoints(db)).not.toThrow();
236
-
237
- const row = raw
238
- .query(
239
- `SELECT memory_reduced_through_message_id, memory_dirty_tail_since_message_id, memory_last_reduced_at
240
- FROM conversations WHERE id = 'conv-rerun'`,
241
- )
242
- .get() as {
243
- memory_reduced_through_message_id: string | null;
244
- memory_dirty_tail_since_message_id: string | null;
245
- memory_last_reduced_at: number | null;
246
- } | null;
247
-
248
- expect(row).toEqual({
249
- memory_reduced_through_message_id: "msg-100",
250
- memory_dirty_tail_since_message_id: "msg-101",
251
- memory_last_reduced_at: now,
252
- });
253
-
254
- raw.close();
255
- });
256
-
257
- test("getConversation exposes the new checkpoint fields as null for new rows", async () => {
258
- initializeDb();
259
-
260
- // Dynamic import to avoid circular module init issues — conversation-crud
261
- // depends on getDb being initialized which happens in initializeDb above.
262
- const { createConversation, getConversation } =
263
- await import("../memory/conversation-crud.js");
264
-
265
- const created = createConversation("Test conversation");
266
- const loaded = getConversation(created.id);
267
-
268
- expect(loaded).not.toBeNull();
269
- expect(loaded!.memoryReducedThroughMessageId).toBeNull();
270
- expect(loaded!.memoryDirtyTailSinceMessageId).toBeNull();
271
- expect(loaded!.memoryLastReducedAt).toBeNull();
272
- });
273
- });