@yeaft/webchat-agent 0.0.118 → 0.0.120

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 +24 -7
  2. package/package.json +1 -1
package/crew.js CHANGED
@@ -317,7 +317,10 @@ async function saveSessionMeta(session) {
317
317
  createdAt: session.createdAt,
318
318
  updatedAt: Date.now(),
319
319
  userId: session.userId,
320
- username: session.username
320
+ username: session.username,
321
+ costUsd: session.costUsd,
322
+ totalInputTokens: session.totalInputTokens,
323
+ totalOutputTokens: session.totalOutputTokens
321
324
  };
322
325
  await fs.writeFile(join(session.sharedDir, 'session.json'), JSON.stringify(meta, null, 2));
323
326
  // 保存 UI 消息历史(用于恢复时重放)
@@ -431,9 +434,9 @@ export async function resumeCrewSession(msg) {
431
434
  status: 'waiting_human',
432
435
  round: meta.round || 0,
433
436
  maxRounds: meta.maxRounds || 20,
434
- costUsd: 0,
435
- totalInputTokens: 0,
436
- totalOutputTokens: 0,
437
+ costUsd: meta.costUsd || 0,
438
+ totalInputTokens: meta.totalInputTokens || 0,
439
+ totalOutputTokens: meta.totalOutputTokens || 0,
437
440
  messageHistory: [],
438
441
  uiMessages: [], // will be loaded from messages.json
439
442
  humanMessageQueue: [],
@@ -1522,9 +1525,23 @@ async function processHumanQueue(session) {
1522
1525
  if (session._processingHumanQueue) return;
1523
1526
  session._processingHumanQueue = true;
1524
1527
  try {
1525
- const msg = session.humanMessageQueue.shift();
1526
- const humanPrompt = `人工消息:\n${msg.content}`;
1527
- await dispatchToRole(session, msg.target, humanPrompt, 'human');
1528
+ const msgs = session.humanMessageQueue.splice(0);
1529
+ if (msgs.length === 1) {
1530
+ const humanPrompt = `人工消息:\n${msgs[0].content}`;
1531
+ await dispatchToRole(session, msgs[0].target, humanPrompt, 'human');
1532
+ } else {
1533
+ // 按 target 分组,合并发送
1534
+ const byTarget = new Map();
1535
+ for (const m of msgs) {
1536
+ if (!byTarget.has(m.target)) byTarget.set(m.target, []);
1537
+ byTarget.get(m.target).push(m.content);
1538
+ }
1539
+ for (const [target, contents] of byTarget) {
1540
+ const combined = contents.join('\n\n---\n\n');
1541
+ const humanPrompt = `人工消息:\n你有 ${contents.length} 条待处理消息,请一并分析并用多个 ROUTE 块并行分配:\n\n${combined}`;
1542
+ await dispatchToRole(session, target, humanPrompt, 'human');
1543
+ }
1544
+ }
1528
1545
  } finally {
1529
1546
  session._processingHumanQueue = false;
1530
1547
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.0.118",
3
+ "version": "0.0.120",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",