Contributing an editor task
A plugin adds a job the Image editor can offer, such as "Colorize a region", with editor_tasks in
manifest.yml. Disabling the plugin removes its tasks.
editor_tasks:
- id: my-plugin.colorize
label: Colorize a region
icon: palette
editors: [image]
region: required
prompt: optional
produces: patch
fallback:
task: edit_region
prompt: Colorize the marked area naturally.The id must start with your plugin id and a dot; ids without a dot belong to core. region and
prompt are required, optional or none. A fallback names a task to run, with a built-in prompt,
when no mode offers this one; the prompt may contain {prompt}, which a run replaces with the user's text. grows: true marks a task whose result is larger than the picture (the way core's
expand is); its runs carry an expand canvas instead of a region (see Editor runs).
Optional keys that shape the run (all default to the old behaviour):
| Key | Meaning |
|---|---|
produces | patch (default), replace, or matte: the run returns the model's RGBA picture at the picture's size instead of a patch. |
grow | 0 to 0.5, default 0. The marked region is grown by this fraction of its longer side (at least 6 px) before the run. |
feather | 0 to 8, default 1. A multiplier on the stitch feather. |
matte | true: the region is a soft matte, kept grayscale and used as the patch alpha. |
internal | true: no rail tool; the task is run by other tools. |
An editor mode may also set instruction:, the prompt sent for a task whose prompt is none
(Editor modes).
A task is offered by presets, not by the manifest: an editor mode names it in its editor_mode.yml
(Editor modes). An editor mode that belongs to your plugin (a preset from your
presets: root, or an editor_modes/ directory under a preset_modes: root, which can target a preset your
plugin does not own) may name your task and the core tasks. An editor mode of another plugin that names your task
is rejected by lint.
src.plugin_api.editor exports TaskDefinition, the shape the host keeps for every registered task.
What the host does with a task:
- The server keeps one task registry. Core registers
edit_region,remove_object,replace_backgroundandfind_subject; a plugin's entries are added when it is enabled and dropped when it is disabled. An id that another source already holds is refused, so a plugin cannot replace a core task.editorsdefaults to[image]. GET /api/editor/tasks?editor=imagelists the registered tasks for that editor, each withoffers(the modes the caller may use that declare it, or that reach it through the task'sfallback; empty when none does) and the caller'sdefaultsetup.POST /api/editor/tasks/{task}/runsstarts a run: one Generate press in the editor. The server prepares the picture and region from the editor mode, submits a normal generation, and blends each result back as a patch.GET /api/editor/runs/{id}follows it,DELETE /api/editor/runs/{id}cancels it, andeditor_run_updateon/ws/generationannounces each change to the run's owner.PUTandDELETE /api/editor/tasks/{task}/defaultset and clear the caller's default setup for a task.- Every route, field and error is in Generative edits in the editor.
producesacceptspatchandreplace. A run creates patches whichever is declared, so writepatch.
The Image editor adds each task the server lists to its Generate group as a rail tool, with the editor's own
options and a Settings panel. Name a rail tool of your own with task: <task id> in editor_tools to replace
that tool; the editor then adds no rail tool for the task.