()
| 30 | * version drift between what the VFS shows and what is loadable. |
| 31 | */ |
| 32 | export function getExposedIntegrationTools(): ExposedIntegrationTool[] { |
| 33 | if (cached) return cached |
| 34 | |
| 35 | // Map the tool ids each visible block exposes (both the raw id and its |
| 36 | // version-stripped base name) to that block's service directory. |
| 37 | const toolToService = new Map<string, string>() |
| 38 | for (const block of getAllBlocks()) { |
| 39 | if (block.hideFromToolbar) continue |
| 40 | if (!block.tools?.access) continue |
| 41 | const service = stripVersionSuffix(block.type) |
| 42 | for (const toolId of block.tools.access) { |
| 43 | toolToService.set(toolId, service) |
| 44 | toolToService.set(stripVersionSuffix(toolId), service) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | const exposed: ExposedIntegrationTool[] = [] |
| 49 | const seen = new Set<string>() |
| 50 | for (const [toolId, config] of Object.entries(getLatestVersionTools(toolRegistry))) { |
| 51 | const baseName = stripVersionSuffix(toolId) |
| 52 | const service = toolToService.get(toolId) ?? toolToService.get(baseName) |
| 53 | if (!service) continue |
| 54 | if (seen.has(baseName)) continue |
| 55 | seen.add(baseName) |
| 56 | const prefix = `${service}_` |
| 57 | const operation = baseName.startsWith(prefix) ? baseName.slice(prefix.length) : baseName |
| 58 | exposed.push({ toolId, config, service, operation }) |
| 59 | } |
| 60 | |
| 61 | cached = exposed |
| 62 | return exposed |
| 63 | } |
| 64 | |
| 65 | /** Test-only: clears the memoized set so registry changes are picked up. */ |
| 66 | export function resetExposedIntegrationToolsCache(): void { |
no test coverage detected