@1agh/maude 2.2.1 → 2.3.2

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 (91) 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/annotations-layer.tsx +8 -0
  33. package/apps/studio/bin/_capture-init.js +5 -0
  34. package/apps/studio/bin/screenshot.sh +7 -1
  35. package/apps/studio/bridge/dgn-protocol.ts +3 -2
  36. package/apps/studio/canvas-shell.tsx +54 -0
  37. package/apps/studio/client/panels/ChatPanel.jsx +19 -4
  38. package/apps/studio/client/panels/PermissionPrompt.jsx +11 -6
  39. package/apps/studio/client/panels/SyncConsentDialog.jsx +4 -1
  40. package/apps/studio/client/panels/acp-runtime.js +95 -7
  41. package/apps/studio/client/v2/ai/Advanced.jsx +4 -3
  42. package/apps/studio/client/v2/ai/AgentNotice.jsx +138 -0
  43. package/apps/studio/client/v2/ai/AgentOffer.jsx +110 -0
  44. package/apps/studio/client/v2/ai/AgentPicker.jsx +121 -0
  45. package/apps/studio/client/v2/ai/Composer.jsx +4 -0
  46. package/apps/studio/client/v2/ai/ConnectSheet.jsx +13 -0
  47. package/apps/studio/client/v2/ai/Feed.jsx +8 -0
  48. package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +24 -1
  49. package/apps/studio/client/v2/ai/Suggest.jsx +5 -1
  50. package/apps/studio/client/v2/ai/advanced-model.js +17 -6
  51. package/apps/studio/client/v2/ai/agents-model.js +333 -0
  52. package/apps/studio/client/v2/ai/agents-store.js +223 -0
  53. package/apps/studio/client/v2/ai/ai.css +63 -0
  54. package/apps/studio/client/v2/ai/needs-you.js +1 -1
  55. package/apps/studio/client/v2/empty/empty-host.jsx +11 -2
  56. package/apps/studio/client/v2/empty/use-empty-canvas.js +22 -7
  57. package/apps/studio/client/v2/fold/fold-store.js +1 -0
  58. package/apps/studio/client/v2/preview/preview-chrome-host.jsx +1 -0
  59. package/apps/studio/client/v2/settings/agent-keys.js +88 -0
  60. package/apps/studio/client/v2/settings/agents-card.jsx +408 -0
  61. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  62. package/apps/studio/client/v2/settings/connections-section.jsx +4 -0
  63. package/apps/studio/client/v2/settings/settings-cards.js +2 -1
  64. package/apps/studio/client/v2/settings/settings-model.js +1 -0
  65. package/apps/studio/client/v2/settings/settings.css +7 -0
  66. package/apps/studio/client/v2/shell/served-routes.js +1 -0
  67. package/apps/studio/client/v2/undo/zoom-undo.jsx +19 -2
  68. package/apps/studio/cloud-build.ts +5 -0
  69. package/apps/studio/comments/reveal.ts +13 -0
  70. package/apps/studio/comments-overlay.tsx +36 -0
  71. package/apps/studio/dist/client.bundle.js +535 -535
  72. package/apps/studio/dist/comment-mount.js +2 -2
  73. package/apps/studio/dist/styles.css +1 -1
  74. package/apps/studio/editing/annotation-count.ts +25 -0
  75. package/apps/studio/editing/empty-report.ts +8 -3
  76. package/apps/studio/editing/empty-reporter.tsx +10 -1
  77. package/apps/studio/generation/keys.ts +197 -11
  78. package/apps/studio/outbox/policy.ts +8 -2
  79. package/apps/studio/outbox/types.ts +5 -0
  80. package/apps/studio/routes/agents.ts +479 -0
  81. package/apps/studio/routes/index.ts +3 -0
  82. package/apps/studio/scripts/acp-conformance-local.ts +95 -0
  83. package/apps/studio/scripts/acp-e2e-local.ts +1026 -0
  84. package/apps/studio/server.ts +9 -0
  85. package/apps/studio/sync/index.ts +9 -1
  86. package/apps/studio/sync/writer-registry.ts +12 -0
  87. package/apps/studio/whats-new.json +19 -0
  88. package/apps/studio/ws.ts +3 -0
  89. package/cli/commands/codex.mjs +36 -2
  90. package/cli/lib/harness/codex-runtime.mjs +98 -11
  91. package/package.json +9 -8
@@ -0,0 +1,25 @@
1
+ // apps/studio/editing/annotation-count.ts — #227: how many annotations the canvas's board holds.
2
+ //
3
+ // The annotation layer is the only code that knows the board (hidden with ⇧P, folded into the far-zoom
4
+ // mosaic or panned out of view, an annotation is still on the canvas — so the DOM is not the answer). It
5
+ // writes the number here; the empty-state reporter (empty-report.ts) reads it and sends it with the
6
+ // artboard count, so "Your canvas is ready." never sits over a canvas somebody has already drawn on.
7
+
8
+ let count = 0;
9
+ const subs = new Set<() => void>();
10
+
11
+ export function setAnnotationCount(n: number): void {
12
+ const next = Number.isFinite(n) ? Math.max(0, Math.round(n)) : 0;
13
+ if (next === count) return;
14
+ count = next;
15
+ for (const fn of subs) fn();
16
+ }
17
+
18
+ export const annotationCount = (): number => count;
19
+
20
+ export function onAnnotationCount(fn: () => void): () => void {
21
+ subs.add(fn);
22
+ return () => {
23
+ subs.delete(fn);
24
+ };
25
+ }
@@ -23,7 +23,7 @@ export interface EmptyRect {
23
23
  }
24
24
 
25
25
  export type EmptyPost =
26
- | { dgn: 'artboards'; count: number }
26
+ | { dgn: 'artboards'; count: number; annotations?: number }
27
27
  | {
28
28
  dgn: 'artboard-empty';
29
29
  artboardId: string | null;
@@ -112,6 +112,8 @@ export interface EmptyReporterDeps {
112
112
  doc: Document;
113
113
  /** The artboard id when exactly one WHOLE artboard is selected, else null. */
114
114
  selectedArtboard: () => string | null;
115
+ /** #227 — how many annotations the board holds (annotation-count.ts). Absent = not told, nothing sent. */
116
+ annotations?: () => number;
115
117
  post: (m: EmptyPost) => void;
116
118
  raf?: (fn: () => void) => number;
117
119
  caf?: (id: number) => void;
@@ -136,14 +138,17 @@ export function createEmptyReporter(deps: EmptyReporterDeps): EmptyReporter {
136
138
  typeof cancelAnimationFrame === 'function' ? frameCaf(id) : clearTimeout(id));
137
139
  let pending: number | null = null;
138
140
  let lastCount = -1;
141
+ let lastAnnotations = -1;
139
142
  let lastKey: string | null = null;
140
143
  let lastId: string | null = null;
141
144
 
142
145
  function pass(): void {
143
146
  const count = deps.doc.querySelectorAll('[data-dc-screen]').length;
144
- if (count !== lastCount) {
147
+ const annotations = deps.annotations ? deps.annotations() : undefined;
148
+ if (count !== lastCount || (annotations !== undefined && annotations !== lastAnnotations)) {
145
149
  lastCount = count;
146
- deps.post({ dgn: 'artboards', count });
150
+ if (annotations !== undefined) lastAnnotations = annotations;
151
+ deps.post({ dgn: 'artboards', count, ...(annotations !== undefined ? { annotations } : {}) });
147
152
  }
148
153
  const id = deps.selectedArtboard();
149
154
  const m = id ? measureEmptyArtboard(deps.doc, id) : null;
@@ -7,6 +7,7 @@ import { useEffect, useRef } from 'react';
7
7
 
8
8
  import { postToShell } from '../bridge/dgn-protocol.ts';
9
9
  import { useSelectionSet } from '../use-selection-set.tsx';
10
+ import { annotationCount, onAnnotationCount } from './annotation-count.ts';
10
11
  import { createEmptyReporter, EMPTY_CHROME_SEL } from './empty-report.ts';
11
12
 
12
13
  /** A whole-artboard selection (no element id) → that artboard's id; anything else → null. */
@@ -29,8 +30,13 @@ export function EmptyArtboardReporter(): null {
29
30
  const reporter = createEmptyReporter({
30
31
  doc: document,
31
32
  selectedArtboard: () => selectedRef.current,
33
+ annotations: annotationCount,
32
34
  post: (m) => {
33
- if (m.dgn === 'artboards') postToShell(window, 'artboards', { count: m.count });
35
+ if (m.dgn === 'artboards')
36
+ postToShell(window, 'artboards', {
37
+ count: m.count,
38
+ ...(m.annotations !== undefined ? { annotations: m.annotations } : {}),
39
+ });
34
40
  else
35
41
  postToShell(window, 'artboard-empty', {
36
42
  artboardId: m.artboardId,
@@ -42,6 +48,8 @@ export function EmptyArtboardReporter(): null {
42
48
  });
43
49
  requestRef.current = reporter.request;
44
50
  reporter.request();
51
+ // #227 — the first sticky on an empty canvas (or the last one gone) is a new answer
52
+ const offAnnotations = onAnnotationCount(reporter.request);
45
53
  let obs: MutationObserver | null = null;
46
54
  if (typeof MutationObserver !== 'undefined') {
47
55
  obs = new MutationObserver((records) => {
@@ -59,6 +67,7 @@ export function EmptyArtboardReporter(): null {
59
67
  }
60
68
  return () => {
61
69
  obs?.disconnect();
70
+ offAnnotations();
62
71
  reporter.cancel();
63
72
  requestRef.current = null;
64
73
  };
@@ -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 }