Documentation Index
Fetch the complete documentation index at: https://docs.svantic.com/llms.txt
Use this file to discover all available pages before exploring further.
MeshConnector
What it is
MeshConnector owns the Svantic platform connection on behalf of an Agent. It is responsible for:
- Authentication — exchanging your
client_id/client_secretfor a JWT (or accepting a pre-issued token). - Registration — telling Svantic the agent exists, what capabilities it has, and how to reach it.
- Transport — in connected mode, dialing an outbound WebSocket; in hosted mode, leaving dispatches to hit the agent’s public URL.
- Liveness — sending heartbeats so the gateway keeps the agent marked healthy.
- Session lifecycle — creating and closing Svantic sessions from the agent side.
new Agent({ mesh: { … } }) + await agent.start() constructs a MeshConnector under the hood, so in most cases you don’t import this class at all.
When to use it
ImportMeshConnector directly when you want the agent endpoints on an Express app you already own:
- You’re using
agent.expose(app)instead ofagent.start(). - You’re running multiple agents in one process and want fine-grained lifecycle control.
- You’re managing the token yourself (e.g. a BFF forwarding a user JWT).
attach — it wires MeshConnector for you.
Functional usage
- Token rotation — when you’re forwarding a user JWT (e.g. a dashboard session token) that the caller rotates periodically, call
mesh.refresh_token(new_jwt)whenever the token changes. No reconnect needed. - Runtime capability changes — after
agent.define_capability(...)at runtime, callmesh.re_register()so the gateway sees the updated tool list without a full reconnect.
Constants
DEFAULT_SVANTIC_URL
svantic_url is omitted from a MeshConnectorConfig.
Constructor
MeshConnectorConfig for every option. The most common shapes:
(client_id + client_secret) or token must be set.
Lifecycle
connect()
- If no
tokenwas supplied, exchange credentials for a JWT. - Register the agent with Svantic (capabilities,
deployment_mode, optionaldispatch_auth, learning config). - In connected mode, open the outbound WebSocket; in hosted mode this step is a no-op.
- Start the heartbeat.
try/catch sees a descriptive message.
disconnect()
POST /agents/deregister, and clears the cached token. Safe to call when not connected.
re_register()
refresh_token(jwt)
Sessions
create_session(options?)
session_id. Throws when not connected.
close_session(session_id)
Properties
| Property | Type | Description |
|---|---|---|
connected | boolean | true while a registration is active. |
svantic_url | string | The resolved Svantic URL (respects DEFAULT_SVANTIC_URL). |
token | string | null | Current JWT, or null before connect() / after disconnect(). |
deployment_mode | 'connected' | 'hosted' | null | Resolved mode from the registration response. null before connect(). |
agent | Agent | The wrapped agent. |
ws_transport | WsTransport | null | The underlying WebSocket transport in connected mode; otherwise null. |
See also
- Connecting to Svantic — when to pick connected vs. hosted.
MeshConnectorConfig- Attach to Express
