refactor(runtime): add prepared runtime foundation (#78248)

* docs(runtime): document prepared runtime guidance

* refactor(provider-runtime): thread prepared provider handles

* refactor(runtime-plan): add prepared runtime foundation

* refactor(outbound): add prepared channel runtime facts

* refactor(models): add scoped model reference helpers

* refactor(plugin-sdk): expose prepared runtime helper surfaces
This commit is contained in:
Marcus Castro
2026-05-07 18:49:42 -03:00
committed by GitHub
parent 70eabd3b08
commit 5df08201ff
22 changed files with 824 additions and 66 deletions

View File

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

View File

@@ -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 } : {}),

View File

@@ -37,6 +37,7 @@ export { parseTtsDirectives } from "../tts/directives.js";
export {
canonicalizeSpeechProviderId,
getSpeechProvider,
listLoadedSpeechProviders,
listSpeechProviders,
normalizeSpeechProviderId,
} from "../tts/provider-registry.js";

View File

@@ -33,6 +33,10 @@ function loadFacadeModule(): FacadeModule {
});
}
export function prewarmTtsRuntimeFacade(): void {
loadFacadeModule();
}
export const _test: FacadeModule["_test"] = createLazyFacadeObjectValue(
() => loadFacadeModule()._test,
);