session_read
Read incremental output and terminal state from an owned session without sending input or stopping the process; use cursor offsets and wait_ms to poll for new output or completion.
Instructions
Read incremental output and terminal state for an owned session. This does not send input or stop the process. Start with cursor=0, then use the returned next_cursor on each read; cursors are byte offsets, not character counts. wait_ms is 0-20000 (default 0): return immediately for new output or a terminal state, otherwise wait up to that many milliseconds. Empty output with done=false is only a polling timeout; continue polling. If older output was dropped from the 1 MiB buffer, truncated=true and reading resumes at the earliest retained byte; a cursor beyond available output is an error. done=true means a terminal result or a closed connection; only then are exit_code, timed_out, canceled and optional error included. A disconnect error is not proof of a remote command's success or confirmed cancellation. Use session_stop to terminate and session_write to supply input. Finished records expire after 30 minutes and server restarts invalidate them.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Byte cursor, initially 0 | |
| wait_ms | No | Wait up to this many milliseconds for output | |
| session_id | Yes | Session identifier | |
| client_token | Yes | Target client connection token, required with management access (including stdio and no-password mode). Device-scoped bearer access implicitly selects its own token. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| done | Yes | Whether the session has reached a terminal state. When false, keep polling session_read. | |
| error | No | Optional execution or connection error. A disconnect does not prove the remote process completed successfully. | |
| output | Yes | Combined terminal output from the requested cursor; may contain echoed input. | |
| canceled | No | True only when the target reported cancellation; a disconnect alone does not confirm cancellation. | |
| exit_code | No | Reported process exit code: 0 means success; -1 means execution failed, was interrupted, or the device disconnected before a normal exit report. | |
| timed_out | No | True if the target reported that the process execution timeout elapsed. | |
| truncated | Yes | True if output exceeded the 1 MiB retention limit. Commands discard excess captured output; sessions discard older buffered bytes. | |
| session_id | Yes | Identifier of the owned session; retain it for subsequent read, write and stop calls. | |
| next_cursor | Yes | Output byte offset to pass as cursor on the next session_read. |