Commit Graph

40 Commits

Author SHA1 Message Date
Johannes Merz b64aaab40a fix: WS upgrade auth — multi-token bearer not validated
Problem: isAuthenticated() for WS upgrade only checked legacy single token.
iOS bearer token (from POST /pair → createToken()) was rejected → 403 on WS.

Fix:
- warmTokenCache(): pre-load all multi-tokens into a sync Set on startup
- validateBearerSync(): O(1) sync lookup against the cache
- createToken(): adds to cache immediately on creation
- isAuthenticated(): checks validateBearerSync() as third fallback
2026-05-16 03:12:43 +02:00
Johannes Merz 38cad794e2 feat: tsconfig.json + npm run typecheck
- tsconfig.json simulates pi's ESM TypeScript runtime
- Resolves peer deps from pi's global node_modules
- 'type: module' added to package.json (correct — pi loads as ESM)
- Fixes found by tsc:
  - buffer/writer.ts: correct Dirent import from node:fs
  - messages.ts: toolCall id/name may be undefined, default to empty string
- Remaining warnings: pi event API names (session_switch etc.) not in types;
  these are guarded with try/catch at runtime — acceptable
- npm run typecheck: tsc --noEmit
2026-05-16 03:08:02 +02:00
Johannes Merz 920f6d8fc3 fix: import readBody+sendJson in server.ts — POST /pair was crashing 2026-05-16 03:04:07 +02:00
Johannes Merz 571cf8c9ec feat: GET /pair-qr endpoint — QR code in terminal, fix double-port bug 2026-05-16 02:56:06 +02:00
Johannes Merz 1f36636e06 feat: POST /pair endpoint + async bearer token auth
- POST /pair: consumes one-time pairingToken, creates named bearer token,
  returns { bearerToken, sidecarId } per IC-3
- isAuthenticatedAsync(): checks legacy token + new multi-token store
- isAuthenticated(): extended with Bearer header support for WS upgrade
- Smoke still 12/12 green
2026-05-16 02:46:15 +02:00
Johannes Merz 911d3f7625 feat(T-1.8/1.9): stream integration smoke, operator guide, Phase 1 complete
- T-1.8: stream.test.mjs — session CRUD, WS stream attach, send-keys,
  marker observation, reconnect+delta replay, thumbnail, delete. 12/12 green.
- T-1.9: docs/reference/OPERATOR.md — full operator guide; README sidecar section.
- Fix: tmux/control.ts -CC → -C (passthrough mode bypassed %output events).
- Fix: tmux/input.ts + snapshot.ts drop hardcoded :0.0 pane (base-index safety).
- SYNC.md + NEXT-STEPS.md: Phase 1 marked done, Phase 2 unblocked.
2026-05-15 11:43:59 +02:00
Johannes Merz b94b668df6 feat(T-1.5/1.6/1.7): stream+input+snapshot routes, sessions CRUD, commands, side-channel, health endpoint 2026-05-15 11:35:55 +02:00
Johannes Merz db6be6dcf8 feat(T-1.10): APNs scaffold — JWT provider auth, push primitive, device-token stub 2026-05-15 11:32:05 +02:00
Johannes Merz f89abd1125 feat(T-1.4): pi adapter — events, commands, autoname 2026-05-15 11:31:36 +02:00
Johannes Merz 6f106d2411 feat(T-1.3): auth tokens, pairing, TLS, CLI (pair/auth list/revoke/name) 2026-05-15 11:30:54 +02:00
Johannes Merz 17c32e7e93 feat(T-1.2): sequence counter + disk ring-buffer writer/reader 2026-05-15 11:29:41 +02:00
Johannes Merz bd990a07ab feat(T-1.1): tmux manager, control-mode client, input, snapshot 2026-05-15 11:28:45 +02:00
jay 568931901d refactor(T-1.0): carve server.ts into server/ sub-modules
Create the modular server/ layout from PHASE-1-sidecar.md §Architecture Sketch:

  server/types.ts    — shared WsClient/WsServer/RemoteServer interfaces
  server/upgrade.ts  — WS upgrade routing per path (LEGACY /ws)
  server/server.ts   — HTTP bootstrap, middleware, LEGACY HTML routes
  server/routes/     — empty dir, placeholder for T-1.5/T-1.6/T-1.7

The original extensions/remote-control/server.ts is replaced with a
thin re-export shim so that index.ts continues to resolve
'./server.js' without changes.

All LEGACY code paths (manifest.json, icon.svg, /, /ws) are tagged
with // LEGACY: … comments. No behaviour changes. No new endpoints.

Pre-existing biome errors in auth.ts, config.ts, index.ts are
unchanged — NOT introduced by this commit.
2026-05-15 10:57:52 +02:00
jay 94b4dc7a41 fix: reconnect immediately on tab visibility (iOS) 2026-05-14 19:22:46 +02:00
jay 74fc22ddfb feat: persist auth token across server restarts
Token is stored in ~/.pi/remote-control/token (mode 600) on first start
and reused on subsequent starts — saved URLs stay valid indefinitely.
2026-05-14 19:00:31 +02:00
jay 9f8b2cc987 Revert "fix: faster WebSocket reconnect on iOS PWA"
This reverts commit c21b6c441c.
2026-05-14 18:59:13 +02:00
jay c21b6c441c fix: faster WebSocket reconnect on iOS PWA
- connection timeout after 4s (vs OS TCP default ~75s)
- visibilitychange listener: reconnect immediately when app resumes
2026-05-14 18:57:02 +02:00
jay 1b610013c3 feat: bindAddress from config + PWA support
- config: read from ~/.pi/remote-control/config.json (zerray-compatible path)
- config: add bindAddress + advertisedBaseUrl fields
- server: listen on host/port from bindAddress (default: 127.0.0.1:random)
- server: /manifest.json + /icon.svg routes (no auth, PWA)
- server: manifest-src 'self' in CSP
- html: apple-mobile-web-app meta tags + manifest/touch-icon links
- index: advertisedBaseUrl as fallback for publicBaseUrl
2026-05-14 18:51:54 +02:00
Yejun Su cff6aa693c
chore: migrate @mariozechner pi packages to @earendil-works namespace 2026-05-08 18:18:04 +08:00
Yejun Su 82c463ec27
chore(remote-control): add Biome and fix all lint warnings 2026-04-21 14:09:42 +08:00
Yejun Su 06fa1147f3
extensions/pi-remote-control -> extensions/remote-control 2026-04-21 12:51:38 +08:00
Yejun Su 8cffeb9e27
fix(remote-control): clear stale status badge on session reload 2026-03-22 00:51:10 +08:00
Yejun Su 9e92201206
feat(statusbar): show cwd with home abbreviated to ~ 2026-03-22 00:46:45 +08:00
Yejun Su 63a879046b
fix(remote-control): send utf-8 charset for plain text errors 2026-03-20 20:12:47 +08:00
Yejun Su 9821efa370
fix(remote-control): always sync on session switch even if turn started 2026-03-20 19:05:28 +08:00
Yejun Su b77c2a57b0
fix(remote-control): re-check idle state inside delayed sync callback 2026-03-20 18:51:11 +08:00
Yejun Su aacabde7dc
fix(remote-control): avoid mid-turn model resync 2026-03-20 18:39:04 +08:00
Yejun Su 0dd6960688
fix(remote-control): resync after restored model changes 2026-03-20 18:32:15 +08:00
Yejun Su 33403bd030
fix(remote-control): resync clients on session switch 2026-03-20 18:26:22 +08:00
Yejun Su f16a5fed83
fix(remote-control): use keybinding hints in info panel 2026-03-20 18:05:53 +08:00
Yejun Su 55741ff9af
fix(remote-control): use keybindings for closing info panel 2026-03-20 17:59:44 +08:00
Yejun Su ad08d297a5
fix(server): prevent shutdown hang by forcefully terminating connections
Use client.terminate() instead of client.close() to avoid waiting for
unresponsive clients to acknowledge the WebSocket close handshake.

Add a 2-second safety timeout that closes the HTTP listener, destroys
lingering sockets, and resolves the promise so session_shutdown does not
block pi from exiting.
2026-03-19 14:37:31 +08:00
Yejun Su 37dc2b2f1e
feat(ui): add stop/abort button to web remote control
When the agent is streaming, the send button becomes a red stop button
that sends a { type: "stop" } WebSocket message. The server handles this
by calling ctx.abort() to cancel the current agent operation.
2026-03-19 13:55:08 +08:00
Yejun Su 4bc4cfa630
feat(html): add markdown table rendering to inline renderer 2026-03-19 13:29:14 +08:00
Yejun Su 98642b5b5a
fix(ui): update HTML title to "π - remote-control" 2026-03-19 13:02:26 +08:00
Yejun Su 824ae6a203
fix: replace qrencode system dependency with pure-JS qrcode package
Use the 'qrcode' npm package instead of shelling out to the 'qrencode'
binary. Load via createRequire for ESM/CJS interop. Use margin: 2 to
avoid the utf8 renderer's invalid array length bug with odd margins.
2026-03-19 12:59:05 +08:00
Yejun Su be2c015b72
refactor: extract index.ts into config, auth, messages, html, and server modules 2026-03-19 12:43:31 +08:00
Yejun Su 7080cdc34f
feat(ui): replace subcommands with interactive menu
/remote-control now opens a select menu with Turn on/off,
Configure URL, and Status instead of relying on subcommands.
Adds ability to stop the server. Shows current URL in the
Configure URL menu item and in the input dialog title.
2026-03-19 12:32:26 +08:00
Yejun Su ee3341d20c
feat: add --remote-control flag, status indicator, and fix config check ordering 2026-03-19 12:10:39 +08:00
Yejun Su 18f49a6828
chore: initial commit 2026-03-19 10:41:11 +08:00