Skip to main content

fp-acp — FP ACP 通信协议

PyPI Python License

简介

fp-acp 实现了 FP 的 Agent Communication Protocol(ACP),一个基于 JSON-RPC 2.0 的通信协议。它允许外部进程(IDE 插件、其他 Agent、自动化脚本)通过标准化的 API 与 Agent 交互。

通过 pip install fp-agent[acp]pip install fp-acp 安装。


什么是 ACP?

ACP(Agent Communication Protocol)定义了 Agent 与外部世界之间的标准通信契约。它使得:

  • IDE 集成 — VS Code、Neovim、Emacs 等编辑器通过 ACP 调用 Agent 能力
  • 跨 Agent 通信 — 多个 Agent 实例通过 ACP 协作完成任务
  • 自动化管道 — CI/CD 脚本通过 ACP 集成 Agent 进行代码审查、文档生成等
┌──────────┐    JSON-RPC 2.0    ┌───────────┐
│   IDE    │ ◄────────────────► │  ACP      │
│ 插件/    │                    │  Server   │──► fp-core Agent
│  脚本    │                    │  (fp-acp) │
└──────────┘                    └───────────┘

安装

pip install fp-acp

要求 Python >= 3.11。


快速使用

默认端口

fp-acp

指定主机和端口

fp-acp --host 127.0.0.1 --port 9090

启动日志:

╭─ FP ACP Server ────────────────╮
│                                           │
│  监听地址: tcp://127.0.0.1:9090          │
│  协议: JSON-RPC 2.0                      │
│                                           │
│  按 Ctrl+C 停止服务                       │
╰───────────────────────────────────────────╯

JSON-RPC 接口

ACP 使用标准的 JSON-RPC 2.0 协议,支持以下方法:

核心方法

方法 参数 返回 说明
chat {message, session_id?, stream?} {response} 发送消息并获取回复
chat_stream {message, session_id?} SSE 流 流式聊天(Server-Sent Events)
tools/list {} [{name, description, parameters}] 获取可用工具列表
tools/call {name, arguments} {result} 直接调用工具
sessions/list {} [{id, created_at, message_count}] 列出会话
sessions/create {id?} {id} 创建新会话
sessions/delete {id} {success} 删除会话
sessions/history {id, limit?} [{role, content}] 获取会话历史
config/get {} {config} 获取当前配置
config/set {key, value} {success} 更新配置项
ping {} {pong} 健康检查
shutdown {} {success} 优雅关闭 Server

调用示例

使用 curl

# 发送聊天消息
curl -X POST http://127.0.0.1:9090 \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "chat",
    "params": {
      "message": "你好,请介绍一下自己",
      "session_id": "my-session"
    }
  }'

响应:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "response": "你好!我是 FP,一个基于生命周期钩子的插件化 Agent。"
  }
}

使用 Python

import httpx

rpc_request = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/list",
    "params": {}
}

response = httpx.post("http://127.0.0.1:9090", json=rpc_request)
tools = response.json()["result"]
print(tools)

使用场景

1. VS Code 集成

通过 ACP,VS Code 扩展可以直接调用 Agent 进行代码审查、重构建议、自动补全:

用户选中代码 → 右键 "Ask FP" → ACP Server 返回分析结果

2. 多 Agent 协作

# Agent A 通过 ACP 调用 Agent B 的专业能力
response = httpx.post("http://agent-b:9090", json={
    "jsonrpc": "2.0",
    "method": "chat",
    "params": {"message": "请分析这段代码的安全性: ..."}
})

3. CI/CD 集成

# .github/workflows/code-review.yml
jobs:
  review:
    steps:
      - run: |
          curl -X POST http://agent:9090 \
            -H "Content-Type: application/json" \
            -d '{
              "method": "chat",
              "params": {
                "message": "Review the diff in commit ${{ github.sha }}"
              }
            }'

安全说明

  • ACP Server 默认绑定 127.0.0.1(仅本地访问)
  • 如果需要远程访问,使用 --host 0.0.0.0 并配合防火墙或反向代理
  • 生产环境建议添加 TLS 加密和 API 认证

依赖

依赖 版本 用途
fp-core >= 0.1.0 Agent 核心引擎

许可

MIT © zpb

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fp_acp-0.1.13.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fp_acp-0.1.13-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file fp_acp-0.1.13.tar.gz.

File metadata

  • Download URL: fp_acp-0.1.13.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for fp_acp-0.1.13.tar.gz
Algorithm Hash digest
SHA256 4c7dba4e96e443837a17e9fefa91cd7561af2951acc8fe48b0c54b6db6f36e55
MD5 8d5309bc3245b2f46bf09e89ff3719c2
BLAKE2b-256 c7f4652901b8fb1709e6d23248c81ae860461de89f69e1394c8e915a66637ebb

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_acp-0.1.13.tar.gz:

Publisher: release.yml on zpb911km/fp-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fp_acp-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: fp_acp-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for fp_acp-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 fa2c0dcdc241e9663ddcda24de0447038b566e9e2db5e22d101397df2b4b3052
MD5 371525c176c364e25bfa8c64fbf9619a
BLAKE2b-256 8d93e2a2cb1f1de2e71904cb7612c3120c88a73e0e44bdd4170d1f26fa7dd8bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fp_acp-0.1.13-py3-none-any.whl:

Publisher: release.yml on zpb911km/fp-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.13 This release

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

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