Skip to main content

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,反之亦然。

Metadata

Release files for agent-phonon-sdk 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-phonon-sdk 0.9.1
File Size Uploaded Provenance
agent_phonon_sdk-0.9.1.tar.gz 10.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-phonon-sdk 0.9.1
File Interpreter ABI Platform
agent_phonon_sdk-0.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / agent_phonon_sdk-0.9.1.tar.gz

Download URL agent_phonon_sdk-0.9.1.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8c18b4b1e235254273a33b8ad02bda957c9c0dd3b042671172756e8f4eb5d611
BLAKE2b-256 checksum
How to use checksums
c497f13aa962fad14bea7b534ec52b2ffafa571ad2610f98cbe4eb7df558c7f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 30, 2026.

Transparency log

Release files / agent_phonon_sdk-0.9.1-py3-none-any.whl

Download URL agent_phonon_sdk-0.9.1-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c20a1d55c885f27f7c2333c184151e1e2c270305caad172be2d72ca2f77e774
BLAKE2b-256 checksum
How to use checksums
2a9cfc261ba9b0cc1e02e4f2746fe91345df9611c560cb2715837d487d8193e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 30, 2026.

Transparency log

Security for agent-phonon-sdk 0.9.1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for agent_phonon_sdk-0.9.1.tar.gz

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 Jun 30, 2026.

Transparency log

A 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.

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