MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / connectionsList

Function connectionsList

packages/core/sdk/src/executor.ts:4739–4773  ·  view source on GitHub ↗
(filter?: {
      readonly integration?: IntegrationSlug;
      readonly owner?: Owner;
    })

Source from the content-addressed store, hash-verified

4737 });
4738
4739 const connectionsList = (filter?: {
4740 readonly integration?: IntegrationSlug;
4741 readonly owner?: Owner;
4742 }): Effect.Effect<readonly Connection[], StorageFailure> =>
4743 Effect.gen(function* () {
4744 const rows = yield* core.findMany("connection", {
4745 where: (b: AnyCb) =>
4746 b.and(
4747 filter?.integration === undefined
4748 ? true
4749 : b("integration", "=", String(filter.integration)),
4750 filter?.owner === undefined ? true : b("owner", "=", filter.owner),
4751 ),
4752 });
4753 // Same catalog gate as `toolsList`: a connection whose integration was
4754 // removed is an orphan, and offering it (in the accounts list, or to
4755 // an agent as a reconnect target) leads into flows that cannot mint.
4756 const catalogSlugs = yield* listCatalogSlugs();
4757 const connections = rows
4758 .filter((row) => catalogSlugs.has(String(row.integration)))
4759 .map(rowToConnection);
4760 if (!activeToolPolicyProvider) return connections;
4761
4762 const visibleTools = yield* toolsList({ includeAnnotations: false });
4763 const visibleConnectionKeys = new Set(
4764 visibleTools
4765 .filter((tool) => !tool.static)
4766 .map((tool) => `${tool.owner}:${tool.integration}:${tool.connection}`),
4767 );
4768 return connections.filter((connection) =>
4769 visibleConnectionKeys.has(
4770 `${connection.owner}:${connection.integration}:${connection.name}`,
4771 ),
4772 );
4773 });
4774
4775 const connectionsGet = (ref: ConnectionRef): Effect.Effect<Connection | null, StorageFailure> =>
4776 findConnectionRow(ref).pipe(Effect.map((row) => (row ? rowToConnection(row) : null)));

Callers 1

createExecutorFunction · 0.85

Calls 2

listCatalogSlugsFunction · 0.85
toolsListFunction · 0.70

Tested by

no test coverage detected