codex-flows/docs/pages/tutorials/dispatch-release-event.md
2026-05-15 22:49:49 +00:00

1.9 KiB

title description
Dispatch a release event Use the shared flow client to trigger release automation from product code.

Dispatch a release event

This tutorial shows the product-facing path: build a deterministic event, select local or HTTP execution, and dispatch it through the same flow client.

1. Build a deterministic event

Products own event ids. Use a stable id when duplicate suppression matters:

const event = {
  id: "patch:upstream.release:openai/codex:rust-v1.2.3",
  type: "upstream.release",
  source: "patch",
  receivedAt: new Date().toISOString(),
  payload: {
    repo: "openai/codex",
    tag: "rust-v1.2.3",
  },
};

Normal dispatch is idempotent by event.id. Replays intentionally create a new attempt for the stored event.

2. Dispatch locally during CLI work

import { createFlowClient } from "@peezy.tech/flow-runtime/client";

const flows = createFlowClient({
  mode: "local",
  cwd: process.cwd(),
});

await flows.dispatchEvent(event);

Local mode discovers .codex/flows/* before flows/*, executes matching steps synchronously, and keeps in-memory state by default. Use state: { kind: "file" } when local ids and replay need to survive process restart.

3. Dispatch to an HTTP backend in service mode

const flows = createFlowClient({
  mode: "http",
  baseUrl: "http://127.0.0.1:7345",
  hmacSecret: process.env.PATCH_FLOW_DISPATCH_SECRET,
});

await flows.dispatchEvent(event);

HTTP mode speaks the backend /events, /runs, replay, and cancel surface. It inherits the backend's durable idempotency and run history.

4. Inspect the result

const flowEvent = await flows.getEvent(event.id);
const runs = await flows.listRuns({ eventId: event.id });

Run views include process status, semantic FLOW_RESULT status, effectiveStatus, attention flags, attempts, output, and result payloads.