mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 03:38:43 +00:00
* refactor: centralize inbound supplemental context * refactor: trim supplemental finalizer typing * docs: clarify supplemental context projection * refactor: move inbound finalization into core * refactor: simplify channel inbound facts * refactor: fold supplemental media into inbound finalizer * refactor: migrate channel inbound callers to builder * docs: mark inbound finalizer compat types deprecated * refactor: wire runtime turn context builder * refactor: replace channel turn runtime API * fix: respect discord quote visibility * fix: avoid deprecated line dispatch helper * refactor: deprecate channel message SDK seams * docs: trim channel outbound SDK page * test: migrate irc inbound assertion * refactor: deprecate outbound SDK facades * refactor: deprecate channel helper SDK facades * refactor: deprecate channel streaming SDK facade * refactor: move direct dm helpers into inbound SDK * chore: mark legacy test-utils SDK alias deprecated * refactor: remove unused allow-from read helper * refactor: route remaining channel dispatch through core * refactor: enforce modern extension SDK imports * test: give slow image root tests more time * ci: support node fallback on windows * fix: add transcripts tool display metadata * refactor: trim legacy channel test seams * fix: preserve channel compat after rebase * fix: keep deprecated channel inbound aliases * fix: preserve discord thread context visibility * fix: clean final rebase conflicts * fix: preserve channel message dispatch aliases * fix: sync channel refactor after rebase * fix: sync channel refactor after latest main * fix: dedupe memory-core subagent mock * test: align clickclack inbound dispatch assertions * fix: sync plugin sdk api hash after rebase * fix: sync channel refactor after latest main * fix: sync plugin sdk api hash after rebase * fix: sync plugin sdk api hash after latest main * test: remove stale inbound context awaits
44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
import { resolveChannelStreamingPreviewChunk } from "openclaw/plugin-sdk/channel-outbound";
|
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
|
|
import { resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-chunking";
|
|
import { resolveAccountEntry } from "openclaw/plugin-sdk/routing";
|
|
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
|
|
import { TELEGRAM_TEXT_CHUNK_LIMIT } from "./outbound-adapter.js";
|
|
|
|
const DEFAULT_TELEGRAM_DRAFT_STREAM_MIN = 200;
|
|
const DEFAULT_TELEGRAM_DRAFT_STREAM_MAX = 800;
|
|
|
|
export function resolveTelegramDraftStreamingChunking(
|
|
cfg: OpenClawConfig | undefined,
|
|
accountId?: string | null,
|
|
): {
|
|
minChars: number;
|
|
maxChars: number;
|
|
breakPreference: "paragraph" | "newline" | "sentence";
|
|
} {
|
|
const textLimit = resolveTextChunkLimit(cfg, "telegram", accountId, {
|
|
fallbackLimit: TELEGRAM_TEXT_CHUNK_LIMIT,
|
|
});
|
|
const normalizedAccountId = normalizeAccountId(accountId);
|
|
const accountCfg = resolveAccountEntry(cfg?.channels?.telegram?.accounts, normalizedAccountId);
|
|
const draftCfg =
|
|
resolveChannelStreamingPreviewChunk(accountCfg) ??
|
|
resolveChannelStreamingPreviewChunk(cfg?.channels?.telegram);
|
|
|
|
const maxRequested = Math.max(
|
|
1,
|
|
Math.floor(draftCfg?.maxChars ?? DEFAULT_TELEGRAM_DRAFT_STREAM_MAX),
|
|
);
|
|
const maxChars = Math.max(1, Math.min(maxRequested, textLimit));
|
|
const minRequested = Math.max(
|
|
1,
|
|
Math.floor(draftCfg?.minChars ?? DEFAULT_TELEGRAM_DRAFT_STREAM_MIN),
|
|
);
|
|
const minChars = Math.min(minRequested, maxChars);
|
|
const breakPreference =
|
|
draftCfg?.breakPreference === "newline" || draftCfg?.breakPreference === "sentence"
|
|
? draftCfg.breakPreference
|
|
: "paragraph";
|
|
return { minChars, maxChars, breakPreference };
|
|
}
|