fp-acp 0.1.1.dev0__tar.gz

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,218 @@
1
+ Metadata-Version: 2.4
2
+ Name: fp-acp
3
+ Version: 0.1.1.dev0
4
+ Summary: 五块卵石 - ACP Server (JSON-RPC 2.0)
5
+ Author: zpb
6
+ License-Expression: MIT
7
+ Keywords: agent,acp,ide
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: Communications
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: fp-core>=0.1.0
17
+
18
+ # fp-acp — 五块卵石 ACP 通信协议
19
+
20
+ [![PyPI](https://img.shields.io/pypi/v/fp-acp)](https://pypi.org/project/fp-acp/)
21
+ [![Python](https://img.shields.io/pypi/pyversions/fp-acp)](https://pypi.org/project/fp-acp/)
22
+ [![License](https://img.shields.io/pypi/l/fp-acp)](LICENSE)
23
+
24
+ ## 简介
25
+
26
+ **fp-acp** 实现了五块卵石(Five Pebbles)的 Agent Communication Protocol(ACP),一个基于 **JSON-RPC 2.0** 的通信协议。它允许外部进程(IDE 插件、其他 Agent、自动化脚本)通过标准化的 API 与 Agent 交互。
27
+
28
+ > 通过 `pip install fp-agent[acp]` 或 `pip install fp-acp` 安装。
29
+
30
+ ---
31
+
32
+ ## 什么是 ACP?
33
+
34
+ ACP(Agent Communication Protocol)定义了 Agent 与外部世界之间的标准通信契约。它使得:
35
+
36
+ - **IDE 集成** — VS Code、Neovim、Emacs 等编辑器通过 ACP 调用 Agent 能力
37
+ - **跨 Agent 通信** — 多个 Agent 实例通过 ACP 协作完成任务
38
+ - **自动化管道** — CI/CD 脚本通过 ACP 集成 Agent 进行代码审查、文档生成等
39
+
40
+ ```
41
+ ┌──────────┐ JSON-RPC 2.0 ┌───────────┐
42
+ │ IDE │ ◄────────────────► │ ACP │
43
+ │ 插件/ │ │ Server │──► fp-core Agent
44
+ │ 脚本 │ │ (fp-acp) │
45
+ └──────────┘ └───────────┘
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 安装
51
+
52
+ ```bash
53
+ pip install fp-acp
54
+ ```
55
+
56
+ 要求 Python >= 3.11。
57
+
58
+ ---
59
+
60
+ ## 快速使用
61
+
62
+ ### 默认端口
63
+
64
+ ```bash
65
+ fp-acp
66
+ ```
67
+
68
+ ### 指定主机和端口
69
+
70
+ ```bash
71
+ fp-acp --host 127.0.0.1 --port 9090
72
+ ```
73
+
74
+ 启动日志:
75
+
76
+ ```
77
+ ╭─ Five Pebbles ACP Server ────────────────╮
78
+ │ │
79
+ │ 监听地址: tcp://127.0.0.1:9090 │
80
+ │ 协议: JSON-RPC 2.0 │
81
+ │ │
82
+ │ 按 Ctrl+C 停止服务 │
83
+ ╰───────────────────────────────────────────╯
84
+ ```
85
+
86
+ ---
87
+
88
+ ## JSON-RPC 接口
89
+
90
+ ACP 使用标准的 JSON-RPC 2.0 协议,支持以下方法:
91
+
92
+ ### 核心方法
93
+
94
+ | 方法 | 参数 | 返回 | 说明 |
95
+ |------|------|------|------|
96
+ | `chat` | `{message, session_id?, stream?}` | `{response}` | 发送消息并获取回复 |
97
+ | `chat_stream` | `{message, session_id?}` | SSE 流 | 流式聊天(Server-Sent Events) |
98
+ | `tools/list` | `{}` | `[{name, description, parameters}]` | 获取可用工具列表 |
99
+ | `tools/call` | `{name, arguments}` | `{result}` | 直接调用工具 |
100
+ | `sessions/list` | `{}` | `[{id, created_at, message_count}]` | 列出会话 |
101
+ | `sessions/create` | `{id?}` | `{id}` | 创建新会话 |
102
+ | `sessions/delete` | `{id}` | `{success}` | 删除会话 |
103
+ | `sessions/history` | `{id, limit?}` | `[{role, content}]` | 获取会话历史 |
104
+ | `config/get` | `{}` | `{config}` | 获取当前配置 |
105
+ | `config/set` | `{key, value}` | `{success}` | 更新配置项 |
106
+ | `ping` | `{}` | `{pong}` | 健康检查 |
107
+ | `shutdown` | `{}` | `{success}` | 优雅关闭 Server |
108
+
109
+ ### 调用示例
110
+
111
+ #### 使用 curl
112
+
113
+ ```bash
114
+ # 发送聊天消息
115
+ curl -X POST http://127.0.0.1:9090 \
116
+ -H "Content-Type: application/json" \
117
+ -d '{
118
+ "jsonrpc": "2.0",
119
+ "id": 1,
120
+ "method": "chat",
121
+ "params": {
122
+ "message": "你好,请介绍一下自己",
123
+ "session_id": "my-session"
124
+ }
125
+ }'
126
+ ```
127
+
128
+ 响应:
129
+
130
+ ```json
131
+ {
132
+ "jsonrpc": "2.0",
133
+ "id": 1,
134
+ "result": {
135
+ "response": "你好!我是五块卵石,一个基于生命周期钩子的插件化 Agent。"
136
+ }
137
+ }
138
+ ```
139
+
140
+ #### 使用 Python
141
+
142
+ ```python
143
+ import httpx
144
+
145
+ rpc_request = {
146
+ "jsonrpc": "2.0",
147
+ "id": 1,
148
+ "method": "tools/list",
149
+ "params": {}
150
+ }
151
+
152
+ response = httpx.post("http://127.0.0.1:9090", json=rpc_request)
153
+ tools = response.json()["result"]
154
+ print(tools)
155
+ ```
156
+
157
+ ---
158
+
159
+ ## 使用场景
160
+
161
+ ### 1. VS Code 集成
162
+
163
+ 通过 ACP,VS Code 扩展可以直接调用 Agent 进行代码审查、重构建议、自动补全:
164
+
165
+ ```
166
+ 用户选中代码 → 右键 "Ask Five Pebbles" → ACP Server 返回分析结果
167
+ ```
168
+
169
+ ### 2. 多 Agent 协作
170
+
171
+ ```python
172
+ # Agent A 通过 ACP 调用 Agent B 的专业能力
173
+ response = httpx.post("http://agent-b:9090", json={
174
+ "jsonrpc": "2.0",
175
+ "method": "chat",
176
+ "params": {"message": "请分析这段代码的安全性: ..."}
177
+ })
178
+ ```
179
+
180
+ ### 3. CI/CD 集成
181
+
182
+ ```yaml
183
+ # .github/workflows/code-review.yml
184
+ jobs:
185
+ review:
186
+ steps:
187
+ - run: |
188
+ curl -X POST http://agent:9090 \
189
+ -H "Content-Type: application/json" \
190
+ -d '{
191
+ "method": "chat",
192
+ "params": {
193
+ "message": "Review the diff in commit ${{ github.sha }}"
194
+ }
195
+ }'
196
+ ```
197
+
198
+ ---
199
+
200
+ ## 安全说明
201
+
202
+ - ACP Server 默认绑定 `127.0.0.1`(仅本地访问)
203
+ - 如果需要远程访问,使用 `--host 0.0.0.0` 并配合防火墙或反向代理
204
+ - 生产环境建议添加 TLS 加密和 API 认证
205
+
206
+ ---
207
+
208
+ ## 依赖
209
+
210
+ | 依赖 | 版本 | 用途 |
211
+ |------|------|------|
212
+ | `fp-core` | >= 0.1.0 | Agent 核心引擎 |
213
+
214
+ ---
215
+
216
+ ## 许可
217
+
218
+ MIT © zpb
@@ -0,0 +1,201 @@
1
+ # fp-acp — 五块卵石 ACP 通信协议
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/fp-acp)](https://pypi.org/project/fp-acp/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/fp-acp)](https://pypi.org/project/fp-acp/)
5
+ [![License](https://img.shields.io/pypi/l/fp-acp)](LICENSE)
6
+
7
+ ## 简介
8
+
9
+ **fp-acp** 实现了五块卵石(Five Pebbles)的 Agent Communication Protocol(ACP),一个基于 **JSON-RPC 2.0** 的通信协议。它允许外部进程(IDE 插件、其他 Agent、自动化脚本)通过标准化的 API 与 Agent 交互。
10
+
11
+ > 通过 `pip install fp-agent[acp]` 或 `pip install fp-acp` 安装。
12
+
13
+ ---
14
+
15
+ ## 什么是 ACP?
16
+
17
+ ACP(Agent Communication Protocol)定义了 Agent 与外部世界之间的标准通信契约。它使得:
18
+
19
+ - **IDE 集成** — VS Code、Neovim、Emacs 等编辑器通过 ACP 调用 Agent 能力
20
+ - **跨 Agent 通信** — 多个 Agent 实例通过 ACP 协作完成任务
21
+ - **自动化管道** — CI/CD 脚本通过 ACP 集成 Agent 进行代码审查、文档生成等
22
+
23
+ ```
24
+ ┌──────────┐ JSON-RPC 2.0 ┌───────────┐
25
+ │ IDE │ ◄────────────────► │ ACP │
26
+ │ 插件/ │ │ Server │──► fp-core Agent
27
+ │ 脚本 │ │ (fp-acp) │
28
+ └──────────┘ └───────────┘
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 安装
34
+
35
+ ```bash
36
+ pip install fp-acp
37
+ ```
38
+
39
+ 要求 Python >= 3.11。
40
+
41
+ ---
42
+
43
+ ## 快速使用
44
+
45
+ ### 默认端口
46
+
47
+ ```bash
48
+ fp-acp
49
+ ```
50
+
51
+ ### 指定主机和端口
52
+
53
+ ```bash
54
+ fp-acp --host 127.0.0.1 --port 9090
55
+ ```
56
+
57
+ 启动日志:
58
+
59
+ ```
60
+ ╭─ Five Pebbles ACP Server ────────────────╮
61
+ │ │
62
+ │ 监听地址: tcp://127.0.0.1:9090 │
63
+ │ 协议: JSON-RPC 2.0 │
64
+ │ │
65
+ │ 按 Ctrl+C 停止服务 │
66
+ ╰───────────────────────────────────────────╯
67
+ ```
68
+
69
+ ---
70
+
71
+ ## JSON-RPC 接口
72
+
73
+ ACP 使用标准的 JSON-RPC 2.0 协议,支持以下方法:
74
+
75
+ ### 核心方法
76
+
77
+ | 方法 | 参数 | 返回 | 说明 |
78
+ |------|------|------|------|
79
+ | `chat` | `{message, session_id?, stream?}` | `{response}` | 发送消息并获取回复 |
80
+ | `chat_stream` | `{message, session_id?}` | SSE 流 | 流式聊天(Server-Sent Events) |
81
+ | `tools/list` | `{}` | `[{name, description, parameters}]` | 获取可用工具列表 |
82
+ | `tools/call` | `{name, arguments}` | `{result}` | 直接调用工具 |
83
+ | `sessions/list` | `{}` | `[{id, created_at, message_count}]` | 列出会话 |
84
+ | `sessions/create` | `{id?}` | `{id}` | 创建新会话 |
85
+ | `sessions/delete` | `{id}` | `{success}` | 删除会话 |
86
+ | `sessions/history` | `{id, limit?}` | `[{role, content}]` | 获取会话历史 |
87
+ | `config/get` | `{}` | `{config}` | 获取当前配置 |
88
+ | `config/set` | `{key, value}` | `{success}` | 更新配置项 |
89
+ | `ping` | `{}` | `{pong}` | 健康检查 |
90
+ | `shutdown` | `{}` | `{success}` | 优雅关闭 Server |
91
+
92
+ ### 调用示例
93
+
94
+ #### 使用 curl
95
+
96
+ ```bash
97
+ # 发送聊天消息
98
+ curl -X POST http://127.0.0.1:9090 \
99
+ -H "Content-Type: application/json" \
100
+ -d '{
101
+ "jsonrpc": "2.0",
102
+ "id": 1,
103
+ "method": "chat",
104
+ "params": {
105
+ "message": "你好,请介绍一下自己",
106
+ "session_id": "my-session"
107
+ }
108
+ }'
109
+ ```
110
+
111
+ 响应:
112
+
113
+ ```json
114
+ {
115
+ "jsonrpc": "2.0",
116
+ "id": 1,
117
+ "result": {
118
+ "response": "你好!我是五块卵石,一个基于生命周期钩子的插件化 Agent。"
119
+ }
120
+ }
121
+ ```
122
+
123
+ #### 使用 Python
124
+
125
+ ```python
126
+ import httpx
127
+
128
+ rpc_request = {
129
+ "jsonrpc": "2.0",
130
+ "id": 1,
131
+ "method": "tools/list",
132
+ "params": {}
133
+ }
134
+
135
+ response = httpx.post("http://127.0.0.1:9090", json=rpc_request)
136
+ tools = response.json()["result"]
137
+ print(tools)
138
+ ```
139
+
140
+ ---
141
+
142
+ ## 使用场景
143
+
144
+ ### 1. VS Code 集成
145
+
146
+ 通过 ACP,VS Code 扩展可以直接调用 Agent 进行代码审查、重构建议、自动补全:
147
+
148
+ ```
149
+ 用户选中代码 → 右键 "Ask Five Pebbles" → ACP Server 返回分析结果
150
+ ```
151
+
152
+ ### 2. 多 Agent 协作
153
+
154
+ ```python
155
+ # Agent A 通过 ACP 调用 Agent B 的专业能力
156
+ response = httpx.post("http://agent-b:9090", json={
157
+ "jsonrpc": "2.0",
158
+ "method": "chat",
159
+ "params": {"message": "请分析这段代码的安全性: ..."}
160
+ })
161
+ ```
162
+
163
+ ### 3. CI/CD 集成
164
+
165
+ ```yaml
166
+ # .github/workflows/code-review.yml
167
+ jobs:
168
+ review:
169
+ steps:
170
+ - run: |
171
+ curl -X POST http://agent:9090 \
172
+ -H "Content-Type: application/json" \
173
+ -d '{
174
+ "method": "chat",
175
+ "params": {
176
+ "message": "Review the diff in commit ${{ github.sha }}"
177
+ }
178
+ }'
179
+ ```
180
+
181
+ ---
182
+
183
+ ## 安全说明
184
+
185
+ - ACP Server 默认绑定 `127.0.0.1`(仅本地访问)
186
+ - 如果需要远程访问,使用 `--host 0.0.0.0` 并配合防火墙或反向代理
187
+ - 生产环境建议添加 TLS 加密和 API 认证
188
+
189
+ ---
190
+
191
+ ## 依赖
192
+
193
+ | 依赖 | 版本 | 用途 |
194
+ |------|------|------|
195
+ | `fp-core` | >= 0.1.0 | Agent 核心引擎 |
196
+
197
+ ---
198
+
199
+ ## 许可
200
+
201
+ MIT © zpb
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64.0", "setuptools-scm>=8.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "fp-acp"
7
+ dynamic = ["version"]
8
+ description = "五块卵石 - ACP Server (JSON-RPC 2.0)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ authors = [{name = "zpb"}]
13
+ keywords = ["agent", "acp", "ide"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Operating System :: OS Independent",
20
+ "Topic :: Communications",
21
+ ]
22
+
23
+ dependencies = [
24
+ "fp-core>=0.1.0",
25
+ ]
26
+
27
+ [project.scripts]
28
+ fp-acp = "fp_acp.server:main"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
32
+ include = ["fp_acp*"]
33
+
34
+ [tool.setuptools_scm]
35
+ root = "../.."
36
+ local_scheme = "no-local-version"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ """
2
+ fp-acp — ACP (Agent Client Protocol) Server
3
+
4
+ 将五块卵石作为 ACP Server 接入 VS Code / Zed 等 IDE,
5
+ 让编辑器直接驱动 AI Agent,无需复制粘贴。
6
+
7
+ 协议: JSON-RPC 2.0 over stdio
8
+ 参考: https://github.com/agentclientprotocol/agent-client-protocol
9
+ """
10
+
11
+ from .server import main as run
12
+
13
+ __all__ = ["run"]
File without changes