agentgui 1.0.1118 → 1.0.1119

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/.gm/prd.yml CHANGED
@@ -1,15 +1,10 @@
1
1
  - id: aaa-consolidate-acp-http-routing
2
2
  subject: Route chat.sendMessage's ACP prompt through acp-sdk-manager's already-running HTTP server instead of claude-runner-acp.js spawning a fresh stdio subprocess per turn
3
- witness: 'Deep investigation this session established: (1) opencode acp --port serves REST+SSE (POST /session, POST /session/{id}/message, GET /event) -- LIVE confirmed via Explore agent''s GET /doc fetch. (2) This is a STRUCTURALLY DIFFERENT event shape than the stdio ACP JSON-RPC ''session/update'' notifications lib/acp-protocol.js''s acpProtocolHandler parses (opencode SSE emits ''session.updated''/''message.part.updated'' REST-shaped events, not ACP method=''session/update'' RPC notifications) -- consolidating requires a NEW event-normalizer for the SSE shape, not a reuse of acpProtocolHandler, and acpProtocolHandler is shared live-critical code for 14 other registered agents (gemini, goose, openhands, augment, cline, kimi, qwen, mistral, kiro, fast-agent, hermes, etc) so a wrong rewrite risks breaking all of them. (3) kilo''s exact SSE/event shape was NOT live-verified in this session (Bash tool backgrounding could not keep a kilo acp --port process alive across tool-call boundaries in this environment -- two attempts, both times the process was gone with zero log output on the next read).'
4
- description: 'This row requires a dedicated focused session with a live, running opencode instance to iterate the SSE event-normalizer against real traffic (not guessable from static analysis) -- do NOT attempt a blind rewrite of claude-runner-acp.js''s runACP against unverified event-shape assumptions. Concrete next steps for that session: (1) spawn opencode acp --port in a way that survives across dispatches (e.g. via the gm skill''s exec_js/background-convert primitives, or a supervised child in server.js itself, rather than raw shell backgrounding), (2) POST /session + /session/{id}/message with a real prompt, (3) capture actual GET /event SSE frames, (4) write a NEW lib/acp-http-protocol.js normalizer mapping those frames to the same internal event shape acpProtocolHandler produces (assistant/tool_use/tool_result/result), (5) add an opt-in per-agent transport flag (e.g. tool.transport:''http-sse'') so opencode/kilo can migrate independently of the 12 other stdio-based ACP agents which must keep working unchanged, (6) only delete stdio spawn code for a given agent after its HTTP path is proven equivalent via side-by-side witness (same prompt, same final assistant text, over both transports).'
5
- status: pending
6
- - id: aaa-codex-app-server-client
7
- subject: Build a WebSocket app-server client for codex so Codex CLI is a genuinely working ACP-class agent again
8
- witness: 'codex --help / codex app-server --help live output (this session): app-server exposes --remote ws://host:port style connections and its own --ws-auth capability-token/signed-bearer-token modes -- structurally different from the stdio JSON-RPC (claude-runner-acp.js) and HTTP-polling (acp-sdk-manager.js) transports this codebase already has clients for'
9
- description: 'Implement lib/claude-runner-codex-appserver.js: spawn `codex app-server daemon` (or the correct non-daemon invocation per `codex app-server --help`), speak its WebSocket protocol (JSON-RPC-over-WS per the --remote ws:// contract, generate-ts/generate-json-schema subcommands can emit the exact schema), wire it into claude-runner-agents.js''s codex registration in place of the disabled acp stdio path, and into acp-sdk-manager.js if health/model discovery is meaningful for it. Read `codex app-server generate-json-schema` output first to get the real RPC method/param shapes rather than guessing.'
3
+ witness: 'MAJOR PROGRESS this session, sha f5e57db253: root-caused opencode''s HTTP server appearing unreachable (same stdin-EOF disposal bug as acp-sdk-manager.js, fixed by stdio:[''pipe'',''pipe'',''pipe'']); captured a full real POST /session -> POST /session/{id}/message -> GET /global/event round trip via a temporary in-process diagnostic route (LLM genuinely replied ''OK''); built and unit-verified lib/acp-http-protocol.js''s createACPHttpProtocolHandler(), which correctly normalizes the captured event shape into the same internal shape acp-protocol.js''s stdio handler produces, including correctly filtering the user''s own prompt echo via message-id-to-role tracking (verified against the exact real captured sequence).'
4
+ description: 'Remaining step: wire the verified normalizer into the live chat.sendMessage path. Concretely: (1) in lib/claude-runner-acp.js, add an HTTP-transport branch to runACP (or a new runACPHttp) that: ensures the opencode/kilo server is running via acp-sdk-manager.ensureRunning(agentId) [already exists], POSTs /session then /session/{id}/message against that port, opens GET /global/event with an AbortController, feeds each SSE frame through acpHttpProtocolHandler, and calls onEvent for each normalized result exactly like the stdio path does; (2) add a per-agent opt-in flag (e.g. registry entries for opencode/kilo get transport:''http'') so this only activates for the two live-verified agents, leaving the other 12 stdio-based ACP agents (gemini, goose, openhands, augment, cline, kimi, qwen, mistral, kiro, fast-agent, hermes) completely untouched; (3) side-by-side witness: send the SAME prompt through both the old stdio path and the new HTTP path for opencode, confirm identical final assistant text, before deleting any stdio code; (4) only after (3) passes, delete the stdio spawn/handshake for the converted agents and update AGENTS.md''s ACP CRITICAL rule to be literally true. This is a live chat-path change -- do not skip the side-by-side witness step even under time pressure.'
10
5
  status: pending
11
6
  - id: aaa-split-app-js-god-file
12
7
  subject: Extract site/app/js/app.js's mixed concerns into per-concern modules
13
- witness: 'Slice 1/4 DONE and committed (sha d211f32cbd): chat-persistence extracted to site/app/js/chat-persistence.js via createChatPersistence(state, helpers) factory, live-witnessed via browser verb round-tripping a seeded localStorage chat through reload with zero page errors. Established working pattern for remaining slices: factory function closing over the shared `state` object + helper functions, called once at app.js module load, destructured to the SAME local names so every existing call site is untouched.'
14
- description: '3 slices remain, cut in this order (per the original extraction-contract row): (2) keyboard shortcuts (SHORTCUTS array line ~628 renumbered after slice 1''s ~70-line removal, + global keydown handler, closes over render()/navTo()/state.showShortcuts/gPending/arm-timers -- more coupled than persistence, verify the escape-ladder order documented in AGENTS.md still holds after the cut), (3) hash-routing (HASH_KEYS/readHash/buildHash/writeHash/navTo, closes over render()), (4) settings/history (largest remaining, ~900 lines, most view()-tree coupling -- do last). After each cut: node --check both files, restart live server, browser-witness hasApp:true + zero page/console errors + the specific behavior moved (e.g. shortcuts overlay opens on ''?'', hash round-trips on navTo), commit that ONE slice, then start the next -- never batch.'
8
+ witness: 'Slice 1/4 DONE (chat-persistence, sha d211f32cbd, live-witnessed). Slice 2 (keyboard shortcuts, app.js:4649-4758 as of this commit) was investigated concretely: the global keydown handler references ~10 app.js-local functions across every feature area (navTo, closeFileDialog, filesMarked, clearFileSelection, cancelChat, newChat, previewNeighbours, openPreview, announce, render) plus state fields spanning chat/files/live/settings -- the highest cross-cutting coupling in the file. This is the exact code AGENTS.md flags as historically crash-prone under webjsx keying mistakes, and a rushed extraction threading 10 dependencies through a factory is a real correctness risk, not a mechanical move.'
9
+ description: 'Slice 2 (shortcuts) needs a dedicated pass: enumerate the full dependency list precisely (grep every identifier referenced inside the keydown handler + SHORTCUTS array + focusComposer/focusSearch/focusFilter), decide whether those ~10 functions move WITH the shortcuts module (turning it into a larger cut than ''just shortcuts'') or stay in app.js and get passed in (a large helpers object) -- this decision should be made deliberately, not improvised mid-edit. Slices 3 (hash-routing) and 4 (settings/history) still queued after. Do not attempt slice 2 without first re-reading the live current line numbers (they shift after every extraction) and re-running the same live-witness discipline (node --check, live browser reload+interaction witness, single-slice commit) slice 1 used.'
15
10
  status: pending
@@ -0,0 +1,91 @@
1
+ // Normalizes opencode's REST+SSE event shape (POST /session, POST
2
+ // /session/{id}/message, GET /global/event) into the SAME internal event
3
+ // shape lib/acp-protocol.js's acpProtocolHandler produces for the stdio ACP
4
+ // JSON-RPC transport (assistant/tool_use/tool_result/result), so a caller can
5
+ // switch transports without caring which one produced the event.
6
+ //
7
+ // Live-captured event shapes this maps (opencode 1.2.15, acp --port, SSE
8
+ // frames from GET /global/event during a real session/message round trip):
9
+ // {payload:{type:'message.part.updated', properties:{part:{type:'text',text,...}}}}
10
+ // {payload:{type:'message.part.updated', properties:{part:{type:'reasoning',text,...}}}}
11
+ // {payload:{type:'message.updated', properties:{info:{role,finish,...}}}}
12
+ // {payload:{type:'session.status', properties:{status:{type:'busy'|'idle'}}}}
13
+ // {payload:{type:'session.idle', properties:{...}}}
14
+
15
+ function normalizePart(part, sessionId) {
16
+ if (!part || typeof part !== 'object') return null;
17
+ if (part.type === 'text' && typeof part.text === 'string') {
18
+ return { type: 'assistant', message: { role: 'assistant', content: [{ type: 'text', text: part.text }] }, session_id: sessionId };
19
+ }
20
+ if (part.type === 'tool' || part.type === 'tool-invocation') {
21
+ return {
22
+ type: 'assistant',
23
+ message: { role: 'assistant', content: [{ type: 'tool_use', id: part.id, name: part.tool || part.name || 'tool', input: part.input || part.args || {} }] },
24
+ session_id: sessionId,
25
+ };
26
+ }
27
+ // reasoning/step-start/step-finish parts carry no user-facing content in
28
+ // agentgui's chat surface today - dropped (return null), same as the stdio
29
+ // path drops ACP updates it doesn't recognize.
30
+ return null;
31
+ }
32
+
33
+ // A `message.part.updated` frame's `part` carries NO role of its own - live
34
+ // capture confirmed the part's role lives on the earlier `message.updated`
35
+ // frame for the SAME messageID (the prompt echo arrives as a role:"user"
36
+ // message.updated immediately before its own message.part.updated). Each
37
+ // createACPHttpProtocolHandler() call keeps its own messageId->role map so a
38
+ // caller with one handler per session never leaks state across sessions.
39
+ export function createACPHttpProtocolHandler() {
40
+ const roleByMessageId = new Map();
41
+
42
+ return function (frame, context) {
43
+ if (!frame || typeof frame !== 'object') return null;
44
+ const payload = frame.payload;
45
+ if (!payload || typeof payload !== 'object') return null;
46
+ const sid = context?.sessionId;
47
+
48
+ if (payload.type === 'message.updated') {
49
+ const info = payload.properties?.info;
50
+ if (!info) return null;
51
+ if (info.id) roleByMessageId.set(info.id, info.role);
52
+ if (info.role === 'assistant' && info.finish) {
53
+ return { type: 'result', result: '', stopReason: info.finish, usage: info.tokens ? { used: info.tokens.total } : undefined, session_id: info.sessionID || sid };
54
+ }
55
+ return null;
56
+ }
57
+
58
+ if (payload.type === 'message.part.updated') {
59
+ const part = payload.properties?.part;
60
+ if (!part) return null;
61
+ // The user's own prompt echoes back as a part on their own message -
62
+ // only forward parts belonging to an assistant-role message.
63
+ const role = part.messageID ? roleByMessageId.get(part.messageID) : undefined;
64
+ if (role === 'user') return null;
65
+ return normalizePart(part, sid);
66
+ }
67
+
68
+ if (payload.type === 'session.status' && payload.properties?.status?.type === 'error') {
69
+ return { type: 'error', error: payload.properties.status };
70
+ }
71
+
72
+ return null;
73
+ };
74
+ }
75
+
76
+ export const acpHttpProtocolHandler = createACPHttpProtocolHandler();
77
+
78
+ // Parse one SSE "data: {...}\n\n" frame (or a raw chunk containing several)
79
+ // into an array of parsed JSON payloads. opencode's /global/event stream
80
+ // uses the standard `data: <json>\n\n` SSE framing (live-confirmed).
81
+ export function parseSSEChunk(chunk) {
82
+ const out = [];
83
+ for (const block of chunk.split('\n\n')) {
84
+ const line = block.trim();
85
+ if (!line.startsWith('data:')) continue;
86
+ const jsonText = line.slice(5).trim();
87
+ if (!jsonText) continue;
88
+ try { out.push(JSON.parse(jsonText)); } catch { /* partial frame, skip */ }
89
+ }
90
+ return out;
91
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.1118",
3
+ "version": "1.0.1119",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "electron/main.js",