tdx-ths-linker
Windows 多端通达信(TDX)与同花顺(THS)联动组件
tdx-ths-linker 通过一套共享 C++ runtime,为 Web、Node/Electron、Python 和 Windows 原生程序提供统一的股票代码读取与设置能力。当前仅支持 Windows x64。
本项目是独立社区项目,与通达信、同花顺及其运营主体不存在隶属、授权、合作或背书关系。相关名称仅用于描述兼容目标,商标归各自权利人所有。
支持的接入方式
| 渠道 | 产物 | 接入方式 | 是否需要 Agent |
|---|---|---|---|
| Web | tdx-ths-linker npm 包 + Agent 安装包 |
自定义协议激活与 loopback HTTP | 是 |
| Node/Electron | tdx-ths-linker.node |
Node-API | 否 |
| Python | tdx-ths-linker wheel |
ctypes 加载内置 DLL |
否 |
| Codex / 自动化 | tdx-ths-linker Skill + CLI |
JSON 命令驱动 | 否 |
| C/C++ | onclaw-tdx-ths.dll |
稳定 C ABI | 否 |
所有渠道复用相同的目标发现、状态读取和代码设置逻辑。TDX 与 THS 均支持读取和写入。
工作方式
Web ── npm client ── onclaw-tdx-ths:// ── Agent ──┐
│
Electron/Harness ── tdx-ths-linker.node ──────────┤
Python ── ctypes ── onclaw-tdx-ths.dll ───────────┼── shared C++ runtime ── TDX / THS
Codex / Harness ── Skill ── npm JSON CLI ─────────┤
C/C++ ── C ABI ── onclaw-tdx-ths.dll ─────────────┘
详细设计参见 架构说明。
快速开始
Web
npm install tdx-ths-linker
import { createWebLinker } from "tdx-ths-linker";
const linker = createWebLinker();
// 必须在用户点击处理函数内调用,协议唤醒会同步发生。
const connection = await linker.connect({ licenseAccepted: true });
if (connection.status === "installer_required") {
location.href = connection.installerUrl;
} else if (!connection.ok) {
throw new Error(connection.message);
}
await linker.client.setCode("tdx", "600825");
await linker.client.setCode("ths", "600825");
Web 客户端只连接 127.0.0.1:17654。正式 GitHub Release 只提供会注册 onclaw-tdx-ths:// 的安装包,不把内部 Agent EXE 作为独立产品发布。完整的无登录 HTML 示例、自动联动和安装恢复流程参见 Web 快速接入。
Node / Electron
import { createRequire } from "node:module";
import { createNodeClient } from "tdx-ths-linker";
const require = createRequire(import.meta.url);
const native = require("./native/win-x64/tdx-ths-linker.node");
const linker = createNodeClient(native);
await linker.initialize(true);
const state = await linker.getState();
await linker.setCode("tdx", "600825");
await linker.setCode("ths", "600825");
Windows x64 的 npm 包已内置 tdx-ths-linker.node,Node/Electron 入口可从 tdx-ths-linker/native 加载;TDX_THS_LINKER_NODE_PATH 可在本地开发时覆盖二进制路径。发布工作流仍会额外附加独立 .node ZIP,供非 npm 宿主使用。
Python
py -m pip install tdx-ths-linker
from tdx_ths_linker import Client
with Client(license_accepted=True) as linker:
state = linker.get_state()
print(state.tdx.code, state.ths.code)
linker.set_code("tdx", "600825")
linker.set_code("ths", "600825")
Python wheel 内置 onclaw-tdx-ths.dll,不启动 Agent,也不使用本地 HTTP。set_code() 返回命令是否已接受;应继续轮询 get_state() 确认目标软件已完成切换。
CLI 驱动与 Codex Skill
Harness、Codex 和进程自动化统一使用 npm 包内置的 JSON CLI:
npx --no-install tdx-ths-linker --json --accept-license doctor
npx --no-install tdx-ths-linker --json --accept-license state
npx --no-install tdx-ths-linker --json --accept-license set 600825 --target tdx --wait
npx --no-install tdx-ths-linker --json --accept-license set 600825 --target ths --wait
Codex Skill 位于 skills/tdx-ths-linker,也会作为独立 ZIP 附加到 GitHub Release。Skill 不包含二进制文件,只调用项目中已安装的 npm CLI。安装和 JSON 合约参见 CLI 驱动与 Skill。
文档
- Web HTML 示例
- Python 示例
- Electron 示例
- DeepSeek Harness 示例
- Skill 示例
- 架构与发布产物
- 本地 Agent 协议
- 开发、测试与发布
- CLI 驱动与 Codex Skill
- npm 客户端说明
- Web 快速接入
安全与兼容性
- Agent 只监听
127.0.0.1:17654,不会绑定公网接口。 - Web 调用必须经过一次性 nonce、自定义协议激活、精确 Origin 和短期 bearer token 配对。
- THS 写入涉及目标进程内存操作;发布前必须针对目标软件版本完成真实兼容测试。
- fallback offset 不是长期稳定接口,不应在未验证的软件版本上假定可用。
- 正式发布的 EXE、DLL 和
.node应进行 Authenticode 签名并记录 SHA-256。 - 进程内存行为可能触发安全软件启发式检测,应使用透明构建、代码签名和误报申诉流程。
安全问题请避免公开披露可利用细节,优先通过仓库的私密安全报告渠道提交。
许可证
本项目采用 GNU General Public License v3.0 only。分发本项目或其修改版本时,必须遵守 GPLv3 对应的源码提供义务。
Metadata
Release files for tdx-ths-linker 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tdx_ths_linker-0.1.2-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for tdx_ths_linker-0.1.2-py3-none-win_amd64.whl |
Release files / tdx_ths_linker-0.1.2-py3-none-win_amd64.whl
| Download URL | tdx_ths_linker-0.1.2-py3-none-win_amd64.whl |
|---|---|
| Size | 139.9 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
86c65e36c309eb7fae30196103db4e8f3bd0ca4725939a97fef501f3d4b350bd
|
|
BLAKE2b-256 checksum How to use checksums |
30cf0c859262823bfc91a4b6bfa6a6f917cb5369988e62038b55f92d057b4be0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 9, 2026.
Transparency logSecurity for tdx-ths-linker 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.
Full provenance
1 file in this release has been uploaded with provenance metadata.
Attestation for tdx_ths_linker-0.1.2-py3-none-win_amd64.whl
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 Nov 9, 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.