@agentclientprotocol/claude-agent-acp 0.102.1-preview.2 → 0.102.1-preview.4

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 (157) hide show
  1. package/dist/acp-agent.d.ts +1 -1812
  2. package/dist/acp-agent.d.ts.map +1 -1
  3. package/dist/acp-agent.js +3 -9657
  4. package/dist/acp-client.d.ts +28 -0
  5. package/dist/acp-client.d.ts.map +1 -0
  6. package/dist/hide-claude-auth.d.ts +3 -3
  7. package/dist/hide-claude-auth.js +3 -3
  8. package/dist/idle-compaction.d.ts +1 -1
  9. package/dist/idle-compaction.js +1 -1
  10. package/dist/lib.d.ts +5 -1
  11. package/dist/lib.d.ts.map +1 -1
  12. package/dist/lib.js +3 -1
  13. package/dist/logger.d.ts +10 -0
  14. package/dist/logger.d.ts.map +1 -0
  15. package/dist/logger.js +1 -0
  16. package/dist/message-filters.d.ts +43 -0
  17. package/dist/message-filters.d.ts.map +1 -0
  18. package/dist/message-filters.js +197 -0
  19. package/dist/new-session-meta.d.ts +40 -0
  20. package/dist/new-session-meta.d.ts.map +1 -0
  21. package/dist/new-session-meta.js +1 -0
  22. package/dist/prompt-to-claude.d.ts +10 -0
  23. package/dist/prompt-to-claude.d.ts.map +1 -0
  24. package/dist/prompt-to-claude.js +120 -0
  25. package/dist/result-end.d.ts +33 -4
  26. package/dist/result-end.d.ts.map +1 -1
  27. package/dist/result-end.js +34 -0
  28. package/dist/sdk-to-acp.d.ts +93 -0
  29. package/dist/sdk-to-acp.d.ts.map +1 -0
  30. package/dist/sdk-to-acp.js +635 -0
  31. package/dist/serve.d.ts +2 -1
  32. package/dist/serve.d.ts.map +1 -1
  33. package/dist/serve.js +1 -1
  34. package/dist/session-titles.d.ts +1 -1
  35. package/dist/session-titles.js +1 -1
  36. package/dist/session-usage.d.ts +1 -1
  37. package/dist/session-usage.d.ts.map +1 -1
  38. package/dist/session-usage.js +1 -1
  39. package/dist/slash-commands.d.ts +10 -0
  40. package/dist/slash-commands.d.ts.map +1 -0
  41. package/dist/slash-commands.js +99 -0
  42. package/dist/task-notifications.d.ts +2 -2
  43. package/dist/task-notifications.js +2 -2
  44. package/dist/utils.d.ts +1 -1
  45. package/dist/utils.d.ts.map +1 -1
  46. package/dist/v1/acp-agent.d.ts +1610 -0
  47. package/dist/v1/acp-agent.d.ts.map +1 -0
  48. package/dist/v1/acp-agent.js +8600 -0
  49. package/dist/{background-work.d.ts → v1/background-work.d.ts} +1 -1
  50. package/dist/v1/background-work.d.ts.map +1 -0
  51. package/dist/v1/goal-extension.d.ts.map +1 -0
  52. package/dist/v1/session-index/activity.d.ts.map +1 -0
  53. package/dist/v1/session-index/archive-title.d.ts.map +1 -0
  54. package/dist/v1/session-index/background-tasks.d.ts.map +1 -0
  55. package/dist/{session-index → v1/session-index}/background-tasks.js +1 -1
  56. package/dist/{session-index → v1/session-index}/connection.d.ts +3 -1
  57. package/dist/v1/session-index/connection.d.ts.map +1 -0
  58. package/dist/{session-index → v1/session-index}/connection.js +1 -1
  59. package/dist/v1/session-index/dir-listing.d.ts.map +1 -0
  60. package/dist/v1/session-index/first-prompt.d.ts.map +1 -0
  61. package/dist/v1/session-index/list-subscriptions.d.ts.map +1 -0
  62. package/dist/v1/session-index/live-registry.d.ts.map +1 -0
  63. package/dist/{session-index → v1/session-index}/live-registry.js +1 -1
  64. package/dist/v1/session-index/project-dirs.d.ts.map +1 -0
  65. package/dist/{session-index → v1/session-index}/project-dirs.js +1 -1
  66. package/dist/v1/session-index/service.d.ts.map +1 -0
  67. package/dist/{session-index → v1/session-index}/service.js +2 -2
  68. package/dist/v1/session-index/session-index.d.ts.map +1 -0
  69. package/dist/{session-index → v1/session-index}/session-index.js +1 -1
  70. package/dist/v1/session-index/session-info.d.ts.map +1 -0
  71. package/dist/{session-index → v1/session-index}/session-info.js +1 -1
  72. package/dist/v1/session-index/transcript-scan.d.ts.map +1 -0
  73. package/dist/v1/session-index/worktrees.d.ts.map +1 -0
  74. package/dist/v1/tool-calls/changed-meta-filter.d.ts.map +1 -0
  75. package/dist/v1/turn-events.d.ts.map +1 -0
  76. package/dist/v1/turn-events.js +1 -0
  77. package/dist/v2/agent.d.ts +1 -1
  78. package/dist/v2/agent.d.ts.map +1 -1
  79. package/dist/v2/agent.js +1 -1
  80. package/dist/v2/auth.d.ts +1 -1
  81. package/dist/v2/auth.d.ts.map +1 -1
  82. package/dist/v2/commands.js +1 -1
  83. package/dist/v2/config.d.ts +1 -1
  84. package/dist/v2/config.d.ts.map +1 -1
  85. package/dist/v2/elicitation.d.ts +1 -1
  86. package/dist/v2/elicitation.d.ts.map +1 -1
  87. package/dist/v2/file-preview.d.ts +1 -1
  88. package/dist/v2/file-preview.d.ts.map +1 -1
  89. package/dist/v2/outcome.d.ts.map +1 -1
  90. package/dist/v2/outcome.js +2 -1
  91. package/dist/v2/remote-control.d.ts +1 -1
  92. package/dist/v2/remote-control.d.ts.map +1 -1
  93. package/dist/v2/reports.d.ts +1 -1
  94. package/dist/v2/reports.d.ts.map +1 -1
  95. package/dist/v2/restarts.d.ts +1 -1
  96. package/dist/v2/restarts.d.ts.map +1 -1
  97. package/dist/v2/session.d.ts +1 -1
  98. package/dist/v2/session.d.ts.map +1 -1
  99. package/dist/v2/session.js +2 -1
  100. package/dist/v2/setup.d.ts +1 -1
  101. package/dist/v2/setup.d.ts.map +1 -1
  102. package/dist/v2/stopped-work.js +1 -1
  103. package/dist/v2/stream.d.ts +3 -2
  104. package/dist/v2/stream.d.ts.map +1 -1
  105. package/dist/v2/stream.js +2 -1
  106. package/dist/v2/subagent-replay.d.ts +1 -1
  107. package/dist/v2/subagent-replay.d.ts.map +1 -1
  108. package/dist/v2/subscription-guard.d.ts +1 -1
  109. package/dist/v2/subscription-guard.d.ts.map +1 -1
  110. package/dist/v2/tasks.d.ts +1 -1
  111. package/dist/v2/tasks.d.ts.map +1 -1
  112. package/package.json +1 -1
  113. package/dist/background-work.d.ts.map +0 -1
  114. package/dist/goal-extension.d.ts.map +0 -1
  115. package/dist/session-index/activity.d.ts.map +0 -1
  116. package/dist/session-index/archive-title.d.ts.map +0 -1
  117. package/dist/session-index/background-tasks.d.ts.map +0 -1
  118. package/dist/session-index/connection.d.ts.map +0 -1
  119. package/dist/session-index/dir-listing.d.ts.map +0 -1
  120. package/dist/session-index/first-prompt.d.ts.map +0 -1
  121. package/dist/session-index/list-subscriptions.d.ts.map +0 -1
  122. package/dist/session-index/live-registry.d.ts.map +0 -1
  123. package/dist/session-index/project-dirs.d.ts.map +0 -1
  124. package/dist/session-index/service.d.ts.map +0 -1
  125. package/dist/session-index/session-index.d.ts.map +0 -1
  126. package/dist/session-index/session-info.d.ts.map +0 -1
  127. package/dist/session-index/transcript-scan.d.ts.map +0 -1
  128. package/dist/session-index/worktrees.d.ts.map +0 -1
  129. package/dist/tool-calls/changed-meta-filter.d.ts.map +0 -1
  130. package/dist/turn-events.d.ts.map +0 -1
  131. /package/dist/{turn-events.js → acp-client.js} +0 -0
  132. /package/dist/{background-work.js → v1/background-work.js} +0 -0
  133. /package/dist/{goal-extension.d.ts → v1/goal-extension.d.ts} +0 -0
  134. /package/dist/{goal-extension.js → v1/goal-extension.js} +0 -0
  135. /package/dist/{session-index → v1/session-index}/activity.d.ts +0 -0
  136. /package/dist/{session-index → v1/session-index}/activity.js +0 -0
  137. /package/dist/{session-index → v1/session-index}/archive-title.d.ts +0 -0
  138. /package/dist/{session-index → v1/session-index}/archive-title.js +0 -0
  139. /package/dist/{session-index → v1/session-index}/background-tasks.d.ts +0 -0
  140. /package/dist/{session-index → v1/session-index}/dir-listing.d.ts +0 -0
  141. /package/dist/{session-index → v1/session-index}/dir-listing.js +0 -0
  142. /package/dist/{session-index → v1/session-index}/first-prompt.d.ts +0 -0
  143. /package/dist/{session-index → v1/session-index}/first-prompt.js +0 -0
  144. /package/dist/{session-index → v1/session-index}/list-subscriptions.d.ts +0 -0
  145. /package/dist/{session-index → v1/session-index}/list-subscriptions.js +0 -0
  146. /package/dist/{session-index → v1/session-index}/live-registry.d.ts +0 -0
  147. /package/dist/{session-index → v1/session-index}/project-dirs.d.ts +0 -0
  148. /package/dist/{session-index → v1/session-index}/service.d.ts +0 -0
  149. /package/dist/{session-index → v1/session-index}/session-index.d.ts +0 -0
  150. /package/dist/{session-index → v1/session-index}/session-info.d.ts +0 -0
  151. /package/dist/{session-index → v1/session-index}/transcript-scan.d.ts +0 -0
  152. /package/dist/{session-index → v1/session-index}/transcript-scan.js +0 -0
  153. /package/dist/{session-index → v1/session-index}/worktrees.d.ts +0 -0
  154. /package/dist/{session-index → v1/session-index}/worktrees.js +0 -0
  155. /package/dist/{tool-calls → v1/tool-calls}/changed-meta-filter.d.ts +0 -0
  156. /package/dist/{tool-calls → v1/tool-calls}/changed-meta-filter.js +0 -0
  157. /package/dist/{turn-events.d.ts → v1/turn-events.d.ts} +0 -0
@@ -0,0 +1,28 @@
1
+ import type { CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse, ReadTextFileRequest, ReadTextFileResponse, RequestPermissionResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk/unstable";
2
+ import type { AcpSessionNotification } from "./acp-subagents.js";
3
+ import type { AcpPermissionRequest } from "./permissions/presentation.js";
4
+ /**
5
+ * Client-facing surface the agent calls back into. This is the subset of ACP
6
+ * client methods the agent actually uses, expressed as a narrow interface so
7
+ * tests can supply lightweight mocks. In the v1 agent it is backed by
8
+ * `ClientConnection` (`v1/acp-agent.ts`) over the SDK's typed `AgentContext`.
9
+ * The v2 session output passes one that only takes `sessionUpdate`
10
+ * (`v2/stream.ts`).
11
+ */
12
+ export interface AcpClient {
13
+ sessionUpdate(params: AcpSessionNotification): Promise<void>;
14
+ /** `signal`, when aborted, sends `$/cancel_request` for the in-flight
15
+ * permission request so the client can dismiss its prompt, and rejects the
16
+ * call at once: a client that ignores the cancel never answers. */
17
+ requestPermission(params: AcpPermissionRequest, signal?: AbortSignal): Promise<RequestPermissionResponse>;
18
+ readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>;
19
+ writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>;
20
+ /** `signal`, when aborted, sends `$/cancel_request` for the in-flight
21
+ * elicitation so the client can dismiss its prompt, and rejects the call
22
+ * at once, as {@link requestPermission} does. */
23
+ createElicitation(params: CreateElicitationRequest, signal?: AbortSignal): Promise<CreateElicitationResponse>;
24
+ completeElicitation(params: CompleteElicitationNotification): Promise<void>;
25
+ /** Send a custom (extension) notification, e.g. `_claude/sdkMessage`. */
26
+ extNotification(method: string, params: Record<string, unknown>): Promise<void>;
27
+ }
28
+ //# sourceMappingURL=acp-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-client.d.ts","sourceRoot":"","sources":["../src/acp-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,aAAa,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D;;wEAEoE;IACpE,iBAAiB,CACf,MAAM,EAAE,oBAAoB,EAC5B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACtC,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACzE,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC5E;;sDAEkD;IAClD,iBAAiB,CACf,MAAM,EAAE,wBAAwB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACtC,mBAAmB,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,yEAAyE;IACzE,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjF"}
@@ -2,7 +2,7 @@
2
2
  * `--hide-claude-auth`: this integration must never bill a claude.ai
3
3
  * subscription. Under the flag the agent hides the claude.ai login method from
4
4
  * `initialize`, and refuses with `authRequired` every session and every turn
5
- * that a subscription would pay for. `acp-agent.ts` decides when the guard
5
+ * that a subscription would pay for. `v1/acp-agent.ts` decides when the guard
6
6
  * applies (flag on, no provider override); this module decides what it refuses.
7
7
  *
8
8
  * The guard judges the `AccountInfo` that the SDK caches at `initialize`. That
@@ -129,14 +129,14 @@ type GuardOptions = {
129
129
  * covers a session created under a provider override that `providers/disable`
130
130
  * later removed, so the create-time check never ran for the routing in force
131
131
  * now. A sign-out ends the query (see `markSessionForSignOutRespawn` in
132
- * `acp-agent.ts`), so the next turn recreates it and `initialize` reports the
132
+ * `v1/acp-agent.ts`), so the next turn recreates it and `initialize` reports the
133
133
  * real account. This guard does not see the residual case the module header
134
134
  * names either.
135
135
  *
136
136
  * A turn is refused when the account bills a subscription, and also when it
137
137
  * holds nothing this integration accepts, which is the user signing out in
138
138
  * mid-session. The refusal mirrors the signed-out path exactly (see
139
- * `failActiveWithSessionFailure` for `auth_required` in `acp-agent.ts`): every
139
+ * `failActiveWithSessionFailure` for `auth_required` in `v1/acp-agent.ts`): every
140
140
  * client gets the `authRequired` JSON-RPC rejection that starts its own auth
141
141
  * flow. The guard sends no separate access message.
142
142
  *
@@ -2,7 +2,7 @@
2
2
  * `--hide-claude-auth`: this integration must never bill a claude.ai
3
3
  * subscription. Under the flag the agent hides the claude.ai login method from
4
4
  * `initialize`, and refuses with `authRequired` every session and every turn
5
- * that a subscription would pay for. `acp-agent.ts` decides when the guard
5
+ * that a subscription would pay for. `v1/acp-agent.ts` decides when the guard
6
6
  * applies (flag on, no provider override); this module decides what it refuses.
7
7
  *
8
8
  * The guard judges the `AccountInfo` that the SDK caches at `initialize`. That
@@ -150,14 +150,14 @@ export function warnClaudeSubscriptionGuardDegraded(options) {
150
150
  * covers a session created under a provider override that `providers/disable`
151
151
  * later removed, so the create-time check never ran for the routing in force
152
152
  * now. A sign-out ends the query (see `markSessionForSignOutRespawn` in
153
- * `acp-agent.ts`), so the next turn recreates it and `initialize` reports the
153
+ * `v1/acp-agent.ts`), so the next turn recreates it and `initialize` reports the
154
154
  * real account. This guard does not see the residual case the module header
155
155
  * names either.
156
156
  *
157
157
  * A turn is refused when the account bills a subscription, and also when it
158
158
  * holds nothing this integration accepts, which is the user signing out in
159
159
  * mid-session. The refusal mirrors the signed-out path exactly (see
160
- * `failActiveWithSessionFailure` for `auth_required` in `acp-agent.ts`): every
160
+ * `failActiveWithSessionFailure` for `auth_required` in `v1/acp-agent.ts`): every
161
161
  * client gets the `authRequired` JSON-RPC rejection that starts its own auth
162
162
  * flow. The guard sends no separate access message.
163
163
  *
@@ -42,7 +42,7 @@ export declare class IdleCompaction {
42
42
  /** `status` of the last `rate_limit_event`; unknown until one arrives. */
43
43
  private rateLimitStatus;
44
44
  constructor(host: IdleCompactionHost, options?: IdleCompactionOptions);
45
- /** Whether an idle compaction it started is still running. `acp-agent.ts` reports
45
+ /** Whether an idle compaction it started is still running. `v1/acp-agent.ts` reports
46
46
  * `trigger: "idle"` while it is true. A client's `/compact` queued behind is read
47
47
  * only after the adapter's turn's `result`, which clears `compacting`; this relies
48
48
  * on the CLI emitting that compaction's `compact_boundary` after the previous
@@ -53,7 +53,7 @@ export class IdleCompaction {
53
53
  this.env = options.env ?? process.env;
54
54
  this.setTimer = options.setTimeout ?? ((cb, ms) => setTimeout(cb, ms));
55
55
  }
56
- /** Whether an idle compaction it started is still running. `acp-agent.ts` reports
56
+ /** Whether an idle compaction it started is still running. `v1/acp-agent.ts` reports
57
57
  * `trigger: "idle"` while it is true. A client's `/compact` queued behind is read
58
58
  * only after the adapter's turn's `result`, which clears `compacting`; this relies
59
59
  * on the CLI emitting that compaction's `compact_boundary` after the previous
package/dist/lib.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- export { ClaudeAcpAgent, isLocalCommandMetadata, stripLocalCommandMetadata, runAcp, toAcpNotifications, streamEventToAcpNotifications, type ToolUpdateMeta, type NewSessionMeta, type SDKMessageFilter, } from "./acp-agent.js";
1
+ export { ClaudeAcpAgent, runAcp } from "./v1/acp-agent.js";
2
+ export { isLocalCommandMetadata, stripLocalCommandMetadata } from "./message-filters.js";
3
+ export { toAcpNotifications, streamEventToAcpNotifications } from "./sdk-to-acp.js";
4
+ export type { NewSessionMeta, SDKMessageFilter } from "./new-session-meta.js";
5
+ export type { ToolUpdateMeta } from "./tool-calls/renderer.js";
2
6
  export { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
3
7
  export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
4
8
  export { SettingsManager, type SettingsManagerOptions } from "./settings.js";
package/dist/lib.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,MAAM,EACN,kBAAkB,EAClB,6BAA6B,EAC7B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG7E,OAAO,EACL,yBAAyB,EACzB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AACpF,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG7E,OAAO,EACL,yBAAyB,EACzB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
package/dist/lib.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // Export the main agent class and utilities for library usage
2
- export { ClaudeAcpAgent, isLocalCommandMetadata, stripLocalCommandMetadata, runAcp, toAcpNotifications, streamEventToAcpNotifications, } from "./acp-agent.js";
2
+ export { ClaudeAcpAgent, runAcp } from "./v1/acp-agent.js";
3
+ export { isLocalCommandMetadata, stripLocalCommandMetadata } from "./message-filters.js";
4
+ export { toAcpNotifications, streamEventToAcpNotifications } from "./sdk-to-acp.js";
3
5
  export { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
4
6
  export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
5
7
  export { SettingsManager } from "./settings.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Logger interface for customizing logging output
3
+ */
4
+ export interface Logger {
5
+ log: (...args: any[]) => void;
6
+ error: (...args: any[]) => void;
7
+ /** Optional: a caller that supplies no `warn` gets its warnings on `error`. */
8
+ warn?: (...args: any[]) => void;
9
+ }
10
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAChC,+EAA+E;IAC/E,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACjC"}
package/dist/logger.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ export declare const LOCAL_ONLY_COMMANDS: Set<string>;
2
+ /**
3
+ * Return user-message content with local-command and injected-context marker
4
+ * tags removed, or `null` if nothing meaningful remains (caller should skip
5
+ * the message). Preserves real prose that's mixed in alongside the markers —
6
+ * e.g. a message like `<command-name>…</command-name>hi` becomes `hi`, and
7
+ * `hi<system-reminder>…</system-reminder>` becomes `hi`.
8
+ */
9
+ export declare function stripLocalCommandMetadata(content: unknown): unknown | null;
10
+ export declare function isLocalCommandMetadata(content: unknown): boolean;
11
+ /**
12
+ * True for the synthetic assistant message the CLI injects into the transcript
13
+ * when a turn fails authentication (e.g. "Not logged in · Please run /login",
14
+ * "Session expired. Please run /login to sign in again."). The `/login`
15
+ * instruction is Claude Code TUI-specific and meaningless to ACP clients
16
+ * (issue #863). The live prompt loop suppresses the text and fails the turn
17
+ * with `authRequired` so the client can run its own auth flow; replay must
18
+ * skip it too — both for parity with what the client saw live and because the
19
+ * message stays in the transcript forever, so it would resurface on every
20
+ * session/load even after the user has logged back in.
21
+ *
22
+ * Takes the API message (`message.message`), which replay only knows as
23
+ * `unknown`. The persisted record's structured `error` marker is stripped by
24
+ * `getSessionMessages`, and the CLI does not always set it to
25
+ * `authentication_failed` anyway: an expired login with no refresh token
26
+ * ("Login expired · Run /login to sign in again, …") arrives as
27
+ * `invalid_request`. So the synthetic model + text is what both paths match on.
28
+ * Usage-limit banners are excluded because some of them also mention `/login`
29
+ * (to switch accounts) and have their own handling.
30
+ */
31
+ export declare function isSyntheticLoginMessage(apiMessage: unknown): boolean;
32
+ /**
33
+ * True for a transcript message delivered to the model from another agent,
34
+ * session or channel. Since SDK 0.3.284 `getSessionMessages` returns these as
35
+ * `is_meta` user messages whose content is the full harness framing (envelope
36
+ * XML plus the "not typed by your user" preamble). The live prompt loop never
37
+ * renders them, so replay skips them too rather than presenting them as text
38
+ * the user typed. Other `is_meta` messages (compact summaries) are kept.
39
+ *
40
+ * `is_meta` and `origin` are runtime fields not declared on `SessionMessage`.
41
+ */
42
+ export declare function isReplayHiddenMetaMessage(message: unknown): boolean;
43
+ //# sourceMappingURL=message-filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-filters.d.ts","sourceRoot":"","sources":["../src/message-filters.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,mBAAmB,aAAqD,CAAC;AA+FtF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAyB1E;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAgBpE;AAYD;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAanE"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * The Claude Code messages and content that a client never sees as the user's
3
+ * or the agent's text: local slash command markers, context the CLI injects,
4
+ * the synthetic `/login` message and meta messages from other agents. The live
5
+ * stream and the `session/load` replay both filter with these.
6
+ */
7
+ import { isLoginRequiredText } from "./result-end.js";
8
+ import { isSyntheticUsageLimitMessage } from "./session-failure-extension.js";
9
+ import { markerTagText, TASK_NOTIFICATION_TAG } from "./task-notifications.js";
10
+ // Slash commands that the SDK handles locally without replaying the user
11
+ // message and without invoking the model.
12
+ export const LOCAL_ONLY_COMMANDS = new Set(["/context", "/heapdump", "/extra-usage"]);
13
+ // Commands whose marker-only transcript records are ACP/client-local UI noise,
14
+ // not model-visible user prompts. Marker-only custom slash skills are not in
15
+ // this list, so replay can reconstruct them from `<command-name>`/`<command-args>`.
16
+ const REPLAY_HIDDEN_COMMANDS = new Set([
17
+ ...LOCAL_ONLY_COMMANDS,
18
+ "/compact",
19
+ "/model",
20
+ "/mcp",
21
+ "/status",
22
+ "/usage",
23
+ ]);
24
+ // The Claude SDK persists local slash command invocations (e.g. `/model`) and
25
+ // their output as user messages in the session transcript, wrapping the
26
+ // payload in these XML-like markers that the CLI uses for its own display.
27
+ // The live prompt loop drops them; replay must strip them too or they leak
28
+ // into the UI on session/load.
29
+ const LOCAL_COMMAND_MARKERS = [
30
+ "command-name",
31
+ "command-message",
32
+ "command-args",
33
+ "local-command-stdout",
34
+ "local-command-stderr",
35
+ ].map((tag) => ({ open: `<${tag}>`, close: `</${tag}>` }));
36
+ // Context the CLI injects into a user turn to steer the model, appended to
37
+ // whatever the user typed. Nobody wrote it and no client sees it live — the
38
+ // prompt loop's user-message skip covers the whole message — but it is
39
+ // persisted alongside that prose, so replay would hand the client a prompt
40
+ // with instructions in it the user never gave. A `task-notification` tells the
41
+ // model that a background task stopped; live, the SDK `task_notification`
42
+ // frame reports the same stop, so replay restores the task state from it (see
43
+ // taskNotificationsOf) instead of showing it.
44
+ const INJECTED_CONTEXT_MARKERS = ["system-reminder", TASK_NOTIFICATION_TAG].map((tag) => ({
45
+ open: `<${tag}>`,
46
+ close: `</${tag}>`,
47
+ }));
48
+ // Everything a replayed user message may be wrapped in that is not speech.
49
+ const TRANSCRIPT_MARKERS = [...LOCAL_COMMAND_MARKERS, ...INJECTED_CONTEXT_MARKERS];
50
+ // Single-pass scanner that removes each `<tag>…</tag>` marker (matching the
51
+ // nearest closing tag of the same name, like a lazy regex would).
52
+ function stripMarkerTags(text) {
53
+ const dead = new Set();
54
+ let result = "";
55
+ let copiedUpTo = 0;
56
+ let i = 0;
57
+ while (i < text.length) {
58
+ if (text[i] === "<") {
59
+ const marker = TRANSCRIPT_MARKERS.find((m) => !dead.has(m.open) && text.startsWith(m.open, i));
60
+ if (marker) {
61
+ const end = text.indexOf(marker.close, i + marker.open.length);
62
+ if (end !== -1) {
63
+ result += text.slice(copiedUpTo, i);
64
+ i = copiedUpTo = end + marker.close.length;
65
+ continue;
66
+ }
67
+ // No closing marker remains anywhere ahead, and `indexOf` only ever
68
+ // searches forward from here on, so stop treating this tag as an
69
+ // opener — that avoids rescanning the tail for it on every match.
70
+ dead.add(marker.open);
71
+ }
72
+ }
73
+ i++;
74
+ }
75
+ return result + text.slice(copiedUpTo);
76
+ }
77
+ function hasMarkerTag(text, tag) {
78
+ return markerTagText(text, tag) !== undefined;
79
+ }
80
+ function commandInvocationFromMarkerOnlyText(text) {
81
+ if (hasMarkerTag(text, "local-command-stdout") || hasMarkerTag(text, "local-command-stderr")) {
82
+ return null;
83
+ }
84
+ const commandName = markerTagText(text, "command-name")?.trim();
85
+ if (!commandName?.startsWith("/"))
86
+ return null;
87
+ if (REPLAY_HIDDEN_COMMANDS.has(commandName.split(" ", 1)[0]))
88
+ return null;
89
+ const commandArgs = markerTagText(text, "command-args")?.trim();
90
+ return commandArgs ? `${commandName} ${commandArgs}` : commandName;
91
+ }
92
+ function stripLocalCommandMetadataText(text) {
93
+ const stripped = stripMarkerTags(text);
94
+ if (stripped.trim() !== "")
95
+ return stripped;
96
+ return commandInvocationFromMarkerOnlyText(text);
97
+ }
98
+ /**
99
+ * Return user-message content with local-command and injected-context marker
100
+ * tags removed, or `null` if nothing meaningful remains (caller should skip
101
+ * the message). Preserves real prose that's mixed in alongside the markers —
102
+ * e.g. a message like `<command-name>…</command-name>hi` becomes `hi`, and
103
+ * `hi<system-reminder>…</system-reminder>` becomes `hi`.
104
+ */
105
+ export function stripLocalCommandMetadata(content) {
106
+ if (typeof content === "string") {
107
+ return stripLocalCommandMetadataText(content);
108
+ }
109
+ if (!Array.isArray(content))
110
+ return content;
111
+ const kept = [];
112
+ for (const block of content) {
113
+ if (block &&
114
+ typeof block === "object" &&
115
+ "type" in block &&
116
+ block.type === "text" &&
117
+ "text" in block &&
118
+ typeof block.text === "string") {
119
+ const stripped = stripLocalCommandMetadataText(block.text);
120
+ if (stripped === null)
121
+ continue;
122
+ kept.push({ ...block, text: stripped });
123
+ }
124
+ else {
125
+ kept.push(block);
126
+ }
127
+ }
128
+ if (kept.length === 0)
129
+ return null;
130
+ return kept;
131
+ }
132
+ export function isLocalCommandMetadata(content) {
133
+ return stripLocalCommandMetadata(content) === null;
134
+ }
135
+ /**
136
+ * True for the synthetic assistant message the CLI injects into the transcript
137
+ * when a turn fails authentication (e.g. "Not logged in · Please run /login",
138
+ * "Session expired. Please run /login to sign in again."). The `/login`
139
+ * instruction is Claude Code TUI-specific and meaningless to ACP clients
140
+ * (issue #863). The live prompt loop suppresses the text and fails the turn
141
+ * with `authRequired` so the client can run its own auth flow; replay must
142
+ * skip it too — both for parity with what the client saw live and because the
143
+ * message stays in the transcript forever, so it would resurface on every
144
+ * session/load even after the user has logged back in.
145
+ *
146
+ * Takes the API message (`message.message`), which replay only knows as
147
+ * `unknown`. The persisted record's structured `error` marker is stripped by
148
+ * `getSessionMessages`, and the CLI does not always set it to
149
+ * `authentication_failed` anyway: an expired login with no refresh token
150
+ * ("Login expired · Run /login to sign in again, …") arrives as
151
+ * `invalid_request`. So the synthetic model + text is what both paths match on.
152
+ * Usage-limit banners are excluded because some of them also mention `/login`
153
+ * (to switch accounts) and have their own handling.
154
+ */
155
+ export function isSyntheticLoginMessage(apiMessage) {
156
+ if (!apiMessage || typeof apiMessage !== "object") {
157
+ return false;
158
+ }
159
+ const { model, content } = apiMessage;
160
+ if (model !== "<synthetic>" || !Array.isArray(content) || content.length !== 1) {
161
+ return false;
162
+ }
163
+ const block = content[0];
164
+ return (!!block &&
165
+ block.type === "text" &&
166
+ typeof block.text === "string" &&
167
+ isLoginRequiredText(block.text) &&
168
+ !isSyntheticUsageLimitMessage(apiMessage));
169
+ }
170
+ /** Origin kinds of the meta user messages `getSessionMessages` returns since
171
+ * SDK 0.3.284 (messages from other agents, sessions and channels). */
172
+ const REPLAY_HIDDEN_META_ORIGIN_KINDS = new Set([
173
+ "peer",
174
+ "channel",
175
+ "observer",
176
+ "observer-activity",
177
+ "slack-ping",
178
+ ]);
179
+ /**
180
+ * True for a transcript message delivered to the model from another agent,
181
+ * session or channel. Since SDK 0.3.284 `getSessionMessages` returns these as
182
+ * `is_meta` user messages whose content is the full harness framing (envelope
183
+ * XML plus the "not typed by your user" preamble). The live prompt loop never
184
+ * renders them, so replay skips them too rather than presenting them as text
185
+ * the user typed. Other `is_meta` messages (compact summaries) are kept.
186
+ *
187
+ * `is_meta` and `origin` are runtime fields not declared on `SessionMessage`.
188
+ */
189
+ export function isReplayHiddenMetaMessage(message) {
190
+ if (!message || typeof message !== "object")
191
+ return false;
192
+ const { type, is_meta, origin } = message;
193
+ return (type === "user" &&
194
+ is_meta === true &&
195
+ typeof origin?.kind === "string" &&
196
+ REPLAY_HIDDEN_META_ORIGIN_KINDS.has(origin.kind));
197
+ }
@@ -0,0 +1,40 @@
1
+ import type { Options, SDKMessageOrigin } from "@anthropic-ai/claude-agent-sdk";
2
+ export type SDKMessageFilter = {
3
+ type: string;
4
+ subtype?: string;
5
+ origin?: SDKMessageOrigin["kind"];
6
+ };
7
+ /**
8
+ * Extra metadata that can be given when creating a new session.
9
+ */
10
+ export type NewSessionMeta = {
11
+ claudeCode?: {
12
+ /**
13
+ * Options forwarded to Claude Code when starting a new session.
14
+ * Those parameters will be ignored and managed by ACP:
15
+ * - cwd
16
+ * - includePartialMessages
17
+ * - permissionMode
18
+ * - canUseTool
19
+ * - executable
20
+ * Those parameters will be used and updated to work with ACP:
21
+ * - hooks (merged with ACP's hooks)
22
+ * - mcpServers (merged with ACP's mcpServers)
23
+ * - disallowedTools (merged with ACP's disallowedTools)
24
+ * - tools (passed through; defaults to claude_code preset if not provided)
25
+ * - allowDangerouslySkipPermissions (set to `false` to remove bypassPermissions
26
+ * from this session; repeat it on session/load. `true` cannot override root)
27
+ */
28
+ options?: Options;
29
+ /**
30
+ * When set, raw SDK messages are emitted as extNotification("_claude/sdkMessage", message)
31
+ * in addition to normal processing.
32
+ * - true: emit all messages
33
+ * - false/undefined: emit nothing (default)
34
+ * - SDKMessageFilter[]: emit only messages matching at least one filter
35
+ */
36
+ emitRawSDKMessages?: boolean | SDKMessageFilter[];
37
+ };
38
+ additionalRoots?: string[];
39
+ };
40
+ //# sourceMappingURL=new-session-meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-session-meta.d.ts","sourceRoot":"","sources":["../src/new-session-meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE;QACX;;;;;;;;;;;;;;;WAeG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;;;;;WAMG;QACH,kBAAkB,CAAC,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAAC;KACnD,CAAC;IACF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The conversion of an ACP prompt into the Claude Code user message.
3
+ */
4
+ import type { PromptRequest } from "@agentclientprotocol/sdk/unstable";
5
+ import type { SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
6
+ /** The prompt content block types that `promptToClaude` converts. The agent
7
+ * advertises no `audio` prompt capability. */
8
+ export declare const SUPPORTED_PROMPT_CONTENT_TYPES: readonly string[];
9
+ export declare function promptToClaude(prompt: PromptRequest): SDKUserMessage;
10
+ //# sourceMappingURL=prompt-to-claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-to-claude.d.ts","sourceRoot":"","sources":["../src/prompt-to-claude.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAoBrE;+CAC+C;AAC/C,eAAO,MAAM,8BAA8B,EAAE,SAAS,MAAM,EAK3D,CAAC;AAEF,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc,CA+FpE"}
@@ -0,0 +1,120 @@
1
+ import { blobResourceToClaude } from "./blob-resources.js";
2
+ function formatUriAsLink(uri) {
3
+ try {
4
+ if (uri.startsWith("file://")) {
5
+ const path = uri.slice(7); // Remove "file://"
6
+ const name = path.split("/").pop() || path;
7
+ return `[@${name}](${uri})`;
8
+ }
9
+ else if (uri.startsWith("zed://")) {
10
+ const parts = uri.split("/");
11
+ const name = parts[parts.length - 1] || uri;
12
+ return `[@${name}](${uri})`;
13
+ }
14
+ return uri;
15
+ }
16
+ catch {
17
+ return uri;
18
+ }
19
+ }
20
+ /** The prompt content block types that `promptToClaude` converts. The agent
21
+ * advertises no `audio` prompt capability. */
22
+ export const SUPPORTED_PROMPT_CONTENT_TYPES = [
23
+ "text",
24
+ "image",
25
+ "resource_link",
26
+ "resource",
27
+ ];
28
+ export function promptToClaude(prompt) {
29
+ const content = [];
30
+ const context = [];
31
+ const firstText = prompt.prompt.find((chunk) => chunk.type === "text");
32
+ for (const chunk of prompt.prompt) {
33
+ switch (chunk.type) {
34
+ case "text": {
35
+ let text = chunk.text;
36
+ // A slash command is the first text block. Change
37
+ // `/mcp:server:command args` to `/server:command (MCP) args`; the
38
+ // arguments can span lines.
39
+ const mcpMatch = chunk === firstText ? text.match(/^\/mcp:([^:\s]+):(\S+)(?:\s+([\s\S]*))?$/) : null;
40
+ if (mcpMatch) {
41
+ const [, server, command, args] = mcpMatch;
42
+ text = `/${server}:${command} (MCP)${args ? ` ${args}` : ""}`;
43
+ }
44
+ content.push({ type: "text", text });
45
+ break;
46
+ }
47
+ case "resource_link": {
48
+ const formattedUri = formatUriAsLink(chunk.uri);
49
+ content.push({
50
+ type: "text",
51
+ text: formattedUri,
52
+ });
53
+ break;
54
+ }
55
+ case "resource": {
56
+ const { uri } = chunk.resource;
57
+ // A blob resource becomes an image or document block, or its decoded
58
+ // text. A v1 prompt skips a blob of any other type, e.g.
59
+ // `application/zip`; a v2 prompt rejects it (see `v1PromptRequest`).
60
+ const blob = "blob" in chunk.resource ? blobResourceToClaude(chunk.resource) : undefined;
61
+ const text = "text" in chunk.resource
62
+ ? chunk.resource.text
63
+ : blob?.kind === "text"
64
+ ? blob.text
65
+ : undefined;
66
+ if (blob?.kind === "image" || blob?.kind === "document") {
67
+ content.push({ type: "text", text: formatUriAsLink(uri) }, blob.block);
68
+ }
69
+ else if (text !== undefined) {
70
+ content.push({ type: "text", text: formatUriAsLink(uri) });
71
+ context.push({
72
+ type: "text",
73
+ text: `\n<context ref="${uri}">\n${text}\n</context>`,
74
+ });
75
+ }
76
+ break;
77
+ }
78
+ case "image":
79
+ if (chunk.data) {
80
+ content.push({
81
+ type: "image",
82
+ source: {
83
+ type: "base64",
84
+ data: chunk.data,
85
+ media_type: chunk.mimeType,
86
+ },
87
+ });
88
+ }
89
+ else if (chunk.uri && chunk.uri.startsWith("http")) {
90
+ content.push({
91
+ type: "image",
92
+ source: {
93
+ type: "url",
94
+ url: chunk.uri,
95
+ },
96
+ });
97
+ }
98
+ break;
99
+ // Ignore audio and other unsupported types
100
+ default:
101
+ break;
102
+ }
103
+ }
104
+ content.push(...context);
105
+ return {
106
+ type: "user",
107
+ message: {
108
+ role: "user",
109
+ content: content,
110
+ },
111
+ session_id: prompt.sessionId,
112
+ parent_tool_use_id: null,
113
+ // ACP prompts are the user's own input relayed by the client. Stamp the
114
+ // provenance explicitly: per the SDK, a host wrapping keyboard input must
115
+ // send `{kind: "human"}` — an absent `origin` is treated as unattributed
116
+ // and fails closed at the CLI's strict isHuman() trust gates (e.g. the
117
+ // ultracode keyword opt-in honors only human-originated turns).
118
+ origin: { kind: "human" },
119
+ };
120
+ }
@@ -1,10 +1,11 @@
1
1
  /**
2
- * How Claude Code's `result` ends the work that it reports: the rules that
3
- * both cores read a turn's result with (the v1 prompt loop in `acp-agent.ts`
4
- * and `v2/outcome.ts`). Each core adds its own side effects, such as v1's
2
+ * How Claude Code's `result` ends the work that it reports, and whether that
3
+ * work was the user's turn or a cycle Claude Code started on its own: the
4
+ * rules that both cores read a turn's result with (the v1 prompt loop in
5
+ * `v1/acp-agent.ts` and `v2/`). Each core adds its own side effects, such as v1's
5
6
  * session failure category.
6
7
  */
7
- import type { SDKResultMessage } from "@anthropic-ai/claude-agent-sdk";
8
+ import type { SDKMessage, SDKMessageOrigin, SDKResultMessage } from "@anthropic-ai/claude-agent-sdk";
8
9
  export type ResultEnd = {
9
10
  stopReason: "refusal" | "max_tokens" | "end_turn" | "max_turn_requests";
10
11
  }
@@ -36,4 +37,32 @@ export declare function isLoginRequiredText(text: string): boolean;
36
37
  * the stop reason. Otherwise `max_turn_requests`.
37
38
  */
38
39
  export declare function resultEnd(result: SDKResultMessage): ResultEnd;
40
+ /** Result-message origin kinds that mark an AUTONOMOUS cycle — work the
41
+ * model did on its own (a task-notification followup, a peer/coordinator/
42
+ * observer message it handled) rather than the user's prompt. Absent,
43
+ * `human`, and `channel` origins are the user's own turn (this adapter's
44
+ * prompts arrive as the ACP channel on some CLI configurations — ALL
45
+ * channel servers are treated as user, so a foreign channel integration's
46
+ * autonomously-handled result is misclassified as the user's; accepted,
47
+ * see below), and `auto-continuation` continues the user's turn, so its
48
+ * result is the turn's real terminal.
49
+ *
50
+ * Deliberately fail-OPEN: an unknown future kind defaults to the user
51
+ * lane — including `unclassified` (SDK 0.3.232+), the CLI's own "couldn't
52
+ * attribute this" marker, which gets the same safe default. Misrouting a
53
+ * USER result into the autonomous lane hangs the prompt un-detectably
54
+ * (the result is skipped, its trailing idle absorbed as owed, so the
55
+ * #825 detector can't fire); misrouting an autonomous result into the
56
+ * user lane is the bounded misattribution class this set exists to
57
+ * reduce.
58
+ *
59
+ * Exception: a result from one of these origins that names a pending prompt
60
+ * in `user_message_uuids` consumed that folded prompt and takes the user
61
+ * lane (see the result handler of each core). */
62
+ export declare const AUTONOMOUS_RESULT_ORIGINS: ReadonlySet<SDKMessageOrigin["kind"]>;
63
+ /** Whether Claude Code ended the work of `result` because an interrupt
64
+ * stopped it, while the model streamed or while a tool ran. */
65
+ export declare function isAbortedResult(result: Extract<SDKMessage, {
66
+ type: "result";
67
+ }>): boolean;
39
68
  //# sourceMappingURL=result-end.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-end.d.ts","sourceRoot":"","sources":["../src/result-end.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,MAAM,MAAM,SAAS,GACjB;IAAE,UAAU,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAA;CAAE;AAC7E;;;GAGG;GACD;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAmB7D"}
1
+ {"version":3,"file":"result-end.d.ts","sourceRoot":"","sources":["../src/result-end.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AAExC,MAAM,MAAM,SAAS,GACjB;IAAE,UAAU,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAA;CAAE;AAC7E;;;GAGG;GACD;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAmB7D;AAMD;;;;;;;;;;;;;;;;;;;;;kDAqBkD;AAClD,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAM1E,CAAC;AAEH;gEACgE;AAChE,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAIxF"}