Skip to main content

Plugin Integration Guide

This guide walks you through integrating the @agentvault/agentvault library directly into your agent’s codebase for full programmatic control over the secure channel.
Not a developer? The Quick Start guide connects your agent with a single terminal command, no code required.
What you will accomplish:
  • Install and configure the agent plugin
  • Enroll your agent with an invite token
  • Approve the agent and establish an encrypted channel
  • Send and receive end-to-end encrypted messages
Time required: ~10 minutes

Prerequisites

  • An AgentVault account at agentvault.chat
  • Node.js 18+ on the machine where your agent runs
  • A Node.js or TypeScript project for your agent

1

Generate an invite token

  1. Log in to agentvault.chat
  2. Navigate to the Invites tab
  3. Enter a name for your agent (e.g., “Research Agent”)
  4. Tap Generate Invite
  5. Copy the token immediately — it is shown only once and expires in 10 minutes
The token looks like: av_tok_abc123def456...
Do not share invite tokens publicly. Anyone with the token can enroll a device to your account.
2

Install the plugin

In your agent’s project directory:
This package handles all cryptography, enrollment, and WebSocket communication automatically.
3

Add the secure channel to your agent

Create a file or add to your existing entry point:
4

Run your agent and approve it

Start your agent:
You will see:
Now go to the Agents tab at agentvault.chat, find the device marked Pending, verify the fingerprint matches, and tap Approve.Your agent’s output will update:
The secure channel is now live with end-to-end encryption.

Full Working Example

A complete echo agent that responds to every message:
Run it:

Configuration Reference

Constructor Options

Channel States

Properties and Methods


Persistence and Restarts

After the first enrollment, your agent reconnects automatically on restart — no new invite needed.
The dataDir folder contains your agent’s encrypted identity and ratchet state. Back it up. If lost, you will need to generate a new invite and re-enroll. If running in Docker, mount it as a volume.

What Happens Under the Hood

The plugin handles the full cryptographic lifecycle automatically:
  1. Key Generation — Ed25519 identity keys and X25519 ephemeral keys are generated locally on your agent’s machine
  2. Enrollment — Your agent proves possession of the private key and registers with the server
  3. Key Exchange — After approval, X3DH (Extended Triple Diffie-Hellman) key agreement establishes a shared secret with the owner
  4. Double Ratchet — Every message uses a fresh encryption key (forward secrecy). Old keys are deleted after decryption.
  5. WebSocket — Real-time bidirectional messaging with automatic reconnection on network interruption
  6. Persistence — Keys and ratchet state are saved to dataDir so your agent survives restarts without re-enrolling
The server never sees message content. Messages are encrypted before leaving your machine and only decrypted on the other end.

Troubleshooting

The invite token is invalid or expired. Generate a new one from the Invites tab in the dashboard. Tokens expire after 10 minutes.
The owner has not approved the device yet. Check the Agents tab at agentvault.chat and approve the pending device.
This indicates a network issue between your agent and the server. Verify that https://api.agentvault.chat is reachable from your agent’s machine. The agent will continue retrying automatically.
Make sure the dataDir directory is writable and persists across restarts. If running in Docker, mount it as a volume:
Both sides must be connected (agent in ready state, owner has the chat open). Messages sent while disconnected are queued and delivered on reconnect.

Security Notes

  • All messages are encrypted with XChaCha20-Poly1305 (AEAD)
  • The server stores only ciphertext — it cannot read your messages
  • Each message derives a unique key via the Double Ratchet protocol (forward secrecy)
  • Verify fingerprints during approval to prevent man-in-the-middle attacks
  • Revoking a device from the dashboard immediately disconnects it and invalidates its keys

Next Steps

Architecture Overview

Understand the full system architecture and data flow.

Security Model

Deep dive into the zero-knowledge design and threat model.