@elizaos/plugin-suno 1.0.6-alpha.4 → 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.
@@ -1,186 +0,0 @@
1
- import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
2
- import { SunoProvider } from "../providers/suno";
3
- import type { CustomGenerateParams } from "../types";
4
-
5
- const customGenerateMusic: Action = {
6
- name: "custom-generate-music",
7
- description: "Generate music with custom parameters using Suno AI",
8
- similes: [
9
- "CREATE_CUSTOM_MUSIC",
10
- "GENERATE_CUSTOM_AUDIO",
11
- "MAKE_CUSTOM_MUSIC",
12
- "COMPOSE_CUSTOM_MUSIC",
13
- "COMPOSE_MUSIC",
14
- "CREATE_MUSIC",
15
- "GENERATE_MUSIC"
16
-
17
- ],
18
-
19
- validate: async (runtime: any, message: any, state?: any, options?: any): Promise<boolean> => {
20
- const __avTextRaw = typeof message?.content?.text === 'string' ? message.content.text : '';
21
- const __avText = __avTextRaw.toLowerCase();
22
- const __avKeywords = ['custom', 'generate', 'music'];
23
- const __avKeywordOk =
24
- __avKeywords.length > 0 &&
25
- __avKeywords.some((word) => word.length > 0 && __avText.includes(word));
26
- const __avRegex = new RegExp('\\b(?:custom|generate|music)\\b', 'i');
27
- const __avRegexOk = __avRegex.test(__avText);
28
- const __avSource = String(message?.content?.source ?? message?.source ?? '');
29
- const __avExpectedSource = '';
30
- const __avSourceOk = __avExpectedSource
31
- ? __avSource === __avExpectedSource
32
- : Boolean(__avSource || state || runtime?.agentId || runtime?.getService || runtime?.getSetting);
33
- const __avOptions = options && typeof options === 'object' ? options : {};
34
- const __avInputOk =
35
- __avText.trim().length > 0 ||
36
- Object.keys(__avOptions as Record<string, unknown>).length > 0 ||
37
- Boolean(message?.content && typeof message.content === 'object');
38
-
39
- if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
40
- return false;
41
- }
42
-
43
- const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
44
- return !!runtime.getSetting("SUNO_API_KEY");
45
- };
46
- try {
47
- return Boolean(await (__avLegacyValidate as any)(runtime, message, state, options));
48
- } catch {
49
- return false;
50
- }
51
- },
52
-
53
- handler: async (
54
- runtime: IAgentRuntime,
55
- message: Memory,
56
- state: State,
57
- _options: { [key: string]: unknown },
58
- callback?: HandlerCallback
59
- ): Promise<boolean> => {
60
- try {
61
- const provider = await SunoProvider.get(runtime, message, state);
62
- const content = message.content as unknown as CustomGenerateParams;
63
-
64
- if (!content.prompt) {
65
- throw new Error("Missing required parameter: prompt");
66
- }
67
-
68
- const response = await provider.request('/custom-generate', {
69
- method: 'POST',
70
- body: JSON.stringify({
71
- prompt: content.prompt,
72
- duration: content.duration || 30,
73
- temperature: content.temperature || 1.0,
74
- top_k: content.topK || 250,
75
- top_p: content.topP || 0.95,
76
- classifier_free_guidance: content.classifier_free_guidance || 3.0,
77
- reference_audio: content.reference_audio,
78
- style: content.style,
79
- bpm: content.bpm,
80
- key: content.key,
81
- mode: content.mode
82
- })
83
- });
84
-
85
- if (callback) {
86
- callback({
87
- text: 'Successfully generated custom music',
88
- content: response
89
- });
90
- }
91
-
92
- return true;
93
- } catch (error) {
94
- if (callback) {
95
- callback({
96
- text: `Failed to generate custom music: ${(error as Error).message}`,
97
- error: error
98
- });
99
- }
100
- return false;
101
- }
102
- },
103
-
104
- examples: [
105
- [
106
- {
107
- user: "{{user1}}",
108
- content: {
109
- text: "Create an upbeat electronic dance track with heavy bass",
110
- prompt: "An upbeat electronic dance track with heavy bass and energetic synths",
111
- duration: 60,
112
- style: "electronic",
113
- bpm: 128
114
- }
115
- },
116
- {
117
- user: "{{agent}}",
118
- content: {
119
- text: "I'll generate an energetic EDM track for you.",
120
- action: "custom-generate-music"
121
- }
122
- },
123
- {
124
- user: "{{agent}}",
125
- content: {
126
- text: "Successfully generated your EDM track with heavy bass and synths."
127
- }
128
- }
129
- ],
130
- [
131
- {
132
- user: "{{user1}}",
133
- content: {
134
- text: "Generate a calm piano melody in C major",
135
- prompt: "A gentle, flowing piano melody with soft dynamics",
136
- duration: 45,
137
- style: "classical",
138
- key: "C",
139
- mode: "major",
140
- temperature: 0.8
141
- }
142
- },
143
- {
144
- user: "{{agent}}",
145
- content: {
146
- text: "I'll create a calming piano piece in C major for you.",
147
- action: "custom-generate-music"
148
- }
149
- },
150
- {
151
- user: "{{agent}}",
152
- content: {
153
- text: "Successfully generated your peaceful piano melody in C major."
154
- }
155
- }
156
- ],
157
- [
158
- {
159
- user: "{{user1}}",
160
- content: {
161
- text: "Make a rock song with guitar solos",
162
- prompt: "A rock song with powerful electric guitar solos and driving drums",
163
- duration: 90,
164
- style: "rock",
165
- bpm: 120,
166
- classifier_free_guidance: 4.0
167
- }
168
- },
169
- {
170
- user: "{{agent}}",
171
- content: {
172
- text: "I'll generate a rock track with guitar solos for you.",
173
- action: "custom-generate-music"
174
- }
175
- },
176
- {
177
- user: "{{agent}}",
178
- content: {
179
- text: "Successfully generated your rock song with guitar solos."
180
- }
181
- }
182
- ]
183
- ]
184
- };
185
-
186
- export default customGenerateMusic;
@@ -1,164 +0,0 @@
1
- import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
2
- import { SunoProvider } from "../providers/suno";
3
- import type { ExtendParams } from "../types";
4
-
5
- const extendAudio: Action = {
6
- name: "extend-audio",
7
- description: "Extend the duration of an existing audio generation",
8
- similes: [
9
- "LENGTHEN_AUDIO",
10
- "PROLONG_AUDIO",
11
- "INCREASE_DURATION",
12
- "MAKE_AUDIO_LONGER"
13
- ],
14
-
15
- validate: async (runtime: any, message: any, state?: any, options?: any): Promise<boolean> => {
16
- const __avTextRaw = typeof message?.content?.text === 'string' ? message.content.text : '';
17
- const __avText = __avTextRaw.toLowerCase();
18
- const __avKeywords = ['extend', 'audio'];
19
- const __avKeywordOk =
20
- __avKeywords.length > 0 &&
21
- __avKeywords.some((word) => word.length > 0 && __avText.includes(word));
22
- const __avRegex = new RegExp('\\b(?:extend|audio)\\b', 'i');
23
- const __avRegexOk = __avRegex.test(__avText);
24
- const __avSource = String(message?.content?.source ?? message?.source ?? '');
25
- const __avExpectedSource = '';
26
- const __avSourceOk = __avExpectedSource
27
- ? __avSource === __avExpectedSource
28
- : Boolean(__avSource || state || runtime?.agentId || runtime?.getService || runtime?.getSetting);
29
- const __avOptions = options && typeof options === 'object' ? options : {};
30
- const __avInputOk =
31
- __avText.trim().length > 0 ||
32
- Object.keys(__avOptions as Record<string, unknown>).length > 0 ||
33
- Boolean(message?.content && typeof message.content === 'object');
34
-
35
- if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
36
- return false;
37
- }
38
-
39
- const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
40
- return !!runtime.getSetting("SUNO_API_KEY");
41
- };
42
- try {
43
- return Boolean(await (__avLegacyValidate as any)(runtime, message, state, options));
44
- } catch {
45
- return false;
46
- }
47
- },
48
-
49
- handler: async (
50
- runtime: IAgentRuntime,
51
- message: Memory,
52
- state: State,
53
- _options: { [key: string]: unknown },
54
- callback?: HandlerCallback
55
- ): Promise<boolean> => {
56
- try {
57
- const provider = await SunoProvider.get(runtime, message, state);
58
- const content = message.content as unknown as ExtendParams;
59
-
60
- if (!content.audio_id || !content.duration) {
61
- throw new Error("Missing required parameters: audio_id and duration");
62
- }
63
-
64
- const response = await provider.request('/extend', {
65
- method: 'POST',
66
- body: JSON.stringify({
67
- audio_id: content.audio_id,
68
- duration: content.duration
69
- })
70
- });
71
-
72
- if (callback) {
73
- callback({
74
- text: `Successfully extended audio ${content.audio_id}`,
75
- content: response
76
- });
77
- }
78
-
79
- return true;
80
- } catch (error) {
81
- if (callback) {
82
- callback({
83
- text: `Failed to extend audio: ${(error as Error).message}`,
84
- error: error
85
- });
86
- }
87
- return false;
88
- }
89
- },
90
-
91
- examples: [
92
- [
93
- {
94
- user: "{{user1}}",
95
- content: {
96
- text: "Make this song longer by 30 seconds",
97
- audio_id: "abc123",
98
- duration: 30
99
- }
100
- },
101
- {
102
- user: "{{agent}}",
103
- content: {
104
- text: "I'll extend your song by 30 seconds.",
105
- action: "extend-audio"
106
- }
107
- },
108
- {
109
- user: "{{agent}}",
110
- content: {
111
- text: "Successfully extended your song by 30 seconds."
112
- }
113
- }
114
- ],
115
- [
116
- {
117
- user: "{{user1}}",
118
- content: {
119
- text: "Double the length of this track",
120
- audio_id: "xyz789",
121
- duration: 60
122
- }
123
- },
124
- {
125
- user: "{{agent}}",
126
- content: {
127
- text: "I'll double the duration of your track.",
128
- action: "extend-audio"
129
- }
130
- },
131
- {
132
- user: "{{agent}}",
133
- content: {
134
- text: "Successfully doubled the length of your track to 60 seconds."
135
- }
136
- }
137
- ],
138
- [
139
- {
140
- user: "{{user1}}",
141
- content: {
142
- text: "Add 15 more seconds to this melody",
143
- audio_id: "def456",
144
- duration: 15
145
- }
146
- },
147
- {
148
- user: "{{agent}}",
149
- content: {
150
- text: "I'll add 15 seconds to your melody.",
151
- action: "extend-audio"
152
- }
153
- },
154
- {
155
- user: "{{agent}}",
156
- content: {
157
- text: "Successfully added 15 seconds to your melody."
158
- }
159
- }
160
- ]
161
- ]
162
- };
163
-
164
- export default extendAudio;
@@ -1,175 +0,0 @@
1
- import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
2
- import { SunoProvider } from "../providers/suno";
3
- import type { GenerateParams } from "../types";
4
-
5
- const generateMusic: Action = {
6
- name: "generate-music",
7
- description: "Generate music using Suno AI",
8
- similes: [
9
- "CREATE_MUSIC",
10
- "MAKE_MUSIC",
11
- "COMPOSE_MUSIC",
12
- "GENERATE_AUDIO",
13
- "CREATE_SONG",
14
- "MAKE_SONG"
15
- ],
16
-
17
- validate: async (runtime: any, message: any, state?: any, options?: any): Promise<boolean> => {
18
- const __avTextRaw = typeof message?.content?.text === 'string' ? message.content.text : '';
19
- const __avText = __avTextRaw.toLowerCase();
20
- const __avKeywords = ['generate', 'music'];
21
- const __avKeywordOk =
22
- __avKeywords.length > 0 &&
23
- __avKeywords.some((word) => word.length > 0 && __avText.includes(word));
24
- const __avRegex = new RegExp('\\b(?:generate|music)\\b', 'i');
25
- const __avRegexOk = __avRegex.test(__avText);
26
- const __avSource = String(message?.content?.source ?? message?.source ?? '');
27
- const __avExpectedSource = '';
28
- const __avSourceOk = __avExpectedSource
29
- ? __avSource === __avExpectedSource
30
- : Boolean(__avSource || state || runtime?.agentId || runtime?.getService || runtime?.getSetting);
31
- const __avOptions = options && typeof options === 'object' ? options : {};
32
- const __avInputOk =
33
- __avText.trim().length > 0 ||
34
- Object.keys(__avOptions as Record<string, unknown>).length > 0 ||
35
- Boolean(message?.content && typeof message.content === 'object');
36
-
37
- if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
38
- return false;
39
- }
40
-
41
- const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
42
- return !!runtime.getSetting("SUNO_API_KEY");
43
- };
44
- try {
45
- return Boolean(await (__avLegacyValidate as any)(runtime, message, state, options));
46
- } catch {
47
- return false;
48
- }
49
- },
50
-
51
- handler: async (
52
- runtime: IAgentRuntime,
53
- message: Memory,
54
- state: State,
55
- _options: { [key: string]: unknown },
56
- callback?: HandlerCallback
57
- ): Promise<boolean> => {
58
- try {
59
- const provider = await SunoProvider.get(runtime, message, state);
60
- const content = message.content as unknown as GenerateParams;
61
-
62
- if (!content.prompt) {
63
- throw new Error("Missing required parameter: prompt");
64
- }
65
-
66
- const response = await provider.request('/generate', {
67
- method: 'POST',
68
- body: JSON.stringify({
69
- prompt: content.prompt,
70
- duration: content.duration || 30,
71
- temperature: content.temperature || 1.0,
72
- top_k: content.topK || 250,
73
- top_p: content.topP || 0.95,
74
- classifier_free_guidance: content.classifier_free_guidance || 3.0
75
- })
76
- });
77
-
78
- if (callback) {
79
- callback({
80
- text: 'Successfully generated music based on your prompt',
81
- content: response
82
- });
83
- }
84
-
85
- return true;
86
- } catch (error) {
87
- if (callback) {
88
- callback({
89
- text: `Failed to extend audio: ${(error as Error).message}`,
90
- error: error
91
- });
92
- }
93
- return false;
94
- }
95
- },
96
-
97
- examples: [
98
- [
99
- {
100
- user: "{{user1}}",
101
- content: {
102
- text: "Create a happy and energetic song",
103
- prompt: "A cheerful and energetic melody with upbeat rhythm",
104
- duration: 30,
105
- temperature: 1.0
106
- }
107
- },
108
- {
109
- user: "{{agent}}",
110
- content: {
111
- text: "I'll generate a happy and energetic song for you.",
112
- action: "generate-music"
113
- }
114
- },
115
- {
116
- user: "{{agent}}",
117
- content: {
118
- text: "Successfully generated your upbeat and energetic song."
119
- }
120
- }
121
- ],
122
- [
123
- {
124
- user: "{{user1}}",
125
- content: {
126
- text: "Generate a relaxing ambient track",
127
- prompt: "A peaceful ambient soundscape with gentle waves and soft pads",
128
- duration: 45,
129
- temperature: 0.8,
130
- classifier_free_guidance: 4.0
131
- }
132
- },
133
- {
134
- user: "{{agent}}",
135
- content: {
136
- text: "I'll create a calming ambient piece for you.",
137
- action: "generate-music"
138
- }
139
- },
140
- {
141
- user: "{{agent}}",
142
- content: {
143
- text: "Successfully generated your relaxing ambient soundscape."
144
- }
145
- }
146
- ],
147
- [
148
- {
149
- user: "{{user1}}",
150
- content: {
151
- text: "Make a short jingle for my podcast",
152
- prompt: "A catchy and professional podcast intro jingle",
153
- duration: 15,
154
- temperature: 1.2,
155
- top_k: 300
156
- }
157
- },
158
- {
159
- user: "{{agent}}",
160
- content: {
161
- text: "I'll generate a podcast jingle for you.",
162
- action: "generate-music"
163
- }
164
- },
165
- {
166
- user: "{{agent}}",
167
- content: {
168
- text: "Successfully generated your podcast jingle."
169
- }
170
- }
171
- ]
172
- ]
173
- };
174
-
175
- export default generateMusic;
package/src/index.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { Plugin } from "@elizaos/core";
2
- import generateMusic from "./actions/generate";
3
- import customGenerateMusic from "./actions/customGenerate";
4
- import extendAudio from "./actions/extend";
5
- import { SunoProvider } from "./providers/suno";
6
-
7
- export {
8
- SunoProvider,
9
- generateMusic as GenerateMusic,
10
- customGenerateMusic as CustomGenerateMusic,
11
- extendAudio as ExtendAudio
12
- };
13
-
14
- export const sunoPlugin: Plugin = {
15
- name: "suno",
16
- description: "Suno AI Music Generation Plugin for Eliza",
17
- actions: [generateMusic, customGenerateMusic, extendAudio],
18
- evaluators: [],
19
- providers: [SunoProvider],
20
- };
21
-
22
- export default sunoPlugin;
@@ -1,78 +0,0 @@
1
- import type { IAgentRuntime, Memory, State } from "@elizaos/core"; // Added type keyword
2
- import type { Provider } from "@elizaos/core"; // Added type keyword
3
-
4
- export interface SunoConfig {
5
- apiKey: string;
6
- baseUrl?: string;
7
- }
8
-
9
- export class SunoProvider implements Provider {
10
- private apiKey: string;
11
- private baseUrl: string;
12
-
13
- static async get(runtime: IAgentRuntime, _message: Memory, _state?: State): Promise<SunoProvider> {
14
- const apiKey = runtime.getSetting("SUNO_API_KEY");
15
- if (!apiKey) {
16
- throw new Error("SUNO_API_KEY is required");
17
- }
18
- return new SunoProvider({ apiKey });
19
- }
20
-
21
- constructor(config: SunoConfig) {
22
- this.apiKey = config.apiKey;
23
- this.baseUrl = config.baseUrl || 'https://api.suno.ai/v1';
24
- }
25
-
26
- async get(_runtime: IAgentRuntime, _message: Memory, _state?: State): Promise<{ status: string }> {
27
- return { status: 'ready' };
28
- }
29
-
30
- async request(endpoint: string, options: RequestInit = {}) {
31
- const url = `${this.baseUrl}${endpoint}`;
32
- const headers = {
33
- 'Authorization': `Bearer ${this.apiKey}`,
34
- 'Content-Type': 'application/json',
35
- ...options.headers,
36
- };
37
-
38
- const response = await fetch(url, {
39
- ...options,
40
- headers,
41
- });
42
-
43
- if (!response.ok) {
44
- throw new Error(`Suno API error: ${response.statusText}`);
45
- }
46
-
47
- return response.json();
48
- }
49
- }
50
-
51
- export interface GenerateParams {
52
- prompt: string;
53
- duration?: number;
54
- temperature?: number;
55
- topK?: number;
56
- topP?: number;
57
- classifier_free_guidance?: number;
58
- }
59
-
60
- export interface CustomGenerateParams extends GenerateParams {
61
- reference_audio?: string;
62
- style?: string;
63
- bpm?: number;
64
- key?: string;
65
- mode?: string;
66
- }
67
-
68
- export interface ExtendParams {
69
- audio_id: string;
70
- duration: number;
71
- }
72
-
73
- export interface GenerationResponse {
74
- id: string;
75
- status: 'pending' | 'processing' | 'completed' | 'failed';
76
- audio_url?: string;
77
- error?: string;
78
- }
@@ -1,34 +0,0 @@
1
- export interface GenerateParams {
2
- prompt: string;
3
- duration?: number;
4
- temperature?: number;
5
- topK?: number;
6
- topP?: number;
7
- classifier_free_guidance?: number;
8
- }
9
-
10
- export interface CustomGenerateParams {
11
- prompt: string;
12
- duration?: number;
13
- temperature?: number;
14
- topK?: number;
15
- topP?: number;
16
- classifier_free_guidance?: number;
17
- reference_audio?: string;
18
- style?: string;
19
- bpm?: number;
20
- key?: string;
21
- mode?: string;
22
- }
23
-
24
- export interface ExtendParams {
25
- audio_id: string;
26
- duration: number;
27
- }
28
-
29
- export interface GenerationResponse {
30
- id: string;
31
- status: string;
32
- url?: string;
33
- error?: string;
34
- }
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "dist",
4
- "rootDir": "src",
5
- "lib": ["ESNext", "dom"],
6
- "module": "Preserve",
7
- "moduleResolution": "Bundler",
8
- "strict": false,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": false,
12
- "allowImportingTsExtensions": true,
13
- "declaration": true,
14
- "emitDeclarationOnly": true,
15
- "resolveJsonModule": true,
16
- "noImplicitAny": false,
17
- "allowJs": true,
18
- "checkJs": false,
19
- "noEmitOnError": false,
20
- "moduleDetection": "force",
21
- "allowArbitraryExtensions": true
22
- },
23
- "include": ["src/**/*.ts"]
24
- }
package/tsup.config.ts DELETED
@@ -1,11 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- entry: ["src/index.ts"],
5
- format: ["cjs", "esm"],
6
- dts: false,
7
- splitting: false,
8
- sourcemap: true,
9
- clean: true,
10
- external: ["@elizaos/core"]
11
- });