@devries-cameron20 / composio Mirror · read-only / commits / 0b32b158f
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, 22:15 UTC

feat(connected-accounts): support REVOKED status added in Apollo PR #9550

Apollo (hermes#9550) added REVOKED to the connected-account status enum. The SDK had several places that hard-coded the prior 6 values and would either fail-fast against the new value (BREAKING) or silently misclassify it (DEGRADED). TypeScript SDK (BREAKING fixes): - Add REVOKED to `ConnectedAccountStatusSchema` / `ConnectedAccountStatuses` so `z.enum().parse(...)` no longer throws on responses that include the new status. - Add REVOKED to the CLI's Effect `Schema.Literal(...)` for `ConnectedAccountItem.status`. - Add REVOKED to the `normalizeConnectedAccountStatus` switch so a REVOKED account is no longer silently coerced to INACTIVE. - Fix the connected-account-list raw-cast to forward REVOKED into the Stainless-generated client (the cast widens to whatever `client.connectedAccounts.list` accepts so it auto-tracks regenerations). Python SDK (DEGRADED fixes): - Add REVOKED to `ConnectionStatusEnum` so consumers checking `event.data.status in ConnectionStatusEnum` recognise the value. - Update `ConnectionRequest.wait_for_connection()` to fail fast on terminal non-ACTIVE statuses (FAILED / EXPIRED / INACTIVE / REVOKED) instead of polling until the 60s timeout. The Stainless-generated `@composio/client` and `composio_client` packages will pick up the new enum value automatically when regenerated; this PR covers the hand-written SDK code only.

Zen Agent committed May 5, 2026 at 04:30 UTC 0b32b158f38bb6d16017bbdcc0deb7e1ce7a2b8d
6 files changed +40 -9
python/composio/core/models/connected_accounts.py
+12 -4
@@ -77,10 +77,18 @@ class ConnectionRequest(Resource):
77 while deadline > time.time():
78 connection = self._client.connected_accounts.retrieve(nanoid=self.id)
79 self.status = connection.status
80 - if self.status != "ACTIVE":
81 - time.sleep(1)
82 - continue
83 - return connection
80 + if self.status == "ACTIVE":
81 + return connection
82 + # Fail fast on terminal non-ACTIVE states (FAILED / EXPIRED /
83 + # INACTIVE / REVOKED) instead of polling until timeout.
84 + if self.status in ("FAILED", "EXPIRED", "INACTIVE", "REVOKED"):
85 + raise exceptions.SDKError(
86 + message=(
87 + f"Connection {self.id} entered terminal state "
88 + f"{self.status!r} before becoming active"
89 + ),
90 + )
91 + time.sleep(1)
92
93 raise exceptions.ComposioSDKTimeoutError(
94 message=f"Timeout while waiting for connection {self.id} to be active",
python/composio/core/models/webhook_events.py
+1
@@ -29,6 +29,7 @@ class ConnectionStatusEnum(str, Enum):
29 FAILED = "FAILED"
30 EXPIRED = "EXPIRED"
31 INACTIVE = "INACTIVE"
32 + REVOKED = "REVOKED"
33
34
35 # =============================================================================
ts/packages/cli/src/models/connected-accounts.ts
+9 -1
@@ -13,7 +13,15 @@ export const ConnectedAccountItem = Schema.Struct({
13 id: Schema.String,
14 word_id: Schema.optional(Schema.NullOr(Schema.String)),
15 alias: Schema.optional(Schema.NullOr(Schema.String)),
16 - status: Schema.Literal('INITIALIZING', 'INITIATED', 'ACTIVE', 'FAILED', 'EXPIRED', 'INACTIVE'),
16 + status: Schema.Literal(
17 + 'INITIALIZING',
18 + 'INITIATED',
19 + 'ACTIVE',
20 + 'FAILED',
21 + 'EXPIRED',
22 + 'INACTIVE',
23 + 'REVOKED'
24 + ),
25 status_reason: Schema.optionalWith(Schema.NullOr(Schema.String), { default: () => null }),
26 is_disabled: Schema.Boolean,
27 user_id: Schema.String,
ts/packages/cli/src/services/composio-clients.ts
+12 -3
@@ -1775,9 +1775,18 @@ function buildConnectedAccountsNamespace(
1775 client.connectedAccounts.list({
1776 toolkit_slugs: params.toolkit_slugs,
1777 user_ids: params.user_ids,
1778 - statuses: params.statuses as
1779 - | Array<'INITIALIZING' | 'INITIATED' | 'ACTIVE' | 'FAILED' | 'EXPIRED' | 'INACTIVE'>
1780 - | undefined,
1778 + // Cast widens to whatever the Stainless-generated client
1779 + // currently accepts, plus 'REVOKED'. The cast bypasses the
1780 + // stale Stainless types so callers passing 'REVOKED' (a valid
1781 + // Apollo status) are forwarded as-is until @composio/client is
1782 + // regenerated.
1783 + statuses: params.statuses as Parameters<
1784 + typeof client.connectedAccounts.list
1785 + >[0] extends infer P
1786 + ? P extends { statuses?: infer S }
1787 + ? S
1788 + : never
1789 + : never,
1790 limit: params.limit,
1791 }),
1792 ConnectedAccountListResponse
ts/packages/cli/src/services/tool-router-session-connections.ts
+1
@@ -56,6 +56,7 @@ const normalizeConnectedAccountStatus = (
56 case 'FAILED':
57 case 'EXPIRED':
58 case 'INACTIVE':
59 + case 'REVOKED':
60 return status;
61 default:
62 return 'INACTIVE';
ts/packages/core/src/models/ConnectedAccounts.ts
+5 -1
@@ -107,7 +107,11 @@ export class ConnectedAccounts {
107 cursor: parsedQuery.data.cursor?.toString(),
108 limit: parsedQuery.data.limit,
109 order_by: parsedQuery.data.orderBy,
110 - statuses: parsedQuery.data.statuses,
110 + // Cast widens to match the Stainless-generated client params, which
111 + // lag behind the live API enum. Apollo accepts the union value at
112 + // runtime (`z.nativeEnum(ConnectionStatusEnum)` on the query param);
113 + // remove the cast once `@composio/client` is regenerated.
114 + statuses: parsedQuery.data.statuses as ConnectedAccountListParamsRaw['statuses'],
115 toolkit_slugs: parsedQuery.data.toolkitSlugs,
116 user_ids: parsedQuery.data.userIds,
117 };