|
2 | 2 | API response models for AGB SDK. |
3 | 3 | """ |
4 | 4 |
|
5 | | -from typing import TYPE_CHECKING, Any, List, Optional |
| 5 | +from typing import TYPE_CHECKING, Any, Dict, List, Optional |
6 | 6 |
|
7 | 7 | if TYPE_CHECKING: |
8 | 8 | from agb.session import Session |
@@ -532,3 +532,201 @@ def __init__( |
532 | 532 | self.success = success |
533 | 533 | self.status = status |
534 | 534 | self.error_message = error_message |
| 535 | + |
| 536 | + |
| 537 | +class McpTool: |
| 538 | + """MCP tool information model""" |
| 539 | + |
| 540 | + def __init__( |
| 541 | + self, |
| 542 | + name: str = "", |
| 543 | + description: str = "", |
| 544 | + input_schema: Optional[Dict[str, Any]] = None, |
| 545 | + server: str = "", |
| 546 | + tool: str = "", |
| 547 | + ): |
| 548 | + """ |
| 549 | + Initialize an McpTool. |
| 550 | +
|
| 551 | + Args: |
| 552 | + name: Tool name |
| 553 | + description: Tool description |
| 554 | + input_schema: Input parameters JSON Schema |
| 555 | + server: MCP server name |
| 556 | + tool: Tool type |
| 557 | + """ |
| 558 | + self.name = name |
| 559 | + self.description = description |
| 560 | + self.input_schema = input_schema or {} |
| 561 | + self.server = server |
| 562 | + self.tool = tool |
| 563 | + |
| 564 | + |
| 565 | +class McpToolResult(ApiResponse): |
| 566 | + """MCP tool call result""" |
| 567 | + |
| 568 | + def __init__( |
| 569 | + self, |
| 570 | + request_id: str = "", |
| 571 | + success: bool = False, |
| 572 | + data: Optional[str] = None, |
| 573 | + error_message: str = "", |
| 574 | + ): |
| 575 | + """ |
| 576 | + Initialize an McpToolResult. |
| 577 | +
|
| 578 | + Args: |
| 579 | + request_id: Request ID |
| 580 | + success: Whether the operation was successful |
| 581 | + data: Tool return data in JSON string format |
| 582 | + error_message: Error message |
| 583 | + """ |
| 584 | + super().__init__(request_id) |
| 585 | + self.success = success |
| 586 | + self.data = data |
| 587 | + self.error_message = error_message |
| 588 | + |
| 589 | + |
| 590 | +class McpToolsResult(ApiResponse): |
| 591 | + """MCP tools list query result""" |
| 592 | + |
| 593 | + def __init__( |
| 594 | + self, |
| 595 | + request_id: str = "", |
| 596 | + success: bool = False, |
| 597 | + tools: Optional[List["McpTool"]] = None, |
| 598 | + error_message: str = "", |
| 599 | + ): |
| 600 | + """ |
| 601 | + Initialize an McpToolsResult. |
| 602 | +
|
| 603 | + Args: |
| 604 | + request_id: Request ID |
| 605 | + success: Whether the operation was successful |
| 606 | + tools: List of tools |
| 607 | + error_message: Error message |
| 608 | + """ |
| 609 | + super().__init__(request_id) |
| 610 | + self.success = success |
| 611 | + self.tools = tools or [] |
| 612 | + self.error_message = error_message |
| 613 | + |
| 614 | +class SessionMetrics: |
| 615 | + """Structured metrics for session monitoring.""" |
| 616 | + |
| 617 | + def __init__( |
| 618 | + self, |
| 619 | + cpu_count: int = 0, |
| 620 | + cpu_used_pct: float = 0.0, |
| 621 | + disk_total: int = 0, |
| 622 | + disk_used: int = 0, |
| 623 | + mem_total: int = 0, |
| 624 | + mem_used: int = 0, |
| 625 | + rx_rate_kbyte_per_s: float = 0.0, |
| 626 | + tx_rate_kbyte_per_s: float = 0.0, |
| 627 | + rx_used_kbyte: float = 0.0, |
| 628 | + tx_used_kbyte: float = 0.0, |
| 629 | + timestamp: str = "", |
| 630 | + # Backward-compatible aliases (deprecated): |
| 631 | + rx_rate_kbps: Optional[float] = None, |
| 632 | + tx_rate_kbps: Optional[float] = None, |
| 633 | + rx_used_kb: Optional[float] = None, |
| 634 | + tx_used_kb: Optional[float] = None, |
| 635 | + ): |
| 636 | + """ |
| 637 | + Initialize SessionMetrics. |
| 638 | +
|
| 639 | + Args: |
| 640 | + cpu_count (int): CPU core count. Defaults to 0. |
| 641 | + cpu_used_pct (float): CPU usage percentage. Defaults to 0.0. |
| 642 | + disk_total (int): Total disk capacity. Defaults to 0. |
| 643 | + disk_used (int): Used disk capacity. Defaults to 0. |
| 644 | + mem_total (int): Total memory. Defaults to 0. |
| 645 | + mem_used (int): Used memory. Defaults to 0. |
| 646 | + rx_rate_kbyte_per_s (float): Receive rate in KB/s. Defaults to 0.0. |
| 647 | + tx_rate_kbyte_per_s (float): Transmit rate in KB/s. Defaults to 0.0. |
| 648 | + rx_used_kbyte (float): Total received data in KB. Defaults to 0.0. |
| 649 | + tx_used_kbyte (float): Total transmitted data in KB. Defaults to 0.0. |
| 650 | + timestamp (str): Timestamp of the metrics. Defaults to "". |
| 651 | + rx_rate_kbps (Optional[float]): Deprecated alias for rx_rate_kbyte_per_s. |
| 652 | + tx_rate_kbps (Optional[float]): Deprecated alias for tx_rate_kbyte_per_s. |
| 653 | + rx_used_kb (Optional[float]): Deprecated alias for rx_used_kbyte. |
| 654 | + tx_used_kb (Optional[float]): Deprecated alias for tx_used_kbyte. |
| 655 | + """ |
| 656 | + self.cpu_count = cpu_count |
| 657 | + self.cpu_used_pct = cpu_used_pct |
| 658 | + self.disk_total = disk_total |
| 659 | + self.disk_used = disk_used |
| 660 | + self.mem_total = mem_total |
| 661 | + self.mem_used = mem_used |
| 662 | + self.rx_rate_kbyte_per_s = ( |
| 663 | + rx_rate_kbyte_per_s if rx_rate_kbyte_per_s is not None else 0.0 |
| 664 | + ) |
| 665 | + self.tx_rate_kbyte_per_s = ( |
| 666 | + tx_rate_kbyte_per_s if tx_rate_kbyte_per_s is not None else 0.0 |
| 667 | + ) |
| 668 | + self.rx_used_kbyte = rx_used_kbyte if rx_used_kbyte is not None else 0.0 |
| 669 | + self.tx_used_kbyte = tx_used_kbyte if tx_used_kbyte is not None else 0.0 |
| 670 | + |
| 671 | + # Backward-compatible aliases (deprecated): allow old args to fill new fields |
| 672 | + if rx_rate_kbps is not None and self.rx_rate_kbyte_per_s == 0.0: |
| 673 | + self.rx_rate_kbyte_per_s = float(rx_rate_kbps) |
| 674 | + if tx_rate_kbps is not None and self.tx_rate_kbyte_per_s == 0.0: |
| 675 | + self.tx_rate_kbyte_per_s = float(tx_rate_kbps) |
| 676 | + if rx_used_kb is not None and self.rx_used_kbyte == 0.0: |
| 677 | + self.rx_used_kbyte = float(rx_used_kb) |
| 678 | + if tx_used_kb is not None and self.tx_used_kbyte == 0.0: |
| 679 | + self.tx_used_kbyte = float(tx_used_kb) |
| 680 | + self.timestamp = timestamp |
| 681 | + |
| 682 | + # Backward-compatible properties (deprecated) |
| 683 | + @property |
| 684 | + def rx_rate_kbps(self) -> float: |
| 685 | + """Deprecated: Use rx_rate_kbyte_per_s instead.""" |
| 686 | + return float(self.rx_rate_kbyte_per_s) |
| 687 | + |
| 688 | + @property |
| 689 | + def tx_rate_kbps(self) -> float: |
| 690 | + """Deprecated: Use tx_rate_kbyte_per_s instead.""" |
| 691 | + return float(self.tx_rate_kbyte_per_s) |
| 692 | + |
| 693 | + @property |
| 694 | + def rx_used_kb(self) -> float: |
| 695 | + """Deprecated: Use rx_used_kbyte instead.""" |
| 696 | + return float(self.rx_used_kbyte) |
| 697 | + |
| 698 | + @property |
| 699 | + def tx_used_kb(self) -> float: |
| 700 | + """Deprecated: Use tx_used_kbyte instead.""" |
| 701 | + return float(self.tx_used_kbyte) |
| 702 | + |
| 703 | +class SessionMetricsResult(ApiResponse): |
| 704 | + """Result of session get_metrics() operation.""" |
| 705 | + |
| 706 | + def __init__( |
| 707 | + self, |
| 708 | + request_id: str = "", |
| 709 | + success: bool = False, |
| 710 | + metrics: Optional[SessionMetrics] = None, |
| 711 | + error_message: str = "", |
| 712 | + raw: Optional[dict] = None, |
| 713 | + ): |
| 714 | + """ |
| 715 | + Initialize a SessionMetricsResult. |
| 716 | +
|
| 717 | + Args: |
| 718 | + request_id (str, optional): Unique identifier for the API request. |
| 719 | + Defaults to "". |
| 720 | + success (bool, optional): Whether the operation was successful. |
| 721 | + Defaults to False. |
| 722 | + metrics (Optional[SessionMetrics], optional): Session metrics data. |
| 723 | + Defaults to None. |
| 724 | + error_message (str, optional): Error message if the operation failed. |
| 725 | + Defaults to "". |
| 726 | + raw (Optional[dict], optional): Raw response data. Defaults to None. |
| 727 | + """ |
| 728 | + super().__init__(request_id) |
| 729 | + self.success = success |
| 730 | + self.metrics = metrics |
| 731 | + self.error_message = error_message |
| 732 | + self.raw = raw or {} |
0 commit comments