> For the complete documentation index, see [llms.txt](https://docs.orchard.airoverflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.orchard.airoverflow.com/guides/live-channels.md).

# Live channels: logs, shell, screen

Beyond request/response REST, Orchard exposes **live WebSocket channels** on a running sandbox. The SDKs present them as streams you iterate.

* **Python**, a context-managed, synchronous iterator. The socket opens on `with` and closes cleanly when you leave the block (or `break`). An async form lives in `orchard_sdk.aio` for event-loop code.
* **TypeScript**, a `Channel<T>` that is both `AsyncIterable` (use `for await`) and an emitter (`.on("message" | "open" | "close" | "error")`), with `.send()` and `.close()`.

## Logs

{% tabs %}
{% tab title="Python" %}

```python
with sb.logs() as stream:
    for line in stream:
        print(line)
```

{% endtab %}

{% tab title="TypeScript" %}

```ts
for await (const line of sb.logs()) console.log(line);
```

{% endtab %}
{% endtabs %}

## Interactive shell

The shell channel is bidirectional, send keystrokes upstream.

{% tabs %}
{% tab title="Python" %}

```python
with sb.shell() as sh:
    sh.send("getprop ro.product.model\n")
    for chunk in sh:
        print(chunk, end="")
```

{% endtab %}

{% tab title="TypeScript" %}

```ts
const sh = sb.shell();
await sh.ready;
await sh.send("getprop ro.product.model\n");
for await (const chunk of sh) process.stdout.write(chunk);
```

{% endtab %}
{% endtabs %}

## Screen, adb, mitm

`screen(source="scrcpy"|"host")` yields raw frame **bytes** (H.264 or PNG, depending on the device). `adb()` yields raw adb-transport bytes, bridge it to a local TCP port to run `adb connect`. `vnc()` yields RFB bytes (iOS VM only). `mitm_flows()` / `mitmFlows()` yields decoded HTTP(S) flow summaries.

{% tabs %}
{% tab title="Python" %}

```python
with sb.screen(source="scrcpy") as frames:
    first = next(iter(frames))
    print("got", len(first), "bytes")

from orchard_sdk.aio import AsyncChannels   # asyncio form
async for frame in AsyncChannels(orchard.config, sb.uuid).screen():
    ...
```

{% endtab %}

{% tab title="TypeScript" %}

```ts
const frames = sb.screen({ source: "scrcpy" });
for await (const frame of frames) { console.log(frame.byteLength); break; }
```

{% endtab %}
{% endtabs %}

If the server rejects or closes a channel with an error code (4401/4403/4404/4502) the stream raises/`throw`s a `ChannelClosedError`, see [Errors & close codes](/reference/errors.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.orchard.airoverflow.com/guides/live-channels.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
