agentex-sdk 0.1.0a6__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 (289) hide show
  1. agentex/__init__.py +103 -0
  2. agentex/_base_client.py +1992 -0
  3. agentex/_client.py +506 -0
  4. agentex/_compat.py +219 -0
  5. agentex/_constants.py +14 -0
  6. agentex/_exceptions.py +108 -0
  7. agentex/_files.py +123 -0
  8. agentex/_models.py +829 -0
  9. agentex/_qs.py +150 -0
  10. agentex/_resource.py +43 -0
  11. agentex/_response.py +830 -0
  12. agentex/_streaming.py +333 -0
  13. agentex/_types.py +219 -0
  14. agentex/_utils/__init__.py +57 -0
  15. agentex/_utils/_logs.py +25 -0
  16. agentex/_utils/_proxy.py +65 -0
  17. agentex/_utils/_reflection.py +42 -0
  18. agentex/_utils/_resources_proxy.py +24 -0
  19. agentex/_utils/_streams.py +12 -0
  20. agentex/_utils/_sync.py +86 -0
  21. agentex/_utils/_transform.py +447 -0
  22. agentex/_utils/_typing.py +151 -0
  23. agentex/_utils/_utils.py +422 -0
  24. agentex/_version.py +4 -0
  25. agentex/lib/.keep +4 -0
  26. agentex/lib/__init__.py +0 -0
  27. agentex/lib/adk/__init__.py +41 -0
  28. agentex/lib/adk/_modules/__init__.py +0 -0
  29. agentex/lib/adk/_modules/acp.py +247 -0
  30. agentex/lib/adk/_modules/agent_task_tracker.py +176 -0
  31. agentex/lib/adk/_modules/agents.py +77 -0
  32. agentex/lib/adk/_modules/events.py +141 -0
  33. agentex/lib/adk/_modules/messages.py +285 -0
  34. agentex/lib/adk/_modules/state.py +291 -0
  35. agentex/lib/adk/_modules/streaming.py +75 -0
  36. agentex/lib/adk/_modules/tasks.py +124 -0
  37. agentex/lib/adk/_modules/tracing.py +194 -0
  38. agentex/lib/adk/providers/__init__.py +9 -0
  39. agentex/lib/adk/providers/_modules/__init__.py +0 -0
  40. agentex/lib/adk/providers/_modules/litellm.py +232 -0
  41. agentex/lib/adk/providers/_modules/openai.py +416 -0
  42. agentex/lib/adk/providers/_modules/sgp.py +85 -0
  43. agentex/lib/adk/utils/__init__.py +5 -0
  44. agentex/lib/adk/utils/_modules/__init__.py +0 -0
  45. agentex/lib/adk/utils/_modules/templating.py +94 -0
  46. agentex/lib/cli/__init__.py +0 -0
  47. agentex/lib/cli/commands/__init__.py +0 -0
  48. agentex/lib/cli/commands/agents.py +328 -0
  49. agentex/lib/cli/commands/init.py +227 -0
  50. agentex/lib/cli/commands/main.py +33 -0
  51. agentex/lib/cli/commands/secrets.py +169 -0
  52. agentex/lib/cli/commands/tasks.py +118 -0
  53. agentex/lib/cli/commands/uv.py +133 -0
  54. agentex/lib/cli/handlers/__init__.py +0 -0
  55. agentex/lib/cli/handlers/agent_handlers.py +160 -0
  56. agentex/lib/cli/handlers/cleanup_handlers.py +186 -0
  57. agentex/lib/cli/handlers/deploy_handlers.py +351 -0
  58. agentex/lib/cli/handlers/run_handlers.py +452 -0
  59. agentex/lib/cli/handlers/secret_handlers.py +670 -0
  60. agentex/lib/cli/templates/default/.dockerignore.j2 +43 -0
  61. agentex/lib/cli/templates/default/Dockerfile-uv.j2 +42 -0
  62. agentex/lib/cli/templates/default/Dockerfile.j2 +42 -0
  63. agentex/lib/cli/templates/default/README.md.j2 +193 -0
  64. agentex/lib/cli/templates/default/deploy/example.yaml.j2 +55 -0
  65. agentex/lib/cli/templates/default/manifest.yaml.j2 +116 -0
  66. agentex/lib/cli/templates/default/project/acp.py.j2 +29 -0
  67. agentex/lib/cli/templates/default/pyproject.toml.j2 +33 -0
  68. agentex/lib/cli/templates/default/requirements.txt.j2 +5 -0
  69. agentex/lib/cli/templates/deploy/Screenshot 2025-03-19 at 10.36.57/342/200/257AM.png +0 -0
  70. agentex/lib/cli/templates/deploy/example.yaml.j2 +55 -0
  71. agentex/lib/cli/templates/sync/.dockerignore.j2 +43 -0
  72. agentex/lib/cli/templates/sync/Dockerfile-uv.j2 +42 -0
  73. agentex/lib/cli/templates/sync/Dockerfile.j2 +42 -0
  74. agentex/lib/cli/templates/sync/README.md.j2 +293 -0
  75. agentex/lib/cli/templates/sync/deploy/example.yaml.j2 +55 -0
  76. agentex/lib/cli/templates/sync/manifest.yaml.j2 +116 -0
  77. agentex/lib/cli/templates/sync/project/acp.py.j2 +26 -0
  78. agentex/lib/cli/templates/sync/pyproject.toml.j2 +33 -0
  79. agentex/lib/cli/templates/sync/requirements.txt.j2 +5 -0
  80. agentex/lib/cli/templates/temporal/.dockerignore.j2 +43 -0
  81. agentex/lib/cli/templates/temporal/Dockerfile-uv.j2 +48 -0
  82. agentex/lib/cli/templates/temporal/Dockerfile.j2 +48 -0
  83. agentex/lib/cli/templates/temporal/README.md.j2 +316 -0
  84. agentex/lib/cli/templates/temporal/deploy/example.yaml.j2 +55 -0
  85. agentex/lib/cli/templates/temporal/manifest.yaml.j2 +137 -0
  86. agentex/lib/cli/templates/temporal/project/acp.py.j2 +30 -0
  87. agentex/lib/cli/templates/temporal/project/run_worker.py.j2 +33 -0
  88. agentex/lib/cli/templates/temporal/project/workflow.py.j2 +66 -0
  89. agentex/lib/cli/templates/temporal/pyproject.toml.j2 +34 -0
  90. agentex/lib/cli/templates/temporal/requirements.txt.j2 +5 -0
  91. agentex/lib/cli/utils/cli_utils.py +14 -0
  92. agentex/lib/cli/utils/credential_utils.py +103 -0
  93. agentex/lib/cli/utils/exceptions.py +6 -0
  94. agentex/lib/cli/utils/kubectl_utils.py +135 -0
  95. agentex/lib/cli/utils/kubernetes_secrets_utils.py +185 -0
  96. agentex/lib/core/__init__.py +0 -0
  97. agentex/lib/core/adapters/__init__.py +0 -0
  98. agentex/lib/core/adapters/llm/__init__.py +1 -0
  99. agentex/lib/core/adapters/llm/adapter_litellm.py +46 -0
  100. agentex/lib/core/adapters/llm/adapter_sgp.py +55 -0
  101. agentex/lib/core/adapters/llm/port.py +24 -0
  102. agentex/lib/core/adapters/streams/adapter_redis.py +128 -0
  103. agentex/lib/core/adapters/streams/port.py +50 -0
  104. agentex/lib/core/clients/__init__.py +1 -0
  105. agentex/lib/core/clients/temporal/__init__.py +0 -0
  106. agentex/lib/core/clients/temporal/temporal_client.py +181 -0
  107. agentex/lib/core/clients/temporal/types.py +47 -0
  108. agentex/lib/core/clients/temporal/utils.py +56 -0
  109. agentex/lib/core/services/__init__.py +0 -0
  110. agentex/lib/core/services/adk/__init__.py +0 -0
  111. agentex/lib/core/services/adk/acp/__init__.py +0 -0
  112. agentex/lib/core/services/adk/acp/acp.py +210 -0
  113. agentex/lib/core/services/adk/agent_task_tracker.py +85 -0
  114. agentex/lib/core/services/adk/agents.py +43 -0
  115. agentex/lib/core/services/adk/events.py +61 -0
  116. agentex/lib/core/services/adk/messages.py +164 -0
  117. agentex/lib/core/services/adk/providers/__init__.py +0 -0
  118. agentex/lib/core/services/adk/providers/litellm.py +256 -0
  119. agentex/lib/core/services/adk/providers/openai.py +723 -0
  120. agentex/lib/core/services/adk/providers/sgp.py +99 -0
  121. agentex/lib/core/services/adk/state.py +120 -0
  122. agentex/lib/core/services/adk/streaming.py +262 -0
  123. agentex/lib/core/services/adk/tasks.py +69 -0
  124. agentex/lib/core/services/adk/tracing.py +36 -0
  125. agentex/lib/core/services/adk/utils/__init__.py +0 -0
  126. agentex/lib/core/services/adk/utils/templating.py +58 -0
  127. agentex/lib/core/temporal/__init__.py +0 -0
  128. agentex/lib/core/temporal/activities/__init__.py +207 -0
  129. agentex/lib/core/temporal/activities/activity_helpers.py +37 -0
  130. agentex/lib/core/temporal/activities/adk/__init__.py +0 -0
  131. agentex/lib/core/temporal/activities/adk/acp/__init__.py +0 -0
  132. agentex/lib/core/temporal/activities/adk/acp/acp_activities.py +86 -0
  133. agentex/lib/core/temporal/activities/adk/agent_task_tracker_activities.py +76 -0
  134. agentex/lib/core/temporal/activities/adk/agents_activities.py +35 -0
  135. agentex/lib/core/temporal/activities/adk/events_activities.py +50 -0
  136. agentex/lib/core/temporal/activities/adk/messages_activities.py +94 -0
  137. agentex/lib/core/temporal/activities/adk/providers/__init__.py +0 -0
  138. agentex/lib/core/temporal/activities/adk/providers/litellm_activities.py +71 -0
  139. agentex/lib/core/temporal/activities/adk/providers/openai_activities.py +210 -0
  140. agentex/lib/core/temporal/activities/adk/providers/sgp_activities.py +42 -0
  141. agentex/lib/core/temporal/activities/adk/state_activities.py +85 -0
  142. agentex/lib/core/temporal/activities/adk/streaming_activities.py +33 -0
  143. agentex/lib/core/temporal/activities/adk/tasks_activities.py +48 -0
  144. agentex/lib/core/temporal/activities/adk/tracing_activities.py +55 -0
  145. agentex/lib/core/temporal/activities/adk/utils/__init__.py +0 -0
  146. agentex/lib/core/temporal/activities/adk/utils/templating_activities.py +41 -0
  147. agentex/lib/core/temporal/services/__init__.py +0 -0
  148. agentex/lib/core/temporal/services/temporal_task_service.py +69 -0
  149. agentex/lib/core/temporal/types/__init__.py +0 -0
  150. agentex/lib/core/temporal/types/workflow.py +5 -0
  151. agentex/lib/core/temporal/workers/__init__.py +0 -0
  152. agentex/lib/core/temporal/workers/worker.py +162 -0
  153. agentex/lib/core/temporal/workflows/workflow.py +26 -0
  154. agentex/lib/core/tracing/__init__.py +5 -0
  155. agentex/lib/core/tracing/processors/agentex_tracing_processor.py +117 -0
  156. agentex/lib/core/tracing/processors/sgp_tracing_processor.py +119 -0
  157. agentex/lib/core/tracing/processors/tracing_processor_interface.py +40 -0
  158. agentex/lib/core/tracing/trace.py +311 -0
  159. agentex/lib/core/tracing/tracer.py +70 -0
  160. agentex/lib/core/tracing/tracing_processor_manager.py +62 -0
  161. agentex/lib/environment_variables.py +87 -0
  162. agentex/lib/py.typed +0 -0
  163. agentex/lib/sdk/__init__.py +0 -0
  164. agentex/lib/sdk/config/__init__.py +0 -0
  165. agentex/lib/sdk/config/agent_config.py +61 -0
  166. agentex/lib/sdk/config/agent_manifest.py +219 -0
  167. agentex/lib/sdk/config/build_config.py +35 -0
  168. agentex/lib/sdk/config/deployment_config.py +117 -0
  169. agentex/lib/sdk/config/local_development_config.py +56 -0
  170. agentex/lib/sdk/config/project_config.py +103 -0
  171. agentex/lib/sdk/fastacp/__init__.py +3 -0
  172. agentex/lib/sdk/fastacp/base/base_acp_server.py +406 -0
  173. agentex/lib/sdk/fastacp/fastacp.py +74 -0
  174. agentex/lib/sdk/fastacp/impl/agentic_base_acp.py +72 -0
  175. agentex/lib/sdk/fastacp/impl/sync_acp.py +109 -0
  176. agentex/lib/sdk/fastacp/impl/temporal_acp.py +97 -0
  177. agentex/lib/sdk/fastacp/tests/README.md +297 -0
  178. agentex/lib/sdk/fastacp/tests/conftest.py +307 -0
  179. agentex/lib/sdk/fastacp/tests/pytest.ini +10 -0
  180. agentex/lib/sdk/fastacp/tests/run_tests.py +227 -0
  181. agentex/lib/sdk/fastacp/tests/test_base_acp_server.py +450 -0
  182. agentex/lib/sdk/fastacp/tests/test_fastacp_factory.py +344 -0
  183. agentex/lib/sdk/fastacp/tests/test_integration.py +477 -0
  184. agentex/lib/sdk/state_machine/__init__.py +6 -0
  185. agentex/lib/sdk/state_machine/noop_workflow.py +21 -0
  186. agentex/lib/sdk/state_machine/state.py +10 -0
  187. agentex/lib/sdk/state_machine/state_machine.py +189 -0
  188. agentex/lib/sdk/state_machine/state_workflow.py +16 -0
  189. agentex/lib/sdk/utils/__init__.py +0 -0
  190. agentex/lib/sdk/utils/messages.py +223 -0
  191. agentex/lib/types/__init__.py +0 -0
  192. agentex/lib/types/acp.py +94 -0
  193. agentex/lib/types/agent_configs.py +79 -0
  194. agentex/lib/types/agent_results.py +29 -0
  195. agentex/lib/types/credentials.py +34 -0
  196. agentex/lib/types/fastacp.py +61 -0
  197. agentex/lib/types/files.py +13 -0
  198. agentex/lib/types/json_rpc.py +49 -0
  199. agentex/lib/types/llm_messages.py +354 -0
  200. agentex/lib/types/task_message_updates.py +171 -0
  201. agentex/lib/types/tracing.py +34 -0
  202. agentex/lib/utils/__init__.py +0 -0
  203. agentex/lib/utils/completions.py +131 -0
  204. agentex/lib/utils/console.py +14 -0
  205. agentex/lib/utils/io.py +29 -0
  206. agentex/lib/utils/iterables.py +14 -0
  207. agentex/lib/utils/json_schema.py +23 -0
  208. agentex/lib/utils/logging.py +31 -0
  209. agentex/lib/utils/mcp.py +17 -0
  210. agentex/lib/utils/model_utils.py +46 -0
  211. agentex/lib/utils/parsing.py +15 -0
  212. agentex/lib/utils/regex.py +6 -0
  213. agentex/lib/utils/temporal.py +13 -0
  214. agentex/py.typed +0 -0
  215. agentex/resources/__init__.py +103 -0
  216. agentex/resources/agents.py +707 -0
  217. agentex/resources/events.py +294 -0
  218. agentex/resources/messages/__init__.py +33 -0
  219. agentex/resources/messages/batch.py +271 -0
  220. agentex/resources/messages/messages.py +492 -0
  221. agentex/resources/spans.py +557 -0
  222. agentex/resources/states.py +544 -0
  223. agentex/resources/tasks.py +615 -0
  224. agentex/resources/tracker.py +384 -0
  225. agentex/types/__init__.py +56 -0
  226. agentex/types/acp_type.py +7 -0
  227. agentex/types/agent.py +29 -0
  228. agentex/types/agent_list_params.py +13 -0
  229. agentex/types/agent_list_response.py +10 -0
  230. agentex/types/agent_rpc_by_name_params.py +21 -0
  231. agentex/types/agent_rpc_params.py +51 -0
  232. agentex/types/agent_rpc_params1.py +21 -0
  233. agentex/types/agent_rpc_response.py +20 -0
  234. agentex/types/agent_rpc_result.py +90 -0
  235. agentex/types/agent_task_tracker.py +34 -0
  236. agentex/types/data_content.py +30 -0
  237. agentex/types/data_content_param.py +31 -0
  238. agentex/types/data_delta.py +14 -0
  239. agentex/types/event.py +29 -0
  240. agentex/types/event_list_params.py +22 -0
  241. agentex/types/event_list_response.py +10 -0
  242. agentex/types/message_author.py +7 -0
  243. agentex/types/message_create_params.py +18 -0
  244. agentex/types/message_list_params.py +14 -0
  245. agentex/types/message_list_response.py +10 -0
  246. agentex/types/message_style.py +7 -0
  247. agentex/types/message_update_params.py +18 -0
  248. agentex/types/messages/__init__.py +8 -0
  249. agentex/types/messages/batch_create_params.py +16 -0
  250. agentex/types/messages/batch_create_response.py +10 -0
  251. agentex/types/messages/batch_update_params.py +16 -0
  252. agentex/types/messages/batch_update_response.py +10 -0
  253. agentex/types/shared/__init__.py +3 -0
  254. agentex/types/shared/task_message_update.py +83 -0
  255. agentex/types/span.py +36 -0
  256. agentex/types/span_create_params.py +40 -0
  257. agentex/types/span_list_params.py +12 -0
  258. agentex/types/span_list_response.py +10 -0
  259. agentex/types/span_update_params.py +37 -0
  260. agentex/types/state.py +25 -0
  261. agentex/types/state_create_params.py +16 -0
  262. agentex/types/state_list_params.py +16 -0
  263. agentex/types/state_list_response.py +10 -0
  264. agentex/types/state_update_params.py +16 -0
  265. agentex/types/task.py +23 -0
  266. agentex/types/task_delete_by_name_response.py +8 -0
  267. agentex/types/task_delete_response.py +8 -0
  268. agentex/types/task_list_response.py +10 -0
  269. agentex/types/task_message.py +33 -0
  270. agentex/types/task_message_content.py +16 -0
  271. agentex/types/task_message_content_param.py +17 -0
  272. agentex/types/task_message_delta.py +16 -0
  273. agentex/types/text_content.py +53 -0
  274. agentex/types/text_content_param.py +54 -0
  275. agentex/types/text_delta.py +14 -0
  276. agentex/types/tool_request_content.py +36 -0
  277. agentex/types/tool_request_content_param.py +37 -0
  278. agentex/types/tool_request_delta.py +18 -0
  279. agentex/types/tool_response_content.py +36 -0
  280. agentex/types/tool_response_content_param.py +36 -0
  281. agentex/types/tool_response_delta.py +18 -0
  282. agentex/types/tracker_list_params.py +16 -0
  283. agentex/types/tracker_list_response.py +10 -0
  284. agentex/types/tracker_update_params.py +19 -0
  285. agentex_sdk-0.1.0a6.dist-info/METADATA +426 -0
  286. agentex_sdk-0.1.0a6.dist-info/RECORD +289 -0
  287. agentex_sdk-0.1.0a6.dist-info/WHEEL +4 -0
  288. agentex_sdk-0.1.0a6.dist-info/entry_points.txt +2 -0
  289. agentex_sdk-0.1.0a6.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,48 @@
1
+ # syntax=docker/dockerfile:1.3
2
+ FROM python:3.12-slim
3
+ COPY --from=ghcr.io/astral-sh/uv:0.6.4 /uv /uvx /bin/
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ htop \
8
+ vim \
9
+ curl \
10
+ tar \
11
+ python3-dev \
12
+ postgresql-client \
13
+ build-essential \
14
+ libpq-dev \
15
+ gcc \
16
+ cmake \
17
+ netcat-openbsd \
18
+ && apt-get clean \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Install tctl (Temporal CLI)
22
+ RUN curl -L https://github.com/temporalio/tctl/releases/download/v1.18.1/tctl_1.18.1_linux_arm64.tar.gz -o /tmp/tctl.tar.gz && \
23
+ tar -xzf /tmp/tctl.tar.gz -C /usr/local/bin && \
24
+ chmod +x /usr/local/bin/tctl && \
25
+ rm /tmp/tctl.tar.gz
26
+
27
+ RUN uv pip install --system --upgrade pip setuptools wheel
28
+
29
+ ENV UV_HTTP_TIMEOUT=1000
30
+
31
+ # Copy just the requirements file to optimize caching
32
+ COPY {{ project_path_from_build_root }}/requirements.txt /app/{{ project_path_from_build_root }}/requirements.txt
33
+
34
+ WORKDIR /app/{{ project_path_from_build_root }}
35
+
36
+ # Install the required Python packages
37
+ RUN uv pip install --system -r requirements.txt
38
+
39
+ # Copy the project code
40
+ COPY {{ project_path_from_build_root }}/project /app/{{ project_path_from_build_root }}/project
41
+
42
+ WORKDIR /app/{{ project_path_from_build_root }}/project
43
+
44
+ # Run the ACP server using uvicorn
45
+ CMD ["uvicorn", "acp:acp", "--host", "0.0.0.0", "--port", "8000"]
46
+
47
+ # When we deploy the worker, we will replace the CMD with the following
48
+ # CMD ["python", "-m", "run_worker"]
@@ -0,0 +1,316 @@
1
+ # {{ agent_name }} - AgentEx Temporal Agent Template
2
+
3
+ This is a starter template for building asynchronous agents with the AgentEx framework and Temporal. It provides a basic implementation of the Agent 2 Client Protocol (ACP) with Temporal workflow support to help you get started quickly.
4
+
5
+ ## What You'll Learn
6
+
7
+ - **Tasks**: A task is a grouping mechanism for related messages. Think of it as a conversation thread or a session.
8
+ - **Messages**: Messages are communication objects within a task. They can contain text, data, or instructions.
9
+ - **ACP Events**: The agent responds to four main events:
10
+ - `task_received`: When a new task is created
11
+ - `task_message_received`: When a message is sent within a task
12
+ - `task_approved`: When a task is approved
13
+ - `task_canceled`: When a task is canceled
14
+ - **Temporal Workflows**: Long-running processes that can handle complex state management and async operations
15
+
16
+ ## Running the Agent
17
+
18
+ 1. Run the agent locally:
19
+ ```bash
20
+ agentex agents run --manifest manifest.yaml
21
+ ```
22
+
23
+ The agent will start on port 8000 and print messages whenever it receives any of the ACP events.
24
+
25
+ ## What's Inside
26
+
27
+ This template:
28
+ - Sets up a basic ACP server with Temporal integration
29
+ - Handles each of the required ACP events
30
+ - Provides a foundation for building complex async agents
31
+ - Includes Temporal workflow and activity definitions
32
+
33
+ ## Next Steps
34
+
35
+ For more advanced agent development, check out the AgentEx tutorials:
36
+
37
+ - **Tutorials 00-08**: Learn about building synchronous agents with ACP
38
+ - **Tutorials 09-10**: Learn how to use Temporal to power asynchronous agents
39
+ - Tutorial 09: Basic Temporal workflow setup
40
+ - Tutorial 10: Advanced Temporal patterns and best practices
41
+
42
+ These tutorials will help you understand:
43
+ - How to handle long-running tasks
44
+ - Implementing state machines
45
+ - Managing complex workflows
46
+ - Best practices for async agent development
47
+
48
+ ## The Manifest File
49
+
50
+ The `manifest.yaml` file is your agent's configuration file. It defines:
51
+ - How your agent should be built and packaged
52
+ - What files are included in your agent's Docker image
53
+ - Your agent's name and description
54
+ - Local development settings (like the port your agent runs on)
55
+ - Temporal worker configuration
56
+
57
+ This file is essential for both local development and deployment of your agent.
58
+
59
+ ## Project Structure
60
+
61
+ ```
62
+ {{ project_name }}/
63
+ ├── project/ # Your agent's code
64
+ │ ├── __init__.py
65
+ │ ├── acp.py # ACP server and event handlers
66
+ │ ├── workflow.py # Temporal workflow definitions
67
+ │ ├── activities.py # Temporal activity definitions
68
+ │ └── run_worker.py # Temporal worker setup
69
+ ├── Dockerfile # Container definition
70
+ ├── manifest.yaml # Deployment config
71
+ {% if use_uv %}
72
+ └── pyproject.toml # Dependencies (uv)
73
+ {% else %}
74
+ └── requirements.txt # Dependencies (pip)
75
+ {% endif %}
76
+ ```
77
+
78
+ ## Development
79
+
80
+ ### 1. Customize Event Handlers
81
+ - Modify the handlers in `acp.py` to implement your agent's logic
82
+ - Add your own tools and capabilities
83
+ - Implement custom state management
84
+
85
+ ### 2. Develop Temporal Workflows
86
+ - Edit `workflow.py` to define your agent's async workflow logic
87
+ - Modify `activities.py` to add custom activities
88
+ - Use `run_worker.py` to configure the Temporal worker
89
+
90
+ ### 3. Manage Dependencies
91
+
92
+ {% if use_uv %}
93
+ You chose **uv** for package management. Here's how to work with dependencies:
94
+
95
+ ```bash
96
+ # Add new dependencies
97
+ agentex uv add requests openai anthropic
98
+
99
+ # Add Temporal-specific dependencies (already included)
100
+ agentex uv add temporalio
101
+
102
+ # Install/sync dependencies
103
+ agentex uv sync
104
+
105
+ # Run commands with uv
106
+ uv run agentex agents run --manifest manifest.yaml
107
+ ```
108
+
109
+ **Benefits of uv:**
110
+ - Faster dependency resolution and installation
111
+ - Better dependency isolation
112
+ - Modern Python packaging standards
113
+
114
+ {% else %}
115
+ You chose **pip** for package management. Here's how to work with dependencies:
116
+
117
+ ```bash
118
+ # Probably create a conda env for your agent.
119
+ # Optionally add agentex-sdk editable installation
120
+
121
+ # Edit requirements.txt manually to add dependencies
122
+ echo "requests" >> requirements.txt
123
+ echo "openai" >> requirements.txt
124
+
125
+ # Temporal dependencies are already included
126
+ # temporalio is already in requirements.txt
127
+
128
+ # Install dependencies
129
+ pip install -r requirements.txt
130
+ ```
131
+
132
+ **Benefits of pip:**
133
+ - Familiar workflow for most Python developers
134
+ - Simple requirements.txt management
135
+ - Wide compatibility
136
+ {% endif %}
137
+
138
+ ### 4. Configure Credentials
139
+ - Add any required credentials to your manifest.yaml
140
+ - For local development, create a `.env` file in the project directory
141
+ - Use `load_dotenv()` only in development mode:
142
+
143
+ ```python
144
+ import os
145
+ from dotenv import load_dotenv
146
+
147
+ if os.environ.get("ENVIRONMENT") == "development":
148
+ load_dotenv()
149
+ ```
150
+
151
+ ## Local Development
152
+
153
+ ### 1. Start the Agentex Backend
154
+ ```bash
155
+ # Navigate to the backend directory
156
+ cd agentex
157
+
158
+ # Start all services using Docker Compose
159
+ make dev
160
+
161
+ # Optional: In a separate terminal, use lazydocker for a better UI (everything should say "healthy")
162
+ lzd
163
+ ```
164
+
165
+ ### 2. Setup Your Agent's requirements/pyproject.toml
166
+ ```bash
167
+ agentex uv sync [--group editable-apy]
168
+ source .venv/bin/activate
169
+
170
+ # OR
171
+ conda create -n {{ project_name }} python=3.12
172
+ conda activate {{ project_name }}
173
+ pip install -r requirements.txt
174
+ ```
175
+ ### 3. Run Your Agent
176
+ ```bash
177
+ # From this directory
178
+ export ENVIRONMENT=development && [uv run] agentex agents run --manifest manifest.yaml
179
+ ```
180
+ 4. **Interact with your agent**
181
+
182
+ Option 0: CLI (deprecated - to be replaced once a new CLI is implemented - please use the web UI for now!)
183
+ ```bash
184
+ # Submit a task via CLI
185
+ agentex tasks submit --agent {{ agent_name }} --task "Your task here"
186
+ ```
187
+
188
+ Option 1: Web UI
189
+ ```bash
190
+ # Start the local web interface
191
+ cd agentex-web
192
+ make dev
193
+
194
+ # Then open http://localhost:3000 in your browser to chat with your agent
195
+ ```
196
+
197
+ ## Development Tips
198
+
199
+ ### Environment Variables
200
+ - Set environment variables in project/.env for any required credentials
201
+ - Or configure them in the manifest.yaml under the `env` section
202
+ - The `.env` file is automatically loaded in development mode
203
+
204
+ ### Local Testing
205
+ - Use `export ENVIRONMENT=development` before running your agent
206
+ - This enables local service discovery and debugging features
207
+ - Your agent will automatically connect to locally running services
208
+
209
+ ### Temporal-Specific Tips
210
+ - Monitor workflows in the Temporal Web UI at http://localhost:8080
211
+ - Use the Temporal CLI for advanced workflow management
212
+ - Check workflow logs for debugging async operations
213
+
214
+ ### Debugging
215
+ - Check agent logs in the terminal where you ran the agent
216
+ - Use the web UI to inspect task history and responses
217
+ - Monitor backend services with `lzd` (LazyDocker)
218
+ - Use Temporal Web UI for workflow debugging
219
+
220
+ ### To build the agent Docker image locally (normally not necessary):
221
+
222
+ 1. Build the agent image:
223
+ ```bash
224
+ agentex agents build --manifest manifest.yaml
225
+ ```
226
+
227
+ ## Advanced Features
228
+
229
+ ### Temporal Workflows
230
+ Extend your agent with sophisticated async workflows:
231
+
232
+ ```python
233
+ # In project/workflow.py
234
+ @workflow.defn
235
+ class MyWorkflow(BaseWorkflow):
236
+ async def complex_operation(self):
237
+ # Multi-step async operations
238
+ # Error handling and retries
239
+ # State management
240
+ pass
241
+ ```
242
+
243
+ ### Custom Activities
244
+ Add custom activities for external operations:
245
+
246
+ ```python
247
+ # In project/activities.py
248
+ @activity.defn
249
+ async def call_external_api(data):
250
+ # HTTP requests, database operations, etc.
251
+ pass
252
+ ```
253
+
254
+ ### Integration with External Services
255
+ {% if use_uv %}
256
+ ```bash
257
+ # Add service clients
258
+ agentex uv add httpx requests-oauthlib
259
+
260
+ # Add AI/ML libraries
261
+ agentex uv add openai anthropic transformers
262
+
263
+ # Add database clients
264
+ agentex uv add asyncpg redis
265
+ ```
266
+ {% else %}
267
+ ```bash
268
+ # Add to requirements.txt
269
+ echo "httpx" >> requirements.txt
270
+ echo "openai" >> requirements.txt
271
+ echo "asyncpg" >> requirements.txt
272
+ pip install -r requirements.txt
273
+ ```
274
+ {% endif %}
275
+
276
+ ## Troubleshooting
277
+
278
+ ### Common Issues
279
+
280
+ 1. **Agent not appearing in web UI**
281
+ - Check if agent is running on port 8000
282
+ - Verify `ENVIRONMENT=development` is set
283
+ - Check agent logs for errors
284
+
285
+ 2. **Temporal workflow issues**
286
+ - Check Temporal Web UI at http://localhost:8080
287
+ - Verify Temporal server is running in backend services
288
+ - Check workflow logs for specific errors
289
+
290
+ 3. **Dependency issues**
291
+ {% if use_uv %}
292
+ - Run `agentex uv sync` to ensure all dependencies are installed
293
+ - Verify temporalio is properly installed
294
+ {% else %}
295
+ - Run `pip install -r requirements.txt`
296
+ - Check if all dependencies are correctly listed in requirements.txt
297
+ - Verify temporalio is installed correctly
298
+ {% endif %}
299
+
300
+ 4. **Port conflicts**
301
+ - Check if another service is using port 8000
302
+ - Use `lsof -i :8000` to find conflicting processes
303
+
304
+ ### Temporal-Specific Troubleshooting
305
+
306
+ 1. **Workflow not starting**
307
+ - Check if Temporal server is running (`docker ps`)
308
+ - Verify task queue configuration in `run_worker.py`
309
+ - Check workflow registration in the worker
310
+
311
+ 2. **Activity failures**
312
+ - Check activity logs in the console
313
+ - Verify activity registration
314
+ - Check for timeout issues
315
+
316
+ Happy building with Temporal! 🚀⚡
@@ -0,0 +1,55 @@
1
+ # Example Override Configuration
2
+ # =============================
3
+ # This file shows how to override deployment settings from the global defaults in manifest.yaml.
4
+ # You can create multiple override files for different environments (e.g., staging.yaml, prod.yaml, dev.yaml)
5
+ # Only specify values that differ from the global defaults in manifest.yaml
6
+
7
+ # Override image tag
8
+ # image:
9
+ # tag: "v1.2.3"
10
+
11
+ # Override replica count
12
+ # replicaCount: 2
13
+
14
+ # Environment-specific environment variables
15
+ # env:
16
+ # - name: LOG_LEVEL
17
+ # value: "DEBUG"
18
+ # - name: ENVIRONMENT
19
+ # value: "staging"
20
+
21
+ # Override resource requirements
22
+ # resources:
23
+ # requests:
24
+ # cpu: "250m"
25
+ # memory: "512Mi"
26
+ # limits:
27
+ # cpu: "500m"
28
+ # memory: "1Gi"
29
+
30
+ # Advanced: Additional helm chart value overrides
31
+ # Use this for any helm chart values not covered by the simple options above
32
+ # additional_overrides:
33
+ # autoscaling:
34
+ # enabled: true
35
+ # minReplicas: 2
36
+ # maxReplicas: 10
37
+ # targetCPUUtilizationPercentage: 70
38
+ #
39
+ # service:
40
+ # type: LoadBalancer
41
+ #
42
+ # ingress:
43
+ # enabled: true
44
+ # annotations:
45
+ # kubernetes.io/ingress.class: "nginx"
46
+ # hosts:
47
+ # - host: {{ agent_name }}.example.com
48
+ # paths:
49
+ # - path: /
50
+ # pathType: Prefix
51
+
52
+ # To use this configuration:
53
+ # 1. Copy this file to a new file (e.g., staging.yaml, prod.yaml)
54
+ # 2. Uncomment and modify the values you want to override
55
+ # 3. Deploy with: agentex agents deploy --cluster your-cluster --namespace your-namespace --override-file staging.yaml
@@ -0,0 +1,137 @@
1
+ # Agent Manifest Configuration
2
+ # ---------------------------
3
+ # This file defines how your agent should be built and deployed.
4
+
5
+ # Build Configuration
6
+ # ------------------
7
+ # The build config defines what gets packaged into your agent's Docker image.
8
+ # This same configuration is used whether building locally or remotely.
9
+ #
10
+ # When building:
11
+ # 1. All files from include_paths are collected into a build context
12
+ # 2. The context is filtered by dockerignore rules
13
+ # 3. The Dockerfile uses this context to build your agent's image
14
+ # 4. The image is pushed to a registry and used to run your agent
15
+ build:
16
+ context:
17
+ # Root directory for the build context
18
+ root: ../ # Keep this as the default root
19
+
20
+ # Paths to include in the Docker build context
21
+ # Must include:
22
+ # - Your agent's directory (your custom agent code)
23
+ # These paths are collected and sent to the Docker daemon for building
24
+ include_paths:
25
+ - {{ project_path_from_build_root }}
26
+
27
+ # Path to your agent's Dockerfile
28
+ # This defines how your agent's image is built from the context
29
+ # Relative to the root directory
30
+ dockerfile: {{ project_path_from_build_root }}/Dockerfile
31
+
32
+ # Path to your agent's .dockerignore
33
+ # Filters unnecessary files from the build context
34
+ # Helps keep build context small and builds fast
35
+ dockerignore: {{ project_path_from_build_root }}/.dockerignore
36
+
37
+
38
+ # Local Development Configuration
39
+ # -----------------------------
40
+ # Only used when running the agent locally
41
+ local_development:
42
+ agent:
43
+ port: 8000 # Port where your local ACP server is running
44
+ host_address: host.docker.internal # Host address for Docker networking (host.docker.internal for Docker, localhost for direct)
45
+
46
+ # File paths for local development (relative to this manifest.yaml)
47
+ paths:
48
+ # Path to ACP server file
49
+ # Examples:
50
+ # project/acp.py (standard)
51
+ # src/server.py (custom structure)
52
+ # ../shared/acp.py (shared across projects)
53
+ # /absolute/path/acp.py (absolute path)
54
+ acp: project/acp.py
55
+
56
+ # Path to temporal worker file
57
+ # Examples:
58
+ # project/run_worker.py (standard)
59
+ # workers/temporal.py (custom structure)
60
+ # ../shared/worker.py (shared across projects)
61
+ worker: project/run_worker.py
62
+
63
+
64
+ # Agent Configuration
65
+ # -----------------
66
+ agent:
67
+ # Type of agent - either sync or agentic
68
+ acp_type: agentic
69
+
70
+ # Unique name for your agent
71
+ # Used for task routing and monitoring
72
+ name: {{ agent_name }}
73
+
74
+ # Description of what your agent does
75
+ # Helps with documentation and discovery
76
+ description: {{ description }}
77
+
78
+ # Temporal workflow configuration
79
+ # This enables your agent to run as a Temporal workflow for long-running tasks
80
+ temporal:
81
+ enabled: true
82
+ workflows:
83
+ # Name of the workflow class
84
+ # Must match the @workflow.defn name in your workflow.py
85
+ - name: {{ workflow_name }}
86
+
87
+ # Queue name for task distribution
88
+ # Used by Temporal to route tasks to your agent
89
+ # Convention: <agent_name>_task_queue
90
+ queue_name: {{ queue_name }}
91
+
92
+ # Optional: Credentials mapping
93
+ # Maps Kubernetes secrets to environment variables
94
+ # Common credentials include:
95
+ # credentials:
96
+ # - env_var_name: OPENAI_API_KEY
97
+ # secret_name: openai-api-key
98
+ # secret_key: api-key
99
+
100
+ # Optional: Set Environment variables for running your agent locally as well
101
+ # as for deployment later on
102
+ # env:
103
+ # OPENAI_API_KEY: "<YOUR_OPENAI_API_KEY_HERE>"
104
+ # OPENAI_BASE_URL: "<YOUR_OPENAI_BASE_URL_HERE>"
105
+ # OPENAI_ORG_ID: "<YOUR_OPENAI_ORG_ID_HERE>"
106
+
107
+
108
+ # Deployment Configuration
109
+ # -----------------------
110
+ # Configuration for deploying your agent to Kubernetes clusters
111
+ deployment:
112
+ # Container image configuration
113
+ image:
114
+ repository: "" # Update with your container registry
115
+ tag: "latest" # Default tag, should be versioned in production
116
+
117
+ imagePullSecrets:
118
+ - name: my-registry-secret # Update with your image pull secret name
119
+
120
+ # Global deployment settings that apply to all clusters
121
+ # These can be overridden using --override-file with custom configuration files
122
+ global:
123
+ agent:
124
+ name: "{{ agent_name }}"
125
+ description: "{{ description }}"
126
+
127
+ # Default replica count
128
+ replicaCount: 1
129
+
130
+ # Default resource requirements
131
+ resources:
132
+ requests:
133
+ cpu: "500m"
134
+ memory: "1Gi"
135
+ limits:
136
+ cpu: "1000m"
137
+ memory: "2Gi"
@@ -0,0 +1,30 @@
1
+ import os
2
+ from agentex.lib.sdk.fastacp.fastacp import FastACP
3
+ from agentex.lib.types.fastacp import TemporalACPConfig
4
+
5
+
6
+ # Create the ACP server
7
+ acp = FastACP.create(
8
+ acp_type="agentic",
9
+ config=TemporalACPConfig(
10
+ # When deployed to the cluster, the Temporal address will automatically be set to the cluster address
11
+ # For local development, we set the address manually to talk to the local Temporal service set up via docker compose
12
+ type="temporal",
13
+ temporal_address=os.getenv("TEMPORAL_ADDRESS", "localhost:7233")
14
+ )
15
+ )
16
+
17
+
18
+ # Notice that we don't need to register any handlers when we use type="temporal"
19
+ # If you look at the code in agentex.sdk.fastacp.impl.temporal_acp
20
+ # You can see that these handlers are automatically registered when the ACP is created
21
+
22
+ # @acp.on_task_create
23
+ # This will be handled by the method in your workflow that is decorated with @workflow.run
24
+
25
+ # @acp.on_task_event_send
26
+ # This will be handled by the method in your workflow that is decorated with @workflow.signal(name=SignalName.RECEIVE_MESSAGE)
27
+
28
+ # @acp.on_task_cancel
29
+ # This does not need to be handled by your workflow.
30
+ # It is automatically handled by the temporal client which cancels the workflow directly
@@ -0,0 +1,33 @@
1
+ import asyncio
2
+ import os
3
+
4
+ from agentex.lib.core.temporal.activities import get_all_activities
5
+ from agentex.lib.core.temporal.workers.worker import AgentexWorker
6
+ from agentex.lib.utils.logging import make_logger
7
+ from agentex.lib.environment_variables import EnvironmentVariables
8
+
9
+ from workflow import {{ workflow_class }}
10
+
11
+
12
+ environment_variables = EnvironmentVariables.refresh()
13
+
14
+ logger = make_logger(__name__)
15
+
16
+
17
+ async def main():
18
+ task_queue_name = environment_variables.WORKFLOW_TASK_QUEUE
19
+ if task_queue_name is None:
20
+ raise ValueError("WORKFLOW_TASK_QUEUE is not set")
21
+
22
+ # Create a worker with automatic tracing
23
+ worker = AgentexWorker(
24
+ task_queue=task_queue_name,
25
+ )
26
+
27
+ await worker.run(
28
+ activities=get_all_activities(),
29
+ workflow={{ workflow_class }},
30
+ )
31
+
32
+ if __name__ == "__main__":
33
+ asyncio.run(main())
@@ -0,0 +1,66 @@
1
+ import json
2
+
3
+ from temporalio import workflow
4
+
5
+ from agentex.lib import adk
6
+ from agentex.lib.types.acp import CreateTaskParams, SendEventParams
7
+ from agentex.lib.core.temporal.workflows.workflow import BaseWorkflow
8
+ from agentex.lib.core.temporal.types.workflow import SignalName
9
+ from agentex.lib.utils.logging import make_logger
10
+ from agentex.types.task_message import TextContent
11
+ from agentex.lib.environment_variables import EnvironmentVariables
12
+
13
+ environment_variables = EnvironmentVariables.refresh()
14
+
15
+ if environment_variables.WORKFLOW_NAME is None:
16
+ raise ValueError("Environment variable WORKFLOW_NAME is not set")
17
+
18
+ if environment_variables.AGENT_NAME is None:
19
+ raise ValueError("Environment variable AGENT_NAME is not set")
20
+
21
+ logger = make_logger(__name__)
22
+
23
+ @workflow.defn(name=environment_variables.WORKFLOW_NAME)
24
+ class {{ workflow_class }}(BaseWorkflow):
25
+ """
26
+ Minimal async workflow template for AgentEx Temporal agents.
27
+ """
28
+ def __init__(self):
29
+ super().__init__(display_name=environment_variables.AGENT_NAME)
30
+ self._complete_task = False
31
+
32
+ @workflow.signal(name=SignalName.RECEIVE_EVENT)
33
+ async def on_task_event_send(self, params: SendEventParams) -> None:
34
+ logger.info(f"Received task message instruction: {params}")
35
+
36
+ # 2. Echo back the client's message to show it in the UI. This is not done by default so the agent developer has full control over what is shown to the user.
37
+ await adk.messages.create(task_id=params.task.id, content=params.event.content)
38
+
39
+ # 3. Send a simple response message.
40
+ # In future tutorials, this is where we'll add more sophisticated response logic.
41
+ await adk.messages.create(
42
+ task_id=params.task.id,
43
+ content=TextContent(
44
+ author="agent",
45
+ content=f"Hello! I've received your message. I can't respond right now, but in future tutorials we'll see how you can get me to intelligently respond to your message.",
46
+ ),
47
+ )
48
+
49
+ @workflow.run
50
+ async def on_task_create(self, params: CreateTaskParams) -> str:
51
+ logger.info(f"Received task create params: {params}")
52
+
53
+ # 1. Acknowledge that the task has been created.
54
+ await adk.messages.create(
55
+ task_id=params.task.id,
56
+ content=TextContent(
57
+ author="agent",
58
+ content=f"Hello! I've received your task. Normally you can do some state initialization here, or just pass and do nothing until you get your first event. For now I'm just acknowledging that I've received a task with the following params:\n\n{json.dumps(params.params, indent=2)}.\n\nYou should only see this message once, when the task is created. All subsequent events will be handled by the `on_task_event_send` handler.",
59
+ ),
60
+ )
61
+
62
+ await workflow.wait_condition(
63
+ lambda: self._complete_task,
64
+ timeout=None, # Set a timeout if you want to prevent the task from running indefinitely. Generally this is not needed. Temporal can run hundreds of millions of workflows in parallel and more. Only do this if you have a specific reason to do so.
65
+ )
66
+ return "Task completed"