fix: preserve model state, isolate commands and harden local HTTP in 1.12.1

This commit is contained in:
Agent Workbench Dev
2026-10-30 23:01:19 +08:00
parent c1e9575259
commit f4bd0ad8dc
26 changed files with 373 additions and 68 deletions
+19
View File
@@ -17,9 +17,28 @@ test('the bundled local service enforces host, origin, token and JSON object con
await assert.rejects(server.api('/sessions', null), { status: 400 });
assert.equal(server.bootstrap.capabilities.commands, 'per-call-approval');
const page = await fetch(server.url); assert.equal(page.status, 200); assert.match(await page.text(), /Agent Workbench/);
assert.equal(page.headers.get('x-frame-options'), 'DENY');
assert.equal(page.headers.get('referrer-policy'), 'no-referrer');
assert.match(page.headers.get('content-security-policy'), /script-src 'self'/);
assert.match(page.headers.get('content-security-policy'), /frame-ancestors 'none'/);
await server.close();
});
test('an in-flight connection probe prevents configuration changes and another probe until its actual result returns', async t => {
const f = fixture(t), host = await launchWorkbench(t, f.data); f.onCleanup(host.close);
let release;
const model = await compatibleFixture(t, async () => { await new Promise(resolve => { release = resolve; }); return { choices: [{ message: { role: 'assistant', content: 'OK' } }] }; });
await host.api('/config', { mode: 'compatible', model: 'owned-probe-model', baseUrl: model.baseUrl, apiKey: 'owned-probe-fixture' });
const probing = host.api('/config/test', {});
await until(() => !!release);
await assert.rejects(host.api('/config', { mode: 'demo' }), { status: 409 });
await assert.rejects(host.api('/config/test', {}), { status: 409 });
await assert.rejects(host.api('/model-center/connections', { name: 'Blocked', model: 'owned-model', baseUrl: model.baseUrl }), { status: 409 });
assert.equal(model.requests.length, 1); assert.equal((await host.api('/bootstrap')).config.model, 'owned-probe-model');
release(); assert.equal((await probing).ok, true);
assert.equal((await host.api('/config', { mode: 'demo', model: 'owned-probe-model', baseUrl: model.baseUrl })).mode, 'demo');
});
test('API review applies verified content, detects conflicts, exports sessions and keeps keys in memory', async t => {
const f = fixture(t), server = await launchWorkbench(t, f.data); f.onCleanup(server.close);
const project = await server.api('/projects', { root: f.projectRoot });