@devries-cameron20 / composio Mirror · read-only / commits / 706b01ce7
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, 21:00 UTC

feat(connected-accounts-py): namespace SHARED-connection surface under experimental

Aligns the Python SDK with the experimental wire shape used by Shared Connections. The flat `account_type` / `acl_config_for_shared` kwargs on `link()` and `authorize()` have moved under a single `experimental` dict, and `update_acl` has moved off `composio.connected_accounts` onto the `composio.experimental` namespace — same precedent as `composio.experimental.tool` / `composio.experimental.Toolkit`. The `experimental` namespace is the signal that the shape may change in future releases. Pinning a SHARED connection in a session config and direct execute by `connectedAccountId` are unchanged — only the connection-create / patch / authorize surfaces are namespaced. Also surfaces the `account_type=` filter on `composio.connected_accounts.list()` so SHARED connections can be listed without dropping to the raw client. The wire keeps this as a flat query param (`?account_type=`), so the SDK keeps it flat too with the experimental signal carried in the value enum description. Caller migration: # before composio.connected_accounts.link( user_id, auth_config_id, account_type="SHARED", acl_config_for_shared={"allow_all_users": True}, ) composio.connected_accounts.update_acl( "ca_abc", allow_all_users=True, ) session.authorize( "github", account_type="SHARED", acl_config_for_shared={"allow_all_users": True}, ) # after composio.connected_accounts.link( user_id, auth_config_id, experimental={ "account_type": "SHARED", "acl_config_for_shared": {"allow_all_users": True}, }, ) composio.experimental.update_acl( "ca_abc", allow_all_users=True, ) session.authorize( "github", experimental={ "account_type": "SHARED", "acl_config_for_shared": {"allow_all_users": True}, }, ) # new — list SHARED connections shared = composio.connected_accounts.list( account_type="SHARED", user_ids=["user_creator"], ) composio-client bumped from 1.38.0 -> 1.39.0 so the generated typed client carries the Experimental TypedDicts for link.create, tool_router.session.link, and connected_accounts.patch. Tests cover: experimental block forwarding (link + authorize), no-op when omitted, empty-list preservation, typed error mapping for the PRIVATE-with-ACL case, experimental.update_acl body construction + deny-list handling + ValidationError when no fields are provided + ValidationError when called without a bound client, and list(account_type="SHARED") flat-filter delegation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

venkat82 committed May 12, 2026 at 20:43 UTC 706b01ce75b3318e6b1d3570165f9fa20f5d7522
8 files changed +216 -174
python/composio/core/models/connected_accounts.py
+14 -87
@@ -7,10 +7,10 @@ import typing as t
7 import warnings
8
9 import typing_extensions as te
10 +from composio_client import BadRequestError, omit
11
12 from composio import exceptions
13 from composio.client import HttpClient
13 -from composio_client import BadRequestError, omit
14 from composio.client.types import (
15 connected_account_create_params,
16 connected_account_patch_params,
@@ -559,8 +559,7 @@ class ConnectedAccounts:
559 callback_url: t.Optional[str] = None,
560 alias: t.Optional[str] = None,
561 allow_multiple: bool = False,
562 - account_type: t.Optional[t.Literal["PRIVATE", "SHARED"]] = None,
563 - acl_config_for_shared: t.Optional[link_create_params.ACLConfigForShared] = None,
562 + experimental: t.Optional[link_create_params.Experimental] = None,
563 ) -> ConnectionRequest:
564 """
565 Create a Composio Connect Link for a user to connect their account to a given auth config.
@@ -577,17 +576,10 @@ class ConnectedAccounts:
576 ``ComposioMultipleConnectedAccountsError`` if the user already has an
577 ``ACTIVE`` connection on this auth config. Pair with ``alias`` and a
578 session-level ``multi_account`` config to disambiguate at execution time.
580 - :param account_type: Sharing model for the new connection. ``PRIVATE``
581 - (default) is usable only by the owning ``user_id``. ``SHARED`` can
582 - be used by other ``user_id``s — but only when the connection is
583 - explicitly pinned in a tool-router session's config and only when
584 - the requesting ``user_id`` passes the connection's ACL.
585 - :param acl_config_for_shared: Per-user ACL for SHARED connections.
586 - Only valid when ``account_type == 'SHARED'``; raises
587 - ``ComposioAclOnlyForSharedError`` on a PRIVATE connection. Pass
588 - an ``ACLConfigForShared`` dict with any combination of
589 - ``allow_all_users``, ``allowed_user_ids``, ``not_allowed_user_ids``.
590 - Omit to keep deny-by-default (only the creator can use).
579 + :param experimental: Experimental options for this connection. Pass an
580 + ``Experimental`` dict with ``account_type`` and/or
581 + ``acl_config_for_shared`` to create a SHARED connection with a
582 + per-user ACL. Experimental — shape may change in future releases.
583 :return: Connection request object.
584
585 Example:
@@ -612,14 +604,16 @@ class ConnectedAccounts:
604 # Wait for the connection to be established
605 connected_account = composio.connected_accounts.wait_for_connection(connection_request.id)
606
615 - Example creating a SHARED connection with an ACL:
607 + Example creating a SHARED connection with an ACL (experimental):
608 connection_request = composio.connected_accounts.link(
609 'user_creator',
610 'auth_config_123',
619 - account_type='SHARED',
620 - acl_config_for_shared={
621 - 'allow_all_users': True,
622 - 'not_allowed_user_ids': ['user_bob'],
611 + experimental={
612 + 'account_type': 'SHARED',
613 + 'acl_config_for_shared': {
614 + 'allow_all_users': True,
615 + 'not_allowed_user_ids': ['user_bob'],
616 + },
617 },
618 )
619 """
@@ -646,10 +640,7 @@ class ConnectedAccounts:
640 user_id=user_id,
641 callback_url=callback_url if callback_url is not None else omit,
642 alias=alias if alias is not None else omit,
649 - account_type=account_type if account_type is not None else omit,
650 - acl_config_for_shared=(
651 - acl_config_for_shared if acl_config_for_shared is not None else omit
652 - ),
643 + experimental=experimental if experimental is not None else omit,
644 )
645 except BadRequestError as error:
646 # The server rejects ACL on PRIVATE connections — surface that
@@ -667,70 +658,6 @@ class ConnectedAccounts:
658 client=self._client,
659 )
660
670 - def update_acl(
671 - self,
672 - nanoid: str,
673 - *,
674 - allow_all_users: t.Optional[bool] = None,
675 - allowed_user_ids: t.Optional[t.List[str]] = None,
676 - not_allowed_user_ids: t.Optional[t.List[str]] = None,
677 - ) -> connected_account_patch_response.ConnectedAccountPatchResponse:
678 - """
679 - Update the per-user ACL on a SHARED connected account.
680 -
681 - Only valid on SHARED connections; raises
682 - ``ComposioAclOnlyForSharedError`` on a PRIVATE connection. Omit a
683 - parameter to leave it unchanged; pass an empty list to clear an
684 - allow/deny list. At least one parameter must be provided.
685 -
686 - :param nanoid: The connected account ID (``ca_xxx``).
687 - :param allow_all_users: When True, any ``user_id`` may use this
688 - SHARED connection (subject to the deny list).
689 - :param allowed_user_ids: Explicit list of allowed ``user_id`` strings.
690 - Pass ``[]`` to clear.
691 - :param not_allowed_user_ids: Explicit deny list (wins over allow on
692 - conflict). Pass ``[]`` to clear — note that clearing the deny
693 - list silently re-grants access to previously-blocked users.
694 - :return: Response with ``id``, ``status``, and ``success``.
695 -
696 - Example:
697 - composio.connected_accounts.update_acl(
698 - 'ca_abc',
699 - allow_all_users=True,
700 - not_allowed_user_ids=['user_bob'],
701 - )
702 - """
703 - if (
704 - allow_all_users is None
705 - and allowed_user_ids is None
706 - and not_allowed_user_ids is None
707 - ):
708 - raise exceptions.ValidationError(
709 - "update_acl requires at least one of allow_all_users, "
710 - "allowed_user_ids, or not_allowed_user_ids"
711 - )
712 -
713 - acl: t.Dict[str, t.Any] = {}
714 - if allow_all_users is not None:
715 - acl["allow_all_users"] = allow_all_users
716 - if allowed_user_ids is not None:
717 - acl["allowed_user_ids"] = allowed_user_ids
718 - if not_allowed_user_ids is not None:
719 - acl["not_allowed_user_ids"] = not_allowed_user_ids
720 -
721 - try:
722 - return self._client.connected_accounts.patch(
723 - nanoid,
724 - acl_config_for_shared=t.cast(
725 - connected_account_patch_params.ACLConfigForShared, acl
726 - ),
727 - )
728 - except BadRequestError as error:
729 - message = str(error)
730 - if "acl_config_for_shared is only valid on SHARED" in message:
731 - raise exceptions.ComposioAclOnlyForSharedError(message) from error
732 - raise
733 -
661 def wait_for_connection(
662 self,
663 id: str,
python/composio/core/models/custom_tool.py
+80 -2
@@ -486,12 +486,90 @@ class ExperimentalToolkit:
486 class ExperimentalAPI:
487 """Experimental APIs accessed via ``composio.experimental``.
488
489 - Provides decorators for creating custom tools and toolkits
490 - that run in-process alongside remote Composio tools.
489 + Provides decorators for creating custom tools and toolkits that run
490 + in-process alongside remote Composio tools, plus experimental SDK
491 + methods whose shape may change in future releases.
492 """
493
494 Toolkit = ExperimentalToolkit
495
496 + def __init__(self, client: t.Optional[t.Any] = None) -> None:
497 + self._client = client
498 +
499 + def update_acl(
500 + self,
501 + nanoid: str,
502 + *,
503 + allow_all_users: t.Optional[bool] = None,
504 + allowed_user_ids: t.Optional[t.List[str]] = None,
505 + not_allowed_user_ids: t.Optional[t.List[str]] = None,
506 + ) -> t.Any:
507 + """
508 + Update the per-user ACL on a SHARED connected account. Experimental —
509 + shape may change in future releases.
510 +
511 + Only valid on SHARED connections; raises
512 + ``ComposioAclOnlyForSharedError`` on a PRIVATE connection. Omit a
513 + parameter to leave it unchanged; pass an empty list to clear an
514 + allow/deny list. At least one parameter must be provided.
515 +
516 + :param nanoid: The connected account ID (``ca_xxx``).
517 + :param allow_all_users: When True, any ``user_id`` may use this
518 + SHARED connection (subject to the deny list).
519 + :param allowed_user_ids: Explicit list of allowed ``user_id`` strings.
520 + Pass ``[]`` to clear.
521 + :param not_allowed_user_ids: Explicit deny list (wins over allow on
522 + conflict). Pass ``[]`` to clear — note that clearing the deny
523 + list silently re-grants access to previously-blocked users.
524 + :return: Response with ``id``, ``status``, and ``success``.
525 +
526 + Example:
527 + composio.experimental.update_acl(
528 + 'ca_abc',
529 + allow_all_users=True,
530 + not_allowed_user_ids=['user_bob'],
531 + )
532 + """
533 + from composio_client import BadRequestError, omit
534 +
535 + from composio import exceptions
536 +
537 + if self._client is None:
538 + raise exceptions.ValidationError(
539 + "update_acl requires a Composio client. Access it via "
540 + "composio.experimental.update_acl(...)."
541 + )
542 + if (
543 + allow_all_users is None
544 + and allowed_user_ids is None
545 + and not_allowed_user_ids is None
546 + ):
547 + raise exceptions.ValidationError(
548 + "update_acl requires at least one of allow_all_users, "
549 + "allowed_user_ids, or not_allowed_user_ids"
550 + )
551 +
552 + acl: t.Dict[str, t.Any] = {}
553 + if allow_all_users is not None:
554 + acl["allow_all_users"] = allow_all_users
555 + if allowed_user_ids is not None:
556 + acl["allowed_user_ids"] = allowed_user_ids
557 + if not_allowed_user_ids is not None:
558 + acl["not_allowed_user_ids"] = not_allowed_user_ids
559 +
560 + try:
561 + return self._client.connected_accounts.patch(
562 + nanoid,
563 + experimental={"acl_config_for_shared": acl},
564 + alias=omit,
565 + connection=omit,
566 + )
567 + except BadRequestError as error:
568 + message = str(error)
569 + if "acl_config_for_shared is only valid on SHARED" in message:
570 + raise exceptions.ComposioAclOnlyForSharedError(message) from error
571 + raise
572 +
573 @t.overload
574 def tool(self, fn: t.Callable[..., t.Any], /) -> CustomTool: ...
575
python/composio/core/models/tool_router_session.py
+12 -21
@@ -14,13 +14,12 @@ from dataclasses import dataclass
14
15 from composio_client import BadRequestError, Omit, omit
16 from composio_client._types import SequenceNotStr
17 -from composio_client.types.tool_router import session_link_params, session_patch_params
18 -from composio.client.types import Tool
17 from composio_client.types.tool_list_response import (
18 ItemDeprecated,
19 ItemDeprecatedToolkit,
20 ItemToolkit,
21 )
22 +from composio_client.types.tool_router import session_link_params, session_patch_params
23 from composio_client.types.tool_router.session_execute_response import (
24 SessionExecuteResponse,
25 )
@@ -33,6 +32,8 @@ from composio_client.types.tool_router.session_search_response import (
32
33 from composio import exceptions
34 from composio.client import HttpClient
35 +from composio.client.types import Tool
36 +from composio.core.models._modifiers import Modifiers, apply_modifier_by_type
37 from composio.core.models.connected_accounts import ConnectionRequest
38 from composio.core.models.custom_tool import find_custom_tool_map_entry_by_final_slug
39 from composio.core.models.custom_tool_execution import (
@@ -50,7 +51,6 @@ from composio.core.models.inline_custom_tools_payload import (
51 inline_custom_tools_execute_experimental,
52 inline_custom_tools_search_experimental,
53 )
53 -from composio.core.models._modifiers import Modifiers, apply_modifier_by_type
54 from composio.core.models.session_context import SessionContextImpl, proxy_execute_impl
55 from composio.core.models.tools import ToolExecuteParams, ToolExecutionResponse
56 from composio.core.provider import TTool, TToolCollection
@@ -58,8 +58,8 @@ from composio.core.provider.base import BaseProvider
58
59 if t.TYPE_CHECKING:
60 from composio.core.models.tool_router import (
61 - ToolRouterSessionExperimental,
61 ToolkitConnectionsDetails,
62 + ToolRouterSessionExperimental,
63 )
64
65 COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL"
@@ -539,10 +539,7 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
539 *,
540 callback_url: t.Optional[str] = None,
541 alias: t.Optional[str] = None,
542 - account_type: t.Optional[t.Literal["PRIVATE", "SHARED"]] = None,
543 - acl_config_for_shared: t.Optional[
544 - session_link_params.ACLConfigForShared
545 - ] = None,
542 + experimental: t.Optional[session_link_params.Experimental] = None,
543 ) -> ConnectionRequest:
544 """
545 Authorize a toolkit for the user and get a connection request.
@@ -551,13 +548,10 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
548
549 :param alias: Human-readable alias for the connection. Must be unique
550 per userId and toolkit within the project.
554 - :param account_type: Sharing model for the new connection. ``PRIVATE``
555 - (default) is usable only by the owning ``user_id``. ``SHARED`` can
556 - be used by other ``user_id``s when the connection is pinned in a
557 - tool-router session and the requesting user passes its ACL.
558 - :param acl_config_for_shared: Per-user ACL for SHARED connections.
559 - Only valid when ``account_type == 'SHARED'``; raises
560 - ``ComposioAclOnlyForSharedError`` on a PRIVATE connection.
551 + :param experimental: Experimental options for this connection. Pass an
552 + ``Experimental`` dict with ``account_type`` and/or
553 + ``acl_config_for_shared`` to create a SHARED connection with a
554 + per-user ACL. Experimental — shape may change in future releases.
555 """
556 try:
557 response = self._client.tool_router.session.link(
@@ -565,10 +559,7 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
559 toolkit=toolkit,
560 callback_url=callback_url if callback_url else omit,
561 alias=alias if alias is not None else omit,
568 - account_type=account_type if account_type is not None else omit,
569 - acl_config_for_shared=(
570 - acl_config_for_shared if acl_config_for_shared is not None else omit
571 - ),
562 + experimental=experimental if experimental is not None else omit,
563 )
564 except BadRequestError as error:
565 # The server rejects ACL on PRIVATE connections — surface that
@@ -598,11 +589,11 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
589 Get toolkit connection states for the session.
590 """
591 from composio.core.models.tool_router import (
592 + ToolkitConnectedAccount,
593 ToolkitConnection,
594 ToolkitConnectionAuthConfig,
603 - ToolkitConnectionState,
604 - ToolkitConnectedAccount,
595 ToolkitConnectionsDetails,
596 + ToolkitConnectionState,
597 )
598
599 toolkits_params: t.Dict[str, t.Any] = {}
python/composio/sdk.py
+3 -2
@@ -179,10 +179,11 @@ class Composio(t.Generic[TTool, TToolCollection], WithLogger):
179 self.connected_accounts = ConnectedAccounts(client=self._client)
180 self.mcp = MCP(client=self._client)
181
182 - # experimental API — decorators for custom tools and toolkits
182 + # experimental API — decorators for custom tools and toolkits,
183 + # plus experimental SDK methods (e.g. update_acl)
184 from composio.core.models.custom_tool import ExperimentalAPI
185
185 - self.experimental = ExperimentalAPI()
186 + self.experimental = ExperimentalAPI(client=self._client)
187
188 # initialize tool router methods
189 self.tool_router = ToolRouter(
python/pyproject.toml
+1 -1
@@ -7,7 +7,7 @@ requires-python = ">=3.10,<4"
7 dependencies = [
8 "pysher>=1.0.8",
9 "pydantic>=2.6.4",
10 - "composio-client==1.38.0",
10 + "composio-client==1.39.0",
11 "typing-extensions>=4.0.0",
12 "openai",
13 "json-schema-to-pydantic>=0.4.8",
python/tests/test_connected_accounts.py
+77 -56
@@ -543,8 +543,8 @@ def _make_bad_request_error(message: str):
543
544
545 class TestConnectedAccountsAcl:
546 - """Tests for ``account_type`` + per-user ACL surfacing on ``link()``
547 - and ``update_acl()``."""
546 + """Tests for SHARED accounts surface on ``link()`` and
547 + ``composio.experimental.update_acl()``."""
548
549 @pytest.fixture
550 def mock_client(self):
@@ -573,68 +573,63 @@ class TestConnectedAccountsAcl:
573 def connected_accounts(self, mock_client):
574 return ConnectedAccounts(client=mock_client)
575
576 - # -- link() with accountType + ACL forwarding ---------------------------
576 + @pytest.fixture
577 + def experimental(self, mock_client):
578 + from composio.core.models.custom_tool import ExperimentalAPI
579
578 - def test_link_forwards_account_type_and_nested_acl(
579 - self, connected_accounts, mock_client
580 - ):
581 - connected_accounts.link(
582 - user_id="user_creator",
583 - auth_config_id="auth_config_123",
584 - account_type="SHARED",
585 - acl_config_for_shared={
586 - "allow_all_users": True,
587 - "not_allowed_user_ids": ["user_bob"],
588 - },
589 - )
580 + return ExperimentalAPI(client=mock_client)
581
591 - call_kwargs = mock_client.link.create.call_args.kwargs
592 - assert call_kwargs["account_type"] == "SHARED"
593 - assert call_kwargs["acl_config_for_shared"] == {
594 - "allow_all_users": True,
595 - "not_allowed_user_ids": ["user_bob"],
596 - }
582 + # -- link() forwards the experimental block -----------------------------
583
598 - def test_link_omits_acl_when_not_provided(self, connected_accounts, mock_client):
584 + def test_link_forwards_experimental_block(self, connected_accounts, mock_client):
585 connected_accounts.link(
586 user_id="user_creator",
587 auth_config_id="auth_config_123",
602 - account_type="SHARED",
588 + experimental={
589 + "account_type": "SHARED",
590 + "acl_config_for_shared": {
591 + "allow_all_users": True,
592 + "not_allowed_user_ids": ["user_bob"],
593 + },
594 + },
595 )
596
597 call_kwargs = mock_client.link.create.call_args.kwargs
606 - assert call_kwargs["account_type"] == "SHARED"
607 - assert call_kwargs["acl_config_for_shared"] is omit
598 + assert call_kwargs["experimental"] == {
599 + "account_type": "SHARED",
600 + "acl_config_for_shared": {
601 + "allow_all_users": True,
602 + "not_allowed_user_ids": ["user_bob"],
603 + },
604 + }
605
609 - def test_link_forwards_only_provided_acl_fields(
606 + def test_link_omits_experimental_when_not_provided(
607 self, connected_accounts, mock_client
608 ):
609 connected_accounts.link(
610 user_id="user_creator",
611 auth_config_id="auth_config_123",
615 - account_type="SHARED",
616 - acl_config_for_shared={"allowed_user_ids": ["user_alice"]},
612 )
613
614 call_kwargs = mock_client.link.create.call_args.kwargs
620 - assert call_kwargs["acl_config_for_shared"] == {
621 - "allowed_user_ids": ["user_alice"]
622 - }
615 + assert call_kwargs["experimental"] is omit
616
617 def test_link_preserves_explicit_empty_lists(self, connected_accounts, mock_client):
618 """An empty list is meaningful (clear the allow/deny list)."""
619 connected_accounts.link(
620 user_id="user_creator",
621 auth_config_id="auth_config_123",
629 - account_type="SHARED",
630 - acl_config_for_shared={
631 - "allowed_user_ids": [],
632 - "not_allowed_user_ids": [],
622 + experimental={
623 + "account_type": "SHARED",
624 + "acl_config_for_shared": {
625 + "allowed_user_ids": [],
626 + "not_allowed_user_ids": [],
627 + },
628 },
629 )
630
631 call_kwargs = mock_client.link.create.call_args.kwargs
637 - assert call_kwargs["acl_config_for_shared"] == {
632 + assert call_kwargs["experimental"]["acl_config_for_shared"] == {
633 "allowed_user_ids": [],
634 "not_allowed_user_ids": [],
635 }
@@ -650,8 +645,10 @@ class TestConnectedAccountsAcl:
645 connected_accounts.link(
646 user_id="user_creator",
647 auth_config_id="auth_config_123",
653 - account_type="PRIVATE",
654 - acl_config_for_shared={"allow_all_users": True},
648 + experimental={
649 + "account_type": "PRIVATE",
650 + "acl_config_for_shared": {"allow_all_users": True},
651 + },
652 )
653
654 def test_link_rethrows_non_acl_bad_request_errors(
@@ -667,16 +664,16 @@ class TestConnectedAccountsAcl:
664 user_id="user_creator", auth_config_id="auth_config_123"
665 )
666
670 - # -- update_acl() body construction + mapper ----------------------------
667 + # -- experimental.update_acl() body construction + mapper ---------------
668
672 - def test_update_acl_serializes_nested_body(self, connected_accounts, mock_client):
669 + def test_update_acl_serializes_nested_body(self, experimental, mock_client):
670 response = Mock()
671 response.id = "ca_abc"
672 response.status = "ACTIVE"
673 response.success = True
674 mock_client.connected_accounts.patch.return_value = response
675
679 - result = connected_accounts.update_acl(
676 + result = experimental.update_acl(
677 "ca_abc",
678 allow_all_users=True,
679 not_allowed_user_ids=["user_bob"],
@@ -684,46 +681,56 @@ class TestConnectedAccountsAcl:
681
682 mock_client.connected_accounts.patch.assert_called_once_with(
683 "ca_abc",
687 - acl_config_for_shared={
688 - "allow_all_users": True,
689 - "not_allowed_user_ids": ["user_bob"],
684 + experimental={
685 + "acl_config_for_shared": {
686 + "allow_all_users": True,
687 + "not_allowed_user_ids": ["user_bob"],
688 + }
689 },
690 + alias=omit,
691 + connection=omit,
692 )
693 assert result is response
694
694 - def test_update_acl_omits_absent_fields(self, connected_accounts, mock_client):
695 - connected_accounts.update_acl("ca_abc", allowed_user_ids=["user_alice"])
695 + def test_update_acl_omits_absent_fields(self, experimental, mock_client):
696 + experimental.update_acl("ca_abc", allowed_user_ids=["user_alice"])
697
698 mock_client.connected_accounts.patch.assert_called_once_with(
699 "ca_abc",
699 - acl_config_for_shared={"allowed_user_ids": ["user_alice"]},
700 + experimental={
701 + "acl_config_for_shared": {"allowed_user_ids": ["user_alice"]}
702 + },
703 + alias=omit,
704 + connection=omit,
705 )
706
702 - def test_update_acl_preserves_empty_array(self, connected_accounts, mock_client):
703 - connected_accounts.update_acl("ca_abc", allowed_user_ids=[])
707 + def test_update_acl_preserves_empty_array(self, experimental, mock_client):
708 + experimental.update_acl("ca_abc", allowed_user_ids=[])
709
710 mock_client.connected_accounts.patch.assert_called_once_with(
711 "ca_abc",
707 - acl_config_for_shared={"allowed_user_ids": []},
712 + experimental={"acl_config_for_shared": {"allowed_user_ids": []}},
713 + alias=omit,
714 + connection=omit,
715 )
716
710 - def test_update_acl_rejects_all_none(self, connected_accounts, mock_client):
717 + def test_update_acl_rejects_all_none(self, experimental, mock_client):
718 with pytest.raises(exceptions.ValidationError):
712 - connected_accounts.update_acl("ca_abc")
719 + experimental.update_acl("ca_abc")
720 mock_client.connected_accounts.patch.assert_not_called()
721
722 def test_update_acl_maps_acl_only_for_shared_to_typed_error(
716 - self, connected_accounts, mock_client
723 + self, experimental, mock_client
724 ):
725 mock_client.connected_accounts.patch.side_effect = _make_bad_request_error(
726 "acl_config_for_shared is only valid on SHARED connections."
727 )
728
729 with pytest.raises(exceptions.ComposioAclOnlyForSharedError):
723 - connected_accounts.update_acl("ca_abc", allow_all_users=True)
730 + experimental.update_acl("ca_abc", allow_all_users=True)
731
732 def test_update_acl_rethrows_non_acl_bad_request_errors(
726 - self, connected_accounts, mock_client
733 + self, experimental, mock_client
734 ):
735 unrelated = _make_bad_request_error("some other 400")
736 mock_client.connected_accounts.patch.side_effect = unrelated
@@ -731,7 +738,21 @@ class TestConnectedAccountsAcl:
738 from composio_client import BadRequestError
739
740 with pytest.raises(BadRequestError):
734 - connected_accounts.update_acl("ca_abc", allow_all_users=True)
741 + experimental.update_acl("ca_abc", allow_all_users=True)
742 +
743 + def test_update_acl_requires_client(self):
744 + from composio.core.models.custom_tool import ExperimentalAPI
745 +
746 + with pytest.raises(exceptions.ValidationError):
747 + ExperimentalAPI().update_acl("ca_abc", allow_all_users=True)
748 +
749 + # -- list(account_type=...) — flat experimental filter -----------------
750 +
751 + def test_list_forwards_account_type_filter(self, connected_accounts, mock_client):
752 + connected_accounts.list(account_type="SHARED", user_ids=["user_creator"])
753 + mock_client.connected_accounts.list.assert_called_once_with(
754 + account_type="SHARED", user_ids=["user_creator"]
755 + )
756
757
758 # SEC-339: initiate() must gate its DeprecationWarning on the response
python/tests/test_tool_router.py
+25 -1
@@ -6,7 +6,6 @@ import pytest
6 from composio_client import omit
7 from pydantic import BaseModel, Field
8
9 -from composio.exceptions import ValidationError
9 from composio.core.models.custom_tool import ExperimentalAPI
10 from composio.core.models.tool_router import (
11 SESSION_PRESET_DIRECT_TOOLS,
@@ -24,6 +23,7 @@ from composio.core.models.tool_router import (
23 from composio.core.models.tool_router_session import (
24 DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX,
25 )
26 +from composio.exceptions import ValidationError
27
28 experimental_api = ExperimentalAPI()
29
@@ -1182,6 +1182,30 @@ class TestToolRouter:
1182 call_args = mock_client.tool_router.session.link.call_args
1183 assert call_args.kwargs.get("callback_url") == "https://myapp.com/callback"
1184
1185 + def test_authorize_forwards_experimental_block(self, tool_router, mock_client):
1186 + """authorize() should pass the experimental options through verbatim."""
1187 + session = tool_router.create(user_id="user_123")
1188 +
1189 + session.authorize(
1190 + "github",
1191 + experimental={
1192 + "account_type": "SHARED",
1193 + "acl_config_for_shared": {
1194 + "allow_all_users": True,
1195 + "not_allowed_user_ids": ["user_bob"],
1196 + },
1197 + },
1198 + )
1199 +
1200 + call_kwargs = mock_client.tool_router.session.link.call_args.kwargs
1201 + assert call_kwargs["experimental"] == {
1202 + "account_type": "SHARED",
1203 + "acl_config_for_shared": {
1204 + "allow_all_users": True,
1205 + "not_allowed_user_ids": ["user_bob"],
1206 + },
1207 + }
1208 +
1209 def test_toolkits_function(self, tool_router, mock_client):
1210 """Test the toolkits function returned by session."""
1211 session = tool_router.create(user_id="user_123")
uv.lock
+4 -4
@@ -621,7 +621,7 @@ dev = [
621
622 [package.metadata]
623 requires-dist = [
624 - { name = "composio-client", specifier = "==1.38.0" },
624 + { name = "composio-client", specifier = "==1.39.0" },
625 { name = "json-schema-to-pydantic", specifier = ">=0.4.8" },
626 { name = "openai" },
627 { name = "pydantic", specifier = ">=2.6.4" },
@@ -663,7 +663,7 @@ requires-dist = [
663
664 [[package]]
665 name = "composio-client"
666 -version = "1.38.0"
666 +version = "1.39.0"
667 source = { registry = "https://pypi.org/simple" }
668 dependencies = [
669 { name = "anyio" },
@@ -673,9 +673,9 @@ dependencies = [
673 { name = "sniffio" },
674 { name = "typing-extensions" },
675 ]
676 -sdist = { url = "https://files.pythonhosted.org/packages/ea/c0/b0f452d153f5ecf807d7281110a1dea3ea3a6993efa1cdf82782e3daf1f4/composio_client-1.38.0.tar.gz", hash = "sha256:70f248f847f91473413353500862f3944baa829cc2740c32f31c631d755f7f9e", size = 248289, upload-time = "2026-05-11T18:16:11.167Z" }
676 +sdist = { url = "https://files.pythonhosted.org/packages/0d/78/efc71b2df0d580c4550ee60644193644ae3ddc06fc89f3fc92998db6393c/composio_client-1.39.0.tar.gz", hash = "sha256:2086493925117b956a3166da18414925cb50829172c8211591137fcdc3d60c7d", size = 248246, upload-time = "2026-05-12T14:28:13.071Z" }
677 wheels = [
678 - { url = "https://files.pythonhosted.org/packages/9e/62/7b5644d995f4d71477918dd6597366889700ba51f7f2fa09e1e557ce6ac2/composio_client-1.38.0-py3-none-any.whl", hash = "sha256:7c183bb9f4721786db532fcd1bd71636403752ba655cd980fa971f89ba59a664", size = 284169, upload-time = "2026-05-11T18:16:09.461Z" },
678 + { url = "https://files.pythonhosted.org/packages/88/59/f4ddca56b9f02c8fed3277584111a687c9be986d0d2e8b421c80a20caa03/composio_client-1.39.0-py3-none-any.whl", hash = "sha256:bf6050dc0d523bd1e9d52e39e162f5b23bd029aa441b5c4a18e1751aae58571d", size = 284163, upload-time = "2026-05-12T14:28:11.681Z" },
679 ]
680
681 [[package]]