agentgui 1.0.939 → 1.0.941

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.
Files changed (46) hide show
  1. package/AGENTS.md +12 -7
  2. package/lib/claude-runner-agents.js +25 -0
  3. package/lib/ws-handlers-util.js +27 -1
  4. package/package.json +1 -1
  5. package/server.js +10 -1
  6. package/site/app/index.html +14 -37
  7. package/site/app/js/app.js +506 -104
  8. package/site/app/js/backend.js +44 -32
  9. package/site/app/vendor/anentrypoint-design/247420.css +274 -86
  10. package/site/app/vendor/anentrypoint-design/247420.js +12 -12
  11. package/site/app/vendor/cdn/dompurify.js +9 -0
  12. package/site/app/vendor/cdn/fonts/1291de6d401a.woff2 +0 -0
  13. package/site/app/vendor/cdn/fonts/1ba89a87e0b8.woff2 +0 -0
  14. package/site/app/vendor/cdn/fonts/3644d51c507b.woff2 +0 -0
  15. package/site/app/vendor/cdn/fonts/4b91d2650dc2.woff2 +0 -0
  16. package/site/app/vendor/cdn/fonts/530d036ba64a.woff2 +0 -0
  17. package/site/app/vendor/cdn/fonts/570a2bdd8f8b.woff2 +0 -0
  18. package/site/app/vendor/cdn/fonts/5dd6d880fee9.woff2 +0 -0
  19. package/site/app/vendor/cdn/fonts/62de9143afe3.woff2 +0 -0
  20. package/site/app/vendor/cdn/fonts/64884efa2f11.woff2 +0 -0
  21. package/site/app/vendor/cdn/fonts/68cd7063be2e.woff2 +0 -0
  22. package/site/app/vendor/cdn/fonts/6c252abcf99b.woff2 +0 -0
  23. package/site/app/vendor/cdn/fonts/71e69e06516a.woff2 +0 -0
  24. package/site/app/vendor/cdn/fonts/9ea68c62083f.woff2 +0 -0
  25. package/site/app/vendor/cdn/fonts/c010f9b7d6b2.woff2 +0 -0
  26. package/site/app/vendor/cdn/fonts/d69723fc74be.woff2 +0 -0
  27. package/site/app/vendor/cdn/fonts/fonts.css +459 -0
  28. package/site/app/vendor/cdn/marked.js +8 -0
  29. package/site/app/vendor/cdn/prismjs/components/prism-bash.min.js +1 -0
  30. package/site/app/vendor/cdn/prismjs/components/prism-clike.min.js +1 -0
  31. package/site/app/vendor/cdn/prismjs/components/prism-core.min.js +1 -0
  32. package/site/app/vendor/cdn/prismjs/components/prism-css.min.js +1 -0
  33. package/site/app/vendor/cdn/prismjs/components/prism-diff.min.js +1 -0
  34. package/site/app/vendor/cdn/prismjs/components/prism-go.min.js +1 -0
  35. package/site/app/vendor/cdn/prismjs/components/prism-javascript.min.js +1 -0
  36. package/site/app/vendor/cdn/prismjs/components/prism-json.min.js +1 -0
  37. package/site/app/vendor/cdn/prismjs/components/prism-jsx.min.js +1 -0
  38. package/site/app/vendor/cdn/prismjs/components/prism-markdown.min.js +1 -0
  39. package/site/app/vendor/cdn/prismjs/components/prism-markup.min.js +1 -0
  40. package/site/app/vendor/cdn/prismjs/components/prism-python.min.js +1 -0
  41. package/site/app/vendor/cdn/prismjs/components/prism-rust.min.js +1 -0
  42. package/site/app/vendor/cdn/prismjs/components/prism-sql.min.js +1 -0
  43. package/site/app/vendor/cdn/prismjs/components/prism-toml.min.js +1 -0
  44. package/site/app/vendor/cdn/prismjs/components/prism-tsx.min.js +1 -0
  45. package/site/app/vendor/cdn/prismjs/components/prism-typescript.min.js +1 -0
  46. package/site/app/vendor/cdn/prismjs/components/prism-yaml.min.js +1 -0
package/AGENTS.md CHANGED
@@ -16,14 +16,9 @@ Dependencies:
16
16
  - `ccsniff` (>=1.1.0) — exports `createHistoryRouter({projectsDir})` mountable on Express; serves `/v1/history/{sessions,sessions/:sid/events,search,snapshot,reindex,stream}`. Reads `~/.claude/projects` (override via `CLAUDE_PROJECTS_DIR`).
17
17
  - `anentrypoint-design` (>=0.0.119) — kit library, single-file ESM from unpkg
18
18
 
19
- ## Browser Witness (2026-05-19)
19
+ ## Browser Witness
20
20
 
21
- Local server on PORT=3056 (default), `bun server.js`:
22
- - `GET /health` → 200 JSON
23
- - `GET /v1/history/sessions` → `{"sessions":[]}` from ccsniff
24
- - `GET /` → site/app/index.html
25
- - WS `/sync` → opens, sync_connected
26
- - Browser at `localhost:3056/`: AppShell renders, nav=[chat,history,settings], SSE `hello` received (live.connected=true, eventCount=1), 0 console errors, backend resolves to `''` (same origin).
21
+ `bun server.js`. Default `PORT=3000` (server.js); the SPA is served under `BASE_URL` (default `/gm/`), so the live app is **http://localhost:3000/gm/** — `/health` and `/` answer at root, the app is under `/gm/`. First request to `/gm/` or `/v1/history/*` triggers a 30-90s ccsniff JSONL walk (curl with a short timeout returns 000 during warmup). AppShell renders nav=[chat,history,settings], SSE `hello`, 0 console errors, backend resolves to `''` (same origin).
27
22
 
28
23
  ## Learning audit
29
24
 
@@ -139,3 +134,13 @@ Throttle renders via `requestAnimationFrame` to avoid event storm during burst l
139
134
  **First request to `/v1/history/*` triggers loadOnce() that walks all JSONL files under ~/.claude/projects** (env default; override with `CLAUDE_PROJECTS_DIR`). In our test env: 299 files, 80MB, 69k events → 30-90s startup latency. Health check timeouts during this window are normal and expected. Subsequent requests are fast (cached index).
140
135
 
141
136
  The endpoints are served by ccsniff's Express router mounted in-process from `server.js`. No external proxy.
137
+
138
+ ## Zero-runtime-CDN: vendored DS deps (2026-05-28)
139
+
140
+ The GUI runs fully offline. `site/app/vendor/cdn/` holds marked, dompurify, prismjs components, and JetBrains+Space Grotesk woff2. The DS bundle (`anentrypoint-design/247420.js`) had its CDN string constants rewritten to local paths, AND its gzip+base64-embedded CSS blob (`Ha`) regenerated to point at local fonts. Full mechanism is in rs-learn (recall "DS bundle gzip Ha vendoring"). Witness offline by browser route-abort of non-origin hosts.
141
+
142
+ ## Agent/model/session management (2026-05-28)
143
+
144
+ - `agents.list` (WS) returns `available` + `npxInstallable` per agent; `agents.models` returns model choices (claude-code → sonnet/opus/haiku). The chat picker is **agent-then-model**, not a flat model list. Unavailable agents are disabled/gated.
145
+ - `chat.sendMessage` accepts `cwd` (defaults to STARTUP_CWD) and `model`/`agentId` separately. `chat.active` (WS) lists in-flight chats with agentId/model/cwd/startedAt/pid; the history tab polls it (3s) and shows a running panel with per-session stop.
146
+ - Client (`app.js`): chat transcript persists to `localStorage[agentgui.chat]` and restores on load; tool_use/result events render as chat parts; keyboard shortcuts (g+c/h/s, n, /, ?); settings has an agents-status panel from `health.acp[]`.
@@ -25,6 +25,31 @@ export class AgentRegistry {
25
25
  }));
26
26
  }
27
27
 
28
+ isAvailable(agentId) {
29
+ if (!this._availCache) this._availCache = new Map();
30
+ if (this._availCache.has(agentId)) return this._availCache.get(agentId);
31
+ const a = this.agents.get(agentId);
32
+ if (!a) return false;
33
+ let ok = false;
34
+ try {
35
+ const whichCmd = isWindows ? 'where' : 'which';
36
+ const which = spawnSync(whichCmd, [a.command], { encoding: 'utf-8', timeout: 3000 });
37
+ if (which.status === 0 && (which.stdout || '').trim()) ok = true;
38
+ if (!ok && a.npxPackage) {
39
+ ok = ['bun', 'npx'].some(r => {
40
+ const c = spawnSync(whichCmd, [r], { encoding: 'utf-8', timeout: 3000 });
41
+ return c.status === 0 && (c.stdout || '').trim();
42
+ });
43
+ }
44
+ } catch { ok = false; }
45
+ this._availCache.set(agentId, ok);
46
+ return ok;
47
+ }
48
+
49
+ listWithAvailability() {
50
+ return this.list().map(a => ({ ...a, available: this.isAvailable(a.id), npxInstallable: !!a.npxPackage }));
51
+ }
52
+
28
53
  listACPAvailable() {
29
54
  return this.list().filter(agent => {
30
55
  try {
@@ -26,10 +26,27 @@ export function register(router, deps) {
26
26
  protocol: a.protocol,
27
27
  supportsStdin: !!a.supportsStdin,
28
28
  features: a.supportedFeatures || [],
29
+ available: registry.isAvailable(a.id),
30
+ npxInstallable: !!a.npxPackage,
29
31
  }));
30
32
  return { agents };
31
33
  });
32
34
 
35
+ // --- agents.models: model choices for a given agent ---
36
+ router.handle('agents.models', (p) => {
37
+ const id = p?.id || p?.agentId;
38
+ if (!id) err(400, 'agent id required');
39
+ if (id === 'claude-code') {
40
+ return { models: [
41
+ { id: 'sonnet', name: 'Claude Sonnet (latest)' },
42
+ { id: 'opus', name: 'Claude Opus (latest)' },
43
+ { id: 'haiku', name: 'Claude Haiku (latest)' },
44
+ ] };
45
+ }
46
+ // Other agents pick their model via their own config/login; none surfaced here.
47
+ return { models: [] };
48
+ });
49
+
33
50
  // --- conversation.subscribe: register this ws for sessionId broadcasts ---
34
51
  router.handle('conversation.subscribe', (p, ws) => {
35
52
  const sid = p?.sessionId;
@@ -61,7 +78,7 @@ export function register(router, deps) {
61
78
  ws.subscriptions = ws.subscriptions || new Set();
62
79
  ws.subscriptions.add(sessionId);
63
80
 
64
- const ctrl = { aborted: false, proc: null };
81
+ const ctrl = { aborted: false, proc: null, agentId, model, cwd, startedAt: Date.now() };
65
82
  activeChats.set(sessionId, ctrl);
66
83
 
67
84
  // Fire-and-forget. Errors broadcast as streaming_error.
@@ -104,6 +121,15 @@ export function register(router, deps) {
104
121
  return { sessionId, started: true };
105
122
  });
106
123
 
124
+ // --- chat.active: list in-flight chats started via this server ---
125
+ router.handle('chat.active', () => {
126
+ const sessions = [];
127
+ for (const [sid, c] of activeChats) {
128
+ sessions.push({ sessionId: sid, agentId: c.agentId || null, model: c.model || null, cwd: c.cwd || null, startedAt: c.startedAt || null, pid: c.proc?.pid || null });
129
+ }
130
+ return { sessions };
131
+ });
132
+
107
133
  // --- chat.cancel: abort an in-flight chat ---
108
134
  router.handle('chat.cancel', (p) => {
109
135
  const sid = p?.sessionId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.939",
3
+ "version": "1.0.941",
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
@@ -173,9 +173,18 @@ const onServerListenStart = () => {
173
173
  loadPluginExtensions();
174
174
  };
175
175
 
176
+ let _portRetries = 0;
177
+ const MAX_PORT_RETRIES = 5;
176
178
  server.on('error', (err) => {
177
179
  if (err.code === 'EADDRINUSE') {
178
- console.error(`Port ${PORT} already in use. Waiting 3 seconds before retry...`);
180
+ _portRetries++;
181
+ if (_portRetries > MAX_PORT_RETRIES) {
182
+ // Bail instead of retrying forever — an unbounded retry loop leaks a
183
+ // live process that holds no useful port and accumulates on each launch.
184
+ console.error(`Port ${PORT} still in use after ${MAX_PORT_RETRIES} retries; exiting. Free the port or set PORT to a different value.`);
185
+ process.exit(1);
186
+ }
187
+ console.error(`Port ${PORT} already in use. Retry ${_portRetries}/${MAX_PORT_RETRIES} in 3s...`);
179
188
  setTimeout(() => { server.listen(PORT, onServerListenStart); }, 3000);
180
189
  } else {
181
190
  console.error('[SERVER] Error (contained):', err.message);
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
- <html lang="en" class="ds-247420" data-theme="dark">
2
+ <html lang="en" class="ds-247420" data-theme="dark" data-typescale="app">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1">
@@ -90,32 +90,17 @@
90
90
 
91
91
  .field-error { color: var(--warn, var(--agentgui-warn)); }
92
92
 
93
- /* chat control cluster in the crumb bar: keep model picker, +new, status
94
- on one tidy baseline-aligned row instead of wrapping under the nav. */
95
- .chat-controls { display: flex; align-items: center; gap: .6em; flex-wrap: nowrap; }
93
+ /* chat control cluster in the crumb bar: model picker, +new, status.
94
+ Allowed to wrap so it never overflows the crumb on tablet widths. */
95
+ .chat-controls { display: flex; align-items: center; gap: .6em; flex-wrap: wrap; }
96
96
  .chat-controls > * { flex: 0 0 auto; }
97
97
  .chat-controls select,
98
98
  .chat-controls .select,
99
- .chat-controls [role="combobox"] { min-width: 150px; max-width: 220px; }
99
+ .chat-controls [role="combobox"] { min-width: 130px; max-width: 220px; }
100
100
  .chat-controls .status-dot { white-space: nowrap; }
101
101
 
102
- /* Tame the design-system hero-sized PageHeader h1 to a sensible page title.
103
- The DS default (--fs-h1, cqi-scaled to ~64-80px) overpowers app content. */
104
- .agentgui-main .ds-section > h1 {
105
- font-size: clamp(22px, 2.2vw, 30px);
106
- line-height: 1.15;
107
- margin-bottom: .35em;
108
- }
109
102
  .agentgui-main .ds-section { margin: 0 0 var(--space-4, 16px); }
110
103
 
111
- /* TextField: stack label above the input so the label can't overlap it. */
112
- .agentgui-main .ds-field {
113
- display: flex; flex-direction: column; gap: .35em; align-items: stretch;
114
- }
115
- .agentgui-main .ds-field-label { font-size: .8rem; color: var(--fg-2, #ccc); }
116
- .agentgui-main .ds-field input,
117
- .agentgui-main .ds-field textarea { width: 100%; }
118
-
119
104
  /* readable backend health summary (replaces raw JSON dump) */
120
105
  .health-summary { display: flex; flex-wrap: wrap; gap: .4em; margin: .6em 0; }
121
106
  .health-chip {
@@ -130,20 +115,8 @@
130
115
  border-color: color-mix(in srgb, var(--accent, var(--agentgui-accent)) 40%, transparent);
131
116
  }
132
117
 
133
- /* search input: match the dark theme instead of a bare white box */
134
- .app input[type="search"],
135
- .app .search-input input,
136
- .app input.search,
137
- input[type="search"] {
138
- background: color-mix(in srgb, var(--fg, var(--agentgui-fg)) 6%, transparent);
139
- color: var(--fg, var(--agentgui-fg));
140
- border: 1px solid color-mix(in srgb, var(--fg, var(--agentgui-fg)) 16%, transparent);
141
- border-radius: 8px; padding: .5em .7em;
142
- }
143
- .app input[type="search"]::placeholder { color: var(--fg-3, #888); }
144
- .app input[type="search"]:focus-visible {
145
- outline: 2px solid var(--accent, var(--agentgui-accent)); outline-offset: 1px;
146
- }
118
+ /* (search-input theming now provided by the design system's .ds-search-input
119
+ + base input rules; the local reskin hack was removed.) */
147
120
 
148
121
  /* empty-state: keep it from wrapping awkwardly in the narrow sidebar */
149
122
  .empty-state { white-space: normal; }
@@ -161,9 +134,13 @@
161
134
  }
162
135
 
163
136
  @media print {
164
- #app { min-height: auto; display: block; }
165
- .skip-link, .status-dot, .history-actions { display: none !important; }
166
- * { background: #fff !important; color: #000 !important; box-shadow: none !important; }
137
+ #app { min-height: auto; display: block; height: auto; }
138
+ .skip-link, .status-dot, .history-actions, .chat-composer { display: none !important; }
139
+ /* Drop chrome backgrounds/shadows for ink-saving, but preserve code
140
+ highlighting and rail colors (don't nuke every color to black). */
141
+ .app, .app-main, .panel, .chat, .chat-thread {
142
+ background: #fff !important; color: #000 !important; box-shadow: none !important;
143
+ }
167
144
  }
168
145
  </style>
169
146
  </head>