Skip to content

feat(notepad): add persistent HTTP example and WS handoff client - #88

Open
eliteprox wants to merge 1 commit into
livepeer:mainfrom
eliteprox:feat/persistent-http-notepad
Open

feat(notepad): add persistent HTTP example and WS handoff client#88
eliteprox wants to merge 1 commit into
livepeer:mainfrom
eliteprox:feat/persistent-http-notepad

Conversation

@eliteprox

Copy link
Copy Markdown

Summary

  • Add notepad (livepeer-example/notepad): persistent HTTP with POST /set and POST /get. This fills the persistent+HTTP cell the other examples leave empty, and is the regression target for Console run_capability with endpoint.
  • Add 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"/get returns the same text
  • uvx pre-commit run --files on the touched files (black, ruff, prettier)
  • Snyk Code: 0 issues on notepad/ and handoff_client.py

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.
Copilot AI lite review requested due to automatic review settings September 2, 2026 00:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.py and 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 thread notepad/runner.py
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants