@toothfairyai/cli 1.1.3 → 1.1.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/api.js +85 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toothfairyai/cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Command-line interface for ToothFairyAI API",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/api.js CHANGED
@@ -215,16 +215,28 @@ class ToothFairyAPI {
215
215
  };
216
216
 
217
217
  // Only include attachment fields if they have content
218
- if (processedAttachments.images && processedAttachments.images.length > 0) {
218
+ if (
219
+ processedAttachments.images &&
220
+ processedAttachments.images.length > 0
221
+ ) {
219
222
  messageData.images = processedAttachments.images;
220
223
  }
221
- if (processedAttachments.audios && processedAttachments.audios.length > 0) {
224
+ if (
225
+ processedAttachments.audios &&
226
+ processedAttachments.audios.length > 0
227
+ ) {
222
228
  messageData.audios = processedAttachments.audios;
223
229
  }
224
- if (processedAttachments.videos && processedAttachments.videos.length > 0) {
230
+ if (
231
+ processedAttachments.videos &&
232
+ processedAttachments.videos.length > 0
233
+ ) {
225
234
  messageData.videos = processedAttachments.videos;
226
235
  }
227
- if (processedAttachments.files && processedAttachments.files.length > 0) {
236
+ if (
237
+ processedAttachments.files &&
238
+ processedAttachments.files.length > 0
239
+ ) {
228
240
  messageData.files = processedAttachments.files;
229
241
  }
230
242
 
@@ -233,9 +245,9 @@ class ToothFairyAPI {
233
245
  messages: [messageData],
234
246
  agentid: agentId,
235
247
  };
236
-
248
+
237
249
  const agentResponse = await this.getAgentResponse(agentData);
238
-
250
+
239
251
  return {
240
252
  chatId: agentResponse.chatId || chatId,
241
253
  messageId: agentResponse.messageId || 'auto-generated',
@@ -251,16 +263,28 @@ class ToothFairyAPI {
251
263
  };
252
264
 
253
265
  // Only include attachment fields if they have content
254
- if (processedAttachments.images && processedAttachments.images.length > 0) {
266
+ if (
267
+ processedAttachments.images &&
268
+ processedAttachments.images.length > 0
269
+ ) {
255
270
  messageData.images = processedAttachments.images;
256
271
  }
257
- if (processedAttachments.audios && processedAttachments.audios.length > 0) {
272
+ if (
273
+ processedAttachments.audios &&
274
+ processedAttachments.audios.length > 0
275
+ ) {
258
276
  messageData.audios = processedAttachments.audios;
259
277
  }
260
- if (processedAttachments.videos && processedAttachments.videos.length > 0) {
278
+ if (
279
+ processedAttachments.videos &&
280
+ processedAttachments.videos.length > 0
281
+ ) {
261
282
  messageData.videos = processedAttachments.videos;
262
283
  }
263
- if (processedAttachments.files && processedAttachments.files.length > 0) {
284
+ if (
285
+ processedAttachments.files &&
286
+ processedAttachments.files.length > 0
287
+ ) {
264
288
  messageData.files = processedAttachments.files;
265
289
  }
266
290
 
@@ -275,12 +299,12 @@ class ToothFairyAPI {
275
299
  providerId: providerId,
276
300
  customerInfo: customerInfo,
277
301
  };
278
-
302
+
279
303
  const agentResponse = await this.getAgentResponse(agentData);
280
-
304
+
281
305
  return {
282
306
  chatId: agentResponse.chatId || 'auto-generated',
283
- messageId: agentResponse.messageId || 'auto-generated',
307
+ messageId: agentResponse.messageId || 'auto-generated',
284
308
  agentResponse: agentResponse,
285
309
  };
286
310
  }
@@ -408,16 +432,28 @@ class ToothFairyAPI {
408
432
  };
409
433
 
410
434
  // Only include attachment fields if they have content
411
- if (processedAttachments.images && processedAttachments.images.length > 0) {
435
+ if (
436
+ processedAttachments.images &&
437
+ processedAttachments.images.length > 0
438
+ ) {
412
439
  messageData.images = processedAttachments.images;
413
440
  }
414
- if (processedAttachments.audios && processedAttachments.audios.length > 0) {
441
+ if (
442
+ processedAttachments.audios &&
443
+ processedAttachments.audios.length > 0
444
+ ) {
415
445
  messageData.audios = processedAttachments.audios;
416
446
  }
417
- if (processedAttachments.videos && processedAttachments.videos.length > 0) {
447
+ if (
448
+ processedAttachments.videos &&
449
+ processedAttachments.videos.length > 0
450
+ ) {
418
451
  messageData.videos = processedAttachments.videos;
419
452
  }
420
- if (processedAttachments.files && processedAttachments.files.length > 0) {
453
+ if (
454
+ processedAttachments.files &&
455
+ processedAttachments.files.length > 0
456
+ ) {
421
457
  messageData.files = processedAttachments.files;
422
458
  }
423
459
 
@@ -510,7 +546,10 @@ class ToothFairyAPI {
510
546
  // Final response with complete data
511
547
  onEvent('complete', eventData);
512
548
  }
513
- } else if (eventData.text && eventData.type === 'message') {
549
+ } else if (
550
+ eventData.text &&
551
+ eventData.type === 'message'
552
+ ) {
514
553
  // This is streaming text data
515
554
  onEvent('data', eventData);
516
555
  } else if (
@@ -525,7 +564,10 @@ class ToothFairyAPI {
525
564
  ) {
526
565
  // Callback metadata with function details and execution plan
527
566
  onEvent('callback', eventData);
528
- } else if (eventData.type === 'chat_created' || eventData.event === 'chat_created') {
567
+ } else if (
568
+ eventData.type === 'chat_created' ||
569
+ eventData.event === 'chat_created'
570
+ ) {
529
571
  // Chat creation event
530
572
  onEvent('chat_created', eventData);
531
573
  } else {
@@ -569,7 +611,9 @@ class ToothFairyAPI {
569
611
  } else {
570
612
  // No chatId provided - let streaming API create chat automatically
571
613
  if (this.verbose) {
572
- console.debug('No chatId provided - letting API create chat automatically');
614
+ console.debug(
615
+ 'No chatId provided - letting API create chat automatically'
616
+ );
573
617
  }
574
618
 
575
619
  // Prepare message data for automatic chat creation
@@ -580,16 +624,28 @@ class ToothFairyAPI {
580
624
  };
581
625
 
582
626
  // Only include attachment fields if they have content
583
- if (processedAttachments.images && processedAttachments.images.length > 0) {
627
+ if (
628
+ processedAttachments.images &&
629
+ processedAttachments.images.length > 0
630
+ ) {
584
631
  messageData.images = processedAttachments.images;
585
632
  }
586
- if (processedAttachments.audios && processedAttachments.audios.length > 0) {
633
+ if (
634
+ processedAttachments.audios &&
635
+ processedAttachments.audios.length > 0
636
+ ) {
587
637
  messageData.audios = processedAttachments.audios;
588
638
  }
589
- if (processedAttachments.videos && processedAttachments.videos.length > 0) {
639
+ if (
640
+ processedAttachments.videos &&
641
+ processedAttachments.videos.length > 0
642
+ ) {
590
643
  messageData.videos = processedAttachments.videos;
591
644
  }
592
- if (processedAttachments.files && processedAttachments.files.length > 0) {
645
+ if (
646
+ processedAttachments.files &&
647
+ processedAttachments.files.length > 0
648
+ ) {
593
649
  messageData.files = processedAttachments.files;
594
650
  }
595
651
 
@@ -687,7 +743,10 @@ class ToothFairyAPI {
687
743
  // Final response with complete data
688
744
  onEvent('complete', eventData);
689
745
  }
690
- } else if (eventData.text && eventData.type === 'message') {
746
+ } else if (
747
+ eventData.text &&
748
+ eventData.type === 'message'
749
+ ) {
691
750
  // This is streaming text data
692
751
  onEvent('data', eventData);
693
752
  } else if (
@@ -1250,8 +1309,7 @@ class ToothFairyAPI {
1250
1309
  externalPath = filePath; // Use URL directly
1251
1310
  } else {
1252
1311
  // For files, construct S3 path
1253
- const filename = path.basename(filePath);
1254
- externalPath = `s3://files-to-import-aus-prod/imported-pdf/${filename}`;
1312
+ externalPath = `s3://files-to-import-aus-prod/${filePath}`;
1255
1313
  }
1256
1314
 
1257
1315
  const documentData = {