Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(cli): support `upgrade` command (#1774)

Alberto Schiabeld14bfd7386df
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e3e6437a1..0ac5edeaf 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -532,6 +532,9 @@ importers:
ansis:
specifier: ^4.1.0
version: 4.1.0
+ decompress:
+ specifier: ^4.2.1
+ version: 4.2.1
effect:
specifier: ^3.16.16
version: 3.16.16
@@ -566,6 +569,9 @@ importers:
'@types/bun':
specifier: ^1.2.16
version: 1.2.16
+ '@types/decompress':
+ specifier: ^4.2.7
+ version: 4.2.7
'@types/semver':
specifier: ^7.7.0
version: 7.7.0
@@ -3142,6 +3148,9 @@ packages:
resolution: {integrity: sha512-1B6jqWHWQud+7yyWAqbxnPmzlHrrOtJzZr1DhhYJ/NbpS4irfZSnq+N5Fm76J9LNRlUZvCmYxTVhhohWRvtqHw==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-9z+8yjKr5Wn73Pt17/ldnmQToaFHZxK0N1GHysuk/JIPT8RIdQeoInM01wWPgypRcvb6VH1drjuFpQ4zmY437g==}
+
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
@@ -3465,6 +3474,10 @@ packages:
resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==}
engines: {node: '>=8.0.0'}
+ resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==}
@@ -3488,6 +3501,9 @@ packages:
resolution: {integrity: sha512-37FHE8rqsYM5JEKCnXFyHpBCzvgHEExwVVTq+nUmloInU7l8ezD1TpOhKpS8oe1DTYFqEK27rFZVKG43oTqXRA==}
+ resolution: {integrity: sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==}
+
resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==}
@@ -3512,9 +3528,24 @@ packages:
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==}
+
+ resolution: {integrity: sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==}
+
+ resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==}
+
resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==}
+ resolution: {integrity: sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==}
+
+ resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
+
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
@@ -3547,6 +3578,10 @@ packages:
resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==}
engines: {node: '>= 0.4'}
@@ -3659,6 +3694,9 @@ packages:
resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
+
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
engines: {node: '>= 6'}
@@ -3783,6 +3821,26 @@ packages:
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==}
+ engines: {node: '>=4'}
+
+ resolution: {integrity: sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==}
+ engines: {node: '>=4'}
+
+ resolution: {integrity: sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==}
+ engines: {node: '>=4'}
+
+ resolution: {integrity: sha512-1fqeluvxgnn86MOh66u8FjbtJpAFv5wgCT9Iw8rcBqQcCo5tO8eiJw7NNTrvt9n4CRBVq7CstiS922oPgyGLrw==}
+ engines: {node: '>=4'}
+
+ resolution: {integrity: sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ==}
+ engines: {node: '>=4'}
+
resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
engines: {node: '>=6'}
@@ -3798,6 +3856,10 @@ packages:
resolution: {integrity: sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==}
engines: {node: '>=8'}
@@ -4121,6 +4183,9 @@ packages:
resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==}
+ resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==}
+
resolution: {integrity: sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==}
peerDependencies:
@@ -4140,6 +4205,18 @@ packages:
resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
engines: {node: '>=16.0.0'}
+ resolution: {integrity: sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==}
+ engines: {node: '>=0.10.0'}
+
+ resolution: {integrity: sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==}
+ engines: {node: '>=4'}
+
+ resolution: {integrity: sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==}
+ engines: {node: '>=4'}
+
resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==}
engines: {node: '>=8'}
@@ -4182,6 +4259,10 @@ packages:
debug:
optional: true
+ resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==}
engines: {node: '>=14'}
@@ -4220,6 +4301,9 @@ packages:
resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==}
engines: {node: '>= 0.8'}
+ resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
+
resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==}
engines: {node: '>=6 <7 || >=8'}
@@ -4263,6 +4347,10 @@ packages:
resolution: {integrity: sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==}
+ resolution: {integrity: sha512-AUGhbbemXxrZJRD5cDvKtQxLuYaIbNtDTK8YqupCI393Q2KSTreEsLUN3ZxAWFGiKTzL6nKuzfcIvieflUX9qA==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==}
engines: {node: '>=16'}
@@ -4331,6 +4419,9 @@ packages:
resolution: {integrity: sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==}
+
resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==}
engines: {node: '>= 0.4'}
@@ -4475,6 +4566,10 @@ packages:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'}
+ resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==}
engines: {node: '>= 0.4'}
@@ -4518,6 +4613,9 @@ packages:
engines: {node: '>=14.16'}
hasBin: true
+ resolution: {integrity: sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==}
+
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
engines: {node: '>=0.12.0'}
@@ -4525,6 +4623,10 @@ packages:
resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==}
+ resolution: {integrity: sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==}
engines: {node: '>=8'}
@@ -4537,6 +4639,10 @@ packages:
resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==}
engines: {node: '>=4'}
+ resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==}
engines: {node: '>=12.13'}
@@ -4553,6 +4659,12 @@ packages:
resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==}
engines: {node: '>=16'}
+ resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
+
+ resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==}
+
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
@@ -4774,6 +4886,10 @@ packages:
resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}
+ resolution: {integrity: sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==}
+ engines: {node: '>=4'}
+
resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==}
hasBin: true
@@ -5165,6 +5281,9 @@ packages:
resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==}
engines: {node: '>= 14.16'}
+ resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}
+
resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==}
engines: {node: '>=4.0.0'}
@@ -5196,10 +5315,22 @@ packages:
resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==}
engines: {node: '>=0.10.0'}
+ resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==}
+ engines: {node: '>=4'}
+
resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==}
+ engines: {node: '>=0.10.0'}
+
+ resolution: {integrity: sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==}
+ engines: {node: '>=0.10.0'}
+
resolution: {integrity: sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==}
@@ -5225,6 +5356,10 @@ packages:
resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}
+ resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==}
engines: {node: '>=14.0.0'}
@@ -5325,6 +5460,9 @@ packages:
resolution: {integrity: sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==}
+ resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
+
resolution: {integrity: sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==}
@@ -5416,6 +5554,9 @@ packages:
resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
+
resolution: {integrity: sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -5502,6 +5643,9 @@ packages:
resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==}
+ resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
+
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
@@ -5522,6 +5666,10 @@ packages:
resolution: {integrity: sha512-6aU+Rwsezw7VR8/nyvKTx8QpWH9FrcYiXXlqC4z5d5XQBDRqtbfsRjnwGyqbi3gddNtWHuEk9OANUotL26qKUw==}
+ resolution: {integrity: sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ==}
+ hasBin: true
+
resolution: {integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==}
engines: {node: '>=10'}
@@ -5543,6 +5691,10 @@ packages:
resolution: {integrity: sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==}
engines: {node: '>= 18'}
+ resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==}
@@ -5679,6 +5831,9 @@ packages:
resolution: {integrity: sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==}
+
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
@@ -5698,6 +5853,9 @@ packages:
resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==}
engines: {node: '>=4'}
+ resolution: {integrity: sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==}
+
resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==}
engines: {node: '>=12'}
@@ -5756,6 +5914,10 @@ packages:
engines: {node: '>=14.0.0'}
hasBin: true
+ resolution: {integrity: sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==}
+ engines: {node: '>= 0.8.0'}
+
resolution: {integrity: sha512-nHc6S/bwIilKHNRgK/3jlhDoIHcp45YgyiwcAk46Tr0LfEqGBVpmiAyuiuxeVE44m3mXnEeVhaipLOEWmH+Njw==}
engines: {node: '>=14.16'}
@@ -5782,6 +5944,9 @@ packages:
resolution: {integrity: sha512-nt6AMGKW1p/70DF/hGBdJB57B8Tspmbp5gfJ8ilhLnt7kkr2ye7hzD6NVG8GGErk2HWF34igrL2CXmNIkzKqKw==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==}
+
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
@@ -5808,6 +5973,10 @@ packages:
resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}
engines: {node: '>=0.6.0'}
+ resolution: {integrity: sha512-tB82LpAIWjhLYbqjx3X4zEeHN6M8CiuOEy2JY8SEQVdYRe3CCHOFaqrBW1doLDrfpWhplcW7BL+bO3/6S3pcDQ==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@@ -5933,6 +6102,10 @@ packages:
resolution: {integrity: sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==}
engines: {node: '>= 0.6'}
+ resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-AnbToFS1T1H+n40QbO2+i0wE6L+55rWnj7zxnM1r781+2gmhMF2dB6dzFpaylWLQYkbg4D1Y13sYnne/6qZwdw==}
engines: {node: '>= 18'}
@@ -5969,6 +6142,9 @@ packages:
resolution: {integrity: sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==}
+ resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==}
+
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
@@ -6128,6 +6304,10 @@ packages:
resolution: {integrity: sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==}
engines: {node: '>=4'}
+ resolution: {integrity: sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==}
+ engines: {node: '>= 0.4'}
+
resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==}
engines: {node: '>= 8'}
@@ -6232,6 +6412,9 @@ packages:
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==}
+
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
@@ -9205,6 +9388,10 @@ snapshots:
dependencies:
'@types/node': 20.19.1
+ '@types/[email protected]':
+ dependencies:
+ '@types/node': 24.0.3
+
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -9232,7 +9419,7 @@ snapshots:
dependencies:
- '@types/node': 20.19.1
+ '@types/node': 24.0.3
dependencies:
@@ -9408,14 +9595,6 @@ snapshots:
chai: 5.2.0
tinyrainbow: 2.0.0
- dependencies:
- '@vitest/spy': 3.2.4
- estree-walker: 3.0.3
- magic-string: 0.30.17
- optionalDependencies:
-
dependencies:
'@vitest/spy': 3.2.4
@@ -9424,14 +9603,6 @@ snapshots:
optionalDependencies:
- dependencies:
- '@vitest/spy': 3.2.4
- estree-walker: 3.0.3
- magic-string: 0.30.17
- optionalDependencies:
-
'@vitest/[email protected]':
dependencies:
tinyrainbow: 2.0.0
@@ -9461,7 +9632,7 @@ snapshots:
sirv: 3.0.1
tinyglobby: 0.2.14
tinyrainbow: 2.0.0
'@vitest/[email protected]':
dependencies:
@@ -9577,6 +9748,10 @@ snapshots:
+ dependencies:
+ possible-typed-array-names: 1.1.0
+
dependencies:
follow-redirects: 1.15.9
@@ -9599,6 +9774,11 @@ snapshots:
+ dependencies:
+ readable-stream: 2.3.8
+ safe-buffer: 5.2.1
+
@@ -9647,8 +9827,24 @@ snapshots:
dependencies:
fill-range: 7.1.1
+
+ dependencies:
+ buffer-alloc-unsafe: 1.1.0
+ buffer-fill: 1.0.0
+
+
+
+ dependencies:
+ base64-js: 1.5.1
+ ieee754: 1.2.1
+
dependencies:
base64-js: 1.5.1
@@ -9680,6 +9876,13 @@ snapshots:
es-errors: 1.3.0
function-bind: 1.1.2
+ dependencies:
+ call-bind-apply-helpers: 1.0.2
+ es-define-property: 1.0.1
+ get-intrinsic: 1.3.0
+ set-function-length: 1.2.2
+
dependencies:
call-bind-apply-helpers: 1.0.2
@@ -9802,6 +10005,8 @@ snapshots:
+
@@ -9913,6 +10118,44 @@ snapshots:
+ dependencies:
+ file-type: 5.2.0
+ is-stream: 1.1.0
+ tar-stream: 1.6.2
+
+ dependencies:
+ decompress-tar: 4.1.1
+ file-type: 6.2.0
+ is-stream: 1.1.0
+ seek-bzip: 1.0.6
+ unbzip2-stream: 1.4.3
+
+ dependencies:
+ decompress-tar: 4.1.1
+ file-type: 5.2.0
+ is-stream: 1.1.0
+
+ dependencies:
+ file-type: 3.9.0
+ get-stream: 2.3.1
+ pify: 2.3.0
+ yauzl: 2.10.0
+
+ dependencies:
+ decompress-tar: 4.1.1
+ decompress-tarbz2: 4.1.1
+ decompress-targz: 4.1.1
+ decompress-unzip: 4.0.1
+ graceful-fs: 4.2.11
+ make-dir: 1.3.0
+ pify: 2.3.0
+ strip-dirs: 2.1.0
+
@@ -9924,6 +10167,12 @@ snapshots:
bundle-name: 4.1.0
default-browser-id: 5.0.0
+ dependencies:
+ es-define-property: 1.0.1
+ es-errors: 1.3.0
+ gopd: 1.2.0
+
@@ -10324,6 +10573,10 @@ snapshots:
dependencies:
reusify: 1.1.0
+ dependencies:
+ pend: 1.2.0
+
optionalDependencies:
picomatch: 4.0.2
@@ -10336,6 +10589,12 @@ snapshots:
dependencies:
flat-cache: 4.0.1
+
+
+
dependencies:
to-regex-range: 5.0.1
@@ -10390,6 +10649,10 @@ snapshots:
+ dependencies:
+ is-callable: 1.2.7
+
dependencies:
cross-spawn: 7.0.6
@@ -10422,6 +10685,8 @@ snapshots:
+
dependencies:
graceful-fs: 4.2.11
@@ -10486,6 +10751,11 @@ snapshots:
data-uri-to-buffer: 2.0.2
source-map: 0.6.1
+ dependencies:
+ object-assign: 4.1.1
+ pinkie-promise: 2.0.1
+
@@ -10563,6 +10833,10 @@ snapshots:
+ dependencies:
+ es-define-property: 1.0.1
+
@@ -10664,6 +10938,8 @@ snapshots:
dependencies:
binary-extensions: 2.3.0
+
dependencies:
hasown: 2.0.2
@@ -10692,10 +10968,14 @@ snapshots:
dependencies:
is-docker: 3.0.0
+
+
@@ -10704,6 +10984,10 @@ snapshots:
dependencies:
better-path-resolve: 1.0.0
+ dependencies:
+ which-typed-array: 1.1.19
+
@@ -10716,6 +11000,10 @@ snapshots:
dependencies:
is-inside-container: 1.0.0
+
+
@@ -10921,6 +11209,10 @@ snapshots:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.0
+ dependencies:
+ pify: 3.0.0
+
dependencies:
argparse: 2.0.1
@@ -11277,6 +11569,8 @@ snapshots:
+
@@ -11299,8 +11593,16 @@ snapshots:
+
+ dependencies:
+ pinkie: 2.0.4
+
+
dependencies:
split2: 4.2.0
@@ -11347,6 +11649,8 @@ snapshots:
mlly: 1.7.4
pathe: 2.0.3
+
dependencies:
postcss: 8.5.6
@@ -11421,6 +11725,8 @@ snapshots:
+
@@ -11522,6 +11828,16 @@ snapshots:
pify: 4.0.1
strip-bom: 3.0.0
+ dependencies:
+ core-util-is: 1.0.3
+ inherits: 2.0.4
+ isarray: 1.0.0
+ process-nextick-args: 2.0.1
+ safe-buffer: 5.1.2
+ string_decoder: 1.1.1
+ util-deprecate: 1.0.2
+
dependencies:
abort-controller: 3.0.0
@@ -11625,6 +11941,8 @@ snapshots:
dependencies:
tslib: 2.8.1
+
@@ -11640,6 +11958,10 @@ snapshots:
+ dependencies:
+ commander: 2.20.3
+
@@ -11694,6 +12016,15 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ define-data-property: 1.1.4
+ es-errors: 1.3.0
+ function-bind: 1.1.2
+ get-intrinsic: 1.3.0
+ gopd: 1.2.0
+ has-property-descriptors: 1.0.2
+
@@ -11875,6 +12206,10 @@ snapshots:
get-east-asian-width: 1.3.0
strip-ansi: 7.1.0
+ dependencies:
+ safe-buffer: 5.1.2
+
dependencies:
safe-buffer: 5.2.1
@@ -11891,6 +12226,10 @@ snapshots:
+ dependencies:
+ is-natural-number: 4.0.1
+
@@ -11974,6 +12313,16 @@ snapshots:
transitivePeerDependencies:
- ts-node
+ dependencies:
+ bl: 1.2.3
+ buffer-alloc: 1.2.0
+ end-of-stream: 1.4.5
+ fs-constants: 1.0.0
+ readable-stream: 2.3.8
+ to-buffer: 1.2.1
+ xtend: 4.0.2
+
@@ -11999,6 +12348,8 @@ snapshots:
+
@@ -12018,6 +12369,12 @@ snapshots:
dependencies:
os-tmpdir: 1.0.2
+ dependencies:
+ isarray: 2.0.5
+ safe-buffer: 5.2.1
+ typed-array-buffer: 1.0.3
+
dependencies:
is-number: 7.0.0
@@ -12131,6 +12488,12 @@ snapshots:
media-typer: 1.1.0
mime-types: 3.0.1
+ dependencies:
+ call-bound: 1.0.4
+ es-errors: 1.3.0
+ is-typed-array: 1.1.15
+
dependencies:
typedoc: 0.28.5([email protected])
@@ -12164,6 +12527,11 @@ snapshots:
+ dependencies:
+ buffer: 5.7.1
+ through: 2.3.8
+
@@ -12326,7 +12694,7 @@ snapshots:
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.4
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
@@ -12410,7 +12778,7 @@ snapshots:
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.4
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
@@ -12467,6 +12835,16 @@ snapshots:
+ dependencies:
+ available-typed-arrays: 1.0.7
+ call-bind: 1.0.8
+ call-bound: 1.0.4
+ for-each: 0.3.5
+ get-proto: 1.0.1
+ gopd: 1.2.0
+ has-tostringtag: 1.0.2
+
dependencies:
isexe: 2.0.0
@@ -12559,6 +12937,11 @@ snapshots:
y18n: 5.0.8
yargs-parser: 21.1.1
+ dependencies:
+ buffer-crc32: 0.2.13
+ fd-slicer: 1.1.0
+
diff --git a/ts/packages/cli/.gitignore b/ts/packages/cli/.gitignore
index da5735229..4d168b645 100644
--- a/ts/packages/cli/.gitignore
+++ b/ts/packages/cli/.gitignore
@@ -1,2 +1,3 @@
.generated/
composio
+.envrc
diff --git a/ts/packages/cli/README.md b/ts/packages/cli/README.md
index b57fdd840..735587b69 100644
--- a/ts/packages/cli/README.md
+++ b/ts/packages/cli/README.md
@@ -30,26 +30,38 @@ composio [--log-level all|trace|debug|info|warning|error|fatal|none]
| `composio version` | Display the current CLI version. | ✅ |
| `composio whoami` | Show the currently logged-in user/account. | ✅ It displays the local API_KEY, or shows a message if no API_KEY is found. |
| `composio login` | Log in to the Composio SDK. | ⏰ The session client is defined, but the authentication workflow is currently incomplete |
+| `composio logout` | Log out from the Composio SDK. | ✅ |
| `composio generate [-o, --output-dir <directory>]` | Auto-detect the project language (Python or TypeScript) and generate the latest app type stubs. | ✅ |
| `composio py` | Python project-specific commands. |
| `composio py generate [-o, --output-dir <directory>]` | Generate updated Python stubs with the latest app data. | ✅ |
| `composio ts` | TypeScript project-specific commands. | ✅ |
| `composio ts generate [-o, --output-dir <directory>] [--single-file]` | Generate updated TypeScript stubs, optionally as a single file. | ✅ |
-| `composio upgrade` | Self-update the Composio CLI if a new release is out. | 🛑 Not implemented yet |
+| `composio upgrade` | Self-update the Composio CLI if a new release is out. | ✅ yet |
## Configuration
-The Composio CLI supports configuration via environment variables and a JSON configuration file.
+The Composio CLI supports configuration via environment variables.
+Additionally, for storing and retrieving user session context, a `user_data.json` JSON configuration file is used.
-The Composio CLI also supports a JSON configuration file. The default location is `~/.composio/user_data.json`, but you can specify a custom location using the `COMPOSIO_CACHE_DIR` environment variable.
+By default, this file is stored in `~/.composio`, but you can specify a custom location using the `COMPOSIO_CACHE_DIR` environment variable.
-| Environment Variable | User JSON config | Description | Default |
-| ---------------------- | ---------------- | ------------------------------------------------------------------ | ------- |
-| COMPOSIO_API_KEY | `api_key` | Your Composio API key | None |
-| COMPOSIO_BASE_URL | `base_url` | The base URL of the Composio backend API | None |
-| COMPOSIO_CACHE_DIR | `cache_dir` | The directory where the Composio CLI stores cache files | None |
-| COMPOSIO_LOG_LEVEL | `log_level` | The log level for the Composio CLI | None |
-| DEBUG_OVERRIDE_VERSION | `version` | The version to use when upgrading the Composio CLI (for debugging) | None |
+| Environment Variable | User JSON config | Description | Default |
+| ---------------------- | ---------------- | ------------------------------------------------------------------ | ----------- |
+| COMPOSIO_API_KEY | `api_key` | Composio backend API key | None |
+| COMPOSIO_BASE_URL | `base_url` | The base URL of the Composio backend API | None |
+| COMPOSIO_CACHE_DIR | - | The directory where the Composio CLI stores cache files | ~/.composio |
+| COMPOSIO_LOG_LEVEL | - | The log level for the Composio CLI | None |
+| DEBUG_OVERRIDE_VERSION | - | The version to use when upgrading the Composio CLI (for debugging) | None |
+
+Additionally, `composio upgrade` supports the following environment variables:
+
+| Environment Variable | Description | Default |
+| ---------------------------- | ------------------------------------------------------------------------------------------------------ | ---------------------- |
+| COMPOSIO_GITHUB_API_BASE_URL | The base URL for the GitHub API | https://api.github.com |
+| COMPOSIO_GITHUB_OWNER | The owner of the Composio repository on GitHub | ComposioHQ |
+| COMPOSIO_GITHUB_REPO | The repository name for the Composio CLI | composio |
+| COMPOSIO_GITHUB_TAG | The tag to use when fetching the Composio CLI binary from Github | latest |
+| COMPOSIO_GITHUB_ACCESS_TOKEN | The access token for the GitHub API. Useful during development to avoid getting rate-limited by Github | None |
## Development
@@ -62,13 +74,13 @@ pnpm install
### Build TypeScript code
```bash
-pnpm build
+bun run build
```
### Build self-contained executable
```bash
-pnpm build:bin
+bun build:bin
```
or
@@ -77,20 +89,35 @@ or
bun run ./scripts/build-binary.ts
```
+### Install self-contained executable
+
+```bash
+bun install:bin
+```
+
+or
+
+```bash
+bun run ./scripts/install-binary.ts ./dist/composio
+```
+
+By default, the executable will be installed in `~/.composio/composio`.
+You can customize the installation directory by setting the `COMPOSIO_INSTALL_DIR` environment variable.
+
### Run interactively
```bash
-pnpm cli
+bun cli
```
For instance, to generate type stubs for a TypeScript project, you can run:
```bash
-pnpm cli ts generate
+bun cli ts generate
```
### Test
```bash
-pnpm test
+bun run test
```
diff --git a/ts/packages/cli/package.json b/ts/packages/cli/package.json
index 10f4e0e01..357bc1429 100644
--- a/ts/packages/cli/package.json
+++ b/ts/packages/cli/package.json
@@ -25,6 +25,7 @@
"clean": "git clean -xdf node_modules",
"cli": "bun run src/bin.ts",
"build:bin": "bun run ./scripts/build-binary.ts",
+ "install:bin": "bun run ./scripts/install-binary.ts ./dist/composio",
"build": "tsup",
"bin": "./dist/composio",
"test": "vitest run",
@@ -44,6 +45,7 @@
"@effect/platform": "^0.85.2",
"@effect/vitest": "^0.23.8",
"@types/bun": "^1.2.16",
+ "@types/decompress": "^4.2.7",
"@types/semver": "^7.7.0",
"tempy": "^3.1.0",
"tsup": "^8.5.0",
@@ -59,6 +61,7 @@
"@effect/platform-bun": "^0.70.4",
"@effect/platform-node-shared": "^0.40.4",
"ansis": "^4.1.0",
+ "decompress": "^4.2.1",
"effect": "^3.16.16",
"effect-errors": "^1.10.11",
"indent-string": "^5.0.0",
diff --git a/ts/packages/cli/scripts/build-binary.ts b/ts/packages/cli/scripts/build-binary.ts
index 20b903a9f..fd6a0d126 100644
--- a/ts/packages/cli/scripts/build-binary.ts
+++ b/ts/packages/cli/scripts/build-binary.ts
@@ -15,6 +15,9 @@ import { Command } from '@effect/platform';
import { BunContext, BunRuntime } from '@effect/platform-bun';
import type { Teardown } from '@effect/platform/Runtime';
+/**
+ * Usage: `bun scripts/build-binary.ts`
+ */
export function buildBinary() {
return Effect.gen(function* () {
const cwd = process.cwd();
diff --git a/ts/packages/cli/scripts/install-binary.ts b/ts/packages/cli/scripts/install-binary.ts
new file mode 100644
index 000000000..950478a0c
--- /dev/null
+++ b/ts/packages/cli/scripts/install-binary.ts
@@ -0,0 +1,68 @@
+import process from 'node:process';
+import {
+ Cause,
+ Config,
+ ConfigProvider,
+ Console,
+ Effect,
+ Exit,
+ Logger,
+ Layer,
+ LogLevel,
+} from 'effect';
+import { BunContext, BunRuntime } from '@effect/platform-bun';
+import type { Teardown } from '@effect/platform/Runtime';
+import path from 'node:path';
+import os from 'node:os';
+import { $ } from 'bun';
+
+/**
+ * Usage: `COMPOSIO_INSTALL_DIR=<INSTALL_DIR> bun scripts/build-binary.ts <BINARY_PATH>`
+ */
+export function installBinary() {
+ return Effect.gen(function* () {
+ const binaryPath = process.argv[2];
+
+ if (!binaryPath) {
+ return yield* Effect.logError('Missing <BINARY_PATH> argument');
+ }
+
+ const defaultInstallDir = path.join(os.homedir(), '.composio');
+ const installDir = yield* Config.string('COMPOSIO_INSTALL_DIR').pipe(
+ Config.withDefault(defaultInstallDir)
+ );
+
+ yield* Effect.logDebug(`Installing binary in ${installDir}`);
+
+ yield* Effect.tryPromise(() => $`cp ${binaryPath} ${installDir}/composio`.quiet());
+
+ yield* Console.log('Binary successfully installed in', installDir);
+ });
+}
+
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
+ const errorCode = Number(process.exitCode ?? 1);
+ onExit(shouldFail ? errorCode : 0);
+};
+
+const ConfigLive = Effect.gen(function* () {
+ const logLevel = yield* Config.logLevel('COMPOSIO_LOG_LEVEL').pipe(
+ Config.withDefault(LogLevel.Info)
+ );
+
+ return Logger.minimumLogLevel(logLevel);
+}).pipe(Layer.unwrapEffect, Layer.merge(Layer.setConfigProvider(ConfigProvider.fromEnv())));
+
+if (require.main === module) {
+ installBinary().pipe(
+ Effect.provide(ConfigLive),
+ Effect.provide(Logger.pretty),
+ Effect.provide(BunContext.layer),
+ Effect.scoped,
+ Effect.map(() => ({ message: 'Binary installed successfully.' })),
+ BunRuntime.runMain({
+ teardown,
+ })
+ );
+}
diff --git a/ts/packages/cli/src/bin.ts b/ts/packages/cli/src/bin.ts
index 0fa4e6bc2..1a5f98b3c 100644
--- a/ts/packages/cli/src/bin.ts
+++ b/ts/packages/cli/src/bin.ts
@@ -2,6 +2,7 @@ import process from 'node:process';
import { Cause, Effect, Exit, Layer, Logger } from 'effect';
import { prettyPrint } from 'effect-errors';
import { CliConfig } from '@effect/cli';
+import { FetchHttpClient } from '@effect/platform';
import { BunContext, BunRuntime, BunFileSystem } from '@effect/platform-bun';
import type { Teardown } from '@effect/platform/Runtime';
import { runWithConfig } from 'src/commands';
@@ -14,9 +15,10 @@ import {
} from 'src/services/composio-clients';
import { NodeOs } from 'src/services/node-os';
import { NodeProcess } from 'src/services/node-process';
-import { EnvLangDetector } from './services/env-lang-detector';
-import { JsPackageManagerDetector } from './services/js-package-manager-detector';
-import { ComposioUserContextLive as _ComposioUserContextLive } from './services/user-context';
+import { EnvLangDetector } from 'src/services/env-lang-detector';
+import { JsPackageManagerDetector } from 'src/services/js-package-manager-detector';
+import { ComposioUserContextLive as _ComposioUserContextLive } from 'src/services/user-context';
+import { UpgradeBinary } from 'src/services/upgrade-binary';
/**
* Concrete Effect layer compositions for the Composio CLI runtime.
@@ -51,9 +53,16 @@ export const ComposioToolkitsRepositoryLive = Layer.provide(
Layer.mergeAll(BunFileSystem.layer, NodeOs.Default, ConfigLive)
) satisfies RequiredLayer;
+export const UpgradeBinaryLive = Layer.provide(
+ UpgradeBinary.Default,
+ Layer.mergeAll(BunFileSystem.layer, FetchHttpClient.layer)
+) satisfies RequiredLayer;
+
const layers = Layer.mergeAll(
CliConfigLive.pipe(Layer.provide(ConfigLive)),
+ NodeOs.Default,
NodeProcess.Default,
+ UpgradeBinaryLive,
ComposioUserContextLive,
ComposioSessionRepositoryLive,
ComposioToolkitsRepositoryLive,
@@ -70,31 +79,31 @@ export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: n
onExit(shouldFail ? errorCode : 0);
};
+const runWithArgs = Effect.flatMap(runWithConfig, run => run(process.argv)) satisfies Effect.Effect<
+ void,
+ unknown,
+ unknown
+>;
+
/**
* CLI entrypoint, which:
* - runs the Effect runtime and sets up its runtime environment
* - collects and displays errors
*/
-if (require.main === module) {
- const runWithArgs = Effect.flatMap(runWithConfig, run =>
- run(process.argv)
- ) satisfies Effect.Effect<void, unknown, unknown>;
-
- runWithArgs.pipe(
- Effect.provide(layers),
- Effect.withConfigProvider(extendConfigProvider(BaseConfigProviderLive)),
- Effect.provide(BunContext.layer),
- Effect.scoped,
- Effect.withSpan('composio-cli', {
- attributes: {
- name: constants.APP_NAME,
- filename: 'src/bin.ts',
- },
- }),
- Effect.sandbox,
- Effect.catchAll(e => Effect.fail(prettyPrint(e))),
- BunRuntime.runMain({
- teardown,
- })
- );
-}
+runWithArgs.pipe(
+ Effect.provide(layers),
+ Effect.withConfigProvider(extendConfigProvider(BaseConfigProviderLive)),
+ Effect.provide(BunContext.layer),
+ Effect.scoped,
+ Effect.withSpan('composio-cli', {
+ attributes: {
+ name: constants.APP_NAME,
+ filename: 'src/bin.ts',
+ },
+ }),
+ Effect.sandbox,
+ Effect.catchAll(e => Effect.fail(prettyPrint(e))),
+ BunRuntime.runMain({
+ teardown,
+ })
+);
diff --git a/ts/packages/cli/src/commands/index.ts b/ts/packages/cli/src/commands/index.ts
index 23753d95f..d5a1b73be 100644
--- a/ts/packages/cli/src/commands/index.ts
+++ b/ts/packages/cli/src/commands/index.ts
@@ -4,6 +4,7 @@ import * as constants from 'src/constants';
import { $defaultCmd } from './$default.cmd';
import { getVersion } from 'src/effects/version';
import { versionCmd } from './version.cmd';
+import { upgradeCmd } from './upgrade.cmd';
import { whoamiCmd } from './whoami.cmd';
import { loginCmd } from './login.cmd';
import { logoutCmd } from './logout.cmd';
@@ -12,7 +13,16 @@ import { tsCmd } from './ts/ts.cmd';
import { generateCmd } from './generate.cmd';
const $cmd = $defaultCmd.pipe(
- Command.withSubcommands([versionCmd, whoamiCmd, loginCmd, logoutCmd, generateCmd, pyCmd, tsCmd])
+ Command.withSubcommands([
+ versionCmd,
+ upgradeCmd,
+ whoamiCmd,
+ loginCmd,
+ logoutCmd,
+ generateCmd,
+ pyCmd,
+ tsCmd,
+ ])
);
export const runWithConfig = Effect.gen(function* () {
diff --git a/ts/packages/cli/src/commands/upgrade.cmd.ts b/ts/packages/cli/src/commands/upgrade.cmd.ts
new file mode 100644
index 000000000..f8e7c1087
--- /dev/null
+++ b/ts/packages/cli/src/commands/upgrade.cmd.ts
@@ -0,0 +1,18 @@
+import { Command } from '@effect/cli';
+import { Effect } from 'effect';
+import { UpgradeBinary } from 'src/services/upgrade-binary';
+
+/**
+ * CLI command to upgrade the CLI to the latest available version.
+ *
+ * @example
+ * ```bash
+ * composio upgrade
+ * ```
+ */
+export const upgradeCmd = Command.make('upgrade', {}, () =>
+ Effect.gen(function* () {
+ const upgradeBinary = yield* UpgradeBinary;
+ yield* upgradeBinary.upgrade();
+ })
+).pipe(Command.withDescription('Upgrade your Composio CLI to the latest available version.'));
diff --git a/ts/packages/cli/src/effects/compare-semver.ts b/ts/packages/cli/src/effects/compare-semver.ts
new file mode 100644
index 000000000..89fc8b656
--- /dev/null
+++ b/ts/packages/cli/src/effects/compare-semver.ts
@@ -0,0 +1,40 @@
+import { Data, Effect } from 'effect';
+import semver from 'semver';
+
+export class CompareSemverError extends Data.TaggedError('services/CompareSemverError')<{
+ readonly cause: Error;
+ readonly message: string;
+}> {}
+
+/**
+ * Compare semantic versions. Returns the same -1, 0, 1 number expected by Array.sort's comparator function.
+ */
+export const semverComparator = (
+ version1: string,
+ version2: string
+): Effect.Effect<number, CompareSemverError, never> =>
+ Effect.gen(function* () {
+ // Remove 'v' or `cli@` prefix if present
+ const v1 = version1.replace(/^(v|cli@)/, '');
+ const v2 = version2.replace(/^(v|cli@)/, '');
+
+ /**
+ * Comparison result of `semver.compare(clean1, clean2)`.
+ *
+ * The return value is one of:
+ * - `-1` if `clean1` is less than `clean2`
+ * - `0` if `clean1` is equal to `clean2`
+ * - `1` if `clean1` is greater than `clean2`
+ */
+ const comparison = yield* Effect.try({
+ try: () => semver.compare(v1, v2),
+ catch: error =>
+ new CompareSemverError({
+ cause: error as Error,
+ message: `Failed to compare versions: ${version1} vs ${version2}`,
+ }),
+ });
+ yield* Effect.logDebug(`Comparing versions: ${version1} vs ${version2} -> ${comparison}`);
+
+ return comparison;
+ });
diff --git a/ts/packages/cli/src/effects/detect-platform.ts b/ts/packages/cli/src/effects/detect-platform.ts
new file mode 100644
index 000000000..fb3eb2d35
--- /dev/null
+++ b/ts/packages/cli/src/effects/detect-platform.ts
@@ -0,0 +1,44 @@
+import { Effect, Match, Data } from 'effect';
+import { NodeOs } from '../services/node-os';
+
+/**
+ * Platform and architecture detection types
+ */
+export type PlatformArch = {
+ platform: 'darwin' | 'linux';
+ arch: 'x64' | 'aarch64';
+};
+
+export class UnsupportedPlatformError extends Data.TaggedError('UnsupportedPlatformError')<{
+ readonly platform: string;
+ readonly arch: string;
+}> {}
+
+/**
+ * Detect current platform and architecture
+ */
+export const detectPlatform: Effect.Effect<PlatformArch, UnsupportedPlatformError, NodeOs> =
+ Effect.gen(function* () {
+ const nodeOs = yield* NodeOs;
+ const rawPlatform = nodeOs.platform;
+ const rawArch = nodeOs.arch;
+
+ const platform: NodeJS.Platform = yield* Match.value(rawPlatform).pipe(
+ Match.when('darwin', () => Effect.succeed('darwin' as const)),
+ Match.when('linux', () => Effect.succeed('linux' as const)),
+ Match.orElse(() =>
+ Effect.fail(new UnsupportedPlatformError({ platform: rawPlatform, arch: rawArch }))
+ )
+ );
+
+ const arch = yield* Match.value(rawArch).pipe(
+ Match.when('x64', () => Effect.succeed('x64' as const)),
+ Match.when('arm64', () => Effect.succeed('aarch64' as const)),
+ Match.when('aarch64', () => Effect.succeed('aarch64' as const)),
+ Match.orElse(() =>
+ Effect.fail(new UnsupportedPlatformError({ platform: rawPlatform, arch: rawArch }))
+ )
+ );
+
+ return { platform, arch };
+ });
diff --git a/ts/packages/cli/src/effects/github-config.ts b/ts/packages/cli/src/effects/github-config.ts
new file mode 100644
index 000000000..73b343d7c
--- /dev/null
+++ b/ts/packages/cli/src/effects/github-config.ts
@@ -0,0 +1,31 @@
+import { Config, Option } from 'effect';
+
+type GITHUB_CONFIG = Config.Config.Wrap<{
+ API_BASE_URL: string;
+ OWNER: string;
+ REPO: string;
+ TAG: Option.Option<string>;
+ ACCESS_TOKEN: Option.Option<string>;
+}>;
+
+/**
+ * Describe every Github configuration key used at runtime.
+ */
+export const GITHUB_CONFIG = {
+ // The base URL for the GitHub API
+ API_BASE_URL: Config.string('GITHUB_API_BASE_URL').pipe(
+ Config.withDefault('https://api.github.com')
+ ),
+
+ // The owner of the Composio repository on GitHub
+ OWNER: Config.string('GITHUB_OWNER').pipe(Config.withDefault('ComposioHQ')),
+
+ // The repository name for the Composio CLI
+ REPO: Config.string('GITHUB_REPO').pipe(Config.withDefault('composio')),
+
+ // The tag to use as the latest release
+ TAG: Config.option(Config.string('GITHUB_TAG')),
+
+ // The access token for the GitHub API. Only useful during development to avoid getting rate-limited by Github
+ ACCESS_TOKEN: Config.option(Config.string('GITHUB_ACCESS_TOKEN')),
+} satisfies GITHUB_CONFIG;
diff --git a/ts/packages/cli/src/services/node-os.ts b/ts/packages/cli/src/services/node-os.ts
index 137667b50..ebd08cd62 100644
--- a/ts/packages/cli/src/services/node-os.ts
+++ b/ts/packages/cli/src/services/node-os.ts
@@ -5,6 +5,11 @@ import { Effect } from 'effect';
export class NodeOs extends Effect.Service<NodeOs>()('services/NodeOs', {
sync: () => ({
homedir: os.homedir(),
+ platform: os.platform(),
+ arch: os.arch(),
}),
dependencies: [],
}) {}
+
+export const defaultNodeOs = ({ homedir }: { homedir: string }) =>
+ new NodeOs({ homedir, platform: os.platform(), arch: os.arch() });
diff --git a/ts/packages/cli/src/services/upgrade-binary.ts b/ts/packages/cli/src/services/upgrade-binary.ts
new file mode 100644
index 000000000..7d20bae17
--- /dev/null
+++ b/ts/packages/cli/src/services/upgrade-binary.ts
@@ -0,0 +1,363 @@
+import { Data, Effect, Console, Config, Option } from 'effect';
+import { HttpClient, FileSystem } from '@effect/platform';
+import * as path from 'node:path';
+import { APP_VERSION } from '../constants';
+import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
+import { GITHUB_CONFIG } from 'src/effects/github-config';
+import { detectPlatform, type PlatformArch } from 'src/effects/detect-platform';
+import { CompareSemverError, semverComparator } from 'src/effects/compare-semver';
+
+// Note: `node:zlib` does not support Github's zip files
+import decompress from 'decompress';
+import type { Predicate } from 'effect/Predicate';
+
+export class UpgradeBinaryError extends Data.TaggedError('services/UpgradeBinaryError')<{
+ readonly cause: Error;
+ readonly message: string;
+}> {}
+
+/**
+ * CLI binary name constant
+ */
+export const CLI_BINARY_NAME = 'composio';
+
+type GitHubRelease = {
+ tag_name: string;
+ assets: Array<{
+ name: string;
+ browser_download_url: string;
+ }>;
+};
+
+// Service to manage CLI binary upgrades
+export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/UpgradeBinary', {
+ accessors: true,
+ // eslint-disable-next-line max-lines-per-function
+ effect: Effect.gen(function* () {
+ const httpClient = yield* HttpClient.HttpClient;
+ const fs = yield* FileSystem.FileSystem;
+ const githubConfig = yield* Config.all(GITHUB_CONFIG);
+
+ /**
+ * Fetch latest release from GitHub
+ */
+ const fetchLatestRelease = (): Effect.Effect<GitHubRelease, UpgradeBinaryError, never> =>
+ Effect.gen(function* () {
+ const urlSuffix = yield* githubConfig.TAG.pipe(
+ Option.match({
+ onNone: Effect.fn(function* () {
+ yield* Effect.logDebug('No tag specified, using latest release');
+ return 'latest';
+ }),
+ onSome: Effect.fn(function* (tag) {
+ yield* Effect.logDebug(`Using tag: ${tag}`);
+ return `tags/${tag}`;
+ }),
+ })
+ );
+
+ const url = `${githubConfig.API_BASE_URL}/repos/${githubConfig.OWNER}/${githubConfig.REPO}/releases/${urlSuffix}`;
+ yield* Effect.logDebug(`GET ${url}`);
+
+ const response = yield* Effect.gen(function* () {
+ const resp = yield* httpClient.get(url);
+ if (resp.status < 200 || resp.status >= 300) {
+ return yield* Effect.fail(
+ new UpgradeBinaryError({
+ cause: new Error(`HTTP ${resp.status}`),
+ message: `Failed to fetch ${urlSuffix} release from GitHub`,
+ })
+ );
+ }
+ return resp;
+ }).pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: new Error(String(error)),
+ message: `Failed to fetch ${urlSuffix} release from GitHub`,
+ })
+ )
+ )
+ );
+
+ const release = yield* Effect.gen(function* () {
+ return yield* response.json;
+ }).pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to parse GitHub release JSON response',
+ })
+ )
+ )
+ );
+
+ return release as GitHubRelease;
+ });
+
+ /**
+ * Check if update is available
+ */
+ const isUpdateAvailable = (
+ release: GitHubRelease
+ ): Effect.Effect<boolean, CompareSemverError | UpgradeBinaryError, never> =>
+ Effect.gen(function* () {
+ // Current version is older than latest
+ const isVersionOutdated: Predicate<number> = comparison => comparison < 0;
+ const comparison = yield* semverComparator(APP_VERSION, release.tag_name);
+ return isVersionOutdated(comparison);
+ });
+
+ /**
+ * Download binary for current platform
+ */
+ const downloadBinary = (
+ release: GitHubRelease,
+ platformArch: PlatformArch
+ ): Effect.Effect<{ name: string; data: Uint8Array }, UpgradeBinaryError, never> =>
+ Effect.gen(function* () {
+ yield* Effect.logDebug(
+ `Looking up binary for ${platformArch.platform}-${platformArch.arch}`
+ );
+
+ const binaryName = `${CLI_BINARY_NAME}-${platformArch.platform}-${platformArch.arch}.zip`;
+
+ const asset = release.assets.find(asset => asset.name === binaryName);
+ if (!asset) {
+ return yield* Effect.fail(
+ new UpgradeBinaryError({
+ cause: new Error(`Binary not found: ${binaryName}`),
+ message: `No binary available for ${platformArch.platform}-${platformArch.arch}`,
+ })
+ );
+ }
+
+ yield* Console.log(`Downloading ${asset.name}...`);
+
+ const response = yield* Effect.gen(function* () {
+ const resp = yield* httpClient.get(asset.browser_download_url);
+ if (resp.status < 200 || resp.status >= 300) {
+ return yield* Effect.fail(
+ new UpgradeBinaryError({
+ cause: new Error(`HTTP ${resp.status}`),
+ message: `Failed to download binary: ${asset.name}`,
+ })
+ );
+ }
+ return resp;
+ }).pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: new Error(String(error)),
+ message: `Failed to download binary: ${asset.name}`,
+ })
+ )
+ )
+ );
+
+ const arrayBuffer = yield* Effect.gen(function* () {
+ return yield* response.arrayBuffer;
+ }).pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to read downloaded binary',
+ })
+ )
+ )
+ );
+
+ return {
+ name: binaryName,
+ data: new Uint8Array(arrayBuffer),
+ };
+ });
+
+ /**
+ * Extract binary from zip archive using FileSystem
+ */
+ const extractBinary = (
+ { name, data }: { name: string; data: Uint8Array },
+ tempDir: string
+ ): Effect.Effect<string, UpgradeBinaryError, never> =>
+ Effect.gen(function* () {
+ const zipPath = path.join(tempDir, name);
+ const extractDir = path.join(tempDir, 'extract');
+ const binaryPath = path.join(extractDir, path.parse(name).name, CLI_BINARY_NAME);
+
+ yield* Effect.logDebug(`Download zip to ${extractDir}`);
+
+ // Write zip file
+ yield* fs.writeFile(zipPath, data).pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to write zip file',
+ })
+ )
+ )
+ );
+
+ // Create extract directory
+ yield* fs.makeDirectory(extractDir, { recursive: true }).pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to create extract directory',
+ })
+ )
+ )
+ );
+
+ yield* Effect.tryPromise({
+ try: async () => {
+ await decompress(zipPath, extractDir);
+ },
+ catch: error =>
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to extract zip archive',
+ }),
+ });
+
+ // Check if binary exists
+ const exists = yield* fs
+ .exists(binaryPath)
+ .pipe(Effect.catchAll(() => Effect.succeed(false)));
+
+ if (!exists) {
+ return yield* Effect.fail(
+ new UpgradeBinaryError({
+ cause: new Error(`Binary not found in archive: ${binaryPath}`),
+ message: 'Extracted archive does not contain expected binary',
+ })
+ );
+ }
+
+ // Make executable
+ yield* fs.chmod(binaryPath, 0o755).pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to make binary executable',
+ })
+ )
+ )
+ );
+
+ return binaryPath;
+ });
+
+ /**
+ * Get current executable path
+ */
+ const getCurrentExecutablePath = Effect.fn(function* () {
+ // E.g., ~/.composio/composio
+ const currentPath = process.execPath;
+
+ const runtimesPaths = [Bun.which('bun'), Bun.which('node')] as Array<string | null>;
+
+ if (runtimesPaths.includes(currentPath)) {
+ return yield* Effect.fail(
+ new UpgradeBinaryError({
+ cause: new Error(`Currently using Composio CLI via Bun or Node.js runtime`),
+ message:
+ 'Cannot upgrade runtime binary. Please run the upgrade command from a self-contained Composio CLI binary.',
+ })
+ );
+ }
+
+ return currentPath;
+ });
+
+ /**
+ * Replace current executable binary with the new target one.
+ */
+ const replaceBinary = (
+ sourcePath: string,
+ targetPath: string
+ ): Effect.Effect<void, UpgradeBinaryError> =>
+ Effect.gen(function* () {
+ yield* Effect.logDebug(`Replacing binary: ${sourcePath} -> ${targetPath}`);
+ yield* fs
+ .copy(sourcePath, targetPath, {
+ // Note: without `overwrite: true`, the copy operation will silently bail out
+ overwrite: true,
+ })
+ .pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to replace binary',
+ })
+ )
+ )
+ );
+ });
+
+ /**
+ * Main upgrade function
+ */
+ const upgrade = () =>
+ Effect.gen(function* () {
+ const upgradeTargetOpt = yield* DEBUG_OVERRIDE_CONFIG['UPGRADE_TARGET'];
+ const currentPath = yield* getCurrentExecutablePath();
+ yield* Effect.logDebug(`Current executable path: ${currentPath}`);
+
+ // If local binary path is provided (for testing), use it directly
+ if (Option.isSome(upgradeTargetOpt)) {
+ yield* Console.log(`📦 New local version available (current: ${APP_VERSION})`);
+ yield* replaceBinary(upgradeTargetOpt.value, currentPath);
+ return;
+ }
+
+ yield* Console.log('Checking for updates...');
+
+ const release = yield* fetchLatestRelease();
+ const updateAvailable = yield* isUpdateAvailable(release);
+ if (!updateAvailable) {
+ yield* Console.log('✅ You are already running the latest version!');
+ return;
+ }
+
+ yield* Console.log(
+ `📦 New version available: ${release.tag_name} (current: ${APP_VERSION})`
+ );
+
+ const platformArch = yield* detectPlatform;
+ const { name, data } = yield* downloadBinary(release, platformArch);
+
+ // The temporary directory is automatically cleaned up
+ const tmpDir = yield* fs
+ .makeTempDirectoryScoped({ prefix: `${CLI_BINARY_NAME}-upgrade}` })
+ .pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to create temporary directory',
+ })
+ )
+ )
+ );
+
+ const extractedBinaryPath = yield* extractBinary({ name, data }, tmpDir);
+ yield* replaceBinary(extractedBinaryPath, currentPath);
+
+ yield* Console.log(`🎉 Upgrade completed! Restart your terminal to use the new version.`);
+ });
+
+ return {
+ upgrade,
+ } as const;
+ }),
+ dependencies: [],
+}) {}
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.yaml
index 78e52fdfe..c468b1abb 100644
--- 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.yaml
@@ -5,7 +5,6 @@ settings:
excludeLinksFromLockfile: false
importers:
-
.:
dependencies:
'@composio/core':
@@ -17,12 +16,13 @@ importers:
version: 5.8.3
packages:
-
- resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==}
- engines: {node: '>=14.17'}
+ resolution:
+ {
+ integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==,
+ }
+ engines: { node: '>=14.17' }
hasBin: true
snapshots:
-
diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.ts
index cb3c01995..4b91a02bf 100644
--- a/ts/packages/cli/test/__utils__/services/test-layer.ts
+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts
@@ -1,7 +1,7 @@
import path from 'node:path';
import * as tempy from 'tempy';
-import { CliApp } from '@effect/cli';
-import { FileSystem } from '@effect/platform';
+import { CliApp, CliConfig } from '@effect/cli';
+import { FetchHttpClient, FileSystem } from '@effect/platform';
import { BunFileSystem, BunContext, BunPath } from '@effect/platform-bun';
import {
ConfigProvider,
@@ -13,7 +13,7 @@ import {
LogLevel,
Schedule,
} from 'effect';
-import { CliConfigLive } from 'src/bin';
+import { ComposioCliConfig } from 'src/cli-config';
import * as MockConsole from './mock-console';
import * as MockTerminal from './mock-terminal';
import type { Toolkits } from 'src/models/toolkits';
@@ -27,6 +27,7 @@ import { JsPackageManagerDetector } from 'src/services/js-package-manager-detect
import type { Tools } from 'src/models/tools';
import type { TriggerTypes } from 'src/models/trigger-types';
import { ComposioUserContextLive } from 'src/services/user-context';
+import { UpgradeBinary } from 'src/services/upgrade-binary';
import { NodeOs } from 'src/services/node-os';
interface TestLiveInput {
@@ -99,6 +100,8 @@ export const TestLayer = (input?: TestLiveInput) =>
NodeOs,
new NodeOs({
homedir: cwd,
+ arch: 'arm64',
+ platform: 'darwin',
})
);
@@ -117,12 +120,20 @@ export const TestLayer = (input?: TestLiveInput) =>
Layer.merge(BunFileSystem.layer, NodeOsTest)
);
+ const UpgradeBinaryTest = Layer.provide(
+ UpgradeBinary.Default,
+ Layer.mergeAll(BunFileSystem.layer, FetchHttpClient.layer)
+ );
+
+ const CliConfigLive = CliConfig.layer(ComposioCliConfig);
+
const _console = yield* MockConsole.effect;
const layers = Layer.mergeAll(
Console.setConsole(_console),
CliConfigLive,
NodeProcessTest,
+ UpgradeBinaryTest,
ComposioUserContextTest,
ComposioSessionRepositoryTest,
ComposioToolkitsRepositoryTest,
diff --git a/ts/packages/cli/test/src/commands/$default.cmd.test.ts b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
index 4d7a78966..c87225e1c 100644
--- a/ts/packages/cli/test/src/commands/$default.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/$default.cmd.test.ts
@@ -60,6 +60,8 @@ describe('CLI: composio', () => {
- version Display your account information.
+ - upgrade Upgrade your Composio CLI to the latest available version.
+
- whoami Display your account information.
- login [--no-browser] Log in to the Composio SDK.
diff --git a/ts/packages/cli/test/src/effects/compare-semver.test.ts b/ts/packages/cli/test/src/effects/compare-semver.test.ts
new file mode 100644
index 000000000..eefc41dfb
--- /dev/null
+++ b/ts/packages/cli/test/src/effects/compare-semver.test.ts
@@ -0,0 +1,368 @@
+import { describe, expect, it } from '@effect/vitest';
+import { Effect } from 'effect';
+import { CompareSemverError, semverComparator } from 'src/effects/compare-semver';
+
+describe('compare-semver.ts', () => {
+ describe('semverComparator', () => {
+ describe('Basic Comparisons', () => {
+ it.effect('should return -1 when first version is older', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0', '2.0.0');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should return 1 when first version is newer', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('2.0.0', '1.0.0');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should return 0 when versions are equal', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0', '1.0.0');
+ expect(result).toBe(0);
+ })
+ );
+ });
+
+ describe('Version Prefix Handling', () => {
+ it.effect('should handle v prefix on first version', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('v1.0.0', '2.0.0');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should handle v prefix on second version', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0', 'v2.0.0');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should handle v prefix on both versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('v1.0.0', 'v2.0.0');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should handle mixed v prefix scenarios', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('v2.0.0', '1.0.0');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should handle equal versions with and without v prefix', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('v1.0.0', '1.0.0');
+ expect(result).toBe(0);
+ })
+ );
+ });
+
+ describe('Cli Prefix Handling', () => {
+ it.effect('should handle cli@ prefix on first version', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('[email protected]', '2.0.0');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should handle cli@ prefix on second version', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0', '[email protected]');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should handle cli@ prefix on both versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('[email protected]', '[email protected]');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should handle mixed cli@ prefix scenarios', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('[email protected]', '1.0.0');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should handle equal versions with and without cli@ prefix', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('[email protected]', '1.0.0');
+ expect(result).toBe(0);
+ })
+ );
+ });
+
+ describe('Semantic Version Components', () => {
+ it.effect('should compare major versions correctly', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('2.0.0', '1.9.9');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should compare minor versions correctly', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.2.0', '1.1.9');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should compare patch versions correctly', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.2', '1.0.1');
+ expect(result).toBe(1);
+ })
+ );
+ });
+
+ describe('Pre-release Versions', () => {
+ it.effect('should handle alpha versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0-alpha.1', '1.0.0-alpha.2');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should handle beta versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0-beta.2', '1.0.0-beta.1');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should handle rc versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0-rc.1', '1.0.0-rc.1');
+ expect(result).toBe(0);
+ })
+ );
+
+ it.effect('should prioritize release over pre-release', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0', '1.0.0-alpha.1');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should compare pre-release identifiers', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0-alpha', '1.0.0-beta');
+ expect(result).toBe(-1);
+ })
+ );
+ });
+
+ describe('Build Metadata', () => {
+ it.effect('should ignore build metadata in comparison', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0+build.1', '1.0.0+build.2');
+ expect(result).toBe(0);
+ })
+ );
+
+ it.effect('should compare versions with build metadata correctly', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.1+build.1', '1.0.0+build.2');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should handle pre-release with build metadata', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.0.0-alpha.1+build.1', '1.0.0-alpha.2+build.2');
+ expect(result).toBe(-1);
+ })
+ );
+ });
+
+ describe('Complex Version Scenarios', () => {
+ it.effect('should handle multi-digit versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('10.15.20', '9.99.99');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should accept zero-padded components', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(semverComparator('1.01.0', '1.1.0'));
+ expect(result).toBeInstanceOf(CompareSemverError);
+ expect((result as CompareSemverError).message).toContain('Failed to compare versions');
+ })
+ );
+
+ it.effect('should handle long pre-release identifiers', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator(
+ '1.0.0-alpha.very.long.identifier',
+ '1.0.0-alpha.very.long.identifier.2'
+ );
+ expect(result).toBe(-1);
+ })
+ );
+ });
+
+ describe('Edge Cases', () => {
+ it.effect('should handle identical versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.2.3', '1.2.3');
+ expect(result).toBe(0);
+ })
+ );
+
+ it.effect('should reject versions with leading zeros', () =>
+ Effect.gen(function* () {
+ // The semver library considers leading zeros as invalid
+ const result = yield* Effect.flip(semverComparator('01.02.03', '1.2.3'));
+ expect(result).toBeInstanceOf(CompareSemverError);
+ expect(result.message).toContain('Failed to compare versions: 01.02.03 vs 1.2.3');
+ expect(result.cause.message).toContain('Invalid Version: 01.02.03');
+ })
+ );
+
+ it.effect('should handle minimal versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('0.0.1', '0.0.0');
+ expect(result).toBe(1);
+ })
+ );
+
+ it.effect('should handle large version numbers', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('999.999.999', '1000.0.0');
+ expect(result).toBe(-1);
+ })
+ );
+ });
+
+ describe('Real-world Version Examples', () => {
+ it.effect('should compare Node.js-style versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('v18.16.0', 'v20.0.0');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should compare npm package versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('3.2.1', '3.10.0');
+ expect(result).toBe(-1);
+ })
+ );
+
+ it.effect('should compare development versions', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('2.0.0-dev.20240101', '2.0.0-dev.20240102');
+ expect(result).toBe(-1);
+ })
+ );
+ });
+
+ describe('Array.sort Compatibility', () => {
+ it.effect('should work as Array.sort comparator for ascending order', () =>
+ Effect.gen(function* () {
+ const versions = ['2.0.0', '1.0.0', '3.0.0'];
+ const comparisons: Array<{ versions: [string, string]; result: number }> = [];
+
+ // Simulate Array.sort behavior
+ for (let i = 0; i < versions.length - 1; i++) {
+ for (let j = i + 1; j < versions.length; j++) {
+ const result = yield* semverComparator(versions[i], versions[j]);
+ comparisons.push({ versions: [versions[i], versions[j]], result });
+ }
+ }
+
+ // Verify that the comparator would sort correctly
+ const expectedOrder = ['1.0.0', '2.0.0', '3.0.0'];
+ const actualResult = [...versions].sort((a, b) => {
+ // Find the comparison result from our Effect calls
+ const comparison = comparisons.find(
+ c =>
+ (c.versions[0] === a && c.versions[1] === b) ||
+ (c.versions[0] === b && c.versions[1] === a)
+ );
+ if (!comparison) return 0;
+ return comparison.versions[0] === a ? comparison.result : -comparison.result;
+ });
+
+ // Since we can't actually use the Effect in Array.sort, just verify
+ // the comparison results are consistent with sort expectations
+ expect(comparisons.length).toBe(3); // 3 comparisons for 3 elements
+ })
+ );
+ });
+
+ describe('Consistent Comparison Results', () => {
+ it.effect('should be reflexive (a == a)', () =>
+ Effect.gen(function* () {
+ const result = yield* semverComparator('1.5.0', '1.5.0');
+ expect(result).toBe(0);
+ })
+ );
+
+ it.effect('should be antisymmetric (if a > b then b < a)', () =>
+ Effect.gen(function* () {
+ const result1 = yield* semverComparator('2.0.0', '1.0.0');
+ const result2 = yield* semverComparator('1.0.0', '2.0.0');
+
+ expect(result1).toBe(1);
+ expect(result2).toBe(-1);
+ expect(result1).toBe(-result2);
+ })
+ );
+
+ it.effect('should be transitive (if a > b and b > c then a > c)', () =>
+ Effect.gen(function* () {
+ const result1 = yield* semverComparator('3.0.0', '2.0.0'); // Should be 1
+ const result2 = yield* semverComparator('2.0.0', '1.0.0'); // Should be 1
+ const result3 = yield* semverComparator('3.0.0', '1.0.0'); // Should be 1
+
+ expect(result1).toBe(1);
+ expect(result2).toBe(1);
+ expect(result3).toBe(1);
+ })
+ );
+ });
+
+ describe('Invalid Version Handling', () => {
+ // Note: These tests check how semver.compare handles invalid versions
+ // The behavior depends on the semver library implementation
+
+ it.effect('should reject empty strings', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(semverComparator('', '1.0.0'));
+ expect(result).toBeInstanceOf(CompareSemverError);
+ expect(result.message).toContain('Failed to compare versions');
+ expect(result.cause.message).toContain('Invalid Version');
+ })
+ );
+
+ it.effect('should reject invalid version formats', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(semverComparator('not.a.version', '1.0.0'));
+ expect(result).toBeInstanceOf(CompareSemverError);
+ expect(result.message).toContain('Failed to compare versions: not.a.version vs 1.0.0');
+ expect(result.cause.message).toContain('Invalid Version: not.a.version');
+ })
+ );
+
+ it.effect('should reject null-like strings', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(semverComparator('null', 'undefined'));
+ expect(result).toBeInstanceOf(CompareSemverError);
+ expect(result.message).toContain('Failed to compare versions: null vs undefined');
+ expect(result.cause.message).toContain('Invalid Version: null');
+ })
+ );
+ });
+ });
+});
diff --git a/ts/packages/cli/test/src/effects/detect-platform.test.ts b/ts/packages/cli/test/src/effects/detect-platform.test.ts
new file mode 100644
index 000000000..ed73bb8a7
--- /dev/null
+++ b/ts/packages/cli/test/src/effects/detect-platform.test.ts
@@ -0,0 +1,381 @@
+import { describe, expect, it } from '@effect/vitest';
+import { Effect, Layer } from 'effect';
+import {
+ detectPlatform,
+ UnsupportedPlatformError,
+ type PlatformArch,
+} from 'src/effects/detect-platform';
+import { NodeOs } from 'src/services/node-os';
+
+/**
+ * Mock NodeOs service with custom platform and architecture
+ */
+const createMockNodeOs = <P extends NodeJS.Platform>(platform: P, arch: string) =>
+ Layer.succeed(
+ NodeOs,
+ NodeOs.make({
+ homedir: '/mock/home',
+ platform: platform as NodeJS.Platform,
+ arch,
+ })
+ );
+
+describe('detect-platform.ts', () => {
+ describe('detectPlatform', () => {
+ describe('Supported Combinations', () => {
+ it.effect('should detect darwin + x64', () =>
+ Effect.gen(function* () {
+ const result = yield* detectPlatform;
+
+ expect(result).toEqual<PlatformArch>({
+ platform: 'darwin',
+ arch: 'x64',
+ });
+ }).pipe(Effect.provide(createMockNodeOs('darwin', 'x64')))
+ );
+
+ it.effect('should detect darwin + arm64 (mapped to aarch64)', () =>
+ Effect.gen(function* () {
+ const result = yield* detectPlatform;
+
+ expect(result).toEqual<PlatformArch>({
+ platform: 'darwin',
+ arch: 'aarch64',
+ });
+ }).pipe(Effect.provide(createMockNodeOs('darwin', 'arm64')))
+ );
+
+ it.effect('should detect darwin + aarch64', () =>
+ Effect.gen(function* () {
+ const result = yield* detectPlatform;
+
+ expect(result).toEqual<PlatformArch>({
+ platform: 'darwin',
+ arch: 'aarch64',
+ });
+ }).pipe(Effect.provide(createMockNodeOs('darwin', 'aarch64')))
+ );
+
+ it.effect('should detect linux + x64', () =>
+ Effect.gen(function* () {
+ const result = yield* detectPlatform;
+
+ expect(result).toEqual<PlatformArch>({
+ platform: 'linux',
+ arch: 'x64',
+ });
+ }).pipe(Effect.provide(createMockNodeOs('linux', 'x64')))
+ );
+
+ it.effect('should detect linux + arm64 (mapped to aarch64)', () =>
+ Effect.gen(function* () {
+ const result = yield* detectPlatform;
+
+ expect(result).toEqual<PlatformArch>({
+ platform: 'linux',
+ arch: 'aarch64',
+ });
+ }).pipe(Effect.provide(createMockNodeOs('linux', 'arm64')))
+ );
+
+ it.effect('should detect linux + aarch64', () =>
+ Effect.gen(function* () {
+ const result = yield* detectPlatform;
+
+ expect(result).toEqual<PlatformArch>({
+ platform: 'linux',
+ arch: 'aarch64',
+ });
+ }).pipe(Effect.provide(createMockNodeOs('linux', 'aarch64')))
+ );
+ });
+
+ describe('Unsupported Platforms', () => {
+ const unsupportedPlatforms = [
+ 'win32',
+ 'freebsd',
+ 'openbsd',
+ 'sunos',
+ 'aix',
+ 'android',
+ 'cygwin',
+ 'netbsd',
+ ] as const;
+
+ unsupportedPlatforms.forEach(platform => {
+ it.effect(`should fail for unsupported platform: ${platform}`, () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe(platform);
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs(platform, 'x64')))
+ );
+ });
+ });
+
+ describe('Unsupported Architectures', () => {
+ const unsupportedArchitectures = [
+ 'ia32',
+ 'mips',
+ 'mipsel',
+ 'ppc',
+ 'ppc64',
+ 's390',
+ 's390x',
+ 'loong64',
+ 'riscv64',
+ ];
+
+ unsupportedArchitectures.forEach(arch => {
+ it.effect(`should fail for unsupported architecture: ${arch} on darwin`, () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('darwin');
+ expect(result.arch).toBe(arch);
+ }).pipe(Effect.provide(createMockNodeOs('darwin', arch)))
+ );
+
+ it.effect(`should fail for unsupported architecture: ${arch} on linux`, () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('linux');
+ expect(result.arch).toBe(arch);
+ }).pipe(Effect.provide(createMockNodeOs('linux', arch)))
+ );
+ });
+ });
+
+ describe('Double Unsupported (Platform + Architecture)', () => {
+ it.effect('should fail with both unsupported platform and architecture', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('win32');
+ expect(result.arch).toBe('ia32');
+ }).pipe(Effect.provide(createMockNodeOs('win32', 'ia32')))
+ );
+
+ it.effect('should fail with freebsd + mips combination', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('freebsd');
+ expect(result.arch).toBe('mips');
+ }).pipe(Effect.provide(createMockNodeOs('freebsd', 'mips')))
+ );
+ });
+
+ describe('Edge Cases', () => {
+ it.effect('should handle empty platform string', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('');
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs('' as NodeJS.Platform, 'x64')))
+ );
+
+ it.effect('should handle empty architecture string', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('darwin');
+ expect(result.arch).toBe('');
+ }).pipe(Effect.provide(createMockNodeOs('darwin', '')))
+ );
+
+ it.effect('should handle both empty platform and architecture', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('');
+ expect(result.arch).toBe('');
+ }).pipe(Effect.provide(createMockNodeOs('' as NodeJS.Platform, '')))
+ );
+
+ it.effect('should handle null-like values as strings', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('null');
+ expect(result.arch).toBe('undefined');
+ }).pipe(Effect.provide(createMockNodeOs('null' as NodeJS.Platform, 'undefined')))
+ );
+
+ it.effect('should handle very long platform name', () => {
+ const longPlatform = 'a'.repeat(1000);
+ return Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe(longPlatform);
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs(longPlatform as NodeJS.Platform, 'x64')));
+ });
+
+ it.effect('should handle very long architecture name', () => {
+ const longArch = 'z'.repeat(1000);
+ return Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('darwin');
+ expect(result.arch).toBe(longArch);
+ }).pipe(Effect.provide(createMockNodeOs('darwin', longArch)));
+ });
+ });
+
+ describe('Case Sensitivity', () => {
+ it.effect('should not match Darwin (uppercase D)', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('Darwin');
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs('Darwin' as NodeJS.Platform, 'x64')))
+ );
+
+ it.effect('should not match LINUX (uppercase)', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('LINUX');
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs('LINUX' as NodeJS.Platform, 'x64')))
+ );
+
+ it.effect('should not match X64 (uppercase)', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('darwin');
+ expect(result.arch).toBe('X64');
+ }).pipe(Effect.provide(createMockNodeOs('darwin', 'X64')))
+ );
+
+ it.effect('should not match ARM64 (uppercase)', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('linux');
+ expect(result.arch).toBe('ARM64');
+ }).pipe(Effect.provide(createMockNodeOs('linux', 'ARM64')))
+ );
+ });
+
+ describe('Whitespace Handling', () => {
+ it.effect('should not match platform with leading whitespace', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe(' darwin');
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs(' darwin' as NodeJS.Platform, 'x64')))
+ );
+
+ it.effect('should not match platform with trailing whitespace', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('linux ');
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs('linux ' as NodeJS.Platform, 'x64')))
+ );
+
+ it.effect('should not match architecture with leading whitespace', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('darwin');
+ expect(result.arch).toBe(' x64');
+ }).pipe(Effect.provide(createMockNodeOs('darwin', ' x64')))
+ );
+
+ it.effect('should not match architecture with trailing whitespace', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('darwin');
+ expect(result.arch).toBe('arm64 ');
+ }).pipe(Effect.provide(createMockNodeOs('darwin', 'arm64 ')))
+ );
+
+ it.effect('should not match with internal whitespace in platform', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('dar win');
+ expect(result.arch).toBe('x64');
+ }).pipe(Effect.provide(createMockNodeOs('dar win' as NodeJS.Platform, 'x64')))
+ );
+
+ it.effect('should not match with internal whitespace in architecture', () =>
+ Effect.gen(function* () {
+ const result = yield* Effect.flip(detectPlatform);
+
+ expect(result).toBeInstanceOf(UnsupportedPlatformError);
+ expect(result.platform).toBe('darwin');
+ expect(result.arch).toBe('x 64');
+ }).pipe(Effect.provide(createMockNodeOs('darwin', 'x 64')))
+ );
+ });
+ });
+
+ describe('UnsupportedPlatformError', () => {
+ it('should be a proper Error instance', () => {
+ const error = new UnsupportedPlatformError({ platform: 'test', arch: 'test' });
+ expect(error).toBeInstanceOf(Error);
+ expect(error).toBeInstanceOf(UnsupportedPlatformError);
+ expect(error._tag).toBe('UnsupportedPlatformError');
+ });
+
+ it('should contain platform and arch information', () => {
+ const error = new UnsupportedPlatformError({ platform: 'testPlatform', arch: 'testArch' });
+ expect(error.platform).toBe('testPlatform');
+ expect(error.arch).toBe('testArch');
+ });
+
+ it('should maintain properties for empty values', () => {
+ const error = new UnsupportedPlatformError({ platform: '', arch: '' });
+ expect(error.platform).toBe('');
+ expect(error.arch).toBe('');
+ });
+ });
+
+ describe('Type Tests', () => {
+ it('should return correct PlatformArch type for supported combinations', () => {
+ // This test verifies TypeScript types at runtime
+ const testType = async (platform: string, arch: string): Promise<PlatformArch> => {
+ return await Effect.runPromise(
+ detectPlatform.pipe(Effect.provide(createMockNodeOs(platform as NodeJS.Platform, arch)))
+ );
+ };
+
+ // These calls should compile without TypeScript errors
+ expect(testType('darwin', 'x64')).resolves.toEqual({ platform: 'darwin', arch: 'x64' });
+ expect(testType('darwin', 'arm64')).resolves.toEqual({ platform: 'darwin', arch: 'aarch64' });
+ expect(testType('linux', 'aarch64')).resolves.toEqual({ platform: 'linux', arch: 'aarch64' });
+ });
+ });
+});
diff --git a/ts/packages/cli/test/src/services/user-context.test.ts b/ts/packages/cli/test/src/services/user-context.test.ts
index a30f6557c..1f08b034f 100644
--- a/ts/packages/cli/test/src/services/user-context.test.ts
+++ b/ts/packages/cli/test/src/services/user-context.test.ts
@@ -5,7 +5,7 @@ import { BunFileSystem } from '@effect/platform-bun';
import { ConfigProvider, Effect, Layer, Option, Data } from 'effect';
import * as tempy from 'tempy';
import { ComposioUserContext, ComposioUserContextLive } from 'src/services/user-context';
-import { NodeOs } from 'src/services/node-os';
+import { defaultNodeOs, NodeOs } from 'src/services/node-os';
import { UserData, userDataToJSON } from 'src/models/user-data';
import { extendConfigProvider } from 'src/services/config';
import path from 'node:path';
@@ -20,7 +20,7 @@ describe('ComposioUserContext', () => {
const cwd = tempy.temporaryDirectory();
const map = new Map([]) satisfies Map<string, string>;
- const NodeOsTest = Layer.succeed(NodeOs, new NodeOs({ homedir: cwd }));
+ const NodeOsTest = Layer.succeed(NodeOs, defaultNodeOs({ homedir: cwd }));
const ComposioUserContextTest = Layer.provideMerge(
ComposioUserContextLive,
Layer.mergeAll(BunFileSystem.layer, NodeOsTest, withMapConfigProvider(map))
@@ -47,7 +47,7 @@ describe('ComposioUserContext', () => {
['COMPOSIO_BASE_URL', 'https://test.composio.localhost'],
]) satisfies Map<string, string>;
- const NodeOsTest = Layer.succeed(NodeOs, new NodeOs({ homedir: cwd }));
+ const NodeOsTest = Layer.succeed(NodeOs, defaultNodeOs({ homedir: cwd }));
const ComposioUserContextTest = Layer.provideMerge(
ComposioUserContextLive,
Layer.mergeAll(BunFileSystem.layer, NodeOsTest, withMapConfigProvider(map))
@@ -74,7 +74,7 @@ describe('ComposioUserContext', () => {
const cwd = tempy.temporaryDirectory();
const map = new Map([]) satisfies Map<string, string>;
- const NodeOsTest = Layer.succeed(NodeOs, new NodeOs({ homedir: cwd }));
+ const NodeOsTest = Layer.succeed(NodeOs, defaultNodeOs({ homedir: cwd }));
const ComposioUserContextTest = Layer.provideMerge(
ComposioUserContextLive,
Layer.mergeAll(BunFileSystem.layer, NodeOsTest, withMapConfigProvider(map))
@@ -103,7 +103,7 @@ describe('ComposioUserContext', () => {
const cwd = tempy.temporaryDirectory();
const map = new Map([['COMPOSIO_API_KEY', 'api_key']]) satisfies Map<string, string>;
- const NodeOsTest = Layer.succeed(NodeOs, new NodeOs({ homedir: cwd }));
+ const NodeOsTest = Layer.succeed(NodeOs, defaultNodeOs({ homedir: cwd }));
const ComposioUserContextTest = Layer.provideMerge(
ComposioUserContextLive,
Layer.mergeAll(BunFileSystem.layer, NodeOsTest, withMapConfigProvider(map))