Step 5 of 8

Phase 4 — Dispatch

Time: ~10 minutes
Prerequisites: Phase 0 read; you want a structured request/response contract
You'll need: TypeScript or JavaScript; optional: an app that calls AI APIs

This phase introduces Dispatch (the in-process model-execution Interaction Format; formerly @restormel/aaif): typed request and response shapes. Types, validation, and a runtime helper (executeDispatchRequest) live in @restormel/dispatch. Dispatch is an in-process contract, not a wire protocol — for cross-agent interop see A2A.

Step 4.1 — Request shape

DispatchRequest: input, task?, constraints? (maxCost/latency/tokens), user?, and routing? (model/provider).

Step 4.2 — Response shape

DispatchResponse: output, provider, model, cost, routing.reason.

Step 4.3 — Install and use

CLI
pnpm add @restormel/dispatch
TypeScript
import type { DispatchRequest, DispatchResponse } from "@restormel/dispatch";
import { isDispatchRequest, isDispatchResponse } from "@restormel/dispatch";

Use the type guards to validate incoming/outgoing payloads. How to test: Pass a sample object to isDispatchRequest / isDispatchResponse; confirm they return true for valid shapes.

Prompts for this phase

Optional. Use if a coding agent should install @restormel/dispatch and verify type guards.

Checkpoint

You now have @restormel/dispatch installed and request/response types and validation guards in use (or ready for when the runtime exists).