Expand description
apr.run — M2 tool. Synchronous inference via subprocess wrapper.
Wraps apr run <model> --json [--prompt X] [--max-tokens N] [--temperature T] [--top-p P].
M3 (FALSIFY-MCP-006) adds cancellation: the call accepts a cancel receiver
and forwards it to run_apr_cancellable, which SIGTERMs the spawned
subprocess on signal and SIGKILLs after the grace window.
M3 (FALSIFY-MCP-PROGRESS-002) adds streaming: when the originating
tools/call carries params._meta.progressToken, call_with_sink
invokes apr run ... --stream (NDJSON: one event=token line per
decoded token, then one event=final blob) and forwards each line as a
notifications/progress message tagged with the caller’s token. When the
sink is absent (no progressToken), we fall back to the original
cancellable sync path so existing clients see no behaviour change.
Constants§
- NAME
- Tool name registered with MCP clients.
Functions§
- call
- Execute
apr.runby spawningapr run <model> --json [...flags]. - call_
with_ sink - Execute
apr.runwith optionalnotifications/progressstreaming. - dispatch
- HELIX-IDEA-002 — unified-signature shim for the inventory dispatcher.
apr.runhonours bothcancel_rxand the optional notification sink. - run_
tool_ definition - Return the MCP tool definition for
apr.run. - stream_
with_ sink - Test-visible: stream
program args...and forward each stdout line as anotifications/progressnotification throughsink, tagged withprogress_token. Each stdout line is JSON-parsed if possible (theapr run --streamNDJSON contract guarantees JSON) so downstream MCP clients receive structuredmessage.event = "token"/"final"events; non-JSON lines fall back to a bare string. The returnedToolCallResultis the aggregated stdout (same shape asrun_apr_cancellable’s success body) so non-streaming consumers get the full payload too.