@vellumai/assistant 0.5.4 → 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 (151) hide show
  1. package/Dockerfile +17 -27
  2. package/node_modules/@vellumai/ces-contracts/src/index.ts +1 -0
  3. package/node_modules/@vellumai/ces-contracts/src/trust-rules.ts +42 -0
  4. package/package.json +1 -1
  5. package/src/__tests__/actor-token-service.test.ts +113 -0
  6. package/src/__tests__/config-schema.test.ts +2 -2
  7. package/src/__tests__/context-window-manager.test.ts +78 -0
  8. package/src/__tests__/conversation-title-service.test.ts +30 -1
  9. package/src/__tests__/credential-security-invariants.test.ts +2 -0
  10. package/src/__tests__/docker-signing-key-bootstrap.test.ts +207 -0
  11. package/src/__tests__/memory-regressions.test.ts +8 -30
  12. package/src/__tests__/openai-whisper.test.ts +93 -0
  13. package/src/__tests__/require-fresh-approval.test.ts +4 -0
  14. package/src/__tests__/slack-messaging-token-resolution.test.ts +319 -0
  15. package/src/__tests__/tool-executor-lifecycle-events.test.ts +4 -0
  16. package/src/__tests__/tool-executor.test.ts +4 -0
  17. package/src/__tests__/volume-security-guard.test.ts +155 -0
  18. package/src/cli/commands/conversations.ts +0 -18
  19. package/src/config/bundled-skills/messaging/tools/shared.ts +1 -0
  20. package/src/config/bundled-skills/transcribe/tools/transcribe-media.ts +16 -37
  21. package/src/config/env-registry.ts +9 -0
  22. package/src/config/env.ts +8 -2
  23. package/src/config/feature-flag-registry.json +8 -8
  24. package/src/config/schema.ts +0 -12
  25. package/src/config/schemas/memory.ts +0 -4
  26. package/src/config/schemas/platform.ts +1 -1
  27. package/src/config/schemas/security.ts +4 -0
  28. package/src/context/window-manager.ts +53 -2
  29. package/src/credential-execution/managed-catalog.ts +5 -15
  30. package/src/daemon/conversation-agent-loop.ts +0 -60
  31. package/src/daemon/conversation-memory.ts +0 -117
  32. package/src/daemon/conversation-runtime-assembly.ts +0 -2
  33. package/src/daemon/daemon-control.ts +7 -0
  34. package/src/daemon/handlers/conversations.ts +0 -11
  35. package/src/daemon/lifecycle.ts +10 -47
  36. package/src/daemon/providers-setup.ts +2 -1
  37. package/src/followups/followup-store.ts +5 -2
  38. package/src/hooks/manager.ts +7 -0
  39. package/src/instrument.ts +33 -1
  40. package/src/memory/conversation-crud.ts +0 -236
  41. package/src/memory/conversation-title-service.ts +26 -10
  42. package/src/memory/db-init.ts +5 -13
  43. package/src/memory/embedding-local.ts +11 -5
  44. package/src/memory/indexer.ts +15 -106
  45. package/src/memory/job-handlers/conversation-starters.ts +24 -36
  46. package/src/memory/job-handlers/embedding.ts +0 -79
  47. package/src/memory/job-utils.ts +1 -1
  48. package/src/memory/jobs-store.ts +0 -8
  49. package/src/memory/jobs-worker.ts +0 -20
  50. package/src/memory/migrations/189-drop-simplified-memory.ts +42 -0
  51. package/src/memory/migrations/index.ts +1 -3
  52. package/src/memory/qdrant-client.ts +4 -6
  53. package/src/memory/schema/conversations.ts +0 -3
  54. package/src/memory/schema/index.ts +0 -2
  55. package/src/messaging/draft-store.ts +2 -2
  56. package/src/messaging/provider.ts +9 -0
  57. package/src/messaging/providers/slack/adapter.ts +29 -2
  58. package/src/oauth/connection-resolver.test.ts +22 -18
  59. package/src/oauth/connection-resolver.ts +92 -7
  60. package/src/oauth/platform-connection.test.ts +78 -69
  61. package/src/oauth/platform-connection.ts +12 -19
  62. package/src/permissions/defaults.ts +3 -3
  63. package/src/permissions/trust-client.ts +332 -0
  64. package/src/permissions/trust-store-interface.ts +105 -0
  65. package/src/permissions/trust-store.ts +531 -39
  66. package/src/platform/client.test.ts +148 -0
  67. package/src/platform/client.ts +71 -0
  68. package/src/providers/speech-to-text/openai-whisper.test.ts +190 -0
  69. package/src/providers/speech-to-text/openai-whisper.ts +68 -0
  70. package/src/providers/speech-to-text/resolve.ts +9 -0
  71. package/src/providers/speech-to-text/types.ts +17 -0
  72. package/src/runtime/auth/route-policy.ts +14 -0
  73. package/src/runtime/auth/token-service.ts +133 -0
  74. package/src/runtime/http-server.ts +4 -2
  75. package/src/runtime/routes/conversation-management-routes.ts +0 -36
  76. package/src/runtime/routes/conversation-query-routes.ts +44 -2
  77. package/src/runtime/routes/conversation-routes.ts +2 -1
  78. package/src/runtime/routes/inbound-message-handler.ts +27 -3
  79. package/src/runtime/routes/inbound-stages/acl-enforcement.ts +16 -1
  80. package/src/runtime/routes/inbound-stages/transcribe-audio.test.ts +287 -0
  81. package/src/runtime/routes/inbound-stages/transcribe-audio.ts +122 -0
  82. package/src/runtime/routes/log-export-routes.ts +1 -0
  83. package/src/runtime/routes/memory-item-routes.test.ts +221 -3
  84. package/src/runtime/routes/memory-item-routes.ts +124 -2
  85. package/src/runtime/routes/secret-routes.ts +4 -1
  86. package/src/runtime/routes/upgrade-broadcast-routes.ts +151 -0
  87. package/src/schedule/schedule-store.ts +0 -21
  88. package/src/security/ces-credential-client.ts +173 -0
  89. package/src/security/secure-keys.ts +65 -22
  90. package/src/signals/bash.ts +3 -0
  91. package/src/signals/cancel.ts +3 -0
  92. package/src/signals/confirm.ts +3 -0
  93. package/src/signals/conversation-undo.ts +3 -0
  94. package/src/signals/event-stream.ts +7 -0
  95. package/src/signals/shotgun.ts +3 -0
  96. package/src/signals/trust-rule.ts +3 -0
  97. package/src/skills/inline-command-render.ts +5 -1
  98. package/src/skills/inline-command-runner.ts +30 -2
  99. package/src/telemetry/usage-telemetry-reporter.test.ts +23 -36
  100. package/src/telemetry/usage-telemetry-reporter.ts +21 -19
  101. package/src/tools/memory/handlers.ts +1 -129
  102. package/src/tools/permission-checker.ts +18 -0
  103. package/src/tools/skills/load.ts +9 -2
  104. package/src/util/device-id.ts +70 -7
  105. package/src/util/logger.ts +35 -9
  106. package/src/util/platform.ts +29 -5
  107. package/src/util/xml.ts +8 -0
  108. package/src/workspace/heartbeat-service.ts +5 -24
  109. package/src/workspace/migrations/migrate-to-workspace-volume.ts +113 -0
  110. package/src/workspace/migrations/registry.ts +2 -0
  111. package/src/__tests__/archive-recall.test.ts +0 -560
  112. package/src/__tests__/conversation-memory-dirty-tail.test.ts +0 -150
  113. package/src/__tests__/conversation-switch-memory-reduction.test.ts +0 -474
  114. package/src/__tests__/db-memory-archive-migration.test.ts +0 -372
  115. package/src/__tests__/db-memory-brief-state-migration.test.ts +0 -213
  116. package/src/__tests__/db-memory-reducer-checkpoints.test.ts +0 -273
  117. package/src/__tests__/memory-brief-open-loops.test.ts +0 -530
  118. package/src/__tests__/memory-brief-time.test.ts +0 -285
  119. package/src/__tests__/memory-brief-wrapper.test.ts +0 -311
  120. package/src/__tests__/memory-chunk-archive.test.ts +0 -400
  121. package/src/__tests__/memory-chunk-dual-write.test.ts +0 -453
  122. package/src/__tests__/memory-episode-archive.test.ts +0 -370
  123. package/src/__tests__/memory-episode-dual-write.test.ts +0 -626
  124. package/src/__tests__/memory-observation-archive.test.ts +0 -375
  125. package/src/__tests__/memory-observation-dual-write.test.ts +0 -318
  126. package/src/__tests__/memory-reducer-job.test.ts +0 -538
  127. package/src/__tests__/memory-reducer-scheduling.test.ts +0 -473
  128. package/src/__tests__/memory-reducer-store.test.ts +0 -728
  129. package/src/__tests__/memory-reducer-types.test.ts +0 -707
  130. package/src/__tests__/memory-reducer.test.ts +0 -704
  131. package/src/__tests__/memory-simplified-config.test.ts +0 -281
  132. package/src/__tests__/simplified-memory-e2e.test.ts +0 -666
  133. package/src/__tests__/simplified-memory-runtime.test.ts +0 -616
  134. package/src/config/schemas/memory-simplified.ts +0 -101
  135. package/src/memory/archive-recall.ts +0 -516
  136. package/src/memory/archive-store.ts +0 -400
  137. package/src/memory/brief-formatting.ts +0 -33
  138. package/src/memory/brief-open-loops.ts +0 -266
  139. package/src/memory/brief-time.ts +0 -162
  140. package/src/memory/brief.ts +0 -75
  141. package/src/memory/job-handlers/backfill-simplified-memory.ts +0 -462
  142. package/src/memory/job-handlers/reduce-conversation-memory.ts +0 -229
  143. package/src/memory/migrations/185-memory-brief-state.ts +0 -52
  144. package/src/memory/migrations/186-memory-archive.ts +0 -109
  145. package/src/memory/migrations/187-memory-reducer-checkpoints.ts +0 -19
  146. package/src/memory/reducer-scheduler.ts +0 -242
  147. package/src/memory/reducer-store.ts +0 -271
  148. package/src/memory/reducer-types.ts +0 -106
  149. package/src/memory/reducer.ts +0 -467
  150. package/src/memory/schema/memory-archive.ts +0 -121
  151. 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
- });