wakeshift 0.2.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.
- wakeshift-0.2.0/.github/workflows/ci.yml +30 -0
- wakeshift-0.2.0/.github/workflows/release.yml +58 -0
- wakeshift-0.2.0/.gitignore +6 -0
- wakeshift-0.2.0/.source-commit +1 -0
- wakeshift-0.2.0/CHANGELOG.md +25 -0
- wakeshift-0.2.0/CONTRIBUTING.md +18 -0
- wakeshift-0.2.0/LICENSE +202 -0
- wakeshift-0.2.0/NOTICE +4 -0
- wakeshift-0.2.0/PKG-INFO +188 -0
- wakeshift-0.2.0/README.md +157 -0
- wakeshift-0.2.0/SECURITY.md +7 -0
- wakeshift-0.2.0/pyproject.toml +69 -0
- wakeshift-0.2.0/src/wakeshift/__init__.py +100 -0
- wakeshift-0.2.0/src/wakeshift/client.py +717 -0
- wakeshift-0.2.0/src/wakeshift/errors.py +27 -0
- wakeshift-0.2.0/src/wakeshift/events.py +910 -0
- wakeshift-0.2.0/src/wakeshift/guest.py +620 -0
- wakeshift-0.2.0/src/wakeshift/harness.py +83 -0
- wakeshift-0.2.0/src/wakeshift/key.py +146 -0
- wakeshift-0.2.0/src/wakeshift/limits.py +98 -0
- wakeshift-0.2.0/src/wakeshift/py.typed +0 -0
- wakeshift-0.2.0/src/wakeshift/retry.py +32 -0
- wakeshift-0.2.0/src/wakeshift/sealed.py +49 -0
- wakeshift-0.2.0/src/wakeshift/spec.py +73 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ci-${{ github.event.pull_request.number || github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
test:
|
|
17
|
+
name: Lint, type-check, test and build
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
timeout-minutes: 15
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
22
|
+
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
|
|
23
|
+
- run: uv sync --locked
|
|
24
|
+
- run: uv run ruff check
|
|
25
|
+
- run: uv run ruff format --check
|
|
26
|
+
- run: uv run pyright
|
|
27
|
+
# The oldest Python it supports, and the newest.
|
|
28
|
+
- run: uv run --locked --python 3.10 --isolated pytest -q
|
|
29
|
+
- run: uv run --locked --python 3.13 --isolated pytest -q
|
|
30
|
+
- run: uv build
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Pushing a tag v<version> (the version in pyproject.toml) publishes that
|
|
4
|
+
# version to PyPI, through trusted publishing: no token is stored here.
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags: ["v*"]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: release-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: false
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
name: Test and build
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
timeout-minutes: 15
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
23
|
+
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
|
|
24
|
+
- name: The tag matches the package's version
|
|
25
|
+
env:
|
|
26
|
+
TAG: ${{ github.ref_name }}
|
|
27
|
+
run: |
|
|
28
|
+
version=$(uv version --short)
|
|
29
|
+
if [ "$TAG" != "v$version" ]; then
|
|
30
|
+
echo "tag $TAG doesn't match the version in pyproject.toml ($version)" >&2
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
- run: uv sync --locked
|
|
34
|
+
- run: uv run --locked --python 3.10 --isolated pytest -q
|
|
35
|
+
- run: uv run --locked --python 3.13 --isolated pytest -q
|
|
36
|
+
- run: uv build
|
|
37
|
+
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
38
|
+
with:
|
|
39
|
+
name: dist
|
|
40
|
+
path: dist/
|
|
41
|
+
if-no-files-found: error
|
|
42
|
+
|
|
43
|
+
publish:
|
|
44
|
+
name: Publish to PyPI
|
|
45
|
+
needs: build
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
timeout-minutes: 10
|
|
48
|
+
environment:
|
|
49
|
+
name: pypi
|
|
50
|
+
url: https://pypi.org/project/wakeshift/
|
|
51
|
+
permissions:
|
|
52
|
+
id-token: write
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
55
|
+
with:
|
|
56
|
+
name: dist
|
|
57
|
+
path: dist/
|
|
58
|
+
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b239914054fd776f55a3fef455953be597138376
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (2026-10-26)
|
|
4
|
+
|
|
5
|
+
### Breaking
|
|
6
|
+
|
|
7
|
+
Sign in with Wakeshift is gone: Wakeshift no longer gives apps grants in people's own workspaces. Your app identifies its own users, with `GuestAuth` or its own sign-in, and acts for the agents in the workspaces it keeps (`wake.workspace`, `wake.add_agent`, `wake.check_agent`). Topics, events and `GuestAuth` work as before.
|
|
8
|
+
|
|
9
|
+
Removed:
|
|
10
|
+
|
|
11
|
+
- `WakeshiftSignIn` and `SignInError`.
|
|
12
|
+
- `Agent` and `Claims`.
|
|
13
|
+
- On `Wakeshift`: `protected_resource()`, `challenge()`, `verify_access_token()`, `exchange()`, `pkce()`, `authorize_url()`, `sign_in()`, `refresh()` and the `mcp_url` argument and attribute.
|
|
14
|
+
- `SignedIn` and `Connection`.
|
|
15
|
+
- `serve_events`' `agent` argument, the `agent` argument of `wake.call`, `event.subscribe` and `event.unsubscribe`, and `Call.agent_token`.
|
|
16
|
+
- Wakeshift refuses a manifest with `accounts: "wakeshift"`, `workspace` or `agent.redirect_uris` (`bad_manifest`).
|
|
17
|
+
|
|
18
|
+
`serve_events` is renamed `attach`, the one call that attaches Wakeshift to your MCP server. Its `user` argument is replaced by `identify`, which returns an `Identity` (`Identity(user=…)`, exported from `wakeshift`). It behaves as before:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
# before
|
|
22
|
+
wake.serve_events(server, user=lambda ctx: my_user(ctx))
|
|
23
|
+
# now
|
|
24
|
+
wake.attach(server, identify=lambda ctx: Identity(user=my_user(ctx)))
|
|
25
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
This repository is generated from Wakeshift's main repository.
|
|
4
|
+
|
|
5
|
+
We read every issue. Report bugs, ask questions and suggest changes in this repository's issues.
|
|
6
|
+
|
|
7
|
+
Pull requests are welcome; we don't guarantee we'll accept every one. An accepted pull request is applied to Wakeshift's main repository, keeping you as the commit's author, and arrives here with the next publish; we close the pull request here with a link to it.
|
|
8
|
+
|
|
9
|
+
Before you open one:
|
|
10
|
+
|
|
11
|
+
- Run `uv run ruff check`, `uv run pyright` and `uv run pytest`.
|
|
12
|
+
- Keep the change focused, and say what it fixes or adds.
|
|
13
|
+
- Don't include keys, tokens or other secrets, including in tests.
|
|
14
|
+
- Change only the code: files this repository's export generates (`.source-commit`) are updated when it's published.
|
|
15
|
+
|
|
16
|
+
Report a security problem privately to support@wakeshift.ai, not in an issue: see [SECURITY](SECURITY.md).
|
|
17
|
+
|
|
18
|
+
By contributing, you agree your contribution is licensed under the Apache License 2.0.
|
wakeshift-0.2.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.
|
wakeshift-0.2.0/NOTICE
ADDED
wakeshift-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: wakeshift
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Wake AI agents when your app's events happen: Wakeshift's SDK for MCP servers in Python
|
|
5
|
+
Project-URL: Homepage, https://wakeshift.ai
|
|
6
|
+
Project-URL: Documentation, https://wakeshift.ai/docs
|
|
7
|
+
Project-URL: Source, https://github.com/wakeshift/wakeshift-python
|
|
8
|
+
Project-URL: Issues, https://github.com/wakeshift/wakeshift-python/issues
|
|
9
|
+
Author-email: "Clawvisor Inc." <support@wakeshift.ai>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: NOTICE
|
|
13
|
+
Keywords: agents,events,mcp,wakeshift
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Framework :: AsyncIO
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: cryptography>=42
|
|
25
|
+
Requires-Dist: httpx>=0.27
|
|
26
|
+
Requires-Dist: mcp-types<3,>=2.3
|
|
27
|
+
Requires-Dist: mcp<3,>=2.3
|
|
28
|
+
Requires-Dist: pydantic>=2.7
|
|
29
|
+
Requires-Dist: starlette>=0.40
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# wakeshift
|
|
33
|
+
|
|
34
|
+
Let agents subscribe to things in your app. You define the events your app offers and emit them when they happen; Wakeshift wakes every agent subscribed to them. Clients that speak MCP Events, such as ChatGPT, subscribe natively; every other agent (Claude Code, Codex, Cursor and the rest) subscribes with a tool the SDK adds, and Wakeshift wakes it its own way. You write no subscribe tool and handle no harnesses.
|
|
35
|
+
|
|
36
|
+
Python 3.10 or later, on the official MCP Python SDK (`mcp` 2.3 or later). The same API as the Node and Go SDKs.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
pip install wakeshift
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or `uv add wakeshift`.
|
|
45
|
+
|
|
46
|
+
## Quickstart: events
|
|
47
|
+
|
|
48
|
+
Register an app in the Wakeshift console (Build) and put its key in `WAKESHIFT_KEY`. The SDK talks to `https://app.wakeshift.ai` unless `WAKESHIFT_CORE` names another address.
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import os
|
|
52
|
+
|
|
53
|
+
from mcp.server.mcpserver import MCPServer
|
|
54
|
+
from pydantic import BaseModel
|
|
55
|
+
|
|
56
|
+
from wakeshift import GuestAuth, Wakeshift
|
|
57
|
+
|
|
58
|
+
wake = Wakeshift(os.environ["WAKESHIFT_KEY"])
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Channel(BaseModel):
|
|
62
|
+
channel: str
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class Message(BaseModel):
|
|
66
|
+
sender: str
|
|
67
|
+
text: str
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
message = wake.define_event(
|
|
71
|
+
"chat.message",
|
|
72
|
+
description="A new message in a channel",
|
|
73
|
+
args=Channel,
|
|
74
|
+
payload=Message,
|
|
75
|
+
text=lambda m, a: f"{m.sender} in #{a.channel}: {m.text}",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class Table(BaseModel):
|
|
80
|
+
table: str
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class Turn(BaseModel):
|
|
84
|
+
hole: list[str]
|
|
85
|
+
to_call: int
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# A personal event: each subscription belongs to its subscriber, and an
|
|
89
|
+
# occurrence goes to one of them, so it can carry their own private view.
|
|
90
|
+
turn = wake.define_event(
|
|
91
|
+
"game.turn",
|
|
92
|
+
description="It's your move at a table",
|
|
93
|
+
args=Table,
|
|
94
|
+
payload=Turn,
|
|
95
|
+
text=lambda t, a: f"Your move at {a.table}: {t.to_call} to call",
|
|
96
|
+
personal=True,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
server = MCPServer("chat")
|
|
100
|
+
wake.attach(server) # define every event first
|
|
101
|
+
|
|
102
|
+
# Guests: MCP clients sign in with no account, each in its own workspace.
|
|
103
|
+
guests = GuestAuth(wake, "https://chat.example.com/mcp")
|
|
104
|
+
app = guests.wrap(server.streamable_http_app()) # run with uvicorn
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# When something happens:
|
|
108
|
+
async def on_message(channel: str, sender: str, text: str) -> None:
|
|
109
|
+
await message.emit({"channel": channel}, {"sender": sender, "text": text})
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
async def on_turn(table: str, player: str, hole: list[str], to_call: int) -> None:
|
|
113
|
+
await turn.emit({"table": table}, {"hole": hole, "to_call": to_call}, to=player)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
That's all. An agent subscribes to `chat.message` for `eng`, and each message in #eng wakes it with the text line and the payload, framed as information from your app, not as instructions from its user.
|
|
117
|
+
|
|
118
|
+
- **`wake.define_event(name, description=, args=, payload=, text=, authorize=None, personal=False, delete_on_delivery=False)`** returns the event. `args` and `payload` are pydantic models or JSON Schemas. `args` is what a subscriber picks; its required string, integer and boolean fields route occurrences, so their values are lowercase IDs (a-z 0-9 . _ -), and an optional one filters on the payload field of the same name. `text(payload, args)` is the line the agent reads first. `authorize(subscriber, args)` (sync or async) decides who may subscribe. With `delete_on_delivery=True`, Wakeshift deletes each occurrence's text and payload once it's delivered.
|
|
119
|
+
- **`await event.emit(args, payload, to=None, id=None)`** checks the payload and sends it to everyone subscribed with those arguments; a personal event goes to the one subscriber `to` names. `id` makes retries emit once.
|
|
120
|
+
- **`wake.attach(server, identify=None)`** attaches Wakeshift to your MCP server. Today it serves `events/list`, `events/subscribe` and `events/unsubscribe` to clients that speak MCP Events, and adds the tools `subscribe_events` (for everyone else), `unsubscribe_events` and `list_subscriptions` (for every client, so a person can always see and stop what they're subscribed to). `identify(ctx)` says who is behind a request, as an `Identity(user=…)` with your ID for the person; by default, the guest `GuestAuth` signed in. Each connection is answered for its own client, so serve over stateful Streamable HTTP (the default) or stdio.
|
|
121
|
+
- **`await event.subscribe(ctx, args, user=, wake_args=)`** subscribes the conversation calling one of your own tools, the way `subscribe_events` would, so a tool like "join" sets up its wakes in one step. `result(text)` is your tool's text with what the agent needs added. **`await event.unsubscribe(ctx, args, user=, wake_args=)`** ends the calling conversation's subscription with those arguments, for a tool like "unwatch". **`await event.end(user, id)`** ends one of a user's subscriptions by its ID.
|
|
122
|
+
|
|
123
|
+
## Sign-in
|
|
124
|
+
|
|
125
|
+
- **`GuestAuth(wake, mcp_url)`** is a small OAuth server inside your app for MCP clients: dynamic client registration, authorize with PKCE, tokens, all signed with a key derived from your app key, so it keeps no state. Each registered client is a guest with its own workspace. `guests.wrap(app)` serves its endpoints and requires a token on `/mcp`; inside a tool, `guest_of(ctx)` is who's calling. Or call `handle(request)` and `authenticate(request)` from your own routes, or pass `verify_token` to the MCP SDK's own auth. Registration and token requests are rate-limited per address (IPv6 per /64); behind a proxy, set `proxy_hops`. `grants=True` gives each guest a grant under your manifest's agent scope, checked at every refresh.
|
|
126
|
+
- Your app identifies its own users, with `GuestAuth` or its own sign-in, and acts for the agents in the workspaces it keeps.
|
|
127
|
+
|
|
128
|
+
## Topics
|
|
129
|
+
|
|
130
|
+
Events are built on topics, which you can use directly: subscribe the conversation calling one of your tools, and publish to it.
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from mcp.server.mcpserver import Context
|
|
134
|
+
from mcp.types import CallToolResult
|
|
135
|
+
|
|
136
|
+
from wakeshift import ConversationId, Harness, SessionKey
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@server.tool()
|
|
140
|
+
async def watch_ci(
|
|
141
|
+
repo: str, ctx: Context, session_key: SessionKey = None, harness: Harness = None, conversation_id: ConversationId = None
|
|
142
|
+
) -> CallToolResult:
|
|
143
|
+
"""Wake me when CI finishes on a repo"""
|
|
144
|
+
call = wake.call(ctx, session=session_key, harness=harness, conversation=conversation_id)
|
|
145
|
+
sub = await wake.subscribe(call, f"ci/{repo.lower()}", replay="5m")
|
|
146
|
+
return sub.result(f"Watching CI on {repo}.")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
async def on_ci(repo: str, conclusion: str, url: str) -> None:
|
|
150
|
+
await wake.publish(f"ci/{repo.lower()}", text=f"CI {conclusion} on {repo}", data={"url": url})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`SessionKey`, `Harness` and `ConversationId` add the optional arguments Wakeshift needs from the agent: the session key an earlier result gave it (a secret: don't log tool arguments that carry it), the program it runs in, and its own conversation ID. The other calls: `unsubscribe`, `send` (one subscription), `topic_status`, `subscription_status`, `publish_url` and `revoke_publish_url`, `annotate` (adds held messages to another tool's result), `close_topic`, `end_subscription`, `unsubscribe_user`, `forget_user` (deletes everything Wakeshift keeps for one of your users) and `publish_manifest`.
|
|
154
|
+
|
|
155
|
+
## Errors
|
|
156
|
+
|
|
157
|
+
Calls raise `WakeshiftError` with the API's `code` (`private_topic`, `bad_request`…) and HTTP `status`; `is_code(err, code)` checks one. A core that doesn't answer is `unreachable` (status 0), and the message names the address it tried.
|
|
158
|
+
|
|
159
|
+
## Keys
|
|
160
|
+
|
|
161
|
+
An app key is `wst_` followed by 50 letters and digits: your app's Ed25519 private key, with a checksum, so a mistyped key fails when you create `Wakeshift`. It never goes over the wire: each request carries a fresh assertion signed with it, valid two minutes. A key goes to `https://app.wakeshift.ai` unless you pass `core` or set `WAKESHIFT_CORE`.
|
|
162
|
+
|
|
163
|
+
The key doesn't name your app. `await wake.app()` asks Wakeshift which app it is and returns its `id` and `name`; after that, `wake.app_id` is the app's ID (before it, reading `wake.app_id` raises).
|
|
164
|
+
|
|
165
|
+
Older keys, `wst_test_<app>_<seed>` and `wst_live_<app>_<seed>`, keep working. They name the app, so `wake.app_id` works at once. A `wst_test_` key needs `core` or `WAKESHIFT_CORE`. `wake.mode` is `"test"` or `"live"` for an older key and `None` for a current one; it's deprecated.
|
|
166
|
+
|
|
167
|
+
## Documentation
|
|
168
|
+
|
|
169
|
+
The guides and the full reference are at [wakeshift.ai/docs](https://wakeshift.ai/docs): the [quickstart](https://wakeshift.ai/docs/quickstart), [events](https://wakeshift.ai/docs/events), [your users](https://wakeshift.ai/docs/users) and [the Python SDK](https://wakeshift.ai/docs/python). The same calls are in the [TypeScript](https://github.com/wakeshift/wakeshift-node) and [Go](https://github.com/wakeshift/wakeshift-go) SDKs.
|
|
170
|
+
|
|
171
|
+
## Development
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
uv sync
|
|
175
|
+
uv run ruff check
|
|
176
|
+
uv run pyright
|
|
177
|
+
uv run pytest
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The end-to-end tests run against a Wakeshift server, so they run in Wakeshift's own repository and are skipped here.
|
|
181
|
+
|
|
182
|
+
## Contributing and security
|
|
183
|
+
|
|
184
|
+
This repository is generated from Wakeshift's main repository. Pull requests are welcome: we apply them there and publish the result. See [CONTRIBUTING](CONTRIBUTING.md). Report a security problem privately to support@wakeshift.ai, not in an issue ([SECURITY](SECURITY.md)).
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
Apache License 2.0; see [LICENSE](LICENSE).
|