@yeaft/webchat-agent 0.1.453 → 0.1.454

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.453",
3
+ "version": "0.1.454",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/unify/engine.js CHANGED
@@ -374,6 +374,7 @@ export class Engine {
374
374
  });
375
375
 
376
376
  const startTime = Date.now();
377
+ let ttfbMs = null; // Time to first token
377
378
  let responseText = '';
378
379
  const toolCalls = [];
379
380
  let stopReason = 'end_turn';
@@ -393,6 +394,7 @@ export class Engine {
393
394
  })) {
394
395
  switch (event.type) {
395
396
  case 'text_delta':
397
+ if (ttfbMs === null) ttfbMs = Date.now() - startTime;
396
398
  responseText += event.text;
397
399
  yield event;
398
400
  break;
@@ -439,6 +441,7 @@ export class Engine {
439
441
  toolCalls: toolCalls.map(tc => ({ id: tc.id, name: tc.name, input: tc.input })),
440
442
  usage: { inputTokens: totalUsage.inputTokens, outputTokens: totalUsage.outputTokens },
441
443
  latencyMs,
444
+ ttfbMs,
442
445
  stopReason: 'error',
443
446
  };
444
447
 
@@ -495,6 +498,7 @@ export class Engine {
495
498
  toolCalls: toolCalls.map(tc => ({ id: tc.id, name: tc.name, input: tc.input })),
496
499
  usage: { inputTokens: totalUsage.inputTokens, outputTokens: totalUsage.outputTokens },
497
500
  latencyMs,
501
+ ttfbMs,
498
502
  stopReason,
499
503
  };
500
504
 
@@ -280,6 +280,7 @@ export async function handleUnifyChat(msg) {
280
280
  toolCalls: event.toolCalls,
281
281
  usage: event.usage,
282
282
  latencyMs: event.latencyMs,
283
+ ttfbMs: event.ttfbMs,
283
284
  stopReason: event.stopReason,
284
285
  });
285
286
  break;