Skip to content

feat(kernel-browser-runtime): pass full RemoteCommsOptions via worker URL#881

Merged
sirtimid merged 7 commits intomainfrom
sirtimid/remote-comms-query-string
Mar 19, 2026
Merged

feat(kernel-browser-runtime): pass full RemoteCommsOptions via worker URL#881
sirtimid merged 7 commits intomainfrom
sirtimid/remote-comms-query-string

Conversation

@sirtimid
Copy link
Contributor

@sirtimid sirtimid commented Mar 18, 2026

Summary

  • Replace relay-only URL helpers (createRelayQueryString/parseRelayQueryString/getRelaysFromCurrentLocation) with typed comms-query-string utilities (createCommsQueryString, parseCommsQueryString, getCommsParamsFromCurrentLocation) that support all serializable RemoteCommsOptions fields (arrays, numeric tuning knobs)
  • Validate inputs at the creation boundary via @metamask/superstruct; silently ignore invalid values when parsing
  • Exclude mnemonic from query string serialization (secret — must not appear in URLs)
  • Exclude directTransports (internal, platform-injected, not URL-serializable)
  • Export CommsQueryParams type for consumers (Omit<RemoteCommsOptions, 'directTransports' | 'mnemonic'>)
  • Auto-extract hostnames from plain ws:// relay multiaddrs into allowedWsHosts in ConnectionFactory, so callers don't need to redundantly specify both
  • Migrate extension and omnium-gatherum offscreen workers and browser kernel-worker to use new APIs
  • Update docs/usage.md examples

Test plan

  • Unit tests for createCommsQueryString (round-trip, validation errors, empty arrays)
  • Unit tests for parseCommsQueryString (valid/invalid JSON, missing params, no leading ?, non-string-array values)
  • Unit tests for getCommsParamsFromCurrentLocation (with/without globalThis.location)
  • 100% coverage on comms-query-string.ts (statements, branches, functions, lines)
  • ConnectionFactory test for auto-allowing ws:// relay hosts
  • All existing connection-factory.test.ts tests pass (77+)
  • Export snapshot tests updated (index.test.ts, utils/index.test.ts)

Note

Medium Risk
Expands how remote comms are configured and parsed from worker URLs and tweaks libp2p WebSocket allowlisting logic, which could affect connectivity and connection gating behavior if misconfigured.

Overview
Updates browser worker remote-comms configuration to pass a full, typed subset of RemoteCommsOptions via URL query params, replacing relay-only helpers with new createCommsQueryString/parseCommsQueryString/getCommsParamsFromCurrentLocation utilities (including runtime validation and support for numeric tuning options and additional address lists).

Migrates the browser kernel-worker plus extension and omnium offscreen worker bootstrapping to use the new comms query params and initializes initRemoteComms with the parsed options object.

Adjusts ConnectionFactory to auto-allow plain ws:// relay hosts by extracting hosts from configured relay multiaddrs into allowedWsHosts, and updates/adds unit tests and docs to reflect the new APIs and initRemoteComms({ relays }) calling convention.

Written by Cursor Bugbot for commit 7a580f4. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.41%
⬆️ +0.10%
7845 / 10134
🔵 Statements 77.22%
⬆️ +0.10%
7970 / 10321
🔵 Functions 75.35%
🟰 ±0%
1887 / 2504
🔵 Branches 74.95%
⬆️ +0.15%
3212 / 4285
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/extension/src/offscreen.ts 0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
19-101
packages/kernel-browser-runtime/src/kernel-worker/kernel-worker.ts 0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
26-111
packages/kernel-browser-runtime/src/utils/comms-query-string.ts 100% 100% 100% 100%
packages/kernel-browser-runtime/src/utils/index.ts 100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
100%
🟰 ±0%
packages/ocap-kernel/src/remotes/platform/connection-factory.ts 92.92%
⬆️ +0.18%
86.45%
⬆️ +0.28%
97.36%
🟰 ±0%
92.82%
⬆️ +0.19%
70, 79, 86, 168-170, 177, 393, 538, 586-587, 592-596, 655, 668
packages/omnium-gatherum/src/offscreen.ts 0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
0%
🟰 ±0%
20-121
Generated in workflow #3967 for commit 7a580f4 by the Vitest Coverage Report Action

@sirtimid sirtimid marked this pull request as ready for review March 19, 2026 14:13
@sirtimid sirtimid requested a review from a team as a code owner March 19, 2026 14:14
@sirtimid sirtimid enabled auto-merge March 19, 2026 15:45
Extract hostnames from plain ws:// relay multiaddrs and merge them into
allowedWsHosts automatically, so callers don't need to redundantly
specify both relays and allowedWsHosts for the same host.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of silently ignoring malformed array/number params, fail fast
with a TypeError so misconfigurations are caught immediately.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sirtimid sirtimid requested a review from rekmarks March 19, 2026 21:11
Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

LGTM!

@sirtimid sirtimid added this pull request to the merge queue Mar 19, 2026
Merged via the queue into main with commit 6600be0 Mar 19, 2026
30 checks passed
@sirtimid sirtimid deleted the sirtimid/remote-comms-query-string branch March 19, 2026 21:18
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