@toothfairyai/cli 1.0.10 → 1.0.12

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/bin/toothfairy.js +37 -10
  2. package/package.json +1 -1
package/bin/toothfairy.js CHANGED
@@ -243,6 +243,7 @@ program
243
243
  let currentText = '';
244
244
  let finalResponse = null;
245
245
  let processingStatus = null;
246
+ let lastUpdateTime = 0;
246
247
 
247
248
  const mapStateWithLabel = (state) => {
248
249
  switch (state) {
@@ -321,7 +322,11 @@ program
321
322
  let currentSpinner = null;
322
323
 
323
324
  // Function to update display with status filtering
324
- const updateDisplay = (text, agentStatus, messageId, type = 'response') => {
325
+ const updateDisplay = (
326
+ text,
327
+ agentStatus,
328
+ type = 'response'
329
+ ) => {
325
330
  if (currentSpinner) {
326
331
  currentSpinner.stop();
327
332
  currentSpinner = null;
@@ -330,12 +335,20 @@ program
330
335
  // Only show text when agent is actually replying
331
336
  if (text && type === 'response' && agentStatus === 'replying') {
332
337
  const trimmedText = text.trim();
333
- // Check if text is actually new/different and longer than before
334
- if (trimmedText !== currentText && trimmedText.length > currentText.length) {
338
+ const now = Date.now();
339
+
340
+ // Only update if the text is actually different and enough time has passed
341
+ // This prevents rapid duplicate updates
342
+ if (
343
+ trimmedText !== currentText &&
344
+ trimmedText?.length > currentText?.length &&
345
+ now - lastUpdateTime > 50
346
+ ) {
335
347
  // For real-time streaming, we overwrite the current line
336
348
  process.stdout.write('\r\x1b[K'); // Clear current line
337
349
  process.stdout.write(chalk.green('🧚 Response: ') + trimmedText);
338
350
  currentText = trimmedText;
351
+ lastUpdateTime = now;
339
352
  }
340
353
  }
341
354
  };
@@ -372,7 +385,9 @@ program
372
385
 
373
386
  if (eventData.status === 'complete') {
374
387
  if (options.showProgress) {
375
- console.log(chalk.green('\nšŸŽ‰ Stream completed successfully!'));
388
+ console.log(
389
+ chalk.green('\nšŸŽ‰ Stream completed successfully!')
390
+ );
376
391
  }
377
392
  return;
378
393
  }
@@ -409,7 +424,6 @@ program
409
424
  updateDisplay(
410
425
  eventData.text,
411
426
  agentStatus,
412
- eventData.message_id,
413
427
  'response'
414
428
  );
415
429
  }
@@ -424,12 +438,17 @@ program
424
438
  currentSpinner = null;
425
439
  }
426
440
  process.stdout.write('\r\x1b[K'); // Clear current line
427
- process.stdout.write(chalk.blue('šŸŖ„ ') + currentText.trim());
441
+ process.stdout.write(
442
+ chalk.blue('šŸŖ„ ') + currentText.trim()
443
+ );
428
444
  }
429
445
  }
430
446
 
431
447
  // Handle additional metadata events (images, files, callback metadata)
432
- if (eventData.images !== undefined || eventData.files !== undefined) {
448
+ if (
449
+ eventData.images !== undefined ||
450
+ eventData.files !== undefined
451
+ ) {
433
452
  // These are attachment events - could show notification if needed
434
453
  if (options.verbose) {
435
454
  console.log(chalk.dim('\nšŸ“Ž Attachments processed'));
@@ -439,7 +458,9 @@ program
439
458
  if (eventData.callbackMetadata) {
440
459
  // Function execution metadata
441
460
  if (options.verbose) {
442
- console.log(chalk.dim('\nāš™ļø Function execution metadata received'));
461
+ console.log(
462
+ chalk.dim('\nāš™ļø Function execution metadata received')
463
+ );
443
464
  }
444
465
  }
445
466
  }
@@ -476,9 +497,15 @@ program
476
497
  if (key === 'agent_processing_status') {
477
498
  console.log(chalk.cyan(`${key}:`), chalk.green(value));
478
499
  } else if (key === 'duration') {
479
- console.log(chalk.cyan(`${key}:`), chalk.yellow(`${value}s`));
500
+ console.log(
501
+ chalk.cyan(`${key}:`),
502
+ chalk.yellow(`${value}s`)
503
+ );
480
504
  } else if (key === 'sources' && Array.isArray(value)) {
481
- console.log(chalk.cyan(`${key}:`), value.length > 0 ? value.join(', ') : 'None');
505
+ console.log(
506
+ chalk.cyan(`${key}:`),
507
+ value.length > 0 ? value.join(', ') : 'None'
508
+ );
482
509
  } else {
483
510
  console.log(chalk.cyan(`${key}:`), String(value));
484
511
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toothfairyai/cli",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Command-line interface for ToothFairy AI API",
5
5
  "main": "index.js",
6
6
  "bin": {