Skip to main content

Python SDK for the Starlight Protocol - Resilient browser automation through autonomous Sentinels

Project description

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

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

starlight_protocol-1.3.3.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

starlight_protocol-1.3.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file starlight_protocol-1.3.3.tar.gz.

File metadata

  • Download URL: starlight_protocol-1.3.3.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for starlight_protocol-1.3.3.tar.gz
Algorithm Hash digest
SHA256 4e0505e300b1119b24f06ab069b374cf17c34e7f817e191ed76bf3a6f746711a
MD5 f9045e2d7503284ac802f606ad3cb226
BLAKE2b-256 010e754a2f4a0d6df76f5d94e2e29a8b62b078bf311fd55d2d414b9633f48ab4

See more details on using hashes here.

File details

Details for the file starlight_protocol-1.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for starlight_protocol-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5fb6f5d3d92c9ce476693e4b6f6bb77683d382e6274aea4d1fa551cbb5de2733
MD5 d38e97bc41d826dccc477a07beb8458a
BLAKE2b-256 96b3ed26ac5e116d4fbbd6d62d2ae210e9766253f8a78dc5a90757359aad5682

See more details on using hashes here.

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