( executor: Executor, invokeOptions: InvokeOptions, toolDiscoveryProvider: ToolDiscoveryProvider, onConnectedToolCall?: (path: string) => void, )
| 340 | }; |
| 341 | |
| 342 | const makeFullInvoker = ( |
| 343 | executor: Executor, |
| 344 | invokeOptions: InvokeOptions, |
| 345 | toolDiscoveryProvider: ToolDiscoveryProvider, |
| 346 | onConnectedToolCall?: (path: string) => void, |
| 347 | ): SandboxToolInvoker => { |
| 348 | const base = makeExecutorToolInvoker(executor, { invokeOptions, onConnectedToolCall }); |
| 349 | return { |
| 350 | invoke: ({ path, args }) => { |
| 351 | if (path === "search") { |
| 352 | if (!isRecord(args)) { |
| 353 | return Effect.fail( |
| 354 | new ExecutionToolError({ |
| 355 | message: |
| 356 | "tools.search expects an object: { query?: string; namespace?: string; limit?: number; offset?: number }", |
| 357 | }), |
| 358 | ); |
| 359 | } |
| 360 | |
| 361 | if (args.query !== undefined && typeof args.query !== "string") { |
| 362 | return Effect.fail( |
| 363 | new ExecutionToolError({ |
| 364 | message: "tools.search query must be a string when provided", |
| 365 | }), |
| 366 | ); |
| 367 | } |
| 368 | |
| 369 | if (args.namespace !== undefined && typeof args.namespace !== "string") { |
| 370 | return Effect.fail( |
| 371 | new ExecutionToolError({ |
| 372 | message: "tools.search namespace must be a string when provided", |
| 373 | }), |
| 374 | ); |
| 375 | } |
| 376 | |
| 377 | const limit = readOptionalLimit(args.limit, "tools.search"); |
| 378 | if (Predicate.isTagged(limit, "ExecutionToolError")) { |
| 379 | return Effect.fail(limit); |
| 380 | } |
| 381 | |
| 382 | const offset = readOptionalOffset(args.offset, "tools.search"); |
| 383 | if (Predicate.isTagged(offset, "ExecutionToolError")) { |
| 384 | return Effect.fail(offset); |
| 385 | } |
| 386 | |
| 387 | return toolDiscoveryProvider |
| 388 | .searchTools({ |
| 389 | executor, |
| 390 | query: args.query ?? "", |
| 391 | limit, |
| 392 | namespace: args.namespace, |
| 393 | offset, |
| 394 | }) |
| 395 | .pipe( |
| 396 | Effect.withSpan("mcp.tool.dispatch", { |
| 397 | attributes: { |
| 398 | "mcp.tool.name": path, |
| 399 | "executor.tool.builtin": true, |
no test coverage detected