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.
Attach to Express
Svantic agents don’t have to live in their own process. When you already have an Express service, you can mount an agent into it with a single call. This guide covers theattach() helper, which wires the A2A endpoints, the Svantic connection, and any declared triggers in one go.
When to use this
- You have an existing HTTP service and you want it to be callable from Svantic in addition to its normal duties.
- You want to share middleware, logging, and process lifecycle with that service.
- You want Svantic traffic to go through your own ingress for auditing.
new Agent({...}).start() is simpler. Use attach when there’s already an app to embed into.
Minimal example
attach returns an AgentHandle you can use to emit events or detach cleanly:
What attach does
- Calls
agent.expose(app)— mounts/.well-known/agent-card.jsonand/sendon your Express app. - Mounts each declared trigger (see Triggers).
- If
meshis provided, creates aMeshConnector, authenticates, registers the agent, and opens the WebSocket (connected mode) or leaves dispatches to hitpublic_url/send(hosted mode). - Installs
SIGTERM/SIGINThandlers that gracefully deregister. - Returns the handle.
Skipping the mesh
Omitmesh during local development to mount the agent without talking to Svantic at all — useful when running A2A clients directly against your local app:
Adding triggers
Register triggers on the agent withagent.add_triggers() before calling attach(). Hand-written or Forge-generated — each trigger carries a prompt template with {{placeholders}}:
Customizing how triggers dispatch
By default, triggers create a Svantic session and send the interpolated prompt to the agent. Override withagent.on_trigger:
Custom endpoint path
agent.expose() defaults to /send. To mount on a different path, use expose() directly instead of attach():
