@yeaft/webchat-agent 0.0.78 → 0.0.80

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.
Files changed (2) hide show
  1. package/crew.js +11 -0
  2. package/package.json +1 -1
package/crew.js CHANGED
@@ -223,6 +223,8 @@ export async function resumeCrewSession(msg) {
223
223
  round: meta.round || 0,
224
224
  maxRounds: meta.maxRounds || 20,
225
225
  costUsd: 0,
226
+ totalInputTokens: 0,
227
+ totalOutputTokens: 0,
226
228
  messageHistory: [],
227
229
  uiMessages: [], // will be loaded from messages.json
228
230
  humanMessageQueue: [],
@@ -306,6 +308,8 @@ export async function createCrewSession(msg) {
306
308
  round: 0,
307
309
  maxRounds,
308
310
  costUsd: 0,
311
+ totalInputTokens: 0,
312
+ totalOutputTokens: 0,
309
313
  messageHistory: [], // 群聊消息历史
310
314
  uiMessages: [], // 精简的 UI 消息历史(用于恢复时重放)
311
315
  humanMessageQueue: [], // 人的消息排队
@@ -797,6 +801,11 @@ async function processRoleOutput(session, roleName, roleQuery, roleState) {
797
801
  if (message.total_cost_usd) {
798
802
  session.costUsd += message.total_cost_usd;
799
803
  }
804
+ // 更新 token 用量
805
+ if (message.usage) {
806
+ session.totalInputTokens += message.usage.input_tokens || 0;
807
+ session.totalOutputTokens += message.usage.output_tokens || 0;
808
+ }
800
809
 
801
810
  // ★ 持久化 sessionId(每次 turn 完成后保存,用于后续 resume)
802
811
  if (roleState.claudeSessionId) {
@@ -1358,6 +1367,8 @@ function sendStatusUpdate(session) {
1358
1367
  round: session.round,
1359
1368
  maxRounds: session.maxRounds,
1360
1369
  costUsd: session.costUsd,
1370
+ totalInputTokens: session.totalInputTokens,
1371
+ totalOutputTokens: session.totalOutputTokens,
1361
1372
  roles: Array.from(session.roles.values()).map(r => ({
1362
1373
  name: r.name,
1363
1374
  displayName: r.displayName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.0.78",
3
+ "version": "0.0.80",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",