@mastra/code-sdk 1.15.1-alpha.5 → 1.16.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/runtime.d.ts.map +1 -1
- package/dist/acp/runtime.js +4 -2
- package/dist/acp/runtime.js.map +1 -1
- package/dist/agents/subagents/index.d.ts +6 -0
- package/dist/agents/subagents/index.d.ts.map +1 -0
- package/dist/agents/subagents/index.js +17 -0
- package/dist/agents/subagents/index.js.map +1 -0
- package/dist/auth/account-rotation-processor.d.ts +6 -6
- package/dist/auth/account-rotation-processor.d.ts.map +1 -1
- package/dist/auth/account-rotation-processor.js +40 -49
- package/dist/auth/account-rotation-processor.js.map +1 -1
- package/dist/headless/cli.d.ts.map +1 -1
- package/dist/headless/cli.js +3 -1
- package/dist/headless/cli.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -13
- package/dist/index.js.map +1 -1
- package/dist/utils/errors.d.ts +1 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +98 -78
- package/dist/utils/errors.js.map +1 -1
- package/package.json +13 -13
package/dist/utils/errors.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface ParsedError {
|
|
|
18
18
|
/** Original error for debugging */
|
|
19
19
|
originalError: Error;
|
|
20
20
|
}
|
|
21
|
-
export type ErrorType = 'rate_limit' | 'auth' | 'network' | 'timeout' | 'invalid_request' | 'server_error' | 'model_not_found' | 'context_length' | 'content_filter' | 'unknown';
|
|
21
|
+
export type ErrorType = 'rate_limit' | 'quota' | 'auth' | 'network' | 'timeout' | 'invalid_request' | 'server_error' | 'model_not_found' | 'context_length' | 'content_filter' | 'unknown';
|
|
22
22
|
export declare function parseError(error: unknown): ParsedError;
|
|
23
23
|
/**
|
|
24
24
|
* Sleep for a given number of milliseconds.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,IAAI,EAAE,SAAS,CAAC;IAChB,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,aAAa,EAAE,KAAK,CAAC;CACtB;AAED,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,iBAAiB,GACjB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,SAAS,CAAC;AAuId,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CA0GtD;AAkDD;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD,GACL,OAAO,CAAC,CAAC,CAAC,CA6BZ"}
|
package/dist/utils/errors.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../auth/provider-auth-error.js";
|
|
2
|
+
import { classifyProviderError } from "@mastra/core/error";
|
|
2
3
|
// src/utils/errors.ts
|
|
3
4
|
/**
|
|
4
5
|
* Error handling utilities for the Mastra Code TUI.
|
|
@@ -47,10 +48,26 @@ function toError(error) {
|
|
|
47
48
|
rebuilt.name = error.name;
|
|
48
49
|
return rebuilt;
|
|
49
50
|
}
|
|
51
|
+
function errorTypeOf(error, message, status) {
|
|
52
|
+
const kind = classifyProviderError(typeof status === "number" ? {
|
|
53
|
+
statusCode: status,
|
|
54
|
+
cause: error
|
|
55
|
+
} : error);
|
|
56
|
+
if (kind === "quota") return "quota";
|
|
57
|
+
if (kind === "rate_limited" || status === 429 || message.includes("429")) return "rate_limit";
|
|
58
|
+
if (kind === "auth" || status === 401 || status === 403 || kind !== "unavailable" && (message.includes("unauthorized") || message.includes("authentication") || message.includes("api key"))) return "auth";
|
|
59
|
+
if (message.includes("network") || message.includes("econnrefused") || message.includes("enotfound") || message.includes("fetch failed") || message.includes("connection")) return "network";
|
|
60
|
+
if (kind === "timeout") return "timeout";
|
|
61
|
+
if (kind === "model_rejected" || message.includes("does not exist")) return "model_not_found";
|
|
62
|
+
if (kind === "context_overflow" || message.includes("context length") || message.includes("too many tokens") || message.includes("token limit")) return "context_length";
|
|
63
|
+
if (message.includes("content filter") || message.includes("content_filter") || message.includes("content policy") || message.includes("safety") || message.includes("prohibited")) return "content_filter";
|
|
64
|
+
if (kind === "unavailable" || typeof status === "number" && status >= 500 && status < 600) return "server_error";
|
|
65
|
+
if (kind === "invalid_request" || kind === "tool_history_rejected" || status === 400 || message.includes("invalid request") || message.includes("bad request")) return "invalid_request";
|
|
66
|
+
return "unknown";
|
|
67
|
+
}
|
|
50
68
|
function parseError(error) {
|
|
51
69
|
const err = toError(error);
|
|
52
|
-
const
|
|
53
|
-
const errorObj = error;
|
|
70
|
+
const errorObj = typeof error === "object" && error !== null ? error : {};
|
|
54
71
|
const detail = summarizeErrorDetail(error);
|
|
55
72
|
const requestUrl = extractRequestUrl(error);
|
|
56
73
|
if (err.name === "ProviderAuthRequiredError") return {
|
|
@@ -61,82 +78,85 @@ function parseError(error) {
|
|
|
61
78
|
retryable: false,
|
|
62
79
|
originalError: err
|
|
63
80
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
81
|
+
const type = errorTypeOf(error, err.message.toLowerCase(), errorObj.statusCode ?? errorObj.status);
|
|
82
|
+
switch (type) {
|
|
83
|
+
case "quota": return {
|
|
84
|
+
message: "Usage quota exhausted for this provider account.",
|
|
85
|
+
detail,
|
|
86
|
+
requestUrl,
|
|
87
|
+
type,
|
|
88
|
+
retryable: false,
|
|
89
|
+
originalError: err
|
|
90
|
+
};
|
|
91
|
+
case "rate_limit": return {
|
|
92
|
+
message: "Rate limited. Please wait a moment before trying again.",
|
|
93
|
+
type,
|
|
94
|
+
retryable: true,
|
|
95
|
+
retryDelay: extractRetryAfter(errorObj) || 5e3,
|
|
96
|
+
originalError: err
|
|
97
|
+
};
|
|
98
|
+
case "auth": return {
|
|
99
|
+
message: (errorObj.statusCode ?? errorObj.status) === 403 ? "Access denied. You may not have permission to use this model." : "Authentication failed. Check the credential configured for this provider.",
|
|
100
|
+
detail,
|
|
101
|
+
requestUrl,
|
|
102
|
+
type,
|
|
103
|
+
retryable: false,
|
|
104
|
+
originalError: err
|
|
105
|
+
};
|
|
106
|
+
case "network": return {
|
|
107
|
+
message: "Network error while contacting the provider or gateway.",
|
|
108
|
+
detail,
|
|
109
|
+
requestUrl,
|
|
110
|
+
type,
|
|
111
|
+
retryable: true,
|
|
112
|
+
retryDelay: 2e3,
|
|
113
|
+
originalError: err
|
|
114
|
+
};
|
|
115
|
+
case "timeout": return {
|
|
116
|
+
message: "Request timed out. The server may be overloaded.",
|
|
117
|
+
type,
|
|
118
|
+
retryable: true,
|
|
119
|
+
retryDelay: 3e3,
|
|
120
|
+
originalError: err
|
|
121
|
+
};
|
|
122
|
+
case "model_not_found": return {
|
|
123
|
+
message: "Model not found. Please select a different model with /models.",
|
|
124
|
+
type,
|
|
125
|
+
retryable: false,
|
|
126
|
+
originalError: err
|
|
127
|
+
};
|
|
128
|
+
case "context_length": return {
|
|
129
|
+
message: "Message too long. Try starting a new thread with /new.",
|
|
130
|
+
type,
|
|
131
|
+
retryable: false,
|
|
132
|
+
originalError: err
|
|
133
|
+
};
|
|
134
|
+
case "content_filter": return {
|
|
135
|
+
message: "Content was filtered by the model's safety system.",
|
|
136
|
+
type,
|
|
137
|
+
retryable: false,
|
|
138
|
+
originalError: err
|
|
139
|
+
};
|
|
140
|
+
case "server_error": return {
|
|
141
|
+
message: "Server error. The API may be experiencing issues.",
|
|
142
|
+
type,
|
|
143
|
+
retryable: true,
|
|
144
|
+
retryDelay: 5e3,
|
|
145
|
+
originalError: err
|
|
146
|
+
};
|
|
147
|
+
case "invalid_request": return {
|
|
148
|
+
message: `Invalid request: ${extractErrorDetail(err)}`,
|
|
149
|
+
type,
|
|
150
|
+
retryable: false,
|
|
151
|
+
originalError: err
|
|
152
|
+
};
|
|
153
|
+
case "unknown": return {
|
|
154
|
+
message: extractErrorDetail(err),
|
|
155
|
+
type,
|
|
156
|
+
retryable: false,
|
|
157
|
+
originalError: err
|
|
158
|
+
};
|
|
159
|
+
}
|
|
140
160
|
}
|
|
141
161
|
/**
|
|
142
162
|
* Extract retry-after header value from error.
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/**\n * Error handling utilities for the Mastra Code TUI.\n * Parses API errors and provides user-friendly messages.\n */\n\nimport { PROVIDER_AUTH_REQUIRED_ERROR } from '../auth/provider-auth-error.js';\n\nexport interface ParsedError {\n /** User-friendly error message */\n message: string;\n /** Extra diagnostic detail to surface to the user */\n detail?: string;\n /** Request URL involved in the failure, when available */\n requestUrl?: string;\n /** Error type for categorization */\n type: ErrorType;\n /** Whether this error is retryable */\n retryable: boolean;\n /** Suggested retry delay in ms (if retryable) */\n retryDelay?: number;\n /** Original error for debugging */\n originalError: Error;\n}\n\nexport type ErrorType =\n | 'rate_limit'\n | 'auth'\n | 'network'\n | 'timeout'\n | 'invalid_request'\n | 'server_error'\n | 'model_not_found'\n | 'context_length'\n | 'content_filter'\n | 'unknown';\n\n/**\n * Parse an error and return a user-friendly representation.\n */\nfunction summarizeErrorDetail(error: unknown): string | undefined {\n if (error instanceof Error) {\n if (error.cause instanceof Error && error.cause.message) {\n return error.cause.message;\n }\n\n if (typeof error.cause === 'string' && error.cause.trim().length > 0) {\n return error.cause;\n }\n\n if (error.message.trim().length > 0) {\n return error.message;\n }\n }\n\n if (typeof error === 'string' && error.trim().length > 0) {\n return error;\n }\n\n if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n const candidates = [errorObj['message'], errorObj['cause'], errorObj['code'], errorObj['statusText']];\n\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length > 0) {\n return candidate;\n }\n }\n }\n\n return undefined;\n}\n\nfunction extractRequestUrl(error: unknown): string | undefined {\n if (!error || typeof error !== 'object') {\n return undefined;\n }\n\n const candidates: unknown[] = [];\n const errorObj = error as Record<string, unknown>;\n candidates.push(errorObj['requestUrl'], errorObj['url']);\n\n if (errorObj['cause'] && typeof errorObj['cause'] === 'object') {\n const causeObj = errorObj['cause'] as Record<string, unknown>;\n candidates.push(causeObj['requestUrl'], causeObj['url']);\n }\n\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length > 0) {\n return candidate;\n }\n }\n\n return undefined;\n}\n\n/** A flattened error crossing the wire: the server sends `{ name, message }`, not an `Error`. */\nfunction isSerializedError(value: unknown): value is { name: string; message: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'name' in value &&\n typeof value.name === 'string' &&\n 'message' in value &&\n typeof value.message === 'string'\n );\n}\n\nfunction toError(error: unknown): Error {\n if (error instanceof Error) return error;\n if (!isSerializedError(error)) return new Error(String(error));\n const rebuilt = new Error(error.message);\n rebuilt.name = error.name;\n return rebuilt;\n}\n\nexport function parseError(error: unknown): ParsedError {\n const err = toError(error);\n const message = err.message.toLowerCase();\n const errorObj = error as Record<string, unknown>;\n const detail = summarizeErrorDetail(error);\n const requestUrl = extractRequestUrl(error);\n\n // Matched by name, not instance: the error may have crossed a serialization boundary.\n if (err.name === PROVIDER_AUTH_REQUIRED_ERROR) {\n return { message: err.message, detail, requestUrl, type: 'auth', retryable: false, originalError: err };\n }\n\n // Check for rate limiting\n if (\n message.includes('rate limit') ||\n message.includes('rate_limit') ||\n message.includes('429') ||\n errorObj.statusCode === 429 ||\n errorObj.status === 429\n ) {\n const retryAfter = extractRetryAfter(errorObj);\n return {\n message: 'Rate limited. Please wait a moment before trying again.',\n type: 'rate_limit',\n retryable: true,\n retryDelay: retryAfter || 5000,\n originalError: err,\n };\n }\n\n // Check for authentication errors\n if (\n message.includes('unauthorized') ||\n message.includes('authentication') ||\n message.includes('invalid api key') ||\n message.includes('invalid_api_key') ||\n message.includes('api key') ||\n errorObj.statusCode === 401 ||\n errorObj.status === 401\n ) {\n return {\n message: 'Authentication failed. Check the credential configured for this provider.',\n detail,\n requestUrl,\n type: 'auth',\n retryable: false,\n originalError: err,\n };\n }\n\n // Check for forbidden/permission errors\n if (errorObj.statusCode === 403 || errorObj.status === 403) {\n return {\n message: 'Access denied. You may not have permission to use this model.',\n detail,\n requestUrl,\n type: 'auth',\n retryable: false,\n originalError: err,\n };\n }\n\n // Check for network errors\n if (\n message.includes('network') ||\n message.includes('econnrefused') ||\n message.includes('enotfound') ||\n message.includes('fetch failed') ||\n message.includes('connection')\n ) {\n return {\n message: 'Network error while contacting the provider or gateway.',\n detail,\n requestUrl,\n type: 'network',\n retryable: true,\n retryDelay: 2000,\n originalError: err,\n };\n }\n\n // Check for timeout errors\n if (message.includes('timeout') || message.includes('timed out') || message.includes('etimedout')) {\n return {\n message: 'Request timed out. The server may be overloaded.',\n type: 'timeout',\n retryable: true,\n retryDelay: 3000,\n originalError: err,\n };\n }\n\n // Check for model not found\n if (\n message.includes('model not found') ||\n message.includes('model_not_found') ||\n message.includes('does not exist') ||\n message.includes('invalid model')\n ) {\n return {\n message: 'Model not found. Please select a different model with /models.',\n type: 'model_not_found',\n retryable: false,\n originalError: err,\n };\n }\n\n // Check for context length errors\n if (\n message.includes('context length') ||\n message.includes('context_length') ||\n message.includes('too many tokens') ||\n message.includes('maximum context') ||\n message.includes('token limit')\n ) {\n return {\n message: 'Message too long. Try starting a new thread with /new.',\n type: 'context_length',\n retryable: false,\n originalError: err,\n };\n }\n\n // Check for content filter errors\n if (\n message.includes('content filter') ||\n message.includes('content_filter') ||\n message.includes('content policy') ||\n message.includes('safety') ||\n message.includes('prohibited')\n ) {\n return {\n message: \"Content was filtered by the model's safety system.\",\n type: 'content_filter',\n retryable: false,\n originalError: err,\n };\n }\n\n // Check for server errors\n if (\n message.includes('internal server') ||\n message.includes('server error') ||\n errorObj.statusCode === 500 ||\n errorObj.status === 500 ||\n errorObj.statusCode === 502 ||\n errorObj.status === 502 ||\n errorObj.statusCode === 503 ||\n errorObj.status === 503\n ) {\n return {\n message: 'Server error. The API may be experiencing issues.',\n type: 'server_error',\n retryable: true,\n retryDelay: 5000,\n originalError: err,\n };\n }\n\n // Check for invalid request errors\n if (\n message.includes('invalid request') ||\n message.includes('bad request') ||\n errorObj.statusCode === 400 ||\n errorObj.status === 400\n ) {\n return {\n message: `Invalid request: ${extractErrorDetail(err)}`,\n type: 'invalid_request',\n retryable: false,\n originalError: err,\n };\n }\n\n // Unknown error - try to extract useful info\n return {\n message: extractErrorDetail(err),\n type: 'unknown',\n retryable: false,\n originalError: err,\n };\n}\n\n/**\n * Extract retry-after header value from error.\n */\nfunction extractRetryAfter(error: Record<string, unknown>): number | undefined {\n const headers = error.headers as Record<string, unknown> | undefined;\n const retryAfter = error.retryAfter || headers?.['retry-after'];\n if (typeof retryAfter === 'number') {\n return retryAfter * 1000; // Convert seconds to ms\n }\n if (typeof retryAfter === 'string') {\n const seconds = parseInt(retryAfter, 10);\n if (!isNaN(seconds)) {\n return seconds * 1000;\n }\n }\n return undefined;\n}\n\n/**\n * Extract a useful error detail from an error object.\n */\nfunction extractErrorDetail(error: Error): string {\n const errorObj = error as unknown as Record<string, unknown>;\n\n // Try to get a specific error message from common API error formats\n if (errorObj.error && typeof errorObj.error === 'object') {\n const apiError = errorObj.error as Record<string, unknown>;\n if (apiError.message) return String(apiError.message);\n }\n\n if (errorObj.message) return String(errorObj.message);\n if (errorObj.detail) return String(errorObj.detail);\n if (errorObj.reason) return String(errorObj.reason);\n\n // Clean up the error message\n let message = error.message;\n\n // Remove common prefixes\n message = message.replace(/^(error|exception|failed):\\s*/i, '');\n\n // Truncate very long messages\n if (message.length > 200) {\n message = message.substring(0, 200) + '...';\n }\n\n return message || 'An unknown error occurred';\n}\n\n/**\n * Sleep for a given number of milliseconds.\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Retry a function with exponential backoff.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n options: {\n maxRetries?: number;\n initialDelay?: number;\n maxDelay?: number;\n onRetry?: (error: ParsedError, attempt: number) => void;\n } = {},\n): Promise<T> {\n const { maxRetries = 3, initialDelay = 1000, maxDelay = 30000, onRetry } = options;\n\n let lastError: ParsedError | undefined;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = parseError(error);\n\n // Don't retry non-retryable errors\n if (!lastError.retryable || attempt === maxRetries) {\n throw lastError.originalError;\n }\n\n // Calculate delay with exponential backoff\n const delay = Math.min(lastError.retryDelay || initialDelay * Math.pow(2, attempt), maxDelay);\n\n if (onRetry) {\n onRetry(lastError, attempt + 1);\n }\n\n await sleep(delay);\n }\n }\n\n // Should never reach here, but TypeScript needs this\n throw lastError?.originalError || new Error('Retry failed');\n}\n"],"mappings":";;;;;;;;;AAuCA,SAAS,qBAAqB,OAAoC;CAChE,IAAI,iBAAiB,OAAO;EAC1B,IAAI,MAAM,iBAAiB,SAAS,MAAM,MAAM,SAC9C,OAAO,MAAM,MAAM;EAGrB,IAAI,OAAO,MAAM,UAAU,YAAY,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,GACjE,OAAO,MAAM;EAGf,IAAI,MAAM,QAAQ,KAAK,CAAC,CAAC,SAAS,GAChC,OAAO,MAAM;CAEjB;CAEA,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,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AM,WAAW,SAAS;EAC1B,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS,OAAO;CACtD;CAEA,IAAI,SAAS,SAAS,OAAO,OAAO,SAAS,OAAO;CACpD,IAAI,SAAS,QAAQ,OAAO,OAAO,SAAS,MAAM;CAClD,IAAI,SAAS,QAAQ,OAAO,OAAO,SAAS,MAAM;CAGlD,IAAI,UAAU,MAAM;CAGpB,UAAU,QAAQ,QAAQ,kCAAkC,EAAE;CAG9D,IAAI,QAAQ,SAAS,KACnB,UAAU,QAAQ,UAAU,GAAG,GAAG,IAAI;CAGxC,OAAO,WAAW;AACpB;;;;AAKA,SAAgB,MAAM,IAA2B;CAC/C,OAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,EAAE,CAAC;AACvD;;;;AAKA,eAAsB,UACpB,IACA,UAKI,CAAC,GACO;CACZ,MAAM,EAAE,aAAa,GAAG,eAAe,KAAM,WAAW,KAAO,YAAY;CAE3E,IAAI;CAEJ,KAAK,IAAI,UAAU,GAAG,WAAW,YAAY,WAC3C,IAAI;EACF,OAAO,MAAM,GAAG;CAClB,SAAS,OAAO;EACd,YAAY,WAAW,KAAK;EAG5B,IAAI,CAAC,UAAU,aAAa,YAAY,YACtC,MAAM,UAAU;EAIlB,MAAM,QAAQ,KAAK,IAAI,UAAU,cAAc,eAAe,KAAK,IAAI,GAAG,OAAO,GAAG,QAAQ;EAE5F,IAAI,SACF,QAAQ,WAAW,UAAU,CAAC;EAGhC,MAAM,MAAM,KAAK;CACnB;CAIF,MAAM,WAAW,iCAAiB,IAAI,MAAM,cAAc;AAC5D"}
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../../src/utils/errors.ts"],"sourcesContent":["/**\n * Error handling utilities for the Mastra Code TUI.\n * Parses API errors and provides user-friendly messages.\n */\n\nimport { classifyProviderError } from '@mastra/core/error';\n\nimport { PROVIDER_AUTH_REQUIRED_ERROR } from '../auth/provider-auth-error.js';\n\nexport interface ParsedError {\n /** User-friendly error message */\n message: string;\n /** Extra diagnostic detail to surface to the user */\n detail?: string;\n /** Request URL involved in the failure, when available */\n requestUrl?: string;\n /** Error type for categorization */\n type: ErrorType;\n /** Whether this error is retryable */\n retryable: boolean;\n /** Suggested retry delay in ms (if retryable) */\n retryDelay?: number;\n /** Original error for debugging */\n originalError: Error;\n}\n\nexport type ErrorType =\n | 'rate_limit'\n | 'quota'\n | 'auth'\n | 'network'\n | 'timeout'\n | 'invalid_request'\n | 'server_error'\n | 'model_not_found'\n | 'context_length'\n | 'content_filter'\n | 'unknown';\n\n/**\n * Parse an error and return a user-friendly representation.\n */\nfunction summarizeErrorDetail(error: unknown): string | undefined {\n if (error instanceof Error) {\n if (error.cause instanceof Error && error.cause.message) {\n return error.cause.message;\n }\n\n if (typeof error.cause === 'string' && error.cause.trim().length > 0) {\n return error.cause;\n }\n\n if (error.message.trim().length > 0) {\n return error.message;\n }\n }\n\n if (typeof error === 'string' && error.trim().length > 0) {\n return error;\n }\n\n if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n const candidates = [errorObj['message'], errorObj['cause'], errorObj['code'], errorObj['statusText']];\n\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length > 0) {\n return candidate;\n }\n }\n }\n\n return undefined;\n}\n\nfunction extractRequestUrl(error: unknown): string | undefined {\n if (!error || typeof error !== 'object') {\n return undefined;\n }\n\n const candidates: unknown[] = [];\n const errorObj = error as Record<string, unknown>;\n candidates.push(errorObj['requestUrl'], errorObj['url']);\n\n if (errorObj['cause'] && typeof errorObj['cause'] === 'object') {\n const causeObj = errorObj['cause'] as Record<string, unknown>;\n candidates.push(causeObj['requestUrl'], causeObj['url']);\n }\n\n for (const candidate of candidates) {\n if (typeof candidate === 'string' && candidate.trim().length > 0) {\n return candidate;\n }\n }\n\n return undefined;\n}\n\n/** A flattened error crossing the wire: the server sends `{ name, message }`, not an `Error`. */\nfunction isSerializedError(value: unknown): value is { name: string; message: string } {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'name' in value &&\n typeof value.name === 'string' &&\n 'message' in value &&\n typeof value.message === 'string'\n );\n}\n\nfunction toError(error: unknown): Error {\n if (error instanceof Error) return error;\n if (!isSerializedError(error)) return new Error(String(error));\n const rebuilt = new Error(error.message);\n rebuilt.name = error.name;\n return rebuilt;\n}\n\nfunction errorTypeOf(error: unknown, message: string, status: unknown): ErrorType {\n const kind = classifyProviderError(typeof status === 'number' ? { statusCode: status, cause: error } : error);\n if (kind === 'quota') return 'quota';\n if (kind === 'rate_limited' || status === 429 || message.includes('429')) return 'rate_limit';\n if (\n kind === 'auth' ||\n status === 401 ||\n status === 403 ||\n (kind !== 'unavailable' &&\n (message.includes('unauthorized') || message.includes('authentication') || message.includes('api key')))\n ) {\n return 'auth';\n }\n if (\n message.includes('network') ||\n message.includes('econnrefused') ||\n message.includes('enotfound') ||\n message.includes('fetch failed') ||\n message.includes('connection')\n ) {\n return 'network';\n }\n if (kind === 'timeout') return 'timeout';\n if (kind === 'model_rejected' || message.includes('does not exist')) return 'model_not_found';\n if (\n kind === 'context_overflow' ||\n message.includes('context length') ||\n message.includes('too many tokens') ||\n message.includes('token limit')\n ) {\n return 'context_length';\n }\n if (\n message.includes('content filter') ||\n message.includes('content_filter') ||\n message.includes('content policy') ||\n message.includes('safety') ||\n message.includes('prohibited')\n ) {\n return 'content_filter';\n }\n if (kind === 'unavailable' || (typeof status === 'number' && status >= 500 && status < 600)) return 'server_error';\n if (\n kind === 'invalid_request' ||\n kind === 'tool_history_rejected' ||\n status === 400 ||\n message.includes('invalid request') ||\n message.includes('bad request')\n ) {\n return 'invalid_request';\n }\n return 'unknown';\n}\n\nexport function parseError(error: unknown): ParsedError {\n const err = toError(error);\n const errorObj = (typeof error === 'object' && error !== null ? error : {}) as Record<string, unknown>;\n const detail = summarizeErrorDetail(error);\n const requestUrl = extractRequestUrl(error);\n\n // Matched by name, not instance: the error may have crossed a serialization boundary.\n if (err.name === PROVIDER_AUTH_REQUIRED_ERROR) {\n return { message: err.message, detail, requestUrl, type: 'auth', retryable: false, originalError: err };\n }\n\n const message = err.message.toLowerCase();\n const type = errorTypeOf(error, message, errorObj.statusCode ?? errorObj.status);\n\n switch (type) {\n case 'quota':\n return {\n message: 'Usage quota exhausted for this provider account.',\n detail,\n requestUrl,\n type,\n retryable: false,\n originalError: err,\n };\n case 'rate_limit':\n return {\n message: 'Rate limited. Please wait a moment before trying again.',\n type,\n retryable: true,\n retryDelay: extractRetryAfter(errorObj) || 5000,\n originalError: err,\n };\n case 'auth':\n return {\n message:\n (errorObj.statusCode ?? errorObj.status) === 403\n ? 'Access denied. You may not have permission to use this model.'\n : 'Authentication failed. Check the credential configured for this provider.',\n detail,\n requestUrl,\n type,\n retryable: false,\n originalError: err,\n };\n case 'network':\n return {\n message: 'Network error while contacting the provider or gateway.',\n detail,\n requestUrl,\n type,\n retryable: true,\n retryDelay: 2000,\n originalError: err,\n };\n case 'timeout':\n return {\n message: 'Request timed out. The server may be overloaded.',\n type,\n retryable: true,\n retryDelay: 3000,\n originalError: err,\n };\n case 'model_not_found':\n return {\n message: 'Model not found. Please select a different model with /models.',\n type,\n retryable: false,\n originalError: err,\n };\n case 'context_length':\n return {\n message: 'Message too long. Try starting a new thread with /new.',\n type,\n retryable: false,\n originalError: err,\n };\n case 'content_filter':\n return {\n message: \"Content was filtered by the model's safety system.\",\n type,\n retryable: false,\n originalError: err,\n };\n case 'server_error':\n return {\n message: 'Server error. The API may be experiencing issues.',\n type,\n retryable: true,\n retryDelay: 5000,\n originalError: err,\n };\n case 'invalid_request':\n return {\n message: `Invalid request: ${extractErrorDetail(err)}`,\n type,\n retryable: false,\n originalError: err,\n };\n case 'unknown':\n return {\n message: extractErrorDetail(err),\n type,\n retryable: false,\n originalError: err,\n };\n }\n}\n\n/**\n * Extract retry-after header value from error.\n */\nfunction extractRetryAfter(error: Record<string, unknown>): number | undefined {\n const headers = error.headers as Record<string, unknown> | undefined;\n const retryAfter = error.retryAfter || headers?.['retry-after'];\n if (typeof retryAfter === 'number') {\n return retryAfter * 1000; // Convert seconds to ms\n }\n if (typeof retryAfter === 'string') {\n const seconds = parseInt(retryAfter, 10);\n if (!isNaN(seconds)) {\n return seconds * 1000;\n }\n }\n return undefined;\n}\n\n/**\n * Extract a useful error detail from an error object.\n */\nfunction extractErrorDetail(error: Error): string {\n const errorObj = error as unknown as Record<string, unknown>;\n\n // Try to get a specific error message from common API error formats\n if (errorObj.error && typeof errorObj.error === 'object') {\n const apiError = errorObj.error as Record<string, unknown>;\n if (apiError.message) return String(apiError.message);\n }\n\n if (errorObj.message) return String(errorObj.message);\n if (errorObj.detail) return String(errorObj.detail);\n if (errorObj.reason) return String(errorObj.reason);\n\n // Clean up the error message\n let message = error.message;\n\n // Remove common prefixes\n message = message.replace(/^(error|exception|failed):\\s*/i, '');\n\n // Truncate very long messages\n if (message.length > 200) {\n message = message.substring(0, 200) + '...';\n }\n\n return message || 'An unknown error occurred';\n}\n\n/**\n * Sleep for a given number of milliseconds.\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * Retry a function with exponential backoff.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n options: {\n maxRetries?: number;\n initialDelay?: number;\n maxDelay?: number;\n onRetry?: (error: ParsedError, attempt: number) => void;\n } = {},\n): Promise<T> {\n const { maxRetries = 3, initialDelay = 1000, maxDelay = 30000, onRetry } = options;\n\n let lastError: ParsedError | undefined;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = parseError(error);\n\n // Don't retry non-retryable errors\n if (!lastError.retryable || attempt === maxRetries) {\n throw lastError.originalError;\n }\n\n // Calculate delay with exponential backoff\n const delay = Math.min(lastError.retryDelay || initialDelay * Math.pow(2, attempt), maxDelay);\n\n if (onRetry) {\n onRetry(lastError, attempt + 1);\n }\n\n await sleep(delay);\n }\n }\n\n // Should never reach here, but TypeScript needs this\n throw lastError?.originalError || new Error('Retry failed');\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AAK,IAAI,GAAG,OAAO,GAAG,QAAQ;EAE5F,IAAI,SACF,QAAQ,WAAW,UAAU,CAAC;EAGhC,MAAM,MAAM,KAAK;CACnB;CAIF,MAAM,WAAW,iCAAiB,IAAI,MAAM,cAAc;AAC5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/code-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0-alpha.7",
|
|
4
4
|
"description": "Mastra Code SDK: the agent core behind Mastra Code (everything except the TUI) — build your own UIs and surfaces on top of it",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@agentclientprotocol/sdk": "^0.21.1",
|
|
49
|
-
"@ai-sdk/amazon-bedrock": "^
|
|
49
|
+
"@ai-sdk/amazon-bedrock": "^5.0.124",
|
|
50
50
|
"@ai-sdk/anthropic": "^3.0.135",
|
|
51
51
|
"@ai-sdk/openai": "^3.0.131",
|
|
52
52
|
"@ai-sdk/openai-compatible": "^2.0.87",
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"yaml": "^2.9.1",
|
|
64
64
|
"zod": "^4.6.7",
|
|
65
65
|
"@mastra/agent-browser": "0.5.5-alpha.0",
|
|
66
|
-
"@mastra/client-js": "1.57.0-alpha.
|
|
67
|
-
"@mastra/duckdb": "1.16.0-alpha.
|
|
66
|
+
"@mastra/client-js": "1.57.0-alpha.6",
|
|
67
|
+
"@mastra/duckdb": "1.16.0-alpha.2",
|
|
68
68
|
"@mastra/github-signals": "0.5.2",
|
|
69
|
-
"@mastra/
|
|
70
|
-
"@mastra/
|
|
71
|
-
"@mastra/
|
|
72
|
-
"@mastra/
|
|
73
|
-
"@mastra/
|
|
74
|
-
"@mastra/memory": "1.39.1-alpha.2",
|
|
69
|
+
"@mastra/libsql": "1.27.1-alpha.1",
|
|
70
|
+
"@mastra/fastembed": "1.3.5-alpha.3",
|
|
71
|
+
"@mastra/mcp": "2.6.0-alpha.2",
|
|
72
|
+
"@mastra/memory": "1.39.1-alpha.3",
|
|
73
|
+
"@mastra/observability": "1.22.0-alpha.3",
|
|
75
74
|
"@mastra/schema-compat": "1.3.17-alpha.0",
|
|
76
75
|
"@mastra/stagehand": "0.3.7-alpha.1",
|
|
76
|
+
"@mastra/pg": "1.33.0-alpha.3",
|
|
77
77
|
"@mastra/tavily": "1.1.3",
|
|
78
|
-
"@mastra/
|
|
78
|
+
"@mastra/parallel": "0.1.4-alpha.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@copilotkit/aimock": "^1.46.0",
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
"tsx": "^4.23.15",
|
|
87
87
|
"typescript": "^6.0.3",
|
|
88
88
|
"vitest": "4.1.12",
|
|
89
|
+
"@internal/lint": "0.0.145",
|
|
89
90
|
"@internal/types-builder": "0.0.120",
|
|
90
91
|
"@internal/workspace-test-utils": "0.0.89",
|
|
91
|
-
"@
|
|
92
|
-
"@mastra/core": "1.80.0-alpha.4"
|
|
92
|
+
"@mastra/core": "1.80.0-alpha.6"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@mastra/core": ">=1.80.0-0 <2.0.0-0"
|