@agentclientprotocol/claude-agent-acp 0.110.0 → 0.110.1-preview.2

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.
@@ -20,7 +20,7 @@ type V1ToolCallReport = (ToolCall & {
20
20
  });
21
21
  /** The terminal updates of the tool call reports of one v2 connection. */
22
22
  export declare class V2Terminals {
23
- /** The terminal and the last reported command of each running command, by session and tool call. */
23
+ /** The display terminal of each running command, by session and tool call. */
24
24
  private readonly running;
25
25
  /**
26
26
  * The terminal updates that a tool call report carries in the extension's
@@ -1 +1 @@
1
- {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/v2/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAClF,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;AAiB7D,0EAA0E;AAC1E,qBAAa,WAAW;IACtB,oGAAoG;IACpG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGpB;IAEJ;;;;;;;;OAQG;IACH,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,GACvB;QAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC;QAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAA;KAAE;IAiDzE;;;;;;OAMG;IACH,eAAe,CACb,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,UAAQ,GACZ,EAAE,CAAC,aAAa,GAAG,SAAS;IAa/B,0CAA0C;IAC1C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAKhC"}
1
+ {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/v2/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAClF,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;AAwB7D,0EAA0E;AAC1E,qBAAa,WAAW;IACtB,8EAA8E;IAC9E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsC;IAE9D;;;;;;;;OAQG;IACH,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,GACvB;QAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC;QAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAA;KAAE;IAiDzE;;;;;;OAMG;IACH,eAAe,CACb,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,UAAQ,GACZ,EAAE,CAAC,aAAa,GAAG,SAAS;IAa/B,0CAA0C;IAC1C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAKhC"}
@@ -6,7 +6,7 @@ const TERMINAL_KEYS = [
6
6
  ];
7
7
  /** The terminal updates of the tool call reports of one v2 connection. */
8
8
  export class V2Terminals {
9
- /** The terminal and the last reported command of each running command, by session and tool call. */
9
+ /** The display terminal of each running command, by session and tool call. */
10
10
  running = new Map();
11
11
  /**
12
12
  * The terminal updates that a tool call report carries in the extension's
@@ -25,7 +25,7 @@ export class V2Terminals {
25
25
  // `cancellable`.
26
26
  if (meta.terminal_info &&
27
27
  this.running.get(key)?.terminalId !== meta.terminal_info.terminal_id) {
28
- this.running.set(key, { terminalId: meta.terminal_info.terminal_id });
28
+ this.running.set(key, { terminalId: meta.terminal_info.terminal_id, endsInCR: false });
29
29
  }
30
30
  const terminal = [];
31
31
  const running = this.running.get(key);
@@ -40,7 +40,7 @@ export class V2Terminals {
40
40
  sessionUpdate: "terminal_update",
41
41
  terminalId: running.terminalId,
42
42
  ...(newCommand ? { command } : {}),
43
- ...(output ? { output: { data: terminalBytes(output.data) } } : {}),
43
+ ...(output ? { output: { data: terminalBytes(output.data, running, "snapshot") } } : {}),
44
44
  ...(exit
45
45
  ? {
46
46
  exitStatus: {
@@ -57,7 +57,7 @@ export class V2Terminals {
57
57
  terminal.push({
58
58
  sessionUpdate: "terminal_output_chunk",
59
59
  terminalId: running.terminalId,
60
- data: terminalBytes(delta.data),
60
+ data: terminalBytes(delta.data, running, "chunk"),
61
61
  });
62
62
  }
63
63
  if (exit)
@@ -115,13 +115,11 @@ function commandOf(rawInput) {
115
115
  const command = rawInput?.command;
116
116
  return typeof command === "string" && command.length > 0 ? command : undefined;
117
117
  }
118
- /**
119
- * The output as the bytes a PTY would have delivered, base64-encoded as a v2
120
- * terminal carries them. A v2 terminal carries the bytes a terminal emulator
121
- * receives, but Claude Code runs a command with its output piped, so no line
122
- * discipline turned each LF into CR LF (`ONLCR`). Without the CR, an emulator
123
- * moves down a row and keeps the column: "a\nb" draws "b" under the end of "a".
124
- */
125
- function terminalBytes(text) {
126
- return Buffer.from(text.replaceAll("\n", "\r\n"), "utf8").toString("base64");
118
+ /** Insert a carriage return before bare LF so the next line starts at column zero. */
119
+ function terminalBytes(text, terminal, kind) {
120
+ const followsCR = kind === "chunk" && terminal.endsInCR;
121
+ const normalized = text.replace(/(?<!\r)\n/g, (lf, offset) => offset === 0 && followsCR ? lf : "\r\n");
122
+ if (kind === "snapshot" || text.length > 0)
123
+ terminal.endsInCR = text.endsWith("\r");
124
+ return Buffer.from(normalized, "utf8").toString("base64");
127
125
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.110.0",
6
+ "version": "0.110.1-preview.2",
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",