UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.93 kB
import{i as parseConcreteConfigPathTokens}from"./dot-path-B1bYAWM5.mjs";import{i as getPluginRegistryForContext}from"./gateway-request-scope-7deHmsb_.mjs";import{t as resolveWebSearchInstallCatalogEntries}from"./web-search-install-catalog-BQcySORe.mjs";import{n as resolveBundledExplicitWebFetchProvidersFromPublicArtifacts,r as resolveBundledExplicitWebSearchProvidersFromPublicArtifacts}from"./web-provider-public-artifacts.explicit-CAtgEiZm.mjs"; //!src/plugins/credential-descriptors.ts function projectPluginCredentialDescriptors(e,t){const n=/* @__PURE__ */ new Map;for(const r of t){if(!r.credentialPath||!r.credentialLabel)continue;let t;try{t=parseConcreteConfigPathTokens(r.credentialPath)}catch{continue}if(t.length<5||t.length>32||t[0]!==`plugins`||t[1]!==`entries`||t[2]!==e||t[3]!==`config`)continue;const i=JSON.stringify(t);if(n.has(i))continue;const a=r.signupUrl&&URL.parse(r.signupUrl)?.protocol;const o=a===`https:`||a===`http:`?r.signupUrl:void 0;n.set(i,{path:t,label:r.credentialLabel,envVars:[...r.envVars],...r.placeholder?{placeholder:r.placeholder}:{},...o?{signupUrl:o}:{},...r.requiresCredential!==void 0?{requiresCredential:r.requiresCredential}:{}})}return[...n.values()]}function resolvePluginCredentialDescriptors(e){const t=getPluginRegistryForContext();const n=[...t?.webSearchProviders??[],...t?.webFetchProviders??[]].filter(t=>t.pluginId===e.id).map(e=>e.provider);if(e.origin===`bundled`){const t={onlyPluginIds:[e.id]};if(e.contracts?.webSearchProviders?.length)n.push(...resolveBundledExplicitWebSearchProvidersFromPublicArtifacts(t)??[]);if(e.contracts?.webFetchProviders?.length)n.push(...resolveBundledExplicitWebFetchProvidersFromPublicArtifacts(t)??[])}else if(e.trustedOfficialInstall)n.push(...resolveWebSearchInstallCatalogEntries().filter(t=>t.pluginId===e.id).map(e=>e.provider));return projectPluginCredentialDescriptors(e.id,n)}export{resolvePluginCredentialDescriptors as t};