diff --git a/apps/sim/lib/copilot/vfs/workspace-vfs.ts b/apps/sim/lib/copilot/vfs/workspace-vfs.ts index b1c021405d..a3f58d3838 100644 --- a/apps/sim/lib/copilot/vfs/workspace-vfs.ts +++ b/apps/sim/lib/copilot/vfs/workspace-vfs.ts @@ -118,6 +118,10 @@ function getStaticComponentFiles(): Map { const latestTools = getLatestVersionTools(toolRegistry) let integrationCount = 0 + + const oauthServices = new Map() + const apiKeyServices = new Map() + for (const [toolId, tool] of Object.entries(latestTools)) { const baseName = stripVersionSuffix(toolId) const service = toolToService.get(toolId) ?? toolToService.get(baseName) @@ -132,8 +136,39 @@ function getStaticComponentFiles(): Map { const path = `components/integrations/${service}/${operation}.json` files.set(path, serializeIntegrationSchema(tool)) integrationCount++ + + if (tool.oauth?.required) { + const existing = oauthServices.get(service) + if (existing) { + existing.operations.push(operation) + } else { + oauthServices.set(service, { provider: tool.oauth.provider, operations: [operation] }) + } + } else if (tool.hosting?.apiKeyParam) { + const existing = apiKeyServices.get(service) + if (existing) { + if (!existing.params.includes(tool.hosting.apiKeyParam)) { + existing.params.push(tool.hosting.apiKeyParam) + } + existing.operations.push(operation) + } else { + apiKeyServices.set(service, { + params: [tool.hosting.apiKeyParam], + operations: [operation], + }) + } + } } + files.set( + 'environment/oauth-integrations.json', + JSON.stringify(Object.fromEntries(oauthServices), null, 2) + ) + files.set( + 'environment/api-key-integrations.json', + JSON.stringify(Object.fromEntries(apiKeyServices), null, 2) + ) + files.set( 'components/blocks/loop.json', JSON.stringify(