Conversation
New package that provides a custom AI SDK ChatTransport implementation bridging Vercel AI SDK's useChat hook with Trigger.dev's durable task execution and realtime streams. Key exports: - TriggerChatTransport class implementing ChatTransport<UIMessage> - createChatTransport() factory function - ChatTaskPayload type for task-side typing - TriggerChatTransportOptions type The transport triggers a Trigger.dev task with chat messages as payload, then subscribes to the task's realtime stream to receive UIMessageChunk data, which useChat processes natively. Co-authored-by: Eric Allam <eric@trigger.dev>
Tests cover: - Constructor with required and optional options - sendMessages triggering task and returning UIMessageChunk stream - Correct payload structure sent to trigger API - Custom streamKey in stream URL - Extra headers propagation - reconnectToStream with existing and non-existing sessions - createChatTransport factory function - Error handling for API failures - regenerate-message trigger type Co-authored-by: Eric Allam <eric@trigger.dev>
- Cache ApiClient instance instead of creating per-call - Add streamTimeoutSeconds option for customizable stream timeout - Clean up subscribeToStream method (remove unused variable) - Improve JSDoc with backend task example - Minor code cleanup Co-authored-by: Eric Allam <eric@trigger.dev>
Adds 3 additional test cases: - Abort signal gracefully closes the stream - Multiple independent chat sessions tracked correctly - ChatRequestOptions.body is merged into task payload Co-authored-by: Eric Allam <eric@trigger.dev>
Co-authored-by: Eric Allam <eric@trigger.dev>
ChatSessionState is an implementation detail of the transport's session tracking. Users don't need to access it since the sessions map is private. Co-authored-by: Eric Allam <eric@trigger.dev>
The accessToken option now accepts either a string or a function
returning a string. This enables dynamic token refresh patterns:
new TriggerChatTransport({
taskId: 'my-task',
accessToken: () => getLatestToken(),
})
The function is called on each sendMessages() call, allowing fresh
tokens to be used for each task trigger.
Co-authored-by: Eric Allam <eric@trigger.dev>
Use the already-resolved token when creating ApiClient instead of calling resolveAccessToken() again through getApiClient(). Co-authored-by: Eric Allam <eric@trigger.dev>
Two new subpath exports: @trigger.dev/sdk/chat (frontend, browser-safe): - TriggerChatTransport — ChatTransport implementation for useChat - createChatTransport() — factory function - TriggerChatTransportOptions type @trigger.dev/sdk/ai (backend, adds to existing ai.tool/ai.currentToolOptions): - chatTask() — pre-typed task wrapper with auto-pipe - pipeChat() — pipe StreamTextResult to realtime stream - CHAT_STREAM_KEY constant - ChatTaskPayload type - ChatTaskOptions type - PipeChatOptions type Co-authored-by: Eric Allam <eric@trigger.dev>
Move and adapt tests from packages/ai to packages/trigger-sdk. - Import from ./chat.js instead of ./transport.js - Use 'task' option instead of 'taskId' - All 17 tests passing Co-authored-by: Eric Allam <eric@trigger.dev>
All functionality now lives in: - @trigger.dev/sdk/chat (frontend transport) - @trigger.dev/sdk/ai (backend chatTask, pipeChat) Co-authored-by: Eric Allam <eric@trigger.dev>
Co-authored-by: Eric Allam <eric@trigger.dev>
1. Add null/object guard before enqueuing UIMessageChunk from SSE stream to handle heartbeat or malformed events safely 2. Use incrementing counter instead of Date.now() in test message factories to avoid duplicate IDs 3. Add test covering publicAccessToken from trigger response being used for stream subscription auth Co-authored-by: Eric Allam <eric@trigger.dev>
Comprehensive guide covering: - Quick start with chatTask + TriggerChatTransport - Backend patterns: simple (return streamText), complex (pipeChat), and manual (task + ChatTaskPayload) - Frontend options: dynamic tokens, extra data, self-hosting - ChatTaskPayload reference - Added to Writing tasks navigation near Streams Co-authored-by: Eric Allam <eric@trigger.dev>
Minimal example showcasing the new chatTask + TriggerChatTransport APIs: - Backend: chatTask with streamText auto-pipe (src/trigger/chat.ts) - Frontend: TriggerChatTransport with useChat (src/components/chat.tsx) - Token generation via auth.createTriggerPublicToken (src/app/page.tsx) - Tailwind v4 styling Co-authored-by: Eric Allam <eric@trigger.dev>
…delMessages @ai-sdk/openai v3 and @ai-sdk/react v3 are needed for ai v6 compatibility. convertToModelMessages is async in newer AI SDK versions. Co-authored-by: Eric Allam <eric@trigger.dev>
…r mesages from the transport
…and documenting it all
…endingMessages hook
Replace triggerAndWait with triggerAndSubscribe in ai.tool to fix: - Parallel tool calls (no more preventMultipleWaits errors) - Stop signal while suspended (parent stays alive, child gets cancelled) New task.triggerAndSubscribe() method: trigger + subscribeToRun in a single span, with abort signal support and cancelOnAbort option. Convert deepResearch to a schemaTask + ai.tool in the reference app. refs TRI-7986
…at.defer improvements - chat.inject(): queue model messages from background work for injection at the next prepareStep boundary or before the next turn's run() - Deferred work from onTurnComplete no longer blocks waiting for next message - Background queue persists across turns (not reset) so deferred work from onTurnComplete can inject into the next turn - Reference app: self-review pattern using generateObject + chat.inject() - Hide transient data-turn-status and data-background-context-injected parts in UI
… ai.tool - Assert toolFromTask return as AI SDK ToolSet-compatible; import ToolSet from ai - Add changesets for @trigger.dev/sdk - ai-chat reference: chat-tools module, registry language model helper, streamText cleanup - Prisma migration removing user tool demo; demo docs and next config tweaks
- Pass TaskRunContext through chat lifecycle events, CompactedEvent, and ChatTaskRunPayload; use ctx.run.id for chat access tokens - Export TaskRunContext from @trigger.dev/sdk - ai-chat reference: executeCode via E2B, code-sandbox module, warm on onTurnStart, dispose on token onWait and onComplete; chat.local run id - Docs: database persistence + code sandbox pattern pages; reference and backend updates for ctx; chat.defer anchor; navigation
…, chat.withClientData, and ChatBuilder
plus playground support, including playground conversations, and a new agent list
- Upgrade streamdown from v1.4.0 to v2.5.0 with @streamdown/code plugin - Custom Shiki theme matching the Trigger.dev VS Code dark theme colors - Consolidate duplicated lazy StreamdownRenderer into shared component - Patch streamdown to inline highlighted body (fixes Arc browser) - Add streamdown storybook page for visual testing - Handle AGENT triggerSource in TestTaskPresenter exhaustive switch - Update Tailwind config to scan streamdown dist for utility classes
…d preloaded conversations on first message
|
Hi @deepshekhardas, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (38)
📒 Files selected for processing (109)
WalkthroughThis pull request introduces comprehensive chat and agent functionality to the Trigger.dev platform. It adds new presenter classes for listing agents and managing playground conversations, extends the database schema with a Estimated code review effort🎯 5 (Critical) | ⏱️ ~210 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
|
Closes #
✅ Checklist
Testing
[Describe the steps you took to test this change]
Changelog
[Short description of what has changed]
Screenshots
[Screenshots]
💯