@agentclientprotocol/claude-agent-acp 0.90.1-preview.9 → 0.91.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.
Files changed (44) hide show
  1. package/README.md +14 -5
  2. package/dist/acp-agent.d.ts +94 -11
  3. package/dist/acp-agent.d.ts.map +1 -1
  4. package/dist/acp-agent.js +246 -76
  5. package/dist/air-extension.d.ts +6 -0
  6. package/dist/air-extension.d.ts.map +1 -1
  7. package/dist/air-extension.js +6 -0
  8. package/dist/file-change-audit.d.ts +17 -0
  9. package/dist/file-change-audit.d.ts.map +1 -1
  10. package/dist/file-change-audit.js +62 -20
  11. package/dist/gateway-models.d.ts +62 -0
  12. package/dist/gateway-models.d.ts.map +1 -0
  13. package/dist/gateway-models.js +180 -0
  14. package/dist/native-subagents.d.ts +34 -9
  15. package/dist/native-subagents.d.ts.map +1 -1
  16. package/dist/native-subagents.js +55 -11
  17. package/dist/session-index/connection.d.ts +4 -3
  18. package/dist/session-index/connection.d.ts.map +1 -1
  19. package/dist/session-index/connection.js +8 -7
  20. package/dist/session-index/list-subscriptions.d.ts.map +1 -1
  21. package/dist/session-index/list-subscriptions.js +4 -1
  22. package/dist/session-index/service.d.ts +10 -0
  23. package/dist/session-index/service.d.ts.map +1 -1
  24. package/dist/session-index/service.js +21 -0
  25. package/dist/session-index/session-index.d.ts +10 -2
  26. package/dist/session-index/session-index.d.ts.map +1 -1
  27. package/dist/session-index/session-index.js +21 -5
  28. package/dist/session-index/session-info.d.ts.map +1 -1
  29. package/dist/session-index/session-info.js +1 -0
  30. package/dist/session-index/transcript-scan.d.ts +25 -1
  31. package/dist/session-index/transcript-scan.d.ts.map +1 -1
  32. package/dist/session-index/transcript-scan.js +57 -1
  33. package/dist/session-index/worktrees.d.ts +6 -0
  34. package/dist/session-index/worktrees.d.ts.map +1 -1
  35. package/dist/session-index/worktrees.js +12 -0
  36. package/dist/session-model.d.ts +21 -1
  37. package/dist/session-model.d.ts.map +1 -1
  38. package/dist/session-model.js +89 -11
  39. package/dist/turn-events.d.ts +5 -1
  40. package/dist/turn-events.d.ts.map +1 -1
  41. package/dist/v2/prompt.d.ts +2 -1
  42. package/dist/v2/prompt.d.ts.map +1 -1
  43. package/dist/v2/prompt.js +2 -1
  44. package/package.json +3 -3
@@ -70,8 +70,8 @@ export declare class SessionIndexConnection {
70
70
  * every other client the title as stored. */
71
71
  clientTitle(title: string): string;
72
72
  /** The AIR capabilities the agent advertises for the index: the index
73
- * itself, archive, rename and the list subscription, all only to a client
74
- * that declared `sessionIndex`. */
73
+ * itself, archive, rename, the list subscription and the `agentWorktree`
74
+ * row field, all only to a client that declared `sessionIndex`. */
75
75
  capabilities(): string[];
76
76
  dispose(): void;
77
77
  /** The query of a session that ran here failed (not a cancel): its row
@@ -120,7 +120,8 @@ export declare class SessionIndexConnection {
120
120
  * - Another AIR client uses delete to mark a session done, and may reopen
121
121
  * it later: the adapter archives it instead (as `_session/archive` does,
122
122
  * after the CLI closed), so the transcript survives.
123
- * - Every other client: the SDK delete, as before.
123
+ * - Every other client: the SDK delete. A session without a transcript
124
+ * succeeds (see {@link deleteSessionIfStored}).
124
125
  */
125
126
  deleteSession(params: DeleteSessionRequest): Promise<DeleteSessionResponse>;
126
127
  private airArchiver;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/session-index/connection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAWlE,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,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IAgBnE;;;+CAG2C;IACrC,OAAO,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAgC/D,sEAAsE;IAChE,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAWjE;;;;;OAKG;YACW,OAAO;IA8CrB;;;;;;;;;OASG;IACG,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAiBjF,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,cAAc;IAKtB,yEAAyE;IACzE,OAAO,CAAC,eAAe;IAgBvB;;wEAEoE;IACpE,OAAO,CAAC,kBAAkB;IAU1B;;;sCAGkC;YACpB,cAAc;CAc7B;AAED,oEAAoE;AACpE,KAAK,mBAAmB,GAAG;IACzB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACnF,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/E,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzE,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACjE,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACpE,CAAC;AAEF;sEACsE;AACtE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,GAAG,QAAQ,CA2BhG"}
@@ -7,11 +7,10 @@
7
7
  * Wire contract: docs/air-extensions.md, "Session index".
8
8
  */
9
9
  import { RequestError, } from "@agentclientprotocol/sdk";
10
- import { deleteSession as sdkDeleteSession } from "@anthropic-ai/claude-agent-sdk";
11
- import { AIR_SESSION_ARCHIVE_CAPABILITY, AIR_SESSION_INDEX_CAPABILITY, AIR_SESSION_LIST_SUBSCRIBE_CAPABILITY, AIR_SESSION_RENAME_CAPABILITY, clientSupportsAirCapability, withAirMeta, } from "../air-extension.js";
10
+ import { AIR_SESSION_ARCHIVE_CAPABILITY, AIR_SESSION_INDEX_CAPABILITY, AIR_SESSION_LIST_SUBSCRIBE_CAPABILITY, AIR_SESSION_RENAME_CAPABILITY, AIR_SESSION_WORKTREES_CAPABILITY, clientSupportsAirCapability, withAirMeta, } from "../air-extension.js";
12
11
  import { isArchivedTitle, storedTitle, visibleTitle } from "./archive-title.js";
13
12
  import { LIST_CHANGES_METHOD, LIST_SUBSCRIBE_METHOD, LIST_UNSUBSCRIBE_METHOD, parseListSubscribeRequest, parseListUnsubscribeRequest, } from "./list-subscriptions.js";
14
- import { archiveInsteadOfDelete, archiveTo, renameTo, parseRenameSessionRequest, parseSessionIdRequest, SESSION_ARCHIVE_METHOD, SESSION_RENAME_METHOD, SESSION_UNARCHIVE_METHOD, SessionIndexService, } from "./service.js";
13
+ import { archiveInsteadOfDelete, deleteSessionIfStored, archiveTo, renameTo, parseRenameSessionRequest, parseSessionIdRequest, SESSION_ARCHIVE_METHOD, SESSION_RENAME_METHOD, SESSION_UNARCHIVE_METHOD, SessionIndexService, } from "./service.js";
15
14
  /** Records the end of a turn at `session_state_changed`. */
16
15
  export function noteSessionState(session, previous, state) {
17
16
  if (state === "idle" && previous !== "idle")
@@ -57,8 +56,8 @@ export class SessionIndexConnection {
57
56
  return this.host.isAirClient() && isArchivedTitle(title) ? visibleTitle(title) : title;
58
57
  }
59
58
  /** The AIR capabilities the agent advertises for the index: the index
60
- * itself, archive, rename and the list subscription, all only to a client
61
- * that declared `sessionIndex`. */
59
+ * itself, archive, rename, the list subscription and the `agentWorktree`
60
+ * row field, all only to a client that declared `sessionIndex`. */
62
61
  capabilities() {
63
62
  return this.service
64
63
  ? [
@@ -66,6 +65,7 @@ export class SessionIndexConnection {
66
65
  AIR_SESSION_ARCHIVE_CAPABILITY,
67
66
  AIR_SESSION_RENAME_CAPABILITY,
68
67
  AIR_SESSION_LIST_SUBSCRIBE_CAPABILITY,
68
+ AIR_SESSION_WORKTREES_CAPABILITY,
69
69
  ]
70
70
  : [];
71
71
  }
@@ -225,7 +225,8 @@ export class SessionIndexConnection {
225
225
  * - Another AIR client uses delete to mark a session done, and may reopen
226
226
  * it later: the adapter archives it instead (as `_session/archive` does,
227
227
  * after the CLI closed), so the transcript survives.
228
- * - Every other client: the SDK delete, as before.
228
+ * - Every other client: the SDK delete. A session without a transcript
229
+ * succeeds (see {@link deleteSessionIfStored}).
229
230
  */
230
231
  async deleteSession(params) {
231
232
  const loaded = this.host.agent.sessions[params.sessionId] !== undefined;
@@ -241,7 +242,7 @@ export class SessionIndexConnection {
241
242
  await archiveInsteadOfDelete(params.sessionId, this.airArchiver());
242
243
  }
243
244
  else {
244
- await sdkDeleteSession(params.sessionId);
245
+ await deleteSessionIfStored(params.sessionId);
245
246
  }
246
247
  return {};
247
248
  }
@@ -1 +1 @@
1
- {"version":3,"file":"list-subscriptions.d.ts","sourceRoot":"","sources":["../../src/session-index/list-subscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAIL,KAAK,mBAAmB,EAEzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAiB,KAAK,YAAY,EAA4B,MAAM,oBAAoB,CAAC;AAGhG,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAC/D,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AACnE,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAE3D,oCAAoC;AACpC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AASrC,MAAM,MAAM,oBAAoB,GAAG;IAAE,GAAG,EAAE,MAAM,CAA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B;;;;;OAKG;YACW,SAAS;IAsCvB,oDAAoD;IACpD,OAAO,CAAC,OAAO;IASf;;;;;;;OAOG;YACW,WAAW;IAmBzB;;yCAEqC;IACrC,OAAO,CAAC,OAAO;IAkDf,wEAAwE;IACxE,OAAO,CAAC,cAAc;CAMvB"}
@@ -1115,7 +1115,10 @@ export class ListSubscriptions {
1115
1115
  }
1116
1116
  if (candidates.length === 0)
1117
1117
  return new Set();
1118
- const { rows, unknown } = await this.deps.index.cachedRowsOf(paths, candidates);
1118
+ // Only the ids count: no worktree check.
1119
+ const { rows, unknown } = await this.deps.index.cachedRowsOf(paths, candidates, {
1120
+ mark: false,
1121
+ });
1119
1122
  for (const row of rows)
1120
1123
  unknown.add(row.sessionId);
1121
1124
  return unknown;
@@ -56,6 +56,16 @@ export declare function renameTo(title: string): TitleChange;
56
56
  /** `_session/archive` and `_session/unarchive`: the current title with or
57
57
  * without the archive prefix; a copy already in that state is left alone. */
58
58
  export declare function archiveTo(archived: boolean): TitleChange;
59
+ /**
60
+ * `session/delete` of a client that is neither AIR nor a `sessionIndex` client:
61
+ * the SDK delete of the session's transcript. A session without one succeeds,
62
+ * as ACP asks ("Deleting an already-deleted session, or a session that never
63
+ * existed, SHOULD succeed silently"): an id that is not a session id, a
64
+ * session deleted before, or a session this connection ran but never prompted,
65
+ * since Claude Code writes the transcript at the first prompt. Other failures
66
+ * still fail the request.
67
+ */
68
+ export declare function deleteSessionIfStored(sessionId: string, deleteSession?: (sessionId: string) => Promise<void>): Promise<void>;
59
69
  /**
60
70
  * `session/delete` of an AIR client without `sessionIndex`, which uses delete
61
71
  * to mark a session done: archives it instead, so the transcript survives. A
@@ -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,EAC1B,MAAM,0BAA0B,CAAC;AAIlC,OAAO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AC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI1C,OAAO,IAAI,IAAI;CAKhB"}
@@ -276,6 +276,27 @@ function sdkDeleteError(sessionId) {
276
276
  ? `Session ${sessionId} not found in any project directory`
277
277
  : `Invalid sessionId: ${sessionId}`);
278
278
  }
279
+ /**
280
+ * `session/delete` of a client that is neither AIR nor a `sessionIndex` client:
281
+ * the SDK delete of the session's transcript. A session without one succeeds,
282
+ * as ACP asks ("Deleting an already-deleted session, or a session that never
283
+ * existed, SHOULD succeed silently"): an id that is not a session id, a
284
+ * session deleted before, or a session this connection ran but never prompted,
285
+ * since Claude Code writes the transcript at the first prompt. Other failures
286
+ * still fail the request.
287
+ */
288
+ export async function deleteSessionIfStored(sessionId, deleteSession = sdkDeleteSession) {
289
+ if (!isSessionId(sessionId))
290
+ return;
291
+ try {
292
+ await deleteSession(sessionId);
293
+ }
294
+ catch (error) {
295
+ if (isSdkNotFound(error))
296
+ return;
297
+ throw error;
298
+ }
299
+ }
279
300
  /**
280
301
  * `session/delete` of an AIR client without `sessionIndex`, which uses delete
281
302
  * to mark a session done: archives it instead, so the transcript survives. A
@@ -52,6 +52,10 @@ export type IndexRow = {
52
52
  facts: TranscriptFacts;
53
53
  mtimeMs: number;
54
54
  archived: boolean;
55
+ /** The session runs in a linked git worktree that Claude Code made for
56
+ * it: its transcript says so (`facts.agentWorktree`) and `cwd` lies in
57
+ * a linked worktree. See {@link markAgentWorktrees}. */
58
+ agentWorktree?: true;
55
59
  };
56
60
  /** A keyset position: the order key and the session id of the last row. */
57
61
  export type ListCursor = {
@@ -171,9 +175,13 @@ export declare class SessionIndex {
171
175
  * alone gives, read from it at once, and the ids of the sessions it gives
172
176
  * no answer for: a transcript of it has nothing cached at its stat, no cwd
173
177
  * known, or is continued in another session (whether the successor hides
174
- * it depends on the successor now). Reads no transcript.
178
+ * it depends on the successor now). Reads no transcript. The rows carry
179
+ * `agentWorktree` ({@link markAgentWorktrees}, which reads git files)
180
+ * unless `mark` is false, for a caller that uses only their ids.
175
181
  */
176
- cachedRowsOf(paths: readonly string[], candidates: readonly TranscriptCandidate[]): Promise<{
182
+ cachedRowsOf(paths: readonly string[], candidates: readonly TranscriptCandidate[], { mark }?: {
183
+ mark?: boolean;
184
+ }): Promise<{
177
185
  rows: IndexRow[];
178
186
  unknown: Set<string>;
179
187
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"session-index.d.ts","sourceRoot":"","sources":["../../src/session-index/session-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAkBH,OAAO,EAeL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAI9B,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,cAAc,MAAM,CAAC;AAelC;;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,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAmBF,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB;;4BAEwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EA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
@@ -25,7 +25,7 @@ import { effectiveTitle, visibleTitle } from "./archive-title.js";
25
25
  import { canonicalPath, encodeProjectPath, isExactProjectDir, isSessionId, normalizePath, pathAndAncestors, projectDirMatches, projectDirsOf, projectsRoot, sameProjectPath, } from "./project-dirs.js";
26
26
  import { continuedInSessionId, hasHistory, isSidechainTranscript, lastTimestamp, readHeadTail, relocatedCwd, scanTranscriptFile, sdkTitles, tailCustomTitle, transcriptAgentName, transcriptProjectCwd, } from "./transcript-scan.js";
27
27
  import { DirListings, statFiles } from "./dir-listing.js";
28
- import { worktreeCounterparts } from "./worktrees.js";
28
+ import { isInLinkedWorktree, worktreeCounterparts } from "./worktrees.js";
29
29
  export const DEFAULT_LIST_LIMIT = 50;
30
30
  export const MAX_LIST_LIMIT = 200;
31
31
  /** Entries of the metadata cache: a few hundred bytes each, so the
@@ -130,6 +130,19 @@ function toRow({ candidate, metadata }, cwd) {
130
130
  mtimeMs: candidate.mtimeMs,
131
131
  };
132
132
  }
133
+ /**
134
+ * Sets `agentWorktree` on the rows whose transcript says Claude Code made
135
+ * their worktree and whose cwd lies in a linked worktree now. Only those rows
136
+ * are checked; the check is not cached, so a removed worktree shows at once.
137
+ */
138
+ async function markAgentWorktrees(rows) {
139
+ await Promise.all(rows.map(async (row) => {
140
+ if (row.facts.agentWorktree === true && (await isInLinkedWorktree(row.cwd))) {
141
+ row.agentWorktree = true;
142
+ }
143
+ }));
144
+ return rows;
145
+ }
133
146
  function isAfter(row, cursor) {
134
147
  return compareRows(row, cursor) > 0;
135
148
  }
@@ -517,9 +530,11 @@ export class SessionIndex {
517
530
  * alone gives, read from it at once, and the ids of the sessions it gives
518
531
  * no answer for: a transcript of it has nothing cached at its stat, no cwd
519
532
  * known, or is continued in another session (whether the successor hides
520
- * it depends on the successor now). Reads no transcript.
533
+ * it depends on the successor now). Reads no transcript. The rows carry
534
+ * `agentWorktree` ({@link markAgentWorktrees}, which reads git files)
535
+ * unless `mark` is false, for a caller that uses only their ids.
521
536
  */
522
- async cachedRowsOf(paths, candidates) {
537
+ async cachedRowsOf(paths, candidates, { mark = true } = {}) {
523
538
  const unknown = new Set();
524
539
  const resolved = [];
525
540
  for (const candidate of candidates) {
@@ -552,7 +567,8 @@ export class SessionIndex {
552
567
  continue;
553
568
  newest.set(id, { row: toRow(item, cwd), mtimeMs: item.candidate.mtimeMs });
554
569
  }
555
- return { rows: [...newest.values()].map(({ row }) => row), unknown };
570
+ const rows = [...newest.values()].map(({ row }) => row);
571
+ return { rows: mark ? await markAgentWorktrees(rows) : rows, unknown };
556
572
  }
557
573
  /**
558
574
  * Reads `candidates` in order into rows, one per session, sorted. A
@@ -645,7 +661,7 @@ export class SessionIndex {
645
661
  await this.learnDirCwds(new Set(pending.map(({ candidate }) => candidate.dirName)), options.unread(read), options.restat ?? false);
646
662
  await settlePending();
647
663
  }
648
- return rows();
664
+ return markAgentWorktrees(rows());
649
665
  }
650
666
  /** Whether the cached metadata of `candidate`, still current, places it
651
667
  * at or before `cursor`. */
@@ -1 +1 @@
1
- {"version":3,"file":"session-info.d.ts","sourceRoot":"","sources":["../../src/session-index/session-info.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAMnD;kEACkE;AAClE,wBAAgB,aAAa,CAC3B,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,eAAe,GAAG,SAAS,EAChC,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,GAAG,EAAE,MAAM,GACV,WAAW,CAgCb;AAED;gCACgC;AAChC,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAEzD"}
1
+ {"version":3,"file":"session-info.d.ts","sourceRoot":"","sources":["../../src/session-index/session-info.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAMnD;kEACkE;AAClE,wBAAgB,aAAa,CAC3B,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,eAAe,GAAG,SAAS,EAChC,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,GAAG,EAAE,MAAM,GACV,WAAW,CAiCb;AAED;gCACgC;AAChC,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAEzD"}
@@ -27,6 +27,7 @@ export function sessionInfoOf(row, own, live, now) {
27
27
  lastPromptAt: iso(facts.lastPromptAt),
28
28
  model: facts.model,
29
29
  forkedFrom: facts.forkedFrom,
30
+ agentWorktree: row.agentWorktree,
30
31
  state: activity?.state,
31
32
  lastTurnEndedAt: activity?.lastTurnEndedAt,
32
33
  cost: cost === undefined ? undefined : { amount: cost, currency: "USD" },
@@ -36,6 +36,11 @@ export type TranscriptFacts = {
36
36
  /** The session this one was forked from: the `forkedFrom.sessionId` that
37
37
  * the SDK and CLI fork write on every copied record. */
38
38
  forkedFrom?: string;
39
+ /** What the last `worktree-state` record says: true when its
40
+ * `worktreeSession` is set and not `enteredExisting` (Claude Code made the
41
+ * worktree and the session is in it), false when it says otherwise.
42
+ * Undefined when no such record was read. See {@link agentWorktreeOf}. */
43
+ agentWorktree?: boolean;
39
44
  /** Whether the head or the tail holds a user or an assistant message. A
40
45
  * transcript without one is a metadata-only stub. */
41
46
  hasMessages: boolean;
@@ -50,7 +55,7 @@ export type HeadTail = {
50
55
  sdkTail?: string;
51
56
  };
52
57
  /** Facts that an earlier scan may have found before the tail window. */
53
- declare const INHERITED_FACTS: readonly ["model", "tailCwd", "lastTurnEndedAt"];
58
+ declare const INHERITED_FACTS: readonly ["model", "tailCwd", "lastTurnEndedAt", "agentWorktree"];
54
59
  /** What an earlier scan of the same file found, at `size`. */
55
60
  export type PreviousScan = {
56
61
  size: number;
@@ -80,6 +85,25 @@ identity?: number): Promise<TranscriptFacts>;
80
85
  /** The cwd of the last `relocated` record of the tail: where the session
81
86
  * was moved, whatever cwd its earlier messages carry. */
82
87
  export declare function relocatedCwd(tail: string): string | undefined;
88
+ /**
89
+ * Whether the last `worktree-state` record of `text` says the session is in
90
+ * a worktree that Claude Code made for it, as AIR's native Claude provider
91
+ * reads it: a `worktreeSession` that is an object without
92
+ * `enteredExisting: true`. The last line that parses as a `worktree-state`
93
+ * record decides; any other `worktreeSession` (`null`, which the CLI writes
94
+ * when the session leaves the worktree, missing, or no object) means false.
95
+ * Only lines that are not JSON (such as the cut first line of a window) are
96
+ * skipped. Undefined when `text` holds no such record.
97
+ *
98
+ * The CLI writes the record when it enters or leaves a worktree (for
99
+ * `claude --worktree`, at the start of the session, so in the head), and
100
+ * writes it again with the other session metadata at the end of the
101
+ * transcript (on exit and as the transcript grows), so the tail usually
102
+ * holds the latest one. Only the head and the tail are read: a session that
103
+ * entered a worktree midway through a long transcript, with no metadata
104
+ * written after it yet, is not seen until the CLI writes the metadata again.
105
+ */
106
+ export declare function agentWorktreeOf(text: string): boolean | undefined;
83
107
  /** The cwd a transcript belongs to, as the SDK reads it: the last
84
108
  * `relocated` record of the tail, else the first cwd of the head. */
85
109
  export declare function transcriptProjectCwd({ head, tail }: HeadTail): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"transcript-scan.d.ts","sourceRoot":"","sources":["../../src/session-index/transcript-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAcvC,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,YAA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B,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,QAAQ,EAC7C,YAAY,CAAC,EAAE,MAAM,GACpB,SAAS,CASX;AAED;iDACiD;AACjD,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"}
@@ -20,7 +20,7 @@ const FULL_SEARCH_CACHE_SIZE = 512;
20
20
  * the same size is not searched again. */
21
21
  const fullySearched = new Map();
22
22
  /** Facts that an earlier scan may have found before the tail window. */
23
- const INHERITED_FACTS = ["model", "tailCwd", "lastTurnEndedAt"];
23
+ const INHERITED_FACTS = ["model", "tailCwd", "lastTurnEndedAt", "agentWorktree"];
24
24
  /** The last `window` bytes of a file of `size` bytes, without the first,
25
25
  * cut line. The whole file when it fits. */
26
26
  async function readTail(handle, size, window) {
@@ -88,6 +88,13 @@ identity) {
88
88
  }
89
89
  }
90
90
  }
91
+ // No worktree record in the tail (or before it, by an earlier scan): the
92
+ // one `claude --worktree` writes at the start may still be in the head.
93
+ if (facts.agentWorktree === undefined) {
94
+ const agentWorktree = agentWorktreeOf(read.head);
95
+ if (agentWorktree !== undefined)
96
+ facts.agentWorktree = agentWorktree;
97
+ }
91
98
  if (facts.lastPromptAt !== undefined || size <= CHUNK_SIZE) {
92
99
  facts.promptSearched = true;
93
100
  }
@@ -135,6 +142,11 @@ identity) {
135
142
  ...wider,
136
143
  ...(facts.model !== undefined && { model: facts.model }),
137
144
  ...(facts.tailCwd !== undefined && { tailCwd: facts.tailCwd }),
145
+ // The wider tail holds the narrow one, so a record it has is the
146
+ // latest; else the narrow scan's (inherited or from the head) stands.
147
+ ...((wider.agentWorktree ?? facts.agentWorktree) !== undefined && {
148
+ agentWorktree: wider.agentWorktree ?? facts.agentWorktree,
149
+ }),
138
150
  // A turn end the wider tail lacks may lie before it: the
139
151
  // narrow scan inherited it from an earlier scan of this file.
140
152
  lastTurnEndedAt: wider.lastTurnEndedAt ?? facts.lastTurnEndedAt,
@@ -174,6 +186,45 @@ export function relocatedCwd(tail) {
174
186
  }
175
187
  return undefined;
176
188
  }
189
+ const WORKTREE_STATE_MARKER = '"worktree-state"';
190
+ /**
191
+ * Whether the last `worktree-state` record of `text` says the session is in
192
+ * a worktree that Claude Code made for it, as AIR's native Claude provider
193
+ * reads it: a `worktreeSession` that is an object without
194
+ * `enteredExisting: true`. The last line that parses as a `worktree-state`
195
+ * record decides; any other `worktreeSession` (`null`, which the CLI writes
196
+ * when the session leaves the worktree, missing, or no object) means false.
197
+ * Only lines that are not JSON (such as the cut first line of a window) are
198
+ * skipped. Undefined when `text` holds no such record.
199
+ *
200
+ * The CLI writes the record when it enters or leaves a worktree (for
201
+ * `claude --worktree`, at the start of the session, so in the head), and
202
+ * writes it again with the other session metadata at the end of the
203
+ * transcript (on exit and as the transcript grows), so the tail usually
204
+ * holds the latest one. Only the head and the tail are read: a session that
205
+ * entered a worktree midway through a long transcript, with no metadata
206
+ * written after it yet, is not seen until the CLI writes the metadata again.
207
+ */
208
+ export function agentWorktreeOf(text) {
209
+ if (!text.includes(WORKTREE_STATE_MARKER))
210
+ return undefined;
211
+ const lines = text.split("\n");
212
+ for (let i = lines.length - 1; i >= 0; i--) {
213
+ const line = lines[i];
214
+ if (!line.includes(WORKTREE_STATE_MARKER))
215
+ continue;
216
+ const entry = parseLine(line);
217
+ // Only a line that is no JSON record is skipped: the latest record that
218
+ // parses decides, even when its `worktreeSession` is missing or no object.
219
+ if (entry?.type !== "worktree-state")
220
+ continue;
221
+ const session = entry.worktreeSession;
222
+ if (!session || typeof session !== "object" || Array.isArray(session))
223
+ return false;
224
+ return session.enteredExisting !== true;
225
+ }
226
+ return undefined;
227
+ }
177
228
  /** The cwd a transcript belongs to, as the SDK reads it: the last
178
229
  * `relocated` record of the tail, else the first cwd of the head. */
179
230
  export function transcriptProjectCwd({ head, tail }) {
@@ -274,6 +325,11 @@ export function scanTranscript({ head, tail }, options = {}) {
274
325
  const forkedFrom = FORKED_FROM_PATTERN.exec(head)?.[1];
275
326
  if (forkedFrom !== undefined)
276
327
  facts.forkedFrom = forkedFrom;
328
+ // The tail only: scanTranscriptFile falls back to the head after it
329
+ // inherits what an earlier scan found before the tail.
330
+ const agentWorktree = agentWorktreeOf(tail);
331
+ if (agentWorktree !== undefined)
332
+ facts.agentWorktree = agentWorktree;
277
333
  const lines = tail.split("\n");
278
334
  let turnEndFound = false;
279
335
  let messageFound = false;
@@ -17,6 +17,12 @@
17
17
  * worktree root, the worktree roots. Empty outside a repository.
18
18
  */
19
19
  export declare function worktreeCounterparts(cwd: string): Promise<string[]>;
20
+ /**
21
+ * Whether `cwd` lies in a linked worktree: its git dir is
22
+ * `<common-dir>/worktrees/<name>`. False in the main worktree, in a
23
+ * submodule and outside a repository.
24
+ */
25
+ export declare function isInLinkedWorktree(cwd: string): Promise<boolean>;
20
26
  /**
21
27
  * Every existing worktree of the repository that contains `cwd`: the main
22
28
  * worktree and the linked ones. Empty outside a repository.
@@ -1 +1 @@
1
- {"version":3,"file":"worktrees.d.ts","sourceRoot":"","sources":["../../src/session-index/worktrees.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqFH;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAazE;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAaxE"}
1
+ {"version":3,"file":"worktrees.d.ts","sourceRoot":"","sources":["../../src/session-index/worktrees.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAqFH;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAazE;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKtE;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAaxE"}
@@ -110,6 +110,18 @@ export async function worktreeCounterparts(cwd) {
110
110
  const existing = await Promise.all(candidates.map(async (candidate) => (await statOrUndefined(candidate))?.isDirectory() ? normalizePath(candidate) : undefined));
111
111
  return [...new Set(existing.filter((value) => value !== undefined))];
112
112
  }
113
+ /**
114
+ * Whether `cwd` lies in a linked worktree: its git dir is
115
+ * `<common-dir>/worktrees/<name>`. False in the main worktree, in a
116
+ * submodule and outside a repository.
117
+ */
118
+ export async function isInLinkedWorktree(cwd) {
119
+ const gitDir = await findGitDir(cwd);
120
+ if (!gitDir)
121
+ return false;
122
+ const commonDir = await commonDirOf(gitDir);
123
+ return path.resolve(path.dirname(gitDir)) === path.resolve(commonDir, "worktrees");
124
+ }
113
125
  /**
114
126
  * Every existing worktree of the repository that contains `cwd`: the main
115
127
  * worktree and the linked ones. Empty outside a repository.
@@ -46,6 +46,26 @@ export declare function isDeniedModel(modelId: string, deniedModels: readonly st
46
46
  * dropped even though the CLI would otherwise leave it unmatched.
47
47
  */
48
48
  export declare function applyAvailableModelsAllowlist(sdkModels: ModelInfo[], allowlist: string[], settingsModelOverrides?: Record<string, string>, deniedModels?: readonly string[]): ModelInfo[];
49
- export declare function getAvailableModels(query: Query, models: ModelInfo[], sdkModels: ModelInfo[], settingsManager: ModelSettingsSource, logger: ModelLogger, isResumedSession: boolean, sessionId: string, resumedModelHint?: string): Promise<SessionModelState>;
49
+ /**
50
+ * Keep the SDK models the `providers/set` gateway listed (`listGatewayModels`,
51
+ * `listBedrockModels`). A row matches when its `resolvedModel` (or
52
+ * its `value` when the SDK gives none) names a listed model in any spelling:
53
+ * `claude-sonnet-5[1m]` matches a listed `claude-sonnet-5-20260101`, and
54
+ * `eu.anthropic.claude-sonnet-5` matches a listed `eu.anthropic.claude-sonnet-5-v1:0`.
55
+ *
56
+ * With a Bedrock `regionPrefix`, a row resolved to another cross-region prefix
57
+ * (`us.anthropic.claude-sonnet-5` under `eu`) is dropped even when the same
58
+ * model is listed under `eu`: the CLI would call it in the other region.
59
+ *
60
+ * A row the SDK gives no `resolvedModel` names its model only by an alias, so
61
+ * it is checked as far as the alias allows: `default` is kept, and a family
62
+ * alias such as `opus` is kept when the gateway lists a model of that family.
63
+ *
64
+ * When no row matches by its model (a `default` row kept only for lacking a
65
+ * `resolvedModel` does not count), the gateway serves none of the SDK's
66
+ * models, and nothing is left: the session offers no model.
67
+ */
68
+ export declare function narrowToGatewayModels(models: ModelInfo[], listedModelIds: readonly string[], regionPrefix?: string): ModelInfo[];
69
+ export declare function getAvailableModels(query: Query, models: ModelInfo[], sdkModels: ModelInfo[], settingsManager: ModelSettingsSource, logger: ModelLogger, isResumedSession: boolean, sessionId: string, resumedModelHint?: string, narrowedByGateway?: boolean): Promise<SessionModelState>;
50
70
  export {};
51
71
  //# sourceMappingURL=session-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-model.d.ts","sourceRoot":"","sources":["../src/session-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,SA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