@chatpanel/bridge 0.11.23 → 0.11.24

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/bridge",
3
- "version": "0.11.23",
3
+ "version": "0.11.24",
4
4
  "type": "module",
5
5
  "description": "Local bridge that exposes the AI coding agents installed on your machine — Claude Code (CLI), Codex (CLI), and Antigravity CLI (formerly Gemini CLI, which remains available for business/enterprise) — to the ChatPanel Chrome extension over a localhost SSE endpoint. Bring your own agent.",
6
6
  "keywords": [
@@ -244,7 +244,7 @@ function runCodex({ args, cwd, env, prompt, outFile, emit, signal }) {
244
244
  /* no message file */
245
245
  }
246
246
  unlink(outFile).catch(() => {});
247
- resolve({ code, stderr, text, streamed, policyBlocked: !!evState.policyBlocked });
247
+ resolve({ code, stderr, text, streamed, said: !!evState.saidAny, policyBlocked: !!evState.policyBlocked });
248
248
  });
249
249
 
250
250
  child.stdin.write(prompt);
@@ -334,7 +334,8 @@ export async function chat({ messages, system, options, images }, emit, { signal
334
334
 
335
335
  if (signal?.aborted) return; // Stop pressed — end quietly, no error
336
336
  if (result.code !== 0) throw new Error(summarizeCliError('Codex', result.code, result.stderr, '', { agentId: 'codex' }));
337
- emit({ type: 'delta', text: result.text || '(no output)' });
337
+ // Said already, message by message (forwardEvent); the file is the fallback, not a repeat.
338
+ if (!result.said) emit({ type: 'delta', text: result.text || '(no output)' });
338
339
  emit({ type: 'done', text: '' });
339
340
  } finally {
340
341
  cleanupImages();
@@ -348,7 +349,7 @@ export async function chat({ messages, system, options, images }, emit, { signal
348
349
  // command_execution: { id, command, aggregated_output, exit_code, status }
349
350
  // reasoning: { id, text } (only some models/efforts emit it)
350
351
  // file_change: { id, changes:[{path}] }
351
- // agent_message: { id, text } (the answer — read from -o outFile at close)
352
+ // agent_message: { id, text } (the answer, a delta per message; -o outFile is the fallback)
352
353
  // web_search: { id, query, action:{ type, query?, url? } } (codex-cli 0.154)
353
354
  // mcp_tool_call: { id, server, tool, arguments, result?, error?, status }
354
355
  // todo_list: { id, items:[{ text, completed }] }
@@ -358,6 +359,23 @@ export function forwardEvent(ev, emit, state = { started: new Set(), reasoned: n
358
359
  const itype = item.type || '';
359
360
  const completed = t === 'item.completed' || item.status === 'completed' || item.status === 'failed';
360
361
 
362
+ // THE ANSWER, AS IT IS WRITTEN. `codex exec --json` streams no tokens: each agent_message
363
+ // arrives whole, and a turn that thinks, runs a command and then concludes writes TWO of
364
+ // them. Reading only `-o outFile` at close kept the LAST one and showed it once the process
365
+ // had exited — the first sentence was lost and the panel sat blank for the whole run. Each
366
+ // message is a delta the moment it completes; the close reads the file only when nothing
367
+ // was said this way (an older codex, or a run that ended before its message).
368
+ if (itype === 'agent_message' && completed) {
369
+ const id = item.id || `msg_${state.n++}`;
370
+ const text = String(item.text || '');
371
+ if (text && !state.said?.has(id)) {
372
+ (state.said ||= new Set()).add(id);
373
+ emit({ type: 'delta', text: `${state.saidAny ? '\n\n' : ''}${text}` });
374
+ state.saidAny = true;
375
+ }
376
+ return;
377
+ }
378
+
361
379
  if (itype === 'command_execution' || (!itype && t.includes('command'))) {
362
380
  const id = item.id || `cmd_${state.n++}`;
363
381
  if (!state.started.has(id)) {
package/src/server.js CHANGED
@@ -79,7 +79,7 @@ import {
79
79
  // Hardcoded (not read from package.json) so it survives Bun's single-file
80
80
  // --compile, where package.json isn't on a readable FS. CI fails the publish if
81
81
  // this drifts from package.json, so the two can't silently diverge.
82
- const VERSION = '0.11.23';
82
+ const VERSION = '0.11.24';
83
83
  const HOST = process.env.CHATPANEL_BRIDGE_HOST || '127.0.0.1';
84
84
  const PORT = Number(process.env.CHATPANEL_BRIDGE_PORT) || 4319;
85
85