@agentclientprotocol/claude-agent-acp 0.90.1-preview.8 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +14 -5
  2. package/dist/acp-agent.d.ts +91 -11
  3. package/dist/acp-agent.d.ts.map +1 -1
  4. package/dist/acp-agent.js +264 -80
  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/gateway-models.d.ts +62 -0
  9. package/dist/gateway-models.d.ts.map +1 -0
  10. package/dist/gateway-models.js +180 -0
  11. package/dist/native-subagents.d.ts +34 -9
  12. package/dist/native-subagents.d.ts.map +1 -1
  13. package/dist/native-subagents.js +55 -11
  14. package/dist/session-index/connection.d.ts +4 -3
  15. package/dist/session-index/connection.d.ts.map +1 -1
  16. package/dist/session-index/connection.js +8 -7
  17. package/dist/session-index/list-subscriptions.d.ts.map +1 -1
  18. package/dist/session-index/list-subscriptions.js +4 -1
  19. package/dist/session-index/service.d.ts +10 -0
  20. package/dist/session-index/service.d.ts.map +1 -1
  21. package/dist/session-index/service.js +21 -0
  22. package/dist/session-index/session-index.d.ts +10 -2
  23. package/dist/session-index/session-index.d.ts.map +1 -1
  24. package/dist/session-index/session-index.js +21 -5
  25. package/dist/session-index/session-info.d.ts.map +1 -1
  26. package/dist/session-index/session-info.js +1 -0
  27. package/dist/session-index/transcript-scan.d.ts +25 -1
  28. package/dist/session-index/transcript-scan.d.ts.map +1 -1
  29. package/dist/session-index/transcript-scan.js +57 -1
  30. package/dist/session-index/worktrees.d.ts +6 -0
  31. package/dist/session-index/worktrees.d.ts.map +1 -1
  32. package/dist/session-index/worktrees.js +12 -0
  33. package/dist/session-model.d.ts +21 -1
  34. package/dist/session-model.d.ts.map +1 -1
  35. package/dist/session-model.js +89 -11
  36. package/dist/turn-events.d.ts +5 -1
  37. package/dist/turn-events.d.ts.map +1 -1
  38. package/dist/v2/prompt.d.ts +2 -1
  39. package/dist/v2/prompt.d.ts.map +1 -1
  40. package/dist/v2/prompt.js +2 -1
  41. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"air-extension.d.ts","sourceRoot":"","sources":["../src/air-extension.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,2BAA2B,CAAC;AAChF,eAAO,MAAM,0BAA0B,eAAe,CAAC;AACvD,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAC/D,eAAO,MAAM,uCAAuC,qBAAqB,CAAC;AAC1E,eAAO,MAAM,kCAAkC,uBAAuB,CAAC;AACvE,eAAO,MAAM,yBAAyB,cAAc,CAAC;AACrD,4EAA4E;AAC5E,eAAO,MAAM,kCAAkC,sBAAsB,CAAC;AACtE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,aAAa,CAAC;AACnD;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAC3D;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAC/D;;;GAGG;AACH,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAC7D;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,yBAAyB,CAAC;AAE5E,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AACpD,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,eAAO,MAAM,0BAA0B,sBAAsB,CAAC;AAC9D,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAC9C,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAC/C,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AACpD;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AAQ3E,2EAA2E;AAC3E,wB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,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GACpC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAErC;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAKnF;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAY9F;AAED,4DAA4D;AAC5D,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAIvE"}
@@ -34,6 +34,12 @@ export const AIR_SESSION_RENAME_CAPABILITY = "sessionRename";
34
34
  * {@link AIR_SESSION_INDEX_CAPABILITY} is; the client does not declare it.
35
35
  */
36
36
  export const AIR_SESSION_LIST_SUBSCRIBE_CAPABILITY = "sessionListSubscribe";
37
+ /**
38
+ * Session index rows carry `agentWorktree: true` when the session runs in a
39
+ * linked git worktree that Claude Code made for it. Advertised exactly when
40
+ * {@link AIR_SESSION_INDEX_CAPABILITY} is; the client does not declare it.
41
+ */
42
+ export const AIR_SESSION_WORKTREES_CAPABILITY = "sessionWorktrees";
37
43
  /** The `_meta.jetbrains.air` keys that the ACP tool call contract defines. */
38
44
  export const AIR_COMMAND_TITLE_KEY = "commandTitle";
39
45
  export const AIR_SUBAGENT_KEY = "subagent";
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Model discovery for a gateway set via `providers/set`.
3
+ *
4
+ * An organization can restrict which models its gateway serves, and the
5
+ * gateway's listing returns only those: `GET /v1/models` for an `anthropic`
6
+ * gateway, `GET /foundation-models` (Bedrock `ListFoundationModels`) for a
7
+ * `bedrock` one. The adapter lists them once when the provider is set, and the
8
+ * model picker then offers only the SDK models the gateway listed (see
9
+ * `narrowToGatewayModels` in `session-model.ts`). A listing that fails fails
10
+ * `providers/set` with a {@link GatewayListingError}.
11
+ */
12
+ /**
13
+ * The bearer token `createEnvForProvider` sets as `ANTHROPIC_AUTH_TOKEN` and
14
+ * `AWS_BEARER_TOKEN_BEDROCK`, so the CLI sends `Authorization: Bearer acp-proxy`
15
+ * unless the provider headers replace it. The listing sends the same, so the
16
+ * gateway sees the same auth as on chat requests.
17
+ */
18
+ export declare const PROVIDER_AUTH_TOKEN_PLACEHOLDER = "acp-proxy";
19
+ type ListingLogger = {
20
+ log: (...args: any[]) => void;
21
+ error: (...args: any[]) => void;
22
+ };
23
+ /**
24
+ * A gateway listing that failed: a network error, a status other than 2xx or
25
+ * 4xx, a body that is not the expected listing, or the 10 s timeout. The
26
+ * message names the request path and the reason, never a header value.
27
+ */
28
+ export declare class GatewayListingError extends Error {
29
+ name: string;
30
+ }
31
+ /**
32
+ * Lists the model ids an `anthropic` gateway at `baseUrl` serves, following
33
+ * `has_more` / `last_id` pagination. Returns `undefined` when the gateway
34
+ * answers 4xx: it has no listing, and nothing is narrowed. Throws a
35
+ * {@link GatewayListingError} when the listing fails. Header values are never
36
+ * logged.
37
+ */
38
+ export declare function listGatewayModels(baseUrl: string, providerHeaders: Record<string, string>, logger: ListingLogger): Promise<string[] | undefined>;
39
+ /**
40
+ * Lists the Anthropic models a `bedrock` gateway at `baseUrl` serves
41
+ * (`GET /foundation-models`, Bedrock `ListFoundationModels`, one page), the
42
+ * listing AI Router answers on its Bedrock route. Returns the listed ids, such
43
+ * as `global.anthropic.claude-sonnet-5-5`; `undefined` and the errors are
44
+ * those of {@link listGatewayModels}.
45
+ */
46
+ export declare function listBedrockModels(baseUrl: string, providerHeaders: Record<string, string>, logger: ListingLogger): Promise<string[] | undefined>;
47
+ /** The cross-region prefix of a Bedrock model id or ARN, if it has one. */
48
+ export declare function bedrockRegionPrefix(modelId: string): string | undefined;
49
+ /**
50
+ * Picks the region of the listed Bedrock models: `global` when the gateway
51
+ * lists it, else the prefix of the first id that has one. A gateway that lists
52
+ * `eu.*` and `us.*` ids gets the prefix that comes first, and the ids of the
53
+ * other prefixes are dropped, so the picker offers only models the CLI can
54
+ * call under that prefix. Ids without a prefix (`anthropic.claude-…`) are
55
+ * dropped too once a prefix is picked; without any prefix every id is kept.
56
+ */
57
+ export declare function selectBedrockRegion(modelIds: readonly string[]): {
58
+ regionPrefix?: string;
59
+ modelIds: string[];
60
+ };
61
+ export {};
62
+ //# sourceMappingURL=gateway-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-models.d.ts","sourceRoot":"","sources":["../src/gateway-models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,cAAc,CAAC;AAW3D,KAAK,aAAa,GAAG;IAAE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAAE,CAAC;AAIxF;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IACnC,IAAI,SAAyB;CACvC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAkB/B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAa/B;AAED,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGvE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAUA"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Model discovery for a gateway set via `providers/set`.
3
+ *
4
+ * An organization can restrict which models its gateway serves, and the
5
+ * gateway's listing returns only those: `GET /v1/models` for an `anthropic`
6
+ * gateway, `GET /foundation-models` (Bedrock `ListFoundationModels`) for a
7
+ * `bedrock` one. The adapter lists them once when the provider is set, and the
8
+ * model picker then offers only the SDK models the gateway listed (see
9
+ * `narrowToGatewayModels` in `session-model.ts`). A listing that fails fails
10
+ * `providers/set` with a {@link GatewayListingError}.
11
+ */
12
+ const LISTING_TIMEOUT_MS = 10_000;
13
+ const ANTHROPIC_PAGE_LIMIT = "1000";
14
+ const MAX_LISTING_PAGES = 20;
15
+ const MAX_LOGGED_BODY_CHARS = 500;
16
+ const ANTHROPIC_VERSION = "2023-06-01";
17
+ /**
18
+ * The bearer token `createEnvForProvider` sets as `ANTHROPIC_AUTH_TOKEN` and
19
+ * `AWS_BEARER_TOKEN_BEDROCK`, so the CLI sends `Authorization: Bearer acp-proxy`
20
+ * unless the provider headers replace it. The listing sends the same, so the
21
+ * gateway sees the same auth as on chat requests.
22
+ */
23
+ export const PROVIDER_AUTH_TOKEN_PLACEHOLDER = "acp-proxy";
24
+ /**
25
+ * The cross-region inference profile prefixes the CLI knows:
26
+ * `eu.anthropic.claude-sonnet-5`. `ANTHROPIC_BEDROCK_REGION_PREFIX` accepts all
27
+ * of them but `us-gov`, which the CLI takes only from a `us-gov-*` AWS region;
28
+ * a gateway listing only `us-gov.*` ids would then get an empty picker. That
29
+ * case is theoretical, so it is left as is.
30
+ */
31
+ const BEDROCK_REGION_PREFIXES = ["us", "eu", "apac", "jp", "au", "us-gov", "global"];
32
+ /**
33
+ * A gateway listing that failed: a network error, a status other than 2xx or
34
+ * 4xx, a body that is not the expected listing, or the 10 s timeout. The
35
+ * message names the request path and the reason, never a header value.
36
+ */
37
+ export class GatewayListingError extends Error {
38
+ name = "GatewayListingError";
39
+ }
40
+ /**
41
+ * Lists the model ids an `anthropic` gateway at `baseUrl` serves, following
42
+ * `has_more` / `last_id` pagination. Returns `undefined` when the gateway
43
+ * answers 4xx: it has no listing, and nothing is narrowed. Throws a
44
+ * {@link GatewayListingError} when the listing fails. Header values are never
45
+ * logged.
46
+ */
47
+ export async function listGatewayModels(baseUrl, providerHeaders, logger) {
48
+ return listPages(`${baseUrl.replace(/\/+$/, "")}/v1/models`, { limit: ANTHROPIC_PAGE_LIMIT }, listingHeaders(providerHeaders, { "anthropic-version": ANTHROPIC_VERSION }), logger, (body) => {
49
+ const page = body;
50
+ if (!Array.isArray(page.data))
51
+ return undefined;
52
+ return {
53
+ ids: stringField(page.data, "id"),
54
+ nextQuery: page.has_more === true && typeof page.last_id === "string"
55
+ ? { limit: ANTHROPIC_PAGE_LIMIT, after_id: page.last_id }
56
+ : undefined,
57
+ };
58
+ });
59
+ }
60
+ /**
61
+ * Lists the Anthropic models a `bedrock` gateway at `baseUrl` serves
62
+ * (`GET /foundation-models`, Bedrock `ListFoundationModels`, one page), the
63
+ * listing AI Router answers on its Bedrock route. Returns the listed ids, such
64
+ * as `global.anthropic.claude-sonnet-5-5`; `undefined` and the errors are
65
+ * those of {@link listGatewayModels}.
66
+ */
67
+ export async function listBedrockModels(baseUrl, providerHeaders, logger) {
68
+ const ids = await listPages(`${baseUrl.replace(/\/+$/, "")}/foundation-models`, {}, listingHeaders(providerHeaders, {}), logger, (body) => {
69
+ const page = body;
70
+ if (!Array.isArray(page.modelSummaries))
71
+ return undefined;
72
+ return { ids: stringField(page.modelSummaries, "modelId") };
73
+ });
74
+ return ids?.filter((id) => id.includes("anthropic."));
75
+ }
76
+ /** The cross-region prefix of a Bedrock model id or ARN, if it has one. */
77
+ export function bedrockRegionPrefix(modelId) {
78
+ const id = modelId.slice(modelId.lastIndexOf("/") + 1).toLowerCase();
79
+ return BEDROCK_REGION_PREFIXES.find((prefix) => id.startsWith(`${prefix}.anthropic.`));
80
+ }
81
+ /**
82
+ * Picks the region of the listed Bedrock models: `global` when the gateway
83
+ * lists it, else the prefix of the first id that has one. A gateway that lists
84
+ * `eu.*` and `us.*` ids gets the prefix that comes first, and the ids of the
85
+ * other prefixes are dropped, so the picker offers only models the CLI can
86
+ * call under that prefix. Ids without a prefix (`anthropic.claude-…`) are
87
+ * dropped too once a prefix is picked; without any prefix every id is kept.
88
+ */
89
+ export function selectBedrockRegion(modelIds) {
90
+ const prefixes = modelIds.map(bedrockRegionPrefix);
91
+ const regionPrefix = prefixes.includes("global")
92
+ ? "global"
93
+ : prefixes.find((prefix) => prefix !== undefined);
94
+ if (!regionPrefix)
95
+ return { modelIds: [...modelIds] };
96
+ return {
97
+ regionPrefix,
98
+ modelIds: modelIds.filter((id) => bedrockRegionPrefix(id) === regionPrefix),
99
+ };
100
+ }
101
+ // Provider headers win over the defaults, matched case-insensitively, the way
102
+ // `ANTHROPIC_CUSTOM_HEADERS` overrides the CLI's own headers.
103
+ function listingHeaders(providerHeaders, protocolHeaders) {
104
+ const headers = new Headers({
105
+ authorization: `Bearer ${PROVIDER_AUTH_TOKEN_PLACEHOLDER}`,
106
+ accept: "application/json",
107
+ ...protocolHeaders,
108
+ });
109
+ for (const [name, value] of Object.entries(providerHeaders)) {
110
+ // `Headers.set` puts an invalid value into its error message, so name only the header.
111
+ try {
112
+ headers.set(name, value);
113
+ }
114
+ catch {
115
+ throw new GatewayListingError(`Model listing cannot send the invalid header "${name}"`);
116
+ }
117
+ }
118
+ return headers;
119
+ }
120
+ function stringField(entries, field) {
121
+ return entries.flatMap((entry) => {
122
+ const value = entry?.[field];
123
+ return typeof value === "string" && value.trim() !== "" ? [value] : [];
124
+ });
125
+ }
126
+ /**
127
+ * Reads `endpoint` page by page; `parse` returns `undefined` for a body it does
128
+ * not understand. A 4xx answer on any page means the gateway has no listing:
129
+ * the result is `undefined`, and nothing is narrowed.
130
+ */
131
+ async function listPages(endpoint, firstQuery, headers, logger, parse) {
132
+ const { pathname: path, username, password } = new URL(endpoint);
133
+ const failure = (reason) => {
134
+ const error = new GatewayListingError(`Model listing GET ${path} ${reason}`);
135
+ logger.error(`[providers/set] ${error.message}`);
136
+ return error;
137
+ };
138
+ // fetch refuses such a URL and repeats it, credentials included, in its error.
139
+ if (username || password)
140
+ throw failure("cannot be sent: the base URL carries credentials");
141
+ const signal = AbortSignal.timeout(LISTING_TIMEOUT_MS);
142
+ const ids = [];
143
+ let query = firstQuery;
144
+ for (let page = 0; page < MAX_LISTING_PAGES && query; page++) {
145
+ const url = new URL(endpoint);
146
+ for (const [name, value] of Object.entries(query))
147
+ url.searchParams.set(name, value);
148
+ let response;
149
+ let body;
150
+ try {
151
+ response = await fetch(url, { headers, signal });
152
+ body = await response.text();
153
+ }
154
+ catch (error) {
155
+ throw failure(`failed: ${error instanceof Error ? error.message : String(error)}`);
156
+ }
157
+ if (response.status >= 400 && response.status < 500) {
158
+ logger.log(`[providers/set] Model listing GET ${path} returned ${response.status}: the gateway has no listing, models are not narrowed`);
159
+ return undefined;
160
+ }
161
+ if (!response.ok) {
162
+ throw failure(`returned ${response.status}: ${body.slice(0, MAX_LOGGED_BODY_CHARS)}`);
163
+ }
164
+ let parsed;
165
+ try {
166
+ parsed = parse(JSON.parse(body));
167
+ }
168
+ catch {
169
+ parsed = undefined;
170
+ }
171
+ if (!parsed)
172
+ throw failure("returned an unexpected body");
173
+ ids.push(...parsed.ids);
174
+ query = parsed.nextQuery;
175
+ }
176
+ if (query) {
177
+ logger.error(`[providers/set] Model listing GET ${path} still had more pages after ${MAX_LISTING_PAGES}; using what was read`);
178
+ }
179
+ return ids;
180
+ }
@@ -34,6 +34,9 @@ export type NativeSubagent = {
34
34
  missingError?: boolean;
35
35
  /** The RFD form: the open permission and question requests of the child. */
36
36
  openRequests?: number;
37
+ /** The RFD form: how many times the client cancelled the child (see
38
+ * `NativeSubagentRuntime.cancelChild`). */
39
+ cancels?: number;
37
40
  /** The RFD form: the ids of the prompt messages in the child's transcript. */
38
41
  promptIds?: Set<string>;
39
42
  /** The RFD form: the calls that delegated to the child, whose runs ended. */
@@ -185,19 +188,32 @@ export declare class NativeSubagentRuntime {
185
188
  * the cancel, for {@link awaitingUser}.
186
189
  */
187
190
  parentCancelled(deliver: Publish): Promise<void>;
191
+ /**
192
+ * The RFD form: the client sent `session/cancel` for the child session
193
+ * `sessionId`, which the child's `cancel` capability permits (see
194
+ * `announceNativeSubagent`). `stop` stops the child's task, as
195
+ * `Query.stopTask` does: Claude Code stops the child's current work and the
196
+ * foreground subagents that it waits on, and the parent's work goes on. The
197
+ * SDK's task events report each stopped child `idle` with `cancelled` (see
198
+ * {@link finishTask}). Accepting the stop is no evidence that the child
199
+ * stopped, so nothing is reported here, and a child whose work already ended
200
+ * keeps its outcome. Returns false when `sessionId` is not a child session
201
+ * of this runtime. AIR's draft grants no `cancel`.
202
+ */
203
+ cancelChild(sessionId: string, stop: (taskId: string) => Promise<void>): Promise<boolean>;
188
204
  /**
189
205
  * Runs `request`, a permission or question request of the session
190
206
  * `sessionId`. In the RFD form, a child waiting on it is `requires_action`
191
207
  * until its last open request ends, and then `running` again.
192
208
  *
193
209
  * `signal` aborts when Claude Code withdraws the request, which is not an
194
- * answer. If the parent was cancelled while the request was open, Claude
195
- * Code's interrupt withdrew it as it stopped the child, and the SDK's events
196
- * report the child `idle` next. The end of the request then reports no
197
- * `running`, which would show a child that is being stopped as working.
198
- * Without a cancel, something else answered the request in the user's place,
199
- * such as a `PermissionRequest` hook, and the child runs on, so the end
200
- * reports `running`.
210
+ * answer. If the root session, the child, or an ancestor of the child was
211
+ * cancelled while the request was open, Claude Code withdrew it as it
212
+ * stopped the child, and the SDK's events report the child `idle` next. The
213
+ * end of the request then reports no `running`, which would show a child
214
+ * that is being stopped as working. Without a cancel, something else
215
+ * answered the request in the user's place, such as a `PermissionRequest`
216
+ * hook, and the child runs on, so the end reports `running`.
201
217
  */
202
218
  awaitingUser<T>(sessionId: string, request: () => Promise<T>, signal?: AbortSignal): Promise<T>;
203
219
  discardPending(parentToolUseId: string): void;
@@ -269,6 +285,13 @@ export declare class NativeSubagentRuntime {
269
285
  */
270
286
  private rememberSendMessage;
271
287
  private rememberToolCallOwner;
288
+ /**
289
+ * The RFD form: how many cancels the client sent for `child`, its
290
+ * ancestors, and the root session. Each cancel stops the foreground work
291
+ * under it, and the counts only grow, so a changed sum shows that a cancel
292
+ * that reaches the child came.
293
+ */
294
+ private cancelsAbove;
272
295
  /** The child generation with the ACP session `sessionId`, if one exists. */
273
296
  private childOfSession;
274
297
  clear(): void;
@@ -299,8 +322,10 @@ export declare class NativeSubagentRuntime {
299
322
  /**
300
323
  * Announces the child on its parent, once, before any update of the child.
301
324
  * The RFD form announces it as running and then sends the prompt as the
302
- * first message of the child. The child gets no capabilities, so the client
303
- * may not cancel or otherwise change it.
325
+ * first message of the child. It grants the child `cancel`: the client may
326
+ * stop the child's current work with `session/cancel` (see
327
+ * `NativeSubagentRuntime.cancelChild`), and nothing else. AIR's draft grants
328
+ * no capabilities.
304
329
  */
305
330
  export declare function announceNativeSubagent(child: NativeSubagent, publish: Publish, form: SubagentForm): Promise<void>;
306
331
  export declare function finishNativeSubagent(session: NativeSubagentSession, taskId: string, state: SubagentState, publish: Publish): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"native-subagents.d.ts","sourceRoot":"","sources":["../src/native-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG9F,kFAAkF;AAClF,MAAM,MAAM,SAAS,GAAG,WAAW,CACjC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,C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AC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAM9E;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,sBAAsB,CAAC,QAAQ,CAAC,GACvC,MAAM,IAAI,OAAO,CAClB,sBAAsB,CAAC,QAAQ,CAAC,EAChC;IAAE,aAAa,EAAE,WAAW,GAAG,kBAAkB,CAAA;CAAE,CACpD,CASA;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAEtE"}
@@ -372,25 +372,49 @@ export class NativeSubagentRuntime {
372
372
  else
373
373
  this.parentCancels++;
374
374
  }
375
+ /**
376
+ * The RFD form: the client sent `session/cancel` for the child session
377
+ * `sessionId`, which the child's `cancel` capability permits (see
378
+ * `announceNativeSubagent`). `stop` stops the child's task, as
379
+ * `Query.stopTask` does: Claude Code stops the child's current work and the
380
+ * foreground subagents that it waits on, and the parent's work goes on. The
381
+ * SDK's task events report each stopped child `idle` with `cancelled` (see
382
+ * {@link finishTask}). Accepting the stop is no evidence that the child
383
+ * stopped, so nothing is reported here, and a child whose work already ended
384
+ * keeps its outcome. Returns false when `sessionId` is not a child session
385
+ * of this runtime. AIR's draft grants no `cancel`.
386
+ */
387
+ async cancelChild(sessionId, stop) {
388
+ if (this.form !== "rfd")
389
+ return false;
390
+ for (const [taskId, child] of this.children) {
391
+ if (child.sessionId !== sessionId || !child.announced)
392
+ continue;
393
+ child.cancels = (child.cancels ?? 0) + 1;
394
+ await stop(taskId);
395
+ return true;
396
+ }
397
+ return false;
398
+ }
375
399
  /**
376
400
  * Runs `request`, a permission or question request of the session
377
401
  * `sessionId`. In the RFD form, a child waiting on it is `requires_action`
378
402
  * until its last open request ends, and then `running` again.
379
403
  *
380
404
  * `signal` aborts when Claude Code withdraws the request, which is not an
381
- * answer. If the parent was cancelled while the request was open, Claude
382
- * Code's interrupt withdrew it as it stopped the child, and the SDK's events
383
- * report the child `idle` next. The end of the request then reports no
384
- * `running`, which would show a child that is being stopped as working.
385
- * Without a cancel, something else answered the request in the user's place,
386
- * such as a `PermissionRequest` hook, and the child runs on, so the end
387
- * reports `running`.
405
+ * answer. If the root session, the child, or an ancestor of the child was
406
+ * cancelled while the request was open, Claude Code withdrew it as it
407
+ * stopped the child, and the SDK's events report the child `idle` next. The
408
+ * end of the request then reports no `running`, which would show a child
409
+ * that is being stopped as working. Without a cancel, something else
410
+ * answered the request in the user's place, such as a `PermissionRequest`
411
+ * hook, and the child runs on, so the end reports `running`.
388
412
  */
389
413
  async awaitingUser(sessionId, request, signal) {
390
414
  const child = this.form === "rfd" ? this.childOfSession(sessionId) : undefined;
391
415
  if (!child?.announced)
392
416
  return request();
393
- const cancelsAtOpen = this.parentCancels;
417
+ const cancelsAtOpen = this.cancelsAbove(child);
394
418
  child.openRequests = (child.openRequests ?? 0) + 1;
395
419
  if (child.openRequests === 1 && child.workState === "running") {
396
420
  await this.reportState(child, { state: "requires_action" }).catch((error) => this.logger.log(`Failed to report that subagent ${child.sessionId} waits: ${error}`));
@@ -401,7 +425,7 @@ export class NativeSubagentRuntime {
401
425
  finally {
402
426
  child.openRequests = (child.openRequests ?? 1) - 1;
403
427
  // Withdrawn after a cancel that came while the request was open.
404
- const stopped = signal?.aborted === true && this.parentCancels !== cancelsAtOpen;
428
+ const stopped = signal?.aborted === true && this.cancelsAbove(child) !== cancelsAtOpen;
405
429
  if (child.openRequests === 0 && child.workState === "requires_action" && !stopped) {
406
430
  await this.reportState(child, { state: "running" }).catch((error) => this.logger.log(`Failed to report that subagent ${child.sessionId} runs: ${error}`));
407
431
  }
@@ -604,6 +628,23 @@ export class NativeSubagentRuntime {
604
628
  this.childByToolCall.delete(oldest);
605
629
  }
606
630
  }
631
+ /**
632
+ * The RFD form: how many cancels the client sent for `child`, its
633
+ * ancestors, and the root session. Each cancel stops the foreground work
634
+ * under it, and the counts only grow, so a changed sum shows that a cancel
635
+ * that reaches the child came.
636
+ */
637
+ cancelsAbove(child) {
638
+ let cancels = this.parentCancels;
639
+ const seen = new Set();
640
+ let next = child;
641
+ while (next && !seen.has(next)) {
642
+ seen.add(next);
643
+ cancels += next.cancels ?? 0;
644
+ next = this.childOfSession(next.parentSessionId);
645
+ }
646
+ return cancels;
647
+ }
607
648
  /** The child generation with the ACP session `sessionId`, if one exists. */
608
649
  childOfSession(sessionId) {
609
650
  if (sessionId === this.rootSessionId)
@@ -716,8 +757,10 @@ export class NativeSubagentRuntime {
716
757
  /**
717
758
  * Announces the child on its parent, once, before any update of the child.
718
759
  * The RFD form announces it as running and then sends the prompt as the
719
- * first message of the child. The child gets no capabilities, so the client
720
- * may not cancel or otherwise change it.
760
+ * first message of the child. It grants the child `cancel`: the client may
761
+ * stop the child's current work with `session/cancel` (see
762
+ * `NativeSubagentRuntime.cancelChild`), and nothing else. AIR's draft grants
763
+ * no capabilities.
721
764
  */
722
765
  export async function announceNativeSubagent(child, publish, form) {
723
766
  if (child.announced)
@@ -734,6 +777,7 @@ export async function announceNativeSubagent(child, publish, form) {
734
777
  sessionId: child.sessionId,
735
778
  ...(child.title ? { title: child.title } : {}),
736
779
  ...(child.description ? { description: child.description } : {}),
780
+ capabilities: { cancel: {} },
737
781
  state: { state: "running" },
738
782
  },
739
783
  });
@@ -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,MAAM,yBAAyB,CAAC;AACjC,OAAO,EASL,mBAAmB,EACnB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EAEtB,MAAM,cAAc,CAAC;AAEtB,sDAAsD;AACtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;kEAC8D;IAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;kEAC8D;IAC9D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;gCAC4B;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;4EACwE;IACxE,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,EACrC,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,GACjC,IAAI,CAGN;AAED,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iEAAiE;IACjE,KAAK,EAAE;QACL,QAAQ,CAAC,QAAQ,EAAE;YAAE,CAAC,GAAG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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.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IA2BtB,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,iBAAiB;IAazB,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,eAAe;IASvB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,gBAAgB;YAoBV,YAAY;IAuB1B;oDACgD;YAClC,YAAY;IAqC1B,OAAO,CAAC,aAAa;IAsBrB,mEAAmE;YACrD,WAAW;IAiDzB,OAAO,CAAC,QAAQ;IAOhB,2EAA2E;IAC3E,OAAO,CAAC,OAAO;IAaf,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,OAAO;IASf;yEACqE;YACvD,IAAI;YA8BJ,IAAI;IAsOlB;;yBAEqB;IACrB,OAAO,CAAC,eAAe;IAOvB;;;;;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