Files
oh-my-pi/packages/coding-agent/test/computer-lazy-schema.test.ts
T
can1357 ef852af986 feat(computer): implemented modular desktop backend and script workflows
- Replaced monolithic desktop native bindings and action batching with a modular cross-platform backend structure supporting Wayland, X11, macOS, and Win32.
- Updated the computer tool schema and supervisor to execute persistent JavaScript script runs with timeout clamping and asynchronous tool calling.
- Integrated accessibility (AX) tree snapshotting, node querying, and bounds-based hit testing across platform desktop layers.
- Added native clipboard bindings and updated coding-agent prompts, renderers, and tests to validate script-based computer workflows.
2026-08-02 19:46:25 +02:00

45 lines
1.3 KiB
TypeScript

import { expect, test } from "bun:test";
import * as path from "node:path";
const preloadPath = path.join(import.meta.dir, "fixtures", "computer-schema-construction-preload.ts");
const probePath = path.join(import.meta.dir, "fixtures", "computer-schema-construction-probe.ts");
test("computer schema is constructed once on first parameters access", async () => {
const proc = Bun.spawn([process.execPath, "--preload", preloadPath, probePath], {
cwd: path.join(import.meta.dir, "../../.."),
stdout: "pipe",
stderr: "pipe",
});
const [stdout, stderr, exitCode] = await Promise.all([
new Response(proc.stdout).text(),
new Response(proc.stderr).text(),
proc.exited,
]);
expect(exitCode, stderr).toBe(0);
expect(JSON.parse(stdout)).toEqual({
counts: {
afterModuleImport: 0,
afterDefaultOffFactory: 0,
afterToolConstruction: 0,
afterFirstParametersAccess: 1,
afterRepeatedParametersAccess: 1,
afterSecondToolParametersAccess: 1,
afterValidation: 1,
},
disabledToolCount: 0,
schema: {
callable: true,
repeatedIdentity: true,
crossToolIdentity: true,
validAccepted: true,
validOutput: {
code: "const windows = await desktop.windows(); windows.length",
read_only: true,
timeout: 10,
},
invalidRejected: [true, true, true, true, true, true],
},
});
}, 20_000);