ToolWrapper — external tool-plugin facade
Diese Seite ist derzeit nur englisch — die JSDoc-Kommentare in der Engine sind englisch verfasst. Eine deutsche Auto-Generierung folgt, sobald die Methoden mit
@apidoc-de-Tags ausgestattet sind. — Zur Übersicht
ToolWrapper is the chainable facade over an external tool plugin (rmbg, facedetect, mlcsd, …). Returned by Engine.tool(name).
Classes
ToolWrapper
Wrapper around a Go-side tool plugin. Engine.tool('rmbg').apply(img),
Engine.tool('mlcsd-txt2img').apply({ prompt: 'a cat' }), etc.
Tools without a reference image (synthesisers, text-to-image
generators) can be invoked with just opts: apply({prompt: …}).
A 1×1 transparent placeholder is synthesised so the FFI stays happy.
Constructors
Constructor
new ToolWrapper(name): ToolWrapper;
Parameters
| Parameter | Type |
|---|---|
name |
string |
Returns
Methods
apply()
apply(inputOrOpts?, opts?): ImageHandle;
Run the tool on input with optional scalar opts.
Returns a fresh ImageHandle. When the first argument is a
plain object instead of an ImageHandle, it is interpreted as
opts and a 1×1 transparent dummy image is supplied.
Parameters
| Parameter | Type |
|---|---|
inputOrOpts? |
Record<string, unknown> | ImageHandle |
opts? |
Record<string, unknown> |
Returns
applyJSON()
applyJSON<T>(inputOrOpts?, opts?): T;
Run a JSON-output tool — one whose manifest declares
outputs:[{format:"json"}]. Returns the parsed JSON. The tool
still receives the input image (so it can do detection /
classification on pixels), it just doesn't produce a new image.
Same input-optional rule as apply(): pass opts directly when the tool doesn't need a reference image.
Used by Engine.detectFaces() and similar typed wrappers.
Type Parameters
| Type Parameter | Default type |
|---|---|
T |
unknown |
Parameters
| Parameter | Type |
|---|---|
inputOrOpts? |
Record<string, unknown> | ImageHandle |
opts? |
Record<string, unknown> |
Returns
T
applyMany()
applyMany(inputs, opts?): Record<string, ImageHandle>;
Run the tool with multiple inputs, possibly per slot. inputs
keys must match the tool manifest's inputs[].key; values are
either a single ImageHandle or a list (for multi=true slots).
v1 supports a single output slot — the result is returned as
{ OUTPUT: ImageHandle } for shape-compat with the eventual
multi-output API.
Parameters
| Parameter | Type |
|---|---|
inputs |
Record<string, | ImageHandle | ImageHandle[]> |
opts? |
Record<string, unknown> |
Returns
Record<string, ImageHandle>