Commit Graph

186 Commits

Author SHA1 Message Date
Stream 2c87f0ac8b Merge branch 'feat/plugin-readme' into feat/trigger
# Conflicts:
#	internal/db/init.go
2025-10-23 11:26:38 +08:00
Harry 27f3d3ad8d 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.
2025-10-10 19:48:23 +08:00
Harry 1dcee066a3 Merge remote-tracking branch 'origin/main' into feat/trigger 2025-09-26 12:04:54 +08:00
Yeuoly b85253f773 feat(plugin): implement unauthorized Langgenius plugin blocking (#458)
* feat(plugin): implement unauthorized Langgenius plugin blocking

- Added configuration option to disable installation of plugins falsely claiming Langgenius authorship.
- Introduced new error handling for unauthorized Langgenius claims during plugin installation.
- Implemented tests to validate unauthorized Langgenius detection logic.
- Updated environment configuration and service files to support the new feature.

* fix: typo

* refactor(plugin): update Langgenius plugin signature enforcement

- Renamed configuration option from DISABLE_UNAUTHORIZED_LANGGENIUS_PACKAGE to ENFORCE_LANGGENIUS_PLUGIN_SIGNATURES for clarity.
- Updated error messages and logic in the plugin installation process to reflect the new configuration.
- Enhanced tests to validate the behavior of unauthorized Langgenius plugin detection with the new enforcement setting.
2025-09-24 11:28:41 +08:00
Maries 64738319b8 Fix/json schema (#460)
* fix(agent_declaration): remove unnecessary 'json_schema' validation from OutputSchema

* fix(endpoint): add error handling for missing endpoint configuration in ListPluginEndpoints

* fix(endpoint): update error handling for missing endpoint configuration in ListPluginEndpoints
2025-09-23 23:53:21 +08:00
Yeuoly 878edde455 feat(datasource): Implement datasource validation and invocation steps (#295)
* 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>
2025-09-16 17:32:14 +08:00
Yunlu Wen 9e3081bd17 feat: support orphan plugin (#440)
* support orphan plugin in serverless mode

* add validation to UpgradePlugin

* log reinstalls
2025-09-12 20:34:38 +08:00
Harry 24a63d88a8 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.
2025-09-04 13:31:20 +08:00
Harry 390b7641ea 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.
2025-09-02 16:28:19 +08:00
Yeuoly 604da5d495 refactor: rename AWS references to Serverless in plugin daemon (#437)
- 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.
2025-08-28 18:24:22 +08:00
Stream 5b5f709e7d feat: implement readme endpoint 2025-08-27 15:57:22 +08:00
Stream 0647713f4c feat: implement readme extracting and storage 2025-08-27 15:57:09 +08:00
Blackoutta b86f12fbaa Add Redis caching to FetchPluginInstallation middleware for performance optimization (#400)
* add caching to fetch plugin installation middleware

* invalidate plugin inst cache after successfully upgrading or uninstalling operations

* optimize: refactored cache invalidation ops from curd layer to service layer

---------

Co-authored-by: yangyi.hu593671 <yangyi.hu593671@seres.cn>
2025-08-27 14:16:52 +08:00
Stream 470aeafc01 Merge branch 'main' into feat/plugin-readme 2025-08-27 13:13:29 +08:00
Yeuoly b286be778e chore: remove JSON schema validation from tool and agent services (#430)
* chore: remove JSON schema validation from tool and agent services

- Remove bindAgentStrategyValidator and bindToolValidator functions
- Remove gojsonschema dependency
- Simplify InvokeAgentStrategy by removing validation logic
- Consolidate tool invocation into generated code
- Remove redundant tool_service.go and related test files
- Move InvokeTool to generated files for consistency

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

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: remove duplicated routes

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-26 20:36:25 +08:00
Harry d3a5d2cbb8 feat(plugins): add FetchPluginReadme endpoint and update launch configurations 2025-08-22 16:40:17 +08:00
Yeuoly bace3bfb58 feat(oauth): implement refresh credentials functionality (#408)
* feat(oauth): implement refresh credentials functionality

- Added RefreshCredentials endpoint to handle OAuth credential refresh requests.
- Introduced RequestOAuthRefreshCredentials structure for request validation.
- Updated access types and actions to include refresh credentials.
- Enhanced server routing and controller logic to support the new functionality.
- Updated OAuth entities to include expiration handling for refreshed credentials.

* feat(oauth): add metadata field to OAuthGetCredentialsResult

---------

Co-authored-by: Harry <xh001x@hotmail.com>
2025-07-23 13:11:36 +08:00
Maries a0414b30e6 0.2.0 (#402)
* feat(oauth): add RedirectURI field to OAuth request structures

* feat(oauth): update OAuthSchema validation

* feat: add Context field to request and session structures

* feat: add CredentialType field to Credentials and InvokeToolRequest structures

* fix: handle unhandled default case in basic_type.go

* feat: add support for build branches in build-push.yml
2025-07-17 16:28:43 +08:00
Yeuoly b97cce7167 enhance(cli/icon): add multiple categories default plugin icons (#388)
* 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
2025-07-08 12:48:48 +08:00
Yeuoly a70d808dd0 feat(dynamic_select): implement dynamic parameter fetching functionality (#358)
* feat(dynamic_select): implement dynamic parameter fetching functionality

- Added FetchDynamicParameterOptions function to handle dynamic parameter selection.
- Introduced new access type and action for dynamic select in access_types.
- Updated HTTP server routes to include the new endpoint for fetching dynamic parameters.
- Created necessary service and controller files for dynamic select operations.

* refactor(access_types): rename dynamic select access type to dynamic parameter

- Updated access type constants to reflect the change from PLUGIN_ACCESS_TYPE_DYNAMIC_SELECT to PLUGIN_ACCESS_TYPE_DYNAMIC_PARAMETER.
- Adjusted related references in the PluginDispatchers and FetchDynamicParameterOptions function to maintain consistency.
2025-06-27 19:24:59 +08:00
Yeuoly a6c8fae9c7 feat: add decode plugin from identifier endpoint (#349)
* feat: add decode plugin from identifier endpoint

- Introduced a new endpoint to decode a plugin from a unique identifier.
- Implemented the DecodePluginFromIdentifier function to handle decoding and verification of plugin signatures.
- Updated the HTTP server routes to include the new decode endpoint.

* refactor: update decode plugin endpoint path

- Moved the decode plugin from identifier endpoint to a new path for better organization.
- Updated the HTTP server routes accordingly to reflect the new endpoint structure.
2025-06-18 16:01:15 +08:00
Novice cfd399b602 feat: agent plugin add meta version 2025-06-05 09:35:04 +08:00
Good Wood 2cd64adf3b feat: change listPlugin struct & add total (#302) 2025-05-27 12:53:37 +08:00
Yeuoly 478c98da5c fix: signature dose not work as expected, if upload new pkg to old dify (#311)
- Updated the  method in the  interface to remove the  parameter, simplifying its usage.
- Introduced a new  function to provide a default verification structure.
- Added a  file to store verification data, improving the plugin signing process.
- Enhanced tests in  to validate the verification process, ensuring proper handling of success and failure scenarios.
- Refactored related code to accommodate the new verification structure and improve overall maintainability.
2025-05-26 13:10:34 +08:00
Yeuoly 3d28e0ceed feat: Add code generation for plugin controllers and services (#301)
* feat: Add code generation for plugin controllers and services

- Introduced a code generation mechanism for plugin controllers and services, allowing for automatic generation based on defined dispatchers.
- Created new files for generated controllers, services, and templates to streamline the plugin invocation process.
- Removed outdated functions related to tool validation and runtime parameters, consolidating functionality into generated files.
- Updated dependencies in go.mod and go.sum to include necessary packages for the new code generation features.

* fix
2025-05-23 14:57:56 +08:00
Yeuoly 9a1da25d59 feat: Enhance plugin signing with authorized category verification (#293)
* feat: Enhance plugin signing with authorized category verification

- Added support for an `authorized_category` flag in the signature command to validate the category before signing.
- Updated the `Sign` function to accept a verification parameter, allowing for category-based signing.
- Enhanced error handling for invalid categories during the signing process.
- Updated tests to cover new verification scenarios and ensure proper functionality with the authorized category.

* fix

* fix

* test

* test: Add unit test for plugin verification without verification field

- Introduced a new test case to verify the behavior of plugins that lack a verification field.
- Updated the signature_test.go file to include the test, ensuring proper functionality of the signing process.
- Removed the outdated verifier_test.go file and associated test data to streamline the codebase.
2025-05-21 20:05:45 +08:00
Yeuoly d884cab8ae feat: add plugin reinstallation functionality and admin API support (#285)
* 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.
2025-05-15 15:22:25 +08:00
Yeuoly d80630acd5 feat: implement OAuth functionality (#245)
* feat: implement OAuth functionality in plugin daemon

- Added OAuth service methods for getting authorization URLs and credentials.
- Updated access types to include OAuth-related actions.
- Created new controller for handling OAuth requests.
- Introduced entities for OAuth results and requests.
- Enhanced plugin entities to support OAuth schema in tool declarations.

* feat: add OAuth endpoints for authorization and credentials retrieval

- Introduced new POST endpoints for obtaining authorization URLs and credentials in the OAuth controller.
- Enhanced the plugin dispatch group to include these new OAuth routes, improving integration with OAuth services.
2025-04-27 13:59:57 +08:00
Yeuoly 00730b67c3 refactor: replace baseSSEService with baseSSEWithSession in multiple service files (#244)
- Introduced baseSSEWithSession to streamline session management across various service functions.
- Updated InvokeAgentStrategy, InvokeLLM, InvokeTextEmbedding, InvokeRerank, InvokeTTS, InvokeSpeech2Text, InvokeModeration, ValidateProviderCredentials, ValidateModelCredentials, GetTTSModelVoices, GetTextEmbeddingNumTokens, GetAIModelSchema, and GetLLMNumTokens to utilize the new session handling approach, improving code readability and maintainability.
2025-04-25 18:34:46 +08:00
非法操作 25e013618a fix self.session.delete alway success (#12)
* fix self.session.delete alway success

* fix save data always failed

* redis delete response deleted item num

* add deleted num to invocate response
2025-04-11 13:32:52 +08:00
Yeuoly 36e7a10169 fix: cobr unmarshal map[string]any to map[any]any, feat: add tests for redirecting traffic with path style and refactor redirect request logic 2025-04-08 13:51:26 +09:00
Yeuoly eed91f2359 feat: add X-Original-Host header handling in endpoint requests and improve request redirection URL construction 2025-04-07 13:28:53 +09:00
Yeuoly 398762558e Merge pull request #128 from zxfishhack/cache-endpoint-and-plugin-install
add cache for endpoint by hook_id and pluginInstallation by plugin_id&tenant_id
2025-04-07 12:22:47 +09:00
kurokobo 6f75bcca43 feat: verify plugin with public keys specified in environment variable in addition to official one 2025-04-02 13:48:04 +00:00
zxfishhack 4aa61bc9bc remove debug log 2025-03-31 09:46:42 +08:00
zxfishhack 3aa0490294 use AutoTypeWithGetter 2025-03-24 16:56:40 +08:00
zxfishhack 1e5e03eaf0 add cache for endpoint by hook_id and plugin by plugin_id&tenant_id 2025-03-20 17:20:07 +08:00
Yeuoly 24315ec568 refactor: Extract request copying logic into separate function with test 2025-03-12 13:35:14 +08:00
Yeuoly 8ab1e2a91e feat: Add max execution time parameter to endpoint handling (#88)
Modify endpoint-related functions to support configurable maximum execution time:
- Update EndpointHandler signature to include maxExecutionTime
- Pass max execution timeout from config to endpoint service
- Modify timeout mechanism to use configurable duration instead of hardcoded 240 seconds
2025-03-10 18:23:13 +08:00
Yeuoly cfd93cd048 feat: improve plugin upgrade with declaration retrieval 2025-02-25 22:01:56 +08:00
Yeuoly b19140ca23 refactor: optimize plugin declaration caching and encoding (#34) 2025-02-25 20:52:51 +08:00
Yeuoly b1674d960f feat: support Dify-Hook-Url 2025-02-12 19:19:03 +08:00
Yeuoly 87463a23c7 refactor: using lowercase to hook id 2025-02-11 22:02:21 +08:00
Yeuoly 6a54d44142 refactor: rename aws_lambda to serverless 2025-02-10 15:04:24 +08:00
Yeuoly 01f9886192 fix: add current identifier to check dependencies 2025-02-08 16:04:19 +08:00
Yeuoly 975f9d5c31 fix: move packager to pkg 2025-02-06 18:16:49 +08:00
非法操作 0f19a092ef fix disable endpoint not work (#17)
* fix disable endpoint not work

* fix disable endpoint

* refactor the disable endpoint

* fix comment
2025-01-26 22:43:59 +08:00
Yeuoly 6444214942 Revert "Revert: refactor: serverless connector This reverts commit b413e6c96546cc50b1dbc94731d24f5c51e7a455."
This reverts commit d08d78e8b2.
2025-01-14 16:31:13 +08:00
Yeuoly ecb0664059 fix: https://github.com/langgenius/dify-plugin-sdks/issues/12 2025-01-13 20:33:11 +08:00
Yeuoly d08d78e8b2 Revert: refactor: serverless connector This reverts commit b413e6c965. 2025-01-09 14:24:10 +08:00