tuna-agent 0.1.35 → 0.1.37
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.
|
@@ -26,7 +26,7 @@ export interface VideoRecord {
|
|
|
26
26
|
aspectRatio?: string;
|
|
27
27
|
}
|
|
28
28
|
export declare function handleGetHistory(ws: AgentWebSocketClient, code: string, taskId: string): void;
|
|
29
|
-
export declare function handleGenerateIdeas(ws: AgentWebSocketClient, code: string, taskId: string, topic: string, styleName?: string, styleDesc?: string, language?: string): Promise<void>;
|
|
29
|
+
export declare function handleGenerateIdeas(ws: AgentWebSocketClient, code: string, taskId: string, topic: string, styleName?: string, styleDesc?: string, language?: string, count?: number, ideasInstruction?: string): Promise<void>;
|
|
30
30
|
export declare function handleGenerateScript(ws: AgentWebSocketClient, code: string, taskId: string, idea: string, topic: string, style?: string, duration?: number, language?: string, styleName?: string, styleGuidance?: string): Promise<void>;
|
|
31
31
|
export declare function handleRetryVideo(ws: AgentWebSocketClient, code: string, taskId: string, videoId: string): void;
|
|
32
32
|
export declare function handleGenerateScene(ws: AgentWebSocketClient, code: string, taskId: string, sceneIdx: number, prompt: string, aspectRatio: string): Promise<void>;
|
|
@@ -64,7 +64,8 @@ function hasContentCreator() {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
// ─── Handler: generate_ideas ──────────────────────────────────────────────────
|
|
67
|
-
export async function handleGenerateIdeas(ws, code, taskId, topic, styleName, styleDesc, language) {
|
|
67
|
+
export async function handleGenerateIdeas(ws, code, taskId, topic, styleName, styleDesc, language, count, ideasInstruction) {
|
|
68
|
+
console.log(`[generate_ideas] Received: topic="${topic}" count=${count} ideasInstruction=${ideasInstruction ? ideasInstruction.length + ' chars' : '(none)'} styleName=${styleName || '(none)'}`);
|
|
68
69
|
if (!hasContentCreator()) {
|
|
69
70
|
const error = 'content-creator agent not found on this machine';
|
|
70
71
|
console.error(`[generate_ideas] ${error}`);
|
|
@@ -86,12 +87,16 @@ export async function handleGenerateIdeas(ws, code, taskId, topic, styleName, st
|
|
|
86
87
|
systemParts.push(`The video style is "${styleName}"${styleDesc ? `: ${styleDesc}` : ''}.`);
|
|
87
88
|
systemParts.push(`Generate ideas that are specifically suited for this style.`);
|
|
88
89
|
}
|
|
90
|
+
if (ideasInstruction && ideasInstruction.trim()) {
|
|
91
|
+
systemParts.push(`\n\nAdditional instructions for idea generation:\n${ideasInstruction.trim()}`);
|
|
92
|
+
}
|
|
89
93
|
const systemPrompt = systemParts.join(' ');
|
|
90
94
|
const langReq = resolvedLang === 'vi'
|
|
91
95
|
? `- Titles must be in Vietnamese, natural and engaging`
|
|
92
96
|
: `- Titles must be in English, natural and engaging`;
|
|
97
|
+
const n = count && count > 0 ? count : 10;
|
|
93
98
|
const prompt = [
|
|
94
|
-
`Generate exactly
|
|
99
|
+
`Generate exactly ${n} viral YouTube Shorts video ideas for the topic: "${topic}".`,
|
|
95
100
|
``,
|
|
96
101
|
`Requirements:`,
|
|
97
102
|
`- Each idea is a catchy, scroll-stopping video title`,
|
|
@@ -100,7 +105,7 @@ export async function handleGenerateIdeas(ws, code, taskId, topic, styleName, st
|
|
|
100
105
|
`- Mix different angles/formats for variety`,
|
|
101
106
|
...(styleName ? [`- Ideas must fit the "${styleName}" video style${styleDesc ? ` (${styleDesc})` : ''}`] : []),
|
|
102
107
|
``,
|
|
103
|
-
`Respond with ONLY a JSON array of
|
|
108
|
+
`Respond with ONLY a JSON array of ${n} strings. No explanation, no markdown, no wrapping.`,
|
|
104
109
|
`Example format: ["title 1","title 2","title 3","title 4","title 5"]`,
|
|
105
110
|
].join('\n');
|
|
106
111
|
try {
|
|
@@ -127,9 +132,9 @@ export async function handleGenerateIdeas(ws, code, taskId, topic, styleName, st
|
|
|
127
132
|
}
|
|
128
133
|
catch { /* skip non-JSON matches */ }
|
|
129
134
|
}
|
|
130
|
-
// Prefer the array closest to
|
|
135
|
+
// Prefer the array closest to n items
|
|
131
136
|
if (arrays.length > 0) {
|
|
132
|
-
ideas = arrays.reduce((best, cur) => Math.abs(cur.length -
|
|
137
|
+
ideas = arrays.reduce((best, cur) => Math.abs(cur.length - n) < Math.abs(best.length - n) ? cur : best);
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
catch { /* fall through to fallback */ }
|
package/dist/daemon/index.js
CHANGED
|
@@ -367,13 +367,13 @@ ${skillContent.slice(0, 15000)}`;
|
|
|
367
367
|
}
|
|
368
368
|
if (extTask === 'generate_ideas') {
|
|
369
369
|
(async () => {
|
|
370
|
-
await handleGenerateIdeas(ws, extCode, extTaskId, msg.topic, msg.styleName, msg.styleDesc, msg.language);
|
|
370
|
+
await handleGenerateIdeas(ws, extCode, extTaskId, msg.topic, msg.styleName, msg.styleDesc, msg.language, msg.count, msg.ideasInstruction);
|
|
371
371
|
})();
|
|
372
372
|
break;
|
|
373
373
|
}
|
|
374
374
|
if (extTask === 'generate_script') {
|
|
375
375
|
(async () => {
|
|
376
|
-
await handleGenerateScript(ws, extCode, extTaskId, msg.idea, msg.topic, msg.style, msg.duration, msg.language, msg.styleName, msg.styleGuidance);
|
|
376
|
+
await handleGenerateScript(ws, extCode, extTaskId, msg.idea, msg.topic, msg.style, msg.duration, msg.language, msg.styleName, (msg.scriptInstruction || msg.styleGuidance));
|
|
377
377
|
})();
|
|
378
378
|
break;
|
|
379
379
|
}
|