Skip to main content

Integrations and messaging architecture

Official integrations give agents tools over a user's accounts, while messaging platforms carry conversations in and out; the two families keep separate credentials and code paths.

FamilyManagerCredentials inGives the agent
Official integrationsIntegrationManager (services/integrations/manager.js)integration_connectionsTools, triggers, memory ingestion
Messaging platformsMessagingManager (services/messaging/manager.js)platform_connectionsInbound chats, send_message delivery

Integration registry​

services/integrations/registry.js discovers every <provider>/provider.js at startup; there is no central list.

  • Factory. Each module exports exactly one create*Provider function.
  • Contract. A provider declares key, label, description, apps, getApp(), getEnvStatus(), getToolDefinitions(), supportsTool() and buildSnapshot().
  • Uniqueness. Duplicate provider keys fail startup.
Provider keyApps
google_workspacegmail, calendar, drive, docs, sheets
microsoft_365outlook, calendar, onedrive, teams
slackslack
githubrepos, mentions
notion, trello, figma, spotifyOne app each
nextcloudfiles, calendar, contacts
home_assistanthome_assistant
neorecallrecall
neocloudfiles
bitwardenpassword_manager
whatsapp_personalpersonal
news, weatherheadlines, forecast
tailscaletailnet

Connecting an account​

  1. Start. The app requests an authorization URL; the server stores a short-lived state and an encrypted PKCE verifier in integration_oauth_states.
  2. Callback. The provider redirects to /api/integrations/oauth/callback.
  3. Exchange. The provider module trades the code for tokens.
  4. Merge. New tokens are merged with any existing ones, so a refresh without refresh_token keeps the old one.
  5. Store. Credentials are encrypted with NEOAGENT_ENCRYPTION_KEY (or SESSION_SECRET) and written to integration_connections.

The shared callback also serves two other flows, told apart by the state prefix:

stateFlowModule
auth_…Sign in to NeoAgent with an external accountservices/account/auth_provider_manager.js
model_…"Sign in with OpenRouter" for a model API keyservices/ai/provider_sign_in/ (route /api/provider-sign-in)
No prefix (48 hex characters)Official integration connectionservices/integrations/manager.js
  • Model sign-in. provider_sign_in/index.js keeps PKCE flows in memory for 10 minutes; openrouter.js is the only method today.
  • Scope. Connections belong to a user, agent, provider and account (account_email).
  • Config-based providers. Nextcloud, Home Assistant, Trello, Bitwarden, NeoRecall, NeoCloud and news use a user-entered config instead of, or before, OAuth.

Tool execution​

  1. Expose. getToolDefinitions() adds a provider's tools only for apps with a connected connection.
  2. Select. executeTool() picks the connection from connection_id or account_email, or the default.
  3. Enforce. A write tool on a read_only connection is refused before the provider runs.
  4. Refresh. Tokens expiring within 60 seconds are refreshed first; a 401 triggers one refresh and retry.
  5. Run. The provider's executeTool() handles the call.
  6. Persist. Updated credentials are written back encrypted.
  • Usage notes. summarizeConnectedProviders() sends each integration's notes once per run, alongside its tools.
  • Access mode. read_write or read_only per connection, set with accessMode; enforced in code, never by prompt wording.

Outbound Tailscale transport​

Tailscale uses the existing interactive connection-session contract. A session is bound to its initiating user and agent. The client opens the Tailscale-hosted node authorization URL and polls the scoped session endpoint; no server-wide OAuth app or tailnet identity is shared. The session response never includes node keys.

The provider owns snapshots and tool definitions; sessions.js owns authorization; policy.js validates service grants; runtime.js dispatches only to the user's isolated cloud VM. Guest client lifecycle, private LocalAPI transport and peer HTTP transport live in guest.js, guest_api.js and guest_network.js. The guest validates grants again and resolves exact peer IDs from its own node's status. The LocalAPI dial stream is consumed directly; Dial-Self is refused.

Operations on a connection are serialized to preserve rotated node state. The guest also serializes clients across connections to bound resource use to one client per VM. Normal clients have a 45-second operation deadline and an independent 50-second OS lifetime limit. Interactive authorization has a five-minute deadline. Disconnect fences the database row before canceling guest work, so queued calls cannot restart the connection. State snapshots are encrypted in integration_connections; temporary files reside in the guest's private shared memory directory and are removed after the client exits.

Memory ingestion​

  • Sweep. A mail provider may implement collectMemorySweep(), run once when an account connects; Google Workspace (Gmail) and Microsoft 365 (Outlook) do.
  • Coverage. Snapshots shown in the app are decorated with ingestion status, domains and document counts.
  • Details. See Memory architecture.

NeoRecall​

AspectBehavior
SetupThe user enters the NeoRecall base URL; OAuth bootstrap returns a client ID
AuthPKCE (S256), scopes search:read, memories:read, recordings:read, refresh token required
DataQueried on demand; never copied into NeoAgent memory
Toolsneorecall_search, neorecall_list_memories, neorecall_get_memory, neorecall_list_mini_memories, neorecall_list_daily_summaries, neorecall_list_conversations, neorecall_get_conversation
LimitsTools use NeoRecall's local hybrid search; none calls NeoRecall Ask or fetches audio

When NeoRecall is connected, neorecall_list_daily_summaries, neorecall_search and neorecall_list_conversations start active in every run.

NeoCloud​

AspectBehavior
SetupThe user enters the NeoCloud URL; NeoAgent requires /api/health status: ok and /api/version product: neocloud, then OAuth bootstrap returns a client ID
AuthPKCE (S256), requests files:read, files:write, signing:read, signing:write; the user narrows them on NeoCloud's consent page; refresh tokens rotate
Granted scopesStored on the connection (scopes_json). The provider's filterToolDefinitions hook offers a tool only when a connection granted its scope and, for writes, isn't read-only; execution re-checks the scope
Toolsneocloud_list_files, neocloud_search_files, neocloud_read_file, neocloud_create_file, neocloud_update_file, neocloud_create_folder, neocloud_move_file, neocloud_delete_file, neocloud_create_pdf, neocloud_request_signatures, neocloud_list_signature_requests, neocloud_get_signature_request, neocloud_remind_signers, neocloud_new_signing_link, neocloud_cancel_signature_request
DataQueried on demand over /api/v1; never copied into NeoAgent memory

createOAuthProvider accepts filterToolDefinitions(tools, connections); the manager passes the connected rows when it lists tools for a run, and other callers get the full set.

Messaging platforms​

MessagingManager.platformTypes registers 24 platform types.

AdapterPlatformsInbound
Native clientswhatsapp (Baileys), discord (discord.js), telegram (Telegraf), githubLong-lived client
http_platforms.jsslack, google_chat, teams, signal, line, mattermost, bluebubbles, imessage (through BlueBubbles)Webhook at /api/messaging/webhook/:platform
http_platforms.jsmatrixSync polling
IRCirc, twitchIRC connection
Generic HTTPfeishu, nextcloud_talk, nostr, synology_chat, tlon, zalo, zalo_personal, wechat, webchatConfigurable webhook
  • Contract. Adapters extend BasePlatform (messaging/base.js): connect(), disconnect(), sendMessage(), plus access-policy hooks.
  • Stored config. Platform config is stored encrypted in platform_connections; WhatsApp session files live in agent-data/messaging-auth/<user>/<agent>/whatsapp.
  • No telephony. There is no SMS or phone-number channel.

Inbound message flow​

  1. Receive. The adapter emits a normalized message.
  2. Persist. MessagingManager writes it to messaging_inbound_jobs; unfinished jobs are replayed after a restart.
  3. Access. access_policy.js checks the sender and chat allowlists.
  4. Queue. inbound_queue.js serializes messages per user, agent, platform and chat.
  5. Behavior. services/behavior/ decides whether to speak in group chats (addressing, turn-taking).
  6. Run. agentEngine.run() starts with triggerSource: 'messaging' while a typing indicator is kept alive.
  7. Reply. The agent answers with send_message, or the final answer is delivered as a fallback.
Personal WhatsApp is not the WhatsApp channel

The whatsapp_personal integration (tools and triggers over the owner's chats) and the whatsapp messaging platform (the agent's own chat channel) use separate sessions; the integration's live in agent-data/integrations/whatsapp-personal/.