@yeaft/webchat-agent 0.1.431 → 0.1.432
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 +1 -1
- package/unify/engine.js +29 -0
- package/unify/web-bridge.js +16 -0
package/package.json
CHANGED
package/unify/engine.js
CHANGED
|
@@ -424,6 +424,20 @@ export class Engine {
|
|
|
424
424
|
responseText,
|
|
425
425
|
});
|
|
426
426
|
|
|
427
|
+
// Emit debug_turn for error path too
|
|
428
|
+
yield {
|
|
429
|
+
type: 'debug_turn',
|
|
430
|
+
turnNumber,
|
|
431
|
+
model: currentModel,
|
|
432
|
+
systemPrompt,
|
|
433
|
+
messages: conversationMessages.map(m => ({ role: m.role, content: typeof m.content === 'string' ? m.content.slice(0, 50000) : m.content })),
|
|
434
|
+
response: responseText || `Error: ${err.message}`,
|
|
435
|
+
toolCalls: toolCalls.map(tc => ({ id: tc.id, name: tc.name, input: tc.input })),
|
|
436
|
+
usage: { inputTokens: totalUsage.inputTokens, outputTokens: totalUsage.outputTokens },
|
|
437
|
+
latencyMs,
|
|
438
|
+
stopReason: 'error',
|
|
439
|
+
};
|
|
440
|
+
|
|
427
441
|
// ─── LLMContextError → force compact → retry ──────
|
|
428
442
|
if (err instanceof LLMContextError && this.#conversationStore && this.#memoryStore) {
|
|
429
443
|
const consolidated = await this.#maybeConsolidate();
|
|
@@ -465,6 +479,21 @@ export class Engine {
|
|
|
465
479
|
responseText,
|
|
466
480
|
});
|
|
467
481
|
|
|
482
|
+
// Emit debug_turn event for web UI debug panel
|
|
483
|
+
// (conversationMessages does NOT yet include the assistant response at this point)
|
|
484
|
+
yield {
|
|
485
|
+
type: 'debug_turn',
|
|
486
|
+
turnNumber,
|
|
487
|
+
model: currentModel,
|
|
488
|
+
systemPrompt,
|
|
489
|
+
messages: conversationMessages.map(m => ({ role: m.role, content: typeof m.content === 'string' ? m.content.slice(0, 50000) : m.content })),
|
|
490
|
+
response: responseText,
|
|
491
|
+
toolCalls: toolCalls.map(tc => ({ id: tc.id, name: tc.name, input: tc.input })),
|
|
492
|
+
usage: { inputTokens: totalUsage.inputTokens, outputTokens: totalUsage.outputTokens },
|
|
493
|
+
latencyMs,
|
|
494
|
+
stopReason,
|
|
495
|
+
};
|
|
496
|
+
|
|
468
497
|
// Append assistant message to conversation
|
|
469
498
|
const assistantMsg = { role: 'assistant', content: responseText };
|
|
470
499
|
if (toolCalls.length > 0) {
|
package/unify/web-bridge.js
CHANGED
|
@@ -214,6 +214,22 @@ export async function handleUnifyChat(msg) {
|
|
|
214
214
|
});
|
|
215
215
|
break;
|
|
216
216
|
|
|
217
|
+
// ── Debug turn data for web debug panel ──
|
|
218
|
+
case 'debug_turn':
|
|
219
|
+
sendUnifyEvent({
|
|
220
|
+
type: 'debug_turn',
|
|
221
|
+
turnNumber: event.turnNumber,
|
|
222
|
+
model: event.model,
|
|
223
|
+
systemPrompt: event.systemPrompt,
|
|
224
|
+
messages: event.messages,
|
|
225
|
+
response: event.response,
|
|
226
|
+
toolCalls: event.toolCalls,
|
|
227
|
+
usage: event.usage,
|
|
228
|
+
latencyMs: event.latencyMs,
|
|
229
|
+
stopReason: event.stopReason,
|
|
230
|
+
});
|
|
231
|
+
break;
|
|
232
|
+
|
|
217
233
|
// ── Errors ──
|
|
218
234
|
case 'error':
|
|
219
235
|
sendUnifyOutput({
|