foley.agent.verbs#
foley’s JSON-safe verbs: the one table the MCP server and the CLI are built from (#62).
Each verb is a plain function, JSON in and JSON out, a thin call into the façade: it
takes and returns only JSON (ids, scores, licence summaries, timeline dicts, store keys),
never a Candidate, a WeaveResult or numpy
audio. VERBS lists them with the surfaces they are on: foley.agent.mcp
serves them as MCP tools, foley.cli.build_parser() as foley commands, and
surface_snapshot() pins what both expose.
The verbs share one injectable state (the library, the session factory, the byte store,
the bound runtime, the server’s spend budget), set by _configure(). Nothing here
imports a surface library: py2mcp / fastmcp load inside
foley.agent.mcp.build_mcp_server() only, cw inside the CLI.
Module Attributes
MCP's tools and the CLI's generated commands are both read from it. |
|
The MCP tool surface at import, in the table's order (kept for callers that read it; the server reads |
Functions
What foley can do here — keys / extras / system deps / offline / sources / degraded. |
|
|
Remove a previously-picked sound from the session. |
|
Edit a library sound into a new one (paid): audio-to-audio, inpaint or extend. |
|
Find verified, license-clean sound candidates for a narrative passage. |
|
Generate a sound from a text prompt (local backends only when offline). |
How to sound-design a narration with foley — the operating playbook for an agent. |
|
|
The sounds picked in this session (the 'persist picks' read side). |
|
Shift a timeline item's onset by |
|
Accept a sound into the session (persisted); |
|
Fold picks (or explicit candidate ids) into a JSON sound-design timeline. |
|
Produce a short audition of a sound; returns its store key (never audio bytes). |
|
Relevance-feedback refinement: expand the query, boost picks, drop rejects, re-rank. |
|
Reject a sound (feeds |
|
Score a narration passage → an editable sound-design timeline + a per-event rationale. |
|
Hybrid (CLAP + keyword) search of the library for a text query; returns candidate rows. |
|
Set a timeline item's gain (dB); returns the new timeline. |
|
Set the timeline's master target (LUFS / true-peak); returns the new timeline. |
|
"More like this" — the library neighbours of a sound (by id); returns candidate rows. |
|
The current runtime posture + this session's pick/reject counts. |
|
Swap a timeline item's clip; returns the new timeline. |
|
Export SDH captions for a timeline ( |
|
Mute/unmute a timeline item; returns the new timeline. |
|
Render a timeline under the narration; returns the mix by store key + captions + credits. |
|
|
Classes
|
One verb of foley's JSON-safe surface: the function and the surfaces it is on (#62). |
- foley.agent.verbs.TOOLS = [<function foley_find>, <function foley_search>, <function foley_similar_to>, <function foley_preview>, <function foley_refine>, <function foley_pick>, <function foley_drop_pick>, <function foley_reject>, <function foley_list_picks>, <function foley_generate>, <function foley_edit>, <function foley_plan>, <function foley_weave>, <function foley_swap_clip>, <function foley_set_gain>, <function foley_nudge>, <function foley_toggle>, <function foley_set_master>, <function foley_timeline_captions>, <function foley_score>, <function foley_guide>, <function foley_capabilities>, <function foley_status>]#
The MCP tool surface at import, in the table’s order (kept for callers that read it; the server reads
VERBSwhen it is built).
- foley.agent.verbs.VERBS = (Verb(fn=<function foley_find>, mcp=True, cli=True, why=''), Verb(fn=<function foley_search>, mcp=True, cli=False, why="the CLI's own `foley search` prints readable rows (it predates the table)"), Verb(fn=<function foley_similar_to>, mcp=True, cli=True, why=''), Verb(fn=<function foley_preview>, mcp=True, cli=True, why=''), Verb(fn=<function foley_refine>, mcp=True, cli=True, why=''), Verb(fn=<function foley_pick>, mcp=True, cli=True, why=''), Verb(fn=<function foley_drop_pick>, mcp=True, cli=True, why=''), Verb(fn=<function foley_reject>, mcp=True, cli=True, why=''), Verb(fn=<function foley_list_picks>, mcp=True, cli=True, why=''), Verb(fn=<function foley_generate>, mcp=True, cli=True, why=''), Verb(fn=<function foley_edit>, mcp=True, cli=True, why=''), Verb(fn=<function foley_plan>, mcp=True, cli=True, why=''), Verb(fn=<function foley_weave>, mcp=True, cli=True, why=''), Verb(fn=<function foley_swap_clip>, mcp=True, cli=True, why=''), Verb(fn=<function foley_set_gain>, mcp=True, cli=True, why=''), Verb(fn=<function foley_nudge>, mcp=True, cli=True, why=''), Verb(fn=<function foley_toggle>, mcp=True, cli=True, why=''), Verb(fn=<function foley_set_master>, mcp=True, cli=True, why=''), Verb(fn=<function foley_timeline_captions>, mcp=True, cli=True, why=''), Verb(fn=<function foley_score>, mcp=True, cli=True, why=''), Verb(fn=<function foley_guide>, mcp=True, cli=True, why=''), Verb(fn=<function foley_capabilities>, mcp=True, cli=True, why=''), Verb(fn=<function foley_status>, mcp=True, cli=True, why=''))#
MCP’s tools and the CLI’s generated commands are both read from it.
- Type:
The verb table (SSOT), in a stable order
- class foley.agent.verbs.Verb(fn, mcp=True, cli=True, why='')[source]#
Bases:
objectOne verb of foley’s JSON-safe surface: the function and the surfaces it is on (#62).
The function is the verb: JSON in, JSON out, a thin call into the façade. MCP serves it as the tool
fn.__name__; thefoleyCLI as the command of that name without itsfoley_prefix (foley.cli.build_parser()). Adding a verb here adds it to both, with no surface code.
- foley.agent.verbs.foley_capabilities()[source]#
What foley can do here — keys / extras / system deps / offline / sources / degraded.
- Return type:
- foley.agent.verbs.foley_drop_pick(sound_id, session='default')[source]#
Remove a previously-picked sound from the session.
- Return type:
- foley.agent.verbs.foley_edit(sound_id, op, prompt='', *, backend=None, commercial_ok=True, session='default', territory=None, strength=None, inpaint_start_s=None, inpaint_end_s=None, extend_before_s=None, extend_after_s=None)[source]#
Edit a library sound into a new one (paid): audio-to-audio, inpaint or extend.
op:audio_to_audio(regenerate the whole clip;strength0..1, how far from the source),inpaint(regenerateinpaint_start_s..``inpaint_end_s``, keep the rest) orextend(extend_before_sand/orextend_after_sseconds of new sound).prompt: what the result should sound like (default: the source’s caption).backend: an edit backend doingop(default: the op’s, which runs only once the host opted in to paid generation).The new sound is stored in the library and cached in the session (pick it like any candidate); its licence is the backend’s narrowed to the source’s, and credits the source. Refused before anything is paid for when the source’s rights do not allow an edit, or the edit could not serve this call’s intent (
commercial_ok,territory): an edit of a non-commercial sound is non-commercial.- Return type:
- foley.agent.verbs.foley_find(context, max_events=6, verify='listen', commercial_ok=True, k=10, session='default', territory=None)[source]#
Find verified, license-clean sound candidates for a narrative passage.
Caches the full candidates in the session so
foley_plan/foley_weavecan rehydrate them by id. Returns compact candidate rows.territory: where the sound is used (an ISO country code, or"WORLD"for online publishing); a licence that excludes territories is refused while it is unstated.- Return type:
- foley.agent.verbs.foley_generate(prompt, backend='auto', commercial_ok=True, session='default', territory=None, preset=None)[source]#
Generate a sound from a text prompt (local backends only when offline).
backend='auto'tries the host’s generation order (ElevenLabs direct first, then the fal backends, then the local Stable Audio Open; the paid ones only when the host opted in with$FOLEY_GENERATE_PAID=1;$FOLEY_GENERATE_ORDER/$FOLEY_GENERATE_BACKENDchange it), skipping what is not configured or not allowed offline; name one to choose (fal_stable_audio_3,elevenlabs, …).A clip QC would quarantine for a clipped run just over the gate is repaired and stored (the repair is in the result’s notes). A refused generation’s dict carries
cache_key: where its paid bytes are in the generations cache (foley.generations.get(cache_key), on the host — bytes never travel over MCP).territory: where the sound is used (an ISO country code, or"WORLD"); a backend whose licence excludes territories (HunyuanVideo-Foley) needs it stated.preset: a category preset for a procedural backend (backend='pyfxr':laser,pickup,explosion, …); other backends ignore it with a note.- Return type:
- foley.agent.verbs.foley_guide()[source]#
How to sound-design a narration with foley — the operating playbook for an agent.
Call this first if you are unsure of the workflow: it returns the tool order, the taste heuristics (restraint, layering, ducking, licensing), and the offline posture.
- Return type:
- foley.agent.verbs.foley_list_picks(session='default')[source]#
The sounds picked in this session (the ‘persist picks’ read side).
- Return type:
- foley.agent.verbs.foley_nudge(timeline, item_id, delta_s)[source]#
Shift a timeline item’s onset by
delta_sseconds; returns the new timeline.- Return type:
- foley.agent.verbs.foley_pick(sound_id, session='default', layer=None, onset=None)[source]#
Accept a sound into the session (persisted);
foley_planfolds picks into a timeline.- Return type:
- foley.agent.verbs.foley_plan(session='default', transcript=None, candidate_ids=None, commercial_ok=True, territory=None)[source]#
Fold picks (or explicit candidate ids) into a JSON sound-design timeline.
Each pick’s explicit
layer/onset(set viafoley_pick()) is overlaid onto its candidate’sSoundEventsoplanhonors the agent’s placement choices — a numericonsetbecomes an absolute-seconds anchor (seefoley.weave.anchor.parse_symbolic_anchor()).Every pick is re-checked under this call’s intent (
commercial_ok,territory), whatever it was found under, on the library’s current record (the onefoley_weave()judges; the cached one only for a sound the library no longer has): one the intent does not keep refuses the plan, naming each such id and why (#191).- Return type:
- foley.agent.verbs.foley_preview(sound_id, seconds=6, session='default')[source]#
Produce a short audition of a sound; returns its store key (never audio bytes).
- Return type:
- foley.agent.verbs.foley_refine(session='default', query=None, picked_ids=None, rejected_ids=None, hint=None, k=10, commercial_ok=True, territory=None)[source]#
Relevance-feedback refinement: expand the query, boost picks, drop rejects, re-rank.
Gated like
foley_search(): only results the intent (commercial_ok,territory) keeps come back, and are cached (#191).- Return type:
- foley.agent.verbs.foley_reject(sound_id, session='default', reason=None)[source]#
Reject a sound (feeds
foley_refinerelevance feedback).- Return type:
- foley.agent.verbs.foley_score(context, commercial_ok=True, verify='listen', max_events=6, session='default', territory=None, allow_generate=True)[source]#
Score a narration passage → an editable sound-design timeline + a per-event rationale.
The one-call SELECT→plan entry for an agent: pass the narration text and get back a JSON timeline plus a rationale for each chosen sound. Weaving (rendering the mastered mix) is a separate step (
foley_weave) so you can review / edit the timeline first — swap a clip, nudge an onset, drop a cue — before committing to a render.territory: where the sound is used (an ISO country code, or"WORLD"for online publishing); a licence that excludes territories is refused while it is unstated.allow_generate=False: retrieval only (no generation fallback, no generation spend).- Return type:
- foley.agent.verbs.foley_search(query, k=10, commercial_ok=True, ucs_category=None, rerank=False, session='default', territory=None)[source]#
Hybrid (CLAP + keyword) search of the library for a text query; returns candidate rows.
Only sounds whose licence serves the intent (
commercial_ok,territory; seefoley_find()) come back, eachlicense_ok(#191).- Return type:
- foley.agent.verbs.foley_set_gain(timeline, item_id, gain_db)[source]#
Set a timeline item’s gain (dB); returns the new timeline.
- Return type:
- foley.agent.verbs.foley_set_master(timeline, target_lufs=None, peak_dbfs=None)[source]#
Set the timeline’s master target (LUFS / true-peak); returns the new timeline.
Either field may be set independently — omitting one keeps the podcast default for that field (so
peak_dbfs=-2.0alone tightens only the true-peak ceiling).- Return type:
- foley.agent.verbs.foley_similar_to(sound_id, k=10, commercial_ok=True, session='default', territory=None)[source]#
“More like this” — the library neighbours of a sound (by id); returns candidate rows.
Gated like
foley_search(): only neighbours the intent keeps (#191).- Return type:
- foley.agent.verbs.foley_status(session='default')[source]#
The current runtime posture + this session’s pick/reject counts.
- Return type:
- foley.agent.verbs.foley_swap_clip(timeline, item_id, sound_id)[source]#
Swap a timeline item’s clip; returns the new timeline.
- Return type:
- foley.agent.verbs.foley_timeline_captions(timeline, fmt='vtt')[source]#
Export SDH captions for a timeline (
fmt='vtt'|'srt').- Return type:
- foley.agent.verbs.foley_toggle(timeline, item_id, enabled)[source]#
Mute/unmute a timeline item; returns the new timeline.
- Return type:
- foley.agent.verbs.foley_weave(narration, timeline, session='default', commercial_ok=True, territory=None)[source]#
Render a timeline under the narration; returns the mix by store key + captions + credits.
Every enabled clip is re-checked under this call’s intent (
commercial_ok,territory), and so is the narration when it is a library sound (astrwith a record there; a narration that is only audio has no licence to check): one the intent does not keep refuses the render, naming each such id and why (#191).- Return type:
- foley.agent.verbs.surface_snapshot(verbs=None)[source]#
{tool name: {parameter: default}}of the MCP tools, plus the CLI commands.What an agent or a script binds to by name, without py2mcp: a test pins it, so a renamed tool or a changed default is a decision, never an accident (#62). A parameter with no default maps to
"<required>".- Return type: