import { requireRuntimeConfig } from "openclaw/plugin-sdk/config-runtime"; import type { CoreConfig } from "../../types.js"; import { resolveMatrixAccountConfig } from "../account-config.js"; import type { MatrixClient } from "../sdk.js";
type MatrixSendClientRuntime = Pick< typeofimport("../client-bootstrap.js"), "withResolvedRuntimeMatrixClient"
>;
let matrixSendClientRuntimePromise: Promise<MatrixSendClientRuntime> | null = null;
export function resolveMediaMaxBytes(
accountId?: string | null,
cfg?: CoreConfig,
): number | undefined { if (!cfg) { thrownew Error( "Matrix media limits requires a resolved runtime config. Load and resolve config at the command or gateway boundary, then pass cfg through the runtime path.",
);
} const resolvedCfg = requireRuntimeConfig(cfg, "Matrix media limits") as CoreConfig; const matrixCfg = resolveMatrixAccountConfig({ cfg: resolvedCfg, accountId }); const mediaMaxMb = typeof matrixCfg.mediaMaxMb === "number" ? matrixCfg.mediaMaxMb : undefined; if (typeof mediaMaxMb === "number") { return mediaMaxMb * 1024 * 1024;
} return undefined;
}
export async function withResolvedMatrixSendClient<T>(
opts: {
client?: MatrixClient;
cfg?: CoreConfig;
timeoutMs?: number;
accountId?: string | null;
},
run: (client: MatrixClient) => Promise<T>,
): Promise<T> { return await withResolvedMatrixClient(
{
...opts, // One-off outbound sends still need a started client so room encryption // state and live crypto sessions are available before sendMessage/sendEvent.
readiness: "started",
},
run, // Started one-off send clients should flush sync/crypto state before CLI // shutdown paths can tear down the process. "persist",
);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.