Remote debugging plugins were not being synchronized across cluster nodes,
causing "no plugin available nodes found" errors when trying to invoke
plugins from different nodes.
1. **Remote debugging plugins not registered to cluster** - The
`ClusterTunnel` notifier was not being added to ControlPanel
2. **Plugin ID inconsistency** - Remote plugins used different plugin_id
formats during installation vs. querying
3. **Non-idempotent registration** - `RegisterPlugin` failed on reconnection
with "plugin has been registered" error
- **internal/types/models/curd/atomic.go**:
- Unify plugin_id calculation for remote plugins (author/name without version)
- Remove plugin_id from plugin query conditions
- Clear old cache when plugin_id is updated
- **internal/cluster/plugin.go**:
- Make `RegisterPlugin` idempotent by updating existing plugin instead
of returning error
- **internal/core/control_panel/daemon.go**:
- Add cluster field to ControlPanel
- Add SetCluster() method for lazy cluster initialization
- **internal/core/control_panel/server_debugger.go**:
- Register remote debugging plugins to cluster on connection
- Unregister from cluster on disconnection
- **internal/core/plugin_manager/manager.go**:
- Add SetCluster() method to set cluster after initialization
- **internal/server/server.go**:
- Call SetCluster() instead of AddClusterTunnel()
Only remote debugging plugins are synchronized across cluster nodes.
Local plugins run only on the node where they are installed and are
not registered to the cluster.
- Error handling improvements using `errors.Is()` instead of `==`
- Handle 404 for missing plugin assets gracefully
- Handle already-installed debugging plugins gracefully
- Remote debugging plugin can be invoked from any node in the cluster
- Plugin reconnection works without errors
- Cache invalidation works correctly when plugin_id changes
* feat(#450): add Redis SSL/TLS configuration support
Add comprehensive SSL/TLS support for Redis connections with configurable certificate verification modes. Introduces new environment variables for SSL configuration including REDIS_USE_SSL, REDIS_SSL_CERT_REQS (supporting CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED), and REDIS_SSL_CA_CERTS for custom CA certificates.
Changes:
- Add Redis SSL configuration options to .env.example
- Implement RedisTLSConfig() method to build tls.Config based on environment settings
- Pass TLS config to both standard Redis and Sentinel mode initializers
- Support custom CA certificate loading and verification modes
- Set minimum TLS version to 1.2 for security
- Minor whitespace cleanup in existing config comments
This enables secure Redis connections in production environments with flexible certificate verification options.
* fix(#450): prevent reference cycle in TLS config and simplify SSL setup
- Capture only RootCAs in VerifyConnection closure to avoid retaining
entire tlsConf and potential reference cycles
- Remove redundant nil checks for tlsConf in Redis client initialization
since tlsConf is guaranteed to be non-nil when useSsl is true
- Update comments to reflect actual behavior and constraints
* fix(#450): improve Redis TLS certificate verification logic for optional certificates
* fix(#450): simplify Redis TLS certificate verification logic for optional and required certificates
* docs(#450): add note for CA certificate file path in Redis SSL configuration
* test(#450): add comprehensive tests for Redis TLS configuration
* fix(#450): enhance Redis SSL configuration documentation and enforce CA cert requirement
* fix(#450): add nil TLS parameter to InitRedisClient calls in tests
Update all InitRedisClient function calls across test files to include the new nil parameter for TLS configuration. This change maintains backward compatibility by explicitly passing nil for TLS settings in non-TLS test scenarios.
* fix(#450): add default TLS configuration for Redis client when no tlsConf is provided
* use slog instead of log package and format to new log schema
* update the environment name to LOG_OUTPUT_FORMAT
* add the env to .env.example
* fix log reference error
* change the order of milldlewares
* delete unused code
* fix the concurrently session potential race condition
* fix the log format in tests
* update the duplicate code
* refactor: convert log functions to slog structured format
- Change log.Error/Info/Warn/Debug/Panic to accept msg + key-value pairs
- Remove printf-style formatting from log functions
- Update log calls in internal/cluster, internal/db, internal/core/session_manager
- Remove unused 'initialized' variable from log package
- Remaining files will be updated in follow-up commits
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor: update all log call sites to use slog structured format
Convert all log.Error, log.Info, log.Warn, log.Debug, and log.Panic
calls from printf-style formatting to slog key-value pairs.
Before: log.Error("failed to do something: %s", err.Error())
After: log.Error("failed to do something", "error", err)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor: update cmd/ log calls to use slog structured format
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat: implement GnetLogger for structured logging in gnet
* refactor: remove deprecated log visibility functions and related calls
* feat: enhance session management with trace and identity context propagation
* feat: implement serverless transaction handler and writer for plugin runtime
* refactor: rename context field to traceCtx in RealBackwardsInvocation
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Yeuoly <admin@srmxy.cn>
* remove enterprise logics
* release lock if runtime already installed
* support setting serverless endpoint by api
* remove global tenant id totally
* scan timeout tasks
* adding comments
* use index in loop
* add log
* feat(plugins): add FetchPluginReadme endpoint and update launch configurations
* feat: add PluginReadme database model
* feat: implement readme extracting and storage
* feat: implement readme endpoint
* feat: add plugin asset extraction endpoint with caching support
* Implement trigger functionality and clean up dynamic select code
- Added new trigger-related access types and actions in access.go.
- Introduced new HTTP routes for trigger operations in http_server.gen.go.
- Updated plugin declaration to include triggers in plugin_entities.
- Removed unused dynamic select service and controller files.
- Enhanced message handling in debugging_runtime to support trigger registration.
This update enhances the plugin system by integrating trigger capabilities while cleaning up legacy code.
* Refactor trigger-related types and enhance dynamic select functionality
- Updated TriggerProviderIdentity and TriggerProviderConfiguration to improve structure and validation.
- Renamed TriggerConfiguration to TriggerDeclaration for clarity.
- Added CredentialType to RequestDynamicParameterSelect for better request handling.
- Enhanced PluginDecoderHelper to read and unmarshal trigger files correctly.
These changes streamline the trigger system and improve the overall request handling in the plugin architecture.
* Add trigger functionality and enhance database integration
- Introduced TriggerInstallation model for managing trigger installations in the database.
- Updated autoMigrate function to include trigger installations in the migration process.
- Added new HTTP routes for listing and retrieving triggers in the HTTP server.
- Implemented ListTriggers and GetTrigger controller functions for handling trigger requests.
- Enhanced plugin management functions to create, update, and delete trigger installations during plugin lifecycle events.
These changes integrate trigger capabilities into the system, improving the overall plugin functionality and management.
* feat: add remapping for trigger icons in MediaBucket
- Enhanced the RemapAssets function to include remapping of trigger identity icons and dark icons.
- Added error handling for remapping failures to ensure robust asset management.
These changes improve the handling of trigger assets within the plugin system, ensuring icons are correctly remapped as needed.
* feat: add Multiple field to TriggerParameter for enhanced configuration
- Introduced a new Multiple field in the TriggerParameter struct to allow for multiple values in trigger configurations.
- This addition improves the flexibility of trigger parameters within the plugin system.
These changes enhance the capability of trigger parameters, enabling more complex configurations.
* feat: add Multiple field to ProviderConfig for enhanced configuration
- Introduced a new Multiple field in the ProviderConfig struct to allow for multiple values in provider configurations.
- This addition improves the flexibility of provider options within the plugin system.
These changes enhance the capability of provider configurations, enabling more complex setups.
* fix(plugin): update validation error messages in ManifestValidate method
- Enhanced error messages in the ManifestValidate function to include 'trigger' in the validation checks for plugin declarations.
- Updated logic to ensure that all relevant fields are considered when validating the presence of mutually exclusive parameters.
* feat(trigger): add CHECKBOX parameter type to plugin entities and refactor the trigger provider strcuture
- Introduced a new CHECKBOX parameter type in constant.go for plugin entities.
- Updated tool_declaration.go and trigger_declaration.go to include TOOL_PARAMETER_TYPE_CHECKBOX and TRIGGER_PARAMETER_TYPE_CHECKBOX respectively.
- Enhanced validation logic to accommodate the new CHECKBOX type in parameter checks.
* fix(trigger): update SubscriptionSchema validation in TriggerProviderDeclaration
- Changed SubscriptionSchema validation from 'omitempty' to 'required' in TriggerProviderDeclaration to ensure it is always provided.
- Updated SubscriptionConstructor field to be a pointer to allow for optional inclusion in the trigger provider configuration.
* fix(trigger): rename ParametersSchema to Parameters in SubscriptionConstructor
- Updated the SubscriptionConstructor struct to rename the ParametersSchema field to Parameters for consistency.
- Adjusted related JSON and YAML marshaling logic to reflect the new field name, ensuring proper handling of trigger parameters.
* refactor(trigger): enhance YAML unmarshalling for SubscriptionConstructor and SubscriptionSchema
- Introduced a new helper function to convert YAML nodes to ProviderConfig lists, improving the handling of subscription_schema and credentials_schema.
- Updated the UnmarshalYAML method to utilize the new function, simplifying the logic for parsing different YAML formats.
- Ensured proper initialization of SubscriptionConstructor fields to prevent nil pointer dereferences.
* fix(trigger): update SubscriptionConstructor validation in TriggerProviderDeclaration
- Changed the validation for SubscriptionConstructor in TriggerProviderDeclaration from 'omitempty,dive' to 'omitempty' to simplify the validation logic.
- Ensured that the SubscriptionConstructor field remains optional while maintaining its intended functionality.
* refactor(trigger): rename Trigger to Event in plugin entities and related structures
- Updated the naming conventions in trigger_declaration.go to replace 'Trigger' with 'Event' for better clarity and consistency.
- Adjusted related types, validation functions, and unmarshalling logic to reflect the new 'Event' terminology.
- Ensured that all references to triggers in the codebase are updated to events, including in the SubscriptionConstructor and response structures.
* refactor(trigger): rename TriggerInvoke to TriggerInvokeEvent and update related structures
- Renamed TriggerInvoke function and associated request/response types to TriggerInvokeEvent for improved clarity.
- Updated routing and controller methods to reflect the new naming convention.
- Ensured all references to the trigger invoke functionality are consistent with the new event terminology.
* refactor(trigger): remove Subscription struct from trigger_declaration.go and update TriggerDispatchEventRequest
- Removed the Subscription struct from trigger_declaration.go to streamline the codebase.
- Added Credentials field to TriggerDispatchEventRequest for enhanced functionality and clarity.
- Ensured that the changes maintain consistency with the existing naming conventions and structures.
* fix(trigger): improve nil checks for SubscriptionConstructor in TriggerProviderDeclaration
- Added nil checks for SubscriptionConstructor before accessing its fields to prevent potential nil pointer dereferences.
- Ensured that Parameters and CredentialsSchema are initialized only if SubscriptionConstructor is not nil, enhancing code robustness.
* fix(plugin): add recovery mechanism in OnTraffic to handle panics
- Introduced a deferred function in OnTraffic to recover from panics, logging the error and stack trace for better debugging.
- This enhancement improves the stability of the DifyServer by preventing crashes due to unexpected runtime errors.
* feat(trigger): add Subscription field to TriggerInvokeEventRequest
- Introduced a new Subscription field in the TriggerInvokeEventRequest struct to accommodate subscription data.
- Ensured the field is marked as required, enhancing the request's functionality and validation requirements.
* refactor(event): simplify EventDescription structure in EventDeclaration
- Removed the EventDescription struct and replaced it with a direct I18nObject field in EventDeclaration.
- This change streamlines the event configuration by reducing complexity while maintaining required validation for the description.
* feat(trigger): add UserID field to TriggerDispatchEventResponse
- Introduced a new UserID field in the TriggerDispatchEventResponse struct to include user identification in the response.
- The field is marked as optional, enhancing the response's flexibility while maintaining existing functionality.
* feat: add payload to TriggerDispatchEventResponse
* fix
* feat(trigger): update TriggerDispatchEventResponse structure
* fix: avoid path collusion
* fix: missing )
* fix: query param
* fix: form param
* fix: remove redundant dynamic parameter access type
* fix: remove dynamic parameter access type from validation
* Update internal/server/controllers/plugins.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
---------
Co-authored-by: Stream <Stream_2@qq.com>
Co-authored-by: Yeuoly <admin@srmxy.cn>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* fix(plugin): support customized stdio buffer size, align serverless runtime with local runtime
* fix(plugin): update config naming to pluginRuntimeBufferSize & pluginRuntimeMaxBufferSize, and keep the compatibility to stdoutBufferSize
* fix: provide a default value for PLUGIN_RUNTIME_BUFFER_SIZE & PLUGIN_RUNTIME_MAX_BUFFER_SIZE
* fix: remove redundant logic
* fix: add compatibility to PLUGIN_STDIO_BUFFER_SIZE & PLUGIN_STDIO_MAX_BUFFER_SIZE
* feat(datasource): Implement datasource validation and invocation steps
- Added new functionality for validating datasource credentials and invoking the first and second steps of the datasource process.
- Introduced new API endpoints for datasource operations in the HTTP server.
- Created corresponding service and controller methods to handle datasource requests.
- Defined new request and response structures for datasource operations in the entities package.
* feat: add routes
* feat(datasource): Add initial datasource models and validation
- Introduced new `DatasourceInstallation` model to represent datasource installations with relevant fields.
- Created `datasource.go` file for future datasource service implementation.
- Enhanced `datasource_declaration.go` with new types and validation functions for datasource provider and parameters.
- Updated `plugin_declaration.go` to include datasource support in plugin structures.
- Refactored `agent_declaration.go` and `tool_declaration.go` to use a unified `ParameterOption` type for options.
* refactor(datasource): Update request and response types for online document content retrieval
- Renamed and updated request and response types for the `DatasourceGetOnlineDocumentPageContent` function to improve clarity and consistency.
- Introduced `RequestInvokeOnlineDocumentDatasourceGetContent` and `DatasourceInvokeOnlineDocumentGetContentResponse` types.
- Adjusted related function signatures and dispatchers to reflect the new types across the datasource service and controller implementations.
* feat(datasource): Implement datasource installation handling
- Added functionality to create and update `DatasourceInstallation` records during plugin installation and upgrade processes.
- Enhanced the `InstallPlugin` function to create a new datasource installation if a datasource declaration is present.
- Updated the `UpgradePlugin` function to handle the deletion of the original datasource installation and creation of a new one if the datasource declaration changes.
* feat(datasource): Add datasource registration handling in plugin runtime
- Introduced handling for datasource declarations in the plugin runtime.
- Updated `RemotePluginRuntime` to track datasource registration status.
- Enhanced message processing to include validation and assignment of datasource declarations.
* feat(datasource): Implement datasource listing and retrieval endpoints
- Added `ListDatasources` and `GetDatasource` functions to the service layer for handling datasource queries.
- Created corresponding controller methods to process HTTP requests for listing and retrieving datasources.
- Implemented request validation for tenant ID, page, page size, plugin ID, and provider parameters.
* add datasource routes
* feat(datasource): Add icon remapping for datasource declarations
- Implemented functionality to remap icons for both the main datasource and its individual datasources within the plugin declaration.
- Enhanced error handling to provide clearer feedback when remapping fails.
* fix(datasource): update OAuthSchema validation to remove unnecessary 'dive' tag
- Modified the validation tag for OAuthSchema in DatasourceProviderDeclaration to simplify the validation process by removing the 'dive' requirement.
* feat(tests): add datasource declaration parsing and output
- Introduced a new main.go file for testing datasource declaration parsing.
- Implemented JSON unmarshalling for RemotePluginRegisterPayload and DatasourceProviderDeclaration.
- Added a sample datasource declaration for testing purposes.
* fix(plugin): improve error handling in UninstallPlugin and add datasource deletion
- Enhanced error handling to return a specific message when a plugin is not installed.
- Added functionality to delete the associated datasource installation during the uninstallation process.
* feat(datasource): add support for decoding datasource provider declaration
- Added custom JSON marshalling and unmarshalling methods to handle CredentialsSchema and Datasources more effectively.
- Improved error handling during YAML unmarshalling to support both object and array formats for CredentialsSchema.
- Ensured proper initialization of DatasourceFiles and Tags to prevent nil references.
* fix: provider type
* refactor(datasource): simplify JSON unmarshalling for CredentialsSchema
- Removed complex handling of CredentialsSchema in the UnmarshalJSON method, focusing on the Datasources field.
- Streamlined the code to improve readability and maintainability by eliminating unnecessary checks and logic related to CredentialsSchema.
* feat: streaming datasource
* feat: datasource
* feat: datasource
* feat:datasource
* feat:datasource
* feat:datasource
* feat: add redirect_uri field to OAuth request structs
* feat: add online driver file request and response structures
* feat: add online driver file request and response structures
* feat: add online_driver datasource type to validation
* feat: rename online driver to online drive and update related classes and methods :)
* refactor: rename OnlineDocumentPageChunk to DatasourceGetPagesResponse and update related references
* feat: update request types for online drive browsing and downloading
* feat: add metadata field to OAuthGetCredentialsResult
* feat: built-in json schema definations
* feat(plugin_entities): add built-in schema definitions and processing for datasource YAML
* test(plugin_entities): add unit tests for schema definitions and YAML processing
* refactor(plugin_entities): centralize built-in schema definitions and processing
* refactor(plugin_entities): remove unused properties from built-in schema definitions
* refactor(plugin_entities): built-in schema & new datasource structure
* refactor(plugin_entities): enhance schema processing with checks and error handling
* refactor(plugin_entities): update validation for OnlineDriveBrowseFilesRequest prefix field to be optional
* refactor(json_schema): remove json schema definitions and validation
* fix(plugin_entities): remove output_schema validation tests
* feat: add rag tag
---------
Co-authored-by: Harry <xh001x@hotmail.com>
Co-authored-by: Dongyu Li <544104925@qq.com>
Co-authored-by: Novice <novice12185727@gmail.com>
- Updated AWS-related types and functions to reflect Serverless terminology, including renaming `AWSTransactionHandler` to `ServerlessTransactionHandler` and `AWSTransactionWriter` to `ServerlessTransactionWriter`.
- Adjusted error messages and comments to align with the new naming conventions.
- Modified installation functions to use Serverless terminology for clarity and consistency across the codebase.
* refactor(plugin_manager): enhance HTTP client timeout handling in serverless runtime with DialContext
- Updated the HTTP client in the ServerlessPluginRuntime to use a context-aware DialContext for better timeout management.
- Removed the write timeout option from the HTTP request builder, streamlining the request handling process.
- Improved connection handling by setting write deadlines based on the PluginMaxExecutionTimeout.
This change enhances the reliability of network operations within the serverless runtime environment.
* refactor(plugin_manager): remove write deadline setting in serverless runtime connection initialization
- Eliminated the write deadline setting from the connection initialization in the ServerlessPluginRuntime.
- This change simplifies the connection handling process and aligns with the recent enhancements to timeout management.
This update contributes to a more streamlined and efficient network operation within the serverless environment.
* refactor(plugin_manager): adjust HTTP client timeout settings in serverless runtime
- Modified the HTTP client configuration in the ServerlessPluginRuntime to set the TLS handshake timeout based on PluginMaxExecutionTimeout.
- Retained the IdleConnTimeout setting to ensure consistent connection management.
This update improves the timeout handling for secure connections, enhancing overall network reliability in the serverless environment.
- Refactored the RemapAssets function to streamline the remapping of icon fields for both models and tools, including support for dark mode icons.
- Introduced new fields IconSmallDark and IconLargeDark in the ModelProviderDeclaration and added IconDark in ToolProviderIdentity to accommodate dark mode assets.
- Improved error handling during the remapping process for better clarity and maintainability.
* feat(plugin_manager): optimize local plugin startup with concurrent control
- Add semaphore-based concurrency control for plugin launches
- Implement parallel plugin startup using goroutines
- Optimize error handling to prevent goroutine blocking
- Add concurrency metrics logging
Note: handleNewLocalPlugins now accepts config parameter with default concurrency limit
* feat(plugin_manager): make local plugin launching concurrency configurable
* fix(plugin_manager): optimize comment and error handling
- Updated comments to clarify the concurrent plugin launching configuration.
- Added a nil check for the error channel during plugin startup to improve code robustness.
* refactor(plugin_manager): refactor plugin startup logic
- Remove the semaphore mechanism and switch to using routine.Submit for concurrency management
* fix(plugin_manager): Optimize plugin startup logs and concurrency control
- Added log output for maximum concurrency when starting local plugins
- Implemented a channel-based concurrency control mechanism to ensure limits are not exceeded
- Fixed closure variable capture issue to prevent incorrect plugin information
- Improved error handling to avoid deadlocks during startup
* fix(plugin_manager): simplify error channel handling and semaphore release logic
---------
Co-authored-by: jim02.he <jim02.he@vipshop.com>
* feat: add support for dark icon
- Introduced IconDark field in PluginDeclaration and related structures to support dark mode icons.
- Updated the installation process to handle dark icons.
- Enhanced asset validation to check for the presence of dark icons.
This change improves the visual consistency of plugins in dark mode environments.
* enhance(cli/icon): add plugin icon support with multiple categories
- Added support for light and dark icons for various plugin categories including agent, datasource, extension, model, tool, and trigger.
- Replaced the previous single icon implementation with a structured map for better organization and retrieval of icons based on category and theme.
- Removed the old Python icon file to streamline asset management.
This update improves the visual representation of plugins across different themes, enhancing user experience.
* change icons
* fix
* fix
* comments
Directly fetch and invoke the listener for a given session_id instead of iterating over the entire listener map.
Signed-off-by: guanz42 <guanz42@163.com>
* refactor: update PluginManager to use configuration for various configurations
- Replaced hardcoded values in PluginManager methods with values from the configuration.
- Updated serverless plugin launch timeout and working paths to utilize the new configuration structure.
- Enhanced local plugin runtime initialization to pull settings from the configuration, improving maintainability and flexibility.
* refactor: clean up PluginManager by removing unused fields and updating platform check
- Removed commented-out fields from PluginManager to enhance code clarity.
- Updated platform check to utilize the configuration structure instead of a direct field reference, improving maintainability.
- Added `pluginMaxExecutionTimeout` to `PluginManager` for configurable execution limits.
- Updated `ServerlessPluginRuntime` to utilize the new timeout setting in HTTP requests.
- Refactored AWSPluginRuntime references to ServerlessPluginRuntime for consistency across the codebase.
* fix: errChan failed to write response because of panic nil (#296)
* fix: join err and er into a single error using errors.Join, thanks @Yeuoly (#296)
---------
Co-authored-by: NeatGuyCoding <cto@sb>
* feat(redis): Add support for Redis Sentinel mode
Added support for Redis Sentinel mode to the Redis client, enabling automatic discovery and connection to the primary node through Sentinel. Updated relevant configuration files and initialization logic to support Sentinel mode configuration and connection.
* add lost RedisUser.
* feat: introduce 'run' command for local plugin execution
- Added a new command `run` to launch plugins locally, allowing communication through stdin/stdout.
- Removed the previous `test` command and its associated functionality to streamline the plugin testing process.
* feat: enhance 'run' command with TCP support
- Introduced a new `RunPluginPayload` structure to encapsulate plugin execution parameters.
- Added TCP communication mode to the `run` command, allowing multiple client connections.
- Updated command flags to configure run mode and logging options.
- Implemented client handling and server creation for both stdin/stdout and TCP modes.
* docs: improve comments in RunPlugin function for clarity
- Enhanced comments to provide clearer explanations of the plugin decoding process and the creation of client streams for both stdin/stdout and TCP modes.
- Updated comments to reflect the functionality and behavior of the plugin execution flow.
* refactor: update command structure and enhance plugin invocation handling
- Changed the command structure to add `runPluginCommand` under `pluginCommand` for better organization.
- Introduced `InvokePluginPayload` type to encapsulate plugin invocation details.
- Enhanced `RunPlugin` function to handle responses and errors more effectively, including logging to stdout.
- Updated client handling to support session management and improved error handling during plugin invocation.
- Renamed TCP server creation function for consistency.
* feat: enhance plugin response handling and logging capabilities
- Added a new flag `--response-format` to specify the output format (text or json) for plugin responses.
- Introduced a `logger` to manage logging output to stdout with timestamps and file information.
- Updated `logResponse` and `systemLog` functions to handle different response formats.
- Enhanced `handleClient` and `RunPlugin` functions to utilize the new response format feature.
- Implemented signal handling to clean up temporary directories on shutdown.
* feat: enhance plugin response structure and logging
- Added `InvokeID` to `InvokePluginPayload` and `GenericResponse` for better tracking of plugin invocations.
- Updated `logResponse` to include `InvokeID` in error responses for improved debugging.
- Enhanced client handling in `handleClient` to log plugin readiness and received requests.
- Refactored client stream creation for better readability and consistency.
* feat: add plugin invoke end response type and logging
- Introduced `GENERIC_RESPONSE_TYPE_PLUGIN_INVOKE_END` to enhance response tracking for plugin invocations.
- Updated `handleClient` to log the end of plugin invocation, improving visibility into the plugin lifecycle.
* chore: remove fullfeature tags
- Introduced a new test file to implement a fake OpenAI server that streams responses for benchmarking purposes.
- Updated the existing benchmark test to utilize the new fake server, enhancing the testing environment for local plugin runtime invocations.
- Refactored the package name in the benchmark test file for clarity and consistency.
* feat: add plugin reinstallation functionality and admin API support
- Implemented ReinstallToAWSFromPkg method to allow reinstallation of plugins on AWS Lambda, updating function URL and name.
- Added clearServerlessRuntimeCache method to manage serverless runtime cache.
- Enhanced LaunchPlugin to support an ignoreIdempotent flag for forced reinstallation.
- Introduced admin API endpoints for plugin reinstallation, secured with an API key validation middleware.
- Updated configuration to include AdminApiEnabled and AdminApiKey settings.
* refactor: update plugin reinstallation endpoint and improve unauthorized response
- Changed the plugin reinstallation endpoint from "/plugins/reinstall" to "/plugin/serverless/reinstall" for better clarity.
- Modified the unauthorized response in the AdminAPIKey middleware to return a more descriptive JSON message.
- Implemented validation in NewInstalledBucket to log warnings for non-alphanumeric starting characters and empty paths for installedPath.
- Updated parameter naming for consistency across methods in InstalledBucket, enhancing code clarity.
- Adjusted the buffer size settings in the stdioHolder to utilize configurable values for stdout buffer size and maximum buffer size, enhancing flexibility in plugin output handling.
* fix: improve line processing in StdioRequestReader
- Replaced synchronous stdin reading with asynchronous data retrieval.
- Enhanced line processing to skip empty lines and handle incomplete data more effectively, improving overall robustness of the request reading mechanism.
* feat: add asynchronous reading to StdioRequestReader
- Implemented the _read_async method to read data from stdin in 64KB chunks, optimizing data retrieval.
- This enhancement improves the efficiency of the request reading process in the StdioRequestReader class.
* feat: add read & write timeout config
* refactor: update Dify invocation configuration to use structured payload
- Changed the Dify invocation daemon to accept a structured payload for initialization, improving clarity and maintainability.
- Updated related configuration variables in the .env.example file to reflect the new naming convention for backwards invocation timeouts.
- Adjusted tests and plugin manager to accommodate the new payload structure.
---------
Co-authored-by: Yeuoly <admin@srmxy.cn>
- Introduced new configuration options for plugin stdio buffer sizes in the .env.example file.
- Updated the PluginManager and LocalPluginRuntime to utilize these new buffer size settings.
- Enhanced the stdioHolder to accept buffer size configurations, improving plugin output handling.
- Modified related tests to accommodate the new stdioHolder configuration structure.
* feat: enhance integration testing for specific plugins
- Added integration tests for the official agent, including test data for agent strategy invocation.
- Introduced JSON schema generation and validation utilities to ensure proper request formatting.
- Enhanced mock invocation handling in the plugin manager to support tool parameters.
- Added new test utilities for simulating OpenAI server responses and managing plugin runtime.
* fix: update RunOnce function to return response stream and enhance integration test
- Modified the RunOnce function to return a response stream instead of an error, allowing for better handling of streamed responses.
- Updated the integration test for the official agent to read from the response stream, ensuring proper validation of the agent strategy invocation.
- Introduced two new patch files: `0.1.1.llm.py.patch` and `0.1.1.request_reader.py.patch` to enhance the plugin's functionality.
- Updated the `environment_python.go` file to reference the new patches and apply them conditionally based on the plugin SDK version.
- Improved the handling of LLM usage and request reading in the plugin environment.
* refactor(plugin_daemon): simplify InvokeTool function and enhance stream handling
- Removed unnecessary complexity from the InvokeTool function by eliminating the blob handling logic and directly returning the response.
- Updated the stream implementation to support blocking writes, allowing for better management of data flow when the buffer is full.
- Added tests for the new blocking write functionality to ensure reliability and performance under high load conditions.
* fix: buffer size