@vellumai/assistant 0.12.1-dev.202609141913.5e16607 → 0.12.1-dev.202609142113.d1590bc
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 +9 -9
- package/openapi.yaml +35 -2
- package/package.json +2 -1
- package/src/__tests__/anthropic-provider.test.ts +0 -63
- package/src/__tests__/assistant-event-hub-machine-name.test.ts +6 -7
- package/src/__tests__/assistant-event-hub.test.ts +44 -0
- package/src/__tests__/computer-use-skill-manifest-regression.test.ts +1 -1
- package/src/__tests__/computer-use-tools.test.ts +2 -2
- package/src/__tests__/heartbeat-service.test.ts +56 -40
- package/src/__tests__/host-cu-proxy.test.ts +539 -0
- package/src/__tests__/list-messages-camera-frame.test.ts +121 -0
- package/src/__tests__/oauth-commands-routes.test.ts +113 -0
- package/src/__tests__/oauth-provider-profiles.test.ts +18 -0
- package/src/__tests__/openai-provider.test.ts +1 -0
- package/src/__tests__/plugin-import-boundary-guard.test.ts +1 -0
- package/src/__tests__/qdrant-manager.test.ts +132 -0
- package/src/__tests__/scaffold-managed-skill-tool.test.ts +229 -6
- package/src/__tests__/skills.test.ts +9 -4
- package/src/__tests__/test-support/computer-use-skill-harness.ts +3 -2
- package/src/__tests__/unicode.test.ts +13 -0
- package/src/acp/agent-process.ts +2 -1
- package/src/agent/loop.ts +1 -0
- package/src/api/events/user-message-echo.ts +7 -1
- package/src/api/responses/conversation-message.ts +5 -0
- package/src/avatar/identity-avatar.ts +7 -2
- package/src/config/bundled-skills/computer-use/SKILL.md +20 -2
- package/src/config/bundled-skills/computer-use/TOOLS.json +99 -0
- package/src/config/bundled-skills/computer-use/tools/computer-use-sequence.ts +12 -0
- package/src/config/bundled-skills/media-processing/services/preprocess.ts +2 -1
- package/src/config/bundled-skills/media-processing/services/processing-pipeline.ts +2 -1
- package/src/config/bundled-skills/media-processing/tools/generate-clip.ts +2 -1
- package/src/config/bundled-skills/playbooks/tools/playbook-create.ts +2 -1
- package/src/config/bundled-skills/playbooks/tools/playbook-update.ts +2 -1
- package/src/config/bundled-skills/skill-management/TOOLS.json +4 -0
- package/src/config/bundled-skills/transcribe/tools/transcribe-media.ts +5 -2
- package/src/credential-health/credential-health-service.ts +11 -17
- package/src/daemon/conversation-error.ts +3 -2
- package/src/daemon/conversation-media-retry.ts +2 -1
- package/src/daemon/conversation-runtime-assembly.ts +2 -1
- package/src/daemon/conversation-surfaces.ts +5 -1
- package/src/daemon/dictation-profile-store.ts +2 -1
- package/src/daemon/handlers/shared.ts +2 -1
- package/src/daemon/handlers/skills.ts +6 -3
- package/src/daemon/host-cu-proxy.ts +186 -19
- package/src/daemon/host-proxy-preactivation.ts +2 -1
- package/src/daemon/reaction-history-render.ts +2 -1
- package/src/heartbeat/heartbeat-service.ts +21 -3
- package/src/live-voice/__tests__/live-voice-sight-frame-echo.test.ts +238 -0
- package/src/live-voice/live-voice-photo.ts +25 -6
- package/src/oauth/AGENTS.md +2 -0
- package/src/oauth/byo-connection.test.ts +60 -0
- package/src/oauth/scope-utils.ts +24 -0
- package/src/oauth/seed-providers.ts +39 -25
- package/src/persistence/conversation-queries.ts +2 -2
- package/src/persistence/embeddings/qdrant-manager.ts +163 -18
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-prompt.test.ts +5 -0
- package/src/plugins/defaults/memory/context-search/agent-runner.ts +3 -2
- package/src/plugins/defaults/memory/context-search/format.ts +3 -2
- package/src/plugins/defaults/memory/context-search/sources/memory-v2.ts +6 -3
- package/src/plugins/defaults/memory/context-search/sources/workspace.ts +3 -2
- package/src/plugins/defaults/memory/graph/capability-seed.ts +2 -1
- package/src/plugins/defaults/memory/host-utils.ts +10 -0
- package/src/plugins/defaults/memory/memory-retrospective-prompt.ts +1 -1
- package/src/plugins/defaults/memory/startup.ts +22 -1
- package/src/plugins/defaults/memory/substrate/page-index.ts +6 -1
- package/src/plugins/defaults/memory/v1/graph/consolidation.ts +4 -2
- package/src/plugins/defaults/memory/v1/graph/extraction.ts +4 -2
- package/src/plugins/defaults/memory/v1/graph/retriever.ts +4 -1
- package/src/plugins/defaults/memory/v2/reranker.ts +6 -1
- package/src/plugins/defaults/memory/v3/__tests__/card.test.ts +24 -0
- package/src/plugins/defaults/memory/v3/__tests__/pool-select.test.ts +39 -3
- package/src/plugins/defaults/memory/v3/__tests__/sections.test.ts +26 -0
- package/src/plugins/defaults/memory/v3/__tests__/shadow-plugin.test.ts +30 -0
- package/src/plugins/defaults/memory/v3/card.ts +3 -2
- package/src/plugins/defaults/memory/v3/pool-select.ts +5 -3
- package/src/plugins/defaults/memory/v3/sections.ts +9 -3
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +5 -2
- package/src/providers/__tests__/retry-outbound-sanitize.test.ts +176 -0
- package/src/providers/anthropic/client.ts +0 -47
- package/src/providers/openai/__tests__/chat-completions-output-token-limit.test.ts +141 -0
- package/src/providers/openai/chat-completions-provider.ts +20 -1
- package/src/providers/openrouter/client.ts +20 -0
- package/src/providers/outbound-request-sanitize.ts +96 -0
- package/src/providers/retry.ts +24 -3
- package/src/providers/unparseable-tool-args.ts +5 -1
- package/src/runtime/AGENTS.md +1 -1
- package/src/runtime/__tests__/host-observe.test.ts +40 -1
- package/src/runtime/agent-wake.ts +2 -1
- package/src/runtime/assistant-event-hub.ts +21 -3
- package/src/runtime/host-observe.ts +11 -1
- package/src/runtime/routes/conversation-routes.ts +16 -3
- package/src/runtime/routes/diagnostics-routes.ts +6 -1
- package/src/runtime/routes/events-routes.ts +4 -0
- package/src/runtime/routes/host-cu-routes.ts +6 -0
- package/src/runtime/routes/oauth-commands-routes.ts +36 -0
- package/src/runtime/routes/workspace-routes.test.ts +55 -26
- package/src/runtime/routes/workspace-routes.ts +46 -63
- package/src/runtime/routes/workspace-tree-walk.test.ts +244 -0
- package/src/runtime/routes/workspace-tree-walk.ts +240 -0
- package/src/runtime/routes/workspace-utils.ts +17 -0
- package/src/schedule/run-script.ts +2 -1
- package/src/schedule/schedule-store.ts +9 -2
- package/src/security/untrusted-content.ts +3 -1
- package/src/tools/__tests__/side-effect-abort-guard.test.ts +1 -0
- package/src/tools/browser/browser-execution.ts +1 -1
- package/src/tools/browser/cdp-client/accessibility-snapshot.ts +9 -3
- package/src/tools/browser/cdp-client/cdp-inspect/discovery.ts +2 -1
- package/src/tools/browser/cdp-client/extension-cdp-client.ts +3 -2
- package/src/tools/browser/network-recorder.ts +2 -1
- package/src/tools/computer-use/definitions.ts +117 -0
- package/src/tools/filesystem/search.ts +2 -1
- package/src/tools/network/web-search.ts +6 -1
- package/src/tools/skills/scaffold-managed.ts +61 -3
- package/src/types/host-capabilities.ts +5 -3
- package/src/util/unicode.ts +15 -1
- package/src/watch/watch-timeline.ts +2 -2
- package/src/workflows/run-manager.ts +2 -1
- package/src/workspace/git-service.ts +1 -1
|
@@ -42,6 +42,11 @@ const MAX_HISTORY_ENTRIES = 10;
|
|
|
42
42
|
const LOOP_DETECTION_WINDOW = 3;
|
|
43
43
|
const CONSECUTIVE_UNCHANGED_WARNING_THRESHOLD = 2;
|
|
44
44
|
|
|
45
|
+
const SEQUENCE_TOOL = "computer_use_sequence";
|
|
46
|
+
|
|
47
|
+
const SCREENSHOT_OMITTED_MESSAGE =
|
|
48
|
+
"Screenshot omitted: the accessibility tree above is current. Pass include_screenshot: true on computer_use_observe to see the screen.";
|
|
49
|
+
|
|
45
50
|
// computer_use_key combos that change only selection/cursor/clipboard state.
|
|
46
51
|
// The AX tree models none of these, so they always produce an empty diff —
|
|
47
52
|
// exempt them from the "NO VISIBLE EFFECT" signal (mirrors computer_use_wait).
|
|
@@ -113,6 +118,8 @@ export interface CuObservationResult {
|
|
|
113
118
|
executionResult?: string;
|
|
114
119
|
executionError?: string;
|
|
115
120
|
userGuidance?: string;
|
|
121
|
+
/** Per-phase helper timings in milliseconds, absent on older helpers. */
|
|
122
|
+
timings?: Record<string, number>;
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
export interface ActionRecord {
|
|
@@ -161,6 +168,40 @@ function actionSignature(record: ActionRecord): string {
|
|
|
161
168
|
return `${record.toolName}:${JSON.stringify(record.input)}`;
|
|
162
169
|
}
|
|
163
170
|
|
|
171
|
+
/**
|
|
172
|
+
* The key a desktop's first look is tracked under. An untargeted request has
|
|
173
|
+
* no client id, so it gets a key no real id can take.
|
|
174
|
+
*/
|
|
175
|
+
function observedTargetKey(targetClientId: string | undefined): string {
|
|
176
|
+
return targetClientId === undefined
|
|
177
|
+
? "\u0000untargeted"
|
|
178
|
+
: `client:${targetClientId}`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Whether `input` scopes the observation to one window or display. */
|
|
182
|
+
function hasCaptureTarget(input: Record<string, unknown>): boolean {
|
|
183
|
+
return (
|
|
184
|
+
Object.hasOwn(input, "capture_window_id") ||
|
|
185
|
+
Object.hasOwn(input, "captureWindowId") ||
|
|
186
|
+
Object.hasOwn(input, "captureDisplayId")
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Whether the resolved client claimed `capability` on its connection. An
|
|
192
|
+
* untargeted request has no client to vouch for it, so it never qualifies.
|
|
193
|
+
*/
|
|
194
|
+
function clientAdvertises(
|
|
195
|
+
targetClientId: string | undefined,
|
|
196
|
+
capability: "host_cu_window_capture" | "host_cu_sequence",
|
|
197
|
+
): boolean {
|
|
198
|
+
const client =
|
|
199
|
+
targetClientId == null
|
|
200
|
+
? undefined
|
|
201
|
+
: assistantEventHub.getClientById(targetClientId);
|
|
202
|
+
return client?.capabilities.includes(capability) ?? false;
|
|
203
|
+
}
|
|
204
|
+
|
|
164
205
|
// ---------------------------------------------------------------------------
|
|
165
206
|
// HostCuProxy
|
|
166
207
|
// ---------------------------------------------------------------------------
|
|
@@ -172,8 +213,36 @@ export class HostCuProxy {
|
|
|
172
213
|
private _previousAXTree: string | undefined;
|
|
173
214
|
private _consecutiveUnchangedSteps = 0;
|
|
174
215
|
private _actionHistory: ActionRecord[] = [];
|
|
175
|
-
/**
|
|
176
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Desktops an unscoped observation has come back from since the last reset,
|
|
218
|
+
* keyed by `observedTargetKey`. A first look is per desktop: having seen one
|
|
219
|
+
* machine says nothing about another the conversation switches to.
|
|
220
|
+
*/
|
|
221
|
+
private _observedTargets = new Set<string>();
|
|
222
|
+
/**
|
|
223
|
+
* Bumped on every reset. A request carries the value it was dispatched
|
|
224
|
+
* under, so an observation that lands after a reset cannot restore state
|
|
225
|
+
* that reset cleared.
|
|
226
|
+
*/
|
|
227
|
+
private _resetGeneration = 0;
|
|
228
|
+
/**
|
|
229
|
+
* Owned request IDs mapped to whether their observation is scoped, whether
|
|
230
|
+
* the helper was told to skip the screenshot, and when the request was
|
|
231
|
+
* dispatched. The dispatch time gives the round trip, which is the part of
|
|
232
|
+
* a step the helper's own timings cannot see.
|
|
233
|
+
*/
|
|
234
|
+
private _ownedRequests = new Map<
|
|
235
|
+
string,
|
|
236
|
+
{
|
|
237
|
+
scoped: boolean;
|
|
238
|
+
screenshotSkipped: boolean;
|
|
239
|
+
targetKey: string;
|
|
240
|
+
resetGeneration: number;
|
|
241
|
+
dispatchedAt: number;
|
|
242
|
+
toolName: string;
|
|
243
|
+
step: number;
|
|
244
|
+
}
|
|
245
|
+
>();
|
|
177
246
|
|
|
178
247
|
constructor(maxSteps = loadConfig().maxStepsPerSession) {
|
|
179
248
|
this._maxSteps = maxSteps;
|
|
@@ -288,11 +357,7 @@ export class HostCuProxy {
|
|
|
288
357
|
}
|
|
289
358
|
// Never dispatch this option to a legacy executor: it would forward the
|
|
290
359
|
// unknown snake-case key and silently capture the entire desktop.
|
|
291
|
-
|
|
292
|
-
resolvedTargetClientId == null
|
|
293
|
-
? undefined
|
|
294
|
-
: assistantEventHub.getClientById(resolvedTargetClientId);
|
|
295
|
-
if (!client?.capabilities.includes("host_cu_window_capture")) {
|
|
360
|
+
if (!clientAdvertises(resolvedTargetClientId, "host_cu_window_capture")) {
|
|
296
361
|
return Promise.resolve({
|
|
297
362
|
content:
|
|
298
363
|
"Window-only observation requires a connected client advertising host_cu_window_capture; update the desktop app before retrying. No capture was requested.",
|
|
@@ -300,14 +365,40 @@ export class HostCuProxy {
|
|
|
300
365
|
});
|
|
301
366
|
}
|
|
302
367
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
368
|
+
// An older helper answers an unknown tool name as done, which would end
|
|
369
|
+
// the session with nothing run.
|
|
370
|
+
if (
|
|
371
|
+
toolName === SEQUENCE_TOOL &&
|
|
372
|
+
!clientAdvertises(resolvedTargetClientId, "host_cu_sequence")
|
|
373
|
+
) {
|
|
374
|
+
return Promise.resolve({
|
|
375
|
+
content:
|
|
376
|
+
"Batched actions require a desktop app that supports computer_use_sequence; update the desktop app, or send the actions one at a time. Nothing was run.",
|
|
377
|
+
isError: true,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
const scopedObservation = hasCaptureTarget(input);
|
|
307
381
|
if (scopedObservation) {
|
|
308
382
|
this._previousAXTree = undefined;
|
|
309
383
|
this._consecutiveUnchangedSteps = 0;
|
|
310
384
|
}
|
|
385
|
+
const targetKey = observedTargetKey(resolvedTargetClientId);
|
|
386
|
+
// Pointing never reaches the helper's capture path, so its input goes out
|
|
387
|
+
// as given. Every other request carries the screenshot decision made now,
|
|
388
|
+
// at dispatch, and never the model-facing snake_case key.
|
|
389
|
+
let dispatchInput = input;
|
|
390
|
+
let screenshotSkipped = false;
|
|
391
|
+
if (toolName !== POINT_AT_PROXY_TOOL) {
|
|
392
|
+
const { include_screenshot: _includeScreenshot, ...rest } = input;
|
|
393
|
+
screenshotSkipped = !this.shouldAttachScreenshot(
|
|
394
|
+
toolName,
|
|
395
|
+
input,
|
|
396
|
+
targetKey,
|
|
397
|
+
);
|
|
398
|
+
dispatchInput = screenshotSkipped
|
|
399
|
+
? { ...rest, includeScreenshot: false }
|
|
400
|
+
: rest;
|
|
401
|
+
}
|
|
311
402
|
const requestId = uuid();
|
|
312
403
|
|
|
313
404
|
return new Promise<ToolExecutionResult>((resolve, reject) => {
|
|
@@ -351,7 +442,15 @@ export class HostCuProxy {
|
|
|
351
442
|
detachAbort = () => signal.removeEventListener("abort", onAbort);
|
|
352
443
|
}
|
|
353
444
|
|
|
354
|
-
this._ownedRequests.set(requestId,
|
|
445
|
+
this._ownedRequests.set(requestId, {
|
|
446
|
+
scoped: scopedObservation,
|
|
447
|
+
screenshotSkipped,
|
|
448
|
+
targetKey,
|
|
449
|
+
resetGeneration: this._resetGeneration,
|
|
450
|
+
dispatchedAt: Date.now(),
|
|
451
|
+
toolName,
|
|
452
|
+
step: stepNumber,
|
|
453
|
+
});
|
|
355
454
|
|
|
356
455
|
pendingInteractions.register(requestId, {
|
|
357
456
|
conversationId,
|
|
@@ -375,7 +474,7 @@ export class HostCuProxy {
|
|
|
375
474
|
requestId,
|
|
376
475
|
conversationId,
|
|
377
476
|
toolName,
|
|
378
|
-
input,
|
|
477
|
+
input: dispatchInput,
|
|
379
478
|
stepNumber,
|
|
380
479
|
reasoning,
|
|
381
480
|
...(resolvedTargetClientId != null
|
|
@@ -403,7 +502,8 @@ export class HostCuProxy {
|
|
|
403
502
|
requestId: string,
|
|
404
503
|
observation: CuObservationResult,
|
|
405
504
|
): ToolExecutionResult | undefined {
|
|
406
|
-
const
|
|
505
|
+
const owned = this._ownedRequests.get(requestId);
|
|
506
|
+
const scopedObservation = owned?.scoped ?? false;
|
|
407
507
|
this._ownedRequests.delete(requestId);
|
|
408
508
|
const interaction = pendingInteractions.resolve(requestId, "answered");
|
|
409
509
|
if (!interaction?.rpcResolve) {
|
|
@@ -411,9 +511,33 @@ export class HostCuProxy {
|
|
|
411
511
|
return undefined;
|
|
412
512
|
}
|
|
413
513
|
|
|
514
|
+
// Label the line from what this request was dispatched with, never from
|
|
515
|
+
// current proxy state. One model response can dispatch several CU tools,
|
|
516
|
+
// and the agent loop runs them concurrently, so a later call can advance
|
|
517
|
+
// the history and the step count before an earlier observation lands.
|
|
518
|
+
// Reading them here would file each measurement under whichever tool was
|
|
519
|
+
// dispatched last, and would mislabel computer_use_point_at, which never
|
|
520
|
+
// records an action at all.
|
|
521
|
+
if (owned) {
|
|
522
|
+
log.info(
|
|
523
|
+
{
|
|
524
|
+
requestId,
|
|
525
|
+
toolName: owned.toolName,
|
|
526
|
+
step: owned.step,
|
|
527
|
+
roundTripMs: Date.now() - owned.dispatchedAt,
|
|
528
|
+
...(observation.timings ? { helper: observation.timings } : {}),
|
|
529
|
+
},
|
|
530
|
+
"Host CU step timings",
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
|
|
414
534
|
// A targeted snapshot has no comparable action/diff baseline; neither it
|
|
415
535
|
// nor the first desktop observation after it can imply "no visible effect".
|
|
416
|
-
|
|
536
|
+
// A response dispatched before the last reset belongs to a finished run,
|
|
537
|
+
// so it must not change any state the new run has started building.
|
|
538
|
+
const fromCurrentRun =
|
|
539
|
+
owned === undefined || owned.resetGeneration === this._resetGeneration;
|
|
540
|
+
if (scopedObservation && fromCurrentRun) {
|
|
417
541
|
this._previousAXTree = undefined;
|
|
418
542
|
this._consecutiveUnchangedSteps = 0;
|
|
419
543
|
}
|
|
@@ -421,10 +545,24 @@ export class HostCuProxy {
|
|
|
421
545
|
const comparableObservation = scopedObservation
|
|
422
546
|
? { ...observation, axDiff: undefined, secondaryWindows: undefined }
|
|
423
547
|
: observation;
|
|
424
|
-
|
|
548
|
+
// Pointing observes nothing, so its response leaves the screen state alone.
|
|
549
|
+
if (
|
|
550
|
+
fromCurrentRun &&
|
|
551
|
+
!scopedObservation &&
|
|
552
|
+
owned?.toolName !== POINT_AT_PROXY_TOOL
|
|
553
|
+
) {
|
|
425
554
|
this.updateStateFromObservation(comparableObservation);
|
|
555
|
+
// A desktop has had its first look only once pixels from it arrived,
|
|
556
|
+
// so a failed capture leaves the next request asking again.
|
|
557
|
+
if (owned && observation.screenshot) {
|
|
558
|
+
this._observedTargets.add(owned.targetKey);
|
|
559
|
+
}
|
|
426
560
|
}
|
|
427
|
-
const result = this.formatObservation(
|
|
561
|
+
const result = this.formatObservation(
|
|
562
|
+
comparableObservation,
|
|
563
|
+
prevAXTree,
|
|
564
|
+
owned?.screenshotSkipped ?? false,
|
|
565
|
+
);
|
|
428
566
|
interaction.rpcResolve(result);
|
|
429
567
|
return result;
|
|
430
568
|
}
|
|
@@ -460,6 +598,27 @@ export class HostCuProxy {
|
|
|
460
598
|
this._previousAXTree = undefined;
|
|
461
599
|
this._consecutiveUnchangedSteps = 0;
|
|
462
600
|
this._actionHistory = [];
|
|
601
|
+
this._observedTargets.clear();
|
|
602
|
+
this._resetGeneration++;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Whether the request about to be dispatched should carry a screenshot. The
|
|
607
|
+
* accessibility tree comes back every step. Pixels come back on the first
|
|
608
|
+
* look since the last reset, for a window- or display-scoped capture, and
|
|
609
|
+
* when the model asks for them. Otherwise whether the tree is enough is the
|
|
610
|
+
* model's call.
|
|
611
|
+
*/
|
|
612
|
+
private shouldAttachScreenshot(
|
|
613
|
+
toolName: string,
|
|
614
|
+
input: Record<string, unknown>,
|
|
615
|
+
targetKey: string,
|
|
616
|
+
): boolean {
|
|
617
|
+
return (
|
|
618
|
+
!this._observedTargets.has(targetKey) ||
|
|
619
|
+
hasCaptureTarget(input) ||
|
|
620
|
+
(toolName === "computer_use_observe" && input.include_screenshot === true)
|
|
621
|
+
);
|
|
463
622
|
}
|
|
464
623
|
|
|
465
624
|
// ---------------------------------------------------------------------------
|
|
@@ -474,6 +633,7 @@ export class HostCuProxy {
|
|
|
474
633
|
formatObservation(
|
|
475
634
|
obs: CuObservationResult,
|
|
476
635
|
previousAXTree?: string,
|
|
636
|
+
screenshotSkipped = false,
|
|
477
637
|
): ToolExecutionResult {
|
|
478
638
|
const prevTree = previousAXTree;
|
|
479
639
|
const parts: string[] = [];
|
|
@@ -552,6 +712,15 @@ export class HostCuProxy {
|
|
|
552
712
|
parts.push(...screenshotMeta);
|
|
553
713
|
}
|
|
554
714
|
|
|
715
|
+
// Only a deliberate omission is announced, and only beside a tree the line
|
|
716
|
+
// can point at. A step that asked for pixels and got none is a capture
|
|
717
|
+
// failure, which this line must not disguise. A refused or failed step
|
|
718
|
+
// still carries the line, since that is where asking for pixels helps most.
|
|
719
|
+
const isError = obs.executionError != null;
|
|
720
|
+
if (screenshotSkipped && !obs.screenshot && obs.axTree) {
|
|
721
|
+
parts.push("", SCREENSHOT_OMITTED_MESSAGE);
|
|
722
|
+
}
|
|
723
|
+
|
|
555
724
|
const content = parts.join("\n").trim() || "Action executed";
|
|
556
725
|
|
|
557
726
|
const contentBlocks: ContentBlock[] = [];
|
|
@@ -566,8 +735,6 @@ export class HostCuProxy {
|
|
|
566
735
|
});
|
|
567
736
|
}
|
|
568
737
|
|
|
569
|
-
const isError = obs.executionError != null;
|
|
570
|
-
|
|
571
738
|
return {
|
|
572
739
|
content: isError
|
|
573
740
|
? `Action failed: ${obs.executionError}\n\n${content}`
|
|
@@ -105,12 +105,13 @@ export const HOST_PROXY_SKILL_PREACTIVATIONS: ReadonlyArray<{
|
|
|
105
105
|
*/
|
|
106
106
|
/**
|
|
107
107
|
* Capabilities a client asks for on its connection rather than getting from
|
|
108
|
-
* what it is.
|
|
108
|
+
* what it is. Each rides the host_cu transport and is answered only by a
|
|
109
109
|
* macOS build new enough to send the header (`events-routes.ts`), so the
|
|
110
110
|
* interface alone cannot say whether one is really there.
|
|
111
111
|
*/
|
|
112
112
|
const NEGOTIATED_CAPABILITIES: ReadonlySet<HostProxyCapability> = new Set([
|
|
113
113
|
"host_cu_window_capture",
|
|
114
|
+
"host_cu_sequence",
|
|
114
115
|
"host_cu_annotate",
|
|
115
116
|
]);
|
|
116
117
|
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
unwrapExternalContentForDisplay,
|
|
29
29
|
wrapUntrustedContent,
|
|
30
30
|
} from "../security/untrusted-content.js";
|
|
31
|
+
import { safeStringSlice } from "../util/unicode.js";
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Slack-style emoji names render in colon form. Anything else (a unicode
|
|
@@ -53,7 +54,7 @@ function snippetOf(text: string): string {
|
|
|
53
54
|
if (flat.length <= TARGET_SNIPPET_MAX_CHARS) {
|
|
54
55
|
return flat;
|
|
55
56
|
}
|
|
56
|
-
return `${flat
|
|
57
|
+
return `${safeStringSlice(flat, 0, TARGET_SNIPPET_MAX_CHARS)}...`;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/**
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
|
|
4
|
+
import { channelForBotProvider } from "@vellumai/service-contracts/channels";
|
|
5
|
+
|
|
4
6
|
import type { HeartbeatAlertEvent } from "../api/events/heartbeat-alert.js";
|
|
5
7
|
import { getConfig } from "../config/loader.js";
|
|
6
8
|
import type { HeartbeatConfig } from "../config/schemas/heartbeat.js";
|
|
@@ -55,6 +57,19 @@ const DEFAULT_CHECKLIST = `- Check in with yourself. Read NOW.md. Is it still ac
|
|
|
55
57
|
const EARLY_HEARTBEAT_THRESHOLD = 3;
|
|
56
58
|
const REENGAGEMENT_COOLDOWN_MS = 18 * 60 * 60 * 1000; // 18 hours
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* A provider key named by the identity it carries. The keys alone do not say
|
|
62
|
+
* which is which (`slack` is the integration acting as the connected person,
|
|
63
|
+
* `slack_channel` is the assistant's own bot), and a heartbeat told to avoid
|
|
64
|
+
* "slack" would otherwise stop posting through a bot whose credential is fine.
|
|
65
|
+
*/
|
|
66
|
+
function describeUnhealthyProvider(providerKey: string): string {
|
|
67
|
+
const channel = channelForBotProvider(providerKey);
|
|
68
|
+
return channel
|
|
69
|
+
? `${providerKey} (the ${channel} channel bot)`
|
|
70
|
+
: `${providerKey} (integration, acts as the connected person)`;
|
|
71
|
+
}
|
|
72
|
+
|
|
58
73
|
// Stripped-comment form of the guardian persona scaffold. Computed
|
|
59
74
|
// once at module load because stripping comment lines is deterministic
|
|
60
75
|
// and the template itself is a compile-time constant.
|
|
@@ -945,10 +960,13 @@ ${checklist}
|
|
|
945
960
|
</heartbeat-checklist>`;
|
|
946
961
|
|
|
947
962
|
if (unhealthyProviders.length > 0) {
|
|
948
|
-
const providers = unhealthyProviders
|
|
963
|
+
const providers = unhealthyProviders
|
|
964
|
+
.map(describeUnhealthyProvider)
|
|
965
|
+
.join(", ");
|
|
949
966
|
prompt += `\n\n<credential-status>
|
|
950
|
-
The following
|
|
951
|
-
Do NOT attempt to use tools for these providers
|
|
967
|
+
The following credentials are broken or expired: ${providers}.
|
|
968
|
+
Do NOT attempt to use tools for these providers, they will fail. Skip any checklist items that depend on them and note the outage in your summary.
|
|
969
|
+
A channel bot is the assistant's own identity on a channel and a separate credential from the integration of the same name; it is affected only when listed here as a channel bot.
|
|
952
970
|
</credential-status>`;
|
|
953
971
|
}
|
|
954
972
|
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { describe, expect, mock, spyOn, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createMockProvider,
|
|
5
|
+
textResponse,
|
|
6
|
+
} from "../../__tests__/helpers/mock-provider.js";
|
|
7
|
+
import { setConfig } from "../../__tests__/helpers/set-config.js";
|
|
8
|
+
import { waitFor } from "../../__tests__/helpers/wait-for.js";
|
|
9
|
+
|
|
10
|
+
setConfig("memory", { enabled: false });
|
|
11
|
+
|
|
12
|
+
import { UserMessageEchoEventSchema } from "../../api/events/user-message-echo.js";
|
|
13
|
+
import type { AssistantEventEnvelope } from "../../api/index.js";
|
|
14
|
+
import { Conversation } from "../../daemon/conversation.js";
|
|
15
|
+
import * as conversationMessaging from "../../daemon/conversation-messaging.js";
|
|
16
|
+
import {
|
|
17
|
+
deleteConversation,
|
|
18
|
+
setConversation,
|
|
19
|
+
} from "../../daemon/conversation-registry.js";
|
|
20
|
+
import { conversationMessagesSyncTag } from "../../daemon/message-types/sync.js";
|
|
21
|
+
import { uploadAttachment } from "../../persistence/attachments-store.js";
|
|
22
|
+
import * as conversationCrud from "../../persistence/conversation-crud.js";
|
|
23
|
+
import { initializeDb } from "../../persistence/db-init.js";
|
|
24
|
+
import { assistantEventHub } from "../../runtime/assistant-event-hub.js";
|
|
25
|
+
import {
|
|
26
|
+
_drainFrameReclaimRechecksForTests,
|
|
27
|
+
_pendingFrameReclaimCountForTests,
|
|
28
|
+
persistAmbientSightFrame,
|
|
29
|
+
persistLiveVoicePhoto,
|
|
30
|
+
} from "../live-voice-photo.js";
|
|
31
|
+
import { LiveVoiceSession } from "../live-voice-session.js";
|
|
32
|
+
import { createLiveVoiceServerFrameSequencer } from "../protocol.js";
|
|
33
|
+
|
|
34
|
+
await initializeDb();
|
|
35
|
+
|
|
36
|
+
function createHarness() {
|
|
37
|
+
const row = conversationCrud.createConversation("Camera frame echo");
|
|
38
|
+
const { provider } = createMockProvider([textResponse("")]);
|
|
39
|
+
const conversation = new Conversation(
|
|
40
|
+
row.id,
|
|
41
|
+
provider,
|
|
42
|
+
"system prompt",
|
|
43
|
+
() => {},
|
|
44
|
+
"/tmp",
|
|
45
|
+
{ maxTokens: 4096 },
|
|
46
|
+
);
|
|
47
|
+
conversation.setTrustContext({
|
|
48
|
+
trustClass: "guardian",
|
|
49
|
+
sourceChannel: "vellum",
|
|
50
|
+
});
|
|
51
|
+
setConversation(row.id, conversation);
|
|
52
|
+
|
|
53
|
+
const sequencer = createLiveVoiceServerFrameSequencer();
|
|
54
|
+
const startVoiceTurn = mock(async () => ({
|
|
55
|
+
turnId: "turn-123",
|
|
56
|
+
abort: mock(),
|
|
57
|
+
}));
|
|
58
|
+
const session = new LiveVoiceSession(
|
|
59
|
+
{
|
|
60
|
+
sessionId: "session-123",
|
|
61
|
+
startFrame: {
|
|
62
|
+
type: "start",
|
|
63
|
+
conversationId: row.id,
|
|
64
|
+
audio: { mimeType: "audio/pcm", sampleRate: 24_000, channels: 1 },
|
|
65
|
+
},
|
|
66
|
+
sendFrame: async (payload) => sequencer.next(payload),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
resolveTranscriber: async () => ({
|
|
70
|
+
providerId: "deepgram",
|
|
71
|
+
boundaryId: "daemon-streaming",
|
|
72
|
+
async start() {},
|
|
73
|
+
sendAudio() {},
|
|
74
|
+
stop() {},
|
|
75
|
+
}),
|
|
76
|
+
startVoiceTurn,
|
|
77
|
+
emitMetrics: false,
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
const published: {
|
|
81
|
+
event: AssistantEventEnvelope;
|
|
82
|
+
persistedIds: string[];
|
|
83
|
+
persistedSeq: number | null;
|
|
84
|
+
}[] = [];
|
|
85
|
+
const subscription = assistantEventHub.subscribe({
|
|
86
|
+
type: "process",
|
|
87
|
+
filter: { conversationId: row.id },
|
|
88
|
+
callback: (event) => {
|
|
89
|
+
if (
|
|
90
|
+
(event.message.type === "user_message_echo" &&
|
|
91
|
+
event.message.conversationId === row.id) ||
|
|
92
|
+
(event.message.type === "sync_changed" &&
|
|
93
|
+
event.message.tags.includes(conversationMessagesSyncTag(row.id)))
|
|
94
|
+
) {
|
|
95
|
+
published.push({
|
|
96
|
+
event,
|
|
97
|
+
persistedIds: conversationCrud.getMessages(row.id).map((m) => m.id),
|
|
98
|
+
persistedSeq: conversationCrud.getConversationPersistedSeq(row.id),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
conversationId: row.id,
|
|
106
|
+
session,
|
|
107
|
+
startVoiceTurn,
|
|
108
|
+
published,
|
|
109
|
+
async dispose() {
|
|
110
|
+
subscription.dispose();
|
|
111
|
+
await session.close("client_end");
|
|
112
|
+
deleteConversation(row.id);
|
|
113
|
+
conversation.dispose();
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function uploadFrame(): Promise<string> {
|
|
119
|
+
const attachment = await uploadAttachment(
|
|
120
|
+
"frame.png",
|
|
121
|
+
"image/png",
|
|
122
|
+
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk",
|
|
123
|
+
);
|
|
124
|
+
return attachment.id;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function expectAnnouncement(
|
|
128
|
+
harness: ReturnType<typeof createHarness>,
|
|
129
|
+
cameraFrame: boolean,
|
|
130
|
+
): Promise<void> {
|
|
131
|
+
await waitFor(() => harness.published.length >= 2);
|
|
132
|
+
expect(harness.published.map(({ event }) => event.message.type)).toEqual([
|
|
133
|
+
"user_message_echo",
|
|
134
|
+
"sync_changed",
|
|
135
|
+
]);
|
|
136
|
+
const [echo, sync] = harness.published;
|
|
137
|
+
const message = UserMessageEchoEventSchema.parse(echo.event.message);
|
|
138
|
+
const rows = conversationCrud.getMessages(harness.conversationId);
|
|
139
|
+
expect(rows).toHaveLength(1);
|
|
140
|
+
expect(message.messageId).toBe(rows[0].id);
|
|
141
|
+
expect(echo.persistedIds).toEqual([rows[0].id]);
|
|
142
|
+
expect(echo.event.seq).toBeNumber();
|
|
143
|
+
expect(sync.persistedSeq).toBe(echo.event.seq!);
|
|
144
|
+
expect(message.text).toBe(cameraFrame ? "(camera frame)" : "here's a photo:");
|
|
145
|
+
if (cameraFrame) {
|
|
146
|
+
expect(message.cameraFrame).toBe(true);
|
|
147
|
+
} else {
|
|
148
|
+
expect(echo.event.message).not.toHaveProperty("cameraFrame");
|
|
149
|
+
}
|
|
150
|
+
expect(harness.startVoiceTurn).not.toHaveBeenCalled();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
describe("standalone image echoes", () => {
|
|
154
|
+
test.each(["sight_frame", "attach_image"] as const)(
|
|
155
|
+
"%s emits one committed row before the history invalidation",
|
|
156
|
+
async (type) => {
|
|
157
|
+
const harness = createHarness();
|
|
158
|
+
try {
|
|
159
|
+
await harness.session.start();
|
|
160
|
+
const attachmentId = await uploadFrame();
|
|
161
|
+
await harness.session.handleClientFrame({ type, attachmentId });
|
|
162
|
+
await expectAnnouncement(harness, type === "sight_frame");
|
|
163
|
+
} finally {
|
|
164
|
+
await harness.dispose();
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
test.each([
|
|
170
|
+
{ kind: "sight_frame", deferred: false },
|
|
171
|
+
{ kind: "photo", deferred: false },
|
|
172
|
+
{ kind: "sight_frame", deferred: true },
|
|
173
|
+
] as const)(
|
|
174
|
+
"$kind preserves its echo marker when a committed write throws (deferred: $deferred)",
|
|
175
|
+
async ({ kind, deferred }) => {
|
|
176
|
+
const harness = createHarness();
|
|
177
|
+
const realPersist = conversationMessaging.persistQueuedMessageBody;
|
|
178
|
+
const realGetMessage = conversationCrud.getMessageById;
|
|
179
|
+
let committed = false;
|
|
180
|
+
const persist = spyOn(
|
|
181
|
+
conversationMessaging,
|
|
182
|
+
"persistQueuedMessageBody",
|
|
183
|
+
).mockImplementation(async (...args) => {
|
|
184
|
+
await realPersist(...args);
|
|
185
|
+
committed = true;
|
|
186
|
+
throw new Error("Post-insert write failed");
|
|
187
|
+
});
|
|
188
|
+
const read = spyOn(conversationCrud, "getMessageById").mockImplementation(
|
|
189
|
+
(...args) => {
|
|
190
|
+
if (deferred && committed) {
|
|
191
|
+
throw new Error("Store temporarily unreadable");
|
|
192
|
+
}
|
|
193
|
+
return realGetMessage(...args);
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
try {
|
|
197
|
+
const attachmentId = await uploadFrame();
|
|
198
|
+
const result =
|
|
199
|
+
kind === "sight_frame"
|
|
200
|
+
? await persistAmbientSightFrame(
|
|
201
|
+
harness.conversationId,
|
|
202
|
+
attachmentId,
|
|
203
|
+
"voice",
|
|
204
|
+
)
|
|
205
|
+
: await persistLiveVoicePhoto(harness.conversationId, attachmentId);
|
|
206
|
+
expect(result.ok).toBe(!deferred);
|
|
207
|
+
if (deferred) {
|
|
208
|
+
expect(harness.published).toHaveLength(0);
|
|
209
|
+
expect(_pendingFrameReclaimCountForTests()).toBe(1);
|
|
210
|
+
_drainFrameReclaimRechecksForTests();
|
|
211
|
+
expect(_pendingFrameReclaimCountForTests()).toBe(1);
|
|
212
|
+
read.mockRestore();
|
|
213
|
+
_drainFrameReclaimRechecksForTests();
|
|
214
|
+
_drainFrameReclaimRechecksForTests();
|
|
215
|
+
expect(_pendingFrameReclaimCountForTests()).toBe(0);
|
|
216
|
+
}
|
|
217
|
+
await expectAnnouncement(harness, kind === "sight_frame");
|
|
218
|
+
} finally {
|
|
219
|
+
persist.mockRestore();
|
|
220
|
+
read.mockRestore();
|
|
221
|
+
_drainFrameReclaimRechecksForTests();
|
|
222
|
+
await harness.dispose();
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
test("the strict echo schema accepts only a true camera marker", () => {
|
|
228
|
+
const echo = { type: "user_message_echo", text: "(camera frame)" };
|
|
229
|
+
expect(
|
|
230
|
+
UserMessageEchoEventSchema.safeParse({ ...echo, cameraFrame: false })
|
|
231
|
+
.success,
|
|
232
|
+
).toBe(false);
|
|
233
|
+
expect(
|
|
234
|
+
UserMessageEchoEventSchema.safeParse({ ...echo, unexpected: true })
|
|
235
|
+
.success,
|
|
236
|
+
).toBe(false);
|
|
237
|
+
});
|
|
238
|
+
});
|