diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..40692c1 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,82 @@ +# AGENTS.md + +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. + +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. + +## 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.** + +## 2. Scripts + +Name scripts by what they do, and follow the demo closest to yours. The common names, where they apply: + +- **`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. + +## 3. `_shared` and sync + +- **[`_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. + +## 4. Setup and credentials + +- **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. + +## 5. UI + +For any demo with a browser UI: + +- **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. + +## 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 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". + +## 7. For demos with a live app that receives deliveries + +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. +- **`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.