|
@@ -2876,35 +2876,29 @@ def hermes_setup_fn() -> None:
|
|
|
print_success("\n✓ Chatto configured. Restart the gateway to activate.")
|
|
print_success("\n✓ Chatto configured. Restart the gateway to activate.")
|
|
|
|
|
|
|
|
|
|
|
|
|
-def hermes_env_enablement_fn() -> dict | None:
|
|
|
|
|
- """Seed PlatformConfig.extra from env vars.
|
|
|
|
|
-
|
|
|
|
|
- Returns a dict compatible with the PlatformConfig merge hook (or None
|
|
|
|
|
- when no env-provided values are present).
|
|
|
|
|
-
|
|
|
|
|
- Called by the platform registry during load_gateway_config().
|
|
|
|
|
- Return None when the platform isn't minimally configured — the
|
|
|
|
|
- caller then skips auto-enabling. Return a dict to seed extras.
|
|
|
|
|
-
|
|
|
|
|
- The special 'home_channel' key is extracted and becomes a proper
|
|
|
|
|
- HomeChannel dataclass on the PlatformConfig; every other key is
|
|
|
|
|
- merged into PlatformConfig.extra.
|
|
|
|
|
|
|
+def hermes_env_enablement_fn() -> dict:
|
|
|
|
|
+ """Seed PlatformConfig.extra from the CHATTO_* environment variables.
|
|
|
|
|
+
|
|
|
|
|
+ Returns a dict compatible with the PlatformConfig merge hook, holding
|
|
|
|
|
+ exactly the values that are actually set via env — never fabricated
|
|
|
|
|
+ defaults. Called by the platform registry during load_gateway_config(),
|
|
|
|
|
+ which commits this dict onto the platform's ``extra`` verbatim; seeding a
|
|
|
|
|
+ value that was not configured would overwrite what the user set in
|
|
|
|
|
+ config.yaml (e.g. a YAML base_url clobbered by the ChattoHQ default).
|
|
|
|
|
+ "Nothing set" therefore stays the adapter's business: every ConfigField
|
|
|
|
|
+ falls back to its declared default (base_url to ChattoHQ) on its own.
|
|
|
|
|
+
|
|
|
|
|
+ Seed keys are the config.yaml "extra" keys (config_key), NOT the env var
|
|
|
|
|
+ names — ChattoConfiguration reads extra[config_key]. The special
|
|
|
|
|
+ 'home_channel' key is extracted by the gateway and becomes a proper
|
|
|
|
|
+ HomeChannel dataclass on the PlatformConfig; every other key is merged
|
|
|
|
|
+ into PlatformConfig.extra.
|
|
|
|
|
|
|
|
Function name should be the same as register argument name with "hermes_" prefix, so we
|
|
Function name should be the same as register argument name with "hermes_" prefix, so we
|
|
|
know that it is needed for plugin register().
|
|
know that it is needed for plugin register().
|
|
|
"""
|
|
"""
|
|
|
- # Seed keys must be the config.yaml "extra" keys (config_key), NOT the env
|
|
|
|
|
- # var names — ChattoConfiguration reads extra[config_key].
|
|
|
|
|
- seed: dict[str, Any] = {
|
|
|
|
|
- ChattoConfiguration.base_url.field_name: (
|
|
|
|
|
- os.getenv(ChattoConfiguration.base_url.env_name)
|
|
|
|
|
- or ChattoClient.DEFAULT_BASE_URL
|
|
|
|
|
- ).strip(),
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ seed: dict[str, Any] = {}
|
|
|
for field in ChattoConfiguration.fields():
|
|
for field in ChattoConfiguration.fields():
|
|
|
- if field.field_name == ChattoConfiguration.base_url.field_name:
|
|
|
|
|
- continue
|
|
|
|
|
env_value = os.getenv(field.env_name)
|
|
env_value = os.getenv(field.env_name)
|
|
|
if env_value:
|
|
if env_value:
|
|
|
seed[field.config_key] = env_value.strip()
|
|
seed[field.config_key] = env_value.strip()
|