swarmauri_tool_skill_execution 0.11.0.dev5__tar.gz → 0.11.0.dev6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: swarmauri_tool_skill_execution
3
- Version: 0.11.0.dev5
3
+ Version: 0.11.0.dev6
4
4
  Summary: Skill-aware subprocess execution tool for Swarmauri agents.
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -16,9 +16,9 @@ Classifier: Programming Language :: Python :: 3 :: Only
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
- Requires-Dist: swarmauri_base
20
- Requires-Dist: swarmauri_core
21
- Requires-Dist: swarmauri_standard
19
+ Requires-Dist: swarmauri_base (>=0.11.0.dev6,<0.12)
20
+ Requires-Dist: swarmauri_core (>=0.11.0.dev6,<0.12)
21
+ Requires-Dist: swarmauri_standard (>=0.11.0.dev8,<0.12)
22
22
  Description-Content-Type: text/markdown
23
23
 
24
24
  # Swarmauri Skill Execution Tool
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_tool_skill_execution"
3
- version = "0.11.0.dev5"
3
+ version = "0.11.0.dev6"
4
4
  description = "Skill-aware subprocess execution tool for Swarmauri agents."
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -18,9 +18,9 @@ classifiers = [
18
18
  ]
19
19
  authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
20
20
  dependencies = [
21
- "swarmauri_core",
22
- "swarmauri_base",
23
- "swarmauri_standard",
21
+ "swarmauri_core>=0.11.0.dev6,<0.12",
22
+ "swarmauri_base>=0.11.0.dev6,<0.12",
23
+ "swarmauri_standard>=0.11.0.dev8,<0.12",
24
24
  ]
25
25
  keywords = ["swarmauri", "sdk", "standards", "skills", "tools", "subprocess"]
26
26
 
@@ -1,6 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import subprocess
4
+
5
+ from swarmauri_base.processes.collect_process import collect_process
6
+ from swarmauri_core.processes import IProcessBackend, ProcessRequest
4
7
  import time
5
8
  from concurrent.futures import ThreadPoolExecutor
6
9
  from pathlib import Path
@@ -63,6 +66,9 @@ class SkillExecutionTool(ToolBase):
63
66
  ]
64
67
  )
65
68
  skills: List[SubclassUnion[SkillBase]] = Field(default_factory=list)
69
+ backend: IProcessBackend | None = Field(default=None, exclude=True)
70
+ workspace: str | None = None
71
+ workspace_skill_roots: dict[str, str] = Field(default_factory=dict)
66
72
  default_timeout: float = 60.0
67
73
  model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
68
74
  type: Literal["SkillExecutionTool"] = "SkillExecutionTool"
@@ -91,6 +97,10 @@ class SkillExecutionTool(ToolBase):
91
97
  ) -> Dict[str, Any]:
92
98
  skill = self._get_skill(skill_name)
93
99
  root = self._skill_root(skill)
100
+ if self.backend is not None and self.workspace is not None:
101
+ process_root = self.workspace_skill_roots[skill.name]
102
+ else:
103
+ process_root = str(root)
94
104
  normalized_commands = self._normalize_commands(commands)
95
105
  effective_timeout = (
96
106
  timeout if timeout is not None else self.default_timeout
@@ -103,14 +113,16 @@ class SkillExecutionTool(ToolBase):
103
113
  results = list(
104
114
  pool.map(
105
115
  lambda argv: self._run_command(
106
- argv, root, input_text, effective_timeout
116
+ argv, process_root, input_text, effective_timeout
107
117
  ),
108
118
  normalized_commands,
109
119
  )
110
120
  )
111
121
  else:
112
122
  results = [
113
- self._run_command(argv, root, input_text, effective_timeout)
123
+ self._run_command(
124
+ argv, process_root, input_text, effective_timeout
125
+ )
114
126
  for argv in normalized_commands
115
127
  ]
116
128
 
@@ -158,15 +170,35 @@ class SkillExecutionTool(ToolBase):
158
170
  raise ValueError("Each command must be a non-empty argv array")
159
171
  return normalized
160
172
 
161
- @staticmethod
162
173
  def _run_command(
174
+ self,
163
175
  argv: List[str],
164
- root: Path,
176
+ root: str,
165
177
  input_text: str | None,
166
178
  timeout: float,
167
179
  ) -> Dict[str, Any]:
168
180
  started = time.perf_counter()
169
181
  try:
182
+ if self.backend is not None:
183
+ stdout_bytes, stderr_bytes, event = collect_process(
184
+ self.backend,
185
+ ProcessRequest(
186
+ tuple(argv),
187
+ cwd=root,
188
+ workspace=self.workspace,
189
+ timeout=timeout,
190
+ ),
191
+ (input_text or "").encode(),
192
+ )
193
+ return {
194
+ "argv": argv,
195
+ "exit_code": "timeout"
196
+ if event.outcome == "timed_out"
197
+ else event.exit_code,
198
+ "stdout": stdout_bytes.decode(errors="replace"),
199
+ "stderr": stderr_bytes.decode(errors="replace"),
200
+ "duration_ms": int((time.perf_counter() - started) * 1000),
201
+ }
170
202
  completed = subprocess.run(
171
203
  argv,
172
204
  cwd=root,