@elizaos/plugin-music 2.0.0-beta.1 → 2.0.3-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,192 +1,175 @@
1
- # @elizaos/plugin-music-library
2
-
3
- A comprehensive plugin for elizaOS that provides music data storage, user preferences, analytics, external music metadata APIs, and YouTube search functionality.
4
-
5
- ## Features
6
-
7
- ### Music Metadata & External APIs
8
- - **Track Information**: Extract metadata from YouTube URLs and track titles
9
- - **Artist Information**: Get artist details from multiple sources
10
- - **Album Information**: Retrieve album metadata
11
- - **Multiple Sources**: MusicBrainz, Last.fm, Genius, TheAudioDB, Wikipedia
12
- - **Fallback Chain**: Automatically tries multiple sources for best results
13
- - **Rate Limiting**: Built-in rate limiting for all APIs
14
- - **Retry Logic**: Automatic retry with exponential backoff
15
- - **Service Health Monitoring**: Tracks status of all integrated APIs
16
-
17
- ### YouTube Integration
18
- - **YouTube Search**: Search for tracks, artists, albums on YouTube
19
- - **Smart Query Parsing**: Detects artist, genre, mood intents
20
- - **URL Extraction**: Parse and validate YouTube URLs
21
-
22
- ### Music Library & Data Storage
23
- - **Track Database**: Store and discover tracks, albums, artists
24
- - **Play History**: Track what's been played and when
25
- - **Request Tracking**: Log who requested which tracks
26
- - **High-Quality Music Storage**: Store original high-quality audio files for archival
27
- - Organized by artist/album/track
28
- - Full metadata indexing
29
- - Optional high-quality vs standard quality modes
30
-
31
- ### Playlists
32
- - **Create & Save**: Save playlists for users
33
- - **Load & List**: Load and list playlists
34
- - **Share**: Share playlists between users
35
-
36
- ### User Preferences
37
- - **Favorite Tracks**: Track user favorite tracks
38
- - **Favorite Artists**: Track favorite artists
39
- - **Disliked Tracks**: Remember what users don't like
40
- - **Genre Preferences**: Learn genre preferences over time
41
- - **Room Preferences**: Aggregate preferences across users in a room
42
-
43
- ### Analytics
44
- - **Play Tracking**: Track every play with duration and requester
45
- - **Session Tracking**: Track listening sessions
46
- - **Statistics**: Get analytics for rooms (top tracks, artists, genres)
47
-
48
- ### Anti-Repetition
49
- - **Repetition Control**: Prevent tracks from replaying too soon
50
- - **Variety Scoring**: Score tracks by variety to encourage diverse playlists
1
+ # @elizaos/plugin-music
2
+
3
+ A comprehensive music plugin for elizaOS that provides music library management, playback, queue management, playlists, analytics, YouTube search, multi-source metadata APIs, AI music generation, and a streaming HTTP API for Eliza agents.
4
+
5
+ ## Capabilities
6
+
7
+ ### Music Playback
8
+ - Stream audio from YouTube URLs or direct media URLs to Discord voice channels or web clients
9
+ - Queue management: add, view, clear tracks
10
+ - Transport controls: play, pause, resume, skip, stop
11
+ - Multi-zone and multi-route audio (broadcast to multiple Discord guilds or web streams simultaneously)
12
+ - Live HTTP streaming endpoint (OGG/Shoutcast/Icecast) for web players
13
+
14
+ ### Music Library & Playlists
15
+ - Persistent song library with title, artist, album, and URL indexing
16
+ - Create, save, load, and share user playlists
17
+ - Play history and request tracking per user and room
18
+ - Smart play query: find and queue the best match from YouTube for a natural-language request
19
+ - Download audio to a local library archive
20
+
21
+ ### Metadata & Discovery
22
+ - Track, artist, and album metadata from MusicBrainz (no API key needed), Last.fm, Genius, TheAudioDB, and Wikipedia
23
+ - YouTube search with smart query parsing (artist, genre, mood)
24
+ - Spotify-backed recommendations
25
+ - Automatic fallback chain across sources
26
+
27
+ ### User Preferences & Analytics
28
+ - Per-user favorite tracks and artists, disliked tracks, genre preferences
29
+ - Aggregated room preferences for auto-fill and DJ logic
30
+ - Anti-repetition scoring to encourage variety
31
+ - Play count, session, and tip analytics
32
+
33
+ ### AI Music Generation (Suno)
34
+ - Generate original music from a text prompt (`generate`)
35
+ - Extend existing audio (`extend`)
36
+ - Custom generation with style, BPM, key, and reference audio (`custom_generate`)
37
+ - Requires `SUNO_API_KEY`
51
38
 
52
39
  ## Installation
53
40
 
54
- As this is a workspace package, it's installed as part of the elizaOS monorepo:
41
+ This plugin is part of the elizaOS monorepo:
55
42
 
56
43
  ```bash
57
44
  bun install
58
45
  ```
59
46
 
60
- ## Configuration
47
+ Add to a character config:
61
48
 
62
- The plugin works out of the box with MusicBrainz (free, no API key needed). For enhanced features, configure additional APIs:
49
+ ```json
50
+ {
51
+ "plugins": [
52
+ "@elizaos/plugin-sql",
53
+ "@elizaos/plugin-music"
54
+ ]
55
+ }
56
+ ```
63
57
 
64
- ### Storage Configuration
58
+ `@elizaos/plugin-sql` is recommended for persistent library, playlist, and preference storage.
65
59
 
66
- ```bash
67
- # High-quality music storage directory (default: ./storage/music)
68
- MUSIC_STORAGE_DIR=/path/to/storage
60
+ ## Auto-Enable
69
61
 
70
- # Store highest quality available (default: true)
71
- MUSIC_STORAGE_HIGH_QUALITY=true
72
- ```
62
+ The plugin auto-enables when any of these settings are present:
63
+ `LASTFM_API_KEY`, `GENIUS_API_KEY`, `THEAUDIODB_API_KEY`, `SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET`.
73
64
 
74
- **Storage vs Cache**:
75
- - **Music Library Storage** (this plugin): Permanent high-quality storage for archival and library management
76
- - Original quality files (WebM, MP4, etc.)
77
- - Organized by artist/album/track
78
- - Indexed for browsing and discovery
79
- - No expiration
80
- - **Music Player Cache** (`plugin-music-player`): Temporary Discord-optimized cache for performance
81
- - Pre-transcoded to Opus/WebM for Discord
82
- - Flat cache directory
83
- - 7-day TTL with automatic cleanup
84
- - Trades disk space for reduced CPU/bandwidth
65
+ ## Configuration
85
66
 
86
- ### Optional Configuration
67
+ ### Required System Dependencies
87
68
 
88
- Add these to your `.env` file for enhanced metadata:
69
+ - **`yt-dlp`** Must be in PATH for audio download and caching. Install via `brew install yt-dlp`, `pipx install yt-dlp`, or download from [github.com/yt-dlp/yt-dlp](https://github.com/yt-dlp/yt-dlp). Override path with `YT_DLP_PATH`.
70
+ - **`ffmpeg` / `ffprobe`** — Bundled via `ffmpeg-static`/`ffprobe-static`; override with `FFMPEG_PATH` and `FFPROBE_PATH`.
89
71
 
90
- ```bash
91
- # MusicBrainz (optional - custom User-Agent)
92
- MUSICBRAINZ_USER_AGENT=YourAppName/1.0.0 (https://yourapp.com)
72
+ ### Optional API Keys
93
73
 
94
- # Last.fm API (free tier with signup)
74
+ Add to `.env` or character settings for enhanced metadata and features:
75
+
76
+ ```bash
77
+ # Last.fm — artist/track metadata (free with signup)
95
78
  LASTFM_API_KEY=your_lastfm_api_key
96
79
 
97
- # Genius API (free tier with signup) - for lyrics URLs
80
+ # Genius lyrics URLs (free with signup)
98
81
  GENIUS_API_KEY=your_genius_api_key
99
82
 
100
- # TheAudioDB API (free tier with signup) - for high-quality artwork
83
+ # TheAudioDB high-quality artwork (free with signup)
101
84
  THEAUDIODB_API_KEY=your_theaudiodb_api_key
102
- ```
103
85
 
104
- ## Usage
86
+ # Spotify — recommendations
87
+ SPOTIFY_CLIENT_ID=your_spotify_client_id
88
+ SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
105
89
 
106
- Add the plugin to your character configuration:
90
+ # Suno AI music generation
91
+ SUNO_API_KEY=your_suno_api_key
107
92
 
108
- ```json
109
- {
110
- "plugins": [
111
- "@elizaos/plugin-sql",
112
- "@elizaos/plugin-music-library"
113
- ]
114
- }
93
+ # MusicBrainz — custom User-Agent (optional; free, no key needed)
94
+ MUSICBRAINZ_USER_AGENT=YourAppName/1.0.0 (https://yourapp.com)
115
95
  ```
116
96
 
117
- ### Service Usage
118
-
119
- Access services directly in your code:
97
+ ### Other Settings
120
98
 
121
- ```typescript
122
- const musicLibrary = runtime.getService('musicLibrary');
99
+ ```bash
100
+ # Audio cache directory (default: <cwd>/cache/audio)
101
+ AUDIO_CACHE_DIR=/path/to/cache
123
102
 
124
- // Get track info
125
- const trackInfo = await musicLibrary.getTrackInfo('https://youtube.com/watch?v=...');
103
+ # Download quality preference (default: mp3_320)
104
+ MUSIC_QUALITY_PREFERENCE=mp3_320
126
105
 
127
- // Save a playlist
128
- const playlist = await musicLibrary.savePlaylist(userId, {
129
- name: 'My Playlist',
130
- tracks: [...]
131
- });
106
+ # YouTube cookies file for age-restricted content
107
+ YOUTUBE_COOKIES=/path/to/cookies.txt
132
108
 
133
- // Track analytics
134
- await musicLibrary.trackTrackPlayed(roomId, track, duration, requester);
109
+ # Proxy for yt-dlp
110
+ YTDLP_PROXY=http://proxy:port
135
111
 
136
- // Get user preferences
137
- const prefs = await musicLibrary.getUserPreferences(userId);
112
+ # Enable verbose music debug logging
113
+ ELIZA_MUSIC_DEBUG=1
138
114
  ```
139
115
 
140
- ### Actions
116
+ ## Actions
141
117
 
142
- Available actions:
143
- - `MUSIC_LIBRARY` - Consolidated planner-facing action.
144
- - `op=playlist`, `subaction=save|load|delete|add` - Manage playlists.
145
- - `op=search-youtube` - Search YouTube for music.
146
- - `op=play-query` - Smart music query parser.
147
- - `op=download` - Download music to the local library.
118
+ All music operations route through a single **`MUSIC`** action with a verb-shaped `action` parameter.
148
119
 
149
- Legacy planner action names such as `PLAYLIST_OP`, `PLAYLIST`,
150
- `SEARCH_YOUTUBE`, `PLAY_MUSIC_QUERY`, and `DOWNLOAD_MUSIC` are retained as
151
- similes for `MUSIC_LIBRARY`.
120
+ | Subaction | Description |
121
+ |-----------|-------------|
122
+ | `play` | Play a track by URL or query |
123
+ | `pause` | Pause current playback |
124
+ | `resume` | Resume paused playback |
125
+ | `skip` | Skip to next track (requires `confirmed: true`) |
126
+ | `stop` | Stop playback (requires `confirmed: true`) |
127
+ | `queue_view` | Show current queue |
128
+ | `queue_add` | Add a track to the queue (requires `confirmed: true`) |
129
+ | `queue_clear` | Clear the queue (requires `confirmed: true`) |
130
+ | `playlist_play` | Load and play a saved playlist |
131
+ | `playlist_save` | Save current queue as a playlist (requires `confirmed: true`) |
132
+ | `search` | Search YouTube for music |
133
+ | `play_query` | Smart natural-language music query (search + play) |
134
+ | `download` | Download a track to the local library (requires `confirmed: true`) |
135
+ | `play_audio` | Play a direct media URL |
136
+ | `set_routing` | Configure audio routing mode |
137
+ | `set_zone` | Configure audio zones |
138
+ | `generate` | AI-generate music from prompt (Suno) |
139
+ | `extend` | Extend existing Suno audio |
140
+ | `custom_generate` | Custom Suno generation with style/BPM/key |
152
141
 
153
- ## Integration with Other Plugins
142
+ The `MUSIC` action aggregates similes from its sub-handlers, so legacy intent names such as `PAUSE_MUSIC`, `PLAY_YOUTUBE`, `PLAYLIST`, `SEARCH_YOUTUBE`, `PLAY_MUSIC_QUERY`, `DOWNLOAD_MUSIC`, and `GENERATE_MUSIC` still match. The verb-shaped aliases in `SUBACTION_ALIASES` (e.g. `playlist`, `search_youtube`, `routing`, `zones`, `next`, `unpause`) are also accepted for the `action` parameter.
154
143
 
155
- This plugin is designed to work with:
144
+ ## HTTP Streaming API
156
145
 
157
- - **@elizaos/plugin-music-player**: Provides data storage for playback
158
- - **@elizaos/plugin-radio**: Provides preferences and analytics for radio programming
159
- - **@elizaos/plugin-sql**: Required for data persistence
146
+ The plugin registers routes on the agent's HTTP server (prefix `/api/<agentId>/music-player/`):
160
147
 
161
- ## API
148
+ | Method | Path | Auth | Description |
149
+ |--------|------|------|-------------|
150
+ | GET | `/stream` | public | Live audio stream |
151
+ | GET | `/now-playing` | public | Now-playing metadata |
152
+ | GET | `/queue` | public | Queue JSON |
153
+ | GET | `/status` | public | Playback status |
154
+ | POST | `/control/pause` | authenticated | Pause |
155
+ | POST | `/control/resume` | authenticated | Resume |
156
+ | POST | `/control/stop` | authenticated | Stop |
157
+ | POST | `/control/skip` | authenticated | Skip |
162
158
 
163
- ### Services
159
+ Authenticated endpoints accept `Authorization: Bearer <token>`, `X-Eliza-Token`, or `X-Api-Key`.
164
160
 
165
- #### MusicInfoService
166
- - `getTrackInfo(urlOrTitle: string)`: Get track metadata
167
- - `getArtistInfo(artistName: string)`: Get artist information
168
- - `getAlbumInfo(albumTitle: string, artistName?: string)`: Get album information
161
+ ## Services
169
162
 
170
- #### YouTubeSearchService
171
- - `search(query: string, maxResults?: number)`: Search YouTube
172
- - `extractVideoId(url: string)`: Extract video ID from URL
163
+ Access from agent code via `runtime.getService(...)`:
173
164
 
174
- #### MusicLibraryService
175
- - `addSong(song)`, `getSong(url)`, `getRecentSongs(limit)`, `searchLibrary(query)`
176
- - `savePlaylist(entityId, playlist)`, `loadPlaylists(entityId)`
177
- - `trackTrackPlayed(roomId, track, duration)`, `trackTrackRequest(entityId, track)`
178
- - `getAggregatedRoomPreferences(roomId)` returns combined favorites/dislikes for auto-fill logic
179
- - Exposes `repetitionControl` utilities and a configured `spotifyClient`
165
+ - `runtime.getService('music')` → `MusicService` — playback engine, queue, routing
166
+ - `runtime.getService('musicLibrary')` `MusicLibraryService` — library, playlists, preferences, analytics
180
167
 
181
- ### Components
168
+ ## Integration
182
169
 
183
- See individual component files for detailed APIs:
184
- - `components/musicLibrary.ts` - Track/album/artist database
185
- - `components/playlists.ts` - Playlist management
186
- - `components/preferences.ts` - User preferences
187
- - `components/analytics.ts` - Analytics tracking
188
- - `components/repetitionControl.ts` - Anti-repetition logic
170
+ This plugin works alongside:
189
171
 
190
- ## License
172
+ - **`@elizaos/plugin-discord`** — Provides voice channel playback (wired automatically on init)
173
+ - **`@elizaos/plugin-sql`** — Required for persistent library and playlist storage
174
+ - **`@elizaos/plugin-suno`** — Required for AI generation subactions
191
175
 
192
- MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-music",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.3-beta.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -13,15 +13,31 @@
13
13
  "./package.json": "./package.json",
14
14
  ".": {
15
15
  "types": "./dist/index.d.ts",
16
+ "eliza-source": {
17
+ "types": "./src/index.ts",
18
+ "import": "./src/index.ts",
19
+ "default": "./src/index.ts"
20
+ },
16
21
  "import": "./dist/index.js"
22
+ },
23
+ "./*.css": "./dist/*.css",
24
+ "./*": {
25
+ "types": "./dist/*.d.ts",
26
+ "eliza-source": {
27
+ "types": "./src/*.ts",
28
+ "import": "./src/*.ts",
29
+ "default": "./src/*.ts"
30
+ },
31
+ "import": "./dist/*.js",
32
+ "default": "./dist/*.js"
17
33
  }
18
34
  },
19
35
  "files": [
20
36
  "dist"
21
37
  ],
22
38
  "dependencies": {
23
- "@elizaos/core": "2.0.0-beta.1",
24
- "@elizaos/plugin-sql": "2.0.0-beta.1",
39
+ "@elizaos/core": "2.0.3-beta.2",
40
+ "@elizaos/plugin-suno": "2.0.3-beta.2",
25
41
  "@vookav2/play-dl": "^1.9.9",
26
42
  "buffer": "^6.0.3",
27
43
  "ffmpeg-static": "^5.3.0",
@@ -39,7 +55,7 @@
39
55
  "build": "tsup",
40
56
  "dev": "tsup --watch",
41
57
  "test": "vitest run",
42
- "typecheck": "tsc --noEmit",
58
+ "typecheck": "tsgo --noEmit -p tsconfig.typecheck.json",
43
59
  "lint": "bunx @biomejs/biome check --write --unsafe .",
44
60
  "lint:check": "bunx @biomejs/biome check .",
45
61
  "clean": "rm -rf dist .turbo .turbo-tsconfig.json tsconfig.tsbuildinfo",
@@ -54,5 +70,6 @@
54
70
  "agentConfig": {
55
71
  "pluginType": "elizaos:plugin:1.0.0",
56
72
  "pluginParameters": {}
57
- }
73
+ },
74
+ "gitHead": "82fe0f44215954c2417328203f5bd6510985c1fc"
58
75
  }