UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.16 kB
import{o as resolveGlobalSingleton}from"./global-singleton-DolL9xGt.mjs"; //!src/agents/context-pressure.ts function decideContextPressure(e){if(exceedsContextWindow(e.estimatedPromptTokens,e.windowTokens))return`overflow`;if(!e.maintenanceDue||!e.boundarySafe)return;return e.runId&&isBoundaryMaintenanceDeclined(e.runId)?void 0:`maintenance`}function exceedsContextWindow(e,t){return typeof e===`number`&&typeof t===`number`&&Number.isFinite(e)&&Number.isFinite(t)&&t>0&&e>t}function isToolBatchBoundarySafe(e){return e.pendingToolCalls===0&&e.itemLifecycle.activeCount===0&&e.itemLifecycle.completedCount===e.itemLifecycle.startedCount&&!e.asyncActivity&&!e.parkedCodeModeRun&&!e.approvalPromptSent}const declinedRuns=resolveGlobalSingleton(Symbol.for(`openclaw.boundaryMaintenanceDeclined`),()=>/* @__PURE__ */ new Set);function declineBoundaryMaintenance(e){declinedRuns.add(e)}function isBoundaryMaintenanceDeclined(e){return declinedRuns.has(e)}function clearBoundaryMaintenance(e){declinedRuns.delete(e)}export{isToolBatchBoundarySafe as a,exceedsContextWindow as i,decideContextPressure as n,declineBoundaryMaintenance as r,clearBoundaryMaintenance as t};