@agentclientprotocol/claude-agent-acp 0.113.1-preview.1 → 0.113.1-preview.11

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.
Files changed (86) hide show
  1. package/README.md +5 -3
  2. package/dist/async-tasks.d.ts +27 -0
  3. package/dist/async-tasks.d.ts.map +1 -1
  4. package/dist/async-tasks.js +36 -0
  5. package/dist/claude-cli.d.ts +22 -16
  6. package/dist/claude-cli.d.ts.map +1 -1
  7. package/dist/claude-cli.js +40 -18
  8. package/dist/mcp-oauth.d.ts +3 -2
  9. package/dist/mcp-oauth.d.ts.map +1 -1
  10. package/dist/mcp-oauth.js +65 -27
  11. package/dist/query-settings.d.ts +42 -0
  12. package/dist/query-settings.d.ts.map +1 -0
  13. package/dist/query-settings.js +43 -0
  14. package/dist/resumed-session.d.ts +9 -2
  15. package/dist/resumed-session.d.ts.map +1 -1
  16. package/dist/resumed-session.js +51 -7
  17. package/dist/sdk-to-acp.js +4 -2
  18. package/dist/session-cursors.d.ts +1 -1
  19. package/dist/session-cursors.d.ts.map +1 -1
  20. package/dist/session-cursors.js +8 -2
  21. package/dist/session-index/service.d.ts.map +1 -1
  22. package/dist/session-index/service.js +9 -17
  23. package/dist/session-index/session-index.d.ts +1 -13
  24. package/dist/session-index/session-index.d.ts.map +1 -1
  25. package/dist/session-index/session-index.js +3 -29
  26. package/dist/session-index/transcript-scan.d.ts +17 -4
  27. package/dist/session-index/transcript-scan.d.ts.map +1 -1
  28. package/dist/session-index/transcript-scan.js +44 -3
  29. package/dist/session-mode.d.ts +69 -3
  30. package/dist/session-mode.d.ts.map +1 -1
  31. package/dist/session-mode.js +103 -15
  32. package/dist/session-model.d.ts +4 -1
  33. package/dist/session-model.d.ts.map +1 -1
  34. package/dist/session-model.js +26 -4
  35. package/dist/session-read.d.ts +45 -0
  36. package/dist/session-read.d.ts.map +1 -0
  37. package/dist/session-read.js +300 -0
  38. package/dist/session-rewind.d.ts +6 -2
  39. package/dist/session-rewind.d.ts.map +1 -1
  40. package/dist/session-rewind.js +13 -4
  41. package/dist/session-ultracode.d.ts +17 -5
  42. package/dist/session-ultracode.d.ts.map +1 -1
  43. package/dist/session-ultracode.js +16 -15
  44. package/dist/settings.d.ts +34 -0
  45. package/dist/settings.d.ts.map +1 -1
  46. package/dist/settings.js +55 -4
  47. package/dist/startup-failure.d.ts +11 -1
  48. package/dist/startup-failure.d.ts.map +1 -1
  49. package/dist/startup-failure.js +33 -1
  50. package/dist/subagent-history.d.ts +9 -1
  51. package/dist/subagent-history.d.ts.map +1 -1
  52. package/dist/subagent-history.js +55 -13
  53. package/dist/v1/acp-agent.d.ts +8 -1
  54. package/dist/v1/acp-agent.d.ts.map +1 -1
  55. package/dist/v1/acp-agent.js +189 -94
  56. package/dist/v1/async-task-stop.d.ts +31 -0
  57. package/dist/v1/async-task-stop.d.ts.map +1 -1
  58. package/dist/v1/async-task-stop.js +41 -0
  59. package/dist/v1/session-read.d.ts +31 -0
  60. package/dist/v1/session-read.d.ts.map +1 -0
  61. package/dist/v1/session-read.js +62 -0
  62. package/dist/v2/agent.d.ts.map +1 -1
  63. package/dist/v2/agent.js +72 -29
  64. package/dist/v2/commands.d.ts +8 -3
  65. package/dist/v2/commands.d.ts.map +1 -1
  66. package/dist/v2/commands.js +4 -3
  67. package/dist/v2/config.d.ts +9 -8
  68. package/dist/v2/config.d.ts.map +1 -1
  69. package/dist/v2/config.js +15 -10
  70. package/dist/v2/session-read.d.ts +11 -0
  71. package/dist/v2/session-read.d.ts.map +1 -0
  72. package/dist/v2/session-read.js +28 -0
  73. package/dist/v2/session.d.ts.map +1 -1
  74. package/dist/v2/session.js +19 -2
  75. package/dist/v2/setup.d.ts +4 -1
  76. package/dist/v2/setup.d.ts.map +1 -1
  77. package/dist/v2/setup.js +4 -2
  78. package/dist/v2/stream.d.ts +9 -13
  79. package/dist/v2/stream.d.ts.map +1 -1
  80. package/dist/v2/stream.js +10 -9
  81. package/dist/v2/subagent-replay.d.ts +16 -4
  82. package/dist/v2/subagent-replay.d.ts.map +1 -1
  83. package/dist/v2/subagent-replay.js +22 -10
  84. package/dist/v2/tasks.d.ts.map +1 -1
  85. package/dist/v2/tasks.js +5 -3
  86. package/package.json +8 -8
@@ -2,7 +2,8 @@ import { getSessionMessages, importSessionToStore, } from "@anthropic-ai/claude-
2
2
  import { access, open, readdir } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { isCompactSummaryMessage } from "./context-compaction.js";
5
- import { claudeConfigDir } from "./paths.js";
5
+ import { projectsRoot } from "./paths.js";
6
+ import { errorCode } from "./session-index/project-dirs.js";
6
7
  import { SessionTiming } from "./session-timing.js";
7
8
  /** The size of one backward read of a transcript. */
8
9
  const TAIL_CHUNK_BYTES = 64 * 1024;
@@ -76,11 +77,11 @@ export async function readResumedSession(sessionId, logger) {
76
77
  * the chain loops and ends there. Without it, the kept messages stay where
77
78
  * they were said, before the boundary.
78
79
  */
79
- export async function readHistoryAcrossCompactions(sessionId, messages, logger, dir) {
80
+ export async function readHistoryAcrossCompactions(sessionId, messages, logger, dir, snapshot) {
80
81
  if (!isCompactSummaryMessage(messages[0]))
81
82
  return messages;
82
83
  try {
83
- const entries = (await loadFullSessionHistory(sessionId, dir)).map(linkCompactBoundary);
84
+ const entries = (snapshot ?? (await loadFullSessionHistory(sessionId, dir))).map(linkCompactBoundary);
84
85
  const history = await getSessionMessages(sessionId, {
85
86
  dir,
86
87
  sessionStore: { append: async () => { }, load: async () => entries },
@@ -88,12 +89,16 @@ export async function readHistoryAcrossCompactions(sessionId, messages, logger,
88
89
  const leaf = messages.at(-1)?.uuid;
89
90
  const end = history.findIndex((message) => message.uuid === leaf);
90
91
  if (end < 0) {
92
+ if (snapshot)
93
+ throw new Error("Compacted history does not reach the active branch");
91
94
  logger?.error(`The history before the last compaction of session ${sessionId} does not reach message ${leaf}: replaying the messages after it`);
92
95
  return messages;
93
96
  }
94
97
  return history.slice(0, end + 1);
95
98
  }
96
99
  catch (error) {
100
+ if (snapshot)
101
+ throw error;
97
102
  logger?.error(`Failed to read the history before the last compaction of session ${sessionId}:`, error);
98
103
  return messages;
99
104
  }
@@ -155,27 +160,66 @@ export async function readResumedTail(sessionId, logger, withModel = true) {
155
160
  return withModel ? { model: (await readResumedSession(sessionId, logger)).model } : {};
156
161
  }
157
162
  /** The local transcript of a session in any project directory, as the SDK looks it up. */
158
- export async function findTranscript(sessionId) {
159
- const projects = path.join(claudeConfigDir(), "projects");
163
+ export async function findTranscript(sessionId, options) {
164
+ const projects = projectsRoot();
160
165
  let directories;
161
166
  try {
162
167
  directories = await readdir(projects);
163
168
  }
164
- catch {
169
+ catch (error) {
170
+ if (options?.strict && errorCode(error) !== "ENOENT")
171
+ throw error;
165
172
  return undefined;
166
173
  }
174
+ let lookupError;
167
175
  for (const directory of directories) {
168
176
  const candidate = path.join(projects, directory, `${sessionId}.jsonl`);
169
177
  try {
170
178
  await access(candidate);
171
179
  return candidate;
172
180
  }
173
- catch {
181
+ catch (error) {
182
+ if (options?.strict && errorCode(error) !== "ENOENT" && errorCode(error) !== "ENOTDIR")
183
+ lookupError ??= error;
174
184
  // Not in this project directory.
175
185
  }
176
186
  }
187
+ if (lookupError)
188
+ throw lookupError;
177
189
  return undefined;
178
190
  }
191
+ /** Read the records once so the SDK projects the active branch and its compactions
192
+ * from the same bytes. An unfinished JSON line can be completed by the next poll. */
193
+ export async function readTranscriptEntries(file) {
194
+ const handle = await open(file, "r");
195
+ try {
196
+ return await readTranscriptEntriesOf(file, handle, (await handle.stat()).size);
197
+ }
198
+ finally {
199
+ await handle.close();
200
+ }
201
+ }
202
+ export async function readTranscriptEntriesOf(file, handle, size) {
203
+ if (size === 0)
204
+ return [];
205
+ try {
206
+ const records = [];
207
+ for await (const line of handle.readLines({ start: 0, end: size - 1 })) {
208
+ try {
209
+ const record = JSON.parse(line);
210
+ if (record && typeof record.type === "string")
211
+ records.push(record);
212
+ }
213
+ catch {
214
+ // Claude's transcript reader skips lines that do not parse.
215
+ }
216
+ }
217
+ return records;
218
+ }
219
+ catch (error) {
220
+ throw Object.assign(new Error(`Could not read ${file}`, { cause: error }), { path: file });
221
+ }
222
+ }
179
223
  /** The model of the last real assistant record and the last permission mode
180
224
  * of the main thread in a JSONL transcript. */
181
225
  async function lastTailRecords(filePath, withModel) {
@@ -324,7 +324,8 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
324
324
  // Resolve the server tool through the normal result path without rendering
325
325
  // opaque ciphertext. Server tools have no later PostToolUse hook to await.
326
326
  const result = chunk.content;
327
- unregisterHookCallback(chunk.tool_use_id);
327
+ if (registerHooks)
328
+ unregisterHookCallback(chunk.tool_use_id);
328
329
  output.push(...toAcpNotifications([
329
330
  {
330
331
  type: "tool_result",
@@ -349,7 +350,8 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
349
350
  case "mcp_tool_result": {
350
351
  const wasEmitted = options?.emittedToolCalls?.has(chunk.tool_use_id) === true;
351
352
  options?.emittedToolCalls?.delete(chunk.tool_use_id);
352
- completeHookCallback(chunk.tool_use_id);
353
+ if (registerHooks)
354
+ completeHookCallback(chunk.tool_use_id);
353
355
  finishedToolCallId = chunk.tool_use_id;
354
356
  // Why this is_error result carries harness prose instead of tool
355
357
  // output (user-rejected / interrupted / …), when the SDK said so.
@@ -95,7 +95,7 @@ export declare class LastReportedEntity {
95
95
  sessionUpdate: string;
96
96
  _meta?: unknown;
97
97
  } & Record<string, unknown>;
98
- }): void;
98
+ }, protocol?: 1 | 2): void;
99
99
  /** The position after the last entity of the session, if the client holds one. */
100
100
  after(sessionId: string): CursorAnchor | undefined;
101
101
  /** The last entity of the session that the client holds, if any. */
@@ -1 +1 @@
1
- {"version":3,"file":"session-cursors.d.ts","sourceRoot":"","sources":["../src/session-cursors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAOrE,+CAA+C;AAC/C,MAAM,MAAM,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,GAAG,SAAS;IAKlD,oEAAoE;IACpE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD,+FAA+F;IAC/F,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;IAMzF;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAajD,+FAA+F;IAC/F,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAOhC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,OAAO,CAGjG;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAIzF;AAmBD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,MAAM,GAAG,SAAS,CAKpB"}
@@ -52,27 +52,33 @@ export class LastReportedEntity {
52
52
  bySession = new Map();
53
53
  /** Per session, in announcement order: the entity before each announced cursor. */
54
54
  beforeCursor = new Map();
55
- sending(notification) {
55
+ sending(notification, protocol = 1) {
56
56
  const { sessionId, update } = notification;
57
57
  const meta = update._meta;
58
58
  if (meta?.claudeCode?.parentToolUseId)
59
59
  return;
60
60
  const messageId = typeof update.messageId === "string" ? update.messageId : undefined;
61
61
  switch (update.sessionUpdate) {
62
+ case "user_message":
62
63
  case "user_message_chunk":
63
64
  if (messageId)
64
65
  this.bySession.set(sessionId, { type: "user_message", messageId });
65
66
  break;
67
+ case "agent_message":
66
68
  case "agent_message_chunk":
67
69
  if (messageId)
68
70
  this.bySession.set(sessionId, { type: "agent_message", messageId });
69
71
  break;
72
+ case "agent_thought":
70
73
  case "agent_thought_chunk":
71
74
  if (messageId)
72
75
  this.bySession.set(sessionId, { type: "agent_thought", messageId });
73
76
  break;
74
77
  case "tool_call":
75
- if (typeof update.toolCallId === "string") {
78
+ case "tool_call_update":
79
+ if ((update.sessionUpdate === "tool_call" ||
80
+ (protocol === 2 && typeof update.name === "string")) &&
81
+ typeof update.toolCallId === "string") {
76
82
  this.bySession.set(sessionId, { type: "tool_call", toolCallId: update.toolCallId });
77
83
  }
78
84
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/session-index/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EACjB,MAAM,mCAAmC,CAAC;AAI3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAQrD,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAiBzD,OAAO,EAKL,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAC7D,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAO7D,MAAM,MAAM,gBAAgB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,oBAAoB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACxE,MAAM,MAA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M,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgB1D,+CAA+C;IAC/C,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAI7C,iEAAiE;IACjE,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI1C,sEAAsE;IACtE,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAInC,4EAA4E;IAC5E,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAInD;sDACkD;IAClD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIpC,OAAO,IAAI,IAAI;CAKhB"}
@@ -19,8 +19,8 @@ import { ForkHolds, ListSubscriptions, } from "./list-subscriptions.js";
19
19
  import { LiveSessionRegistry } from "./live-registry.js";
20
20
  import { isSessionId } from "../paths.js";
21
21
  import { canonicalPath, exists, isExactProjectDir, projectDirMatches, sameProjectPath, } from "./project-dirs.js";
22
- import { readHeadTail, readHeadTailOf, sdkTitles, tailCustomTitle, transcriptAgentName, transcriptProjectCwd, } from "./transcript-scan.js";
23
- import { DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT, ARCHIVED_FILTERS, readSidecarTitle, SessionIndex, } from "./session-index.js";
22
+ import { customTitleSidecarPath, readHeadTail, readHeadTailOf, readSidecarTitle, readTranscriptTitles, transcriptAgentName, transcriptProjectCwd, } from "./transcript-scan.js";
23
+ import { DEFAULT_LIST_LIMIT, MAX_LIST_LIMIT, ARCHIVED_FILTERS, SessionIndex, } from "./session-index.js";
24
24
  import { sessionInfoOf } from "./session-info.js";
25
25
  export const SESSION_RENAME_METHOD = "_session/rename";
26
26
  export const SESSION_ARCHIVE_METHOD = "_session/archive";
@@ -129,17 +129,12 @@ export function decodeListCursor(cursor, scope) {
129
129
  }
130
130
  return { orderAtMs: payload.u, sessionId: payload.id };
131
131
  }
132
- /** `<projectDir>/<sessionId>/custom-title.json` of a transcript. */
133
- function sidecarPath(transcriptPath) {
134
- const sessionId = path.basename(transcriptPath, ".jsonl");
135
- return path.join(path.dirname(transcriptPath), sessionId, "custom-title.json");
136
- }
137
132
  /** Writes `<projectDir>/<sessionId>/custom-title.json` the way the CLI's
138
133
  * `/rename` does: file 0600 in a 0700 directory, replaced atomically. The
139
134
  * temporary file has a random name of the CLI's `custom-title.json.tmp.*`
140
135
  * pattern, and only a temporary file this call created is removed. */
141
136
  export async function writeCustomTitleSidecar(transcriptPath, title) {
142
- const target = sidecarPath(transcriptPath);
137
+ const target = customTitleSidecarPath(transcriptPath);
143
138
  await fs.mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
144
139
  const temporary = `${target}.tmp.${randomBytes(8).toString("hex")}`;
145
140
  const handle = await fs.open(temporary, "wx", 0o600);
@@ -213,13 +208,10 @@ async function ensureAgentName(filePath, sessionId, title) {
213
208
  * {@link effectiveTitle}): its agent name, else the title the SDK reports.
214
209
  * It carries the archive prefix only when the copy is archived: a generated
215
210
  * title never archives a session. */
216
- async function copyTitle(filePath, sessionId) {
211
+ async function copyTitle(filePath) {
217
212
  const { size } = await fs.stat(filePath);
218
213
  const headTail = await readHeadTail(filePath, size);
219
- const sidecar = tailCustomTitle(headTail) === undefined
220
- ? await readSidecarTitle(filePath, sessionId)
221
- : undefined;
222
- const { title, archived } = effectiveTitle(transcriptAgentName(headTail), sdkTitles(headTail, sidecar));
214
+ const { title, archived } = effectiveTitle(transcriptAgentName(headTail), await readTranscriptTitles(filePath, headTail));
223
215
  return title !== undefined && !archived && isArchivedTitle(title) ? visibleTitle(title) : title;
224
216
  }
225
217
  /** Rewrites the sidecar of a copy whose title is `current` when the
@@ -228,7 +220,7 @@ async function copyTitle(filePath, sessionId) {
228
220
  async function alignSidecar(transcript, current, sessionId) {
229
221
  if (current === undefined)
230
222
  return;
231
- const sidecar = await readSidecarTitle(transcript, sessionId);
223
+ const sidecar = await readSidecarTitle(transcript);
232
224
  if (sidecar === undefined || isArchivedTitle(sidecar) === isArchivedTitle(current))
233
225
  return;
234
226
  await writeCustomTitleSidecar(transcript, storedTitle(current, isArchivedTitle(current), sessionId));
@@ -451,7 +443,7 @@ export class SessionIndexService {
451
443
  // The transcript holds the current title, also one changed otherwise
452
444
  // (a `/rename`); without one, the title last given to the CLI.
453
445
  const primary = cli ?? others[0];
454
- const read = primary ? await copyTitle(primary, sessionId) : undefined;
446
+ const read = primary ? await copyTitle(primary) : undefined;
455
447
  const current = read ?? live.stored() ?? live.shown;
456
448
  stored = change(current, sessionId);
457
449
  if (stored !== undefined) {
@@ -496,7 +488,7 @@ export class SessionIndexService {
496
488
  async titleCopies(sessionId, transcripts, change, sidecar) {
497
489
  let first;
498
490
  for (const transcript of transcripts) {
499
- const current = await copyTitle(transcript, sessionId);
491
+ const current = await copyTitle(transcript);
500
492
  const title = change(current, sessionId);
501
493
  if (title === undefined) {
502
494
  await alignSidecar(transcript, current, sessionId);
@@ -504,7 +496,7 @@ export class SessionIndexService {
504
496
  }
505
497
  await ensureTitleRecords(transcript, sessionId, title);
506
498
  first ??= title;
507
- if (sidecar === "always" || (await exists(sidecarPath(transcript)))) {
499
+ if (sidecar === "always" || (await exists(customTitleSidecarPath(transcript)))) {
508
500
  await writeCustomTitleSidecar(transcript, title);
509
501
  }
510
502
  }
@@ -6,7 +6,7 @@
6
6
  * `stat` per transcript. The pages after a cursor reuse that enumeration for
7
7
  * a short while (see {@link SessionIndex.reusableListing}). The metadata of a transcript is
8
8
  * cached by `(path, mtime, size)` in an LRU and read on a miss from one head
9
- * and tail read (the titles by the SDK's rule, see {@link sdkTitles}; the
9
+ * and tail read (the titles by the SDK's rule, see {@link readTranscriptTitles}; the
10
10
  * facts, see {@link scanTranscriptFile}) and the title sidecar. Misses are
11
11
  * read in parallel batches.
12
12
  *
@@ -73,8 +73,6 @@ export type ListQuery = {
73
73
  archived: ArchivedFilter;
74
74
  after?: ListCursor;
75
75
  };
76
- /** The title of the CLI's `custom-title.json` sidecar of a transcript. */
77
- export declare function readSidecarTitle(filePath: string, sessionId: string): Promise<string | undefined>;
78
76
  export type SessionIndexOptions = {
79
77
  /** Whether a live process holds the session. Only for such a session the
80
78
  * whole transcript is searched for its background tasks. */
@@ -235,16 +233,6 @@ export declare class SessionIndex {
235
233
  * then the whole transcript is read.
236
234
  */
237
235
  private withAllBackgroundTasks;
238
- /**
239
- * The titles the SDK gives the listed transcript (`customTitle` and
240
- * `summary` of its `getSessionInfo`), by the SDK's rule from the head and
241
- * tail read here and the sidecar (see {@link sdkTitles}). Not through the
242
- * SDK itself: its lookup of the transcript reads the whole project
243
- * directory on every call, which made each page of a large project cost a
244
- * listing of every transcript per row, and it may read another copy of the
245
- * session than the listed one.
246
- */
247
- private titlesOf;
248
236
  /** Whether a successor of a continued transcript holds history: the SDK
249
237
  * list then hides the predecessor. */
250
238
  private continuedElsewhere;
@@ -1 +1 @@
1
- {"version":3,"file":"session-index.d.ts","sourceRoot":"","sources":["../../src/session-index/session-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAmBH,OAAO,EAeL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAK9B,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,uEAAuE;AACvE,qBAAa,4BAA6B,SAAQ,KAAK;CAAG;AAiB1D;;aAEa;AACb,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,UAAU,GAAG,KAAK,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAAsC,CAAC;AAE7F,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAEtF;AAED,oDAAoD;AACpD,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,4EAA4E;IAC5E,WAAW,C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,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIjD,gDAAgD;IAChD,UAAU,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAI9C,gEAAgE;IAC1D,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAkC7E,2DAA2D;YAC7C,YAAY;IAS1B;;;;;;;;;OASG;YACW,eAAe;IAa7B;;;;;;;;OAQG;IACG,MAAM,CACV,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,QAAQ,EAAE,MAAM,SAAS,mBAAmB,EAAE,GAC7C,OAAO,CAAC,QAAQ,EAAE,CAAC;IAStB;;;;;;;;OAQG;IACG,YAAY,CAChB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,UAAU,EAAE,SAAS,mBAAmB,EAAE,EAC1C,EAAE,IAAW,EAAE,GAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO,GACvC,OAAO,CAAC;QAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;IAkCtD;;;;;;;;;;;;OAYG;YACW,WAAW;IAqGzB;iCAC6B;IAC7B,OAAO,CAAC,YAAY;IAkBpB;;;uDAGmD;YACrC,YAAY;IAyC1B,iEAAiE;IACjE,OAAO,CAAC,WAAW;YAaL,UAAU;YAwBV,YAAY;YA2BZ,YAAY;IAgD1B;;;;;OAKG;YACW,sBAAsB;IAYpC;2CACuC;YACzB,kBAAkB;IAKhC;;yDAEqD;YACvC,UAAU;CAazB"}
@@ -6,7 +6,7 @@
6
6
  * `stat` per transcript. The pages after a cursor reuse that enumeration for
7
7
  * a short while (see {@link SessionIndex.reusableListing}). The metadata of a transcript is
8
8
  * cached by `(path, mtime, size)` in an LRU and read on a miss from one head
9
- * and tail read (the titles by the SDK's rule, see {@link sdkTitles}; the
9
+ * and tail read (the titles by the SDK's rule, see {@link readTranscriptTitles}; the
10
10
  * facts, see {@link scanTranscriptFile}) and the title sidecar. Misses are
11
11
  * read in parallel batches.
12
12
  *
@@ -24,7 +24,7 @@ import { sanitizeTitle } from "../session-titles.js";
24
24
  import { effectiveTitle, visibleTitle } from "./archive-title.js";
25
25
  import { isSessionId, projectsRoot } from "../paths.js";
26
26
  import { canonicalPath, encodeProjectPath, errorCode, exists, isExactProjectDir, normalizePath, pathAndAncestors, projectDirMatches, projectDirsOf, sameProjectPath, } from "./project-dirs.js";
27
- import { continuedInSessionId, hasHistory, isSidechainTranscript, lastTimestamp, readHeadTail, relocatedCwd, scanTranscriptFile, sdkTitles, tailCustomTitle, transcriptAgentName, transcriptProjectCwd, } from "./transcript-scan.js";
27
+ import { continuedInSessionId, hasHistory, isSidechainTranscript, lastTimestamp, readHeadTail, readTranscriptTitles, relocatedCwd, scanTranscriptFile, transcriptAgentName, transcriptProjectCwd, } from "./transcript-scan.js";
28
28
  import { searchBackgroundTasks } from "./background-tasks.js";
29
29
  import { DirListings, statFiles } from "./dir-listing.js";
30
30
  import { isInLinkedWorktree, worktreeCounterparts } from "./worktrees.js";
@@ -168,17 +168,6 @@ function byMtimeDescending(a, b) {
168
168
  return b.mtimeMs - a.mtimeMs;
169
169
  return a.sessionId < b.sessionId ? -1 : a.sessionId > b.sessionId ? 1 : 0;
170
170
  }
171
- /** The title of the CLI's `custom-title.json` sidecar of a transcript. */
172
- export async function readSidecarTitle(filePath, sessionId) {
173
- try {
174
- const text = await fs.readFile(path.join(path.dirname(filePath), sessionId, "custom-title.json"), "utf8");
175
- const title = JSON.parse(text).customTitle;
176
- return typeof title === "string" && title.trim() ? title : undefined;
177
- }
178
- catch {
179
- return undefined;
180
- }
181
- }
182
171
  /**
183
172
  * On macOS the SDK opens `<projects>/<encoded cwd>` through the file system,
184
173
  * which ignores case on the usual volumes: a directory whose name differs in
@@ -876,7 +865,7 @@ export class SessionIndex {
876
865
  ]);
877
866
  if (fileCwd)
878
867
  this.dirCwds.set(candidate.dirName, fileCwd);
879
- const sdk = await this.titlesOf(candidate, headTail);
868
+ const sdk = await readTranscriptTitles(candidate.filePath, headTail);
880
869
  // No title at all: the SDK does not list it either.
881
870
  if (!sdk.summary)
882
871
  return null;
@@ -916,21 +905,6 @@ export class SessionIndex {
916
905
  const backgroundTasks = await searchBackgroundTasks(candidate.filePath, candidate.size);
917
906
  return { ...facts, backgroundTasks };
918
907
  }
919
- /**
920
- * The titles the SDK gives the listed transcript (`customTitle` and
921
- * `summary` of its `getSessionInfo`), by the SDK's rule from the head and
922
- * tail read here and the sidecar (see {@link sdkTitles}). Not through the
923
- * SDK itself: its lookup of the transcript reads the whole project
924
- * directory on every call, which made each page of a large project cost a
925
- * listing of every transcript per row, and it may read another copy of the
926
- * session than the listed one.
927
- */
928
- async titlesOf(candidate, headTail) {
929
- const sidecar = tailCustomTitle(headTail) === undefined
930
- ? await readSidecarTitle(candidate.filePath, candidate.sessionId)
931
- : undefined;
932
- return sdkTitles(headTail, sidecar);
933
- }
934
908
  /** Whether a successor of a continued transcript holds history: the SDK
935
909
  * list then hides the predecessor. */
936
910
  async continuedElsewhere(candidate, metadata) {
@@ -133,9 +133,18 @@ export declare function scanTranscript({ head, tail }: HeadTail, options?: {
133
133
  /** Whether the first record of the transcript is a sidechain one, which the
134
134
  * SDK never lists. */
135
135
  export declare function isSidechainTranscript(head: string): boolean;
136
- /** The title of the last `custom-title` record of the tail, as the SDK reads
137
- * it (see {@link lastRecordField}). */
138
- export declare function tailCustomTitle({ tail, sdkTail }: HeadTail): string | undefined;
136
+ /** `<projectDir>/<sessionId>/custom-title.json` of a transcript. */
137
+ export declare function customTitleSidecarPath(transcriptPath: string): string;
138
+ /** The custom title that the SDK reads first: the tail's, else the CLI's
139
+ * sidecar's. A strict read throws when the sidecar cannot be read. */
140
+ export declare function readRecentCustomTitle(transcriptPath: string, headTail: HeadTail, options?: {
141
+ strict: boolean;
142
+ }): Promise<string | undefined>;
143
+ /** The title of the CLI's sidecar, if it has a readable title. A strict read
144
+ * throws when the sidecar exists but cannot be read. */
145
+ export declare function readSidecarTitle(transcriptPath: string, options?: {
146
+ strict: boolean;
147
+ }): Promise<string | undefined>;
139
148
  /** The last agent name of a transcript, as AIR's native Claude provider
140
149
  * reads it: the top-level `agentName` of any record, from the tail, else
141
150
  * from the head. */
@@ -154,7 +163,11 @@ export type SdkTitles = {
154
163
  * file, without its lookup of the file. The sidecar title counts only when
155
164
  * the tail has no custom title.
156
165
  */
157
- export declare function sdkTitles({ head, tail: wholeLines, sdkTail }: HeadTail, sidecarTitle?: string): SdkTitles;
166
+ export declare function sdkTitles(headTail: HeadTail, sidecarTitle?: string): SdkTitles;
167
+ /** Reads the titles of this transcript copy without another SDK project lookup. */
168
+ export declare function readTranscriptTitles(transcriptPath: string, headTail: HeadTail, options?: {
169
+ strict: boolean;
170
+ }): Promise<SdkTitles>;
158
171
  /** The title of a transcript without a custom title, in the SDK's order: AI
159
172
  * title, last prompt, summary, first prompt. The last prompt and the summary
160
173
  * are the field of a record of any type. */
@@ -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;AACvC,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAchF,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,O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AAC,OAAO,CAAC,CA2BnE"}
@@ -12,8 +12,10 @@
12
12
  * earlier scan (see `background-tasks.ts`).
13
13
  */
14
14
  import * as fs from "node:fs/promises";
15
+ import * as path from "node:path";
15
16
  import { backgroundTasksOf } from "./background-tasks.js";
16
17
  import { firstPrompt, isUserPrompt, mediaPrompt, promptOf } from "./first-prompt.js";
18
+ import { errorCode } from "./project-dirs.js";
17
19
  const CHUNK_SIZE = 64 * 1024;
18
20
  /** The largest tail window read to find the last message. */
19
21
  const MAX_TAIL_SIZE = 4 * 1024 * 1024;
@@ -532,9 +534,40 @@ export function isSidechainTranscript(head) {
532
534
  }
533
535
  /** The title of the last `custom-title` record of the tail, as the SDK reads
534
536
  * it (see {@link lastRecordField}). */
535
- export function tailCustomTitle({ tail, sdkTail }) {
537
+ function tailCustomTitle({ tail, sdkTail }) {
536
538
  return lastRecordField(sdkTail ?? tail, "customTitle", "custom-title");
537
539
  }
540
+ /** `<projectDir>/<sessionId>/custom-title.json` of a transcript. */
541
+ export function customTitleSidecarPath(transcriptPath) {
542
+ const sessionId = path.basename(transcriptPath, ".jsonl");
543
+ return path.join(path.dirname(transcriptPath), sessionId, "custom-title.json");
544
+ }
545
+ /** The custom title that the SDK reads first: the tail's, else the CLI's
546
+ * sidecar's. A strict read throws when the sidecar cannot be read. */
547
+ export async function readRecentCustomTitle(transcriptPath, headTail, options) {
548
+ return tailCustomTitle(headTail) ?? (await readSidecarTitle(transcriptPath, options));
549
+ }
550
+ /** The title of the CLI's sidecar, if it has a readable title. A strict read
551
+ * throws when the sidecar exists but cannot be read. */
552
+ export async function readSidecarTitle(transcriptPath, options) {
553
+ const file = customTitleSidecarPath(transcriptPath);
554
+ let text;
555
+ try {
556
+ text = await fs.readFile(file, "utf8");
557
+ }
558
+ catch (error) {
559
+ if (options?.strict && errorCode(error) !== "ENOENT")
560
+ throw error;
561
+ return undefined;
562
+ }
563
+ try {
564
+ const title = JSON.parse(text).customTitle;
565
+ return typeof title === "string" && title.trim() ? title : undefined;
566
+ }
567
+ catch {
568
+ return undefined;
569
+ }
570
+ }
538
571
  /** The last non-blank top-level `agentName` of the records of `text`, the
539
572
  * name `/rename`, a `rename_session` and AIR write with the custom title. */
540
573
  function lastAgentName(text) {
@@ -564,15 +597,23 @@ export function transcriptAgentName({ head, tail }) {
564
597
  * file, without its lookup of the file. The sidecar title counts only when
565
598
  * the tail has no custom title.
566
599
  */
567
- export function sdkTitles({ head, tail: wholeLines, sdkTail }, sidecarTitle) {
600
+ export function sdkTitles(headTail, sidecarTitle) {
601
+ const { head, tail: wholeLines, sdkTail } = headTail;
568
602
  const tail = sdkTail ?? wholeLines;
569
- const customTitle = lastRecordField(tail, "customTitle", "custom-title") ??
603
+ const customTitle = tailCustomTitle(headTail) ??
570
604
  sidecarTitle ??
571
605
  lastRecordField(head, "customTitle", "custom-title") ??
572
606
  lastRecordField(tail, "aiTitle", "ai-title") ??
573
607
  lastRecordField(head, "aiTitle", "ai-title");
574
608
  return { customTitle, summary: customTitle ?? generatedTitle({ head, tail }) };
575
609
  }
610
+ /** Reads the titles of this transcript copy without another SDK project lookup. */
611
+ export async function readTranscriptTitles(transcriptPath, headTail, options) {
612
+ const customTitle = tailCustomTitle(headTail);
613
+ if (customTitle !== undefined)
614
+ return { customTitle, summary: customTitle };
615
+ return sdkTitles(headTail, await readSidecarTitle(transcriptPath, options));
616
+ }
576
617
  /** The title of a transcript without a custom title, in the SDK's order: AI
577
618
  * title, last prompt, summary, first prompt. The last prompt and the summary
578
619
  * are the field of a record of any type. */