Cresco Python Client (pycrescolib)
Python client library for the Cresco edge-computing framework. It connects
to the wsapi WebSocket plugin (wss://host:8282, authenticated with the
cresco_service_key header) to control agents, deploy plugins, run pipelines, stream the
data plane, and build stunnel tunnels.
Part of the Cresco framework — see the agent repository for the full architecture and the Java client for the equivalent in Java.
Standardized clients. The Python and Java clients are kept feature- and name-identical: the same submodules (
messaging,agents,admin,api,globalcontroller,stunnel), the same method names (snake_case in both languages), the same behavior, and the same examples. Anything you can do in one, you can do in the other with the same call. This README is identical to the Java client's, except for the install and quick-start sections below.
Install: pip install pycrescolib (Python 3.8+; depends on websockets, cryptography, backoff).
From a source checkout use pip install ., and to build the distributions run python -m build.
Quick start
from pycrescolib.clientlib import clientlib
# host/ip of an agent running the wsapi plugin, its port, and the wsapi service key
client = clientlib("localhost", 8282, "your-service-key", verify_ssl=False)
if client.connect():
print(client.api.get_api_region_name(), client.api.get_api_agent_name())
print(client.globalcontroller.get_agent_list())
client.close()
Runnable, standardized examples (identical to the Java client's example/standard/StandardExamples.java)
live in examples/standard_examples.py: example_connect, example_pipeline,
example_plugin_lifecycle, example_dataplane, example_logstreamer, example_admin.
Concepts
- Connect once, use submodules. A
clientlibopens one authenticated control connection and exposes six submodule handles:messaging,agents,admin,api,globalcontroller,stunnel. - Resolve plugins by name, not by log-scraping.
globalcontroller.find_plugin(region, agent, name)returns the liveplugin_idfor a plugin loaded on an agent, so you never parse logs to address a plugin. - Streams are separate sockets.
get_dataplane(...)andget_logstreamer(...)open their own WebSocket connections, are tracked by name on the client, and auto-reconnect if the socket drops. - "Not found" vs "couldn't ask". Inventory queries (
globalcontroller.list_plugins/find_plugin/get_agent_list/get_region_list/get_pipeline_list/get_pipeline_id_by_name,agents.list_plugin_agent/find_plugin) return an empty list /Noneonly when the fabric answered "none". When the query fails they raise:CrescoQueryError(frompycrescolib.base_classes; an error reply such as wsapi's 504, or a reply without the list) orTimeoutError/ConnectionError(no reply, e.g. right after a global restart). Since 1.3.2; earlier versions returned[]/Noneon failure, which made check-then-act code (if not find_plugin(...): add) start duplicate plugins. Code that only displays the result can catch the exception; code that acts on "absent" must not. A control socket the server closed (e.g. a global restart) raisesConnectionErrorandconnected()turns False, so reconnect withconnect(); earlier versions keptconnected()True and answered every RPC with an empty reply. - RPC vs fire-and-forget. Messaging calls take an
is_rpcflag: when true the call blocks for the reply, when false it is sent without waiting.
API reference
Signatures are shown language-neutrally; names and behavior are identical in both clients.
Client — clientlib / CrescoClient
| Method | Description |
|---|---|
clientlib(host, port, service_key, verify_ssl=False) |
Create the client for a wsapi endpoint. |
connect(block_on_connect=True) -> bool |
Connect to the wsapi endpoint; block until connected when block_on_connect. |
connected() -> bool |
Return True if connected to the wsapi endpoint. |
close() -> bool |
Close the client connection and all managed streams. |
connection() |
Return the underlying websocket transport interface. |
get_dataplane(stream_name, callback=None) |
Get (and register) a dataplane for the given stream query. |
close_dataplane(stream_name) -> bool |
Close and deregister the named dataplane. |
get_active_dataplanes() -> list |
List names of currently registered dataplanes. |
get_logstreamer(name=None, callback=None) |
Get (and register) a logstreamer. |
close_logstreamer(name) -> bool |
Close and deregister the named logstreamer. |
get_active_logstreamers() -> list |
List names of currently registered logstreamers. |
Submodule handles: messaging, agents, admin, api, globalcontroller, stunnel.
api
| Method | Description |
|---|---|
get_api_region_name() |
Region name of the agent hosting the wsapi plugin. |
get_api_agent_name() |
Agent name of the agent hosting the wsapi plugin. |
get_api_plugin_name() |
Plugin name of the wsapi plugin. |
get_global_region() |
Global controller region. |
get_global_agent() |
Global controller agent. |
get_global_info() |
Pair of (global_region, global_agent). |
admin
| Method | Description |
|---|---|
stopcontroller(dst_region, dst_agent) |
Stop the agent's controller plugin. |
restartcontroller(dst_region, dst_agent) |
Restart the agent's controller plugin. |
restartframework(dst_region, dst_agent) |
Restart the underlying OSGi framework. |
killjvm(dst_region, dst_agent) |
Force-terminate the agent JVM. |
agents
| Method | Description |
|---|---|
is_controller_active(dst_region, dst_agent) |
Whether the target controller is active. |
get_controller_status(dst_region, dst_agent) |
Controller status. |
add_plugin_agent(dst_region, dst_agent, configparams, edges=None) |
Add a plugin to an agent. |
remove_plugin_agent(dst_region, dst_agent, plugin_id) |
Remove a plugin from an agent. |
list_plugin_agent(dst_region, dst_agent) |
List plugins on an agent (asks the agent itself; raises if it cannot be read). |
find_plugin(dst_region, dst_agent, pluginname) |
Resolve a plugin's plugin_id by name from the agent's own list (or None if not loaded). |
status_plugin_agent(dst_region, dst_agent, plugin_id) |
Get plugin status. |
get_agent_info(dst_region, dst_agent) |
Get agent information. |
get_agent_log(dst_region, dst_agent) |
Get agent logs. |
repo_pull_plugin_agent(dst_region, dst_agent, jar_file_path) |
Pull a plugin jar to the agent repo. |
upload_plugin_agent(dst_region, dst_agent, jar_file_path) |
Upload a plugin jar to the agent. |
update_plugin_agent(dst_region, dst_agent, jar_file_path) |
Update a plugin on the agent. |
get_broadcast_discovery(dst_region, dst_agent) |
Get broadcast discovery from an agent. |
cepadd(input_stream, input_stream_desc, output_stream, output_stream_desc, query, dst_region, dst_agent) |
Add a complex-event-processing query. |
globalcontroller
| Method | Description |
|---|---|
submit_pipeline(cadl, tenant_id='0') |
Submit a CADL pipeline. |
remove_pipeline(pipeline_id) |
Remove a pipeline. |
get_pipeline_list() |
List pipelines. |
get_pipeline_info(pipeline_id) |
Get pipeline information. |
get_pipeline_status(pipeline_id) |
Get pipeline status code. |
get_pipeline_id_by_name(pipeline_name) |
Look up a pipeline ID by name. |
get_pipeline_export(pipeline_id) |
Export a pipeline. |
get_pipeline_is_assignment_info(inode_id, resource_id) |
Get inode-to-resource assignment info. |
get_agent_list(dst_region=None) |
List agents (optionally in one region). |
get_agent_resources(dst_region, dst_agent) |
Get an agent's resource info. |
get_region_resources(dst_region) |
Get a region's resource info. |
get_region_list() |
List regions. |
get_plugin_repo_list() |
List plugins available in the repositories. |
get_repo_plugins() |
List plugins known to the repositories. |
list_plugins(dst_region, dst_agent) |
List the plugins loaded on an agent (via the global controller — reliable from anywhere in the mesh). |
find_plugin(dst_region, dst_agent, pluginname) |
Resolve the live plugin_id for a plugin loaded on an agent by its plugin name (or None). |
upload_plugin_global(jar_file_path) |
Upload a plugin jar to the global repo. |
get_metric_inventory(scope, dst_region, dst_agent, include_plugins, include_resource) |
Pull the fabric's unified metric inventory (controller + plugin metrics, optional resource summary). |
get_capability_inventory(scope, dst_region, dst_agent, include_plugins, include_osgi) |
Pull the fabric's self-describing capability catalog (LLM-facing tool descriptors). |
The metric/capability inventories take
scope='node','region', or'global'; passdst_region+dst_agentto target one agent's controller. (In the Java client these two methods currently order the positional args asdst_region, dst_agent, scope, ….)
stunnel
Build and manage secure TCP tunnels through the io.cresco.stunnel
plugin: a listener on src_port at the source agent forwards to dst_host:dst_port reachable from the
destination agent, with tunnel data riding the Cresco data plane. Plugin ids are auto-resolved by name via
find_plugin, so callers never pass a raw plugin_id.
| Method | Description |
|---|---|
find_plugin(region, agent) |
Resolve the io.cresco.stunnel plugin_id loaded on an agent (or None). |
deploy_plugin(region, agent, jar_file_path=None) |
Ensure the stunnel plugin runs on an agent: no-op if loaded, else upload jar_file_path (pluginupload) or start the copy embedded in the agent (stunnel.jar) with pluginadd. "Not loaded" is confirmed with the agent itself (pluginlist) before adding, because the global's view can lag the agent briefly after a restart. Returns the plugin_id, or None if the add failed; raises (and adds nothing) when the inventory could not be read. |
create_tunnel(stunnel_id, src_region, src_agent, src_port, dst_region, dst_agent, dst_host, dst_port, buffer_size="8192", src_plugin_id=None, dst_plugin_id=None, watchdog_timeout=None, performance_report_rate=None) |
Create a tunnel; plugin ids auto-resolved; optional params are sent only when not None. Returns the parsed stunnel_config. |
remove_tunnel(stunnel_id, src_region, src_agent, dst_region, dst_agent, src_plugin_id=None, dst_plugin_id=None) |
Remove both ends of a tunnel; returns {stunnel_id, src_removal, dst_removal, fully_removed}. |
get_tunnel_list(region, agent) |
List tunnels on an agent. |
get_tunnel_status(region, agent, stunnel_id) |
Get a tunnel's status (ACTIVE/RECOVERING/DOWN/UNKNOWN). |
get_tunnel_config(region, agent, stunnel_id) |
Get a tunnel's config. |
tunnel_health_check(region, agent, stunnel_id) |
True if that agent's plugin holds a config for the tunnel (tunnelhealthcheck). |
get_metrics(region, agent) |
The plugin's live metrics (getmetrics) as a dict. |
set_net_tuning(region, agent, tuning) |
Plugin-wide network tuning (nettuning): net_socket_buffer_bytes, net_read_chunk_bytes, net_write_high_water_bytes, net_fc_window_bytes, net_trace_sample_n; applies to connections opened afterwards. |
remove_src_tunnel(region, agent, stunnel_id) |
Remove only the source end (the server cascades the matching dst removal). |
remove_dst_tunnel(region, agent, stunnel_id) |
Remove only the destination end. |
Every per-agent method also takes an optional trailing plugin_id to skip the lookup; when the lookup
itself fails the method raises (see "Not found vs couldn't ask" above) instead of reporting "no plugin". Method names and
arguments match the Java client's crescoclient.core.Stunnel.
messaging
All take (is_rpc, message_event_type, message_payload, ...) and return the reply dict for RPC calls.
| Method | Routes to |
|---|---|
global_controller_msgevent(...) |
the global controller |
regional_controller_msgevent(...) |
the regional controller |
global_agent_msgevent(..., dst_region, dst_agent) |
an agent via the global controller |
regional_agent_msgevent(..., dst_agent) |
an agent in the local region |
agent_msgevent(...) |
the local agent |
global_plugin_msgevent(..., dst_region, dst_agent, dst_plugin) |
a plugin via the global controller |
regional_plugin_msgevent(..., dst_agent, dst_plugin) |
a plugin in the local region |
plugin_msgevent(..., dst_plugin) |
a local plugin |
dataplane (from get_dataplane)
| Method | Description |
|---|---|
send(message) |
Send a text message. |
send_binary(data) |
Send a binary message. |
send_binary_file(file_path) |
Read and send a binary file. |
send_partial(data, complete) |
Send a payload as a fragmented message (flushed when complete). |
update_config(dst_region, dst_agent) |
Update the dataplane stream configuration. |
connect() |
Open the stream. |
connected() |
Whether the stream is connected. |
close() |
Close the stream. |
get_metrics() |
Client-side counters for this stream (messages/bytes sent + received, active). |
logstreamer (from get_logstreamer)
| Method | Description |
|---|---|
send(message) |
Send a message over the log stream. |
update_config(dst_region, dst_agent) |
Point the log stream at an agent. |
update_config_class(dst_region, dst_agent, loglevel, baseclass) |
Set the log level for one base class. |
connect() |
Open the stream. |
connected() |
Whether the stream is connected. |
close() |
Close the stream. |
SSL verification
By default SSL certificate verification is disabled (Cresco agents use self-signed certs). Enable it with the constructor flag:
client = clientlib("localhost", 8282, "your-service-key", verify_ssl=True)
Testing & cross-language parity
Both clients ship a self-contained test suite (no live mesh needed) that asserts they emit identical wire messages for identical API calls — the Python and Java suites assert the same generated golden corpus, so a green run on both proves the clients produce the same results.
- Python:
pip install -e .[test] && pytest - Java:
mvn test
See the test-suite README for coverage, the canonical wire contract, and how to regenerate the golden corpus after adding or changing a method.
License
See LICENSE.txt.
Metadata
Release files for pycrescolib 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycrescolib-1.3.2.tar.gz | 51.5 kB | With provenance | Details for pycrescolib-1.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycrescolib-1.3.2-py3-none-any.whl | Python 3 | none | any | Details for pycrescolib-1.3.2-py3-none-any.whl |
Total release size: 97.6 kB
Release files / pycrescolib-1.3.2.tar.gz
| Download URL | pycrescolib-1.3.2.tar.gz |
|---|---|
| Size | 51.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
690c96310d38d9dba2bbd47ba01c74c90e7eaf71f1e3f569db92d304425a9186
|
|
BLAKE2b-256 checksum How to use checksums |
9c71795daa96157fa970463841b8fbe919469e66698668f3bee524027f89bfbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / pycrescolib-1.3.2-py3-none-any.whl
| Download URL | pycrescolib-1.3.2-py3-none-any.whl |
|---|---|
| Size | 46.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dedd18e8ae6e5c542e5a41cc1a747d31730b771a6860172a455cc3e6e3fb548
|
|
BLAKE2b-256 checksum How to use checksums |
2af213159c601ddc4d96a6cb06b9b576295b2e84d7efa708d275b0a69e6ffa55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logSecurity for pycrescolib 1.3.2
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pycrescolib-1.3.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logA 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.