Support MoQ direct mode, reading the session from the URL - #51
Draft
kixelated wants to merge 3 commits into
Draft
Conversation
A bot run with `--moq-direct` is already on the relay before anyone opens the client, so there is no `/start` to ask where to meet it. Read the session from the page URL instead — `relay`, `ns`, `botId`, `clientId`, as the Pipecat runner prints them — and hand those to the transport as constructor options. Leaving `startBotParams` unset is what skips the POST: the base connects the transport directly when no endpoint is in play. A URL carrying `relay` also opens on the MoQ transport, since it names the session to join. Without it, MoQ still goes through `/start` unchanged. `botId`/`clientId` are passed explicitly because the transport still defaults to the older bot0/client0 pair, while the bot now publishes its broadcast as the response and reads the peer's as the request. Co-Authored-By: Claude <noreply@anthropic.com>
Everyone opening a direct-mode URL shares a namespace, so a fixed participant id meant the second visitor published over the first. Mint a random id per page load and hang both broadcast paths off it, giving each caller their own call on a shared URL. The runner watches the request prefix and starts a bot per id it sees. Path.from joins components with "/", so a slashed id needs nothing from the transport package. Co-Authored-By: Claude <noreply@anthropic.com>
Falling back to the transport's built-in `pipecat` namespace put an unscoped call on a path shared with everyone else who omitted `ns`, which on a public relay is both a collision and a disclosure. Default to empty instead, so the call sits at the relay root and `ns` is genuinely optional; the per-page session id is what keeps callers apart. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds support for MoQ direct mode, where the bot waits on the relay rather than being started by a
/startrequest. There is no rendezvous response to ask where to meet it, so the client reads the session from the page URL instead and connects the transport straight from those values.Depends on the Pipecat runner's
--moq-directflag (pipecat-ai/pipecat#5123).How
relay,ns,botId,clientIdare read from the query string, as the runner prints them, and passed toMoqTransportas constructor options. LeavingstartBotParamsunset is what skips the POST —PipecatAppBaseconnects the transport directly when no endpoint is in play, so no change was needed invoice-ui-kit.relayalso opens on the MoQ transport rather than the default, since it names the session to join.<client-id>/<uuid>,<bot-id>/<uuid>). Everyone sharing a direct-mode URL shares a namespace, so without this the second visitor publishes over the first and neither call works. The runner watches the request prefix and starts a bot per id it sees.nsis optional and defaults to empty, putting calls at the relay root. Falling back to the transport's built-inpipecatnamespace would quietly place an unscoped call on a path shared with everyone else who omitted it — on a public relay, both a collision and a disclosure.Without
relayin the URL, MoQ behaves exactly as before.botId/clientIdare passed explicitly because@pipecat-ai/moq-transportstill defaults them to the olderbot0/client0pair, while the bot now publishes its broadcast as theresponseand reads the peer's as therequest.Testing
Ran against a live
--moq-directbot: the UI opens on MoQ from the URL, connects with no/startrequest (confirmed by filtering the network log), negotiates RTVI, renders the bot's greeting, and carries typed input back to the bot over the MoQ transcript track. Two browsers on one URL each get their own bot with disjoint paths.tsc --noEmitandvite buildclean.Note that a direct-mode session also needs pipecat-ai/pipecat-client-web-transports#167 — without it the client subscribes to the bot's broadcast before the bot exists and the streams are reset.
(written by Opus 5)