@1agh/maude 2.2.0 → 2.3.1

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 (79) hide show
  1. package/apps/studio/acp/agents/auth.ts +241 -0
  2. package/apps/studio/acp/agents/catalog.ts +308 -0
  3. package/apps/studio/acp/agents/chat-key.ts +64 -0
  4. package/apps/studio/acp/agents/conformance.ts +1853 -0
  5. package/apps/studio/acp/agents/consent.ts +92 -0
  6. package/apps/studio/acp/agents/descriptor.ts +188 -0
  7. package/apps/studio/acp/agents/discover.ts +491 -0
  8. package/apps/studio/acp/agents/e2e-model.ts +58 -0
  9. package/apps/studio/acp/agents/health.ts +46 -0
  10. package/apps/studio/acp/agents/link-scan.ts +230 -0
  11. package/apps/studio/acp/agents/spawn.ts +164 -0
  12. package/apps/studio/acp/agents/state.ts +132 -0
  13. package/apps/studio/acp/ask-queue.ts +13 -4
  14. package/apps/studio/acp/bootstrap-brief.ts +16 -3
  15. package/apps/studio/acp/bridge.ts +709 -99
  16. package/apps/studio/acp/env.ts +43 -1
  17. package/apps/studio/acp/index.ts +428 -43
  18. package/apps/studio/acp/may-scope.ts +244 -21
  19. package/apps/studio/acp/policy/agent-home.ts +202 -0
  20. package/apps/studio/acp/policy/bridge-gate.ts +68 -0
  21. package/apps/studio/acp/policy/codex-home.ts +228 -0
  22. package/apps/studio/acp/policy/enforce.ts +620 -0
  23. package/apps/studio/acp/policy/gate-types.ts +41 -0
  24. package/apps/studio/acp/policy/launch-codex.ts +351 -0
  25. package/apps/studio/acp/policy/launch-copilot.ts +119 -0
  26. package/apps/studio/acp/policy/launch-gemini.ts +120 -0
  27. package/apps/studio/acp/policy/launch-opencode.ts +131 -0
  28. package/apps/studio/acp/policy/opencode-user-config.ts +240 -0
  29. package/apps/studio/acp/probe.ts +78 -14
  30. package/apps/studio/acp/transcript.ts +14 -0
  31. package/apps/studio/acp/write-scope.ts +62 -2
  32. package/apps/studio/canvas-pages-view.tsx +3 -2
  33. package/apps/studio/canvas-theme-pill.tsx +125 -72
  34. package/apps/studio/client/panels/ChatPanel.jsx +19 -4
  35. package/apps/studio/client/panels/PermissionPrompt.jsx +11 -6
  36. package/apps/studio/client/panels/acp-runtime.js +95 -7
  37. package/apps/studio/client/v2/ai/Advanced.jsx +4 -3
  38. package/apps/studio/client/v2/ai/AgentNotice.jsx +138 -0
  39. package/apps/studio/client/v2/ai/AgentOffer.jsx +110 -0
  40. package/apps/studio/client/v2/ai/AgentPicker.jsx +121 -0
  41. package/apps/studio/client/v2/ai/Composer.jsx +4 -0
  42. package/apps/studio/client/v2/ai/ConnectSheet.jsx +13 -0
  43. package/apps/studio/client/v2/ai/Feed.jsx +8 -0
  44. package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +24 -1
  45. package/apps/studio/client/v2/ai/Suggest.jsx +5 -1
  46. package/apps/studio/client/v2/ai/advanced-model.js +17 -6
  47. package/apps/studio/client/v2/ai/agents-model.js +333 -0
  48. package/apps/studio/client/v2/ai/agents-store.js +223 -0
  49. package/apps/studio/client/v2/ai/ai.css +63 -0
  50. package/apps/studio/client/v2/ai/needs-you.js +1 -1
  51. package/apps/studio/client/v2/fold/fold-store.js +1 -0
  52. package/apps/studio/client/v2/left-panel/left-panel.css +8 -0
  53. package/apps/studio/client/v2/settings/agent-keys.js +88 -0
  54. package/apps/studio/client/v2/settings/agents-card.jsx +408 -0
  55. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  56. package/apps/studio/client/v2/settings/connections-section.jsx +4 -0
  57. package/apps/studio/client/v2/settings/settings-cards.js +2 -1
  58. package/apps/studio/client/v2/settings/settings-model.js +1 -0
  59. package/apps/studio/client/v2/settings/settings.css +7 -0
  60. package/apps/studio/client/v2/shell/served-routes.js +1 -0
  61. package/apps/studio/cloud-build.ts +5 -0
  62. package/apps/studio/dist/client.bundle.js +604 -604
  63. package/apps/studio/dist/styles.css +1 -1
  64. package/apps/studio/ds/board/board.css +4 -78
  65. package/apps/studio/ds/board/ds-bar.tsx +15 -9
  66. package/apps/studio/generation/keys.ts +197 -11
  67. package/apps/studio/outbox/policy.ts +8 -2
  68. package/apps/studio/outbox/types.ts +5 -0
  69. package/apps/studio/routes/agents.ts +479 -0
  70. package/apps/studio/routes/index.ts +3 -0
  71. package/apps/studio/scripts/acp-conformance-local.ts +95 -0
  72. package/apps/studio/scripts/acp-e2e-local.ts +1026 -0
  73. package/apps/studio/server.ts +9 -0
  74. package/apps/studio/sync/writer-registry.ts +12 -0
  75. package/apps/studio/whats-new.json +19 -0
  76. package/apps/studio/ws.ts +3 -0
  77. package/cli/commands/codex.mjs +36 -2
  78. package/cli/lib/harness/codex-runtime.mjs +98 -11
  79. package/package.json +9 -8
@@ -448,82 +448,9 @@
448
448
  }
449
449
 
450
450
  /* ─── The bar (Maude's chrome over the user's design — the HUD island tokens, never the DS and never CSS
451
- system colours, so it follows the APP theme: 13 `.island.ds-bar`) ─── */
452
- .ds-bar {
453
- position: fixed;
454
- left: 50%;
455
- top: 16px;
456
- translate: -50% 0;
457
- z-index: 2147483000;
458
- display: flex;
459
- align-items: center;
460
- gap: 8px;
461
- height: 44px;
462
- padding: 0 8px 0 12px;
463
- border-radius: var(--maude-hud-radius-lg, 14px);
464
- background: var(--maude-hud-island-bg);
465
- color: var(--maude-chrome-fg-0);
466
- -webkit-backdrop-filter: saturate(1.4) blur(18px);
467
- backdrop-filter: saturate(1.4) blur(18px);
468
- box-shadow:
469
- var(--maude-hud-island-shadow),
470
- inset 0 0 0 0.5px var(--maude-hud-island-edge);
471
- font: 400 var(--maude-hud-type-sm, 12px) / 1 var(--maude-chrome-font-body);
472
- white-space: nowrap;
473
- }
474
- .ds-bar-ic {
475
- display: grid;
476
- place-items: center;
477
- width: 24px;
478
- height: 24px;
479
- border-radius: var(--maude-hud-radius-xs, 4px);
480
- background: var(--maude-hud-accent-muted);
481
- color: var(--maude-hud-accent-text);
482
- }
483
- .ds-bar b {
484
- font-weight: 600;
485
- }
486
- .ds-bar-seg {
487
- display: inline-flex;
488
- margin: 0 0 0 8px;
489
- min-width: 0;
490
- border: 0;
491
- padding: 2px;
492
- border-radius: var(--maude-hud-radius-md, 10px);
493
- background: var(--maude-chrome-bg-3);
494
- }
495
- .ds-bar-b {
496
- appearance: none;
497
- border: 0;
498
- border-radius: calc(var(--maude-hud-radius-md, 10px) - 2px);
499
- padding: 4px 12px;
500
- background: transparent;
501
- color: var(--maude-chrome-fg-1);
502
- font: inherit;
503
- font-size: var(--maude-hud-type-xs, 11px);
504
- cursor: pointer;
505
- }
506
- .ds-bar-b[aria-pressed="true"] {
507
- background: var(--maude-chrome-bg-2);
508
- color: var(--maude-chrome-fg-0);
509
- box-shadow:
510
- var(--maude-hud-shadow-md),
511
- inset 0 0 0 1px var(--maude-hud-accent);
512
- }
513
- .ds-bar-b--ic {
514
- display: grid;
515
- place-items: center;
516
- padding-inline: 7px;
517
- }
518
-
519
- .ds-bar-b:disabled {
520
- opacity: 0.4;
521
- cursor: default;
522
- }
523
- .ds-bar-b:focus-visible {
524
- outline: 2px solid var(--maude-hud-focus-ring);
525
- outline-offset: 1px;
526
- }
451
+ system colours, so it follows the APP theme: 13 `.island.ds-bar`). #225: the island itself, its glyph tile,
452
+ name and Light | Dark are the canvas pill's (`CanvasTopIsland`, canvas-theme-pill.tsx — placed in the shell's
453
+ free top band); only the bar's own extras are styled here. ─── */
527
454
  .ds-bar-p {
528
455
  display: inline-flex;
529
456
  align-items: center;
@@ -571,8 +498,7 @@
571
498
  }
572
499
 
573
500
  @media (prefers-reduced-motion: reduce) {
574
- .ds-board *,
575
- .ds-bar * {
501
+ .ds-board * {
576
502
  transition-duration: 1ms !important;
577
503
  animation-duration: 1ms !important;
578
504
  }
@@ -8,13 +8,15 @@
8
8
  // 13 `DsBar`: island · 24 px `system` glyph tile · name · `.seg` Light | Dark · Review… as the primary button.
9
9
  // 2.0.7 polish (decision `v2-207-pages-on-ds-canvas`): Canvas | Pages and, in Pages, ‹ n / N › after Light | Dark —
10
10
  // the switch every ordinary canvas has on its pill (canvas-pages-view.tsx), which this canvas does not draw.
11
+ // #225: the bar IS the canvas pill's island (`CanvasTopIsland`) with these controls on its row — the same place in the
12
+ // shell's free top band, the same chrome, the path line above; board.css no longer keeps a copy of the island.
11
13
 
12
14
  import type { ReactNode } from 'react';
13
15
  import { createPortal } from 'react-dom';
14
- import { DsIcon } from '../../canvas-ds-icons.tsx';
15
16
  import { CanvasPagesSwitch } from '../../canvas-pages-view.tsx';
16
17
  import { setCanvasTheme } from '../../canvas-theme.ts';
17
18
  import { THEME_WORD, ThemeIcon } from '../../canvas-theme-icons.tsx';
19
+ import { CanvasTopIsland, TopIslandTitle } from '../../canvas-theme-pill.tsx';
18
20
  import { isEmbedCanvas } from '../../read-only-mode.ts';
19
21
  import { useBoardMode, useBoardModel } from './state.ts';
20
22
  import type { BoardMode, BoardModel } from './types.ts';
@@ -45,17 +47,21 @@ export function DsBarView({
45
47
  const waiting = linked ? null : waitingWords(model.pendingCount);
46
48
  const hasDark = model.themes.dark !== null;
47
49
  return (
48
- <div className="ds-bar" data-testid="ds-bar" role="toolbar" aria-label="Design system">
49
- <span className="ds-bar-ic" aria-hidden="true">
50
- <DsIcon name="system" size={14} />
51
- </span>
52
- <b>{model.label}</b>
53
- <fieldset className="ds-bar-seg" aria-label="Show the system in">
50
+ // #225 — the same island as every canvas's pill (canvas-theme-pill.tsx): placed in the shell's free top band, the
51
+ // canvas's path on its own line above this row; never a second copy of the chrome
52
+ <CanvasTopIsland
53
+ testid="ds-bar"
54
+ ariaLabel="Design system"
55
+ rowTestid="ds-bar-row"
56
+ pathTestid="ds-bar-path"
57
+ >
58
+ <TopIslandTitle name={model.label} />
59
+ <fieldset className="dc-theme-pill-seg" aria-label="Show the system in">
54
60
  {(['light', 'dark'] as const).map((m) => (
55
61
  <button
56
62
  key={m}
57
63
  type="button"
58
- className="ds-bar-b ds-bar-b--ic k-seg-b"
64
+ className="dc-theme-pill-b dc-theme-pill-b--ic"
59
65
  data-testid={`ds-bar-mode-${m}`}
60
66
  aria-pressed={mode === m}
61
67
  aria-label={THEME_WORD[m]}
@@ -96,7 +102,7 @@ export function DsBarView({
96
102
  ) : null}
97
103
  </>
98
104
  ) : null}
99
- </div>
105
+ </CanvasTopIsland>
100
106
  );
101
107
  }
102
108
 
@@ -17,7 +17,16 @@
17
17
  // `{ configured: true }`, mirroring `github_is_signed_in`). `isConfigured` backs
18
18
  // the GET status probe — it reveals only presence, never the value.
19
19
 
20
- import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
20
+ import {
21
+ chmodSync,
22
+ existsSync,
23
+ mkdirSync,
24
+ readFileSync,
25
+ renameSync,
26
+ rmSync,
27
+ statSync,
28
+ writeFileSync,
29
+ } from 'node:fs';
21
30
  import { homedir, platform } from 'node:os';
22
31
  import { dirname, join } from 'node:path';
23
32
 
@@ -34,6 +43,19 @@ export function keysConfigPath(): string {
34
43
 
35
44
  interface KeysFile {
36
45
  keys: Record<string, string>;
46
+ /**
47
+ * B7 (DDR-252) — the LEGACY chat scope, before keys were per profile: one key per ACP agent id.
48
+ * Read as the `default` profile's only (security review 2026-11-12, M3); the first chat-key write
49
+ * moves it into `chatByProfile.default`.
50
+ */
51
+ chat?: Record<string, string>;
52
+ /** The chat scope per profile: profile id → agent id (`codex`, `gemini`, …) → key, never Claude's. */
53
+ chatByProfile?: Record<string, Record<string, string>>;
54
+ /**
55
+ * B7 — Claude's Anthropic key, per profile (DDR-252 amends DDR-123): present only after the
56
+ * person turned on "Use an Anthropic API key for Claude" for that profile. `optIn` must be true.
57
+ */
58
+ claudeApiKey?: Record<string, { key: string; optIn: true; at: number }>;
37
59
  }
38
60
 
39
61
  let _modeWarnedFor: string | null = null;
@@ -66,19 +88,23 @@ function readKeysFile(): KeysFile {
66
88
  }
67
89
  }
68
90
 
69
- /** Write keys.json atomically-ish with a hard 0600 mode (create + chmod). */
91
+ /**
92
+ * Write keys.json atomically with a hard 0600 mode: a 0600 temp file beside it, then rename (B7 —
93
+ * the file now holds chat keys too, so a torn write must never leave a half file or a wider mode).
94
+ */
70
95
  function writeKeysFile(data: KeysFile): void {
71
96
  const path = keysConfigPath();
72
97
  mkdirSync(dirname(path), { recursive: true });
73
- // Write then chmod — writeFileSync's mode is masked by umask, so we assert
74
- // 0600 explicitly afterwards (same guarantee cli/lib/hubs-config.mjs makes).
75
- writeFileSync(path, `${JSON.stringify(data, null, 2)}\n`, { mode: 0o600 });
76
- if (platform() !== 'win32') {
77
- try {
78
- chmodSync(path, 0o600);
79
- } catch {
80
- /* best-effort — the warn-on-read path is the backstop */
81
- }
98
+ const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
99
+ try {
100
+ // `wx`: never through a planted file. writeFileSync's mode is masked by umask, so chmod 0600
101
+ // explicitly before the rename (same guarantee cli/lib/hubs-config.mjs makes).
102
+ writeFileSync(tmp, `${JSON.stringify(data, null, 2)}\n`, { mode: 0o600, flag: 'wx' });
103
+ if (platform() !== 'win32') chmodSync(tmp, 0o600);
104
+ renameSync(tmp, path);
105
+ } catch (err) {
106
+ rmSync(tmp, { force: true });
107
+ throw err;
82
108
  }
83
109
  }
84
110
 
@@ -160,3 +186,163 @@ export function configuredProviders(): string[] {
160
186
  .filter(([, v]) => typeof v === 'string' && v.length > 0)
161
187
  .map(([id]) => id);
162
188
  }
189
+
190
+ // ---------------------------------------------------------------- chat scope (B7, DDR-252)
191
+ //
192
+ // One key per ACP agent, injected by acp/agents/chat-key.ts into THAT agent's env only (after the
193
+ // shared scrub, spawn.ts). Nothing here hands a key to a route: routes read `chatKeyStatus` —
194
+ // presence and the last four characters — and only the spawn path reads the value (`getChatKey`).
195
+
196
+ /** An agent id a chat key may be stored under: a catalog slug. `claude` has its own slot below. */
197
+ const CHAT_AGENT_ID_RE = /^[a-z][a-z0-9-]{0,31}$/;
198
+ /** sidecar::profile_env's id shape (profiles.rs); anything else is the default profile. */
199
+ const PROFILE_ID_RE = /^[a-z0-9-]{1,32}$/;
200
+
201
+ /** A key as typed: trimmed, non-empty, at most 512 characters, no whitespace or control chars. */
202
+ export function normalizeChatKey(value: unknown): string | null {
203
+ if (typeof value !== 'string') return null;
204
+ const key = value.trim();
205
+ if (key.length === 0 || key.length > 512) return null;
206
+ if (/[\s\p{Cc}]/u.test(key)) return null;
207
+ return key;
208
+ }
209
+
210
+ function chatAgentId(agentId: string): string {
211
+ if (agentId === 'claude' || !CHAT_AGENT_ID_RE.test(agentId)) throw new Error('invalid agent id');
212
+ return agentId;
213
+ }
214
+
215
+ /** The profile this server runs as — the server learns it only from env (`sidecar::profile_env`). */
216
+ export function currentProfileId(env: Record<string, string | undefined> = process.env): string {
217
+ const id = env.MAUDE_PROFILE_ID;
218
+ return id && PROFILE_ID_RE.test(id) ? id : 'default';
219
+ }
220
+
221
+ export interface ChatKeyStatus {
222
+ set: boolean;
223
+ /** The last four characters, only when set (Settings shows ••••last4). */
224
+ last4: string | null;
225
+ }
226
+
227
+ const statusOf = (key: string | null | undefined): ChatKeyStatus =>
228
+ typeof key === 'string' && key.length > 0
229
+ ? { set: true, last4: key.slice(-4) }
230
+ : { set: false, last4: null };
231
+
232
+ /**
233
+ * Security review 2026-11-12 (defender M3) — chat keys are per profile, like Claude's opt-in key:
234
+ * a work profile's chat never runs on the personal profile's key. The pre-profile `chat` map is the
235
+ * `default` profile's (the legacy install IS the default profile, profiles.rs) and no other's.
236
+ */
237
+ function chatKeysOf(file: KeysFile, profileId: string): Record<string, string> {
238
+ const legacy = profileId === 'default' ? (file.chat ?? {}) : {};
239
+ return { ...legacy, ...(file.chatByProfile?.[profileId] ?? {}) };
240
+ }
241
+
242
+ /** Move the legacy `chat` map into `chatByProfile.default` (before any chat-key write). */
243
+ function migrateLegacyChat(file: KeysFile): void {
244
+ if (!file.chat) return;
245
+ const byProfile = { ...(file.chatByProfile ?? {}) };
246
+ byProfile.default = { ...file.chat, ...(byProfile.default ?? {}) };
247
+ file.chatByProfile = byProfile;
248
+ delete file.chat;
249
+ }
250
+
251
+ /** Store an agent's chat key for this profile (Settings › AI agents). Throws on a bad id or key. */
252
+ export function setChatKey(
253
+ agentId: string,
254
+ value: unknown,
255
+ profileId: string = currentProfileId()
256
+ ): ChatKeyStatus {
257
+ const id = chatAgentId(agentId);
258
+ const key = normalizeChatKey(value);
259
+ if (!key) throw new Error('invalid key');
260
+ if (!PROFILE_ID_RE.test(profileId)) throw new Error('invalid profile');
261
+ const file = readKeysFile();
262
+ migrateLegacyChat(file);
263
+ file.chatByProfile = {
264
+ ...(file.chatByProfile ?? {}),
265
+ [profileId]: { ...(file.chatByProfile?.[profileId] ?? {}), [id]: key },
266
+ };
267
+ writeKeysFile(file);
268
+ return statusOf(key);
269
+ }
270
+
271
+ /** Remove this profile's chat key for an agent. No-op when absent. */
272
+ export function clearChatKey(agentId: string, profileId: string = currentProfileId()): void {
273
+ const id = chatAgentId(agentId);
274
+ const file = readKeysFile();
275
+ if (!(id in chatKeysOf(file, profileId))) return;
276
+ migrateLegacyChat(file);
277
+ const mine = file.chatByProfile?.[profileId];
278
+ if (mine && id in mine) delete mine[id];
279
+ writeKeysFile(file);
280
+ }
281
+
282
+ /** Presence + last four characters — never the key. Claude's reads this profile's opt-in slot. */
283
+ export function chatKeyStatus(agentId: string): ChatKeyStatus {
284
+ if (agentId === 'claude') return claudeApiKeyStatus();
285
+ if (!CHAT_AGENT_ID_RE.test(agentId)) return statusOf(null);
286
+ return statusOf(normalizeChatKey(chatKeysOf(readKeysFile(), currentProfileId())[agentId]));
287
+ }
288
+
289
+ export function hasChatKey(agentId: string): boolean {
290
+ return chatKeyStatus(agentId).set;
291
+ }
292
+
293
+ /**
294
+ * The key itself — for the spawn path ONLY (acp/agents/chat-key.ts), into the owning agent's env.
295
+ * Never returned by a route. Claude's answers only when this profile opted in.
296
+ */
297
+ export function getChatKey(agentId: string): string | null {
298
+ if (agentId === 'claude') return claudeApiKeyFor(currentProfileId());
299
+ if (!CHAT_AGENT_ID_RE.test(agentId)) return null;
300
+ return normalizeChatKey(chatKeysOf(readKeysFile(), currentProfileId())[agentId]);
301
+ }
302
+
303
+ /**
304
+ * Turn on "Use an Anthropic API key for Claude instead of your Claude account" for this profile
305
+ * (DDR-252 amends DDR-123). `optIn` must be literally `true`: the confirm card is the person's
306
+ * choice, and nothing stores a Claude key without it.
307
+ */
308
+ export function setClaudeApiKey(
309
+ value: unknown,
310
+ optIn: unknown,
311
+ profileId: string = currentProfileId()
312
+ ): ChatKeyStatus {
313
+ if (optIn !== true) throw new Error('opt-in required');
314
+ if (!PROFILE_ID_RE.test(profileId)) throw new Error('invalid profile');
315
+ const key = normalizeChatKey(value);
316
+ if (!key) throw new Error('invalid key');
317
+ const file = readKeysFile();
318
+ file.claudeApiKey = {
319
+ ...(file.claudeApiKey ?? {}),
320
+ [profileId]: { key, optIn: true, at: Date.now() },
321
+ };
322
+ writeKeysFile(file);
323
+ return statusOf(key);
324
+ }
325
+
326
+ /** Turn the opt-in off for this profile: the key goes with it and Claude is back on the account. */
327
+ export function clearClaudeApiKey(profileId: string = currentProfileId()): void {
328
+ const file = readKeysFile();
329
+ if (file.claudeApiKey && profileId in file.claudeApiKey) {
330
+ delete file.claudeApiKey[profileId];
331
+ writeKeysFile(file);
332
+ }
333
+ }
334
+
335
+ function claudeApiKeyFor(profileId: string): string | null {
336
+ const rec = readKeysFile().claudeApiKey?.[profileId];
337
+ if (!rec || typeof rec !== 'object' || rec.optIn !== true) return null;
338
+ return normalizeChatKey(rec.key);
339
+ }
340
+
341
+ export function claudeApiKeyStatus(profileId: string = currentProfileId()): ChatKeyStatus {
342
+ return statusOf(claudeApiKeyFor(profileId));
343
+ }
344
+
345
+ /** Whether this profile turned the Claude API-key opt-in on (with a key stored). */
346
+ export function claudeApiKeyOptedIn(profileId: string = currentProfileId()): boolean {
347
+ return claudeApiKeyFor(profileId) !== null;
348
+ }
@@ -110,7 +110,9 @@ const NEEDS_SIGN_IN: readonly IntentKind[] = [
110
110
  * content-lane entry without a final answer (O4: the `after` gate).
111
111
  */
112
112
  export function closedGates(
113
- record: Pick<IntentRecord, 'kind' | 'project' | 'watermark'>,
113
+ record: Pick<IntentRecord, 'kind' | 'project' | 'watermark'> & {
114
+ payload?: { kind: string; agent?: unknown };
115
+ },
114
116
  facts: GateFacts,
115
117
  contentPending: readonly number[],
116
118
  now: number
@@ -122,7 +124,11 @@ export function closedGates(
122
124
  // S8.10 — a Handoff to production is an AI run that writes the code: it waits on the AI gates too
123
125
  // ("Connect your Claude account to let AI draft this."; after Connect, the waiting handoff runs).
124
126
  if (record.kind === 'ai.prompt' || record.kind === 'export.handoff') {
125
- if (!facts.aiConnected) closed.add('ai-connected');
127
+ // E2E finding (2026-11-12): `aiConnected` is CLAUDE's sign-in. A chat on another agent (Codex,
128
+ // opencode — its connection is checked at attach) is not held by it (plan Decision 1).
129
+ const agent = record.payload?.kind === 'ai.prompt' ? record.payload.agent : null;
130
+ const otherAgent = typeof agent === 'string' && agent !== 'claude';
131
+ if (!facts.aiConnected && !otherAgent) closed.add('ai-connected');
126
132
  if (!facts.aiReady) closed.add('ai-ready');
127
133
  if (typeof facts.allowanceResetsAt === 'number' && now < facts.allowanceResetsAt)
128
134
  closed.add('ai-allowance');
@@ -85,6 +85,11 @@ export type IntentPayload =
85
85
  attachments: string[];
86
86
  /** 'field' = 03's "waits in the field" (setting up, used up) */
87
87
  presentation: 'sent' | 'field';
88
+ /**
89
+ * B3 (universal ACP) — the chat's agent when it is not Claude. Claude's sign-in gate
90
+ * (`ai-connected`) does not hold it: that agent's connection is checked at attach.
91
+ */
92
+ agent?: string;
88
93
  }
89
94
  | { kind: 'share.invite'; email: string; role: Role; scope: ShareScope; message?: string }
90
95
  | { kind: 'share.ask-to-edit'; scope: ShareScope; note?: string }