Files
deepseek-harness/packages/experimental/webworker-runtime/src/storage/active.ts
T
imccyu f47b1ecac2 feat(webworker): browser worker host runtime and the vfs image packer
Two private experimental packages run the whole harness tree inside one
dedicated Web Worker. dsh-experimental-webworker-runtime owns the in-memory
VFS (BigInt stats with per-path identity and strictly increasing mtimes),
the CommonJS wrapper loader over a lazily-evaluated builtin table whose
shims typecheck against Node's own module types, the postMessage tunnel
speaking plain HTTP, the AsyncLocalStorage runtime, and the worker
assembly. dsh-experimental-webworker-packer lowers every module body at
pack time against the shared wrapper contract, sweeps the profile closure
by static reachability, and writes a deterministically gzip-compressed tar
the worker inflates through the browser's native DecompressionStream while
it downloads.
2026-08-21 20:35:32 +08:00

29 lines
851 B
TypeScript

/**
* Process-wide slot holding the mounted filesystem. Kept apart from any
* backend implementation: the `node:fs` proxy depends on the slot, not on
* which backend the worker entry mounted.
* @module @deepseek-ai/dsh-experimental-webworker-runtime/src/storage/active
*/
import type { MemoryVfs } from './memory.ts'
let active: MemoryVfs | undefined
/**
* Publish the filesystem the `node:fs` proxy reads.
* @param vfs - Filesystem mounted by the worker entry.
*/
export function setActiveVfs(vfs: MemoryVfs): void {
active = vfs
}
/**
* Read the mounted filesystem.
* @returns The active filesystem.
*/
export function requireActiveVfs(): MemoryVfs {
if (active === undefined) {
throw new Error('webworker vfs: no filesystem is mounted; the worker entry must call setActiveVfs before any node:fs access')
}
return active
}