fix: export Adapter alias + qualify bare runtime imports

Two compounding bugs from the post-#87 extraction:

1. adapter.py never aliased GeminiCLIAdapter to the contract name
   `Adapter`, which `molecule_runtime.adapters.get_adapter()` reads
   via `getattr(mod, "Adapter")`. Without it, every gemini-cli
   workspace startup fails preflight with "no `Adapter` class is
   exported".

2. Four bare imports of runtime modules
   (`from config`, `from executor_helpers` in adapter.py + cli_executor.py)
   never got qualified to `from molecule_runtime.X import Y`. They
   worked when the runtime was bundled into workspace/ where bare
   imports resolved against sibling files; in the standalone template
   repo they explode with ModuleNotFoundError.

Same migration debt as fixed in claude-code template
(commits 280e89c and e7dea39). The pattern across templates was
sniffed out by tonight's wire-real E2E sweep; the OTHER 5 templates
(langgraph, crewai, autogen, deepagents, openclaw) also need the
Adapter alias added — file separately. langgraph + deepagents also
have bare `from a2a_executor import LangGraphA2AExecutor` — same fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hongming Wang 2026-04-27 05:30:37 -07:00
parent fa2a589fe2
commit a8c8c62080
2 changed files with 7 additions and 4 deletions

View File

@ -77,7 +77,7 @@ class GeminiCLIAdapter(BaseAdapter):
Also seeds GEMINI.md from system-prompt.md if GEMINI.md is absent, Also seeds GEMINI.md from system-prompt.md if GEMINI.md is absent,
so the agent has role context on first boot. so the agent has role context on first boot.
""" """
from executor_helpers import get_mcp_server_path from molecule_runtime.executor_helpers import get_mcp_server_path
# -- MCP wiring -------------------------------------------------- # -- MCP wiring --------------------------------------------------
gemini_dir = Path.home() / ".gemini" gemini_dir = Path.home() / ".gemini"
@ -116,7 +116,7 @@ class GeminiCLIAdapter(BaseAdapter):
async def create_executor(self, config: AdapterConfig) -> AgentExecutor: async def create_executor(self, config: AdapterConfig) -> AgentExecutor:
from cli_executor import CLIAgentExecutor from cli_executor import CLIAgentExecutor
from config import RuntimeConfig from molecule_runtime.config import RuntimeConfig
rc = config.runtime_config rc = config.runtime_config
if isinstance(rc, dict): if isinstance(rc, dict):
@ -139,3 +139,6 @@ class GeminiCLIAdapter(BaseAdapter):
config_path=config.config_path, config_path=config.config_path,
heartbeat=config.heartbeat, heartbeat=config.heartbeat,
) )
Adapter = GeminiCLIAdapter

View File

@ -38,8 +38,8 @@ from a2a.server.events import EventQueue
# KI-009: a2a-sdk v1 renames a2a.utils → a2a.helpers # KI-009: a2a-sdk v1 renames a2a.utils → a2a.helpers
from a2a.helpers import new_agent_text_message from a2a.helpers import new_agent_text_message
from config import RuntimeConfig from molecule_runtime.config import RuntimeConfig
from executor_helpers import ( from molecule_runtime.executor_helpers import (
CONFIG_MOUNT, CONFIG_MOUNT,
MEMORY_CONTENT_MAX_CHARS, MEMORY_CONTENT_MAX_CHARS,
WORKSPACE_MOUNT, WORKSPACE_MOUNT,