feat(runtime): default to passthrough and persist execution permissions

This commit is contained in:
Agent Workbench Dev
2026-11-06 04:58:57 +08:00
parent 67c034f4b6
commit 2fa220735d
113 changed files with 1866 additions and 631 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
import { unrestricted, ceiling } from '../../shared/contracts/execution-policy.mjs';
import fs from 'node:fs';
import path from 'node:path';
import http from 'node:http';
@@ -62,7 +63,7 @@ export class LocalFilePreviews {
if (!mediaType) throw fail('此文件类型不用于网页预览。', 403);
await verifyWorkspaceProject(this.store, project);
const file = safePath(project, resource), stat = fs.statSync(file);
if (!stat.isFile() || stat.size > 20 * 1024 * 1024) throw fail('资源不存在或超过 20 MB 预览上限。', 413);
if (!stat.isFile() || stat.size > ceiling(this.store, 20 * 1024 * 1024)) throw fail('资源不存在或超过 20 MB 预览上限。', 413);
const bytes = fs.readFileSync(file);
entry.lastRead = Date.now();
response.writeHead(200, { 'Content-Type': mediaType, 'Content-Length': bytes.length });
+2 -1
View File
@@ -1,3 +1,4 @@
import { unrestricted } from '../../shared/contracts/execution-policy.mjs';
import fs from 'node:fs';
import path from 'node:path';
import { randomUUID } from 'node:crypto';
@@ -58,7 +59,7 @@ export class PreviewManager {
const plan = { schemaVersion: 1, id: randomUUID(), sessionId: session.id, projectId: project.id, taskId: session.taskId, runId: session.runId,
root: project.root, workspace: projectWorkspaceIdentity(project), nodeIdentity: node.identity, sourceFingerprint: inspection.sourceFingerprint,
cli, script: manifest.scripts.dev, invocation: { executable: node.runtime.node.path, args: [cli.path, '--host', '127.0.0.1', '--port', String(port), '--strictPort', '--clearScreen', 'false'] },
port, url: 'http://127.0.0.1:' + port + '/', timeoutMs: 8 * 60 * 60 * 1000, status: 'planned', createdAt: at() };
port, url: 'http://127.0.0.1:' + port + '/', timeoutMs: unrestricted(this.store) ? 0 : 8 * 60 * 60 * 1000, status: 'planned', createdAt: at() };
plan.fingerprint = hash(seal(plan)); const artifact = this.artifact(session, plan.runId, seal(plan), 'preview-plan');
plan.artifactId = artifact.id; plan.artifactSha256 = artifact.sha256;
return this.store.putRecord('preview_plan', session, plan, 'preview.planned');