UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

67 lines (66 loc) • 2.97 kB
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { i as resolveExplicitSessionStorePathForScope, l as resolveSessionStorePathCore } from "./paths-DvQ5AJvD.mjs"; import { x as resolveSessionAgentId } from "./agent-scope-config-DmXgFGKP.mjs"; import "./agent-scope-BwB8YH6y.mjs"; import { X as captureSessionTarget, d as getSessionControllerOperation } from "./session-controller.state-BApgK0mV.mjs"; import { l as resolveCommandTurnContext, o as isNativeCommandTurn, r as isAuthorizedTextSlashCommandTurn } from "./command-turn-context-BaN4kAo-.mjs"; import { o as captureReplyMessageInjectionTarget } from "./session-controller.steer-BWjVys2Y.mjs"; import "./session-controller-Bu0l-8-p.mjs"; import { t as resolveCommandSourceSessionKey } from "./command-source-session-key-BC-MTeHx.mjs"; //#region 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) ?? ""); } /** * True when this turn is an explicit /steer command. Its handler only replies with * usage or hands the message to queue policy, so admission must let it reach that * policy beside the active turn it steers instead of waiting for that turn to end. */ function isExplicitSteerCommandTurn(e) { return readExplicitSteerMessage(e) !== null; } /** * Resolve an authorized explicit steer command to the exact session that owns * an injectable active reply. This is intentionally read-only: callers decide * whether to retarget session preparation or continue as an ordinary prompt. */ 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; } } //#endregion export { parseSteerMessage as n, resolveActiveExplicitSteerSessionKey as r, isExplicitSteerCommandTurn as t };