@vybestack/llxprt-code-core 0.1.23-nightly.250903.97906524 → 0.1.23-nightly.250905.67589d14

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 (82) hide show
  1. package/dist/src/adapters/IStreamAdapter.d.ts +3 -3
  2. package/dist/src/auth/types.d.ts +4 -4
  3. package/dist/src/config/index.d.ts +7 -0
  4. package/dist/src/config/index.js +8 -0
  5. package/dist/src/config/index.js.map +1 -0
  6. package/dist/src/core/client.d.ts +9 -21
  7. package/dist/src/core/client.js +46 -144
  8. package/dist/src/core/client.js.map +1 -1
  9. package/dist/src/core/compression-config.d.ts +1 -1
  10. package/dist/src/core/compression-config.js +4 -5
  11. package/dist/src/core/compression-config.js.map +1 -1
  12. package/dist/src/core/coreToolScheduler.js +50 -15
  13. package/dist/src/core/coreToolScheduler.js.map +1 -1
  14. package/dist/src/core/geminiChat.d.ts +51 -2
  15. package/dist/src/core/geminiChat.js +592 -93
  16. package/dist/src/core/geminiChat.js.map +1 -1
  17. package/dist/src/core/nonInteractiveToolExecutor.js +70 -19
  18. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
  19. package/dist/src/index.d.ts +1 -2
  20. package/dist/src/index.js +2 -2
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/providers/BaseProvider.d.ts +8 -3
  23. package/dist/src/providers/BaseProvider.js.map +1 -1
  24. package/dist/src/providers/IProvider.d.ts +9 -3
  25. package/dist/src/providers/LoggingProviderWrapper.d.ts +10 -3
  26. package/dist/src/providers/LoggingProviderWrapper.js +33 -27
  27. package/dist/src/providers/LoggingProviderWrapper.js.map +1 -1
  28. package/dist/src/providers/ProviderContentGenerator.d.ts +2 -2
  29. package/dist/src/providers/ProviderContentGenerator.js +9 -6
  30. package/dist/src/providers/ProviderContentGenerator.js.map +1 -1
  31. package/dist/src/providers/anthropic/AnthropicProvider.d.ts +12 -17
  32. package/dist/src/providers/anthropic/AnthropicProvider.js +238 -447
  33. package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
  34. package/dist/src/providers/gemini/GeminiProvider.d.ts +12 -6
  35. package/dist/src/providers/gemini/GeminiProvider.js +184 -458
  36. package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
  37. package/dist/src/providers/openai/ConversationCache.d.ts +3 -3
  38. package/dist/src/providers/openai/IChatGenerateParams.d.ts +9 -4
  39. package/dist/src/providers/openai/OpenAIProvider.d.ts +14 -61
  40. package/dist/src/providers/openai/OpenAIProvider.js +270 -575
  41. package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
  42. package/dist/src/providers/openai/buildResponsesRequest.d.ts +3 -3
  43. package/dist/src/providers/openai/buildResponsesRequest.js +67 -37
  44. package/dist/src/providers/openai/buildResponsesRequest.js.map +1 -1
  45. package/dist/src/providers/openai/estimateRemoteTokens.d.ts +2 -2
  46. package/dist/src/providers/openai/estimateRemoteTokens.js +21 -8
  47. package/dist/src/providers/openai/estimateRemoteTokens.js.map +1 -1
  48. package/dist/src/providers/openai/parseResponsesStream.d.ts +6 -2
  49. package/dist/src/providers/openai/parseResponsesStream.js +99 -391
  50. package/dist/src/providers/openai/parseResponsesStream.js.map +1 -1
  51. package/dist/src/providers/openai/syntheticToolResponses.d.ts +5 -5
  52. package/dist/src/providers/openai/syntheticToolResponses.js +102 -91
  53. package/dist/src/providers/openai/syntheticToolResponses.js.map +1 -1
  54. package/dist/src/providers/openai-responses/OpenAIResponsesProvider.d.ts +16 -17
  55. package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js +222 -224
  56. package/dist/src/providers/openai-responses/OpenAIResponsesProvider.js.map +1 -1
  57. package/dist/src/providers/types.d.ts +1 -1
  58. package/dist/src/services/history/ContentConverters.d.ts +6 -1
  59. package/dist/src/services/history/ContentConverters.js +155 -18
  60. package/dist/src/services/history/ContentConverters.js.map +1 -1
  61. package/dist/src/services/history/HistoryService.d.ts +52 -0
  62. package/dist/src/services/history/HistoryService.js +245 -93
  63. package/dist/src/services/history/HistoryService.js.map +1 -1
  64. package/dist/src/services/history/IContent.d.ts +4 -0
  65. package/dist/src/services/history/IContent.js.map +1 -1
  66. package/dist/src/telemetry/types.d.ts +16 -4
  67. package/dist/src/telemetry/types.js.map +1 -1
  68. package/dist/src/tools/IToolFormatter.d.ts +2 -2
  69. package/dist/src/tools/ToolFormatter.d.ts +3 -3
  70. package/dist/src/tools/ToolFormatter.js +80 -37
  71. package/dist/src/tools/ToolFormatter.js.map +1 -1
  72. package/dist/src/tools/todo-schemas.d.ts +4 -4
  73. package/package.json +8 -7
  74. package/dist/src/core/ContentGeneratorAdapter.d.ts +0 -37
  75. package/dist/src/core/ContentGeneratorAdapter.js +0 -58
  76. package/dist/src/core/ContentGeneratorAdapter.js.map +0 -1
  77. package/dist/src/providers/IMessage.d.ts +0 -38
  78. package/dist/src/providers/IMessage.js +0 -17
  79. package/dist/src/providers/IMessage.js.map +0 -1
  80. package/dist/src/providers/adapters/GeminiCompatibleWrapper.d.ts +0 -69
  81. package/dist/src/providers/adapters/GeminiCompatibleWrapper.js +0 -577
  82. package/dist/src/providers/adapters/GeminiCompatibleWrapper.js.map +0 -1
@@ -1,459 +1,167 @@
1
- /**
2
- * @plan PLAN-20250120-DEBUGLOGGING.P15
3
- * @requirement REQ-INT-001.1
4
- */
5
- import { DebugLogger } from '../../debug/index.js';
6
- import { ContentGeneratorRole } from '../ContentGeneratorRole.js';
7
- const MAX_ACCUMULATOR_SIZE = 10000; // Prevent unbounded accumulator growth
8
- // Helper function to convert O3 model's answer/response fields to strings
9
- function formatArrayResponse(value) {
10
- if (typeof value === 'string') {
11
- return value;
12
- }
13
- if (Array.isArray(value)) {
14
- // Handle numeric arrays like [4, 1] -> "4.1"
15
- if (value.every((item) => typeof item === 'number')) {
16
- return value.join('.');
17
- }
18
- // Handle mixed arrays like ["gpt", 4.1] -> "gpt 4.1"
19
- return value.map((item) => String(item)).join(' ');
20
- }
21
- // Handle other types by converting to string
22
- return String(value);
23
- }
24
- /** Return true if the chunk starts with "{" or "[". Used to decide
25
- whether it even makes sense to call JSON.parse on the chunk. */
26
- function looksLikeJSONObjectOrArray(s) {
27
- return /^[[{]/.test(s.trim());
28
- }
29
- // Create a single logger instance for the module (following singleton pattern)
30
- const logger = new DebugLogger('llxprt:providers:openai');
31
1
  export async function* parseResponsesStream(stream) {
32
- const decoder = new TextDecoder();
33
2
  const reader = stream.getReader();
3
+ const decoder = new TextDecoder();
34
4
  let buffer = '';
35
- // Track function calls being assembled
36
5
  const functionCalls = new Map();
37
- // Track accumulated text to detect reasoning JSON
38
- let textAccumulator = '';
39
6
  try {
40
7
  while (true) {
41
8
  const { done, value } = await reader.read();
42
9
  if (done)
43
10
  break;
11
+ // Decode chunk and add to buffer
44
12
  buffer += decoder.decode(value, { stream: true });
13
+ // Process complete lines
45
14
  const lines = buffer.split('\n');
46
- buffer = lines.pop() || '';
15
+ buffer = lines.pop() || ''; // Keep incomplete line in buffer
47
16
  for (const line of lines) {
48
- if (line.trim() === '')
49
- continue;
50
- // Parse event type
51
- if (line.startsWith('event: ')) {
52
- continue;
53
- }
54
- else if (line.startsWith('data: ')) {
55
- const dataLine = line.slice(6);
56
- if (dataLine === '[DONE]') {
17
+ if (line.startsWith('data: ')) {
18
+ const data = line.substring(6);
19
+ // Skip [DONE] marker
20
+ if (data === '[DONE]')
57
21
  continue;
58
- }
59
22
  try {
60
- const event = JSON.parse(dataLine);
23
+ const event = JSON.parse(data);
61
24
  // Handle different event types
62
25
  switch (event.type) {
63
26
  case 'response.output_text.delta':
64
- // Accumulate and check for reasoning JSON
27
+ // Text content chunk
65
28
  if (event.delta) {
66
- // Fast-path: If delta is just a number, yield it immediately
67
- if (/^\d+(\.\d+)?$/.test(event.delta.trim())) {
68
- yield {
69
- role: ContentGeneratorRole.ASSISTANT,
70
- content: event.delta,
71
- };
72
- continue;
73
- }
74
- textAccumulator += event.delta;
75
- // Only try to parse if accumulator looks like JSON
76
- if (looksLikeJSONObjectOrArray(textAccumulator)) {
77
- // Check if we have complete reasoning JSON
78
- try {
79
- const parsed = JSON.parse(textAccumulator);
80
- if (parsed.reasoning && parsed.next_speaker) {
81
- // Format reasoning nicely
82
- yield {
83
- role: ContentGeneratorRole.ASSISTANT,
84
- content: `Thinking: ${parsed.reasoning}\n\n`,
85
- };
86
- // Check if there's an answer/response field
87
- if (parsed.answer || parsed.response) {
88
- yield {
89
- role: ContentGeneratorRole.ASSISTANT,
90
- content: formatArrayResponse(parsed.answer || parsed.response),
91
- };
92
- }
93
- // Reset accumulator
94
- textAccumulator = '';
95
- continue;
96
- }
97
- }
98
- catch {
99
- // Not complete JSON yet or not reasoning
100
- // Check if this looks like the start of JSON
101
- if (textAccumulator.trim().startsWith('{') &&
102
- textAccumulator.includes('"reasoning"')) {
103
- // Still accumulating reasoning JSON, don't yield yet
104
- if (textAccumulator.length > MAX_ACCUMULATOR_SIZE) {
105
- yield {
106
- role: ContentGeneratorRole.ASSISTANT,
107
- content: textAccumulator,
108
- };
109
- textAccumulator = '';
110
- }
111
- continue;
112
- }
113
- }
114
- }
115
- // Check if the delta itself is complete JSON (only if it looks like an object/array)
116
- if (looksLikeJSONObjectOrArray(event.delta)) {
117
- try {
118
- const parsed = JSON.parse(event.delta);
119
- if (parsed.reasoning !== undefined &&
120
- parsed.next_speaker !== undefined) {
121
- // This is complete O3 JSON in a single delta
122
- yield {
123
- role: ContentGeneratorRole.ASSISTANT,
124
- content: `Thinking: ${parsed.reasoning}\n\n`,
125
- };
126
- // Check if there's an answer/response field
127
- if (parsed.answer || parsed.response) {
128
- yield {
129
- role: ContentGeneratorRole.ASSISTANT,
130
- content: formatArrayResponse(parsed.answer || parsed.response),
131
- };
132
- }
133
- // Reset accumulator
134
- textAccumulator = '';
135
- continue;
136
- }
137
- }
138
- catch {
139
- // Not JSON, continue with regular text handling
140
- }
141
- }
142
- // Regular text, yield it
143
29
  yield {
144
- role: ContentGeneratorRole.ASSISTANT,
145
- content: event.delta,
30
+ speaker: 'ai',
31
+ blocks: [{ type: 'text', text: event.delta }],
146
32
  };
147
- // Reset accumulator since we're in regular text mode
148
- textAccumulator = '';
149
- }
150
- break;
151
- case 'response.message_content.delta':
152
- // Handle message content deltas (might contain reasoning)
153
- if (event.delta) {
154
- // Fast-path: If delta is just a number, yield it immediately
155
- if (/^\d+(\.\d+)?$/.test(event.delta.trim())) {
156
- yield {
157
- role: ContentGeneratorRole.ASSISTANT,
158
- content: event.delta,
159
- };
160
- continue;
161
- }
162
- textAccumulator += event.delta;
163
- // Only try to parse if accumulator looks like JSON
164
- if (looksLikeJSONObjectOrArray(textAccumulator)) {
165
- // Check if we have complete reasoning JSON
166
- try {
167
- const parsed = JSON.parse(textAccumulator);
168
- if (parsed.reasoning && parsed.next_speaker) {
169
- // Format reasoning nicely
170
- yield {
171
- role: ContentGeneratorRole.ASSISTANT,
172
- content: `Thinking: ${parsed.reasoning}\n\n`,
173
- };
174
- // Check if there's an answer/response field
175
- if (parsed.answer || parsed.response) {
176
- yield {
177
- role: ContentGeneratorRole.ASSISTANT,
178
- content: formatArrayResponse(parsed.answer || parsed.response),
179
- };
180
- }
181
- // Reset accumulator
182
- textAccumulator = '';
183
- continue;
184
- }
185
- }
186
- catch {
187
- // Not complete JSON yet or not reasoning
188
- // Check if this looks like the start of JSON
189
- if (textAccumulator.trim().startsWith('{') &&
190
- textAccumulator.includes('"reasoning"')) {
191
- // Still accumulating reasoning JSON, don't yield yet
192
- if (textAccumulator.length > MAX_ACCUMULATOR_SIZE) {
193
- yield {
194
- role: ContentGeneratorRole.ASSISTANT,
195
- content: textAccumulator,
196
- };
197
- textAccumulator = '';
198
- }
199
- continue;
200
- }
201
- }
202
- }
203
- // Check if the delta itself is complete JSON (only if it looks like an object/array)
204
- if (looksLikeJSONObjectOrArray(event.delta)) {
205
- try {
206
- const parsed = JSON.parse(event.delta);
207
- if (parsed.reasoning !== undefined &&
208
- parsed.next_speaker !== undefined) {
209
- // This is complete O3 JSON in a single delta
210
- yield {
211
- role: ContentGeneratorRole.ASSISTANT,
212
- content: `Thinking: ${parsed.reasoning}\n\n`,
213
- };
214
- // Check if there's an answer/response field
215
- if (parsed.answer || parsed.response) {
216
- yield {
217
- role: ContentGeneratorRole.ASSISTANT,
218
- content: formatArrayResponse(parsed.answer || parsed.response),
219
- };
220
- }
221
- // Reset accumulator
222
- textAccumulator = '';
223
- continue;
224
- }
225
- }
226
- catch {
227
- // Not JSON, continue with regular text handling
228
- }
229
- }
230
- // If we have accumulated text that's not JSON, yield it all
231
- if (textAccumulator &&
232
- !looksLikeJSONObjectOrArray(textAccumulator)) {
233
- yield {
234
- role: ContentGeneratorRole.ASSISTANT,
235
- content: textAccumulator,
236
- };
237
- textAccumulator = '';
238
- }
239
- else if (!textAccumulator) {
240
- // No accumulator, just yield the delta
241
- yield {
242
- role: ContentGeneratorRole.ASSISTANT,
243
- content: event.delta,
244
- };
245
- }
246
33
  }
247
34
  break;
248
35
  case 'response.output_item.added':
249
- // A new function call is starting
36
+ // New function call started
250
37
  if (event.item?.type === 'function_call' && event.item.id) {
251
38
  functionCalls.set(event.item.id, {
252
- id: event.item.call_id || event.item.id,
39
+ id: event.item.id,
40
+ call_id: event.item.call_id,
253
41
  name: event.item.name || '',
254
42
  arguments: event.item.arguments || '',
255
- output_index: event.output_index || 0,
256
43
  });
257
44
  }
258
- else if (event.item?.type === 'message') {
259
- // Handle message-type items that might contain reasoning
260
- // These should be handled but not stop the stream
261
- if (event.item.content?.length) {
262
- const content = event.item.content[0];
263
- if (content?.type === 'text' && content.text) {
264
- // Check if this is reasoning JSON
265
- try {
266
- const parsed = JSON.parse(content.text);
267
- if (parsed.reasoning && parsed.next_speaker) {
268
- // This is reasoning JSON - format it nicely
269
- yield {
270
- role: ContentGeneratorRole.ASSISTANT,
271
- content: `Thinking: ${parsed.reasoning}\n\n`,
272
- };
273
- // Check if there's an answer/response field
274
- if (parsed.answer || parsed.response) {
275
- yield {
276
- role: ContentGeneratorRole.ASSISTANT,
277
- content: formatArrayResponse(parsed.answer || parsed.response),
278
- };
279
- }
280
- }
281
- else {
282
- // Valid JSON but not reasoning
283
- yield {
284
- role: ContentGeneratorRole.ASSISTANT,
285
- content: content.text,
286
- };
287
- }
288
- }
289
- catch {
290
- // Not JSON, treat as regular text
291
- yield {
292
- role: ContentGeneratorRole.ASSISTANT,
293
- content: content.text,
294
- };
295
- }
296
- }
297
- }
298
- }
299
- // Reset accumulator after processing output_item.added
300
- textAccumulator = '';
301
45
  break;
302
46
  case 'response.function_call_arguments.delta':
303
- // Accumulate function call arguments
304
- if (event.item_id &&
305
- event.delta &&
306
- functionCalls.has(event.item_id)) {
47
+ // Function call arguments chunk
48
+ if (event.item_id && event.delta) {
307
49
  const call = functionCalls.get(event.item_id);
308
- call.arguments += event.delta;
50
+ if (call) {
51
+ call.arguments += event.delta;
52
+ }
309
53
  }
310
54
  break;
55
+ case 'response.function_call_arguments.done':
311
56
  case 'response.output_item.done':
312
- // Handle completed output items
313
- if (event.item?.type === 'function_call' && event.item.id) {
314
- // Function call is complete, yield it
315
- if (functionCalls.has(event.item.id)) {
316
- const call = functionCalls.get(event.item.id);
317
- // Update with final data from the done event
318
- if (event.item.arguments) {
319
- call.arguments = event.item.arguments;
320
- }
321
- // Convert to tool_calls array format
322
- yield {
323
- role: ContentGeneratorRole.ASSISTANT,
324
- content: '',
325
- tool_calls: [
326
- {
327
- id: call.id,
328
- type: 'function',
329
- function: {
57
+ // Function call completed
58
+ if (event.item?.type === 'function_call' || event.item_id) {
59
+ const itemId = event.item?.id || event.item_id;
60
+ if (itemId) {
61
+ const call = functionCalls.get(itemId);
62
+ if (call) {
63
+ // Use final arguments from event if available, otherwise use accumulated
64
+ const finalArguments = event.arguments || call.arguments;
65
+ yield {
66
+ speaker: 'ai',
67
+ blocks: [
68
+ {
69
+ type: 'tool_call',
70
+ id: call.call_id || call.id,
330
71
  name: call.name,
331
- arguments: call.arguments,
72
+ parameters: finalArguments
73
+ ? JSON.parse(finalArguments)
74
+ : {},
332
75
  },
333
- },
334
- ],
335
- };
336
- // Remove the completed call
337
- functionCalls.delete(event.item.id);
338
- }
339
- }
340
- else if (event.item?.type === 'message') {
341
- // Reset accumulator at message boundaries
342
- textAccumulator = '';
343
- // Handle completed message items
344
- if (event.item.content?.length) {
345
- const content = event.item.content[0];
346
- if (content?.type === 'text' && content.text) {
347
- // Check if this is reasoning JSON
348
- try {
349
- const parsed = JSON.parse(content.text);
350
- if (parsed.reasoning && parsed.next_speaker) {
351
- // This is reasoning JSON - format it nicely
352
- yield {
353
- role: ContentGeneratorRole.ASSISTANT,
354
- content: `Thinking: ${parsed.reasoning}\n\n`,
355
- };
356
- // Check if there's an answer/response field
357
- if (parsed.answer || parsed.response) {
358
- yield {
359
- role: ContentGeneratorRole.ASSISTANT,
360
- content: formatArrayResponse(parsed.answer || parsed.response),
361
- };
362
- }
363
- }
364
- else {
365
- // Valid JSON but not reasoning
366
- yield {
367
- role: ContentGeneratorRole.ASSISTANT,
368
- content: content.text,
369
- };
370
- }
371
- }
372
- catch {
373
- // Not JSON, treat as regular text
374
- yield {
375
- role: ContentGeneratorRole.ASSISTANT,
376
- content: content.text,
377
- };
378
- }
76
+ ],
77
+ };
78
+ // Clean up
79
+ functionCalls.delete(itemId);
379
80
  }
380
81
  }
381
82
  }
382
- // Reset textAccumulator after processing response.output_item.done
383
- textAccumulator = '';
384
83
  break;
385
84
  case 'response.completed':
386
- // Reset accumulator when response is completed
387
- textAccumulator = '';
388
- // Extract usage data and the final response ID
389
- if (event.response) {
390
- // Build the message object step by step to avoid read-only issues
391
- const finalMessage = {
392
- role: ContentGeneratorRole.ASSISTANT,
393
- content: '',
85
+ // Usage data
86
+ if (event.response?.usage) {
87
+ yield {
88
+ speaker: 'ai',
89
+ blocks: [],
90
+ metadata: {
91
+ usage: {
92
+ promptTokens: event.response.usage.input_tokens,
93
+ completionTokens: event.response.usage.output_tokens,
94
+ totalTokens: event.response.usage.total_tokens,
95
+ },
96
+ },
394
97
  };
395
- // Only add id if it exists
396
- if (event.response.id) {
397
- finalMessage.id = event.response.id;
398
- }
399
- if (event.response.usage) {
400
- finalMessage.usage = {
401
- prompt_tokens: event.response.usage.input_tokens || 0,
402
- completion_tokens: event.response.usage.output_tokens || 0,
403
- total_tokens: event.response.usage.total_tokens || 0,
404
- };
405
- }
406
- yield finalMessage;
407
98
  }
408
99
  break;
409
100
  default:
410
- // Ignore other event types for now
101
+ // Ignore unknown event types
411
102
  break;
412
103
  }
413
104
  }
414
- catch (parseError) {
415
- logger.debug(() => `Failed to parse event: ${parseError}`);
105
+ catch {
106
+ // Skip malformed JSON events
107
+ continue;
416
108
  }
417
109
  }
418
110
  }
419
111
  }
420
- // Yield any remaining accumulated text
421
- if (textAccumulator) {
422
- yield {
423
- role: ContentGeneratorRole.ASSISTANT,
424
- content: textAccumulator,
425
- };
426
- }
427
112
  }
428
113
  finally {
429
114
  reader.releaseLock();
430
115
  }
431
116
  }
432
117
  export function parseErrorResponse(status, body, providerName) {
118
+ // Try to parse JSON error response first
433
119
  try {
434
120
  const errorData = JSON.parse(body);
435
- const message = errorData.error?.message || errorData.message || 'Unknown error';
436
- // Format error message based on status code
437
- let errorPrefix;
438
- if (status === 409) {
439
- errorPrefix = 'Conflict';
121
+ // Handle various error response formats
122
+ let message = 'Unknown error';
123
+ if (errorData.error?.message) {
124
+ message = errorData.error.message;
125
+ }
126
+ else if (errorData.error?.description) {
127
+ message = errorData.error.description;
440
128
  }
441
- else if (status === 410) {
442
- errorPrefix = 'Gone';
129
+ else if (errorData.message) {
130
+ message = errorData.message;
443
131
  }
444
- else if (status === 429) {
445
- errorPrefix = 'Rate limit exceeded';
132
+ else if (errorData.description) {
133
+ message = errorData.description;
446
134
  }
447
- else if (status >= 500 && status < 600) {
448
- errorPrefix = 'Server error';
135
+ else if (typeof errorData === 'string') {
136
+ message = errorData;
449
137
  }
450
- else {
451
- // For unknown status codes, just return the message without prefix
452
- const error = new Error(message);
453
- error.status = status;
454
- error.code =
455
- errorData.error?.code || errorData.code;
456
- return error;
138
+ // Determine the error prefix based on specific status codes
139
+ let errorPrefix = 'API Error';
140
+ switch (status) {
141
+ case 409:
142
+ errorPrefix = 'Conflict';
143
+ break;
144
+ case 410:
145
+ errorPrefix = 'Gone';
146
+ break;
147
+ case 418: {
148
+ // For 418 I'm a teapot, just return the message without prefix
149
+ const teapotError = new Error(message);
150
+ teapotError.status = status;
151
+ teapotError.code =
152
+ errorData.error?.code || errorData.code;
153
+ return teapotError;
154
+ }
155
+ case 429:
156
+ errorPrefix = 'Rate limit exceeded';
157
+ break;
158
+ default:
159
+ if (status >= 400 && status < 500) {
160
+ errorPrefix = 'Client error';
161
+ }
162
+ else if (status >= 500 && status < 600) {
163
+ errorPrefix = 'Server error';
164
+ }
457
165
  }
458
166
  const error = new Error(`${errorPrefix}: ${message}`);
459
167
  error.status = status;
@@ -1 +1 @@
1
- {"version":3,"file":"parseResponsesStream.js","sourceRoot":"","sources":["../../../../src/providers/openai/parseResponsesStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,oBAAoB,GAAG,KAAK,CAAC,CAAC,uCAAuC;AAE3E,0EAA0E;AAC1E,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,6CAA6C;QAC7C,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;YACpD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QAED,qDAAqD;QACrD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,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,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,4CAA4C;QAC5C,MAAM,WAAW,GACf,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;QAC/D,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,GAAG,WAAW,KAAK,YAAY,eAAe,MAAM,EAAE,CACvD,CAAC;QACD,KAA6B,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"parseResponsesStream.js","sourceRoot":"","sources":["../../../../src/providers/openai/parseResponsesStream.ts"],"names":[],"mappings":"AA2CA,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,oBAAoB,CACzC,MAAkC;IAElC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,aAAa,GAAG,IAAI,GAAG,EAA6B,CAAC;IAE3D,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAE5C,IAAI,IAAI;gBAAE,MAAM;YAEhB,iCAAiC;YACjC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAElD,yBAAyB;YACzB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,iCAAiC;YAE7D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,IAAI,CAAC,UAAU,CAAC,Q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,EAAE,CACvD,CAAC;QACD,KAA6B,CAAC,MAAM,GAAG,MAAM,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -3,7 +3,7 @@
3
3
  * Copyright 2025 Vybestack LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { IMessage } from '../../index.js';
6
+ import { IContent } from '../../services/history/IContent.js';
7
7
  /**
8
8
  * Interface for cancelled tool information
9
9
  */
@@ -18,26 +18,26 @@ export declare class SyntheticToolResponseHandler {
18
18
  * @param cancelledTools Array of cancelled tool information
19
19
  * @returns Array of synthetic tool response messages
20
20
  */
21
- static createSyntheticResponses(cancelledTools: CancelledToolInfo[]): IMessage[];
21
+ static createSyntheticResponses(cancelledTools: CancelledToolInfo[]): IContent[];
22
22
  /**
23
23
  * Identifies tool calls that need synthetic responses by comparing
24
24
  * assistant messages with tool_calls against existing tool responses
25
25
  * @param messages The conversation history
26
26
  * @returns Array of tool call IDs that need synthetic responses
27
27
  */
28
- static identifyMissingToolResponses(messages: IMessage[]): string[];
28
+ static identifyMissingToolResponses(messages: IContent[]): string[];
29
29
  /**
30
30
  * Patches a message history to include synthetic responses for any
31
31
  * tool calls that don't have corresponding tool responses
32
32
  * @param messages The original message history
33
33
  * @returns Patched message history with synthetic responses added
34
34
  */
35
- static patchMessageHistory(messages: IMessage[]): IMessage[];
35
+ static patchMessageHistory(messages: IContent[]): IContent[];
36
36
  /**
37
37
  * Adds a user-facing cancellation notice to the message history
38
38
  * @param messages The message history
39
39
  * @param cancelledCount Number of tools that were cancelled
40
40
  * @returns Message history with cancellation notice added
41
41
  */
42
- static addCancellationNotice(messages: IMessage[], cancelledCount: number): IMessage[];
42
+ static addCancellationNotice(messages: IContent[], cancelledCount: number): IContent[];
43
43
  }