aooo_han connected Alma, uninstalled the Alma app, and then couldn't turn
Alma off in magpie: it said "Alma isn't running - open Alma and try again".
Alma's settings are reached only through its local API, so an app that is
gone could never be turned off.
- Alma: when the API is down and Alma isn't installed (macOS bundle,
Windows install folder or registered guid, Linux /opt or desktop entry,
or alma-server on PATH), turning it off clears magpie's own record and
remembers a takeout (alma.takeout in the stash). Alma's providers live
in its SQLite database, so magpie doesn't edit its files. If Alma comes
back, the next Sync takes magpie's provider and default model out of
it, then forgets the takeout. Turning Alma on again forgets it too.
An installed Alma that isn't running still says to open it.
- OpenHanako (the sibling with the same need: a sealed catalog it
rewrites only while running): uninstalled, the model in its config file
goes back to the user's own and the sealed provider entry is left
alone, instead of errSealed.
- An app in the Trash, as a Mac app is uninstalled, still shows up in
Spotlight. spotlightBundles now skips ~/.Trash and /.Trashes paths.
Run: go test -run 'Alma|Hanako|InTrash' ./internal/agent and the whole
internal/agent package (wsl-run, since mote's sshd refused connections);
go vet for darwin, linux (nogui) and windows; gofmt. e2e in a sandbox
HOME on WSL with no Alma: on origin/main `magpie alma default` printed
"Alma isn't running - open Alma and try again"; with this change it
prints "Alma model default", exit 0, and the list shows Alma off.
Broken by hand: without the Alma branch TestAlmaOffUninstalled fails
with "isn't running"; without the Hanako branch
TestHanakoSealedUninstalled fails with errSealed; without the Sync
takeout magpie's provider and default model stay in a returned Alma;
inTrash returning false fails TestInTrash.
Not tried: a real uninstalled Alma on macOS or Windows (the live Alma is
the owner's); a reinstalled OpenHanako doesn't get its sealed provider
taken out (its Sync is skipped once hand-wired); an AppImage OpenHanako
isn't detected as installed.
Alma has one: Settings › Image Generation, settings.imageGen.model,
"<providerId>:<model>" like chat.defaultModel, "" for Auto (Alma's
src/services/settingsApiService.ts defaults). Its `alma image gen` and
in-chat image requests send an openai-type provider's model to
{baseURL}/images/generations, which the gateway draws with.
Choosing one of magpie's models for Alma now also sets imageGen.model to
magpie's provider and the model magpie draws with (gateway.Drawer: the
Settings' Image generation model, else AutoDrawer's), only when it is
Auto: a model the user picked, theirs or magpie's, is left. Sync leaves
an Auto alone (the user may have gone back to it) and only replaces one of
magpie's that magpie no longer offers. That model is listed on magpie's
provider with capabilityOverrides.imageOutput, as Alma's picker lists only
a provider's models that make images and shows another as "unavailable".
Going back to Alma's own model puts an image model of magpie's back to
Auto with the provider. Nothing changes when magpie draws with nothing.
Verified: TestAlmaImageGen against the fake Alma (settings kept whole,
aspectRatio untouched): Auto filled with p1:img/gpt-image-1 and the model
listed with imageOutput; the user's own pick and a magpie chat model kept
by Apply and Sync; Auto kept by Sync; a stale magpie drawer replaced; Auto
again on going back. It fails without almaSetImage ("image generation:
\"\", want \"p1:img/gpt-image-1\""). TestAlma checks nothing is written
when magpie draws with nothing. Go tests ran on Linux (golang:1.26 in
Docker). Not tried with the real Alma: Alma's settings page reading the
override as an image model, and an image drawn through it, are unverified.
alma-server (Alma without a desktop, Linux x64/arm64) keeps its data in
$ALMA_DATA_DIR, else $XDG_DATA_HOME/alma, else ~/.local/share/alma
(Alma's electron/headless/electron-shim.ts getDefaultUserDataPath), and
answers on the same localhost:23001. magpie looked only in the desktop's
folder (os.UserConfigDir()/alma), so on such a machine Alma's Sync never
ran, its magpie provider kept the old shared key, and the gateway read its
requests by their User-Agent alone, the AI SDK's
("ai-sdk/openai/4.0.15 ai-sdk/provider-utils/5.0.10 runtime/node.js/22",
@ai-sdk/openai 4.0.15 and provider-utils 5.0.10 as alma-server bundles
them; Alma sends no header of its own). almaDir now also looks in
alma-server's folders on systems other than macOS and Windows, the
desktop's first; ALMA_DATA_DIR is in agentenv's Vars.
Verified: TestAlmaServerKeyed (a Linux home with only
~/.local/share/alma and a fake Alma whose magpie provider has the old
key): Sync re-keys it to magpie-alma; XDG_DATA_HOME and ALMA_DATA_DIR are
followed, the desktop's folder wins, and macOS/Windows look only in the
desktop's. It fails without the change ("Alma's folder:
.../.config/alma, want alma-server's .../.local/share/alma").
TestAgentOf has alma-server's real User-Agent bytes: Alma with magpie's
Alma key, "ai-sdk" without. Go tests ran on Linux (golang:1.26 in Docker;
this Mac's syspolicyd held every new test binary at launch).
Not tried with a real alma-server, and an alma-server on another
computer, reaching magpie with a gateway key, still reads as the AI SDK:
its User-Agent says nothing of Alma.