Skip to main content

Starlight Protocol Python SDK

PyPI version License

Python SDK for building Sentinels that connect to the Starlight Protocol Hub.

Installation

pip install starlight-protocol

Quick Start

🚀 New in v1.3 Series: Protocol Resilience & Extended Actions

  • Protocol Resilience: Support for Phase 14 Hub features (Generic Perception, Self-Healing).
  • Extended Commands: Native support for scroll, hover, check/uncheck, select, press, type.
  • Enterprise Security: JWT-ready Sentinel base class.

Create a custom Sentinel in just a few lines:

from starlight_protocol import SentinelBase

class MySentinel(SentinelBase):
    def __init__(self):
        super().__init__(
            layer_name="MySentinel",
            priority=5,
            capabilities=["custom-detection"]
        )
    
    async def on_pre_check(self, params, msg_id):
        # Called before each Hub action
        blocking = params.get("blocking", [])
        
        if self.should_intervene(blocking):
            await self.send_hijack("Custom obstacle detected")
            await self.send_action("click", "#close-button")
            await self.send_resume()
        else:
            await self.send_clear()
    
    def should_intervene(self, blocking):
        # Your custom detection logic
        return any(b.get("className", "").find("custom-modal") >= 0 for b in blocking)

# Run the Sentinel
if __name__ == "__main__":
    sentinel = MySentinel()
    sentinel.run()

Core Classes

SentinelBase

Abstract base class for all Sentinels.

class SentinelBase:
    def __init__(
        self,
        layer_name: str,      # Unique identifier (e.g., "JanitorSentinel")
        priority: int,        # 1-10, lower = higher priority
        uri: str = "ws://localhost:8080",  # Hub WebSocket URL
        capabilities: list = None,  # ["stability", "obstacle-removal", "vision"]
        selectors: list = None,     # CSS selectors to monitor
    )

Methods to Override

Method When Called Purpose
on_pre_check(params, msg_id) Before each Hub action Decide to clear, wait, or hijack
on_message(msg) Any message received Custom message handling

Methods to Call

Method Purpose
send_clear() Signal all-clear to Hub
send_wait(delay_ms, reason) Request Hub to wait
send_hijack(reason) Take exclusive control
send_action(action, selector, **kwargs) Execute browser action during hijack
send_resume(re_check=False) Return control to Hub

Built-in Sentinels

The package includes reference Sentinel implementations:

from starlight_protocol.sentinels import PulseSentinel, JanitorSentinel

# Stability monitoring
pulse = PulseSentinel()
pulse.run()

# Obstacle removal
janitor = JanitorSentinel()
janitor.run()

Protocol Compliance

This SDK implements Starlight Protocol v1.0.0.

Certification

Test your Sentinel with the TCK Validator:

# Start validator
node validator/starlight_validator.js

# Run your Sentinel
python -m starlight_protocol.my_sentinel

Configuration

Sentinels automatically load config.json from the project root:

{
  "sentinel": {
    "reconnectDelay": 3,
    "heartbeatInterval": 2
  },
  "security": {
    "authToken": "your-secret-token"
  }
}

License

MIT - See LICENSE

Metadata

Release files for starlight-protocol 1.3.4

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

Source distribution (sdist)

Source distribution for starlight-protocol 1.3.4
File Size Uploaded Provenance
starlight_protocol-1.3.4.tar.gz 7.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for starlight-protocol 1.3.4
File Interpreter ABI Platform
starlight_protocol-1.3.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.6 kB

Release files / starlight_protocol-1.3.4.tar.gz

Download URL starlight_protocol-1.3.4.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bc3d2c51d610f873423ea88e95fa390b290b1294a649cce4658d6f485fb5adce
BLAKE2b-256 checksum
How to use checksums
57e1a0cc9088c6ce66a1c9a1a7071db9cef83c0051ec4297963a12a08bda890f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / starlight_protocol-1.3.4-py3-none-any.whl

Download URL starlight_protocol-1.3.4-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2d98af20d52a872eda4c557c5192663dcfbec47bdc5b1afcaf46ac22531afda
BLAKE2b-256 checksum
How to use checksums
a967900c77a311201fea34c25b56b92c8f644406f32355e9ef19d9dd6859beeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for starlight-protocol 1.3.4

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.

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