mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 22:10:51 +00:00
fix(plugins): forward plugin subagent overrides (#48277)
Merged via squash.
Prepared head SHA: ffa45893e0
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
@@ -20,4 +20,17 @@ describe("gateway request scope", () => {
|
||||
expect(second.getPluginRuntimeGatewayRequestScope()).toEqual(TEST_SCOPE);
|
||||
});
|
||||
});
|
||||
|
||||
it("attaches plugin id to the active scope", async () => {
|
||||
const runtimeScope = await import("./gateway-request-scope.js");
|
||||
|
||||
await runtimeScope.withPluginRuntimeGatewayRequestScope(TEST_SCOPE, async () => {
|
||||
await runtimeScope.withPluginRuntimePluginIdScope("voice-call", async () => {
|
||||
expect(runtimeScope.getPluginRuntimeGatewayRequestScope()).toEqual({
|
||||
...TEST_SCOPE,
|
||||
pluginId: "voice-call",
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ export type PluginRuntimeGatewayRequestScope = {
|
||||
context?: GatewayRequestContext;
|
||||
client?: GatewayRequestOptions["client"];
|
||||
isWebchatConnect: GatewayRequestOptions["isWebchatConnect"];
|
||||
pluginId?: string;
|
||||
};
|
||||
|
||||
const PLUGIN_RUNTIME_GATEWAY_REQUEST_SCOPE_KEY: unique symbol = Symbol.for(
|
||||
@@ -37,6 +38,20 @@ export function withPluginRuntimeGatewayRequestScope<T>(
|
||||
return pluginRuntimeGatewayRequestScope.run(scope, run);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs work under the current gateway request scope while attaching plugin identity.
|
||||
*/
|
||||
export function withPluginRuntimePluginIdScope<T>(pluginId: string, run: () => T): T {
|
||||
const current = pluginRuntimeGatewayRequestScope.getStore();
|
||||
const scoped: PluginRuntimeGatewayRequestScope = current
|
||||
? { ...current, pluginId }
|
||||
: {
|
||||
pluginId,
|
||||
isWebchatConnect: () => false,
|
||||
};
|
||||
return pluginRuntimeGatewayRequestScope.run(scoped, run);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current plugin gateway request scope when called from a plugin request handler.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,8 @@ export type { RuntimeLogger };
|
||||
export type SubagentRunParams = {
|
||||
sessionKey: string;
|
||||
message: string;
|
||||
provider?: string;
|
||||
model?: string;
|
||||
extraSystemPrompt?: string;
|
||||
lane?: string;
|
||||
deliver?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user