fix: add web project folder picker and isolated HTML file previews

This commit is contained in:
Agent Workbench Dev
2026-11-02 08:54:31 +08:00
parent bfd2f213a5
commit 70ac4c40b5
28 changed files with 515 additions and 20 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
export const DESKTOP_CHANNELS = Object.freeze({ status: 'awb:desktop-status', pickProject: 'awb:desktop-pick-project',
revealFile: 'awb:desktop-reveal-file', projectFolder: 'awb:desktop-project-folder', reviewTask: 'awb:desktop-review-task', stopHost: 'awb:desktop-stop-host' });
revealFile: 'awb:desktop-reveal-file', openFilePreview: 'awb:desktop-file-preview', projectFolder: 'awb:desktop-project-folder', reviewTask: 'awb:desktop-review-task', stopHost: 'awb:desktop-stop-host' });
export const desktopError = message => Object.assign(new Error(message), { code: 'DESKTOP_SCOPE_REJECTED', status: 403 });
export function desktopOrigin(value, origin) {
try { const url = new URL(value); return url.origin === origin && url.protocol === 'http:' && !url.username && !url.password; } catch { return false; }
@@ -10,7 +10,7 @@ export function assertDesktopFrame(event, window, origin) {
}
export function desktopInput(action, input) {
const fields = { status: [], pickProject: [], stopHost: [], projectFolder: ['projectId'], reviewTask: ['projectId', 'sessionId', 'taskId'],
revealFile: ['projectId', 'sessionId', 'taskId', 'path', 'sha256'] }[action];
openFilePreview: ['projectId', 'url'], revealFile: ['projectId', 'sessionId', 'taskId', 'path', 'sha256'] }[action];
if (!fields) throw desktopError('本机操作不存在。');
const value = input ?? {};
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(key => !fields.includes(key))) throw desktopError('本机操作字段无效。');