dirextalk-message-server

module
v1.1.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: AGPL-3.0

README

Dirextalk Message Server

Dirextalk Message Server is Dirextalk's backend contract authority. It combines a Matrix-compatible homeserver, ProductCore actions, product policy, projections, external MCP access, and the authenticated proxy to the separately deployed Native Agent runtime in one Go service.

It is based on Element Dendrite, but this repository is maintained as a Dirextalk product server rather than a general-purpose Matrix homeserver distribution.

Dirextalk Message Server overview

中文说明

Each personal node keeps one contract boundary for Matrix, ProductCore, and Native Agent:

  • Matrix is the source of truth for rooms, membership, ordinary messages, media, history, search, unread state, and redaction.
  • ProductCore actions provide the authenticated product facade for validation, remote forwarding, Matrix write orchestration, and projection reads.
  • PostgreSQL-backed P2P tables are projection/read models unless a current contract explicitly makes a record authoritative.
  • Flutter connects only to Message Server. The external dirextalk-agent service owns Native Agent execution and data; Message Server preserves the existing owner-authenticated agent.* actions and Native Agent WS frames.
  • POST /mcp and Agent Product Capability callbacks reuse Message Server's product/Matrix services. They do not make Native Agent part of the plugin lifecycle or create a second client-facing API.

Runtime

  • Production entry point: cmd/dirextalk-message-server
  • Docker image: dirextalk/message-server:latest
  • Default config path in Docker: /etc/dirextalk-message-server/message-server.yaml
  • Default data path in Docker: /var/dirextalk-message-server
  • Go module: github.com/YingSuiAI/dirextalk-message-server
  • Go version: 1.26.5
  • Server database: PostgreSQL only; SQLite and file DSNs are unsupported.
  • Docker development database: PostgreSQL 18

API Surface

Matrix protocol routes remain under:

  • /_matrix/*
  • /_synapse/*
  • /_dendrite/*
  • /.well-known/matrix/*

Dirextalk product APIs use the body-action surface:

  • GET /_p2p/health
  • POST /_p2p/query
  • POST /_p2p/command
  • GET /_p2p/ws
  • GET /.well-known/portal/owner.json

The generated ProductCore action metadata is docs/product-action-contract.json; it is the checkable action list and may change as capabilities are added. Owner clients prefer client.request/server.response over the realtime WebSocket and use HTTP query/command fallback when realtime is not ready. External MCP clients use JSON-RPC over POST /mcp with an agent_token.

Authentication and transport boundaries:

  • Owner ProductCore actions use Authorization: Bearer <access_token>.
  • realtime.ws_ticket.create issues a short-lived single-use owner ticket; GET /_p2p/ws accepts that ticket, not a bearer token.
  • agent_token is limited to agent.matrix_session.create and the standard POST /mcp endpoint; it cannot create an owner WebSocket ticket or call owner actions.

Product requests use this envelope:

{
  "action": "channels.public.get",
  "params": {
    "room_id": "!room:dendrite-a:8448",
    "remote_node_base_url": "https://dendrite-a:8448/_p2p"
  }
}

Local Development

Run commands from the repository root. PowerShell, Bash on Linux, Bash on macOS, and Bash in WSL are all supported; choose the command form that matches the shell you are using.

Build the server:

go build ./cmd/dirextalk-message-server
go build ./cmd/dendrite

Run the single-node Docker stack:

docker compose -f docker-compose.p2p.yml up --build
docker compose -f docker-compose.p2p.yml exec message-server cat /var/dirextalk-message-server/p2p/bootstrap.json

Run the three-node regression stack.

PowerShell:

$env:P2P_DUAL_PUBLIC_HOST = if ($env:P2P_DUAL_PUBLIC_HOST) { $env:P2P_DUAL_PUBLIC_HOST } else { "host.docker.internal" }
docker compose -f docker-compose.p2p-dual.yml up -d --force-recreate dendrite-a dendrite-b dendrite-c
python scripts/p2p-three-node-regression.py

Bash on Linux, macOS, or WSL:

export P2P_DUAL_PUBLIC_HOST="${P2P_DUAL_PUBLIC_HOST:-host.docker.internal}"
docker compose -f docker-compose.p2p-dual.yml up -d --force-recreate dendrite-a dendrite-b dendrite-c
python3 scripts/p2p-three-node-regression.py

Run tests against a local PostgreSQL instance:

PowerShell:

$env:POSTGRES_USER = "postgres"
$env:POSTGRES_PASSWORD = "123789"
$env:POSTGRES_HOST = "localhost"
$env:POSTGRES_PORT = "5432"
$env:POSTGRES_DB = "postgres"
go test ./p2p ./internal/productpolicy -count=1

Bash:

export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=123789
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_DB=postgres
go test ./p2p ./internal/productpolicy -count=1

The Go test helper creates isolated dendrite_test_* databases and drops them when each test finishes.

Contract Sources

Read these maintained current sources before changing clients, deployment tooling, or Agent/MCP behavior:

Documentation

Current maintained docs are intentionally small. Historical Dendrite site docs, obsolete trackers, and one-off implementation plans are not maintained in this fork.

License

This project retains upstream license and copyright notices where code originates from Element Dendrite. See LICENSE and LICENSE-COMMERCIAL.

Directories

Path Synopsis
api
Package api contains methods used by dendrite components in multi-process mode to send requests to the appservice component, typically in order to ask an application service for some information.
Package api contains methods used by dendrite components in multi-process mode to send requests to the appservice component, typically in order to ask an application service for some information.
query
Package query handles requests from other internal dendrite components when they interact with the AppServiceQueryAPI.
Package query handles requests from other internal dendrite components when they interact with the AppServiceQueryAPI.
api
auth
Package auth implements authentication checks and storage.
Package auth implements authentication checks and storage.
cmd
create-account command
dendrite command
furl command
generate-config command
generate-keys command
resolve-state command
api
agentstream
Package agentstream contains the transport-neutral Native Agent stream contract.
Package agentstream contains the transport-neutral Native Agent stream contract.
hooks
Package hooks exposes places in Dendrite where custom code can be executed, useful for MSCs.
Package hooks exposes places in Dendrite where custom code can be executed, useful for MSCs.
p2p
internal/action
Package action owns the shared ProductCore action boundary primitives.
Package action owns the shared ProductCore action boundary primitives.
internal/agent
Package agent owns the narrow account projection shared by the external Native Agent gateway and the Matrix-backed Online Agent.
Package agent owns the narrow account projection shared by the external Native Agent gateway and the Matrix-backed Online Agent.
internal/blocks
Package blocks owns ProductCore contact-block actions and block lookups.
Package blocks owns ProductCore contact-block actions and block lookups.
internal/calls
Package calls owns ProductCore call-session actions and lifecycle projection.
Package calls owns ProductCore call-session actions and lifecycle projection.
internal/channels
Package channels owns ProductCore channel CRUD, listing, lifecycle, and member-count persistence orchestration.
Package channels owns ProductCore channel CRUD, listing, lifecycle, and member-count persistence orchestration.
internal/contacts
Package contacts owns contact reads and durable contact-save orchestration.
Package contacts owns contact reads and durable contact-save orchestration.
internal/conversation
Package conversation owns ProductCore conversation actions and read-model presentation.
Package conversation owns ProductCore conversation actions and read-model presentation.
internal/events
Package events owns the durable ProductCore event stream, sequence allocation, retention, cursor validation, and live waiter notification.
Package events owns the durable ProductCore event stream, sequence allocation, retention, cursor validation, and live waiter notification.
internal/groups
Package groups owns ProductCore group CRUD, listing, lifecycle, and policy actions.
Package groups owns ProductCore group CRUD, listing, lifecycle, and policy actions.
internal/httpapi
Package httpapi owns the ProductCore and MCP HTTP protocol adapters.
Package httpapi owns the ProductCore and MCP HTTP protocol adapters.
internal/mcp
Package mcp adapts Dirextalk product state and Matrix transport to the shared internal/dirextalkmcp capability service.
Package mcp adapts Dirextalk product state and Matrix transport to the shared internal/dirextalkmcp capability service.
internal/members
Package members owns shared ProductCore group and channel member reads and lifecycle and policy mutations.
Package members owns shared ProductCore group and channel member reads and lifecycle and policy mutations.
internal/operations
Package operations defines durable records for recoverable ProductCore operations.
Package operations defines durable records for recoverable ProductCore operations.
internal/plugins
Package plugins owns the non-Agent plugin ProductCore actions, persistence orchestration, invocation validation, and Docker runner boundary.
Package plugins owns the non-Agent plugin ProductCore actions, persistence orchestration, invocation validation, and Docker runner boundary.
internal/portal
Package portal owns portal authentication, session rotation, password, and runtime-status ProductCore workflows.
Package portal owns portal authentication, session rotation, password, and runtime-status ProductCore workflows.
internal/profile
Package profile owns the owner profile ProductCore workflow and public well-known projection.
Package profile owns the owner profile ProductCore workflow and public well-known projection.
internal/projector
Package projector owns roomserver output consumption and projection dispatch.
Package projector owns roomserver output consumption and projection dispatch.
internal/realtimews
Package realtimews owns the ProductCore realtime WebSocket transport.
Package realtimews owns the ProductCore realtime WebSocket transport.
internal/registryjson
Package registryjson contains strict JSON primitives for built-in registries.
Package registryjson contains strict JSON primitives for built-in registries.
internal/release
Package release owns the ProductCore release status, apply, and client-build reporting workflows.
Package release owns the ProductCore release status, apply, and client-build reporting workflows.
internal/reports
Package reports owns report submission, durable report creation, and the related Matrix system-notification projection.
Package reports owns report submission, durable report creation, and the related Matrix system-notification projection.
internal/social
Package social owns ProductCore favorite and follow actions.
Package social owns ProductCore favorite and follow actions.
api
api
Package api provides the types that are used to communicate with the roomserver.
Package api provides the types that are used to communicate with the roomserver.
internal/input
Package input contains the code processes new room events
Package input contains the code processes new room events
types
Package types provides the types that are used internally within the roomserver.
Package types provides the types that are used internally within the roomserver.
mscs
Package mscs implements Matrix Spec Changes from https://github.com/matrix-org/matrix-doc
Package mscs implements Matrix Spec Changes from https://github.com/matrix-org/matrix-doc
mscs/msc2836
Package msc2836 'Threading' implements https://github.com/matrix-org/matrix-doc/pull/2836
Package msc2836 'Threading' implements https://github.com/matrix-org/matrix-doc/pull/2836
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL