Introduction¶
The philosophy behind DeepSeek Harness (DSH) is “everything is a plugin.” When connecting an Agent to DSH, you install the plugins for whatever capabilities you need. If all you want to do is “control the local macOS Music app,” you can write your own AppleScript or use existing tools. The dsh-music plugin is the solution that gives an Agent this capability: letting the Agent play songs, control playback, and check the current status through natural conversation.
How it works: the Agent executes a tool → the plugin calls a persistent daemon via a Unix socket → the daemon controls the Music app through AppleScript. Compared to calling osascript directly, this approach reduces per-operation latency from hundreds of milliseconds down to tens of milliseconds.
Plugin Overview¶
- Name: dsh-music
- Maintainer: Ez4code
- Category: Workflow
- Description: Enables a DSH Agent to control the macOS Music app, supporting song playback, playback control, system volume, and status queries
Core Capabilities¶
The plugin registers four tools for the Agent, each corresponding to a different capability:
music_play: Matches library tracks by song title / artist / album with partial (fuzzy) matching; supports both Chinese and English; plays a specified playlistmusic_search: Searches without playing — confirms whether a song exists in the librarymusic_control: Resume, pause, play/pause, previous track, next track, stop; adjust system output volumemusic_status: Returns the current track, artist, album, progress, system volume, and mute state
System volume controls the “system output volume,” consistent with the menu bar and keyboard volume keys — not the slider inside the Music app. When increasing volume, mute is automatically turned off.
Installation & Enablement¶
Prerequisites:
- macOS 26+ (Tahoe)
- DeepSeek Harness (DSH) installed and running
- Apple Music signed in, with songs in the library
Installation steps:
- Clone the repository
git clone https://github.com/Ez4code/dsh-music.git
- Install into DSH
- Navigate to the “Plugins” menu in the DSH UI
- Select “Add Plugin”
- Choose the cloned dsh-music directory
Alternatively, let the Agent execute:
plugin_manager.installBundle("/path/to/dsh-music")
The first time the plugin controls the Music app, macOS will show a one-time prompt: “MusicHelper wants to control Music.” Click “Allow,” and it won’t bother you again.
Requesting Songs via IM¶
After installing and connecting @xmanrui/dsh-im, the chat window becomes your remote control.
Example conversation:
You (WeChat): Play Bang!
DSH: Now playing: Bang! — AJR (OK ORCHESTRA)
You: Next track, volume to 40
DSH: Now playing (system volume 40): Sports car — Tate McRae
You: What’s playing now?
DSH: Now playing: Sports car — Tate McRae (SO CLOSE TO WHAT???)
(0:42 / 2:45, system volume 40)
No glue code needed: dsh-music’s tools are registered on the same Agent, and dsh-im simply delivers the messages.
Performance¶
Tool-side latency is in the tens-of-milliseconds range:
| Action | Tool-side latency |
|---|---|
| Play a song and start playback | 130–270 ms |
| Pause / Resume / Skip / Volume | 50–70 ms |
| Query “what’s playing” | ~130 ms |
| Search library | 70–85 ms |
| First cold start of the day | 300–500 ms (one-time only) |
Optimizations:
- Persistent daemon: after the first invocation, the helper stays listening on the Unix socket. Subsequent calls are a single socket round-trip (10–30 ms) instead of spawning a new process per request
- Wait for state changes, don’t blindly sleep: play/pause uses short polling to wait for the player state to actually change, replacing fixed delays
- No wasted work: control scripts no longer read system volume as a side effect; on plugin reload, the plugin first pings the existing daemon to avoid spawning a duplicate helper
How It Works¶
The flow is as follows:
- User sends a command via IM →
dsh-impasses it to the Agent - Agent executes the corresponding tool (
music_play,music_control,music_status, etc.) - The plugin communicates with the persistent daemon over a Unix socket
- The daemon controls the Music app via AppleScript
- The Music app performs playback or updates its status
The plugin ships with an ad-hoc signed assets/MusicHelper.app, launched via open. Its purpose is to provide a separate Apple Events authorization identity, because the DSH host runs inside a sandbox and has not declared an Apple Events usage purpose — a direct osascript call would be rejected by the system (-10004 authorization violation).
The daemon’s exchange directory with the plugin defaults to /tmp/dsh-music, with socket file permissions set to 0600.
Configuration¶
The following keys can be adjusted in the plugin line of cordis.patch.yml:
| Key | Default | Description |
|—|—|
| timeoutSec | 20 | Timeout for a single AppleScript call (seconds), max 120 |
| helperPath | Bundled assets/MusicHelper.app | Path to the helper app |
| exchangeDir | /tmp/dsh-music | Directory where the helper and plugin exchange the socket |
Limitations¶
- Only plays tracks already in the library; does not access the network, search the Apple Music catalog, record audio, or upload any data
- Cloud tracks require a valid Apple Music subscription; local file tracks have no such restriction
- macOS only, requires macOS 26+
- AppleScript commands execute serially (one at a time)
Who It’s For¶
If you’re building a DSH-based Agent and need it to control local macOS Music, this plugin is ready to use out of the box. It also fits scenarios where you want to request songs remotely via IM (WeChat, QQ, Feishu, etc.).
We recommend reviewing the source code and license (MIT) before installing.