fix: retain verifiable task observations within context budgets
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ const releases = path.resolve(root, 'releases');
|
||||
fs.mkdirSync(releases, { recursive: true });
|
||||
const baseName = 'Agent-Workbench-' + meta.version;
|
||||
const refresh = process.argv.includes('--refresh');
|
||||
const buildSuffix = !refresh && fs.existsSync(path.join(releases, baseName + '-win-x64')) ? '-' + new Date().toISOString().replace(/[-:TZ.]/g, '') : '';
|
||||
const buildSuffix = !refresh && (process.argv.includes('--immutable') || fs.existsSync(path.join(releases, baseName + '-win-x64'))) ? '-' + new Date().toISOString().replace(/[-:TZ.]/g, '') : '';
|
||||
const portableRoot = path.join(releases, baseName + '-win-x64' + buildSuffix);
|
||||
const sourceRoot = path.join(releases, baseName + '-source' + buildSuffix);
|
||||
for (const target of [portableRoot, sourceRoot]) {
|
||||
|
||||
@@ -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'].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'].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,13 +6,14 @@ import { gitEnvironment } from '../src/core/git-process.mjs';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
|
||||
assert.equal(version, '1.6.0', 'Review evidence paths when introducing the next release.');
|
||||
const prefix = 'workspaces', resultFile = `.qa/${prefix}-all-ui-validation.json`, results = [];
|
||||
assert.ok(['1.6.0', '1.6.1'].includes(version), 'Review evidence paths when introducing the next release.');
|
||||
const prefix = version === '1.6.0' ? 'workspaces' : 'working-context', 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/workspaces-batch-ui-validation.json'],
|
||||
['verify-context-ui.mjs', '.qa/workspaces-context-ui-validation.json'], ['verify-workspaces-ui.mjs', 'docs/workspaces-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`],
|
||||
];
|
||||
fs.mkdirSync('.qa', { recursive: true });
|
||||
const externalHost = new Set(['verify-ui.mjs', 'verify-diagnostics-ui.mjs', 'verify-execution-ui.mjs', 'verify-index-ui.mjs']);
|
||||
|
||||
@@ -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'].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' : 'workspaces-batch';
|
||||
assert.ok(['1.4.0', '1.5.0', '1.5.1', '1.6.0', '1.6.1'].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' : 'working-context-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; };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { randomUUID, createHash } from 'node:crypto';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { chromium, expect } from 'playwright/test';
|
||||
import { Store } from '../src/server/store.mjs';
|
||||
@@ -12,7 +12,7 @@ import { call } from '../tests/helpers.mjs';
|
||||
const root = path.resolve('.qa', 'context-ui-' + randomUUID()), data = path.join(root, 'data');
|
||||
fs.mkdirSync(root, { recursive: true }); fs.mkdirSync('.qa/screenshots', { recursive: true });
|
||||
const store = new Store(data), cases = {};
|
||||
for (const name of ['long', 'other', 'paused', 'paused-repeat']) {
|
||||
for (const name of ['long', 'other', 'paused', 'paused-repeat', 'working']) {
|
||||
const projectRoot = path.join(root, 'context-' + name); fs.mkdirSync(projectRoot);
|
||||
fs.writeFileSync(path.join(projectRoot, 'README.md'), '# Owned context UI fixture\n');
|
||||
const project = store.addProject(projectRoot), session = store.createSession(project.id, '上下文验收 ' + name);
|
||||
@@ -36,6 +36,22 @@ for (const name of ['long', 'other', 'paused', 'paused-repeat']) {
|
||||
session.providerMessages.push({ role: 'assistant', content: 'Saved fixture read.', tool_calls: [tool] },
|
||||
{ role: 'tool', tool_call_id: tool.id, content: JSON.stringify(result) });
|
||||
}
|
||||
if (name === 'working') {
|
||||
const content = 'export const actual = "当前任务真实代码🙂";\n';
|
||||
fs.writeFileSync(path.join(projectRoot, 'actual.mjs'), content);
|
||||
const values = [{ tool: 'read_file', args: { path: 'actual.mjs' }, result: { path: 'actual.mjs', content,
|
||||
sha256: createHash('sha256').update(content).digest('hex'), start_line: 1, end_line: 2, total_lines: 2, truncated: false } },
|
||||
{ tool: 'query_code', args: { query: 'large' }, result: { results: 'Large owned mixed group '.repeat(16000) } }];
|
||||
const calls = values.map(value => call(randomUUID(), value.tool, value.args)), messages = [];
|
||||
for (const [index, invocation] of calls.entries()) {
|
||||
const event = store.event(session, { kind: 'tool', tool: invocation.function.name, toolCallId: invocation.id,
|
||||
runId: run.id, taskId: run.taskId, phase: 'queued', startedAt: new Date().toISOString(), label: '工作依据样本' });
|
||||
store.registerInvocation(session, invocation, run, event); store.beginInvocation(session, invocation, run, event);
|
||||
store.finishInvocation(session, event, values[index].result);
|
||||
messages.push({ role: 'tool', tool_call_id: invocation.id, content: JSON.stringify(values[index].result) });
|
||||
}
|
||||
session.providerMessages.push({ role: 'assistant', content: '', tool_calls: calls }, ...messages); store.save(session);
|
||||
}
|
||||
const step = store.beginStep(session, run), first = planner.prepare(session, run, store.config, {
|
||||
system: goal + '\n' + JSON.stringify({ project_id: project.id, session_id: session.id, task_id: run.taskId }), tools: toolDefinitions, stepId: step.id });
|
||||
const response = { message: { role: 'assistant', content: '独立界面样本已保存;没有请求真实模型。' }, usage: { prompt_tokens: 2400, completion_tokens: 300 } };
|
||||
@@ -60,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'].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'].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' : 'workspaces-context';
|
||||
const proofPrefix = bootstrap.version === '1.5.0' ? 'context' : bootstrap.version === '1.5.1' ? 'context-fix' : bootstrap.version === '1.6.0' ? 'workspaces-context' : 'working-context';
|
||||
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));
|
||||
@@ -147,6 +163,21 @@ try {
|
||||
const resumed = await api('/sessions/' + cases['paused-repeat'].session.id);
|
||||
assert.equal(resumed.execution.task.id, pausedTaskId); assert.equal(resumed.execution.run.resumeOf, cases['paused-repeat'].runs[0]);
|
||||
mark('390px repeated-read pause explains the cause and explicit continuation retains the same Task');
|
||||
await page.setViewportSize({ width: 1440, height: 1000 }); await choose('working');
|
||||
await expect(panel()).toContainText('当前任务依据'); await expect(panel()).toContainText('1 项代码与执行结果');
|
||||
await panel().getByRole('button', { name: '查看工作依据', exact: true }).click();
|
||||
await expect(artifact.locator('pre')).toContainText('当前任务真实代码');
|
||||
await expect(artifact.locator('pre')).toContainText('result_artifact_id'); await screenshot('desktop-working-evidence');
|
||||
await page.keyboard.press('Escape'); mark('desktop working evidence shows actual code, original result provenance and the current Task');
|
||||
await page.setViewportSize({ width: 390, height: 844 }); await choose('working');
|
||||
await panel().getByRole('button', { name: '查看工作依据', exact: true }).click();
|
||||
await expect(artifact.locator('pre')).toContainText('当前任务真实代码');
|
||||
const workingBounds = await artifact.boundingBox(); assert.ok(workingBounds.x >= 0 && workingBounds.x + workingBounds.width <= 390);
|
||||
await screenshot('mobile-working-evidence'); await page.keyboard.press('Escape'); await expect(panel()).toBeVisible();
|
||||
await panel().getByRole('button', { name: '查看发送内容', exact: true }).click();
|
||||
await expect(artifact.locator('pre')).toContainText('working_set'); await page.keyboard.press('Escape');
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 2));
|
||||
mark('390px working evidence and sent request stay readable and closing the artifact retains task navigation');
|
||||
assert.deepEqual(pageErrors, []); assert.deepEqual(requestFailures, []);
|
||||
const result = { success: true, version: bootstrap.version, testedAt: new Date().toISOString(), passed, pageErrors, requestFailures, screenshots, root, data,
|
||||
mode: 'saved synthetic context evidence; no real model or project commands executed by this UI verifier', browser: browser.version() };
|
||||
|
||||
@@ -11,6 +11,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 proofPrefix = JSON.parse(fs.readFileSync('package.json', 'utf8')).version === '1.6.0' ? 'workspaces' : 'working-context-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']) {
|
||||
@@ -66,7 +67,7 @@ async function fit(name) {
|
||||
});
|
||||
assert.ok(size.scrollWidth <= size.width + 1, name + ' page horizontal overflow');
|
||||
if (size.top !== undefined) { assert.ok(size.top >= 0 && size.left >= 0 && size.right <= size.width + 1 && size.bottom <= size.height + 1, name + ' modal bounds'); assert.ok(size.closeBottom <= size.height); }
|
||||
const file = '.qa/screenshots/1.6-workspace-' + name + '.png'; await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file);
|
||||
const file = '.qa/screenshots/' + proofPrefix + '-' + name + '.png'; await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file);
|
||||
}
|
||||
try {
|
||||
await page.goto(url); await page.waitForLoadState('networkidle');
|
||||
@@ -138,10 +139,10 @@ try {
|
||||
assert.equal(pageErrors.length, 0, pageErrors.join('\n')); assert.equal(requestFailures.length, 0, requestFailures.join('\n'));
|
||||
const result = { success: true, version: bootstrap.version, at: new Date().toISOString(), browser: browser.version(), passed, pageErrors, requestFailures, screenshots, projectRoot: root,
|
||||
scope: 'Independent synthetic Git projects and real browser flows. Desktop/390×844, actual worktree creation, source preservation, explicit external recovery, ownership navigation, delayed success/error/navigation. No production service or real model credential used.' };
|
||||
fs.writeFileSync('docs/workspaces-ui-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
|
||||
fs.writeFileSync('docs/' + proofPrefix + '-ui-validation.json', JSON.stringify(result, null, 2) + '\n'); console.log(JSON.stringify(result, null, 2));
|
||||
} catch (error) {
|
||||
await page.screenshot({ path: '.qa/screenshots/1.6-workspace-failure.png', scale: 'css' });
|
||||
fs.writeFileSync('.qa/workspaces-ui-failure.json', JSON.stringify({ success: false, message: error.message, passed, pageErrors, requestFailures }, null, 2)); throw error;
|
||||
await page.screenshot({ path: '.qa/screenshots/' + proofPrefix + '-failure.png', scale: 'css' });
|
||||
fs.writeFileSync('.qa/' + proofPrefix + '-ui-failure.json', JSON.stringify({ success: false, message: error.message, passed, pageErrors, requestFailures }, null, 2)); throw error;
|
||||
} finally {
|
||||
await browser.close(); try { await api('/shutdown', {}); await wait(() => host.exitCode !== null); } catch { if (host.exitCode === null) host.kill(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user