@trishchuk/codex-mcp-tool 1.2.0 → 1.4.0
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/README.md +84 -170
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/ask-codex.tool.d.ts.map +1 -1
- package/dist/tools/ask-codex.tool.js +82 -54
- package/dist/tools/ask-codex.tool.js.map +1 -1
- package/dist/tools/batch-codex.tool.js +1 -1
- package/dist/tools/batch-codex.tool.js.map +1 -1
- package/dist/tools/health.tool.d.ts +3 -0
- package/dist/tools/health.tool.d.ts.map +1 -0
- package/dist/tools/health.tool.js +189 -0
- package/dist/tools/health.tool.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/list-sessions.tool.d.ts +3 -0
- package/dist/tools/list-sessions.tool.d.ts.map +1 -0
- package/dist/tools/list-sessions.tool.js +71 -0
- package/dist/tools/list-sessions.tool.js.map +1 -0
- package/dist/utils/codexCommandBuilder.d.ts +87 -0
- package/dist/utils/codexCommandBuilder.d.ts.map +1 -0
- package/dist/utils/codexCommandBuilder.js +285 -0
- package/dist/utils/codexCommandBuilder.js.map +1 -0
- package/dist/utils/codexExecutor.d.ts +12 -1
- package/dist/utils/codexExecutor.d.ts.map +1 -1
- package/dist/utils/codexExecutor.js +18 -181
- package/dist/utils/codexExecutor.js.map +1 -1
- package/dist/utils/commandExecutor.js +3 -3
- package/dist/utils/commandExecutor.js.map +1 -1
- package/dist/utils/errorTypes.d.ts +74 -0
- package/dist/utils/errorTypes.d.ts.map +1 -0
- package/dist/utils/errorTypes.js +268 -0
- package/dist/utils/errorTypes.js.map +1 -0
- package/dist/utils/modelDetection.d.ts +45 -0
- package/dist/utils/modelDetection.d.ts.map +1 -0
- package/dist/utils/modelDetection.js +148 -0
- package/dist/utils/modelDetection.js.map +1 -0
- package/dist/utils/sessionStorage.d.ts +79 -0
- package/dist/utils/sessionStorage.d.ts.map +1 -0
- package/dist/utils/sessionStorage.js +276 -0
- package/dist/utils/sessionStorage.js.map +1 -0
- package/dist/utils/versionDetection.d.ts +123 -0
- package/dist/utils/versionDetection.d.ts.map +1 -0
- package/dist/utils/versionDetection.js +188 -0
- package/dist/utils/versionDetection.js.map +1 -0
- package/dist/utils/workingDirResolver.d.ts +13 -8
- package/dist/utils/workingDirResolver.d.ts.map +1 -1
- package/dist/utils/workingDirResolver.js +44 -26
- package/dist/utils/workingDirResolver.js.map +1 -1
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandExecutor.js","sourceRoot":"","sources":["../../src/utils/commandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"commandExecutor.js","sourceRoot":"","sources":["../../src/utils/commandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAyBrC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAe,EACf,IAAc,EACd,UAA0B,EAAE;IAE5B,MAAM,EACJ,UAAU,EACV,SAAS,GAAG,MAAM,EAClB,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,eAAe;IAClD,KAAK,GACN,GAAG,OAAO,CAAC;IAEZ,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,MAAM,WAAW,GAAG,KAAK,EAAE,QAAQ,IAAI,CAAC,CAAC;IAEzC,OAAO,OAAO,GAAG,WAAW,EAAE,CAAC;QAC7B,OAAO,EAAE,CAAC;QACV,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE;YAC9C,UAAU;YACV,SAAS;YACT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,UAAU;QACV,SAAS;KACV,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,IAAI,eAAe,CAAC;QACtD,MAAM,IAAI,KAAK,CACb,MAAM,CAAC,QAAQ;YACb,CAAC,CAAC,2BAA2B,SAAS,IAAI;YAC1C,CAAC,CAAC,iCAAiC,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CACpE,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Error Types for Codex MCP Tool
|
|
3
|
+
* Provides typed error handling with 8 categories for better debugging and user feedback
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Error categories for classification
|
|
7
|
+
*/
|
|
8
|
+
export declare enum ErrorCategory {
|
|
9
|
+
CLI_NOT_FOUND = "CLI_NOT_FOUND",
|
|
10
|
+
AUTHENTICATION = "AUTHENTICATION",
|
|
11
|
+
RATE_LIMIT = "RATE_LIMIT",
|
|
12
|
+
TIMEOUT = "TIMEOUT",
|
|
13
|
+
SANDBOX = "SANDBOX",
|
|
14
|
+
NETWORK = "NETWORK",
|
|
15
|
+
SESSION = "SESSION",
|
|
16
|
+
UNKNOWN = "UNKNOWN"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* User-friendly error messages by category
|
|
20
|
+
*/
|
|
21
|
+
export declare const ERROR_MESSAGES: Record<ErrorCategory, {
|
|
22
|
+
title: string;
|
|
23
|
+
description: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Solutions/suggestions by error category
|
|
27
|
+
*/
|
|
28
|
+
export declare const ERROR_SOLUTIONS: Record<ErrorCategory, string[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Custom error class with category and structured data
|
|
31
|
+
*/
|
|
32
|
+
export declare class CodexError extends Error {
|
|
33
|
+
readonly category: ErrorCategory;
|
|
34
|
+
readonly originalError?: Error;
|
|
35
|
+
readonly context?: Record<string, unknown>;
|
|
36
|
+
constructor(category: ErrorCategory, message?: string, originalError?: Error, context?: Record<string, unknown>);
|
|
37
|
+
/**
|
|
38
|
+
* Get user-friendly error title
|
|
39
|
+
*/
|
|
40
|
+
get title(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Get solutions/suggestions for this error
|
|
43
|
+
*/
|
|
44
|
+
get solutions(): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Format error for display
|
|
47
|
+
*/
|
|
48
|
+
toUserFriendlyString(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Format as markdown
|
|
51
|
+
*/
|
|
52
|
+
toMarkdown(): string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Classify error message into category
|
|
56
|
+
*/
|
|
57
|
+
export declare function classifyError(errorMessage: string): ErrorCategory;
|
|
58
|
+
/**
|
|
59
|
+
* Create CodexError from generic error
|
|
60
|
+
*/
|
|
61
|
+
export declare function createCodexError(error: Error | string, context?: Record<string, unknown>): CodexError;
|
|
62
|
+
/**
|
|
63
|
+
* Format any error for user-friendly display
|
|
64
|
+
*/
|
|
65
|
+
export declare function formatErrorForUser(error: Error | string | CodexError): string;
|
|
66
|
+
/**
|
|
67
|
+
* Check if error is retryable
|
|
68
|
+
*/
|
|
69
|
+
export declare function isRetryableError(error: CodexError | ErrorCategory): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Get retry delay based on error category (in milliseconds)
|
|
72
|
+
*/
|
|
73
|
+
export declare function getRetryDelay(error: CodexError | ErrorCategory, attempt?: number): number;
|
|
74
|
+
//# sourceMappingURL=errorTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorTypes.d.ts","sourceRoot":"","sources":["../../src/utils/errorTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,aAAa;IACv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GAAG,MAAM,CAO7E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,GAAG,OAAO,CAU3E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,EAAE,OAAO,GAAE,MAAU,GAAG,MAAM,CAmB5F"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Error Types for Codex MCP Tool
|
|
3
|
+
* Provides typed error handling with 8 categories for better debugging and user feedback
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Error categories for classification
|
|
7
|
+
*/
|
|
8
|
+
export var ErrorCategory;
|
|
9
|
+
(function (ErrorCategory) {
|
|
10
|
+
ErrorCategory["CLI_NOT_FOUND"] = "CLI_NOT_FOUND";
|
|
11
|
+
ErrorCategory["AUTHENTICATION"] = "AUTHENTICATION";
|
|
12
|
+
ErrorCategory["RATE_LIMIT"] = "RATE_LIMIT";
|
|
13
|
+
ErrorCategory["TIMEOUT"] = "TIMEOUT";
|
|
14
|
+
ErrorCategory["SANDBOX"] = "SANDBOX";
|
|
15
|
+
ErrorCategory["NETWORK"] = "NETWORK";
|
|
16
|
+
ErrorCategory["SESSION"] = "SESSION";
|
|
17
|
+
ErrorCategory["UNKNOWN"] = "UNKNOWN";
|
|
18
|
+
})(ErrorCategory || (ErrorCategory = {}));
|
|
19
|
+
/**
|
|
20
|
+
* User-friendly error messages by category
|
|
21
|
+
*/
|
|
22
|
+
export const ERROR_MESSAGES = {
|
|
23
|
+
[ErrorCategory.CLI_NOT_FOUND]: {
|
|
24
|
+
title: 'Codex CLI Not Found',
|
|
25
|
+
description: 'Codex CLI is not installed or not in PATH.',
|
|
26
|
+
},
|
|
27
|
+
[ErrorCategory.AUTHENTICATION]: {
|
|
28
|
+
title: 'Authentication Failed',
|
|
29
|
+
description: 'API key is invalid or authentication is required.',
|
|
30
|
+
},
|
|
31
|
+
[ErrorCategory.RATE_LIMIT]: {
|
|
32
|
+
title: 'Rate Limit Exceeded',
|
|
33
|
+
description: 'Too many requests. Please wait and try again.',
|
|
34
|
+
},
|
|
35
|
+
[ErrorCategory.TIMEOUT]: {
|
|
36
|
+
title: 'Request Timeout',
|
|
37
|
+
description: 'Operation took longer than expected.',
|
|
38
|
+
},
|
|
39
|
+
[ErrorCategory.SANDBOX]: {
|
|
40
|
+
title: 'Sandbox Permission Error',
|
|
41
|
+
description: 'Operation blocked by sandbox restrictions.',
|
|
42
|
+
},
|
|
43
|
+
[ErrorCategory.NETWORK]: {
|
|
44
|
+
title: 'Network Error',
|
|
45
|
+
description: 'Failed to connect to API server.',
|
|
46
|
+
},
|
|
47
|
+
[ErrorCategory.SESSION]: {
|
|
48
|
+
title: 'Session Error',
|
|
49
|
+
description: 'Session is invalid, expired, or not found.',
|
|
50
|
+
},
|
|
51
|
+
[ErrorCategory.UNKNOWN]: {
|
|
52
|
+
title: 'Unknown Error',
|
|
53
|
+
description: 'An unexpected error occurred.',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Solutions/suggestions by error category
|
|
58
|
+
*/
|
|
59
|
+
export const ERROR_SOLUTIONS = {
|
|
60
|
+
[ErrorCategory.CLI_NOT_FOUND]: [
|
|
61
|
+
'Install Codex CLI: `npm install -g @openai/codex`',
|
|
62
|
+
'Verify installation: `codex --version`',
|
|
63
|
+
'Check PATH environment variable',
|
|
64
|
+
],
|
|
65
|
+
[ErrorCategory.AUTHENTICATION]: [
|
|
66
|
+
'Run `codex login` to authenticate',
|
|
67
|
+
'Set `OPENAI_API_KEY` environment variable',
|
|
68
|
+
'Verify API key has Codex access in OpenAI dashboard',
|
|
69
|
+
],
|
|
70
|
+
[ErrorCategory.RATE_LIMIT]: [
|
|
71
|
+
'Wait a few minutes before retrying',
|
|
72
|
+
'Check usage quotas in OpenAI dashboard',
|
|
73
|
+
'Consider using a less powerful model',
|
|
74
|
+
],
|
|
75
|
+
[ErrorCategory.TIMEOUT]: [
|
|
76
|
+
'Increase timeout: `timeout: 300000` (5 minutes)',
|
|
77
|
+
'Simplify request or break into smaller parts',
|
|
78
|
+
'Check network connectivity',
|
|
79
|
+
],
|
|
80
|
+
[ErrorCategory.SANDBOX]: [
|
|
81
|
+
'Use `sandboxMode: "workspace-write"` for file operations',
|
|
82
|
+
'Use `approval: "on-request"` for interactive approval',
|
|
83
|
+
'Use `fullAuto: true` for automated operations',
|
|
84
|
+
],
|
|
85
|
+
[ErrorCategory.NETWORK]: [
|
|
86
|
+
'Check internet connection',
|
|
87
|
+
'Verify firewall/proxy settings',
|
|
88
|
+
'Try again later - API may be experiencing issues',
|
|
89
|
+
],
|
|
90
|
+
[ErrorCategory.SESSION]: [
|
|
91
|
+
'Session may have expired (default TTL: 24 hours)',
|
|
92
|
+
'Use `list-sessions` to check active sessions',
|
|
93
|
+
'Create new session by omitting `sessionId`',
|
|
94
|
+
'Use `resetSession: true` to start fresh',
|
|
95
|
+
],
|
|
96
|
+
[ErrorCategory.UNKNOWN]: [
|
|
97
|
+
'Check Codex CLI: `codex --version`',
|
|
98
|
+
'Run `codex login` to verify authentication',
|
|
99
|
+
'Try simpler query to isolate the issue',
|
|
100
|
+
'Use `health` tool to diagnose',
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Custom error class with category and structured data
|
|
105
|
+
*/
|
|
106
|
+
export class CodexError extends Error {
|
|
107
|
+
category;
|
|
108
|
+
originalError;
|
|
109
|
+
context;
|
|
110
|
+
constructor(category, message, originalError, context) {
|
|
111
|
+
const errorInfo = ERROR_MESSAGES[category];
|
|
112
|
+
super(message || errorInfo.description);
|
|
113
|
+
this.name = 'CodexError';
|
|
114
|
+
this.category = category;
|
|
115
|
+
this.originalError = originalError;
|
|
116
|
+
this.context = context;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get user-friendly error title
|
|
120
|
+
*/
|
|
121
|
+
get title() {
|
|
122
|
+
return ERROR_MESSAGES[this.category].title;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get solutions/suggestions for this error
|
|
126
|
+
*/
|
|
127
|
+
get solutions() {
|
|
128
|
+
return ERROR_SOLUTIONS[this.category];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Format error for display
|
|
132
|
+
*/
|
|
133
|
+
toUserFriendlyString() {
|
|
134
|
+
const lines = [];
|
|
135
|
+
lines.push(`**${this.title}**: ${this.message}`);
|
|
136
|
+
lines.push('');
|
|
137
|
+
lines.push('**Solutions:**');
|
|
138
|
+
for (const solution of this.solutions) {
|
|
139
|
+
lines.push(`- ${solution}`);
|
|
140
|
+
}
|
|
141
|
+
return lines.join('\n');
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Format as markdown
|
|
145
|
+
*/
|
|
146
|
+
toMarkdown() {
|
|
147
|
+
const emoji = this.category === ErrorCategory.UNKNOWN ? '?' : '';
|
|
148
|
+
let output = `## ${emoji} ${this.title}\n\n`;
|
|
149
|
+
output += `${this.message}\n\n`;
|
|
150
|
+
output += `### Recommended Actions\n\n`;
|
|
151
|
+
for (const solution of this.solutions) {
|
|
152
|
+
output += `- ${solution}\n`;
|
|
153
|
+
}
|
|
154
|
+
if (this.context) {
|
|
155
|
+
output += `\n### Context\n\n`;
|
|
156
|
+
output += '```json\n';
|
|
157
|
+
output += JSON.stringify(this.context, null, 2);
|
|
158
|
+
output += '\n```\n';
|
|
159
|
+
}
|
|
160
|
+
return output;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Classify error message into category
|
|
165
|
+
*/
|
|
166
|
+
export function classifyError(errorMessage) {
|
|
167
|
+
const message = errorMessage.toLowerCase();
|
|
168
|
+
// CLI not found
|
|
169
|
+
if (message.includes('command not found') ||
|
|
170
|
+
message.includes('not found') ||
|
|
171
|
+
message.includes('enoent')) {
|
|
172
|
+
return ErrorCategory.CLI_NOT_FOUND;
|
|
173
|
+
}
|
|
174
|
+
// Authentication
|
|
175
|
+
if (message.includes('authentication') ||
|
|
176
|
+
message.includes('unauthorized') ||
|
|
177
|
+
message.includes('api key') ||
|
|
178
|
+
message.includes('401')) {
|
|
179
|
+
return ErrorCategory.AUTHENTICATION;
|
|
180
|
+
}
|
|
181
|
+
// Rate limiting
|
|
182
|
+
if (message.includes('rate limit') ||
|
|
183
|
+
message.includes('quota') ||
|
|
184
|
+
message.includes('too many requests') ||
|
|
185
|
+
message.includes('429')) {
|
|
186
|
+
return ErrorCategory.RATE_LIMIT;
|
|
187
|
+
}
|
|
188
|
+
// Timeout
|
|
189
|
+
if (message.includes('timeout') ||
|
|
190
|
+
message.includes('timed out') ||
|
|
191
|
+
message.includes('etimedout')) {
|
|
192
|
+
return ErrorCategory.TIMEOUT;
|
|
193
|
+
}
|
|
194
|
+
// Sandbox/Permission
|
|
195
|
+
if (message.includes('sandbox') ||
|
|
196
|
+
message.includes('permission') ||
|
|
197
|
+
message.includes('denied') ||
|
|
198
|
+
message.includes('access')) {
|
|
199
|
+
return ErrorCategory.SANDBOX;
|
|
200
|
+
}
|
|
201
|
+
// Network
|
|
202
|
+
if (message.includes('network') ||
|
|
203
|
+
message.includes('connect') ||
|
|
204
|
+
message.includes('econnrefused') ||
|
|
205
|
+
message.includes('enotfound')) {
|
|
206
|
+
return ErrorCategory.NETWORK;
|
|
207
|
+
}
|
|
208
|
+
// Session
|
|
209
|
+
if (message.includes('session') ||
|
|
210
|
+
message.includes('expired') ||
|
|
211
|
+
message.includes('conversation id')) {
|
|
212
|
+
return ErrorCategory.SESSION;
|
|
213
|
+
}
|
|
214
|
+
return ErrorCategory.UNKNOWN;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Create CodexError from generic error
|
|
218
|
+
*/
|
|
219
|
+
export function createCodexError(error, context) {
|
|
220
|
+
const message = error instanceof Error ? error.message : error;
|
|
221
|
+
const category = classifyError(message);
|
|
222
|
+
const originalError = error instanceof Error ? error : undefined;
|
|
223
|
+
return new CodexError(category, message, originalError, context);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Format any error for user-friendly display
|
|
227
|
+
*/
|
|
228
|
+
export function formatErrorForUser(error) {
|
|
229
|
+
if (error instanceof CodexError) {
|
|
230
|
+
return error.toUserFriendlyString();
|
|
231
|
+
}
|
|
232
|
+
const codexError = createCodexError(error);
|
|
233
|
+
return codexError.toUserFriendlyString();
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Check if error is retryable
|
|
237
|
+
*/
|
|
238
|
+
export function isRetryableError(error) {
|
|
239
|
+
const category = error instanceof CodexError ? error.category : error;
|
|
240
|
+
const retryableCategories = [
|
|
241
|
+
ErrorCategory.RATE_LIMIT,
|
|
242
|
+
ErrorCategory.TIMEOUT,
|
|
243
|
+
ErrorCategory.NETWORK,
|
|
244
|
+
];
|
|
245
|
+
return retryableCategories.includes(category);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Get retry delay based on error category (in milliseconds)
|
|
249
|
+
*/
|
|
250
|
+
export function getRetryDelay(error, attempt = 1) {
|
|
251
|
+
const category = error instanceof CodexError ? error.category : error;
|
|
252
|
+
const baseDelays = {
|
|
253
|
+
[ErrorCategory.RATE_LIMIT]: 60000, // 1 minute
|
|
254
|
+
[ErrorCategory.TIMEOUT]: 5000, // 5 seconds
|
|
255
|
+
[ErrorCategory.NETWORK]: 10000, // 10 seconds
|
|
256
|
+
[ErrorCategory.CLI_NOT_FOUND]: 0,
|
|
257
|
+
[ErrorCategory.AUTHENTICATION]: 0,
|
|
258
|
+
[ErrorCategory.SANDBOX]: 0,
|
|
259
|
+
[ErrorCategory.SESSION]: 0,
|
|
260
|
+
[ErrorCategory.UNKNOWN]: 5000,
|
|
261
|
+
};
|
|
262
|
+
const baseDelay = baseDelays[category];
|
|
263
|
+
// Exponential backoff with jitter
|
|
264
|
+
const delay = baseDelay * Math.pow(2, attempt - 1);
|
|
265
|
+
const jitter = Math.random() * 1000;
|
|
266
|
+
return Math.min(delay + jitter, 300000); // Max 5 minutes
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=errorTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorTypes.js","sourceRoot":"","sources":["../../src/utils/errorTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,aASX;AATD,WAAY,aAAa;IACvB,gDAA+B,CAAA;IAC/B,kDAAiC,CAAA;IACjC,0CAAyB,CAAA;IACzB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACrB,CAAC,EATW,aAAa,KAAb,aAAa,QASxB;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkE;IAC3F,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE;QAC7B,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EAAE,4CAA4C;KAC1D;IACD,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE;QAC9B,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EAAE,mDAAmD;KACjE;IACD,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QAC1B,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EAAE,+CAA+C;KAC7D;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,sCAAsC;KACpD;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,4CAA4C;KAC1D;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE,kCAAkC;KAChD;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE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,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1B,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI;KAC9B,CAAC;IAEF,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvC,kCAAkC;IAClC,MAAM,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;IAEpC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,gBAAgB;AAC3D,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model availability detection and fallback chain
|
|
3
|
+
* Ensures compatibility with different Codex CLI versions and user access levels
|
|
4
|
+
*/
|
|
5
|
+
export interface ModelInfo {
|
|
6
|
+
name: string;
|
|
7
|
+
available: boolean;
|
|
8
|
+
isDefault: boolean;
|
|
9
|
+
priority: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Check if a specific model is available via Codex CLI
|
|
13
|
+
*
|
|
14
|
+
* This function performs a real availability check by attempting to execute
|
|
15
|
+
* a minimal test prompt with the specified model. Results are cached for 5 minutes
|
|
16
|
+
* to reduce unnecessary CLI calls.
|
|
17
|
+
*
|
|
18
|
+
* @param modelName Model identifier to check (e.g., 'gpt-5.1-codex-max')
|
|
19
|
+
* @param bypassCache If true, ignores cache and forces fresh check
|
|
20
|
+
* @returns Promise<boolean> True if model is available and working
|
|
21
|
+
*/
|
|
22
|
+
export declare function isModelAvailable(modelName: string, bypassCache?: boolean): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Get the best available default model using fallback chain
|
|
25
|
+
* @returns Promise<string> The best available model name
|
|
26
|
+
*/
|
|
27
|
+
export declare function getDefaultModel(): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Validate if a user-specified model name is valid
|
|
30
|
+
* @param modelName User-provided model name
|
|
31
|
+
* @returns boolean True if model name exists in MODELS constant
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidModel(modelName: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get model name with fallback to default
|
|
36
|
+
* @param requestedModel User-requested model (optional)
|
|
37
|
+
* @returns Promise<string> Model name to use
|
|
38
|
+
*/
|
|
39
|
+
export declare function getModelWithFallback(requestedModel?: string): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Get all available models (for future use in model listing)
|
|
42
|
+
* @returns Promise<string[]> Array of available model names
|
|
43
|
+
*/
|
|
44
|
+
export declare function getAvailableModels(): Promise<string[]>;
|
|
45
|
+
//# sourceMappingURL=modelDetection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelDetection.d.ts","sourceRoot":"","sources":["../../src/utils/modelDetection.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAsBD;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,OAAe,GAC3B,OAAO,CAAC,OAAO,CAAC,CAwDlB;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAqBvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBnF;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAgB5D"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { MODELS } from '../constants.js';
|
|
2
|
+
import { Logger } from './logger.js';
|
|
3
|
+
import { executeCommand } from './commandExecutor.js';
|
|
4
|
+
const modelAvailabilityCache = new Map();
|
|
5
|
+
const CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
6
|
+
/**
|
|
7
|
+
* Priority-ordered fallback chain for default model selection
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_MODEL_FALLBACK = [
|
|
10
|
+
MODELS.GPT5_1_CODEX_MAX, // Highest priority: Latest frontier model
|
|
11
|
+
MODELS.GPT5_CODEX, // Fallback: Previous default
|
|
12
|
+
MODELS.GPT5, // Ultimate fallback: Base GPT-5
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Check if a specific model is available via Codex CLI
|
|
16
|
+
*
|
|
17
|
+
* This function performs a real availability check by attempting to execute
|
|
18
|
+
* a minimal test prompt with the specified model. Results are cached for 5 minutes
|
|
19
|
+
* to reduce unnecessary CLI calls.
|
|
20
|
+
*
|
|
21
|
+
* @param modelName Model identifier to check (e.g., 'gpt-5.1-codex-max')
|
|
22
|
+
* @param bypassCache If true, ignores cache and forces fresh check
|
|
23
|
+
* @returns Promise<boolean> True if model is available and working
|
|
24
|
+
*/
|
|
25
|
+
export async function isModelAvailable(modelName, bypassCache = false) {
|
|
26
|
+
// Check cache first (unless bypassed)
|
|
27
|
+
if (!bypassCache) {
|
|
28
|
+
const cached = modelAvailabilityCache.get(modelName);
|
|
29
|
+
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
30
|
+
Logger.debug(`Using cached availability for model ${modelName}: ${cached.available}`);
|
|
31
|
+
return cached.available;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
// Strategy 1: Try to execute a minimal test prompt with the model
|
|
36
|
+
// This is the most reliable way to check if model is truly available
|
|
37
|
+
Logger.debug(`Testing model availability: ${modelName}`);
|
|
38
|
+
try {
|
|
39
|
+
// Attempt a very quick test with the model (5 second timeout)
|
|
40
|
+
await executeCommand('codex', ['exec', '-m', modelName, 'echo test'], undefined, 5000);
|
|
41
|
+
Logger.debug(`Model ${modelName} is available (test execution succeeded)`);
|
|
42
|
+
// Cache positive result
|
|
43
|
+
modelAvailabilityCache.set(modelName, {
|
|
44
|
+
available: true,
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
});
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
catch (testError) {
|
|
50
|
+
// If test execution failed, check if Codex CLI itself is working
|
|
51
|
+
Logger.debug(`Model test failed for ${modelName}, checking Codex CLI availability`);
|
|
52
|
+
// Strategy 2: Fallback - check if Codex CLI is installed at all
|
|
53
|
+
await executeCommand('codex', ['--version'], undefined, 3000);
|
|
54
|
+
// If we reach here, Codex CLI works but model might not be available
|
|
55
|
+
// This could mean: model doesn't exist, user doesn't have access, or model name is wrong
|
|
56
|
+
Logger.warn(`Model ${modelName} test execution failed but Codex CLI is working. Model may not be available or accessible.`);
|
|
57
|
+
// Cache negative result (shorter TTL for potentially transient failures)
|
|
58
|
+
modelAvailabilityCache.set(modelName, {
|
|
59
|
+
available: false,
|
|
60
|
+
timestamp: Date.now(),
|
|
61
|
+
});
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// Complete failure - Codex CLI is not working at all
|
|
67
|
+
Logger.warn(`Codex CLI availability check failed for ${modelName}:`, error);
|
|
68
|
+
// Don't cache complete CLI failures as they might be transient
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the best available default model using fallback chain
|
|
74
|
+
* @returns Promise<string> The best available model name
|
|
75
|
+
*/
|
|
76
|
+
export async function getDefaultModel() {
|
|
77
|
+
Logger.log('Detecting best available default model...');
|
|
78
|
+
// Try each model in priority order
|
|
79
|
+
for (const modelName of DEFAULT_MODEL_FALLBACK) {
|
|
80
|
+
try {
|
|
81
|
+
const available = await isModelAvailable(modelName);
|
|
82
|
+
if (available) {
|
|
83
|
+
Logger.log(`Selected default model: ${modelName}`);
|
|
84
|
+
return modelName;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
Logger.warn(`Failed to check model ${modelName}:`, error);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Ultimate fallback if all checks fail
|
|
93
|
+
Logger.warn(`All default models unavailable, falling back to ${MODELS.GPT5_CODEX}`);
|
|
94
|
+
return MODELS.GPT5_CODEX;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Validate if a user-specified model name is valid
|
|
98
|
+
* @param modelName User-provided model name
|
|
99
|
+
* @returns boolean True if model name exists in MODELS constant
|
|
100
|
+
*/
|
|
101
|
+
export function isValidModel(modelName) {
|
|
102
|
+
const validModels = Object.values(MODELS);
|
|
103
|
+
return validModels.includes(modelName);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get model name with fallback to default
|
|
107
|
+
* @param requestedModel User-requested model (optional)
|
|
108
|
+
* @returns Promise<string> Model name to use
|
|
109
|
+
*/
|
|
110
|
+
export async function getModelWithFallback(requestedModel) {
|
|
111
|
+
// If no model requested, use default
|
|
112
|
+
if (!requestedModel) {
|
|
113
|
+
return await getDefaultModel();
|
|
114
|
+
}
|
|
115
|
+
// Validate requested model
|
|
116
|
+
if (!isValidModel(requestedModel)) {
|
|
117
|
+
Logger.warn(`Invalid model "${requestedModel}", falling back to default`);
|
|
118
|
+
return await getDefaultModel();
|
|
119
|
+
}
|
|
120
|
+
// Check if requested model is available
|
|
121
|
+
const available = await isModelAvailable(requestedModel);
|
|
122
|
+
if (!available) {
|
|
123
|
+
Logger.warn(`Model "${requestedModel}" not available, falling back to default`);
|
|
124
|
+
return await getDefaultModel();
|
|
125
|
+
}
|
|
126
|
+
return requestedModel;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get all available models (for future use in model listing)
|
|
130
|
+
* @returns Promise<string[]> Array of available model names
|
|
131
|
+
*/
|
|
132
|
+
export async function getAvailableModels() {
|
|
133
|
+
const availableModels = [];
|
|
134
|
+
for (const modelName of Object.values(MODELS)) {
|
|
135
|
+
try {
|
|
136
|
+
const available = await isModelAvailable(modelName);
|
|
137
|
+
if (available) {
|
|
138
|
+
availableModels.push(modelName);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// Skip unavailable models
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return availableModels;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=modelDetection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelDetection.js","sourceRoot":"","sources":["../../src/utils/modelDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAsBtD,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAA2B,CAAC;AAClE,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAEhD;;GAEG;AACH,MAAM,sBAAsB,GAAa;IACvC,MAAM,CAAC,gBAAgB,EAAE,0CAA0C;IACnE,MAAM,CAAC,UAAU,EAAE,6BAA6B;IAChD,MAAM,CAAC,IAAI,EAAE,gCAAgC;CAC9C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAAiB,EACjB,cAAuB,KAAK;IAE5B,sCAAsC;IACtC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,sBAAsB,CAAC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;IACjC,CAAC;IAED,2BAA2B;IAC3B,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,kBAAkB,cAAc,4BAA4B,CAAC,CAAC;QAC1E,OAAO,MAAM,eAAe,EAAE,CAAC;IACjC,CAAC;IAED,wCAAwC;IACxC,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACzD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,UAAU,cAAc,0CAA0C,CAAC,CAAC;QAChF,OAAO,MAAM,eAAe,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,eAAe,GAAa,EAAE,CAAC;IAErC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9C,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,SAAS,CAAC,CAAC;YACpD,IAAI,SAAS,EAAE,CAAC;gBACd,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,0BAA0B;YAC1B,SAAS;QACX,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session data structure
|
|
3
|
+
*/
|
|
4
|
+
export interface SessionData {
|
|
5
|
+
sessionId: string;
|
|
6
|
+
workspaceId: string;
|
|
7
|
+
codexConversationId?: string;
|
|
8
|
+
lastPrompt: string;
|
|
9
|
+
lastResponse: string;
|
|
10
|
+
model?: string;
|
|
11
|
+
workingDir?: string;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
updatedAt: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generate workspace ID using MD5 hash
|
|
17
|
+
* Format: repo:head:path -> 12-char hex
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateWorkspaceId(workingDir: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Generate unique session ID
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateSessionId(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Save or update a session
|
|
26
|
+
*/
|
|
27
|
+
export declare function saveSession(data: Partial<SessionData> & {
|
|
28
|
+
sessionId: string;
|
|
29
|
+
}): SessionData;
|
|
30
|
+
/**
|
|
31
|
+
* Get session by ID
|
|
32
|
+
*/
|
|
33
|
+
export declare function getSession(sessionId: string): SessionData | null;
|
|
34
|
+
/**
|
|
35
|
+
* Get session by workspace ID (returns most recent)
|
|
36
|
+
*/
|
|
37
|
+
export declare function getSessionByWorkspace(workspaceId: string): SessionData | null;
|
|
38
|
+
/**
|
|
39
|
+
* Get or create session for a workspace
|
|
40
|
+
*
|
|
41
|
+
* When sessionId is provided: returns existing session or creates new with that ID
|
|
42
|
+
* When sessionId is NOT provided: returns workspace session or creates new with generated ID
|
|
43
|
+
*/
|
|
44
|
+
export declare function getOrCreateSession(workingDir: string, sessionId?: string): SessionData;
|
|
45
|
+
/**
|
|
46
|
+
* Update session with Codex conversation ID (for native resume)
|
|
47
|
+
*/
|
|
48
|
+
export declare function setCodexConversationId(sessionId: string, conversationId: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get Codex conversation ID for resume
|
|
51
|
+
*/
|
|
52
|
+
export declare function getCodexConversationId(sessionId: string): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* List all active sessions
|
|
55
|
+
*/
|
|
56
|
+
export declare function listSessions(): SessionData[];
|
|
57
|
+
/**
|
|
58
|
+
* Delete a session
|
|
59
|
+
*/
|
|
60
|
+
export declare function deleteSession(sessionId: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Clear all sessions
|
|
63
|
+
*/
|
|
64
|
+
export declare function clearAllSessions(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get session statistics
|
|
67
|
+
*/
|
|
68
|
+
export declare function getSessionStats(): {
|
|
69
|
+
total: number;
|
|
70
|
+
withConversationId: number;
|
|
71
|
+
maxSessions: number;
|
|
72
|
+
ttlMs: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Parse Codex conversation ID from stderr output
|
|
76
|
+
* Pattern: "conversation id: abc123" or "Conversation ID: abc-123-def"
|
|
77
|
+
*/
|
|
78
|
+
export declare function parseConversationIdFromOutput(output: string): string | null;
|
|
79
|
+
//# sourceMappingURL=sessionStorage.d.ts.map
|