← Back to Pull requests

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

Closed
unknown closed this pull request without merging on Nov 26, 2026 14:15 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 12:39 UTC
Author

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
    

  • 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/.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: aojea Review duration: 2975m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #934"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%