Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat: make generate work properly inside node modules (#1682)
Rahul Tarak9c004932d3b8
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4d8bad162..c4fd499e6 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -521,14 +521,14 @@ importers:specifier: workspace:*version: link:../ts-builders'@effect/cli':- specifier: ^0.63.11- version: 0.63.11(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])+ specifier: ^0.64.2+ version: 0.64.2(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])'@effect/platform-bun':- specifier: ^0.69.16- version: 0.69.16(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])+ specifier: ^0.70.4+ version: 0.70.5(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])'@effect/platform-node-shared':- specifier: ^0.40.2- version: 0.40.4(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])+ specifier: ^0.40.4+ version: 0.40.4(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])chalk:specifier: ^5.4.1version: 5.4.1@@ -537,7 +537,7 @@ importers:version: 3.16.8effect-errors:specifier: ^1.10.11- version: 1.10.11(cf59ec752dcdeadb070feeecd266ef4f)+ version: 1.10.11(aee16c6ba0d05f0cbe9c66fcd0455e75)indent-string:specifier: ^5.0.0version: 5.0.0@@ -552,8 +552,8 @@ importers:specifier: ^0.3.2version: 0.3.2'@effect/platform':- specifier: ^0.84.11- version: 0.84.11([email protected])+ specifier: ^0.85.2+ version: 0.85.2([email protected])'@effect/vitest':specifier: ^0.23.8version: 0.23.8([email protected])([email protected])@@ -1152,13 +1152,13 @@ packages:'@dprint/[email protected]':resolution: {integrity: sha512-tuKn4leCPItox1O4uunHcQF0QllDCvPWklnNQIh2PiWWVtRAGltJJnM4Cwj5AciplosD1Hiz7vAY3ew3crLb3A==}- '@effect/[email protected]':- resolution: {integrity: sha512-e95XKrCLHFKQor1hRWD5a1nh34cMNWfhaZrRc5iqI2sWUTQumV8rUUDAPMNHFzPC0tIrdO42wrOUhIgJs7i2iA==}+ '@effect/[email protected]':+ resolution: {integrity: sha512-j+HsbpyglfVwNFVgFNxb7EDVDvvGJgWqDqvN1B+idfHMl9D+3qB1P3pou/40yKj8J3dpOR87OBSSVIDrKc97mg==}peerDependencies:- '@effect/platform': ^0.84.11- '@effect/printer': ^0.44.7- '@effect/printer-ansi': ^0.44.7- effect: ^3.16.7+ '@effect/platform': ^0.85.2+ '@effect/printer': ^0.44.8+ '@effect/printer-ansi': ^0.44.8+ effect: ^3.16.8'@effect/[email protected]':resolution: {integrity: sha512-gHR3m/GAd5gQ2YXKJ4BX//fY1zjqRvZbKjxHuZ7+8KSvtaQbYelGDf/+DJ21nHusDL6hFJkMRSFaR7J2JYImHw==}@@ -1185,23 +1185,14 @@ packages:lmdb:optional: true- '@effect/[email protected]':- resolution: {integrity: sha512-5Mocp+ZfCZ4xw1kI5OmoTAzLKtHht8NisEwD66rc8wium+2elFxFsuiM2kGM3TYz9jC3vwkEXf1SXgecBLWz4A==}- peerDependencies:- '@effect/cluster': ^0.38.16- '@effect/platform': ^0.84.11- '@effect/rpc': ^0.61.15- '@effect/sql': ^0.37.12- effect: ^3.16.7-- '@effect/[email protected]':- resolution: {integrity: sha512-aJ7jVm9V+SEeNumRmHb+TxD0C38uv/1LLfBHB2Qg+xb5UjnZhak8SzwolAgSKkMNDFpAAdF2AlxZ1tO/HfhCiw==}+ '@effect/[email protected]':+ resolution: {integrity: sha512-3nvR+RFo0apkwL1HgbuyVCDFqTtgkubiHSN8T0zC+nYJWvghR75VaU2ajbDLECUltpef53g5iNisnXpwUC92bQ==}peerDependencies:- '@effect/cluster': ^0.38.16- '@effect/platform': ^0.84.11- '@effect/rpc': ^0.61.15- '@effect/sql': ^0.37.12- effect: ^3.16.7+ '@effect/cluster': ^0.39.5+ '@effect/platform': ^0.85.2+ '@effect/rpc': ^0.62.4+ '@effect/sql': ^0.38.2+ effect: ^3.16.8'@effect/[email protected]':resolution: {integrity: sha512-EfnRTSHKs33OTfKN9pF+G2AyxMXm/+4rKrGM8yEw56Ij6QV5dq2g28yi0eOH7BytvilnreVmcbAec7M77EArgg==}@@ -1212,6 +1203,15 @@ packages:'@effect/sql': ^0.38.2effect: ^3.16.8+ '@effect/[email protected]':+ resolution: {integrity: sha512-Ru86IQ0E3tZNgO6UiWXBWNj4qZOgMT10z4fGF7Y4XwaB6lASWaFmCsDAkfYSqsmoesbtWvPQXbJkOr2QHYeU0Q==}+ peerDependencies:+ '@effect/cluster': ^0.39.5+ '@effect/platform': ^0.85.2+ '@effect/rpc': ^0.62.4+ '@effect/sql': ^0.38.2+ effect: ^3.16.8+'@effect/[email protected]':resolution: {integrity: sha512-AImYc+Tg/EF0miKKgORgQEEZ1a6PpdqkH2ZU4wt0ChmWi1XFa1WF/NYzK5qRrtfSKF+ug6Vd/5/psWvZNJTdyw==}peerDependencies:@@ -1221,10 +1221,10 @@ packages:'@effect/sql': ^0.38.2effect: ^3.16.8- '@effect/[email protected]':- resolution: {integrity: sha512-u3eURhaF38e8jqq/JC2NW9EDHUFVDETD/JLEFtFi7N6RnAUF90qaC8sRcoK5xe8UAo3/fJDQ+sEfDqYonUa30w==}+ '@effect/[email protected]':+ resolution: {integrity: sha512-zIRixbQeO6QniR0k2mwR7DmR2HO1w6+qQlzQ5nb8lyPyPgd1gV9wo/9yBeB6zRC+CGnxiUiYsRMamclVISuxLw==}peerDependencies:- effect: ^3.16.7+ effect: ^3.16.8'@effect/[email protected]':resolution: {integrity: sha512-HFatTgDyPgXc0Kbw2BH0nUht0ViAPukggIHuxGDm1EN0G7uKX9qXHLkFaQ7HGhotNOuf2hC6AXaKkzWOhxWp1A==}@@ -6906,9 +6906,9 @@ snapshots:'@dprint/[email protected]': {}- '@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])':dependencies:- '@effect/platform': 0.84.11([email protected])+ '@effect/platform': 0.85.2([email protected])effect: 3.16.8@@ -6916,12 +6916,12 @@ snapshots:toml: 3.0.0yaml: 2.8.0- '@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])':dependencies:- '@effect/platform': 0.84.11([email protected])- '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])- '@effect/workflow': 0.2.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])+ '@effect/platform': 0.85.2([email protected])+ '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])+ '@effect/workflow': 0.2.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])effect: 3.16.8'@effect/[email protected]':@@ -6930,31 +6930,31 @@ snapshots:'@dprint/typescript': 0.91.8prettier-linter-helpers: 1.0.0dependencies:- '@effect/platform': 0.84.11([email protected])+ '@effect/platform': 0.85.2([email protected])effect: 3.16.8uuid: 11.1.0- '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':dependencies:- '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])- '@effect/platform': 0.84.11([email protected])- '@effect/platform-node-shared': 0.39.16(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])- '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])+ '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])+ '@effect/platform': 0.85.2([email protected])+ '@effect/platform-node-shared': 0.40.5(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])+ '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])effect: 3.16.8multipasta: 0.2.5transitivePeerDependencies:- bufferutil- utf-8-validate- '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':dependencies:- '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])- '@effect/platform': 0.84.11([email protected])- '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])+ '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])+ '@effect/platform': 0.85.2([email protected])+ '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])'@parcel/watcher': 2.5.1effect: 3.16.8multipasta: 0.2.5@@ -6963,12 +6963,12 @@ snapshots:- bufferutil- utf-8-validate- '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':dependencies:- '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])- '@effect/platform': 0.84.11([email protected])- '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])+ '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])+ '@effect/platform': 0.85.2([email protected])+ '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])'@parcel/watcher': 2.5.1effect: 3.16.8multipasta: 0.2.5@@ -6977,13 +6977,13 @@ snapshots:- bufferutil- utf-8-validate- '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])':dependencies:- '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])- '@effect/platform': 0.84.11([email protected])- '@effect/platform-node-shared': 0.40.4(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])- '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])+ '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])+ '@effect/platform': 0.85.2([email protected])+ '@effect/platform-node-shared': 0.40.4(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])+ '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])effect: 3.16.8mime: 3.0.0undici: 7.10.0@@ -6992,7 +6992,7 @@ snapshots:- bufferutil- utf-8-validate- '@effect/[email protected]([email protected])':+ '@effect/[email protected]([email protected])':dependencies:effect: 3.16.8find-my-way-ts: 0.1.5@@ -7010,15 +7010,15 @@ snapshots:'@effect/typeclass': 0.35.8([email protected])effect: 3.16.8dependencies:- '@effect/platform': 0.84.11([email protected])+ '@effect/platform': 0.85.2([email protected])effect: 3.16.8- '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])':dependencies:- '@effect/platform': 0.84.11([email protected])+ '@effect/platform': 0.85.2([email protected])'@opentelemetry/semantic-conventions': 1.34.0effect: 3.16.8uuid: 11.1.0@@ -7032,10 +7032,10 @@ snapshots:effect: 3.16.8vitest: 3.2.4(@types/[email protected])(@vitest/[email protected])([email protected])([email protected])([email protected])- '@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])':+ '@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected])':dependencies:- '@effect/platform': 0.84.11([email protected])+ '@effect/platform': 0.85.2([email protected])effect: 3.16.8'@emnapi/[email protected]':@@ -9832,13 +9832,13 @@ snapshots:- [email protected](cf59ec752dcdeadb070feeecd266ef4f):+ [email protected](aee16c6ba0d05f0cbe9c66fcd0455e75):dependencies:- '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])- '@effect/platform': 0.84.11([email protected])- '@effect/platform-node': 0.86.4(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])- '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])+ '@effect/cluster': 0.39.4(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected])+ '@effect/platform': 0.85.2([email protected])+ '@effect/platform-node': 0.86.4(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))([email protected]))([email protected]))(@effect/[email protected]([email protected]))(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected](@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected]))([email protected])+ '@effect/sql': 0.38.2(@effect/[email protected](@effect/[email protected]([email protected]))([email protected]))(@effect/[email protected]([email protected]))([email protected])comment-json: 4.2.5effect: 3.16.8picocolors: 1.1.1diff --git a/ts/packages/cli/package.json b/ts/packages/cli/package.jsonindex 08e670b11..717714c90 100644--- a/ts/packages/cli/package.json+++ b/ts/packages/cli/package.json@@ -40,7 +40,7 @@"packageManager": "[email protected]","devDependencies": {"@effect/eslint-plugin": "^0.3.2",- "@effect/platform": "^0.84.11",+ "@effect/platform": "^0.85.2","@effect/vitest": "^0.23.8","@types/bun": "^1.2.16","@types/semver": "^7.7.0",@@ -54,9 +54,9 @@"@composio/client": "0.1.0-alpha.17","@composio/core": "workspace:*","@composio/ts-builders": "workspace:*",- "@effect/cli": "^0.63.11",- "@effect/platform-bun": "^0.69.16",- "@effect/platform-node-shared": "^0.40.2",+ "@effect/cli": "^0.64.2",+ "@effect/platform-bun": "^0.70.4",+ "@effect/platform-node-shared": "^0.40.4","chalk": "^5.4.1","effect": "^3.16.8","effect-errors": "^1.10.11",diff --git a/ts/packages/cli/src/bin.ts b/ts/packages/cli/src/bin.tsindex e321f423a..4a2820cec 100644--- a/ts/packages/cli/src/bin.ts+++ b/ts/packages/cli/src/bin.ts@@ -14,6 +14,7 @@ import {} from 'src/services/composio-clients';import { NodeProcess } from 'src/services/node-process';import { EnvLangDetector } from './services/env-lang-detector';+import { JsPackageManagerDetector } from './services/js-package-manager-detector';/*** Concrete Effect layer compositions for the Composio CLI runtime.@@ -42,6 +43,7 @@ const layers = Layer.mergeAll(ComposioSessionRepository.Default.pipe(Layer.provide(UserConfigProviderLiveFromFs)),ComposioToolkitsRepository.Default.pipe(Layer.provide(UserConfigProviderLiveFromFs)),EnvLangDetector.Default,+ JsPackageManagerDetector.Default,BunContext.layer,BunFileSystem.layer);@@ -65,6 +67,7 @@ if (require.main === module) {runWithArgs.pipe(Effect.provide(layers),Effect.provide(BunContext.layer),+ Effect.scoped,Effect.withSpan('composio-cli', {attributes: {name: constants.APP_NAME,diff --git a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.tsindex c21fbbcd3..89f0c66f4 100644--- a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts+++ b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts@@ -1,12 +1,13 @@-import path from 'node:path';import { Command, Options } from '@effect/cli';-import { Console, Effect, Option } from 'effect';+import { pipe, Console, Effect, Option } from 'effect';import { FileSystem } from '@effect/platform';import { ComposioToolkitsRepository } from 'src/services/composio-clients';import type { GetCmdParams } from 'src/type-utils';import { NodeProcess } from 'src/services/node-process';import { createToolkitIndex } from 'src/generation/create-toolkit-index';-import { generatePythonToolkitSources } from 'src/generation/python/generate-toolkit-sources';+import { pyFindComposioCoreGenerated } from 'src/effects/find-composio-core-generated';+import { BANNER } from 'src/generation/constants';+import { generatePythonSources } from 'src/generation/python/generate';export const outputOpt = Options.optional(Options.directory('output-dir', {@@ -14,9 +15,7 @@ export const outputOpt = Options.optional(})).pipe(Options.withAlias('o'),- Options.withDescription(- 'Output directory for the generated Python type stubs (default: `./.generated/composio-py`)'- )+ Options.withDescription('Output directory for the generated Python type stubs'));const _pyCmd$Generate = Command.make('generate', { outputOpt }).pipe(@@ -29,37 +28,71 @@ export function generatePythonTypeStubs({ outputOpt }: GetCmdParams<typeof _pyCmreturn Effect.gen(function* () {const process = yield* NodeProcess;const cwd = process.cwd;-const fs = yield* FileSystem.FileSystem;+ const client = yield* ComposioToolkitsRepository;- const output = outputOpt.pipe(- Option.getOrElse(() => path.join(cwd, '.generated', 'composio-py'))- );- yield* fs.makeDirectory(output, { recursive: true });+ // Determine the actual output directory+ const outputDir = yield* outputOpt.pipe(+ Option.match({+ // If no output directory is specified, use the default+ onNone: () => pyFindComposioCoreGenerated(cwd),- yield* Console.log('Fetching latest data from Composio API...');- const client = yield* ComposioToolkitsRepository;+ // If an output directory is specified, validate and create it+ onSome: outputDir =>+ pipe(+ Effect.succeed(outputDir),+ Effect.tap(fs.makeDirectory(outputDir, { recursive: true }))+ ),+ })+ );- yield* Effect.logDebug('Fetching toolkits...');- const toolkits = yield* client.getToolkits();+ yield* Effect.log(`Writing type stubs to ${outputDir}...`);- yield* Effect.logDebug('Fetching tools...');- const tools = yield* client.getTools();+ // Fetch data from Composio API+ yield* Console.log('Fetching latest data from Composio API...');- yield* Effect.logDebug('Fetching trigger types...');- const triggerTypes = yield* client.getTriggerTypes();+ const [toolkits, tools, triggerTypes] = yield* Effect.all(+ [+ Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),+ Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getTools())),+ Effect.logDebug('Fetching trigger types...').pipe(+ Effect.flatMap(() => client.getTriggerTypes())+ ),+ ],+ { concurrency: 'unbounded' }+ );const index = createToolkitIndex({ toolkits, tools, triggerTypes });- const sourceFiles = generatePythonToolkitSources(index).map(- ([filename, content]) => [path.join(output, filename), content] as const- );- yield* Console.log(`Writing type stubs to ${output}...`);+ // Generate Python sources+ const sources = generatePythonSources({+ banner: BANNER,+ outputDir,+ })(index);- yield* Effect.all(- sourceFiles.map(([filePath, content]) => fs.writeFileString(filePath, content))+ // Write all generated files+ yield* pipe(+ Effect.all(+ sources.map(([filePath, content]) =>+ fs+ .writeFileString(filePath, content)+ .pipe(Effect.mapError(error => new Error(`Failed to write file ${filePath}: ${error}`)))+ ),+ { concurrency: 1 }+ ),+ Effect.mapError(error => new Error(`Failed to write generated files: ${error}`)));- return yield* Console.log('✅ Type stubs generated successfully.');+ yield* Option.isNone(outputOpt)+ ? Console.log(+ '✅ Type stubs generated successfully.\n' ++ 'You can now import generated types via `from composio.<toolkit_name> import <TOOLKIT_NAME>`.\n'+ )+ : Console.log(+ `✅ Type stubs generated successfully.\n` ++ `Generated files are available at: ${outputDir}`+ );++ return outputDir;});}diff --git a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.tsindex cf406504f..2bacfc2b3 100644--- a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts+++ b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts@@ -1,12 +1,31 @@+/**+ * The `composio ts generate` command can be configured as follows:+ * - `--compact`: Emit a single module file+ * - `--transpiled`: Emit not just the TypeScript files, but also the transpiled JavaScript files+ * - `--output-dir`: Output directory for the generated TypeScript type stubs.+ *+ * Invariants:+ * - The `--output-dir` cannot refer to a path inside `node_modules`+ * - If `--output-dir` is not specified, the command will use `findComposioCoreGeneratedPath` to locate the `@composio/core` package+ * and write to it inside `node_modules`+ * - The absence of `--output-dir` implies that, by default, `--transpiled` is set to true+ * - If `--output-dir` is specified, `--transpiled` is, by default, set to false+ * - If `--transpiled` evaluates to true, the sources generated by `generateTypeScriptSources` need to be transpiled to ESM JavaScript too,+ * and stored along with the generated TypeScript files. CJS is not supported.+ */+import path from 'node:path';import { Command, Options } from '@effect/cli';-import { Console, Effect, Option } from 'effect';+import { Console, Effect, Option, pipe } from 'effect';import { FileSystem } from '@effect/platform';import { ComposioToolkitsRepository } from 'src/services/composio-clients';import { NodeProcess } from 'src/services/node-process';import { createToolkitIndex } from 'src/generation/create-toolkit-index';import type { GetCmdParams } from 'src/type-utils';import { generateTypeScriptSources } from 'src/generation/typescript/generate';+import { jsFindComposioCoreGenerated } from 'src/effects/find-composio-core-generated';+import { transpileTypeScriptSources } from 'src/generation/typescript/transpile';+import { BANNER } from 'src/generation/constants';export const outputOpt = Options.optional(Options.directory('output-dir', {@@ -14,62 +33,143 @@ export const outputOpt = Options.optional(})).pipe(Options.withAlias('o'),- Options.withDescription(- 'Output directory for the generated Python type stubs (default: `./.generated/composio-py`)'- )+ Options.withDescription('Output directory for the generated TypeScript type stubs.'));-export const singleFile = Options.boolean('single-file').pipe(+export const compact = Options.boolean('compact').pipe(Options.withDefault(false),Options.withDescription('Emit a single TypeScript file'));-const _tsCmd$Generate = Command.make('generate', { outputOpt, singleFile }).pipe(- Command.withDescription('Updates the local type stubs with the latest app data.')+export const transpiled = Options.boolean('transpiled').pipe(+ Options.withDefault(false),+ Options.withDescription('Whether to emit transpiled JavaScript alongside TypeScript files'));+const _tsCmd$Generate = Command.make('generate', {+ outputOpt,+ compact,+ transpiled: transpiled,+}).pipe(Command.withDescription('Updates the local type stubs with the latest app data.'));++/**+ * Validates that the output directory is not inside node_modules+ */+function validateOutputDir(outputDir: string): Effect.Effect<string, Error, FileSystem.FileSystem> {+ return Effect.gen(function* () {+ const normalizedPath = path.normalize(outputDir);++ if (normalizedPath.includes('node_modules')) {+ return yield* Effect.fail(+ new Error(+ 'Output directory cannot be inside node_modules. Please specify a different directory.'+ )+ );+ }++ return outputDir;+ });+}+export const tsCmd$Generate = _tsCmd$Generate.pipe(- Command.withHandler(generateTypescriptTypeStubs)+ Command.withHandler(params => {+ // Determine if we should compile based on the rules:+ // - If --output-dir is specified, default transpiled to false unless overridden+ // - If no --output-dir, default transpiled to true unless overridden+ const shouldCompile = params.transpiled || !Option.isSome(params.outputOpt);++ return generateTypescriptTypeStubs({+ ...params,+ compact: params.compact,+ transpiled: shouldCompile,+ });+ }));export function generateTypescriptTypeStubs({outputOpt,- singleFile,-}: GetCmdParams<typeof _tsCmd$Generate>) {+ compact,+ transpiled = false,+}: GetCmdParams<typeof _tsCmd$Generate> & { transpiled?: boolean }) {return Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;const process = yield* NodeProcess;const cwd = process.cwd;+ const client = yield* ComposioToolkitsRepository;- const fs = yield* FileSystem.FileSystem;+ // Determine the actual output directory+ const outputDir = yield* outputOpt.pipe(+ Option.match({+ // If no output directory is specified, use the default+ onNone: () => jsFindComposioCoreGenerated(cwd),- const outputDir = outputOpt.pipe(- Option.getOrElse(() => path.join(cwd, '.generated', 'composio-ts'))+ // If an output directory is specified, validate and create it+ onSome: outputDir =>+ validateOutputDir(outputDir).pipe(+ Effect.tap(fs.makeDirectory(outputDir, { recursive: true }))+ ),+ }));- yield* fs.makeDirectory(outputDir, { recursive: true });-- yield* Console.log('Fetching latest data from Composio API...');- const client = yield* ComposioToolkitsRepository;- yield* Effect.logDebug('Fetching toolkits...');- const toolkits = yield* client.getToolkits();+ yield* Effect.log(`Writing type stubs to ${outputDir}...`);- yield* Effect.logDebug('Fetching tools...');- const tools = yield* client.getTools();+ // Fetch data from Composio API+ yield* Console.log('Fetching latest data from Composio API...');- yield* Effect.logDebug('Fetching trigger types...');- const triggerTypes = yield* client.getTriggerTypes();+ const [toolkits, tools, triggerTypes] = yield* Effect.all(+ [+ Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),+ Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getTools())),+ Effect.logDebug('Fetching trigger types...').pipe(+ Effect.flatMap(() => client.getTriggerTypes())+ ),+ ],+ { concurrency: 'unbounded' }+ );const index = createToolkitIndex({ toolkits, tools, triggerTypes });++ // Generate TypeScript sourcesconst sources = generateTypeScriptSources({- banner: 'Auto-generated by Composio CLI. Do not modify manually.',- emitSingleFile: singleFile,outputDir,+ emitSingleFile: Boolean(compact), // Ensure boolean type+ banner: BANNER,+ importExtension: 'js',})(index);- yield* Console.log(`Writing type stubs to ${outputDir}...`);+ // Write all generated files+ yield* pipe(+ Effect.all(+ sources.map(([filePath, content]) =>+ fs+ .writeFileString(filePath, content)+ .pipe(Effect.mapError(error => new Error(`Failed to write file ${filePath}: ${error}`)))+ ),+ { concurrency: 'unbounded' }+ ),+ Effect.mapError(error => new Error(`Failed to write generated files: ${error}`))+ );++ // Compile TypeScript to JavaScript if needed+ if (transpiled) {+ yield* pipe(+ transpileTypeScriptSources({ sources, outputDir }),+ Effect.catchAll(error =>+ Effect.logWarning(`Failed to compile TypeScript files: ${error.message}`)+ )+ );+ }- yield* Effect.all(sources.map(([filePath, content]) => fs.writeFileString(filePath, content)));+ yield* Option.isNone(outputOpt)+ ? Console.log(+ '✅ Type stubs generated successfully.\n' ++ 'You can now import generated types via `import { composio } from "@composio/core/generated"`'+ )+ : Console.log(+ `✅ Type stubs generated successfully.\n` ++ `Generated files are available at: ${outputDir}`+ );- return yield* Console.log('✅ Type stubs generated successfully.');+ return outputDir;});}diff --git a/ts/packages/cli/src/effects/find-composio-core-generated.ts b/ts/packages/cli/src/effects/find-composio-core-generated.tsnew file mode 100644index 000000000..1e7e1c2a1--- /dev/null+++ b/ts/packages/cli/src/effects/find-composio-core-generated.ts@@ -0,0 +1,130 @@+import path from 'node:path';+import { Command, FileSystem } from '@effect/platform';+import { Data, Effect, Match, Option } from 'effect';+import {+ JsPackageManagerDetector,+ type PackageManager,+} from 'src/services/js-package-manager-detector';++export class ComposioCorePkgNotFound extends Data.TaggedError('error/ComposioCorePkgNotFound')<{+ readonly message: string;+ readonly cause: string;+ readonly fix?: string;+}> {}++export function pyFindComposioCoreGenerated(cwd: string) {+ return Effect.gen(function* () {+ /**+ * Returns a `ComposioCorePkgNotFound` error with the given message and cause.+ * It lazily identifies the package manager used by the user to tell them how to install `@composio/core`.+ */+ const onError = (message: string) => (e: Error | string) =>+ Effect.gen(function* () {+ yield* Effect.logDebug('Identifying JS package manager...');+ const pkgManagerDetector = yield* JsPackageManagerDetector;+ const pkgManager = yield* pkgManagerDetector.detectJsPackageManager(cwd).pipe(+ Effect.andThen(pkgManager => pkgManager),+ Effect.tapError(e => Effect.logError(e)),+ Effect.catchAll(() => Effect.succeed('npm' as PackageManager))+ );++ yield* Effect.logDebug({ pkgManager });++ const installCmd = `uv pip install`;++ const fix = `Install \`composio-core\` with \`${installCmd} composio-core\`, or specify an output directory using \`--output-dir\``;++ return yield* Effect.fail(+ new ComposioCorePkgNotFound({+ cause: e instanceof Error ? e.message : e,+ fix,+ message,+ })+ );+ }) satisfies Effect.Effect<never, ComposioCorePkgNotFound, JsPackageManagerDetector>;++ // Try to find `composio-core` in the current `uv` environment+ // Try to find `composio-core` in the current `uv` environment+ const [cmd, ...args] = [+ 'uv',+ 'run',+ '--active',+ 'python',+ '-c',+ 'import composio; print(composio.__file__)',+ ];++ const stdout = yield* Command.make(cmd, ...args).pipe(+ Command.string,+ Effect.catchAll(e => onError('Failed to locate composio-core in uv environment')(e))+ );++ yield* Effect.logDebug({ stdout, cmd: [cmd, ...args].join(' ') });++ const composioCorePath = path.dirname(stdout);+ yield* Effect.logDebug({ composioCorePath });++ return composioCorePath;+ }) satisfies Effect.Effect<string, ComposioCorePkgNotFound, unknown>;+}++/**+ * Returns the path to `@composio/core/generated` inside the user's project, if it exists.+ * The search is scoped to the given current working directory.+ */+export function jsFindComposioCoreGenerated(cwd: string) {+ return Effect.gen(function* () {+ /**+ * Returns a `ComposioCorePkgNotFound` error with the given message and cause.+ * It lazily identifies the package manager used by the user to tell them how to install `@composio/core`.+ */+ const onError = (message: string) => (e: Error | string) =>+ Effect.gen(function* () {+ yield* Effect.logDebug('Identifying JS package manager...');+ const pkgManagerDetector = yield* JsPackageManagerDetector;+ const pkgManager = yield* pkgManagerDetector.detectJsPackageManager(cwd).pipe(+ Effect.andThen(pkgManager => pkgManager),+ Effect.tapError(e => Effect.logError(e)),+ Effect.catchAll(() => Effect.succeed('npm' as PackageManager))+ );++ yield* Effect.logDebug({ pkgManager });++ const installCmd = Match.value(pkgManager).pipe(+ Match.when('pnpm', () => 'pnpm add'),+ Match.when('bun', () => 'bun add'),+ Match.when('yarn', () => 'yarn add'),+ Match.when('npm', () => 'npm install -S'),+ Match.exhaustive+ );++ const fix = `Install @composio/core with \`${installCmd} @composio/core\`, or specify an output directory using \`--output-dir\``;++ return yield* Effect.fail(+ new ComposioCorePkgNotFound({+ cause: e instanceof Error ? e.message : e,+ fix,+ message,+ })+ );+ }) satisfies Effect.Effect<never, ComposioCorePkgNotFound, JsPackageManagerDetector>;++ const fs = yield* FileSystem.FileSystem;++ // First, try to find @composio/core in node_modules+ const nodeModulesPath = path.join(cwd, 'node_modules', '@composio', 'core');+ const nodeModulesExists = yield* fs+ .exists(nodeModulesPath)+ .pipe(+ Effect.catchAll(e =>+ Effect.flip(onError('@composio/core not readable in `node_modules`')(e))+ )+ );++ if (nodeModulesExists) {+ return path.join(nodeModulesPath, 'generated');+ }++ return yield* onError('@composio/core not found')('@composio/core not installed');+ }) satisfies Effect.Effect<string, ComposioCorePkgNotFound, unknown>;+}diff --git a/ts/packages/cli/src/generation/constants.ts b/ts/packages/cli/src/generation/constants.tsnew file mode 100644index 000000000..11dc04a15--- /dev/null+++ b/ts/packages/cli/src/generation/constants.ts@@ -0,0 +1 @@+export const BANNER = 'Auto-generated by Composio CLI. Do not modify manually.';diff --git a/ts/packages/cli/src/generation/python/generate-toolkit-sources.ts b/ts/packages/cli/src/generation/python/generate-toolkit-sources.tsindex 1eddb1668..2101d0201 100644--- a/ts/packages/cli/src/generation/python/generate-toolkit-sources.ts+++ b/ts/packages/cli/src/generation/python/generate-toolkit-sources.ts@@ -20,49 +20,53 @@import { pipe, Record } from 'effect';import type { ToolkitName } from 'src/models/toolkits';-import type { ToolkitIndex, ToolkitIndexData } from '../create-toolkit-index';--type SourceFile = [filename: string, content: string];+import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';+import type { SourceFile } from 'src/generation/types';/*** Generates a list of Python source files that should be written to disk by the caller.*/-export function generatePythonToolkitSources(index: ToolkitIndex): Array<SourceFile> {- return pipe(index, Record.mapEntries(generatePythonToolkitSource), Record.toEntries);+export function generatePythonToolkitSources(banner: string) {+ return (index: ToolkitIndex): Array<SourceFile> => {+ const toolkitSources = pipe(+ index,+ Record.mapEntries(generatePythonToolkitSource(banner)),+ Record.toEntries+ );++ return toolkitSources;+ };}-function generatePythonToolkitSource(- toolkit: ToolkitIndexData,- toolkitName: ToolkitName-): SourceFile {- const filename = `${toolkit.slug}.py`;+function generatePythonToolkitSource(banner: string) {+ return (toolkit: ToolkitIndexData, toolkitName: ToolkitName): SourceFile => {+ const filename = `${toolkit.slug}.py`;- const toolsEntries = (spacing: number) => {- const spacePad = ' '.repeat(spacing);+ const toolsEntries = (spacing: number) => {+ const spacePad = ' '.repeat(spacing);- if (Record.size(toolkit.tools) > 0) {- return Object.entries(toolkit.tools)- .map(([toolName, toolValue]) => `${spacePad}${toolName} = "${toolValue}"`)- .join('\n');- }+ if (Record.size(toolkit.tools) > 0) {+ return Object.entries(toolkit.tools)+ .map(([toolName, toolValue]) => `${spacePad}${toolName} = "${toolValue}"`)+ .join('\n');+ }- return `${spacePad}pass`;- };+ return `${spacePad}pass`;+ };- const triggerTypesEntries = (spacing: number) => {- const spacePad = ' '.repeat(spacing);+ const triggerTypesEntries = (spacing: number) => {+ const spacePad = ' '.repeat(spacing);- if (Record.size(toolkit.triggerTypes) > 0) {- return Object.entries(toolkit.triggerTypes)- .map(([triggerName, triggerValue]) => `${spacePad}${triggerName} = "${triggerValue}"`)- .join('\n');- }+ if (Record.size(toolkit.triggerTypes) > 0) {+ return Object.entries(toolkit.triggerTypes)+ .map(([triggerName, triggerValue]) => `${spacePad}${triggerName} = "${triggerValue}"`)+ .join('\n');+ }- return `${spacePad}pass`;- };+ return `${spacePad}pass`;+ };- const filesource = `# Auto-generated by Composio CLI via \`composio py generate\`.-# Do not modify manually.+ const filesource = `# ${banner}.class ${toolkitName}:"""Map of Composio's ${toolkitName} toolkit."""@@ -76,5 +80,6 @@ ${toolsEntries(8)}${triggerTypesEntries(8)}`;- return [filename, filesource];+ return [filename, filesource];+ };}diff --git a/ts/packages/cli/src/generation/python/generate.ts b/ts/packages/cli/src/generation/python/generate.tsnew file mode 100644index 000000000..108c5437f--- /dev/null+++ b/ts/packages/cli/src/generation/python/generate.ts@@ -0,0 +1,21 @@+import path from 'node:path';+import type { ToolkitIndex } from 'src/generation/create-toolkit-index';+import type { SourceFile } from 'src/generation/types';+import { generatePythonToolkitSources } from './generate-toolkit-sources';++type GeneratePythonSourcesParams = {+ banner: string;+ outputDir: string;+};++export function generatePythonSources(params: GeneratePythonSourcesParams) {+ return (index: ToolkitIndex): Array<SourceFile> => {+ const toolkiteSources = generatePythonToolkitSources(params.banner)(index);++ return [+ ...toolkiteSources.map(+ ([filename, content]) => [path.join(params.outputDir, filename), content] as const+ ),+ ] as const;+ };+}diff --git a/ts/packages/cli/src/generation/types.ts b/ts/packages/cli/src/generation/types.tsnew file mode 100644index 000000000..699443474--- /dev/null+++ b/ts/packages/cli/src/generation/types.ts@@ -0,0 +1 @@+export type SourceFile = readonly [filename: string, content: string];diff --git a/ts/packages/cli/src/generation/typescript/generate-index-source.ts b/ts/packages/cli/src/generation/typescript/generate-index-source.tsindex ab5190987..3c0137eb4 100644--- a/ts/packages/cli/src/generation/typescript/generate-index-source.ts+++ b/ts/packages/cli/src/generation/typescript/generate-index-source.ts@@ -25,14 +25,15 @@import * as ts from '@composio/ts-builders';import { pipe, Record, Array as Arr } from 'effect';-import type { ToolkitIndex } from '../create-toolkit-index';+import type { ToolkitIndex } from 'src/generation/create-toolkit-index';-type generateTypeScriptIndexMapSourceParams = {+type GenerateTypeScriptIndexMapSourceParams = {banner: string;emitSingleFile: boolean;+ importExtension: 'ts' | 'js';};-export function generateIndexSource(params: generateTypeScriptIndexMapSourceParams) {+export function generateIndexSource(params: GenerateTypeScriptIndexMapSourceParams) {return (index: ToolkitIndex) => {const indexMap = generateTypeScriptIndexMapSource(params)(index);const toolkitUnionType = generateToolkitUnionType(index);@@ -57,7 +58,7 @@ ${toolsByToolkitType}/*** Generates a list of Python source files that should be written to disk by the caller.*/-export function generateTypeScriptIndexMapSource(params: generateTypeScriptIndexMapSourceParams) {+export function generateTypeScriptIndexMapSource(params: GenerateTypeScriptIndexMapSourceParams) {return (index: ToolkitIndex): string => {const indexMapEntries = pipe(index,@@ -74,7 +75,9 @@ export function generateTypeScriptIndexMapSource(params: generateTypeScriptIndexbreak;}- indexMapFile.addImport(ts.moduleImport(`./${value.slug}.ts`).named(toolkitName));+ indexMapFile.addImport(+ ts.moduleImport(`./${value.slug}.${params.importExtension}`).named(toolkitName)+ );}indexMapFile.add(diff --git a/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts b/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.tsindex 81810979d..adddf619c 100644--- a/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts+++ b/ts/packages/cli/src/generation/typescript/generate-toolkit-sources.ts@@ -26,24 +26,17 @@import * as ts from '@composio/ts-builders';import { pipe, Record } from 'effect';import type { ToolkitName } from 'src/models/toolkits';-import type { ToolkitIndex, ToolkitIndexData } from '../create-toolkit-index';--type SourceFile = [filename: string, content: string];--type GenerateTypeScriptToolkitSourcesInput = {- banner: string;- emitSingleFile: boolean;- outputDir: string;-};+import type { ToolkitIndex, ToolkitIndexData } from 'src/generation/create-toolkit-index';+import type { SourceFile } from 'src/generation/types';/**- * Generates a list of Python source files that should be written to disk by the caller.+ * Generates a list of TypeScript source files that should be written to disk by the caller.*/-export function generateTypeScriptToolkitSources(params: GenerateTypeScriptToolkitSourcesInput) {+export function generateTypeScriptToolkitSources(banner: string) {return (index: ToolkitIndex): Array<SourceFile> => {const toolkitSources = pipe(index,- Record.mapEntries(generateTypeScriptToolkitSource(params)),+ Record.mapEntries(generateTypeScriptToolkitSource(banner)),Record.toEntries);@@ -51,7 +44,7 @@ export function generateTypeScriptToolkitSources(params: GenerateTypeScriptToolk};}-function generateTypeScriptToolkitSource(_params: GenerateTypeScriptToolkitSourcesInput) {+function generateTypeScriptToolkitSource(_banner: string) {return ({ slug, tools, triggerTypes }: ToolkitIndexData,toolkitName: ToolkitNamediff --git a/ts/packages/cli/src/generation/typescript/generate.ts b/ts/packages/cli/src/generation/typescript/generate.tsindex 266fa1103..b246bdb76 100644--- a/ts/packages/cli/src/generation/typescript/generate.ts+++ b/ts/packages/cli/src/generation/typescript/generate.ts@@ -4,15 +4,18 @@ import type { ToolkitIndex } from 'src/generation/create-toolkit-index';import { generateTypeScriptToolkitSources } from './generate-toolkit-sources';import { generateIndexSource } from './generate-index-source';+type SourceFile = readonly [filename: string, content: string];+type GenerateTypeScriptSourcesParams = {banner: string;emitSingleFile: boolean;outputDir: string;+ importExtension: 'ts' | 'js';};export function generateTypeScriptSources(params: GenerateTypeScriptSourcesParams) {- return (index: ToolkitIndex): Array<readonly [string, string]> => {- const toolkiteSources = generateTypeScriptToolkitSources(params)(index);+ return (index: ToolkitIndex): Array<SourceFile> => {+ const toolkiteSources = generateTypeScriptToolkitSources(params.banner)(index);const indexSource = generateIndexSource(params)(index);const indexFilename = path.join(params.outputDir, 'index.ts');diff --git a/ts/packages/cli/src/generation/typescript/transpile.ts b/ts/packages/cli/src/generation/typescript/transpile.tsnew file mode 100644index 000000000..4ef1ae94f--- /dev/null+++ b/ts/packages/cli/src/generation/typescript/transpile.ts@@ -0,0 +1,90 @@+import ts from 'typescript';+import { Effect, Data } from 'effect';++export class TypeScriptTranspileError extends Data.TaggedError('error/TypeScriptTranspileError')<{+ readonly message: string;+ readonly cause: string;+}> {}++type TranspileTypeScriptFilesParams = {+ sources: (readonly [filePath: string, content: string])[];+ outputDir: string;+};++/**+ * Compiles TypeScript files to JavaScript using the TypeScript compiler.+ * TODO: unify with `test/__utils__/typescript-compiler.ts`.+ */+export function transpileTypeScriptSources({ sources, outputDir }: TranspileTypeScriptFilesParams) {+ return Effect.gen(function* () {+ const compilerOptions = {+ target: ts.ScriptTarget.ES2022,+ module: ts.ModuleKind.NodeNext,+ moduleResolution: ts.ModuleResolutionKind.NodeNext,+ esModuleInterop: true,+ skipLibCheck: true,+ outDir: outputDir,+ rootDir: outputDir,+ declaration: true,+ emitDeclarationOnly: false,+ noEmitOnError: true,+ } satisfies ts.CompilerOptions;++ const virtualFileMap = new Map(+ sources.map(+ ([filename, code]) =>+ [+ filename,+ ts.createSourceFile(filename, code, compilerOptions.target, true, ts.ScriptKind.TS),+ ] as const+ )+ );+ const virtualFileNames = Array.from(virtualFileMap.keys());+ const tsFiles = sources.map(([filePath, _]) => filePath);++ if (tsFiles.length === 0) {+ return yield* Effect.void;+ }++ const tsHost = ts.createCompilerHost(compilerOptions);+ const ogGetSourceFile = tsHost.getSourceFile;+ tsHost.getSourceFile = (filename, languageVersion, onError, shouldCreateNewSourceFile) => {+ if (virtualFileMap.has(filename)) {+ return virtualFileMap.get(filename);+ }++ return ogGetSourceFile(filename, languageVersion, onError, shouldCreateNewSourceFile);+ };++ const program = ts.createProgram(virtualFileNames, compilerOptions, tsHost);+ const emitResult = program.emit();++ // Check for syntax or semantic errors+ const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);++ if (diagnostics.length > 0) {+ const formatDiagnostic = (diagnostic: ts.Diagnostic): string => {+ if (diagnostic.file && diagnostic.start !== undefined) {+ const { line, character } = ts.getLineAndCharacterOfPosition(+ diagnostic.file,+ diagnostic.start+ );+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');+ return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`;+ } else {+ return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');+ }+ };++ const errorMessages = diagnostics.map(d => formatDiagnostic(d)).join('\n');+ return yield* Effect.fail(+ new TypeScriptTranspileError({+ message: `TypeScript compilation failed`,+ cause: errorMessages,+ })+ );+ }++ return yield* Effect.void;+ });+}diff --git a/ts/packages/cli/src/models/toolkits.ts b/ts/packages/cli/src/models/toolkits.tsindex cb656d666..0643c480f 100644--- a/ts/packages/cli/src/models/toolkits.ts+++ b/ts/packages/cli/src/models/toolkits.ts@@ -3,7 +3,7 @@ import { JSONTransformSchema } from './utils/json-transform-schema';export const Toolkit = Schema.Struct({name: Schema.String, // "Gmail"- slug: Schema.String, // "gmail"+ slug: Schema.Trim.pipe(Schema.nonEmptyString()), // "gmail"auth_schemes: Schema.Array(Schema.String), // [ "OAUTH2", "BEARER_TOKEN" ]composio_managed_auth_schemes: Schema.Array(Schema.String), // [ "OAUTH2" ]is_local_toolkit: Schema.Boolean,diff --git a/ts/packages/cli/src/services/composio-clients.ts b/ts/packages/cli/src/services/composio-clients.tsindex 170977065..6ea88dcb6 100644--- a/ts/packages/cli/src/services/composio-clients.ts+++ b/ts/packages/cli/src/services/composio-clients.ts@@ -155,6 +155,12 @@ export class ComposioToolkitsRepository extends Effect.Service<ComposioToolkitsRreturn {getToolkits: () =>+ // Effect.succeed([+ // {+ // slug: 'gmail',+ // name: 'GMAIL',+ // } as unknown as Toolkit,+ // ]),client.toolkits.list().pipe(Effect.map(response => response.items),Effect.flatMap(toolkits =>diff --git a/ts/packages/cli/src/services/env-lang-detector.ts b/ts/packages/cli/src/services/env-lang-detector.tsindex 9b6879218..f1c61109f 100644--- a/ts/packages/cli/src/services/env-lang-detector.ts+++ b/ts/packages/cli/src/services/env-lang-detector.ts@@ -13,7 +13,9 @@ export class EnvLangDetector extends Effect.Service<EnvLangDetector>()('servicesconst fs = yield* FileSystem.FileSystem;return {- detectEnvLanguage: (cwd: string) =>+ detectEnvLanguage: (+ cwd: string+ ): Effect.Effect<'TypeScript' | 'Python', EnvLangDetectorError, never> =>Effect.gen(function* () {const files = yield* pipe(fs.readDirectory(cwd),diff --git a/ts/packages/cli/src/services/js-package-manager-detector.ts b/ts/packages/cli/src/services/js-package-manager-detector.tsnew file mode 100644index 000000000..b40216cfb--- /dev/null+++ b/ts/packages/cli/src/services/js-package-manager-detector.ts@@ -0,0 +1,156 @@+import { BunFileSystem } from '@effect/platform-bun';+import { Data, Effect, Option, Schema, pipe } from 'effect';+import { FileSystem } from '@effect/platform';+import * as path from 'path';++const toError = (e: unknown): Error => (e instanceof Error ? e : new Error(String(e)));++/**+ * Error thrown when a package manager detection fails.+ */+export class JsPackageManagerError extends Data.TaggedError('services/JsPackageManagerError')<{+ readonly cause: Error;+ readonly message: string;+}> {}++/**+ * Valid JavaScript package manager names recognised by Composio.+ */+export type PackageManager = 'pnpm' | 'bun' | 'yarn' | 'npm';++const LOCK_FILES: Record<PackageManager, string> = {+ pnpm: 'pnpm-lock.yaml',+ bun: 'bun.lockb',+ yarn: 'yarn.lock',+ npm: 'package-lock.json',+};++const PM_PREFERENCE: PackageManager[] = ['pnpm', 'bun', 'yarn', 'npm'];++// Service that attempts to detect the package manager of the project in the current working directory.+export class JsPackageManagerDetector extends Effect.Service<JsPackageManagerDetector>()(+ 'services/JsPackageManagerDetector',+ {+ accessors: true,+ effect: Effect.gen(function* () {+ yield* Effect.logDebug('[JsPackageManagerDetector] Identifying JS package manager...');++ const fs = yield* FileSystem.FileSystem;++ const parsePackageManager = (pm: string): Option.Option<PackageManager> => {+ if (pm.startsWith('pnpm@')) return Option.some('pnpm');+ if (pm.startsWith('bun@')) return Option.some('bun');+ if (pm.startsWith('yarn@')) return Option.some('yarn');+ if (pm.startsWith('npm@')) return Option.some('npm');+ return Option.none();+ };++ const PackageJsonSchema = Schema.Struct({+ packageManager: Schema.optional(Schema.String),+ }).annotations({ identifier: 'package.json' });++ const detectFromPackageJson = (+ cwd: string+ ): Effect.Effect<Option.Option<PackageManager>, JsPackageManagerError> =>+ Effect.gen(function* () {+ const contentEffect = pipe(+ fs.readFileString(path.join(cwd, 'package.json')),+ Effect.catchTag('SystemError', e =>+ Effect.fail(+ new JsPackageManagerError({ cause: e, message: 'Failed to read package.json' })+ )+ )+ );++ const content = yield* Effect.option(contentEffect);++ if (Option.isNone(content)) {+ return Option.none();+ }++ const json = yield* Effect.try({+ try: () => JSON.parse(content.value) as unknown,+ catch: e =>+ new JsPackageManagerError({+ cause: toError(e),+ message: 'Failed to parse package.json',+ }),+ });++ const decoded = yield* pipe(+ Schema.decodeUnknown(PackageJsonSchema)(json),+ Effect.mapError(+ e =>+ new JsPackageManagerError({+ cause: toError(e),+ message: 'Failed to decode package.json',+ })+ )+ );++ return Option.fromNullable(decoded.packageManager).pipe(+ Option.flatMap(parsePackageManager)+ );+ });++ const detectRecursive = (+ cwd: string+ ): Effect.Effect<Option.Option<PackageManager>, JsPackageManagerError> =>+ Effect.gen(function* () {+ const fromPackageJson = yield* detectFromPackageJson(cwd);+ if (Option.isSome(fromPackageJson)) {+ return fromPackageJson;+ }++ const parentDir = path.dirname(cwd);+ if (parentDir === cwd) {+ return Option.none();+ }++ return yield* detectRecursive(parentDir);+ });++ const detectJsPackageManager = (+ cwd: string+ ): Effect.Effect<PackageManager, JsPackageManagerError> =>+ Effect.gen(function* () {+ const files = yield* pipe(+ fs.readDirectory(cwd),+ Effect.mapError(+ e =>+ new JsPackageManagerError({+ cause: toError(e),+ message: `Failed to read directory ${cwd}`,+ })+ )+ );++ const fileNames = files.map(f => f.toLowerCase());++ for (const pm of PM_PREFERENCE) {+ if (fileNames.includes(LOCK_FILES[pm])) {+ return pm;+ }+ }++ const result = yield* detectRecursive(cwd);++ if (Option.isSome(result)) {+ return result.value;+ }++ return yield* Effect.fail(+ new JsPackageManagerError({+ cause: new Error('Recursive lookup exhausted'),+ message: 'Failed to detect package manager',+ })+ );+ });++ return {+ detectJsPackageManager,+ };+ }),+ dependencies: [BunFileSystem.layer],+ }+) {}diff --git a/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/.python-version b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/.python-versionnew file mode 100644index 000000000..e4fba2183--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/.python-version@@ -0,0 +1 @@+3.12diff --git a/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/main.py b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/main.pynew file mode 100644index 000000000..32ff4d292--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/main.py@@ -0,0 +1,6 @@+def main():+ print("Hello from python-project-with-composio-core!")+++if __name__ == "__main__":+ main()diff --git a/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/pyproject.toml b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/pyproject.tomlnew file mode 100644index 000000000..56f6be020--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/pyproject.toml@@ -0,0 +1,7 @@+[project]+name = "python-project-with-composio-core"+version = "0.1.0"+description = "Add your description here"+readme = "README.md"+requires-python = ">=3.12, <4"+dependencies = []diff --git a/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/requirements.txt b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/requirements.txtnew file mode 100644index 000000000..bea1e4164--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/requirements.txt@@ -0,0 +1 @@+composio_corediff --git a/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/setup.sh b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/setup.shnew file mode 100755index 000000000..cd0776a53--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/python-project-with-composio-core/setup.sh@@ -0,0 +1,13 @@+#!/bin/bash++set -e -o pipefail++# uv init++uv venv+source .venv/bin/activate+uv pip install --requirements requirements.txt;++uv run --active python -c "import composio; print (composio.__file__)"++# deactivatediff --git a/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/bun.lock b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/bun.locknew file mode 100644index 000000000..096e6d9b7--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/bun.lock@@ -0,0 +1,18 @@+{+ "lockfileVersion": 1,+ "workspaces": {+ "": {+ "dependencies": {+ "@composio/core": "link:../../../../core",+ },+ "devDependencies": {+ "typescript": "^5.8.3",+ },+ },+ },+ "packages": {+ "@composio/core": ["@composio/core@link:../../../../core", {}],++ "typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="],+ }+}diff --git a/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/package.json b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/package.jsonnew file mode 100644index 000000000..3242102bd--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/package.json@@ -0,0 +1,9 @@+{+ "type": "module",+ "devDependencies": {+ "typescript": "^5.8.3"+ },+ "dependencies": {+ "@composio/core": "link:../../../../core"+ }+}diff --git a/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/pnpm-lock.yaml b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/pnpm-lock.yamlnew file mode 100644index 000000000..78e52fdfe--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/pnpm-lock.yaml@@ -0,0 +1,28 @@+lockfileVersion: '9.0'++settings:+ autoInstallPeers: true+ excludeLinksFromLockfile: false++importers:++ .:+ dependencies:+ '@composio/core':+ specifier: link:../../../../core+ version: link:../../../../core+ devDependencies:+ typescript:+ specifier: ^5.8.3+ version: 5.8.3++packages:++ resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==}+ engines: {node: '>=14.17'}+ hasBin: true++snapshots:++ [email protected]: {}diff --git a/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/src/index.js b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/src/index.jsnew file mode 100644index 000000000..7ddc177d6--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/src/index.js@@ -0,0 +1,4 @@+import { composio } from '@composio/core/generated';++console.log('Test: Using generated Composio types');+console.log(composio.GMAIL.tools.CREATE_EMAIL_DRAFT);diff --git a/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/tsconfig.json b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/tsconfig.jsonnew file mode 100644index 000000000..840cb4edd--- /dev/null+++ b/ts/packages/cli/test/__fixtures__/typescript-project-with-composio-core/tsconfig.json@@ -0,0 +1,20 @@+{+ "compilerOptions": {+ "target": "ESNext",+ "module": "ESNext",+ "declaration": true,+ "outDir": "./dist",+ "rootDir": "./src",+ "paths": {+ "src/*": ["./src/*"],+ "test/*": ["./test/*"]+ },+ "strict": true,+ "esModuleInterop": true,+ "moduleResolution": "node",+ "skipLibCheck": true,+ "resolveJsonModule": true+ },+ "include": ["src"],+ "exclude": ["**/dist", "**/node_modules", "test/__fixtures__/**"]+}diff --git a/ts/packages/cli/test/__utils__/index.ts b/ts/packages/cli/test/__utils__/index.tsindex a8dbae05b..7bc9872d8 100644--- a/ts/packages/cli/test/__utils__/index.ts+++ b/ts/packages/cli/test/__utils__/index.ts@@ -2,6 +2,6 @@ import pkg from '../../package.json' with { type: 'json' };export * as MockConsole from './services/mock-console';export * as MockTerminal from './services/mock-terminal';-export { TestLayer as TestLive, runEffect } from './services/test-layer';+export { TestLayer as TestLive } from './services/test-layer';export { cli } from './cli';export { pkg };diff --git a/ts/packages/cli/test/__utils__/services/mock-console.ts b/ts/packages/cli/test/__utils__/services/mock-console.tsindex dc980ed0d..745f66fce 100644--- a/ts/packages/cli/test/__utils__/services/mock-console.ts+++ b/ts/packages/cli/test/__utils__/services/mock-console.ts@@ -4,6 +4,7 @@ import * as Array from 'effect/Array';import * as Console from 'effect/Console';import * as Context from 'effect/Context';import * as Effect from 'effect/Effect';+import * as Layer from 'effect/Layer';import * as Ref from 'effect/Ref';export interface MockConsole extends Console.Console {@@ -49,8 +50,11 @@ export const make = Effect.gen(function* () {return Ref.update(lines, Array.appendAll(args));};+ const clear: MockConsole['clear'] = Ref.update(lines, Array.empty);+return MockConsole.of({[Console.TypeId]: Console.TypeId,+ clear,getLines,log,info,@@ -58,7 +62,6 @@ export const make = Effect.gen(function* () {error,unsafe: globalThis.console,assert: () => Effect.void,- clear: Effect.void,count: () => Effect.void,countReset: () => Effect.void,debug: () => Effect.void,@@ -74,6 +77,13 @@ export const make = Effect.gen(function* () {});});+export const effect = Effect.gen(function* () {+ yield* Effect.addFinalizer(() => Console.clear);+ return yield* make;+});++export const layer = Layer.scoped(MockConsole, effect);+export const getLines = (params?: Partial<{readonly stripAnsi?: boolean;diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.tsindex 575c0c3f6..a3007c966 100644--- a/ts/packages/cli/test/__utils__/services/test-layer.ts+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts@@ -14,6 +14,7 @@ import {ComposioToolkitsRepository,} from 'src/services/composio-clients';import { EnvLangDetector } from 'src/services/env-lang-detector';+import { JsPackageManagerDetector } from 'src/services/js-package-manager-detector';import type { Tools } from 'src/models/tools';import type { TriggerTypes } from 'src/models/trigger-types';@@ -72,15 +73,16 @@ export const TestLayer = (input?: TestLiveInput) =>});const NodeProcessTest = Layer.succeed(NodeProcess, nodeProcessTest);- const MockConsoleTestLive = yield* MockConsole.make;+ const _console = yield* MockConsole.effect;const layers = Layer.mergeAll(- Console.setConsole(MockConsoleTestLive),+ Console.setConsole(_console),NodeProcessTest,CliConfigLive,ComposioSessionRepositoryTest,ComposioToolkitsRepositoryTest,EnvLangDetector.Default,+ JsPackageManagerDetector.Default,BunFileSystem.layer,BunContext.layer,MockTerminal.layer,@@ -88,13 +90,13 @@ export const TestLayer = (input?: TestLiveInput) =>);return layers;- }).pipe(Logger.withMinimumLogLevel(LogLevel.Info), Layer.unwrapEffect);+ }).pipe(Logger.withMinimumLogLevel(LogLevel.Info), Effect.scoped, Layer.unwrapEffect);// Run @effect/vitest suite with TestLive layer-export const runEffect =- (input?: TestLiveInput) =>- <E, A>(self: Effect.Effect<A, E, CliApp.CliApp.Environment>): Promise<A> =>- Effect.provide(self, TestLayer(input)).pipe(Effect.runPromise);+// export const runEffect =+// (input?: TestLiveInput) =>+// <E, A>(self: Effect.Effect<A, E, CliApp.CliApp.Environment>): Promise<A> =>+// Effect.provide(self, TestLayer(input)).pipe(Effect.scoped, Effect.runPromise);function setupFixtureFolder({ fixture, tempDir }: { fixture?: string; tempDir: string }) {return Effect.gen(function* () {diff --git a/ts/packages/cli/test/__utils__/typescript-compiler.ts b/ts/packages/cli/test/__utils__/typescript-compiler.tsindex 0afd8d439..479c5c032 100644--- a/ts/packages/cli/test/__utils__/typescript-compiler.ts+++ b/ts/packages/cli/test/__utils__/typescript-compiler.ts@@ -1,5 +1,9 @@+import path from 'node:path';import { describe, it, expect } from 'vitest';+import { Effect, Stream, String } from 'effect';+import { Command } from '@effect/platform';import ts from 'typescript';+import { cwd } from 'node:process';interface AssertTypeScriptIsValidInput {files: {@@ -59,6 +63,41 @@ export function assertTypeScriptIsValid({ files }: AssertTypeScriptIsValidInput)expect(diagnostics).toEqual([]);}+type AssertTranspiledTypeScriptIsValidInput = {+ cwd: string;+ testSourceCodePath: string;+};++export function assertTranspiledTypeScriptIsValid({+ cwd,+ testSourceCodePath,+}: AssertTranspiledTypeScriptIsValidInput) {+ return Effect.gen(function* () {+ const installCmd = Command.make('node', testSourceCodePath);+ const [exitCode, stdout, stderr] = yield* installCmd.pipe(+ Command.workingDirectory(cwd),+ Command.start,+ Effect.andThen(process =>+ Effect.all(+ [+ // Wait for exit code+ process.exitCode,+ // Get stdout as lines+ process.stdout.pipe(Stream.decodeText(), Stream.runFold(String.empty, String.concat)),+ // Get stderr as lines+ process.stderr.pipe(Stream.decodeText(), Stream.runFold(String.empty, String.concat)),+ ],+ { concurrency: 3 }+ )+ )+ );++ expect(exitCode).toBe(0);+ expect(stderr).toBe('');+ return stdout;+ });+}+if (import.meta.vitest) {describe('assertTypeScriptIsValid', () => {it('[Given] valid TypeScript code [Then] no errors are found', () => {diff --git a/ts/packages/cli/test/__utils__/vitest.global-setup.ts b/ts/packages/cli/test/__utils__/vitest.global-setup.tsnew file mode 100644index 000000000..246cddfb2--- /dev/null+++ b/ts/packages/cli/test/__utils__/vitest.global-setup.ts@@ -0,0 +1,190 @@+import { BunFileSystem, BunContext } from '@effect/platform-bun';+import { Command, FileSystem } from '@effect/platform';+import { Effect, Option, Logger, LogLevel } from 'effect';+import path from 'node:path';++const __dirname = path.resolve(path.dirname(new URL(import.meta.url).pathname));++/**+ * Sets up TypeScript fixtures by simulating `@composio/core` package installation via `pnpm`.+ * For all fixture folders containing a `package.json` with `@composio/core` in `dependencies` / `devDependencies`,+ * installs the package by copying the built files from dist to node_modules.+ */+function setupFixturesTypeScript(fixturePaths: string[]) {+ return Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;++ yield* Effect.all(+ fixturePaths.map(fixturePath => {+ const fixtureDirName = path.basename(fixturePath);+ return Effect.gen(function* () {+ // Check if package.json exists and contains @composio/core+ const packageJsonPath = path.join(fixturePath, 'package.json');+ const packageJsonExists = yield* fs.exists(packageJsonPath);++ if (!packageJsonExists) {+ yield* Effect.logDebug(`Skipping ${fixtureDirName}: no package.json found`);+ return;+ }++ // Read and parse package.json+ const packageJsonContent = yield* fs.readFileString(packageJsonPath);+ const packageJson = JSON.parse(packageJsonContent);++ // Check if @composio/core is in dependencies or devDependencies+ const hasComposioCore =+ (packageJson.dependencies && packageJson.dependencies['@composio/core']) ||+ (packageJson.devDependencies && packageJson.devDependencies['@composio/core']);++ if (!hasComposioCore) {+ yield* Effect.logDebug(+ `Skipping ${fixtureDirName}: no @composio/core dependency found`+ );+ return;+ }++ yield* Effect.logDebug(`Setting up @composio/core for fixture: ${fixtureDirName}`);++ // Clean up existing node_modules/@composio/core+ const nodeModulesDir = path.join(fixturePath, 'node_modules');+ yield* fs.remove(nodeModulesDir, { recursive: true, force: true });++ const installCmd = Command.make('pnpm', 'install', '--ignore-workspace');+ const exitCode = yield* installCmd.pipe(+ Command.workingDirectory(fixturePath),+ Command.stdout('inherit'),+ Command.stderr('inherit'),+ Command.exitCode+ );++ if (exitCode !== 0) {+ yield* Effect.logError(+ `Failed to install @composio/core for fixture: ${fixtureDirName}`+ );+ return;+ }++ yield* Effect.logDebug(+ `Successfully set up @composio/core for fixture: ${fixtureDirName}`+ );+ }).pipe(+ Effect.catchAll(error =>+ Effect.logError(`Failed to setup fixture ${fixtureDirName}: ${error}`)+ )+ );+ }),+ { concurrency: 4 }+ );+ });+}++/**+ * Sets up Python fixtures by simulating `composio_core` package installation via `uv pip`.+ * For all fixture folders containing a `requirements.txt` it sets up `uv venv` and installs+ * the required packages from the Internet.+ */+function setupFixturesPython(fixturePaths: string[]) {+ return Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;++ yield* Effect.all(+ fixturePaths.map(fixturePath => {+ const fixtureDirName = path.basename(fixturePath);+ return Effect.gen(function* () {+ // Check if requirements.txt exists+ const requirementsPath = path.join(fixturePath, 'requirements.txt');+ const requirementsExists = yield* fs.exists(requirementsPath);++ if (!requirementsExists) {+ yield* Effect.logDebug(`Skipping ${fixtureDirName}: no requirements.txt found`);+ return;+ }++ // Read and parse requirements.txt+ const requirementsContent = yield* fs.readFileString(requirementsPath);+ const requirementsTxt = requirementsContent.split('\n');++ // Check if @composio/core is in dependencies or devDependencies+ const hasComposioCore = requirementsTxt.includes('composio_core');++ if (!hasComposioCore) {+ yield* Effect.logDebug(+ `Skipping ${fixtureDirName}: no \`composio_core\` dependency found`+ );+ return;+ }++ const setupShPath = path.join(fixturePath, 'setup.sh');+ const setupShExists = yield* fs.exists(setupShPath);++ if (!setupShExists) {+ yield* Effect.logDebug(`Skipping ${fixtureDirName}: no setup.sh found`);+ return;+ }++ yield* Effect.logDebug(`Setting up \`uv\` for fixture: ${fixtureDirName}`);++ const installCmd = Command.make(setupShPath);+ const exitCode = yield* installCmd.pipe(+ Command.workingDirectory(fixturePath),+ Command.runInShell(true),+ Command.stdout('inherit'),+ Command.stderr('inherit'),+ Command.exitCode+ );++ if (exitCode !== 0) {+ yield* Effect.logError(+ `Failed to install @composio/core for fixture: ${fixtureDirName}`+ );+ return;+ }++ yield* Effect.logDebug(+ `Successfully set up @composio/core for fixture: ${fixtureDirName}`+ );+ }).pipe(+ Effect.catchAll(error =>+ Effect.logError(`Failed to setup fixture ${fixtureDirName}: ${error}`)+ )+ );+ }),+ { concurrency: 4 }+ );+ });+}++export async function setup() {+ const program = Effect.gen(function* () {+ // Path to the fixtures directory.+ // Note: we're using `__dirname` because `import.meta.resolve` is not yet available in Vitest.+ // See: https://github.com/vitest-dev/vitest/pull/5188.+ const fixturesDir = path.resolve(__dirname, '../__fixtures__');+ yield* Effect.logDebug(`Setting up TypeScript fixtures in ${fixturesDir}`);++ const fs = yield* FileSystem.FileSystem;++ // Get all fixture directories+ const fixtureEntries = yield* fs.readDirectory(fixturesDir);++ // Filter to only directories by checking each entry+ const fixtureDirNames: string[] = yield* Effect.all(+ fixtureEntries.map(entryName =>+ Effect.gen(function* () {+ const entryPath = path.join(fixturesDir, entryName);+ const stat = yield* fs.stat(entryPath);+ return stat.type === 'Directory' ? Option.some(entryPath) : Option.none<string>();+ }).pipe(Effect.catchAll(() => Effect.succeed(Option.none<string>())))+ )+ ).pipe(Effect.map(Option.all), Effect.map(Option.getOrElse(() => [] as string[])));++ yield* setupFixturesPython(fixtureDirNames);+ yield* setupFixturesTypeScript(fixtureDirNames);+ }).pipe(+ Effect.provide(BunFileSystem.layer),+ Effect.provide(BunContext.layer),+ Effect.provide(Logger.minimumLogLevel(LogLevel.Debug))+ );++ await Effect.runPromise(program);+}diff --git a/ts/packages/cli/test/src/commands/$default.cmd.test.ts b/ts/packages/cli/test/src/commands/$default.cmd.test.tsindex 7b6486259..60ee4259e 100644--- a/ts/packages/cli/test/src/commands/$default.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/$default.cmd.test.ts@@ -1,25 +1,28 @@import { describe, expect, layer } from '@effect/vitest';-import { Effect, Fiber } from 'effect';+import { Effect } from 'effect';import { ValidationError, HelpDoc } from '@effect/cli';import { cli, pkg, TestLive, MockConsole } from 'test/__utils__';import { sanitize } from 'test/__utils__/sanitize';describe('CLI: composio', () => {layer(TestLive())(it => {- it.effect.skip('[Given] unknown argument [Then] print error message', () =>+ it.scoped('[Given] unknown argument [Then] print error message', () =>Effect.gen(function* () {const args = ['--bar'];- const fiber = yield* Effect.fork(cli(args));- yield* Fiber.join(fiber);- const result = yield* Effect.flip(fiber);+ const result = yield* cli(args).pipe(Effect.catchAll(e => Effect.succeed(e)));+expect(result).toEqual(- ValidationError.invalidValue(HelpDoc.p("Received unknown argument: '--bar'"))+ ValidationError.commandMismatch(+ HelpDoc.p("Invalid subcommand for composio - use 'version'")+ ));}));+ });- it.effect('[Given] --help flag [Then] prints help message', () =>+ layer(TestLive())(it => {+ it.scoped('[Given] --help flag [Then] prints help message', () =>Effect.gen(function* () {const args = ['--help'];yield* cli(args);@@ -55,27 +58,29 @@ describe('CLI: composio', () => {[0;1mCOMMANDS[0m- - version Display your account information.+ - version Display your account information.- - whoami Display your account information.+ - whoami Display your account information.- - login Log in to the Composio SDK.+ - login Log in to the Composio SDK.- - generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).+ - generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data, automatically detecting the language of the project in the current working directory (TypeScript | Python).- - py Handle Python projects.+ - py Handle Python projects.- - py generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data.+ - py generate [(-o, --output-dir directory)] Updates the local type stubs with the latest app data.- - ts Handle TypeScript projects.+ - ts Handle TypeScript projects.- - ts generate [(-o, --output-dir directory)] [--single-file] Updates the local type stubs with the latest app data.+ - ts generate [(-o, --output-dir directory)] [--compact] [--transpiled] Updates the local type stubs with the latest app data."`);}));+ });- it.effect("[Given] --version flag [Then] prints composio's version from package.json", () =>+ layer(TestLive())(it => {+ it.scoped("[Given] --version flag [Then] prints composio's version from package.json", () =>Effect.gen(function* () {const args = ['--version'];yield* cli(args);@@ -84,19 +89,21 @@ describe('CLI: composio', () => {expect(output).toContain(pkg.version);}));-- // it.effect('[Pressing] CTRL+C [Then] quit wizard mode', () =>- // Effect.gen(function* () {- // const args = ['--wizard'];-- // const fiber = yield* Effect.fork(cli(args));- // yield* MockTerminal.inputKey('c', { ctrl: true });- // yield* Fiber.join(fiber);-- // const lines = yield* MockConsole.getLines();- // const output = lines.join('\n');- // expect(output).toContain('Quitting wizard mode...');- // })- // );});++ // layer(TestLive())(it => {+ // it.scoped('[Pressing] CTRL+C [Then] quit wizard mode', () =>+ // Effect.gen(function* () {+ // const args = ['--wizard'];++ // const fiber = yield* Effect.fork(cli(args));+ // yield* MockTerminal.inputKey('c', { ctrl: true });+ // yield* Fiber.join(fiber);++ // const lines = yield* MockConsole.getLines();+ // const output = lines.join('\n');+ // expect(output).toContain('Quitting wizard mode...');+ // })+ // );+ // });});diff --git a/ts/packages/cli/test/src/commands/generate.cmd.test.ts b/ts/packages/cli/test/src/commands/generate.cmd.test.tsindex 0889fcc2d..3235d9373 100644--- a/ts/packages/cli/test/src/commands/generate.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/generate.cmd.test.ts@@ -1,5 +1,6 @@import { describe, expect, layer } from '@effect/vitest';import { Effect } from 'effect';+import { NodeProcess } from 'src/services/node-process';import { cli, TestLive, MockConsole } from 'test/__utils__';describe('CLI: composio generate', () => {@@ -8,9 +9,12 @@ describe('CLI: composio generate', () => {fixture: 'python-project',}))(it => {- it.effect('[Given] a valid Python project in cwd [Then] it detects its language', () =>+ it.scoped('[Given] a valid Python project in cwd [Then] it detects its language', () =>Effect.gen(function* () {- const args = ['generate'];+ const process = yield* NodeProcess;+ const cwd = process.cwd;++ const args = ['generate', '--output-dir', cwd];yield* cli(args);const lines = yield* MockConsole.getLines();const output = lines.join('\n');@@ -24,9 +28,12 @@ describe('CLI: composio generate', () => {fixture: 'typescript-project',}))(it => {- it.effect('[Given] a valid TypeScript project in cwd [Then] it detects its language', () =>+ it.scoped('[Given] a valid TypeScript project in cwd [Then] it detects its language', () =>Effect.gen(function* () {- const args = ['generate'];+ const process = yield* NodeProcess;+ const cwd = process.cwd;++ const args = ['generate', '--output-dir', cwd];yield* cli(args);const lines = yield* MockConsole.getLines();const output = lines.join('\n');diff --git a/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts b/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.tsindex 29b0f608e..b1aa824d4 100644--- a/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts@@ -24,25 +24,30 @@ describe('CLI: composio py generate', () => {layer(TestLive({- fixture: 'python-project',+ fixture: 'python-project-with-composio-core',toolkitsData: appClientData,}))(it => {describe('[Given] valid fetched app data', () => {- it.effect(- '[Given] no arguments [Then] it generates type stubs relative to the cache directory',+ it.scoped.skip(+ '[Given] no arguments [Then] it generates type stubs relative the `composio` module if detectable by uv',() =>Effect.gen(function* () {const process = yield* NodeProcess;const cwd = process.cwd;const fs = yield* FileSystem.FileSystem;- vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);-const args = ['py', 'generate'];yield* cli(args);- const outputDir = path.join(cwd, '.generated', 'composio-py');+ const outputDir = path.join(+ cwd,+ '.venv',+ 'lib',+ 'python3.12',+ 'site-packages',+ 'composio'+ );const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.py'));const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));@@ -84,27 +89,23 @@ describe('CLI: composio py generate', () => {}));- it.effect(+ it.scoped('[Given] --output-dir [Then] it generates type stubs relative to the given output directory',- () =>- Effect.gen(function* () {- const process = yield* NodeProcess;- const cwd = process.cwd;- const fs = yield* FileSystem.FileSystem;-- const outputDirArg = path.join('.generated', 'composio-py');+ Effect.fn(function* () {+ const process = yield* NodeProcess;+ const cwd = process.cwd;+ const fs = yield* FileSystem.FileSystem;- const args = ['py', 'generate', '--output-dir', outputDirArg];- yield* cli(args);+ const outputDir = path.join(cwd, '.generated', 'composio-py');- const outputDir = path.join(cwd, outputDirArg);+ const args = ['py', 'generate', '--output-dir', outputDir];+ yield* cli(args);- const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.py'));- const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));+ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.py'));+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.py'));- expect(gmailSourceCode).toMatchInlineSnapshot(`- "# Auto-generated by Composio CLI via \`composio py generate\`.- # Do not modify manually.+ expect(gmailSourceCode).toMatchInlineSnapshot(`+ "# Auto-generated by Composio CLI. Do not modify manually..class GMAIL:"""Map of Composio's GMAIL toolkit."""@@ -120,9 +121,8 @@ describe('CLI: composio py generate', () => {NEW_GMAIL_MESSAGE = "GMAIL_NEW_GMAIL_MESSAGE""`);- expect(slackSourceCode).toMatchInlineSnapshot(`- "# Auto-generated by Composio CLI via \`composio py generate\`.- # Do not modify manually.+ expect(slackSourceCode).toMatchInlineSnapshot(`+ "# Auto-generated by Composio CLI. Do not modify manually..class SLACK:"""Map of Composio's SLACK toolkit."""@@ -136,82 +136,6 @@ describe('CLI: composio py generate', () => {pass"`);- })- );-- it.effect('[Given] --single-file [Then] it generates type stubs in a single file', () =>- Effect.gen(function* () {- const process = yield* NodeProcess;- const cwd = process.cwd;- const fs = yield* FileSystem.FileSystem;-- vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);-- const args = ['ts', 'generate', '--single-file'];- yield* cli(args);-- const outputDir = path.join(cwd, '.generated', 'composio-ts');-- expect(yield* fs.exists(path.join(outputDir, 'index.ts'))).toBe(true);-- const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));-- expect(indexSourceCode).toMatchInlineSnapshot(`- "/**- * Auto-generated by Composio CLI. Do not modify manually.- */-- /**- * Map of Composio's GMAIL toolkit.- */- export const GMAIL = {- slug: "gmail",- tools: {- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",- },- triggerTypes: {- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",- },- }-- /**- * Map of Composio's SLACK toolkit.- */- export const SLACK = {- slug: "slack",- tools: {},- triggerTypes: {},- }-- /**- * Map of Composio toolkits to actions.- */- export const composio = {- GMAIL: GMAIL,- SLACK: SLACK,- }-- /**- * Type declarations- */-- /**- * Union of all available toolkits.- */- export type Toolkit =- | "GMAIL"- | "SLACK"-- /**- * Given a toolkit, returns the tools available for that toolkit.- */- export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]--- "- `);}));});diff --git a/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts b/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.tsindex 88597065a..ac68a0e3b 100644--- a/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts@@ -1,11 +1,15 @@import path from 'node:path';-import { describe, expect, layer, vi } from '@effect/vitest';-import { Effect } from 'effect';-import { FileSystem } from '@effect/platform';+import { describe, expect, layer } from '@effect/vitest';+import { Effect, Stream, String } from 'effect';+import { Command, FileSystem } from '@effect/platform';import { cli, TestLive } from 'test/__utils__';import { makeTestToolkits } from 'test/__utils__/models/toolkits';import { NodeProcess } from 'src/services/node-process';-import { assertTypeScriptIsValid } from 'test/__utils__/typescript-compiler';+import {+ assertTranspiledTypeScriptIsValid,+ assertTypeScriptIsValid,+} from 'test/__utils__/typescript-compiler';+import { ComposioCorePkgNotFound } from 'src/effects/find-composio-core-generated';describe('CLI: composio ts generate', () => {const appClientData = {@@ -23,278 +27,413 @@ describe('CLI: composio ts generate', () => {triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],};- layer(- TestLive({- fixture: 'typescript-project',- toolkitsData: appClientData,- })- )(it => {- describe('[Given] valid fetched app data', () => {- it.effect(- '[Given] no arguments [Then] it generates type stubs relative to the cache directory',- () =>+ describe('[Given] valid fetched app data', () => {+ layer(+ TestLive({+ fixture: 'typescript-project-with-composio-core',+ toolkitsData: appClientData,+ })+ )(it => {+ describe('[Given] `@composio/core` already installed', () => {+ it.scoped(+ '[Given] no args [Then] it generates types + JS in `node_modules/@composio/core/generated`',+ () =>+ Effect.gen(function* () {+ const process = yield* NodeProcess;+ const cwd = process.cwd;+ const fs = yield* FileSystem.FileSystem;++ // Create the @composio/core/generated directory structure as if installed+ const nodeModulesDir = path.join(cwd, 'node_modules', '@composio', 'core');+ const generatedDir = path.join(nodeModulesDir, 'generated');+ yield* fs.makeDirectory(nodeModulesDir, { recursive: true });+ yield* fs.makeDirectory(generatedDir, { recursive: true });++ const outputDir = path.join(cwd, 'node_modules', '@composio', 'core', 'generated');+ const args = ['ts', 'generate'];+ yield* cli(args);++ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.ts'));+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.ts'));+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));++ expect(gmailSourceCode).toMatchInlineSnapshot(`+ "/**+ * Map of Composio's GMAIL toolkit.+ */+ export const GMAIL = {+ slug: "gmail",+ tools: {+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",+ },+ triggerTypes: {+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",+ },+ }+ "+ `);+ expect(slackSourceCode).toMatchInlineSnapshot(`+ "/**+ * Map of Composio's SLACK toolkit.+ */+ export const SLACK = {+ slug: "slack",+ tools: {},+ triggerTypes: {},+ }+ "+ `);+ expect(indexSourceCode).toMatchInlineSnapshot(`+ "/**+ * Auto-generated by Composio CLI. Do not modify manually.+ */++ import { GMAIL } from "./gmail.js"+ import { SLACK } from "./slack.js"++ /**+ * Map of Composio toolkits to actions.+ */+ export const composio = {+ GMAIL: GMAIL,+ SLACK: SLACK,+ }++ /**+ * Type declarations+ */++ /**+ * Union of all available toolkits.+ */+ export type Toolkit =+ | "GMAIL"+ | "SLACK"++ /**+ * Given a toolkit, returns the tools available for that toolkit.+ */+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]++ "+ `);++ assertTypeScriptIsValid({ files: { './gmail.ts': gmailSourceCode } });+ assertTypeScriptIsValid({ files: { './slack.ts': slackSourceCode } });+ assertTypeScriptIsValid({+ files: {+ './index.ts': indexSourceCode,+ './gmail.ts': gmailSourceCode,+ './slack.ts': slackSourceCode,+ },+ });++ const testSourceCodePath = path.join(cwd, 'src', 'index.js');+ const testSourceCode = yield* fs.readFileString(testSourceCodePath);+ expect(testSourceCode).toMatchInlineSnapshot(`+ "import { composio } from '@composio/core/generated';++ console.log('Test: Using generated Composio types');+ console.log(composio.GMAIL.tools.CREATE_EMAIL_DRAFT);+ "+ `);++ const stdout = yield* assertTranspiledTypeScriptIsValid({ cwd, testSourceCodePath });+ expect(stdout).toMatchInlineSnapshot(`+ "Test: Using generated Composio types+ GMAIL_CREATE_EMAIL_DRAFT+ "+ `);+ })+ );++ it.scoped(+ '[Given] --output-dir [Then] it generates type stubs relative to the given output directory',+ () =>+ Effect.gen(function* () {+ const process = yield* NodeProcess;+ const cwd = process.cwd;+ const fs = yield* FileSystem.FileSystem;++ const outputDir = path.join(cwd, '.generated', 'composio-ts');++ const args = ['ts', 'generate', '--output-dir', outputDir];+ yield* cli(args);++ const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.ts'));+ const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.ts'));+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));++ expect(gmailSourceCode).toMatchInlineSnapshot(`+ "/**+ * Map of Composio's GMAIL toolkit.+ */+ export const GMAIL = {+ slug: "gmail",+ tools: {+ CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",+ DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",+ FETCH_EMAILS: "GMAIL_FETCH_EMAILS",+ },+ triggerTypes: {+ NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",+ },+ }+ "+ `);+ expect(slackSourceCode).toMatchInlineSnapshot(`+ "/**+ * Map of Composio's SLACK toolkit.+ */+ export const SLACK = {+ slug: "slack",+ tools: {},+ triggerTypes: {},+ }+ "+ `);+ expect(indexSourceCode).toMatchInlineSnapshot(`+ "/**+ * Auto-generated by Composio CLI. Do not modify manually.+ */++ import { GMAIL } from "./gmail.js"+ import { SLACK } from "./slack.js"++ /**+ * Map of Composio toolkits to actions.+ */+ export const composio = {+ GMAIL: GMAIL,+ SLACK: SLACK,+ }++ /**+ * Type declarations+ */++ /**+ * Union of all available toolkits.+ */+ export type Toolkit =+ | "GMAIL"+ | "SLACK"++ /**+ * Given a toolkit, returns the tools available for that toolkit.+ */+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]++ "+ `);++ assertTypeScriptIsValid({ files: { './gmail.ts': gmailSourceCode } });+ assertTypeScriptIsValid({ files: { './slack.ts': slackSourceCode } });+ assertTypeScriptIsValid({+ files: {+ './index.ts': indexSourceCode,+ './gmail.ts': gmailSourceCode,+ './slack.ts': slackSourceCode,+ },+ });+ })+ );++ it.scoped('[Given] --compact [Then] it generates type stubs in a single file', () =>Effect.gen(function* () {const process = yield* NodeProcess;const cwd = process.cwd;const fs = yield* FileSystem.FileSystem;+ const outputDir = path.join(cwd, 'generated-single');- vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);-- const args = ['ts', 'generate'];+ const args = ['ts', 'generate', '--compact', '--output-dir', outputDir];yield* cli(args);- const outputDir = path.join(cwd, '.generated', 'composio-ts');+ // Check if the output directory contains the expected files+ const files = yield* fs.readDirectory(outputDir);+ const fileNames = files.map(file => path.basename(file));- const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.ts'));- const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.ts'));- const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));+ // Should only have index.ts and no other .ts files+ const tsFiles = fileNames.filter(name => name.endsWith('.ts'));+ expect(tsFiles).toContain('index.ts');+ expect(tsFiles.length).toBe(1);- expect(gmailSourceCode).toMatchInlineSnapshot(`- "/**- * Map of Composio's GMAIL toolkit.- */- export const GMAIL = {- slug: "gmail",- tools: {- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",- },- triggerTypes: {- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",- },- }- "- `);- expect(slackSourceCode).toMatchInlineSnapshot(`- "/**- * Map of Composio's SLACK toolkit.- */- export const SLACK = {- slug: "slack",- tools: {},- triggerTypes: {},- }- "- `);- expect(indexSourceCode).toMatchInlineSnapshot(`- "/**- * Auto-generated by Composio CLI. Do not modify manually.- */-- import { GMAIL } from "./gmail.ts"- import { SLACK } from "./slack.ts"-- /**- * Map of Composio toolkits to actions.- */- export const composio = {- GMAIL: GMAIL,- SLACK: SLACK,- }-- /**- * Type declarations- */-- /**- * Union of all available toolkits.- */- export type Toolkit =- | "GMAIL"- | "SLACK"-- /**- * Given a toolkit, returns the tools available for that toolkit.- */- export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]-- "- `);-- assertTypeScriptIsValid({ files: { './gmail.ts': gmailSourceCode } });- assertTypeScriptIsValid({ files: { './slack.ts': slackSourceCode } });- assertTypeScriptIsValid({- files: {- './index.ts': indexSourceCode,- './gmail.ts': gmailSourceCode,- './slack.ts': slackSourceCode,- },- });+ // Verify the file content+ const content = yield* fs.readFileString(path.join(outputDir, 'index.ts'));+ expect(content).toContain('Auto-generated by Composio CLI');+ expect(content).toContain('export const GMAIL');+ expect(content).toContain('export const SLACK');})- );+ );- it.effect(- '[Given] --output-dir [Then] it generates type stubs relative to the given output directory',- () =>+ it.scoped('[Given] --transpiled [Then] it generates both .ts and .js files', () =>Effect.gen(function* () {const process = yield* NodeProcess;const cwd = process.cwd;const fs = yield* FileSystem.FileSystem;+ const outputDir = path.join(cwd, 'generated-compiled');- const outputDirArg = path.join('.generated', 'composio-ts');-- const args = ['ts', 'generate', '--output-dir', outputDirArg];+ const args = ['ts', 'generate', '--transpiled', '--output-dir', outputDir];yield* cli(args);- const outputDir = path.join(cwd, outputDirArg);+ // Check if the output directory contains both .ts and .js files+ const files = yield* fs.readDirectory(outputDir);+ const fileNames = files.map(file => path.basename(file));- const gmailSourceCode = yield* fs.readFileString(path.join(outputDir, 'gmail.ts'));- const slackSourceCode = yield* fs.readFileString(path.join(outputDir, 'slack.ts'));- const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));+ // Should have both .ts and .js files+ const tsFiles = fileNames.filter(name => name.endsWith('.ts'));+ const jsFiles = fileNames.filter(name => name.endsWith('.js'));+ const dtsFiles = fileNames.filter(name => name.endsWith('.d.ts'));- expect(gmailSourceCode).toMatchInlineSnapshot(`- "/**- * Map of Composio's GMAIL toolkit.- */- export const GMAIL = {- slug: "gmail",- tools: {- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",- },- triggerTypes: {- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",- },- }- "- `);- expect(slackSourceCode).toMatchInlineSnapshot(`- "/**- * Map of Composio's SLACK toolkit.- */- export const SLACK = {- slug: "slack",- tools: {},- triggerTypes: {},- }- "- `);- expect(indexSourceCode).toMatchInlineSnapshot(`- "/**- * Auto-generated by Composio CLI. Do not modify manually.- */-- import { GMAIL } from "./gmail.ts"- import { SLACK } from "./slack.ts"-- /**- * Map of Composio toolkits to actions.- */- export const composio = {- GMAIL: GMAIL,- SLACK: SLACK,- }+ expect(tsFiles.length).toBeGreaterThan(0);+ expect(jsFiles.length).toBeGreaterThan(0);+ expect(dtsFiles.length).toBeGreaterThan(0);- /**- * Type declarations- */-- /**- * Union of all available toolkits.- */- export type Toolkit =- | "GMAIL"- | "SLACK"-- /**- * Given a toolkit, returns the tools available for that toolkit.- */- export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]-- "- `);-- assertTypeScriptIsValid({ files: { './gmail.ts': gmailSourceCode } });- assertTypeScriptIsValid({ files: { './slack.ts': slackSourceCode } });- assertTypeScriptIsValid({- files: {- './index.ts': indexSourceCode,- './gmail.ts': gmailSourceCode,- './slack.ts': slackSourceCode,- },- });- })- );-- it.effect('[Given] --single-file [Then] it generates type stubs in a single file', () =>- Effect.gen(function* () {- const process = yield* NodeProcess;- const cwd = process.cwd;- const fs = yield* FileSystem.FileSystem;-- vi.stubEnv('COMPOSIO_CACHE_DIR', cwd);-- const args = ['ts', 'generate', '--single-file'];- yield* cli(args);-- const outputDir = path.join(cwd, '.generated', 'composio-ts');-- expect(yield* fs.exists(path.join(outputDir, 'index.ts'))).toBe(true);-- const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));-- expect(indexSourceCode).toMatchInlineSnapshot(`- "/**- * Auto-generated by Composio CLI. Do not modify manually.- */-- /**- * Map of Composio's GMAIL toolkit.- */- export const GMAIL = {- slug: "gmail",- tools: {- CREATE_EMAIL_DRAFT: "GMAIL_CREATE_EMAIL_DRAFT",- DELETE_MESSAGE: "GMAIL_DELETE_MESSAGE",- FETCH_EMAILS: "GMAIL_FETCH_EMAILS",- },- triggerTypes: {- NEW_GMAIL_MESSAGE: "GMAIL_NEW_GMAIL_MESSAGE",- },+ // Verify the files are valid TypeScript+ for (const file of tsFiles) {+ const filePath = path.join(outputDir, file);+ assertTypeScriptIsValid({ files: { './index.ts': filePath } });}+ })+ );- /**- * Map of Composio's SLACK toolkit.- */- export const SLACK = {- slug: "slack",- tools: {},- triggerTypes: {},- }+ it.scoped('[Given] no `--output-dir` [Then] it compiles by default', () =>+ Effect.gen(function* () {+ const process = yield* NodeProcess;+ const cwd = process.cwd;+ const fs = yield* FileSystem.FileSystem;- /**- * Map of Composio toolkits to actions.- */- export const composio = {- GMAIL: GMAIL,- SLACK: SLACK,- }+ // Set up @composio/core/generated directory+ const nodeModulesDir = path.join(cwd, 'node_modules', '@composio', 'core');+ const generatedDir = path.join(nodeModulesDir, 'generated');+ yield* fs.makeDirectory(nodeModulesDir, { recursive: true });+ yield* fs.makeDirectory(generatedDir, { recursive: true });++ const args = ['ts', 'generate'];+ yield* cli(args);++ // Check if the output directory contains both .ts and .js files+ const files = yield* fs.readDirectory(generatedDir);+ const fileNames = files.map(file => path.basename(file));++ // Should have both .ts and .js files since compiled is true by default for @composio/core/generated+ const tsFiles = fileNames.filter(name => name.endsWith('.ts'));+ const jsFiles = fileNames.filter(name => name.endsWith('.js'));+ const dtsFiles = fileNames.filter(name => name.endsWith('.d.ts'));- /**- * Type declarations- */+ expect(tsFiles.length).toBeGreaterThan(0);+ expect(jsFiles.length).toBeGreaterThan(0);+ expect(dtsFiles.length).toBeGreaterThan(0);+ })+ );++ it.scoped(+ '[Given] `--output-dir` with no `--transpiled` [Then] it does not generate .js files',+ () =>+ Effect.gen(function* () {+ const process = yield* NodeProcess;+ const cwd = process.cwd;+ const fs = yield* FileSystem.FileSystem;+ const outputDir = path.join(cwd, 'generated-no-compile');++ const args = ['ts', 'generate', '--output-dir', outputDir];+ yield* cli(args);++ // Check if the output directory contains only .ts files+ const files = yield* fs.readDirectory(outputDir);+ const fileNames = files.map(file => path.basename(file));++ // Should have .ts files but no .js files+ const tsFiles = fileNames.filter(name => name.endsWith('.ts'));+ const jsFiles = fileNames.filter(name => name.endsWith('.js'));++ expect(tsFiles.length).toBeGreaterThan(0);+ expect(jsFiles.length).toBe(0);+ })+ );++ it.scoped('[Given] `--compact` [Then] it generates in the correct location', () =>+ Effect.gen(function* () {+ const process = yield* NodeProcess;+ const cwd = process.cwd;+ const fs = yield* FileSystem.FileSystem;- /**- * Union of all available toolkits.- */- export type Toolkit =- | "GMAIL"- | "SLACK"-- /**- * Given a toolkit, returns the tools available for that toolkit.- */- export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]+ // Run the command+ const args = ['ts', 'generate', '--compact'];+ yield* cli(args);+ // Verify the output+ const outputDir = path.join(cwd, '.generated', 'composio-ts');+ const fileExists = yield* fs.exists(path.join(outputDir, 'index.ts'));+ expect(fileExists).toBe(true);- "- `);+ const indexSourceCode = yield* fs.readFileString(path.join(outputDir, 'index.ts'));+ expect(indexSourceCode).toMatchInlineSnapshot(`+ "/**+ * Auto-generated by Composio CLI. Do not modify manually.+ */++ import { GMAIL } from "./gmail.js"+ import { SLACK } from "./slack.js"++ /**+ * Map of Composio toolkits to actions.+ */+ export const composio = {+ GMAIL: GMAIL,+ SLACK: SLACK,+ }++ /**+ * Type declarations+ */++ /**+ * Union of all available toolkits.+ */+ export type Toolkit =+ | "GMAIL"+ | "SLACK"++ /**+ * Given a toolkit, returns the tools available for that toolkit.+ */+ export type ToolsByToolkit<Toolkit extends keyof (typeof composio)> = typeof composio[Toolkit]++ "+ `);++ assertTypeScriptIsValid({ files: { './index.ts': indexSourceCode } });+ })+ );+ });+ });- assertTypeScriptIsValid({ files: { './index.ts': indexSourceCode } });+ describe('[Given] `@composio/core` not installed', () => {+ layer(+ TestLive({+ fixture: 'typescript-project',+ toolkitsData: appClientData,})- );+ )(it => {+ it.scoped('[Given] no custom output dir [Then] [Then] it raises an error', () =>+ Effect.gen(function* () {+ const args = ['ts', 'generate'];++ const result = yield* cli(args).pipe(Effect.catchAll(e => Effect.succeed(e)));++ expect(result).toEqual(+ new ComposioCorePkgNotFound({+ message: '@composio/core not found',+ cause: '@composio/core not installed',+ fix: 'Install @composio/core with `npm install -S @composio/core`, or specify an output directory using `--output-dir`',+ })+ );+ })+ );+ });});});});diff --git a/ts/packages/cli/test/src/commands/version.test.ts b/ts/packages/cli/test/src/commands/version.test.tsindex 9f2598065..781442b5c 100644--- a/ts/packages/cli/test/src/commands/version.test.ts+++ b/ts/packages/cli/test/src/commands/version.test.ts@@ -4,7 +4,7 @@ import { cli, pkg, TestLive, MockConsole } from 'test/__utils__';describe('CLI: composio', () => {layer(TestLive())(it => {- it.effect("[Given] no arguments [Then] prints composio's version from package.json", () =>+ it.scoped("[Given] no arguments [Then] prints composio's version from package.json", () =>Effect.gen(function* () {const args = ['version'];yield* cli(args);@@ -14,7 +14,7 @@ describe('CLI: composio', () => {}));- it.effect('[Given] DEBUG_OVERRIDE_VERSION env var [Then] prints overridden version', () =>+ it.scoped('[Given] DEBUG_OVERRIDE_VERSION env var [Then] prints overridden version', () =>Effect.gen(function* () {const expectedVersion = '1.2.3-test';vi.stubEnv('DEBUG_OVERRIDE_VERSION', expectedVersion);diff --git a/ts/packages/cli/test/src/commands/whoami.cmd.test.ts b/ts/packages/cli/test/src/commands/whoami.cmd.test.tsindex 8451c4514..f23433abb 100644--- a/ts/packages/cli/test/src/commands/whoami.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/whoami.cmd.test.ts@@ -11,7 +11,7 @@ describe('CLI: composio whoami', () => {);layer(TestLive().pipe(Layer.provide(Layer.setConfigProvider(mockConfigProvider))))(it => {- it.effect('[Given] `COMPOSIO_API_KEY` env var [Then] prints it in stdout', () =>+ it.scoped('[Given] `COMPOSIO_API_KEY` env var [Then] prints it in stdout', () =>Effect.gen(function* () {const args = ['whoami'];yield* cli(args);diff --git a/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts b/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.tsindex d289dac21..f82715daa 100644--- a/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts+++ b/ts/packages/cli/test/src/generation/python/generate-toolkit-source.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest';import { generatePythonToolkitSources } from 'src/generation/python/generate-toolkit-sources';import { createToolkitIndex } from 'src/generation/create-toolkit-index';+import { BANNER } from 'src/generation/constants';import { makeTestToolkits } from 'test/__utils__/models/toolkits';describe('generatePythonToolkitSources', () => {@@ -11,7 +12,7 @@ describe('generatePythonToolkitSources', () => {triggerTypes: [],});- const sources = generatePythonToolkitSources(index);+ const sources = generatePythonToolkitSources(BANNER)(index);expect(sources).toEqual([]);});@@ -30,13 +31,12 @@ describe('generatePythonToolkitSources', () => {triggerTypes: [],});- const sources = generatePythonToolkitSources(index);+ const sources = generatePythonToolkitSources(BANNER)(index);expect(sources).toHaveLength(1);expect(sources[0]).toHaveLength(2);expect(sources[0][0]).toBe('slack.py');expect(sources[0][1]).toMatchInlineSnapshot(`- "# Auto-generated by Composio CLI via \`composio py generate\`.- # Do not modify manually.+ "# Auto-generated by Composio CLI. Do not modify manually..class SLACK:"""Map of Composio's SLACK toolkit."""@@ -70,14 +70,13 @@ describe('generatePythonToolkitSources', () => {triggerTypes: ['GMAIL_NEW_GMAIL_MESSAGE'],});- const sources = generatePythonToolkitSources(index);+ const sources = generatePythonToolkitSources(BANNER)(index);expect(sources).toHaveLength(2);expect(sources[0]).toHaveLength(2);expect(sources[0][0]).toBe('gmail.py');expect(sources[0][1]).toMatchInlineSnapshot(`- "# Auto-generated by Composio CLI via \`composio py generate\`.- # Do not modify manually.+ "# Auto-generated by Composio CLI. Do not modify manually..class GMAIL:"""Map of Composio's GMAIL toolkit."""@@ -97,8 +96,7 @@ describe('generatePythonToolkitSources', () => {expect(sources[1]).toHaveLength(2);expect(sources[1][0]).toBe('slack.py');expect(sources[1][1]).toMatchInlineSnapshot(`- "# Auto-generated by Composio CLI via \`composio py generate\`.- # Do not modify manually.+ "# Auto-generated by Composio CLI. Do not modify manually..class SLACK:"""Map of Composio's SLACK toolkit."""diff --git a/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts b/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.tsindex 60fe27871..5b3994d02 100644--- a/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts+++ b/ts/packages/cli/test/src/generation/typescript/generate-index-source.test.ts@@ -223,7 +223,7 @@ describe('generateTypeScriptToolkitSources', () => {* Some banner that will appear in a comment*/- import { SLACK } from "./slack.ts"+ import { SLACK } from "./slack.undefined"/*** Map of Composio toolkits to actions.@@ -277,8 +277,8 @@ describe('generateTypeScriptToolkitSources', () => {* Some banner that will appear in a comment*/- import { GMAIL } from "./gmail.ts"- import { SLACK } from "./slack.ts"+ import { GMAIL } from "./gmail.undefined"+ import { SLACK } from "./slack.undefined"/*** Map of Composio toolkits to actions.diff --git a/ts/packages/cli/test/src/generation/typescript/generate.test.ts b/ts/packages/cli/test/src/generation/typescript/generate.test.tsindex fb001b9b7..bae6cd523 100644--- a/ts/packages/cli/test/src/generation/typescript/generate.test.ts+++ b/ts/packages/cli/test/src/generation/typescript/generate.test.ts@@ -10,7 +10,8 @@ describe('generateTypeScriptSources', () => {const _params = {outputDir: '<cwd>',emitSingleFile: false,- };+ importExtension: 'ts',+ } as const satisfies Omit<Parameters<typeof generateTypeScriptSources>[0], 'banner'>;describe('with banner', () => {const params = {diff --git a/ts/packages/cli/test/src/services/js-package-manager-detector.test.ts b/ts/packages/cli/test/src/services/js-package-manager-detector.test.tsnew file mode 100644index 000000000..9bec07f20--- /dev/null+++ b/ts/packages/cli/test/src/services/js-package-manager-detector.test.ts@@ -0,0 +1,106 @@+import { describe, expect, layer } from '@effect/vitest';+import { BunFileSystem } from '@effect/platform-bun';+import { FileSystem } from '@effect/platform';+import { Effect, Layer } from 'effect';+import * as tempy from 'tempy';+import { JsPackageManagerDetector } from 'src/services/js-package-manager-detector';+import * as path from 'path';++describe('JsPackageManagerDetector', () => {+ const testLayer = Layer.provideMerge(JsPackageManagerDetector.Default, BunFileSystem.layer);++ layer(testLayer)(it => {+ it.scoped('should detect pnpm from lock file', () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const detector = yield* JsPackageManagerDetector;+ const cwd = tempy.temporaryDirectory();++ yield* fs.writeFileString(path.join(cwd, 'pnpm-lock.yaml'), '');++ const result = yield* detector.detectJsPackageManager(cwd);++ expect(result).toEqual('pnpm');+ })+ );++ it.scoped('should detect bun from lock file', () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const detector = yield* JsPackageManagerDetector;+ const cwd = tempy.temporaryDirectory();++ yield* fs.writeFileString(path.join(cwd, 'bun.lockb'), '');++ const result = yield* detector.detectJsPackageManager(cwd);++ expect(result).toEqual('bun');+ })+ );++ it.scoped('should detect yarn from lock file', () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const detector = yield* JsPackageManagerDetector;+ const cwd = tempy.temporaryDirectory();++ yield* fs.writeFileString(path.join(cwd, 'yarn.lock'), '');++ const result = yield* detector.detectJsPackageManager(cwd);++ expect(result).toEqual('yarn');+ })+ );++ it.scoped('should detect npm from lock file', () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const detector = yield* JsPackageManagerDetector;+ const cwd = tempy.temporaryDirectory();++ yield* fs.writeFileString(path.join(cwd, 'package-lock.json'), '');++ const result = yield* detector.detectJsPackageManager(cwd);++ expect(result).toEqual('npm');+ })+ );++ it.scoped('should detect from package.json if no lock file is present', () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const detector = yield* JsPackageManagerDetector;+ const cwd = tempy.temporaryDirectory();++ yield* fs.writeFileString(+ path.join(cwd, 'package.json'),+ JSON.stringify({ packageManager: '[email protected]' })+ );++ const result = yield* detector.detectJsPackageManager(cwd);++ expect(result).toEqual('pnpm');+ })+ );++ it.scoped('should detect recursively from parent directory', () =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const detector = yield* JsPackageManagerDetector;+ const rootDir = tempy.temporaryDirectory();++ yield* fs.writeFileString(+ path.join(rootDir, 'package.json'),+ JSON.stringify({ packageManager: '[email protected]' })+ );++ const subDir = path.join(rootDir, 'subdir');+ yield* fs.makeDirectory(subDir);++ const result = yield* detector.detectJsPackageManager(subDir);++ expect(result).toEqual('pnpm');+ })+ );+ });+});diff --git a/ts/packages/cli/vitest.config.ts b/ts/packages/cli/vitest.config.tsindex 6f357b0f8..bf68fa613 100644--- a/ts/packages/cli/vitest.config.ts+++ b/ts/packages/cli/vitest.config.ts@@ -16,5 +16,6 @@ export default defineConfig({tsconfig: './tsconfig.test.json',},includeSource: ['src/**/*.ts', 'test/**/*.ts'],+ globalSetup: './test/__utils__/vitest.global-setup.ts',},});diff --git a/ts/packages/core/.gitignore b/ts/packages/core/.gitignorenew file mode 100644index 000000000..9ab870da8--- /dev/null+++ b/ts/packages/core/.gitignore@@ -0,0 +1 @@+generated/diff --git a/ts/packages/core/package.json b/ts/packages/core/package.jsonindex eb99e3234..9c9d89de6 100644--- a/ts/packages/core/package.json+++ b/ts/packages/core/package.json@@ -14,11 +14,16 @@"import": "./dist/index.js","types": "./dist/index.d.ts","require": "./dist/index.cjs"+ },+ "./generated": {+ "import": "./generated/index.js",+ "types": "./generated/index.d.ts"}},"files": ["README.md",- "dist"+ "dist",+ "generated"],"scripts": {"clean": "git clean -xdf node_modules",