agentex-sdk 0.1.0__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.
- agentex/__init__.py +103 -0
- agentex/_base_client.py +1992 -0
- agentex/_client.py +506 -0
- agentex/_compat.py +219 -0
- agentex/_constants.py +14 -0
- agentex/_exceptions.py +108 -0
- agentex/_files.py +123 -0
- agentex/_models.py +829 -0
- agentex/_qs.py +150 -0
- agentex/_resource.py +43 -0
- agentex/_response.py +830 -0
- agentex/_streaming.py +333 -0
- agentex/_types.py +219 -0
- agentex/_utils/__init__.py +57 -0
- agentex/_utils/_logs.py +25 -0
- agentex/_utils/_proxy.py +65 -0
- agentex/_utils/_reflection.py +42 -0
- agentex/_utils/_resources_proxy.py +24 -0
- agentex/_utils/_streams.py +12 -0
- agentex/_utils/_sync.py +86 -0
- agentex/_utils/_transform.py +447 -0
- agentex/_utils/_typing.py +151 -0
- agentex/_utils/_utils.py +422 -0
- agentex/_version.py +4 -0
- agentex/lib/.keep +4 -0
- agentex/lib/__init__.py +0 -0
- agentex/lib/adk/__init__.py +41 -0
- agentex/lib/adk/_modules/__init__.py +0 -0
- agentex/lib/adk/_modules/acp.py +247 -0
- agentex/lib/adk/_modules/agent_task_tracker.py +176 -0
- agentex/lib/adk/_modules/agents.py +77 -0
- agentex/lib/adk/_modules/events.py +141 -0
- agentex/lib/adk/_modules/messages.py +285 -0
- agentex/lib/adk/_modules/state.py +291 -0
- agentex/lib/adk/_modules/streaming.py +75 -0
- agentex/lib/adk/_modules/tasks.py +124 -0
- agentex/lib/adk/_modules/tracing.py +194 -0
- agentex/lib/adk/providers/__init__.py +9 -0
- agentex/lib/adk/providers/_modules/__init__.py +0 -0
- agentex/lib/adk/providers/_modules/litellm.py +232 -0
- agentex/lib/adk/providers/_modules/openai.py +416 -0
- agentex/lib/adk/providers/_modules/sgp.py +85 -0
- agentex/lib/adk/utils/__init__.py +5 -0
- agentex/lib/adk/utils/_modules/__init__.py +0 -0
- agentex/lib/adk/utils/_modules/templating.py +94 -0
- agentex/lib/cli/__init__.py +0 -0
- agentex/lib/cli/commands/__init__.py +0 -0
- agentex/lib/cli/commands/agents.py +328 -0
- agentex/lib/cli/commands/init.py +227 -0
- agentex/lib/cli/commands/main.py +33 -0
- agentex/lib/cli/commands/secrets.py +169 -0
- agentex/lib/cli/commands/tasks.py +118 -0
- agentex/lib/cli/commands/uv.py +133 -0
- agentex/lib/cli/handlers/__init__.py +0 -0
- agentex/lib/cli/handlers/agent_handlers.py +160 -0
- agentex/lib/cli/handlers/cleanup_handlers.py +186 -0
- agentex/lib/cli/handlers/deploy_handlers.py +351 -0
- agentex/lib/cli/handlers/run_handlers.py +452 -0
- agentex/lib/cli/handlers/secret_handlers.py +670 -0
- agentex/lib/cli/templates/default/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/default/Dockerfile-uv.j2 +42 -0
- agentex/lib/cli/templates/default/Dockerfile.j2 +42 -0
- agentex/lib/cli/templates/default/README.md.j2 +193 -0
- agentex/lib/cli/templates/default/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/default/manifest.yaml.j2 +116 -0
- agentex/lib/cli/templates/default/project/acp.py.j2 +29 -0
- agentex/lib/cli/templates/default/pyproject.toml.j2 +33 -0
- agentex/lib/cli/templates/default/requirements.txt.j2 +5 -0
- agentex/lib/cli/templates/deploy/Screenshot 2025-03-19 at 10.36.57/342/200/257AM.png +0 -0
- agentex/lib/cli/templates/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/sync/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/sync/Dockerfile-uv.j2 +42 -0
- agentex/lib/cli/templates/sync/Dockerfile.j2 +42 -0
- agentex/lib/cli/templates/sync/README.md.j2 +293 -0
- agentex/lib/cli/templates/sync/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/sync/manifest.yaml.j2 +116 -0
- agentex/lib/cli/templates/sync/project/acp.py.j2 +26 -0
- agentex/lib/cli/templates/sync/pyproject.toml.j2 +33 -0
- agentex/lib/cli/templates/sync/requirements.txt.j2 +5 -0
- agentex/lib/cli/templates/temporal/.dockerignore.j2 +43 -0
- agentex/lib/cli/templates/temporal/Dockerfile-uv.j2 +48 -0
- agentex/lib/cli/templates/temporal/Dockerfile.j2 +48 -0
- agentex/lib/cli/templates/temporal/README.md.j2 +316 -0
- agentex/lib/cli/templates/temporal/deploy/example.yaml.j2 +55 -0
- agentex/lib/cli/templates/temporal/manifest.yaml.j2 +137 -0
- agentex/lib/cli/templates/temporal/project/acp.py.j2 +30 -0
- agentex/lib/cli/templates/temporal/project/run_worker.py.j2 +33 -0
- agentex/lib/cli/templates/temporal/project/workflow.py.j2 +66 -0
- agentex/lib/cli/templates/temporal/pyproject.toml.j2 +34 -0
- agentex/lib/cli/templates/temporal/requirements.txt.j2 +5 -0
- agentex/lib/cli/utils/cli_utils.py +14 -0
- agentex/lib/cli/utils/credential_utils.py +103 -0
- agentex/lib/cli/utils/exceptions.py +6 -0
- agentex/lib/cli/utils/kubectl_utils.py +135 -0
- agentex/lib/cli/utils/kubernetes_secrets_utils.py +185 -0
- agentex/lib/core/__init__.py +0 -0
- agentex/lib/core/adapters/__init__.py +0 -0
- agentex/lib/core/adapters/llm/__init__.py +1 -0
- agentex/lib/core/adapters/llm/adapter_litellm.py +46 -0
- agentex/lib/core/adapters/llm/adapter_sgp.py +55 -0
- agentex/lib/core/adapters/llm/port.py +24 -0
- agentex/lib/core/adapters/streams/adapter_redis.py +128 -0
- agentex/lib/core/adapters/streams/port.py +50 -0
- agentex/lib/core/clients/__init__.py +1 -0
- agentex/lib/core/clients/temporal/__init__.py +0 -0
- agentex/lib/core/clients/temporal/temporal_client.py +181 -0
- agentex/lib/core/clients/temporal/types.py +47 -0
- agentex/lib/core/clients/temporal/utils.py +56 -0
- agentex/lib/core/services/__init__.py +0 -0
- agentex/lib/core/services/adk/__init__.py +0 -0
- agentex/lib/core/services/adk/acp/__init__.py +0 -0
- agentex/lib/core/services/adk/acp/acp.py +210 -0
- agentex/lib/core/services/adk/agent_task_tracker.py +85 -0
- agentex/lib/core/services/adk/agents.py +43 -0
- agentex/lib/core/services/adk/events.py +61 -0
- agentex/lib/core/services/adk/messages.py +164 -0
- agentex/lib/core/services/adk/providers/__init__.py +0 -0
- agentex/lib/core/services/adk/providers/litellm.py +256 -0
- agentex/lib/core/services/adk/providers/openai.py +723 -0
- agentex/lib/core/services/adk/providers/sgp.py +99 -0
- agentex/lib/core/services/adk/state.py +120 -0
- agentex/lib/core/services/adk/streaming.py +262 -0
- agentex/lib/core/services/adk/tasks.py +69 -0
- agentex/lib/core/services/adk/tracing.py +36 -0
- agentex/lib/core/services/adk/utils/__init__.py +0 -0
- agentex/lib/core/services/adk/utils/templating.py +58 -0
- agentex/lib/core/temporal/__init__.py +0 -0
- agentex/lib/core/temporal/activities/__init__.py +207 -0
- agentex/lib/core/temporal/activities/activity_helpers.py +37 -0
- agentex/lib/core/temporal/activities/adk/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/acp/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/acp/acp_activities.py +86 -0
- agentex/lib/core/temporal/activities/adk/agent_task_tracker_activities.py +76 -0
- agentex/lib/core/temporal/activities/adk/agents_activities.py +35 -0
- agentex/lib/core/temporal/activities/adk/events_activities.py +50 -0
- agentex/lib/core/temporal/activities/adk/messages_activities.py +94 -0
- agentex/lib/core/temporal/activities/adk/providers/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/providers/litellm_activities.py +71 -0
- agentex/lib/core/temporal/activities/adk/providers/openai_activities.py +210 -0
- agentex/lib/core/temporal/activities/adk/providers/sgp_activities.py +42 -0
- agentex/lib/core/temporal/activities/adk/state_activities.py +85 -0
- agentex/lib/core/temporal/activities/adk/streaming_activities.py +33 -0
- agentex/lib/core/temporal/activities/adk/tasks_activities.py +48 -0
- agentex/lib/core/temporal/activities/adk/tracing_activities.py +55 -0
- agentex/lib/core/temporal/activities/adk/utils/__init__.py +0 -0
- agentex/lib/core/temporal/activities/adk/utils/templating_activities.py +41 -0
- agentex/lib/core/temporal/services/__init__.py +0 -0
- agentex/lib/core/temporal/services/temporal_task_service.py +69 -0
- agentex/lib/core/temporal/types/__init__.py +0 -0
- agentex/lib/core/temporal/types/workflow.py +5 -0
- agentex/lib/core/temporal/workers/__init__.py +0 -0
- agentex/lib/core/temporal/workers/worker.py +162 -0
- agentex/lib/core/temporal/workflows/workflow.py +26 -0
- agentex/lib/core/tracing/__init__.py +5 -0
- agentex/lib/core/tracing/processors/agentex_tracing_processor.py +117 -0
- agentex/lib/core/tracing/processors/sgp_tracing_processor.py +119 -0
- agentex/lib/core/tracing/processors/tracing_processor_interface.py +40 -0
- agentex/lib/core/tracing/trace.py +311 -0
- agentex/lib/core/tracing/tracer.py +70 -0
- agentex/lib/core/tracing/tracing_processor_manager.py +62 -0
- agentex/lib/environment_variables.py +87 -0
- agentex/lib/py.typed +0 -0
- agentex/lib/sdk/__init__.py +0 -0
- agentex/lib/sdk/config/__init__.py +0 -0
- agentex/lib/sdk/config/agent_config.py +61 -0
- agentex/lib/sdk/config/agent_manifest.py +219 -0
- agentex/lib/sdk/config/build_config.py +35 -0
- agentex/lib/sdk/config/deployment_config.py +117 -0
- agentex/lib/sdk/config/local_development_config.py +56 -0
- agentex/lib/sdk/config/project_config.py +103 -0
- agentex/lib/sdk/fastacp/__init__.py +3 -0
- agentex/lib/sdk/fastacp/base/base_acp_server.py +406 -0
- agentex/lib/sdk/fastacp/fastacp.py +74 -0
- agentex/lib/sdk/fastacp/impl/agentic_base_acp.py +72 -0
- agentex/lib/sdk/fastacp/impl/sync_acp.py +109 -0
- agentex/lib/sdk/fastacp/impl/temporal_acp.py +97 -0
- agentex/lib/sdk/fastacp/tests/README.md +297 -0
- agentex/lib/sdk/fastacp/tests/conftest.py +307 -0
- agentex/lib/sdk/fastacp/tests/pytest.ini +10 -0
- agentex/lib/sdk/fastacp/tests/run_tests.py +227 -0
- agentex/lib/sdk/fastacp/tests/test_base_acp_server.py +450 -0
- agentex/lib/sdk/fastacp/tests/test_fastacp_factory.py +344 -0
- agentex/lib/sdk/fastacp/tests/test_integration.py +477 -0
- agentex/lib/sdk/state_machine/__init__.py +6 -0
- agentex/lib/sdk/state_machine/noop_workflow.py +21 -0
- agentex/lib/sdk/state_machine/state.py +10 -0
- agentex/lib/sdk/state_machine/state_machine.py +189 -0
- agentex/lib/sdk/state_machine/state_workflow.py +16 -0
- agentex/lib/sdk/utils/__init__.py +0 -0
- agentex/lib/sdk/utils/messages.py +223 -0
- agentex/lib/types/__init__.py +0 -0
- agentex/lib/types/acp.py +94 -0
- agentex/lib/types/agent_configs.py +79 -0
- agentex/lib/types/agent_results.py +29 -0
- agentex/lib/types/credentials.py +34 -0
- agentex/lib/types/fastacp.py +61 -0
- agentex/lib/types/files.py +13 -0
- agentex/lib/types/json_rpc.py +49 -0
- agentex/lib/types/llm_messages.py +354 -0
- agentex/lib/types/task_message_updates.py +171 -0
- agentex/lib/types/tracing.py +34 -0
- agentex/lib/utils/__init__.py +0 -0
- agentex/lib/utils/completions.py +131 -0
- agentex/lib/utils/console.py +14 -0
- agentex/lib/utils/io.py +29 -0
- agentex/lib/utils/iterables.py +14 -0
- agentex/lib/utils/json_schema.py +23 -0
- agentex/lib/utils/logging.py +31 -0
- agentex/lib/utils/mcp.py +17 -0
- agentex/lib/utils/model_utils.py +46 -0
- agentex/lib/utils/parsing.py +15 -0
- agentex/lib/utils/regex.py +6 -0
- agentex/lib/utils/temporal.py +13 -0
- agentex/py.typed +0 -0
- agentex/resources/__init__.py +103 -0
- agentex/resources/agents.py +707 -0
- agentex/resources/events.py +294 -0
- agentex/resources/messages/__init__.py +33 -0
- agentex/resources/messages/batch.py +271 -0
- agentex/resources/messages/messages.py +492 -0
- agentex/resources/spans.py +557 -0
- agentex/resources/states.py +544 -0
- agentex/resources/tasks.py +615 -0
- agentex/resources/tracker.py +384 -0
- agentex/types/__init__.py +56 -0
- agentex/types/acp_type.py +7 -0
- agentex/types/agent.py +29 -0
- agentex/types/agent_list_params.py +13 -0
- agentex/types/agent_list_response.py +10 -0
- agentex/types/agent_rpc_by_name_params.py +21 -0
- agentex/types/agent_rpc_params.py +51 -0
- agentex/types/agent_rpc_params1.py +21 -0
- agentex/types/agent_rpc_response.py +20 -0
- agentex/types/agent_rpc_result.py +90 -0
- agentex/types/agent_task_tracker.py +34 -0
- agentex/types/data_content.py +30 -0
- agentex/types/data_content_param.py +31 -0
- agentex/types/data_delta.py +14 -0
- agentex/types/event.py +29 -0
- agentex/types/event_list_params.py +22 -0
- agentex/types/event_list_response.py +10 -0
- agentex/types/message_author.py +7 -0
- agentex/types/message_create_params.py +18 -0
- agentex/types/message_list_params.py +14 -0
- agentex/types/message_list_response.py +10 -0
- agentex/types/message_style.py +7 -0
- agentex/types/message_update_params.py +18 -0
- agentex/types/messages/__init__.py +8 -0
- agentex/types/messages/batch_create_params.py +16 -0
- agentex/types/messages/batch_create_response.py +10 -0
- agentex/types/messages/batch_update_params.py +16 -0
- agentex/types/messages/batch_update_response.py +10 -0
- agentex/types/shared/__init__.py +3 -0
- agentex/types/shared/task_message_update.py +83 -0
- agentex/types/span.py +36 -0
- agentex/types/span_create_params.py +40 -0
- agentex/types/span_list_params.py +12 -0
- agentex/types/span_list_response.py +10 -0
- agentex/types/span_update_params.py +37 -0
- agentex/types/state.py +25 -0
- agentex/types/state_create_params.py +16 -0
- agentex/types/state_list_params.py +16 -0
- agentex/types/state_list_response.py +10 -0
- agentex/types/state_update_params.py +16 -0
- agentex/types/task.py +23 -0
- agentex/types/task_delete_by_name_response.py +8 -0
- agentex/types/task_delete_response.py +8 -0
- agentex/types/task_list_response.py +10 -0
- agentex/types/task_message.py +33 -0
- agentex/types/task_message_content.py +16 -0
- agentex/types/task_message_content_param.py +17 -0
- agentex/types/task_message_delta.py +16 -0
- agentex/types/text_content.py +53 -0
- agentex/types/text_content_param.py +54 -0
- agentex/types/text_delta.py +14 -0
- agentex/types/tool_request_content.py +36 -0
- agentex/types/tool_request_content_param.py +37 -0
- agentex/types/tool_request_delta.py +18 -0
- agentex/types/tool_response_content.py +36 -0
- agentex/types/tool_response_content_param.py +36 -0
- agentex/types/tool_response_delta.py +18 -0
- agentex/types/tracker_list_params.py +16 -0
- agentex/types/tracker_list_response.py +10 -0
- agentex/types/tracker_update_params.py +19 -0
- agentex_sdk-0.1.0.dist-info/METADATA +423 -0
- agentex_sdk-0.1.0.dist-info/RECORD +289 -0
- agentex_sdk-0.1.0.dist-info/WHEEL +4 -0
- agentex_sdk-0.1.0.dist-info/entry_points.txt +2 -0
- agentex_sdk-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,344 @@
|
|
1
|
+
import asyncio
|
2
|
+
from unittest.mock import AsyncMock, MagicMock, patch
|
3
|
+
|
4
|
+
import pytest
|
5
|
+
|
6
|
+
from agentex.lib.sdk.fastacp.base.base_acp_server import BaseACPServer
|
7
|
+
from agentex.lib.sdk.fastacp.fastacp import FastACP
|
8
|
+
from agentex.lib.sdk.fastacp.impl.agentic_base_acp import AgenticBaseACP
|
9
|
+
from agentex.lib.sdk.fastacp.impl.sync_acp import SyncACP
|
10
|
+
from agentex.lib.sdk.fastacp.impl.temporal_acp import TemporalACP
|
11
|
+
from agentex.lib.types.fastacp import (
|
12
|
+
AgenticACPConfig,
|
13
|
+
AgenticBaseACPConfig,
|
14
|
+
SyncACPConfig,
|
15
|
+
TemporalACPConfig,
|
16
|
+
)
|
17
|
+
|
18
|
+
|
19
|
+
class TestFastACPInitialization:
|
20
|
+
"""Test FastACP basic functionality"""
|
21
|
+
|
22
|
+
def test_factory_class_exists(self):
|
23
|
+
"""Test that FastACP class exists and is properly structured"""
|
24
|
+
assert hasattr(FastACP, "create")
|
25
|
+
assert hasattr(FastACP, "create_sync_acp")
|
26
|
+
assert hasattr(FastACP, "create_agentic_acp")
|
27
|
+
|
28
|
+
|
29
|
+
class TestSyncACPCreation:
|
30
|
+
"""Test SyncACP creation through factory"""
|
31
|
+
|
32
|
+
@pytest.mark.asyncio
|
33
|
+
async def test_create_sync_acp_direct_method(self):
|
34
|
+
"""Test creating SyncACP using direct method"""
|
35
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
36
|
+
sync_acp = FastACP.create_sync_acp()
|
37
|
+
|
38
|
+
assert isinstance(sync_acp, SyncACP)
|
39
|
+
assert isinstance(sync_acp, BaseACPServer)
|
40
|
+
assert hasattr(sync_acp, "_handlers")
|
41
|
+
|
42
|
+
@pytest.mark.asyncio
|
43
|
+
async def test_create_sync_acp_with_config(self):
|
44
|
+
"""Test creating SyncACP with configuration"""
|
45
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
46
|
+
config = SyncACPConfig()
|
47
|
+
sync_acp = FastACP.create_sync_acp(config=config)
|
48
|
+
|
49
|
+
assert isinstance(sync_acp, SyncACP)
|
50
|
+
|
51
|
+
@pytest.mark.asyncio
|
52
|
+
async def test_create_sync_acp_via_generic_create(self):
|
53
|
+
"""Test creating SyncACP via generic create method"""
|
54
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
55
|
+
sync_acp = FastACP.create("sync")
|
56
|
+
|
57
|
+
assert isinstance(sync_acp, SyncACP)
|
58
|
+
|
59
|
+
@pytest.mark.asyncio
|
60
|
+
async def test_create_sync_acp_via_generic_create_with_config(self):
|
61
|
+
"""Test creating SyncACP via generic create method with config"""
|
62
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
63
|
+
config = SyncACPConfig()
|
64
|
+
sync_acp = FastACP.create("sync", config=config)
|
65
|
+
|
66
|
+
assert isinstance(sync_acp, SyncACP)
|
67
|
+
|
68
|
+
@pytest.mark.asyncio
|
69
|
+
async def test_create_sync_acp_with_enum(self):
|
70
|
+
"""Test creating SyncACP using ACPType enum"""
|
71
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
72
|
+
sync_acp = FastACP.create("sync")
|
73
|
+
|
74
|
+
assert isinstance(sync_acp, SyncACP)
|
75
|
+
|
76
|
+
@pytest.mark.asyncio
|
77
|
+
async def test_create_sync_acp_with_kwargs(self):
|
78
|
+
"""Test creating SyncACP with additional kwargs"""
|
79
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
80
|
+
sync_acp = FastACP.create_sync_acp(custom_param="test_value")
|
81
|
+
|
82
|
+
assert isinstance(sync_acp, SyncACP)
|
83
|
+
|
84
|
+
|
85
|
+
class TestAgenticBaseACPCreation:
|
86
|
+
"""Test AgenticBaseACP creation through factory"""
|
87
|
+
|
88
|
+
@pytest.mark.asyncio
|
89
|
+
async def test_create_agentic_base_acp_direct_method(self):
|
90
|
+
"""Test creating AgenticBaseACP using direct method"""
|
91
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
92
|
+
config = AgenticACPConfig(type="base")
|
93
|
+
agentic_acp = FastACP.create_agentic_acp(config=config)
|
94
|
+
|
95
|
+
assert isinstance(agentic_acp, AgenticBaseACP)
|
96
|
+
assert isinstance(agentic_acp, BaseACPServer)
|
97
|
+
|
98
|
+
@pytest.mark.asyncio
|
99
|
+
async def test_create_agentic_base_acp_with_specific_config(self):
|
100
|
+
"""Test creating AgenticBaseACP with AgenticBaseACPConfig"""
|
101
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
102
|
+
config = AgenticBaseACPConfig(type="base")
|
103
|
+
agentic_acp = FastACP.create_agentic_acp(config=config)
|
104
|
+
|
105
|
+
assert isinstance(agentic_acp, AgenticBaseACP)
|
106
|
+
|
107
|
+
@pytest.mark.asyncio
|
108
|
+
async def test_create_agentic_base_acp_via_generic_create(self):
|
109
|
+
"""Test creating AgenticBaseACP via generic create method"""
|
110
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
111
|
+
config = AgenticACPConfig(type="base")
|
112
|
+
agentic_acp = FastACP.create("agentic", config=config)
|
113
|
+
|
114
|
+
assert isinstance(agentic_acp, AgenticBaseACP)
|
115
|
+
|
116
|
+
@pytest.mark.asyncio
|
117
|
+
async def test_create_agentic_base_acp_with_enum(self):
|
118
|
+
"""Test creating AgenticBaseACP using ACPType enum"""
|
119
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
120
|
+
config = AgenticACPConfig(type="base")
|
121
|
+
agentic_acp = FastACP.create("agentic", config=config)
|
122
|
+
|
123
|
+
assert isinstance(agentic_acp, AgenticBaseACP)
|
124
|
+
|
125
|
+
|
126
|
+
class TestAgenticTemporalACPCreation:
|
127
|
+
"""Test AgenticTemporalACP (TemporalACP) creation through factory"""
|
128
|
+
|
129
|
+
@pytest.mark.asyncio
|
130
|
+
async def test_create_temporal_acp_direct_method(self):
|
131
|
+
"""Test creating TemporalACP using direct method"""
|
132
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
133
|
+
config = AgenticACPConfig(type="temporal")
|
134
|
+
|
135
|
+
# Mock the TemporalACP.create method since it requires temporal dependencies
|
136
|
+
with patch.object(TemporalACP, "create", new_callable=AsyncMock) as mock_create:
|
137
|
+
mock_temporal_instance = MagicMock(spec=TemporalACP)
|
138
|
+
mock_create.return_value = mock_temporal_instance
|
139
|
+
|
140
|
+
temporal_acp = FastACP.create_agentic_acp(config=config)
|
141
|
+
|
142
|
+
assert temporal_acp == mock_temporal_instance
|
143
|
+
mock_create.assert_called_once()
|
144
|
+
|
145
|
+
@pytest.mark.asyncio
|
146
|
+
async def test_create_temporal_acp_with_temporal_config(self):
|
147
|
+
"""Test creating TemporalACP with TemporalACPConfig"""
|
148
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
149
|
+
config = TemporalACPConfig(type="temporal", temporal_address="localhost:7233")
|
150
|
+
|
151
|
+
with patch.object(TemporalACP, "create", new_callable=AsyncMock) as mock_create:
|
152
|
+
mock_temporal_instance = MagicMock(spec=TemporalACP)
|
153
|
+
mock_create.return_value = mock_temporal_instance
|
154
|
+
|
155
|
+
temporal_acp = FastACP.create_agentic_acp(config=config)
|
156
|
+
|
157
|
+
assert temporal_acp == mock_temporal_instance
|
158
|
+
# Verify temporal_address was passed
|
159
|
+
mock_create.assert_called_once_with(temporal_address="localhost:7233")
|
160
|
+
|
161
|
+
@pytest.mark.asyncio
|
162
|
+
async def test_create_temporal_acp_via_generic_create(self):
|
163
|
+
"""Test creating TemporalACP via generic create method"""
|
164
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
165
|
+
config = AgenticACPConfig(type="temporal")
|
166
|
+
|
167
|
+
with patch.object(TemporalACP, "create", new_callable=AsyncMock) as mock_create:
|
168
|
+
mock_temporal_instance = MagicMock(spec=TemporalACP)
|
169
|
+
mock_create.return_value = mock_temporal_instance
|
170
|
+
|
171
|
+
temporal_acp = FastACP.create("agentic", config=config)
|
172
|
+
|
173
|
+
assert temporal_acp == mock_temporal_instance
|
174
|
+
|
175
|
+
@pytest.mark.asyncio
|
176
|
+
async def test_create_temporal_acp_with_custom_address(self):
|
177
|
+
"""Test creating TemporalACP with custom temporal address"""
|
178
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
179
|
+
config = TemporalACPConfig(type="temporal", temporal_address="custom-temporal:9999")
|
180
|
+
|
181
|
+
with patch.object(TemporalACP, "create", new_callable=AsyncMock) as mock_create:
|
182
|
+
mock_temporal_instance = MagicMock(spec=TemporalACP)
|
183
|
+
mock_create.return_value = mock_temporal_instance
|
184
|
+
|
185
|
+
FastACP.create_agentic_acp(config=config)
|
186
|
+
|
187
|
+
mock_create.assert_called_once_with(temporal_address="custom-temporal:9999")
|
188
|
+
|
189
|
+
|
190
|
+
class TestConfigurationValidation:
|
191
|
+
"""Test configuration validation and error handling"""
|
192
|
+
|
193
|
+
@pytest.mark.asyncio
|
194
|
+
async def test_agentic_requires_config(self):
|
195
|
+
"""Test that agentic ACP creation requires configuration"""
|
196
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
197
|
+
with pytest.raises(ValueError, match="AgenticACPConfig is required"):
|
198
|
+
FastACP.create("agentic")
|
199
|
+
|
200
|
+
@pytest.mark.asyncio
|
201
|
+
async def test_agentic_requires_correct_config_type(self):
|
202
|
+
"""Test that agentic ACP creation requires AgenticACPConfig type"""
|
203
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
204
|
+
sync_config = SyncACPConfig()
|
205
|
+
|
206
|
+
with pytest.raises(ValueError, match="AgenticACPConfig is required"):
|
207
|
+
FastACP.create("agentic", config=sync_config)
|
208
|
+
|
209
|
+
@pytest.mark.asyncio
|
210
|
+
async def test_agentic_direct_method_requires_config(self):
|
211
|
+
"""Test that direct agentic method requires configuration"""
|
212
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
213
|
+
# This should raise TypeError since config is required parameter
|
214
|
+
with pytest.raises(TypeError):
|
215
|
+
FastACP.create_agentic_acp()
|
216
|
+
|
217
|
+
def test_invalid_acp_type_string(self):
|
218
|
+
"""Test that invalid ACP type string raises ValueError"""
|
219
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
220
|
+
with pytest.raises(ValueError):
|
221
|
+
asyncio.run(FastACP.create("invalid_type"))
|
222
|
+
|
223
|
+
def test_invalid_agentic_type_in_config(self):
|
224
|
+
"""Test that invalid agentic type in config raises ValueError"""
|
225
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
226
|
+
# This should raise ValueError during config creation
|
227
|
+
with pytest.raises(ValueError):
|
228
|
+
AgenticACPConfig(type="invalid_agentic_type")
|
229
|
+
|
230
|
+
@pytest.mark.asyncio
|
231
|
+
async def test_unsupported_acp_type_enum(self):
|
232
|
+
"""Test handling of unsupported ACP type enum values"""
|
233
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
234
|
+
# Create a mock enum value that's not supported
|
235
|
+
with patch("agentex.sdk.fastacp.fastacp.ACPType") as mock_enum:
|
236
|
+
mock_enum.SYNC = "sync"
|
237
|
+
mock_enum.AGENTIC = "agentic"
|
238
|
+
unsupported_type = "unsupported"
|
239
|
+
|
240
|
+
with pytest.raises(ValueError, match="Unsupported ACP type"):
|
241
|
+
FastACP.create(unsupported_type)
|
242
|
+
|
243
|
+
|
244
|
+
class TestErrorHandling:
|
245
|
+
"""Test error handling scenarios"""
|
246
|
+
|
247
|
+
@pytest.mark.asyncio
|
248
|
+
async def test_sync_acp_creation_failure(self):
|
249
|
+
"""Test handling of SyncACP creation failure"""
|
250
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
251
|
+
with patch.object(SyncACP, "create", side_effect=Exception("Creation failed")):
|
252
|
+
with pytest.raises(Exception, match="Creation failed"):
|
253
|
+
FastACP.create_sync_acp()
|
254
|
+
|
255
|
+
@pytest.mark.asyncio
|
256
|
+
async def test_agentic_acp_creation_failure(self):
|
257
|
+
"""Test handling of AgenticACP creation failure"""
|
258
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
259
|
+
config = AgenticACPConfig(type="base")
|
260
|
+
|
261
|
+
with patch.object(AgenticBaseACP, "create", side_effect=Exception("Creation failed")):
|
262
|
+
with pytest.raises(Exception, match="Creation failed"):
|
263
|
+
FastACP.create_agentic_acp(config=config)
|
264
|
+
|
265
|
+
@pytest.mark.asyncio
|
266
|
+
async def test_temporal_acp_creation_failure(self):
|
267
|
+
"""Test handling of TemporalACP creation failure"""
|
268
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
269
|
+
config = AgenticACPConfig(type="temporal")
|
270
|
+
|
271
|
+
with patch.object(
|
272
|
+
TemporalACP, "create", side_effect=Exception("Temporal connection failed")
|
273
|
+
):
|
274
|
+
with pytest.raises(Exception, match="Temporal connection failed"):
|
275
|
+
FastACP.create_agentic_acp(config=config)
|
276
|
+
|
277
|
+
|
278
|
+
class TestIntegrationScenarios:
|
279
|
+
"""Test integration scenarios and real-world usage patterns"""
|
280
|
+
|
281
|
+
@pytest.mark.asyncio
|
282
|
+
async def test_create_all_acp_types(self):
|
283
|
+
"""Test creating all supported ACP types"""
|
284
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
285
|
+
# Create SyncACP
|
286
|
+
sync_acp = FastACP.create("sync")
|
287
|
+
assert isinstance(sync_acp, SyncACP)
|
288
|
+
|
289
|
+
# Create AgenticBaseACP
|
290
|
+
base_config = AgenticACPConfig(type="base")
|
291
|
+
agentic_base = FastACP.create("agentic", config=base_config)
|
292
|
+
assert isinstance(agentic_base, AgenticBaseACP)
|
293
|
+
|
294
|
+
# Create TemporalACP (mocked)
|
295
|
+
temporal_config = AgenticACPConfig(type="temporal")
|
296
|
+
with patch.object(TemporalACP, "create", new_callable=AsyncMock) as mock_create:
|
297
|
+
mock_temporal_instance = MagicMock(spec=TemporalACP)
|
298
|
+
mock_create.return_value = mock_temporal_instance
|
299
|
+
|
300
|
+
temporal_acp = FastACP.create("agentic", config=temporal_config)
|
301
|
+
assert temporal_acp == mock_temporal_instance
|
302
|
+
|
303
|
+
@pytest.mark.asyncio
|
304
|
+
async def test_configuration_driven_creation(self):
|
305
|
+
"""Test configuration-driven ACP creation"""
|
306
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
307
|
+
configs = [
|
308
|
+
("sync", None),
|
309
|
+
("agentic", AgenticACPConfig(type="base")),
|
310
|
+
("agentic", TemporalACPConfig(type="temporal", temporal_address="localhost:7233")),
|
311
|
+
]
|
312
|
+
|
313
|
+
created_acps = []
|
314
|
+
|
315
|
+
for acp_type, config in configs:
|
316
|
+
if acp_type == "agentic" and config.type == "temporal":
|
317
|
+
# Mock temporal creation
|
318
|
+
with patch.object(TemporalACP, "create", new_callable=AsyncMock) as mock_create:
|
319
|
+
mock_temporal_instance = MagicMock(spec=TemporalACP)
|
320
|
+
mock_create.return_value = mock_temporal_instance
|
321
|
+
|
322
|
+
acp = FastACP.create(acp_type, config=config)
|
323
|
+
created_acps.append(acp)
|
324
|
+
else:
|
325
|
+
acp = FastACP.create(acp_type, config=config)
|
326
|
+
created_acps.append(acp)
|
327
|
+
|
328
|
+
assert len(created_acps) == 3
|
329
|
+
assert isinstance(created_acps[0], SyncACP)
|
330
|
+
assert isinstance(created_acps[1], AgenticBaseACP)
|
331
|
+
# Third one is mocked TemporalACP
|
332
|
+
|
333
|
+
@pytest.mark.asyncio
|
334
|
+
async def test_factory_with_custom_kwargs(self):
|
335
|
+
"""Test factory methods with custom keyword arguments"""
|
336
|
+
with patch.dict("os.environ", {"AGENTEX_BASE_URL": ""}):
|
337
|
+
# Test sync with kwargs
|
338
|
+
sync_acp = FastACP.create_sync_acp(custom_param="test")
|
339
|
+
assert isinstance(sync_acp, SyncACP)
|
340
|
+
|
341
|
+
# Test agentic base with kwargs
|
342
|
+
config = AgenticACPConfig(type="base")
|
343
|
+
agentic_acp = FastACP.create_agentic_acp(config=config, custom_param="test")
|
344
|
+
assert isinstance(agentic_acp, AgenticBaseACP)
|