UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

7 lines • 3.4 kB
import{o as normalizeLowercaseStringOrEmpty}from"./string-coerce-CpTFcSwY.mjs";import{D as hasKind,r as createPluginActivationSource,u as normalizePluginsConfig}from"./config-state-C1eV6UWf.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{_ as resolveSubagentMaxConcurrent,g as resolveAgentMaxConcurrent}from"./validation-core-Dgg8JyG6.mjs";import{l as resolveAuthorizedDreamingSidecar}from"./loader-shared-BU-FgZ1q.mjs";import{s as DEFAULT_MEMORY_DREAMING_PLUGIN_ID}from"./dreaming-DWa9EF3D.mjs";import{n as enableSessionSuspensionWritesForGatewayStart}from"./session-suspension-BVmAQtTx.mjs";import{c as publishLaneConfiguration,r as getCommandLaneSnapshot,u as setCommandLaneConcurrency}from"./command-queue-fBrp5ERY.mjs";import{t as resolveCronMaxConcurrentRuns}from"./cron-limits-ViH90sRt.mjs"; //!src/gateway/server-cron-memory-dreaming-jobs.ts async function reconcileOrphanedMemoryDreamingJobs(e){const t=normalizePluginsConfig(e.cfg.plugins);const n=normalizeLowercaseStringOrEmpty(t.slots.memory);if(!n||n===`none`||n===`memory-core`)return;const{manifestRegistry:r}=e;if(!r)return;const i=r.plugins.find(e=>e.id===n);if(i&&!hasKind(i.kind,`memory`)||resolveAuthorizedDreamingSidecar({cfg:e.cfg,normalized:t,activationSource:createPluginActivationSource({config:e.cfg,plugins:t}),manifestRegistry:r,memorySlot:n})!==null||!e.isCurrent())return;let a;try{a=await e.cron.list({includeDisabled:true})}catch(t){if(e.isCurrent())e.logger.warn(`Dreaming job inventory failed: ${formatErrorMessage(t)}`);return}const commitGuard=()=>{if(!e.isCurrent())throw new DOMException(`Dreaming cleanup superseded`,`AbortError`)};for(const t of a){if(t.declarationKey!==`memory-core:memory-dreaming-promotion`)continue;if(!e.isCurrent())return;try{await e.cron.remove(t.id,{commitGuard})}catch(n){if(!e.isCurrent())return;e.logger.warn(`Dreaming job ${t.id} cleanup failed: ${formatErrorMessage(n)}`)}}} //!src/gateway/server-lanes.ts const HOOK_DISPATCH_LANE_RESERVATION=1;const CRON_HOOK_LANE_GROUP=`cron-hooks`;function resolveGatewayLaneConcurrency(e){const t=resolveCronMaxConcurrentRuns();return{cron:t,hookDispatch:e.hooks?.enabled===true?t:0,main:resolveAgentMaxConcurrent(e),subagent:resolveSubagentMaxConcurrent(e)}}function applyGatewayLaneConcurrency(e,t={}){if(t.gatewayStart)enableSessionSuspensionWritesForGatewayStart();setCommandLaneConcurrency(`cron`,e.cron);const n=e.hookDispatch>0;const r=getCommandLaneSnapshot(`hook-dispatch`);const i=!n&&r.activeCount>0;publishLaneConfiguration({lanes:{["cron-nested"]:e.cron,["hook-dispatch"]:e.hookDispatch},groups:n||i?{[CRON_HOOK_LANE_GROUP]:{budget:e.cron,members:[`cron-nested`,`hook-dispatch`],reservations:n?{["hook-dispatch"]:HOOK_DISPATCH_LANE_RESERVATION}:void 0}}:void 0,clearGroups:n||i?void 0:[CRON_HOOK_LANE_GROUP]});setCommandLaneConcurrency(`main`,e.main);setCommandLaneConcurrency(`restart-recovery`,e.main);if(t.gatewayStart)setCommandLaneConcurrency(`nested`,1);setCommandLaneConcurrency(`subagent`,e.subagent);setCommandLaneConcurrency(`active-memory`,e.subagent)} //!src/gateway/server/hook-client-ip-config.ts function resolveHookClientIpConfig(e){return{trustedProxies:e.gateway?.trustedProxies,allowRealIpFallback:e.gateway?.allowRealIpFallback===true}}export{reconcileOrphanedMemoryDreamingJobs as i,applyGatewayLaneConcurrency as n,resolveGatewayLaneConcurrency as r,resolveHookClientIpConfig as t};