The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(runtime): canonical served-profile names instead of the profiles/-parent guess
Teknium73617dd9c0ac
diff --git a/gateway/session_bot.py b/gateway/session_bot.pyindex c9a3d48f73e..25a124a4034 100644--- a/gateway/session_bot.py+++ b/gateway/session_bot.py@@ -16,8 +16,9 @@ from tools.bot_live_delivery import _delivery_id, _locked, _read, _writedef _home(authority, actor, profile):+ from gateway.session_authorities import served_profile_namehome = Path(authority.db.db_path).parent.resolve()- name = home.name if home.parent.name == 'profiles' else 'default'+ name = served_profile_name(home)if actor.profile_id != authority.profile_id or profile not in (name, 'hermes' if name == 'default' else name):raise RuntimeStoreError('profile_mismatch')if 'session:submit' not in actor.capabilities:@@ -73,8 +74,9 @@ async def _record_reply(authority, home, key, future):def relay_operation(connection, operation, params):authority, actor = connection.authority, connection.actor+ from gateway.session_authorities import served_profile_namehome = Path(authority.db.db_path).parent.resolve()- name = home.name if home.parent.name == 'profiles' else 'default'+ name = served_profile_name(home)_home(authority, actor, name)if 'session:control' not in actor.capabilities:raise RuntimeStoreError('permission_denied')diff --git a/gateway/session_group_controls.py b/gateway/session_group_controls.pyindex a5f57f1195b..eadb486c5c1 100644--- a/gateway/session_group_controls.py+++ b/gateway/session_group_controls.py@@ -139,7 +139,8 @@ def _group(authority, actor, home, method, params):if service is not None:return {'room': service.create_room(**params)}from gateway.hosted_room_discussion import validate_roster- name = home.name if home.parent.name == 'profiles' else 'default'+ from gateway.session_authorities import served_profile_name+ name = served_profile_name(home)profiles = {name}if name == 'default' and (home / 'profiles').is_dir():profiles.update(path.name for path in (home / 'profiles').iterdir() if path.is_dir())@@ -233,7 +234,8 @@ def _profiles(authority, actor, home, params):include_sessions = params.get('include_sessions', True)if type(include_sessions) is not bool:raise RuntimeStoreError('invalid_params')- name = home.name if home.parent.name == 'profiles' else 'default'+ from gateway.session_authorities import served_profile_name+ name = served_profile_name(home)profile = _profile_info(name, home, is_default=name == 'default')row = {'name': name, 'path': str(home), 'is_default': profile.is_default,'model': profile.model, 'provider': profile.provider,diff --git a/gateway/session_hosted_service.py b/gateway/session_hosted_service.pyindex 25b9982faa0..75dbb3fe948 100644--- a/gateway/session_hosted_service.py+++ b/gateway/session_hosted_service.py@@ -25,8 +25,9 @@ class CanonicalHostedRoomService(HostedControls, HostedRoomService):def profile_homes(self):from gateway.run import _load_gateway_configfrom gateway.hosted_rooms_common import IDENTIFIER_RE+ from gateway.session_authorities import served_profile_namehome = Path(self.authority.profile_id)- own = home.name if home.parent.name == 'profiles' else 'default'+ own = served_profile_name(home)configured = _load_gateway_config().get('hosted_rooms', {}).get('profiles', {})result = {own: home}if not isinstance(configured, dict):diff --git a/gateway/session_hosted_transport.py b/gateway/session_hosted_transport.pyindex 67dfa7fbba8..5fdc59870ed 100644--- a/gateway/session_hosted_transport.py+++ b/gateway/session_hosted_transport.py@@ -157,8 +157,8 @@ def install_hosted_transport(server, authority, loop, *, attest):selector = envelope['selector']if operation not in _OPERATIONS or set(selector) != {'room_id', 'member_id', 'profile'}:raise RuntimeStoreError('invalid_params')- home = Path(authority.profile_id)- profile = home.name if home.parent.name == 'profiles' else 'default'+ from gateway.session_authorities import served_profile_name+ profile = served_profile_name(Path(authority.profile_id))if selector['profile'] != profile:raise RuntimeStoreError('profile_mismatch')binding = {'source_home': envelope['source_home'], 'selector': selector,diff --git a/hermes_cli/gateway_runtime_service_identity.py b/hermes_cli/gateway_runtime_service_identity.pyindex 415bbf75b95..df531d3c304 100644--- a/hermes_cli/gateway_runtime_service_identity.py+++ b/hermes_cli/gateway_runtime_service_identity.py@@ -77,7 +77,8 @@ def verify_gateway_argv(argv: list[str], home: Path) -> None:if profiles:# An explicit selector must agree with the pinned environment. This# preserves custom-root profiles without borrowing the caller's root.- expected = home.name if home.parent.name == "profiles" else "default"+ from hermes_constants import profile_name_for_home+ expected = profile_name_for_home(home) or (home.name if home.parent.name == "profiles" else "default")if profiles[0] != expected:raise ValueError("profile_mismatch")if filtered[:2] != ["gateway", "run"] or any(