autobyteus 1.1.0__py3-none-any.whl → 1.1.2__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.
- autobyteus/agent/bootstrap_steps/agent_bootstrapper.py +1 -1
- autobyteus/agent/bootstrap_steps/agent_runtime_queue_initialization_step.py +1 -1
- autobyteus/agent/bootstrap_steps/base_bootstrap_step.py +1 -1
- autobyteus/agent/bootstrap_steps/system_prompt_processing_step.py +1 -1
- autobyteus/agent/bootstrap_steps/workspace_context_initialization_step.py +1 -1
- autobyteus/agent/context/__init__.py +0 -5
- autobyteus/agent/context/agent_config.py +6 -2
- autobyteus/agent/context/agent_context.py +2 -5
- autobyteus/agent/context/agent_phase_manager.py +105 -5
- autobyteus/agent/context/agent_runtime_state.py +2 -2
- autobyteus/agent/context/phases.py +2 -0
- autobyteus/agent/events/__init__.py +0 -11
- autobyteus/agent/events/agent_events.py +0 -37
- autobyteus/agent/events/notifiers.py +25 -7
- autobyteus/agent/events/worker_event_dispatcher.py +1 -1
- autobyteus/agent/factory/agent_factory.py +6 -2
- autobyteus/agent/group/agent_group.py +16 -7
- autobyteus/agent/handlers/approved_tool_invocation_event_handler.py +28 -14
- autobyteus/agent/handlers/lifecycle_event_logger.py +1 -1
- autobyteus/agent/handlers/llm_complete_response_received_event_handler.py +4 -2
- autobyteus/agent/handlers/tool_invocation_request_event_handler.py +40 -15
- autobyteus/agent/handlers/tool_result_event_handler.py +12 -7
- autobyteus/agent/hooks/__init__.py +7 -0
- autobyteus/agent/hooks/base_phase_hook.py +11 -2
- autobyteus/agent/hooks/hook_definition.py +36 -0
- autobyteus/agent/hooks/hook_meta.py +37 -0
- autobyteus/agent/hooks/hook_registry.py +118 -0
- autobyteus/agent/input_processor/base_user_input_processor.py +6 -3
- autobyteus/agent/input_processor/passthrough_input_processor.py +2 -1
- autobyteus/agent/input_processor/processor_meta.py +1 -1
- autobyteus/agent/input_processor/processor_registry.py +19 -0
- autobyteus/agent/llm_response_processor/base_processor.py +6 -3
- autobyteus/agent/llm_response_processor/processor_meta.py +1 -1
- autobyteus/agent/llm_response_processor/processor_registry.py +19 -0
- autobyteus/agent/llm_response_processor/provider_aware_tool_usage_processor.py +2 -1
- autobyteus/agent/message/context_file_type.py +2 -3
- autobyteus/agent/phases/__init__.py +18 -0
- autobyteus/agent/phases/discover.py +52 -0
- autobyteus/agent/phases/manager.py +265 -0
- autobyteus/agent/phases/phase_enum.py +49 -0
- autobyteus/agent/phases/transition_decorator.py +40 -0
- autobyteus/agent/phases/transition_info.py +33 -0
- autobyteus/agent/remote_agent.py +1 -1
- autobyteus/agent/runtime/agent_runtime.py +5 -10
- autobyteus/agent/runtime/agent_worker.py +62 -19
- autobyteus/agent/streaming/agent_event_stream.py +58 -5
- autobyteus/agent/streaming/stream_event_payloads.py +24 -13
- autobyteus/agent/streaming/stream_events.py +14 -11
- autobyteus/agent/system_prompt_processor/base_processor.py +6 -3
- autobyteus/agent/system_prompt_processor/processor_meta.py +1 -1
- autobyteus/agent/system_prompt_processor/tool_manifest_injector_processor.py +45 -31
- autobyteus/agent/tool_invocation.py +29 -3
- autobyteus/agent/utils/wait_for_idle.py +1 -1
- autobyteus/agent/workspace/__init__.py +2 -0
- autobyteus/agent/workspace/base_workspace.py +33 -11
- autobyteus/agent/workspace/workspace_config.py +160 -0
- autobyteus/agent/workspace/workspace_definition.py +36 -0
- autobyteus/agent/workspace/workspace_meta.py +37 -0
- autobyteus/agent/workspace/workspace_registry.py +72 -0
- autobyteus/cli/__init__.py +4 -3
- autobyteus/cli/agent_cli.py +25 -207
- autobyteus/cli/cli_display.py +205 -0
- autobyteus/events/event_manager.py +2 -1
- autobyteus/events/event_types.py +3 -1
- autobyteus/llm/api/autobyteus_llm.py +2 -12
- autobyteus/llm/api/deepseek_llm.py +11 -173
- autobyteus/llm/api/grok_llm.py +11 -172
- autobyteus/llm/api/kimi_llm.py +24 -0
- autobyteus/llm/api/mistral_llm.py +4 -4
- autobyteus/llm/api/ollama_llm.py +2 -2
- autobyteus/llm/api/openai_compatible_llm.py +193 -0
- autobyteus/llm/api/openai_llm.py +11 -139
- autobyteus/llm/extensions/token_usage_tracking_extension.py +11 -1
- autobyteus/llm/llm_factory.py +168 -42
- autobyteus/llm/models.py +25 -29
- autobyteus/llm/ollama_provider.py +6 -2
- autobyteus/llm/ollama_provider_resolver.py +44 -0
- autobyteus/llm/providers.py +1 -0
- autobyteus/llm/token_counter/kimi_token_counter.py +24 -0
- autobyteus/llm/token_counter/token_counter_factory.py +3 -0
- autobyteus/llm/utils/messages.py +3 -3
- autobyteus/tools/__init__.py +2 -0
- autobyteus/tools/base_tool.py +7 -1
- autobyteus/tools/functional_tool.py +20 -5
- autobyteus/tools/mcp/call_handlers/stdio_handler.py +15 -1
- autobyteus/tools/mcp/config_service.py +106 -127
- autobyteus/tools/mcp/registrar.py +247 -59
- autobyteus/tools/mcp/types.py +5 -3
- autobyteus/tools/registry/tool_definition.py +8 -1
- autobyteus/tools/registry/tool_registry.py +18 -0
- autobyteus/tools/tool_category.py +11 -0
- autobyteus/tools/tool_meta.py +3 -1
- autobyteus/tools/tool_state.py +20 -0
- autobyteus/tools/usage/parsers/_json_extractor.py +99 -0
- autobyteus/tools/usage/parsers/default_json_tool_usage_parser.py +46 -77
- autobyteus/tools/usage/parsers/default_xml_tool_usage_parser.py +87 -96
- autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py +37 -47
- autobyteus/tools/usage/parsers/openai_json_tool_usage_parser.py +112 -113
- {autobyteus-1.1.0.dist-info → autobyteus-1.1.2.dist-info}/METADATA +13 -12
- {autobyteus-1.1.0.dist-info → autobyteus-1.1.2.dist-info}/RECORD +103 -82
- {autobyteus-1.1.0.dist-info → autobyteus-1.1.2.dist-info}/WHEEL +0 -0
- {autobyteus-1.1.0.dist-info → autobyteus-1.1.2.dist-info}/licenses/LICENSE +0 -0
- {autobyteus-1.1.0.dist-info → autobyteus-1.1.2.dist-info}/top_level.txt +0 -0
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
# file: autobyteus/autobyteus/agent/workspace/base_workspace.py
|
|
2
2
|
import logging
|
|
3
|
-
from abc import ABC
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
4
|
from typing import Optional, Any, Dict, TYPE_CHECKING
|
|
5
|
+
from autobyteus.tools.parameter_schema import ParameterSchema
|
|
6
|
+
from autobyteus.agent.workspace.workspace_meta import WorkspaceMeta
|
|
7
|
+
from autobyteus.agent.workspace.workspace_config import WorkspaceConfig
|
|
5
8
|
|
|
6
9
|
if TYPE_CHECKING:
|
|
7
10
|
from autobyteus.agent.context import AgentContext
|
|
8
11
|
|
|
9
12
|
logger = logging.getLogger(__name__)
|
|
10
13
|
|
|
11
|
-
class BaseAgentWorkspace(ABC):
|
|
14
|
+
class BaseAgentWorkspace(ABC, metaclass=WorkspaceMeta):
|
|
12
15
|
"""
|
|
13
16
|
Abstract base class for an agent's workspace or working environment.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
A workspace is a passive data container that describes an agent's operating
|
|
19
|
+
environment (e.g., a local directory, SSH connection details). It does not
|
|
20
|
+
implement active operations itself; that is the responsibility of Tools.
|
|
18
21
|
"""
|
|
19
22
|
|
|
20
|
-
def __init__(self, config: Optional[
|
|
23
|
+
def __init__(self, config: Optional[WorkspaceConfig] = None):
|
|
21
24
|
"""
|
|
22
25
|
Initializes the BaseAgentWorkspace.
|
|
23
26
|
|
|
24
27
|
Args:
|
|
25
28
|
config: Optional configuration for the workspace (e.g., base path, credentials).
|
|
26
29
|
"""
|
|
27
|
-
self._config:
|
|
30
|
+
self._config: WorkspaceConfig = config or WorkspaceConfig()
|
|
28
31
|
self.context: Optional['AgentContext'] = None
|
|
29
|
-
|
|
30
|
-
logger.info("BaseAgentWorkspace initialized. Context pending injection.")
|
|
32
|
+
logger.debug(f"{self.__class__.__name__} instance initialized. Context pending injection.")
|
|
31
33
|
|
|
32
34
|
def set_context(self, context: 'AgentContext'):
|
|
33
35
|
"""
|
|
@@ -47,9 +49,29 @@ class BaseAgentWorkspace(ABC):
|
|
|
47
49
|
return None
|
|
48
50
|
|
|
49
51
|
@property
|
|
50
|
-
def config(self) ->
|
|
52
|
+
def config(self) -> WorkspaceConfig:
|
|
51
53
|
"""Configuration for the workspace. Implementations can use this as needed."""
|
|
52
54
|
return self._config
|
|
53
55
|
|
|
56
|
+
# --- Methods for self-description ---
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
@abstractmethod
|
|
60
|
+
def get_workspace_type_name(cls) -> str:
|
|
61
|
+
"""Returns the unique, machine-readable type name for this workspace (e.g., 'local_workspace')."""
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
@abstractmethod
|
|
66
|
+
def get_description(cls) -> str:
|
|
67
|
+
"""Returns a user-friendly description of this workspace type."""
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
@classmethod
|
|
71
|
+
@abstractmethod
|
|
72
|
+
def get_config_schema(cls) -> ParameterSchema:
|
|
73
|
+
"""Returns the ParameterSchema defining the configuration arguments needed to create an instance of this workspace."""
|
|
74
|
+
pass
|
|
75
|
+
|
|
54
76
|
def __repr__(self) -> str:
|
|
55
77
|
return f"<{self.__class__.__name__} agent_id='{self.agent_id or 'N/A'}>"
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# file: autobyteus/autobyteus/agent/workspace/workspace_config.py
|
|
2
|
+
import logging
|
|
3
|
+
import json
|
|
4
|
+
from typing import Dict, Any, Mapping
|
|
5
|
+
from collections.abc import Mapping as MappingABC
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
def _default_serializer(obj: Any) -> Any:
|
|
10
|
+
"""
|
|
11
|
+
A robust serializer for objects that might not be JSON-serializable,
|
|
12
|
+
ensuring a stable representation for hashing and comparison.
|
|
13
|
+
"""
|
|
14
|
+
try:
|
|
15
|
+
# For common un-serializable collection types, convert to a sorted list
|
|
16
|
+
# to ensure a stable representation.
|
|
17
|
+
if isinstance(obj, set):
|
|
18
|
+
return sorted(list(obj))
|
|
19
|
+
# For other objects, repr() is often a good choice for a unique,
|
|
20
|
+
# and often reconstructible, string representation.
|
|
21
|
+
return repr(obj)
|
|
22
|
+
except Exception:
|
|
23
|
+
# Fallback for any object that fails repr() or other serialization.
|
|
24
|
+
return f"<unrepresentable object of type {type(obj).__name__}>"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class WorkspaceConfig:
|
|
28
|
+
"""
|
|
29
|
+
An immutable, hashable configuration class for agent workspaces.
|
|
30
|
+
|
|
31
|
+
This class stores workspace configuration parameters. It is immutable, meaning
|
|
32
|
+
that methods like `set` or `update` return a new `WorkspaceConfig` instance
|
|
33
|
+
rather than modifying the existing one.
|
|
34
|
+
|
|
35
|
+
This immutability makes `WorkspaceConfig` instances hashable, allowing them to
|
|
36
|
+
be used as dictionary keys for caching and reusing workspace instances.
|
|
37
|
+
"""
|
|
38
|
+
_params: Dict[str, Any]
|
|
39
|
+
_canonical_rep: str
|
|
40
|
+
|
|
41
|
+
def __init__(self, params: Mapping[str, Any] = None):
|
|
42
|
+
"""
|
|
43
|
+
Initializes the WorkspaceConfig.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
params: A dictionary of configuration parameters. A copy is stored.
|
|
47
|
+
"""
|
|
48
|
+
self._params = dict(params or {})
|
|
49
|
+
|
|
50
|
+
# Pre-compute canonical representation for hashing and equality.
|
|
51
|
+
try:
|
|
52
|
+
self._canonical_rep = json.dumps(self._params, sort_keys=True, default=_default_serializer)
|
|
53
|
+
except Exception as e:
|
|
54
|
+
logger.error(f"Failed to create canonical representation for WorkspaceConfig: {e}", exc_info=True)
|
|
55
|
+
# Fallback for extreme cases
|
|
56
|
+
self._canonical_rep = repr(self._params)
|
|
57
|
+
|
|
58
|
+
logger.debug(f"WorkspaceConfig initialized with params keys: {list(self._params.keys())}")
|
|
59
|
+
|
|
60
|
+
def __hash__(self) -> int:
|
|
61
|
+
return hash(self._canonical_rep)
|
|
62
|
+
|
|
63
|
+
def __eq__(self, other: object) -> bool:
|
|
64
|
+
if not isinstance(other, WorkspaceConfig):
|
|
65
|
+
return NotImplemented
|
|
66
|
+
return self._canonical_rep == other._canonical_rep
|
|
67
|
+
|
|
68
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
69
|
+
"""
|
|
70
|
+
Convert the WorkspaceConfig to a dictionary representation.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
Dict[str, Any]: A copy of the configuration parameters.
|
|
74
|
+
"""
|
|
75
|
+
return self._params.copy()
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_dict(cls, config_data: Dict[str, Any]) -> 'WorkspaceConfig':
|
|
79
|
+
"""
|
|
80
|
+
Create a WorkspaceConfig instance from a dictionary.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
config_data: Dictionary containing configuration parameters.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
A new, immutable WorkspaceConfig instance.
|
|
87
|
+
"""
|
|
88
|
+
if not isinstance(config_data, dict):
|
|
89
|
+
raise TypeError("config_data must be a dictionary")
|
|
90
|
+
return cls(params=config_data)
|
|
91
|
+
|
|
92
|
+
def merge(self, other: 'WorkspaceConfig') -> 'WorkspaceConfig':
|
|
93
|
+
"""
|
|
94
|
+
Merge this WorkspaceConfig with another, with the other taking precedence.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
other: WorkspaceConfig to merge with this one.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
A new, merged WorkspaceConfig instance.
|
|
101
|
+
"""
|
|
102
|
+
if not isinstance(other, WorkspaceConfig):
|
|
103
|
+
raise TypeError("Can only merge with another WorkspaceConfig instance")
|
|
104
|
+
|
|
105
|
+
merged_params = self._params.copy()
|
|
106
|
+
merged_params.update(other._params)
|
|
107
|
+
return WorkspaceConfig(params=merged_params)
|
|
108
|
+
|
|
109
|
+
def get(self, key: str, default: Any = None) -> Any:
|
|
110
|
+
"""
|
|
111
|
+
Get a configuration parameter.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
key: The parameter key.
|
|
115
|
+
default: Default value if key doesn't exist.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
The parameter value or default.
|
|
119
|
+
"""
|
|
120
|
+
return self._params.get(key, default)
|
|
121
|
+
|
|
122
|
+
def set(self, key: str, value: Any) -> 'WorkspaceConfig':
|
|
123
|
+
"""
|
|
124
|
+
Return a new WorkspaceConfig with a key set to a new value.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
key: The parameter key.
|
|
128
|
+
value: The parameter value.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
A new WorkspaceConfig instance with the updated parameter.
|
|
132
|
+
"""
|
|
133
|
+
new_params = self._params.copy()
|
|
134
|
+
new_params[key] = value
|
|
135
|
+
return WorkspaceConfig(params=new_params)
|
|
136
|
+
|
|
137
|
+
def update(self, params: Mapping[str, Any]) -> 'WorkspaceConfig':
|
|
138
|
+
"""
|
|
139
|
+
Return a new WorkspaceConfig with multiple updated parameters.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
params: Dictionary of parameters to update.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
A new WorkspaceConfig instance with the updated parameters.
|
|
146
|
+
"""
|
|
147
|
+
if not isinstance(params, MappingABC):
|
|
148
|
+
raise TypeError("params must be a mapping (e.g., a dictionary)")
|
|
149
|
+
new_params = self._params.copy()
|
|
150
|
+
new_params.update(params)
|
|
151
|
+
return WorkspaceConfig(params=new_params)
|
|
152
|
+
|
|
153
|
+
def __repr__(self) -> str:
|
|
154
|
+
return f"WorkspaceConfig(params={self._params})"
|
|
155
|
+
|
|
156
|
+
def __len__(self) -> int:
|
|
157
|
+
return len(self._params)
|
|
158
|
+
|
|
159
|
+
def __bool__(self) -> bool:
|
|
160
|
+
return bool(self._params)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module defines the WorkspaceDefinition class, which encapsulates the metadata
|
|
3
|
+
for a specific type of agent workspace.
|
|
4
|
+
"""
|
|
5
|
+
import logging
|
|
6
|
+
from typing import Type, Optional, TYPE_CHECKING
|
|
7
|
+
from autobyteus.tools.parameter_schema import ParameterSchema
|
|
8
|
+
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from autobyteus.agent.workspace.base_workspace import BaseAgentWorkspace
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
class WorkspaceDefinition:
|
|
15
|
+
"""Represents the definition of a discoverable and creatable agent workspace type."""
|
|
16
|
+
def __init__(self,
|
|
17
|
+
workspace_type_name: str,
|
|
18
|
+
description: str,
|
|
19
|
+
workspace_class: Type['BaseAgentWorkspace'],
|
|
20
|
+
config_schema: ParameterSchema):
|
|
21
|
+
if not all([workspace_type_name, description, workspace_class, config_schema is not None]):
|
|
22
|
+
raise ValueError("All parameters for WorkspaceDefinition are required.")
|
|
23
|
+
|
|
24
|
+
self.workspace_type_name = workspace_type_name
|
|
25
|
+
self.description = description
|
|
26
|
+
self.workspace_class = workspace_class
|
|
27
|
+
self.config_schema = config_schema
|
|
28
|
+
logger.debug(f"WorkspaceDefinition created for type '{workspace_type_name}'.")
|
|
29
|
+
|
|
30
|
+
def to_dict(self) -> dict:
|
|
31
|
+
"""Serializes the definition to a dictionary for API exposure."""
|
|
32
|
+
return {
|
|
33
|
+
"workspace_type_name": self.workspace_type_name,
|
|
34
|
+
"description": self.description,
|
|
35
|
+
"config_schema": self.config_schema.to_dict()
|
|
36
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module contains the metaclass for BaseAgentWorkspace for automatic registration.
|
|
3
|
+
"""
|
|
4
|
+
import logging
|
|
5
|
+
from abc import ABCMeta
|
|
6
|
+
from .workspace_registry import default_workspace_registry
|
|
7
|
+
from .workspace_definition import WorkspaceDefinition
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
class WorkspaceMeta(ABCMeta):
|
|
12
|
+
"""Metaclass to automatically register concrete BaseAgentWorkspace subclasses."""
|
|
13
|
+
def __init__(cls, name, bases, dct):
|
|
14
|
+
super().__init__(name, bases, dct)
|
|
15
|
+
|
|
16
|
+
if name == 'BaseAgentWorkspace' or getattr(cls, "__abstractmethods__", None):
|
|
17
|
+
logger.debug(f"Skipping registration for abstract workspace class: {name}")
|
|
18
|
+
return
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
workspace_type_name = cls.get_workspace_type_name()
|
|
22
|
+
description = cls.get_description()
|
|
23
|
+
config_schema = cls.get_config_schema()
|
|
24
|
+
|
|
25
|
+
definition = WorkspaceDefinition(
|
|
26
|
+
workspace_type_name=workspace_type_name,
|
|
27
|
+
description=description,
|
|
28
|
+
workspace_class=cls,
|
|
29
|
+
config_schema=config_schema
|
|
30
|
+
)
|
|
31
|
+
default_workspace_registry.register(definition)
|
|
32
|
+
config_params_info = f"config_params: {len(config_schema) if config_schema else 0}"
|
|
33
|
+
logger.info(f"Auto-registered workspace: '{workspace_type_name}' from class {name} ({config_params_info})")
|
|
34
|
+
except AttributeError as e:
|
|
35
|
+
logger.error(f"Workspace class {name} is missing a required static/class method ({e}). Skipping registration.")
|
|
36
|
+
except Exception as e:
|
|
37
|
+
logger.error(f"Failed to auto-register workspace class {name}: {e}", exc_info=True)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides a central registry for agent workspace types.
|
|
3
|
+
"""
|
|
4
|
+
import logging
|
|
5
|
+
from typing import Dict, Any, Optional, List, TYPE_CHECKING
|
|
6
|
+
from autobyteus.utils.singleton import SingletonMeta
|
|
7
|
+
from .workspace_definition import WorkspaceDefinition
|
|
8
|
+
from .workspace_config import WorkspaceConfig
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from .base_workspace import BaseAgentWorkspace
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
class WorkspaceRegistry(metaclass=SingletonMeta):
|
|
16
|
+
"""
|
|
17
|
+
A singleton registry for WorkspaceDefinition objects. Workspaces are
|
|
18
|
+
typically auto-registered via WorkspaceMeta.
|
|
19
|
+
"""
|
|
20
|
+
def __init__(self):
|
|
21
|
+
self._definitions: Dict[str, WorkspaceDefinition] = {}
|
|
22
|
+
logger.info("Core WorkspaceRegistry initialized.")
|
|
23
|
+
|
|
24
|
+
def register(self, definition: WorkspaceDefinition):
|
|
25
|
+
"""Registers a workspace definition."""
|
|
26
|
+
if not isinstance(definition, WorkspaceDefinition):
|
|
27
|
+
raise TypeError("Can only register WorkspaceDefinition objects.")
|
|
28
|
+
if definition.workspace_type_name in self._definitions:
|
|
29
|
+
logger.warning(f"Overwriting workspace definition for type '{definition.workspace_type_name}'.")
|
|
30
|
+
self._definitions[definition.workspace_type_name] = definition
|
|
31
|
+
|
|
32
|
+
def get_definition(self, workspace_type_name: str) -> Optional[WorkspaceDefinition]:
|
|
33
|
+
"""Retrieves a workspace definition by its unique type name."""
|
|
34
|
+
return self._definitions.get(workspace_type_name)
|
|
35
|
+
|
|
36
|
+
def get_all_definitions(self) -> List[WorkspaceDefinition]:
|
|
37
|
+
"""Returns a list of all registered workspace definitions."""
|
|
38
|
+
return list(self._definitions.values())
|
|
39
|
+
|
|
40
|
+
def create_workspace(self, workspace_type_name: str, config: WorkspaceConfig) -> 'BaseAgentWorkspace':
|
|
41
|
+
"""
|
|
42
|
+
Creates an instance of a workspace.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
workspace_type_name (str): The unique type name of the workspace to create.
|
|
46
|
+
config (WorkspaceConfig): The configuration object for the workspace.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
An instance of a BaseAgentWorkspace subclass.
|
|
50
|
+
|
|
51
|
+
Raises:
|
|
52
|
+
ValueError: If the type is unknown or parameters are invalid.
|
|
53
|
+
"""
|
|
54
|
+
definition = self.get_definition(workspace_type_name)
|
|
55
|
+
if not definition:
|
|
56
|
+
raise ValueError(f"Unknown workspace type: '{workspace_type_name}'")
|
|
57
|
+
|
|
58
|
+
is_valid, errors = definition.config_schema.validate_config(config.to_dict())
|
|
59
|
+
if not is_valid:
|
|
60
|
+
error_str = ", ".join(errors)
|
|
61
|
+
raise ValueError(f"Invalid parameters for workspace type '{workspace_type_name}': {error_str}")
|
|
62
|
+
|
|
63
|
+
try:
|
|
64
|
+
workspace_class = definition.workspace_class
|
|
65
|
+
instance = workspace_class(config=config)
|
|
66
|
+
logger.info(f"Successfully created instance of workspace type '{workspace_type_name}'.")
|
|
67
|
+
return instance
|
|
68
|
+
except Exception as e:
|
|
69
|
+
logger.error(f"Failed to instantiate workspace class '{definition.workspace_class.__name__}': {e}", exc_info=True)
|
|
70
|
+
raise RuntimeError(f"Workspace instantiation failed for type '{workspace_type_name}': {e}") from e
|
|
71
|
+
|
|
72
|
+
default_workspace_registry = WorkspaceRegistry()
|
autobyteus/cli/__init__.py
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
"""
|
|
3
3
|
Command-Line Interface (CLI) utilities for interacting with AutoByteUs components.
|
|
4
4
|
"""
|
|
5
|
-
from . import
|
|
5
|
+
from .agent_cli import run
|
|
6
|
+
from .cli_display import InteractiveCLIDisplay
|
|
6
7
|
|
|
7
8
|
__all__ = [
|
|
8
|
-
"
|
|
9
|
+
"run",
|
|
10
|
+
"InteractiveCLIDisplay",
|
|
9
11
|
]
|
|
10
|
-
|