xpander-sdk 1.59.0__tar.gz → 2.0.169__tar.gz

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 (116) hide show
  1. {xpander_sdk-1.59.0 → xpander_sdk-2.0.169}/LICENSE +0 -1
  2. xpander_sdk-2.0.169/PKG-INFO +538 -0
  3. xpander_sdk-2.0.169/README.md +489 -0
  4. xpander_sdk-2.0.169/pyproject.toml +19 -0
  5. xpander_sdk-2.0.169/setup.py +38 -0
  6. xpander_sdk-2.0.169/src/xpander_sdk/__init__.py +86 -0
  7. xpander_sdk-2.0.169/src/xpander_sdk/consts/__init__.py +0 -0
  8. xpander_sdk-2.0.169/src/xpander_sdk/consts/api_routes.py +63 -0
  9. xpander_sdk-2.0.169/src/xpander_sdk/core/__init__.py +0 -0
  10. xpander_sdk-2.0.169/src/xpander_sdk/core/module_base.py +164 -0
  11. xpander_sdk-2.0.169/src/xpander_sdk/core/state.py +10 -0
  12. xpander_sdk-2.0.169/src/xpander_sdk/core/xpander_api_client.py +119 -0
  13. xpander_sdk-2.0.169/src/xpander_sdk/exceptions/__init__.py +0 -0
  14. xpander_sdk-2.0.169/src/xpander_sdk/exceptions/module_exception.py +45 -0
  15. xpander_sdk-2.0.169/src/xpander_sdk/models/__init__.py +0 -0
  16. xpander_sdk-2.0.169/src/xpander_sdk/models/activity.py +65 -0
  17. xpander_sdk-2.0.169/src/xpander_sdk/models/compactization.py +112 -0
  18. xpander_sdk-2.0.169/src/xpander_sdk/models/configuration.py +92 -0
  19. xpander_sdk-2.0.169/src/xpander_sdk/models/deep_planning.py +18 -0
  20. xpander_sdk-2.0.169/src/xpander_sdk/models/events.py +76 -0
  21. xpander_sdk-2.0.169/src/xpander_sdk/models/frameworks.py +64 -0
  22. xpander_sdk-2.0.169/src/xpander_sdk/models/shared.py +102 -0
  23. xpander_sdk-2.0.169/src/xpander_sdk/models/user.py +21 -0
  24. xpander_sdk-2.0.169/src/xpander_sdk/modules/__init__.py +0 -0
  25. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/__init__.py +0 -0
  26. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/agents_module.py +164 -0
  27. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/models/__init__.py +0 -0
  28. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/models/agent.py +477 -0
  29. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/models/agent_list.py +107 -0
  30. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/models/knowledge_bases.py +33 -0
  31. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/sub_modules/__init__.py +0 -0
  32. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/sub_modules/agent.py +956 -0
  33. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/utils/__init__.py +0 -0
  34. xpander_sdk-2.0.169/src/xpander_sdk/modules/agents/utils/generic.py +2 -0
  35. xpander_sdk-2.0.169/src/xpander_sdk/modules/backend/__init__.py +0 -0
  36. xpander_sdk-2.0.169/src/xpander_sdk/modules/backend/backend_module.py +425 -0
  37. xpander_sdk-2.0.169/src/xpander_sdk/modules/backend/frameworks/__init__.py +0 -0
  38. xpander_sdk-2.0.169/src/xpander_sdk/modules/backend/frameworks/agno.py +939 -0
  39. xpander_sdk-2.0.169/src/xpander_sdk/modules/backend/frameworks/dispatch.py +36 -0
  40. xpander_sdk-2.0.169/src/xpander_sdk/modules/backend/utils/__init__.py +0 -0
  41. xpander_sdk-2.0.169/src/xpander_sdk/modules/backend/utils/mcp_oauth.py +95 -0
  42. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/__init__.py +0 -0
  43. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/decorators/__init__.py +0 -0
  44. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/decorators/on_boot.py +94 -0
  45. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/decorators/on_shutdown.py +94 -0
  46. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/decorators/on_task.py +203 -0
  47. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/events_module.py +650 -0
  48. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/models/__init__.py +0 -0
  49. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/models/deployments.py +25 -0
  50. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/models/events.py +57 -0
  51. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/utils/__init__.py +0 -0
  52. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/utils/generic.py +56 -0
  53. xpander_sdk-2.0.169/src/xpander_sdk/modules/events/utils/git_init.py +32 -0
  54. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/__init__.py +0 -0
  55. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/knowledge_bases_module.py +217 -0
  56. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/models/__init__.py +0 -0
  57. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/models/knowledge_bases.py +11 -0
  58. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/sub_modules/__init__.py +0 -0
  59. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/sub_modules/knowledge_base.py +107 -0
  60. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/sub_modules/knowledge_base_document_item.py +40 -0
  61. xpander_sdk-2.0.169/src/xpander_sdk/modules/knowledge_bases/utils/__init__.py +0 -0
  62. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/__init__.py +0 -0
  63. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/models/__init__.py +0 -0
  64. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/models/task.py +153 -0
  65. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/models/tasks_list.py +107 -0
  66. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/sub_modules/__init__.py +0 -0
  67. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/sub_modules/task.py +976 -0
  68. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/tasks_module.py +492 -0
  69. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/utils/__init__.py +0 -0
  70. xpander_sdk-2.0.169/src/xpander_sdk/modules/tasks/utils/files.py +114 -0
  71. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/__init__.py +0 -0
  72. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/decorators/__init__.py +0 -0
  73. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/decorators/register_tool.py +108 -0
  74. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/models/__init__.py +0 -0
  75. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/models/mcp.py +68 -0
  76. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/models/tool_invocation_result.py +14 -0
  77. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/sub_modules/__init__.py +0 -0
  78. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/sub_modules/tool.py +578 -0
  79. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/tools_repository_module.py +259 -0
  80. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/utils/__init__.py +0 -0
  81. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/utils/generic.py +57 -0
  82. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/utils/local_tools.py +52 -0
  83. xpander_sdk-2.0.169/src/xpander_sdk/modules/tools_repository/utils/schemas.py +308 -0
  84. xpander_sdk-2.0.169/src/xpander_sdk/utils/__init__.py +0 -0
  85. xpander_sdk-2.0.169/src/xpander_sdk/utils/agents/__init__.py +0 -0
  86. xpander_sdk-2.0.169/src/xpander_sdk/utils/agents/compactization_agent.py +219 -0
  87. xpander_sdk-2.0.169/src/xpander_sdk/utils/env.py +44 -0
  88. xpander_sdk-2.0.169/src/xpander_sdk/utils/event_loop.py +67 -0
  89. xpander_sdk-2.0.169/src/xpander_sdk/utils/generic.py +5 -0
  90. xpander_sdk-2.0.169/src/xpander_sdk/utils/tools.py +32 -0
  91. xpander_sdk-2.0.169/src/xpander_sdk.egg-info/PKG-INFO +538 -0
  92. xpander_sdk-2.0.169/src/xpander_sdk.egg-info/SOURCES.txt +102 -0
  93. xpander_sdk-2.0.169/src/xpander_sdk.egg-info/requires.txt +26 -0
  94. xpander_sdk-2.0.169/tests/test_agents_module.py +92 -0
  95. xpander_sdk-2.0.169/tests/test_api_client.py +34 -0
  96. xpander_sdk-2.0.169/tests/test_backend_module.py +213 -0
  97. xpander_sdk-2.0.169/tests/test_boot_shutdown_handlers.py +489 -0
  98. xpander_sdk-2.0.169/tests/test_configuration.py +47 -0
  99. xpander_sdk-2.0.169/tests/test_knowledge_bases_module.py +118 -0
  100. xpander_sdk-2.0.169/tests/test_tasks_module.py +277 -0
  101. xpander_sdk-2.0.169/tests/test_tools_repository.py +238 -0
  102. xpander_sdk-1.59.0/MANIFEST.in +0 -1
  103. xpander_sdk-1.59.0/PKG-INFO +0 -368
  104. xpander_sdk-1.59.0/README.md +0 -342
  105. xpander_sdk-1.59.0/pyproject.toml +0 -9
  106. xpander_sdk-1.59.0/setup.py +0 -63
  107. xpander_sdk-1.59.0/src/xpander_sdk/__init__.py +0 -7803
  108. xpander_sdk-1.59.0/src/xpander_sdk/_jsii/__init__.py +0 -39
  109. xpander_sdk-1.59.0/src/xpander_sdk/_jsii/xpander-sdk@1.59.0.jsii.tgz +0 -0
  110. xpander_sdk-1.59.0/src/xpander_sdk/py.typed +0 -1
  111. xpander_sdk-1.59.0/src/xpander_sdk.egg-info/PKG-INFO +0 -368
  112. xpander_sdk-1.59.0/src/xpander_sdk.egg-info/SOURCES.txt +0 -14
  113. xpander_sdk-1.59.0/src/xpander_sdk.egg-info/requires.txt +0 -3
  114. {xpander_sdk-1.59.0 → xpander_sdk-2.0.169}/setup.cfg +0 -0
  115. {xpander_sdk-1.59.0 → xpander_sdk-2.0.169}/src/xpander_sdk.egg-info/dependency_links.txt +0 -0
  116. {xpander_sdk-1.59.0 → xpander_sdk-2.0.169}/src/xpander_sdk.egg-info/top_level.txt +0 -0
@@ -1,4 +1,3 @@
1
-
2
1
  Apache License
3
2
  Version 2.0, January 2004
4
3
  http://www.apache.org/licenses/
@@ -0,0 +1,538 @@
1
+ Metadata-Version: 2.4
2
+ Name: xpander-sdk
3
+ Version: 2.0.169
4
+ Summary: xpander.ai Backend-as-a-service for AI Agents - SDK
5
+ Home-page: https://www.xpander.ai
6
+ Author: xpanderAI
7
+ Author-email: dev@xpander.ai
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: python-dotenv
15
+ Requires-Dist: packaging
16
+ Requires-Dist: pydantic
17
+ Requires-Dist: loguru
18
+ Requires-Dist: httpx
19
+ Requires-Dist: httpx_sse
20
+ Requires-Dist: nest-asyncio
21
+ Requires-Dist: strands-agents
22
+ Requires-Dist: openai-agents
23
+ Provides-Extra: agno
24
+ Requires-Dist: agno; extra == "agno"
25
+ Requires-Dist: sqlalchemy; extra == "agno"
26
+ Requires-Dist: psycopg[binary,pool]; extra == "agno"
27
+ Requires-Dist: greenlet; extra == "agno"
28
+ Provides-Extra: dev
29
+ Requires-Dist: black; extra == "dev"
30
+ Requires-Dist: pre-commit; extra == "dev"
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: anthropic; extra == "dev"
33
+ Requires-Dist: mcp; extra == "dev"
34
+ Requires-Dist: openai; extra == "dev"
35
+ Requires-Dist: fireworks-ai; extra == "dev"
36
+ Requires-Dist: aioboto3; extra == "dev"
37
+ Requires-Dist: google-genai; extra == "dev"
38
+ Dynamic: author
39
+ Dynamic: author-email
40
+ Dynamic: classifier
41
+ Dynamic: description
42
+ Dynamic: description-content-type
43
+ Dynamic: home-page
44
+ Dynamic: license-file
45
+ Dynamic: provides-extra
46
+ Dynamic: requires-dist
47
+ Dynamic: requires-python
48
+ Dynamic: summary
49
+
50
+ # xpander.ai SDK
51
+
52
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Documentation](https://img.shields.io/badge/docs-available-brightgreen.svg)](https://docs.xpander.ai) [![PyPI Version](https://img.shields.io/pypi/v/xpander-sdk?label=PyPI)](https://pypi.org/project/xpander-sdk/) [![Downloads](https://pepy.tech/badge/xpander-sdk)](https://pepy.tech/project/xpander-sdk)
53
+
54
+ The official Python SDK for xpander.ai - a powerful Backend-as-a-Service (BaaS) platform for building, deploying, and managing AI agents at scale.
55
+
56
+ ## 🚀 Overview
57
+
58
+ xpander.ai SDK provides comprehensive tools for:
59
+
60
+ - **Agent Management**: Create, configure, and manage AI agents
61
+ - **Task Execution**: Handle complex task workflows and execution
62
+ - **Tools Repository**: Integrate external tools and services
63
+ - **Knowledge Bases**: Manage and search knowledge repositories
64
+ - **Event Handling**: Event-driven programming with decorators
65
+ - **Real-time Monitoring**: Track agent performance and execution
66
+
67
+ ## 📦 Installation
68
+
69
+ ```bash
70
+ pip install xpander-sdk
71
+ ```
72
+
73
+ ### With Optional Dependencies
74
+
75
+ ```bash
76
+ # For Agno framework support (2.0+)
77
+ pip install xpander-sdk[agno]
78
+
79
+ # For development
80
+ pip install xpander-sdk[dev]
81
+ ```
82
+
83
+ ## 🔧 Quick Start
84
+
85
+ ### 1. Configuration
86
+
87
+ ```python
88
+ from xpander_sdk import Configuration
89
+
90
+ # Using environment variables (recommended)
91
+ config = Configuration()
92
+
93
+ # Or explicit configuration
94
+ config = Configuration(
95
+ api_key="your-api-key",
96
+ organization_id="your-org-id",
97
+ base_url="https://inbound.xpander.ai"
98
+ )
99
+ ```
100
+
101
+ ### 2. Basic Agent Operations
102
+
103
+ ```python
104
+ from xpander_sdk import Agents, Agent, Tasks, AgentDeploymentType
105
+
106
+ # Initialize agents module
107
+ agents = Agents(configuration=config)
108
+
109
+ # List all agents
110
+ agent_list = await agents.alist()
111
+
112
+ # Load existing agent
113
+ agent = await agents.aget("agent-id")
114
+
115
+ # Create and execute a task
116
+ task = await agent.acreate_task(
117
+ prompt="Help me analyze this data",
118
+ file_urls=["https://example.com/data.csv"]
119
+ )
120
+ ```
121
+
122
+ ### 3. Task Management
123
+
124
+ ```python
125
+ from xpander_sdk import Tasks, Task
126
+
127
+ # Initialize tasks module
128
+ tasks = Tasks(configuration=config)
129
+
130
+ # Load and manage tasks
131
+ task = await tasks.aget("task-id")
132
+ await task.aset_status(AgentExecutionStatus.Running)
133
+ await task.asave()
134
+
135
+ # Retrieve task activity log
136
+ activity_log = await task.aget_activity_log()
137
+ for message in activity_log.messages:
138
+ print(f"{message.role}: {message.content.text}")
139
+ ```
140
+
141
+ ### 4. Tools Integration
142
+
143
+ ```python
144
+ from xpander_sdk import register_tool, ToolsRepository
145
+
146
+ # Register a local tool
147
+ @register_tool
148
+ def check_weather(location: str) -> str:
149
+ """Check weather for a given location."""
150
+ return f"Weather in {location}: Sunny, 25°C"
151
+
152
+ # Register a tool with graph synchronization
153
+ @register_tool(add_to_graph=True)
154
+ async def analyze_data(data: list, analysis_type: str) -> dict:
155
+ """Analyze data from multiple sources."""
156
+ return {
157
+ "analysis_type": analysis_type,
158
+ "data_points": len(data),
159
+ "status": "completed"
160
+ }
161
+
162
+ # Use tools repository
163
+ tools = ToolsRepository(configuration=config)
164
+ weather_tool = tools.get_tool_by_id("check_weather")
165
+ result = await weather_tool.ainvoke(
166
+ agent_id="agent-id",
167
+ payload={"location": "New York"}
168
+ )
169
+ ```
170
+
171
+ ### 5. Knowledge Base Operations
172
+
173
+ ```python
174
+ from xpander_sdk import KnowledgeBases, KnowledgeBase
175
+
176
+ # Initialize knowledge bases
177
+ kb_module = KnowledgeBases(configuration=config)
178
+
179
+ # Create knowledge base
180
+ kb = await kb_module.acreate(
181
+ name="Company Docs",
182
+ description="Internal documentation"
183
+ )
184
+
185
+ # Add documents
186
+ documents = await kb.aadd_documents([
187
+ "https://example.com/doc1.pdf",
188
+ "https://example.com/doc2.txt"
189
+ ])
190
+
191
+ # Search knowledge base
192
+ results = await kb.asearch(
193
+ search_query="product pricing",
194
+ top_k=5
195
+ )
196
+ ```
197
+
198
+ ### 6. Event-Driven Programming
199
+
200
+ ```python
201
+ from xpander_sdk import on_task, Events
202
+
203
+ # Basic task handler
204
+ @on_task
205
+ async def handle_task(task):
206
+ print(f"Processing task: {task.id}")
207
+ # Task processing logic here
208
+ task.result = "Task processed successfully"
209
+ return task
210
+
211
+ # Task handler with configuration
212
+ @on_task(configuration=config)
213
+ def sync_task_handler(task):
214
+ print(f"Handling task synchronously: {task.id}")
215
+ task.result = "Sync processing complete"
216
+ return task
217
+
218
+ ```
219
+
220
+ ## 📚 Core Modules
221
+
222
+ | Module | Description | Documentation |
223
+ | ------------------- | ----------------------------------------- | ---------------------------------------------------------------------------------------- |
224
+ | **Agents** | Agent creation, management, and execution | [Agents Guide](https://github.com/xpander-ai/xpander-sdk/blob/main/docs/AGENTS.md) |
225
+ | **Tasks** | Task lifecycle and execution management | [Tasks Guide](https://github.com/xpander-ai/xpander-sdk/blob/main/docs/TASKS.md) |
226
+ | **ToolsRepository** | External tools and integrations | [Tools Guide](https://github.com/xpander-ai/xpander-sdk/blob/main/docs/TOOLS.md) |
227
+ | **KnowledgeBases** | Knowledge management and search | [Knowledge Guide](https://github.com/xpander-ai/xpander-sdk/blob/main/docs/KNOWLEDGE.md) |
228
+ | **Events** | Event-driven programming | [Events Guide](https://github.com/xpander-ai/xpander-sdk/blob/main/docs/EVENTS.md) |
229
+ | **Backend** | Agent runtime arguments for frameworks | [Backend Guide](https://github.com/xpander-ai/xpander-sdk/blob/main/docs/BACKEND.md) |
230
+
231
+ ## 🔄 Async/Sync Support
232
+
233
+ The SDK provides both asynchronous and synchronous interfaces:
234
+
235
+ ```python
236
+ # Asynchronous (recommended for production)
237
+ agent = await Agent.aload("agent-id")
238
+ task = await agent.acreate_task(prompt="input data")
239
+
240
+ # Synchronous (convenient for scripts)
241
+ agent = Agent.load("agent-id")
242
+ task = agent.create_task(prompt="input data")
243
+ ```
244
+
245
+ ## 📖 Advanced Examples
246
+
247
+ ### Multi-Agent Orchestration
248
+
249
+ ```python
250
+ # Load multiple specialized agents
251
+ agents_list = await agents.alist()
252
+ data_agent = await agents.aget("data-agent-id")
253
+ writer_agent = await agents.aget("writer-agent-id")
254
+
255
+ # Chain agent executions
256
+ analysis_task = await data_agent.acreate_task(prompt="Analyze sales data")
257
+ report_task = await writer_agent.acreate_task(
258
+ prompt=f"Write a report based on: {analysis_task.result}"
259
+ )
260
+ ```
261
+
262
+ ### Tool Integration with MCP Servers
263
+
264
+ ```python
265
+ from xpander_sdk import MCPServerDetails, MCPServerType
266
+
267
+ # Configure MCP server
268
+ mcp_server = MCPServerDetails(
269
+ name="data-server",
270
+ type=MCPServerType.STDIO,
271
+ command="python",
272
+ args=["-m", "mcp_server"],
273
+ env={"API_KEY": "your-key"}
274
+ )
275
+
276
+ # MCP servers are configured at the platform level
277
+ # and tools become available through ToolsRepository
278
+ ```
279
+
280
+ ### Streaming Task Execution
281
+
282
+ ```python
283
+ # Create a task with event streaming enabled
284
+ task = await agent.acreate_task(
285
+ prompt="complex analysis task",
286
+ events_streaming=True
287
+ )
288
+
289
+ # Stream events from the task
290
+ async for event in task.aevents():
291
+ print(f"Event Type: {event.type}")
292
+ print(f"Event Data: {event.data}")
293
+ ```
294
+
295
+ ### Task Activity Monitoring
296
+
297
+ ```python
298
+ from xpander_sdk import Task
299
+ from xpander_sdk.models.activity import (
300
+ AgentActivityThreadMessage,
301
+ AgentActivityThreadToolCall,
302
+ AgentActivityThreadReasoning
303
+ )
304
+
305
+ # Load a completed task
306
+ task = await Task.aload("task-id")
307
+
308
+ # Get detailed activity log
309
+ activity_log = await task.aget_activity_log()
310
+
311
+ # Analyze messages between user and agent
312
+ for message in activity_log.messages:
313
+ if isinstance(message, AgentActivityThreadMessage):
314
+ print(f"{message.role}: {message.content.text}")
315
+ elif isinstance(message, AgentActivityThreadToolCall):
316
+ # Tool call
317
+ print(f"Tool: {message.tool_name}")
318
+ print(f"Payload: {message.payload}")
319
+ print(f"Result: {message.result}")
320
+ elif isinstance(message, AgentActivityThreadReasoning):
321
+ # Reasoning step
322
+ print(f"Reasoning ({message.type}): {message.thought}")
323
+
324
+ # Synchronous version
325
+ task = Task.load("task-id")
326
+ activity_log = task.get_activity_log()
327
+ ```
328
+
329
+ ### Local Task Testing
330
+
331
+ ```python
332
+ from xpander_sdk.modules.tasks.models.task import LocalTaskTest, AgentExecutionInput
333
+ from xpander_sdk.models.shared import OutputFormat
334
+ from xpander_sdk import on_task
335
+
336
+ # Define a local test task
337
+ local_task = LocalTaskTest(
338
+ input=AgentExecutionInput(text="What can you do?"),
339
+ output_format=OutputFormat.Json,
340
+ output_schema={"capabilities": "list of capabilities"}
341
+ )
342
+
343
+ # Test with local task
344
+ @on_task(test_task=local_task)
345
+ async def handle_test_task(task):
346
+ task.result = {
347
+ "capabilities": [
348
+ "Data analysis",
349
+ "Text processing",
350
+ "API integration"
351
+ ]
352
+ }
353
+ return task
354
+ ```
355
+
356
+ ## 🧪 Testing
357
+
358
+ ```bash
359
+ # Run tests
360
+ pytest tests/
361
+
362
+ # Run with coverage
363
+ pytest tests/ --cov=xpander_sdk
364
+
365
+ # Run specific test
366
+ pytest tests/test_agents.py::test_agent_creation
367
+ ```
368
+
369
+ ## 🏗️ Architecture
370
+
371
+ ```plaintext
372
+ xpander_sdk/
373
+ ├── core/ # Core API client and base classes
374
+ ├── models/ # Pydantic models and configurations
375
+ ├── modules/
376
+ │ ├── agents/ # Agent management
377
+ │ ├── tasks/ # Task execution
378
+ │ ├── tools_repository/ # Tools and integrations
379
+ │ ├── knowledge_bases/ # Knowledge management
380
+ │ ├── events/ # Event handling
381
+ │ └── backend/ # Agent runtime arguments for frameworks
382
+ └── utils/ # Utility functions
383
+ ```
384
+
385
+ ## 🔒 Authentication
386
+
387
+ The SDK supports multiple authentication methods:
388
+
389
+ ### Environment Variables (Recommended)
390
+
391
+ ```bash
392
+ export XPANDER_API_KEY="your-api-key"
393
+ export XPANDER_ORGANIZATION_ID="your-org-id"
394
+ export XPANDER_BASE_URL="https://inbound.xpander.ai" # Optional
395
+ export XPANDER_AGENT_ID="your-agent-id" # Optional for Backend module
396
+ ```
397
+
398
+ ### Configuration Object
399
+
400
+ ```python
401
+ config = Configuration(
402
+ api_key="your-api-key",
403
+ organization_id="your-org-id"
404
+ )
405
+ ```
406
+
407
+ ### From File
408
+
409
+ ```python
410
+ # .env file
411
+ XPANDER_API_KEY=your-api-key
412
+ XPANDER_ORGANIZATION_ID=your-org-id
413
+
414
+ # Python code
415
+ from dotenv import load_dotenv
416
+ load_dotenv()
417
+ config = Configuration()
418
+ ```
419
+
420
+ ## 🏢 Self-Hosted Deployment
421
+
422
+ If you're using a self-hosted xpander.ai deployment, configure the SDK to point to your Agent Controller endpoint.
423
+
424
+ **Important**: Use the **Agent Controller API key** generated during Helm installation, not your xpander.ai cloud API key.
425
+
426
+ ### Configuration
427
+
428
+ ```bash
429
+ # Set environment variables
430
+ export XPANDER_API_KEY="your-agent-controller-api-key" # From Helm installation
431
+ export XPANDER_ORGANIZATION_ID="your-org-id"
432
+ export XPANDER_BASE_URL="https://agent-controller.my-company.com"
433
+ ```
434
+
435
+ Or configure explicitly:
436
+
437
+ ```python
438
+ from xpander_sdk import Configuration
439
+
440
+ config = Configuration(
441
+ api_key="your-agent-controller-api-key", # From Helm installation
442
+ organization_id="your-org-id",
443
+ base_url="https://agent-controller.my-company.com"
444
+ )
445
+ ```
446
+
447
+ ### Using with Agno Framework
448
+
449
+ ```python
450
+ from xpander_sdk import Backend, Configuration
451
+ from agno.agent import Agent
452
+
453
+ # Configure for self-hosted
454
+ config = Configuration(
455
+ api_key="your-agent-controller-api-key", # From Helm installation
456
+ organization_id="your-org-id",
457
+ base_url="https://agent-controller.my-company.com"
458
+ )
459
+
460
+ # Initialize Backend with self-hosted config
461
+ backend = Backend(configuration=config)
462
+
463
+ # Create agent - it will use your self-hosted infrastructure
464
+ agno_agent = Agent(**backend.get_args(agent_id="agent-123"))
465
+
466
+ # Run agent
467
+ result = await agno_agent.arun(
468
+ input="What can you help me with?",
469
+ stream=True
470
+ )
471
+ ```
472
+
473
+ ### Complete Self-Hosted Example
474
+
475
+ ```python
476
+ import asyncio
477
+ from xpander_sdk import Configuration, Agent
478
+
479
+ async def main():
480
+ # Configure for self-hosted deployment
481
+ config = Configuration(
482
+ api_key="your-agent-controller-api-key", # From Helm installation
483
+ organization_id="your-org-id",
484
+ base_url="https://agent-controller.my-company.com"
485
+ )
486
+
487
+ # Load agent from self-hosted deployment
488
+ agent = await Agent.aload("agent-123", configuration=config)
489
+ print(f"Agent: {agent.name}")
490
+
491
+ # Create and execute task
492
+ task = await agent.acreate_task(
493
+ prompt="Analyze Q4 sales data",
494
+ file_urls=["https://example.com/sales-q4.csv"]
495
+ )
496
+ print(f"Task created: {task.id}")
497
+ print(f"Status: {task.status}")
498
+
499
+ if __name__ == "__main__":
500
+ asyncio.run(main())
501
+ ```
502
+
503
+ **Important**: Make sure your `base_url` points to the Agent Controller endpoint (e.g., `https://agent-controller.{your-domain}`), not the root domain.
504
+
505
+ 📖 **Full Guide**: [Self-Hosted Configuration Documentation](https://docs.xpander.ai/api-reference/configuration/self-hosted)
506
+
507
+ ## 🔄 Error Handling
508
+
509
+ ```python
510
+ from xpander_sdk.exceptions import ModuleException
511
+
512
+ try:
513
+ agent = await Agent.aload("invalid-agent-id")
514
+ except ModuleException as e:
515
+ print(f"Error {e.status_code}: {e.description}")
516
+ ```
517
+
518
+ ## 🤝 Contributing
519
+
520
+ 1. Fork the repository
521
+ 2. Create a feature branch (`git checkout -b feature/{base_branch}/amazing-feature`)
522
+ 3. Commit your changes (`git commit -m 'feat/chore/fix: Add amazing feature'`)
523
+ 4. Push to the branch (`git push origin feature/{base_branch}/amazing-feature`)
524
+ 5. Open a Pull Request
525
+
526
+ ## 📄 License
527
+
528
+ This project is licensed under the MIT License - see the LICENSE file for details.
529
+
530
+ ## 🆘 Support
531
+
532
+ - **Documentation**: [https://docs.xpander.ai](https://docs.xpander.ai)
533
+ - **Issues**: [GitHub Issues](https://github.com/xpander-ai/xpander-sdk/issues)
534
+ - **Email**: support@xpander.ai
535
+
536
+ ---
537
+
538
+ Built with ❤️ by the xpander.ai team