@illalabs/sdk 0.3.3-canary.b7f69a88 → 0.4.0-canary.2c2d50f5

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 (126) hide show
  1. package/README.md +68 -9
  2. package/dist/src/chat/Chat.d.ts +36 -4
  3. package/dist/src/chat/Chat.d.ts.map +1 -1
  4. package/dist/src/chat/Chat.js +134 -24
  5. package/dist/src/chat/Chat.js.map +1 -1
  6. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.d.ts +22 -0
  7. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.d.ts.map +1 -0
  8. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.js +31 -0
  9. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.js.map +1 -0
  10. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.d.ts +19 -0
  11. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.d.ts.map +1 -0
  12. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.js +28 -0
  13. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.js.map +1 -0
  14. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.d.ts +22 -0
  15. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.d.ts.map +1 -0
  16. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.js +31 -0
  17. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.js.map +1 -0
  18. package/dist/src/chat/errors/index.d.ts +3 -0
  19. package/dist/src/chat/errors/index.d.ts.map +1 -1
  20. package/dist/src/chat/errors/index.js +3 -0
  21. package/dist/src/chat/errors/index.js.map +1 -1
  22. package/dist/src/chat/utils/prompt.d.ts +3 -0
  23. package/dist/src/chat/utils/prompt.d.ts.map +1 -0
  24. package/dist/src/chat/utils/prompt.js +5 -0
  25. package/dist/src/chat/utils/prompt.js.map +1 -0
  26. package/dist/src/context/ContextManager.d.ts +2 -0
  27. package/dist/src/context/ContextManager.d.ts.map +1 -1
  28. package/dist/src/context/ContextManager.js +8 -1
  29. package/dist/src/context/ContextManager.js.map +1 -1
  30. package/dist/src/errors/SdkEmptyToolsResultsError.d.ts +19 -0
  31. package/dist/src/errors/SdkEmptyToolsResultsError.d.ts.map +1 -0
  32. package/dist/src/errors/SdkEmptyToolsResultsError.js +28 -0
  33. package/dist/src/errors/SdkEmptyToolsResultsError.js.map +1 -0
  34. package/dist/src/interfaces/chat.interface.d.ts +55 -3
  35. package/dist/src/interfaces/chat.interface.d.ts.map +1 -1
  36. package/dist/src/interfaces/contextManager.interface.d.ts +7 -1
  37. package/dist/src/interfaces/contextManager.interface.d.ts.map +1 -1
  38. package/dist/src/interfaces/coreApiProvider.interface.d.ts +13 -1
  39. package/dist/src/interfaces/coreApiProvider.interface.d.ts.map +1 -1
  40. package/dist/src/interfaces/index.d.ts +1 -1
  41. package/dist/src/interfaces/index.d.ts.map +1 -1
  42. package/dist/src/internal.d.ts +1 -0
  43. package/dist/src/internal.d.ts.map +1 -1
  44. package/dist/src/internal.js +1 -0
  45. package/dist/src/internal.js.map +1 -1
  46. package/dist/src/prompt/Prompt.d.ts +2 -10
  47. package/dist/src/prompt/Prompt.d.ts.map +1 -1
  48. package/dist/src/prompt/Prompt.js +9 -22
  49. package/dist/src/prompt/Prompt.js.map +1 -1
  50. package/dist/src/prompt/index.d.ts +1 -1
  51. package/dist/src/prompt/index.d.ts.map +1 -1
  52. package/dist/src/prompt/types.d.ts +7 -9
  53. package/dist/src/prompt/types.d.ts.map +1 -1
  54. package/dist/src/prompt/utils/cloneToolResult.d.ts +6 -6
  55. package/dist/src/prompt/utils/cloneToolResult.d.ts.map +1 -1
  56. package/dist/src/prompt/utils/cloneToolResult.js +11 -16
  57. package/dist/src/prompt/utils/cloneToolResult.js.map +1 -1
  58. package/dist/src/prompt/utils/index.d.ts +1 -3
  59. package/dist/src/prompt/utils/index.d.ts.map +1 -1
  60. package/dist/src/prompt/utils/index.js +1 -3
  61. package/dist/src/prompt/utils/index.js.map +1 -1
  62. package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts +40 -1
  63. package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts.map +1 -1
  64. package/dist/src/providers/coreApiProvider/CoreApiProvider.js +124 -2
  65. package/dist/src/providers/coreApiProvider/CoreApiProvider.js.map +1 -1
  66. package/dist/src/providers/coreApiProvider/index.d.ts +1 -1
  67. package/dist/src/providers/coreApiProvider/index.d.ts.map +1 -1
  68. package/dist/src/providers/coreApiProvider/types.d.ts +44 -0
  69. package/dist/src/providers/coreApiProvider/types.d.ts.map +1 -1
  70. package/dist/src/sdk.d.ts +312 -25
  71. package/dist/src/sdk.d.ts.map +1 -1
  72. package/dist/src/sdk.js +366 -26
  73. package/dist/src/sdk.js.map +1 -1
  74. package/dist/src/streaming/errors/SSEParse.d.ts +15 -0
  75. package/dist/src/streaming/errors/SSEParse.d.ts.map +1 -0
  76. package/dist/src/streaming/errors/SSEParse.js +23 -0
  77. package/dist/src/streaming/errors/SSEParse.js.map +1 -0
  78. package/dist/src/streaming/errors/StreamingHttpError.d.ts +18 -0
  79. package/dist/src/streaming/errors/StreamingHttpError.d.ts.map +1 -0
  80. package/dist/src/streaming/errors/StreamingHttpError.js +27 -0
  81. package/dist/src/streaming/errors/StreamingHttpError.js.map +1 -0
  82. package/dist/src/streaming/errors/StreamingResponseBodyNull.d.ts +13 -0
  83. package/dist/src/streaming/errors/StreamingResponseBodyNull.d.ts.map +1 -0
  84. package/dist/src/streaming/errors/StreamingResponseBodyNull.js +21 -0
  85. package/dist/src/streaming/errors/StreamingResponseBodyNull.js.map +1 -0
  86. package/dist/src/streaming/errors/StreamingServerError.d.ts +23 -0
  87. package/dist/src/streaming/errors/StreamingServerError.d.ts.map +1 -0
  88. package/dist/src/streaming/errors/StreamingServerError.js +33 -0
  89. package/dist/src/streaming/errors/StreamingServerError.js.map +1 -0
  90. package/dist/src/streaming/errors/index.d.ts +5 -0
  91. package/dist/src/streaming/errors/index.d.ts.map +1 -0
  92. package/dist/src/streaming/errors/index.js +5 -0
  93. package/dist/src/streaming/errors/index.js.map +1 -0
  94. package/dist/src/streaming/index.d.ts +4 -0
  95. package/dist/src/streaming/index.d.ts.map +1 -0
  96. package/dist/src/streaming/index.js +3 -0
  97. package/dist/src/streaming/index.js.map +1 -0
  98. package/dist/src/streaming/parseSSE.d.ts +23 -0
  99. package/dist/src/streaming/parseSSE.d.ts.map +1 -0
  100. package/dist/src/streaming/parseSSE.js +152 -0
  101. package/dist/src/streaming/parseSSE.js.map +1 -0
  102. package/dist/src/streaming/types.d.ts +6 -0
  103. package/dist/src/streaming/types.d.ts.map +1 -0
  104. package/dist/src/streaming/types.js +6 -0
  105. package/dist/src/streaming/types.js.map +1 -0
  106. package/dist/src/telemetry/TelemetryClient.d.ts +140 -0
  107. package/dist/src/telemetry/TelemetryClient.d.ts.map +1 -0
  108. package/dist/src/telemetry/TelemetryClient.js +225 -0
  109. package/dist/src/telemetry/TelemetryClient.js.map +1 -0
  110. package/dist/src/telemetry/index.d.ts +2 -0
  111. package/dist/src/telemetry/index.d.ts.map +1 -0
  112. package/dist/src/telemetry/index.js +2 -0
  113. package/dist/src/telemetry/index.js.map +1 -0
  114. package/package.json +3 -5
  115. package/dist/src/chat/errors/ChatInvalidModelContext.d.ts +0 -15
  116. package/dist/src/chat/errors/ChatInvalidModelContext.d.ts.map +0 -1
  117. package/dist/src/chat/errors/ChatInvalidModelContext.js +0 -24
  118. package/dist/src/chat/errors/ChatInvalidModelContext.js.map +0 -1
  119. package/dist/src/prompt/utils/normalizeTextPrompt.d.ts +0 -14
  120. package/dist/src/prompt/utils/normalizeTextPrompt.d.ts.map +0 -1
  121. package/dist/src/prompt/utils/normalizeTextPrompt.js +0 -22
  122. package/dist/src/prompt/utils/normalizeTextPrompt.js.map +0 -1
  123. package/dist/src/prompt/utils/normalizeToolResult.d.ts +0 -14
  124. package/dist/src/prompt/utils/normalizeToolResult.d.ts.map +0 -1
  125. package/dist/src/prompt/utils/normalizeToolResult.js +0 -27
  126. package/dist/src/prompt/utils/normalizeToolResult.js.map +0 -1
package/dist/src/sdk.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { normalizePrompt } from "./chat/utils/prompt.js";
2
+ import { SdkEmptyToolsResultsError } from "./errors/SdkEmptyToolsResultsError.js";
1
3
  import { AsyncToolChecker, Chat, ContextManager, CoreApiProvider, InMemoryCache, Prompt, UserContextMissing, } from "./internal.js";
2
4
  /**
3
5
  * Error raised when attempting to interact with a chat that doesn't exist.
@@ -77,9 +79,13 @@ class IllaSDK {
77
79
  constructor(config, options) {
78
80
  this.coreApiProvider = new CoreApiProvider({
79
81
  baseURL: config.baseURL,
82
+ timeout: config.timeout,
80
83
  headers: {
81
84
  "x-api-key": config.apiKey,
85
+ ...config.headers,
82
86
  },
87
+ httpClientFactory: config.httpClientFactory,
88
+ routes: config.routes,
83
89
  });
84
90
  if (options && options.contextManager) {
85
91
  this.contextManager = options.contextManager;
@@ -164,6 +170,7 @@ class IllaSDK {
164
170
  coreApiProvider: this.coreApiProvider,
165
171
  }),
166
172
  personalityContext: options.personalityContext,
173
+ modelContext: options.modelContext,
167
174
  });
168
175
  this.chats.set(chat.getId(), chat);
169
176
  return chat;
@@ -173,15 +180,16 @@ class IllaSDK {
173
180
  * If a chatId is provided, the message will be sent to the existing chat.
174
181
  * If a chatId is not provided, a new chat will be created with the provided userContext.
175
182
  *
176
- * @param msg - The message text to send
183
+ * @param msg - The message to send (can be a string or Prompt object)
177
184
  * @param context - Context containing either chatId for existing chat or userContext for new chat
185
+ * @param chatOptions - Optional chat configuration when creating a new chat
178
186
  * @returns {Promise<SendMessageResult>} The AI's response including chat ID, response text, and any pending tools
179
187
  *
180
188
  * @example
181
189
  * ```typescript
182
190
  * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
183
191
  *
184
- * // Start a new conversation
192
+ * // Start a new conversation with a string
185
193
  * const result1 = await sdk.sendMessage(
186
194
  * "What can you help me with?",
187
195
  * { userContext: { address: "0x1234..." } }
@@ -189,28 +197,94 @@ class IllaSDK {
189
197
  * console.log(result1.response.text);
190
198
  * console.log("Chat ID:", result1.chatId);
191
199
  *
192
- * // Continue the conversation using the chat ID
193
- * const result2 = await sdk.sendMessage(
194
- * "I want to swap 1 ETH for USDC on Base",
195
- * { chatId: result1.chatId }
196
- * );
200
+ * // Continue the conversation with a Prompt object
201
+ * const prompt = new Prompt({ text: "I want to swap 1 ETH for USDC on Base" });
202
+ * const result2 = await sdk.sendMessage(prompt, { chatId: result1.chatId });
197
203
  *
198
204
  * // Check if there are tools to execute
199
205
  * if (result2.response.pendingTools && result2.response.pendingTools.length > 0) {
200
206
  * console.log("Tool to execute:", result2.response.pendingTools[0]);
201
207
  * }
208
+ *
209
+ * // With telemetry callback for real-time events
210
+ * const result3 = await sdk.sendMessage(
211
+ * "Show me my balance",
212
+ * { chatId: result1.chatId },
213
+ * undefined,
214
+ * {
215
+ * onRequestId: (requestId) => {
216
+ * // Connect to telemetry stream
217
+ * telemetryClient.connect(requestId);
218
+ * }
219
+ * }
220
+ * );
221
+ * ```
222
+ */
223
+ sendMessage(msg, context, chatOptions, options) {
224
+ const prompt = normalizePrompt(msg);
225
+ const chat = this.getOrCreateChat(context, chatOptions);
226
+ return chat.sendMessage(prompt, options);
227
+ }
228
+ /**
229
+ * Sends a message with streaming response via SSE.
230
+ *
231
+ * Instead of waiting for the full response, this method streams telemetry events
232
+ * in real-time as they occur during orchestration. The final result is delivered
233
+ * through the `onComplete` callback.
234
+ *
235
+ * This eliminates the need for a separate telemetry subscription - events and
236
+ * the result are delivered through a single HTTP connection.
237
+ *
238
+ * @param msg - The message to send (can be a string or Prompt object)
239
+ * @param context - Context containing either chatId for existing chat or userContext for new chat
240
+ * @param options - Streaming options with event callbacks
241
+ * @param chatOptions - Optional chat configuration when creating a new chat
242
+ * @returns {Promise<void>} A promise that resolves when the stream ends
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
247
+ *
248
+ * await sdk.sendMessageStreaming(
249
+ * "What can you help me with?",
250
+ * { userContext: { address: "0x1234..." } },
251
+ * {
252
+ * onEvent: (event) => console.log('Event:', event.type),
253
+ * onComplete: (result) => {
254
+ * console.log('Response:', result.text);
255
+ * console.log('Pending tools:', result.pendingTools?.length ?? 0);
256
+ * },
257
+ * onError: (error) => console.error('Error:', error),
258
+ * }
259
+ * );
202
260
  * ```
203
261
  */
204
- sendMessage(msg, context) {
205
- if (context.chatId && this.chats.get(context.chatId) !== undefined) {
206
- return this.chats.get(context.chatId).sendMessage(new Prompt({ text: msg }));
262
+ sendMessageStreaming(msg, context, options = {}, chatOptions) {
263
+ const prompt = normalizePrompt(msg);
264
+ const chat = this.getOrCreateChat(context, chatOptions);
265
+ return chat.sendMessageStreaming(prompt, options);
266
+ }
267
+ /**
268
+ * Gets an existing chat or creates a new one if it doesn't exist.
269
+ *
270
+ * @param context - Context containing either chatId for existing chat or userContext for new chat
271
+ * @param chatOptions - Optional chat configuration when creating a new chat
272
+ * @returns {Chat} The chat instance
273
+ */
274
+ getOrCreateChat(context, chatOptions) {
275
+ if (context.chatId) {
276
+ const existingChat = this.chats.get(context.chatId);
277
+ if (existingChat) {
278
+ return existingChat;
279
+ }
207
280
  }
281
+ // If no chatId is provided, create a new chat
208
282
  if (!context.userContext) {
209
283
  throw new UserContextMissing();
210
284
  }
211
- const chat = this.createChat({ userContext: context.userContext });
285
+ const chat = this.createChat({ userContext: context.userContext, ...chatOptions });
212
286
  this.chats.set(chat.getId(), chat);
213
- return chat.sendMessage(new Prompt({ text: msg }));
287
+ return chat;
214
288
  }
215
289
  /**
216
290
  * Sends the result of a tool execution back to the AI. This method is used to complete
@@ -219,10 +293,12 @@ class IllaSDK {
219
293
  * @param chatId - The ID of the chat to send the tool result to
220
294
  * @param toolResult - The result of the tool execution
221
295
  * @returns {Promise<SendMessageResult>} The AI's response after processing the tool result
222
- * @throws {Error} If the chat with the specified chatId is not found
296
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
223
297
  *
224
298
  * @example
225
299
  * ```typescript
300
+ * import { IllaToolOutcome, IllaToolError } from '@illalabs/interfaces';
301
+ *
226
302
  * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
227
303
  *
228
304
  * // Start a conversation that will request a tool execution
@@ -235,27 +311,30 @@ class IllaSDK {
235
311
  * if (result1.response.pendingTools && result1.response.pendingTools.length > 0) {
236
312
  * const tool = result1.response.pendingTools[0];
237
313
  *
238
- * // Execute the tool (e.g., send a transaction)
239
- * const executionResult = await executeTool(tool);
240
- *
241
- * // Send the result back to the ILLA
242
- * const toolResult: ToolResultType = {
243
- * toolCallId: tool.toolCallId,
244
- * toolName: tool.toolName,
245
- * result?: executionResult,
246
- * error?: executionResult.error,
247
- * };
314
+ * // Execute the tool and create the outcome
315
+ * let toolResult: IllaToolOutcome<unknown>;
316
+ * try {
317
+ * const executionResult = await executeTool(tool);
318
+ * toolResult = IllaToolOutcome.success(tool.toolCallId, tool.toolName, executionResult);
319
+ * } catch (error) {
320
+ * toolResult = IllaToolOutcome.error(
321
+ * tool.toolCallId,
322
+ * tool.toolName,
323
+ * IllaToolError.execution(tool.toolCallId, tool.toolName, error.message)
324
+ * );
325
+ * }
248
326
  *
249
- * const result2 = await sdk.sendToolResult(result1.chatId, toolResult);
327
+ * // Send the result back to ILLA
328
+ * const result2 = await sdk.sendToolResult(result1.chatId, toolResult.toJSON());
250
329
  * console.log(result2.response.text); // ILLA's response after processing the tool result
251
330
  * }
252
331
  * ```
253
332
  */
254
333
  async sendToolResult(chatId, toolResult) {
255
- if (this.chats.get(chatId) === undefined) {
334
+ if (!this.chats.has(chatId)) {
256
335
  throw new ChatNotFound(chatId);
257
336
  }
258
- return await this.chats.get(chatId).sendMessage(new Prompt({ toolResult }));
337
+ return this.chats.get(chatId).sendMessage([new Prompt({ toolResult: [toolResult] })]);
259
338
  }
260
339
  /**
261
340
  * Gets the messages for a given chat ID.
@@ -271,6 +350,265 @@ class IllaSDK {
271
350
  }
272
351
  return chat.messages;
273
352
  }
353
+ /**
354
+ * Appends messages to an existing chat's message history.
355
+ *
356
+ * @param chatId - The ID of the chat to append messages to
357
+ * @param messages - The messages to append to the chat history
358
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
363
+ *
364
+ * // Append synthetic messages for testing or prompting
365
+ * await sdk.appendMessages(chatId, [
366
+ * { role: "user", content: "Previous context..." },
367
+ * { role: "assistant", content: "Understood..." }
368
+ * ]);
369
+ * ```
370
+ */
371
+ async appendMessages(chatId, messages) {
372
+ if (!this.chats.has(chatId)) {
373
+ throw new ChatNotFound(chatId);
374
+ }
375
+ await this.contextManager.appendMessages(chatId, messages);
376
+ }
377
+ /**
378
+ * Clears the message history for a chat while keeping the chat instance.
379
+ *
380
+ * @param chatId - The ID of the chat to clear
381
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
386
+ *
387
+ * // Clear chat history to start fresh
388
+ * await sdk.clearContext(chatId);
389
+ * ```
390
+ */
391
+ async clearContext(chatId) {
392
+ if (!this.chats.has(chatId)) {
393
+ throw new ChatNotFound(chatId);
394
+ }
395
+ await this.contextManager.clearContext(chatId);
396
+ }
397
+ /**
398
+ * Deletes a chat and removes all associated data.
399
+ *
400
+ * @param chatId - The ID of the chat to delete
401
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
402
+ *
403
+ * @example
404
+ * ```typescript
405
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
406
+ *
407
+ * // Clean up chat when done
408
+ * await sdk.deleteChat(chatId);
409
+ * ```
410
+ */
411
+ async deleteChat(chatId) {
412
+ if (!this.chats.has(chatId)) {
413
+ throw new ChatNotFound(chatId);
414
+ }
415
+ await this.contextManager.deleteContext(chatId);
416
+ this.chats.delete(chatId);
417
+ }
418
+ /**
419
+ * Sends multiple tool results back to the AI in a single request.
420
+ * This method is used when multiple tools need to be executed and their results
421
+ * sent back together.
422
+ *
423
+ * @param chatId - The ID of the chat to send the tool results to
424
+ * @param toolResults - Array of tool execution results
425
+ * @param options - Optional parameters including AbortSignal
426
+ * @returns {Promise<SendMessageResult>} The AI's response after processing all tool results
427
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
428
+ *
429
+ * @example
430
+ * ```typescript
431
+ * import { IllaToolOutcome, IllaToolError } from '@illalabs/interfaces';
432
+ *
433
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
434
+ *
435
+ * // Execute multiple tools and send results together
436
+ * const toolResults = pendingTools.map(tool => {
437
+ * try {
438
+ * const result = executeToolSync(tool);
439
+ * return IllaToolOutcome.success(tool.toolCallId, tool.toolName, result);
440
+ * } catch (error) {
441
+ * return IllaToolOutcome.error(
442
+ * tool.toolCallId,
443
+ * tool.toolName,
444
+ * IllaToolError.execution(tool.toolCallId, tool.toolName, error.message)
445
+ * );
446
+ * }
447
+ * });
448
+ *
449
+ * const response = await sdk.sendToolResults(chatId, toolResults.map(r => r.toJSON()));
450
+ * ```
451
+ */
452
+ async sendToolResults(chatId, toolResults) {
453
+ if (!this.chats.has(chatId)) {
454
+ throw new ChatNotFound(chatId);
455
+ }
456
+ if (toolResults.length === 0) {
457
+ throw new SdkEmptyToolsResultsError({ chatId });
458
+ }
459
+ const chat = this.chats.get(chatId);
460
+ return await chat.sendMessage(toolResults.map((toolResult) => new Prompt({ toolResult: [toolResult] })));
461
+ }
462
+ /**
463
+ * Subscribes to status updates for a long-running tool execution.
464
+ *
465
+ * @param params - Parameters identifying the tool execution to monitor
466
+ * @param callbacks - Event handlers for status changes and errors
467
+ * @param config - Optional polling configuration
468
+ * @returns {EventSubscription} Subscription handle to cancel monitoring
469
+ *
470
+ * @example
471
+ * ```typescript
472
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
473
+ *
474
+ * const subscription = sdk.subscribeToToolStatus(
475
+ * { toolName: "swap", protocol: "li.fi", args: txHash },
476
+ * {
477
+ * onStatusChange: (event) => console.log("Status:", event.status),
478
+ * onError: (error) => console.error("Error:", error)
479
+ * },
480
+ * { interval: 2000, maxDuration: 300, maxRetries: 3 }
481
+ * );
482
+ *
483
+ * // Later, cancel the subscription
484
+ * subscription.unsubscribe();
485
+ * ```
486
+ */
487
+ subscribeToToolStatus(params, callbacks, config) {
488
+ const asyncToolChecker = new AsyncToolChecker({
489
+ coreApiProvider: this.coreApiProvider,
490
+ });
491
+ const defaultConfig = {
492
+ interval: config?.interval ?? 5000,
493
+ maxDuration: config?.maxDuration ?? 300,
494
+ retryThreshold: config?.retryThreshold ?? 30000,
495
+ maxRetries: config?.maxRetries ?? 3,
496
+ };
497
+ return asyncToolChecker.subscribe(params, callbacks, defaultConfig);
498
+ }
499
+ /**
500
+ * Awaits the completion of a long-running action triggered by a chat.
501
+ *
502
+ * @param chatId - The ID of the chat that triggered the action
503
+ * @param descriptor - Descriptor identifying the action to track
504
+ * @returns {Promise<AwaitActionResult>} The final status of the action
505
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
506
+ *
507
+ * @example
508
+ * ```typescript
509
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
510
+ *
511
+ * const result = await sdk.awaitAction(chatId, {
512
+ * toolName: "swap",
513
+ * protocol: "li.fi",
514
+ * args: { txHash: "0x..." }
515
+ * });
516
+ *
517
+ * if (result.isError) {
518
+ * console.error("Action failed:", result.error);
519
+ * } else {
520
+ * console.log("Action completed:", result.response);
521
+ * }
522
+ * ```
523
+ */
524
+ async awaitAction(chatId, descriptor) {
525
+ const chat = this.chats.get(chatId);
526
+ if (!chat) {
527
+ throw new ChatNotFound(chatId);
528
+ }
529
+ return chat.awaitAction(descriptor);
530
+ }
531
+ /**
532
+ * Gets the underlying Chat instance for advanced operations.
533
+ *
534
+ * @param chatId - The ID of the chat to retrieve
535
+ * @returns {Chat} The Chat instance
536
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
537
+ *
538
+ * @example
539
+ * ```typescript
540
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
541
+ *
542
+ * const chat = sdk.getChat(chatId);
543
+ * // Now you can use advanced Chat methods directly
544
+ * const context = await chat.getContext();
545
+ * ```
546
+ */
547
+ getChat(chatId) {
548
+ const chat = this.chats.get(chatId);
549
+ if (!chat) {
550
+ throw new ChatNotFound(chatId);
551
+ }
552
+ return chat;
553
+ }
554
+ /**
555
+ * Gets all active chat IDs as an array.
556
+ * Alias for the chatIds getter property.
557
+ *
558
+ * @returns {string[]} Array of active chat IDs
559
+ *
560
+ * @example
561
+ * ```typescript
562
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
563
+ *
564
+ * const ids = sdk.getChatIds();
565
+ * console.log("Active chats:", ids);
566
+ * ```
567
+ */
568
+ getChatIds() {
569
+ return this.chatIds;
570
+ }
571
+ /**
572
+ * Helper method to extract detailed response metadata from a SendMessageResult.
573
+ * Provides access to incompleteTools, toolErrors, and other response details.
574
+ *
575
+ * @param result - The SendMessageResult to extract metadata from
576
+ * @returns {ResponseMetadata} Extracted response metadata
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
581
+ *
582
+ * const result = await sdk.sendMessage("Hello", { chatId });
583
+ * const metadata = sdk.getResponseMetadata(result);
584
+ *
585
+ * if (metadata.incompleteTools?.length > 0) {
586
+ * console.log("Incomplete tools:", metadata.incompleteTools);
587
+ * }
588
+ * if (metadata.toolErrors?.length > 0) {
589
+ * console.log("Tool errors:", metadata.toolErrors);
590
+ * }
591
+ * ```
592
+ */
593
+ getResponseMetadata(result) {
594
+ if (result.response.isError) {
595
+ return {
596
+ isError: true,
597
+ error: result.response.error,
598
+ };
599
+ }
600
+ const data = result.response.data;
601
+ return {
602
+ isError: false,
603
+ text: data.text,
604
+ messages: data.messages,
605
+ pendingTools: data.pendingTools,
606
+ toolErrors: data.toolErrors,
607
+ };
608
+ }
609
+ isSuccessResponse(response) {
610
+ return "status" in response && response.status === 200;
611
+ }
274
612
  }
275
613
  /**
276
614
  * Exports the public API of the SDK.
@@ -285,4 +623,6 @@ export { ContextManager } from "./context/index.js";
285
623
  export { AsyncToolChecker } from "./asyncToolChecker/index.js";
286
624
  export { CoreApiProvider } from "./providers/index.js";
287
625
  export { UserContextMissing } from "./chat/errors/index.js";
626
+ export { TelemetryClient, TelemetryStreamFailed, } from "./telemetry/index.js";
627
+ export { parseSSEStream, SSEParse, StreamingHttpError, StreamingResponseBodyNull, StreamingServerError, } from "./streaming/index.js";
288
628
  //# sourceMappingURL=sdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,gBAAgB,EAChB,IAAI,EACJ,cAAc,EACd,eAAe,EACf,aAAa,EACb,MAAM,EACN,kBAAkB,GACrB,MAAM,eAAe,CAAC;AAyDvB;;;;;GAKG;AACH,MAAM,YAAa,SAAQ,KAAK;IAC5B;;OAEG;IACa,MAAM,CAAS;IAE/B;;;;;OAKG;IACH,YAAmB,MAAc,EAAE,OAAsB;QACrD,KAAK,CAAC,gBAAgB,MAAM,YAAY,EAAE,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO;IACD,eAAe,CAAkB;IACjC,cAAc,CAAkB;IAEhC,KAAK,GAAsB,IAAI,GAAG,EAAE,CAAC;IAE7C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,YAAY,MAAqB,EAAE,OAAwB;QACvD,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC;YACvC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE;gBACL,WAA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sB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACH,eAAe,EACf,qBAAqB,GAGxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GAOvB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Error thrown when SSE parsing fails.
3
+ *
4
+ * This error is emitted when the SSE stream contains malformed data
5
+ * that cannot be parsed as valid JSON or event format.
6
+ */
7
+ export declare class SSEParse extends Error {
8
+ /**
9
+ * Creates a new SSEParse error
10
+ * @param message - Description of the parse error
11
+ * @param cause - Optional underlying error that caused the parse failure
12
+ */
13
+ constructor(message: string, cause?: unknown);
14
+ }
15
+ //# sourceMappingURL=SSEParse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SSEParse.d.ts","sourceRoot":"","sources":["../../../../src/streaming/errors/SSEParse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAC/B;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAW/C"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Error thrown when SSE parsing fails.
3
+ *
4
+ * This error is emitted when the SSE stream contains malformed data
5
+ * that cannot be parsed as valid JSON or event format.
6
+ */
7
+ export class SSEParse extends Error {
8
+ /**
9
+ * Creates a new SSEParse error
10
+ * @param message - Description of the parse error
11
+ * @param cause - Optional underlying error that caused the parse failure
12
+ */
13
+ constructor(message, cause) {
14
+ super(`SSE parse error: ${message}`, { cause });
15
+ this.name = "SSEParse";
16
+ // Restore the prototype chain for proper Error subclassing in TypeScript
17
+ Object.setPrototypeOf(this, new.target.prototype);
18
+ if (Error.captureStackTrace) {
19
+ Error.captureStackTrace(this, SSEParse);
20
+ }
21
+ }
22
+ }
23
+ //# sourceMappingURL=SSEParse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SSEParse.js","sourceRoot":"","sources":["../../../../src/streaming/errors/SSEParse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAC/B;;;;OAIG;IACH,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,oBAAoB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvB,yEAAyE;QACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Error thrown when the streaming request receives an HTTP error response.
3
+ *
4
+ * This error captures the HTTP status code and error message from the server.
5
+ */
6
+ export declare class StreamingHttpError extends Error {
7
+ /**
8
+ * The HTTP status code from the failed request.
9
+ */
10
+ readonly statusCode: number;
11
+ /**
12
+ * Creates a new StreamingHttpError.
13
+ * @param statusCode - The HTTP status code from the response
14
+ * @param message - The error message from the server or a default message
15
+ */
16
+ constructor(statusCode: number, message: string);
17
+ }
18
+ //# sourceMappingURL=StreamingHttpError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingHttpError.d.ts","sourceRoot":"","sources":["../../../../src/streaming/errors/StreamingHttpError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACzC;;OAEG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;gBACS,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAYlD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Error thrown when the streaming request receives an HTTP error response.
3
+ *
4
+ * This error captures the HTTP status code and error message from the server.
5
+ */
6
+ export class StreamingHttpError extends Error {
7
+ /**
8
+ * The HTTP status code from the failed request.
9
+ */
10
+ statusCode;
11
+ /**
12
+ * Creates a new StreamingHttpError.
13
+ * @param statusCode - The HTTP status code from the response
14
+ * @param message - The error message from the server or a default message
15
+ */
16
+ constructor(statusCode, message) {
17
+ super(message);
18
+ this.name = "StreamingHttpError";
19
+ this.statusCode = statusCode;
20
+ // Restore the prototype chain for proper Error subclassing in TypeScript
21
+ Object.setPrototypeOf(this, new.target.prototype);
22
+ if (Error.captureStackTrace) {
23
+ Error.captureStackTrace(this, StreamingHttpError);
24
+ }
25
+ }
26
+ }
27
+ //# sourceMappingURL=StreamingHttpError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingHttpError.js","sourceRoot":"","sources":["../../../../src/streaming/errors/StreamingHttpError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzC;;OAEG;IACa,UAAU,CAAS;IAEnC;;;;OAIG;IACH,YAAY,UAAkB,EAAE,OAAe;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,yEAAyE;QACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Error thrown when the streaming response body is null.
3
+ *
4
+ * This typically indicates the server did not return a streaming response
5
+ * when one was expected.
6
+ */
7
+ export declare class StreamingResponseBodyNull extends Error {
8
+ /**
9
+ * Creates a new StreamingResponseBodyNull error.
10
+ */
11
+ constructor();
12
+ }
13
+ //# sourceMappingURL=StreamingResponseBodyNull.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingResponseBodyNull.d.ts","sourceRoot":"","sources":["../../../../src/streaming/errors/StreamingResponseBodyNull.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAChD;;OAEG;;CAYN"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Error thrown when the streaming response body is null.
3
+ *
4
+ * This typically indicates the server did not return a streaming response
5
+ * when one was expected.
6
+ */
7
+ export class StreamingResponseBodyNull extends Error {
8
+ /**
9
+ * Creates a new StreamingResponseBodyNull error.
10
+ */
11
+ constructor() {
12
+ super("Response body is null - streaming not available");
13
+ this.name = "StreamingResponseBodyNull";
14
+ // Restore the prototype chain for proper Error subclassing in TypeScript
15
+ Object.setPrototypeOf(this, new.target.prototype);
16
+ if (Error.captureStackTrace) {
17
+ Error.captureStackTrace(this, StreamingResponseBodyNull);
18
+ }
19
+ }
20
+ }
21
+ //# sourceMappingURL=StreamingResponseBodyNull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingResponseBodyNull.js","sourceRoot":"","sources":["../../../../src/streaming/errors/StreamingResponseBodyNull.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAChD;;OAEG;IACH;QACI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QAExC,yEAAyE;QACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,yBAAyB,CAAC,CAAC;QAC7D,CAAC;IACL,CAAC;CACJ"}