mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 10:21:34 +00:00
* feat(swarm): add QuickJS guest orchestration (#110325) * fix(agents): turn-stable swarm replay identity — distinct exec invocations cannot collide * fix(agents): turn-stable swarm replay identity — distinct exec invocations cannot collide * fix(agents): turn-stable swarm replay identity — distinct exec invocations cannot collide
23 lines
727 B
TypeScript
23 lines
727 B
TypeScript
import { AsyncLocalStorage } from "node:async_hooks";
|
|
import type { AssistantMessage } from "@openclaw/llm-core";
|
|
import type { AgentToolCall } from "./types.js";
|
|
|
|
/** Internal assistant-turn context for one concrete tool invocation. */
|
|
export interface AgentToolExecutionContext {
|
|
assistantMessage: AssistantMessage;
|
|
toolCall: AgentToolCall;
|
|
}
|
|
|
|
const activeToolExecution = new AsyncLocalStorage<AgentToolExecutionContext>();
|
|
|
|
export function getAgentToolExecutionContext(): AgentToolExecutionContext | undefined {
|
|
return activeToolExecution.getStore();
|
|
}
|
|
|
|
export function runWithAgentToolExecutionContext<T>(
|
|
context: AgentToolExecutionContext,
|
|
run: () => T,
|
|
): T {
|
|
return activeToolExecution.run(context, run);
|
|
}
|