@yeaft/webchat-agent 0.1.444 → 0.1.445

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.444",
3
+ "version": "0.1.445",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -32,6 +32,11 @@ let unifyConversationId = null;
32
32
  /** Current query mode: 'chat' or 'work' */
33
33
  let currentMode = 'chat';
34
34
 
35
+ /** Accumulated conversation messages for context continuity across queries.
36
+ * Each entry is { role: 'user'|'assistant', content: string|Array }.
37
+ * Cleared on session reset or consolidation. */
38
+ let conversationMessages = [];
39
+
35
40
  /** Whether we've already sent a permission warning to the UI */
36
41
  let _permissionDiagnosticSent = false;
37
42
 
@@ -133,10 +138,14 @@ export async function handleUnifyChat(msg) {
133
138
  resetQueryTimer();
134
139
 
135
140
  try {
141
+ // ─── Collect assistant response for conversation history ──
142
+ let assistantTextParts = [];
143
+
136
144
  // ─── Stream Engine events → claude_output format ──
137
145
  for await (const event of session.engine.query({
138
146
  prompt,
139
147
  mode: currentMode,
148
+ messages: conversationMessages,
140
149
  signal: currentAbort.signal,
141
150
  })) {
142
151
  // Reset timeout on every event — activity means the query is alive
@@ -144,6 +153,7 @@ export async function handleUnifyChat(msg) {
144
153
  switch (event.type) {
145
154
  // ── Text streaming ──
146
155
  case 'text_delta':
156
+ assistantTextParts.push(event.text);
147
157
  sendUnifyOutput({
148
158
  type: 'assistant',
149
159
  message: {
@@ -232,6 +242,9 @@ export async function handleUnifyChat(msg) {
232
242
 
233
243
  // ── Context consolidation ──
234
244
  case 'consolidate':
245
+ // Engine has compressed the context — clear our accumulated history.
246
+ // The engine's compactSummary will provide context on next query.
247
+ conversationMessages = [];
235
248
  sendUnifyEvent({
236
249
  type: 'consolidate',
237
250
  archivedCount: event.archivedCount,
@@ -303,7 +316,15 @@ export async function handleUnifyChat(msg) {
303
316
  }
304
317
  }
305
318
 
306
- // ─── Query complete — signal turn end ──
319
+ // ─── Query complete — accumulate messages for context continuity ──
320
+ conversationMessages.push({ role: 'user', content: prompt });
321
+
322
+ const fullText = assistantTextParts.join('');
323
+ if (fullText) {
324
+ conversationMessages.push({ role: 'assistant', content: fullText });
325
+ }
326
+
327
+ // ─── Signal turn end to UI ──
307
328
  // Finish any streaming text
308
329
  sendUnifyOutput({
309
330
  type: 'assistant',
@@ -426,4 +447,5 @@ export async function resetUnifySession() {
426
447
  }
427
448
  unifyConversationId = null;
428
449
  currentMode = 'chat';
450
+ conversationMessages = [];
429
451
  }