Skip to main content

Ennew Harness Python SDK

适用于 Python 3.9 及以上版本,安装包名为 ennew-harness-sdk,导入名称为 ennew_harness。

从 0.1.1 起,导入名称由 harness 改为 ennew_harness,避免与 Worker 自身的同名包冲突。升级后请同步修改业务脚本中的导入语句;不保留旧名称别名。

python3 -m pip install --upgrade ennew-harness-sdk

本 SDK 依赖 Ennew Harness 运行环境,并非独立运行的公共网关客户端。运行时必须提供 CODEX_THREAD_ID;读取上下文还需设置 ENV,并能访问对应业务网关。发送前端消息需要本机 Worker 服务。

读取上下文时,Worker 还需通过环境变量 HARNESS_GATEWAY_CONTEXT_TOKEN 注入对应环境的服务凭据。SDK 将其放入 X-OpenClaw-Mcp-Gateway-Token 请求头;未配置或为空时,在发送请求前报错。不要将真实凭据写入源码、镜像或发布包。

安装到运行业务脚本的 Python 环境后,可直接使用:

from ennew_harness import context, gui

current = context.get_current_context()
gui.send("file_changed", {"file": "report.md"})

两个方法都从运行时的 CODEX_THREAD_ID 获取当前线程身份。gui.send 要求传入非空的 type 和字典 payload,把 type 同时写入 params.type 与 params.message 中的业务 JSON,经 Worker 本机 127.0.0.1:18080/internal/events 发到当前线程的前端连接。只有线程正在执行且前端连接仍在时才能发送;接口返回成功表示消息已写入 WebSocket,不保证前端已处理。

context.get_current_context() 根据运行环境变量 ENV 选择 FAT、UAT 或 PROD 的网关配置,只返回允许业务脚本读取的身份与业务字段。三套网关 URL 定义在 ennew_harness/context.py,请求不内置 Token。环境名称区分大小写;安装 SDK 不会自动授予业务网关访问权限。

源码仓库中可运行上下文示例脚本:python3 fat_context.py。该脚本不随安装包提供。

Metadata

Release files for ennew-harness-sdk 0.1.2

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

Source distribution (sdist)

Source distribution for ennew-harness-sdk 0.1.2
File Size Uploaded Provenance
ennew_harness_sdk-0.1.2.tar.gz 5.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ennew-harness-sdk 0.1.2
File Interpreter ABI Platform
ennew_harness_sdk-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / ennew_harness_sdk-0.1.2.tar.gz

Download URL ennew_harness_sdk-0.1.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dd05ff04549ec9602452f8ab0167cfed06c5f8e587a9479fe5432d8b08117db4
BLAKE2b-256 checksum
How to use checksums
34ba25d90ac8fde2e6c4e1484ee2aba40073bcaf39057859b5fedd7a5255cf81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / ennew_harness_sdk-0.1.2-py3-none-any.whl

Download URL ennew_harness_sdk-0.1.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1655490f4c83b0a5fb9b3bdd24880dbc336076933643cf5f83a11692d496e68f
BLAKE2b-256 checksum
How to use checksums
a4659722fa267a4d097a5b93f07b8ca2295b16c022ae4d5662d745ee1d055bf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for ennew-harness-sdk 0.1.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.

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.

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