UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

4 lines • 2.41 kB
//!packages/gateway-protocol/src/client-info.ts const GATEWAY_CLIENT_IDS={WEBCHAT_UI:`webchat-ui`,CONTROL_UI:`openclaw-control-ui`,BROWSER_COPILOT:`openclaw-browser-copilot`,TUI:`openclaw-tui`,WEBCHAT:`webchat`,CLI:`cli`,GATEWAY_CLIENT:`gateway-client`,MACOS_APP:`openclaw-macos`,LINUX_APP:`openclaw-linux`,IOS_APP:`openclaw-ios`,WATCHOS_APP:`openclaw-watchos`,ANDROID_APP:`openclaw-android`,NODE_HOST:`node-host`,WORKER:`openclaw-worker`,TEST:`test`,FINGERPRINT:`fingerprint`,PROBE:`openclaw-probe`};const GATEWAY_CLIENT_NAMES=GATEWAY_CLIENT_IDS;const GATEWAY_CLIENT_MODES={WEBCHAT:`webchat`,CLI:`cli`,UI:`ui`,BACKEND:`backend`,NODE:`node`,WORKER:`worker`,PROBE:`probe`,TEST:`test`};const GATEWAY_CLIENT_ID_BY_VALUE=new Map(Object.values(GATEWAY_CLIENT_IDS).map(e=>[e,e]));const GATEWAY_CLIENT_MODE_BY_VALUE=new Map(Object.values(GATEWAY_CLIENT_MODES).map(e=>[e,e])); //!src/shared/operator-scope-compat.ts const OPERATOR_ROLE=`operator`;const OPERATOR_ADMIN_SCOPE=`operator.admin`;const OPERATOR_READ_SCOPE=`operator.read`;const OPERATOR_TALK_SCOPE=`operator.talk`;const OPERATOR_WRITE_SCOPE=`operator.write`;const OPERATOR_CRON_SCOPE=`operator.cron`;const OPERATOR_SESSION_READ_SCOPE=`operator.sessions.read`;const OPERATOR_SESSION_WRITE_SCOPE=`operator.sessions.write`;const OPERATOR_SCOPE_PREFIX=`operator.`;function operatorScopeSatisfied(e,t){if(!e.startsWith(OPERATOR_SCOPE_PREFIX))return false;return t.includes(e)||t.includes(OPERATOR_ADMIN_SCOPE)||(e===OPERATOR_READ_SCOPE||e===OPERATOR_TALK_SCOPE||e===OPERATOR_CRON_SCOPE||e===OPERATOR_SESSION_READ_SCOPE||e===OPERATOR_SESSION_WRITE_SCOPE)&&t.includes(OPERATOR_WRITE_SCOPE)||e===OPERATOR_SESSION_READ_SCOPE&&(t.includes(OPERATOR_READ_SCOPE)||t.includes(OPERATOR_SESSION_WRITE_SCOPE))}function resolveMissingOperatorScope(e,t){for(const n of e){const e=n.trim();if(e&&!operatorScopeSatisfied(e,t))return n}return null}function roleScopesAllow(e){return resolveMissingRequestedScope(e)===null}function resolveMissingRequestedScope(e){const t=e.role.trim();const n=e.allowedScopes.map(e=>e.trim());if(t===OPERATOR_ROLE)return resolveMissingOperatorScope(e.requestedScopes,n);const r=`${t}.`;for(const t of e.requestedScopes){const e=t.trim();if(!e)continue;if(!e.startsWith(r)||!n.includes(e))return t}return null}export{GATEWAY_CLIENT_NAMES as a,GATEWAY_CLIENT_MODES as i,roleScopesAllow as n,GATEWAY_CLIENT_IDS as r,operatorScopeSatisfied as t};