openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.93 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{ml as t,pl as n}from"./control-ui-connection-Bfj9beF_.js";function r(e){return e.startsWith(`/`)&&!e.startsWith(`//`)&&!/[#\\ ]/u.test(e)&&!n(e)}function i(e){let t=URL.parse(e);if(!t)return null;let n=(t.protocol===`codex:`||t.protocol===`chatgpt:`||t.protocol===`openclaw:`)&&t.hostname===`plugins`,i=t.protocol===`https:`&&t.hostname===`chatgpt.com`;if(!n&&!i||t.hash||t.username||t.password||t.port)return null;let a=(n?t.pathname:t.pathname.replace(/^\/plugins(?=\/)/u,``)).match(/^\/([^/]+)\/app\/([^/]+)\/?$/u);if(!a?.[1]||!a[2]||i&&!t.pathname.startsWith(`/plugins/`))return null;try{let e=n?a[1].split(`@`):[a[1]];if(e.length>2||!e[0]||e.length===2&&!e[1])return null;let i=decodeURIComponent(e[0]),o=e[1]?decodeURIComponent(e[1]):void 0,s=decodeURIComponent(a[2]),c=t.searchParams.get(`path`)??`/`;return!i||!s||!r(c)?null:{kind:`plugin`,pluginId:i,...o?{marketplace:o}:{},toolName:s,deepLink:c}}catch{return null}}function a(e){let t=new URLSearchParams({tool:e.toolName,path:e.deepLink});return e.kind===`server`?t.set(`server`,e.serverName):(t.set(`plugin`,e.pluginId),e.marketplace&&t.set(`marketplace`,e.marketplace)),`?${t}`}function o(e){let t=new URLSearchParams(e),n=t.get(`server`),i=t.get(`plugin`),a=t.get(`marketplace`),o=t.get(`tool`),s=t.get(`path`)??`/`;return!o||!r(s)||!!n==!!i?null:n?a?null:{kind:`server`,serverName:n,toolName:o,deepLink:s}:i?{kind:`plugin`,pluginId:i,...a?{marketplace:a}:{},toolName:o,deepLink:s}:null}function s(e,t,n=!1){let r=e.filter(e=>(t.kind===`server`?e.serverName===t.serverName:e.pluginId===t.pluginId&&(e.marketplace??void 0)===t.marketplace)&&(e.entrypoints.some(e=>e.toolName===t.toolName&&(e.entrypoint.type===`global`||n&&e.entrypoint.type===`settings`))||n&&e.settings?.readTool===t.toolName));return r.length===1?r[0]:void 0}function c(){return(c=e((()=>{t()})))()}export{s as a,i,o as n,a as r,c as t};