@yeaft/webchat-agent 1.0.504 → 1.0.505
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 +98 -93
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +4 -3
- package/local-runtime/web/style.bundle.css +1 -1
- package/local-runtime/web/style.bundle.css.gz +0 -0
- package/local-runtime/web/vendor/katex/LICENSE +21 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Bold.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Italic.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Math-Italic.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Script-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/local-runtime/web/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/local-runtime/web/vendor/katex/katex.min.css +1 -0
- package/local-runtime/web/vendor.bundle.js +1 -0
- package/local-runtime/web/vendor.bundle.js.gz +0 -0
- package/package.json +1 -1
- package/yeaft/config-api.js +16 -5
- package/yeaft/config.js +11 -2
- package/yeaft/conversation/history-index-worker.js +151 -0
- package/yeaft/conversation/history-index.js +96 -1
- package/yeaft/conversation/persist.js +6 -1
- package/yeaft/conversation/recall-relevance.js +103 -0
- package/yeaft/debug-trace.js +15 -4
- package/yeaft/engine.js +89 -16
- package/yeaft/history-window.js +370 -0
- package/yeaft/web-bridge.js +19 -12
package/yeaft/web-bridge.js
CHANGED
|
@@ -107,7 +107,7 @@ import { loadSessionConfig, normalizeSessionConfig, resolveSessionConfig, Sessio
|
|
|
107
107
|
import { updateSessionConfig } from './sessions/session-crud.js';
|
|
108
108
|
import { createCoordinator } from './sessions/coordinator.js';
|
|
109
109
|
import { seedDefaultSession } from './sessions/seed-default.js';
|
|
110
|
-
import { trimHistoryCacheForRuntime
|
|
110
|
+
import { trimHistoryCacheForRuntime } from './history-window.js';
|
|
111
111
|
import { persistYeaftAttachments, attachmentsForPersistence, persistedAttachmentPreviewPayload } from './attachments.js';
|
|
112
112
|
import { normalizeSessionMessageQuote, sessionMessageQuotePrompt } from './session-message-quote.js';
|
|
113
113
|
import { ConversationStore, parseSeqFromId, projectVisibleSessionMessages } from './conversation/persist.js';
|
|
@@ -2264,6 +2264,7 @@ async function routeEnvelopeToVpThread(sessionId, vpId, envelope) {
|
|
|
2264
2264
|
related = false;
|
|
2265
2265
|
} else {
|
|
2266
2266
|
persistInboundMessageOnceByMsgId({
|
|
2267
|
+
envelope,
|
|
2267
2268
|
msgId: envelope?.msg?.id,
|
|
2268
2269
|
text,
|
|
2269
2270
|
sessionId,
|
|
@@ -2364,6 +2365,7 @@ function ensureDriverRunning(sessionId, vpId, threadId = 'main') {
|
|
|
2364
2365
|
const isInternal = injectedBy === 'route_forward' || injectedBy === 'task_result';
|
|
2365
2366
|
const senderVpId = isInternal ? (meta.senderVpId || envelope?.msg?.from || null) : null;
|
|
2366
2367
|
persistInboundMessageOnceByMsgId({
|
|
2368
|
+
envelope,
|
|
2367
2369
|
msgId: envMsgId,
|
|
2368
2370
|
text,
|
|
2369
2371
|
sessionId,
|
|
@@ -5672,14 +5674,10 @@ async function runVpTurn({ prompt, promptParts = null, sessionId, vpId, threadId
|
|
|
5672
5674
|
markEngineTerminal,
|
|
5673
5675
|
markTurnEnd,
|
|
5674
5676
|
};
|
|
5675
|
-
//
|
|
5676
|
-
//
|
|
5677
|
-
// changes the persisted transcript. See `trimSnapshotForBudget`.
|
|
5677
|
+
// The runtime cache is already bounded. Preserve its candidates here:
|
|
5678
|
+
// Engine allocates recent + related turns together at each provider boundary.
|
|
5678
5679
|
const trimStart = perfNowMs();
|
|
5679
|
-
const trimmedMessages =
|
|
5680
|
-
messageTokenBudget: session?.config?.messageTokenBudget,
|
|
5681
|
-
language: session?.config?.language,
|
|
5682
|
-
});
|
|
5680
|
+
const trimmedMessages = baseSnapshot;
|
|
5683
5681
|
if (perfTraceId) {
|
|
5684
5682
|
recordAgentPerfTrace(ctx.CONFIG, {
|
|
5685
5683
|
traceId: perfTraceId,
|
|
@@ -5707,6 +5705,7 @@ async function runVpTurn({ prompt, promptParts = null, sessionId, vpId, threadId
|
|
|
5707
5705
|
// each write a copy of the user message, and history replay
|
|
5708
5706
|
// would render the user's prompt N times.
|
|
5709
5707
|
userAlreadyPersisted: true,
|
|
5708
|
+
currentUserMessage: inboundEnvelope?._persistedUserMessage || null,
|
|
5710
5709
|
askUser: ({ question, options }, toolCall = null) => new Promise((resolve, reject) => {
|
|
5711
5710
|
const requestId = `ask_${randomUUID()}`;
|
|
5712
5711
|
const signal = vpAbort.signal;
|
|
@@ -6102,7 +6101,7 @@ function appendTurnToSessionHistory(sessionId, threadId, vpId, prompts, assistan
|
|
|
6102
6101
|
* @returns {boolean} true if this call wrote the row, false if a prior
|
|
6103
6102
|
* call already wrote it (dedup hit).
|
|
6104
6103
|
*/
|
|
6105
|
-
function persistInboundMessageOnceByMsgId({ msgId, text, sessionId, threadId = 'main', role, speakerVpId, attachments, quote, internal = false, ts = null, clientMessageId = null }) {
|
|
6104
|
+
function persistInboundMessageOnceByMsgId({ envelope = null, msgId, text, sessionId, threadId = 'main', role, speakerVpId, attachments, quote, internal = false, ts = null, clientMessageId = null }) {
|
|
6106
6105
|
if (!session?.conversationStore) return false;
|
|
6107
6106
|
// No msgId means no dedup key — caller is responsible for guarding.
|
|
6108
6107
|
// Both call sites already do (`if (envMsgId && text)` and
|
|
@@ -6111,8 +6110,11 @@ function persistInboundMessageOnceByMsgId({ msgId, text, sessionId, threadId = '
|
|
|
6111
6110
|
// every call would mint a unique id and write a duplicate row, which
|
|
6112
6111
|
// is the exact bug this helper exists to prevent.
|
|
6113
6112
|
if (!msgId || typeof msgId !== 'string') return false;
|
|
6114
|
-
const dedupKey = `${msgId}::${threadId || 'main'}`;
|
|
6115
|
-
if (_persistedUserMsgIds.has(dedupKey))
|
|
6113
|
+
const dedupKey = `${sessionId || ''}::${msgId}::${threadId || 'main'}`;
|
|
6114
|
+
if (_persistedUserMsgIds.has(dedupKey)) {
|
|
6115
|
+
if (envelope) envelope._persistedUserMessage = _persistedInboundRows.get(dedupKey) || null;
|
|
6116
|
+
return false;
|
|
6117
|
+
}
|
|
6116
6118
|
// Mark BEFORE the empty-text bail. If a later same-id call arrives
|
|
6117
6119
|
// with non-empty text (e.g. a route_forward injection that the first
|
|
6118
6120
|
// caller passed in with empty text), the Set must already remember
|
|
@@ -6131,6 +6133,7 @@ function persistInboundMessageOnceByMsgId({ msgId, text, sessionId, threadId = '
|
|
|
6131
6133
|
const v = iter.next();
|
|
6132
6134
|
if (v.done) break;
|
|
6133
6135
|
_persistedUserMsgIds.delete(v.value);
|
|
6136
|
+
_persistedInboundRows.delete(v.value);
|
|
6134
6137
|
}
|
|
6135
6138
|
}
|
|
6136
6139
|
try {
|
|
@@ -6170,7 +6173,9 @@ function persistInboundMessageOnceByMsgId({ msgId, text, sessionId, threadId = '
|
|
|
6170
6173
|
if (ts && typeof ts === 'string') {
|
|
6171
6174
|
record.time = ts;
|
|
6172
6175
|
}
|
|
6173
|
-
session.conversationStore.append(record);
|
|
6176
|
+
const persisted = session.conversationStore.append(record);
|
|
6177
|
+
_persistedInboundRows.set(dedupKey, persisted);
|
|
6178
|
+
if (envelope) envelope._persistedUserMessage = persisted;
|
|
6174
6179
|
return true;
|
|
6175
6180
|
} catch (err) {
|
|
6176
6181
|
console.warn(
|
|
@@ -6186,6 +6191,7 @@ function persistInboundMessageOnceByMsgId({ msgId, text, sessionId, threadId = '
|
|
|
6186
6191
|
* starts with no stale msg-ids.
|
|
6187
6192
|
*/
|
|
6188
6193
|
const _persistedUserMsgIds = new Set();
|
|
6194
|
+
const _persistedInboundRows = new Map();
|
|
6189
6195
|
|
|
6190
6196
|
/**
|
|
6191
6197
|
* Abort every in-flight VP turn and clear all queued envelopes across
|
|
@@ -7734,6 +7740,7 @@ export async function resetYeaftSession() {
|
|
|
7734
7740
|
// History-dedup cache is keyed by per-session coordinator msg ids;
|
|
7735
7741
|
// a fresh session resets the id space, so clear the cache too.
|
|
7736
7742
|
_persistedUserMsgIds.clear();
|
|
7743
|
+
_persistedInboundRows.clear();
|
|
7737
7744
|
// vp-status: nuke the broker table too. Drivers above have just
|
|
7738
7745
|
// been aborted, so any in-flight `settleIdle` from their outer
|
|
7739
7746
|
// `finally` blocks is racing this reset. Clearing here makes the
|