Metadata-Version: 2.3
Name: jetpack-sdk
Version: 0.1.1
Summary: Lightweight Python Worker SDK for JetPack local IPC and proxy orchestration
Project-URL: Homepage, https://jetpack-desktop.github.io
Project-URL: Documentation, https://jetpack-desktop.github.io/sdk/worker/python-sdk
Project-URL: Repository, https://github.com/jetpack-desktop/jetpack
Project-URL: Issues, https://github.com/jetpack-desktop/jetpack/issues
Author: JetPack Contributors
License: MIT OR Apache-2.0
Keywords: ai,gpu,ipc,jetpack,msgpack,sandbox,worker,zero-copy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Classifier: Typing :: Typed
Requires-Python: >=3.9
Provides-Extra: msgpack
Requires-Dist: msgpack>=1.0.0; extra == 'msgpack'
Description-Content-Type: text/markdown

# `jetpack-sdk`

Lightweight, zero-dependency Python Worker SDK for [JetPack](https://jetpack-desktop.github.io) local IPC, zero-copy binary framing, and sandboxed GPU worker orchestration.

## Installation

```bash
pip install jetpack-sdk
```

Or using `uv`:

```bash
uv add jetpack-sdk
```

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):

```bash
pip install "jetpack-sdk[msgpack]"
```

> **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`.

## Quick Start

```python
from jetpack_sdk import JetPackClient

with JetPackClient() as client:
    while True:
        frame = client.read_frame()
        if frame is None:
            break  # Daemon closed IPC channel

        if frame.opcode == "worker.ping":
            client.send_frame(
                opcode="worker.pong",
                payload=frame.payload or b"pong",
                channel_id=frame.channel_id,
                correlation_id=frame.correlation_id,
            )
```

## Typed Opcode Contracts (`@opcode`)

Decorate handlers with `@opcode` and generate strict TypeScript `JetPackOpcodeMap` definitions via `jetpack codegen`:

```python
from pydantic import BaseModel
from jetpack_sdk import JetPackClient, opcode

class ResizeMeta(BaseModel):
    width: int
    height: int

@opcode("image.resize", request=ResizeMeta, response=dict, binary=True)
def handle_resize(client: JetPackClient, frame) -> None:
    mv = memoryview(frame.payload)
    # Process binary bytes zero-copy...
    client.send_frame(
        opcode="image.resize.ok",
        payload=bytes(mv),
        channel_id=frame.channel_id,
        correlation_id=frame.correlation_id,
    )
```

## Documentation

- [Python Worker SDK & GPU Wheels](https://jetpack-desktop.github.io/sdk/worker/python-sdk)
- [Volumes & Userspace Network Proxy](https://jetpack-desktop.github.io/sdk/worker/volumes-and-network)
- [Manifest Reference (`app.toml`)](https://jetpack-desktop.github.io/publishing/manifest-reference)
