(self, logger: Optional[WorkflowLogger] = None, *, session_id: Optional[str] = None)
| 21 | graph: GraphContext |
| 22 | |
| 23 | def build(self, logger: Optional[WorkflowLogger] = None, *, session_id: Optional[str] = None) -> RuntimeContext: |
| 24 | tool_manager = ToolManager() |
| 25 | function_manager = get_function_manager(EDGE_FUNCTION_DIR) |
| 26 | processor_function_manager = get_function_manager(EDGE_PROCESSOR_FUNCTION_DIR) |
| 27 | logger = logger or WorkflowLogger(self.graph.name, self.graph.log_level) |
| 28 | log_manager = LogManager(logger) |
| 29 | token_tracker = TokenTracker(workflow_id=self.graph.name) |
| 30 | |
| 31 | code_workspace = (self.graph.directory / "code_workspace").resolve() |
| 32 | code_workspace.mkdir(parents=True, exist_ok=True) |
| 33 | attachments_dir = code_workspace / "attachments" |
| 34 | attachments_dir.mkdir(parents=True, exist_ok=True) |
| 35 | attachment_store = AttachmentStore(attachments_dir) |
| 36 | |
| 37 | global_state: Dict[str, Any] = { |
| 38 | "graph_directory": self.graph.directory, |
| 39 | "vars": self.graph.config.vars, |
| 40 | "python_workspace_root": code_workspace, |
| 41 | "attachment_store": attachment_store, |
| 42 | } |
| 43 | |
| 44 | context = RuntimeContext( |
| 45 | tool_manager=tool_manager, |
| 46 | function_manager=function_manager, |
| 47 | edge_processor_function_manager=processor_function_manager, |
| 48 | logger=logger, |
| 49 | log_manager=log_manager, |
| 50 | token_tracker=token_tracker, |
| 51 | attachment_store=attachment_store, |
| 52 | code_workspace=code_workspace, |
| 53 | global_state=global_state, |
| 54 | ) |
| 55 | context.session_id = session_id |
| 56 | if session_id: |
| 57 | context.global_state.setdefault("session_id", session_id) |
| 58 | return context |
no test coverage detected