fp
v0.3.0Lodash-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.
Install
iii trigger compose::add worker=fp@0.3.0Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.
Full markdown
/registry/workers/fp.md?version=0.3.0. Paste it into an LLM prompt or pipe it through curl from a worker.Install
iii trigger compose::add worker=fp@0.3.0Dependencies
Readme
fp
Lodash-style value transforms and fp::pipe — worker-side pipelines that
move big values function→function over the iii bus without routing them
through the model.
Install
iii call compose::add worker=fpThe worker is a deploy: binary Rust worker with no configuration.
Why
An agent that fetches a document and re-types it into the next call's
arguments burns its context window and stalls the provider stream mid-call.
fp::pipe runs the whole move in one call — each step calls a function
and its result lands in the next step's payload — so the value flows
worker→worker and the chat only ever sees per-step sizes and a preview.
While connected (and unless turned off) the worker also injects a usage
section into the agent system prompt: fp::inject-guidance observes the
harness's harness::hook::on-pre-generate with args
{ on_error: "fail_open", inject_prompt: <the guidance> }. The knob lives in the builtin configuration
worker under the fp entry: inject_guidance is ON by default; turn it
off in global Settings (or via configuration::set) to save
the ~750 tokens per generation (the harness's # Granted functions catalog
still advertises the fp::* ids) — it hot-applies, the worker observes the
hook or disposes the observer on the spot, no restart. The Console renders the
entry with its explicit worker settings form. The guidance stays
presence-gated either way (no fp worker, no prompt text). When enabled before
the harness is up, the observer stays pending and becomes active when the
harness registers the hook function. The worker also observes
configuration::on-updated for its own entry (fp::on-config-change).
Functions
| function | lodash | request |
|---|---|---|
fp::pipe |
— | { through: [{function, payload?, into?}], preview_chars? } |
fp::batch |
— | { calls: [{id?, function, payload?, namespace?, timeout_ms?}], concurrency?, stop_on_error?, timeout_ms?, max_entry_bytes?, max_calls? } — independent calls, every answer in place (experimental) |
fp::get |
_.get |
{ value, path } — JSON pointer; a miss names the available keys |
fp::pick |
_.pick |
{ value, paths } — subset an object by top-level keys |
fp::omit |
_.omit |
{ value, paths } — drop top-level keys |
fp::take |
_.take |
{ value, n } — first n array elements / string chars |
fp::drop |
_.drop |
{ value, n } — skip the first n |
fp::map |
_.map |
{ value, path } — pluck a pointer from each element; misses → null |
fp::filter |
_.filter |
{ value, matches } — keep elements matching a partial object |
fp::split |
_.split |
{ value, separator } |
fp::join |
_.join |
{ value, separator? } (default ,) |
fp::uniq |
_.uniq |
{ value } — dedupe, first occurrences win |
fp::size |
_.size |
{ value } — array length / string chars / object key count |
fp::compact |
_.compact |
{ value } — remove null elements (0/false/"" are kept) |
fp::nth |
_.nth |
{ value, n } — element at index; negative counts from the end |
fp::getOr |
fp.getOr |
{ value, path, default } — pointer value, or default on a miss |
fp::flatten |
_.flatten |
{ value } — unnest one level |
fp::sortBy |
_.sortBy |
{ value, path } — stable ascending sort by a plucked pointer ("" = the element itself) |
fp::reverse |
_.reverse |
{ value } — reversed copy (immutable, fp-style) |
fp::sum |
_.sum / _.sumBy |
{ value, path? } — total; path plucks the addend from each element. Empty array totals 0 |
fp::mean |
_.mean / _.meanBy |
{ value, path? } — arithmetic mean; an empty array errors |
fp::min |
_.min / _.minBy |
{ value, path? } — smallest NUMBER (not the element holding it); an empty array errors |
fp::max |
_.max / _.maxBy |
{ value, path? } — largest NUMBER (not the element holding it); an empty array errors |
fp::groupBy |
_.groupBy |
{ value, path } — { key: [elements] } bucketed by a plucked key ("" = the element itself) |
fp::countBy |
_.countBy |
{ value, path } — { key: count } with the same key rules |
fp::when |
— | { value, path?, op, to? } — { passed, value }; as a pipe step a failing comparison stops the pipe (short_circuited: true) |
fp::condition |
— | { event, condition_config: { path?, op, to?, negate? } } — { decision: "allow" | "skip", reason }: the fp::when comparison as a guard in a harness observer's conditions (harness::observe) |
The reductions are the worker's arithmetic: all-integer inputs fold to an
integer (so the result compares cleanly in a fp::when guard), a non-numeric
element errors instead of being skipped — a skipped row is a total that
silently covers less than the caller counted — and min/max return the
number rather than lodash's …By element so a guard can compare it directly.
groupBy/countBy add the per-key axis the reductions lack: countBy gives
counts in one step, and groupBy's buckets each feed fp::sum for a per-key
total. Group keys must be a string, number, or boolean — lodash coerces a null
or object key to "null"/"[object Object]", silently merging distinct groups
into one bucket, so those error here instead.
Transforms take their input at value and return { value }. They deviate
from lodash where silence would thread garbage through a pipe: a type
mismatch is an error (not a silent {}); a map path matching NO element
errors naming what was available (pointers pluck stored fields — no computed
properties like /length; fp::size counts); compact removes only null
(lodash's full-falsey removal would eat legitimate 0/false/"");
nth out of bounds and size on a non-collection error instead of returning
undefined/0; sortBy requires every element to carry the key with one
comparable type. Sporadic map misses still become null, like lodash —
fp::compact drops them.
The pipe
fp::pipe { through: [
{ function: "browser::fetch",
payload: { url: "https://…", format: "markdown", main_content_only: true } },
{ function: "fp::get", payload: { path: "/content" } },
{ function: "fp::take", payload: { n: 20000 } },
{ function: "state::set", payload: { scope: "research", key: "article" } }
]}- Step N's result lands in step N+1's payload at
into(a JSON pointer, default/value— which is exactly where the transforms andstate::setread their input, so most pipes need nointoat all). - A transform step threads the transformed value itself — the
{ value }wrapper in the function table is only its direct-call response shape, so there is never a{value}layer to unwrap between steps. - The FIRST step receives no threaded value: start with a producing function
(a fetch, a
state::get) or seed a leading transform viapayload.value. An unseeded leading transform fails validation before anything runs. fp::*transform steps run inline in this worker; every other step is one bus call with a 120 s budget. The whole pipe must also fit the caller's own dispatch timeout onfp::pipe.- 1–12 steps. The response is receipts only:
{ steps: [{function, chars}], value_preview }(preview_charssizes the preview, default 400, capped at 8000 — the receipt must never become the bulk channel it replaces). - A failing step stops the pipe; the error carries the completed-step trail.
The batch (experimental)
fp::batch { calls: [
{ id: "info", function: "engine::workers::info", payload: { name: "todo" } },
{ id: "http", function: "http::status" },
{ id: "logs", function: "compose::logs", payload: { container: "todo", tail: 40 } }
]}- Independent calls, nothing threaded. They run at once, or
concurrencyat a time;stop_on_error: trueruns them in order and stops after the first error (the rest answerSKIPPED). - One result per call, in order:
{ id, function, status: "ok", result, chars, truncated? }or{ id, function, status: "error", code, message }.iddefaults to the position.okis true only when every call answered. - Defaults: 10 s per call (
timeout_ms, per call or per request), 16 KB per result (max_entry_bytes; a bigger result comes back as the first bytes of its JSON text withtruncated: trueand the fullchars), 12 calls per request (max_calls; more still runs, with a warning that the response may be too large to deliver; hard ceiling 64). - Same refusals as pipe steps, plus no nested batch and no pipe as a call. A batch is not a pipe step, and a pipe is not a batch call.
- Every refusal lists all the problems of the request, not only the first; fix them all in one resend.
completedandfailedcount the outcomes;okis true only whenfailedis 0. Same approval surface: the batch runs with this worker's authority.
Boundaries
- Steps run with THIS worker's authority, not the calling agent's per-step
dispatch policy — the
fp::pipecall itself is the policy/approval surface (an approver sees the full step list). For that reason the pipe is not agent-callable without approval by default; the pure transforms are. Seeiii-permissions.yaml. shell::*/coder::*steps run under the harness-forwarded filesystem scope: the harness stamps the trustedfs_scopeonto thefp::pipecall itself (harness/src/filesystem_scope.rs) and fp re-stamps it onto each scoped step as the last write before dispatch, overwriting anything authored or threaded at/fs_scope. Without a stamp (no session working directory, or a non-harness caller — cron, worker-to-worker) scoped steps are refused, fail-closed. A path-access rejection inside a pipe just fails the step; only a direct call offers the access-grant ladder.- Statically refused as steps:
fp::batchandfp::pipe(no nesting),engine::observers::dispose(observer control; agents observe throughharness::observe), nested pipes, and every class the agent policy hard-denies — session writes andsession::store::*,approval::*,configuration::*/oauth::*(credentials),router::*/provider::*(model spend),harness::*/run::*(turn control),stream::*(the deprecated iii-stream surface) and bus internals,*::on-config-change— because steps run with worker authority and must not ride past those denies. Session READS (session::get/list/messages*/get-message/get-attachment/list-attachments) are allowed, likedatabase::query: the policy only gates them behind approval, and the pipe call is that surface — pulling an attachment out of the session and threading it on is exactly what a pipe is for.state::*is the deliberate exception on the write side: persisting the threaded value is the pipe's purpose.state::claim-namespaceandprovider-openai-codex::state::*remain operator-only and cannot be pipe steps, even when the pipe itself is approved.
Skills
API reference (JSON)
{
"functions": [
{
"description": "Run several INDEPENDENT calls in one request and get every answer in place: { calls: [{ id?, function, payload?, namespace?, timeout_ms? }], concurrency?, stop_on_error?, timeout_ms? (default 10000 per call), max_entry_bytes? (default 16384), max_calls? (default 12; more only warns) } → { ok, completed, failed, results: [{ id, function, status: \"ok\", result, chars, truncated? } | { id, function, status: \"error\", code, message }], warnings }. Nothing is threaded between calls; for that use fp::pipe. A batch is not a pipe step and a pipe is not a batch call: fp::batch and fp::pipe cannot be calls, and the same refusals as pipe steps apply. ok is true only when every call answered; completed and failed count the outcomes. A refusal lists every problem in the request.",
"metadata": {},
"name": "fp::batch",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"BatchCall": {
"additionalProperties": false,
"properties": {
"function": {
"description": "Function id to call.",
"type": "string"
},
"id": {
"default": null,
"description": "Echoed on the result; defaults to the call's position (`\"0\"`, `\"1\"`, …).",
"type": [
"string",
"null"
]
},
"namespace": {
"default": null,
"description": "Namespace of the target function (default: this worker's; say `default` for the engine's).",
"type": [
"string",
"null"
]
},
"payload": {
"default": null
},
"timeout_ms": {
"default": null,
"description": "Budget for this call alone.",
"format": "uint64",
"minimum": 0,
"type": [
"integer",
"null"
]
}
},
"required": [
"function"
],
"type": "object"
}
},
"properties": {
"calls": {
"description": "Independent calls; results come back in this order.",
"items": {
"$ref": "#/definitions/BatchCall"
},
"type": "array"
},
"concurrency": {
"default": null,
"description": "How many run at once (default: all).",
"format": "uint32",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"max_calls": {
"default": null,
"description": "Calls per request before a warning (default 12).",
"format": "uint32",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"max_entry_bytes": {
"default": null,
"description": "Largest serialized result kept per entry (default 16384); a bigger one is cut to this many bytes of its JSON text and marked `truncated`.",
"format": "uint64",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"stop_on_error": {
"default": null,
"description": "Run in order and stop after the first error (default false: every call runs and reports).",
"type": [
"boolean",
"null"
]
},
"timeout_ms": {
"default": null,
"description": "Per-call budget when a call sets none (default 10000).",
"format": "uint64",
"minimum": 0,
"type": [
"integer",
"null"
]
}
},
"required": [
"calls"
],
"title": "BatchRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"BatchResult": {
"oneOf": [
{
"properties": {
"chars": {
"description": "Size of the full result (chars of its string or serialized form).",
"format": "uint",
"minimum": 0,
"type": "integer"
},
"function": {
"type": "string"
},
"id": {
"type": "string"
},
"result": true,
"status": {
"enum": [
"ok"
],
"type": "string"
},
"truncated": {
"description": "Set when `result` is a cut of the JSON text, not the value.",
"type": "boolean"
}
},
"required": [
"chars",
"function",
"id",
"result",
"status",
"truncated"
],
"type": "object"
},
{
"properties": {
"code": {
"type": "string"
},
"function": {
"type": "string"
},
"id": {
"type": "string"
},
"message": {
"type": "string"
},
"status": {
"enum": [
"error"
],
"type": "string"
}
},
"required": [
"code",
"function",
"id",
"message",
"status"
],
"type": "object"
}
]
}
},
"properties": {
"completed": {
"description": "Calls that answered with a result.",
"format": "uint",
"minimum": 0,
"type": "integer"
},
"failed": {
"description": "Calls that answered with an error, including `SKIPPED`.",
"format": "uint",
"minimum": 0,
"type": "integer"
},
"ok": {
"description": "True when every call answered `ok`.",
"type": "boolean"
},
"results": {
"items": {
"$ref": "#/definitions/BatchResult"
},
"type": "array"
},
"warnings": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"completed",
"failed",
"ok",
"results",
"warnings"
],
"title": "BatchResponse",
"type": "object"
}
},
{
"description": "Remove null elements from an array (lodash _.compact, null-only: 0, false and \"\" are KEPT). Pairs with fp::map, whose sporadic misses become null.",
"metadata": {},
"name": "fp::compact",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the value-only ops (uniq/size/compact/flatten/reverse).",
"properties": {
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ValueRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Harness observer guard: compare a JSON pointer inside the observed event and answer { decision: \"allow\" | \"skip\", reason }; config is { path?, op, to?, negate? } with the fp::when ops. A pointer that resolves to nothing SKIPS rather than erroring.",
"metadata": {},
"name": "fp::condition",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"ConditionConfig": {
"description": "The caller-authored half, out of the observer's `conditions[].config`.",
"properties": {
"negate": {
"default": false,
"description": "Invert the verdict — the only way to fire when the path is ABSENT (a path that never resolves then fires on every event).",
"type": "boolean"
},
"op": {
"allOf": [
{
"$ref": "#/definitions/WhenOp"
}
],
"description": "Comparison to run."
},
"path": {
"default": null,
"description": "JSON pointer into the event; defaults to the whole event.",
"type": [
"string",
"null"
]
},
"to": {
"default": null,
"description": "Right-hand side for the comparison ops; rejected for exists/not_empty."
}
},
"required": [
"op"
],
"type": "object"
},
"WhenOp": {
"description": "The comparison a `fp::when` guard runs.",
"enum": [
"==",
"!=",
">",
">=",
"<",
"<=",
"exists",
"not_empty"
],
"type": "string"
}
},
"description": "The condition envelope; `binding` and `context` are accepted and ignored.",
"properties": {
"condition_config": {
"anyOf": [
{
"$ref": "#/definitions/ConditionConfig"
},
{
"type": "null"
}
]
},
"event": true
},
"required": [
"event"
],
"title": "ConditionInput",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "The typed answer the harness condition contract expects.",
"oneOf": [
{
"properties": {
"decision": {
"enum": [
"allow"
],
"type": "string"
},
"reason": {
"type": "string"
}
},
"required": [
"decision",
"reason"
],
"type": "object"
},
{
"properties": {
"decision": {
"enum": [
"skip"
],
"type": "string"
},
"reason": {
"type": "string"
}
},
"required": [
"decision",
"reason"
],
"type": "object"
}
],
"title": "Decision"
}
},
{
"description": "Count array elements per plucked key (lodash _.countBy) into { \"<key>\": <count> }; path \"\" counts by the element itself. Same key rules as fp::groupBy.",
"metadata": {},
"name": "fp::countBy",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the keyed groupings (groupBy/countBy).",
"properties": {
"path": {
"description": "JSON pointer plucked from each element as the bucket key (`\"\"` = the element itself).",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"path",
"value"
],
"title": "GroupByRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Skip the first n elements of an array or the first n characters of a string (lodash _.drop).",
"metadata": {},
"name": "fp::drop",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"n": {
"description": "How many array elements / string characters to skip.",
"format": "uint32",
"minimum": 0,
"type": "integer"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"n",
"value"
],
"title": "DropRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Keep array elements whose properties equal a partial object (lodash _.filter with a matches iteratee). `matches` is a partial OBJECT, never a bare string/number; only object elements can match.",
"metadata": {},
"name": "fp::filter",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"matches": {
"additionalProperties": true,
"description": "Partial object an element's top-level properties must equal.",
"type": "object"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"matches",
"value"
],
"title": "FilterRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Flatten an array one level (lodash _.flatten).",
"metadata": {},
"name": "fp::flatten",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the value-only ops (uniq/size/compact/flatten/reverse).",
"properties": {
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ValueRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Extract the single value at a JSON pointer (lodash _.get). A miss names the keys that were available.",
"metadata": {},
"name": "fp::get",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"path": {
"description": "JSON pointer selecting the value to return (e.g. `/content`).",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"path",
"value"
],
"title": "GetRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Extract the value at a JSON pointer, or `default` when the path misses (lodash fp.getOr). A stored null is a hit, not a miss.",
"metadata": {},
"name": "fp::getOr",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"default": {
"description": "Returned when the path matches nothing (a stored null is a hit)."
},
"path": {
"description": "JSON pointer selecting the value to return (e.g. `/content`).",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"default",
"path",
"value"
],
"title": "GetOrRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Bucket array elements by a plucked key (lodash _.groupBy) into { \"<key>\": [element, ...] }; path \"\" groups by the element itself. Keys must be a string, number, or boolean; null or container keys error.",
"metadata": {},
"name": "fp::groupBy",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the keyed groupings (groupBy/countBy).",
"properties": {
"path": {
"description": "JSON pointer plucked from each element as the bucket key (`\"\"` = the element itself).",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"path",
"value"
],
"title": "GroupByRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Internal pre_generate hook: appends fp::pipe usage guidance to the agent system prompt. Observes harness::hook::on-pre-generate while inject_guidance is on; not called directly.",
"metadata": {
"internal": true
},
"name": "fp::inject-guidance",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"GenerateContext": {
"properties": {
"system_prompt": {
"default": "",
"description": "The system prompt assembled so far (base + any prior hook's mutation).",
"type": "string"
}
},
"type": "object"
}
},
"description": "The `pre_generate` hook envelope slice we read; the generation context is nested under `generate`.",
"properties": {
"generate": {
"$ref": "#/definitions/GenerateContext"
}
},
"title": "PreGenerateEvent",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"PreGenerateMutations": {
"description": "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.",
"properties": {
"system_prompt": {
"description": "Full replacement system prompt (base + appended guidance). The harness overwrites, it does not merge.",
"type": [
"string",
"null"
]
}
},
"type": "object"
}
},
"description": "Hook envelope returned to the harness: the mutations to apply to the generation.",
"properties": {
"mutations": {
"$ref": "#/definitions/PreGenerateMutations"
}
},
"required": [
"mutations"
],
"title": "PreGenerateResponse",
"type": "object"
}
},
{
"description": "Join array elements into one string (lodash _.join); separator defaults to \",\".",
"metadata": {},
"name": "fp::join",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"separator": {
"default": ",",
"description": "Separator between elements (default `\",\"`).",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "JoinRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Pluck the value at a JSON pointer from each array element (lodash _.map with a property iteratee). Sporadic misses become null (fp::compact drops them); a path matching NO element errors.",
"metadata": {},
"name": "fp::map",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"path": {
"description": "JSON pointer plucked from each element (e.g. `/id`); sporadic misses become null, a path matching no element errors.",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"path",
"value"
],
"title": "MapRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Find the largest number in an array (lodash _.max/_.maxBy); `path` plucks from each element first. Returns the NUMBER, not the element. An empty array errors.",
"metadata": {},
"name": "fp::max",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the numeric reductions (sum/mean/min/max).",
"properties": {
"path": {
"default": null,
"description": "JSON pointer plucked from each element before reducing (the lodash `…By` form).",
"type": [
"string",
"null"
]
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ReduceRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Average an array of numbers (lodash _.mean/_.meanBy); `path` plucks from each element first. Deviates from lodash: an EMPTY array errors instead of yielding NaN.",
"metadata": {},
"name": "fp::mean",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the numeric reductions (sum/mean/min/max).",
"properties": {
"path": {
"default": null,
"description": "JSON pointer plucked from each element before reducing (the lodash `…By` form).",
"type": [
"string",
"null"
]
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ReduceRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Find the smallest number in an array (lodash _.min/_.minBy); `path` plucks from each element first. Returns the NUMBER, not the element. An empty array errors.",
"metadata": {},
"name": "fp::min",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the numeric reductions (sum/mean/min/max).",
"properties": {
"path": {
"default": null,
"description": "JSON pointer plucked from each element before reducing (the lodash `…By` form).",
"type": [
"string",
"null"
]
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ReduceRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Return array element n (negative counts from the end, lodash _.nth). Out of bounds errors naming the length.",
"metadata": {},
"name": "fp::nth",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"n": {
"description": "Index to pluck; negative counts from the end (`-1` = last element).",
"format": "int64",
"type": "integer"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"n",
"value"
],
"title": "NthRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Drop top-level keys from an object (lodash _.omit).",
"metadata": {},
"name": "fp::omit",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"paths": {
"description": "Top-level keys to drop; missing keys are ignored.",
"items": {
"type": "string"
},
"type": "array"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"paths",
"value"
],
"title": "OmitRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Internal: reload fp settings from the authoritative configuration on change.",
"metadata": {
"internal": true
},
"name": "fp::on-config-change",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "The `configuration::on-updated` event, delivered as output to `<worker>::on-config-change`. Advisory only: handlers read `id` and re-fetch the authoritative value, so a direct call can never inject config.",
"properties": {
"id": {
"default": null,
"description": "Configuration id that changed.",
"type": [
"string",
"null"
]
}
},
"title": "OnConfigChangeEvent",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Ack returned by the internal `<worker>::on-config-change` handler.",
"properties": {
"ok": {
"type": "boolean"
}
},
"required": [
"ok"
],
"title": "OnConfigChangeResponse",
"type": "object"
}
},
{
"description": "Subset an object by top-level keys (lodash _.pick); missing keys are omitted.",
"metadata": {},
"name": "fp::pick",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"paths": {
"description": "Top-level keys to keep; missing keys are silently omitted.",
"items": {
"type": "string"
},
"type": "array"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"paths",
"value"
],
"title": "PickRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Run a worker-side pipeline: each step calls a function and its result lands in the next step's payload at `into` (default \"/value\"); fp::* steps thread the bare value and a failing fp::when stops the pipe. The FIRST step gets no threaded value. Returns per-step sizes and a preview, not the value. A pipe is a chain, not a batch: fp::batch and fp::pipe cannot be steps (no nesting), and neither can engine::observers::dispose, configuration::, oauth::, router::, provider::, harness::, run::, session writes or approval::. For independent calls use fp::batch. A refusal lists every problem in the request.",
"metadata": {},
"name": "fp::pipe",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"PipeStep": {
"additionalProperties": false,
"properties": {
"function": {
"description": "Function id to call.",
"type": "string"
},
"into": {
"default": null,
"description": "JSON pointer in this step's payload where the previous value lands (default `/value`); object keys only, no array indexing.",
"type": [
"string",
"null"
]
},
"payload": {
"default": null,
"description": "Base payload for the call."
}
},
"required": [
"function"
],
"type": "object"
}
},
"properties": {
"preview_chars": {
"default": null,
"description": "Preview length of the final threaded value in the receipt (capped at 8000).",
"format": "uint32",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"through": {
"description": "Steps run in order; step N+1 receives step N's threaded value.",
"items": {
"$ref": "#/definitions/PipeStep"
},
"type": "array"
}
},
"required": [
"through"
],
"title": "PipeRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"StepReceipt": {
"properties": {
"chars": {
"description": "Size of the value threaded OUT of this step (chars of its string or serialized form).",
"format": "uint",
"minimum": 0,
"type": "integer"
},
"function": {
"type": "string"
},
"note": {
"description": "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.",
"type": [
"string",
"null"
]
}
},
"required": [
"chars",
"function"
],
"type": "object"
}
},
"properties": {
"short_circuited": {
"description": "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.",
"type": "boolean"
},
"steps": {
"items": {
"$ref": "#/definitions/StepReceipt"
},
"type": "array"
},
"value_preview": {
"type": [
"string",
"null"
]
}
},
"required": [
"short_circuited",
"steps"
],
"title": "PipeResponse",
"type": "object"
}
},
{
"description": "Reverse an array (lodash _.reverse, immutable like lodash/fp).",
"metadata": {},
"name": "fp::reverse",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the value-only ops (uniq/size/compact/flatten/reverse).",
"properties": {
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ValueRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Count a collection (lodash _.size): array length, string chars, or object key count. Non-collections error instead of returning 0.",
"metadata": {},
"name": "fp::size",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the value-only ops (uniq/size/compact/flatten/reverse).",
"properties": {
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ValueRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Sort array elements ascending by the value at a JSON pointer (lodash _.sortBy, stable); path \"\" sorts the elements themselves. Keys must all be numbers, strings, or booleans. Pair with fp::reverse for descending.",
"metadata": {},
"name": "fp::sortBy",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"path": {
"description": "JSON pointer plucked from each element as the sort key (e.g. `/score`).",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"path",
"value"
],
"title": "SortByRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Split a string into an array of strings (lodash _.split).",
"metadata": {},
"name": "fp::split",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"separator": {
"description": "Non-empty separator to split on (e.g. `\"\\n\"`).",
"type": "string"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"separator",
"value"
],
"title": "SplitRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Total an array of numbers (lodash _.sum/_.sumBy); `path` plucks the addend from each element first. An empty array totals 0; a non-numeric element errors rather than being skipped.",
"metadata": {},
"name": "fp::sum",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the numeric reductions (sum/mean/min/max).",
"properties": {
"path": {
"default": null,
"description": "JSON pointer plucked from each element before reducing (the lodash `…By` form).",
"type": [
"string",
"null"
]
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ReduceRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Keep the first n elements of an array or the first n characters of a string (lodash _.take).",
"metadata": {},
"name": "fp::take",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"n": {
"description": "How many array elements / string characters to keep.",
"format": "uint32",
"minimum": 0,
"type": "integer"
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"n",
"value"
],
"title": "TakeRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Deduplicate an array, keeping first occurrences (lodash _.uniq).",
"metadata": {},
"name": "fp::uniq",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Shared request for the value-only ops (uniq/size/compact/flatten/reverse).",
"properties": {
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"value"
],
"title": "ValueRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"value": true
},
"required": [
"value"
],
"title": "UtilResponse",
"type": "object"
}
},
{
"description": "Guard: test the value at a JSON pointer (`path` defaults to the whole value; a pointer miss FAILS, never errors) and return { passed, value }. As a fp::pipe step a passing guard threads the ORIGINAL value onward and a failing one STOPS the pipe (`short_circuited: true`).",
"metadata": {},
"name": "fp::when",
"request_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"WhenOp": {
"description": "The comparison a `fp::when` guard runs.",
"enum": [
"==",
"!=",
">",
">=",
"<",
"<=",
"exists",
"not_empty"
],
"type": "string"
}
},
"properties": {
"op": {
"allOf": [
{
"$ref": "#/definitions/WhenOp"
}
],
"description": "Comparison to run."
},
"path": {
"default": null,
"description": "JSON pointer selecting what to test (default: the whole value).",
"type": [
"string",
"null"
]
},
"to": {
"default": null,
"description": "Right-hand side for the comparison ops; rejected for exists / not_empty."
},
"value": {
"description": "Input value (a pipe lands the previous step's value here)."
}
},
"required": [
"op",
"value"
],
"title": "WhenRequest",
"type": "object"
},
"response_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"passed": {
"type": "boolean"
},
"value": {
"description": "The ORIGINAL input value, untouched — guards test, they never reshape."
}
},
"required": [
"passed",
"value"
],
"title": "WhenResponse",
"type": "object"
}
}
]
}