UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

39 lines (38 loc) • 1.53 kB
import { o as composeSessionSourceAssertion } from "./session-source-authority-TlTpfRVE.mjs"; import { t as ErrorCodes } from "./gateway-error-details-B69XiHdh.mjs"; import { p as errorShape } from "./error-codes-BzF7aRQ0.mjs"; //#region src/gateway/server-methods/agent-runtime-authority.ts function hasActiveAgentRuntimeAuthority(e, t, n) { try { n?.(); } catch { return false; } const r = e?.internal?.agentRuntimeIdentity; const i = t.validateAgentRuntimeApprovalAuthority; return !r || !i || i(r); } function assertActiveAgentRuntimeAuthority(e, t, n) { if (!hasActiveAgentRuntimeAuthority(e, t, n)) throw new TypeError("agent runtime authority is no longer active"); } function createAgentRuntimeAuthorityGuard(e, t, n, r) { const hasActive = () => hasActiveAgentRuntimeAuthority(e, t, r); return { commitGuard: r || e?.internal?.agentRuntimeIdentity && t.validateAgentRuntimeApprovalAuthority ? composeSessionSourceAssertion([r], (n) => assertActiveAgentRuntimeAuthority(e, t, n)) : void 0, ensureActive() { if (hasActive()) return true; n(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, "agent runtime authority is no longer active")); return false; }, handleClosedError(e) { if (e instanceof TypeError && !hasActive()) { n(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, e.message)); return; } throw e; }, hasActive }; } //#endregion export { createAgentRuntimeAuthorityGuard as n, hasActiveAgentRuntimeAuthority as r, assertActiveAgentRuntimeAuthority as t };