Commit graph

8 commits

Author SHA1 Message Date
73713a574d fix: handle downloadContent response format correctly
client.downloadContent() returns {data: Buffer, contentType: string},
not a raw Buffer. This was causing media downloads to fail with
ERR_INVALID_ARG_TYPE.
2026-02-01 20:01:09 +01:00
68ebaf5014 debug: add file-based logging to track message handling
Writes to /home/keller/clawd/agents/mondo-assistant/matrix-debug.log
2026-02-01 19:44:52 +01:00
fc96f0e967 fix: deduplicate E2EE events + add debug logs
- Add event deduplication to prevent double-processing from room.message + room.decrypted_event
- Add console.log DEBUG output for decrypted_event and failed_decryption to diagnose E2EE file issues
2026-02-01 19:37:25 +01:00
8e36620140 fix: route decrypted E2EE events to message handler
Previously room.decrypted_event was only logged but not processed,
causing encrypted messages (including files) to be ignored by agents
with encryption enabled (like Mona).
2026-02-01 19:22:54 +01:00
2c653096eb fix: pass accountId to resolveAgentRoute for multi-account routing
The handler was calling resolveAgentRoute without accountId, causing
all Matrix messages to route to the default agent regardless of which
account received them.

Changes:
- Add accountId to MatrixMonitorHandlerParams type
- Extract accountId in createMatrixRoomMessageHandler
- Pass accountId to resolveAgentRoute call
- Pass accountId from monitorMatrixProvider to handler
2026-02-01 12:18:25 +01:00
91f9010237 fix: also serialize matrix/index.js import in channel.ts
The parallel account startup was crashing because the dynamic import
of ./matrix/index.js returned undefined when called concurrently.

Added importMatrixIndex() to import-mutex.ts and use it in channel.ts
to ensure the module is only imported once during parallel startup.
2026-02-01 11:35:37 +01:00
c0e38bb990 fix: serialize dynamic imports to prevent race condition on parallel account startup
Problem: When multiple Matrix accounts start in parallel, they all trigger
dynamic imports simultaneously. The Rust native crypto module
(@matrix-org/matrix-sdk-crypto-nodejs) crashes when loaded in parallel.

Solution: Add import-mutex.ts that caches import promises. Concurrent callers
now await the same promise instead of triggering parallel imports.

Files changed:
- NEW: src/matrix/import-mutex.ts - serializedImport() utility
- src/matrix/client/create-client.ts - use importCryptoNodejs()
- src/matrix/client/config.ts - use importCredentials()
2026-02-01 11:31:44 +01:00
8790ba5dad feat: Add multi-account Matrix support
- Modified shared.ts to maintain a Map of clients per accountId
- Each account gets its own Matrix client instance
- Backwards compatible with single-account usage
- resolveMatrixAuth now accepts accountId parameter
- stopSharedClient can stop specific or all accounts

Files changed:
- src/matrix/client/shared.ts (main changes)
- src/matrix/client/config.ts (accountId support)
- src/matrix/accounts.ts (list enabled accounts)
- src/matrix/monitor/index.ts (pass accountId)
- src/types.ts (accounts config type)
2026-02-01 11:06:37 +01:00