(filter?: ToolListFilter)
| 3235 | }); |
| 3236 | |
| 3237 | const toolsList = (filter?: ToolListFilter): Effect.Effect<readonly Tool[], StorageFailure> => |
| 3238 | Effect.gen(function* () { |
| 3239 | yield* syncStaleConnectionTools; |
| 3240 | // Projected: the list surface is metadata (address, description, |
| 3241 | // annotations) — loading every tool's input/output schema JSON made |
| 3242 | // an unbounded list scale with schema bytes, not tool count. |
| 3243 | const rows = yield* core.findMany("tool", { |
| 3244 | where: (b: AnyCb) => |
| 3245 | b.and( |
| 3246 | filter?.integration === undefined |
| 3247 | ? true |
| 3248 | : b("integration", "=", String(filter.integration)), |
| 3249 | filter?.owner === undefined ? true : b("owner", "=", filter.owner), |
| 3250 | filter?.connection === undefined |
| 3251 | ? true |
| 3252 | : b("connection", "=", String(filter.connection)), |
| 3253 | ), |
| 3254 | select: TOOL_INVOCATION_COLUMNS, |
| 3255 | }); |
| 3256 | const includeBlocked = filter?.includeBlocked ?? false; |
| 3257 | const policyRules = yield* listActivePolicyRuleSet(); |
| 3258 | const tools: Tool[] = []; |
| 3259 | for (const row of rows) { |
| 3260 | const tool = rowToTool(row); |
| 3261 | if (!matchesToolFilter(tool, filter)) continue; |
| 3262 | if (!includeBlocked) { |
| 3263 | const effective = yield* resolvePolicyFromRuleSet( |
| 3264 | normalizedPolicyId(tool), |
| 3265 | policyRules, |
| 3266 | tool.annotations?.requiresApproval, |
| 3267 | ); |
| 3268 | if (effective.action === "block") continue; |
| 3269 | } |
| 3270 | tools.push(tool); |
| 3271 | } |
| 3272 | for (const entry of staticTools.values()) { |
| 3273 | const tool = staticToolToTool(entry); |
| 3274 | if (!matchesToolFilter(tool, filter)) continue; |
| 3275 | if (!includeBlocked) { |
| 3276 | const effective = yield* resolvePolicyFromRuleSet( |
| 3277 | normalizedPolicyId(tool), |
| 3278 | policyRules, |
| 3279 | tool.annotations?.requiresApproval, |
| 3280 | ); |
| 3281 | if (effective.action === "block") continue; |
| 3282 | } |
| 3283 | tools.push(tool); |
| 3284 | } |
| 3285 | return tools; |
| 3286 | }); |
| 3287 | |
| 3288 | const toolSchema = ( |
| 3289 | address: ToolAddress, |
no test coverage detected