Skip to main content

Tuoni Script Engine type stubs

Type hints for Python scripts run by Tuoni. Install this package locally to get editor completion, API documentation, and static type checking for tuoni_script_engine.

The package contains type information only. Tuoni provides the actual tuoni_script_engine module when it runs a server-side script.

Python 3.12 or newer is required.

These stubs describe the tuoni_script_engine API in Tuoni Server 0.17.0. The legacy tuoni module intentionally has no stubs.

Installation

python -m pip install tuoni-script-engine-stubs

To check a script with Pyright:

python -m pip install pyright
python -m pyright path/to/script.py

Quick example

import tuoni_script_engine as tse

for agent in tse.agents.list(status=tse.AgentStatus.ACTIVE):
    print(agent.guid, agent.metadata.hostname)

tse.discovery.services.create(
    "10.10.20.15",
    445,
    protocol="tcp",
    banner="SMB",
)

API overview

API What it provides
agents Find agents, inspect metadata and listeners, change status, and queue commands.
commands Queue, inspect, update, or cancel commands and register dynamic aliases.
command_templates Inspect available commands, schemas, and example configurations.
command_aliases Create and manage saved aliases with fixed configurations.
notes Create, query, update, and archive notes attached to commands.
discovery Create, search, update, archive, and restore hosts, services, and credentials.
events Subscribe to live events and query recorded events.
files Upload and access files stored by Tuoni.
listeners Create, inspect, start, stop, reconfigure, and delete listeners.
payloads Create, inspect, generate, and archive payloads.
payload_templates Inspect available payload types and their configuration schemas.
plugins Inspect loaded listener, command, and payload plugins.
jobs Inspect jobs and pause, resume, or restart supported jobs.
settings Read server and plugin settings.
ips List server IP addresses detected by Tuoni.

APIs that accept configuration use one of these types:

tuoni_script_engine.JsonConfiguration({"key": "value"})
tuoni_script_engine.BinaryConfiguration(b"content")
tuoni_script_engine.MultipartConfiguration(
    files={"payload.bin": b"content"},
    json={"key": "value"},
)

Dynamic command aliases

A dynamic alias adds a command to Tuoni for as long as its script is loaded. Register an object that implements these methods:

  • configuration_schema() returns the command configuration as JSON Schema.
  • can_send_to_agent(agent) decides whether the command is available for an agent.
  • validate_config(config, agent) performs any additional validation. Raise ValidationError when the input should be rejected.
  • execute(ctx, config, agent) runs the alias. Use ctx to queue child commands, publish results, and finish or fail the alias.

The following alias exposes the native ps command under a new name:

import tuoni_script_engine as tse


class ProcessListAlias(tse.DynamicAlias):
    description = "List running processes"

    def configuration_schema(self) -> str:
        return '{"type":"object","properties":{},"additionalProperties":false}'

    def can_send_to_agent(self, agent: tse.Agent) -> bool:
        return agent.type is tse.AgentType.SHELLCODE_AGENT

    def validate_config(
        self,
        config: tse.Configuration,
        agent: tse.Agent,
    ) -> None:
        pass

    def execute(
        self,
        ctx: tse.AliasContext,
        config: tse.Configuration,
        agent: tse.Agent,
    ) -> None:
        command = ctx.queue_command("ps", tse.JsonConfiguration({}))

        if not command.wait_for_completion(timeout=300):
            command.cancel()
            ctx.fail("Process listing timed out")
            return

        if command.is_failed():
            error = command.result.error_message if command.result else None
            ctx.fail(error or "Process listing failed")
            return

        if command.result:
            ctx.set_result(command.result.entries)
        ctx.finish()


tse.commands.register_dynamic_alias("script-ps", ProcessListAlias())

An alias must eventually call ctx.finish() or ctx.fail(). It may call ctx.set_result(...) before completion to publish ongoing or final result entries.

Metadata

Release files for tuoni-script-engine-stubs 0.17.0.post1

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

Source distribution (sdist)

Source distribution for tuoni-script-engine-stubs 0.17.0.post1
File Size Uploaded Provenance Actions
tuoni_script_engine_stubs-0.17.0.post1.tar.gz 14.8 kB Without provenance Details for tuoni_script_engine_stubs-0.17.0.post1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tuoni-script-engine-stubs 0.17.0.post1
File Interpreter ABI Platform Actions
tuoni_script_engine_stubs-0.17.0.post1-py3-none-any.whl Python 3 none any Details for tuoni_script_engine_stubs-0.17.0.post1-py3-none-any.whl

Total release size: 30.1 kB

Release files / tuoni_script_engine_stubs-0.17.0.post1.tar.gz

Download URL tuoni_script_engine_stubs-0.17.0.post1.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e6f8e3e2beb0bad29d57309ecf3ab75389ab0504e5f13a3c997d3ae9f1ea6b3f
BLAKE2b-256 checksum
How to use checksums
b8a91538d1ab3ca12a65c5c08ac36247f1e48b9d67989ad7ee9c010e134ddb71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / tuoni_script_engine_stubs-0.17.0.post1-py3-none-any.whl

Download URL tuoni_script_engine_stubs-0.17.0.post1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2bc7ed33e49a022e7a21c8e2a1769566339da3eb0e7e37d1c074d589153e6b03
BLAKE2b-256 checksum
How to use checksums
5a46ee6af44517526c3f9c1e2f0da63b5be3a5e5e8cba163afbcddece2425b3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for tuoni-script-engine-stubs 0.17.0.post1

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.17.0.post1 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