mirror of
https://github.com/rookiestar28/ComfyUI-OpenClaw.git
synced 2026-08-14 00:48:07 +00:00
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
import os
|
|
import sys
|
|
|
|
# Ensure this custom node root is on sys.path (ComfyUI loads modules by path, not package)
|
|
_OPENCLAW_ROOT = os.path.dirname(os.path.abspath(__file__))
|
|
if _OPENCLAW_ROOT not in sys.path:
|
|
sys.path.insert(0, _OPENCLAW_ROOT)
|
|
|
|
if __package__:
|
|
from .nodes.batch_variants import OpenClawBatchVariants
|
|
from .nodes.image_to_prompt import OpenClawImageToPrompt
|
|
from .nodes.portability_contract import NODE_PORTABILITY_MAPPINGS
|
|
from .nodes.prompt_planner import OpenClawPromptPlanner
|
|
from .nodes.prompt_refiner import OpenClawPromptRefiner
|
|
|
|
NODE_CLASS_MAPPINGS = {
|
|
# IMPORTANT: keep legacy mapping keys stable for existing workflows.
|
|
"MoltbotPromptPlanner": OpenClawPromptPlanner,
|
|
"MoltbotBatchVariants": OpenClawBatchVariants,
|
|
"MoltbotImageToPrompt": OpenClawImageToPrompt,
|
|
"MoltbotPromptRefiner": OpenClawPromptRefiner,
|
|
}
|
|
|
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
|
"MoltbotPromptPlanner": "openclaw: Prompt Planner",
|
|
"MoltbotBatchVariants": "openclaw: Batch Variants",
|
|
"MoltbotImageToPrompt": "openclaw: Image to Prompt",
|
|
"MoltbotPromptRefiner": "openclaw: Prompt Refiner",
|
|
}
|
|
|
|
__all__ = [
|
|
"NODE_CLASS_MAPPINGS",
|
|
"NODE_DISPLAY_NAME_MAPPINGS",
|
|
"NODE_PORTABILITY_MAPPINGS",
|
|
"WEB_DIRECTORY",
|
|
]
|
|
else:
|
|
# Allow test collection to proceed without crashing on relative imports
|
|
NODE_CLASS_MAPPINGS = {}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
NODE_PORTABILITY_MAPPINGS = {}
|
|
__all__ = ["NODE_PORTABILITY_MAPPINGS", "WEB_DIRECTORY"]
|
|
|
|
WEB_DIRECTORY = "./web"
|
|
|
|
|
|
def _bootstrap_openclaw_routes() -> None:
|
|
# IMPORTANT: keep entrypoint thin; heavy startup orchestration lives in
|
|
# services.route_bootstrap to prevent __init__.py from regressing into a
|
|
# large mixed-responsibility module again.
|
|
try:
|
|
if __package__:
|
|
from .services.route_bootstrap import register_routes_once
|
|
else:
|
|
from services.route_bootstrap import register_routes_once
|
|
except Exception as exc:
|
|
try:
|
|
if __package__:
|
|
from .services.startup_lifecycle import mark_bootstrap_import_failed
|
|
else:
|
|
from services.startup_lifecycle import mark_bootstrap_import_failed
|
|
|
|
mark_bootstrap_import_failed(exc)
|
|
except Exception:
|
|
# IMPORTANT: diagnostics must not mask the original compatibility fallback.
|
|
pass
|
|
return
|
|
|
|
register_routes_once()
|
|
|
|
|
|
_bootstrap_openclaw_routes()
|