From 675b80c4a4defdf8c88cb7dec3f170e48501a095 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Tue, 31 Mar 2026 21:55:59 +0900 Subject: [PATCH] perf(slack): narrow send chunking imports --- extensions/slack/src/send.ts | 6 +++--- extensions/slack/src/send.upload.test.ts | 6 +----- package.json | 4 ++++ scripts/lib/plugin-sdk-entrypoints.json | 1 + src/plugin-sdk/reply-chunking.ts | 6 ++++++ 5 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 src/plugin-sdk/reply-chunking.ts diff --git a/extensions/slack/src/send.ts b/extensions/slack/src/send.ts index d233dd02954..b6a9c4c11a0 100644 --- a/extensions/slack/src/send.ts +++ b/extensions/slack/src/send.ts @@ -2,13 +2,13 @@ import { type Block, type KnownBlock, type WebClient } from "@slack/web-api"; import { loadConfig, type OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/config-runtime"; import { withTrustedEnvProxyGuardedFetchMode } from "openclaw/plugin-sdk/fetch-runtime"; -import { resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload"; import { chunkMarkdownTextWithMode, + isSilentReplyText, resolveChunkMode, resolveTextChunkLimit, -} from "openclaw/plugin-sdk/reply-runtime"; -import { isSilentReplyText } from "openclaw/plugin-sdk/reply-runtime"; +} from "openclaw/plugin-sdk/reply-chunking"; +import { resolveTextChunksWithFallback } from "openclaw/plugin-sdk/reply-payload"; import { logVerbose } from "openclaw/plugin-sdk/runtime-env"; import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime"; import { loadWebMedia } from "openclaw/plugin-sdk/web-media"; diff --git a/extensions/slack/src/send.upload.test.ts b/extensions/slack/src/send.upload.test.ts index a0c26f6ce1b..b11b390257d 100644 --- a/extensions/slack/src/send.upload.test.ts +++ b/extensions/slack/src/send.upload.test.ts @@ -33,6 +33,7 @@ vi.mock("openclaw/plugin-sdk/web-media", () => ({ let sendMessageSlack: typeof import("./send.js").sendMessageSlack; let clearSlackDmChannelCache: typeof import("./send.js").clearSlackDmChannelCache; +({ sendMessageSlack, clearSlackDmChannelCache } = await import("./send.js")); type UploadTestClient = WebClient & { conversations: { open: ReturnType }; @@ -65,11 +66,6 @@ function createUploadTestClient(): UploadTestClient { describe("sendMessageSlack file upload with user IDs", () => { const originalFetch = globalThis.fetch; - beforeAll(async () => { - vi.resetModules(); - ({ sendMessageSlack, clearSlackDmChannelCache } = await import("./send.js")); - }); - beforeEach(() => { globalThis.fetch = vi.fn( async () => new Response("ok", { status: 200 }), diff --git a/package.json b/package.json index cf312d15696..727460f7057 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,10 @@ "types": "./dist/plugin-sdk/reply-runtime.d.ts", "default": "./dist/plugin-sdk/reply-runtime.js" }, + "./plugin-sdk/reply-chunking": { + "types": "./dist/plugin-sdk/reply-chunking.d.ts", + "default": "./dist/plugin-sdk/reply-chunking.js" + }, "./plugin-sdk/reply-payload": { "types": "./dist/plugin-sdk/reply-payload.d.ts", "default": "./dist/plugin-sdk/reply-payload.js" diff --git a/scripts/lib/plugin-sdk-entrypoints.json b/scripts/lib/plugin-sdk-entrypoints.json index 107b2b9fb3c..db4f9512ae5 100644 --- a/scripts/lib/plugin-sdk-entrypoints.json +++ b/scripts/lib/plugin-sdk-entrypoints.json @@ -15,6 +15,7 @@ "approval-runtime", "config-runtime", "reply-runtime", + "reply-chunking", "reply-payload", "channel-reply-pipeline", "channel-runtime", diff --git a/src/plugin-sdk/reply-chunking.ts b/src/plugin-sdk/reply-chunking.ts new file mode 100644 index 00000000000..a2fb8edef12 --- /dev/null +++ b/src/plugin-sdk/reply-chunking.ts @@ -0,0 +1,6 @@ +export { + chunkMarkdownTextWithMode, + resolveChunkMode, + resolveTextChunkLimit, +} from "../auto-reply/chunk.js"; +export { isSilentReplyText } from "../auto-reply/tokens.js";