streamQuery method

AgentQuery streamQuery({
  1. required Stream<SdkUserInput> prompt,
  2. Options? options,
})

Mirrors sdk.query({prompt: AsyncIterable<SDKUserMessage>, options}), the SDK's streaming-input mode.

Each SdkUserInput on prompt is sent to the running query as it arrives; when prompt is done, the query's input ends and the query finishes what it has. Keep prompt open while you may still want to send something: the Claude Code process reaches Dart tools and canUseTool through that input, so ending it early cuts them off. A system message with subtype: 'session_state_changed' and state: 'idle' (requested automatically) says the process is waiting for input, which is the usual moment to send the next message or close prompt.

Requires a transport that implements AgentSdkInputTransport; with any other the returned stream fails with an UnsupportedError.

Implementation

AgentQuery streamQuery({
  required Stream<SdkUserInput> prompt,
  Options? options,
}) => _run(options, input: prompt);