skip to content
$worker

fp

v0.2.3

Lodash-style value transforms (fp::get/pick/take/…) and fp::pipe — worker-side pipelines that move big values function→function without routing them through the model.

iiiverified
341 installs18 in 7d1 today
install
$iii worker add fp@0.2.3
  • macOS: arm64 · x64
  • Linux: arm64 · armv7 · x64
  • Windows: arm64 · x64 · x86

exact versions are immutable; binary and bundle artifacts are digest-pinned.

functions

20

fp::compact

function

Remove null elements from an array (lodash _.compact, null-only: 0, false and "" are KEPT so plucked data survives): { value }. Pairs with fp::map, whose sporadic misses become null. Mainly useful as a fp::pipe step.

request
  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::drop

function

Skip the first n elements of an array or the first n characters of a string (lodash _.drop): { value, n }. Mainly useful as a fp::pipe step.

request
  • ninteger· uint32requiredmin 0

    How many array elements / string characters to skip.

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::filter

function

Keep array elements whose properties equal a partial object (lodash _.filter with a matches iteratee): { value, matches: { status: "active" } }. matches is a partial OBJECT (never a bare string/number) and only object elements can match. Mainly useful as a fp::pipe step.

request
  • matchesobjectrequired

    Partial object an element's top-level properties must equal.

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::flatten

function

Flatten an array one level (lodash _.flatten): [1,[2],[[3]]] -> [1,2,[3]]. Mainly useful as a fp::pipe step.

request
  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::get

function

Extract the single value at a JSON pointer (lodash _.get): { value, path: "/content" }. A miss names the keys that were available. Mainly useful as a fp::pipe step.

request
  • pathstringrequired

    JSON pointer selecting the value to return (e.g. `/content`).

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::getOr

function

Extract the value at a JSON pointer, or `default` when the path misses (lodash fp.getOr): { value, path, default }. A stored null is a hit, not a miss. Mainly useful as a fp::pipe step.

request
  • defaultunknownrequired

    Returned when the path matches nothing (a stored null is a hit).

  • pathstringrequired

    JSON pointer selecting the value to return (e.g. `/content`).

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::inject-guidance

function

Internal pre_generate hook: appends fp::pipe usage guidance to the agent system prompt. Bound to harness::hook::pre-generate at worker startup; not called directly.

request
  • generateobject
    • system_promptstring

      The system prompt assembled so far (base + any prior hook's mutation).

response
  • mutationsobjectrequired

    The harness applies `system_prompt` only when the key is present (`HookRunner::run_pre_generate` — `if m.system_prompt.is_some()`), so `None` serializes to an empty object: the safe no-op that preserves the harness's assembled prompt.

    • system_promptstring

      Full replacement system prompt (base + appended guidance). The harness overwrites, it does not merge.

fp::join

function

Join array elements into one string (lodash _.join): { value, separator } (separator defaults to ","). Mainly useful as a fp::pipe step.

request
  • separatorstring

    Separator between elements (default `","`).

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::map

function

Pluck the value at a JSON pointer from each array element (lodash _.map with a property iteratee): { value, path: "/id" }. Sporadic misses become null (fp::compact drops them), but a path matching NO element errors — pointers pluck stored fields, not computed properties like /length (fp::size counts). Mainly useful as a fp::pipe step.

request
  • pathstringrequired

    JSON pointer plucked from each element (e.g. `/id`). Sporadic misses become null; a path matching NO element is an error (stored fields only — no computed properties like `/length`).

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::nth

function

Element at index n; negative n counts from the end (lodash _.nth): { value, n: -1 } is the last element. Out of bounds errors naming the length. Mainly useful as a fp::pipe step.

request
  • ninteger· int64required

    Index to pluck; negative counts from the end (`-1` = last element).

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::omit

function

Drop top-level keys from an object (lodash _.omit): { value, paths: ["a","b"] }. Mainly useful as a fp::pipe step.

request
  • pathsstring[]required

    Top-level keys to drop; missing keys are ignored.

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::pick

function

Subset an object by top-level keys (lodash _.pick): { value, paths: ["a","b"] } -> {a, b}; missing keys are omitted. Mainly useful as a fp::pipe step.

request
  • pathsstring[]required

    Top-level keys to keep; missing keys are silently omitted.

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::pipe

function

Run a short worker-side pipeline in one call: each step triggers a function and its result lands in the next step's payload at `into` (default "/value") — large values flow worker→worker and never enter the chat. fp::* transform steps (get/pick/omit/take/drop/map/filter/split/join/uniq/size/compact/nth/getOr/flatten/sortBy/reverse/when, lodash semantics) run inline and thread the transformed value itself — the {value} wrapper they return when called directly never appears between steps. A failing fp::when guard STOPS the pipe (`short_circuited: true`), so a trailing write step runs only when its condition holds. The FIRST step receives no threaded value: start with a producing function (a fetch, a state::get) or seed a leading transform via payload.value. Example: fetch an article and persist it trimmed: through=[{function:'scrapling::fetch', payload:{url,format:'markdown'}}, {function:'fp::get', payload:{path:'/content'}}, {function:'fp::take', payload:{n:20000}}, {function:'state::set', payload:{scope,key}}]. Returns per-step sizes and a preview, not the value.

request
  • preview_charsinteger· uint32min 0

    Preview length of the final threaded value in the receipt (capped at 8000).

  • throughobject[]required

    Steps run in order; step N+1 receives step N's threaded value.

    • functionstringrequired

      Function id to trigger (e.g. `scrapling::fetch`, `fp::get`, `state::set`).

    • intostring

      JSON pointer in THIS step's payload where the previous step's value lands (default `/value`). Object keys only (`~0`/`~1` escapes are decoded); indexing into arrays is unsupported.

    • payloadunknown

      Base payload for the call.

response
  • short_circuitedbooleanrequired

    True when a `fp::when` guard failed and stopped the pipe: the receipts end at the guard and NO later step ran. Absent (false) on a full run.

  • stepsobject[]required
    • charsinteger· uintrequiredmin 0

      Size of the value threaded OUT of this step (chars of its string or serialized form).

    • functionstringrequired
    • notestring

      Set when the threaded value REPLACED a non-null literal already in this step's payload at the `into` pointer — almost always an omitted `into` on a write step clobbering the value it meant to write.

  • value_previewstring

fp::reverse

function

Reverse an array (lodash _.reverse, immutable like lodash/fp): { value }. Mainly useful as a fp::pipe step.

request
  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::size

function

Count a collection (lodash _.size): array length, string chars, or object key count: { value }. Non-collections error instead of returning 0. Mainly useful as a fp::pipe step.

request
  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::sortBy

function

Sort array elements ascending by the value at a JSON pointer (lodash _.sortBy, stable): { value, path } — path "" sorts the elements themselves (primitives). Keys must all be numbers, strings, or booleans; an element missing the path errors. Pair with fp::reverse for descending. Mainly useful as a fp::pipe step.

request
  • pathstringrequired

    JSON pointer plucked from each element as the sort key (e.g. `/score`).

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::split

function

Split a string into an array of strings (lodash _.split): { value, separator: "\n" }. Mainly useful as a fp::pipe step.

request
  • separatorstringrequired

    Non-empty separator to split on (e.g. `"\n"`).

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::take

function

Keep the first n elements of an array or the first n characters of a string (lodash _.take): { value, n }. Mainly useful as a fp::pipe step.

request
  • ninteger· uint32requiredmin 0

    How many array elements / string characters to keep.

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::uniq

function

Deduplicate an array, keeping first occurrences (lodash _.uniq): { value }. Mainly useful as a fp::pipe step.

request
  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • valueunknownrequired

fp::when

function

Guard: test the value at a JSON pointer ({ value, path?, op, to? }; ops ==, !=, >, >=, <, <=, exists, not_empty; path defaults to the whole value; a pointer miss FAILS the guard, it never errors). Direct calls return { passed, value }. As a fp::pipe step, a passing guard threads the ORIGINAL value onward unchanged and a failing one STOPS the pipe (`short_circuited: true`), so a trailing write step (e.g. state::set) runs only when the condition holds.

request
  • opall ofrequired

    One of "==", "!=", ">", ">=", "<", "<=", "exists", "not_empty".

    all of (1)
    variant 1
    valuestringenum: ==, !=, >, >=, <, <=,
  • pathstring

    JSON pointer selecting what to test (default: the whole value).

  • tounknown

    Right-hand side for the comparison ops; meaningless (and rejected) for exists / not_empty.

  • valueunknownrequired

    Input value (a pipe lands the previous step's value here).

response
  • passedbooleanrequired
  • valueunknownrequired

    The ORIGINAL input value, untouched — guards test, they never reshape.

triggers

0
no triggers registered