Fix plugin-sdk text boundary regressions

This commit is contained in:
Junebugg1214 2026-03-20 23:12:13 -04:00
parent 34231c48ca
commit 80bc497c8a
22 changed files with 99 additions and 30 deletions

View File

@ -1,5 +1,5 @@
import MarkdownIt from "markdown-it";
import { isAutoLinkedFileRef } from "openclaw/plugin-sdk/text-runtime";
import { isAutoLinkedFileRef } from "openclaw/plugin-sdk/text-core";
const md = new MarkdownIt({
html: false,

View File

@ -2,9 +2,9 @@ import type { MarkdownTableMode } from "openclaw/plugin-sdk/config-runtime";
import {
chunkMarkdownIR,
markdownToIR,
renderMarkdownWithMarkers,
type MarkdownLinkSpan,
} from "openclaw/plugin-sdk/text-runtime";
import { renderMarkdownWithMarkers } from "openclaw/plugin-sdk/text-runtime";
} from "openclaw/plugin-sdk/text-core";
// Escape special characters for Slack mrkdwn format.
// Preserve Slack's angle-bracket tokens so mentions and links stay intact.

View File

@ -7,7 +7,7 @@ import {
normalizeHyphenSlug,
normalizeStringEntries,
normalizeStringEntriesLower,
} from "openclaw/plugin-sdk/text-runtime";
} from "openclaw/plugin-sdk/text-core";
const SLACK_SLUG_CACHE_MAX = 512;
const slackSlugCache = new Map<string, string>();

View File

@ -24,7 +24,7 @@ import { normalizeMainKey } from "openclaw/plugin-sdk/routing";
import { warn } from "openclaw/plugin-sdk/runtime-env";
import { createNonExitingRuntime, type RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
import { normalizeStringEntries } from "openclaw/plugin-sdk/text-runtime";
import { normalizeStringEntries } from "openclaw/plugin-sdk/text-core";
import { resolveSlackAccount } from "../accounts.js";
import { resolveSlackWebClientOptions } from "../client.js";
import { normalizeSlackWebhookPath, registerSlackHttpHandler } from "../http/index.js";

View File

@ -11,7 +11,7 @@ import {
} from "openclaw/plugin-sdk/config-runtime";
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
import { danger, logVerbose } from "openclaw/plugin-sdk/runtime-env";
import { chunkItems } from "openclaw/plugin-sdk/text-runtime";
import { chunkItems } from "openclaw/plugin-sdk/text-core";
import type { ResolvedSlackAccount } from "../accounts.js";
import { truncateSlackText } from "../truncate.js";
import { resolveSlackAllowListMatch, resolveSlackUserAllowed } from "./allow-list.js";

View File

@ -1,5 +1,5 @@
import type { BaseProbeResult } from "openclaw/plugin-sdk/channel-contract";
import { withTimeout } from "openclaw/plugin-sdk/text-runtime";
import { withTimeout } from "openclaw/plugin-sdk/text-core";
import { createSlackWebClient } from "./client.js";
export type SlackProbe = BaseProbeResult & {

View File

@ -1,5 +1,5 @@
import type { WebClient } from "@slack/web-api";
import { isRecord } from "openclaw/plugin-sdk/text-runtime";
import { isRecord } from "openclaw/plugin-sdk/text-core";
import { createSlackWebClient } from "./client.js";
export type SlackScopesResult = {

View File

@ -1,4 +1,4 @@
import { resolveGlobalMap } from "openclaw/plugin-sdk/text-runtime";
import { resolveGlobalMap } from "openclaw/plugin-sdk/text-core";
/**
* In-memory cache of Slack threads the bot has participated in.

View File

@ -1,5 +1,4 @@
import { isRecord } from "openclaw/plugin-sdk/text-runtime";
import { fetchWithTimeout } from "openclaw/plugin-sdk/text-runtime";
import { fetchWithTimeout, isRecord } from "openclaw/plugin-sdk/text-core";
import type {
AuditTelegramGroupMembershipParams,
TelegramGroupMembershipAudit,

View File

@ -1,6 +1,6 @@
import type { Bot } from "grammy";
import { createFinalizableDraftLifecycle } from "openclaw/plugin-sdk/channel-lifecycle";
import { resolveGlobalSingleton } from "openclaw/plugin-sdk/text-runtime";
import { resolveGlobalSingleton } from "openclaw/plugin-sdk/text-core";
import { buildTelegramThreadParams, type TelegramThreadSpec } from "./bot/helpers.js";
import { isSafeToRetrySendError, isTelegramClientRejection } from "./network-errors.js";

View File

@ -4,10 +4,10 @@ import {
FILE_REF_EXTENSIONS_WITH_TLD,
isAutoLinkedFileRef,
markdownToIR,
renderMarkdownWithMarkers,
type MarkdownLinkSpan,
type MarkdownIR,
} from "openclaw/plugin-sdk/text-runtime";
import { renderMarkdownWithMarkers } from "openclaw/plugin-sdk/text-runtime";
} from "openclaw/plugin-sdk/text-core";
export type TelegramFormattedChunk = {
html: string;

View File

@ -1,5 +1,5 @@
import type { BaseProbeResult } from "openclaw/plugin-sdk/channel-contract";
import { fetchWithTimeout } from "openclaw/plugin-sdk/text-runtime";
import { fetchWithTimeout } from "openclaw/plugin-sdk/text-core";
import type { TelegramNetworkConfig } from "../runtime-api.js";
import { resolveTelegramFetch } from "./fetch.js";
import { makeProxyFetch } from "./proxy.js";

View File

@ -3,7 +3,7 @@ import {
resolveReactionLevel,
type ReactionLevel,
type ResolvedReactionLevel as BaseResolvedReactionLevel,
} from "openclaw/plugin-sdk/text-runtime";
} from "openclaw/plugin-sdk/text-core";
import { resolveTelegramAccount } from "./accounts.js";
export type TelegramReactionLevel = ReactionLevel;

View File

@ -1,7 +1,10 @@
import { formatReasoningMessage } from "openclaw/plugin-sdk/agent-runtime";
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
import { findCodeRegions, isInsideCode } from "openclaw/plugin-sdk/text-runtime";
import { stripReasoningTagsFromText } from "openclaw/plugin-sdk/text-runtime";
import {
findCodeRegions,
isInsideCode,
stripReasoningTagsFromText,
} from "openclaw/plugin-sdk/text-core";
const REASONING_MESSAGE_PREFIX = "Reasoning:\n";
const REASONING_TAG_PREFIXES = [

View File

@ -18,7 +18,7 @@ import { isGifMedia, kindFromMime } from "openclaw/plugin-sdk/media-runtime";
import { normalizePollInput, type PollInput } from "openclaw/plugin-sdk/media-runtime";
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
import { redactSensitiveText } from "openclaw/plugin-sdk/text-runtime";
import { redactSensitiveText } from "openclaw/plugin-sdk/text-core";
import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
import { type ResolvedTelegramAccount, resolveTelegramAccount } from "./accounts.js";
import { withTelegramApiErrorLogging } from "./api-logging.js";

View File

@ -1,4 +1,4 @@
import { resolveGlobalMap } from "openclaw/plugin-sdk/text-runtime";
import { resolveGlobalMap } from "openclaw/plugin-sdk/text-core";
/**
* In-memory cache of sent message IDs per chat.

View File

@ -14,7 +14,7 @@ import { writeJsonAtomic } from "openclaw/plugin-sdk/infra-runtime";
import { normalizeAccountId } from "openclaw/plugin-sdk/routing";
import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
import { resolveGlobalSingleton } from "openclaw/plugin-sdk/text-runtime";
import { resolveGlobalSingleton } from "openclaw/plugin-sdk/text-core";
const DEFAULT_THREAD_BINDING_IDLE_TIMEOUT_MS = 24 * 60 * 60 * 1000;
const DEFAULT_THREAD_BINDING_MAX_AGE_MS = 0;

View File

@ -1,5 +1,7 @@
import fsSync from "node:fs";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { vi } from "vitest";
import type { MockBaileysSocket } from "../../../test/mocks/baileys.js";
import { createMockBaileys } from "../../../test/mocks/baileys.js";
@ -32,6 +34,42 @@ export function resetLoadConfigMock() {
(globalThis as Record<symbol, unknown>)[CONFIG_KEY] = () => DEFAULT_CONFIG;
}
function normalizeAgentIdForStorePath(value: string | undefined): string {
const trimmed = (value ?? "").trim();
if (!trimmed) {
return "main";
}
return (
trimmed
.toLowerCase()
.replace(/[^a-z0-9_-]+/g, "-")
.replace(/^-+/, "")
.replace(/-+$/, "")
.slice(0, 64) || "main"
);
}
function resolveStorePathFallback(store?: string, opts?: { agentId?: string }): string {
const agentId = normalizeAgentIdForStorePath(opts?.agentId);
if (!store) {
return path.resolve(
process.env.HOME ?? os.homedir(),
".openclaw",
"agents",
agentId,
"sessions",
"sessions.json",
);
}
if (store.includes("{agentId}")) {
return path.resolve(store.replaceAll("{agentId}", agentId));
}
if (store.startsWith("~")) {
return path.resolve(path.join(process.env.HOME ?? os.homedir(), store.slice(1)));
}
return path.resolve(store);
}
vi.mock("openclaw/plugin-sdk/config-runtime", async (importOriginal) => {
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/config-runtime")>();
const mockModule = Object.create(null) as Record<string, unknown>;
@ -92,7 +130,7 @@ vi.mock("openclaw/plugin-sdk/config-runtime", async (importOriginal) => {
configurable: true,
enumerable: true,
writable: true,
value: actual.resolveStorePath,
value: actual.resolveStorePath ?? resolveStorePathFallback,
},
});
return mockModule;

View File

@ -149,6 +149,10 @@
"types": "./dist/plugin-sdk/thread-bindings-runtime.d.ts",
"default": "./dist/plugin-sdk/thread-bindings-runtime.js"
},
"./plugin-sdk/text-core": {
"types": "./dist/plugin-sdk/text-core.d.ts",
"default": "./dist/plugin-sdk/text-core.js"
},
"./plugin-sdk/text-runtime": {
"types": "./dist/plugin-sdk/text-runtime.d.ts",
"default": "./dist/plugin-sdk/text-runtime.js"

View File

@ -27,6 +27,7 @@
"matrix-runtime-heavy",
"matrix-runtime-shared",
"thread-bindings-runtime",
"text-core",
"text-runtime",
"agent-runtime",
"speech-runtime",

View File

@ -0,0 +1,32 @@
// Narrow text/shared helpers for extensions that should not pull the full
// text-runtime aggregator into mixed runtime/Jiti loader paths.
export { redactSensitiveText } from "../logging/redact.js";
export {
chunkMarkdownIR,
markdownToIR,
type MarkdownIR,
type MarkdownLinkSpan,
} from "../markdown/ir.js";
export { renderMarkdownWithMarkers } from "../markdown/render.js";
export { resolveGlobalMap, resolveGlobalSingleton } from "../shared/global-singleton.js";
export {
normalizeHyphenSlug,
normalizeStringEntries,
normalizeStringEntriesLower,
} from "../shared/string-normalization.js";
export {
FILE_REF_EXTENSIONS_WITH_TLD,
isAutoLinkedFileRef,
} from "../shared/text/auto-linked-file-ref.js";
export { findCodeRegions, isInsideCode } from "../shared/text/code-regions.js";
export { stripReasoningTagsFromText } from "../shared/text/reasoning-tags.js";
export { isRecord } from "../utils.js";
export { chunkItems } from "../utils/chunk-items.js";
export { fetchWithTimeout } from "../utils/fetch-timeout.js";
export {
resolveReactionLevel,
type ReactionLevel,
type ResolvedReactionLevel,
} from "../utils/reaction-level.js";
export { withTimeout } from "../utils/with-timeout.js";

View File

@ -31,14 +31,6 @@
"resolvedPath": "extensions/imessage/runtime-api.js",
"reason": "imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-matrix.ts",
"line": 4,
"kind": "import",
"specifier": "../../../extensions/matrix/runtime-api.js",
"resolvedPath": "extensions/matrix/runtime-api.js",
"reason": "imports extension-owned file from src/plugins"
},
{
"file": "src/plugins/runtime/runtime-slack-ops.runtime.ts",
"line": 10,