@@ -23,8 +23,10 @@ import type { Provider } from "@/provider/provider"
2323import { ModelID , ProviderID } from "@/provider/schema"
2424import { Effect , Schema , Types } from "effect"
2525import { NonNegativeInt } from "@opencode-ai/core/schema"
26- import { namedSchemaError } from "@/util/named-schema-error"
2726import * as EffectLogger from "@opencode-ai/core/effect/logger"
27+ import { MessageError } from "./message-error"
28+ import { AuthError , OutputLengthError } from "./message-error"
29+ export { AuthError , OutputLengthError } from "./message-error"
2830
2931/** Error shape thrown by Bun's fetch() when gzip/br decompression fails mid-stream */
3032interface FetchDecompressionError extends Error {
@@ -36,17 +38,12 @@ interface FetchDecompressionError extends Error {
3638export const SYNTHETIC_ATTACHMENT_PROMPT = "Attached media from tool result:"
3739export { isMedia }
3840
39- export const OutputLengthError = namedSchemaError ( "MessageOutputLengthError" , { } )
40- export const AbortedError = namedSchemaError ( "MessageAbortedError" , { message : Schema . String } )
41- export const StructuredOutputError = namedSchemaError ( "StructuredOutputError" , {
41+ export const AbortedError = NamedError . create ( "MessageAbortedError" , { message : Schema . String } )
42+ export const StructuredOutputError = NamedError . create ( "StructuredOutputError" , {
4243 message : Schema . String ,
4344 retries : NonNegativeInt ,
4445} )
45- export const AuthError = namedSchemaError ( "ProviderAuthError" , {
46- providerID : Schema . String ,
47- message : Schema . String ,
48- } )
49- export const APIError = namedSchemaError ( "APIError" , {
46+ export const APIError = NamedError . create ( "APIError" , {
5047 message : Schema . String ,
5148 statusCode : Schema . optional ( NonNegativeInt ) ,
5249 isRetryable : Schema . Boolean ,
@@ -55,7 +52,7 @@ export const APIError = namedSchemaError("APIError", {
5552 metadata : Schema . optional ( Schema . Record ( Schema . String , Schema . String ) ) ,
5653} )
5754export type APIError = Schema . Schema . Type < typeof APIError . Schema >
58- export const ContextOverflowError = namedSchemaError ( "ContextOverflowError" , {
55+ export const ContextOverflowError = NamedError . create ( "ContextOverflowError" , {
5956 message : Schema . String ,
6057 responseBody : Schema . optional ( Schema . String ) ,
6158} )
@@ -381,9 +378,7 @@ export type Part =
381378 | CompactionPart
382379
383380const AssistantErrorSchema = Schema . Union ( [
384- AuthError . EffectSchema ,
385- NamedError . Unknown . EffectSchema ,
386- OutputLengthError . EffectSchema ,
381+ ...MessageError . Shared ,
387382 AbortedError . EffectSchema ,
388383 StructuredOutputError . EffectSchema ,
389384 ContextOverflowError . EffectSchema ,
0 commit comments