Problem
AgentSideConnection uses native JS #private fields, which breaks TypeScript structural typing when multiple copies of the package exist in node_modules.
In monorepos using pnpm, it's common for @agentclientprotocol/sdk to be installed multiple times with different peer dependency versions (e.g., zod@4.2.1 vs zod@4.3.6). Even though the code is identical, TypeScript treats #private fields from different package instances as incompatible:
error TS2345: Argument of type 'AgentSideConnection' is not assignable to parameter of type 'AgentSideConnection'.
Property '#private' in type 'AgentSideConnection' refers to a different member that cannot be accessed from within type 'AgentSideConnection'.
This is a well-known footgun with native #private fields in library code — see TypeScript #48885.
Suggested Fix
Use TypeScript's private keyword instead of native #private fields for classes that are part of the public API (like AgentSideConnection and ClientSideConnection). The private keyword is erased at compile time and doesn't break structural typing across duplicate instances.
Workaround
Consumers can work around this by ensuring a single copy of the package via pnpm overrides or by aligning all peer dependency versions.
Problem
AgentSideConnectionuses native JS#privatefields, which breaks TypeScript structural typing when multiple copies of the package exist innode_modules.In monorepos using pnpm, it's common for
@agentclientprotocol/sdkto be installed multiple times with different peer dependency versions (e.g.,zod@4.2.1vszod@4.3.6). Even though the code is identical, TypeScript treats#privatefields from different package instances as incompatible:This is a well-known footgun with native
#privatefields in library code — see TypeScript #48885.Suggested Fix
Use TypeScript's
privatekeyword instead of native#privatefields for classes that are part of the public API (likeAgentSideConnectionandClientSideConnection). Theprivatekeyword is erased at compile time and doesn't break structural typing across duplicate instances.Workaround
Consumers can work around this by ensuring a single copy of the package via pnpm overrides or by aligning all peer dependency versions.