@elizaos/plugin-suno 1.0.6-alpha.2 → 1.0.6-alpha.4
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/{biome.json.bak → biome.json} +8 -7
- package/dist/index.js +72 -6
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/actions/customGenerate.ts +182 -182
- package/src/actions/extend.ts +160 -160
- package/src/actions/generate.ts +171 -171
- package/src/providers/suno.ts +9 -49
- package/tsup.config.ts +1 -1
|
@@ -1,186 +1,186 @@
|
|
|
1
|
-
import type { Action, IAgentRuntime, Memory, State, HandlerCallback } from "@elizaos/core";
|
|
2
|
-
import { SunoProvider } from "../providers/suno";
|
|
3
|
-
import type { CustomGenerateParams } from "../types";
|
|
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');
|
|
4
38
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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"
|
|
39
|
+
if (!(__avKeywordOk && __avRegexOk && __avSourceOk && __avInputOk)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
16
42
|
|
|
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((kw) => kw.length > 0 && __avText.includes(kw));
|
|
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);
|
|
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");
|
|
43
|
+
const __avLegacyValidate = async (runtime: IAgentRuntime, _message: Memory) => {
|
|
44
|
+
return !!runtime.getSetting("SUNO_API_KEY");
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
186
|
export default customGenerateMusic;
|