agent-runtime-core 0.5.2__py3-none-any.whl → 0.6.0__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.
- agent_runtime_core/__init__.py +1 -1
- agent_runtime_core/registry.py +100 -21
- {agent_runtime_core-0.5.2.dist-info → agent_runtime_core-0.6.0.dist-info}/METADATA +2 -1
- {agent_runtime_core-0.5.2.dist-info → agent_runtime_core-0.6.0.dist-info}/RECORD +6 -6
- {agent_runtime_core-0.5.2.dist-info → agent_runtime_core-0.6.0.dist-info}/WHEEL +0 -0
- {agent_runtime_core-0.5.2.dist-info → agent_runtime_core-0.6.0.dist-info}/licenses/LICENSE +0 -0
agent_runtime_core/__init__.py
CHANGED
agent_runtime_core/registry.py
CHANGED
|
@@ -3,72 +3,151 @@ Agent runtime registry.
|
|
|
3
3
|
|
|
4
4
|
Provides a global registry for agent runtimes, allowing them to be
|
|
5
5
|
looked up by key.
|
|
6
|
+
|
|
7
|
+
Supports:
|
|
8
|
+
- Manual registration via register_runtime()
|
|
9
|
+
- Factory functions for lazy instantiation
|
|
10
|
+
- Class registration (auto-instantiation)
|
|
6
11
|
"""
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
import logging
|
|
14
|
+
from typing import Callable, Optional, Type, Union
|
|
9
15
|
|
|
10
16
|
from agent_runtime_core.interfaces import AgentRuntime
|
|
11
17
|
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
12
19
|
|
|
13
20
|
# Global registry
|
|
14
21
|
_runtimes: dict[str, AgentRuntime] = {}
|
|
22
|
+
_runtime_factories: dict[str, Callable[[], AgentRuntime]] = {}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _is_agent_runtime(obj) -> bool:
|
|
26
|
+
"""Check if an object is an AgentRuntime instance."""
|
|
27
|
+
return isinstance(obj, AgentRuntime)
|
|
28
|
+
|
|
15
29
|
|
|
30
|
+
def _is_agent_runtime_class(cls) -> bool:
|
|
31
|
+
"""Check if a class is an AgentRuntime subclass."""
|
|
32
|
+
if not isinstance(cls, type):
|
|
33
|
+
return False
|
|
34
|
+
try:
|
|
35
|
+
return issubclass(cls, AgentRuntime)
|
|
36
|
+
except TypeError:
|
|
37
|
+
return False
|
|
16
38
|
|
|
17
|
-
|
|
39
|
+
|
|
40
|
+
def register_runtime(
|
|
41
|
+
runtime: Union[AgentRuntime, Type[AgentRuntime], Callable[[], AgentRuntime]],
|
|
42
|
+
key: Optional[str] = None,
|
|
43
|
+
) -> None:
|
|
18
44
|
"""
|
|
19
45
|
Register an agent runtime.
|
|
20
|
-
|
|
46
|
+
|
|
21
47
|
Args:
|
|
22
|
-
runtime:
|
|
23
|
-
|
|
48
|
+
runtime: Runtime instance, class, or factory function
|
|
49
|
+
key: Optional key override (uses runtime.key if not provided)
|
|
50
|
+
|
|
51
|
+
Examples:
|
|
52
|
+
# Register an instance
|
|
53
|
+
register_runtime(MyRuntime())
|
|
54
|
+
|
|
55
|
+
# Register a class (will be instantiated)
|
|
56
|
+
register_runtime(MyRuntime)
|
|
57
|
+
|
|
58
|
+
# Register with custom key
|
|
59
|
+
register_runtime(MyRuntime(), key="custom-key")
|
|
60
|
+
|
|
61
|
+
# Register a factory
|
|
62
|
+
register_runtime(lambda: MyRuntime(config=get_config()), key="my-runtime")
|
|
63
|
+
|
|
24
64
|
Raises:
|
|
25
|
-
ValueError: If
|
|
65
|
+
ValueError: If key is required but not provided
|
|
66
|
+
TypeError: If runtime is not a valid type
|
|
26
67
|
"""
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
68
|
+
if _is_agent_runtime(runtime):
|
|
69
|
+
# Instance provided
|
|
70
|
+
runtime_key = key or runtime.key
|
|
71
|
+
_runtimes[runtime_key] = runtime
|
|
72
|
+
logger.info(f"Registered agent runtime: {runtime_key}")
|
|
73
|
+
|
|
74
|
+
elif _is_agent_runtime_class(runtime):
|
|
75
|
+
# Class provided - instantiate it
|
|
76
|
+
instance = runtime()
|
|
77
|
+
runtime_key = key or instance.key
|
|
78
|
+
_runtimes[runtime_key] = instance
|
|
79
|
+
logger.info(f"Registered agent runtime: {runtime_key}")
|
|
31
80
|
|
|
81
|
+
elif callable(runtime):
|
|
82
|
+
# Factory function provided
|
|
83
|
+
if not key:
|
|
84
|
+
raise ValueError("key is required when registering a factory function")
|
|
85
|
+
_runtime_factories[key] = runtime
|
|
86
|
+
logger.info(f"Registered agent runtime factory: {key}")
|
|
32
87
|
|
|
33
|
-
|
|
88
|
+
else:
|
|
89
|
+
raise TypeError(
|
|
90
|
+
f"runtime must be AgentRuntime instance, class, or callable, got {type(runtime)}"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def get_runtime(key: str) -> AgentRuntime:
|
|
34
95
|
"""
|
|
35
96
|
Get a registered runtime by key.
|
|
36
|
-
|
|
97
|
+
|
|
37
98
|
Args:
|
|
38
99
|
key: The runtime key
|
|
39
|
-
|
|
100
|
+
|
|
40
101
|
Returns:
|
|
41
|
-
The runtime
|
|
102
|
+
The runtime instance
|
|
103
|
+
|
|
104
|
+
Raises:
|
|
105
|
+
KeyError: If runtime not found
|
|
42
106
|
"""
|
|
43
|
-
|
|
107
|
+
# Check instances first
|
|
108
|
+
if key in _runtimes:
|
|
109
|
+
return _runtimes[key]
|
|
110
|
+
|
|
111
|
+
# Check factories
|
|
112
|
+
if key in _runtime_factories:
|
|
113
|
+
instance = _runtime_factories[key]()
|
|
114
|
+
_runtimes[key] = instance
|
|
115
|
+
return instance
|
|
116
|
+
|
|
117
|
+
raise KeyError(f"Agent runtime not found: {key}. Available: {list_runtimes()}")
|
|
44
118
|
|
|
45
119
|
|
|
46
120
|
def list_runtimes() -> list[str]:
|
|
47
121
|
"""
|
|
48
122
|
List all registered runtime keys.
|
|
49
|
-
|
|
123
|
+
|
|
50
124
|
Returns:
|
|
51
125
|
List of runtime keys
|
|
52
126
|
"""
|
|
53
|
-
return list(_runtimes.keys())
|
|
127
|
+
return list(set(_runtimes.keys()) | set(_runtime_factories.keys()))
|
|
54
128
|
|
|
55
129
|
|
|
56
130
|
def unregister_runtime(key: str) -> bool:
|
|
57
131
|
"""
|
|
58
132
|
Unregister a runtime.
|
|
59
|
-
|
|
133
|
+
|
|
60
134
|
Args:
|
|
61
135
|
key: The runtime key
|
|
62
|
-
|
|
136
|
+
|
|
63
137
|
Returns:
|
|
64
138
|
True if unregistered, False if not found
|
|
65
139
|
"""
|
|
140
|
+
removed = False
|
|
66
141
|
if key in _runtimes:
|
|
67
142
|
del _runtimes[key]
|
|
68
|
-
|
|
69
|
-
|
|
143
|
+
removed = True
|
|
144
|
+
if key in _runtime_factories:
|
|
145
|
+
del _runtime_factories[key]
|
|
146
|
+
removed = True
|
|
147
|
+
return removed
|
|
70
148
|
|
|
71
149
|
|
|
72
150
|
def clear_registry() -> None:
|
|
73
151
|
"""Clear all registered runtimes. Useful for testing."""
|
|
74
152
|
_runtimes.clear()
|
|
153
|
+
_runtime_factories.clear()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-runtime-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: Framework-agnostic Python library for executing AI agents with consistent patterns
|
|
5
5
|
Project-URL: Homepage, https://github.com/makemore/agent-runtime-core
|
|
6
6
|
Project-URL: Repository, https://github.com/makemore/agent-runtime-core
|
|
@@ -53,6 +53,7 @@ A lightweight, framework-agnostic Python library for building AI agent systems.
|
|
|
53
53
|
|
|
54
54
|
| Version | Date | Changes |
|
|
55
55
|
|---------|------|---------|
|
|
56
|
+
| **0.6.0** | 2025-01-23 | Enhanced registry with factory functions and class registration |
|
|
56
57
|
| **0.5.2** | 2025-01-14 | Add ToolCallingAgent base class, execute_with_events helper |
|
|
57
58
|
| **0.5.1** | 2025-01-13 | Bug fixes and improvements |
|
|
58
59
|
| **0.5.0** | 2025-01-12 | Initial stable release |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
agent_runtime_core/__init__.py,sha256=
|
|
1
|
+
agent_runtime_core/__init__.py,sha256=qPJb-oJ424TMygK4OxUpLqoOu8e4I68MWok1ufxOAzQ,4139
|
|
2
2
|
agent_runtime_core/config.py,sha256=e3_uB5brAuQcWU36sOhWF9R6RoJrngtCS-xEB3n2fas,4986
|
|
3
3
|
agent_runtime_core/interfaces.py,sha256=T74pgS229tvarQD-_o25oflylUR7jq_jbgUjnvVs6IA,12191
|
|
4
|
-
agent_runtime_core/registry.py,sha256=
|
|
4
|
+
agent_runtime_core/registry.py,sha256=QmazCAcHTsPt236Z_xEBJjdppm6jUuufE-gfvcGMUCk,3959
|
|
5
5
|
agent_runtime_core/runner.py,sha256=M3It72UhfmLt17jVnSvObiSfQ1_RN4JVUIJsjnRd2Ps,12771
|
|
6
6
|
agent_runtime_core/steps.py,sha256=XpVFK7P-ZOpr7NwaP7XFygduIpjrKld-OIig7dHNMKE,11994
|
|
7
7
|
agent_runtime_core/testing.py,sha256=ordECGprBappLBMWxlETvuf2AoIPNomJFeSedXaY30E,11131
|
|
@@ -32,7 +32,7 @@ agent_runtime_core/state/sqlite.py,sha256=HKZwDiC_7F1W8Z_Pz8roEs91XhQ9rUHfGpuQ7W
|
|
|
32
32
|
agent_runtime_core/tracing/__init__.py,sha256=u1QicGc39e30gWyQD4cQWxGGjITnkwoOPUhNrG6aNyI,1266
|
|
33
33
|
agent_runtime_core/tracing/langfuse.py,sha256=Rj2sUlatk5sFro0y68tw5X6fQcSwWxcBOSOjB0F7JTU,3660
|
|
34
34
|
agent_runtime_core/tracing/noop.py,sha256=SpsbpsUcNG6C3xZG3uyiNPUHY8etloISx3w56Q8D3KE,751
|
|
35
|
-
agent_runtime_core-0.
|
|
36
|
-
agent_runtime_core-0.
|
|
37
|
-
agent_runtime_core-0.
|
|
38
|
-
agent_runtime_core-0.
|
|
35
|
+
agent_runtime_core-0.6.0.dist-info/METADATA,sha256=Q9egtbhBSMcgmeA9TM4gy_8P5pUcN0WFMCNaAOii12w,23858
|
|
36
|
+
agent_runtime_core-0.6.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
37
|
+
agent_runtime_core-0.6.0.dist-info/licenses/LICENSE,sha256=fDlWep3_mUrj8KHV_jk275tHVEW7_9sJRhkNuGCZ_TA,1068
|
|
38
|
+
agent_runtime_core-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|