Skip to main content

zDeck Python plugin SDK

Python 3.10+ SDK for the same protocol v1 used by @zdeck/plugin-sdk. Python plugins contribute the same actions, sliders, toggles and embedded icons as JavaScript/TypeScript plugins. No Node runtime is required for a Python plugin. MIT licensed; no runtime dependencies. This package is not yet published to PyPI.

Quick start (from this repository)

Run from the repository root with Python 3.10 or newer installed. Create a new staging folder, then copy the example and SDK into it (PowerShell users can use New-Item and Copy-Item instead):

mkdir -p build/python-plugins
mkdir build/python-plugins/hello-python
cp packages/plugin-sdk-python/examples/hello/main.py build/python-plugins/hello-python/
cp packages/plugin-sdk-python/examples/hello/manifest.json build/python-plugins/hello-python/
mkdir build/python-plugins/hello-python/zdeck_plugin_sdk
cp packages/plugin-sdk-python/zdeck_plugin_sdk/*.py build/python-plugins/hello-python/zdeck_plugin_sdk/
cp packages/plugin-sdk-python/zdeck_plugin_sdk/py.typed build/python-plugins/hello-python/zdeck_plugin_sdk/
cp packages/plugin-sdk-python/LICENSE build/python-plugins/hello-python/
printf '{"protocolVersion":1,"id":"hello","type":"describe"}\n' \
  | python3 -E -s -B build/python-plugins/hello-python/main.py

On Windows use python for the interpreter. This example only updates in-memory values; it does not control an external application. describe never calls handlers.

Copy the entire hello-python folder into zDeck's plugin folder (Settings → External plugins → Open plugin folder), then Refresh, review, trust and enable it. The folder name must equal manifest.id. Do not copy a virtual environment, source checkout, symlinks, __pycache__ or .pyc files into a distribution. Desktop runtime detection uses PATH plus common Python install locations on Windows, macOS and Linux. Install Python separately; zDeck does not bundle/download it or run pip. On Windows the Python executable, not just the py launcher, must be available.

A Python installation contains manifest.json, one fixed main.py, and the regular local zdeck_plugin_sdk directory (including __init__.py and types.py) alongside it. Folders with both main.js and main.py are rejected. Manifests contain no executable paths or runtime flags. Python is launched without a shell, using -E -s -B: ignore PYTHON* environment settings, disable user-site packages, and avoid bytecode writes that would change trusted package fingerprints. Global site packages are not disabled; process separation is not a sandbox.

For additional dependencies, vendor real files beside main.py using your developer environment and include their licenses. Recipients should not run pip or install from a source tree. The existing package fingerprint limits (4096 files / 64 MiB) apply; large dependency stacks cannot be installed this way.

API

from threading import Event
from zdeck_plugin_sdk import Args, Manifest, State, serve

class MyPlugin:
    manifest: Manifest = {
        "id": "my-plugin", "version": "0.1.0", "protocolVersion": 1,
        "actions": [{"id": "go", "title": "Go", "config": {}}],
    }

    def state(self, signal: Event) -> State:
        return {"ready": True}

    def execute(self, action: str, args: Args, signal: Event) -> State:
        # Perform the action once, then return observed JSON state.
        return self.state(signal)

if __name__ == "__main__":
    serve(MyPlugin())
  • serve(plugin, *, input=None, output=None) blocks until EOF or timeout. Optional streams are binary file-like objects. Stdout is reserved for one UTF-8 JSON response per line; send local diagnostics to stderr, never secrets.
  • Handlers may be def or async def. They run sequentially in worker threads; async handlers get a new event loop per call. Create loop/thread-bound resources inside the handler, not in the main thread or an earlier request. Main-thread-only OS APIs must be marshalled explicitly by the plugin.
  • signal is a threading.Event, set at the 10-second deadline. Check signal.is_set() during long work and give blocking I/O its own timeout. Python cannot forcibly cancel arbitrary handler code: after a deadline the SDK sends timeout and returns without admitting another request. Use serve as the main process's final operation; never restart it or retry timed-out actions. A daemon worker permits process exit even when a handler ignores cancellation.
  • validate_manifest(value) returns the original object or raises TypeError; serve snapshots metadata before reading requests.
  • validate_arguments(action, args) returns the original dict or raises PluginError. Integer fields accept only finite, safe integral JSON numbers (not booleans), with declared bounds and minimum + n * step alignment. All configured fields are required; extras are rejected. Boolean fields accept only bool.
  • PluginError(code) exposes a fixed public error code/message/hint. Unknown codes become internal_error; raw exception text is never returned. Supported codes match the TypeScript SDK; application-specific hints are platform-neutral in Python. Once an execute handler is invoked, failures report outcome: "unknown", never imply the action was not applied. No automatic retry.
  • State must be a dict of JSON values (string keys, dict/list/null/bool/int/finite float/string). Non-JSON values, non-finite numbers and cycles produce sanitized errors. Transport errors propagate rather than printing protocol noise.
  • PROTOCOL_VERSION is 1; read-only LIMITS exposes request_bytes=16384, response_bytes=65536, manifest_bytes=16384, request_timeout_ms=10000.

Wire field names remain camelCase (protocolVersion, stateKey); Python API names are snake_case. The manifest schema, icon limits, control metadata and request/error framing are documented in the TypeScript SDK and the plugin contract. Only one control-bearing field per action is supported. Live state is session-only; persist explicit user configuration in the host, not action results.

Development and verification

cd packages/plugin-sdk-python
python3 -B -m unittest discover -s tests -v

Tests use the standard library, plus installed Node for cross-language contract checks. They cover strict validation, framing bounds, cancellation, sanitization, sync/async handlers and a self-contained consumer in a temporary directory. Rust integration tests launch the Python example through the real host, test trust, execute, restart/restore, disable persistence and fingerprint stability. The cross-platform CI matrix runs both suites on Python 3.10 and builds a wheel, then reruns the SDK tests against that wheel's public import (including a consumer copied from its package resources). A local macOS pass is not proof of Windows/Linux native parity.

pyproject.toml provides setuptools packaging metadata for developer installation/builds; setuptools is a build dependency only. Desktop plugins bundle the zdeck_plugin_sdk directory, so end users do not need package installation. PyPI publishing, runtime bundling and automatic dependency installation are not included.

Metadata

Release files for zdeck-plugin-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zdeck-plugin-sdk 0.1.0
File Size Uploaded Provenance Actions
zdeck_plugin_sdk-0.1.0.tar.gz 13.1 kB Without provenance Details for zdeck_plugin_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zdeck-plugin-sdk 0.1.0
File Interpreter ABI Platform Actions
zdeck_plugin_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for zdeck_plugin_sdk-0.1.0-py3-none-any.whl

Total release size: 23.5 kB

Release files / zdeck_plugin_sdk-0.1.0.tar.gz

Download URL zdeck_plugin_sdk-0.1.0.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2156ecfb4b5eadd82376fcc63471000c72b2c12e31d01bd0d28fc01f79dc5b05
BLAKE2b-256 checksum
How to use checksums
cdbcadb0e5ff061bfe25cf0426078fa1a8532b61b289a29bc1b7507b62831e89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / zdeck_plugin_sdk-0.1.0-py3-none-any.whl

Download URL zdeck_plugin_sdk-0.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fde56b1a28aae501e6f73e744517e9e00713c4997bc8fd03f03d0e7ff33659c
BLAKE2b-256 checksum
How to use checksums
64d669d11b302edaf96687d92d75c00b4ac46f990d0bb55ebc83bea8ccd03739
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for zdeck-plugin-sdk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page