@chatpanel/bridge 0.11.16 → 0.11.17

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.16",
3
+ "version": "0.11.17",
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": [
@@ -39,6 +39,11 @@ const REASONING = process.env.CHATPANEL_CODEX_EFFORT ?? 'low'; // '' → respect
39
39
  // straight from that file, plus a few common ids. The picker still accepts any
40
40
  // free-text value, so an out-of-date curated entry is harmless.
41
41
  const CODEX_KNOWN = ['gpt-5-codex', 'gpt-5', 'o3', 'o4-mini'];
42
+ // Set once Codex has reported that its managed requirements forbid approval_policy=never;
43
+ // cleared only by a bridge restart, which is when a policy could plausibly have changed.
44
+ let approvalPolicyBlocked = false;
45
+ export function resetApprovalPolicy() { approvalPolicyBlocked = false; }
46
+
42
47
  export async function listModels() {
43
48
  const set = new Set();
44
49
  try {
@@ -234,7 +239,7 @@ function runCodex({ args, cwd, env, prompt, outFile, emit, signal }) {
234
239
  /* no message file */
235
240
  }
236
241
  unlink(outFile).catch(() => {});
237
- resolve({ code, stderr, text, streamed });
242
+ resolve({ code, stderr, text, streamed, policyBlocked: !!evState.policyBlocked });
238
243
  });
239
244
 
240
245
  child.stdin.write(prompt);
@@ -265,7 +270,11 @@ export async function chat({ messages, system, options, images }, emit, { signal
265
270
  args.push('--dangerously-bypass-approvals-and-sandbox');
266
271
  } else {
267
272
  const sandbox = options.permissionMode === 'acceptEdits' ? 'workspace-write' : 'read-only';
268
- args.push('-s', sandbox, '-c', 'approval_policy=never');
273
+ args.push('-s', sandbox);
274
+ // `never` is what a headless run needs — but an organisation can pin approval_policy
275
+ // through Codex's managed requirements, and then every turn opened with a paragraph
276
+ // of warning and fell back to OnRequest anyway. Once Codex has said so, stop asking.
277
+ if (!approvalPolicyBlocked) args.push('-c', 'approval_policy=never');
269
278
  }
270
279
  if (REASONING) args.push('-c', `model_reasoning_effort=${REASONING}`);
271
280
  // Ask Codex to emit reasoning SUMMARIES so the panel can stream the model's thinking.
@@ -303,6 +312,7 @@ export async function chat({ messages, system, options, images }, emit, { signal
303
312
 
304
313
  try {
305
314
  let result = await attempt();
315
+ if (result.policyBlocked) approvalPolicyBlocked = true;
306
316
 
307
317
  // The failure this exists for: one of the user's OWN MCP servers could not authenticate
308
318
  // or could not be reached, and took a turn with it that never needed that server. Drop it
@@ -418,8 +428,19 @@ export function forwardEvent(ev, emit, state = { started: new Set(), reasoned: n
418
428
  }
419
429
 
420
430
  if (itype === 'error' || t === 'error') {
421
- const msg = item.message || ev.message || '';
422
- if (msg) emit({ type: 'status', text: `Codex: ${String(msg).slice(0, 300)}` });
431
+ const msg = String(item.message || ev.message || '');
432
+ if (!msg) return;
433
+ // The managed-requirements warning: long, per turn, and about a flag WE pass. Say it
434
+ // once in a sentence, and remember (see buildArgs) so the next turn does not earn it.
435
+ if (/approval_policy.*(disallowed|not in the allowed set)/i.test(msg)) {
436
+ state.policyBlocked = true;
437
+ if (!state.policyNoted) {
438
+ state.policyNoted = true;
439
+ emit({ type: 'status', text: 'Codex: your organisation pins approval_policy, so Codex will ask before actions it cannot run on its own. ChatPanel will stop passing its own setting.' });
440
+ }
441
+ return;
442
+ }
443
+ emit({ type: 'status', text: `Codex: ${msg.slice(0, 300)}` });
423
444
  return;
424
445
  }
425
446
 
package/src/server.js CHANGED
@@ -67,7 +67,7 @@ import {
67
67
  // Hardcoded (not read from package.json) so it survives Bun's single-file
68
68
  // --compile, where package.json isn't on a readable FS. CI fails the publish if
69
69
  // this drifts from package.json, so the two can't silently diverge.
70
- const VERSION = '0.11.16';
70
+ const VERSION = '0.11.17';
71
71
  const HOST = process.env.CHATPANEL_BRIDGE_HOST || '127.0.0.1';
72
72
  const PORT = Number(process.env.CHATPANEL_BRIDGE_PORT) || 4319;
73
73