Skip to content

webapp, sdk/js: a browser joins the mesh from the web app at /node/ - #934

Merged
aojea merged 1 commit into
google:mainfrom
kaisoz:kaisoz/node-webapp
Nov 26, 2026
Merged

aojea merged 1 commit into
google:mainfrom
kaisoz:kaisoz/node-webapp

Conversation

@kaisoz

@kaisoz kaisoz commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

A browser can now join a mesh. Before this, a member needed agentmesh-node, an SDK program or the Android app.

agentmesh-one and agentmesh-console serve Agent Mesh Connect at /node/. It is a web app that runs the JavaScript SDK in the page. The browser becomes a normal member, with its own key, credential and Node ID.

internal/webapp/          # the page and its Go handler, embedded in the binaries
├── app.go                # serves /node/ with a strict CSP
└── public/
    ├── model.js          # the page's state machine (pure, unit tested)
    └── app.js            # effects: enroll, join, sign in, local agent
sdk/js/
├── src/                  # SDK: unenroll support, MeshTool values
└── webapp/               # WebMCP + relay pairing; bundled for the page, not shipped to npm
cmd/agentmesh-one/        # mounts /node/, prints the App URL in the banner
cmd/agentmesh-console/    # mounts /node/ for the testnets

What a user can do

Join

  • Paste an enrollment token, or open a <url>/node/#token=<token> link. The fragment never reaches a server.
  • Or tap Sign in, when the mesh has a sign-in provider.
  • The key stays in the browser's storage. The page joins through the router over WebSocket or WebTransport.

Run the node

  • The dashboard shows the Node ID, peers and routers.
  • Start, Stop, Unenroll and Reset device identity.
  • A device the mesh no longer accepts rejoins with a new token, or by signing in again, and keeps its Node ID.
  • A banned browser can always reset its identity, so it is never stuck.

Connect a local agent (computers only)

  • The Config tab offers the node's five caller tools to an agent such as Claude Code. The agent then calls the mesh as this node.
  • The user copies one prompt from the page into the agent. No configuration.

Sign in

The page shows Sign in only when:

  • the control plane's /info names an issuer, and
  • the provider's discovery document answers the page with that same issuer.
tap Sign in
  page → provider: authorization code + PKCE, back to /node/
  page → provider: code + verifier → ID token
  page → control plane: POST /register with the ID token
renew
  POST /refresh by proof of possession; the ID token is never kept or sent again
  • The page trusts a return only when its state matches the sign-in this tab started. A crafted ?error= or ?code= link shows only the page's own text.
  • The provider lookup runs each time the welcome or rejoin view opens. A changed or removed provider is followed without a reload.
  • Each provider request gives up after 15 s, so a silent provider never blocks the token form.
  • The session lasts 90 days by default (--oidc-session-ttl on agentmesh-control-plane).

Local agent

sequenceDiagram
    participant Agent as Local agent
    participant Relay as Relay (Node.js, on the computer)
    participant Page as Web app (browser)
    Agent->>Relay: MCP tool call
    Relay->>Page: call signed with the paired key
    Page->>Page: verify signature, nonce, 60 s window
    Page-->>Relay: result
    Relay-->>Agent: result
Loading
  • The page offers the tools through WebMCP, with @w3c/webmcp-polyfill 0.1.1 where the browser lacks it.
  • The agent reaches the page through the MCP-B local relay (@mcp-b/webmcp-local-relay 6.2.0). That relay accepts calls from any local program, so the mesh serves a launcher around it: one file, /node/sdk/agentmesh-relay.mjs, which needs only Node.js 22.
  • The launcher pairs once with a single-use token from the page. It signs every call with the key both sides derive.
  • The page runs only calls signed by a paired agent: once each, within 60 s, and never a call signed before the page first offered its tools.
  • The key is in a file only the user can read, as agentmesh-node's API token is.

SDK changes (sdk/js)

  • New for any program that unenrolls: NotEnrolledError, AgentMesh.forget and StateStore.remove.
  • close() waits for an in-flight credential refresh or control plane pull.
  • The five caller tools are plain MeshTool values, which the stdio MCP server registers.
  • The WebMCP registration and the pairing live in sdk/js/webapp/. npm does not ship them.
  • The relay library raises the lockfile's ws from 8.21.3 to 8.23.0, which its ^8.22.1 range needs.

Build and deploy

  • make all builds the SDK bundle the page imports, then the binaries. Releases and container images build both.
  • A binary built with make build only still runs. It says the app is missing and serves a page that says so.
  • Testnets:
    • the HTTPRoute sends /node/ on the control plane's host to the console;
    • the testnet Dex lists https://{bananas,hub}.sam-mesh.dev/node/ as redirect URIs and allows both origins.
  • The page treats its own origin as the control plane, so it is served on the control plane's host only.

Evidence

Every new test was checked to fail without its fix.

Layer Command What it pins
Page model node --test internal/webapp/model.test.mjs state machine, sign-in return parsing, the agent prompt
SDK cd sdk/js && npm test (Node 22) refused calls (unsigned, unpaired, stale, replayed, sent twice at once, altered, signed before a reload), one agent per pairing token, close waiting for a refresh
Go go test ./internal/webapp/ ./cmd/agentmesh-one/ ./cmd/agentmesh-console/ handler files and headers, the /node/ mount in both binaries
UI make ui-test the journeys below

UI journeys in tests/ui/app.spec.js:

  • enroll from a link and resume after a reload, directly and behind a TLS edge;
  • pair a local agent through the downloaded launcher; only its signed calls run;
  • renew a lapsed credential at launch;
  • rejoin with a pasted token after the mesh forgets the device;
  • a banned browser can still reset its identity;
  • Sign in, against a mock provider that checks the PKCE verifier:
    • hidden with no provider, without CORS, or with a discovery document for another issuer;
    • forged returns show only the page's own text;
    • a silent provider: gives up after 15 s, and a token join still works;
    • follows a provider being removed and restored without a reload;
    • joins, renews without sending the ID token, and rejoins with the same Node ID.

Merge Danger

Door: two-way. The app is new, under a new path, /node/. Removing the mount or the route rule turns it off.

Blast Radius: small.

  • Existing members, the console and the control plane APIs are unchanged.
  • The SDK gains the unenroll exports. The WebMCP and pairing code is not in the npm package.
  • Testnet Dex gains redirect URIs and allowed origins for /node/.

@kaisoz
kaisoz requested a review from aojea as a code owner November 24, 2026 12:39

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the 'Agent Mesh Connect' web application, which allows users to enroll and manage their mesh node directly from a browser. The changes include the implementation of the web app (HTML, CSS, and JavaScript), backend integration in both 'agentmesh-one' and 'agentmesh-console' to serve the application at the '/node/' path, and a local relay mechanism to enable local MCP agents to interact with the mesh node. Additionally, the SDK has been updated to support state management via a new 'forget' method and 'NotEnrolledError', with comprehensive unit, integration, and E2E tests added to cover the new functionality. Documentation has been updated to reflect these changes. I have no feedback to provide as there were no review comments to assess.

@kaisoz
kaisoz force-pushed the kaisoz/node-webapp branch from a5c379b to 3599308 Compare November 24, 2026 14:12
@aojea

aojea commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

govulncheck is unrelated I will fix it separately, is the console-ui related?

@kaisoz
kaisoz force-pushed the kaisoz/node-webapp branch from 3599308 to b896ef6 Compare November 24, 2026 19:44
@kaisoz

kaisoz commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

govulncheck is unrelated I will fix it separately, is the console-ui related?

Yes, I just pushed a fix

@aojea

aojea commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

govulncheck, just leave agentmesh-one and console out of this PR and we land the webapp only , I'm unsure we want to create this tighly coupling between control plane and data plane

A browser had no way onto a mesh: a member needed agentmesh-node, an SDK
program or the Android app. A new agentmesh-webapp binary serves Agent
Mesh Connect, a web app that runs the JavaScript SDK in the page. The
page knows no mesh. The person enters the control plane's address,
pastes the mesh://enroll code agentmesh-one prints (api.EnrollURI),
which carries it, or opens a <page>#server=<url>&token=<token> link
whose fragment never reaches a server. The address takes https, or http
to localhost or 127.0.0.1, the loopback hosts the page's CSP can name. A
browser belongs to one mesh at a time: once it joins, the address is
fixed until Reset device identity, and it follows the control plane the
saved credential names. Cancel once the control plane has answered still
enrolls the device, because the SDK has saved the credential, so the
address locks then too, and Join checks the lock again. The page keeps
its key in the browser's storage and joins through the router over
WebSocket or WebTransport. The dashboard shows the Node ID, peers and
routers, with Start, Stop, Unenroll and Reset device identity. A device
the mesh no longer accepts rejoins with a new pasted token and keeps its
Node ID. A browser that kept its key can always reset it, so a banned
one is never stuck.

When the control plane names a sign-in provider in /info and the
provider's discovery document answers the page with the same issuer, the
welcome and rejoin views also offer Sign in. They ask when the address
is entered and on every entry, so a provider the operator changes or
removes is followed without a reload. A #server=<url> link alone fills
in the address, so a mesh's Sign in shows at once. Leaving the view
cancels the lookup and the provider lookup gives up after 15 s, so a
silent provider never holds the token form or stays offered. The page
runs the authorization code flow with PKCE back to itself and enrolls
with the ID token through /register, which already checks bans and the
node role binding. It keeps no ID token: the credential renews by proof
of possession for the OIDC session, 90 days by default. The page trusts
a return only when its state matches the sign-in the tab started, so a
crafted ?error= or ?code= link shows the page's own words. The testnet
Dex lists https://{bananas,hub}.sam-mesh.dev/node/ as redirect URIs and
allows both origins.

On a computer, the Config tab can also offer the node's five caller
tools to a local agent such as Claude Code, so the agent calls the mesh
as this node. The goal is no configuration: the user copies a prompt
from the page and pastes it into the agent. The page offers the tools
through WebMCP, with @w3c/webmcp-polyfill 0.1.1 where the browser lacks
it, and the agent reaches the page through the MCP-B local relay
(@mcp-b/webmcp-local-relay 6.2.0), which accepts calls from any local
program. So agentmesh-webapp serves a launcher around the relay as one
file, sdk/agentmesh-relay.mjs beside the page, which needs only Node.js
22. It pairs once with a single-use token from the page and signs every
call with the key both sides derive. The page runs only calls signed by
a paired agent, once each even when copies arrive together, within 60 s,
and never a call signed before the page first offered its tools. The key
sits in a file only the user reads, as agentmesh-node's API token does.
The relay library raises the lockfile's ws from 8.21.3 to 8.23.0, the
version its ^8.22.1 range needs.

The SDK gains what any program needs to unenroll: NotEnrolledError,
AgentMesh.forget and StateStore.remove, and a session close that waits
for an in-flight credential refresh or control plane pull. A refresh now
saves the new biscuit as soon as the control plane answers, before it
asks for /keys, in the JavaScript and Python SDKs: the control plane
spends the old biscuit when it answers, so a page reloaded in between
kept only a spent one and was refused at its next refresh ("Biscuit
already rotated"), as CI showed. The SDK's five caller tools become
plain MeshTool values that the stdio MCP server registers. The WebMCP
registration, which runs only signed calls, and the pairing live in
sdk/js/webapp/ beside the launcher: the page bundle and the launcher
build from there, and npm does not ship them.

agentmesh-webapp serves the page at / and shares nothing with the other
components: agentmesh-one, the console and the control plane do not
serve it, and it has no flag that names a mesh. The control plane's mesh
routes already answer any origin. The page's CSP adds http to localhost
and 127.0.0.1, so a page reaches a control plane on the same computer.
It ships as an image and a Helm chart, charts/agentmesh-webapp, whose
optional Gateway follows the agentmesh chart's, and not in release
archives. The testnets mount it at /node/ on the existing host through
its own HTTPRoute, which strips the prefix, so they need no DNS record
or certificate of their own.

make all builds the SDK bundle the page imports, then the binaries; the
agentmesh-webapp image builds both. A binary built with make build only
still runs, says the app is missing and serves a page that says so.

Tests pin the page's state machine, pairing and every refused call
(unsigned, unpaired, stale, replayed, sent twice at once, altered,
signed before a reload), the registration refusing an unsigned call, one
agent per token when two pairing requests overlap, an agent's cancel
reaching the mesh call, close waiting for a refresh and a pull, the
handler's files and headers at / and nothing under /node/, the address
rules, #server= links and the one-mesh lock, and the chart's route and
probe. UI journeys serve the page from agentmesh-webapp on an origin
apart from the mesh, so every journey crosses origins. They enroll from
a link, rejoin after a reload, rejoin with a pasted token after a key
rotation, keep a banned browser able to reset, take the address from the
saved credential, keep it fixed after an unenroll and refuse a code for
another mesh, free the address after a reset, renew a lapsed credential,
and pair a local agent through the downloaded launcher. Against a mock
provider that checks the PKCE verifier, Sign in stays hidden until the
address is entered, without a provider, without CORS, or with a
discovery document for another issuer or without a token endpoint. It
refuses forged returns, gives up on a silent token endpoint after 15 s
and offers Sign in again for the same mesh, locks the address and shows
Reset when Cancel comes after the control plane answered, refuses at
Join a code for another mesh taken before that lock, lets a token join
at once while discovery hangs, drops a provider whose discovery stops
answering, follows the provider being removed and restored, joins,
renews without sending the ID token, joins again after a reload made
while /keys is held after a refresh, and rejoins with the same Node ID.
In both SDKs a process stopped while /keys is asked still refreshes from
what it saved. The two SDK tests and the journey step fail on the
previous save order.
@kaisoz
kaisoz force-pushed the kaisoz/node-webapp branch from b896ef6 to 318442d Compare November 26, 2026 13:03
@aojea
aojea merged commit 36ccd72 into google:main Nov 26, 2026
23 checks passed
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