|
1 | 1 | import { z } from "zod"; |
2 | 2 |
|
3 | | -export type ErrorCode = |
4 | | - | "auth_token_missing" |
5 | | - | "auth_token_invalid" |
6 | | - | "auth_token_expired" |
7 | | - | "payment_method_required" |
8 | | - | "payment_method_failed" |
9 | | - | "subscription_past_due" |
10 | | - | "permission_access_denied" |
11 | | - | "permission_plan_required" |
12 | | - | "resource_user_not_found" |
13 | | - | "resource_project_not_found" |
14 | | - | "resource_thread_not_found" |
15 | | - | "resource_run_not_found" |
16 | | - | "resource_output_not_found" |
17 | | - | "resource_tool_not_found" |
18 | | - | "resource_skill_not_found" |
19 | | - | "request_body_invalid" |
20 | | - | "request_query_param_invalid" |
21 | | - | "request_path_param_invalid" |
22 | | - | "validation_model_unavailable" |
23 | | - | "validation_tool_not_registered" |
24 | | - | "idempotency_key_reused" |
25 | | - | "validation_byok_required" |
26 | | - | "conflict_request_in_flight" |
27 | | - | "conflict_run_already_active" |
28 | | - | "conflict_state_invalid" |
29 | | - | "rate_limit_exceeded" |
30 | | - | "quota_sandbox_hours_exhausted" |
31 | | - | "quota_composio_calls_exhausted" |
32 | | - | "byok_key_missing" |
33 | | - | "byok_key_invalid" |
34 | | - | "byok_key_quota_exhausted" |
35 | | - | "sandbox_disk_full" |
36 | | - | "sandbox_cpu_exhausted" |
37 | | - | "sandbox_start_failed" |
38 | | - | "sandbox_command_failed" |
39 | | - | "sandbox_process_limit_reached" |
40 | | - | "tool_validation_failed" |
41 | | - | "tool_execution_failed" |
42 | | - | "tool_execution_timeout" |
43 | | - | "upstream_llm_overloaded" |
44 | | - | "upstream_llm_failed" |
45 | | - | "upstream_llm_timeout" |
46 | | - | "upstream_sandbox_failed" |
47 | | - | "upstream_sandbox_timeout" |
48 | | - | "upstream_provider_outage" |
49 | | - | "repo_import_failed" |
50 | | - | "internal_service_error" |
51 | | - | "service_maintenance_unavailable"; |
| 3 | +export const ErrorCodeSchema = z.enum([ |
| 4 | + "auth_token_missing", |
| 5 | + "auth_token_invalid", |
| 6 | + "auth_token_expired", |
| 7 | + "payment_method_required", |
| 8 | + "payment_method_failed", |
| 9 | + "subscription_past_due", |
| 10 | + "permission_access_denied", |
| 11 | + "permission_plan_required", |
| 12 | + "resource_user_not_found", |
| 13 | + "resource_project_not_found", |
| 14 | + "resource_thread_not_found", |
| 15 | + "resource_run_not_found", |
| 16 | + "resource_output_not_found", |
| 17 | + "resource_tool_not_found", |
| 18 | + "resource_skill_not_found", |
| 19 | + "request_body_invalid", |
| 20 | + "request_query_param_invalid", |
| 21 | + "request_path_param_invalid", |
| 22 | + "validation_model_unavailable", |
| 23 | + "validation_tool_not_registered", |
| 24 | + "idempotency_key_reused", |
| 25 | + "validation_byok_required", |
| 26 | + "conflict_request_in_flight", |
| 27 | + "conflict_run_already_active", |
| 28 | + "conflict_state_invalid", |
| 29 | + "rate_limit_exceeded", |
| 30 | + "quota_sandbox_hours_exhausted", |
| 31 | + "quota_composio_calls_exhausted", |
| 32 | + "byok_key_missing", |
| 33 | + "byok_key_invalid", |
| 34 | + "byok_key_quota_exhausted", |
| 35 | + "sandbox_disk_full", |
| 36 | + "sandbox_cpu_exhausted", |
| 37 | + "sandbox_start_failed", |
| 38 | + "sandbox_command_failed", |
| 39 | + "sandbox_process_limit_reached", |
| 40 | + "tool_validation_failed", |
| 41 | + "tool_execution_failed", |
| 42 | + "tool_execution_timeout", |
| 43 | + "upstream_llm_overloaded", |
| 44 | + "upstream_llm_failed", |
| 45 | + "upstream_llm_timeout", |
| 46 | + "upstream_sandbox_failed", |
| 47 | + "upstream_sandbox_timeout", |
| 48 | + "upstream_provider_outage", |
| 49 | + "repo_import_failed", |
| 50 | + "internal_service_error", |
| 51 | + "service_maintenance_unavailable", |
| 52 | +]); |
| 53 | + |
| 54 | +export type ErrorCode = z.infer<typeof ErrorCodeSchema>; |
52 | 55 |
|
53 | 56 | export const ErrorResponseSchema = z.strictObject({ |
54 | 57 | error: z.strictObject({ |
55 | | - code: z.string(), |
| 58 | + code: ErrorCodeSchema, |
56 | 59 | message: z.string(), |
57 | 60 | hint: z.string().optional(), |
58 | 61 | retriable: z.boolean(), |
|
0 commit comments