@yeaft/webchat-agent 0.1.289 → 0.1.291
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 +3 -0
- package/connection/message-router.js +6 -1
- package/conversation.js +39 -0
- package/package.json +1 -1
- package/sdk/query.js +8 -0
package/claude.js
CHANGED
|
@@ -286,6 +286,9 @@ async function processClaudeOutput(conversationId, claudeQuery, state) {
|
|
|
286
286
|
for await (const message of claudeQuery) {
|
|
287
287
|
console.log('Output:', message.type, message.subtype || '');
|
|
288
288
|
|
|
289
|
+
// Track last output time for ping health checks
|
|
290
|
+
state._lastOutputTime = Date.now();
|
|
291
|
+
|
|
289
292
|
// 捕获 system init 消息中的 metadata
|
|
290
293
|
if (message.type === 'system' && message.subtype === 'init') {
|
|
291
294
|
state.claudeSessionId = message.session_id;
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
createConversation, resumeConversation, deleteConversation,
|
|
13
13
|
handleRefreshConversation, handleCancelExecution,
|
|
14
14
|
handleUserInput, handleUpdateConversationSettings, handleAskUserAnswer,
|
|
15
|
-
sendConversationList, handleBtwQuestion, preloadSlashCommands
|
|
15
|
+
sendConversationList, handleBtwQuestion, preloadSlashCommands,
|
|
16
|
+
handlePingSession
|
|
16
17
|
} from '../conversation.js';
|
|
17
18
|
import {
|
|
18
19
|
createCrewSession, handleCrewHumanInput, handleCrewControl,
|
|
@@ -115,6 +116,10 @@ export async function handleMessage(msg) {
|
|
|
115
116
|
await handleRefreshConversation(msg);
|
|
116
117
|
break;
|
|
117
118
|
|
|
119
|
+
case 'ping_session':
|
|
120
|
+
handlePingSession(msg);
|
|
121
|
+
break;
|
|
122
|
+
|
|
118
123
|
// Terminal (PTY) messages
|
|
119
124
|
case 'terminal_create':
|
|
120
125
|
await handleTerminalCreate(msg);
|
package/conversation.js
CHANGED
|
@@ -477,6 +477,45 @@ export function deleteConversation(msg) {
|
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
// 刷新会话状态 - 发送当前会话的处理状态
|
|
480
|
+
/**
|
|
481
|
+
* Handle ping_session — report session real status back to client.
|
|
482
|
+
* Allows the frontend to distinguish: agent-offline, session-lost, cli-exited, ok.
|
|
483
|
+
*/
|
|
484
|
+
export function handlePingSession(msg) {
|
|
485
|
+
const { conversationId } = msg;
|
|
486
|
+
const conv = ctx.conversations.get(conversationId);
|
|
487
|
+
|
|
488
|
+
if (!conv) {
|
|
489
|
+
ctx.sendToServer({
|
|
490
|
+
type: 'pong_session',
|
|
491
|
+
conversationId,
|
|
492
|
+
clientId: msg.clientId,
|
|
493
|
+
status: 'session-lost'
|
|
494
|
+
});
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// CLI process exited (no active query)
|
|
499
|
+
if (!conv.query) {
|
|
500
|
+
ctx.sendToServer({
|
|
501
|
+
type: 'pong_session',
|
|
502
|
+
conversationId,
|
|
503
|
+
clientId: msg.clientId,
|
|
504
|
+
status: 'cli-exited'
|
|
505
|
+
});
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
ctx.sendToServer({
|
|
510
|
+
type: 'pong_session',
|
|
511
|
+
conversationId,
|
|
512
|
+
clientId: msg.clientId,
|
|
513
|
+
status: 'ok',
|
|
514
|
+
isProcessing: !!conv.turnActive,
|
|
515
|
+
currentTool: conv.currentTool || null
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
480
519
|
export async function handleRefreshConversation(msg) {
|
|
481
520
|
const { conversationId } = msg;
|
|
482
521
|
const conv = ctx.conversations.get(conversationId);
|
package/package.json
CHANGED
package/sdk/query.js
CHANGED
|
@@ -144,6 +144,14 @@ export class Query {
|
|
|
144
144
|
// Forward only tool_use blocks (text already sent via deltas)
|
|
145
145
|
message.message.content = nonTextBlocks;
|
|
146
146
|
this.inputStream.enqueue(message);
|
|
147
|
+
} else {
|
|
148
|
+
// Pure text message fully streamed — send finish-streaming signal
|
|
149
|
+
// so frontend clears isStreaming and typing dots can reappear
|
|
150
|
+
this.inputStream.enqueue({
|
|
151
|
+
type: 'assistant',
|
|
152
|
+
message: { role: 'assistant', content: [] },
|
|
153
|
+
_finishStreaming: true
|
|
154
|
+
});
|
|
147
155
|
}
|
|
148
156
|
// If only text blocks: skip entirely (all content already streamed)
|
|
149
157
|
} else if (typeof content === 'string') {
|