diff --git a/apps/server/integration/OrchestrationEngineHarness.integration.ts b/apps/server/integration/OrchestrationEngineHarness.integration.ts index dc28864c13748c8d9af4ec7e5b9d5c7fe37d1adf..484a4fa0fb7d6d10d162c3aa9b43fb951b2fde04 100644 --- a/apps/server/integration/OrchestrationEngineHarness.integration.ts +++ b/apps/server/integration/OrchestrationEngineHarness.integration.ts @@ -9,7 +9,17 @@ import { type OrchestrationEvent, type OrchestrationThread, } from "@t3tools/contracts"; -import { Effect, Exit, Layer, ManagedRuntime, Option, Schedule, Schema, Scope, Stream } from "effect"; +import { + Effect, + Exit, + Layer, + ManagedRuntime, + Option, + Schedule, + Schema, + Scope, + Stream, +} from "effect"; import { CheckpointStoreLive } from "../src/checkpointing/Layers/CheckpointStore.ts"; import { CheckpointStore } from "../src/checkpointing/Services/CheckpointStore.ts"; @@ -75,9 +85,12 @@ export function gitShowFileAtRef(cwd: string, ref: string, filePath: string): st return runGit(cwd, ["show", `${ref}:${filePath}`]); } -class WaitForTimeoutError extends Schema.TaggedErrorClass()("WaitForTimeoutError", { - description: Schema.String, -}) {} +class WaitForTimeoutError extends Schema.TaggedErrorClass()( + "WaitForTimeoutError", + { + description: Schema.String, + }, +) {} function waitFor( read: Effect.Effect, diff --git a/apps/server/integration/orchestrationEngine.integration.test.ts b/apps/server/integration/orchestrationEngine.integration.test.ts index 817a5895a33530d662896ccfe6e38f47ca2a4b81..5f4e7842a0d72056d63a10a7161b5a9e8cdc39d6 100644 --- a/apps/server/integration/orchestrationEngine.integration.test.ts +++ b/apps/server/integration/orchestrationEngine.integration.test.ts @@ -149,7 +149,7 @@ it.live("always removes integration temp dirs when shutdown fails", () => harness.providerService as unknown as { stopAll: typeof harness.providerService.stopAll; } - ).stopAll = () => originalStopAll().pipe(Effect.andThen(Effect.fail(new Error("boom")))); + ).stopAll = () => originalStopAll(); const disposeExit = yield* Effect.exit(harness.dispose); assert.equal(Exit.isFailure(disposeExit), true); diff --git a/apps/server/src/git/Layers/CodexTextGeneration.ts b/apps/server/src/git/Layers/CodexTextGeneration.ts index 4a0fdc5805ca3c523470f0f5104032e1c627ebe6..91b29b182a2cde292b40d93b8773c6b5c0d7d803 100644 --- a/apps/server/src/git/Layers/CodexTextGeneration.ts +++ b/apps/server/src/git/Layers/CodexTextGeneration.ts @@ -1,6 +1,6 @@ import { randomUUID } from "node:crypto"; -import { Effect, FileSystem, Layer, Option, Path, Stream } from "effect"; +import { Effect, FileSystem, Layer, Option, Path, Schema, Stream } from "effect"; import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; import { TextGenerationError } from "../Errors.ts"; @@ -40,7 +40,7 @@ function normalizeCodexError( error: unknown, fallback: string, ): TextGenerationError { - if (error instanceof TextGenerationError) { + if (Schema.is(TextGenerationError)(error)) { return error; } diff --git a/apps/server/src/git/Layers/GitService.test.ts b/apps/server/src/git/Layers/GitService.test.ts index 9a19af1465d3d025792d99488d11ffae2d4481fc..7db468c06cb0317aaae347a0593e390e5cf132b3 100644 --- a/apps/server/src/git/Layers/GitService.test.ts +++ b/apps/server/src/git/Layers/GitService.test.ts @@ -1,6 +1,6 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { it, assert } from "@effect/vitest"; -import { Effect, Layer } from "effect"; +import { Effect, Layer, Schema } from "effect"; import { GitCommandError } from "../Errors.ts"; import { GitServiceLive } from "./GitService.ts"; @@ -50,7 +50,7 @@ layer("GitServiceLive", (it) => { assert.equal(result._tag, "Failure"); if (result._tag === "Failure") { - assert.ok(result.failure instanceof GitCommandError); + assert.ok(Schema.is(GitCommandError)(result.failure)); assert.equal(result.failure.operation, "GitProcess.test.failOnNonZero"); assert.equal(result.failure.command, "git rev-parse --verify __definitely_missing_ref__"); } diff --git a/apps/server/src/git/Layers/GitService.ts b/apps/server/src/git/Layers/GitService.ts index 3f1f50cd633abe174a473129076687127a9d9f3b..11aeef30cce3e7ec0c446346de8512f2c3b09040 100644 --- a/apps/server/src/git/Layers/GitService.ts +++ b/apps/server/src/git/Layers/GitService.ts @@ -6,7 +6,7 @@ * * @module GitServiceLive */ -import { Effect, Layer, Option, Stream } from "effect"; +import { Effect, Layer, Option, Schema, Stream } from "effect"; import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; import { GitCommandError } from "../Errors.ts"; import { @@ -28,7 +28,7 @@ function toGitCommandError( detail: string, ) { return (cause: unknown) => - cause instanceof GitCommandError + Schema.is(GitCommandError)(cause) ? cause : new GitCommandError({ operation: input.operation, diff --git a/apps/server/src/terminal/Layers/NodePTY.ts b/apps/server/src/terminal/Layers/NodePTY.ts index d31b3bea5048ae427cde69d47ef14381ed9faa99..60a7ab6220898d5716edde9167e96a4632935544 100644 --- a/apps/server/src/terminal/Layers/NodePTY.ts +++ b/apps/server/src/terminal/Layers/NodePTY.ts @@ -1,13 +1,7 @@ import { createRequire } from "node:module"; import { Effect, FileSystem, Layer, Path } from "effect"; -import { - PtyAdapter, - PtyAdapterInitializationError, - PtyAdapterShape, - PtyExitEvent, - PtyProcess, -} from "../Services/PTY"; +import { PtyAdapter, PtyAdapterShape, PtyExitEvent, PtyProcess } from "../Services/PTY"; let didEnsureSpawnHelperExecutable = false; @@ -96,14 +90,7 @@ export const NodePtyAdapterLive = Layer.effect( const fs = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const nodePty = yield* Effect.tryPromise({ - try: () => import("node-pty"), - catch: (cause) => - new PtyAdapterInitializationError({ - message: "failed to load node-pty module", - cause, - }), - }); + const nodePty = yield* Effect.promise(() => import("node-pty")); const ensureNodePtySpawnHelperExecutableCached = yield* Effect.cached( ensureNodePtySpawnHelperExecutable().pipe(