feat(notepad): add persistent HTTP example and WS handoff client - #88
Open
eliteprox wants to merge 1 commit into
Open
feat(notepad): add persistent HTTP example and WS handoff client#88eliteprox wants to merge 1 commit into
eliteprox wants to merge 1 commit into
Conversation
notepad fills the persistent+HTTP cell: a held session with POST /set and POST /get, the regression target for run_capability endpoint. handoff_client.py consumes a Console reserve envelope and drives realtime-transcription funding plus the WebSocket — proof of concept only; do not ship an unscoped signer JWT.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The notepad runner’s session state handling needs to be bound to a Livepeer session identifier to avoid cross-session state leakage, and new docs include dead references to files not present in this repository.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new notepad example to cover persistent + plain HTTP runner sessions with process-local state, and introduces a session handoff spike client for the realtime-transcription example to prototype Console → client WebSocket streaming with an external funding loop.
Changes:
- Add
notepad/example app (runner + client) with Docker/Compose and documentation for persistent HTTP sessions. - Add
realtime-transcription/handoff_client.pyand document the “session handoff” spike workflow. - Update repo-level docs and CI image build workflow to include the new notepad example.
File summaries
| File | Description |
|---|---|
realtime-transcription/README.md |
Documents the new “Session handoff (spike)” flow and how to run the handoff client. |
realtime-transcription/handoff_client.py |
Adds a proof-of-concept client that consumes a handoff envelope, runs a funding loop, and streams over WebSocket. |
README.md |
Adds notepad to the transport/mode examples table and related narrative. |
notepad/runner.py |
Implements the notepad persistent HTTP runner with /set and /get endpoints. |
notepad/README.md |
Provides usage docs and explains how persistent HTTP session state is demonstrated. |
notepad/pyproject.toml |
Declares the notepad example’s Python package metadata and dependencies. |
notepad/Dockerfile |
Builds a container image for the notepad runner. |
notepad/compose.yml |
Defines an offchain orchestrator + notepad compose setup. |
notepad/compose.onchain.yml |
Adds the on-chain/signer overlay configuration for the notepad example. |
notepad/client.py |
Adds a client that reserves a session, POSTs /set then /get, then stops the session. |
notepad/.env.example |
Provides example env vars for on-chain operation and pricing caps. |
.github/workflows/images.yml |
Extends the image build matrix/paths to include the notepad example. |
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+54
to
+68
| async def _handle_set(request: web.Request) -> web.Response: | ||
| global _note, _revision | ||
| try: | ||
| payload = await request.json() | ||
| except Exception: | ||
| payload = None | ||
| if not isinstance(payload, dict): | ||
| raise web.HTTPBadRequest(text="body must be a JSON object") | ||
| _note = str(payload.get("text", "")) | ||
| _revision += 1 | ||
| return web.json_response({"text": _note, "revision": _revision}) | ||
|
|
||
|
|
||
| async def _handle_get(_request: web.Request) -> web.Response: | ||
| return web.json_response({"text": _note, "revision": _revision}) |
|
|
||
| [`handoff_client.py`](handoff_client.py) is a proof-of-concept for the Console → client streaming design: it does **not** call `reserve_session`. It reads a JSON envelope (`session_id`, `app_url`, `control_url`, `endpoint`, payment snapshot, `signer_url`, `signer_token`), runs the 3-second funding loop itself, opens `wss://` from `app_url`, and `POST`s `control_url/stop` on the way out. | ||
|
|
||
| This is not a production MCP tool. A signer JWT that can call `generate-live-payment` is unscoped today — see `gateway-web/docs/stream-session-handoff.md`. Use it only against a local envelope you minted yourself: |
Comment on lines
+6
to
+8
| drives the WebSocket and the 3-second funding loop. Do not treat a signer JWT | ||
| as production-safe until it is scoped to one manifest — see | ||
| gateway-web/docs/stream-session-handoff.md. |
Comment on lines
+128
to
+132
| try: | ||
| await asyncio.wait_for(stop.wait(), timeout=PAYMENT_INTERVAL_S) | ||
| return | ||
| except TimeoutError: | ||
| pass |
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.
Summary
notepad(livepeer-example/notepad): persistent HTTP withPOST /setandPOST /get. This fills the persistent+HTTP cell the other examples leave empty, and is the regression target for Consolerun_capabilitywithendpoint.realtime-transcription/handoff_client.py: proof-of-concept client that consumes a Console reserve envelope (session URLs + payment snapshot + signer token), runs the 3s funding loop, and streams over WebSocket. Not a production MCP tool — PymtHouse cannot scope that JWT today.Test plan
cd notepad && docker compose up -d --build && uv run client.py --text "hello from a held session"—/getreturns the same textuvx pre-commit run --fileson the touched files (black, ruff, prettier)notepad/andhandoff_client.py