Local-first LLM gateway
agentmesh-node can run as a local-first, multi-protocol LLM gateway for coding
agents (Google Antigravity, Claude Code, Codex CLI, Gemini CLI,
and any OpenAI, Anthropic, or Gemini client). Start locally with your own
provider API keys or Ollama in 30 seconds—no control plane or mesh enrollment
required—then hot-attach to a private Agent Mesh later with a single command
and zero agent restarts.
Quick start
Install agentmesh-node and agentmesh-tray for your OS (see
Quick start for .deb, .rpm,
.apk, Homebrew, Scoop, and Winget options):
# macOS / Linux:
curl -sL https://google.github.io/agentmesh/install.sh | bash
# Windows (PowerShell):
# irm https://google.github.io/agentmesh/install.ps1 | iex
Run zero-config setup and install the persistent background service:
agentmesh-node init --service
agentmesh-node init detects installed coding CLIs (agy, claude, codex,
gemini), checks for provider environment keys or local Ollama, installs the
Agent Mesh skill across ~/.claude/skills/, ~/.gemini/config/skills/, and
~/.codex/skills/, configures the Claude Code status line without touching
existing settings, and starts the local gateway daemon. Passing --service
registers it as a persistent user-level OS background service (launchd on
macOS, systemd --user on Linux, or a limited-privilege logon task in Windows
Task Scheduler) so the gateway is always running before any agent starts.
Desktop menu bar / system tray (agentmesh-tray)
Launch agentmesh-tray to place a live status badge and switcher in your macOS
menu bar, Linux status bar (StatusNotifierItem / AppIndicator over D-Bus), or
Windows system tray:
agentmesh-tray

agentmesh-tray in MESH (Private) mode: emerald badge, live private mesh & MCP status, 5-hour spend readout, and 1-click trust-zone switching.

Switching live to BOTH (Hybrid) mode updates the tray badge to indigo and populates Active Model / Provider with discovered mesh:*, local on-device, and cloud models.
agentmesh-tray talks strictly over operator.sock (protojson) and /v1/models:
| Badge color | Label | Active trust-zone state |
|---|---|---|
| Emerald | MESH | Private Agent Mesh models and remote MCP tools only (fails closed) |
| Indigo | BOTH | Hybrid mode: private Agent Mesh plus public cloud and local models |
| Sky blue | PUB | Public cloud providers and local on-device models (private mesh MCP hidden) |
| Amber | OFF | Air-gapped on-device local models only (for example Ollama) |
| Slate | STOP | Local gateway stopped (click Start / Restart Gateway Service) |
Key tray capabilities:
- One-click trust-zone switching between
Mesh,Both,Public, andOffline(automatically disables disallowed modes underORG LOCKEDMDM or control-plane policies). - Live model & provider pinning across discovered private
mesh:*models, local on-device Ollama models, and cloud providers (or Auto to route by mode). - Rolling 5-hour spend and avoided-spend readout plus private mesh / MCP connection status.
- One-click controls for Open Web Dashboard (
/ui), Detach / Reconnect Private Mesh, and Start / Restart Gateway Service.
Managing the OS background service
Manage the user-level gateway service at any time on macOS (launchd), Linux
(systemd --user), or Windows (Task Scheduler):
agentmesh-node service install # write user service definition and start it
agentmesh-node service install --mode mesh # start with a specific default mode
agentmesh-node service status # show service manager state and operator.sock health
agentmesh-node service start # start the installed service
agentmesh-node service stop # stop the service without uninstalling
agentmesh-node service uninstall # stop and remove the user service unit
Launch any coding agent through the gateway with wrap:
agentmesh-node wrap -- agy # Google Antigravity (GenAI or OpenAI wire)
agentmesh-node wrap -- claude # Claude Code (Anthropic Messages ingress)
agentmesh-node wrap -- codex # Codex CLI (OpenAI Responses ingress)
agentmesh-node wrap -- gemini # Gemini CLI (Gemini ingress)
Optional shell wrappers make agy, claude, codex, and gemini route
through the gateway automatically and add the short am alias:
eval "$(agentmesh-node shell-init)" # add to ~/.bashrc or ~/.zshrc
When a wrapped agent exits, agentmesh-node wrap revokes its ephemeral session
tokens immediately and prints a session receipt showing requests, tokens,
public cloud spend, and avoided spend on private or on-device models.
Trust-zone modes
Every provider belongs to one of three trust zones (private, public, or
on-device), and every gateway default or wrap session runs in one of four
explicit modes:
| Mode | Aliases | Allowed providers | Mesh MCP tools | Failover rule |
|---|---|---|---|---|
public | personal, cloud | Direct cloud APIs (public) + local models (on-device) | Hidden (read-only gateway tools only) | Public and on-device only |
mesh | private, enterprise, work | Attested Agent Mesh peers + private cloud backends (private) | Visible | Fail closed — never falls back to public cloud |
both | hybrid | private, public, and on-device concurrently | Visible (when attached) | Strict zone boundary — private requests never fail over to public |
offline | local, airgap, on-device | Loopback on-device models only (for example Ollama) | Hidden | Zero external network or mesh egress |
Switch modes live from any terminal without restarting running agents:
agentmesh-node mode # show active mode, mesh state, and providers
agentmesh-node mode mesh # fail closed to private mesh / VPC backends only
agentmesh-node mode public # route to public cloud + on-device models
agentmesh-node mode both --prefer mesh # run both concurrently, preferring private mesh
agentmesh-node mode offline # air-gap to loopback on-device models only
Override the mode for a single agent session with short flags:
agentmesh-node wrap -m -- agy # mesh-only (private) session
agentmesh-node wrap -p -- agy # public session
agentmesh-node wrap -b -- claude # both zones active
agentmesh-node wrap -o -- codex # offline on-device session
Multi-protocol ingress and translation
The gateway accepts all four major LLM wire dialects on its local API listener and translates transparently between them when the target provider speaks a different dialect (using native zero-overhead passthrough when ingress and upstream dialects match):
| Endpoint | Wire dialect | Primary clients |
|---|---|---|
POST /v1/chat/completions, POST /v1/completions | OpenAI Chat Completions | OpenAI SDKs, Antigravity, custom tools |
POST /v1/responses, POST /responses | OpenAI Responses API | Codex CLI, newer OpenAI SDKs |
POST /v1/messages, POST /v1/messages/count_tokens | Anthropic Messages API | Claude Code, Anthropic SDKs |
POST /v1beta/models/{model}:generateContent, :streamGenerateContent | Google Gemini API | Google Antigravity (agy), Gemini CLI, Google GenAI SDKs |
GET /v1/models | OpenAI model listing (filtered by active trust zone) | All clients |
Selecting providers and models
You can select a backend in three ways:
- Inline model prefix (works with
/modelinside Claude Code, Codex, or any API call):mesh:<model>— route directly to an attested Agent Mesh inference peer (for examplemesh:qwen3-coder).<provider>:<model>— route to a named configured provider (for exampleopenai:gpt-4.1-mini,gemini:gemini-2.5-pro,ollama:gemma3:1b).- Bare
<model>— auto-resolved by model name and active mode/preference.
- Operator CLI pin (applies immediately over
operator.sock):agentmesh-node use ollama:gemma3:1b agentmesh-node use mesh:qwen3-coder agentmesh-node use auto # clear pin - Per-session pin at launch:
agentmesh-node wrap -p --provider gemini:gemini-2.5-pro -- claude
Wrapping coding agents
agentmesh-node wrap creates a short-lived capability-scoped session, injects
only the environment variables the target CLI expects, strips raw provider API
keys from the child environment, and revokes the session automatically when the
process exits (even on SIGKILL via a kernel-monitored /hold control pipe):
- Claude Code (
claude): setsANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKEN, and unsetsANTHROPIC_API_KEY. To keep an existing Claude OAuth subscription inpublicmode, pass--oauth-passthrough, which sends the wrap token inANTHROPIC_CUSTOM_HEADERSso Claude’s OAuth bearer header passes through untouched to Anthropic. - Codex CLI (
codex): setsOPENAI_BASE_URL(http://127.0.0.1:8080/v1),OPENAI_API_KEY, andAGENTMESH_SESSION_TOKENtargeting/v1/responses. - Gemini CLI (
gemini): setsGOOGLE_GEMINI_BASE_URLandGEMINI_API_KEY, and unsetsGOOGLE_API_KEY. - Google Antigravity (
agy):wrapsetsAGY_LLM_GATEWAY_URL,AGY_LLM_GATEWAY_WIRE_PROTOCOL, andAGY_LLM_GATEWAY_API_KEYautomatically soagentmesh-node wrap -- agyroutes straight through the local gateway. - Corporate
HTTP_PROXYsafety:wrapalways preserves existingNO_PROXYentries and adds127.0.0.1,localhost,::1so ambient proxies never hijack loopback gateway traffic.
To also route non-LLM outbound HTTP/HTTPS calls (such as curl, git, or package
installers) through the gateway’s cooperative proxy, add --proxy-all:
agentmesh-node wrap --proxy-all -- claude
--proxy-all injects a separate proxy-only token (amw_proxy_*) into
HTTP_PROXY / HTTPS_PROXY. Proxy tokens are rejected on /v1/*, /mcp, and
/ui routes, so a leaked proxy URL cannot call LLM endpoints or MCP tools.
Hot-attaching a private Agent Mesh
Start local-first in public mode, then attach the running daemon to an Agent
Mesh control plane at any time without restarting your daemon or wrapped agents:
# Attach via interactive OIDC login (or pass --bootstrap-token-path for agentmesh-one):
agentmesh-node join https://mesh.example.com
When agentmesh-node join detects a running gateway daemon on operator.sock,
it enrolls and hot-attaches the live libp2p host, Biscuit identity, and mesh
inference/MCP services in place. By default, hot-attach fails closed into
mesh mode (use --mode both to keep public providers available
alongside the mesh).
To disconnect from the mesh while keeping local and public routing active:
agentmesh-node detach
If mesh policy sets forbid_mesh_detach: true, detach is refused.
Configuration and workspaces
Add a gateway: and optional workspaces: block to agentmesh-node.yaml:
version: "v1alpha1"
gateway:
enabled: true
mode: both
preference: mesh-first
providers:
- name: anthropic
protocol: anthropic
trust_zone: public
base_url: "https://api.anthropic.com"
api_key_env: ANTHROPIC_API_KEY
models: ["claude-sonnet-4-6", "claude-opus-4-6"]
- name: openai
protocol: openai-responses
trust_zone: public
base_url: "https://api.openai.com/v1"
api_key_env: OPENAI_API_KEY
models: ["gpt-5", "gpt-4.1-mini"]
- name: vertex-claude
protocol: anthropic
backend: vertex
trust_zone: private
auth: adc
project: my-gcp-project
location: us-east5
models: ["claude-sonnet-4-6"]
- name: ollama
protocol: openai-chat
trust_zone: on-device
base_url: "http://127.0.0.1:11434/v1"
auth: none
discover_models: true
usage:
retention_days: 90
otlp:
endpoint: "https://otel.corp.example/v1/metrics"
headers_path: "/etc/agentmesh/otlp-headers.txt"
workspaces:
- path: "~/work/**"
mode: mesh
- path: "~/oss/**"
mode: public
Provider credentials are always read from api_key_path, api_key_env, cloud
ADC/AWS defaults, or mesh border JWTs—inline credentials in URLs or YAML are
rejected.
With workspaces: configured, agentmesh-node wrap inspects the current
working directory and enforces the matching workspace mode automatically. Trying
to override a mesh workspace with -p or -b is refused unless
--force is passed (and is always refused when a policy lock applies).
Managed OS and control-plane governance
Organizations can enforce hard ceilings above user configuration in two ways, merged with strictest-wins semantics:
- OS-managed file (
/etc/agentmesh/managed-policy.yaml, root-owned, deployed via MDM): can setlocked_mode,allowed_modes,forbid_mesh_detach,forbid_static_local_api_keys,require_inspected_inference,mandatory_egress_floor, and lockedworkspaces:. Ready-to-deploy MDM templates for/etc/agentmesh/managed-policy.yaml, Google Antigravity (admin_settings.json), and Claude Code (managed-settings.json) are provided underdeploy/mdm/. - Control-plane
PolicyConfig.gateway_policy: pushed dynamically to enrolled nodes inGET /policiesand refreshed on every policy update.
See Node configuration and Mesh policy for every field.
Usage tracking, status line, and dashboard
Every request through the gateway—streaming or non-streaming, across all four
protocols—is metered inline by a zero-goroutine StreamTap into a local
0600 SQLite ledger (<data-dir>/usage.db). Prompt and completion contents
are never stored.
agentmesh-node usage # last 24h grouped by provider
agentmesh-node usage --by zone # public spend vs. private/on-device avoided spend
agentmesh-node usage --daily # last 30 days by calendar day
agentmesh-node usage --blocks # 5-hour billing windows
agentmesh-node usage --by model --json # machine-readable protojson
Live status line
agentmesh-node statusline responds in a few milliseconds over operator.sock
and stays silent when the daemon is stopped:
agentmesh-node statusline # [MESH] mesh/qwen3-coder | 5h $0.00 pub · 29.8k mesh (~$0.07 saved)
agentmesh-node statusline --prompt # [MESH] (compact badge for shell PS1)
agentmesh-node statusline --claude # reads Claude Code statusLine JSON (adds ctx %)
Local web dashboard
Open the built-in dark dashboard in your browser:
agentmesh-node ui # mints a scoped operator cookie and opens /ui
agentmesh-node ui --no-open # prints the authenticated URL without opening a browser
The dashboard shows live trust-zone mode controls, mesh status, public spend vs. avoided spend, active wrap sessions, and recent request events.
Telemetry privacy firewall
When gateway.usage.otlp.endpoint is configured, the OTLP metrics exporter
strictly filters to trust_zone == "private" records. Personal public and
on-device usage stays exclusively in the local SQLite database and never
leaves the workstation.
Security model
The local gateway treats wrapped coding agents as untrusted callers—even when they run as your OS user and can invoke shell commands via a Bash tool:
- Operator vs. agent plane split: mutating controls (
mode,use,join,detach,ui, session creation) are served exclusively on a separate Unix socket (<data-dir>/operator.sock, mode0600), never on TCP. On Linux and macOS, the daemon inspectsSO_PEERCRED/LOCAL_PEERPIDand walks the process ancestry tree to reject connections from any wrapped agent PID or its descendants. - Read-only, zone-scoped MCP:
/mcpexposes only read-only gateway tools (get_gateway_status,list_inference_providers,get_usage_stats) filtered to the session’s trust zone. Remote mesh tools are mounted only when the session permitsprivatetraffic, preventing confused-deputy access frompublicorofflinesessions. - Capability token separation: wrap sessions mint separate
amw_llm_*(LLM/MCP only) andamw_proxy_*(HTTP proxy only) tokens, and scrub all inbound auth headers before forwarding upstream. - CSRF and DNS-rebinding defense:
/uiaccepts onlyHttpOnly; SameSite=Strictoperator cookies minted overoperator.sock, enforces CSRF tokens on every mutation, and rejects non-loopbackHostheaders on loopback-bound listeners.