diff --git a/README.md b/README.md index 1128fcf..5b9165f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ deepgram/ Deepgram integration demos vapi/ Vapi integration demos elevenlabs/ ElevenLabs integration demos retell/ Retell AI integration demos +livekit/ LiveKit integration demos _shared/ Source of truth for code shared across demos ``` @@ -89,6 +90,12 @@ For example, `npx giget@latest gh:hookdeck/hookdeck-demos/deepgram/stt-tts my-de |------|-------------| | [outbound-lead-calling](retell/outbound-lead-calling/) | A lead arrives, Retell places an outbound call, and the `call_started`, `call_ended` and `call_analyzed` events come back through Hookdeck (signature verification, deduplication, retries) to update the lead | +### LiveKit + +| Demo | Description | +|------|-------------| +| [voice-adventure](livekit/voice-adventure/) | A multiplayer LiveKit voice adventure with AI characters; room, participant and ingress webhooks through Hookdeck build a session chronicle | + ## Shared Utilities | Utility | Description | diff --git a/_shared/manifest.json b/_shared/manifest.json index 8e021cc..13b369b 100644 --- a/_shared/manifest.json +++ b/_shared/manifest.json @@ -50,6 +50,15 @@ "scenes": "scenes/kit", "topology-pane": "public/topology-pane", "theme": "public/theme.js" + }, + "livekit/voice-adventure": { + "ds": "public/ds", + "hookdeck-cli": "scripts/hookdeck-cli.ts", + "hookdeck-listen": "scripts/hookdeck-listen.ts", + "flow-drawer-server": "src/flow-drawer-server.ts", + "scenes": "scenes/kit", + "topology-pane": "public/topology-pane", + "theme": "public/theme.js" } } } diff --git a/livekit/voice-adventure/.env.example b/livekit/voice-adventure/.env.example new file mode 100644 index 0000000..4ed46e4 --- /dev/null +++ b/livekit/voice-adventure/.env.example @@ -0,0 +1,42 @@ +# LiveKit Cloud project credentials (REQUIRED) +# LiveKit Cloud dashboard: Settings -> API keys (https://cloud.livekit.io/projects/p_/settings/keys) +LIVEKIT_URL=wss://your-project.livekit.cloud +LIVEKIT_API_KEY=your_livekit_api_key +LIVEKIT_API_SECRET=your_livekit_api_secret + +# Hookdeck project API key (REQUIRED) +# Hookdeck dashboard: Project settings -> API keys. `npm run setup` creates the +# connection in this project and `npm run listen` forwards its source, using a CLI +# config file of its own, so your interactive `hookdeck login` is untouched. +HOOKDECK_API_KEY=your_hookdeck_api_key_here + +# Server port (optional), and the address it listens on. The default 127.0.0.1 keeps it local; 0.0.0.0 opens it to your network. +PORT=4000 +# HOST=127.0.0.1 +# Most story rooms and Pixel bots that can run at once (optional) +# MAX_ROOMS=6 +# MAX_PIXELS=4 + +# Optional settings +# Where the agent reaches the app (default http://localhost:), and the agent's registered name (default story-gm) +# STORY_APP_URL=http://localhost:4000 +# STORY_AGENT_NAME=story-gm +# Start the story somewhere else, for a quick test: STORY_START=cave +# STORY_START= +# Where the app keeps its data (default data/) +# DATA_DIR= +# LiveKit Cloud project to put the webhook in, if LIVEKIT_URL doesn't pick one (`npm run setup`) +# LIVEKIT_PROJECT_ID= +# A LiveKit Cloud session token, instead of `lk cloud auth --user-auth` (`npm run setup`) +# LIVEKIT_SESSION_TOKEN= +# Path to a Hookdeck CLI binary (default: the hookdeck-cli npm dependency) +# HOOKDECK_CLI= + +# Written by `npm run setup`: paste this URL into LiveKit Cloud -> Settings -> Webhooks +LIVEKIT_WEBHOOK_URL=https://hkdk.events/your-source-id-here + +# Soundtracks (optional): LiveKit Cloud fetches them, so the URL must be public. +# Default: this folder on the repository's main branch. Host the files yourself with: +# SOUNDTRACK_BASE_URL=https://example.com/soundtracks +# One scene only: SOUNDTRACK_URL_TAVERN, SOUNDTRACK_URL_FOREST, SOUNDTRACK_URL_CAVE or SOUNDTRACK_URL_FINALE +# SOUNDTRACK_URL_CAVE=https://example.com/cave.ogg diff --git a/livekit/voice-adventure/.gitignore b/livekit/voice-adventure/.gitignore new file mode 100644 index 0000000..0759f15 --- /dev/null +++ b/livekit/voice-adventure/.gitignore @@ -0,0 +1,41 @@ +# Dependencies +node_modules/ + +# Build output +dist/ + +# Environment files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo + +# OS files +.DS_Store +Thumbs.db + +# TypeScript +*.tsbuildinfo + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# JSON data storage +data/ + +# Hookdeck CLI config written by the setup and listen scripts +run/ +public/scenes/ +agent/node_modules/ diff --git a/livekit/voice-adventure/README.md b/livekit/voice-adventure/README.md new file mode 100644 index 0000000..d296959 --- /dev/null +++ b/livekit/voice-adventure/README.md @@ -0,0 +1,266 @@ +# LiveKit story night with Hookdeck + +## The use case + +A backend that needs a reliable record of what happens in LiveKit rooms: who joined, who dropped, which tracks were published, when an ingress or egress started and ended, and how long the session ran. LiveKit reports all of it as webhooks. This demo builds that record from the room webhooks, delivered through [Hookdeck Event Gateway](https://hookdeck.com/event-gateway): the app verifies each webhook's signed token, Event Gateway deduplicates repeats on the event `id` and retries deliveries when the app fails, and every event can be replayed. + +## The scenario: story night + +To give every room event a visible purpose, the demo is a multiplayer voice adventure. Players join a LiveKit room from the page. Two LiveKit agents run the evening: Hester Pennywhistle, the innkeeper of the Drowned Bell, writes each name in her ledger and fetches Old Bram Tallow, a retired lighthouse keeper who tells a four-scene story. A mute bot player, Pixel, takes part with gestures. At each scene the app pulls a soundtrack into the room with LiveKit's Ingress API, so ingress events appear in the record too. The **session chronicle** on the page is the backend record: a timeline built only from the webhooks the app receives, and the call log beside it keeps one entry per room session. Both characters are fictional. + +``` +players ──► LiveKit room ◄── agent (Hester, then Old Bram) ──► this app: POST /api/scene + │ │ Ingress API: soundtrack + └──webhooks──► Hookdeck source ──► hookdeck listen ──► this app (:4000) +``` + +The demo has three parts: this app (and its agent), LiveKit Cloud and Hookdeck Event Gateway. The agent uses LiveKit Inference for speech-to-text, the language model and text-to-speech, so the only credentials are your LiveKit key and secret (plus a Hookdeck project API key). + +## Quick start + +After [setup](#setup) (about five minutes, once), run three things in three terminals: + +```bash +npm run listen # Hookdeck forwards the webhooks to the app +npm start # the app +npm run agent # Hester and Old Bram (installs agent/ on first run) +``` + +1. Open (or the `PORT` in `.env`). +2. Enter a name if you like (Hester then greets you by it and doesn't ask), select **Join a call** and allow the microphone. If you typed a name, Hester greets you by it, otherwise she asks for your first name. Then she says she will fetch Old Bram, who tells the story. +3. To play with friends, copy the **invite link** the page shows once you have joined and send it, or open it in a second tab. The link is this page's address with `?room=story-...`; opening it and selecting **Join a call** puts you in the same story. The app only joins a room it created and that is still open, so an old or made-up link says the story is not open. Each person needs their own microphone (the agent hears one player at a time). To play alone with company, select **Add Pixel, a mute player**: Pixel is a scripted traveller who cannot speak. It answers when you speak to it, and once when the party arrives somewhere new, with one short gesture line (for example "*Pixel holds the lantern up to the cave wall and taps a carving.*") that appears in the Transcript. Pixel never holds a turn and nothing waits for it. Pixel uses no language model of its own. +4. Play: the goal is to relight Old Bram's lighthouse with the Lantern of Hollow Mere. The party moves between five places (the inn, the Hollow Wood, the hollow oak, the cave under the Mere, the lighthouse), takes items into one shared satchel (a map, a small brass key, the Lantern, flint and a wick) and opens the iron chest in the inn with the key. Bram says what you see, hear and notice and never tells you what to do. The story ends when the Lantern is lit at the lighthouse. +5. When Old Bram closes the story, the page says **The story has ended** and offers **Start a new story**. Select **Leave** any time to stop earlier. The **Session chronicle**, the call log and the **Data flow** pane fill in as the webhooks arrive. A session ends, and its chronicle closes, about a minute after the last person leaves, because LiveKit closes an empty room after its departure timeout. + +## Setup + +### 1. Install + +```bash +npm install +cp .env.example .env +``` + +### 2. Add your keys to `.env` + +| Variable | Where to get it | +|---|---| +| `LIVEKIT_URL` | LiveKit Cloud dashboard, Settings, API keys: the project's WebSocket URL (`wss://.livekit.cloud`) | +| `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET` | The same page: create a key pair. The secret is shown once | +| `HOOKDECK_API_KEY` | Hookdeck dashboard, Project settings, API keys | + +### 3. Create the Hookdeck connection + +```bash +npm run setup +``` + +This creates a `livekit-voice-adventure` source, a CLI destination that forwards to `/webhooks/livekit`, and the connection between them with a deduplicate rule and a retry rule. It writes the source URL to `LIVEKIT_WEBHOOK_URL` in `.env`. The script is idempotent. It logs the bundled Hookdeck CLI in to the project for `HOOKDECK_API_KEY` with a config file of its own, so your interactive `hookdeck login` is untouched. + +### 4. Add the webhook in LiveKit Cloud + +`npm run setup` creates the webhook for you when you are signed in to LiveKit Cloud with the LiveKit CLI. It uses LiveKit Cloud's management API (on LiveKit's `beta-api` host), which takes your user sign-in rather than an API key and secret: + +```bash +lk cloud auth --user-auth # opens a browser sign-in once +npm run setup # also creates (or updates) the "Hookdeck: livekit-voice-adventure" webhook +``` + +**Renamed from "call log".** This demo used to be `livekit/call-log`, with a `livekit-call-log` source and connection, a `local-livekit-call-log` destination and a LiveKit Cloud webhook named "Hookdeck: livekit-call-log". `npm run setup` now creates the `livekit-voice-adventure` resources and moves an existing "Hookdeck: livekit-call-log" webhook to the new source URL instead of adding a second one. The old Hookdeck source, connection and destination are safe to delete in the dashboard. + +Setup finds your project by matching `LIVEKIT_URL` (set `LIVEKIT_PROJECT_ID` to choose one), signs the webhook with `LIVEKIT_API_KEY`, and updates the webhook instead of duplicating it when you run it again. To use a session token yourself, set `LIVEKIT_SESSION_TOKEN`. + +If you are not signed in, setup still creates the Hookdeck connection and prints these steps. In the LiveKit Cloud dashboard open **Settings, Webhooks** and select **Create new webhook**. Enter a name, paste the `LIVEKIT_WEBHOOK_URL` value as the URL, choose your API key as the **Signing API key**, and select **Create**. Use **Actions, Send a test event** to check the path. + +See LiveKit's [webhooks documentation](https://docs.livekit.io/intro/basics/rooms-participants-tracks/webhooks-events/) for the events and payloads. + +### 5. Run it + +In two terminals: + +```bash +npm run listen # hookdeck listen: forwards the source to localhost:4000 +npm start # the app +``` + +Open . + +## How it works + +- **Raw-body verification.** LiveKit signs each webhook with a JWT in the `Authorization` header, and the JWT includes a SHA-256 hash of the body. The app verifies it with `WebhookReceiver` from `livekit-server-sdk` on the raw body (`application/webhook+json` is not parsed by `express.json()`). +- **Retries after 5 minutes.** The token expires 5 minutes after LiveKit issues it, and Event Gateway forwards the original `Authorization` header on every retry. So the app verifies with a clock tolerance that covers the connection's retry window (about 2 hours 7 minutes, plus 5 minutes: `src/verify.ts`). The signature and the body hash are still checked; the trade-off is that a captured request stays acceptable for that long, which is harmless because events apply idempotently. With the LIVEKIT source type, Event Gateway does this check and the app doesn't need to (see the TODO below). +- **Idempotent room record.** Each event is applied as a set-this-field update keyed by the room session id, so a duplicate delivery, a retry or an event that arrives out of order leaves the log correct. See [`src/call-log.ts`](src/call-log.ts). +- **Delivery list.** The page lists every request the app received and whether it was applied, a duplicate or rejected. +- **Join a call from the page.** A **Join a call** button connects your browser to a LiveKit room with `livekit-client` and your microphone, using a short-lived token the server mints (`POST /api/token`). The API secret stays on the server. The token's room configuration dispatches the agent by name (`story-gm`), so only rooms joined from this page get the story agent. +- **A soundtrack per place.** When the party moves to a place whose soundtrack differs from the one playing, the agent posts to the app (`POST /api/scene`, with a secret header derived from your API secret, so only the agent can call it), and the app checks the file with a HEAD request and then pulls it into the room with the Ingress API (a URL input). A file that can't be fetched means no music, and Old Bram is not told there is any. The files last 180 seconds, so when a scene's ingress ends (the `ingress_ended` webhook) the app starts the same soundtrack again while the story is still in that scene. The hollow oak keeps the forest soundtrack. The room then shows an ingress participant and `ingress_started` and `ingress_ended` webhooks arrive through Event Gateway like every other event. +- **A session chronicle.** The page builds a timeline of the session from the webhooks it receives: who joined and when, who dropped (`participant_connection_aborted`), each scene's soundtrack starting and ending, and the session length. It tells players, the story agent and soundtracks apart with `participant.kind` in the payload (`AGENT` for the agent, `INGRESS` for a soundtrack, absent for a player). See [`src/chronicle.ts`](src/chronicle.ts). +- **Event Gateway rules.** The connection deduplicates on the LiveKit event id (`body.id`, 10 minutes) and retries failed deliveries with exponential backoff (8 attempts from 30 seconds). +- **A data flow pane.** The page's bottom pane shows each webhook travelling from LiveKit Cloud through Event Gateway and `hookdeck listen` to the app, with scripted scenes for a call's lifecycle, a duplicate, a bad signature and an app that is down. + +## The story and the agent + +`npm run agent` starts a worker (`agent/src/main.ts`, built with [`@livekit/agents`](https://docs.livekit.io/agents/) for Node.js) that registers with your LiveKit project as `story-gm`. It needs Node.js 22.18 or later. The page's token dispatches it when the first player joins, so there is nothing to configure in the LiveKit dashboard. + +| Character | Role | Manner | Voice (LiveKit Inference) | +|---|---|---|---| +| **Hester Pennywhistle** | Innkeeper of the Drowned Bell. Greets travellers by the name they typed on the page, or asks for a first name when there is none, writes each in the ledger (`write_in_ledger`), then announces in her own voice that she is fetching Old Bram and hands over. The announcement and the handoff are code (`session.say`, then `session.updateAgent`), not a model call, so they cannot be skipped. | Brisk, warm, a little nosy, dry humour, calls everyone "love" or "dear". | Cartesia Sonic 3, voice `f31cc6a7-c1e8-4764-980c-60a361443dd1` (Robyn, an Australian, mature voice from LiveKit's documented list) | +| **Old Bram Tallow** | Retired lighthouse keeper who tells "The Lantern of Hollow Mere". He has no tools: the code decides what happens and he narrates it. | + +Hester and Bram are one agent participant in the room. The agent publishes what the page shows as participant attributes on itself: `story.character`, `story.turn`, `story.turn_name` and `story.turn_seq` (whose turn it is), `story.scene` and `story.state` (`ended` when the story is over). Turns are code, not a model tool: Old Bram ends each reply by naming the player who answers next, and when his speech has finished playing the agent links that player (or the next in rotation) and sets `story.turn`. Only real player input counts toward a scene (a final transcript from the linked player), `next_scene` is allowed only in the reply that answers a player who clearly chose to move on (never chained after another call, and never to push the group on: there is no minimum number of exchanges and no nudge), and a filter drops any tool name from speech before text-to-speech. + +Speech-to-text (Deepgram Nova 3), the language model (OpenAI GPT-4.1 mini) and text-to-speech all run on [LiveKit Inference](https://docs.livekit.io/agents/models/) billed to your LiveKit project, so the only credentials are your LiveKit key and secret. + +The agent logs `LLM: LiveKit Inference openai/gpt-4.1-mini` at startup. Inference usage beyond your plan's included credits is billed to your LiveKit project, so keep test runs short. + +**Pixel**, the mute player, is a small Node participant (`agent/src/pixel.ts`, `@livekit/rtc-node`) that the app starts when you select **Add Pixel** (at most `MAX_PIXELS`, default 4, at a time). It joins as `bot-pixel`, publishes no media, and sends the gesture lines the story agent hands it on the `lk.chat` topic, which the page shows in the Transcript. Those chat messages do not reach the agent: an agent session accepts text only from the participant it is linked to, and Pixel is never linked, because it never holds a turn. Old Bram reacts through the agent's own notes instead. The agent chooses the line (for the place and the satchel), publishes it as the `story.pixel_line` and `story.pixel_seq` attributes, remembers what Pixel did, and tells Bram to weave it into his next reply. Pixel logs to `data/pixel.log`. Its webhooks are `participant_joined` and `participant_left` as a standard participant, so the chronicle lists it as a player. + +The agent calls the app at `http://localhost:4000` (set `STORY_APP_URL` if the app runs elsewhere). The story runs about six minutes, and the page's **Transcript** shows what is said, from the `lk.transcription` text streams the agent publishes. + +## Soundtracks + +The four 3 minute soundtracks in `public/soundtracks/` are real ambience recordings that fit the scenes: cafe chatter for the tavern, a woodland morning chorus for the forest, a dripping cave, and wind and rigging in a harbour for the finale (Old Bram is a retired lighthouse keeper). They are public-domain or CC0 field recordings, trimmed to 3 minutes, loudness-normalized to a quiet level so the storyteller stays audible, and encoded as Ogg Vorbis. Sources, authors and licences are in [`public/soundtracks/CREDITS.md`](public/soundtracks/CREDITS.md), and [`scripts/make-soundtracks.sh`](scripts/make-soundtracks.sh) rebuilds them with ffmpeg. A soundtrack plays until the next scene replaces it, so each is longer than a scene usually runs. The page shows **Now playing** while one is in the room. + +LiveKit Cloud fetches the file itself, so the URL must be public: `localhost` doesn't work. By default the app points at this folder in the repository (`raw.githubusercontent.com/hookdeck/hookdeck-demos/main/livekit/voice-adventure/public/soundtracks/.ogg`). To host the files yourself, set `SOUNDTRACK_BASE_URL` in `.env`, or `SOUNDTRACK_URL_TAVERN` (and `_FOREST`, `_CAVE`, `_FINALE`) for one scene. If a soundtrack can't be fetched, the story carries on without music. Each scene's ingress is deleted when the next scene starts, when the story ends and when the room finishes (the `room_finished` webhook), and the app deletes leftover `scene:*` ingresses from rooms that are gone when it starts, so nothing counts against your project's ingress limit. + +## The webhooks it produces + +Observed on LiveKit Cloud with a 20 second call (two participants), a WEBHOOK source type and the app verifying each delivery with `WebhookReceiver`: + +| Event | Count | Body size | +|---|---|---| +| `room_started` | 1 | 457 bytes | +| `participant_joined` | 2 (plus the agent and each soundtrack) | about 760 bytes | +| `track_published`, `track_unpublished` | 2 each | 1.0 to 1.1 KB | +| `participant_left` | 2 | about 860 bytes | +| `room_finished` | 1 | 152 bytes | +| `ingress_started`, `ingress_ended` | 1 each per soundtrack | about 0.6 KB | + +- **Ordering and timing.** Events arrived in the order LiveKit generated them. `room_finished` came about 38 seconds after the last participant left (the room's departure timeout), so a record must not assume a call ends as soon as the last person leaves. +- **Signature.** The `Authorization` header is a JWT (HS256) whose `iss` claim is the signing key, whose `sha256` claim is the base64 SHA-256 of the body, and which expires five minutes after LiveKit issues it. Event Gateway stores the request and forwards the header and the body unchanged; the body it stored and the body the app received were identical. +- **Who is who.** `participant.kind` is absent for a player, `AGENT` for the story agent, and `INGRESS` for a soundtrack. `track_published` and `track_unpublished` events carry no `kind`, so the chronicle reads participant events. A second `participant_joined` of kind `AGENT` in the same room means LiveKit restarted the storyteller; the chronicle notes it. +- **Dedup and retries.** Sending the same event id twice produces one delivery (the second request is recorded with `ignored_count: 1` and no event). An app that answers 503 or 401 gets retried: the first retry about 30 seconds later, then exponential backoff for up to 8 attempts. + +## The data flow pane + +The page has a **Data flow** pane at the bottom, open by default. **Live** shows the demo as it runs: each webhook travels from LiveKit Cloud through Event Gateway (receive, store, dedup, retry) and `hookdeck listen` to the app. Click a node or a packet for that webhook's details below the diagram: each delivery attempt, what the app answered and a **View in Hookdeck** link. When Old Bram starts a scene, a packet travels from the app to LiveKit's Ingress API along the outbound **INGRESS** edge, and the ingress webhooks come back through Event Gateway. The other tabs play scripted scenes with captions: **Call lifecycle**, **Duplicate dropped**, **Bad signature** and **App down, retry succeeds**. + +The scenes live in `scenes/livekit-calls.ts` (the kit in `scenes/kit/` is synced from `_shared/scenes`). MP4 captures of the four scenes, landscape and square, are in `scenes/captures/`. To render them again: `npm run capture -- livekit-call-lifecycle`. + +## Themes + +The page has a switch with System, Light, Dark and **Story**, an old-world fantasy theme that is the default until you choose another (the choice is remembered). The switch is the shared `_shared/theme/theme.js`: a demo declares `data-demo-theme`, `data-demo-theme-label` and `data-demo-theme-default` on `` to add a fourth option. The Story theme is `public/theme-story.css`: it overrides design-system tokens on `main` (and on the How it works dialog) and styles the parchment cards, banner, badges and transcript with them, using Cinzel Decorative, Cinzel and IM Fell English from Google Fonts. The Data flow pane is outside `main`, so it keeps the standard look. Headings and microcopy have a plain and a Story version (`only-plain` and `only-story`), so the other themes keep today's wording. + +## Generate activity from the command line (optional) + +The **Join a call** button is the way to try the demo. To generate a call without a browser or the agent, install the [LiveKit CLI](https://docs.livekit.io/home/cli/) (`brew install livekit-cli`), then: + +```bash +npm run activity +``` + +This path needs no browser. The script creates a room, joins two test participants with demo media, and lets them leave. The call log shows the room appear, the participants join and leave, and the room finish. Pass a room name and a duration in seconds: `npm run activity -- standup 30`. + +To end a call immediately, delete the room: + +```bash +lk room delete +``` + +### Without a LiveKit room + +`npm run simulate` sends correctly signed events to your Hookdeck source, signed the way LiveKit signs them (a JWT in the `Authorization` header with a `sha256` claim for the body). Use it to try the duplicate and bad-signature paths: + +```bash +npm run simulate # room_started, participant_joined, participant_left, room_finished +npm run simulate -- room_finished --twice # the second request is deduplicated by Event Gateway +npm run simulate -- room_finished --bad-signature # the app rejects it with 401 +``` + +**A failing app.** In the page's failure injection panel, set "Fail the next" to 2 and generate some activity. The app answers 503 to the first two deliveries. Hookdeck keeps the event, retries it, and the call log updates when the app finally answers 200. LiveKit is never kept waiting. Set "Delay each answer" to make the app slow instead. + +### Recordings + +Recording links come from egress events. Start a room composite egress with an output location you control (see LiveKit's [egress documentation](https://docs.livekit.io/home/egress/overview/)); when it ends, `egress_ended` carries the file location and the app adds it to the call. + +## How a turn works + +After each player input (a spoken answer) one small separate Inference call (`openai/gpt-4.1-mini`, JSON out) reads the words into `{ move, take, use, give }`. The code validates each part against the world: only real exits from the current place, only items that lie here, the chest opens only with the key, and the Lantern lights only at the lighthouse with the flint and wick. It then gives Bram a note with the place, what lies here, the satchel, the ways out and what just happened, and Bram narrates. Where the party is, the satchel and the puzzle flags are saved in the room metadata, so a resumed story keeps them. Items are not room events, so the satchel is shown from agent attributes (`story.satchel`) and never appears in the chronicle. For a quick test, `STORY_START=cave` starts the party in the cave with the map. + +## Known limits + +- **A storyteller that dies resumes the story.** After each player turn and each scene change the agent saves the story in the room's metadata: the scene, the names in the ledger, the clues shown and a few lines of running summary (small JSON, a few hundred bytes to about 4 KB). When a story agent joins a room that already has that state, Hester stays out of it and Old Bram opens with a short recap, then the same scene carries on. This covers LiveKit re-dispatching a dead job and the **Continue the story** button, which appears when the storyteller has left the room or has not answered for 20 seconds after a player spoke, and asks the app (`POST /api/story/continue`) to dispatch a new story agent. A second agent in a room that already has a live one leaves, so the story is never told twice. The chronicle notes "The storyteller returned". The saved summary is only the last few lines, so the recap is approximate. +- **Stalls.** A final transcript that never ends the player's turn is recovered after 15 seconds (the turn is committed, then Old Bram says one short line). A model request that hangs is covered after 20 seconds. Turns end on voice activity (700 ms to 3 s of silence), not the local turn-detector model, preemptive generation and session recording are off. +- The agent hears one player at a time, and a mute player (Pixel) takes part through gestures the agent hands it, not audio. +- **Leaving.** A player who leaves is taken out of the turn rotation and Bram's roster, and the turn goes on to someone still in the room. A traveller who joins mid-story without a name is called "Traveller" until they say "I'm Priya". If the closing never plays (a hung reply), the agent speaks a short closing and ends the story anyway, and ignores typed input once the story is ending. + +## Tests + +```bash +npm test +``` + +The tests build a call log from a sample event sequence, then check that duplicates, reverse order and a late `egress_updated` give the same result, and that `WebhookReceiver` accepts a signed body and rejects an altered one. The scene and pane tests run in a browser: install one with `npx playwright install chromium` first. + +## Replaying a delivery + +Every request the app receives is appended to `data/deliveries.jsonl` with its headers and raw body (base64), keeping the last 500. The `Authorization` header is stored as `[redacted]`: it is a bearer token until it expires, and the file shouldn't hold it. To replay an event, use Event Gateway, which keeps the original request: open it in the dashboard and select **Retry**, or run `hookdeck gateway event retry `. + +## Running it safely + +- The app binds to `127.0.0.1` (set `HOST=0.0.0.0` to open it to your network). It mints LiveKit tokens and can start agents and bots, so don't expose it to a network you don't trust. +- A Join only ever goes to a room the app names itself (`story-` and hex digits) or to an open one of those. Continue and Add Pixel accept the same rooms only. At most `MAX_ROOMS` (default 6) stories run at once. +- `POST /api/scene` and `/api/scene/end` need the agent's secret header; the failure-injection controls and data endpoints are for the local page. + +## Project structure + +``` +livekit/voice-adventure/ +├── .env.example +├── package.json +├── agent/ # `npm run agent`: Hester and Old Bram +├── scenes/ +│ ├── livekit-calls.ts # The topology: live scene and four scripted scenes +│ ├── entry.ts # What the page's bundle exposes +│ ├── captures/ # MP4s, landscape and square +│ └── kit/ # Synced from _shared/scenes +├── scripts/ +│ ├── make-soundtracks.sh # Generates public/soundtracks/*.ogg with ffmpeg +│ ├── activity.sh # Creates a room and joins test participants with the lk CLI +│ ├── simulate.ts # Sends signed events (or a bad signature, or a duplicate) to the source +│ ├── livekit-cloud.ts # Creates the LiveKit Cloud webhook through the management API +│ ├── hookdeck-cli.ts # Synced from _shared: runs the Hookdeck CLI against the API key's project +│ ├── listen.ts # npm run listen +│ └── setup-hookdeck.ts # npm run setup +├── src/ +│ ├── token.ts # Mints the short-lived browser token and dispatches the agent +│ ├── chronicle.ts # Builds the session chronicle from webhooks +│ ├── soundtracks.ts # Scene names, soundtrack URLs and the HEAD check +│ ├── soundtrack-keeper.ts # Keeps one soundtrack playing per room, restarts it when it ends +│ ├── rooms.ts # Which rooms a Join may use, the room caps, the agent's secret header +│ ├── call-log.ts # Turns events into calls (idempotent, order-independent) +│ ├── verify.ts # Webhook verification with a clock tolerance for retries +│ ├── server.ts # Express app and the verified webhook endpoint +│ ├── deliveries.ts # What the app answered, for the data flow pane +│ └── store.ts # JSON file persistence in data/ +├── test/ # Call log, scenes and pane tests +└── public/ # The call log page and the data flow pane +``` + + + +## Troubleshooting + +- **Webhook not arriving:** check that `npm run listen` is running and that the Hookdeck dashboard shows the event. Use **Actions, Send a test event** in LiveKit Cloud. +- **Deliveries rejected with 401:** the API key selected as **Signing API key** in LiveKit must match `LIVEKIT_API_KEY` and `LIVEKIT_API_SECRET` in `.env`. +- **`lk` can't connect:** `LIVEKIT_URL`, `LIVEKIT_API_KEY` and `LIVEKIT_API_SECRET` must be set in `.env`; the script loads them. diff --git a/livekit/voice-adventure/agent/package-lock.json b/livekit/voice-adventure/agent/package-lock.json new file mode 100644 index 0000000..2f223de --- /dev/null +++ b/livekit/voice-adventure/agent/package-lock.json @@ -0,0 +1,2991 @@ +{ + "name": "hookdeck-livekit-story-agent", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "hookdeck-livekit-story-agent", + "version": "1.0.0", + "dependencies": { + "@livekit/agents": "1.10.0", + "@livekit/rtc-node": "1.2.2", + "dotenv": "^16.3.1", + "zod": "^4.1.12" + }, + "devDependencies": { + "@types/node": "^22.0.0", + "typescript": "^5.9.2" + }, + "engines": { + "node": ">=22.18" + } + }, + "node_modules/@bufbuild/protobuf": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.1.tgz", + "integrity": "sha512-wJ8ReQbHxsAfXhrf9ixl0aYbZorRuOWpBNzm8pL8ftmSxQx/wnJD5Eg861NwJU/czy2VXFIebCeZnZrI9rktIQ==", + "license": "(Apache-2.0 AND BSD-3-Clause)" + }, + "node_modules/@datastructures-js/deque": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@datastructures-js/deque/-/deque-1.0.8.tgz", + "integrity": "sha512-PSBhJ2/SmeRPRHuBv7i/fHWIdSC3JTyq56qb+Rq0wjOagi0/fdV5/B/3Md5zFZus/W6OkSPMaxMKKMNMrSmubg==", + "license": "MIT" + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", + "cpu": [ + "arm" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@livekit/agents": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@livekit/agents/-/agents-1.10.0.tgz", + "integrity": "sha512-sxKJ5zg1JaQVBxw0exARmPmfRxLTz+Cby1ysxUROk7NSAjgIgoXIsS1sLmkbrWVVqDOu4sIMcdiaakDET6R/RA==", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.10.0", + "@livekit/av": "^10.0.0", + "@livekit/blingfire": "^1.2.0", + "@livekit/local-inference": "^0.3.1", + "@livekit/mutex": "^1.1.1", + "@livekit/protocol": "^1.53.4", + "@livekit/throws-transformer": "0.1.8", + "@livekit/typed-emitter": "^3.0.0", + "@opentelemetry/api": "^1.9.0", + "@opentelemetry/api-logs": "^0.220.0", + "@opentelemetry/core": "^2.8.0", + "@opentelemetry/exporter-logs-otlp-proto": "^0.220.0", + "@opentelemetry/exporter-metrics-otlp-proto": "^0.220.0", + "@opentelemetry/exporter-trace-otlp-proto": "^0.220.0", + "@opentelemetry/instrumentation-pino": "^0.66.0", + "@opentelemetry/otlp-exporter-base": "^0.220.0", + "@opentelemetry/resources": "^2.8.0", + "@opentelemetry/sdk-logs": "^0.220.0", + "@opentelemetry/sdk-metrics": "^2.8.0", + "@opentelemetry/sdk-trace-base": "^2.8.0", + "@opentelemetry/sdk-trace-node": "^2.8.0", + "@opentelemetry/semantic-conventions": "^1.28.0", + "@types/pidusage": "^2.0.5", + "commander": "^12.0.0", + "fluent-ffmpeg": "^2.1.3", + "form-data": "^4.0.5", + "heap-js": "^2.6.0", + "json-schema": "^0.4.0", + "jsonrepair": "^3.14.0", + "livekit-server-sdk": "^2.15.0", + "ofetch": "^1.5.1", + "openai": "^6.8.1", + "pidusage": "^4.0.1", + "pino": "^8.19.0", + "pino-pretty": "^11.0.0", + "sharp": "0.35.5", + "ws": "^8.21.0", + "zod-to-json-schema": "^3.24.6" + }, + "bin": { + "livekit-agents": "dist/bin/livekit-agents.js" + }, + "peerDependencies": { + "@livekit/rtc-node": "^1.2.2", + "@modelcontextprotocol/client": "^2.3.1", + "zod": "^3.25.76 || ^4.1.8" + }, + "peerDependenciesMeta": { + "@modelcontextprotocol/client": { + "optional": true + } + } + }, + "node_modules/@livekit/av": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@livekit/av/-/av-10.1.0.tgz", + "integrity": "sha512-e9VEckIjUJt8vLiziGcgPQD6AiFuBxHBAC4Ujpk93Cm0wnTurR+IKHn6wZR5hf/9rtaEgOPur/JmlXI9QhqwSQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "@livekit/av-darwin-arm64": "10.1.0", + "@livekit/av-darwin-x64": "10.1.0", + "@livekit/av-linux-arm64": "10.1.0", + "@livekit/av-linux-x64": "10.1.0", + "@livekit/av-win32-x64": "10.1.0" + } + }, + "node_modules/@livekit/av-darwin-arm64": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@livekit/av-darwin-arm64/-/av-darwin-arm64-10.1.0.tgz", + "integrity": "sha512-RwmT79UEwWDSaKar8zSJqf2vxCzFK7mrco1m/g1AtKMa1wC+uewMNy5rLR53hqoBB5NN44Ouqb3maVfVO+pDxw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-2.1-or-later", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@livekit/av-darwin-x64": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@livekit/av-darwin-x64/-/av-darwin-x64-10.1.0.tgz", + "integrity": "sha512-Gn0PPT3wRwNeVV6313I5QI/vXi7c6B/CjRx70vDPMEx9vbs68g5HL76wxGdrzjZwS5aFPQw3zgX87e7U43V9Ng==", + "cpu": [ + "x64" + ], + "license": "LGPL-2.1-or-later", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@livekit/av-linux-arm64": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@livekit/av-linux-arm64/-/av-linux-arm64-10.1.0.tgz", + "integrity": "sha512-s0jyXUksZhseQACtMeRCq3yvgKb8uV3U8a0WQPu8PCUrzWsbmDPuz7jqGGv7Qq+Ll95e3PtVrELHuBBMWp0UsA==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-2.1-or-later", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/av-linux-x64": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@livekit/av-linux-x64/-/av-linux-x64-10.1.0.tgz", + "integrity": "sha512-xuoN05T8Kgm6WP23yInOYujA7hpNPbly4Dqe9yKfMdSt+xQA2V9sveoNQu09rEnoDPd3lxftGSIWqB78F/Ebfw==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "LGPL-2.1-or-later", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/av-win32-x64": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/@livekit/av-win32-x64/-/av-win32-x64-10.1.0.tgz", + "integrity": "sha512-Tbon131LwTPqQgpkP7yvvf7dZOCV/lzaNSrkheqgjQ676H4EhgaQw8/4exkaI4N1z8bBU5GHi2kM0DrLPn8sOA==", + "cpu": [ + "x64" + ], + "license": "LGPL-2.1-or-later", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@livekit/blingfire": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire/-/blingfire-1.2.0.tgz", + "integrity": "sha512-NBkAm31MpXyatfstI5YlaPlU2TCcvwoyghgODeieZU63TjhGM9tTHDsh10P8FP5nJ67nJLN+ZqbH3L1Pkdvpjg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "node-gyp-build": "^4.8.0" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "@livekit/blingfire-darwin-arm64": "1.2.0", + "@livekit/blingfire-darwin-x64": "1.2.0", + "@livekit/blingfire-linux-arm64-gnu": "1.2.0", + "@livekit/blingfire-linux-arm64-musl": "1.2.0", + "@livekit/blingfire-linux-x64-gnu": "1.2.0", + "@livekit/blingfire-linux-x64-musl": "1.2.0", + "@livekit/blingfire-win32-x64-msvc": "1.2.0" + } + }, + "node_modules/@livekit/blingfire-darwin-arm64": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire-darwin-arm64/-/blingfire-darwin-arm64-1.2.0.tgz", + "integrity": "sha512-T5VutjrRGhDjYlPGMpfTbu1FQ+fX+kne/Q6iXp+wjwlcslauxzc5fhjdhO4jfjC240vZy/51psWxxHW9YD1hyQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@livekit/blingfire-darwin-x64": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire-darwin-x64/-/blingfire-darwin-x64-1.2.0.tgz", + "integrity": "sha512-85gLmr16ZF/7fKWzx3t2x+BSfWp6KebMH9k70pUFqzmfPxaw95ykiHME4Xh5tgbbBqe7RLF4gFIOGcfUZi9hGQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@livekit/blingfire-linux-arm64-gnu": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire-linux-arm64-gnu/-/blingfire-linux-arm64-gnu-1.2.0.tgz", + "integrity": "sha512-ByYgnLPKE6PFFNwLKMmTaNPVo3daGl006nNCyIIP7PFTVQ7GUnP2nC6a42GlquSj1bKtaXI9JA/rUWbcVRT1JQ==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/blingfire-linux-arm64-musl": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire-linux-arm64-musl/-/blingfire-linux-arm64-musl-1.2.0.tgz", + "integrity": "sha512-i52nJN3DxrJA0H7F0vIs7gsDKpxwuNqvc3/w/6SxpPJuV9X0UfvtZ5GcYKmcKUfLIZBk1pxW2ukRW3KagBcPaQ==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/blingfire-linux-x64-gnu": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire-linux-x64-gnu/-/blingfire-linux-x64-gnu-1.2.0.tgz", + "integrity": "sha512-9GA+RaNikYlLhQd4i3aJQGAICd3kSFKN3xr8JZhi3YirhbU4GsPLC6FIdTC44QgOtciR/4tUGS1fCM/SkIJowg==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/blingfire-linux-x64-musl": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire-linux-x64-musl/-/blingfire-linux-x64-musl-1.2.0.tgz", + "integrity": "sha512-/Phblzva6LsWYgFrk3niZq4sBIDY9/3fFMCJo8lF65B2Rkz1BWNoxSCEjmyFeYdfjmgsDClRtR1lymGZrjT5hA==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/blingfire-win32-x64-msvc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@livekit/blingfire-win32-x64-msvc/-/blingfire-win32-x64-msvc-1.2.0.tgz", + "integrity": "sha512-VAz0sr5ogT11CsviPSdbaGV0A7onGH9oW+vtN8XP1hwP5Mm1Dgz7rfG2ZYVi1pRuNqJfF2zmEVm9/Qmb6EYvDA==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@livekit/local-inference": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@livekit/local-inference/-/local-inference-0.3.1.tgz", + "integrity": "sha512-XlVVh9MeqheD+wFzp2x20s+EDKg2ethL0j4D2L25wd+wnbRXOIsj/nt0mMruX+Q4Dd0XS2f4gdCIQXz7AFjVzA==", + "hasInstallScript": true, + "license": "Apache-2.0 AND LicenseRef-LiveKit-Model", + "dependencies": { + "node-gyp-build": "^4.8.0" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "@livekit/local-inference-darwin-arm64": "0.3.1", + "@livekit/local-inference-darwin-x64": "0.3.1", + "@livekit/local-inference-linux-arm64-gnu": "0.3.1", + "@livekit/local-inference-linux-x64-gnu": "0.3.1", + "@livekit/local-inference-win32-x64-msvc": "0.3.1" + } + }, + "node_modules/@livekit/local-inference-darwin-arm64": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@livekit/local-inference-darwin-arm64/-/local-inference-darwin-arm64-0.3.1.tgz", + "integrity": "sha512-yLe4SNxe7NRr6DuB5j6MHzFT3Gc8q3+By0AFVm4ouv2LTU2TJ3YIO3aLCdWrmUjT6xWAaUu0aAdyBvkQZmnmlg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@livekit/local-inference-darwin-x64": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@livekit/local-inference-darwin-x64/-/local-inference-darwin-x64-0.3.1.tgz", + "integrity": "sha512-5A1TiXnQrLBt8JdmgYCjjY0xUz3IpT9NxwlY/IYx6qz38JdvznI/0AG0lSU8jE/XoGT0x4yynO/n9dP1Mym8Kw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@livekit/local-inference-linux-arm64-gnu": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@livekit/local-inference-linux-arm64-gnu/-/local-inference-linux-arm64-gnu-0.3.1.tgz", + "integrity": "sha512-Aw5NFw1dsWL1d/GYFEbzEk9jUvj9QjS7DFc00K/onLbSphD30mG+a+GvxYW872XUlvRkh3eUblUB+lDBokXZ7w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/local-inference-linux-x64-gnu": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@livekit/local-inference-linux-x64-gnu/-/local-inference-linux-x64-gnu-0.3.1.tgz", + "integrity": "sha512-hIKKfMQWNQ8qLzg8i79NkEgiElV2BgBK9D+YvDnWFZct7WrAflxmCOQj/n2Et2zVMTL1u9HTU9QvyZj2vrKHOg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@livekit/local-inference-win32-x64-msvc": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@livekit/local-inference-win32-x64-msvc/-/local-inference-win32-x64-msvc-0.3.1.tgz", + "integrity": "sha512-3p0187XMeEAbbp8gPFhWFwr9SwmQVFlwWI48HukbpPnhiYK/jEsAGeHzXd2uEISu2qlj6Ee1euhPoWALAXeqxw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@livekit/mutex": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@livekit/mutex/-/mutex-1.1.1.tgz", + "integrity": "sha512-EsshAucklmpuUAfkABPxJNhzj9v2sG7JuzFDL4ML1oJQSV14sqrpTYnsaOudMAw9yOaW53NU3QQTlUQoRs4czw==", + "license": "Apache-2.0" + }, + "node_modules/@livekit/protocol": { + "version": "1.54.1", + "resolved": "https://registry.npmjs.org/@livekit/protocol/-/protocol-1.54.1.tgz", + "integrity": "sha512-eW6iAeKQdljAD4aDmANnV2SE0iQ06Atw2F1F4kIiy4lXaD5bNTlfAnH27B+ZKgu49Nrnn172JnRQ3WxXVBhlBQ==", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.10.0" + } + }, + "node_modules/@livekit/rtc-ffi-bindings": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@livekit/rtc-ffi-bindings/-/rtc-ffi-bindings-0.13.2.tgz", + "integrity": "sha512-0JrZABVvpQt/PcCR51udLxm0JAPF3jt8ncQOBu/H8qlNTLAqW00qTVhYp7hrtJ7REd7MKxIkgv+zThLQVpXXzQ==", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.10.1" + }, + "engines": { + "node": ">= 18" + }, + "optionalDependencies": { + "@livekit/rtc-ffi-bindings-darwin-arm64": "0.13.2", + "@livekit/rtc-ffi-bindings-darwin-x64": "0.13.2", + "@livekit/rtc-ffi-bindings-linux-arm64-gnu": "0.13.2", + "@livekit/rtc-ffi-bindings-linux-x64-gnu": "0.13.2", + "@livekit/rtc-ffi-bindings-win32-x64-msvc": "0.13.2" + } + }, + "node_modules/@livekit/rtc-ffi-bindings-darwin-arm64": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@livekit/rtc-ffi-bindings-darwin-arm64/-/rtc-ffi-bindings-darwin-arm64-0.13.2.tgz", + "integrity": "sha512-XPdp00ZHM5kiCRdKNxGer5eDrlq1KO4ck7CAisX+fWENUxTXzMhOPzbIxfjH28fMVw24Ajs8ViMJwvIUIKuBQA==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 18" + } + }, + "node_modules/@livekit/rtc-ffi-bindings-darwin-x64": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@livekit/rtc-ffi-bindings-darwin-x64/-/rtc-ffi-bindings-darwin-x64-0.13.2.tgz", + "integrity": "sha512-36R0qqV7JeECWPp68uJtHy46gPfDl+xlGabnUiSz2sSutmrjtNK0bTpzX2OgoP7HPqMDep0bBySTnkv/8RCPtg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 18" + } + }, + "node_modules/@livekit/rtc-ffi-bindings-linux-arm64-gnu": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@livekit/rtc-ffi-bindings-linux-arm64-gnu/-/rtc-ffi-bindings-linux-arm64-gnu-0.13.2.tgz", + "integrity": "sha512-flYJL65NG+o1tNisPXY3Mhx0+fGb7DlBgvTaMzwYsc+KHhefEUgIRSSo78JEF/IM1MQVEneLQsGPqXuqEMC3aA==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 18" + } + }, + "node_modules/@livekit/rtc-ffi-bindings-linux-x64-gnu": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@livekit/rtc-ffi-bindings-linux-x64-gnu/-/rtc-ffi-bindings-linux-x64-gnu-0.13.2.tgz", + "integrity": "sha512-acxG8CXMCN4Dgx+nl/1n4CP2G1c8YgmYBs2cA/BpUwYUXsCf9nlnJKRa1i/PIQlTFshdnbgq31RJtz4b3cdGNA==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 18" + } + }, + "node_modules/@livekit/rtc-ffi-bindings-win32-x64-msvc": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/@livekit/rtc-ffi-bindings-win32-x64-msvc/-/rtc-ffi-bindings-win32-x64-msvc-0.13.2.tgz", + "integrity": "sha512-ho3Q6T5kdvaXEVMvvLl+RmuStlDXzwqg3rY7hm95eZXeRwSCAmkfRz+cHuUDzztCiYNAey4zI1jPkHSRK5lTGg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 18" + } + }, + "node_modules/@livekit/rtc-node": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@livekit/rtc-node/-/rtc-node-1.2.2.tgz", + "integrity": "sha512-OiSB0d+2xuYarQktFVbVUA0BnhgALEf2Qg52EwNriMGDbua/1Pmw4793+FuN+zTXG0b7ntGFHdy1rRqu0+GHqA==", + "license": "Apache-2.0", + "dependencies": { + "@datastructures-js/deque": "1.0.8", + "@livekit/mutex": "^1.0.0", + "@livekit/rtc-ffi-bindings": "0.13.2", + "@livekit/typed-emitter": "^3.0.0", + "pino": "^9.0.0", + "pino-pretty": "^13.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@livekit/rtc-node/node_modules/fast-copy": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-4.3.1.tgz", + "integrity": "sha512-CRzQaTFOFUs6PuhsAq7lk9Zqr995soJBcFNZlfJS/5keTSl1awREV9dZW4xS2nX4pWbhIIR0xp4h+J8PQxCkvg==", + "license": "MIT" + }, + "node_modules/@livekit/rtc-node/node_modules/pino": { + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-9.14.0.tgz", + "integrity": "sha512-8OEwKp5juEvb/MjpIc4hjqfgCNysrS94RIOMXYvpYCdm/jglrKEiAYmiumbmGhCvs+IcInsphYDFwqrjr7398w==", + "license": "MIT", + "dependencies": { + "@pinojs/redact": "^0.4.0", + "atomic-sleep": "^1.0.0", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^2.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^5.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^4.0.1", + "thread-stream": "^3.0.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/@livekit/rtc-node/node_modules/pino-abstract-transport": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz", + "integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==", + "license": "MIT", + "dependencies": { + "split2": "^4.0.0" + } + }, + "node_modules/@livekit/rtc-node/node_modules/pino-pretty": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.2.0.tgz", + "integrity": "sha512-jjghD1ML+Di/WxjJDz6j6Y4FT7hIXOlb8h27AyJ+ohtAXJXH4PS/xkv7si+RCCIW59HMgZsMKTDgzdr0RhuRrg==", + "license": "MIT", + "dependencies": { + "colorette": "^2.0.7", + "dateformat": "^4.6.3", + "fast-copy": "^4.0.0", + "fast-safe-stringify": "^2.1.1", + "help-me": "^5.0.0", + "joycon": "^3.1.1", + "minimist": "^1.2.6", + "on-exit-leak-free": "^2.1.2", + "pino-abstract-transport": "^3.0.0", + "pump": "^3.0.3", + "secure-json-parse": "^4.1.0", + "sonic-boom": "^5.0.0", + "strip-json-comments": "^5.0.3" + }, + "bin": { + "pino-pretty": "bin.js" + } + }, + "node_modules/@livekit/rtc-node/node_modules/pino-pretty/node_modules/pino-abstract-transport": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz", + "integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==", + "license": "MIT", + "dependencies": { + "split2": "^4.0.0" + } + }, + "node_modules/@livekit/rtc-node/node_modules/pino-pretty/node_modules/sonic-boom": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-5.0.2.tgz", + "integrity": "sha512-/JEruzo6yhNVhsLblTRchgTQHIt7SsdJP0YyrfWaNKjIOQDfrdZv9gwYraYCAsmKV39/LAdV31FLL5NCDpoL/A==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/@livekit/rtc-node/node_modules/pino-std-serializers": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz", + "integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==", + "license": "MIT" + }, + "node_modules/@livekit/rtc-node/node_modules/process-warning": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.1.1.tgz", + "integrity": "sha512-oCkNVj4OKnKEcocVBcDfiIugN1/cE6rgfT3nCtzeqZPA8+rIxMaQ0xXzIkGP8Gj2qUaP1UR7uhJ1VD8lUCpzCg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, + "node_modules/@livekit/rtc-node/node_modules/secure-json-parse": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-4.1.1.tgz", + "integrity": "sha512-lnd81MQEZKjhW/Gd2TQqdd4XP6QYNdDW/EP+I7nTrFHP9y2LmaGPIHk9xsnzcOiEr1c39c/e84xFgGviQKBTRw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/@livekit/rtc-node/node_modules/sonic-boom": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz", + "integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/@livekit/rtc-node/node_modules/strip-json-comments": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.1.0.tgz", + "integrity": "sha512-ErcwpJBYr8EfX/Br7JauOIGXoRE92w0hVtuS9j92UFgbATxA+WRSIZksSUDzEeItfWB/0QCEprTZT55RSINUHQ==", + "license": "MIT", + "engines": { + "node": ">=22" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@livekit/rtc-node/node_modules/thread-stream": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-3.2.0.tgz", + "integrity": "sha512-zLBvqpwr4Esa0kRjcrzGU6zL25lePWaCLMx0RQFrmteozIfeNdaMLpG5U7PeHzvlFkAWaRKA9/KVW4F60iB+qw==", + "license": "MIT", + "dependencies": { + "real-require": "^0.2.0" + } + }, + "node_modules/@livekit/throws-transformer": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/@livekit/throws-transformer/-/throws-transformer-0.1.8.tgz", + "integrity": "sha512-AaSwQfIaG6YArKOCO+5/DgI8HfL19oHdrkyI0LJJVCqGeZXzPsZIO/Nm/SKUHbT1ERGhF5c34X8CcVWeOePpIQ==", + "license": "Apache-2.0", + "dependencies": { + "glob": "^13.0.0" + }, + "bin": { + "throws-check": "dist/cli.js" + }, + "peerDependencies": { + "typescript": ">=4.7.0" + } + }, + "node_modules/@livekit/typed-emitter": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@livekit/typed-emitter/-/typed-emitter-3.0.0.tgz", + "integrity": "sha512-9bl0k4MgBPZu3Qu3R3xy12rmbW17e3bE9yf4YY85gJIQ3ezLEj/uzpKHWBsLaDoL5Mozz8QCgggwIBudYQWeQg==", + "license": "MIT" + }, + "node_modules/@opentelemetry/api": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.1.tgz", + "integrity": "sha512-gLyJlPHPZYdAk1JENA9LeHejZe1Ti77/pTeFm/nMXmQH/HFZlcS/O2XJB+L8fkbrNSqhdtlvjBVjxwUYanNH5Q==", + "license": "Apache-2.0", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@opentelemetry/api-logs": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.220.0.tgz", + "integrity": "sha512-CmVa4ImJ+ynfrPMNaAXHET6Bhb44SwzmfyVJFq9ni2jgXJR/l7C6gfVFddNmHP+ZOkP9cf4f9DBe68qVLTHc9w==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api": "^1.3.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@opentelemetry/context-async-hooks": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/context-async-hooks/-/context-async-hooks-2.12.1.tgz", + "integrity": "sha512-1+zgZyD7QvBr0/K6+FVx5UAzdGo0shnQf8pbWUFFbj43qZPIKTtfK4xX4J3bS7AmkifiZzAEMdk8dztiEfkgmg==", + "license": "Apache-2.0", + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/core": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.12.1.tgz", + "integrity": "sha512-3hr6Pj0/G0oVgIGb97IVcw9BjZ6eudonKjrmQxw7JquyU/XmVbJelkmyoU0sT/OvHGkv+r1tcrwv8MbSX7aKHw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-logs-otlp-proto": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-logs-otlp-proto/-/exporter-logs-otlp-proto-0.220.0.tgz", + "integrity": "sha512-8LZAxdJ0ENDAFwr4j0oY35mHBltiSzvlhdQAPGiC7p9VnxtuSq4SW1gfBAdW6t6hiQG6OwUl8w7KHaOdJPKHWg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/otlp-exporter-base": "0.220.0", + "@opentelemetry/otlp-transformer": "0.220.0", + "@opentelemetry/sdk-logs": "0.220.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-http": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-http/-/exporter-metrics-otlp-http-0.220.0.tgz", + "integrity": "sha512-Yqt3RBw/bRVncaE9qIIhk4WfjbAQqXuP9FgAaU+IKPndnLEp/cUqZlSC324+bpmduRz7DoTjig8Ub0PeILWXUA==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/otlp-exporter-base": "0.220.0", + "@opentelemetry/otlp-transformer": "0.220.0", + "@opentelemetry/resources": "2.9.0", + "@opentelemetry/sdk-metrics": "2.9.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.9.0.tgz", + "integrity": "sha512-m2nckMT80NnmjTYSPjJQObBJ+8dgkoajEOUbznL8AHZ3T3yHRk2P7gI1PhEBc1+lOnrYE9UWrWHqJDsmqjmNbw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/resources": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.9.0.tgz", + "integrity": "sha512-jyA5MBLQ+Dkl3+JsZkUoUvL7yHvU64kLsvpXKarWm6347Sl1t1bXFTFykUePNpT5WH5pm9a2Qtt03iIYQhZ1Fg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/sdk-metrics": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.9.0.tgz", + "integrity": "sha512-Xx8RGS4H5XEBl01WuCreMIpiah9cCXMbSkeuIePPdD2cUpq/vUzYmj8E/MK1OsbOc93FuAD4jfn2WOacKwLn7Q==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/resources": "2.9.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.9.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-proto": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-proto/-/exporter-metrics-otlp-proto-0.220.0.tgz", + "integrity": "sha512-lyO+IQBdSvqHN/ZOW/OzrSWemtfD+HgWngn+HBNLhjy0YrCQQTz0OE/kSekH2Pl340dn9DWzhqHdz5Eftr+HLA==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/exporter-metrics-otlp-http": "0.220.0", + "@opentelemetry/otlp-exporter-base": "0.220.0", + "@opentelemetry/otlp-transformer": "0.220.0", + "@opentelemetry/resources": "2.9.0", + "@opentelemetry/sdk-metrics": "2.9.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.9.0.tgz", + "integrity": "sha512-m2nckMT80NnmjTYSPjJQObBJ+8dgkoajEOUbznL8AHZ3T3yHRk2P7gI1PhEBc1+lOnrYE9UWrWHqJDsmqjmNbw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/resources": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.9.0.tgz", + "integrity": "sha512-jyA5MBLQ+Dkl3+JsZkUoUvL7yHvU64kLsvpXKarWm6347Sl1t1bXFTFykUePNpT5WH5pm9a2Qtt03iIYQhZ1Fg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-metrics-otlp-proto/node_modules/@opentelemetry/sdk-metrics": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.9.0.tgz", + "integrity": "sha512-Xx8RGS4H5XEBl01WuCreMIpiah9cCXMbSkeuIePPdD2cUpq/vUzYmj8E/MK1OsbOc93FuAD4jfn2WOacKwLn7Q==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/resources": "2.9.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.9.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-trace-otlp-proto": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-proto/-/exporter-trace-otlp-proto-0.220.0.tgz", + "integrity": "sha512-voTAD8XgJxlK7zLkXh8EzMB09zrQr3tyY/BsnDTlDiQU/UdK58MZ63A3mUjdEDrxMjCVmBHU3WQJhRmQe+Dvzg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/otlp-exporter-base": "0.220.0", + "@opentelemetry/otlp-transformer": "0.220.0", + "@opentelemetry/resources": "2.9.0", + "@opentelemetry/sdk-trace": "2.9.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.9.0.tgz", + "integrity": "sha512-m2nckMT80NnmjTYSPjJQObBJ+8dgkoajEOUbznL8AHZ3T3yHRk2P7gI1PhEBc1+lOnrYE9UWrWHqJDsmqjmNbw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/resources": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.9.0.tgz", + "integrity": "sha512-jyA5MBLQ+Dkl3+JsZkUoUvL7yHvU64kLsvpXKarWm6347Sl1t1bXFTFykUePNpT5WH5pm9a2Qtt03iIYQhZ1Fg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/instrumentation": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.220.0.tgz", + "integrity": "sha512-xQx3E2WxP1mDvKzxLxX+CTCtNLa560YJZ3087qYHerl2YmiKpv7AH+dAy7vmx+eVrZ5BwhfWUAVoKOoxCNHcpw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "0.220.0", + "import-in-the-middle": "^3.0.0", + "require-in-the-middle": "^8.0.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/instrumentation-pino": { + "version": "0.66.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-pino/-/instrumentation-pino-0.66.0.tgz", + "integrity": "sha512-RMAtAYuyouaMbHkQG8E97nJfwHftxmCbOURdD3n5s2Yd5zctLNudXB5hAfW18lsfUbePwQCND6QUXZixFN92Pw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "^0.220.0", + "@opentelemetry/core": "^2.0.0", + "@opentelemetry/instrumentation": "^0.220.0", + "@opentelemetry/semantic-conventions": "^1.41.1" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/otlp-exporter-base": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.220.0.tgz", + "integrity": "sha512-CXYo8UD5Mn9YbgebO2EL4wejtA+gxLmLiu6HCk2KH2BR7XhFN6/6p1UlCb23DYCjeYkndevLHuejCCN1yx4+OQ==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/otlp-transformer": "0.220.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/otlp-exporter-base/node_modules/@opentelemetry/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.9.0.tgz", + "integrity": "sha512-m2nckMT80NnmjTYSPjJQObBJ+8dgkoajEOUbznL8AHZ3T3yHRk2P7gI1PhEBc1+lOnrYE9UWrWHqJDsmqjmNbw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/otlp-transformer": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.220.0.tgz", + "integrity": "sha512-lXGrv7KXZ0gNH9SVNUaa6vv6phVYGvJxfXAlMbzbakiXru75f5MZl8Z7oqiMMQD77riVHJCFlQvbZs/VVN2/4A==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "0.220.0", + "@opentelemetry/core": "2.9.0", + "@opentelemetry/resources": "2.9.0", + "@opentelemetry/sdk-logs": "0.220.0", + "@opentelemetry/sdk-metrics": "2.9.0", + "@opentelemetry/sdk-trace": "2.9.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" + } + }, + "node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.9.0.tgz", + "integrity": "sha512-m2nckMT80NnmjTYSPjJQObBJ+8dgkoajEOUbznL8AHZ3T3yHRk2P7gI1PhEBc1+lOnrYE9UWrWHqJDsmqjmNbw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/resources": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.9.0.tgz", + "integrity": "sha512-jyA5MBLQ+Dkl3+JsZkUoUvL7yHvU64kLsvpXKarWm6347Sl1t1bXFTFykUePNpT5WH5pm9a2Qtt03iIYQhZ1Fg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/otlp-transformer/node_modules/@opentelemetry/sdk-metrics": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.9.0.tgz", + "integrity": "sha512-Xx8RGS4H5XEBl01WuCreMIpiah9cCXMbSkeuIePPdD2cUpq/vUzYmj8E/MK1OsbOc93FuAD4jfn2WOacKwLn7Q==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/resources": "2.9.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.9.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/resources": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.12.1.tgz", + "integrity": "sha512-IwrNcuLCvnJAnNLkXxx0Uw+rjBkVW6VGQrhd7PanNf0LavOzkTk9sDAjdqegM7p/VdxefNRrii6d+wBRJfz35g==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.12.1", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-logs": { + "version": "0.220.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.220.0.tgz", + "integrity": "sha512-WywcTkQtv2iNmt+6y5Kcd4rzvx9bLVsBa2Nwcmg01IUaBTkTow3W4d9KE5vNBpEDtb9tp21WcRBY/lANRrApYA==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/api-logs": "0.220.0", + "@opentelemetry/core": "2.9.0", + "@opentelemetry/resources": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.9.0.tgz", + "integrity": "sha512-m2nckMT80NnmjTYSPjJQObBJ+8dgkoajEOUbznL8AHZ3T3yHRk2P7gI1PhEBc1+lOnrYE9UWrWHqJDsmqjmNbw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-logs/node_modules/@opentelemetry/resources": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.9.0.tgz", + "integrity": "sha512-jyA5MBLQ+Dkl3+JsZkUoUvL7yHvU64kLsvpXKarWm6347Sl1t1bXFTFykUePNpT5WH5pm9a2Qtt03iIYQhZ1Fg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-metrics": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.12.1.tgz", + "integrity": "sha512-HeSblYhpds4QWliBE7ANCfoa2p3QH83uUxX4vO2qtk6BhIcqP7qDYYT36z3LOXftEBpdfbDStZxv+Cw5mqKX5g==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.12.1", + "@opentelemetry/resources": "2.12.1" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.9.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-trace": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace/-/sdk-trace-2.9.0.tgz", + "integrity": "sha512-sGA19HvtrrSKYsseHphluH6j3p6Xa3fqc7c7y8f/7mYWejc1lyDFcpSdD1kYa50HCLUeEo4zA5bW0pniaPszuw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/resources": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-trace-base": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.12.1.tgz", + "integrity": "sha512-CMrcqFxTikYmYQCuHToBO4kQvWIseRk2ztzWidTd7VutIxj1rljvJZCZnFPJEGNOS7FvaSmRL21Jeuu3/wrCAQ==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.12.1", + "@opentelemetry/resources": "2.12.1", + "@opentelemetry/sdk-trace": "2.12.1", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-trace-base/node_modules/@opentelemetry/sdk-trace": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace/-/sdk-trace-2.12.1.tgz", + "integrity": "sha512-vANdmCYnn+Ka/alBKxwICMl4Koa+aQBlRC9zAZy+Ig1Obbo3RZt2oiyv+8/gET5rrBBYrO3YniPcXfwZrN01rg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.12.1", + "@opentelemetry/resources": "2.12.1", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-trace-node": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-node/-/sdk-trace-node-2.12.1.tgz", + "integrity": "sha512-nRe0mimXZHknAEW2PKN9VbmML+93il5okotyDIUMhgYJ0QPM999fsh7djH6HDheyAbXO/C24t/B4fOQbNap8Vw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/context-async-hooks": "2.12.1", + "@opentelemetry/core": "2.12.1", + "@opentelemetry/sdk-trace-base": "2.12.1" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-trace/node_modules/@opentelemetry/core": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.9.0.tgz", + "integrity": "sha512-m2nckMT80NnmjTYSPjJQObBJ+8dgkoajEOUbznL8AHZ3T3yHRk2P7gI1PhEBc1+lOnrYE9UWrWHqJDsmqjmNbw==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/sdk-trace/node_modules/@opentelemetry/resources": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.9.0.tgz", + "integrity": "sha512-jyA5MBLQ+Dkl3+JsZkUoUvL7yHvU64kLsvpXKarWm6347Sl1t1bXFTFykUePNpT5WH5pm9a2Qtt03iIYQhZ1Fg==", + "license": "Apache-2.0", + "dependencies": { + "@opentelemetry/core": "2.9.0", + "@opentelemetry/semantic-conventions": "^1.29.0" + }, + "engines": { + "node": "^18.19.0 || >=20.6.0" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.10.0" + } + }, + "node_modules/@opentelemetry/semantic-conventions": { + "version": "1.45.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.45.0.tgz", + "integrity": "sha512-aOP45mbcOKbQVvFWfQmgoOPT8R2iwbbbgl83k4CujGV9BrJhFr3qG55MFpwFs4YLabpuW3HhzUY9eQxPlDqaZw==", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + } + }, + "node_modules/@pinojs/redact": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz", + "integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==", + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/pidusage": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/pidusage/-/pidusage-2.0.5.tgz", + "integrity": "sha512-MIiyZI4/MK9UGUXWt0jJcCZhVw7YdhBuTOuqP/BjuLDLZ2PmmViMIQgZiWxtaMicQfAz/kMrZ5T7PKxFSkTeUA==", + "license": "MIT" + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/cjs-module-lexer": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-2.3.0.tgz", + "integrity": "sha512-lmNyBzi6iYiqyrExTctfmjd8tInx+dHu9PBomTfH5RXS53c27JMFJgzNv5TyAnm3PgGf+MLy0+Ws41/HlVxdKQ==", + "license": "MIT" + }, + "node_modules/colorette": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/destr": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.5.tgz", + "integrity": "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==", + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-module-lexer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-3.0.5.tgz", + "integrity": "sha512-RNq2lKJw53c7z9QRHeiKeA6Ez0oikOqiBGdmxQhKDxEiOX1g5QJR4IoFVwicn8uCZcRWNrXC3NZaJihgK7aEbg==", + "license": "MIT" + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/fast-copy": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-3.1.0.tgz", + "integrity": "sha512-IuCOCDFM1F/s4LtG7Bjr3yUUwPHybyhqN74xk2cMYoP51vVeErMy8+6HGFchi/+45lW8uzhs6lBeEqks2GWt6A==", + "license": "MIT" + }, + "node_modules/fast-redact": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz", + "integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "license": "MIT" + }, + "node_modules/fluent-ffmpeg": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.3.tgz", + "integrity": "sha512-Be3narBNt2s6bsaqP6Jzq91heDgOEaDCJAXcE3qcma/EJBSy5FB4cvO31XBInuAuKBx8Kptf8dkhjK0IOru39Q==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "license": "MIT", + "dependencies": { + "async": "^0.2.9", + "which": "^1.1.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob": { + "version": "13.0.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.7.tgz", + "integrity": "sha512-wfsFgXQ8A3SEI9XGf7Nl3Y9l7ffSrGh7SUCT7vU/2CzYPep9kjxAn1S40F9OPKxAMGCVl7HtNlJhrCJUeUq83g==", + "license": "BlueOak-1.0.0", + "dependencies": { + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/heap-js": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/heap-js/-/heap-js-2.7.1.tgz", + "integrity": "sha512-EQfezRg0NCZGNlhlDR3Evrw1FVL2G3LhU7EgPoxufQKruNBSYA8MiRPHeWbU+36o+Fhel0wMwM+sLEiBAlNLJA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/help-me": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz", + "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==", + "license": "MIT" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/import-in-the-middle": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-3.6.0.tgz", + "integrity": "sha512-xRU7hI24S2FhucXtuZXn8EpcOjfVP6iiEQyR0USayPeaOroEmSsNlqnl95866iRdRtkHrd6Q/Z4D14R60au0+A==", + "license": "Apache-2.0", + "dependencies": { + "cjs-module-lexer": "^2.2.0", + "es-module-lexer": "^3.0.4", + "module-details-from-path": "^1.0.4" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC" + }, + "node_modules/jose": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-5.10.0.tgz", + "integrity": "sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", + "license": "(AFL-2.1 OR BSD-3-Clause)" + }, + "node_modules/jsonrepair": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/jsonrepair/-/jsonrepair-3.15.0.tgz", + "integrity": "sha512-wy8OTjwsJwQRnQJkKnMJJ9vcytRdBPAgIF/Hy6+s1dAj42BHMKiyL8JzEieIl3JY7idt8eyHwBWTO8mh/+mtwA==", + "license": "ISC", + "bin": { + "jsonrepair": "bin/cli.js" + } + }, + "node_modules/livekit-server-sdk": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/livekit-server-sdk/-/livekit-server-sdk-2.20.0.tgz", + "integrity": "sha512-kkzvWp50q8oPGhJp7gpgGSPx2riQAzTZQXOBKz7ze58Be+dzdArneTbXM9ATZ5BdRFFvN+sxGEfGYyXAczLFig==", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.10.1", + "@livekit/protocol": "1.53.0", + "jose": "^5.1.2" + }, + "engines": { + "node": ">=19" + } + }, + "node_modules/livekit-server-sdk/node_modules/@livekit/protocol": { + "version": "1.53.0", + "resolved": "https://registry.npmjs.org/@livekit/protocol/-/protocol-1.53.0.tgz", + "integrity": "sha512-dM562Q7sEQbJ9ZghjIpcVuRxRApGNwJW/JfXRub+dJT8J1cC2Tep0SyYkDzOawix7+0x969fnjXt0qEZOxkjbQ==", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.10.0" + } + }, + "node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/module-details-from-path": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/module-details-from-path/-/module-details-from-path-1.0.4.tgz", + "integrity": "sha512-EGWKgxALGMgzvxYF1UyGTy0HXX/2vHLkw6+NvDKW2jypWbHpjQuj4UMcqQWXHERJhVGKikolT06G3bcKe4fi7w==", + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/node-fetch-native": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.7.tgz", + "integrity": "sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==", + "license": "MIT" + }, + "node_modules/node-gyp-build": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz", + "integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==", + "license": "MIT", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/ofetch": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.5.1.tgz", + "integrity": "sha512-2W4oUZlVaqAPAil6FUg/difl6YhqhUR7x2eZY4bQCko22UXg3hptq9KLQdqFClV+Wu85UX7hNtdGTngi/1BxcA==", + "license": "MIT", + "dependencies": { + "destr": "^2.0.5", + "node-fetch-native": "^1.6.7", + "ufo": "^1.6.1" + } + }, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/openai": { + "version": "6.49.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-6.49.0.tgz", + "integrity": "sha512-aYCc0C6L864eR6WSYIwQGyXriw/nIyZx0ObvhzOEVuk0zoBDpynjSbrionWI7q65B5H8jJX0DXR9snEzM6bfPg==", + "license": "Apache-2.0", + "peerDependencies": { + "@aws-sdk/credential-provider-node": ">=3.972.0 <4", + "@smithy/hash-node": ">=4.3.0 <5", + "@smithy/signature-v4": ">=5.4.0 <6", + "ws": "^8.18.0", + "zod": "^3.25 || ^4.0" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-provider-node": { + "optional": true + }, + "@smithy/hash-node": { + "optional": true + }, + "@smithy/signature-v4": { + "optional": true + }, + "ws": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, + "node_modules/path-scurry": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/pidusage": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/pidusage/-/pidusage-4.1.0.tgz", + "integrity": "sha512-0hHaTY71M63oQQw1F41jvSIbHZQ+qnhUGGtctVsKgw4rO3p6ECUEC7Fry3c8RzuZeMugtLttg+bAEb9lmliGyw==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/pino": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-8.21.0.tgz", + "integrity": "sha512-ip4qdzjkAyDDZklUaZkcRFb2iA118H9SgRh8yzTkSQK8HilsOJF7rSY8HoW5+I0M46AZgX/pxbprf2vvzQCE0Q==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.1.1", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^1.2.0", + "pino-std-serializers": "^6.0.0", + "process-warning": "^3.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^3.7.0", + "thread-stream": "^2.6.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-1.2.0.tgz", + "integrity": "sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q==", + "license": "MIT", + "dependencies": { + "readable-stream": "^4.0.0", + "split2": "^4.0.0" + } + }, + "node_modules/pino-pretty": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-11.3.0.tgz", + "integrity": "sha512-oXwn7ICywaZPHmu3epHGU2oJX4nPmKvHvB/bwrJHlGcbEWaVcotkpyVHMKLKmiVryWYByNp0jpgAcXpFJDXJzA==", + "license": "MIT", + "dependencies": { + "colorette": "^2.0.7", + "dateformat": "^4.6.3", + "fast-copy": "^3.0.2", + "fast-safe-stringify": "^2.1.1", + "help-me": "^5.0.0", + "joycon": "^3.1.1", + "minimist": "^1.2.6", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^2.0.0", + "pump": "^3.0.0", + "readable-stream": "^4.0.0", + "secure-json-parse": "^2.4.0", + "sonic-boom": "^4.0.1", + "strip-json-comments": "^3.1.1" + }, + "bin": { + "pino-pretty": "bin.js" + } + }, + "node_modules/pino-pretty/node_modules/pino-abstract-transport": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-2.0.0.tgz", + "integrity": "sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==", + "license": "MIT", + "dependencies": { + "split2": "^4.0.0" + } + }, + "node_modules/pino-pretty/node_modules/sonic-boom": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz", + "integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/pino-std-serializers": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.2.2.tgz", + "integrity": "sha512-cHjPPsE+vhj/tnhCy/wiMh3M3z3h/j15zHQX+S9GkTBgqJuTuJzYJ4gUyACLhDaJ7kk9ba9iRDmbH2tJU03OiA==", + "license": "MIT" + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/process-warning": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-3.0.0.tgz", + "integrity": "sha512-mqn0kFRl0EoqhnL0GQ0veqFHyIN1yig9RHh/InzORTUiZHFRAur+aMtRkELNwGs9aNwKS6tg/An4NYBPGwvtzQ==", + "license": "MIT" + }, + "node_modules/pump": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", + "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", + "license": "MIT" + }, + "node_modules/readable-stream": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.8.0.tgz", + "integrity": "sha512-2jhTTU3Eilp/2DMT71gbcoqC35eQHasMJH0RHkYxwlxIv3+FR6Y5xAFZIwEGLxKkjZYEFlsiMNIdwUqjK2lLHQ==", + "license": "MIT", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/real-require": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", + "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", + "license": "MIT", + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/require-in-the-middle": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/require-in-the-middle/-/require-in-the-middle-8.0.1.tgz", + "integrity": "sha512-QT7FVMXfWOYFbeRBF6nu+I6tr2Tf3u0q8RIEjNob/heKY/nh7drD/k7eeMFmSQgnTtCzLDcCu/XEnpW2wk4xCQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "module-details-from-path": "^1.0.3" + }, + "engines": { + "node": ">=9.3.0 || >=8.10.0 <9.0.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/secure-json-parse": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-2.7.0.tgz", + "integrity": "sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==", + "license": "BSD-3-Clause" + }, + "node_modules/semver": { + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sharp": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz", + "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==", + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.5", + "@img/sharp-darwin-x64": "0.35.5", + "@img/sharp-freebsd-wasm32": "0.35.5", + "@img/sharp-libvips-darwin-arm64": "1.3.4", + "@img/sharp-libvips-darwin-x64": "1.3.4", + "@img/sharp-libvips-linux-arm": "1.3.4", + "@img/sharp-libvips-linux-arm64": "1.3.4", + "@img/sharp-libvips-linux-ppc64": "1.3.4", + "@img/sharp-libvips-linux-riscv64": "1.3.4", + "@img/sharp-libvips-linux-s390x": "1.3.4", + "@img/sharp-libvips-linux-x64": "1.3.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", + "@img/sharp-libvips-linuxmusl-x64": "1.3.4", + "@img/sharp-linux-arm": "0.35.5", + "@img/sharp-linux-arm64": "0.35.5", + "@img/sharp-linux-ppc64": "0.35.5", + "@img/sharp-linux-riscv64": "0.35.5", + "@img/sharp-linux-s390x": "0.35.5", + "@img/sharp-linux-x64": "0.35.5", + "@img/sharp-linuxmusl-arm64": "0.35.5", + "@img/sharp-linuxmusl-x64": "0.35.5", + "@img/sharp-webcontainers-wasm32": "0.35.5", + "@img/sharp-win32-arm64": "0.35.5", + "@img/sharp-win32-ia32": "0.35.5", + "@img/sharp-win32-x64": "0.35.5" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/sonic-boom": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.8.1.tgz", + "integrity": "sha512-y4Z8LCDBuum+PBP3lSV7RHrXscqksve/bi0as7mhwVnBW+/wUqKT/2Kb7um8yqcFy0duYbbPxzt89Zy2nOCaxg==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/thread-stream": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-2.7.0.tgz", + "integrity": "sha512-qQiRWsU/wvNolI6tbbCKd9iKaTnCXsTwVxhhKM6nctPdujTyztjlbUkUTUymidWcMnZ5pWR0ej4a0tjsW021vw==", + "license": "MIT", + "dependencies": { + "real-require": "^0.2.0" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "license": "0BSD", + "optional": true + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/ufo": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.4.tgz", + "integrity": "sha512-JFNbkD1Svwe0KvGi8GOeLcP4kAWQ609twvCdcHxq1oSL8svv39ZuSvajcD8B+5D0eL4+s1Is2D/O6KN3qcTeRA==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/ws": { + "version": "8.23.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.23.0.tgz", + "integrity": "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz", + "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==", + "license": "ISC", + "peerDependencies": { + "zod": "^3.25.28 || ^4" + } + } + } +} diff --git a/livekit/voice-adventure/agent/package.json b/livekit/voice-adventure/agent/package.json new file mode 100644 index 0000000..9b786b1 --- /dev/null +++ b/livekit/voice-adventure/agent/package.json @@ -0,0 +1,25 @@ +{ + "name": "hookdeck-livekit-story-agent", + "version": "1.0.0", + "private": true, + "type": "module", + "description": "The voice agents for the LiveKit call log demo: an intro agent and a game master", + "scripts": { + "start": "node src/main.ts dev", + "typecheck": "tsc --noEmit", + "test": "node --test test/*.test.ts" + }, + "dependencies": { + "@livekit/agents": "1.10.0", + "@livekit/rtc-node": "1.2.2", + "dotenv": "^16.3.1", + "zod": "^4.1.12" + }, + "engines": { + "node": ">=22.18" + }, + "devDependencies": { + "@types/node": "^22.0.0", + "typescript": "^5.9.2" + } +} diff --git a/livekit/voice-adventure/agent/src/llm.ts b/livekit/voice-adventure/agent/src/llm.ts new file mode 100644 index 0000000..8b32b83 --- /dev/null +++ b/livekit/voice-adventure/agent/src/llm.ts @@ -0,0 +1,22 @@ +/** The characters' language model: LiveKit Inference, `openai/gpt-4.1-mini`, billed to your LiveKit project. */ +import { inference, llm } from '@livekit/agents'; + +export const LLM_MODEL = 'openai/gpt-4.1-mini'; + +/** One line for the startup log. */ +export const describeLlm = () => `LLM: LiveKit Inference ${LLM_MODEL}`; + +export const makeLlm = (): llm.LLM => new inference.LLM({ model: LLM_MODEL }); + +/** One small, separate call with a short answer (a few tokens, or a small JSON object with a larger limit). Used to read a player's words into actions. */ +export async function askShort(prompt: { system: string; user: string }, timeout_ms = 4000, max_tokens = 4): Promise { + const small = new inference.LLM({ model: LLM_MODEL, modelOptions: { max_completion_tokens: max_tokens, temperature: 0 } as any }); + const chat_ctx = llm.ChatContext.empty(); + chat_ctx.addMessage({ role: 'system', content: prompt.system }); + chat_ctx.addMessage({ role: 'user', content: prompt.user }); + const stream = small.chat({ chatCtx: chat_ctx, toolChoice: 'none' }); + let text = ''; + const run = (async () => { for await (const chunk of stream) text += chunk.delta?.content ?? ''; return text; })(); + const timer = new Promise((_, reject) => setTimeout(() => reject(new Error(`no answer within ${timeout_ms} ms`)), timeout_ms)); + try { return await Promise.race([run, timer]); } finally { stream.close(); } +} diff --git a/livekit/voice-adventure/agent/src/main.ts b/livekit/voice-adventure/agent/src/main.ts new file mode 100644 index 0000000..a6459be --- /dev/null +++ b/livekit/voice-adventure/agent/src/main.ts @@ -0,0 +1,662 @@ +/** + * The two characters of story night: Hester Pennywhistle, the innkeeper of the Drowned Bell, who greets + * travellers at the door and writes each name in her ledger, and Old Bram Tallow, a retired lighthouse + * keeper who tells the adventure. Both are fictional. They are one agent participant in the room, handed + * off when Hester says she will fetch Bram. The code decides what happens (a small model call reads each player input into + * moves, takes, uses and gives, and the code validates and applies them); Bram only narrates. When the party moves to a place with a + * different soundtrack, the demo app pulls it into the room with LiveKit's Ingress API. + * + * Speech-to-text, the language model and text-to-speech all run on LiveKit Inference, so the only + * credentials are the LiveKit project's API key and secret. Run it with `npm run agent`. + * + * The agent publishes what the page needs as participant attributes on its own participant: + * `story.character` (who is speaking), `story.turn` and `story.turn_name` (whose turn it is), + * `story.scene` and `story.place` (the place id and its name), `story.satchel`, `story.state` (`playing` or `ended`). + */ +import { type JobContext, ServerOptions, cli, defineAgent, inference, llm, voice } from '@livekit/agents'; +import { ParticipantKind, type RemoteParticipant } from '@livekit/rtc-node'; +import { RoomServiceClient } from 'livekit-server-sdk'; +import dotenv from 'dotenv'; +import { createHmac } from 'node:crypto'; +import { fileURLToPath } from 'node:url'; +import { z } from 'zod'; +import { exitsByDestination, itemById, itemNamed, matchDestination, normalizeItem, PLACES, actionPrompt, addressesPixel, addLightingFromWords, applyActions, closingNote, endTriggered, noActions, parseActions, parseNameCorrection, placeNote, satchelAttribute, usesName, worldAt, type PlaceId, type World } from './world.ts'; +import { askShort, describeLlm, makeLlm } from './llm.ts'; +import { botName, fetchLine, planLedger, shouldFetchBram } from './names.ts'; +import { chooseGesture, respondLine } from './pixel-lines.ts'; +import { addSummaryLine, buildState, decodeState, encodeState, recapInstructions, resumePlayers, shouldResume, type StoryState } from './resume.ts'; +import { BREVITY, CLOSING_LINE, GOAL_LINE, bramInstructions, createEndWatcher, onBramReply, onPlayerInput, onPlayout, onSceneStart, speechFilter, createLlmWatchdog, createTurnRecovery, stallLine } from './story.ts'; + +dotenv.config({ path: fileURLToPath(new URL('../../.env', import.meta.url)) }); + +/** Must match AGENT_NAME in ../src/token.ts: the token's room configuration dispatches this name. */ +const AGENT_NAME = process.env.STORY_AGENT_NAME || 'story-gm'; +const APP_URL = process.env.STORY_APP_URL || `http://localhost:${process.env.PORT || 4000}`; +// The app only accepts scene calls that carry this header (derived from the API secret both processes read from .env; see ../src/rooms.ts) +const APP_HEADERS = { 'content-type': 'application/json', 'x-story-scene-secret': createHmac('sha256', process.env.LIVEKIT_API_SECRET || '').update('story-scene-call').digest('hex') }; + +// Voices, all through LiveKit Inference. Cartesia's Robyn is an Australian, mature voice from LiveKit's +// documented list; Deepgram's Aura 2 Draco is a British male voice. +const HESTER_VOICE = 'cartesia/sonic-3:f31cc6a7-c1e8-4764-980c-60a361443dd1'; +const BRAM_VOICE = 'deepgram/aura-2:draco'; + +interface Player { + identity: string; + name: string; + /** A silent test participant ("Add a bot player" on the page): Bram voices its turns. */ + bot: boolean; + /** Joined with no name: called "Traveller" until they say their name. Not published as their display name. */ + placeholder?: boolean; +} + +interface StoryData { + ctx: JobContext; + players: Player[]; + /** Scenes started so far, and when the last one started. */ + scene_index: number; + last_scene_at: number; + /** Real player inputs in the current scene: a final transcript from the linked player, or Pixel's chat gesture. */ + inputs: number; + /** A player has spoken (or gestured) since Bram's last tool call: next_scene and end_story need it, so they cannot be chained. */ + input_since_call: boolean; + /** Bram's last spoken reply, and who had the last turn (an index into players): code picks the next speaker after playout. */ + last_reply: string; + rotation: number; + /** Finishes the story once the last speech has played out and a short pause has passed. */ + end_watcher: ReturnType | undefined; + /** The storyteller agent. */ + bram: Bram | undefined; + /** Fires if Bram owes a reply and nothing happens for 20 seconds (a hung model request). */ + watchdog: ReturnType | undefined; + ending: boolean; + /** A "say that again" line was spoken: the next playout keeps the turn with the player it went back to. */ + hold_turn?: boolean; + /** Everyone is in the ledger: once Hester has finished speaking, she fetches Bram. */ + handoff_pending: boolean; + pending_bots: string[]; + handed_off: boolean; + /** The last few exchanges, one line each, saved with the story state. */ + summary: string[]; + replies_in_scene: number; + described: string[]; + /** Where the party is and what it carries: the code's state of the world. */ + world: World; + /** The soundtrack that is playing (a place that shares it keeps it going). */ + soundtrack: string | undefined; + /** Where the party is (for the reply's atmosphere tracking) and turns given to a human since the mute player last had one. */ + location?: PlaceId; + /** A counter for Pixel's gestures (`story.pixel_seq`), and what Pixel last did, for Bram to weave into his next reply. */ + pixel_seq: number; + pixel_did: string | undefined; + /** Travellers who joined after the story began: Bram acknowledges them once. */ + arrivals: string[]; + /** Pixel's gesture cooldown: line to the turn it was last used, and a count of turns given. */ + pixel_cooldown: Map; + turn_no: number; + /** Who the current reply answers, for the name check. */ + last_speaker_name: string | undefined; + /** This agent picked up a story another agent left. */ + resumed: boolean; +} + +const is_bot = (p: RemoteParticipant) => p.identity.startsWith('bot-'); +const is_player = (p: RemoteParticipant) => p.info.kind === ParticipantKind.STANDARD || p.info.kind === undefined; +const humans = (ctx: JobContext) => [...ctx.room.remoteParticipants.values()].filter((p) => is_player(p) && !is_bot(p)); + +/** Everyone at the door: players and silent bots, with the name the page's token gave them (if any). */ +const guests = (ctx: JobContext) => + [...ctx.room.remoteParticipants.values()].filter(is_player).map((p) => ({ identity: p.identity, name: p.name, bot: is_bot(p) })); + +/** + * Writes the guests Hester already knows (a typed name on the page, or a bot) into the ledger without asking, + * and returns who she can greet by name and which humans she still has to ask. + */ +function registerKnown(data: StoryData): { greet: string[]; bots: string[]; unnamed: string[] } { + const plan = planLedger(guests(data.ctx), new Set(data.players.map((p) => p.identity))); + const greet: string[] = []; + const bots: string[] = []; + for (const g of plan.named) { + data.players.push({ identity: g.identity, name: g.name, bot: g.bot }); + (g.bot ? bots : greet).push(g.name); + } + publishLedger(data); + return { greet, bots, unnamed: plan.unnamed }; +} + +/** What Hester should say next, given who she just wrote in and who is still unnamed. */ +function nextStep(greet: string[], bots: string[], _unnamed: boolean, _everyone: string): string { + const greeting = greet.length + ? `${greet.join(' and ')} told the page ${greet.length === 1 ? 'their name' : 'their names'}, so do not ask: greet ${greet.length === 1 ? 'them' : 'each'} by name in one short, in-character sentence (for example "Ah, ${greet[0]}, we've been expecting you") and they are already in the ledger. ` + : ''; + const mute = bots.length ? `${bots.join(' and ')} cannot speak: greet ${bots.length === 1 ? 'them' : 'each'} warmly too ("and your quiet friend, ${bots[0]}"). ` : ''; + return `${greeting}${mute}Another traveller at the door gave no name and you can hear them now: ask them for their first name.`; +} + +const switchListener = (session: voice.AgentSession, identity: string | null) => (session as any)._roomIO?.setParticipant(identity); +const listening_to = (session: voice.AgentSession): string | undefined => (session as any)._roomIO?.linkedParticipant?.identity; + +/** What the page shows, published as attributes on the agent's own participant. */ +const publish = (ctx: JobContext, attributes: Record) => ctx.room.localParticipant?.setAttributes(attributes).catch(() => undefined); + +/** + * Publishes the ledger (identity to name, humans only) as `story.ledger` on the agent's participant, so the page can fill a name field + * with what Hester wrote, and gives each ledger name to its participant as the display name (people list, transcript, chronicle). + */ +const named_here = new Set(); +function publishLedger(data: StoryData) { + const ledger: Record = {}; + for (const p of data.players) if (!p.bot && !p.placeholder) ledger[p.identity] = p.name; + publish(data.ctx, { 'story.ledger': JSON.stringify(ledger) }); + for (const [identity, name] of Object.entries(ledger)) { + const here = data.ctx.room.remoteParticipants.get(identity); + const key = `${data.ctx.room.name}/${identity}/${name}`; + if (!here || here.name === name || named_here.has(key)) continue; + named_here.add(key); + room_client ??= new RoomServiceClient((process.env.LIVEKIT_URL || '').replace(/^ws/, 'http'), process.env.LIVEKIT_API_KEY, process.env.LIVEKIT_API_SECRET); + room_client.updateParticipant(data.ctx.room.name!, identity, { name }).catch((error: any) => console.log('could not set the display name:', error?.message ?? error)); + } +} + +/** Saves the story state in the room's metadata (small JSON), so a new agent can pick the story up. Debounced; failures are only logged. */ +let room_client: RoomServiceClient | undefined; +let save_timer: ReturnType | undefined; +function saveState(data: StoryData, ended = false) { + if (save_timer) clearTimeout(save_timer); + save_timer = setTimeout(async () => { + try { + room_client ??= new RoomServiceClient((process.env.LIVEKIT_URL || '').replace(/^ws/, 'http'), process.env.LIVEKIT_API_KEY, process.env.LIVEKIT_API_SECRET); + const state = buildState({ scene_index: data.scene_index, players: data.players, summary: data.summary, ended, world: data.world }); + await room_client.updateRoomMetadata(data.ctx.room.name!, encodeState(state)); + console.log(`story state saved: scene ${state.scene_index}, ${state.summary.length} summary lines`); + } catch (error: any) { + console.log('story state not saved:', error?.message ?? error); + } + }, 800); +} + +/** Hester announces she is fetching Old Bram, in her own voice, then the table passes to him. Code, not a model call. */ +async function fetchBram(session: voice.AgentSession, greet: string[], bots: string[]) { + const data = session.userData; + if (data.handed_off) return; + data.handed_off = true; + data.handoff_pending = false; + // Anyone who came in while Hester was talking (a bot, or a player who typed a name) is in the story too + const late = registerKnown(data); + const line = fetchLine([...greet, ...late.greet], [...bots, ...late.bots], data.players.length % 2); + await session.say(line, { allowInterruptions: false }).waitForPlayout(); + session.updateAgent(Bram.build(data.players)); +} + +const itemLabelFor = (raw: string) => { const id = normalizeItem(raw); return id && id !== 'chest' ? itemById(id)?.label : undefined; }; + +/** The satchel, as item ids on the agent's participant: the page lists it. */ +const publishSatchel = (data: StoryData) => publish(data.ctx, { 'story.satchel': satchelAttribute(data.world) }); + +/** The place the party is in: its id (for Pixel) and name (for the page). The turn is cleared until Bram has spoken. */ +const publishPlace = (data: StoryData) => { + const place = PLACES[data.world.location]; + return publish(data.ctx, { 'story.scene': place.id, 'story.place': place.name, 'story.turn': '', 'story.turn_name': '' }); +}; + +/** Pixel acts: a new sequence number with the gesture to send. Nothing waits for it and it holds no turn: the line goes into the transcript. */ +const pixelAct = (data: StoryData, line: string) => { + data.pixel_seq += 1; + console.log(`pixel gesture ${data.pixel_seq}: ${line}`); + return publish(data.ctx, { 'story.pixel_line': line, 'story.pixel_seq': String(data.pixel_seq) }); +}; + +/** Asks the app to have this soundtrack playing in the room: it starts it, keeps one that is playing, or restarts one that has ended. */ +async function ensureSoundtrack(data: StoryData, soundtrack: string): Promise { + try { + const response = await fetch(`${APP_URL}/api/scene`, { method: 'POST', headers: APP_HEADERS, body: JSON.stringify({ room: data.ctx.room.name, scene: soundtrack }), signal: AbortSignal.timeout(15000) }); + if (!response.ok) console.log(`soundtrack ${soundtrack}: the app answered ${response.status} ${(await response.text().catch(() => '')).slice(0, 120)}`); + return response.ok; + } catch (error: any) { + console.log(`soundtrack ${soundtrack}: could not reach the app: ${error?.message ?? error}`); + return false; + } +} + +/** + * The party is at (a new) place: counts, saved story, attributes, and the soundtrack. Returns what to tell Bram about the music, and only + * says there is music when the app has a soundtrack playing. A place that shares the playing soundtrack still asks the app, which + * restarts it if its file (180 s) has ended; Bram isn't told, nothing changed. + */ +async function arrive(data: StoryData): Promise { + onSceneStart(data, data.world.location); + data.last_scene_at = Date.now(); + saveState(data); + publishPlace(data); + publishSatchel(data); + const place = PLACES[data.world.location]; + if (place.soundtrack === data.soundtrack) { + ensureSoundtrack(data, place.soundtrack).then((ok) => { if (!ok) data.soundtrack = undefined; }); + return undefined; + } + const ok = await ensureSoundtrack(data, place.soundtrack); + // A soundtrack that could not start is tried again on the next arrival + data.soundtrack = ok ? place.soundtrack : undefined; + return ok ? 'with its soundtrack' : 'without music'; +} + +/** + * One player input (a spoken answer or Pixel's gesture): a small separate model call reads it into moves, takes, uses and gives, and the + * code validates and applies them. Returns the note Bram narrates from. Any failure of the call counts as no actions. + */ +async function resolveTurn(data: StoryData, words: string, from_bot = false): Promise { + let actions = noActions(); + const pixel = data.players.find((p) => p.bot); + try { + actions = parseActions(await askShort(actionPrompt(data.world, words, !!pixel), 6000, 160)); + } catch (error: any) { + console.log(`resolver failed (${error?.message ?? error}): treated as no actions`); + } + console.log(`resolver at ${data.world.location}: "${words.trim().slice(0, 80)}" -> ${JSON.stringify(actions)}`); + // The destination the player names outweighs the model's guess (and words like "door"): the exit that leads there, or a refusal when there is none + if (!from_bot) { + const dest = matchDestination(data.world, words); + if (dest?.exit && actions.move !== dest.exit.id) { console.log(`destination named: ${dest.exit.id} (the resolver said ${actions.move})`); actions.move = dest.exit.id; actions.blocked = null; } + else if (dest?.destination && !dest.exit) { console.log(`destination named with no way from here: ${dest.destination.name}`); actions.move = null; actions.blocked = dest.destination.name; } + } + // Lighting is decided on the player's words too: a cut-off or questioning turn ("can we now light the lighthouse?") still lights it where it can be lit + if (!from_bot && addLightingFromWords(data.world, words, actions)) console.log('lighting requested in the player\'s words: the resolver missed it'); + const to_pixel = !!pixel && !from_bot && (actions.addressed === 'pixel' || addressesPixel(words)); + // "Give Pixel the map": if the resolver missed an obvious give, the words still name the item + if (to_pixel && !actions.give.length && !actions.take.length && /\b(give|hand|pass|offer|toss|lend)\b/i.test(words)) { + const named = itemNamed(words); + if (named) actions.give.push({ item: named, to: 'pixel' }); + } + const result = applyActions(data.world, actions); + // A player spoke to Pixel (the resolver says so, or the name is in the words; Pixel's own gestures never count): it answers next turn + const extra: string[] = []; + if (to_pixel) { + const gave = actions.give.find((g) => /pix/i.test(g.to)); + const gave_item = gave ? itemLabelFor(gave.item) : undefined; + console.log(`pixel addressed: "${words.trim().slice(0, 80)}"${gave_item ? ` (gave ${gave_item})` : ''}`); + // Pixel answers at once with a gesture that responds to what was asked; it holds no turn and nothing waits for it + pixelAct(data, respondLine(data.world, gave_item)); + extra.push(`The player spoke to Pixel, the mute traveller. Acknowledge it in a sentence by describing Pixel noticing and reacting (a tilt of the head, a look), and never speak for Pixel or say what Pixel thinks: Pixel answers with a gesture of its own.`); + } + if (data.pixel_did) { + extra.push(`Pixel, the mute traveller, just did this: ${data.pixel_did.replace(/\*/g, '')} Weave it into your reply in one clause if it fits, and never speak for Pixel.`); + data.pixel_did = undefined; + } + if (result.blocked_move) extra.push(`The party's move was blocked, so nothing changed. Reply with one plain sentence only, naming where they can go from here: ${exitsByDestination(data.world)}. Do not describe the room again.`); + if (data.arrivals.length) { + extra.push(`${data.arrivals.join(' and ')} just joined the party: acknowledge the new arrival in a few words.`); + data.arrivals = []; + } + if (result.outcomes.length) console.log(`resolved: ${result.outcomes.join(' | ')}`); + let music: string | undefined; + if (result.moved) { + music = await arrive(data); + // On arriving somewhere new Pixel may react once (when it has a fitting line); Bram weaves it into his next reply + if (pixel && !to_pixel) { + const choice = chooseGesture(data.world, data.pixel_cooldown, data.turn_no); + if (choice.line) { pixelAct(data, choice.line); data.pixel_did = choice.line; } else console.log(`pixel stays quiet on arriving: ${choice.reason}`); + } + } + else if (result.took.length || result.opened || result.lit) { + publishSatchel(data); + saveState(data, endTriggered(result)); + } + if (endTriggered(result)) { + // The Lantern is lit at the lighthouse: the story ends once Bram's closing has played out + data.ending = true; + data.end_watcher?.arm(); + console.log(`the Lantern is lit: ending the story at ${new Date().toISOString()}`); + return closingNote(result.outcomes); + } + return placeNote(data.world, { full: result.moved, described: data.described, replies: data.replies_in_scene, outcomes: result.outcomes, music, arriving: result.moved, extra }); +} + +class Hester extends voice.Agent { + /** + * Opens the evening. Called once the room is connected and the first guest is at the door, because + * who is there, and whether they gave a name, decides what Hester says first. + */ + async open(session: voice.AgentSession) { + const data = session.userData; + const { greet, bots, unnamed } = registerKnown(data); + const first_human = unnamed[0] ?? data.players.find((p) => !p.bot)?.identity; + if (first_human) switchListener(session, first_human); + // Everyone at the door already has a name (typed on the page, or a bot): greet them and fetch Bram, with no model call + if (!unnamed.length) return fetchBram(session, greet, bots); + const intro = 'You are standing at the door of the inn, shaking the rain off your apron as travellers come in. '; + const known = greet.length || bots.length; + session.generateReply({ + instructions: known + ? `${intro}${nextStep(greet, bots, true, '')}` + : `${intro}Greet them in one short sentence, say it is a wild night and the ledger is open, and ask the traveller you can hear for their first name.`, + }); + } + + static build() { + return new Hester({ + instructions: `You are Hester Pennywhistle, innkeeper of the Drowned Bell, a crooked old inn on the shore of the Hollow Mere. You are brisk, warm and a little nosy, with a dry sense of humour, and you call everyone "love" or "dear". You are a fictional character in a spoken adventure. ${BREVITY} Speak plainly: at most one "love" or "dear" per reply, and no riddles. +Travellers who come in out of the storm must sign your ledger. A traveller who already gave their name at the door is written in for you: never ask for it and never call write_in_ledger for them. You can hear only one traveller at a time: ask the one you can hear for their first name. When you hear it, call write_in_ledger with it as the whole of your reply, with no words before it, then greet them by name in one short sentence once it returns. Never write or say a tool name or function call. Never mention fetching Old Bram: that is done for you.`, + tts: new inference.TTS({ model: HESTER_VOICE as any }), + // A player talking over her must not cut her off + allowInterruptions: false, + tools: { + write_in_ledger: llm.tool({ + description: 'Write the first name of the traveller you can hear in the inn ledger.', + parameters: z.object({ name: z.string().describe('The traveller\'s first name') }), + execute: async ({ name }, { ctx }: llm.ToolOptions) => { + const data = ctx.userData; + const { players } = data; + const session = ctx.session as voice.AgentSession; + // Only a plausible first name goes in the ledger: not "I", "the" or a sentence + if (!/^\p{L}[\p{L}'-]{1,19}$/u.test(name.trim()) || ['the', 'my', 'me', 'and', 'light', 'home', 'way'].includes(name.trim().toLowerCase())) return `That did not sound like a first name. Ask the traveller again, in your own words, for just their first name.`; + const identity = listening_to(session); + if (identity && !players.some((p) => p.identity === identity)) { players.push({ identity, name, bot: false }); publishLedger(data); } + // Anyone who came in with a name on the page, and any bot, goes in the ledger without being asked + const { greet, bots, unnamed } = registerKnown(data); + if (unnamed.length) { + switchListener(session, unnamed[0]); + return `${name} is in the ledger. ${nextStep(greet, bots, true, '')}`; + } + const first = players.find((p) => !p.bot); + if (first) switchListener(session, first.identity); + // Everyone is in: once this reply has been spoken, the code (not the model) fetches Old Bram + data.handoff_pending = true; + data.pending_bots = bots; + return `${name} is in the ledger. Greet ${name} by name in one short sentence. Say nothing about fetching anyone: that is done for you.`; + }, + }), + }, + }); + } +} + +class Bram extends voice.Agent { + /** Set when this Bram is picking up a story another agent left: he recaps instead of starting the first scene. */ + resume_state: StoryState | undefined; + + async onEnter() { + publish(this.session.userData.ctx, { 'story.character': 'Old Bram Tallow, storyteller' }); + this.session.userData.bram = this; + if (this.resume_state) { + console.log(`resuming the story at scene ${this.resume_state.scene_index} with a recap`); + this.session.generateReply({ instructions: recapInstructions(this.resume_state, this.session.userData.players), toolChoice: 'none' }); + return; + } + // The story starts: the party is in its first place, and the code tells Bram what is there + const data = this.session.userData; + arrive(data).then((music) => { + const note = placeNote(data.world, { full: true, music, arriving: true }); + this.session.generateReply({ + instructions: `You have just come in from the fire at Hester's call. Introduce yourself in one plain sentence as Old Bram, retired keeper of the Hollow Light, greet the travellers by name once, state the goal plainly in one sentence (${GOAL_LINE}), then describe where the party is. Do not call any tool. ${note}`, + toolChoice: 'none', + }); + }); + } + + /** + * Runs when a player has finished speaking, before Bram replies. The input is counted here (a real player input), and a system + * note says where the scene stands, so the reply follows the story's pacing. + */ + async onUserTurnCompleted(chat_ctx: llm.ChatContext, new_message: llm.ChatMessage): Promise { + const data = this.session.userData; + if (!data.handed_off || data.ending || !new_message.textContent?.trim()) return; + onPlayerInput(data); + data.watchdog?.arm(); + console.log(`player input counted: inputs=${data.inputs}`); + data.summary = addSummaryLine(data.summary, data.players.find((p) => p.identity === listening_to(this.session))?.name ?? 'Player', new_message.textContent); + saveState(data); + // A small separate model call reads the words into actions; the code applies them and tells Bram what happened + const words = new_message.textContent; + const speaker = data.players.find((p) => p.identity === listening_to(this.session)); + // A player who gives or corrects their name ("I'm Snaggle"): the ledger follows, and Bram acknowledges it + let name_note = ''; + const given = parseNameCorrection(words); + if (speaker && !speaker.bot && given && given.toLowerCase() !== speaker.name.toLowerCase()) { + console.log(`name corrected: ${speaker.name} -> ${given}`); + speaker.name = given; + speaker.placeholder = false; + publishLedger(data); + saveState(data); + name_note = ` The player has just told you their name is ${given}: acknowledge it in a few words and carry on.`; + } + data.last_speaker_name = speaker?.name; + const note = await resolveTurn(data, words); + chat_ctx.addMessage({ role: 'system', content: `${note}${name_note}` }); + } + + static build(players: Player[], resume?: StoryState) { + const bram = Bram.make(players); + bram.resume_state = resume; + return bram; + } + + private static make(players: Player[]) { + return new Bram({ + instructions: bramInstructions(players), + tts: new inference.TTS({ model: BRAM_VOICE as any }), + allowInterruptions: false, + }); + } +} + +export default defineAgent({ + entry: async (ctx: JobContext) => { + const session = new voice.AgentSession({ + stt: new inference.STT({ model: 'deepgram/nova-3', language: 'en' }), + llm: makeLlm(), + // Bram has two tools and a model that chains tool calls gets cut off: allow one step, and filter tool names from speech as a backstop + maxToolSteps: 2, + turnHandling: { + // The local turn-detector model stalled under load (a final transcript, then silence), and our scene note changes the chat + // context every turn so a preemptive reply is always thrown away. End turns on VAD silence (at most 3 s) and generate after the turn. + turnDetection: 'vad', + endpointing: { minDelay: 700, maxDelay: 3000 }, + preemptiveGeneration: { enabled: false }, + }, + ttsTextTransforms: ['filter_markdown', 'filter_emoji', speechFilter((what) => console.log(`speech filter removed a tool name from: ${what.slice(0, 120)}`))], + userData: { ctx, players: [], scene_index: 0, last_scene_at: 0, inputs: 0, input_since_call: false, last_reply: '', rotation: -1, end_watcher: undefined, bram: undefined, watchdog: undefined, ending: false, handoff_pending: false, pending_bots: [], handed_off: false, summary: [], resumed: false, replies_in_scene: 0, described: [], world: worldAt(process.env.STORY_START, process.env.STORY_ITEMS), soundtrack: undefined, pixel_cooldown: new Map(), turn_no: 0, pixel_seq: 0, pixel_did: undefined, arrivals: [], last_speaker_name: undefined }, + }); + const job_ctx = ctx; + session.userData.end_watcher = createEndWatcher(() => { + // The closing has played out and the pause has passed: mark the story ended, stop the soundtrack, leave + console.log(`story ended at ${new Date().toISOString()}: closing played out, pause done`); + publish(job_ctx, { 'story.state': 'ended', 'story.turn': '', 'story.turn_name': '' }); + fetch(`${APP_URL}/api/scene/end`, { method: 'POST', headers: APP_HEADERS, body: JSON.stringify({ room: job_ctx.room.name }), signal: AbortSignal.timeout(10000) }) + .catch(() => undefined) + .finally(() => setTimeout(() => job_ctx.shutdown('the story is over'), 3000)); + }); + session.on(voice.AgentSessionEventTypes.AgentStateChanged, (e: any) => session.userData.end_watcher?.onAgentState(e.oldState, e.newState)); + // Who is still in the room: a player who left never gets the turn + const here = (p: Player) => ctx.room.remoteParticipants.has(p.identity); + // The in-character "say that again" line, with the turn handed back to the player + const say_again = (why: string) => { + const data = session.userData; + if (data.ending) { + // The story is over but Bram's closing never played (a hung reply): speak a short closing, and finish the story anyway + console.log(`watchdog (${why}): the closing never played: saying a short closing and finishing the story`); + session.interrupt(); + session.say(CLOSING_LINE, { allowInterruptions: false }); + data.end_watcher?.arm(); + setTimeout(() => data.end_watcher?.force(), 25000).unref(); + return; + } + const player = (data.players[data.rotation] && !data.players[data.rotation].bot && here(data.players[data.rotation]) ? data.players[data.rotation] : undefined) ?? data.players.find((p) => !p.bot && here(p)); + console.log(`watchdog (${why}): giving the turn back to ${player?.name ?? 'the player'} with the say-that-again line`); + session.interrupt(); + session.say(stallLine(player?.name), { allowInterruptions: false }); + if (player) { + // The turn stays with this player when the line has been spoken, whoever Bram's last reply named + data.rotation = data.players.indexOf(player); + data.hold_turn = true; + switchListener(session, player.identity); + publish(data.ctx, { 'story.turn': player.identity, 'story.turn_name': player.name, 'story.turn_seq': String(data.inputs + data.scene_index * 100 + data.rotation + 50) }); + } + }; + // If a model request hangs after the turn ended, Bram says one short line and the turn goes back to the player + session.userData.watchdog = createLlmWatchdog(() => say_again('no reply 20 s after the turn ended')); + // If a final transcript arrives and the turn never ends (the stall seen under load), force the turn to end after 15 s; if that + // produces nothing either, say the line + const recovery = createTurnRecovery({ + commit: () => { console.log('watchdog (turn never ended 15 s after a final transcript): committing the user turn'); session.commitUserTurn(); }, + say_again: () => say_again('committing the turn did not start a reply'), + }); + session.on(voice.AgentSessionEventTypes.UserInputTranscribed, (e: any) => { if (e.isFinal && String(e.transcript || '').trim() && !session.userData.ending) recovery.onFinalTranscript(); }); + session.on(voice.AgentSessionEventTypes.AgentStateChanged, (e: any) => { if (e.newState === 'thinking' || e.newState === 'speaking') recovery.onProgress(); }); + // Progress: Bram started speaking, so the request is not hung. A tool that ran owes a follow-up reply, so the watchdog starts again + session.on(voice.AgentSessionEventTypes.AgentStateChanged, (e: any) => { if (e.newState === 'speaking') session.userData.watchdog?.progress(); }); + session.on(voice.AgentSessionEventTypes.FunctionToolsExecuted, () => session.userData.watchdog?.arm()); + // Once Hester has finished the sentence that follows the last name in the ledger, she fetches Old Bram + session.on(voice.AgentSessionEventTypes.AgentStateChanged, (e: any) => { + const data = session.userData; + if (shouldFetchBram(e.oldState, e.newState, data.handoff_pending, data.handed_off)) fetchBram(session, [], data.pending_bots).catch((error) => console.log('handoff error:', error)); + }); + session.on(voice.AgentSessionEventTypes.Error, (e: any) => console.log('agent error:', e.error?.message ?? e)); + session.on(voice.AgentSessionEventTypes.ConversationItemAdded, (e: any) => { + const item = e.item; + if (!item?.role || !item.textContent) return; + console.log(`${item.role}: ${item.textContent}`); + const data = session.userData; + if (!data.handed_off || data.ending) return; + // Player inputs are counted in Bram's onUserTurnCompleted. Here only Bram's own reply is kept, to see who he named. + if (item.role === 'assistant') { + onBramReply(data, item.textContent); + if (usesName(item.textContent, data.last_speaker_name)) console.log(`name check: the reply used the speaker's name "${data.last_speaker_name}" (${data.players.filter((p) => !p.bot).length} human player(s))`); + data.summary = addSummaryLine(data.summary, 'Bram', item.textContent); + saveState(data); + } + }); + // When Bram has finished speaking, code (not a model tool) gives the next turn: the player he named, or the next in rotation + session.on(voice.AgentSessionEventTypes.AgentStateChanged, (e: any) => { + const data = session.userData; + if (e.oldState !== 'speaking' || e.newState !== 'listening' || !data.handed_off || data.ending || !data.bram || data.scene_index === 0) return; + // Humans only: Pixel never holds the turn + const next = onPlayout(data, data.players, here); + if (!next) return; + data.turn_no += 1; + const index = data.rotation; + // Text input is accepted only from the participant being listened to, so link whoever's turn it is + switchListener(session, next.identity); + publish(data.ctx, { 'story.turn': next.identity, 'story.turn_name': next.name, 'story.turn_seq': String(data.turn_no * 1000 + data.inputs * 10 + index) }); + console.log(`turn given to ${next.name} after playout (inputs=${data.inputs})`); + }); + + // A player who leaves must not end the story for the others: listen to someone who is still here, give the turn on if it was theirs, + // and take them out of Bram's roster so he doesn't address them + ctx.room.on('participantDisconnected', (p: RemoteParticipant) => { + const data = session.userData; + const had_turn = ctx.room.localParticipant?.attributes?.['story.turn'] === p.identity; + if (listening_to(session) === p.identity || had_turn) { + const next = data.players.find((x) => !x.bot && x.identity !== p.identity && here(x)) ?? humans(ctx)[0]; + switchListener(session, next ? next.identity : null); + if (had_turn && next && data.handed_off && !data.ending) { + const name = 'name' in next && next.name ? next.name : next.identity; + publish(data.ctx, { 'story.turn': next.identity, 'story.turn_name': String(name), 'story.turn_seq': String(data.turn_no * 1000 + data.inputs * 10 + 500) }); + console.log(`${p.name || p.identity} left with the turn: it goes to ${name}`); + } + } + if (data.handed_off && !is_bot(p)) { + console.log(`${p.name || p.identity} left the party`); + data.bram?.updateInstructions(bramInstructions(data.players.filter(here))).catch(() => undefined); + } + }); + + // Hard rule: nothing waits on Pixel. If the listener is ever a bot for more than about 5 s, it goes back to a human and the skip is logged + let bot_since = 0; + setInterval(() => { + const who = listening_to(session); + if (!who || !who.startsWith('bot-')) { bot_since = 0; return; } + bot_since ||= Date.now(); + if (Date.now() - bot_since < 5000) return; + const human = session.userData.players.find((p) => !p.bot) ?? humans(ctx).map((p) => ({ identity: p.identity, name: p.name }))[0]; + console.log(`pixel held the listener for 5 s: skipping to ${human?.name ?? 'the next human'}`); + if (human) switchListener(session, human.identity); + bot_since = 0; + }, 1000).unref(); + + // A traveller who joins after the story began (Pixel added mid-story, or a player with a name) joins the party: it was never in the + // ledger, so without this it would never get a turn. Bram's roster is updated and he acknowledges the arrival once. + ctx.room.on('participantConnected', (p: RemoteParticipant) => { + const data = session.userData; + if (!data.handed_off || !is_player(p) || data.players.some((x) => x.identity === p.identity)) return; + const bot = is_bot(p); + // A late joiner who gave no name still joins, as "Traveller": otherwise they would never be heard. They can say their name ("I'm Priya"). + const given = p.name && p.name !== p.identity ? p.name : bot ? botName(p.identity) : ''; + const taken = data.players.filter((x) => x.placeholder).length; + const name = given || (taken ? `Traveller ${taken + 1}` : 'Traveller'); + data.players.push({ identity: p.identity, name, bot, ...(given ? {} : { placeholder: true }) }); + data.arrivals.push(bot ? `${name}, a mute traveller,` : given ? name : 'a new traveller'); + console.log(`${name} joined the party after the story began`); + publishLedger(data); + saveState(data); + data.bram?.updateInstructions(bramInstructions(data.players.filter(here))).catch(() => undefined); + }); + + const hester = Hester.build(); + await session.start({ + agent: hester, + room: ctx.room, + // No session audio or trace recording: the recorder (ffmpeg, plus whole-session buffers) was holding most of the job's memory + record: false, + inputOptions: { + closeOnDisconnect: false, + // Chat text from the player being listened to: a mute player's gesture. It is a real player input, and Bram reacts to it as to a spoken answer. + textInputCallback: (sess, ev) => { + const data = session.userData; + // The story is over: typed input and gestures are ignored, so nothing starts a new reply over the ending + if (data.ending) return; + if (data.handed_off && !data.ending) { + onPlayerInput(data); + data.watchdog?.arm(); + console.log(`player gesture counted: inputs=${data.inputs}`); + data.summary = addSummaryLine(data.summary, data.players.find((p) => p.identity === listening_to(session))?.name ?? 'Player', ev.text); + saveState(data); + } + sess.interrupt(); + // A gesture is read into actions like a spoken answer (Pixel can point at an exit or an item), then Bram narrates from the note + const reply = (instructions: string | undefined) => sess.generateReply({ userInput: ev.text, instructions }); + if (data.handed_off && !data.ending) resolveTurn(data, ev.text, (listening_to(session) ?? '').startsWith('bot-')).then(reply, () => reply(undefined)); + else reply(undefined); + }, + }, + }); + await ctx.connect(); + // Two story agents in one room would run two stories at once: if another is already here, this one leaves + if ([...ctx.room.remoteParticipants.values()].some((p) => p.info.kind === ParticipantKind.AGENT)) { + console.log('another story agent is already in this room: leaving'); + ctx.shutdown('duplicate story agent'); + return; + } + // onEnter ran before the room connected, so publish Hester's attributes again now + await publish(ctx, { 'story.character': 'Hester Pennywhistle, innkeeper', 'story.state': 'playing', 'story.turn': '', 'story.turn_name': '' }); + publishSatchel(session.userData); + // Open once the first guest is at the door: whether they gave a name decides Hester's first words + await ctx.waitForParticipant(); + // A story another agent left (a dead job that LiveKit re-dispatched, or "Continue the story"): skip Hester and pick it up + const saved = decodeState(ctx.room.metadata); + if (shouldResume(saved)) { + const data = session.userData; + data.players = resumePlayers(saved.players, guests(ctx).map((g) => ({ identity: g.identity, name: g.name || '', bot: g.bot }))); + data.scene_index = saved.scene_index; + data.last_scene_at = Date.now(); + data.summary = saved.summary; + data.handed_off = true; + data.resumed = true; + data.world = saved.world; + data.soundtrack = PLACES[saved.world.location].soundtrack; + data.replies_in_scene = 0; + data.described = []; + data.location = saved.world.location; + const first = data.players.find((p) => !p.bot); + if (first) switchListener(session, first.identity); + publish(ctx, { 'story.scene': saved.world.location, 'story.place': PLACES[saved.world.location].name }); + console.log(`story state found in the room: resuming at scene ${saved.scene_index}`); + publishLedger(data); + publishSatchel(data); + session.updateAgent(Bram.build(data.players, saved)); + return; + } + await hester.open(session); + }, +}); + +console.log(describeLlm()); +cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url), agentName: AGENT_NAME })); diff --git a/livekit/voice-adventure/agent/src/names.ts b/livekit/voice-adventure/agent/src/names.ts new file mode 100644 index 0000000..c490592 --- /dev/null +++ b/livekit/voice-adventure/agent/src/names.ts @@ -0,0 +1,63 @@ +/** + * Who the innkeeper already knows. A player who typed a name on the page joins with it as the + * participant name, so Hester greets them by it and writes it in the ledger without asking. She + * asks only for players who joined without one: no name, or the placeholder `web-xxxx` identity. + * Silent bot players (identity `bot-...`) always have a known name. + */ + +export interface Guest { + identity: string; + name?: string | null; + bot: boolean; +} + +export interface LedgerPlan { + /** Guests Hester can greet by name and write in the ledger without asking. */ + named: Array<{ identity: string; name: string; bot: boolean }>; + /** Humans she still has to ask, in the order she meets them. */ + unnamed: string[]; +} + +/** A name worth greeting: not empty, not the identity, not a generic placeholder. */ +export function realName(name: string | null | undefined, identity: string): string | undefined { + const trimmed = (name ?? '').trim(); + if (!trimmed || trimmed === identity || /^web-[0-9a-f]+$/i.test(trimmed)) return undefined; + if (['player', 'guest', 'you'].includes(trimmed.toLowerCase())) return undefined; + return trimmed.slice(0, 24); +} + +/** The bot's name comes from its identity: `bot-pixel` is Pixel. */ +export const botName = (identity: string) => `${identity.slice(4, 5).toUpperCase()}${identity.slice(5)}`; + +/** Splits the guests who are not in the ledger yet into those she can greet by name and those she must ask. */ +export function planLedger(guests: Guest[], registered: Set): LedgerPlan { + const plan: LedgerPlan = { named: [], unnamed: [] }; + for (const guest of guests) { + if (registered.has(guest.identity)) continue; + const name = guest.bot ? realName(guest.name, guest.identity) ?? botName(guest.identity) : realName(guest.name, guest.identity); + if (name) plan.named.push({ identity: guest.identity, name, bot: guest.bot }); + else if (!guest.bot) plan.unnamed.push(guest.identity); + } + return plan; +} + +/** + * What Hester says when everyone is in the ledger and she goes to fetch Old Bram. It is spoken straight + * through text-to-speech, in her voice, with no model call: the handoff is code, so it cannot be skipped or + * leak a tool call into the speech, and the same words cost nothing. + */ +export function fetchLine(greet: string[], bots: string[], variant = 0): string { + const humans = greet.length === 0 ? '' : greet.length === 1 ? greet[0] : `${greet.slice(0, -1).join(', ')} and ${greet[greet.length - 1]}`; + const quiet = bots.length === 0 ? '' : ` and your quiet friend${bots.length > 1 ? 's' : ''}, ${bots.join(' and ')}`; + const welcome = humans ? `Ah, ${humans}, we've been expecting you${quiet}.` : quiet ? `And there's your quiet friend${bots.length > 1 ? 's' : ''}, ${bots.join(' and ')}.` : ''; + const fetch = [ + "Let me fetch Old Bram, love, he's been waiting all evening for a crowd.", + "Sit by the fire, dears, while I fetch Old Bram. He's been itching for a crowd all night.", + ][variant % 2]; + return `${welcome} ${fetch}`.trim(); +} + +/** Hester fetches Bram when everyone is in the ledger and she has just finished speaking (speaking to listening). */ +export function shouldFetchBram(old_state: string, new_state: string, pending: boolean, handed_off: boolean): boolean { + return pending && !handed_off && old_state === 'speaking' && new_state === 'listening'; +} diff --git a/livekit/voice-adventure/agent/src/pixel-lines.ts b/livekit/voice-adventure/agent/src/pixel-lines.ts new file mode 100644 index 0000000..bd5086b --- /dev/null +++ b/livekit/voice-adventure/agent/src/pixel-lines.ts @@ -0,0 +1,132 @@ +/** + * Pixel is a mute traveller: it never speaks, it gestures. The story agent picks the gesture line for Pixel's turn (so the line fits + * the place and what the party carries) and publishes it; Pixel sends it as a chat message after a short delay. The storyteller + * reacts to the gesture on his normal turn. + */ +import { itemsHere, type ItemId, type PlaceId, type World } from './world.ts'; + +/** A gesture line, and what must be true for it to make sense. A gesture never refers to something that is no longer so. */ +export interface GestureLine { + text: string; + /** Items the party must already carry. */ + needs?: ItemId[]; + /** Items that must still be lying in this place (so Pixel points at something that is there). */ + here?: ItemId[]; + /** Puzzle flags that must have this value (the chest is still shut, the Lantern is not yet lit). */ + flags?: { chest_open?: boolean; lantern_lit?: boolean }; +} + +const L = (text: string, o: Omit = {}): GestureLine => ({ text, ...o }); + +// Few lines, each one a small reaction to something that is really there. Pixel adds colour; it never carries the story. +export const SCENE_LINES: Record = { + tavern: [ + L('*Pixel taps the salt-stained map and points at a small drawing of a lantern.*', { here: ['map'] }), + L('*Pixel gives the lock of the small iron chest a puzzled tug.*', { flags: { chest_open: false } }), + L('*Pixel peers into the open chest and grins.*', { flags: { chest_open: true } }), + ], + forest: [ + L('*Pixel crouches, brushes the leaves aside and points at a trail of silver footprints.*'), + L('*Pixel points at the hollow oak and its small door.*'), + ], + oak: [ + L('*Pixel points at the small brass key on the shelf.*', { here: ['brass_key'] }), + L('*Pixel sniffs the resin-scented air and wrinkles its nose.*'), + ], + cave: [ + L('*Pixel points at the Lantern on the stone ledge.*', { here: ['lantern'] }), + L('*Pixel points at the rowboat on the dark pool.*'), + ], + lighthouse: [ + L('*Pixel looks up at the dark lamp, then out at the clearing storm.*', { flags: { lantern_lit: false } }), + L('*Pixel cups both hands around the Lantern and nods: nearly home.*', { needs: ['lantern'], flags: { lantern_lit: false } }), + ], +}; + +/** Lines that fit anywhere, with no item needs. */ +export const GENERIC_LINES: GestureLine[] = [ + L('*Pixel listens to the storm and pulls its collar up.*'), + L('*Pixel tilts its head at a faint sound in the distance.*'), + L('*Pixel points at the nearest way out, then at the others.*'), + L('*Pixel nods along and taps a foot.*'), +]; + +/** Pixel's answers when a player speaks to it: it responds to what was asked, never with words. */ +export const RESPONDING_LINES: GestureLine[] = [ + L('*Pixel tilts its head, considers, and nods slowly.*'), + L('*Pixel shrugs and spreads both hands, as if to say: not sure.*'), + L('*Pixel gives a firm thumbs up and a small grin.*'), +]; + +/** Things Pixel points at when it answers, by place: something real that is there. */ +export const POINTING_RESPONSES: Record = { + tavern: '*Pixel points at the north door, then at the storm outside, and raises an eyebrow.*', + forest: '*Pixel points at the hollow oak and its small door.*', + oak: '*Pixel points at the little door back out to the wood.*', + cave: '*Pixel points at the rowboat on the dark pool.*', + lighthouse: '*Pixel points up at the lamp room.*', +}; + +/** A line is not used again for this many turns. */ +export const COOLDOWN_TURNS = 6; + +export type GestureChoice = { line: string; reason?: undefined } | { line?: undefined; reason: 'no eligible line' | 'cooldown' }; + +/** + * Picks a gesture for Pixel's turn: a line for this place that makes sense for what the party carries and what still lies here (or + * one of the generic lines that fit anywhere), not used in the last COOLDOWN_TURNS turns. When none qualifies the reason says why + * (nothing eligible at all, or everything eligible is cooling down) and Pixel skips the turn. `cooldown` records the turn a line was used on. + */ +export function chooseGesture(world: World, cooldown: Map, turn_no: number, random: () => number = Math.random): GestureChoice { + const here = new Set(itemsHere(world).map((i) => i.id)); + const fits = [...SCENE_LINES[world.location], ...GENERIC_LINES].filter((line) => + (line.needs ?? []).every((id) => world.satchel.includes(id)) && (line.here ?? []).every((id) => here.has(id)) + && (line.flags?.chest_open === undefined || line.flags.chest_open === world.chest_open) + && (line.flags?.lantern_lit === undefined || line.flags.lantern_lit === world.lantern_lit)); + if (!fits.length) return { reason: 'no eligible line' }; + const eligible = fits.filter((line) => { + const last = cooldown.get(line.text); + return last === undefined || turn_no - last >= COOLDOWN_TURNS; + }); + if (!eligible.length) return { reason: 'cooldown' }; + const line = eligible[Math.floor(random() * eligible.length)].text; + cooldown.set(line, turn_no); + return { line }; +} + +export const pickGesture = (world: World, cooldown: Map, turn_no: number, random: () => number = Math.random): string | undefined => chooseGesture(world, cooldown, turn_no, random).line; + +/** Pixel's answer when addressed: handed an item, it takes it; otherwise a response, or a pointer at something here. */ +export function respondLine(world: World, gave_label: string | undefined, random: () => number = Math.random): string { + if (gave_label) return `*Pixel takes ${gave_label} with a small bow and tucks it away.*`; + const options = [...RESPONDING_LINES.map((l) => l.text), POINTING_RESPONSES[world.location]]; + return options[Math.floor(random() * options.length)]; +} + +/** What Pixel sees in the story agent's participant attributes. */ +export interface StoryAttributes { + state?: string; + /** A counter the agent bumps each time it wants Pixel to act, and the gesture for that moment. Pixel never holds a turn. */ + pixel_seq?: string; + line?: string; +} + +export const PIXEL_IDENTITY = 'bot-pixel'; + +export const readAttributes = (a: Record): StoryAttributes => ({ + state: a['story.state'], + pixel_seq: a['story.pixel_seq'], + line: a['story.pixel_line'], +}); + +/** + * Whether Pixel should send a gesture now: the agent published a new sequence number with a line. Pixel acts only on that. It does + * not wait for a turn and nothing waits for it: the gesture goes into the transcript, and the storyteller weaves it into a reply. + */ +export function shouldGesture(attrs: StoryAttributes, last_seq: string | undefined): 'gesture' | 'idle' { + if (!attrs.pixel_seq || !attrs.line) return 'idle'; + return attrs.pixel_seq === last_seq ? 'idle' : 'gesture'; +} + +/** Pixel waits one to three seconds before it gestures. */ +export const gestureDelayMs = (random: () => number = Math.random) => 1000 + Math.floor(random() * 2000); diff --git a/livekit/voice-adventure/agent/src/pixel.ts b/livekit/voice-adventure/agent/src/pixel.ts new file mode 100644 index 0000000..3594077 --- /dev/null +++ b/livekit/voice-adventure/agent/src/pixel.ts @@ -0,0 +1,61 @@ +/** + * Pixel: a silent, scripted player. The demo app starts this process when someone selects "Add a bot player". + * It joins the room as `bot-pixel` (name "Pixel"), publishes no audio or video, and when the storyteller asks for a + * gesture (a new `story.pixel_seq` with a `story.pixel_line` on the story agent's participant) it waits a moment and sends that line as a + * chat message on the `lk.chat` topic. The page shows it in the transcript. The agent does not receive it as input (an agent session + * takes text only from the participant it is linked to, and Pixel is never linked): the storyteller reacts through the agent's own + * Pixel notes, with no model call of Pixel's own. + * + * It is started with PIXEL_URL and PIXEL_TOKEN (a short-lived token the app minted: no key or secret here). + */ +import { ParticipantKind, Room, RoomEvent } from '@livekit/rtc-node'; +import { gestureDelayMs, readAttributes, shouldGesture } from './pixel-lines.ts'; + +const url = process.env.PIXEL_URL; +const token = process.env.PIXEL_TOKEN; +if (!url || !token) { + console.error('PIXEL_URL and PIXEL_TOKEN are required (the demo app sets them).'); + process.exit(1); +} + +const room = new Room(); +let last_seq: string | undefined; +let busy = false; + +process.on('unhandledRejection', (error) => console.error('Pixel error:', error)); +room.on(RoomEvent.Disconnected, () => process.exit(0)); +process.on('SIGTERM', () => room.disconnect().finally(() => process.exit(0))); + +await room.connect(url, token, { autoSubscribe: false, dynacast: false }); +console.log('Pixel joined', room.name); + +const story_agent = () => [...room.remoteParticipants.values()].find((p) => p.info.kind === ParticipantKind.AGENT); +let ended_at = 0; + +// The agent's attributes change a few times a second at most: polling them is simple and cheap +setInterval(async () => { + const agent = story_agent(); + if (!agent) return; + const attrs = readAttributes(agent.attributes); + if (attrs.state === 'ended') { + ended_at ||= Date.now(); + if (Date.now() - ended_at > 8000) await room.disconnect(); + return; + } + if (busy || shouldGesture(attrs, last_seq) !== 'gesture') return; + console.log('Pixel: the storyteller asked for a gesture (seq', attrs.pixel_seq + ')'); + busy = true; + last_seq = attrs.pixel_seq; + setTimeout(async () => { + // The story agent chose the line for this place and satchel + const line = attrs.line; + if (line) { + await room.localParticipant!.sendText(line, { topic: 'lk.chat' }); + console.log('Pixel:', line); + } + busy = false; + }, gestureDelayMs()); +}, 500); + +// Leave on our own after ten minutes, so a forgotten bot does not sit in a room +setTimeout(() => room.disconnect(), 10 * 60 * 1000).unref(); diff --git a/livekit/voice-adventure/agent/src/resume.ts b/livekit/voice-adventure/agent/src/resume.ts new file mode 100644 index 0000000..222a1f4 --- /dev/null +++ b/livekit/voice-adventure/agent/src/resume.ts @@ -0,0 +1,114 @@ +/** + * Story state kept in the LiveKit room's metadata, so a story survives its agent: when LiveKit re-dispatches a dead + * job, or someone presses "Continue the story", the new agent reads this and picks the story up where it stopped. + * Small JSON: where the party is, the satchel and the puzzle flags, who is in the ledger, and a few lines of running summary. + */ +import { PLACES, goalDone, itemById, placeNote, type ItemId, type PlaceId, type World } from './world.ts'; + +export interface SavedPlayer { + identity: string; + name: string; + bot: boolean; +} + +export interface StoryState { + v: 2; + /** Places entered so far (1 means the story has started). */ + scene_index: number; + players: SavedPlayer[]; + /** The last few exchanges, one short line each, oldest first. */ + summary: string[]; + ended: boolean; + /** Where the party is, what it carries, and the puzzle flags. */ + world: World; + saved_at: number; +} + +export const SUMMARY_LINES = 6; +const LINE_MAX = 160; +/** LiveKit allows far more (64 KB); this is the ceiling this demo keeps itself to. */ +export const STATE_MAX_CHARS = 4000; + +const clip = (text: string, max: number) => { + const flat = text.replace(/\s+/g, ' ').trim(); + return flat.length <= max ? flat : `${flat.slice(0, max - 1).trimEnd()}…`; +}; + +/** Adds one exchange to the running summary, keeping the most recent lines. */ +export function addSummaryLine(lines: readonly string[], speaker: string, text: string): string[] { + const line = clip(text, LINE_MAX); + if (!line) return [...lines]; + return [...lines, `${speaker}: ${line}`].slice(-SUMMARY_LINES); +} + +export function buildState(input: { scene_index: number; players: readonly SavedPlayer[]; summary: readonly string[]; ended?: boolean; world: World }, now = Date.now()): StoryState { + return { + v: 2, + scene_index: input.scene_index, + players: input.players.map((p) => ({ identity: p.identity, name: p.name, bot: p.bot })), + summary: [...input.summary], + ended: Boolean(input.ended), + world: { location: input.world.location, satchel: [...input.world.satchel], chest_open: input.world.chest_open, lantern_lit: input.world.lantern_lit }, + saved_at: now, + }; +} + +/** JSON for the room metadata. If it would be too long, the oldest summary lines go first. */ +export function encodeState(state: StoryState): string { + let current = state; + let json = JSON.stringify(current); + while (json.length > STATE_MAX_CHARS && current.summary.length > 0) { + current = { ...current, summary: current.summary.slice(1) }; + json = JSON.stringify(current); + } + return json; +} + +/** Reads room metadata; anything that is not this demo's current state (empty, other JSON, broken JSON, the older scene-based state) gives null. */ +export function decodeState(metadata: string | undefined | null): StoryState | null { + if (!metadata) return null; + try { + const raw = JSON.parse(metadata); + if (!raw || raw.v !== 2 || typeof raw.scene_index !== 'number' || !Array.isArray(raw.players) || !raw.world || !(raw.world.location in PLACES)) return null; + return { + v: 2, + scene_index: Math.max(0, Math.floor(raw.scene_index)), + players: raw.players.filter((p: any) => p && typeof p.identity === 'string' && typeof p.name === 'string').map((p: any) => ({ identity: p.identity, name: p.name, bot: Boolean(p.bot) })), + summary: Array.isArray(raw.summary) ? raw.summary.filter((c: unknown) => typeof c === 'string').slice(-SUMMARY_LINES) : [], + ended: Boolean(raw.ended), + world: { + location: raw.world.location as PlaceId, + satchel: (Array.isArray(raw.world.satchel) ? raw.world.satchel : []).filter((id: unknown): id is ItemId => typeof id === 'string' && !!itemById(id)), + chest_open: Boolean(raw.world.chest_open), + lantern_lit: Boolean(raw.world.lantern_lit), + }, + saved_at: typeof raw.saved_at === 'number' ? raw.saved_at : 0, + }; + } catch { + return null; + } +} + +/** A story is picked up again only when it was under way (a scene had started) and had not ended. */ +export const shouldResume = (state: StoryState | null): state is StoryState => Boolean(state && !state.ended && state.scene_index >= 1); + +/** + * Who is in the story after a resume: everyone now in the room with a name keeps their place; players from the saved ledger who have + * not come back are dropped, except that a saved human is kept when nobody currently in the room has a name (the page sent no name). + */ +export function resumePlayers(saved: readonly SavedPlayer[], here: readonly SavedPlayer[]): SavedPlayer[] { + const named = here.filter((g) => g.name); + if (named.length) return named.map((g) => ({ ...g })); + const humans = saved.filter((p) => !p.bot); + return (humans.length ? humans : saved).map((p) => ({ ...p })); +} + +/** What Old Bram does when he walks back in: a short recap in character, then the story carries on where it stopped. */ +export function recapInstructions(state: StoryState, players: readonly SavedPlayer[]): string { + const names = players.map((p) => p.name).join(' and '); + const recent = state.summary.length ? `\nWhat was said last:\n${state.summary.join('\n')}` : ''; + const note = placeNote(state.world, { full: false, described: [], replies: 1 }); + return `You have been away from the fire for a moment and you are back. The travellers are ${names || 'the players'}.${recent} +${note} +Do not call any tool. In one or two plain sentences, in character, say where the tale had got to ("Now, where were we?") and what is in front of the travellers. Do not repeat the earlier lines. Speak to the player as "you" and use no name. End on a short open line with no question.${goalDone(state.world) ? ' The quest is already complete.' : ''}`; +} diff --git a/livekit/voice-adventure/agent/src/story.ts b/livekit/voice-adventure/agent/src/story.ts new file mode 100644 index 0000000..0b39c1f --- /dev/null +++ b/livekit/voice-adventure/agent/src/story.ts @@ -0,0 +1,257 @@ +import { sightsOf, usedDetails, type PlaceId, type World } from './world.ts'; +import { ReadableStream, TransformStream, type TransformStreamDefaultController } from 'node:stream/web'; + +/** + * Waits for the end of the story's last speech before it finishes. `armed` is set when end_story is called. Whenever the + * agent stops speaking, a pause starts; if the agent starts speaking or thinking again in that time (a farewell after the + * tool result, for example) the pause is cancelled. When the pause runs out, `finish` is called once. + */ +export function createEndWatcher(finish: () => void, pause_ms = 2000, timers = { set: setTimeout, clear: clearTimeout }) { + let armed = false; + let done = false; + let handle: ReturnType | undefined; + return { + arm() { armed = true; }, + /** The closing never played (a hung reply): finish anyway, once. */ + force() { if (done) return; done = true; timers.clear(handle); finish(); }, + get done() { return done; }, + onAgentState(_old: string, next: string) { + if (!armed || done) return; + if (next === 'listening' || next === 'idle') { + timers.clear(handle); + handle = timers.set(() => { if (!done) { done = true; finish(); } }, pause_ms); + } else timers.clear(handle); + }, + }; +} + +/** A short closing, spoken straight through text-to-speech when the story is over but Bram's own closing never played. */ +export const CLOSING_LINE = 'The Lantern burns, the Mere is still, and the Hollow Light shines again. Fare well, travellers, and thank you for the evening.'; + +/** After a mute player's turn the listener goes back to a player who can speak (the first one), so their answer is heard. */ +export const speakerAfterMute = (players: T[]): T | undefined => players.find((p) => !p.bot); + +// ---- Turns are code, not a model tool ---- + +export interface Addressable { + name: string; + identity: string; + bot: boolean; +} + +const escapeRegExp = (s: string) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + +/** The player Bram names last in his reply (he ends a reply by naming who answers next), if he names one. */ +export function addressedPlayer(text: string, players: T[]): T | undefined { + let best: { player: T; at: number } | undefined; + for (const player of players) { + const re = new RegExp(`(?= best.at) best = { player, at: m.index! }; + } + return best?.player; +} + +/** Who has the next turn: the player Bram named, or else the next one in the rotation. Returns the index into `players`. */ +export function nextSpeakerIndex(players: T[], last_index: number, reply: string): number { + if (!players.length) return -1; + const named = addressedPlayer(reply, players); + return named ? players.indexOf(named) : (last_index + 1) % players.length; +} + +// ---- A backstop so the model never speaks a tool name ---- + +export const TOOL_NAMES = ['next_scene', 'end_story', 'take_item', 'use_item', 'move_to', 'write_in_ledger', 'fetch_bram', 'give_turn']; +const SPOKEN_CALL = new RegExp(`(?:functions\\.)?(?:${TOOL_NAMES.join('|')})(?:\\s*\\([^)]*\\)?)?|functions\\.\\w*(?:\\s*\\([^)]*\\)?)?`, 'gi'); + +/** Removes tool calls and tool names from text that is about to be spoken. Returns the cleaned text and whether it removed anything. */ +export function cleanSpeech(text: string): { text: string; removed: boolean } { + const removed = new RegExp(SPOKEN_CALL.source, 'i').test(text); + return { text: removed ? text.replace(SPOKEN_CALL, '').replace(/ {2,}/g, ' ') : text, removed }; +} + +/** + * A stream transform for the session's `ttsTextTransforms`. Text arrives in small pieces ("next_" then "scene"), so it + * holds back the end of what it has seen until a word boundary or the end of the stream, and cleans what it releases. + */ +export function speechFilter(on_removed: (what: string) => void = () => undefined) { + return (input: ReadableStream): ReadableStream => { + let held = ''; + const release = (controller: TransformStreamDefaultController, all: boolean) => { + // Hold back from the last space, and from an open "functions." or tool-name-length tail, unless it is the end + const cut = all ? held.length : Math.max(held.lastIndexOf(' '), held.lastIndexOf('\n'), held.lastIndexOf('.') >= 0 && !/functions\.?\w*$/i.test(held) ? held.lastIndexOf('.') : -1) + 1; + if (cut <= 0) return; + const { text, removed } = cleanSpeech(held.slice(0, cut)); + if (removed) on_removed(held.slice(0, cut).trim()); + held = held.slice(cut); + if (text) controller.enqueue(text); + }; + return input.pipeThrough(new TransformStream({ + transform(chunk, controller) { held += chunk; release(controller, false); }, + flush(controller) { release(controller, true); }, + })); + }; +} + +// ---- The turn state machine ---- + +/** The fields of the story's state that turns and move-on guards depend on. */ +export interface TurnState { + scene_index: number; + /** Real player inputs in the current scene. */ + inputs: number; + /** A player has spoken or gestured since the last tool call. */ + input_since_call: boolean; + last_reply: string; + /** Index of the player who had the last turn. */ + rotation: number; + ending: boolean; + short_mode?: boolean; + /** Where the party is. */ + location?: PlaceId; + /** The state of the world: what can be seen is built from it. */ + world?: World; + /** Bram's replies since the scene began (the arrival description is the first), and the sights he has already used in them. */ + replies_in_scene?: number; + described?: string[]; + /** An item tool already ran for this player input: one per reply. */ + item_acted?: boolean; + /** A "say that again" line was spoken to the player who holds the turn: the next playout keeps the turn with them. */ + hold_turn?: boolean; +} + +/** A final transcript from the linked player, or Pixel's chat gesture. The only thing that counts as an exchange. */ +export function onPlayerInput(s: TurnState) { + s.inputs += 1; + s.item_acted = false; + s.input_since_call = true; +} + +export function onBramReply(s: TurnState, text: string) { + s.last_reply = text; + s.replies_in_scene = (s.replies_in_scene ?? 0) + 1; + // What Bram has now described is judged against what can be seen now, so a thing that changed (the chest, now open) counts as new + if (s.world) s.described = [...new Set([...(s.described ?? []), ...usedDetails(sightsOf(s.world), text)])]; +} + +/** + * Bram has finished speaking: who gets the next turn, among the human players only. The mute player is never in the rotation: nothing + * waits for it, and it acts only as an extra around a human turn (when addressed, or once on arriving somewhere). `here` says who is + * still in the room: a player who left is never given the turn. After a "say that again" line the turn stays with the player it was + * given back to (if they are still here), whoever Bram's last reply named. + */ +export function onPlayout(s: TurnState, players: T[], here: (player: T) => boolean = () => true): T | undefined { + if (s.ending || s.scene_index === 0) return undefined; + const holder = players[s.rotation]; + if (s.hold_turn) { + s.hold_turn = false; + if (holder && !holder.bot && here(holder)) return holder; + } + const humans = players.filter((p) => !p.bot && here(p)); + const pool = humans.length ? humans : players.filter((p) => !p.bot).length ? [] : players.filter(here); + if (!pool.length) return undefined; + const last = pool.indexOf(holder); + const index = nextSpeakerIndex(pool, last, s.last_reply); + if (index < 0) return undefined; + s.rotation = players.indexOf(pool[index]); + return pool[index]; +} + +/** The party arrives at a place: this place's own count of inputs and replies starts over. */ +export function onSceneStart(s: TurnState, location: PlaceId) { + s.scene_index += 1; + s.location = location; + s.inputs = 0; + s.input_since_call = false; + s.replies_in_scene = 0; + s.described = []; +} + +// ---- A watchdog for a model request that never answers ---- + +/** + * Armed when a player has finished and Bram owes a reply. Anything that shows progress (he starts speaking) clears it. If + * nothing happens for `ms` the stall callback runs once, so the player is not left waiting on a hung request. + */ +export function createLlmWatchdog(on_stall: () => void, ms = 20000, timers = { set: setTimeout, clear: clearTimeout }) { + let handle: ReturnType | undefined; + return { + arm() { + timers.clear(handle); + handle = timers.set(() => { handle = undefined; on_stall(); }, ms); + }, + progress() { + timers.clear(handle); + handle = undefined; + }, + get armed() { return handle !== undefined; }, + }; +} + +/** One short in-character line for when the storyteller lost the thread, spoken straight through text-to-speech. */ +export function stallLine(player_name: string | undefined, variant = 0): string { + const who = player_name ?? 'friend'; + return [ + `Ah, the tide took my words for a moment. Say that again for me, ${who}.`, + `Forgive an old keeper, ${who}, I lost the thread there. What was it you said?`, + ][variant % 2]; +} + + +// ---- What Bram is told: describe, don't direct ---- + +export const BREVITY = 'You speak aloud, so keep to two short sentences at a time, with no lists, no stage directions and no emoji.'; + +/** Bad lines, shown to Bram only as examples of what never to say. The prompt tests skip this block. */ +export const LEADING_BLOCK_START = '[never say lines like these]'; +export const LEADING_BLOCK_END = '[end of lines never to say]'; + + +/** The goal as Bram states it once when he opens: why the Lantern matters. */ +export const GOAL_LINE = 'my lighthouse went dark in the storm, and only the Mere\'s own flame, which the Lantern of Hollow Mere holds, will light its great lamp again, and that Lantern was lost under the Mere.'; + +/** Bram's standing instructions: who he is, how he speaks, how he describes and hands over. */ +export function bramInstructions(players: Array<{ name: string; bot: boolean }>): string { + const humans = players.filter((p) => !p.bot); + const roster = players.map((p) => (p.bot ? `${p.name} (a mute traveller who cannot speak: what ${p.name} does arrives as a message like "${p.name} taps the map.")` : p.name)).join(', '); + const mute = players.some((p) => p.bot) ? ' A mute traveller never decides anything: its gestures can show the way, but only a spoken decision from a player moves the group on.' : ''; + const names = humans.length > 1 + ? 'There is more than one human player: address the player who just spoke as "you", and use a name only when you need to say which of the players you mean.' + : 'There is one human player: after your greeting never use their name at all. Address them as "you".'; + return `You are Old Bram Tallow, a retired lighthouse keeper who tells stories at the Drowned Bell: warm, gravelly and kind. You are a fictional character telling "The Lantern of Hollow Mere" to these travellers and only these: ${roster}. ${BREVITY} +The goal, which you state plainly once when you open: ${GOAL_LINE} Say it as "my lighthouse". +Speak plainly, with at most one sea-worn phrase per reply, and none is fine. No riddles. +Describe, don't direct. Say what the players see, hear and notice, and where each thing lies. Never tell them what to do, never ask whether they would like to do something, and never put an object next to the action that solves it. Write "A small iron chest sits under the bench, locked." and stop there. +${LEADING_BLOCK_START} "Would you like to search the room to find something to open the chest?" "Why not follow the footprints?" "Maybe you could use the key on the door." ${LEADING_BLOCK_END} +Good lines describe only: "A small iron chest sits under the bench, locked." "Silver footprints lead off into the pines." "The stranger watches you over the rim of his mug." +Clues sit in the scene for the players to find. Reveal a clue only when a player investigates that thing. If a player says they are stuck or asks for a hint, give one gentle nudge about something to look at, never the solution. +Respond to what the players actually try, including the unexpected: say what happens and let consequences follow. Never invent items, doors, places or puzzles that the scene note does not give you, and never describe the party being anywhere but where the note says. +Describe a place in full only when you arrive in it. After that, never restate the setting (the weather, the fire, the map): answer what the player did, in one or two sentences, and mention a sight or sound only if it is new, has changed, or matters to what they just did. +Names. Speak to the player as "you": never talk about the player you are answering in the third person ("Snaggle is beside you now", "the stranger falls in behind Snaggle"). ${names} Never put a name at the start or the end of a reply ("Snaggle, the way is before you"). If a player tells you their name or corrects it ("I'm Snaggle"), acknowledge it in a few words and use it from then on only as the rules above allow. Use only the names of the travellers listed above. +End each reply on the description or on what happens, with no question and no name tacked on: the page already shows whose turn it is. Never point at an action. Then stop and wait: you never answer for the players and never continue until a player has spoken. Rotate between the players.${mute} Never ask two questions in one reply. +Each reply to a player is preceded by a system note: it says where the party is, what lies here, what is in the satchel, the ways out and what just happened. Follow it exactly and narrate what it says happened, plainly, as fact. You have no tools: never write or say a tool name or function call in your speech.`; +} + +/** + * Recovery for a user turn that never ends. A final transcript arms it; when the agent starts thinking or speaking, or the + * user turn completes, it is cleared. If nothing happens for `ms` the first stage forces the turn to end (`commit`) and waits + * once more; if that also produces nothing, the second stage says the in-character "say that again" line (`say_again`). + */ +export function createTurnRecovery(actions: { commit: () => void; say_again: () => void }, ms = 15000, timers = { set: setTimeout, clear: clearTimeout }) { + let stage = 0; + const watchdog = createLlmWatchdog(() => { + if (stage === 0) { + stage = 1; + actions.commit(); + watchdog.arm(); + } else { + stage = 0; + actions.say_again(); + } + }, ms, timers); + return { + onFinalTranscript() { stage = 0; watchdog.arm(); }, + onProgress() { stage = 0; watchdog.progress(); }, + get stage() { return stage; }, + }; +} + diff --git a/livekit/voice-adventure/agent/src/world.ts b/livekit/voice-adventure/agent/src/world.ts new file mode 100644 index 0000000..13ede87 --- /dev/null +++ b/livekit/voice-adventure/agent/src/world.ts @@ -0,0 +1,478 @@ +/** + * The world of "The Lantern of Hollow Mere", as code. The code decides what happens; Bram only narrates it. + * + * Places are joined by named exits in both directions: + * + * tavern (map, locked chest) <-north door-> forest <-oak door-> hollow oak (brass key) + * forest <-rope bridge / steps-> cave (the Lantern, a boat) -boat-> lighthouse + * lighthouse <-shore path-> tavern, lighthouse <-headland track-> forest + * + * Items stay where they are until taken. The party shares one satchel. The chest stays in the tavern: it opens with the brass key + * and holds flint and a wick. The quest is done when the Lantern is lit with them at the lighthouse. The items can be gathered in any + * order and meet at the lighthouse. + */ + +export type PlaceId = 'tavern' | 'forest' | 'oak' | 'cave' | 'lighthouse'; +export type ItemId = 'map' | 'brass_key' | 'lantern' | 'flint_and_wick'; + +export interface ExitDef { + /** What the resolver and the code call this way out. */ + id: string; + to: PlaceId; + /** How it is described, as part of the place. */ + text: string; +} + +export interface PlaceDef { + id: PlaceId; + /** Shown on the page. */ + name: string; + /** What players call it (lower case, as speech to text writes it): used to match a named destination. */ + aliases: string[]; + /** The soundtrack file (scene name) played here. Places that share one keep it playing. */ + soundtrack: 'tavern' | 'forest' | 'cave' | 'finale'; + place: string; + /** The fixed ambience of the place (weather, fire, trees, drips): never an item, never anything a player can change. */ + ambient: string[]; + exits: ExitDef[]; + /** Things to find, revealed only when a player investigates that thing: built from the world state (see cluesOf). */ +} + +export const PLACES: Record = { + tavern: { + id: 'tavern', + name: 'The Drowned Bell', + aliases: ['the drowned bell', 'drowned bell', 'the inn', 'the tavern', 'the bell', 'the pub'], + soundtrack: 'tavern', + place: 'the common room of the Drowned Bell on a stormy night, with a fire, a long table and a hooded stranger', + ambient: ['rain on the shutters', 'the fire popping', 'the hooded stranger watching from the long table'], + exits: [ + { id: 'north_door', to: 'forest', text: 'a north door leads out into the storm toward the Hollow Wood' }, + { id: 'shore_door', to: 'lighthouse', text: 'a back door opens onto a shore path that climbs to the lighthouse' }, + ], + }, + forest: { + id: 'forest', + name: 'The Hollow Wood', + aliases: ['the hollow wood', 'the wood', 'the woods', 'the forest', 'the trees'], + soundtrack: 'forest', + place: 'the Hollow Wood, a damp pine forest', + ambient: ['a rope bridge over a stream', 'a muddy path under the pines', 'silver footprints in the mud', 'a hollow oak with a small door in its trunk'], + exits: [ + { id: 'oak_door', to: 'oak', text: 'the small door in the hollow oak' }, + { id: 'rope_bridge', to: 'cave', text: 'the rope bridge and stone steps beside a waterfall lead down toward the Mere, following the dripping water' }, + { id: 'inn_path', to: 'tavern', text: 'the lit windows of the Drowned Bell show back down the path' }, + { id: 'headland_track', to: 'lighthouse', text: 'a headland track leads out toward the lighthouse' }, + ], + }, + oak: { + id: 'oak', + name: 'The Hollow Oak', + aliases: ['the hollow oak', 'the oak', 'the oak tree', 'the tree'], + soundtrack: 'forest', + place: 'inside the hollow oak, a cramped, dry hollow that smells of resin', + ambient: ['a root shelf along the wall', 'the storm muffled outside the little door'], + exits: [{ id: 'out', to: 'forest', text: 'the small door leads back out to the wood' }], + }, + cave: { + id: 'cave', + name: 'The Cave under the Mere', + aliases: ['the cave', 'the mere', 'the hollow mere', 'the cave under the mere', 'the pool'], + soundtrack: 'cave', + place: 'the cave under the Hollow Mere, dripping and dark', + ambient: ['a stone ledge above the water', 'drips from the ceiling', 'a carving of a boat crossing a pool on the wall', 'a small rowboat on the underground pool'], + exits: [ + { id: 'steps_up', to: 'forest', text: 'stone steps beside the waterfall lead back up to the wood' }, + { id: 'boat', to: 'lighthouse', text: 'rowing the boat across the pool leads out to the shore below the lighthouse' }, + ], + }, + lighthouse: { + id: 'lighthouse', + name: 'The Lighthouse', + aliases: ['the lighthouse', 'the light house', 'the lamp room', 'the tower'], + soundtrack: 'finale', + place: 'the lamp room of Old Bram\'s lighthouse at dawn', + ambient: ['the storm clearing outside', 'the stone walls streaked with salt', 'the Drowned Bell far below'], + exits: [ + { id: 'shore_path', to: 'tavern', text: 'a shore path leads down to the Drowned Bell' }, + { id: 'headland_track', to: 'forest', text: 'a headland track leads back to the Hollow Wood' }, + ], + }, +}; + +export interface ItemDef { + id: ItemId; + /** How Bram and the page name it. */ + label: string; + place: PlaceId; + aliases: string[]; +} + +export const ITEMS: readonly ItemDef[] = [ + { id: 'map', label: 'the salt-stained map', place: 'tavern', aliases: ['map', 'salt-stained map'] }, + { id: 'brass_key', label: 'the small brass key', place: 'oak', aliases: ['key', 'brass key', 'small brass key'] }, + { id: 'lantern', label: 'the Lantern of Hollow Mere', place: 'cave', aliases: ['lantern', 'lantern of hollow mere', 'lamp'] }, + { id: 'flint_and_wick', label: 'the flint and wick', place: 'tavern', aliases: ['flint', 'wick', 'flint and wick'] }, +]; + +export interface World { + location: PlaceId; + satchel: ItemId[]; + chest_open: boolean; + lantern_lit: boolean; +} + +export const newWorld = (): World => ({ location: 'tavern', satchel: [], chest_open: false, lantern_lit: false }); + +/** Test starts (STORY_START=): begin elsewhere with the map in the satchel. */ +export const worldAt = (place: string | undefined, items?: string): World => { + const w = newWorld(); + if (place && place in PLACES) { + w.location = place as PlaceId; + if (place !== 'tavern') w.satchel = ['map']; + } + // STORY_ITEMS=map,lantern puts those items in the satchel to begin with + for (const id of (items ?? '').split(',').map((s) => s.trim())) if (itemById(id) && !w.satchel.includes(id as ItemId)) w.satchel.push(id as ItemId); + return w; +}; + +/** The way out of this place, described by where it leads: for telling the players their real options. */ +export const exitsByDestination = (w: World): string => placeOf(w).exits.map((e) => `${PLACES[e.to].name} (${e.text})`).join('; '); + +const MOVE_WORDS = /\b(go|goes|going|head|heading|walk|walking|return|returning|back|enter|travel|get|run|leave|climb|row|follow|through|into|towards?|take us|take me|off to|out to)\b/i; + +/** + * Names a destination in the player's words ("go through the door into the Drowned Bell"): the exit from here that leads there, or the + * destination when there is no direct exit. The destination the player names outweighs words like "door" or "path". Only with a + * word of movement, so "look at the inn sign" does not move anyone. + */ +export function matchDestination(w: World, words: string): { exit?: ExitDef; destination?: PlaceDef } | undefined { + if (!MOVE_WORDS.test(words)) return undefined; + const text = words.toLowerCase(); + let best: { place: PlaceDef; at: number; len: number } | undefined; + for (const place of Object.values(PLACES)) { + if (place.id === w.location) continue; + for (const alias of place.aliases) { + const at = text.search(new RegExp(`\\b${alias.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`)); + if (at >= 0 && (!best || alias.length > best.len || (alias.length === best.len && at > best.at))) best = { place, at, len: alias.length }; + } + } + if (!best) return undefined; + const exit = placeOf(w).exits.find((e) => e.to === best!.place.id); + return exit ? { exit } : { destination: best.place }; +} + +/** How an item looks where it lies: written for the item, so a taken item is simply no longer described. */ +const LYING: Record = { + map: 'a salt-stained map on the table in front of the stranger', + brass_key: 'a small brass key on a root shelf along the wall', + lantern: 'the Lantern of Hollow Mere on a stone ledge, unlit', + flint_and_wick: 'flint and a wick lying inside the open chest', +}; + +/** + * What can be seen here right now, built from the world state: the fixed ambience, the items still lying here where they lie, the + * chest as it is (locked, or open with what is left inside), and the lamp as it is. Nothing in the static text depends on the state, + * so nothing here can be out of date. + */ +export function sightsOf(w: World): string[] { + const p = placeOf(w); + const out = [...p.ambient]; + for (const item of itemsHere(w)) if (item.id !== 'flint_and_wick') out.push(LYING[item.id]); + if (chestHere(w)) { + if (!w.chest_open) out.push('a small iron chest under the bench, locked'); + else out.push(w.satchel.includes('flint_and_wick') ? 'the small iron chest under the bench, open and empty' : `the small iron chest under the bench, open, with ${LYING.flint_and_wick.replace(' lying inside the open chest', '')} inside`); + } + if (w.location === 'lighthouse') out.push(w.lantern_lit ? 'the great lamp blazing, lit from the Lantern\'s flame' : 'the great lamp, dark'); + return out; +} + +/** Things to find, revealed only when a player investigates that thing. Each one goes when it stops being true. */ +export function cluesOf(w: World): string[] { + const out: string[] = []; + switch (w.location) { + case 'tavern': + out.push('the map has a lantern drawn near the Hollow Mere and a margin note about dripping water; the stranger knows the way and says so only if asked'); + if (!w.chest_open) out.push('the chest is locked and needs a key'); + break; + case 'forest': + out.push('the footprints are small and lead to the door in the oak'); + break; + case 'oak': + if (!w.satchel.includes('brass_key')) out.push('the brass key looks the right size for a small lock'); + break; + case 'cave': + out.push('the carving shows a boat crossing the pool toward a light'); + if (!w.satchel.includes('lantern')) out.push('the Lantern is cold and unlit'); + break; + case 'lighthouse': + if (!w.lantern_lit) out.push('the dark great lamp will take only the Lantern\'s flame, and the Lantern needs flint and a wick to wake it'); + break; + } + return out; +} + +/** What happens when the Lantern is lit: one beat. The Mere's flame is the only fire the great lamp takes, and the party keeps the Lantern. */ +export const LIT_OUTCOME = 'The flint strikes and the wick catches. The Lantern wakes with the Mere\'s own flame, and the great lamp catches from it and blazes. The Lantern stays lit in the party\'s hands: the quest is done.'; + +const LIGHT_REQUEST = /\b(?:re)?(?:light|kindle|ignite)\b[^.?!]{0,30}?\b(?:lantern|lamp|beacon|light|lighthouse)\b/i; +const LIGHT_REFUSAL = /\b(?:don'?t|do not|not|never|shouldn'?t|won'?t|no)\b[^.?!]{0,20}\b(?:re)?(?:light|kindle|ignite)\b/i; + +/** True when the player's words ask to light, kindle or relight the Lantern, the lamp, the beacon, the light or the lighthouse ("can we...", "let's...", "I want to..." included). */ +export const asksToLight = (words: string): boolean => LIGHT_REQUEST.test(words) && !LIGHT_REFUSAL.test(words); + +/** + * Lighting is decided on the player's words as well as the resolver's reading: at the lighthouse, with the Lantern and the flint and wick + * in the satchel and the Lantern not yet lit, any request to light it lights it, whatever the resolver made of a cut-off or questioning + * turn. Anywhere else this does nothing, so the usual refusals stand. Returns whether it added the use. + */ +export function addLightingFromWords(w: World, words: string, actions: Actions): boolean { + if (w.location !== 'lighthouse' || w.lantern_lit || !w.satchel.includes('lantern') || !w.satchel.includes('flint_and_wick')) return false; + if (!asksToLight(words)) return false; + const already = actions.use.some((u) => { const a = normalizeItem(u.item); const b = normalizeItem(u.target); return (a === 'lantern' && b === 'flint_and_wick') || (a === 'flint_and_wick' && b === 'lantern'); }); + if (!already) actions.use.push({ item: 'lantern', target: 'flint_and_wick' }); + return !already; +} + +export const goalDone = (w: World) => w.lantern_lit; +export const itemById = (id: string): ItemDef | undefined => ITEMS.find((i) => i.id === id); +export const placeOf = (w: World): PlaceDef => PLACES[w.location]; +export const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1); + +/** Maps what the resolver wrote ("brass key", "the Lantern") to an item id, or 'chest'. */ +export function normalizeItem(text: unknown): ItemId | 'chest' | undefined { + if (typeof text !== 'string') return undefined; + const t = text.toLowerCase().replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim().replace(/^(the|a|an|my|our) /, ''); + if (/\bchest\b|\bbox\b/.test(t)) return 'chest'; + for (const item of ITEMS) if (item.id.replace(/_/g, ' ') === t || item.aliases.includes(t)) return item.id; + if (/\bflint\b|\bwick\b/.test(t)) return 'flint_and_wick'; + if (/\bkey\b/.test(t)) return 'brass_key'; + if (/\blantern\b/.test(t)) return 'lantern'; + if (/\bmap\b/.test(t)) return 'map'; + return undefined; +} + +/** Items lying here that nobody has taken. The flint and wick are visible only once the chest is open. */ +export function itemsHere(w: World): ItemDef[] { + return ITEMS.filter((i) => i.place === w.location && !w.satchel.includes(i.id) && (i.id !== 'flint_and_wick' || w.chest_open)); +} + +export const chestHere = (w: World) => w.location === 'tavern'; + +// ---- What the resolver returns, and what the code makes of it ---- + +export interface Actions { + /** An exit id the player clearly chose. */ + move: string | null; + /** Somewhere or some way the player tried to go that is not one of the exits (so it is refused, not guessed). */ + blocked: string | null; + /** "pixel" when the player spoke to the mute traveller ("ask Pixel what he thinks"). */ + addressed: string | null; + take: string[]; + use: Array<{ item: string; target: string }>; + give: Array<{ item: string; to: string }>; +} + +export const noActions = (): Actions => ({ move: null, blocked: null, addressed: null, take: [], use: [], give: [] }); + +const str = (v: unknown): string | undefined => (typeof v === 'string' && v.trim() ? v.trim() : undefined); + +/** Reads the resolver's answer: the first JSON object in the text, with anything of the wrong shape dropped. Anything unreadable is no actions. */ +export function parseActions(raw: string): Actions { + const out = noActions(); + const start = raw.indexOf('{'); + const end = raw.lastIndexOf('}'); + if (start < 0 || end <= start) return out; + let json: any; + try { + json = JSON.parse(raw.slice(start, end + 1)); + } catch { + return out; + } + if (!json || typeof json !== 'object') return out; + out.move = str(json.move) ?? null; + out.blocked = str(json.blocked) ?? null; + out.addressed = str(json.addressed)?.toLowerCase() ?? null; + if (Array.isArray(json.take)) out.take = json.take.map(str).filter((x: string | undefined): x is string => !!x); + if (Array.isArray(json.use)) out.use = json.use.map((u: any) => ({ item: str(u?.item), target: str(u?.target) })).filter((u: any) => u.item && u.target); + if (Array.isArray(json.give)) out.give = json.give.map((g: any) => ({ item: str(g?.item), to: str(g?.to) ?? 'stranger' })).filter((g: any) => g.item); + return out; +} + +/** The question for the resolver: the place, its exits, what lies here, what the party carries, and the player's words. */ +export function actionPrompt(w: World, words: string, pixel_present = false): { system: string; user: string } { + const p = placeOf(w); + const here = itemsHere(w).map((i) => `${i.id} (${i.label})`); + const carried = w.satchel.map((id) => `${id} (${itemById(id)!.label})`); + return { + system: 'You read what a player says in a spoken adventure and list only what they clearly do right now. Reply with one JSON object and nothing else: {"move": exit id or null, "blocked": text or null, "addressed": "pixel" or null, "take": [item ids], "use": [{"item": id, "target": id or "chest"}], "give": [{"item": id, "to": "stranger"}]}. Choose a "move" only when the player\'s words clearly name or describe one of the listed exits. Prefer the exit whose destination the player names ("the Drowned Bell", "the inn", "the lighthouse", "the cave"): the destination outweighs words like "door" or "path". If the player tries to go somewhere, or by a way, that is NOT in the list of exits, set "move" to null and put what they tried in "blocked". Never pick the nearest exit as a guess. Use empty arrays and null when the player does none of these. Handing an item to someone is "give" ("to" is who gets it, for example "pixel" or "stranger"). When the player speaks to or asks Pixel something, set "addressed" to "pixel". Exploring, asking, looking and talking are none of these.', + user: `Place: ${p.place}. +Exits (use the id): ${p.exits.map((e) => `${e.id}: ${e.text}, leads to ${PLACES[e.to].name} (also called ${PLACES[e.to].aliases.join(', ')})`).join('; ')}. +Items lying here: ${here.join('; ') || 'none'}.${chestHere(w) ? ` An iron chest is here, ${w.chest_open ? 'open' : 'locked'}.` : ''} +The party carries: ${carried.join('; ') || 'nothing'}. +${pixel_present ? 'Pixel, a mute traveller, is in the party.\n' : ''}The player said: "${words.trim().slice(0, 300)}"`, + }; +} + +export interface Resolution { + /** One short factual sentence per thing that happened or was refused, for Bram to narrate. */ + outcomes: string[]; + moved: boolean; + opened: boolean; + lit: boolean; + took: ItemId[]; + /** A move was asked for and refused (no such exit, or a destination with no way from here). */ + blocked_move: boolean; +} + +/** Validates and applies the resolver's actions in order: take, give, use, then move. Anything that does not hold becomes a refusal outcome. */ +export function applyActions(w: World, actions: Actions): Resolution { + const r: Resolution = { outcomes: [], moved: false, opened: false, lit: false, took: [], blocked_move: false }; + const taken_ids = new Set(); + const take = (raw: string, via_stranger = false, who = 'the stranger') => { + const id = normalizeItem(raw); + if (id === 'chest') return r.outcomes.push('The iron chest is far too heavy to take and is bolted to the floor of the inn. It stays where it is.'); + const item = id ? itemById(id) : undefined; + if (!item) return r.outcomes.push(`There is no "${raw}" here that can be taken.`); + // "flint" and "wick" are one item: say it once + if (taken_ids.has(item.id)) return; + taken_ids.add(item.id); + if (w.satchel.includes(item.id)) return r.outcomes.push(`${cap(item.label)} is already in the satchel.`); + if (!itemsHere(w).some((i) => i.id === item.id)) return r.outcomes.push(`${cap(item.label)} is not in this place.`); + w.satchel.push(item.id); + r.took.push(item.id); + r.outcomes.push(via_stranger ? `The party gave ${item.label} to ${who}, who carries it: it is in the party's satchel.` : `The party took ${item.label}. It is in the satchel.`); + }; + for (const raw of actions.take) take(raw); + for (const g of actions.give) { + const id = normalizeItem(g.item); + const item = id && id !== 'chest' ? itemById(id) : undefined; + const who = /pix/i.test(g.to) ? 'Pixel' : 'the stranger'; + if (item && w.satchel.includes(item.id)) r.outcomes.push(`The party handed ${item.label} to ${who}, who carries it: it stays in the party's satchel.`); + else take(g.item, true, who); + } + for (const u of actions.use) { + const a = normalizeItem(u.item); + const b = normalizeItem(u.target); + const pair = (x: string, y: string) => (a === x && b === y) || (a === y && b === x); + if (pair('brass_key', 'chest') || a === 'chest' || b === 'chest') { + if (!chestHere(w)) r.outcomes.push('There is no chest in this place.'); + else if (w.chest_open) r.outcomes.push('The chest is already open.'); + else if (!pair('brass_key', 'chest')) r.outcomes.push('The chest is locked and does not open that way. It needs a key.'); + else if (!w.satchel.includes('brass_key')) r.outcomes.push('The party tried to open the chest: it is locked and the party has no key.'); + else { w.chest_open = true; r.opened = true; r.outcomes.push('The brass key turns and the chest opens. Inside lie flint and a wick, now in plain sight.'); } + } else if (pair('lantern', 'flint_and_wick')) { + if (!w.satchel.includes('lantern')) r.outcomes.push('The party is not carrying the Lantern.'); + else if (!w.satchel.includes('flint_and_wick')) r.outcomes.push('There is nothing to light the Lantern with: the party has no flint and wick.'); + else if (w.location !== 'lighthouse') r.outcomes.push('This is not the place to light the Lantern. It must be lit at the lighthouse, where the great lamp is.'); + else if (w.lantern_lit) r.outcomes.push('The Lantern is already lit.'); + else { w.lantern_lit = true; r.lit = true; r.outcomes.push(LIT_OUTCOME); } + } else if (a && itemById(a) && !w.satchel.includes(a)) r.outcomes.push(`${cap(itemById(a)!.label)} is not in the satchel.`); + else r.outcomes.push('Nothing happens: that does not work here.'); + } + if (!actions.move && actions.blocked) { r.blocked_move = true; r.outcomes.push(`There is no way to ${actions.blocked} from here. From here the party can go to: ${exitsByDestination(w)}.`); } + if (actions.move) { + const here = placeOf(w); + const wanted = actions.move.toLowerCase().replace(/[\s-]+/g, '_'); + const exit = here.exits.find((e) => e.id === wanted) ?? here.exits.find((e) => e.to === wanted); + if (!exit) { r.blocked_move = true; r.outcomes.push(`There is no way "${actions.move}" from here. From here the party can go to: ${exitsByDestination(w)}.`); } + else { + w.location = exit.to; + r.moved = true; + r.outcomes.push(`The party moved to ${PLACES[exit.to].name}.`); + } + } + return r; +} + +/** Whether the story ends now: the Lantern is lit (at the lighthouse, the only place it can be). */ +export const endTriggered = (r: Resolution) => r.lit; + +// ---- What Bram is told ---- + +/** The scene note for one reply: where the party is, what lies here, what is carried, the exits as description, what just happened. */ +/** The first item the words name ("give pixel to map" still names the map), for when the resolver missed an obvious give. */ +export function itemNamed(words: string): ItemId | undefined { + const t = words.toLowerCase(); + for (const item of ITEMS) if (item.aliases.some((a) => new RegExp(`\\b${a.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`).test(t))) return item.id; + return undefined; +} + +/** True when the words name Pixel (speech to text may write "pixel" or "pixle"). */ +export const addressesPixel = (words: string): boolean => /\bpix(?:el|le)\b/i.test(words); + +export function placeNote(w: World, opts: { extra?: string[]; full: boolean; described?: string[]; replies?: number; outcomes?: string[]; music?: string; arriving?: boolean }): string { + const p = placeOf(w); + const replies = opts.replies ?? 0; + const parts: string[] = []; + parts.push(`You are at ${p.name}: ${p.place}. Never describe being anywhere else, and never describe the party moving, unless this note says the party moved.`); + if (opts.music) parts.push(`The place has started ${opts.music}.`); + const sights = sightsOf(w); + if (opts.full) parts.push(`What can be seen and heard: ${sights.join(', ')}.`); + else { + // Only what is still true counts as described: a phrase for how things used to be (the locked chest) is dropped, never repeated to Bram + const described = (opts.described ?? []).filter((d) => sights.includes(d)); + const fresh = sights.filter((d) => !described.includes(d)); + parts.push(`You have already described this place${described.length ? `: already described, so do not repeat it unless something about it changes or it matters to what the player just did: ${described.join('; ')}` : ''}.${fresh.length ? ` Not yet mentioned: ${fresh.join('; ')}.` : ''}`); + } + parts.push('Never describe the Lantern or the great lamp being lit, anything opening, or anything being taken, unless "What just happened" says so.'); + parts.push(`Ways out, to describe only as part of the place: ${p.exits.map((e) => e.text).join('; ')}.`); + const clues = cluesOf(w); + if (clues.length && !w.lantern_lit) parts.push(`Things to find, revealed only when a player investigates that thing: ${clues.join('; ')}.`); + const here = itemsHere(w); + parts.push(here.length ? `Lying here, not yet taken: ${here.map((i) => i.label).join('; ')}. Describe each where it lies and never tell the players to take it.` : 'Nothing here is left to take.'); + parts.push(`In the satchel: ${w.satchel.length ? w.satchel.map((id) => itemById(id)!.label).join('; ') : 'nothing'}.`); + if (chestHere(w)) parts.push(`The iron chest is here, ${w.chest_open ? 'open' : 'locked'}.`); + if (opts.outcomes?.length) parts.push(`What just happened, resolved by the story (state it plainly as fact, never contradict it): ${opts.outcomes.join(' ')}`); + for (const e of opts.extra ?? []) parts.push(e); + if (opts.arriving) parts.push('Describe the place in two short plain sentences using some of what can be seen and heard, then stop on a short open line with no name and no question.'); + else if (replies >= 4) parts.push('Give the shortest reply now: one sentence about what happens, and no atmosphere at all.'); + else if (replies >= 1) parts.push('Answer only what the player did, in one or two sentences, with no recap of the scene.'); + return parts.join(' '); +} + +/** The closing note once the Lantern is lit: Bram speaks his closing and nothing more. */ +export const closingNote = (outcomes: string[]) => `The quest is complete: ${outcomes.join(' ')} Speak your closing now: at most three plain sentences that say what the players did, that the party keeps the lit Lantern and carries it back down to the Drowned Bell, and end the story. Do not say anything after it.`; + +const STOP = new Set(['the', 'and', 'with', 'its', 'on', 'in', 'of', 'a', 'an', 'to', 'it', 'from', 'under', 'over', 'into', 'across', 'near', 'that', 'small', 'front']); + +/** The sights (comma-separated details) that a reply mentions: a detail counts as used when one of its key words appears. */ +export function usedDetails(details: string[], reply: string): string[] { + const text = reply.toLowerCase(); + return details.filter((detail) => detail.toLowerCase().match(/[a-z]+/g)?.some((word) => word.length >= 3 && !STOP.has(word) && new RegExp(`\\b${word}(?:s|es)?\\b`).test(text))); +} + +export const satchelAttribute = (w: World): string => JSON.stringify(w.satchel); + +export function parseSatchel(value: string | undefined): ItemId[] { + if (!value) return []; + try { + const raw = JSON.parse(value); + return Array.isArray(raw) ? raw.filter((id): id is ItemId => typeof id === 'string' && !!itemById(id)) : []; + } catch { + return []; + } +} + +// ---- Names ---- + +const NAME_STOP = new Set(['not', 'going', 'ready', 'here', 'sorry', 'fine', 'good', 'done', 'sure', 'afraid', 'looking', 'trying', 'taking', 'using', 'stuck', 'lost', 'tired', 'back', 'just', 'still', 'also', 'in', 'at', 'on', 'the', 'a', 'an', 'so', 'very', 'really', 'now', 'with', 'for', 'to']); + +/** Words that follow "I'm" or "my name is" without being a name: feelings, directions, days, months, and the story's own names. */ +const NOT_NAMES = new Set(['i', 'we', 'you', 'he', 'she', 'they', 'it', 'this', 'that', 'what', 'where', 'how', 'who', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december', 'old', 'bram', 'hester', 'pixel', 'hollow', 'mere', 'lantern', 'lighthouse']); + +/** + * "my name is Snaggle", "call me Snaggle", "I'm Snaggle": the name a player gave, or undefined. Only a capitalised word counts, and + * not a possessive ("This is Pixel's idea"), a story name, a day or month, or a word that follows "I'm" without being a name + * ("I'm Tired"). "It's Tuesday" and "This is Pixel" are not introductions, so they never rename. + */ +export function parseNameCorrection(text: string): string | undefined { + const m = text.match(/\b(?:[Ii]['’]?m|[Ii] am|[Mm]y name(?:['’]s| is)|[Cc]all me)\s+([A-Z][A-Za-z'’-]{1,19})\b/); + if (!m || /['’]s$/i.test(m[1])) return undefined; + const name = m[1]; + const lower = name.toLowerCase(); + return NAME_STOP.has(lower) || NOT_NAMES.has(lower) ? undefined : name; +} + +/** True when a reply uses the player's name as a word (so the check can log it). */ +export const usesName = (reply: string, name: string | undefined): boolean => !!name && new RegExp(`\\b${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'i').test(reply); diff --git a/livekit/voice-adventure/agent/test/llm-pixel.test.ts b/livekit/voice-adventure/agent/test/llm-pixel.test.ts new file mode 100644 index 0000000..68422cc --- /dev/null +++ b/livekit/voice-adventure/agent/test/llm-pixel.test.ts @@ -0,0 +1,28 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { LLM_MODEL, describeLlm } from '../src/llm.ts'; +import { SCENE_LINES, gestureDelayMs, shouldGesture } from '../src/pixel-lines.ts'; + +test('the language model is LiveKit Inference gpt-4.1-mini, and the startup line says so', () => { + assert.equal(LLM_MODEL, 'openai/gpt-4.1-mini'); + assert.equal(describeLlm(), 'LLM: LiveKit Inference openai/gpt-4.1-mini'); +}); + +test('the gesture delay is one to three seconds', () => { + assert.equal(gestureDelayMs(() => 0), 1000); + assert.equal(gestureDelayMs(() => 0.999), 2998); +}); + +test('Pixel answers its own turn once, and only its own turn', () => { + const ask = { pixel_seq: '3', line: '*Pixel nods.*' }; + assert.equal(shouldGesture(ask, undefined), 'gesture'); + assert.equal(shouldGesture(ask, '3'), 'idle'); + assert.equal(shouldGesture({ ...ask, pixel_seq: '4' }, '3'), 'gesture'); + assert.equal(shouldGesture({ pixel_seq: '5' }, undefined), 'idle'); // no line, nothing to send + assert.equal(shouldGesture({}, undefined), 'idle'); +}); + + +test('every place has a few gesture lines', () => { + for (const [place, lines] of Object.entries(SCENE_LINES)) assert.ok(lines.length >= 2, place); +}); diff --git a/livekit/voice-adventure/agent/test/names.test.ts b/livekit/voice-adventure/agent/test/names.test.ts new file mode 100644 index 0000000..570604f --- /dev/null +++ b/livekit/voice-adventure/agent/test/names.test.ts @@ -0,0 +1,59 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { fetchLine, planLedger, realName, shouldFetchBram } from '../src/names.ts'; + +test('a typed name is a real name; an empty one, the identity or a placeholder is not', () => { + assert.equal(realName('Priya', 'web-1a2b3c'), 'Priya'); + assert.equal(realName(' Sam ', 'web-1a2b3c'), 'Sam'); + assert.equal(realName('', 'web-1a2b3c'), undefined); + assert.equal(realName(undefined, 'web-1a2b3c'), undefined); + assert.equal(realName('web-1a2b3c', 'web-1a2b3c'), undefined); + assert.equal(realName('web-ff00aa', 'something-else'), undefined); + assert.equal(realName('Player', 'web-1a2b3c'), undefined); +}); + +test('a player who typed a name is greeted and written in without being asked', () => { + const plan = planLedger([{ identity: 'web-1', name: 'Priya', bot: false }], new Set()); + assert.deepEqual(plan.named, [{ identity: 'web-1', name: 'Priya', bot: false }]); + assert.deepEqual(plan.unnamed, []); +}); + +test('only players who joined without a name are asked, in the order she meets them', () => { + const plan = planLedger([ + { identity: 'web-1', name: '', bot: false }, + { identity: 'web-2', name: 'Sam', bot: false }, + { identity: 'web-3', name: undefined, bot: false }, + ], new Set()); + assert.deepEqual(plan.named.map((g) => g.name), ['Sam']); + assert.deepEqual(plan.unnamed, ['web-1', 'web-3']); +}); + +test('a second player joining later is planned the same way, and guests already in the ledger are skipped', () => { + const guests = [ + { identity: 'web-1', name: 'Priya', bot: false }, + { identity: 'web-2', name: 'Sam', bot: false }, + ]; + const plan = planLedger(guests, new Set(['web-1'])); + assert.deepEqual(plan.named.map((g) => g.name), ['Sam']); + assert.deepEqual(plan.unnamed, []); +}); + +test('the bot has a known name from its identity and is never asked', () => { + const plan = planLedger([{ identity: 'bot-pixel', name: '', bot: true }], new Set()); + assert.deepEqual(plan.named, [{ identity: 'bot-pixel', name: 'Pixel', bot: true }]); + assert.deepEqual(plan.unnamed, []); +}); + +test('the line Hester speaks before fetching Old Bram greets the named players and the quiet one', () => { + assert.equal(fetchLine(['Priya'], ['Pixel']), "Ah, Priya, we've been expecting you and your quiet friend, Pixel. Let me fetch Old Bram, love, he's been waiting all evening for a crowd."); + assert.match(fetchLine(['Priya', 'Sam'], []), /^Ah, Priya and Sam, we've been expecting you\. Let me fetch Old Bram/); + assert.match(fetchLine([], ['Pixel']), /^And there's your quiet friend, Pixel\. Let me fetch Old Bram/); + assert.match(fetchLine([], [], 1), /^Sit by the fire, dears, while I fetch Old Bram/); +}); + +test('Hester fetches Bram only after the ledger is complete and she has finished speaking, and only once', () => { + assert.equal(shouldFetchBram('speaking', 'listening', true, false), true); + assert.equal(shouldFetchBram('thinking', 'listening', true, false), false); + assert.equal(shouldFetchBram('speaking', 'listening', false, false), false); + assert.equal(shouldFetchBram('speaking', 'listening', true, true), false); +}); diff --git a/livekit/voice-adventure/agent/test/resume.test.ts b/livekit/voice-adventure/agent/test/resume.test.ts new file mode 100644 index 0000000..7fa1b65 --- /dev/null +++ b/livekit/voice-adventure/agent/test/resume.test.ts @@ -0,0 +1,18 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { addSummaryLine, decodeState, resumePlayers, SUMMARY_LINES } from '../src/resume.ts'; + +const players = [{ identity: 'web-1', name: 'Priya', bot: false }, { identity: 'bot-pixel', name: 'Pixel', bot: true }]; + +test('decode ignores empty, foreign and broken metadata', () => { + assert.equal(decodeState(''), null); + assert.equal(decodeState(undefined), null); + assert.equal(decodeState('not json'), null); + assert.equal(decodeState('{"hello":1}'), null); +}); + +test('resume players: named guests now in the room win; otherwise the saved humans come back', () => { + assert.deepEqual(resumePlayers(players, [{ identity: 'web-9', name: 'Priya', bot: false }]).map((p) => p.identity), ['web-9']); + assert.deepEqual(resumePlayers(players, [{ identity: 'web-9', name: '', bot: false }]).map((p) => p.name), ['Priya']); +}); + diff --git a/livekit/voice-adventure/agent/test/story.test.ts b/livekit/voice-adventure/agent/test/story.test.ts new file mode 100644 index 0000000..60f90d9 --- /dev/null +++ b/livekit/voice-adventure/agent/test/story.test.ts @@ -0,0 +1,235 @@ +import assert from 'node:assert/strict'; +import { mock, test } from 'node:test'; +import { createEndWatcher, speakerAfterMute } from '../src/story.ts'; + +test('the ending waits for the last speech to finish and a 2 second pause, and a late speech cancels it', () => { + mock.timers.enable({ apis: ['setTimeout'] }); + try { + let finished = 0; + const w = createEndWatcher(() => { finished += 1; }, 2000, { set: setTimeout, clear: clearTimeout }); + w.onAgentState('thinking', 'listening'); // before end_story: ignored + mock.timers.tick(5000); + assert.equal(finished, 0); + w.arm(); + w.onAgentState('speaking', 'listening'); // the closing finished + mock.timers.tick(1500); + w.onAgentState('listening', 'thinking'); // the tool result starts a farewell: cancel the pause + mock.timers.tick(3000); + assert.equal(finished, 0); + w.onAgentState('speaking', 'listening'); // the farewell finished + mock.timers.tick(1999); + assert.equal(finished, 0); + mock.timers.tick(2); + assert.equal(finished, 1); + w.onAgentState('speaking', 'listening'); + mock.timers.tick(5000); + assert.equal(finished, 1); // only once + } finally { + mock.timers.reset(); + } +}); + +test('after the mute player\'s turn the listener goes back to the first player who can speak', () => { + const players = [{ name: 'Pixel', bot: true }, { name: 'Priya', bot: false }, { name: 'Sam', bot: false }]; + assert.equal(speakerAfterMute(players)?.name, 'Priya'); + assert.equal(speakerAfterMute([{ name: 'Pixel', bot: true }]), undefined); +}); + +import { addressedPlayer, cleanSpeech, nextSpeakerIndex, onBramReply, onPlayerInput, onPlayout, speechFilter, type TurnState } from '../src/story.ts'; + +const crew = [ + { name: 'Priya', identity: 'web-1', bot: false }, + { name: 'Sam', identity: 'web-2', bot: false }, + { name: 'Pixel', identity: 'bot-pixel', bot: true }, +]; + +test('the next speaker is the player Bram names last, else the next in rotation', () => { + assert.equal(addressedPlayer('The door is open. Priya, will you go through, or does Sam want to look first?', crew)?.name, 'Sam'); + assert.equal(addressedPlayer('Nobody is named here.', crew), undefined); + assert.equal(addressedPlayer('Samuel the stranger waves.', crew), undefined); // a longer word is not Sam + assert.equal(nextSpeakerIndex(crew, 0, 'Sam, which way?'), 1); + assert.equal(nextSpeakerIndex(crew, 1, 'Which way do you go?'), 2); + assert.equal(nextSpeakerIndex(crew, 2, 'Which way do you go?'), 0); + assert.equal(nextSpeakerIndex([], 0, 'x'), -1); +}); + +test('the speech filter removes spoken tool calls and tool names', () => { + assert.deepEqual(cleanSpeech('We step out. functions.next_scene()'), { text: 'We step out. ', removed: true }); + assert.equal(cleanSpeech('Time for next_scene now').text, 'Time for now'); + assert.equal(cleanSpeech('functions.give_turn({player: "Sam"}) Sam, go on.').text, ' Sam, go on.'); + assert.deepEqual(cleanSpeech('Plain words only.'), { text: 'Plain words only.', removed: false }); + assert.equal(cleanSpeech('end_story, write_in_ledger and fetch_bram').text.trim(), ', and'); +}); + +test('the speech filter works on a stream, with a tool name split across chunks', async () => { + const removed: string[] = []; + const chunks = ['The cave opens. ', 'functions.', 'next_', 'scene()', ' You see a ledge.']; + const stream = new ReadableStream({ start(c) { for (const x of chunks) c.enqueue(x); c.close(); } }); + const out: string[] = []; + for await (const part of speechFilter((what) => removed.push(what))(stream)) out.push(part); + const spoken = out.join(''); + assert.ok(!/next_scene|functions/.test(spoken), spoken); + assert.ok(spoken.includes('The cave opens.') && spoken.includes('You see a ledge.')); + assert.ok(removed.length >= 1); +}); + +const fresh = (): TurnState => ({ scene_index: 1, inputs: 0, input_since_call: false, last_reply: '', rotation: -1, ending: false }); + +test('simulation: no turn is given before the first scene or while the story is ending', () => { + const s = fresh(); + s.scene_index = 0; + assert.equal(onPlayout(s, crew), undefined); + s.scene_index = 1; s.ending = true; + assert.equal(onPlayout(s, crew), undefined); +}); + +import { createLlmWatchdog, stallLine } from '../src/story.ts'; + +test('the watchdog fires once after 20 seconds of silence, and progress cancels it', () => { + mock.timers.enable({ apis: ['setTimeout'] }); + try { + let stalls = 0; + const w = createLlmWatchdog(() => { stalls += 1; }, 20000, { set: setTimeout, clear: clearTimeout }); + w.arm(); + assert.equal(w.armed, true); + mock.timers.tick(19999); + assert.equal(stalls, 0); + mock.timers.tick(2); + assert.equal(stalls, 1); + assert.equal(w.armed, false); + mock.timers.tick(60000); + assert.equal(stalls, 1); // once + + w.arm(); + mock.timers.tick(10000); + w.progress(); // Bram started speaking + mock.timers.tick(60000); + assert.equal(stalls, 1); + + w.arm(); // a new player input re-arms from zero + mock.timers.tick(15000); + w.arm(); + mock.timers.tick(15000); + assert.equal(stalls, 1); + mock.timers.tick(5001); + assert.equal(stalls, 2); + } finally { + mock.timers.reset(); + } +}); + +test('the stall line is short, in character and names the player', () => { + assert.match(stallLine('Priya'), /Priya/); + assert.ok(stallLine(undefined, 1).length < 90); + assert.notEqual(stallLine('Sam', 0), stallLine('Sam', 1)); +}); + +import { LEADING_BLOCK_END, LEADING_BLOCK_START, bramInstructions } from '../src/story.ts'; + +// Phrasing that directs the players: offers, choices, suggestions and "would you like to" questions +const LEADING = /would you like|do you want to|you could|you might|you may want|why not|maybe you|try to|try and|how about|shall (we|you)|should you|offer|choice|suggest|search for/i; + +const withoutLeadingExamples = (text: string) => text.replace(new RegExp(`${escapeRegExp(LEADING_BLOCK_START)}[\\s\\S]*?${escapeRegExp(LEADING_BLOCK_END)}`), ''); +function escapeRegExp(s: string) { return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } + +import { createTurnRecovery } from '../src/story.ts'; + +test('turn recovery: a final transcript with no turn end commits the turn after 15 s, then says the line after 15 s more', () => { + mock.timers.enable({ apis: ['setTimeout'] }); + try { + const log: string[] = []; + const r = createTurnRecovery({ commit: () => log.push('commit'), say_again: () => log.push('say') }, 15000, { set: setTimeout, clear: clearTimeout }); + r.onFinalTranscript(); + mock.timers.tick(14999); + assert.deepEqual(log, []); + mock.timers.tick(2); + assert.deepEqual(log, ['commit']); + mock.timers.tick(15001); + assert.deepEqual(log, ['commit', 'say']); + mock.timers.tick(60000); + assert.deepEqual(log, ['commit', 'say']); // done: nothing repeats + } finally { mock.timers.reset(); } +}); + +test('turn recovery: progress (the turn ended, or the agent started thinking or speaking) cancels it', () => { + mock.timers.enable({ apis: ['setTimeout'] }); + try { + const log: string[] = []; + const r = createTurnRecovery({ commit: () => log.push('commit'), say_again: () => log.push('say') }, 15000, { set: setTimeout, clear: clearTimeout }); + r.onFinalTranscript(); + mock.timers.tick(10000); + r.onProgress(); + mock.timers.tick(60000); + assert.deepEqual(log, []); + // after a commit, progress also clears the second stage + r.onFinalTranscript(); + mock.timers.tick(15001); + assert.deepEqual(log, ['commit']); + r.onProgress(); + mock.timers.tick(60000); + assert.deepEqual(log, ['commit']); + // a later final transcript starts over from stage zero + r.onFinalTranscript(); + mock.timers.tick(15001); + assert.deepEqual(log, ['commit', 'commit']); + } finally { mock.timers.reset(); } +}); + + + + +import { CLOSING_LINE } from '../src/story.ts'; + +const table = [ + { name: 'Priya', identity: 'web-a', bot: false }, + { name: 'Sam', identity: 'web-b', bot: false }, + { name: 'Pixel', identity: 'bot-pixel', bot: true }, +]; + +test('a player who left never gets the turn, and the rotation carries on with those still here', () => { + const s = fresh(); + s.last_reply = 'Water drips from the ceiling.'; + const here = (p: { identity: string }) => p.identity !== 'web-b'; + const order: string[] = []; + for (let i = 0; i < 4; i++) order.push(onPlayout(s, table, here)!.name); + assert.deepEqual(order, ['Priya', 'Priya', 'Priya', 'Priya']); + // When Bram names the absent player, the turn still goes to someone present + s.last_reply = 'Sam, what do you do?'; + assert.equal(onPlayout(s, table, here)!.name, 'Priya'); + // Nobody human is here: nobody gets the turn + assert.equal(onPlayout(s, table, (p) => p.identity === 'bot-pixel'), undefined); +}); + +test('after a say-that-again line the turn stays with the player it was given back to', () => { + const s = fresh(); + s.last_reply = 'Sam, what do you do?'; + s.rotation = 0; // Priya had the last turn; Bram named Sam + s.hold_turn = true; + assert.equal(onPlayout(s, table)!.name, 'Priya'); + assert.equal(s.hold_turn, false); + // The hold is used once: the next playout follows Bram's reply again + assert.equal(onPlayout(s, table)!.name, 'Sam'); + // A held player who has left is not held + s.hold_turn = true; + s.rotation = 1; + assert.notEqual(onPlayout(s, table, (p) => p.identity !== 'web-b')!.name, 'Sam'); +}); + +test('the end watcher can be forced once when the closing never plays', () => { + mock.timers.enable({ apis: ['setTimeout'] }); + try { + let finished = 0; + const w = createEndWatcher(() => { finished += 1; }, 2000, { set: setTimeout, clear: clearTimeout }); + w.arm(); + w.force(); + assert.equal(finished, 1); + w.onAgentState('speaking', 'listening'); + mock.timers.tick(5000); + w.force(); + assert.equal(finished, 1); + assert.equal(w.done, true); + assert.ok(CLOSING_LINE.length > 40 && CLOSING_LINE.split('.').length <= 4); + } finally { + mock.timers.reset(); + } +}); diff --git a/livekit/voice-adventure/agent/test/world.test.ts b/livekit/voice-adventure/agent/test/world.test.ts new file mode 100644 index 0000000..c05fa1a --- /dev/null +++ b/livekit/voice-adventure/agent/test/world.test.ts @@ -0,0 +1,482 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { addLightingFromWords, cluesOf, sightsOf, addressesPixel, exitsByDestination, itemNamed, ITEMS, matchDestination, PLACES, actionPrompt, applyActions, closingNote, endTriggered, itemsHere, newWorld, noActions, normalizeItem, parseActions, parseNameCorrection, parseSatchel, placeNote, satchelAttribute, usedDetails, usesName, worldAt, type Actions, type World } from '../src/world.ts'; +import { buildState, decodeState, encodeState, recapInstructions, shouldResume } from '../src/resume.ts'; +import { bramInstructions, cleanSpeech, onBramReply, onPlayout, onSceneStart, TOOL_NAMES, type TurnState } from '../src/story.ts'; +import { COOLDOWN_TURNS, GENERIC_LINES, POINTING_RESPONSES, RESPONDING_LINES, SCENE_LINES, chooseGesture, pickGesture, respondLine } from '../src/pixel-lines.ts'; + +const act = (o: Partial): Actions => ({ ...noActions(), ...o }); +const at = (place: World['location'], satchel: World['satchel'] = []): World => ({ ...newWorld(), location: place, satchel: [...satchel] }); + +test('the map: every exit leads to a real place and, except the boat, has a way back', () => { + for (const place of Object.values(PLACES)) { + for (const exit of place.exits) { + const target = PLACES[exit.to]; + assert.ok(target, `${place.id} -> ${exit.id}`); + // the boat across the pool is the one one-way exit: the lighthouse is reached by water, and left by land + if (exit.id !== 'boat') assert.ok(target.exits.some((e) => e.to === place.id), `${exit.to} has a way back to ${place.id}`); + } + } + const to = (from: string, id: string) => PLACES[from as keyof typeof PLACES].exits.find((e) => e.id === id)?.to; + assert.equal(to('tavern', 'north_door'), 'forest'); + assert.equal(to('forest', 'oak_door'), 'oak'); + assert.equal(to('oak', 'out'), 'forest'); + assert.equal(to('forest', 'rope_bridge'), 'cave'); + assert.equal(to('cave', 'steps_up'), 'forest'); + assert.equal(to('cave', 'boat'), 'lighthouse'); + assert.equal(to('lighthouse', 'shore_path'), 'tavern'); + assert.equal(to('lighthouse', 'headland_track'), 'forest'); +}); + +test('moving: a real exit moves the party, a bad exit does not, and going back works', () => { + const w = newWorld(); + let r = applyActions(w, act({ move: 'north_door' })); + assert.equal(r.moved, true); + assert.equal(w.location, 'forest'); + assert.match(r.outcomes[0], /moved to The Hollow Wood/); + r = applyActions(w, act({ move: 'secret_tunnel' })); + assert.equal(r.moved, false); + assert.equal(w.location, 'forest'); + assert.match(r.outcomes[0], /no way "secret_tunnel"/); + applyActions(w, act({ move: 'oak_door' })); + assert.equal(w.location, 'oak'); + applyActions(w, act({ move: 'out' })); + assert.equal(w.location, 'forest'); + applyActions(w, act({ move: 'inn_path' })); + assert.equal(w.location, 'tavern'); + // an exit that is not in this place is refused + assert.equal(applyActions(w, act({ move: 'boat' })).moved, false); +}); + +test('items stay where they are; taking works only where the item lies; the flint and wick appear only with the chest open', () => { + const w = newWorld(); + assert.deepEqual(itemsHere(w).map((i) => i.id), ['map']); + assert.equal(itemsHere(at('oak')).map((i) => i.id)[0], 'brass_key'); + assert.deepEqual(itemsHere(at('cave')).map((i) => i.id), ['lantern']); + assert.equal(applyActions(w, act({ take: ['the lantern'] })).took.length, 0); + assert.match(applyActions(at('tavern'), act({ take: ['brass key'] })).outcomes[0], /not in this place/); + const r = applyActions(w, act({ take: ['map'] })); + assert.deepEqual(w.satchel, ['map']); + assert.deepEqual(r.took, ['map']); + assert.match(applyActions(w, act({ take: ['map'] })).outcomes[0], /already in the satchel/); + assert.match(applyActions(w, act({ take: ['chest'] })).outcomes[0], /too heavy/); + assert.match(applyActions(w, act({ take: ['flint'] })).outcomes[0], /not in this place/); + // left behind in the oak until taken, even after the party leaves and returns + const v = at('oak'); + applyActions(v, act({ move: 'out' })); + applyActions(v, act({ move: 'oak_door' })); + assert.deepEqual(itemsHere(v).map((i) => i.id), ['brass_key']); +}); + +test('give to the stranger is the party taking it: an item here is taken, a carried one stays in the shared satchel, and one not here is refused', () => { + const w = at('cave'); + let r = applyActions(w, act({ give: [{ item: 'lantern', to: 'stranger' }] })); + assert.deepEqual(w.satchel, ['lantern']); + assert.match(r.outcomes[0], /stranger, who carries it/); + r = applyActions(w, act({ give: [{ item: 'lantern', to: 'stranger' }] })); + assert.deepEqual(w.satchel, ['lantern']); // no duplicate + assert.match(r.outcomes[0], /stays in the party's satchel/); + assert.match(applyActions(w, act({ give: [{ item: 'brass key', to: 'stranger' }] })).outcomes[0], /not in this place/); +}); + +test('the chest is in the tavern: it needs the key; with the key it opens and the flint and wick can be taken', () => { + const w = at('tavern'); + assert.match(applyActions(w, act({ use: [{ item: 'brass key', target: 'chest' }] })).outcomes[0], /no key/); + assert.match(applyActions(at('forest', ['brass_key']), act({ use: [{ item: 'brass key', target: 'chest' }] })).outcomes[0], /no chest in this place/); + const v = at('tavern', ['brass_key']); + const r = applyActions(v, act({ use: [{ item: 'key', target: 'chest' }] })); + assert.equal(r.opened, true); + assert.equal(v.chest_open, true); + assert.match(applyActions(v, act({ use: [{ item: 'key', target: 'chest' }] })).outcomes[0], /already open/); + assert.deepEqual(itemsHere(v).map((i) => i.id).sort(), ['flint_and_wick', 'map']); + assert.equal(applyActions(v, act({ take: ['flint and wick'] })).took[0], 'flint_and_wick'); +}); + +test('lighting: only at the lighthouse with the Lantern and the flint and wick, in any order of gathering; then the ending triggers', () => { + assert.match(applyActions(at('lighthouse', ['flint_and_wick']), act({ use: [{ item: 'lantern', target: 'flint and wick' }] })).outcomes[0], /not carrying the Lantern/); + assert.match(applyActions(at('lighthouse', ['lantern']), act({ use: [{ item: 'lantern', target: 'flint and wick' }] })).outcomes[0], /no flint and wick/); + assert.match(applyActions(at('cave', ['lantern', 'flint_and_wick']), act({ use: [{ item: 'flint', target: 'lantern' }] })).outcomes[0], /not the place/); + const w = at('lighthouse', ['lantern', 'flint_and_wick']); + const r = applyActions(w, act({ use: [{ item: 'flint and wick', target: 'lantern' }] })); + assert.equal(r.lit, true); + assert.equal(endTriggered(r), true); + assert.match(closingNote(r.outcomes), /Speak your closing now/); + // the whole route: lantern first, boat to the lighthouse, back by the shore path, the key from the oak, the chest, back to the lighthouse + const route = newWorld(); + const steps: Actions[] = [act({ move: 'north_door' }), act({ move: 'rope_bridge' }), act({ take: ['lantern'] }), act({ move: 'boat' }), act({ move: 'shore_path' }), act({ move: 'north_door' }), act({ move: 'oak_door' }), act({ take: ['key'] }), act({ move: 'out' }), act({ move: 'inn_path' }), act({ use: [{ item: 'key', target: 'chest' }] }), act({ take: ['flint'] }), act({ move: 'shore_door' })]; + for (const s of steps) applyActions(route, s); + assert.equal(route.location, 'lighthouse'); + assert.deepEqual([...route.satchel].sort(), ['brass_key', 'flint_and_wick', 'lantern']); + assert.equal(applyActions(route, act({ use: [{ item: 'lantern', target: 'flint' }] })).lit, true); +}); + +test('resolver JSON: parsed from the model text, bad shapes dropped, unreadable is no actions; the prompt carries place, exits, items and the words', () => { + assert.deepEqual(parseActions('{"move":"boat","take":["lantern"],"use":[{"item":"key","target":"chest"}],"give":[{"item":"map","to":"stranger"}]}'), { move: 'boat', blocked: null, addressed: null, take: ['lantern'], use: [{ item: 'key', target: 'chest' }], give: [{ item: 'map', to: 'stranger' }] }); + assert.deepEqual(parseActions('```json\n{"move": null, "take": [], "use": [], "give": []}\n```'), noActions()); + assert.deepEqual(parseActions('{"move": 3, "take": "map", "use": [{"item": "key"}], "give": [{"to": "x"}]}'), noActions()); + for (const bad of ['', 'no', '{broken', '[1]', 'null']) assert.deepEqual(parseActions(bad), noActions()); + const p = actionPrompt(newWorld(), 'I take the map and go north'); + assert.match(p.user, /north_door/); + assert.match(p.user, /map \(the salt-stained map\)/); + assert.match(p.user, /I take the map and go north/); + assert.match(p.user, /chest is here, locked/); +}); + +test('state saves and resumes with location, satchel and puzzle flags; the older scene-based state is ignored', () => { + const world: World = { location: 'oak', satchel: ['map', 'lantern'], chest_open: false, lantern_lit: false }; + const back = decodeState(encodeState(buildState({ scene_index: 5, players: [{ identity: 'web-1', name: 'Priya', bot: false }], summary: ['Bram: x'], world })))!; + assert.deepEqual(back.world, world); + assert.equal(shouldResume(back), true); + assert.equal(shouldResume({ ...back, ended: true }), false); + assert.match(recapInstructions(back, back.players), /You are at The Hollow Oak/); + assert.match(recapInstructions(back, back.players), /In the satchel: the salt-stained map; the Lantern of Hollow Mere/); + assert.equal(decodeState(JSON.stringify({ v: 1, scene_index: 2, players: [], clues: [], summary: [], ended: false, saved_at: 1 })), null); + assert.deepEqual(parseSatchel(satchelAttribute(world)), ['map', 'lantern']); + assert.deepEqual(parseSatchel('nonsense'), []); +}); + +test('the note: where the party is, never anywhere else; what lies here and is carried; the exits as description; what just happened; shortening', () => { + const w = at('forest'); + const arrival = placeNote(w, { full: true, arriving: true, outcomes: ['The party moved to The Hollow Wood.'], music: 'with its soundtrack' }); + assert.match(arrival, /You are at The Hollow Wood/); + assert.match(arrival, /Never describe being anywhere else, and never describe the party moving, unless this note says the party moved/); + assert.match(arrival, /What can be seen and heard: a rope bridge/); + assert.match(arrival, /Ways out, to describe only as part of the place: the small door in the hollow oak/); + assert.match(arrival, /What just happened.*moved to The Hollow Wood/); + assert.match(arrival, /Nothing here is left to take/); + const oak = placeNote(at('oak'), { full: true }); + assert.match(oak, /Lying here, not yet taken: the small brass key.*never tell the players to take it/); + assert.doesNotMatch(oak, /iron chest/); + assert.match(placeNote(at('tavern'), { full: true }), /iron chest is here, locked/); + const later = placeNote(w, { full: false, described: ['a rope bridge over a stream'], replies: 2 }); + assert.match(later, /already described, so do not repeat it.*a rope bridge over a stream/); + assert.match(later, /Answer only what the player did, in one or two sentences/); + assert.match(placeNote(w, { full: false, replies: 4 }), /shortest reply now/); + assert.deepEqual(usedDetails(sightsOf(newWorld()), 'The fire pops and the rain hammers the shutters.'), ['rain on the shutters', 'the fire popping']); +}); + +test('atmosphere tracking follows the place and resets on arrival', () => { + const s: TurnState = { scene_index: 0, inputs: 0, input_since_call: false, last_reply: '', rotation: -1, ending: false, world: newWorld() }; + onSceneStart(s, 'tavern'); + assert.equal(s.scene_index, 1); + onBramReply(s, 'The fire pops and the rain hammers the shutters.'); + assert.deepEqual(s.described, ['rain on the shutters', 'the fire popping']); + onSceneStart(s, 'forest'); + assert.deepEqual(s.described, []); + assert.equal(s.replies_in_scene, 0); +}); + +test('the instructions: no tools, "my lighthouse", you not names, and no invented places', () => { + const text = bramInstructions([{ name: 'Snaggle', bot: false }, { name: 'Pixel', bot: true }]); + assert.match(text, /Say it as "my lighthouse"/); + assert.match(text, /You have no tools/); + assert.doesNotMatch(text, /next_scene|take_item|use_item|end_story/); + assert.match(text, /never describe the party being anywhere but where the note says/); + assert.match(text, /Speak to the player as "you"/); + assert.match(text, /There is one human player: after your greeting never use their name at all/); +}); + +test('names: items normalised; tool names still kept out of speech; corrections parsed; the name check finds a reply that uses it', () => { + assert.equal(normalizeItem('The Brass Key'), 'brass_key'); + assert.equal(normalizeItem('iron chest'), 'chest'); + assert.equal(normalizeItem(7), undefined); + assert.ok(TOOL_NAMES.includes('take_item')); + assert.equal(cleanSpeech('You pick it up. take_item("key") and go').removed, true); + assert.equal(parseNameCorrection("I'm Snaggle."), 'Snaggle'); + assert.equal(parseNameCorrection("I'm going to the door"), undefined); + assert.equal(parseNameCorrection('My name is Snaggle'), 'Snaggle'); + assert.equal(parseNameCorrection('Call me Snaggle, please'), 'Snaggle'); + assert.equal(parseNameCorrection('I am Priya and I want the key'), 'Priya'); + // Not introductions: a day, a possessive, a character, a feeling + for (const text of ["It's Tuesday", "This is Pixel's idea", "It's Bram", "This is Pixel", "I'm Tired", "I'm Pixel", "my name is Tuesday", "It's Snaggle"]) assert.equal(parseNameCorrection(text), undefined, text); + assert.equal(usesName('Snaggle, the way is before you.', 'Snaggle'), true); + assert.equal(usesName('The way is before you.', 'Snaggle'), false); +}); + +test('Pixel: lines fit the place and the satchel, with a cooldown, and it skips when nothing fits', () => { + const cooldown = new Map(); + const random = () => 0; + // an empty satchel never gets a line about the Lantern or the key + const taken: string[] = []; + const cave = at('cave'); + for (let turn = 0; turn < 40; turn++) { const l = pickGesture(cave, cooldown, turn * 100, random); if (l) taken.push(l); } + assert.ok(taken.length > 0); + assert.ok(taken.every((l) => !/holds the Lantern up/.test(l))); + // lines about something lying here stop once it is taken + assert.ok(Object.values(SCENE_LINES).flat().some((l) => l.here)); + const oak = at('oak', ['brass_key']); + for (let turn = 0; turn < 30; turn++) assert.doesNotMatch(pickGesture(oak, new Map(), turn * 100, () => Math.random()) ?? '', /brass key on the shelf/); + // cooldown: the same line is not repeated within COOLDOWN_TURNS, then it comes back + const c2 = new Map(); + const first = pickGesture(at('oak'), c2, 0, random)!; + for (let turn = 1; turn < COOLDOWN_TURNS; turn++) assert.notEqual(pickGesture(at('oak'), c2, turn, random), first); + // a place whose lines are all cooling down: Pixel skips + const c3 = new Map(); + for (const line of [...SCENE_LINES.oak, ...GENERIC_LINES]) c3.set(line.text, 10); + assert.equal(pickGesture(at('oak'), c3, 11, random), undefined); + assert.deepEqual(chooseGesture(at('oak'), c3, 11, random), { reason: 'cooldown' }); +}); + +test('an exit the player names that does not exist is refused, not guessed; flint and wick are one take', () => { + const w = at('cave'); + const r = applyActions(w, act({ blocked: 'the shore path' })); + assert.equal(r.moved, false); + assert.equal(w.location, 'cave'); + assert.match(r.outcomes[0], /no way to the shore path from here.*rowing the boat/); + assert.deepEqual(parseActions('{"move": null, "blocked": "the hollow oak", "take": [], "use": [], "give": []}').blocked, 'the hollow oak'); + const v = at('tavern', ['brass_key']); + v.chest_open = true; + const t = applyActions(v, act({ take: ['flint', 'wick'] })); + assert.equal(t.outcomes.length, 1); + assert.deepEqual(v.satchel, ['brass_key', 'flint_and_wick']); + assert.match(actionPrompt(v, 'x').system, /Never pick the nearest exit as a guess/); + assert.match(applyActions(at('tavern'), act({ take: ['chest'] })).outcomes[0], /bolted to the floor/); +}); + +test('test starts: STORY_START puts the party elsewhere with the map', () => { + assert.equal(worldAt('cave').location, 'cave'); + assert.deepEqual(worldAt('cave').satchel, ['map']); + assert.equal(worldAt(undefined).location, 'tavern'); + assert.equal(worldAt('nowhere').location, 'tavern'); + assert.deepEqual(worldAt('lighthouse', 'lantern,bogus').satchel, ['map', 'lantern']); + assert.equal(ITEMS.length, 4); +}); + +test('presence floor: every place has generic lines that need nothing, so Pixel never runs dry; the reason for a skip is named', () => { + assert.ok(GENERIC_LINES.length >= 3 && GENERIC_LINES.every((l) => !l.needs && !l.here)); + for (const place of Object.keys(PLACES) as Array) { + // an empty-handed party, even with every place line cooling down, still has the generic lines + const cool = new Map(); + for (const l of SCENE_LINES[place]) cool.set(l.text, 5); + const choice = chooseGesture(at(place), cool, 6, () => 0); + assert.ok(choice.line, `${place}: ${JSON.stringify(choice)}`); + assert.ok(GENERIC_LINES.some((l) => l.text === choice.line)); + } + // nothing eligible at all is its own reason (a world where no line fits cannot happen with generics, so test the cooldown path and the empty-pool wording) + const all = new Map(); + for (const l of [...SCENE_LINES.cave, ...GENERIC_LINES]) all.set(l.text, 0); + assert.equal(chooseGesture(at('cave'), all, 1).reason, 'cooldown'); +}); + +test('addressing Pixel: detected in the words and flagged by the resolver; an item given to Pixel joins the shared satchel', () => { + for (const words of ['Ask the pixel what he thinks.', 'Pixel, what do you think?', 'give Pixel the map', 'ask pixle']) assert.equal(addressesPixel(words), true, words); + assert.equal(addressesPixel('I look at the pixelated map'), false); + assert.equal(parseActions('{"move": null, "addressed": "Pixel", "take": [], "use": [], "give": [{"item": "map", "to": "pixel"}]}').addressed, 'pixel'); + const p = actionPrompt(newWorld(), 'ask pixel', true); + assert.match(p.user, /Pixel, a mute traveller, is in the party/); + assert.match(p.system, /"addressed": "pixel" or null/); + assert.doesNotMatch(actionPrompt(newWorld(), 'x', false).user, /Pixel, a mute traveller/); + const w = newWorld(); + const r = applyActions(w, act({ give: [{ item: 'map', to: 'Pixel' }] })); + assert.deepEqual(w.satchel, ['map']); + assert.match(r.outcomes[0], /gave the salt-stained map to Pixel, who carries it/); + // Pixel answers: handed an item it takes it; otherwise a response or a pointer at something here + assert.match(respondLine(w, 'the salt-stained map'), /Pixel takes the salt-stained map with a small bow/); + const answers = new Set(); + for (let i = 0; i < 60; i++) answers.add(respondLine(at('cave'), undefined)); + assert.ok([...answers].every((a) => RESPONDING_LINES.some((l) => l.text === a) || a === POINTING_RESPONSES.cave)); + assert.ok(answers.has(POINTING_RESPONSES.cave)); + assert.match(placeNote(w, { full: false, replies: 1, extra: ['The player spoke to Pixel, the mute traveller.'] }), /spoke to Pixel/); +}); + +test('a garbled "give pixel to map" still names the item, so the code can make the give itself', () => { + assert.equal(itemNamed('Give pixel to map.'), 'map'); + assert.equal(itemNamed('hand Pixel the brass key'), 'brass_key'); + assert.equal(itemNamed('give pixel a hug'), undefined); +}); + +test('Pixel is never in the turn rotation: with any number of humans, only humans get the turn', () => { + const players = [{ identity: 'web-1', name: 'Gandalf', bot: false }, { identity: 'bot-pixel', name: 'Pixel', bot: true }, { identity: 'web-2', name: 'Strider', bot: false }]; + const s: TurnState = { scene_index: 1, inputs: 0, input_since_call: false, last_reply: '', rotation: -1, ending: false }; + const order: string[] = []; + for (let i = 0; i < 12; i++) order.push(onPlayout(s, players)!.name); + assert.ok(!order.includes('Pixel'), order.join(',')); + assert.deepEqual(order.slice(0, 4), ['Gandalf', 'Strider', 'Gandalf', 'Strider']); + // one human: the turn always goes back to them + const one: TurnState = { scene_index: 1, inputs: 0, input_since_call: false, last_reply: '', rotation: -1, ending: false }; + for (let i = 0; i < 5; i++) assert.equal(onPlayout(one, [players[0], players[1]])!.name, 'Gandalf'); +}); + +test('Pixel lines follow the puzzle flags: no tug at a chest that is open, no "nearly home" once the Lantern is lit', () => { + const open = at('tavern'); + open.chest_open = true; + for (let i = 0; i < 60; i++) assert.doesNotMatch(pickGesture(open, new Map(), 0, () => Math.random()) ?? '', /puzzled tug/); + const shut = at('tavern'); + const seen = new Set(); + for (let i = 0; i < 200; i++) seen.add(pickGesture(shut, new Map(), 0, () => Math.random()) ?? ''); + assert.ok([...seen].some((l) => /puzzled tug/.test(l))); + assert.ok(![...seen].some((l) => /open chest/.test(l))); + const lit = at('lighthouse', ['lantern']); + lit.lantern_lit = true; + for (let i = 0; i < 60; i++) assert.doesNotMatch(pickGesture(lit, new Map(), 0, () => Math.random()) ?? '', /nearly home|dark lamp/); + assert.ok(Object.values(SCENE_LINES).every((lines) => lines.length <= 3), 'few, better lines'); +}); + +test('destinations: "Go through the door into the Drowned Bell" from the forest is the inn path, not the oak door', () => { + const forest = at('forest'); + const m = matchDestination(forest, 'Go through the door into the drowned bell.'); + assert.equal(m?.exit?.id, 'inn_path'); + assert.equal(matchDestination(forest, 'head back to the inn')?.exit?.id, 'inn_path'); + assert.equal(matchDestination(forest, 'we go to the lighthouse')?.exit?.id, 'headland_track'); + assert.equal(matchDestination(forest, 'walk into the cave under the mere')?.exit?.id, 'rope_bridge'); + assert.equal(matchDestination(forest, 'go into the hollow oak')?.exit?.id, 'oak_door'); + // a destination with no direct exit from here: named, with no exit + const cave = at('cave'); + const nope = matchDestination(cave, 'go back to the inn'); + assert.equal(nope?.exit, undefined); + assert.equal(nope?.destination?.name, 'The Drowned Bell'); + // no word of movement, no move; and the current place is not a destination + assert.equal(matchDestination(forest, 'look at the inn sign'), undefined); + assert.equal(matchDestination(forest, 'go deeper into the wood'), undefined); + // the prompt shows each exit with its destination and what it is called + const p = actionPrompt(forest, 'x'); + assert.match(p.user, /inn_path: .*leads to The Drowned Bell \(also called the drowned bell, drowned bell, the inn/); + assert.match(p.system, /destination outweighs words like "door" or "path"/); +}); + +test('a blocked move names the real ways out by destination', () => { + const w = at('forest'); + const r = applyActions(w, act({ blocked: 'the tone' })); + assert.equal(r.blocked_move, true); + assert.match(r.outcomes[0], /From here the party can go to: The Hollow Oak \(the small door in the hollow oak\); The Cave under the Mere/); + assert.match(r.outcomes[0], /The Drowned Bell \(the lit windows/); + assert.match(exitsByDestination(at('oak')), /The Hollow Wood \(the small door leads back out/); + const bad = applyActions(at('cave'), act({ move: 'north_door' })); + assert.equal(bad.blocked_move, true); + assert.match(bad.outcomes[0], /The Hollow Wood.*The Lighthouse/); +}); + +const everything = (w: World, extra = '') => [placeNote(w, { full: true, arriving: true }), placeNote(w, { full: false, described: [], replies: 1 }), sightsOf(w).join(', '), cluesOf(w).join('; '), extra].join(' | '); + +test('state-built descriptions: the static place text names no item and no puzzle state', () => { + for (const place of Object.values(PLACES)) { + const fixed = [place.place, ...place.ambient].join(' '); + assert.doesNotMatch(fixed, /\b(map|key|chest|lantern|flint|wick|locked|unlit|dark lamp)\b/i, `${place.id}: ${fixed}`); + } +}); + +test('the tavern before and after the chest is opened: locked, then open with the flint and wick until taken', () => { + const w = newWorld(); + assert.match(everything(w), /small iron chest under the bench, locked/); + assert.match(everything(w), /chest is locked and needs a key/); + assert.match(placeNote(w, { full: true }), /iron chest is here, locked/); + w.satchel.push('brass_key'); + applyActions(w, act({ use: [{ item: 'key', target: 'chest' }] })); + const opened = everything(w); + assert.doesNotMatch(opened, /locked|needs a key/i); + assert.match(opened, /iron chest under the bench, open, with flint and a wick inside/); + assert.match(opened, /iron chest is here, open/); + assert.match(opened, /Lying here, not yet taken: .*flint and wick/); + assert.match(actionPrompt(w, 'x').user, /chest is here, open/); + // once the flint and wick are taken the open chest is empty, and nothing says locked + applyActions(w, act({ take: ['flint and wick'] })); + const empty = everything(w); + assert.match(empty, /open and empty/); + assert.doesNotMatch(empty, /locked|needs a key|flint and a wick inside/i); +}); + +test('a taken item is no longer described where it lay: the map, the key, the Lantern', () => { + const tavern = newWorld(); + assert.match(sightsOf(tavern).join(', '), /salt-stained map on the table/); + applyActions(tavern, act({ take: ['map'] })); + assert.doesNotMatch(everything(tavern), /map on the table|Lying here, not yet taken: the salt-stained map/); + const oak = at('oak'); + assert.match(everything(oak), /small brass key on a root shelf/); + assert.match(everything(oak), /right size for a small lock/); + applyActions(oak, act({ take: ['key'] })); + assert.doesNotMatch(everything(oak), /brass key on a root shelf|right size for a small lock/); + assert.match(placeNote(oak, { full: true }), /Nothing here is left to take/); + const cave = at('cave'); + assert.match(everything(cave), /Lantern of Hollow Mere on a stone ledge, unlit/); + applyActions(cave, act({ take: ['lantern'] })); + assert.doesNotMatch(everything(cave), /on a stone ledge, unlit|cold and unlit/); + assert.match(placeNote(cave, { full: true }), /In the satchel: the Lantern of Hollow Mere/); +}); + +test('the lighthouse lamp is dark until the Lantern is lit, then described as lit', () => { + const w = at('lighthouse', ['lantern', 'flint_and_wick']); + assert.match(sightsOf(w).join(', '), /great lamp, dark/); + applyActions(w, act({ use: [{ item: 'flint and wick', target: 'lantern' }] })); + const lit = everything(w); + assert.match(lit, /great lamp blazing, lit from the Lantern's flame/); + assert.doesNotMatch(lit, /lamp, dark/); + assert.doesNotMatch(sightsOf(at('lighthouse')).join(' '), /chest/i); +}); + +test('a changed thing counts as new: the chest now open may be mentioned once, though the locked chest was already described', () => { + const s: TurnState = { scene_index: 0, inputs: 0, input_since_call: false, last_reply: '', rotation: -1, ending: false }; + const w = newWorld(); + s.world = w; + onSceneStart(s, 'tavern'); + onBramReply(s, 'A small iron chest sits under the bench, locked.'); + assert.ok(s.described!.includes('a small iron chest under the bench, locked')); + w.satchel.push('brass_key'); + applyActions(w, act({ use: [{ item: 'key', target: 'chest' }] })); + const note = placeNote(w, { full: false, described: s.described, replies: 1 }); + assert.match(note, /Not yet mentioned:.*iron chest under the bench, open/); + assert.doesNotMatch(note, /locked/); +}); + +test('Pixel lines use the same state: no tap at a map that was taken, no pointing at a key that is gone', () => { + const tavern = newWorld(); + applyActions(tavern, act({ take: ['map'] })); + for (let i = 0; i < 80; i++) assert.doesNotMatch(pickGesture(tavern, new Map(), 0, () => Math.random()) ?? '', /taps the salt-stained map/); + const oak = at('oak', ['brass_key']); + for (let i = 0; i < 80; i++) assert.doesNotMatch(pickGesture(oak, new Map(), 0, () => Math.random()) ?? '', /brass key on the shelf/); +}); + +// ---- Lighting the Lantern: decided on the player's words as well as the resolver's reading ---- + +const lightWith = (w: World, words: string, a: Actions = noActions()) => { + addLightingFromWords(w, words, a); + return applyActions(w, a); +}; + +test('at the lighthouse with the Lantern and the flint and wick, any request to light it lights it, whatever the resolver said', () => { + for (const words of ['Can we light the lantern with the', 'Can we now light the lighthouse?', 'light the lamp', "Let's light the beacon", 'I want to relight the light', 'kindle the lantern please']) { + const w = at('lighthouse', ['lantern', 'flint_and_wick']); + const r = lightWith(w, words, act({ addressed: 'pixel' })); + assert.equal(r.lit, true, words); + assert.equal(w.lantern_lit, true, words); + assert.equal(endTriggered(r), true, words); + assert.ok(w.satchel.includes('lantern'), 'the Lantern is kept'); + } +}); + +test('the same words do not light it elsewhere, without both items, when already lit, or when refused', () => { + const words = 'Can we now light the lighthouse?'; + const cave = at('cave', ['lantern', 'flint_and_wick']); + assert.equal(addLightingFromWords(cave, words, noActions()), false); + assert.equal(lightWith(cave, words).lit, false); + assert.equal(lightWith(at('lighthouse', ['lantern']), words).lit, false); + assert.equal(lightWith(at('lighthouse', ['flint_and_wick']), words).lit, false); + const lit = at('lighthouse', ['lantern', 'flint_and_wick']); + lit.lantern_lit = true; + assert.equal(addLightingFromWords(lit, words, noActions()), false); + assert.equal(lightWith(at('lighthouse', ['lantern', 'flint_and_wick']), "Don't light the lantern yet").lit, false); + assert.equal(lightWith(at('lighthouse', ['lantern', 'flint_and_wick']), 'What is the lamp made of?').lit, false); + // a resolver use that already lights it is not doubled + const w = at('lighthouse', ['lantern', 'flint_and_wick']); + const a = act({ use: [{ item: 'lantern', target: 'flint' }] }); + assert.equal(addLightingFromWords(w, 'light the lantern', a), false); + assert.equal(a.use.length, 1); +}); + +test('Bram cannot narrate changes the code did not make, and the lighthouse clue is a hint, not an event', () => { + const w = at('lighthouse', ['lantern', 'flint_and_wick']); + assert.match(placeNote(w, { full: true }), /Never describe the Lantern or the great lamp being lit, anything opening, or anything being taken, unless "What just happened" says so/); + assert.match(placeNote(w, { full: false }), /unless "What just happened" says so/); + const clue = cluesOf(w).join(' '); + assert.doesNotMatch(clue, /\b(is|are) lit\b|lit here/i); + assert.match(clue, /only the Lantern's flame/); +}); + +test('the Lantern is a special flame that is kept: the outcome, the sights and the closing say so', () => { + const w = at('lighthouse', ['lantern', 'flint_and_wick']); + const r = lightWith(w, 'light the lamp'); + assert.match(r.outcomes.join(' '), /Mere's own flame, and the great lamp catches from it/); + assert.match(r.outcomes.join(' '), /stays lit in the party's hands/); + assert.ok(w.satchel.includes('lantern') && w.satchel.includes('flint_and_wick')); + assert.match(closingNote(r.outcomes), /keeps the lit Lantern and carries it back down to the Drowned Bell/); + assert.match(bramInstructions([{ name: 'A', bot: false }]), /only the Mere's own flame, which the Lantern of Hollow Mere holds/); +}); diff --git a/livekit/voice-adventure/agent/tsconfig.json b/livekit/voice-adventure/agent/tsconfig.json new file mode 100644 index 0000000..e0f0717 --- /dev/null +++ b/livekit/voice-adventure/agent/tsconfig.json @@ -0,0 +1,13 @@ +{ + "include": ["src/**/*"], + "compilerOptions": { + "target": "ES2022", + "module": "nodenext", + "moduleResolution": "nodenext", + "strict": true, + "noEmit": true, + "skipLibCheck": true, + "allowImportingTsExtensions": true, + "erasableSyntaxOnly": true + } +} diff --git a/livekit/voice-adventure/package-lock.json b/livekit/voice-adventure/package-lock.json new file mode 100644 index 0000000..df44358 --- /dev/null +++ b/livekit/voice-adventure/package-lock.json @@ -0,0 +1,1783 @@ +{ + "name": "hookdeck-livekit-voice-adventure", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "hookdeck-livekit-voice-adventure", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "dotenv": "^16.3.1", + "express": "^4.18.2", + "hookdeck-cli": "3.1.0", + "livekit-server-sdk": "2.19.3", + "ts-node": "^10.9.2", + "typescript": "^5.9.2", + "yaml": "^2.9.1" + }, + "devDependencies": { + "@material-symbols/svg-400": "0.47.4", + "@types/express": "^4.17.21", + "@types/node": "^22.0.0", + "esbuild": "0.25.9", + "gsap": "3.15.0", + "playwright": "1.55.0" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@bufbuild/protobuf": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.10.1.tgz", + "integrity": "sha512-wJ8ReQbHxsAfXhrf9ixl0aYbZorRuOWpBNzm8pL8ftmSxQx/wnJD5Eg861NwJU/czy2VXFIebCeZnZrI9rktIQ==", + "license": "(Apache-2.0 AND BSD-3-Clause)" + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz", + "integrity": "sha512-OaGtL73Jck6pBKjNIe24BnFE6agGl+6KxDtTfHhy1HmhthfKouEcOhqpSL64K4/0WCtbKFLOdzD/44cJ4k9opA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.9.tgz", + "integrity": "sha512-5WNI1DaMtxQ7t7B6xa572XMXpHAaI/9Hnhk8lcxF4zVN4xstUgTlvuGDorBguKEnZO70qwEcLpfifMLoxiPqHQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.9.tgz", + "integrity": "sha512-IDrddSmpSv51ftWslJMvl3Q2ZT98fUSL2/rlUXuVqRXHCs5EUF1/f+jbjF5+NG9UffUDMCiTyh8iec7u8RlTLg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.9.tgz", + "integrity": "sha512-I853iMZ1hWZdNllhVZKm34f4wErd4lMyeV7BLzEExGEIZYsOzqDWDf+y082izYUE8gtJnYHdeDpN/6tUdwvfiw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.9.tgz", + "integrity": "sha512-XIpIDMAjOELi/9PB30vEbVMs3GV1v2zkkPnuyRRURbhqjyzIINwj+nbQATh4H9GxUgH1kFsEyQMxwiLFKUS6Rg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.9.tgz", + "integrity": "sha512-jhHfBzjYTA1IQu8VyrjCX4ApJDnH+ez+IYVEoJHeqJm9VhG9Dh2BYaJritkYK3vMaXrf7Ogr/0MQ8/MeIefsPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.9.tgz", + "integrity": "sha512-z93DmbnY6fX9+KdD4Ue/H6sYs+bhFQJNCPZsi4XWJoYblUqT06MQUdBCpcSfuiN72AbqeBFu5LVQTjfXDE2A6Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.9.tgz", + "integrity": "sha512-mrKX6H/vOyo5v71YfXWJxLVxgy1kyt1MQaD8wZJgJfG4gq4DpQGpgTB74e5yBeQdyMTbgxp0YtNj7NuHN0PoZg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.9.tgz", + "integrity": "sha512-HBU2Xv78SMgaydBmdor38lg8YDnFKSARg1Q6AT0/y2ezUAKiZvc211RDFHlEZRFNRVhcMamiToo7bDx3VEOYQw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.9.tgz", + "integrity": "sha512-BlB7bIcLT3G26urh5Dmse7fiLmLXnRlopw4s8DalgZ8ef79Jj4aUcYbk90g8iCa2467HX8SAIidbL7gsqXHdRw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.9.tgz", + "integrity": "sha512-e7S3MOJPZGp2QW6AK6+Ly81rC7oOSerQ+P8L0ta4FhVi+/j/v2yZzx5CqqDaWjtPFfYz21Vi1S0auHrap3Ma3A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.9.tgz", + "integrity": "sha512-Sbe10Bnn0oUAB2AalYztvGcK+o6YFFA/9829PhOCUS9vkJElXGdphz0A3DbMdP8gmKkqPmPcMJmJOrI3VYB1JQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.9.tgz", + "integrity": "sha512-YcM5br0mVyZw2jcQeLIkhWtKPeVfAerES5PvOzaDxVtIyZ2NUBZKNLjC5z3/fUlDgT6w89VsxP2qzNipOaaDyA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.9.tgz", + "integrity": "sha512-++0HQvasdo20JytyDpFvQtNrEsAgNG2CY1CLMwGXfFTKGBGQT3bOeLSYE2l1fYdvML5KUuwn9Z8L1EWe2tzs1w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.9.tgz", + "integrity": "sha512-uNIBa279Y3fkjV+2cUjx36xkx7eSjb8IvnL01eXUKXez/CBHNRw5ekCGMPM0BcmqBxBcdgUWuUXmVWwm4CH9kg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.9.tgz", + "integrity": "sha512-Mfiphvp3MjC/lctb+7D287Xw1DGzqJPb/J2aHHcHxflUo+8tmN/6d4k6I2yFR7BVo5/g7x2Monq4+Yew0EHRIA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.9.tgz", + "integrity": "sha512-iSwByxzRe48YVkmpbgoxVzn76BXjlYFXC7NvLYq+b+kDjyyk30J0JY47DIn8z1MO3K0oSl9fZoRmZPQI4Hklzg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.9.tgz", + "integrity": "sha512-9jNJl6FqaUG+COdQMjSCGW4QiMHH88xWbvZ+kRVblZsWrkXlABuGdFJ1E9L7HK+T0Yqd4akKNa/lO0+jDxQD4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.9.tgz", + "integrity": "sha512-RLLdkflmqRG8KanPGOU7Rpg829ZHu8nFy5Pqdi9U01VYtG9Y0zOG6Vr2z4/S+/3zIyOxiK6cCeYNWOFR9QP87g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.9.tgz", + "integrity": "sha512-YaFBlPGeDasft5IIM+CQAhJAqS3St3nJzDEgsgFixcfZeyGPCd6eJBWzke5piZuZ7CtL656eOSYKk4Ls2C0FRQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.9.tgz", + "integrity": "sha512-1MkgTCuvMGWuqVtAvkpkXFmtL8XhWy+j4jaSO2wxfJtilVCi0ZE37b8uOdMItIHz4I6z1bWWtEX4CJwcKYLcuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.9.tgz", + "integrity": "sha512-4Xd0xNiMVXKh6Fa7HEJQbrpP3m3DDn43jKxMjxLLRjWnRsfxjORYJlXPO4JNcXtOyfajXorRKY9NkOpTHptErg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.9.tgz", + "integrity": "sha512-WjH4s6hzo00nNezhp3wFIAfmGZ8U7KtrJNlFMRKxiI9mxEK1scOMAaa9i4crUtu+tBr+0IN6JCuAcSBJZfnphw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.9.tgz", + "integrity": "sha512-mGFrVJHmZiRqmP8xFOc6b84/7xa5y5YvR1x8djzXpJBSv/UsNK6aqec+6JDjConTgvvQefdGhFDAs2DLAds6gQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.9.tgz", + "integrity": "sha512-b33gLVU2k11nVx1OhX3C8QQP6UHQK4ZtN56oFWvVXvz2VkDoe6fbG8TOgHFxEvqeqohmRnIHe5A1+HADk4OQww==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.9.tgz", + "integrity": "sha512-PPOl1mi6lpLNQxnGoyAfschAodRFYXJ+9fs6WHXz7CSWKbOqiMZsubC+BQsVKuul+3vKLuwTHsS2c2y9EoKwxQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@livekit/protocol": { + "version": "1.53.0", + "resolved": "https://registry.npmjs.org/@livekit/protocol/-/protocol-1.53.0.tgz", + "integrity": "sha512-dM562Q7sEQbJ9ZghjIpcVuRxRApGNwJW/JfXRub+dJT8J1cC2Tep0SyYkDzOawix7+0x969fnjXt0qEZOxkjbQ==", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.10.0" + } + }, + "node_modules/@material-symbols/svg-400": { + "version": "0.47.4", + "resolved": "https://registry.npmjs.org/@material-symbols/svg-400/-/svg-400-0.47.4.tgz", + "integrity": "sha512-o6vhGUH7Lk6epJkDJevmjRF2vQz2ognSlJujHW5O10S/2CTwVD+CRxCePfgj3tF0GVwhJMkd8qCMYUCfAEhXkg==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.13.tgz", + "integrity": "sha512-gcLdvR9HO1ZJBypsOGqaP6TFEzb6vIta0KSTLt9NAQ6pXQO3cRgSVyCN6pzYqI9DlJgY71XKO0dpDhCf08b3pg==", + "license": "MIT" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "license": "MIT" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "license": "MIT" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "license": "MIT" + }, + "node_modules/@types/body-parser": { + "version": "1.19.6", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/express": { + "version": "4.17.25", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.25.tgz", + "integrity": "sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "^1" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.19.9", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.9.tgz", + "integrity": "sha512-QP2ESEe/ImWY0HDwNAnK9PvEffUyhLTnWkk7KXzHfyeWAnlrDe1fN77bXl6ia8KT3wPlmA7t9/VPRpnf4Ex9sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/http-errors": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/mime": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/qs": { + "version": "6.15.1", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.15.1.tgz", + "integrity": "sha512-GZHUBZR9hckSUhrxmp1nG6NwdpM9fCunJwyThLW1X3AyHgd9IlHb6VANpQQqDr2o/qQp6McZ3y/IA2rVzKzSbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", + "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.10", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.10.tgz", + "integrity": "sha512-tRs1dB+g8Itk72rlSI2ZrW6vZg0YrLI81iQSTkMmOqnqCaNr/8Ek4VwWcN5vZgCYWbg/JJSGBlUaYGAOP73qBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*", + "@types/send": "<1" + } + }, + "node_modules/@types/serve-static/node_modules/@types/send": { + "version": "0.17.6", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.6.tgz", + "integrity": "sha512-Uqt8rPBE8SY0RK8JB1EzVOIZ32uqy8HwdxCnoCOsYrvnswqmFZ/k+9Ikidlk/ImhsdvBsloHbAlewb2IEBV/Og==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.5", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.5.tgz", + "integrity": "sha512-HEHNfbars9v4pgpW6SO1KSPkfoS0xVOM/9UzkJltjlsHZmJasxg8aXkuZa7SMf8vKGIBhpUsPluQSqhJFCqebw==", + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "license": "MIT" + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/body-parser": { + "version": "1.20.9", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz", + "integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.16.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/diff": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz", + "integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz", + "integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz", + "integrity": "sha512-CRbODhYyQx3qp7ZEwzxOk4JBqmD/seJrzPa/cGjY1VtIn5E09Oi9/dB4JwctnfZ8Q8iT7rioVv5k/FNT/uf54g==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.9", + "@esbuild/android-arm": "0.25.9", + "@esbuild/android-arm64": "0.25.9", + "@esbuild/android-x64": "0.25.9", + "@esbuild/darwin-arm64": "0.25.9", + "@esbuild/darwin-x64": "0.25.9", + "@esbuild/freebsd-arm64": "0.25.9", + "@esbuild/freebsd-x64": "0.25.9", + "@esbuild/linux-arm": "0.25.9", + "@esbuild/linux-arm64": "0.25.9", + "@esbuild/linux-ia32": "0.25.9", + "@esbuild/linux-loong64": "0.25.9", + "@esbuild/linux-mips64el": "0.25.9", + "@esbuild/linux-ppc64": "0.25.9", + "@esbuild/linux-riscv64": "0.25.9", + "@esbuild/linux-s390x": "0.25.9", + "@esbuild/linux-x64": "0.25.9", + "@esbuild/netbsd-arm64": "0.25.9", + "@esbuild/netbsd-x64": "0.25.9", + "@esbuild/openbsd-arm64": "0.25.9", + "@esbuild/openbsd-x64": "0.25.9", + "@esbuild/openharmony-arm64": "0.25.9", + "@esbuild/sunos-x64": "0.25.9", + "@esbuild/win32-arm64": "0.25.9", + "@esbuild/win32-ia32": "0.25.9", + "@esbuild/win32-x64": "0.25.9" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.22.3", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.3.tgz", + "integrity": "sha512-Bdcs4+3qlpVlx2NRn6fgX2Ue2/gGRaPeawebgclM0ERSCqDpA+owF1fdPwjJUTAJWMTuAaxjDf+hzb0/4eKvvw==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.5", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.13", + "proxy-addr": "~2.0.7", + "qs": "~6.16.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gsap": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/gsap/-/gsap-3.15.0.tgz", + "integrity": "sha512-dMW4CWBTUK1AEEDeZc1g4xpPGIrSf9fJF960qbTZmN/QwZIWY5wgliS6JWl9/25fpTGJrMRtSjGtOmPnfjZB+A==", + "dev": true, + "license": "Standard 'no charge' license: https://gsap.com/standard-license." + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hookdeck-cli": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/hookdeck-cli/-/hookdeck-cli-3.1.0.tgz", + "integrity": "sha512-S25JhQJShoe7JwZmRiAGUEbyXRoBg8q1upTLv6Kb9cae9C0fDs4bRkJOGLFU5mTTRWVy4JcT3M1fvRynctmwXQ==", + "license": "Apache-2.0", + "bin": { + "hookdeck": "bin/hookdeck.js" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/jose": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-5.10.0.tgz", + "integrity": "sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/livekit-server-sdk": { + "version": "2.19.3", + "resolved": "https://registry.npmjs.org/livekit-server-sdk/-/livekit-server-sdk-2.19.3.tgz", + "integrity": "sha512-DRcTr/aU2759IW9aJRnM+fL3kRFbDuS7DSfwSRRP7NBByWbD58EsdGkzYFZa1Ka4g7ks1HPvEQaAmE5b6WHNPQ==", + "license": "Apache-2.0", + "dependencies": { + "@bufbuild/protobuf": "^1.10.1", + "@livekit/protocol": "1.53.0", + "jose": "^5.1.2" + }, + "engines": { + "node": ">=19" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "license": "ISC" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz", + "integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, + "node_modules/playwright": { + "version": "1.55.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.55.0.tgz", + "integrity": "sha512-sdCWStblvV1YU909Xqx0DhOjPZE4/5lJsIS84IfN9dAZfcl/CIZ5O8l3o0j7hPMjDvqoTF8ZUcc+i/GL5erstA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.55.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.55.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.55.0.tgz", + "integrity": "sha512-GvZs4vU3U5ro2nZpeiwyb0zuFaqb9sUiAJuyrWpcGouD8y9/HLgGbNRjIph7zU9D3hnPaisMl9zG9CgFi/biIg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz", + "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/qs": { + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.2.tgz", + "integrity": "sha512-VYdnB5S7/0IeXzBacUtwNAaM6d7Y/PgYnNC7bJCI6meqA/OgnsQbZMtVW8Dt2D1PHgbHGtYmhSoEIgvt7xZ2ZA==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "license": "MIT" + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/yaml": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "license": "MIT", + "engines": { + "node": ">=6" + } + } + } +} diff --git a/livekit/voice-adventure/package.json b/livekit/voice-adventure/package.json new file mode 100644 index 0000000..5f729cf --- /dev/null +++ b/livekit/voice-adventure/package.json @@ -0,0 +1,39 @@ +{ + "name": "hookdeck-livekit-voice-adventure", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "npm run build:scenes && ts-node src/server.ts", + "setup": "ts-node scripts/setup-hookdeck.ts", + "listen": "ts-node scripts/listen.ts", + "activity": "bash scripts/activity.sh", + "simulate": "ts-node scripts/simulate.ts", + "typecheck": "tsc --noEmit", + "test": "node --require ts-node/register --test test/*.test.ts", + "build:scenes": "node scripts/build-scenes.mjs", + "capture": "ts-node scenes/kit/capture/capture.ts", + "agent": "npm install --prefix agent --no-audit --no-fund --silent && npm start --prefix agent" + }, + "description": "Hookdeck + LiveKit: a multiplayer voice adventure (story night) whose room events are recorded from webhooks delivered through Event Gateway", + "license": "ISC", + "dependencies": { + "dotenv": "^16.3.1", + "express": "^4.18.2", + "hookdeck-cli": "3.1.0", + "livekit-server-sdk": "2.19.3", + "ts-node": "^10.9.2", + "typescript": "^5.9.2", + "yaml": "^2.9.1" + }, + "devDependencies": { + "@material-symbols/svg-400": "0.47.4", + "@types/express": "^4.17.21", + "@types/node": "^22.0.0", + "esbuild": "0.25.9", + "gsap": "3.15.0", + "playwright": "1.55.0" + }, + "engines": { + "node": ">=22" + } +} diff --git a/livekit/voice-adventure/public/app.js b/livekit/voice-adventure/public/app.js new file mode 100644 index 0000000..cc85597 --- /dev/null +++ b/livekit/voice-adventure/public/app.js @@ -0,0 +1,62 @@ +const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); +const time = (ms) => (ms ? new Date(ms).toLocaleTimeString() : '?'); +const dur = (s) => (s === undefined ? 'in progress' : s >= 60 ? `${Math.floor(s / 60)}m ${s % 60}s` : `${s}s`); +// Only link recordings that are web URLs; show s3:// and gs:// locations as text +const link = (l) => (/^https?:\/\//.test(l.url) ? `${esc(l.label)}` : `${esc(l.label)} ${esc(l.url)}`); + +function callCard(c) { + const people = Object.values(c.participants); + const recs = Object.values(c.recordings); + return `
+
+ ${esc(c.room_name)} + ${c.status} +
+
+ Started ${time(c.started_at)}Ended ${time(c.ended_at)}Duration ${dur(c.duration_s)} + Room ${esc(c.room_sid || 'unknown')} +
+
    ${people.map((p) => `
  • ${esc(p.name || p.identity)}${p.kind === 'AGENT' ? ' story agent' : p.kind === 'INGRESS' ? ' soundtrack' : ''} joined ${time(p.joined_at)}${p.left_at ? `, left ${time(p.left_at)}` : ''}${p.disconnect_reason ? ` (${esc(p.disconnect_reason)})` : ''}
  • `).join('') || '
  • No participants seen yet
  • '}
+ ${recs.length ? `
    ${recs.map((r) => `
  • Recording ${esc(r.egress_id)}: ${esc((r.status || '').replace('EGRESS_', '').toLowerCase())}${r.links.map((l) => ` - ${link(l)}`).join('')}${r.error ? ` ${esc(r.error)}` : ''}
  • `).join('')}
` : ''} +
`; +} + +function chronicleCard(c) { + return `
+
+ ${esc(c.room_name)} + ${c.status} +
+
+ Players: ${c.players.length ? c.players.map(esc).join(', ') : 'none yet'}Scenes: ${c.scenes}${c.length_s !== undefined ? `Length ${dur(c.length_s)}` : ''} +
+
    ${c.lines.map((l) => `
  • ${new Date(l.at).toLocaleTimeString()} ${esc(l.text)}
  • `).join('')}
+
`; +} + +async function refresh() { + const [calls, deliveries, chronicle] = await Promise.all([fetch('/api/calls').then((r) => r.json()), fetch('/api/deliveries').then((r) => r.json()), fetch('/api/chronicle').then((r) => r.json())]); + document.getElementById('chronicle').innerHTML = chronicle.length ? chronicle.map(chronicleCard).join('') : '

No session yet. Join a call and the chronicle fills in as the webhooks arrive.

'; + document.getElementById('calls').innerHTML = calls.length ? calls.map(callCard).join('') : '

No calls yet. Select Join a call above and the events appear here.

'; + document.getElementById('deliveries').innerHTML = deliveries.map((d) => + `${new Date(d.received_at).toLocaleTimeString()}${esc(d.event || '-')}${esc(d.event_id || '-')}${d.verified ? (d.duplicate ? 'duplicate' : 'applied') : `rejected: ${esc(d.error)}`}`).join(''); +} + +async function loadChaos() { + const state = await (await fetch('/api/state')).json(); + document.getElementById('chaosState').textContent = state.fail_next || state.delay_seconds + ? `Active: fail next ${state.fail_next}, delay ${state.delay_seconds}s` + : ''; +} + +document.getElementById('chaosBtn').addEventListener('click', async () => { + await fetch('/api/chaos', { + method: 'POST', headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ fail_next: document.getElementById('failNext').value, delay_seconds: document.getElementById('delay').value }), + }); + loadChaos(); +}); + +refresh(); +loadChaos(); +setInterval(() => { if (document.getElementById('autoRefresh').checked) { refresh(); loadChaos(); } }, 2000); diff --git a/livekit/voice-adventure/public/call.js b/livekit/voice-adventure/public/call.js new file mode 100644 index 0000000..03c7bfb --- /dev/null +++ b/livekit/voice-adventure/public/call.js @@ -0,0 +1,411 @@ +// Join a call from the browser with livekit-client and a token the server minted. The API key and +// secret stay on the server: the token can join one room for 10 minutes. +// Pinned exact version, loaded as an ES module from esm.sh (no build step). +import { Room, RoomEvent, Track } from 'https://esm.sh/livekit-client@2.24.0'; + +const $ = (id) => document.getElementById(id); +const say = (text) => { $('callStatus').textContent = text; $('callStatus').dataset.themed = ''; }; +// A status line built from theme wording is rebuilt when the theme changes +let say_themed = () => {}; +const say_copy = (key, fallback, vars) => { const draw = () => { $('callStatus').textContent = T(key, fallback, vars); }; draw(); $('callStatus').dataset.themed = '1'; say_themed = draw; }; +const fail = (text) => { const m = $('callMessage'); m.hidden = !text; m.textContent = text || ''; m.className = 'message body-s error'; }; +let room = null; +let room_name = null; +let my_identity = null; +// An invite link (`?room=story-...`) joins the story that is already running; without one, Join starts a new story +let invite_room = new URLSearchParams(location.search).get('room'); + +// Remote audio (the innkeeper, the storyteller, other players, the scene soundtrack) plays through hidden