agentgui 1.0.722 → 1.0.724

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.
@@ -16,6 +16,7 @@ export class JsonlWatcher {
16
16
  this._timers = new Map();
17
17
  this._seqs = new Map();
18
18
  this._streaming = new Set();
19
+ this._sessions = new Map();
19
20
  this._watcher = null;
20
21
  }
21
22
 
@@ -42,6 +43,7 @@ export class JsonlWatcher {
42
43
  this._convMap.delete(sid);
43
44
  this._seqs.delete(sid);
44
45
  this._streaming.delete(sid);
46
+ this._sessions.delete(sid);
45
47
  for (const key of [...this._emitted.keys()]) if (key.startsWith(`${sid}:`)) this._emitted.delete(key);
46
48
  for (const [fp, s] of this._tails.entries()) {
47
49
  if (!fp.includes(sid)) continue;
@@ -58,6 +60,7 @@ export class JsonlWatcher {
58
60
  for (const t of this._timers.values()) clearTimeout(t);
59
61
  this._tails.clear(); this._convMap.clear(); this._emitted.clear();
60
62
  this._timers.clear(); this._seqs.clear(); this._streaming.clear();
63
+ this._sessions.clear();
61
64
  }
62
65
 
63
66
  _scanDir(dir, depth) {
@@ -129,8 +132,19 @@ export class JsonlWatcher {
129
132
 
130
133
  _seq(sid) { const n = (this._seqs.get(sid) || 0) + 1; this._seqs.set(sid, n); return n; }
131
134
 
135
+ _dbSession(cid, sid) {
136
+ if (this._sessions.has(sid)) return this._sessions.get(sid);
137
+ const sess = this._q.createSession(cid);
138
+ this._q.updateSession(sess.id, { status: 'active' });
139
+ this._sessions.set(sid, sess.id);
140
+ return sess.id;
141
+ }
142
+
132
143
  _emit(cid, sid, block, role, extra) {
133
- this._bc({ type: 'streaming_progress', sessionId: sid, conversationId: cid, block, blockRole: role, seq: this._seq(sid), timestamp: Date.now(), ...extra });
144
+ const dbSid = this._dbSession(cid, sid);
145
+ const seq = this._seq(sid);
146
+ try { this._q.createChunk(dbSid, cid, seq, block.type || 'unknown', block); } catch (_) {}
147
+ this._bc({ type: 'streaming_progress', sessionId: dbSid, conversationId: cid, block, blockRole: role, seq, timestamp: Date.now(), ...extra });
134
148
  }
135
149
 
136
150
  _emitBlocks(cid, sid, blocks, role) {
@@ -143,20 +157,28 @@ export class JsonlWatcher {
143
157
  _startStreaming(cid, sid) {
144
158
  if (this._streaming.has(sid)) return;
145
159
  this._streaming.add(sid);
146
- this._bc({ type: 'streaming_start', sessionId: sid, conversationId: cid, agentId: 'cli-claude', timestamp: Date.now() });
160
+ const dbSid = this._dbSession(cid, sid);
161
+ this._q.setIsStreaming(cid, true);
162
+ this._bc({ type: 'streaming_start', sessionId: dbSid, conversationId: cid, agentId: 'cli-claude', timestamp: Date.now() });
147
163
  }
148
164
 
149
165
  _endStreaming(cid, sid) {
150
166
  if (!this._streaming.has(sid)) return;
151
167
  this._streaming.delete(sid);
152
- this._bc({ type: 'streaming_complete', sessionId: sid, conversationId: cid, agentId: 'cli-claude', eventCount: 0, seq: this._seq(sid), timestamp: Date.now() });
168
+ const dbSid = this._sessions.get(sid);
169
+ if (dbSid) {
170
+ try { this._q.updateSession(dbSid, { status: 'completed', completed_at: Date.now() }); } catch (_) {}
171
+ }
172
+ this._q.setIsStreaming(cid, false);
173
+ this._bc({ type: 'streaming_complete', sessionId: dbSid || sid, conversationId: cid, agentId: 'cli-claude', eventCount: 0, seq: this._seq(sid), timestamp: Date.now() });
174
+ this._sessions.delete(sid);
153
175
  }
154
176
 
155
177
  _route(cid, sid, e) {
156
178
  if (e.type === 'queue-operation' || e.type === 'last-prompt' || (e.type === 'user' && e.isMeta)) return;
157
179
 
158
180
  if (e.isApiErrorMessage && e.error === 'rate_limit') {
159
- this._bc({ type: 'streaming_error', sessionId: sid, conversationId: cid, error: 'Rate limit hit', recoverable: true, timestamp: Date.now() });
181
+ this._bc({ type: 'streaming_error', sessionId: this._sessions.get(sid) || sid, conversationId: cid, error: 'Rate limit hit', recoverable: true, timestamp: Date.now() });
160
182
  return;
161
183
  }
162
184
 
@@ -185,7 +207,14 @@ export class JsonlWatcher {
185
207
  if (e.type === 'user' && e.message?.content) {
186
208
  if (e.isCompactSummary) { this._emit(cid, sid, { type: 'compact_summary', content: e.message.content }, 'system'); return; }
187
209
  this._startStreaming(cid, sid);
188
- const blocks = Array.isArray(e.message.content) ? e.message.content : [];
210
+ const content = e.message.content;
211
+ const textParts = Array.isArray(content)
212
+ ? content.filter(b => b.type === 'text' && b.text && !b.text.startsWith('<task-notification>')).map(b => b.text).join('\n')
213
+ : (typeof content === 'string' && !content.startsWith('<task-notification>') ? content : '');
214
+ if (textParts) {
215
+ try { this._q.createMessage(cid, 'user', textParts); } catch (_) {}
216
+ }
217
+ const blocks = Array.isArray(content) ? content : [];
189
218
  for (const b of blocks) if (b.type === 'tool_result') this._emit(cid, sid, b, 'tool_result');
190
219
  return;
191
220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.722",
3
+ "version": "1.0.724",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",