@yeaft/webchat-agent 1.0.497 → 1.0.498
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.
|
Binary file
|
package/package.json
CHANGED
package/yeaft/debug-trace.js
CHANGED
|
@@ -211,6 +211,9 @@ function buildInitialRawRequestDelta(value) {
|
|
|
211
211
|
delta.set[key] = cloneRawValue(item);
|
|
212
212
|
}
|
|
213
213
|
const body = isPlainObject(value.body) ? value.body : null;
|
|
214
|
+
if (body && ['input', 'messages'].some(key => Object.hasOwn(body, key) && !Array.isArray(body[key]))) {
|
|
215
|
+
return { replacement: cloneRawValue(value) };
|
|
216
|
+
}
|
|
214
217
|
if (body) {
|
|
215
218
|
for (const [key, bodyValue] of Object.entries(body)) {
|
|
216
219
|
if (key === 'messages' || key === 'input') continue;
|
|
@@ -261,6 +264,10 @@ function buildRawRequestDelta(previous, next) {
|
|
|
261
264
|
|
|
262
265
|
const prevBody = isPlainObject(comparablePrevious.body) ? comparablePrevious.body : null;
|
|
263
266
|
const nextBody = isPlainObject(comparableNext.body) ? comparableNext.body : null;
|
|
267
|
+
if (prevBody && nextBody && (rawRequestMessageKey(prevBody) !== rawRequestMessageKey(nextBody)
|
|
268
|
+
|| [prevBody, nextBody].some(body => ['input', 'messages'].some(key => Object.hasOwn(body, key) && !Array.isArray(body[key]))))) {
|
|
269
|
+
return stableEqual(comparablePrevious, comparableNext) ? null : { replacement: cloneRawValue(comparableNext) };
|
|
270
|
+
}
|
|
264
271
|
if (prevBody && nextBody) {
|
|
265
272
|
for (const key of Object.keys(nextBody)) {
|
|
266
273
|
if (key === 'messages' || key === 'input') continue;
|
|
@@ -601,12 +608,12 @@ function summarizeTrace(trace, detailsLoaded = false) {
|
|
|
601
608
|
callId: t.toolCallId || t.id || null,
|
|
602
609
|
traceToolId: t.id || null,
|
|
603
610
|
name: t.toolName || t.name || '?',
|
|
611
|
+
toolInput: t.toolInput == null ? null : String(t.toolInput),
|
|
604
612
|
toolOutput: t.toolOutput == null ? null : String(t.toolOutput),
|
|
605
613
|
durationMs: t.durationMs || 0,
|
|
606
614
|
isError: !!t.isError,
|
|
607
615
|
})) : [],
|
|
608
616
|
detailsLoaded,
|
|
609
|
-
requestBase: trace?.baseRequest || null,
|
|
610
617
|
};
|
|
611
618
|
}
|
|
612
619
|
|
|
@@ -626,8 +633,10 @@ function expandTrace(trace) {
|
|
|
626
633
|
loopInstanceId: loop.loopInstanceId || loop.turnRowId || null,
|
|
627
634
|
loopNumber: loop.loopNumber || 0,
|
|
628
635
|
model: loop.model || null,
|
|
629
|
-
|
|
630
|
-
|
|
636
|
+
// Request snapshots are attached only to the latest loop below. Earlier
|
|
637
|
+
// loops retain their responses, calls and timing, not repeated history.
|
|
638
|
+
systemPrompt: '',
|
|
639
|
+
messages: [],
|
|
631
640
|
response: loop.response || '',
|
|
632
641
|
toolCalls: Array.isArray(loop.toolCalls) ? loop.toolCalls : [],
|
|
633
642
|
usage,
|
|
@@ -635,15 +644,19 @@ function expandTrace(trace) {
|
|
|
635
644
|
ttfbMs: loop.ttfbMs || null,
|
|
636
645
|
stopReason: loop.stopReason || null,
|
|
637
646
|
at: loop.at || null,
|
|
638
|
-
rawRequest,
|
|
647
|
+
rawRequest: null,
|
|
639
648
|
rawResponse: loop.rawResponse ?? null,
|
|
640
|
-
requestDelta: loop.requestDelta || {},
|
|
641
|
-
requestBase: trace.baseRequest || null,
|
|
642
649
|
sessionId: trace.sessionId || null,
|
|
643
650
|
vpId: trace.vpId || null,
|
|
644
651
|
threadId: trace.threadId || null,
|
|
645
652
|
});
|
|
646
653
|
}
|
|
654
|
+
const latest = loops.at(-1);
|
|
655
|
+
if (latest && snapshot) {
|
|
656
|
+
latest.systemPrompt = snapshot.systemPrompt || '';
|
|
657
|
+
latest.messages = Array.isArray(snapshot.messages) ? snapshot.messages : [];
|
|
658
|
+
latest.rawRequest = rawRequest;
|
|
659
|
+
}
|
|
647
660
|
return { loops, turns: Array.from(turnsById.values()) };
|
|
648
661
|
}
|
|
649
662
|
|
|
@@ -1263,7 +1263,7 @@ export function projectActionRequestDetail(action, run, history, runs = [run]) {
|
|
|
1263
1263
|
at: count(loop.at),
|
|
1264
1264
|
detailTruncated,
|
|
1265
1265
|
tools: projectedTools,
|
|
1266
|
-
rawRequest: sanitizeDebugValue(reconstructDebugRawRequest(
|
|
1266
|
+
rawRequest: sanitizeDebugValue(loop.rawRequest ?? reconstructDebugRawRequest(
|
|
1267
1267
|
loop.rawRequestBase ?? loop.requestBase?.rawRequest ?? null,
|
|
1268
1268
|
loop.requestDelta || null,
|
|
1269
1269
|
)),
|