bowire-plugin 0.3.0__py3-none-any.whl
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.
- bowire_plugin/__init__.py +69 -0
- bowire_plugin/_http.py +127 -0
- bowire_plugin/_manual_entry.py +165 -0
- bowire_plugin/_models.py +194 -0
- bowire_plugin/_plugin.py +95 -0
- bowire_plugin/_runtime.py +258 -0
- bowire_plugin/_settings.py +203 -0
- bowire_plugin-0.3.0.dist-info/METADATA +486 -0
- bowire_plugin-0.3.0.dist-info/RECORD +11 -0
- bowire_plugin-0.3.0.dist-info/WHEEL +4 -0
- bowire_plugin-0.3.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bowire-plugin
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Write a Bowire protocol plugin in Python — JSON-RPC sidecar SDK (stdio + HTTP/SSE).
|
|
5
|
+
Project-URL: Homepage, https://bowire.io/
|
|
6
|
+
Project-URL: Repository, https://github.com/Kuestenlogik/Bowire.Sdk.Python
|
|
7
|
+
Project-URL: Sidecar spec, https://github.com/Kuestenlogik/Bowire/blob/main/docs/architecture/sidecar-plugins.md
|
|
8
|
+
Author: Küstenlogik
|
|
9
|
+
License: Apache License
|
|
10
|
+
Version 2.0, January 2004
|
|
11
|
+
http://www.apache.org/licenses/
|
|
12
|
+
|
|
13
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
14
|
+
|
|
15
|
+
1. Definitions.
|
|
16
|
+
|
|
17
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
18
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
19
|
+
|
|
20
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
21
|
+
the copyright owner that is granting the License.
|
|
22
|
+
|
|
23
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
24
|
+
other entities that control, are controlled by, or are under common
|
|
25
|
+
control with that entity. For the purposes of this definition,
|
|
26
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
27
|
+
direction or management of such entity, whether by contract or
|
|
28
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
29
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
30
|
+
|
|
31
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
32
|
+
exercising permissions granted by this License.
|
|
33
|
+
|
|
34
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
35
|
+
including but not limited to software source code, documentation
|
|
36
|
+
source, and configuration files.
|
|
37
|
+
|
|
38
|
+
"Object" form shall mean any form resulting from mechanical
|
|
39
|
+
transformation or translation of a Source form, including but
|
|
40
|
+
not limited to compiled object code, generated documentation,
|
|
41
|
+
and conversions to other media types.
|
|
42
|
+
|
|
43
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
44
|
+
Object form, made available under the License, as indicated by a
|
|
45
|
+
copyright notice that is included in or attached to the work
|
|
46
|
+
(an example is provided in the Appendix below).
|
|
47
|
+
|
|
48
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
49
|
+
form, that is based on (or derived from) the Work and for which the
|
|
50
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
51
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
52
|
+
of this License, Derivative Works shall not include works that remain
|
|
53
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
54
|
+
the Work and Derivative Works thereof.
|
|
55
|
+
|
|
56
|
+
"Contribution" shall mean any work of authorship, including
|
|
57
|
+
the original version of the Work and any modifications or additions
|
|
58
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
59
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
60
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
61
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
62
|
+
means any form of electronic, verbal, or written communication sent
|
|
63
|
+
to the Licensor or its representatives, including but not limited to
|
|
64
|
+
communication on electronic mailing lists, source code control systems,
|
|
65
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
66
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
67
|
+
excluding communication that is conspicuously marked or otherwise
|
|
68
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
69
|
+
|
|
70
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
71
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
72
|
+
subsequently incorporated within the Work.
|
|
73
|
+
|
|
74
|
+
2. Grant of Copyright 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
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
78
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
79
|
+
Work and such Derivative Works in Source or Object form.
|
|
80
|
+
|
|
81
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
82
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
83
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
84
|
+
(except as stated in this section) patent license to make, have made,
|
|
85
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
86
|
+
where such license applies only to those patent claims licensable
|
|
87
|
+
by such Contributor that are necessarily infringed by their
|
|
88
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
89
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
90
|
+
institute patent litigation against any entity (including a
|
|
91
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
92
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
93
|
+
or contributory patent infringement, then any patent licenses
|
|
94
|
+
granted to You under this License for that Work shall terminate
|
|
95
|
+
as of the date such litigation is filed.
|
|
96
|
+
|
|
97
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
98
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
99
|
+
modifications, and in Source or Object form, provided that You
|
|
100
|
+
meet the following conditions:
|
|
101
|
+
|
|
102
|
+
(a) You must give any other recipients of the Work or
|
|
103
|
+
Derivative Works a copy of this License; and
|
|
104
|
+
|
|
105
|
+
(b) You must cause any modified files to carry prominent notices
|
|
106
|
+
stating that You changed the files; and
|
|
107
|
+
|
|
108
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
109
|
+
that You distribute, all copyright, patent, trademark, and
|
|
110
|
+
attribution notices from the Source form of the Work,
|
|
111
|
+
excluding those notices that do not pertain to any part of
|
|
112
|
+
the Derivative Works; and
|
|
113
|
+
|
|
114
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
115
|
+
distribution, then any Derivative Works that You distribute must
|
|
116
|
+
include a readable copy of the attribution notices contained
|
|
117
|
+
within such NOTICE file, excluding those notices that do not
|
|
118
|
+
pertain to any part of the Derivative Works, in at least one
|
|
119
|
+
of the following places: within a NOTICE text file distributed
|
|
120
|
+
as part of the Derivative Works; within the Source form or
|
|
121
|
+
documentation, if provided along with the Derivative Works; or,
|
|
122
|
+
within a display generated by the Derivative Works, if and
|
|
123
|
+
wherever such third-party notices normally appear. The contents
|
|
124
|
+
of the NOTICE file are for informational purposes only and
|
|
125
|
+
do not modify the License. You may add Your own attribution
|
|
126
|
+
notices within Derivative Works that You distribute, alongside
|
|
127
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
128
|
+
that such additional attribution notices cannot be construed
|
|
129
|
+
as modifying the License.
|
|
130
|
+
|
|
131
|
+
You may add Your own copyright statement to Your modifications and
|
|
132
|
+
may provide additional or different license terms and conditions
|
|
133
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
134
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
135
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
136
|
+
the conditions stated in this License.
|
|
137
|
+
|
|
138
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
139
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
140
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
141
|
+
this License, without any additional terms or conditions.
|
|
142
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
143
|
+
the terms of any separate license agreement you may have executed
|
|
144
|
+
with Licensor regarding such Contributions.
|
|
145
|
+
|
|
146
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
147
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
148
|
+
except as required for reasonable and customary use in describing the
|
|
149
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
150
|
+
|
|
151
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
152
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
153
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
154
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
155
|
+
implied, including, without limitation, any warranties or conditions
|
|
156
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
157
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
158
|
+
appropriateness of using or redistributing the Work and assume any
|
|
159
|
+
risks associated with Your exercise of permissions under this License.
|
|
160
|
+
|
|
161
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
162
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
163
|
+
unless required by applicable law (such as deliberate and grossly
|
|
164
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
165
|
+
liable to You for damages, including any direct, indirect, special,
|
|
166
|
+
incidental, or consequential damages of any character arising as a
|
|
167
|
+
result of this License or out of the use or inability to use the
|
|
168
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
169
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
170
|
+
other commercial damages or losses), even if such Contributor
|
|
171
|
+
has been advised of the possibility of such damages.
|
|
172
|
+
|
|
173
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
174
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
175
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
176
|
+
or other liability obligations and/or rights consistent with this
|
|
177
|
+
License. However, in accepting such obligations, You may act only
|
|
178
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
179
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
180
|
+
defend, and hold each Contributor harmless for any liability
|
|
181
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
182
|
+
of your accepting any such warranty or additional liability.
|
|
183
|
+
|
|
184
|
+
END OF TERMS AND CONDITIONS
|
|
185
|
+
|
|
186
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
187
|
+
|
|
188
|
+
To apply the Apache License to your work, attach the following
|
|
189
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
190
|
+
replaced with your own identifying information. (Don't include
|
|
191
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
192
|
+
comment syntax for the file format. We also recommend that a
|
|
193
|
+
file or class name and description of purpose be included on the
|
|
194
|
+
same "printed page" as the copyright notice for easier
|
|
195
|
+
identification within third-party archives.
|
|
196
|
+
|
|
197
|
+
Copyright [yyyy] [name of copyright owner]
|
|
198
|
+
|
|
199
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
200
|
+
you may not use this file except in compliance with the License.
|
|
201
|
+
You may obtain a copy of the License at
|
|
202
|
+
|
|
203
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
204
|
+
|
|
205
|
+
Unless required by applicable law or agreed to in writing, software
|
|
206
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
207
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
208
|
+
See the License for the specific language governing permissions and
|
|
209
|
+
limitations under the License.
|
|
210
|
+
License-File: LICENSE
|
|
211
|
+
Keywords: bowire,developer-tools,json-rpc,plugin,protocol,sidecar
|
|
212
|
+
Classifier: Development Status :: 4 - Beta
|
|
213
|
+
Classifier: Intended Audience :: Developers
|
|
214
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
215
|
+
Classifier: Programming Language :: Python :: 3
|
|
216
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
217
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
218
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
219
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
220
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
221
|
+
Requires-Python: >=3.10
|
|
222
|
+
Provides-Extra: dev
|
|
223
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
224
|
+
Requires-Dist: ruff<0.18,>=0.16; extra == 'dev'
|
|
225
|
+
Description-Content-Type: text/markdown
|
|
226
|
+
|
|
227
|
+
# bowire-plugin (Python SDK)
|
|
228
|
+
|
|
229
|
+
[](https://pypi.org/project/bowire-plugin/)
|
|
230
|
+
[](https://pypi.org/project/bowire-plugin/)
|
|
231
|
+
[](LICENSE)
|
|
232
|
+
|
|
233
|
+
Write a [Bowire](https://github.com/Kuestenlogik/Bowire) protocol plugin **in Python**.
|
|
234
|
+
|
|
235
|
+
Bowire's first-party plugins are .NET assemblies, but any executable can be a plugin by speaking JSON-RPC 2.0 over its stdin/stdout — a *sidecar*. This SDK hides the wire: subclass `BowirePlugin`, implement the methods you need, call `run()`. Perfect when the best client for your protocol lives in the Python ecosystem (`paho-mqtt`, the SciPy/ML stack, vendor SDKs, …).
|
|
236
|
+
|
|
237
|
+
See the full wire spec: [`docs/architecture/sidecar-plugins.md`](https://github.com/Kuestenlogik/Bowire/blob/main/docs/architecture/sidecar-plugins.md).
|
|
238
|
+
|
|
239
|
+
## Install
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
pip install bowire-plugin
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Write a plugin
|
|
246
|
+
|
|
247
|
+
```python
|
|
248
|
+
from bowire_plugin import BowirePlugin, ServiceInfo, MethodInfo, InvokeResult, run
|
|
249
|
+
|
|
250
|
+
class MyPlugin(BowirePlugin):
|
|
251
|
+
id = "myproto" # must match sidecar.json's protocol.id
|
|
252
|
+
name = "MyProtocol"
|
|
253
|
+
icon_svg = "<svg/>" # optional
|
|
254
|
+
|
|
255
|
+
def discover(self, server_url, show_internal, settings):
|
|
256
|
+
return [ServiceInfo("Things", methods=[
|
|
257
|
+
MethodInfo("get", full_name="Things/get", method_type="Unary"),
|
|
258
|
+
])]
|
|
259
|
+
|
|
260
|
+
def invoke(self, server_url, service, method, json_messages, show_internal, metadata,
|
|
261
|
+
settings):
|
|
262
|
+
payload = json_messages[0] if json_messages else ""
|
|
263
|
+
return InvokeResult(response=f"got {payload}", status="OK")
|
|
264
|
+
|
|
265
|
+
def invoke_stream(self, server_url, service, method, json_messages, show_internal, metadata,
|
|
266
|
+
settings):
|
|
267
|
+
for i in range(5):
|
|
268
|
+
yield f'{{"tick":{i}}}' # each yield → a $/stream/data frame
|
|
269
|
+
|
|
270
|
+
if __name__ == "__main__":
|
|
271
|
+
run(MyPlugin())
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
`run()` blocks, handling the contract (`initialize` / `discover` / `invoke` / `invokeStream` / `ping` / `shutdown`) until the host disconnects.
|
|
275
|
+
|
|
276
|
+
## Settings
|
|
277
|
+
|
|
278
|
+
A plugin declares settings once; Bowire renders them in its Settings dialog,
|
|
279
|
+
under the plugin's own section (Bowire 2.8 or later). The values come back on
|
|
280
|
+
every call as the `settings` argument.
|
|
281
|
+
|
|
282
|
+
**Declare** them by overriding `settings()`:
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
from bowire_plugin import PluginSetting, SettingOption
|
|
286
|
+
|
|
287
|
+
class MyPlugin(BowirePlugin):
|
|
288
|
+
def settings(self):
|
|
289
|
+
return [
|
|
290
|
+
PluginSetting("probeWindow", "Probe window", type="number", default_value=5,
|
|
291
|
+
description="Seconds to listen before answering discovery."),
|
|
292
|
+
PluginSetting("verbose", "Verbose", type="bool", default_value=False),
|
|
293
|
+
PluginSetting("mode", "Mode", type="select", default_value="fast", options=[
|
|
294
|
+
SettingOption("fast", "Fast"),
|
|
295
|
+
SettingOption("thorough", "Thorough"),
|
|
296
|
+
]),
|
|
297
|
+
]
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
`type` is `"bool"` (the default), `"string"`, `"number"` or `"select"`. A
|
|
301
|
+
`select` needs `options`; declaring one without them raises `ValueError`.
|
|
302
|
+
|
|
303
|
+
**Read** them from the `settings` argument every call receives:
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
def discover(self, server_url, show_internal, settings):
|
|
307
|
+
window = settings.get_float("probeWindow") # 5.0 until somebody sets it
|
|
308
|
+
if settings.get_bool("verbose"):
|
|
309
|
+
...
|
|
310
|
+
thorough = settings.get_str("mode") == "thorough"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
What the accessors guarantee:
|
|
314
|
+
|
|
315
|
+
- **Fresh per call.** The host sends the current values with each request, so
|
|
316
|
+
a changed setting applies from the next call — no restart. Read the
|
|
317
|
+
argument; don't copy it into the plugin at startup.
|
|
318
|
+
- **Typed, with the declared default.** `get_str` / `get_bool` / `get_int` /
|
|
319
|
+
`get_float` parse the value the host sent (always a string on the wire) and
|
|
320
|
+
return the `default_value` you declared when the key is absent — the host
|
|
321
|
+
only sends keys somebody actually set. Pass `default=` to override it for
|
|
322
|
+
one read.
|
|
323
|
+
- **A value that does not parse falls back** to the default, as the host's own
|
|
324
|
+
.NET accessors do: `get_bool` accepts `true` / `false` in any case,
|
|
325
|
+
`get_int` ASCII digits with an optional sign, `get_float` a finite decimal
|
|
326
|
+
with an optional exponent. A key with neither a usable value nor a default
|
|
327
|
+
raises `KeyError`.
|
|
328
|
+
- `settings` is also a read-only mapping of exactly what the host sent:
|
|
329
|
+
`dict(settings)`, `"verbose" in settings`, `settings.get("mode")`.
|
|
330
|
+
|
|
331
|
+
## Hand-entry form
|
|
332
|
+
|
|
333
|
+
A user can call your plugin without discovery, from the workbench's freeform
|
|
334
|
+
form or Compose, and only your plugin knows what such a call needs. Declare it
|
|
335
|
+
in `manual_entry()`. The SDK sends it in the `initialize` reply, and the
|
|
336
|
+
workbench renders a Compose form from it and offers exactly these method types
|
|
337
|
+
in the freeform form (Bowire 2.11 or later).
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
from bowire_plugin import ManualCallKind, ManualEntryForm, ManualField
|
|
341
|
+
|
|
342
|
+
def manual_entry(self) -> ManualEntryForm:
|
|
343
|
+
return ManualEntryForm(
|
|
344
|
+
url_placeholder="mybroker://localhost:9000",
|
|
345
|
+
call_kinds=[
|
|
346
|
+
ManualCallKind("produce", "Unary", label="Produce", service="{topic}", method="produce"),
|
|
347
|
+
ManualCallKind("consume", "ServerStreaming", label="Consume", service="{topic}", method="consume"),
|
|
348
|
+
],
|
|
349
|
+
fields=[
|
|
350
|
+
ManualField("topic", label="Topic", placement="template", required=True),
|
|
351
|
+
ManualField("key", label="Key", call_kinds=["produce"]),
|
|
352
|
+
],
|
|
353
|
+
)
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
- A **call kind** names how it runs: `Unary` is `invoke`, `ServerStreaming`
|
|
357
|
+
is `invoke_stream`, and `ClientStreaming` or `Duplex` opens a channel.
|
|
358
|
+
`service` and `method` are templates, in which `{key}` is the value of the
|
|
359
|
+
field with that key.
|
|
360
|
+
- A **field** with `placement="template"` only feeds the templates. The
|
|
361
|
+
default, `"metadata"`, goes into the call's metadata under its `key`, which
|
|
362
|
+
is where your `invoke` reads it.
|
|
363
|
+
- A form the host would refuse raises `ValueError` where it is built, naming
|
|
364
|
+
the problem. Examples are an unknown method type, a placeholder no field
|
|
365
|
+
declares, and a `select` without options. `manual_entry_problems(form)`
|
|
366
|
+
runs the same check.
|
|
367
|
+
|
|
368
|
+
## Ship it
|
|
369
|
+
|
|
370
|
+
Put the script next to a `sidecar.json` manifest:
|
|
371
|
+
|
|
372
|
+
```json
|
|
373
|
+
{
|
|
374
|
+
"packageId": "Acme.Bowire.Sidecar.MyProto",
|
|
375
|
+
"protocol": { "id": "myproto", "name": "MyProtocol" },
|
|
376
|
+
"executable": "python",
|
|
377
|
+
"args": ["my_plugin.py"],
|
|
378
|
+
"version": "1.0.0"
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
The manifest names the interpreter and passes the script as its argument, so
|
|
383
|
+
the script needs no shebang and no executable bit. The host first looks for
|
|
384
|
+
`executable` in the plugin directory, then — for a bare name — on `PATH`
|
|
385
|
+
(Bowire 2.8 or later). The SDK has to be installed into the interpreter that
|
|
386
|
+
name resolves to.
|
|
387
|
+
|
|
388
|
+
Why `python` and not `python3`: no single name exists on every machine, and
|
|
389
|
+
`python` is the one that does wherever this SDK is installed in practice.
|
|
390
|
+
|
|
391
|
+
| Where the plugin runs | `python` | `python3` |
|
|
392
|
+
|---|---|---|
|
|
393
|
+
| Windows, python.org installer or `actions/setup-python` | yes | no — resolves to the Microsoft Store alias, which exits without running anything |
|
|
394
|
+
| Any virtual environment (`venv` on PATH), Linux, macOS or Windows | yes | Linux / macOS only — a Windows venv has no `python3.exe` |
|
|
395
|
+
| Linux / macOS system interpreter, no venv | only where the distribution ships it (`python-is-python3`) | yes |
|
|
396
|
+
|
|
397
|
+
The last row is also the one where `pip install bowire-plugin` is refused by
|
|
398
|
+
default on current distributions (PEP 668), so a plugin there already needs a
|
|
399
|
+
venv. If you ship a plugin only for Linux or macOS system interpreters, name
|
|
400
|
+
`python3` instead.
|
|
401
|
+
|
|
402
|
+
Zip the folder and install into Bowire:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
bowire plugin install --file my-proto-sidecar.zip
|
|
406
|
+
bowire --url myproto://your-server
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
`bowire plugin list` tags it `[sidecar: myproto]`.
|
|
410
|
+
|
|
411
|
+
## Transports: stdio (default) or HTTP/SSE
|
|
412
|
+
|
|
413
|
+
The same `BowirePlugin` runs over either wire — like MCP's stdio +
|
|
414
|
+
streamable-HTTP. Default is stdio (the examples above). For a
|
|
415
|
+
long-running / remote service, serve it over HTTP instead:
|
|
416
|
+
|
|
417
|
+
```python
|
|
418
|
+
from bowire_plugin import run_http
|
|
419
|
+
run_http(MyPlugin(), host="127.0.0.1", port=8770)
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
`run_http` exposes one path: `POST` for JSON-RPC requests (the response
|
|
423
|
+
body is the reply), `GET` as the SSE stream that carries server
|
|
424
|
+
notifications (`$/stream/data`, …). Point the manifest at it with
|
|
425
|
+
`transport: "http"`:
|
|
426
|
+
|
|
427
|
+
```json
|
|
428
|
+
{
|
|
429
|
+
"packageId": "Acme.Bowire.Sidecar.MyProto",
|
|
430
|
+
"protocol": { "id": "myproto", "name": "MyProtocol" },
|
|
431
|
+
"transport": "http",
|
|
432
|
+
"url": "http://127.0.0.1:8770/"
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
| | stdio | http |
|
|
437
|
+
|---|---|---|
|
|
438
|
+
| Lifecycle | Bowire spawns/kills the process | you run the service; Bowire is just a client |
|
|
439
|
+
| Best for | local plugin shipped as a zip | hosted / remote / shared by many hosts |
|
|
440
|
+
| Deps | none | none (stdlib `http.server`) |
|
|
441
|
+
|
|
442
|
+
## API surface
|
|
443
|
+
|
|
444
|
+
| Override | When it's called | Return |
|
|
445
|
+
|----------|------------------|--------|
|
|
446
|
+
| `discover(server_url, show_internal, settings)` | discovery | `list[ServiceInfo]` (empty = decline the URL) |
|
|
447
|
+
| `invoke(server_url, service, method, json_messages, show_internal, metadata, settings)` | unary call | `InvokeResult` |
|
|
448
|
+
| `invoke_stream(...)` | server-streaming call | iterator of JSON strings (each → one frame) |
|
|
449
|
+
| `settings()` | once, for the `initialize` reply | `list[PluginSetting]` |
|
|
450
|
+
| `manual_entry()` | for the `initialize` reply | `ManualEntryForm`, or `None` for no form |
|
|
451
|
+
| `shutdown()` | host exit | `None` (cleanup hook) |
|
|
452
|
+
|
|
453
|
+
Class attributes: `id` (required, matches the manifest), `name`, `icon_svg`.
|
|
454
|
+
|
|
455
|
+
Models — `ServiceInfo`, `MethodInfo`, `MessageInfo`, `FieldInfo`, `InvokeResult`, `PluginSetting`, `SettingOption`, `ManualEntryForm`, `ManualCallKind`, `ManualField` — are dataclasses that serialize to the camelCase shapes the host expects. `Settings` is the per-call argument described under [Settings](#settings).
|
|
456
|
+
|
|
457
|
+
## Example
|
|
458
|
+
|
|
459
|
+
[`examples/echo`](examples/echo) is a runnable plugin (unary echo + a ticker stream) that declares and reads three settings: a reply `prefix` (string), a `letterCase` (select) and the ticker length `ticks` (number). Smoke-test it as a plain process:
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | python examples/echo/echo_plugin.py
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Or install it into a real Bowire host, discover through it, and round-trip its settings through the workbench — what CI runs on Linux and Windows:
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
python scripts/e2e.py --bowire "$(command -v bowire)" --work "$(mktemp -d)"
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Releasing
|
|
472
|
+
|
|
473
|
+
Pushing a tag `vX.Y.Z` that matches `version` in `pyproject.toml` publishes
|
|
474
|
+
`bowire-plugin` to PyPI (`.github/workflows/release.yml`). The workflow tests
|
|
475
|
+
that commit, builds the sdist and the wheel, and uploads them through PyPI
|
|
476
|
+
Trusted Publishing from the `pypi` environment, so no API token is stored. A
|
|
477
|
+
version already on PyPI is skipped. To publish an existing tag again, run the
|
|
478
|
+
workflow by hand with that tag.
|
|
479
|
+
|
|
480
|
+
## Not in scope
|
|
481
|
+
|
|
482
|
+
Sidecars implement **protocols**, not host extensions (auth providers, UI widgets, mock emitters stay .NET). Full duplex channels (`open_channel`) are on the roadmap; today expose long-lived streams via `invoke_stream`.
|
|
483
|
+
|
|
484
|
+
## License
|
|
485
|
+
|
|
486
|
+
Apache-2.0.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
bowire_plugin/__init__.py,sha256=C6y5s9C3NeTTsukJZ6bE-FA6_YZfzV3FnM6iUyaT6lg,1832
|
|
2
|
+
bowire_plugin/_http.py,sha256=0kwNM6dIikr4b7unABl403fJYBRE8EIEbbV1KjSeEtM,5034
|
|
3
|
+
bowire_plugin/_manual_entry.py,sha256=JAsRKjmGIVoH4RSn2FM_eXJsoLJnBUzgGqy_vVK8zLw,5642
|
|
4
|
+
bowire_plugin/_models.py,sha256=aGWpqIpF9sJIzENbE9X16LT0tYJ5UxDihXKZZmQQvEk,5997
|
|
5
|
+
bowire_plugin/_plugin.py,sha256=OPoqHOb7QmUKWZ7WQ-27KZkAxDgY2c494Fi09EqYFXU,3414
|
|
6
|
+
bowire_plugin/_runtime.py,sha256=hN62Mz0X7XGZkPotRoYPekdsDI3PlIcOTN2aAfQG2o4,10846
|
|
7
|
+
bowire_plugin/_settings.py,sha256=fZE4LTHFoL4uJUJbpzl8IB4aOP9c2WUH19TRfKOPHwo,7491
|
|
8
|
+
bowire_plugin-0.3.0.dist-info/METADATA,sha256=QBPmI47bCTJLZ1XnBinxawfDr_ZC-L1l5L3MbdW79y8,25311
|
|
9
|
+
bowire_plugin-0.3.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
10
|
+
bowire_plugin-0.3.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
11
|
+
bowire_plugin-0.3.0.dist-info/RECORD,,
|