File size: 2,393 Bytes
2dfc473
 
 
 
 
 
 
 
 
 
 
 
 
7289c0c
 
 
 
 
 
 
 
 
 
2dfc473
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7289c0c
 
2dfc473
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Lead Writer agent - Script creation specialist."""
from typing import Any, Dict
from base_agent import BaseAgent


class LeadWriterAgent(BaseAgent):
    """Lead Writer agent that crafts the first draft script."""

    def __init__(self):
        """Initialize the Lead Writer agent."""
        system_prompt = (
            "You are the Lead Writer. Using the outline and cultural notes, write a complete "
            "episode script. Each character must speak in their own voice. Include scene headings, "
            "action lines, and dialogue. Format it like a proper script.\n\n"
            "CRITICAL CHARACTER CONSISTENCY:\n"
            "You will receive a 'character_list' in the inputs. You MUST use ONLY these characters "
            "in your script. Do NOT invent new characters or use different names. If the list is "
            "['Alex', 'Jordan', 'Casey', 'Morgan'], use ONLY these names. Every character name in "
            "your script MUST match exactly one from the provided list.\n\n"
            "POP CULTURE REFERENCE LIMIT:\n"
            "Limit pop culture references to 1-2 per scene maximum. Avoid reference dumps that "
            "make the dialogue feel forced or unnatural.\n\n"
            "Output as JSON with keys: full_episode_first_draft, scene_descriptions, dialogue, stage_directions."
        )
        super().__init__(
            agent_id="lead-writer",
            agent_name="Lead Writer",
            system_prompt=system_prompt,
        )

    def write_script(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
        """Write episode script from outline and cultural notes.

        Args:
            inputs: Dictionary with keys:
                - approved_outline: From Story Editor
                - cultural_consultant_notes: From Cultural Consultant
                - character_voice_guide: Character definitions
                - character_list: List of valid character names (MUST use only these)
                - story_premise: Story premise from Showrunner

        Returns:
            Dictionary with generated script and related outputs
        """
        outputs = self.process(inputs)
        
        # Save state
        self.save_state(
            {
                "inputs": inputs,
                "outputs": outputs,
            },
            filename="first_draft.json",
        )
        
        return outputs