@agentclientprotocol/claude-agent-acp 0.108.1-preview.4 → 0.108.1-preview.5
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/README.md +4 -0
- package/dist/fork-session.d.ts +7 -0
- package/dist/fork-session.d.ts.map +1 -1
- package/dist/fork-session.js +10 -0
- package/dist/v1/acp-agent.d.ts +1 -1
- package/dist/v1/acp-agent.js +1 -1
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +9 -18
- package/dist/v2/elicitation.d.ts +14 -0
- package/dist/v2/elicitation.d.ts.map +1 -1
- package/dist/v2/elicitation.js +29 -0
- package/dist/v2/subagent-replay.d.ts +34 -24
- package/dist/v2/subagent-replay.d.ts.map +1 -1
- package/dist/v2/subagent-replay.js +19 -17
- package/dist/v2/tasks.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -74,6 +74,10 @@ with replay, which `replay_complete` ends, `session/close`, `session/prompt`, `s
|
|
|
74
74
|
compaction, display terminals for commands, permission requests, elicitation, providers, auth, and
|
|
75
75
|
[subagents](docs/subagent-sessions.md). Steering is v1 only for now.
|
|
76
76
|
|
|
77
|
+
Two parts of the draft are not served yet. `session/prompt` takes an `idempotencyKey` and does not
|
|
78
|
+
use it, so a prompt that a client sends again with the same key is inserted again. The adapter
|
|
79
|
+
announces no session cursors, so `session/fork` with a `cursorId` fails with `-32602`.
|
|
80
|
+
|
|
77
81
|
v2 is served by the v2 agent in `src/v2/`, which runs straight on Claude
|
|
78
82
|
Code instead of translating to v1. A v2 client that declares JetBrains AIR
|
|
79
83
|
(`_meta.jetbrains.air`) also gets the AIR extensions that ACP v2 does not cover.
|
package/dist/fork-session.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ type ForkSessionDependencies = {
|
|
|
10
10
|
message?: unknown;
|
|
11
11
|
}) => string | undefined;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Copies the transcript of `params.sessionId` into a new session.
|
|
15
|
+
*
|
|
16
|
+
* Fails with invalid params (-32602) for a `cursorId`: the agent sends no
|
|
17
|
+
* `cursor_update`, so it issued no cursor, and ACP forbids forking the whole
|
|
18
|
+
* session in its place.
|
|
19
|
+
*/
|
|
13
20
|
export declare function forkSession(params: ForkSessionRequest, dependencies: ForkSessionDependencies): Promise<ForkSessionResponse>;
|
|
14
21
|
export {};
|
|
15
22
|
//# sourceMappingURL=fork-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-session.d.ts","sourceRoot":"","sources":["../src/fork-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,mCAAmC,CAAC;AAyB3C,KAAK,uBAAuB,GAAG;IAC7B,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;IAC/C,oBAAoB,EAAE,CAAC,OAAO,EAAE;QAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AA6IF,wBAAsB,WAAW,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,uBAAuB,GACpC,OAAO,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"fork-session.d.ts","sourceRoot":"","sources":["../src/fork-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,mCAAmC,CAAC;AAyB3C,KAAK,uBAAuB,GAAG;IAC7B,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;IAC/C,oBAAoB,EAAE,CAAC,OAAO,EAAE;QAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AA6IF;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,uBAAuB,GACpC,OAAO,CAAC,mBAAmB,CAAC,CAe9B"}
|
package/dist/fork-session.js
CHANGED
|
@@ -105,7 +105,17 @@ function isUnknownSessionError(error, sessionId) {
|
|
|
105
105
|
return (error.message === `Session ${sessionId} not found` ||
|
|
106
106
|
error.message === `Invalid sessionId: ${sessionId}`);
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Copies the transcript of `params.sessionId` into a new session.
|
|
110
|
+
*
|
|
111
|
+
* Fails with invalid params (-32602) for a `cursorId`: the agent sends no
|
|
112
|
+
* `cursor_update`, so it issued no cursor, and ACP forbids forking the whole
|
|
113
|
+
* session in its place.
|
|
114
|
+
*/
|
|
108
115
|
export async function forkSession(params, dependencies) {
|
|
116
|
+
if (params.cursorId != null) {
|
|
117
|
+
throw RequestError.invalidParams({ cursorId: params.cursorId }, `Session ${params.sessionId} has no cursor ${params.cursorId}: this agent announces no session cursors. Send the request without \`cursorId\` to fork the whole session.`);
|
|
118
|
+
}
|
|
109
119
|
try {
|
|
110
120
|
return await forkTranscript(params, dependencies);
|
|
111
121
|
}
|
package/dist/v1/acp-agent.d.ts
CHANGED
|
@@ -1501,7 +1501,7 @@ export declare class ClaudeAcpAgent {
|
|
|
1501
1501
|
*
|
|
1502
1502
|
* Call it in the same synchronous step as the handler's `return`: an
|
|
1503
1503
|
* `await` between them would let the timer run before the response. The ACP
|
|
1504
|
-
* SDK (2.
|
|
1504
|
+
* SDK (2.8.0) gives a request handler no responder and no after-response
|
|
1505
1505
|
* hook, so the order rests on two things that its source shows and its API
|
|
1506
1506
|
* does not promise. `registerAppRequest` queues the response in the
|
|
1507
1507
|
* microtask that follows the handler's return, with no macrotask in
|
package/dist/v1/acp-agent.js
CHANGED
|
@@ -7008,7 +7008,7 @@ export class ClaudeAcpAgent {
|
|
|
7008
7008
|
*
|
|
7009
7009
|
* Call it in the same synchronous step as the handler's `return`: an
|
|
7010
7010
|
* `await` between them would let the timer run before the response. The ACP
|
|
7011
|
-
* SDK (2.
|
|
7011
|
+
* SDK (2.8.0) gives a request handler no responder and no after-response
|
|
7012
7012
|
* hook, so the order rests on two things that its source shows and its API
|
|
7013
7013
|
* does not promise. `registerAppRequest` queues the response in the
|
|
7014
7014
|
* microtask that follows the handler's return, with no macrotask in
|
package/dist/v2/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAYxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAYxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA+D3C,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,8CAA8C;AAC9C,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACpC,EAAE,CAAC,QAAQ,CA6Cb"}
|
package/dist/v2/agent.js
CHANGED
|
@@ -43,6 +43,7 @@ import { airInitializeMeta, airSupport, NO_AIR } from "./air.js";
|
|
|
43
43
|
import { V2Auth } from "./auth.js";
|
|
44
44
|
import { subagentHooks } from "./child-config.js";
|
|
45
45
|
import { modelSwitchHook, SessionConfig } from "./config.js";
|
|
46
|
+
import { v2ElicitationRequest } from "./elicitation.js";
|
|
46
47
|
import { fileChangePreviewHook } from "./file-preview.js";
|
|
47
48
|
import { canUseTool, denyingStoppedWork } from "./permissions.js";
|
|
48
49
|
import { ReplayHolds } from "./replay-hold.js";
|
|
@@ -209,10 +210,10 @@ class V2Agent {
|
|
|
209
210
|
createElicitation(request, signal) {
|
|
210
211
|
// An elicitation of a request, not of a session, names no session.
|
|
211
212
|
const sessionId = request.sessionId;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
return this.afterReplay(typeof sessionId === "string" ? sessionId : undefined, signal, () => this.ctx.request(v2.methods.client.elicitation.create, v2ElicitationRequest(request), {
|
|
214
|
+
cancellationSignal: signal,
|
|
215
|
+
stopWaitingOnCancel: true,
|
|
216
|
+
}));
|
|
216
217
|
}
|
|
217
218
|
completeElicitation(params) {
|
|
218
219
|
return this.ctx.notify(v2.methods.client.elicitation.complete, params);
|
|
@@ -432,6 +433,10 @@ class V2Agent {
|
|
|
432
433
|
release?.();
|
|
433
434
|
// A notice is not history, so it follows `replay_complete`.
|
|
434
435
|
subagents?.reportMissingHistory();
|
|
436
|
+
// A `subagent_update` after its parent's `replay_complete` is current,
|
|
437
|
+
// and so is a `state_update` of the child: the replayed children's
|
|
438
|
+
// current states go out here, before the snapshot and the response.
|
|
439
|
+
subagents?.currentStates();
|
|
435
440
|
}
|
|
436
441
|
// The current title, after the replay and before the state.
|
|
437
442
|
await session.reports.publishTitle();
|
|
@@ -439,20 +444,6 @@ class V2Agent {
|
|
|
439
444
|
this.send(notification);
|
|
440
445
|
const response = await this.setupFields(session);
|
|
441
446
|
this.afterSetup(session, params);
|
|
442
|
-
// A replayed child's state that comes before the response is history to
|
|
443
|
-
// the client, also after the child's `replay_complete`: the children's
|
|
444
|
-
// current states follow the response. The ACP SDK (2.7.0)
|
|
445
|
-
// gives a request handler no responder and no after-response hook, so the
|
|
446
|
-
// order rests on two things that its source shows and its API does not
|
|
447
|
-
// promise. `registerAppRequest` queues the response in the microtask that
|
|
448
|
-
// follows this handler's return, with no macrotask in between, so the
|
|
449
|
-
// timer runs after it. And `Connection.sendMessage` writes in call order,
|
|
450
|
-
// so what the timer sends is written after the response. The timer is
|
|
451
|
-
// set in the same synchronous step as the `return`: an `await` between
|
|
452
|
-
// them would let it run first. The v1 core's `afterSetupResponse` relies
|
|
453
|
-
// on the same.
|
|
454
|
-
if (subagents)
|
|
455
|
-
setTimeout(() => subagents.afterResponse(), 0);
|
|
456
447
|
return response;
|
|
457
448
|
}
|
|
458
449
|
/**
|
package/dist/v2/elicitation.d.ts
CHANGED
|
@@ -18,10 +18,24 @@
|
|
|
18
18
|
* answers is shared with v1 (`elicitation.ts`).
|
|
19
19
|
*/
|
|
20
20
|
import type { CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse } from "@agentclientprotocol/sdk/unstable";
|
|
21
|
+
import type * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
21
22
|
import type { CanUseTool, Options, Query } from "@anthropic-ai/claude-agent-sdk";
|
|
22
23
|
import type { Logger } from "../logger.js";
|
|
23
24
|
import { type ElicitationSupport } from "../elicitation.js";
|
|
24
25
|
import type { RequestTarget } from "./tasks.js";
|
|
26
|
+
/**
|
|
27
|
+
* The v2 form of an elicitation that the shared module built in v1 types.
|
|
28
|
+
*
|
|
29
|
+
* A form's string properties go without `pattern`: v1 has the keyword, and v2
|
|
30
|
+
* removed it. Only an MCP server's schema can carry one, since it is relayed
|
|
31
|
+
* as the server sent it. The server still gets the answer as the client sent
|
|
32
|
+
* it, and checks it against its own schema.
|
|
33
|
+
*
|
|
34
|
+
* Nothing else changes, and the cast does not check the rest: the v1 types
|
|
35
|
+
* accept a property schema with any `type`, and the v2 types accept an
|
|
36
|
+
* unknown one only in a received value.
|
|
37
|
+
*/
|
|
38
|
+
export declare function v2ElicitationRequest(request: CreateElicitationRequest): v2.CreateElicitationRequest;
|
|
25
39
|
/** What the elicitations need of the connection and the session. */
|
|
26
40
|
export interface ElicitationHost {
|
|
27
41
|
readonly sessionId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../src/v2/elicitation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EACV,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,sGAAsG;IACtG,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CACf,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACtC,mBAAmB,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,mEAAmE;IACnE,MAAM,CAAC,OAAO,EAAE,MAAM,GAA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AAQ,CAAC,YAAY,CAAqB;gBAErB,IAAI,EAAE,eAAe;IAElD;;;;;OAKG;IACH,YAAY,IAAI,IAAI,CAClB,OAAO,EACP,eAAe,GAAG,cAAc,GAAG,sBAAsB,GAAG,iBAAiB,CAC9E;IA4BD,uGAAuG;IACvG,UAAU,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU;IAiB/C,2EAA2E;IAC3E,IAAI,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAIvD,yFAAyF;IACzF,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAStC;;;;OAIG;IACH,sBAAsB,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAkB5D,gFAAgF;IAChF,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,SAAS,IAAI,IAAI;IAOjB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAyBd;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAevB"}
|
package/dist/v2/elicitation.js
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
import { answerAskUserQuestion, answerMcpElicitation, answerUserDialog, elicitUnlessWithdrawn, REFUSAL_FALLBACK_DIALOG_KIND, } from "../elicitation.js";
|
|
2
2
|
import { startMcpServerAuthentication } from "../mcp-oauth.js";
|
|
3
|
+
/**
|
|
4
|
+
* The v2 form of an elicitation that the shared module built in v1 types.
|
|
5
|
+
*
|
|
6
|
+
* A form's string properties go without `pattern`: v1 has the keyword, and v2
|
|
7
|
+
* removed it. Only an MCP server's schema can carry one, since it is relayed
|
|
8
|
+
* as the server sent it. The server still gets the answer as the client sent
|
|
9
|
+
* it, and checks it against its own schema.
|
|
10
|
+
*
|
|
11
|
+
* Nothing else changes, and the cast does not check the rest: the v1 types
|
|
12
|
+
* accept a property schema with any `type`, and the v2 types accept an
|
|
13
|
+
* unknown one only in a received value.
|
|
14
|
+
*/
|
|
15
|
+
export function v2ElicitationRequest(request) {
|
|
16
|
+
if (request.mode !== "form")
|
|
17
|
+
return request;
|
|
18
|
+
// The custom modes of the union keep `mode` a string, so it does not narrow.
|
|
19
|
+
const { requestedSchema } = request;
|
|
20
|
+
const properties = Object.fromEntries(Object.entries(requestedSchema.properties ?? {}).map(([name, property]) => {
|
|
21
|
+
if (property.type !== "string" || !("pattern" in property))
|
|
22
|
+
return [name, property];
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
const { pattern, ...rest } = property;
|
|
25
|
+
return [name, rest];
|
|
26
|
+
}));
|
|
27
|
+
return {
|
|
28
|
+
...request,
|
|
29
|
+
requestedSchema: { ...requestedSchema, properties },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
3
32
|
export class SessionElicitations {
|
|
4
33
|
host;
|
|
5
34
|
/** Whether Claude Code takes `annotations[question].unanswered` (`ask_user_question_unanswered_v1`). */
|
|
@@ -20,17 +20,21 @@
|
|
|
20
20
|
* history follows its launch, so a call to a child from its parent is always
|
|
21
21
|
* delivered first. Any other SendMessage call stays a tool call.
|
|
22
22
|
*
|
|
23
|
-
* Every child's end goes out on its parent at the end of the replay
|
|
24
|
-
* announced child then gets its own `replay_complete`, as v2 requires
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
23
|
+
* Every child's end goes out on its parent at the end of the replay, and
|
|
24
|
+
* each announced child then gets its own `replay_complete`, as v2 requires.
|
|
25
|
+
* These ends are history to the client: a `subagent_update` is an update of
|
|
26
|
+
* the child's parent, so the parent's `replay_complete` is what separates a
|
|
27
|
+
* replayed one from a current one. A child's own stream gets no state in the
|
|
28
|
+
* replay: v2 forbids replaying a past `running` as current activity.
|
|
29
|
+
*
|
|
30
|
+
* Each child's current state goes out after the root's `replay_complete`,
|
|
31
|
+
* which follows every other one, and before the resume's state snapshot
|
|
32
|
+
* ({@link currentStates}): on its parent and on its own stream. A child that
|
|
33
|
+
* works in the live session, on a resume of the active session, gets its
|
|
34
|
+
* current state from the resume snapshot instead
|
|
35
|
+
* (`SessionTasks.currentState`). A child whose configuration is not the
|
|
36
|
+
* `model` that the replay sent, such as a live child whose hooks reported its
|
|
37
|
+
* mode, gets it again then too.
|
|
34
38
|
*
|
|
35
39
|
* A launch without metadata has no known id, so it is not announced: the RFD
|
|
36
40
|
* forbids inventing one. Its Agent call stays an ordinary tool call of the
|
|
@@ -56,8 +60,8 @@ export interface ReplayHost {
|
|
|
56
60
|
}
|
|
57
61
|
/** What the live session knows of the replayed children. */
|
|
58
62
|
export interface LiveChildren {
|
|
59
|
-
/** Whether the
|
|
60
|
-
|
|
63
|
+
/** Whether the child session `sessionId` works in the live session now. */
|
|
64
|
+
working(sessionId: string): boolean;
|
|
61
65
|
/** The configuration that the client last got for the live child `sessionId`, if any. */
|
|
62
66
|
configuration(sessionId: string): SessionConfigOption[] | undefined;
|
|
63
67
|
}
|
|
@@ -82,9 +86,8 @@ export declare class SubagentReplay {
|
|
|
82
86
|
/**
|
|
83
87
|
* Ends the replay of the children. Every child's end goes out on its
|
|
84
88
|
* parent, whose history it is. Then each announced child gets its
|
|
85
|
-
* `replay_complete`, also one without history
|
|
86
|
-
*
|
|
87
|
-
* `replay_complete`.
|
|
89
|
+
* `replay_complete`, also one without history. The caller sends the root's
|
|
90
|
+
* `replay_complete` next, then the current states ({@link currentStates}).
|
|
88
91
|
*/
|
|
89
92
|
finish(): void;
|
|
90
93
|
/**
|
|
@@ -93,15 +96,22 @@ export declare class SubagentReplay {
|
|
|
93
96
|
*/
|
|
94
97
|
reportMissingHistory(): void;
|
|
95
98
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* replayed child
|
|
101
|
-
*
|
|
102
|
-
*
|
|
99
|
+
* What is current of the replayed children. The caller sends it after the
|
|
100
|
+
* root's `replay_complete`, so every child's parent has sent its own, and
|
|
101
|
+
* before the resume's state snapshot.
|
|
102
|
+
*
|
|
103
|
+
* The current state of each replayed child that does not work in the live
|
|
104
|
+
* session: its work ended, or its process is gone, so its replayed end, on
|
|
105
|
+
* its parent and on its own stream. A `cwd` that is gone, such as a
|
|
106
|
+
* worktree that Claude Code removed, is cleared. Then each replayed child's
|
|
107
|
+
* configuration, when it is not the `model` that the replay sent: the live
|
|
108
|
+
* child's, else the model of its latest response, by the session's model
|
|
109
|
+
* list.
|
|
110
|
+
*
|
|
111
|
+
* The v1 core sends the same after the response (`currentStates`): on v1
|
|
112
|
+
* the response is what separates a replayed child state from a current one.
|
|
103
113
|
*/
|
|
104
|
-
|
|
114
|
+
currentStates(): void;
|
|
105
115
|
private sendConfiguration;
|
|
106
116
|
private sendEndState;
|
|
107
117
|
private ownerHooks;
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;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,EAOL,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAmBhC,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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;IAczB,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,UAAU;IAWlB;;;OAGG;IACH;;;;;;;OAOG;IACH,OAAO,CAAC,KAAK;IAyDb;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAcjB,0FAA0F;IAC1F,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,QAAQ;IAiChB,qFAAqF;IACrF,OAAO,CAAC,SAAS;IAcjB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAgBpB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,KAAK;CAKd"}
|
|
@@ -5,7 +5,7 @@ import { taskNotificationsOf } from "../task-notifications.js";
|
|
|
5
5
|
import { REPLAY_COMPLETE } from "./setup.js";
|
|
6
6
|
import { SessionOutput } from "./stream.js";
|
|
7
7
|
import { sameDirectory } from "./tasks.js";
|
|
8
|
-
const NO_LIVE_CHILDREN = {
|
|
8
|
+
const NO_LIVE_CHILDREN = { working: () => false, configuration: () => undefined };
|
|
9
9
|
export class SubagentReplay {
|
|
10
10
|
host;
|
|
11
11
|
history;
|
|
@@ -53,9 +53,8 @@ export class SubagentReplay {
|
|
|
53
53
|
/**
|
|
54
54
|
* Ends the replay of the children. Every child's end goes out on its
|
|
55
55
|
* parent, whose history it is. Then each announced child gets its
|
|
56
|
-
* `replay_complete`, also one without history
|
|
57
|
-
*
|
|
58
|
-
* `replay_complete`.
|
|
56
|
+
* `replay_complete`, also one without history. The caller sends the root's
|
|
57
|
+
* `replay_complete` next, then the current states ({@link currentStates}).
|
|
59
58
|
*/
|
|
60
59
|
finish() {
|
|
61
60
|
const announced = [...this.transcript.children.values()].filter((child) => child.announced);
|
|
@@ -71,10 +70,6 @@ export class SubagentReplay {
|
|
|
71
70
|
}
|
|
72
71
|
for (const child of announced) {
|
|
73
72
|
this.host.send({ sessionId: child.sessionId, update: REPLAY_COMPLETE });
|
|
74
|
-
this.host.send({
|
|
75
|
-
sessionId: child.sessionId,
|
|
76
|
-
update: { sessionUpdate: "state_update", ...replayEndState(child) },
|
|
77
|
-
});
|
|
78
73
|
}
|
|
79
74
|
}
|
|
80
75
|
/**
|
|
@@ -90,19 +85,26 @@ export class SubagentReplay {
|
|
|
90
85
|
}
|
|
91
86
|
}
|
|
92
87
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* replayed child
|
|
98
|
-
*
|
|
99
|
-
*
|
|
88
|
+
* What is current of the replayed children. The caller sends it after the
|
|
89
|
+
* root's `replay_complete`, so every child's parent has sent its own, and
|
|
90
|
+
* before the resume's state snapshot.
|
|
91
|
+
*
|
|
92
|
+
* The current state of each replayed child that does not work in the live
|
|
93
|
+
* session: its work ended, or its process is gone, so its replayed end, on
|
|
94
|
+
* its parent and on its own stream. A `cwd` that is gone, such as a
|
|
95
|
+
* worktree that Claude Code removed, is cleared. Then each replayed child's
|
|
96
|
+
* configuration, when it is not the `model` that the replay sent: the live
|
|
97
|
+
* child's, else the model of its latest response, by the session's model
|
|
98
|
+
* list.
|
|
99
|
+
*
|
|
100
|
+
* The v1 core sends the same after the response (`currentStates`): on v1
|
|
101
|
+
* the response is what separates a replayed child state from a current one.
|
|
100
102
|
*/
|
|
101
|
-
|
|
103
|
+
currentStates() {
|
|
102
104
|
for (const child of this.transcript.children.values()) {
|
|
103
105
|
if (!child.announced)
|
|
104
106
|
continue;
|
|
105
|
-
if (!this.live.
|
|
107
|
+
if (!this.live.working(child.sessionId))
|
|
106
108
|
this.sendEndState(child);
|
|
107
109
|
this.sendConfiguration(child);
|
|
108
110
|
}
|
package/dist/v2/tasks.js
CHANGED
|
@@ -315,7 +315,7 @@ export class SessionTasks {
|
|
|
315
315
|
/** Reads the subagents that the history `messages` launched, for its replay. */
|
|
316
316
|
loadReplay(messages) {
|
|
317
317
|
return SubagentReplay.load(this.host, messages, {
|
|
318
|
-
|
|
318
|
+
working: (sessionId) => this.children.get(sessionId)?.working === true,
|
|
319
319
|
configuration: (sessionId) => this.hasChild(sessionId) ? this.configs.published(sessionId) : undefined,
|
|
320
320
|
});
|
|
321
321
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.108.1-preview.
|
|
6
|
+
"version": "0.108.1-preview.5",
|
|
7
7
|
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"node": ">=22"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@agentclientprotocol/sdk": "2.
|
|
71
|
+
"@agentclientprotocol/sdk": "2.8.0",
|
|
72
72
|
"@anthropic-ai/claude-agent-sdk": "0.3.326",
|
|
73
73
|
"diff": "9.0.0",
|
|
74
74
|
"zod": "4.6.7"
|