@vellumai/assistant 0.11.2-dev.202608051734.355dff7 → 0.11.2-dev.202608051933.deffc0f
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/ARCHITECTURE.md +4 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/ingress.ts +10 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/ingress.ts +10 -0
- package/node_modules/@vellumai/service-contracts/src/ingress.ts +10 -0
- package/openapi.yaml +22 -0
- package/package.json +1 -1
- package/src/__tests__/agent-loop-override-profile.test.ts +38 -48
- package/src/__tests__/assistant-feature-flags-integration.test.ts +0 -10
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +1 -0
- package/src/__tests__/conversation-tool-setup-attribution.test.ts +61 -0
- package/src/__tests__/cu-unified-flow.test.ts +2 -6
- package/src/__tests__/file-ops-service.test.ts +75 -4
- package/src/__tests__/host-bash-proxy.test.ts +10 -5
- package/src/__tests__/host-browser-proxy.test.ts +2 -2
- package/src/__tests__/host-cu-proxy.test.ts +3 -7
- package/src/__tests__/host-file-proxy.test.ts +3 -7
- package/src/__tests__/host-file-read-tool.test.ts +5 -1
- package/src/__tests__/host-transfer-proxy-targeted.test.ts +6 -4
- package/src/__tests__/llm-resolver-override-or-default.test.ts +141 -0
- package/src/__tests__/media-stream-server-integration.test.ts +36 -0
- package/src/__tests__/stt-language-catalog-parity.test.ts +38 -0
- package/src/__tests__/subagent-tool-gate-mode.test.ts +1 -0
- package/src/__tests__/subagent-tools.test.ts +48 -92
- package/src/__tests__/tool-result-spool.test.ts +74 -18
- package/src/agent/loop.ts +6 -3
- package/src/calls/media-stream-server.ts +9 -1
- package/src/config/bundled-skills/settings/TOOLS.json +2 -2
- package/src/config/bundled-skills/settings/tools/voice-config-update.ts +1 -0
- package/src/config/bundled-skills/subagent/SKILL.md +3 -3
- package/src/config/bundled-skills/subagent/TOOLS.json +1 -1
- package/src/config/feature-flag-registry.json +0 -16
- package/src/config/llm-resolver.ts +41 -12
- package/src/config/schemas/stt.ts +10 -4
- package/src/context/post-turn-tool-result-truncation.ts +32 -16
- package/src/context/tool-result-spool.ts +32 -18
- package/src/daemon/conversation-tool-setup.ts +1 -1
- package/src/persistence/conversation-attention-store.ts +30 -10
- package/src/persistence/conversation-queries.ts +74 -1
- package/src/platform/managed-speech.test.ts +20 -0
- package/src/platform/managed-speech.ts +9 -0
- package/src/providers/speech-to-text/__tests__/resolve.test.ts +164 -6
- package/src/providers/speech-to-text/deepgram.ts +1 -0
- package/src/providers/speech-to-text/resolve.ts +80 -10
- package/src/providers/speech-to-text/vellum-managed.ts +7 -1
- package/src/providers/speech-to-text/vellum-speech-relay-connection.ts +3 -1
- package/src/runtime/auth/__tests__/guard-tests.test.ts +2 -0
- package/src/runtime/auth/__tests__/scopes.test.ts +20 -0
- package/src/runtime/auth/same-actor.ts +38 -7
- package/src/runtime/auth/scopes.ts +12 -0
- package/src/runtime/auth/types.ts +2 -0
- package/src/runtime/routes/__tests__/conversation-list-routes.test.ts +279 -1
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +14 -10
- package/src/runtime/routes/conversation-list-routes.ts +25 -0
- package/src/runtime/routes/conversation-query-routes.ts +0 -50
- package/src/stt/daemon-batch-transcriber.ts +8 -6
- package/src/tools/filesystem/read.ts +2 -2
- package/src/tools/host-filesystem/read.ts +14 -6
- package/src/tools/shared/filesystem/file-ops-service.ts +36 -3
- package/src/tools/subagent/spawn.ts +26 -78
- package/src/tools/types.ts +5 -3
|
@@ -17,11 +17,20 @@ mock.module("../../assistant-event-hub.js", () => ({
|
|
|
17
17
|
}));
|
|
18
18
|
|
|
19
19
|
import { findConversation } from "../../../daemon/conversation-registry.js";
|
|
20
|
+
import {
|
|
21
|
+
projectAssistantMessage,
|
|
22
|
+
recordConversationSeenSignal,
|
|
23
|
+
} from "../../../persistence/conversation-attention-store.js";
|
|
20
24
|
import { createConversation } from "../../../persistence/conversation-crud.js";
|
|
21
25
|
import { getDb } from "../../../persistence/db-connection.js";
|
|
22
26
|
import { initializeDb } from "../../../persistence/db-init.js";
|
|
27
|
+
import { createGroup } from "../../../persistence/group-crud.js";
|
|
23
28
|
import { rawRun } from "../../../persistence/raw-query.js";
|
|
24
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
conversationAssistantAttentionState,
|
|
31
|
+
conversationAttentionEvents,
|
|
32
|
+
conversations,
|
|
33
|
+
} from "../../../persistence/schema/index.js";
|
|
25
34
|
import { ROUTES as CONVERSATION_LIST_ROUTES } from "../conversation-list-routes.js";
|
|
26
35
|
import { BadRequestError } from "../errors.js";
|
|
27
36
|
import type { RouteDefinition } from "../types.js";
|
|
@@ -236,3 +245,272 @@ describe("GET /v1/conversations — conversationType", () => {
|
|
|
236
245
|
);
|
|
237
246
|
});
|
|
238
247
|
});
|
|
248
|
+
|
|
249
|
+
describe("GET /v1/conversations/unread-count", () => {
|
|
250
|
+
const unreadCountHandler = findHandler(
|
|
251
|
+
CONVERSATION_LIST_ROUTES,
|
|
252
|
+
"getUnreadConversationCount",
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
function invokeUnreadCount(): { count: number } {
|
|
256
|
+
return unreadCountHandler({}) as { count: number };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function seedUnseen(conversationId: string): void {
|
|
260
|
+
projectAssistantMessage({
|
|
261
|
+
conversationId,
|
|
262
|
+
messageId: `msg-${conversationId}`,
|
|
263
|
+
messageAt: Date.now(),
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function markSeen(conversationId: string): void {
|
|
268
|
+
recordConversationSeenSignal({
|
|
269
|
+
conversationId,
|
|
270
|
+
sourceChannel: "vellum",
|
|
271
|
+
signalType: "macos_conversation_opened",
|
|
272
|
+
confidence: "explicit",
|
|
273
|
+
source: "test",
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
beforeEach(() => {
|
|
278
|
+
getDb().delete(conversationAttentionEvents).run();
|
|
279
|
+
getDb().delete(conversationAssistantAttentionState).run();
|
|
280
|
+
clearConversations();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test("counts only foreground conversations with an unseen latest assistant message", () => {
|
|
284
|
+
const unseen = createConversation("unseen-1");
|
|
285
|
+
seedUnseen(unseen.id);
|
|
286
|
+
|
|
287
|
+
// A conversation with no attention projection reads as seen.
|
|
288
|
+
createConversation("no-attention-row");
|
|
289
|
+
|
|
290
|
+
const seen = createConversation("seen-1");
|
|
291
|
+
seedUnseen(seen.id);
|
|
292
|
+
markSeen(seen.id);
|
|
293
|
+
|
|
294
|
+
expect(invokeUnreadCount()).toEqual({ count: 1 });
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
test("marking seen removes the conversation from the count", () => {
|
|
298
|
+
const conv = createConversation("unseen-then-seen");
|
|
299
|
+
seedUnseen(conv.id);
|
|
300
|
+
expect(invokeUnreadCount()).toEqual({ count: 1 });
|
|
301
|
+
|
|
302
|
+
markSeen(conv.id);
|
|
303
|
+
expect(invokeUnreadCount()).toEqual({ count: 0 });
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
test("archived conversations are excluded", () => {
|
|
307
|
+
const conv = createConversation("unseen-archived");
|
|
308
|
+
seedUnseen(conv.id);
|
|
309
|
+
rawRun(
|
|
310
|
+
"test:archiveConversation",
|
|
311
|
+
"UPDATE conversations SET archived_at = ? WHERE id = ?",
|
|
312
|
+
Date.now(),
|
|
313
|
+
conv.id,
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expect(invokeUnreadCount()).toEqual({ count: 0 });
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
test("background and scheduled conversations count only when surfaced", () => {
|
|
320
|
+
const bg = createConversation({
|
|
321
|
+
title: "bg-1",
|
|
322
|
+
conversationType: "background",
|
|
323
|
+
});
|
|
324
|
+
seedUnseen(bg.id);
|
|
325
|
+
const sched = createConversation({
|
|
326
|
+
title: "sched-1",
|
|
327
|
+
conversationType: "scheduled",
|
|
328
|
+
});
|
|
329
|
+
seedUnseen(sched.id);
|
|
330
|
+
expect(invokeUnreadCount()).toEqual({ count: 0 });
|
|
331
|
+
|
|
332
|
+
// Surfacing promotes a row into the foreground listing, so it counts.
|
|
333
|
+
rawRun(
|
|
334
|
+
"test:surfaceConversation",
|
|
335
|
+
"UPDATE conversations SET surfaced_at = ? WHERE id = ?",
|
|
336
|
+
Date.now(),
|
|
337
|
+
bg.id,
|
|
338
|
+
);
|
|
339
|
+
expect(invokeUnreadCount()).toEqual({ count: 1 });
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The daemon half of the unread-count contract.
|
|
344
|
+
*
|
|
345
|
+
* The web client answers the same question in TypeScript
|
|
346
|
+
* (`contributesToUnreadCount` in
|
|
347
|
+
* `clients/web/src/utils/conversation-predicates.ts`), and its
|
|
348
|
+
* `conversation-predicates.test.ts` asserts this same matrix against the
|
|
349
|
+
* predicate. The two definitions are maintained separately, so this matrix
|
|
350
|
+
* is the tripwire: a rule changed on one side without the other shows up as
|
|
351
|
+
* one of these scenarios disagreeing across the two suites.
|
|
352
|
+
*
|
|
353
|
+
* Keep the scenario names identical on both sides.
|
|
354
|
+
*/
|
|
355
|
+
describe("unread-count contract (daemon half)", () => {
|
|
356
|
+
const scenarios: Array<{
|
|
357
|
+
name: string;
|
|
358
|
+
counts: boolean;
|
|
359
|
+
seed: (groupId: string) => string;
|
|
360
|
+
}> = [
|
|
361
|
+
{
|
|
362
|
+
name: "unseen foreground row",
|
|
363
|
+
counts: true,
|
|
364
|
+
seed: () => createConversation("unseen-foreground").id,
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "seen foreground row",
|
|
368
|
+
counts: false,
|
|
369
|
+
seed: () => {
|
|
370
|
+
const conv = createConversation("seen-foreground");
|
|
371
|
+
seedUnseen(conv.id);
|
|
372
|
+
markSeen(conv.id);
|
|
373
|
+
return conv.id;
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: "unseen archived row",
|
|
378
|
+
counts: false,
|
|
379
|
+
seed: () => {
|
|
380
|
+
const conv = createConversation("unseen-archived");
|
|
381
|
+
rawRun(
|
|
382
|
+
"test:archiveConversation",
|
|
383
|
+
"UPDATE conversations SET archived_at = ? WHERE id = ?",
|
|
384
|
+
Date.now(),
|
|
385
|
+
conv.id,
|
|
386
|
+
);
|
|
387
|
+
return conv.id;
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: "unseen background row, not surfaced",
|
|
392
|
+
counts: false,
|
|
393
|
+
seed: () =>
|
|
394
|
+
createConversation({
|
|
395
|
+
title: "unseen-background",
|
|
396
|
+
conversationType: "background",
|
|
397
|
+
}).id,
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: "unseen scheduled row, not surfaced",
|
|
401
|
+
counts: false,
|
|
402
|
+
seed: () =>
|
|
403
|
+
createConversation({
|
|
404
|
+
title: "unseen-scheduled",
|
|
405
|
+
conversationType: "scheduled",
|
|
406
|
+
}).id,
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
name: "unseen background row, surfaced",
|
|
410
|
+
counts: true,
|
|
411
|
+
seed: () => {
|
|
412
|
+
const conv = createConversation({
|
|
413
|
+
title: "unseen-background-surfaced",
|
|
414
|
+
conversationType: "background",
|
|
415
|
+
});
|
|
416
|
+
rawRun(
|
|
417
|
+
"test:surfaceConversation",
|
|
418
|
+
"UPDATE conversations SET surfaced_at = ? WHERE id = ?",
|
|
419
|
+
Date.now(),
|
|
420
|
+
conv.id,
|
|
421
|
+
);
|
|
422
|
+
return conv.id;
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
name: "unseen background row filed in a custom group, not surfaced",
|
|
427
|
+
counts: false,
|
|
428
|
+
seed: (groupId) => {
|
|
429
|
+
const conv = createConversation({
|
|
430
|
+
title: "unseen-background-in-group",
|
|
431
|
+
conversationType: "background",
|
|
432
|
+
});
|
|
433
|
+
rawRun(
|
|
434
|
+
"test:fileIntoGroup",
|
|
435
|
+
"UPDATE conversations SET group_id = ? WHERE id = ?",
|
|
436
|
+
groupId,
|
|
437
|
+
conv.id,
|
|
438
|
+
);
|
|
439
|
+
return conv.id;
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: "unseen standard row filed in a custom group",
|
|
444
|
+
counts: true,
|
|
445
|
+
seed: (groupId) => {
|
|
446
|
+
const conv = createConversation("unseen-standard-in-group");
|
|
447
|
+
rawRun(
|
|
448
|
+
"test:fileIntoGroup",
|
|
449
|
+
"UPDATE conversations SET group_id = ? WHERE id = ?",
|
|
450
|
+
groupId,
|
|
451
|
+
conv.id,
|
|
452
|
+
);
|
|
453
|
+
return conv.id;
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
];
|
|
457
|
+
|
|
458
|
+
for (const scenario of scenarios) {
|
|
459
|
+
test(`${scenario.name} ${scenario.counts ? "counts" : "does not count"}`, () => {
|
|
460
|
+
const group = createGroup("unread-contract-group");
|
|
461
|
+
const conversationId = scenario.seed(group.id);
|
|
462
|
+
// The "seen" scenario seeds and clears its own attention row.
|
|
463
|
+
if (scenario.name !== "seen foreground row") {
|
|
464
|
+
seedUnseen(conversationId);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
expect(invokeUnreadCount()).toEqual({
|
|
468
|
+
count: scenario.counts ? 1 : 0,
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
test("the matrix totals across every scenario at once", () => {
|
|
474
|
+
const group = createGroup("unread-contract-group");
|
|
475
|
+
for (const scenario of scenarios) {
|
|
476
|
+
const conversationId = scenario.seed(group.id);
|
|
477
|
+
if (scenario.name !== "seen foreground row") {
|
|
478
|
+
seedUnseen(conversationId);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const expected = scenarios.filter((s) => s.counts).length;
|
|
482
|
+
|
|
483
|
+
expect(invokeUnreadCount()).toEqual({ count: expected });
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
test("background rows filed in a custom group stay excluded until surfaced", () => {
|
|
488
|
+
// Custom-group rows are visible in the standard listing regardless of
|
|
489
|
+
// type, but a non-surfaced background row must not count as unread
|
|
490
|
+
// (the client's unread predicate excludes it).
|
|
491
|
+
const group = createGroup("unread-count-test-group");
|
|
492
|
+
|
|
493
|
+
const bgInGroup = createConversation({
|
|
494
|
+
title: "bg-in-group",
|
|
495
|
+
conversationType: "background",
|
|
496
|
+
});
|
|
497
|
+
seedUnseen(bgInGroup.id);
|
|
498
|
+
rawRun(
|
|
499
|
+
"test:fileIntoGroup",
|
|
500
|
+
"UPDATE conversations SET group_id = ? WHERE id = ?",
|
|
501
|
+
group.id,
|
|
502
|
+
bgInGroup.id,
|
|
503
|
+
);
|
|
504
|
+
|
|
505
|
+
const standardInGroup = createConversation("standard-in-group");
|
|
506
|
+
seedUnseen(standardInGroup.id);
|
|
507
|
+
rawRun(
|
|
508
|
+
"test:fileIntoGroup",
|
|
509
|
+
"UPDATE conversations SET group_id = ? WHERE id = ?",
|
|
510
|
+
group.id,
|
|
511
|
+
standardInGroup.id,
|
|
512
|
+
);
|
|
513
|
+
|
|
514
|
+
expect(invokeUnreadCount()).toEqual({ count: 1 });
|
|
515
|
+
});
|
|
516
|
+
});
|
|
@@ -1427,7 +1427,7 @@ describe("custom profile write normalization (complete overrides)", () => {
|
|
|
1427
1427
|
});
|
|
1428
1428
|
});
|
|
1429
1429
|
|
|
1430
|
-
describe("call-site override
|
|
1430
|
+
describe("call-site override writes stay sparse", () => {
|
|
1431
1431
|
const configPatchRoute = ROUTES.find(
|
|
1432
1432
|
(r) => r.operationId === "config_patch",
|
|
1433
1433
|
)!;
|
|
@@ -1444,7 +1444,11 @@ describe("call-site override tuning backfill", () => {
|
|
|
1444
1444
|
seedRawConfig();
|
|
1445
1445
|
});
|
|
1446
1446
|
|
|
1447
|
-
|
|
1447
|
+
// The resolver layers `CALL_SITE_DEFAULTS` under the workspace entry, so a
|
|
1448
|
+
// written entry carries only what the user chose. Copying shipped tuning in
|
|
1449
|
+
// here would freeze a snapshot that later changes to call-site-defaults.ts
|
|
1450
|
+
// could never reach.
|
|
1451
|
+
test("a bare { profile } entry is written verbatim, without shipped tuning", async () => {
|
|
1448
1452
|
await configPatchRoute.handler({
|
|
1449
1453
|
body: {
|
|
1450
1454
|
llm: {
|
|
@@ -1457,14 +1461,14 @@ describe("call-site override tuning backfill", () => {
|
|
|
1457
1461
|
});
|
|
1458
1462
|
const memoryRouter = savedCallSites().memoryRouter!;
|
|
1459
1463
|
expect(memoryRouter.profile).toBe("mine");
|
|
1460
|
-
expect(memoryRouter
|
|
1464
|
+
expect("contextWindow" in memoryRouter).toBe(false);
|
|
1461
1465
|
const commitMessage = savedCallSites().commitMessage!;
|
|
1462
1466
|
expect(commitMessage.profile).toBe("mine");
|
|
1463
|
-
expect(commitMessage
|
|
1464
|
-
expect(commitMessage
|
|
1467
|
+
expect("maxTokens" in commitMessage).toBe(false);
|
|
1468
|
+
expect("effort" in commitMessage).toBe(false);
|
|
1465
1469
|
});
|
|
1466
1470
|
|
|
1467
|
-
test("explicit patch values
|
|
1471
|
+
test("explicit patch values are still written", async () => {
|
|
1468
1472
|
await configPatchRoute.handler({
|
|
1469
1473
|
body: {
|
|
1470
1474
|
llm: {
|
|
@@ -1474,10 +1478,11 @@ describe("call-site override tuning backfill", () => {
|
|
|
1474
1478
|
});
|
|
1475
1479
|
const saved = savedCallSites().commitMessage!;
|
|
1476
1480
|
expect(saved.maxTokens).toBe(500);
|
|
1477
|
-
|
|
1481
|
+
// Not copied from the shipped default: the resolver supplies it.
|
|
1482
|
+
expect("temperature" in saved).toBe(false);
|
|
1478
1483
|
});
|
|
1479
1484
|
|
|
1480
|
-
test("existing
|
|
1485
|
+
test("an existing entry's own customization is preserved", async () => {
|
|
1481
1486
|
rawConfigFixture = {
|
|
1482
1487
|
llm: { callSites: { recall: { profile: "old", maxTokens: 200 } } },
|
|
1483
1488
|
};
|
|
@@ -1494,10 +1499,9 @@ describe("call-site override tuning backfill", () => {
|
|
|
1494
1499
|
const saved = savedCallSites().recall!;
|
|
1495
1500
|
expect(saved.profile).toBe("mine");
|
|
1496
1501
|
expect(saved.maxTokens).toBe(200);
|
|
1497
|
-
expect(saved.disableCache).toBeUndefined();
|
|
1498
1502
|
});
|
|
1499
1503
|
|
|
1500
|
-
test("deleting an entry (null)
|
|
1504
|
+
test("deleting an entry (null) removes it", async () => {
|
|
1501
1505
|
rawConfigFixture = {
|
|
1502
1506
|
llm: { callSites: { recall: { profile: "old" } } },
|
|
1503
1507
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Route handlers for conversation listing, detail, and seen/unread state.
|
|
3
3
|
*
|
|
4
4
|
* GET /v1/conversations — paginated conversation list
|
|
5
|
+
* GET /v1/conversations/unread-count - count of unseen foreground conversations
|
|
5
6
|
* POST /v1/conversations/seen — record a seen signal (single)
|
|
6
7
|
* POST /v1/conversations/seen/bulk — record seen signals (batch)
|
|
7
8
|
* POST /v1/conversations/unread — mark a conversation unread
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
import { resolveConversationId } from "../../persistence/conversation-key-store.js";
|
|
28
29
|
import {
|
|
29
30
|
countConversations,
|
|
31
|
+
countUnreadConversations,
|
|
30
32
|
listConversations,
|
|
31
33
|
listPinnedConversations,
|
|
32
34
|
} from "../../persistence/conversation-queries.js";
|
|
@@ -141,6 +143,10 @@ const conversationDetailResponseSchema = z.object({
|
|
|
141
143
|
conversation: conversationSummarySchema,
|
|
142
144
|
});
|
|
143
145
|
|
|
146
|
+
const unreadConversationCountResponseSchema = z.object({
|
|
147
|
+
count: z.number(),
|
|
148
|
+
});
|
|
149
|
+
|
|
144
150
|
// ---------------------------------------------------------------------------
|
|
145
151
|
// Helpers
|
|
146
152
|
// ---------------------------------------------------------------------------
|
|
@@ -265,6 +271,10 @@ function handleListConversations({ queryParams = {} }: RouteHandlerArgs) {
|
|
|
265
271
|
return response;
|
|
266
272
|
}
|
|
267
273
|
|
|
274
|
+
function handleGetUnreadConversationCount() {
|
|
275
|
+
return { count: countUnreadConversations() };
|
|
276
|
+
}
|
|
277
|
+
|
|
268
278
|
function handleRecordSeen({ body = {}, headers }: RouteHandlerArgs) {
|
|
269
279
|
const rawConversationId = body.conversationId as string | undefined;
|
|
270
280
|
if (!rawConversationId) {
|
|
@@ -454,6 +464,21 @@ export const ROUTES: RouteDefinition[] = [
|
|
|
454
464
|
responseBody: listConversationsResponseSchema,
|
|
455
465
|
handler: handleListConversations,
|
|
456
466
|
},
|
|
467
|
+
{
|
|
468
|
+
operationId: "getUnreadConversationCount",
|
|
469
|
+
endpoint: "conversations/unread-count",
|
|
470
|
+
method: "GET",
|
|
471
|
+
policy: {
|
|
472
|
+
requiredScopes: ["chat.read"],
|
|
473
|
+
allowedPrincipalTypes: ACTOR_PRINCIPALS,
|
|
474
|
+
},
|
|
475
|
+
summary: "Unread conversation count",
|
|
476
|
+
description:
|
|
477
|
+
"Count of foreground conversations whose latest assistant message is unseen. Matches the sidebar's unread indicators: archived rows and non-surfaced background/scheduled rows are excluded.",
|
|
478
|
+
tags: ["conversations"],
|
|
479
|
+
responseBody: unreadConversationCountResponseSchema,
|
|
480
|
+
handler: handleGetUnreadConversationCount,
|
|
481
|
+
},
|
|
457
482
|
{
|
|
458
483
|
operationId: "recordConversationSeen",
|
|
459
484
|
endpoint: "conversations/seen",
|
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
LatencyBreakdownSchema,
|
|
30
30
|
LLMRequestLogEntrySchema,
|
|
31
31
|
} from "../../api/responses/llm-request-log-entry.js";
|
|
32
|
-
import { CALL_SITE_DEFAULTS } from "../../config/call-site-defaults.js";
|
|
33
32
|
import {
|
|
34
33
|
deepMergeOverwrite,
|
|
35
34
|
fillContextDefaultsForMissingKeys,
|
|
@@ -47,7 +46,6 @@ import { AssistantConfigSchema } from "../../config/schema.js";
|
|
|
47
46
|
import { getSchemaAtPath } from "../../config/schema-utils.js";
|
|
48
47
|
import {
|
|
49
48
|
DefaultProviderSchema,
|
|
50
|
-
type LLMCallSite,
|
|
51
49
|
LLMConfigBase,
|
|
52
50
|
LLMConfigFragment,
|
|
53
51
|
ProfileEntry,
|
|
@@ -924,53 +922,6 @@ function stripWireOnlyProfileKeys(patch: unknown): void {
|
|
|
924
922
|
}
|
|
925
923
|
}
|
|
926
924
|
|
|
927
|
-
/**
|
|
928
|
-
* Backfill shipped call-site tuning into NEWLY created `llm.callSites`
|
|
929
|
-
* entries in a config-write fragment, in place.
|
|
930
|
-
*
|
|
931
|
-
* The resolver's tweak layer is `llm.callSites[id] ?? CALL_SITE_DEFAULTS[id]`
|
|
932
|
-
* — an explicit entry replaces the shipped default wholesale. Workspace
|
|
933
|
-
* migrations that materialize entries therefore mirror the shipped tuning
|
|
934
|
-
* exactly (see 090-memory-router-cost-optimized-profile); a client writing a
|
|
935
|
-
* bare `{ profile }` for a site it has no entry for would silently drop
|
|
936
|
-
* shipped knobs like `memoryRouter`'s 1M input window or `recall`'s token/
|
|
937
|
-
* effort bounds. Enforce the same invariant here: when a patch creates an
|
|
938
|
-
* entry, copy in any shipped tuning key the patch doesn't set itself.
|
|
939
|
-
*
|
|
940
|
-
* `profile` is never backfilled — it is the selection discriminator, and
|
|
941
|
-
* stamping it onto a custom provider/model entry would change winner
|
|
942
|
-
* selection. Existing on-disk entries are never touched: deep-merge already
|
|
943
|
-
* preserves their keys, and their values may be deliberate customization.
|
|
944
|
-
*/
|
|
945
|
-
function backfillNewCallSiteEntries(
|
|
946
|
-
raw: Record<string, unknown>,
|
|
947
|
-
patch: unknown,
|
|
948
|
-
): void {
|
|
949
|
-
const patchSites = readPlainObject(
|
|
950
|
-
readPlainObject(readPlainObject(patch)?.llm)?.callSites,
|
|
951
|
-
);
|
|
952
|
-
if (!patchSites) {
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
955
|
-
const rawSites = readPlainObject(readPlainObject(raw.llm)?.callSites);
|
|
956
|
-
for (const [id, value] of Object.entries(patchSites)) {
|
|
957
|
-
const entry = readPlainObject(value);
|
|
958
|
-
if (!entry || rawSites?.[id] != null) {
|
|
959
|
-
continue;
|
|
960
|
-
}
|
|
961
|
-
const shipped = CALL_SITE_DEFAULTS[id as LLMCallSite];
|
|
962
|
-
if (!shipped) {
|
|
963
|
-
continue;
|
|
964
|
-
}
|
|
965
|
-
for (const [key, shippedValue] of Object.entries(shipped)) {
|
|
966
|
-
if (key === "profile" || key in entry) {
|
|
967
|
-
continue;
|
|
968
|
-
}
|
|
969
|
-
entry[key] = structuredClone(shippedValue);
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
|
|
974
925
|
/**
|
|
975
926
|
* Normalize managed default-profile entries in a config-write fragment, in
|
|
976
927
|
* place, so a `config get` → write round-trip of the enriched wire view is a
|
|
@@ -1561,7 +1512,6 @@ async function handlePatchConfig({ body }: RouteHandlerArgs) {
|
|
|
1561
1512
|
|
|
1562
1513
|
const raw = loadRawConfig();
|
|
1563
1514
|
const patch = body as Record<string, unknown>;
|
|
1564
|
-
backfillNewCallSiteEntries(raw, patch);
|
|
1565
1515
|
deepMergeOverwrite(raw, patch);
|
|
1566
1516
|
scrubRemovedServiceModes(raw);
|
|
1567
1517
|
seedSttProviderForSparseBlock(raw);
|
|
@@ -214,6 +214,8 @@ class VellumManagedBatchTranscriber implements BatchTranscriber {
|
|
|
214
214
|
readonly providerId = "vellum" as const;
|
|
215
215
|
readonly boundaryId = "daemon-batch" as const;
|
|
216
216
|
|
|
217
|
+
constructor(private readonly language: string | undefined) {}
|
|
218
|
+
|
|
217
219
|
async transcribe(
|
|
218
220
|
request: SttTranscribeRequest,
|
|
219
221
|
): Promise<SttTranscribeResult> {
|
|
@@ -223,6 +225,7 @@ class VellumManagedBatchTranscriber implements BatchTranscriber {
|
|
|
223
225
|
request.audio,
|
|
224
226
|
request.mimeType,
|
|
225
227
|
request.signal,
|
|
228
|
+
this.language,
|
|
226
229
|
);
|
|
227
230
|
}
|
|
228
231
|
}
|
|
@@ -237,12 +240,11 @@ class VellumManagedBatchTranscriber implements BatchTranscriber {
|
|
|
237
240
|
* is unavailable.
|
|
238
241
|
*
|
|
239
242
|
* `language` is the spoken language, forwarded to providers whose batch API
|
|
240
|
-
* accepts one: Deepgram (where `"multi"` also pins nova-3)
|
|
243
|
+
* accepts one: Deepgram (where `"multi"` also pins nova-3), xAI (where
|
|
241
244
|
* `"multi"` is dropped because it is a Deepgram-specific value, not a
|
|
242
|
-
* language code)
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* see the deferral note in `resolveBatchTranscriber`).
|
|
245
|
+
* language code), and the vellum managed path, whose platform proxy passes
|
|
246
|
+
* it to Deepgram server-side. Whisper and Gemini auto-detect natively and
|
|
247
|
+
* take no language parameter, so it is silently ignored for them.
|
|
246
248
|
*/
|
|
247
249
|
export function createDaemonBatchTranscriber(
|
|
248
250
|
apiKey: string | null | undefined,
|
|
@@ -251,7 +253,7 @@ export function createDaemonBatchTranscriber(
|
|
|
251
253
|
): BatchTranscriber | null {
|
|
252
254
|
// vellum authenticates via the platform connection, not an API key.
|
|
253
255
|
if (providerId === "vellum") {
|
|
254
|
-
return new VellumManagedBatchTranscriber();
|
|
256
|
+
return new VellumManagedBatchTranscriber(language);
|
|
255
257
|
}
|
|
256
258
|
if (!apiKey) {
|
|
257
259
|
return null;
|
|
@@ -43,7 +43,7 @@ export const fileReadInputSchema = z.looseObject({
|
|
|
43
43
|
.catch(undefined),
|
|
44
44
|
limit: z
|
|
45
45
|
.number()
|
|
46
|
-
.describe("Maximum number of lines to read")
|
|
46
|
+
.describe("Maximum number of lines to read (defaults to 2000)")
|
|
47
47
|
.optional()
|
|
48
48
|
.catch(undefined),
|
|
49
49
|
activity: z
|
|
@@ -58,7 +58,7 @@ export const fileReadInputSchema = z.looseObject({
|
|
|
58
58
|
export const fileReadTool = {
|
|
59
59
|
name: "file_read",
|
|
60
60
|
description:
|
|
61
|
-
"Read the contents of a file on your own machine. For image files (JPEG, PNG, GIF, WebP), returns the image for visual analysis. For audio files (MP3, WAV, OGG, FLAC, AAC, M4A), returns the audio for listening. Use host_file_read for files on your guardian's device instead.",
|
|
61
|
+
"Read the contents of a file on your own machine. Text reads return the first 2000 lines unless you pass `limit`; when a read stops short the result says so, and `offset` pages on from there. For image files (JPEG, PNG, GIF, WebP), returns the image for visual analysis. For audio files (MP3, WAV, OGG, FLAC, AAC, M4A), returns the audio for listening. Use host_file_read for files on your guardian's device instead.",
|
|
62
62
|
category: "filesystem",
|
|
63
63
|
executionTarget: "sandbox",
|
|
64
64
|
defaultRiskLevel: RiskLevel.Low,
|
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
AUDIO_EXTENSIONS,
|
|
11
11
|
readAudioFile,
|
|
12
12
|
} from "../shared/filesystem/audio-read.js";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
DEFAULT_READ_LINE_LIMIT,
|
|
15
|
+
FileSystemOps,
|
|
16
|
+
} from "../shared/filesystem/file-ops-service.js";
|
|
14
17
|
import {
|
|
15
18
|
IMAGE_EXTENSIONS,
|
|
16
19
|
readImageFile,
|
|
@@ -30,8 +33,8 @@ import type {
|
|
|
30
33
|
* Model-input schema, the single source for both runtime validation (via
|
|
31
34
|
* `TOOL_INPUT_SCHEMAS`) and the advertised `input_schema` below — mirrors
|
|
32
35
|
* `filesystem/read.ts`. `offset`/`limit` catch to `undefined` so a
|
|
33
|
-
* non-numeric value
|
|
34
|
-
* `target_client_id` catches so a non-string (or empty) value means
|
|
36
|
+
* non-numeric value falls back to the default line window instead of failing
|
|
37
|
+
* the call; `target_client_id` catches so a non-string (or empty) value means
|
|
35
38
|
* "untargeted".
|
|
36
39
|
*/
|
|
37
40
|
export const hostFileReadInputSchema = z.looseObject({
|
|
@@ -43,7 +46,7 @@ export const hostFileReadInputSchema = z.looseObject({
|
|
|
43
46
|
.catch(undefined),
|
|
44
47
|
limit: z
|
|
45
48
|
.number()
|
|
46
|
-
.describe("Maximum number of lines to read")
|
|
49
|
+
.describe("Maximum number of lines to read (defaults to 2000)")
|
|
47
50
|
.optional()
|
|
48
51
|
.catch(undefined),
|
|
49
52
|
target_client_id: z
|
|
@@ -58,7 +61,7 @@ export const hostFileReadInputSchema = z.looseObject({
|
|
|
58
61
|
export const hostFileReadTool = {
|
|
59
62
|
name: "host_file_read",
|
|
60
63
|
description:
|
|
61
|
-
"Read the contents of a file on your guardian's device, including images (JPEG, PNG, GIF, WebP) and audio (MP3, WAV, OGG, FLAC, AAC, M4A). For files on your own machine, use file_read instead.",
|
|
64
|
+
"Read the contents of a file on your guardian's device, including images (JPEG, PNG, GIF, WebP) and audio (MP3, WAV, OGG, FLAC, AAC, M4A). Text reads return the first 2000 lines unless you pass `limit`; when a read stops short the result says so, and `offset` pages on from there. For files on your own machine, use file_read instead.",
|
|
62
65
|
category: "host-filesystem",
|
|
63
66
|
executionTarget: "host",
|
|
64
67
|
defaultRiskLevel: RiskLevel.Medium,
|
|
@@ -73,7 +76,12 @@ export const hostFileReadTool = {
|
|
|
73
76
|
if (!parsed.success) {
|
|
74
77
|
return invalidToolInputResult("host_file_read", parsed.error);
|
|
75
78
|
}
|
|
76
|
-
const { path: rawPath, offset
|
|
79
|
+
const { path: rawPath, offset } = parsed.data;
|
|
80
|
+
// Resolve the default here rather than leaving it to the read, so the
|
|
81
|
+
// proxied branch below is bounded by the same window as the local one. A
|
|
82
|
+
// proxied read that sent no limit would stream a whole host file across
|
|
83
|
+
// the bridge before anything could trim it.
|
|
84
|
+
const limit = parsed.data.limit ?? DEFAULT_READ_LINE_LIMIT;
|
|
77
85
|
|
|
78
86
|
const targetClientId =
|
|
79
87
|
parsed.data.target_client_id !== ""
|
|
@@ -77,6 +77,29 @@ function pathError(
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Lines returned by a read that names no `limit`. Without a default the read
|
|
82
|
+
* returns the whole file, and a file-read result is honored in full for the
|
|
83
|
+
* rest of the turn (see `isSpoolEligible` in `context/tool-result-spool.ts`),
|
|
84
|
+
* so one unbounded read of a large file rides every subsequent LLM call in
|
|
85
|
+
* that turn. The cap bounds that; `offset`/`limit` page past it, and
|
|
86
|
+
* {@link truncationNotice} tells the model when it is looking at a window
|
|
87
|
+
* rather than the whole file.
|
|
88
|
+
*/
|
|
89
|
+
export const DEFAULT_READ_LINE_LIMIT = 2000;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Trailing marker appended when a read stops short of the last line. Silent
|
|
93
|
+
* truncation is the failure mode worth avoiding: a model that cannot tell a
|
|
94
|
+
* window from a whole file reasons about code it never saw.
|
|
95
|
+
*/
|
|
96
|
+
function truncationNotice(
|
|
97
|
+
lastLineReturned: number,
|
|
98
|
+
totalLines: number,
|
|
99
|
+
): string {
|
|
100
|
+
return `\n\n[Truncated: showing through line ${lastLineReturned} of ${totalLines}. Read on with offset=${lastLineReturned + 1}, or pass an explicit limit.]`;
|
|
101
|
+
}
|
|
102
|
+
|
|
80
103
|
export class FileSystemOps {
|
|
81
104
|
private policy: PathPolicy;
|
|
82
105
|
private sizeLimit: number | undefined;
|
|
@@ -119,8 +142,9 @@ export class FileSystemOps {
|
|
|
119
142
|
const lines = raw.split("\n");
|
|
120
143
|
|
|
121
144
|
const offset = (input.offset ?? 1) - 1;
|
|
122
|
-
const
|
|
123
|
-
const
|
|
145
|
+
const start = Math.max(0, offset);
|
|
146
|
+
const limit = input.limit ?? DEFAULT_READ_LINE_LIMIT;
|
|
147
|
+
const selected = lines.slice(start, offset + limit);
|
|
124
148
|
|
|
125
149
|
const numbered = selected
|
|
126
150
|
.map((line, i) => {
|
|
@@ -129,7 +153,16 @@ export class FileSystemOps {
|
|
|
129
153
|
})
|
|
130
154
|
.join("\n");
|
|
131
155
|
|
|
132
|
-
|
|
156
|
+
// Only when the window stops before the last line. An empty window means
|
|
157
|
+
// the caller paged past the end or asked for nothing, which is not a
|
|
158
|
+
// truncated read.
|
|
159
|
+
const lastLineReturned = start + selected.length;
|
|
160
|
+
const content =
|
|
161
|
+
selected.length > 0 && lastLineReturned < lines.length
|
|
162
|
+
? numbered + truncationNotice(lastLineReturned, lines.length)
|
|
163
|
+
: numbered;
|
|
164
|
+
|
|
165
|
+
return { ok: true, value: { content } };
|
|
133
166
|
} catch (err) {
|
|
134
167
|
const msg = err instanceof Error ? err.message : String(err);
|
|
135
168
|
return { ok: false, error: Err.ioError(filePath, msg) };
|