Commit Graph

65 Commits

Author SHA1 Message Date
Harry df2073fbb1 Merge remote-tracking branch 'origin/main' into feat/trigger 2025-10-20 14:39:39 +08:00
Maries 569e68ac62 refactor: update model provider to use ModelFactory for instance mana… (#223)
* refactor: update model provider to use ModelFactory for instance management

* refactor: integrate ModelFactory for model instance mapping in tests

* refactor: remove unused imports and clean up test files
2025-10-20 14:27:20 +08:00
Harry 8d32dfb347 refactor: add payload to event handler's on_event function 2025-10-20 12:04:43 +08:00
Harry 9bbbf70423 refactor: update event description type and clean up YAML files
- Changed the type of the event description in EventConfiguration from EventDescription to I18nObject for better internationalization support.
- Updated related test cases to reflect this change.
- Simplified the description fields in various issue and star event YAML files by removing redundant human and llm sections, retaining only the essential translations.

These changes enhance the clarity and maintainability of event configurations and improve support for multiple languages.
2025-10-13 20:48:51 +08:00
Harry e526acc498 refactor: enhance subscription handling in PluginExecutor and related classes
- Added subscription handling to the EventRuntime and TriggerInvokeEventRequest classes, improving the management of event subscriptions.
- Updated the PluginExecutor to include subscription details when invoking events, ensuring better integration with subscription-based workflows.
- Modified test cases to reflect the new subscription structure, enhancing test coverage and reliability.

These changes improve the overall functionality and clarity of the subscription system within the plugin.
2025-10-13 18:12:54 +08:00
Harry 66e3c29c2c chore: bump dify_plugin version to 0.6.0b9 in pyproject.toml
- Updated the version of dify_plugin from 0.6.0b8 to 0.6.0b9 in pyproject.toml.

This change ensures that the project is aligned with the latest version of the plugin.
2025-10-11 21:58:54 +08:00
Harry 8cdd62509d refactor: enhance trigger subscription handling and improve type annotations
- Updated the PluginExecutor and related classes to improve type annotations and clarity, particularly in methods handling OAuth credentials and trigger subscriptions.
- Refactored the PluginRegistration and TriggerFactory classes to streamline the retrieval of trigger providers and event handlers, ensuring better type safety and consistency.
- Adjusted the YAML loader function to specify return types, enhancing code readability and maintainability.

These changes improve the overall structure and usability of the trigger subscription system, making it more robust and easier to understand.
2025-10-11 21:09:12 +08:00
Harry ec9bb73fbe refactor: streamline trigger imports and enhance plugin registration logic
- Simplified import statements across various files by reordering and consolidating imports for better readability.
- Refactored the PluginRegistration class to improve the clarity of the configuration handling logic, ensuring more concise checks for subscription constructors.

These changes enhance code maintainability and readability throughout the plugin structure.
2025-10-10 14:31:49 +08:00
Harry a9b6abf9fc refactor: update trigger and event terminology across the codebase
- Renamed classes and methods related to triggers to use "Event" terminology for consistency and clarity.
- Updated the PluginExecutor, PluginRegistration, and TriggerFactory to reflect the new event handling structure.
- Adjusted YAML configurations and example implementations to align with the new event definitions.
- Enhanced the .gitignore file to include .DS_Store and ensure cleaner project management.

These changes improve the overall coherence of the codebase and enhance the clarity of event-driven functionality.
2025-09-30 20:10:16 +08:00
Harry 46b1ef471a refactor: streamline GitHub issue trigger implementation
- Removed the deprecated IssuesTrigger class and replaced it with a more focused IssueOpenedTrigger class to handle specific events when a new issue is opened.
- Updated the GitHub trigger YAML configuration to reflect changes in the subscription schema and parameters.
- Enhanced the validation logic for issue parameters, including title patterns, labels, assignees, authors, milestones, and body content.
- Improved the overall structure and clarity of the trigger implementation, ensuring better maintainability and functionality.

These changes contribute to a more efficient and organized handling of GitHub issue events, enhancing the plugin's responsiveness to user interactions.
2025-09-29 18:31:39 +08:00
Yeuoly 64244dc603 refactor: enhance test structure for TriggerProvider and TriggerSubscriptionConstructor
- Introduced TriggerProviderImpl and TriggerSubscriptionConstructor implementations in test_construct_trigger_provider.py to facilitate testing.
- Updated session management and request/response handling for improved test clarity and functionality.
- Ensured that the tests validate the behavior of the TriggerProvider and TriggerSubscriptionConstructor interfaces effectively.

These changes contribute to a more robust and maintainable testing framework for trigger functionality.
2025-09-26 23:30:19 +08:00
Yeuoly e8d4949f0b refactor: simplify trigger implementation in tests
- Removed the TriggerRuntime dependency from the test_construct_trigger.py file, streamlining the trigger instantiation process.
- Adjusted imports to reflect the updated structure, enhancing code clarity.

These changes contribute to a cleaner and more maintainable test setup for the trigger functionality.
2025-09-26 23:25:43 +08:00
Yeuoly 420b2b6db1 refactor: improve code readability and organization
- Adjusted import order in request.py for consistency.
- Enhanced the description formatting in trigger.py for better clarity.
- Streamlined exception handling and method signatures in github.py for improved readability.
- Simplified dictionary construction in message_delivered.py to enhance clarity.
- Consolidated return statements in test_trigger_factory.py for better organization.

These changes contribute to a cleaner and more maintainable codebase, improving overall readability and consistency across the project.
2025-09-26 23:23:38 +08:00
Yeuoly 1881a22494 refactor: streamline trigger factory and enhance plugin registration
- Consolidated logic in PluginRegistration for determining subscription constructor classes.
- Simplified method signatures in TriggerFactory for better readability.
- Updated import paths in providers.py to reflect the new module structure.
- Introduced comprehensive tests for the TriggerFactory to ensure robust functionality.

These changes improve code clarity and maintainability while enhancing the overall structure of the trigger management system.
2025-09-26 23:14:03 +08:00
Yeuoly 3254019ec6 Add documentation and tests for trigger factory (#212) 2025-09-26 23:08:29 +08:00
Harry 26b1324c59 Merge remote-tracking branch 'origin/main' into feat/trigger
# Conflicts:
#	python/dify_plugin/core/entities/message.py
#	python/dify_plugin/core/entities/plugin/request.py
#	python/dify_plugin/core/entities/plugin/setup.py
#	python/dify_plugin/core/plugin_registration.py
#	python/dify_plugin/plugin.py
#	python/examples/github/tools/github_repositories.yaml
#	python/pyproject.toml
2025-09-26 14:18:06 +08:00
Harry fe397eaa9f Merge remote-tracking branch 'origin/main' into feat/datasource 2025-09-18 13:06:53 +08:00
Harry b182fd2668 feat(trigger): enhance GitHub trigger event handling and update version
- Refactored `TriggerInvokeResponse` to use `Mapping[str, Any]` for event representation.
- Renamed `properties` to `variables` in the `Event` class for clarity and updated the description accordingly.
- Expanded the event options in the GitHub trigger configuration to allow selection of all events.
- Removed the deprecated `issue_comment` trigger implementation and its associated files.
- Bumped version in `manifest.yaml` to 0.0.9 to reflect these changes.

These updates improve the flexibility and clarity of the GitHub trigger integration, allowing for a broader range of event handling.
2025-09-17 13:46:04 +08:00
immortal-wm 2fc9753673 fix: corrected latency accuracy (#189)
* fix latency calc

* feat: add timing context management to AIModel for latency tracking

- Introduced a new TimingContextRaceConditionError to handle race conditions in multi-threaded environments.
- Implemented a timing_context method in AIModel to track request timing and prevent concurrent usage.
- Updated various model classes (LargeLanguageModel, ModerationModel, RerankModel, Speech2TextModel, TextEmbeddingModel, TTSModel) to utilize the new timing context for latency calculations.
- Added tests to validate timing context behavior under concurrent and sequential usage scenarios.

* feat: implement ModelFactory for dynamic model instance creation

- Added ModelFactory class to generate stateless model instances based on provider configurations and model classes.
- Updated PluginRegistration to utilize ModelFactory for managing model instances, enhancing code organization and maintainability.

* feat: add unit tests for model registry and mock model provider

- Introduced a new test file for validating model registry functionality.
- Implemented mock classes for model provider and LLM to facilitate testing.
- Added tests to ensure correct model instance retrieval from the registry.

* apply ruff

---------

Co-authored-by: Yeuoly <admin@srmxy.cn>
2025-09-16 16:15:20 +08:00
Harry 34cf20564b fix(test): update test case for oauth_get_authorization_url to include redirect URI
- Modified the test for `oauth_get_authorization_url` to pass a redirect URI as the first argument, ensuring proper functionality and coverage.

This change enhances the accuracy of the test case for the TriggerProvider's OAuth implementation.
2025-09-09 00:03:14 +08:00
Harry a285c70f52 refactor: clean up imports and improve code readability
- Removed unused imports in `__init__.py` and `dynamic_options.py`.
- Consolidated import statements in `github.py` and `issue_comment.py` for better organization.
- Standardized string formatting in test cases for consistency.
- Enhanced overall code clarity and maintainability.

These changes contribute to a cleaner codebase and improved readability across the project.
2025-09-08 23:55:31 +08:00
Harry 826a6df1a8 feat(trigger): enhance trigger validation and HTTP handling
- Updated `PluginExecutor` to return a result upon validating provider credentials.
- Renamed `ValidateProviderCredentials` to `ValidateTriggerCredentials` for consistency in trigger actions.
- Improved the `PluginRegistration` class to return OAuth schemas for registered providers.
- Added new error classes for better handling of trigger provider credential validation and OAuth errors.
- Refactored HTTP request and response serialization/deserialization for improved clarity and functionality.
- Enhanced GitHub provider to utilize new error handling and validation mechanisms.

This commit improves the overall structure and error management of the trigger system, ensuring better integration and usability.
2025-09-04 16:52:20 +08:00
Harry 9c431c21a1 test: fix import names after refactoring
- Update TriggerEvent import (was Trigger) in test_construct_trigger.py
- Update http_parser function imports to use new names:
  * serialize_request (was convert_request_to_raw_data)
  * serialize_response (was convert_response_to_raw_data)
  * deserialize_request (was parse_raw_request)
  * deserialize_response (was parse_raw_response)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 14:39:03 +08:00
Harry 1fa18bfd1c refactor(trigger): update trigger error handling and response types
- Renamed `WebhookValidationError` to `TriggerValidationError` for consistency in error handling across trigger operations.
- Updated references to the new `TriggerValidationError` in the GitHub provider and trigger interfaces.
- Enhanced the `TriggerProvider` class to raise the new validation error for webhook signature issues.
- Adjusted the `IssueCommentTrigger` to return the correct event response type.
- Improved type hints and imports in various modules for better clarity and organization.
2025-09-03 14:04:33 +08:00
Harry e9df3cbd4a feat(trigger): enhance trigger execution and response handling
- Introduced new response entities for trigger operations: TriggerInvokeResponse, TriggerDispatchResponse, TriggerSubscriptionResponse, TriggerUnsubscribeResponse, and TriggerRefreshResponse.
- Updated PluginExecutor methods to utilize the new response structures, improving clarity and consistency in trigger handling.
- Enhanced HTTP request parsing and response conversion utilities for better integration with various content types.
- Refactored GitHub provider to align with the updated trigger dispatch and subscription handling mechanisms.
2025-08-30 19:36:24 +08:00
Harry f05cbce8f8 feat(trigger): implement trigger provider functionality and actions 2025-08-26 20:52:57 +08:00
Harry f2a079f835 Merge remote-tracking branch 'origin/main' into feat/trigger
# Conflicts:
#	python/dify_plugin/core/entities/plugin/request.py
#	python/dify_plugin/core/plugin_executor.py
#	python/dify_plugin/entities/__init__.py
#	python/dify_plugin/entities/provider_config.py
#	python/dify_plugin/entities/tool.py
#	python/dify_plugin/interfaces/tool/__init__.py
#	python/dify_plugin/plugin.py
#	python/examples/code_based_workflow/.env
#	python/examples/code_based_workflow/provider/code_based_workflow.yaml
#	python/examples/code_based_workflow/tools/llm.py
#	python/examples/code_based_workflow/tools/llm.yaml
#	python/tests/interfaces/tool/test_costruct_tool.py
2025-08-20 22:00:46 +08:00
Maries c6f83a63e1 feat[0.4.2]: Tool OAuth (#179)
* chore: fix ruff issue

* feat(oauth): implement OAuth

* feat(invoke-message): refactor message handling and introduce InvokeMessage class

* feat(plugin-oauth): add credential_id and credential_type to tool parameters

* feat(plugin-oauth): add credential_id and credential_type to tool parameters

* chore: update dify_plugin version to 0.5.0b4 and clean up github.yaml

* chore: update plugin version to 0.1.2 in manifest.yaml

* feat(session): session context and tool backwards invocation credential support

* feat(oauth): session context and tool backwards invocation credential support

* feat: update README and requirements for OAuth support in version 0.4.2

* feat: add .gitignore to exclude IDE files and secret keys

* chore: apply ruff

* feat: bump version to 0.4.2b1

* feat: update GitHub plugin configuration for OAuth support and improve credential handling

* feat: update .gitignore to exclude dify plugin files and public keys

* feat: fix credential validation for GitHub API and bump version to 0.2.1

* feat: update GitHub plugin to support multiple access tokens and bump version to 0.2.5

* chore: apply ruff

* feat: add ToolProviderOAuthError for improved OAuth error handling in GitHub plugin

* chore: apply ruff

* chore: bump version to 0.4.2

* chore: update examples sdk version to 0.4.2

* fix: thread deadlock in PluginRunner when running tests without gevent monkey patching

* feat: add support for refreshing OAuth credentials in Plugin and GitHub provider

* feat: refactor OAuth credential handling to return structured OAuthCredentials object

* apply ruff

* feat: refactor OAuth credential handling to use ToolOAuthCredentials for improved structure

* feat: reorganize imports in __init__.py for improved clarity and structure

* feat: add Microsoft To Do plugin for refresh token example

* chore: apply ruff

* fix: update author in GitHub configuration and clean up Microsoft To Do schema

* chore: bump version to 0.4.2b2 in pyproject.toml

* feat: update Microsoft To Do plugin to handle OAuth token encoding and version bump

* feat:remove inelegant example

* chore: update dify_plugin version to 0.4.2

* chore: bump version to 0.4.2 in pyproject.toml

---------

Co-authored-by: Yeuoly <admin@srmxy.cn>
2025-07-23 13:49:01 +08:00
Harry 1915391a14 Merge branch 'feat/plugin-oauth' into feat/datasource 2025-07-14 11:01:08 +08:00
Harry 3f1899a1dd feat(session): session context and tool backwards invocation credential support 2025-07-13 01:33:41 +08:00
Harry 0ec96aea2a feat(oauth): implement OAuth 2025-07-07 15:16:56 +08:00
Harry f2e9190d2d feat: add CredentialType enum and integrate into ToolRuntime and update examples 2025-07-04 19:12:09 +08:00
Harry 89137a3694 refactor: rename OnlineDocumentPagesMessage to DatasourceGetPagesResponse and update related methods 2025-07-02 23:18:09 +08:00
Harry e8cc4760cb refactor: update type hints to use union syntax and improve import order 2025-07-02 16:15:28 +08:00
Harry e59d246115 Merge remote-tracking branch 'origin/main' into feat/oauth-datasource
# Conflicts:
#	python/dify_plugin/core/entities/plugin/request.py
#	python/dify_plugin/core/plugin_executor.py
#	python/dify_plugin/entities/__init__.py
#	python/dify_plugin/entities/tool.py
#	python/dify_plugin/interfaces/tool/__init__.py
#	python/dify_plugin/plugin.py
#	python/pyproject.toml
2025-07-02 14:08:12 +08:00
Yeuoly 132d6572ee feat[0.4.0]: add dynamic select support (#163)
* 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
2025-06-27 15:59:22 +08:00
Harry 856dffeda8 feat: update OAuth methods to include redirect_uri parameter 2025-06-26 14:38:28 +08:00
Yeuoly ffc06fa5c0 Merge branch 'feat/dynamic-select' into feat/trigger 2025-06-23 18:07:53 +08:00
Yeuoly 503db4ced5 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.
2025-06-23 18:06:19 +08:00
Yeuoly 0df3d13ec6 fix: linter 2025-06-23 17:53:09 +08:00
Yeuoly 4bc3d18364 feat: add trigger functionality and dynamic select parameter support
- Introduced new `Trigger` and `TriggerProvider` classes for handling trigger operations.
- Added `TriggerResponse`, `TriggerRuntime`, and `TriggerParameter` models to manage trigger data.
- Implemented `DynamicSelectProtocol` for dynamic parameter options.
- Updated `ToolParameterOption` to inherit from `ParameterOption`.
- Enhanced `CommonParameterType` with `DYNAMIC_SELECT` option.
- Added tests for `TriggerProvider` and `Trigger` to ensure proper functionality.
2025-06-23 17:51:21 +08:00
Harry 63a8a5da25 feat: datasource 2025-06-12 18:59:21 +08:00
Harry 4f25923fc6 feat: streaming datasource 2025-06-12 18:29:40 +08:00
Dongyu Li 87609ba7f7 feat: update datasource response message and update version to 0.4.0b5 2025-06-11 17:06:36 +08:00
Yeuoly cc4a611b0c feat: enhance PluginRunner to build plugins from source directories (#150)
* 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
2025-05-27 14:04:26 +08:00
Yeuoly da0b4ddd5d apply ruff 2025-05-23 18:31:24 +08:00
Yeuoly 0b496fb3ff feat: add tests 2025-05-23 18:22:21 +08:00
Yeuoly 8af6e7d5e1 tests 2025-05-19 22:27:51 +08:00
Yeuoly 6d5d601804 feat[0.4.0](oauth): implement OAuth authorization URL and credentials retrieval (#116)
* 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.
2025-05-19 22:13:53 +08:00
Yeuoly 46eb504125 feat[0.3.0]: add plugin runner functionality (#144)
* 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.
2025-05-19 14:56:13 +08:00