From 36ab232bceac29904d1379f082f692a3ddfd7a2c Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Mon, 30 Nov 2026 12:58:30 +0000 Subject: [PATCH 1/2] docs: add AGENTS.md with the demo-building rules Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ CLAUDE.md | 1 + README.md | 2 +- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 AGENTS.md create mode 100644 CLAUDE.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..cc0e9b9 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,68 @@ +# AGENTS.md + +Rules for agents building or changing a demo in this repo. Read the root `README.md` first, then the README of the demo you're touching. This repo is public: name no individuals, link no private repos or internal tools, and don't write about what a product can't do. + +## Demo shape + +- **One folder per demo:** `//`. Hookdeck features count as a vendor (`hookdeck/`); `ecommerce/` is the one exception. Add the demo to the root README table. +- **Three parts only:** the demo app, the platform it demos, and Event Gateway. No automation tools, hosted databases or other third-party services. +- **Standalone:** people copy one folder with `npx giget@latest gh:hookdeck/hookdeck-demos//`, so nothing may import from outside the folder. CI proves it by building each demo from a copy of its folder alone. +- **Same scripts:** `npm run setup`, `listen`, `typecheck`, and `probe` or `simulate` where they apply. Follow the demo closest to yours, for example `vapi/agency-routing`. +- **README:** setup steps, the `.env` variables and where to get each, and how to make a test call. +- **TypeScript, Node 22.** + +## `_shared` and sync + +- **`_shared/` is the source of truth** for the design system, Hookdeck API and CLI helpers, flow drawer, scene kit, topology pane and theme switch. Edit there, never in a demo's copy. Copies carry a "Generated from" header, and directories carry a `GENERATED.md`. +- **`_shared/manifest.json`** says which demo takes which piece and where it lands. To add a demo to a piece, add it to `demos` in the manifest. +- **Run `npm run sync-shared`** from the repo root after any change in `_shared/`. `npm run sync-shared -- --check` changes nothing and exits non-zero on drift. +- **CI runs the check on every pull request** (`.github/workflows/shared.yml`, no `paths:` filter), then builds each manifest demo from an isolated copy, with `npm ci` or `npm install` and its `typecheck` script. + +## Setup and verification + +- **Setup is TypeScript:** `npm run setup` calls the platform's API and the Hookdeck REST API (version `2026-09-01`) through the `hookdeck()` helper. The CLI is used only for `npm run listen`. +- **Credentials come from `.env`:** `HOOKDECK_API_KEY` for a Hookdeck project, plus the platform's keys. Don't use the machine's default CLI profile. Keep `.env.example` complete, never print secret values, and never sign up for a platform with someone's identity. Build what you can without keys, then stop and list the exact `.env` variables and where to get each. +- **Event Gateway verifies** the platform's signature at the source. Create sources with the REST API `auth` config and check the source reports `authenticated`. +- **The app verifies `x-hookdeck-signature`** on every delivery, using the shared `hookdeck-signature` piece. +- **Retries and dedup:** setup adds a retry rule so the data-flow pane shows retries, and a deduplicate rule where the platform can send duplicates. + +## Demo UI + +- **Use the Hookdeck design system** from `_shared/ds`. Don't add new colors. +- **Keep the main view on the use case.** Explanations go behind ⓘ dialogs or hovers. +- **One theme per demo** through `_shared/theme`. +- **Data flow pane:** each demo shows each message moving through Event Gateway live, using `_shared/flow-drawer` and `_shared/topology-pane`. Scenes come from `_shared/scenes`; follow the `hookdeck-topology-diagrams` skill and `_shared/scenes/README.md`. +- **A "Start call" button** uses the platform's browser SDK, so nobody needs the vendor dashboard to try the demo. Private keys stay on the server; the server returns only public keys, signed URLs or short-lived tokens. +- **Pin browser SDKs** to an exact version loaded from esm.sh, and pick a version at least two weeks old. +- **Bind to `127.0.0.1`** by default, with `HOST` as the override, and tell people to open the app as `localhost`. + +## Failure injection + +- **Each demo has a failure panel:** fail the next N deliveries with a `503`, and where it applies delay each answer. The pane then shows Event Gateway keeping the event and retrying. +- **Keep the retry interval short** in the demo's retry rule so a retry is visible. Say in a comment that production would use a longer one. +- **Skip deliveries that are part of a live conversation by default**, such as a Vapi tool call, because a failed one delays the spoken answer. Offer a checkbox to include them. + +## Probes + +- **`npm run probe` proves verification:** a correctly signed request is recorded as verified, and a badly signed one as rejected with `rejection_cause` `VERIFICATION_FAILED` and no event. +- **Assert on the request record from the Hookdeck API** (`verified`, `rejection_cause`), not on the HTTP status or on `GET /sources`, which redacts auth. The status Event Gateway returns to a rejected request depends on the source type, so don't hard-code one. +- **Wording:** write "Event Gateway verifies" in code comments, READMEs, UI strings and commit messages. Don't write "edge", "core" or "after ingestion". + +## Local running + +- **Run one `hookdeck listen` per set of sources.** Two processes for the same sources double every event, because Event Gateway delivers one copy per CLI client. Check for a leftover process before you start one. +- **Use Event Gateway before a tunnel** for any public URL for localhost. +- **Run the demo against a real platform account** before calling it done, and record what you saw: event types, payload sizes, timings, retries. Don't state a size or timing you haven't measured. + +## Dependencies + +- **Pin exact versions** for anything loaded in the browser. +- **Run `npm run typecheck` and the demo's `npm test`** before committing. Run `npm run sync-shared -- --check` if you touched `_shared/` or the manifest. +- **Link a demo from docs only** as `https://github.com/hookdeck/hookdeck-demos/tree/main//`, even before it merges. + +## Related skills + +- **`hookdeck-platform-demos`:** the demo, tutorial, clip and post pipeline across repos. +- **`hookdeck-topology-diagrams`:** scenes and topology diagrams for the data-flow pane, guides and videos. +- **`hookdeck-demo-videos`:** recording clips of a demo. +- **`hookdeck-voice`:** wording for anything public. diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..43c994c --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +@AGENTS.md diff --git a/README.md b/README.md index ca2ecec..dce1be8 100644 --- a/README.md +++ b/README.md @@ -130,4 +130,4 @@ To add a demo to a piece, add it to `demos` in the manifest and run `npm run syn ## Contributing -Each demo has its own README with setup instructions. See the individual demo directories for details. +Each demo has its own README with setup instructions. See the individual demo directories for details. Building or changing a demo? Read [AGENTS.md](AGENTS.md) first: it has the rules for demo shape, shared code, verification and UI. From 9e77fc914942c98f8609bf717ed9fe6b6956e961 Mon Sep 17 00:00:00 2001 From: Phil Leggetter Date: Mon, 30 Nov 2026 13:33:57 +0000 Subject: [PATCH 2/2] docs: make AGENTS.md apply to every demo and link the files it names Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 94 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index cc0e9b9..40692c1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,67 +1,81 @@ # AGENTS.md -Rules for agents building or changing a demo in this repo. Read the root `README.md` first, then the README of the demo you're touching. This repo is public: name no individuals, link no private repos or internal tools, and don't write about what a product can't do. +Rules for agents building or changing a demo in this repo. Read the root [README.md](README.md) first, then the README of the demo you're touching. This repo is public: in a demo's code, README or UI, name no individuals, link no private repos or internal tools, and don't write about what a product can't do. -## Demo shape +The demos span several shapes, from a script that sends sample events to a full app with a live data-flow pane. Sections 1 to 6 apply to every demo; where a rule needs a condition, it says so. Sections 7 and 8 apply only to the demos they name. When a rule here and the demo you're editing disagree, follow the demo and say so in your pull request. A demo with its own `AGENTS.md`, such as [hookdeck/mcp-events-forward-proxy/AGENTS.md](hookdeck/mcp-events-forward-proxy/AGENTS.md), adds to this file. -- **One folder per demo:** `//`. Hookdeck features count as a vendor (`hookdeck/`); `ecommerce/` is the one exception. Add the demo to the root README table. -- **Three parts only:** the demo app, the platform it demos, and Event Gateway. No automation tools, hosted databases or other third-party services. -- **Standalone:** people copy one folder with `npx giget@latest gh:hookdeck/hookdeck-demos//`, so nothing may import from outside the folder. CI proves it by building each demo from a copy of its folder alone. -- **Same scripts:** `npm run setup`, `listen`, `typecheck`, and `probe` or `simulate` where they apply. Follow the demo closest to yours, for example `vapi/agency-routing`. -- **README:** setup steps, the `.env` variables and where to get each, and how to make a test call. +## 1. Demo shape + +- **One folder per demo:** `//`. Hookdeck features count as a vendor ([hookdeck/](hookdeck/)); [ecommerce/](ecommerce/) is the one exception. Add the demo to the table in [README.md](README.md). +- **Keep to what the demo is about:** the demo app, the platform it demos where it has one, and Event Gateway. No automation tools, hosted databases or other third-party services. +- **Standalone:** people copy one folder with [`npx giget@latest gh:hookdeck/hookdeck-demos//`](https://github.com/unjs/giget), so nothing may import from outside the folder. +- **README:** setup steps, the `.env` variables and where to get each, and how to try the demo. A demo with credentials keeps a complete `.env.example`, for example [vapi/agency-routing/.env.example](vapi/agency-routing/.env.example). - **TypeScript, Node 22.** -## `_shared` and sync +## 2. Scripts -- **`_shared/` is the source of truth** for the design system, Hookdeck API and CLI helpers, flow drawer, scene kit, topology pane and theme switch. Edit there, never in a demo's copy. Copies carry a "Generated from" header, and directories carry a `GENERATED.md`. -- **`_shared/manifest.json`** says which demo takes which piece and where it lands. To add a demo to a piece, add it to `demos` in the manifest. -- **Run `npm run sync-shared`** from the repo root after any change in `_shared/`. `npm run sync-shared -- --check` changes nothing and exits non-zero on drift. -- **CI runs the check on every pull request** (`.github/workflows/shared.yml`, no `paths:` filter), then builds each manifest demo from an isolated copy, with `npm ci` or `npm install` and its `typecheck` script. +Name scripts by what they do, and follow the demo closest to yours. The common names, where they apply: -## Setup and verification +- **`npm run setup`:** creates the Hookdeck resources, for example [vapi/agency-routing/scripts/setup.ts](vapi/agency-routing/scripts/setup.ts). +- **`npm run listen`:** runs `hookdeck listen`, for example [vapi/agency-routing/scripts/listen.ts](vapi/agency-routing/scripts/listen.ts). +- **`npm run typecheck`:** CI runs it for every demo in the manifest. +- **`npm run probe` or `simulate`:** the verification probe (section 7) and a script that sends sample events without the platform. -- **Setup is TypeScript:** `npm run setup` calls the platform's API and the Hookdeck REST API (version `2026-09-01`) through the `hookdeck()` helper. The CLI is used only for `npm run listen`. -- **Credentials come from `.env`:** `HOOKDECK_API_KEY` for a Hookdeck project, plus the platform's keys. Don't use the machine's default CLI profile. Keep `.env.example` complete, never print secret values, and never sign up for a platform with someone's identity. Build what you can without keys, then stop and list the exact `.env` variables and where to get each. -- **Event Gateway verifies** the platform's signature at the source. Create sources with the REST API `auth` config and check the source reports `authenticated`. -- **The app verifies `x-hookdeck-signature`** on every delivery, using the shared `hookdeck-signature` piece. -- **Retries and dedup:** setup adds a retry rule so the data-flow pane shows retries, and a deduplicate rule where the platform can send duplicates. +## 3. `_shared` and sync -## Demo UI +- **[`_shared/`](_shared/) is the source of truth** for the design system ([_shared/ds](_shared/ds)), the Hookdeck API and CLI helpers ([_shared/hookdeck](_shared/hookdeck)), the flow drawer, the scene kit, the topology pane and the theme switch. Edit there, never in a demo's copy. Copies carry a "Generated from" header, for example [vapi/agency-routing/src/hookdeck-signature.ts](vapi/agency-routing/src/hookdeck-signature.ts), and directories carry a `GENERATED.md`, for example [vapi/agency-routing/public/ds/GENERATED.md](vapi/agency-routing/public/ds/GENERATED.md). +- **[_shared/manifest.json](_shared/manifest.json)** says which demo takes which piece and where it lands. To add a demo to a piece, add it to `demos` in the manifest. A demo that isn't in the manifest owns its own code; several older demos aren't. +- **Run `npm run sync-shared`** from the repo root after any change in `_shared/`. The script is [scripts/sync-shared.mjs](scripts/sync-shared.mjs). `npm run sync-shared -- --check` changes nothing and exits non-zero on drift. +- **CI runs the check on every pull request** ([.github/workflows/shared.yml](.github/workflows/shared.yml), no `paths:` filter), then builds each demo in the manifest from a copy of its folder alone, with `npm ci` or `npm install` and its `typecheck` script. That is the proof that a manifest demo is standalone. -- **Use the Hookdeck design system** from `_shared/ds`. Don't add new colors. -- **Keep the main view on the use case.** Explanations go behind ⓘ dialogs or hovers. -- **One theme per demo** through `_shared/theme`. -- **Data flow pane:** each demo shows each message moving through Event Gateway live, using `_shared/flow-drawer` and `_shared/topology-pane`. Scenes come from `_shared/scenes`; follow the `hookdeck-topology-diagrams` skill and `_shared/scenes/README.md`. -- **A "Start call" button** uses the platform's browser SDK, so nobody needs the vendor dashboard to try the demo. Private keys stay on the server; the server returns only public keys, signed URLs or short-lived tokens. -- **Pin browser SDKs** to an exact version loaded from esm.sh, and pick a version at least two weeks old. -- **Bind to `127.0.0.1`** by default, with `HOST` as the override, and tell people to open the app as `localhost`. +## 4. Setup and credentials -## Failure injection +- **Setup is TypeScript:** it calls the platform's API and the Hookdeck REST API (version `2026-09-01`) through the helper in [_shared/hookdeck/hookdeck-api.ts](_shared/hookdeck/hookdeck-api.ts). The [Hookdeck CLI](https://github.com/hookdeck/hookdeck-cli) is used only for `hookdeck listen`. +- **Credentials come from `.env`:** `HOOKDECK_API_KEY` for a Hookdeck project, plus any platform keys. Don't use the machine's default CLI profile. Never print secret values, and never sign up for a platform with someone's identity. Build what you can without keys, then stop and list the exact `.env` variables and where to get each. +- **Event Gateway verifies** the platform's signature at the source, for platforms that sign their webhooks. Create the source with the REST API `auth` config and check the source reports `authenticated`. +- **Retries and dedup:** where a demo shows delivery behavior, setup adds a retry rule with a short interval, and a deduplicate rule where the platform can send duplicates. Say in a comment that production would use a longer retry interval, as [vapi/agency-routing/scripts/setup.ts](vapi/agency-routing/scripts/setup.ts) does. -- **Each demo has a failure panel:** fail the next N deliveries with a `503`, and where it applies delay each answer. The pane then shows Event Gateway keeping the event and retrying. -- **Keep the retry interval short** in the demo's retry rule so a retry is visible. Say in a comment that production would use a longer one. -- **Skip deliveries that are part of a live conversation by default**, such as a Vapi tool call, because a failed one delays the spoken answer. Offer a checkbox to include them. +## 5. UI -## Probes +For any demo with a browser UI: -- **`npm run probe` proves verification:** a correctly signed request is recorded as verified, and a badly signed one as rejected with `rejection_cause` `VERIFICATION_FAILED` and no event. -- **Assert on the request record from the Hookdeck API** (`verified`, `rejection_cause`), not on the HTTP status or on `GET /sources`, which redacts auth. The status Event Gateway returns to a rejected request depends on the source type, so don't hard-code one. -- **Wording:** write "Event Gateway verifies" in code comments, READMEs, UI strings and commit messages. Don't write "edge", "core" or "after ingestion". +- **Use the Hookdeck design system** from [_shared/ds](_shared/ds). Don't add new colors. +- **Keep the main view on the use case.** Explanations go behind ⓘ dialogs or hovers. +- **One theme per demo** through [_shared/theme](_shared/theme). +- **Pin browser dependencies** to an exact version, and pick a version at least two weeks old. -## Local running +## 6. Running and checking - **Run one `hookdeck listen` per set of sources.** Two processes for the same sources double every event, because Event Gateway delivers one copy per CLI client. Check for a leftover process before you start one. - **Use Event Gateway before a tunnel** for any public URL for localhost. -- **Run the demo against a real platform account** before calling it done, and record what you saw: event types, payload sizes, timings, retries. Don't state a size or timing you haven't measured. +- **Run the demo for real** before calling it done, against the platform's real account where the demo has one, and record what you saw: event types, payload sizes, timings, retries. Don't state a size or timing you haven't measured. +- **Before committing,** run the demo's `npm run typecheck` and `npm test` where they exist, and `npm run sync-shared -- --check` if you touched `_shared/` or the manifest. +- **Link a demo from docs** only as `https://github.com/hookdeck/hookdeck-demos/tree/main//`, even before it merges. +- **Wording:** write "Event Gateway verifies" in code comments, READMEs, UI strings and commit messages. Don't write "edge", "core" or "after ingestion". -## Dependencies +## 7. For demos with a live app that receives deliveries -- **Pin exact versions** for anything loaded in the browser. -- **Run `npm run typecheck` and the demo's `npm test`** before committing. Run `npm run sync-shared -- --check` if you touched `_shared/` or the manifest. -- **Link a demo from docs only** as `https://github.com/hookdeck/hookdeck-demos/tree/main//`, even before it merges. +These demos run a local server that Event Gateway delivers to, such as the four voice AI demos and [hookdeck/mcp-events-forward-proxy](hookdeck/mcp-events-forward-proxy/). Demos that only send events, or only run a transformation, don't need this section. + +- **The app verifies `x-hookdeck-signature`** on every delivery, using the `hookdeck-signature` piece ([_shared/hookdeck/hookdeck-signature.ts](_shared/hookdeck/hookdeck-signature.ts)). +- **Bind to `127.0.0.1`** by default, with `HOST` as the override (see [vapi/agency-routing/src/server.ts](vapi/agency-routing/src/server.ts)), and tell people to open the app as `localhost`. +- **Show the data flow:** a bottom pane shows each message moving through Event Gateway live, using [_shared/flow-drawer](_shared/flow-drawer) and [_shared/topology-pane](_shared/topology-pane). Scenes come from [_shared/scenes](_shared/scenes); follow the `hookdeck-topology-diagrams` skill and [_shared/scenes/README.md](_shared/scenes/README.md). +- **Add a failure panel:** fail the next N deliveries with a `503`, and where it applies delay each answer, so the pane shows Event Gateway keeping the event and retrying. The panel's state lives in the server, for example `chaos` in [vapi/agency-routing/src/server.ts](vapi/agency-routing/src/server.ts). +- **Probe verification** where the demo has `npm run probe`, for example [vapi/agency-routing/scripts/probe.ts](vapi/agency-routing/scripts/probe.ts). A correctly signed request is recorded as verified, and a badly signed one as rejected with `rejection_cause` `VERIFICATION_FAILED` and no event. Assert on the request record from the Hookdeck API (`verified`, `rejection_cause`), not on the HTTP status or on `GET /sources`, which redacts auth. The status Event Gateway returns to a rejected request depends on the source type, so don't hard-code one. + +## 8. For voice AI demos + +The four voice AI demos are [elevenlabs/post-call-transcripts](elevenlabs/post-call-transcripts/), [vapi/agency-routing](vapi/agency-routing/), [retell/outbound-lead-calling](retell/outbound-lead-calling/) and [livekit/voice-adventure](livekit/voice-adventure/). They add these rules to section 7: + +- **A "Start call" button** uses the platform's browser SDK, so nobody needs the vendor dashboard to try the demo. Private keys stay on the server; the server returns only public keys, signed URLs or short-lived tokens. For example, [elevenlabs/post-call-transcripts/public/call.js](elevenlabs/post-call-transcripts/public/call.js). +- **Load browser SDKs from [esm.sh](https://esm.sh)** at an exact version, as `call.js` does with `@elevenlabs/client`. +- **Spare live-conversation deliveries from the failure panel by default,** such as a Vapi tool call, because a failed one delays the spoken answer. Offer a checkbox to include them, as `include_tool_calls` does in [vapi/agency-routing/src/server.ts](vapi/agency-routing/src/server.ts). +- **The README ends with how to make a test call,** and a script (`simulate`, `call` or `send`) lets someone try the flow without a phone or microphone. ## Related skills +These are Hookdeck's internal agent skills, kept in the private repo [hookdeck/hookdeck-skills-internal](https://github.com/hookdeck/hookdeck-skills-internal). Outsiders can't open it; the rules above stand on their own. + - **`hookdeck-platform-demos`:** the demo, tutorial, clip and post pipeline across repos. - **`hookdeck-topology-diagrams`:** scenes and topology diagrams for the data-flow pane, guides and videos. - **`hookdeck-demo-videos`:** recording clips of a demo.