refactor(plugin-sdk): clean shared core imports
This commit is contained in:
parent
7964563299
commit
b3025e6d8e
@ -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.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { runPassiveAccountLifecycle } from "openclaw/plugin-sdk";
|
||||
import { runPassiveAccountLifecycle } from "openclaw/plugin-sdk/core";
|
||||
|
||||
type StoppableMonitor = {
|
||||
stop: () => void;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { createLoggerBackedRuntime } from "openclaw/plugin-sdk";
|
||||
import { createLoggerBackedRuntime } from "openclaw/plugin-sdk/core";
|
||||
|
||||
export function resolveLoggerBackedRuntime<TRuntime>(
|
||||
runtime: TRuntime | undefined,
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user