refactor: dedupe bundled plugin entrypoints

This commit is contained in:
Peter Steinberger
2026-03-17 00:14:01 -07:00
parent be4fdb9222
commit 6f795fd60e
69 changed files with 814 additions and 850 deletions

View File

@@ -113,7 +113,7 @@ export async function resolveSharedMemoryStatusSnapshot(params: {
purpose: "status";
}) => Promise<{
manager: {
probeVectorAvailability(): Promise<void>;
probeVectorAvailability(): Promise<boolean>;
status(): MemoryProviderStatus;
close?(): Promise<void>;
} | null;

View File

@@ -1,4 +1,5 @@
type JsonSchemaObject = {
type?: string | string[];
properties?: Record<string, JsonSchemaObject>;
additionalProperties?: JsonSchemaObject | boolean;
items?: JsonSchemaObject | JsonSchemaObject[];

View File

@@ -1,7 +1,7 @@
// Narrow plugin-sdk surface for the bundled copilot-proxy plugin.
// Keep this list additive and scoped to symbols used under extensions/copilot-proxy.
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { definePluginEntry } from "./core.js";
export type {
OpenClawPluginApi,
ProviderAuthContext,

View File

@@ -5,6 +5,7 @@ import type {
OpenClawPluginApi,
OpenClawPluginCommandDefinition,
OpenClawPluginConfigSchema,
OpenClawPluginDefinition,
PluginInteractiveTelegramHandlerContext,
} from "../plugins/types.js";
@@ -42,6 +43,7 @@ export type {
ProviderAuthMethod,
ProviderAuthResult,
OpenClawPluginCommandDefinition,
OpenClawPluginDefinition,
PluginInteractiveTelegramHandlerContext,
} from "../plugins/types.js";
export type { OpenClawConfig } from "../config/config.js";
@@ -88,11 +90,53 @@ type DefineChannelPluginEntryOptions<TPlugin extends ChannelPlugin = ChannelPlug
name: string;
description: string;
plugin: TPlugin;
configSchema?: () => OpenClawPluginConfigSchema;
configSchema?: DefinePluginEntryOptions["configSchema"];
setRuntime?: (runtime: PluginRuntime) => void;
registerFull?: (api: OpenClawPluginApi) => void;
};
type DefinePluginEntryOptions = {
id: string;
name: string;
description: string;
kind?: OpenClawPluginDefinition["kind"];
configSchema?: OpenClawPluginConfigSchema | (() => OpenClawPluginConfigSchema);
register: (api: OpenClawPluginApi) => void;
};
type DefinedPluginEntry = {
id: string;
name: string;
description: string;
configSchema: OpenClawPluginConfigSchema;
register: NonNullable<OpenClawPluginDefinition["register"]>;
} & Pick<OpenClawPluginDefinition, "kind">;
function resolvePluginConfigSchema(
configSchema: DefinePluginEntryOptions["configSchema"] = emptyPluginConfigSchema,
): OpenClawPluginConfigSchema {
return typeof configSchema === "function" ? configSchema() : configSchema;
}
// Shared generic plugin-entry boilerplate for bundled and third-party plugins.
export function definePluginEntry({
id,
name,
description,
kind,
configSchema = emptyPluginConfigSchema,
register,
}: DefinePluginEntryOptions): DefinedPluginEntry {
return {
id,
name,
description,
...(kind ? { kind } : {}),
configSchema: resolvePluginConfigSchema(configSchema),
register,
};
}
// Shared channel-plugin entry boilerplate for bundled and third-party channels.
export function defineChannelPluginEntry<TPlugin extends ChannelPlugin>({
id,
@@ -103,11 +147,11 @@ export function defineChannelPluginEntry<TPlugin extends ChannelPlugin>({
setRuntime,
registerFull,
}: DefineChannelPluginEntryOptions<TPlugin>) {
return {
return definePluginEntry({
id,
name,
description,
configSchema: configSchema(),
configSchema,
register(api: OpenClawPluginApi) {
setRuntime?.(api.runtime);
api.registerChannel({ plugin });
@@ -116,7 +160,7 @@ export function defineChannelPluginEntry<TPlugin extends ChannelPlugin>({
}
registerFull?.(api);
},
};
});
}
// Shared setup-entry shape so bundled channels do not duplicate `{ plugin }`.

View File

@@ -1,6 +1,7 @@
// Narrow plugin-sdk surface for the bundled device-pair plugin.
// Keep this list additive and scoped to symbols used under extensions/device-pair.
export { definePluginEntry } from "./core.js";
export { approveDevicePairing, listDevicePairing } from "../infra/device-pairing.js";
export { issueDeviceBootstrapToken } from "../infra/device-bootstrap.js";
export type { OpenClawPluginApi } from "../plugins/types.js";

View File

@@ -1,6 +1,7 @@
// Narrow plugin-sdk surface for the bundled llm-task plugin.
// Keep this list additive and scoped to symbols used under extensions/llm-task.
export { definePluginEntry } from "./core.js";
export { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
export {
formatThinkingLevels,

View File

@@ -1,6 +1,7 @@
// Narrow plugin-sdk surface for the bundled lobster plugin.
// Keep this list additive and scoped to symbols used under extensions/lobster.
export { definePluginEntry } from "./core.js";
export {
applyWindowsSpawnProgramPolicy,
materializeWindowsSpawnProgram,

View File

@@ -1,4 +1,5 @@
// Narrow plugin-sdk surface for the bundled memory-lancedb plugin.
// Keep this list additive and scoped to symbols used under extensions/memory-lancedb.
export { definePluginEntry } from "./core.js";
export type { OpenClawPluginApi } from "../plugins/types.js";

View File

@@ -1,7 +1,7 @@
// Narrow plugin-sdk surface for MiniMax OAuth helpers used by the bundled minimax plugin.
// Keep this list additive and scoped to MiniMax OAuth support code.
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { definePluginEntry } from "./core.js";
export { buildOauthProviderAuthResult } from "./provider-auth-result.js";
export type {
OpenClawPluginApi,

View File

@@ -1,4 +1,5 @@
// Narrow plugin-sdk surface for the bundled open-prose plugin.
// Keep this list additive and scoped to symbols used under extensions/open-prose.
export { definePluginEntry } from "./core.js";
export type { OpenClawPluginApi } from "../plugins/types.js";

View File

@@ -1,6 +1,7 @@
// Narrow plugin-sdk surface for the bundled phone-control plugin.
// Keep this list additive and scoped to symbols used under extensions/phone-control.
export { definePluginEntry } from "./core.js";
export type {
OpenClawPluginApi,
OpenClawPluginCommandDefinition,

View File

@@ -1,7 +1,7 @@
// Narrow plugin-sdk surface for the bundled qwen-portal-auth plugin.
// Keep this list additive and scoped to symbols used under extensions/qwen-portal-auth.
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { definePluginEntry } from "./core.js";
export { buildOauthProviderAuthResult } from "./provider-auth-result.js";
export type {
OpenClawPluginApi,

View File

@@ -49,6 +49,7 @@ describe("plugin-sdk subpath exports", () => {
it("keeps core focused on generic shared exports", () => {
expect(typeof coreSdk.emptyPluginConfigSchema).toBe("function");
expect(typeof coreSdk.definePluginEntry).toBe("function");
expect(typeof coreSdk.defineChannelPluginEntry).toBe("function");
expect(typeof coreSdk.defineSetupPluginEntry).toBe("function");
expect("runPassiveAccountLifecycle" in asExports(coreSdk)).toBe(false);

View File

@@ -1,4 +1,5 @@
// Narrow plugin-sdk surface for the bundled talk-voice plugin.
// Keep this list additive and scoped to symbols used under extensions/talk-voice.
export { definePluginEntry } from "./core.js";
export type { OpenClawPluginApi } from "../plugins/types.js";

View File

@@ -1,5 +1,6 @@
// Narrow plugin-sdk surface for the bundled thread-ownership plugin.
// Keep this list additive and scoped to symbols used under extensions/thread-ownership.
export { definePluginEntry } from "./core.js";
export type { OpenClawConfig } from "../config/config.js";
export type { OpenClawPluginApi } from "../plugins/types.js";

View File

@@ -1,6 +1,7 @@
// Narrow plugin-sdk surface for the bundled voice-call plugin.
// Keep this list additive and scoped to symbols used under extensions/voice-call.
export { definePluginEntry } from "./core.js";
export {
TtsAutoSchema,
TtsConfigSchema,

View File

@@ -45,7 +45,7 @@ type RegisterCliContext = {
function setup(config: Record<string, unknown>): Registered {
const methods = new Map<string, unknown>();
const tools: unknown[] = [];
plugin.register({
void plugin.register({
id: "voice-call",
name: "Voice Call",
description: "test",