Runtime

Libraries for runtime functionality including background task execution, HTTP server integration, key-value storage, concurrency primitives, and exposing a script as a first-class plugin server.

Available Libraries

Library Description
scriptling.runtime Background tasks and async execution
scriptling.runtime.http HTTP route registration and response helpers
scriptling.runtime.jsonrpc Concurrent JSON-RPC 2.0 server over stdio or HTTP
scriptling.runtime.kv Thread-safe key-value store
scriptling.runtime.plugin Expose a script as a first-class plugin server
scriptling.runtime.sync Named cross-environment concurrency primitives
scriptling.runtime.sandbox Isolated script execution environments
scriptling.runtime.mcp Register MCP tools via decorators

Quick Start

import scriptling.runtime as runtime
import scriptling.runtime.kv as kv

# Background task (handler is passed by name)
def my_task():
    print("Running in background")

runtime.background("my_task", "my_task")

# Key-value storage
store = kv.open("./mydata.db")
store.set("key", "value")
print(store.get("key"))

Registration

The runtime libraries are registered one at a time. scriptling.runtime.kv (package extlibs/runtime/kv) and scriptling.runtime.http (package extlibs/runtime/http) have packages of their own; the rest are in extlibs/runtime. Each sub-library registered on the same interpreter is also an attribute of scriptling.runtime, so import scriptling.runtime as rt; rt.kv works when scriptling.runtime.kv is registered. The CLI registers all of them; disable one with --disable-lib scriptling.runtime.kv (and so on), or the parent and all of its sub-libraries except scriptling.runtime.plugin (disabled by its own name) with --disable-lib scriptling.runtime. See Runtime Libraries.

See Also