Skip to main content

A small Python Aglets-inspired mobile object runtime.

Project description

paglets social preview

paglets

CI Docs Python License PyPI

Introduction / overview paper:

DOI

paglets is a compact Python re-imagining of the Java Aglets mobile-agent idea: stateful objects with identity, lifecycle hooks, message passing, proxies, movement between hosts, durable deactivation, resident services, and explicit dataclass state serialization.

Hosts are expected to already have the same paglet code importable. Movement transfers the paglet class name, state class name, and serialized dataclass state; it does not upload code or move Python stacks, threads, sockets, or arbitrary live resources.

Quick Start

Install and run tests from a checkout:

uv run pytest

Build the Python package locally:

uv build

After a tagged release is published, install the package with:

python -m pip install paglets

Start two local hosts:

uv run paglets-host --name alpha --port 8765 --mesh-version dev
uv run paglets-host --name beta --port 8766 --peer http://127.0.0.1:8765 --mesh-version dev

Run a packaged example CLI:

uv run paglets-sysinfo summary
uv run paglets-compute-slots status
uv run paglets-analysis-jobs --tasks 3 --target-runtime 3
uv run paglets-search grep TODO .
uv run paglets-pi-compute --digits 32

The built-in compute-slots service admits coarse jobs by explicit cpu_cores, expected RAM, and temp-storage estimates; on Linux and Windows it can best-effort pin granted jobs to allocated CPU IDs. New compute job paglets can derive from ComputeJobPaglet so scheduling, wakeup, redirects, affinity metadata, and lease release stay out of job-specific code.

Run a source-tree demo:

uv run python demos/disk_survey_demo.py --hosts alpha beta gamma

Minimal Paglet

from dataclasses import dataclass, field

from paglets.core.agent import Paglet, PagletState
from paglets.core.messages import Message


@dataclass
class CounterState(PagletState):
    count: int = 0
    events: list[str] = field(default_factory=list)


class CounterPaglet(Paglet[CounterState]):
    State = CounterState

    def handle_message(self, message: Message):
        if message.kind == "increment":
            self.state.count += int(message.args.get("by", 1))
            return {"count": self.state.count}
        return self.not_handled()

Public imports are intentionally explicit:

from paglets.runtime.host import Host
from paglets.core.agent import Paglet, PagletState
from paglets.core.messages import Message
from paglets.remote.proxy import PagletProxy

Flat imports such as from paglets import Host are unsupported.

Documentation

The full documentation is published at https://cklukas.github.io/paglets/.

Useful entry points:

Build docs locally:

uv run --extra docs mkdocs build --strict
uv run --extra docs mkdocs serve

Project Layout

src/paglets/core/            paglet model, messages, lifecycle events
src/paglets/runtime/         host facade, child processes, HTTP, relay, storage runtime
src/paglets/remote/          clients, proxies, transfer tickets, mesh, admin API
src/paglets/persistence/     inactive records and managed storage
src/paglets/services/        service contracts and resident services
src/paglets/system/          built-in resident service agents
src/paglets/serialization/   dataclass wire conversion and import resolution
src/paglets/config/          launch config and bundled defaults
src/paglets/tooling/         CLI, discovery, git auto-update
src/paglets/examples/        packaged example agents and CLIs
demos/                       runnable source-tree demo scripts
tests/                       behavior-oriented test suites by topic

Status

paglets is early-stage software for experiments and trusted local/LAN meshes. Use API-key authentication for shared networks and relay deployments.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paglets-1.0.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paglets-1.0.0-py3-none-any.whl (214.0 kB view details)

Uploaded Python 3

File details

Details for the file paglets-1.0.0.tar.gz.

File metadata

  • Download URL: paglets-1.0.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for paglets-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0e80470ebaa322ca99aa8aa448040eca104ff60ba763793cdfc15065104589f8
MD5 f7faf685c10a3124478a85c5850a6570
BLAKE2b-256 981b39dc333e1753403623668b0a3e9d6735614cb8d9a1085b72b9f6058e426a

See more details on using hashes here.

Provenance

The following attestation bundles were made for paglets-1.0.0.tar.gz:

Publisher: publish.yml on cklukas/paglets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file paglets-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: paglets-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 214.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for paglets-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e54e8b79307b969d89c815839591836c9ddc7972d375042071dabf7e9a1b181
MD5 5fcec6422bab4416620c23bcdf49a49b
BLAKE2b-256 50807af90ce9ca80934d758c2e73bee6273f38e6bc17cea6024a3430e1a1fb3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for paglets-1.0.0-py3-none-any.whl:

Publisher: publish.yml on cklukas/paglets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page