aiexecode 1.0.157

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.
Files changed (188) hide show
  1. package/LICENSE +68 -0
  2. package/README.md +347 -0
  3. package/config_template/mcp_config.json +3 -0
  4. package/config_template/package_name_store.json +5 -0
  5. package/config_template/settings.json +5 -0
  6. package/index.js +879 -0
  7. package/mcp-agent-lib/example/01-basic-usage.js +82 -0
  8. package/mcp-agent-lib/example/02-quick-start.js +52 -0
  9. package/mcp-agent-lib/example/03-http-server.js +76 -0
  10. package/mcp-agent-lib/example/04-multiple-servers.js +117 -0
  11. package/mcp-agent-lib/example/05-error-handling.js +116 -0
  12. package/mcp-agent-lib/example/06-resources-and-prompts.js +174 -0
  13. package/mcp-agent-lib/example/07-advanced-configuration.js +191 -0
  14. package/mcp-agent-lib/example/08-real-world-chatbot.js +331 -0
  15. package/mcp-agent-lib/example/README.md +346 -0
  16. package/mcp-agent-lib/index.js +19 -0
  17. package/mcp-agent-lib/init.sh +3 -0
  18. package/mcp-agent-lib/package-lock.json +1216 -0
  19. package/mcp-agent-lib/package.json +53 -0
  20. package/mcp-agent-lib/sampleFastMCPClient/client.py +25 -0
  21. package/mcp-agent-lib/sampleFastMCPClient/run.sh +3 -0
  22. package/mcp-agent-lib/sampleFastMCPServer/run.sh +3 -0
  23. package/mcp-agent-lib/sampleFastMCPServer/server.py +12 -0
  24. package/mcp-agent-lib/sampleFastMCPServerElicitationRequest/run.sh +3 -0
  25. package/mcp-agent-lib/sampleFastMCPServerElicitationRequest/server.py +43 -0
  26. package/mcp-agent-lib/sampleFastMCPServerRootsRequest/server.py +63 -0
  27. package/mcp-agent-lib/sampleMCPHost/index.js +386 -0
  28. package/mcp-agent-lib/sampleMCPHost/mcp_config.json +24 -0
  29. package/mcp-agent-lib/sampleMCPHostFeatures/elicitation.js +151 -0
  30. package/mcp-agent-lib/sampleMCPHostFeatures/index.js +166 -0
  31. package/mcp-agent-lib/sampleMCPHostFeatures/roots.js +197 -0
  32. package/mcp-agent-lib/src/mcp_client.js +1860 -0
  33. package/mcp-agent-lib/src/mcp_message_logger.js +517 -0
  34. package/package.json +72 -0
  35. package/payload_viewer/out/404/index.html +1 -0
  36. package/payload_viewer/out/404.html +1 -0
  37. package/payload_viewer/out/_next/static/chunks/060f9a97930f3d04.js +1 -0
  38. package/payload_viewer/out/_next/static/chunks/103c802c8f4a5ea1.js +1 -0
  39. package/payload_viewer/out/_next/static/chunks/16474fd6c6910c45.js +1 -0
  40. package/payload_viewer/out/_next/static/chunks/17722e3ac4e00587.js +1 -0
  41. package/payload_viewer/out/_next/static/chunks/305b077a9873cf54.js +1 -0
  42. package/payload_viewer/out/_next/static/chunks/4c1d05c6741c2bdd.js +5 -0
  43. package/payload_viewer/out/_next/static/chunks/538cc02e54714b23.js +1 -0
  44. package/payload_viewer/out/_next/static/chunks/6251fa5907d2b226.js +5 -0
  45. package/payload_viewer/out/_next/static/chunks/a6dad97d9634a72d.js +1 -0
  46. package/payload_viewer/out/_next/static/chunks/b6c0459f3789d25c.js +1 -0
  47. package/payload_viewer/out/_next/static/chunks/b75131b58f8ca46a.css +3 -0
  48. package/payload_viewer/out/_next/static/chunks/bd2dcf98c9b362f6.js +1 -0
  49. package/payload_viewer/out/_next/static/chunks/c8a542ae21335479.js +1 -0
  50. package/payload_viewer/out/_next/static/chunks/cdd12d5c1a5a6064.js +1 -0
  51. package/payload_viewer/out/_next/static/chunks/e411019f55d87c42.js +1 -0
  52. package/payload_viewer/out/_next/static/chunks/e60ef129113f6e24.js +1 -0
  53. package/payload_viewer/out/_next/static/chunks/f1ac9047ac4a3fde.js +1 -0
  54. package/payload_viewer/out/_next/static/chunks/turbopack-0ac29803ce3c3c7a.js +3 -0
  55. package/payload_viewer/out/_next/static/chunks/turbopack-89db4c64206a73e4.js +3 -0
  56. package/payload_viewer/out/_next/static/chunks/turbopack-a5b8235fa59d7119.js +3 -0
  57. package/payload_viewer/out/_next/static/media/4fa387ec64143e14-s.c1fdd6c2.woff2 +0 -0
  58. package/payload_viewer/out/_next/static/media/7178b3e590c64307-s.b97b3418.woff2 +0 -0
  59. package/payload_viewer/out/_next/static/media/797e433ab948586e-s.p.dbea232f.woff2 +0 -0
  60. package/payload_viewer/out/_next/static/media/8a480f0b521d4e75-s.8e0177b5.woff2 +0 -0
  61. package/payload_viewer/out/_next/static/media/bbc41e54d2fcbd21-s.799d8ef8.woff2 +0 -0
  62. package/payload_viewer/out/_next/static/media/caa3a2e1cccd8315-s.p.853070df.woff2 +0 -0
  63. package/payload_viewer/out/_next/static/media/favicon.0b3bf435.ico +0 -0
  64. package/payload_viewer/out/_next/static/uqQYtKpKV7kCSkUbLgdfJ/_buildManifest.js +14 -0
  65. package/payload_viewer/out/_next/static/uqQYtKpKV7kCSkUbLgdfJ/_clientMiddlewareManifest.json +1 -0
  66. package/payload_viewer/out/_next/static/uqQYtKpKV7kCSkUbLgdfJ/_ssgManifest.js +1 -0
  67. package/payload_viewer/out/favicon.ico +0 -0
  68. package/payload_viewer/out/file.svg +1 -0
  69. package/payload_viewer/out/globe.svg +1 -0
  70. package/payload_viewer/out/index.html +1 -0
  71. package/payload_viewer/out/index.txt +23 -0
  72. package/payload_viewer/out/next.svg +1 -0
  73. package/payload_viewer/out/vercel.svg +1 -0
  74. package/payload_viewer/out/window.svg +1 -0
  75. package/payload_viewer/web_server.js +861 -0
  76. package/prompts/completion_judge.txt +128 -0
  77. package/prompts/orchestrator.txt +1213 -0
  78. package/src/LLMClient/client.js +1375 -0
  79. package/src/LLMClient/converters/input-normalizer.js +238 -0
  80. package/src/LLMClient/converters/responses-to-claude.js +503 -0
  81. package/src/LLMClient/converters/responses-to-gemini.js +648 -0
  82. package/src/LLMClient/converters/responses-to-ollama.js +348 -0
  83. package/src/LLMClient/converters/responses-to-zai.js +667 -0
  84. package/src/LLMClient/errors.js +398 -0
  85. package/src/LLMClient/index.js +36 -0
  86. package/src/ai_based/completion_judge.js +421 -0
  87. package/src/ai_based/orchestrator.js +527 -0
  88. package/src/ai_based/pip_package_installer.js +173 -0
  89. package/src/ai_based/pip_package_lookup.js +197 -0
  90. package/src/cli/mcp_cli.js +70 -0
  91. package/src/cli/mcp_commands.js +255 -0
  92. package/src/commands/agents.js +18 -0
  93. package/src/commands/apikey.js +55 -0
  94. package/src/commands/bg.js +140 -0
  95. package/src/commands/commands.js +56 -0
  96. package/src/commands/debug.js +54 -0
  97. package/src/commands/exit.js +19 -0
  98. package/src/commands/help.js +35 -0
  99. package/src/commands/mcp.js +128 -0
  100. package/src/commands/model.js +176 -0
  101. package/src/commands/setup.js +13 -0
  102. package/src/commands/skills.js +51 -0
  103. package/src/commands/tools.js +165 -0
  104. package/src/commands/viewer.js +147 -0
  105. package/src/config/ai_models.js +312 -0
  106. package/src/config/config.js +10 -0
  107. package/src/config/constants.js +71 -0
  108. package/src/config/feature_flags.js +15 -0
  109. package/src/frontend/App.js +1263 -0
  110. package/src/frontend/README.md +81 -0
  111. package/src/frontend/components/AutocompleteMenu.js +47 -0
  112. package/src/frontend/components/BackgroundProcessList.js +175 -0
  113. package/src/frontend/components/BlankLine.js +62 -0
  114. package/src/frontend/components/ConversationItem.js +893 -0
  115. package/src/frontend/components/CurrentModelView.js +43 -0
  116. package/src/frontend/components/FileDiffViewer.js +616 -0
  117. package/src/frontend/components/Footer.js +25 -0
  118. package/src/frontend/components/Header.js +42 -0
  119. package/src/frontend/components/HelpView.js +154 -0
  120. package/src/frontend/components/Input.js +344 -0
  121. package/src/frontend/components/LoadingIndicator.js +31 -0
  122. package/src/frontend/components/ModelListView.js +49 -0
  123. package/src/frontend/components/ModelUpdatedView.js +22 -0
  124. package/src/frontend/components/SessionSpinner.js +66 -0
  125. package/src/frontend/components/SetupWizard.js +242 -0
  126. package/src/frontend/components/StreamOutput.js +34 -0
  127. package/src/frontend/components/TodoList.js +56 -0
  128. package/src/frontend/components/ToolApprovalPrompt.js +452 -0
  129. package/src/frontend/design/themeColors.js +42 -0
  130. package/src/frontend/hooks/useCompletion.js +84 -0
  131. package/src/frontend/hooks/useFileCompletion.js +467 -0
  132. package/src/frontend/hooks/useKeypress.js +145 -0
  133. package/src/frontend/index.js +65 -0
  134. package/src/frontend/utils/GridRenderer.js +140 -0
  135. package/src/frontend/utils/InlineFormatter.js +156 -0
  136. package/src/frontend/utils/diffUtils.js +235 -0
  137. package/src/frontend/utils/inputBuffer.js +441 -0
  138. package/src/frontend/utils/markdownParser.js +377 -0
  139. package/src/frontend/utils/outputRedirector.js +47 -0
  140. package/src/frontend/utils/renderInkComponent.js +42 -0
  141. package/src/frontend/utils/syntaxHighlighter.js +149 -0
  142. package/src/frontend/utils/toolUIFormatter.js +261 -0
  143. package/src/system/agents_loader.js +170 -0
  144. package/src/system/ai_request.js +737 -0
  145. package/src/system/background_process.js +317 -0
  146. package/src/system/code_executer.js +1233 -0
  147. package/src/system/command_loader.js +40 -0
  148. package/src/system/command_parser.js +133 -0
  149. package/src/system/conversation_state.js +265 -0
  150. package/src/system/conversation_trimmer.js +265 -0
  151. package/src/system/custom_command_loader.js +395 -0
  152. package/src/system/file_integrity.js +466 -0
  153. package/src/system/import_analyzer.py +174 -0
  154. package/src/system/log.js +82 -0
  155. package/src/system/mcp_integration.js +304 -0
  156. package/src/system/output_helper.js +89 -0
  157. package/src/system/session.js +1393 -0
  158. package/src/system/session_memory.js +481 -0
  159. package/src/system/skill_loader.js +324 -0
  160. package/src/system/system_info.js +483 -0
  161. package/src/system/tool_approval.js +160 -0
  162. package/src/system/tool_registry.js +184 -0
  163. package/src/system/ui_events.js +279 -0
  164. package/src/tools/code_editor.js +792 -0
  165. package/src/tools/file_reader.js +385 -0
  166. package/src/tools/glob.js +263 -0
  167. package/src/tools/response_message.js +30 -0
  168. package/src/tools/ripgrep.js +554 -0
  169. package/src/tools/skill_tool.js +122 -0
  170. package/src/tools/todo_write.js +182 -0
  171. package/src/tools/web_download.py +74 -0
  172. package/src/tools/web_downloader.js +83 -0
  173. package/src/util/clone.js +174 -0
  174. package/src/util/config.js +203 -0
  175. package/src/util/config_migration.js +174 -0
  176. package/src/util/debug_log.js +49 -0
  177. package/src/util/exit_handler.js +53 -0
  178. package/src/util/file_reference_parser.js +132 -0
  179. package/src/util/mcp_config_manager.js +159 -0
  180. package/src/util/output_formatter.js +50 -0
  181. package/src/util/path_helper.js +27 -0
  182. package/src/util/path_validator.js +178 -0
  183. package/src/util/prompt_loader.js +184 -0
  184. package/src/util/rag_helper.js +101 -0
  185. package/src/util/safe_fs.js +645 -0
  186. package/src/util/setup_wizard.js +62 -0
  187. package/src/util/text_formatter.js +33 -0
  188. package/src/util/version_check.js +116 -0
@@ -0,0 +1,398 @@
1
+ /**
2
+ * OpenAI-compatible error handling
3
+ */
4
+
5
+ /**
6
+ * OpenAI API Error class
7
+ * Follows OpenAI Responses API error format
8
+ */
9
+ export class LLMError extends Error {
10
+ constructor(message, options = {}) {
11
+ super(message);
12
+ this.name = 'LLMError';
13
+
14
+ // OpenAI error structure
15
+ this.error = {
16
+ message: message,
17
+ type: options.type || 'api_error',
18
+ param: options.param || null,
19
+ code: options.code || null
20
+ };
21
+
22
+ // HTTP status code (if applicable)
23
+ this.status = options.status || 500;
24
+
25
+ // Original error (for debugging)
26
+ this.originalError = options.originalError || null;
27
+
28
+ // Provider information
29
+ this.provider = options.provider || 'unknown';
30
+
31
+ // Store original request for response format
32
+ this.request = options.request || {};
33
+ }
34
+
35
+ /**
36
+ * Convert to OpenAI Responses API error format
37
+ */
38
+ toResponsesFormat() {
39
+ return {
40
+ id: `resp_error_${Date.now()}`,
41
+ object: 'response',
42
+ created_at: Math.floor(Date.now() / 1000),
43
+ status: 'failed',
44
+ background: false,
45
+ billing: {
46
+ payer: 'developer'
47
+ },
48
+ error: {
49
+ type: this.error.type,
50
+ message: this.error.message,
51
+ code: this.error.code,
52
+ param: this.error.param
53
+ },
54
+ incomplete_details: null,
55
+ instructions: this.request.instructions || null,
56
+ max_output_tokens: this.request.max_output_tokens || null,
57
+ max_tool_calls: null,
58
+ model: this.request.model || null,
59
+ output: [],
60
+ parallel_tool_calls: true,
61
+ previous_response_id: null,
62
+ prompt_cache_key: null,
63
+ prompt_cache_retention: null,
64
+ reasoning: {
65
+ effort: this.request.reasoning?.effort || null,
66
+ summary: this.request.reasoning?.summary || null
67
+ },
68
+ safety_identifier: null,
69
+ service_tier: 'default',
70
+ store: this.request.store !== undefined ? this.request.store : true,
71
+ temperature: this.request.temperature !== undefined ? this.request.temperature : 1,
72
+ text: {
73
+ format: {
74
+ type: 'text'
75
+ },
76
+ verbosity: 'medium'
77
+ },
78
+ tool_choice: this.request.tool_choice || 'auto',
79
+ tools: this.request.tools || [],
80
+ top_logprobs: 0,
81
+ top_p: this.request.top_p !== undefined ? this.request.top_p : 1,
82
+ truncation: 'disabled',
83
+ usage: {
84
+ input_tokens: 0,
85
+ input_tokens_details: {
86
+ cached_tokens: 0
87
+ },
88
+ output_tokens: 0,
89
+ output_tokens_details: {
90
+ reasoning_tokens: 0
91
+ },
92
+ total_tokens: 0
93
+ },
94
+ user: null,
95
+ metadata: {},
96
+ output_text: ''
97
+ };
98
+ }
99
+
100
+ /**
101
+ * Convert to JSON (Legacy OpenAI error format)
102
+ */
103
+ toJSON() {
104
+ return {
105
+ error: this.error
106
+ };
107
+ }
108
+
109
+ /**
110
+ * Convert to string
111
+ */
112
+ toString() {
113
+ return `${this.provider} Error [${this.error.type}]: ${this.error.message}`;
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Map HTTP status codes to OpenAI error types
119
+ */
120
+ const ERROR_TYPE_MAP = {
121
+ 400: 'invalid_request_error',
122
+ 401: 'authentication_error',
123
+ 403: 'permission_error',
124
+ 404: 'not_found_error',
125
+ 429: 'rate_limit_error',
126
+ 500: 'api_error',
127
+ 502: 'api_error',
128
+ 503: 'api_error'
129
+ };
130
+
131
+ /**
132
+ * Create LLMError from HTTP response
133
+ */
134
+ export async function createErrorFromResponse(response, provider) {
135
+ const status = response.status;
136
+ let errorData = null;
137
+
138
+ try {
139
+ const text = await response.text();
140
+ errorData = JSON.parse(text);
141
+ } catch (e) {
142
+ // Failed to parse JSON
143
+ return new LLMError(
144
+ `HTTP ${status}: ${response.statusText}`,
145
+ {
146
+ type: ERROR_TYPE_MAP[status] || 'api_error',
147
+ status: status,
148
+ provider: provider
149
+ }
150
+ );
151
+ }
152
+
153
+ // Extract error information
154
+ let message = errorData.error?.message || errorData.message || response.statusText;
155
+ let type = errorData.error?.type || ERROR_TYPE_MAP[status] || 'api_error';
156
+ let param = errorData.error?.param || null;
157
+ let code = errorData.error?.code || null;
158
+
159
+ return new LLMError(message, {
160
+ type: type,
161
+ param: param,
162
+ code: code,
163
+ status: status,
164
+ provider: provider,
165
+ originalError: errorData
166
+ });
167
+ }
168
+
169
+ /**
170
+ * Convert provider-specific error to LLMError
171
+ */
172
+ export function normalizeError(error, provider) {
173
+ // Already an LLMError
174
+ if (error instanceof LLMError) {
175
+ return error;
176
+ }
177
+
178
+ // Anthropic SDK error (check BEFORE OpenAI SDK error, as both have error.status && error.error)
179
+ // Z.AI uses Anthropic SDK so handle similarly
180
+ if ((provider === 'claude' || provider === 'zai') && error.status) {
181
+ // Parse Claude error from error.error object (Anthropic SDK provides parsed error)
182
+ let errorType = ERROR_TYPE_MAP[error.status] || 'api_error';
183
+ let code = null;
184
+ let message = error.message || (provider === 'zai' ? 'Z.AI API error' : 'Claude API error');
185
+
186
+ // Z.AI specific error format: { detail: [{ type, loc, msg, ... }] }
187
+ if (error.error && error.error.detail && Array.isArray(error.error.detail)) {
188
+ const zaiError = error.error.detail[0];
189
+ if (zaiError) {
190
+ code = zaiError.type || null;
191
+ message = zaiError.msg || message;
192
+
193
+ // Map Z.AI error types
194
+ if (zaiError.type === 'json_invalid') {
195
+ errorType = 'invalid_request_error';
196
+ }
197
+ }
198
+ }
199
+ // Z.AI auth error format: { error: { message, type: "401" } }
200
+ else if (error.error && error.error.type === '401') {
201
+ errorType = 'authentication_error';
202
+ code = 'invalid_api_key';
203
+ message = error.error.message || 'Invalid or expired API key';
204
+ }
205
+ // Z.AI context exceeded format: { error: { code: "1210", message: "..." } }
206
+ else if (error.error && (error.error.code === '1210' || error.error.code === 1210)) {
207
+ errorType = 'invalid_request_error';
208
+ code = 'context_length_exceeded';
209
+ message = error.error.message || 'Context length exceeded';
210
+ }
211
+ // Anthropic SDK provides error.error object with structure:
212
+ // { type: 'error', error: { type: 'not_found_error', message: '...' } }
213
+ else if (error.error && error.error.error) {
214
+ const claudeError = error.error.error;
215
+
216
+ if (claudeError.type) {
217
+ code = claudeError.type;
218
+
219
+ // Map Claude error types to OpenAI error types
220
+ const claudeType = claudeError.type;
221
+ if (claudeType === 'not_found_error') {
222
+ errorType = 'not_found_error';
223
+ } else if (claudeType === 'invalid_request_error') {
224
+ errorType = 'invalid_request_error';
225
+ } else if (claudeType === 'authentication_error') {
226
+ errorType = 'authentication_error';
227
+ } else if (claudeType === 'permission_error') {
228
+ errorType = 'permission_error';
229
+ } else if (claudeType === 'rate_limit_error') {
230
+ errorType = 'rate_limit_error';
231
+ } else if (claudeType === 'overloaded_error') {
232
+ errorType = 'api_error';
233
+ }
234
+ }
235
+
236
+ // Use the actual error message from Claude
237
+ if (claudeError.message) {
238
+ message = claudeError.message;
239
+ }
240
+ }
241
+
242
+ return new LLMError(
243
+ message,
244
+ {
245
+ type: errorType,
246
+ param: null,
247
+ code: code,
248
+ status: error.status,
249
+ provider: provider,
250
+ originalError: error
251
+ }
252
+ );
253
+ }
254
+
255
+ // OpenAI SDK error
256
+ if (error.status && error.error) {
257
+ return new LLMError(
258
+ error.error.message || error.message,
259
+ {
260
+ type: error.error.type || ERROR_TYPE_MAP[error.status] || 'api_error',
261
+ param: error.error.param || null,
262
+ code: error.error.code || null,
263
+ status: error.status,
264
+ provider: provider,
265
+ originalError: error
266
+ }
267
+ );
268
+ }
269
+
270
+ // Google Generative AI error
271
+ if (provider === 'gemini') {
272
+ // Extract status from error message if available
273
+ let status = 500;
274
+ const statusMatch = error.message?.match(/\[(\d+)\s+/);
275
+ if (statusMatch) {
276
+ status = parseInt(statusMatch[1]);
277
+ }
278
+
279
+ return new LLMError(
280
+ error.message || 'Gemini API error',
281
+ {
282
+ type: ERROR_TYPE_MAP[status] || 'api_error',
283
+ param: null,
284
+ code: null,
285
+ status: status,
286
+ provider: 'gemini',
287
+ originalError: error
288
+ }
289
+ );
290
+ }
291
+
292
+ // Ollama error
293
+ if (provider === 'ollama') {
294
+ return new LLMError(
295
+ error.message || 'Ollama API error',
296
+ {
297
+ type: 'api_error',
298
+ param: null,
299
+ code: null,
300
+ status: error.status || 500,
301
+ provider: 'ollama',
302
+ originalError: error
303
+ }
304
+ );
305
+ }
306
+
307
+ // Network errors (connection refused, DNS errors, etc)
308
+ if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND' || error.code === 'ETIMEDOUT') {
309
+ return new LLMError(
310
+ error.message || 'Network connection error',
311
+ {
312
+ type: 'api_error',
313
+ param: null,
314
+ code: error.code,
315
+ status: 500,
316
+ provider: provider,
317
+ originalError: error
318
+ }
319
+ );
320
+ }
321
+
322
+ // TypeError (usually from URL parsing or network issues)
323
+ if (error instanceof TypeError) {
324
+ return new LLMError(
325
+ error.message || 'Request error',
326
+ {
327
+ type: 'api_error',
328
+ param: null,
329
+ code: null,
330
+ status: 500,
331
+ provider: provider,
332
+ originalError: error
333
+ }
334
+ );
335
+ }
336
+
337
+ // Generic error
338
+ return new LLMError(
339
+ error.message || 'Unknown error',
340
+ {
341
+ type: 'api_error',
342
+ status: 500,
343
+ provider: provider,
344
+ originalError: error
345
+ }
346
+ );
347
+ }
348
+
349
+ /**
350
+ * Specific error types for common cases
351
+ */
352
+
353
+ export class AuthenticationError extends LLMError {
354
+ constructor(message, provider) {
355
+ super(message, {
356
+ type: 'authentication_error',
357
+ code: 'invalid_api_key',
358
+ status: 401,
359
+ provider: provider
360
+ });
361
+ this.name = 'AuthenticationError';
362
+ }
363
+ }
364
+
365
+ export class InvalidRequestError extends LLMError {
366
+ constructor(message, param, provider) {
367
+ super(message, {
368
+ type: 'invalid_request_error',
369
+ param: param,
370
+ status: 400,
371
+ provider: provider
372
+ });
373
+ this.name = 'InvalidRequestError';
374
+ }
375
+ }
376
+
377
+ export class RateLimitError extends LLMError {
378
+ constructor(message, provider) {
379
+ super(message, {
380
+ type: 'rate_limit_error',
381
+ code: 'rate_limit_exceeded',
382
+ status: 429,
383
+ provider: provider
384
+ });
385
+ this.name = 'RateLimitError';
386
+ }
387
+ }
388
+
389
+ export class NotFoundError extends LLMError {
390
+ constructor(message, provider) {
391
+ super(message, {
392
+ type: 'not_found_error',
393
+ status: 404,
394
+ provider: provider
395
+ });
396
+ this.name = 'NotFoundError';
397
+ }
398
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * LLM Function Adapter
3
+ * Unified interface for LLMs using OpenAI Responses API format
4
+ */
5
+
6
+ export { UnifiedLLMClient } from './client.js';
7
+
8
+ // Export Responses API converters
9
+ export {
10
+ convertResponsesRequestToClaudeFormat,
11
+ convertClaudeResponseToResponsesFormat
12
+ } from './converters/responses-to-claude.js';
13
+
14
+ export {
15
+ convertResponsesRequestToGeminiFormat,
16
+ convertGeminiResponseToResponsesFormat
17
+ } from './converters/responses-to-gemini.js';
18
+
19
+ export {
20
+ convertResponsesRequestToOllamaFormat,
21
+ convertOllamaResponseToResponsesFormat
22
+ } from './converters/responses-to-ollama.js';
23
+
24
+ export {
25
+ convertResponsesRequestToZaiFormat,
26
+ convertZaiResponseToResponsesFormat
27
+ } from './converters/responses-to-zai.js';
28
+
29
+ // Export error classes
30
+ export {
31
+ LLMError,
32
+ AuthenticationError,
33
+ InvalidRequestError,
34
+ RateLimitError,
35
+ NotFoundError
36
+ } from './errors.js';