rf-agent 0.3.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.
- rf_agent-0.3.0/.gitignore +216 -0
- rf_agent-0.3.0/PKG-INFO +50 -0
- rf_agent-0.3.0/README.md +23 -0
- rf_agent-0.3.0/pyproject.toml +65 -0
- rf_agent-0.3.0/src/agent/__init__.py +1 -0
- rf_agent-0.3.0/src/agent/__main__.py +3 -0
- rf_agent-0.3.0/src/agent/app/__init__.py +43 -0
- rf_agent-0.3.0/src/agent/app/factories.py +126 -0
- rf_agent-0.3.0/src/agent/app/runner.py +295 -0
- rf_agent-0.3.0/src/agent/cli.py +499 -0
- rf_agent-0.3.0/src/agent/config/__init__.py +102 -0
- rf_agent-0.3.0/src/agent/config/errors.py +10 -0
- rf_agent-0.3.0/src/agent/config/loader.py +384 -0
- rf_agent-0.3.0/src/agent/domain/__init__.py +200 -0
- rf_agent-0.3.0/src/agent/processing/__init__.py +38 -0
- rf_agent-0.3.0/src/agent/processing/fft_pipeline.py +94 -0
- rf_agent-0.3.0/src/agent/processing/parse_iq.py +134 -0
- rf_agent-0.3.0/src/agent/processing/processor.py +136 -0
- rf_agent-0.3.0/src/agent/protocol/__init__.py +428 -0
- rf_agent-0.3.0/src/agent/session/__init__.py +433 -0
- rf_agent-0.3.0/src/agent/session/bandwidth.py +115 -0
- rf_agent-0.3.0/src/agent/source/__init__.py +0 -0
- rf_agent-0.3.0/src/agent/source/base.py +38 -0
- rf_agent-0.3.0/src/agent/source/sigmf.py +170 -0
- rf_agent-0.3.0/src/agent/source/simulator.py +74 -0
- rf_agent-0.3.0/src/agent/source/wav.py +245 -0
- rf_agent-0.3.0/src/agent/telemetry/__init__.py +20 -0
- rf_agent-0.3.0/src/agent/telemetry/loop.py +146 -0
- rf_agent-0.3.0/src/agent/telemetry/metrics.py +136 -0
- rf_agent-0.3.0/src/agent/telemetry/stage_timing.py +95 -0
- rf_agent-0.3.0/src/agent/transport/__init__.py +63 -0
- rf_agent-0.3.0/src/agent/transport/transport.py +149 -0
- rf_agent-0.3.0/src/agent/utils/__init__.py +0 -0
- rf_agent-0.3.0/src/agent/utils/power.py +32 -0
- rf_agent-0.3.0/src/agent.svg +423 -0
- rf_agent-0.3.0/src/tests/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/conftest.py +109 -0
- rf_agent-0.3.0/src/tests/fixtures/LTE_uplink_847MHz_2022-01-30_30720ksps_fix/LTE_uplink_847MHz_2022-01-30_30720ksps.sigmf-data +0 -0
- rf_agent-0.3.0/src/tests/fixtures/LTE_uplink_847MHz_2022-01-30_30720ksps_fix/LTE_uplink_847MHz_2022-01-30_30720ksps.sigmf-meta +21 -0
- rf_agent-0.3.0/src/tests/fixtures/MWlamp_5829250000Hz_1250ksps_fix/5829250000Hz_MWlamp_1250k_small.wav +0 -0
- rf_agent-0.3.0/src/tests/fixtures/UMTS_O2_5_downlink_small.wav +0 -0
- rf_agent-0.3.0/src/tests/fixtures/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/fixtures/audio_16035000Hz_96ksps_fix/audio_16035000Hz_96k_small.wav +0 -0
- rf_agent-0.3.0/src/tests/integration/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/integration/conftest.py +14 -0
- rf_agent-0.3.0/src/tests/integration/fixtures/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/integration/fixtures/agent_builders.py +87 -0
- rf_agent-0.3.0/src/tests/integration/fixtures/fake_server.py +130 -0
- rf_agent-0.3.0/src/tests/integration/fixtures/message_helpers.py +80 -0
- rf_agent-0.3.0/src/tests/integration/session/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/integration/session/test_handshake_flow.py +165 -0
- rf_agent-0.3.0/src/tests/integration/session/test_runtime_recovery.py +305 -0
- rf_agent-0.3.0/src/tests/integration/session/test_streaming_flow.py +312 -0
- rf_agent-0.3.0/src/tests/integration/test_fake_server.py +371 -0
- rf_agent-0.3.0/src/tests/unit/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/app/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/app/test_factories.py +44 -0
- rf_agent-0.3.0/src/tests/unit/app/test_runner.py +682 -0
- rf_agent-0.3.0/src/tests/unit/cli/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/cli/test_cli.py +115 -0
- rf_agent-0.3.0/src/tests/unit/config/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/config/test_agent_config.py +284 -0
- rf_agent-0.3.0/src/tests/unit/config/test_config_loader.py +561 -0
- rf_agent-0.3.0/src/tests/unit/domain/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/processing/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/processing/test_fft_pipeline.py +244 -0
- rf_agent-0.3.0/src/tests/unit/processing/test_iq_parser.py +525 -0
- rf_agent-0.3.0/src/tests/unit/processing/test_iq_processor.py +619 -0
- rf_agent-0.3.0/src/tests/unit/processing/test_processor.py +341 -0
- rf_agent-0.3.0/src/tests/unit/protocol/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/protocol/test_codec.py +634 -0
- rf_agent-0.3.0/src/tests/unit/session/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/session/test_bandwidth.py +152 -0
- rf_agent-0.3.0/src/tests/unit/session/test_session_manager.py +1151 -0
- rf_agent-0.3.0/src/tests/unit/source/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/source/test_sigmf_source.py +172 -0
- rf_agent-0.3.0/src/tests/unit/source/test_wav_source.py +599 -0
- rf_agent-0.3.0/src/tests/unit/telemetry/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/telemetry/test_metrics_collector.py +151 -0
- rf_agent-0.3.0/src/tests/unit/telemetry/test_stage_timing.py +100 -0
- rf_agent-0.3.0/src/tests/unit/telemetry/test_telemetry.py +380 -0
- rf_agent-0.3.0/src/tests/unit/transport/__init__.py +0 -0
- rf_agent-0.3.0/src/tests/unit/transport/test_transport.py +357 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
|
|
204
|
+
# Ruff stuff:
|
|
205
|
+
.ruff_cache/
|
|
206
|
+
|
|
207
|
+
# PyPI configuration file
|
|
208
|
+
.pypirc
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# Streamlit
|
|
216
|
+
.streamlit/secrets.toml
|
rf_agent-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rf-agent
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: SDR agent for RF spectrum streaming
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: fft,rf,sdr,spectrum,websocket
|
|
7
|
+
Classifier: Environment :: Console
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Requires-Dist: numpy>=1.24
|
|
16
|
+
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
17
|
+
Requires-Dist: websockets>=12.0
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
21
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
22
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: ruff>=0.3; extra == 'dev'
|
|
24
|
+
Provides-Extra: sdr
|
|
25
|
+
Requires-Dist: pyrtlsdr>=0.3.0; extra == 'sdr'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# rf-agent
|
|
29
|
+
|
|
30
|
+
SDR agent for live RF spectrum streaming. Reads IQ samples from an SDR device (or a file/simulator), runs FFT, and streams spectrum frames over WebSocket to an rf-platform server.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip install rf-agent
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
With RTL-SDR hardware support:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
pip install "rf-agent[sdr]"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
rf-agent connect --server ws://your-server/ws/agent --token <token>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
See `rf-agent connect --help` for all options.
|
rf_agent-0.3.0/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# rf-agent
|
|
2
|
+
|
|
3
|
+
SDR agent for live RF spectrum streaming. Reads IQ samples from an SDR device (or a file/simulator), runs FFT, and streams spectrum frames over WebSocket to an rf-platform server.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pip install rf-agent
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
With RTL-SDR hardware support:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
pip install "rf-agent[sdr]"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
rf-agent connect --server ws://your-server/ws/agent --token <token>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
See `rf-agent connect --help` for all options.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "rf-agent"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
description = "SDR agent for RF spectrum streaming"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
keywords = ["sdr", "rf", "spectrum", "fft", "websocket"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.10",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Topic :: Scientific/Engineering",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"numpy>=1.24",
|
|
24
|
+
"websockets>=12.0",
|
|
25
|
+
"tomli>=2.0; python_version < '3.11'",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
rf-agent = "agent.cli:main"
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
sdr = [
|
|
33
|
+
"pyrtlsdr>=0.3.0",
|
|
34
|
+
]
|
|
35
|
+
dev = [
|
|
36
|
+
"pytest>=8.0",
|
|
37
|
+
"pytest-asyncio>=0.23",
|
|
38
|
+
"pytest-cov>=5.0",
|
|
39
|
+
"mypy>=1.8",
|
|
40
|
+
"ruff>=0.3",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.targets.wheel]
|
|
44
|
+
packages = ["src/agent"]
|
|
45
|
+
exclude = ["src/tests"]
|
|
46
|
+
|
|
47
|
+
[tool.pytest.ini_options]
|
|
48
|
+
testpaths = ["src/tests"]
|
|
49
|
+
asyncio_mode = "auto"
|
|
50
|
+
markers = [
|
|
51
|
+
"integration: marks integration tests (deselect with '-m \"not integration\"')",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[tool.mypy]
|
|
55
|
+
python_version = "3.10"
|
|
56
|
+
strict = true
|
|
57
|
+
packages = ["agent"]
|
|
58
|
+
mypy_path = "src"
|
|
59
|
+
|
|
60
|
+
[tool.ruff]
|
|
61
|
+
target-version = "py310"
|
|
62
|
+
src = ["src", "src/tests"]
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint]
|
|
65
|
+
select = ["E", "F", "UP"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""RF spectrum streaming agent."""
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Agent orchestrator — composition and lifecycle.
|
|
2
|
+
|
|
3
|
+
This is the top-level entry point. It wires components together,
|
|
4
|
+
starts concurrent tasks, and handles shutdown.
|
|
5
|
+
|
|
6
|
+
It does no real work itself — only composes.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Protocol
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AgentRuntime(Protocol):
|
|
15
|
+
"""Top-level agent lifecycle."""
|
|
16
|
+
|
|
17
|
+
async def run(self) -> None:
|
|
18
|
+
"""Start the agent. Runs until shutdown signal.
|
|
19
|
+
|
|
20
|
+
Wiring:
|
|
21
|
+
source = create_source(config)
|
|
22
|
+
processor = create_processor(config)
|
|
23
|
+
transport = create_transport(config)
|
|
24
|
+
session = create_session(transport, codec, config)
|
|
25
|
+
telemetry = create_telemetry(session, config)
|
|
26
|
+
|
|
27
|
+
iq_queue = asyncio.Queue(maxsize=config.queues.iq_queue_size)
|
|
28
|
+
frame_queue = asyncio.Queue(maxsize=config.queues.frame_queue_size)
|
|
29
|
+
|
|
30
|
+
run concurrently:
|
|
31
|
+
source.run(output=iq_queue)
|
|
32
|
+
processor.run(input=iq_queue, output=frame_queue)
|
|
33
|
+
session.run(frame_queue=frame_queue)
|
|
34
|
+
telemetry.run()
|
|
35
|
+
|
|
36
|
+
Shutdown:
|
|
37
|
+
On SIGINT/SIGTERM → cancel all tasks → close transport → stop source.
|
|
38
|
+
"""
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
async def shutdown(self) -> None:
|
|
42
|
+
"""Graceful shutdown. Cancel tasks, close connections, release hardware."""
|
|
43
|
+
...
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""Standard production component factories.
|
|
2
|
+
|
|
3
|
+
Wires WebSocketTransport, JsonBase64Codec, IQProcessor, Session, and
|
|
4
|
+
TelemetryLoop into a RunnerFactories bundle ready for AgentRunner.
|
|
5
|
+
|
|
6
|
+
A new WebSocketTransport is created per reconnect attempt; codec is shared.
|
|
7
|
+
Processor, session, and telemetry are constructed fresh per-attempt by the runner.
|
|
8
|
+
|
|
9
|
+
PipelineTiming and MetricsCollector are shared across attempts so cumulative
|
|
10
|
+
stats survive reconnects. The runner's own MetricsCollector arg in
|
|
11
|
+
make_telemetry is intentionally ignored in favour of the shared one.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
import datetime
|
|
18
|
+
from collections.abc import Callable
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from agent.app.runner import RunnerFactories
|
|
22
|
+
from agent.config import AgentConfig
|
|
23
|
+
from agent.domain import AgentMetrics
|
|
24
|
+
from agent.processing import Processor
|
|
25
|
+
from agent.processing.processor import IQProcessor
|
|
26
|
+
from agent.protocol import JsonBase64Codec, ProtocolCodec
|
|
27
|
+
from agent.session import Session
|
|
28
|
+
from agent.source.base import IQSource
|
|
29
|
+
from agent.telemetry.loop import TelemetryLoop
|
|
30
|
+
from agent.telemetry.metrics import MetricsCollector
|
|
31
|
+
from agent.telemetry.stage_timing import PipelineTiming
|
|
32
|
+
from agent.transport import Transport
|
|
33
|
+
from agent.transport.transport import WebSocketTransport
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _TransportSender:
|
|
37
|
+
"""Adapts (WebSocketTransport, JsonBase64Codec)
|
|
38
|
+
to TelemetryLoop's TelemetrySender."""
|
|
39
|
+
|
|
40
|
+
def __init__(self, transport: Transport, codec: ProtocolCodec) -> None:
|
|
41
|
+
self._transport = transport
|
|
42
|
+
self._codec = codec
|
|
43
|
+
|
|
44
|
+
async def send_heartbeat(
|
|
45
|
+
self, node_id: str, session_id: str, timestamp_utc: str
|
|
46
|
+
) -> None:
|
|
47
|
+
await self._transport.send(
|
|
48
|
+
self._codec.encode_heartbeat(node_id, session_id, timestamp_utc)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
async def send_agent_status(
|
|
52
|
+
self,
|
|
53
|
+
node_id: str,
|
|
54
|
+
session_id: str,
|
|
55
|
+
timestamp_utc: str,
|
|
56
|
+
metrics: AgentMetrics,
|
|
57
|
+
) -> None:
|
|
58
|
+
await self._transport.send(
|
|
59
|
+
self._codec.encode_agent_status(node_id, session_id, timestamp_utc, metrics)
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def make_standard_factories(
|
|
64
|
+
source_factory: Callable[[AgentConfig], IQSource],
|
|
65
|
+
) -> RunnerFactories:
|
|
66
|
+
"""Return a RunnerFactories bundle wired to standard production components."""
|
|
67
|
+
pipeline_timing = PipelineTiming()
|
|
68
|
+
shared_metrics = MetricsCollector(timings=pipeline_timing)
|
|
69
|
+
|
|
70
|
+
codec = JsonBase64Codec()
|
|
71
|
+
|
|
72
|
+
def make_transport(cfg: AgentConfig) -> Transport:
|
|
73
|
+
return WebSocketTransport()
|
|
74
|
+
|
|
75
|
+
def make_codec(cfg: AgentConfig) -> ProtocolCodec:
|
|
76
|
+
return codec
|
|
77
|
+
|
|
78
|
+
def make_processor(cfg: AgentConfig) -> Processor:
|
|
79
|
+
return IQProcessor(
|
|
80
|
+
descriptor=cfg.iq,
|
|
81
|
+
rf_config=cfg.rf,
|
|
82
|
+
timings=pipeline_timing,
|
|
83
|
+
metrics=shared_metrics,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
def make_session(
|
|
87
|
+
cfg: AgentConfig,
|
|
88
|
+
t: Transport,
|
|
89
|
+
c: ProtocolCodec,
|
|
90
|
+
on_connected: Callable[[], None] | None = None,
|
|
91
|
+
) -> Session:
|
|
92
|
+
return Session(
|
|
93
|
+
config=cfg,
|
|
94
|
+
transport=t,
|
|
95
|
+
codec=c,
|
|
96
|
+
timings=pipeline_timing,
|
|
97
|
+
metrics=shared_metrics,
|
|
98
|
+
on_connected=on_connected,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def make_telemetry(
|
|
102
|
+
cfg: AgentConfig,
|
|
103
|
+
session: Any,
|
|
104
|
+
_metrics: MetricsCollector,
|
|
105
|
+
t: Transport,
|
|
106
|
+
c: ProtocolCodec,
|
|
107
|
+
) -> TelemetryLoop:
|
|
108
|
+
return TelemetryLoop(
|
|
109
|
+
node_id=cfg.identity.node_id,
|
|
110
|
+
session=session,
|
|
111
|
+
sender=_TransportSender(t, c),
|
|
112
|
+
metrics=shared_metrics,
|
|
113
|
+
heartbeat_interval_sec=cfg.telemetry.heartbeat_interval_s,
|
|
114
|
+
status_interval_sec=cfg.telemetry.status_interval_s,
|
|
115
|
+
clock=lambda: datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
|
116
|
+
sleep=asyncio.sleep,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
return RunnerFactories(
|
|
120
|
+
make_source=source_factory,
|
|
121
|
+
make_processor=make_processor,
|
|
122
|
+
make_transport=make_transport,
|
|
123
|
+
make_codec=make_codec,
|
|
124
|
+
make_session=make_session,
|
|
125
|
+
make_telemetry=make_telemetry,
|
|
126
|
+
)
|