fix(dsh): restore native file tools and official loading UI
Core regression / Python core and release configuration (push) Successful in 20s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python core and release configuration (push) Successful in 20s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
1340f6c233
commit
705c15eb93
19 files changed
+398
-42
No files matched your search
@@ -33,6 +33,7 @@ def main():
|
||||
parser.add_argument('--provider-config', type=Path)
|
||||
parser.add_argument('--live-model', action='store_true')
|
||||
parser.add_argument('--model-settings-check', action='store_true', help='Create an isolated custom provider using a local model-list fixture')
|
||||
parser.add_argument('--file-check', action='store_true', help='Pick and upload a real local text file and ZIP in the official UI')
|
||||
parser.add_argument('--incident', action='store_true', help='Inject a read-only controlled failure and verify automatic diagnosis and Git escalation')
|
||||
parser.add_argument('--outbox-only', action='store_true', help='Verify failed publication stays in local outbox without creating another real issue')
|
||||
parser.add_argument('--without-git', action='store_true', help='Simulate a client with no Git credentials or executable')
|
||||
@@ -40,6 +41,13 @@ def main():
|
||||
args = parser.parse_args()
|
||||
output = args.output.resolve()
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
if args.file_check:
|
||||
import zipfile
|
||||
fixtures = output / 'file-fixtures'
|
||||
fixtures.mkdir(exist_ok=True)
|
||||
(fixtures / 'dsh-upload.txt').write_text('DSH_UPLOAD_CONTENT_中文\n', encoding='utf8')
|
||||
with zipfile.ZipFile(fixtures / 'dsh-upload.zip', 'w', zipfile.ZIP_DEFLATED) as archive:
|
||||
archive.writestr('中文目录/说明.txt', 'DSH_ZIP_UPLOAD_CONTENT_中文')
|
||||
data = output / ('data-' + time.strftime('%Y%m%d-%H%M%S'))
|
||||
project_root = output / 'source-projects'
|
||||
source_hashes = {}
|
||||
@@ -65,14 +73,16 @@ def main():
|
||||
os.environ.pop('QT_QPA_PLATFORM', None)
|
||||
from PySide6.QtCore import QTimer, Qt
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox, QDialogButtonBox
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox, QDialogButtonBox, QFileDialog, QLineEdit
|
||||
if args.file_check:
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_DontUseNativeDialogs)
|
||||
from dx_productivity.trial_task_center import application
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
from dx_productivity.trial_task_center.ui.dsh_task_creation import DshTaskCreationDialog
|
||||
|
||||
report = {'driver': 'Qt QTest mouse clicks + Chromium CDP Input events', 'checks': []}
|
||||
state = {'phase': 'select', 'child': None, 'creation_step': 'input',
|
||||
'deadline': time.monotonic() + (420 if args.incident else 300 if args.create_task else 240 if args.live_model else 150)}
|
||||
'deadline': time.monotonic() + (600 if args.file_check else 420 if args.incident else 300 if args.create_task else 240 if args.live_model else 150)}
|
||||
|
||||
def build_window(service):
|
||||
if not args.create_task:
|
||||
@@ -91,6 +101,8 @@ def main():
|
||||
|
||||
def failed(error):
|
||||
report.update(status='failed', error=type(error).__name__ + ': ' + str(error))
|
||||
if window._dsh_view is not None:
|
||||
report['runtimeStatus'] = window._dsh_view.status.text()
|
||||
(output / 'desktop-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf8')
|
||||
child = state['child']
|
||||
if child and child.poll() is None:
|
||||
@@ -102,7 +114,43 @@ def main():
|
||||
try:
|
||||
if time.monotonic() > state['deadline']:
|
||||
raise TimeoutError('Native desktop acceptance timed out')
|
||||
if state['phase'] == 'ready' and window._dsh_view is not None and window._dsh_view.retry.isVisible():
|
||||
from dx_productivity.dsh.provider_config import load_provider
|
||||
key = load_provider(data / 'dsh').get('DSH_API_KEY', '')
|
||||
diagnostic = window._dsh_view.last_error
|
||||
if key:
|
||||
diagnostic = diagnostic.replace(key, '[redacted]')
|
||||
report['startupDiagnostic'] = diagnostic[-8000:]
|
||||
raise RuntimeError(window._dsh_view.status.text())
|
||||
modal = QApplication.activeModalWidget()
|
||||
if state['phase'] == 'ready' and window._dsh_view is not None and not report.get('officialLoadingPassed') and not state.get('checkingLoading'):
|
||||
state['checkingLoading'] = True
|
||||
def loading_ready(value):
|
||||
state['checkingLoading'] = False
|
||||
if value and not report.get('officialLoadingPassed'):
|
||||
assert not window._dsh_view.status.isVisible()
|
||||
report['officialLoadingPassed'] = True
|
||||
state['loadingCapture'] = subprocess.Popen(['node', str(REPO / 'tools/dsh_cdp.mjs'),
|
||||
'--capture-loading', str(args.port), str(output / 'official-loading.png')],
|
||||
cwd=REPO, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == 'nt' else 0)
|
||||
report['checks'].append('unmodified official frontend HARNESS loading spinner rendered before local runtime readiness')
|
||||
window._dsh_view.web.page().runJavaScript("!!document.querySelector('[data-dsh-boot] [data-dsh-boot-spinner]')", loading_ready)
|
||||
if args.file_check and isinstance(modal, QFileDialog) and not modal.property('dshAcceptancePicked'):
|
||||
modal.setProperty('dshAcceptancePicked', True)
|
||||
selected = (output / 'file-picker-request.json')
|
||||
assert selected.is_file(), 'Unexpected file picker'
|
||||
files = json.loads(selected.read_text(encoding='utf8'))
|
||||
edit = modal.findChild(QLineEdit, 'fileNameEdit')
|
||||
assert edit is not None
|
||||
QApplication.clipboard().setText(' '.join('"' + str(Path(f).resolve()) + '"' for f in files))
|
||||
edit.setFocus()
|
||||
QTest.keyClick(edit, Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier)
|
||||
QTest.keyClick(edit, Qt.Key.Key_V, Qt.KeyboardModifier.ControlModifier)
|
||||
buttons = modal.findChild(QDialogButtonBox)
|
||||
assert buttons is not None
|
||||
QTest.mouseClick(buttons.button(QDialogButtonBox.StandardButton.Open), Qt.MouseButton.LeftButton)
|
||||
report['checks'].append('selected owned text and ZIP fixtures in the real Qt file picker and clicked Open')
|
||||
if args.create_task and isinstance(modal, DshTaskCreationDialog):
|
||||
if state['creation_step'] == 'input':
|
||||
assert modal.name_edit.text() == 'DSH对话换料验收'
|
||||
@@ -124,6 +172,7 @@ def main():
|
||||
assert window.task_list.list.count() == 0
|
||||
click_navigation(window.dsh_action)
|
||||
state['phase'] = 'ready'
|
||||
state['runtimeWaitStarted'] = time.monotonic()
|
||||
report['checks'].append('opened native assistant from an empty task center')
|
||||
elif state['phase'] == 'select' and window.task_list.list.count() and not window._task_query.busy:
|
||||
item = window.task_list.list.item(0)
|
||||
@@ -142,13 +191,18 @@ def main():
|
||||
assert window.content_stack.currentWidget() is window._dsh_view
|
||||
report['checks'].append('clicked task row and opened DSH with one click on the right navigation item')
|
||||
state['phase'] = 'ready'
|
||||
state['runtimeWaitStarted'] = time.monotonic()
|
||||
elif state['phase'] == 'ready' and window._dsh_view is not None and window._dsh_view._started:
|
||||
if 'runtimeWaitStarted' in state:
|
||||
report['runtimeWaitSeconds'] = round(time.monotonic() - state['runtimeWaitStarted'], 2)
|
||||
script = 'verify_dsh_task_creation_ui.mjs' if args.create_task else 'verify_dsh_incident_ui.mjs' if args.incident else 'verify_dsh_native_ui.mjs'
|
||||
command = ['node', str(REPO / 'tools' / script), str(output), str(args.port), '--confirm-cancel']
|
||||
if args.live_model:
|
||||
command.append('--live-model')
|
||||
if args.model_settings_check:
|
||||
command.append('--model-settings-check')
|
||||
if args.file_check:
|
||||
command.append('--file-check')
|
||||
if args.outbox_only:
|
||||
command.append('--outbox-only')
|
||||
state['child'] = subprocess.Popen(command, cwd=REPO, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
@@ -215,6 +269,14 @@ def main():
|
||||
|
||||
application._load_window = lambda: build_window
|
||||
code = application.main(['--data-root', str(data)])
|
||||
capture = state.get('loadingCapture')
|
||||
if capture is not None:
|
||||
try:
|
||||
capture.communicate(timeout=5)
|
||||
except subprocess.TimeoutExpired:
|
||||
capture.terminate()
|
||||
capture.communicate(timeout=5)
|
||||
report['officialLoadingScreenshot'] = capture.returncode == 0
|
||||
if code or report.get('status') != 'passed':
|
||||
print(json.dumps(report, ensure_ascii=False))
|
||||
return 1
|
||||
@@ -226,8 +288,8 @@ def main():
|
||||
audit_file = data / 'dsh/harness-home/task-tool-audit.jsonl'
|
||||
audit = [json.loads(line) for line in audit_file.read_text(encoding='utf8').splitlines()] if audit_file.is_file() else []
|
||||
report['modelToolCalls'] = audit
|
||||
expected_tool = 'dx_task_create' if args.create_task else 'dx_task_snapshot'
|
||||
report['modelToolSucceeded'] = any(row['name'] == expected_tool and row['is_error'] is False for row in audit)
|
||||
expected_tools = ['read', 'extract_zip'] if args.file_check else ['dx_task_create' if args.create_task else 'dx_task_snapshot']
|
||||
report['modelToolSucceeded'] = all(any(row['name'] == name and row['is_error'] is False for row in audit) for name in expected_tools)
|
||||
(output / 'desktop-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf8')
|
||||
print(json.dumps(report, ensure_ascii=True))
|
||||
return 0 if report['cleanShutdown'] and not report['uncaughtErrors'] and not report['unexpectedUiErrors'] and (not (args.live_model or args.incident or args.create_task) or report['modelToolSucceeded']) else 1
|
||||
|
||||
+15
-5
@@ -1,12 +1,14 @@
|
||||
/** Tiny CDP driver for the real Qt Chromium page; no browser mocks. */
|
||||
import {writeFile} from 'node:fs/promises';
|
||||
|
||||
export async function connect(port=9226) {
|
||||
export async function connect(port=9226,{loading=false}={}) {
|
||||
let target;
|
||||
const deadline=Date.now()+45000;
|
||||
const deadline=Date.now()+60000;
|
||||
while(Date.now()<deadline){
|
||||
const targets=await fetch(`http://127.0.0.1:${port}/json`,{signal:AbortSignal.timeout(3000)}).then(r=>r.json());
|
||||
target=targets.find(x=>x.type==='page'&&x.url?.startsWith('http://127.0.0.1:'));
|
||||
let targets;
|
||||
try{targets=await fetch(`http://127.0.0.1:${port}/json`,{signal:AbortSignal.timeout(10000)}).then(r=>r.json());}
|
||||
catch{await new Promise(resolve=>setTimeout(resolve,100));continue;}
|
||||
target=targets.find(x=>x.type==='page'&&(loading?x.url?.startsWith('file:'):x.url?.startsWith('http://127.0.0.1:')));
|
||||
if(target)break;
|
||||
await new Promise(resolve=>setTimeout(resolve,100));
|
||||
}
|
||||
@@ -60,11 +62,19 @@ export async function connect(port=9226) {
|
||||
}
|
||||
|
||||
if(process.argv[1]?.endsWith('dsh_cdp.mjs')) {
|
||||
const client=await connect(Number(process.argv[2] || 9226));
|
||||
const loading=process.argv[2]==='--capture-loading';
|
||||
const client=await connect(Number(process.argv[loading?3:2] || 9226),{loading});
|
||||
try {
|
||||
if(loading){
|
||||
const actual=await client.evaluate(`({official:!!document.querySelector('[data-dsh-boot-spinner]'),text:document.body.innerText})`);
|
||||
if(!actual.official||!actual.text.includes('HARNESS'))throw Error('Official loading page was not rendered');
|
||||
await client.screenshot(process.argv[4]);
|
||||
console.log(JSON.stringify({officialLoading:true}));
|
||||
}else{
|
||||
console.log(JSON.stringify(await client.evaluate(`({title:document.title,text:document.body.innerText,
|
||||
buttons:[...document.querySelectorAll('button')].map(x=>({text:x.innerText,label:x.getAttribute('aria-label'),title:x.title})),
|
||||
svg:document.querySelectorAll('svg').length,animations:document.getAnimations().length,
|
||||
animatedSvg:document.querySelectorAll('animate,animateTransform,animateMotion').length,canvas:document.querySelectorAll('canvas').length})`)));
|
||||
}
|
||||
}finally{client.close();}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/** Upload owned files via the real composer menu and Qt's actual file chooser. */
|
||||
import assert from 'node:assert/strict';
|
||||
import {writeFile,readdir,readFile} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
export async function verifyFileUi(c,output){
|
||||
const wait=async(expression)=>{
|
||||
const end=Date.now()+30000;
|
||||
while(Date.now()<end){if(await c.evaluate(expression))return;await new Promise(r=>setTimeout(r,100));}
|
||||
throw Error('File UI timed out: '+expression);
|
||||
};
|
||||
const fixtures=path.join(output,'file-fixtures');
|
||||
const files=['dsh-upload.txt','dsh-upload.zip'].map(name=>path.join(fixtures,name));
|
||||
await writeFile(path.join(output,'file-picker-request.json'),JSON.stringify(files));
|
||||
// Plus opens the official command menu; choose its native attachment action.
|
||||
const plus=`[...document.querySelectorAll('button[aria-label="添加文件或调用指令"]')].find(e=>e.getBoundingClientRect().width>0)`;
|
||||
await c.click(plus);
|
||||
const fileOption=`[...document.querySelectorAll('[role="option"],button')].find(e=>e.getBoundingClientRect().width>0&&/^文件\\s*file/.test(e.textContent.trim()))`;
|
||||
await wait(`!!(${fileOption})`);
|
||||
await c.click(fileOption);
|
||||
await wait(`document.body.innerText.includes('dsh-upload.txt')&&document.body.innerText.includes('dsh-upload.zip')`);
|
||||
await wait(`![...document.querySelectorAll('[role="progressbar"]')].some(e=>e.getBoundingClientRect().width>0)`);
|
||||
await c.screenshot(path.join(output,'file-uploaded.png'));
|
||||
// Validate the uploaded bytes in Harness's actual owned storage, not the DOM echo.
|
||||
const roots=(await readdir(output)).filter(x=>x.startsWith('data-'));
|
||||
assert.equal(roots.length,1);
|
||||
const home=path.join(output,roots[0],'dsh/harness-home');
|
||||
const expected=await Promise.all(files.map(f=>readFile(f)));
|
||||
const found=new Set();
|
||||
async function scan(dir){
|
||||
for(const entry of await readdir(dir,{withFileTypes:true})){
|
||||
const filename=path.join(dir,entry.name);
|
||||
if(entry.isDirectory())await scan(filename);
|
||||
else if(entry.isFile()){
|
||||
const data=await readFile(filename);
|
||||
expected.forEach((bytes,i)=>{if(data.equals(bytes))found.add(i);});
|
||||
}
|
||||
}
|
||||
}
|
||||
const end=Date.now()+20000;
|
||||
while(found.size<files.length&&Date.now()<end){await scan(home);if(found.size<files.length)await new Promise(r=>setTimeout(r,150));}
|
||||
assert.equal(found.size,2,'text and ZIP must reach actual Harness file storage unchanged');
|
||||
return {status:'passed',realQtFilePicker:true,textAndZipUploaded:true,storedBytesMatched:true};
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/** Exercise actual Harness file tools against owned folders and ZIP archives. */
|
||||
import assert from 'node:assert/strict';
|
||||
import {mkdir,mkdtemp,writeFile,readFile,readdir} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {createRequire} from 'node:module';
|
||||
import {bootRuntime} from '../integration/dsh/start.mjs';
|
||||
const require=createRequire(new URL('../integration/dsh/start.mjs',import.meta.url));
|
||||
const {zipSync,strToU8}=require('fflate');
|
||||
const output=path.resolve('build/dsh-files-verification');await mkdir(output,{recursive:true});
|
||||
const root=await mkdtemp(path.join(output,'run-'));
|
||||
for(const key of ['DSH_API_KEY','DSH_API_BASE','DSH_MODEL','DX_DSH_MODELS'])delete process.env[key];
|
||||
process.env.DX_DSH_HOME=path.join(root,'home');process.env.DX_DSH_CONTEXT_FILE=path.join(root,'context.json');
|
||||
await writeFile(process.env.DX_DSH_CONTEXT_FILE,'{"task_id":"files-fixture","revision":"files","status":"observe"}');
|
||||
const source=path.join(root,'输入 文件夹');await mkdir(source);
|
||||
await writeFile(path.join(source,'说明.txt'),'DSH_FILE_CONTENT_中文\n');
|
||||
const archive=path.join(source,'资料.zip');
|
||||
await writeFile(archive,zipSync({'子目录/说明.txt':strToU8('DSH_ZIP_CONTENT_中文'),'binary.bin':new Uint8Array([0,1,2,255])}));
|
||||
const {ctx,shutdown}=await bootRuntime({announce:false});
|
||||
try{
|
||||
const names=ctx.tools.schemas().map(x=>x.name);
|
||||
for(const name of ['read','read_image','glob','grep','working_directory','extract_zip'])
|
||||
assert.ok(names.includes(name),'Missing file capability: '+name);
|
||||
const workspace=await ctx.workspaceRegistry.create(process.env.DX_DSH_WORKSPACE,'File fixture');
|
||||
const {sessionId}=await ctx.sessionController.create({workspaceId:workspace.id,agentPreset:'dx-task'});
|
||||
const agent=ctx.agents.get(sessionId);
|
||||
const call=async(name,args)=>ctx.tools.execute({name,arguments:args,callId:crypto.randomUUID(),agent,signal:AbortSignal.timeout(20000)});
|
||||
const ok=async(name,args)=>{
|
||||
const result=await call(name,args);assert.equal(result.isError,false,name+': '+JSON.stringify(result));return result;
|
||||
};
|
||||
assert.match(JSON.stringify(await ok('read',{file_path:path.join(source,'说明.txt')})),/DSH_FILE_CONTENT_中文/);
|
||||
assert.match(JSON.stringify(await ok('glob',{pattern:'*',path:source})),/说明.txt/);
|
||||
assert.match(JSON.stringify(await ok('grep',{pattern:'DSH_FILE_CONTENT',path:source})),/DSH_FILE_CONTENT/);
|
||||
await ok('working_directory',{cd:source});
|
||||
assert.match(JSON.stringify(await ok('read',{file_path:'说明.txt'})),/DSH_FILE_CONTENT/);
|
||||
const extracted=await ok('extract_zip',{file_path:'资料.zip'});
|
||||
const destination=extracted.value.directory;
|
||||
assert.equal(await readFile(path.join(destination,'子目录/说明.txt'),'utf8'),'DSH_ZIP_CONTENT_中文');
|
||||
assert.deepEqual(new Uint8Array(await readFile(path.join(destination,'binary.bin'))),new Uint8Array([0,1,2,255]));
|
||||
assert.match(JSON.stringify(await ok('read',{file_path:path.join(destination,'子目录/说明.txt')})),/DSH_ZIP_CONTENT/);
|
||||
assert.notEqual((await ok('extract_zip',{file_path:archive})).value.directory,destination,'repeated extraction must not overwrite');
|
||||
await writeFile(path.join(source,'unsafe.zip'),zipSync({'../escaped.txt':strToU8('must not escape')}));
|
||||
const before=await readdir(source);
|
||||
assert.equal((await call('extract_zip',{file_path:'unsafe.zip'})).isError,true);
|
||||
assert.deepEqual(await readdir(source),before,'unsafe archive must not publish a partial directory');
|
||||
await writeFile(path.join(source,'broken.zip'),'not a zip');
|
||||
assert.equal((await call('extract_zip',{file_path:'broken.zip'})).isError,true);
|
||||
const corrupt=Buffer.from(zipSync({'evidence.txt':strToU8('ORIGINAL_CONTENT')},{level:0}));
|
||||
const payload=corrupt.indexOf(Buffer.from('ORIGINAL_CONTENT'));assert.ok(payload>0);corrupt[payload]=88;
|
||||
await writeFile(path.join(source,'corrupt.zip'),corrupt);
|
||||
assert.equal((await call('extract_zip',{file_path:'corrupt.zip'})).isError,true,'CRC mismatch must not report successful extraction');
|
||||
assert.equal(await readFile(path.join(source,'说明.txt'),'utf8'),'DSH_FILE_CONTENT_中文\n');
|
||||
ctx.emit('dx/diagnose-request',{request_id:'files-incident-probe',incident_id:'a'.repeat(24),phase:'diagnose',
|
||||
snapshot:{task_id:'files-fixture'},evidence:'Owned fixture; no model is configured.'});
|
||||
let incident;
|
||||
const deadline=Date.now()+20000;
|
||||
while(Date.now()<deadline){
|
||||
incident=ctx.agents.list().find(value=>value.id!==agent.id);
|
||||
if(incident)break;
|
||||
await new Promise(resolve=>setTimeout(resolve,50));
|
||||
}
|
||||
assert.ok(incident,'automatic incident session must be created');
|
||||
let marked=false;
|
||||
while(Date.now()<deadline){
|
||||
const snapshot=await ctx.tools.execute({name:'dx_task_snapshot',arguments:{},callId:crypto.randomUUID(),agent:incident,signal:AbortSignal.timeout(2000)});
|
||||
if(snapshot.value?.revision==='a'.repeat(24)){marked=true;break;}
|
||||
await new Promise(resolve=>setTimeout(resolve,50));
|
||||
}
|
||||
assert.ok(marked,'incident snapshot must be bound before checking admission');
|
||||
for(const [name,args] of [['read',{file_path:path.join(source,'说明.txt')}],['extract_zip',{file_path:archive}]]){
|
||||
const denied=await ctx.tools.execute({name,arguments:args,callId:crypto.randomUUID(),agent:incident,signal:AbortSignal.timeout(2000)});
|
||||
assert.equal(denied.isError,true,'automatic incident must not inherit interactive file access');
|
||||
}
|
||||
const report={status:'passed',realHarness:true,read:true,folderSearch:true,workingDirectory:true,
|
||||
zipTextAndBinary:true,repeatedExtractionNoOverwrite:true,zipTraversalRejected:true,invalidZipRejected:true,corruptZipRejected:true,
|
||||
automaticSessionIsolation:true};
|
||||
await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));console.log(JSON.stringify(report));
|
||||
}finally{await shutdown.shutdown(0);}
|
||||
@@ -58,6 +58,10 @@ try {
|
||||
await c.click(`document.querySelectorAll('button[aria-label="新建会话"]')[1]`);
|
||||
await wait(`!!document.querySelector('[data-testid="dx-task-panel"]')`);
|
||||
report.checks.push('native new conversation retains task dock');
|
||||
if(process.argv.includes('--file-check')){
|
||||
const {verifyFileUi}=await import('./verify_dsh_file_ui.mjs');
|
||||
report.files=await verifyFileUi(c,output);
|
||||
}
|
||||
if(!liveModel) {
|
||||
await c.click(`document.querySelector('button[aria-label="收起侧边栏"]')`);
|
||||
await wait(`!!document.querySelector('button[aria-label="打开侧边栏"]')`);
|
||||
@@ -86,7 +90,8 @@ try {
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyDown',key:'Escape',code:'Escape'});
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyUp',key:'Escape',code:'Escape'});
|
||||
await c.click(`document.querySelector('[contenteditable="true"]')`);
|
||||
const prompt=liveModel ? '请分析当前任务的状态和异常,告诉我任务名称、现在进展到哪一步以及接下来可以做什么。不要修改工程。' : '请分析当前任务的异常,并说明允许的处理方式。';
|
||||
const fileCheck=process.argv.includes('--file-check');
|
||||
const prompt=liveModel ? (fileCheck?'请分析当前任务的附件:读取上传的 dsh-upload.txt,再解压 dsh-upload.zip 并读取其中说明.txt,分别告诉我这两份文本的完整内容和解压后的真实目录。不要修改原文件或运行 CAD。':'请分析当前任务的状态和异常,告诉我任务名称、现在进展到哪一步以及接下来可以做什么。不要修改工程。') : '请分析当前任务的异常,并说明允许的处理方式。';
|
||||
report.prompt=prompt;
|
||||
report.explicitToolNamesInPrompt=false;
|
||||
await c.call('Input.insertText',{text:prompt});
|
||||
@@ -96,8 +101,8 @@ try {
|
||||
if(liveModel) {
|
||||
await c.click(`document.querySelector('button[aria-label="发送消息"]')`);
|
||||
const replies=`[...document.querySelectorAll('[data-chat-group-part="response"]')].map(e=>e.innerText).join('\\n')`;
|
||||
await wait(`(${replies}).length>30 && /任务|状态/.test(${replies})`,100000);
|
||||
await wait(`![...document.querySelectorAll('button[aria-label="停止生成"]')].some(e=>e.getBoundingClientRect().width>0)`,100000);
|
||||
await wait(fileCheck?`(${replies}).includes('DSH_UPLOAD_CONTENT')&&(${replies}).includes('DSH_ZIP_UPLOAD_CONTENT')`:`(${replies}).length>30 && /任务|状态/.test(${replies})`,fileCheck?180000:100000);
|
||||
await wait(`![...document.querySelectorAll('button[aria-label="停止生成"]')].some(e=>e.getBoundingClientRect().width>0)`,fileCheck?180000:100000);
|
||||
report.reply=await c.evaluate(replies);
|
||||
report.liveModelReplyTested=true;
|
||||
report.liveTurnCompleted=true;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import {mkdtemp,mkdir,readFile,writeFile,readdir} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {bootRuntime,overlay,prepareProfileDirectory} from '../integration/dsh/start.mjs';
|
||||
import {bootRuntime,overlay,prepareProfileDirectory,TASK_TOOLS,FILE_TOOLS} from '../integration/dsh/start.mjs';
|
||||
|
||||
const output=path.resolve('build/dsh-profile-settings-verification');
|
||||
await mkdir(output,{recursive:true});
|
||||
@@ -34,7 +34,7 @@ assert.equal(await readFile(path.join(legacyDir,'cordis.patch.yml'),'utf8'),migr
|
||||
const {ctx,shutdown}=await bootRuntime({announce:false});
|
||||
try{
|
||||
assert.deepEqual((await ctx.llm.listModels('profile-fixture')).map(x=>x.id),['persisted-fixture-model']);
|
||||
assert.equal(ctx.tools.schemas().length,7);
|
||||
assert.equal(ctx.tools.schemas().length,TASK_TOOLS.length+FILE_TOOLS.length);
|
||||
console.log(JSON.stringify({status:'passed',nativeSettingsPreserved:true,actualProviderRestored:true,
|
||||
legacyMigrationPreservedModels:true,byteBackup:true,modelRequests:0}));
|
||||
}finally{await shutdown.shutdown(0);}
|
||||
@@ -4,7 +4,7 @@ import {mkdir,writeFile} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath,pathToFileURL} from 'node:url';
|
||||
import {createRequire} from 'node:module';
|
||||
import {bootRuntime} from '../integration/dsh/start.mjs';
|
||||
import {bootRuntime,TASK_TOOLS,FILE_TOOLS} from '../integration/dsh/start.mjs';
|
||||
|
||||
const repo=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
||||
const output=path.join(repo,'build/dsh-native-cli-verification');
|
||||
@@ -18,7 +18,7 @@ const report={};
|
||||
try {
|
||||
const schemas=ctx.tools.schemas();
|
||||
report.tools=schemas.map(x=>x.name);
|
||||
assert.deepEqual(report.tools,['dx_task_snapshot','dx_task_create','dx_task_catalog','dx_task_preflight','dx_task_manage','dx_task_execute','dx_task_operations']);
|
||||
assert.deepEqual([...report.tools].sort(),[...TASK_TOOLS,...FILE_TOOLS].sort());
|
||||
const presets=await ctx.agentPresets.list();
|
||||
report.presets=presets.map(x=>x.id);
|
||||
assert.deepEqual(report.presets,['dx-task']);
|
||||
|
||||
Reference in new issue
Block a user