openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
39 lines (38 loc) • 1.62 kB
JavaScript
import { n as getRegisteredAgentHarness } from "./registry-D1_C7waJ.js";
import { h as resolveSessionPinnedHarnessId } from "./agent-harness-session-key-BOz3yx0-.js";
import { t as AgentHarnessPreflightError } from "./errors-70ml6R0Z.js";
//#region src/agents/harness/session-runtime-ownership.ts
/** Reads private ownership for a caller-supplied authoritative session, never a pin heuristic. */
function readSessionRuntimeOwnership(params) {
const entry = params.sessionEntry;
const sessionId = entry?.sessionId;
const harnessId = resolveSessionPinnedHarnessId(entry);
if (!sessionId || !harnessId) return;
const harness = getRegisteredAgentHarness(harnessId)?.harness;
if (!harness?.resolveSessionRuntimeOwnership) return;
let active = true;
const assertCurrent = () => {
params.assertCurrent?.();
if (!active || getRegisteredAgentHarness(harnessId)?.harness !== harness || entry?.sessionId !== sessionId || resolveSessionPinnedHarnessId(entry) !== harnessId) throw new AgentHarnessPreflightError("Native session ownership changed while reading its runtime. Reattach the original native session before retrying.");
};
try {
assertCurrent();
const ownership = harness.resolveSessionRuntimeOwnership({
config: params.config,
agentId: params.agentId,
sessionId,
sessionKey: params.sessionKey,
storePath: params.storePath,
assertCurrent
});
assertCurrent();
return ownership ? {
...ownership,
...ownership.modelRef ? { modelRef: { ...ownership.modelRef } } : {}
} : void 0;
} finally {
active = false;
}
}
//#endregion
export { readSessionRuntimeOwnership as t };