refactor(plugin): simplify websearch effects (#43943)

This commit is contained in:
Kit Langton
2026-08-21 14:23:10 -04:00
committed by GitHub
parent 0eaa04718c
commit 2a83911c7e
2 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -45,9 +45,9 @@ export const call = <F extends Schema.Struct.Fields, R extends Schema.Struct.Fie
params: Schema.Struct({ name: Schema.String, arguments: schema.input }),
}),
)({
jsonrpc: "2.0" as const,
id: 1 as const,
method: "tools/call" as const,
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: { name: tool, arguments: value },
}),
)
+9 -9
View File
@@ -63,15 +63,15 @@ export const Plugin = define<HttpClient.HttpClient | Scope.Scope>({
max_results: 8,
}),
)
const response = yield* Effect.gen(function* () {
const httpResponse = yield* HttpClient.filterStatusOk(http).execute(request)
return yield* HttpClientResponse.schemaBodyJson(SearchResponse)(httpResponse)
}).pipe(
Effect.timeoutOrElse({
duration: Duration.seconds(25),
orElse: () => Effect.fail(new Error("Tavily web search request timed out")),
}),
)
const response = yield* HttpClient.filterStatusOk(http)
.execute(request)
.pipe(
Effect.flatMap(HttpClientResponse.schemaBodyJson(SearchResponse)),
Effect.timeoutOrElse({
duration: Duration.seconds(25),
orElse: () => Effect.fail(new Error("Tavily web search request timed out")),
}),
)
return response.results.map((item) => ({
url: item.url,
title: item.title,