* fix: Add response body to CredentialsValidateFailedError exceptions to aid in error diagnosis, especially useful for locally provided models
* fix: linter
---------
Co-authored-by: liull <liulili@thunisoft.com>
Co-authored-by: Yeuoly <admin@srmxy.cn>
* feat: add dynamic select support
- Introduced ParameterOption class for parameter options with value, label, and optional icon.
- Updated ToolParameterOption to inherit from ParameterOption.
- Added DYNAMIC_SELECT to CommonParameterType enum.
- Implemented fetch_parameter_options method in Tool class for fetching parameter options.
- Created DynamicSelectProtocol for dynamic select functionality.
- Added tests for Tool construction and parameter options fetching.
* feat: implement dynamic parameter fetching functionality
- Added DynamicParameterFetchParameterOptionsRequest class for dynamic parameter requests.
- Introduced DynamicParameterActions enum for action types related to dynamic parameters.
- Enhanced PluginExecutor with methods to handle dynamic parameter fetching.
- Updated Tool interface to include a method for fetching parameter options.
- Documented the DynamicSelectProtocol for clarity on its usage.
* feat: enhance plugin functionality with dynamic parameter options and trigger interface
- Added dynamic parameter fetching capabilities to the Plugin class.
- Introduced TriggerProvider and Trigger classes for managing trigger functionalities.
- Updated Tool interface to enforce implementation of credential validation and OAuth methods.
- Enhanced error messages for NotImplementedError in ToolProvider and Trigger classes.
- Removed deprecated tools and their configurations from the codebase.
* docs: update README.md to include support for `dynamic-select` parameter type in manifest versioning
* chore: remove code_based_workflow
* feat: add LLMStructuredOutput and LLMStructuredOutputInvocation for structured output handling
- Introduced LLMStructuredOutput model class for structured output representation.
- Added LLMStructuredOutputInvocation class to handle invocation with structured output.
- Updated ModelInvocations to include LLMStructuredOutputInvocation.
- Modified InvokeType enum to support LLMStructuredOutput type.
* docs: update README.md to include support for LLM structured output in manifest versioning
* docs: update README.md with manifest versioning details and enhance setup.py field descriptions for version compatibility
* docs: enhance README.md with manifest versioning details and update Python SDK README for version constraints
* feat: enhance PluginRunner to build plugins from source directories
- Added functionality to the PluginRunner to detect if the plugin package path is a directory and build the plugin accordingly.
- Introduced a new method `_build_plugin` to handle the building process and log the output.
- Implemented resource cleanup for temporary directories used during the build process.
- Updated integration tests to reflect changes in the mock server configuration by using a constant for the server port.
* fix: linter
- Removed the `provider` field from `DatasourceIdentity` in the manifest.
- Added identity and description fields to `notion.yaml` for better clarity.
- Enhanced `notion.py` with OAuth methods for authorization and credential handling.
- Updated `notion.yaml` to include icon and provider type information.
- Implemented logic to write a datasource declaration message when a datasource configuration is present during plugin initialization.
- Introduced a new message type, `DATASOURCE_DECLARATION`, in the `InitializeMessage` class to support this functionality.
- Added new request models for datasource actions including validation, website crawling, and content retrieval.
- Enhanced `PluginExecutor` with methods to validate datasource credentials, crawl websites, and retrieve pages and content.
- Updated `PluginRegistration` to include methods for fetching datasource provider classes and handling website and online document datasources.
- Refined the `DatasourceProvider` interface to use `Mapping` for credentials, improving type safety.
- Introduced `DatasourceProviderMapping` class to manage datasource provider configurations and mappings.
- Enhanced `PluginRegistration` to include datasource configuration and mapping logic.
- Added new `DatasourceActions` enum for handling datasource-related actions.
- Updated `PluginConfiguration` to include a list of datasource manifest paths, improving plugin extensibility.
- Added validation for the `datasources` field in `DatasourceProviderManifest` to ensure it is a list of strings representing datasource paths.
- Introduced YAML loading for datasource configurations, improving the handling of datasource entities.
- Enhanced documentation annotations for `DatasourceProviderType`, `DatasourceParameter`, and `DatasourceIdentity` classes to clarify their purpose and usage.
- Added `DatasourceEntityExtra` and `DatasourceProviderConfigurationExtra` classes to encapsulate extra information for datasource and provider entities.
- Updated `DatasourceEntity` and `DatasourceProviderManifest` to include new `extra` fields, enhancing the data structure and documentation.
- Introduced documentation annotations for improved clarity on the purpose of new classes and fields.
- Introduced `DatasourceProviderType`, `DatasourceParameter`, and related classes to support new datasource functionalities.
- Added `ParameterOption`, `ParameterAutoGenerate`, and `ParameterTemplate` classes for improved parameter handling.
- Updated existing models to utilize the new parameter classes, enhancing type safety and documentation.
- Introduced `OnlineDocumentDatasource` and `WebsiteCrawlDatasource` abstract classes for handling online document and website crawl functionalities.
- Added corresponding methods for retrieving pages and content, enhancing the datasource capabilities.
- Created new models for online document and website information to support the new interfaces.
* feat(oauth): implement OAuth authorization URL and credentials retrieval
- Added OAuthGetAuthorizationUrlRequest and OAuthGetCredentialsRequest models for handling OAuth requests.
- Introduced methods in PluginExecutor for generating OAuth authorization URLs and retrieving OAuth credentials.
- Updated ToolProvider interface to include OAuth methods for authorization URL and credentials handling.
- Refactored PluginInvokeType and related action enums to support OAuth actions.
* feat: add integration configuration and plugin runner functionality
- Introduced `IntegrationConfig` class for managing plugin testing configurations, including validation for the `dify_cli_path`.
- Added `PluginInvokeRequest` and `PluginGenericResponse` models to handle plugin invocation requests and responses.
- Implemented `PluginRunner` class to facilitate running plugins locally, including asynchronous message handling and process management.
- Merged access actions into a single `PluginAccessAction` for streamlined access control.
* apply ruff
* feat: enhance plugin runner with new response handling and exception management
- Added `PLUGIN_INVOKE_END` response type to manage the end of plugin invocations.
- Introduced `PluginStopped` exception to handle plugin termination gracefully.
- Updated `PluginRunner` to support stopping the plugin process and handling asynchronous message reading with improved error management.
- Modified message queue to accommodate `None` responses for completed invocations.
* refactor: rename PluginStopped exception to PluginStoppedError
- Renamed `PluginStopped` to `PluginStoppedError` for clarity and consistency.
- Updated references in the `run.py` file to reflect the new exception name.
- Added a docstring to `PluginStoppedError` to describe its purpose.
* fix: update version check for dify CLI in IntegrationConfig
- Modified the version check in the IntegrationConfig class to require a minimum version of 0.1.0 instead of 0.4.0.
- Ensured that the version validation logic is clearer and more robust.
* chore: update dependencies and lock file
- Updated the `content_hash` in `pdm.lock` to reflect changes in dependencies.
- Added `packaging>=25.0` to the dependencies in `pyproject.toml` to ensure compatibility with the latest packaging features.
* feat: enhance IntegrationConfig with improved CLI path validation
- Added a list of potential plugin names to search for the dify CLI executable.
- Updated the validation logic to check for the CLI path against multiple plugin names.
- Changed error handling to use ValidationError for invalid CLI path and version checks.
* feat: add setup script for dify-plugin-cli installation
- Introduced a new script to automate the installation of dify-plugin-cli, including OS and architecture detection.
- Updated the pull request workflow to include the setup of the dify-plugin-cli before installing dependencies.
- Refactored error handling in IntegrationConfig to use ValueError instead of ValidationError for CLI path and version checks.
* feat: add integration test for invoking LLM with mocked OpenAI server
- Introduced a new integration test in `test_invoke_llm.py` to validate the invocation of the LLM plugin using a mocked OpenAI server.
- Implemented a mock server to simulate OpenAI's chat completions API, supporting both streaming and non-streaming responses.
- The test downloads the latest `langgenius-openai` plugin, runs the plugin, and asserts the expected response from the LLM.
* fix: add timeout to requests in LLM integration test
- Updated the `test_invoke_llm.py` file to include a timeout of 10 seconds for both POST and GET requests to the marketplace API.
- This change aims to improve the reliability of the integration test by preventing indefinite blocking on network calls.
* feat: enhance dify-plugin-cli setup script with installation verification and PATH configuration
- Added verification to check if dify-plugin is available in the user's PATH after installation.
- Implemented logic to add dify-plugin to the system PATH for all users when run as root, or to the user's profile for non-root users.
- Created symlinks in common bin directories and provided usage instructions for the dify-plugin commands.
* refactor: update dify-plugin-cli setup script for improved PATH management
- Enhanced the script to add the installation directory to the GITHUB_PATH for GitHub Actions.
- Modified the PATH export for local development to ensure the installation directory is prioritized.
- Removed redundant installation verification and symlink creation logic, streamlining the setup process.
* test: add SSH support to pull request workflow
- Integrated SSH functionality into the pull request workflow using the mxschmitt/action-tmate@v3 action.
- This addition allows for interactive debugging and terminal access during pull request checks.
* chore: remove SSH step from pull request workflow and fix import in integration test
- Eliminated the SSH step from the pull request workflow to streamline the process.
- Fixed the import statement for the `requests` library in `test_invoke_llm.py` to ensure proper functionality during the test execution.
* wtf
* feat: implement OpenAI mock server for integration testing
- Added a new mock server in `python/tests/__mock_server` to simulate OpenAI's chat completions API, supporting both streaming and non-streaming responses.
- Updated the pull request workflow to install the `uv` tool and launch the mock server during testing.
- Refactored `test_invoke_llm.py` to utilize the mock server, ensuring reliable integration tests without external dependencies.
* apply ruff
* refactor: streamline mock server launch in pull request workflow
- Replaced inline mock server launch commands in the pull request workflow with a dedicated script `launch_mock_server.sh` for improved readability and maintainability.
- The new script handles the execution of the mock server, ensuring a cleaner workflow configuration.
* fix: update mock server launch path in pull request workflow
- Changed the path for launching the mock server script from `./scripts/launch_mock_server.sh` to `./python/scripts/launch_mock_server.sh` to ensure correct execution within the workflow.
* fix: run mock server in background during pull request workflow
- Updated the pull request workflow to launch the mock server script in the background by appending `&` to the command. This change allows subsequent steps to execute without waiting for the mock server to terminate.
* chore: clean up dify-plugin-cli setup script by removing outdated installation instructions
- Removed outdated comments regarding the download and installation of dify-plugin-cli, streamlining the script for clarity.
* feat: enhance PluginRunner with graceful shutdown and thread safety
- Introduced a stop flag and a lock to ensure thread-safe access to the stop flag in the PluginRunner class.
- Implemented a _close method to handle graceful termination of the plugin process, including sending a SIGTERM signal and closing pipes.
- Refactored the _read_async method to ensure proper cleanup and handling of messages, maintaining the integrity of the message queue.
* support REMOTE_INSTALL_URL
* nit
* nit
* passing remote_install_host and remote_install_port to TCPReaderWriter
* fix the host and port parsing approach without yarl
* extract method for parsing the host and port
* nit
* nit
* nit
* nit
* improve _get_remote_install_host_and_port method
* fix style
* fix style
- Introduced an optional `repo` field in the `PluginConfiguration` class to store the repository URL of the plugin, enhancing the configuration capabilities.
- Added `@final` decorator to the constructors of `AgentStrategy`, `Endpoint`, `AIModel`, and `Tool` classes to prevent overriding.
- Included documentation notes in each constructor to indicate that they should not be overridden.