stream_read
Read raw stream-json output lines from a Claude or Codex agent seat using a cursor, optionally waiting for new lines or state changes such as pending answer requests.
Instructions
machine席(agent_launch harness:claude-machine のClaude席、またはcodex-machineのCodex席)の出力をデータで読む。claude -p stream-json(Codexは codex app-server のJSON-RPC)のstdoutの行を、解釈も整形もせず、そのまま返す(assistant・user・system・result・rate_limit_event・control_request(can_use_tool、AskUserQuestionを含む)など)。cursorは前回の返りのcursor(省略はこの起動のstreamの先頭)。wait_msを付けると、新しい行か状態の変化まで待つ。state.pendingは答えを待つ要求で、stream_offset/stream_endはその行のstream内の位置(cursorは<launch_id>:<stream_end>)。resume・wakeは新しい起動(launch_id)で、前の起動のcursorも、その起動のfileが残る間(席をcloseするまで)は読める。無ければSTREAM_CURSOR_STALE。vendorとharnessは返した起動の値。
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"session_id": "<session_id>"
},
"name": "stream_read"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | 前回の返りのcursor。省略は先頭 | |
| remote | No | 別端末のAitermで実行する時のSSH接続情報。hostだけならssh_configの接続名として使う。Aitermは接続情報を保存・管理しない。passphraseは会話記録に残るため、ssh-agentかpassphrase_env(環境変数名)を推奨する。 | |
| wait_ms | No | 新しい行か状態の変化まで待つ(既定0) | |
| max_lines | No | 既定200 | |
| session_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lines | Yes | claudeのstdoutの行そのまま(JSON文字列) | |
| state | Yes | ||
| at_end | Yes | ||
| cursor | Yes | ||
| schema | Yes | ||
| vendor | No | Vendor of the returned launch; absent on old remotes | |
| harness | No | Harness of the returned launch; absent on old remotes | |
| launch_id | Yes | ||
| session_id | Yes | ||
| current_launch_id | Yes |