tuna-agent 0.1.113 → 0.1.114
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.
|
@@ -33,6 +33,7 @@ export interface AppContext {
|
|
|
33
33
|
isWholeApp: boolean;
|
|
34
34
|
allFeatures: string[];
|
|
35
35
|
}
|
|
36
|
+
export declare function handleClaudePrompt(ws: AgentWebSocketClient, code: string, taskId: string, prompt: string, systemPrompt?: string): Promise<void>;
|
|
36
37
|
export declare function handleGenerateIdeas(ws: AgentWebSocketClient, code: string, taskId: string, topic: string, styleName?: string, styleDesc?: string, language?: string, count?: number, ideasInstruction?: string, provider?: string, appContext?: AppContext): Promise<void>;
|
|
37
38
|
export declare function handleGenerateScript(ws: AgentWebSocketClient, code: string, taskId: string, idea: string, topic: string, style?: string, duration?: number, language?: string, styleName?: string, styleGuidance?: string, provider?: string): Promise<void>;
|
|
38
39
|
export declare function handleRetryVideo(ws: AgentWebSocketClient, code: string, taskId: string, videoId: string): void;
|
|
@@ -64,6 +64,50 @@ function hasContentCreator() {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
// ─── Handler: claude_prompt (generic prompt → JSON result) ──────────────────
|
|
68
|
+
export async function handleClaudePrompt(ws, code, taskId, prompt, systemPrompt) {
|
|
69
|
+
console.log(`[claude_prompt] Received: ${prompt.substring(0, 100)}...`);
|
|
70
|
+
if (!hasContentCreator()) {
|
|
71
|
+
const error = 'content-creator agent not found on this machine';
|
|
72
|
+
ws.sendExtensionEvent(code, { type: 'prompt_result', taskId, result: null, error });
|
|
73
|
+
ws.sendExtensionDone(code, taskId, { error });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const result = await runClaude({
|
|
78
|
+
prompt,
|
|
79
|
+
systemPrompt: systemPrompt || 'You are a content strategy expert. Always respond with ONLY valid JSON — no explanation, no markdown fences, no extra text.',
|
|
80
|
+
cwd: CONTENT_CREATOR_DIR,
|
|
81
|
+
maxTurns: 1,
|
|
82
|
+
outputFormat: 'json',
|
|
83
|
+
timeoutMs: 60000,
|
|
84
|
+
});
|
|
85
|
+
const text = typeof result === 'string' ? result : result.result || JSON.stringify(result);
|
|
86
|
+
console.log(`[claude_prompt] Result: ${text.substring(0, 200)}`);
|
|
87
|
+
// Try to parse JSON from response
|
|
88
|
+
const cleaned = text.replace(/```json?\s*/g, '').replace(/```/g, '').trim();
|
|
89
|
+
let parsed = null;
|
|
90
|
+
try {
|
|
91
|
+
parsed = JSON.parse(cleaned);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
const jsonMatch = cleaned.match(/[\[{][\s\S]*[\]}]/);
|
|
95
|
+
if (jsonMatch)
|
|
96
|
+
try {
|
|
97
|
+
parsed = JSON.parse(jsonMatch[0]);
|
|
98
|
+
}
|
|
99
|
+
catch { }
|
|
100
|
+
}
|
|
101
|
+
ws.sendExtensionEvent(code, { type: 'prompt_result', taskId, result: parsed, raw: text });
|
|
102
|
+
ws.sendExtensionDone(code, taskId, { result: parsed, raw: text });
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
console.error(`[claude_prompt] Error: ${err.message}`);
|
|
106
|
+
ws.sendExtensionEvent(code, { type: 'prompt_result', taskId, result: null, error: err.message });
|
|
107
|
+
ws.sendExtensionDone(code, taskId, { error: err.message });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// ─── Handler: generate_ideas ─────────────────────────────────────────────────
|
|
67
111
|
export async function handleGenerateIdeas(ws, code, taskId, topic, styleName, styleDesc, language, count, ideasInstruction, provider, appContext) {
|
|
68
112
|
console.log(`[generate_ideas] Received: topic="${topic}" count=${count} provider=${provider || 'claude-cli'} ideasInstruction=${ideasInstruction ? ideasInstruction.length + ' chars' : '(none)'} styleName=${styleName || '(none)'} appContext=${appContext ? appContext.appName : '(none)'}`);
|
|
69
113
|
if (provider !== 'openai' && !hasContentCreator()) {
|
package/dist/daemon/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { loadPMState, savePMState, clearPMState } from './pm-state.js';
|
|
|
9
9
|
import { chatWithPM } from '../pm/planner.js';
|
|
10
10
|
import { executePlanAndReport, simplifyMarkdown, waitForInput } from '../utils/execution-helpers.js';
|
|
11
11
|
import { runClaude } from '../utils/claude-cli.js';
|
|
12
|
-
import { handleGetHistory, handleRetryVideo, handleGenerateIdeas, handleGenerateScript, handleGenerateScene, handleGenerateScenes, handleRenderVideo, handleListCharacters, handleCreateCharacter, handleSaveCharacterSelection, handleSyncApps, } from './extension-handlers.js';
|
|
12
|
+
import { handleGetHistory, handleRetryVideo, handleGenerateIdeas, handleGenerateScript, handleGenerateScene, handleGenerateScenes, handleRenderVideo, handleListCharacters, handleCreateCharacter, handleSaveCharacterSelection, handleSyncApps, handleClaudePrompt, } from './extension-handlers.js';
|
|
13
13
|
import { downloadAttachments, cleanupAttachments } from '../utils/image-download.js';
|
|
14
14
|
import { scanSkills } from '../utils/skill-scanner.js';
|
|
15
15
|
import { setupMcpConfig } from '../mcp/setup.js';
|
|
@@ -547,6 +547,12 @@ ${skillContent.slice(0, 15000)}`;
|
|
|
547
547
|
handleGetHistory(ws, extCode, extTaskId);
|
|
548
548
|
break;
|
|
549
549
|
}
|
|
550
|
+
if (extTask === 'claude_prompt') {
|
|
551
|
+
(async () => {
|
|
552
|
+
await handleClaudePrompt(ws, extCode, extTaskId, msg.prompt, msg.systemPrompt);
|
|
553
|
+
})();
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
550
556
|
if (extTask === 'generate_ideas') {
|
|
551
557
|
(async () => {
|
|
552
558
|
await handleGenerateIdeas(ws, extCode, extTaskId, msg.topic, msg.styleName, msg.styleDesc, msg.language, msg.count, msg.ideasInstruction, msg.provider, msg.appContext);
|