feat: add matrix channel plugin

This commit is contained in:
Peter Steinberger
2026-01-15 08:29:17 +00:00
parent f4bb5b381d
commit 725a6b71dc
51 changed files with 3986 additions and 24 deletions

View File

@@ -41,6 +41,7 @@ export function buildThreadingToolContext(params: {
To: threadingTo,
ReplyToId: sessionCtx.ReplyToId,
ThreadLabel: sessionCtx.ThreadLabel,
MessageThreadId: sessionCtx.MessageThreadId,
},
hasRepliedRef,
}) ?? {}

View File

@@ -216,9 +216,11 @@ export async function runReplyAgent(params: {
abortedLastRun: false,
};
const agentId = resolveAgentIdFromSessionKey(sessionKey);
const topicId =
typeof sessionCtx.MessageThreadId === "number" ? sessionCtx.MessageThreadId : undefined;
const nextSessionFile = resolveSessionTranscriptPath(nextSessionId, agentId, topicId);
const nextSessionFile = resolveSessionTranscriptPath(
nextSessionId,
agentId,
sessionCtx.MessageThreadId,
);
nextEntry.sessionFile = nextSessionFile;
activeSessionStore[sessionKey] = nextEntry;
try {

View File

@@ -23,7 +23,10 @@ export function buildInboundDedupeKey(ctx: MsgContext): string | null {
if (!peerId) return null;
const sessionKey = ctx.SessionKey?.trim() ?? "";
const accountId = ctx.AccountId?.trim() ?? "";
const threadId = typeof ctx.MessageThreadId === "number" ? String(ctx.MessageThreadId) : "";
const threadId =
ctx.MessageThreadId !== undefined && ctx.MessageThreadId !== null
? String(ctx.MessageThreadId)
: "";
return [provider, accountId, sessionKey, peerId, threadId, messageId].filter(Boolean).join("|");
}

View File

@@ -36,8 +36,8 @@ export type FollowupRun = {
originatingTo?: string;
/** Provider account id (multi-account). */
originatingAccountId?: string;
/** Telegram forum topic thread id. */
originatingThreadId?: number;
/** Thread id for reply routing (Telegram topic id or Matrix thread event id). */
originatingThreadId?: string | number;
run: {
agentId: string;
agentDir: string;

View File

@@ -27,8 +27,8 @@ export type RouteReplyParams = {
sessionKey?: string;
/** Provider account id (multi-account). */
accountId?: string;
/** Telegram message thread id (forum topics). */
threadId?: number;
/** Thread id for replies (Telegram topic id or Matrix thread event id). */
threadId?: string | number;
/** Config for provider-specific settings. */
cfg: ClawdbotConfig;
/** Optional abort signal for cooperative cancellation. */

View File

@@ -53,8 +53,8 @@ export type MsgContext = {
CommandAuthorized?: boolean;
CommandSource?: "text" | "native";
CommandTargetSessionKey?: string;
/** Telegram forum topic thread ID. */
MessageThreadId?: number;
/** Thread identifier (Telegram topic id or Matrix thread event id). */
MessageThreadId?: string | number;
/** Telegram forum supergroup marker. */
IsForum?: boolean;
/**