@yeaft/webchat-agent 0.0.68 → 0.0.69
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/claude.js +6 -5
- package/crew.js +17 -1
- package/package.json +1 -1
package/claude.js
CHANGED
|
@@ -355,16 +355,17 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
|
|
|
355
355
|
}
|
|
356
356
|
state.usage.totalCostUsd += message.total_cost_usd || 0;
|
|
357
357
|
|
|
358
|
-
//
|
|
358
|
+
// 计算上下文使用百分比
|
|
359
359
|
const inputTokens = message.usage?.input_tokens || 0;
|
|
360
360
|
const maxContextTokens = 200000; // Claude 模型 context window
|
|
361
|
-
let contextUsage = null;
|
|
362
361
|
if (inputTokens > 0) {
|
|
363
|
-
|
|
362
|
+
ctx.sendToServer({
|
|
363
|
+
type: 'context_usage',
|
|
364
|
+
conversationId,
|
|
364
365
|
inputTokens,
|
|
365
366
|
maxTokens: maxContextTokens,
|
|
366
367
|
percentage: Math.min(100, Math.round((inputTokens / maxContextTokens) * 100))
|
|
367
|
-
};
|
|
368
|
+
});
|
|
368
369
|
}
|
|
369
370
|
|
|
370
371
|
console.log(`[SDK] Query completed for ${conversationId}, cost: $${state.usage.totalCostUsd.toFixed(4)}, context: ${inputTokens}/${maxContextTokens} tokens`);
|
|
@@ -385,7 +386,7 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
|
|
|
385
386
|
|
|
386
387
|
// ★ await 确保 result 和 turn_completed 消息确实发送成功
|
|
387
388
|
// 不 await 会导致 encrypt 失败时消息静默丢失,前端卡在"思考中"
|
|
388
|
-
await sendOutput(conversationId,
|
|
389
|
+
await sendOutput(conversationId, message);
|
|
389
390
|
await ctx.sendToServer({
|
|
390
391
|
type: 'turn_completed',
|
|
391
392
|
conversationId,
|
package/crew.js
CHANGED
|
@@ -151,9 +151,25 @@ export async function handleListCrewSessions(msg) {
|
|
|
151
151
|
export async function resumeCrewSession(msg) {
|
|
152
152
|
const { sessionId, userId, username } = msg;
|
|
153
153
|
|
|
154
|
-
// 如果已经在活跃 sessions
|
|
154
|
+
// 如果已经在活跃 sessions 中,重新发送完整信息让前端重建
|
|
155
155
|
if (crewSessions.has(sessionId)) {
|
|
156
156
|
const session = crewSessions.get(sessionId);
|
|
157
|
+
const roles = Array.from(session.roles.values());
|
|
158
|
+
sendCrewMessage({
|
|
159
|
+
type: 'crew_session_created',
|
|
160
|
+
sessionId,
|
|
161
|
+
projectDir: session.projectDir,
|
|
162
|
+
sharedDir: session.sharedDir,
|
|
163
|
+
goal: session.goal,
|
|
164
|
+
roles: roles.map(r => ({
|
|
165
|
+
name: r.name, displayName: r.displayName, icon: r.icon,
|
|
166
|
+
description: r.description, isDecisionMaker: r.isDecisionMaker || false
|
|
167
|
+
})),
|
|
168
|
+
decisionMaker: session.decisionMaker,
|
|
169
|
+
maxRounds: session.maxRounds,
|
|
170
|
+
userId: session.userId,
|
|
171
|
+
username: session.username
|
|
172
|
+
});
|
|
157
173
|
sendStatusUpdate(session);
|
|
158
174
|
return;
|
|
159
175
|
}
|