(filter?: ToolListFilter)
| 5563 | }); |
| 5564 | |
| 5565 | const toolsList = (filter?: ToolListFilter): Effect.Effect<readonly Tool[], StorageFailure> => |
| 5566 | Effect.gen(function* () { |
| 5567 | if (toolsSyncGraceMs === null) { |
| 5568 | yield* syncStaleConnectionTools; |
| 5569 | } else { |
| 5570 | yield* awaitStaleSyncWithinGrace(toolsSyncGraceMs); |
| 5571 | } |
| 5572 | // Projected: the list surface is metadata (address, description, |
| 5573 | // annotations) — loading every tool's input/output schema JSON made |
| 5574 | // an unbounded list scale with schema bytes, not tool count. |
| 5575 | const rows = yield* core.findMany("tool", { |
| 5576 | where: (b: AnyCb) => |
| 5577 | b.and( |
| 5578 | filter?.integration === undefined |
| 5579 | ? true |
| 5580 | : b("integration", "=", String(filter.integration)), |
| 5581 | filter?.owner === undefined ? true : b("owner", "=", filter.owner), |
| 5582 | filter?.connection === undefined |
| 5583 | ? true |
| 5584 | : b("connection", "=", String(filter.connection)), |
| 5585 | ), |
| 5586 | select: TOOL_INVOCATION_COLUMNS, |
| 5587 | }); |
| 5588 | const includeBlocked = filter?.includeBlocked ?? false; |
| 5589 | const policyRules = yield* listActivePolicyRuleSet(); |
| 5590 | const tools: Tool[] = []; |
| 5591 | for (const row of rows) { |
| 5592 | const tool = rowToTool(row); |
| 5593 | if (!matchesToolFilter(tool, filter)) continue; |
| 5594 | if (!includeBlocked) { |
| 5595 | const effective = yield* resolvePolicyFromRuleSet( |
| 5596 | normalizedPolicyId(tool), |
| 5597 | policyRules, |
| 5598 | tool.annotations?.requiresApproval, |
| 5599 | ); |
| 5600 | if (effective.action === "block") continue; |
| 5601 | } |
| 5602 | tools.push(tool); |
| 5603 | } |
| 5604 | for (const entry of staticTools.values()) { |
| 5605 | const tool = staticToolToTool(entry); |
| 5606 | if (!matchesToolFilter(tool, filter)) continue; |
| 5607 | if (!includeBlocked) { |
| 5608 | const effective = yield* resolvePolicyFromRuleSet( |
| 5609 | normalizedPolicyId(tool), |
| 5610 | policyRules, |
| 5611 | tool.annotations?.requiresApproval, |
| 5612 | ); |
| 5613 | if (effective.action === "block") continue; |
| 5614 | } |
| 5615 | tools.push(tool); |
| 5616 | } |
| 5617 | return tools; |
| 5618 | }); |
| 5619 | |
| 5620 | const toolSchema = ( |
| 5621 | address: ToolAddress, |
no test coverage detected