Server SDK for agent-phonon — orchestrate AI agents across multiple devices.
Project description
agent-phonon — Python Server SDK
让任何 Python 项目「一键成为 agent-phonon 服务端」:编排多台设备上的 AI agent(Claude Code / Codex / OpenCode / OpenClaw / Hermes)。
安装
pip install agent-phonon # 或 pip install -e sdk-python/
用法
import asyncio
from agent_phonon import PhononServer
async def main():
server = PhononServer(port=8080, authenticate=verify_device)
@server.on_device
async def handle(device): # 每台设备拨入时
agents = await device.discover() # 列设备上的 agent
proj = await device.project_create("my-proj")
session = await device.create_session(
project=proj["project"]["projectId"],
agent="openclaw:main", model="claude-opus-4.8",
)
# HITL:危险操作裁决
device.set_hook_decider(
lambda hook, s: "abort" if "rm -rf" in str(hook.get("payload", {})) else "continue"
)
await session.send("帮我重构这个函数")
async for event in session.stream(): # 流式输出
if event.get("type") == "message":
print(event["text"], end="")
await server.listen()
await asyncio.Future() # 长跑
async def verify_device(device_id, device_key):
return "tenant-1" if device_key == "secret" else None # None = 拒绝
asyncio.run(main())
核心抽象
PhononServer— ws 监听,管理多设备;authenticate(device_id, device_key) -> tenant_id | None;on_device回调;list_devices()/get_device()PhononDevice—discover()/create_session()/list_sessions()+project_*/skill_*封装;set_hook_decider()(HITL)/set_unsolicited_handler()(自发输出)PhononSession—send()+async for event in session.stream()(流式);inject/interrupt/switch_model/compress/status/terminate;自动 stream.ack
多设备
一个 PhononServer 同时连多个 phonon 设备,各设备 tenant 隔离、互不干扰——这是 phonon 作为「个人设备编排中心」的核心。
协议
JSON-RPC 2.0 over WebSocket。与 TS SDK(@agent-phonon/server-sdk)完全协议兼容——Python 服务端能指挥 TS phonon,反之亦然。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_phonon_sdk-0.2.4.tar.gz.
File metadata
- Download URL: agent_phonon_sdk-0.2.4.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e9768ceced9a26955879f1af82cf5d9567716f162e813cc03c90dd69e7098aa
|
|
| MD5 |
bc83d8e396e67ba3dc088e5647d85048
|
|
| BLAKE2b-256 |
d333a64570076a5ecbb47102723c201b3bd4071aa77fde3cfbf03e023189d73c
|
Provenance
The following attestation bundles were made for agent_phonon_sdk-0.2.4.tar.gz:
Publisher:
publish-pypi.yml on hackerphysics/agent-phonon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_phonon_sdk-0.2.4.tar.gz -
Subject digest:
1e9768ceced9a26955879f1af82cf5d9567716f162e813cc03c90dd69e7098aa - Sigstore transparency entry: 1910240354
- Sigstore integration time:
-
Permalink:
hackerphysics/agent-phonon@6bcf95bb9ebab276964c21018c69d6ddd715b9f9 -
Branch / Tag:
refs/tags/py-v0.2.4 - Owner: https://github.com/hackerphysics
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@6bcf95bb9ebab276964c21018c69d6ddd715b9f9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agent_phonon_sdk-0.2.4-py3-none-any.whl.
File metadata
- Download URL: agent_phonon_sdk-0.2.4-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e65e4e5955f32507791443b3021fb295852eaf8314b547de37345a63a6fdec2c
|
|
| MD5 |
072a9f2753699f360cbc37c9aa808ed2
|
|
| BLAKE2b-256 |
9316b1c64d9fc3ec42a491273ae2887db65b02c419db3d17dcc3f167285c9f55
|
Provenance
The following attestation bundles were made for agent_phonon_sdk-0.2.4-py3-none-any.whl:
Publisher:
publish-pypi.yml on hackerphysics/agent-phonon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_phonon_sdk-0.2.4-py3-none-any.whl -
Subject digest:
e65e4e5955f32507791443b3021fb295852eaf8314b547de37345a63a6fdec2c - Sigstore transparency entry: 1910240474
- Sigstore integration time:
-
Permalink:
hackerphysics/agent-phonon@6bcf95bb9ebab276964c21018c69d6ddd715b9f9 -
Branch / Tag:
refs/tags/py-v0.2.4 - Owner: https://github.com/hackerphysics
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@6bcf95bb9ebab276964c21018c69d6ddd715b9f9 -
Trigger Event:
push
-
Statement type: