mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-07 07:58:36 +00:00
refactor(plugin-sdk): expose prepared runtime helper surfaces
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
83c7b0a2953a24cac8d576bb561948ccd70d4bac3c06d0a39814a766b7a330b6 plugin-sdk-api-baseline.json
|
||||
387c0a4b34b0edd3c576658d71f13cdeb64d74bc949c36698798563de08f570d plugin-sdk-api-baseline.jsonl
|
||||
51b5c2078621b696301cbeb45035ace7498f9ab8433517f172cf83a60bbe7692 plugin-sdk-api-baseline.json
|
||||
212725570b9e5577c7d36c652a9203450bbfecb4a43cfcd58b743e7014e1dba3 plugin-sdk-api-baseline.jsonl
|
||||
|
||||
@@ -101,6 +101,15 @@ export const pluginSdkDocMetadata = {
|
||||
"runtime-store": {
|
||||
category: "runtime",
|
||||
},
|
||||
"agent-runtime": {
|
||||
category: "runtime",
|
||||
},
|
||||
"speech-core": {
|
||||
category: "provider",
|
||||
},
|
||||
"tts-runtime": {
|
||||
category: "runtime",
|
||||
},
|
||||
"allow-from": {
|
||||
category: "utilities",
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@ export * from "../agents/identity.js";
|
||||
export * from "../agents/model-auth-markers.js";
|
||||
export * from "../agents/model-auth.js";
|
||||
export * from "../agents/model-catalog.js";
|
||||
export * from "../agents/model-catalog-scope.js";
|
||||
export * from "../agents/model-selection.js";
|
||||
export * from "../agents/simple-completion-runtime.js";
|
||||
export * from "../agents/pi-embedded-block-chunker.js";
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { emptyChannelConfigSchema } from "../channels/plugins/config-schema.js";
|
||||
import type { ChannelOutboundAdapter } from "../channels/plugins/types.adapters.js";
|
||||
import type { ChannelConfigSchema } from "../channels/plugins/types.config.js";
|
||||
import type { ChannelLegacyStateMigrationPlan } from "../channels/plugins/types.core.js";
|
||||
import type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
@@ -52,6 +53,7 @@ type DefineBundledChannelEntryOptions<TPlugin = ChannelPlugin> = {
|
||||
description: string;
|
||||
importMetaUrl: string;
|
||||
plugin: BundledEntryModuleRef;
|
||||
outbound?: BundledEntryModuleRef;
|
||||
secrets?: BundledEntryModuleRef;
|
||||
configSchema?: ChannelEntryConfigSchema<TPlugin> | (() => ChannelEntryConfigSchema<TPlugin>);
|
||||
runtime?: BundledEntryModuleRef;
|
||||
@@ -108,6 +110,9 @@ export type BundledChannelEntryContract<TPlugin = ChannelPlugin> = {
|
||||
features?: BundledChannelEntryFeatures;
|
||||
register: (api: OpenClawPluginApi) => void;
|
||||
loadChannelPlugin: (options?: BundledEntryModuleLoadOptions) => TPlugin;
|
||||
loadChannelOutbound?: (
|
||||
options?: BundledEntryModuleLoadOptions,
|
||||
) => ChannelOutboundAdapter | undefined;
|
||||
loadChannelSecrets?: (
|
||||
options?: BundledEntryModuleLoadOptions,
|
||||
) => ChannelPlugin["secrets"] | undefined;
|
||||
@@ -435,6 +440,7 @@ export function defineBundledChannelEntry<TPlugin = ChannelPlugin>({
|
||||
description,
|
||||
importMetaUrl,
|
||||
plugin,
|
||||
outbound,
|
||||
secrets,
|
||||
configSchema,
|
||||
runtime,
|
||||
@@ -449,6 +455,14 @@ export function defineBundledChannelEntry<TPlugin = ChannelPlugin>({
|
||||
: ((configSchema ?? emptyChannelConfigSchema()) as ChannelEntryConfigSchema<TPlugin>);
|
||||
const loadChannelPlugin = (options?: BundledEntryModuleLoadOptions) =>
|
||||
loadBundledEntryExportSync<TPlugin>(importMetaUrl, plugin, options);
|
||||
const loadChannelOutbound = outbound
|
||||
? (options?: BundledEntryModuleLoadOptions) =>
|
||||
loadBundledEntryExportSync<ChannelOutboundAdapter | undefined>(
|
||||
importMetaUrl,
|
||||
outbound,
|
||||
options,
|
||||
)
|
||||
: undefined;
|
||||
const loadChannelSecrets = secrets
|
||||
? (options?: BundledEntryModuleLoadOptions) =>
|
||||
loadBundledEntryExportSync<ChannelPlugin["secrets"] | undefined>(
|
||||
@@ -511,6 +525,7 @@ export function defineBundledChannelEntry<TPlugin = ChannelPlugin>({
|
||||
profile("bundled-register:registerFull", () => registerFull?.(api));
|
||||
},
|
||||
loadChannelPlugin,
|
||||
...(loadChannelOutbound ? { loadChannelOutbound } : {}),
|
||||
...(loadChannelSecrets ? { loadChannelSecrets } : {}),
|
||||
...(loadChannelAccountInspector ? { loadChannelAccountInspector } : {}),
|
||||
...(setChannelRuntime ? { setChannelRuntime } : {}),
|
||||
|
||||
@@ -35,6 +35,7 @@ export { parseTtsDirectives } from "../tts/directives.js";
|
||||
export {
|
||||
canonicalizeSpeechProviderId,
|
||||
getSpeechProvider,
|
||||
listLoadedSpeechProviders,
|
||||
listSpeechProviders,
|
||||
normalizeSpeechProviderId,
|
||||
} from "../tts/provider-registry.js";
|
||||
|
||||
@@ -31,6 +31,10 @@ function loadFacadeModule(): FacadeModule {
|
||||
});
|
||||
}
|
||||
|
||||
export function prewarmTtsRuntimeFacade(): void {
|
||||
loadFacadeModule();
|
||||
}
|
||||
|
||||
export const _test: FacadeModule["_test"] = createLazyFacadeObjectValue(
|
||||
() => loadFacadeModule()._test,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { OpenClawConfig } from "../config/types.js";
|
||||
import { getActiveRuntimePluginRegistry } from "../plugins/active-runtime-registry.js";
|
||||
import {
|
||||
resolvePluginCapabilityProvider,
|
||||
resolvePluginCapabilityProviders,
|
||||
@@ -17,6 +18,10 @@ function resolveSpeechProviderPluginEntries(cfg?: OpenClawConfig): SpeechProvide
|
||||
});
|
||||
}
|
||||
|
||||
function resolveLoadedSpeechProviderPluginEntries(): SpeechProviderPlugin[] {
|
||||
return (getActiveRuntimePluginRegistry()?.speechProviders ?? []).map((entry) => entry.provider);
|
||||
}
|
||||
|
||||
const defaultSpeechProviderRegistryResolver: SpeechProviderRegistryResolver = {
|
||||
getProvider: (providerId, cfg) =>
|
||||
resolvePluginCapabilityProvider({
|
||||
@@ -31,7 +36,19 @@ const defaultSpeechProviderRegistry = createSpeechProviderRegistry(
|
||||
defaultSpeechProviderRegistryResolver,
|
||||
);
|
||||
|
||||
const loadedSpeechProviderRegistry = createSpeechProviderRegistry({
|
||||
getProvider: (providerId) =>
|
||||
resolveLoadedSpeechProviderPluginEntries().find((provider) => {
|
||||
if (provider.id === providerId) {
|
||||
return true;
|
||||
}
|
||||
return provider.aliases?.includes(providerId) ?? false;
|
||||
}),
|
||||
listProviders: () => resolveLoadedSpeechProviderPluginEntries(),
|
||||
});
|
||||
|
||||
export const listSpeechProviders = defaultSpeechProviderRegistry.listSpeechProviders;
|
||||
export const listLoadedSpeechProviders = loadedSpeechProviderRegistry.listSpeechProviders;
|
||||
export const getSpeechProvider = defaultSpeechProviderRegistry.getSpeechProvider;
|
||||
export const canonicalizeSpeechProviderId =
|
||||
defaultSpeechProviderRegistry.canonicalizeSpeechProviderId;
|
||||
|
||||
Reference in New Issue
Block a user