UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

32 lines (31 loc) • 1.87 kB
import "./session-key-DY3MOX4N.mjs"; import { a as isCronSessionKey, r as isAcpSessionKey, s as isSubagentSessionKey } from "./session-key-utils-CDyBC9Gn.mjs"; import { t as freezeJsonSnapshot } from "./immutable-data-MyNs7ITg.mjs"; import { t as assertAdmittedRunOperatorAuthority } from "./admitted-run-context-D0yzk2io.mjs"; import { t as intersectOperatorScopes } from "./operator-scope-compat-Ci6GBcmU.mjs"; import { a as isAgentHarnessSessionKey } from "./agent-harness-session-key-Dx0vv6oG.mjs"; //#region src/agents/operator-run-recovery-source.ts /** Admission writes this with its source claim, never by reconstructing session attribution. */ function createRestartRecoveryOperatorSource(params) { const { authority, entry, sessionKey } = params; if (!authority) return; assertAdmittedRunOperatorAuthority(authority); authority.assertCurrent(); const snapshot = authority.recoverySnapshot; if (!snapshot || entry.incognito || entry.spawnedBy || entry.subagentRole || (entry.spawnDepth ?? 0) > 0 || entry.completionOwnerSessionKey || entry.acp || entry.pluginOwnerId || entry.cronRunContinuation || params.inputProvenance && params.inputProvenance.kind !== "external_user" || isCronSessionKey(sessionKey) || isSubagentSessionKey(sessionKey) || isAcpSessionKey(sessionKey) || isAgentHarnessSessionKey(sessionKey)) return; const source = { version: 1, agentId: params.agentId, sessionKey, sessionId: entry.sessionId, ...entry.lifecycleRevision !== void 0 ? { lifecycleRevision: entry.lifecycleRevision } : {}, sourceRunId: params.sourceRunId, snapshot: { ...structuredClone(snapshot), scopes: intersectOperatorScopes(snapshot.scopes, authority.scopes) } }; return Buffer.byteLength(JSON.stringify(source), "utf8") <= 65536 ? freezeJsonSnapshot(source) : void 0; } //#endregion export { createRestartRecoveryOperatorSource as t };