| @@ -10,7 +10,7 @@ import { · 9 unmodified lines |
| 10 | 10 | tool, |
| 11 | 11 | } from "@executor/sdk"; |
| 12 | 12 | import { createExecutionEngine } from "./engine"; |
| 13 | | −import { describeTool, discoverTools } from "./tool-invoker"; |
| 13 | +import { describeTool, searchTools } from "./tool-invoker"; |
| 14 | 14 | |
| 15 | 15 | const EmptyInput = Schema.Struct({}); |
| 16 | 16 | const RepoInput = Schema.Struct({ |
| @@ -95,16 +95,16 @@ describe("tool discovery", () => { · 78 unmodified lines |
| 95 | 95 | Effect.gen(function* () { |
| 96 | 96 | const executor = yield* makeSearchExecutor(); |
| 97 | 97 | |
| 98 | | − const githubMatches = yield* discoverTools(executor, "github issues", 5); |
| 98 | + const githubMatches = yield* searchTools(executor, "github issues", 5); |
| 99 | 99 | expect(githubMatches.map((match) => match.path)).toEqual([ |
| 100 | 100 | "github.listRepositoryIssues", |
| 101 | 101 | ]); |
| 102 | 102 | expect(githubMatches[0]?.score ?? 0).toBeGreaterThan(0); |
| 103 | 103 | |
| 104 | | − const repoMatches = yield* discoverTools(executor, "repo details", 5); |
| 104 | + const repoMatches = yield* searchTools(executor, "repo details", 5); |
| 105 | 105 | expect(repoMatches[0]?.path).toBe("github.getRepositoryDetails"); |
| 106 | 106 | |
| 107 | | − const crmMatches = yield* discoverTools(executor, "crm create contact", 5); |
| 107 | + const crmMatches = yield* searchTools(executor, "crm create contact", 5); |
| 108 | 108 | expect(crmMatches[0]?.path).toBe("crm.createContact"); |
| 109 | 109 | expect(crmMatches[0]?.score ?? 0).toBeGreaterThan(crmMatches[1]?.score ?? 0); |
| 110 | 110 | }), |
| @@ -113,7 +113,7 @@ describe("tool discovery", () => { · 2 unmodified lines |
| 113 | 113 | it.effect("returns no matches for empty queries instead of listing arbitrary tools", () => |
| 114 | 114 | Effect.gen(function* () { |
| 115 | 115 | const executor = yield* makeSearchExecutor(); |
| 116 | | − const matches = yield* discoverTools(executor, "", 5); |
| 116 | + const matches = yield* searchTools(executor, "", 5); |
| 117 | 117 | expect(matches).toEqual([]); |
| 118 | 118 | }), |
| 119 | 119 | ); |
| @@ -122,14 +122,14 @@ describe("tool discovery", () => { · 2 unmodified lines |
| 122 | 122 | Effect.gen(function* () { |
| 123 | 123 | const executor = yield* makeSearchExecutor(); |
| 124 | 124 | |
| 125 | | − const githubOnly = yield* discoverTools(executor, "list", 5, { |
| 125 | + const githubOnly = yield* searchTools(executor, "list", 5, { |
| 126 | 126 | namespace: "github", |
| 127 | 127 | }); |
| 128 | 128 | expect(githubOnly.map((match) => match.path)).toEqual([ |
| 129 | 129 | "github.listRepositoryIssues", |
| 130 | 130 | ]); |
| 131 | 131 | |
| 132 | | − const crmOnly = yield* discoverTools(executor, "list", 5, { |
| 132 | + const crmOnly = yield* searchTools(executor, "list", 5, { |
| 133 | 133 | namespace: "crm", |
| 134 | 134 | }); |
| 135 | 135 | expect(crmOnly.map((match) => match.path)).toEqual([ |
| @@ -138,7 +138,7 @@ describe("tool discovery", () => { · 2 unmodified lines |
| 138 | 138 | |
| 139 | 139 | const sandboxResult = yield* Effect.promise(() => |
| 140 | 140 | createExecutionEngine({ executor }).execute( |
| 141 | | − 'return await tools.discover({ namespace: "crm", query: "create contact", limit: 5 });', |
| 141 | + 'return await tools.search({ namespace: "crm", query: "create contact", limit: 5 });', |
| 142 | 142 | { onElicitation: acceptAll }, |
| 143 | 143 | ), |
| 144 | 144 | ); |
| @@ -169,7 +169,7 @@ describe("tool discovery", () => { · 24 unmodified lines |
| 169 | 169 | |
| 170 | 170 | const searched = yield* Effect.promise(() => |
| 171 | 171 | createExecutionEngine({ executor }).execute( |
| 172 | | − 'return await tools.executor.tools.search({ query: "list contacts", namespace: "crm", limit: 5 });', |
| 172 | + 'return await tools.search({ query: "list contacts", namespace: "crm", limit: 5 });', |
| 173 | 173 | { onElicitation: acceptAll }, |
| 174 | 174 | ), |
| 175 | 175 | ); |
| @@ -219,7 +219,7 @@ describe("tool discovery", () => { · 43 unmodified lines |
| 219 | 219 | engine.execute( |
| 220 | 220 | [ |
| 221 | 221 | "try {", |
| 222 | | − " await tools.discover(\"github issues\");", |
| 222 | + " await tools.search(\"github issues\");", |
| 223 | 223 | " return \"unexpected\";", |
| 224 | 224 | "} catch (error) {", |
| 225 | 225 | " return error instanceof Error ? error.message : String(error);", |
| @@ -230,12 +230,12 @@ describe("tool discovery", () => { · 4 unmodified lines |
| 230 | 230 | ); |
| 231 | 231 | expect(invalid.error).toBeUndefined(); |
| 232 | 232 | expect(String(invalid.result)).toContain( |
| 233 | | − "tools.discover expects an object: { query?: string; namespace?: string; limit?: number }", |
| 233 | + "tools.search expects an object: { query?: string; namespace?: string; limit?: number }", |
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | 236 | const emptyQuery = yield* Effect.promise(() => |
| 237 | 237 | engine.execute( |
| 238 | | − "return await tools.discover({ query: \"\", limit: 5 });", |
| 238 | + "return await tools.search({ query: \"\", limit: 5 });", |
| 239 | 239 | { onElicitation: acceptAll }, |
| 240 | 240 | ), |
| 241 | 241 | ); |
| @@ -260,15 +260,15 @@ describe("tool discovery", () => { · 18 unmodified lines |
| 260 | 260 | "tools.describe.tool no longer accepts includeSchemas", |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | | − const invalidExecutorSearch = yield* Effect.promise(() => |
| 263 | + const invalidSearch = yield* Effect.promise(() => |
| 264 | 264 | engine.execute( |
| 265 | | − 'try { return await tools.executor.tools.search("crm"); } catch (error) { return error instanceof Error ? error.message : String(error); }', |
| 265 | + 'try { return await tools.search("crm"); } catch (error) { return error instanceof Error ? error.message : String(error); }', |
| 266 | 266 | { onElicitation: acceptAll }, |
| 267 | 267 | ), |
| 268 | 268 | ); |
| 269 | | − expect(invalidExecutorSearch.error).toBeUndefined(); |
| 270 | | − expect(String(invalidExecutorSearch.result)).toContain( |
| 271 | | − "tools.executor.tools.search expects an object", |
| 269 | + expect(invalidSearch.error).toBeUndefined(); |
| 270 | + expect(String(invalidSearch.result)).toContain( |
| 271 | + "tools.search expects an object", |
| 272 | 272 | ); |
| 273 | 273 | }), |
| 274 | 274 | ); |