fix(sdk): make inferred chat agent types portable for declaration emit#4218
Conversation
Exporting a chat.agent from a project with declaration: true failed with TS2742 because the inferred task payload type lived in the internal ai-shared module, which is not reachable through the package exports map. ChatTaskWirePayload and ChatInputChunk are now declared in the public chat subpath (ai-shared re-exports them type-only, so internal imports and the browser-safety split are unchanged), and a regression test compiles a consumer fixture against the built package and asserts the emitted declaration names only public specifiers.
🦋 Changeset detectedLatest commit: 568d287 The changes in this PR will be included in the next version bump. This PR includes changesets to release 28 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe SDK now declares and exports 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
## Summary 1 improvement, 2 bug fixes. ## Breaking changes - Removed support for the end-of-life v3 `trigger dev` CLI. Starting a dev session with an old v3 CLI now returns an upgrade message instead of connecting - upgrade to the v4 CLI to continue using `trigger dev`. ([#4198](#4198)) ## Bug fixes - Fix TS2742 ("inferred type cannot be named") when exporting a `chat.agent` from a project with declaration emit: `ChatTaskWirePayload` and `ChatInputChunk` are now declared in the public `@trigger.dev/sdk/chat` subpath, so inferred agent types emit portable declarations and the wire types are directly importable. ([#4218](#4218)) ## Server changes These changes affect the self-hosted Docker image and Trigger.dev Cloud: - Reduce primary database load on the runs page by serving its empty-state check from ClickHouse instead of Postgres. ([#4202](#4202)) - Fixed submitting your email on the login page reloading back to an empty form instead of showing the magic link confirmation screen. ([#4215](#4215)) <details> <summary>Raw changeset output</summary> # Releases ## @trigger.dev/build@4.5.3 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.3` ## trigger.dev@4.5.3 ### Patch Changes - Updated dependencies: - `@trigger.dev/build@4.5.3` - `@trigger.dev/core@4.5.3` - `@trigger.dev/schema-to-json@4.5.3` ## @trigger.dev/python@4.5.3 ### Patch Changes - Updated dependencies: - `@trigger.dev/sdk@4.5.3` - `@trigger.dev/build@4.5.3` - `@trigger.dev/core@4.5.3` ## @trigger.dev/react-hooks@4.5.3 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.3` ## @trigger.dev/redis-worker@4.5.3 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.3` ## @trigger.dev/rsc@4.5.3 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.3` ## @trigger.dev/schema-to-json@4.5.3 ### Patch Changes - Updated dependencies: - `@trigger.dev/core@4.5.3` ## @trigger.dev/sdk@4.5.3 ### Patch Changes - Fix TS2742 ("inferred type cannot be named") when exporting a `chat.agent` from a project with declaration emit: `ChatTaskWirePayload` and `ChatInputChunk` are now declared in the public `@trigger.dev/sdk/chat` subpath, so inferred agent types emit portable declarations and the wire types are directly importable. ([#4218](#4218)) - Updated dependencies: - `@trigger.dev/core@4.5.3` ## @trigger.dev/core@4.5.3 </details> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
Exporting a
chat.agentfrom a project withdeclaration: truefailed with TS2742: the inferred type of the agent referencesChatTaskWirePayload, which was declared in an internal module not reachable through the package exports map, so tsc could only name it via a file path intonode_modulesand refused to emit. Consumers had to hand-mirror the wire type and annotate their export.Fix
ChatTaskWirePayloadandChatInputChunkare now declared in@trigger.dev/sdk/chat(a public subpath) and re-exported type-only from the internal shared module, so every internal import is unchanged and the browser/server module split is untouched. Declaration emit for an inferred agent type now produces a portable specifier:As a side effect the wire types are now directly importable, which is what affected users were reconstructing by hand.
Verification
Reproduced against the built 4.5.2-equivalent package: a consumer fixture with declaration emit produced
import("<file path>/ai-shared.js")in its declaration (the TS2742 trigger); after the fix the same fixture emits the public specifier with zero diagnostics. A regression test now builds that consumer simulation in a temp directory on every test run: it copies the built package into a fake node_modules (copied, not symlinked, because tsc only applies exports-map naming to real node_modules paths), compiles the fixture with the TypeScript API, and asserts no errors, no relative-path imports, and no internal module references in the emit.