mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-05 11:51:35 +00:00
* fix: normalize fractional text chunk limits * fix: normalize markdown chunk limits * fix: normalize direct newline chunk limits * fix(matrix): reuse progress-safe text chunker * test(matrix): align runtime API guard * test(matrix): keep outbound shard topology stable * fix(matrix): preserve facade chunk compatibility * test(matrix): keep runtime export guard stable * fix(matrix): normalize render-aware chunk limits * test(matrix): type real-send assertions * fix(matrix): preserve one-unit event limits --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
81 lines
2.9 KiB
TypeScript
81 lines
2.9 KiB
TypeScript
// Matrix API module exposes the plugin public contract.
|
|
import { chunkTextForOutbound as chunkTextForOutboundSdk } from "openclaw/plugin-sdk/text-chunking";
|
|
|
|
export {
|
|
type MatrixResolvedStringField,
|
|
type MatrixResolvedStringValues,
|
|
resolveMatrixAccountStringValues,
|
|
} from "./src/auth-precedence.js";
|
|
export {
|
|
requiresExplicitMatrixDefaultAccount,
|
|
resolveMatrixDefaultOrOnlyAccountId,
|
|
} from "./src/account-selection.js";
|
|
export {
|
|
findMatrixAccountEntry,
|
|
resolveConfiguredMatrixAccountIds,
|
|
resolveMatrixChannelConfig,
|
|
} from "./src/account-selection.js";
|
|
export {
|
|
getMatrixScopedEnvVarNames,
|
|
listMatrixEnvAccountIds,
|
|
resolveMatrixEnvAccountToken,
|
|
} from "./src/env-vars.js";
|
|
export {
|
|
hashMatrixAccessToken,
|
|
resolveMatrixAccountStorageRoot,
|
|
resolveMatrixCredentialsDir,
|
|
resolveMatrixCredentialsFilename,
|
|
resolveMatrixCredentialsPath,
|
|
resolveMatrixHomeserverKey,
|
|
sanitizeMatrixPathSegment,
|
|
} from "./src/storage-paths.js";
|
|
export { ensureMatrixSdkInstalled, isMatrixSdkAvailable } from "./src/matrix/deps.js";
|
|
export {
|
|
assertHttpUrlTargetsPrivateNetwork,
|
|
closeDispatcher,
|
|
createPinnedDispatcher,
|
|
resolvePinnedHostnameWithPolicy,
|
|
ssrfPolicyFromDangerouslyAllowPrivateNetwork,
|
|
type LookupFn,
|
|
type SsrFPolicy,
|
|
} from "openclaw/plugin-sdk/ssrf-runtime";
|
|
export {
|
|
setMatrixThreadBindingIdleTimeoutBySessionKey,
|
|
setMatrixThreadBindingMaxAgeBySessionKey,
|
|
} from "./src/matrix/thread-bindings-shared.js";
|
|
export { setMatrixRuntime } from "./src/runtime.js";
|
|
export { writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
|
|
export type {
|
|
ChannelDirectoryEntry,
|
|
ChannelMessageActionContext,
|
|
} from "openclaw/plugin-sdk/channel-contract";
|
|
export type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
|
export { formatZonedTimestamp } from "openclaw/plugin-sdk/time-runtime";
|
|
export type { PluginRuntime, RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime";
|
|
export type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
|
export type { WizardPrompter } from "openclaw/plugin-sdk/setup";
|
|
|
|
// This facade shipped distinct empty and whitespace behavior. Preserve that
|
|
// contract while delegating fractional limits to the progress-safe SDK owner.
|
|
export function chunkTextForOutbound(text: string, limit: number): string[] {
|
|
if (text.length === 0) {
|
|
return [""];
|
|
}
|
|
if (Number.isFinite(limit) && limit > 0 && !Number.isInteger(limit)) {
|
|
return chunkTextForOutboundSdk(text, limit);
|
|
}
|
|
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) {
|
|
chunks.push(remaining);
|
|
}
|
|
return chunks;
|
|
}
|