@lucascouts/claude-agent-tui 0.16.5 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,6 +26,7 @@ This project bridges the two: it drives the **official Claude Code TUI** over a
26
26
 
27
27
  - The **`claude` CLI** (Claude Code subscription) available on your `PATH`.
28
28
  - **Node.js ≥ 24** — the runtime and test suite use native TypeScript type-stripping (`node --experimental-strip-types`). Raising this floor from the previous `>=20` is a **breaking change** for consumers still on Node 20–23.
29
+ - **SDK lines** — the ACP TypeScript SDK 2.x (`@agentclientprotocol/sdk` 2.4.0, its `/unstable` entry; ACP protocol v1 on the wire) and `@anthropic-ai/claude-agent-sdk` 0.3.318. This fork drives the `claude` CLI installed on the host, not the one the SDK bundles.
29
30
 
30
31
  > **Why 24, and not upstream's `>=22`?** The floor is a support policy, not a measured minimum: this project targets the **active LTS** line, which is Node 24. It is verified rather than copied — a fresh clone with no host `node_modules` or `dist/`, then `npm ci` → `npm run build` → `npm test`, inside `node:24` pinned by digest `sha256:934240a162082fd8b8a2f90cd5114446443f1eba1c5378f6687167ca405e6584` (Node v24.19.0). Green in both the fork and mirror trees: 1222 tests in the fork, 1183 here, 0 failures.
31
32
  >
@@ -1,4 +1,4 @@
1
- import { Agent, AgentSideConnection, AuthenticateRequest, CancelNotification, ClientCapabilities, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, ResumeSessionRequest, ResumeSessionResponse, SessionConfigOption, SessionModeState, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, CloseSessionResponse, DeleteSessionRequest, DeleteSessionResponse, LogoutRequest, LogoutResponse, TerminalHandle, TerminalOutputResponse, WriteTextFileRequest, WriteTextFileResponse, AvailableCommand } from "@agentclientprotocol/sdk";
1
+ import { type AgentContext, AuthenticateRequest, CancelNotification, ClientCapabilities, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, ResumeSessionRequest, ResumeSessionResponse, SessionConfigOption, SessionModeState, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, CloseSessionResponse, DeleteSessionRequest, DeleteSessionResponse, LogoutRequest, LogoutResponse, TerminalHandle, TerminalOutputResponse, WriteTextFileRequest, WriteTextFileResponse, AvailableCommand, CreateElicitationRequest, CreateElicitationResponse, RequestPermissionRequest, RequestPermissionResponse } from "@agentclientprotocol/sdk/unstable";
2
2
  import { ModelInfo, Options, PermissionMode, PermissionUpdate, SDKMessageOrigin, SDKPartialAssistantMessage, Settings } from "@anthropic-ai/claude-agent-sdk";
3
3
  import { ContentBlockParam } from "@anthropic-ai/sdk/resources";
4
4
  import { BetaContentBlock, BetaRawContentBlockDelta } from "@anthropic-ai/sdk/resources/beta.mjs";
@@ -695,11 +695,36 @@ export declare function resolvePermissionMode(defaultMode?: unknown, logger?: Lo
695
695
  * tool so "Always Allow" is never a blank check without disclosure.
696
696
  */
697
697
  export declare function describeAlwaysAllow(suggestions: PermissionUpdate[] | undefined, toolName: string): string;
698
- export declare class ClaudeAcpAgent implements Agent {
698
+ /**
699
+ * The client surface the agent calls back into — the five methods this fork uses, named as ACP
700
+ * 1.x's `AgentSideConnection` named them, so every caller (the permission relay, the elicitation
701
+ * bridge, the notification writers) is unchanged. ACP SDK 2.x removed that class (story 071);
702
+ * {@link ClientConnection} backs this interface with the connection's peer context instead, the
703
+ * same shape the plus adapter took in upstream #790.
704
+ */
705
+ export interface AcpClient {
706
+ sessionUpdate(params: SessionNotification): Promise<void>;
707
+ requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse>;
708
+ readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>;
709
+ writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>;
710
+ createElicitation(params: CreateElicitationRequest): Promise<CreateElicitationResponse>;
711
+ }
712
+ /** {@link AcpClient} over the connection-scoped peer context `connect(...)` returns as `.client`;
713
+ * each method sends exactly the request or notification ACP 1.x's class sent. */
714
+ export declare class ClientConnection implements AcpClient {
715
+ private readonly ctx;
716
+ constructor(ctx: AgentContext);
717
+ sessionUpdate(params: SessionNotification): Promise<void>;
718
+ requestPermission(params: RequestPermissionRequest): Promise<RequestPermissionResponse>;
719
+ readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>;
720
+ writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>;
721
+ createElicitation(params: CreateElicitationRequest): Promise<CreateElicitationResponse>;
722
+ }
723
+ export declare class ClaudeAcpAgent {
699
724
  sessions: {
700
725
  [key: string]: Session;
701
726
  };
702
- client: AgentSideConnection;
727
+ client: AcpClient;
703
728
  toolUseCache: ToolUseCache;
704
729
  backgroundTerminals: {
705
730
  [key: string]: BackgroundTerminal;
@@ -752,7 +777,7 @@ export declare class ClaudeAcpAgent implements Agent {
752
777
  private readonly modelCatalogSource;
753
778
  /** Live PTY-engine registry shared with the per-session engines (story 014 cleanup map). */
754
779
  private readonly engines;
755
- constructor(client: AgentSideConnection, logger?: Logger, engine?: Engine, deps?: AgentDeps);
780
+ constructor(client: AcpClient, logger?: Logger, engine?: Engine, deps?: AgentDeps);
756
781
  initialize(request: InitializeRequest): Promise<InitializeResponse>;
757
782
  newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
758
783
  unstable_forkSession(params: ForkSessionRequest): Promise<ForkSessionResponse>;
@@ -1110,7 +1135,7 @@ export declare function promptToClaude(prompt: PromptRequest, logger?: Logger, m
1110
1135
  * Convert an SDKAssistantMessage (Claude) to a SessionNotification (ACP).
1111
1136
  * Only handles text, image, and thinking chunks for now.
1112
1137
  */
1113
- export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger, options?: {
1138
+ export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AcpClient, logger: Logger, options?: {
1114
1139
  registerHooks?: boolean;
1115
1140
  clientCapabilities?: ClientCapabilities;
1116
1141
  parentToolUseId?: string | null;
@@ -1122,13 +1147,13 @@ export declare function toAcpNotifications(content: string | ContentBlockParam[]
1122
1147
  held?: Set<string>;
1123
1148
  };
1124
1149
  }): SessionNotification[];
1125
- export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AgentSideConnection, logger: Logger, options?: {
1150
+ export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AcpClient, logger: Logger, options?: {
1126
1151
  clientCapabilities?: ClientCapabilities;
1127
1152
  cwd?: string;
1128
1153
  taskState?: TaskState;
1129
1154
  }): SessionNotification[];
1130
1155
  export declare function runAcp(deps?: AgentDeps): {
1131
- connection: AgentSideConnection;
1156
+ connection: import("@agentclientprotocol/sdk/unstable").AgentConnection;
1132
1157
  agent: ClaudeAcpAgent;
1133
1158
  };
1134
1159
  /** Resolve a model alias's context window (the usage_update `size` denominator).
package/dist/acp-agent.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AgentSideConnection, ndJsonStream, RequestError, } from "@agentclientprotocol/sdk";
1
+ import { agent as acpAgent, ndJsonStream, RequestError, methods, } from "@agentclientprotocol/sdk/unstable";
2
2
  import { deleteSession, getSessionInfo, listSessions, } from "@anthropic-ai/claude-agent-sdk";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { existsSync } from "node:fs";
@@ -773,6 +773,28 @@ function deriveSubagentLabel(messages, parentId) {
773
773
  }
774
774
  return undefined;
775
775
  }
776
+ /** {@link AcpClient} over the connection-scoped peer context `connect(...)` returns as `.client`;
777
+ * each method sends exactly the request or notification ACP 1.x's class sent. */
778
+ export class ClientConnection {
779
+ constructor(ctx) {
780
+ this.ctx = ctx;
781
+ }
782
+ sessionUpdate(params) {
783
+ return this.ctx.notify(methods.client.session.update, params);
784
+ }
785
+ requestPermission(params) {
786
+ return this.ctx.request(methods.client.session.requestPermission, params);
787
+ }
788
+ readTextFile(params) {
789
+ return this.ctx.request(methods.client.fs.readTextFile, params);
790
+ }
791
+ writeTextFile(params) {
792
+ return this.ctx.request(methods.client.fs.writeTextFile, params);
793
+ }
794
+ createElicitation(params) {
795
+ return this.ctx.request(methods.client.elicitation.create, params);
796
+ }
797
+ }
776
798
  export class ClaudeAcpAgent {
777
799
  constructor(client, logger, engine = createStubEngine(), deps = {}) {
778
800
  this.backgroundTerminals = {};
@@ -3748,13 +3770,31 @@ export function runAcp(deps) {
3748
3770
  const input = nodeToWebWritable(process.stdout);
3749
3771
  const output = nodeToWebReadable(process.stdin);
3750
3772
  const stream = ndJsonStream(input, output);
3773
+ // ACP SDK 2.x removed `AgentSideConnection` (story 071). The handlers are the ones ACP 1.8.0's
3774
+ // own legacy adapter (`legacyAgentApp`, dist/acp.js) registered for this class — same methods,
3775
+ // same `?? {}` for the calls that may return nothing — so the wire is unchanged. They close over
3776
+ // `agent`, assigned right after `connect()` returns, before any inbound message is processed.
3777
+ // eslint-disable-next-line prefer-const
3751
3778
  let agent;
3752
- const connection = new AgentSideConnection((client) => {
3753
- // Positions 2-3 (logger/engine) default; `deps` carries the bootstrap-resolved flags
3754
- // (story 038: usageUpdate from process.env.USAGE_UPDATE, default OFF).
3755
- agent = new ClaudeAcpAgent(client, undefined, undefined, deps);
3756
- return agent;
3757
- }, stream);
3779
+ const connection = acpAgent()
3780
+ .onRequest(methods.agent.initialize, (ctx) => agent.initialize(ctx.params))
3781
+ .onRequest(methods.agent.session.new, (ctx) => agent.newSession(ctx.params))
3782
+ .onRequest(methods.agent.authenticate, async (ctx) => (await agent.authenticate(ctx.params)) ?? {})
3783
+ .onRequest(methods.agent.session.prompt, (ctx) => agent.prompt(ctx.params))
3784
+ .onNotification(methods.agent.session.cancel, (ctx) => agent.cancel(ctx.params))
3785
+ .onRequest(methods.agent.session.load, (ctx) => agent.loadSession(ctx.params))
3786
+ .onRequest(methods.agent.session.list, (ctx) => agent.listSessions(ctx.params))
3787
+ .onRequest(methods.agent.session.delete, async (ctx) => (await agent.deleteSession(ctx.params)) ?? {})
3788
+ .onRequest(methods.agent.session.fork, (ctx) => agent.unstable_forkSession(ctx.params))
3789
+ .onRequest(methods.agent.session.resume, (ctx) => agent.resumeSession(ctx.params))
3790
+ .onRequest(methods.agent.session.close, async (ctx) => (await agent.closeSession(ctx.params)) ?? {})
3791
+ .onRequest(methods.agent.session.setMode, async (ctx) => (await agent.setSessionMode(ctx.params)) ?? {})
3792
+ .onRequest(methods.agent.session.setConfigOption, (ctx) => agent.setSessionConfigOption(ctx.params))
3793
+ .onRequest(methods.agent.logout, async (ctx) => (await agent.logout(ctx.params)) ?? {})
3794
+ .connect(stream);
3795
+ // Positions 2-3 (logger/engine) default; `deps` carries the bootstrap-resolved flags
3796
+ // (story 038: usageUpdate from process.env.USAGE_UPDATE, default OFF).
3797
+ agent = new ClaudeAcpAgent(new ClientConnection(connection.client), undefined, undefined, deps);
3758
3798
  return { connection, agent };
3759
3799
  }
3760
3800
  /** Resolve a model alias's context window (the usage_update `size` denominator).
@@ -1,7 +1,7 @@
1
- import { type AgentSideConnection, type SessionNotification } from "@agentclientprotocol/sdk";
1
+ import { type SessionNotification } from "@agentclientprotocol/sdk/unstable";
2
2
  import { type ContentBlockParam } from "@anthropic-ai/sdk/resources";
3
3
  import { BetaContentBlock, BetaRawContentBlockDelta } from "@anthropic-ai/sdk/resources/beta.mjs";
4
- import { toAcpNotifications, type Logger, type ToolUseCache } from "./acp-agent.js";
4
+ import { toAcpNotifications, type AcpClient, type Logger, type ToolUseCache } from "./acp-agent.js";
5
5
  /**
6
6
  * Per-surface enable flags for the convenience translation. Each surface is gated independently so
7
7
  * the orchestrator can, e.g., keep `plan` while suppressing `image` (or disable both entirely).
@@ -37,7 +37,7 @@ type TranslateFn = typeof toAcpNotifications;
37
37
  * Signature mirrors `toAcpNotifications`'s real parameter list/types (acp-agent.ts:2866), with the
38
38
  * required `flags` and the optional `opts.translate` test seam appended.
39
39
  */
40
- export declare function translateBestEffort(content: string | ContentBlock[], role: "assistant" | "user", sessionId: string, cache: ToolUseCache, client: AgentSideConnection, logger: Logger, flags: ConvenienceFlags, opts?: {
40
+ export declare function translateBestEffort(content: string | ContentBlock[], role: "assistant" | "user", sessionId: string, cache: ToolUseCache, client: AcpClient, logger: Logger, flags: ConvenienceFlags, opts?: {
41
41
  translate?: TranslateFn;
42
42
  }): SessionNotification[];
43
43
  export {};
@@ -1,4 +1,4 @@
1
- import type { AvailableCommand } from "@agentclientprotocol/sdk";
1
+ import type { AvailableCommand } from "@agentclientprotocol/sdk/unstable";
2
2
  /**
3
3
  * The curated built-in slash-command tier (R9) — the interactive `claude` TUI's own built-ins, which are
4
4
  * baked into the binary and therefore NOT disk-discoverable. This is a CURATED APPROXIMATION (C1), NOT a
@@ -1,4 +1,4 @@
1
- import type { ToolCallContent } from "@agentclientprotocol/sdk";
1
+ import type { ToolCallContent } from "@agentclientprotocol/sdk/unstable";
2
2
  /** A single diff hunk — the unit the reused `toolUpdateFromDiffToolResponse` reads `lines` from. */
3
3
  export interface Hunk {
4
4
  readonly oldStart: number;
@@ -1,4 +1,4 @@
1
- import type { PromptResponse } from "@agentclientprotocol/sdk";
1
+ import type { PromptResponse } from "@agentclientprotocol/sdk/unstable";
2
2
  import { TURN_WATCHDOG_MS } from "./linearize.js";
3
3
  import { FILE_DISCOVERY_WATCHDOG_MS } from "./jsonl.js";
4
4
  import { type StopReasonLogger } from "./stop-reason-map.js";
@@ -1,4 +1,4 @@
1
- import type { McpServer } from "@agentclientprotocol/sdk";
1
+ import type { McpServer } from "@agentclientprotocol/sdk/unstable";
2
2
  /**
3
3
  * A single entry under claude's `--mcp-config` `mcpServers` map. A discriminated union over the
4
4
  * transport claude understands:
@@ -1,5 +1,5 @@
1
1
  import type { ModelInfo } from "@anthropic-ai/claude-agent-sdk";
2
- import type { ClientCapabilities, SessionConfigOption } from "@agentclientprotocol/sdk";
2
+ import type { ClientCapabilities, SessionConfigOption } from "@agentclientprotocol/sdk/unstable";
3
3
  /**
4
4
  * Effort levels offered for reasoning-capable models — the SDK's `supportedEffortLevels` vocabulary.
5
5
  * Exactly the real `--effort` enum. Ultracode is NOT a level (item 84): it is its own switch, see
@@ -1,4 +1,4 @@
1
- import type { CreateElicitationRequest, CreateElicitationResponse } from "@agentclientprotocol/sdk";
1
+ import type { CreateElicitationRequest, CreateElicitationResponse } from "@agentclientprotocol/sdk/unstable";
2
2
  /**
3
3
  * The gate decision this bridge yields. Mirrors hook-server's `DenyWithReason`: AskUserQuestion is
4
4
  * ALWAYS denied at the wire, and the user's selection (or the dismissal note) is carried in `reason`.
@@ -1,4 +1,4 @@
1
- import type { StopReason } from "@agentclientprotocol/sdk";
1
+ import type { StopReason } from "@agentclientprotocol/sdk/unstable";
2
2
  /** Telemetry sink for an unmapped stop_reason (drift). Structural — the acp-agent logger satisfies it. */
3
3
  export interface StopReasonLogger {
4
4
  error: (...args: unknown[]) => void;
package/dist/tools.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PlanEntry, ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
1
+ import { PlanEntry, ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk/unstable";
2
2
  import { HookCallback } from "@anthropic-ai/claude-agent-sdk";
3
3
  import { TaskCreateInput, TaskCreateOutput, TaskListOutput, TaskUpdateInput, TaskUpdateOutput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
4
4
  import { ToolResultBlockParam, WebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources";
package/dist/usage.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SessionUpdate } from "@agentclientprotocol/sdk";
1
+ import type { SessionUpdate } from "@agentclientprotocol/sdk/unstable";
2
2
  /** The UNSTABLE `usage_update` variant of the SDK 0.22.1 SessionUpdate union. */
3
3
  export type UsageUpdateNotification = Extract<SessionUpdate, {
4
4
  sessionUpdate: "usage_update";
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.16.5",
6
+ "version": "0.17.0",
7
7
  "description": "Runs the official Claude Code TUI over a PTY and exposes it via ACP, so Claude Code threads render natively in Zed's agent panel. Built for Anthropic's June 2026 billing split (since paused).",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",
@@ -64,13 +64,13 @@
64
64
  "node": ">=24"
65
65
  },
66
66
  "dependencies": {
67
- "@agentclientprotocol/sdk": "1.8.0",
68
- "@anthropic-ai/claude-agent-sdk": "0.3.296",
67
+ "@agentclientprotocol/sdk": "2.4.0",
68
+ "@anthropic-ai/claude-agent-sdk": "0.3.318",
69
69
  "node-pty": "1.1.0",
70
70
  "zod": "^4.0.0"
71
71
  },
72
72
  "devDependencies": {
73
- "@anthropic-ai/sdk": "0.132.1",
73
+ "@anthropic-ai/sdk": "1.4.0",
74
74
  "@eslint/js": "10.0.1",
75
75
  "@types/node": "26.6.5",
76
76
  "@typescript-eslint/eslint-plugin": "8.72.0",