managarten/scripts
Till JS 8a882a3760 feat(wardrobe,picture): Google Nano Banana as a Try-On option
Add Google's Gemini image edit family (Nano Banana) as a user-
selectable model for Wardrobe Try-On next to the existing OpenAI
path. Three concrete choices now expose themselves in the Solo and
Outfit Try-On buttons:

  - openai/gpt-image-2          (default, falls back to gpt-image-1
                                 server-side when the org isn't
                                 verified)
  - google/gemini-3-pro-image-preview   (Nano Banana Pro — premium
                                 identity / character consistency)
  - google/gemini-3.1-flash-image-preview (Nano Banana 2 — newest,
                                 fast, cheapest)

All three accept multi-image refs (face + body + garment) through
the same /api/v1/picture/generate-with-reference endpoint; the only
differences are the provider-specific request/response shape and
the model-id routing.

Server (apps/api/src/modules/picture/routes.ts):
- Guard now accepts `openai/*` and `google/*` prefixes and rejects
  everything else as "not supported for edits". Each provider's key
  is validated separately so missing GEMINI_API_KEY doesn't break
  OpenAI calls and vice versa.
- New `callGeminiEdits(modelName)` helper mirrors the shape of
  callOpenAiEdits: encodes the normalized PNG refs as base64
  inline_data parts, POSTs to
  generativelanguage.googleapis.com/v1beta/models/{model}:generateContent
  with responseModalities=["TEXT","IMAGE"] and imageConfig
  (aspectRatio + imageSize), pulls the generated image out of
  candidates[].content.parts[].inlineData.
- Our internal size strings map cleanly: 1024x1024 → 1:1 / 1K,
  1024x1536 → 2:3 / 1K, 1536x1024 → 3:2 / 1K. Gemini 1K is enough
  for the thumbnail sizes Wardrobe renders; going higher bloats
  payload without visible gain.
- creditsFor() gains a google/ branch proportional to upstream
  pricing (pro ≈ 18, 3.1-flash ≈ 6, 2.5-flash ≈ 5).
- Response `model` reports `${provider}/${modelUsed}` so the picture
  row's model metadata is accurate across providers.

Client (apps/mana/apps/web/src/lib/modules/wardrobe):
- api/try-on.ts: export `TryOnModel` union + `DEFAULT_TRY_ON_MODEL`.
  RunGarmentTryOnParams / RunOutfitTryOnParams gain an optional
  `model` field, threaded through `callGenerateWithReference`.
- components/TryOnModelPicker.svelte: new segmented control, three
  options with label + one-line hint. Grid-auto-fits so it reflows
  on the narrow workbench card.
- components/GarmentTryOnButton.svelte + TryOnButton.svelte: both
  mount the picker above the Sparkle CTA. `estimatedCredits` on the
  button label updates live when the user switches model so the
  cost signal matches what the server will actually charge.

Env (scripts/generate-env.mjs): GEMINI_API_KEY and GOOGLE_API_KEY
now propagate from the root `.env.development` into `apps/api/.env`
so mana-api can pick them up at boot. The route reads GEMINI_API_KEY
with GOOGLE_API_KEY as fallback, matching how mana-llm ships today.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 16:04:21 +02:00
..
dev chore(dev): seed real credit balance in setup-dev-user.sh 2026-04-15 18:51:39 +02:00
mac-mini chore(infra): unify prod deploy on .env.macmini + document missing keys 2026-04-23 13:01:29 +02:00
personas feat(personas): M2.a-c — persona schemas + admin endpoints + seed pipeline 2026-04-23 13:55:14 +02:00
test-data feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
test-reporting chore: complete ManaCore → Mana rename (docs, go modules, plists, images) 2026-04-07 12:26:10 +02:00
audit-bundle.mjs chore(bundle): add bundle-size audit + snapshot inventory 2026-04-22 17:52:08 +02:00
audit-complexity.mjs chore(audit): module complexity reports + workbench map 2026-04-14 19:47:42 +02:00
audit-crypto-registry.mjs feat(crypto): Phase C — build-time registry ↔ Dexie audit 2026-04-20 14:36:32 +02:00
audit-encrypted-tools.ts fix(personas): exact tool_use_id pairing + CI drift audit 2026-04-23 15:34:52 +02:00
audit-i18n-coverage.mjs chore(i18n): add coverage audit + migration inventory 2026-04-22 17:16:55 +02:00
audit-icon-usage.mjs perf(invoices): lazy-load pdf-lib + swissqrbill, -516 KB on route 2026-04-22 18:03:53 +02:00
audit-module-coupling.mjs chore(audit): module complexity reports + workbench map 2026-04-14 19:47:42 +02:00
audit-modules.mjs chore(audit): module complexity reports + workbench map 2026-04-14 19:47:42 +02:00
audit-port-drift.mjs chore(services): add port-drift audit 2026-04-22 17:22:37 +02:00
audit-test-coverage.mjs chore(test + audit): add test-coverage audit + wire audit:all 2026-04-22 17:38:12 +02:00
audit-workspace-deps.mjs refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
backup-monitoring.sh feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
build-complexity-map.mjs chore(audit): module complexity reports + workbench map 2026-04-14 19:47:42 +02:00
check-status.sh feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
create-gift-codes.mjs feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
deploy-metrics.sh fix(deploy): fix image size measurement in deploy metrics 2026-03-20 21:13:03 +01:00
ecosystem-audit.mjs feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
fix-mixed-imports.mjs Fix wrong type 2025-12-04 23:25:25 +01:00
generate-dockerfiles.mjs feat(infra): extend Dockerfile validator to backends and services 2026-03-25 08:57:10 +01:00
generate-env.mjs feat(wardrobe,picture): Google Nano Banana as a Try-On option 2026-04-24 16:04:21 +02:00
generate-status-page.sh feat(mana-ai): Prometheus /metrics endpoint + status.mana.how integration 2026-04-15 01:41:40 +02:00
lighthouse-audit.sh refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
migrate-theme-tokens.mjs refactor(theming): migrate remaining 738 token violations across routes + components 2026-04-22 15:42:55 +02:00
migrate-transition-all.mjs refactor(theming): replace transition-all with specific transitions 2026-04-22 15:57:49 +02:00
run-integration-tests.sh fix(mana-auth): account lockout was structurally dead + add failure-path tests 2026-04-08 18:29:00 +02:00
run-tests-with-coverage.sh feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
setup-databases.sh chore(setup:db): surface drizzle-kit errors instead of catch-all 2026-04-23 15:36:18 +02:00
setup-secrets.mjs feat(env): persistent dev secrets via .env.secrets override 2026-04-08 17:50:37 +02:00
test-chat-auth.sh chore: tidy root files + reorganize a few stale docs 2026-04-08 12:15:27 +02:00
validate-cloudflared-config.mjs chore(infra): pre-commit validator for cloudflared-config.yml 2026-04-09 18:02:51 +02:00
validate-dockerfiles.mjs refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
validate-monorepo.mjs refactor: rename zitare -> quotes (Zitate) 2026-04-14 20:59:16 +02:00
validate-no-recursive-turbo.mjs chore(turbo): lint against recursive \turbo run\ calls in child packages 2026-04-20 14:39:32 +02:00
validate-pg-schema-isolation.mjs chore(db): enforce pgSchema isolation with a lint script 2026-04-20 14:45:59 +02:00
validate-theme-parity.mjs refactor(theming): migrate who semantic colours to theme tokens 2026-04-22 17:19:53 +02:00
validate-theme-utilities.mjs refactor(theming): migrate who semantic colours to theme tokens 2026-04-22 17:19:53 +02:00
validate-theme-variables.mjs refactor(theming): re-apply theme validator suite after parallel rebase 2026-04-22 17:07:48 +02:00