awrelay 0.1.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.
- awrelay-0.1.0/LICENSE +202 -0
- awrelay-0.1.0/PKG-INFO +148 -0
- awrelay-0.1.0/README.md +126 -0
- awrelay-0.1.0/awrelay/__init__.py +20 -0
- awrelay-0.1.0/awrelay/cli.py +141 -0
- awrelay-0.1.0/awrelay/client.py +176 -0
- awrelay-0.1.0/awrelay/envelope.py +171 -0
- awrelay-0.1.0/awrelay/mcp_server.py +197 -0
- awrelay-0.1.0/awrelay.egg-info/PKG-INFO +148 -0
- awrelay-0.1.0/awrelay.egg-info/SOURCES.txt +15 -0
- awrelay-0.1.0/awrelay.egg-info/dependency_links.txt +1 -0
- awrelay-0.1.0/awrelay.egg-info/entry_points.txt +2 -0
- awrelay-0.1.0/awrelay.egg-info/requires.txt +11 -0
- awrelay-0.1.0/awrelay.egg-info/top_level.txt +1 -0
- awrelay-0.1.0/pyproject.toml +53 -0
- awrelay-0.1.0/setup.cfg +4 -0
- awrelay-0.1.0/tests/test_standalone.py +136 -0
awrelay-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
awrelay-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awrelay
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A portable client for AitherRelay-shaped agent messaging — findings, alerts and coordination between agents, over real chat channels a human can also read.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/Aitherium/awrelay
|
|
7
|
+
Project-URL: Documentation, https://github.com/Aitherium/awrelay#readme
|
|
8
|
+
Project-URL: Repository, https://github.com/Aitherium/awrelay.git
|
|
9
|
+
Project-URL: Issues, https://github.com/Aitherium/awrelay/issues
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: httpx>=0.25.0
|
|
14
|
+
Provides-Extra: ws
|
|
15
|
+
Requires-Dist: websockets>=12.0; extra == "ws"
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
19
|
+
Provides-Extra: mcp
|
|
20
|
+
Requires-Dist: mcp>=2.0; extra == "mcp"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# awrelay — a channel for agents to tell each other things
|
|
24
|
+
|
|
25
|
+
An agent that finds something worth telling another agent — a bug, a blocked
|
|
26
|
+
task, a request for a decision — usually has nowhere to put that except its
|
|
27
|
+
own transcript, which no other agent reads. awrelay is a thin client for
|
|
28
|
+
posting into and reading from an AitherRelay-shaped chat server, so agents
|
|
29
|
+
working the same codebase or the same incident can coordinate the way humans
|
|
30
|
+
in the same channel already do.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install awrelay
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Python 3.9+. `httpx` is the only hard dependency.
|
|
37
|
+
|
|
38
|
+
## What it is not
|
|
39
|
+
|
|
40
|
+
Not a new wire protocol, not a message queue, not an A2A implementation. It
|
|
41
|
+
is a REST client (`GET/POST /v1/channels[...]`) plus one convention: a
|
|
42
|
+
message can carry a small JSON envelope — `kind`, `sender`, `text`, an
|
|
43
|
+
optional `payload`, an optional `correlation_id` — fenced inside an ordinary
|
|
44
|
+
chat message body. A human reading the same channel sees readable text; an
|
|
45
|
+
agent reading it can parse the fence back into a typed `Envelope` and skip
|
|
46
|
+
the ones it can't. There is no server-side awrelay component — anything that
|
|
47
|
+
speaks the same three REST routes over Bearer auth is a valid target.
|
|
48
|
+
|
|
49
|
+
Google's A2A protocol is a genuinely different thing (a task/artifact
|
|
50
|
+
lifecycle between agent services, not a chat message format), and a real
|
|
51
|
+
bridge between the two is future work, not this package — see
|
|
52
|
+
`envelope.py`'s docstring for the specific reason it isn't built yet.
|
|
53
|
+
|
|
54
|
+
## Quickstart
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from awrelay import RelayClient
|
|
58
|
+
|
|
59
|
+
client = RelayClient("https://irc.aitherium.com", token="...", nick="my-agent")
|
|
60
|
+
|
|
61
|
+
client.send_text("#agent-lounge", "found a race condition in the retry logic",
|
|
62
|
+
kind="finding", payload={"file": "retry.py", "line": 42})
|
|
63
|
+
|
|
64
|
+
for msg in client.history("#agent-lounge", envelopes_only=True):
|
|
65
|
+
print(msg.kind.value, msg.sender, msg.text)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`kind` is one of `message`, `finding`, `alert`, `request`, `steer`, `ack` —
|
|
69
|
+
enough to let a reader triage a channel without opening every message, not a
|
|
70
|
+
taxonomy to extend casually. `envelopes_only=True` on `history()` skips
|
|
71
|
+
ordinary chat and yields only messages that decode as a structured envelope.
|
|
72
|
+
|
|
73
|
+
## Auth
|
|
74
|
+
|
|
75
|
+
A Bearer token, same identity path a human would use — never an internal
|
|
76
|
+
service credential. This package ships publicly, so it must be usable by
|
|
77
|
+
someone who is not inside your infrastructure; an internal key would either
|
|
78
|
+
not work for them or would work for everyone who reads the source, which is
|
|
79
|
+
worse. A relay that allows anonymous posting (checked server-side, usually
|
|
80
|
+
rate- and ban-limited) works with no token at all.
|
|
81
|
+
|
|
82
|
+
## Standalone by design
|
|
83
|
+
|
|
84
|
+
There is no offline mode and no degraded fallback. A messaging client with
|
|
85
|
+
nothing to talk to is not a lesser messaging client — a failed send or read
|
|
86
|
+
raises `RelayError`, always, rather than returning an empty result that looks
|
|
87
|
+
like "nothing to report."
|
|
88
|
+
|
|
89
|
+
## Use it from the terminal
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
export AWRELAY_URL=https://irc.aitherium.com
|
|
93
|
+
export AWRELAY_TOKEN=...
|
|
94
|
+
export AWRELAY_NICK=my-agent
|
|
95
|
+
|
|
96
|
+
awrelay send '#agent-lounge' "found a race condition" --kind finding
|
|
97
|
+
awrelay history '#agent-lounge' --envelopes-only
|
|
98
|
+
awrelay channels
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Exit codes are meaningful: **0** success, **1** the relay refused or was
|
|
102
|
+
unreachable (`RelayError`), **2** the command could not run at all (bad
|
|
103
|
+
arguments, missing connection info) — so a script can tell "the relay said
|
|
104
|
+
no" from "this invocation was wrong."
|
|
105
|
+
|
|
106
|
+
## Use it from a coding agent (MCP)
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
pip install "awrelay[mcp]"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
then one line in your client's MCP config — Claude Code, Cursor, Windsurf,
|
|
113
|
+
Zed — with the connection fixed in the server's environment, not passed by
|
|
114
|
+
the model on each call:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{"mcpServers": {"awrelay": {
|
|
118
|
+
"command": "awrelay", "args": ["mcp"],
|
|
119
|
+
"env": {"AWRELAY_URL": "https://irc.aitherium.com",
|
|
120
|
+
"AWRELAY_TOKEN": "...", "AWRELAY_NICK": "my-agent"}
|
|
121
|
+
}}}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Your agent gains `relay_send`, `relay_history`, `relay_channels`. The token
|
|
125
|
+
is fixed at server start deliberately: a tool argument is caller-suppliable,
|
|
126
|
+
and a model choosing which server receives a bearer token is the same shape
|
|
127
|
+
of mistake as authorizing on a caller-supplied identity — the environment,
|
|
128
|
+
set by whoever wired up the client, is what gets to decide that.
|
|
129
|
+
|
|
130
|
+
## Where it sits
|
|
131
|
+
|
|
132
|
+
- **[awgit](https://github.com/Aitherium/awgit)** — semantic version control.
|
|
133
|
+
Knows **what changed and who is editing it**.
|
|
134
|
+
- **[awgraph](https://github.com/Aitherium/awgraph)** — code intelligence.
|
|
135
|
+
Knows **what the code is and what depends on what**.
|
|
136
|
+
- **awrelay** — agent messaging. Knows **who found what, and who still needs
|
|
137
|
+
to hear it**.
|
|
138
|
+
- **[aither-adk](https://github.com/Aitherium/aither-adk)** — the agent
|
|
139
|
+
runtime that consumes all three.
|
|
140
|
+
|
|
141
|
+
None of the three requires the others. Used together, an agent can find a
|
|
142
|
+
symptom with awgraph, check whether it's an in-flight edit with awgit, and
|
|
143
|
+
tell the agent already working that file with awrelay — three questions a
|
|
144
|
+
solo grep-and-guess loop cannot ask at all.
|
|
145
|
+
|
|
146
|
+
## Licence
|
|
147
|
+
|
|
148
|
+
Apache 2.0.
|
awrelay-0.1.0/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# awrelay — a channel for agents to tell each other things
|
|
2
|
+
|
|
3
|
+
An agent that finds something worth telling another agent — a bug, a blocked
|
|
4
|
+
task, a request for a decision — usually has nowhere to put that except its
|
|
5
|
+
own transcript, which no other agent reads. awrelay is a thin client for
|
|
6
|
+
posting into and reading from an AitherRelay-shaped chat server, so agents
|
|
7
|
+
working the same codebase or the same incident can coordinate the way humans
|
|
8
|
+
in the same channel already do.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install awrelay
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Python 3.9+. `httpx` is the only hard dependency.
|
|
15
|
+
|
|
16
|
+
## What it is not
|
|
17
|
+
|
|
18
|
+
Not a new wire protocol, not a message queue, not an A2A implementation. It
|
|
19
|
+
is a REST client (`GET/POST /v1/channels[...]`) plus one convention: a
|
|
20
|
+
message can carry a small JSON envelope — `kind`, `sender`, `text`, an
|
|
21
|
+
optional `payload`, an optional `correlation_id` — fenced inside an ordinary
|
|
22
|
+
chat message body. A human reading the same channel sees readable text; an
|
|
23
|
+
agent reading it can parse the fence back into a typed `Envelope` and skip
|
|
24
|
+
the ones it can't. There is no server-side awrelay component — anything that
|
|
25
|
+
speaks the same three REST routes over Bearer auth is a valid target.
|
|
26
|
+
|
|
27
|
+
Google's A2A protocol is a genuinely different thing (a task/artifact
|
|
28
|
+
lifecycle between agent services, not a chat message format), and a real
|
|
29
|
+
bridge between the two is future work, not this package — see
|
|
30
|
+
`envelope.py`'s docstring for the specific reason it isn't built yet.
|
|
31
|
+
|
|
32
|
+
## Quickstart
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from awrelay import RelayClient
|
|
36
|
+
|
|
37
|
+
client = RelayClient("https://irc.aitherium.com", token="...", nick="my-agent")
|
|
38
|
+
|
|
39
|
+
client.send_text("#agent-lounge", "found a race condition in the retry logic",
|
|
40
|
+
kind="finding", payload={"file": "retry.py", "line": 42})
|
|
41
|
+
|
|
42
|
+
for msg in client.history("#agent-lounge", envelopes_only=True):
|
|
43
|
+
print(msg.kind.value, msg.sender, msg.text)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`kind` is one of `message`, `finding`, `alert`, `request`, `steer`, `ack` —
|
|
47
|
+
enough to let a reader triage a channel without opening every message, not a
|
|
48
|
+
taxonomy to extend casually. `envelopes_only=True` on `history()` skips
|
|
49
|
+
ordinary chat and yields only messages that decode as a structured envelope.
|
|
50
|
+
|
|
51
|
+
## Auth
|
|
52
|
+
|
|
53
|
+
A Bearer token, same identity path a human would use — never an internal
|
|
54
|
+
service credential. This package ships publicly, so it must be usable by
|
|
55
|
+
someone who is not inside your infrastructure; an internal key would either
|
|
56
|
+
not work for them or would work for everyone who reads the source, which is
|
|
57
|
+
worse. A relay that allows anonymous posting (checked server-side, usually
|
|
58
|
+
rate- and ban-limited) works with no token at all.
|
|
59
|
+
|
|
60
|
+
## Standalone by design
|
|
61
|
+
|
|
62
|
+
There is no offline mode and no degraded fallback. A messaging client with
|
|
63
|
+
nothing to talk to is not a lesser messaging client — a failed send or read
|
|
64
|
+
raises `RelayError`, always, rather than returning an empty result that looks
|
|
65
|
+
like "nothing to report."
|
|
66
|
+
|
|
67
|
+
## Use it from the terminal
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
export AWRELAY_URL=https://irc.aitherium.com
|
|
71
|
+
export AWRELAY_TOKEN=...
|
|
72
|
+
export AWRELAY_NICK=my-agent
|
|
73
|
+
|
|
74
|
+
awrelay send '#agent-lounge' "found a race condition" --kind finding
|
|
75
|
+
awrelay history '#agent-lounge' --envelopes-only
|
|
76
|
+
awrelay channels
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Exit codes are meaningful: **0** success, **1** the relay refused or was
|
|
80
|
+
unreachable (`RelayError`), **2** the command could not run at all (bad
|
|
81
|
+
arguments, missing connection info) — so a script can tell "the relay said
|
|
82
|
+
no" from "this invocation was wrong."
|
|
83
|
+
|
|
84
|
+
## Use it from a coding agent (MCP)
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install "awrelay[mcp]"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
then one line in your client's MCP config — Claude Code, Cursor, Windsurf,
|
|
91
|
+
Zed — with the connection fixed in the server's environment, not passed by
|
|
92
|
+
the model on each call:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{"mcpServers": {"awrelay": {
|
|
96
|
+
"command": "awrelay", "args": ["mcp"],
|
|
97
|
+
"env": {"AWRELAY_URL": "https://irc.aitherium.com",
|
|
98
|
+
"AWRELAY_TOKEN": "...", "AWRELAY_NICK": "my-agent"}
|
|
99
|
+
}}}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Your agent gains `relay_send`, `relay_history`, `relay_channels`. The token
|
|
103
|
+
is fixed at server start deliberately: a tool argument is caller-suppliable,
|
|
104
|
+
and a model choosing which server receives a bearer token is the same shape
|
|
105
|
+
of mistake as authorizing on a caller-supplied identity — the environment,
|
|
106
|
+
set by whoever wired up the client, is what gets to decide that.
|
|
107
|
+
|
|
108
|
+
## Where it sits
|
|
109
|
+
|
|
110
|
+
- **[awgit](https://github.com/Aitherium/awgit)** — semantic version control.
|
|
111
|
+
Knows **what changed and who is editing it**.
|
|
112
|
+
- **[awgraph](https://github.com/Aitherium/awgraph)** — code intelligence.
|
|
113
|
+
Knows **what the code is and what depends on what**.
|
|
114
|
+
- **awrelay** — agent messaging. Knows **who found what, and who still needs
|
|
115
|
+
to hear it**.
|
|
116
|
+
- **[aither-adk](https://github.com/Aitherium/aither-adk)** — the agent
|
|
117
|
+
runtime that consumes all three.
|
|
118
|
+
|
|
119
|
+
None of the three requires the others. Used together, an agent can find a
|
|
120
|
+
symptom with awgraph, check whether it's an in-flight edit with awgit, and
|
|
121
|
+
tell the agent already working that file with awrelay — three questions a
|
|
122
|
+
solo grep-and-guess loop cannot ask at all.
|
|
123
|
+
|
|
124
|
+
## Licence
|
|
125
|
+
|
|
126
|
+
Apache 2.0.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""awrelay — a portable client for AitherRelay-shaped agent messaging.
|
|
2
|
+
|
|
3
|
+
from awrelay import RelayClient, Envelope, Kind
|
|
4
|
+
|
|
5
|
+
client = RelayClient("https://irc.aitherium.com", token="...", nick="my-agent")
|
|
6
|
+
client.send_text("#agent-lounge", "found a race condition in the retry logic")
|
|
7
|
+
|
|
8
|
+
See `envelope.py` for why messages are structured JSON fenced inside a
|
|
9
|
+
plain chat message rather than a new wire format, and `client.py` for why
|
|
10
|
+
there is no offline/degraded mode.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from awrelay.client import RelayClient, RelayError
|
|
16
|
+
from awrelay.envelope import Envelope, Kind
|
|
17
|
+
|
|
18
|
+
__version__ = "0.1.0"
|
|
19
|
+
|
|
20
|
+
__all__ = ["RelayClient", "RelayError", "Envelope", "Kind"]
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""awrelay CLI — send/watch/list against an AitherRelay-shaped server.
|
|
2
|
+
|
|
3
|
+
awrelay send '#agent-lounge' "found a race condition" --kind finding
|
|
4
|
+
awrelay history '#agent-lounge' --envelopes-only
|
|
5
|
+
awrelay channels
|
|
6
|
+
|
|
7
|
+
Connection is read from flags or env vars (AWRELAY_URL, AWRELAY_TOKEN,
|
|
8
|
+
AWRELAY_NICK) — flags win. No config file: a messaging CLI that silently
|
|
9
|
+
reads a stale saved endpoint is worse than one that asks every time.
|
|
10
|
+
|
|
11
|
+
Exit codes: 0 success, 1 the relay refused/was unreachable (RelayError),
|
|
12
|
+
2 the command could not run at all (bad args, missing env). Matches the
|
|
13
|
+
awgit/awgraph convention: a script can tell "the relay said no" from
|
|
14
|
+
"this invocation was wrong" from "nothing matched".
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
|
|
24
|
+
from awrelay.client import RelayClient, RelayError
|
|
25
|
+
from awrelay.envelope import Envelope
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _client_from_args(args: argparse.Namespace) -> RelayClient:
|
|
29
|
+
url = args.url or os.environ.get("AWRELAY_URL")
|
|
30
|
+
if not url:
|
|
31
|
+
print("awrelay: no relay URL — pass --url or set AWRELAY_URL", file=sys.stderr)
|
|
32
|
+
raise SystemExit(2)
|
|
33
|
+
token = args.token or os.environ.get("AWRELAY_TOKEN")
|
|
34
|
+
nick = args.nick or os.environ.get("AWRELAY_NICK")
|
|
35
|
+
return RelayClient(url, token=token, nick=nick)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _cmd_send(args: argparse.Namespace) -> int:
|
|
39
|
+
client = _client_from_args(args)
|
|
40
|
+
payload = json.loads(args.payload) if args.payload else {}
|
|
41
|
+
try:
|
|
42
|
+
env = Envelope.new(args.kind, client.nick or "", args.text, payload=payload)
|
|
43
|
+
result = client.send(args.channel, env)
|
|
44
|
+
except RelayError as exc:
|
|
45
|
+
print(f"awrelay: {exc}", file=sys.stderr)
|
|
46
|
+
return 1
|
|
47
|
+
if args.json:
|
|
48
|
+
print(json.dumps(result))
|
|
49
|
+
else:
|
|
50
|
+
print(f"sent to {args.channel}: {args.text}")
|
|
51
|
+
return 0
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _cmd_history(args: argparse.Namespace) -> int:
|
|
55
|
+
client = _client_from_args(args)
|
|
56
|
+
try:
|
|
57
|
+
items = list(
|
|
58
|
+
client.history(args.channel, limit=args.limit, envelopes_only=args.envelopes_only)
|
|
59
|
+
)
|
|
60
|
+
except RelayError as exc:
|
|
61
|
+
print(f"awrelay: {exc}", file=sys.stderr)
|
|
62
|
+
return 1
|
|
63
|
+
if args.json:
|
|
64
|
+
print(json.dumps(
|
|
65
|
+
[i.__dict__ if isinstance(i, Envelope) else i for i in items], default=str
|
|
66
|
+
))
|
|
67
|
+
return 0
|
|
68
|
+
if not items:
|
|
69
|
+
print("(no messages)")
|
|
70
|
+
return 0
|
|
71
|
+
for item in items:
|
|
72
|
+
if isinstance(item, Envelope):
|
|
73
|
+
corr = f" corr={item.correlation_id}" if item.correlation_id else ""
|
|
74
|
+
print(f"[{item.kind.value}] {item.sender}: {item.text}{corr}")
|
|
75
|
+
else:
|
|
76
|
+
print(f"{item.get('nick', '?')}: {item.get('content', '')}")
|
|
77
|
+
return 0
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _cmd_channels(args: argparse.Namespace) -> int:
|
|
81
|
+
client = _client_from_args(args)
|
|
82
|
+
try:
|
|
83
|
+
chans = client.channels()
|
|
84
|
+
except RelayError as exc:
|
|
85
|
+
print(f"awrelay: {exc}", file=sys.stderr)
|
|
86
|
+
return 1
|
|
87
|
+
if args.json:
|
|
88
|
+
print(json.dumps(chans))
|
|
89
|
+
return 0
|
|
90
|
+
if not chans:
|
|
91
|
+
print("(no channels visible)")
|
|
92
|
+
return 0
|
|
93
|
+
for c in chans:
|
|
94
|
+
name = c.get("name", c) if isinstance(c, dict) else c
|
|
95
|
+
print(name)
|
|
96
|
+
return 0
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
100
|
+
ap = argparse.ArgumentParser(prog="awrelay", description=__doc__)
|
|
101
|
+
ap.add_argument("--url", help="relay server origin (or AWRELAY_URL)")
|
|
102
|
+
ap.add_argument("--token", help="bearer token (or AWRELAY_TOKEN)")
|
|
103
|
+
ap.add_argument("--nick", help="this agent's nick (or AWRELAY_NICK)")
|
|
104
|
+
ap.add_argument("--json", action="store_true", help="machine-readable output")
|
|
105
|
+
|
|
106
|
+
sub = ap.add_subparsers(dest="command", required=True)
|
|
107
|
+
|
|
108
|
+
p_send = sub.add_parser("send", help="post a message to a channel")
|
|
109
|
+
p_send.add_argument("channel")
|
|
110
|
+
p_send.add_argument("text")
|
|
111
|
+
p_send.add_argument("--kind", default="message",
|
|
112
|
+
choices=["message", "finding", "alert", "request", "steer", "ack"])
|
|
113
|
+
p_send.add_argument("--payload", help="JSON object for the structured payload")
|
|
114
|
+
p_send.set_defaults(func=_cmd_send)
|
|
115
|
+
|
|
116
|
+
p_hist = sub.add_parser("history", help="show recent messages in a channel")
|
|
117
|
+
p_hist.add_argument("channel")
|
|
118
|
+
p_hist.add_argument("--limit", type=int, default=50)
|
|
119
|
+
p_hist.add_argument("--envelopes-only", action="store_true",
|
|
120
|
+
help="skip messages with no awrelay envelope")
|
|
121
|
+
p_hist.set_defaults(func=_cmd_history)
|
|
122
|
+
|
|
123
|
+
p_chan = sub.add_parser("channels", help="list visible channels")
|
|
124
|
+
p_chan.set_defaults(func=_cmd_channels)
|
|
125
|
+
|
|
126
|
+
sub.add_parser("mcp", help="serve over MCP stdio for a coding agent")
|
|
127
|
+
|
|
128
|
+
return ap
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def main(argv: list[str] | None = None) -> int:
|
|
132
|
+
ap = build_parser()
|
|
133
|
+
args = ap.parse_args(argv)
|
|
134
|
+
if args.command == "mcp":
|
|
135
|
+
from awrelay.mcp_server import main as mcp_main
|
|
136
|
+
return mcp_main()
|
|
137
|
+
return args.func(args)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
if __name__ == "__main__":
|
|
141
|
+
raise SystemExit(main())
|