UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

50 lines (49 loc) • 1.7 kB
import { r as normalizeAgentIdStrict } from "./agent-id-CQjtp2ft.mjs"; import "./session-key-CqAyZeVk.mjs"; import { i as listAgentIds } from "./agent-roster-t1ooUdXp.mjs"; import { _ as resolveDefaultAgentId, a as resolveAgentDir, t as AgentSelectionRequiredError } from "./agent-scope-config-DmXgFGKP.mjs"; import "./agent-scope-BwB8YH6y.mjs"; import { r as GatewayErrorDetailCodes, t as ErrorCodes } from "./gateway-error-details-B69XiHdh.mjs"; import { p as errorShape } from "./error-codes-BzF7aRQ0.mjs"; //#region src/gateway/server-methods/model-auth-agent-scope.ts /** Resolves model-auth RPC scope without letting explicit garbage reach the default store. */ 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 }) }; } //#endregion export { resolveModelAuthAgentScope as t };