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.
| Family | Manager | Credentials in | Gives the agent |
|---|---|---|---|
| Official integrations | IntegrationManager (services/integrations/manager.js) | integration_connections | Tools, triggers, memory ingestion |
| Messaging platforms | MessagingManager (services/messaging/manager.js) | platform_connections | Inbound 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*Providerfunction. - Contract. A provider declares
key,label,description,apps,getApp(),getEnvStatus(),getToolDefinitions(),supportsTool()andbuildSnapshot(). - Uniqueness. Duplicate provider keys fail startup.
| Provider key | Apps |
|---|---|
google_workspace | gmail, calendar, drive, docs, sheets |
microsoft_365 | outlook, calendar, onedrive, teams |
slack | slack |
github | repos, mentions |
notion, trello, figma, spotify | One app each |
nextcloud | files, calendar, contacts |
home_assistant | home_assistant |
neorecall | recall |
neocloud | files |
bitwarden | password_manager |
whatsapp_personal | personal |
news, weather | headlines, forecast |
tailscale | tailnet |
Connecting an account
- Start. The app requests an authorization URL; the server stores a short-lived state and an encrypted PKCE verifier in
integration_oauth_states. - Callback. The provider redirects to
/api/integrations/oauth/callback. - Exchange. The provider module trades the code for tokens.
- Merge. New tokens are merged with any existing ones, so a refresh without
refresh_tokenkeeps the old one. - Store. Credentials are encrypted with
NEOAGENT_ENCRYPTION_KEY(orSESSION_SECRET) and written tointegration_connections.
The shared callback also serves two other flows, told apart by the state prefix:
state | Flow | Module |
|---|---|---|
auth_… | Sign in to NeoAgent with an external account | services/account/auth_provider_manager.js |
model_… | "Sign in with OpenRouter" for a model API key | services/ai/provider_sign_in/ (route /api/provider-sign-in) |
| No prefix (48 hex characters) | Official integration connection | services/integrations/manager.js |
- Model sign-in.
provider_sign_in/index.jskeeps PKCE flows in memory for 10 minutes;openrouter.jsis 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
- Expose.
getToolDefinitions()adds a provider's tools only for apps with aconnectedconnection. - Select.
executeTool()picks the connection fromconnection_idoraccount_email, or the default. - Enforce. A write tool on a
read_onlyconnection is refused before the provider runs. - Refresh. Tokens expiring within 60 seconds are refreshed first; a
401triggers one refresh and retry. - Run. The provider's
executeTool()handles the call. - Persist. Updated credentials are written back encrypted.
- Usage notes.
summarizeConnectedProviders()sends each integration's notes once per run, alongside its tools. - Access mode.
read_writeorread_onlyper connection, set withaccessMode; 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
| Aspect | Behavior |
|---|---|
| Setup | The user enters the NeoRecall base URL; OAuth bootstrap returns a client ID |
| Auth | PKCE (S256), scopes search:read, memories:read, recordings:read, refresh token required |
| Data | Queried on demand; never copied into NeoAgent memory |
| Tools | neorecall_search, neorecall_list_memories, neorecall_get_memory, neorecall_list_mini_memories, neorecall_list_daily_summaries, neorecall_list_conversations, neorecall_get_conversation |
| Limits | Tools 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
| Aspect | Behavior |
|---|---|
| Setup | The user enters the NeoCloud URL; NeoAgent requires /api/health status: ok and /api/version product: neocloud, then OAuth bootstrap returns a client ID |
| Auth | PKCE (S256), requests files:read, files:write, signing:read, signing:write; the user narrows them on NeoCloud's consent page; refresh tokens rotate |
| Granted scopes | Stored 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 |
| Tools | neocloud_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 |
| Data | Queried 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.
| Adapter | Platforms | Inbound |
|---|---|---|
| Native clients | whatsapp (Baileys), discord (discord.js), telegram (Telegraf), github | Long-lived client |
http_platforms.js | slack, google_chat, teams, signal, line, mattermost, bluebubbles, imessage (through BlueBubbles) | Webhook at /api/messaging/webhook/:platform |
http_platforms.js | matrix | Sync polling |
| IRC | irc, twitch | IRC connection |
| Generic HTTP | feishu, nextcloud_talk, nostr, synology_chat, tlon, zalo, zalo_personal, wechat, webchat | Configurable 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 inagent-data/messaging-auth/<user>/<agent>/whatsapp. - No telephony. There is no SMS or phone-number channel.
Inbound message flow
- Receive. The adapter emits a normalized message.
- Persist.
MessagingManagerwrites it tomessaging_inbound_jobs; unfinished jobs are replayed after a restart. - Access.
access_policy.jschecks the sender and chat allowlists. - Queue.
inbound_queue.jsserializes messages per user, agent, platform and chat. - Behavior.
services/behavior/decides whether to speak in group chats (addressing, turn-taking). - Run.
agentEngine.run()starts withtriggerSource: 'messaging'while a typing indicator is kept alive. - Reply. The agent answers with
send_message, or the final answer is delivered as a fallback.
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/.