@vellumai/assistant 0.12.2-dev.202609211618.b1a8976 → 0.12.2-dev.202609211820.22f71b0
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/docs/voice-input-diagnostics.md +9 -4
- package/node_modules/@vellumai/gateway-client/src/trust-verdict-contract.ts +5 -6
- package/package.json +1 -1
- package/src/__tests__/annotate-activity-metadata.test.ts +1 -1
- package/src/__tests__/browser-fill-credential.test.ts +11 -22
- package/src/__tests__/build-persisted-content.test.ts +1 -1
- package/src/__tests__/headless-browser-interactions.test.ts +64 -20
- package/src/__tests__/server-history-render.test.ts +1 -1
- package/src/__tests__/tool-result-metadata-plumbing.test.ts +1 -1
- package/src/__tests__/web-search-backend-failure.test.ts +1 -1
- package/src/agent/loop.ts +1 -1
- package/src/api/events/tool-result.ts +5 -0
- package/src/browser/operation-meta.ts +2 -1
- package/src/calls/__tests__/barge-in-guard.test.ts +3 -0
- package/src/calls/__tests__/voice-session-bridge.test.ts +34 -0
- package/src/calls/barge-in-guard.ts +5 -0
- package/src/calls/voice-session-bridge.ts +6 -4
- package/src/daemon/conversation-agent-loop-handlers.ts +5 -5
- package/src/daemon/conversation-runtime-assembly.ts +3 -2
- package/src/daemon/message-protocol.ts +0 -1
- package/src/daemon/message-provenance.ts +5 -4
- package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +316 -31
- package/src/live-voice/__tests__/live-voice-look-follow-up.test.ts +191 -10
- package/src/live-voice/__tests__/session-controls.test.ts +23 -0
- package/src/live-voice/live-voice-session.ts +212 -131
- package/src/live-voice/session-controls.ts +11 -3
- package/src/persistence/conversation-crud.ts +2 -2
- package/src/providers/speech-to-text/__tests__/vellum-managed-realtime.test.ts +50 -1
- package/src/providers/speech-to-text/vellum-managed-flux-realtime.ts +13 -0
- package/src/runtime/actor-trust-resolver.ts +3 -3
- package/src/runtime/trust-class.test.ts +7 -6
- package/src/runtime/trust-class.ts +9 -17
- package/src/tools/browser/browser-execution.ts +22 -59
- package/src/tools/browser/cdp-client/__tests__/cdp-dom-helpers.test.ts +561 -39
- package/src/tools/browser/cdp-client/cdp-dom-helpers.ts +435 -39
- package/src/tools/network/web-fetch.ts +2 -2
- package/src/tools/network/web-search.ts +2 -2
- package/src/tools/tool-types.ts +3 -3
- package/src/tools/types.ts +1 -1
- package/src/daemon/message-types/web-activity.ts +0 -71
|
@@ -30,8 +30,9 @@ Search the assistant log for `Live voice input diagnostics` or `voice_input_`. A
|
|
|
30
30
|
- `voice_input_window` summarizes each approximately five-second arrival window: received audio duration, zero-signal duration, duration-weighted mean amplitude, minimum/maximum chunk mean amplitude, classified speech/silence/echo duration, and maximum arrival gap. Window emission requires incoming audio; `voice_input_closed` flushes a partial window.
|
|
31
31
|
- The same window includes `sttSubmittedChunks`, `sttSubmittedAudioMs`, and `sttMaxSubmissionGapMs`. These measure handoff to the transcription adapter, not provider receipt. A probe can buffer audio before submission, and the final chunk of an arrival window can be submitted in the next window. Compare sustained windows to identify input that arrives normally but stops reaching transcription.
|
|
32
32
|
- `voice_input_provider_turn_start` and `voice_input_provider_turn_end` record provider boundaries alongside local VAD state. End records include confidence, the provider's `trigger` (`model`, `timeout`, or `manual`), decoded audio position in seconds from stream start, and elapsed time since locally detected speech. Missing provider fields are null. These records describe received decisions, including ones ignored as stale or after fallback; correlate with the turn metrics to identify the boundary that committed the request.
|
|
33
|
-
- `voice_input_microphone_gate_changed` records when the transcription audio gate closes or reopens. `microphoneGateClosed` is included with the other input diagnostics. Closing replaces room audio with silence; it does not commit a transcript or stop local
|
|
34
|
-
- `voice_input_barge_in_armed`, `voice_input_barge_in_fired`, and `voice_input_barge_in_expired` distinguish a candidate from an accepted or expired interruption. Fired events include accumulated speech duration, guard resets, and a bounded trace of the preceding two seconds (at most 40 input chunks).
|
|
33
|
+
- `voice_input_microphone_gate_changed` records when the transcription audio gate closes or reopens. `microphoneGateClosed` is included with the other input diagnostics. Closing replaces room audio with silence; it does not commit a transcript or stop local energy detection.
|
|
34
|
+
- `voice_input_barge_in_armed`, `voice_input_barge_in_fired`, and `voice_input_barge_in_expired` distinguish a candidate from an accepted or expired local interruption on providers without native turn detection. Fired events include accumulated speech duration, guard resets, and a bounded trace of the preceding two seconds (at most 40 input chunks).
|
|
35
|
+
- `voice_input_speech_started` includes `source: "provider"` when a Flux `StartOfTurn` triggers the client speech signal and any active-turn cancellation. `source: "local"` identifies local onset or a confirmed pre-dial guard replay; guards completed during ordinary streaming use `voice_input_barge_in_fired`.
|
|
35
36
|
- Each trace entry captures the amplitude and gate/echo state before classification, and classified durations, remaining probe buffer, and correlation result after classification. The classifier can hold a probe and release multiple older chunks together, so a row's classified duration can differ from its received duration. A null correlation means no comparison ran, not a measured zero correlation.
|
|
36
37
|
- `voice_input_speech_routed` binds the speech generation to the input turn that actually receives its audio. At onset, the prior spent cycle may still be installed, so use this routing record for correlation rather than assuming the onset's `inputTurnId` is the new utterance.
|
|
37
38
|
- `voice_input_transcript` reports committed character count and provider, never words. `voice_input_utterance_discarded` reports the discard reason and remaining transcript/partial state.
|
|
@@ -42,9 +43,13 @@ These are local diagnostic logs, not new analytics events or voice protocol fiel
|
|
|
42
43
|
|
|
43
44
|
## Flux pause handling
|
|
44
45
|
|
|
45
|
-
When Flux owns turn detection, microphone audio passes through for one second of received audio after the last locally detected speech. After that, the input gate replaces room audio with digital silence while the microphone and local
|
|
46
|
+
When Flux owns turn detection, microphone audio passes through for one second of received audio after the last locally detected speech. After that, the input gate replaces room audio with digital silence while the microphone and local energy detector keep listening. The cutoff is measured in PCM samples, so network batching does not change it. Flux continues receiving elapsed silence and owns the turn boundary; closing this gate does not release the question.
|
|
46
47
|
|
|
47
|
-
While closed, the gate holds the most recent 200 ms before deciding whether to send those samples as silence or as the lead-in to resumed speech. On speech onset, it forwards that lead-in and the new speech exactly once. The provider feed can lag input by up to 200 ms while idle, then catches up on speech onset. Confirmed playback echo is replaced with silence before entering this buffer.
|
|
48
|
+
While closed, the gate holds the most recent 200 ms before deciding whether to send those samples as silence or as the lead-in to resumed speech. On speech onset, it forwards that lead-in and the new speech exactly once. The provider feed can lag input by up to 200 ms while idle, then catches up on speech onset. Confirmed playback echo is replaced with silence before entering this buffer. Idle audio is not accumulated into request recordings. Manual capture and locally endpointed providers retain their existing routing.
|
|
49
|
+
|
|
50
|
+
Flux `StartOfTurn` owns hands-free interruption, independently of the provider end-of-turn setting. Above-threshold microphone audio alone cannot pause playback, cancel a reply, or trigger a speech-start screenshot. A provider turn start emits `speech_started` immediately, without the local sustained-speech delay, and cancels an active reply through the shared interruption path. Duplicate or older provider turn indices are ignored within a stream. Other providers retain the local guard. This waits for provider recognition and does not guarantee rejection of playback echo or background speech that Flux transcribes.
|
|
51
|
+
|
|
52
|
+
Managed Flux maps provider turn indices into one continuous sequence across transparent relay reconnects. A new relay connection restarting at zero therefore cannot make fresh speech look like a duplicate. If connection setup falls back to a provider without native turn detection, the suppressed local onset is replayed through the local interruption path, preserving its sustained-speech guard result even if the utterance ended during the dial.
|
|
48
53
|
|
|
49
54
|
The gate shares the existing adaptive energy classifier. Quiet speech within the one-second tail passes through; quiet onset in the 200 ms buffer is preserved if followed by detected speech. Sustained speech entirely below the local threshold can be suppressed, and noise classified as speech can reopen the gate. This limits background exposure rather than guaranteeing that every false transcript is eliminated.
|
|
50
55
|
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The gateway resolves this verdict from its ACL DB and stamps it onto the
|
|
5
5
|
* inbound payload's `sourceMetadata`; the runtime consumes it. Keeping the
|
|
6
|
-
* type here avoids the runtime importing from `gateway/src
|
|
7
|
-
*
|
|
8
|
-
* one source of truth.
|
|
6
|
+
* type here avoids the runtime importing from `gateway/src`, and the daemon
|
|
7
|
+
* imports {@link TrustClass} from here rather than declaring its own.
|
|
9
8
|
*
|
|
10
9
|
* This contract carries ACL + identity keys + minimal labels only — never
|
|
11
10
|
* info fields (notes, userFile, contactType). `status` / `policy` / `type`
|
|
@@ -19,9 +18,9 @@ import { z } from "zod";
|
|
|
19
18
|
import { AdmissionPolicySchema } from "./admission-policy-contract.js";
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Trust classification of an inbound actor, ordered most- to least-trusted.
|
|
22
|
+
* The one declaration of the vocabulary: the gateway classifies with it and
|
|
23
|
+
* the daemon derives capabilities from it.
|
|
25
24
|
*/
|
|
26
25
|
export const TRUST_CLASS_VALUES = [
|
|
27
26
|
"guardian",
|
package/package.json
CHANGED
|
@@ -44,6 +44,7 @@ mock.module("../persistence/llm-request-log-store.js", () => ({
|
|
|
44
44
|
}));
|
|
45
45
|
|
|
46
46
|
// ── Imports (after mocks) ─────────────────────────────────────────────────────
|
|
47
|
+
import type { ToolActivityMetadata } from "../api/events/tool-result.js";
|
|
47
48
|
import type {
|
|
48
49
|
EventHandlerDeps,
|
|
49
50
|
EventHandlerState,
|
|
@@ -52,7 +53,6 @@ import {
|
|
|
52
53
|
createEventHandlerState,
|
|
53
54
|
handleToolResult,
|
|
54
55
|
} from "../daemon/conversation-agent-loop-handlers.js";
|
|
55
|
-
import type { ToolActivityMetadata } from "../daemon/message-types/web-activity.js";
|
|
56
56
|
import { mockUnownedModeSessions } from "./helpers/mock-conversation.js";
|
|
57
57
|
|
|
58
58
|
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
@@ -244,42 +244,32 @@ describe("executeBrowserFillCredential", () => {
|
|
|
244
244
|
expect(detachCalls).toBe(1);
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
test("
|
|
248
|
-
// Regression: previously, fillCredential called focus + insertText
|
|
249
|
-
// directly, which APPENDED the credential to any existing value
|
|
250
|
-
// (autofill, prior typing, etc.) — corrupting the password and
|
|
251
|
-
// leaking partial state. The fix routes through the shared
|
|
252
|
-
// clearAndInsertText helper.
|
|
247
|
+
test("selects pre-populated content before inserting credential text", async () => {
|
|
253
248
|
snapshotBackendNodeMaps.set("test-conversation", new Map([["e1", 555]]));
|
|
254
249
|
await executeBrowserFillCredential(
|
|
255
250
|
{ service: "gmail", field: "password", element_id: "e1" },
|
|
256
251
|
ctx,
|
|
257
252
|
);
|
|
258
253
|
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
// must precede Input.insertText.
|
|
254
|
+
// Selection must happen before Input.insertText so the credential replaces
|
|
255
|
+
// existing content without mutating framework-owned editor state directly.
|
|
262
256
|
const methodSeq = sendCalls.map((c) => c.method);
|
|
263
257
|
const clearIdx = methodSeq.indexOf("Runtime.callFunctionOn");
|
|
264
258
|
const insertIdx = methodSeq.indexOf("Input.insertText");
|
|
265
259
|
expect(clearIdx).toBeGreaterThanOrEqual(0);
|
|
266
260
|
expect(insertIdx).toBeGreaterThan(clearIdx);
|
|
267
261
|
|
|
268
|
-
//
|
|
269
|
-
// `textContent` so input/textarea AND contenteditable targets
|
|
270
|
-
// are handled.
|
|
262
|
+
// Form fields and contenteditable targets use their native selection APIs.
|
|
271
263
|
const clearCall = sendCalls[clearIdx]!;
|
|
272
264
|
const fnDecl = (clearCall.params as { functionDeclaration: string })
|
|
273
265
|
.functionDeclaration;
|
|
274
|
-
expect(fnDecl).toContain(
|
|
275
|
-
expect(fnDecl).toContain("this
|
|
276
|
-
expect(fnDecl).toContain('
|
|
266
|
+
expect(fnDecl).toContain("this.select()");
|
|
267
|
+
expect(fnDecl).toContain("range.selectNodeContents(this)");
|
|
268
|
+
expect(fnDecl).not.toContain('this.value = ""');
|
|
269
|
+
expect(fnDecl).not.toContain("this.textContent =");
|
|
277
270
|
|
|
278
|
-
// After the clear, the helper re-focuses the element (some sites
|
|
279
|
-
// blur on programmatic value reset) before inserting text — so we
|
|
280
|
-
// expect at least 2 DOM.focus calls in total.
|
|
281
271
|
const focusCount = methodSeq.filter((m) => m === "DOM.focus").length;
|
|
282
|
-
expect(focusCount).
|
|
272
|
+
expect(focusCount).toBe(1);
|
|
283
273
|
});
|
|
284
274
|
|
|
285
275
|
test("fills credential by CSS selector", async () => {
|
|
@@ -364,14 +354,13 @@ describe("executeBrowserFillCredential", () => {
|
|
|
364
354
|
expect(result.isError).toBe(false);
|
|
365
355
|
const methods = sendCalls.map((c) => c.method);
|
|
366
356
|
expect(methods).toContain("Input.insertText");
|
|
367
|
-
//
|
|
368
|
-
// (Enter has text "\r" so it now produces a char event too).
|
|
357
|
+
// Enter dispatches rawKeyDown + char + keyUp.
|
|
369
358
|
const keyEvents = sendCalls.filter(
|
|
370
359
|
(c) => c.method === "Input.dispatchKeyEvent",
|
|
371
360
|
);
|
|
372
361
|
expect(keyEvents).toHaveLength(3);
|
|
373
362
|
expect((keyEvents[0]!.params as { type: string; key: string }).type).toBe(
|
|
374
|
-
"
|
|
363
|
+
"rawKeyDown",
|
|
375
364
|
);
|
|
376
365
|
expect((keyEvents[0]!.params as { type: string; key: string }).key).toBe(
|
|
377
366
|
"Enter",
|
|
@@ -29,12 +29,12 @@ mock.module("../persistence/llm-request-log-store.js", () => ({
|
|
|
29
29
|
// ── Imports (after mocks) ─────────────────────────────────────────────────────
|
|
30
30
|
import { REDACTED_SENTINEL_OPEN } from "@vellumai/service-contracts/redacted-credential";
|
|
31
31
|
|
|
32
|
+
import type { ToolActivityMetadata } from "../api/events/tool-result.js";
|
|
32
33
|
import type { ResolvedRevealCandidate } from "../daemon/chat-credential-redaction.js";
|
|
33
34
|
import {
|
|
34
35
|
buildPersistedAssistantContent,
|
|
35
36
|
stampThinkingTiming,
|
|
36
37
|
} from "../daemon/conversation-agent-loop-handlers.js";
|
|
37
|
-
import type { ToolActivityMetadata } from "../daemon/message-types/web-activity.js";
|
|
38
38
|
import type { ContentBlock } from "../providers/types.js";
|
|
39
39
|
import {
|
|
40
40
|
OPENAI_PROJECT_KEY_REDACTION_MARKER,
|
|
@@ -163,7 +163,7 @@ function resetMockPage() {
|
|
|
163
163
|
*/
|
|
164
164
|
function defaultCdpHandler(
|
|
165
165
|
method: string,
|
|
166
|
-
|
|
166
|
+
params: Record<string, unknown> | undefined,
|
|
167
167
|
): unknown {
|
|
168
168
|
switch (method) {
|
|
169
169
|
case "DOM.getDocument":
|
|
@@ -177,12 +177,28 @@ function defaultCdpHandler(
|
|
|
177
177
|
case "Runtime.evaluate":
|
|
178
178
|
return { result: { value: { w: 800, h: 600 } } };
|
|
179
179
|
case "Runtime.callFunctionOn":
|
|
180
|
+
if (
|
|
181
|
+
params?.returnByValue === true &&
|
|
182
|
+
String(params.functionDeclaration).includes("isConnected")
|
|
183
|
+
) {
|
|
184
|
+
return {
|
|
185
|
+
result: { value: { connected: true, matches: true } },
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (
|
|
189
|
+
params?.returnByValue === true &&
|
|
190
|
+
String(params.functionDeclaration).includes("clearFirst")
|
|
191
|
+
) {
|
|
192
|
+
return { result: { value: { needsRefocus: false } } };
|
|
193
|
+
}
|
|
180
194
|
// executeBrowserSelectOption invokes a function that returns
|
|
181
195
|
// a `matched` boolean — default to true so wrapper-contract
|
|
182
196
|
// tests don't need to know the inner select-option matching
|
|
183
197
|
// shape. Tests that exercise the no-match path override the
|
|
184
198
|
// handler explicitly.
|
|
185
199
|
return { result: { value: true } };
|
|
200
|
+
case "Input.insertText":
|
|
201
|
+
return {};
|
|
186
202
|
default:
|
|
187
203
|
return {};
|
|
188
204
|
}
|
|
@@ -485,20 +501,21 @@ describe("executeBrowserType", () => {
|
|
|
485
501
|
expect(result.content).toContain('Typed into element: element_id "e3"');
|
|
486
502
|
expect(result.content).toContain("cleared existing content");
|
|
487
503
|
|
|
488
|
-
//
|
|
489
|
-
//
|
|
490
|
-
// DOM.focus → Input.insertText
|
|
504
|
+
// The editor selection precedes insertion, and a live-node read verifies
|
|
505
|
+
// that the requested text persisted.
|
|
491
506
|
const methods = sendCalls.map((c) => c.method);
|
|
492
507
|
expect(methods).toEqual([
|
|
493
508
|
"DOM.focus",
|
|
494
509
|
"DOM.resolveNode",
|
|
495
510
|
"Runtime.callFunctionOn",
|
|
496
|
-
"DOM.focus",
|
|
497
511
|
"Input.insertText",
|
|
512
|
+
"Runtime.callFunctionOn",
|
|
498
513
|
]);
|
|
499
514
|
const focusCall = sendCalls[0]!;
|
|
500
515
|
expect(focusCall.params).toEqual({ backendNodeId: 555 });
|
|
501
|
-
const insertCall = sendCalls
|
|
516
|
+
const insertCall = sendCalls.find(
|
|
517
|
+
(call) => call.method === "Input.insertText",
|
|
518
|
+
)!;
|
|
502
519
|
expect(insertCall.params).toEqual({ text: "hello" });
|
|
503
520
|
});
|
|
504
521
|
|
|
@@ -524,11 +541,10 @@ describe("executeBrowserType", () => {
|
|
|
524
541
|
);
|
|
525
542
|
expect(result.isError).toBe(false);
|
|
526
543
|
expect(result.content).not.toContain("cleared");
|
|
527
|
-
//
|
|
528
|
-
// and the re-focus call, so we should see focus + insertText only.
|
|
544
|
+
// Append mode collapses the editor selection at the end before insertion.
|
|
529
545
|
const methods = sendCalls.map((c) => c.method);
|
|
530
|
-
expect(methods).
|
|
531
|
-
expect(methods).
|
|
546
|
+
expect(methods).toContain("DOM.resolveNode");
|
|
547
|
+
expect(methods).toContain("Runtime.callFunctionOn");
|
|
532
548
|
const focusCount = methods.filter((m) => m === "DOM.focus").length;
|
|
533
549
|
expect(focusCount).toBe(1);
|
|
534
550
|
expect(methods).toContain("Input.insertText");
|
|
@@ -542,22 +558,22 @@ describe("executeBrowserType", () => {
|
|
|
542
558
|
expect(result.isError).toBe(false);
|
|
543
559
|
expect(result.content).toContain("pressed Enter");
|
|
544
560
|
const methods = sendCalls.map((c) => c.method);
|
|
545
|
-
// Input.insertText must come before the Enter
|
|
561
|
+
// Input.insertText must come before the Enter rawKeyDown/char/keyUp.
|
|
546
562
|
const insertIdx = methods.indexOf("Input.insertText");
|
|
547
563
|
const keyDownIdx = methods.findIndex(
|
|
548
564
|
(m, i) =>
|
|
549
565
|
m === "Input.dispatchKeyEvent" &&
|
|
550
|
-
(sendCalls[i]!.params as { type: string }).type === "
|
|
566
|
+
(sendCalls[i]!.params as { type: string }).type === "rawKeyDown",
|
|
551
567
|
);
|
|
552
568
|
expect(insertIdx).toBeGreaterThanOrEqual(0);
|
|
553
569
|
expect(keyDownIdx).toBeGreaterThan(insertIdx);
|
|
554
|
-
// Enter is text-producing
|
|
570
|
+
// Enter is text-producing, so it emits rawKeyDown + char + keyUp.
|
|
555
571
|
const keyEvents = sendCalls.filter(
|
|
556
572
|
(c) => c.method === "Input.dispatchKeyEvent",
|
|
557
573
|
);
|
|
558
574
|
expect(keyEvents).toHaveLength(3);
|
|
559
575
|
expect((keyEvents[0]!.params as { key: string }).key).toBe("Enter");
|
|
560
|
-
expect((keyEvents[0]!.params as { type: string }).type).toBe("
|
|
576
|
+
expect((keyEvents[0]!.params as { type: string }).type).toBe("rawKeyDown");
|
|
561
577
|
expect((keyEvents[1]!.params as { type: string }).type).toBe("char");
|
|
562
578
|
expect((keyEvents[2]!.params as { type: string }).type).toBe("keyUp");
|
|
563
579
|
});
|
|
@@ -689,7 +705,7 @@ describe("executeBrowserPressKey", () => {
|
|
|
689
705
|
expect(result.content).toContain('Pressed "Enter"');
|
|
690
706
|
// No target => no DOM.focus, no selector resolution. Enter is a
|
|
691
707
|
// text-producing key (text "\r") so dispatchKeyPress emits
|
|
692
|
-
//
|
|
708
|
+
// rawKeyDown + char + keyUp.
|
|
693
709
|
const methods = sendCalls.map((c) => c.method);
|
|
694
710
|
expect(methods).toEqual([
|
|
695
711
|
"Input.dispatchKeyEvent",
|
|
@@ -699,7 +715,7 @@ describe("executeBrowserPressKey", () => {
|
|
|
699
715
|
const keyDown = sendCalls[0]!.params as Record<string, unknown>;
|
|
700
716
|
const charEvt = sendCalls[1]!.params as Record<string, unknown>;
|
|
701
717
|
const keyUp = sendCalls[2]!.params as Record<string, unknown>;
|
|
702
|
-
expect(keyDown.type).toBe("
|
|
718
|
+
expect(keyDown.type).toBe("rawKeyDown");
|
|
703
719
|
expect(keyDown.key).toBe("Enter");
|
|
704
720
|
expect(keyDown.windowsVirtualKeyCode).toBe(13);
|
|
705
721
|
expect(charEvt.type).toBe("char");
|
|
@@ -707,6 +723,36 @@ describe("executeBrowserPressKey", () => {
|
|
|
707
723
|
expect(keyUp.key).toBe("Enter");
|
|
708
724
|
});
|
|
709
725
|
|
|
726
|
+
test("presses modifier chords on the focused element", async () => {
|
|
727
|
+
const result = await executeBrowserPressKey({ key: "Meta+v" }, ctx);
|
|
728
|
+
expect(result.isError).toBe(false);
|
|
729
|
+
expect(result.content).toContain('Pressed "Meta+v"');
|
|
730
|
+
|
|
731
|
+
const keyEvents = sendCalls.filter(
|
|
732
|
+
(call) => call.method === "Input.dispatchKeyEvent",
|
|
733
|
+
);
|
|
734
|
+
expect(keyEvents).toHaveLength(4);
|
|
735
|
+
expect(keyEvents[0]!.params).toMatchObject({
|
|
736
|
+
type: "rawKeyDown",
|
|
737
|
+
key: "Meta",
|
|
738
|
+
modifiers: 4,
|
|
739
|
+
});
|
|
740
|
+
expect(keyEvents[1]!.params).toMatchObject({
|
|
741
|
+
type: "rawKeyDown",
|
|
742
|
+
key: "v",
|
|
743
|
+
modifiers: 4,
|
|
744
|
+
});
|
|
745
|
+
expect(keyEvents[2]!.params).toMatchObject({
|
|
746
|
+
type: "keyUp",
|
|
747
|
+
key: "v",
|
|
748
|
+
modifiers: 4,
|
|
749
|
+
});
|
|
750
|
+
expect(keyEvents[3]!.params).toMatchObject({
|
|
751
|
+
type: "keyUp",
|
|
752
|
+
key: "Meta",
|
|
753
|
+
});
|
|
754
|
+
});
|
|
755
|
+
|
|
710
756
|
test("presses key on targeted element via element_id", async () => {
|
|
711
757
|
snapshotBackendNodeMaps.set("test-conversation", new Map([["e5", 555]]));
|
|
712
758
|
const result = await executeBrowserPressKey(
|
|
@@ -716,14 +762,12 @@ describe("executeBrowserPressKey", () => {
|
|
|
716
762
|
expect(result.isError).toBe(false);
|
|
717
763
|
expect(result.content).toContain('Pressed "Tab" on element');
|
|
718
764
|
expect(result.content).toContain('element_id "e5"');
|
|
719
|
-
// Backend-resolved path: focus
|
|
720
|
-
// text-producing so we also dispatch a char event).
|
|
765
|
+
// Backend-resolved path: focus, then Tab key down and key up.
|
|
721
766
|
const methods = sendCalls.map((c) => c.method);
|
|
722
767
|
expect(methods).toEqual([
|
|
723
768
|
"DOM.focus",
|
|
724
769
|
"Input.dispatchKeyEvent",
|
|
725
770
|
"Input.dispatchKeyEvent",
|
|
726
|
-
"Input.dispatchKeyEvent",
|
|
727
771
|
]);
|
|
728
772
|
expect(sendCalls[0]!.params).toEqual({ backendNodeId: 555 });
|
|
729
773
|
});
|
|
@@ -767,7 +811,7 @@ describe("executeBrowserPressKey", () => {
|
|
|
767
811
|
|
|
768
812
|
test("surfaces CDP failure as a press-key error", async () => {
|
|
769
813
|
sendHandler = () => new Error("Key not recognized");
|
|
770
|
-
const result = await executeBrowserPressKey({ key: "
|
|
814
|
+
const result = await executeBrowserPressKey({ key: "Enter" }, ctx);
|
|
771
815
|
expect(result.isError).toBe(true);
|
|
772
816
|
expect(result.content).toContain("Press key failed");
|
|
773
817
|
expect(result.content).toContain("Key not recognized");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, test } from "bun:test";
|
|
2
2
|
|
|
3
3
|
import type { AnsweredQuestion } from "../api/events/question-answered.js";
|
|
4
|
+
import type { ToolActivityMetadata } from "../api/events/tool-result.js";
|
|
4
5
|
import { renderHistoryContent } from "../daemon/handlers/shared.js";
|
|
5
|
-
import type { ToolActivityMetadata } from "../daemon/message-types/web-activity.js";
|
|
6
6
|
import {
|
|
7
7
|
getAttachmentsForMessage,
|
|
8
8
|
linkAttachmentToMessage,
|
|
@@ -26,6 +26,7 @@ mock.module("../persistence/llm-request-log-store.js", () => ({
|
|
|
26
26
|
}));
|
|
27
27
|
|
|
28
28
|
// ── Imports (after mocks) ─────────────────────────────────────────────────────
|
|
29
|
+
import type { ToolActivityMetadata } from "../api/events/tool-result.js";
|
|
29
30
|
import type { AssistantEvent } from "../api/index.js";
|
|
30
31
|
import { toolImageFilename } from "../daemon/assistant-attachments.js";
|
|
31
32
|
import type {
|
|
@@ -37,7 +38,6 @@ import {
|
|
|
37
38
|
handleToolResult,
|
|
38
39
|
handleToolUse,
|
|
39
40
|
} from "../daemon/conversation-agent-loop-handlers.js";
|
|
40
|
-
import type { ToolActivityMetadata } from "../daemon/message-types/web-activity.js";
|
|
41
41
|
import { mockUnownedModeSessions } from "./helpers/mock-conversation.js";
|
|
42
42
|
|
|
43
43
|
type ToolResultEvent = Extract<AssistantEvent, { type: "tool_result" }>;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
29
29
|
|
|
30
|
-
import type { ToolActivityMetadata } from "../
|
|
30
|
+
import type { ToolActivityMetadata } from "../api/events/tool-result.js";
|
|
31
31
|
|
|
32
32
|
// ---------------------------------------------------------------------------
|
|
33
33
|
// Mock the daemon collaborators the handler module imports at load time so the
|
package/src/agent/loop.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AnsweredQuestion } from "../api/events/question-answered.js";
|
|
2
|
+
import type { ToolActivityMetadata } from "../api/events/tool-result.js";
|
|
2
3
|
import { resolveCallSiteConfig } from "../config/llm-resolver.js";
|
|
3
4
|
import { getConfig } from "../config/loader.js";
|
|
4
5
|
import type { LLMCallSite } from "../config/schemas/llm.js";
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
getCalibrationProviderKey,
|
|
14
15
|
} from "../context/token-estimator.js";
|
|
15
16
|
import { spoolAndStubOversizedToolResults } from "../context/tool-result-spool.js";
|
|
16
|
-
import type { ToolActivityMetadata } from "../daemon/message-types/web-activity.js";
|
|
17
17
|
import { parseActualTokensFromError } from "../daemon/parse-actual-tokens-from-error.js";
|
|
18
18
|
import type { TrustContext } from "../daemon/trust-context-types.js";
|
|
19
19
|
import type {
|
|
@@ -68,13 +68,18 @@ export const WebFetchProviderIdSchema = z.enum([
|
|
|
68
68
|
export type WebFetchProviderId = z.infer<typeof WebFetchProviderIdSchema>;
|
|
69
69
|
|
|
70
70
|
export const WebSearchResultItemSchema = z.object({
|
|
71
|
+
/** 1-indexed. */
|
|
71
72
|
rank: z.number(),
|
|
72
73
|
title: z.string(),
|
|
73
74
|
url: z.string(),
|
|
75
|
+
/** The lowercased host. */
|
|
74
76
|
domain: z.string(),
|
|
75
77
|
faviconUrl: z.string().optional(),
|
|
78
|
+
/** Absent for `anthropic-native`, whose content is encrypted. */
|
|
76
79
|
snippet: z.string().optional(),
|
|
80
|
+
/** A freshness hint; Brave only. */
|
|
77
81
|
age: z.string().optional(),
|
|
82
|
+
/** Tavily only. */
|
|
78
83
|
score: z.number().optional(),
|
|
79
84
|
});
|
|
80
85
|
|
|
@@ -216,7 +216,7 @@ Examples:
|
|
|
216
216
|
name: "key",
|
|
217
217
|
type: "string",
|
|
218
218
|
description:
|
|
219
|
-
'The key to press (e.g. "Enter", "
|
|
219
|
+
'The key or modifier chord to press (e.g. "Enter", "Meta+v", "Control+a").',
|
|
220
220
|
required: true,
|
|
221
221
|
},
|
|
222
222
|
{
|
|
@@ -238,6 +238,7 @@ the key is dispatched to that element; otherwise to the focused element.
|
|
|
238
238
|
Examples:
|
|
239
239
|
$ assistant browser press-key --key Enter
|
|
240
240
|
$ assistant browser press-key --key Tab --element-id e5
|
|
241
|
+
$ assistant browser press-key --key "Meta+v"
|
|
241
242
|
$ assistant browser press-key --key Escape`,
|
|
242
243
|
},
|
|
243
244
|
{
|
|
@@ -12,13 +12,16 @@ describe("createBargeInGuard", () => {
|
|
|
12
12
|
expect(guard.track("speech", 100)).toBe("pending");
|
|
13
13
|
expect(guard.track("speech", 100)).toBe("pending");
|
|
14
14
|
expect(guard.speechMs).toBe(200);
|
|
15
|
+
expect(guard.fired).toBe(false);
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
test("sustained speech reaching the threshold fires once and stays fired", () => {
|
|
18
19
|
const guard = createBargeInGuard(250);
|
|
19
20
|
guard.track("speech", 200);
|
|
20
21
|
expect(guard.track("speech", 50)).toBe("fired");
|
|
22
|
+
expect(guard.fired).toBe(true);
|
|
21
23
|
expect(guard.track("silence", 1_000)).toBe("fired");
|
|
24
|
+
expect(guard.fired).toBe(true);
|
|
22
25
|
});
|
|
23
26
|
|
|
24
27
|
test("a brief sub-threshold gap does not reset the run", () => {
|
|
@@ -974,6 +974,22 @@ describe("startVoiceTurn triage-and-escalate control prompt", () => {
|
|
|
974
974
|
expect(installed()).toContain(frontDoorDecisionRule({ includeHold: true }));
|
|
975
975
|
});
|
|
976
976
|
|
|
977
|
+
test("a hidden look follow-up routes the original request", async () => {
|
|
978
|
+
const installed = captureInstalledPrompt();
|
|
979
|
+
const callerUtterance = "Show me where to add a new page.";
|
|
980
|
+
const content = "(fresh view taken; answer from it now)";
|
|
981
|
+
await startVoiceTurn({
|
|
982
|
+
...makeTurnOptions(),
|
|
983
|
+
content,
|
|
984
|
+
routingUtterance: callerUtterance,
|
|
985
|
+
hiddenSyntheticPrompt: true,
|
|
986
|
+
voiceControlPrompt: LIVE_VOICE_PROMPT,
|
|
987
|
+
routingLeg: "front-door",
|
|
988
|
+
});
|
|
989
|
+
expect(installed()).toContain(frontDoorDecisionRule({ callerUtterance }));
|
|
990
|
+
expect(installed()).not.toContain(JSON.stringify(content));
|
|
991
|
+
});
|
|
992
|
+
|
|
977
993
|
test("appends the escalated continuation rule to a caller-supplied prompt", async () => {
|
|
978
994
|
const installed = captureInstalledPrompt();
|
|
979
995
|
await startVoiceTurn({
|
|
@@ -3449,4 +3465,22 @@ describe("startVoiceTurn escalation judge", () => {
|
|
|
3449
3465
|
expect(handle.overrule).toBeUndefined();
|
|
3450
3466
|
}
|
|
3451
3467
|
});
|
|
3468
|
+
|
|
3469
|
+
test.each([
|
|
3470
|
+
"What do you see on my screen?",
|
|
3471
|
+
"Show me where to add a new page.",
|
|
3472
|
+
])("a captured look bypasses the text-only judge: %s", async (request) => {
|
|
3473
|
+
judgeEscalationVerdict = true;
|
|
3474
|
+
const handle = await startVoiceTurn({
|
|
3475
|
+
...makeTurnOptions(),
|
|
3476
|
+
content: "(fresh view taken; answer from it now)",
|
|
3477
|
+
routingUtterance: request,
|
|
3478
|
+
routingLeg: "front-door",
|
|
3479
|
+
hiddenSyntheticPrompt: true,
|
|
3480
|
+
});
|
|
3481
|
+
|
|
3482
|
+
expect(judgeEscalationCalls).toEqual([]);
|
|
3483
|
+
expect(handle.escalationJudgement).toBeUndefined();
|
|
3484
|
+
expect(handle.overrule).toBeUndefined();
|
|
3485
|
+
});
|
|
3452
3486
|
});
|
|
@@ -55,6 +55,8 @@ export type BargeInGuardStep = "pending" | "reset" | "fired";
|
|
|
55
55
|
export interface BargeInGuard {
|
|
56
56
|
/** Speech accumulated in the current run. */
|
|
57
57
|
readonly speechMs: number;
|
|
58
|
+
/** Whether this run has met the threshold, latched until the guard is replaced. */
|
|
59
|
+
readonly fired: boolean;
|
|
58
60
|
/** Feed one classified chunk of `chunkMs` audio. */
|
|
59
61
|
track(
|
|
60
62
|
classification: BargeInChunkClassification,
|
|
@@ -82,6 +84,9 @@ export function createBargeInGuard(minSpeechMs: number): BargeInGuard {
|
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
return {
|
|
87
|
+
get fired() {
|
|
88
|
+
return fired;
|
|
89
|
+
},
|
|
85
90
|
get speechMs() {
|
|
86
91
|
return speechMs;
|
|
87
92
|
},
|
|
@@ -524,6 +524,8 @@ export interface VoiceTurnOptions {
|
|
|
524
524
|
* fixed sentinel.
|
|
525
525
|
*/
|
|
526
526
|
hiddenSyntheticPrompt?: boolean;
|
|
527
|
+
/** Original caller request resumed by a synthetic turn, used for routing. */
|
|
528
|
+
routingUtterance?: string;
|
|
527
529
|
/**
|
|
528
530
|
* Unified front-door: this leg was dispatched speculatively at a silence
|
|
529
531
|
* boundary, so its decision rule includes the hold branch (leading token
|
|
@@ -988,10 +990,8 @@ export async function startVoiceTurn(
|
|
|
988
990
|
// control markers (ASK_GUARDIAN, END_CALL, etc.) and recognize opener turns.
|
|
989
991
|
const isCallerGuardian = opts.trustContext?.trustClass === "guardian";
|
|
990
992
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
// than the marker itself.
|
|
994
|
-
const routingLegRule = routingLegRuleFor(opts, persistedContent);
|
|
993
|
+
const routingUtterance = opts.routingUtterance?.trim() || persistedContent;
|
|
994
|
+
const routingLegRule = routingLegRuleFor(opts, routingUtterance);
|
|
995
995
|
let voiceCallControlPrompt: string | null;
|
|
996
996
|
if (opts.voiceControlPrompt === undefined) {
|
|
997
997
|
voiceCallControlPrompt = buildVoiceCallControlPrompt({
|
|
@@ -1997,6 +1997,8 @@ export async function startVoiceTurn(
|
|
|
1997
1997
|
// The escalation judge runs beside the front-door leg's model call, so its
|
|
1998
1998
|
// verdict is usually in before the leg's first answer word. Snapshot the
|
|
1999
1999
|
// history now: the leg's own reply must not be part of what is judged.
|
|
2000
|
+
// Hidden fresh-view follow-ups route with their image; this text-only judge
|
|
2001
|
+
// cannot assess that context.
|
|
2000
2002
|
const escalationJudgement =
|
|
2001
2003
|
opts.routingLeg === "front-door" && !isHiddenSyntheticPrompt
|
|
2002
2004
|
? judgeEscalation({
|
|
@@ -14,6 +14,11 @@ import { onActivationToolCall } from "../activation/turn-hooks.js";
|
|
|
14
14
|
import type { AgentEvent } from "../agent/loop.js";
|
|
15
15
|
import { resolveComputerUseToolName } from "../api/computer-use-tool.js";
|
|
16
16
|
import type { AnsweredQuestion } from "../api/events/question-answered.js";
|
|
17
|
+
import type {
|
|
18
|
+
ToolActivityMetadata,
|
|
19
|
+
WebSearchMetadata,
|
|
20
|
+
WebSearchResultItem,
|
|
21
|
+
} from "../api/events/tool-result.js";
|
|
17
22
|
import type { AssistantEvent } from "../api/index.js";
|
|
18
23
|
import type {
|
|
19
24
|
TurnChannelContext,
|
|
@@ -147,11 +152,6 @@ import type {
|
|
|
147
152
|
SurfaceAction,
|
|
148
153
|
UiSurfaceShow,
|
|
149
154
|
} from "./message-protocol.js";
|
|
150
|
-
import type {
|
|
151
|
-
ToolActivityMetadata,
|
|
152
|
-
WebSearchMetadata,
|
|
153
|
-
WebSearchResultItem,
|
|
154
|
-
} from "./message-types/web-activity.js";
|
|
155
155
|
import { bestEffortModeSessionTracking } from "./mode-session-tracking.js";
|
|
156
156
|
import { referenceMediaBlocksForPersist } from "./persist-media-references.js";
|
|
157
157
|
import { buildProviderRejectionLogFields } from "./provider-rejection-log-fields.js";
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import { statSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
|
|
11
|
+
import { TrustClassSchema } from "@vellumai/gateway-client";
|
|
12
|
+
|
|
11
13
|
import {
|
|
12
14
|
getApp,
|
|
13
15
|
getAppDirPath,
|
|
@@ -81,7 +83,6 @@ import type {
|
|
|
81
83
|
import type { ContentBlock, Message } from "../providers/types.js";
|
|
82
84
|
import type { TrustClass } from "../runtime/actor-trust-resolver.js";
|
|
83
85
|
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
84
|
-
import { trustClassSchema } from "../runtime/trust-class.js";
|
|
85
86
|
import type { SubagentState } from "../subagent/types.js";
|
|
86
87
|
import { TERMINAL_STATUSES } from "../subagent/types.js";
|
|
87
88
|
import { canonicalizeInboundIdentity } from "../util/canonicalize-identity.js";
|
|
@@ -1188,7 +1189,7 @@ function placeholderForBlockType(type: ContentBlock["type"]): string | null {
|
|
|
1188
1189
|
function rowToRenderable(row: SlackTranscriptInputRow): RenderableSlackMessage {
|
|
1189
1190
|
const slackMeta = readSlackMetadataFromMessageMetadata(row.metadata);
|
|
1190
1191
|
const provenanceTrustClass = row.metadata
|
|
1191
|
-
?
|
|
1192
|
+
? TrustClassSchema.safeParse(
|
|
1192
1193
|
safeParseRecord(row.metadata).provenanceTrustClass,
|
|
1193
1194
|
).data
|
|
1194
1195
|
: undefined;
|
|
@@ -18,7 +18,6 @@ export * from "./message-types/shared.js";
|
|
|
18
18
|
export * from "./message-types/skills.js";
|
|
19
19
|
export * from "./message-types/surfaces.js";
|
|
20
20
|
export * from "./message-types/sync.js";
|
|
21
|
-
export * from "./message-types/web-activity.js";
|
|
22
21
|
|
|
23
22
|
// Client-message domain aliases for the ClientMessage union.
|
|
24
23
|
import type { _ComputerUseClientMessages } from "./message-types/computer-use.js";
|