Skip to content

Commit 7d17be7

Browse files
Document advanced chat transport mapping and run store options
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent ffb91a1 commit 7d17be7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/tasks/streams.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,34 @@ The default payload sent to your task is a rich, typed object that includes:
606606
- `messages`
607607
- `request` (`headers`, `body`, and `metadata`)
608608

609+
### Advanced transport options
610+
611+
`TriggerChatTransport` also supports:
612+
613+
- `payloadMapper` (sync or async) for custom task payload shapes
614+
- `triggerOptions` as an object or resolver function (sync or async)
615+
- `runStore` for custom reconnect-state persistence (including async stores)
616+
617+
```ts
618+
import type { TriggerChatRunState, TriggerChatRunStore } from "@trigger.dev/ai";
619+
620+
class MemoryRunStore implements TriggerChatRunStore {
621+
private runs = new Map<string, TriggerChatRunState>();
622+
623+
async get(chatId: string) {
624+
return this.runs.get(chatId);
625+
}
626+
627+
async set(state: TriggerChatRunState) {
628+
this.runs.set(state.chatId, state);
629+
}
630+
631+
async delete(chatId: string) {
632+
this.runs.delete(chatId);
633+
}
634+
}
635+
```
636+
609637
## Complete Example: AI Streaming
610638

611639
### Define the stream

0 commit comments

Comments
 (0)