fix: retain browser splitter drag and gate release 1.22 on actual browser flows

This commit is contained in:
Agent Workbench Dev
2026-11-02 03:50:27 +08:00
parent dc32c899f1
commit 4697c3954a
14 changed files with 244 additions and 48 deletions
+1
View File
@@ -15,6 +15,7 @@ const prefixes = Object.freeze({
'1.20.0': 'engineering-evals',
'1.20.1': 'task-control',
'1.21.0': 'reproducible-env',
'1.22.0': 'embedded-browser',
});
export function releaseEvidencePrefix(version) {
const prefix = prefixes[version];
+1 -1
View File
@@ -64,7 +64,7 @@ export async function upgradeRunning({ url, pid, currentRoot, newRoot, handlerRo
if (!fs.existsSync(originalScript) || !fs.existsSync(upgradeScript) || !fs.existsSync(path.join(next, 'dist-client', 'index.html'))) throw new Error('Upgrade bundles are incomplete.');
if (!Number.isInteger(pid) || pid < 1 || pid === process.pid) throw new Error('Invalid target process.');
const before = await readUpgradeJson(origin + '/api/bootstrap', 5000, 'Read original Workbench');
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.20.2', '1.20.3', '1.21.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
if (!before.token || !['0.1.0', '1.0.0', '1.1.0', '1.2.0', '1.3.0', '1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.20.2', '1.20.3', '1.21.0', '1.22.0'].includes(before.version)) throw new Error('This migration accepts a supported existing Workbench.');
if (before.sessions.some(session => ['running', 'awaiting_approval', 'stopping'].includes(session.status))) throw new Error('Wait for existing tasks and approvals before upgrading.');
let protocol, socket, enabledHere = false, paused = false;
const breakpoints = [];
+17 -16
View File
@@ -9,32 +9,33 @@ import { randomUUID } from 'node:crypto';
if (process.argv.slice(2).some(value => value !== '--help')) throw new Error('Unsupported argument; use --help.');
if (process.argv.includes('--help')) { console.log('node scripts/verify-all-ui.mjs - run serial desktop/390px checks in independent local hosts; use explicit QA Python/Harness/Purge source paths for 1.15.'); process.exit(0); }
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version), 'Review evidence paths when introducing the next release.');
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version), 'Review evidence paths when introducing the next release.');
const prefix = releaseEvidencePrefix(version), resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
const qaEnvironment = Object.fromEntries(['AGENT_WORKBENCH_TEST_PYTHON', 'AGENT_WORKBENCH_DEEPSEEK_ROOT', 'AGENT_WORKBENCH_PURGE_178_ROOT', 'AGENT_WORKBENCH_PURGE_181_ROOT']
.filter(name => process.env[name]).map(name => [name, process.env[name]]));
for (const [name, value] of Object.entries(qaEnvironment)) assert.ok(path.isAbsolute(value) && fs.existsSync(value), 'Use an existing absolute QA runtime/source path: ' + name);
const cases = [
...(['1.21.0'].includes(version)?[['verify-environment-ui.mjs',null],['verify-model-fidelity-ui.mjs',null],['verify-model-wait-ui.mjs',null],['verify-task-control-ui.mjs',null]]:[]),
...(['1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-evaluations-ui.mjs', null]] : []),
...(['1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-project-cache-ui.mjs', null]] : []),
...(['1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-vision-ui.mjs', null]] : []),
...(['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-model-protocols-ui.mjs', null]] : []),
...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-companion-ui.mjs', null]] : []),
...(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-controlled-ui.mjs', null], ['verify-purge-ui.mjs', null]] : []),
...(['1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-workers-ui.mjs', null]] : []),
...(['1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-task-plans-ui.mjs', `docs/${prefix}-task-ui-validation.json`]] : []),
...(['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-browser-ui.mjs', `docs/${prefix}-browser-ui-validation.json`]] : []),
...(['1.22.0'].includes(version)?[['verify-embedded-browser.mjs',null]]:[]),
...(['1.21.0', '1.22.0'].includes(version)?[['verify-environment-ui.mjs',null],['verify-model-fidelity-ui.mjs',null],['verify-model-wait-ui.mjs',null],['verify-task-control-ui.mjs',null]]:[]),
...(['1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-evaluations-ui.mjs', null]] : []),
...(['1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-project-cache-ui.mjs', null]] : []),
...(['1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-vision-ui.mjs', null]] : []),
...(['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-model-protocols-ui.mjs', null]] : []),
...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-companion-ui.mjs', null]] : []),
...(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-controlled-ui.mjs', null], ['verify-purge-ui.mjs', null]] : []),
...(['1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-workers-ui.mjs', null]] : []),
...(['1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-task-plans-ui.mjs', `docs/${prefix}-task-ui-validation.json`]] : []),
...(['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-browser-ui.mjs', `docs/${prefix}-browser-ui-validation.json`]] : []),
['verify-ui.mjs', '.qa/ui-validation.json'], ['verify-diagnostics-ui.mjs', '.qa/diagnostics-ui-validation.json'],
['verify-execution-ui.mjs', '.qa/execution-ui-validation.json'], ['verify-delivery-ui.mjs', '.qa/delivery-ui-validation.json'],
['verify-index-ui.mjs', '.qa/index-ui-result.json'], ['verify-change-sets-ui.mjs', `docs/${prefix}-batch-ui-validation.json`],
['verify-context-ui.mjs', `.qa/${version === '1.6.0' ? 'workspaces-context' : prefix}-ui-validation.json`],
['verify-workspaces-ui.mjs', `docs/${prefix === 'workspaces' ? prefix : prefix + '-workspaces'}-ui-validation.json`],
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
...(['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
...(['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? [['verify-engines-ui.mjs', version === '1.9.0' ? 'docs/engines-ui-validation.json' : `docs/${prefix}-engines-ui-validation.json`]] : []),
...(['1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0'].includes(version) ? ['model-center', 'project-memory', 'task-checkpoints', 'skills', 'mcp', 'mcp-recovery'].map(name => [`verify-${name}-ui.mjs`, null]) : []),
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : `docs/${prefix}-react-delivery-validation.json`]] : []),
...(['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
...(['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? [['verify-engines-ui.mjs', version === '1.9.0' ? 'docs/engines-ui-validation.json' : `docs/${prefix}-engines-ui-validation.json`]] : []),
...(['1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.21.0', '1.22.0'].includes(version) ? ['model-center', 'project-memory', 'task-checkpoints', 'skills', 'mcp', 'mcp-recovery'].map(name => [`verify-${name}-ui.mjs`, null]) : []),
];
fs.mkdirSync('.qa', { recursive: true });
const externalHost = new Set(['verify-ui.mjs', 'verify-diagnostics-ui.mjs', 'verify-execution-ui.mjs', 'verify-index-ui.mjs']);
+65
View File
@@ -0,0 +1,65 @@
import fs from 'node:fs';
import path from 'node:path';
import http from 'node:http';
import https from 'node:https';
import { X509Certificate } from 'node:crypto';
import assert from 'node:assert/strict';
import { chromium, expect } from 'playwright/test';
// This helper checks the real mobile shell against the same host, observation
// and original PNG as the actual Electron test. The loopback relay verifies
// the gateway CA on every request; it neither installs trust nor bypasses TLS.
export async function verifyBrowsingMobile({ controller, session, root, record }) {
let browser, relay, cookie = '', gateway;
const errors = [];
const post=(route,input)=>controller.api(route,{method:'POST',input});
try {
const status = await controller.api('/companion'); assert.equal(status.enabled, false); assert.ok(status.addresses.length);
const address = status.addresses[0].address, reservation = http.createServer();
await new Promise(resolve => reservation.listen(0, address, resolve)); const port = reservation.address().port;
await new Promise(resolve => reservation.close(resolve));
gateway = await post('/companion/start', { address, port });
const certificate = await fetch(controller.url + '/api/companion/certificate', { headers: { 'X-Workbench-Token': controller.token } });
assert.equal(certificate.status, 200); const ca = new X509Certificate(Buffer.from(await certificate.arrayBuffer())).toString();
const pair = await post('/companion/pair', { projectIds: [session.projectId], permissions: { observe: true, approve: true, stop: true }, expiresInHours: 1 });
const target = new URL(gateway.origin);
relay = http.createServer((request, response) => {
const forwarded = https.request(new URL(request.url, target), { method: request.method, ca, servername: '', headers: {
Host: target.host, Origin: target.origin, Connection: 'close', ...(cookie ? { Cookie: cookie } : {}),
...(request.headers['content-type'] ? { 'Content-Type': request.headers['content-type'] } : {}) } }, incoming => {
if (incoming.headers['set-cookie']?.length) cookie = incoming.headers['set-cookie'][0].split(';')[0];
const headers = { ...incoming.headers }; delete headers['set-cookie']; response.writeHead(incoming.statusCode, headers); incoming.pipe(response);
});
forwarded.on('error', () => { if (response.headersSent) response.destroy(); else { response.writeHead(503); response.end('Owned TLS relay failed'); } });
request.pipe(forwarded);
});
await new Promise(resolve => relay.listen(0, '127.0.0.1', resolve));
const url = 'http://127.0.0.1:' + relay.address().port;
browser = await chromium.launch({ channel: 'msedge', headless: true });
const context = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true, serviceWorkers: 'block' });
const mobile = await context.newPage(); mobile.on('pageerror', error => errors.push(error.message));
await mobile.goto(url + '/#pair=' + new URLSearchParams(new URL(pair.url).hash.slice(1)).get('pair'));
await mobile.getByRole('button', { name: '连接这台电脑', exact: true }).click();
await mobile.locator('.mobile-task-row').filter({ hasText: session.title }).click();
const observation = mobile.locator('.mobile-input-image').filter({ has: mobile.getByRole('heading', { name: '电脑网页原观察', exact: true }) });
await expect(observation).toContainText('SHA-256 已核对');
await observation.getByText('查看原页面截图', { exact: true }).click(); await expect(observation.getByRole('img')).toBeVisible();
assert.equal(await mobile.evaluate(() => document.documentElement.scrollWidth > innerWidth), false);
await mobile.screenshot({ path: path.join(root, 'phone-original-browser-observation.png'), fullPage: true });
record('390px mobile shell verifies and displays the same actual Electron original PNG through CA-verified TLS', { nativeIPhone: 'pending', trustChanged: false });
await mobile.route('**/browser-observations/*/image', async route => { const response = await route.fetch(); await route.fulfill({ response, headers: { ...response.headers(), 'x-content-sha256': '0'.repeat(64) } }); });
await mobile.reload(); await mobile.locator('.mobile-task-row').filter({ hasText: session.title }).click();
await expect(observation).toContainText('原网页截图SHA-256核对失败'); await expect(observation.getByRole('img')).toHaveCount(0);
await mobile.screenshot({ path: path.join(root, 'phone-browser-digest-rejected.png'), fullPage: true });
record('mobile digest mismatch shows failure and never displays unverified screenshot');
const devices = (await controller.api('/companion')).devices; assert.equal(devices.length, 1);
await post('/companion/devices/' + devices[0].id + '/revoke', { revision: devices[0].revision });
await mobile.getByRole('button', { name: '刷新任务', exact: true }).click();
await expect(mobile.getByRole('heading', { name: '接续电脑上的任务', exact: true })).toBeVisible(); await expect(mobile.getByRole('img')).toHaveCount(0);
record('mobile device revocation removes original browser observation and task content'); assert.deepEqual(errors, []);
} finally {
if (browser) await browser.close();
if (relay) await new Promise(resolve => { relay.closeAllConnections(); relay.close(resolve); });
if (gateway) await post('/companion/close', {});
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ export async function verifyControlledApi({ api, url, token, directory, appRoot,
const origin = new URL(url);
assert.equal(origin.hostname, '127.0.0.1'); assert.notEqual(origin.port, '4318');
const expectedVersion = JSON.parse(fs.readFileSync(path.join(appRoot, fs.existsSync(path.join(appRoot, 'MANIFEST.json')) ? 'MANIFEST.json' : 'package.json'), 'utf8')).version;
assert.ok(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.20.2', '1.20.3', '1.21.0'].includes(expectedVersion));
assert.ok(['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1', '1.20.2', '1.20.3', '1.21.0', '1.22.0'].includes(expectedVersion));
const bootstrap = await api('/bootstrap'); assert.equal(bootstrap.version, expectedVersion);
assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
const root = path.join(directory, 'compiled-controlled-node'), hooks = path.join(directory, 'disabled-hooks');
+98
View File
@@ -0,0 +1,98 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { randomUUID, createHash } from 'node:crypto';
import { _electron, expect } from 'playwright/test';
import { fixture, until } from '../tests/helpers.mjs';
import { previewProject, freePreviewPort } from '../tests/fixtures/preview-project.mjs';
import { HostController } from '../src/core/desktop/host-controller.mjs';
import { desktopExecutableIdentity } from '../src/core/desktop/app-installation.mjs';
import { projectEnvironment } from '../src/core/process-environment.mjs';
import { execFileSync } from 'node:child_process';
import { verifyBrowsingMobile } from './verify-browsing-mobile.mjs';
if(process.argv.includes('--help')) { console.log('node scripts/verify-embedded-browser.mjs [--app-root <absolute package>] [--native-review] — actual Electron + owned React/Vite + 390px mobile original observation; no real model or production state.'); process.exit(0); }
const options=process.argv.slice(2).filter(value=>value!=='--native-review');
assert.ok(options.length===0||options.length===2&&options[0]==='--app-root'&&path.isAbsolute(options[1]));
const appRoot=fs.realpathSync.native(options[1]??process.cwd()),root=path.resolve('.qa','embedded-browser-'+randomUUID());fs.mkdirSync(root,{recursive:true});
const nodePath=options[1]?path.join(appRoot,'runtime/node.exe'):process.execPath;assert.ok(fs.existsSync(nodePath));
const hash=bytes=>createHash('sha256').update(bytes).digest('hex');
const files=(folder,relative='')=>fs.readdirSync(path.join(folder,relative),{withFileTypes:true}).sort((a,b)=>a.name.localeCompare(b.name)).flatMap(entry=>entry.isDirectory()?files(folder,path.join(relative,entry.name)):[path.join(relative,entry.name)]);
const inputNames=['dist-client','dist-server','dist-desktop',...['src','tests','scripts'].filter(folder=>fs.existsSync(path.join(appRoot,folder)))].flatMap(folder=>files(path.join(appRoot,folder)).map(name=>path.join(folder,name))).concat(['package.json','package-lock.json','MANIFEST.json'].filter(name=>fs.existsSync(path.join(appRoot,name))));
const inputSnapshot=()=>inputNames.map(name=>({path:name.replaceAll('\\','/'),bytes:fs.statSync(path.join(appRoot,name)).size,sha256:hash(fs.readFileSync(path.join(appRoot,name)))}));
const inputs=inputSnapshot();let sourceCommit=null,verifierSourceState='archive-without-git';try{sourceCommit=execFileSync('git',['rev-parse','HEAD'],{encoding:'utf8',windowsHide:true}).trim();verifierSourceState=execFileSync('git',['status','--porcelain','--','src','scripts','tests','package.json','package-lock.json'],{encoding:'utf8',windowsHide:true}).trim()?'modified-source-with-exact-input-manifest':'clean';}catch{}
fs.writeFileSync(path.join(root,'inputs.json'),JSON.stringify({sourceCommit,verifierSourceState,appRoot,inputs},null,2));
const cleanups=[],f=fixture({after:callback=>cleanups.push(callback)}),p=await previewProject(f);
fs.writeFileSync(path.join(p.root,'index.html'),'<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><title>所属React真实预览</title></head><body><div id="root"></div><script type="module" src="/src.jsx"></script></body></html>');
const source=`import React,{useState} from 'react';import{createRoot}from'react-dom/client';function App(){const[name,setName]=useState(''),[saved,setSaved]=useState('尚未保存');return <main style={{padding:32,fontFamily:'sans-serif'}}><h1>真实React工程预览</h1><label>项目名称<input aria-label="项目名称" value={name} onChange={e=>setName(e.target.value)}/></label><button onClick={()=>setSaved('已保存:'+name)}>保存计划</button><p role="status">{saved}</p><a href="/next.html">下一页</a><button onClick={()=>window.open('https://example.com/')}>尝试新窗口</button><input aria-label="密码" type="password"/><a href="/download.txt" download>原下载链接</a></main>}createRoot(document.getElementById('root')).render(<App/>);`;
fs.writeFileSync(path.join(p.root,'src.jsx'),source);fs.writeFileSync(path.join(p.root,'next.html'),'<!doctype html><meta charset="UTF-8"><h1>所属第二页</h1><a href="/">返回</a>');
fs.writeFileSync(path.join(p.root,'download.txt'),'原下载字节\r\nowned-download\r\n');
p.session.title='内置浏览器真实验收';f.store.save(p.session);f.store.close();
const port=await freePreviewPort(),controller=new HostController({appRoot,dataRoot:f.data,port,nodePath,timeoutMs:60000});
const results=[],errors=[];let application,page,nativeId,stage='host startup',previewJob,version=null;
const record=(name,detail={})=>{results.push({name,passed:true,...detail});console.log(name+': passed');};
async function nativeReview(label){if(!process.argv.includes('--native-review'))return;const pending=path.join(root,'native-review-'+label+'.json'),release=path.join(root,'native-continue-'+label);fs.writeFileSync(pending,JSON.stringify({label,pid:await application.evaluate(()=>process.pid),root}));console.log('NATIVE_REVIEW '+pending);while(!fs.existsSync(release))await new Promise(resolve=>setTimeout(resolve,300));}
const api=async(action,input)=>{const response=await fetch(controller.url+'/api/sessions/'+p.session.id+'/'+action,{method:input===undefined?'GET':'POST',headers:{'X-Workbench-Token':controller.token,'Content-Type':'application/json'},body:input===undefined?undefined:JSON.stringify(input),signal:AbortSignal.timeout(45000)});const value=await response.json();if(!response.ok)throw Object.assign(new Error('HTTP '+response.status+': '+value.error),{status:response.status});return value;};
const state=()=>controller.api('/sessions/'+p.session.id);
async function capture(name){
const native=await application.browserWindow(page),png=await native.evaluate(async win=>(await win.capturePage()).toPNG().toString('base64'));
const filename=path.join(root,name+'.png');fs.writeFileSync(filename,Buffer.from(png,'base64'));fs.writeFileSync(path.join(root,name+'.html'),await page.content());
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);return filename;
}
async function site(code){return application.evaluate(async({webContents},{id,code})=>{const contents=webContents.fromId(id);if(!contents)throw new Error('Original native contents ended');return contents.executeJavaScript(code);},{id:nativeId,code});}
async function nativeVisible(){return application.evaluate(({BrowserWindow},id)=>BrowserWindow.getAllWindows()[0].contentView.children.some(view=>view.webContents?.id===id&&view.getVisible()),nativeId);}
async function observe(){await api('browsing/tabs/'+(await currentTab()).id+'/observe',{});return currentObservation();}
async function currentTab(){return(await api('browsing')).tabs.filter(tab=>tab.status==='open').at(-1);}
async function currentObservation(){const snapshot=await api('browsing'),tab=snapshot.tabs.filter(tab=>tab.status==='open').at(-1);return snapshot.observations.find(value=>value.id===tab?.observationId);}
async function act(input){const tab=await currentTab(),observation=await currentObservation();return api('browsing/tabs/'+tab.id+'/act',{...input,observationId:observation.id,revision:observation.revision,approved:true});}
function save(extra){const receipt={schemaVersion:1,kind:'actual-electron-owned-preview',root,appRoot,version,nodePath,nodeSha256:hash(fs.readFileSync(nodePath)),stage,results,checks:results,errors,realModelRequests:0,sourceCommit,verifierSourceState,inputManifestSha256:hash(fs.readFileSync(path.join(root,'inputs.json'))),screenshots:'BrowserWindow images show the main renderer only. Independent native WebContents requires native OS screenshots or the original observation PNG.',...extra};fs.writeFileSync(path.join(root,'result.json'),JSON.stringify(receipt,null,2));fs.writeFileSync('.qa/embedded-browser-latest.json',JSON.stringify(receipt,null,2));}
try{
const host=await controller.start(),executable=desktopExecutableIdentity(appRoot).path,packaged=executable.toLowerCase().endsWith('agentworkbench.exe');version=(await controller.health()).version;
application=await _electron.launch({executablePath:executable,args:[...(packaged?[]:[path.join(appRoot,'dist-desktop/main.cjs')]),'--app-root',appRoot,'--data-root',f.data,'--node',nodePath,'--port',String(port),'--hidden-window'],cwd:appRoot,env:projectEnvironment(),timeout:60000});
page=await application.firstWindow();page.on('pageerror',error=>errors.push(error.message));await page.locator('.connection.connected').waitFor({timeout:30000});
const native=await application.browserWindow(page);await native.evaluate(win=>{win.showInactive();win.setContentSize(1440,1000);});
await page.getByRole('combobox',{name:'当前项目',exact:true}).selectOption(p.project.id);await page.getByRole('button',{name:'查看任务记录',exact:true}).click();
stage='owned Vite UI plan';const service=page.getByRole('region',{name:'项目开发预览'});await service.getByRole('spinbutton',{name:'预览端口'}).fill(String(p.port));await service.getByRole('button',{name:'创建启动计划',exact:true}).click();
await service.getByRole('button',{name:'核对并批准预览',exact:true}).click();await expect(page.getByRole('dialog',{name:'确认项目预览'})).toContainText('Vite 配置');await capture('desktop-preview-approval');
await page.getByRole('button',{name:'确认启动预览',exact:true}).click();await until(async()=>{previewJob=(await state()).execution.previewJobs.at(-1);return previewJob&&!['queued','starting'].includes(previewJob.status);},40000);assert.equal(previewJob.status,'ready',JSON.stringify(previewJob));
record('actual owned React/Vite UI approval, OS listener identity and HTTP readiness',{hostPid:host.identity.pid,previewPid:previewJob.process.pid});
await service.getByRole('button',{name:'打开浏览区',exact:true}).click();await page.getByRole('button',{name:'打开目标',exact:true}).click();await expect(page.getByLabel('浏览目标地址')).toHaveValue(previewJob.url);await page.getByRole('button',{name:'确认授权并打开',exact:true}).click();
await expect(page.getByRole('dialog')).toHaveCount(0,{timeout:30000});stage='native page';await until(async()=>!!(await currentTab()),30000);
nativeId=await application.evaluate(({webContents},origin)=>webContents.getAllWebContents().find(value=>value.getURL().startsWith(origin))?.id,new URL(previewJob.url).origin);assert.ok(nativeId);
await until(()=>site("document.querySelector('h1')?.textContent==='真实React工程预览'"),20000);await until(nativeVisible,10000);
assert.deepEqual(await site("({node:typeof require,process:typeof process,bridge:typeof window.desktopWorkbench})"),{node:'undefined',process:'undefined',bridge:'undefined'});
assert.equal(await site(`fetch(${JSON.stringify(controller.url+'/api/bootstrap')}).then(()=>false,()=>true)`),true);
record('same actual native page, isolated Node/preload and blocked workbench API');
stage='resize and zoom';const separator=page.getByRole('separator',{name:'调整检视区宽度'}),separatorBox=await separator.boundingBox(),beforeWidth=await page.locator('.inspector').evaluate(node=>node.getBoundingClientRect().width);
await page.mouse.move(separatorBox.x+3,separatorBox.y+80);await page.mouse.down();await until(async()=>!await nativeVisible());await page.mouse.move(separatorBox.x-110,separatorBox.y+80);await page.mouse.up();await until(nativeVisible);
assert.ok(await page.locator('.inspector').evaluate(node=>node.getBoundingClientRect().width)>beforeWidth+90);
await separator.focus();await page.keyboard.press('ArrowLeft');await expect(separator).toHaveAttribute('aria-valuenow',String(Math.round(beforeWidth+145)));
await native.evaluate(win=>win.webContents.setZoomFactor(1.25));await until(async()=>await nativeVisible());
await until(async()=>{const box=await page.locator('.native-browser-slot').boundingBox(),bounds=await application.evaluate(({BrowserWindow},id)=>BrowserWindow.getAllWindows()[0].contentView.children.find(view=>view.webContents?.id===id)?.getBounds(),nativeId);return bounds&&Math.abs(bounds.x-Math.round(box.x*1.25))<=2&&Math.abs(bounds.width-Math.floor(box.width*1.25))<=2;});
await native.evaluate(win=>win.webContents.setZoomFactor(1));await until(nativeVisible);record('drag and keyboard width adjustment, native occlusion during drag and 125% zoom geometry');
await capture('desktop-native-browser');await nativeReview('desktop');
stage='real React input action';let observation=await observe(),input=observation.controls.find(value=>value.label==='项目名称');assert.ok(input);
await act({action:'fill',ref:input.ref,value:'专业工作台验收'});observation=await currentObservation();let button=observation.controls.find(value=>value.label==='保存计划');await act({action:'click',ref:button.ref});
assert.equal(await site("document.querySelector('[role=status]').textContent"),'已保存:专业工作台验收');record('fixed original-control fill and click operate real React controlled state');
stage='stale page';observation=await observe();await site("document.querySelector('h1').textContent='人工更改的页面'");
await assert.rejects(api('browsing/tabs/'+(await currentTab()).id+'/act',{action:'click',ref:button.ref,observationId:observation.id,revision:observation.revision,approved:true}),/409/);
assert.match((await api('browsing')).actions.at(-1).error,/变化/);
record('actual DOM mutation invalidates previous observation without submitting');
stage='HMR';fs.writeFileSync(path.join(p.root,'src.jsx'),source.replace('真实React工程预览','热更新后的React预览'));await until(()=>site("document.querySelector('h1')?.textContent==='热更新后的React预览'"),20000);await observe();record('actual source update reaches same native WebContents through Vite live reload');
stage='phone original observation';await verifyBrowsingMobile({controller,session:await state(),root,record});
stage='modal visibility';await page.getByRole('button',{name:'打开目标',exact:true}).click();await until(async()=>!await nativeVisible(),8000);await capture('native-hidden-for-modal');await page.getByRole('dialog').getByRole('button',{name:'取消',exact:true}).click();await until(nativeVisible,8000);record('native page hides for main-window authorization modal and restores');
stage='popup';let before=await application.evaluate(({webContents})=>webContents.getAllWebContents().length);await site("[...document.querySelectorAll('button')].find(value=>value.textContent==='尝试新窗口').click()");assert.equal(await application.evaluate(({webContents})=>webContents.getAllWebContents().length),before);record('unapproved popup is denied in actual Electron');
stage='navigation';observation=await observe();const link=observation.controls.find(value=>value.label==='下一页');await act({action:'click',ref:link.ref});await until(()=>site("document.querySelector('h1')?.textContent==='所属第二页'"));await act({action:'back'});await until(()=>site("document.querySelector('h1')?.textContent==='热更新后的React预览'"));await act({action:'forward'});assert.equal(await site("document.querySelector('h1').textContent"),'所属第二页');await act({action:'back'});record('actual native navigation, back and forward preserve original scoped receipts');
stage='download';await observe();await act({action:'download',url:previewJob.url+'download.txt'});const downloaded=(await api('browsing')).actions.findLast(value=>value.downloadArtifactId);assert.ok(downloaded?.downloadSha256);record('explicit exact-URL download keeps original binary artifact and SHA',{sha256:downloaded.downloadSha256});
stage='profile isolation';await site("document.cookie='awb_ephemeral=private;SameSite=Lax'");const firstTab=await currentTab(),firstNativeId=nativeId;
await api('browsing/tabs',{url:previewJob.url,previewJobId:previewJob.id,interact:true,persistent:true,approved:true});let second=await currentTab();nativeId=await application.evaluate(({webContents},{origin,first})=>webContents.getAllWebContents().find(value=>value.id!==first&&value.getURL().startsWith(origin))?.id,{origin:new URL(previewJob.url).origin,first:firstNativeId});
assert.equal(await site("document.cookie.includes('awb_ephemeral')"),false);await site("document.cookie='awb_persistent=stored;Max-Age=3600;SameSite=Lax'");await api('browsing/tabs/'+second.id+'/close',{approved:true});
await api('browsing/tabs',{url:previewJob.url,previewJobId:previewJob.id,profileId:second.profileId,interact:true,approved:true});second=await currentTab();nativeId=await application.evaluate(({webContents},{origin,first})=>webContents.getAllWebContents().find(value=>value.id!==first&&value.getURL().startsWith(origin))?.id,{origin:new URL(previewJob.url).origin,first:firstNativeId});assert.equal(await site("document.cookie.includes('awb_persistent=stored')"),true);
await api('browsing/tabs/'+second.id+'/clear',{approved:true});assert.equal(await application.evaluate(async({session},id)=>(await session.fromPartition('persist:awb-browsing-'+id).cookies.get({})).length,second.profileId),0);nativeId=firstNativeId;assert.equal(await site("document.cookie.includes('awb_ephemeral=private')"),true);record('actual independent temporary/persistent sessions, explicit reuse and selective cookie/storage/cache revocation');
stage='mobile';await native.evaluate(win=>win.setContentSize(390,844));await until(()=>page.evaluate(()=>innerWidth===390));await page.getByRole('button',{name:'查看任务记录',exact:true}).click();await page.getByRole('button',{name:'浏览',exact:true}).click();await until(nativeVisible,10000);await capture('mobile-native-browser');await nativeReview('mobile');
await page.getByRole('button',{name:'打开目标',exact:true}).click();await until(async()=>!await nativeVisible());await capture('mobile-authorize-modal');await page.getByRole('dialog').getByRole('button',{name:'取消',exact:true}).click();await page.getByRole('button',{name:'返回任务',exact:true}).click();await until(async()=>!await nativeVisible());record('390px native geometry, modal occlusion and return-to-task with no horizontal overflow');
stage='close view';await native.evaluate(win=>win.setContentSize(1440,1000));await page.getByRole('button',{name:'浏览',exact:true}).click();await until(nativeVisible);await page.getByRole('button',{name:'关闭浏览标签页',exact:true}).click();await until(async()=>!(await currentTab()));assert.equal((await state()).execution.previewJobs.at(-1).status,'ready');record('closing actual view leaves owned development service running');
stage='host lifetime';await application.close();application=null;assert.equal((await controller.health()).pid,host.identity.pid);assert.equal((await state()).execution.previewJobs.at(-1).status,'ready');await api('preview-jobs/'+previewJob.id+'/stop',{});assert.equal((await state()).execution.previewJobs.at(-1).status,'stopped');record('window close retains host and preview; explicit service stop confirms original process tree');
assert.deepEqual(errors,[]);assert.deepEqual(inputSnapshot(),inputs,'Verification inputs changed during the actual browser flow');stage='complete';save({passed:true,success:true});console.log('EVIDENCE '+root);console.log(JSON.stringify({passed:true,root,groups:results.length}));
}catch(error){if(application&&page)await capture('original-failure').catch(()=>{});if(await controller.health()){fs.writeFileSync(path.join(root,'original-session.json'),JSON.stringify(await state(),null,2));fs.writeFileSync(path.join(root,'original-browsing.json'),JSON.stringify(await api('browsing'),null,2));}save({passed:false,error:error.stack});console.error(JSON.stringify({passed:false,stage,root,error:error.message}));process.exitCode=1;}
finally{if(application)await application.close().catch(()=>{});if(await controller.health())await controller.stop();for(const cleanup of cleanups.reverse())await cleanup();}
+7 -7
View File
@@ -34,7 +34,7 @@ for (const name of Object.keys(env)) if (name.toLowerCase() === 'path') delete e
const windowsRoot = process.env.SystemRoot || 'C:\\Windows';
env.PATH = [windowsRoot, path.join(windowsRoot, 'System32'), path.join(windowsRoot, 'System32', 'WindowsPowerShell', 'v1.0')].join(path.delimiter);
let externalGit = null;
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version)) {
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(manifest.version)) {
// The controlled project requires external Git. Preserve its observed binary
// directory while keeping system Node/npm unavailable to the packaged host.
const binary = fs.realpathSync.native(execFileSync('where.exe', ['git.exe'], { env: gitEnvironment(), encoding: 'utf8', windowsHide: true, timeout: 10000 }).trim().split(/\r?\n/)[0]);
@@ -88,7 +88,7 @@ try {
console.log((await launch()).trim());
assert.equal(JSON.parse(fs.readFileSync(path.join(data, 'service-info.json'), 'utf8')).pid, firstInfo.pid);
const example = bootstrap.projects.find(project => project.id === bootstrap.exampleProjectId);
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version)) {
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(manifest.version)) {
assert.equal(path.resolve(example.root).toLowerCase(), path.join(data, 'projects', 'starter-project').toLowerCase());
const compareTemplate = relative => { for (const entry of fs.readdirSync(path.join(appRoot, 'examples/starter-project', relative), { withFileTypes: true })) {
const next = path.join(relative, entry.name); if (entry.isDirectory()) compareTemplate(next);
@@ -114,7 +114,7 @@ try {
const checkLog = await api('/artifacts/' + checked.results[0].logArtifactId + '?session=' + session.id); assert.match(checkLog.content, /tests 4/);
assert.ok(fs.existsSync(path.join(appRoot, 'runtime/node_modules/npm/bin/npm-cli.js')));
const actualRea = [];
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version)) {
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(manifest.version)) {
const installation = await api('/research/availability'); assert.equal(installation.status, 'available'); assert.equal(installation.version, '6.8.0');
assert.equal(fs.realpathSync.native(installation.packageRoot), fs.realpathSync.native(path.join(appRoot, 'runtime/node_modules/rea-agents')));
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
@@ -146,7 +146,7 @@ try {
console.log('PASS actual contained REA: ASAR, PE imports and PE resources; zero target execution/model requests');
}
let actualEngine = null;
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version) && process.argv.includes('--native-engines')) {
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(manifest.version) && process.argv.includes('--native-engines')) {
const installation = await api('/engines/deepseek/availability'); assert.equal(installation.status, 'available', installation.message);
assert.equal(fs.realpathSync.native(installation.node.path), fs.realpathSync.native(path.join(appRoot, 'runtime/node.exe')));
const engineRoot = path.join(data, 'engine-project'); fs.mkdirSync(engineRoot); fs.writeFileSync(path.join(engineRoot, 'README.md'), '# Owned portable engine connection\n');
@@ -166,8 +166,8 @@ try {
assert.equal((await api('/research')).length, 4);
const page = await fetch(url); assert.equal(page.status, 200);
assert.match(await page.text(), /Agent Workbench/);
const actualBrowser = ['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version) ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualControlled = ['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version) ? await verifyControlledApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualBrowser = ['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(manifest.version) ? await verifyBrowserApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
const actualControlled = ['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(manifest.version) ? await verifyControlledApi({ api, url, token: bootstrap.token, directory: data, appRoot, contained: true }) : null;
console.log((await stop()).trim()); started = false;
await until(async () => { try { await fetch(url + '/api/health'); return false; } catch { return true; } });
for (const file of manifest.files) {
@@ -176,7 +176,7 @@ try {
}
const result = { success: true, date: new Date().toISOString(), appRoot, version: manifest.version, nodeVersion: manifest.nodeVersion,
verifiedFiles: manifest.files.length, url, reusedPid: firstInfo.pid, checks: { jobId, status: checked.status, tests: checked.results[0].tests }, actualRea, actualEngine, actualBrowser, actualControlled, externalGit,
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(manifest.version) ? ['starter project copied to owned user data; original template bytes matched'] : []), 'explicit command consent', 'actual bundled Node version', 'actual bundled npm check without system Node/npm', 'check log artifact', ...(actualRea.length ? ['contained REA installation and Node identity', 'actual ASAR/imports/resources', 'original Bundle and target hash binding', 'verified reuse without producer replay'] : []), 'report availability', 'graceful stop', 'every original packaged file remains unchanged'], realModel: false };
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(manifest.version) ? ['starter project copied to owned user data; original template bytes matched'] : []), 'explicit command consent', 'actual bundled Node version', 'actual bundled npm check without system Node/npm', 'check log artifact', ...(actualRea.length ? ['contained REA installation and Node identity', 'actual ASAR/imports/resources', 'original Bundle and target hash binding', 'verified reuse without producer replay'] : []), 'report availability', 'graceful stop', 'every original packaged file remains unchanged'], realModel: false };
fs.writeFileSync('.qa/release-validation.json', JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));
} finally { if (started) { try { await stop(); } catch {} } }
+28 -18
View File
@@ -19,7 +19,7 @@ assert.ok(fs.existsSync(npmCli), 'Use Node with its bundled npm.');
const files = (root, relative = '') => fs.readdirSync(path.join(root, relative), { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))
.flatMap(entry => entry.isDirectory() ? files(root, path.join(relative, entry.name)) : [path.join(relative, entry.name)]);
const digest = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex');
const buildFolders = ['dist-client', 'dist-server', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version) ? ['dist-desktop'] : [])];
const buildFolders = ['dist-client', 'dist-server', ...(['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version) ? ['dist-desktop'] : [])];
const expected = Object.fromEntries(buildFolders.flatMap(folder => files(path.join(workspace, folder)).map(relative => [path.join(folder, relative), digest(path.join(workspace, folder, relative))])));
const allowedEnv = /^(path|pathext|systemroot|systemdrive|windir|comspec|temp|tmp|userprofile|homedrive|homepath|home|appdata|localappdata|programfiles(?:\(x86\))?|commonprogramfiles(?:\(x86\))?|lang|lc_all|AGENT_WORKBENCH_TEST_PYTHON|AGENT_WORKBENCH_DEEPSEEK_ROOT|AGENT_WORKBENCH_PURGE_ROOT)$/i;
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => allowedEnv.test(key)));
@@ -30,7 +30,7 @@ const directory = path.join(sourceRoot, '.qa', 'package-validation-' + randomUUI
fs.mkdirSync(directory, { recursive: true });
const inputFolders = ['src', 'tests', 'scripts', ...['benchmarks', 'public', 'examples', 'research'].filter(folder => fs.existsSync(path.join(sourceRoot, folder)))];
const inputNames = [...inputFolders.flatMap(folder => files(path.join(sourceRoot, folder)).map(relative => path.join(folder, relative))),
'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', ...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version) ? ['mobile.html'] : []), ...['.gitattributes', '.gitignore', 'Start-Desktop.cmd', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'].filter(name => fs.existsSync(path.join(sourceRoot, name)))].sort();
'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', ...(['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version) ? ['mobile.html'] : []), ...['.gitattributes', '.gitignore', 'Start-Desktop.cmd', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'].filter(name => fs.existsSync(path.join(sourceRoot, name)))].sort();
const snapshot = () => inputNames.map(relative => ({ path: relative.replaceAll('\\', '/'), bytes: fs.statSync(path.join(sourceRoot, relative)).size, sha256: digest(path.join(sourceRoot, relative)) }));
const inputs = snapshot(); fs.writeFileSync(path.join(directory, 'inputs.json'), JSON.stringify(inputs, null, 2));
let stage = 'environment preflight', python = null;
@@ -83,7 +83,7 @@ try {
assert.deepEqual(actualFiles.slice().sort(), Object.keys(expected).sort());
for (const [relative, sha256] of Object.entries(expected)) assert.equal(digest(path.join(sourceRoot, relative)), sha256, relative);
let actualRea = null;
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.8.0', '1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'contained REA';
const reaOutput = await run(['scripts/verify-rea.mjs', '--app-root', sourceRoot, '--contained'], 'rea.log');
actualRea = JSON.parse(reaOutput.trim().split('\n').at(-1));
@@ -91,7 +91,7 @@ try {
assert.ok(actualRea.results.every(item => item.rootExited === true));
}
let actualEngine = null;
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version) && process.argv.includes('--native-engines')) {
if (['1.9.0', '1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version) && process.argv.includes('--native-engines')) {
stage = 'native DeepSeek SDK';
const output = await run(['scripts/verify-engines.mjs'], 'engines.log');
actualEngine = JSON.parse(output.trim().split('\n').at(-1));
@@ -99,7 +99,7 @@ try {
assert.equal(actualEngine.modelRequests, 0); assert.equal(actualEngine.rootExited, true); assert.equal(actualEngine.nativeMethods.length, 6);
}
let actualBrowser = null;
if (['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.10.0', '1.10.1', '1.11.0', '1.12.0', '1.12.1', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'contained browser runtime';
const output = await run(['scripts/verify-browser.mjs', '--app-root', sourceRoot, '--contained'], 'browser.log');
actualBrowser = JSON.parse(output.trim().split('\n').at(-1));
@@ -109,7 +109,7 @@ try {
assert.equal(actualBrowser.modelRequests, 0);
}
let actualControlled = null;
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'compiled controlled-engine delivery';
const output = await run(['scripts/verify-controlled-release.mjs', '--app-root', sourceRoot], 'controlled-engine.log');
actualControlled = JSON.parse(output.trim().split('\n').at(-1));
@@ -117,7 +117,7 @@ try {
assert.equal(actualControlled.realModelRequests, 0); assert.equal(actualControlled.cases, 4); assert.ok(actualControlled.fixtureModelRequests > 0);
}
let actualCompanion = null;
if (['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'contained companion gateway and UI';
const output = await run(['scripts/verify-companion-ui.mjs', '--app-root', sourceRoot], 'companion-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -128,7 +128,7 @@ try {
assert.equal(actualCompanion.passed.length, 7); assert.deepEqual(actualCompanion.errors, []); assert.equal(actualCompanion.realModelRequests, 0);
}
let actualProtocols = null;
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'contained model protocols and mobile streams';
const output = await run(['scripts/verify-model-protocols-ui.mjs', '--app-root', sourceRoot], 'model-protocols-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -139,7 +139,7 @@ try {
assert.equal(actualProtocols.passed.length, 5); assert.deepEqual(actualProtocols.pageErrors, []); assert.deepEqual(actualProtocols.requestFailures, []);
}
let actualVision = null;
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'contained screenshot inputs and exact Task budget resume';
const output = await run(['scripts/verify-vision-ui.mjs', '--app-root', sourceRoot], 'vision-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -150,7 +150,7 @@ try {
assert.equal(actualVision.passed.length, 5); assert.deepEqual(actualVision.pageErrors, []); assert.equal(actualVision.realModelRequests, 0);
}
let actualProjectCache = null;
if (['1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'contained source-verified parsing cache controls';
const output = await run(['scripts/verify-project-cache-ui.mjs', '--app-root', sourceRoot], 'project-cache-ui.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -161,7 +161,7 @@ try {
assert.equal(actualProjectCache.realModelRequests, 0); assert.deepEqual(actualProjectCache.pageErrors, []);
}
let actualEnvironment = null, actualEnvironmentEngineering = null;
if (evidence.version === '1.21.0') {
if (['1.21.0','1.22.0'].includes(evidence.version)) {
stage = 'contained environment approval, stop and recovery UI';
const output = await run(['scripts/verify-environment-ui.mjs', '--app-root', sourceRoot], 'environment-ui.log');
const summary = JSON.parse(output.trim().split(/\r?\n/).findLast(line => line.startsWith('{"success":')));
@@ -178,6 +178,16 @@ try {
assert.equal(actualEnvironmentEngineering.reactCandidate, 'passed'); assert.equal(actualEnvironmentEngineering.reactTests, 9);
assert.equal(actualEnvironmentEngineering.pythonTests, 2); assert.equal(actualEnvironmentEngineering.realModelRequests, 0);
}
let actualEmbeddedBrowser = null;
if (evidence.version === '1.22.0') {
stage = 'actual embedded Electron, Vite and original mobile observation';
await run(['scripts/verify-embedded-browser.mjs', '--app-root', sourceRoot], 'embedded-browser.log');
actualEmbeddedBrowser = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/embedded-browser-latest.json'), 'utf8'));
assert.equal(actualEmbeddedBrowser.success, true); assert.equal(actualEmbeddedBrowser.version, evidence.version);
assert.equal(fs.realpathSync.native(actualEmbeddedBrowser.appRoot), sourceRoot); assert.equal(actualEmbeddedBrowser.checks.length, 17);
assert.equal(fs.realpathSync.native(actualEmbeddedBrowser.nodePath), path.join(sourceRoot, 'runtime', 'node.exe'));
assert.equal(actualEmbeddedBrowser.realModelRequests, 0); assert.deepEqual(actualEmbeddedBrowser.errors, []);
}
// Only this file opens the fixed inspector port. Run it separately so another
// test's child host can never compete for that port during the full suite.
const testFiles = files(path.join(sourceRoot, 'tests')).filter(file => !file.includes(path.sep) && file.endsWith('.test.mjs'));
@@ -205,14 +215,14 @@ try {
for (const key of ['fail', 'cancelled', 'skipped', 'todo']) assert.equal(groupStats[key], 0);
}
let actualTaskControl = null;
if (['1.20.1', '1.21.0'].includes(evidence.version)) {
if (['1.20.1', '1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'task control desktop and 390px';
await run(['scripts/verify-task-control-ui.mjs', '--app-root', sourceRoot], 'task-control-ui.log');
actualTaskControl = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/task-control-ui-validation.json'), 'utf8'));
assert.equal(actualTaskControl.success, true); assert.equal(actualTaskControl.passed.length, 5); assert.equal(actualTaskControl.realModelRequests, 0);
}
let actualDesktop = null;
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'actual contained Electron window'; await run(['scripts/verify-desktop-window.mjs'], 'desktop-window.log');
const window = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/desktop-window-latest.json'), 'utf8'));
assert.equal(window.success, true); assert.equal(path.resolve(window.appRoot), sourceRoot); assert.equal(window.results.length, 7);
@@ -226,7 +236,7 @@ try {
actualDesktop = { window, ui, projects, scope: 'Independently rebuilt source and its shipped Electron binary; original window/engine/engineering assertions. Own credentials/HTTP fixtures; Windows native picker and complete host crash/stop have separate actual evidence.' };
}
let actualProtocolEngineering = null;
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'Responses SSE actual Node React Python engineering';
await run(['scripts/verify-controlled-projects.mjs', '--responses'], 'responses-engineering.log');
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/responses-engineering-location.json'), 'utf8'));
@@ -236,7 +246,7 @@ try {
assert.deepEqual(actualProtocolEngineering.results.map(value => value.parentCheck.results[0].tests.passed), [8, 9, 10]);
}
let actualVisionEngineering = null;
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.18.0', '1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'screenshot Task Node React Python engineering';
await run(['scripts/verify-vision-projects.mjs'], 'vision-engineering.log');
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/vision-engineering-location.json'), 'utf8'));
@@ -246,7 +256,7 @@ try {
assert.deepEqual(actualVisionEngineering.results.map(value => value.check.results[0].tests.passed), [8, 9, 10]);
}
let actualCacheEngineering = null;
if (['1.19.0', '1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.19.0', '1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'cached index original requests and Node React Python engineering';
await run(['scripts/verify-project-cache-projects.mjs'], 'project-cache-engineering.log');
const location = JSON.parse(fs.readFileSync(path.join(sourceRoot, '.qa/project-cache-engineering-location.json'), 'utf8'));
@@ -256,7 +266,7 @@ try {
assert.deepEqual(actualCacheEngineering.results.map(value => value.check.results[0].tests.passed), [8, 9, 10]);
}
let actualEvaluations = null, actualEvaluationEngineering = null;
if (['1.20.0', '1.20.1','1.21.0'].includes(evidence.version)) {
if (['1.20.0', '1.20.1','1.21.0', '1.22.0'].includes(evidence.version)) {
stage = 'compiled fixed engineering evaluations';
const output = await run(['scripts/verify-evaluations-release.mjs', '--app-root', sourceRoot], 'evaluations-release.log');
const location = [...output.matchAll(/^EVIDENCE (.+)\r?$/gm)].at(-1)?.[1]?.trim();
@@ -275,7 +285,7 @@ try {
}
assert.deepEqual(snapshot(), inputs, 'Source package inputs changed during validation.');
const result = { success: true, version: evidence.version, testedAt: new Date().toISOString(), sourceRoot, directory, nodeVersion: process.version, python, offlineInstall: true,
inputs, inputFiles: inputs.length, logs, buildMatchedFiles: Object.keys(expected).length, buildFiles: Object.entries(expected).map(([path, sha256]) => ({ path: path.replaceAll('\\', '/'), sha256 })), tests: stats, testPlan, actualEnvironment, actualEnvironmentEngineering, actualTaskControl, actualRea, actualEngine, actualBrowser, actualControlled, actualDesktop, actualCompanion, actualProtocols, actualProtocolEngineering, actualVision, actualVisionEngineering, actualProjectCache, actualCacheEngineering, actualEvaluations, actualEvaluationEngineering, credentialsHandling: 'Only build/runtime environment paths are inherited; no configured model credentials are used. The controlled-engine stage supplies a declared owned local response fixture.' };
inputs, inputFiles: inputs.length, logs, buildMatchedFiles: Object.keys(expected).length, buildFiles: Object.entries(expected).map(([path, sha256]) => ({ path: path.replaceAll('\\', '/'), sha256 })), tests: stats, testPlan, actualEmbeddedBrowser, actualEnvironment, actualEnvironmentEngineering, actualTaskControl, actualRea, actualEngine, actualBrowser, actualControlled, actualDesktop, actualCompanion, actualProtocols, actualProtocolEngineering, actualVision, actualVisionEngineering, actualProjectCache, actualCacheEngineering, actualEvaluations, actualEvaluationEngineering, credentialsHandling: 'Only build/runtime environment paths are inherited; no configured model credentials are used. The controlled-engine stage supplies a declared owned local response fixture.' };
save(result); console.log(JSON.stringify({ success: true, version: result.version, sourceRoot, directory, tests: stats, nodeVersion: process.version, python, inputFiles: inputs.length, buildMatchedFiles: result.buildMatchedFiles, rea: !!actualRea?.success, engine: !!actualEngine?.success, browser: !!actualBrowser?.success, controlled: !!actualControlled?.success }));
} catch (error) {
save({ success: false, version: evidence.version, testedAt: new Date().toISOString(), stage, error: error.message, sourceRoot, directory, nodeVersion: process.version, python, inputs, logs });
+1 -1
View File
@@ -8,7 +8,7 @@ import { workerHttp } from '../tests/fixtures/workers-http.mjs';
import { workerDefinition, ownerBytes, applyWorkerProposals, approveWorkerChecks } from '../tests/fixtures/workers-project.mjs';
if (process.argv.includes('--help')) { console.log('node scripts/verify-workers-ui.mjs — owned local fixture, real isolated Git/checks/review, desktop/390px, conflicts, stop, recovery and late source errors'); process.exit(0); }
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version, prefix = version === '1.21.0' ? 'reproducible-env-workers' : version === '1.20.1' ? 'task-control-workers' : version === '1.20.0' ? 'engineering-evals-workers' : version === '1.19.0' ? 'project-cache-workers' : version === '1.18.0' ? 'vision-inputs-workers' : version === '1.17.0' ? 'model-protocols-workers' : version === '1.16.0' ? 'mobile-companion-workers' : version === '1.15.0' ? 'desktop-host-workers' : version === '1.14.0' ? 'controlled-engine-workers' : version === '1.13.0' ? 'workers' : 'workers-development';
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version, prefix = version === '1.22.0' ? 'embedded-browser-workers' : version === '1.21.0' ? 'reproducible-env-workers' : version === '1.20.1' ? 'task-control-workers' : version === '1.20.0' ? 'engineering-evals-workers' : version === '1.19.0' ? 'project-cache-workers' : version === '1.18.0' ? 'vision-inputs-workers' : version === '1.17.0' ? 'model-protocols-workers' : version === '1.16.0' ? 'mobile-companion-workers' : version === '1.15.0' ? 'desktop-host-workers' : version === '1.14.0' ? 'controlled-engine-workers' : version === '1.13.0' ? 'workers' : 'workers-development';
const directory = path.resolve('.qa', 'workers-ui-' + randomUUID()); fs.mkdirSync(directory, { recursive: true });
const disposers = [], t = { after: dispose => disposers.push(dispose) }, f = fixture(t), host = await workerHttp(f);
assert.notEqual(new URL(host.url).port, '4318');