mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-20 01:21:41 -06:00
6e79ca3cbc
* fix(fal): route grok-imagine and nano-banana-2-lite edits to correct endpoints
The fal image-generation provider appends '/image-to-image' to any model
that isn't 'openai/gpt-image-*' or 'fal-ai/nano-banana-*' when reference
images are supplied. That's wrong for two models fal serves:
- `xai/grok-imagine-image`: fal 404s on '/image-to-image'. The real edit
endpoint is '/quality/edit'. The endpoint also expects lowercase
resolution values ('1k'/'2k' only) and a distinct aspect_ratio enum.
- `google/nano-banana-2-lite`: fal 404s on '/image-to-image'. The real
edit endpoint is '/edit'. The endpoint does not accept a 'resolution'
parameter.
Add schema entries for both models so ensureFalModelPath and
applyFalImageGeometry pick the right suffix and body shape. Introduce
resolution allowlist support ('resolutions: readonly string[]') and
lowercase transform ('resolutionCase: "lower"') on the schema; existing
schemas keep their behaviour (nb2 still forwards uppercase resolution
unchanged; flux/gpt-image/nb2/krea untouched). Refactor
ensureFalModelPath to consult schema.appendEditPath instead of hardcoded
prefix checks so future models only need a schema entry.
Tested:
- Existing 49 fal unit tests still pass; added 9 new tests covering the
two new endpoints and their guard conditions (32 -> 34 tests in the
image-generation-provider suite).
- Live fal.ai calls confirm both endpoints return 200 with real
reference images; the buggy old URLs still return 404.
* fix(fal): preserve standard edit routing
* fix(image): apply inferred resolution per model
* fix(image): preserve provider reference limits
* fix(image): resolve reference limits per model
* fix(fal): preserve nano banana family limits
* test(ios): stub generated file list helper
---------
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
/** Public runtime parameter and result types for image generation calls. */
|
|
import type { AuthProfileStore } from "../agents/auth-profiles/types.js";
|
|
import type { FallbackAttempt } from "../agents/model-fallback.types.js";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import type { SsrFPolicy } from "../infra/net/ssrf.js";
|
|
import type {
|
|
GeneratedImageAsset,
|
|
ImageGenerationBackground,
|
|
ImageGenerationIgnoredOverride,
|
|
ImageGenerationNormalization,
|
|
ImageGenerationOutputFormat,
|
|
ImageGenerationProvider,
|
|
ImageGenerationProviderOptions,
|
|
ImageGenerationQuality,
|
|
ImageGenerationResolution,
|
|
ImageGenerationSourceImage,
|
|
} from "./types.js";
|
|
|
|
export type GenerateImageParams = {
|
|
cfg: OpenClawConfig;
|
|
prompt: string;
|
|
agentDir?: string;
|
|
authStore?: AuthProfileStore;
|
|
modelOverride?: string;
|
|
count?: number;
|
|
size?: string;
|
|
aspectRatio?: string;
|
|
resolution?: ImageGenerationResolution;
|
|
/** Resolution inferred from reference images; omitted for incompatible fallback models. */
|
|
inferredResolution?: ImageGenerationResolution;
|
|
quality?: ImageGenerationQuality;
|
|
outputFormat?: ImageGenerationOutputFormat;
|
|
background?: ImageGenerationBackground;
|
|
inputImages?: ImageGenerationSourceImage[];
|
|
autoProviderFallback?: boolean;
|
|
/** Optional per-request provider timeout in milliseconds. */
|
|
timeoutMs?: number;
|
|
providerOptions?: ImageGenerationProviderOptions;
|
|
/** SSRF policy to propagate into image-generation provider HTTP calls. */
|
|
ssrfPolicy?: SsrFPolicy;
|
|
};
|
|
|
|
export type GenerateImageRuntimeResult = {
|
|
images: GeneratedImageAsset[];
|
|
provider: string;
|
|
model: string;
|
|
attempts: FallbackAttempt[];
|
|
appliedResolution?: ImageGenerationResolution;
|
|
normalization?: ImageGenerationNormalization;
|
|
metadata?: Record<string, unknown>;
|
|
ignoredOverrides: ImageGenerationIgnoredOverride[];
|
|
};
|
|
|
|
export type ListRuntimeImageGenerationProvidersParams = {
|
|
config?: OpenClawConfig;
|
|
};
|
|
|
|
export type RuntimeImageGenerationProvider = ImageGenerationProvider;
|