* refactor: move Discord channel implementation to extensions/discord/src/ Move all Discord source files from src/discord/ to extensions/discord/src/, following the extension migration pattern. Source files in src/discord/ are replaced with re-export shims. Channel-plugin files from src/channels/plugins/*/discord* are similarly moved and shimmed. - Copy all .ts source files preserving subdirectory structure (monitor/, voice/) - Move channel-plugin files (actions, normalize, onboarding, outbound, status-issues) - Fix all relative imports to use correct paths from new location - Create re-export shims at original locations for backward compatibility - Delete test files from shim locations (tests live in extension now) - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." to accommodate extension files outside src/ - Update write-plugin-sdk-entry-dts.ts to match new declaration output paths * fix: add importOriginal to thread-bindings session-meta mock for extensions test * style: fix formatting in thread-bindings lifecycle test
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { resolveTextChunkLimit } from "../../../src/auto-reply/chunk.js";
|
|
import { getChannelDock } from "../../../src/channels/dock.js";
|
|
import type { OpenClawConfig } from "../../../src/config/config.js";
|
|
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
|
|
import { normalizeAccountId } from "../../../src/routing/session-key.js";
|
|
|
|
const DEFAULT_DISCORD_DRAFT_STREAM_MIN = 200;
|
|
const DEFAULT_DISCORD_DRAFT_STREAM_MAX = 800;
|
|
|
|
export function resolveDiscordDraftStreamingChunking(
|
|
cfg: OpenClawConfig | undefined,
|
|
accountId?: string | null,
|
|
): {
|
|
minChars: number;
|
|
maxChars: number;
|
|
breakPreference: "paragraph" | "newline" | "sentence";
|
|
} {
|
|
const providerChunkLimit = getChannelDock("discord")?.outbound?.textChunkLimit;
|
|
const textLimit = resolveTextChunkLimit(cfg, "discord", accountId, {
|
|
fallbackLimit: providerChunkLimit,
|
|
});
|
|
const normalizedAccountId = normalizeAccountId(accountId);
|
|
const accountCfg = resolveAccountEntry(cfg?.channels?.discord?.accounts, normalizedAccountId);
|
|
const draftCfg = accountCfg?.draftChunk ?? cfg?.channels?.discord?.draftChunk;
|
|
|
|
const maxRequested = Math.max(
|
|
1,
|
|
Math.floor(draftCfg?.maxChars ?? DEFAULT_DISCORD_DRAFT_STREAM_MAX),
|
|
);
|
|
const maxChars = Math.max(1, Math.min(maxRequested, textLimit));
|
|
const minRequested = Math.max(
|
|
1,
|
|
Math.floor(draftCfg?.minChars ?? DEFAULT_DISCORD_DRAFT_STREAM_MIN),
|
|
);
|
|
const minChars = Math.min(minRequested, maxChars);
|
|
const breakPreference =
|
|
draftCfg?.breakPreference === "newline" || draftCfg?.breakPreference === "sentence"
|
|
? draftCfg.breakPreference
|
|
: "paragraph";
|
|
return { minChars, maxChars, breakPreference };
|
|
}
|