* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule The PLUGIN-COMPAT layer (2776813df3+d63e380324+0a5164cebe) kept pre-#102117 import paths alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader has already been skipping plugins that use the old paths. This removes the layer itself: - 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party names, restored dead definitions) and the three re-export stub modules (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils) - COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step - the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section, the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the `plugins.allow_deprecated_imports` escape hatch An external plugin that still imports an old path now fails to load with its ImportError as the reason in `hermes plugins list`, the same path as any broken plugin. hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect, summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout swap (tests/compat/old_updater_surface.json). In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its `shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed `run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the seam production reads, like every sibling test in that file. * chore: retrigger CI (zero-job startup_failure phantom) * test: drop resolution allowlist rows for the two deleted which() sites hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available (a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires their allowlist entries go with them.
114 lines
4.8 KiB
Python
114 lines
4.8 KiB
Python
"""FAL.ai registration adapter. Catalog, payload, submission, managed-gateway selection and
|
|
Clarity Upscaler chaining live in :mod:`tools.image_generation_tool`; this plugin imports it at
|
|
call time so tests keep patching ``image_tool.*`` and there is one FAL code path."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import logging
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
from agent.image_gen_provider import DEFAULT_ASPECT_RATIO, resolve_aspect_ratio
|
|
from plugins.image_gen._common import StaticImageGenProvider, catalog_rows
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
_PASSTHROUGH_KWARGS = (
|
|
"num_inference_steps", "guidance_scale", "num_images", "output_format", "seed", "upscale",
|
|
)
|
|
|
|
|
|
class FalImageGenProvider(StaticImageGenProvider):
|
|
"""FAL.ai backend delegating to ``tools.image_generation_tool`` at call time."""
|
|
|
|
provider_id = "fal"
|
|
label = "FAL.ai"
|
|
setup = dict(
|
|
name="FAL.ai", badge="paid",
|
|
tag="Pick from flux-2-klein, flux-2-pro, gpt-image, nano-banana-2, nano-banana-pro, etc. — text-to-image & image editing",
|
|
key="FAL_KEY", prompt="FAL API key", url="https://fal.ai/dashboard/keys")
|
|
|
|
def is_available(self) -> bool:
|
|
# Direct FAL_KEY or a managed Nous fal-queue origin, per the legacy module.
|
|
import tools.image_generation_tool as _it
|
|
|
|
try:
|
|
return bool(_it.check_fal_api_key())
|
|
except Exception: # noqa: BLE001 — never break the picker
|
|
return False
|
|
|
|
def list_models(self) -> List[Dict[str, Any]]:
|
|
from tools.image_generation_catalog import FAL_MODELS
|
|
return catalog_rows(FAL_MODELS)
|
|
|
|
def default_model(self) -> Optional[str]:
|
|
from tools.image_generation_catalog import DEFAULT_MODEL
|
|
return DEFAULT_MODEL
|
|
|
|
def capabilities(self) -> Dict[str, Any]:
|
|
# Image-to-image depends on the selected model (``edit_endpoint``); upscale works for any.
|
|
import tools.image_generation_tool as _it
|
|
|
|
try:
|
|
_model_id, meta = _it._resolve_fal_model()
|
|
except Exception: # noqa: BLE001
|
|
return {"modalities": ["text"], "max_reference_images": 0}
|
|
if meta.get("edit_endpoint"):
|
|
return {
|
|
"modalities": ["text", "image"],
|
|
"max_reference_images": int(meta.get("max_reference_images") or 1),
|
|
"supports_upscale": True,
|
|
}
|
|
return {"modalities": ["text"], "max_reference_images": 0, "supports_upscale": True}
|
|
|
|
def generate(
|
|
self, prompt: str, aspect_ratio: str = DEFAULT_ASPECT_RATIO, *,
|
|
image_url: Optional[str] = None, reference_image_urls: Optional[List[str]] = None,
|
|
**kwargs: Any,
|
|
) -> Dict[str, Any]:
|
|
"""Forward to ``image_generate_tool`` and reshape its JSON-string response into the ABC dict."""
|
|
import tools.image_generation_tool as _it
|
|
|
|
aspect = resolve_aspect_ratio(aspect_ratio)
|
|
passthrough = {key: kwargs[key] for key in _PASSTHROUGH_KWARGS if kwargs.get(key) is not None}
|
|
# Only forward image-to-image inputs when supplied (no noisy None kwargs).
|
|
if image_url is not None:
|
|
passthrough["image_url"] = image_url
|
|
if reference_image_urls is not None:
|
|
passthrough["reference_image_urls"] = reference_image_urls
|
|
|
|
try:
|
|
raw = _it.image_generate_tool(prompt=prompt, aspect_ratio=aspect, **passthrough)
|
|
except Exception as exc: # noqa: BLE001 — never raise out of generate
|
|
logger.warning("FAL image_generate_tool raised: %s", exc, exc_info=True)
|
|
return {
|
|
"success": False, "image": None, "error": f"FAL image generation failed: {exc}",
|
|
"error_type": type(exc).__name__, "provider": "fal", "prompt": prompt, "aspect_ratio": aspect,
|
|
}
|
|
|
|
try:
|
|
response = json.loads(raw) if isinstance(raw, str) else raw
|
|
except Exception: # noqa: BLE001
|
|
response = {"success": False, "image": None, "error": "Invalid JSON from FAL pipeline"}
|
|
|
|
if not isinstance(response, dict):
|
|
response = {
|
|
"success": False, "image": None, "error": "FAL pipeline returned a non-dict response",
|
|
"error_type": "provider_contract",
|
|
}
|
|
# Stamp the uniform shape; the legacy pipeline resolves the model internally.
|
|
response.setdefault("provider", "fal")
|
|
response.setdefault("prompt", prompt)
|
|
response.setdefault("aspect_ratio", aspect)
|
|
if "model" not in response:
|
|
try:
|
|
response["model"] = _it._resolve_fal_model()[0]
|
|
except Exception: # noqa: BLE001
|
|
pass
|
|
return response
|
|
|
|
|
|
def register(ctx) -> None:
|
|
"""Plugin entry point — wire ``FalImageGenProvider`` into the registry."""
|
|
ctx.register_image_gen_provider(FalImageGenProvider())
|