Skip to main content

Python wrapper for the mlld CLI

Project description

mlld Python SDK

Python wrapper for mlld using a persistent NDJSON RPC transport over mlld live --stdio.

Installation

pip install mlld-sdk

Requirements

  • Python 3.10+
  • Node.js runtime
  • mlld CLI available by command path

Quick Start

from mlld import Client

client = Client()

# Optional command override (local repo build example)
# client = Client(command='node', command_args=['./dist/cli.cjs'])

output = client.process('show "Hello World"')
print(output)

result = client.execute(
    './agent.mld',
    {'text': 'hello'},
    state={'count': 0},
    dynamic_modules={
        '@config': {'mode': 'demo'}
    },
    timeout=10,
)
print(result.output)

client.close()

In-Flight State Updates

handle = client.process_async(
    'loop(99999, 50ms) until @state.exit [\n  continue\n]\nshow "done"',
    state={'exit': False},
    mode='strict',
    timeout=10,
)

time.sleep(0.12)
handle.update_state('exit', True)
print(handle.result())

API

Client

  • Client(command='mlld', command_args=None, timeout=30.0, working_dir=None)
  • process(script, *, file_path=None, payload=None, state=None, dynamic_modules=None, dynamic_module_source=None, mode=None, allow_absolute_paths=None, timeout=None)
  • process_async(...) -> ProcessHandle
  • execute(filepath, payload=None, *, state=None, dynamic_modules=None, dynamic_module_source=None, allow_absolute_paths=None, mode=None, timeout=None)
  • execute_async(...) -> ExecuteHandle
  • analyze(filepath)
  • close()

Handle Methods

ProcessHandle and ExecuteHandle both provide:

  • request_id
  • cancel()
  • update_state(path, value, *, timeout=None)
  • wait()
  • result()

Module-level Convenience Functions

  • mlld.process(...)
  • mlld.process_async(...)
  • mlld.execute(...)
  • mlld.execute_async(...)
  • mlld.analyze(...)

Notes

  • Each Client keeps one live RPC subprocess for repeated calls.
  • ExecuteResult.state_writes merges final-result writes and streamed state:write events.
  • Sync methods remain as wrappers around async handle methods.

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

mlld_sdk-2.0.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

mlld_sdk-2.0.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file mlld_sdk-2.0.1.tar.gz.

File metadata

  • Download URL: mlld_sdk-2.0.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mlld_sdk-2.0.1.tar.gz
Algorithm Hash digest
SHA256 c174a6ea59419b5e72122ccc13dbb5e26ec31fd1eda6f9447a15f96219150bca
MD5 804d846ce41cd11d1a37b71acf0b9c3a
BLAKE2b-256 7a46a8e5c9817226cd9bda7ef5f184ab0899c84c9e4e26b627fb5d80bfc4d66e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlld_sdk-2.0.1.tar.gz:

Publisher: publish.yml on mlld-lang/mlld

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

File details

Details for the file mlld_sdk-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: mlld_sdk-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mlld_sdk-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5545e4a483945bad5d64bb8d713a7a458a09c9d349e17fa2fce7839c325465f
MD5 5f62330804ca6a1f1d404668a36e7a7f
BLAKE2b-256 e747f42ea36bb257ff2312d341ffafae0db541157aa06fbae8240b0dea2bb965

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlld_sdk-2.0.1-py3-none-any.whl:

Publisher: publish.yml on mlld-lang/mlld

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