Open History to see the last commit
1---
2id: replayRunStream
3title: replayRunStream
4---
5
6```ts
7function replayRunStream<TOffset>(
8 durability,
9 offset?,
10signal?): AsyncGenerator<AGUIEvent>;
11```
12
13Defined in: packages/ai/src/stream-durability.ts:588
14
15Replay a run's delivery-durability log as a bare stream of chunks, for
16callers that serve a `joinRun` handler without an HTTP `Response` — e.g. a
17TanStack Start server function returning an async iterable:
18
19```ts
20async function* joinImageRun({ data: runId }: { data: string }) {
21 yield* replayRunStream(memoryStream({ runId }))
22}
23
24// Serve it from a server function whose handler is the generator above
25// (`createServerFn({ method: 'GET' }).inputValidator(...)`).
26```
27
28NOTE: the example deliberately declares the generator separately instead of
29inlining it into the server-fn builder chain. TanStack Start's server-fn
30Vite plugin decides whether a module needs compiling by regex-matching the
31SOURCE for a dotted `handler(` call, and JSDoc survives into `dist` — an
32inlined chain here would make every Start app treat this package as a
33server-fn module and try to resolve its framework's `@tanstack/*-start`
34package, failing the build wherever that framework is not the one installed.
35
36Reads from `offset` (default `'-1'` — from the start) and tails until the
37producer closes the log or `signal` aborts, exactly like the HTTP
38`resumeServerSentEventsResponse` path.
39
40## Type Parameters
41
42### TOffset
43
44`TOffset` *extends* `string`
45
46## Parameters
47
48### durability
49
50[`StreamDurability`](../interfaces/StreamDurability.md)\<`TOffset`\>
51
52### offset?
53
54`TOffset`
55
56### signal?
57
58`AbortSignal`
59
60## Returns
61
62`AsyncGenerator`\<[`AGUIEvent`](../type-aliases/AGUIEvent.md)\>