(filter?: ToolListFilter)
| 3136 | }); |
| 3137 | |
| 3138 | const toolsList = (filter?: ToolListFilter): Effect.Effect<readonly Tool[], StorageFailure> => |
| 3139 | Effect.gen(function* () { |
| 3140 | yield* syncStaleConnectionTools; |
| 3141 | // Projected: the list surface is metadata (address, description, |
| 3142 | // annotations) — loading every tool's input/output schema JSON made |
| 3143 | // an unbounded list scale with schema bytes, not tool count. |
| 3144 | const rows = yield* core.findMany("tool", { |
| 3145 | where: (b: AnyCb) => |
| 3146 | b.and( |
| 3147 | filter?.integration === undefined |
| 3148 | ? true |
| 3149 | : b("integration", "=", String(filter.integration)), |
| 3150 | filter?.owner === undefined ? true : b("owner", "=", filter.owner), |
| 3151 | filter?.connection === undefined |
| 3152 | ? true |
| 3153 | : b("connection", "=", String(filter.connection)), |
| 3154 | ), |
| 3155 | select: TOOL_INVOCATION_COLUMNS, |
| 3156 | }); |
| 3157 | const includeBlocked = filter?.includeBlocked ?? false; |
| 3158 | const policyRules = yield* listActivePolicyRuleSet(); |
| 3159 | const tools: Tool[] = []; |
| 3160 | for (const row of rows) { |
| 3161 | const tool = rowToTool(row); |
| 3162 | if (!matchesToolFilter(tool, filter)) continue; |
| 3163 | if (!includeBlocked) { |
| 3164 | const effective = yield* resolvePolicyFromRuleSet( |
| 3165 | normalizedPolicyId(tool), |
| 3166 | policyRules, |
| 3167 | tool.annotations?.requiresApproval, |
| 3168 | ); |
| 3169 | if (effective.action === "block") continue; |
| 3170 | } |
| 3171 | tools.push(tool); |
| 3172 | } |
| 3173 | for (const entry of staticTools.values()) { |
| 3174 | const tool = staticToolToTool(entry); |
| 3175 | if (!matchesToolFilter(tool, filter)) continue; |
| 3176 | if (!includeBlocked) { |
| 3177 | const effective = yield* resolvePolicyFromRuleSet( |
| 3178 | normalizedPolicyId(tool), |
| 3179 | policyRules, |
| 3180 | tool.annotations?.requiresApproval, |
| 3181 | ); |
| 3182 | if (effective.action === "block") continue; |
| 3183 | } |
| 3184 | tools.push(tool); |
| 3185 | } |
| 3186 | return tools; |
| 3187 | }); |
| 3188 | |
| 3189 | const toolSchema = ( |
| 3190 | address: ToolAddress, |
no test coverage detected