first commit

This commit is contained in:
2026-09-11 13:37:34 -04:00
commit 0f00e11823
27 changed files with 802 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { ComputerUseSession } from '../computer-use/session.js';
test('computer use requires an explicit grant and enforces its step budget', () => {
let now = 1000;
const session = new ComputerUseSession({ stepsMax: 2, clock: () => now });
assert.throws(() => session.beginStep(), /inactive/);
assert.deepEqual(session.grant({ persist: true }).restore_token_present, true);
session.beginStep();
session.beginStep();
assert.throws(() => session.beginStep(), /budget/);
assert.equal(session.status().steps_used, 2);
session.revoke();
assert.equal(session.status().active, false);
now += 1;
});
test('computer use expires its wall clock grant', () => {
let now = 0;
const session = new ComputerUseSession({ clock: () => now });
session.grant();
now = 180001;
assert.throws(() => session.beginStep(), /expired/);
assert.equal(session.status().backend, 'none');
});