Skip to content

feat(browser): internal hostnames served by the agent or a Worker - #2669

Open
ben-reitz wants to merge 6 commits into
browser-tool/modulefrom
browser-internal-hosts/core
Open

ben-reitz wants to merge 6 commits into
browser-tool/modulefrom
browser-internal-hosts/core

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Gives the browser hostnames that your agent serves instead of the internet, using Browser Run's per-session host routing.

sequenceDiagram
    participant Page as Browser Run page
    participant Router as InternalHostRouter (your Worker)
    participant Agent as Agent DO
    Page->>Router: GET http://docs.internal/
    Router->>Agent: fetchInternalHost(message)
    Agent->>Agent: browser.fetchInternalHost → host.fetch(request)
    Agent-->>Page: response
Loading
browser = new Browser({
  provider: browserRun(this.env.BROWSER, {
    internalHosts: {
      router: this.ctx.exports.InternalHostRouter,
      hosts: {
        "docs.internal": { description: "Staging docs", fetch: (req) => … },
        "api.internal": { worker: this.env.API } // straight to a Worker
      }
    }
  })
});
  • Agent has fetchInternalHost() built in; a plain DO adds a one-line method.
  • Hostnames must end in .internal, .test, .example or .invalid (never resolve publicly). A probe showed single-label names that are real TLDs (docs, app) fail silently in Browser Run.
  • At most 8 hosts, plain http on port 80, no WebSockets, deployed only (local dev logs a warning and starts without them).
  • Hardening: rejects DO stubs as worker, validates router props, terse 502s when fetch throws.

Merge Danger

Blast Radius: none for existing users — opt-in internalHosts option.

@ben-reitz
ben-reitz added this pull request to stack #2675 October 22, 2026 15:10
@ben-reitz ben-reitz changed the title browser internal hosts/core feat(browser): internal hostnames served by the agent or a Worker Oct 22, 2026
@agent-think

agent-think Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🟡 agents import sizes: 1 entry point grew

Entry point Exports Largest gzip change Size now
🟡 agents/browser 2 resized, 2 new up to +1 KiB (+2.18%) 48.9 KiB
Changed exports (4)
Import Gzip change Size now
🟡 agents/browser#Browser +1 KiB (+2.18%) 48.9 KiB
🟡 agents/browser#browserRun +577 B (+1.57%) 36.6 KiB
🆕 agents/browser#InternalHostRouter — 36.5 KiB
🆕 agents/browser#MAX_INTERNAL_HOSTS — 36 KiB
How this works

Each runtime export is bundled on its own, minified, and gzipped. Changes smaller than 100 B, or smaller than 1% and 1 KiB, are ignored. Growth over 10% or 5 KiB is marked 🔴. This report is informational and does not fail CI. The workflow artifact contains every measurement.

Compared e1b84c06 → 0e7378ac · workflow run · reported by agent-think[bot]

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2669

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2669

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2669

hono-agents

npm i https://pkg.pr.new/hono-agents@2669

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2669

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2669

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2669

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2669

commit: 0e7378a

@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch from 93c0025 to af8ae00 Compare October 22, 2026 15:40
@changeset-bot

changeset-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0e7378a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: af8ae00

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch from af8ae00 to de8496e Compare October 22, 2026 23:08
@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch from de8496e to 6cd6dd1 Compare October 22, 2026 23:22
@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch from 6cd6dd1 to 444d5f1 Compare October 23, 2026 10:01
@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch from 444d5f1 to 63ef8d8 Compare October 23, 2026 10:52
@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch from 63ef8d8 to b4bf9c1 Compare October 23, 2026 12:29
@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch 3 times, most recently from 4ee73ed to fbaf3ba Compare October 23, 2026 13:26
- Require a reserved suffix (.internal, .test, .example, .invalid) and reject *.localhost
- Reject Durable Object stubs as fetcher at compile time; correct the DataCloneError message
- Router checks its props (and v) before use, answers 502 instead of resetting
- Log host fetch errors instead of returning them to the page
- Share the browser capability id between Browser and Agent.fetchInternalHost
- Document that any http page in the browser can send requests to fetch hosts
- Test request bodies, a ctx.exports fetcher host, stale-session close, router and fallback paths
@ben-reitz
ben-reitz force-pushed the browser-internal-hosts/core branch from fbaf3ba to dafff35 Compare October 23, 2026 13:34
@ben-reitz
ben-reitz marked this pull request as ready for review October 23, 2026 13:42
devin-ai-integration[bot]

This comment was marked as resolved.

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