@agentclientprotocol/claude-agent-acp 0.88.1-preview.5 → 0.88.1-preview.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/acp-agent.d.ts +39 -2
  2. package/dist/acp-agent.d.ts.map +1 -1
  3. package/dist/acp-agent.js +120 -35
  4. package/dist/air-extension.d.ts +23 -0
  5. package/dist/air-extension.d.ts.map +1 -1
  6. package/dist/air-extension.js +23 -0
  7. package/dist/diff.d.ts +2 -0
  8. package/dist/diff.d.ts.map +1 -1
  9. package/dist/diff.js +37 -1
  10. package/dist/mcp-command.d.ts.map +1 -1
  11. package/dist/mcp-command.js +5 -0
  12. package/dist/session-index/activity.d.ts +56 -0
  13. package/dist/session-index/activity.d.ts.map +1 -0
  14. package/dist/session-index/activity.js +96 -0
  15. package/dist/session-index/archive-title.d.ts +52 -0
  16. package/dist/session-index/archive-title.d.ts.map +1 -0
  17. package/dist/session-index/archive-title.js +77 -0
  18. package/dist/session-index/connection.d.ts +152 -0
  19. package/dist/session-index/connection.d.ts.map +1 -0
  20. package/dist/session-index/connection.js +310 -0
  21. package/dist/session-index/dir-listing.d.ts +30 -0
  22. package/dist/session-index/dir-listing.d.ts.map +1 -0
  23. package/dist/session-index/dir-listing.js +110 -0
  24. package/dist/session-index/explicit-title.d.ts +34 -0
  25. package/dist/session-index/explicit-title.d.ts.map +1 -0
  26. package/dist/session-index/explicit-title.js +65 -0
  27. package/dist/session-index/first-prompt.d.ts +37 -0
  28. package/dist/session-index/first-prompt.d.ts.map +1 -0
  29. package/dist/session-index/first-prompt.js +195 -0
  30. package/dist/session-index/list-subscriptions.d.ts +190 -0
  31. package/dist/session-index/list-subscriptions.d.ts.map +1 -0
  32. package/dist/session-index/list-subscriptions.js +1163 -0
  33. package/dist/session-index/live-registry.d.ts +72 -0
  34. package/dist/session-index/live-registry.d.ts.map +1 -0
  35. package/dist/session-index/live-registry.js +240 -0
  36. package/dist/session-index/project-dirs.d.ts +45 -0
  37. package/dist/session-index/project-dirs.d.ts.map +1 -0
  38. package/dist/session-index/project-dirs.js +122 -0
  39. package/dist/session-index/service.d.ts +158 -0
  40. package/dist/session-index/service.d.ts.map +1 -0
  41. package/dist/session-index/service.js +546 -0
  42. package/dist/session-index/session-index.d.ts +201 -0
  43. package/dist/session-index/session-index.d.ts.map +1 -0
  44. package/dist/session-index/session-index.js +740 -0
  45. package/dist/session-index/session-info.d.ts +16 -0
  46. package/dist/session-index/session-info.d.ts.map +1 -0
  47. package/dist/session-index/session-info.js +51 -0
  48. package/dist/session-index/transcript-scan.d.ts +137 -0
  49. package/dist/session-index/transcript-scan.d.ts.map +1 -0
  50. package/dist/session-index/transcript-scan.js +545 -0
  51. package/dist/session-index/worktrees.d.ts +25 -0
  52. package/dist/session-index/worktrees.d.ts.map +1 -0
  53. package/dist/session-index/worktrees.js +128 -0
  54. package/dist/session-titles.d.ts +21 -0
  55. package/dist/session-titles.d.ts.map +1 -1
  56. package/dist/session-titles.js +101 -5
  57. package/dist/utils.d.ts +31 -0
  58. package/dist/utils.d.ts.map +1 -1
  59. package/dist/utils.js +60 -2
  60. package/dist/v2/agent.d.ts.map +1 -1
  61. package/dist/v2/agent.js +33 -4
  62. package/package.json +1 -1
@@ -0,0 +1,201 @@
1
+ /**
2
+ * The session list of a `sessionIndex` client.
3
+ *
4
+ * Each list enumerates the transcripts of the requested cwd and of every
5
+ * worktree of its repository: one `readdir` per project directory and one
6
+ * `stat` per transcript, no long-lived cache. The metadata of a transcript is
7
+ * cached by `(path, mtime, size)` in an LRU and read on a miss with the SDK
8
+ * `getSessionInfo` (titles, sidecar) plus one head and tail read for
9
+ * what the SDK does not report (see {@link scanTranscript}). Misses are read in
10
+ * parallel batches.
11
+ *
12
+ * Order is the last user activity descending, then session id: the time of
13
+ * the last real user prompt (`lastPromptAt`), else `updatedAt`. `updatedAt`
14
+ * is the time of the last message, capped at the transcript mtime, so a
15
+ * rename or another metadata record does not move a session up, and the
16
+ * order key is never later than it. Candidates are read in mtime order: a
17
+ * candidate's order key is at most its mtime, so the scan stops as soon as
18
+ * the page is full and the next mtime is older than the key of the last row.
19
+ */
20
+ import type { SDKSessionInfo } from "@anthropic-ai/claude-agent-sdk";
21
+ import { type TranscriptFacts } from "./transcript-scan.js";
22
+ export declare const DEFAULT_LIST_LIMIT = 50;
23
+ export declare const MAX_LIST_LIMIT = 200;
24
+ /** Which sessions a list holds by archive state: `unarchived` the
25
+ * unarchived ones only, `archived` the archived ones only, `all` both in one
26
+ * order. */
27
+ export type ArchivedFilter = "unarchived" | "archived" | "all";
28
+ export declare const ARCHIVED_FILTERS: readonly ArchivedFilter[];
29
+ /** Whether `filter` keeps a session of that archive state. */
30
+ export declare function archivedFilterKeeps(filter: ArchivedFilter, archived: boolean): boolean;
31
+ /** One transcript file found by the enumeration. */
32
+ export type TranscriptCandidate = {
33
+ sessionId: string;
34
+ filePath: string;
35
+ dirName: string;
36
+ /** The requested path (cwd or worktree) whose project directory this is. */
37
+ projectPath?: string;
38
+ mtimeMs: number;
39
+ size: number;
40
+ /** Tells a replaced file from one that grew. */
41
+ ino: number;
42
+ };
43
+ export type IndexRow = {
44
+ sessionId: string;
45
+ cwd: string;
46
+ title: string;
47
+ updatedAtMs: number;
48
+ /** The order key: the last user activity, `lastPromptAt`, else
49
+ * `updatedAt`. Never later than `updatedAt`, so never later than the
50
+ * transcript mtime. */
51
+ orderAtMs: number;
52
+ facts: TranscriptFacts;
53
+ mtimeMs: number;
54
+ archived: boolean;
55
+ };
56
+ /** A keyset position: the order key and the session id of the last row. */
57
+ export type ListCursor = {
58
+ orderAtMs: number;
59
+ sessionId: string;
60
+ };
61
+ export type ListQuery = {
62
+ cwd?: string | null;
63
+ /** Also list the sessions of the existing linked worktrees of `cwd`. */
64
+ includeWorktrees?: boolean;
65
+ limit: number;
66
+ archived: ArchivedFilter;
67
+ after?: ListCursor;
68
+ };
69
+ export type GetSessionInfo = (sessionId: string, options: {
70
+ dir?: string;
71
+ }) => Promise<SDKSessionInfo | undefined>;
72
+ /** The title of the CLI's `custom-title.json` sidecar of a transcript. */
73
+ export declare function readSidecarTitle(filePath: string, sessionId: string): Promise<string | undefined>;
74
+ export declare class SessionIndex {
75
+ private readonly getSessionInfo;
76
+ private readonly listings;
77
+ private readonly metadata;
78
+ /** The metadata reads in flight, by path: a list and a subscription that
79
+ * want the same transcript at the same stat read it once. */
80
+ private readonly reading;
81
+ /** A cwd that encodes to each project directory name, learned from its
82
+ * transcripts; it recovers the cwd of a sibling that has none. */
83
+ private readonly dirCwds;
84
+ /** The project cwd of the transcripts of prefix-matched long directories. */
85
+ private readonly transcriptCwds;
86
+ /** Directories whose transcripts gave no cwd, by the directory mtime and
87
+ * when that was learned. */
88
+ private readonly dirsWithoutCwd;
89
+ constructor(getSessionInfo: GetSessionInfo);
90
+ /** The paths whose sessions a list of `cwd` shows: `cwd`, and with
91
+ * `includeWorktrees` the same subdirectory of every other existing
92
+ * worktree of its repository (the worktree roots for a cwd at the root). */
93
+ listedPaths(cwd: string, includeWorktrees: boolean): Promise<string[]>;
94
+ /** The project directories (names under the projects root) of `paths`.
95
+ * A long path is matched by its cut prefix, which other long paths may
96
+ * share: such a directory counts only when one of its transcripts belongs
97
+ * to the path, as the SDK checks. */
98
+ projectDirs(paths: readonly string[]): Promise<{
99
+ dirName: string;
100
+ projectPath: string;
101
+ }[]>;
102
+ /** Whether a transcript of the prefix-matched `dirName` belongs to
103
+ * `projectPath`. The cwd of each transcript is cached by its
104
+ * `(path, mtime, size)`, so a transcript that changes is read again. */
105
+ private longDirBelongsTo;
106
+ /** Every non-empty transcript file of `paths` (without, of all projects),
107
+ * every copy of a session: a list shows the newest one that has a row
108
+ * (see {@link collectRows}), as the SDK does. */
109
+ enumerateFiles(paths?: readonly string[]): Promise<TranscriptCandidate[]>;
110
+ /**
111
+ * Every transcript (with its size) and every `<sessionId>/` directory
112
+ * (sidecar, subagent transcripts) of the session, in any project
113
+ * directory, by the exact id. One pass over the (cached) project directory
114
+ * listings.
115
+ */
116
+ scanSession(sessionId: string): Promise<{
117
+ transcripts: {
118
+ filePath: string;
119
+ size: number;
120
+ }[];
121
+ sessionDirs: string[];
122
+ }>;
123
+ /** Every transcript file of `sessionId` (see {@link scanSession}). Empty
124
+ * files only with `includeEmpty`. */
125
+ findTranscripts(sessionId: string, options?: {
126
+ includeEmpty?: boolean;
127
+ }): Promise<string[]>;
128
+ /** Every `<sessionId>/` directory of the session (see {@link scanSession}). */
129
+ findSessionDirs(sessionId: string): Promise<string[]>;
130
+ /** Whether `candidate` was read at its stat: its metadata is cached, also
131
+ * when it holds no row. False after a failed read. */
132
+ isRead(candidate: TranscriptCandidate): boolean;
133
+ /** The session that the cached metadata of `filePath` says it was
134
+ * continued in. */
135
+ continuedIn(filePath: string): string | undefined;
136
+ /** Drops the cached metadata of `filePaths`. */
137
+ invalidate(filePaths: readonly string[]): void;
138
+ /** One page of rows, plus whether more rows follow the page. */
139
+ list(query: ListQuery): Promise<{
140
+ rows: IndexRow[];
141
+ hasMore: boolean;
142
+ }>;
143
+ /**
144
+ * The rows of `candidates`, one per session (its newest transcript that has
145
+ * a row), any archive state, as a list of `paths` shows them: a candidate
146
+ * without a row (no title, a sidechain, continued elsewhere, another path
147
+ * that shares the project directory) is left out. `siblings` are the other
148
+ * transcripts of the candidates' directories, read only when a candidate
149
+ * has no cwd of its own. The metadata cache makes an unchanged transcript
150
+ * free.
151
+ */
152
+ rowsOf(paths: readonly string[], candidates: readonly TranscriptCandidate[], siblings: () => readonly TranscriptCandidate[]): Promise<IndexRow[]>;
153
+ /**
154
+ * The rows of `candidates` (as {@link rowsOf}) that the metadata cache
155
+ * alone gives, read from it at once, and the ids of the sessions it gives
156
+ * no answer for: a transcript of it has nothing cached at its stat, no cwd
157
+ * known, or is continued in another session (whether the successor hides
158
+ * it depends on the successor now). Reads no transcript.
159
+ */
160
+ cachedRowsOf(paths: readonly string[], candidates: readonly TranscriptCandidate[]): Promise<{
161
+ rows: IndexRow[];
162
+ unknown: Set<string>;
163
+ }>;
164
+ /**
165
+ * Reads `candidates` in order into rows, one per session, sorted. A
166
+ * session copied to several transcripts shows its newest one that has a
167
+ * row, as the SDK list does. With a finite `wanted`, stops once `wanted`
168
+ * rows are certain to come first (a candidate's order key is at most its
169
+ * mtime, so `candidates` must be in mtime order then).
170
+ */
171
+ private collectRows;
172
+ /** Whether the cached metadata of `candidate`, still current, places it
173
+ * at or before `cursor`. */
174
+ private cachedBefore;
175
+ /** Reads the unread transcripts of `dirNames` until each directory has a
176
+ * known cwd, at most {@link MAX_CWD_PROBES_PER_DIR} per directory. A
177
+ * directory that gives none is not read again for a while, unless it
178
+ * changes. */
179
+ private learnDirCwds;
180
+ /** The requested path of the directory, else a sibling's cwd. */
181
+ private fallbackCwd;
182
+ private metadataOf;
183
+ private readAndCache;
184
+ private readMetadata;
185
+ /**
186
+ * The titles the SDK reports for the listed transcript (`customTitle` and
187
+ * `summary` of `getSessionInfo`). The SDK reads the first copy of the
188
+ * session that its search finds; its answer is used only when that copy is
189
+ * the listed file (same size and mtime), else the same titles are taken
190
+ * from the listed file itself (see {@link sdkTitles}).
191
+ */
192
+ private titlesOf;
193
+ /** Whether a successor of a continued transcript holds history: the SDK
194
+ * list then hides the predecessor. */
195
+ private continuedElsewhere;
196
+ /** The first candidate that encodes to `dirName`, or, on macOS, that
197
+ * encodes to a name the file system resolves to `dirName` (it differs in
198
+ * case only). A directory name is never decoded. */
199
+ private recoverCwd;
200
+ }
201
+ //# sourceMappingURL=session-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-index.d.ts","sourceRoot":"","sources":["../../src/session-index/session-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAerE,OAAO,EAeL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAI9B,eAAO,MAAM,kBAAkB,KAAK,CA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