swarmauri_toolkit_runtime 0.1.1.dev2__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.
- swarmauri_toolkit_runtime/InspectRuntimeTool.py +38 -0
- swarmauri_toolkit_runtime/ListRuntimeTools.py +31 -0
- swarmauri_toolkit_runtime/RegisterRuntimeTool.py +53 -0
- swarmauri_toolkit_runtime/ReplaceRuntimeTool.py +68 -0
- swarmauri_toolkit_runtime/RuntimeToolkit.py +43 -0
- swarmauri_toolkit_runtime/UnregisterRuntimeTool.py +43 -0
- swarmauri_toolkit_runtime/__init__.py +15 -0
- swarmauri_toolkit_runtime/_tool_factory.py +49 -0
- swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/METADATA +171 -0
- swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/RECORD +13 -0
- swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/WHEEL +4 -0
- swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/entry_points.txt +10 -0
- swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from swarmauri_base.ComponentBase import ComponentBase
|
|
6
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
7
|
+
from swarmauri_base.toolkits.ToolkitBase import ToolkitBase
|
|
8
|
+
from swarmauri_standard.tools.Parameter import Parameter
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@ComponentBase.register_type(ToolBase, "InspectRuntimeTool")
|
|
12
|
+
class InspectRuntimeTool(ToolBase):
|
|
13
|
+
version: str = "0.1.0"
|
|
14
|
+
name: str = "InspectRuntimeTool"
|
|
15
|
+
description: str = "Read one tool from the active toolkit by name."
|
|
16
|
+
type: Literal["InspectRuntimeTool"] = "InspectRuntimeTool"
|
|
17
|
+
toolkit: ToolkitBase | None = Field(default=None, exclude=True, repr=False)
|
|
18
|
+
parameters: List[Parameter] = Field(
|
|
19
|
+
default_factory=lambda: [
|
|
20
|
+
Parameter(
|
|
21
|
+
name="tool_name",
|
|
22
|
+
input_type="string",
|
|
23
|
+
description="Name of the tool to fetch from the toolkit.",
|
|
24
|
+
required=True,
|
|
25
|
+
)
|
|
26
|
+
]
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def __call__(self, tool_name: str) -> Dict[str, Any]:
|
|
30
|
+
if self.toolkit is None:
|
|
31
|
+
raise ValueError("toolkit is not configured")
|
|
32
|
+
|
|
33
|
+
tool = self.toolkit.get_tool_by_name(tool_name)
|
|
34
|
+
return {
|
|
35
|
+
"tool_name": tool_name,
|
|
36
|
+
"tool_type": tool.type,
|
|
37
|
+
"tool": tool.model_dump(exclude_none=True),
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from swarmauri_base.ComponentBase import ComponentBase
|
|
6
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
7
|
+
from swarmauri_base.toolkits.ToolkitBase import ToolkitBase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@ComponentBase.register_type(ToolBase, "ListRuntimeTools")
|
|
11
|
+
class ListRuntimeTools(ToolBase):
|
|
12
|
+
version: str = "0.1.0"
|
|
13
|
+
name: str = "ListRuntimeTools"
|
|
14
|
+
description: str = "List all tools currently available in the active toolkit."
|
|
15
|
+
type: Literal["ListRuntimeTools"] = "ListRuntimeTools"
|
|
16
|
+
toolkit: ToolkitBase | None = Field(default=None, exclude=True, repr=False)
|
|
17
|
+
parameters: List[Any] = Field(default_factory=list)
|
|
18
|
+
|
|
19
|
+
def __call__(self) -> Dict[str, Any]:
|
|
20
|
+
if self.toolkit is None:
|
|
21
|
+
raise ValueError("toolkit is not configured")
|
|
22
|
+
|
|
23
|
+
tools = {
|
|
24
|
+
name: tool.model_dump(exclude_none=True)
|
|
25
|
+
for name, tool in self.toolkit.tools.items()
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
"tool_count": len(self.toolkit),
|
|
29
|
+
"tool_names": list(self.toolkit.tools.keys()),
|
|
30
|
+
"tools": tools,
|
|
31
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Literal, Mapping
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from swarmauri_base.ComponentBase import ComponentBase
|
|
6
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
7
|
+
from swarmauri_base.toolkits.ToolkitBase import ToolkitBase
|
|
8
|
+
from swarmauri_standard.tools.Parameter import Parameter
|
|
9
|
+
|
|
10
|
+
from ._tool_factory import build_tool_from_spec
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@ComponentBase.register_type(ToolBase, "RegisterRuntimeTool")
|
|
14
|
+
class RegisterRuntimeTool(ToolBase):
|
|
15
|
+
version: str = "0.1.0"
|
|
16
|
+
name: str = "RegisterRuntimeTool"
|
|
17
|
+
description: str = (
|
|
18
|
+
"Create a tool from a serialized tool spec and add it to the active toolkit."
|
|
19
|
+
)
|
|
20
|
+
type: Literal["RegisterRuntimeTool"] = "RegisterRuntimeTool"
|
|
21
|
+
toolkit: ToolkitBase | None = Field(default=None, exclude=True, repr=False)
|
|
22
|
+
protected_tool_names: set[str] = Field(
|
|
23
|
+
default_factory=set, exclude=True, repr=False
|
|
24
|
+
)
|
|
25
|
+
parameters: List[Parameter] = Field(
|
|
26
|
+
default_factory=lambda: [
|
|
27
|
+
Parameter(
|
|
28
|
+
name="tool_spec",
|
|
29
|
+
input_type="object",
|
|
30
|
+
description="Serialized tool payload with at least a 'type' field.",
|
|
31
|
+
required=True,
|
|
32
|
+
)
|
|
33
|
+
]
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def __call__(self, tool_spec: Mapping[str, Any] | ToolBase) -> Dict[str, Any]:
|
|
37
|
+
if self.toolkit is None:
|
|
38
|
+
raise ValueError("toolkit is not configured")
|
|
39
|
+
|
|
40
|
+
tool = build_tool_from_spec(tool_spec)
|
|
41
|
+
if tool.name in self.protected_tool_names:
|
|
42
|
+
raise ValueError(f"Tool '{tool.name}' is reserved by RuntimeToolkit")
|
|
43
|
+
if tool.name in self.toolkit.tools:
|
|
44
|
+
raise ValueError(f"Tool '{tool.name}' already exists in the toolkit")
|
|
45
|
+
|
|
46
|
+
self.toolkit.add_tool(tool)
|
|
47
|
+
return {
|
|
48
|
+
"status": "created",
|
|
49
|
+
"tool_name": tool.name,
|
|
50
|
+
"tool_type": tool.type,
|
|
51
|
+
"tool": tool.model_dump(exclude_none=True),
|
|
52
|
+
"tool_count": len(self.toolkit),
|
|
53
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Literal, Mapping
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from swarmauri_base.ComponentBase import ComponentBase
|
|
6
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
7
|
+
from swarmauri_base.toolkits.ToolkitBase import ToolkitBase
|
|
8
|
+
from swarmauri_standard.tools.Parameter import Parameter
|
|
9
|
+
|
|
10
|
+
from ._tool_factory import build_tool_from_spec
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@ComponentBase.register_type(ToolBase, "ReplaceRuntimeTool")
|
|
14
|
+
class ReplaceRuntimeTool(ToolBase):
|
|
15
|
+
version: str = "0.1.0"
|
|
16
|
+
name: str = "ReplaceRuntimeTool"
|
|
17
|
+
description: str = "Replace an existing non-reserved tool in the active toolkit with a new serialized tool spec."
|
|
18
|
+
type: Literal["ReplaceRuntimeTool"] = "ReplaceRuntimeTool"
|
|
19
|
+
toolkit: ToolkitBase | None = Field(default=None, exclude=True, repr=False)
|
|
20
|
+
protected_tool_names: set[str] = Field(
|
|
21
|
+
default_factory=set, exclude=True, repr=False
|
|
22
|
+
)
|
|
23
|
+
parameters: List[Parameter] = Field(
|
|
24
|
+
default_factory=lambda: [
|
|
25
|
+
Parameter(
|
|
26
|
+
name="tool_name",
|
|
27
|
+
input_type="string",
|
|
28
|
+
description="Existing tool name to replace.",
|
|
29
|
+
required=True,
|
|
30
|
+
),
|
|
31
|
+
Parameter(
|
|
32
|
+
name="tool_spec",
|
|
33
|
+
input_type="object",
|
|
34
|
+
description="Serialized replacement tool payload with at least a 'type' field.",
|
|
35
|
+
required=True,
|
|
36
|
+
),
|
|
37
|
+
]
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def __call__(
|
|
41
|
+
self, tool_name: str, tool_spec: Mapping[str, Any] | ToolBase
|
|
42
|
+
) -> Dict[str, Any]:
|
|
43
|
+
if self.toolkit is None:
|
|
44
|
+
raise ValueError("toolkit is not configured")
|
|
45
|
+
if tool_name in self.protected_tool_names:
|
|
46
|
+
raise ValueError(f"Tool '{tool_name}' is reserved by RuntimeToolkit")
|
|
47
|
+
if tool_name not in self.toolkit.tools:
|
|
48
|
+
raise ValueError(f"Tool '{tool_name}' not found in the toolkit")
|
|
49
|
+
|
|
50
|
+
replacement = build_tool_from_spec(tool_spec)
|
|
51
|
+
if (
|
|
52
|
+
replacement.name in self.protected_tool_names
|
|
53
|
+
and replacement.name != tool_name
|
|
54
|
+
):
|
|
55
|
+
raise ValueError(f"Tool '{replacement.name}' is reserved by RuntimeToolkit")
|
|
56
|
+
if replacement.name != tool_name and replacement.name in self.toolkit.tools:
|
|
57
|
+
raise ValueError(f"Tool '{replacement.name}' already exists in the toolkit")
|
|
58
|
+
|
|
59
|
+
self.toolkit.remove_tool(tool_name)
|
|
60
|
+
self.toolkit.add_tool(replacement)
|
|
61
|
+
return {
|
|
62
|
+
"status": "updated",
|
|
63
|
+
"previous_tool_name": tool_name,
|
|
64
|
+
"tool_name": replacement.name,
|
|
65
|
+
"tool_type": replacement.type,
|
|
66
|
+
"tool": replacement.model_dump(exclude_none=True),
|
|
67
|
+
"tool_count": len(self.toolkit),
|
|
68
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from typing import Dict, Literal
|
|
2
|
+
|
|
3
|
+
from swarmauri_base.ComponentBase import ComponentBase, SubclassUnion
|
|
4
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
5
|
+
from swarmauri_base.toolkits.ToolkitBase import ToolkitBase
|
|
6
|
+
|
|
7
|
+
from .RegisterRuntimeTool import RegisterRuntimeTool
|
|
8
|
+
from .InspectRuntimeTool import InspectRuntimeTool
|
|
9
|
+
from .ListRuntimeTools import ListRuntimeTools
|
|
10
|
+
from .UnregisterRuntimeTool import UnregisterRuntimeTool
|
|
11
|
+
from .ReplaceRuntimeTool import ReplaceRuntimeTool
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@ComponentBase.register_type(ToolkitBase, "RuntimeToolkit")
|
|
15
|
+
class RuntimeToolkit(ToolkitBase):
|
|
16
|
+
type: Literal["RuntimeToolkit"] = "RuntimeToolkit"
|
|
17
|
+
tools: Dict[str, SubclassUnion[ToolBase]] = {}
|
|
18
|
+
|
|
19
|
+
def __init__(self, **kwargs):
|
|
20
|
+
super().__init__(**kwargs)
|
|
21
|
+
self.tools = self._build_management_tools()
|
|
22
|
+
|
|
23
|
+
def _build_management_tools(self) -> Dict[str, SubclassUnion[ToolBase]]:
|
|
24
|
+
protected_tool_names = {
|
|
25
|
+
"RegisterRuntimeTool",
|
|
26
|
+
"InspectRuntimeTool",
|
|
27
|
+
"ListRuntimeTools",
|
|
28
|
+
"UnregisterRuntimeTool",
|
|
29
|
+
"ReplaceRuntimeTool",
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
"RegisterRuntimeTool": RegisterRuntimeTool(
|
|
33
|
+
toolkit=self, protected_tool_names=protected_tool_names
|
|
34
|
+
),
|
|
35
|
+
"InspectRuntimeTool": InspectRuntimeTool(toolkit=self),
|
|
36
|
+
"ListRuntimeTools": ListRuntimeTools(toolkit=self),
|
|
37
|
+
"UnregisterRuntimeTool": UnregisterRuntimeTool(
|
|
38
|
+
toolkit=self, protected_tool_names=protected_tool_names
|
|
39
|
+
),
|
|
40
|
+
"ReplaceRuntimeTool": ReplaceRuntimeTool(
|
|
41
|
+
toolkit=self, protected_tool_names=protected_tool_names
|
|
42
|
+
),
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from swarmauri_base.ComponentBase import ComponentBase
|
|
6
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
7
|
+
from swarmauri_base.toolkits.ToolkitBase import ToolkitBase
|
|
8
|
+
from swarmauri_standard.tools.Parameter import Parameter
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@ComponentBase.register_type(ToolBase, "UnregisterRuntimeTool")
|
|
12
|
+
class UnregisterRuntimeTool(ToolBase):
|
|
13
|
+
version: str = "0.1.0"
|
|
14
|
+
name: str = "UnregisterRuntimeTool"
|
|
15
|
+
description: str = "Delete a non-reserved tool from the active toolkit."
|
|
16
|
+
type: Literal["UnregisterRuntimeTool"] = "UnregisterRuntimeTool"
|
|
17
|
+
toolkit: ToolkitBase | None = Field(default=None, exclude=True, repr=False)
|
|
18
|
+
protected_tool_names: set[str] = Field(
|
|
19
|
+
default_factory=set, exclude=True, repr=False
|
|
20
|
+
)
|
|
21
|
+
parameters: List[Parameter] = Field(
|
|
22
|
+
default_factory=lambda: [
|
|
23
|
+
Parameter(
|
|
24
|
+
name="tool_name",
|
|
25
|
+
input_type="string",
|
|
26
|
+
description="Name of the tool to remove from the toolkit.",
|
|
27
|
+
required=True,
|
|
28
|
+
)
|
|
29
|
+
]
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def __call__(self, tool_name: str) -> Dict[str, Any]:
|
|
33
|
+
if self.toolkit is None:
|
|
34
|
+
raise ValueError("toolkit is not configured")
|
|
35
|
+
if tool_name in self.protected_tool_names:
|
|
36
|
+
raise ValueError(f"Tool '{tool_name}' is reserved by RuntimeToolkit")
|
|
37
|
+
|
|
38
|
+
self.toolkit.remove_tool(tool_name)
|
|
39
|
+
return {
|
|
40
|
+
"status": "deleted",
|
|
41
|
+
"tool_name": tool_name,
|
|
42
|
+
"tool_count": len(self.toolkit),
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from .RegisterRuntimeTool import RegisterRuntimeTool
|
|
2
|
+
from .InspectRuntimeTool import InspectRuntimeTool
|
|
3
|
+
from .ListRuntimeTools import ListRuntimeTools
|
|
4
|
+
from .UnregisterRuntimeTool import UnregisterRuntimeTool
|
|
5
|
+
from .RuntimeToolkit import RuntimeToolkit
|
|
6
|
+
from .ReplaceRuntimeTool import ReplaceRuntimeTool
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"RegisterRuntimeTool",
|
|
10
|
+
"InspectRuntimeTool",
|
|
11
|
+
"ListRuntimeTools",
|
|
12
|
+
"UnregisterRuntimeTool",
|
|
13
|
+
"RuntimeToolkit",
|
|
14
|
+
"ReplaceRuntimeTool",
|
|
15
|
+
]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from importlib import import_module
|
|
2
|
+
from typing import Any, Mapping
|
|
3
|
+
|
|
4
|
+
from swarmauri_base.tools.ToolBase import ToolBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _resolve_tool_module(tool_type: str):
|
|
8
|
+
module_names = [
|
|
9
|
+
f"swarmauri.tools.{tool_type}",
|
|
10
|
+
f"swarmauri_standard.tools.{tool_type}",
|
|
11
|
+
]
|
|
12
|
+
last_error: ModuleNotFoundError | None = None
|
|
13
|
+
for module_name in module_names:
|
|
14
|
+
try:
|
|
15
|
+
return import_module(module_name)
|
|
16
|
+
except ModuleNotFoundError as exc:
|
|
17
|
+
last_error = exc
|
|
18
|
+
raise ValueError(f"Unable to resolve tool type '{tool_type}'") from last_error
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def build_tool_from_spec(tool_spec: Mapping[str, Any] | ToolBase) -> ToolBase:
|
|
22
|
+
if isinstance(tool_spec, ToolBase):
|
|
23
|
+
if not tool_spec.parameters:
|
|
24
|
+
raise ValueError("Runtime tool registration requires declared parameters")
|
|
25
|
+
return tool_spec
|
|
26
|
+
if not isinstance(tool_spec, Mapping):
|
|
27
|
+
raise TypeError("tool_spec must be a mapping or ToolBase instance")
|
|
28
|
+
|
|
29
|
+
tool_data = dict(tool_spec)
|
|
30
|
+
tool_type = tool_data.get("type")
|
|
31
|
+
if not isinstance(tool_type, str) or not tool_type:
|
|
32
|
+
raise ValueError("tool_spec must include a non-empty string 'type' field")
|
|
33
|
+
declared_parameters = tool_data.get("parameters")
|
|
34
|
+
if not isinstance(declared_parameters, list) or not declared_parameters:
|
|
35
|
+
raise ValueError(
|
|
36
|
+
"Runtime tool registration requires a non-empty 'parameters' list"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
module = _resolve_tool_module(tool_type)
|
|
40
|
+
|
|
41
|
+
tool_cls = getattr(module, tool_type, None)
|
|
42
|
+
if tool_cls is None:
|
|
43
|
+
raise ValueError(
|
|
44
|
+
f"Module for tool type '{tool_type}' does not expose that class"
|
|
45
|
+
)
|
|
46
|
+
if not issubclass(tool_cls, ToolBase):
|
|
47
|
+
raise TypeError(f"Resolved class '{tool_type}' is not a ToolBase subtype")
|
|
48
|
+
|
|
49
|
+
return tool_cls.model_validate(tool_data)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_toolkit_runtime
|
|
3
|
+
Version: 0.1.1.dev2
|
|
4
|
+
Summary: Runtime toolkit for explicit-parameter registration, inspection, replacement, listing, and removal of Swarmauri tools during agent execution.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: swarmauri,sdk,standards,toolkit,runtime,agent-runtime,tool-management,tool-registration,tool-inspection,tool-replacement,tool-removal,tool-schema,explicit-parameters,runtime-governance,agent,crud,runtime-tools
|
|
8
|
+
Author: Jacob Stewart
|
|
9
|
+
Author-email: jacob@swarmauri.com
|
|
10
|
+
Requires-Python: >=3.10,<3.13
|
|
11
|
+
Classifier: Development Status :: 1 - Planning
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
22
|
+
Requires-Dist: pydantic
|
|
23
|
+
Requires-Dist: swarmauri_base
|
|
24
|
+
Requires-Dist: swarmauri_core
|
|
25
|
+
Requires-Dist: swarmauri_standard
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://pepy.tech/project/swarmauri_toolkit_runtime/">
|
|
32
|
+
<img src="https://static.pepy.tech/badge/swarmauri_toolkit_runtime/month" alt="PyPI - Downloads"/></a>
|
|
33
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_toolkit_runtime/">
|
|
34
|
+
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_toolkit_runtime.svg"/></a>
|
|
35
|
+
<a href="https://pypi.org/project/swarmauri_toolkit_runtime/">
|
|
36
|
+
<img src="https://img.shields.io/pypi/pyversions/swarmauri_toolkit_runtime" alt="PyPI - Python Version"/></a>
|
|
37
|
+
<a href="https://pypi.org/project/swarmauri_toolkit_runtime/">
|
|
38
|
+
<img src="https://img.shields.io/pypi/l/swarmauri_toolkit_runtime" alt="PyPI - License"/></a>
|
|
39
|
+
<a href="https://pypi.org/project/swarmauri_toolkit_runtime/">
|
|
40
|
+
<img src="https://img.shields.io/pypi/v/swarmauri_toolkit_runtime?label=swarmauri_toolkit_runtime&color=green" alt="PyPI - swarmauri_toolkit_runtime"/></a>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
# Swarmauri Toolkit RuntimeToolkit
|
|
44
|
+
|
|
45
|
+
`RuntimeToolkit` is a Swarmauri runtime-management toolkit for agents that need to register, inspect, list, replace, and remove tools during execution. It keeps tool mutation inside the active toolkit instance and requires explicit parameter declarations when a new runtime tool is introduced.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- Bundles agent-callable CRUD operations for toolkit members.
|
|
50
|
+
- Accepts serialized tool specs with `type` fields and materializes installed Swarmauri tools at runtime.
|
|
51
|
+
- Enforces a non-empty declared `parameters` list for runtime tool registration and replacement.
|
|
52
|
+
- Returns agent-friendly dictionaries for reads, lists, and mutation results.
|
|
53
|
+
- Protects the toolkit's own management tools from accidental overwrite or removal.
|
|
54
|
+
- Supports Python 3.10 through 3.12.
|
|
55
|
+
|
|
56
|
+
## Support
|
|
57
|
+
|
|
58
|
+
- Python `3.10`
|
|
59
|
+
- Python `3.11`
|
|
60
|
+
- Python `3.12`
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
**uv**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
uv add swarmauri_toolkit_runtime
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**pip**
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install swarmauri_toolkit_runtime
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
Use `RuntimeToolkit` when an agent needs to mutate its own tool surface safely at runtime. The expected workflow is:
|
|
79
|
+
|
|
80
|
+
1. Start with the management toolkit.
|
|
81
|
+
2. Register a runtime tool using an explicit parameter contract.
|
|
82
|
+
3. Inspect or list the available runtime tools.
|
|
83
|
+
4. Execute the registered tool.
|
|
84
|
+
5. Replace or unregister the tool when the runtime surface changes.
|
|
85
|
+
|
|
86
|
+
Instantiate the toolkit and hand it to an agent or tool-capable model. The toolkit starts with only its management tools, then grows as the agent adds tools.
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from swarmauri_toolkit_runtime import RuntimeToolkit
|
|
90
|
+
|
|
91
|
+
toolkit = RuntimeToolkit()
|
|
92
|
+
|
|
93
|
+
toolkit.get_tool_by_name("RegisterRuntimeTool")(
|
|
94
|
+
{
|
|
95
|
+
"type": "AdditionTool",
|
|
96
|
+
"name": "RuntimeAdditionTool",
|
|
97
|
+
"description": "Adds two integers during the active agent session.",
|
|
98
|
+
"parameters": [
|
|
99
|
+
{
|
|
100
|
+
"name": "x",
|
|
101
|
+
"input_type": "integer",
|
|
102
|
+
"description": "The left operand",
|
|
103
|
+
"required": True,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "y",
|
|
107
|
+
"input_type": "integer",
|
|
108
|
+
"description": "The right operand",
|
|
109
|
+
"required": True,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
result = toolkit.get_tool_by_name("RuntimeAdditionTool")(2, 3)
|
|
116
|
+
print(result)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Agent Workflow
|
|
120
|
+
|
|
121
|
+
1. Call `ListRuntimeTools` to inspect the current runtime surface.
|
|
122
|
+
2. Call `RegisterRuntimeTool` with a tool spec to extend the toolkit.
|
|
123
|
+
3. Call `InspectRuntimeTool` to inspect the hydrated tool metadata.
|
|
124
|
+
4. Call `ReplaceRuntimeTool` when the agent needs to replace a tool with a revised spec.
|
|
125
|
+
5. Call `UnregisterRuntimeTool` when a runtime tool should no longer be available.
|
|
126
|
+
|
|
127
|
+
## Tool Spec Contract
|
|
128
|
+
|
|
129
|
+
Mutation tools accept a serialized tool specification. At minimum, provide:
|
|
130
|
+
|
|
131
|
+
- a `type` field that resolves to an installed Swarmauri tool import such as `swarmauri.tools.AdditionTool`
|
|
132
|
+
- a non-empty `parameters` list that explicitly declares the runtime callable contract
|
|
133
|
+
|
|
134
|
+
Resolution prefers the `swarmauri` facade when present and falls back to `swarmauri_standard.tools.<ToolName>` for isolated package installs.
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
{
|
|
138
|
+
"type": "AdditionTool",
|
|
139
|
+
"name": "RuntimeAdditionTool",
|
|
140
|
+
"description": "Adds two integers.",
|
|
141
|
+
"parameters": [
|
|
142
|
+
{
|
|
143
|
+
"name": "x",
|
|
144
|
+
"input_type": "integer",
|
|
145
|
+
"description": "The left operand",
|
|
146
|
+
"required": True,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "y",
|
|
150
|
+
"input_type": "integer",
|
|
151
|
+
"description": "The right operand",
|
|
152
|
+
"required": True,
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
If the target tool defines extra fields, include them in the spec and the toolkit will validate them against the concrete tool class.
|
|
159
|
+
|
|
160
|
+
## Failure Modes
|
|
161
|
+
|
|
162
|
+
- Registration fails when the tool spec omits `parameters`.
|
|
163
|
+
- Registration fails when the tool name collides with a protected management tool.
|
|
164
|
+
- Replacement fails when the target tool is missing, reserved, or renamed to an existing tool.
|
|
165
|
+
- Unregistration fails when the target is reserved or absent.
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
`swarmauri_toolkit_runtime` is released under the Apache 2.0 License. See `LICENSE` for details.
|
|
170
|
+
|
|
171
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
swarmauri_toolkit_runtime/InspectRuntimeTool.py,sha256=vy4XllPb46TfUxGJVN_ggYm-TEIHpTpI8BAiQJBrBF0,1341
|
|
2
|
+
swarmauri_toolkit_runtime/ListRuntimeTools.py,sha256=D6tiHi8d1O95fd81fgVDyUdhNT4Tjqp4RWO3Na8b2Sk,1106
|
|
3
|
+
swarmauri_toolkit_runtime/RegisterRuntimeTool.py,sha256=z3Uhr7iKCrCAAgdaolLlP0x-XUBMae36LptkFCzxF5M,1953
|
|
4
|
+
swarmauri_toolkit_runtime/ReplaceRuntimeTool.py,sha256=5uZutD2jrIgVKHYWAlxQ5IEKZiW8XxL3vIlvQq2Jx0g,2708
|
|
5
|
+
swarmauri_toolkit_runtime/RuntimeToolkit.py,sha256=q_SKZ6BADVPP6Zt5JdMmfqG8ac_xeDmek19pGRHgBgg,1683
|
|
6
|
+
swarmauri_toolkit_runtime/UnregisterRuntimeTool.py,sha256=6dWC6CEgZ2eHSlgohgRB6c-mxPCoPBDs4TLT_kWYjps,1573
|
|
7
|
+
swarmauri_toolkit_runtime/__init__.py,sha256=Ing0vOmvJXTiLCe8RMLXkOMN8-3DAt0NDDCnfumZoNA,471
|
|
8
|
+
swarmauri_toolkit_runtime/_tool_factory.py,sha256=ZUCyxu9BXPtg8aVKRs66rQxpAJjokhCLp07qPSABXLs,1832
|
|
9
|
+
swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/METADATA,sha256=lWjpAsmmkhAs3_28jOJ_c5a6fPO68Rx7bZwgKvmETQg,6715
|
|
10
|
+
swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/WHEEL,sha256=Vz2fHgx6HFtSwhs8KvkHLqH5Ea4w1_rner5uNVGCeIE,88
|
|
11
|
+
swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/entry_points.txt,sha256=pB0M21BP9R-2_M52C_i5JBCsU1TLQD5m7P50IJs_lXA,421
|
|
12
|
+
swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
|
|
13
|
+
swarmauri_toolkit_runtime-0.1.1.dev2.dist-info/RECORD,,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[swarmauri.toolkits]
|
|
2
|
+
RuntimeToolkit=swarmauri_toolkit_runtime:RuntimeToolkit
|
|
3
|
+
|
|
4
|
+
[swarmauri.tools]
|
|
5
|
+
InspectRuntimeTool=swarmauri_toolkit_runtime:InspectRuntimeTool
|
|
6
|
+
ListRuntimeTools=swarmauri_toolkit_runtime:ListRuntimeTools
|
|
7
|
+
RegisterRuntimeTool=swarmauri_toolkit_runtime:RegisterRuntimeTool
|
|
8
|
+
ReplaceRuntimeTool=swarmauri_toolkit_runtime:ReplaceRuntimeTool
|
|
9
|
+
UnregisterRuntimeTool=swarmauri_toolkit_runtime:UnregisterRuntimeTool
|
|
10
|
+
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2025] [Jacob Stewart @ Swarmauri]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|