> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Streaming

> Stream WarpGrep search steps

Stream WarpGrep search steps back to your UI in real-time.

<img src="https://mintcdn.com/morph-555d6c14/eNG-4EdAVQCA-lWO/images/warpgrep-searching.gif?s=dfd889c929109d15f8882fab6b620c67" alt="WarpGrep streaming search steps" width="670" height="374" data-path="images/warpgrep-searching.gif" />

### Why?

Use streaming when you want to show users what WarpGrep is doing as it works — progress indicators, "Searching for X...", "Reading file Y..." messages. Skip it for background or batch searches where no user is watching.

Streaming steps are **not separate API calls** — they are yields from the same search operation. Streaming adds zero latency overhead to the total search time. Each step shows the tool calls WarpGrep made on that turn before executing them locally.

Streaming also works with `searchGitHub` — pass `streamSteps: true` the same way.

***

Pass `streamSteps: true` to get an `AsyncGenerator` that yields each turn's tool calls before they execute.

## Basic Usage

```typescript theme={null}
import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

const stream = morph.warpGrep.execute({
  searchTerm: 'Find authentication middleware',
  repoRoot: '.',
  streamSteps: true
});

for await (const step of stream) {
  console.log(`Turn ${step.turn}:`, step.toolCalls);
}
```

## Step Format

Each yielded step contains the turn number and tool calls made:

```typescript theme={null}
type WarpGrepStep = {
  turn: number;  // 1-4
  toolCalls: Array<{
    name: string;       // "grep" | "read" | "list_directory" | "finish"
    arguments: Record<string, unknown>;
  }>;
};
```

Example output:

```typescript theme={null}
// Turn 1
{ turn: 1, toolCalls: [
  { name: "grep", arguments: { pattern: "auth", path: "src/" } },
  { name: "list_directory", arguments: { path: "src/auth" } }
]}

// Turn 2
{ turn: 2, toolCalls: [
  { name: "read", arguments: { path: "src/auth/middleware.ts", start: 1, end: 50 } }
]}

// Turn 3 (finish)
{ turn: 3, toolCalls: [
  { name: "finish", arguments: { files: [...] } }
]}
```

All types are importable from `@morphllm/morphsdk`.

See the [streaming example](https://github.com/morphllm/examples/tree/main/warpgrep/streaming) and [GitHub streaming example](https://github.com/morphllm/examples/tree/main/warpgrep/github-streaming) for complete, runnable code.

## Return Type

```typescript theme={null}
// streamSteps: true
AsyncGenerator<WarpGrepStep, WarpGrepResult, undefined>
// yield: WarpGrepStep (each turn), return: WarpGrepResult (final result)

// streamSteps: false (default)
Promise<WarpGrepResult>
```
