Files
t3code/apps/server/src/provider/Errors.ts
T
Julius Marminge 26f631b638 Migrate provider runtime/session flow to thread-scoped IDs
- Replace provider session-id centric plumbing with thread-id based runtime handling across server orchestration and provider layers
- Update persistence repositories/migrations and contracts for threadless runtime semantics
- Refresh integration/unit tests and web session/store types to match the new runtime model
2026-03-05 23:00:41 -08:00

164 lines
4.6 KiB
TypeScript

import { Schema } from "effect";
import type { CheckpointServiceError } from "../checkpointing/Errors.ts";
/**
* ProviderAdapterValidationError - Invalid adapter API input.
*/
export class ProviderAdapterValidationError extends Schema.TaggedErrorClass<ProviderAdapterValidationError>()(
"ProviderAdapterValidationError",
{
provider: Schema.String,
operation: Schema.String,
issue: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `Provider adapter validation failed (${this.provider}) in ${this.operation}: ${this.issue}`;
}
}
/**
* ProviderAdapterSessionNotFoundError - Adapter-owned session id is unknown.
*/
export class ProviderAdapterSessionNotFoundError extends Schema.TaggedErrorClass<ProviderAdapterSessionNotFoundError>()(
"ProviderAdapterSessionNotFoundError",
{
provider: Schema.String,
threadId: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `Unknown ${this.provider} adapter thread: ${this.threadId}`;
}
}
/**
* ProviderAdapterSessionClosedError - Adapter session exists but is closed.
*/
export class ProviderAdapterSessionClosedError extends Schema.TaggedErrorClass<ProviderAdapterSessionClosedError>()(
"ProviderAdapterSessionClosedError",
{
provider: Schema.String,
threadId: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `${this.provider} adapter thread is closed: ${this.threadId}`;
}
}
/**
* ProviderAdapterRequestError - Provider protocol request failed or timed out.
*/
export class ProviderAdapterRequestError extends Schema.TaggedErrorClass<ProviderAdapterRequestError>()(
"ProviderAdapterRequestError",
{
provider: Schema.String,
method: Schema.String,
detail: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `Provider adapter request failed (${this.provider}) for ${this.method}: ${this.detail}`;
}
}
/**
* ProviderAdapterProcessError - Provider process lifecycle failure.
*/
export class ProviderAdapterProcessError extends Schema.TaggedErrorClass<ProviderAdapterProcessError>()(
"ProviderAdapterProcessError",
{
provider: Schema.String,
threadId: Schema.String,
detail: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `Provider adapter process error (${this.provider}) for thread ${this.threadId}: ${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",
{
threadId: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `Unknown provider thread: ${this.threadId}`;
}
}
/**
* ProviderSessionDirectoryPersistenceError - Session directory persistence failure.
*/
export class ProviderSessionDirectoryPersistenceError extends Schema.TaggedErrorClass<ProviderSessionDirectoryPersistenceError>()(
"ProviderSessionDirectoryPersistenceError",
{
operation: Schema.String,
detail: Schema.String,
cause: Schema.optional(Schema.Defect),
},
) {
override get message(): string {
return `Provider session directory persistence error in ${this.operation}: ${this.detail}`;
}
}
export type ProviderAdapterError =
| ProviderAdapterValidationError
| ProviderAdapterSessionNotFoundError
| ProviderAdapterSessionClosedError
| ProviderAdapterRequestError
| ProviderAdapterProcessError;
export type ProviderServiceError =
| ProviderValidationError
| ProviderUnsupportedError
| ProviderSessionNotFoundError
| ProviderSessionDirectoryPersistenceError
| ProviderAdapterError
| CheckpointServiceError;