mindwire 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.
- mindwire-0.1.0/.gitignore +92 -0
- mindwire-0.1.0/LICENSE +201 -0
- mindwire-0.1.0/PKG-INFO +188 -0
- mindwire-0.1.0/README.md +156 -0
- mindwire-0.1.0/RELEASING.md +52 -0
- mindwire-0.1.0/pyproject.toml +60 -0
- mindwire-0.1.0/src/mindwire/__init__.py +29 -0
- mindwire-0.1.0/src/mindwire/_client.py +277 -0
- mindwire-0.1.0/src/mindwire/_errors.py +32 -0
- mindwire-0.1.0/src/mindwire/_runs.py +135 -0
- mindwire-0.1.0/src/mindwire/_transport.py +166 -0
- mindwire-0.1.0/src/mindwire/_types.py +39 -0
- mindwire-0.1.0/src/mindwire/_version.py +1 -0
- mindwire-0.1.0/src/mindwire/py.typed +0 -0
- mindwire-0.1.0/tests/test_client.py +286 -0
- mindwire-0.1.0/tests/test_runtime.py +92 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# ---- Node / TypeScript ----
|
|
2
|
+
node_modules/
|
|
3
|
+
dist/
|
|
4
|
+
build/
|
|
5
|
+
out/
|
|
6
|
+
*.tsbuildinfo
|
|
7
|
+
.turbo/
|
|
8
|
+
coverage/
|
|
9
|
+
.eslintcache
|
|
10
|
+
|
|
11
|
+
# Package manager artifacts (keep ONE lockfile per repo; see below)
|
|
12
|
+
.pnp.*
|
|
13
|
+
.yarn/*
|
|
14
|
+
!.yarn/patches
|
|
15
|
+
!.yarn/releases
|
|
16
|
+
next-env.d.ts
|
|
17
|
+
.next/
|
|
18
|
+
|
|
19
|
+
# ---- Go ----
|
|
20
|
+
# Compiled binaries / build output
|
|
21
|
+
/packages/daemon/dist/
|
|
22
|
+
/packages/daemon/bin/
|
|
23
|
+
/packages/daemon/.dev/
|
|
24
|
+
*.exe
|
|
25
|
+
*.test
|
|
26
|
+
*.out
|
|
27
|
+
# Go workspace file (local, machine-specific)
|
|
28
|
+
go.work
|
|
29
|
+
go.work.sum
|
|
30
|
+
|
|
31
|
+
# ---- Fumadocs generated content ----
|
|
32
|
+
# The .source cache and the four generated reference trees are rebuilt by `bun run gen:reference`
|
|
33
|
+
# + the fumadocs-mdx step. Ignore ONLY the generated artifacts so the hand-authored pages in the same
|
|
34
|
+
# reference/ folder (meta.json, agents/meta.json, agents/{claude,codex}.mdx) stay tracked.
|
|
35
|
+
/apps/web/.source/
|
|
36
|
+
/apps/web/content/docs/reference/rest/
|
|
37
|
+
/apps/web/content/docs/reference/sdk-ts/
|
|
38
|
+
/apps/web/content/docs/reference/sdk-go/
|
|
39
|
+
/apps/web/content/docs/reference/agents/index.mdx
|
|
40
|
+
|
|
41
|
+
# ---- Daemon runtime state ----
|
|
42
|
+
agent-state.json
|
|
43
|
+
.mindwire-state.json
|
|
44
|
+
*.log
|
|
45
|
+
|
|
46
|
+
# ---- Prebuilt daemon packages + local dev binary (from packages/sdk/scripts/build-daemon.mjs) ----
|
|
47
|
+
/packages/sdk/npm/
|
|
48
|
+
/packages/sdk/bin/
|
|
49
|
+
|
|
50
|
+
# ---- Env / secrets ----
|
|
51
|
+
.env
|
|
52
|
+
.env.*
|
|
53
|
+
!.env.example
|
|
54
|
+
.mindwire-dev-token
|
|
55
|
+
|
|
56
|
+
# ---- OS ----
|
|
57
|
+
.DS_Store
|
|
58
|
+
Thumbs.db
|
|
59
|
+
desktop.ini
|
|
60
|
+
|
|
61
|
+
# ---- Editors / IDEs ----
|
|
62
|
+
.idea/
|
|
63
|
+
.vscode/*
|
|
64
|
+
!.vscode/extensions.json
|
|
65
|
+
!.vscode/settings.json.example
|
|
66
|
+
*.swp
|
|
67
|
+
*~
|
|
68
|
+
|
|
69
|
+
# ---- Logs / temp ----
|
|
70
|
+
*.tmp
|
|
71
|
+
tmp/
|
|
72
|
+
.cache/
|
|
73
|
+
|
|
74
|
+
# Preview/console local state — Better Auth SQLite (real accounts + password hashes). Never commit.
|
|
75
|
+
apps/console/.data/
|
|
76
|
+
packages/daemon/catalog.json
|
|
77
|
+
|
|
78
|
+
# Apple app captures and local tooling output.
|
|
79
|
+
apps/apple/artifacts/app-store/
|
|
80
|
+
apps/apple/artifacts/Mindwire-App-Store.zip
|
|
81
|
+
apps/apple/artifacts/launch-film-*/
|
|
82
|
+
**/__pycache__/
|
|
83
|
+
|
|
84
|
+
# Python SDK development and packaging.
|
|
85
|
+
.venv/
|
|
86
|
+
.pytest_cache/
|
|
87
|
+
.mypy_cache/
|
|
88
|
+
.ruff_cache/
|
|
89
|
+
*.egg-info/
|
|
90
|
+
|
|
91
|
+
# Local push service account and migration exports; never build or commit.
|
|
92
|
+
.secrets/
|
mindwire-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 The mindwire authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
mindwire-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mindwire
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for building products with MindWire's shared coding-agent runtime.
|
|
5
|
+
Project-URL: Homepage, https://mindwire.sh
|
|
6
|
+
Project-URL: Documentation, https://github.com/oblien/mindwire/tree/main/packages/python
|
|
7
|
+
Project-URL: Repository, https://github.com/oblien/mindwire
|
|
8
|
+
Project-URL: Issues, https://github.com/oblien/mindwire/issues
|
|
9
|
+
Author: Oblien
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,claude-code,codex,mindwire,sdk
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
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
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: httpx<1,>=0.28.1
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: build<2,>=1.2; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy<2,>=1.18; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest<10,>=8; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff<1,>=0.14; extra == 'dev'
|
|
30
|
+
Requires-Dist: twine<8,>=7; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# MindWire for Python
|
|
34
|
+
|
|
35
|
+
Build products with the same agent runtime used by MindWire's TypeScript and Go
|
|
36
|
+
SDKs. This initial Python SDK connects to an **existing local or remote runtime**
|
|
37
|
+
over HTTP and server-sent events. It includes synchronous and asynchronous clients,
|
|
38
|
+
turns, streaming, run snapshots, cancellation, interaction responses and conversation
|
|
39
|
+
handoffs. The low-level `request()` method exposes the rest of the shared API.
|
|
40
|
+
|
|
41
|
+
Requires Python 3.10 or newer. Licensed under Apache-2.0.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
Once the first release is published:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pip install mindwire
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For development from this repository:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
python -m pip install -e './packages/python[dev]'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Connect and run
|
|
58
|
+
|
|
59
|
+
Start or connect to a [MindWire runtime](https://mindwire.sh/docs/guides/quickstart)
|
|
60
|
+
and authenticate its agent. Set `MINDWIRE_BASE_URL` and `MINDWIRE_TOKEN` in your
|
|
61
|
+
application environment. A local runtime usually listens on `http://127.0.0.1:8790`;
|
|
62
|
+
use its configured bearer token. Use HTTPS for connections across the network.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import os
|
|
66
|
+
from mindwire import Mindwire
|
|
67
|
+
|
|
68
|
+
with Mindwire(
|
|
69
|
+
base_url=os.environ["MINDWIRE_BASE_URL"],
|
|
70
|
+
token=os.environ["MINDWIRE_TOKEN"],
|
|
71
|
+
agent="codex",
|
|
72
|
+
) as mw:
|
|
73
|
+
run = mw.turn(
|
|
74
|
+
chat_id="launch",
|
|
75
|
+
message="Read brief.md and write a launch plan.",
|
|
76
|
+
cwd="/workspace/product", # A directory on the runtime's computer.
|
|
77
|
+
)
|
|
78
|
+
for event in run:
|
|
79
|
+
if event["type"] == "text":
|
|
80
|
+
print(event.get("text", ""), end="", flush=True)
|
|
81
|
+
outcome = run.wait()
|
|
82
|
+
print(outcome["run"]["status"])
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`run.wait()` consumes the stream and checks the final run record. Calling it after
|
|
86
|
+
iteration replays the stream internally to collect its result. It raises
|
|
87
|
+
`RunFailedError` for errors, cancellation, or a stream ending before a terminal
|
|
88
|
+
status. Pass `throw_on_error=False` to inspect that outcome yourself.
|
|
89
|
+
|
|
90
|
+
The Python SDK does not install, launch or provision the runtime in this release.
|
|
91
|
+
Local, Docker, SSH and cloud environments work when you provide a reachable
|
|
92
|
+
runtime URL and token. Harness authentication and capability support are owned by
|
|
93
|
+
the runtime; the SDK does not sign in to an agent on your behalf.
|
|
94
|
+
|
|
95
|
+
## Async applications
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import asyncio
|
|
99
|
+
import os
|
|
100
|
+
from mindwire import AsyncMindwire
|
|
101
|
+
|
|
102
|
+
async def main():
|
|
103
|
+
async with AsyncMindwire(
|
|
104
|
+
base_url=os.environ["MINDWIRE_BASE_URL"],
|
|
105
|
+
token=os.environ["MINDWIRE_TOKEN"],
|
|
106
|
+
agent="claude-code",
|
|
107
|
+
) as mw:
|
|
108
|
+
run = await mw.turn(chat_id="research", message="Summarize this project.")
|
|
109
|
+
async for event in run:
|
|
110
|
+
if event["type"] == "text":
|
|
111
|
+
print(event.get("text", ""), end="", flush=True)
|
|
112
|
+
await run.wait()
|
|
113
|
+
|
|
114
|
+
asyncio.run(main())
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Runs and streams
|
|
118
|
+
|
|
119
|
+
- `mw.turn(...)` starts a turn. Supply `request_id` and retain it when retrying an
|
|
120
|
+
unacknowledged creation request on runtimes supporting `turnRequestVersion`.
|
|
121
|
+
- `mw.run(run_id)` and `mw.latest_run(chat_id)` reattach to existing work.
|
|
122
|
+
- `run.snapshot()` reads current output and its cursor;
|
|
123
|
+
`run.stream(after=snapshot["sequence"])` follows newer events on runtimes that
|
|
124
|
+
advertise cursor support.
|
|
125
|
+
- `run.cancel()` stops execution. Closing a client or event stream only closes
|
|
126
|
+
observation; the runtime continues admitted work while it remains running.
|
|
127
|
+
- `run.respond({...})` answers a supported interaction using the shared API payload.
|
|
128
|
+
- `mw.turn(..., mode="resolve", resolve={"maxIterations": 5})` runs bounded
|
|
129
|
+
continuation when the selected harness supports it.
|
|
130
|
+
|
|
131
|
+
To stop reading early, explicitly close the stream using `contextlib.closing`
|
|
132
|
+
(sync) or `contextlib.aclosing` (async). For example:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from contextlib import closing
|
|
136
|
+
|
|
137
|
+
with closing(run.stream()) as stream:
|
|
138
|
+
for event in stream:
|
|
139
|
+
if event["type"] == "interaction":
|
|
140
|
+
break
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Unary requests have a configurable timeout (`timeout=120.0`, in seconds). SSE
|
|
144
|
+
streams have no read timeout so an agent can continue working through idle periods.
|
|
145
|
+
The client does not automatically retry turns or reconnect interrupted streams.
|
|
146
|
+
|
|
147
|
+
## Shared API and handoffs
|
|
148
|
+
|
|
149
|
+
`mw.request(method, path, json=..., params=...)` returns the parsed response body.
|
|
150
|
+
It accepts runtime API paths, not arbitrary URLs. All payloads, response objects,
|
|
151
|
+
turn `options` and event fields retain the shared API's **camelCase** field names.
|
|
152
|
+
Python method parameters use snake_case.
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
bots = mw.request("GET", "/bots")
|
|
156
|
+
config = mw.request("GET", "/config", params={"agent": "codex"})
|
|
157
|
+
preview = mw.preview_handoff("launch")
|
|
158
|
+
handoff = mw.handoff("launch", {
|
|
159
|
+
"newChatId": "launch-review",
|
|
160
|
+
"requestId": "launch-review-001",
|
|
161
|
+
"targetAgentId": "saved-claude-profile-id",
|
|
162
|
+
"task": "Review the plan and identify missing steps.",
|
|
163
|
+
})
|
|
164
|
+
review_run = mw.run(handoff["run"]["id"])
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Handoffs require a compatible runtime, an eligible source conversation and a saved
|
|
168
|
+
destination agent profile. Use `preview` to inspect the context before submission;
|
|
169
|
+
see the [handoff guide](https://mindwire.sh/docs/guides/handoffs) for field semantics.
|
|
170
|
+
|
|
171
|
+
`APIError` preserves `status`, `method`, `path` and the server's `body`.
|
|
172
|
+
`ConnectionError` and `TimeoutError` identify transport failures. All inherit
|
|
173
|
+
from `MindwireError`. Errors do not expose the configured bearer token.
|
|
174
|
+
|
|
175
|
+
## Development and releases
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
cd packages/python
|
|
179
|
+
python -m pytest
|
|
180
|
+
ruff check src tests
|
|
181
|
+
mypy src
|
|
182
|
+
python -m build
|
|
183
|
+
python -m twine check --strict dist/*
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The Python package has its own version, initially `0.1.0`. The runtime and
|
|
187
|
+
TypeScript package keep their existing release cycle. See [RELEASING.md](RELEASING.md)
|
|
188
|
+
for PyPI setup and publishing.
|
mindwire-0.1.0/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# MindWire for Python
|
|
2
|
+
|
|
3
|
+
Build products with the same agent runtime used by MindWire's TypeScript and Go
|
|
4
|
+
SDKs. This initial Python SDK connects to an **existing local or remote runtime**
|
|
5
|
+
over HTTP and server-sent events. It includes synchronous and asynchronous clients,
|
|
6
|
+
turns, streaming, run snapshots, cancellation, interaction responses and conversation
|
|
7
|
+
handoffs. The low-level `request()` method exposes the rest of the shared API.
|
|
8
|
+
|
|
9
|
+
Requires Python 3.10 or newer. Licensed under Apache-2.0.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Once the first release is published:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pip install mindwire
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For development from this repository:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
python -m pip install -e './packages/python[dev]'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Connect and run
|
|
26
|
+
|
|
27
|
+
Start or connect to a [MindWire runtime](https://mindwire.sh/docs/guides/quickstart)
|
|
28
|
+
and authenticate its agent. Set `MINDWIRE_BASE_URL` and `MINDWIRE_TOKEN` in your
|
|
29
|
+
application environment. A local runtime usually listens on `http://127.0.0.1:8790`;
|
|
30
|
+
use its configured bearer token. Use HTTPS for connections across the network.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import os
|
|
34
|
+
from mindwire import Mindwire
|
|
35
|
+
|
|
36
|
+
with Mindwire(
|
|
37
|
+
base_url=os.environ["MINDWIRE_BASE_URL"],
|
|
38
|
+
token=os.environ["MINDWIRE_TOKEN"],
|
|
39
|
+
agent="codex",
|
|
40
|
+
) as mw:
|
|
41
|
+
run = mw.turn(
|
|
42
|
+
chat_id="launch",
|
|
43
|
+
message="Read brief.md and write a launch plan.",
|
|
44
|
+
cwd="/workspace/product", # A directory on the runtime's computer.
|
|
45
|
+
)
|
|
46
|
+
for event in run:
|
|
47
|
+
if event["type"] == "text":
|
|
48
|
+
print(event.get("text", ""), end="", flush=True)
|
|
49
|
+
outcome = run.wait()
|
|
50
|
+
print(outcome["run"]["status"])
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`run.wait()` consumes the stream and checks the final run record. Calling it after
|
|
54
|
+
iteration replays the stream internally to collect its result. It raises
|
|
55
|
+
`RunFailedError` for errors, cancellation, or a stream ending before a terminal
|
|
56
|
+
status. Pass `throw_on_error=False` to inspect that outcome yourself.
|
|
57
|
+
|
|
58
|
+
The Python SDK does not install, launch or provision the runtime in this release.
|
|
59
|
+
Local, Docker, SSH and cloud environments work when you provide a reachable
|
|
60
|
+
runtime URL and token. Harness authentication and capability support are owned by
|
|
61
|
+
the runtime; the SDK does not sign in to an agent on your behalf.
|
|
62
|
+
|
|
63
|
+
## Async applications
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
import os
|
|
68
|
+
from mindwire import AsyncMindwire
|
|
69
|
+
|
|
70
|
+
async def main():
|
|
71
|
+
async with AsyncMindwire(
|
|
72
|
+
base_url=os.environ["MINDWIRE_BASE_URL"],
|
|
73
|
+
token=os.environ["MINDWIRE_TOKEN"],
|
|
74
|
+
agent="claude-code",
|
|
75
|
+
) as mw:
|
|
76
|
+
run = await mw.turn(chat_id="research", message="Summarize this project.")
|
|
77
|
+
async for event in run:
|
|
78
|
+
if event["type"] == "text":
|
|
79
|
+
print(event.get("text", ""), end="", flush=True)
|
|
80
|
+
await run.wait()
|
|
81
|
+
|
|
82
|
+
asyncio.run(main())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Runs and streams
|
|
86
|
+
|
|
87
|
+
- `mw.turn(...)` starts a turn. Supply `request_id` and retain it when retrying an
|
|
88
|
+
unacknowledged creation request on runtimes supporting `turnRequestVersion`.
|
|
89
|
+
- `mw.run(run_id)` and `mw.latest_run(chat_id)` reattach to existing work.
|
|
90
|
+
- `run.snapshot()` reads current output and its cursor;
|
|
91
|
+
`run.stream(after=snapshot["sequence"])` follows newer events on runtimes that
|
|
92
|
+
advertise cursor support.
|
|
93
|
+
- `run.cancel()` stops execution. Closing a client or event stream only closes
|
|
94
|
+
observation; the runtime continues admitted work while it remains running.
|
|
95
|
+
- `run.respond({...})` answers a supported interaction using the shared API payload.
|
|
96
|
+
- `mw.turn(..., mode="resolve", resolve={"maxIterations": 5})` runs bounded
|
|
97
|
+
continuation when the selected harness supports it.
|
|
98
|
+
|
|
99
|
+
To stop reading early, explicitly close the stream using `contextlib.closing`
|
|
100
|
+
(sync) or `contextlib.aclosing` (async). For example:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from contextlib import closing
|
|
104
|
+
|
|
105
|
+
with closing(run.stream()) as stream:
|
|
106
|
+
for event in stream:
|
|
107
|
+
if event["type"] == "interaction":
|
|
108
|
+
break
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Unary requests have a configurable timeout (`timeout=120.0`, in seconds). SSE
|
|
112
|
+
streams have no read timeout so an agent can continue working through idle periods.
|
|
113
|
+
The client does not automatically retry turns or reconnect interrupted streams.
|
|
114
|
+
|
|
115
|
+
## Shared API and handoffs
|
|
116
|
+
|
|
117
|
+
`mw.request(method, path, json=..., params=...)` returns the parsed response body.
|
|
118
|
+
It accepts runtime API paths, not arbitrary URLs. All payloads, response objects,
|
|
119
|
+
turn `options` and event fields retain the shared API's **camelCase** field names.
|
|
120
|
+
Python method parameters use snake_case.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
bots = mw.request("GET", "/bots")
|
|
124
|
+
config = mw.request("GET", "/config", params={"agent": "codex"})
|
|
125
|
+
preview = mw.preview_handoff("launch")
|
|
126
|
+
handoff = mw.handoff("launch", {
|
|
127
|
+
"newChatId": "launch-review",
|
|
128
|
+
"requestId": "launch-review-001",
|
|
129
|
+
"targetAgentId": "saved-claude-profile-id",
|
|
130
|
+
"task": "Review the plan and identify missing steps.",
|
|
131
|
+
})
|
|
132
|
+
review_run = mw.run(handoff["run"]["id"])
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Handoffs require a compatible runtime, an eligible source conversation and a saved
|
|
136
|
+
destination agent profile. Use `preview` to inspect the context before submission;
|
|
137
|
+
see the [handoff guide](https://mindwire.sh/docs/guides/handoffs) for field semantics.
|
|
138
|
+
|
|
139
|
+
`APIError` preserves `status`, `method`, `path` and the server's `body`.
|
|
140
|
+
`ConnectionError` and `TimeoutError` identify transport failures. All inherit
|
|
141
|
+
from `MindwireError`. Errors do not expose the configured bearer token.
|
|
142
|
+
|
|
143
|
+
## Development and releases
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
cd packages/python
|
|
147
|
+
python -m pytest
|
|
148
|
+
ruff check src tests
|
|
149
|
+
mypy src
|
|
150
|
+
python -m build
|
|
151
|
+
python -m twine check --strict dist/*
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The Python package has its own version, initially `0.1.0`. The runtime and
|
|
155
|
+
TypeScript package keep their existing release cycle. See [RELEASING.md](RELEASING.md)
|
|
156
|
+
for PyPI setup and publishing.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Publish the Python SDK
|
|
2
|
+
|
|
3
|
+
The distribution is named `mindwire`, with import namespace `mindwire`. A name
|
|
4
|
+
becomes claimed only after the first successful PyPI upload. Pending publishers
|
|
5
|
+
do not reserve names; check availability before the first release.
|
|
6
|
+
|
|
7
|
+
## One-time PyPI account setup
|
|
8
|
+
|
|
9
|
+
1. [Sign in or register](https://pypi.org/account/login/) on PyPI, verify your email
|
|
10
|
+
and complete its two-factor authentication setup.
|
|
11
|
+
2. Open [Publishing](https://pypi.org/manage/account/publishing/) and add a pending
|
|
12
|
+
**GitHub** publisher with these exact values:
|
|
13
|
+
|
|
14
|
+
| Field | Value |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| PyPI project name | `mindwire` |
|
|
17
|
+
| Owner | `oblien` |
|
|
18
|
+
| Repository name | `mindwire` |
|
|
19
|
+
| Workflow name | `publish-python.yml` |
|
|
20
|
+
| Environment name | `pypi` |
|
|
21
|
+
|
|
22
|
+
3. The matching GitHub environment is `pypi`. Configure its deployment permissions
|
|
23
|
+
under the [repository environments](https://github.com/oblien/mindwire/settings/environments).
|
|
24
|
+
|
|
25
|
+
Publishing uses GitHub's OIDC identity, so no PyPI password or persistent API token
|
|
26
|
+
is needed in GitHub secrets or source files. The first upload creates the PyPI
|
|
27
|
+
project in the account that configured the pending publisher.
|
|
28
|
+
|
|
29
|
+
## Publish
|
|
30
|
+
|
|
31
|
+
1. Update `__version__` in `src/mindwire/_version.py`. Package metadata, the public
|
|
32
|
+
version and the User-Agent all use that value.
|
|
33
|
+
2. Commit and push the reviewed SDK changes to `main`.
|
|
34
|
+
3. Open [Python SDK workflow](https://github.com/oblien/mindwire/actions/workflows/publish-python.yml).
|
|
35
|
+
Choose **Run workflow**, select `main`, and enable **Publish to PyPI**.
|
|
36
|
+
|
|
37
|
+
The workflow tests Python 3.10 and 3.14, builds a source archive and universal
|
|
38
|
+
Python wheel, validates their metadata, installs the built wheel and source
|
|
39
|
+
archive in clean environments, and tests against a fresh Go runtime. Only the
|
|
40
|
+
publish job has OIDC permission. It uploads the already-tested artifacts to PyPI
|
|
41
|
+
and then checks that a clean `pip install mindwire==VERSION` succeeds from PyPI.
|
|
42
|
+
|
|
43
|
+
Ordinary pushes and pull requests run checks without publishing. Manual runs with
|
|
44
|
+
the publish option disabled also only validate. Publication is restricted to the
|
|
45
|
+
repository's `main` branch. Bump the Python version for subsequent releases; PyPI
|
|
46
|
+
does not allow replacing previously uploaded distributions.
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
gh workflow run publish-python.yml --ref main -f publish=true
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
See [PyPI's Trusted Publishing documentation](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/).
|