@agentclientprotocol/claude-agent-acp 0.109.1-preview.1 → 0.109.1-preview.10

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 (70) hide show
  1. package/README.md +10 -5
  2. package/dist/acp-subagents.d.ts +39 -0
  3. package/dist/acp-subagents.d.ts.map +1 -1
  4. package/dist/acp-subagents.js +47 -0
  5. package/dist/auth-status-reporter.d.ts +2 -3
  6. package/dist/auth-status-reporter.d.ts.map +1 -1
  7. package/dist/auth-status-reporter.js +32 -29
  8. package/dist/auth-status.d.ts +6 -7
  9. package/dist/auth-status.d.ts.map +1 -1
  10. package/dist/auth-status.js +9 -8
  11. package/dist/client-system-prompt.d.ts +6 -4
  12. package/dist/client-system-prompt.d.ts.map +1 -1
  13. package/dist/client-system-prompt.js +7 -2
  14. package/dist/context-compaction.d.ts.map +1 -1
  15. package/dist/context-compaction.js +4 -3
  16. package/dist/native-subagents.d.ts +102 -7
  17. package/dist/native-subagents.d.ts.map +1 -1
  18. package/dist/native-subagents.js +208 -17
  19. package/dist/plans.d.ts +4 -4
  20. package/dist/providers.d.ts +34 -1
  21. package/dist/providers.d.ts.map +1 -1
  22. package/dist/providers.js +37 -1
  23. package/dist/serve.d.ts +1 -1
  24. package/dist/serve.js +1 -1
  25. package/dist/subagent-replay.d.ts +49 -33
  26. package/dist/subagent-replay.d.ts.map +1 -1
  27. package/dist/subagent-replay.js +49 -52
  28. package/dist/tool-calls/renderer.d.ts +0 -9
  29. package/dist/tool-calls/renderer.d.ts.map +1 -1
  30. package/dist/tool-calls/renderer.js +1 -19
  31. package/dist/tool-calls/reporters/interaction.d.ts +9 -0
  32. package/dist/tool-calls/reporters/interaction.d.ts.map +1 -1
  33. package/dist/tool-calls/reporters/interaction.js +23 -1
  34. package/dist/tool-calls/reporters/search.d.ts +7 -3
  35. package/dist/tool-calls/reporters/search.d.ts.map +1 -1
  36. package/dist/tool-calls/reporters/search.js +9 -4
  37. package/dist/v1/acp-agent.d.ts +35 -19
  38. package/dist/v1/acp-agent.d.ts.map +1 -1
  39. package/dist/v1/acp-agent.js +123 -67
  40. package/dist/v1/client-connection.d.ts +4 -2
  41. package/dist/v1/client-connection.d.ts.map +1 -1
  42. package/dist/v1/client-connection.js +6 -2
  43. package/dist/v1/session-fingerprint.d.ts.map +1 -1
  44. package/dist/v1/session-fingerprint.js +1 -2
  45. package/dist/v2/agent.d.ts.map +1 -1
  46. package/dist/v2/agent.js +53 -19
  47. package/dist/v2/auth.d.ts +6 -5
  48. package/dist/v2/auth.d.ts.map +1 -1
  49. package/dist/v2/auth.js +2 -2
  50. package/dist/v2/permissions.d.ts +1 -1
  51. package/dist/v2/permissions.js +1 -1
  52. package/dist/v2/replay-hold.d.ts +15 -5
  53. package/dist/v2/replay-hold.d.ts.map +1 -1
  54. package/dist/v2/replay-hold.js +21 -7
  55. package/dist/v2/reports.d.ts +4 -0
  56. package/dist/v2/reports.d.ts.map +1 -1
  57. package/dist/v2/reports.js +10 -1
  58. package/dist/v2/session-requests.js +3 -1
  59. package/dist/v2/session-update.js +3 -3
  60. package/dist/v2/session.d.ts.map +1 -1
  61. package/dist/v2/session.js +2 -0
  62. package/dist/v2/subagent-replay.d.ts +20 -18
  63. package/dist/v2/subagent-replay.d.ts.map +1 -1
  64. package/dist/v2/subagent-replay.js +16 -31
  65. package/dist/v2/tasks.d.ts +55 -6
  66. package/dist/v2/tasks.d.ts.map +1 -1
  67. package/dist/v2/tasks.js +147 -19
  68. package/dist/v2/tool-call.d.ts.map +1 -1
  69. package/dist/v2/tool-call.js +23 -1
  70. package/package.json +4 -4
package/dist/v2/tasks.js CHANGED
@@ -18,6 +18,14 @@
18
18
  * wait for it. A child that ends before it is announced stays unexposed.
19
19
  * Each run of it is the child's foreground work: `running` from its start
20
20
  * to its end, on its stream and mirrored on the parent's `subagent_update`.
21
+ * - A forked skill (`context: fork`, such as `/code-review`) runs as a
22
+ * subagent that no Agent or Task call launched. One that Claude called
23
+ * with the Skill tool is announced on the session that made the call, which
24
+ * stays shown. One that the user typed has no call: it is announced on the
25
+ * root, and its messages name it by `agent_id` only, under an id that no
26
+ * call has (`forked-command-code-review`). Claude Code (2.1.328) holds
27
+ * those until after the task's end, so the child's end waits for them (see
28
+ * {@link SessionTasks.taskEnded}).
21
29
  * - The parent is not shown the Agent call of an announced child: the call's
22
30
  * prompt is the parent's outgoing `session_message` and the child's
23
31
  * incoming one, and a foreground child's answer is its reply to the parent.
@@ -48,7 +56,7 @@ import * as path from "node:path";
48
56
  import { RequestError } from "@agentclientprotocol/sdk/unstable";
49
57
  import { backgroundBashTaskFromToolResult, taskProgressFields } from "../async-tasks.js";
50
58
  import { BackgroundOutputTail, foregroundCommandToolCall, isCommandTool, TaskOutputPoll, } from "../background-output.js";
51
- import { childModelOption, HANDBACK_TOOL, handbackMessage, isNativeSubagentControlTool, launchReply, linkedSessionMessages, mergeSubagentIdentity, responseModelEntry, resumedNativeSubagentId, rfdLabels, sendMessageResume, subagentIdentity, targetAgentId, unexposedControlFallback, withSessionReference, } from "../native-subagents.js";
59
+ import { childModelOption, endsMessageWait, endWaitsForMessages, HANDBACK_TOOL, handbackMessage, isNativeSubagentControlTool, launchReply, linkedSessionMessages, mergeSubagentIdentity, responseModelEntry, resumedNativeSubagentId, rfdLabels, sendMessageResume, subagentIdentity, targetAgentId, unexposedControlFallback, withSessionReference, } from "../native-subagents.js";
52
60
  import { subagentLineage } from "../subagent-history.js";
53
61
  import { streamedTerminals, withRunningTerminal, withRunningToolCall, withStreamedTerminal, } from "../tool-calls/background.js";
54
62
  import { ClientCapabilities } from "../tool-calls/client-capabilities.js";
@@ -56,6 +64,7 @@ import { AcpToolCallRenderer } from "../tool-calls/renderer.js";
56
64
  import { workflowCard, workflowSnapshot } from "../workflow-progress.js";
57
65
  import { ChildConfigurations } from "./child-config.js";
58
66
  import { SessionOutput } from "./stream.js";
67
+ import { REPLAY_COMPLETE } from "./setup.js";
59
68
  import { SubagentReplay } from "./subagent-replay.js";
60
69
  /** The tools whose structured result names the task that the call started. */
61
70
  const TASK_TOOLS = new Set(["Monitor", "Workflow"]);
@@ -78,6 +87,11 @@ export class SessionTasks {
78
87
  pendingByLaunch = new Map();
79
88
  /** The live subagent tasks, by agent id, announced or not. */
80
89
  agents = new Map();
90
+ /**
91
+ * The ends of the runs that wait for their messages (see {@link taskEnded}),
92
+ * by agent id.
93
+ */
94
+ heldEnds = new Map();
81
95
  /** The open permission requests of each subagent, by agent id. */
82
96
  agentRequests = new Map();
83
97
  /** The subagents whose runs a cancel stops, by agent id, until their runs end. */
@@ -164,6 +178,7 @@ export class SessionTasks {
164
178
  * was a child's, which then goes to the child's stream only.
165
179
  */
166
180
  handle(message) {
181
+ this.releaseHeldEnds(message);
167
182
  switch (message.type) {
168
183
  case "system":
169
184
  switch (message.subtype) {
@@ -323,7 +338,12 @@ export class SessionTasks {
323
338
  hasLiveSubagents() {
324
339
  return this.agents.size > 0;
325
340
  }
326
- /** Whether `sessionId` is an announced child session of this root. */
341
+ /**
342
+ * Whether `sessionId` is a child session that this root announced in its
343
+ * current conversation. A child that only a replay announced, or one from
344
+ * before a conversation reset, is not: the client still knows those (see
345
+ * `AnnouncedChildren`).
346
+ */
327
347
  hasChild(sessionId) {
328
348
  return this.children.get(sessionId)?.announced === true;
329
349
  }
@@ -536,6 +556,38 @@ export class SessionTasks {
536
556
  }
537
557
  return true;
538
558
  }
559
+ /**
560
+ * For a resume of the active session that replays: the announcement and
561
+ * the `replay_complete` of each current child that the replay did not
562
+ * announce (`replayed`), parents first. The stored history has no launch of
563
+ * such a child: a forked skill's, whose metadata names no call, or a
564
+ * subagent that Claude launched after the history was written. Its replay
565
+ * is empty, so its `replay_complete` follows its announcement at once.
566
+ *
567
+ * A child is current when it works, when its parent lists it, or when the
568
+ * replay holds something its session sent (`held`), such as the end of a
569
+ * run that ended while the history was read. v2 asks for a child's
570
+ * announcement again on every resume, before any other update of its
571
+ * session, and for a `replay_complete` on every child that is announced
572
+ * before the response. The caller sends these after the root's
573
+ * `replay_complete`, where an announcement is current, and before what the
574
+ * replay held.
575
+ */
576
+ unreplayedChildren(replayed, held) {
577
+ const lists = this.lists();
578
+ return this.parentsFirst()
579
+ .filter((child) => !replayed(child.sessionId) &&
580
+ (held.has(child.sessionId) || this.worksOrListed(child, lists)))
581
+ .flatMap((child) => [
582
+ { sessionId: child.parentSessionId, update: this.announcement(child) },
583
+ { sessionId: child.sessionId, update: REPLAY_COMPLETE },
584
+ ]);
585
+ }
586
+ /** Whether `child` works, or its parent's `background` list (of `lists`) names it. */
587
+ worksOrListed(child, lists) {
588
+ return (child.working ||
589
+ (lists.get(child.parentSessionId) ?? []).some((item) => item.type === "subagent" && item.sessionId === child.sessionId));
590
+ }
539
591
  /**
540
592
  * The current state of the session's work, for a resume of the active
541
593
  * session: each subagent that a session lists, or that works in its
@@ -550,9 +602,7 @@ export class SessionTasks {
550
602
  const lists = this.lists();
551
603
  const visit = (sessionId) => {
552
604
  const listed = lists.get(sessionId) ?? [];
553
- const children = this.parentsFirst().filter((child) => child.parentSessionId === sessionId &&
554
- (child.working ||
555
- listed.some((item) => item.type === "subagent" && item.sessionId === child.sessionId)));
605
+ const children = this.parentsFirst().filter((child) => child.parentSessionId === sessionId && this.worksOrListed(child, lists));
556
606
  for (const child of children) {
557
607
  const state = stateObject(this.childState(child), undefined);
558
608
  if ((lists.get(child.sessionId) ?? []).length === 0) {
@@ -604,6 +654,14 @@ export class SessionTasks {
604
654
  .filter((toolCall) => toolCall.output.sessionId === sessionId)
605
655
  .map((toolCall) => toolCall.toolCallId));
606
656
  }
657
+ /**
658
+ * The root's turn ends: a run whose end still waited for its messages ends
659
+ * before the root's idle, since the turn waited on it. Such a turn ended
660
+ * without a result, as one that a cancel stopped can.
661
+ */
662
+ turnClosed() {
663
+ this.releaseHeldEnds();
664
+ }
607
665
  /**
608
666
  * Claude Code's query ended: its tasks ended with its process. Terminals
609
667
  * exit and background tool calls are cancelled; a child that worked ends
@@ -611,6 +669,7 @@ export class SessionTasks {
611
669
  */
612
670
  queryEnded(error) {
613
671
  this.stopForeground();
672
+ this.releaseHeldEnds();
614
673
  for (const [taskId, terminal] of this.terminals) {
615
674
  terminal.tail?.stop();
616
675
  if (error)
@@ -641,6 +700,7 @@ export class SessionTasks {
641
700
  * its state.
642
701
  */
643
702
  conversationReset() {
703
+ this.releaseHeldEnds();
644
704
  for (const child of [...this.parentsFirst()].reverse()) {
645
705
  if (!child.working)
646
706
  continue;
@@ -742,10 +802,12 @@ export class SessionTasks {
742
802
  if (toolUseId !== undefined) {
743
803
  this.pendingByLaunch.delete(toolUseId);
744
804
  this.childByToolUse.set(toolUseId, child);
745
- // The launch call names the parent. Without one, it is the parent task.
746
- const launch = this.launches.get(toolUseId);
747
- if (launch)
748
- this.announce(child, launch.output.sessionId);
805
+ // The call that launched it names the parent: an Agent or Task call,
806
+ // else a call that a session's stream mapped, such as the Skill call
807
+ // of a forked skill. Without a call, it is the parent task.
808
+ const parent = this.launches.get(toolUseId)?.output.sessionId ?? this.callerOf(toolUseId);
809
+ if (parent !== undefined)
810
+ this.announce(child, parent);
749
811
  }
750
812
  else {
751
813
  // No session update may carry a session id before its announcement.
@@ -846,13 +908,14 @@ export class SessionTasks {
846
908
  */
847
909
  taskEnded(taskId, status, error) {
848
910
  const child = this.children.get(taskId);
911
+ const foreground = this.agents.get(taskId)?.background === false;
849
912
  if (this.agents.delete(taskId))
850
913
  this.host.foregroundRequestsChanged();
851
914
  if (child && !child.announced) {
852
915
  this.withdrawChild(child);
853
916
  }
854
917
  else if (child) {
855
- this.endRun(child, status === "completed"
918
+ const outcome = status === "completed"
856
919
  ? { stopReason: "end_turn" }
857
920
  : status === "stopped"
858
921
  ? { stopReason: "cancelled" }
@@ -861,7 +924,26 @@ export class SessionTasks {
861
924
  ...(error
862
925
  ? { error: { code: RequestError.internalError().code, message: error } }
863
926
  : {}),
864
- });
927
+ };
928
+ const held = this.heldEnds.get(taskId);
929
+ if (held) {
930
+ // A second report of an end that waits can give the text of its failure.
931
+ if (held.stopReason === "error" &&
932
+ !held.error &&
933
+ outcome.stopReason === "error" &&
934
+ outcome.error) {
935
+ this.heldEnds.set(taskId, outcome);
936
+ }
937
+ }
938
+ else if (child.working &&
939
+ endWaitsForMessages({ launched: child.launchToolUseId !== undefined, foreground })) {
940
+ // The run of a child whose messages Claude Code holds until after
941
+ // its end ends once they came (see `releaseHeldEnds`).
942
+ this.heldEnds.set(taskId, outcome);
943
+ }
944
+ else {
945
+ this.endRun(child, outcome);
946
+ }
865
947
  }
866
948
  // A foreground command's output is read no more: a tool call that gets no
867
949
  // result, such as one of a reply that Claude Code took back, would
@@ -912,6 +994,7 @@ export class SessionTasks {
912
994
  // --- Children ---------------------------------------------------------------------
913
995
  /** A new child, not announced, which runs; the messages of its launch that came wait for it. */
914
996
  newChild(sessionId, launchToolUseId, task) {
997
+ const pending = launchToolUseId !== undefined ? (this.pendingByLaunch.get(launchToolUseId) ?? []) : [];
915
998
  const child = {
916
999
  sessionId,
917
1000
  parentSessionId: this.host.sessionId,
@@ -919,7 +1002,8 @@ export class SessionTasks {
919
1002
  task,
920
1003
  announced: false,
921
1004
  awaitedParent: undefined,
922
- pending: launchToolUseId !== undefined ? (this.pendingByLaunch.get(launchToolUseId) ?? []) : [],
1005
+ pending,
1006
+ heard: pending.length > 0,
923
1007
  title: undefined,
924
1008
  description: undefined,
925
1009
  working: true,
@@ -992,16 +1076,53 @@ export class SessionTasks {
992
1076
  this.startRun(child, prompt, toolUseId);
993
1077
  this.host.foregroundRequestsChanged();
994
1078
  }
1079
+ /** The session whose stream mapped the tool call `toolCallId`, if one did. */
1080
+ callerOf(toolCallId) {
1081
+ if (this.rootOutput.holds(toolCallId))
1082
+ return this.host.sessionId;
1083
+ for (const child of this.children.values()) {
1084
+ if (child.output?.holds(toolCallId))
1085
+ return child.sessionId;
1086
+ }
1087
+ return undefined;
1088
+ }
1089
+ /**
1090
+ * Ends the runs whose ends waited for their messages (see {@link taskEnded}),
1091
+ * when `message` ends their wait (see `endsMessageWait`). Without a
1092
+ * message, all of them: the root's turn or the query ended, or the
1093
+ * conversation was reset.
1094
+ */
1095
+ releaseHeldEnds(message) {
1096
+ if (this.heldEnds.size === 0)
1097
+ return;
1098
+ for (const [agentId, outcome] of [...this.heldEnds]) {
1099
+ const child = this.children.get(agentId);
1100
+ if (!endsMessageWait(message, child?.heard === true))
1101
+ continue;
1102
+ this.heldEnds.delete(agentId);
1103
+ if (child)
1104
+ this.endRun(child, outcome);
1105
+ this.publish();
1106
+ }
1107
+ }
995
1108
  /**
996
1109
  * A message of a subagent, by its `parent_tool_use_id`: it goes to the
997
- * child's stream, or waits for the child's announcement. A message of an
998
- * agent that no known call launched is the root's.
1110
+ * child's stream, or waits for the child's announcement. One whose
1111
+ * `parent_tool_use_id` is no Agent or Task call goes by its `agent_id`: a
1112
+ * forked skill that the user typed sends `forked-command-<skill>` for every
1113
+ * run of the skill. A message of an agent that neither names is the root's.
999
1114
  */
1000
1115
  childMessage(message) {
1001
1116
  const launchId = message.parent_tool_use_id;
1002
1117
  if (launchId === null)
1003
1118
  return false;
1004
- const child = this.childByToolUse.get(launchId);
1119
+ const agentId = message.agent_id;
1120
+ const child = this.childByToolUse.get(launchId) ??
1121
+ (typeof agentId === "string" && !this.launches.has(launchId)
1122
+ ? this.children.get(agentId)
1123
+ : undefined);
1124
+ if (child)
1125
+ child.heard = true;
1005
1126
  if (child?.announced) {
1006
1127
  this.deliver(child, message);
1007
1128
  return true;
@@ -1068,8 +1189,13 @@ export class SessionTasks {
1068
1189
  update: { sessionUpdate: "state_update", ...state },
1069
1190
  });
1070
1191
  const prompt = child.task.prompt ?? identity?.prompt;
1071
- if (prompt)
1072
- this.sendPrompt(child, prompt, child.launchToolUseId, parentSessionId, true);
1192
+ // The prompt replaces an Agent or Task call in the parent's transcript.
1193
+ // Another call that launched the child, such as a Skill call, stays
1194
+ // shown there, so the prompt is the child's incoming message only.
1195
+ const replacesCall = child.launchToolUseId !== undefined && this.launches.has(child.launchToolUseId);
1196
+ if (prompt) {
1197
+ this.sendPrompt(child, prompt, child.launchToolUseId, parentSessionId, replacesCall);
1198
+ }
1073
1199
  // What its hooks reported before, after the prompt.
1074
1200
  this.publishConfiguration(child, undefined);
1075
1201
  const pending = child.pending;
@@ -1149,9 +1275,11 @@ export class SessionTasks {
1149
1275
  /**
1150
1276
  * `notification`, an update that the client is shown on the session
1151
1277
  * `shownOn`, with a `session` reference when it is of a TaskStop or
1152
- * SendMessage call that names an announced child by its agent id, or of a
1278
+ * SendMessage call that names an announced child by its agent id, of a
1153
1279
  * SendMessage call that resumed one and stays shown (see
1154
- * {@link requestShows}), as on v1 (`NativeSubagentRuntime.withTarget`).
1280
+ * {@link requestShows}), or of the call that launched one and is no Agent
1281
+ * or Task call, such as the Skill call of a forked skill, as on v1
1282
+ * (`NativeSubagentRuntime.withTarget`).
1155
1283
  */
1156
1284
  withTarget(notification, shownOn) {
1157
1285
  const { update } = notification;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../src/v2/tool-call.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAmB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAE7E,KAAK,gBAAgB,GACjB,CAAC,QAAQ,GAAG;IAAE,aAAa,EAAE,WAAW,CAAA;CAAE,CAAC,GAC3C,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC;AAE7D,KAAK,gBAAgB,GAAG,EAAE,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAElF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAE3E;AAcD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAM9E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,EAAE,CAAC,cAAc,CAUtF"}
1
+ {"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../src/v2/tool-call.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAmB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAE7E,KAAK,gBAAgB,GACjB,CAAC,QAAQ,GAAG;IAAE,aAAa,EAAE,WAAW,CAAA;CAAE,CAAC,GAC3C,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC;AAE7D,KAAK,gBAAgB,GAAG,EAAE,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAElF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAE3E;AAcD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAM9E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,EAAE,CAAC,cAAc,CAYtF"}
@@ -51,9 +51,31 @@ export function v2ToolCallPatch(toolCall) {
51
51
  const patch = Object.fromEntries(Object.entries(toolCall).filter(([key, value]) => value !== null && key !== "sessionUpdate" && key !== "content"));
52
52
  return {
53
53
  ...patch,
54
- ...(toolCall.content != null ? { content: toolCall.content.map(v2ToolCallContent) } : {}),
54
+ ...(toolCall.content != null
55
+ ? { content: separateParagraphs(toolCall.content).map(v2ToolCallContent) }
56
+ : {}),
55
57
  };
56
58
  }
59
+ /**
60
+ * v2 reads adjacent text items as one continuous text, which a client joins
61
+ * without a separator. The agent's text items are separate paragraphs, such
62
+ * as one per question of an AskUserQuestion or one per block of a tool
63
+ * result, so each one that another text item follows ends with a blank line.
64
+ * Without it, two fenced error blocks would join into "```\nA\n``````\nB\n```".
65
+ */
66
+ function separateParagraphs(content) {
67
+ return content.map((item, index) => {
68
+ const next = content[index + 1];
69
+ if (!isText(item) || !next || !isText(next))
70
+ return item;
71
+ const { text } = item.content;
72
+ const separator = text.endsWith("\n\n") ? "" : text.endsWith("\n") ? "\n" : "\n\n";
73
+ return { ...item, content: { ...item.content, text: text + separator } };
74
+ });
75
+ }
76
+ function isText(item) {
77
+ return item.type === "content" && item.content.type === "text";
78
+ }
57
79
  function v2ToolCallContent(item) {
58
80
  switch (item.type) {
59
81
  case "content":
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.109.1-preview.1",
6
+ "version": "0.109.1-preview.10",
7
7
  "description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",
@@ -68,13 +68,13 @@
68
68
  "node": ">=22"
69
69
  },
70
70
  "dependencies": {
71
- "@agentclientprotocol/sdk": "2.8.0",
72
- "@anthropic-ai/claude-agent-sdk": "0.3.328",
71
+ "@agentclientprotocol/sdk": "2.9.1",
72
+ "@anthropic-ai/claude-agent-sdk": "0.3.330",
73
73
  "diff": "9.0.0",
74
74
  "zod": "4.6.7"
75
75
  },
76
76
  "devDependencies": {
77
- "@anthropic-ai/sdk": "1.10.0",
77
+ "@anthropic-ai/sdk": "1.12.0",
78
78
  "@eslint/js": "10.0.1",
79
79
  "@tsconfig/node22": "22.0.7",
80
80
  "@types/node": "26.6.6",