-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathindex.ts
More file actions
87 lines (76 loc) · 2.99 KB
/
Copy pathindex.ts
File metadata and controls
87 lines (76 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// src/index.ts
import dotenv from "dotenv";
import inquirer from "inquirer";
import { runResearchStage } from "./src/agents/research.js";
import { runScriptingStage } from "./src/agents/scripting.js";
import { runHumanReviewNode } from "./src/agents/human_review.js";
import { runAudioStage } from "./src/agents/audio.js";
import { runVideoGenerationStage } from "./src/agents/video_generation.js";
import type { AgentState } from "./src/state/state.js";
dotenv.config();
async function main() {
const { topic } = await inquirer.prompt([
{
type: "input",
name: "topic",
message: "What topic would you like to generate video content for?",
default: "Claude code for development in 2026",
},
]);
const TOPIC = topic;
// Initialize State
let state: AgentState = {
topic: TOPIC,
};
try {
// ----------------------------------------------------------------
// --- STAGE 1: Research ---
// ----------------------------------------------------------------
const researchData = await runResearchStage(TOPIC);
state.researchData = researchData;
console.log("📊 Research Data collected.");
// ----------------------------------------------------------------
// --- STAGE 2: Scripting (Loop with Human Review) ---
// ----------------------------------------------------------------
let scriptApproved = false;
while (!scriptApproved) {
const script = await runScriptingStage(state);
state.script = script;
// Run Review
const reviewResult = await runHumanReviewNode(script);
if (reviewResult.approved) {
console.log("✅ Script Approved!");
scriptApproved = true;
state.feedback = undefined;
} else {
console.log("🔄 Feedback received:", reviewResult.feedback);
state.feedback = reviewResult.feedback;
}
}
// ----------------------------------------------------------------
// --- STAGE 3: Audio Generation ---
// ----------------------------------------------------------------
if (state.script) {
// Logic: Generate audio and save to state
state.audioUrl = await runAudioStage(state.script);
console.log("🎧 Audio generated:", state.audioUrl);
} else {
console.warn("⚠️ No script available for audio generation.");
}
// ----------------------------------------------------------------
// --- STAGE 4: Video Generation (HeyGen) ---
// ----------------------------------------------------------------
if (state.audioUrl) {
console.log("🎬 Starting Video Generation...");
const videoLink = await runVideoGenerationStage(state.audioUrl);
console.log("\n=================================");
console.log("🚀 FINAL VIDEO READY:", videoLink);
console.log("=================================\n");
} else {
console.log("⚠️ Skipping video generation: No audio URL provided.");
}
} catch (error) {
console.error("❌ Pipeline Failed:", error);
}
}
main();