@egdesk/next-api-plugin 1.5.19 → 1.5.20

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.
@@ -2449,14 +2449,69 @@ export type AiCallerCallResult = {
2449
2449
  };
2450
2450
 
2451
2451
  /**
2452
- * Call Gemini and log token usage. Returns the AI response plus a usage summary.
2453
- * Supports images, filePaths, and inline files (documents, text, video frames).
2452
+ * Call Gemini for TEXT generation and log token usage. Returns the AI response plus a usage summary.
2453
+ * Supports images, filePaths, and inline files (documents, text, video frames) as INPUT context.
2454
2454
  * Omit \`maxOutputTokens\` to auto-use the selected model's maximum from the Gemini API.
2455
+ *
2456
+ * Do NOT pass an image-generation model (gemini-*-image, imagen-*) here — it cannot return image
2457
+ * bytes and will throw. Use \`generateAiCallerImage\` instead.
2455
2458
  */
2456
2459
  export async function callAiCaller(prompt: string, options: AiCallerCallOptions = {}): Promise<AiCallerCallResult> {
2457
2460
  return callAiCallerTool('ai_caller_call', { prompt, ...options });
2458
2461
  }
2459
2462
 
2463
+ export type AiCallerGenerateImageOptions = {
2464
+ /** Image model id (e.g. gemini-3.1-flash-image, imagen-4.0-generate-001). Defaults to the preferred image model from AI Keys. */
2465
+ model?: string;
2466
+ /** Number of images to generate (default: 1) */
2467
+ count?: number;
2468
+ /** Optional reference images (base64, raw or data URLs) to ground generation */
2469
+ images?: string[];
2470
+ /** Aspect ratio (Imagen only; default 1:1) */
2471
+ aspectRatio?: '1:1' | '16:9' | '9:16' | '4:3' | '3:4';
2472
+ /** Output resolution (Imagen only; default 1K) */
2473
+ imageSize?: '1K' | '2K';
2474
+ /** Output MIME type (Imagen only; default image/png) */
2475
+ outputMimeType?: 'image/jpeg' | 'image/png';
2476
+ /** Optional absolute directory (on the EGDesk host) to also save generated images to disk */
2477
+ outputDir?: string;
2478
+ /** Gemini image model to fall back to if the primary (usually Imagen) model fails */
2479
+ fallbackModel?: string;
2480
+ caller?: string;
2481
+ /** Select a specific Google API key by name (as saved in EGDesk AI Keys Manager). Leave empty to use the default key. */
2482
+ keyName?: ${(options.apiKeyNames ?? []).length > 0
2483
+ ? (options.apiKeyNames.map(n => `'${n}'`).join(' | ') + ' | (string & {})')
2484
+ : 'string'};
2485
+ };
2486
+
2487
+ export type AiCallerGeneratedImage = {
2488
+ fileName: string;
2489
+ mimeType: string;
2490
+ /** Base64-encoded image data */
2491
+ data: string;
2492
+ size: number;
2493
+ /** Local path on the EGDesk host, only set when outputDir was provided */
2494
+ filePath: string | null;
2495
+ };
2496
+
2497
+ export type AiCallerGenerateImageResult = {
2498
+ model: string;
2499
+ count: number;
2500
+ images: AiCallerGeneratedImage[];
2501
+ };
2502
+
2503
+ /**
2504
+ * Generate image(s) with Gemini image models or Imagen and log token usage.
2505
+ * Returns base64 image data (and a local filePath when \`outputDir\` is set).
2506
+ * Use this instead of \`callAiCaller\` for any image-generation model.
2507
+ */
2508
+ export async function generateAiCallerImage(
2509
+ prompt: string,
2510
+ options: AiCallerGenerateImageOptions = {}
2511
+ ): Promise<AiCallerGenerateImageResult> {
2512
+ return callAiCallerTool('ai_caller_generate_image', { prompt, ...options });
2513
+ }
2514
+
2460
2515
  export type AiCallerUsageOptions = {
2461
2516
  caller?: string;
2462
2517
  model?: string;
@@ -2490,11 +2545,15 @@ export type AiCallerModelsResult = {
2490
2545
  models: string[];
2491
2546
  defaultModel: string;
2492
2547
  modelDetails?: AiCallerModelDetails[];
2548
+ /** Image-generation model ids — pass these to generateAiCallerImage, NOT callAiCaller */
2549
+ imageModels: string[];
2550
+ defaultImageModel: string;
2493
2551
  };
2494
2552
 
2495
2553
  /**
2496
2554
  * List Gemini models available for text generation, fetched live from the Google API via EGDesk.
2497
- * Includes per-model input/output token limits when available.
2555
+ * Includes per-model input/output token limits when available, plus separate image-generation
2556
+ * model ids (for use with generateAiCallerImage).
2498
2557
  */
2499
2558
  export async function listAiCallerModels(): Promise<AiCallerModelsResult> {
2500
2559
  return callAiCallerTool('ai_caller_list_models', {});
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * The minimum EGDesk app version this plugin version is compatible with.
9
9
  * The app checks this at setup time and warns on mismatch.
10
10
  */
11
- export declare const COMPATIBLE_APP_VERSION = "1.4.32";
11
+ export declare const COMPATIBLE_APP_VERSION = "1.4.33";
12
12
  export interface SetupOptions {
13
13
  egdeskUrl?: string;
14
14
  /** Production EGDesk server URL — written to .env.production.local. Falls back to egdeskUrl. */
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ exports.setupNextApiPlugin = setupNextApiPlugin;
46
46
  * The minimum EGDesk app version this plugin version is compatible with.
47
47
  * The app checks this at setup time and warns on mismatch.
48
48
  */
49
- exports.COMPATIBLE_APP_VERSION = '1.4.32';
49
+ exports.COMPATIBLE_APP_VERSION = '1.4.33';
50
50
  const fs = __importStar(require("fs"));
51
51
  const path = __importStar(require("path"));
52
52
  const setup_userdata_1 = require("./setup-userdata");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.5.19",
3
+ "version": "1.5.20",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",