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 22, 17:00 UTC
Feat: Add support for enable/disable tags and search in toolkits (#2305)
Musthaq Ahamad committed
Dec 24, 2025 at 16:36 UTC
a76b0027051ee89a09413fbbab6181f6e314b916
38 files changed
+819
-128
.changeset/dry-rings-turn.md
new
+5
@@ -0,0 +1,5 @@
1
+---
2
+'@composio/core': patch
3
+---
4
+
5
+Add support for enable/disable tags and search toolkits in tool router
pnpm-lock.yaml
+8
-32
@@ -13,8 +13,8 @@ catalogs:
13
specifier: ^4.20250917.0
14
version: 4.20250917.0
15
'@composio/client':
16
- specifier: 0.1.0-alpha.51
17
- version: 0.1.0-alpha.51
16
+ specifier: 0.1.0-alpha.52
17
+ version: 0.1.0-alpha.52
18
'@modelcontextprotocol/sdk':
19
specifier: ^1.24.0
20
version: 1.24.1
@@ -819,7 +819,7 @@ importers:
819
version: 1.0.0-alpha.1
820
'@composio/client':
821
specifier: 'catalog:'
822
- version: 0.1.0-alpha.51
822
+ version: 0.1.0-alpha.52
823
'@composio/core':
824
specifier: workspace:*
825
version: link:../core
@@ -913,7 +913,7 @@ importers:
913
dependencies:
914
'@composio/client':
915
specifier: 'catalog:'
916
- version: 0.1.0-alpha.51
916
+ version: 0.1.0-alpha.52
917
'@composio/json-schema-to-zod':
918
specifier: workspace:*
919
version: link:../json-schema-to-zod
@@ -1620,8 +1620,8 @@ packages:
1620
'@cloudflare/workers-types@4.20250917.0':
1621
resolution: {integrity: sha512-Lsn9dZoRYZZCXXHZNa50cMP8kWhQZG9M7WjxNSiXFzC8bk4Wh/0SYYo4YINxEjEt6h2o69LmAhFaJ+qgaJTh8Q==}
1622
1623
- '@composio/client@0.1.0-alpha.51':
1624
- resolution: {integrity: sha512-Qy7Ag2G2/6t226cXNZnCJmaVO3zMmKWnX4zHewvmqAgufUSwKAc/l4t5TTPN5EjMGUuzCwGE0FeHXODJffBNQg==}
1623
+ '@composio/client@0.1.0-alpha.52':
1624
+ resolution: {integrity: sha512-IFPa77R/v4JUX0QeRHRTEkJCBZ+OqMQBh1rIn4Nv5PIP1eP3sZqxlTYJUKPS4qLNnwBJRD+Vn7/jUs5J7pdv5g==}
1625
1626
'@composio/mcp@1.0.3-0':
1627
resolution: {integrity: sha512-IpbfST0SSs/CEv+PIf6+EL0feNuJhQyUrOHJLPge8NhyLLrCyVqvujRIPyRUUjy0NDsked/Mm5VpJmYM6OACbg==}
@@ -8037,7 +8037,7 @@ snapshots:
8037
8038
'@cloudflare/workers-types@4.20250917.0': {}
8039
8040
- '@composio/client@0.1.0-alpha.51': {}
8040
+ '@composio/client@0.1.0-alpha.52': {}
8041
8042
'@composio/mcp@1.0.3-0': {}
8043
@@ -10904,14 +10904,6 @@ snapshots:
10904
chai: 5.2.0
10905
tinyrainbow: 2.0.0
10906
10907
- '@vitest/mocker@3.2.4(vite@7.2.6(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.0))':
10908
- dependencies:
10909
- '@vitest/spy': 3.2.4
10910
- estree-walker: 3.0.3
10911
- magic-string: 0.30.21
10912
- optionalDependencies:
10913
- vite: 7.2.6(@types/node@20.19.1)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.0)
10914
-
10907
'@vitest/mocker@3.2.4(vite@7.2.6(@types/node@22.15.32)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.1))':
10908
dependencies:
10909
'@vitest/spy': 3.2.4
@@ -10920,22 +10912,6 @@ snapshots:
10912
optionalDependencies:
10913
vite: 7.2.6(@types/node@22.15.32)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.1)
10914
10923
- '@vitest/mocker@3.2.4(vite@7.2.6(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.1))':
10924
- dependencies:
10925
- '@vitest/spy': 3.2.4
10926
- estree-walker: 3.0.3
10927
- magic-string: 0.30.21
10928
- optionalDependencies:
10929
- vite: 7.2.6(@types/node@24.0.3)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.1)
10930
-
10931
- '@vitest/mocker@3.2.4(vite@7.2.6(@types/node@24.6.2)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.1))':
10932
- dependencies:
10933
- '@vitest/spy': 3.2.4
10934
- estree-walker: 3.0.3
10935
- magic-string: 0.30.21
10936
- optionalDependencies:
10937
- vite: 7.2.6(@types/node@24.6.2)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.1)
10938
-
10915
'@vitest/pretty-format@3.2.4':
10916
dependencies:
10917
tinyrainbow: 2.0.0
@@ -10965,7 +10941,7 @@ snapshots:
10941
sirv: 3.0.1
10942
tinyglobby: 0.2.14
10943
tinyrainbow: 2.0.0
10968
- vitest: 3.2.4(@types/node@20.19.1)(@vitest/ui@3.2.4)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.0)
10944
+ vitest: 3.2.4(@types/node@22.15.32)(@vitest/ui@3.2.4)(jiti@1.21.7)(tsx@4.20.5)(yaml@2.8.1)
10945
10946
'@vitest/utils@3.2.4':
10947
dependencies:
pnpm-workspace.yaml
+1
-1
@@ -15,7 +15,7 @@ packages:
15
catalog:
16
'@cloudflare/vitest-pool-workers': ^0.9.2
17
'@cloudflare/workers-types': ^4.20250917.0
18
- '@composio/client': 0.1.0-alpha.51
18
+ '@composio/client': 0.1.0-alpha.52
19
'@modelcontextprotocol/sdk': ^1.24.0
20
ai: 5.0.52
21
openai: ^5.20.3
python/composio/core/models/tool_router.py
+136
-22
@@ -12,6 +12,7 @@ from dataclasses import dataclass
12
from enum import Enum
13
14
from composio_client import omit
15
+from composio_client.types.tool_router import session_create_params
16
import typing_extensions as te
17
18
from composio.client import HttpClient
@@ -40,6 +41,12 @@ class ToolsFn(t.Protocol):
41
...
42
43
44
+# Type alias for MCP tag literals
45
+ToolRouterTag = t.Literal[
46
+ "readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"
47
+]
48
+
49
+
50
class ToolRouterToolkitsEnableConfig(te.TypedDict, total=False):
51
"""Configuration for enabling specific toolkits in tool router session.
52
@@ -84,13 +91,12 @@ class ToolRouterToolsTagsConfig(te.TypedDict, total=False):
91
"""Configuration for filtering tools by MCP tags.
92
93
Attributes:
87
- tags: List of MCP tags to filter tools by.
88
- Only tools with these tags will be available.
94
+ tags: Tags configuration - can be a list of tags (shorthand for enable)
95
+ or an object with enable/disable keys.
96
+ Only tools matching these tags will be available.
97
"""
98
91
- tags: t.List[
92
- t.Literal["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"]
93
- ]
99
+ tags: ToolRouterConfigTags
100
101
102
# Type alias for per-toolkit tool configuration
@@ -107,6 +113,35 @@ ToolRouterToolsConfig = t.Union[
113
]
114
115
116
+class ToolRouterTagsEnableDisableConfig(te.TypedDict, total=False):
117
+ """Configuration for tags in tool router session.
118
+
119
+ Attributes:
120
+ enable: List of tags to enable in the tool router session.
121
+ disable: List of tags to disable in the tool router session.
122
+ """
123
+
124
+ enable: t.Optional[t.List[ToolRouterTag]]
125
+ disable: t.Optional[t.List[ToolRouterTag]]
126
+
127
+
128
+# Type alias for tags configuration
129
+# Can be:
130
+# - List[ToolRouterTag]: List of tag literals (shorthand for enable)
131
+# - ToolRouterTagsEnableDisableConfig: Dict with 'enable' and/or 'disable' keys
132
+ToolRouterConfigTags = t.Union[
133
+ t.List[ToolRouterTag],
134
+ ToolRouterTagsEnableDisableConfig,
135
+]
136
+
137
+
138
+def _is_tools_tags_config(
139
+ config: ToolRouterToolsConfig,
140
+) -> t.TypeGuard[ToolRouterToolsTagsConfig]:
141
+ """Type guard to check if config is ToolRouterToolsTagsConfig."""
142
+ return isinstance(config, dict) and "tags" in config
143
+
144
+
145
class ToolRouterWorkbenchConfig(te.TypedDict, total=False):
146
"""Configuration for workbench settings in tool router session.
147
@@ -392,6 +427,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
427
next_cursor: t.Optional[str] = None,
428
limit: t.Optional[int] = None,
429
is_connected: t.Optional[bool] = None,
430
+ search: t.Optional[str] = None,
431
) -> ToolkitConnectionsDetails:
432
"""
433
Get toolkit connection states for the session.
@@ -409,7 +445,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
445
- True: Only return toolkits with active connections
446
- False: Only return toolkits without active connections
447
- None: Return all toolkits regardless of connection status
412
-
448
+ search: Search term to filter toolkits by name.
449
Returns:
450
ToolkitConnectionsDetails: Object containing:
451
- items: List of ToolkitConnectionState objects with:
@@ -459,6 +495,8 @@ class ToolRouter(Resource, t.Generic[TProvider]):
495
toolkits_params["toolkits"] = toolkits
496
if is_connected is not None:
497
toolkits_params["is_connected"] = is_connected
498
+ if search is not None:
499
+ toolkits_params["search"] = search
500
501
result = self._client.tool_router.session.toolkits(
502
session_id=session_id,
@@ -638,6 +676,45 @@ class ToolRouter(Resource, t.Generic[TProvider]):
676
677
return tools_fn
678
679
+ def _transform_tags_params(
680
+ self, tags: t.Optional[ToolRouterConfigTags]
681
+ ) -> t.Optional[session_create_params.TagsUnionMember1]:
682
+ """Transform tags configuration to API format.
683
+
684
+ Args:
685
+ tags: Tags configuration - can be a list (shorthand for enable)
686
+ or an object with enable/disable keys.
687
+
688
+ Returns:
689
+ Transformed tags payload in API format, or None if tags is None.
690
+ """
691
+ if tags is None:
692
+ return None
693
+
694
+ if isinstance(tags, list):
695
+ # List shorthand means enable these tags
696
+ # Return value structure matches TagsUnionMember1: {"enable": [...]}
697
+ return {"enable": tags}
698
+ elif isinstance(tags, dict):
699
+ # Object format with enable/disable
700
+ # Only include keys that are present and not None
701
+ # Return value structure matches TagsUnionMember1
702
+ enable_value = tags.get("enable")
703
+ disable_value = tags.get("disable")
704
+
705
+ # Build result dict only with non-None values
706
+ if enable_value is not None and disable_value is not None:
707
+ return {
708
+ "enable": enable_value,
709
+ "disable": disable_value,
710
+ }
711
+ elif enable_value is not None:
712
+ return {"enable": enable_value}
713
+ elif disable_value is not None:
714
+ return {"disable": disable_value}
715
+ else:
716
+ return None
717
+
718
def create(
719
self,
720
*,
@@ -650,13 +727,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
727
]
728
] = None,
729
tools: t.Optional[t.Dict[str, ToolRouterToolsConfig]] = None,
653
- tags: t.Optional[
654
- t.List[
655
- t.Literal[
656
- "readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"
657
- ]
658
- ]
659
- ] = None,
730
+ tags: t.Optional[ToolRouterConfigTags] = None,
731
manage_connections: t.Optional[
732
t.Union[bool, ToolRouterManageConnectionsConfig]
733
] = None,
@@ -684,7 +755,9 @@ class ToolRouter(Resource, t.Generic[TProvider]):
755
- ToolRouterToolsDisableConfig: Dict with 'disable' key.
756
Example: {'disable': ['GMAIL_DELETE_EMAIL']}
757
- ToolRouterToolsTagsConfig: Dict with 'tags' key.
758
+ Tags can be a list (shorthand for enable) or object with enable/disable.
759
Example: {'tags': ['readOnlyHint', 'idempotentHint']}
760
+ Example: {'tags': {'enable': ['readOnlyHint'], 'disable': ['destructiveHint']}}
761
Example: {
762
'gmail': ['GMAIL_SEND_EMAIL', 'GMAIL_SEARCH'],
763
'github': {'enable': ['GITHUB_CREATE_ISSUE']},
@@ -692,9 +765,13 @@ class ToolRouter(Resource, t.Generic[TProvider]):
765
'linear': {'tags': ['readOnlyHint']}
766
}
767
:param tags: Optional global MCP tags to filter tools by.
695
- Must be a list of literal values: 'readOnlyHint', 'destructiveHint',
696
- 'idempotentHint', or 'openWorldHint'.
697
- Example: ['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint']
768
+ Can be:
769
+ - List[str]: List of tag literals (shorthand for enable).
770
+ Example: ['readOnlyHint', 'idempotentHint']
771
+ - ToolRouterTagsEnableDisableConfig: Dict with 'enable' and/or 'disable' keys.
772
+ Example: {'enable': ['readOnlyHint'], 'disable': ['destructiveHint']}
773
+ Available tag values: 'readOnlyHint', 'destructiveHint',
774
+ 'idempotentHint', 'openWorldHint'.
775
Toolkit-level tags override this global setting.
776
:param manage_connections: Optional connection management configuration. Can be:
777
- bool: Simple boolean to enable/disable.
@@ -745,7 +822,7 @@ class ToolRouter(Resource, t.Generic[TProvider]):
822
tags=['readOnlyHint', 'idempotentHint']
823
)
824
748
- # Create a session with toolkit-specific tag filtering
825
+ # Create a session with toolkit-specific tag filtering (array format)
826
session = tool_router.create(
827
user_id='user_123',
828
tools={
@@ -754,6 +831,15 @@ class ToolRouter(Resource, t.Generic[TProvider]):
831
}
832
)
833
834
+ # Create a session with toolkit-specific tag filtering (object format)
835
+ session = tool_router.create(
836
+ user_id='user_123',
837
+ tools={
838
+ 'gmail': {'tags': {'enable': ['readOnlyHint']}},
839
+ 'github': {'tags': {'enable': ['readOnlyHint'], 'disable': ['destructiveHint']}}
840
+ }
841
+ )
842
+
843
# Create a session with connection management
844
session = tool_router.create(
845
user_id='user_123',
@@ -807,9 +893,32 @@ class ToolRouter(Resource, t.Generic[TProvider]):
893
# List shorthand means enable these tools
894
tools_payload[toolkit_slug] = {"enable": config}
895
elif isinstance(config, dict):
810
- # Already in dict format with 'enable', 'disable', or 'tags'
811
- # Pass through as-is since it matches the client SDK format
812
- tools_payload[toolkit_slug] = dict(config)
896
+ # Transform config dict - handle 'tags' specially if present
897
+ # Build the transformed config explicitly to maintain proper typing
898
+ transformed_config: t.Dict[
899
+ str,
900
+ t.Union[
901
+ t.List[str],
902
+ session_create_params.TagsUnionMember1,
903
+ ],
904
+ ] = {}
905
+ # Copy existing keys (enable, disable) if present
906
+ if "enable" in config:
907
+ # config is ToolRouterToolsEnableConfig when "enable" is present
908
+ enable_config = t.cast(ToolRouterToolsEnableConfig, config)
909
+ transformed_config["enable"] = enable_config["enable"]
910
+ if "disable" in config:
911
+ # config is ToolRouterToolsDisableConfig when "disable" is present
912
+ disable_config = t.cast(ToolRouterToolsDisableConfig, config)
913
+ transformed_config["disable"] = disable_config["disable"]
914
+ # Use type guard to narrow the type when "tags" is present
915
+ if _is_tools_tags_config(config):
916
+ # Type narrowed: config is now ToolRouterToolsTagsConfig
917
+ tags_value = config["tags"]
918
+ transformed_tags = self._transform_tags_params(tags_value)
919
+ if transformed_tags is not None:
920
+ transformed_config["tags"] = transformed_tags
921
+ tools_payload[toolkit_slug] = transformed_config
922
923
# Parse callback_uri
924
callback_url = (
@@ -845,8 +954,10 @@ class ToolRouter(Resource, t.Generic[TProvider]):
954
if tools_payload:
955
create_params["tools"] = tools_payload
956
848
- if tags is not None:
849
- create_params["tags"] = tags
957
+ # Transform tags config
958
+ tags_payload = self._transform_tags_params(tags)
959
+ if tags_payload is not None:
960
+ create_params["tags"] = tags_payload
961
962
if workbench is not None:
963
execution_payload: t.Dict[str, t.Any] = {}
@@ -925,6 +1036,9 @@ __all__ = [
1036
"ToolRouterToolsDisableConfig",
1037
"ToolRouterToolsTagsConfig",
1038
"ToolRouterToolsConfig",
1039
+ "ToolRouterTag",
1040
+ "ToolRouterTagsEnableDisableConfig",
1041
+ "ToolRouterConfigTags",
1042
"ToolRouterManageConnectionsConfig",
1043
"ToolRouterWorkbenchConfig",
1044
"ToolkitConnectionState",
python/composio/core/models/tools.py
+3
-1
@@ -357,9 +357,11 @@ class Tools(Resource, t.Generic[TProvider]):
357
processed_arguments = modified_params.get("arguments", arguments)
358
359
# Execute the tool via the session's execute_meta endpoint
360
+ # Note: execute_meta accepts regular tool slugs at runtime, not just meta tool slugs
361
+ # The type signature expects Literal meta tool slugs, but runtime accepts any str
362
response = self._client.tool_router.session.execute_meta(
363
session_id=session_id,
362
- slug=slug,
364
+ slug=slug, # type: ignore[arg-type]
365
arguments=processed_arguments,
366
)
367
python/providers/anthropic/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-anthropic"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your Anthropic LLMs."
5
readme = "README.md"
6
requires-python = ">=3.10,<4"
python/providers/anthropic/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_anthropic",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Anthropic LLMs.",
python/providers/autogen/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-autogen"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your autogen agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/autogen/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_autogen",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Autogen agent.",
python/providers/claude_code_agents/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-claude-code-agents"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with Claude Code Agents SDK."
5
readme = "README.md"
6
requires-python = ">=3.10,<4"
python/providers/claude_code_agents/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import find_packages, setup
8
9
setup(
10
name="composio_claude_code_agents",
11
- version="0.10.1",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of tools for Claude Code Agents SDK",
python/providers/crewai/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-crewai"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your CrewAI agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/crewai/setup.py
+1
-1
@@ -6,7 +6,7 @@ from setuptools import setup
6
7
setup(
8
name="composio_crewai",
9
- version="0.10.2",
9
+ version="0.10.3",
10
author="Composio",
11
author_email="tech@composio.dev",
12
description="Use Composio to get an array of tools with your CrewAI agent.",
python/providers/gemini/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-gemini"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your Gemini agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/gemini/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_gemini",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Gemini agent.",
python/providers/google/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-google"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your Google AI Python Gemini model."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/google/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_google",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Google AI Python Gemini model.",
python/providers/google_adk/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-google-adk"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your Google AI Python Gemini model."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/google_adk/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_google_adk",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Google AI Python Gemini model.",
python/providers/langchain/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-langchain"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your Langchain agent."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/langchain/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_langchain",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your Langchain agent.",
python/providers/langgraph/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-langgraph"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get array of tools with LangGraph Agent Workflows."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/langgraph/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_langgraph",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of tools with LangGraph Agent Workflows",
python/providers/llamaindex/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-llamaindex"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get array of tools with LlamaIndex Agent Workflows."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/llamaindex/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_llamaindex",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of tools with LlamaIndex Agent Workflows",
python/providers/openai/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-openai"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get an array of tools with your OpenAI Function Call."
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/openai/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import setup
8
9
setup(
10
name="composio_openai",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get an array of tools with your OpenAI Function Call.",
python/providers/openai_agents/pyproject.toml
+1
-1
@@ -1,6 +1,6 @@
1
[project]
2
name = "composio-openai-agents"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "Use Composio to get array of strongly typed tools for OpenAI Agents"
5
readme = "README.md"
6
requires-python = ">=3.9,<4"
python/providers/openai_agents/setup.py
+1
-1
@@ -8,7 +8,7 @@ from setuptools import find_packages, setup
8
9
setup(
10
name="composio_openai_agents",
11
- version="0.10.2",
11
+ version="0.10.3",
12
author="Composio",
13
author_email="tech@composio.dev",
14
description="Use Composio to get array of strongly typed tools for OpenAI Agents",
python/pyproject.toml
+2
-2
@@ -1,13 +1,13 @@
1
[project]
2
name = "composio"
3
-version = "0.10.2"
3
+version = "0.10.3"
4
description = "SDK for integrating Composio with your applications."
5
readme = "README.md"
6
requires-python = ">=3.10,<4"
7
dependencies = [
8
"pysher>=1.0.8",
9
"pydantic>=2.6.4",
10
- "composio-client>=1.21.0",
10
+ "composio-client>=1.22.0",
11
"typing-extensions>=4.0.0",
12
"openai",
13
]
python/tests/test_tool_router.py
+278
-8
@@ -164,21 +164,73 @@ class TestToolRouter:
164
assert kwargs["tools"]["github"] == {"enable": ["GITHUB_CREATE_ISSUE"]}
165
166
def test_create_session_with_global_tags(self, tool_router, mock_client):
167
- """Test creating a session with global tag filtering."""
167
+ """Test creating a session with global tag filtering (array format)."""
168
session = tool_router.create(
169
user_id="user_123", tags=["readOnlyHint", "idempotentHint"]
170
)
171
172
assert session.session_id == "session_123"
173
174
- # Verify the API was called with tags at top level
174
+ # Verify the API was called with tags transformed to enable format
175
call_args = mock_client.tool_router.session.create.call_args
176
kwargs = call_args.kwargs
177
assert "tags" in kwargs
178
- assert kwargs["tags"] == ["readOnlyHint", "idempotentHint"]
178
+ assert kwargs["tags"] == {"enable": ["readOnlyHint", "idempotentHint"]}
179
+
180
+ def test_create_session_with_global_tags_object_enable(
181
+ self, tool_router, mock_client
182
+ ):
183
+ """Test creating a session with global tags using object format with enable."""
184
+ session = tool_router.create(
185
+ user_id="user_123", tags={"enable": ["readOnlyHint", "idempotentHint"]}
186
+ )
187
+
188
+ assert session.session_id == "session_123"
189
+
190
+ call_args = mock_client.tool_router.session.create.call_args
191
+ kwargs = call_args.kwargs
192
+ assert "tags" in kwargs
193
+ assert kwargs["tags"] == {"enable": ["readOnlyHint", "idempotentHint"]}
194
+
195
+ def test_create_session_with_global_tags_object_disable(
196
+ self, tool_router, mock_client
197
+ ):
198
+ """Test creating a session with global tags using object format with disable."""
199
+ session = tool_router.create(
200
+ user_id="user_123", tags={"disable": ["destructiveHint"]}
201
+ )
202
+
203
+ assert session.session_id == "session_123"
204
+
205
+ call_args = mock_client.tool_router.session.create.call_args
206
+ kwargs = call_args.kwargs
207
+ assert "tags" in kwargs
208
+ assert kwargs["tags"] == {"disable": ["destructiveHint"]}
209
+
210
+ def test_create_session_with_global_tags_object_both(
211
+ self, tool_router, mock_client
212
+ ):
213
+ """Test creating a session with global tags using object format with both enable and disable."""
214
+ session = tool_router.create(
215
+ user_id="user_123",
216
+ tags={
217
+ "enable": ["readOnlyHint", "idempotentHint"],
218
+ "disable": ["destructiveHint"],
219
+ },
220
+ )
221
+
222
+ assert session.session_id == "session_123"
223
+
224
+ call_args = mock_client.tool_router.session.create.call_args
225
+ kwargs = call_args.kwargs
226
+ assert "tags" in kwargs
227
+ assert kwargs["tags"] == {
228
+ "enable": ["readOnlyHint", "idempotentHint"],
229
+ "disable": ["destructiveHint"],
230
+ }
231
232
def test_create_session_with_toolkit_specific_tags(self, tool_router, mock_client):
181
- """Test creating a session with per-toolkit tag filtering."""
233
+ """Test creating a session with per-toolkit tag filtering (array format)."""
234
session = tool_router.create(
235
user_id="user_123",
236
tools={
@@ -192,8 +244,76 @@ class TestToolRouter:
244
call_args = mock_client.tool_router.session.create.call_args
245
kwargs = call_args.kwargs
246
assert "tools" in kwargs
195
- assert kwargs["tools"]["gmail"] == {"tags": ["readOnlyHint"]}
196
- assert kwargs["tools"]["github"] == {"tags": ["readOnlyHint", "idempotentHint"]}
247
+ assert kwargs["tools"]["gmail"] == {"tags": {"enable": ["readOnlyHint"]}}
248
+ assert kwargs["tools"]["github"] == {
249
+ "tags": {"enable": ["readOnlyHint", "idempotentHint"]}
250
+ }
251
+
252
+ def test_create_session_with_toolkit_specific_tags_object_enable(
253
+ self, tool_router, mock_client
254
+ ):
255
+ """Test creating a session with per-toolkit tags using object format with enable."""
256
+ session = tool_router.create(
257
+ user_id="user_123",
258
+ tools={
259
+ "gmail": {"tags": {"enable": ["readOnlyHint", "idempotentHint"]}},
260
+ },
261
+ )
262
+
263
+ assert session.session_id == "session_123"
264
+
265
+ call_args = mock_client.tool_router.session.create.call_args
266
+ kwargs = call_args.kwargs
267
+ assert "tools" in kwargs
268
+ assert kwargs["tools"]["gmail"] == {
269
+ "tags": {"enable": ["readOnlyHint", "idempotentHint"]}
270
+ }
271
+
272
+ def test_create_session_with_toolkit_specific_tags_object_disable(
273
+ self, tool_router, mock_client
274
+ ):
275
+ """Test creating a session with per-toolkit tags using object format with disable."""
276
+ session = tool_router.create(
277
+ user_id="user_123",
278
+ tools={
279
+ "gmail": {"tags": {"disable": ["destructiveHint"]}},
280
+ },
281
+ )
282
+
283
+ assert session.session_id == "session_123"
284
+
285
+ call_args = mock_client.tool_router.session.create.call_args
286
+ kwargs = call_args.kwargs
287
+ assert "tools" in kwargs
288
+ assert kwargs["tools"]["gmail"] == {"tags": {"disable": ["destructiveHint"]}}
289
+
290
+ def test_create_session_with_toolkit_specific_tags_object_both(
291
+ self, tool_router, mock_client
292
+ ):
293
+ """Test creating a session with per-toolkit tags using object format with both enable and disable."""
294
+ session = tool_router.create(
295
+ user_id="user_123",
296
+ tools={
297
+ "gmail": {
298
+ "tags": {
299
+ "enable": ["readOnlyHint", "idempotentHint"],
300
+ "disable": ["destructiveHint"],
301
+ }
302
+ },
303
+ },
304
+ )
305
+
306
+ assert session.session_id == "session_123"
307
+
308
+ call_args = mock_client.tool_router.session.create.call_args
309
+ kwargs = call_args.kwargs
310
+ assert "tools" in kwargs
311
+ assert kwargs["tools"]["gmail"] == {
312
+ "tags": {
313
+ "enable": ["readOnlyHint", "idempotentHint"],
314
+ "disable": ["destructiveHint"],
315
+ }
316
+ }
317
318
def test_create_session_with_open_world_hint_tag(self, tool_router, mock_client):
319
"""Test creating a session with openWorldHint tag."""
@@ -207,7 +327,7 @@ class TestToolRouter:
327
call_args = mock_client.tool_router.session.create.call_args
328
kwargs = call_args.kwargs
329
assert "tags" in kwargs
210
- assert kwargs["tags"] == ["openWorldHint", "readOnlyHint"]
330
+ assert kwargs["tags"] == {"enable": ["openWorldHint", "readOnlyHint"]}
331
332
def test_create_session_with_mixed_tools_config(self, tool_router, mock_client):
333
"""Test creating a session with mixed tool configuration (enable, disable, tags)."""
@@ -226,7 +346,71 @@ class TestToolRouter:
346
kwargs = call_args.kwargs
347
assert kwargs["tools"]["gmail"] == {"enable": ["GMAIL_SEND_EMAIL"]}
348
assert kwargs["tools"]["slack"] == {"disable": ["SLACK_DELETE_MESSAGE"]}
229
- assert kwargs["tools"]["github"] == {"tags": ["readOnlyHint"]}
349
+ assert kwargs["tools"]["github"] == {"tags": {"enable": ["readOnlyHint"]}}
350
+
351
+ def test_create_session_with_global_and_toolkit_tags(
352
+ self, tool_router, mock_client
353
+ ):
354
+ """Test creating a session with both global tags and toolkit-specific tags."""
355
+ session = tool_router.create(
356
+ user_id="user_123",
357
+ tags=["readOnlyHint"], # Global tags
358
+ tools={
359
+ "gmail": {
360
+ "tags": {
361
+ "enable": ["idempotentHint"],
362
+ "disable": ["destructiveHint"],
363
+ }
364
+ },
365
+ },
366
+ )
367
+
368
+ assert session.session_id == "session_123"
369
+
370
+ call_args = mock_client.tool_router.session.create.call_args
371
+ kwargs = call_args.kwargs
372
+ assert kwargs["tags"] == {"enable": ["readOnlyHint"]}
373
+ assert kwargs["tools"]["gmail"] == {
374
+ "tags": {"enable": ["idempotentHint"], "disable": ["destructiveHint"]}
375
+ }
376
+
377
+ def test_create_session_with_empty_tags_array(self, tool_router, mock_client):
378
+ """Test creating a session with empty tags array."""
379
+ session = tool_router.create(
380
+ user_id="user_123",
381
+ tags=[],
382
+ )
383
+
384
+ assert session.session_id == "session_123"
385
+
386
+ call_args = mock_client.tool_router.session.create.call_args
387
+ kwargs = call_args.kwargs
388
+ assert kwargs["tags"] == {"enable": []}
389
+
390
+ def test_create_session_with_all_tag_types(self, tool_router, mock_client):
391
+ """Test creating a session with all available tag types."""
392
+ session = tool_router.create(
393
+ user_id="user_123",
394
+ tags=[
395
+ "readOnlyHint",
396
+ "destructiveHint",
397
+ "idempotentHint",
398
+ "openWorldHint",
399
+ ],
400
+ )
401
+
402
+ assert session.session_id == "session_123"
403
+
404
+ call_args = mock_client.tool_router.session.create.call_args
405
+ kwargs = call_args.kwargs
406
+ assert kwargs["tags"] == {
407
+ "enable": [
408
+ "readOnlyHint",
409
+ "destructiveHint",
410
+ "idempotentHint",
411
+ "openWorldHint",
412
+ ]
413
+ }
414
415
def test_create_session_with_manage_connections_boolean(
416
self, tool_router, mock_client
@@ -469,6 +653,92 @@ class TestToolRouter:
653
assert github_toolkit.connection.auth_config is None
654
assert github_toolkit.connection.connected_account is None
655
656
+ def test_toolkits_function_with_search(self, tool_router, mock_client):
657
+ """Test the toolkits function with search parameter."""
658
+ session = tool_router.create(user_id="user_123")
659
+
660
+ session.toolkits(search="gmail")
661
+
662
+ # Verify toolkits was called with search param
663
+ call_args = mock_client.tool_router.session.toolkits.call_args
664
+ assert call_args.kwargs.get("search") == "gmail"
665
+ assert call_args.kwargs["session_id"] == "session_123"
666
+
667
+ def test_toolkits_function_with_search_and_toolkits_filter(
668
+ self, tool_router, mock_client
669
+ ):
670
+ """Test the toolkits function with search and toolkits filter together."""
671
+ session = tool_router.create(user_id="user_123")
672
+
673
+ session.toolkits(search="github", toolkits=["github", "slack"])
674
+
675
+ # Verify toolkits was called with both search and toolkits params
676
+ call_args = mock_client.tool_router.session.toolkits.call_args
677
+ assert call_args.kwargs.get("search") == "github"
678
+ assert call_args.kwargs.get("toolkits") == ["github", "slack"]
679
+ assert call_args.kwargs["session_id"] == "session_123"
680
+
681
+ def test_toolkits_function_with_search_and_is_connected(
682
+ self, tool_router, mock_client
683
+ ):
684
+ """Test the toolkits function with search and is_connected filter."""
685
+ session = tool_router.create(user_id="user_123")
686
+
687
+ session.toolkits(search="mail", is_connected=True)
688
+
689
+ # Verify toolkits was called with search and is_connected params
690
+ call_args = mock_client.tool_router.session.toolkits.call_args
691
+ assert call_args.kwargs.get("search") == "mail"
692
+ assert call_args.kwargs.get("is_connected") is True
693
+ assert call_args.kwargs["session_id"] == "session_123"
694
+
695
+ def test_toolkits_function_with_search_and_pagination(
696
+ self, tool_router, mock_client
697
+ ):
698
+ """Test the toolkits function with search and pagination parameters."""
699
+ session = tool_router.create(user_id="user_123")
700
+
701
+ session.toolkits(search="slack", next_cursor="cursor_xyz", limit=5)
702
+
703
+ # Verify toolkits was called with search and pagination params
704
+ call_args = mock_client.tool_router.session.toolkits.call_args
705
+ assert call_args.kwargs.get("search") == "slack"
706
+ assert call_args.kwargs.get("cursor") == "cursor_xyz"
707
+ assert call_args.kwargs.get("limit") == 5
708
+ assert call_args.kwargs["session_id"] == "session_123"
709
+
710
+ def test_toolkits_function_with_search_all_params(self, tool_router, mock_client):
711
+ """Test the toolkits function with search and all other parameters."""
712
+ session = tool_router.create(user_id="user_123")
713
+
714
+ session.toolkits(
715
+ search="gmail",
716
+ toolkits=["gmail", "github"],
717
+ next_cursor="cursor_123",
718
+ limit=20,
719
+ is_connected=False,
720
+ )
721
+
722
+ # Verify toolkits was called with all params including search
723
+ call_args = mock_client.tool_router.session.toolkits.call_args
724
+ assert call_args.kwargs.get("search") == "gmail"
725
+ assert call_args.kwargs.get("toolkits") == ["gmail", "github"]
726
+ assert call_args.kwargs.get("cursor") == "cursor_123"
727
+ assert call_args.kwargs.get("limit") == 20
728
+ assert call_args.kwargs.get("is_connected") is False
729
+ assert call_args.kwargs["session_id"] == "session_123"
730
+
731
+ def test_toolkits_function_with_empty_search(self, tool_router, mock_client):
732
+ """Test the toolkits function with empty search string."""
733
+ session = tool_router.create(user_id="user_123")
734
+
735
+ session.toolkits(search="")
736
+
737
+ # Verify toolkits was called with empty search string
738
+ call_args = mock_client.tool_router.session.toolkits.call_args
739
+ assert call_args.kwargs.get("search") == ""
740
+ assert call_args.kwargs["session_id"] == "session_123"
741
+
742
@patch("composio.core.models.tools.Tools")
743
def test_tools_function(
744
self, mock_tools_class, tool_router, mock_client, mock_provider
ts/packages/core/src/lib/toolRouterParams.ts
+21
-1
@@ -1,5 +1,6 @@
1
import { SessionCreateParams } from '@composio/client/resources/tool-router.mjs';
2
import {
3
+ ToolRouterConfigTags,
4
ToolRouterConfigTools,
5
ToolRouterConfigToolsSchema,
6
ToolRouterToolsParam,
@@ -34,7 +35,10 @@ export const transformToolRouterToolsParams = (
35
} else if ('disable' in data) {
36
acc[key] = { disable: data.disable };
37
} else if ('tags' in data) {
37
- acc[key] = { tags: data.tags };
38
+ const tags = transformToolRouterTagsParams(data.tags);
39
+ if (tags) {
40
+ acc[key] = { tags };
41
+ }
42
}
43
} else {
44
throw new ValidationError(parsedResult.error.message);
@@ -52,3 +56,19 @@ export const transformToolRouterToolsParams = (
56
return result;
57
}
58
};
59
+
60
+export const transformToolRouterTagsParams = (
61
+ params?: ToolRouterConfigTags
62
+): SessionCreateParams.Tags['tags'] | undefined => {
63
+ if (!params) {
64
+ return undefined;
65
+ }
66
+ if (Array.isArray(params)) {
67
+ return { enable: params };
68
+ } else if (typeof params === 'object') {
69
+ return {
70
+ enable: params.enable,
71
+ disable: params.disable,
72
+ };
73
+ }
74
+};
ts/packages/core/src/models/ToolRouter.ts
+7
-2
@@ -45,7 +45,10 @@ import { ConnectedAccountStatuses } from '../types/connectedAccounts.types';
45
import { transform } from '../utils/transform';
46
import { SessionCreateParams } from '@composio/client/resources/tool-router.mjs';
47
import { ValidationError } from '../errors';
48
-import { transformToolRouterToolsParams } from '../lib/toolRouterParams';
48
+import {
49
+ transformToolRouterTagsParams,
50
+ transformToolRouterToolsParams,
51
+} from '../lib/toolRouterParams';
52
53
export class ToolRouter<
54
TToolCollection,
@@ -115,6 +118,7 @@ export class ToolRouter<
118
limit: toolkitOptions.data.limit,
119
toolkits: toolkitOptions.data.toolkits,
120
is_connected: toolkitOptions.data.isConnected,
121
+ search: toolkitOptions.data.search,
122
});
123
124
const toolkitConnectedStates = result.items.map(item => {
@@ -261,6 +265,7 @@ export class ToolRouter<
265
? { enable: routerConfig.toolkits }
266
: routerConfig.toolkits;
267
268
+ const tags = transformToolRouterTagsParams(routerConfig.tags);
269
const tools = transformToolRouterToolsParams(routerConfig.tools);
270
271
const payload: SessionCreateParams = {
@@ -269,7 +274,7 @@ export class ToolRouter<
274
auth_configs: routerConfig.authConfigs,
275
connected_accounts: routerConfig.connectedAccounts,
276
tools: tools,
272
- tags: routerConfig.tags,
277
+ tags: tags,
278
manage_connections: {
279
enable: manageConnectedAccounts,
280
callback_url:
ts/packages/core/src/models/Tools.ts
+3
-1
@@ -52,6 +52,7 @@ import { ComposioConfig } from '../composio';
52
import { getToolkitVersion } from '../utils/toolkitVersion';
53
import { handleToolExecutionError } from '../errors/ToolErrors';
54
import { ToolExecuteMetaParams } from '../types/tool.types';
55
+import { SessionExecuteMetaParams } from '@composio/client/resources/tool-router.mjs';
56
/**
57
* This class is used to manage tools in the Composio SDK.
58
* It provides methods to list, get, and execute tools.
@@ -911,7 +912,8 @@ export class Tools<
912
);
913
914
const response = await this.client.toolRouter.session.executeMeta(body.sessionId, {
914
- slug: toolSlug,
915
+ // assert this because backend might keep adding more tool slugs
916
+ slug: toolSlug as SessionExecuteMetaParams['slug'],
917
arguments: params,
918
});
919
ts/packages/core/src/types/toolRouter.types.ts
+14
-21
@@ -56,25 +56,22 @@ export const ToolRouterManageConnectionsConfigSchema = z.object({
56
57
// Tags
58
export const ToolRouterTagsParamSchema = z
59
- .array(z.string())
60
- .describe('The tags to use in the tool router session');
61
-export const ToolRouterEnabledTagsConfigSchema = z
62
- .object({
63
- enable: ToolRouterTagsParamSchema.describe('The tags to enable in the tool router session'),
64
- })
65
- .strict();
66
-export const ToolRouterDisabledTagsConfigSchema = z
59
+ .array(z.enum(['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint']))
60
+ .describe('The tags to filter the tools by');
61
+export const ToolRouterTagsEnableDisableSchema = z
62
.object({
68
- disable: ToolRouterTagsParamSchema.describe('The tags to disable in the tool router session'),
63
+ enable: ToolRouterTagsParamSchema.optional().describe(
64
+ 'The tags to enable in the tool router session'
65
+ ),
66
+ disable: ToolRouterTagsParamSchema.optional().describe(
67
+ 'The tags to disable in the tool router session'
68
+ ),
69
})
70
.strict();
71
export const ToolRouterConfigTagsSchema = z
72
- .union([
73
- ToolRouterTagsParamSchema,
74
- ToolRouterEnabledTagsConfigSchema,
75
- ToolRouterDisabledTagsConfigSchema,
76
- ])
72
+ .union([ToolRouterTagsParamSchema, ToolRouterTagsEnableDisableSchema])
73
.describe('The tags to use in the tool router session');
74
+export type ToolRouterConfigTags = z.infer<typeof ToolRouterConfigTagsSchema>;
75
76
/**
77
* Tools config - Configure tools per toolkit using toolkit slug as key
@@ -103,11 +100,6 @@ export const ToolRouterToolsParamSchema = z
100
.describe('The tools to use in the tool router session');
101
export type ToolRouterToolsParam = z.infer<typeof ToolRouterToolsParamSchema>;
102
106
-export const ToolRouterToolsTagsParamSchema = z
107
- .array(z.enum(['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint']))
108
- .describe('The tags to filter the tools by');
109
-export type ToolRouterToolsTagsParam = z.infer<typeof ToolRouterToolsTagsParamSchema>;
110
-
103
export const ToolRouterConfigToolsSchema = z
104
.union([
105
ToolRouterToolsParamSchema,
@@ -127,7 +119,7 @@ export const ToolRouterConfigToolsSchema = z
119
.strict(),
120
z
121
.object({
130
- tags: ToolRouterToolsTagsParamSchema.describe(
122
+ tags: ToolRouterConfigTagsSchema.describe(
123
'The tags to filter the tools by, this will override the global tags'
124
),
125
})
@@ -155,7 +147,7 @@ export const ToolRouterCreateSessionConfigSchema = z
147
.optional()
148
.describe('The tools to use in the tool router session'),
149
158
- tags: ToolRouterToolsTagsParamSchema.optional().describe('Global tags to filter the tools by'),
150
+ tags: ToolRouterConfigTagsSchema.optional().describe('Global tags to filter the tools by'),
151
152
toolkits: z
153
.union([
@@ -284,6 +276,7 @@ export const ToolRouterToolkitsOptionsSchema = z.object({
276
nextCursor: z.string().optional(),
277
limit: z.number().optional(),
278
isConnected: z.boolean().optional(),
279
+ search: z.string().optional(),
280
});
281
export type ToolRouterToolkitsOptions = z.infer<typeof ToolRouterToolkitsOptionsSchema>;
282
ts/packages/core/test/lib/toolRouterParams.test.ts
new
+129
@@ -0,0 +1,129 @@
1
+import { describe, it, expect } from 'vitest';
2
+import { transformToolRouterTagsParams } from '../../src/lib/toolRouterParams';
3
+import { ToolRouterConfigTags } from '../../src/types/toolRouter.types';
4
+
5
+describe('transformToolRouterTagsParams', () => {
6
+ describe('with undefined input', () => {
7
+ it('should return undefined when params is undefined', () => {
8
+ const result = transformToolRouterTagsParams(undefined);
9
+ expect(result).toBeUndefined();
10
+ });
11
+ });
12
+
13
+ describe('with array input', () => {
14
+ it('should transform array of tags to enable format', () => {
15
+ const params: ToolRouterConfigTags = ['readOnlyHint', 'idempotentHint'];
16
+ const result = transformToolRouterTagsParams(params);
17
+
18
+ expect(result).toEqual({
19
+ enable: ['readOnlyHint', 'idempotentHint'],
20
+ });
21
+ });
22
+
23
+ it('should handle single tag in array', () => {
24
+ const params: ToolRouterConfigTags = ['readOnlyHint'];
25
+ const result = transformToolRouterTagsParams(params);
26
+
27
+ expect(result).toEqual({
28
+ enable: ['readOnlyHint'],
29
+ });
30
+ });
31
+
32
+ it('should handle all tag types', () => {
33
+ const params: ToolRouterConfigTags = [
34
+ 'readOnlyHint',
35
+ 'destructiveHint',
36
+ 'idempotentHint',
37
+ 'openWorldHint',
38
+ ];
39
+ const result = transformToolRouterTagsParams(params);
40
+
41
+ expect(result).toEqual({
42
+ enable: ['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint'],
43
+ });
44
+ });
45
+
46
+ it('should handle empty array', () => {
47
+ const params: ToolRouterConfigTags = [];
48
+ const result = transformToolRouterTagsParams(params);
49
+
50
+ expect(result).toEqual({
51
+ enable: [],
52
+ });
53
+ });
54
+ });
55
+
56
+ describe('with object input', () => {
57
+ it('should transform object with enable property', () => {
58
+ const params: ToolRouterConfigTags = {
59
+ enable: ['readOnlyHint', 'idempotentHint'],
60
+ };
61
+ const result = transformToolRouterTagsParams(params);
62
+
63
+ expect(result).toEqual({
64
+ enable: ['readOnlyHint', 'idempotentHint'],
65
+ });
66
+ });
67
+
68
+ it('should transform object with disable property', () => {
69
+ const params: ToolRouterConfigTags = {
70
+ disable: ['destructiveHint'],
71
+ };
72
+ const result = transformToolRouterTagsParams(params);
73
+
74
+ expect(result).toEqual({
75
+ enable: undefined,
76
+ disable: ['destructiveHint'],
77
+ });
78
+ });
79
+
80
+ it('should transform object with both enable and disable properties', () => {
81
+ const params: ToolRouterConfigTags = {
82
+ enable: ['readOnlyHint', 'idempotentHint'],
83
+ disable: ['destructiveHint'],
84
+ };
85
+ const result = transformToolRouterTagsParams(params);
86
+
87
+ expect(result).toEqual({
88
+ enable: ['readOnlyHint', 'idempotentHint'],
89
+ disable: ['destructiveHint'],
90
+ });
91
+ });
92
+
93
+ it('should handle object with only enable property', () => {
94
+ const params: ToolRouterConfigTags = {
95
+ enable: ['readOnlyHint'],
96
+ };
97
+ const result = transformToolRouterTagsParams(params);
98
+
99
+ expect(result).toEqual({
100
+ enable: ['readOnlyHint'],
101
+ });
102
+ });
103
+
104
+ it('should handle object with only disable property', () => {
105
+ const params: ToolRouterConfigTags = {
106
+ disable: ['destructiveHint', 'openWorldHint'],
107
+ };
108
+ const result = transformToolRouterTagsParams(params);
109
+
110
+ expect(result).toEqual({
111
+ enable: undefined,
112
+ disable: ['destructiveHint', 'openWorldHint'],
113
+ });
114
+ });
115
+
116
+ it('should handle empty arrays in object', () => {
117
+ const params: ToolRouterConfigTags = {
118
+ enable: [],
119
+ disable: [],
120
+ };
121
+ const result = transformToolRouterTagsParams(params);
122
+
123
+ expect(result).toEqual({
124
+ enable: [],
125
+ disable: [],
126
+ });
127
+ });
128
+ });
129
+});
ts/packages/core/test/models/toolRouter.test.ts
+175
@@ -305,6 +305,181 @@ describe('ToolRouter', () => {
305
});
306
});
307
308
+ describe('tags configuration', () => {
309
+ it('should create a session with tags as array', async () => {
310
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
311
+
312
+ const config: ToolRouterCreateSessionConfig = {
313
+ tags: ['readOnlyHint', 'idempotentHint'],
314
+ };
315
+
316
+ await toolRouter.create(userId, config);
317
+
318
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
319
+ user_id: userId,
320
+ toolkits: undefined,
321
+ auth_configs: undefined,
322
+ connected_accounts: undefined,
323
+ tools: undefined,
324
+ tags: {
325
+ enable: ['readOnlyHint', 'idempotentHint'],
326
+ },
327
+ manage_connections: createExpectedManageConnections(),
328
+ workbench: undefined,
329
+ });
330
+ });
331
+
332
+ it('should create a session with tags object with enable property', async () => {
333
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
334
+
335
+ const config: ToolRouterCreateSessionConfig = {
336
+ tags: {
337
+ enable: ['readOnlyHint', 'idempotentHint'],
338
+ },
339
+ };
340
+
341
+ await toolRouter.create(userId, config);
342
+
343
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
344
+ user_id: userId,
345
+ toolkits: undefined,
346
+ auth_configs: undefined,
347
+ connected_accounts: undefined,
348
+ tools: undefined,
349
+ tags: {
350
+ enable: ['readOnlyHint', 'idempotentHint'],
351
+ },
352
+ manage_connections: createExpectedManageConnections(),
353
+ workbench: undefined,
354
+ });
355
+ });
356
+
357
+ it('should create a session with tags object with disable property', async () => {
358
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
359
+
360
+ const config: ToolRouterCreateSessionConfig = {
361
+ tags: {
362
+ disable: ['destructiveHint'],
363
+ },
364
+ };
365
+
366
+ await toolRouter.create(userId, config);
367
+
368
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
369
+ user_id: userId,
370
+ toolkits: undefined,
371
+ auth_configs: undefined,
372
+ connected_accounts: undefined,
373
+ tools: undefined,
374
+ tags: {
375
+ enable: undefined,
376
+ disable: ['destructiveHint'],
377
+ },
378
+ manage_connections: createExpectedManageConnections(),
379
+ workbench: undefined,
380
+ });
381
+ });
382
+
383
+ it('should create a session with tags object with both enable and disable properties', async () => {
384
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
385
+
386
+ const config: ToolRouterCreateSessionConfig = {
387
+ tags: {
388
+ enable: ['readOnlyHint', 'idempotentHint'],
389
+ disable: ['destructiveHint'],
390
+ },
391
+ };
392
+
393
+ await toolRouter.create(userId, config);
394
+
395
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
396
+ user_id: userId,
397
+ toolkits: undefined,
398
+ auth_configs: undefined,
399
+ connected_accounts: undefined,
400
+ tools: undefined,
401
+ tags: {
402
+ enable: ['readOnlyHint', 'idempotentHint'],
403
+ disable: ['destructiveHint'],
404
+ },
405
+ manage_connections: createExpectedManageConnections(),
406
+ workbench: undefined,
407
+ });
408
+ });
409
+
410
+ it('should create a session with single tag in array', async () => {
411
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
412
+
413
+ const config: ToolRouterCreateSessionConfig = {
414
+ tags: ['readOnlyHint'],
415
+ };
416
+
417
+ await toolRouter.create(userId, config);
418
+
419
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
420
+ user_id: userId,
421
+ toolkits: undefined,
422
+ auth_configs: undefined,
423
+ connected_accounts: undefined,
424
+ tools: undefined,
425
+ tags: {
426
+ enable: ['readOnlyHint'],
427
+ },
428
+ manage_connections: createExpectedManageConnections(),
429
+ workbench: undefined,
430
+ });
431
+ });
432
+
433
+ it('should create a session with all tag types', async () => {
434
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
435
+
436
+ const config: ToolRouterCreateSessionConfig = {
437
+ tags: ['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint'],
438
+ };
439
+
440
+ await toolRouter.create(userId, config);
441
+
442
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
443
+ user_id: userId,
444
+ toolkits: undefined,
445
+ auth_configs: undefined,
446
+ connected_accounts: undefined,
447
+ tools: undefined,
448
+ tags: {
449
+ enable: ['readOnlyHint', 'destructiveHint', 'idempotentHint', 'openWorldHint'],
450
+ },
451
+ manage_connections: createExpectedManageConnections(),
452
+ workbench: undefined,
453
+ });
454
+ });
455
+
456
+ it('should create a session with tags combined with toolkits', async () => {
457
+ mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
458
+
459
+ const config: ToolRouterCreateSessionConfig = {
460
+ toolkits: ['gmail', 'slack'],
461
+ tags: ['readOnlyHint'],
462
+ };
463
+
464
+ await toolRouter.create(userId, config);
465
+
466
+ expect(mockClient.toolRouter.session.create).toHaveBeenCalledWith({
467
+ user_id: userId,
468
+ toolkits: {
469
+ enable: ['gmail', 'slack'],
470
+ },
471
+ auth_configs: undefined,
472
+ connected_accounts: undefined,
473
+ tools: undefined,
474
+ tags: {
475
+ enable: ['readOnlyHint'],
476
+ },
477
+ manage_connections: createExpectedManageConnections(),
478
+ workbench: undefined,
479
+ });
480
+ });
481
+ });
482
+
483
// describe('tools configuration', () => {
484
// it('should create a session with tools overrides as array', async () => {
485
// mockClient.toolRouter.session.create.mockResolvedValueOnce(mockSessionCreateResponse);
uv.lock
+13
-13
@@ -477,7 +477,7 @@ wheels = [
477
478
[[package]]
479
name = "composio"
480
-version = "0.10.2"
480
+version = "0.10.3"
481
source = { virtual = "python" }
482
dependencies = [
483
{ name = "composio-client" },
@@ -506,7 +506,7 @@ dev = [
506
507
[package.metadata]
508
requires-dist = [
509
- { name = "composio-client", specifier = ">=1.21.0" },
509
+ { name = "composio-client", specifier = ">=1.22.0" },
510
{ name = "openai" },
511
{ name = "pydantic", specifier = ">=2.6.4" },
512
{ name = "pysher", specifier = ">=1.0.8" },
@@ -532,7 +532,7 @@ dev = [
532
533
[[package]]
534
name = "composio-anthropic"
535
-version = "0.10.2"
535
+version = "0.10.3"
536
source = { virtual = "python/providers/anthropic" }
537
dependencies = [
538
{ name = "anthropic" },
@@ -547,7 +547,7 @@ requires-dist = [
547
548
[[package]]
549
name = "composio-client"
550
-version = "1.21.0"
550
+version = "1.22.0"
551
source = { registry = "https://pypi.org/simple" }
552
dependencies = [
553
{ name = "anyio" },
@@ -557,14 +557,14 @@ dependencies = [
557
{ name = "sniffio" },
558
{ name = "typing-extensions" },
559
]
560
-sdist = { url = "https://files.pythonhosted.org/packages/27/9a/1bd2d84b133442537b757d713666e8883738f47b19e6405c2ab631f35d4a/composio_client-1.21.0.tar.gz", hash = "sha256:d994615932275442202ff994325ab85e59604799fc8ad0369970d89942dd366d", size = 185285 }
560
+sdist = { url = "https://files.pythonhosted.org/packages/44/a7/81fe217a855992ee3854acd07939c0eed893d9b8019ea544e28fd0aa1b86/composio_client-1.22.0.tar.gz", hash = "sha256:13dd4ecf3b1289cfd6acdb538f9144d123d0344c03b387aa411d6fb0f1dec6d0", size = 185804 }
561
wheels = [
562
- { url = "https://files.pythonhosted.org/packages/e1/db/066255019b8457e16a8418f821c2ccb89da37e0c8ce986b0c487231b0663/composio_client-1.21.0-py3-none-any.whl", hash = "sha256:a5f1f737c0c6f9a74dcc6cb5fb598a923f6a2e44364cd71fc14b0a1903ddf073", size = 200987 },
562
+ { url = "https://files.pythonhosted.org/packages/8f/1f/2abe83f3363edc3d5be94002f97eafed9ea95d7129fe6ea1c33655751aeb/composio_client-1.22.0-py3-none-any.whl", hash = "sha256:3afe32fd3206c3bd2a7183d729817908fdc4bfac2b52da22144334fab2384932", size = 201474 },
563
]
564
565
[[package]]
566
name = "composio-crewai"
567
-version = "0.10.2"
567
+version = "0.10.3"
568
source = { virtual = "python/providers/crewai" }
569
dependencies = [
570
{ name = "composio" },
@@ -579,7 +579,7 @@ requires-dist = [
579
580
[[package]]
581
name = "composio-gemini"
582
-version = "0.10.2"
582
+version = "0.10.3"
583
source = { virtual = "python/providers/gemini" }
584
dependencies = [
585
{ name = "composio" },
@@ -594,7 +594,7 @@ requires-dist = [
594
595
[[package]]
596
name = "composio-google"
597
-version = "0.10.2"
597
+version = "0.10.3"
598
source = { virtual = "python/providers/google" }
599
dependencies = [
600
{ name = "composio" },
@@ -609,7 +609,7 @@ requires-dist = [
609
610
[[package]]
611
name = "composio-google-adk"
612
-version = "0.10.2"
612
+version = "0.10.3"
613
source = { virtual = "python/providers/google_adk" }
614
dependencies = [
615
{ name = "composio" },
@@ -624,7 +624,7 @@ requires-dist = [
624
625
[[package]]
626
name = "composio-langchain"
627
-version = "0.10.2"
627
+version = "0.10.3"
628
source = { virtual = "python/providers/langchain" }
629
dependencies = [
630
{ name = "composio" },
@@ -639,7 +639,7 @@ requires-dist = [
639
640
[[package]]
641
name = "composio-openai"
642
-version = "0.10.2"
642
+version = "0.10.3"
643
source = { virtual = "python/providers/openai" }
644
dependencies = [
645
{ name = "composio" },
@@ -654,7 +654,7 @@ requires-dist = [
654
655
[[package]]
656
name = "composio-openai-agents"
657
-version = "0.10.2"
657
+version = "0.10.3"
658
source = { virtual = "python/providers/openai_agents" }
659
dependencies = [
660
{ name = "composio" },