feat: verify owned DeepSeek engine connections and responsive task execution

This commit is contained in:
Agent Workbench Dev
2026-10-30 07:25:09 +08:00
parent 1d8abaceab
commit 91981c1400
69 changed files with 4068 additions and 50 deletions
+70
View File
@@ -0,0 +1,70 @@
import fs from 'node:fs';
import path from 'node:path';
// A declared wire fixture. It does not load the third-party SDK or call a model.
export function createEngineFixture(directory, options = {}) {
fs.mkdirSync(directory, { recursive: true });
const version = '0.2.1-rc.2';
const manifests = [
['apps/cli/package.json', '@deepseek-ai/dsh'],
['packages/bundle/sdk-minimal/package.json', '@deepseek-ai/dsh-sdk-minimal'],
['packages/sdk/server/package.json', '@deepseek-ai/dsh-sdk-jsonrpc-server'],
['packages/sdk/protocol/package.json', '@deepseek-ai/dsh-sdk-protocol'],
['packages/sdk/client/package.json', '@deepseek-ai/dsh-sdk-client'],
];
const write = (relative, content) => { const filename = path.join(directory, relative); fs.mkdirSync(path.dirname(filename), { recursive: true }); fs.writeFileSync(filename, content); };
for (const [relative, name] of manifests) write(relative, JSON.stringify({ name, version, type: 'module', fixture: true }));
for (const relative of ['packages/boot/cmdline/lib/index.js', 'packages/bundle/sdk-app/lib/index.js', 'packages/sdk/server/lib/index.js', 'packages/sdk/protocol/lib/index.js']) write(relative, '// Owned protocol fixture; not the actual SDK.\n');
write('packages/bundle/sdk-minimal/cordis.patch.yml', '# Owned wire-fixture profile\n');
write('pnpm-lock.yaml', '# Owned deterministic fixture identity\n');
write('apps/cli/node_modules/@deepseek-ai/cordis/package.json', JSON.stringify({ name: '@deepseek-ai/cordis', type: 'module', exports: './index.mjs', fixture: true }));
write('apps/cli/node_modules/@deepseek-ai/cordis/index.mjs', '// Owned Cordis identity fixture; never imported.\n');
write('fixture-options.json', JSON.stringify(options));
write('apps/cli/lib/bin.js', `import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createInterface } from 'node:readline';
import { randomUUID } from 'node:crypto';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
const options = JSON.parse(fs.readFileSync(path.join(root, 'fixture-options.json'), 'utf8'));
const patch = JSON.parse(fs.readFileSync(process.argv[process.argv.indexOf('--patch') + 1], 'utf8'));
const config = patch[0].insert[0].config;
const audit = value => fs.appendFileSync(path.join(root, 'wire.jsonl'), JSON.stringify(value) + '\\n');
const send = value => process.stdout.write(JSON.stringify(value) + '\\n');
audit({ type: 'launch', cwd: process.cwd(), nodeOptionsInherited: !!process.env.NODE_OPTIONS,
secretInherited: !!process.env.OWNED_ENGINE_TEST_SECRET, profile: process.argv[process.argv.indexOf('--profile') + 1] });
if (options.mode !== 'no-ready') setTimeout(() => {
fs.writeFileSync(config.marker, JSON.stringify({ schemaVersion: 1, nonce: options.mode === 'bad-ready' ? 'wrong' : config.nonce,
pid: process.pid, signal: 'appReady', readyAt: new Date().toISOString() }), { flag: 'wx' });
}, options.readyDelayMs ?? 0);
const reader = createInterface({ input: process.stdin });
reader.on('line', async line => {
const value = JSON.parse(line); audit({ type: 'wire', value });
if (!value.method) return;
const params = value.params ?? {};
let result = {};
if (value.method === 'initialize') {
if (!fs.existsSync(config.marker)) { send({ jsonrpc: '2.0', id: value.id, error: { code: -32603, message: 'initialize before appReady' } }); return; }
if (options.mode === 'hang-init') return;
if (options.mode === 'malformed') { process.stdout.write('{broken-json}\\n'); return; }
if (options.mode === 'reverse-request') send({ jsonrpc: '2.0', id: 'reverse-control', method: 'approve-command', params: { command: 'fixture-never-executed' } });
if (options.mode === 'unowned-event') send({ jsonrpc: '2.0', method: 'session.status', params: { sessionId: randomUUID(), status: 'idle' } });
if (options.mode === 'model-request') await fetch(process.env.DEEPSEEK_BASE_URL + '/chat/completions', { method: 'POST', body: '{}' });
result = { serverInfo: { name: 'deepseek-harness-sdk-runtime', version: options.mode === 'wrong-version' ? '9.9' : '0.0.1' } };
} else if (value.method === 'session/working-directory/get') {
if (options.mode === 'change-input') fs.appendFileSync(path.join(root, 'packages/boot/cmdline/lib/index.js'), '// changed\\n');
if (options.mode === 'change-workspace') fs.writeFileSync(path.join(process.cwd(), 'README.md'), 'fixture mutated');
result = { cwd: options.mode === 'wrong-cwd' ? root : process.cwd() };
} else if (['session/wait', 'session/resume', 'session/cancel'].includes(value.method)) {
send({ jsonrpc: '2.0', id: value.id, error: { code: -32603, message: value.method === 'session/cancel'
? 'unknown DeepSeek Harness SDK runtime method: session/cancel' : 'unknown SDK session: ' + params.sessionId } }); return;
} else if (value.method !== 'shutdown') {
send({ jsonrpc: '2.0', id: value.id, error: { code: -32601, message: 'unknown fixture method' } }); return;
}
send({ jsonrpc: '2.0', id: value.id, result });
if (value.method === 'shutdown') setImmediate(() => process.exit(0));
});
process.stdin.on('end', () => process.exit(0));
`);
return directory;
}
+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'].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'].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 = [];
+6 -5
View File
@@ -6,17 +6,18 @@ import { gitEnvironment } from '../src/core/git-process.mjs';
import { randomUUID } from 'node:crypto';
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'].includes(version), 'Review evidence paths when introducing the next release.');
const prefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context' : version === '1.6.2' ? 'working-retention' : version === '1.7.0' ? 'python-engine' : 'rea-engine', resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
assert.ok(['1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0'].includes(version), 'Review evidence paths when introducing the next release.');
const prefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context' : version === '1.6.2' ? 'working-retention' : version === '1.7.0' ? 'python-engine' : version === '1.9.0' ? 'external-engines' : 'rea-engine', resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
const cases = [
['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'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '1.8.0'].includes(version) ? [['verify-react-delivery.mjs', version === '1.7.0' ? 'docs/react-engine-delivery-validation.json' : 'docs/rea-engine-react-delivery-validation.json']] : []),
...(version === '1.8.0' ? [['verify-research-ui.mjs', 'docs/rea-engine-research-ui-validation.json']] : []),
...(['1.7.0', '1.8.0', '1.9.0'].includes(version) ? [['verify-python-ui.mjs', `docs/${prefix}-python-ui-validation.json`]] : []),
...(['1.7.0', '1.8.0', '1.9.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'].includes(version) ? [['verify-research-ui.mjs', `docs/${prefix}-research-ui-validation.json`]] : []),
...(version === '1.9.0' ? [['verify-engines-ui.mjs', 'docs/engines-ui-validation.json']] : []),
];
fs.mkdirSync('.qa', { recursive: true });
const externalHost = new Set(['verify-ui.mjs', 'verify-diagnostics-ui.mjs', 'verify-execution-ui.mjs', 'verify-index-ui.mjs']);
+2 -2
View File
@@ -33,8 +33,8 @@ child.stdout.on('data', value => { output += value; for (const line of output.sp
child.stderr.on('data', value => { errors += value; });
const wait = async predicate => { const deadline = Date.now() + 15000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('UI fixture timed out: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
await wait(() => url); const bootstrap = await (await fetch(url + '/api/bootstrap')).json();
assert.ok(['1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
const proofPrefix = bootstrap.version === '1.4.0' ? 'm2-batch' : bootstrap.version === '1.5.0' ? 'context-batch' : bootstrap.version === '1.5.1' ? 'context-fix-batch' : bootstrap.version === '1.6.0' ? 'workspaces-batch' : bootstrap.version === '1.6.1' ? 'working-context-batch' : bootstrap.version === '1.6.2' ? 'working-retention-batch' : bootstrap.version === '1.7.0' ? 'python-engine-batch' : 'rea-engine-batch';
assert.ok(['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'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
const proofPrefix = bootstrap.version === '1.4.0' ? 'm2-batch' : bootstrap.version === '1.5.0' ? 'context-batch' : bootstrap.version === '1.5.1' ? 'context-fix-batch' : bootstrap.version === '1.6.0' ? 'workspaces-batch' : bootstrap.version === '1.6.1' ? 'working-context-batch' : bootstrap.version === '1.6.2' ? 'working-retention-batch' : bootstrap.version === '1.7.0' ? 'python-engine-batch' : bootstrap.version === '1.9.0' ? 'external-engines-batch' : 'rea-engine-batch';
const screenshotPrefix = bootstrap.version === '1.4.0' ? '1.4-batch' : proofPrefix;
const api = async (route, input) => { const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': bootstrap.token, Connection: 'close' },
...(input === undefined ? {} : { body: JSON.stringify(input) }) }); const value = await response.json(); assert.ok(response.ok, value.error); return value; };
+2 -2
View File
@@ -76,9 +76,9 @@ child.stderr.on('data', bytes => { errors += bytes.toString('utf8'); });
const until = async predicate => { const deadline = Date.now() + 20000; while (!await predicate()) { if (Date.now() > deadline) throw new Error('Context UI fixture timeout: ' + errors); await new Promise(resolve => setTimeout(resolve, 40)); } };
await until(() => url || child.exitCode !== null); assert.ok(url, errors);
const bootstrap = await (await fetch(url + '/api/bootstrap', { headers: { Connection: 'close' } })).json();
assert.ok(['1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
assert.ok(['1.5.0', '1.5.1', '1.6.0', '1.6.1', '1.6.2', '1.7.0', '1.8.0', '1.9.0'].includes(bootstrap.version)); assert.equal(bootstrap.config.mode, 'demo'); assert.equal(bootstrap.config.hasKey, false);
const api = async route => { const response = await fetch(url + '/api' + route, { headers: { 'X-Workbench-Token': bootstrap.token, Connection: 'close' } }); const value = await response.json(); assert.ok(response.ok, value.error); return value; };
const proofPrefix = bootstrap.version === '1.5.0' ? 'context' : bootstrap.version === '1.5.1' ? 'context-fix' : bootstrap.version === '1.6.0' ? 'workspaces-context' : bootstrap.version === '1.6.1' ? 'working-context' : bootstrap.version === '1.6.2' ? 'working-retention' : bootstrap.version === '1.7.0' ? 'python-engine' : 'rea-engine';
const proofPrefix = bootstrap.version === '1.5.0' ? 'context' : bootstrap.version === '1.5.1' ? 'context-fix' : bootstrap.version === '1.6.0' ? 'workspaces-context' : bootstrap.version === '1.6.1' ? 'working-context' : bootstrap.version === '1.6.2' ? 'working-retention' : bootstrap.version === '1.7.0' ? 'python-engine' : bootstrap.version === '1.9.0' ? 'external-engines' : 'rea-engine';
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
const passed = [], pageErrors = [], requestFailures = [], screenshots = [];
page.on('pageerror', error => pageErrors.push(error.message));
+141
View File
@@ -0,0 +1,141 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { randomUUID, createHash } from 'node:crypto';
import { chromium } from 'playwright';
import { Store } from '../src/server/store.mjs';
import { launchWorkbench, until } from '../tests/helpers.mjs';
import { createEngineFixture } from './engine-fixtures.mjs';
import { resolveDeepSeekInstallation } from '../src/core/engines/deepseek-installation.mjs';
if (process.argv.includes('--help')) { console.log('node scripts/verify-engines-ui.mjs — isolated browser flows, declared stop fixture and actual installed SDK'); process.exit(0); }
const root = path.resolve('.qa', 'engines-ui-' + randomUUID()), data = path.join(root, 'data'), projectRoot = path.join(root, 'project');
fs.mkdirSync(projectRoot, { recursive: true }); fs.mkdirSync('.qa/screenshots', { recursive: true });
const projectBytes = Buffer.from('# Owned engine UI validation project\n'); fs.writeFileSync(path.join(projectRoot, 'README.md'), projectBytes);
const store = new Store(data), project = store.addProject(projectRoot), session = store.createSession(project.id), other = store.createSession(project.id);
session.title = '引擎连接与原记录验收'; other.title = '引擎归属对照'; store.save(session); store.save(other); store.close();
const fixtureRoot = createEngineFixture(path.join(root, '本地 SDK #')), native = resolveDeepSeekInstallation();
const disposers = [], t = { after: fn => disposers.push(fn) };
let host = await launchWorkbench(t, data, { AGENT_WORKBENCH_DEEPSEEK_ROOT: fixtureRoot }), selectedRoute = '/sessions/' + session.id, deliberateNavigation = false;
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1050 } });
const passed = [], pageErrors = [], requestFailures = [], expectedRequestFailures = [], screenshots = [], starts = [];
const sha = value => createHash('sha256').update(value).digest('hex'), state = () => host.api(selectedRoute);
const panel = () => page.getByRole('dialog', { name: '本地代理引擎', exact: true });
const view = () => page.getByRole('dialog', { name: '引擎原检查记录', exact: true });
const card = job => panel().locator('[data-engine-job="' + job.id + '"]');
const textContains = async (locator, text) => { await locator.waitFor({ state: 'visible' }); await until(async () => (await locator.innerText()).includes(text)); };
const enabled = async locator => { await locator.waitFor({ state: 'visible' }); await until(() => locator.isEnabled()); };
const mark = text => { passed.push(text); console.log('PASS ' + text); };
page.on('pageerror', error => pageErrors.push(error.message));
page.on('requestfailed', request => { const failure = { url: request.url(), error: request.failure()?.errorText };
(deliberateNavigation && failure.error?.includes('ERR_ABORTED') ? expectedRequestFailures : requestFailures).push(failure); });
page.on('request', request => { if (request.method() === 'POST' && request.url().endsWith('/engines/jobs')) starts.push(request.postDataJSON()); });
async function screenshot(name) { const directory = path.join(root, 'screenshots'); fs.mkdirSync(directory, { recursive: true }); const filename = path.join(directory, 'engines-' + name + '.png'); await page.screenshot({ path: filename, scale: 'css' }); screenshots.push(filename); }
async function open(title = session.title) {
deliberateNavigation = true; await page.goto(host.url); await page.waitForLoadState('networkidle'); deliberateNavigation = false;
if (!await page.getByLabel('当前项目').isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
await page.getByLabel('当前项目').selectOption(project.id); await page.locator('.session-list button').filter({ hasText: title }).click();
await page.getByRole('button', { name: '本地代理引擎', exact: true }).click(); await panel().waitFor({ state: 'visible' });
await textContains(panel(), '已找到 0.2.1-rc.2');
}
async function detect(installationRoot) {
await panel().getByLabel('DeepSeek安装目录').fill(installationRoot); await textContains(panel(), '目录已改变');
assert.equal(await panel().getByRole('button', { name: '核验连接', exact: true }).isEnabled(), false);
await panel().getByRole('button', { name: '检测安装', exact: true }).click();
await enabled(panel().getByRole('button', { name: '核验连接', exact: true }));
}
async function waitJob(before) {
await until(async () => (await state()).execution.engineJobs.length === before + 1);
await until(async () => (await state()).execution.engineJobs.at(-1).reportArtifactId, 20000);
const job = (await state()).execution.engineJobs.at(-1); await textContains(card(job), job.status === 'completed' ? '连接通过' : '已停止'); return job;
}
let result;
try {
assert.notEqual(new URL(host.url).port, '4318'); assert.equal(host.bootstrap.config.hasKey, false);
await open(); assert.equal((await state()).execution.task, null); await textContains(panel(), '本次检查不发送模型任务');
mark('independent desktop engine entry detects the declared installation and clearly separates connection from project execution');
await panel().getByLabel('DeepSeek安装目录').fill(path.join(root, '不存在的安装')); await panel().getByRole('button', { name: '检测安装', exact: true }).click();
await textContains(panel(), '本地引擎关键输入不完整'); assert.equal(await panel().getByRole('button', { name: '核验连接', exact: true }).isEnabled(), false);
assert.equal((await state()).execution.engineJobs.length, 0); await detect(fixtureRoot);
mark('missing installations and edited directories cannot launch a check until detection succeeds');
await panel().getByRole('button', { name: '核验连接', exact: true }).click(); const first = await waitJob(0);
assert.equal(first.taskId, (await state()).execution.task.id); assert.equal(first.reportSummary.modelRequests, 0); assert.equal(first.reportSummary.rootExited, true);
await textContains(card(first).getByLabel('引擎实际检查依据'), first.installation.identitySha256.slice(0, 12));
assert.ok(starts[0].identitySha256); assert.equal(starts[0].identitySha256, first.installation.identitySha256);
mark('UI launch seals the selected installation into the current Task/Run and renders actual startup and process-close facts');
await card(first).getByRole('button', { name: '查看原记录', exact: true }).click(); await view().waitFor({ state: 'visible' });
const firstPage = await host.api(selectedRoute + '/engines/jobs/' + first.id + '/report?limit=4000');
await until(async () => (await view().getByLabel('引擎原记录内容').innerText()) === firstPage.content);
assert.equal(firstPage.truncated, true); await view().getByRole('button', { name: '下一页', exact: true }).click();
const secondPage = await host.api(selectedRoute + '/engines/jobs/' + first.id + '/report?offset=4000&limit=4000');
await until(async () => (await view().getByLabel('引擎原记录内容').innerText()) === secondPage.content);
await view().getByRole('button', { name: '回到首页', exact: true }).click(); await textContains(view(), first.reportSha256);
const pendingDownload = page.waitForEvent('download'); await view().getByRole('button', { name: '下载完整记录', exact: true }).click();
const download = await pendingDownload, filename = path.join(root, 'downloaded-report.json'); await download.saveAs(filename);
assert.equal(sha(fs.readFileSync(filename)), first.reportSha256); assert.equal(JSON.parse(fs.readFileSync(filename, 'utf8')).report.responses.length, 6);
await page.keyboard.press('Escape'); await view().waitFor({ state: 'hidden' }); assert.equal(await panel().isVisible(), true);
mark('original record paging, full download SHA256 and nested-dialog keyboard close preserve the exact evidence');
await card(first).getByRole('button', { name: '重新核验', exact: true }).click();
const retry = page.getByRole('dialog', { name: '重新核验引擎连接', exact: true }); await retry.waitFor({ state: 'visible' });
assert.equal((await state()).execution.engineJobs.length, 1); await retry.getByRole('button', { name: '开始新的核验', exact: true }).click();
const second = await waitJob(1); assert.notEqual(second.pid, first.pid); assert.notEqual(second.id, first.id);
assert.equal((await state()).execution.engineJobs.find(job => job.id === first.id).reportSha256, first.reportSha256);
mark('an explicit new check creates a different process and record while retaining the original check unchanged');
fs.writeFileSync(path.join(fixtureRoot, 'fixture-options.json'), JSON.stringify({ mode: 'hang-init' }));
await panel().getByRole('button', { name: '核验连接', exact: true }).click();
await until(async () => (await state()).execution.engineJobs.at(-1).status === 'initializing');
await enabled(panel().getByRole('button', { name: '停止检查', exact: true })); await panel().getByRole('button', { name: '停止检查', exact: true }).click();
const stopped = await waitJob(2); assert.equal(stopped.status, 'cancelled'); assert.equal(stopped.reportSummary.rootExited, true);
assert.equal(fs.readFileSync(path.join(fixtureRoot, 'wire.jsonl'), 'utf8').includes('notifications/cancelled'), false);
fs.writeFileSync(path.join(fixtureRoot, 'fixture-options.json'), '{}');
await card(stopped).getByRole('button', { name: '重新核验', exact: true }).click();
await page.getByRole('dialog', { name: '重新核验引擎连接', exact: true }).getByRole('button', { name: '开始新的核验', exact: true }).click();
const resumed = await waitJob(3); assert.equal(resumed.status, 'completed');
mark('declared pending-initialize fixture stops its owned process and explicit retry preserves the stopped result');
assert.equal(native.status, 'available', native.message); await detect(native.root);
await panel().getByRole('button', { name: '核验连接', exact: true }).click(); const nativeJob = await waitJob(4);
assert.equal(nativeJob.status, 'completed'); assert.equal(nativeJob.installation.root, native.root); assert.equal(nativeJob.reportSummary.observedResponses, 6);
assert.equal(nativeJob.reportSummary.modelRequests, 0); assert.equal(nativeJob.reportSummary.rootExited, true); await screenshot('native-desktop');
mark('the same product UI verifies the actual installed DeepSeek SDK without a prompt or configured-model call');
await page.setViewportSize({ width: 390, height: 844 }); await textContains(card(nativeJob), '连接通过');
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true);
await card(nativeJob).getByRole('button', { name: '查看原记录', exact: true }).click(); await view().waitFor({ state: 'visible' });
await textContains(view(), nativeJob.reportSha256); assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true);
await screenshot('record-mobile'); await page.keyboard.press('Escape'); await view().waitFor({ state: 'hidden' });
await panel().getByLabel('DeepSeek安装目录').scrollIntoViewIfNeeded(); await screenshot('native-mobile');
mark('390px installation paths, source chain, original record, paging and keyboard close remain readable without page overflow');
await page.setViewportSize({ width: 1440, height: 1050 });
let held = false, release;
const delay = new Promise(resolve => { release = resolve; });
const pattern = '**/api/engines/deepseek/availability*'; await page.route(pattern, async route => {
held = true; await delay; await route.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ error: 'owned-late-engine-error-must-stay-in-original-view' }) });
});
await panel().getByRole('button', { name: '检测安装', exact: true }).click(); await until(() => held);
await panel().getByRole('button', { name: '关闭窗口', exact: true }).click(); await panel().waitFor({ state: 'hidden' });
if (!await page.locator('.session-list').isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click();
await page.locator('.session-list button').filter({ hasText: other.title }).click(); selectedRoute = '/sessions/' + other.id;
const lateResponse = page.waitForResponse(response => response.url().includes('/engines/deepseek/availability') && response.status() === 500);
release(); await lateResponse; await page.unroute(pattern);
await page.getByRole('button', { name: '本地代理引擎', exact: true }).click(); await panel().waitFor({ state: 'visible' });
await textContains(panel(), '已找到 0.2.1-rc.2'); await textContains(panel(), '先验证这个安装能否连接');
assert.equal((await state()).execution.engineJobs.length, 0); assert.equal(await page.getByText('owned-late-engine-error-must-stay-in-original-view').count(), 0);
mark('late detection failure from a closed panel cannot appear in a different task or reveal its prior engine records');
const wireBefore = fs.readFileSync(path.join(fixtureRoot, 'wire.jsonl')), saved = await host.api('/sessions/' + session.id);
deliberateNavigation = true; await host.close(); host = await launchWorkbench(t, data, { AGENT_WORKBENCH_DEEPSEEK_ROOT: fixtureRoot });
selectedRoute = '/sessions/' + session.id; await open();
assert.deepEqual((await state()).execution.engineJobs, saved.execution.engineJobs); assert.deepEqual(fs.readFileSync(path.join(fixtureRoot, 'wire.jsonl')), wireBefore);
await card(nativeJob).getByRole('button', { name: '查看原记录', exact: true }).click(); await view().waitFor({ state: 'visible' }); await textContains(view(), nativeJob.reportSha256);
assert.deepEqual(fs.readFileSync(path.join(projectRoot, 'README.md')), projectBytes); assert.equal((await state()).execution.task.usage.requests, 0);
mark('actual host restart preserves all native and declared-fixture records with no protocol replay or project modification');
assert.equal(pageErrors.length, 0); assert.equal(requestFailures.length, 0);
result = { success: true, version: host.bootstrap.version, testedAt: new Date().toISOString(), root, browser: browser.version(), passed, pageErrors,
requestFailures, expectedRequestFailures, screenshots, starts, nativeJob,
actualSdk: { version: native.version, identitySha256: nativeJob.installation.identitySha256, nativeMethods: 6, modelRequests: 0, rootExited: true },
stopScope: 'declared private SDK pending-initialize fixture', scope: 'Independent service and data. Original 4318 Provider, tasks and credentials were not accessed.' };
} catch (error) {
await screenshot('initial-failure').catch(() => {}); fs.writeFileSync(path.join(root, 'failure-dom.html'), await page.content().catch(() => ''));
result = { success: false, version: host.bootstrap.version, testedAt: new Date().toISOString(), root, passed, pageErrors, requestFailures, expectedRequestFailures, screenshots, error: error.stack }; process.exitCode = 1;
} finally { deliberateNavigation = true; await browser.close(); for (const dispose of disposers.reverse()) await dispose(); }
fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify(result, null, 2) + '\n');
fs.writeFileSync('docs/engines-ui-validation.json', JSON.stringify(result, null, 2) + '\n');
console.log(JSON.stringify({ success: result.success, version: result.version, groups: passed.length, root, pageErrors, requestFailures, error: result.error }));
+52
View File
@@ -0,0 +1,52 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { randomUUID, createHash } from 'node:crypto';
import { EngineManager } from '../src/core/engine-manager.mjs';
import { Store } from '../src/server/store.mjs';
import { APP_VERSION } from '../src/server/diagnostics.mjs';
if (process.argv.includes('--help')) {
console.log('node scripts/verify-engines.mjs [--root <installed-DeepSeek-Harness-root>] — native SDK connection, no prompt or configured model'); process.exit(0);
}
const rootIndex = process.argv.indexOf('--root'), requestedRoot = rootIndex >= 0 ? process.argv[rootIndex + 1] : undefined;
if (rootIndex >= 0 && !requestedRoot) throw new Error('--root needs an installation directory');
const directory = path.resolve('.qa', 'native-engine-' + randomUUID()), projectRoot = path.join(directory, 'project');
fs.mkdirSync(projectRoot, { recursive: true });
const projectBytes = Buffer.from('# Owned native SDK connection validation\n'); fs.writeFileSync(path.join(projectRoot, 'README.md'), projectBytes);
const store = new Store(path.join(directory, 'data')), manager = new EngineManager(store), project = store.addProject(projectRoot), session = store.createSession(project.id);
const sha = bytes => createHash('sha256').update(bytes).digest('hex');
let result;
try {
const installation = manager.availability(requestedRoot);
assert.equal(installation.status, 'available', installation.message);
const started = manager.start(session, { root: installation.root, identitySha256: installation.identitySha256 }), job = await started.promise;
assert.equal(job.status, 'completed', job.summary); assert.equal(job.verification?.verified, true);
const reportText = manager.originalReport(session, job), original = JSON.parse(reportText);
assert.equal(sha(reportText), job.reportSha256);
assert.deepEqual(original.owner, { sessionId: session.id, projectId: project.id, taskId: session.taskId, runId: session.runId, jobId: job.id });
assert.equal(original.report.readiness.signal, 'appReady'); assert.equal(original.report.readiness.pid, job.pid);
assert.equal(original.report.before.identitySha256, original.report.after.identitySha256);
assert.equal(original.report.before.identitySha256, installation.identitySha256);
assert.deepEqual(original.report.responses.map(value => value.method), ['initialize', 'session/working-directory/get', 'session/wait', 'session/resume', 'session/cancel', 'shutdown']);
assert.equal(original.report.process.pid, original.report.cleanup.pid); assert.equal(original.report.cleanup.rootExited, true); assert.equal(original.report.cleanup.exit.code, 0);
assert.equal(original.report.modelRequests, 0); assert.equal(original.report.providerRequests, 0);
assert.equal(store.core.task.get(session.taskId).usage.requests, 0); assert.equal(session.changes.length, 0);
assert.equal(original.report.workspace.unchanged, true); assert.deepEqual(fs.readFileSync(path.join(projectRoot, 'README.md')), projectBytes);
fs.writeFileSync(path.join(directory, 'original-report.json'), reportText);
result = { success: true, version: APP_VERSION, testedAt: new Date().toISOString(), directory,
evidenceKind: 'actual-native-DeepSeek-Harness-SDK; no protocol fixture', scope: job.scope,
owner: original.owner, installation: { root: installation.root, version: installation.version, profile: installation.profile,
identitySha256: installation.identitySha256, inputs: installation.inputs, node: installation.node },
process: original.report.process, readiness: original.report.readiness, responses: original.report.responses,
cleanup: original.report.cleanup, workspace: original.report.workspace, reportSha256: job.reportSha256,
modelRequests: 0, providerRequests: 0, projectChanges: 0,
executionBoundary: 'Connection validation only; session/prompt was not sent. Original user service and credentials were not used.' };
} catch (error) {
result = { success: false, version: APP_VERSION, testedAt: new Date().toISOString(), directory,
error: error.stack, jobs: manager.jobs(session).map(job => manager.summary(session, job)) }; process.exitCode = 1;
} finally { await manager.stopAll(); store.close(); }
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2) + '\n');
fs.writeFileSync(path.resolve('.qa', 'native-engine-validation.json'), JSON.stringify(result, null, 2) + '\n');
console.log(JSON.stringify({ success: result.success, version: result.version, directory, sdkVersion: result.installation?.version,
nativeMethods: result.responses?.map(value => value.method), modelRequests: result.modelRequests, rootExited: result.cleanup?.rootExited, error: result.error }));
+1 -1
View File
@@ -12,7 +12,7 @@ const protectedFiles = createPythonDeliveryProject(f), source = captureWorkspace
f.session.title = 'Python工程检查与交付'; f.store.core.task.get(f.session.taskId).goal = '修复三个Python模块,保护测试与声明,核对实际检查并交付本地Git报告。';
f.store.save(f.session); f.store.close();
const host = await launchWorkbench(t, f.data, process.env.AGENT_WORKBENCH_TEST_PYTHON ? { AGENT_WORKBENCH_PYTHON_PATH: process.env.AGENT_WORKBENCH_TEST_PYTHON } : {});
const proofPrefix = host.bootstrap.version === '1.8.0' ? 'rea-engine' : 'python-engine';
const proofPrefix = host.bootstrap.version === '1.8.0' ? 'rea-engine' : host.bootstrap.version === '1.9.0' ? 'external-engines' : 'python-engine';
assert.notEqual(new URL(host.url).port, '4318'); assert.equal(host.bootstrap.config.hasKey, false);
fs.mkdirSync('.qa/screenshots', { recursive: true });
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
+1 -1
View File
@@ -117,7 +117,7 @@ try {
checks: actual.results.map(result => ({ name: result.name, status: result.status, exitCode: result.exitCode, tests: result.tests })),
commit: job.commit, changes: job.paths, protectedFiles: Object.fromEntries(Object.entries(protectedBytes).map(([relative, bytes]) => [relative, sha(bytes)])),
scope: 'Owned frozen React TypeScript project with offline-installed fixed dependencies, real npm/typecheck/build/browser and Workbench review/Git/report. API fixtures supply repairs; configured-model success is separate.' };
fs.writeFileSync(host.bootstrap.version === '1.8.0' ? 'docs/rea-engine-react-delivery-validation.json' : 'docs/react-engine-delivery-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
fs.writeFileSync(host.bootstrap.version === '1.8.0' ? 'docs/rea-engine-react-delivery-validation.json' : host.bootstrap.version === '1.9.0' ? 'docs/external-engines-react-delivery-validation.json' : 'docs/react-engine-delivery-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
} catch (error) {
await snapshot('failure').catch(() => {});
fs.writeFileSync('.qa/react-engine-delivery-failure.json', JSON.stringify({ error: error.message, passed, pageErrors, requestFailures, session }, null, 2)); throw error;
+20 -2
View File
@@ -91,7 +91,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 (manifest.version === '1.8.0') {
if (['1.8.0', '1.9.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')));
@@ -122,13 +122,31 @@ try {
assert.equal((await api(researchRoute)).execution.task.usage.requests, 0); assert.equal(fs.existsSync(samples.marker), false);
console.log('PASS actual contained REA: ASAR, PE imports and PE resources; zero target execution/model requests');
}
let actualEngine = null;
if (manifest.version === '1.9.0' && 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');
const project = await api('/projects', { root: engineRoot }), engineSession = await api('/sessions', { projectId: project.id }), route = '/sessions/' + engineSession.id;
const started = await api(route + '/engines/jobs', { root: installation.root, identitySha256: installation.identitySha256 });
let job; await until(async () => { job = await api(route + '/engines/jobs/' + started.job.id); return !!job.reportArtifactId; }, 30000);
assert.equal(job.status, 'completed', job.summary); assert.equal(job.reportSummary.rootExited, true); assert.equal(job.reportSummary.modelRequests, 0);
const response = await fetch(url + '/api' + route + '/engines/jobs/' + job.id + '/download', { headers: { 'X-Workbench-Token': bootstrap.token, Connection: 'close' } });
assert.equal(response.status, 200); const bytes = Buffer.from(await response.arrayBuffer());
assert.equal(createHash('sha256').update(bytes).digest('hex'), job.reportSha256);
const original = JSON.parse(bytes.toString('utf8')); assert.equal(original.owner.taskId, job.taskId); assert.equal(original.report.responses.length, 6);
assert.equal(original.report.providerRequests, 0); assert.equal(original.report.cleanup.exit.code, 0);
actualEngine = { packageVersion: installation.version, profile: installation.profile, installationSha256: installation.identitySha256,
reportSha256: job.reportSha256, rootExited: true, modelRequests: 0, nativeMethods: original.report.responses.map(value => value.method), node: installation.node };
console.log('PASS compiled portable engine adapter: actual local SDK, contained Node, six native methods and sealed original report');
}
assert.equal((await api('/research')).length, 4);
const page = await fetch(url); assert.equal(page.status, 200);
assert.match(await page.text(), /Agent Workbench/);
console.log((await stop()).trim()); started = false;
await until(async () => { try { await fetch(url + '/api/health'); return false; } catch { return true; } });
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,
verifiedFiles: manifest.files.length, url, reusedPid: firstInfo.pid, checks: { jobId, status: checked.status, tests: checked.results[0].tests }, actualRea, actualEngine,
steps: ['manifest hashes', 'bundled Node launch', 'same-service reuse', 'packaged example and static page', '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'], realModel: false };
fs.writeFileSync('.qa/release-validation.json', JSON.stringify(result, null, 2));
console.log(JSON.stringify(result, null, 2));
+4 -2
View File
@@ -7,6 +7,8 @@ import { Store } from '../src/server/store.mjs';
import { launchWorkbench } from '../tests/helpers.mjs';
import { createResearchSamples, ownedAsar } from './research-fixtures.mjs';
const proofPrefix = JSON.parse(fs.readFileSync('package.json', 'utf8')).version === '1.9.0' ? 'external-engines' : 'rea-engine';
if (process.argv.includes('--help')) { console.log('node scripts/verify-research-ui.mjs — independent owned projects, real REA static operations and a declared stdio stop fixture'); process.exit(0); }
const root = path.resolve('.qa', 'research-ui-' + randomUUID()), data = path.join(root, 'data'), projectRoot = path.join(root, 'project');
fs.mkdirSync(projectRoot, { recursive: true }); fs.mkdirSync('.qa/screenshots', { recursive: true });
@@ -28,7 +30,7 @@ page.on('requestfailed', request => {
(deliberateNavigation && failure.error?.includes('ERR_ABORTED') ? expectedRequestFailures : requestFailures).push(failure);
});
page.on('request', request => { if (request.method() === 'POST' && request.url().endsWith('/research/jobs')) analysisRequests.push({ url: request.url(), input: request.postDataJSON() }); });
async function screenshot(name) { const filename = '.qa/screenshots/rea-engine-' + name + '.png'; await page.screenshot({ path: filename, scale: 'css' }); screenshots.push(filename); }
async function screenshot(name) { const filename = '.qa/screenshots/' + proofPrefix + '-' + name + '.png'; await page.screenshot({ path: filename, scale: 'css' }); screenshots.push(filename); }
async function openProject(projectId = project.id, title = original.title) {
await page.goto(host.url); await page.waitForLoadState('networkidle');
await page.getByLabel('当前项目').selectOption(projectId); await page.locator('.session-list button').filter({ hasText: title }).click();
@@ -176,5 +178,5 @@ try {
deliberateNavigation = true; await browser.close(); for (const dispose of disposers.reverse()) await dispose();
}
fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify(result, null, 2) + '\n');
fs.writeFileSync('docs/rea-engine-research-ui-validation.json', JSON.stringify(result, null, 2) + '\n');
fs.writeFileSync('docs/' + proofPrefix + '-research-ui-validation.json', JSON.stringify(result, null, 2) + '\n');
console.log(JSON.stringify({ success: result.success, version: result.version, groups: passed.length, root, pageErrors, requestFailures, error: result.error }, null, 2));
+10 -2
View File
@@ -42,19 +42,27 @@ 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 (evidence.version === '1.8.0') {
if (['1.8.0', '1.9.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));
assert.equal(actualRea.success, true); assert.equal(actualRea.version, evidence.version); assert.equal(actualRea.results.length, 3);
assert.ok(actualRea.results.every(item => item.rootExited === true));
}
let actualEngine = null;
if (evidence.version === '1.9.0' && 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));
assert.equal(actualEngine.success, true); assert.equal(actualEngine.version, evidence.version);
assert.equal(actualEngine.modelRequests, 0); assert.equal(actualEngine.rootExited, true); assert.equal(actualEngine.nativeMethods.length, 6);
}
stage = 'tests';
const output = await run(['--test', '--test-concurrency=2', '--test-reporter=tap', ...files(path.join(sourceRoot, 'tests')).filter(file => !file.includes(path.sep) && file.endsWith('.test.mjs')).map(file => path.join('tests', file))], 'tests.tap');
const stats = Object.fromEntries([...output.matchAll(/^# (tests|pass|fail|cancelled|skipped|todo) (\d+)\s*$/gm)].map(match => [match[1], Number(match[2])]));
assert.ok(stats.tests > 0); assert.equal(stats.pass, stats.tests); for (const key of ['fail', 'cancelled', 'skipped', 'todo']) assert.equal(stats[key], 0);
const result = { success: true, version: evidence.version, testedAt: new Date().toISOString(), sourceRoot, offlineInstall: true,
buildMatchedFiles: Object.keys(expected).length, tests: stats, actualRea, credentialsHandling: 'Only build/runtime environment paths are inherited; no model configuration or credentials are used.' };
buildMatchedFiles: Object.keys(expected).length, tests: stats, actualRea, actualEngine, credentialsHandling: 'Only build/runtime environment paths are inherited; no model configuration or credentials are used.' };
fs.writeFileSync(resultFile, JSON.stringify(result, null, 2)); console.log(JSON.stringify(result, null, 2));
} catch (error) {
fs.writeFileSync(resultFile, JSON.stringify({ success: false, version: evidence.version, stage, error: error.message, sourceRoot }, null, 2));
+1
View File
@@ -43,4 +43,5 @@ try {
}
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2) + '\n'); fs.writeFileSync('.qa/tests-validation.json', JSON.stringify(result, null, 2) + '\n');
if (version === '1.8.0') fs.writeFileSync('docs/rea-engine-tests-validation.json', JSON.stringify(result, null, 2) + '\n');
if (version === '1.9.0') fs.writeFileSync('docs/external-engines-tests-validation.json', JSON.stringify(result, null, 2) + '\n');
console.log(JSON.stringify({ success: result.success, version, tests: result.tests, inputFiles: result.inputFiles, directory, error: result.error, tail: result.tail }, null, 2));
+1 -1
View File
@@ -12,7 +12,7 @@ import { captureWorkspaceSource, assertWorkspaceSource } from '../tests/fixtures
// Every host/project is synthetic and independently owned. Never uses 4318.
const root = path.resolve('.qa', 'workspace-ui-' + randomUUID()), data = path.join(root, 'data');
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
const proofPrefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context-workspaces' : version === '1.6.2' ? 'working-retention-workspaces' : version === '1.7.0' ? 'python-engine-workspaces' : 'rea-engine-workspaces';
const proofPrefix = version === '1.6.0' ? 'workspaces' : version === '1.6.1' ? 'working-context-workspaces' : version === '1.6.2' ? 'working-retention-workspaces' : version === '1.7.0' ? 'python-engine-workspaces' : version === '1.9.0' ? 'external-engines-workspaces' : 'rea-engine-workspaces';
fs.mkdirSync(root, { recursive: true }); fs.mkdirSync('.qa/screenshots', { recursive: true });
const store = new Store(data), cases = {}, passed = [], pageErrors = [], requestFailures = [], screenshots = [], createPosts = [];
for (const name of ['normal', 'mobile', 'recovery', 'late-success', 'late-failure']) {