@1agh/maude 2.2.1 → 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/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/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/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 +10 -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
package/apps/studio/acp/index.ts
CHANGED
|
@@ -38,6 +38,13 @@ import { listCanvases } from '../routes/canvas-source.ts';
|
|
|
38
38
|
import { isCanvasSource, isUnderscoreModuleRel } from '../skip-dirs.ts';
|
|
39
39
|
import { getHubRecord } from '../sync/hubs-config.ts';
|
|
40
40
|
import type { WsData } from '../ws.ts';
|
|
41
|
+
import { agentById, CLAUDE } from './agents/catalog.ts';
|
|
42
|
+
import { hasAgentConsent, recordAgentConsent } from './agents/consent.ts';
|
|
43
|
+
import { type AgentDescriptor, versionFit } from './agents/descriptor.ts';
|
|
44
|
+
import { probeAgentVersion, resolveAgentBin } from './agents/discover.ts';
|
|
45
|
+
import { agentHealth, markAgentUnavailable } from './agents/health.ts';
|
|
46
|
+
import { UnsafeLinkError } from './agents/link-scan.ts';
|
|
47
|
+
import { type AgentStateStore, createAgentStateStore } from './agents/state.ts';
|
|
41
48
|
import { type AskQueue, noteRateLimit, promptLabel } from './ask-queue.ts';
|
|
42
49
|
import { createHubWriteAudience, type WriteAudienceSource } from './audience.ts';
|
|
43
50
|
import { buildStudioBrief } from './bootstrap-brief.ts';
|
|
@@ -45,12 +52,19 @@ import { AcpBridge, type BridgeUsage } from './bridge.ts';
|
|
|
45
52
|
import { shellOpensWindow, shellOutlivesCall } from './design-write-verb.ts';
|
|
46
53
|
import { type AiMay, parseMay } from './may-scope.ts';
|
|
47
54
|
import { isNativePluginContext, resolveSessionPlugins } from './plugin-bootstrap.ts';
|
|
55
|
+
import { createBridgeGate } from './policy/bridge-gate.ts';
|
|
48
56
|
import { probeAcpAvailability } from './probe.ts';
|
|
49
57
|
import { registerActivityProbe, registerRunningChatsProbe } from './running.ts';
|
|
50
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
linkChatCanvas,
|
|
60
|
+
noteChatArtboards,
|
|
61
|
+
readChatLinesAfter,
|
|
62
|
+
readChatMeta,
|
|
63
|
+
writeChatMeta,
|
|
64
|
+
} from './transcript.ts';
|
|
51
65
|
|
|
52
66
|
/**
|
|
53
|
-
* Browser → server frames: `{ t: 'attach', chat, seq }` (Addendum Task 8 — bind
|
|
67
|
+
* Browser → server frames: `{ t: 'attach', chat, seq, agent?, consent? }` (Addendum Task 8 — bind
|
|
54
68
|
* this socket to the chat's possibly-already-running bridge and replay the
|
|
55
69
|
* transcript lines after `seq`, which is what the client hydrated over HTTP),
|
|
56
70
|
* `{ t: 'prompt', text, chat?, model?, effort?, mode?, may? }`,
|
|
@@ -80,6 +94,21 @@ import { linkChatCanvas, noteChatArtboards, readChatLinesAfter } from './transcr
|
|
|
80
94
|
* Every `update` frame carries a `seq` — its transcript line — so a client can
|
|
81
95
|
* join the live stream to the history it hydrated without duplicating or
|
|
82
96
|
* dropping output (see `transcript.ts`'s "re-attach seam").
|
|
97
|
+
*
|
|
98
|
+
* B3 (universal ACP, DDR-252) — which agent a chat runs. `attach` / `prompt` / `warm` may carry
|
|
99
|
+
* `agent` (a catalog id, default `claude`) and `consent: true`. A chat records its agent at its
|
|
100
|
+
* first attach (`_chat/<id>.meta.json` `agent`) and keeps it; a chat with history and no record is
|
|
101
|
+
* a Claude chat. Refusals are `error` frames with a `code`:
|
|
102
|
+
* `agent-unknown` (no such agent) · `agent-switch-refused` (`agent` = the chat's, `requested`) ·
|
|
103
|
+
* `agent-needs-consent` (an 'unrestricted' agent this project has no yes for; resend with
|
|
104
|
+
* `consent: true` — refused on a read-only socket) · `agent-unavailable` (its policy did not hold
|
|
105
|
+
* earlier this run) · `agent-policy-violated` (the tripwire ended this chat's session) ·
|
|
106
|
+
* `agent-unsafe-link` (S3: an agent that judges reads by its own permission engine was not
|
|
107
|
+
* started — the project holds a link out of the folders AI may read; `link` names it).
|
|
108
|
+
* Frames of a non-Claude chat carry `agent: { id, label, vendor, statusUrl? }` on `error`; a turn a
|
|
109
|
+
* Maude refusal ended is `{ t: 'turn-end', stopReason, reason: 'refused', notice }`; an "AI may"
|
|
110
|
+
* restart that could not keep the session sends `{ t: 'agent-note', chat, kind, message }`.
|
|
111
|
+
* `attached` carries `agent: { id, label, vendor }`.
|
|
83
112
|
*/
|
|
84
113
|
export interface Acp {
|
|
85
114
|
onOpen(ws: ServerWebSocket<WsData>): void;
|
|
@@ -142,6 +171,29 @@ export interface AcpOptions {
|
|
|
142
171
|
* the linked hub's canvas grants over this project's closure (`projectWriteAudience`).
|
|
143
172
|
*/
|
|
144
173
|
writeAudience?: WriteAudienceSource;
|
|
174
|
+
/** B3 — tests only: the agent catalog lookup, binary discovery and the consent file. */
|
|
175
|
+
agents?: {
|
|
176
|
+
byId?: (id: string) => AgentDescriptor | undefined;
|
|
177
|
+
resolveBin?: (d: AgentDescriptor) => string | null;
|
|
178
|
+
consentFile?: string;
|
|
179
|
+
/** The profile's "connected" records (default: this profile's `agents.json`). */
|
|
180
|
+
store?: AgentStateStore;
|
|
181
|
+
/** The version `realBin` reports now (default: discovery's cached probe). */
|
|
182
|
+
version?: (d: AgentDescriptor, realBin: string) => Promise<string | null>;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** B3 — who an error came from, for a non-Claude agent ("Codex reported: …"). */
|
|
187
|
+
export function agentAttribution(
|
|
188
|
+
d: AgentDescriptor
|
|
189
|
+
): { id: string; label: string; vendor: string; statusUrl?: string } | undefined {
|
|
190
|
+
if (d.policy === 'claude-meta') return undefined;
|
|
191
|
+
return {
|
|
192
|
+
id: d.id,
|
|
193
|
+
label: d.label,
|
|
194
|
+
vendor: d.vendor,
|
|
195
|
+
...(d.statusUrl ? { statusUrl: d.statusUrl } : {}),
|
|
196
|
+
};
|
|
145
197
|
}
|
|
146
198
|
|
|
147
199
|
/**
|
|
@@ -705,6 +757,10 @@ interface BridgeEntry {
|
|
|
705
757
|
sentRuns: Map<string, string>;
|
|
706
758
|
/** rc2-e — runs whose refused `begin` this chat was already told about (once, never again) */
|
|
707
759
|
toldRefused: Set<string>;
|
|
760
|
+
/** B3 — the agent this chat runs (fixed for the chat's life). */
|
|
761
|
+
agent: AgentDescriptor;
|
|
762
|
+
/** B3 rule 12 — the tripwire ended this bridge; its turn's own error frame is not sent. */
|
|
763
|
+
violated: boolean;
|
|
708
764
|
}
|
|
709
765
|
|
|
710
766
|
export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOptions = {}): Acp {
|
|
@@ -763,7 +819,9 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
763
819
|
function reap(entry: BridgeEntry): void {
|
|
764
820
|
if (entry.reapTimer) clearTimeout(entry.reapTimer);
|
|
765
821
|
entry.reapTimer = null;
|
|
766
|
-
|
|
822
|
+
// B3 — a bridge the tripwire ended is reaped at once; a later reap of it must not drop the
|
|
823
|
+
// chat's NEXT bridge.
|
|
824
|
+
if (bridges.get(entry.chatId) === entry) bridges.delete(entry.chatId);
|
|
767
825
|
// The agent really is gone now, so any "Claude is editing …" banner it
|
|
768
826
|
// raised must clear — unlike on a mere detach, where the banner is still
|
|
769
827
|
// TRUE (a detached-but-running turn is still editing files).
|
|
@@ -810,8 +868,206 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
810
868
|
}
|
|
811
869
|
}
|
|
812
870
|
|
|
871
|
+
const lookupAgent = (id: string) => (options.agents?.byId ?? agentById)(id);
|
|
872
|
+
const consentPlace = () => ({
|
|
873
|
+
projectRoot: ctx.paths.repoRoot,
|
|
874
|
+
...(options.agents?.consentFile ? { file: options.agents.consentFile } : {}),
|
|
875
|
+
});
|
|
876
|
+
const resolveBinFor = (d: AgentDescriptor) => (options.agents?.resolveBin ?? resolveAgentBin)(d);
|
|
877
|
+
|
|
878
|
+
// Security review 2026-11-12 (defender M4 / attacker C3) — a bridge-enforced agent other than
|
|
879
|
+
// Claude starts only when the person connected it (the profile's `agents.json`) at the version its
|
|
880
|
+
// binary reports NOW, and that version is a tested one. A chat's record (`_chat/<id>.meta.json`)
|
|
881
|
+
// is project data a clone can plant: it never starts an agent by itself.
|
|
882
|
+
let lazyAgentStore: AgentStateStore | null = null;
|
|
883
|
+
const agentStore = (): AgentStateStore => {
|
|
884
|
+
if (options.agents?.store) return options.agents.store;
|
|
885
|
+
lazyAgentStore ??= createAgentStateStore();
|
|
886
|
+
return lazyAgentStore;
|
|
887
|
+
};
|
|
888
|
+
const versionNow =
|
|
889
|
+
options.agents?.version ?? ((d: AgentDescriptor, bin: string) => probeAgentVersion(d, bin));
|
|
890
|
+
/** What the last `checkAgentVersions` found, per agent id: the binary and the version it reports. */
|
|
891
|
+
const foundVersion = new Map<string, { bin: string; version: string | null }>();
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Probe the version of every agent this request could run (asked for, live, or recorded) so the
|
|
895
|
+
* synchronous `pickAgent` can compare it. Never throws; a failed probe reads as "no version".
|
|
896
|
+
* Null when no such agent is in play (a Claude chat): the caller stays synchronous, as before.
|
|
897
|
+
*/
|
|
898
|
+
function checkAgentVersions(
|
|
899
|
+
chatId: string,
|
|
900
|
+
want: { agent?: unknown } = {}
|
|
901
|
+
): Promise<void> | null {
|
|
902
|
+
const ids = new Set<string>();
|
|
903
|
+
if (typeof want.agent === 'string') ids.add(want.agent);
|
|
904
|
+
const live = bridges.get(chatId);
|
|
905
|
+
if (live) ids.add(live.agent.id);
|
|
906
|
+
else {
|
|
907
|
+
try {
|
|
908
|
+
const recorded = readChatMeta(ctx.paths.designRoot, chatId).agent;
|
|
909
|
+
if (recorded) ids.add(recorded);
|
|
910
|
+
} catch {
|
|
911
|
+
/* no record */
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
const enforced = [...ids]
|
|
915
|
+
.map((id) => lookupAgent(id))
|
|
916
|
+
.filter((d): d is AgentDescriptor => !!d && d.policy === 'bridge-enforced');
|
|
917
|
+
if (!enforced.length) return null;
|
|
918
|
+
return Promise.all(
|
|
919
|
+
enforced.map(async (d) => {
|
|
920
|
+
const id = d.id;
|
|
921
|
+
const bin = resolveBinFor(d);
|
|
922
|
+
if (!bin) {
|
|
923
|
+
foundVersion.delete(id);
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
let version: string | null = null;
|
|
927
|
+
try {
|
|
928
|
+
version = await versionNow(d, bin);
|
|
929
|
+
} catch {
|
|
930
|
+
version = null;
|
|
931
|
+
}
|
|
932
|
+
foundVersion.set(id, { bin, version });
|
|
933
|
+
})
|
|
934
|
+
).then(() => undefined);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/** True when this bridge-enforced agent may start now (see above). */
|
|
938
|
+
function connectedNow(d: AgentDescriptor): boolean {
|
|
939
|
+
let rec: { version: string | null } | undefined;
|
|
940
|
+
try {
|
|
941
|
+
rec = agentStore().read().connected[d.id];
|
|
942
|
+
} catch {
|
|
943
|
+
return false;
|
|
944
|
+
}
|
|
945
|
+
const found = foundVersion.get(d.id);
|
|
946
|
+
const bin = resolveBinFor(d);
|
|
947
|
+
return (
|
|
948
|
+
!!rec &&
|
|
949
|
+
!!found &&
|
|
950
|
+
!!bin &&
|
|
951
|
+
found.bin === bin &&
|
|
952
|
+
!!found.version &&
|
|
953
|
+
rec.version === found.version &&
|
|
954
|
+
versionFit(d, found.version) === 'ok'
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* B3 — the agent a chat runs, or the error frame that refuses the request. The chat's own record
|
|
960
|
+
* wins (a live bridge, else `_chat/<id>.meta.json` `agent`, else Claude for a chat with history).
|
|
961
|
+
* A chat with no history yet may change agent (its idle bridge is reaped and the record rewritten);
|
|
962
|
+
* once it has history a request naming another agent is refused, never switched. An 'unrestricted' agent needs this
|
|
963
|
+
* project's consent (app-owned, `agents/consent.ts`): `consent: true` records it, except from a
|
|
964
|
+
* read-only socket. A new non-Claude chat records its agent here.
|
|
965
|
+
*/
|
|
966
|
+
function pickAgent(
|
|
967
|
+
chatId: string,
|
|
968
|
+
want: { agent?: unknown; consent?: unknown } = {}
|
|
969
|
+
): { ok: true; agent: AgentDescriptor } | { ok: false; frame: Record<string, unknown> } {
|
|
970
|
+
const refuse = (code: string, message: string, extra: Record<string, unknown> = {}) => ({
|
|
971
|
+
ok: false as const,
|
|
972
|
+
frame: { t: 'error', code, chat: chatId, message, ...extra },
|
|
973
|
+
});
|
|
974
|
+
let requested: AgentDescriptor | undefined;
|
|
975
|
+
if (want.agent !== undefined && want.agent !== null) {
|
|
976
|
+
requested = typeof want.agent === 'string' ? lookupAgent(want.agent) : undefined;
|
|
977
|
+
if (!requested) return refuse('agent-unknown', 'Maude does not know that AI agent.');
|
|
978
|
+
}
|
|
979
|
+
const live = bridges.get(chatId);
|
|
980
|
+
let recordedId: string | undefined = live?.agent.id;
|
|
981
|
+
if (!live) {
|
|
982
|
+
try {
|
|
983
|
+
recordedId = readChatMeta(ctx.paths.designRoot, chatId).agent;
|
|
984
|
+
} catch {
|
|
985
|
+
recordedId = undefined;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
const recorded = recordedId ? lookupAgent(recordedId) : undefined;
|
|
989
|
+
if (recordedId && !recorded) {
|
|
990
|
+
return refuse(
|
|
991
|
+
'agent-unknown',
|
|
992
|
+
'This chat runs an AI agent this version of Maude does not have.'
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
const hasHistory = existsSync(transcriptPathFor(chatId));
|
|
996
|
+
let current = recorded ?? (hasHistory ? (lookupAgent('claude') ?? CLAUDE) : undefined);
|
|
997
|
+
// A chat with nothing said yet may still change its agent (the picker before the first
|
|
998
|
+
// message, or Allow on a consent card): drop the idle bridge and re-record. Once the chat has
|
|
999
|
+
// history it keeps its agent for good.
|
|
1000
|
+
let switched = false;
|
|
1001
|
+
if (requested && current && requested.id !== current.id && !hasHistory) {
|
|
1002
|
+
if (live) reap(live);
|
|
1003
|
+
current = undefined;
|
|
1004
|
+
switched = true;
|
|
1005
|
+
}
|
|
1006
|
+
if (requested && current && requested.id !== current.id) {
|
|
1007
|
+
return refuse(
|
|
1008
|
+
'agent-switch-refused',
|
|
1009
|
+
`This chat runs ${current.label}. Start a new chat to use ${requested.label}.`,
|
|
1010
|
+
{ agent: current.id, requested: requested.id }
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
const agent = current ?? requested ?? CLAUDE;
|
|
1014
|
+
if (agent.policy === 'claude-meta') {
|
|
1015
|
+
// A chat switched back to Claude before its first message drops the old record.
|
|
1016
|
+
if (switched) {
|
|
1017
|
+
try {
|
|
1018
|
+
writeChatMeta(ctx.paths.designRoot, chatId, { agent: agent.id });
|
|
1019
|
+
} catch {
|
|
1020
|
+
/* a read-only _chat/: the live bridge still holds the agent for this server run */
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return { ok: true, agent };
|
|
1024
|
+
}
|
|
1025
|
+
const health = agentHealth(agent.id);
|
|
1026
|
+
if (!health.available) {
|
|
1027
|
+
return refuse(
|
|
1028
|
+
'agent-unavailable',
|
|
1029
|
+
`${agent.label} is unavailable: Maude stopped it earlier because its policy did not hold.`,
|
|
1030
|
+
{ agent: agentAttribution(agent), reason: health.reason }
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
if (agent.policy === 'bridge-enforced' && !connectedNow(agent)) {
|
|
1034
|
+
return refuse(
|
|
1035
|
+
'agent-not-connected',
|
|
1036
|
+
`${agent.label} is not connected at the version installed on this Mac. Connect it in Settings › Connections › AI agents.`,
|
|
1037
|
+
{ agent: agentAttribution(agent) }
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
if (agent.policy === 'unrestricted') {
|
|
1041
|
+
let consented = false;
|
|
1042
|
+
try {
|
|
1043
|
+
consented = hasAgentConsent(consentPlace(), agent.id);
|
|
1044
|
+
if (!consented && want.consent === true && !readOnlyNow()) {
|
|
1045
|
+
recordAgentConsent(consentPlace(), agent.id);
|
|
1046
|
+
consented = true;
|
|
1047
|
+
}
|
|
1048
|
+
} catch {
|
|
1049
|
+
consented = false;
|
|
1050
|
+
}
|
|
1051
|
+
if (!consented) {
|
|
1052
|
+
return refuse(
|
|
1053
|
+
'agent-needs-consent',
|
|
1054
|
+
`Maude cannot confine ${agent.label} in this project. Allow it here first.`,
|
|
1055
|
+
{ agent: agentAttribution(agent) }
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
if (switched || (!live && !recordedId)) {
|
|
1060
|
+
try {
|
|
1061
|
+
writeChatMeta(ctx.paths.designRoot, chatId, { agent: agent.id });
|
|
1062
|
+
} catch {
|
|
1063
|
+
/* a read-only _chat/: the live bridge still holds the agent for this server run */
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return { ok: true, agent };
|
|
1067
|
+
}
|
|
1068
|
+
|
|
813
1069
|
/** Get-or-create the per-CHAT bridge, wiring its update/permission/command sinks. */
|
|
814
|
-
function getOrCreateEntry(chatId: string): BridgeEntry | null {
|
|
1070
|
+
function getOrCreateEntry(chatId: string, agent: AgentDescriptor = CLAUDE): BridgeEntry | null {
|
|
815
1071
|
const existing = bridges.get(chatId);
|
|
816
1072
|
if (existing) return existing;
|
|
817
1073
|
// A3 — before minting a new bridge (and with it a `claude` process stack),
|
|
@@ -847,8 +1103,35 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
847
1103
|
runId: null,
|
|
848
1104
|
sentRuns: new Map(),
|
|
849
1105
|
toldRefused: new Set(),
|
|
1106
|
+
agent,
|
|
1107
|
+
violated: false,
|
|
850
1108
|
};
|
|
1109
|
+
// B3 — Claude's bridge options stay exactly as before; another agent gets its descriptor, its
|
|
1110
|
+
// real binary, the bridge gate and the CLI flavour of the brief, and no Claude plugins.
|
|
1111
|
+
const claude = agent.policy === 'claude-meta';
|
|
851
1112
|
entry.bridge = new AcpBridge({
|
|
1113
|
+
...(claude
|
|
1114
|
+
? {}
|
|
1115
|
+
: {
|
|
1116
|
+
agent,
|
|
1117
|
+
agentBin: resolveBinFor(agent) ?? undefined,
|
|
1118
|
+
permissionGate: createBridgeGate(agent),
|
|
1119
|
+
onPolicyViolation: (reason: string) => {
|
|
1120
|
+
entry.violated = true;
|
|
1121
|
+
markAgentUnavailable(agent.id, reason);
|
|
1122
|
+
broadcast(entry, {
|
|
1123
|
+
t: 'error',
|
|
1124
|
+
code: 'agent-policy-violated',
|
|
1125
|
+
chat: chatId,
|
|
1126
|
+
agent: agentAttribution(agent),
|
|
1127
|
+
reason,
|
|
1128
|
+
message: `Maude stopped ${agent.label}: it did something its Maude policy does not allow. It stays off until Maude restarts.`,
|
|
1129
|
+
});
|
|
1130
|
+
reap(entry);
|
|
1131
|
+
},
|
|
1132
|
+
onNote: (note: { kind: string; message: string }) =>
|
|
1133
|
+
broadcast(entry, { t: 'agent-note', chat: chatId, ...note }),
|
|
1134
|
+
}),
|
|
852
1135
|
// V2-1.15 §5.4 — the adapter carries MAUDE_CHAT_ID=<this chat> (the hook's run binding).
|
|
853
1136
|
chatId,
|
|
854
1137
|
// S5.10 — a folder AI may read is never a write path (acp/write-scope `read-only-grant`).
|
|
@@ -884,13 +1167,15 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
884
1167
|
// that plainly instead of hedging. (`/flow:*` is intentionally excluded
|
|
885
1168
|
// from the chat for now — 2026-07-03.)
|
|
886
1169
|
commandsAvailable: isNativePluginContext(),
|
|
1170
|
+
// B4 — a non-Claude agent's Maude commands are the `maude design` CLI.
|
|
1171
|
+
...(claude ? {} : { agentCli: true }),
|
|
887
1172
|
}),
|
|
888
1173
|
// DDR-143 — session-scoped `design` auto-load for the zero-install desktop
|
|
889
1174
|
// path (`/flow` auto-load disabled for now — 2026-07-03). Empty on the
|
|
890
1175
|
// power-user (already-installed) + web-serve no-op paths. Computed once
|
|
891
1176
|
// here; carried on the readonly bridge options so it survives an adapter
|
|
892
1177
|
// re-spawn (model/effort change).
|
|
893
|
-
plugins: resolveSessionPlugins(),
|
|
1178
|
+
plugins: claude ? resolveSessionPlugins() : undefined,
|
|
894
1179
|
// S5.6 (D7) — Needs you waits while a socket is attached; a detached bridge still denies
|
|
895
1180
|
// once nobody has watched it for the full timeout (a never-attached one counts from birth).
|
|
896
1181
|
detachedFor: () =>
|
|
@@ -930,6 +1215,9 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
930
1215
|
// bridge validates a response against this SAME set, so the client
|
|
931
1216
|
// is being shown the real option set, not a cosmetic subset.
|
|
932
1217
|
options: req.options,
|
|
1218
|
+
// Universal ACP (Design Decision 5) — who asks: a non-Claude agent's label for the card's words;
|
|
1219
|
+
// absent for Claude (agentAttribution → undefined), whose card reads as before.
|
|
1220
|
+
agent: agentAttribution(entry.agent),
|
|
933
1221
|
// Present ONLY when the write-path gate judged a write tool and
|
|
934
1222
|
// declined it — carries the RESOLVED absolute path(s) so the card
|
|
935
1223
|
// can name what will actually be written rather than echoing the
|
|
@@ -976,7 +1264,19 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
976
1264
|
latestCommands = commands;
|
|
977
1265
|
broadcast(entry, { t: 'commands', commands });
|
|
978
1266
|
},
|
|
979
|
-
|
|
1267
|
+
// F3 — `agent` names which agent the roster belongs to (additive; the picker lists only
|
|
1268
|
+
// the modes its descriptor allows — the bridge filters refused ones out, rule 10).
|
|
1269
|
+
onCaps: (modes, configOptions) =>
|
|
1270
|
+
broadcast(entry, {
|
|
1271
|
+
t: 'caps',
|
|
1272
|
+
modes,
|
|
1273
|
+
configOptions,
|
|
1274
|
+
agent: entry.bridge?.agentInfo,
|
|
1275
|
+
// The modes the picker may list (rule 10); Claude's frame stays as before.
|
|
1276
|
+
...(agent.enforcement?.pinMode && modes
|
|
1277
|
+
? { allowedModes: modes.availableModes.map((m) => m.id) }
|
|
1278
|
+
: {}),
|
|
1279
|
+
}),
|
|
980
1280
|
onSessionInfo: (info) => broadcast(entry, { t: 'session-info', ...info }),
|
|
981
1281
|
// Issue #177 — the live background tasks (chrome, like caps: replayed on attach, never transcripted).
|
|
982
1282
|
onBackground: (tasks) => broadcast(entry, { t: 'background', tasks }),
|
|
@@ -998,8 +1298,18 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
998
1298
|
* detached. Re-attaching cancels the reaper, which is what makes a page
|
|
999
1299
|
* reload a no-op for a running turn instead of a kill.
|
|
1000
1300
|
*/
|
|
1001
|
-
function attach(
|
|
1002
|
-
|
|
1301
|
+
function attach(
|
|
1302
|
+
ws: ServerWebSocket<WsData>,
|
|
1303
|
+
chatId: string,
|
|
1304
|
+
want: { agent?: unknown; consent?: unknown } = {}
|
|
1305
|
+
): BridgeEntry | 'refused' | null {
|
|
1306
|
+
// B3 — which agent this chat runs; a refusal is its own error frame (the caller stops there).
|
|
1307
|
+
const pick = pickAgent(chatId, want);
|
|
1308
|
+
if (!pick.ok) {
|
|
1309
|
+
send(ws, pick.frame);
|
|
1310
|
+
return 'refused';
|
|
1311
|
+
}
|
|
1312
|
+
const entry = getOrCreateEntry(chatId, pick.agent);
|
|
1003
1313
|
if (!entry) return null;
|
|
1004
1314
|
entry.sinks.add(ws);
|
|
1005
1315
|
entry.detachedSince = 0;
|
|
@@ -1092,6 +1402,7 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1092
1402
|
entry.tracker?.beginTurn?.(text, runId);
|
|
1093
1403
|
let turnOutcome: 'done' | 'failed' = 'failed';
|
|
1094
1404
|
let stopReason: string | null = null;
|
|
1405
|
+
let refusal: string | undefined;
|
|
1095
1406
|
try {
|
|
1096
1407
|
await bridge.ensureStarted();
|
|
1097
1408
|
if (runId && runs) {
|
|
@@ -1102,17 +1413,31 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1102
1413
|
return;
|
|
1103
1414
|
}
|
|
1104
1415
|
}
|
|
1105
|
-
({ stopReason } = await bridge.prompt(text, entry.chatId));
|
|
1416
|
+
({ stopReason, refusal } = await bridge.prompt(text, entry.chatId));
|
|
1106
1417
|
// Only a turn that ended on its own publishes; a cancel, a refusal or a
|
|
1107
1418
|
// token limit leaves its edits for the person (T16).
|
|
1108
1419
|
if (stopReason === 'end_turn') turnOutcome = 'done';
|
|
1109
1420
|
broadcast(entry, { t: 'connected', sessionId: bridge.sessionId });
|
|
1110
|
-
|
|
1421
|
+
// B3 rule 13 — a turn a Maude refusal ended says why ("Codex stopped: Maude refused …").
|
|
1422
|
+
broadcast(
|
|
1423
|
+
entry,
|
|
1424
|
+
refusal
|
|
1425
|
+
? { t: 'turn-end', stopReason, reason: 'refused', notice: refusal }
|
|
1426
|
+
: { t: 'turn-end', stopReason }
|
|
1427
|
+
);
|
|
1111
1428
|
} catch (err) {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1429
|
+
// B3 — the tripwire already said why this turn ended (`agent-policy-violated`).
|
|
1430
|
+
if (!entry.violated) {
|
|
1431
|
+
const attribution = agentAttribution(entry.agent);
|
|
1432
|
+
broadcast(entry, {
|
|
1433
|
+
t: 'error',
|
|
1434
|
+
message: err instanceof Error ? err.message : String(err),
|
|
1435
|
+
// S3 — the spawn refused a project with a link out of it (acp/agents/link-scan.ts).
|
|
1436
|
+
...(err instanceof UnsafeLinkError ? { code: err.code, link: err.link } : {}),
|
|
1437
|
+
// B3 — "Codex reported: …" (Claude's errors read as they always have)
|
|
1438
|
+
...(attribution ? { chat: entry.chatId, agent: attribution } : {}),
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1116
1441
|
} finally {
|
|
1117
1442
|
entry.turnActive = false;
|
|
1118
1443
|
entry.runId = null;
|
|
@@ -1124,7 +1449,7 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1124
1449
|
// The turn was the only reason a detached bridge was being kept alive; now
|
|
1125
1450
|
// that it's done, let the ordinary TTL run out rather than holding the
|
|
1126
1451
|
// subprocess indefinitely for a client that never came back.
|
|
1127
|
-
if (entry.sinks.size === 0) {
|
|
1452
|
+
if (entry.sinks.size === 0 && !entry.violated) {
|
|
1128
1453
|
if (!entry.detachedSince) entry.detachedSince = Date.now();
|
|
1129
1454
|
armReap(entry);
|
|
1130
1455
|
}
|
|
@@ -1201,7 +1526,8 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1201
1526
|
effort: string | null,
|
|
1202
1527
|
modeId: string | null,
|
|
1203
1528
|
ask: { askId?: unknown; scope?: unknown } = {},
|
|
1204
|
-
may: AiMay | null = null
|
|
1529
|
+
may: AiMay | null = null,
|
|
1530
|
+
want: { agent?: unknown; consent?: unknown } = {}
|
|
1205
1531
|
): Promise<void> {
|
|
1206
1532
|
const safeChat = sanitizeChatId(chatId);
|
|
1207
1533
|
// S5.17 G1 — a scope that was sent but names nothing inside the design root (`..`, absolute, a
|
|
@@ -1216,7 +1542,11 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1216
1542
|
});
|
|
1217
1543
|
return;
|
|
1218
1544
|
}
|
|
1219
|
-
|
|
1545
|
+
// M4 — the agent's version, probed before the sync pick (null, no await, for a Claude chat)
|
|
1546
|
+
const checking = checkAgentVersions(safeChat, want);
|
|
1547
|
+
if (checking) await checking;
|
|
1548
|
+
const entry = attach(ws, safeChat, want);
|
|
1549
|
+
if (entry === 'refused') return;
|
|
1220
1550
|
if (!entry) {
|
|
1221
1551
|
send(ws, { t: 'error', message: 'Too many chats are open. Close one and try again.' });
|
|
1222
1552
|
return;
|
|
@@ -1252,7 +1582,13 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1252
1582
|
// S5.18 (G10): the signed-in check settles first — a Mac that is not signed in keeps the prompt.
|
|
1253
1583
|
const settling = options.queue?.()?.ready();
|
|
1254
1584
|
if (settling) await settling; // only while the sign-in answer is stale: a fresh one stays synchronous
|
|
1255
|
-
const queued =
|
|
1585
|
+
const queued =
|
|
1586
|
+
options.queue?.()?.maybeQueue({
|
|
1587
|
+
chatId: safeChat,
|
|
1588
|
+
text,
|
|
1589
|
+
scope,
|
|
1590
|
+
agent: entry.bridge.agentInfo.id,
|
|
1591
|
+
}) ?? null;
|
|
1256
1592
|
if (queued && 'refused' in queued) {
|
|
1257
1593
|
send(ws, { t: 'error', code: 'not-queued', chat: safeChat, message: queued.refused });
|
|
1258
1594
|
return;
|
|
@@ -1285,7 +1621,13 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1285
1621
|
const fail = () => {
|
|
1286
1622
|
if (isLive(runs.get(rec.runId) ?? rec)) void runs.turnEnded(rec.runId, 'failed');
|
|
1287
1623
|
};
|
|
1288
|
-
const
|
|
1624
|
+
const runChat = sanitizeChatId(rec.chatId);
|
|
1625
|
+
// B3 — a registry turn runs on the chat's own agent (refused like any other frame would be).
|
|
1626
|
+
const checking = bridges.has(runChat) ? null : checkAgentVersions(runChat);
|
|
1627
|
+
if (checking) await checking;
|
|
1628
|
+
const pick = bridges.has(runChat) ? null : pickAgent(runChat);
|
|
1629
|
+
if (pick && !pick.ok) return fail();
|
|
1630
|
+
const entry = getOrCreateEntry(runChat, pick?.ok ? pick.agent : CLAUDE);
|
|
1289
1631
|
if (!entry || !text) return fail();
|
|
1290
1632
|
// D3 — a turn the registry generates by itself (a continuation, a run that waited in line,
|
|
1291
1633
|
// Keep going) is a write as much as a typed prompt: the live predicate gates it too.
|
|
@@ -1331,10 +1673,13 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1331
1673
|
model: string | null,
|
|
1332
1674
|
effort: string | null,
|
|
1333
1675
|
modeId: string | null,
|
|
1334
|
-
may: AiMay | null = null
|
|
1676
|
+
may: AiMay | null = null,
|
|
1677
|
+
want: { agent?: unknown; consent?: unknown } = {}
|
|
1335
1678
|
): Promise<void> {
|
|
1336
|
-
const
|
|
1337
|
-
if (
|
|
1679
|
+
const checking = checkAgentVersions(sanitizeChatId(chatId), want); // M4, as handlePrompt
|
|
1680
|
+
if (checking) await checking;
|
|
1681
|
+
const entry = attach(ws, sanitizeChatId(chatId), want);
|
|
1682
|
+
if (!entry || entry === 'refused') return; // at the ceiling — warm-up is best-effort
|
|
1338
1683
|
const { bridge } = entry;
|
|
1339
1684
|
bridge.setSessionStorePath(sessionStorePathFor(chatId));
|
|
1340
1685
|
bridge.setConfig(model, effort, modeId);
|
|
@@ -1382,6 +1727,14 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1382
1727
|
const entry = entryForSocket(ws, chatId);
|
|
1383
1728
|
const bridge = entry?.bridge;
|
|
1384
1729
|
if (!entry || !bridge) return;
|
|
1730
|
+
// F3 (rule 10) — a mode the agent's descriptor refuses is answered, not silently dropped.
|
|
1731
|
+
if (bridge.refusesMode(modeId)) {
|
|
1732
|
+
send(ws, {
|
|
1733
|
+
t: 'error',
|
|
1734
|
+
message: `${bridge.agentInfo.label} can't use the "${modeId}" mode in Maude.`,
|
|
1735
|
+
});
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1385
1738
|
if (!bridge.modes?.availableModes.some((m) => m.id === modeId)) return; // not advertised — reject silently
|
|
1386
1739
|
try {
|
|
1387
1740
|
await bridge.setMode(entry.chatId, modeId);
|
|
@@ -1400,6 +1753,13 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1400
1753
|
// Attachment-scoped via entryForSocket, same as handleSetMode above.
|
|
1401
1754
|
const bridge = entryForSocket(ws, chatId)?.bridge;
|
|
1402
1755
|
if (!bridge) return;
|
|
1756
|
+
if (configId === 'mode' && bridge.refusesMode(value)) {
|
|
1757
|
+
send(ws, {
|
|
1758
|
+
t: 'error',
|
|
1759
|
+
message: `${bridge.agentInfo.label} can't use the "${value}" mode in Maude.`,
|
|
1760
|
+
});
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1403
1763
|
if (!optionOffers(bridge, configId, value)) return; // not advertised — reject silently
|
|
1404
1764
|
try {
|
|
1405
1765
|
await bridge.setConfigOption(sanitizeChatId(chatId), configId, value);
|
|
@@ -1430,7 +1790,12 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1430
1790
|
return {
|
|
1431
1791
|
onOpen(ws) {
|
|
1432
1792
|
const probe = probeAcpAvailability();
|
|
1433
|
-
send(ws, {
|
|
1793
|
+
send(ws, {
|
|
1794
|
+
t: 'ready',
|
|
1795
|
+
available: probe.available,
|
|
1796
|
+
reason: probe.reason,
|
|
1797
|
+
agent: probe.agent,
|
|
1798
|
+
});
|
|
1434
1799
|
// Replay the last-known command catalogue so autocomplete is instant on a
|
|
1435
1800
|
// re-open (no re-warm needed within a dev-server lifetime).
|
|
1436
1801
|
if (latestCommands.length) send(ws, { t: 'commands', commands: latestCommands });
|
|
@@ -1465,9 +1830,16 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1465
1830
|
askId?: unknown;
|
|
1466
1831
|
scope?: unknown;
|
|
1467
1832
|
may?: unknown;
|
|
1833
|
+
agent?: unknown;
|
|
1834
|
+
consent?: unknown;
|
|
1468
1835
|
};
|
|
1469
1836
|
|
|
1470
1837
|
const chatId = typeof frame.chat === 'string' && frame.chat ? frame.chat : 'default';
|
|
1838
|
+
// B3 — which agent the chat runs (a new chat's pick; an existing chat's must match).
|
|
1839
|
+
// Security review 2026-11-12 (defender M5) — `consent` counts only on a socket the person's
|
|
1840
|
+
// own page opened (server.ts stamps `person` at the handshake); a helper's is ignored.
|
|
1841
|
+
const personSocket = 'person' in ws.data && ws.data.person === true;
|
|
1842
|
+
const want = { agent: frame.agent, consent: personSocket ? frame.consent : undefined };
|
|
1471
1843
|
|
|
1472
1844
|
// S5.6 (D3, decision v2-S5-acp-role-gate-per-frame) — the read-only gate, PER FRAME against
|
|
1473
1845
|
// the live predicate: a role that drops mid-socket refuses the very next frame. Refused:
|
|
@@ -1507,25 +1879,37 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1507
1879
|
// stretch. Replaying exactly that range is why a reload neither
|
|
1508
1880
|
// duplicates the last few seconds nor leaves a hole in them.
|
|
1509
1881
|
const safeChat = sanitizeChatId(chatId);
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
for (const line of readChatLinesAfter(ctx.paths.designRoot, safeChat, from)) {
|
|
1517
|
-
if (line.entry.role === 'agent' && line.entry.update) {
|
|
1518
|
-
send(ws, { t: 'update', update: line.entry.update, seq: line.seq });
|
|
1882
|
+
const doAttach = () => {
|
|
1883
|
+
const entry = attach(ws, safeChat, want);
|
|
1884
|
+
if (entry === 'refused') return;
|
|
1885
|
+
if (!entry) {
|
|
1886
|
+
send(ws, { t: 'error', message: 'Too many chats are open. Close one and try again.' });
|
|
1887
|
+
return;
|
|
1519
1888
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1889
|
+
const from = typeof frame.seq === 'number' && frame.seq >= 0 ? Math.floor(frame.seq) : 0;
|
|
1890
|
+
for (const line of readChatLinesAfter(ctx.paths.designRoot, safeChat, from)) {
|
|
1891
|
+
if (line.entry.role === 'agent' && line.entry.update) {
|
|
1892
|
+
send(ws, { t: 'update', update: line.entry.update, seq: line.seq });
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
// Tells the client whether it re-joined a LIVE turn (so it can restore
|
|
1896
|
+
// the busy state) rather than a finished one. Without this a reload
|
|
1897
|
+
// mid-turn would look idle while the agent kept working.
|
|
1898
|
+
send(ws, {
|
|
1899
|
+
t: 'attached',
|
|
1900
|
+
chat: safeChat,
|
|
1901
|
+
running: entry.turnActive,
|
|
1902
|
+
agent: entry.bridge.agentInfo,
|
|
1903
|
+
});
|
|
1904
|
+
// Issue #177 — what is still running in the background (a reload must not hide it).
|
|
1905
|
+
send(ws, { t: 'background', tasks: entry.bridge.backgroundTasks });
|
|
1906
|
+
entry.sentRuns.clear(); // a re-attached client gets the chat's live runs again
|
|
1907
|
+
pushRunFrames(entry);
|
|
1908
|
+
};
|
|
1909
|
+
// M4 — a bridge-enforced agent's version is probed first; a Claude chat attaches at once.
|
|
1910
|
+
const checking = checkAgentVersions(safeChat, want);
|
|
1911
|
+
if (checking) void checking.then(doAttach);
|
|
1912
|
+
else doAttach();
|
|
1529
1913
|
} else if (frame.t === 'prompt' && typeof frame.text === 'string') {
|
|
1530
1914
|
void handlePrompt(
|
|
1531
1915
|
ws,
|
|
@@ -1535,10 +1919,11 @@ export function createAcp(ctx: Context, aiActivity?: AiActivity, options: AcpOpt
|
|
|
1535
1919
|
effort,
|
|
1536
1920
|
modeId,
|
|
1537
1921
|
{ askId: frame.askId, scope: frame.scope },
|
|
1538
|
-
may
|
|
1922
|
+
may,
|
|
1923
|
+
want
|
|
1539
1924
|
);
|
|
1540
1925
|
} else if (frame.t === 'warm') {
|
|
1541
|
-
void handleWarm(ws, chatId, model, effort, modeId, may);
|
|
1926
|
+
void handleWarm(ws, chatId, model, effort, modeId, may, want);
|
|
1542
1927
|
} else if (frame.t === 'cancel') {
|
|
1543
1928
|
// RC5 — a cancelled turn may never resolve prompt(); clear banners now.
|
|
1544
1929
|
const entry = entryForSocket(ws, typeof frame.chat === 'string' ? frame.chat : undefined);
|