@agentclientprotocol/claude-agent-acp 0.114.1-preview.4 → 0.115.0

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.
@@ -28,7 +28,7 @@ import { answerAskUserQuestion, answerMcpElicitation, answerUserDialog, elicitUn
28
28
  import { startMcpServerAuthentication as startSharedMcpServerAuthentication, supportsMcpOAuth, } from "../mcp-oauth.js";
29
29
  import { forkSession } from "../fork-session.js";
30
30
  import { anchoredForkCursorUpdate, forkCursorUpdate, hasForkCursor, LastReportedEntity, promptGetsCursor, withRewindCapability, } from "../session-cursors.js";
31
- import { SESSION_READ_CAPABILITY, SESSION_READ_METHOD } from "../session-read.js";
31
+ import { SESSION_READ_CAPABILITY, SESSION_READ_METHOD, SESSION_READ_SUBAGENTS_CAPABILITY, } from "../session-read.js";
32
32
  import { cutAtRewindPoint, loadRewindableHistory, parseSessionRewindRequest, prepareRewoundResume, rewindSession, SESSION_REWIND_METHOD, } from "../session-rewind.js";
33
33
  import { clientSystemPrompt, sessionSystemPrompt, SYSTEM_PROMPT_CAPABILITY, } from "../client-system-prompt.js";
34
34
  import { readSubagentMessages, readSubagentMessagesOrFail, subagentHistory, subagentLaunchIds, subagentLaunchedBy, subagentLineage, } from "../subagent-history.js";
@@ -641,7 +641,10 @@ export class ClaudeAcpAgent {
641
641
  // Only AIR gets the AIR capabilities and the goal capability, under
642
642
  // `jetbrains.air`.
643
643
  _meta: {
644
- sessionRead: SESSION_READ_CAPABILITY,
644
+ // The status and child reads need native subagent sessions.
645
+ sessionRead: subagentForm(this.clientCapabilities)
646
+ ? SESSION_READ_SUBAGENTS_CAPABILITY
647
+ : SESSION_READ_CAPABILITY,
645
648
  ...(this.toolCallCapabilities.air.client
646
649
  ? withAirMeta(airSessionFailureCapabilityMeta(AGENT_FILE_CHANGE_REPORT_CAPABILITY, AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY, AIR_ASYNC_TASKS_CAPABILITY, AIR_CUSTOM_INSTRUCTIONS_CAPABILITY, AIR_RECOMMENDED_CONFIG_VALUE_CAPABILITY, AIR_DIFF_PATCH_CAPABILITY, AIR_PLAN_FILE_CAPABILITY, AIR_BACKGROUND_SUBAGENTS_CAPABILITY, AIR_KNOWN_MODELS_CAPABILITY, ...this.sessionIndex.capabilities(), ...(clientSupportsAirCapability(request.clientCapabilities, AIR_SESSION_REWIND_CAPABILITY)
647
650
  ? [AIR_SESSION_REWIND_CAPABILITY]
@@ -921,6 +924,7 @@ export class ClaudeAcpAgent {
921
924
  return this.sessionReads.read(params, {
922
925
  capabilities: this.clientCapabilities,
923
926
  airClient: this.toolCallCapabilities.air.client,
927
+ subagentForm: subagentForm(this.clientCapabilities),
924
928
  signal,
925
929
  isOpen: (sessionId) => Object.hasOwn(this.sessions, sessionId),
926
930
  assertRoot: (sessionId) => this.assertNoChildSession(sessionId, "read"),
@@ -6345,12 +6349,21 @@ export class ClaudeAcpAgent {
6345
6349
  // no model to the list, and each child's model is its id until the load
6346
6350
  // response refines it (see `publishCurrentSubagentStates`).
6347
6351
  const replayModels = pending ? undefined : this.subagentModels(sessionId);
6348
- const readSubagentHistory = () => detached
6349
- ? subagentHistory(sessionId, { strict: true, transcript: detached.transcript })
6352
+ const readSubagentHistory = async () => detached
6353
+ ? (detached.child?.history ??
6354
+ detached.subagentStatus?.history ??
6355
+ subagentHistory(sessionId, { strict: true, transcript: detached.transcript }))
6350
6356
  : subagentHistory(sessionId);
6351
- const readChildMessages = (agentId, history, launchId) => detached
6352
- ? readSubagentMessagesOrFail(sessionId, agentId, history, launchId)
6353
- : readSubagentMessages(sessionId, agentId, history, this.logger);
6357
+ const readChildMessages = async (agentId, history, launchId) => {
6358
+ if (!detached)
6359
+ return readSubagentMessages(sessionId, agentId, history, this.logger);
6360
+ // A child read leaves out the transcripts of the other children.
6361
+ if (detached.child && !detached.child.expand(agentId))
6362
+ return [];
6363
+ const read = await readSubagentMessagesOrFail(sessionId, agentId, history, launchId);
6364
+ detached.child?.read(agentId, read);
6365
+ return read;
6366
+ };
6354
6367
  // Registers the Agent and Task launches of `list`, and the terminal state
6355
6368
  // of each launch from its tool_result.
6356
6369
  const registerLaunches = (list) => {
@@ -6694,6 +6707,20 @@ export class ClaudeAcpAgent {
6694
6707
  if (!agentId || replayedSubagents.has(agentId))
6695
6708
  continue;
6696
6709
  replayedSubagents.add(agentId);
6710
+ if (detached?.subagentStatus) {
6711
+ // A status read: the child's launches only (see `SubagentStatus.launches`).
6712
+ const launches = detached.subagentStatus.launches(agentId, toolUseId);
6713
+ registerLaunches(launches.messages);
6714
+ for (const notification of launches.notifications) {
6715
+ await restoreTaskNotification(notification);
6716
+ }
6717
+ // The launch calls announce the nested children, as in a child's history.
6718
+ for (const launch of launches.messages) {
6719
+ if (launch.type === "assistant")
6720
+ await replayMessage(launch);
6721
+ }
6722
+ continue;
6723
+ }
6697
6724
  const childMessages = await readChildMessages(agentId, subagents, toolUseId);
6698
6725
  registerLaunches(childMessages);
6699
6726
  airReplay?.scan(childMessages, agentId);
@@ -6708,9 +6735,14 @@ export class ClaudeAcpAgent {
6708
6735
  const launched = rfdReplay.childOfLaunch(toolUseId);
6709
6736
  if (!launched || launched.announced)
6710
6737
  continue;
6738
+ if (detached?.subagentStatus) {
6739
+ await rfdReplay.announceStatus(launched, detached.subagentStatus);
6740
+ continue;
6741
+ }
6711
6742
  const childMessages = await readChildMessages(launched.sessionId, rfdHistory, toolUseId);
6712
6743
  await rfdReplay.announce(launched);
6713
6744
  rfdReplay.scan(childMessages, launched.sessionId);
6745
+ await rfdReplay.childReplaying(launched, childMessages);
6714
6746
  for (const childMessage of childMessages)
6715
6747
  await replayMessage(childMessage, launched);
6716
6748
  await rfdReplay.childReplayed(launched, childMessages);
@@ -6740,7 +6772,9 @@ export class ClaudeAcpAgent {
6740
6772
  }
6741
6773
  detached?.endHistory();
6742
6774
  if (rfdReplay && !pending?.stopped) {
6743
- await rfdReplay.finish(clientSupportsNotices(this.clientCapabilities), sessionId);
6775
+ detached?.subagentStatus?.report(rfdReplay.statusEntries(detached.subagentStatus, sessionId));
6776
+ // A status read reports the ends in its status update, outside the cursor.
6777
+ await rfdReplay.finish(clientSupportsNotices(this.clientCapabilities), sessionId, !detached?.subagentStatus);
6744
6778
  if (!detached)
6745
6779
  this.replayedSubagents.set(sessionId, rfdReplay);
6746
6780
  }
@@ -6753,11 +6787,16 @@ export class ClaudeAcpAgent {
6753
6787
  }
6754
6788
  if (!detached && childModels.size > 0)
6755
6789
  this.replayedChildModels.set(sessionId, childModels);
6790
+ const status = detached?.subagentStatus;
6791
+ status?.report([...replayChildren]
6792
+ .filter(([, child]) => child.announced)
6793
+ .map(([launchId, child]) => status.airEntry(launchId, child, child.parentToolUseId && replayChildren.get(child.parentToolUseId)?.sessionId)));
6756
6794
  // Claude history persists sidechain messages and Agent/Task tool uses,
6757
6795
  // but not task_started/task_updated lifecycle frames. Recover terminal
6758
6796
  // state from the launch tool_result. Missing results and malformed or
6759
6797
  // orphan lineage use the draft protocol's deterministic disconnected state.
6760
- for (const child of [...replayChildren.values()].reverse()) {
6798
+ // A status read reports the states in its status update, outside the cursor.
6799
+ for (const child of status ? [] : [...replayChildren.values()].reverse()) {
6761
6800
  if (!child.announced)
6762
6801
  continue;
6763
6802
  const parentSessionId = child.parentToolUseId
@@ -1,6 +1,8 @@
1
1
  import type { ClientCapabilities } from "@agentclientprotocol/sdk/unstable";
2
2
  import type { SessionMessage } from "@anthropic-ai/claude-agent-sdk";
3
3
  import type { AcpClient } from "../acp-client.js";
4
+ import { type SessionReadChild } from "../session-read.js";
5
+ import type { SubagentStatus } from "../subagent-status.js";
4
6
  /** A render whose updates are held until the read cursor is validated. */
5
7
  export type DetachedReplay = {
6
8
  messages: SessionMessage[];
@@ -8,6 +10,10 @@ export type DetachedReplay = {
8
10
  publish: AcpClient["sessionUpdate"];
9
11
  endHistory: () => void;
10
12
  signal: AbortSignal;
13
+ /** A child read: the replay reads only the transcripts that `child` expands. */
14
+ child?: SessionReadChild;
15
+ /** A status read: the replay reads no child transcript and reports each child to it. */
16
+ subagentStatus?: SubagentStatus;
11
17
  };
12
18
  export declare class V1SessionReads {
13
19
  private readonly client;
@@ -19,6 +25,8 @@ export declare class V1SessionReads {
19
25
  read(params: unknown, options: {
20
26
  capabilities: ClientCapabilities | undefined;
21
27
  airClient: boolean;
28
+ /** The subagent form of the client, undefined without native subagent sessions. */
29
+ subagentForm: "air" | "rfd" | undefined;
22
30
  signal?: AbortSignal;
23
31
  isOpen: (sessionId: string) => boolean;
24
32
  assertRoot: (sessionId: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"session-read.d.ts","sourceRoot":"","sources":["../../src/v1/session-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,mCAAmC,CAAC;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;gBAEnB,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC;IAErE,OAAO,IAAI,IAAI;IAIf,QAAQ,CAAC,UAAU,kGAA0C;IAE7D,IAAI,CACF,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,YAAY,EAAE,kBAAkB,GAAG,SAAS,CAAC;QAC7C,SAAS,EAAE,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,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;gBAEnB,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC;IAErE,OAAO,IAAI,IAAI;IAIf,QAAQ,CAAC,UAAU,kGAA0C;IAE7D,IAAI,CACF,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,YAAY,EAAE,kBAAkB,GAAG,SAAS,CAAC;QAC7C,SAAS,EAAE,OAAO,CAAC;QACnB,mFAAmF;QACnF,YAAY,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;QACxC,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;QACvC,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;QACxC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;QACvC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACnF,GACA,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAiElC"}
@@ -1,4 +1,4 @@
1
- import { readSessionTranscript, SessionReads } from "../session-read.js";
1
+ import { readSessionTranscript, SessionReads, } from "../session-read.js";
2
2
  import { ChangedMetaFilter } from "./tool-calls/changed-meta-filter.js";
3
3
  export class V1SessionReads {
4
4
  client;
@@ -19,11 +19,17 @@ export class V1SessionReads {
19
19
  protocol: 1,
20
20
  capabilities: options.capabilities,
21
21
  cursors: options.capabilities?.session?.cursors != null,
22
+ subagents: options.subagentForm !== undefined,
22
23
  isOpen: options.isOpen,
23
24
  assertRoot: options.assertRoot,
24
25
  signal,
25
- replay: async (sessionId, cwd, observeStorage) => {
26
- const transcript = await readSessionTranscript(sessionId, cwd, observeStorage);
26
+ replay: async (sessionId, cwd, observeStorage, scope) => {
27
+ const transcript = await readSessionTranscript(sessionId, cwd, observeStorage, scope, options.airClient);
28
+ const { child, subagentStatus } = transcript;
29
+ const form = options.subagentForm;
30
+ // `SessionReads` refuses a child read without native subagent sessions.
31
+ if (child && !form)
32
+ throw new Error("A subagent read needs native subagent sessions");
27
33
  signal.throwIfAborted();
28
34
  const frames = [];
29
35
  let historyEnd;
@@ -52,7 +58,11 @@ export class V1SessionReads {
52
58
  return {
53
59
  frames,
54
60
  cwd: transcript.cwd,
55
- storage: transcript.storage,
61
+ storage: child
62
+ ? child.storage(transcript.transcript, transcript.rewound)
63
+ : transcript.storage,
64
+ ...(child && form ? { stream: child.streamId(form) } : {}),
65
+ ...(subagentStatus ? { status: subagentStatus } : {}),
56
66
  historyEnd,
57
67
  title: transcript.title === undefined ? undefined : options.clientTitle(transcript.title),
58
68
  };
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAcxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAwF3C,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,CAyDb"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAcxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA4F3C,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,CAyDb"}
package/dist/v2/agent.js CHANGED
@@ -35,7 +35,7 @@ import { readHistoryAcrossCompactions, readResumedTail, resumedModelFromTranscri
35
35
  import { mergeEffortSettings } from "../session-effort.js";
36
36
  import { configuredSettings, resolveThinkingConfig } from "../session-env.js";
37
37
  import { resolveInitialPermissionMode, startModeUnderPolicy } from "../session-mode.js";
38
- import { SESSION_READ_CAPABILITY, SESSION_READ_METHOD, SessionReads } from "../session-read.js";
38
+ import { SESSION_READ_METHOD, SESSION_READ_SUBAGENTS_CAPABILITY, SessionReads, } from "../session-read.js";
39
39
  import { cutAtRewindPoint, prepareRewoundResume } from "../session-rewind.js";
40
40
  import { sanitizeTitle } from "../session-titles.js";
41
41
  import { renameSession } from "../session-index/rename.js";
@@ -289,7 +289,7 @@ class V2Agent {
289
289
  const { authMethods, auth, _meta } = this.auth.initialize(request.capabilities);
290
290
  const airMeta = airInitializeMeta(this.air);
291
291
  return {
292
- _meta: { ...airMeta, sessionRead: SESSION_READ_CAPABILITY },
292
+ _meta: { ...airMeta, sessionRead: SESSION_READ_SUBAGENTS_CAPABILITY },
293
293
  protocolVersion: v2.PROTOCOL_VERSION,
294
294
  info: { name: packageJson.name, title: "Claude Agent", version: packageJson.version },
295
295
  capabilities: {
@@ -314,7 +314,8 @@ class V2Agent {
314
314
  cursors: true,
315
315
  signal,
316
316
  isOpen: (sessionId) => this.sessions.has(sessionId) || this.stopped.has(sessionId) || this.starting.has(sessionId),
317
- replay: (sessionId, cwd, observeStorage) => renderSessionRead(sessionId, cwd, this.logger, capabilities, observeStorage),
317
+ subagents: true,
318
+ replay: (sessionId, cwd, observeStorage, scope) => renderSessionRead(sessionId, cwd, this.logger, capabilities, observeStorage, scope),
318
319
  send: (frame) => this.ctx.notify(v2.methods.client.session.update, frame),
319
320
  });
320
321
  }
@@ -1,16 +1,50 @@
1
1
  import type * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
2
2
  import type { Logger } from "../logger.js";
3
- import { type SessionReadFrame } from "../session-read.js";
3
+ import { type SessionReadFrame, type SessionReadScope } from "../session-read.js";
4
4
  /** Renders a stored history without the connection's live tool calls or child sessions. */
5
- export declare function renderSessionRead(sessionId: string, dir: string | undefined, logger: Logger, capabilities: v2.ClientCapabilities | null | undefined, observeStorage: boolean): Promise<{
5
+ export declare function renderSessionRead(sessionId: string, dir: string | undefined, logger: Logger, capabilities: v2.ClientCapabilities | null | undefined, observeStorage: boolean, scope?: SessionReadScope): Promise<{
6
+ frames: SessionReadFrame[];
7
+ cwd: string;
8
+ historyEnd: number;
9
+ storage: import("../session-read.js").SessionReadStorage | undefined;
10
+ stream: string;
11
+ title?: undefined;
12
+ status?: undefined;
13
+ } | {
14
+ frames: SessionReadFrame[];
15
+ cwd: string;
16
+ historyEnd: number;
17
+ title: string | undefined;
18
+ storage: {
19
+ skills?: {
20
+ cwd: string;
21
+ paths: [string, string | null][];
22
+ } | undefined;
23
+ files?: [string, string | null][] | undefined;
24
+ subagents?: string | undefined;
25
+ transcript: string;
26
+ version: string | undefined;
27
+ sidecarTitle: string | null | undefined;
28
+ } | undefined;
29
+ status: import("../subagent-status.js").SubagentStatus;
30
+ stream?: undefined;
31
+ } | {
6
32
  frames: SessionReadFrame[];
7
33
  cwd: string;
8
34
  historyEnd: number;
9
35
  title: string | undefined;
10
36
  storage: {
37
+ skills?: {
38
+ cwd: string;
39
+ paths: [string, string | null][];
40
+ } | undefined;
41
+ files?: [string, string | null][] | undefined;
42
+ subagents?: string | undefined;
11
43
  transcript: string;
12
- version: string;
44
+ version: string | undefined;
13
45
  sidecarTitle: string | null | undefined;
14
46
  } | undefined;
47
+ stream?: undefined;
48
+ status?: undefined;
15
49
  }>;
16
50
  //# sourceMappingURL=session-read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-read.d.ts","sourceRoot":"","sources":["../../src/v2/session-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMlF,2FAA2F;AAC3F,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,EAAE,CAAC,kBAAkB,GAAG,IAAI,GAAG,SAAS,EACtD,cAAc,EAAE,OAAO;;;;;;;;;;GAoCxB"}
1
+ {"version":3,"file":"session-read.d.ts","sourceRoot":"","sources":["../../src/v2/session-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAM5B,2FAA2F;AAC3F,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,EAAE,CAAC,kBAAkB,GAAG,IAAI,GAAG,SAAS,EACtD,cAAc,EAAE,OAAO,EACvB,KAAK,GAAE,gBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8C7B"}
@@ -1,18 +1,18 @@
1
- import { readSessionTranscript } from "../session-read.js";
1
+ import { readSessionTranscript, } from "../session-read.js";
2
2
  import { replayEndUpdate } from "./setup.js";
3
3
  import { SessionOutput } from "./stream.js";
4
4
  import { replaySessionHistory, SubagentReplay } from "./subagent-replay.js";
5
5
  import { V2UpdateTranslator } from "./update-translator.js";
6
6
  /** Renders a stored history without the connection's live tool calls or child sessions. */
7
- export async function renderSessionRead(sessionId, dir, logger, capabilities, observeStorage) {
8
- const { messages, cwd, transcript, title, storage } = await readSessionTranscript(sessionId, dir, observeStorage);
7
+ export async function renderSessionRead(sessionId, dir, logger, capabilities, observeStorage, scope = {}) {
8
+ const { messages, cwd, transcript, title, storage, child, rewound, subagentStatus } = await readSessionTranscript(sessionId, dir, observeStorage, scope);
9
9
  const frames = [];
10
10
  const translator = new V2UpdateTranslator();
11
11
  const send = (notification) => {
12
12
  frames.push(notification);
13
13
  };
14
14
  const output = new SessionOutput(sessionId, cwd, translator, (update) => send({ sessionId, update }), logger, { detached: true });
15
- const subagents = await SubagentReplay.load({ sessionId, cwd, logger, translator, send }, messages, { transcript });
15
+ const subagents = await SubagentReplay.load({ sessionId, cwd, logger, translator, send }, messages, { transcript, child, status: subagentStatus });
16
16
  let historyEnd = 0;
17
17
  replaySessionHistory(send, output, messages, subagents, {
18
18
  // Child end states follow the parent history even when the parent appends more messages.
@@ -24,5 +24,18 @@ export async function renderSessionRead(sessionId, dir, logger, capabilities, ob
24
24
  if (end)
25
25
  send({ sessionId, update: end });
26
26
  subagents?.reportMissingHistory();
27
+ if (child) {
28
+ return {
29
+ frames,
30
+ cwd,
31
+ historyEnd,
32
+ storage: child.storage(transcript, rewound),
33
+ stream: child.streamId("rfd"),
34
+ };
35
+ }
36
+ if (subagentStatus) {
37
+ subagentStatus.report(subagents?.statusEntries() ?? []);
38
+ return { frames, cwd, historyEnd, title, storage, status: subagentStatus };
39
+ }
27
40
  return { frames, cwd, historyEnd, title, storage };
28
41
  }
@@ -49,6 +49,8 @@ import type { SessionMessage } from "@anthropic-ai/claude-agent-sdk";
49
49
  import type { Logger } from "../logger.js";
50
50
  import type { AcpSessionNotification } from "../acp-subagents.js";
51
51
  import { type SubagentModels } from "../native-subagents.js";
52
+ import { type SubagentHistory } from "../subagent-history.js";
53
+ import type { SubagentStatus, SubagentStatusEntry } from "../subagent-status.js";
52
54
  import type { V2UpdateTranslator } from "./update-translator.js";
53
55
  import { SessionOutput, type ReplayHooks } from "./stream.js";
54
56
  /** What the replay needs of its root session. */
@@ -82,6 +84,8 @@ export declare class SubagentReplay {
82
84
  private readonly transcripts;
83
85
  private readonly live;
84
86
  private readonly detached;
87
+ /** A status read: the replay reads no child transcript (see `SubagentStatus`). */
88
+ private readonly status?;
85
89
  private readonly transcript;
86
90
  /** Children whose transcript could not be read: only their association is replayed. */
87
91
  private withoutHistory;
@@ -90,11 +94,21 @@ export declare class SubagentReplay {
90
94
  /**
91
95
  * Reads the subagent history that `messages`, the session's transcript,
92
96
  * launched, with every child's transcript. Undefined when it launched none.
97
+ * A child read (`child`) reads only the transcripts that it expands, and a
98
+ * status read (`status`) none.
93
99
  */
94
- static load(host: ReplayHost, messages: SessionMessage[], { live, transcript: transcriptPath, }?: {
100
+ static load(host: ReplayHost, messages: SessionMessage[], { live, transcript: transcriptPath, child, status, }?: {
95
101
  live?: LiveChildren;
96
102
  transcript?: string;
103
+ child?: {
104
+ history: SubagentHistory;
105
+ expand(agentId: string): boolean;
106
+ read(agentId: string, messages: SessionMessage[]): void;
107
+ };
108
+ status?: SubagentStatus;
97
109
  }): Promise<SubagentReplay | undefined>;
110
+ /** A status read: the status of each announced child (see `SubagentStatus.transcriptEntries`). */
111
+ statusEntries(): SubagentStatusEntry[];
98
112
  /** The hooks of the replay of the root session's history (`messages`). */
99
113
  hooks(output: SessionOutput, messages: SessionMessage[]): ReplayHooks;
100
114
  /** Whether the replay announced the child session `sessionId`. */
@@ -148,6 +162,11 @@ export declare class SubagentReplay {
148
162
  private replaying;
149
163
  /** After a message that launched children: each is announced, and its history replays. */
150
164
  private replayed;
165
+ /**
166
+ * A status read: announces `child` with the prompt of its launch, then the
167
+ * children that it launched, from `status` without its transcript.
168
+ */
169
+ private announceStatus;
151
170
  private announce;
152
171
  /**
153
172
  * The rest of a child's user message to replay, or `null` when nothing is
@@ -167,6 +186,8 @@ export declare class SubagentReplay {
167
186
  * the delivered text.
168
187
  */
169
188
  private sendDelivery;
189
+ /** The prompt of `child`'s launch, unless its prompt went out. */
190
+ private sendLaunchPrompt;
170
191
  private sendPrompt;
171
192
  private outputOf;
172
193
  private cwdOf;
@@ -1 +1 @@
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;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAqBhC,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,kEAAkE;IAClE,MAAM,CAAC,IAAI,cAAc,CAAC;CAC3B;AAED,4DAA4D;AAC5D,MAAM,WAAW,YAAY;IAC3B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,CAAC,KAAK;IAwDb;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAcjB,0FAA0F;IAC1F,OAAO,CAAC,QAAQ;IAqBhB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,QAAQ;IAiChB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAgBpB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAwBpB,kEAAkE;IAClE,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,KAAK;CAKd"}
@@ -1,6 +1,6 @@
1
1
  import { launchReply, linkedSessionMessages, nativeSubagentState, rfdLabels, } from "../native-subagents.js";
2
2
  import { readSubagentMessages, readSubagentMessagesOrFail, subagentHistory, subagentLaunchIds, } from "../subagent-history.js";
3
- import { currentChildConfiguration, deliveredCall, isDelivery, isDirectory, missingHistoryNotice, ReplayTranscript, replayEndState, textOf, trackResponseModel, } from "../subagent-replay.js";
3
+ import { currentChildConfiguration, deliveredCall, isDelivery, isDirectory, missingHistoryNotice, ReplayTranscript, replayEndState, startsWithPrompt, 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";
@@ -19,42 +19,59 @@ export class SubagentReplay {
19
19
  transcripts;
20
20
  live;
21
21
  detached;
22
+ status;
22
23
  transcript;
23
24
  /** Children whose transcript could not be read: only their association is replayed. */
24
25
  withoutHistory = 0;
25
26
  rootOutput;
26
27
  constructor(host, history,
27
28
  /** The transcript of each child, by agent id. */
28
- transcripts, live, detached) {
29
+ transcripts, live, detached,
30
+ /** A status read: the replay reads no child transcript (see `SubagentStatus`). */
31
+ status) {
29
32
  this.host = host;
30
33
  this.history = history;
31
34
  this.transcripts = transcripts;
32
35
  this.live = live;
33
36
  this.detached = detached;
37
+ this.status = status;
34
38
  this.transcript = new ReplayTranscript(history);
35
39
  }
36
40
  /**
37
41
  * Reads the subagent history that `messages`, the session's transcript,
38
42
  * launched, with every child's transcript. Undefined when it launched none.
43
+ * A child read (`child`) reads only the transcripts that it expands, and a
44
+ * status read (`status`) none.
39
45
  */
40
- static async load(host, messages, { live = NO_LIVE_CHILDREN, transcript: transcriptPath, } = {}) {
46
+ static async load(host, messages, { live = NO_LIVE_CHILDREN, transcript: transcriptPath, child, status, } = {}) {
41
47
  if (!messages.some((message) => launchIdsOf(message).length > 0))
42
48
  return undefined;
43
- const history = await subagentHistory(host.sessionId, transcriptPath === undefined ? undefined : { strict: true, transcript: transcriptPath });
49
+ const history = child?.history ??
50
+ status?.history ??
51
+ (await subagentHistory(host.sessionId, transcriptPath === undefined ? undefined : { strict: true, transcript: transcriptPath }));
44
52
  const transcripts = new Map();
45
- const queue = messages.flatMap(launchIdsOf);
53
+ const queue = status ? [] : messages.flatMap(launchIdsOf);
46
54
  while (queue.length > 0) {
47
55
  const launchId = queue.shift();
48
56
  const record = history.agents.get(launchId);
49
57
  if (!record || transcripts.has(record.agentId))
50
58
  continue;
59
+ if (child && !child.expand(record.agentId)) {
60
+ transcripts.set(record.agentId, []);
61
+ continue;
62
+ }
51
63
  const transcript = (await (transcriptPath === undefined
52
64
  ? readSubagentMessages(host.sessionId, record.agentId, history, host.logger)
53
65
  : readSubagentMessagesOrFail(host.sessionId, record.agentId, history, launchId))).map((message) => ({ ...message, parent_tool_use_id: null }));
54
66
  transcripts.set(record.agentId, transcript);
67
+ child?.read(record.agentId, transcript);
55
68
  queue.push(...transcript.flatMap(launchIdsOf));
56
69
  }
57
- return new SubagentReplay(host, history, transcripts, live, transcriptPath !== undefined);
70
+ return new SubagentReplay(host, history, transcripts, live, transcriptPath !== undefined, status);
71
+ }
72
+ /** A status read: the status of each announced child (see `SubagentStatus.transcriptEntries`). */
73
+ statusEntries() {
74
+ return (this.status?.transcriptEntries(this.transcript.children.values(), this.host.sessionId) ?? []);
58
75
  }
59
76
  /** The hooks of the replay of the root session's history (`messages`). */
60
77
  hooks(output, messages) {
@@ -74,7 +91,8 @@ export class SubagentReplay {
74
91
  */
75
92
  finish() {
76
93
  const announced = [...this.transcript.children.values()].filter((child) => child.announced);
77
- for (const child of [...announced].reverse()) {
94
+ // A status read reports the ends in its status update, outside the cursor.
95
+ for (const child of this.status ? [] : [...announced].reverse()) {
78
96
  this.host.send({
79
97
  sessionId: child.parentSessionId,
80
98
  update: {
@@ -237,15 +255,34 @@ export class SubagentReplay {
237
255
  const child = this.transcript.children.get(launchId);
238
256
  if (!child || child.announced)
239
257
  continue;
258
+ if (this.status) {
259
+ this.announceStatus(child, parent, this.status);
260
+ continue;
261
+ }
240
262
  const messages = this.transcripts.get(child.sessionId) ?? [];
241
263
  if (messages.length === 0)
242
264
  this.withoutHistory++;
243
265
  this.announce(child);
244
266
  this.transcript.scan(messages, child.sessionId);
267
+ // A transcript without its prompt at the start gets the launch's prompt first,
268
+ // so that new records come after it and a cursor of the child's stream continues.
269
+ if (!startsWithPrompt(messages))
270
+ this.sendLaunchPrompt(child, parent);
245
271
  child.output.replay(messages, this.ownerHooks(child.output, child));
246
- if (!child.promptSent && typeof child.input.prompt === "string") {
247
- this.sendPrompt(child, parent, child.input.prompt);
248
- }
272
+ this.sendLaunchPrompt(child, parent);
273
+ }
274
+ }
275
+ /**
276
+ * A status read: announces `child` with the prompt of its launch, then the
277
+ * children that it launched, from `status` without its transcript.
278
+ */
279
+ announceStatus(child, parent, status) {
280
+ this.announce(child);
281
+ this.sendLaunchPrompt(child, parent);
282
+ const launches = status.launches(child.record.agentId, child.launchId);
283
+ for (const nested of this.transcript.scanLaunches(launches, child.sessionId)) {
284
+ if (!nested.announced)
285
+ this.announceStatus(nested, child.output, status);
249
286
  }
250
287
  }
251
288
  announce(child) {
@@ -321,6 +358,12 @@ export class SubagentReplay {
321
358
  },
322
359
  ]);
323
360
  }
361
+ /** The prompt of `child`'s launch, unless its prompt went out. */
362
+ sendLaunchPrompt(child, parent) {
363
+ if (!child.promptSent && typeof child.input.prompt === "string") {
364
+ this.sendPrompt(child, parent, child.input.prompt);
365
+ }
366
+ }
324
367
  sendPrompt(child, parent, text) {
325
368
  child.promptSent = true;
326
369
  const [outgoing, incoming] = linkedSessionMessages(child.launchId, child.parentSessionId, child.sessionId, text);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.114.1-preview.4",
6
+ "version": "0.115.0",
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",