Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

more effect: add new service definitions

Julius Marminge5bfd0598e763
diff --git a/apps/server/src/provider/Errors.ts b/apps/server/src/provider/Errors.ts
new file mode 100644
index 000000000..9655b1f65
--- /dev/null
+++ b/apps/server/src/provider/Errors.ts
@@ -0,0 +1,282 @@
+import { Schema } from "effect";
+
+/**
+ * CheckpointValidationError - Invalid checkpoint API input.
+ */
+export class CheckpointValidationError extends Schema.TaggedErrorClass<CheckpointValidationError>()(
+ "CheckpointValidationError",
+ {
+ operation: Schema.String,
+ issue: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Checkpoint validation failed in ${this.operation}: ${this.issue}`;
+ }
+}
+
+/**
+ * CheckpointGitCommandError - Git command execution failed in checkpoint store.
+ */
+export class CheckpointGitCommandError extends Schema.TaggedErrorClass<CheckpointGitCommandError>()(
+ "CheckpointGitCommandError",
+ {
+ operation: Schema.String,
+ command: Schema.String,
+ cwd: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Checkpoint git command failed in ${this.operation}: ${this.command} (${this.cwd}) - ${this.detail}`;
+ }
+}
+
+/**
+ * CheckpointUnavailableError - Expected checkpoint does not exist.
+ */
+export class CheckpointUnavailableError extends Schema.TaggedErrorClass<CheckpointUnavailableError>()(
+ "CheckpointUnavailableError",
+ {
+ threadId: Schema.String,
+ turnCount: Schema.Number,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Checkpoint unavailable for thread ${this.threadId} turn ${this.turnCount}: ${this.detail}`;
+ }
+}
+
+/**
+ * CheckpointRepositoryError - Checkpointing unavailable for cwd/repository.
+ */
+export class CheckpointRepositoryError extends Schema.TaggedErrorClass<CheckpointRepositoryError>()(
+ "CheckpointRepositoryError",
+ {
+ cwd: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Checkpoint repository error for ${this.cwd}: ${this.detail}`;
+ }
+}
+
+/**
+ * CodexValidationError - Invalid Codex API input.
+ */
+export class CodexValidationError extends Schema.TaggedErrorClass<CodexValidationError>()(
+ "CodexValidationError",
+ {
+ operation: Schema.String,
+ issue: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Codex validation failed in ${this.operation}: ${this.issue}`;
+ }
+}
+
+/**
+ * CodexSessionNotFoundError - Session id is unknown.
+ */
+export class CodexSessionNotFoundError extends Schema.TaggedErrorClass<CodexSessionNotFoundError>()(
+ "CodexSessionNotFoundError",
+ {
+ sessionId: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Unknown codex session: ${this.sessionId}`;
+ }
+}
+
+/**
+ * CodexSessionClosedError - Session exists but is closed.
+ */
+export class CodexSessionClosedError extends Schema.TaggedErrorClass<CodexSessionClosedError>()(
+ "CodexSessionClosedError",
+ {
+ sessionId: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Codex session is closed: ${this.sessionId}`;
+ }
+}
+
+/**
+ * CodexProtocolError - Invalid/unexpected JSON-RPC payload from app-server.
+ */
+export class CodexProtocolError extends Schema.TaggedErrorClass<CodexProtocolError>()(
+ "CodexProtocolError",
+ {
+ operation: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Codex protocol error in ${this.operation}: ${this.detail}`;
+ }
+}
+
+/**
+ * CodexRequestError - JSON-RPC request failed or timed out.
+ */
+export class CodexRequestError extends Schema.TaggedErrorClass<CodexRequestError>()(
+ "CodexRequestError",
+ {
+ method: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Codex request failed for ${this.method}: ${this.detail}`;
+ }
+}
+
+/**
+ * CodexProcessError - codex app-server process lifecycle failure.
+ */
+export class CodexProcessError extends Schema.TaggedErrorClass<CodexProcessError>()(
+ "CodexProcessError",
+ {
+ sessionId: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Codex process error for session ${this.sessionId}: ${this.detail}`;
+ }
+}
+
+/**
+ * ProviderValidationError - Invalid provider API input.
+ */
+export class ProviderValidationError extends Schema.TaggedErrorClass<ProviderValidationError>()(
+ "ProviderValidationError",
+ {
+ operation: Schema.String,
+ issue: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Provider validation failed in ${this.operation}: ${this.issue}`;
+ }
+}
+
+/**
+ * ProviderUnsupportedError - Requested provider is not implemented.
+ */
+export class ProviderUnsupportedError extends Schema.TaggedErrorClass<ProviderUnsupportedError>()(
+ "ProviderUnsupportedError",
+ {
+ provider: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Provider '${this.provider}' is not implemented`;
+ }
+}
+
+/**
+ * ProviderSessionNotFoundError - Provider-facing session not found.
+ */
+export class ProviderSessionNotFoundError extends Schema.TaggedErrorClass<ProviderSessionNotFoundError>()(
+ "ProviderSessionNotFoundError",
+ {
+ sessionId: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Unknown provider session: ${this.sessionId}`;
+ }
+}
+
+/**
+ * ProviderCheckpointUnavailableError - Checkpointing unavailable for this session.
+ */
+export class ProviderCheckpointUnavailableError extends Schema.TaggedErrorClass<ProviderCheckpointUnavailableError>()(
+ "ProviderCheckpointUnavailableError",
+ {
+ sessionId: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Provider checkpoint unavailable for session ${this.sessionId}: ${this.detail}`;
+ }
+}
+
+/**
+ * ProviderCheckpointRangeError - Requested checkpoint range is invalid.
+ */
+export class ProviderCheckpointRangeError extends Schema.TaggedErrorClass<ProviderCheckpointRangeError>()(
+ "ProviderCheckpointRangeError",
+ {
+ sessionId: Schema.String,
+ fromTurnCount: Schema.Number,
+ toTurnCount: Schema.Number,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Provider checkpoint range error for session ${this.sessionId}: ${this.fromTurnCount}..${this.toTurnCount} (${this.detail})`;
+ }
+}
+
+/**
+ * ProviderFilesystemError - Filesystem checkpoint capture/restore failure.
+ */
+export class ProviderFilesystemError extends Schema.TaggedErrorClass<ProviderFilesystemError>()(
+ "ProviderFilesystemError",
+ {
+ sessionId: Schema.String,
+ detail: Schema.String,
+ cause: Schema.optional(Schema.Defect),
+ },
+) {
+ override get message(): string {
+ return `Provider filesystem checkpoint error for session ${this.sessionId}: ${this.detail}`;
+ }
+}
+
+export type CheckpointStoreError =
+ | CheckpointValidationError
+ | CheckpointGitCommandError
+ | CheckpointUnavailableError
+ | CheckpointRepositoryError;
+
+export type CodexServiceError =
+ | CodexValidationError
+ | CodexSessionNotFoundError
+ | CodexSessionClosedError
+ | CodexProtocolError
+ | CodexRequestError
+ | CodexProcessError;
+
+export type ProviderServiceError =
+ | ProviderValidationError
+ | ProviderUnsupportedError
+ | ProviderSessionNotFoundError
+ | ProviderCheckpointUnavailableError
+ | ProviderCheckpointRangeError
+ | ProviderFilesystemError
+ | CodexServiceError
+ | CheckpointStoreError;
diff --git a/apps/server/src/provider/Services/CheckpointStore.ts b/apps/server/src/provider/Services/CheckpointStore.ts
new file mode 100644
index 000000000..98bbacbed
--- /dev/null
+++ b/apps/server/src/provider/Services/CheckpointStore.ts
@@ -0,0 +1,91 @@
+/**
+ * CheckpointStore - Repository interface for filesystem-backed workspace checkpoints.
+ *
+ * Uses Effect `ServiceMap.Service` for dependency injection and exposes typed
+ * domain errors for checkpoint lifecycle operations.
+ *
+ * @module CheckpointStore
+ */
+import { ServiceMap } from "effect";
+import type { Effect } from "effect";
+
+import type { CheckpointStoreError } from "../Errors.ts";
+
+export interface CaptureCheckpointInput {
+ readonly cwd: string;
+ readonly threadId: string;
+ readonly turnCount: number;
+}
+
+export interface EnsureRootCheckpointInput {
+ readonly cwd: string;
+ readonly threadId: string;
+}
+
+export interface RestoreCheckpointInput {
+ readonly cwd: string;
+ readonly threadId: string;
+ readonly turnCount: number;
+}
+
+export interface DiffCheckpointsInput {
+ readonly cwd: string;
+ readonly threadId: string;
+ readonly fromTurnCount: number;
+ readonly toTurnCount: number;
+}
+
+export interface PruneAfterTurnInput {
+ readonly cwd: string;
+ readonly threadId: string;
+ readonly maxTurnCount: number;
+}
+
+export interface CheckpointStoreShape {
+ /**
+ * Check whether cwd is inside a Git worktree.
+ */
+ readonly isGitRepository: (cwd: string) => Effect.Effect<boolean, CheckpointStoreError>;
+
+ /**
+ * Capture a checkpoint for a thread at a turn count.
+ */
+ readonly captureCheckpoint: (input: CaptureCheckpointInput) => Effect.Effect<void, CheckpointStoreError>;
+
+ /**
+ * Check whether a checkpoint ref exists.
+ */
+ readonly hasCheckpoint: (input: RestoreCheckpointInput) => Effect.Effect<boolean, CheckpointStoreError>;
+
+ /**
+ * Ensure a turn-0 checkpoint exists for a thread.
+ */
+ readonly ensureRootCheckpoint: (
+ input: EnsureRootCheckpointInput,
+ ) => Effect.Effect<boolean, CheckpointStoreError>;
+
+ /**
+ * Restore workspace/staging state to a checkpoint.
+ */
+ readonly restoreCheckpoint: (
+ input: RestoreCheckpointInput,
+ ) => Effect.Effect<boolean, CheckpointStoreError>;
+
+ /**
+ * Compute patch diff between two checkpoint turn counts.
+ */
+ readonly diffCheckpoints: (input: DiffCheckpointsInput) => Effect.Effect<string, CheckpointStoreError>;
+
+ /**
+ * Delete checkpoints newer than the provided turn count.
+ */
+ readonly pruneAfterTurn: (input: PruneAfterTurnInput) => Effect.Effect<void, CheckpointStoreError>;
+}
+
+/**
+ * CheckpointStore - Context tag for checkpoint persistence and restore operations.
+ */
+export class CheckpointStore extends ServiceMap.Service<
+ CheckpointStore,
+ CheckpointStoreShape
+>()("provider/CheckpointStore") {}
diff --git a/apps/server/src/provider/Services/Codex.ts b/apps/server/src/provider/Services/Codex.ts
new file mode 100644
index 000000000..06a556fa3
--- /dev/null
+++ b/apps/server/src/provider/Services/Codex.ts
@@ -0,0 +1,110 @@
+/**
+ * CodexService - Service interface for codex app-server session lifecycle and RPC.
+ *
+ * Uses Effect `ServiceMap.Service` for dependency injection and returns typed
+ * domain errors for process, protocol, and session operations.
+ *
+ * @module CodexService
+ */
+import type {
+ ProviderApprovalDecision,
+ ProviderEvent,
+ ProviderSendTurnInput,
+ ProviderSession,
+ ProviderSessionStartInput,
+ ProviderTurnStartResult,
+} from "@t3tools/contracts";
+import { ServiceMap } from "effect";
+import type { Effect } from "effect";
+
+import type { CodexServiceError } from "../Errors.ts";
+
+export interface CodexThreadTurnSnapshot {
+ readonly id: string;
+ readonly items: ReadonlyArray<unknown>;
+}
+
+export interface CodexThreadSnapshot {
+ readonly threadId: string;
+ readonly turns: ReadonlyArray<CodexThreadTurnSnapshot>;
+}
+
+export interface CodexServiceShape {
+ /**
+ * Start a codex app-server-backed provider session.
+ */
+ readonly startSession: (
+ input: ProviderSessionStartInput,
+ ) => Effect.Effect<ProviderSession, CodexServiceError>;
+
+ /**
+ * Send a new turn to an active codex session.
+ */
+ readonly sendTurn: (
+ input: ProviderSendTurnInput,
+ ) => Effect.Effect<ProviderTurnStartResult, CodexServiceError>;
+
+ /**
+ * Interrupt an active turn.
+ */
+ readonly interruptTurn: (
+ sessionId: string,
+ turnId?: string,
+ ) => Effect.Effect<void, CodexServiceError>;
+
+ /**
+ * Read a thread snapshot (including turns).
+ */
+ readonly readThread: (sessionId: string) => Effect.Effect<CodexThreadSnapshot, CodexServiceError>;
+
+ /**
+ * Roll back a thread by N turns.
+ */
+ readonly rollbackThread: (
+ sessionId: string,
+ numTurns: number,
+ ) => Effect.Effect<CodexThreadSnapshot, CodexServiceError>;
+
+ /**
+ * Respond to an interactive approval request from codex app-server.
+ */
+ readonly respondToRequest: (
+ sessionId: string,
+ requestId: string,
+ decision: ProviderApprovalDecision,
+ ) => Effect.Effect<void, CodexServiceError>;
+
+ /**
+ * Stop one session.
+ */
+ readonly stopSession: (sessionId: string) => Effect.Effect<void, CodexServiceError>;
+
+ /**
+ * List active sessions.
+ */
+ readonly listSessions: () => Effect.Effect<ReadonlyArray<ProviderSession>>;
+
+ /**
+ * Check whether session id is currently active.
+ */
+ readonly hasSession: (sessionId: string) => Effect.Effect<boolean>;
+
+ /**
+ * Stop all sessions.
+ */
+ readonly stopAll: () => Effect.Effect<void, CodexServiceError>;
+
+ /**
+ * Subscribe to provider events emitted by codex app-server.
+ */
+ readonly subscribeToEvents: (
+ callback: (event: ProviderEvent) => void,
+ ) => Effect.Effect<() => void, CodexServiceError>;
+}
+
+/**
+ * CodexService - Context tag for codex session and RPC operations.
+ */
+export class CodexService extends ServiceMap.Service<CodexService, CodexServiceShape>()(
+ "provider/CodexService",
+) {}
diff --git a/apps/server/src/provider/Services/Provider.ts b/apps/server/src/provider/Services/Provider.ts
new file mode 100644
index 000000000..6ae8ee351
--- /dev/null
+++ b/apps/server/src/provider/Services/Provider.ts
@@ -0,0 +1,113 @@
+/**
+ * ProviderService - Service interface for provider sessions, turns, and checkpoints.
+ *
+ * Uses Effect `ServiceMap.Service` for dependency injection and returns typed
+ * domain errors for validation, session, codex, and checkpoint workflows.
+ *
+ * @module ProviderService
+ */
+import type {
+ ProviderEvent,
+ ProviderGetCheckpointDiffInput,
+ ProviderGetCheckpointDiffResult,
+ ProviderInterruptTurnInput,
+ ProviderListCheckpointsInput,
+ ProviderListCheckpointsResult,
+ ProviderRespondToRequestInput,
+ ProviderRevertToCheckpointInput,
+ ProviderRevertToCheckpointResult,
+ ProviderSendTurnInput,
+ ProviderSession,
+ ProviderSessionStartInput,
+ ProviderStopSessionInput,
+ ProviderTurnStartResult,
+} from "@t3tools/contracts";
+import { ServiceMap } from "effect";
+import type { Effect } from "effect";
+
+import type { ProviderServiceError } from "../Errors.ts";
+
+export interface ProviderServiceShape {
+ /**
+ * Start a provider session.
+ */
+ readonly startSession: (
+ input: ProviderSessionStartInput,
+ ) => Effect.Effect<ProviderSession, ProviderServiceError>;
+
+ /**
+ * Send a provider turn.
+ */
+ readonly sendTurn: (
+ input: ProviderSendTurnInput,
+ ) => Effect.Effect<ProviderTurnStartResult, ProviderServiceError>;
+
+ /**
+ * Interrupt a running provider turn.
+ */
+ readonly interruptTurn: (
+ input: ProviderInterruptTurnInput,
+ ) => Effect.Effect<void, ProviderServiceError>;
+
+ /**
+ * Respond to a provider approval request.
+ */
+ readonly respondToRequest: (
+ input: ProviderRespondToRequestInput,
+ ) => Effect.Effect<void, ProviderServiceError>;
+
+ /**
+ * Stop a provider session.
+ */
+ readonly stopSession: (input: ProviderStopSessionInput) => Effect.Effect<void, ProviderServiceError>;
+
+ /**
+ * List active provider sessions.
+ */
+ readonly listSessions: () => Effect.Effect<ReadonlyArray<ProviderSession>>;
+
+ /**
+ * List checkpoints for a provider session.
+ */
+ readonly listCheckpoints: (
+ input: ProviderListCheckpointsInput,
+ ) => Effect.Effect<ProviderListCheckpointsResult, ProviderServiceError>;
+
+ /**
+ * Diff two checkpoints for a provider session.
+ */
+ readonly getCheckpointDiff: (
+ input: ProviderGetCheckpointDiffInput,
+ ) => Effect.Effect<ProviderGetCheckpointDiffResult, ProviderServiceError>;
+
+ /**
+ * Revert a provider session to a checkpoint.
+ */
+ readonly revertToCheckpoint: (
+ input: ProviderRevertToCheckpointInput,
+ ) => Effect.Effect<ProviderRevertToCheckpointResult, ProviderServiceError>;
+
+ /**
+ * Stop all provider sessions.
+ */
+ readonly stopAll: () => Effect.Effect<void, ProviderServiceError>;
+
+ /**
+ * Dispose provider resources (logs/listeners).
+ */
+ readonly dispose: () => Effect.Effect<void, ProviderServiceError>;
+
+ /**
+ * Subscribe to provider event stream.
+ */
+ readonly subscribeToEvents: (
+ callback: (event: ProviderEvent) => void,
+ ) => Effect.Effect<() => void, ProviderServiceError>;
+}
+
+/**
+ * ProviderService - Context tag for provider orchestration.
+ */
+export class ProviderService extends ServiceMap.Service<ProviderService, ProviderServiceShape>()(
+ "provider/ProviderService",
+) {}
diff --git a/apps/server/src/provider/contracts.test.ts b/apps/server/src/provider/contracts.test.ts
new file mode 100644
index 000000000..3675af73e
--- /dev/null
+++ b/apps/server/src/provider/contracts.test.ts
@@ -0,0 +1,125 @@
+import { describe, expect, it } from "vitest";
+
+import { Effect, Layer, ManagedRuntime } from "effect";
+
+import {
+ CheckpointValidationError,
+ CodexValidationError,
+ ProviderFilesystemError,
+ ProviderUnsupportedError,
+ type CheckpointStoreError,
+ type CodexServiceError,
+ type ProviderServiceError,
+} from "./Errors.ts";
+import { CheckpointStore } from "./Services/CheckpointStore.ts";
+import { CodexService } from "./Services/Codex.ts";
+import { ProviderService } from "./Services/Provider.ts";
+
+describe("provider service contracts", () => {
+ it("resolves provider, codex, and checkpoint services from ServiceMap tags", async () => {
+ const providerLive: typeof ProviderService.Service = {
+ startSession: () =>
+ Effect.fail<ProviderServiceError>(new ProviderUnsupportedError({ provider: "x" })),
+ sendTurn: () =>
+ Effect.fail<ProviderServiceError>(new ProviderUnsupportedError({ provider: "x" })),
+ interruptTurn: () =>
+ Effect.fail<ProviderServiceError>(new ProviderUnsupportedError({ provider: "x" })),
+ respondToRequest: () =>
+ Effect.fail<ProviderServiceError>(new ProviderUnsupportedError({ provider: "x" })),
+ stopSession: () => Effect.void,
+ listSessions: () => Effect.succeed([]),
+ listCheckpoints: () =>
+ Effect.fail<ProviderServiceError>(new ProviderUnsupportedError({ provider: "x" })),
+ getCheckpointDiff: () =>
+ Effect.fail<ProviderServiceError>(new ProviderUnsupportedError({ provider: "x" })),
+ revertToCheckpoint: () =>
+ Effect.fail<ProviderServiceError>(new ProviderUnsupportedError({ provider: "x" })),
+ stopAll: () => Effect.void,
+ dispose: () => Effect.void,
+ subscribeToEvents: () => Effect.succeed(() => undefined),
+ };
+
+ const codexLive: typeof CodexService.Service = {
+ startSession: () =>
+ Effect.fail<CodexServiceError>(
+ new CodexValidationError({ operation: "startSession", issue: "not implemented" }),
+ ),
+ sendTurn: () =>
+ Effect.fail<CodexServiceError>(
+ new CodexValidationError({ operation: "sendTurn", issue: "not implemented" }),
+ ),
+ interruptTurn: () =>
+ Effect.fail<CodexServiceError>(
+ new CodexValidationError({ operation: "interruptTurn", issue: "not implemented" }),
+ ),
+ readThread: () =>
+ Effect.fail<CodexServiceError>(
+ new CodexValidationError({ operation: "readThread", issue: "not implemented" }),
+ ),
+ rollbackThread: () =>
+ Effect.fail<CodexServiceError>(
+ new CodexValidationError({ operation: "rollbackThread", issue: "not implemented" }),
+ ),
+ respondToRequest: () =>
+ Effect.fail<CodexServiceError>(
+ new CodexValidationError({ operation: "respondToRequest", issue: "not implemented" }),
+ ),
+ stopSession: () => Effect.void,
+ listSessions: () => Effect.succeed([]),
+ hasSession: () => Effect.succeed(false),
+ stopAll: () => Effect.void,
+ subscribeToEvents: () => Effect.succeed(() => undefined),
+ };
+
+ const checkpointLive: typeof CheckpointStore.Service = {
+ isGitRepository: () => Effect.succeed(false),
+ captureCheckpoint: () => Effect.void,
+ hasCheckpoint: () => Effect.succeed(false),
+ ensureRootCheckpoint: () => Effect.succeed(false),
+ restoreCheckpoint: () => Effect.succeed(false),
+ diffCheckpoints: () =>
+ Effect.fail<CheckpointStoreError>(
+ new CheckpointValidationError({
+ operation: "diffCheckpoints",
+ issue: "not implemented",
+ }),
+ ),
+ pruneAfterTurn: () => Effect.void,
+ };
+
+ const runtime = ManagedRuntime.make(
+ Layer.mergeAll(
+ Layer.succeed(ProviderService, providerLive),
+ Layer.succeed(CodexService, codexLive),
+ Layer.succeed(CheckpointStore, checkpointLive),
+ ),
+ );
+
+ const [provider, codex, checkpoint] = await Promise.all([
+ runtime.runPromise(Effect.service(ProviderService)),
+ runtime.runPromise(Effect.service(CodexService)),
+ runtime.runPromise(Effect.service(CheckpointStore)),
+ ]);
+
+ expect(provider).toBe(providerLive);
+ expect(codex).toBe(codexLive);
+ expect(checkpoint).toBe(checkpointLive);
+
+ await runtime.dispose();
+ });
+});
+
+describe("provider error taxonomy", () => {
+ it("keeps defect cause and message on tagged errors", () => {
+ const cause = new Error("filesystem failed");
+ const error = new ProviderFilesystemError({
+ sessionId: "sess-1",
+ detail: "capture failed",
+ cause,
+ });
+
+ expect(error._tag).toBe("ProviderFilesystemError");
+ expect(error.message).toContain("sess-1");
+ expect(error.cause).toBe(cause);
+ });
+});