ComposioHQ / composio

Composio equip's your AI agents & LLMs with 100+ high-quality integrations via function calling
https://docs.composio.dev
Other
9.63k stars 3.8k forks source link

feat: bump js release to 0.1.6 #360

Closed utkarsh-dixit closed 2 months ago

utkarsh-dixit commented 2 months ago

PR Type

Enhancement, Bug fix


Description


Changes walkthrough πŸ“

Relevant files
Enhancement
workspace.ts
Refactor Docker workspace setup and imports                           

js/src/env/docker/workspace.ts
  • Replaced direct imports with nodeExternalRequire for dynamic
    requiring.
  • Changed Docker.Container type to any.
  • Moved COMPOSIO_PATH and COMPOSIO_CACHE definitions inside the setup
    method.
  • Updated cli-progress usage to use type CliProgress.Bar.
  • +18/-15 
    workspace.ts
    Use dynamic requiring for Sandbox in E2B workspace             

    js/src/env/e2b/workspace.ts
  • Replaced direct import of Sandbox with nodeExternalRequire.
  • Added non-null assertion operator for sandbox usage.
  • +9/-8     
    base.ts
    Simplify Shell class by removing EventEmitter inheritance

    js/src/env/base.ts - Removed `EventEmitter` inheritance from `Shell` class.
    +1/-3     
    shared.ts
    Add utility for dynamic module requiring                                 

    js/src/utils/shared.ts
  • Added nodeExternalRequire function for dynamic requiring of modules.
  • +12/-0   
    package.json
    Bump version to 0.1.6                                                                       

    js/package.json - Updated version from `0.1.6-3` to `0.1.6`.
    +1/-1     
    Configuration changes
    wrangler.toml
    Enable Node.js compatibility in Wrangler configuration     

    js/wrangler.toml - Added `node_compat = true` for Node.js compatibility.
    +1/-0     
    Additional files (token-limit)
    pnpm-lock.yaml
    ...                                                                                                           

    js/examples/ai-playground-main/pnpm-lock.yaml ...
    +524/-1118

    πŸ’‘ PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review: 3 πŸ”΅πŸ”΅πŸ”΅βšͺβšͺ
    πŸ§ͺ No relevant tests
    πŸ”’ No security concerns identified
    ⚑ Key issues to review

    Type Safety
    The `container` property in `DockerWorkspace` class is changed from `Docker.Container` to `any`. This reduces type safety and could lead to runtime errors if the object does not conform to the expected structure. Consider maintaining strict types or providing a more specific interface. Dynamic Requiring
    The use of `nodeExternalRequire` for dynamic module requiring could lead to issues if the module names are not resolved correctly at runtime or if the modules are not present in the environment where the code runs. This approach also makes static analysis and bundling more difficult. Error Handling
    There is no error handling for asynchronous operations within the `setup` method. If any of the `process.start` or other asynchronous calls fail, it could lead to unhandled promise rejections, which can crash the application.
    codiumai-pr-agent-pro[bot] commented 2 months ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Correct the wrangler version format to a standard version string without embedded dependency information ___ **The wrangler dependency version in the devDependencies section is specified with an
    unusual format that includes another dependency version. This might be an error or
    typo. Simplify the version specification to avoid potential parsing errors or
    misconfigurations.** [js/examples/ai-playground-main/pnpm-lock.yaml [24-26]](https://github.com/ComposioHQ/composio/pull/360/files#diff-52d637854db874e21b04c1a0b124cd991857ebf396920dbe5be4e0a5c965afeaR24-R26) ```diff wrangler: specifier: ^3.0.0 - version: 3.63.1(@cloudflare/workers-types@4.20240620.0) + version: 3.63.1 ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 10 Why: The unusual format could cause parsing errors or misconfigurations. Correcting it to a standard version string is crucial for proper dependency management.
    10
    Error handling
    Add error handling for module loading to enhance robustness ___ **Add error handling for the nodeExternalRequire function to prevent runtime errors
    when the required module is not found or fails to load. This will enhance the
    robustness of the application.** [js/src/env/docker/workspace.ts [36]](https://github.com/ComposioHQ/composio/pull/360/files#diff-32ee46b296bb6f8b6057a91d605dddb67bf44959fd07877e17e416e0dae339edR36-R36) ```diff this.docker = nodeExternalRequire("dockerode")(); +if (!this.docker) { + throw new Error("Failed to load 'dockerode' module."); +} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Adding error handling for the `nodeExternalRequire` function is crucial for preventing runtime errors when the required module fails to load. This significantly enhances the robustness of the application.
    9
    Possible issue
    Align the version numbers for @cloudflare/workers-types in both the dependencies and packages sections ___ **It's recommended to use consistent versioning for dependencies to avoid potential
    conflicts and ensure compatibility. The version for @cloudflare/workers-types is
    specified inconsistently in the dependencies and packages sections. Consider
    aligning these versions to the latest one used in the packages section.** [js/examples/ai-playground-main/pnpm-lock.yaml [18-20]](https://github.com/ComposioHQ/composio/pull/360/files#diff-52d637854db874e21b04c1a0b124cd991857ebf396920dbe5be4e0a5c965afeaR18-R20) ```diff '@cloudflare/workers-types': - specifier: ^4.20230419.0 + specifier: ^4.20240620.0 version: 4.20240620.0 '@cloudflare/workers-types@4.20240620.0': resolution: {integrity: sha512-CQD8YS6evRob7LChvIX3gE3zYo0KVgaLDOu1SwNP1BVIS2Sa0b+FC8S1e1hhrNN8/E4chYlVN+FDAgA4KRDUEQ==} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Consistent versioning helps avoid potential conflicts and ensures compatibility. This suggestion addresses a possible issue that could lead to dependency resolution problems.
    9
    Best practice
    Replace dynamic require with static import for better compatibility and maintainability ___ **Replace the dynamic require with a static import for better maintainability and
    compatibility with modern JavaScript module systems. Using dynamic require can lead
    to issues with bundlers and linters, and it's generally advisable to use static
    imports where possible.** [js/src/env/docker/workspace.ts [14]](https://github.com/ComposioHQ/composio/pull/360/files#diff-32ee46b296bb6f8b6057a91d605dddb67bf44959fd07877e17e416e0dae339edR14-R14) ```diff -const server = require("node:net").createServer(); +import { createServer } from "node:net"; +const server = createServer(); ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Replacing dynamic `require` with static `import` improves maintainability and compatibility with modern JavaScript module systems. This change is beneficial for bundlers and linters, making the code more robust.
    8
    Use specific types instead of any to improve type safety and clarity ___ **Use a more specific type than any for container to improve type safety and code
    clarity. Defining a specific type helps with IntelliSense in IDEs and reduces the
    risk of runtime errors.** [js/src/env/docker/workspace.ts [26]](https://github.com/ComposioHQ/composio/pull/360/files#diff-32ee46b296bb6f8b6057a91d605dddb67bf44959fd07877e17e416e0dae339edR26-R26) ```diff -public container: any | null = null; +import { Container } from "dockerode"; +public container: Container | null = null; ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: Using a more specific type than `any` for `container` improves type safety and code clarity. This change helps with IntelliSense in IDEs and reduces the risk of runtime errors.
    7
    Enhancement
    Update the Node.js version requirement for @jridgewell/resolve-uri to align with other dependencies ___ **The engines field for @jridgewell/resolve-uri specifies a minimum Node.js version of
    6.0.0, which is significantly lower than other dependencies. Consider updating this
    to a more recent version to ensure compatibility and security.** [js/examples/ai-playground-main/pnpm-lock.yaml [217-219]](https://github.com/ComposioHQ/composio/pull/360/files#diff-52d637854db874e21b04c1a0b124cd991857ebf396920dbe5be4e0a5c965afeaR217-R219) ```diff '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} - engines: {node: '>=6.0.0'} + engines: {node: '>=12'} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Aligning the Node.js version requirement with other dependencies enhances compatibility and security, making it a valuable enhancement.
    8
    Maintainability
    Use a variable for the private port number to enhance flexibility and maintainability ___ **Instead of using a hardcoded port number, use a variable to store the private port
    number. This makes the code more flexible and easier to maintain, especially if the
    port number changes in the future.** [js/src/env/docker/workspace.ts [93]](https://github.com/ComposioHQ/composio/pull/360/files#diff-32ee46b296bb6f8b6057a91d605dddb67bf44959fd07877e17e416e0dae339edR93-R93) ```diff -this.port = existingContainer.Ports.find((port: any) => port.PrivatePort === 8000)?.PublicPort!; +const PRIVATE_PORT = 8000; +this.port = existingContainer.Ports.find((port: any) => port.PrivatePort === PRIVATE_PORT)?.PublicPort!; ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: Using a variable for the private port number instead of a hardcoded value makes the code more flexible and easier to maintain, especially if the port number changes in the future.
    6
    Review and adjust the Node.js version requirements for better compatibility across different environments ___ **The engines field for many dependencies specifies a minimum Node.js version of 12,
    which might not be necessary for all packages. Review and possibly lower the
    required Node.js version for packages that do not specifically need Node.js version
    12 or higher, to enhance compatibility with a broader range of environments.** [js/examples/ai-playground-main/pnpm-lock.yaml [81-83]](https://github.com/ComposioHQ/composio/pull/360/files#diff-52d637854db874e21b04c1a0b124cd991857ebf396920dbe5be4e0a5c965afeaR81-R83) ```diff '@esbuild/android-arm64@0.17.19': resolution: {integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==} - engines: {node: '>=12'} + engines: {node: '>=10'} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: While lowering the Node.js version requirement could enhance compatibility, it might not be necessary for all packages and could introduce other issues. This suggestion is more about maintainability and compatibility.
    6
    codiumai-pr-agent-pro[bot] commented 2 months ago

    CI Failure Feedback 🧐

    (Checks updated until commit https://github.com/ComposioHQ/composio/commit/b12d219253293c9aa05fc8a3fa4c67a304f2daba)

    **Action:** test (ubuntu-latest, 3.10)
    **Failed stage:** [Unittests](https://github.com/ComposioHQ/composio/actions/runs/10040594694/job/27747023399) [❌]
    **Failed test name:** test_action_enum
    **Failure summary:** The action failed because the test test_action_enum failed. The test failed due to a ValueError
    being raised in the Action class. Specifically:
  • The value GITHUB_ISSUES_LIST was deemed invalid for the Action enum.
  • The error occurred in the file composio/client/enums/base.py at line 112.
  • Relevant error logs: ```yaml 1: ##[group]Operating System 2: Ubuntu ... 506: * [new branch] fix/readme -> origin/fix/readme 507: * [new branch] fix/readme-logo -> origin/fix/readme-logo 508: * [new branch] fix/swe-agent -> origin/fix/swe-agent 509: * [new branch] ft-add-better-help-text -> origin/ft-add-better-help-text 510: * [new branch] ft-add-js-example -> origin/ft-add-js-example 511: * [new branch] ft-apps-id -> origin/ft-apps-id 512: * [new branch] ft-bring-back-core-sdk -> origin/ft-bring-back-core-sdk 513: * [new branch] ft-did-you-mean -> origin/ft-did-you-mean 514: * [new branch] ft-error-tracking -> origin/ft-error-tracking ... 933: tests/test_cli/test_actions.py::TestListActions::test_list_all[arguments3-exptected_outputs3-unexptected_outputs3] PASSED [ 17%] 934: tests/test_cli/test_actions.py::TestListActions::test_tag_not_found PASSED [ 19%] 935: tests/test_cli/test_actions.py::TestListActions::test_limit SKIPPED [ 21%] 936: tests/test_cli/test_actions.py::TestListActions::test_copy PASSED [ 23%] 937: tests/test_cli/test_add.py::TestComposioAdd::test_no_auth PASSED [ 25%] 938: tests/test_cli/test_apps.py::TestList::test_list PASSED [ 27%] 939: tests/test_cli/test_apps.py::TestUpdate::test_update_not_required PASSED [ 29%] 940: tests/test_cli/test_apps.py::TestUpdate::test_update SKIPPED (Needs 941: investigation, this test fails in CI) [ 31%] ... 949: tests/test_client/test_client.py::test_raise_invalid_api_key PASSED [ 48%] 950: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_trigger_objects_to_comma_separated_string PASSED [ 51%] 951: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_trigger_strings_to_comma_separated_string PASSED [ 53%] 952: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_mix_of_trigger_objects_and_strings PASSED [ 55%] 953: tests/test_client/test_collections.py::test_trigger_subscription PASSED [ 57%] 954: tests/test_client/test_endpoints.py::test_endpoint PASSED [ 59%] 955: tests/test_client/test_enum.py::test_tag_enum PASSED [ 61%] 956: tests/test_client/test_enum.py::test_app_enum PASSED [ 63%] 957: tests/test_client/test_enum.py::test_action_enum FAILED [ 65%] ... 966: tests/test_tools/test_local/test_workspace.py::test_stderr PASSED [ 85%] 967: tests/test_tools/test_local/test_workspace.py::test_workspace PASSED [ 87%] 968: tests/test_utils/test_decorators.py::test_deprecated PASSED [ 89%] 969: tests/test_utils/test_git.py::test_get_git_user_info PASSED [ 91%] 970: tests/test_utils/test_shared.py::test_get_pydantic_signature_format_from_schema_params PASSED [ 93%] 971: tests/test_utils/test_shared.py::test_json_schema_to_pydantic_field PASSED [ 95%] 972: tests/test_utils/test_shared.py::test_json_schema_to_fields_dict PASSED [ 97%] 973: tests/test_utils/test_url.py::test_get_web_url PASSED [100%] 974: =================================== FAILURES =================================== ... 984: self = 985: value = 'GITHUB_ISSUES_LIST' 986: def __init__(self, value: t.Union[str, te.Self]) -> None: 987: """Create an Enum""" 988: if isinstance(value, _AnnotatedEnum): 989: value = value._slug 990: value = t.cast(str, value).upper() 991: if value not in self.__annotations__ and value not in _runtime_actions: 992: > raise ValueError(f"Invalid value `{value}` for `{self.__class__.__name__}`") 993: E ValueError: Invalid value `GITHUB_ISSUES_LIST` for `Action` 994: composio/client/enums/base.py:112: ValueError ... 999: .tox/unittests/lib/python3.10/site-packages/paramiko/pkey.py:100 1000: /home/runner/work/composio/composio/python/.tox/unittests/lib/python3.10/site-packages/paramiko/pkey.py:100: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0. 1001: "cipher": algorithms.TripleDES, 1002: .tox/unittests/lib/python3.10/site-packages/paramiko/transport.py:259 1003: /home/runner/work/composio/composio/python/.tox/unittests/lib/python3.10/site-packages/paramiko/transport.py:259: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0. 1004: "class": algorithms.TripleDES, 1005: .tox/unittests/lib/python3.10/site-packages/pydantic/_internal/_config.py:291 1006: .tox/unittests/lib/python3.10/site-packages/pydantic/_internal/_config.py:291 1007: /home/runner/work/composio/composio/python/.tox/unittests/lib/python3.10/site-packages/pydantic/_internal/_config.py:291: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.8/migration/ ... 1202: examples/Podcast_summarizer_Agents/Tools/composio_slack.py 4 4 0% 1-5 1203: examples/Podcast_summarizer_Agents/__init__.py 0 0 100% 1204: examples/Podcast_summarizer_Agents/main.py 15 15 0% 1-21 1205: -------------------------------------------------------------------------------------------------------------- 1206: TOTAL 9992 2323 77% 1207: Coverage HTML written to dir htmlcov 1208: Coverage XML written to file coverage.xml 1209: =========================== short test summary info ============================ 1210: FAILED tests/test_client/test_enum.py::test_action_enum - ValueError: Invalid value `GITHUB_ISSUES_LIST` for `Action` 1211: ============= 1 failed, 41 passed, 5 skipped, 5 warnings in 34.30s ============= 1212: unittests: exit 1 (36.28 seconds) /home/runner/work/composio/composio/python> pytest -vvv -rfE --doctest-modules composio/ tests/ --cov=composio --cov=examples --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc pid=5754 1213: .pkg: _exit> python /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__ 1214: unittests: FAIL code 1 (79.03=setup[37.31]+cmd[5.44,36.28] seconds) 1215: evaluation failed :( (79.90 seconds) 1216: ##[error]Process completed with exit code 1. ```

    ✨ CI feedback usage guide:
    The CI feedback tool (`/checks)` automatically triggers when a PR has a failed check. The tool analyzes the failed checks and provides several feedbacks: - Failed stage - Failed test name - Failure summary - Relevant error logs In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: ``` /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}" ``` where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check. #### Configuration options - `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true. - `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list. - `enable_help_text` - if set to true, the tool will provide a help message with the feedback. Default is true. - `persistent_comment` - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true. - `final_update_message` - if `persistent_comment` is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true. See more information about the `checks` tool in the [docs](https://pr-agent-docs.codium.ai/tools/ci_feedback/).