| ... | @@ -1,5 +1,5 @@ | ... | @@ -1,5 +1,5 @@ |
| 1 | import * as NodeServices from "@effect/platform-node/NodeServices"; | 1 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 2 | import { Effect, FileSystem, Layer } from "effect"; | 2 | import { Effect, FileSystem, Layer, Path } from "effect"; |
| 3 | import * as SqlClient from "effect/unstable/sql/SqlClient"; | 3 | import * as SqlClient from "effect/unstable/sql/SqlClient"; |
| 4 | | 4 | |
| 5 | import { CheckpointDiffQueryLive } from "./checkpointing/Layers/CheckpointDiffQuery"; | 5 | import { CheckpointDiffQueryLive } from "./checkpointing/Layers/CheckpointDiffQuery"; |
| ... | @@ -32,10 +32,26 @@ import { GitCoreLive } from "./git/Layers/GitCore"; | ... | @@ -32,10 +32,26 @@ import { GitCoreLive } from "./git/Layers/GitCore"; |
| 32 | import { GitHubCliLive } from "./git/Layers/GitHubCli"; | 32 | import { GitHubCliLive } from "./git/Layers/GitHubCli"; |
| 33 | import { CodexTextGenerationLive } from "./git/Layers/CodexTextGeneration"; | 33 | import { CodexTextGenerationLive } from "./git/Layers/CodexTextGeneration"; |
| 34 | import { GitServiceLive } from "./git/Layers/GitService"; | 34 | import { GitServiceLive } from "./git/Layers/GitService"; |
| 35 | import { BunPtyAdapterLive } from "./terminal/Layers/BunPTY"; | 35 | import { PtyAdapter } from "./terminal/Services/PTY"; |
| 36 | import { NodePtyAdapterLive } from "./terminal/Layers/NodePTY"; | | |
| 37 | import { AnalyticsService } from "./telemetry/Services/AnalyticsService"; | 36 | import { AnalyticsService } from "./telemetry/Services/AnalyticsService"; |
| 38 | | 37 | |
| | 38 | type RuntimePtyAdapterLoader = { |
| | 39 | layer: Layer.Layer<PtyAdapter, never, FileSystem.FileSystem | Path.Path>; |
| | 40 | }; |
| | 41 | |
| | 42 | const runtimePtyAdapterLoaders = { |
| | 43 | bun: () => import("./terminal/Layers/BunPTY"), |
| | 44 | node: () => import("./terminal/Layers/NodePTY"), |
| | 45 | } satisfies Record<string, () => Promise<RuntimePtyAdapterLoader>>; |
| | 46 | |
| | 47 | const makeRuntimePtyAdapterLayer = () => |
| | 48 | Effect.gen(function* () { |
| | 49 | const runtime = process.versions.bun !== undefined ? "bun" : "node"; |
| | 50 | const loader = runtimePtyAdapterLoaders[runtime]; |
| | 51 | const ptyAdapterModule = yield* Effect.promise<RuntimePtyAdapterLoader>(loader); |
| | 52 | return ptyAdapterModule.layer; |
| | 53 | }).pipe(Layer.unwrap); |
| | 54 | |
| 39 | export function makeServerProviderLayer(): Layer.Layer< | 55 | export function makeServerProviderLayer(): Layer.Layer< |
| 40 | ProviderService, | 56 | ProviderService, |
| 41 | ProviderUnsupportedError, | 57 | ProviderUnsupportedError, |
| ... | @@ -108,13 +124,7 @@ export function makeServerRuntimeServicesLayer() { | ... | @@ -108,13 +124,7 @@ export function makeServerRuntimeServicesLayer() { |
| 108 | Layer.provideMerge(checkpointReactorLayer), | 124 | Layer.provideMerge(checkpointReactorLayer), |
| 109 | ); | 125 | ); |
| 110 | | 126 | |
| 111 | const terminalLayer = TerminalManagerLive.pipe( | 127 | const terminalLayer = TerminalManagerLive.pipe(Layer.provide(makeRuntimePtyAdapterLayer())); |
| 112 | Layer.provide( | | |
| 113 | typeof Bun !== "undefined" && process.platform !== "win32" | | |
| 114 | ? BunPtyAdapterLive | | |
| 115 | : NodePtyAdapterLive, | | |
| 116 | ), | | |
| 117 | ); | | |
| 118 | | 128 | |
| 119 | const gitManagerLayer = GitManagerLive.pipe( | 129 | const gitManagerLayer = GitManagerLive.pipe( |
| 120 | Layer.provideMerge(gitCoreLayer), | 130 | Layer.provideMerge(gitCoreLayer), |