openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
25 lines (24 loc) • 1.34 kB
JavaScript
import { a as getPluginRuntimeGatewayRequestScope } from "./gateway-request-scope-Btza1qbw.mjs";
import { r as dispatchGatewayMethodInProcessRaw } from "./server-plugin-in-process-dispatch-6C_GjuWo.mjs";
import "./server-plugins-DBTgmUoj.mjs";
//#region src/plugin-sdk/gateway-method-runtime.ts
/**
* Dispatch a Gateway control-plane method from an authenticated plugin request scope.
*/
async function dispatchGatewayMethod(method, params, options) {
const scope = getPluginRuntimeGatewayRequestScope();
if (scope?.gatewayMethodDispatchAllowed !== true) {
const pluginLabel = scope?.pluginId ? ` for plugin "${scope.pluginId}"` : "";
throw new Error(`Gateway method dispatch is reserved for authenticated plugin HTTP routes or RPC handlers that declare contracts.gatewayMethodDispatch: ["authenticated-request"]${pluginLabel}.`);
}
return await dispatchGatewayMethodInProcessRaw(method, params, {
disableSyntheticClient: true,
requireScopedClient: true,
...scope.signal ? { signal: scope.signal } : {},
...scope.hasCurrentClientAuthority ? { hasCurrentClientAuthority: scope.hasCurrentClientAuthority } : {},
...options?.expectFinal !== void 0 ? { expectFinal: options.expectFinal } : {},
...options?.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {}
});
}
//#endregion
export { dispatchGatewayMethod as t };