agentize-bridge 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentize-bridge
3
+ Version: 0.2.0
4
+ Summary: 一个轻量级框架,用于通过 HTTP、CLI 和 MCP 暴露现有的 Python 应用程序命令。
5
+ Author: ewoaoo
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: fastapi>=0.162.0
11
+ Requires-Dist: mcp>=2.3.0
12
+ Requires-Dist: pydantic>=2.7.4
13
+ Requires-Dist: uvicorn>=0.54.0
14
+ Dynamic: license-file
15
+
16
+ <div align="center">
17
+
18
+ # agentize-bridge
19
+
20
+ **让运行中的 Python 应用,成为 AI 代理可以调用的工具。**
21
+
22
+ 一个装饰器注册命令,同时获得 HTTP、CLI、MCP 三个入口,并支持在宿主程序的主线程中执行命令。
23
+
24
+ [![Python](https://img.shields.io/badge/python-3.11%2B-3776AB?logo=python&logoColor=white)](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/getting-started.md#安装)
25
+ [![License](https://img.shields.io/badge/license-MIT-2ea44f)](https://github.com/ewoaoo/agentize-bridge/blob/main/LICENSE)
26
+
27
+ [**文档**](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/README.md) · [快速开始](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/getting-started.md) · [MCP 接入](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/mcp.md) · [安全](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/security.md)
28
+
29
+ </div>
30
+
31
+ ---
32
+
33
+ 桌面 GUI、DCC 软件等程序的状态只能在主线程中读写,无法直接接入 Web 框架,AI 代理因而无法调用它们。
34
+ 使用 `agentize-bridge` 时,只需注册命令,参数校验、线程调度与对外暴露由框架负责。
35
+
36
+ 命令也可以用 `BinaryResult` 返回文件或程序生成的二进制数据。HTTP 和 CLI 可以保存原始字节,MCP 也可将 PNG 和 JPEG 作为图像工具结果返回。 [返回二进制数据](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/commands.md#返回二进制数据)
37
+
38
+ CLI 和 MCP 都通过 HTTP 调用宿主程序里注册的命令。宿主程序可以在线程池中执行命令,也可以在主循环中调用 `run_pending()`,在主线程执行队列里的命令。 [架构图](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/README.md#它是怎么工作的)
39
+
40
+ ## 快速开始
41
+
42
+ ```bash
43
+ git clone https://github.com/ewoaoo/agentize-bridge.git
44
+ cd agentize-bridge
45
+ uv sync # 或:pip install -e .
46
+ ```
47
+
48
+ ```python
49
+ import time
50
+
51
+ from agentize_bridge import AgentizeServer, command
52
+
53
+
54
+ @command()
55
+ def add(a: int, b: int = 2) -> int:
56
+ """把两个数字相加。"""
57
+ return a + b
58
+
59
+
60
+ if __name__ == "__main__":
61
+ server = AgentizeServer("My App")
62
+ server.start_http(host="127.0.0.1", port=8765)
63
+ try:
64
+ while True:
65
+ server.run_pending() # 在主线程中执行 thread="main" 的命令
66
+ time.sleep(0.01)
67
+ except KeyboardInterrupt:
68
+ server.close()
69
+ ```
70
+
71
+ ```bash
72
+ curl -X POST http://127.0.0.1:8765/command/add \
73
+ -H 'Content-Type: application/json' -d '{"a": 2, "b": 3}' # 5
74
+
75
+ azb call add -a '{"a": 2, "b": 3}' # 5
76
+ ```
77
+
78
+ 控制台默认只显示失败请求的访问记录。设置 `AgentizeServer("My App", log_mode="full")` 可查看成功请求。文件输出配置见[访问日志](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/getting-started.md#访问日志)。
79
+
80
+ ## 文档
81
+
82
+ [**完整文档 →**](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/README.md) 位于仓库的 `docs/` 目录,下面是常用入口:
83
+
84
+ | | 说明 |
85
+ | --- | --- |
86
+ | [定义命令](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/commands.md) | 参数、类型校验与二进制返回值 |
87
+ | [线程模型](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/threading.md) | `worker` 与 `main`,接入主循环 |
88
+ | [实例方法](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/instance-methods.md) | 暴露已有对象的方法 |
89
+ | [HTTP API](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/http-api.md) · [CLI](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/cli.md) · [MCP](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/mcp.md) | 三种调用方式 |
90
+ | [安全与限制](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/security.md) | 默认防护与已知缺口 |
91
+ | [开发](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/development.md) | 测试、构建与代码结构 |
92
+
93
+ > [!WARNING]
94
+ > **身份验证默认关闭。** 此时,任何能访问端口的人都能调用已注册的命令。本机使用建议保持默认的 `127.0.0.1`。跨机使用时,请开启鉴权并通过 HTTPS 或加密隧道连接。 [安全与限制](https://github.com/ewoaoo/agentize-bridge/blob/main/docs/security.md)
95
+
96
+ ## License
97
+
98
+ [MIT](https://github.com/ewoaoo/agentize-bridge/blob/main/LICENSE)
@@ -0,0 +1,30 @@
1
+ agentize_bridge/__init__.py,sha256=W0IszFbHzqHtCWC6eIWI26jS5Abu6RmbWkQkhUhaATg,227
2
+ agentize_bridge/__version__.py,sha256=-QbOHPLO58XrpWSqMEz9SItLSkvMddXKrgQwxg4ZLPc,217
3
+ agentize_bridge/adapters/http_client.py,sha256=xugBRYcQpb-HMIkTGbsthgoFIb2BVJ1e3RHw8Do0Ufc,7335
4
+ agentize_bridge/adapters/mcp_server.py,sha256=2_RpRhSdHJTYn_ZKb-CBwksopLMf066FsRam01FXYso,4369
5
+ agentize_bridge/adapters/cli/__init__.py,sha256=HEkgUtMb9zbbFPX__Nm_MzxSdoewLUHS0nq74pIpQtU,42
6
+ agentize_bridge/adapters/cli/app.py,sha256=gxU7hh0_gRt-RK_QCNvhbiv1QlTMPu9uMysVMteNUwg,647
7
+ agentize_bridge/adapters/cli/commands.py,sha256=obuTV4QsNdR0jm8AbVIFSwSatQ-Ze7-4i9Xv00U2PJQ,13152
8
+ agentize_bridge/adapters/cli/output.py,sha256=P7DPlbHk2TWYqYTDqOUw3v4XandiWJU8Wz28hrPU8K8,2803
9
+ agentize_bridge/adapters/cli/parser.py,sha256=qTwoA2I9_R4xdCv-f-_TESEO-DRF4RDLDUTTepVkujM,8700
10
+ agentize_bridge/core/__init__.py,sha256=0iSwrnWxr-ndRtUeM4LSZ7oG71t6d4tSmtbYMD2n0K0,212
11
+ agentize_bridge/core/command.py,sha256=icbRqBpaJO6usmSVR9zmw06lDzK-Aagf8XEuOZz9ue0,2814
12
+ agentize_bridge/core/registry.py,sha256=YFNa1d7l8HRRSI2bQ-mto335rcu53h0CSrNese_HVbo,669
13
+ agentize_bridge/core/result.py,sha256=ZK4V8KDXosNTqdJIjP-U4XUqtcNXDjYfEyJ84F8s5WA,628
14
+ agentize_bridge/core/schema.py,sha256=0fHGTDYGSYNIZdK_KzFQfLNGVqFGWFhH_owvH_YSwmI,2129
15
+ agentize_bridge/runtime/__init__.py,sha256=R6g-I1W4V2M_QDTKqI8Y99XodIRPkuzbeNGh3Rg_yfQ,320
16
+ agentize_bridge/runtime/container.py,sha256=XKXXxfOv9wa2cc93Jvv-5tNtOa428OqC2o5k-cV8TT0,725
17
+ agentize_bridge/runtime/executor.py,sha256=1n6RpBJzPExsnreHOQU-T5gs3oI3OIl-p_amkSEVZuE,1744
18
+ agentize_bridge/runtime/queues.py,sha256=td7Jl4Sn3g6TpVDC3pbWkf1vZzpRCJojryu8cd1QsDk,1031
19
+ agentize_bridge/runtime/util.py,sha256=lnWZR5b2Qx5602iMRLdTGlX2vkLaUkgrtacesVtRsq0,855
20
+ agentize_bridge/server/__init__.py,sha256=XVC-T0miYQPxybtSRm48KjadY57dExAB_VJ7iRs8tck,65
21
+ agentize_bridge/server/accept.py,sha256=0nKrDI8zNL9VxN_JnUg0TSpCpzQRi1qflD13Npxst3c,1404
22
+ agentize_bridge/server/access_log.py,sha256=Bs8ZzaI1xj_nGO4REyook2o1lCRR3egJIOjvfVTm6Jo,7933
23
+ agentize_bridge/server/bridge.py,sha256=MbV5KClh4BnAq5xNy1xET4YDXZRWm_bIyMIcStrF-JE,12249
24
+ agentize_bridge/server/credentials.py,sha256=EKjG-tkU3CtNGNDGtDngSS0B5DZY7BsxHxYZC---RNw,4077
25
+ agentize_bridge-0.2.0.dist-info/licenses/LICENSE,sha256=NN5aaZLEl8VloBdUCkScMPtkcIQtZwHuMhk6Lyi3SJI,1063
26
+ agentize_bridge-0.2.0.dist-info/METADATA,sha256=wFXYIzGuNyLyhc7lVLk7DnYd8H4w34Seu2Uk2KQQ-YU,4781
27
+ agentize_bridge-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
28
+ agentize_bridge-0.2.0.dist-info/entry_points.txt,sha256=Y3BiIC4Spz4HqN_JXqQwheBYxRoLPfMPIqUZz3p_gZk,173
29
+ agentize_bridge-0.2.0.dist-info/top_level.txt,sha256=o_flLFoqHg6_Jws8tyEV8aTdxOJ4kPURQMrIC5GEHLw,16
30
+ agentize_bridge-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,4 @@
1
+ [console_scripts]
2
+ agentize-bridge = agentize_bridge.adapters.cli:main
3
+ agentize-bridge-mcp = agentize_bridge.adapters.mcp_server:main
4
+ azb = agentize_bridge.adapters.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ewoaoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ agentize_bridge