swarmauri_toolkit_runtime 0.1.1.dev2__py3-none-any.whl → 0.11.0.dev4__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.
@@ -1,38 +1,3 @@
1
- from typing import Any, Dict, List, Literal
1
+ from swarmauri_tool_inspectruntimetool import InspectRuntimeTool
2
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
- }
3
+ __all__ = ["InspectRuntimeTool"]
@@ -1,31 +1,3 @@
1
- from typing import Any, Dict, List, Literal
1
+ from swarmauri_tool_listruntimetools import ListRuntimeTools
2
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
- }
3
+ __all__ = ["ListRuntimeTools"]
@@ -0,0 +1,47 @@
1
+ from collections.abc import Callable
2
+ from typing import Any, Literal
3
+
4
+ from pydantic import BaseModel, Field
5
+ from swarmauri_base.ComponentBase import ComponentBase
6
+ from swarmauri_base.tools.ToolBase import ToolBase
7
+
8
+
9
+ class RecipeStep(BaseModel):
10
+ """Call one installed tool with literals or input references."""
11
+
12
+ tool: str
13
+ arguments: dict[str, Any] = Field(default_factory=dict)
14
+
15
+
16
+ @ComponentBase.register_type(ToolBase, "RecipeTool")
17
+ class RecipeTool(ToolBase):
18
+ """Run a sequence of existing tool calls through a host dispatcher."""
19
+
20
+ type: Literal["RecipeTool"] = "RecipeTool"
21
+ steps: list[RecipeStep] = Field(min_length=1, max_length=32)
22
+ dispatch: Callable[[str, dict[str, Any]], dict[str, Any]] = Field(
23
+ exclude=True
24
+ )
25
+
26
+ def __call__(self, **inputs):
27
+ declared = {parameter.name for parameter in self.parameters}
28
+ required = {
29
+ parameter.name
30
+ for parameter in self.parameters
31
+ if parameter.required
32
+ }
33
+ if inputs.keys() - declared or required - inputs.keys():
34
+ raise ValueError("Recipe inputs do not match its parameters")
35
+ results = []
36
+ for step in self.steps:
37
+ arguments = {
38
+ key: inputs[value["input"]]
39
+ if isinstance(value, dict) and value.keys() == {"input"}
40
+ else value
41
+ for key, value in step.arguments.items()
42
+ }
43
+ result = self.dispatch(step.tool, arguments)
44
+ results.append(result)
45
+ if result.get("status") != "completed":
46
+ break
47
+ return {"steps": results}
@@ -1,53 +1,3 @@
1
- from typing import Any, Dict, List, Literal, Mapping
1
+ from swarmauri_tool_registerruntimetool import RegisterRuntimeTool
2
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
- }
3
+ __all__ = ["RegisterRuntimeTool"]
@@ -1,68 +1,3 @@
1
- from typing import Any, Dict, List, Literal, Mapping
1
+ from swarmauri_tool_replaceruntimetool import ReplaceRuntimeTool
2
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
- }
3
+ __all__ = ["ReplaceRuntimeTool"]
@@ -1,6 +1,9 @@
1
+ from collections.abc import Callable, Mapping
1
2
  from typing import Dict, Literal
2
3
 
3
- from swarmauri_base.ComponentBase import ComponentBase, SubclassUnion
4
+ from pydantic import Field, PrivateAttr
5
+
6
+ from swarmauri_base.ComponentBase import ComponentBase
4
7
  from swarmauri_base.tools.ToolBase import ToolBase
5
8
  from swarmauri_base.toolkits.ToolkitBase import ToolkitBase
6
9
 
@@ -9,18 +12,22 @@ from .InspectRuntimeTool import InspectRuntimeTool
9
12
  from .ListRuntimeTools import ListRuntimeTools
10
13
  from .UnregisterRuntimeTool import UnregisterRuntimeTool
11
14
  from .ReplaceRuntimeTool import ReplaceRuntimeTool
15
+ from .RecipeTool import RecipeTool
16
+ from ._tool_factory import build_tool_from_spec
12
17
 
13
18
 
14
19
  @ComponentBase.register_type(ToolkitBase, "RuntimeToolkit")
15
20
  class RuntimeToolkit(ToolkitBase):
16
21
  type: Literal["RuntimeToolkit"] = "RuntimeToolkit"
17
- tools: Dict[str, SubclassUnion[ToolBase]] = {}
22
+ tools: Dict[str, ToolBase] = {}
23
+ revision: int = Field(default=0, ge=0)
24
+ _recipe_dispatch: Callable | None = PrivateAttr(default=None)
18
25
 
19
26
  def __init__(self, **kwargs):
20
27
  super().__init__(**kwargs)
21
28
  self.tools = self._build_management_tools()
22
29
 
23
- def _build_management_tools(self) -> Dict[str, SubclassUnion[ToolBase]]:
30
+ def _build_management_tools(self) -> Dict[str, ToolBase]:
24
31
  protected_tool_names = {
25
32
  "RegisterRuntimeTool",
26
33
  "InspectRuntimeTool",
@@ -30,7 +37,9 @@ class RuntimeToolkit(ToolkitBase):
30
37
  }
31
38
  return {
32
39
  "RegisterRuntimeTool": RegisterRuntimeTool(
33
- toolkit=self, protected_tool_names=protected_tool_names
40
+ toolkit=self,
41
+ protected_tool_names=protected_tool_names,
42
+ factory=self._build_tool,
34
43
  ),
35
44
  "InspectRuntimeTool": InspectRuntimeTool(toolkit=self),
36
45
  "ListRuntimeTools": ListRuntimeTools(toolkit=self),
@@ -38,6 +47,29 @@ class RuntimeToolkit(ToolkitBase):
38
47
  toolkit=self, protected_tool_names=protected_tool_names
39
48
  ),
40
49
  "ReplaceRuntimeTool": ReplaceRuntimeTool(
41
- toolkit=self, protected_tool_names=protected_tool_names
50
+ toolkit=self,
51
+ protected_tool_names=protected_tool_names,
52
+ factory=self._build_tool,
42
53
  ),
43
54
  }
55
+
56
+ def bind_recipe_dispatch(self, dispatch: Callable) -> None:
57
+ """Configure the application dispatcher for recipe steps."""
58
+ self._recipe_dispatch = dispatch
59
+
60
+ def _build_tool(self, spec):
61
+ if isinstance(spec, Mapping) and spec.get("type") == "RecipeTool":
62
+ if self._recipe_dispatch is None:
63
+ raise ValueError("Recipe dispatch is not configured")
64
+ return RecipeTool.model_validate(
65
+ {**spec, "dispatch": self._recipe_dispatch}
66
+ )
67
+ return build_tool_from_spec(spec)
68
+
69
+ def add_tool(self, tool):
70
+ super().add_tool(tool)
71
+ self.revision += 1
72
+
73
+ def remove_tool(self, tool_name):
74
+ super().remove_tool(tool_name)
75
+ self.revision += 1
@@ -1,43 +1,3 @@
1
- from typing import Any, Dict, List, Literal
1
+ from swarmauri_tool_unregisterruntimetool import UnregisterRuntimeTool
2
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
- }
3
+ __all__ = ["UnregisterRuntimeTool"]
@@ -0,0 +1,3 @@
1
+ from swarmauri_standard.tools._dynamic_runtime_tool import DynamicRuntimeTool
2
+
3
+ __all__ = ["DynamicRuntimeTool"]
@@ -1,49 +1,3 @@
1
- from importlib import import_module
2
- from typing import Any, Mapping
1
+ from swarmauri_standard.tools._tool_factory import build_tool_from_spec
3
2
 
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)
3
+ __all__ = ["build_tool_from_spec"]
@@ -1,31 +1,38 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: swarmauri_toolkit_runtime
3
- Version: 0.1.1.dev2
3
+ Version: 0.11.0.dev4
4
4
  Summary: Runtime toolkit for explicit-parameter registration, inspection, replacement, listing, and removal of Swarmauri tools during agent execution.
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
7
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
8
  Author: Jacob Stewart
9
9
  Author-email: jacob@swarmauri.com
10
- Requires-Python: >=3.10,<3.13
10
+ Requires-Python: >=3.10,<3.15
11
11
  Classifier: Development Status :: 1 - Planning
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: License :: OSI Approved :: Apache Software License
14
14
  Classifier: Natural Language :: English
15
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
15
16
  Classifier: Programming Language :: Python
16
17
  Classifier: Programming Language :: Python :: 3
17
18
  Classifier: Programming Language :: Python :: 3 :: Only
18
19
  Classifier: Programming Language :: Python :: 3.10
19
20
  Classifier: Programming Language :: Python :: 3.11
20
21
  Classifier: Programming Language :: Python :: 3.12
21
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
22
24
  Requires-Dist: pydantic
23
- Requires-Dist: swarmauri_base
24
- Requires-Dist: swarmauri_core
25
- Requires-Dist: swarmauri_standard
25
+ Requires-Dist: swarmauri_base (>=0.11.0.dev6,<0.12)
26
+ Requires-Dist: swarmauri_core (>=0.11.0.dev6,<0.12)
27
+ Requires-Dist: swarmauri_standard (>=0.11.0.dev8,<0.12)
28
+ Requires-Dist: swarmauri_tool_inspectruntimetool (>=0.1.0,<0.2)
29
+ Requires-Dist: swarmauri_tool_listruntimetools (>=0.1.0,<0.2)
30
+ Requires-Dist: swarmauri_tool_registerruntimetool (>=0.1.0,<0.2)
31
+ Requires-Dist: swarmauri_tool_replaceruntimetool (>=0.1.0,<0.2)
32
+ Requires-Dist: swarmauri_tool_unregisterruntimetool (>=0.1.0,<0.2)
26
33
  Description-Content-Type: text/markdown
27
34
 
28
- ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
35
+ ![Swarmauri Logo](https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri_sdk_brand.png)
29
36
 
30
37
  <p align="center">
31
38
  <a href="https://pepy.tech/project/swarmauri_toolkit_runtime/">
@@ -33,22 +40,24 @@ Description-Content-Type: text/markdown
33
40
  <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_toolkit_runtime/">
34
41
  <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_toolkit_runtime.svg"/></a>
35
42
  <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>
43
+ <img src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue" alt="PyPI - Python Version"/></a>
37
44
  <a href="https://pypi.org/project/swarmauri_toolkit_runtime/">
38
45
  <img src="https://img.shields.io/pypi/l/swarmauri_toolkit_runtime" alt="PyPI - License"/></a>
39
46
  <a href="https://pypi.org/project/swarmauri_toolkit_runtime/">
40
47
  <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>
48
+ <a href="https://discord.gg/N4UpBuQv8T">
49
+ <img src="https://img.shields.io/badge/Discord-Join%20Chat-5865F2?logo=discord&logoColor=white" alt="Discord"/></a></p>
42
50
 
43
51
  # Swarmauri Toolkit RuntimeToolkit
44
52
 
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.
53
+ `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 both explicit parameter declarations and an explicit `__call__` implementation when a new runtime tool is introduced.
46
54
 
47
55
  ## Features
48
56
 
49
57
  - 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.
58
+ - Accepts serialized runtime tool specs with `type`, `parameters`, and `__call__` fields.
59
+ - Enforces a non-empty declared `parameters` list and a non-empty `__call__` body for runtime tool registration and replacement.
60
+ - Evaluates runtime `__call__` bodies through a restricted expression rail rather than unrestricted Python execution.
52
61
  - Returns agent-friendly dictionaries for reads, lists, and mutation results.
53
62
  - Protects the toolkit's own management tools from accidental overwrite or removal.
54
63
  - Supports Python 3.10 through 3.12.
@@ -78,7 +87,7 @@ pip install swarmauri_toolkit_runtime
78
87
  Use `RuntimeToolkit` when an agent needs to mutate its own tool surface safely at runtime. The expected workflow is:
79
88
 
80
89
  1. Start with the management toolkit.
81
- 2. Register a runtime tool using an explicit parameter contract.
90
+ 2. Register a runtime tool using an explicit parameter contract and explicit callable body.
82
91
  3. Inspect or list the available runtime tools.
83
92
  4. Execute the registered tool.
84
93
  5. Replace or unregister the tool when the runtime surface changes.
@@ -92,7 +101,7 @@ toolkit = RuntimeToolkit()
92
101
 
93
102
  toolkit.get_tool_by_name("RegisterRuntimeTool")(
94
103
  {
95
- "type": "AdditionTool",
104
+ "type": "RuntimeAdditionTool",
96
105
  "name": "RuntimeAdditionTool",
97
106
  "description": "Adds two integers during the active agent session.",
98
107
  "parameters": [
@@ -109,6 +118,7 @@ toolkit.get_tool_by_name("RegisterRuntimeTool")(
109
118
  "required": True,
110
119
  },
111
120
  ],
121
+ "__call__": '{"sum": str(x + y)}',
112
122
  }
113
123
  )
114
124
 
@@ -128,14 +138,15 @@ print(result)
128
138
 
129
139
  Mutation tools accept a serialized tool specification. At minimum, provide:
130
140
 
131
- - a `type` field that resolves to an installed Swarmauri tool import such as `swarmauri.tools.AdditionTool`
141
+ - a non-empty `type` field that names the runtime tool surface
132
142
  - a non-empty `parameters` list that explicitly declares the runtime callable contract
143
+ - a non-empty `__call__` string that evaluates as a safe Python expression over the declared parameters and approved builtins
133
144
 
134
- Resolution prefers the `swarmauri` facade when present and falls back to `swarmauri_standard.tools.<ToolName>` for isolated package installs.
145
+ The runtime evaluator permits only a constrained expression subset and approved builtins such as `str`, `int`, `float`, `len`, `sum`, `min`, `max`, and `abs`. Imports, attribute traversal, and arbitrary function calls are rejected.
135
146
 
136
147
  ```python
137
148
  {
138
- "type": "AdditionTool",
149
+ "type": "RuntimeAdditionTool",
139
150
  "name": "RuntimeAdditionTool",
140
151
  "description": "Adds two integers.",
141
152
  "parameters": [
@@ -152,15 +163,19 @@ Resolution prefers the `swarmauri` facade when present and falls back to `swarma
152
163
  "required": True,
153
164
  },
154
165
  ],
166
+ "__call__": '{"sum": str(x + y)}',
155
167
  }
156
168
  ```
157
169
 
158
- If the target tool defines extra fields, include them in the spec and the toolkit will validate them against the concrete tool class.
170
+ The `__call__` value is evaluated against the declared parameter names. A body such as `{"sum": str(x + y)}` is valid. A body that tries to import modules, access attributes, or reference undeclared names is rejected.
159
171
 
160
172
  ## Failure Modes
161
173
 
162
174
  - Registration fails when the tool spec omits `parameters`.
175
+ - Registration fails when the tool spec omits `__call__`.
176
+ - Registration fails when the `__call__` body uses unsafe syntax or disallowed names.
163
177
  - Registration fails when the tool name collides with a protected management tool.
178
+ - Execution failures inside an accepted runtime tool return a structured error payload instead of propagating a hard exception or terminating the host process.
164
179
  - Replacement fails when the target tool is missing, reserved, or renamed to an existing tool.
165
180
  - Unregistration fails when the target is reserved or absent.
166
181
 
@@ -169,3 +184,5 @@ If the target tool defines extra fields, include them in the spec and the toolki
169
184
  `swarmauri_toolkit_runtime` is released under the Apache 2.0 License. See `LICENSE` for details.
170
185
 
171
186
 
187
+
188
+
@@ -0,0 +1,15 @@
1
+ swarmauri_toolkit_runtime/InspectRuntimeTool.py,sha256=3s7rRUd4cPp1J9KcYAfiP5jQ1m655NI0WmIXkub0tOo,99
2
+ swarmauri_toolkit_runtime/ListRuntimeTools.py,sha256=Mw8EpJYIXFT518EC3GizQp1yzvTxKVVwFGGoHgBvI7c,93
3
+ swarmauri_toolkit_runtime/RecipeTool.py,sha256=rdFVAa9eebPeqvlQgSHWZxaQNhnCtN3Vm2V8oMH-d1s,1632
4
+ swarmauri_toolkit_runtime/RegisterRuntimeTool.py,sha256=SZztFabPFbCcPlM7UYpl6N4fijveGXpEtd9RSxxzLO8,102
5
+ swarmauri_toolkit_runtime/ReplaceRuntimeTool.py,sha256=_NkhlhC_hU_R2eK1A6p830d32UyrUmllydlJoRK5c50,99
6
+ swarmauri_toolkit_runtime/RuntimeToolkit.py,sha256=9x0W5aMsI8hu0HnGAeLWqN4vVrq7PEx9qWj-f23sPoI,2791
7
+ swarmauri_toolkit_runtime/UnregisterRuntimeTool.py,sha256=cHnB8Vze5_286xH2qidgkD_7h1-kRQHBNm-4WjKMCI4,108
8
+ swarmauri_toolkit_runtime/__init__.py,sha256=Ing0vOmvJXTiLCe8RMLXkOMN8-3DAt0NDDCnfumZoNA,471
9
+ swarmauri_toolkit_runtime/_dynamic_runtime_tool.py,sha256=IRx_cvrZrAGzQ-8cZ0hHihYjJ2ekmU9-s2vPOra3khY,112
10
+ swarmauri_toolkit_runtime/_tool_factory.py,sha256=ZMZYHfT_s6cFpCrf7fMXYvqnFVKvoe1toZKmYfols7g,108
11
+ swarmauri_toolkit_runtime-0.11.0.dev4.dist-info/METADATA,sha256=CfGuDnXulzSrDOmA_SV_nSuQCbDob8bfIOBOa_Ll_2A,8246
12
+ swarmauri_toolkit_runtime-0.11.0.dev4.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
13
+ swarmauri_toolkit_runtime-0.11.0.dev4.dist-info/entry_points.txt,sha256=_d-Lk2LpVH3gxwTThpYM70d23mFZOvf7TGjAZSsuWrg,78
14
+ swarmauri_toolkit_runtime-0.11.0.dev4.dist-info/licenses/LICENSE,sha256=djUXOlCxLVszShEpZXshZ7v33G-2qIC_j9KXpWKZSzQ,11359
15
+ swarmauri_toolkit_runtime-0.11.0.dev4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.3.2
2
+ Generator: poetry-core 2.5.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [swarmauri.toolkits]
2
+ RuntimeToolkit=swarmauri_toolkit_runtime:RuntimeToolkit
3
+
@@ -1,13 +0,0 @@
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,,
@@ -1,10 +0,0 @@
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
-