1import type { CodexSettings, ProviderInstanceId } from "@t3tools/contracts";
2import * as Effect from "effect/Effect";
3import * as Path from "effect/Path";
4import { resolveCodexHomeLayout } from "./Drivers/CodexHomeLayout.ts";
5
6export const resolveManagedCodexHomeLayout = Effect.fn("resolveManagedCodexHomeLayout")(function* (
7 stateDir: string,
8 instanceId: ProviderInstanceId,
9 config: CodexSettings,
10) {
11 const path = yield* Path.Path;
12 return yield* resolveCodexHomeLayout({
13 ...config,
14 shadowHomePath:
15 config.shadowHomePath.trim() ||
16 (instanceId === "codex"
17 ? ""
18 : path.join(stateDir, "providers", "codex", instanceId, "shadow")),
19 });
20});