---
title: EventDef
description: "A workflow event, as `defineEvent` gives it back: plain, frozen data and a zod schema, safe to import anywhere."
---

# `EventDef`

Type, in `src/define-event.ts` of `@jr2/agent-protocol`, a dependency of `@jr2/orchestrator`. The signature of an export, or a type that it names, names this type. The [Authoring surface](../authoring-surface.md) page lists each export. This type is not an export of `@jr2/orchestrator`, so a workflow module does not import it by name.

```ts
type EventDef<Name extends string = string, Input extends z.ZodObject = z.ZodObject> = {
  readonly name: Name;
  readonly description?: string;
  readonly input: Input;
  readonly semantics: EventSemantics;
  readonly audience?: EventAudience;
};
```

A workflow event, as `defineEvent` gives it back: plain, frozen data and a zod schema, safe to
import anywhere. Give it to `jr2Setup({ events })`. A Machine accepts only the events in that
list.

**Fields**

- `name`: `Name`

  The event's name: its xstate event `type`, and the name of its tool on the Agent's Menu.
- `description` (optional): `string`

  What the event means. An Agent's model reads it as the tool's description.
- `input`: `Input`

  The schema of the event's payload: a flat `z.object`, never a union.
- `semantics`: [`EventSemantics`](type-eventsemantics.md)

  How the sender gets its answer: always `"ack"` on an event that `createMachine` accepts.
- `audience` (optional): [`EventAudience`](type-eventaudience.md)

  Who may send the event. Absent: the state of each `on` key decides (see [`EventAudience`](type-eventaudience.md)).

**See also**

- [Write a Workflow](../../guides/write-a-workflow.md)
- [ADR-0011: Control events are workflow-defined and delivered by closure, not routed](../decisions/0011-workflow-defined-events.md)
