Skip to main content
Glama
00011110

trayfeel

by 00011110

TrayFeel

面向 AI 智能体的即插即用 CD/DVD 托盘情感执行器。

TrayFeel 将 Linux 光驱转变为物理肢体语言通道:open、close、pulse、wiggle,以及一系列命名情感——以 Python 库、CLI、MCP 服务器和可选 HTTP 守护进程的形式提供。

Linux 优先。MIT 许可。纯 Python ioctl 路径(无需 eject 二进制文件)。

要求

  • Python 3.10+

  • Linux 系统,配备支持 OPEN_TRAY / CLOSE_TRAY 的 /dev/sr* 光驱

  • 用户属于 cdrom 组(Ubuntu/Debian 上通常如此)

sudo usermod -aG cdrom "$USER"
# log out and back in, then:
groups   # should list cdrom

安装

pip install trayfeel
# or from a checkout:
pip install -e ".[dev]"

可选环境变量(参见 .env.example):

变量

用途

TRAYFEEL_DEVICE

强制指定设备路径(默认:第一个 /dev/sr*)

TRAYFEEL_TOKEN

HTTP 守护进程的 Bearer 令牌

TRAYFEEL_CAMERA

可选的 /dev/videoN,用于视觉反馈

TRAYFEEL_HOST / TRAYFEEL_PORT

守护进程绑定地址(默认 127.0.0.1:8765)

快速入门

trayfeel list-drives
trayfeel doctor
trayfeel status
trayfeel pulse
trayfeel emote laugh
trayfeel emote nod_yes --dry-run
trayfeel catalog

Python:

from trayfeel import Tray

with Tray() as tray:
    print(tray.status())
    tray.run("pulse")
    tray.emote("wave")

安全

TrayFeel 默认拒绝鲁莽动作:

  • 每台设备的独占 flock 锁(~/.cache/trayfeel/…)

  • 速率限制(默认每分钟 30 次动作)

  • 动作之间的最小间隔(默认 200 毫秒)

  • 光盘保护——当光盘存在时,拒绝猛击模式(pulse、wiggle、nod 等),除非 force=True

  • 多次开合循环后的冷却时间

当你有意接受风险时,可使用 --force / force=True 覆盖。

情感

trayfeel/emotions/catalog.yaml 中的命名编排:

laugh, giggle, gasp, surprise, shrug, think, ponder, nod_yes, shake_no, applause, sulk, pout, excited, bored, angry, curious, wave, heartbeat, sigh, celebrate, confused, acknowledge, reject, greet, farewell, error, success, idle_breath

trayfeel emote celebrate
trayfeel emote think --dry-run

原语

open, close, toggle, lock, unlock, status, pulse, wiggle, hold_open, nod, double_tap, spin_up, spin_down, sleep, wait

MCP 服务器

trayfeel mcp
# or: python -m trayfeel mcp

工具:tray_status、tray_list_drives、tray_primitive、tray_emote、tray_catalog、tray_doctor。

Claude Desktop

添加到 claude_desktop_config.json:

{
  "mcpServers": {
    "trayfeel": {
      "command": "trayfeel",
      "args": ["mcp"]
    }
  }
}

Cursor

添加一个指向相同命令(trayfeel mcp 或 python -m trayfeel mcp)的 MCP 服务器条目。确保环境具有 cdrom 组权限。

用于 OpenAI / Claude 函数调用的工具模式位于 examples/openai_tools.json 和 examples/claude_tools.json。智能体技能说明:examples/agent_skill.md。

HTTP 守护进程

适用于无法附加 stdio MCP 的局域网智能体:

export TRAYFEEL_TOKEN="$(openssl rand -hex 16)"
trayfeel daemon --host 0.0.0.0 --port 8765

方法

路径

请求体

GET

/health

—

GET

/status

—

GET

/catalog

—

POST

/primitive

{"name":"pulse","open_ms":300}

POST

/emote

{"name":"wave"}

当配置了令牌时,发送 Authorization: Bearer $TRAYFEEL_TOKEN。

视觉(可选)

如果设置了 TRAYFEEL_CAMERA=/dev/video0 且安装了 ffmpeg,trayfeel vision 将通过 V4L2 捕获一帧,并返回尽力而为的亮度/边缘启发式结果。缺少摄像头或 ffmpeg 时返回 ok: false 并附带原因——它绝不会导致进程崩溃。

库结构

trayfeel/
  core.py          # Tray, Emoter
  primitives.py    # motion primitives
  safety.py        # flock, rate limits, disc guards
  hardware/linux.py
  emotions/        # catalog.yaml + engine
  mcp_server.py
  daemon.py
  cli.py

许可证

MIT——版权所有(c)2026 TrayFeel 贡献者

Related MCP Connectors