@yeaft/webchat-agent 1.0.390 → 1.0.391
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/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +92 -95
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +2 -2
- package/local-runtime/web/style.bundle.css +1 -1
- package/local-runtime/web/style.bundle.css.gz +0 -0
- package/package.json +1 -1
- package/yeaft/conversation/persist.js +5 -26
- package/yeaft/web-bridge.js +3 -21
|
Binary file
|
package/package.json
CHANGED
|
@@ -86,18 +86,6 @@ function latestTodoWriteSnapshot(toolCalls) {
|
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
function projectAssistantToolsForVisibleHistory(message) {
|
|
90
|
-
const { toolCalls, ...rest } = message;
|
|
91
|
-
if (!Array.isArray(toolCalls) || toolCalls.length === 0) return rest;
|
|
92
|
-
const todos = latestTodoWriteSnapshot(toolCalls);
|
|
93
|
-
const toolSummaryCount = toolCalls.filter(call => call?.name !== 'TodoWrite').length;
|
|
94
|
-
return {
|
|
95
|
-
...rest,
|
|
96
|
-
...(todos ? { todos } : {}),
|
|
97
|
-
...(toolSummaryCount > 0 ? { toolSummaryCount } : {}),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
89
|
function emptySegmentIndex() {
|
|
102
90
|
return {
|
|
103
91
|
version: 2,
|
|
@@ -370,7 +358,7 @@ export function projectVisibleSessionMessages(messages) {
|
|
|
370
358
|
if (!isVisibleConversationRow(row)) continue;
|
|
371
359
|
if (row.role !== 'assistant' || !Array.isArray(row.toolCalls) || row.toolCalls.length === 0) {
|
|
372
360
|
if (row.role === 'assistant' && !row.content && !row.attachments && !row.images
|
|
373
|
-
&& !row.todos && !row.
|
|
361
|
+
&& !row.todos && !row.askUserResults) continue;
|
|
374
362
|
const responseKind = row.role === 'assistant' ? projectedResponseKind(row) : null;
|
|
375
363
|
visible.push(responseKind && row.responseKind !== responseKind
|
|
376
364
|
? { ...row, responseKind }
|
|
@@ -379,13 +367,13 @@ export function projectVisibleSessionMessages(messages) {
|
|
|
379
367
|
}
|
|
380
368
|
|
|
381
369
|
const askUserResults = [];
|
|
382
|
-
|
|
370
|
+
const visibleToolCalls = [];
|
|
383
371
|
for (const toolCall of row.toolCalls) {
|
|
384
372
|
if (toolCall?.name === 'TodoWrite') continue;
|
|
385
373
|
const identity = askUserToolIdentity(row, toolCall?.id);
|
|
386
374
|
const result = parseAskUserResult(toolCall, identity ? toolResults.get(identity) : null);
|
|
387
375
|
if (result) askUserResults.push(result);
|
|
388
|
-
|
|
376
|
+
visibleToolCalls.push(toolCall);
|
|
389
377
|
}
|
|
390
378
|
const { toolCalls, ...rowWithoutToolCalls } = row;
|
|
391
379
|
const responseKind = projectedResponseKind(rowWithoutToolCalls);
|
|
@@ -396,11 +384,11 @@ export function projectVisibleSessionMessages(messages) {
|
|
|
396
384
|
const projected = {
|
|
397
385
|
...rest,
|
|
398
386
|
...(todos ? { todos } : {}),
|
|
399
|
-
...(
|
|
387
|
+
...(visibleToolCalls.length > 0 ? { toolCalls: visibleToolCalls } : {}),
|
|
400
388
|
...(askUserResults.length > 0 ? { askUserResults } : {}),
|
|
401
389
|
};
|
|
402
390
|
if (!projected.content && !projected.attachments && !projected.images
|
|
403
|
-
&& !projected.todos && !projected.
|
|
391
|
+
&& !projected.todos && !projected.toolCalls && !projected.askUserResults) continue;
|
|
404
392
|
visible.push(projected);
|
|
405
393
|
}
|
|
406
394
|
return visible;
|
|
@@ -1718,7 +1706,6 @@ export class ConversationStore {
|
|
|
1718
1706
|
|
|
1719
1707
|
const { messages, truncated } = this.#loadRecentSessionWindow(sessionId, turnsLimit, {
|
|
1720
1708
|
roles: null,
|
|
1721
|
-
stripAssistantToolCalls: false,
|
|
1722
1709
|
includeReflections,
|
|
1723
1710
|
});
|
|
1724
1711
|
if (truncated) {
|
|
@@ -1886,7 +1873,6 @@ export class ConversationStore {
|
|
|
1886
1873
|
beforeSeq: cutoff,
|
|
1887
1874
|
afterSeq: stopAtSeq === null ? -Infinity : stopAtSeq - 1,
|
|
1888
1875
|
roles: null,
|
|
1889
|
-
stripAssistantToolCalls: false,
|
|
1890
1876
|
visibleOnly: true,
|
|
1891
1877
|
});
|
|
1892
1878
|
const messages = projectVisibleSessionMessages(page.messages);
|
|
@@ -2186,7 +2172,6 @@ export class ConversationStore {
|
|
|
2186
2172
|
const beforeRaw = this.#loadRecentSessionWindow(sessionId, beforeTurns + 1, {
|
|
2187
2173
|
beforeSeq: anchorSeq + 1,
|
|
2188
2174
|
roles: null,
|
|
2189
|
-
stripAssistantToolCalls: false,
|
|
2190
2175
|
visibleOnly: true,
|
|
2191
2176
|
});
|
|
2192
2177
|
const messages = beforeRaw.messages.slice();
|
|
@@ -2885,7 +2870,6 @@ export class ConversationStore {
|
|
|
2885
2870
|
beforeSeq = Infinity,
|
|
2886
2871
|
afterSeq = -Infinity,
|
|
2887
2872
|
roles = null,
|
|
2888
|
-
stripAssistantToolCalls = false,
|
|
2889
2873
|
includeReflections = false,
|
|
2890
2874
|
visibleOnly = false,
|
|
2891
2875
|
} = {}) {
|
|
@@ -2902,11 +2886,6 @@ export class ConversationStore {
|
|
|
2902
2886
|
|
|
2903
2887
|
const project = (m) => {
|
|
2904
2888
|
if (roles && !roles.has(m.role)) return null;
|
|
2905
|
-
if (stripAssistantToolCalls && m.role === 'assistant') {
|
|
2906
|
-
const projected = projectAssistantToolsForVisibleHistory(m);
|
|
2907
|
-
if (!projected.content && !projected.attachments && !projected.todos && !projected.toolSummaryCount) return null;
|
|
2908
|
-
return projected;
|
|
2909
|
-
}
|
|
2910
2889
|
return m;
|
|
2911
2890
|
};
|
|
2912
2891
|
const keep = (m) => {
|
package/yeaft/web-bridge.js
CHANGED
|
@@ -1323,9 +1323,6 @@ function projectPersistedToHistoryEntry(m, { includeReflections = false } = {})
|
|
|
1323
1323
|
input: tc.input,
|
|
1324
1324
|
}));
|
|
1325
1325
|
}
|
|
1326
|
-
if (Number.isFinite(m.toolSummaryCount) && m.toolSummaryCount > 0) {
|
|
1327
|
-
entry.toolSummaryCount = m.toolSummaryCount;
|
|
1328
|
-
}
|
|
1329
1326
|
if (m.isError) entry.isError = true;
|
|
1330
1327
|
if (m.ts) entry.ts = m.ts;
|
|
1331
1328
|
else if (m.time) entry.ts = m.time;
|
|
@@ -1333,7 +1330,7 @@ function projectPersistedToHistoryEntry(m, { includeReflections = false } = {})
|
|
|
1333
1330
|
if (Array.isArray(m.attachments) && m.attachments.length > 0) entry.attachments = m.attachments;
|
|
1334
1331
|
if (m.quote && typeof m.quote === 'object') entry.quote = m.quote;
|
|
1335
1332
|
if (Array.isArray(m.todos)) entry.todos = m.todos;
|
|
1336
|
-
if ((entry.role === 'user' || entry.role === 'assistant') && !entry.content && !entry.attachments && !entry.images && !entry.toolCalls && !entry.todos && !entry.
|
|
1333
|
+
if ((entry.role === 'user' || entry.role === 'assistant') && !entry.content && !entry.attachments && !entry.images && !entry.toolCalls && !entry.todos && !entry.askUserResults) return null;
|
|
1337
1334
|
return entry;
|
|
1338
1335
|
}
|
|
1339
1336
|
|
|
@@ -1436,9 +1433,7 @@ function projectVisibleHistoryChunkMessages(messages = []) {
|
|
|
1436
1433
|
...(typeof m.stopReason === 'string' && m.stopReason ? { stopReason: m.stopReason } : {}),
|
|
1437
1434
|
...(Array.isArray(m.todos) ? { todos: m.todos } : {}),
|
|
1438
1435
|
...(Array.isArray(m.askUserResults) && m.askUserResults.length > 0 ? { askUserResults: m.askUserResults } : {}),
|
|
1439
|
-
...(
|
|
1440
|
-
? { toolSummaryCount: m.toolSummaryCount }
|
|
1441
|
-
: (Array.isArray(m.toolCalls) && m.toolCalls.length > 0 ? { toolSummaryCount: m.toolCalls.length } : {})),
|
|
1436
|
+
...(Array.isArray(m.toolCalls) && m.toolCalls.length > 0 ? { toolCalls: m.toolCalls } : {}),
|
|
1442
1437
|
}));
|
|
1443
1438
|
}
|
|
1444
1439
|
|
|
@@ -1498,25 +1493,12 @@ function emitLegacyHistoryOutputFrames(replayEntries) {
|
|
|
1498
1493
|
id: entry.id || null,
|
|
1499
1494
|
content: [
|
|
1500
1495
|
...(entry.content ? [{ type: 'text', text: entry.content }] : []),
|
|
1496
|
+
...((entry.toolCalls || []).map(toolCall => ({ type: 'tool_use', ...toolCall, history: true }))),
|
|
1501
1497
|
...((entry.images || []).map(image => ({ type: 'image_asset', image }))),
|
|
1502
1498
|
],
|
|
1503
1499
|
},
|
|
1504
1500
|
ts: entry.ts || null,
|
|
1505
1501
|
}, envelopeOpts);
|
|
1506
|
-
if (Array.isArray(entry.toolCalls) && entry.toolCalls.length > 0) {
|
|
1507
|
-
sendSessionOutputFrame({
|
|
1508
|
-
type: 'assistant',
|
|
1509
|
-
message: {
|
|
1510
|
-
content: [{
|
|
1511
|
-
type: 'tool_summary',
|
|
1512
|
-
count: entry.toolCalls.length,
|
|
1513
|
-
omittedCount: entry.toolCalls.length,
|
|
1514
|
-
source: 'history',
|
|
1515
|
-
}],
|
|
1516
|
-
},
|
|
1517
|
-
ts: entry.ts || null,
|
|
1518
|
-
}, envelopeOpts);
|
|
1519
|
-
}
|
|
1520
1502
|
sendSessionOutputFrame({ type: 'result', result_text: '' }, envelopeOpts);
|
|
1521
1503
|
}
|
|
1522
1504
|
}
|