88 listRuntimeMusicGenerationProviders ,
99} from "../../music-generation/runtime.js" ;
1010import { RequestScopedSubagentRuntimeError } from "../../plugin-sdk/error-runtime.js" ;
11- import { resolveGlobalSingleton } from "../../shared/global-singleton.js" ;
1211import {
1312 createLazyRuntimeMethod ,
1413 createLazyRuntimeMethodBinder ,
@@ -20,6 +19,12 @@ import {
2019 listRuntimeVideoGenerationProviders ,
2120} from "../../video-generation/runtime.js" ;
2221import { listWebSearchProviders , runWebSearch } from "../../web-search/runtime.js" ;
22+ import {
23+ gatewaySubagentState ,
24+ setGatewayNodesRuntime ,
25+ setGatewaySubagentRuntime ,
26+ clearGatewaySubagentRuntime ,
27+ } from "./gateway-bindings.js" ;
2328import { createRuntimeAgent } from "./runtime-agent.js" ;
2429import { defineCachedValue } from "./runtime-cache.js" ;
2530import { createRuntimeChannel } from "./runtime-channel.js" ;
@@ -33,6 +38,11 @@ import { createRuntimeTasks } from "./runtime-tasks.js";
3338import type { CreatePluginRuntimeOptions , PluginRuntime } from "./types.js" ;
3439
3540export type { CreatePluginRuntimeOptions } from "./types.js" ;
41+ export {
42+ clearGatewaySubagentRuntime ,
43+ setGatewayNodesRuntime ,
44+ setGatewaySubagentRuntime ,
45+ } from "./gateway-bindings.js" ;
3646
3747const loadTtsRuntime = createLazyRuntimeModule ( ( ) => import ( "../../tts/tts.js" ) ) ;
3848const loadMediaUnderstandingRuntime = createLazyRuntimeModule (
@@ -140,46 +150,6 @@ function createUnavailableSubagentRuntime(): PluginRuntime["subagent"] {
140150// active gateway subagent dynamically without changing the default behavior for
141151// ordinary plugin runtimes.
142152
143- const GATEWAY_SUBAGENT_SYMBOL : unique symbol = Symbol . for (
144- "openclaw.plugin.gatewaySubagentRuntime" ,
145- ) as unknown as typeof GATEWAY_SUBAGENT_SYMBOL ;
146-
147- type GatewaySubagentState = {
148- subagent : PluginRuntime [ "subagent" ] | undefined ;
149- nodes : PluginRuntime [ "nodes" ] | undefined ;
150- } ;
151-
152- const gatewaySubagentState = resolveGlobalSingleton < GatewaySubagentState > (
153- GATEWAY_SUBAGENT_SYMBOL ,
154- ( ) => ( {
155- subagent : undefined ,
156- nodes : undefined ,
157- } ) ,
158- ) ;
159-
160- /**
161- * Set the process-global gateway subagent runtime.
162- * Called during gateway startup so that gateway-bindable plugin runtimes can
163- * resolve subagent methods dynamically even when their registry was cached
164- * before the gateway finished loading plugins.
165- */
166- export function setGatewaySubagentRuntime ( subagent : PluginRuntime [ "subagent" ] ) : void {
167- gatewaySubagentState . subagent = subagent ;
168- }
169-
170- export function setGatewayNodesRuntime ( nodes : PluginRuntime [ "nodes" ] ) : void {
171- gatewaySubagentState . nodes = nodes ;
172- }
173-
174- /**
175- * Reset the process-global gateway subagent runtime.
176- * Used by tests to avoid leaking gateway state across module reloads.
177- */
178- export function clearGatewaySubagentRuntime ( ) : void {
179- gatewaySubagentState . subagent = undefined ;
180- gatewaySubagentState . nodes = undefined ;
181- }
182-
183153/**
184154 * Create a late-binding subagent that resolves to:
185155 * 1. An explicitly provided subagent (from runtimeOptions), OR
0 commit comments