Skip to main content

Module run

Module run 

Source
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.run by spawning apr run <model> --json [...flags].
call_with_sink
Execute apr.run with optional notifications/progress streaming.
dispatch
HELIX-IDEA-002 — unified-signature shim for the inventory dispatcher. apr.run honours both cancel_rx and 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 a notifications/progress notification through sink, tagged with progress_token. Each stdout line is JSON-parsed if possible (the apr run --stream NDJSON contract guarantees JSON) so downstream MCP clients receive structured message.event = "token" / "final" events; non-JSON lines fall back to a bare string. The returned ToolCallResult is the aggregated stdout (same shape as run_apr_cancellable’s success body) so non-streaming consumers get the full payload too.