feat(image-gen-fal): port the fal.ai image tool to a WIT component plugin - #152
Open
JordanTheJet wants to merge 2 commits into
Open
feat(image-gen-fal): port the fal.ai image tool to a WIT component plugin#152JordanTheJet wants to merge 2 commits into
JordanTheJet wants to merge 2 commits into
Conversation
…ugin
The `image_gen_fal` tool has had no source in this repo. It was developed under
`plugins/image-gen-fal` in the zeroclaw tree, moved out by "chore(plugins): move
example plugins out of the main tree", and then deleted outright by #8137
("scope plugin config per-alias and remove raw env access"). Only the compiled
0.1.0 zip survived as a release asset, so the capability existed with nothing
maintainable behind it. This restores it here, where it belongs.
Not a copy — a port. The 0.1.0 source targeted the retired extism ABI
(`#[plugin_fn]`, `zc_env_read`, `zc_http_request`). This rewrites it against the
`tool-plugin` world in `wit/v0`, following `redact-text` as the reference:
* Credentials move from environment to config. 0.1.0 read `FAL_API_KEY` from the
process environment; #8137 removed raw env access from plugins, so the key now
comes from this plugin's own jailed config section, injected into `execute`
args as `__config`. The manifest requests `config_read` instead of `env_read`
(which now only survives as a serde alias for `ConfigRead`). Breaking for
0.1.0 users, hence 0.2.0 and a migration note in the README.
* HTTP moves to `wasi:http` via `waki`, replacing the host-function shim.
* Pure logic is split into `src/fal.rs` with no wasm dependency so it is
host-testable with a plain `cargo test`; `src/lib.rs` is a thin component shim.
Behavior from 0.1.0 is preserved: same tool name, same parameters and defaults,
same `https://fal.run/<model>` contract, same `/images/0/url` extraction, and the
same model-identifier validation that blocks `..`, `?`, `#`, `\`, and a leading
`/` from reaching the request URL. Error bodies are still clipped to 500 chars so
an upstream HTML error page cannot flood the agent's context.
17 host tests cover argument defaulting and validation, config-based key
resolution (including asserting the error does not send operators back to the
removed env flow), response parsing, truncation, and the schema. Builds clean to
a wasm32-wasip2 component (317 KB, layer 1, exports zeroclaw:plugin, imports
wasi:http); clippy is clean.
registry.json is intentionally untouched — the publish workflow generates it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
image_gen_faltool has had no source in this repo. It was developed underplugins/image-gen-falin the zeroclaw tree, moved out by "chore(plugins): move example plugins out of the main tree", then deleted outright by #8137 ("scope plugin config per-alias and remove raw env access"). Only the compiledimage-gen-fal-0.1.0.zipsurvived as a release asset — the capability existed with nothing maintainable behind it. This restores it here, where it belongs.Not a copy — a port
The 0.1.0 source targeted the retired extism ABI (
#[plugin_fn],zc_env_read,zc_http_request). This rewrites it against thetool-pluginworld inwit/v0, followingredact-textas the reference:FAL_API_KEYfrom the process environment. #8137 removed raw env access from plugins, so the key now comes from this plugin’s own jailed config section, injected intoexecuteargs as__config. The manifest requestsconfig_readrather thanenv_read— which now survives only as a serde alias forConfigRead. Breaking for 0.1.0 users, hence0.2.0plus a migration note in the README.wasi:httpviawaki, replacing the host-function shim.src/fal.rswith no wasm dependency, so it is host-testable with a plaincargo test;src/lib.rsis a thin component shim.Behavior preserved from 0.1.0
Same tool name, parameters and defaults, the same
https://fal.run/<model>contract, the same/images/0/urlextraction, and the same model-identifier validation blocking..,?,#,\, and a leading/from reaching the request URL. Upstream error bodies are still clipped to 500 chars so an HTML error page cannot flood the agent’s context.Verification
wasm32-wasip2component: 317 KB, layer 1, exportszeroclaw:plugin, importswasi:http.registry.jsonis intentionally untouched — the publish workflow generates it.Follow-up (not in this PR)
Removing
zeroclaw-tools/src/image_gen.rsfrom core is a separate zeroclaw PR. It touchesconfig/schema.rs(ImageGenConfig, the[image_gen]section and fixture), so by convention it is milestoned v0.9.0; two test files (providers/multimodal.rs,runtime/agent/dispatcher.rs) assert generic image-marker canonicalization usingimage_genas the fixture and will need a replacement rather than deletion.