openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.65 kB
JavaScript
import{t as pruneMapToMaxSize}from"./map-size-DLQqorvK.mjs";
//!src/agents/agent-tools.before-tool-call.state.ts
const adjustedParamsByToolCallId=/* @__PURE__ */ new Map;const preExecutionBlockedToolCallIds=/* @__PURE__ */ new Set;const structuredReplaySafeToolCallIds=/* @__PURE__ */ new Set;const trackedToolCallIds=/* @__PURE__ */ new Map;function buildAdjustedParamsKey(e){if(e.runId&&e.runId.trim())return`${e.runId}:${e.toolCallId}`;return e.toolCallId}function recordAdjustedParamsForToolCall(e,t,n){if(!e)return;let r;try{r=structuredClone(t)}catch{return}adjustedParamsByToolCallId.set(buildAdjustedParamsKey({runId:n,toolCallId:e}),r);pruneMapToMaxSize(adjustedParamsByToolCallId,1024)}function consumeAdjustedParamsForToolCall(e,t){const n=buildAdjustedParamsKey({runId:t,toolCallId:e});const r=adjustedParamsByToolCallId.get(n);adjustedParamsByToolCallId.delete(n);return r}function peekAdjustedParamsForToolCall(e,t){return adjustedParamsByToolCallId.get(buildAdjustedParamsKey({runId:t,toolCallId:e}))}function consumePreExecutionBlockedToolCall(e,t){return preExecutionBlockedToolCallIds.delete(buildAdjustedParamsKey({runId:t,toolCallId:e}))}function peekPreExecutionBlockedToolCall(e,t){return preExecutionBlockedToolCallIds.has(buildAdjustedParamsKey({runId:t,toolCallId:e}))}function recordToolExecutionTracked(e,t){const n=buildAdjustedParamsKey({runId:t,toolCallId:e});if(!trackedToolCallIds.has(n))trackedToolCallIds.set(n,false)}function recordToolExecutionStarted(e,t){trackedToolCallIds.set(buildAdjustedParamsKey({runId:t,toolCallId:e}),true)}function clearTrackedToolExecution(e,t){trackedToolCallIds.delete(buildAdjustedParamsKey({runId:t,toolCallId:e}))}function consumeTrackedToolExecutionStarted(e,t){const n=buildAdjustedParamsKey({runId:t,toolCallId:e});const r=trackedToolCallIds.get(n);trackedToolCallIds.delete(n);return r}function recordStructuredReplaySafeToolCall(e,t){structuredReplaySafeToolCallIds.add(buildAdjustedParamsKey({runId:t,toolCallId:e}))}function consumeStructuredReplaySafeToolCall(e,t){return structuredReplaySafeToolCallIds.delete(buildAdjustedParamsKey({runId:t,toolCallId:e}))}export{consumeStructuredReplaySafeToolCall as a,peekPreExecutionBlockedToolCall as c,recordStructuredReplaySafeToolCall as d,recordToolExecutionStarted as f,consumePreExecutionBlockedToolCall as i,preExecutionBlockedToolCallIds as l,structuredReplaySafeToolCallIds as m,clearTrackedToolExecution as n,consumeTrackedToolExecutionStarted as o,recordToolExecutionTracked as p,consumeAdjustedParamsForToolCall as r,peekAdjustedParamsForToolCall as s,buildAdjustedParamsKey as t,recordAdjustedParamsForToolCall as u};