Repository navigation
fix(panel): thread the tunnel bearer through every daemon call - #14
Merged
Merged
Conversation
agentproto/ts#1398 makes a remote daemon in bearer mode require the real bearer on every non-loopback route — an allowlisted Origin is no longer sufficient. Several panel call sites never sent it: the prompt POST in SessionEventsView/SessionChatView, the transcript export fetches, and the SSE/PTY streams relied on a stale "Origin is enough" assumption. Centralizes this in two helpers in use-daemon.ts (daemonFetch for Authorization: Bearer, withToken for the ?token= query form SSE/WS need) and routes every daemon-facing call through them, threading the token prop down to SessionChatView/SessionEventsView/SessionJsonView from the panel page where it was previously missing entirely. Also accepts the connection as a URL fragment (#daemon=<url>&token=<t>, paired with remote_enable's phoneUrl) alongside the existing ?daemon=&token= query form — fragments never reach a server, so they can't leak into an access log or Referer header the way a query string can. The "copy link" button now produces the fragment form and only embeds the token behind an explicit "include access token" toggle (default off).
agentiknet
added a commit
to agentproto/ts
that referenced
this pull request
Sep 25, 2026
…e enable --qr PHONE-PLAN.md P1.2. remote_enable (MCP tool and the new POST /remote/enable REST route) now also returns phoneUrl: the installed session-chat app's UI when present (<tunnel>/apps/@agentik/session-chat/ui#token=<t>), else the hosted panel fallback (https://cli.agentproto.sh/panel#daemon=<tunnel>&token=<t>). The token rides in a URL fragment, never a query string, so it never reaches a server log — matching agentproto/cli-site#14's readFragmentConnection. Omitted for passthrough tunnels, same condition as bearerToken/mcpEndpoint. Adds GET/POST /remote/status/enable/disable REST routes (RemoteController was previously MCP-only) and a new `agentproto remote enable/disable/status` CLI verb built on them, mirroring `agentproto tunnel`'s discoverDaemon() pattern. `--qr` renders phoneUrl as a terminal QR code via the existing qrcode-terminal dependency, extracted from pair.ts's printQr into a shared util so both commands use the same renderer.
agentiknet
added a commit
to agentproto/ts
that referenced
this pull request
Sep 26, 2026
…e enable --qr PHONE-PLAN.md P1.2. remote_enable (MCP tool and the new POST /remote/enable REST route) now also returns phoneUrl: the installed session-chat app's UI when present (<tunnel>/apps/@agentik/session-chat/ui#token=<t>), else the hosted panel fallback (https://cli.agentproto.sh/panel#daemon=<tunnel>&token=<t>). The token rides in a URL fragment, never a query string, so it never reaches a server log — matching agentproto/cli-site#14's readFragmentConnection. Omitted for passthrough tunnels, same condition as bearerToken/mcpEndpoint. Adds GET/POST /remote/status/enable/disable REST routes (RemoteController was previously MCP-only) and a new `agentproto remote enable/disable/status` CLI verb built on them, mirroring `agentproto tunnel`'s discoverDaemon() pattern. `--qr` renders phoneUrl as a terminal QR code via the existing qrcode-terminal dependency, extracted from pair.ts's printQr into a shared util so both commands use the same renderer.
agentiknet
added a commit
to agentproto/ts
that referenced
this pull request
Sep 26, 2026
…e enable --qr (#1402) * feat(runtime,cli): remote_enable returns a phoneUrl; agentproto remote enable --qr PHONE-PLAN.md P1.2. remote_enable (MCP tool and the new POST /remote/enable REST route) now also returns phoneUrl: the installed session-chat app's UI when present (<tunnel>/apps/@agentik/session-chat/ui#token=<t>), else the hosted panel fallback (https://cli.agentproto.sh/panel#daemon=<tunnel>&token=<t>). The token rides in a URL fragment, never a query string, so it never reaches a server log — matching agentproto/cli-site#14's readFragmentConnection. Omitted for passthrough tunnels, same condition as bearerToken/mcpEndpoint. Adds GET/POST /remote/status/enable/disable REST routes (RemoteController was previously MCP-only) and a new `agentproto remote enable/disable/status` CLI verb built on them, mirroring `agentproto tunnel`'s discoverDaemon() pattern. `--qr` renders phoneUrl as a terminal QR code via the existing qrcode-terminal dependency, extracted from pair.ts's printQr into a shared util so both commands use the same renderer. * docs(cli): add agentproto remote verb page The docs.mjs --check gate failed CI: a new verb (remote) with no docs/cli/verbs/ page is a hard error. Covers enable [--qr]/disable/status, the two phoneUrl shapes (session-chat link vs. the cli.agentproto.sh/panel fallback) and why the token rides in a URL fragment, and the post-#1398 security model (every non-loopback route needs the bearer once enabled). * chore: agentic reviewer — changeset --------- Co-authored-by: agentproto-bot <bot@agentproto.dev>
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.
Pairs with agentproto/ts#1398 (the P0 tunnel-auth fix). PHONE-PLAN.md sections P1.3 (this panel's token) and P1.2 (fragment link shape).
The problem
After ts#1398, a remote daemon in bearer mode 401s any non-loopback request that doesn't carry the real bearer — an allowlisted
Originis no longer a substitute. Several panel call sites never sent the bearer at all, so a panel connected over a tunnel would break:PromptInput's POST in bothSessionEventsView.tsx(~745) andSessionChatView.tsx(~745) — noAuthorizationheader, and notokenprop even threaded down to the component.SessionChatView's transcript export fetches (~861, ~867) andSessionJsonView's (~1226, ~1231) — same gap.use-session-events.ts's polling fetch (~144) — same gap.SessionTerminal.tsx's SSE (EventSource) already threaded?token=correctly but its own comment justified this as defense-in-depth ("the stream is ungated") rather than a requirement — now it actually is one.use-daemon.ts's ownrefresh/killSession/createTerminalSession/health-probe fetches already sent the bearer via an ad hocauthHeaders()closure.The fix
Two helpers in
src/lib/use-daemon.ts:daemonFetch(url, token, init?)— wrapsfetchwithmode:"cors", credentials:"include"and setsAuthorization: Bearer <token>when present.withToken(url, token)— appends?token=<token>(the query-string formEventSource/WebSocketneed, since they can't set headers).Every daemon-facing call now goes through one of these:
use-daemon.ts's own fetches (replacingauthHeaders()),use-session-events.ts, bothPromptInputs,SessionChatView's +SessionJsonView's export fetches, andSessionTerminal.tsx's WS/SSE URLs.tokenis now threaded as a prop frompanel/page.tsxintoSessionChatView/SessionEventsView/SessionJsonView, which previously never received it.The fragment link
Added
readFragmentConnection()alongside the existingreadLinkConnection()(?daemon=&token=, kept for back-compat): it reads#daemon=<url>&token=<t>— the shaperemote_enable's upcomingphoneUrlwill use (ts P1.2) — and scrubs it from the address bar the same way. Fragments never reach a server (no Referer, no access/proxy log, no CDN cache key), unlike a query string.The "copy link" button now produces the fragment form. Since a copied link with the token embedded grants full access to whoever opens it, the token is only included behind an explicit "include access token" checkbox (default off, disabled when there's no token to embed).
Gate
pnpm typecheckandpnpm buildboth pass (exit 0). No lockfile committed (this repo builds frompackage.jsonranges in CI — see its own workflow's comment on why).🤖 @agentproto-bot — PR · session
sess_897aba74(security: tunnel auth hardening (P0)) · claude-code / subscription · auth-profileClaude Subs Agentik· modelclaude-sonnet-5· $21.0496 (daemon) · hostmac.home· cwdagentproto/tunnel-auth-hardening