agentgui 1.0.769 → 1.0.770

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.md CHANGED
@@ -50,6 +50,8 @@ lib/routes-speech.js Speech/TTS HTTP route handlers (stt, tts, voices, speech-
50
50
  lib/routes-oauth.js OAuth HTTP route handlers (gemini-oauth/*, codex-oauth/*)
51
51
  lib/routes-tools.js Tool management HTTP route handlers (list, install, update, history, refresh)
52
52
  lib/routes-util.js Utility HTTP route handlers (clone, folders, git, home, version, import)
53
+ lib/routes-conversations.js Conversation CRUD HTTP route handlers (list, create, get, update, delete, archive, restore)
54
+ lib/routes-debug.js Debug/backup/restore/ws-stats HTTP route handlers
53
55
  lib/routes-threads.js Thread CRUD HTTP route handlers (ACP v0.2.3 thread API)
54
56
  lib/ws-protocol.js WebSocket RPC router (WsRouter class)
55
57
  lib/ws-optimizer.js Per-client priority queue for WS event batching
@@ -0,0 +1,87 @@
1
+ import path from 'path';
2
+ import os from 'os';
3
+
4
+ function expandTilde(p) { return p && p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p; }
5
+
6
+ export function register(deps) {
7
+ const { sendJSON, parseBody, queries, activeExecutions, broadcastSync } = deps;
8
+ const routes = {};
9
+
10
+ routes['GET /api/conversations'] = async (req, res) => {
11
+ const conversations = queries.getConversationsList();
12
+ const activeSessionConvIds = new Set(queries.getActiveSessionConversationIds());
13
+ for (const conv of conversations) {
14
+ if (conv.isStreaming && !activeExecutions.has(conv.id) && !activeSessionConvIds.has(conv.id)) conv.isStreaming = 0;
15
+ }
16
+ sendJSON(req, res, 200, { conversations });
17
+ };
18
+
19
+ routes['POST /api/conversations'] = async (req, res) => {
20
+ const body = await parseBody(req);
21
+ const normalizedWorkingDir = body.workingDirectory ? path.resolve(expandTilde(body.workingDirectory)) : null;
22
+ const conversation = queries.createConversation(body.agentId, body.title, normalizedWorkingDir, body.model || null);
23
+ queries.createEvent('conversation.created', { agentId: body.agentId, workingDirectory: conversation.workingDirectory, model: conversation.model }, conversation.id);
24
+ broadcastSync({ type: 'conversation_created', conversation });
25
+ sendJSON(req, res, 201, { conversation });
26
+ };
27
+
28
+ routes['GET /api/conversations/archived'] = async (req, res) => {
29
+ sendJSON(req, res, 200, { conversations: queries.getArchivedConversations() });
30
+ };
31
+
32
+ routes['_match'] = (method, pathOnly) => {
33
+ const key = `${method} ${pathOnly}`;
34
+ if (routes[key]) return routes[key];
35
+ let m;
36
+ if ((m = pathOnly.match(/^\/api\/conversations\/([^/]+)$/))) {
37
+ if (method === 'GET') return (req, res) => handleGetConv(req, res, m[1]);
38
+ if (method === 'POST' || method === 'PUT') return (req, res) => handleUpdateConv(req, res, m[1]);
39
+ if (method === 'DELETE') return (req, res) => handleDeleteConv(req, res, m[1]);
40
+ }
41
+ if (method === 'POST' && (m = pathOnly.match(/^\/api\/conversations\/([^/]+)\/archive$/)))
42
+ return (req, res) => handleArchive(req, res, m[1]);
43
+ if (method === 'POST' && (m = pathOnly.match(/^\/api\/conversations\/([^/]+)\/restore$/)))
44
+ return (req, res) => handleRestore(req, res, m[1]);
45
+ return null;
46
+ };
47
+
48
+ async function handleGetConv(req, res, id) {
49
+ const conv = queries.getConversation(id);
50
+ if (!conv) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
51
+ const latestSession = queries.getLatestSession(id);
52
+ sendJSON(req, res, 200, { conversation: conv, isActivelyStreaming: activeExecutions.has(id), latestSession });
53
+ }
54
+
55
+ async function handleUpdateConv(req, res, id) {
56
+ const body = await parseBody(req);
57
+ if (body.workingDirectory) body.workingDirectory = path.resolve(expandTilde(body.workingDirectory));
58
+ const conv = queries.updateConversation(id, body);
59
+ if (!conv) { sendJSON(req, res, 404, { error: 'Conversation not found' }); return; }
60
+ queries.createEvent('conversation.updated', body, id);
61
+ broadcastSync({ type: 'conversation_updated', conversation: conv });
62
+ sendJSON(req, res, 200, { conversation: conv });
63
+ }
64
+
65
+ async function handleDeleteConv(req, res, id) {
66
+ const deleted = queries.deleteConversation(id);
67
+ if (!deleted) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
68
+ broadcastSync({ type: 'conversation_deleted', conversationId: id });
69
+ sendJSON(req, res, 200, { deleted: true });
70
+ }
71
+
72
+ async function handleArchive(req, res, id) {
73
+ const conv = queries.archiveConversation(id);
74
+ if (!conv) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
75
+ broadcastSync({ type: 'conversation_deleted', conversationId: id });
76
+ sendJSON(req, res, 200, { conversation: conv });
77
+ }
78
+
79
+ async function handleRestore(req, res, id) {
80
+ const conv = queries.restoreConversation(id);
81
+ if (!conv) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
82
+ broadcastSync({ type: 'conversation_created', conversation: conv });
83
+ sendJSON(req, res, 200, { conversation: conv });
84
+ }
85
+
86
+ return routes;
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.769",
3
+ "version": "1.0.770",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "electron/main.js",
package/server.js CHANGED
@@ -24,6 +24,7 @@ import { register as registerUtilRoutes } from './lib/routes-util.js';
24
24
  import { register as registerToolRoutes } from './lib/routes-tools.js';
25
25
  import { register as registerThreadRoutes } from './lib/routes-threads.js';
26
26
  import { register as registerDebugRoutes } from './lib/routes-debug.js';
27
+ import { register as registerConvRoutes } from './lib/routes-conversations.js';
27
28
  import { startCodexOAuth, exchangeCodexOAuthCode, handleCodexOAuthCallback, getCodexOAuthStatus, getCodexOAuthState, CODEX_HOME, CODEX_AUTH_FILE } from './lib/oauth-codex.js';
28
29
  import { WSOptimizer } from './lib/ws-optimizer.js';
29
30
  import { WsRouter } from './lib/ws-protocol.js';
@@ -546,94 +547,8 @@ const server = http.createServer(async (req, res) => {
546
547
  return;
547
548
  }
548
549
 
549
- if (pathOnly === '/api/conversations' && req.method === 'GET') {
550
- const conversations = queries.getConversationsList();
551
- // Filter out stale streaming state using a single bulk query instead of N+1 per-conversation queries
552
- const activeSessionConvIds = new Set(queries.getActiveSessionConversationIds());
553
- for (const conv of conversations) {
554
- if (conv.isStreaming && !activeExecutions.has(conv.id) && !activeSessionConvIds.has(conv.id)) {
555
- conv.isStreaming = 0;
556
- }
557
- }
558
- sendJSON(req, res, 200, { conversations });
559
- return;
560
- }
561
-
562
- if (pathOnly === '/api/conversations' && req.method === 'POST') {
563
- const body = await parseBody(req);
564
- // Normalize working directory to avoid Windows path issues; expand ~ to home
565
- const expandTilde = p => p && p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p;
566
- const normalizedWorkingDir = body.workingDirectory ? path.resolve(expandTilde(body.workingDirectory)) : null;
567
- const conversation = queries.createConversation(body.agentId, body.title, normalizedWorkingDir, body.model || null);
568
- queries.createEvent('conversation.created', { agentId: body.agentId, workingDirectory: conversation.workingDirectory, model: conversation.model }, conversation.id);
569
- broadcastSync({ type: 'conversation_created', conversation });
570
- sendJSON(req, res, 201, { conversation });
571
- return;
572
- }
573
-
574
- const convMatch = pathOnly.match(/^\/api\/conversations\/([^/]+)$/);
575
- if (convMatch) {
576
- if (req.method === 'GET') {
577
- const conv = queries.getConversation(convMatch[1]);
578
- if (!conv) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
579
-
580
- const latestSession = queries.getLatestSession(convMatch[1]);
581
- const isActivelyStreaming = activeExecutions.has(convMatch[1]);
582
-
583
- sendJSON(req, res, 200, {
584
- conversation: conv,
585
- isActivelyStreaming,
586
- latestSession
587
- });
588
- return;
589
- }
590
-
591
- if (req.method === 'POST' || req.method === 'PUT') {
592
- const body = await parseBody(req);
593
- // Normalize working directory if present to avoid Windows path issues; expand ~ to home
594
- if (body.workingDirectory) {
595
- const expandTilde = p => p && p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p;
596
- body.workingDirectory = path.resolve(expandTilde(body.workingDirectory));
597
- }
598
- const conv = queries.updateConversation(convMatch[1], body);
599
- if (!conv) { sendJSON(req, res, 404, { error: 'Conversation not found' }); return; }
600
- queries.createEvent('conversation.updated', body, convMatch[1]);
601
- broadcastSync({ type: 'conversation_updated', conversation: conv });
602
- sendJSON(req, res, 200, { conversation: conv });
603
- return;
604
- }
605
-
606
- if (req.method === 'DELETE') {
607
- const deleted = queries.deleteConversation(convMatch[1]);
608
- if (!deleted) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
609
- broadcastSync({ type: 'conversation_deleted', conversationId: convMatch[1] });
610
- sendJSON(req, res, 200, { deleted: true });
611
- return;
612
- }
613
- }
614
-
615
- if (pathOnly === '/api/conversations/archived' && req.method === 'GET') {
616
- sendJSON(req, res, 200, { conversations: queries.getArchivedConversations() });
617
- return;
618
- }
619
-
620
- const archiveMatch = pathOnly.match(/^\/api\/conversations\/([^/]+)\/archive$/);
621
- if (archiveMatch && req.method === 'POST') {
622
- const conv = queries.archiveConversation(archiveMatch[1]);
623
- if (!conv) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
624
- broadcastSync({ type: 'conversation_deleted', conversationId: archiveMatch[1] });
625
- sendJSON(req, res, 200, { conversation: conv });
626
- return;
627
- }
628
-
629
- const restoreMatch = pathOnly.match(/^\/api\/conversations\/([^/]+)\/restore$/);
630
- if (restoreMatch && req.method === 'POST') {
631
- const conv = queries.restoreConversation(restoreMatch[1]);
632
- if (!conv) { sendJSON(req, res, 404, { error: 'Not found' }); return; }
633
- broadcastSync({ type: 'conversation_created', conversation: conv });
634
- sendJSON(req, res, 200, { conversation: conv });
635
- return;
636
- }
550
+ const convHandler = _convRoutes._match(req.method, pathOnly);
551
+ if (convHandler) { await convHandler(req, res); return; }
637
552
 
638
553
  const messagesMatch = pathOnly.match(/^\/api\/conversations\/([^/]+)\/messages$/);
639
554
  if (messagesMatch) {
@@ -2850,6 +2765,7 @@ const _utilRoutes = registerUtilRoutes({ sendJSON, parseBody, queries, STARTUP_C
2850
2765
  const _toolRoutes = registerToolRoutes({ sendJSON, parseBody, queries, broadcastSync, logError, toolManager });
2851
2766
  const _threadRoutes = registerThreadRoutes({ sendJSON, parseBody, queries });
2852
2767
  const _debugRoutes = registerDebugRoutes({ sendJSON, queries, activeExecutions, messageQueues, syncClients, wsOptimizer, _errLogPath });
2768
+ const _convRoutes = registerConvRoutes({ sendJSON, parseBody, queries, activeExecutions, broadcastSync });
2853
2769
 
2854
2770
  registerConvHandlers(wsRouter, {
2855
2771
  queries, activeExecutions, rateLimitState,