@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 245 lines 5.84 KB
Raw
1 /**
2 * OpenAI error metadata augmentation.
3 *
4 * Provides OpenAI-specific metadata fields for AI error types through module
5 * augmentation, enabling typed access to OpenAI error details.
6 *
7 * @stability unstable
8 * @since 4.0.0
9 */
10
11 /**
12 * OpenAI-specific error metadata fields.
13 *
14 * @stability unstable
15 * @category models
16 * @since 4.0.0
17 */
18 export type OpenAiErrorMetadata = {
19 /**
20 * The OpenAI error code returned by the API.
21 */
22 readonly errorCode: string | null
23 /**
24 * The OpenAI error type returned by the API.
25 */
26 readonly errorType: string | null
27 /**
28 * The unique request ID for debugging with OpenAI support.
29 */
30 readonly requestId: string | null
31 }
32
33 /**
34 * OpenAI-specific rate limit metadata fields.
35 *
36 * **Details**
37 *
38 * Extends base error metadata with rate limit specific information from
39 * OpenAI's rate limit headers.
40 *
41 * @stability unstable
42 * @category models
43 * @since 4.0.0
44 */
45 export type OpenAiRateLimitMetadata = OpenAiErrorMetadata & {
46 /**
47 * The rate limit type (e.g. "requests", "tokens").
48 */
49 readonly limit: string | null
50 /**
51 * Number of remaining requests in the current window.
52 */
53 readonly remaining: number | null
54 /**
55 * Time until the request rate limit resets.
56 */
57 readonly resetRequests: string | null
58 /**
59 * Time until the token rate limit resets.
60 */
61 readonly resetTokens: string | null
62 }
63
64 declare module "effect/ai/AiError" {
65 /**
66 * OpenAI metadata attached to `RateLimitError` values.
67 *
68 * **Details**
69 *
70 * Captures OpenAI error details together with rate limit header information
71 * from responses where the provider rejected the request because a limit was
72 * reached.
73 *
74 * @category models
75 * @since 4.0.0
76 */
77 export interface RateLimitErrorMetadata {
78 /**
79 * OpenAI-specific details for the rate limit response.
80 */
81 readonly openai?: OpenAiRateLimitMetadata | null
82 }
83
84 /**
85 * OpenAI metadata attached to `QuotaExhaustedError` values.
86 *
87 * **Details**
88 *
89 * Preserves provider error details for failures caused by exhausted account,
90 * billing, or usage quota.
91 *
92 * @category models
93 * @since 4.0.0
94 */
95 export interface QuotaExhaustedErrorMetadata {
96 /**
97 * OpenAI-specific details for the quota exhaustion response.
98 */
99 readonly openai?: OpenAiErrorMetadata | null
100 }
101
102 /**
103 * OpenAI metadata attached to `AuthenticationError` values.
104 *
105 * **Details**
106 *
107 * Preserves provider error details for failed API key, authorization, or
108 * permission checks.
109 *
110 * @category models
111 * @since 4.0.0
112 */
113 export interface AuthenticationErrorMetadata {
114 /**
115 * OpenAI-specific details for the authentication failure.
116 */
117 readonly openai?: OpenAiErrorMetadata | null
118 }
119
120 /**
121 * OpenAI metadata attached to `ContentPolicyError` values.
122 *
123 * **Details**
124 *
125 * Preserves provider error details when OpenAI rejects input or output because
126 * it violates a content policy.
127 *
128 * @category models
129 * @since 4.0.0
130 */
131 export interface ContentPolicyErrorMetadata {
132 /**
133 * OpenAI-specific details for the content policy response.
134 */
135 readonly openai?: OpenAiErrorMetadata | null
136 }
137
138 /**
139 * OpenAI metadata attached to `InvalidRequestError` values.
140 *
141 * **Details**
142 *
143 * Preserves provider error details for malformed requests, unsupported
144 * parameters, or other request validation failures reported by OpenAI.
145 *
146 * @category models
147 * @since 4.0.0
148 */
149 export interface InvalidRequestErrorMetadata {
150 /**
151 * OpenAI-specific details for the invalid request response.
152 */
153 readonly openai?: OpenAiErrorMetadata | null
154 }
155
156 /**
157 * OpenAI metadata attached to `InternalProviderError` values.
158 *
159 * **Details**
160 *
161 * Preserves provider error details for OpenAI-side failures such as transient
162 * server errors.
163 *
164 * @category models
165 * @since 4.0.0
166 */
167 export interface InternalProviderErrorMetadata {
168 /**
169 * OpenAI-specific details for the internal provider response.
170 */
171 readonly openai?: OpenAiErrorMetadata | null
172 }
173
174 /**
175 * OpenAI metadata attached to `InvalidOutputError` values.
176 *
177 * **Details**
178 *
179 * Preserves provider error details when an OpenAI response cannot be parsed or
180 * validated as the expected output.
181 *
182 * @category models
183 * @since 4.0.0
184 */
185 export interface InvalidOutputErrorMetadata {
186 /**
187 * OpenAI-specific details for the invalid output response.
188 */
189 readonly openai?: OpenAiErrorMetadata | null
190 }
191
192 /**
193 * OpenAI metadata attached to `StructuredOutputError` values.
194 *
195 * **Details**
196 *
197 * Preserves provider error details when OpenAI returns content that does not
198 * satisfy the requested structured output schema.
199 *
200 * @category models
201 * @since 4.0.0
202 */
203 export interface StructuredOutputErrorMetadata {
204 /**
205 * OpenAI-specific details for the structured output failure.
206 */
207 readonly openai?: OpenAiErrorMetadata | null
208 }
209
210 /**
211 * OpenAI metadata attached to `UnsupportedSchemaError` values.
212 *
213 * **Details**
214 *
215 * Preserves provider error details when an unsupported schema failure is
216 * associated with an OpenAI response.
217 *
218 * @category models
219 * @since 4.0.0
220 */
221 export interface UnsupportedSchemaErrorMetadata {
222 /**
223 * OpenAI-specific details for the unsupported schema failure.
224 */
225 readonly openai?: OpenAiErrorMetadata | null
226 }
227
228 /**
229 * OpenAI metadata attached to `UnknownError` values.
230 *
231 * **Details**
232 *
233 * Preserves provider error details for OpenAI failures that do not map cleanly
234 * to a more specific AI error category.
235 *
236 * @category models
237 * @since 4.0.0
238 */
239 export interface UnknownErrorMetadata {
240 /**
241 * OpenAI-specific details for the unclassified provider failure.
242 */
243 readonly openai?: OpenAiErrorMetadata | null
244 }
245 }