From 7d17be7406c7a23d53dd67866bca44d304b67af2 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 14 Feb 2026 23:52:29 +0000 Subject: [PATCH] Document advanced chat transport mapping and run store options Co-authored-by: Eric Allam --- docs/tasks/streams.mdx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/tasks/streams.mdx b/docs/tasks/streams.mdx index 64b846459..2b9eab71a 100644 --- a/docs/tasks/streams.mdx +++ b/docs/tasks/streams.mdx @@ -606,6 +606,34 @@ The default payload sent to your task is a rich, typed object that includes: - `messages` - `request` (`headers`, `body`, and `metadata`) +### Advanced transport options + +`TriggerChatTransport` also supports: + +- `payloadMapper` (sync or async) for custom task payload shapes +- `triggerOptions` as an object or resolver function (sync or async) +- `runStore` for custom reconnect-state persistence (including async stores) + +```ts +import type { TriggerChatRunState, TriggerChatRunStore } from "@trigger.dev/ai"; + +class MemoryRunStore implements TriggerChatRunStore { + private runs = new Map(); + + async get(chatId: string) { + return this.runs.get(chatId); + } + + async set(state: TriggerChatRunState) { + this.runs.set(state.chatId, state); + } + + async delete(chatId: string) { + this.runs.delete(chatId); + } +} +``` + ## Complete Example: AI Streaming ### Define the stream