Skip to main content

Python client library for the loom browser-automation daemon

Project description

loom (Python SDK)

Python client library for the loom browser-automation daemon.

Prerequisites

The SDK talks to a running loom-daemon over a Unix socket. Install loom (CLI + daemon + chromium pin) first via Homebrew, cargo install, or the install script — see the main README. Then start the daemon:

loom serve

Install

pip install mentiora-loom

The distribution is named mentiora-loom; it still imports as loom (import loom). Requires Python ≥ 3.11.

Quick start (sync)

import loom

with loom.Session.create() as session:
    receipt = session.navigate("https://example.com")
    print(receipt.action_hash)

Quick start (async)

import asyncio
import loom

async def main():
    async with await loom.AsyncSession.create() as session:
        receipt = await session.navigate("https://example.com")
        print(receipt.action_hash)

asyncio.run(main())

What the SDK exposes

  • Session / AsyncSession — session lifecycle (create / close / abort / kill / replay / inspect / validate / export).
  • Session.{navigate, click, type_text, select, hover, scroll, wait, evaluate, screenshot, snapshot} — every web action surface.
  • Admin RPCs: kill_session(session_id, ...) (force-terminate without a handle), daemon_health(deep=...) (operational snapshot).
  • Receipt + summary types in loom.typesReceipt, SessionInfo, SessionInspection, DiffReport, ExportInfo, ValidationResult, GrantInfo, SchemaRegistry, LoomErrorCode.
  • Typed errors: LoomError, LoomRPCError, LoomConnectionError, LoomTokenError.

Cancellation (async only)

AsyncSession supports transparent cancellation via standard asyncio primitives. Wrap a call in asyncio.wait_for or cancel its enclosing task and the SDK fires a request.cancel envelope at the daemon, then re-raises asyncio.CancelledError so TaskGroup / asyncio.timeout keep working:

import asyncio
import loom

async with await loom.AsyncSession.create() as s:
    try:
        await asyncio.wait_for(s.navigate("https://example.com"), timeout=5.0)
    except asyncio.TimeoutError:
        # SDK already sent request.cancel before the timeout re-raised.
        ...

Sync Session is single-in-flight by design — there is no cancellation hook. For cancellable work, reach for AsyncSession.

Connection details

Session.create() defaults work when a single user runs the daemon on their own machine. Override per-call if needed:

session = loom.Session.create(
    socket_path="/var/run/loom/loom.sock",  # custom daemon socket
    token="...",                             # explicit HELLO-token
    profile="standard",                      # or "safe", "full"
    network_mode="live",                     # the only mode (see below)
    seed=42,                                 # determinism seed
)

Network mode: page traffic is always live

network_mode accepts exactly one value, "live" (the default). Page traffic is always fetched live from the network — loom records the manifest hash chain and per-request metadata, not page-network responses. Response bodies are never captured, so HAR exports contain request entries without bodies, and replay re-executes the recorded actions rather than serving recorded responses. Any other value ("recorded", "mixed", "replay") is rejected at Session.create() with invalid_network_mode.

License

Apache-2.0. See the main repository for details.

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

mentiora_loom-0.13.2.tar.gz (34.3 kB view details)

Uploaded Source

Built Distribution

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

mentiora_loom-0.13.2-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file mentiora_loom-0.13.2.tar.gz.

File metadata

  • Download URL: mentiora_loom-0.13.2.tar.gz
  • Upload date:
  • Size: 34.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mentiora_loom-0.13.2.tar.gz
Algorithm Hash digest
SHA256 d436bf93f2eb3a30d6eb2dffbca7f48f5daf8a49b293cf8c5b81c3e887ad33d0
MD5 26da729bc364b3ceb679eb28a0949db2
BLAKE2b-256 d40bfe382e4176c2e296e51e05972c2d4a9c9e6ae42e302b8ae92424392688a6

See more details on using hashes here.

File details

Details for the file mentiora_loom-0.13.2-py3-none-any.whl.

File metadata

  • Download URL: mentiora_loom-0.13.2-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mentiora_loom-0.13.2-py3-none-any.whl
Algorithm Hash digest
SHA256 391953488fe2d913b17af5cf710d91d461bc507b501f456a1bbb55171ac2e329
MD5 181c1a9242a073cbe1d0a7b1402f7a21
BLAKE2b-256 34d474a61c8cc754577e347453e880c7cae9d7aeb43a2112c135840a96cdeac1

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