fix: complete unrestricted waits catalog and network flows

This commit is contained in:
Agent Workbench Dev
2026-11-06 06:21:59 +08:00
parent c93c434808
commit c9c77c7ee6
32 changed files with 295 additions and 84 deletions
+6 -1
View File
@@ -15,6 +15,7 @@ async function until(predicate, timeout = 20000) {
}
export async function verifyBrowserApi({ api, url, token, directory, appRoot, contained = false }) {
const open = (await api('/bootstrap')).config.executionMode === 'unrestricted';
const projectRoot = path.join(directory, 'browser-project'); fs.mkdirSync(path.join(projectRoot, 'dist'), { recursive: true });
fs.writeFileSync(path.join(projectRoot, 'README.md'), '# Owned portable browser acceptance\n');
fs.writeFileSync(path.join(projectRoot, 'dist', 'index.html'), '<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>随包页面验收</title>'
@@ -27,8 +28,12 @@ export async function verifyBrowserApi({ api, url, token, directory, appRoot, co
await until(async () => { current = await api(route); return current.status === 'awaiting_approval'; });
const approval = current.approvals.find(value => value.status === 'pending'); assert.equal(approval.command, 'node --version');
await api(route + '/approvals/' + approval.id, { allow: true });
await until(async () => { current = await api(route); return current.status === 'needs_review'; });
await until(async () => { current = await api(route); return current.status === (open ? 'completed' : 'needs_review'); });
for (const change of current.changes.filter(value => value.status === 'pending')) await api(route + '/changes/' + change.id + '/reject', {});
if (open) {
assert.ok(current.changes.some(value => value.status === 'applied'));
for (const change of current.changes.filter(value => value.status === 'applied')) await api(route + '/changes/' + change.id + '/rollback', {});
}
const taskId = (await api(route)).execution.task.id, availability = (await api(route + '/browser')).availability;
assert.equal(availability.status, 'available', availability.message); assert.equal(availability.playwrightVersion, '1.64.1');
const steps = [{ action: 'fill', selector: '#query', value: '本地页面验收' }, { action: 'select', selector: '#filter', value: 'pending' },
+1 -1
View File
@@ -158,7 +158,7 @@ try {
...(['1.24.9', '1.25.0', '1.25.1', '1.25.2', '1.25.3', '1.25.5'].includes(version) ? [['verify-requirements-ui.mjs', [], 7], ['verify-requirements-desktop.mjs', [], 3], ['verify-turn-progress-ui.mjs', [], 9], ['verify-turn-progress-ui.mjs', ['--desktop'], 9]] : []),
...(['1.25.0', '1.25.1', '1.25.2', '1.25.3', '1.25.5'].includes(version) ? [['verify-task-agreement-ui.mjs', [], 6], ['verify-task-agreement-ui.mjs', ['--desktop'], 6], ['verify-task-follow-up-ui.mjs', [], 5], ['verify-task-follow-up-ui.mjs', ['--desktop'], 5]] : []),
...(['1.25.3', '1.25.5'].includes(version) ? [['verify-reasoning-settings-ui.mjs', [], 6], ['verify-reasoning-settings-ui.mjs', ['--desktop'], 6], ['verify-model-catalog-ui.mjs', [], 8], ['verify-model-catalog-ui.mjs', ['--desktop'], 8]] : []),
...(version === '1.25.5' ? [['verify-model-capacity-ui.mjs', [], 3], ['verify-model-capacity-ui.mjs', ['--desktop'], 3], ['verify-unrestricted-ui.mjs', [], 8], ['verify-unrestricted-ui.mjs', ['--desktop'], 9]] : []),
...(version === '1.25.5' ? [['verify-model-capacity-ui.mjs', [], 3], ['verify-model-capacity-ui.mjs', ['--desktop'], 3], ['verify-unrestricted-ui.mjs', [], 10], ['verify-unrestricted-ui.mjs', ['--desktop'], 11]] : []),
];
for (const [script, args, expected] of suites) {
const output = await run(process.execPath, [path.join(appRoot, 'scripts', script), ...args], { cwd: appRoot,
+1 -1
View File
@@ -100,7 +100,7 @@ try {
let current;
await until(async () => { current = await api('/sessions/' + session.id); return current.status === 'awaiting_approval'; });
assert.equal(current.approvals[0].command, 'node --version');
assert.equal(fs.existsSync(path.join(example.root, 'WORKBENCH-NOTES.md')), false);
assert.equal(fs.existsSync(path.join(example.root, 'WORKBENCH-NOTES.md')), bootstrap.config.executionMode === 'unrestricted');
await api('/sessions/' + session.id + '/approvals/' + current.approvals[0].id, { allow: true });
await until(async () => { current = await api('/sessions/' + session.id); return current.status === 'completed'; });
const command = current.events.find(event => event.tool === 'run_command');
+46 -2
View File
@@ -55,7 +55,7 @@ try {
}
return completion([], 'Owned full browser flow complete.');
};
const model = await compatibleFixture(t, (url, body) => ownedFailure ? { status: 429, body: { error: { code: 'owned_rate', type: 'owned_original', message: 'UI-UPSTREAM-ORIGINAL', detail: '原始上游正文'.repeat(6000) } }, headers: { 'x-request-id': 'owned-ui-error-id' } } : url.endsWith('/models') ? { data: [{ id: 'owned-capacity', context_length: 131072, max_output_tokens: 32768, capabilities: { text: true, tools: true } }] }
const model = await compatibleFixture(t, (url, body) => ownedFailure ? { status: 429, body: { error: { code: 'owned_rate', type: 'owned_original', message: 'UI-UPSTREAM-ORIGINAL', detail: '原始上游正文'.repeat(6000) } }, headers: { 'x-request-id': 'owned-ui-error-id' } } : url.endsWith('/models') ? { data: [{ id: 'owned-capacity', context_length: 131072, max_output_tokens: 32768, capabilities: { text: true, tools: true } }, ...Array.from({ length: 121 }, (_, index) => ({ id: 'owned-bulk-' + index, capabilities: { text: true, tools: true } }))] }
: body.messages.some(row => row.role === 'user' && row.content.includes('FULL-BROWSER-FLOW')) ? browserReply(body)
: body.messages.some(row => row.role === 'user' && row.content.includes('PERMISSION-FLOW')) ? completion(body.messages.some(row => row.role === 'tool') ? [] : [call('owned-permission', 'run_command', { command: process.platform === 'win32' ? 'Write-Output "OWNED-PERMISSION-MARKER"' : 'printf OWNED-PERMISSION-MARKER', reason: 'Verify permission switching in the actual UI.' })], 'Permission flow complete.')
: body.messages.some(row => row.role === 'user' && row.content.includes('AUTO-WRITE-FLOW')) ? completion(body.messages.some(row => row.role === 'tool') ? [] : [call('owned-write', 'propose_file', { path: 'ui-auto.txt', content: 'OWNED-APPLIED\n', reason: 'Verify automatic writes and exact rollback.' })], 'File flow complete.')
@@ -112,6 +112,50 @@ try {
await expect(budgets().getByLabel('额度策略', { exact: true })).toHaveValue('unrestricted');
for (const width of [1440,390]) { await resize(width); assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1)); await shot('open-settings-' + width); }
mark('open defaults save as real zeros, survive reload, hide local quotas and retain model selection at 1440 and 390 pixels');
await resize(1440); await dialog().getByRole('button', { name: '等待时限', exact: true }).click();
const waits = () => dialog().getByRole('form', { name: '模型等待时限', exact: true });
await expect(waits().getByLabel('单次模型响应上限(秒)', { exact: true })).toHaveValue('0');
await expect(waits().getByLabel('流式无数据上限(秒)', { exact: true })).toHaveValue('0');
await waits().getByLabel('单次模型响应上限(秒)', { exact: true }).fill('960');
await waits().getByLabel('流式无数据上限(秒)', { exact: true }).fill('901');
await waits().getByRole('button', { name: '保存等待时限', exact: true }).click();
await expect(dialog().getByRole('status').filter({ hasText: '等待时限已保存' })).toBeVisible();
await page.reload(); await open(); await dialog().getByRole('button', { name: '等待时限', exact: true }).click();
await expect(waits().getByLabel('单次模型响应上限(秒)', { exact: true })).toHaveValue('960');
await expect(waits().getByLabel('流式无数据上限(秒)', { exact: true })).toHaveValue('901');
for (const label of ['单次模型响应上限(秒)', '流式无数据上限(秒)']) await waits().getByLabel(label, { exact: true }).fill('0');
await waits().getByRole('button', { name: '保存等待时限', exact: true }).click();
await expect(dialog().getByRole('status').filter({ hasText: '等待时限已保存' })).toBeVisible();
assert.deepEqual((await host.api('/model-center')).waitSettings, { modelResponseTimeoutMs: 0, modelStreamIdleTimeoutMs: 0 });
for (const width of [1440,390]) { await resize(width); await shot('unlimited-waits-' + width); }
mark('wait settings accept zero and values beyond old ceilings, persist after reload and restore unlimited waits');
await resize(1440); await dialog().getByRole('button', { name: '模型连接', exact: true }).click();
await dialog().getByRole('button', { name: '从上游添加模型', exact: true }).click();
const catalog = () => dialog().getByRole('region', { name: '上游模型目录', exact: true });
await catalog().getByLabel('目录上游连接', { exact: true }).selectOption(source.id);
await catalog().getByRole('button', { name: '获取上游模型', exact: true }).click();
await expect(catalog().getByLabel('上游模型列表', { exact: true }).getByRole('checkbox')).toHaveCount(122);
await catalog().getByRole('button', { name: '选中当前筛选', exact: true }).click();
await catalog().getByLabel('模型使用方式', { exact: true }).selectOption('auto');
await expect(catalog().getByRole('button', { name: '保存所选 122 个模型', exact: true })).toBeEnabled();
await expect(catalog()).toContainText('目录、连接和自动池不设本地数量上限');
for (const width of [1440,390]) { await resize(width); await shot('open-model-selection-' + width); }
await catalog().getByRole('button', { name: '关闭目录', exact: true }).click();
assert.deepEqual((await host.api('/model-center')).selected, originalSelection);
await dialog().getByRole('navigation', { name: '模型中心分类', exact: true }).getByRole('button', { name: '连接诊断', exact: true }).click();
const network = () => dialog().getByRole('region', { name: '模型连接诊断', exact: true });
await network().getByLabel('诊断连接', { exact: true }).selectOption(source.id);
await network().getByRole('button', { name: '开始直连检查', exact: true }).click();
await expect(network().getByRole('status')).toHaveText('直连握手通过');
await expect(network()).toContainText('保留全部检查记录');
await network().locator('details summary').click();
await expect(network().getByText('不限 / 不限', { exact: true })).toBeVisible();
const diagnostic = (await host.api('/model-center/network-diagnostics')).jobs[0];
assert.equal(diagnostic.status, 'passed'); assert.equal(diagnostic.budgetMs, 0); assert.equal(diagnostic.stageTimeoutMs, 0);
assert.equal(diagnostic.httpRequests, 0); assert.equal(diagnostic.modelRequests, 0);
for (const width of [1440,390]) { await resize(width); await shot('open-network-diagnostic-' + width); }
mark('catalog UI selects 122 models and enables automatic routing; actual TCP diagnostics show unlimited waits and complete history');
await resize(1440); await dialog().getByRole('button', { name: '运行预算', exact: true }).click();
await budgets().getByLabel('额度策略', { exact: true }).selectOption('restricted');
await budgets().getByLabel('容量策略', { exact: true }).selectOption('manual');
await budgets().getByLabel('输出上限', { exact: true }).fill('32768');
@@ -184,7 +228,7 @@ try {
}
assert.deepEqual(errors, []);
assert.equal(model.requests.filter(row => row.input).length, desktop ? 13 : 7);
result={success:true,version:host.bootstrap.version,appRoot,actualElectron:desktop,checks,screenshots,errors,realModelRequests:0,ownedModelRequests:desktop ? 13 : 7,directoryGets:1,officialServiceTouched:false};
result={success:true,version:host.bootstrap.version,appRoot,actualElectron:desktop,checks,screenshots,errors,realModelRequests:0,ownedModelRequests:desktop ? 13 : 7,directoryGets:model.requests.filter(row => !row.input).length,officialServiceTouched:false};
} catch(error) {if(page)await shot('failure').catch(()=>{});result={success:false,appRoot,actualElectron:desktop,checks,screenshots,errors,error:error.stack,realModelRequests:0};}
finally {if(application)await application.close();if(browser)await browser.close();if(controller&&await controller.health())await controller.stop();await host?.close?.();for(const dispose of disposers.reverse())await dispose();fs.writeFileSync(path.join(directory,'result.json'),JSON.stringify(result,null,2));}
console.log(JSON.stringify({directory,...result}));if(!result.success)process.exitCode=1;