openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 3.27 kB
JavaScript
import{p as toErrorObject}from"./error-coercion-DlKnt6w-.mjs";import"./errors-D37BJTfI.mjs";import{n as normalizeAgentId}from"./agent-id-cOfqmfln.mjs";import{N as parseAgentSessionKey,y as isAcpSessionKey}from"./session-key-BPgKfU2m.mjs";import{a as normalizeStoreSessionKey}from"./store-entry-DbH6jRLn.mjs";import{n as buildAcpDatabaseSessionKey}from"./session-meta-keys-DL7xDHXx.mjs";import{n as AcpRuntimeError,t as ACP_ERROR_CODES}from"./errors-C1zF32os.mjs";import"./errors-BaJzP_Lf.mjs";import{n as resolveSessionStorePathForAcp}from"./session-meta-store-BnKQZPZp.mjs";
//!src/acp/control-plane/manager.utils.ts
function resolveAcpAgentFromSessionKey(e){const t=parseAgentSessionKey(e);return normalizeAgentId(t?.agentId??`main`)}function resolveMissingMetaError(e){return new AcpRuntimeError(`ACP_SESSION_INIT_FAILED`,`ACP metadata is missing for ${e}. Recreate this ACP session with /acp spawn and rebind the thread.`)}function resolveStoredAcpSession(e,t){if(t?.acp)return{kind:`ready`,...e,meta:t.acp,entry:t.entry};return isAcpSessionKey(e.sessionKey)?{kind:`stale`,...e,error:resolveMissingMetaError(e.sessionKey)}:{kind:`none`,...e}}function resolveAcpSessionResolutionError(e){if(e.kind===`ready`)return null;if(e.kind===`stale`)return e.error;return new AcpRuntimeError(`ACP_SESSION_INIT_FAILED`,`Session is not ACP-enabled: ${e.sessionKey}`)}function requireReadySessionMeta(e){if(e.kind===`ready`)return e.meta;throw toErrorObject(resolveAcpSessionResolutionError(e),`Non-Error thrown`)}function resolveAcpSessionTarget(e){const t=normalizeStoreSessionKey(e.sessionKey);if(!t)throw new AcpRuntimeError(`ACP_SESSION_INIT_FAILED`,`ACP session key is required.`);const{agentId:n,storeSessionKey:r}=resolveSessionStorePathForAcp({...e,sessionKey:t});return{agentId:n,sessionKey:r}}function acpSessionActorKey(e){return buildAcpDatabaseSessionKey(normalizeStoreSessionKey(e.sessionKey),e.agentId)}function normalizeAcpErrorCode(e){if(!e)return`ACP_TURN_FAILED`;const t=e.trim().toUpperCase();return ACP_ERROR_CODES.find(e=>e===t)??`ACP_TURN_FAILED`}function createUnsupportedControlError(e){return new AcpRuntimeError(`ACP_BACKEND_UNSUPPORTED_CONTROL`,`ACP backend "${e.backend}" does not support ${e.control}.`)}function hasLegacyAcpIdentityProjection(e){const t=e;return Object.hasOwn(t,`backendSessionId`)||Object.hasOwn(t,`agentSessionId`)||Object.hasOwn(t,`sessionIdsProvisional`)}const SESSION_ACTOR_SUPERSEDED_DETAIL_CODE=`SESSION_ACTOR_SUPERSEDED`;function createSupersededActorError(e){return new AcpRuntimeError(`ACP_SESSION_INIT_FAILED`,`ACP session actor was superseded during runtime initialization for ${e}.`,{detailCode:SESSION_ACTOR_SUPERSEDED_DETAIL_CODE})}function isSupersededActorError(e){return e instanceof AcpRuntimeError&&e.detailCode===SESSION_ACTOR_SUPERSEDED_DETAIL_CODE}function assertCurrentAcpActor(e,t){if(!e)throw createSupersededActorError(t)}export{hasLegacyAcpIdentityProjection as a,requireReadySessionMeta as c,resolveAcpSessionTarget as d,resolveStoredAcpSession as f,createUnsupportedControlError as i,resolveAcpAgentFromSessionKey as l,assertCurrentAcpActor as n,isSupersededActorError as o,createSupersededActorError as r,normalizeAcpErrorCode as s,acpSessionActorKey as t,resolveAcpSessionResolutionError as u};