digitalkin 0.3.1.dev2__py3-none-any.whl → 0.3.2.dev14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. base_server/server_async_insecure.py +6 -5
  2. base_server/server_async_secure.py +6 -5
  3. base_server/server_sync_insecure.py +5 -4
  4. base_server/server_sync_secure.py +5 -4
  5. digitalkin/__version__.py +1 -1
  6. digitalkin/core/job_manager/base_job_manager.py +1 -1
  7. digitalkin/core/job_manager/single_job_manager.py +28 -9
  8. digitalkin/core/job_manager/taskiq_broker.py +7 -6
  9. digitalkin/core/job_manager/taskiq_job_manager.py +1 -1
  10. digitalkin/core/task_manager/surrealdb_repository.py +7 -7
  11. digitalkin/core/task_manager/task_session.py +60 -98
  12. digitalkin/grpc_servers/module_server.py +109 -168
  13. digitalkin/grpc_servers/module_servicer.py +38 -16
  14. digitalkin/grpc_servers/utils/grpc_client_wrapper.py +24 -8
  15. digitalkin/grpc_servers/utils/utility_schema_extender.py +100 -0
  16. digitalkin/models/__init__.py +1 -1
  17. digitalkin/models/core/job_manager_models.py +0 -8
  18. digitalkin/models/core/task_monitor.py +4 -0
  19. digitalkin/models/grpc_servers/models.py +91 -6
  20. digitalkin/models/module/__init__.py +18 -13
  21. digitalkin/models/module/base_types.py +61 -0
  22. digitalkin/models/module/module_context.py +173 -13
  23. digitalkin/models/module/module_types.py +28 -392
  24. digitalkin/models/module/setup_types.py +490 -0
  25. digitalkin/models/module/tool_cache.py +68 -0
  26. digitalkin/models/module/tool_reference.py +117 -0
  27. digitalkin/models/module/utility.py +167 -0
  28. digitalkin/models/services/registry.py +35 -0
  29. digitalkin/modules/__init__.py +5 -1
  30. digitalkin/modules/_base_module.py +154 -61
  31. digitalkin/modules/archetype_module.py +6 -1
  32. digitalkin/modules/tool_module.py +6 -1
  33. digitalkin/modules/triggers/__init__.py +8 -0
  34. digitalkin/modules/triggers/healthcheck_ping_trigger.py +45 -0
  35. digitalkin/modules/triggers/healthcheck_services_trigger.py +63 -0
  36. digitalkin/modules/triggers/healthcheck_status_trigger.py +52 -0
  37. digitalkin/services/__init__.py +4 -0
  38. digitalkin/services/communication/__init__.py +7 -0
  39. digitalkin/services/communication/communication_strategy.py +76 -0
  40. digitalkin/services/communication/default_communication.py +101 -0
  41. digitalkin/services/communication/grpc_communication.py +234 -0
  42. digitalkin/services/cost/grpc_cost.py +1 -1
  43. digitalkin/services/filesystem/grpc_filesystem.py +1 -1
  44. digitalkin/services/registry/__init__.py +22 -1
  45. digitalkin/services/registry/default_registry.py +135 -4
  46. digitalkin/services/registry/exceptions.py +47 -0
  47. digitalkin/services/registry/grpc_registry.py +306 -0
  48. digitalkin/services/registry/registry_models.py +15 -0
  49. digitalkin/services/registry/registry_strategy.py +88 -4
  50. digitalkin/services/services_config.py +25 -3
  51. digitalkin/services/services_models.py +5 -1
  52. digitalkin/services/setup/default_setup.py +1 -1
  53. digitalkin/services/setup/grpc_setup.py +1 -1
  54. digitalkin/services/storage/grpc_storage.py +1 -1
  55. digitalkin/services/user_profile/__init__.py +11 -0
  56. digitalkin/services/user_profile/grpc_user_profile.py +2 -2
  57. digitalkin/services/user_profile/user_profile_strategy.py +0 -15
  58. digitalkin/utils/schema_splitter.py +207 -0
  59. {digitalkin-0.3.1.dev2.dist-info → digitalkin-0.3.2.dev14.dist-info}/METADATA +5 -5
  60. digitalkin-0.3.2.dev14.dist-info/RECORD +143 -0
  61. {digitalkin-0.3.1.dev2.dist-info → digitalkin-0.3.2.dev14.dist-info}/top_level.txt +1 -0
  62. modules/archetype_with_tools_module.py +244 -0
  63. modules/cpu_intensive_module.py +1 -1
  64. modules/dynamic_setup_module.py +5 -29
  65. modules/minimal_llm_module.py +1 -1
  66. modules/text_transform_module.py +1 -1
  67. monitoring/digitalkin_observability/__init__.py +46 -0
  68. monitoring/digitalkin_observability/http_server.py +150 -0
  69. monitoring/digitalkin_observability/interceptors.py +176 -0
  70. monitoring/digitalkin_observability/metrics.py +201 -0
  71. monitoring/digitalkin_observability/prometheus.py +137 -0
  72. monitoring/tests/test_metrics.py +172 -0
  73. services/filesystem_module.py +7 -5
  74. services/storage_module.py +4 -2
  75. digitalkin/grpc_servers/registry_server.py +0 -65
  76. digitalkin/grpc_servers/registry_servicer.py +0 -456
  77. digitalkin-0.3.1.dev2.dist-info/RECORD +0 -119
  78. {digitalkin-0.3.1.dev2.dist-info → digitalkin-0.3.2.dev14.dist-info}/WHEEL +0 -0
  79. {digitalkin-0.3.1.dev2.dist-info → digitalkin-0.3.2.dev14.dist-info}/licenses/LICENSE +0 -0
@@ -1,10 +1,141 @@
1
- """Default registry."""
1
+ """Default registry implementation."""
2
2
 
3
+ from typing import ClassVar
4
+
5
+ from digitalkin.models.services.registry import (
6
+ ModuleInfo,
7
+ RegistryModuleStatus,
8
+ RegistryModuleType,
9
+ )
10
+ from digitalkin.services.registry.exceptions import RegistryModuleNotFoundError
11
+ from digitalkin.services.registry.registry_models import ModuleStatusInfo
3
12
  from digitalkin.services.registry.registry_strategy import RegistryStrategy
4
13
 
5
14
 
6
15
  class DefaultRegistry(RegistryStrategy):
7
- """Default registry strategy."""
16
+ """Default registry strategy using in-memory storage."""
17
+
18
+ _modules: ClassVar[dict[str, ModuleInfo]] = {}
19
+
20
+ def discover_by_id(self, module_id: str) -> ModuleInfo:
21
+ """Get module info by ID.
22
+
23
+ Args:
24
+ module_id: The module identifier.
25
+
26
+ Returns:
27
+ ModuleInfo with module details.
28
+
29
+ Raises:
30
+ RegistryModuleNotFoundError: If module not found.
31
+ """
32
+ if module_id not in self._modules:
33
+ raise RegistryModuleNotFoundError(module_id)
34
+ return self._modules[module_id]
35
+
36
+ def search(
37
+ self,
38
+ name: str | None = None,
39
+ module_type: str | None = None,
40
+ organization_id: str | None = None, # noqa: ARG002
41
+ ) -> list[ModuleInfo]:
42
+ """Search for modules by criteria.
43
+
44
+ Args:
45
+ name: Filter by name (partial match).
46
+ module_type: Filter by type (archetype, tool).
47
+ organization_id: Filter by organization (not used in local storage).
48
+
49
+ Returns:
50
+ List of matching modules.
51
+ """
52
+ results = list(self._modules.values())
53
+
54
+ if name:
55
+ results = [m for m in results if name in m.name]
56
+
57
+ if module_type:
58
+ results = [m for m in results if m.module_type == module_type]
59
+
60
+ return results
61
+
62
+ def get_status(self, module_id: str) -> ModuleStatusInfo:
63
+ """Get module status.
64
+
65
+ Args:
66
+ module_id: The module identifier.
67
+
68
+ Returns:
69
+ ModuleStatusInfo with current status.
70
+
71
+ Raises:
72
+ RegistryModuleNotFoundError: If module not found.
73
+ """
74
+ if module_id not in self._modules:
75
+ raise RegistryModuleNotFoundError(module_id)
76
+
77
+ module = self._modules[module_id]
78
+ return ModuleStatusInfo(
79
+ module_id=module_id,
80
+ status=module.status or RegistryModuleStatus.UNSPECIFIED,
81
+ )
82
+
83
+ def register(
84
+ self,
85
+ module_id: str,
86
+ address: str,
87
+ port: int,
88
+ version: str,
89
+ ) -> ModuleInfo | None:
90
+ """Register a module with the registry.
91
+
92
+ Note: Updates existing module or creates new one in local storage.
93
+
94
+ Args:
95
+ module_id: Unique module identifier.
96
+ address: Network address.
97
+ port: Network port.
98
+ version: Module version.
99
+
100
+ Returns:
101
+ ModuleInfo if successful, None otherwise.
102
+ """
103
+ existing = self._modules.get(module_id)
104
+ self._modules[module_id] = ModuleInfo(
105
+ module_id=module_id,
106
+ module_type=existing.module_type if existing else RegistryModuleType.UNSPECIFIED,
107
+ address=address,
108
+ port=port,
109
+ version=version,
110
+ name=existing.name if existing else module_id,
111
+ status=RegistryModuleStatus.ACTIVE,
112
+ )
113
+ return self._modules[module_id]
114
+
115
+ def heartbeat(self, module_id: str) -> RegistryModuleStatus:
116
+ """Send heartbeat to keep module active.
117
+
118
+ Args:
119
+ module_id: The module identifier.
120
+
121
+ Returns:
122
+ Current module status after heartbeat.
123
+
124
+ Raises:
125
+ RegistryModuleNotFoundError: If module not found.
126
+ """
127
+ if module_id not in self._modules:
128
+ raise RegistryModuleNotFoundError(module_id)
8
129
 
9
- def get_by_id(self, module_id: str) -> None:
10
- """Get services from the registry."""
130
+ module = self._modules[module_id]
131
+ # Update status to ACTIVE on heartbeat
132
+ self._modules[module_id] = ModuleInfo(
133
+ module_id=module.module_id,
134
+ module_type=module.module_type,
135
+ address=module.address,
136
+ port=module.port,
137
+ version=module.version,
138
+ name=module.name,
139
+ status=RegistryModuleStatus.ACTIVE,
140
+ )
141
+ return RegistryModuleStatus.ACTIVE
@@ -0,0 +1,47 @@
1
+ """Registry-specific exceptions.
2
+
3
+ This module contains custom exceptions for registry service operations.
4
+ """
5
+
6
+
7
+ class RegistryServiceError(Exception):
8
+ """Base exception for registry service errors."""
9
+
10
+
11
+ class RegistryModuleNotFoundError(RegistryServiceError):
12
+ """Raised when a module is not found in the registry."""
13
+
14
+ def __init__(self, module_id: str) -> None:
15
+ """Initialize the exception.
16
+
17
+ Args:
18
+ module_id: The ID of the module that was not found.
19
+ """
20
+ self.module_id = module_id
21
+ super().__init__(f"Module '{module_id}' not found in registry")
22
+
23
+
24
+ class ModuleAlreadyExistsError(RegistryServiceError):
25
+ """Raised when attempting to register an already-registered module."""
26
+
27
+ def __init__(self, module_id: str) -> None:
28
+ """Initialize the exception.
29
+
30
+ Args:
31
+ module_id: The ID of the module that already exists.
32
+ """
33
+ self.module_id = module_id
34
+ super().__init__(f"Module '{module_id}' already registered")
35
+
36
+
37
+ class InvalidStatusError(RegistryServiceError):
38
+ """Raised when an invalid status is provided."""
39
+
40
+ def __init__(self, status: int) -> None:
41
+ """Initialize the exception.
42
+
43
+ Args:
44
+ status: The invalid status value.
45
+ """
46
+ self.status = status
47
+ super().__init__(f"Invalid module status: {status}")
@@ -0,0 +1,306 @@
1
+ """gRPC Registry client implementation.
2
+
3
+ This module provides a gRPC-based registry client that communicates with
4
+ the Service Provider's Registry service.
5
+ """
6
+
7
+ from typing import Any
8
+
9
+ from agentic_mesh_protocol.registry.v1 import (
10
+ registry_enums_pb2,
11
+ registry_models_pb2,
12
+ registry_requests_pb2,
13
+ registry_service_pb2_grpc,
14
+ )
15
+
16
+ from digitalkin.grpc_servers.utils.exceptions import ServerError
17
+ from digitalkin.grpc_servers.utils.grpc_client_wrapper import GrpcClientWrapper
18
+ from digitalkin.grpc_servers.utils.grpc_error_handler import GrpcErrorHandlerMixin
19
+ from digitalkin.logger import logger
20
+ from digitalkin.models.grpc_servers.models import ClientConfig
21
+ from digitalkin.models.services.registry import (
22
+ ModuleInfo,
23
+ RegistryModuleStatus,
24
+ RegistryModuleType,
25
+ )
26
+ from digitalkin.services.registry.exceptions import (
27
+ RegistryModuleNotFoundError,
28
+ RegistryServiceError,
29
+ )
30
+ from digitalkin.services.registry.registry_models import ModuleStatusInfo
31
+ from digitalkin.services.registry.registry_strategy import RegistryStrategy
32
+
33
+
34
+ class GrpcRegistry(RegistryStrategy, GrpcClientWrapper, GrpcErrorHandlerMixin):
35
+ """gRPC-based registry client.
36
+
37
+ This client communicates with the Service Provider's Registry service
38
+ to perform module discovery, registration, and status management operations.
39
+ """
40
+
41
+ def __init__(
42
+ self,
43
+ mission_id: str,
44
+ setup_id: str,
45
+ setup_version_id: str,
46
+ client_config: ClientConfig,
47
+ config: dict[str, Any] | None = None,
48
+ ) -> None:
49
+ """Initialize the gRPC registry client."""
50
+ RegistryStrategy.__init__(self, mission_id, setup_id, setup_version_id, config)
51
+ self.service_name = "RegistryService"
52
+ self.stub = registry_service_pb2_grpc.RegistryServiceStub(self._init_channel(client_config))
53
+ logger.debug("Channel client 'Registry' initialized successfully")
54
+
55
+ @staticmethod
56
+ def _proto_to_module_info(
57
+ descriptor: registry_models_pb2.ModuleDescriptor,
58
+ ) -> ModuleInfo:
59
+ """Convert proto ModuleDescriptor to ModuleInfo.
60
+
61
+ Args:
62
+ descriptor: Proto ModuleDescriptor message.
63
+
64
+ Returns:
65
+ ModuleInfo with mapped fields.
66
+ """
67
+ type_name = registry_enums_pb2.ModuleType.Name(descriptor.module_type).removeprefix("MODULE_TYPE_")
68
+ return ModuleInfo(
69
+ module_id=descriptor.id,
70
+ module_type=RegistryModuleType[type_name],
71
+ address=descriptor.address,
72
+ port=descriptor.port,
73
+ version=descriptor.version,
74
+ name=descriptor.name,
75
+ documentation=descriptor.documentation or None,
76
+ )
77
+
78
+ def discover_by_id(self, module_id: str) -> ModuleInfo:
79
+ """Get module info by ID.
80
+
81
+ Args:
82
+ module_id: The module identifier.
83
+
84
+ Returns:
85
+ ModuleInfo with module details.
86
+
87
+ Raises:
88
+ RegistryModuleNotFoundError: If module not found.
89
+ RegistryServiceError: If gRPC call fails.
90
+ """
91
+ logger.debug("Discovering module by ID", extra={"module_id": module_id})
92
+
93
+ with self.handle_grpc_errors("GetModule", RegistryServiceError):
94
+ try:
95
+ response = self.exec_grpc_query(
96
+ "GetModule",
97
+ registry_requests_pb2.GetModuleRequest(module_id=module_id),
98
+ )
99
+ except ServerError as e:
100
+ msg = f"Failed to discover module '{module_id}': {e}"
101
+ logger.error(msg)
102
+ raise RegistryServiceError(msg) from e
103
+
104
+ if not response.id:
105
+ logger.warning("Module not found in registry", extra={"module_id": module_id})
106
+ raise RegistryModuleNotFoundError(module_id)
107
+
108
+ logger.debug(
109
+ "Module discovered",
110
+ extra={
111
+ "module_id": response.id,
112
+ "address": response.address,
113
+ "port": response.port,
114
+ },
115
+ )
116
+ return self._proto_to_module_info(response)
117
+
118
+ def search(
119
+ self,
120
+ name: str | None = None,
121
+ module_type: str | None = None,
122
+ organization_id: str | None = None,
123
+ ) -> list[ModuleInfo]:
124
+ """Search for modules by criteria.
125
+
126
+ Args:
127
+ name: Filter by name (partial match via query).
128
+ module_type: Filter by type (archetype, tool).
129
+ organization_id: Filter by organization.
130
+
131
+ Returns:
132
+ List of matching modules.
133
+
134
+ Raises:
135
+ RegistryServiceError: If gRPC call fails.
136
+ """
137
+ logger.debug(
138
+ "Searching modules",
139
+ extra={
140
+ "name": name,
141
+ "module_type": module_type,
142
+ "organization_id": organization_id,
143
+ },
144
+ )
145
+
146
+ with self.handle_grpc_errors("DiscoverModules", RegistryServiceError):
147
+ module_types = []
148
+ if module_type:
149
+ enum_val = RegistryModuleType[module_type.upper()]
150
+ module_types.append(getattr(registry_enums_pb2, f"MODULE_TYPE_{enum_val.name}"))
151
+
152
+ try:
153
+ response = self.exec_grpc_query(
154
+ "DiscoverModules",
155
+ registry_requests_pb2.DiscoverModulesRequest(
156
+ query=name or "",
157
+ organization_id=organization_id or "",
158
+ module_types=module_types,
159
+ ),
160
+ )
161
+ except ServerError as e:
162
+ msg = f"Failed to search modules: {e}"
163
+ logger.error(msg)
164
+ raise RegistryServiceError(msg) from e
165
+
166
+ logger.debug("Search returned %d modules", len(response.modules))
167
+ return [self._proto_to_module_info(m) for m in response.modules]
168
+
169
+ def get_status(self, module_id: str) -> ModuleStatusInfo:
170
+ """Get module status by fetching the module.
171
+
172
+ Args:
173
+ module_id: The module identifier.
174
+
175
+ Returns:
176
+ ModuleStatusInfo with current status.
177
+
178
+ Raises:
179
+ RegistryModuleNotFoundError: If module not found.
180
+ RegistryServiceError: If gRPC call fails.
181
+ """
182
+ logger.debug("Getting module status", extra={"module_id": module_id})
183
+
184
+ with self.handle_grpc_errors("GetModule", RegistryServiceError):
185
+ try:
186
+ response = self.exec_grpc_query(
187
+ "GetModule",
188
+ registry_requests_pb2.GetModuleRequest(module_id=module_id),
189
+ )
190
+ except ServerError as e:
191
+ msg = f"Failed to get module status for '{module_id}': {e}"
192
+ logger.error(msg)
193
+ raise RegistryServiceError(msg) from e
194
+
195
+ if not response.id:
196
+ logger.warning("Module not found in registry", extra={"module_id": module_id})
197
+ raise RegistryModuleNotFoundError(module_id)
198
+
199
+ status_name = registry_enums_pb2.ModuleStatus.Name(response.status).removeprefix("MODULE_STATUS_")
200
+ logger.debug(
201
+ "Module status retrieved",
202
+ extra={"module_id": response.id, "status": status_name},
203
+ )
204
+ return ModuleStatusInfo(
205
+ module_id=response.id,
206
+ status=RegistryModuleStatus[status_name],
207
+ )
208
+
209
+ def register(
210
+ self,
211
+ module_id: str,
212
+ address: str,
213
+ port: int,
214
+ version: str,
215
+ ) -> ModuleInfo | None:
216
+ """Register a module with the registry.
217
+
218
+ Note: The new proto only updates address/port/version for an existing module.
219
+ The module must already exist in the registry database.
220
+
221
+ Args:
222
+ module_id: Unique module identifier.
223
+ address: Network address.
224
+ port: Network port.
225
+ version: Module version.
226
+
227
+ Returns:
228
+ ModuleInfo if successful, None if module not found.
229
+
230
+ Raises:
231
+ RegistryServiceError: If gRPC call fails.
232
+ """
233
+ logger.info(
234
+ "Registering module with registry",
235
+ extra={
236
+ "module_id": module_id,
237
+ "address": address,
238
+ "port": port,
239
+ "version": version,
240
+ },
241
+ )
242
+
243
+ with self.handle_grpc_errors("RegisterModule", RegistryServiceError):
244
+ try:
245
+ response = self.exec_grpc_query(
246
+ "RegisterModule",
247
+ registry_requests_pb2.RegisterModuleRequest(
248
+ module_id=module_id,
249
+ address=address,
250
+ port=port,
251
+ version=version,
252
+ ),
253
+ )
254
+ except ServerError as e:
255
+ msg = f"Failed to register module '{module_id}': {e}"
256
+ logger.error(msg)
257
+ raise RegistryServiceError(msg) from e
258
+
259
+ if not response.module or not response.module.id:
260
+ logger.warning(
261
+ "Registry returned empty response for module registration",
262
+ extra={"module_id": module_id},
263
+ )
264
+ return None
265
+
266
+ logger.info(
267
+ "Module registered successfully",
268
+ extra={
269
+ "module_id": response.module.id,
270
+ "address": response.module.address,
271
+ "port": response.module.port,
272
+ },
273
+ )
274
+ return self._proto_to_module_info(response.module)
275
+
276
+ def heartbeat(self, module_id: str) -> RegistryModuleStatus:
277
+ """Send heartbeat to keep module active.
278
+
279
+ Args:
280
+ module_id: The module identifier.
281
+
282
+ Returns:
283
+ Current module status after heartbeat.
284
+
285
+ Raises:
286
+ RegistryServiceError: If gRPC call fails.
287
+ """
288
+ logger.debug("Sending heartbeat", extra={"module_id": module_id})
289
+
290
+ with self.handle_grpc_errors("Heartbeat", RegistryServiceError):
291
+ try:
292
+ response = self.exec_grpc_query(
293
+ "Heartbeat",
294
+ registry_requests_pb2.HeartbeatRequest(module_id=module_id),
295
+ )
296
+ except ServerError as e:
297
+ msg = f"Failed to send heartbeat for '{module_id}': {e}"
298
+ logger.error(msg)
299
+ raise RegistryServiceError(msg) from e
300
+
301
+ status_name = registry_enums_pb2.ModuleStatus.Name(response.status).removeprefix("MODULE_STATUS_")
302
+ logger.debug(
303
+ "Heartbeat response",
304
+ extra={"module_id": module_id, "status": status_name},
305
+ )
306
+ return RegistryModuleStatus[status_name]
@@ -0,0 +1,15 @@
1
+ """Registry data models.
2
+
3
+ This module contains Pydantic models for registry service data structures.
4
+ """
5
+
6
+ from pydantic import BaseModel
7
+
8
+ from digitalkin.models.services.registry import RegistryModuleStatus
9
+
10
+
11
+ class ModuleStatusInfo(BaseModel):
12
+ """Module status response."""
13
+
14
+ module_id: str
15
+ status: RegistryModuleStatus
@@ -1,14 +1,98 @@
1
- """This module contains the abstract base class for registry strategies."""
1
+ """Abstract base class for registry strategies."""
2
2
 
3
3
  from abc import ABC, abstractmethod
4
+ from typing import Any
4
5
 
6
+ from digitalkin.models.services.registry import (
7
+ ModuleInfo,
8
+ RegistryModuleStatus,
9
+ )
5
10
  from digitalkin.services.base_strategy import BaseStrategy
11
+ from digitalkin.services.registry.registry_models import ModuleStatusInfo
6
12
 
7
13
 
8
14
  class RegistryStrategy(BaseStrategy, ABC):
9
- """Abstract base class for registry strategies."""
15
+ """Abstract base class for registry strategies.
16
+
17
+ Defines the interface for registry operations including module discovery,
18
+ registration, and status management.
19
+ """
20
+
21
+ def __init__(
22
+ self,
23
+ mission_id: str,
24
+ setup_id: str,
25
+ setup_version_id: str,
26
+ config: dict[str, Any] | None = None,
27
+ ) -> None:
28
+ """Initialize the strategy."""
29
+ super().__init__(mission_id, setup_id, setup_version_id)
30
+ self.config = config
31
+
32
+ @abstractmethod
33
+ def discover_by_id(self, module_id: str) -> ModuleInfo:
34
+ """Get module info by ID."""
35
+ raise NotImplementedError
36
+
37
+ @abstractmethod
38
+ def search(
39
+ self,
40
+ name: str | None = None,
41
+ module_type: str | None = None,
42
+ organization_id: str | None = None,
43
+ ) -> list[ModuleInfo]:
44
+ """Search for modules by criteria.
45
+
46
+ Args:
47
+ name: Filter by name (partial match via query).
48
+ module_type: Filter by type (archetype, tool).
49
+ organization_id: Filter by organization.
50
+
51
+ Returns:
52
+ List of matching modules.
53
+ """
54
+ raise NotImplementedError
55
+
56
+ @abstractmethod
57
+ def get_status(self, module_id: str) -> ModuleStatusInfo:
58
+ """Get module status."""
59
+ raise NotImplementedError
10
60
 
11
61
  @abstractmethod
12
- def get_by_id(self, module_id: str) -> None:
13
- """Get services from the registry."""
62
+ def register(
63
+ self,
64
+ module_id: str,
65
+ address: str,
66
+ port: int,
67
+ version: str,
68
+ ) -> ModuleInfo | None:
69
+ """Register a module with the registry.
70
+
71
+ Note: The new proto only updates address/port/version for an existing module.
72
+ The module must already exist in the registry database.
73
+
74
+ Args:
75
+ module_id: Unique module identifier.
76
+ address: Network address.
77
+ port: Network port.
78
+ version: Module version.
79
+
80
+ Returns:
81
+ ModuleInfo if successful, None otherwise.
82
+ """
83
+ raise NotImplementedError
84
+
85
+ @abstractmethod
86
+ def heartbeat(self, module_id: str) -> RegistryModuleStatus:
87
+ """Send heartbeat to keep module active.
88
+
89
+ Args:
90
+ module_id: The module identifier.
91
+
92
+ Returns:
93
+ Current module status after heartbeat.
94
+
95
+ Raises:
96
+ RegistryModuleNotFoundError: If module not found.
97
+ """
14
98
  raise NotImplementedError
@@ -5,13 +5,15 @@ from typing import Any, ClassVar
5
5
  from pydantic import BaseModel, Field, PrivateAttr
6
6
 
7
7
  from digitalkin.services.agent import AgentStrategy, DefaultAgent
8
+ from digitalkin.services.communication import CommunicationStrategy, DefaultCommunication, GrpcCommunication
8
9
  from digitalkin.services.cost import CostStrategy, DefaultCost, GrpcCost
9
10
  from digitalkin.services.filesystem import DefaultFilesystem, FilesystemStrategy, GrpcFilesystem
10
11
  from digitalkin.services.identity import DefaultIdentity, IdentityStrategy
11
- from digitalkin.services.registry import DefaultRegistry, RegistryStrategy
12
+ from digitalkin.services.registry import DefaultRegistry, GrpcRegistry, RegistryStrategy
12
13
  from digitalkin.services.services_models import ServicesMode, ServicesStrategy
13
14
  from digitalkin.services.snapshot import DefaultSnapshot, SnapshotStrategy
14
15
  from digitalkin.services.storage import DefaultStorage, GrpcStorage, StorageStrategy
16
+ from digitalkin.services.user_profile import DefaultUserProfile, GrpcUserProfile, UserProfileStrategy
15
17
 
16
18
 
17
19
  class ServicesConfig(BaseModel):
@@ -38,9 +40,9 @@ class ServicesConfig(BaseModel):
38
40
  )
39
41
  _config_snapshot: dict[str, Any | None] = PrivateAttr(default_factory=dict)
40
42
  _registry: ServicesStrategy[RegistryStrategy] = PrivateAttr(
41
- default_factory=lambda: ServicesStrategy(local=DefaultRegistry, remote=DefaultRegistry)
43
+ default_factory=lambda: ServicesStrategy(local=DefaultRegistry, remote=GrpcRegistry)
42
44
  )
43
- _config__registry: dict[str, Any | None] = PrivateAttr(default_factory=dict)
45
+ _config_registry: dict[str, Any | None] = PrivateAttr(default_factory=dict)
44
46
  _filesystem: ServicesStrategy[FilesystemStrategy] = PrivateAttr(
45
47
  default_factory=lambda: ServicesStrategy(local=DefaultFilesystem, remote=GrpcFilesystem)
46
48
  )
@@ -53,6 +55,14 @@ class ServicesConfig(BaseModel):
53
55
  default_factory=lambda: ServicesStrategy(local=DefaultIdentity, remote=DefaultIdentity)
54
56
  )
55
57
  _config_identity: dict[str, Any | None] = PrivateAttr(default_factory=dict)
58
+ _communication: ServicesStrategy[CommunicationStrategy] = PrivateAttr(
59
+ default_factory=lambda: ServicesStrategy(local=DefaultCommunication, remote=GrpcCommunication)
60
+ )
61
+ _config_communication: dict[str, Any | None] = PrivateAttr(default_factory=dict)
62
+ _user_profile: ServicesStrategy[UserProfileStrategy] = PrivateAttr(
63
+ default_factory=lambda: ServicesStrategy(local=DefaultUserProfile, remote=GrpcUserProfile)
64
+ )
65
+ _config_user_profile: dict[str, Any | None] = PrivateAttr(default_factory=dict)
56
66
 
57
67
  # List of valid strategy names for validation
58
68
  _valid_strategy_names: ClassVar[set[str]] = {
@@ -63,6 +73,8 @@ class ServicesConfig(BaseModel):
63
73
  "filesystem",
64
74
  "agent",
65
75
  "identity",
76
+ "communication",
77
+ "user_profile",
66
78
  }
67
79
 
68
80
  def __init__(
@@ -169,6 +181,16 @@ class ServicesConfig(BaseModel):
169
181
  """Get the identity service strategy class based on the current mode."""
170
182
  return self._identity[self.mode.value]
171
183
 
184
+ @property
185
+ def communication(self) -> type[CommunicationStrategy]:
186
+ """Get the communication service strategy class based on the current mode."""
187
+ return self._communication[self.mode.value]
188
+
189
+ @property
190
+ def user_profile(self) -> type[UserProfileStrategy]:
191
+ """Get the user_profile service strategy class based on the current mode."""
192
+ return self._user_profile[self.mode.value]
193
+
172
194
  def update_mode(self, mode: ServicesMode) -> None:
173
195
  """Update the strategy mode.
174
196