refactor(plugin-sdk): clean shared core imports

This commit is contained in:
Peter Steinberger 2026-03-16 00:25:22 -07:00
parent 7964563299
commit b3025e6d8e
No known key found for this signature in database
6 changed files with 14 additions and 3 deletions

View File

@ -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.

View File

@ -1,4 +1,4 @@
import { runPassiveAccountLifecycle } from "openclaw/plugin-sdk";
import { runPassiveAccountLifecycle } from "openclaw/plugin-sdk/core";
type StoppableMonitor = {
stop: () => void;

View File

@ -1,4 +1,4 @@
import { createLoggerBackedRuntime } from "openclaw/plugin-sdk";
import { createLoggerBackedRuntime } from "openclaw/plugin-sdk/core";
export function resolveLoggerBackedRuntime<TRuntime>(
runtime: TRuntime | undefined,

View File

@ -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) {

View File

@ -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";

View File

@ -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", () => {