refactor(tool): convert webfetch tool internals to Effect (#21809)

This commit is contained in:
Kit Langton
2026-04-10 10:50:13 -04:00
committed by GitHub
parent 42206da1f8
commit e83404367c
6 changed files with 180 additions and 163 deletions

View File

@@ -1,5 +1,7 @@
import { describe, test, expect } from "bun:test"
import path from "path"
import { Effect } from "effect"
import { FetchHttpClient } from "effect/unstable/http"
import { Instance } from "../../src/project/instance"
import { WebFetchTool } from "../../src/tool/webfetch"
import { SessionID, MessageID } from "../../src/session/schema"
@@ -30,7 +32,11 @@ describe("memory: abort controller leak", () => {
await Instance.provide({
directory: projectRoot,
fn: async () => {
const tool = await WebFetchTool.init()
const tool = await WebFetchTool.pipe(
Effect.flatMap((info) => Effect.promise(() => info.init())),
Effect.provide(FetchHttpClient.layer),
Effect.runPromise,
)
// Warm up
await tool.execute({ url: "https://example.com", format: "text" }, ctx).catch(() => {})