@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.
- package/apps/studio/acp/agents/auth.ts +241 -0
- package/apps/studio/acp/agents/catalog.ts +308 -0
- package/apps/studio/acp/agents/chat-key.ts +64 -0
- package/apps/studio/acp/agents/conformance.ts +1853 -0
- package/apps/studio/acp/agents/consent.ts +92 -0
- package/apps/studio/acp/agents/descriptor.ts +188 -0
- package/apps/studio/acp/agents/discover.ts +491 -0
- package/apps/studio/acp/agents/e2e-model.ts +58 -0
- package/apps/studio/acp/agents/health.ts +46 -0
- package/apps/studio/acp/agents/link-scan.ts +230 -0
- package/apps/studio/acp/agents/spawn.ts +164 -0
- package/apps/studio/acp/agents/state.ts +132 -0
- package/apps/studio/acp/ask-queue.ts +13 -4
- package/apps/studio/acp/bootstrap-brief.ts +16 -3
- package/apps/studio/acp/bridge.ts +709 -99
- package/apps/studio/acp/env.ts +43 -1
- package/apps/studio/acp/index.ts +428 -43
- package/apps/studio/acp/may-scope.ts +244 -21
- package/apps/studio/acp/policy/agent-home.ts +202 -0
- package/apps/studio/acp/policy/bridge-gate.ts +68 -0
- package/apps/studio/acp/policy/codex-home.ts +228 -0
- package/apps/studio/acp/policy/enforce.ts +620 -0
- package/apps/studio/acp/policy/gate-types.ts +41 -0
- package/apps/studio/acp/policy/launch-codex.ts +351 -0
- package/apps/studio/acp/policy/launch-copilot.ts +119 -0
- package/apps/studio/acp/policy/launch-gemini.ts +120 -0
- package/apps/studio/acp/policy/launch-opencode.ts +131 -0
- package/apps/studio/acp/policy/opencode-user-config.ts +240 -0
- package/apps/studio/acp/probe.ts +78 -14
- package/apps/studio/acp/transcript.ts +14 -0
- package/apps/studio/acp/write-scope.ts +62 -2
- package/apps/studio/canvas-pages-view.tsx +3 -2
- package/apps/studio/canvas-theme-pill.tsx +125 -72
- package/apps/studio/client/panels/ChatPanel.jsx +19 -4
- package/apps/studio/client/panels/PermissionPrompt.jsx +11 -6
- package/apps/studio/client/panels/acp-runtime.js +95 -7
- package/apps/studio/client/v2/ai/Advanced.jsx +4 -3
- package/apps/studio/client/v2/ai/AgentNotice.jsx +138 -0
- package/apps/studio/client/v2/ai/AgentOffer.jsx +110 -0
- package/apps/studio/client/v2/ai/AgentPicker.jsx +121 -0
- package/apps/studio/client/v2/ai/Composer.jsx +4 -0
- package/apps/studio/client/v2/ai/ConnectSheet.jsx +13 -0
- package/apps/studio/client/v2/ai/Feed.jsx +8 -0
- package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +24 -1
- package/apps/studio/client/v2/ai/Suggest.jsx +5 -1
- package/apps/studio/client/v2/ai/advanced-model.js +17 -6
- package/apps/studio/client/v2/ai/agents-model.js +333 -0
- package/apps/studio/client/v2/ai/agents-store.js +223 -0
- package/apps/studio/client/v2/ai/ai.css +63 -0
- package/apps/studio/client/v2/ai/needs-you.js +1 -1
- package/apps/studio/client/v2/fold/fold-store.js +1 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +8 -0
- package/apps/studio/client/v2/settings/agent-keys.js +88 -0
- package/apps/studio/client/v2/settings/agents-card.jsx +408 -0
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/settings/connections-section.jsx +4 -0
- package/apps/studio/client/v2/settings/settings-cards.js +2 -1
- package/apps/studio/client/v2/settings/settings-model.js +1 -0
- package/apps/studio/client/v2/settings/settings.css +7 -0
- package/apps/studio/client/v2/shell/served-routes.js +1 -0
- package/apps/studio/cloud-build.ts +5 -0
- package/apps/studio/dist/client.bundle.js +604 -604
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +4 -78
- package/apps/studio/ds/board/ds-bar.tsx +15 -9
- package/apps/studio/generation/keys.ts +197 -11
- package/apps/studio/outbox/policy.ts +8 -2
- package/apps/studio/outbox/types.ts +5 -0
- package/apps/studio/routes/agents.ts +479 -0
- package/apps/studio/routes/index.ts +3 -0
- package/apps/studio/scripts/acp-conformance-local.ts +95 -0
- package/apps/studio/scripts/acp-e2e-local.ts +1026 -0
- package/apps/studio/server.ts +9 -0
- package/apps/studio/sync/writer-registry.ts +12 -0
- package/apps/studio/whats-new.json +19 -0
- package/apps/studio/ws.ts +3 -0
- package/cli/commands/codex.mjs +36 -2
- package/cli/lib/harness/codex-runtime.mjs +98 -11
- package/package.json +9 -8
|
@@ -246,6 +246,69 @@
|
|
|
246
246
|
line-height: var(--lh-xs);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
/* ── Universal ACP B6: another agent on this Mac (agents-model.js). Quiet: the hint's ink, a text link. ── */
|
|
250
|
+
.ai-agent-offer {
|
|
251
|
+
padding: var(--space-1) var(--space-1) 0;
|
|
252
|
+
}
|
|
253
|
+
.ai-agent-offer-t {
|
|
254
|
+
margin: 0;
|
|
255
|
+
color: var(--fg-2);
|
|
256
|
+
font-size: var(--type-sm);
|
|
257
|
+
line-height: var(--lh-sm);
|
|
258
|
+
}
|
|
259
|
+
.maude .ai-agent-link {
|
|
260
|
+
display: inline;
|
|
261
|
+
padding: 0;
|
|
262
|
+
border: 0;
|
|
263
|
+
background: none;
|
|
264
|
+
color: var(--accent);
|
|
265
|
+
font: inherit;
|
|
266
|
+
cursor: pointer;
|
|
267
|
+
}
|
|
268
|
+
.maude .ai-agent-link:hover {
|
|
269
|
+
text-decoration: underline;
|
|
270
|
+
}
|
|
271
|
+
.maude .ai-agent-link:focus-visible {
|
|
272
|
+
outline: 2px solid var(--focus-ring);
|
|
273
|
+
outline-offset: 2px;
|
|
274
|
+
border-radius: var(--radius-sm);
|
|
275
|
+
}
|
|
276
|
+
.maude .ai-agent-link--quiet {
|
|
277
|
+
color: var(--fg-2);
|
|
278
|
+
}
|
|
279
|
+
.ai-agent-sep {
|
|
280
|
+
margin: 0 var(--space-1);
|
|
281
|
+
color: var(--fg-2);
|
|
282
|
+
}
|
|
283
|
+
.ai-agent-note {
|
|
284
|
+
margin: var(--space-1) 0 0;
|
|
285
|
+
color: var(--fg-2);
|
|
286
|
+
font-size: var(--type-xs);
|
|
287
|
+
}
|
|
288
|
+
.ai-agent-note--err {
|
|
289
|
+
color: var(--status-error);
|
|
290
|
+
}
|
|
291
|
+
.ai-agent-badge {
|
|
292
|
+
display: inline-block;
|
|
293
|
+
margin-bottom: var(--space-1);
|
|
294
|
+
color: var(--fg-2);
|
|
295
|
+
font-size: var(--type-xs);
|
|
296
|
+
line-height: var(--lh-xs);
|
|
297
|
+
}
|
|
298
|
+
.maude .ai-agent-chip {
|
|
299
|
+
flex: none;
|
|
300
|
+
max-width: 120px;
|
|
301
|
+
font-size: var(--type-xs);
|
|
302
|
+
line-height: var(--lh-xs);
|
|
303
|
+
}
|
|
304
|
+
.maude .ai-agent-chip--locked {
|
|
305
|
+
color: var(--fg-2);
|
|
306
|
+
}
|
|
307
|
+
.maude .ai-conn-other {
|
|
308
|
+
align-self: flex-start;
|
|
309
|
+
font-size: var(--type-xs);
|
|
310
|
+
}
|
|
311
|
+
|
|
249
312
|
/* ── An answer that touched nothing ── */
|
|
250
313
|
.ai-unchanged {
|
|
251
314
|
margin: var(--space-2) 0 0;
|
|
@@ -105,7 +105,7 @@ function canvasName(path) {
|
|
|
105
105
|
*/
|
|
106
106
|
export function permissionModel(request, work = null) {
|
|
107
107
|
const toolCall = request?.toolCall ?? {};
|
|
108
|
-
const outside = describeOutOfProject(request?.scope);
|
|
108
|
+
const outside = describeOutOfProject(request?.scope, request?.agent);
|
|
109
109
|
const all = Array.isArray(request?.options) ? request.options.filter(Boolean) : [];
|
|
110
110
|
// Decision D is enforced server-side; this second pass only keeps a stale frame from painting a
|
|
111
111
|
// button the server would refuse.
|
|
@@ -330,8 +330,16 @@
|
|
|
330
330
|
color: var(--fg-2);
|
|
331
331
|
font-variant-numeric: tabular-nums;
|
|
332
332
|
}
|
|
333
|
+
/* #224: the strip scrolls itself within a cap. A system row opened into its artboards (65 for a big system)
|
|
334
|
+
used to grow it past the panel: `.sh-sidebar` clips (F35), so the canvas list below — the panel's only
|
|
335
|
+
scroller — was squeezed to nothing and no wheel scrolled anything. Still `flex: none`: a shrinkable strip
|
|
336
|
+
gave way to the canvas list and cut the system row itself (26 of its 61 px). */
|
|
333
337
|
.lp-pinned {
|
|
334
338
|
flex: none;
|
|
339
|
+
max-height: 40%;
|
|
340
|
+
overflow-x: hidden;
|
|
341
|
+
overflow-y: auto;
|
|
342
|
+
overscroll-behavior: contain;
|
|
335
343
|
margin: 0 var(--space-2) var(--space-1);
|
|
336
344
|
padding-bottom: var(--space-1);
|
|
337
345
|
box-shadow: inset 0 -0.5px 0 var(--border-default);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// client/v2/settings/agent-keys.js — B7 (DDR-252 § BYOK): own API keys for the chat agents, the model and
|
|
2
|
+
// the two writes behind Settings › AI agents › Advanced. The server never sends a key back: a row carries
|
|
3
|
+
// `acceptsKey`, `keySet` and `keyLast4` only (routes/agents.ts), and this file never keeps one past the
|
|
4
|
+
// save call. Pure of React so the tests drive it with a scripted fetch.
|
|
5
|
+
|
|
6
|
+
import { loadAgents } from '../ai/agents-store.js';
|
|
7
|
+
|
|
8
|
+
const CLAUDE_ID = 'claude';
|
|
9
|
+
const enc = (id) => encodeURIComponent(id);
|
|
10
|
+
|
|
11
|
+
/** The rows that take an own key: installed agents the server says accept one, Claude last. */
|
|
12
|
+
export function agentKeyRows(agents = []) {
|
|
13
|
+
const rows = agents
|
|
14
|
+
.filter((a) => a && a.installed === true && a.acceptsKey === true)
|
|
15
|
+
.map((a) => ({
|
|
16
|
+
id: a.id,
|
|
17
|
+
label: typeof a.label === 'string' && a.label ? a.label : a.id,
|
|
18
|
+
keySet: a.keySet === true,
|
|
19
|
+
last4: a.keySet === true && typeof a.keyLast4 === 'string' ? a.keyLast4.slice(-4) : null,
|
|
20
|
+
}));
|
|
21
|
+
return {
|
|
22
|
+
keys: rows.filter((r) => r.id !== CLAUDE_ID),
|
|
23
|
+
claude: rows.find((r) => r.id === CLAUDE_ID) ?? null,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** "••••1234" for a stored key, "" when none. */
|
|
28
|
+
export const maskedKey = (last4) => (last4 ? `••••${last4}` : '');
|
|
29
|
+
|
|
30
|
+
/** The confirm card's words for Claude's opt-in (DDR-252: the billing switch is explicit). */
|
|
31
|
+
export const CLAUDE_OPTIN_WORDS =
|
|
32
|
+
'Claude will use this Anthropic API key instead of your Claude account. Every message is billed to that API account, per token, not to your Claude plan. Only for this profile; turn it off to go back to your account.';
|
|
33
|
+
|
|
34
|
+
/** A key as typed is worth sending: non-empty, one line, at most 512 characters. */
|
|
35
|
+
export function keyLooksValid(value) {
|
|
36
|
+
if (typeof value !== 'string') return false;
|
|
37
|
+
const v = value.trim();
|
|
38
|
+
return v.length > 0 && v.length <= 512 && !/\s/.test(v);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A refused save, in words. */
|
|
42
|
+
export function keyErrorWords(r) {
|
|
43
|
+
switch (r?.reason) {
|
|
44
|
+
case 'invalid-key':
|
|
45
|
+
return 'That does not look like an API key. Paste it again, on one line.';
|
|
46
|
+
case 'opt-in-required':
|
|
47
|
+
return 'Turn on the Anthropic API key first.';
|
|
48
|
+
case 'no-api-key':
|
|
49
|
+
return 'This agent takes no API key from Maude. Sign in to it instead.';
|
|
50
|
+
default:
|
|
51
|
+
return 'Could not save the key. Try again.';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function post(fetchImpl, url, body) {
|
|
56
|
+
try {
|
|
57
|
+
const res = await fetchImpl(url, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
...(body
|
|
60
|
+
? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }
|
|
61
|
+
: {}),
|
|
62
|
+
});
|
|
63
|
+
return (await res.json().catch(() => null)) ?? { ok: false };
|
|
64
|
+
} catch {
|
|
65
|
+
return { ok: false };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Save an agent's key (Claude's needs `optIn: true`, from the confirm card). Reloads the list. */
|
|
70
|
+
export async function saveAgentKey(
|
|
71
|
+
id,
|
|
72
|
+
key,
|
|
73
|
+
{ optIn = false, fetchImpl = (...a) => fetch(...a) } = {}
|
|
74
|
+
) {
|
|
75
|
+
const r = await post(fetchImpl, `/_api/agents/${enc(id)}/key`, {
|
|
76
|
+
key,
|
|
77
|
+
...(optIn ? { optIn: true } : {}),
|
|
78
|
+
});
|
|
79
|
+
await loadAgents({ force: false, fetchImpl });
|
|
80
|
+
return r;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Remove an agent's key (for Claude: the opt-in goes with it). Reloads the list. */
|
|
84
|
+
export async function removeAgentKey(id, { fetchImpl = (...a) => fetch(...a) } = {}) {
|
|
85
|
+
const r = await post(fetchImpl, `/_api/agents/${enc(id)}/key-remove`);
|
|
86
|
+
await loadAgents({ force: false, fetchImpl });
|
|
87
|
+
return r;
|
|
88
|
+
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
// client/v2/settings/agents-card.jsx — universal ACP B6, Design Decision 2: Settings › Connections › AI agents,
|
|
2
|
+
// the always-present list of the other AI agents on this Mac, right under the Claude card.
|
|
3
|
+
//
|
|
4
|
+
// ✦ AI agents Other AI on this Mac. ● Codex connected ›
|
|
5
|
+
// Codex OpenAI ● Connected [Disconnect]
|
|
6
|
+
// opencode opencode ● Available Uses opencode's hosted model… [Connect]
|
|
7
|
+
// › Advanced agents Maude cannot hold to its limits, each behind a consent card, and (B7) own API keys:
|
|
8
|
+
// "Codex API key [••••] [Save]" per agent that takes one, and Claude's opt-in
|
|
9
|
+
// "Use an Anthropic API key for Claude instead of your Claude account" behind a billing card
|
|
10
|
+
//
|
|
11
|
+
// Only installed agents appear, Claude never (it keeps its own card). With nothing but Claude on this Mac the
|
|
12
|
+
// card is not drawn at all (agentsCardVisible) — the Claude-only Settings are unchanged.
|
|
13
|
+
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
|
|
16
|
+
import { reasonProps } from '../access/disabled-reason.js';
|
|
17
|
+
import {
|
|
18
|
+
agentRows,
|
|
19
|
+
agentsCardSummary,
|
|
20
|
+
agentsCardVisible,
|
|
21
|
+
consentWords,
|
|
22
|
+
} from '../ai/agents-model.js';
|
|
23
|
+
import {
|
|
24
|
+
connectProgressWords,
|
|
25
|
+
disconnectAgent,
|
|
26
|
+
loadAgents,
|
|
27
|
+
useAgentConnect,
|
|
28
|
+
useAgents,
|
|
29
|
+
} from '../ai/agents-store.js';
|
|
30
|
+
import {
|
|
31
|
+
agentKeyRows,
|
|
32
|
+
CLAUDE_OPTIN_WORDS,
|
|
33
|
+
keyErrorWords,
|
|
34
|
+
keyLooksValid,
|
|
35
|
+
maskedKey,
|
|
36
|
+
removeAgentKey,
|
|
37
|
+
saveAgentKey,
|
|
38
|
+
} from './agent-keys.js';
|
|
39
|
+
import { connectionFoldId } from './connections-model.js';
|
|
40
|
+
import { CardRow, SettingsCard, StatusLine } from './settings-card.jsx';
|
|
41
|
+
|
|
42
|
+
const btn = 'btn btn--sm';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* B7 — "Use an API key" for one agent: a masked input + Save, or ••••last4 + Remove once stored. The
|
|
46
|
+
* typed key lives only in this input's state and is dropped after the save; the server never sends it.
|
|
47
|
+
*/
|
|
48
|
+
export function AgentKeyRow({ row, label, save = saveAgentKey, remove = removeAgentKey, optIn }) {
|
|
49
|
+
const [value, setValue] = useState('');
|
|
50
|
+
const [busy, setBusy] = useState(false);
|
|
51
|
+
const [error, setError] = useState(null);
|
|
52
|
+
const ok = keyLooksValid(value);
|
|
53
|
+
const doSave = async () => {
|
|
54
|
+
if (!ok || busy) return;
|
|
55
|
+
setBusy(true);
|
|
56
|
+
setError(null);
|
|
57
|
+
const r = await save(row.id, value.trim(), optIn ? { optIn: true } : undefined);
|
|
58
|
+
setBusy(false);
|
|
59
|
+
setValue('');
|
|
60
|
+
if (!r?.ok) setError(keyErrorWords(r));
|
|
61
|
+
};
|
|
62
|
+
const doRemove = async () => {
|
|
63
|
+
setBusy(true);
|
|
64
|
+
setError(null);
|
|
65
|
+
const r = await remove(row.id);
|
|
66
|
+
setBusy(false);
|
|
67
|
+
if (!r?.ok) setError('Could not remove the key. Try again.');
|
|
68
|
+
};
|
|
69
|
+
return (
|
|
70
|
+
<div className="v2s-agent" data-testid={`settings-agent-keyrow-${row.id}`}>
|
|
71
|
+
<CardRow
|
|
72
|
+
k={label ?? `${row.label} API key`}
|
|
73
|
+
testid={`settings-agent-keystate-${row.id}`}
|
|
74
|
+
action={
|
|
75
|
+
row.keySet ? (
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
className={btn}
|
|
79
|
+
disabled={busy}
|
|
80
|
+
onClick={doRemove}
|
|
81
|
+
data-testid={`settings-agent-key-remove-${row.id}`}
|
|
82
|
+
>
|
|
83
|
+
Remove
|
|
84
|
+
</button>
|
|
85
|
+
) : null
|
|
86
|
+
}
|
|
87
|
+
>
|
|
88
|
+
<StatusLine sw={row.keySet ? 'ok' : 'off'}>
|
|
89
|
+
{row.keySet ? `Using your key ${maskedKey(row.last4)}` : 'Not set'}
|
|
90
|
+
</StatusLine>
|
|
91
|
+
</CardRow>
|
|
92
|
+
{row.keySet ? null : (
|
|
93
|
+
<span className="v2s-conn-replace">
|
|
94
|
+
<input
|
|
95
|
+
className="input"
|
|
96
|
+
type="password"
|
|
97
|
+
autoComplete="off"
|
|
98
|
+
spellCheck={false}
|
|
99
|
+
placeholder="Paste an API key"
|
|
100
|
+
value={value}
|
|
101
|
+
onChange={(e) => setValue(e.target.value)}
|
|
102
|
+
onKeyDown={(e) => {
|
|
103
|
+
if (e.key === 'Enter') void doSave();
|
|
104
|
+
}}
|
|
105
|
+
aria-label={`${row.label} API key`}
|
|
106
|
+
data-testid={`settings-agent-key-${row.id}`}
|
|
107
|
+
/>
|
|
108
|
+
<button
|
|
109
|
+
type="button"
|
|
110
|
+
className={btn}
|
|
111
|
+
disabled={busy || !ok}
|
|
112
|
+
{...reasonProps(busy || !ok, busy ? 'Saving…' : 'Paste the key first.')}
|
|
113
|
+
onClick={() => void doSave()}
|
|
114
|
+
data-testid={`settings-agent-key-save-${row.id}`}
|
|
115
|
+
>
|
|
116
|
+
Save
|
|
117
|
+
</button>
|
|
118
|
+
</span>
|
|
119
|
+
)}
|
|
120
|
+
{error ? (
|
|
121
|
+
<p className="v2s-conn-err" role="alert" data-testid={`settings-agent-key-error-${row.id}`}>
|
|
122
|
+
{error}
|
|
123
|
+
</p>
|
|
124
|
+
) : null}
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* B7 (DDR-252 amends DDR-123) — "Use an Anthropic API key for Claude instead of your Claude account".
|
|
131
|
+
* Off by default; turning it on shows the billing confirm card first, and only then the key input.
|
|
132
|
+
* Removing the key turns it off.
|
|
133
|
+
*/
|
|
134
|
+
export function ClaudeApiKeyOptIn({ row, save = saveAgentKey, remove = removeAgentKey }) {
|
|
135
|
+
const [confirming, setConfirming] = useState(false);
|
|
136
|
+
const [confirmed, setConfirmed] = useState(false);
|
|
137
|
+
const on = row.keySet;
|
|
138
|
+
return (
|
|
139
|
+
<div className="v2s-agent" data-testid="settings-claude-apikey">
|
|
140
|
+
<label className="v2s-row v2s-row--switch">
|
|
141
|
+
<span className="v2s-row-t">
|
|
142
|
+
<span className="v2s-row-k">
|
|
143
|
+
Use an Anthropic API key for Claude instead of your Claude account
|
|
144
|
+
</span>
|
|
145
|
+
<span className="v2s-hint">
|
|
146
|
+
{on
|
|
147
|
+
? `Billed per token to the key ${maskedKey(row.last4)}`
|
|
148
|
+
: 'Off: Claude uses your Claude plan.'}
|
|
149
|
+
</span>
|
|
150
|
+
</span>
|
|
151
|
+
<input
|
|
152
|
+
type="checkbox"
|
|
153
|
+
className="v2s-switch"
|
|
154
|
+
role="switch"
|
|
155
|
+
aria-checked={on || confirmed}
|
|
156
|
+
checked={on || confirmed}
|
|
157
|
+
onChange={(e) => {
|
|
158
|
+
if (e.target.checked) setConfirming(true);
|
|
159
|
+
else if (on) void remove(row.id);
|
|
160
|
+
else setConfirmed(false);
|
|
161
|
+
}}
|
|
162
|
+
data-testid="settings-claude-apikey-optin"
|
|
163
|
+
/>
|
|
164
|
+
</label>
|
|
165
|
+
{confirming && !on ? (
|
|
166
|
+
// biome-ignore lint/a11y/useSemanticElements: a labelled question with two buttons, not a form fieldset
|
|
167
|
+
<div
|
|
168
|
+
className="v2s-conn-keys"
|
|
169
|
+
role="group"
|
|
170
|
+
aria-label="Bill Claude to an API key"
|
|
171
|
+
data-testid="settings-claude-apikey-confirm"
|
|
172
|
+
>
|
|
173
|
+
<p className="v2s-hint">{CLAUDE_OPTIN_WORDS}</p>
|
|
174
|
+
<span className="v2s-conn-replace">
|
|
175
|
+
<button
|
|
176
|
+
type="button"
|
|
177
|
+
className={btn}
|
|
178
|
+
onClick={() => setConfirming(false)}
|
|
179
|
+
data-testid="settings-claude-apikey-cancel"
|
|
180
|
+
>
|
|
181
|
+
Cancel
|
|
182
|
+
</button>
|
|
183
|
+
<button
|
|
184
|
+
type="button"
|
|
185
|
+
className="btn btn--sm btn--primary"
|
|
186
|
+
onClick={() => {
|
|
187
|
+
setConfirming(false);
|
|
188
|
+
setConfirmed(true);
|
|
189
|
+
}}
|
|
190
|
+
data-testid="settings-claude-apikey-confirm-yes"
|
|
191
|
+
>
|
|
192
|
+
Bill my API account
|
|
193
|
+
</button>
|
|
194
|
+
</span>
|
|
195
|
+
</div>
|
|
196
|
+
) : null}
|
|
197
|
+
{on || confirmed ? (
|
|
198
|
+
<AgentKeyRow
|
|
199
|
+
row={row}
|
|
200
|
+
label="Anthropic API key"
|
|
201
|
+
optIn
|
|
202
|
+
save={save}
|
|
203
|
+
remove={async (id) => {
|
|
204
|
+
setConfirmed(false);
|
|
205
|
+
return remove(id);
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
) : null}
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** One agent's row: its name and vendor, its state word, and its one action. */
|
|
214
|
+
export function AgentRow({ row, c, onAskConsent, onDisconnect }) {
|
|
215
|
+
const busy = c.busyId === row.id;
|
|
216
|
+
const other = c.busyId !== null && !busy;
|
|
217
|
+
const progress = busy ? connectProgressWords(c.phase, row.label) : null;
|
|
218
|
+
let action = null;
|
|
219
|
+
if (busy)
|
|
220
|
+
action = (
|
|
221
|
+
<button
|
|
222
|
+
type="button"
|
|
223
|
+
className={btn}
|
|
224
|
+
onClick={c.cancel}
|
|
225
|
+
data-testid={`settings-agent-cancel-${row.id}`}
|
|
226
|
+
>
|
|
227
|
+
Cancel
|
|
228
|
+
</button>
|
|
229
|
+
);
|
|
230
|
+
else if (row.action === 'connect' || row.action === 'signin')
|
|
231
|
+
action = (
|
|
232
|
+
<button
|
|
233
|
+
type="button"
|
|
234
|
+
className={btn}
|
|
235
|
+
disabled={other}
|
|
236
|
+
{...reasonProps(other, 'Another agent is connecting.')}
|
|
237
|
+
onClick={() =>
|
|
238
|
+
row.unrestricted && row.action === 'connect'
|
|
239
|
+
? onAskConsent(row)
|
|
240
|
+
: c.connect(row, { signinFirst: row.action === 'signin' })
|
|
241
|
+
}
|
|
242
|
+
data-testid={`settings-agent-connect-${row.id}`}
|
|
243
|
+
>
|
|
244
|
+
{row.action === 'signin' ? 'Sign in…' : 'Connect'}
|
|
245
|
+
</button>
|
|
246
|
+
);
|
|
247
|
+
else if (row.action === 'disconnect')
|
|
248
|
+
action = (
|
|
249
|
+
<button
|
|
250
|
+
type="button"
|
|
251
|
+
className={btn}
|
|
252
|
+
disabled={other}
|
|
253
|
+
{...reasonProps(other, 'Another agent is connecting.')}
|
|
254
|
+
onClick={() => onDisconnect(row)}
|
|
255
|
+
data-testid={`settings-agent-disconnect-${row.id}`}
|
|
256
|
+
>
|
|
257
|
+
Disconnect
|
|
258
|
+
</button>
|
|
259
|
+
);
|
|
260
|
+
return (
|
|
261
|
+
<div className="v2s-agent" data-testid={`settings-agent-row-${row.id}`} data-state={row.state}>
|
|
262
|
+
<CardRow k={row.label} action={action} testid={`settings-agent-state-${row.id}`}>
|
|
263
|
+
<StatusLine sw={busy ? 'busy' : row.sw}>{progress ?? row.word}</StatusLine>
|
|
264
|
+
</CardRow>
|
|
265
|
+
{row.vendor ? <p className="v2s-hint v2s-agent-v">{`By ${row.vendor}`}</p> : null}
|
|
266
|
+
{row.connectNote && !row.connected ? (
|
|
267
|
+
<p className="v2s-hint" data-testid={`settings-agent-note-${row.id}`}>
|
|
268
|
+
{row.connectNote}
|
|
269
|
+
</p>
|
|
270
|
+
) : null}
|
|
271
|
+
{c.errorId === row.id && c.error ? (
|
|
272
|
+
<p className="v2s-conn-err" role="alert" data-testid={`settings-agent-error-${row.id}`}>
|
|
273
|
+
{c.error}
|
|
274
|
+
</p>
|
|
275
|
+
) : null}
|
|
276
|
+
</div>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** The consent card an unrestricted agent needs before Connect: per project, with its own words. */
|
|
281
|
+
export function AgentConsent({ row, onAllow, onCancel }) {
|
|
282
|
+
return (
|
|
283
|
+
// biome-ignore lint/a11y/useSemanticElements: a labelled question with two buttons, not a form fieldset
|
|
284
|
+
<div
|
|
285
|
+
className="v2s-conn-keys"
|
|
286
|
+
role="group"
|
|
287
|
+
aria-label={`Allow ${row.label}`}
|
|
288
|
+
data-testid="settings-agent-consent"
|
|
289
|
+
>
|
|
290
|
+
<p className="v2s-hint">{consentWords(row.label)}</p>
|
|
291
|
+
<span className="v2s-conn-replace">
|
|
292
|
+
<button
|
|
293
|
+
type="button"
|
|
294
|
+
className={btn}
|
|
295
|
+
onClick={onCancel}
|
|
296
|
+
data-testid="settings-agent-consent-cancel"
|
|
297
|
+
>
|
|
298
|
+
Cancel
|
|
299
|
+
</button>
|
|
300
|
+
<button
|
|
301
|
+
type="button"
|
|
302
|
+
className="btn btn--sm btn--primary"
|
|
303
|
+
onClick={onAllow}
|
|
304
|
+
data-testid="settings-agent-consent-allow"
|
|
305
|
+
>
|
|
306
|
+
Allow and connect
|
|
307
|
+
</button>
|
|
308
|
+
</span>
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** The card, controlled (a `list` from `/_api/agents`); `null` when only Claude is on this Mac. */
|
|
314
|
+
export function AgentsCardView({
|
|
315
|
+
list,
|
|
316
|
+
c,
|
|
317
|
+
card,
|
|
318
|
+
disconnect = disconnectAgent,
|
|
319
|
+
saveKey = saveAgentKey,
|
|
320
|
+
removeKey = removeAgentKey,
|
|
321
|
+
}) {
|
|
322
|
+
const [asking, setAsking] = useState(null);
|
|
323
|
+
const agents = list?.agents ?? [];
|
|
324
|
+
if (!agentsCardVisible(agents)) return null;
|
|
325
|
+
const { main, advanced } = agentRows(agents);
|
|
326
|
+
const { keys, claude } = agentKeyRows(agents);
|
|
327
|
+
const foldBody = advanced.length || keys.length || claude;
|
|
328
|
+
const row = (r) => (
|
|
329
|
+
<AgentRow
|
|
330
|
+
key={r.id}
|
|
331
|
+
row={r}
|
|
332
|
+
c={c}
|
|
333
|
+
onAskConsent={setAsking}
|
|
334
|
+
onDisconnect={(x) => void disconnect(x.id)}
|
|
335
|
+
/>
|
|
336
|
+
);
|
|
337
|
+
return (
|
|
338
|
+
<SettingsCard
|
|
339
|
+
id="agents"
|
|
340
|
+
testid="settings-agents-card"
|
|
341
|
+
summaryTestid="settings-conn-agents-status"
|
|
342
|
+
icon="sparkle"
|
|
343
|
+
title="AI agents"
|
|
344
|
+
desc="Other AI on this Mac, for the AI chat."
|
|
345
|
+
summary={agentsCardSummary(agents)}
|
|
346
|
+
sw={agents.some((a) => a.id !== 'claude' && a.connected) ? 'ok' : 'off'}
|
|
347
|
+
fold={
|
|
348
|
+
foldBody
|
|
349
|
+
? {
|
|
350
|
+
panel: connectionFoldId('agents'),
|
|
351
|
+
hint: advanced.length
|
|
352
|
+
? keys.length || claude
|
|
353
|
+
? 'own API keys, agents without Maude’s limits'
|
|
354
|
+
: 'agents without Maude’s limits'
|
|
355
|
+
: 'own API keys',
|
|
356
|
+
testid: 'settings-agents-advanced',
|
|
357
|
+
body: (
|
|
358
|
+
<>
|
|
359
|
+
{keys.map((k) => (
|
|
360
|
+
<AgentKeyRow key={`key-${k.id}`} row={k} save={saveKey} remove={removeKey} />
|
|
361
|
+
))}
|
|
362
|
+
{claude ? (
|
|
363
|
+
<ClaudeApiKeyOptIn row={claude} save={saveKey} remove={removeKey} />
|
|
364
|
+
) : null}
|
|
365
|
+
{advanced.map(row)}
|
|
366
|
+
{asking ? (
|
|
367
|
+
<AgentConsent
|
|
368
|
+
row={asking}
|
|
369
|
+
onCancel={() => setAsking(null)}
|
|
370
|
+
onAllow={() => {
|
|
371
|
+
const r = asking;
|
|
372
|
+
setAsking(null);
|
|
373
|
+
void c.connect(r, { consent: true });
|
|
374
|
+
}}
|
|
375
|
+
/>
|
|
376
|
+
) : null}
|
|
377
|
+
</>
|
|
378
|
+
),
|
|
379
|
+
}
|
|
380
|
+
: undefined
|
|
381
|
+
}
|
|
382
|
+
{...card('agents')}
|
|
383
|
+
>
|
|
384
|
+
{main.length ? (
|
|
385
|
+
main.map(row)
|
|
386
|
+
) : (
|
|
387
|
+
<p className="v2s-hint">
|
|
388
|
+
Only agents that need your yes first are on this Mac. See Advanced.
|
|
389
|
+
</p>
|
|
390
|
+
)}
|
|
391
|
+
<button
|
|
392
|
+
type="button"
|
|
393
|
+
className="btn btn--ghost btn--sm"
|
|
394
|
+
onClick={() => void loadAgents({ force: true })}
|
|
395
|
+
data-testid="settings-agents-refresh"
|
|
396
|
+
>
|
|
397
|
+
Look again
|
|
398
|
+
</button>
|
|
399
|
+
</SettingsCard>
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** The card, wired to the shared agent list. */
|
|
404
|
+
export function AgentsCard({ card }) {
|
|
405
|
+
const list = useAgents();
|
|
406
|
+
const c = useAgentConnect();
|
|
407
|
+
return <AgentsCardView list={list} c={c} card={card} />;
|
|
408
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// the mask — and a Figma or provider key only ever reads as "configured".
|
|
10
10
|
|
|
11
11
|
/** The fold ids, one per connection row (registered in fold-store.js FOLD_PANELS). */
|
|
12
|
-
export const CONNECTION_ROWS = Object.freeze(['cloud', 'hub', 'github', 'ai', 'figma']);
|
|
12
|
+
export const CONNECTION_ROWS = Object.freeze(['cloud', 'hub', 'github', 'ai', 'figma', 'agents']);
|
|
13
13
|
export const connectionFoldId = (row) => `connections.${row}`;
|
|
14
14
|
|
|
15
15
|
const MASK = '••••';
|
|
@@ -23,6 +23,7 @@ import { GitHubDeviceDialog } from '../../panels/IdentityBar.jsx';
|
|
|
23
23
|
import { ProviderCard } from '../../panels/SettingsPanel.jsx';
|
|
24
24
|
import { ConnectSheet } from '../ai/ConnectSheet.jsx';
|
|
25
25
|
import { reasonProps } from '../access/disabled-reason.js';
|
|
26
|
+
import { AgentsCard } from './agents-card.jsx';
|
|
26
27
|
import { ConnField } from './connection-row.jsx';
|
|
27
28
|
import {
|
|
28
29
|
claudeRow,
|
|
@@ -173,6 +174,9 @@ export default function ConnectionsSection({ focus = null }) {
|
|
|
173
174
|
) : null}
|
|
174
175
|
</SettingsCard>
|
|
175
176
|
|
|
177
|
+
{/* Universal ACP B6 (Design Decision 2): the other AI agents on this Mac — absent with Claude only */}
|
|
178
|
+
<AgentsCard card={card} />
|
|
179
|
+
|
|
176
180
|
<SettingsCard
|
|
177
181
|
id="figma"
|
|
178
182
|
summaryTestid="settings-conn-figma-status"
|
|
@@ -21,7 +21,8 @@ export const CARDS = Object.freeze({
|
|
|
21
21
|
// a cloud tab has no This project card: the account the hub signed it in as is its own card
|
|
22
22
|
'account',
|
|
23
23
|
]),
|
|
24
|
-
|
|
24
|
+
// B6: `agents` (AI agents) is drawn only when an agent other than Claude is on this Mac
|
|
25
|
+
connections: Object.freeze(['claude', 'agents', 'figma', 'github', 'ai']),
|
|
25
26
|
advanced: Object.freeze([
|
|
26
27
|
'spend',
|
|
27
28
|
'this-mac',
|
|
@@ -499,6 +499,7 @@ export const FOLD_LABELS = Object.freeze({
|
|
|
499
499
|
'connections.github': 'Connections › GitHub › Advanced',
|
|
500
500
|
'connections.ai': 'Connections › AI images, video and voice › Advanced',
|
|
501
501
|
'connections.figma': 'Connections › Figma › Advanced',
|
|
502
|
+
'connections.agents': 'Connections › AI agents › Advanced',
|
|
502
503
|
share: 'Share › Advanced',
|
|
503
504
|
timeline: 'Timeline › Advanced',
|
|
504
505
|
export: 'Export › Advanced',
|
|
@@ -1244,6 +1244,13 @@
|
|
|
1244
1244
|
font-size: var(--type-xs);
|
|
1245
1245
|
color: var(--status-error);
|
|
1246
1246
|
}
|
|
1247
|
+
/* universal ACP B6 — one agent in Settings › Connections › AI agents (agents-card.jsx) */
|
|
1248
|
+
.v2s-agent + .v2s-agent {
|
|
1249
|
+
margin-top: var(--space-2);
|
|
1250
|
+
}
|
|
1251
|
+
.v2s-agent .v2s-hint {
|
|
1252
|
+
margin: 0;
|
|
1253
|
+
}
|
|
1247
1254
|
|
|
1248
1255
|
/* gate-b-polish2 — Look › Theme: Light · Dark · Auto (02 ob-settings), the DS `.seg` with native radios */
|
|
1249
1256
|
.v2s-seg {
|
|
@@ -32,6 +32,7 @@ export const CELL_UNSERVED = Object.freeze([
|
|
|
32
32
|
'/_api/project/undo-stack', // personal undo is this Mac's
|
|
33
33
|
'/_api/asset-state', // the per-Mac asset ledger
|
|
34
34
|
'/_api/votes', // board votes are the hub's (S9.13)
|
|
35
|
+
'/_api/agents', // which AI agents this Mac has (universal ACP B6); a cell runs no local AI
|
|
35
36
|
]);
|
|
36
37
|
|
|
37
38
|
/** How long a first ask waits for `/_config` before it goes out anyway. */
|