> ## Documentation Index
> Fetch the complete documentation index at: https://smithers.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Browser runtime

> Run portable Smithers workflows in a browser through the RuntimeAdapter contract.

Import the browser-safe facade from `smithers-orchestrator/browser`. It runs the
real Smithers driver, scheduler, renderer, graph extractor, schema validation,
and task dependency semantics without pulling Node database, server, CLI-agent,
or subprocess code into the bundle.

```tsx theme={"theme":{"light":"github-light","dark":"github-dark"}}
import React from "react";
import { z } from "zod";
import {
  Task,
  Workflow,
  createBrowserRuntime,
  createBrowserSmithers,
  defineBrowserWorkflow,
} from "smithers-orchestrator/browser";

const resultSchema = z.object({ answer: z.number() });
const workflow = defineBrowserWorkflow(() =>
  React.createElement(
    Workflow,
    { name: "browser-example" },
    React.createElement(
      Task,
      {
        id: "answer",
        output: "results",
        outputSchema: resultSchema,
        agent: {
          async generate() {
            return { answer: 42 };
          },
        },
      },
      "Return the answer.",
    ),
  ),
);

const runtime = createBrowserRuntime();
const smithers = createBrowserSmithers({ workflow, runtime });
const run = await smithers.run({ input: {}, runId: "browser-demo" });

console.log(run.status); // "finished"
console.log(await smithers.getOutputs(run.runId));
```

`createBrowserSmithers` creates a fresh driver and scheduler session for every
`run()` call. `getRun(runId)` and `getOutputs(runId)` read through the selected
runtime storage adapter. `runBrowserWorkflow(workflow, options)` is the
one-shot equivalent when you do not need to retain the Smithers wrapper.

## Browser-safe exports

| Export                                                                                               | Purpose                                                      |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| `defineBrowserWorkflow(build, options?)`                                                             | Define a portable workflow from a context-to-React builder.  |
| `createBrowserRuntime(options?)`                                                                     | Create the default browser `RuntimeAdapter`.                 |
| `createBrowserSmithers({ workflow, runtime?, runtimeOptions? })`                                     | Create a reusable runner with run and output lookup methods. |
| `runBrowserWorkflow(workflow, options?)`                                                             | Run one workflow once.                                       |
| `Task`, `Workflow`, `Sequence`, `Worktree`                                                           | Browser-safe workflow primitives.                            |
| `RuntimeCapabilityError`, `RUNTIME_CAPABILITY_UNAVAILABLE`                                           | Typed failure for unavailable host capabilities.             |
| `RuntimeAdapter`, `BrowserRuntimeOptions`, `BrowserWorkflow`, `BrowserRunOptions`, `BrowserSmithers` | Public TypeScript contracts.                                 |

## Runtime options

The default runtime uses `Date`, `performance`, abortable `setTimeout`, Web
Crypto UUIDs, and Map-backed run/output storage. Override any portable seam:

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
type BrowserRuntimeOptions = {
  clock?: RuntimeClock;
  storage?: RuntimeStorage;
  uuid?: () => string;
  executeTask?: (
    task: TaskDescriptor,
    context: TaskExecutorContext,
  ) => Promise<unknown> | unknown;
};
```

Provide `storage` when state must outlive a page refresh. Provide
`executeTask` to route task execution through an application-owned worker,
provider client, or policy boundary. The default executor supports static and
compute tasks plus in-process agents exposing `generate`, `execute`, `run`, or
`call`. It validates Zod-like `outputSchema` values before storing outputs.

## Capability boundary

The browser adapter intentionally fails closed for `filesystem`, `subprocess`,
`worktree`, and `sandbox`. Calling one of those operations throws a
`RuntimeCapabilityError` with code `RUNTIME_CAPABILITY_UNAVAILABLE`, the
runtime name, capability, and operation. The exported `Worktree` primitive is
portable at graph-render time, but a browser run cannot resolve a real
worktree unless the application supplies a custom `RuntimeAdapter` that owns
that capability.

The browser facade does not include Node database factories, server helpers,
CLI agents, bundled tools, or the full Node component barrel. Use the main
`smithers-orchestrator` entry point for those surfaces.

***

**Source** [browser engine](https://github.com/smithersai/smithers/blob/main/packages/engine/src/browser.js) · **Tests** [browser runtime tests](https://github.com/smithersai/smithers/blob/main/packages/engine/tests/browser.test.jsx) · **See also** [Run workflow](/runtime/run-workflow), [Testing workflows](/guides/testing-workflows), [Package configuration](/reference/package-configuration)
