Voicebox documentation

Zero-Server Browser Delegation & Task Placement

Voicebox supports running task delegation (delegate_task, task_status, cancel_task) across browser-only, local machine, and remote server environments. Where a task executes is determined by the target environment’s placement (browser, machine, or remote) rather than requiring a central server broker (core/tasks.ts, lib/task-placement.mjs).


1. The Three Execution Placements

Placement Execution Runtime Supported Root Kinds Max Deadline Max Active Tasks Transport
browser In-page / Web Worker opfs, handle 300s (5 min) 4 In-memory / MessagePort
machine Local host process / stdio machine 3600s (1 hr) 8 Local process / stdio pipe
remote Paired remote server machine (on remote) 3600s (1 hr) 8 Paired HTTP / WebSocket

Placement is derived automatically from the environment descriptor:


2. Core Contracts & Bounds

1. Portable Task Roots (core/tasks.ts)

reduceTask in core/tasks.ts validates task log entries across all three workspace root types without assuming a local POSIX filesystem path:

const expectedRoot = record.root.kind === "handle"
  ? `picked:${record.root.id}`
  : `${record.root.kind}:${record.root.path}`;
if (record.instance !== entry.instance || entry.root !== expectedRoot) {
  throw new Error("task writer or root mismatch");
}

2. Placement Execution Bounds (PLACEMENT_BOUNDS)

Defined in core/tasks.ts and enforced synchronously at admission via validatePlacementBounds(placement, bounds) in lib/task-placement.mjs:

export const PLACEMENT_BOUNDS: Record<TaskPlacement, TaskPlacementBounds> = {
  browser: { defaultDeadlineMs: 30000, maxDeadlineMs: 300000, maxOutputBytes: 65536, maxActiveTasks: 4 },
  machine: { defaultDeadlineMs: 60000, maxDeadlineMs: 3600000, maxOutputBytes: 65536, maxActiveTasks: 8 },
  remote:  { defaultDeadlineMs: 60000, maxDeadlineMs: 3600000, maxOutputBytes: 65536, maxActiveTasks: 8 },
};

Requests exceeding the target placement’s deadline or output ceiling are refused at admission with unbounded-executor.


3. Browser Task Host (lib/task-placement.mjs)

createBrowserTaskHost(options) implements full task admission, execution, and cancellation inside the browser runtime with zero Node.js dependencies:

Direct Placement Dispatch (createPlacementDispatcher)

createPlacementDispatcher({ hosts }) routes delegate_task, task_status, and cancel_task directly to the host responsible for the target environment’s placement (browser, machine, or remote), avoiding any mandatory server round-trip for browser-local tasks.

Verification Suite

node --test tests/task-placement.test.mjs