agentgui 1.0.701 → 1.0.703
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 +1 -1
- package/static/js/client.js +0 -7
- package/acp-queries.js +0 -182
- package/static/js/codec.js +0 -2
- package/static/js/sync-debug.js +0 -146
- package/test-cli-detection.mjs +0 -37
- package/test-fixes.mjs +0 -103
- package/test-thread-steering.mjs +0 -100
package/package.json
CHANGED
package/static/js/client.js
CHANGED
|
@@ -730,23 +730,18 @@ class AgentGUIClient {
|
|
|
730
730
|
|
|
731
731
|
switch (data.type) {
|
|
732
732
|
case 'streaming_start':
|
|
733
|
-
window.syncDebugger?.logEvent('streaming_start', data);
|
|
734
733
|
this.handleStreamingStart(data).catch(e => console.error('handleStreamingStart error:', e));
|
|
735
734
|
break;
|
|
736
735
|
case 'streaming_resumed':
|
|
737
|
-
window.syncDebugger?.logEvent('streaming_resumed', data);
|
|
738
736
|
this.handleStreamingResumed(data).catch(e => console.error('handleStreamingResumed error:', e));
|
|
739
737
|
break;
|
|
740
738
|
case 'streaming_progress':
|
|
741
|
-
window.syncDebugger?.logEvent('streaming_progress', { sessionId: data.sessionId });
|
|
742
739
|
this.handleStreamingProgress(data);
|
|
743
740
|
break;
|
|
744
741
|
case 'streaming_complete':
|
|
745
|
-
window.syncDebugger?.logEvent('streaming_complete', data);
|
|
746
742
|
this.handleStreamingComplete(data);
|
|
747
743
|
break;
|
|
748
744
|
case 'streaming_error':
|
|
749
|
-
window.syncDebugger?.logEvent('streaming_error', data);
|
|
750
745
|
this.handleStreamingError(data);
|
|
751
746
|
break;
|
|
752
747
|
case 'conversation_created':
|
|
@@ -756,11 +751,9 @@ class AgentGUIClient {
|
|
|
756
751
|
this.handleAllConversationsDeleted(data);
|
|
757
752
|
break;
|
|
758
753
|
case 'message_created':
|
|
759
|
-
window.syncDebugger?.logEvent('message_created', data);
|
|
760
754
|
this.handleMessageCreated(data);
|
|
761
755
|
break;
|
|
762
756
|
case 'conversation_updated':
|
|
763
|
-
window.syncDebugger?.logEvent('conversation_updated', data);
|
|
764
757
|
this.handleConversationUpdated(data);
|
|
765
758
|
break;
|
|
766
759
|
case 'queue_status':
|
package/acp-queries.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
|
-
const gid = (p) => `${p}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
3
|
-
const uuid = () => randomUUID();
|
|
4
|
-
const iso = (t) => new Date(t).toISOString();
|
|
5
|
-
const j = (o) => JSON.stringify(o);
|
|
6
|
-
const jp = (s) => { try { return JSON.parse(s); } catch { return {}; } };
|
|
7
|
-
|
|
8
|
-
export function createACPQueries(db, prep) {
|
|
9
|
-
return {
|
|
10
|
-
createThread(metadata = {}) {
|
|
11
|
-
const id = uuid(), now = Date.now();
|
|
12
|
-
prep('INSERT INTO conversations (id, agentId, title, created_at, updated_at, status, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)').run(id, 'unknown', null, now, now, 'idle', j(metadata));
|
|
13
|
-
return { thread_id: id, created_at: iso(now), updated_at: iso(now), metadata, status: 'idle' };
|
|
14
|
-
},
|
|
15
|
-
getThread(tid) {
|
|
16
|
-
const r = prep('SELECT * FROM conversations WHERE id = ?').get(tid);
|
|
17
|
-
if (!r) return null;
|
|
18
|
-
return { thread_id: r.id, created_at: iso(r.created_at), updated_at: iso(r.updated_at), metadata: jp(r.metadata), status: r.status || 'idle' };
|
|
19
|
-
},
|
|
20
|
-
patchThread(tid, upd) {
|
|
21
|
-
const t = this.getThread(tid);
|
|
22
|
-
if (!t) throw new Error('Thread not found');
|
|
23
|
-
const now = Date.now(), meta = upd.metadata !== undefined ? upd.metadata : t.metadata, stat = upd.status !== undefined ? upd.status : t.status;
|
|
24
|
-
prep('UPDATE conversations SET metadata = ?, status = ?, updated_at = ? WHERE id = ?').run(j(meta), stat, now, tid);
|
|
25
|
-
return { thread_id: tid, created_at: t.created_at, updated_at: iso(now), metadata: meta, status: stat };
|
|
26
|
-
},
|
|
27
|
-
deleteThread(tid) {
|
|
28
|
-
const pr = prep('SELECT COUNT(*) as count FROM run_metadata WHERE thread_id = ? AND status = ?').get(tid, 'pending');
|
|
29
|
-
if (pr && pr.count > 0) throw new Error('Cannot delete thread with pending runs');
|
|
30
|
-
db.transaction(() => {
|
|
31
|
-
prep('DELETE FROM thread_states WHERE thread_id = ?').run(tid);
|
|
32
|
-
prep('DELETE FROM checkpoints WHERE thread_id = ?').run(tid);
|
|
33
|
-
prep('DELETE FROM run_metadata WHERE thread_id = ?').run(tid);
|
|
34
|
-
prep('DELETE FROM sessions WHERE conversationId = ?').run(tid);
|
|
35
|
-
prep('DELETE FROM messages WHERE conversationId = ?').run(tid);
|
|
36
|
-
prep('DELETE FROM chunks WHERE conversationId = ?').run(tid);
|
|
37
|
-
prep('DELETE FROM events WHERE conversationId = ?').run(tid);
|
|
38
|
-
prep('DELETE FROM conversations WHERE id = ?').run(tid);
|
|
39
|
-
})();
|
|
40
|
-
return true;
|
|
41
|
-
},
|
|
42
|
-
saveThreadState(tid, cid, sd) {
|
|
43
|
-
const id = gid('state'), now = Date.now();
|
|
44
|
-
prep('INSERT INTO thread_states (id, thread_id, checkpoint_id, state_data, created_at) VALUES (?, ?, ?, ?, ?)').run(id, tid, cid, j(sd), now);
|
|
45
|
-
return { id, thread_id: tid, checkpoint_id: cid, created_at: iso(now) };
|
|
46
|
-
},
|
|
47
|
-
getThreadState(tid, cid = null) {
|
|
48
|
-
const r = cid ? prep('SELECT * FROM thread_states WHERE thread_id = ? AND checkpoint_id = ? ORDER BY created_at DESC LIMIT 1').get(tid, cid) : prep('SELECT * FROM thread_states WHERE thread_id = ? ORDER BY created_at DESC LIMIT 1').get(tid);
|
|
49
|
-
if (!r) return null;
|
|
50
|
-
const sd = jp(r.state_data);
|
|
51
|
-
return { checkpoint: { checkpoint_id: r.checkpoint_id }, values: sd.values || {}, messages: sd.messages || [], metadata: sd.metadata || {} };
|
|
52
|
-
},
|
|
53
|
-
getThreadHistory(tid, lim = 50, off = 0) {
|
|
54
|
-
const tot = prep('SELECT COUNT(*) as count FROM thread_states WHERE thread_id = ?').get(tid).count;
|
|
55
|
-
const rows = prep('SELECT * FROM thread_states WHERE thread_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?').all(tid, lim, off);
|
|
56
|
-
const states = rows.map(r => { const sd = jp(r.state_data); return { checkpoint: { checkpoint_id: r.checkpoint_id }, values: sd.values || {}, messages: sd.messages || [], metadata: sd.metadata || {} }; });
|
|
57
|
-
return { states, total: tot, limit: lim, offset: off, hasMore: off + lim < tot };
|
|
58
|
-
},
|
|
59
|
-
copyThread(stid) {
|
|
60
|
-
const st = this.getThread(stid);
|
|
61
|
-
if (!st) throw new Error('Source thread not found');
|
|
62
|
-
const ntid = uuid(), now = Date.now();
|
|
63
|
-
db.transaction(() => {
|
|
64
|
-
prep('INSERT INTO conversations (id, agentId, title, created_at, updated_at, status, metadata, workingDirectory) SELECT ?, agentId, title || \' (copy)\', ?, ?, status, metadata, workingDirectory FROM conversations WHERE id = ?').run(ntid, now, now, stid);
|
|
65
|
-
const cps = prep('SELECT * FROM checkpoints WHERE thread_id = ? ORDER BY sequence ASC').all(stid);
|
|
66
|
-
cps.forEach(cp => prep('INSERT INTO checkpoints (id, thread_id, checkpoint_name, sequence, created_at) VALUES (?, ?, ?, ?, ?)').run(uuid(), ntid, cp.checkpoint_name, cp.sequence, now));
|
|
67
|
-
const sts = prep('SELECT * FROM thread_states WHERE thread_id = ? ORDER BY created_at ASC').all(stid);
|
|
68
|
-
sts.forEach(s => prep('INSERT INTO thread_states (id, thread_id, checkpoint_id, state_data, created_at) VALUES (?, ?, ?, ?, ?)').run(gid('state'), ntid, s.checkpoint_id, s.state_data, now));
|
|
69
|
-
const msgs = prep('SELECT * FROM messages WHERE conversationId = ? ORDER BY created_at ASC').all(stid);
|
|
70
|
-
msgs.forEach(m => prep('INSERT INTO messages (id, conversationId, role, content, created_at) VALUES (?, ?, ?, ?, ?)').run(gid('msg'), ntid, m.role, m.content, now));
|
|
71
|
-
})();
|
|
72
|
-
return this.getThread(ntid);
|
|
73
|
-
},
|
|
74
|
-
createCheckpoint(tid, name = null) {
|
|
75
|
-
const id = uuid(), now = Date.now();
|
|
76
|
-
const ms = prep('SELECT MAX(sequence) as max FROM checkpoints WHERE thread_id = ?').get(tid);
|
|
77
|
-
const seq = (ms?.max ?? -1) + 1;
|
|
78
|
-
prep('INSERT INTO checkpoints (id, thread_id, checkpoint_name, sequence, created_at) VALUES (?, ?, ?, ?, ?)').run(id, tid, name, seq, now);
|
|
79
|
-
return { checkpoint_id: id, thread_id: tid, checkpoint_name: name, sequence: seq, created_at: iso(now) };
|
|
80
|
-
},
|
|
81
|
-
getCheckpoint(cid) {
|
|
82
|
-
const r = prep('SELECT * FROM checkpoints WHERE id = ?').get(cid);
|
|
83
|
-
if (!r) return null;
|
|
84
|
-
return { checkpoint_id: r.id, thread_id: r.thread_id, checkpoint_name: r.checkpoint_name, sequence: r.sequence, created_at: iso(r.created_at) };
|
|
85
|
-
},
|
|
86
|
-
listCheckpoints(tid, lim = 50, off = 0) {
|
|
87
|
-
const tot = prep('SELECT COUNT(*) as count FROM checkpoints WHERE thread_id = ?').get(tid).count;
|
|
88
|
-
const rows = prep('SELECT * FROM checkpoints WHERE thread_id = ? ORDER BY sequence DESC LIMIT ? OFFSET ?').all(tid, lim, off);
|
|
89
|
-
const cps = rows.map(r => ({ checkpoint_id: r.id, thread_id: r.thread_id, checkpoint_name: r.checkpoint_name, sequence: r.sequence, created_at: iso(r.created_at) }));
|
|
90
|
-
return { checkpoints: cps, total: tot, limit: lim, offset: off, hasMore: off + lim < tot };
|
|
91
|
-
},
|
|
92
|
-
createRun(aid, tid = null, inp = null, cfg = null, wh = null) {
|
|
93
|
-
const rid = uuid(), now = Date.now(), mid = gid('runmeta');
|
|
94
|
-
let atid = tid;
|
|
95
|
-
if (!tid) {
|
|
96
|
-
atid = uuid();
|
|
97
|
-
prep('INSERT INTO conversations (id, agentId, title, created_at, updated_at, status, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)').run(atid, aid, 'Stateless Run', now, now, 'idle', '{"stateless":true}');
|
|
98
|
-
}
|
|
99
|
-
prep('INSERT INTO sessions (id, conversationId, status, started_at, completed_at, response, error) VALUES (?, ?, ?, ?, ?, ?, ?)').run(rid, atid, 'pending', now, null, null, null);
|
|
100
|
-
prep('INSERT INTO run_metadata (id, run_id, thread_id, agent_id, status, input, config, webhook_url, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)').run(mid, rid, tid, aid, 'pending', inp ? j(inp) : null, cfg ? j(cfg) : null, wh, now, now);
|
|
101
|
-
return { run_id: rid, thread_id: tid, agent_id: aid, status: 'pending', created_at: iso(now), updated_at: iso(now) };
|
|
102
|
-
},
|
|
103
|
-
getRun(rid) {
|
|
104
|
-
const r = prep('SELECT * FROM run_metadata WHERE run_id = ?').get(rid);
|
|
105
|
-
if (!r) return null;
|
|
106
|
-
return { run_id: r.run_id, thread_id: r.thread_id, agent_id: r.agent_id, status: r.status, created_at: iso(r.created_at), updated_at: iso(r.updated_at) };
|
|
107
|
-
},
|
|
108
|
-
updateRunStatus(rid, stat) {
|
|
109
|
-
const now = Date.now();
|
|
110
|
-
prep('UPDATE run_metadata SET status = ?, updated_at = ? WHERE run_id = ?').run(stat, now, rid);
|
|
111
|
-
prep('UPDATE sessions SET status = ? WHERE id = ?').run(stat, rid);
|
|
112
|
-
return this.getRun(rid);
|
|
113
|
-
},
|
|
114
|
-
cancelRun(rid) {
|
|
115
|
-
const r = this.getRun(rid);
|
|
116
|
-
if (!r) throw new Error('Run not found');
|
|
117
|
-
if (['success', 'error', 'cancelled'].includes(r.status)) throw new Error('Run already completed or cancelled');
|
|
118
|
-
return this.updateRunStatus(rid, 'cancelled');
|
|
119
|
-
},
|
|
120
|
-
deleteRun(rid) {
|
|
121
|
-
db.transaction(() => {
|
|
122
|
-
prep('DELETE FROM chunks WHERE sessionId = ?').run(rid);
|
|
123
|
-
prep('DELETE FROM events WHERE sessionId = ?').run(rid);
|
|
124
|
-
prep('DELETE FROM run_metadata WHERE run_id = ?').run(rid);
|
|
125
|
-
prep('DELETE FROM sessions WHERE id = ?').run(rid);
|
|
126
|
-
})();
|
|
127
|
-
return true;
|
|
128
|
-
},
|
|
129
|
-
getThreadRuns(tid, lim = 50, off = 0) {
|
|
130
|
-
const tot = prep('SELECT COUNT(*) as count FROM run_metadata WHERE thread_id = ?').get(tid).count;
|
|
131
|
-
const rows = prep('SELECT * FROM run_metadata WHERE thread_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?').all(tid, lim, off);
|
|
132
|
-
const runs = rows.map(r => ({ run_id: r.run_id, thread_id: r.thread_id, agent_id: r.agent_id, status: r.status, created_at: iso(r.created_at), updated_at: iso(r.updated_at) }));
|
|
133
|
-
return { runs, total: tot, limit: lim, offset: off, hasMore: off + lim < tot };
|
|
134
|
-
},
|
|
135
|
-
searchThreads(flt = {}) {
|
|
136
|
-
const { metadata, status, dateRange, limit = 50, offset = 0 } = flt;
|
|
137
|
-
let wh = "status != 'deleted'", prm = [];
|
|
138
|
-
if (status) { wh += ' AND status = ?'; prm.push(status); }
|
|
139
|
-
if (dateRange?.start) { wh += ' AND created_at >= ?'; prm.push(new Date(dateRange.start).getTime()); }
|
|
140
|
-
if (dateRange?.end) { wh += ' AND created_at <= ?'; prm.push(new Date(dateRange.end).getTime()); }
|
|
141
|
-
if (metadata) { for (const [k, v] of Object.entries(metadata)) { wh += ' AND metadata LIKE ?'; prm.push(`%"${k}":"${v}"%`); } }
|
|
142
|
-
const tot = prep(`SELECT COUNT(*) as count FROM conversations WHERE ${wh}`).get(...prm).count;
|
|
143
|
-
const rows = prep(`SELECT * FROM conversations WHERE ${wh} ORDER BY updated_at DESC LIMIT ? OFFSET ?`).all(...prm, limit, offset);
|
|
144
|
-
const ths = rows.map(r => ({ thread_id: r.id, created_at: iso(r.created_at), updated_at: iso(r.updated_at), metadata: jp(r.metadata), status: r.status || 'idle' }));
|
|
145
|
-
return { threads: ths, total: tot, limit, offset, hasMore: offset + limit < tot };
|
|
146
|
-
},
|
|
147
|
-
searchAgents(agents, flt = {}) {
|
|
148
|
-
const { name, version, capabilities, limit = 50, offset = 0 } = flt;
|
|
149
|
-
let results = agents;
|
|
150
|
-
if (name) {
|
|
151
|
-
const n = name.toLowerCase();
|
|
152
|
-
results = results.filter(a => a.name.toLowerCase().includes(n) || a.id.toLowerCase().includes(n));
|
|
153
|
-
}
|
|
154
|
-
if (capabilities) {
|
|
155
|
-
results = results.filter(a => {
|
|
156
|
-
const desc = this.getAgentDescriptor ? this.getAgentDescriptor(a.id) : null;
|
|
157
|
-
if (!desc) return false;
|
|
158
|
-
const caps = desc.specs?.capabilities || {};
|
|
159
|
-
if (capabilities.streaming !== undefined && !caps.streaming) return false;
|
|
160
|
-
if (capabilities.threads !== undefined && caps.threads !== capabilities.threads) return false;
|
|
161
|
-
if (capabilities.interrupts !== undefined && caps.interrupts !== capabilities.interrupts) return false;
|
|
162
|
-
return true;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
const total = results.length;
|
|
166
|
-
const paginated = results.slice(offset, offset + limit);
|
|
167
|
-
const agents_list = paginated.map(a => ({ agent_id: a.id, name: a.name, version: version || '1.0.0', path: a.path }));
|
|
168
|
-
return { agents: agents_list, total, limit, offset, hasMore: offset + limit < total };
|
|
169
|
-
},
|
|
170
|
-
searchRuns(flt = {}) {
|
|
171
|
-
const { agent_id, thread_id, status, limit = 50, offset = 0 } = flt;
|
|
172
|
-
let wh = '1=1', prm = [];
|
|
173
|
-
if (agent_id) { wh += ' AND agent_id = ?'; prm.push(agent_id); }
|
|
174
|
-
if (thread_id) { wh += ' AND thread_id = ?'; prm.push(thread_id); }
|
|
175
|
-
if (status) { wh += ' AND status = ?'; prm.push(status); }
|
|
176
|
-
const tot = prep(`SELECT COUNT(*) as count FROM run_metadata WHERE ${wh}`).get(...prm).count;
|
|
177
|
-
const rows = prep(`SELECT * FROM run_metadata WHERE ${wh} ORDER BY created_at DESC LIMIT ? OFFSET ?`).all(...prm, limit, offset);
|
|
178
|
-
const runs = rows.map(r => ({ run_id: r.run_id, thread_id: r.thread_id, agent_id: r.agent_id, status: r.status, created_at: iso(r.created_at), updated_at: iso(r.updated_at) }));
|
|
179
|
-
return { runs, total: tot, limit, offset, hasMore: offset + limit < tot };
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}
|
package/static/js/codec.js
DELETED
package/static/js/sync-debug.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sync-to-Display Debug System
|
|
3
|
-
* Comprehensive logging and state validation for sync/render pipeline
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
class SyncDebugger {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.enabled = false;
|
|
9
|
-
this.eventLog = [];
|
|
10
|
-
this.maxLogSize = 500;
|
|
11
|
-
this.stateSnapshots = [];
|
|
12
|
-
this.processingStack = [];
|
|
13
|
-
this.startTime = Date.now();
|
|
14
|
-
|
|
15
|
-
// Event tracking
|
|
16
|
-
this.processedEventIds = new Set();
|
|
17
|
-
this.eventCounts = {};
|
|
18
|
-
|
|
19
|
-
// Timing
|
|
20
|
-
this.timingMarkers = {};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
enable() {
|
|
24
|
-
this.enabled = true;
|
|
25
|
-
console.log('[SyncDebug] Enabled');
|
|
26
|
-
window.SyncDebugger = this;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
disable() {
|
|
30
|
-
this.enabled = false;
|
|
31
|
-
console.log('[SyncDebug] Disabled');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
logEvent(type, data) {
|
|
35
|
-
if (!this.enabled) return;
|
|
36
|
-
|
|
37
|
-
const timestamp = Date.now() - this.startTime;
|
|
38
|
-
const eventId = data?.id || data?.messageId || data?.conversationId || '?';
|
|
39
|
-
|
|
40
|
-
// Check for duplicates
|
|
41
|
-
const isDuplicate = this.processedEventIds.has(eventId) &&
|
|
42
|
-
this.eventLog.some(e => e.type === type && e.eventId === eventId);
|
|
43
|
-
|
|
44
|
-
const entry = {
|
|
45
|
-
timestamp,
|
|
46
|
-
type,
|
|
47
|
-
eventId,
|
|
48
|
-
isDuplicate,
|
|
49
|
-
dataKeys: data ? Object.keys(data) : [],
|
|
50
|
-
dataSize: JSON.stringify(data || {}).length
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
this.eventLog.push(entry);
|
|
54
|
-
this.eventCounts[type] = (this.eventCounts[type] || 0) + 1;
|
|
55
|
-
this.processedEventIds.add(eventId);
|
|
56
|
-
|
|
57
|
-
if (this.eventLog.length > this.maxLogSize) {
|
|
58
|
-
this.eventLog.shift();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (isDuplicate) {
|
|
62
|
-
console.warn(`[SyncDebug] DUPLICATE EVENT: ${type} - ${eventId}`, entry);
|
|
63
|
-
} else {
|
|
64
|
-
console.log(`[SyncDebug] Event: ${type} (${timestamp}ms)`, entry);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
logStateChange(name, before, after) {
|
|
69
|
-
if (!this.enabled) return;
|
|
70
|
-
|
|
71
|
-
const timestamp = Date.now() - this.startTime;
|
|
72
|
-
const snapshot = {
|
|
73
|
-
timestamp,
|
|
74
|
-
name,
|
|
75
|
-
before: JSON.parse(JSON.stringify(before)),
|
|
76
|
-
after: JSON.parse(JSON.stringify(after)),
|
|
77
|
-
changed: JSON.stringify(before) !== JSON.stringify(after)
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
this.stateSnapshots.push(snapshot);
|
|
81
|
-
if (this.stateSnapshots.length > this.maxLogSize) {
|
|
82
|
-
this.stateSnapshots.shift();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (snapshot.changed) {
|
|
86
|
-
console.log(`[SyncDebug] State changed: ${name}`, snapshot);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
pushOperation(name) {
|
|
91
|
-
const marker = { name, start: Date.now() };
|
|
92
|
-
this.processingStack.push(marker);
|
|
93
|
-
console.log(`[SyncDebug] > ${name}`);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
popOperation() {
|
|
97
|
-
const marker = this.processingStack.pop();
|
|
98
|
-
if (marker) {
|
|
99
|
-
const duration = Date.now() - marker.start;
|
|
100
|
-
console.log(`[SyncDebug] < ${marker.name} (${duration}ms)`);
|
|
101
|
-
if (duration > 100) {
|
|
102
|
-
console.warn(`[SyncDebug] SLOW: ${marker.name} took ${duration}ms`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
getReport() {
|
|
108
|
-
return {
|
|
109
|
-
totalEvents: this.eventLog.length,
|
|
110
|
-
eventCounts: this.eventCounts,
|
|
111
|
-
duplicates: this.eventLog.filter(e => e.isDuplicate).length,
|
|
112
|
-
stateChanges: this.stateSnapshots.length,
|
|
113
|
-
uniqueEventIds: this.processedEventIds.size,
|
|
114
|
-
recentEvents: this.eventLog.slice(-20),
|
|
115
|
-
recentStateChanges: this.stateSnapshots.slice(-20)
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
printReport() {
|
|
120
|
-
const report = this.getReport();
|
|
121
|
-
console.table(report);
|
|
122
|
-
console.table(report.recentEvents);
|
|
123
|
-
console.table(report.recentStateChanges);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
clearLogs() {
|
|
127
|
-
this.eventLog = [];
|
|
128
|
-
this.stateSnapshots = [];
|
|
129
|
-
this.processedEventIds.clear();
|
|
130
|
-
this.eventCounts = {};
|
|
131
|
-
this.processingStack = [];
|
|
132
|
-
console.log('[SyncDebug] Logs cleared');
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (window.__DEBUG__) {
|
|
137
|
-
window.syncDebugger = new SyncDebugger();
|
|
138
|
-
window.debugSync = {
|
|
139
|
-
enable: () => window.syncDebugger.enable(),
|
|
140
|
-
disable: () => window.syncDebugger.disable(),
|
|
141
|
-
report: () => window.syncDebugger.printReport(),
|
|
142
|
-
clear: () => window.syncDebugger.clearLogs(),
|
|
143
|
-
get: () => window.syncDebugger.getReport()
|
|
144
|
-
};
|
|
145
|
-
console.log('[SyncDebug] Available. Use: debugSync.enable(), debugSync.report(), debugSync.clear()');
|
|
146
|
-
}
|
package/test-cli-detection.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { checkCliInstalled, getCliVersion } from './lib/tool-manager.js';
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
|
|
5
|
-
console.log('=== CLI Tool Detection Test ===\n');
|
|
6
|
-
|
|
7
|
-
const tools = [
|
|
8
|
-
{ pkg: '@anthropic-ai/claude-code', bin: 'claude' },
|
|
9
|
-
{ pkg: 'opencode-ai', bin: 'opencode' },
|
|
10
|
-
{ pkg: '@google/gemini-cli', bin: 'gemini' },
|
|
11
|
-
{ pkg: '@kilocode/cli', bin: 'kilo' },
|
|
12
|
-
{ pkg: '@openai/codex', bin: 'codex' }
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
tools.forEach(tool => {
|
|
16
|
-
try {
|
|
17
|
-
// Direct which check
|
|
18
|
-
const which = process.platform === 'win32' ? 'where' : 'which';
|
|
19
|
-
execSync(`${which} ${tool.bin}`, { stdio: 'pipe', timeout: 3000 });
|
|
20
|
-
const version = execSync(`${tool.bin} --version`, { stdio: 'pipe', timeout: 2000, encoding: 'utf8' }).trim();
|
|
21
|
-
const match = version.match(/(\d+\.\d+\.\d+)/);
|
|
22
|
-
console.log(`✓ ${tool.pkg}`);
|
|
23
|
-
console.log(` Binary: ${tool.bin} (found)`);
|
|
24
|
-
console.log(` Version output: ${version.substring(0, 50)}`);
|
|
25
|
-
console.log(` Parsed version: ${match ? match[1] : 'NOT FOUND'}`);
|
|
26
|
-
} catch (e) {
|
|
27
|
-
console.log(`✗ ${tool.pkg}`);
|
|
28
|
-
console.log(` Binary: ${tool.bin} (not found in PATH)`);
|
|
29
|
-
}
|
|
30
|
-
console.log();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
console.log('=== Testing Tool Manager Functions ===\n');
|
|
34
|
-
|
|
35
|
-
// Test with promises
|
|
36
|
-
console.log('Note: Tool manager functions require async context');
|
|
37
|
-
console.log('Use tool-manager directly in server to test full functionality');
|
package/test-fixes.mjs
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Test script for validating the two fixes:
|
|
5
|
-
* 1. Agent selector visibility in chat view
|
|
6
|
-
* 2. TTS streaming pre-generation
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import fs from 'fs';
|
|
10
|
-
import { execSync } from 'child_process';
|
|
11
|
-
|
|
12
|
-
console.log('=== AgentGUI Fix Validation ===\n');
|
|
13
|
-
|
|
14
|
-
// Test 1: Verify agent selectors are NOT hidden on desktop
|
|
15
|
-
console.log('Test 1: Agent Selector Visibility');
|
|
16
|
-
console.log('-----------------------------------');
|
|
17
|
-
const html = fs.readFileSync('./static/index.html', 'utf-8');
|
|
18
|
-
const beforeMobileMedia = html.substring(0, html.indexOf('@media (max-width: 480px)'));
|
|
19
|
-
const cliHiddenOnDesktop = beforeMobileMedia.includes('.cli-selector { display: none; }');
|
|
20
|
-
const modelHiddenOnDesktop = beforeMobileMedia.includes('.model-selector { display: none; }');
|
|
21
|
-
|
|
22
|
-
if (!cliHiddenOnDesktop && !modelHiddenOnDesktop) {
|
|
23
|
-
console.log('✓ PASS: Agent selectors are NOT hidden by CSS on desktop');
|
|
24
|
-
console.log(' - CLI selector will be visible when populated');
|
|
25
|
-
console.log(' - Model selector will be visible when populated');
|
|
26
|
-
} else {
|
|
27
|
-
console.log('❌ FAIL: Agent selectors are still hidden on desktop');
|
|
28
|
-
if (cliHiddenOnDesktop) console.log(' - .cli-selector has display:none');
|
|
29
|
-
if (modelHiddenOnDesktop) console.log(' - .model-selector has display:none');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Verify selectors are in HTML
|
|
33
|
-
const hasSelectors = html.includes('data-cli-selector') &&
|
|
34
|
-
html.includes('data-agent-selector') &&
|
|
35
|
-
html.includes('data-model-selector');
|
|
36
|
-
if (hasSelectors) {
|
|
37
|
-
console.log('✓ PASS: All selector elements are present in HTML');
|
|
38
|
-
} else {
|
|
39
|
-
console.log('❌ FAIL: Some selector elements are missing');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Test 2: Verify TTS pre-generation is implemented
|
|
43
|
-
console.log('\nTest 2: TTS Streaming Pre-generation');
|
|
44
|
-
console.log('--------------------------------------');
|
|
45
|
-
const voiceJs = fs.readFileSync('./static/js/voice.js', 'utf-8');
|
|
46
|
-
const hasPreGenerateFunction = voiceJs.includes('function preGenerateTTS(text)');
|
|
47
|
-
const callsPreGenerate = voiceJs.includes('preGenerateTTS(block.text)');
|
|
48
|
-
const usesCache = voiceJs.includes('if (ttsAudioCache.has(cacheKey)) return;');
|
|
49
|
-
const fetchesTTS = voiceJs.match(/fetch\(BASE \+ '\/api\/tts'/g)?.length >= 2; // Should be in both preGenerate and processQueue
|
|
50
|
-
|
|
51
|
-
if (hasPreGenerateFunction && callsPreGenerate && usesCache && fetchesTTS) {
|
|
52
|
-
console.log('✓ PASS: TTS pre-generation is fully implemented');
|
|
53
|
-
console.log(' - preGenerateTTS function exists');
|
|
54
|
-
console.log(' - Called when assistant text arrives');
|
|
55
|
-
console.log(' - Uses cache to avoid duplicate generation');
|
|
56
|
-
console.log(' - Audio generation happens in background');
|
|
57
|
-
} else {
|
|
58
|
-
console.log('❌ FAIL: TTS pre-generation incomplete');
|
|
59
|
-
if (!hasPreGenerateFunction) console.log(' - Missing preGenerateTTS function');
|
|
60
|
-
if (!callsPreGenerate) console.log(' - Not called in handleVoiceBlock');
|
|
61
|
-
if (!usesCache) console.log(' - Missing cache check');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Test 3: Check that client.js populates selectors correctly
|
|
65
|
-
console.log('\nTest 3: Selector Population Logic');
|
|
66
|
-
console.log('-----------------------------------');
|
|
67
|
-
const clientJs = fs.readFileSync('./static/js/client.js', 'utf-8');
|
|
68
|
-
const setsDisplay = clientJs.includes("this.ui.cliSelector.style.display = 'inline-block'");
|
|
69
|
-
const populatesOptions = clientJs.includes('.innerHTML = displayAgents');
|
|
70
|
-
|
|
71
|
-
if (setsDisplay && populatesOptions) {
|
|
72
|
-
console.log('✓ PASS: Client.js correctly populates and displays selectors');
|
|
73
|
-
console.log(' - Sets display to inline-block when agents loaded');
|
|
74
|
-
console.log(' - Populates options from agent list');
|
|
75
|
-
} else {
|
|
76
|
-
console.log('❌ FAIL: Selector population logic may be broken');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Summary
|
|
80
|
-
console.log('\n=== SUMMARY ===');
|
|
81
|
-
const allTestsPass = !cliHiddenOnDesktop && !modelHiddenOnDesktop &&
|
|
82
|
-
hasSelectors && hasPreGenerateFunction &&
|
|
83
|
-
callsPreGenerate && usesCache &&
|
|
84
|
-
setsDisplay && populatesOptions;
|
|
85
|
-
|
|
86
|
-
if (allTestsPass) {
|
|
87
|
-
console.log('✓ ALL TESTS PASSED\n');
|
|
88
|
-
console.log('Manual Testing Instructions:');
|
|
89
|
-
console.log('1. Start server: npm run dev');
|
|
90
|
-
console.log('2. Open http://localhost:3000/gm/');
|
|
91
|
-
console.log('3. Check chat input area - you should see:');
|
|
92
|
-
console.log(' - CLI selector dropdown (e.g., "Claude")');
|
|
93
|
-
console.log(' - Model selector dropdown (e.g., "Sonnet 4.5")');
|
|
94
|
-
console.log(' - Microphone button for voice input');
|
|
95
|
-
console.log('4. Open Voice tab and enable "Auto-speak responses"');
|
|
96
|
-
console.log('5. Send a message and observe:');
|
|
97
|
-
console.log(' - Text streams in as agent responds');
|
|
98
|
-
console.log(' - Voice playback starts immediately after completion (no delay)');
|
|
99
|
-
console.log(' - Audio was pre-generated during streaming');
|
|
100
|
-
} else {
|
|
101
|
-
console.log('❌ SOME TESTS FAILED - Review output above\n');
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
package/test-thread-steering.mjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Thread Steering Test
|
|
5
|
-
* Tests the thread.run.steer endpoint for interrupting and restarting with instruction
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import http from 'http';
|
|
9
|
-
|
|
10
|
-
const BASE_URL = 'http://localhost:3000/gm';
|
|
11
|
-
|
|
12
|
-
async function request(method, path, body = null) {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
const url = new URL(path, BASE_URL);
|
|
15
|
-
const options = {
|
|
16
|
-
hostname: url.hostname,
|
|
17
|
-
port: url.port || 3000,
|
|
18
|
-
path: url.pathname + url.search,
|
|
19
|
-
method,
|
|
20
|
-
headers: { 'Content-Type': 'application/json' }
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const req = http.request(options, (res) => {
|
|
24
|
-
let data = '';
|
|
25
|
-
res.on('data', (chunk) => (data += chunk));
|
|
26
|
-
res.on('end', () => {
|
|
27
|
-
try {
|
|
28
|
-
resolve({ status: res.statusCode, data: JSON.parse(data) });
|
|
29
|
-
} catch (e) {
|
|
30
|
-
resolve({ status: res.statusCode, data: data || null });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
req.on('error', reject);
|
|
36
|
-
if (body) req.write(JSON.stringify(body));
|
|
37
|
-
req.end();
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function runTests() {
|
|
42
|
-
console.log('🧪 Thread Steering Tests\n');
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
// Health check
|
|
46
|
-
const health = await request('GET', '/api/home');
|
|
47
|
-
if (health.status !== 200) {
|
|
48
|
-
console.error('❌ Server not running at', BASE_URL);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
console.log('✅ Server is running\n');
|
|
53
|
-
|
|
54
|
-
// Test 1: Verify thread.run.steer endpoint exists (check if it's callable)
|
|
55
|
-
console.log('[TEST 1] Verify thread.run.steer endpoint accepts correct parameters');
|
|
56
|
-
console.log(' - Creating thread...');
|
|
57
|
-
|
|
58
|
-
// Note: We can't fully test thread.run.steer without a running agent,
|
|
59
|
-
// but we can verify the endpoint structure exists by checking server.js
|
|
60
|
-
const serverCheck = await request('GET', '/api/agents');
|
|
61
|
-
if (serverCheck.status === 200) {
|
|
62
|
-
console.log(' ✅ Agent endpoint accessible');
|
|
63
|
-
console.log(' ✅ thread.run.steer endpoint should be available via WebSocket\n');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
console.log('[TEST 2] Thread steering mechanism');
|
|
67
|
-
console.log(' Implementation verified:');
|
|
68
|
-
console.log(' - Endpoint: thread.run.steer');
|
|
69
|
-
console.log(' - Parameters: id (threadId), runId, instruction');
|
|
70
|
-
console.log(' - Behavior: Cancel run, create new run with instruction');
|
|
71
|
-
console.log(' - Result: New run executes with steering instruction\n');
|
|
72
|
-
|
|
73
|
-
console.log('[TEST 3] Thread steering vs Conversation steering');
|
|
74
|
-
console.log(' Conversation steering (conv.steer):');
|
|
75
|
-
console.log(' ✓ Keeps process alive, sends instruction via stdin JSON-RPC');
|
|
76
|
-
console.log(' ✓ Preserves execution context');
|
|
77
|
-
console.log(' ✗ Only works with agents that support stdin\n');
|
|
78
|
-
|
|
79
|
-
console.log(' Thread steering (thread.run.steer):');
|
|
80
|
-
console.log(' ✓ Works with any agent type');
|
|
81
|
-
console.log(' ✓ Simple cancel + resume mechanism');
|
|
82
|
-
console.log(' ✗ Restarts from beginning (loses context)\n');
|
|
83
|
-
|
|
84
|
-
console.log('✅ Thread steering implementation verified');
|
|
85
|
-
console.log('\nUsage example:');
|
|
86
|
-
console.log(' const result = await wsClient.rpc("thread.run.steer", {');
|
|
87
|
-
console.log(' id: threadId,');
|
|
88
|
-
console.log(' runId: currentRunId,');
|
|
89
|
-
console.log(' instruction: "new prompt or instruction"');
|
|
90
|
-
console.log(' });');
|
|
91
|
-
console.log(' // Returns: { steered: true, cancelled_run, new_run, ... }');
|
|
92
|
-
|
|
93
|
-
process.exit(0);
|
|
94
|
-
} catch (err) {
|
|
95
|
-
console.error('❌ Test error:', err.message);
|
|
96
|
-
process.exit(1);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
runTests();
|