jetpack-sdk 0.1.1__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.
- jetpack_sdk-0.1.1/.gitignore +163 -0
- jetpack_sdk-0.1.1/LICENSE +30 -0
- jetpack_sdk-0.1.1/PKG-INFO +103 -0
- jetpack_sdk-0.1.1/README.md +73 -0
- jetpack_sdk-0.1.1/jetpack_sdk/__init__.py +28 -0
- jetpack_sdk-0.1.1/jetpack_sdk/client.py +534 -0
- jetpack_sdk-0.1.1/jetpack_sdk/decorators.py +46 -0
- jetpack_sdk-0.1.1/jetpack_sdk/framing.py +287 -0
- jetpack_sdk-0.1.1/jetpack_sdk/py.typed +0 -0
- jetpack_sdk-0.1.1/pyproject.toml +62 -0
- jetpack_sdk-0.1.1/tests/test_app_home.py +74 -0
- jetpack_sdk-0.1.1/tests/test_decorators.py +41 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# ==========================================
|
|
2
|
+
# CoreNode Monorepo .gitignore
|
|
3
|
+
# ==========================================
|
|
4
|
+
|
|
5
|
+
# ------------------------------------------
|
|
6
|
+
# Operating System Files
|
|
7
|
+
# ------------------------------------------
|
|
8
|
+
# macOS
|
|
9
|
+
.DS_Store
|
|
10
|
+
.AppleDouble
|
|
11
|
+
.LSOverride
|
|
12
|
+
._*
|
|
13
|
+
.Spotlight-V100
|
|
14
|
+
.Trashes
|
|
15
|
+
|
|
16
|
+
# Windows
|
|
17
|
+
Thumbs.db
|
|
18
|
+
Thumbs.db:encryptable
|
|
19
|
+
ehthumbs.db
|
|
20
|
+
ehthumbs_vista.db
|
|
21
|
+
[Dd]esktop.ini
|
|
22
|
+
$RECYCLE.BIN/
|
|
23
|
+
|
|
24
|
+
# Linux
|
|
25
|
+
*~
|
|
26
|
+
.fuse_hidden*
|
|
27
|
+
.directory
|
|
28
|
+
|
|
29
|
+
# ------------------------------------------
|
|
30
|
+
# Rust & Cargo (crates/*)
|
|
31
|
+
# ------------------------------------------
|
|
32
|
+
# Build output directory
|
|
33
|
+
target/
|
|
34
|
+
debug/
|
|
35
|
+
release/
|
|
36
|
+
|
|
37
|
+
# Backup files generated by cargo fix
|
|
38
|
+
**/*.rs.bk
|
|
39
|
+
|
|
40
|
+
# Cargo profiling & cache
|
|
41
|
+
**/*.cargo-ok
|
|
42
|
+
|
|
43
|
+
# Note: Cargo.lock is intentionally committed for executable/daemon crates
|
|
44
|
+
# in accordance with Rust best practices. If you wish to ignore it, uncomment:
|
|
45
|
+
# Cargo.lock
|
|
46
|
+
|
|
47
|
+
# ------------------------------------------
|
|
48
|
+
# WebAssembly & wasm-pack (corenode-wasm)
|
|
49
|
+
# ------------------------------------------
|
|
50
|
+
**/pkg/
|
|
51
|
+
*.wasm.d.ts
|
|
52
|
+
web/packages/jetpack-client/wasm/
|
|
53
|
+
|
|
54
|
+
# ------------------------------------------
|
|
55
|
+
# JavaScript / TypeScript / Frontend (web/)
|
|
56
|
+
# ------------------------------------------
|
|
57
|
+
node_modules/
|
|
58
|
+
dist/
|
|
59
|
+
build/
|
|
60
|
+
out/
|
|
61
|
+
.next/
|
|
62
|
+
.nuxt/
|
|
63
|
+
.vite/
|
|
64
|
+
.turbo/
|
|
65
|
+
.cache/
|
|
66
|
+
.pnpm-store/
|
|
67
|
+
docs/.vitepress/dist/
|
|
68
|
+
docs/.vitepress/cache/
|
|
69
|
+
|
|
70
|
+
# Logs
|
|
71
|
+
npm-debug.log*
|
|
72
|
+
yarn-debug.log*
|
|
73
|
+
yarn-error.log*
|
|
74
|
+
pnpm-debug.log*
|
|
75
|
+
lerna-debug.log*
|
|
76
|
+
|
|
77
|
+
# ------------------------------------------
|
|
78
|
+
# Python (sdks/python & workers)
|
|
79
|
+
# ------------------------------------------
|
|
80
|
+
__pycache__/
|
|
81
|
+
*.py[cod]
|
|
82
|
+
*$py.class
|
|
83
|
+
*.so
|
|
84
|
+
|
|
85
|
+
# Environments
|
|
86
|
+
.venv/
|
|
87
|
+
venv/
|
|
88
|
+
env/
|
|
89
|
+
ENV/
|
|
90
|
+
.env/
|
|
91
|
+
|
|
92
|
+
# Packaging & distribution
|
|
93
|
+
*.egg-info/
|
|
94
|
+
.eggs/
|
|
95
|
+
*.egg
|
|
96
|
+
sdks/python/dist/
|
|
97
|
+
|
|
98
|
+
# Testing & quality tooling
|
|
99
|
+
.pytest_cache/
|
|
100
|
+
.ruff_cache/
|
|
101
|
+
.mypy_cache/
|
|
102
|
+
.coverage
|
|
103
|
+
.coverage.*
|
|
104
|
+
htmlcov/
|
|
105
|
+
|
|
106
|
+
# Python standalone / uv cache
|
|
107
|
+
.uv/
|
|
108
|
+
|
|
109
|
+
# ------------------------------------------
|
|
110
|
+
# IPC, Runtime & Sandboxed Storage
|
|
111
|
+
# ------------------------------------------
|
|
112
|
+
# Unix domain sockets and named pipes
|
|
113
|
+
*.sock
|
|
114
|
+
*.socket
|
|
115
|
+
|
|
116
|
+
# Local runtime directories & downloaded OCI artifacts
|
|
117
|
+
run/
|
|
118
|
+
tmp/
|
|
119
|
+
temp/
|
|
120
|
+
*.oci
|
|
121
|
+
*.tar.gz
|
|
122
|
+
tmp/tmp.txt
|
|
123
|
+
|
|
124
|
+
# ------------------------------------------
|
|
125
|
+
# Secrets & Environment Configurations
|
|
126
|
+
# ------------------------------------------
|
|
127
|
+
.env
|
|
128
|
+
.env*.local
|
|
129
|
+
*.local.env
|
|
130
|
+
!*.env.example
|
|
131
|
+
*.key
|
|
132
|
+
*.pem
|
|
133
|
+
*.secret
|
|
134
|
+
jetpack-root-signing*
|
|
135
|
+
|
|
136
|
+
# ------------------------------------------
|
|
137
|
+
# IDEs & Editors
|
|
138
|
+
# ------------------------------------------
|
|
139
|
+
# JetBrains (IntelliJ / RustRover / WebStorm / PyCharm)
|
|
140
|
+
#.idea/workspace.xml
|
|
141
|
+
#.idea/tasks.xml
|
|
142
|
+
#.idea/usage.statistics.xml
|
|
143
|
+
#.idea/shelf/
|
|
144
|
+
#.idea/httpRequests/
|
|
145
|
+
#.idea/dataSources/
|
|
146
|
+
#.idea/dataSources.local.xml
|
|
147
|
+
#*.iws
|
|
148
|
+
# (Optional: uncomment the line below to ignore .idea completely)
|
|
149
|
+
.idea/
|
|
150
|
+
|
|
151
|
+
# Visual Studio Code
|
|
152
|
+
.vscode/*
|
|
153
|
+
!.vscode/settings.json
|
|
154
|
+
!.vscode/tasks.json
|
|
155
|
+
!.vscode/launch.json
|
|
156
|
+
!.vscode/extensions.json
|
|
157
|
+
*.code-workspace
|
|
158
|
+
|
|
159
|
+
# Other editors
|
|
160
|
+
*.sublime-project
|
|
161
|
+
*.sublime-workspace
|
|
162
|
+
*.swp
|
|
163
|
+
*.swo
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
JetPack (`jetpack-sdk`) is dual-licensed under either:
|
|
2
|
+
|
|
3
|
+
- Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
4
|
+
- MIT License (http://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
at your option.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 JetPack Contributors
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above content does NOT show the above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: jetpack-sdk
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Lightweight Python Worker SDK for JetPack local IPC and proxy orchestration
|
|
5
|
+
Project-URL: Homepage, https://jetpack-desktop.github.io
|
|
6
|
+
Project-URL: Documentation, https://jetpack-desktop.github.io/sdk/worker/python-sdk
|
|
7
|
+
Project-URL: Repository, https://github.com/jetpack-desktop/jetpack
|
|
8
|
+
Project-URL: Issues, https://github.com/jetpack-desktop/jetpack/issues
|
|
9
|
+
Author: JetPack Contributors
|
|
10
|
+
License: MIT OR Apache-2.0
|
|
11
|
+
Keywords: ai,gpu,ipc,jetpack,msgpack,sandbox,worker,zero-copy
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
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
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: System :: Networking
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Provides-Extra: msgpack
|
|
28
|
+
Requires-Dist: msgpack>=1.0.0; extra == 'msgpack'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# `jetpack-sdk`
|
|
32
|
+
|
|
33
|
+
Lightweight, zero-dependency Python Worker SDK for [JetPack](https://jetpack-desktop.github.io) local IPC, zero-copy binary framing, and sandboxed GPU worker orchestration.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install jetpack-sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or using `uv`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv add jetpack-sdk
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For faster Cython-accelerated MsgPack header encoding/decoding, install the optional `msgpack` extra (otherwise `jetpack-sdk` uses its built-in pure-Python MsgPack codec with zero external runtime dependencies):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install "jetpack-sdk[msgpack]"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> **Note:** When running inside a worker managed by `jetpack-daemon`, `jetpack-sdk` is also embedded offline inside the daemon and provisioned into `.venv` automatically if `requirements = ["jetpack-sdk"]` is declared in `app.toml`.
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from jetpack_sdk import JetPackClient
|
|
59
|
+
|
|
60
|
+
with JetPackClient() as client:
|
|
61
|
+
while True:
|
|
62
|
+
frame = client.read_frame()
|
|
63
|
+
if frame is None:
|
|
64
|
+
break # Daemon closed IPC channel
|
|
65
|
+
|
|
66
|
+
if frame.opcode == "worker.ping":
|
|
67
|
+
client.send_frame(
|
|
68
|
+
opcode="worker.pong",
|
|
69
|
+
payload=frame.payload or b"pong",
|
|
70
|
+
channel_id=frame.channel_id,
|
|
71
|
+
correlation_id=frame.correlation_id,
|
|
72
|
+
)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Typed Opcode Contracts (`@opcode`)
|
|
76
|
+
|
|
77
|
+
Decorate handlers with `@opcode` and generate strict TypeScript `JetPackOpcodeMap` definitions via `jetpack codegen`:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from pydantic import BaseModel
|
|
81
|
+
from jetpack_sdk import JetPackClient, opcode
|
|
82
|
+
|
|
83
|
+
class ResizeMeta(BaseModel):
|
|
84
|
+
width: int
|
|
85
|
+
height: int
|
|
86
|
+
|
|
87
|
+
@opcode("image.resize", request=ResizeMeta, response=dict, binary=True)
|
|
88
|
+
def handle_resize(client: JetPackClient, frame) -> None:
|
|
89
|
+
mv = memoryview(frame.payload)
|
|
90
|
+
# Process binary bytes zero-copy...
|
|
91
|
+
client.send_frame(
|
|
92
|
+
opcode="image.resize.ok",
|
|
93
|
+
payload=bytes(mv),
|
|
94
|
+
channel_id=frame.channel_id,
|
|
95
|
+
correlation_id=frame.correlation_id,
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Documentation
|
|
100
|
+
|
|
101
|
+
- [Python Worker SDK & GPU Wheels](https://jetpack-desktop.github.io/sdk/worker/python-sdk)
|
|
102
|
+
- [Volumes & Userspace Network Proxy](https://jetpack-desktop.github.io/sdk/worker/volumes-and-network)
|
|
103
|
+
- [Manifest Reference (`app.toml`)](https://jetpack-desktop.github.io/publishing/manifest-reference)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# `jetpack-sdk`
|
|
2
|
+
|
|
3
|
+
Lightweight, zero-dependency Python Worker SDK for [JetPack](https://jetpack-desktop.github.io) local IPC, zero-copy binary framing, and sandboxed GPU worker orchestration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install jetpack-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or using `uv`:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv add jetpack-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For faster Cython-accelerated MsgPack header encoding/decoding, install the optional `msgpack` extra (otherwise `jetpack-sdk` uses its built-in pure-Python MsgPack codec with zero external runtime dependencies):
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install "jetpack-sdk[msgpack]"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> **Note:** When running inside a worker managed by `jetpack-daemon`, `jetpack-sdk` is also embedded offline inside the daemon and provisioned into `.venv` automatically if `requirements = ["jetpack-sdk"]` is declared in `app.toml`.
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from jetpack_sdk import JetPackClient
|
|
29
|
+
|
|
30
|
+
with JetPackClient() as client:
|
|
31
|
+
while True:
|
|
32
|
+
frame = client.read_frame()
|
|
33
|
+
if frame is None:
|
|
34
|
+
break # Daemon closed IPC channel
|
|
35
|
+
|
|
36
|
+
if frame.opcode == "worker.ping":
|
|
37
|
+
client.send_frame(
|
|
38
|
+
opcode="worker.pong",
|
|
39
|
+
payload=frame.payload or b"pong",
|
|
40
|
+
channel_id=frame.channel_id,
|
|
41
|
+
correlation_id=frame.correlation_id,
|
|
42
|
+
)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Typed Opcode Contracts (`@opcode`)
|
|
46
|
+
|
|
47
|
+
Decorate handlers with `@opcode` and generate strict TypeScript `JetPackOpcodeMap` definitions via `jetpack codegen`:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from pydantic import BaseModel
|
|
51
|
+
from jetpack_sdk import JetPackClient, opcode
|
|
52
|
+
|
|
53
|
+
class ResizeMeta(BaseModel):
|
|
54
|
+
width: int
|
|
55
|
+
height: int
|
|
56
|
+
|
|
57
|
+
@opcode("image.resize", request=ResizeMeta, response=dict, binary=True)
|
|
58
|
+
def handle_resize(client: JetPackClient, frame) -> None:
|
|
59
|
+
mv = memoryview(frame.payload)
|
|
60
|
+
# Process binary bytes zero-copy...
|
|
61
|
+
client.send_frame(
|
|
62
|
+
opcode="image.resize.ok",
|
|
63
|
+
payload=bytes(mv),
|
|
64
|
+
channel_id=frame.channel_id,
|
|
65
|
+
correlation_id=frame.correlation_id,
|
|
66
|
+
)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Documentation
|
|
70
|
+
|
|
71
|
+
- [Python Worker SDK & GPU Wheels](https://jetpack-desktop.github.io/sdk/worker/python-sdk)
|
|
72
|
+
- [Volumes & Userspace Network Proxy](https://jetpack-desktop.github.io/sdk/worker/volumes-and-network)
|
|
73
|
+
- [Manifest Reference (`app.toml`)](https://jetpack-desktop.github.io/publishing/manifest-reference)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""JetPack Python Worker SDK.
|
|
2
|
+
|
|
3
|
+
Lightweight, zero-dependency client library for native sandboxed workers
|
|
4
|
+
communicating with `jetpack-daemon` over local IPC.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .client import JetPackClient
|
|
8
|
+
from .decorators import get_opcode_metadata, opcode
|
|
9
|
+
from .framing import (
|
|
10
|
+
FrameHeader,
|
|
11
|
+
HybridFrame,
|
|
12
|
+
decode_stream_frame,
|
|
13
|
+
encode_hybrid_frame,
|
|
14
|
+
pack_msgpack,
|
|
15
|
+
unpack_msgpack,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"JetPackClient",
|
|
20
|
+
"FrameHeader",
|
|
21
|
+
"HybridFrame",
|
|
22
|
+
"opcode",
|
|
23
|
+
"get_opcode_metadata",
|
|
24
|
+
"encode_hybrid_frame",
|
|
25
|
+
"decode_stream_frame",
|
|
26
|
+
"pack_msgpack",
|
|
27
|
+
"unpack_msgpack",
|
|
28
|
+
]
|