openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.43 kB
JavaScript
import{r as normalizeAgentIdStrict}from"./agent-id-cOfqmfln.mjs";import"./session-key-BPgKfU2m.mjs";import{i as listAgentIds}from"./agent-roster-4XrgUgPK.mjs";import{_ as resolveDefaultAgentId,a as resolveAgentDir,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{n as GatewayErrorDetailCodes}from"./gateway-error-details-CMG6VuUF.mjs";import{p as errorShape}from"./error-codes-CQNGhXT-.mjs";
//!src/gateway/server-methods/model-auth-agent-scope.ts
function resolveModelAuthAgentScope(e,t){let n;if(t===void 0||t===``)try{n=resolveDefaultAgentId(e,{surface:`model auth`,hint:`Pass agentId to select a configured agent.`})}catch(e){if(!(e instanceof AgentSelectionRequiredError))throw e;return{ok:false,error:errorShape(ErrorCodes.INVALID_REQUEST,e.message)}}else{if(typeof t!==`string`)return unknownAgentScope(t===null?`null`:typeof t);const r=t.trim();if(!r)return unknownAgentScope(t);const i=normalizeAgentIdStrict(r);if(!i.ok||!listAgentIds(e).includes(i.value))return unknownAgentScope(r);n=i.value}return{ok:true,agentId:n,agentDir:resolveAgentDir(e,n)}}function unknownAgentScope(e){const t={code:GatewayErrorDetailCodes.UNKNOWN_AGENT_ID,agentId:e};return{ok:false,error:errorShape(ErrorCodes.INVALID_REQUEST,`unknown agent id "${e}"`,{details:t})}}export{resolveModelAuthAgentScope as t};