Skip to content

connect-next 5/5: machine port shares on the next address (host daemon protocol 247) - #6051

Merged
SawyerHood merged 1 commit into
connect-next/4-pluginfrom
connect-next/5-machine-tunnels
Oct 21, 2026
Merged

SawyerHood merged 1 commit into
connect-next/4-pluginfrom
connect-next/5-machine-tunnels

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

After PR 4 only the server machine's own ports answer on the next address. Every other enrolled machine shares ports at https://<machine-label>--<port>.getbb.app through its host daemon's Cloudflare tunnel, and has no way onto the Fly gate. Two bugs from the live staging test are fixed here too.

PR 5 of 5 (stack: account API → server ingress → gate → plugin → machine tunnels). Based on #6050.

What changed

  • Wire change: HOST_DAEMON_PROTOCOL_VERSION 246 → 247. The session-open response carries connectNext: { generation, config }; the server pushes { type: "connect-next.replace", generation, config } to each connected daemon with a bb connect machine credential; the daemon answers { type: "connect-next.status", status }. Compatibility with the previously shipped daemon is kept deliberately and tested: HOST_DAEMON_COMPATIBLE_PROTOCOL_VERSIONS = [246, 247]; a 246 daemon gets the old session-open response and no connect-next.* message, so its Cloudflare machine tunnel works as before (hostDaemonSupportsConnectNext). (On the old branch this was 244 → 245; main moved to 246 meanwhile, so ours is 247 and 246 is the accepted previous version.)
  • apps/host-daemon/src/connect-next: runs an FrpcSupervisor from @bb/frp-client with one proxy per declared shared port at <machine-label>--<port>.<domain>, using the machine credential; refuses a config whose domain is not its enrollment's base domain or next.<base domain>, whose tunnel host is not tunnel.<domain>, or that is not wss for an https enrollment; stops after 30 s without a server session (a next-joined machine cannot hear null once next is off).
  • apps/server: host-shared-ports.ts keeps one next-tunnel config owned by a plugin and sends it; bb.hosts.internal_DO_NOT_USE_setNextTunnels, internal_DO_NOT_USE_nextTunnelStatuses, internal_DO_NOT_USE_onNextTunnelStatusChange (SDK types, fake host, docs/api_to_audit.md entry naming connect-next as the only caller). PLUGIN_SDK_VERSION 0.6.66 → 0.6.67; connect-next requires it.
  • apps/connect-next: the gate relays POST /api/connect/machine-label (machine credential) to the account API so a machine enrolled through the next address learns its label; a label is held while any of its proxies is open (machine presence, peer routing); a proxy its still-connected client removed answers 503 at once.
  • apps/host-daemon/src/connect-tunnel: machines enrolled through a next address skip the Cloudflare dial.
  • plugins/connect-next: turns machine tunnels on with the plugin, shows each machine's tunnel and shares in settings, status and CLI. plugins/connect: other machines' listings get nextUrl.
  • Staging fix: a machine enrolled through the next address listed the same https://<label>--<port>.next.<domain> as both url and nextUrl, so bb connect expose … --host <machine> printed it twice. Its listing now has only url (the next address) and no nextUrl; documented in plugins/connect/README.md, the share-server-links skill and docs/connect-next.md.
  • Staging fix (also in PR 4 for the earlier copy): the settings copy names no fixed next.getbb.app.
  • Test fixes from CI: the daemon's real-frpc test dials frps at 127.0.0.1 through a wrapped supervisor (Windows frpc cannot resolve *.localhost) and still asserts the runner prepared tunnel.next.bb.localhost; e2e-local.ts takes the live-test provider from @bb/test-helpers (LIVE_TEST_PROVIDER_ID) so core gains no provider-id literal (provider-literal ratchet).
  • packages/host-daemon-contract test: added idleProviderSessionTimeoutMinutes, which main made required, to the new session-open case.

How you verified

  • Local end to end on the top of the stack, apps/connect-next/scripts/e2e-local.sh with BB_E2E_PLAYWRIGHT_DIR (browser + MCP OAuth) and BB_E2E_OLD_DAEMON_REPO (a checkout of main 9fad6b6255, protocol 246): single gate 94/94, --two-gates 96/96, nothing skipped. Covers the next-joined machine (join through the gate, a real codex turn, shares, HMR, unexpose, off/on), a Cloudflare-joined machine (share on both addresses, next off stops its frpc), and the 246 daemon (opens a session with protocol 246, its Cloudflare share answers, it gets no next tunnel).
  • pnpm exec turbo run typecheck --filter='...[connect-next/4-plugin]': all tasks pass. pnpm exec turbo run test --filter='[connect-next/4-plugin]': @bb/host-daemon-contract 74/74 (incl. 246/247 compatibility), @bb/host-daemon 806 passed / 7 skipped (the two command-discovery failures are the stray /tmp/.git on bee; 28/28 with TMPDIR outside /tmp), @bb/server 3,646 passed / 1 skipped (incl. a protocol-246 daemon getting its Cloudflare shares and never a next message), @bb/connect-next 90/90, bb-plugin-bb--connect-next 28/28, bb-plugin-connect 143/143 (the new next-enrolled listing test fails before the fix with nextUrl present), @get-bb/plugin-sdk 390/390.
  • oxfmt --check, pnpm lint: clean.
  • CI: the full CI workflow was dispatched on this branch (the stack's top), since stacked PRs not based on main only get the base checks.

AGENT GENERATED

@SawyerHood
SawyerHood added this pull request to stack #6052 October 21, 2026 16:48
@SawyerHood
SawyerHood force-pushed the connect-next/5-machine-tunnels branch from eafc4e0 to 0e4bafe Compare October 21, 2026 16:50
@SawyerHood
SawyerHood force-pushed the connect-next/5-machine-tunnels branch from 0e4bafe to c09c4a6 Compare October 21, 2026 16:53
@SawyerHood
SawyerHood force-pushed the connect-next/5-machine-tunnels branch from c09c4a6 to dddddbc Compare October 21, 2026 17:03
…address

Host daemons run frpc for their shares at <machine-label>--<port>.<next
domain> with their machine credential. HOST_DAEMON_PROTOCOL_VERSION 247 adds
connectNext to the session-open response and connect-next.replace /
connect-next.status messages; the server still accepts protocol 246 and
never sends it next fields. bb.hosts.internal_DO_NOT_USE_setNextTunnels,
nextTunnelStatuses and onNextTunnelStatusChange; the gate relays machine
labels. A machine enrolled through the next address lists its share URL once.
@SawyerHood
SawyerHood force-pushed the connect-next/5-machine-tunnels branch from dddddbc to fb429db Compare October 21, 2026 17:13
@SawyerHood
SawyerHood merged commit af4cdf4 into main Oct 21, 2026
48 checks passed
@SawyerHood
SawyerHood deleted the connect-next/5-machine-tunnels branch October 21, 2026 17:21
alexandre-vl added a commit to alexandre-vl/bb that referenced this pull request Oct 21, 2026
Main moved the SDK to 0.6.67 (get-bb#6048, get-bb#6051), so this branch's own type
changes need the next version.
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.

1 participant