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

fix(cli): fix type errors, add typecheck scripts

jkomyno committed Jul 29, 2025 at 00:22 UTC b1cd8d1f57f488dca6ae25f6c41f6d358baddc21
11 files changed +50 -142
ts/packages/cli/package.json
+5 -1
@@ -26,10 +26,14 @@
26 "cli": "bun run src/bin.ts",
27 "build:bin": "bun run ./scripts/build-binary.ts",
28 "install:bin": "bun run ./scripts/install-binary.ts ./dist/composio",
29 + "prebuild": "bun run typecheck",
30 "build": "tsup",
31 "bin": "./dist/composio",
32 "test": "vitest run",
32 - "prepublishOnly": "pnpm build && pnpm build:bin"
33 + "prepublishOnly": "bun run build && bun run build:bin",
34 + "typecheck:src": "tsc --noEmit -p ./tsconfig.src.json",
35 + "typecheck:test": "tsc --noEmit -p ./tsconfig.test.json",
36 + "typecheck": "bun run typecheck:src && bun run typecheck:test"
37 },
38 "keywords": [
39 "composio",
ts/packages/cli/src/generation/typescript/generate-index-source.ts
+1 -1
@@ -29,7 +29,7 @@ import type { ToolkitIndex } from 'src/generation/create-toolkit-index';
29
30 const BARREL_OBJECT_NAME = 'Toolkits';
31
32 -type GenerateTypeScriptIndexMapSourceParams = {
32 +export type GenerateTypeScriptIndexMapSourceParams = {
33 banner: string;
34 emitSingleFile: boolean;
35 importExtension: 'ts' | 'js';
ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts
+12 -7
@@ -1,5 +1,8 @@
1 import { describe, expect, it } from 'vitest';
2 -import { generateIndexSource } from 'src/generation/typescript/generate-index-source';
2 +import {
3 + generateIndexSource,
4 + type GenerateTypeScriptIndexMapSourceParams,
5 +} from 'src/generation/typescript/generate-index-source';
6 import { createToolkitIndex } from 'src/generation/create-toolkit-index';
7 import { makeTestToolkits } from 'test/__utils__/models/toolkits';
8 import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';
@@ -7,9 +10,10 @@ import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';
10 describe('generateTypeScriptToolkitSources', () => {
11 describe('with a single emitted file', () => {
12 const _params = {
10 - outputDir: '<cwd>',
13 emitSingleFile: true,
12 - };
14 + banner: '<BANNER>',
15 + importExtension: 'ts' as const,
16 + } satisfies GenerateTypeScriptIndexMapSourceParams;
17
18 describe('with banner', () => {
19 const params = {
@@ -151,8 +155,9 @@ describe('generateTypeScriptToolkitSources', () => {
155
156 describe('with multiple emitted files', () => {
157 const _params = {
154 - outputDir: '<cwd>',
158 emitSingleFile: false,
159 + banner: '<BANNER>',
160 + importExtension: 'ts' as const,
161 };
162
163 describe('with banner', () => {
@@ -223,7 +228,7 @@ describe('generateTypeScriptToolkitSources', () => {
228 * Some banner that will appear in a comment
229 */
230
226 - import { SLACK } from "./slack.undefined"
231 + import { SLACK } from "./slack.ts"
232
233 /**
234 * Map of Composio toolkits to actions.
@@ -277,8 +282,8 @@ describe('generateTypeScriptToolkitSources', () => {
282 * Some banner that will appear in a comment
283 */
284
280 - import { GMAIL } from "./gmail.undefined"
281 - import { SLACK } from "./slack.undefined"
285 + import { GMAIL } from "./gmail.ts"
286 + import { SLACK } from "./slack.ts"
287
288 /**
289 * Map of Composio toolkits to actions.
ts/packages/cli/test/src/generation/typescript/generate-toolkit-source.test.ts
+4 -125
@@ -5,129 +5,8 @@ import { makeTestToolkits } from 'test/__utils__/models/toolkits';
5
6 describe('generateTypeScriptToolkitSources', () => {
7 describe('with a single emitted file', () => {
8 - const _params = {
9 - outputDir: '<cwd>',
10 - emitSingleFile: true,
11 - };
12 -
13 - describe('with banner', () => {
14 - const params = {
15 - ..._params,
16 - banner: 'Some banner that will appear in a comment',
17 - };
18 -
19 - it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
20 - const index = createToolkitIndex({
21 - toolkits: [],
22 - tools: [],
23 - triggerTypes: [],
24 - });
25 -
26 - const sources = generateTypeScriptToolkitSources(params)(index);
27 -
28 - expect(sources).toEqual([]);
29 - });
30 -
31 - it('[Given] a single toolkit with no tools or triggerTypes [Then] it returns a single toolkit source file', () => {
32 - const toolkits = makeTestToolkits([
33 - {
34 - name: 'Slack Helper',
35 - slug: 'slack',
36 - },
37 - ]);
38 -
39 - const index = createToolkitIndex({
40 - toolkits,
41 - tools: [],
42 - triggerTypes: [],
43 - });
44 -
45 - const sources = generateTypeScriptToolkitSources(params)(index);
46 - expect(sources).toHaveLength(1);
47 - expect(sources[0]).toHaveLength(2);
48 - expect(sources[0][0]).toBe('slack.ts');
49 - expect(sources[0][1]).toMatchInlineSnapshot(`
50 - "/**
51 - * Map of Composio's SLACK toolkit.
52 - */
53 - export const SLACK = {
54 - slug: "slack",
55 - tools: {},
56 - triggerTypes: {},
57 - }
58 - "
59 - `);
60 - });
61 -
62 - it('[Given] toolkits with tools and triggerTypes [Then] it returns a TypeScript source file for each toolkit + the index map', () => {
63 - const toolkits = makeTestToolkits([
64 - {
65 - name: 'Gmail',
66 - slug: 'gmail',
67 - },
68 - {
69 - name: 'Slack Helper',
70 - slug: 'slack',
71 - },
72 - ]);
73 -
74 - const index = createToolkitIndex({
75 - toolkits,
76 - tools: ['GMAIL_CREATE_EMAIL_DRAFT', 'GMAIL_DELETE_MESSAGE', 'GMAIL_FETCH_EMAILS'],
77 - triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
78 - });
79 -
80 - const sources = generateTypeScriptToolkitSources(params)(index);
81 - expect(sources).toHaveLength(2);
82 -
83 - expect(sources[0]).toHaveLength(2);
84 - expect(sources[0][0]).toBe('gmail.ts');
85 - expect(sources[0][1]).toMatchInlineSnapshot(`
86 - "/**
87 - * Map of Composio's GMAIL toolkit.
88 - */
89 - export const GMAIL = {
90 - slug: "gmail",
91 - tools: {
92 - CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",
93 - DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",
94 - FETCH_EMAILS: "GMAIL_FETCH_EMAILS",
95 - },
96 - triggerTypes: {
97 - NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",
98 - },
99 - }
100 - "
101 - `);
102 -
103 - expect(sources[1]).toHaveLength(2);
104 - expect(sources[1][0]).toBe('slack.ts');
105 - expect(sources[1][1]).toMatchInlineSnapshot(`
106 - "/**
107 - * Map of Composio's SLACK toolkit.
108 - */
109 - export const SLACK = {
110 - slug: "slack",
111 - tools: {},
112 - triggerTypes: {},
113 - }
114 - "
115 - `);
116 - });
117 - });
118 - });
119 -
120 - describe('with multiple emitted files', () => {
121 - const _params = {
122 - outputDir: '<cwd>',
123 - emitSingleFile: false,
124 - };
125 -
8 describe('with banner', () => {
127 - const params = {
128 - ..._params,
129 - banner: 'Some banner that will appear in a comment',
130 - };
9 + const banner = 'Some banner that will appear in a comment';
10
11 it('[Given] empty toolkits, tools, triggerTypes [Then] it returns an empty array', () => {
12 const index = createToolkitIndex({
@@ -136,7 +15,7 @@ describe('generateTypeScriptToolkitSources', () => {
15 triggerTypes: [],
16 });
17
139 - const sources = generateTypeScriptToolkitSources(params)(index);
18 + const sources = generateTypeScriptToolkitSources(banner)(index);
19
20 expect(sources).toEqual([]);
21 });
@@ -155,7 +34,7 @@ describe('generateTypeScriptToolkitSources', () => {
34 triggerTypes: [],
35 });
36
158 - const sources = generateTypeScriptToolkitSources(params)(index);
37 + const sources = generateTypeScriptToolkitSources(banner)(index);
38 expect(sources).toHaveLength(1);
39 expect(sources[0]).toHaveLength(2);
40 expect(sources[0][0]).toBe('slack.ts');
@@ -190,7 +69,7 @@ describe('generateTypeScriptToolkitSources', () => {
69 triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],
70 });
71
193 - const sources = generateTypeScriptToolkitSources(params)(index);
72 + const sources = generateTypeScriptToolkitSources(banner)(index);
73 expect(sources).toHaveLength(2);
74
75 expect(sources[0]).toHaveLength(2);
ts/packages/cli/tsconfig.json
+1 -1
@@ -10,5 +10,5 @@
10 },
11 "types": ["@types/bun", "vitest/importMeta"]
12 },
13 - "include": ["src", "test", "scripts"]
13 + "include": ["src/**/*", "test/**/*", "scripts/**/*", "package.json"]
14 }
ts/packages/cli/tsconfig.options.json
+1 -3
@@ -11,7 +11,6 @@
11 "moduleResolution": "node",
12 "skipLibCheck": true,
13 "resolveJsonModule": true,
14 - "verbatimModuleSyntax": true,
14 "pretty": true,
15 "noImplicitReturns": true,
16 "noFallthroughCasesInSwitch": true,
@@ -23,6 +22,5 @@
22 }
23 ]
24 },
26 - "include": ["src"],
27 - "exclude": ["**/dist", "test/__fixtures__/**"]
25 + "exclude": ["node_modules", "**/dist"]
26 }
ts/packages/cli/tsconfig.src.json
+7 -1
@@ -1,6 +1,11 @@
1 {
2 "$schema": "https://json.schemastore.org/tsconfig",
3 "extends": "./tsconfig.options.json",
4 + "references": [
5 + {
6 + "path": "../core"
7 + }
8 + ],
9 "compilerOptions": {
10 "outDir": "./dist",
11 "rootDir": ".",
@@ -9,5 +14,6 @@
14 },
15 "types": ["@types/bun"]
16 },
12 - "include": ["src"]
17 + "include": ["src/**/*", "package.json"],
18 + "exclude": ["node_modules", "../../../node_modules", "**/dist", "test/__fixtures__/**"]
19 }
ts/packages/cli/tsconfig.test.json
+9 -2
@@ -1,12 +1,19 @@
1 {
2 "$schema": "https://json.schemastore.org/tsconfig",
3 "extends": "./tsconfig.options.json",
4 + "references": [
5 + {
6 + "path": "../core"
7 + }
8 + ],
9 "compilerOptions": {
10 "rootDir": ".",
11 "paths": {
12 "src/*": ["./src/*"],
13 "test/*": ["./test/*"]
9 - }
14 + },
15 + "types": ["@types/bun", "vitest/importMeta"]
16 },
11 - "include": ["test"]
17 + "include": ["src/**/*", "test/**/*", "package.json"],
18 + "exclude": ["node_modules", "../../../node_modules", "**/dist", "test/__fixtures__/**"]
19 }
ts/packages/core/tsconfig.build.json new
+7
@@ -0,0 +1,7 @@
1 +// https://github.com/egoist/tsup/issues/571#issuecomment-1760052931
2 +{
3 + "extends": "./tsconfig.json",
4 + "compilerOptions": {
5 + "composite": false
6 + }
7 +}
ts/packages/core/tsconfig.json
+2 -1
@@ -1,5 +1,6 @@
1 {
2 "compilerOptions": {
3 + "composite": true,
4 "target": "ESNext",
5 "module": "ESNext",
6 "declaration": true,
@@ -11,5 +12,5 @@
12 "skipLibCheck": true,
13 "resolveJsonModule": true
14 },
14 - "include": ["src"]
15 + "include": ["src/**/*.ts"]
16 }
ts/packages/core/tsup.config.ts
+1
@@ -7,4 +7,5 @@ export default defineConfig({
7 clean: true,
8 minify: false,
9 outDir: 'dist',
10 + tsconfig: './tsconfig.build.json',
11 });