@yeaft/webchat-agent 1.0.503 → 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/server/db/connection.js +14 -2
- package/local-runtime/server/db/user-stats-db.js +7 -0
- package/local-runtime/server/handlers/agent-conversation.js +2 -1
- package/local-runtime/server/handlers/agent-output.js +4 -1
- package/local-runtime/server/routes/admin-routes.js +3 -3
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +108 -120
- 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/vp/seed-defaults.js +169 -8
- package/yeaft/vp/stock-ids.js +2 -0
- package/yeaft/web-bridge.js +19 -12
|
@@ -99,6 +99,7 @@ db.exec(`
|
|
|
99
99
|
cache_read_tokens INTEGER DEFAULT 0,
|
|
100
100
|
cache_write_tokens INTEGER DEFAULT 0,
|
|
101
101
|
total_tokens INTEGER DEFAULT 0,
|
|
102
|
+
last_turn_completed_at INTEGER,
|
|
102
103
|
updated_at INTEGER NOT NULL DEFAULT 0
|
|
103
104
|
);
|
|
104
105
|
|
|
@@ -375,6 +376,7 @@ const migrations = [
|
|
|
375
376
|
`ALTER TABLE user_stats ADD COLUMN cache_read_tokens INTEGER DEFAULT 0`,
|
|
376
377
|
`ALTER TABLE user_stats ADD COLUMN cache_write_tokens INTEGER DEFAULT 0`,
|
|
377
378
|
`ALTER TABLE user_stats ADD COLUMN total_tokens INTEGER DEFAULT 0`,
|
|
379
|
+
`ALTER TABLE user_stats ADD COLUMN last_turn_completed_at INTEGER`,
|
|
378
380
|
`ALTER TABLE daily_stats ADD COLUMN input_tokens INTEGER DEFAULT 0`,
|
|
379
381
|
`ALTER TABLE daily_stats ADD COLUMN output_tokens INTEGER DEFAULT 0`,
|
|
380
382
|
`ALTER TABLE daily_stats ADD COLUMN cache_read_tokens INTEGER DEFAULT 0`,
|
|
@@ -1235,7 +1237,8 @@ export const stmts = {
|
|
|
1235
1237
|
`),
|
|
1236
1238
|
|
|
1237
1239
|
getDailyStatsAll: db.prepare(`
|
|
1238
|
-
SELECT ds.user_id, u.username, u.display_name, u.role,
|
|
1240
|
+
SELECT ds.user_id, u.username, u.display_name, u.role,
|
|
1241
|
+
MAX(us.last_turn_completed_at) as last_turn_completed_at,
|
|
1239
1242
|
SUM(ds.message_count) as message_count, SUM(ds.session_count) as session_count,
|
|
1240
1243
|
SUM(ds.request_count) as request_count, SUM(ds.bytes_sent) as bytes_sent,
|
|
1241
1244
|
SUM(ds.bytes_received) as bytes_received,
|
|
@@ -1245,6 +1248,7 @@ export const stmts = {
|
|
|
1245
1248
|
SUM(ds.total_tokens) as total_tokens
|
|
1246
1249
|
FROM daily_stats ds
|
|
1247
1250
|
JOIN users u ON ds.user_id = u.id
|
|
1251
|
+
LEFT JOIN user_stats us ON us.user_id = ds.user_id
|
|
1248
1252
|
WHERE ds.date >= ?
|
|
1249
1253
|
GROUP BY ds.user_id
|
|
1250
1254
|
ORDER BY message_count DESC
|
|
@@ -1259,7 +1263,7 @@ export const stmts = {
|
|
|
1259
1263
|
`),
|
|
1260
1264
|
|
|
1261
1265
|
getUserStats: db.prepare(`
|
|
1262
|
-
SELECT us.*, u.username, u.display_name, u.role
|
|
1266
|
+
SELECT us.*, u.username, u.display_name, u.role
|
|
1263
1267
|
FROM user_stats us
|
|
1264
1268
|
JOIN users u ON us.user_id = u.id
|
|
1265
1269
|
ORDER BY us.message_count DESC
|
|
@@ -1269,6 +1273,14 @@ export const stmts = {
|
|
|
1269
1273
|
SELECT * FROM user_stats WHERE user_id = ?
|
|
1270
1274
|
`),
|
|
1271
1275
|
|
|
1276
|
+
updateLastTurnCompletedAt: db.prepare(`
|
|
1277
|
+
INSERT INTO user_stats (user_id, last_turn_completed_at, updated_at)
|
|
1278
|
+
VALUES (?, ?, ?)
|
|
1279
|
+
ON CONFLICT(user_id) DO UPDATE SET
|
|
1280
|
+
last_turn_completed_at = MAX(COALESCE(last_turn_completed_at, 0), excluded.last_turn_completed_at),
|
|
1281
|
+
updated_at = MAX(updated_at, excluded.updated_at)
|
|
1282
|
+
`),
|
|
1283
|
+
|
|
1272
1284
|
getAgentMetricWatermark: db.prepare(`
|
|
1273
1285
|
SELECT * FROM agent_metric_watermarks
|
|
1274
1286
|
WHERE user_id = ? AND agent_instance_id = ? AND metric_epoch = ?
|
|
@@ -100,6 +100,13 @@ export const userStatsDb = {
|
|
|
100
100
|
return stmts.getUserStatsById.get(userId) || null;
|
|
101
101
|
},
|
|
102
102
|
|
|
103
|
+
recordTurnCompleted(userId, completedAt = Date.now()) {
|
|
104
|
+
if (!userId) return;
|
|
105
|
+
const timestamp = Number(completedAt);
|
|
106
|
+
if (!Number.isFinite(timestamp) || timestamp <= 0) return;
|
|
107
|
+
stmts.updateLastTurnCompletedAt.run(userId, timestamp, timestamp);
|
|
108
|
+
},
|
|
109
|
+
|
|
103
110
|
/**
|
|
104
111
|
* Convert one cumulative agent snapshot into an idempotent user delta.
|
|
105
112
|
* A new metric epoch means the agent process restarted and counters began at
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sessionDb, messageDb, sessionUiMetadataDb } from '../database.js';
|
|
1
|
+
import { sessionDb, messageDb, sessionUiMetadataDb, userStatsDb } from '../database.js';
|
|
2
2
|
import {
|
|
3
3
|
broadcastAgentList, notifyConversationUpdate, forwardToClients
|
|
4
4
|
} from '../ws-utils.js';
|
|
@@ -250,6 +250,7 @@ export async function handleAgentConversation(agentId, agent, msg) {
|
|
|
250
250
|
console.warn(`[turn_completed] Ignoring duplicate for ${msg.conversationId}`);
|
|
251
251
|
break;
|
|
252
252
|
}
|
|
253
|
+
userStatsDb.recordTurnCompleted(turnConv?.userId || agent.ownerId, Date.now());
|
|
253
254
|
if (turnConv) {
|
|
254
255
|
turnConv.processing = false;
|
|
255
256
|
if (msg.claudeSessionId) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from 'crypto';
|
|
2
|
-
import { messageDb, sessionUiMetadataDb, yeaftProjectDb, yeaftSessionDb } from '../database.js';
|
|
2
|
+
import { messageDb, sessionUiMetadataDb, userStatsDb, yeaftProjectDb, yeaftSessionDb } from '../database.js';
|
|
3
3
|
import { transaction } from '../db/connection.js';
|
|
4
4
|
import { broadcastAgentList, broadcastSessionCatalog, forwardToClients, sendToAgent, sendToWebClient } from '../ws-utils.js';
|
|
5
5
|
import { advanceYeaftDebugRequestChunk, consumeYeaftDebugRequest, webClients, previewFiles } from '../context.js';
|
|
@@ -572,6 +572,9 @@ export async function handleAgentOutput(agentId, agent, msg) {
|
|
|
572
572
|
agent.yeaftStatus = event;
|
|
573
573
|
await broadcastAgentList();
|
|
574
574
|
}
|
|
575
|
+
if (event?.type === 'vp_turn_end') {
|
|
576
|
+
userStatsDb.recordTurnCompleted(agent.ownerId, event.ts || Date.now());
|
|
577
|
+
}
|
|
575
578
|
if (event?.type === 'session_roster_changed' && agent.ownerId && event.sessionId) {
|
|
576
579
|
try {
|
|
577
580
|
const existing = yeaftSessionDb.getForAgent(agent.ownerId, agentId, event.sessionId);
|
|
@@ -71,7 +71,7 @@ function mergePendingUserStats(stats) {
|
|
|
71
71
|
username: userId,
|
|
72
72
|
display_name: userId,
|
|
73
73
|
role: 'pro',
|
|
74
|
-
|
|
74
|
+
last_turn_completed_at: null,
|
|
75
75
|
updated_at: Date.now(),
|
|
76
76
|
message_count: toNumber(delta.messages),
|
|
77
77
|
session_count: toNumber(delta.sessions),
|
|
@@ -159,7 +159,7 @@ export function registerAdminRoutes(app, { requireAuth, requireAdmin }) {
|
|
|
159
159
|
cache_read_tokens: 0,
|
|
160
160
|
cache_write_tokens: 0,
|
|
161
161
|
total_tokens: 0,
|
|
162
|
-
|
|
162
|
+
last_turn_completed_at: null,
|
|
163
163
|
updated_at: user.created_at,
|
|
164
164
|
});
|
|
165
165
|
}
|
|
@@ -181,7 +181,7 @@ export function registerAdminRoutes(app, { requireAuth, requireAdmin }) {
|
|
|
181
181
|
cacheReadTokens: s.cache_read_tokens,
|
|
182
182
|
cacheWriteTokens: s.cache_write_tokens,
|
|
183
183
|
totalTokens: s.total_tokens,
|
|
184
|
-
|
|
184
|
+
lastTurnCompletedAt: s.last_turn_completed_at,
|
|
185
185
|
updatedAt: s.updated_at
|
|
186
186
|
})));
|
|
187
187
|
} catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.505"}
|