# Schemas

> Zod schemas + inferred types — the Taskbox wire contract.

Source: https://taskbox.n.yatsyk.com/docs/schemas

# @taskbox/schemas

Zod schemas for everything that crosses a Taskbox boundary: the `TaskSpec`
input, the `TaskResult` output, the `TaskEvent` stream, errors, artifacts,
proxy / network configuration, and per-tool inputs (e.g. `media.downloadSubtitles`).
Every schema is paired with a type alias inferred from it, so the SDK and
the CLI consume the same source of truth as the in-container runner.

* **Stability:** beta
* **Platforms:** node, browser

## Install

```bash
npm i @taskbox/schemas
```

## Parse a TaskSpec

```ts
import { TaskSpecSchema, type TaskSpec } from "@taskbox/schemas";

const spec: TaskSpec = TaskSpecSchema.parse({
  tool: "media.downloadSubtitles",
  input: { url: "https://youtu.be/jNQXAC9IVRw", languages: ["en"] },
  network: { mode: "direct" },
  runtime: { backend: "podman" },
});
```

## Walk a TaskEvent stream

```ts
import { TaskEventSchema, type TaskEvent } from "@taskbox/schemas";

for (const line of jsonl.split("\n").filter(Boolean)) {
  const ev: TaskEvent = TaskEventSchema.parse(JSON.parse(line));
  if (ev.type === "task.completed") console.log("ok in", ev.durationMs, "ms");
}
```

See [API](./api.mdx) for the full export list.
