@devries-cameron20 / composio Mirror · read-only / commits / 517725b47
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 11:00 UTC

test: remove low-value tests without reducing coverage (#4630)

This PR: - removes 91 tests that duplicate a stronger owner test, assert on their own mocks or on private fields, or compare a value with itself - `core`: 13, `cli`: 14, providers and `ts-builders`: 34, `py`: 30 - removes `ts/packages/cli/src/effect-errors/logic/errors/extract-error-details.test.ts`, which vitest never collected (only `test/**/*.test.ts` is included); `test/src/effect-errors/extract-error-details.test.ts` owns that contract - removes the CLI's `readableStreamFromNode` helper, which never had a production caller (#3884 moved the call site to `Stream.toReadableStream`), and `AuthConfigs.getClient()`, which the tests alone used - removes the CLI's `ConfigProvider.env` config block, which has duplicated the `fromMap` block since the Effect v4 migration made `fromEnv` a wrapper around `fromEnvRecord` - keeps coverage unchanged: I ran the full suites of core, the CLI, `ts-builders`, and 9 providers with v8 coverage, and the Python suite with coverage.py, before and after; no covered line or branch became uncovered - uncovered in core stays at 1061 statements / 1006 branches / 147 functions; the CLI drops from 3658 to 3652 uncovered statements because the removed helper had uncovered paths - the one Python difference, `schema_converter.py:1829-1835`, comes from a Hypothesis property test that covers those lines at random (1 of 3 runs on the same tree) - verification: core 1659, CLI 1429, providers and `ts-builders` 393, and Python 2041 tests pass; `typecheck`, oxlint, `validate:boundaries`, Prettier, and ruff are clean ## Context I followed the [test-audit method](https://github.com/openclaw/openclaw/blob/main/.agents/skills/test-audit/SKILL.md), which keeps public API, protocol, config, security, regression, and cross-SDK contract tests. These looked suspicious but stay: the per-provider dangling-`$defs` regressions, the schema-semantics corpora, `UnionType` "empty variants" (the only test covering that guard), and the Gemini tests (CI never runs them). Follow-ups, not in this PR: - `connectionRequest.test.ts` timeout test has a try/catch without `expect.assertions`, so it can pass vacuously - CI (`py.test.yml`) installs only the crewai, langchain, and langgraph providers, so the Gemini and Google provider tests always skip and the `openai_agents` and `claude_agent_sdk` provider tests never run

Alberto Schiabel committed Sep 28, 2026 at 15:44 UTC 517725b477b9ecf4e4874ee97b4fe63474fa0a28
27 files changed +6 -1685
python/tests/test_auth_configs.py
+5 -234
@@ -1,5 +1,6 @@
1 """Tests for auth configs management."""
2
3 +import json
4 from unittest.mock import Mock
5
6 import httpx
@@ -106,20 +107,6 @@ class TestAuthConfigs:
107 )
108 assert result == mock_response
109
109 - def test_list_with_empty_result(self, auth_configs, mock_client):
110 - """Test listing auth configs returns empty list."""
111 - mock_response = Mock(spec=auth_config_list_response.AuthConfigListResponse)
112 - mock_response.items = []
113 - mock_response.next_cursor = None
114 - mock_response.total_pages = 0
115 - mock_client.auth_configs.list.return_value = mock_response
116 -
117 - result = auth_configs.list()
118 -
119 - assert len(result.items) == 0
120 - assert result.next_cursor is None
121 - assert result.total_pages == 0
122 -
110 # Create tests
111 def test_create_with_default_composio_managed_auth(self, auth_configs, mock_client):
112 """Test creating auth config with default Composio managed type."""
@@ -225,47 +212,6 @@ class TestAuthConfigs:
212
213 assert "Auth config not found" in str(exc_info.value)
214
228 - def test_get_with_is_enabled_for_tool_router_true(
229 - self, auth_configs, mock_client, mock_auth_config_response
230 - ):
231 - """Test retrieving auth config with isEnabledForToolRouter set to true."""
232 - mock_auth_config_response.is_enabled_for_tool_router = True
233 - mock_client.auth_configs.retrieve.return_value = mock_auth_config_response
234 -
235 - result = auth_configs.get("auth_12345")
236 -
237 - assert hasattr(result, "is_enabled_for_tool_router")
238 - assert result.is_enabled_for_tool_router is True
239 -
240 - def test_get_with_is_enabled_for_tool_router_false(
241 - self, auth_configs, mock_client, mock_auth_config_response
242 - ):
243 - """Test retrieving auth config with isEnabledForToolRouter set to false."""
244 - mock_auth_config_response.is_enabled_for_tool_router = False
245 - mock_client.auth_configs.retrieve.return_value = mock_auth_config_response
246 -
247 - result = auth_configs.get("auth_12345")
248 -
249 - assert hasattr(result, "is_enabled_for_tool_router")
250 - assert result.is_enabled_for_tool_router is False
251 -
252 - def test_get_with_is_enabled_for_tool_router_undefined(
253 - self, auth_configs, mock_client, mock_auth_config_response
254 - ):
255 - """Test retrieving auth config with isEnabledForToolRouter undefined."""
256 - # Don't set the attribute at all to simulate undefined
257 - if hasattr(mock_auth_config_response, "is_enabled_for_tool_router"):
258 - delattr(mock_auth_config_response, "is_enabled_for_tool_router")
259 - mock_client.auth_configs.retrieve.return_value = mock_auth_config_response
260 -
261 - result = auth_configs.get("auth_12345")
262 -
263 - # Should not have the attribute or it should be None
264 - assert (
265 - not hasattr(result, "is_enabled_for_tool_router")
266 - or result.is_enabled_for_tool_router is None
267 - )
268 -
215 # Update tests
216 def test_update_custom_auth_config_with_credentials(
217 self, auth_configs, mock_client
@@ -293,27 +239,6 @@ class TestAuthConfigs:
239 assert call_args.kwargs["credentials"] == options["credentials"]
240 assert result == mock_response
241
296 - def test_update_default_auth_config_with_scopes(self, auth_configs, mock_client):
297 - """Test updating default auth config with scopes."""
298 - mock_response = auth_config_update_response.AuthConfigUpdateResponse(
299 - success=True, message="Successfully updated auth config"
300 - )
301 - mock_client.auth_configs.update.return_value = mock_response
302 -
303 - options = {
304 - "type": "default",
305 - "scopes": "read:user,repo",
306 - }
307 -
308 - result = auth_configs.update("auth_12345", options=options)
309 -
310 - mock_client.auth_configs.update.assert_called_once()
311 - # Check that scopes are not directly passed but other fields are
312 - call_args = mock_client.auth_configs.update.call_args
313 - assert call_args.kwargs["nanoid"] == "auth_12345"
314 - assert call_args.kwargs["type"] == "default"
315 - assert result == mock_response
316 -
242 def test_update_with_is_enabled_for_tool_router(self, auth_configs, mock_client):
243 """Test updating auth config with isEnabledForToolRouter."""
244 mock_response = auth_config_update_response.AuthConfigUpdateResponse(
@@ -354,33 +279,6 @@ class TestAuthConfigs:
279 assert call_args.kwargs["tool_access_config"] == options["tool_access_config"]
280 assert result == mock_response
281
357 - def test_update_with_large_credential_object(self, auth_configs, mock_client):
358 - """Test updating auth config with large credential object."""
359 - mock_response = auth_config_update_response.AuthConfigUpdateResponse(
360 - success=True, message="Successfully updated auth config"
361 - )
362 - mock_client.auth_configs.update.return_value = mock_response
363 -
364 - large_credentials = {
365 - "field1": "value1",
366 - "field2": "value2",
367 - "field3": {"nested": "object"},
368 - "field4": ["array", "values"],
369 - "field5": 12345,
370 - "field6": True,
371 - }
372 -
373 - options = {
374 - "type": "custom",
375 - "credentials": large_credentials,
376 - }
377 -
378 - result = auth_configs.update("auth_12345", options=options)
379 -
380 - call_args = mock_client.auth_configs.update.call_args
381 - assert call_args.kwargs["credentials"] == large_credentials
382 - assert result == mock_response
383 -
282 def test_update_handles_api_error(self, auth_configs, mock_client):
283 """Test update handles API errors."""
284 mock_client.auth_configs.update.side_effect = Exception("Update failed")
@@ -489,137 +387,6 @@ class TestAuthConfigs:
387 assert call_args.kwargs["tool_access_config"] == mock_client.not_given
388 assert result == mock_response
389
492 - def test_create_with_minimal_options(self, auth_configs, mock_client):
493 - """Test creating auth config with minimal options."""
494 - mock_auth_config = Mock(spec=auth_config_create_response.AuthConfig)
495 - mock_auth_config.id = "auth_12345"
496 -
497 - mock_response = Mock(spec=auth_config_create_response.AuthConfigCreateResponse)
498 - mock_response.auth_config = mock_auth_config
499 -
500 - mock_client.auth_configs.create.return_value = mock_response
501 -
502 - # Just the toolkit, using default type
503 - result = auth_configs.create("github", {"type": "use_composio_managed_auth"})
504 -
505 - mock_client.auth_configs.create.assert_called_once()
506 - assert result == mock_auth_config
507 -
508 - def test_list_with_pagination(self, auth_configs, mock_client):
509 - """Test listing auth configs with pagination."""
510 - mock_response = Mock(spec=auth_config_list_response.AuthConfigListResponse)
511 - mock_response.items = [Mock(), Mock(), Mock()]
512 - mock_response.next_cursor = "next_page_cursor"
513 - mock_response.total_pages = 5
514 - mock_client.auth_configs.list.return_value = mock_response
515 -
516 - result = auth_configs.list(cursor="current_cursor", limit=3)
517 -
518 - mock_client.auth_configs.list.assert_called_once()
519 - assert len(result.items) == 3
520 - assert result.next_cursor == "next_page_cursor"
521 - assert result.total_pages == 5
522 -
523 - def test_get_minimal_auth_config(self, auth_configs, mock_client):
524 - """Test retrieving auth config with minimal fields."""
525 - minimal_response = Mock(
526 - spec=auth_config_retrieve_response.AuthConfigRetrieveResponse
527 - )
528 - minimal_response.id = "auth_minimal"
529 - minimal_response.name = "Minimal Config"
530 - minimal_response.no_of_connections = 0
531 - minimal_response.status = "DISABLED"
532 - minimal_response.toolkit = Mock()
533 - minimal_response.toolkit.logo = ""
534 - minimal_response.toolkit.slug = "minimal-toolkit"
535 - minimal_response.uuid = "uuid-minimal"
536 -
537 - mock_client.auth_configs.retrieve.return_value = minimal_response
538 -
539 - result = auth_configs.get("auth_minimal")
540 -
541 - assert result.id == "auth_minimal"
542 - assert result.name == "Minimal Config"
543 - assert result.no_of_connections == 0
544 - assert result.status == "DISABLED"
545 -
546 -
547 -class TestAuthConfigsOverloads:
548 - """Test type overloads for create and update methods."""
549 -
550 - @pytest.fixture
551 - def mock_client(self):
552 - """Create a mock client for testing."""
553 - client = Mock()
554 - client.auth_configs = Mock()
555 - client.auth_configs.create = Mock()
556 - client.auth_configs.update = Mock()
557 - client.not_given = object()
558 - return client
559 -
560 - @pytest.fixture
561 - def auth_configs(self, mock_client):
562 - """Create an AuthConfigs instance with mock client."""
563 - return AuthConfigs(client=mock_client)
564 -
565 - def test_create_overload_use_composio_managed_auth(self, auth_configs, mock_client):
566 - """Test create with use_composio_managed_auth type."""
567 - mock_auth_config = Mock(spec=auth_config_create_response.AuthConfig)
568 - mock_response = Mock(spec=auth_config_create_response.AuthConfigCreateResponse)
569 - mock_response.auth_config = mock_auth_config
570 - mock_client.auth_configs.create.return_value = mock_response
571 -
572 - options = {"type": "use_composio_managed_auth"}
573 - result = auth_configs.create("github", options)
574 -
575 - assert result == mock_auth_config
576 -
577 - def test_create_overload_use_custom_auth(self, auth_configs, mock_client):
578 - """Test create with use_custom_auth type."""
579 - mock_auth_config = Mock(spec=auth_config_create_response.AuthConfig)
580 - mock_response = Mock(spec=auth_config_create_response.AuthConfigCreateResponse)
581 - mock_response.auth_config = mock_auth_config
582 - mock_client.auth_configs.create.return_value = mock_response
583 -
584 - options = {
585 - "type": "use_custom_auth",
586 - "auth_scheme": "API_KEY",
587 - "credentials": {"api_key": "test_key"},
588 - }
589 - result = auth_configs.create("github", options)
590 -
591 - assert result == mock_auth_config
592 -
593 - def test_update_overload_custom_type(self, auth_configs, mock_client):
594 - """Test update with custom type."""
595 - mock_response = auth_config_update_response.AuthConfigUpdateResponse(
596 - success=True, message="Successfully updated auth config"
597 - )
598 - mock_client.auth_configs.update.return_value = mock_response
599 -
600 - options = {
601 - "type": "custom",
602 - "credentials": {"api_key": "new_key"},
603 - }
604 - result = auth_configs.update("auth_12345", options=options)
605 -
606 - assert result == mock_response
607 -
608 - def test_update_overload_default_type(self, auth_configs, mock_client):
609 - """Test update with default type."""
610 - mock_response = auth_config_update_response.AuthConfigUpdateResponse(
611 - success=True, message="Successfully updated auth config"
612 - )
613 - mock_client.auth_configs.update.return_value = mock_response
614 -
615 - options = {
616 - "type": "default",
617 - "scopes": "read:user",
618 - }
619 - result = auth_configs.update("auth_12345", options=options)
620 -
621 - assert result == mock_response
622 -
390
391 @pytest.mark.parametrize(
392 ("operation", "method", "path", "response_type"),
@@ -692,6 +459,10 @@ def test_mutation_response_through_generated_client(
459 assert len(requests) == 1
460 assert requests[0].method == method
461 assert requests[0].url.path == path
462 + if operation == "update_default":
463 + assert json.loads(requests[0].content)["type"] == "default"
464 + elif operation == "update_custom":
465 + assert json.loads(requests[0].content)["type"] == "custom"
466 assert isinstance(result, response_type)
467 assert isinstance(result, BaseModel)
468 assert result.success is True
python/tests/test_core_types.py
-26
@@ -3,7 +3,6 @@
3 from composio.core.types import (
4 ToolkitLatestVersion,
5 ToolkitVersion,
6 - ToolkitVersionParam,
6 ToolkitVersions,
7 )
8
@@ -30,31 +29,6 @@ class TestCoreTypes:
29 assert hasattr(ToolkitVersions, "__origin__")
30 assert ToolkitVersions.__origin__ is dict
31
33 - def test_toolkit_version_param_is_union(self):
34 - """Test ToolkitVersionParam is union type."""
35 - # Should be Union[str, ToolkitVersions, None]
36 - assert hasattr(ToolkitVersionParam, "__origin__")
37 -
38 - def test_toolkit_version_param_accepts_string(self):
39 - """Test ToolkitVersionParam accepts string."""
40 - version: ToolkitVersionParam = "latest"
41 - assert version == "latest"
42 -
43 - version = "v1.0.0"
44 - assert version == "v1.0.0"
45 -
46 - def test_toolkit_version_param_accepts_dict(self):
47 - """Test ToolkitVersionParam accepts dictionary."""
48 - version: ToolkitVersionParam = {"github": "v1.0.0", "slack": "latest"}
49 - assert isinstance(version, dict)
50 - assert version["github"] == "v1.0.0"
51 - assert version["slack"] == "latest"
52 -
53 - def test_toolkit_version_param_accepts_none(self):
54 - """Test ToolkitVersionParam accepts None."""
55 - version: ToolkitVersionParam = None
56 - assert version is None
57 -
32 def test_all_types_exported(self):
33 """Test that all types are properly exported."""
34 from composio.core.types import __all__
python/tests/test_imports.py
-24
@@ -1,14 +1,5 @@
1 """Test imports to ensure no circular import issues."""
2
3 -import pytest
4 -
5 -
6 -def test_basic_import():
7 - """Test basic import of Composio class."""
8 - from composio import Composio
9 -
10 - assert Composio is not None
11 -
3
4 def test_import_all_public_exports():
5 """Test importing all public exports from composio package."""
@@ -111,18 +102,3 @@ def test_import_exceptions():
102
103 assert exceptions is not None
104 assert hasattr(exceptions, "ApiKeyNotProvidedError")
114 -
115 -
116 -def test_circular_import_prevention():
117 - """Test that circular imports are prevented."""
118 - # This test passes if no ImportError is raised during import
119 - try:
120 - from composio import Composio # noqa: F401
121 - from composio.core.models.tools import Tools # noqa: F401
122 - from composio.core.types import ToolkitVersion # noqa: F401
123 - from composio.types import ToolkitVersionParam # noqa: F401
124 -
125 - # If we get here, no circular import occurred
126 - assert True
127 - except ImportError as e:
128 - pytest.fail(f"Circular import detected: {e}")
python/tests/test_provider.py
-93
@@ -88,81 +88,10 @@ class TestProviderInitialization:
88 assert provider.name == "test_agentic"
89 assert isinstance(provider, AgenticProvider)
90
91 - def test_provider_has_name_attribute(self):
92 - """Test that all providers have a name attribute."""
93 - from composio.core.provider._openai import OpenAIProvider
94 -
95 - provider = OpenAIProvider()
96 - assert hasattr(provider, "name")
97 - assert isinstance(provider.name, str)
98 - assert len(provider.name) > 0
99 -
91
92 class TestProviderExecuteToolSetup:
93 """Test cases for execute_tool setup during initialization."""
94
104 - def test_execute_tool_set_during_tools_initialization_non_agentic(self):
105 - """Test that execute_tool is set during Tools initialization for non-agentic providers."""
106 - mock_client = mock_http_client()
107 - from composio.core.provider._openai import OpenAIProvider
108 -
109 - provider = OpenAIProvider()
110 -
111 - # Create Tools instance
112 - Tools(
113 - client=mock_client,
114 - provider=provider,
115 - toolkit_versions={"github": "12012025_00"},
116 - )
117 -
118 - # After initialization, provider should have execute_tool
119 - assert hasattr(provider, "execute_tool")
120 - assert provider.execute_tool is not None
121 - assert callable(provider.execute_tool)
122 -
123 - def test_execute_tool_set_during_tools_initialization_agentic(self):
124 - """Test that execute_tool is set during Tools initialization for agentic providers."""
125 - mock_client = mock_http_client()
126 -
127 - class TestAgenticProvider(AgenticProvider, name="test_agentic"):
128 - def wrap_tool(self, tool, execute_tool):
129 - return {"slug": tool.slug, "execute": execute_tool}
130 -
131 - def wrap_tools(self, tools, execute_tool):
132 - return [self.wrap_tool(tool, execute_tool) for tool in tools]
133 -
134 - provider = TestAgenticProvider()
135 -
136 - # Create Tools instance
137 - Tools(
138 - client=mock_client,
139 - provider=provider,
140 - toolkit_versions={"github": "12012025_00"},
141 - )
142 -
143 - # After initialization, provider should have execute_tool
144 - assert hasattr(provider, "execute_tool")
145 - assert provider.execute_tool is not None
146 - assert callable(provider.execute_tool)
147 -
148 - def test_execute_tool_available_immediately_after_initialization(self):
149 - """Test that execute_tool is available immediately after initialization, before get() is called."""
150 - mock_client = mock_http_client()
151 - from composio.core.provider._openai import OpenAIProvider
152 -
153 - provider = OpenAIProvider()
154 -
155 - # Create Tools instance (but don't call get())
156 - Tools(
157 - client=mock_client,
158 - provider=provider,
159 - toolkit_versions={"github": "12012025_00"},
160 - )
161 -
162 - # execute_tool should be available immediately
163 - assert hasattr(provider, "execute_tool")
164 - assert callable(provider.execute_tool)
165 -
95 def test_execute_tool_signature_matches_protocol(self):
96 """Test that execute_tool has the correct signature matching ExecuteToolFn protocol."""
97 mock_client = mock_http_client()
@@ -719,28 +648,6 @@ class TestNonAgenticProviderHelperMethods:
648 class TestAgenticProviderFunctionality:
649 """Test cases for agentic providers."""
650
722 - def test_agentic_provider_has_execute_tool_after_initialization(self):
723 - """Test that agentic providers have execute_tool after Tools initialization."""
724 - mock_client = mock_http_client()
725 -
726 - class TestAgenticProvider(AgenticProvider, name="test_agentic"):
727 - def wrap_tool(self, tool, execute_tool):
728 - return {"slug": tool.slug, "execute": execute_tool}
729 -
730 - def wrap_tools(self, tools, execute_tool):
731 - return [self.wrap_tool(tool, execute_tool) for tool in tools]
732 -
733 - provider = TestAgenticProvider()
734 -
735 - Tools(
736 - client=mock_client,
737 - provider=provider,
738 - toolkit_versions={"github": "12012025_00"},
739 - )
740 -
741 - assert hasattr(provider, "execute_tool")
742 - assert callable(provider.execute_tool)
743 -
651 def test_agentic_provider_execute_tool_works(self):
652 """Test that agentic provider's execute_tool executes tools correctly."""
653 mock_client = mock_http_client()
python/tests/test_sdk.py
-85
@@ -11,7 +11,6 @@ import pytest
11 from composio import Composio, exceptions
12 from composio.client import HttpClient
13 from composio.core.provider._openai import OpenAIProvider
14 -from composio.core.types import ToolkitVersionParam
14
15
16 class TestComposioSDK:
@@ -29,27 +28,6 @@ class TestComposioSDK:
28 with pytest.raises(exceptions.ApiKeyNotProvidedError):
29 Composio(api_key=None)
30
32 - def test_sdk_accepts_api_key_from_env(self):
33 - """Test that SDK accepts API key from environment."""
34 - with patch.dict(os.environ, {"COMPOSIO_API_KEY": "test-key"}):
35 - with patch("composio.core.models.Tools"):
36 - with patch("composio.core.models.Toolkits"):
37 - with patch("composio.core.models.Triggers"):
38 - with patch("composio.core.models.AuthConfigs"):
39 - with patch("composio.core.models.ConnectedAccounts"):
40 - sdk = Composio()
41 - assert sdk is not None
42 -
43 - def test_sdk_accepts_api_key_as_parameter(self):
44 - """Test that SDK accepts API key as parameter."""
45 - with patch("composio.core.models.Tools"):
46 - with patch("composio.core.models.Toolkits"):
47 - with patch("composio.core.models.Triggers"):
48 - with patch("composio.core.models.AuthConfigs"):
49 - with patch("composio.core.models.ConnectedAccounts"):
50 - sdk = Composio(api_key="test-key")
51 - assert sdk is not None
52 -
31 def test_sdk_forwards_user_and_org_api_keys_to_client(self):
32 """User and org keys reach the API client, which selects them per operation."""
33 sdk = Composio(
@@ -105,20 +83,6 @@ class TestComposioSDK:
83 }
84 assert set(SDKConfig.__annotations__.keys()) == expected_fields
85
108 - def test_toolkit_version_param_types(self):
109 - """Test toolkit version parameter types."""
110 - from composio.core.types import (
111 - ToolkitLatestVersion,
112 - ToolkitVersion,
113 - ToolkitVersions,
114 - )
115 -
116 - # Test that types are defined correctly
117 - assert ToolkitLatestVersion is not None
118 - assert ToolkitVersion is not None
119 - assert ToolkitVersions is not None
120 - assert ToolkitVersionParam is not None
121 -
86 def test_sdk_mounts_webhooks_and_logs(self):
87 from composio.core.models import Logs, Webhooks
88
@@ -160,20 +124,6 @@ class TestComposioSDK:
124 assert hasattr(sdk, "provider")
125 assert hasattr(sdk, "client")
126
163 - def test_sdk_default_provider(self):
164 - """Test that SDK uses default provider."""
165 - with patch.dict(os.environ, {"COMPOSIO_API_KEY": "test-key"}):
166 - with patch("composio.core.models.Tools"):
167 - with patch("composio.core.models.Toolkits"):
168 - with patch("composio.core.models.Triggers"):
169 - with patch("composio.core.models.AuthConfigs"):
170 - with patch("composio.core.models.ConnectedAccounts"):
171 - sdk = Composio()
172 -
173 - # Check that provider is set
174 - assert sdk.provider is not None
175 - assert hasattr(sdk.provider, "name")
176 -
127 def test_default_provider_is_isolated_per_instance(self):
128 """Regression test for #4369.
129
@@ -200,41 +150,6 @@ class TestComposioSDK:
150 sdk = Composio(provider=provider, api_key="key-a")
151 assert sdk.provider is provider
152
203 - def test_toolkit_versions_processing(self):
204 - """Test toolkit versions parameter processing."""
205 - with patch.dict(os.environ, {"COMPOSIO_API_KEY": "test-key"}):
206 - with patch("composio.core.models.Tools"):
207 - with patch("composio.core.models.Toolkits"):
208 - with patch("composio.core.models.Triggers"):
209 - with patch("composio.core.models.AuthConfigs"):
210 - with patch("composio.core.models.ConnectedAccounts"):
211 - with patch(
212 - "composio.sdk.get_toolkit_versions"
213 - ) as mock_get_versions:
214 - mock_get_versions.return_value = "latest"
215 -
216 - # Test with string version
217 - Composio(toolkit_versions="v1.0.0")
218 - mock_get_versions.assert_called_once()
219 -
220 - # Reset mock for next test
221 - mock_get_versions.reset_mock()
222 -
223 - # Test with dict version
224 - versions_dict = {
225 - "github": "v1.0.0",
226 - "slack": "latest",
227 - }
228 - Composio(toolkit_versions=versions_dict)
229 - mock_get_versions.assert_called_once()
230 -
231 - # Reset mock for next test
232 - mock_get_versions.reset_mock()
233 -
234 - # Test with None (default)
235 - Composio()
236 - mock_get_versions.assert_called_once()
237 -
153 def test_sdk_env_var_integration(self):
154 """Test that SDK properly integrates with environment variables for toolkit versions."""
155 with patch.dict(
python/tests/test_toolkit_version.py
-8
@@ -31,14 +31,6 @@ class TestToolkitVersion:
31 result = get_toolkit_version("github", None)
32 assert result == "latest"
33
34 - def test_get_toolkit_version_with_env_var(self):
35 - """Test get_toolkit_version with environment variable."""
36 - with pytest.MonkeyPatch().context():
37 - # The function doesn't directly use COMPOSIO_TOOLKIT_VERSION env var
38 - # It only looks at the toolkit_versions parameter
39 - result = get_toolkit_version("github", None)
40 - assert result == "latest"
41 -
34 def test_get_toolkit_versions_with_string(self):
35 """Test get_toolkit_versions with string parameter."""
36 result = get_toolkit_versions("v1.0.0")
ts/packages/cli/src/effect-errors/logic/errors/extract-error-details.test.ts deleted
-105
@@ -1,105 +0,0 @@
1 -import { describe, expect, it } from 'vitest';
2 -
3 -import { extractErrorDetails } from './extract-error-details';
4 -
5 -describe('extractErrorDetails function', () => {
6 - it('should handle plain strings', () => {
7 - const error = 'Oh no';
8 -
9 - const result = extractErrorDetails(error);
10 -
11 - expect(result).toStrictEqual({ isPlainString: true, message: error });
12 - });
13 -
14 - it('should preserve the actionable message for tagged errors with a cause', () => {
15 - const _tag = 'MyError';
16 - const message = 'Oh no!';
17 - const cause = 'Some cause';
18 -
19 - class MyError extends Error {
20 - constructor(message: string, cause: string) {
21 - super(message, { cause });
22 - }
23 -
24 - public _tag = _tag;
25 - }
26 - const error = new MyError(message, cause);
27 -
28 - const result = extractErrorDetails(error);
29 -
30 - expect(result).toStrictEqual({
31 - isPlainString: false,
32 - message: `${message}\nCaused by: ${cause}`,
33 - type: 'Error',
34 - });
35 - });
36 -
37 - it('should handle errors with Error ctor', () => {
38 - const message = 'Oh no!';
39 - const cause = 'Some cause';
40 -
41 - class MyError extends Error {
42 - constructor(message: string, cause: string) {
43 - super(message, { cause });
44 - }
45 - }
46 - const error = new MyError(message, cause);
47 -
48 - const result = extractErrorDetails(error);
49 -
50 - expect(result).toStrictEqual({
51 - isPlainString: false,
52 - message: [message],
53 - type: 'Error',
54 - });
55 - });
56 -
57 - it('should handle plain objects with tag attribute', () => {
58 - const error = {
59 - _tag: 'MyError',
60 - message: 'Oh no!',
61 - };
62 -
63 - const result = extractErrorDetails(error);
64 -
65 - expect(result).toStrictEqual({
66 - isPlainString: false,
67 - message: error.message,
68 - type: error['_tag'],
69 - });
70 - });
71 -
72 - it('should handle plain objects with toString impl', () => {
73 - const errorType = 'MyError';
74 - const error = {
75 - message: 'Oh no!',
76 - toString: () => `${errorType}: Oh no!`,
77 - };
78 -
79 - const result = extractErrorDetails(error);
80 -
81 - expect(result).toStrictEqual({
82 - isPlainString: false,
83 - message: [error.message],
84 - type: errorType,
85 - });
86 - });
87 -
88 - it('should handle plain objects with toString impl and underlying type', () => {
89 - const errorTypeWithUnderlyingType = 'MyError: Sucks to be you';
90 - const error = {
91 - message: 'Oh no!',
92 - toString: () => `${errorTypeWithUnderlyingType}: Oh no!`,
93 - };
94 -
95 - const result = extractErrorDetails(error);
96 -
97 - const [errorType, message] = errorTypeWithUnderlyingType.split(': ');
98 -
99 - expect(result).toStrictEqual({
100 - isPlainString: false,
101 - message: [message, error.message],
102 - type: errorType,
103 - });
104 - });
105 -});
ts/packages/cli/src/services/run-subagent-acp.ts
-41
@@ -1,5 +1,4 @@
1 import { createRequire } from 'node:module';
2 -import type { Readable } from 'node:stream';
2 import * as acp from '@agentclientprotocol/sdk';
3 import * as BunServices from '@effect/platform-bun/BunServices';
4 import {
@@ -69,46 +68,6 @@ const getLegacySetSessionModel = (
68 return Predicate.isFunction(method) ? async params => method.call(connection, params) : undefined;
69 };
70
72 -export const readableStreamFromNode = (input: Readable): ReadableStream<Uint8Array> => {
73 - let cleanup = () => undefined;
74 -
75 - return new ReadableStream<Uint8Array>({
76 - start: controller => {
77 - const onData = (chunk: Buffer | string) => {
78 - controller.enqueue(
79 - typeof chunk === 'string' ? new TextEncoder().encode(chunk) : Uint8Array.from(chunk)
80 - );
81 - if ((controller.desiredSize ?? 1) <= 0) {
82 - input.pause();
83 - }
84 - };
85 - const onEnd = () => {
86 - cleanup();
87 - controller.close();
88 - };
89 - const onError = (error: Error) => {
90 - cleanup();
91 - controller.error(error);
92 - };
93 - cleanup = () => {
94 - input.off('data', onData);
95 - input.off('end', onEnd);
96 - input.off('error', onError);
97 - };
98 - input.on('data', onData);
99 - input.once('end', onEnd);
100 - input.once('error', onError);
101 - },
102 - pull: () => {
103 - input.resume();
104 - },
105 - cancel: reason => {
106 - cleanup();
107 - input.destroy(reason instanceof Error ? reason : undefined);
108 - },
109 - });
110 -};
111 -
71 // Bridges the ACP connection's outgoing ndjson writes into an Effect Queue that
72 // a forked fiber drains into the child's stdin Sink. A bounded queue keeps the
73 // child's stdin backpressure visible to the ACP writer, and shutting the queue
ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts
-108
@@ -475,114 +475,6 @@ describe('generatePythonToolkitSources', () => {
475
476 assertPythonIsValid({ files: Object.fromEntries(sources) });
477 });
478 -
479 - it('[Given] multiple toolkits with different version overrides [Then] each file includes its version comment', () => {
480 - const toolkits = makeTestToolkits([
481 - {
482 - name: 'Gmail',
483 - slug: 'gmail',
484 - },
485 - {
486 - name: 'Slack Helper',
487 - slug: 'slack',
488 - },
489 - ]);
490 -
491 - const versionMap = new Map([
492 - ['gmail', '20250901_00'],
493 - ['slack', '20250815_00'],
494 - ]) as Map<Lowercase<string>, string>;
495 -
496 - const index = createToolkitIndex({
497 - toolkits,
498 - typeableTools: {
499 - withTypes: true,
500 - tools: [...TOOLS_TYPES_GMAIL.slice(0, 1)],
501 - },
502 - triggerTypes: [],
503 - versionMap,
504 - });
505 -
506 - const sources = generatePythonToolkitSources(BANNER)(index);
507 - expect(sources).toHaveLength(2);
508 -
509 - // Gmail should have its version comment
510 - expect(sources[0][0]).toBe('gmail.py');
511 - expect(sources[0][1]).toContain('# @toolkit-version: 20250901_00');
512 -
513 - // Slack should have its version comment
514 - expect(sources[1][0]).toBe('slack.py');
515 - expect(sources[1][1]).toContain('# @toolkit-version: 20250815_00');
516 -
517 - assertPythonIsValid({ files: Object.fromEntries(sources) });
518 - });
519 -
520 - it('[Given] only some toolkits with version override [Then] only those files include version comment', () => {
521 - const toolkits = makeTestToolkits([
522 - {
523 - name: 'Gmail',
524 - slug: 'gmail',
525 - },
526 - {
527 - name: 'Slack Helper',
528 - slug: 'slack',
529 - },
530 - ]);
531 -
532 - // Only gmail has a version override
533 - const versionMap = new Map([['gmail', '20250901_00']]) as Map<Lowercase<string>, string>;
534 -
535 - const index = createToolkitIndex({
536 - toolkits,
537 - typeableTools: {
538 - withTypes: true,
539 - tools: [...TOOLS_TYPES_GMAIL.slice(0, 1)],
540 - },
541 - triggerTypes: [],
542 - versionMap,
543 - });
544 -
545 - const sources = generatePythonToolkitSources(BANNER)(index);
546 - expect(sources).toHaveLength(2);
547 -
548 - // Gmail should have version comment
549 - expect(sources[0][0]).toBe('gmail.py');
550 - expect(sources[0][1]).toContain('# @toolkit-version: 20250901_00');
551 -
552 - // Slack should NOT have version comment
553 - expect(sources[1][0]).toBe('slack.py');
554 - expect(sources[1][1]).not.toContain('@toolkit-version');
555 -
556 - assertPythonIsValid({ files: Object.fromEntries(sources) });
557 - });
558 -
559 - it('[Given] empty versionMap [Then] no files include version comment', () => {
560 - const toolkits = makeTestToolkits([
561 - {
562 - name: 'Gmail',
563 - slug: 'gmail',
564 - },
565 - ]);
566 -
567 - const versionMap = new Map() as Map<Lowercase<string>, string>;
568 -
569 - const index = createToolkitIndex({
570 - toolkits,
571 - typeableTools: {
572 - withTypes: true,
573 - tools: [...TOOLS_TYPES_GMAIL.slice(0, 1)],
574 - },
575 - triggerTypes: [],
576 - versionMap,
577 - });
578 -
579 - const sources = generatePythonToolkitSources(BANNER)(index);
580 - expect(sources).toHaveLength(1);
581 - expect(sources[0][0]).toBe('gmail.py');
582 - expect(sources[0][1]).not.toContain('@toolkit-version');
583 -
584 - assertPythonIsValid({ files: Object.fromEntries(sources) });
585 - });
478 });
479 });
480 });
ts/packages/cli/test/src/services/config.test.ts
+1 -240
@@ -1,10 +1,9 @@
1 -import { beforeEach, describe, expect, it, vi } from '@effect/vitest';
1 +import { describe, expect, it } from '@effect/vitest';
2 import { deepStrictEqual } from '@effect/vitest/utils';
3
4 import { Config, ConfigProvider, Effect, Option } from 'effect';
5 import { APP_CONFIG, UNPREFIXED_CONFIG } from 'src/effects/app-config';
6 import { extendConfigProvider } from 'src/services/config';
7 -import { liveEnvConfigProvider } from '../../__utils__/live-env-config-provider';
7 import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
8 import * as constants from 'src/constants';
9
@@ -457,242 +456,4 @@ describe('Config', () => {
456 );
457 });
458 });
460 -
461 - describe('[When] using `ConfigProvider.env`', () => {
462 - const withEnvConfigProvider = Effect.provideService(
463 - ConfigProvider.ConfigProvider,
464 - extendConfigProvider(liveEnvConfigProvider)
465 - );
466 -
467 - // These cases assert what the config resolves from a clean environment,
468 - // but the developer's shell (direnv) and the shared vitest setup both
469 - // export COMPOSIO_* variables. Neutralize every APP_CONFIG input.
470 - beforeEach(() => {
471 - vi.stubEnv('COMPOSIO_USER_API_KEY', undefined);
472 - vi.stubEnv('COMPOSIO_ENVIRONMENT', undefined);
473 - vi.stubEnv('COMPOSIO_BASE_URL', undefined);
474 - vi.stubEnv('COMPOSIO_WEB_URL', undefined);
475 - vi.stubEnv('COMPOSIO_CACHE_DIR', undefined);
476 - vi.stubEnv('COMPOSIO_SESSION_DIR', undefined);
477 - vi.stubEnv('COMPOSIO_BIN_DIR', undefined);
478 - vi.stubEnv('COMPOSIO_LOG_LEVEL', undefined);
479 - vi.stubEnv('COMPOSIO_ORG_ID', undefined);
480 - vi.stubEnv('COMPOSIO_PROJECT_ID', undefined);
481 - vi.stubEnv('COMPOSIO_AGENTS_BASE_URL', undefined);
482 - vi.stubEnv('COMPOSIO_WEBHOOK_SECRET', undefined);
483 - vi.stubEnv('COMPOSIO_CLI_INVOCATION_ORIGIN', undefined);
484 - vi.stubEnv('COMPOSIO_CLI_PARENT_RUN_ID', undefined);
485 - vi.stubEnv('COMPOSIO_RUN_ACP_ONLY', undefined);
486 - vi.stubEnv('COMPOSIO_RUN_OUTPUT_DIR', undefined);
487 - vi.stubEnv('COMPOSIO_PERF_DEBUG', undefined);
488 - vi.stubEnv('COMPOSIO_TOOL_DEBUG', undefined);
489 - vi.stubEnv('COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', undefined);
490 - });
491 -
492 - describe('APP_CONFIG', () => {
493 - it.effect('[When] no env variable is set', () =>
494 - Effect.gen(function* () {
495 - const actual = yield* withEnvConfigProvider(Config.all(APP_CONFIG));
496 -
497 - deepStrictEqual(actual, {
498 - USER_API_KEY: Option.none(),
499 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
500 - ENVIRONMENT: Option.none(),
501 - BASE_URL: 'https://backend.composio.dev',
502 - WEB_URL: 'https://dashboard.composio.dev/',
503 - LOG_LEVEL: Option.none(),
504 - ORG_ID: Option.none(),
505 - PROJECT_ID: Option.none(),
506 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
507 - });
508 - })
509 - );
510 -
511 - it.effect('[When] env variables are set without `COMPOSIO_` prefix', () =>
512 - Effect.gen(function* () {
513 - vi.stubEnv('USER_API_KEY', 'api_key');
514 - vi.stubEnv('BASE_URL', 'https://test.localhost');
515 - vi.stubEnv('CACHE_DIR', '~/.composio');
516 - vi.stubEnv('LOG_LEVEL', 'info');
517 -
518 - const actual = yield* withEnvConfigProvider(Config.all(APP_CONFIG));
519 -
520 - deepStrictEqual(actual, {
521 - USER_API_KEY: Option.none(),
522 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
523 - ENVIRONMENT: Option.none(),
524 - BASE_URL: 'https://backend.composio.dev',
525 - WEB_URL: 'https://dashboard.composio.dev/',
526 - LOG_LEVEL: Option.none(),
527 - ORG_ID: Option.none(),
528 - PROJECT_ID: Option.none(),
529 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
530 - });
531 - })
532 - );
533 -
534 - it.effect('[When] env variables are set with `COMPOSIO_` prefix', () =>
535 - Effect.gen(function* () {
536 - vi.stubEnv('COMPOSIO_USER_API_KEY', 'api_key');
537 - vi.stubEnv('COMPOSIO_BASE_URL', 'https://test.localhost');
538 - vi.stubEnv('COMPOSIO_WEB_URL', 'https://test.localhost');
539 - vi.stubEnv('COMPOSIO_CACHE_DIR', '~/.composio');
540 - vi.stubEnv('COMPOSIO_SESSION_DIR', '/tmp/composio-sessions');
541 - vi.stubEnv('COMPOSIO_BIN_DIR', '/usr/local/bin');
542 - vi.stubEnv('COMPOSIO_LOG_LEVEL', 'Info');
543 - vi.stubEnv('COMPOSIO_AGENTS_BASE_URL', 'https://agents.test.localhost');
544 - vi.stubEnv('COMPOSIO_WEBHOOK_SECRET', 'secret');
545 - vi.stubEnv('COMPOSIO_CLI_INVOCATION_ORIGIN', 'run');
546 - vi.stubEnv('COMPOSIO_CLI_PARENT_RUN_ID', 'run_parent');
547 - vi.stubEnv('COMPOSIO_RUN_ACP_ONLY', '1');
548 - vi.stubEnv('COMPOSIO_RUN_OUTPUT_DIR', '/tmp/composio-output');
549 - vi.stubEnv('COMPOSIO_PERF_DEBUG', '1');
550 - vi.stubEnv('COMPOSIO_TOOL_DEBUG', '1');
551 -
552 - const actual = yield* withEnvConfigProvider(Config.all(APP_CONFIG));
553 -
554 - deepStrictEqual(actual, {
555 - USER_API_KEY: Option.some('api_key'),
556 - ENVIRONMENT: Option.none(),
557 - BASE_URL: 'https://test.localhost',
558 - WEB_URL: 'https://test.localhost',
559 - CACHE_DIR: '~/.composio',
560 - SESSION_DIR: '/tmp/composio-sessions',
561 - BIN_DIR: '/usr/local/bin',
562 - LOG_LEVEL: Option.some('Info' as const),
563 - ORG_ID: Option.none(),
564 - PROJECT_ID: Option.none(),
565 - AGENTS_BASE_URL: 'https://agents.test.localhost',
566 - WEBHOOK_SECRET: 'secret',
567 - CLI_INVOCATION_ORIGIN: 'run',
568 - CLI_PARENT_RUN_ID: 'run_parent',
569 - RUN_ACP_ONLY: true,
570 - RUN_OUTPUT_DIR: '/tmp/composio-output',
571 - PERF_DEBUG: true,
572 - TOOL_DEBUG: true,
573 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
574 - });
575 - })
576 - );
577 -
578 - it.effect('[When] COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE is "false"', () =>
579 - Effect.gen(function* () {
580 - vi.stubEnv('COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', 'false');
581 -
582 - const actual = yield* withEnvConfigProvider(Config.all(APP_CONFIG));
583 -
584 - deepStrictEqual(actual, {
585 - USER_API_KEY: Option.none(),
586 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
587 - ENVIRONMENT: Option.none(),
588 - BASE_URL: 'https://backend.composio.dev',
589 - WEB_URL: 'https://dashboard.composio.dev/',
590 - LOG_LEVEL: Option.none(),
591 - ORG_ID: Option.none(),
592 - PROJECT_ID: Option.none(),
593 - DISABLE_CONNECTED_ACCOUNT_CACHE: false,
594 - });
595 - })
596 - );
597 -
598 - it.effect('[When] COMPOSIO_ENVIRONMENT is "staging"', () =>
599 - Effect.gen(function* () {
600 - vi.stubEnv('COMPOSIO_ENVIRONMENT', 'staging');
601 -
602 - const actual = yield* withEnvConfigProvider(Config.all(APP_CONFIG));
603 -
604 - deepStrictEqual(actual, {
605 - USER_API_KEY: Option.none(),
606 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
607 - ENVIRONMENT: Option.some('staging'),
608 - BASE_URL: constants.STAGING_BASE_URL,
609 - WEB_URL: 'https://staging-dashboard.composio.dev/',
610 - LOG_LEVEL: Option.none(),
611 - ORG_ID: Option.none(),
612 - PROJECT_ID: Option.none(),
613 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
614 - });
615 - })
616 - );
617 -
618 - it.effect('[When] COMPOSIO_ENVIRONMENT is "staging" but explicit URLs override', () =>
619 - Effect.gen(function* () {
620 - vi.stubEnv('COMPOSIO_ENVIRONMENT', 'staging');
621 - vi.stubEnv('COMPOSIO_BASE_URL', 'https://custom.localhost');
622 - vi.stubEnv('COMPOSIO_WEB_URL', 'https://custom-web.localhost');
623 -
624 - const actual = yield* withEnvConfigProvider(Config.all(APP_CONFIG));
625 -
626 - deepStrictEqual(actual, {
627 - USER_API_KEY: Option.none(),
628 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
629 - ENVIRONMENT: Option.some('staging'),
630 - BASE_URL: 'https://custom.localhost',
631 - WEB_URL: 'https://custom-web.localhost',
632 - LOG_LEVEL: Option.none(),
633 - ORG_ID: Option.none(),
634 - PROJECT_ID: Option.none(),
635 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
636 - });
637 - })
638 - );
639 - });
640 -
641 - describe('DEBUG_OVERRIDE_CONFIG', () => {
642 - it.effect('[When] no env variable is set', () =>
643 - Effect.gen(function* () {
644 - const actual = yield* withEnvConfigProvider(Config.all(DEBUG_OVERRIDE_CONFIG));
645 -
646 - deepStrictEqual(actual, {
647 - UPGRADE_TARGET: Option.none(),
648 - VERSION: Option.none(),
649 - });
650 - })
651 - );
652 -
653 - it.effect('[When] env variables are set without `DEBUG_OVERRIDE_` prefix', () =>
654 - Effect.gen(function* () {
655 - vi.stubEnv('UPGRADE_TARGET', 'upgrade_target');
656 - vi.stubEnv('VERSION', 'x.x.x');
657 -
658 - const actual = yield* withEnvConfigProvider(Config.all(DEBUG_OVERRIDE_CONFIG));
659 -
660 - deepStrictEqual(actual, {
661 - UPGRADE_TARGET: Option.none(),
662 - VERSION: Option.none(),
663 - });
664 - })
665 - );
666 -
667 - it.effect(
668 - '[When] env variables are set without `DEBUG_OVERRIDE_` but with `COMPOSIO_` prefix',
669 - () =>
670 - Effect.gen(function* () {
671 - vi.stubEnv('COMPOSIO_UPGRADE_TARGET', 'upgrade_target');
672 - vi.stubEnv('COMPOSIO_VERSION', 'x.x.x');
673 -
674 - const actual = yield* withEnvConfigProvider(Config.all(DEBUG_OVERRIDE_CONFIG));
675 -
676 - deepStrictEqual(actual, {
677 - UPGRADE_TARGET: Option.none(),
678 - VERSION: Option.none(),
679 - });
680 - })
681 - );
682 -
683 - it.effect('[When] env variables are set with `DEBUG_OVERRIDE_` prefix', () =>
684 - Effect.gen(function* () {
685 - vi.stubEnv('DEBUG_OVERRIDE_UPGRADE_TARGET', 'upgrade_target');
686 - vi.stubEnv('DEBUG_OVERRIDE_VERSION', 'x.x.x');
687 -
688 - const actual = yield* withEnvConfigProvider(Config.all(DEBUG_OVERRIDE_CONFIG));
689 -
690 - deepStrictEqual(actual, {
691 - UPGRADE_TARGET: Option.some('upgrade_target'),
692 - VERSION: Option.some('x.x.x'),
693 - });
694 - })
695 - );
696 - });
697 - });
459 });
ts/packages/cli/test/src/services/run-subagent-acp.test.ts
-23
@@ -1,7 +1,6 @@
1 import * as fs from 'node:fs';
2 import * as os from 'node:os';
3 import * as path from 'node:path';
4 -import { Readable } from 'node:stream';
4 import * as BunServices from '@effect/platform-bun/BunServices';
5 import { Effect } from 'effect';
6 import { afterEach, describe, expect, it, vi } from '@effect/vitest';
@@ -9,7 +8,6 @@ import {
8 BufferedChunkLogger,
9 createStructuredOutputMcpContext,
10 MissingAcpAdapterAssetsError,
12 - readableStreamFromNode,
11 resolveAcpAdapterCommand,
12 selectPermissionOutcome,
13 } from 'src/services/run-subagent-acp';
@@ -21,27 +19,6 @@ describe('run-subagent-acp', () => {
19 vi.unstubAllGlobals();
20 });
21
24 - it('pauses a Node producer while the Web Stream queue is full', async () => {
25 - const input = new Readable({ read: () => undefined });
26 - const stream = readableStreamFromNode(input);
27 -
28 - input.push(new TextEncoder().encode('first'));
29 - input.push(new TextEncoder().encode('second'));
30 - await new Promise<void>(resolve => setImmediate(resolve));
31 -
32 - expect(input.isPaused()).toBe(true);
33 -
34 - const reader = stream.getReader();
35 - const first = await reader.read();
36 - const second = await reader.read();
37 -
38 - expect(new TextDecoder().decode(first.value)).toBe('first');
39 - expect(new TextDecoder().decode(second.value)).toBe('second');
40 -
41 - await reader.cancel();
42 - expect(input.destroyed).toBe(true);
43 - });
44 -
22 it.effect(
23 '[Given] bundled adapter packages [Then] it resolves to the bundled path without npx',
24 () =>
ts/packages/core/src/models/AuthConfigs.ts
-9
@@ -45,15 +45,6 @@ export class AuthConfigs {
45 telemetry.instrument(this, 'AuthConfigs');
46 }
47
48 - /**
49 - * Protected getter for the client instance.
50 - * This is primarily used for testing purposes.
51 - * @protected
52 - */
53 - protected getClient(): ComposioClient {
54 - return this.client;
55 - }
56 -
48 /**
49 * Lists authentication configurations based on provided filter criteria.
50 *
ts/packages/core/test/AuthConfigs/authConfigs.test.ts
-11
@@ -88,17 +88,6 @@ describe('AuthConfigs', () => {
88 authConfigs = new AuthConfigs(mockClient as unknown as ComposioClient);
89 });
90
91 - describe('constructor', () => {
92 - it('should create an instance successfully with valid client', () => {
93 - expect(authConfigs).toBeInstanceOf(AuthConfigs);
94 - });
95 -
96 - it('should have protected getClient method for testing', () => {
97 - // @ts-expect-error - Accessing protected method for testing
98 - expect(authConfigs.getClient()).toBe(mockClient);
99 - });
100 - });
101 -
91 describe('parseAuthConfigRetrieveResponse', () => {
92 it('should transform API response to SDK format correctly', () => {
93 const result = transformAuthConfigRetrieveResponse(mockComposioAuthConfigResponse);
ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
-101
@@ -56,18 +56,6 @@ describe('ConnectedAccounts', () => {
56 connectedAccounts = new ConnectedAccounts(extendedMockClient as unknown as ComposioClient);
57 });
58
59 - describe('constructor', () => {
60 - it('should create an instance successfully with valid client', () => {
61 - expect(connectedAccounts).toBeInstanceOf(ConnectedAccounts);
62 - });
63 -
64 - it('should not throw an error if client is provided', () => {
65 - expect(
66 - () => new ConnectedAccounts(extendedMockClient as unknown as ComposioClient)
67 - ).not.toThrow();
68 - });
69 - });
70 -
59 describe('list', () => {
60 it('should call client.connectedAccounts.list with the provided query', async () => {
61 const query = { limit: 10 };
@@ -1281,69 +1269,6 @@ describe('ConnectedAccounts', () => {
1269 expect(extendedMockClient.link.create).not.toHaveBeenCalled();
1270 });
1271
1284 - it('should handle undefined options gracefully', async () => {
1285 - const userId = 'user_123';
1286 - const authConfigId = 'auth_config_123';
1287 -
1288 - const mockLinkResponse = {
1289 - connected_account_id: 'conn_456def',
1290 - redirect_url: 'https://connect.composio.dev/auth?token=abc123',
1291 - };
1292 -
1293 - extendedMockClient.link.create.mockResolvedValueOnce(mockLinkResponse);
1294 -
1295 - const connectionRequest = await connectedAccounts.link(userId, authConfigId, undefined);
1296 -
1297 - expect(extendedMockClient.link.create).toHaveBeenCalledWith(
1298 - {
1299 - auth_config_id: authConfigId,
1300 - user_id: userId,
1301 - },
1302 - undefined
1303 - );
1304 -
1305 - expect(connectionRequest).toHaveProperty('id', 'conn_456def');
1306 - expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);
1307 - expect(connectionRequest).toHaveProperty(
1308 - 'redirectUrl',
1309 - 'https://connect.composio.dev/auth?token=abc123'
1310 - );
1311 - expect(connectionRequest).toHaveProperty('waitForConnection');
1312 - expect(typeof connectionRequest.waitForConnection).toBe('function');
1313 - });
1314 -
1315 - it('should handle empty options object gracefully', async () => {
1316 - const userId = 'user_123';
1317 - const authConfigId = 'auth_config_123';
1318 - const options = {};
1319 -
1320 - const mockLinkResponse = {
1321 - connected_account_id: 'conn_456def',
1322 - redirect_url: 'https://connect.composio.dev/auth?token=abc123',
1323 - };
1324 -
1325 - extendedMockClient.link.create.mockResolvedValueOnce(mockLinkResponse);
1326 -
1327 - const connectionRequest = await connectedAccounts.link(userId, authConfigId, options);
1328 -
1329 - expect(extendedMockClient.link.create).toHaveBeenCalledWith(
1330 - {
1331 - auth_config_id: authConfigId,
1332 - user_id: userId,
1333 - },
1334 - undefined
1335 - );
1336 -
1337 - expect(connectionRequest).toHaveProperty('id', 'conn_456def');
1338 - expect(connectionRequest).toHaveProperty('status', ConnectedAccountStatuses.INITIATED);
1339 - expect(connectionRequest).toHaveProperty(
1340 - 'redirectUrl',
1341 - 'https://connect.composio.dev/auth?token=abc123'
1342 - );
1343 - expect(connectionRequest).toHaveProperty('waitForConnection');
1344 - expect(typeof connectionRequest.waitForConnection).toBe('function');
1345 - });
1346 -
1272 it('should return a ConnectionRequest with the expected structure', async () => {
1273 const userId = 'user_123';
1274 const authConfigId = 'auth_config_123';
@@ -1528,32 +1453,6 @@ describe('ConnectedAccounts', () => {
1453 expect(callArgs).not.toHaveProperty('callback_url');
1454 });
1455
1531 - it('should include callback_url in API call only when callbackUrl is provided', async () => {
1532 - const userId = 'user_123';
1533 - const authConfigId = 'auth_config_123';
1534 - const options = {
1535 - callbackUrl: 'https://example.com/callback',
1536 - };
1537 -
1538 - const mockLinkResponse = {
1539 - connected_account_id: 'conn_456def',
1540 - redirect_url: 'https://connect.composio.dev/auth?token=abc123',
1541 - };
1542 -
1543 - extendedMockClient.link.create.mockResolvedValueOnce(mockLinkResponse);
1544 -
1545 - await connectedAccounts.link(userId, authConfigId, options);
1546 -
1547 - expect(extendedMockClient.link.create).toHaveBeenCalledWith(
1548 - {
1549 - auth_config_id: authConfigId,
1550 - user_id: userId,
1551 - callback_url: 'https://example.com/callback',
1552 - },
1553 - undefined
1554 - );
1555 - });
1556 -
1456 it('throws ComposioMultipleConnectedAccountsError when an active connection exists and allowMultiple is false', async () => {
1457 const userId = 'user_123';
1458 const authConfigId = 'auth_config_123';
ts/packages/core/test/models/toolRouter.test.ts
-4
@@ -193,10 +193,6 @@ describe('ToolRouter', () => {
193 expect(telemetry.instrument).toHaveBeenCalledWith(toolRouter, 'ToolRouter');
194 });
195
196 - it('should store the client reference', () => {
197 - expect(toolRouter['client']).toBe(mockClient);
198 - });
199 -
196 it('should store the config reference', () => {
197 expect(toolRouter['config']).toEqual({ provider: mockProvider, apiKey: 'test-api-key' });
198 });
ts/packages/core/test/models/toolkits.test.ts
-4
@@ -119,10 +119,6 @@ describe('Toolkits', () => {
119 expect(toolkits).toBeInstanceOf(Toolkits);
120 expect(telemetry.instrument).toHaveBeenCalledWith(toolkits, 'Toolkits');
121 });
122 -
123 - it('should store the client reference', () => {
124 - expect(toolkits['client']).toBe(mockClient);
125 - });
122 });
123
124 describe('get', () => {
ts/packages/core/test/models/triggers.test.ts
-76
@@ -240,10 +240,6 @@ describe('Triggers', () => {
240 expect(triggers).toBeInstanceOf(Triggers);
241 expect(telemetry.instrument).toHaveBeenCalledWith(triggers, 'Triggers');
242 });
243 -
244 - it('should store the client reference', () => {
245 - expect(triggers['client']).toBe(mockClient);
246 - });
243 });
244
245 describe('setWebhookSubscription', () => {
@@ -1068,12 +1064,6 @@ describe('Triggers', () => {
1064 });
1065 });
1066
1071 - describe('telemetry integration', () => {
1072 - it('should instrument the class for telemetry', () => {
1073 - expect(telemetry.instrument).toHaveBeenCalledWith(triggers, 'Triggers');
1074 - });
1075 - });
1076 -
1067 describe('subscribe callback handling', () => {
1068 const mockCallback = vi.fn();
1069
@@ -1082,35 +1072,6 @@ describe('Triggers', () => {
1072 vi.mocked(logger.debug).mockClear();
1073 });
1074
1085 - it('should pass the parsed trigger data to callback when filters match', async () => {
1086 - await triggers.subscribe(mockCallback);
1087 -
1088 - const subscribeCall = vi.mocked(mockPusherService.subscribe).mock.calls[0];
1089 - const filterCallback = subscribeCall[0];
1090 -
1091 - filterCallback(mockTriggerData);
1092 -
1093 - expect(mockCallback).toHaveBeenCalledTimes(1);
1094 - expect(mockCallback).toHaveBeenCalledWith(
1095 - expect.objectContaining({
1096 - id: 'trigger-123-nano',
1097 - uuid: 'trigger-123',
1098 - metadata: expect.objectContaining({
1099 - id: 'trigger-123-nano',
1100 - uuid: 'trigger-123',
1101 - connectedAccount: expect.objectContaining({
1102 - id: 'conn-123',
1103 - uuid: 'conn-123',
1104 - authConfigId: 'auth-123',
1105 - authConfigUUID: 'github',
1106 - userId: 'user-456',
1107 - status: 'ACTIVE',
1108 - }),
1109 - }),
1110 - })
1111 - );
1112 - });
1113 -
1075 it('should not call callback when trigger data does not match filters', async () => {
1076 const filters: TriggerSubscribeParams = {
1077 toolkits: ['slack'], // Different toolkit than the mock data
@@ -1145,43 +1106,6 @@ describe('Triggers', () => {
1106 Error('Error in user callback')
1107 );
1108 });
1148 -
1149 - it('should handle multiple callbacks with different filters', async () => {
1150 - const callback1 = vi.fn();
1151 - const callback2 = vi.fn();
1152 -
1153 - // Subscribe with different filters
1154 - await triggers.subscribe(callback1, { toolkits: ['github'] });
1155 - await triggers.subscribe(callback2, { toolkits: ['slack'] });
1156 -
1157 - const subscribeCall1 = vi.mocked(mockPusherService.subscribe).mock.calls[0];
1158 - const subscribeCall2 = vi.mocked(mockPusherService.subscribe).mock.calls[1];
1159 -
1160 - // Trigger github event
1161 - subscribeCall1[0](mockTriggerData);
1162 - // Trigger should only call callback1
1163 - expect(callback1).toHaveBeenCalledTimes(1);
1164 - expect(callback2).not.toHaveBeenCalled();
1165 -
1166 - // Reset mocks
1167 - callback1.mockClear();
1168 - callback2.mockClear();
1169 -
1170 - // Trigger slack event
1171 - const slackTriggerData = {
1172 - ...mockTriggerData,
1173 - appName: 'slack',
1174 - metadata: {
1175 - ...mockTriggerData.metadata,
1176 - triggerName: 'slack_message',
1177 - },
1178 - };
1179 -
1180 - subscribeCall2[0](slackTriggerData);
1181 - // Trigger should only call callback2
1182 - expect(callback1).not.toHaveBeenCalled();
1183 - expect(callback2).toHaveBeenCalledTimes(1);
1184 - });
1109 });
1110
1111 describe('parsePusherPayload (V1/V2/V3 format support)', () => {
ts/packages/providers/anthropic/test/anthropic.test.ts
-77
@@ -436,42 +436,6 @@ describe('AnthropicProvider', () => {
436 });
437 });
438
439 - describe('executeTool', () => {
440 - it('should execute a tool using the global execute function', async () => {
441 - const toolSlug = 'test-tool';
442 - const toolParams = {
443 - userId: 'test-user',
444 - arguments: { input: 'test-value' },
445 - };
446 -
447 - const result = await provider.executeTool(toolSlug, toolParams);
448 -
449 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
450 - expect(result).toEqual({
451 - data: { result: 'success' },
452 - error: null,
453 - successful: true,
454 - });
455 - });
456 -
457 - it('should pass modifiers to the global execute function', async () => {
458 - const toolSlug = 'test-tool';
459 - const toolParams = {
460 - userId: 'test-user',
461 - arguments: { input: 'test-value' },
462 - };
463 -
464 - const modifiers = {
465 - beforeExecute: vi.fn(({ params }) => params),
466 - afterExecute: vi.fn(({ result }) => result),
467 - };
468 -
469 - await provider.executeTool(toolSlug, toolParams, modifiers);
470 -
471 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
472 - });
473 - });
474 -
439 describe('MCP functionality', () => {
440 describe('wrapMcpServerResponse', () => {
441 it('should transform McpUrlResponse to AnthropicMcpServerGetResponse format', () => {
@@ -511,20 +475,6 @@ describe('AnthropicProvider', () => {
475 expect(result).toHaveLength(0);
476 });
477
514 - it('should handle single item array', () => {
515 - const mcpResponse = [{ name: 'single-server', url: 'https://single.example.com' }];
516 -
517 - const result = provider.wrapMcpServerResponse(mcpResponse);
518 -
519 - expect(Array.isArray(result)).toBe(true);
520 - expect(result).toHaveLength(1);
521 - expect(result[0]).toEqual({
522 - url: 'https://single.example.com',
523 - name: 'single-server',
524 - type: 'url',
525 - });
526 - });
527 -
478 it('should preserve URL strings exactly', () => {
479 const mcpResponse = [
480 { name: 'http-server', url: 'http://insecure.example.com' },
@@ -551,32 +501,5 @@ describe('AnthropicProvider', () => {
501 });
502 });
503 });
554 -
555 - describe('MCP integration with provider', () => {
556 - it('should correctly type the MCP response transformation', () => {
557 - const mcpResponse = [{ name: 'test-server', url: 'https://test.example.com' }];
558 -
559 - const result = provider.wrapMcpServerResponse(mcpResponse);
560 -
561 - // TypeScript should infer this as AnthropicMcpServerGetResponse
562 - expect(result[0]).toHaveProperty('url');
563 - expect(result[0]).toHaveProperty('name');
564 - expect(result[0]).toHaveProperty('type');
565 - expect(result[0].url).toBe('https://test.example.com');
566 - expect(result[0].type).toBe('url');
567 - });
568 -
569 - it('should work with MCP provider instance', () => {
570 - // Verify the provider can transform MCP responses
571 - const newProvider = new AnthropicProvider();
572 - const testResponse = [{ name: 'test', url: 'https://test.com' }];
573 -
574 - const result = newProvider.wrapMcpServerResponse(testResponse);
575 - expect(result).toHaveLength(1);
576 - expect(result[0].name).toBe('test');
577 - expect(result[0].url).toBe('https://test.com');
578 - expect(result[0].type).toBe('url');
579 - });
580 - });
504 });
505 });
ts/packages/providers/claude-agent-sdk/test/claude-agent-sdk.test.ts
-36
@@ -340,42 +340,6 @@ describe('ClaudeAgentSDKProvider', () => {
340 });
341 });
342
343 - describe('executeTool', () => {
344 - it('should execute a tool using the global execute function', async () => {
345 - const toolSlug = 'GMAIL_SEND_EMAIL';
346 - const toolParams = {
347 - userId: 'test-user',
348 - arguments: { to: 'test@example.com', subject: 'Test', body: 'Hello' },
349 - };
350 -
351 - const result = await provider.executeTool(toolSlug, toolParams);
352 -
353 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
354 - expect(result).toEqual({
355 - data: { result: 'success' },
356 - error: null,
357 - successful: true,
358 - });
359 - });
360 -
361 - it('should pass modifiers to the global execute function', async () => {
362 - const toolSlug = 'GMAIL_SEND_EMAIL';
363 - const toolParams = {
364 - userId: 'test-user',
365 - arguments: { to: 'test@example.com', subject: 'Test', body: 'Hello' },
366 - };
367 -
368 - const modifiers = {
369 - beforeExecute: vi.fn(({ params }) => params),
370 - afterExecute: vi.fn(({ result }) => result),
371 - };
372 -
373 - await provider.executeTool(toolSlug, toolParams, modifiers);
374 -
375 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
376 - });
377 - });
378 -
343 describe('JSON Schema to Zod conversion', () => {
344 it('should handle various property types', () => {
345 const toolWithVariousTypes: Tool = {
ts/packages/providers/cloudflare/test/cloudflare.test.ts
-36
@@ -271,42 +271,6 @@ describe('CloudflareProvider', () => {
271 });
272 });
273
274 - describe('executeTool', () => {
275 - it('should execute a tool using the global execute function', async () => {
276 - const toolSlug = 'test-tool';
277 - const toolParams = {
278 - userId: 'test-user',
279 - arguments: { input: 'test-value' },
280 - };
281 -
282 - const result = await provider.executeTool(toolSlug, toolParams);
283 -
284 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
285 - expect(result).toEqual({
286 - data: { result: 'success' },
287 - error: null,
288 - successful: true,
289 - });
290 - });
291 -
292 - it('should pass modifiers to the global execute function', async () => {
293 - const toolSlug = 'test-tool';
294 - const toolParams = {
295 - userId: 'test-user',
296 - arguments: { input: 'test-value' },
297 - };
298 -
299 - const modifiers = {
300 - beforeExecute: vi.fn(({ params }) => params),
301 - afterExecute: vi.fn(({ result }) => result),
302 - };
303 -
304 - await provider.executeTool(toolSlug, toolParams, modifiers);
305 -
306 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
307 - });
308 - });
309 -
274 describe('integration with Cloudflare AI', () => {
275 it('should produce tools compatible with Cloudflare AI', () => {
276 const wrapped = provider.wrapTool(mockTool) as MockedCloudflareToolInput;
ts/packages/providers/google/test/google.test.ts
-36
@@ -248,40 +248,4 @@ describe('GoogleProvider', () => {
248 );
249 });
250 });
251 -
252 - describe('executeTool', () => {
253 - it('should execute a tool using the global execute function', async () => {
254 - const toolSlug = 'test-tool';
255 - const toolParams = {
256 - userId: 'test-user',
257 - arguments: { input: 'test-value' },
258 - };
259 -
260 - const result = await provider.executeTool(toolSlug, toolParams);
261 -
262 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
263 - expect(result).toEqual({
264 - data: { result: 'success' },
265 - error: null,
266 - successful: true,
267 - });
268 - });
269 -
270 - it('should pass modifiers to the global execute function', async () => {
271 - const toolSlug = 'test-tool';
272 - const toolParams = {
273 - userId: 'test-user',
274 - arguments: { input: 'test-value' },
275 - };
276 -
277 - const modifiers = {
278 - beforeExecute: vi.fn(({ params }) => params),
279 - afterExecute: vi.fn(({ result }) => result),
280 - };
281 -
282 - await provider.executeTool(toolSlug, toolParams, modifiers);
283 -
284 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
285 - });
286 - });
251 });
ts/packages/providers/llamaindex/test/llamaindex.test.ts
-13
@@ -265,19 +265,6 @@ describe('LlamaindexProvider', () => {
265 expect(result).toHaveLength(0);
266 });
267
268 - it('should handle single item array', () => {
269 - const mcpResponse = [{ name: 'single-server', url: 'https://single.example.com' }];
270 -
271 - const result = provider.wrapMcpServerResponse(mcpResponse);
272 -
273 - expect(Array.isArray(result)).toBe(true);
274 - expect(result).toHaveLength(1);
275 - expect(result[0]).toEqual({
276 - url: new URL('https://single.example.com'),
277 - name: 'single-server',
278 - });
279 - });
280 -
268 it('should create proper URL objects from string URLs', () => {
269 const mcpResponse = [
270 { name: 'http-server', url: 'http://insecure.example.com' },
ts/packages/providers/mastra/test/mastra.test.ts
-140
@@ -382,87 +382,7 @@ describe('MastraProvider', () => {
382 });
383 });
384
385 - describe('executeTool', () => {
386 - it('should execute a tool using the global execute function', async () => {
387 - const toolSlug = 'test-tool';
388 - const toolParams = {
389 - userId: 'test-user',
390 - arguments: { input: 'test-value' },
391 - };
392 -
393 - const result = await provider.executeTool(toolSlug, toolParams);
394 -
395 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
396 - expect(result).toEqual({
397 - data: { result: 'success' },
398 - error: null,
399 - successful: true,
400 - });
401 - });
402 -
403 - it('should pass modifiers to the global execute function', async () => {
404 - const toolSlug = 'test-tool';
405 - const toolParams = {
406 - userId: 'test-user',
407 - arguments: { input: 'test-value' },
408 - };
409 -
410 - const modifiers = {
411 - beforeExecute: vi.fn(({ params }) => params),
412 - afterExecute: vi.fn(({ result }) => result),
413 - };
414 -
415 - await provider.executeTool(toolSlug, toolParams, modifiers);
416 -
417 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
418 - });
419 -
420 - it('should handle execution errors gracefully', async () => {
421 - const toolSlug = 'test-tool';
422 - const toolParams = {
423 - userId: 'test-user',
424 - arguments: { input: 'test-value' },
425 - };
426 -
427 - const errorResponse = {
428 - data: null,
429 - error: { message: 'Tool execution failed' },
430 - successful: false,
431 - };
432 -
433 - mockExecuteToolFn.mockResolvedValueOnce(errorResponse);
434 -
435 - const result = await provider.executeTool(toolSlug, toolParams);
436 -
437 - expect(result).toEqual(errorResponse);
438 - });
439 - });
440 -
385 describe('integration with Mastra', () => {
442 - it('should produce tools compatible with Mastra createTool', () => {
443 - const wrapped = provider.wrapTool(mockTool, mockExecuteToolFn) as unknown as MockedMastraTool;
444 -
445 - // Verify the wrapped tool has the expected structure
446 - expect(wrapped).toHaveProperty('id');
447 - expect(wrapped).toHaveProperty('description');
448 - expect(wrapped).toHaveProperty('inputSchema');
449 - expect(wrapped).toHaveProperty('outputSchema');
450 - expect(wrapped).toHaveProperty('execute');
451 -
452 - // The execute property should be a function
453 - expect(typeof wrapped.execute).toBe('function');
454 - });
455 -
456 - it('should create tools with correct id mapping from slug', () => {
457 - const wrapped = provider.wrapTool(mockTool, mockExecuteToolFn) as unknown as MockedMastraTool;
458 -
459 - expect(createTool).toHaveBeenCalledWith(
460 - expect.objectContaining({
461 - id: mockTool.slug,
462 - })
463 - );
464 - });
465 -
386 it('should handle tools without schemas gracefully', () => {
387 const minimalTool: Tool = {
388 slug: 'minimal-tool',
@@ -514,36 +434,7 @@ describe('MastraProvider', () => {
434 });
435 });
436
517 - describe('type safety', () => {
518 - it('should maintain correct typing for MastraTool', () => {
519 - const wrapped = provider.wrapTool(mockTool, mockExecuteToolFn);
520 -
521 - // Type assertion should work
522 - expect(wrapped).toBeDefined();
523 - expect(typeof wrapped).toBe('object');
524 - });
525 -
526 - it('should maintain correct typing for MastraToolCollection', () => {
527 - const tools = [mockTool];
528 - const wrapped = provider.wrapTools(tools, mockExecuteToolFn);
529 -
530 - // Should be an object with string keys
531 - expect(typeof wrapped).toBe('object');
532 - expect(Array.isArray(wrapped)).toBe(false);
533 - });
534 - });
535 -
437 describe('strict mode', () => {
537 - it('should create provider with strict mode disabled by default', () => {
538 - const defaultProvider = new MastraProvider();
539 - expect(defaultProvider['strict']).toBe(false);
540 - });
541 -
542 - it('should create provider with strict mode enabled when specified', () => {
543 - const strictProvider = new MastraProvider({ strict: true });
544 - expect(strictProvider['strict']).toBe(true);
545 - });
546 -
438 it('should keep optional properties as required-nullable when strict mode is enabled', () => {
439 const strictProvider = new MastraProvider({ strict: true });
440
@@ -841,16 +732,6 @@ describe('MastraProvider', () => {
732 expect(result).toEqual({});
733 });
734
844 - it('should handle single item array', () => {
845 - const mcpResponse = [{ name: 'single-server', url: 'https://single.example.com' }];
846 -
847 - const result = provider.wrapMcpServerResponse(mcpResponse);
848 -
849 - expect(result).toEqual({
850 - 'single-server': { url: 'https://single.example.com' },
851 - });
852 - });
853 -
735 it('should handle duplicate names by overwriting', () => {
736 const mcpResponse = [
737 { name: 'duplicate', url: 'https://first.example.com' },
@@ -887,26 +768,5 @@ describe('MastraProvider', () => {
768 });
769 });
770 });
890 -
891 - describe('MCP integration with provider', () => {
892 - it('should correctly type the MCP response transformation', () => {
893 - const mcpResponse = [{ name: 'test-server', url: 'https://test.example.com' }];
894 -
895 - const result = provider.wrapMcpServerResponse(mcpResponse);
896 -
897 - // TypeScript should infer this as MastraUrlMap
898 - const urlMap: { [name: string]: { url: string } } = result;
899 - expect(urlMap['test-server'].url).toBe('https://test.example.com');
900 - });
901 -
902 - it('should work with MCP provider instance', () => {
903 - // Verify the provider can transform MCP responses
904 - const newProvider = new MastraProvider();
905 - const testResponse = [{ name: 'test', url: 'https://test.com' }];
906 -
907 - const result = newProvider.wrapMcpServerResponse(testResponse);
908 - expect(result).toEqual({ test: { url: 'https://test.com' } });
909 - });
910 - });
771 });
772 });
ts/packages/providers/openai-agents/test/openai-agents.test.ts
-74
@@ -298,42 +298,6 @@ describe('OpenAIAgentsProvider', () => {
298 });
299 });
300
301 - describe('executeTool', () => {
302 - it('should execute a tool using the global execute function', async () => {
303 - const toolSlug = 'test-tool';
304 - const toolParams = {
305 - userId: 'test-user',
306 - arguments: { input: 'test-value' },
307 - };
308 -
309 - const result = await provider.executeTool(toolSlug, toolParams);
310 -
311 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
312 - expect(result).toEqual({
313 - data: { result: 'success' },
314 - error: null,
315 - successful: true,
316 - });
317 - });
318 -
319 - it('should pass modifiers to the global execute function', async () => {
320 - const toolSlug = 'test-tool';
321 - const toolParams = {
322 - userId: 'test-user',
323 - arguments: { input: 'test-value' },
324 - };
325 -
326 - const modifiers = {
327 - beforeExecute: vi.fn(({ params }) => params),
328 - afterExecute: vi.fn(({ result }) => result),
329 - };
330 -
331 - await provider.executeTool(toolSlug, toolParams, modifiers);
332 -
333 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
334 - });
335 - });
336 -
301 describe('MCP functionality', () => {
302 describe('wrapMcpServerResponse', () => {
303 it('should transform McpUrlResponse to standard McpServerGetResponse format', () => {
@@ -369,44 +333,6 @@ describe('OpenAIAgentsProvider', () => {
333 expect(Array.isArray(result)).toBe(true);
334 expect(result).toHaveLength(0);
335 });
372 -
373 - it('should handle single item array', () => {
374 - const mcpResponse = [{ name: 'single-server', url: 'https://single.example.com' }];
375 -
376 - const result = provider.wrapMcpServerResponse(mcpResponse);
377 -
378 - expect(Array.isArray(result)).toBe(true);
379 - expect(result).toHaveLength(1);
380 - expect(result[0]).toEqual({
381 - url: new URL('https://single.example.com'),
382 - name: 'single-server',
383 - });
384 - });
385 - });
386 -
387 - describe('MCP integration with provider', () => {
388 - it('should correctly type the MCP response transformation', () => {
389 - const mcpResponse = [{ name: 'test-server', url: 'https://test.example.com' }];
390 -
391 - const result = provider.wrapMcpServerResponse(mcpResponse);
392 -
393 - // TypeScript should infer this as McpServerGetResponse
394 - expect(result[0]).toHaveProperty('url');
395 - expect(result[0]).toHaveProperty('name');
396 - expect(result[0].url).toBeInstanceOf(URL);
397 - expect(result[0].url.href).toBe('https://test.example.com/');
398 - });
399 -
400 - it('should work with MCP provider instance', () => {
401 - // Verify the provider can transform MCP responses
402 - const newProvider = new OpenAIAgentsProvider();
403 - const testResponse = [{ name: 'test', url: 'https://test.com' }];
404 -
405 - const result = newProvider.wrapMcpServerResponse(testResponse);
406 - expect(result).toHaveLength(1);
407 - expect(result[0].name).toBe('test');
408 - expect(result[0].url.href).toBe('https://test.com/');
409 - });
336 });
337 });
338 });
ts/packages/providers/openai/test/openai.test.ts
-36
@@ -490,42 +490,6 @@ describe('OpenAIProvider', () => {
490 });
491 });
492
493 - describe('executeTool', () => {
494 - it('should execute a tool using the global execute function', async () => {
495 - const toolSlug = 'test-tool';
496 - const toolParams = {
497 - userId: 'test-user',
498 - arguments: { input: 'test-value' },
499 - };
500 -
501 - const result = await provider.executeTool(toolSlug, toolParams);
502 -
503 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
504 - expect(result).toEqual({
505 - data: { result: 'success' },
506 - error: null,
507 - successful: true,
508 - });
509 - });
510 -
511 - it('should pass modifiers to the global execute function', async () => {
512 - const toolSlug = 'test-tool';
513 - const toolParams = {
514 - userId: 'test-user',
515 - arguments: { input: 'test-value' },
516 - };
517 -
518 - const modifiers = {
519 - beforeExecute: vi.fn(({ params }) => params),
520 - afterExecute: vi.fn(({ result }) => result),
521 - };
522 -
523 - await provider.executeTool(toolSlug, toolParams, modifiers);
524 -
525 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
526 - });
527 - });
528 -
493 describe('waitAndHandleAssistantToolCalls', () => {
494 it('should handle and submit tool outputs for an assistant run', async () => {
495 const userId = 'test-user';
ts/packages/providers/vercel/test/vercel.test.ts
-36
@@ -269,42 +269,6 @@ describe('VercelProvider', () => {
269 });
270 });
271
272 - describe('executeTool', () => {
273 - it('should execute a tool using the global execute function', async () => {
274 - const toolSlug = 'test-tool';
275 - const toolParams = {
276 - userId: 'test-user',
277 - arguments: { input: 'test-value' },
278 - };
279 -
280 - const result = await provider.executeTool(toolSlug, toolParams);
281 -
282 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, undefined);
283 - expect(result).toEqual({
284 - data: { result: 'success' },
285 - error: null,
286 - successful: true,
287 - });
288 - });
289 -
290 - it('should pass modifiers to the global execute function', async () => {
291 - const toolSlug = 'test-tool';
292 - const toolParams = {
293 - userId: 'test-user',
294 - arguments: { input: 'test-value' },
295 - };
296 -
297 - const modifiers = {
298 - beforeExecute: vi.fn(({ params }) => params),
299 - afterExecute: vi.fn(({ result }) => result),
300 - };
301 -
302 - await provider.executeTool(toolSlug, toolParams, modifiers);
303 -
304 - expect(mockExecuteToolFn).toHaveBeenCalledWith(toolSlug, toolParams, modifiers);
305 - });
306 - });
307 -
272 describe('integration with Vercel AI SDK', () => {
273 it('should produce tools compatible with Vercel AI SDK', () => {
274 const wrapped = provider.wrapTool(mockTool, mockExecuteToolFn) as unknown as MockedVercelTool;
ts/packages/ts-builders/src/UnionType.multiline.test.ts
-9
@@ -29,15 +29,6 @@ describe('UnionType multiline formatting', () => {
29 );
30 });
31
32 - it('should still format inline when multiline is not enabled', () => {
33 - const union = unionType([namedType('string'), namedType('number'), namedType('boolean')]);
34 -
35 - const writer = new Writer(0, undefined);
36 - union.write(writer);
37 -
38 - expect(writer.toString()).toBe('string | number | boolean');
39 - });
40 -
32 it('should handle single variant union in multiline', () => {
33 const union = unionType(namedType('string'));
34