@agentclientprotocol/claude-agent-acp 0.89.2-preview.9 → 0.90.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 (52) hide show
  1. package/README.md +56 -8
  2. package/dist/acp-agent.d.ts +50 -1
  3. package/dist/acp-agent.d.ts.map +1 -1
  4. package/dist/acp-agent.js +493 -147
  5. package/dist/acp-subagents.d.ts +16 -6
  6. package/dist/acp-subagents.d.ts.map +1 -1
  7. package/dist/acp-subagents.js +8 -2
  8. package/dist/async-tasks.d.ts +4 -1
  9. package/dist/async-tasks.d.ts.map +1 -1
  10. package/dist/auth-status.d.ts +2 -2
  11. package/dist/auth-status.d.ts.map +1 -1
  12. package/dist/auth-status.js +18 -4
  13. package/dist/exit-plan.d.ts +17 -0
  14. package/dist/exit-plan.d.ts.map +1 -1
  15. package/dist/exit-plan.js +34 -0
  16. package/dist/native-subagents.d.ts +228 -11
  17. package/dist/native-subagents.d.ts.map +1 -1
  18. package/dist/native-subagents.js +489 -40
  19. package/dist/settings.d.ts +6 -0
  20. package/dist/settings.d.ts.map +1 -1
  21. package/dist/settings.js +13 -0
  22. package/dist/subagent-history.d.ts +44 -2
  23. package/dist/subagent-history.d.ts.map +1 -1
  24. package/dist/subagent-history.js +116 -10
  25. package/dist/subagent-replay.d.ts +108 -0
  26. package/dist/subagent-replay.d.ts.map +1 -0
  27. package/dist/subagent-replay.js +261 -0
  28. package/dist/tool-calls/background.d.ts +9 -0
  29. package/dist/tool-calls/background.d.ts.map +1 -1
  30. package/dist/tool-calls/background.js +25 -0
  31. package/dist/tool-calls/renderer.d.ts +30 -9
  32. package/dist/tool-calls/renderer.d.ts.map +1 -1
  33. package/dist/tool-calls/renderer.js +48 -22
  34. package/dist/tool-calls/reporters/bash.d.ts +7 -0
  35. package/dist/tool-calls/reporters/bash.d.ts.map +1 -1
  36. package/dist/tool-calls/reporters/bash.js +16 -1
  37. package/dist/tool-calls/reporters/search.d.ts.map +1 -1
  38. package/dist/tool-calls/reporters/search.js +20 -2
  39. package/dist/v2/agent.d.ts.map +1 -1
  40. package/dist/v2/agent.js +45 -12
  41. package/dist/v2/initialize.d.ts.map +1 -1
  42. package/dist/v2/initialize.js +10 -1
  43. package/dist/v2/session-update.d.ts +11 -0
  44. package/dist/v2/session-update.d.ts.map +1 -1
  45. package/dist/v2/session-update.js +67 -0
  46. package/dist/v2/session.d.ts +3 -12
  47. package/dist/v2/session.d.ts.map +1 -1
  48. package/dist/v2/session.js +5 -18
  49. package/dist/v2/tool-call-meta.d.ts +44 -0
  50. package/dist/v2/tool-call-meta.d.ts.map +1 -0
  51. package/dist/v2/tool-call-meta.js +72 -0
  52. package/package.json +9 -9
@@ -1,12 +1,22 @@
1
1
  import type { ClientCapabilities, SessionCapabilities, SessionNotification } from "@agentclientprotocol/sdk";
2
2
  export { AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY } from "./air-extension.js";
3
3
  /**
4
- * Temporary typed surface for agentclientprotocol/agent-client-protocol#1992.
4
+ * How a client gets native subagent sessions.
5
5
  *
6
- * The wire contract is already defined by the ACP draft, but the published
7
- * TypeScript SDK does not contain it yet. Keep the compatibility boundary in
8
- * this file so it can be replaced by SDK exports without changing lifecycle
9
- * code when the draft ships.
6
+ * - `rfd`: the subagents RFD (agentclientprotocol/agent-client-protocol#1992,
7
+ * as revised): `subagent_update` and `session_message`, which the SDK types.
8
+ * A client that declares `clientCapabilities.subagents` and is not AIR gets
9
+ * it. (ACP v2 clients do not get subagents yet.)
10
+ * - `air`: the earlier draft of that RFD, which AIR implements:
11
+ * `subagent_spawned` and `subagent_state_update`, typed below. AIR gets it,
12
+ * whichever capability it declares (`docs/air-extensions.md`).
13
+ */
14
+ export type SubagentForm = "rfd" | "air";
15
+ /** The form of native subagent sessions that the client gets, or none. */
16
+ export declare function subagentForm(capabilities?: ClientCapabilities | null): SubagentForm | undefined;
17
+ /**
18
+ * The earlier draft of the subagents RFD, which AIR implements and the SDK
19
+ * does not type.
10
20
  */
11
21
  export type SubagentSessionCapabilities = {
12
22
  cancel?: boolean;
@@ -83,6 +93,6 @@ export type SubagentAwareSessionCapabilities = SessionCapabilities & {
83
93
  subagents?: Record<string, never>;
84
94
  };
85
95
  export declare function clientSupportsSubagents(capabilities?: ClientCapabilities | null): boolean;
86
- /** The only cast needed until the TypeScript SDK publishes PR #1992. */
96
+ /** The cast that AIR's draft updates and the async task updates need. */
87
97
  export declare function asSdkSessionNotification(notification: AcpSessionNotification): SessionNotification;
88
98
  //# sourceMappingURL=acp-subagents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"acp-subagents.d.ts","sourceRoot":"","sources":["../src/acp-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,EAAE,kBAAkB,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,2BAA2B,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,CAAC;AAElF,MAAM,MAAM,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BAAsB,GAAG,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,GAAG;IACzE,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,mBAAmB,GAAG;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACnC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CASzF;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,sBAAsB,GACnC,mBAAmB,CAErB"}
@@ -1,5 +1,11 @@
1
- import { AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY, clientSupportsAirCapability, } from "./air-extension.js";
1
+ import { AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY, clientSupportsAirCapability, isAirClient, } from "./air-extension.js";
2
2
  export { AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY } from "./air-extension.js";
3
+ /** The form of native subagent sessions that the client gets, or none. */
4
+ export function subagentForm(capabilities) {
5
+ if (!clientSupportsSubagents(capabilities))
6
+ return undefined;
7
+ return isAirClient(capabilities) ? "air" : "rfd";
8
+ }
3
9
  export function clientSupportsSubagents(capabilities) {
4
10
  const subagents = capabilities?.subagents;
5
11
  if (typeof subagents === "object" && subagents !== null && !Array.isArray(subagents)) {
@@ -7,7 +13,7 @@ export function clientSupportsSubagents(capabilities) {
7
13
  }
8
14
  return clientSupportsAirCapability(capabilities, AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY);
9
15
  }
10
- /** The only cast needed until the TypeScript SDK publishes PR #1992. */
16
+ /** The cast that AIR's draft updates and the async task updates need. */
11
17
  export function asSdkSessionNotification(notification) {
12
18
  return notification;
13
19
  }
@@ -188,7 +188,10 @@ export declare class AsyncTaskRuntime {
188
188
  export declare function backgroundBashTaskFromToolResult(content: unknown, toolUseResult: unknown, toolUses: Record<string, {
189
189
  name: string;
190
190
  input: unknown;
191
- }>): AsyncTaskStarted | undefined;
191
+ }>): (AsyncTaskStarted & {
192
+ taskId: string;
193
+ toolCallId: string;
194
+ }) | undefined;
192
195
  /**
193
196
  * The Bash tool calls in `content` whose command went to the background. Only
194
197
  * structured data counts: the task from the structured tool result, a task
@@ -1 +1 @@
1
- {"version":3,"file":"async-tasks.d.ts","sourceRoot":"","sources":["../src/async-tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIjF,KAAK,OAAO,GAAG,CAAC,YAAY,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACvE,qEAAqE;AACrE,KAAK,KAAK,GAAG,CAAC,YAAY,EAAE,sBAAsB,KAAK,sBAAsB,GAAG,IAAI,CAAC;AAoCrF,KAAK,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAI5D,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;I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O,CAAC,IAAI;IAwBZ,OAAO,CAAC,YAAY;IAwBpB,oEAAoE;IACpE,OAAO,CAAC,eAAe;IAQvB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAM3B,kFAAkF;YACpE,aAAa;IAK3B,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,mBAAmB;IAQ3B;;;;;;;;;;;;;OAaG;YACW,QAAQ;YAuCR,MAAM;YAkCN,eAAe;IAa7B;;;OAGG;YACW,eAAe;IAqB7B,wFAAwF;YAC1E,YAAY;IAmB1B,yEAAyE;YAC3D,IAAI;CAKnB;AAyBD;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,OAAO,EACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,GACzD,CAAC,gBAAgB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,CAuCzE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,EAC1D,OAAO,EAAE,gBAAgB,EACzB,cAAc,CAAC,EAAE,gBAAgB,GAChC,GAAG,CAAC,MAAM,CAAC,CAmBb"}
@@ -109,11 +109,11 @@ export declare function accountInfoHasIdentitySignal(account: AccountInfo | unde
109
109
  /** Session-time mapping from the SDK's `AccountInfo`, the richest source when
110
110
  * it is populated. Returns `undefined` when the account carries no identity
111
111
  * signal, so callers keep the status they already know. */
112
- export declare function fromAccountInfo(account: AccountInfo | undefined): AuthStatus | undefined;
112
+ export declare function fromAccountInfo(account: AccountInfo | undefined, apiKeyHelper?: string): AuthStatus | undefined;
113
113
  /** Pre-session mapping from `claude auth status --json` stdout. Returns
114
114
  * `undefined` when the output is not the expected JSON object, so callers can
115
115
  * report "not known" instead of guessing. */
116
- export declare function fromCliStatus(stdout: string): AuthStatus | undefined;
116
+ export declare function fromCliStatus(stdout: string, apiKeyHelper?: string): AuthStatus | undefined;
117
117
  /**
118
118
  * Do two payloads describe the same login? Compared on the field that
119
119
  * identifies each kind — the key source for `api_key`, the email for
@@ -1 +1 @@
1
- {"version":3,"file":"auth-status.d.ts","sourceRoot":"","sources":["../src/auth-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE;uEACuE;AACvE,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;6CAC6C;AAC7C,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB;4DACwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd;4EACwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC;AAEtE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Y,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAyBF,wBAAgB,qBAAqB,IAAI,UAAU,CAElD;AAED;kFACkF;AAClF,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAc9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAOtF;AAED;;4DAE4D;AAC5D,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,YAAY,CAAC,EAAE,MAAM,GACpB,UAAU,GAAG,SAAS,CAYxB;AAED;;8CAE8C;AAC9C,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CA6B3F;AAsED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAYlE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAe9F;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAgBhF"}
@@ -53,6 +53,12 @@ const NOT_LOGGED_IN = {
53
53
  kind: "none",
54
54
  label: "Not logged in",
55
55
  };
56
+ const API_KEY_SOURCE_DETAILS = new Map([
57
+ ["apiKeyHelper", "API key helper"],
58
+ ["env", "env"],
59
+ ["ANTHROPIC_API_KEY", "ANTHROPIC_API_KEY"],
60
+ ["ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_AUTH_TOKEN"],
61
+ ]);
56
62
  /** Display names for the non-firstParty backends, where auth lives outside the
57
63
  * agent (AWS credentials, gcloud ADC, …). */
58
64
  const EXTERNAL_PROVIDER_LABELS = {
@@ -108,7 +114,7 @@ export function accountInfoHasIdentitySignal(account) {
108
114
  /** Session-time mapping from the SDK's `AccountInfo`, the richest source when
109
115
  * it is populated. Returns `undefined` when the account carries no identity
110
116
  * signal, so callers keep the status they already know. */
111
- export function fromAccountInfo(account) {
117
+ export function fromAccountInfo(account, apiKeyHelper) {
112
118
  if (!account || !accountInfoHasIdentitySignal(account)) {
113
119
  return undefined;
114
120
  }
@@ -118,12 +124,13 @@ export function fromAccountInfo(account) {
118
124
  apiKeySource: account.apiKeySource,
119
125
  email: account.email,
120
126
  organization: account.organization,
127
+ apiKeyHelper,
121
128
  });
122
129
  }
123
130
  /** Pre-session mapping from `claude auth status --json` stdout. Returns
124
131
  * `undefined` when the output is not the expected JSON object, so callers can
125
132
  * report "not known" instead of guessing. */
126
- export function fromCliStatus(stdout) {
133
+ export function fromCliStatus(stdout, apiKeyHelper) {
127
134
  let parsed;
128
135
  try {
129
136
  parsed = JSON.parse(stdout);
@@ -151,6 +158,7 @@ export function fromCliStatus(stdout) {
151
158
  apiKeySource: status.apiKeySource,
152
159
  email: status.email,
153
160
  organization: status.orgName,
161
+ apiKeyHelper,
154
162
  });
155
163
  }
156
164
  /** Single mapping table shared by both sources; see the `kind`/`label` table in
@@ -175,11 +183,17 @@ function mapAuthFields(fields) {
175
183
  };
176
184
  }
177
185
  if (apiKeySource) {
186
+ if (apiKeySource === "apiKeyHelper" &&
187
+ typeof fields.apiKeyHelper === "string" &&
188
+ /\bcentral\b/i.test(fields.apiKeyHelper) &&
189
+ /\bproxy\s+start\b/i.test(fields.apiKeyHelper)) {
190
+ return { kind: "gateway", label: "JetBrains Air Gateway" };
191
+ }
192
+ const detail = API_KEY_SOURCE_DETAILS.get(apiKeySource);
178
193
  return {
179
194
  kind: "api_key",
180
195
  label: "Anthropic API key",
181
- // The source ("apiKeyHelper", "env", …) is the specifics line.
182
- detail: apiKeySource,
196
+ ...(detail ? { detail } : {}),
183
197
  };
184
198
  }
185
199
  if (subscriptionType) {
@@ -22,11 +22,28 @@ export declare function executionDiagnostic(message: SDKResultMessage): string |
22
22
  /** Whether `message` is the error-shaped diagnostic Claude emits for the cycle
23
23
  * a recorded ExitPlanMode `interrupt: true` answer stopped. */
24
24
  export declare function isExitPlanInterruptionResult(message: SDKResultMessage, pending: ExitPlanState["pendingExitPlanModeInterruption"]): boolean;
25
+ /** The id of the plan that an approved ExitPlanMode publishes. Claude Code
26
+ * keeps one plan file per session, which a later plan mode rewrites, so each
27
+ * approval replaces the plan before it. The TodoWrite checklist is a
28
+ * separate plan. */
29
+ export declare const PLAN_MODE_PLAN_ID = "plan-mode";
30
+ /** The plan, trimmed, that a successful ExitPlanMode result approved: the plan
31
+ * of the structured `output`, which includes the user's edits, else the plan
32
+ * that Claude Code adds to the tool's `input`. Replay has only the input: the
33
+ * SDK's `getSessionMessages` drops the structured output that the transcript
34
+ * keeps. Undefined for a subagent's plan, one that waits for its team lead
35
+ * (both only known from the output), and an empty plan. */
36
+ export declare function approvedPlan(input: unknown, output: unknown): string | undefined;
37
+ /** The update that shows an approved plan to a client that supports plan
38
+ * operations (the `plan` client capability, which every v2 client has). */
39
+ export declare function planModeUpdate(plan: string): SessionNotification["update"];
25
40
  /** Claude wraps a rejected ExitPlanMode explanation in a Markdown code fence.
26
41
  * Strip exactly one complete outer fence for that tool only. */
27
42
  export declare function exitPlanModeRawOutput(toolName: string, content: unknown): unknown;
28
43
  export type ExitPlanRestartHost<Session extends ClearContextSession<Turn>, Turn extends ClearContextTurn> = Omit<ClearContextCoordinatorHost<Session, Turn>, "publishSessionState" | "continuationMessage"> & {
29
44
  sessionUpdate(notification: SessionNotification): Promise<void>;
45
+ /** Whether the client takes plan operations (see planModeUpdate). */
46
+ supportsPlanOperations(): boolean;
30
47
  destroyReplacement(sessionId: string, session: Session): void;
31
48
  settleCancelledTurn(oldSession: Session, turnSession: Session, turn: Turn): void;
32
49
  settleFailedTurn(turnSession: Session, turn: Turn, error: unknown): void;
@@ -1 +1 @@
1
- {"version":3,"file":"exit-plan.d.ts","sourceRoot":"","sources":["../src/exit-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAEtB,MAAM,gCAAgC,CAAC;AAGxC,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,mBAAmB,EACjC,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,mBAAmB,CAarB;AAeD,KAAK,aAAa,GAAG;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IAC3D,+BAA+B,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,CAAC;IACjF,2BAA2B,CAAC,EAAE,iBAAiB,CAAC;CACjD,CAAC;AA0BF;+EAC+E;AAC/E,wBAAgB,0BAA0B,CACxC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,EACrD,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,aAAa,GACnB,MAAM,GAAG,SAAS,CA0BpB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAKjF;AAED;+DAC+D;AAC/D,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,aAAa,CAAC,iCAAi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.js CHANGED
@@ -78,6 +78,34 @@ export function isExitPlanInterruptionResult(message, pending) {
78
78
  /(?:^|\s)result_type=user(?:\s|$)/.test(diagnostic) &&
79
79
  /(?:^|\s)stop_reason=tool_use(?:\s|$)/.test(diagnostic));
80
80
  }
81
+ /** The id of the plan that an approved ExitPlanMode publishes. Claude Code
82
+ * keeps one plan file per session, which a later plan mode rewrites, so each
83
+ * approval replaces the plan before it. The TodoWrite checklist is a
84
+ * separate plan. */
85
+ export const PLAN_MODE_PLAN_ID = "plan-mode";
86
+ /** The plan, trimmed, that a successful ExitPlanMode result approved: the plan
87
+ * of the structured `output`, which includes the user's edits, else the plan
88
+ * that Claude Code adds to the tool's `input`. Replay has only the input: the
89
+ * SDK's `getSessionMessages` drops the structured output that the transcript
90
+ * keeps. Undefined for a subagent's plan, one that waits for its team lead
91
+ * (both only known from the output), and an empty plan. */
92
+ export function approvedPlan(input, output) {
93
+ const result = output;
94
+ if (result?.isAgent === true || result?.awaitingLeaderApproval === true)
95
+ return undefined;
96
+ const plan = typeof result?.plan === "string"
97
+ ? result.plan
98
+ : input?.plan;
99
+ return typeof plan === "string" && plan.trim() !== "" ? plan.trim() : undefined;
100
+ }
101
+ /** The update that shows an approved plan to a client that supports plan
102
+ * operations (the `plan` client capability, which every v2 client has). */
103
+ export function planModeUpdate(plan) {
104
+ return {
105
+ sessionUpdate: "plan_update",
106
+ plan: { type: "markdown", planId: PLAN_MODE_PLAN_ID, content: plan },
107
+ };
108
+ }
81
109
  /** Claude wraps a rejected ExitPlanMode explanation in a Markdown code fence.
82
110
  * Strip exactly one complete outer fence for that tool only. */
83
111
  export function exitPlanModeRawOutput(toolName, content) {
@@ -115,6 +143,12 @@ export class ExitPlanCoordinator {
115
143
  sessionId: id,
116
144
  update: { sessionUpdate: "config_option_update", configOptions },
117
145
  });
146
+ // The approved plan becomes the session's plan once the fresh
147
+ // context that carries it out exists. Its ExitPlanMode ended with
148
+ // an error result, so toAcpNotifications did not publish it.
149
+ if (this.host.supportsPlanOperations()) {
150
+ await this.host.sessionUpdate({ sessionId: id, update: planModeUpdate(reset.plan) });
151
+ }
118
152
  },
119
153
  continuationMessage: (id, plan, promptUuid) => ({
120
154
  type: "user",
@@ -1,4 +1,9 @@
1
- import type { AcpSessionNotification, SubagentState } from "./acp-subagents.js";
1
+ import { type SessionNotification } from "@agentclientprotocol/sdk";
2
+ import type { AcpSessionNotification, SubagentForm, SubagentState } from "./acp-subagents.js";
3
+ /** The work state of a child, as the RFD's `subagent_update.state` carries it. */
4
+ export type WorkState = NonNullable<Extract<SessionNotification["update"], {
5
+ sessionUpdate: "subagent_update";
6
+ }>["state"]>;
2
7
  export type NativeSubagent = {
3
8
  sessionId: string;
4
9
  parentSessionId: string;
@@ -7,9 +12,32 @@ export type NativeSubagent = {
7
12
  task: string;
8
13
  /**
9
14
  * The exact prompt of this generation, sent as `prompt` in
10
- * `subagent_spawned`. It is absent when the adapter has no prompt.
15
+ * `subagent_spawned`, or as the child's first `session_message` in the RFD
16
+ * form. It is absent when the adapter has no prompt.
11
17
  */
12
18
  prompt?: string;
19
+ /** The RFD form: the parent's label for the child, `subagent_update.title`. */
20
+ title?: string;
21
+ /** The RFD form: the child's role, its `subagent_type`, for the title. */
22
+ role?: string;
23
+ /** The RFD form: the child's purpose, `subagent_update.description`. */
24
+ description?: string;
25
+ /**
26
+ * The RFD form: the work state the client holds. The child is reusable, so
27
+ * `idle` is not terminal. AIR's draft uses {@link terminalState} instead.
28
+ */
29
+ workState?: WorkState["state"];
30
+ /**
31
+ * The RFD form: the child's idle snapshot reports a failure without the
32
+ * SDK's error text, which a later event of the same failure may carry.
33
+ */
34
+ missingError?: boolean;
35
+ /** The RFD form: the open permission and question requests of the child. */
36
+ openRequests?: number;
37
+ /** The RFD form: the ids of the prompt messages in the child's transcript. */
38
+ promptIds?: Set<string>;
39
+ /** The RFD form: the calls that delegated to the child, whose runs ended. */
40
+ endedRuns?: Set<string>;
13
41
  announced?: boolean;
14
42
  terminalState?: SubagentState;
15
43
  /** Connection-local single-flight state; never serialized on the wire. */
@@ -26,6 +54,18 @@ type Publish = (notification: AcpSessionNotification) => Promise<void>;
26
54
  type Logger = {
27
55
  log(message: string): void;
28
56
  };
57
+ /** What the SDK says about the end of a task, beyond its status. */
58
+ export type TaskEnd = {
59
+ /** The SDK's text for a failure. */
60
+ error?: string;
61
+ /** The SDK's reason for an unusual end, such as `worker_restart`. */
62
+ reason?: string;
63
+ /**
64
+ * The adapter knows that the work ended, but not why: the stream ended, or
65
+ * the conversation was reset, with the task still running.
66
+ */
67
+ unexplained?: boolean;
68
+ };
29
69
  type TaskStarted = {
30
70
  taskId: string;
31
71
  toolUseId?: string | null;
@@ -33,6 +73,23 @@ type TaskStarted = {
33
73
  description?: unknown;
34
74
  prompt?: unknown;
35
75
  };
76
+ /** An agent of the session's subagent history, as the runtime restores it. */
77
+ export type HistoricalSubagent = {
78
+ agentId: string;
79
+ /** The Agent or Task call that launched it. */
80
+ launchId: string;
81
+ /** The agent that made that call. None means the root session. */
82
+ parentAgentId?: string;
83
+ name?: string;
84
+ agentType?: string;
85
+ description?: string;
86
+ };
87
+ /**
88
+ * The agent `agentId` and its ancestors, root first, from the session's
89
+ * subagent history; empty when the history cannot place it (see
90
+ * `subagentLineage`).
91
+ */
92
+ export type SubagentLineage = (agentId: string) => Promise<readonly HistoricalSubagent[]>;
36
93
  /**
37
94
  * Owns the connection-local native subagent registry and all ACP lifecycle
38
95
  * ordering. The main agent only supplies SDK facts and delivers routed output.
@@ -42,7 +99,10 @@ export declare class NativeSubagentRuntime {
42
99
  private readonly session;
43
100
  private readonly publish;
44
101
  private readonly logger;
102
+ private readonly lineage?;
45
103
  readonly enabled: boolean;
104
+ /** The form of the child sessions; see {@link SubagentForm}. */
105
+ readonly form: SubagentForm | undefined;
46
106
  private readonly children;
47
107
  private readonly taskByToolUse;
48
108
  private readonly parentByToolUse;
@@ -56,11 +116,18 @@ export declare class NativeSubagentRuntime {
56
116
  */
57
117
  private readonly childByToolCall;
58
118
  private readonly taskFinishPromises;
119
+ /** The RFD form: the session that made each SendMessage call. */
120
+ private readonly senderByToolUse;
59
121
  private readonly generationByTaskId;
60
122
  private readonly pending;
61
123
  private pendingCount;
62
- constructor(enabled: boolean, rootSessionId: string, session: NativeSubagentSession, publish: Publish, logger: Logger);
124
+ /**
125
+ * `form` is undefined for a client without native subagent sessions. The RFD
126
+ * form restores an agent from before a load or resume with `lineage`.
127
+ */
128
+ constructor(form: SubagentForm | undefined, rootSessionId: string, session: NativeSubagentSession, publish: Publish, logger: Logger, lineage?: SubagentLineage | undefined);
63
129
  route(notification: AcpSessionNotification, deliver: Publish, forcedSessionId?: string): Promise<AcpSessionNotification | null>;
130
+ private routeUpdate;
64
131
  taskStarted(task: TaskStarted, deliver: Publish): Promise<void>;
65
132
  /**
66
133
  * Opens a new generation of a finished child when the SDK resumes the same
@@ -68,14 +135,107 @@ export declare class NativeSubagentRuntime {
68
135
  * running `task_updated` patch or a SendMessage `resumedAgentId` is the
69
136
  * signal. A child that did not finish is not changed. The `prompt` is the
70
137
  * SendMessage text that resumed the child, when the adapter knows it.
138
+ *
139
+ * In the RFD form, the running patch only reports that the child runs: its
140
+ * prompt is a guess (the latest SendMessage to the agent), and the
141
+ * `task_started` or the SendMessage result carries the delegation.
71
142
  */
72
143
  taskResumed(taskId: string, deliver: Publish, prompt?: string): Promise<void>;
73
- finishTask(taskId: string, status: unknown, deliver: Publish, toolUseId?: string | null): Promise<void>;
144
+ /**
145
+ * The SDK reports in a SendMessage result that the call `toolUseId`, with
146
+ * the message `prompt`, resumed the agent `taskId`. AIR's draft treats it as
147
+ * any resume signal. In the RFD form, the call is the delegation, which the
148
+ * child takes unless its run already ended: the result can arrive after it.
149
+ */
150
+ sendMessageResumed(taskId: string, deliver: Publish, prompt?: string, toolUseId?: string): Promise<void>;
151
+ /**
152
+ * The RFD form: whether the run of the call `toolUseId` that delegated to
153
+ * the child `taskId` already ended. AIR's draft has no such runs.
154
+ */
155
+ isEndedDelegation(taskId: string, toolUseId: string | null | undefined): boolean;
156
+ /**
157
+ * The RFD form: whether `toolUseId` is an earlier delegation of the child
158
+ * `taskId`, whose end does not end the current one. AIR's draft has no
159
+ * such delegations.
160
+ */
161
+ isStaleEnd(taskId: string, toolUseId: string | null | undefined): boolean;
162
+ /**
163
+ * Reports that the SDK ended the task's work. `end` has what the SDK says
164
+ * about it: its text for a failure, and its reason for an unusual end.
165
+ */
166
+ finishTask(taskId: string, status: unknown, deliver: Publish, toolUseId?: string | null, end?: TaskEnd): Promise<void>;
167
+ /**
168
+ * Ends every child that still runs, because the stream ended or the
169
+ * conversation was reset. AIR's draft reports `state` for each. In the RFD
170
+ * form the cause of each child's end is unknown, so it is idle with no stop
171
+ * reason: a child that a cancel stopped already reported it from the SDK's
172
+ * events, and a background child that outlived the cancel was not cancelled.
173
+ */
74
174
  finishAll(state: SubagentState, deliver: Publish): Promise<void>;
175
+ /**
176
+ * The parent session got `session/cancel`. AIR's draft ends every child as
177
+ * cancelled here. The RFD form reports nothing: acknowledging a cancel is no
178
+ * evidence that a child stopped. Claude Code's interrupt stops the
179
+ * foreground children that the turn waits on and, currently, background
180
+ * children too, and the SDK's task events report each as cancelled. A child
181
+ * that keeps running keeps its open requests
182
+ * (agentclientprotocol/agent-client-protocol#2308).
183
+ */
184
+ parentCancelled(deliver: Publish): Promise<void>;
185
+ /**
186
+ * Runs `request`, a permission or question request of the session
187
+ * `sessionId`. In the RFD form, a child waiting on it is `requires_action`
188
+ * until its last open request ends.
189
+ */
190
+ awaitingUser<T>(sessionId: string, request: () => Promise<T>): Promise<T>;
75
191
  discardPending(parentToolUseId: string): void;
76
192
  /**
77
- * Routes an update to the child session. An update of a finished child is
78
- * dropped: it never goes to the root session.
193
+ * The RFD form: restores the agent `agentId` when the SendMessage call
194
+ * `toolUseId` resumes it and the runtime does not know it, because it ran
195
+ * before the session was loaded or resumed. A new launch is no resume: its
196
+ * call is an Agent or Task call.
197
+ *
198
+ * The agent keeps its session id from before, its agent id. The session's
199
+ * subagent history (see {@link SubagentLineage}) gives the call that
200
+ * launched it and its ancestors. The launch call is its delegation again:
201
+ * Claude Code sends the resumed run's messages under that call's id. Before the agent's traffic, the RFD requires its complete
202
+ * ancestor chain, parent before child. So each ancestor that the client was
203
+ * not told about in this connection is announced, with no work state since
204
+ * nothing says that it runs; then the agent, as running. The RFD forbids
205
+ * guessing a parent, so an agent that the history cannot place stays
206
+ * unexposed, as before.
207
+ */
208
+ private restore;
209
+ /**
210
+ * The RFD form: the child runs again, and keeps its session. `toolUseId` is
211
+ * the call that delegated, usually a SendMessage: the SDK runs the resumed
212
+ * work under its id, so it becomes the child's current delegation, whose
213
+ * end ends the run, and its prompt is the message with that id. A child
214
+ * that is already working only takes the delegation; a prompt already in
215
+ * its transcript is not sent again. A child that was never announced is
216
+ * not changed.
217
+ */
218
+ private resumeChild;
219
+ /**
220
+ * The RFD form: a child that ends before its parent is known stays
221
+ * unexposed, since the RFD forbids guessing its parent. Its buffered updates
222
+ * are dropped, and it is forgotten, so a late frame does not announce it.
223
+ * (Buffering until that frame would also meet the RFD, but the frame comes
224
+ * before the task in the SDK's order, so a child ending without it is rare.)
225
+ */
226
+ private withdraw;
227
+ /**
228
+ * The RFD form: a later event of a failure can carry the SDK's error text
229
+ * that the reported idle snapshot lacks.
230
+ */
231
+ private supplyError;
232
+ /** Announces `child` in the client's form. A runtime without one never does. */
233
+ private announce;
234
+ /** The RFD form: publishes the work state of `child` on its parent. */
235
+ private reportState;
236
+ /**
237
+ * Routes an update to the child session. It never goes to the root session:
238
+ * in AIR's draft, an update of a finished child is dropped.
79
239
  */
80
240
  private toChild;
81
241
  /**
@@ -84,12 +244,18 @@ export declare class NativeSubagentRuntime {
84
244
  * tool call when the work started. An async task can outlive that child: a
85
245
  * subagent can start a background command and end its turn. So the route
86
246
  * still sends `async_task_spawned`, `async_task_progress` and
87
- * `async_task_state_update` to the child generation after it finished. The route drops every other update
88
- * after the child finished. `undefined` means that the root session owns the
89
- * tool call. `eagerSessionId` is the session where a permission request
90
- * created the tool call before the stream routed it.
247
+ * `async_task_state_update` to the child generation after it finished. In
248
+ * AIR's draft, the route drops every other update after the child finished;
249
+ * in the RFD form, an idle child gets them all. `undefined` means that the
250
+ * root session owns the tool call. `eagerSessionId` is the session where a
251
+ * permission request created the tool call before the stream routed it.
91
252
  */
92
253
  routeOfToolCall(toolCallId: string, eagerSessionId?: string): ((notification: AcpSessionNotification) => AcpSessionNotification | null) | undefined;
254
+ /**
255
+ * The RFD form: remembers the session that made a SendMessage call, the
256
+ * sender of the prompt when the call resumes a child.
257
+ */
258
+ private rememberSendMessage;
93
259
  private rememberToolCallOwner;
94
260
  /** The child generation with the ACP session `sessionId`, if one exists. */
95
261
  private childOfSession;
@@ -106,10 +272,49 @@ export declare class NativeSubagentRuntime {
106
272
  * delivers the updates that waited for the child.
107
273
  */
108
274
  private openGeneration;
275
+ /**
276
+ * The ACP session id of a child: the SDK agent id, and in AIR's draft a
277
+ * generation suffix for each resume. The RFD needs it unique within the
278
+ * connection and never under two parents. Agent ids are random, and an
279
+ * agent keeps its parent, so only a fork could repeat one under another
280
+ * root. That holds today because the SDK's `forkSession` copies no
281
+ * `subagents/` history, so a fork cannot resume an agent of the original.
282
+ * If a fork ever can, the RFD requires remapping the copied ids, for
283
+ * example by deriving the child id from the root session id.
284
+ */
109
285
  private nextChildSessionId;
110
286
  }
111
- export declare function announceNativeSubagent(child: NativeSubagent, publish: Publish): Promise<void>;
287
+ /**
288
+ * Announces the child on its parent, once, before any update of the child.
289
+ * The RFD form announces it as running and then sends the prompt as the
290
+ * first message of the child. The child gets no capabilities, so the client
291
+ * may not cancel or otherwise change it.
292
+ */
293
+ export declare function announceNativeSubagent(child: NativeSubagent, publish: Publish, form: SubagentForm): Promise<void>;
112
294
  export declare function finishNativeSubagent(session: NativeSubagentSession, taskId: string, state: SubagentState, publish: Publish): Promise<void>;
295
+ /**
296
+ * The RFD form: the work state at the end of a child's work.
297
+ *
298
+ * A failure is idle with the `error` stop reason and, when the SDK gives its
299
+ * text, the JSON-RPC `error`, as the RFD asks: a v1 child has no prompt
300
+ * response, so this is how a client learns that its work failed. The error is
301
+ * an internal error, as for a failed turn on the v2 surface.
302
+ *
303
+ * A task that a worker restart orphaned, or that was still running when the
304
+ * stream ended, is idle with no stop reason: its work ended, but the adapter
305
+ * did not see a cancellation or a failure, which the RFD forbids claiming.
306
+ */
307
+ export declare function rfdEndState(state: SubagentState, end: TaskEnd | undefined): WorkState;
308
+ /**
309
+ * The RFD form: the parent's labels for a child. The title is the agent's
310
+ * name, with its role after it when both are known, else the role. The
311
+ * description is the task's short description, never the prompt.
312
+ */
313
+ export declare function rfdLabels(name: unknown, role: unknown, description: unknown): {
314
+ title?: string;
315
+ role?: string;
316
+ description?: string;
317
+ };
113
318
  /**
114
319
  * The agent id that a successful SendMessage result resumed. The SDK puts it
115
320
  * in `tool_use_result.resumedAgentId` when a finished agent runs again.
@@ -124,6 +329,18 @@ export declare function sendMessageResumePrompt(toolUses: Record<string, {
124
329
  name: string;
125
330
  input: unknown;
126
331
  } | undefined>, agentId: string, resultToolUseIds?: readonly string[]): string | undefined;
332
+ /**
333
+ * The SendMessage call that resumed the agent `agentId`, and its text when it
334
+ * has one; see {@link sendMessageResumePrompt}. The call is known even
335
+ * without text, so a late result still names the delegation it reports.
336
+ */
337
+ export declare function sendMessageResume(toolUses: Record<string, {
338
+ name: string;
339
+ input: unknown;
340
+ } | undefined>, agentId: string, resultToolUseIds?: readonly string[]): {
341
+ toolUseId: string;
342
+ text?: string;
343
+ } | undefined;
127
344
  export declare function nativeSubagentState(status: unknown): SubagentState | undefined;
128
345
  export declare function isNativeSubagentControlUpdate(update: AcpSessionNotification["update"]): update is Extract<AcpSessionNotification["update"], {
129
346
  sessionUpdate: "tool_call" | "tool_call_update";