fix(sandbox): support real development workspaces

- raise finite development defaults/ceilings and queue capacities
- migrate untouched v1 default policy
- exclude generated output and shipped runtime paths from snapshots
- report snapshot limit errors with the offending path
This commit is contained in:
xiaohan.yuan committed 2026-10-18 18:08:20 +08:00
1 parent c7d6c558e6
commit b2d37472f0
9 files changed
+115 -28

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@ import { assertActive } from './policy'
interface Waiting { workspace: string; start(): void; cancel(): void }
const queue: Waiting[] = [], busy = new Set<string>()
const maximumActive = 4, maximumQueued = 32
const maximumActive = 4, maximumQueued = 64
function drain(): void {
for (let index = 0; index < queue.length && busy.size < maximumActive;) {
const item = queue[index]
@@ -15,7 +15,7 @@ function drain(): void {
export async function withSandboxExecution<T>(root: string, signal: AbortSignal | undefined, operation: (canonicalRoot: string) => Promise<T>): Promise<T> {
assertActive(signal)
const real = await fs.realpath(root), workspace = process.platform === 'win32' ? real.toLowerCase() : real
if (queue.length >= maximumQueued || queue.filter(item => item.workspace === workspace).length >= 8) throw new Error('沙盒执行队列已满,请稍后重试')
if (queue.length >= maximumQueued || queue.filter(item => item.workspace === workspace).length >= 12) throw new Error('沙盒执行队列已满,请稍后重试')
return new Promise<T>((done, reject) => {
const item: Waiting = {
workspace,