openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
490 lines (489 loc) • 22.8 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { r as resolveGlobalMap } from "./global-singleton-D7yf05nR.mjs";
import { t as pruneMapToMaxSize } from "./map-size-BBr20tbc.mjs";
import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs";
import "./session-key-CqAyZeVk.mjs";
import { r as normalizeOptionalAccountId } from "./account-id-BqKT3GuY.mjs";
import { Et as _enum, Fn as object, Jn as string, Lt as boolean, Nt as array, Pn as number, Yt as discriminatedUnion, or as union, sr as unknown, xn as literal } from "./schemas-Cy6abvsu.mjs";
import { O as validateAgentRunDelegatedAuthority, c as getActiveAgentRunDelegatedAuthority } from "./agent-run-registry-D7vkrqFT.mjs";
import { t as normalizeChatType } from "./chat-type-CL5nBDaO.mjs";
import { t as safeEqualSecret } from "./secret-equal-BogABOFr.mjs";
import { a as parseExecutionIdentityAdmissionToken } from "./execution-identity-admission-EuMO_R29.mjs";
import { n as ensureExecApprovalsSocket, r as readExecApprovalsSocket } from "./exec-approvals-socket-DEOHtzox.mjs";
import { u as hasCronCreatorGrantProvenance } from "./cron-creator-authority-grant-pGPjtQX_.mjs";
import { createHmac, randomUUID } from "node:crypto";
//#region src/gateway/agent-runtime-execution-lineage.ts
const AGENT_RUNTIME_EXECUTION_LINEAGE = Symbol("agentRuntimeExecutionLineage");
const AGENT_RUNTIME_EXECUTION_LINEAGE_REDEMPTION = Symbol("agentRuntimeExecutionLineageRedemption");
const EXECUTION_LINEAGE_HANDOFF_TTL_MS = 6e4;
function hasAgentRuntimeExecutionLineageRedemption(e) {
return AGENT_RUNTIME_EXECUTION_LINEAGE_REDEMPTION in e;
}
const executionLineageHandoffs = resolveGlobalMap(Symbol.for("openclaw.agentRuntimeExecutionLineageHandoffs"), (e) => e.clear());
function sameOperationalRunInstance(e, t) {
return e.instanceId === t.instanceId && e.runId === t.runId;
}
function pruneExecutionLineageHandoffs(e) {
for (const [t, n] of executionLineageHandoffs) if (n.expiresAtMs <= e || !validateAgentRunDelegatedAuthority(n.delegatedAuthority)) executionLineageHandoffs.delete(t);
pruneMapToMaxSize(executionLineageHandoffs, 255);
}
/** Add process-local lineage without expanding or serializing the spawn context. */
function withAgentRuntimeExecutionLineage(e, t) {
return {
...e,
[AGENT_RUNTIME_EXECUTION_LINEAGE]: t
};
}
function readAgentRuntimeExecutionLineage(e) {
return e?.[AGENT_RUNTIME_EXECUTION_LINEAGE];
}
/** Register a local one-shot handoff; its opaque id is correlation, never authority. */
function createAgentRuntimeExecutionLineageHandoff(e) {
if (!readAgentRuntimeExecutionLineage(e.sessionSpawnContext) || !validateAgentRunDelegatedAuthority(e.delegatedAuthority)) return;
if (!sameOperationalRunInstance(e.operationalRunInstance, e.delegatedAuthority.operationalRunInstance) || e.executionIdentity !== void 0 && e.executionIdentity.runId !== e.operationalRunInstance.runId) throw new Error("execution lineage handoff disagrees with its parent admission");
const t = Date.now();
pruneExecutionLineageHandoffs(t);
const n = randomUUID();
executionLineageHandoffs.set(n, Object.freeze({
agentId: e.agentId,
sessionKey: e.sessionKey,
operationalRunInstance: e.operationalRunInstance,
delegatedAuthority: e.delegatedAuthority,
...e.executionIdentity ? { executionIdentity: e.executionIdentity } : {},
sessionSpawnContext: e.sessionSpawnContext,
expiresAtMs: t + EXECUTION_LINEAGE_HANDOFF_TTL_MS
}));
return Object.freeze({
id: n,
revoke: () => {
executionLineageHandoffs.delete(n);
}
});
}
/** Redeem the host-owned handoff while binding it to the exact signed parent owner. */
function redeemAgentRuntimeExecutionLineageHandoff(e) {
const t = executionLineageHandoffs.get(e.id);
executionLineageHandoffs.delete(e.id);
if (!t || t.expiresAtMs <= Date.now() || t.agentId !== e.agentId || t.sessionKey !== e.sessionKey || !sameOperationalRunInstance(t.operationalRunInstance, e.operationalRunInstance) || t.delegatedAuthority.claimId !== e.delegatedAuthority.claimId || t.delegatedAuthority.lifecycleGeneration !== e.delegatedAuthority.lifecycleGeneration || !validateAgentRunDelegatedAuthority(t.delegatedAuthority)) return;
let n = false;
return Object.freeze({
...t.executionIdentity ? { executionIdentity: t.executionIdentity } : {},
sessionSpawnContext: t.sessionSpawnContext,
redemption: Object.freeze({ consume: () => {
if (n || !validateAgentRunDelegatedAuthority(t.delegatedAuthority)) return false;
n = true;
return true;
} })
});
}
function withAgentRuntimeExecutionLineageRedemption(e, t) {
return {
...e,
[AGENT_RUNTIME_EXECUTION_LINEAGE_REDEMPTION]: t
};
}
/** Direct in-process lineage needs no redemption; handed-off lineage is one-shot. */
function consumeAgentRuntimeExecutionLineage(e) {
return hasAgentRuntimeExecutionLineageRedemption(e) ? e[AGENT_RUNTIME_EXECUTION_LINEAGE_REDEMPTION].consume() : true;
}
//#endregion
//#region src/gateway/agent-runtime-identity-token.ts
const AGENT_RUNTIME_IDENTITY_TOKEN_CONTEXT = "openclaw:gateway-agent-runtime-identity-token:v1";
const AGENT_RUNTIME_IDENTITY_TOKEN_KIND = "agent-runtime";
const MESSAGE_ACTION_TOKEN_TTL_MS = 6e4;
const CRON_SELF_MANAGEMENT_TOKEN_TTL_MS = 6e4;
const normalizedRequiredStringSchema = string().transform(normalizeOptionalString).pipe(string());
const ignoredOptionalStringSchema = unknown().transform(normalizeOptionalString).optional();
const safeNonNegativeIntegerSchema = number().refine(Number.isSafeInteger).refine((e) => e >= 0);
const operationalRunInstanceSchema = object({
instanceId: normalizedRequiredStringSchema,
runId: normalizedRequiredStringSchema
});
const gatewayUiCommandTargetSchema = object({
connId: normalizedRequiredStringSchema,
profileId: normalizedRequiredStringSchema.optional()
});
const workerTurnClaimSchema = object({
sessionId: normalizedRequiredStringSchema,
claimId: normalizedRequiredStringSchema,
runId: normalizedRequiredStringSchema,
placementGeneration: safeNonNegativeIntegerSchema,
owner: object({
kind: literal("worker"),
environmentId: normalizedRequiredStringSchema,
ownerEpoch: safeNonNegativeIntegerSchema
})
});
const delegatedAuthoritySchema = discriminatedUnion("kind", [object({
kind: literal("local"),
lifecycleGeneration: normalizedRequiredStringSchema,
claimId: normalizedRequiredStringSchema,
operationalRunInstance: operationalRunInstanceSchema
}), object({
kind: literal("worker"),
lifecycleGeneration: normalizedRequiredStringSchema,
claimId: normalizedRequiredStringSchema,
operationalRunInstance: operationalRunInstanceSchema,
turnClaim: workerTurnClaimSchema
})]);
const stringListSchema = array(string()).transform((e) => e.map((e) => e.trim()).filter(Boolean));
const spawnModelAutoSelectionSchema = object({
model: normalizedRequiredStringSchema,
hasFallbackOrigin: boolean()
});
const sessionSpawnContextSchema = object({
requesterProfileId: normalizedRequiredStringSchema.optional(),
gitContributorProfileId: normalizedRequiredStringSchema.optional(),
requesterSenderIsOwner: boolean().optional(),
completionOwnerSessionKey: normalizedRequiredStringSchema.optional(),
inheritedPermissionMode: _enum([
"read-only",
"guarded",
"workspace",
"full"
]).optional(),
resolvedModel: object({
provider: normalizedRequiredStringSchema,
model: normalizedRequiredStringSchema
}).optional(),
inheritedToolPolicy: object({
version: literal(1),
allow: stringListSchema,
deny: stringListSchema,
delegatedToolPolicy: object({
requesterSessionKey: normalizedRequiredStringSchema,
targetAgentId: normalizedRequiredStringSchema,
deny: stringListSchema,
requesterDeny: stringListSchema
}).strict().optional()
}),
spawnModelAutoSelection: spawnModelAutoSelectionSchema.optional()
}).transform((e) => ({
...e.requesterProfileId ? { requesterProfileId: e.requesterProfileId } : {},
...e.gitContributorProfileId ? { gitContributorProfileId: e.gitContributorProfileId } : {},
...e.completionOwnerSessionKey ? { completionOwnerSessionKey: e.completionOwnerSessionKey } : {},
...e.requesterSenderIsOwner !== void 0 ? { requesterSenderIsOwner: e.requesterSenderIsOwner } : {},
inheritedToolPolicy: e.inheritedToolPolicy,
...e.inheritedPermissionMode ? { inheritedPermissionMode: e.inheritedPermissionMode } : {},
...e.resolvedModel ? { resolvedModel: e.resolvedModel } : {},
...e.spawnModelAutoSelection ? { spawnModelAutoSelection: e.spawnModelAutoSelection } : {}
}));
const cronCreatorAuthorityGrantSchema = object({
runId: normalizedRequiredStringSchema,
token: normalizedRequiredStringSchema
});
const messageActionToolContextSchema = object({
currentChannelId: ignoredOptionalStringSchema,
currentChatType: unknown().transform((e) => normalizeChatType(typeof e === "string" ? e : void 0)).optional(),
currentMessagingTarget: ignoredOptionalStringSchema,
currentGraphChannelId: ignoredOptionalStringSchema,
currentChannelProvider: ignoredOptionalStringSchema,
currentThreadTs: ignoredOptionalStringSchema,
currentMessageId: union([string(), number()]).optional(),
currentSourceTurnId: ignoredOptionalStringSchema,
replyToMode: _enum([
"off",
"first",
"all",
"batched"
]).optional(),
hasRepliedRef: object({ value: boolean() }).optional(),
sameChannelThreadRequired: boolean().optional().catch(void 0),
skipCrossContextDecoration: boolean().optional().catch(void 0)
}).transform((e) => ({
...e,
currentChannelProvider: e.currentChannelProvider
}));
const messageActionContextSchema = object({
expiresAtMs: number().finite(),
turnCapability: normalizedRequiredStringSchema.optional(),
sourceReplyFinal: boolean().optional(),
sourceReplyToolCallId: normalizedRequiredStringSchema.optional(),
sessionId: ignoredOptionalStringSchema,
sourceReplySessionKey: ignoredOptionalStringSchema,
requesterAccountId: ignoredOptionalStringSchema,
requesterSenderId: ignoredOptionalStringSchema,
requesterSenderName: ignoredOptionalStringSchema,
requesterSenderUsername: ignoredOptionalStringSchema,
requesterSenderE164: ignoredOptionalStringSchema,
toolContext: messageActionToolContextSchema.optional()
});
const cronSelfManagementContextSchema = object({
jobId: normalizedRequiredStringSchema,
expiresAtMs: number().finite()
});
const agentRuntimeIdentityTokenPayloadSchema = object({
kind: literal(AGENT_RUNTIME_IDENTITY_TOKEN_KIND),
agentId: string(),
sessionKey: string(),
operationalRunInstance: operationalRunInstanceSchema,
delegatedAuthority: delegatedAuthoritySchema,
approvalOwnerPluginId: string().optional().catch(void 0),
executionIdentity: unknown().optional(),
turnSourceChannel: string().optional().catch(void 0),
turnSourceLocal: literal(true).optional(),
turnSourceTo: string().optional().catch(void 0),
turnSourceAccountId: string().optional().catch(void 0),
turnSourceThreadId: union([string(), number()]).optional().catch(void 0),
gatewayUiCommandTarget: gatewayUiCommandTargetSchema.optional(),
messageActionContext: messageActionContextSchema.optional(),
cronSelfManagementContext: cronSelfManagementContextSchema.optional(),
cronToolsAllowCapture: literal("final-executable-surface").optional(),
cronExecToolTarget: object({
host: literal("gateway"),
ask: literal("always").optional()
}).optional(),
cronCreatorAuthorityGrant: cronCreatorAuthorityGrantSchema.optional(),
cronManagementGrant: cronCreatorAuthorityGrantSchema.optional(),
sessionSpawnContext: sessionSpawnContextSchema.optional(),
executionLineageHandoffId: normalizedRequiredStringSchema.optional()
});
function decodeDelegatedAuthority(e, t) {
const { lifecycleGeneration: n, claimId: r } = e;
const { instanceId: i, runId: a } = e.operationalRunInstance;
if (i !== t.instanceId || a !== t.runId) return;
const o = {
operationalRunInstance: t,
lifecycleGeneration: n,
claimId: r
};
if (e.kind === "local") return {
kind: "local",
...o
};
return e.turnClaim.runId === t.runId ? {
kind: "worker",
...o,
turnClaim: e.turnClaim
} : void 0;
}
async function readSharedAgentRuntimeIdentitySecret() {
return (await readExecApprovalsSocket())?.socket_token?.trim() || null;
}
async function requireSharedAgentRuntimeIdentitySecret() {
const e = (await ensureExecApprovalsSocket()).socket_token?.trim();
if (!e) throw new Error("Unable to mint agent runtime identity token without local socket credentials.");
return e;
}
function signPayload(e, t) {
return createHmac("sha256", e).update(AGENT_RUNTIME_IDENTITY_TOKEN_CONTEXT).update("\0").update(t).digest("base64url");
}
function encodePayload(e) {
return Buffer.from(JSON.stringify(e), "utf8").toString("base64url");
}
function decodeMessageActionContext(e, t) {
if (t >= e.expiresAtMs) return;
const n = {
expiresAtMs: e.expiresAtMs,
turnCapability: e.turnCapability,
sessionId: e.sessionId,
sourceReplySessionKey: e.sourceReplySessionKey,
requesterAccountId: e.requesterAccountId,
requesterSenderId: e.requesterSenderId,
requesterSenderName: e.requesterSenderName,
requesterSenderUsername: e.requesterSenderUsername,
requesterSenderE164: e.requesterSenderE164,
toolContext: e.toolContext
};
if (e.sourceReplyFinal === true) {
if (!e.sourceReplyToolCallId) return;
return {
...n,
sourceReplyFinal: true,
sourceReplyToolCallId: e.sourceReplyToolCallId
};
}
return {
...n,
...e.sourceReplyFinal === false ? { sourceReplyFinal: false } : {},
...e.sourceReplyToolCallId ? { sourceReplyToolCallId: e.sourceReplyToolCallId } : {}
};
}
function decodePayload(e, t) {
try {
return parsePayload(JSON.parse(Buffer.from(e, "base64url").toString("utf8")), t);
} catch {
return;
}
}
function parsePayload(e, t) {
try {
const n = agentRuntimeIdentityTokenPayloadSchema.safeParse(e);
if (!n.success) return;
const r = n.data;
const i = normalizeAgentId(r.agentId);
const a = r.sessionKey.trim();
const o = normalizeOptionalString(r.approvalOwnerPluginId);
const s = r.operationalRunInstance.instanceId;
const c = r.operationalRunInstance.runId;
const l = normalizeOptionalAccountId(r.turnSourceAccountId);
const u = normalizeOptionalString(r.turnSourceChannel);
const d = r.turnSourceLocal;
if (d && u) return;
const f = normalizeOptionalString(r.turnSourceTo);
const p = r.turnSourceThreadId;
if (!i || !a) return;
const m = Object.freeze({
instanceId: s,
runId: c
});
const h = decodeDelegatedAuthority(r.delegatedAuthority, m);
if (!h) return;
const g = r.messageActionContext ? decodeMessageActionContext(r.messageActionContext, t) : void 0;
if (r.messageActionContext !== void 0 && !g) return;
const _ = r.cronSelfManagementContext && t < r.cronSelfManagementContext.expiresAtMs ? r.cronSelfManagementContext : void 0;
if (r.cronSelfManagementContext !== void 0 && !_) return;
const v = r.sessionSpawnContext;
const y = r.executionLineageHandoffId;
const b = r.cronToolsAllowCapture;
const x = b ? r.cronExecToolTarget : void 0;
const S = r.cronCreatorAuthorityGrant;
if (!hasCronCreatorGrantProvenance(r, c)) return;
let C;
if (r.executionIdentity !== void 0) C = parseExecutionIdentityAdmissionToken(r.executionIdentity);
if (C?.runId !== c) C = void 0;
return {
kind: AGENT_RUNTIME_IDENTITY_TOKEN_KIND,
agentId: i,
sessionKey: a,
operationalRunInstance: m,
delegatedAuthority: h,
...o ? { approvalOwnerPluginId: o } : {},
...u ? { turnSourceChannel: u } : {},
...d ? { turnSourceLocal: d } : {},
...f ? { turnSourceTo: f } : {},
...l ? { turnSourceAccountId: l } : {},
...p !== void 0 ? { turnSourceThreadId: p } : {},
...r.gatewayUiCommandTarget ? { gatewayUiCommandTarget: Object.freeze(r.gatewayUiCommandTarget) } : {},
...g ? { messageActionContext: g } : {},
..._ ? { cronSelfManagementContext: _ } : {},
...v ? { sessionSpawnContext: v } : {},
...y ? { executionLineageHandoffId: y } : {},
...b ? { cronToolsAllowCapture: b } : {},
...x ? { cronExecToolTarget: x } : {},
...S ? { cronCreatorAuthorityGrant: S } : {},
...r.cronManagementGrant ? { cronManagementGrant: r.cronManagementGrant } : {},
...C ? { executionIdentity: C } : {}
};
} catch {
return;
}
}
function prepareAgentRuntimeIdentityTokenPayload(e) {
const t = normalizeOptionalString(e.operationalRunInstance.instanceId);
const n = normalizeOptionalString(e.operationalRunInstance.runId);
if (!t || !n) throw new Error("agent runtime identity requires an operational run instance");
const r = e.sessionSpawnContext ? sessionSpawnContextSchema.safeParse(e.sessionSpawnContext) : void 0;
if (r && !r.success) throw new Error("agent runtime session spawn context violates its bounded contract");
const i = r?.data;
const a = normalizeOptionalString(e.executionLineageHandoffId);
if (a && (i || e.executionIdentityToken)) throw new Error("execution lineage handoff cannot duplicate private spawn facts");
const o = getActiveAgentRunDelegatedAuthority({
instanceId: t,
runId: n
});
if (!o) throw new Error("agent runtime identity requires active delegated run authority");
if (e.workerTurnClaim && (e.workerTurnClaim.owner.kind !== "worker" || e.workerTurnClaim.runId !== n)) throw new Error("worker delegated authority disagrees with the operational run");
const s = e.approvalAuthority ?? o;
if (e.workerTurnClaim && s.claimId === o.claimId) throw new Error("worker runtime identity requires its original claim approval authority");
if (s.operationalRunInstance.instanceId !== t || s.operationalRunInstance.runId !== n || !validateAgentRunDelegatedAuthority(s)) throw new Error("agent runtime approval authority is no longer active");
const c = e.workerTurnClaim ? {
kind: "worker",
...s,
turnClaim: e.workerTurnClaim
} : {
kind: "local",
...s
};
if (!hasCronCreatorGrantProvenance(e, n)) throw new Error("cron creator authority grants require tool-surface or authenticated-requester provenance");
if (e.messageActionContext?.sourceReplyFinal === true && !normalizeOptionalString(e.messageActionContext.sourceReplyToolCallId)) throw new Error("terminal source reply requires tool-call correlation");
const l = e.messageActionContext ? {
...e.messageActionContext,
expiresAtMs: Math.min(e.messageActionContext.expiresAtMs, Date.now() + MESSAGE_ACTION_TOKEN_TTL_MS)
} : void 0;
const u = normalizeOptionalAccountId(e.turnSourceAccountId);
const d = normalizeOptionalString(e.turnSourceChannel);
if (e.turnSourceLocal === true && d) throw new Error("agent runtime turn source cannot be both local and channel-bound");
const f = normalizeOptionalString(e.turnSourceTo);
const p = typeof e.turnSourceThreadId === "string" ? normalizeOptionalString(e.turnSourceThreadId) : e.turnSourceThreadId;
const m = normalizeOptionalString(e.cronSelfManagementJobId);
const h = m ? {
jobId: m,
expiresAtMs: Date.now() + CRON_SELF_MANAGEMENT_TOKEN_TTL_MS
} : void 0;
return {
kind: AGENT_RUNTIME_IDENTITY_TOKEN_KIND,
agentId: normalizeAgentId(e.agentId),
sessionKey: e.sessionKey.trim(),
operationalRunInstance: {
instanceId: t,
runId: n
},
delegatedAuthority: c,
...normalizeOptionalString(e.approvalOwnerPluginId) ? { approvalOwnerPluginId: normalizeOptionalString(e.approvalOwnerPluginId) } : {},
...d ? { turnSourceChannel: d } : {},
...e.turnSourceLocal === true ? { turnSourceLocal: true } : {},
...f ? { turnSourceTo: f } : {},
...u ? { turnSourceAccountId: u } : {},
...p !== void 0 ? { turnSourceThreadId: p } : {},
...e.gatewayUiCommandTarget ? { gatewayUiCommandTarget: gatewayUiCommandTargetSchema.parse(e.gatewayUiCommandTarget) } : {},
...l ? { messageActionContext: l } : {},
...h ? { cronSelfManagementContext: h } : {},
...e.cronToolsAllowCapture === "final-executable-surface" ? { cronToolsAllowCapture: e.cronToolsAllowCapture } : {},
...e.cronToolsAllowCapture === "final-executable-surface" && e.cronExecToolTarget?.host === "gateway" ? { cronExecToolTarget: { ...e.cronExecToolTarget } } : {},
...e.cronCreatorAuthorityGrant ? { cronCreatorAuthorityGrant: e.cronCreatorAuthorityGrant } : {},
...e.cronManagementGrant ? { cronManagementGrant: e.cronManagementGrant } : {},
...i ? { sessionSpawnContext: i } : {},
...a ? { executionLineageHandoffId: a } : {},
...e.executionIdentityToken?.runId === n ? { executionIdentity: e.executionIdentityToken } : {}
};
}
/** Measure the exact ASCII token size without reading signing credentials or minting a bearer. */
function measureAgentRuntimeIdentityTokenBytes(e) {
const t = encodePayload(prepareAgentRuntimeIdentityTokenPayload(e));
return Buffer.byteLength(`${t}.${signPayload("", t)}`, "utf8");
}
/** Mint an opaque token that lets trusted local agent-tool clients identify their agent. */
async function mintAgentRuntimeIdentityToken(e) {
const t = encodePayload(prepareAgentRuntimeIdentityTokenPayload(e));
return `${t}.${signPayload(await requireSharedAgentRuntimeIdentitySecret(), t)}`;
}
/** Validate a presented agent runtime token and return the internal caller identity. */
async function verifyAgentRuntimeIdentityToken(e, t) {
const n = e?.trim();
if (!n) return;
const [r, i, ...a] = n.split(".");
if (!r || !i || a.length > 0) return;
const o = await readSharedAgentRuntimeIdentitySecret();
if (!o || !safeEqualSecret(i, signPayload(o, r))) return;
const s = decodePayload(r, t ?? Date.now());
if (!s) return;
return resolveAgentRuntimeIdentityPayload(s);
}
/** Build a host-owned caller identity without minting or reading transport credentials. */
async function createAgentRuntimeIdentity(e) {
const t = parsePayload(prepareAgentRuntimeIdentityTokenPayload(e), Date.now());
return t ? resolveAgentRuntimeIdentityPayload(t) : void 0;
}
function resolveAgentRuntimeIdentityPayload(e) {
const t = e.executionLineageHandoffId ? redeemAgentRuntimeExecutionLineageHandoff({
id: e.executionLineageHandoffId,
agentId: e.agentId,
sessionKey: e.sessionKey,
operationalRunInstance: e.operationalRunInstance,
delegatedAuthority: e.delegatedAuthority
}) : void 0;
if (e.executionLineageHandoffId && !t) return;
const n = t?.executionIdentity ?? e.executionIdentity;
const r = t?.sessionSpawnContext ?? e.sessionSpawnContext;
const { kind: i, executionLineageHandoffId: a, executionIdentity: o, sessionSpawnContext: s, ...c } = e;
const l = {
...c,
kind: "agentRuntime",
...n ? { executionIdentity: n } : {},
...r ? { sessionSpawnContext: r } : {}
};
return t ? withAgentRuntimeExecutionLineageRedemption(l, t.redemption) : l;
}
//#endregion
export { consumeAgentRuntimeExecutionLineage as a, withAgentRuntimeExecutionLineage as c, verifyAgentRuntimeIdentityToken as i, measureAgentRuntimeIdentityTokenBytes as n, createAgentRuntimeExecutionLineageHandoff as o, mintAgentRuntimeIdentityToken as r, readAgentRuntimeExecutionLineage as s, createAgentRuntimeIdentity as t };