openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.22 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{i as resolveExplicitSessionStorePathForScope,l as resolveSessionStorePathCore}from"./paths-CcxgiC3g.mjs";import{x as resolveSessionAgentId}from"./agent-scope-config-CG9CFpGX.mjs";import"./agent-scope-Dw5XRSEh.mjs";import{Z as captureSessionTarget,p as getSessionControllerOperation}from"./session-controller.state-BIDbpLPn.mjs";import{l as resolveCommandTurnContext,o as isNativeCommandTurn,r as isAuthorizedTextSlashCommandTurn}from"./command-turn-context-vtXH8Cqw.mjs";import{c as captureReplyMessageInjectionTarget}from"./session-controller.steer-BUP3NUvG.mjs";import"./session-controller-CrWZc5Fi.mjs";import{t as resolveCommandSourceSessionKey}from"./command-source-session-key-D8_KKStL.mjs";
//!src/auto-reply/reply/explicit-steer-routing.ts
function parseSteerMessage(e){const t=e.trim().match(/^\/(?:steer|tell)(?:\s+([\s\S]*))?$/i);return t?(t[1]??``).trim():null}function listSteerCandidateSessionKeys(e){return e.includes(`:slash:`)?[e,e.replace(`:slash:`,`:direct:`),e.replace(`:slash:`,`:dm:`)]:[e]}function readExplicitSteerMessage(e,t){const n=resolveCommandTurnContext(e);if(!isNativeCommandTurn(n)&&!isAuthorizedTextSlashCommandTurn(n))return null;return parseSteerMessage(t??n.body??normalizeOptionalString(e.CommandBody)??normalizeOptionalString(e.BodyForCommands)??normalizeOptionalString(e.Body)??``)}function isExplicitSteerCommandTurn(e){return readExplicitSteerMessage(e)!==null}function resolveActiveExplicitSteerSessionKey(e){if(!readExplicitSteerMessage(e.ctx,e.commandBody))return;const t=resolveCommandSourceSessionKey({...e,sessionKey:e.sessionKey??e.ctx.SessionKey});if(!t)return;const n=resolveSessionAgentId({sessionKey:t,config:e.cfg,fallbackAgentId:e.ctx.AgentId});const r=resolveExplicitSessionStorePathForScope({agentId:n,sessionKey:t})??resolveSessionStorePathCore(e.cfg.session?.store,{agentId:n});for(const e of listSteerCandidateSessionKeys(t)){const t=getSessionControllerOperation(e,captureSessionTarget({storeScope:r,sessionKey:e,agentId:n}));if(captureReplyMessageInjectionTarget(t))return e}}export{parseSteerMessage as n,resolveActiveExplicitSteerSessionKey as r,isExplicitSteerCommandTurn as t};