swarmauri_middleware_stdio 0.8.0.dev47__tar.gz → 0.11.0__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.
- swarmauri_middleware_stdio-0.11.0/NOTICE +7 -0
- swarmauri_middleware_stdio-0.11.0/PKG-INFO +401 -0
- swarmauri_middleware_stdio-0.11.0/README.md +373 -0
- {swarmauri_middleware_stdio-0.8.0.dev47 → swarmauri_middleware_stdio-0.11.0}/pyproject.toml +59 -9
- {swarmauri_middleware_stdio-0.8.0.dev47 → swarmauri_middleware_stdio-0.11.0}/swarmauri_middleware_stdio/StdioMiddleware.py +1 -1
- swarmauri_middleware_stdio-0.8.0.dev47/PKG-INFO +0 -116
- swarmauri_middleware_stdio-0.8.0.dev47/README.md +0 -90
- {swarmauri_middleware_stdio-0.8.0.dev47 → swarmauri_middleware_stdio-0.11.0}/LICENSE +0 -0
- {swarmauri_middleware_stdio-0.8.0.dev47 → swarmauri_middleware_stdio-0.11.0}/swarmauri_middleware_stdio/__init__.py +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_middleware_stdio
|
|
3
|
+
Version: 0.11.0
|
|
4
|
+
Summary: Middleware that logs requests and responses to standard output
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: swarmauri,sdk,standards,middleware,stdio
|
|
9
|
+
Author: Jacob Stewart
|
|
10
|
+
Author-email: jacob@swarmauri.com
|
|
11
|
+
Requires-Python: >=3.10,<3.15
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Requires-Dist: starlette
|
|
23
|
+
Requires-Dist: swarmauri_base
|
|
24
|
+
Requires-Dist: swarmauri_core
|
|
25
|
+
Requires-Dist: swarmauri_standard
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# swarmauri_middleware_stdio
|
|
29
|
+
|
|
30
|
+
<!-- readme-standards:begin branding -->
|
|
31
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
32
|
+
<p align="center"><strong>swarmauri_middleware_stdio</strong></p>
|
|
33
|
+
<p align="center">Middleware that logs requests and responses to standard output</p>
|
|
34
|
+
<p align="center">
|
|
35
|
+
<a href="https://pypi.org/project/swarmauri_middleware_stdio/"><img alt="pypi: swarmauri_middleware_stdio" src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?labelColor=1E293B&color=1D4ED8"></a>
|
|
36
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml"><img alt="Source version: 0.11.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.11.0&labelColor=1E293B&color=4338CA"></a>
|
|
37
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=1E293B&color=0F766E"></a>
|
|
38
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=1E293B&color=6D28D9"></a>
|
|
39
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=1E293B&color=166534"></a>
|
|
40
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=1E293B&color=86198F"></a>
|
|
41
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=1E293B&color=86198F"></a>
|
|
42
|
+
</p>
|
|
43
|
+
<p align="center">
|
|
44
|
+
<a href="https://pypi.org/project/swarmauri_middleware_stdio/"><img alt="Monthly PyPI downloads: swarmauri_middleware_stdio" src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio?labelColor=1E293B&color=0E7490"></a>
|
|
45
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/README.md"><img alt="README hits: swarmauri_middleware_stdio" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_middleware_stdio/README.md.svg?label=README%20hits&labelColor=1E293B&color=0E7490"></a>
|
|
46
|
+
</p>
|
|
47
|
+
<p align="center">
|
|
48
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=1E293B&color=1D4ED8"></a>
|
|
49
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=1E293B&color=0F766E"></a>
|
|
50
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=1E293B&color=92400E"></a>
|
|
51
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=1E293B&color=4338CA"></a>
|
|
52
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=1E293B&color=6D28D9"></a>
|
|
53
|
+
</p>
|
|
54
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
55
|
+
<!-- readme-standards:end branding -->
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Overview
|
|
60
|
+
|
|
61
|
+
### Summary
|
|
62
|
+
|
|
63
|
+
`swarmauri_middleware_stdio` provides a lightweight Starlette middleware that
|
|
64
|
+
logs incoming requests and outgoing responses to standard output using
|
|
65
|
+
Python's logging module. It is handy for development and debugging when a
|
|
66
|
+
full logging stack is unnecessary.
|
|
67
|
+
|
|
68
|
+
### Why This Package
|
|
69
|
+
|
|
70
|
+
`swarmauri_middleware_stdio` isolates this responsibility: Middleware that logs requests and responses to standard output. Its [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) exposes `StdioMiddleware`, allowing consumers to select this package without treating adjacent packages as part of its public contract.
|
|
71
|
+
|
|
72
|
+
### When to Use
|
|
73
|
+
|
|
74
|
+
Choose `swarmauri_middleware_stdio` when your integration needs middleware that logs requests and responses to standard output. Match the imports below to your application boundary and install its declared dependencies before using the example.
|
|
75
|
+
|
|
76
|
+
### Features
|
|
77
|
+
|
|
78
|
+
- `StdioMiddleware`: Log request and response details to stdout.
|
|
79
|
+
|
|
80
|
+
### Non-Goals
|
|
81
|
+
|
|
82
|
+
`swarmauri_middleware_stdio` owns middleware that logs requests and responses to standard output. Its imports do not by themselves configure credentials, deploy a service, or certify the behavior of its consumers. Dependencies and neighboring packages retain their own documented responsibilities.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Getting Started
|
|
87
|
+
|
|
88
|
+
### Prerequisites
|
|
89
|
+
|
|
90
|
+
Python `>=3.10,<3.15` is required. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) declares runtime dependencies including `starlette`, `swarmauri-core`, `swarmauri-base`, `swarmauri-standard`. Read the example’s inputs and service requirements before execution.
|
|
91
|
+
|
|
92
|
+
### Installation
|
|
93
|
+
|
|
94
|
+
Pick the tool that matches your workflow:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# pip
|
|
98
|
+
pip install swarmauri_middleware_stdio
|
|
99
|
+
|
|
100
|
+
# Poetry
|
|
101
|
+
poetry add swarmauri_middleware_stdio
|
|
102
|
+
|
|
103
|
+
# uv
|
|
104
|
+
pip install uv # install uv if it's not already available
|
|
105
|
+
uv add swarmauri_middleware_stdio
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### uv
|
|
109
|
+
|
|
110
|
+
<!-- readme-standards:begin installation.uv -->
|
|
111
|
+
```bash
|
|
112
|
+
uv add swarmauri_middleware_stdio
|
|
113
|
+
```
|
|
114
|
+
<!-- readme-standards:end installation.uv -->
|
|
115
|
+
|
|
116
|
+
#### pip
|
|
117
|
+
|
|
118
|
+
<!-- readme-standards:begin installation.pip -->
|
|
119
|
+
```bash
|
|
120
|
+
python -m pip install swarmauri_middleware_stdio
|
|
121
|
+
```
|
|
122
|
+
<!-- readme-standards:end installation.pip -->
|
|
123
|
+
|
|
124
|
+
#### Poetry
|
|
125
|
+
|
|
126
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
127
|
+
```bash
|
|
128
|
+
poetry add swarmauri_middleware_stdio
|
|
129
|
+
```
|
|
130
|
+
<!-- readme-standards:end installation.poetry -->
|
|
131
|
+
|
|
132
|
+
### Quick Start
|
|
133
|
+
|
|
134
|
+
#### Example
|
|
135
|
+
|
|
136
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
137
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/docs/readme/quick_start.py).
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
import logging
|
|
141
|
+
import sys
|
|
142
|
+
|
|
143
|
+
from starlette.applications import Starlette
|
|
144
|
+
from starlette.middleware.base import BaseHTTPMiddleware
|
|
145
|
+
from starlette.requests import Request
|
|
146
|
+
from starlette.responses import JSONResponse
|
|
147
|
+
from swarmauri_middleware_stdio import StdioMiddleware
|
|
148
|
+
|
|
149
|
+
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
|
150
|
+
|
|
151
|
+
app = Starlette()
|
|
152
|
+
stdio = StdioMiddleware()
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
async def log_to_stdout(request: Request, call_next):
|
|
156
|
+
return await stdio.dispatch(request, call_next)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
app.add_middleware(BaseHTTPMiddleware, dispatch=log_to_stdout)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
async def hello(_request):
|
|
163
|
+
return JSONResponse({"message": "hello"})
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
app.add_route("/", hello)
|
|
167
|
+
```
|
|
168
|
+
<!-- readme-standards:end example.quick-start -->
|
|
169
|
+
|
|
170
|
+
#### Expected Result
|
|
171
|
+
|
|
172
|
+
The example demonstrates the documented `swarmauri_middleware_stdio` source boundary or workflow. Complete its required configuration first. README CI checks the maintained source’s syntax and declarations; it does not claim that external services or the application workflow were exercised.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Usage
|
|
177
|
+
|
|
178
|
+
### Common Workflows
|
|
179
|
+
|
|
180
|
+
<!-- readme-standards:begin example.usage -->
|
|
181
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/docs/readme/usage.py).
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
import logging
|
|
185
|
+
import sys
|
|
186
|
+
|
|
187
|
+
from starlette.applications import Starlette
|
|
188
|
+
from starlette.middleware.base import BaseHTTPMiddleware
|
|
189
|
+
from starlette.requests import Request
|
|
190
|
+
from starlette.responses import JSONResponse
|
|
191
|
+
from swarmauri_middleware_stdio import StdioMiddleware
|
|
192
|
+
|
|
193
|
+
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
|
194
|
+
|
|
195
|
+
app = Starlette()
|
|
196
|
+
stdio = StdioMiddleware()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
async def log_to_stdout(request: Request, call_next):
|
|
200
|
+
return await stdio.dispatch(request, call_next)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
app.add_middleware(BaseHTTPMiddleware, dispatch=log_to_stdout)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
async def hello(_request):
|
|
207
|
+
return JSONResponse({"message": "hello"})
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
app.add_route("/", hello)
|
|
211
|
+
```
|
|
212
|
+
<!-- readme-standards:end example.usage -->
|
|
213
|
+
|
|
214
|
+
### Configuration
|
|
215
|
+
|
|
216
|
+
Configure `swarmauri_middleware_stdio` through the APIs in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py); its [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) describes installation requirements, not an implicit service configuration. No additional package-global configuration contract is inferred from dependencies.
|
|
217
|
+
|
|
218
|
+
### Error Handling
|
|
219
|
+
|
|
220
|
+
The inspected `swarmauri_middleware_stdio` source does not establish a package-wide exception hierarchy. Preserve errors from its declared dependencies and validate inputs using the specific public contract in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py).
|
|
221
|
+
|
|
222
|
+
### Best Practices
|
|
223
|
+
|
|
224
|
+
Use the explicit `swarmauri_middleware_stdio` imports documented below and keep collaborator configuration with the caller. Run the package’s relevant tests after changing `StdioMiddleware`; an import or successful installation alone does not establish its runtime guarantees.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Package Boundary
|
|
229
|
+
|
|
230
|
+
### What It Owns
|
|
231
|
+
|
|
232
|
+
`swarmauri_middleware_stdio` is located in `standards` and owns middleware that logs requests and responses to standard output. Source-declared APIs include `StdioMiddleware`. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) records its direct dependency boundary.
|
|
233
|
+
|
|
234
|
+
### Public API and Import Surfaces
|
|
235
|
+
|
|
236
|
+
Import namespace: `swarmauri_middleware_stdio`.
|
|
237
|
+
|
|
238
|
+
Source-declared exports or types: `StdioMiddleware`.
|
|
239
|
+
|
|
240
|
+
Inspect [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) for exact signatures; this inventory does not designate every internal module as stable.
|
|
241
|
+
|
|
242
|
+
### Entry Points
|
|
243
|
+
|
|
244
|
+
<!-- readme-standards:begin entry-points -->
|
|
245
|
+
- `swarmauri.middlewares` → `StdioMiddleware` → `swarmauri_middleware_stdio:StdioMiddleware`
|
|
246
|
+
<!-- readme-standards:end entry-points -->
|
|
247
|
+
|
|
248
|
+
### Injected Dependencies
|
|
249
|
+
|
|
250
|
+
The direct installation dependencies of `swarmauri_middleware_stdio` are `starlette`, `swarmauri-core`, `swarmauri-base`, `swarmauri-standard`. These declarations do not imply automatic provider selection. Pass collaborators through the explicit constructors or call signatures in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py).
|
|
251
|
+
|
|
252
|
+
### Protocol Consumers
|
|
253
|
+
|
|
254
|
+
No direct package-manifest dependency on `swarmauri_middleware_stdio` was found in the audited three-repository inventory. External consumers may still use its documented imports or commands.
|
|
255
|
+
|
|
256
|
+
### Extensions
|
|
257
|
+
|
|
258
|
+
For `swarmauri_middleware_stdio`, use the source-declared public interfaces (`StdioMiddleware`) when composing or extending behavior. Its entry-point section below is authoritative for registered plugins; no additional extension loader is inferred from the package name.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Operations and Readiness
|
|
263
|
+
|
|
264
|
+
### Operational Requirements
|
|
265
|
+
|
|
266
|
+
Operate `swarmauri_middleware_stdio` according to its actual entry points and collaborators. The dependency and Python requirements in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) are prerequisites; deployment topology, credentials, and readiness remain the responsibility of the consuming application unless explicitly documented above.
|
|
267
|
+
|
|
268
|
+
### Health and Observability
|
|
269
|
+
|
|
270
|
+
This README does not establish a standalone health endpoint for `swarmauri_middleware_stdio`. Observe the concrete caller’s results, exceptions, and existing test reports. An application that embeds this package must define its own health and telemetry contract.
|
|
271
|
+
|
|
272
|
+
### Security and Resource Limits
|
|
273
|
+
|
|
274
|
+
Apply the input, credential, and resource constraints implemented in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py). The `swarmauri_middleware_stdio` README gate is a documentation check, not a security review or a substitute for the implementation’s limits and caller authorization.
|
|
275
|
+
|
|
276
|
+
### Compatibility
|
|
277
|
+
|
|
278
|
+
This source version of `swarmauri_middleware_stdio` declares Python `>=3.10,<3.15`. Consult its dependency constraints before upgrading. Source-version and registry-version badges have separate meanings; this migration makes no additional platform or interoperability certification claim.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Verification
|
|
283
|
+
|
|
284
|
+
### Tests
|
|
285
|
+
|
|
286
|
+
Run `python -m pytest tests/unit/test_readme_sources.py` from the `swarmauri_middleware_stdio` package directory for the maintained example source checks (Python compilation and non-Python file presence). Existing package tests include:
|
|
287
|
+
|
|
288
|
+
- [tests/example/test_readme_example.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/example/test_readme_example.py)
|
|
289
|
+
- [tests/i9n/test_i9n__init__.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/i9n/test_i9n__init__.py)
|
|
290
|
+
- [tests/i9n/test_starlette_integration.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/i9n/test_starlette_integration.py)
|
|
291
|
+
- [tests/unit/test_StdioMiddleware.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/unit/test_StdioMiddleware.py)
|
|
292
|
+
|
|
293
|
+
The repository README gate also checks the required heading tree, metadata, managed fragments, and referenced files.
|
|
294
|
+
|
|
295
|
+
### Certification Status
|
|
296
|
+
|
|
297
|
+
No external certification is asserted for `swarmauri_middleware_stdio` by this documentation migration. README conformance, example syntax, runtime tests, and protocol or security certification are distinct evidence scopes.
|
|
298
|
+
|
|
299
|
+
### Evidence
|
|
300
|
+
|
|
301
|
+
The [README standards CI](https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml) records mechanical documentation results for its tested commit. The [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) and example sources support the package-boundary description; external runtime behavior requires its own test evidence.
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## FAQ
|
|
306
|
+
|
|
307
|
+
### Why
|
|
308
|
+
|
|
309
|
+
**Why select this package?** `swarmauri_middleware_stdio` provides middleware that logs requests and responses to standard output; use its own API boundary rather than assuming neighboring packages are bundled or configured automatically.
|
|
310
|
+
|
|
311
|
+
### How
|
|
312
|
+
|
|
313
|
+
**How do I start?** Install or synchronize the environment under Getting Started, follow the maintained example for `swarmauri_middleware_stdio`, and consult [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) for the exact types and signatures involved.
|
|
314
|
+
|
|
315
|
+
### When
|
|
316
|
+
|
|
317
|
+
**When should I validate an upgrade?** Recheck `swarmauri_middleware_stdio` whenever its source version, declared collaborators, configuration, or caller changes. Run relevant behavioral tests in addition to the README gate before promotion.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Documentation and Related Packages
|
|
322
|
+
|
|
323
|
+
### More Documentation
|
|
324
|
+
|
|
325
|
+
The [repository contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md), [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py), and [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) provide the supporting context for `swarmauri_middleware_stdio`. The [README policy](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md) defines the common document structure.
|
|
326
|
+
|
|
327
|
+
### Related Packages
|
|
328
|
+
|
|
329
|
+
- [swarmauri_base](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/20-bases/swarmauri_base/README.md): Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
|
|
330
|
+
- [swarmauri_core](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/10-interfaces/swarmauri_core/README.md): Core interface contracts and shared types for Swarmauri composable intelligence infrastructure components.
|
|
331
|
+
- [swarmauri_standard](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/30-standard-kernel/swarmauri_standard/README.md): First-party Swarmauri standard components for agents, tools, parsers, vectors, model adapters, and composable intelligence workflows.
|
|
332
|
+
|
|
333
|
+
### Project Links
|
|
334
|
+
|
|
335
|
+
<!-- readme-standards:begin project-links -->
|
|
336
|
+
- [pypi: swarmauri_middleware_stdio](https://pypi.org/project/swarmauri_middleware_stdio/)
|
|
337
|
+
<!-- readme-standards:end project-links -->
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Contributing
|
|
342
|
+
|
|
343
|
+
### How to Contribute
|
|
344
|
+
|
|
345
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
346
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
347
|
+
that will help you get started.
|
|
348
|
+
|
|
349
|
+
### Development Setup
|
|
350
|
+
|
|
351
|
+
Work from the `pkgs/40-standards/swarmauri_middleware_stdio` checkout. Synchronize its declared development environment with uv, then run the relevant package tests and `python -m pytest tests/unit/test_readme_sources.py`. The repository’s dedicated README job installs `readme-standards==0.1.3` without resolving unrelated runtime packages.
|
|
352
|
+
|
|
353
|
+
### Notes for Maintainers
|
|
354
|
+
|
|
355
|
+
**How It Works**
|
|
356
|
+
|
|
357
|
+
`StdioMiddleware` uses Python's logging facilities under the logger name
|
|
358
|
+
`swarmauri_middleware_stdio.StdioMiddleware`. Each request produces an `INFO`
|
|
359
|
+
record before the downstream handler runs, and the matching response status is
|
|
360
|
+
logged afterwards. Configure logging (as in the example above) to route those
|
|
361
|
+
messages to stdout or another destination appropriate for your deployment.
|
|
362
|
+
|
|
363
|
+
When the middleware is active you should see output similar to:
|
|
364
|
+
|
|
365
|
+
```
|
|
366
|
+
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Request: GET /
|
|
367
|
+
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Response: 200
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Governance
|
|
373
|
+
|
|
374
|
+
### Ownership and Decision Making
|
|
375
|
+
|
|
376
|
+
Changes to `swarmauri_middleware_stdio` follow the maintainer review process of [swarmauri/swarmauri-sdk](https://github.com/swarmauri/swarmauri-sdk) and its contribution guide. Author attribution remains in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml); this README does not assign new publishing or administrative authority.
|
|
377
|
+
|
|
378
|
+
### Standards and Policies
|
|
379
|
+
|
|
380
|
+
`swarmauri_middleware_stdio` follows the versioned [package-guide-v1 outline](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md). All fixed headings, hierarchy, order, separators, and package-specific branding are checked by CI; reviewers assess the accuracy and usefulness of authored claims.
|
|
381
|
+
|
|
382
|
+
### Lifecycle and Migration
|
|
383
|
+
|
|
384
|
+
The `swarmauri_middleware_stdio` source version is `0.11.0`.
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## License and Attribution
|
|
389
|
+
|
|
390
|
+
### License
|
|
391
|
+
|
|
392
|
+
<!-- readme-standards:begin license -->
|
|
393
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/LICENSE).
|
|
394
|
+
<!-- readme-standards:end license -->
|
|
395
|
+
|
|
396
|
+
### Notices
|
|
397
|
+
|
|
398
|
+
<!-- readme-standards:begin notices -->
|
|
399
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/NOTICE) for attribution.
|
|
400
|
+
<!-- readme-standards:end notices -->
|
|
401
|
+
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
# swarmauri_middleware_stdio
|
|
2
|
+
|
|
3
|
+
<!-- readme-standards:begin branding -->
|
|
4
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
5
|
+
<p align="center"><strong>swarmauri_middleware_stdio</strong></p>
|
|
6
|
+
<p align="center">Middleware that logs requests and responses to standard output</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_middleware_stdio/"><img alt="pypi: swarmauri_middleware_stdio" src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?labelColor=1E293B&color=1D4ED8"></a>
|
|
9
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml"><img alt="Source version: 0.11.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.11.0&labelColor=1E293B&color=4338CA"></a>
|
|
10
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=1E293B&color=0F766E"></a>
|
|
11
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=1E293B&color=6D28D9"></a>
|
|
12
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=1E293B&color=166534"></a>
|
|
13
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=1E293B&color=86198F"></a>
|
|
14
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=1E293B&color=86198F"></a>
|
|
15
|
+
</p>
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://pypi.org/project/swarmauri_middleware_stdio/"><img alt="Monthly PyPI downloads: swarmauri_middleware_stdio" src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio?labelColor=1E293B&color=0E7490"></a>
|
|
18
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/README.md"><img alt="README hits: swarmauri_middleware_stdio" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_middleware_stdio/README.md.svg?label=README%20hits&labelColor=1E293B&color=0E7490"></a>
|
|
19
|
+
</p>
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=1E293B&color=1D4ED8"></a>
|
|
22
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=1E293B&color=0F766E"></a>
|
|
23
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=1E293B&color=92400E"></a>
|
|
24
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=1E293B&color=4338CA"></a>
|
|
25
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=1E293B&color=6D28D9"></a>
|
|
26
|
+
</p>
|
|
27
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
28
|
+
<!-- readme-standards:end branding -->
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
### Summary
|
|
35
|
+
|
|
36
|
+
`swarmauri_middleware_stdio` provides a lightweight Starlette middleware that
|
|
37
|
+
logs incoming requests and outgoing responses to standard output using
|
|
38
|
+
Python's logging module. It is handy for development and debugging when a
|
|
39
|
+
full logging stack is unnecessary.
|
|
40
|
+
|
|
41
|
+
### Why This Package
|
|
42
|
+
|
|
43
|
+
`swarmauri_middleware_stdio` isolates this responsibility: Middleware that logs requests and responses to standard output. Its [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) exposes `StdioMiddleware`, allowing consumers to select this package without treating adjacent packages as part of its public contract.
|
|
44
|
+
|
|
45
|
+
### When to Use
|
|
46
|
+
|
|
47
|
+
Choose `swarmauri_middleware_stdio` when your integration needs middleware that logs requests and responses to standard output. Match the imports below to your application boundary and install its declared dependencies before using the example.
|
|
48
|
+
|
|
49
|
+
### Features
|
|
50
|
+
|
|
51
|
+
- `StdioMiddleware`: Log request and response details to stdout.
|
|
52
|
+
|
|
53
|
+
### Non-Goals
|
|
54
|
+
|
|
55
|
+
`swarmauri_middleware_stdio` owns middleware that logs requests and responses to standard output. Its imports do not by themselves configure credentials, deploy a service, or certify the behavior of its consumers. Dependencies and neighboring packages retain their own documented responsibilities.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Getting Started
|
|
60
|
+
|
|
61
|
+
### Prerequisites
|
|
62
|
+
|
|
63
|
+
Python `>=3.10,<3.15` is required. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) declares runtime dependencies including `starlette`, `swarmauri-core`, `swarmauri-base`, `swarmauri-standard`. Read the example’s inputs and service requirements before execution.
|
|
64
|
+
|
|
65
|
+
### Installation
|
|
66
|
+
|
|
67
|
+
Pick the tool that matches your workflow:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# pip
|
|
71
|
+
pip install swarmauri_middleware_stdio
|
|
72
|
+
|
|
73
|
+
# Poetry
|
|
74
|
+
poetry add swarmauri_middleware_stdio
|
|
75
|
+
|
|
76
|
+
# uv
|
|
77
|
+
pip install uv # install uv if it's not already available
|
|
78
|
+
uv add swarmauri_middleware_stdio
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### uv
|
|
82
|
+
|
|
83
|
+
<!-- readme-standards:begin installation.uv -->
|
|
84
|
+
```bash
|
|
85
|
+
uv add swarmauri_middleware_stdio
|
|
86
|
+
```
|
|
87
|
+
<!-- readme-standards:end installation.uv -->
|
|
88
|
+
|
|
89
|
+
#### pip
|
|
90
|
+
|
|
91
|
+
<!-- readme-standards:begin installation.pip -->
|
|
92
|
+
```bash
|
|
93
|
+
python -m pip install swarmauri_middleware_stdio
|
|
94
|
+
```
|
|
95
|
+
<!-- readme-standards:end installation.pip -->
|
|
96
|
+
|
|
97
|
+
#### Poetry
|
|
98
|
+
|
|
99
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
100
|
+
```bash
|
|
101
|
+
poetry add swarmauri_middleware_stdio
|
|
102
|
+
```
|
|
103
|
+
<!-- readme-standards:end installation.poetry -->
|
|
104
|
+
|
|
105
|
+
### Quick Start
|
|
106
|
+
|
|
107
|
+
#### Example
|
|
108
|
+
|
|
109
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
110
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/docs/readme/quick_start.py).
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import logging
|
|
114
|
+
import sys
|
|
115
|
+
|
|
116
|
+
from starlette.applications import Starlette
|
|
117
|
+
from starlette.middleware.base import BaseHTTPMiddleware
|
|
118
|
+
from starlette.requests import Request
|
|
119
|
+
from starlette.responses import JSONResponse
|
|
120
|
+
from swarmauri_middleware_stdio import StdioMiddleware
|
|
121
|
+
|
|
122
|
+
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
|
123
|
+
|
|
124
|
+
app = Starlette()
|
|
125
|
+
stdio = StdioMiddleware()
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
async def log_to_stdout(request: Request, call_next):
|
|
129
|
+
return await stdio.dispatch(request, call_next)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
app.add_middleware(BaseHTTPMiddleware, dispatch=log_to_stdout)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
async def hello(_request):
|
|
136
|
+
return JSONResponse({"message": "hello"})
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
app.add_route("/", hello)
|
|
140
|
+
```
|
|
141
|
+
<!-- readme-standards:end example.quick-start -->
|
|
142
|
+
|
|
143
|
+
#### Expected Result
|
|
144
|
+
|
|
145
|
+
The example demonstrates the documented `swarmauri_middleware_stdio` source boundary or workflow. Complete its required configuration first. README CI checks the maintained source’s syntax and declarations; it does not claim that external services or the application workflow were exercised.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Usage
|
|
150
|
+
|
|
151
|
+
### Common Workflows
|
|
152
|
+
|
|
153
|
+
<!-- readme-standards:begin example.usage -->
|
|
154
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/docs/readme/usage.py).
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
import logging
|
|
158
|
+
import sys
|
|
159
|
+
|
|
160
|
+
from starlette.applications import Starlette
|
|
161
|
+
from starlette.middleware.base import BaseHTTPMiddleware
|
|
162
|
+
from starlette.requests import Request
|
|
163
|
+
from starlette.responses import JSONResponse
|
|
164
|
+
from swarmauri_middleware_stdio import StdioMiddleware
|
|
165
|
+
|
|
166
|
+
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
|
167
|
+
|
|
168
|
+
app = Starlette()
|
|
169
|
+
stdio = StdioMiddleware()
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
async def log_to_stdout(request: Request, call_next):
|
|
173
|
+
return await stdio.dispatch(request, call_next)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
app.add_middleware(BaseHTTPMiddleware, dispatch=log_to_stdout)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
async def hello(_request):
|
|
180
|
+
return JSONResponse({"message": "hello"})
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
app.add_route("/", hello)
|
|
184
|
+
```
|
|
185
|
+
<!-- readme-standards:end example.usage -->
|
|
186
|
+
|
|
187
|
+
### Configuration
|
|
188
|
+
|
|
189
|
+
Configure `swarmauri_middleware_stdio` through the APIs in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py); its [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) describes installation requirements, not an implicit service configuration. No additional package-global configuration contract is inferred from dependencies.
|
|
190
|
+
|
|
191
|
+
### Error Handling
|
|
192
|
+
|
|
193
|
+
The inspected `swarmauri_middleware_stdio` source does not establish a package-wide exception hierarchy. Preserve errors from its declared dependencies and validate inputs using the specific public contract in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py).
|
|
194
|
+
|
|
195
|
+
### Best Practices
|
|
196
|
+
|
|
197
|
+
Use the explicit `swarmauri_middleware_stdio` imports documented below and keep collaborator configuration with the caller. Run the package’s relevant tests after changing `StdioMiddleware`; an import or successful installation alone does not establish its runtime guarantees.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Package Boundary
|
|
202
|
+
|
|
203
|
+
### What It Owns
|
|
204
|
+
|
|
205
|
+
`swarmauri_middleware_stdio` is located in `standards` and owns middleware that logs requests and responses to standard output. Source-declared APIs include `StdioMiddleware`. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) records its direct dependency boundary.
|
|
206
|
+
|
|
207
|
+
### Public API and Import Surfaces
|
|
208
|
+
|
|
209
|
+
Import namespace: `swarmauri_middleware_stdio`.
|
|
210
|
+
|
|
211
|
+
Source-declared exports or types: `StdioMiddleware`.
|
|
212
|
+
|
|
213
|
+
Inspect [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) for exact signatures; this inventory does not designate every internal module as stable.
|
|
214
|
+
|
|
215
|
+
### Entry Points
|
|
216
|
+
|
|
217
|
+
<!-- readme-standards:begin entry-points -->
|
|
218
|
+
- `swarmauri.middlewares` → `StdioMiddleware` → `swarmauri_middleware_stdio:StdioMiddleware`
|
|
219
|
+
<!-- readme-standards:end entry-points -->
|
|
220
|
+
|
|
221
|
+
### Injected Dependencies
|
|
222
|
+
|
|
223
|
+
The direct installation dependencies of `swarmauri_middleware_stdio` are `starlette`, `swarmauri-core`, `swarmauri-base`, `swarmauri-standard`. These declarations do not imply automatic provider selection. Pass collaborators through the explicit constructors or call signatures in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py).
|
|
224
|
+
|
|
225
|
+
### Protocol Consumers
|
|
226
|
+
|
|
227
|
+
No direct package-manifest dependency on `swarmauri_middleware_stdio` was found in the audited three-repository inventory. External consumers may still use its documented imports or commands.
|
|
228
|
+
|
|
229
|
+
### Extensions
|
|
230
|
+
|
|
231
|
+
For `swarmauri_middleware_stdio`, use the source-declared public interfaces (`StdioMiddleware`) when composing or extending behavior. Its entry-point section below is authoritative for registered plugins; no additional extension loader is inferred from the package name.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Operations and Readiness
|
|
236
|
+
|
|
237
|
+
### Operational Requirements
|
|
238
|
+
|
|
239
|
+
Operate `swarmauri_middleware_stdio` according to its actual entry points and collaborators. The dependency and Python requirements in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) are prerequisites; deployment topology, credentials, and readiness remain the responsibility of the consuming application unless explicitly documented above.
|
|
240
|
+
|
|
241
|
+
### Health and Observability
|
|
242
|
+
|
|
243
|
+
This README does not establish a standalone health endpoint for `swarmauri_middleware_stdio`. Observe the concrete caller’s results, exceptions, and existing test reports. An application that embeds this package must define its own health and telemetry contract.
|
|
244
|
+
|
|
245
|
+
### Security and Resource Limits
|
|
246
|
+
|
|
247
|
+
Apply the input, credential, and resource constraints implemented in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py). The `swarmauri_middleware_stdio` README gate is a documentation check, not a security review or a substitute for the implementation’s limits and caller authorization.
|
|
248
|
+
|
|
249
|
+
### Compatibility
|
|
250
|
+
|
|
251
|
+
This source version of `swarmauri_middleware_stdio` declares Python `>=3.10,<3.15`. Consult its dependency constraints before upgrading. Source-version and registry-version badges have separate meanings; this migration makes no additional platform or interoperability certification claim.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Verification
|
|
256
|
+
|
|
257
|
+
### Tests
|
|
258
|
+
|
|
259
|
+
Run `python -m pytest tests/unit/test_readme_sources.py` from the `swarmauri_middleware_stdio` package directory for the maintained example source checks (Python compilation and non-Python file presence). Existing package tests include:
|
|
260
|
+
|
|
261
|
+
- [tests/example/test_readme_example.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/example/test_readme_example.py)
|
|
262
|
+
- [tests/i9n/test_i9n__init__.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/i9n/test_i9n__init__.py)
|
|
263
|
+
- [tests/i9n/test_starlette_integration.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/i9n/test_starlette_integration.py)
|
|
264
|
+
- [tests/unit/test_StdioMiddleware.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/unit/test_StdioMiddleware.py)
|
|
265
|
+
|
|
266
|
+
The repository README gate also checks the required heading tree, metadata, managed fragments, and referenced files.
|
|
267
|
+
|
|
268
|
+
### Certification Status
|
|
269
|
+
|
|
270
|
+
No external certification is asserted for `swarmauri_middleware_stdio` by this documentation migration. README conformance, example syntax, runtime tests, and protocol or security certification are distinct evidence scopes.
|
|
271
|
+
|
|
272
|
+
### Evidence
|
|
273
|
+
|
|
274
|
+
The [README standards CI](https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml) records mechanical documentation results for its tested commit. The [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) and example sources support the package-boundary description; external runtime behavior requires its own test evidence.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## FAQ
|
|
279
|
+
|
|
280
|
+
### Why
|
|
281
|
+
|
|
282
|
+
**Why select this package?** `swarmauri_middleware_stdio` provides middleware that logs requests and responses to standard output; use its own API boundary rather than assuming neighboring packages are bundled or configured automatically.
|
|
283
|
+
|
|
284
|
+
### How
|
|
285
|
+
|
|
286
|
+
**How do I start?** Install or synchronize the environment under Getting Started, follow the maintained example for `swarmauri_middleware_stdio`, and consult [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py) for the exact types and signatures involved.
|
|
287
|
+
|
|
288
|
+
### When
|
|
289
|
+
|
|
290
|
+
**When should I validate an upgrade?** Recheck `swarmauri_middleware_stdio` whenever its source version, declared collaborators, configuration, or caller changes. Run relevant behavioral tests in addition to the README gate before promotion.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Documentation and Related Packages
|
|
295
|
+
|
|
296
|
+
### More Documentation
|
|
297
|
+
|
|
298
|
+
The [repository contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md), [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/swarmauri_middleware_stdio/__init__.py), and [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml) provide the supporting context for `swarmauri_middleware_stdio`. The [README policy](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md) defines the common document structure.
|
|
299
|
+
|
|
300
|
+
### Related Packages
|
|
301
|
+
|
|
302
|
+
- [swarmauri_base](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/20-bases/swarmauri_base/README.md): Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
|
|
303
|
+
- [swarmauri_core](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/10-interfaces/swarmauri_core/README.md): Core interface contracts and shared types for Swarmauri composable intelligence infrastructure components.
|
|
304
|
+
- [swarmauri_standard](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/30-standard-kernel/swarmauri_standard/README.md): First-party Swarmauri standard components for agents, tools, parsers, vectors, model adapters, and composable intelligence workflows.
|
|
305
|
+
|
|
306
|
+
### Project Links
|
|
307
|
+
|
|
308
|
+
<!-- readme-standards:begin project-links -->
|
|
309
|
+
- [pypi: swarmauri_middleware_stdio](https://pypi.org/project/swarmauri_middleware_stdio/)
|
|
310
|
+
<!-- readme-standards:end project-links -->
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Contributing
|
|
315
|
+
|
|
316
|
+
### How to Contribute
|
|
317
|
+
|
|
318
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
319
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
320
|
+
that will help you get started.
|
|
321
|
+
|
|
322
|
+
### Development Setup
|
|
323
|
+
|
|
324
|
+
Work from the `pkgs/40-standards/swarmauri_middleware_stdio` checkout. Synchronize its declared development environment with uv, then run the relevant package tests and `python -m pytest tests/unit/test_readme_sources.py`. The repository’s dedicated README job installs `readme-standards==0.1.3` without resolving unrelated runtime packages.
|
|
325
|
+
|
|
326
|
+
### Notes for Maintainers
|
|
327
|
+
|
|
328
|
+
**How It Works**
|
|
329
|
+
|
|
330
|
+
`StdioMiddleware` uses Python's logging facilities under the logger name
|
|
331
|
+
`swarmauri_middleware_stdio.StdioMiddleware`. Each request produces an `INFO`
|
|
332
|
+
record before the downstream handler runs, and the matching response status is
|
|
333
|
+
logged afterwards. Configure logging (as in the example above) to route those
|
|
334
|
+
messages to stdout or another destination appropriate for your deployment.
|
|
335
|
+
|
|
336
|
+
When the middleware is active you should see output similar to:
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Request: GET /
|
|
340
|
+
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Response: 200
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## Governance
|
|
346
|
+
|
|
347
|
+
### Ownership and Decision Making
|
|
348
|
+
|
|
349
|
+
Changes to `swarmauri_middleware_stdio` follow the maintainer review process of [swarmauri/swarmauri-sdk](https://github.com/swarmauri/swarmauri-sdk) and its contribution guide. Author attribution remains in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/pyproject.toml); this README does not assign new publishing or administrative authority.
|
|
350
|
+
|
|
351
|
+
### Standards and Policies
|
|
352
|
+
|
|
353
|
+
`swarmauri_middleware_stdio` follows the versioned [package-guide-v1 outline](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md). All fixed headings, hierarchy, order, separators, and package-specific branding are checked by CI; reviewers assess the accuracy and usefulness of authored claims.
|
|
354
|
+
|
|
355
|
+
### Lifecycle and Migration
|
|
356
|
+
|
|
357
|
+
The `swarmauri_middleware_stdio` source version is `0.11.0`.
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## License and Attribution
|
|
362
|
+
|
|
363
|
+
### License
|
|
364
|
+
|
|
365
|
+
<!-- readme-standards:begin license -->
|
|
366
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/LICENSE).
|
|
367
|
+
<!-- readme-standards:end license -->
|
|
368
|
+
|
|
369
|
+
### Notices
|
|
370
|
+
|
|
371
|
+
<!-- readme-standards:begin notices -->
|
|
372
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/NOTICE) for attribution.
|
|
373
|
+
<!-- readme-standards:end notices -->
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_middleware_stdio"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.11.0"
|
|
4
4
|
description = "Middleware that logs requests and responses to standard output"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
repository = "http://github.com/swarmauri/swarmauri-sdk/pkgs/pkgs/swarmauri_middleware_stdio/"
|
|
8
|
-
requires-python = ">=3.10,<3.
|
|
8
|
+
requires-python = ">=3.10,<3.15"
|
|
9
9
|
classifiers = [
|
|
10
|
-
"License :: OSI Approved :: Apache Software License",
|
|
11
10
|
"Natural Language :: English",
|
|
12
|
-
"Programming Language :: Python :: 3.10",
|
|
13
|
-
"Programming Language :: Python :: 3.11",
|
|
14
|
-
"Programming Language :: Python :: 3.12",
|
|
15
|
-
"Programming Language :: Python :: 3.13",
|
|
16
11
|
"Development Status :: 3 - Alpha",
|
|
17
12
|
"Programming Language :: Python",
|
|
18
13
|
"Programming Language :: Python :: 3",
|
|
19
14
|
"Programming Language :: Python :: 3 :: Only",
|
|
15
|
+
"Programming Language :: Python :: 3.10",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Programming Language :: Python :: 3.14",
|
|
20
20
|
]
|
|
21
21
|
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
22
22
|
dependencies = [
|
|
23
|
-
"
|
|
23
|
+
"starlette",
|
|
24
24
|
"swarmauri_core",
|
|
25
25
|
"swarmauri_base",
|
|
26
26
|
"swarmauri_standard",
|
|
@@ -32,6 +32,7 @@ keywords = [
|
|
|
32
32
|
'middleware',
|
|
33
33
|
'stdio',
|
|
34
34
|
]
|
|
35
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
35
36
|
|
|
36
37
|
[tool.uv.sources]
|
|
37
38
|
swarmauri_core = { workspace = true }
|
|
@@ -59,6 +60,54 @@ log_cli_format = "%(asctime)s [%(levelname)s] %(message)s"
|
|
|
59
60
|
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
|
60
61
|
asyncio_default_fixture_loop_scope = "function"
|
|
61
62
|
|
|
63
|
+
[tool.readme_standards]
|
|
64
|
+
policy = "package-guide-v1"
|
|
65
|
+
readme = "README.md"
|
|
66
|
+
brand = "swarmauri"
|
|
67
|
+
brand_catalog = "../../../tools/readme/brands.toml"
|
|
68
|
+
repository = "https://github.com/swarmauri/swarmauri-sdk"
|
|
69
|
+
ref = "master"
|
|
70
|
+
package_path = "pkgs/40-standards/swarmauri_middleware_stdio"
|
|
71
|
+
layer = "standards"
|
|
72
|
+
lifecycle = "active"
|
|
73
|
+
license_file = "LICENSE"
|
|
74
|
+
notice_file = "NOTICE"
|
|
75
|
+
|
|
76
|
+
[tool.readme_standards.distributions.pypi]
|
|
77
|
+
name = "swarmauri_middleware_stdio"
|
|
78
|
+
published = true
|
|
79
|
+
|
|
80
|
+
[tool.readme_standards.examples.quick_start]
|
|
81
|
+
source = "docs/readme/quick_start.py"
|
|
82
|
+
test = "tests/unit/test_readme_sources.py"
|
|
83
|
+
language = "python"
|
|
84
|
+
expected_exit_code = 0
|
|
85
|
+
|
|
86
|
+
[tool.readme_standards.examples.usage]
|
|
87
|
+
source = "docs/readme/usage.py"
|
|
88
|
+
test = "tests/unit/test_readme_sources.py"
|
|
89
|
+
language = "python"
|
|
90
|
+
expected_exit_code = 0
|
|
91
|
+
|
|
92
|
+
[tool.readme_standards.statuses.readme]
|
|
93
|
+
label = "CI gate"
|
|
94
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
95
|
+
|
|
96
|
+
[tool.readme_standards.statuses.tests]
|
|
97
|
+
label = "example source"
|
|
98
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/tests/unit/test_readme_sources.py"
|
|
99
|
+
|
|
100
|
+
[tool.readme_standards.statuses.certification]
|
|
101
|
+
label = "not certified"
|
|
102
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_middleware_stdio/README.md#certification-status"
|
|
103
|
+
|
|
104
|
+
[tool.readme_standards.statuses.governance]
|
|
105
|
+
label = "repository policy"
|
|
106
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"
|
|
107
|
+
|
|
108
|
+
[tool.readme_standards.statuses.evidence]
|
|
109
|
+
label = "source and CI"
|
|
110
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
62
111
|
[build-system]
|
|
63
112
|
requires = ["poetry-core>=1.0.0"]
|
|
64
113
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -70,11 +119,12 @@ dev = [
|
|
|
70
119
|
"pytest-xdist>=3.6.1",
|
|
71
120
|
"pytest-json-report>=1.5.0",
|
|
72
121
|
"python-dotenv",
|
|
73
|
-
"
|
|
122
|
+
"httpx>=0.27",
|
|
74
123
|
"flake8>=7.0",
|
|
75
124
|
"pytest-timeout>=2.3.1",
|
|
76
125
|
"ruff>=0.9.9",
|
|
77
126
|
"pytest-benchmark>=4.0.0",
|
|
127
|
+
"readme-standards==0.1.3; python_version >= \"3.11\"",
|
|
78
128
|
]
|
|
79
129
|
|
|
80
130
|
[project.entry-points.'swarmauri.middlewares']
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: swarmauri_middleware_stdio
|
|
3
|
-
Version: 0.8.0.dev47
|
|
4
|
-
Summary: Middleware that logs requests and responses to standard output
|
|
5
|
-
License-Expression: Apache-2.0
|
|
6
|
-
License-File: LICENSE
|
|
7
|
-
Keywords: swarmauri,sdk,standards,middleware,stdio
|
|
8
|
-
Author: Jacob Stewart
|
|
9
|
-
Author-email: jacob@swarmauri.com
|
|
10
|
-
Requires-Python: >=3.10,<3.13
|
|
11
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
-
Classifier: Natural Language :: English
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
Classifier: Development Status :: 3 - Alpha
|
|
18
|
-
Classifier: Programming Language :: Python
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
-
Requires-Dist: fastapi
|
|
22
|
-
Requires-Dist: swarmauri_base
|
|
23
|
-
Requires-Dist: swarmauri_core
|
|
24
|
-
Requires-Dist: swarmauri_standard
|
|
25
|
-
Description-Content-Type: text/markdown
|
|
26
|
-
|
|
27
|
-

|
|
28
|
-
|
|
29
|
-
<p align="center">
|
|
30
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
31
|
-
<img src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio" alt="PyPI - Downloads"/>
|
|
32
|
-
</a>
|
|
33
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio/">
|
|
34
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio.svg"/>
|
|
35
|
-
</a>
|
|
36
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
37
|
-
<img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_stdio" alt="PyPI - Python Version"/>
|
|
38
|
-
</a>
|
|
39
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
40
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_middleware_stdio" alt="PyPI - License"/>
|
|
41
|
-
</a>
|
|
42
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
43
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?label=swarmauri_middleware_stdio&color=green" alt="PyPI - swarmauri_middleware_stdio"/>
|
|
44
|
-
</a>
|
|
45
|
-
</p>
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
# Swarmauri Middleware Stdio
|
|
50
|
-
|
|
51
|
-
`swarmauri_middleware_stdio` provides a lightweight FastAPI middleware that
|
|
52
|
-
logs incoming requests and outgoing responses to standard output using
|
|
53
|
-
Python's logging module. It is handy for development and debugging when a
|
|
54
|
-
full logging stack is unnecessary.
|
|
55
|
-
|
|
56
|
-
## Installation
|
|
57
|
-
|
|
58
|
-
Pick the tool that matches your workflow:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
# pip
|
|
62
|
-
pip install swarmauri_middleware_stdio
|
|
63
|
-
|
|
64
|
-
# Poetry
|
|
65
|
-
poetry add swarmauri_middleware_stdio
|
|
66
|
-
|
|
67
|
-
# uv
|
|
68
|
-
pip install uv # install uv if it's not already available
|
|
69
|
-
uv add swarmauri_middleware_stdio
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Usage
|
|
73
|
-
|
|
74
|
-
```python
|
|
75
|
-
import logging
|
|
76
|
-
import sys
|
|
77
|
-
|
|
78
|
-
from fastapi import FastAPI, Request
|
|
79
|
-
from swarmauri_middleware_stdio import StdioMiddleware
|
|
80
|
-
|
|
81
|
-
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
|
82
|
-
|
|
83
|
-
app = FastAPI()
|
|
84
|
-
stdio = StdioMiddleware()
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
@app.middleware("http")
|
|
88
|
-
async def log_to_stdout(request: Request, call_next):
|
|
89
|
-
return await stdio.dispatch(request, call_next)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@app.get("/")
|
|
93
|
-
async def hello() -> dict[str, str]:
|
|
94
|
-
return {"message": "hello"}
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## How It Works
|
|
98
|
-
|
|
99
|
-
`StdioMiddleware` uses Python's logging facilities under the logger name
|
|
100
|
-
`swarmauri_middleware_stdio.StdioMiddleware`. Each request produces an `INFO`
|
|
101
|
-
record before the downstream handler runs, and the matching response status is
|
|
102
|
-
logged afterwards. Configure logging (as in the example above) to route those
|
|
103
|
-
messages to stdout or another destination appropriate for your deployment.
|
|
104
|
-
|
|
105
|
-
When the middleware is active you should see output similar to:
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Request: GET /
|
|
109
|
-
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Response: 200
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Want to help?
|
|
113
|
-
|
|
114
|
-
If you want to contribute to swarmauri-sdk, read up on our
|
|
115
|
-
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
116
|
-
that will help you get started.
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
5
|
-
<img src="https://img.shields.io/pypi/dm/swarmauri_middleware_stdio" alt="PyPI - Downloads"/>
|
|
6
|
-
</a>
|
|
7
|
-
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio/">
|
|
8
|
-
<img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_middleware_stdio.svg"/>
|
|
9
|
-
</a>
|
|
10
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
11
|
-
<img src="https://img.shields.io/pypi/pyversions/swarmauri_middleware_stdio" alt="PyPI - Python Version"/>
|
|
12
|
-
</a>
|
|
13
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
14
|
-
<img src="https://img.shields.io/pypi/l/swarmauri_middleware_stdio" alt="PyPI - License"/>
|
|
15
|
-
</a>
|
|
16
|
-
<a href="https://pypi.org/project/swarmauri_middleware_stdio/">
|
|
17
|
-
<img src="https://img.shields.io/pypi/v/swarmauri_middleware_stdio?label=swarmauri_middleware_stdio&color=green" alt="PyPI - swarmauri_middleware_stdio"/>
|
|
18
|
-
</a>
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# Swarmauri Middleware Stdio
|
|
24
|
-
|
|
25
|
-
`swarmauri_middleware_stdio` provides a lightweight FastAPI middleware that
|
|
26
|
-
logs incoming requests and outgoing responses to standard output using
|
|
27
|
-
Python's logging module. It is handy for development and debugging when a
|
|
28
|
-
full logging stack is unnecessary.
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
32
|
-
Pick the tool that matches your workflow:
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# pip
|
|
36
|
-
pip install swarmauri_middleware_stdio
|
|
37
|
-
|
|
38
|
-
# Poetry
|
|
39
|
-
poetry add swarmauri_middleware_stdio
|
|
40
|
-
|
|
41
|
-
# uv
|
|
42
|
-
pip install uv # install uv if it's not already available
|
|
43
|
-
uv add swarmauri_middleware_stdio
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Usage
|
|
47
|
-
|
|
48
|
-
```python
|
|
49
|
-
import logging
|
|
50
|
-
import sys
|
|
51
|
-
|
|
52
|
-
from fastapi import FastAPI, Request
|
|
53
|
-
from swarmauri_middleware_stdio import StdioMiddleware
|
|
54
|
-
|
|
55
|
-
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
|
|
56
|
-
|
|
57
|
-
app = FastAPI()
|
|
58
|
-
stdio = StdioMiddleware()
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
@app.middleware("http")
|
|
62
|
-
async def log_to_stdout(request: Request, call_next):
|
|
63
|
-
return await stdio.dispatch(request, call_next)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
@app.get("/")
|
|
67
|
-
async def hello() -> dict[str, str]:
|
|
68
|
-
return {"message": "hello"}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## How It Works
|
|
72
|
-
|
|
73
|
-
`StdioMiddleware` uses Python's logging facilities under the logger name
|
|
74
|
-
`swarmauri_middleware_stdio.StdioMiddleware`. Each request produces an `INFO`
|
|
75
|
-
record before the downstream handler runs, and the matching response status is
|
|
76
|
-
logged afterwards. Configure logging (as in the example above) to route those
|
|
77
|
-
messages to stdout or another destination appropriate for your deployment.
|
|
78
|
-
|
|
79
|
-
When the middleware is active you should see output similar to:
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Request: GET /
|
|
83
|
-
INFO swarmauri_middleware_stdio.StdioMiddleware STDIO Response: 200
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Want to help?
|
|
87
|
-
|
|
88
|
-
If you want to contribute to swarmauri-sdk, read up on our
|
|
89
|
-
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
90
|
-
that will help you get started.
|
|
File without changes
|
|
File without changes
|