Feature Request: Better Data Stream Support for RAG & Agentic Applications

### Feature Description

### The problem 
When using `StreamData` with `streamText` via `StreamTextResult.toDataStreamResponse`, it is possible to append messages to the data stream via `StreamData.appendMessage` and `StreamData.appendMessageAnnotation` _before_ `streamText` is called. 

However, because `toDataStreamResponse` is a method of the return value of `streamText`, this creates a waterfall that blocks any data from being streamed to the client until all of the arguments to `streamText` are ready, and until `streamText` itself can be called (although now at least it returns instantly, and is not async). 

To illustrate the problem, let's imagine a workflow where there are intermediate steps such as retrieval or other agent invocations that must happen before a final call to `streamText`:

```typescript
const data = new StreamData()

// assume this takes several seconds to finish, but calls `data.appendMessage` or `data.appendMessageAnnotation` 
// several times to send intermediate status updates, events, and retrieval results to the client
const results = await doRetrievalOrAgenticStuff(data)

// this cannot be called until retrieval / other intermediate work has been finished
const streamTextResult = streamText({model, prompt: buildPromptFromRetrieval(results)})

// data stream events are not able to be streamed to the client until this is called;
return streamTextResult.toDataStreamResponse({data})
```

The result of this is that even if we are ready to stream intermediate events to the client early-on in retrieval or other parts of intermediate work before the call to `streamText`, no events are actually streamed to the client until the call to `streamText` can be made. 

Right now, the only way around this is to implement the data stream protocol and manually merge intermediate events with `streamText` outputs for text, tool calls etc. 



### The solution (and feature request)
Allow streaming data to the client _before_ the call to `streamText` can be made. Below are a couple (non-exhaustive) ideas of how this could possibly be implemented:

- Allow returning a data stream response before `streamText` is called, and merge the streams together
- Allow passing a promise to `streamText` such that `streamText` still returns instantly, but it does not actually invoke the 
LLM via API and start streaming response tokens until the promise resolves. E.g., passing in a promise for the prompt could be a decent solution here. 

### Use Cases

Two use-cases immediately come to mind:
1. RAG - in many cases it is desirable to stream retrieval results, status updates, etc. to the client _before_ the LLM begins generating, to populate as much of the UI as possible as early as possible, and to create a better UX by providing feedback about ongoing work. This would be especially beneficial in multi-step retrieval pipelines where retrieval can take some time. 
2. agents - in some cases it may be necessary to have multiple different agents through different invocations to `streamText` or `generateText` or `generateObject`, and it would be desirable to be able to stream outputs or status updates from these intermediate invocations to the client _before_ we are ready to make the final call to `streamText`. 

### Additional context

in conversations with @lgrammel he suggested that it may be necessary to expose a "merge streams" abstraction to solve this issue. 

Labels: feature, ai/core
State: closed