Commit Graph
3 Commits
Author SHA1 Message Date
Jeremy 8d74c5d2b9 feat(ai-features): let each built-in engine follow its own recipe (#83)
* feat(ai-core): share the image.segment request and result contract

* fix(ai-core): take only an inline PNG as the selection mask

* feat(ai-engine-rten): bounded picture decoding, mask encoding and resampling for selection models

* feat(ai-engine-rten): run SAM 2.1 through the shared selection contract

* fix(ai-engine-rten): bound a thin picture's memory, refuse extreme sides, and make the mask size fallible

* feat(ai-features): let each built-in engine follow its own recipe

A built-in engine now plans, offers, registers and checks files from the first usable recipe that
lists it (`Feature::engine_recipe`), instead of every engine acting on the first usable recipe.
A first recipe that lists one engine no longer hides a later recipe that lists another. The plain
built-in offer and engine advice still start from the first usable recipe, and `Feature::engines`
lists every engine some usable recipe names, once each, in catalogue order.

The catalogue is unchanged, so no behaviour changes today; the tests build the two-recipe shape
from the real SAM 3 recipe.

* fix(ai-engine-rten): judge a match on the mask handed on, not on the raw logits

A review finding: matched was set from the model's raw logits before resampling and 8-bit
quantization, so one positive logit that a small picture never samples reported a match with an
all-black mask. The match is now whether any pixel of the emitted mask is above half, using the
same quantization as the PNG. Written first and seen to fail (matched stayed true for a speck at
logit 8 in a 10 by 6 picture). The runner's raw-logit test stays as a shortcut that skips the
resampling; forcing it open gives the same answer, so its mutation case is retired with the reason
in the group header.

* docs(mutation): point the usage text at GROUPS instead of a list that was out of date

A review finding: the usage line named only the early groups and left out rt, which is new here,
and also seg, gs and others. A list in the usage text goes stale each time a group is added, so
it now says to take the group from GROUPS and README.md.
2026-10-21 23:10:24 +01:00
Jeremy f52feba1f6 feat(ai-client): a setup session with approval, one running request and worker-safe answers (#71)
* feat(ai-features): plan and offer a built-in runtime's own files

plan_native and setup_offer_native compare the files a runtime reads, which are a different
layout from the ComfyUI checkpoint, and need neither ComfyUI nor its node packs. Setup options
gain Route::Native (native:<feature>:<provider>) for each runtime that names files. A runtime
with no files of its own gets no plan, no offer and no option. The built-in install offer now
lists the runtime's three files, not the ComfyUI checkpoint.

* feat(ai-client): find, check and download a built-in runtime's own files

NativeSetupPlan is an immutable, reviewable plan for one runtime's files: where they are, where a download would go, how many bytes are still needed. FolderDesk finds a runtime's files in the person's folders (only together in one directory), hashes them before reuse, and downloads only into the chosen default folder, with licence approval. The folder scan lists a runtime's tokenizer files on an exact name and size. The picker lists a runtime as needing an adapter when the app has none.

* feat(ai-client): a setup session with approval, one running request and worker-safe answers

SetupSession keeps the licence approval, one running request with a ticket, and cancel. It refuses late, stale and foreign answers, progress for the wrong request, and a result for a different reviewed directory or runtime. Starting a download consumes the approval. Mutation group nq covers these rules.

* fix(ai-features): one recipe rule for every built-in runtime path, and a build that compiles alone

Planning, the Install offer and the setup options stopped at the first recipe, while registration
and engine advice used the first usable one. An unusable recipe in front hid a usable one behind
it, and two recipes naming one runtime gave two options with the same id.

`Feature::first_usable_recipe` is now the one rule. `plan_native`, the built-in Install offer and
`setup_options` use it, and each runtime gets a single option.

The picker's route match gets a Native arm that lists nothing yet, so this change builds on main
without the next one.

* fix(ai-client): skip a registered folder that has gone, use the first usable recipe, test with and without Candle

- `native_files` no longer fails every native call when one registered folder is missing (an
  unplugged drive, a deleted folder). That folder is not a candidate; the others are still read.
- `native_route` uses `Feature::first_usable_recipe`, the rule the planner and the setup options
  now share, so a Set up link that the picker shows can be followed.
- The picker tests accept the built-in engine either as NotSetUp (Candle built in) or as
  NeedsAdapter (not built in), as `picker_native` already did.

Merges the fix to #69 (one recipe rule, and the picker's Native arm).

* fix(ai-client): progress cannot cancel a download, and a lost model file can be set up again

- `SetupSession::review` compares only what the person approved (tool, runtime, destination and
  availability, `NativeSetupPlan::same_target`). The bytes still needed and the directory where
  files were found change as a download runs, so a fresh plan for the same target no longer
  cancels the worker, clears the approval or drops the verified result.
- A built-in model whose saved connection has lost its weights file is listed with its Set up
  link again, and says the files are missing, instead of showing a connection with no way back.

Merges the fixes to #69 and #70.

* fix(ai-features): list every local model before any built-in runtime

A tool with a built-in runtime put its option ahead of a later tool's local models, which broke
the documented order. Runtimes are now collected apart and added after all local options and
before hosted services.

* fix(ai-client): a result belongs to its directory, and a built-in option matches its own model

- `SetupSession::review` drops a checked result when a later plan for the same target finds the
  files in another directory, so the widget cannot offer to use the old one. Progress in the same
  directory still keeps it.
- The picker hides a built-in option only for the connection that option saves
  (`local-<feature>-<provider>`), not for any connection of the same runtime and role.

Merges the ordering fix to #69.

* fix(ai-features): the built-in Install offer agrees to words that match what it does

The offer reused the ComfyUI terms, which promise that everything stays in the app's own folder
and that ComfyUI is installed. The built-in route installs no ComfyUI and saves into the model
folder the person chose. `agreement_for(route)` gives it its own wording and version; the ComfyUI
route keeps `agreement()` unchanged. The wording is still draft, like the original.

* feat(ai-features): a native setup option names its model

Route::Native carries the model id its connection will have, so the picker can tell a saved
connection for this model from one for another model of the same runtime.

* fix(ai-client): match a built-in option to its own model, and drop a late result for a moved-from directory

- The picker hides a built-in option only for a saved connection whose model id is the one the
  option names (`Route::Native::model`), so an older model on the same connection id does not
  hide the current one.
- A worker's answer that arrives after a review moved to another directory is accepted as the
  running request's answer but not kept as a checked result, and is not an error.

* fix(ai-features): the built-in terms name the Download click

The built-in flow's control is Download, not Install, so its terms now say Download.

* fix(ai-client): the picker matches a built-in option to its own model

A saved connection hides a built-in option only if one of its models is the model that option
names, so another model of the same runtime does not hide it.

* fix(ai-client): keep a download's result when complete files exist elsewhere

A checked result is kept for a directory the plan stands for: where it found complete files, or
where a download would go. The stricter rule discarded the result of a download into its
destination whenever discovery pointed at another complete copy.
2026-10-21 13:20:26 +01:00
Jeremy 50b224d875 feat(ai-client): find, check and download a built-in runtime's own files (#70)
* feat(ai-features): plan and offer a built-in runtime's own files

plan_native and setup_offer_native compare the files a runtime reads, which are a different
layout from the ComfyUI checkpoint, and need neither ComfyUI nor its node packs. Setup options
gain Route::Native (native:<feature>:<provider>) for each runtime that names files. A runtime
with no files of its own gets no plan, no offer and no option. The built-in install offer now
lists the runtime's three files, not the ComfyUI checkpoint.

* feat(ai-client): find, check and download a built-in runtime's own files

NativeSetupPlan is an immutable, reviewable plan for one runtime's files: where they are, where a download would go, how many bytes are still needed. FolderDesk finds a runtime's files in the person's folders (only together in one directory), hashes them before reuse, and downloads only into the chosen default folder, with licence approval. The folder scan lists a runtime's tokenizer files on an exact name and size. The picker lists a runtime as needing an adapter when the app has none.

* fix(ai-features): one recipe rule for every built-in runtime path, and a build that compiles alone

Planning, the Install offer and the setup options stopped at the first recipe, while registration
and engine advice used the first usable one. An unusable recipe in front hid a usable one behind
it, and two recipes naming one runtime gave two options with the same id.

`Feature::first_usable_recipe` is now the one rule. `plan_native`, the built-in Install offer and
`setup_options` use it, and each runtime gets a single option.

The picker's route match gets a Native arm that lists nothing yet, so this change builds on main
without the next one.

* fix(ai-client): skip a registered folder that has gone, use the first usable recipe, test with and without Candle

- `native_files` no longer fails every native call when one registered folder is missing (an
  unplugged drive, a deleted folder). That folder is not a candidate; the others are still read.
- `native_route` uses `Feature::first_usable_recipe`, the rule the planner and the setup options
  now share, so a Set up link that the picker shows can be followed.
- The picker tests accept the built-in engine either as NotSetUp (Candle built in) or as
  NeedsAdapter (not built in), as `picker_native` already did.

Merges the fix to #69 (one recipe rule, and the picker's Native arm).

* fix(ai-features): list every local model before any built-in runtime

A tool with a built-in runtime put its option ahead of a later tool's local models, which broke
the documented order. Runtimes are now collected apart and added after all local options and
before hosted services.

* fix(ai-features): the built-in Install offer agrees to words that match what it does

The offer reused the ComfyUI terms, which promise that everything stays in the app's own folder
and that ComfyUI is installed. The built-in route installs no ComfyUI and saves into the model
folder the person chose. `agreement_for(route)` gives it its own wording and version; the ComfyUI
route keeps `agreement()` unchanged. The wording is still draft, like the original.

* feat(ai-features): a native setup option names its model

Route::Native carries the model id its connection will have, so the picker can tell a saved
connection for this model from one for another model of the same runtime.

* fix(ai-features): the built-in terms name the Download click

The built-in flow's control is Download, not Install, so its terms now say Download.

* fix(ai-client): the picker matches a built-in option to its own model

A saved connection hides a built-in option only if one of its models is the model that option
names, so another model of the same runtime does not hide it.
2026-10-21 13:08:58 +01:00