(self, node: "Node", edge_config: Optional[Dict[str, Any]] = None)
| 354 | return None |
| 355 | |
| 356 | def add_successor(self, node: "Node", edge_config: Optional[Dict[str, Any]] = None) -> None: |
| 357 | if node not in self.successors: |
| 358 | self.successors.append(node) |
| 359 | payload = dict(edge_config or {}) |
| 360 | existing = next((link for link in self._outgoing_edges if link.target is node), None) |
| 361 | trigger = bool(payload.get("trigger", True)) if payload else True |
| 362 | carry_data = bool(payload.get("carry_data", True)) if payload else True |
| 363 | keep_message = bool(payload.get("keep_message", False)) if payload else False |
| 364 | clear_context = bool(payload.get("clear_context", False)) if payload else False |
| 365 | clear_kept_context = bool(payload.get("clear_kept_context", False)) if payload else False |
| 366 | condition_config = payload.pop("condition_config", None) |
| 367 | if not isinstance(condition_config, EdgeConditionConfig): |
| 368 | raw_value = payload.get("condition", "true") |
| 369 | condition_config = EdgeConditionConfig.from_dict( |
| 370 | raw_value, |
| 371 | path=extend_path(self.path, f"edge[{self.id}->{node.id}].condition"), |
| 372 | ) |
| 373 | condition_label = condition_config.display_label() |
| 374 | condition_type = condition_config.type |
| 375 | condition_serializable = condition_config.to_external_value() |
| 376 | |
| 377 | process_config = payload.pop("process_config", None) |
| 378 | if process_config is None and payload.get("process") is not None: |
| 379 | process_config = EdgeProcessorConfig.from_dict( |
| 380 | payload.get("process"), |
| 381 | path=extend_path(self.path, f"edge[{self.id}->{node.id}].process"), |
| 382 | ) |
| 383 | process_serializable = process_config.to_external_value() if isinstance(process_config, EdgeProcessorConfig) else None |
| 384 | process_type = process_config.type if isinstance(process_config, EdgeProcessorConfig) else None |
| 385 | process_label = process_config.display_label() if isinstance(process_config, EdgeProcessorConfig) else None |
| 386 | |
| 387 | # Handle dynamic_config |
| 388 | dynamic_config = payload.pop("dynamic_config", None) |
| 389 | if dynamic_config is None and payload.get("dynamic") is not None: |
| 390 | dynamic_config = DynamicEdgeConfig.from_dict( |
| 391 | payload.get("dynamic"), |
| 392 | path=extend_path(self.path, f"edge[{self.id}->{node.id}].dynamic"), |
| 393 | ) |
| 394 | |
| 395 | payload["condition"] = condition_serializable |
| 396 | payload["condition_label"] = condition_label |
| 397 | payload["condition_type"] = condition_type |
| 398 | if process_serializable is not None: |
| 399 | payload["process"] = process_serializable |
| 400 | payload["process_label"] = process_label |
| 401 | payload["process_type"] = process_type |
| 402 | |
| 403 | if existing: |
| 404 | existing.config.update(payload) |
| 405 | existing.trigger = trigger |
| 406 | existing.condition = condition_label |
| 407 | existing.condition_config = condition_config |
| 408 | existing.condition_type = condition_type |
| 409 | existing.carry_data = carry_data |
| 410 | existing.keep_message = keep_message |
| 411 | existing.clear_context = clear_context |
| 412 | existing.clear_kept_context = clear_kept_context |
| 413 | if isinstance(process_config, EdgeProcessorConfig): |
no test coverage detected