swarmauri_transport_stdio 0.1.1.dev18__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.
@@ -0,0 +1,13 @@
1
+ Copyright 2024 Jacob Stewart
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_transport_stdio
3
+ Version: 0.1.1.dev18
4
+ Summary: STDIO bridge transport for spawning Swarmauri-compatible subprocesses.
5
+ License: Copyright 2024 Jacob Stewart
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ License-File: LICENSE
19
+ Keywords: swarmauri,transport,stdio,subprocess,cli,asyncio,bridge,sdk,standards
20
+ Author: Jacob Stewart
21
+ Author-email: jacob@swarmauri.com
22
+ Requires-Python: >=3.10
23
+ Classifier: Development Status :: 2 - Pre-Alpha
24
+ Classifier: Intended Audience :: Developers
25
+ Classifier: License :: OSI Approved :: Apache Software License
26
+ Classifier: Programming Language :: Python
27
+ Classifier: Programming Language :: Python :: 3
28
+ Classifier: Programming Language :: Python :: 3 :: Only
29
+ Classifier: Programming Language :: Python :: 3.10
30
+ Classifier: Programming Language :: Python :: 3.11
31
+ Classifier: Programming Language :: Python :: 3.12
32
+ Classifier: Topic :: Software Development :: Libraries
33
+ Classifier: Topic :: System :: Shells
34
+ Requires-Dist: swarmauri-base
35
+ Requires-Dist: swarmauri-core
36
+ Project-URL: Homepage, https://github.com/swarmauri/swarmauri-sdk
37
+ Project-URL: Repository, https://github.com/swarmauri/swarmauri-sdk
38
+ Description-Content-Type: text/markdown
39
+
40
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
41
+
42
+ <p align="center">
43
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
44
+ <img src="https://img.shields.io/pypi/dm/swarmauri-transport-stdio" alt="PyPI - Downloads"/>
45
+ </a>
46
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/swarmauri_transport_stdio/">
47
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/swarmauri_transport_stdio.svg"/>
48
+ </a>
49
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
50
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri-transport-stdio" alt="PyPI - Python Version"/>
51
+ </a>
52
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
53
+ <img src="https://img.shields.io/pypi/l/swarmauri-transport-stdio" alt="PyPI - License"/>
54
+ </a>
55
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
56
+ <img src="https://img.shields.io/pypi/v/swarmauri-transport-stdio?label=swarmauri-transport-stdio&color=green" alt="PyPI - swarmauri-transport-stdio"/>
57
+ </a>
58
+ </p>
59
+
60
+ ---
61
+
62
+ # Swarmauri Transport – STDIO Bridge
63
+
64
+ `swarmauri-transport-stdio` spawns subprocesses and communicates over standard input/output so command-line tools can act as Swarmauri peers.
65
+
66
+ ## Installation
67
+
68
+ ### Using `uv`
69
+
70
+ ```bash
71
+ uv pip install swarmauri-transport-stdio --index-url https://pypi.org/simple
72
+ ```
73
+
74
+ ### Using `pip`
75
+
76
+ ```bash
77
+ pip install swarmauri-transport-stdio
78
+ ```
79
+
80
+ ## Usage
81
+
82
+ ```python
83
+ import asyncio
84
+ from swarmauri_transport_stdio import StdioTransport
85
+
86
+ async def run_tool() -> None:
87
+ transport = StdioTransport(["python", "script.py"])
88
+ async with transport.client():
89
+ await transport.send("tool", b"input\n")
90
+ print(await transport.recv())
91
+
92
+ asyncio.run(run_tool())
93
+ ```
94
+
95
+ Wrap any CLI-friendly model or service and adapt its IO using the Swarmauri transport interfaces.
96
+
@@ -0,0 +1,56 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri-transport-stdio" alt="PyPI - Downloads"/>
6
+ </a>
7
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/swarmauri_transport_stdio/">
8
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/swarmauri_transport_stdio.svg"/>
9
+ </a>
10
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
11
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri-transport-stdio" alt="PyPI - Python Version"/>
12
+ </a>
13
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
14
+ <img src="https://img.shields.io/pypi/l/swarmauri-transport-stdio" alt="PyPI - License"/>
15
+ </a>
16
+ <a href="https://pypi.org/project/swarmauri-transport-stdio/">
17
+ <img src="https://img.shields.io/pypi/v/swarmauri-transport-stdio?label=swarmauri-transport-stdio&color=green" alt="PyPI - swarmauri-transport-stdio"/>
18
+ </a>
19
+ </p>
20
+
21
+ ---
22
+
23
+ # Swarmauri Transport – STDIO Bridge
24
+
25
+ `swarmauri-transport-stdio` spawns subprocesses and communicates over standard input/output so command-line tools can act as Swarmauri peers.
26
+
27
+ ## Installation
28
+
29
+ ### Using `uv`
30
+
31
+ ```bash
32
+ uv pip install swarmauri-transport-stdio --index-url https://pypi.org/simple
33
+ ```
34
+
35
+ ### Using `pip`
36
+
37
+ ```bash
38
+ pip install swarmauri-transport-stdio
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ import asyncio
45
+ from swarmauri_transport_stdio import StdioTransport
46
+
47
+ async def run_tool() -> None:
48
+ transport = StdioTransport(["python", "script.py"])
49
+ async with transport.client():
50
+ await transport.send("tool", b"input\n")
51
+ print(await transport.recv())
52
+
53
+ asyncio.run(run_tool())
54
+ ```
55
+
56
+ Wrap any CLI-friendly model or service and adapt its IO using the Swarmauri transport interfaces.
@@ -0,0 +1,74 @@
1
+ [project]
2
+ name = "swarmauri_transport_stdio"
3
+ version = "0.1.1.dev18"
4
+ description = "STDIO bridge transport for spawning Swarmauri-compatible subprocesses."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
8
+ license = { file = "LICENSE" }
9
+ dependencies = [
10
+ "swarmauri-base",
11
+ "swarmauri-core",
12
+ ]
13
+ keywords = [
14
+ "swarmauri",
15
+ "transport",
16
+ "stdio",
17
+ "subprocess",
18
+ "cli",
19
+ "asyncio",
20
+ "bridge",
21
+ "sdk",
22
+ "standards",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 2 - Pre-Alpha",
26
+ "Intended Audience :: Developers",
27
+ "License :: OSI Approved :: Apache Software License",
28
+ "Programming Language :: Python",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Topic :: Software Development :: Libraries",
35
+ "Topic :: System :: Shells",
36
+ ]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/swarmauri/swarmauri-sdk"
40
+ Repository = "https://github.com/swarmauri/swarmauri-sdk"
41
+
42
+ [build-system]
43
+ requires = ["poetry-core>=1.8.0"]
44
+ build-backend = "poetry.core.masonry.api"
45
+
46
+ [tool.pytest.ini_options]
47
+ markers = [
48
+ "test: standard test",
49
+ "unit: Unit tests",
50
+ "i9n: Integration tests",
51
+ "r8n: Regression tests",
52
+ "acceptance: Acceptance tests",
53
+ "perf: Performance tests",
54
+ "example: Documentation examples",
55
+ ]
56
+ timeout = 300
57
+ log_cli = true
58
+ log_cli_level = "INFO"
59
+ log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
60
+ log_cli_date_format = "%Y-%m-%d %H:%M:%S"
61
+ asyncio_default_fixture_loop_scope = "function"
62
+ addopts = "--pylicense-accept-deps=sniffio"
63
+
64
+ [dependency-groups]
65
+ dev = [
66
+ "pytest>=8.0",
67
+ "pytest-asyncio>=0.24.0",
68
+ "pytest-xdist>=3.6.1",
69
+ "pytest-json-report>=1.5.0",
70
+ "pytest-timeout>=2.3.1",
71
+ "pytest-benchmark>=4.0.0",
72
+ "ruff>=0.9.9",
73
+ "swarmauri_tests_pylicense",
74
+ ]
@@ -0,0 +1,5 @@
1
+ """STDIO transport package."""
2
+
3
+ from .stdio_transport import StdioTransport
4
+
5
+ __all__ = ["StdioTransport"]
@@ -0,0 +1,70 @@
1
+ from __future__ import annotations
2
+
3
+ import asyncio
4
+ import contextlib
5
+ from typing import Optional, Sequence
6
+
7
+ from swarmauri_base.transports.peer_mixin import PeerTransportMixin
8
+ from swarmauri_base.transports.runnable_mixin import RunnableMixin
9
+ from swarmauri_base.transports.TransportBase import TransportBase
10
+ from swarmauri_base.transports.unicast_mixin import UnicastTransportMixin
11
+ from swarmauri_core.transports.capabilities import TransportCapabilities
12
+ from swarmauri_core.transports.enums import (
13
+ AddressScheme,
14
+ Cast,
15
+ Feature,
16
+ IOModel,
17
+ Protocol,
18
+ SecurityMode,
19
+ )
20
+
21
+
22
+ class StdioTransport(
23
+ TransportBase, RunnableMixin, PeerTransportMixin, UnicastTransportMixin
24
+ ):
25
+ """Spawned process transport that communicates over stdio."""
26
+
27
+ def __init__(self, argv: Sequence[str]) -> None:
28
+ super().__init__(name="STDIO")
29
+ self._argv = list(argv)
30
+ self._process: asyncio.Process | None = None
31
+
32
+ def supports(self) -> TransportCapabilities:
33
+ return TransportCapabilities(
34
+ protocols=frozenset({Protocol.STDIO}),
35
+ io=IOModel.STREAM,
36
+ casts=frozenset({Cast.UNICAST}),
37
+ features=frozenset({Feature.RELIABLE, Feature.ORDERED}),
38
+ security=SecurityMode.NONE,
39
+ schemes=frozenset({AddressScheme.STDIO}),
40
+ )
41
+
42
+ async def _start_server(self, **kwargs) -> None:
43
+ raise NotImplementedError("STDIO transport launches child processes only")
44
+
45
+ async def _open_client(self) -> None:
46
+ self._process = await asyncio.create_subprocess_exec(
47
+ *self._argv,
48
+ stdin=asyncio.subprocess.PIPE,
49
+ stdout=asyncio.subprocess.PIPE,
50
+ )
51
+
52
+ async def _close_client(self) -> None:
53
+ if self._process is not None:
54
+ self._process.terminate()
55
+ with contextlib.suppress(Exception):
56
+ await self._process.wait()
57
+ self._process = None
58
+
59
+ async def send(
60
+ self, target: str, data: bytes, *, timeout: Optional[float] = None
61
+ ) -> None:
62
+ if self._process is None or self._process.stdin is None:
63
+ raise RuntimeError("not connected")
64
+ self._process.stdin.write(data)
65
+ await asyncio.wait_for(self._process.stdin.drain(), timeout)
66
+
67
+ async def recv(self, *, timeout: Optional[float] = None) -> bytes:
68
+ if self._process is None or self._process.stdout is None:
69
+ raise RuntimeError("not connected")
70
+ return await asyncio.wait_for(self._process.stdout.read(65536), timeout)