(filter?: ToolListFilter)
| 5091 | }); |
| 5092 | |
| 5093 | const toolsList = (filter?: ToolListFilter): Effect.Effect<readonly Tool[], StorageFailure> => |
| 5094 | Effect.gen(function* () { |
| 5095 | if (toolsSyncGraceMs === null) { |
| 5096 | yield* syncStaleConnectionTools; |
| 5097 | } else { |
| 5098 | yield* awaitStaleSyncWithinGrace(toolsSyncGraceMs); |
| 5099 | } |
| 5100 | // Projected: the list surface is metadata (address, description, |
| 5101 | // annotations) — loading every tool's input/output schema JSON made |
| 5102 | // an unbounded list scale with schema bytes, not tool count. |
| 5103 | const rows = yield* core.findMany("tool", { |
| 5104 | where: (b: AnyCb) => |
| 5105 | b.and( |
| 5106 | filter?.integration === undefined |
| 5107 | ? true |
| 5108 | : b("integration", "=", String(filter.integration)), |
| 5109 | filter?.owner === undefined ? true : b("owner", "=", filter.owner), |
| 5110 | filter?.connection === undefined |
| 5111 | ? true |
| 5112 | : b("connection", "=", String(filter.connection)), |
| 5113 | ), |
| 5114 | select: TOOL_INVOCATION_COLUMNS, |
| 5115 | }); |
| 5116 | const includeBlocked = filter?.includeBlocked ?? false; |
| 5117 | const policyRules = yield* listActivePolicyRuleSet(); |
| 5118 | const tools: Tool[] = []; |
| 5119 | for (const row of rows) { |
| 5120 | const tool = rowToTool(row); |
| 5121 | if (!matchesToolFilter(tool, filter)) continue; |
| 5122 | if (!includeBlocked) { |
| 5123 | const effective = yield* resolvePolicyFromRuleSet( |
| 5124 | normalizedPolicyId(tool), |
| 5125 | policyRules, |
| 5126 | tool.annotations?.requiresApproval, |
| 5127 | ); |
| 5128 | if (effective.action === "block") continue; |
| 5129 | } |
| 5130 | tools.push(tool); |
| 5131 | } |
| 5132 | for (const entry of staticTools.values()) { |
| 5133 | const tool = staticToolToTool(entry); |
| 5134 | if (!matchesToolFilter(tool, filter)) continue; |
| 5135 | if (!includeBlocked) { |
| 5136 | const effective = yield* resolvePolicyFromRuleSet( |
| 5137 | normalizedPolicyId(tool), |
| 5138 | policyRules, |
| 5139 | tool.annotations?.requiresApproval, |
| 5140 | ); |
| 5141 | if (effective.action === "block") continue; |
| 5142 | } |
| 5143 | tools.push(tool); |
| 5144 | } |
| 5145 | return tools; |
| 5146 | }); |
| 5147 | |
| 5148 | const toolSchema = ( |
| 5149 | address: ToolAddress, |
no test coverage detected