refactor(tool): convert bash to defineEffect with ChildProcessSpawner (#21895)

This commit is contained in:
Kit Langton
2026-04-10 13:26:31 -04:00
committed by GitHub
parent 180ded6a27
commit f7514d9eca
6 changed files with 291 additions and 260 deletions
+6 -1
View File
@@ -31,6 +31,8 @@ import path from "path"
import { pathToFileURL } from "url"
import { Effect, Layer, ServiceMap } from "effect"
import { FetchHttpClient, HttpClient } from "effect/unstable/http"
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner"
import * as CrossSpawnSpawner from "@/effect/cross-spawn-spawner"
import { InstanceState } from "@/effect/instance-state"
import { makeRuntime } from "@/effect/run-service"
import { Env } from "../env"
@@ -86,6 +88,7 @@ export namespace ToolRegistry {
| Instruction.Service
| AppFileSystem.Service
| HttpClient.HttpClient
| ChildProcessSpawner
> = Layer.effect(
Service,
Effect.gen(function* () {
@@ -102,6 +105,7 @@ export namespace ToolRegistry {
const plan = yield* PlanExitTool
const webfetch = yield* WebFetchTool
const websearch = yield* WebSearchTool
const bash = yield* BashTool
const codesearch = yield* CodeSearchTool
const state = yield* InstanceState.make<State>(
@@ -161,7 +165,7 @@ export namespace ToolRegistry {
const tool = yield* Effect.all({
invalid: Tool.init(InvalidTool),
bash: Tool.init(BashTool),
bash: Tool.init(bash),
read: Tool.init(read),
glob: Tool.init(GlobTool),
grep: Tool.init(GrepTool),
@@ -315,6 +319,7 @@ export namespace ToolRegistry {
Layer.provide(Instruction.defaultLayer),
Layer.provide(AppFileSystem.defaultLayer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(CrossSpawnSpawner.defaultLayer),
),
)