xpander-sdk 1.60.8__py3-none-any.whl → 2.0.155__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. xpander_sdk/__init__.py +76 -7793
  2. xpander_sdk/consts/__init__.py +0 -0
  3. xpander_sdk/consts/api_routes.py +63 -0
  4. xpander_sdk/core/__init__.py +0 -0
  5. xpander_sdk/core/module_base.py +164 -0
  6. xpander_sdk/core/state.py +10 -0
  7. xpander_sdk/core/xpander_api_client.py +119 -0
  8. xpander_sdk/exceptions/__init__.py +0 -0
  9. xpander_sdk/exceptions/module_exception.py +45 -0
  10. xpander_sdk/models/__init__.py +0 -0
  11. xpander_sdk/models/activity.py +65 -0
  12. xpander_sdk/models/configuration.py +92 -0
  13. xpander_sdk/models/events.py +70 -0
  14. xpander_sdk/models/frameworks.py +64 -0
  15. xpander_sdk/models/shared.py +102 -0
  16. xpander_sdk/models/user.py +21 -0
  17. xpander_sdk/modules/__init__.py +0 -0
  18. xpander_sdk/modules/agents/__init__.py +0 -0
  19. xpander_sdk/modules/agents/agents_module.py +164 -0
  20. xpander_sdk/modules/agents/models/__init__.py +0 -0
  21. xpander_sdk/modules/agents/models/agent.py +477 -0
  22. xpander_sdk/modules/agents/models/agent_list.py +107 -0
  23. xpander_sdk/modules/agents/models/knowledge_bases.py +33 -0
  24. xpander_sdk/modules/agents/sub_modules/__init__.py +0 -0
  25. xpander_sdk/modules/agents/sub_modules/agent.py +953 -0
  26. xpander_sdk/modules/agents/utils/__init__.py +0 -0
  27. xpander_sdk/modules/agents/utils/generic.py +2 -0
  28. xpander_sdk/modules/backend/__init__.py +0 -0
  29. xpander_sdk/modules/backend/backend_module.py +425 -0
  30. xpander_sdk/modules/backend/frameworks/__init__.py +0 -0
  31. xpander_sdk/modules/backend/frameworks/agno.py +627 -0
  32. xpander_sdk/modules/backend/frameworks/dispatch.py +36 -0
  33. xpander_sdk/modules/backend/utils/__init__.py +0 -0
  34. xpander_sdk/modules/backend/utils/mcp_oauth.py +95 -0
  35. xpander_sdk/modules/events/__init__.py +0 -0
  36. xpander_sdk/modules/events/decorators/__init__.py +0 -0
  37. xpander_sdk/modules/events/decorators/on_boot.py +94 -0
  38. xpander_sdk/modules/events/decorators/on_shutdown.py +94 -0
  39. xpander_sdk/modules/events/decorators/on_task.py +203 -0
  40. xpander_sdk/modules/events/events_module.py +629 -0
  41. xpander_sdk/modules/events/models/__init__.py +0 -0
  42. xpander_sdk/modules/events/models/deployments.py +25 -0
  43. xpander_sdk/modules/events/models/events.py +57 -0
  44. xpander_sdk/modules/events/utils/__init__.py +0 -0
  45. xpander_sdk/modules/events/utils/generic.py +56 -0
  46. xpander_sdk/modules/events/utils/git_init.py +32 -0
  47. xpander_sdk/modules/knowledge_bases/__init__.py +0 -0
  48. xpander_sdk/modules/knowledge_bases/knowledge_bases_module.py +217 -0
  49. xpander_sdk/modules/knowledge_bases/models/__init__.py +0 -0
  50. xpander_sdk/modules/knowledge_bases/models/knowledge_bases.py +11 -0
  51. xpander_sdk/modules/knowledge_bases/sub_modules/__init__.py +0 -0
  52. xpander_sdk/modules/knowledge_bases/sub_modules/knowledge_base.py +107 -0
  53. xpander_sdk/modules/knowledge_bases/sub_modules/knowledge_base_document_item.py +40 -0
  54. xpander_sdk/modules/knowledge_bases/utils/__init__.py +0 -0
  55. xpander_sdk/modules/tasks/__init__.py +0 -0
  56. xpander_sdk/modules/tasks/models/__init__.py +0 -0
  57. xpander_sdk/modules/tasks/models/task.py +153 -0
  58. xpander_sdk/modules/tasks/models/tasks_list.py +107 -0
  59. xpander_sdk/modules/tasks/sub_modules/__init__.py +0 -0
  60. xpander_sdk/modules/tasks/sub_modules/task.py +887 -0
  61. xpander_sdk/modules/tasks/tasks_module.py +492 -0
  62. xpander_sdk/modules/tasks/utils/__init__.py +0 -0
  63. xpander_sdk/modules/tasks/utils/files.py +114 -0
  64. xpander_sdk/modules/tools_repository/__init__.py +0 -0
  65. xpander_sdk/modules/tools_repository/decorators/__init__.py +0 -0
  66. xpander_sdk/modules/tools_repository/decorators/register_tool.py +108 -0
  67. xpander_sdk/modules/tools_repository/models/__init__.py +0 -0
  68. xpander_sdk/modules/tools_repository/models/mcp.py +68 -0
  69. xpander_sdk/modules/tools_repository/models/tool_invocation_result.py +14 -0
  70. xpander_sdk/modules/tools_repository/sub_modules/__init__.py +0 -0
  71. xpander_sdk/modules/tools_repository/sub_modules/tool.py +578 -0
  72. xpander_sdk/modules/tools_repository/tools_repository_module.py +259 -0
  73. xpander_sdk/modules/tools_repository/utils/__init__.py +0 -0
  74. xpander_sdk/modules/tools_repository/utils/generic.py +57 -0
  75. xpander_sdk/modules/tools_repository/utils/local_tools.py +52 -0
  76. xpander_sdk/modules/tools_repository/utils/schemas.py +308 -0
  77. xpander_sdk/utils/__init__.py +0 -0
  78. xpander_sdk/utils/env.py +44 -0
  79. xpander_sdk/utils/event_loop.py +67 -0
  80. xpander_sdk/utils/tools.py +32 -0
  81. xpander_sdk-2.0.155.dist-info/METADATA +538 -0
  82. xpander_sdk-2.0.155.dist-info/RECORD +85 -0
  83. {xpander_sdk-1.60.8.dist-info → xpander_sdk-2.0.155.dist-info}/WHEEL +1 -1
  84. {xpander_sdk-1.60.8.dist-info → xpander_sdk-2.0.155.dist-info/licenses}/LICENSE +0 -1
  85. xpander_sdk/_jsii/__init__.py +0 -39
  86. xpander_sdk/_jsii/xpander-sdk@1.60.8.jsii.tgz +0 -0
  87. xpander_sdk/py.typed +0 -1
  88. xpander_sdk-1.60.8.dist-info/METADATA +0 -368
  89. xpander_sdk-1.60.8.dist-info/RECORD +0 -9
  90. {xpander_sdk-1.60.8.dist-info → xpander_sdk-2.0.155.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,153 @@
1
+ """
2
+ Task models for agent execution in the xpander.ai SDK.
3
+
4
+ This module defines the various data models related to task execution, status,
5
+ and inputs for agents within the xpander.ai platform.
6
+ """
7
+
8
+ from enum import Enum
9
+ from typing import Any, Dict, List, Optional
10
+ from pydantic import BaseModel
11
+ from xpander_sdk.models.shared import ExecutionTokens, OutputFormat, Tokens, XPanderSharedModel
12
+ from xpander_sdk.models.user import User
13
+
14
+
15
+ class AgentExecutionStatus(str, Enum):
16
+ """
17
+ Enumeration of possible execution statuses for an agent task.
18
+
19
+ Values:
20
+ Pending: Task is pending execution.
21
+ Executing: Task is currently executing.
22
+ Paused: Task execution is paused.
23
+ Error: Task encountered an error during execution.
24
+ Failed: Task execution failed to complete successfully.
25
+ Completed: Task execution completed successfully.
26
+ Stopped: Task execution was stopped by the user.
27
+
28
+ Example:
29
+ >>> status = AgentExecutionStatus.Executing
30
+ >>> print(status.value) # "executing"
31
+ """
32
+
33
+ Pending = "pending"
34
+ Executing = "executing"
35
+ Paused = "paused"
36
+ Error = "error"
37
+ Failed = "failed"
38
+ Completed = "completed"
39
+ Stopped = "stopped"
40
+
41
+
42
+ class HumanInTheLoop(BaseModel):
43
+ """
44
+ Model representing human-in-the-loop approval records for tasks.
45
+
46
+ Attributes:
47
+ operation_id (str): Unique identifier of the operation requiring approval.
48
+ approved_by (Optional[str]): User who approved the operation.
49
+ rejected_by (Optional[str]): User who rejected the operation.
50
+ title (Optional[str]): Title/subject of the approval request.
51
+ description (Optional[str]): Detailed description of the approval.
52
+ content (str): Content or action that requires approval.
53
+ """
54
+
55
+ operation_id: str
56
+ approved_by: Optional[str] = None
57
+ rejected_by: Optional[str] = None
58
+ title: Optional[str] = None
59
+ description: Optional[str] = None
60
+ content: str
61
+
62
+
63
+ class AgentExecutionInput(BaseModel):
64
+ """
65
+ Model representing input to agent task execution.
66
+
67
+ Attributes:
68
+ text (Optional[str]): Textual input for the agent task.
69
+ files (Optional[List[str]]): List of file URLs to provide as input.
70
+ user (Optional[User]): User details associated with task execution.
71
+
72
+ Validators:
73
+ validate_at_least_one: Ensures that either text or files are provided.
74
+
75
+ Example:
76
+ >>> input = AgentExecutionInput(text="Process data", files=["http://file.url"])
77
+ >>> print(f"Input text: {input.text}")
78
+ """
79
+
80
+ text: Optional[str] = ""
81
+ files: Optional[List[str]] = []
82
+ user: Optional[User] = None
83
+
84
+ class PendingECARequest(BaseModel):
85
+ """
86
+ Model for pending ECA (External Credential Authorization) requests.
87
+
88
+ Attributes:
89
+ connector_name (str): Name of the connector requesting authorization.
90
+ auth_url (str): URL to initiate the authorization process.
91
+
92
+ Example:
93
+ >>> request = PendingECARequest(
94
+ ... connector_name="Google Drive",
95
+ ... auth_url="https://auth.example.com"
96
+ ... )
97
+ >>> print(f"Connector: {request.connector_name}")
98
+ """
99
+
100
+ connector_name: str
101
+ auth_url: str
102
+
103
+
104
+ class LocalTaskTest(BaseModel):
105
+ """
106
+ Model for testing tasks locally in the SDK.
107
+
108
+ Attributes:
109
+ input (AgentExecutionInput): The input for the task to be tested.
110
+ agent_version (Optional[str]): Specific version of the agent for the test.
111
+ output_format (Optional[OutputFormat]): Desired format of the output.
112
+ output_schema (Optional[Dict]): Schema defining the structure of the output.
113
+
114
+ Example:
115
+ >>> test = LocalTaskTest(
116
+ ... input=AgentExecutionInput(text="Test input"),
117
+ ... agent_version="1.0"
118
+ ... )
119
+ >>> print(f"Agent Version: {test.agent_version}")
120
+ """
121
+
122
+ input: AgentExecutionInput
123
+ agent_version: Optional[str] = None
124
+ output_format: Optional[OutputFormat] = None
125
+ output_schema: Optional[Dict] = None
126
+
127
+ class TaskReportRequest(XPanderSharedModel):
128
+ id: Optional[str] = None
129
+ input: Optional[str] = None
130
+ llm_response: Optional[Any] = None
131
+ tokens: Optional[Tokens] = None
132
+ is_success: Optional[bool] = True
133
+ result: Optional[str] = None
134
+ duration: Optional[float] = 0
135
+ used_tools: Optional[List[str]] = []
136
+
137
+ class ExecutionMetricsReport(XPanderSharedModel):
138
+ execution_id: str
139
+ source: str
140
+ sub_executions: Optional[list[str]] = []
141
+ memory_thread_id: str
142
+ task: str
143
+ triggered_by: Optional[str] = "N/A"
144
+ skills: Optional[list[str]] = []
145
+ status: str
146
+ internal_status: Optional[str] = None
147
+ duration: float
148
+ ai_model: str
149
+ worker: Optional[str] = None
150
+ ai_employee_id: Optional[str] = None
151
+ api_calls_made: Optional[List[Any]] = None
152
+ result: Optional[str]
153
+ llm_tokens: Optional[ExecutionTokens] = ExecutionTokens()
@@ -0,0 +1,107 @@
1
+ """
2
+ Tasks list item model for the xpander.ai SDK.
3
+
4
+ This module defines the TasksListItem model, which represents summary information
5
+ about tasks as returned in list operations, with methods to load full task details.
6
+ """
7
+
8
+ from datetime import datetime
9
+ from typing import Optional
10
+ from pydantic import BaseModel, Field
11
+
12
+ from xpander_sdk.models.configuration import Configuration
13
+ from xpander_sdk.modules.tasks.models.task import AgentExecutionStatus
14
+ from xpander_sdk.modules.tasks.sub_modules.task import Task
15
+ from xpander_sdk.utils.event_loop import run_sync
16
+
17
+ class TasksListItem(BaseModel):
18
+ """
19
+ Summary representation of a task in list operations.
20
+
21
+ This model provides essential information about a task, suitable for
22
+ display and interaction in list views, while enabling efficient retrieval
23
+ of full task details when needed.
24
+
25
+ Attributes:
26
+ id (str): Unique identifier for this task execution.
27
+ agent_id (str): ID of the agent responsible for executing the task.
28
+ organization_id (str): ID of the organization that owns the agent.
29
+ status (AgentExecutionStatus): Current execution status of the task.
30
+ created_at (Optional[datetime]): Timestamp when the execution was created.
31
+ updated_at (Optional[datetime]): Timestamp of the last update to this execution.
32
+ source_node_type (Optional[str]): The type of the source node that triggered execution.
33
+ result (Optional[str]): Final result of the execution, if available.
34
+ title (Optional[str]): Task title.
35
+
36
+ Methods:
37
+ aload: Asynchronously load the full task details.
38
+ load: Synchronously load the full task details.
39
+
40
+ Example:
41
+ >>> tasks = Tasks()
42
+ >>> task_list = tasks.list(agent_id="agent123")
43
+ >>> for item in task_list:
44
+ ... print(f"Task: {item.id} - Status: {item.status}")
45
+ ... full_task = item.load() # Load complete task details
46
+ """
47
+
48
+ id: str = Field(..., description="Unique identifier for this execution")
49
+ agent_id: str = Field(..., description="ID of the agent being executed")
50
+ user_id: Optional[str] = Field(default=None, description="ID of the user that created the task")
51
+ parent_task_id: Optional[str] = Field(default=None, description="ID of the parent task that triggered this task")
52
+ triggering_agent_id: Optional[str] = Field(default=None, description="ID of the triggering agen that triggered this task")
53
+ organization_id: str = Field(..., description="ID of the organization that owns the agent")
54
+ status: AgentExecutionStatus = Field(..., description="Current execution status")
55
+ created_at: Optional[datetime] = Field(default=None, description="Timestamp when the execution was created")
56
+ updated_at: Optional[datetime] = Field(default=None, description="Timestamp of the last update to this execution")
57
+ source_node_type: Optional[str] = Field(default=None, description="Type of the source node that triggered this execution (if any)")
58
+ result: Optional[str] = Field(default=None, description="Final result of the execution, if available")
59
+ title: Optional[str] = Field(default=None, description="Task title")
60
+
61
+ async def aload(self, configuration: Optional[Configuration] = None) -> Task:
62
+ """
63
+ Asynchronously load the complete Task object for this task.
64
+
65
+ Retrieves full task details from the xpander.ai platform, including
66
+ configuration, execution records, and results.
67
+
68
+ Args:
69
+ configuration (Optional[Configuration]): SDK configuration to use
70
+ for the request. If None, uses default configuration.
71
+
72
+ Returns:
73
+ Task: Complete task object with detailed configuration and history.
74
+
75
+ Raises:
76
+ ModuleException: If the task cannot be loaded or access is denied.
77
+
78
+ Example:
79
+ >>> task_item = task_list[0]
80
+ >>> full_task = await task_item.aload()
81
+ >>> print(f"Task result: {full_task.result}")
82
+ """
83
+ return await Task.aload(task_id=self.id, configuration=configuration)
84
+
85
+ def load(self, configuration: Optional[Configuration] = None) -> Task:
86
+ """
87
+ Synchronously load the complete Task object for this task.
88
+
89
+ This is the synchronous version of aload(). It internally calls the
90
+ asynchronous method and waits for completion.
91
+
92
+ Args:
93
+ configuration (Optional[Configuration]): SDK configuration to use
94
+ for the request. If None, uses default configuration.
95
+
96
+ Returns:
97
+ Task: Complete task object with detailed configuration and history.
98
+
99
+ Raises:
100
+ ModuleException: If the task cannot be loaded or access is denied.
101
+
102
+ Example:
103
+ >>> task_item = task_list[0]
104
+ >>> full_task = task_item.load()
105
+ >>> print(f"Task result: {full_task.result}")
106
+ """
107
+ return run_sync(self.aload(configuration=configuration))
File without changes