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 23, 00:30 UTC
Fix issues with connected accounts in custom tools
haxzie committed
Jun 11, 2025 at 12:38 UTC
4f804aa2a1ff7ebf546ecb92d30f3e5e1df11583
4 files changed
+10
-54
.husky/pre-commit
+4
-1
@@ -1 +1,4 @@
1
-pnpm lint
1
+#!/usr/bin/env sh
2
+. "$(dirname -- "$0")/_/husky.sh"
3
+
4
+pnpm lint-staged
package.json
+4
-2
@@ -14,7 +14,9 @@
14
"test": "turbo test --filter=./packages/**",
15
"test:ui": "vitest --ui",
16
"lint": "eslint . --ext .ts,.tsx",
17
+ "lint:packages": "eslint packages --ext .ts,.tsx",
18
"lint:fix": "eslint . --ext .ts,.tsx --fix",
19
+ "lint:fix:packages": "eslint packages --ext .ts,.tsx --fix",
20
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
21
"prepare": "husky",
22
"create:provider": "bash scripts/create-provider.sh",
@@ -46,10 +48,10 @@
48
"zod": "^3.24.2"
49
},
50
"lint-staged": {
49
- "*.{ts,tsx}": [
51
+ "packages/**/*.{ts,tsx}": [
52
"eslint --fix"
53
],
52
- "*.{ts,tsx,js,jsx,json,md}": [
54
+ "packages/**/*.{ts,tsx,js,jsx,json,md}": [
55
"prettier --write"
56
]
57
}
packages/core/src/models/CustomTools.ts
+2
-31
@@ -33,6 +33,7 @@ import {
33
ConnectedAccountRetrieveResponseSchema,
34
} from '../types/connectedAccounts.types';
35
import { ValidationError } from '../errors';
36
+import { transformConnectedAccountResponse } from '../utils/transformers/connectedAccounts';
37
38
export class CustomTools {
39
private readonly client: ComposioClient;
@@ -219,37 +220,7 @@ export class CustomTools {
220
);
221
}
222
222
- const connectedAccountResponse = await ConnectedAccountRetrieveResponseSchema.safeParse({
223
- id: connectedAccount.id,
224
- authConfig: {
225
- id: connectedAccount.auth_config.id,
226
- authScheme: connectedAccount.auth_config.auth_scheme,
227
- isComposioManaged: connectedAccount.auth_config.is_composio_managed,
228
- isDisabled: connectedAccount.auth_config.is_disabled,
229
- },
230
- userId: connectedAccount.user_id,
231
- data: connectedAccount.data || {},
232
- status: connectedAccount.status,
233
- statusReason: connectedAccount.status_reason,
234
- toolkit: {
235
- slug: connectedAccount.toolkit.slug,
236
- },
237
- testRequestEndpoint: connectedAccount.test_request_endpoint,
238
- isDisabled: connectedAccount.is_disabled,
239
- createdAt: connectedAccount.created_at,
240
- updatedAt: connectedAccount.updated_at,
241
- });
242
-
243
- if (!connectedAccountResponse.success) {
244
- throw new ValidationError(
245
- `Validation error for connected account of ${toolkitSlug} for user ${userId}`,
246
- {
247
- cause: connectedAccountResponse.error,
248
- }
249
- );
250
- }
251
-
252
- return connectedAccountResponse.data;
223
+ return transformConnectedAccountResponse(connectedAccount);
224
}
225
226
/**
packages/core/src/models/Session.ts
deleted
-20
@@ -1,20 +0,0 @@
1
-import ComposioClient from '@composio/client';
2
-import { telemetry } from '../telemetry/Telemetry';
3
-import { SessionRetrieveResponse } from '@composio/client/resources/auth/session';
4
-
5
-export class Session {
6
- private client: ComposioClient;
7
-
8
- constructor(client: ComposioClient) {
9
- this.client = client;
10
- telemetry.instrument(this);
11
- }
12
-
13
- /**
14
- * Get the active session info
15
- * @returns {Promise<SessionInfoResponse>} Session info
16
- */
17
- async getInfo(): Promise<SessionRetrieveResponse> {
18
- return this.client.auth.session.retrieve();
19
- }
20
-}