UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

94 lines (93 loc) • 3.73 kB
import { h as readRuntimeConfig } from "./runtime-snapshot-WbwbY5b7.mjs"; import { _t as getSessionControllerEntryForOperation, bt as isCurrentSessionControllerOperation, kt as operationsByUpstreamAbortSignal } from "./session-controller.state-BApgK0mV.mjs"; import { d as getControllerEmbeddedAttachment, r as ACTIVE_EMBEDDED_RUNS_BY_RUN_ID, u as getActiveNativeAttempt } from "./run-state-jrY5s7TG.mjs"; import "./config-CMA-J084.mjs"; import { i as getRpcSourceForSignal } from "./session-controller.rpc-sources-CTFbRW2t.mjs"; import { i as captureSessionControllerStop, r as stopSession } from "./session-controller.stop-BqKrTY7V.mjs"; import { c as resolveActiveReplyOperationForSessionId, l as resolveActiveSessionRunId } from "./session-controller.queries-D7T8foQX.mjs"; import { i as getDiagnosticSessionActivitySnapshot } from "./diagnostic-run-activity-BzWz2WN_.mjs"; import { a as resolveActiveReplyRunOwnerForSignal } from "./session-controller.barriers-DbvoxYCP.mjs"; import { n as steerSessionControllerOperation } from "./session-controller.steer-BWjVys2Y.mjs"; import { h as resolveActiveEmbeddedRunOwnerByRunId } from "./runs-C1RO1Y6L.mjs"; import { t as abortControlledSubagents } from "./chat-abort-descendants-2IwJM3Ms.mjs"; //#region src/talk/agent-run-control.runtime.ts /** Signal-owned sources stay exact; external callers retain native run-ID selection. */ function resolveSourceRunOwner(e, t) { if (t.aborted) return; const n = getRpcSourceForSignal(e, t)?.input; const r = n ? n.claim?.released ? void 0 : n.claim?.operation : operationsByUpstreamAbortSignal.get(t); if (!n && !r) { const t = resolveActiveEmbeddedRunOwnerByRunId(e); return t ? { ...t, operation: ACTIVE_EMBEDDED_RUNS_BY_RUN_ID.get(e.trim())?.operation } : void 0; } if (!r || r.result || !isCurrentSessionControllerOperation(r)) return; const i = ACTIVE_EMBEDDED_RUNS_BY_RUN_ID.get(e.trim()); if (i && i.operation !== r) return; const a = resolveActiveEmbeddedRunOwnerByRunId(e) ?? (getControllerEmbeddedAttachment(r) ? void 0 : resolveActiveReplyRunOwnerForSignal(r.abortSignal)); return a ? { ...a, operation: r } : void 0; } /** * Key-only Talk cancel: Stop source `talk` aborts the session's current turn and * that turn's subagents, and keeps the session's waiting inputs. */ async function stopRealtimeVoiceSessionRun(e) { const t = resolveActiveReplyOperationForSessionId(e.sessionId); if (!t || t.key !== e.sessionKey) return false; const n = getSessionControllerEntryForOperation(t); const r = captureSessionControllerStop({ inputs: n.mailbox?.entries.filter((e) => e.claim?.operation === t), operations: [t] }); const i = getActiveNativeAttempt(e.sessionId)?.runId; return (await stopSession({ source: "talk", capture: r, assertCurrent: e.assertCurrent, hookContext: { sessionKey: e.sessionKey, sessionId: e.sessionId, commandSource: "talk" }, stopChildren: async (n) => { if (!i) { await n(); return { stopped: 0, failed: 0 }; } const r = await abortControlledSubagents({ cfg: readRuntimeConfig(), sessionKey: e.sessionKey, agentId: t.agentId, requesterTurnRunId: i, beforeKill: n, assertCurrent: e.assertCurrent }); return { stopped: r?.killed ?? 0, failed: r?.status === "error" ? r.failed : 0 }; } }).completed).aborted; } const realtimeVoiceControlRuntime = { stopRealtimeVoiceSessionRun, steerActiveRun: (e, t, n) => steerSessionControllerOperation({ operation: e, text: t, options: n, abortOnUnconfirmedTranscript: false }), resolveSourceRunOwner, resolveActiveSessionRunId, getDiagnosticSessionActivitySnapshot }; //#endregion export { realtimeVoiceControlRuntime };