swarmauri_tool_containerfeedchars 0.7.5.dev1__tar.gz → 0.9.0.dev3__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.3
2
2
  Name: swarmauri_tool_containerfeedchars
3
- Version: 0.7.5.dev1
3
+ Version: 0.9.0.dev3
4
4
  Summary: Execute commands in Docker or Kubernetes containers.
5
5
  License: Apache-2.0
6
6
  Author: Jacob Stewart
@@ -47,7 +47,8 @@ pip install swarmauri_tool_containerfeedchars
47
47
  ```python
48
48
  from swarmauri_tool_containerfeedchars import ContainerFeedCharsTool
49
49
 
50
- output = ContainerFeedCharsTool()(container_name="my-container", command="ls -al")
50
+ tool = ContainerFeedCharsTool(container_name="my-container")
51
+ output = tool(command="ls -al")
51
52
  print(output["stdout"])
52
53
  ```
53
54
 
@@ -30,6 +30,7 @@ pip install swarmauri_tool_containerfeedchars
30
30
  ```python
31
31
  from swarmauri_tool_containerfeedchars import ContainerFeedCharsTool
32
32
 
33
- output = ContainerFeedCharsTool()(container_name="my-container", command="ls -al")
33
+ tool = ContainerFeedCharsTool(container_name="my-container")
34
+ output = tool(command="ls -al")
34
35
  print(output["stdout"])
35
36
  ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_tool_containerfeedchars"
3
- version = "0.7.5.dev1"
3
+ version = "0.9.0.dev3"
4
4
  description = "Execute commands in Docker or Kubernetes containers."
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -17,28 +17,35 @@ class ContainerFeedCharsTool(ToolBase):
17
17
 
18
18
  driver: Literal["docker", "kubernetes"] = "docker"
19
19
 
20
+ container_name: str | None = Field(
21
+ default=None, description="Target container or pod name"
22
+ )
23
+
20
24
  parameters: List[Parameter] = Field(
21
25
  default_factory=lambda: [
22
26
  Parameter(
23
- name="container_name",
27
+ name="command",
24
28
  input_type="string",
25
- description="Target container or pod name",
29
+ description="Shell command to execute",
26
30
  required=True,
27
31
  ),
28
32
  Parameter(
29
- name="command",
33
+ name="container_name",
30
34
  input_type="string",
31
- description="Shell command to execute",
32
- required=True,
35
+ description="Target container or pod name",
36
+ required=False,
33
37
  ),
34
38
  ]
35
39
  )
36
40
 
37
- def __call__(self, container_name: str, command: str) -> dict:
41
+ def __call__(self, command: str, container_name: str | None = None) -> dict:
42
+ name = container_name or self.container_name
43
+ if name is None:
44
+ raise ValueError("container_name must be provided")
38
45
  if self.driver == "docker":
39
- cmd = ["docker", "exec", container_name, "sh", "-c", command]
46
+ cmd = ["docker", "exec", name, "sh", "-c", command]
40
47
  else:
41
- cmd = ["kubectl", "exec", container_name, "--", "sh", "-c", command]
48
+ cmd = ["kubectl", "exec", name, "--", "sh", "-c", command]
42
49
  result = subprocess.run(cmd, capture_output=True, text=True)
43
50
  if result.returncode != 0:
44
51
  raise RuntimeError(result.stderr.strip())