diff --git a/docs/tools/plugin.md b/docs/tools/plugin.md index a53a05bf6c0..246724719ff 100644 --- a/docs/tools/plugin.md +++ b/docs/tools/plugin.md @@ -571,7 +571,7 @@ Notes: Use SDK subpaths instead of the monolithic `openclaw/plugin-sdk` import when authoring plugins: -- `openclaw/plugin-sdk/core` for generic plugin APIs, provider auth types, and shared helpers. +- `openclaw/plugin-sdk/core` for generic plugin APIs, provider auth types, and shared helpers such as routing/session utilities and logger-backed runtimes. - `openclaw/plugin-sdk/compat` for bundled/internal plugin code that needs broader shared runtime helpers than `core`. - `openclaw/plugin-sdk/telegram` for Telegram channel plugins. - `openclaw/plugin-sdk/discord` for Discord channel plugins. diff --git a/extensions/shared/passive-monitor.ts b/extensions/shared/passive-monitor.ts index e5ffb3f03ff..0be48afd014 100644 --- a/extensions/shared/passive-monitor.ts +++ b/extensions/shared/passive-monitor.ts @@ -1,4 +1,4 @@ -import { runPassiveAccountLifecycle } from "openclaw/plugin-sdk"; +import { runPassiveAccountLifecycle } from "openclaw/plugin-sdk/core"; type StoppableMonitor = { stop: () => void; diff --git a/extensions/shared/runtime.ts b/extensions/shared/runtime.ts index a1950ba6be0..2a75360aa20 100644 --- a/extensions/shared/runtime.ts +++ b/extensions/shared/runtime.ts @@ -1,4 +1,4 @@ -import { createLoggerBackedRuntime } from "openclaw/plugin-sdk"; +import { createLoggerBackedRuntime } from "openclaw/plugin-sdk/core"; export function resolveLoggerBackedRuntime( runtime: TRuntime | undefined, diff --git a/scripts/check-no-monolithic-plugin-sdk-entry-imports.ts b/scripts/check-no-monolithic-plugin-sdk-entry-imports.ts index 9b77ae9cf61..01a2eb38c75 100644 --- a/scripts/check-no-monolithic-plugin-sdk-entry-imports.ts +++ b/scripts/check-no-monolithic-plugin-sdk-entry-imports.ts @@ -59,6 +59,10 @@ function collectPluginSourceFiles(rootDir: string): string[] { return files; } +function collectSharedExtensionSourceFiles(): string[] { + return collectPluginSourceFiles(path.join(process.cwd(), "extensions", "shared")); +} + function main() { const discovery = discoverOpenClawPlugins({}); const bundledCandidates = discovery.candidates.filter((c) => c.origin === "bundled"); @@ -69,6 +73,9 @@ function main() { filesToCheck.add(srcFile); } } + for (const sharedFile of collectSharedExtensionSourceFiles()) { + filesToCheck.add(sharedFile); + } const offenders: string[] = []; for (const entryFile of filesToCheck) { diff --git a/src/plugin-sdk/core.ts b/src/plugin-sdk/core.ts index 458a4ecfce7..01807d79132 100644 --- a/src/plugin-sdk/core.ts +++ b/src/plugin-sdk/core.ts @@ -144,3 +144,5 @@ export { type RoutePeerKind, } from "../routing/resolve-route.js"; export { resolveThreadSessionKeys } from "../routing/session-key.js"; +export { runPassiveAccountLifecycle } from "./channel-lifecycle.js"; +export { createLoggerBackedRuntime } from "./runtime.js"; diff --git a/src/plugin-sdk/subpaths.test.ts b/src/plugin-sdk/subpaths.test.ts index be9e2680ec5..5c26ebf44ca 100644 --- a/src/plugin-sdk/subpaths.test.ts +++ b/src/plugin-sdk/subpaths.test.ts @@ -29,6 +29,8 @@ describe("plugin-sdk subpath exports", () => { it("exports core routing helpers", () => { expect(typeof coreSdk.buildAgentSessionKey).toBe("function"); expect(typeof coreSdk.resolveThreadSessionKeys).toBe("function"); + expect(typeof coreSdk.runPassiveAccountLifecycle).toBe("function"); + expect(typeof coreSdk.createLoggerBackedRuntime).toBe("function"); }); it("exports Discord helpers", () => {