Compare commits

...

2 Commits

Author SHA1 Message Date
Kit Langton 7bdb4e6280 test(webfetch): keep tool execution in scope
Execute the webfetch tool inside the same provided Effect scope used for initialization so the HTTP client layer stays alive for the assertions instead of interrupting the test fibers.
2026-04-12 08:17:46 -04:00
Kit Langton a550ebf682 refactor(tool): yield Truncate and Agent in Tool.define, close over in wrap
Services are resolved at define-time (in registry context), passed into
wrap as closed-over values. Info.init() and Tool.init() stay R=never.
Tests updated to provide Truncate.defaultLayer and Agent.defaultLayer.
2026-04-12 08:17:46 -04:00
5 changed files with 5 additions and 26 deletions
@@ -14,14 +14,7 @@ import { tmpdir } from "../fixture/fixture"
import { SessionID, MessageID } from "../../src/session/schema" import { SessionID, MessageID } from "../../src/session/schema"
const runtime = ManagedRuntime.make( const runtime = ManagedRuntime.make(
Layer.mergeAll( Layer.mergeAll(LSP.defaultLayer, AppFileSystem.defaultLayer, Format.defaultLayer, Bus.layer, Truncate.defaultLayer, Agent.defaultLayer),
LSP.defaultLayer,
AppFileSystem.defaultLayer,
Format.defaultLayer,
Bus.layer,
Truncate.defaultLayer,
Agent.defaultLayer,
),
) )
const baseCtx = { const baseCtx = {
+1 -9
View File
@@ -36,15 +36,7 @@ async function touch(file: string, time: number) {
} }
const runtime = ManagedRuntime.make( const runtime = ManagedRuntime.make(
Layer.mergeAll( Layer.mergeAll(LSP.defaultLayer, FileTime.defaultLayer, AppFileSystem.defaultLayer, Format.defaultLayer, Bus.layer, Truncate.defaultLayer, Agent.defaultLayer),
LSP.defaultLayer,
FileTime.defaultLayer,
AppFileSystem.defaultLayer,
Format.defaultLayer,
Bus.layer,
Truncate.defaultLayer,
Agent.defaultLayer,
),
) )
afterAll(async () => { afterAll(async () => {
+1 -3
View File
@@ -9,9 +9,7 @@ import * as CrossSpawnSpawner from "../../src/effect/cross-spawn-spawner"
import { Truncate } from "../../src/tool/truncate" import { Truncate } from "../../src/tool/truncate"
import { Agent } from "../../src/agent/agent" import { Agent } from "../../src/agent/agent"
const runtime = ManagedRuntime.make( const runtime = ManagedRuntime.make(Layer.mergeAll(CrossSpawnSpawner.defaultLayer, Truncate.defaultLayer, Agent.defaultLayer))
Layer.mergeAll(CrossSpawnSpawner.defaultLayer, Truncate.defaultLayer, Agent.defaultLayer),
)
function initGrep() { function initGrep() {
return runtime.runPromise(GrepTool.pipe(Effect.flatMap((info) => info.init()))) return runtime.runPromise(GrepTool.pipe(Effect.flatMap((info) => info.init())))
+1 -3
View File
@@ -21,9 +21,7 @@ const ctx = {
ask: () => Effect.void, ask: () => Effect.void,
} }
const it = testEffect( const it = testEffect(Layer.mergeAll(Question.defaultLayer, CrossSpawnSpawner.defaultLayer, Truncate.defaultLayer, Agent.defaultLayer))
Layer.mergeAll(Question.defaultLayer, CrossSpawnSpawner.defaultLayer, Truncate.defaultLayer, Agent.defaultLayer),
)
const pending = Effect.fn("QuestionToolTest.pending")(function* (question: Question.Interface) { const pending = Effect.fn("QuestionToolTest.pending")(function* (question: Question.Interface) {
for (;;) { for (;;) {
+1 -3
View File
@@ -152,9 +152,7 @@ Use this skill.
await Instance.provide({ await Instance.provide({
directory: tmp.path, directory: tmp.path,
fn: async () => { fn: async () => {
const runtime = ManagedRuntime.make( const runtime = ManagedRuntime.make(Layer.mergeAll(Skill.defaultLayer, Ripgrep.defaultLayer, Truncate.defaultLayer, Agent.defaultLayer))
Layer.mergeAll(Skill.defaultLayer, Ripgrep.defaultLayer, Truncate.defaultLayer, Agent.defaultLayer),
)
const info = await runtime.runPromise(SkillTool) const info = await runtime.runPromise(SkillTool)
const tool = await runtime.runPromise(info.init()) const tool = await runtime.runPromise(info.init())
const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = [] const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []