Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { computerObservation } from "./computer-support.js";
|
|
import { observationToolResult, parseComputerActions } from "./computer-tools.js";
|
|
|
|
describe("computer tool bridge", () => {
|
|
it("normalizes a bounded batch into provider-neutral actions", () => {
|
|
expect(
|
|
parseComputerActions([
|
|
{ kind: "click", x: 20.4, y: 30.6 },
|
|
{ kind: "type", text: "hello" },
|
|
{ kind: "scroll", direction: "up", amount: 999 },
|
|
]),
|
|
).toEqual([
|
|
{ kind: "pointer", x: 20, y: 31, type: "click", button: "left" },
|
|
{ kind: "clipboard", text: "hello" },
|
|
{ kind: "scroll", direction: "up", amount: 20 },
|
|
]);
|
|
});
|
|
|
|
it("rejects batches whose expanded double-click actions exceed the limit", () => {
|
|
expect(() =>
|
|
parseComputerActions(
|
|
Array.from({ length: 13 }, () => ({ kind: "click", x: 10, y: 10, double: true })),
|
|
),
|
|
).toThrow(/more than 24/);
|
|
});
|
|
|
|
it("returns observations as model-visible image content", () => {
|
|
const observation = computerObservation(Uint8Array.from([1, 2, 3]), {
|
|
mimeType: "image/png",
|
|
width: 1280,
|
|
height: 800,
|
|
});
|
|
const result = observationToolResult(observation);
|
|
expect(result.content).toEqual([
|
|
expect.objectContaining({ type: "text" }),
|
|
{ type: "image", data: "AQID", mimeType: "image/png" },
|
|
]);
|
|
});
|
|
|
|
it("does not resend an unchanged screenshot", () => {
|
|
const observation = computerObservation(Uint8Array.from([1, 2, 3]), {
|
|
mimeType: "image/png",
|
|
width: 1280,
|
|
height: 800,
|
|
});
|
|
const result = observationToolResult(observation, "observed", observation.frameId);
|
|
|
|
expect(result.content).toEqual([
|
|
expect.objectContaining({ type: "text", text: expect.stringContaining("unchanged") }),
|
|
]);
|
|
});
|
|
});
|