@agentclientprotocol/claude-agent-acp 0.109.1-preview.6 → 0.109.1-preview.7
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/dist/acp-subagents.d.ts +39 -0
- package/dist/acp-subagents.d.ts.map +1 -1
- package/dist/acp-subagents.js +47 -0
- package/dist/native-subagents.d.ts +16 -6
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +72 -13
- package/dist/subagent-replay.d.ts +49 -33
- package/dist/subagent-replay.d.ts.map +1 -1
- package/dist/subagent-replay.js +49 -52
- package/dist/v1/acp-agent.d.ts +28 -8
- package/dist/v1/acp-agent.d.ts.map +1 -1
- package/dist/v1/acp-agent.js +49 -27
- package/dist/v1/client-connection.d.ts +4 -2
- package/dist/v1/client-connection.d.ts.map +1 -1
- package/dist/v1/client-connection.js +6 -2
- package/dist/v2/agent.js +39 -17
- package/dist/v2/replay-hold.d.ts +15 -5
- package/dist/v2/replay-hold.d.ts.map +1 -1
- package/dist/v2/replay-hold.js +21 -7
- package/dist/v2/subagent-replay.d.ts +20 -18
- package/dist/v2/subagent-replay.d.ts.map +1 -1
- package/dist/v2/subagent-replay.js +16 -31
- package/dist/v2/tasks.d.ts +27 -2
- package/dist/v2/tasks.d.ts.map +1 -1
- package/dist/v2/tasks.js +40 -4
- package/package.json +1 -1
package/dist/v2/agent.js
CHANGED
|
@@ -18,7 +18,7 @@ import { deleteSession, getSessionMessages, listSessions, query, } from "@anthro
|
|
|
18
18
|
import packageJson from "../../package.json" with { type: "json" };
|
|
19
19
|
import { messageIdForGrouping } from "../sdk-to-acp.js";
|
|
20
20
|
import { customAgents } from "../session-config-options.js";
|
|
21
|
-
import { restrictedChild } from "../acp-subagents.js";
|
|
21
|
+
import { AnnouncedChildren, restrictedChild } from "../acp-subagents.js";
|
|
22
22
|
import { claudeCliPath, cliDelivery } from "../claude-cli.js";
|
|
23
23
|
import { clientSystemPrompt, sessionSystemPrompt } from "../client-system-prompt.js";
|
|
24
24
|
import { forkSession } from "../fork-session.js";
|
|
@@ -126,6 +126,12 @@ class V2Agent {
|
|
|
126
126
|
* session whose query ended, keep the record.
|
|
127
127
|
*/
|
|
128
128
|
promptKeys = new Map();
|
|
129
|
+
/**
|
|
130
|
+
* The subagent sessions that the sessions announced, from each one's
|
|
131
|
+
* `subagent_update` to the `session/close` of its root or the end of the
|
|
132
|
+
* connection (see `AnnouncedChildren`).
|
|
133
|
+
*/
|
|
134
|
+
children = new AnnouncedChildren();
|
|
129
135
|
translator = new V2UpdateTranslator();
|
|
130
136
|
auth;
|
|
131
137
|
/** The `--hide-claude-auth` subscription guard (see `subscription-guard.ts`). */
|
|
@@ -171,6 +177,8 @@ class V2Agent {
|
|
|
171
177
|
// --- SessionConnection ---------------------------------------------------
|
|
172
178
|
/** Sends the update, after the `replay_complete` of a replay that holds it (see {@link heldBy}). */
|
|
173
179
|
send(notification) {
|
|
180
|
+
// Before the client can name the child that a `subagent_update` announces.
|
|
181
|
+
this.children.sending(notification);
|
|
174
182
|
const send = () => {
|
|
175
183
|
this.ctx.notify(v2.methods.client.session.update, notification).catch((error) => {
|
|
176
184
|
this.logger.error(`Failed to send a ${notification.update.sessionUpdate} update:`, error);
|
|
@@ -180,7 +188,7 @@ class V2Agent {
|
|
|
180
188
|
if (held === undefined)
|
|
181
189
|
send();
|
|
182
190
|
else
|
|
183
|
-
this.replays.defer(held, send);
|
|
191
|
+
this.replays.defer(held, send, notification.sessionId);
|
|
184
192
|
}
|
|
185
193
|
/**
|
|
186
194
|
* The session whose replay holds what the session `sessionId` sends now
|
|
@@ -202,14 +210,14 @@ class V2Agent {
|
|
|
202
210
|
*/
|
|
203
211
|
afterReplay(sessionId, signal, send) {
|
|
204
212
|
const held = sessionId === undefined ? undefined : this.heldBy(sessionId);
|
|
205
|
-
if (held === undefined)
|
|
213
|
+
if (sessionId === undefined || held === undefined)
|
|
206
214
|
return send();
|
|
207
215
|
return new Promise((resolve, reject) => this.replays.defer(held, () => {
|
|
208
216
|
if (signal.aborted)
|
|
209
217
|
reject(new Error("The request was withdrawn"));
|
|
210
218
|
else
|
|
211
219
|
send().then(resolve, reject);
|
|
212
|
-
}));
|
|
220
|
+
}, sessionId));
|
|
213
221
|
}
|
|
214
222
|
requestPermission(request, signal) {
|
|
215
223
|
// Aborting `signal` sends `$/cancel_request`, and stops waiting for the answer.
|
|
@@ -322,7 +330,7 @@ class V2Agent {
|
|
|
322
330
|
* with.
|
|
323
331
|
*/
|
|
324
332
|
async forkSession(params) {
|
|
325
|
-
if (this.
|
|
333
|
+
if (this.children.has(params.sessionId))
|
|
326
334
|
throw restrictedChild(params.sessionId, "fork");
|
|
327
335
|
// Rejects bad `configOptions`, a bad `cwd` or MCP server before the transcript is copied.
|
|
328
336
|
const initial = initialConfigRequests(params.sessionId, params.configOptions);
|
|
@@ -373,7 +381,7 @@ class V2Agent {
|
|
|
373
381
|
if (replayFrom != null && replayFrom.type !== "start") {
|
|
374
382
|
throw RequestError.invalidParams({ replayFrom }, `Replaying from a ${replayFrom.type} cursor is not supported`);
|
|
375
383
|
}
|
|
376
|
-
if (this.
|
|
384
|
+
if (this.children.has(sessionId))
|
|
377
385
|
throw restrictedChild(sessionId, "resume");
|
|
378
386
|
const initial = initialConfigRequests(sessionId, params.configOptions);
|
|
379
387
|
// No await before it: nothing of the session goes out between the request and the hold.
|
|
@@ -466,7 +474,10 @@ class V2Agent {
|
|
|
466
474
|
* subagents (`subagents`), and ends the replay: each replayed child's
|
|
467
475
|
* `replay_complete` (see `SubagentReplay.finish`), then the session's. An
|
|
468
476
|
* AIR client that declared `loadReplayEnd` gets AIR's own mark after it.
|
|
469
|
-
*
|
|
477
|
+
* Then each live child that the history did not have is announced again and
|
|
478
|
+
* gets its `replay_complete` (see `SessionTasks.unreplayedChildren`), ahead
|
|
479
|
+
* of what the replay held of it. All in one synchronous step, as
|
|
480
|
+
* `ReplayHolds.replay` requires.
|
|
470
481
|
*/
|
|
471
482
|
replay(session, messages, subagents) {
|
|
472
483
|
const { sessionId } = session;
|
|
@@ -477,6 +488,9 @@ class V2Agent {
|
|
|
477
488
|
const end = replayEndUpdate(this.clientCapabilities);
|
|
478
489
|
if (end)
|
|
479
490
|
this.send({ sessionId, update: end });
|
|
491
|
+
const unreplayed = session.tasks.unreplayedChildren((child) => subagents?.announced(child) === true, this.replays.senders(sessionId));
|
|
492
|
+
for (const notification of unreplayed)
|
|
493
|
+
this.send(notification);
|
|
480
494
|
});
|
|
481
495
|
}
|
|
482
496
|
async listSessions(params) {
|
|
@@ -521,7 +535,7 @@ class V2Agent {
|
|
|
521
535
|
const session = this.sessions.get(sessionId);
|
|
522
536
|
if (session)
|
|
523
537
|
return { status: "open", state: session.statusState() };
|
|
524
|
-
if (this.
|
|
538
|
+
if (this.children.has(sessionId))
|
|
525
539
|
throw restrictedChild(sessionId, "ask the status of");
|
|
526
540
|
return savedSessionStatus(sessionId);
|
|
527
541
|
}
|
|
@@ -550,7 +564,7 @@ class V2Agent {
|
|
|
550
564
|
};
|
|
551
565
|
let session;
|
|
552
566
|
if (sessionId != null) {
|
|
553
|
-
if (this.
|
|
567
|
+
if (this.children.has(sessionId))
|
|
554
568
|
throw restrictedChild(sessionId, "read the options of");
|
|
555
569
|
// A restart or a resume that runs makes the session active.
|
|
556
570
|
await this.restarts.settled(sessionId);
|
|
@@ -587,7 +601,7 @@ class V2Agent {
|
|
|
587
601
|
}
|
|
588
602
|
/** Closing is idempotent: a session that is not active closes at once. */
|
|
589
603
|
async closeSession({ sessionId }) {
|
|
590
|
-
if (this.
|
|
604
|
+
if (this.children.has(sessionId))
|
|
591
605
|
throw restrictedChild(sessionId, "close");
|
|
592
606
|
// A restart that runs ends first, so the close ends the session it started.
|
|
593
607
|
await this.restarts.closing(sessionId);
|
|
@@ -607,11 +621,13 @@ class V2Agent {
|
|
|
607
621
|
this.guard.sessionEnded(sessionId);
|
|
608
622
|
}
|
|
609
623
|
this.restarts.closed(sessionId);
|
|
624
|
+
// After the close's last updates, which name the session's children.
|
|
625
|
+
this.children.rootClosed(sessionId);
|
|
610
626
|
return {};
|
|
611
627
|
}
|
|
612
628
|
/** Deleting a session that does not exist succeeds, as v2 asks. */
|
|
613
629
|
async deleteSession({ sessionId }) {
|
|
614
|
-
if (this.
|
|
630
|
+
if (this.children.has(sessionId))
|
|
615
631
|
throw restrictedChild(sessionId, "delete");
|
|
616
632
|
// A resume that runs, or its start, may make the session live.
|
|
617
633
|
await this.setupSettled(sessionId);
|
|
@@ -639,7 +655,7 @@ class V2Agent {
|
|
|
639
655
|
async setTitle(params) {
|
|
640
656
|
const request = parseRenameSessionRequest(params);
|
|
641
657
|
const { sessionId } = request;
|
|
642
|
-
if (this.
|
|
658
|
+
if (this.children.has(sessionId))
|
|
643
659
|
throw restrictedChild(sessionId, "retitle");
|
|
644
660
|
// Renamed through the query that runs once a restart or resume settled.
|
|
645
661
|
await this.restarts.settled(sessionId);
|
|
@@ -671,7 +687,7 @@ class V2Agent {
|
|
|
671
687
|
const session = this.sessions.get(sessionId);
|
|
672
688
|
if (session)
|
|
673
689
|
return session;
|
|
674
|
-
if (this.
|
|
690
|
+
if (this.children.has(sessionId))
|
|
675
691
|
throw restrictedChild(sessionId, method);
|
|
676
692
|
throw this.inactive(sessionId);
|
|
677
693
|
}
|
|
@@ -694,18 +710,24 @@ class V2Agent {
|
|
|
694
710
|
/** `terminal/cancel` and `tool_call/cancel`: stops a listed item of a session or a child. */
|
|
695
711
|
async cancelItem(sessionId, target) {
|
|
696
712
|
const root = this.sessions.get(sessionId) ?? this.ownerOfChild(sessionId);
|
|
697
|
-
|
|
713
|
+
// A subagent's session is known to the client also when its root's query
|
|
714
|
+
// ended: it lists nothing then.
|
|
715
|
+
if (!root && !this.children.has(sessionId))
|
|
698
716
|
throw this.inactive(sessionId);
|
|
699
|
-
if (!(await root.tasks.cancelItem(sessionId, target))) {
|
|
717
|
+
if (!root || !(await root.tasks.cancelItem(sessionId, target))) {
|
|
700
718
|
throw "terminalId" in target
|
|
701
719
|
? RequestError.invalidParams({ sessionId, terminalId: target.terminalId }, `Terminal ${target.terminalId} is not a command running in the background, so it cannot be cancelled.`)
|
|
702
720
|
: RequestError.invalidParams({ sessionId, toolCallId: target.toolCallId }, `Tool call ${target.toolCallId} is not running in the background, so it cannot be cancelled.`);
|
|
703
721
|
}
|
|
704
722
|
return {};
|
|
705
723
|
}
|
|
706
|
-
/**
|
|
724
|
+
/**
|
|
725
|
+
* The active root session that `sessionId` is a subagent session of.
|
|
726
|
+
* Undefined also for a child whose root's query ended.
|
|
727
|
+
*/
|
|
707
728
|
ownerOfChild(sessionId) {
|
|
708
|
-
|
|
729
|
+
const root = this.children.rootOf(sessionId);
|
|
730
|
+
return root === undefined ? undefined : this.sessions.get(root);
|
|
709
731
|
}
|
|
710
732
|
async dispose() {
|
|
711
733
|
await this.restarts.dispose();
|
package/dist/v2/replay-hold.d.ts
CHANGED
|
@@ -7,11 +7,16 @@
|
|
|
7
7
|
* permission request or an elicitation.
|
|
8
8
|
*
|
|
9
9
|
* The replay itself runs in one synchronous step ({@link ReplayHolds.replay}),
|
|
10
|
-
* so what a session sends during that step is its replayed history
|
|
11
|
-
* else tells
|
|
10
|
+
* so what a session sends during that step is not held: its replayed history
|
|
11
|
+
* and the `replay_complete` updates that end it. Nothing else tells that from
|
|
12
|
+
* what waits.
|
|
12
13
|
*/
|
|
13
14
|
export declare class ReplayHolds {
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* What each session with a replay in flight holds, in send order, with the
|
|
17
|
+
* count of its replays and the sessions that sent what it holds: itself and
|
|
18
|
+
* its subagent sessions.
|
|
19
|
+
*/
|
|
15
20
|
private readonly sessions;
|
|
16
21
|
/** Whether {@link replay} runs. */
|
|
17
22
|
private replaying;
|
|
@@ -27,8 +32,13 @@ export declare class ReplayHolds {
|
|
|
27
32
|
* Calling it again does nothing.
|
|
28
33
|
*/
|
|
29
34
|
begin(sessionId: string): () => void;
|
|
30
|
-
/**
|
|
31
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Runs `send`, an update or a request of the session `sender`, once the
|
|
37
|
+
* session `sessionId` no longer holds its sends (see {@link holds}).
|
|
38
|
+
*/
|
|
39
|
+
defer(sessionId: string, send: () => void, sender: string): void;
|
|
40
|
+
/** The sessions whose updates or requests the session `sessionId` holds now. */
|
|
41
|
+
senders(sessionId: string): ReadonlySet<string>;
|
|
32
42
|
/** Runs `replay`, which must send the history and its `replay_complete` before it returns. */
|
|
33
43
|
replay(replay: () => void): void;
|
|
34
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replay-hold.d.ts","sourceRoot":"","sources":["../../src/v2/replay-hold.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"replay-hold.d.ts","sourceRoot":"","sources":["../../src/v2/replay-hold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAW;IACtB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAGrB;IACJ,mCAAmC;IACnC,OAAO,CAAC,SAAS,CAAS;IAE1B,2CAA2C;IAC3C,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,mHAAmH;IACnH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIjC;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,IAAI;IAcpC;;;OAGG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAMhE,gFAAgF;IAChF,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAI/C,8FAA8F;IAC9F,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI;CAQjC"}
|
package/dist/v2/replay-hold.js
CHANGED
|
@@ -7,11 +7,16 @@
|
|
|
7
7
|
* permission request or an elicitation.
|
|
8
8
|
*
|
|
9
9
|
* The replay itself runs in one synchronous step ({@link ReplayHolds.replay}),
|
|
10
|
-
* so what a session sends during that step is its replayed history
|
|
11
|
-
* else tells
|
|
10
|
+
* so what a session sends during that step is not held: its replayed history
|
|
11
|
+
* and the `replay_complete` updates that end it. Nothing else tells that from
|
|
12
|
+
* what waits.
|
|
12
13
|
*/
|
|
13
14
|
export class ReplayHolds {
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* What each session with a replay in flight holds, in send order, with the
|
|
17
|
+
* count of its replays and the sessions that sent what it holds: itself and
|
|
18
|
+
* its subagent sessions.
|
|
19
|
+
*/
|
|
15
20
|
sessions = new Map();
|
|
16
21
|
/** Whether {@link replay} runs. */
|
|
17
22
|
replaying = false;
|
|
@@ -31,7 +36,7 @@ export class ReplayHolds {
|
|
|
31
36
|
* Calling it again does nothing.
|
|
32
37
|
*/
|
|
33
38
|
begin(sessionId) {
|
|
34
|
-
const hold = this.sessions.get(sessionId) ?? { resumes: 0, sends: [] };
|
|
39
|
+
const hold = this.sessions.get(sessionId) ?? { resumes: 0, sends: [], senders: new Set() };
|
|
35
40
|
hold.resumes++;
|
|
36
41
|
this.sessions.set(sessionId, hold);
|
|
37
42
|
let released = false;
|
|
@@ -46,9 +51,18 @@ export class ReplayHolds {
|
|
|
46
51
|
send();
|
|
47
52
|
};
|
|
48
53
|
}
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Runs `send`, an update or a request of the session `sender`, once the
|
|
56
|
+
* session `sessionId` no longer holds its sends (see {@link holds}).
|
|
57
|
+
*/
|
|
58
|
+
defer(sessionId, send, sender) {
|
|
59
|
+
const hold = this.sessions.get(sessionId);
|
|
60
|
+
hold.sends.push(send);
|
|
61
|
+
hold.senders.add(sender);
|
|
62
|
+
}
|
|
63
|
+
/** The sessions whose updates or requests the session `sessionId` holds now. */
|
|
64
|
+
senders(sessionId) {
|
|
65
|
+
return this.sessions.get(sessionId)?.senders ?? new Set();
|
|
52
66
|
}
|
|
53
67
|
/** Runs `replay`, which must send the history and its `replay_complete` before it returns. */
|
|
54
68
|
replay(replay) {
|
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
* metadata file names the Agent or Task call that launched it (see
|
|
7
7
|
* `subagentHistory`). The replay announces each child right after that call,
|
|
8
8
|
* under its live session id (the agent id), with no capabilities: it cannot
|
|
9
|
-
* run again in this process. Then it sends the child's
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* a child that handed back any report gets no reply from its launch's result.
|
|
9
|
+
* run again in this process. Then it sends the child's history to the child
|
|
10
|
+
* session. As live, the parent is not shown the launch call: its prompt is
|
|
11
|
+
* the parent's outgoing message, and a foreground child's answer its reply. A
|
|
12
|
+
* child's successful SubagentHandback call is its message to the parent
|
|
13
|
+
* instead. Unlike live, the replay does not tell runs apart, so a child that
|
|
14
|
+
* handed back any report gets no reply from its launch's result.
|
|
16
15
|
*
|
|
17
16
|
* A SendMessage call whose message the replay delivered to a child before it
|
|
18
17
|
* reached the call is that message too: the sender's outgoing view, at the
|
|
@@ -32,9 +31,12 @@
|
|
|
32
31
|
* ({@link currentStates}): on its parent and on its own stream. A child that
|
|
33
32
|
* works in the live session, on a resume of the active session, gets its
|
|
34
33
|
* current state from the resume snapshot instead
|
|
35
|
-
* (`SessionTasks.currentState`).
|
|
36
|
-
*
|
|
37
|
-
*
|
|
34
|
+
* (`SessionTasks.currentState`).
|
|
35
|
+
*
|
|
36
|
+
* The replay sends no `config_option_update` of a child: v2 asks an agent not
|
|
37
|
+
* to replay a past one. Each child's configuration goes out after the root's
|
|
38
|
+
* `replay_complete` too, following the child's current state (see
|
|
39
|
+
* `currentChildConfiguration`).
|
|
38
40
|
*
|
|
39
41
|
* A launch without metadata has no known id, so it is not announced: the RFD
|
|
40
42
|
* forbids inventing one. Its Agent call stays an ordinary tool call of the
|
|
@@ -83,6 +85,8 @@ export declare class SubagentReplay {
|
|
|
83
85
|
static load(host: ReplayHost, messages: SessionMessage[], live?: LiveChildren): Promise<SubagentReplay | undefined>;
|
|
84
86
|
/** The hooks of the replay of the root session's history (`messages`). */
|
|
85
87
|
hooks(output: SessionOutput, messages: SessionMessage[]): ReplayHooks;
|
|
88
|
+
/** Whether the replay announced the child session `sessionId`. */
|
|
89
|
+
announced(sessionId: string): boolean;
|
|
86
90
|
/**
|
|
87
91
|
* Ends the replay of the children. Every child's end goes out on its
|
|
88
92
|
* parent, whose history it is. Then each announced child gets its
|
|
@@ -104,9 +108,8 @@ export declare class SubagentReplay {
|
|
|
104
108
|
* session: its work ended, or its process is gone, so its replayed end, on
|
|
105
109
|
* its parent and on its own stream. A `cwd` that is gone, such as a
|
|
106
110
|
* worktree that Claude Code removed, is cleared. Then each replayed child's
|
|
107
|
-
* configuration
|
|
108
|
-
*
|
|
109
|
-
* list.
|
|
111
|
+
* configuration (see `currentChildConfiguration`): the live child's, else
|
|
112
|
+
* the model of its latest response, by the session's model list.
|
|
110
113
|
*
|
|
111
114
|
* The v1 core sends the same after the response (`currentStates`): on v1
|
|
112
115
|
* the response is what separates a replayed child state from a current one.
|
|
@@ -129,16 +132,15 @@ export declare class SubagentReplay {
|
|
|
129
132
|
*/
|
|
130
133
|
private route;
|
|
131
134
|
/**
|
|
132
|
-
* Before a message of `owner`'s history (the root's when undefined):
|
|
133
|
-
* child's response
|
|
134
|
-
* persisted task notification of a child is the state its work ended
|
|
135
|
+
* Before a message of `owner`'s history (the root's when undefined): the
|
|
136
|
+
* model of a child's response is its latest one (see `trackResponseModel`),
|
|
137
|
+
* and a persisted task notification of a child is the state its work ended
|
|
138
|
+
* in.
|
|
135
139
|
*/
|
|
136
140
|
private replaying;
|
|
137
141
|
/** After a message that launched children: each is announced, and its history replays. */
|
|
138
142
|
private replayed;
|
|
139
143
|
private announce;
|
|
140
|
-
/** The `model` of a response of `child`, when it is not the one the client holds. */
|
|
141
|
-
private sendModel;
|
|
142
144
|
/**
|
|
143
145
|
* The rest of a child's user message to replay, or `null` when nothing is
|
|
144
146
|
* left, after its text went out as the child's incoming `session_message`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-replay.d.ts","sourceRoot":"","sources":["../../src/v2/subagent-replay.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"subagent-replay.d.ts","sourceRoot":"","sources":["../../src/v2/subagent-replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAoBhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAG9D,iDAAiD;AACjD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,kEAAkE;IAClE,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC,yBAAyB,GAAG,IAAI,CAAC;IACvD,MAAM,IAAI,cAAc,CAAC;CAC1B;AAED,4DAA4D;AAC5D,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,yFAAy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;IAMhB,OAAO,CAAC,KAAK;CAKd"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { launchReply, linkedSessionMessages, nativeSubagentState, rfdLabels, } from "../native-subagents.js";
|
|
2
2
|
import { readSubagentMessages, subagentHistory, subagentLaunchIds, } from "../subagent-history.js";
|
|
3
|
-
import {
|
|
3
|
+
import { currentChildConfiguration, deliveredCall, isDelivery, isDirectory, missingHistoryNotice, ReplayTranscript, replayEndState, textOf, trackResponseModel, } from "../subagent-replay.js";
|
|
4
4
|
import { taskNotificationsOf } from "../task-notifications.js";
|
|
5
5
|
import { REPLAY_COMPLETE } from "./setup.js";
|
|
6
6
|
import { SessionOutput } from "./stream.js";
|
|
@@ -50,6 +50,10 @@ export class SubagentReplay {
|
|
|
50
50
|
this.transcript.scan(messages, output.sessionId);
|
|
51
51
|
return this.ownerHooks(output, undefined);
|
|
52
52
|
}
|
|
53
|
+
/** Whether the replay announced the child session `sessionId`. */
|
|
54
|
+
announced(sessionId) {
|
|
55
|
+
return this.transcript.byAgentId.get(sessionId)?.announced === true;
|
|
56
|
+
}
|
|
53
57
|
/**
|
|
54
58
|
* Ends the replay of the children. Every child's end goes out on its
|
|
55
59
|
* parent, whose history it is. Then each announced child gets its
|
|
@@ -93,9 +97,8 @@ export class SubagentReplay {
|
|
|
93
97
|
* session: its work ended, or its process is gone, so its replayed end, on
|
|
94
98
|
* its parent and on its own stream. A `cwd` that is gone, such as a
|
|
95
99
|
* worktree that Claude Code removed, is cleared. Then each replayed child's
|
|
96
|
-
* configuration
|
|
97
|
-
*
|
|
98
|
-
* list.
|
|
100
|
+
* configuration (see `currentChildConfiguration`): the live child's, else
|
|
101
|
+
* the model of its latest response, by the session's model list.
|
|
99
102
|
*
|
|
100
103
|
* The v1 core sends the same after the response (`currentStates`): on v1
|
|
101
104
|
* the response is what separates a replayed child state from a current one.
|
|
@@ -110,15 +113,13 @@ export class SubagentReplay {
|
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
sendConfiguration(child) {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const replayed = child.model ? JSON.stringify([childModelOption(child.model)]) : undefined;
|
|
116
|
-
if (!current || JSON.stringify(current) === replayed)
|
|
116
|
+
const configOptions = currentChildConfiguration(child, this.live.configuration(child.sessionId), this.host.models());
|
|
117
|
+
if (!configOptions)
|
|
117
118
|
return;
|
|
118
119
|
child.output.emitV1([
|
|
119
120
|
{
|
|
120
121
|
sessionId: child.sessionId,
|
|
121
|
-
update: { sessionUpdate: "config_option_update", configOptions
|
|
122
|
+
update: { sessionUpdate: "config_option_update", configOptions },
|
|
122
123
|
},
|
|
123
124
|
]);
|
|
124
125
|
}
|
|
@@ -203,15 +204,16 @@ export class SubagentReplay {
|
|
|
203
204
|
return [];
|
|
204
205
|
}
|
|
205
206
|
/**
|
|
206
|
-
* Before a message of `owner`'s history (the root's when undefined):
|
|
207
|
-
* child's response
|
|
208
|
-
* persisted task notification of a child is the state its work ended
|
|
207
|
+
* Before a message of `owner`'s history (the root's when undefined): the
|
|
208
|
+
* model of a child's response is its latest one (see `trackResponseModel`),
|
|
209
|
+
* and a persisted task notification of a child is the state its work ended
|
|
210
|
+
* in.
|
|
209
211
|
*/
|
|
210
212
|
replaying(message, owner) {
|
|
211
213
|
const inner = message.message;
|
|
212
214
|
if (message.type === "assistant") {
|
|
213
215
|
if (owner)
|
|
214
|
-
|
|
216
|
+
trackResponseModel(owner, inner?.model);
|
|
215
217
|
return;
|
|
216
218
|
}
|
|
217
219
|
for (const notification of taskNotificationsOf(inner?.content)) {
|
|
@@ -232,7 +234,6 @@ export class SubagentReplay {
|
|
|
232
234
|
if (messages.length === 0)
|
|
233
235
|
this.withoutHistory++;
|
|
234
236
|
this.announce(child);
|
|
235
|
-
this.sendModel(child, firstResponseModel(messages));
|
|
236
237
|
this.transcript.scan(messages, child.sessionId);
|
|
237
238
|
child.output.replay(messages, this.ownerHooks(child.output, child));
|
|
238
239
|
if (!child.promptSent && typeof child.input.prompt === "string") {
|
|
@@ -261,22 +262,6 @@ export class SubagentReplay {
|
|
|
261
262
|
});
|
|
262
263
|
child.output = new SessionOutput(child.sessionId, child.cwd ?? parentCwd, this.host.translator, (update) => this.host.send({ sessionId: child.sessionId, update }), this.host.logger, true);
|
|
263
264
|
}
|
|
264
|
-
/** The `model` of a response of `child`, when it is not the one the client holds. */
|
|
265
|
-
sendModel(child, model) {
|
|
266
|
-
const entry = responseModelEntry(model, this.host.models());
|
|
267
|
-
if (!entry || !child.output)
|
|
268
|
-
return;
|
|
269
|
-
child.responseModel = model;
|
|
270
|
-
if (child.model?.value === entry.value && child.model.name === entry.name)
|
|
271
|
-
return;
|
|
272
|
-
child.model = entry;
|
|
273
|
-
child.output.emitV1([
|
|
274
|
-
{
|
|
275
|
-
sessionId: child.sessionId,
|
|
276
|
-
update: { sessionUpdate: "config_option_update", configOptions: [childModelOption(entry)] },
|
|
277
|
-
},
|
|
278
|
-
]);
|
|
279
|
-
}
|
|
280
265
|
/**
|
|
281
266
|
* The rest of a child's user message to replay, or `null` when nothing is
|
|
282
267
|
* left, after its text went out as the child's incoming `session_message`.
|
package/dist/v2/tasks.d.ts
CHANGED
|
@@ -173,8 +173,13 @@ export declare class SessionTasks {
|
|
|
173
173
|
loadReplay(messages: SessionMessage[]): Promise<SubagentReplay | undefined>;
|
|
174
174
|
/** Whether a subagent task runs, announced or not, in the foreground or the background. */
|
|
175
175
|
hasLiveSubagents(): boolean;
|
|
176
|
-
/**
|
|
177
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Whether `sessionId` is a child session that this root announced in its
|
|
178
|
+
* current conversation. A child that only a replay announced, or one from
|
|
179
|
+
* before a conversation reset, is not: the client still knows those (see
|
|
180
|
+
* `AnnouncedChildren`).
|
|
181
|
+
*/
|
|
182
|
+
private hasChild;
|
|
178
183
|
/**
|
|
179
184
|
* The session that a permission request of the agent `agentId` goes to:
|
|
180
185
|
* its child session once it is announced, else the root. A request can
|
|
@@ -265,6 +270,26 @@ export declare class SessionTasks {
|
|
|
265
270
|
} | {
|
|
266
271
|
toolCallId: string;
|
|
267
272
|
}): Promise<boolean>;
|
|
273
|
+
/**
|
|
274
|
+
* For a resume of the active session that replays: the announcement and
|
|
275
|
+
* the `replay_complete` of each current child that the replay did not
|
|
276
|
+
* announce (`replayed`), parents first. The stored history has no launch of
|
|
277
|
+
* such a child: a forked skill's, whose metadata names no call, or a
|
|
278
|
+
* subagent that Claude launched after the history was written. Its replay
|
|
279
|
+
* is empty, so its `replay_complete` follows its announcement at once.
|
|
280
|
+
*
|
|
281
|
+
* A child is current when it works, when its parent lists it, or when the
|
|
282
|
+
* replay holds something its session sent (`held`), such as the end of a
|
|
283
|
+
* run that ended while the history was read. v2 asks for a child's
|
|
284
|
+
* announcement again on every resume, before any other update of its
|
|
285
|
+
* session, and for a `replay_complete` on every child that is announced
|
|
286
|
+
* before the response. The caller sends these after the root's
|
|
287
|
+
* `replay_complete`, where an announcement is current, and before what the
|
|
288
|
+
* replay held.
|
|
289
|
+
*/
|
|
290
|
+
unreplayedChildren(replayed: (sessionId: string) => boolean, held: ReadonlySet<string>): v2.UpdateSessionNotification[];
|
|
291
|
+
/** Whether `child` works, or its parent's `background` list (of `lists`) names it. */
|
|
292
|
+
private worksOrListed;
|
|
268
293
|
/**
|
|
269
294
|
* The current state of the session's work, for a resume of the active
|
|
270
295
|
* session: each subagent that a session lists, or that works in its
|
package/dist/v2/tasks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/v2/tasks.ts"],"names":[],"mappings":"AAuDA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACf,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EA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E,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CASlE"}
|
package/dist/v2/tasks.js
CHANGED
|
@@ -64,6 +64,7 @@ import { AcpToolCallRenderer } from "../tool-calls/renderer.js";
|
|
|
64
64
|
import { workflowCard, workflowSnapshot } from "../workflow-progress.js";
|
|
65
65
|
import { ChildConfigurations } from "./child-config.js";
|
|
66
66
|
import { SessionOutput } from "./stream.js";
|
|
67
|
+
import { REPLAY_COMPLETE } from "./setup.js";
|
|
67
68
|
import { SubagentReplay } from "./subagent-replay.js";
|
|
68
69
|
/** The tools whose structured result names the task that the call started. */
|
|
69
70
|
const TASK_TOOLS = new Set(["Monitor", "Workflow"]);
|
|
@@ -337,7 +338,12 @@ export class SessionTasks {
|
|
|
337
338
|
hasLiveSubagents() {
|
|
338
339
|
return this.agents.size > 0;
|
|
339
340
|
}
|
|
340
|
-
/**
|
|
341
|
+
/**
|
|
342
|
+
* Whether `sessionId` is a child session that this root announced in its
|
|
343
|
+
* current conversation. A child that only a replay announced, or one from
|
|
344
|
+
* before a conversation reset, is not: the client still knows those (see
|
|
345
|
+
* `AnnouncedChildren`).
|
|
346
|
+
*/
|
|
341
347
|
hasChild(sessionId) {
|
|
342
348
|
return this.children.get(sessionId)?.announced === true;
|
|
343
349
|
}
|
|
@@ -550,6 +556,38 @@ export class SessionTasks {
|
|
|
550
556
|
}
|
|
551
557
|
return true;
|
|
552
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* For a resume of the active session that replays: the announcement and
|
|
561
|
+
* the `replay_complete` of each current child that the replay did not
|
|
562
|
+
* announce (`replayed`), parents first. The stored history has no launch of
|
|
563
|
+
* such a child: a forked skill's, whose metadata names no call, or a
|
|
564
|
+
* subagent that Claude launched after the history was written. Its replay
|
|
565
|
+
* is empty, so its `replay_complete` follows its announcement at once.
|
|
566
|
+
*
|
|
567
|
+
* A child is current when it works, when its parent lists it, or when the
|
|
568
|
+
* replay holds something its session sent (`held`), such as the end of a
|
|
569
|
+
* run that ended while the history was read. v2 asks for a child's
|
|
570
|
+
* announcement again on every resume, before any other update of its
|
|
571
|
+
* session, and for a `replay_complete` on every child that is announced
|
|
572
|
+
* before the response. The caller sends these after the root's
|
|
573
|
+
* `replay_complete`, where an announcement is current, and before what the
|
|
574
|
+
* replay held.
|
|
575
|
+
*/
|
|
576
|
+
unreplayedChildren(replayed, held) {
|
|
577
|
+
const lists = this.lists();
|
|
578
|
+
return this.parentsFirst()
|
|
579
|
+
.filter((child) => !replayed(child.sessionId) &&
|
|
580
|
+
(held.has(child.sessionId) || this.worksOrListed(child, lists)))
|
|
581
|
+
.flatMap((child) => [
|
|
582
|
+
{ sessionId: child.parentSessionId, update: this.announcement(child) },
|
|
583
|
+
{ sessionId: child.sessionId, update: REPLAY_COMPLETE },
|
|
584
|
+
]);
|
|
585
|
+
}
|
|
586
|
+
/** Whether `child` works, or its parent's `background` list (of `lists`) names it. */
|
|
587
|
+
worksOrListed(child, lists) {
|
|
588
|
+
return (child.working ||
|
|
589
|
+
(lists.get(child.parentSessionId) ?? []).some((item) => item.type === "subagent" && item.sessionId === child.sessionId));
|
|
590
|
+
}
|
|
553
591
|
/**
|
|
554
592
|
* The current state of the session's work, for a resume of the active
|
|
555
593
|
* session: each subagent that a session lists, or that works in its
|
|
@@ -564,9 +602,7 @@ export class SessionTasks {
|
|
|
564
602
|
const lists = this.lists();
|
|
565
603
|
const visit = (sessionId) => {
|
|
566
604
|
const listed = lists.get(sessionId) ?? [];
|
|
567
|
-
const children = this.parentsFirst().filter((child) => child.parentSessionId === sessionId &&
|
|
568
|
-
(child.working ||
|
|
569
|
-
listed.some((item) => item.type === "subagent" && item.sessionId === child.sessionId)));
|
|
605
|
+
const children = this.parentsFirst().filter((child) => child.parentSessionId === sessionId && this.worksOrListed(child, lists));
|
|
570
606
|
for (const child of children) {
|
|
571
607
|
const state = stateObject(this.childState(child), undefined);
|
|
572
608
|
if ((lists.get(child.sessionId) ?? []).length === 0) {
|
package/package.json
CHANGED