agent-runtime-core 0.5.2__tar.gz → 0.6.0__tar.gz

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 (49) hide show
  1. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/PKG-INFO +2 -1
  2. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/README.md +1 -0
  3. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/__init__.py +1 -1
  4. agent_runtime_core-0.6.0/agent_runtime_core/registry.py +153 -0
  5. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/pyproject.toml +1 -1
  6. agent_runtime_core-0.5.2/agent_runtime_core/registry.py +0 -74
  7. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/.gitignore +0 -0
  8. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/LICENSE +0 -0
  9. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/config.py +0 -0
  10. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/events/__init__.py +0 -0
  11. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/events/base.py +0 -0
  12. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/events/memory.py +0 -0
  13. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/events/redis.py +0 -0
  14. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/events/sqlite.py +0 -0
  15. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/interfaces.py +0 -0
  16. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/llm/__init__.py +0 -0
  17. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/llm/anthropic.py +0 -0
  18. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/llm/litellm_client.py +0 -0
  19. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/llm/openai.py +0 -0
  20. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/persistence/__init__.py +0 -0
  21. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/persistence/base.py +0 -0
  22. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/persistence/file.py +0 -0
  23. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/persistence/manager.py +0 -0
  24. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/queue/__init__.py +0 -0
  25. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/queue/base.py +0 -0
  26. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/queue/memory.py +0 -0
  27. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/queue/redis.py +0 -0
  28. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/queue/sqlite.py +0 -0
  29. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/runner.py +0 -0
  30. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/state/__init__.py +0 -0
  31. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/state/base.py +0 -0
  32. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/state/memory.py +0 -0
  33. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/state/redis.py +0 -0
  34. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/state/sqlite.py +0 -0
  35. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/steps.py +0 -0
  36. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/testing.py +0 -0
  37. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/tool_calling_agent.py +0 -0
  38. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/tracing/__init__.py +0 -0
  39. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/tracing/langfuse.py +0 -0
  40. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/agent_runtime_core/tracing/noop.py +0 -0
  41. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/__init__.py +0 -0
  42. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/test_events.py +0 -0
  43. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/test_imports.py +0 -0
  44. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/test_persistence.py +0 -0
  45. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/test_queue.py +0 -0
  46. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/test_state.py +0 -0
  47. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/test_steps.py +0 -0
  48. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/tests/test_testing.py +0 -0
  49. {agent_runtime_core-0.5.2 → agent_runtime_core-0.6.0}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-runtime-core
3
- Version: 0.5.2
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 |
@@ -10,6 +10,7 @@ A lightweight, framework-agnostic Python library for building AI agent systems.
10
10
 
11
11
  | Version | Date | Changes |
12
12
  |---------|------|---------|
13
+ | **0.6.0** | 2025-01-23 | Enhanced registry with factory functions and class registration |
13
14
  | **0.5.2** | 2025-01-14 | Add ToolCallingAgent base class, execute_with_events helper |
14
15
  | **0.5.1** | 2025-01-13 | Bug fixes and improvements |
15
16
  | **0.5.0** | 2025-01-12 | Initial stable release |
@@ -34,7 +34,7 @@ Example usage:
34
34
  return RunResult(final_output={"message": "Hello!"})
35
35
  """
36
36
 
37
- __version__ = "0.5.2"
37
+ __version__ = "0.6.0"
38
38
 
39
39
  # Core interfaces
40
40
  from agent_runtime_core.interfaces import (
@@ -0,0 +1,153 @@
1
+ """
2
+ Agent runtime registry.
3
+
4
+ Provides a global registry for agent runtimes, allowing them to be
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)
11
+ """
12
+
13
+ import logging
14
+ from typing import Callable, Optional, Type, Union
15
+
16
+ from agent_runtime_core.interfaces import AgentRuntime
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+ # Global registry
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
+
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
38
+
39
+
40
+ def register_runtime(
41
+ runtime: Union[AgentRuntime, Type[AgentRuntime], Callable[[], AgentRuntime]],
42
+ key: Optional[str] = None,
43
+ ) -> None:
44
+ """
45
+ Register an agent runtime.
46
+
47
+ Args:
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
+
64
+ Raises:
65
+ ValueError: If key is required but not provided
66
+ TypeError: If runtime is not a valid type
67
+ """
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}")
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}")
87
+
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:
95
+ """
96
+ Get a registered runtime by key.
97
+
98
+ Args:
99
+ key: The runtime key
100
+
101
+ Returns:
102
+ The runtime instance
103
+
104
+ Raises:
105
+ KeyError: If runtime not found
106
+ """
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()}")
118
+
119
+
120
+ def list_runtimes() -> list[str]:
121
+ """
122
+ List all registered runtime keys.
123
+
124
+ Returns:
125
+ List of runtime keys
126
+ """
127
+ return list(set(_runtimes.keys()) | set(_runtime_factories.keys()))
128
+
129
+
130
+ def unregister_runtime(key: str) -> bool:
131
+ """
132
+ Unregister a runtime.
133
+
134
+ Args:
135
+ key: The runtime key
136
+
137
+ Returns:
138
+ True if unregistered, False if not found
139
+ """
140
+ removed = False
141
+ if key in _runtimes:
142
+ del _runtimes[key]
143
+ removed = True
144
+ if key in _runtime_factories:
145
+ del _runtime_factories[key]
146
+ removed = True
147
+ return removed
148
+
149
+
150
+ def clear_registry() -> None:
151
+ """Clear all registered runtimes. Useful for testing."""
152
+ _runtimes.clear()
153
+ _runtime_factories.clear()
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "agent-runtime-core"
7
- version = "0.5.2"
7
+ version = "0.6.0"
8
8
  description = "Framework-agnostic Python library for executing AI agents with consistent patterns"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -1,74 +0,0 @@
1
- """
2
- Agent runtime registry.
3
-
4
- Provides a global registry for agent runtimes, allowing them to be
5
- looked up by key.
6
- """
7
-
8
- from typing import Optional
9
-
10
- from agent_runtime_core.interfaces import AgentRuntime
11
-
12
-
13
- # Global registry
14
- _runtimes: dict[str, AgentRuntime] = {}
15
-
16
-
17
- def register_runtime(runtime: AgentRuntime) -> None:
18
- """
19
- Register an agent runtime.
20
-
21
- Args:
22
- runtime: The runtime to register
23
-
24
- Raises:
25
- ValueError: If a runtime with the same key is already registered
26
- """
27
- key = runtime.key
28
- if key in _runtimes:
29
- raise ValueError(f"Runtime already registered: {key}")
30
- _runtimes[key] = runtime
31
-
32
-
33
- def get_runtime(key: str) -> Optional[AgentRuntime]:
34
- """
35
- Get a registered runtime by key.
36
-
37
- Args:
38
- key: The runtime key
39
-
40
- Returns:
41
- The runtime, or None if not found
42
- """
43
- return _runtimes.get(key)
44
-
45
-
46
- def list_runtimes() -> list[str]:
47
- """
48
- List all registered runtime keys.
49
-
50
- Returns:
51
- List of runtime keys
52
- """
53
- return list(_runtimes.keys())
54
-
55
-
56
- def unregister_runtime(key: str) -> bool:
57
- """
58
- Unregister a runtime.
59
-
60
- Args:
61
- key: The runtime key
62
-
63
- Returns:
64
- True if unregistered, False if not found
65
- """
66
- if key in _runtimes:
67
- del _runtimes[key]
68
- return True
69
- return False
70
-
71
-
72
- def clear_registry() -> None:
73
- """Clear all registered runtimes. Useful for testing."""
74
- _runtimes.clear()