mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 05:13:36 +00:00
refactor: use channel target resolution APIs (#85814)
* refactor: use channel target resolution apis * refactor: satisfy delivery lint * refactor: remove unused target parsing shim * fix: preserve routed cron topic targets
This commit is contained in:
committed by
GitHub
parent
fd2a9adbe6
commit
c4f0da00a9
@@ -8,6 +8,23 @@ import {
|
||||
} from "./registry.js";
|
||||
|
||||
const datePattern = /^\d{4}-\d{2}-\d{2}$/u;
|
||||
const sourceRootsForDeprecatedCallGuard = [
|
||||
"src",
|
||||
"extensions",
|
||||
"packages",
|
||||
"test",
|
||||
"scripts",
|
||||
] as const;
|
||||
const deprecatedTargetParserCallPattern =
|
||||
/\.parseExplicitTarget\?\.\s*\(|parseExplicitTargetFor(?:Channel|LoadedChannel)\s*\(|resolveRouteTargetFor(?:Channel|LoadedChannel)\s*\(/u;
|
||||
const deprecatedTargetParserCompatFiles = new Set([
|
||||
"src/auto-reply/reply/group-id.ts",
|
||||
"src/channels/plugins/target-parsing-loaded.ts",
|
||||
"src/channels/plugins/target-parsing.test.ts",
|
||||
"src/infra/outbound/outbound-session.ts",
|
||||
"src/infra/outbound/outbound-session.test-helpers.ts",
|
||||
"src/plugins/compat/registry.test.ts",
|
||||
]);
|
||||
|
||||
const knownDeprecatedSurfaceMarkers = [
|
||||
{
|
||||
@@ -150,6 +167,36 @@ const knownDeprecatedSurfaceMarkers = [
|
||||
file: "src/channels/plugins/target-parsing-loaded.ts",
|
||||
marker: "ComparableChannelTarget",
|
||||
},
|
||||
{
|
||||
code: "channel-explicit-target-parser",
|
||||
file: "src/channels/plugins/types.core.ts",
|
||||
marker: "parseExplicitTarget?:",
|
||||
},
|
||||
{
|
||||
code: "channel-explicit-target-parser",
|
||||
file: "src/plugin-sdk/channel-route.ts",
|
||||
marker: "resolveChannelRouteTargetWithParser",
|
||||
},
|
||||
{
|
||||
code: "channel-explicit-target-parser",
|
||||
file: "src/channels/plugins/target-parsing-loaded.ts",
|
||||
marker: "ParsedChannelExplicitTarget",
|
||||
},
|
||||
{
|
||||
code: "channel-explicit-target-parser",
|
||||
file: "src/channels/plugins/target-parsing-loaded.ts",
|
||||
marker: "parseExplicitTargetForLoadedChannel",
|
||||
},
|
||||
{
|
||||
code: "channel-explicit-target-parser",
|
||||
file: "src/channels/plugins/target-parsing-loaded.ts",
|
||||
marker: "resolveRouteTargetForLoadedChannel",
|
||||
},
|
||||
{
|
||||
code: "channel-messaging-targets-subpath",
|
||||
file: "src/plugin-sdk/messaging-targets.ts",
|
||||
marker: "openclaw/plugin-sdk/channel-targets",
|
||||
},
|
||||
] as const;
|
||||
|
||||
function parseDate(date: string): Date {
|
||||
@@ -169,6 +216,20 @@ function expectNonEmptyStringList(values: readonly string[], label: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function listSourceFiles(dir: string): string[] {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
return entries.flatMap((entry) => {
|
||||
const path = `${dir}/${entry.name}`;
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.name === "dist" || entry.name === "node_modules") {
|
||||
return [];
|
||||
}
|
||||
return listSourceFiles(path);
|
||||
}
|
||||
return /\.(?:ts|tsx|mts|cts)$/u.test(entry.name) ? [path] : [];
|
||||
});
|
||||
}
|
||||
|
||||
describe("plugin compatibility registry", () => {
|
||||
it("keeps compatibility codes unique and lookup-safe", () => {
|
||||
const records = listPluginCompatRecords();
|
||||
@@ -215,4 +276,13 @@ describe("plugin compatibility registry", () => {
|
||||
expect(fs.readFileSync(surface.file, "utf8"), surface.file).toContain(surface.marker);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps deprecated explicit target parser calls inside compatibility shims", () => {
|
||||
const offenders = sourceRootsForDeprecatedCallGuard
|
||||
.flatMap((root) => listSourceFiles(root))
|
||||
.filter((file) => !deprecatedTargetParserCompatFiles.has(file))
|
||||
.filter((file) => deprecatedTargetParserCallPattern.test(fs.readFileSync(file, "utf8")));
|
||||
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,11 +33,11 @@ export const PLUGIN_COMPAT_RECORDS = [
|
||||
removeAfter: "2026-08-16",
|
||||
replacement: "`gateway_stop` hook",
|
||||
docsPath: "/plugins/hooks#upcoming-deprecations",
|
||||
surfaces: ["api.on(\"deactivate\", ...)", "plugin typed hook registration"],
|
||||
surfaces: ['api.on("deactivate", ...)', "plugin typed hook registration"],
|
||||
diagnostics: ["plugin runtime compatibility warning"],
|
||||
tests: ["src/plugins/loader.test.ts"],
|
||||
releaseNote:
|
||||
"`api.on(\"deactivate\", ...)` remains wired as a deprecated compatibility alias while plugins migrate to `gateway_stop`.",
|
||||
'`api.on("deactivate", ...)` remains wired as a deprecated compatibility alias while plugins migrate to `gateway_stop`.',
|
||||
},
|
||||
{
|
||||
code: "hook-only-plugin-shape",
|
||||
@@ -203,13 +203,13 @@ export const PLUGIN_COMPAT_RECORDS = [
|
||||
warningStarts: "2026-04-28",
|
||||
removeAfter: "2026-07-28",
|
||||
replacement:
|
||||
"`resolveRouteTargetForChannel`, `ChannelRouteParsedTarget`, `channelRouteTargetsMatchExact`, and `channelRouteTargetsShareConversation`",
|
||||
"`ChannelRouteParsedTarget`, `channelRouteTargetsMatchExact`, `channelRouteTargetsShareConversation`, and `messaging.resolveOutboundSessionRoute` for provider-specific target grammar",
|
||||
docsPath: "/plugins/sdk-migration",
|
||||
surfaces: [
|
||||
"src/channels/plugins/target-parsing ComparableChannelTarget",
|
||||
"src/channels/plugins/target-parsing resolveComparableTargetForChannel",
|
||||
"src/channels/plugins/target-parsing comparableChannelTargetsMatch",
|
||||
"src/channels/plugins/target-parsing comparableChannelTargetsShareRoute",
|
||||
"src/channels/plugins/target-parsing-loaded ComparableChannelTarget",
|
||||
"src/channels/plugins/target-parsing-loaded resolveComparableTargetForLoadedChannel",
|
||||
"src/channels/plugins/target-parsing-loaded comparableChannelTargetsMatch",
|
||||
"src/channels/plugins/target-parsing-loaded comparableChannelTargetsShareRoute",
|
||||
],
|
||||
diagnostics: ["plugin SDK compatibility warning"],
|
||||
tests: [
|
||||
@@ -217,6 +217,49 @@ export const PLUGIN_COMPAT_RECORDS = [
|
||||
"src/plugins/contracts/plugin-sdk-subpaths.test.ts",
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "channel-explicit-target-parser",
|
||||
status: "deprecated",
|
||||
owner: "sdk",
|
||||
introduced: "2026-04-28",
|
||||
deprecated: "2026-05-23",
|
||||
warningStarts: "2026-05-23",
|
||||
removeAfter: "2026-08-23",
|
||||
replacement:
|
||||
"`messaging.targetResolver` for target normalization and `messaging.resolveOutboundSessionRoute` for session/thread identity",
|
||||
docsPath: "/plugins/sdk-migration",
|
||||
surfaces: [
|
||||
"ChannelMessagingAdapter.parseExplicitTarget",
|
||||
"openclaw/plugin-sdk/channel-route ChannelRouteExplicitTarget",
|
||||
"openclaw/plugin-sdk/channel-route ChannelRouteExplicitTargetParser",
|
||||
"openclaw/plugin-sdk/channel-route resolveChannelRouteTargetWithParser",
|
||||
"src/channels/plugins/target-parsing-loaded ParsedChannelExplicitTarget",
|
||||
"src/channels/plugins/target-parsing-loaded parseExplicitTargetForLoadedChannel",
|
||||
"src/channels/plugins/target-parsing-loaded resolveRouteTargetForLoadedChannel",
|
||||
],
|
||||
diagnostics: ["plugin SDK compatibility warning"],
|
||||
tests: [
|
||||
"src/channels/plugins/contracts/test-helpers/surface-contract-suite.ts",
|
||||
"src/plugins/compat/registry.test.ts",
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "channel-messaging-targets-subpath",
|
||||
status: "deprecated",
|
||||
owner: "sdk",
|
||||
introduced: "2026-04-28",
|
||||
deprecated: "2026-05-23",
|
||||
warningStarts: "2026-05-23",
|
||||
removeAfter: "2026-08-23",
|
||||
replacement: "`openclaw/plugin-sdk/channel-targets`",
|
||||
docsPath: "/plugins/sdk-migration",
|
||||
surfaces: ["openclaw/plugin-sdk/messaging-targets"],
|
||||
diagnostics: ["plugin SDK compatibility warning"],
|
||||
tests: [
|
||||
"src/plugins/compat/registry.test.ts",
|
||||
"src/plugins/contracts/plugin-sdk-subpaths.test.ts",
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "bundled-plugin-allowlist",
|
||||
status: "active",
|
||||
|
||||
@@ -860,7 +860,6 @@ describe("plugin-sdk subpath exports", () => {
|
||||
pattern:
|
||||
/\b(?:ComparableChannelTarget|resolveComparableTargetFor(?:Channel|LoadedChannel)|comparableChannelTargets(?:Match|ShareRoute))\b/u,
|
||||
exclude: [
|
||||
"src/channels/plugins/target-parsing.ts",
|
||||
"src/channels/plugins/target-parsing-loaded.ts",
|
||||
"src/channels/plugins/target-parsing.test.ts",
|
||||
"src/plugins/compat/registry.ts",
|
||||
|
||||
Reference in New Issue
Block a user