-
Notifications
You must be signed in to change notification settings - Fork 406
Description
Summary
We need to import PI RPC types in downstream TypeScript, but the RPC types live at a non-exported subpath (dist/modes/rpc/rpc-types.js). This fails under modern TS module resolution because the subpath isn’t in exports.
Environment
- package:
@mariozechner/[email protected] - TypeScript: 5.x
- moduleResolution:
bundler(also affectsnode16/nodenext) - ESM project
Repro
// Type-only import in a consumer project
import type { RpcCommand } from "@mariozechner/pi-coding-agent/dist/modes/rpc/rpc-types.js";Actual
TypeScript error:
TS2307: Cannot find module '@mariozechner/pi-coding-agent/dist/modes/rpc/rpc-types.js' or its corresponding type declarations.
Expected
RPC types should be importable from a public, exported path.
Why it matters
Downstream consumers (agent-runner/orchestrators, SDK wrappers, etc.) need RpcCommand/RpcResponse to send PI-native RPC and validate payloads. Today we have to add local TS path hacks or copy types.
Root cause (moduleResolution + exports)
In TS moduleResolution: bundler / nodenext, package exports is enforced. When exports is present, deep subpaths are blocked unless explicitly listed. Since the RPC types are only in dist/... and not exported, TS can’t resolve them.
Proposed fix (simple)
Expose the RPC types subpath in package.json exports (or re-export from dist/index).
Example:
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./rpc-types": {
"types": "./dist/modes/rpc/rpc-types.d.ts",
"import": "./dist/modes/rpc/rpc-types.js"
}
}Then consumers can do:
import type { RpcCommand, RpcResponse } from "@mariozechner/pi-coding-agent/rpc-types";Alternative (also OK):
- Re-export
RpcCommand/RpcResponse/RpcSessionStatefromdist/index.d.tsso they’re available via the main entrypoint.