Skip to content

connect-next 4/5: frp-client and the connect-next plugin - #6050

Merged
SawyerHood merged 1 commit into
connect-next/3-gatefrom
connect-next/4-plugin
Oct 21, 2026
Merged

SawyerHood merged 1 commit into
connect-next/3-gatefrom
connect-next/4-plugin

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

With the account API (PR 1), the server ingress (PR 2) and the gate (PR 3) in place, nothing on a bb server dials the gate yet. bb needs an opt-in builtin plugin that runs frpc to the gate with the server's link credential, points it at the tunnel ingress, and serves the server machine's port shares on the next address too.

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

What changed

  • packages/frp-client (@bb/frp-client): frpc download and SHA-256 verification (frp 0.71.0), config writing (wss with a trusted CA file and server name, credential in metadatas, proxies), log redaction and an FrpcSupervisor (restart with backoff, hot reload, login-refusal handling); ./testing fixtures that run real frps and gate hooks.
  • plugins/connect-next (builtin bb--connect-next, disabled by default; registered in builtin-registry.ts, bundled plugins, bb-official.json, the bundled marketplace): requires bbPluginSdk >=0.6.66 (the ingress member from PR 2); setting enabled, RPC status/setEnabled, CLI bb connect-next status|on|off, a settings section with state, address and shared ports, and a skill. The next domain follows the bb account: next.<host of the account's base URL> (BB_CONNECT_NEXT_SERVER and BB_CONNECT_FRPC override the server and binary). It opens the server's tunnel ingress through bb.server.internal_DO_NOT_USE_openTunnelIngress and proxies <label> to it and <label>--<port> straight to 127.0.0.1:<port> for shares.
  • plugins/bb-account: bb-account.v1.connectCredential also answers bb--connect-next (read-only; adopting and refusing a pairing stay connect-only).
  • plugins/connect: connect.internal_DO_NOT_USE.serverShares / waitForServerSharesChange (long poll, answers only bb--connect-next), and share listings carry nextUrl for server-machine shares while connect next is on (bb connect expose prints it on a second line).
  • apps/server: the real-frps tunnel ingress test (moved here from PR 2 because it drives the plugin's frpc).
  • docs/configuration.md (Connect next section), turbo.json (plugin typecheck needs the SDK types).
  • Fix from the staging test: the settings section description, the enabled setting and the plugin description no longer hard-code next.getbb.app (wrong on staging, next.vibecodethis.site); they say next.<your bb account's domain> and the section shows the address derived from the account.

How you verified

  • pnpm exec turbo run typecheck --filter='...[connect-next/3-gate]': 109/109 tasks pass.
  • pnpm exec turbo run test --filter='[connect-next/3-gate]' (turbo.json changed, so every package ran): all green except failures that are unrelated to this change and pass on rerun or fail on main for the machine: @bb/server timeouts under full-repo load in timeline-in-turn-window, plugin-native-server-loading, plugin-service (75/75 when rerun), @bb/host-daemon command-discovery (stray /tmp/.git on bee; 28/28 with TMPDIR outside /tmp), @bb/scripts ci-bun (no zip binary on bee). Relevant counts: @bb/frp-client 38/38, bb-plugin-bb--connect-next 26/26 (incl. the new copy test: fails with the old (next.getbb.app) copy), bb-plugin-connect 141/141, bb-plugin-bb-account 61/61, @bb/server 3,637 passed (incl. real frps + plugin frpc through the ingress).
  • oxfmt --check, pnpm lint: clean.
  • Local end to end: results on PR 5.

AGENT GENERATED

@bb/frp-client (download, verify, configure and supervise frpc) and the
builtin bb--connect-next plugin (disabled by default): settings, status,
RPC, CLI and skill; it tunnels the server through its ingress and serves the
server machine's port shares on the next address. bb-account lets it read
the server credential; connect lists next share URLs. Settings copy names no
fixed next domain.
@SawyerHood
SawyerHood force-pushed the connect-next/4-plugin branch from 1a64038 to d6c79a5 Compare October 21, 2026 16:53
@SawyerHood
SawyerHood merged commit b839f0a into main Oct 21, 2026
53 checks passed
@SawyerHood
SawyerHood deleted the connect-next/4-plugin branch October 21, 2026 17:21
SawyerHood added a commit that referenced this pull request Oct 21, 2026
…n protocol 247) (#6051)

## 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
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