@toothfairyai/cli 1.0.11 ā 1.0.13
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.
- package/bin/toothfairy.js +35 -19
- package/package.json +1 -1
package/bin/toothfairy.js
CHANGED
|
@@ -244,6 +244,7 @@ program
|
|
|
244
244
|
let finalResponse = null;
|
|
245
245
|
let processingStatus = null;
|
|
246
246
|
let lastUpdateTime = 0;
|
|
247
|
+
let hasStartedResponse = false;
|
|
247
248
|
|
|
248
249
|
const mapStateWithLabel = (state) => {
|
|
249
250
|
switch (state) {
|
|
@@ -322,7 +323,7 @@ program
|
|
|
322
323
|
let currentSpinner = null;
|
|
323
324
|
|
|
324
325
|
// Function to update display with status filtering
|
|
325
|
-
const updateDisplay = (text, agentStatus,
|
|
326
|
+
const updateDisplay = (text, agentStatus, type = 'response') => {
|
|
326
327
|
if (currentSpinner) {
|
|
327
328
|
currentSpinner.stop();
|
|
328
329
|
currentSpinner = null;
|
|
@@ -332,13 +333,21 @@ program
|
|
|
332
333
|
if (text && type === 'response' && agentStatus === 'replying') {
|
|
333
334
|
const trimmedText = text.trim();
|
|
334
335
|
const now = Date.now();
|
|
335
|
-
|
|
336
|
+
|
|
336
337
|
// Only update if the text is actually different and enough time has passed
|
|
337
338
|
// This prevents rapid duplicate updates
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
339
|
+
if (
|
|
340
|
+
trimmedText !== currentText &&
|
|
341
|
+
trimmedText?.length > currentText?.length &&
|
|
342
|
+
now - lastUpdateTime > 50
|
|
343
|
+
) {
|
|
344
|
+
if (!hasStartedResponse) {
|
|
345
|
+
// First time showing response - print header on new line
|
|
346
|
+
console.log(chalk.green('š§ Responding'));
|
|
347
|
+
hasStartedResponse = true;
|
|
348
|
+
}
|
|
349
|
+
// Stream new text content on new line
|
|
350
|
+
console.log(trimmedText);
|
|
342
351
|
currentText = trimmedText;
|
|
343
352
|
lastUpdateTime = now;
|
|
344
353
|
}
|
|
@@ -377,7 +386,9 @@ program
|
|
|
377
386
|
|
|
378
387
|
if (eventData.status === 'complete') {
|
|
379
388
|
if (options.showProgress) {
|
|
380
|
-
console.log(
|
|
389
|
+
console.log(
|
|
390
|
+
chalk.green('\nš Stream completed successfully!')
|
|
391
|
+
);
|
|
381
392
|
}
|
|
382
393
|
return;
|
|
383
394
|
}
|
|
@@ -411,12 +422,7 @@ program
|
|
|
411
422
|
|
|
412
423
|
// Handle progressive text streaming
|
|
413
424
|
if (eventData.text && agentStatus === 'replying') {
|
|
414
|
-
updateDisplay(
|
|
415
|
-
eventData.text,
|
|
416
|
-
agentStatus,
|
|
417
|
-
eventData.message_id,
|
|
418
|
-
'response'
|
|
419
|
-
);
|
|
425
|
+
updateDisplay(eventData.text, agentStatus, 'response');
|
|
420
426
|
}
|
|
421
427
|
|
|
422
428
|
// Handle fulfilled status (final response)
|
|
@@ -428,13 +434,15 @@ program
|
|
|
428
434
|
currentSpinner.stop();
|
|
429
435
|
currentSpinner = null;
|
|
430
436
|
}
|
|
431
|
-
|
|
432
|
-
process.stdout.write(chalk.blue('šŖ ') + currentText.trim());
|
|
437
|
+
console.log(chalk.blue('šŖ Response complete'));
|
|
433
438
|
}
|
|
434
439
|
}
|
|
435
440
|
|
|
436
441
|
// Handle additional metadata events (images, files, callback metadata)
|
|
437
|
-
if (
|
|
442
|
+
if (
|
|
443
|
+
eventData.images !== undefined ||
|
|
444
|
+
eventData.files !== undefined
|
|
445
|
+
) {
|
|
438
446
|
// These are attachment events - could show notification if needed
|
|
439
447
|
if (options.verbose) {
|
|
440
448
|
console.log(chalk.dim('\nš Attachments processed'));
|
|
@@ -444,7 +452,9 @@ program
|
|
|
444
452
|
if (eventData.callbackMetadata) {
|
|
445
453
|
// Function execution metadata
|
|
446
454
|
if (options.verbose) {
|
|
447
|
-
console.log(
|
|
455
|
+
console.log(
|
|
456
|
+
chalk.dim('\nāļø Function execution metadata received')
|
|
457
|
+
);
|
|
448
458
|
}
|
|
449
459
|
}
|
|
450
460
|
}
|
|
@@ -481,9 +491,15 @@ program
|
|
|
481
491
|
if (key === 'agent_processing_status') {
|
|
482
492
|
console.log(chalk.cyan(`${key}:`), chalk.green(value));
|
|
483
493
|
} else if (key === 'duration') {
|
|
484
|
-
console.log(
|
|
494
|
+
console.log(
|
|
495
|
+
chalk.cyan(`${key}:`),
|
|
496
|
+
chalk.yellow(`${value}s`)
|
|
497
|
+
);
|
|
485
498
|
} else if (key === 'sources' && Array.isArray(value)) {
|
|
486
|
-
console.log(
|
|
499
|
+
console.log(
|
|
500
|
+
chalk.cyan(`${key}:`),
|
|
501
|
+
value.length > 0 ? value.join(', ') : 'None'
|
|
502
|
+
);
|
|
487
503
|
} else {
|
|
488
504
|
console.log(chalk.cyan(`${key}:`), String(value));
|
|
489
505
|
}
|