UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 1.81 kB
import{r as asNullableRecord}from"./record-coerce-BTbqdJ3-.mjs"; //!packages/gateway-protocol/src/gateway-error-codes.ts const ErrorCodes={NOT_LINKED:`NOT_LINKED`,NOT_PAIRED:`NOT_PAIRED`,AGENT_TIMEOUT:`AGENT_TIMEOUT`,INVALID_REQUEST:`INVALID_REQUEST`,FORBIDDEN:`FORBIDDEN`,APPROVAL_NOT_FOUND:`APPROVAL_NOT_FOUND`,UNAVAILABLE:`UNAVAILABLE`};const WIZARD_NOT_FOUND_ERROR_CODE=`WIZARD_NOT_FOUND`;const SETUP_ADMISSION_BUSY_ERROR_CODE=`SETUP_ADMISSION_BUSY`;const TASK_WORKTREE_SOURCE_REQUIRED_ERROR_CODE=`TASK_WORKTREE_SOURCE_REQUIRED`; //!packages/gateway-protocol/src/missing-scope-error.ts const MISSING_SCOPE_ERROR_CODE=`MISSING_SCOPE`;const LEGACY_MISSING_SCOPE_PATTERN=/\bmissing scope:\s*([a-z0-9._-]+)/i;function readMissingScopeErrorDetails(e){const t=asNullableRecord(e);if(t?.code!==`MISSING_SCOPE`)return null;const n=typeof t.missingScope===`string`?t.missingScope.trim():``;const r=Array.isArray(t.requiredScopes)?t.requiredScopes.map(e=>typeof e===`string`?e.trim():``):[];if(!n||r.length===0||r.some(e=>!e))return null;return{code:MISSING_SCOPE_ERROR_CODE,missingScope:n,requiredScopes:r}}function readMissingScopeError(e){const t=asNullableRecord(e);if(!t)return null;const n=readMissingScopeErrorDetails(t.details);if(n)return n;const r=typeof t.gatewayCode===`string`?t.gatewayCode:typeof t.code===`string`?t.code:``;if(r!==ErrorCodes.FORBIDDEN&&r!==ErrorCodes.INVALID_REQUEST)return null;const i=(typeof t.message===`string`?t.message:``).match(LEGACY_MISSING_SCOPE_PATTERN)?.[1];return i?{code:MISSING_SCOPE_ERROR_CODE,missingScope:i,requiredScopes:[i]}:null}export{SETUP_ADMISSION_BUSY_ERROR_CODE as a,ErrorCodes as i,readMissingScopeError as n,TASK_WORKTREE_SOURCE_REQUIRED_ERROR_CODE as o,readMissingScopeErrorDetails as r,WIZARD_NOT_FOUND_ERROR_CODE as s,MISSING_SCOPE_ERROR_CODE as t};