@agentclientprotocol/claude-agent-acp 0.114.0 → 0.114.1-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/session-index/transcript-scan.d.ts +2 -4
- package/dist/session-index/transcript-scan.d.ts.map +1 -1
- package/dist/session-index/transcript-scan.js +3 -3
- package/dist/session-read.d.ts +16 -2
- package/dist/session-read.d.ts.map +1 -1
- package/dist/session-read.js +159 -52
- package/dist/v1/session-read.d.ts.map +1 -1
- package/dist/v1/session-read.js +4 -3
- package/dist/v2/agent.js +1 -1
- package/dist/v2/session-read.d.ts +7 -2
- package/dist/v2/session-read.d.ts.map +1 -1
- package/dist/v2/session-read.js +3 -3
- package/package.json +1 -1
|
@@ -136,10 +136,8 @@ export declare function isSidechainTranscript(head: string): boolean;
|
|
|
136
136
|
/** `<projectDir>/<sessionId>/custom-title.json` of a transcript. */
|
|
137
137
|
export declare function customTitleSidecarPath(transcriptPath: string): string;
|
|
138
138
|
/** The custom title that the SDK reads first: the tail's, else the CLI's
|
|
139
|
-
* sidecar's
|
|
140
|
-
export declare function readRecentCustomTitle(transcriptPath: string, headTail: HeadTail,
|
|
141
|
-
strict: boolean;
|
|
142
|
-
}): Promise<string | undefined>;
|
|
139
|
+
* sidecar's, read by `readSidecar`. */
|
|
140
|
+
export declare function readRecentCustomTitle(transcriptPath: string, headTail: HeadTail, readSidecar?: (transcriptPath: string) => Promise<string | undefined>): Promise<string | undefined>;
|
|
143
141
|
/** The title of the CLI's sidecar, if it has a readable title. A strict read
|
|
144
142
|
* throws when the sidecar exists but cannot be read. */
|
|
145
143
|
export declare function readSidecarTitle(transcriptPath: string, options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transcript-scan.d.ts","sourceRoot":"","sources":["../../src/session-index/transcript-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;A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,GAC7E,eAAe,CAoGjB;AAoFD;uBACuB;AACvB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI3D;AAQD,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAGrE;AAED;
|
|
1
|
+
{"version":3,"file":"transcript-scan.d.ts","sourceRoot":"","sources":["../../src/session-index/transcript-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAehF,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;0BACsB;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;8EAC0E;IAC1E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;qDACiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;kEAC8D;IAC9D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;6DACyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;+EAG2E;IAC3E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;yEACqE;IACrE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;0DACsD;IACtD,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb;4BACwB;I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,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAU9E;AAED,mFAAmF;AACnF,wBAAsB,oBAAoB,CACxC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAC5B,OAAO,CAAC,SAAS,CAAC,CAIpB;AAED;;6CAE6C;AAC7C,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAQ3E;AAED;6EAC6E;AAC7E,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB/F;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAsBrE;AAOD;0EAC0E;AAC1E,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BnE"}
|
|
@@ -543,9 +543,9 @@ export function customTitleSidecarPath(transcriptPath) {
|
|
|
543
543
|
return path.join(path.dirname(transcriptPath), sessionId, "custom-title.json");
|
|
544
544
|
}
|
|
545
545
|
/** The custom title that the SDK reads first: the tail's, else the CLI's
|
|
546
|
-
* sidecar's
|
|
547
|
-
export async function readRecentCustomTitle(transcriptPath, headTail,
|
|
548
|
-
return tailCustomTitle(headTail) ?? (await
|
|
546
|
+
* sidecar's, read by `readSidecar`. */
|
|
547
|
+
export async function readRecentCustomTitle(transcriptPath, headTail, readSidecar = readSidecarTitle) {
|
|
548
|
+
return tailCustomTitle(headTail) ?? (await readSidecar(transcriptPath));
|
|
549
549
|
}
|
|
550
550
|
/** The title of the CLI's sidecar, if it has a readable title. A strict read
|
|
551
551
|
* throws when the sidecar exists but cannot be read. */
|
package/dist/session-read.d.ts
CHANGED
|
@@ -16,25 +16,39 @@ type ReadOptions = {
|
|
|
16
16
|
cursors: boolean;
|
|
17
17
|
signal?: AbortSignal;
|
|
18
18
|
isOpen(sessionId: string): boolean;
|
|
19
|
-
|
|
19
|
+
assertRoot?(sessionId: string): void;
|
|
20
|
+
replay(sessionId: string, cwd: string | undefined, observeStorage: boolean): Promise<{
|
|
20
21
|
frames: SessionReadFrame[];
|
|
21
22
|
cwd: string;
|
|
22
23
|
historyEnd?: number;
|
|
23
24
|
title?: string;
|
|
25
|
+
storage?: SessionReadStorage;
|
|
24
26
|
}>;
|
|
25
27
|
send(frame: SessionReadFrame): Promise<void> | void;
|
|
26
28
|
};
|
|
29
|
+
export type SessionReadStorage = {
|
|
30
|
+
transcript: string;
|
|
31
|
+
version: string;
|
|
32
|
+
/** Undefined when replay skipped the sidecar, null when it had no title. */
|
|
33
|
+
sidecarTitle?: string | null;
|
|
34
|
+
};
|
|
27
35
|
/** The SDK follows parent links in these records, including the branch selected by rewind.json. */
|
|
28
|
-
export declare function readSessionTranscript(sessionId: string, cwd?: string): Promise<{
|
|
36
|
+
export declare function readSessionTranscript(sessionId: string, cwd?: string, observeStorage?: boolean): Promise<{
|
|
29
37
|
messages: import("@anthropic-ai/claude-agent-sdk").SessionMessage[];
|
|
30
38
|
cwd: string;
|
|
31
39
|
transcript: string;
|
|
32
40
|
title: string | undefined;
|
|
41
|
+
storage: {
|
|
42
|
+
transcript: string;
|
|
43
|
+
version: string;
|
|
44
|
+
sidecarTitle: string | null | undefined;
|
|
45
|
+
} | undefined;
|
|
33
46
|
}>;
|
|
34
47
|
/** A read owns only a replay on this connection. Closing it invalidates the pending delivery. */
|
|
35
48
|
export declare class SessionReads {
|
|
36
49
|
private readonly active;
|
|
37
50
|
private readonly transitions;
|
|
51
|
+
private readonly checkpoints;
|
|
38
52
|
/** Reserve a session before load, resume, close or delete can yield. */
|
|
39
53
|
transition<T>(sessionId: string | undefined, kind: "open" | "close", run: () => Promise<T>): Promise<T>;
|
|
40
54
|
read(params: unknown, options: ReadOptions): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-read.d.ts","sourceRoot":"","sources":["../src/session-read.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-read.d.ts","sourceRoot":"","sources":["../src/session-read.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,uBAAuB;;CAA+B,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAcF,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,UAAU,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,cAAc,EAAE,OAAO,GACtB,OAAO,CAAC;QACT,MAAM,EAAE,gBAAgB,EAAE,CAAC;QAC3B,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,kBAAkB,CAAC;KAC9B,CAAC,CAAC;IACH,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAqDF,mGAAmG;AACnG,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,EACZ,cAAc,UAAQ;;;;;;;;;;GA8DvB;AAsJD,iGAAiG;AACjG,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA+C;IAEtE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6B;IAEzD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAE7D,wEAAwE;IAClE,UAAU,CAAC,CAAC,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,IAAI,EAAE,MAAM,GAAG,OAAO,EACtB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC;IAkBP,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAoKlF"}
|
package/dist/session-read.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { RequestError } from "@agentclientprotocol/sdk/unstable";
|
|
2
2
|
import { getSessionMessages } from "@anthropic-ai/claude-agent-sdk";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
-
import { open } from "node:fs/promises";
|
|
4
|
+
import { lstat, open } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import packageJson from "../package.json" with { type: "json" };
|
|
8
8
|
import { claudeConfigDir, isSessionId } from "./paths.js";
|
|
9
9
|
import { findTranscript, readHistoryAcrossCompactions, readTranscriptEntriesOf, } from "./resumed-session.js";
|
|
10
10
|
import { LastReportedEntity } from "./session-cursors.js";
|
|
11
|
-
import { readHeadTailOf, readRecentCustomTitle, } from "./session-index/transcript-scan.js";
|
|
11
|
+
import { readHeadTailOf, readRecentCustomTitle, readSidecarTitle, } from "./session-index/transcript-scan.js";
|
|
12
12
|
import { sanitizeTitle } from "./session-titles.js";
|
|
13
|
-
import {
|
|
13
|
+
import { activeSessionMessages, readRewindPoint } from "./session-rewind.js";
|
|
14
14
|
export const SESSION_READ_METHOD = "_session/read";
|
|
15
15
|
export const SESSION_READ_CAPABILITY = { supported: true };
|
|
16
16
|
const request = z.object({
|
|
@@ -24,8 +24,55 @@ const request = z.object({
|
|
|
24
24
|
])
|
|
25
25
|
.nullish(),
|
|
26
26
|
});
|
|
27
|
+
function fileVersion(stats) {
|
|
28
|
+
const { dev, ino, mode, size, mtimeNs, ctimeNs } = stats;
|
|
29
|
+
return [dev, ino, mode, size, mtimeNs, ctimeNs].join(":");
|
|
30
|
+
}
|
|
31
|
+
/** Checks the transcript's metadata and the sidecar inputs read by the replay. */
|
|
32
|
+
async function storageUnchanged(sessionId, storage) {
|
|
33
|
+
try {
|
|
34
|
+
// A move or a different matching project must go through the ordinary lookup.
|
|
35
|
+
const transcript = await findTranscript(sessionId, { strict: true });
|
|
36
|
+
if (transcript !== storage.transcript)
|
|
37
|
+
return false;
|
|
38
|
+
const matchesTranscript = async () => {
|
|
39
|
+
const root = await lstat(transcript, { bigint: true });
|
|
40
|
+
return root.isFile() && fileVersion(root) === storage.version;
|
|
41
|
+
};
|
|
42
|
+
if (!(await matchesTranscript()))
|
|
43
|
+
return false;
|
|
44
|
+
if (storage.sidecarTitle !== undefined) {
|
|
45
|
+
const title = await readSidecarTitle(transcript, { strict: true });
|
|
46
|
+
if ((title ?? null) !== storage.sidecarTitle)
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (await readRewindPoint(sessionId, undefined, { transcript }))
|
|
50
|
+
return false;
|
|
51
|
+
return await matchesTranscript();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// An uncertain probe leaves validation and errors to the ordinary replay.
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** These tools render their stored input and result, with no child or workspace reads. */
|
|
59
|
+
const ROOT_ONLY_TOOLS = new Set(["Bash", "PowerShell", "Read", "Write", "Edit", "Glob", "Grep"]);
|
|
60
|
+
function hasIndependentHistory(content) {
|
|
61
|
+
return (Array.isArray(content) &&
|
|
62
|
+
content.some((block) => ["tool_use", "server_tool_use", "mcp_tool_use"].includes(block?.type) &&
|
|
63
|
+
!ROOT_ONLY_TOOLS.has(block.name)));
|
|
64
|
+
}
|
|
65
|
+
function currentDirectory() {
|
|
66
|
+
try {
|
|
67
|
+
return process.cwd();
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// The working directory could be gone; a replay with a stored cwd may still work.
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
27
74
|
/** The SDK follows parent links in these records, including the branch selected by rewind.json. */
|
|
28
|
-
export async function readSessionTranscript(sessionId, cwd) {
|
|
75
|
+
export async function readSessionTranscript(sessionId, cwd, observeStorage = false) {
|
|
29
76
|
if (!isSessionId(sessionId)) {
|
|
30
77
|
throw RequestError.invalidParams({ sessionId }, "Read the root Claude session by its UUID.");
|
|
31
78
|
}
|
|
@@ -35,17 +82,27 @@ export async function readSessionTranscript(sessionId, cwd) {
|
|
|
35
82
|
const handle = await open(transcript, "r");
|
|
36
83
|
let headTail;
|
|
37
84
|
let records;
|
|
85
|
+
let version;
|
|
38
86
|
try {
|
|
39
|
-
const
|
|
87
|
+
const stat = await handle.stat({ bigint: true });
|
|
88
|
+
if (observeStorage)
|
|
89
|
+
version = fileVersion(stat);
|
|
90
|
+
const size = Number(stat.size);
|
|
40
91
|
headTail = await readHeadTailOf(handle, size);
|
|
41
92
|
records = await readTranscriptEntriesOf(transcript, handle, size);
|
|
42
93
|
}
|
|
43
94
|
finally {
|
|
44
95
|
await handle.close();
|
|
45
96
|
}
|
|
97
|
+
let sidecarTitle;
|
|
98
|
+
const readTitle = async (file) => {
|
|
99
|
+
const title = await readSidecarTitle(file, { strict: true });
|
|
100
|
+
sidecarTitle = title ?? null;
|
|
101
|
+
return title;
|
|
102
|
+
};
|
|
46
103
|
const title = records[0]?.isSidechain === true
|
|
47
104
|
? undefined
|
|
48
|
-
: ((await readRecentCustomTitle(transcript, headTail,
|
|
105
|
+
: ((await readRecentCustomTitle(transcript, headTail, readTitle)) ??
|
|
49
106
|
lastRecordedTitle(records, "custom-title", "customTitle") ??
|
|
50
107
|
lastRecordedTitle(records, "ai-title", "aiTitle"));
|
|
51
108
|
const dir = cwd ?? records.find((r) => typeof r.cwd === "string" && path.isAbsolute(r.cwd))?.cwd;
|
|
@@ -55,13 +112,19 @@ export async function readSessionTranscript(sessionId, cwd) {
|
|
|
55
112
|
sessionStore: { append: async () => { }, load: async () => records },
|
|
56
113
|
};
|
|
57
114
|
const chain = await getSessionMessages(sessionId, options);
|
|
58
|
-
const
|
|
115
|
+
const rewind = await readRewindPoint(sessionId, undefined, { transcript });
|
|
116
|
+
const retained = activeSessionMessages(chain, rewind);
|
|
59
117
|
const messages = await readHistoryAcrossCompactions(sessionId, retained, undefined, effectiveCwd, records);
|
|
60
118
|
return {
|
|
61
119
|
messages,
|
|
62
120
|
cwd: effectiveCwd,
|
|
63
121
|
transcript,
|
|
64
122
|
title: title && sanitizeTitle(title),
|
|
123
|
+
storage: version &&
|
|
124
|
+
!rewind &&
|
|
125
|
+
!messages.some((message) => hasIndependentHistory(message.message?.content))
|
|
126
|
+
? { transcript, version, sidecarTitle }
|
|
127
|
+
: undefined,
|
|
65
128
|
};
|
|
66
129
|
}
|
|
67
130
|
/**
|
|
@@ -173,6 +236,7 @@ function snapshot(frames, root, protocol, scope, previous, historyEnd = frames.l
|
|
|
173
236
|
export class SessionReads {
|
|
174
237
|
active = new Map();
|
|
175
238
|
transitions = new Map();
|
|
239
|
+
checkpoints = new Map();
|
|
176
240
|
/** Reserve a session before load, resume, close or delete can yield. */
|
|
177
241
|
async transition(sessionId, kind, run) {
|
|
178
242
|
if (sessionId === undefined)
|
|
@@ -183,6 +247,7 @@ export class SessionReads {
|
|
|
183
247
|
throw alreadyOpen(sessionId);
|
|
184
248
|
read.invalidated = true;
|
|
185
249
|
}
|
|
250
|
+
this.checkpoints.delete(sessionId);
|
|
186
251
|
this.transitions.set(sessionId, (this.transitions.get(sessionId) ?? 0) + 1);
|
|
187
252
|
try {
|
|
188
253
|
return await run();
|
|
@@ -199,7 +264,8 @@ export class SessionReads {
|
|
|
199
264
|
const parsed = request.safeParse(params);
|
|
200
265
|
if (!parsed.success)
|
|
201
266
|
throw RequestError.invalidParams(undefined, parsed.error.issues[0]?.message);
|
|
202
|
-
const { sessionId,
|
|
267
|
+
const { sessionId, replayFrom } = parsed.data;
|
|
268
|
+
const cwd = parsed.data.cwd ?? undefined;
|
|
203
269
|
const previous = replayFrom?.type === "cursor" ? replayFrom.cursorId : undefined;
|
|
204
270
|
if (replayFrom?.type === "cursor" &&
|
|
205
271
|
(typeof previous !== "string" || !previous || !options.cursors))
|
|
@@ -215,10 +281,21 @@ export class SessionReads {
|
|
|
215
281
|
throw alreadyOpen(sessionId);
|
|
216
282
|
};
|
|
217
283
|
check();
|
|
284
|
+
options.assertRoot?.(sessionId);
|
|
218
285
|
this.active.set(sessionId, read);
|
|
286
|
+
const useCursor = options.cursors && replayFrom != null;
|
|
287
|
+
const processCwd = useCursor ? currentDirectory() : undefined;
|
|
288
|
+
const scopeFor = (effectiveCwd) => json([
|
|
289
|
+
sessionId,
|
|
290
|
+
effectiveCwd,
|
|
291
|
+
claudeConfigDir(),
|
|
292
|
+
options.protocol,
|
|
293
|
+
options.capabilities,
|
|
294
|
+
packageJson.version,
|
|
295
|
+
]);
|
|
219
296
|
const replay = async () => {
|
|
220
297
|
try {
|
|
221
|
-
const view = await options.replay(sessionId, cwd
|
|
298
|
+
const view = await options.replay(sessionId, cwd, useCursor);
|
|
222
299
|
if (options.protocol === 1 && view.title)
|
|
223
300
|
view.frames.push({
|
|
224
301
|
sessionId,
|
|
@@ -239,59 +316,89 @@ export class SessionReads {
|
|
|
239
316
|
}, `Could not read the history of ${sessionId}. Retry the read. ${String(error)}`);
|
|
240
317
|
}
|
|
241
318
|
};
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
let cursorId;
|
|
247
|
-
const useCursor = options.cursors && replayFrom != null;
|
|
248
|
-
if (useCursor) {
|
|
249
|
-
const scope = json([
|
|
250
|
-
sessionId,
|
|
251
|
-
effectiveCwd,
|
|
252
|
-
claudeConfigDir(),
|
|
253
|
-
options.protocol,
|
|
254
|
-
options.capabilities,
|
|
255
|
-
packageJson.version,
|
|
256
|
-
]);
|
|
257
|
-
const next = snapshot(frames, sessionId, options.protocol, scope, cursor, historyEnd);
|
|
258
|
-
outgoing = next.outgoing;
|
|
259
|
-
cursorId = next.cursorId;
|
|
260
|
-
if (cursorId && cursorId !== cursor) {
|
|
261
|
-
// A terminal can append or rewind between the reads of the root and a child.
|
|
262
|
-
const again = await replay();
|
|
263
|
-
check();
|
|
264
|
-
if (again.cwd !== effectiveCwd ||
|
|
265
|
-
again.historyEnd !== historyEnd ||
|
|
266
|
-
frames.length !== again.frames.length ||
|
|
267
|
-
frames.some((frame, i) => json(frame) !== json(again.frames[i]))) {
|
|
268
|
-
throw RequestError.internalError({ sessionId, retryable: true }, "History changed during the read. Retry with the last successful cursor.");
|
|
269
|
-
}
|
|
270
|
-
const end = outgoing.findIndex((frame) => frame.sessionId === sessionId && frame.update.sessionUpdate === "replay_complete");
|
|
271
|
-
outgoing.splice(end < 0 ? outgoing.length : end, 0, {
|
|
272
|
-
sessionId,
|
|
273
|
-
update: {
|
|
274
|
-
sessionUpdate: "cursor_update",
|
|
275
|
-
cursorId,
|
|
276
|
-
anchor: next.anchor,
|
|
277
|
-
capabilities: { read: {} },
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
|
-
}
|
|
319
|
+
const deliver = async (outgoing, cursorId, title) => {
|
|
320
|
+
for (const frame of outgoing) {
|
|
321
|
+
check();
|
|
322
|
+
await options.send(frame);
|
|
281
323
|
}
|
|
282
324
|
// On v2 the title is current session info, outside the replay cursor.
|
|
283
325
|
if (options.protocol === 2 && (title || useCursor)) {
|
|
284
|
-
|
|
326
|
+
check();
|
|
327
|
+
await options.send({
|
|
285
328
|
sessionId,
|
|
286
329
|
update: { sessionUpdate: "session_info_update", title: title || null },
|
|
287
330
|
});
|
|
288
331
|
}
|
|
289
|
-
|
|
332
|
+
check();
|
|
333
|
+
return cursorId ? { cursorId } : {};
|
|
334
|
+
};
|
|
335
|
+
try {
|
|
336
|
+
const cached = cursor ? this.checkpoints.get(sessionId) : undefined;
|
|
337
|
+
if (cached &&
|
|
338
|
+
cached.cursorId === cursor &&
|
|
339
|
+
(cached.requestedCwd === cwd || cached.cwd === cwd) &&
|
|
340
|
+
cached.processCwd === processCwd &&
|
|
341
|
+
cached.scope === scopeFor(cached.cwd) &&
|
|
342
|
+
(await storageUnchanged(sessionId, cached.storage)) &&
|
|
343
|
+
cached.processCwd === currentDirectory()) {
|
|
344
|
+
return await deliver(cached.boundaries, cached.cursorId, cached.title);
|
|
345
|
+
}
|
|
346
|
+
check();
|
|
347
|
+
if (useCursor)
|
|
348
|
+
this.checkpoints.delete(sessionId);
|
|
349
|
+
const { frames, cwd: effectiveCwd, historyEnd, title, storage } = await replay();
|
|
350
|
+
check();
|
|
351
|
+
if (!useCursor)
|
|
352
|
+
return await deliver(frames, undefined, title);
|
|
353
|
+
const scope = scopeFor(effectiveCwd);
|
|
354
|
+
const { outgoing, cursorId, anchor } = snapshot(frames, sessionId, options.protocol, scope, cursor, historyEnd);
|
|
355
|
+
let verifiedStorage = storage;
|
|
356
|
+
const isRootBoundary = (frame) => frame.sessionId === sessionId && frame.update.sessionUpdate === "replay_complete";
|
|
357
|
+
if (cursorId && cursorId !== cursor) {
|
|
358
|
+
// A terminal can append or rewind between the reads of the root and a child.
|
|
359
|
+
const again = await replay();
|
|
290
360
|
check();
|
|
291
|
-
|
|
361
|
+
if (again.cwd !== effectiveCwd ||
|
|
362
|
+
again.historyEnd !== historyEnd ||
|
|
363
|
+
frames.length !== again.frames.length ||
|
|
364
|
+
frames.some((frame, i) => json(frame) !== json(again.frames[i]))) {
|
|
365
|
+
throw RequestError.internalError({ sessionId, retryable: true }, "History changed during the read. Retry with the last successful cursor.");
|
|
366
|
+
}
|
|
367
|
+
if (again.storage?.transcript !== storage?.transcript ||
|
|
368
|
+
again.storage?.version !== storage?.version ||
|
|
369
|
+
again.storage?.sidecarTitle !== storage?.sidecarTitle) {
|
|
370
|
+
verifiedStorage = undefined;
|
|
371
|
+
}
|
|
372
|
+
const end = outgoing.findIndex(isRootBoundary);
|
|
373
|
+
outgoing.splice(end < 0 ? outgoing.length : end, 0, {
|
|
374
|
+
sessionId,
|
|
375
|
+
update: {
|
|
376
|
+
sessionUpdate: "cursor_update",
|
|
377
|
+
cursorId,
|
|
378
|
+
anchor,
|
|
379
|
+
capabilities: { read: {} },
|
|
380
|
+
},
|
|
381
|
+
});
|
|
292
382
|
}
|
|
383
|
+
// Pair the cursor only with the inputs read by its render, never a later append.
|
|
384
|
+
const result = await deliver(outgoing, cursorId, title);
|
|
293
385
|
check();
|
|
294
|
-
|
|
386
|
+
if (cursorId && verifiedStorage && processCwd && processCwd === currentDirectory()) {
|
|
387
|
+
this.checkpoints.set(sessionId, {
|
|
388
|
+
cursorId,
|
|
389
|
+
scope,
|
|
390
|
+
requestedCwd: cwd,
|
|
391
|
+
cwd: effectiveCwd,
|
|
392
|
+
processCwd,
|
|
393
|
+
storage: verifiedStorage,
|
|
394
|
+
boundaries: frames.filter(isRootBoundary),
|
|
395
|
+
title,
|
|
396
|
+
});
|
|
397
|
+
if (this.checkpoints.size > 32) {
|
|
398
|
+
this.checkpoints.delete(this.checkpoints.keys().next().value);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
295
402
|
}
|
|
296
403
|
finally {
|
|
297
404
|
this.active.delete(sessionId);
|
|
@@ -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,OAAO,CAAC;QACnB,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,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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;CAkDlC"}
|
package/dist/v1/session-read.js
CHANGED
|
@@ -20,10 +20,10 @@ export class V1SessionReads {
|
|
|
20
20
|
capabilities: options.capabilities,
|
|
21
21
|
cursors: options.capabilities?.session?.cursors != null,
|
|
22
22
|
isOpen: options.isOpen,
|
|
23
|
+
assertRoot: options.assertRoot,
|
|
23
24
|
signal,
|
|
24
|
-
replay: async (sessionId, cwd) => {
|
|
25
|
-
|
|
26
|
-
const transcript = await readSessionTranscript(sessionId, cwd);
|
|
25
|
+
replay: async (sessionId, cwd, observeStorage) => {
|
|
26
|
+
const transcript = await readSessionTranscript(sessionId, cwd, observeStorage);
|
|
27
27
|
signal.throwIfAborted();
|
|
28
28
|
const frames = [];
|
|
29
29
|
let historyEnd;
|
|
@@ -52,6 +52,7 @@ export class V1SessionReads {
|
|
|
52
52
|
return {
|
|
53
53
|
frames,
|
|
54
54
|
cwd: transcript.cwd,
|
|
55
|
+
storage: transcript.storage,
|
|
55
56
|
historyEnd,
|
|
56
57
|
title: transcript.title === undefined ? undefined : options.clientTitle(transcript.title),
|
|
57
58
|
};
|
package/dist/v2/agent.js
CHANGED
|
@@ -312,7 +312,7 @@ class V2Agent {
|
|
|
312
312
|
cursors: true,
|
|
313
313
|
signal,
|
|
314
314
|
isOpen: (sessionId) => this.sessions.has(sessionId) || this.stopped.has(sessionId) || this.starting.has(sessionId),
|
|
315
|
-
replay: (sessionId, cwd) => renderSessionRead(sessionId, cwd, this.logger, capabilities),
|
|
315
|
+
replay: (sessionId, cwd, observeStorage) => renderSessionRead(sessionId, cwd, this.logger, capabilities, observeStorage),
|
|
316
316
|
send: (frame) => this.ctx.notify(v2.methods.client.session.update, frame),
|
|
317
317
|
});
|
|
318
318
|
}
|
|
@@ -2,10 +2,15 @@ import type * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
|
2
2
|
import type { Logger } from "../logger.js";
|
|
3
3
|
import { type SessionReadFrame } 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): Promise<{
|
|
5
|
+
export declare function renderSessionRead(sessionId: string, dir: string | undefined, logger: Logger, capabilities: v2.ClientCapabilities | null | undefined, observeStorage: boolean): Promise<{
|
|
6
6
|
frames: SessionReadFrame[];
|
|
7
7
|
cwd: string;
|
|
8
8
|
historyEnd: number;
|
|
9
|
-
title
|
|
9
|
+
title: string | undefined;
|
|
10
|
+
storage: {
|
|
11
|
+
transcript: string;
|
|
12
|
+
version: string;
|
|
13
|
+
sidecarTitle: string | null | undefined;
|
|
14
|
+
} | undefined;
|
|
10
15
|
}>;
|
|
11
16
|
//# 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,
|
|
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"}
|
package/dist/v2/session-read.js
CHANGED
|
@@ -4,8 +4,8 @@ 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) {
|
|
8
|
-
const { messages, cwd, transcript, title } = await readSessionTranscript(sessionId, dir);
|
|
7
|
+
export async function renderSessionRead(sessionId, dir, logger, capabilities, observeStorage) {
|
|
8
|
+
const { messages, cwd, transcript, title, storage } = await readSessionTranscript(sessionId, dir, observeStorage);
|
|
9
9
|
const frames = [];
|
|
10
10
|
const translator = new V2UpdateTranslator();
|
|
11
11
|
const send = (notification) => {
|
|
@@ -24,5 +24,5 @@ export async function renderSessionRead(sessionId, dir, logger, capabilities) {
|
|
|
24
24
|
if (end)
|
|
25
25
|
send({ sessionId, update: end });
|
|
26
26
|
subagents?.reportMissingHistory();
|
|
27
|
-
return { frames, cwd, historyEnd, title };
|
|
27
|
+
return { frames, cwd, historyEnd, title, storage };
|
|
28
28
|
}
|
package/package.json
CHANGED