Fix libei
Rolling release / release (push) Successful in 9m40s

This commit is contained in:
2026-09-12 11:07:40 -04:00
parent b8c60e4326
commit 5b7c2b3b6d
20 changed files with 671 additions and 79 deletions
+17
View File
@@ -1,11 +1,13 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import { ComputerUseSession } from '../computer-use/session.js';
import { ComputerActuator } from '../computer-use/actuator.js';
import { ComputerAudit } from '../computer-use/audit.js';
import { mkdtemp, readFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
test('computer use requires an explicit grant and enforces its step budget', () => {
let now = 1000;
@@ -30,6 +32,13 @@ test('computer use expires its wall clock grant', () => {
assert.equal(session.status().backend, 'none');
});
test('computer use records portal-notify as a live backend', () => {
const session = new ComputerUseSession();
session.grant();
assert.equal(session.setBackend('portal-notify'), 'portal-notify');
assert.equal(session.status().backend, 'portal-notify');
});
test('computer use semantic actuation previews, budgets, and audits actions', async () => {
const dir = await mkdtemp(path.join(tmpdir(), 'jarvis-cu-audit-'));
const audit = new ComputerAudit({ dir }); const session = new ComputerUseSession({ stepsMax: 1, audit }); const sent = [];
@@ -44,3 +53,11 @@ test('computer use refuses password targets and unconfirmed dangerous keys', asy
await assert.rejects(() => actuator.type({ ref: 'password', text: 'secret' }), /password/);
await assert.rejects(() => actuator.key({ combo: 'alt+f4' }), /confirmation/);
});
test('libei sender binds bitmask capabilities from libei.h', () => {
const pyDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../computer-use/py');
const compiled = spawnSync('python3', ['-m', 'py_compile', 'libei_sender.py', 'portal_remote_desktop.py', 'portal_screenshot.py'], { cwd: pyDir, encoding: 'utf8' });
assert.equal(compiled.status, 0, compiled.stderr);
const caps = spawnSync('python3', ['-c', 'from libei_sender import CAP_POINTER, CAP_KEYBOARD, CAP_BUTTON, F_KEYS; assert CAP_POINTER == 1 and CAP_KEYBOARD == 4 and CAP_BUTTON == 32 and F_KEYS["f11"] == 87'], { cwd: pyDir, encoding: 'utf8' });
assert.equal(caps.status, 0, caps.stderr);
});