UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.5 kB
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{r as normalizeAgentIdStrict}from"./agent-id-cOfqmfln.mjs";import"./session-key-BPgKfU2m.mjs";import{i as listAgentIds}from"./agent-roster-4XrgUgPK.mjs";import{A as tryResolveLegacyCompatibilityAgentId,_ as resolveDefaultAgentId,t as AgentSelectionRequiredError}from"./agent-scope-config-CG9CFpGX.mjs";import"./agent-scope-Dw5XRSEh.mjs";import{i as ErrorCodes}from"./missing-scope-error-CkgBgh6d.mjs";import{p as errorShape}from"./error-codes-CQNGhXT-.mjs"; //!src/gateway/server-methods/agent-id-shared.ts function resolveConfiguredAgentIdOrRespondError(e,t,n){const r=normalizeAgentIdStrict(e);if(r.ok&&listAgentIds(t).includes(r.value))return r.value;n(false,void 0,errorShape(ErrorCodes.INVALID_REQUEST,`agent "${e}" not found`));return null}function resolveAgentIdOrRespondError(e){const t=listAgentIds(e.cfg);const n=normalizeOptionalString(e.rawAgentId)??``;let r;try{r=n||tryResolveLegacyCompatibilityAgentId(e.cfg)||resolveDefaultAgentId(e.cfg,{surface:`this Gateway request`,hint:`Set agentId to one of the configured agents.`})}catch(t){if(!(t instanceof AgentSelectionRequiredError))throw t;e.respond(false,void 0,errorShape(ErrorCodes.INVALID_REQUEST,t.message));return null}if(n&&!t.includes(r)){e.respond(false,void 0,errorShape(ErrorCodes.INVALID_REQUEST,`unknown agent id "${n}"`));return null}return{cfg:e.cfg,agentId:r}}export{resolveConfiguredAgentIdOrRespondError as n,resolveAgentIdOrRespondError as t};