( executor: Executor, invokeOptions: InvokeOptions, toolDiscoveryProvider: ToolDiscoveryProvider, )
| 215 | }; |
| 216 | |
| 217 | const makeFullInvoker = ( |
| 218 | executor: Executor, |
| 219 | invokeOptions: InvokeOptions, |
| 220 | toolDiscoveryProvider: ToolDiscoveryProvider, |
| 221 | ): SandboxToolInvoker => { |
| 222 | const base = makeExecutorToolInvoker(executor, { invokeOptions }); |
| 223 | return { |
| 224 | invoke: ({ path, args }) => { |
| 225 | if (path === "search") { |
| 226 | if (!isRecord(args)) { |
| 227 | return Effect.fail( |
| 228 | new ExecutionToolError({ |
| 229 | message: |
| 230 | "tools.search expects an object: { query?: string; namespace?: string; limit?: number; offset?: number }", |
| 231 | }), |
| 232 | ); |
| 233 | } |
| 234 | |
| 235 | if (args.query !== undefined && typeof args.query !== "string") { |
| 236 | return Effect.fail( |
| 237 | new ExecutionToolError({ |
| 238 | message: "tools.search query must be a string when provided", |
| 239 | }), |
| 240 | ); |
| 241 | } |
| 242 | |
| 243 | if (args.namespace !== undefined && typeof args.namespace !== "string") { |
| 244 | return Effect.fail( |
| 245 | new ExecutionToolError({ |
| 246 | message: "tools.search namespace must be a string when provided", |
| 247 | }), |
| 248 | ); |
| 249 | } |
| 250 | |
| 251 | const limit = readOptionalLimit(args.limit, "tools.search"); |
| 252 | if (Predicate.isTagged(limit, "ExecutionToolError")) { |
| 253 | return Effect.fail(limit); |
| 254 | } |
| 255 | |
| 256 | const offset = readOptionalOffset(args.offset, "tools.search"); |
| 257 | if (Predicate.isTagged(offset, "ExecutionToolError")) { |
| 258 | return Effect.fail(offset); |
| 259 | } |
| 260 | |
| 261 | return toolDiscoveryProvider |
| 262 | .searchTools({ |
| 263 | executor, |
| 264 | query: args.query ?? "", |
| 265 | limit, |
| 266 | namespace: args.namespace, |
| 267 | offset, |
| 268 | }) |
| 269 | .pipe( |
| 270 | Effect.withSpan("mcp.tool.dispatch", { |
| 271 | attributes: { "mcp.tool.name": path, "executor.tool.builtin": true }, |
| 272 | }), |
| 273 | ); |
| 274 | } |
no test coverage detected