From 8ea5c22985aea8f37110babc0502cabf514d9988 Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Sat, 28 Mar 2026 15:35:05 +0530 Subject: [PATCH] fix(matrix): avoid heavy jiti runtime barrels --- extensions/matrix/runtime-api.ts | 21 ++++++++++++++++++--- extensions/matrix/src/account-selection.ts | 12 ++++++------ src/plugin-sdk/account-core.ts | 1 + 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/extensions/matrix/runtime-api.ts b/extensions/matrix/runtime-api.ts index 9bcb83a8e01..d24bd6f9398 100644 --- a/extensions/matrix/runtime-api.ts +++ b/extensions/matrix/runtime-api.ts @@ -32,6 +32,21 @@ export type { RuntimeLogger, RuntimeEnv, WizardPrompter, -} from "openclaw/plugin-sdk/matrix"; -export { formatZonedTimestamp } from "openclaw/plugin-sdk/matrix"; -export { chunkTextForOutbound } from "openclaw/plugin-sdk/matrix"; +} from "openclaw/plugin-sdk/matrix-runtime-shared"; +export { formatZonedTimestamp } from "openclaw/plugin-sdk/matrix-runtime-shared"; + +export function chunkTextForOutbound(text: string, limit: number): string[] { + const chunks: string[] = []; + let remaining = text; + while (remaining.length > limit) { + const window = remaining.slice(0, limit); + const splitAt = Math.max(window.lastIndexOf("\n"), window.lastIndexOf(" ")); + const breakAt = splitAt > 0 ? splitAt : limit; + chunks.push(remaining.slice(0, breakAt).trimEnd()); + remaining = remaining.slice(breakAt).trimStart(); + } + if (remaining.length > 0 || text.length === 0) { + chunks.push(remaining); + } + return chunks; +} diff --git a/extensions/matrix/src/account-selection.ts b/extensions/matrix/src/account-selection.ts index 8804c5fc5f2..33b1f5ac69e 100644 --- a/extensions/matrix/src/account-selection.ts +++ b/extensions/matrix/src/account-selection.ts @@ -1,14 +1,14 @@ -import { - DEFAULT_ACCOUNT_ID, - normalizeAccountId, - normalizeOptionalAccountId, -} from "openclaw/plugin-sdk/account-id"; import { listCombinedAccountIds, listConfiguredAccountIds, resolveListedDefaultAccountId, resolveNormalizedAccountEntry, -} from "openclaw/plugin-sdk/account-resolution"; +} from "openclaw/plugin-sdk/account-core"; +import { + DEFAULT_ACCOUNT_ID, + normalizeAccountId, + normalizeOptionalAccountId, +} from "openclaw/plugin-sdk/account-id"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { listMatrixEnvAccountIds } from "./env-vars.js"; diff --git a/src/plugin-sdk/account-core.ts b/src/plugin-sdk/account-core.ts index e40508b6cfb..a8129970270 100644 --- a/src/plugin-sdk/account-core.ts +++ b/src/plugin-sdk/account-core.ts @@ -6,6 +6,7 @@ export { describeAccountSnapshot, listCombinedAccountIds, mergeAccountConfig, + resolveListedDefaultAccountId, resolveMergedAccountConfig, } from "../channels/plugins/account-helpers.js"; export { normalizeChatType } from "../channels/chat-type.js";