---
title: chartSchemaFor
description: The Chart grammar for one Open body, as a zod schema.
---

# `chartSchemaFor`

Function, in `@jr2/orchestrator/src/chart.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Charts.

```ts
function chartSchemaFor(decl: OpenBodyDeclaration): z.ZodType<ChartText>
```

The Chart grammar for one Open body, as a zod schema. The names that the Open body lends, and the
models and the Workspace accesses that it allows, are the only values that the schema takes.
Make it the parameter of the pick of a planner. The model then gets the grammar as the
parameters of its tool, and the Briefing tells it how a Chart runs. The door still checks each
Chart before it runs.

**Parameters**

- `decl` ([`OpenBodyDeclaration`](type-openbodydeclaration.md)): The declaration of the Open body that the Chart binds.

**Returns**: The schema of a Chart for that Open body.

**Example**

```ts
import { z } from "zod";
import { chartSchemaFor, defineEvent, type OpenBodyDeclaration } from "@jr2/orchestrator";

const declaration: OpenBodyDeclaration = {
  lends: { agents: ["writer"], gate: true },
  allows: { models: ["anthropic/claude-haiku-5-5"], workspace: ["none"] },
  ceilings: { turns: 12, wallClock: "30m", transitions: 500, fanOut: 2, size: 65536 },
};

export const runChart = defineEvent({
  name: "run_chart",
  description: "Run this Chart. Its outcome is the answer to this call.",
  input: z.object({ chart: chartSchemaFor(declaration) }),
});
```

**See also**

- [Let an Agent write a Chart](../../guides/let-an-agent-write-a-chart.md)
- [Charts](../../concepts/charts.md)
