()
| 2236 | ); |
| 2237 | |
| 2238 | const integrationsList = (): Effect.Effect<readonly Integration[], StorageFailure> => |
| 2239 | Effect.gen(function* () { |
| 2240 | const rows = yield* core.findMany("integration", {}); |
| 2241 | const staticIntegrationList = staticIntegrations().map(staticDeclToIntegration); |
| 2242 | const dbIntegrations = rows.map((row) => |
| 2243 | rowToIntegration(row, describeAuthMethodsForRow(row), describeDisplayForRow(row)), |
| 2244 | ); |
| 2245 | // A scoped toolkit must not advertise providers it grants no tools from |
| 2246 | // (mirrors `connectionsList`). Static integrations are system namespaces, not |
| 2247 | // user providers, so they stay; DB-backed integrations are filtered to |
| 2248 | // those that contribute at least one visible tool under the active policy. |
| 2249 | if (!activeToolPolicyProvider) return [...staticIntegrationList, ...dbIntegrations]; |
| 2250 | const visibleTools = yield* toolsList({ includeAnnotations: false }); |
| 2251 | const visibleIntegrationSlugs = new Set( |
| 2252 | visibleTools.filter((tool) => !tool.static).map((tool) => String(tool.integration)), |
| 2253 | ); |
| 2254 | return [ |
| 2255 | ...staticIntegrationList, |
| 2256 | ...dbIntegrations.filter((integration) => |
| 2257 | visibleIntegrationSlugs.has(String(integration.slug)), |
| 2258 | ), |
| 2259 | ]; |
| 2260 | }); |
| 2261 | |
| 2262 | const integrationsGet = ( |
| 2263 | slug: IntegrationSlug, |
no test coverage detected