Documentation
¶
Overview ¶
Package jqfilter runs a jq program over an already-decoded JSON value in a locked-down sandbox. It backs the MCP server's optional `jq` argument, which lets an agent reshape, filter and aggregate a tool's reply server-side so only the needed data enters its context.
The host process holds the caller's BRON_API_KEY in its environment, so the sandbox is deliberately strict: no environment access (gojq's `env`/`$ENV` resolve to empty), no stdin (`input`/`inputs` are rejected at compile time), no module imports, a wall-clock timeout against runaway programs, and a cap on emitted values so a filter can't blow up the context it is meant to shrink.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTimeout bounds a single jq evaluation. gojq honours context // cancellation between steps, so this bites infinite generators // (`repeat(.)`, `range(1e12)`). DefaultTimeout = 2 * time.Second // DefaultMaxResults caps how many top-level values the program may emit // before Run aborts. A jq filter can multiply output (`[range(1e6)]`); // the whole point here is to shrink context, so an exploding result is // treated as an error, not silently truncated. DefaultMaxResults = 10000 )
Defaults applied by Run. Exposed as vars so callers/tests can tighten them.
var ErrTooManyResults = errors.New("jq produced too many results")
ErrTooManyResults is returned when a program emits more than the cap.
Functions ¶
func Run ¶
Run compiles and evaluates program against input and returns the produced values. A program emitting exactly one value returns that value unwrapped (the common reshape/filter case); zero values returns nil; multiple values returns a []interface{} stream. Compile errors surface verbatim so a calling agent can correct its own filter.
Types ¶
This section is empty.