pi-banana 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -58,7 +58,7 @@ The model calls `banana_image` or `banana_vision` automatically.
58
58
  | `prompt` | string | — | Required. What to draw, or what to change about the reference image. |
59
59
  | `aspectRatio` | enum | `1:1` | `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9` |
60
60
  | `imageSize` | enum | `1K` | `1K`, `2K`, `4K`. `4K` requires `quality=high`. |
61
- | `quality` | enum | `fast` | `fast` = Nano Banana 2 (~3–10 s, cheapest). `high` = Nano Banana Pro (slower, top quality). |
61
+ | `quality` | enum | `fast` | `lite` = Nano Banana 2 Lite (ultra-low latency, cheapest). `fast` = Nano Banana 2 (~3–10 s). `high` = Nano Banana Pro (slower, top quality). All GA model ids since 2.4.0. |
62
62
  | `referenceImages` | array | — | Optional array of paths (PNG/JPEG/WebP/GIF) to edit or use for composition instead of generating from scratch. |
63
63
  | `outputPath` | string | `./generated/<slug>-<ts>.png` | Optional output path. Parent dirs are created. |
64
64
 
@@ -18,7 +18,7 @@
18
18
  * Vertex AI Express keys (AQ.…) automatically switch to Vertex.
19
19
  */
20
20
 
21
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
21
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
22
22
  import { StringEnum } from "@earendil-works/pi-ai";
23
23
  import {
24
24
  Box,
@@ -51,26 +51,26 @@ const ASPECT_RATIOS = [
51
51
  "21:9",
52
52
  ] as const;
53
53
  const IMAGE_SIZES = ["1K", "2K", "4K"] as const;
54
- const QUALITY = ["fast", "high"] as const;
55
-
56
- // Resolved against a live Vertex Express (AQ.*) key on 2026-05-08:
57
- // gemini-3.1-flash-image → 404
58
- // gemini-3.1-flash-image-preview → ok (Nano Banana 2)
59
- // gemini-3-pro-image 404
60
- // gemini-3-pro-image-preview ok (Nano Banana Pro)
61
- // AI Studio keys (AIza*) sometimes publish the un-suffixed GA names.
62
- // `callWithModelFallback` below transparently retries with `-preview`
63
- // if the un-suffixed id 404s, so both backends just work.
64
- const MODEL_FOR_QUALITY: Record<(typeof QUALITY)[number], string> = {
65
- fast: "gemini-3.1-flash-image-preview", // Nano Banana 2
66
- high: "gemini-3-pro-image-preview", // Nano Banana Pro
54
+ const IMAGE_QUALITY = ["lite", "fast", "high"] as const;
55
+ const VISION_QUALITY = ["fast", "high"] as const;
56
+ type ImageQuality = (typeof IMAGE_QUALITY)[number];
57
+
58
+ // GA ids (Gemini API changelog 2026-05-28: gemini-3.1-flash-image and
59
+ // gemini-3-pro-image went GA; 2026-06-30: gemini-3.1-flash-lite-image GA).
60
+ // Vertex Express keys historically served the `-preview` variants; the
61
+ // GA and preview ids are published at different times per backend, so
62
+ // `callWithModelFallback` retries the other variant on 404. Both work.
63
+ // Verified against the Gemini API changelog on 2026-09-01.
64
+ const MODEL_FOR_QUALITY: Record<ImageQuality, string> = {
65
+ lite: "gemini-3.1-flash-lite-image", // Nano Banana 2 Lite (ultra-low latency, cheapest)
66
+ fast: "gemini-3.1-flash-image", // Nano Banana 2
67
+ high: "gemini-3-pro-image", // Nano Banana Pro
67
68
  };
68
69
 
69
70
  const DEFAULT_OUTPUT_DIR =
70
71
  process.env.PI_IMAGE_DIR?.trim() || "generated";
71
72
  const DEFAULT_QUALITY = (process.env.PI_IMAGE_QUALITY as
72
- | "fast"
73
- | "high"
73
+ | ImageQuality
74
74
  | undefined) ?? "fast";
75
75
  const SUPPORTED_INPUT_MIME = new Set([
76
76
  "image/png",
@@ -103,7 +103,7 @@ function hasVertexADC(): boolean {
103
103
  }
104
104
 
105
105
  async function buildClient(
106
- modelRegistry: ExtensionAPI["modelRegistry"] | undefined,
106
+ modelRegistry: ExtensionContext["modelRegistry"] | undefined,
107
107
  ): Promise<GoogleGenAI> {
108
108
  // 1. Pi's model registry — the pi-native auth chain
109
109
  // (auth.json → env vars → models.json fallback)
@@ -277,9 +277,9 @@ export default function (pi: ExtensionAPI) {
277
277
  }),
278
278
  ),
279
279
  quality: Type.Optional(
280
- StringEnum(QUALITY, {
280
+ StringEnum(IMAGE_QUALITY, {
281
281
  description:
282
- "'fast' = Nano Banana 2 (default, ~3s, cheap). 'high' = Nano Banana Pro (slower, top quality).",
282
+ "'lite' = Nano Banana 2 Lite (ultra-low latency, cheapest). 'fast' = Nano Banana 2 (default, ~3s, cheap). 'high' = Nano Banana Pro (slower, top quality).",
283
283
  default: DEFAULT_QUALITY,
284
284
  }),
285
285
  ),
@@ -348,7 +348,7 @@ export default function (pi: ExtensionAPI) {
348
348
  content: [
349
349
  {
350
350
  type: "text",
351
- text: `🎨 ${verbLabel} ${aspectRatio} ${imageSize} image with ${quality === "fast" ? "Nano Banana 2" : "Nano Banana Pro"}…`,
351
+ text: `🎨 ${verbLabel} ${aspectRatio} ${imageSize} image with ${quality === "lite" ? "Nano Banana 2 Lite" : quality === "fast" ? "Nano Banana 2" : "Nano Banana Pro"}…`,
352
352
  },
353
353
  ],
354
354
  details: { model, aspectRatio, imageSize, quality, editing },
@@ -479,7 +479,6 @@ export default function (pi: ExtensionAPI) {
479
479
  container.addChild(new Spacer(1));
480
480
  container.addChild(
481
481
  new Image((details as any).imageBase64, (details as any).mimeType ?? "image/png", {
482
- ...theme,
483
482
  fallbackColor: (s: string) => theme.fg("muted", s),
484
483
  }, {
485
484
  maxWidthCells: 80,
@@ -560,10 +559,10 @@ export default function (pi: ExtensionAPI) {
560
559
  "to analyze (e.g., ['image1.png']). Relative paths resolve to current working directory.",
561
560
  }),
562
561
  quality: Type.Optional(
563
- StringEnum(QUALITY, {
562
+ StringEnum(VISION_QUALITY, {
564
563
  description:
565
564
  "'fast' = gemini-3.1-flash-lite (default, fast/cheap). 'high' = gemini-3.1-pro-preview (slower, deep reasoning).",
566
- default: DEFAULT_QUALITY,
565
+ default: "fast",
567
566
  }),
568
567
  ),
569
568
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-banana",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Generate, edit, and analyze images in pi using Google Nano Banana (image gen) and Gemini Vision (analysis). Inline terminal preview, reference-image editing, auto-save.",
5
5
  "author": "Francesco Frapporti <effedue@gmail.com>",
6
6
  "license": "MIT",