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
Agent Mesh desktop tray in MESH mode showing Private Mesh connected with 2 models and MCP active

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

Agent Mesh desktop tray in BOTH hybrid mode with the Active Model / Provider submenu expanded showing private mesh models, local Ollama, and cloud Gemini

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 colorLabelActive trust-zone state
EmeraldMESHPrivate Agent Mesh models and remote MCP tools only (fails closed)
IndigoBOTHHybrid mode: private Agent Mesh plus public cloud and local models
Sky bluePUBPublic cloud providers and local on-device models (private mesh MCP hidden)
AmberOFFAir-gapped on-device local models only (for example Ollama)
SlateSTOPLocal gateway stopped (click Start / Restart Gateway Service)

Key tray capabilities:

  • One-click trust-zone switching between Mesh, Both, Public, and Offline (automatically disables disallowed modes under ORG LOCKED MDM 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:

ModeAliasesAllowed providersMesh MCP toolsFailover rule
publicpersonal, cloudDirect cloud APIs (public) + local models (on-device)Hidden (read-only gateway tools only)Public and on-device only
meshprivate, enterprise, workAttested Agent Mesh peers + private cloud backends (private)VisibleFail closed — never falls back to public cloud
bothhybridprivate, public, and on-device concurrentlyVisible (when attached)Strict zone boundary — private requests never fail over to public
offlinelocal, airgap, on-deviceLoopback on-device models only (for example Ollama)HiddenZero 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):

EndpointWire dialectPrimary clients
POST /v1/chat/completions, POST /v1/completionsOpenAI Chat CompletionsOpenAI SDKs, Antigravity, custom tools
POST /v1/responses, POST /responsesOpenAI Responses APICodex CLI, newer OpenAI SDKs
POST /v1/messages, POST /v1/messages/count_tokensAnthropic Messages APIClaude Code, Anthropic SDKs
POST /v1beta/models/{model}:generateContent, :streamGenerateContentGoogle Gemini APIGoogle Antigravity (agy), Gemini CLI, Google GenAI SDKs
GET /v1/modelsOpenAI model listing (filtered by active trust zone)All clients

Selecting providers and models

You can select a backend in three ways:

  1. Inline model prefix (works with /model inside Claude Code, Codex, or any API call):
    • mesh:<model> — route directly to an attested Agent Mesh inference peer (for example mesh:qwen3-coder).
    • <provider>:<model> — route to a named configured provider (for example openai:gpt-4.1-mini, gemini:gemini-2.5-pro, ollama:gemma3:1b).
    • Bare <model> — auto-resolved by model name and active mode/preference.
  2. 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
    
  3. 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): sets ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, and unsets ANTHROPIC_API_KEY. To keep an existing Claude OAuth subscription in public mode, pass --oauth-passthrough, which sends the wrap token in ANTHROPIC_CUSTOM_HEADERS so Claude’s OAuth bearer header passes through untouched to Anthropic.
  • Codex CLI (codex): sets OPENAI_BASE_URL (http://127.0.0.1:8080/v1), OPENAI_API_KEY, and AGENTMESH_SESSION_TOKEN targeting /v1/responses.
  • Gemini CLI (gemini): sets GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY, and unsets GOOGLE_API_KEY.
  • Google Antigravity (agy): wrap sets AGY_LLM_GATEWAY_URL, AGY_LLM_GATEWAY_WIRE_PROTOCOL, and AGY_LLM_GATEWAY_API_KEY automatically so agentmesh-node wrap -- agy routes straight through the local gateway.
  • Corporate HTTP_PROXY safety: wrap always preserves existing NO_PROXY entries and adds 127.0.0.1,localhost,::1 so 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:

  1. OS-managed file (/etc/agentmesh/managed-policy.yaml, root-owned, deployed via MDM): can set locked_mode, allowed_modes, forbid_mesh_detach, forbid_static_local_api_keys, require_inspected_inference, mandatory_egress_floor, and locked workspaces:. Ready-to-deploy MDM templates for /etc/agentmesh/managed-policy.yaml, Google Antigravity (admin_settings.json), and Claude Code (managed-settings.json) are provided under deploy/mdm/.
  2. Control-plane PolicyConfig.gateway_policy: pushed dynamically to enrolled nodes in GET /policies and 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, mode 0600), never on TCP. On Linux and macOS, the daemon inspects SO_PEERCRED / LOCAL_PEERPID and walks the process ancestry tree to reject connections from any wrapped agent PID or its descendants.
  • Read-only, zone-scoped MCP: /mcp exposes 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 permits private traffic, preventing confused-deputy access from public or offline sessions.
  • Capability token separation: wrap sessions mint separate amw_llm_* (LLM/MCP only) and amw_proxy_* (HTTP proxy only) tokens, and scrub all inbound auth headers before forwarding upstream.
  • CSRF and DNS-rebinding defense: /ui accepts only HttpOnly; SameSite=Strict operator cookies minted over operator.sock, enforces CSRF tokens on every mutation, and rejects non-loopback Host headers on loopback-bound listeners.