Commit Graph

98 Commits

Author SHA1 Message Date
wangxiaolei d9fe93f1f9 feat: plugin package clean command line (#584) 2026-03-08 10:20:13 +08:00
Byron.wang ca3d00229e Feat/Implement structured logging and Trace ID propagation (#552)
* 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>
2025-12-30 11:00:48 +08:00
Yeuoly 888ad788bc refactor: plugin lifecycle control panel (#499)
* refactor: introduce local plugin control panel and cleanup environment setup process

* fix: args

* refactor: new local runtime

* temp: stash work for refactor on RemotePluginServer

* refactor: unify local runtime lifetime and sperate init environment process

* chore: add missing files

* stash

* refactor: local plugin lifetime control

* refactor: complete installation process of control panel

* refactor: adapt service layer to new controlpanel

* refactor: pluginManager.Install

* fix: add routine wrap to InstallServerless, avoid blocking main thread

* feat: reinstall serverless runtime

* chore: add comments to Reinstall and update confusing naming

* refactor: unify install plugin service

* refactor: add labels to debugging runtime

* refactor: add getters to plugin manager

* refactor: split install service to decode/install_task/install service

* ???

* refactor: adapt controllers

* refactor: session write

* refactor: session runtime

* Refine install task orchestration (#501)

* refactor: installing task

* refactor cluster management, decouple lifetime management and cluster

* fix cli test command

* fix: cleanup TODO comments and implement GracefulStop for instance

* feat: add logger to control panel

* fix: multiple nil references

* refactor: better lifetime control

* refactor: better cycle interval

* fix(LocalPluginRuntime): prevent returning err when it's not  error

* fix: avoid adding empty PipExtraArgs

* fix: missing errors in Environment init

* fix: add truncateMessage to avoid db explosion

* cleanup: better lifecycle management

* fix: init status at the beginning of installation

* optimize: GracefulStop for pluginInstance

* refactor: tests

* refactor: centralize routine labels (#504)

* cleanup: RoutineKey

* fix: init routine pool

* fix: correctly handle cluster register error

* fix: memory leak

* fix: add \n to instance write

* fix(installer.go): set success to true after succeed for defer func

* refactor

* fix: missing cwd in testutils

* fix: scaleup default runtime nums to 1 when testing

* fix: localruntime appconfig in testing module

* Update internal/core/local_runtime/load_balancing.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fix: more efficiency implement in installer_local.go

* fix: returns after failing in onDebuggingRuntimeDisconnected

* fix: returns after failing in onDebuggingRuntimeDisconnected

* fix: splits tests

* refactor: naming

* refactor: manifest.VersionX

* fix: adapt SetDefault to tests

* fix: enforce use constants in DBType

* fix: generate

* fix: linter

* cleanup tests

* refactor: change  package to

* cleanup: useless codes

* Update internal/cluster/plugin.go

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* cleanup

* refactor: decouple connection_key management from debugging_time

* refactor: confused naming

* feat: recycle resources to adapt to https://github.com/langgenius/dify-plugin-daemon/pull/500

* refactor: confusing redirecting

* fix: support get serverless runtime

* fix: race condition in Launching

* fix: avoid ManifestValidate in first step of debugging handshake

* fix: adding ReleaseAllLocks to finalizers

* wtf: what a beautiful code

* refactor: rename Stream.Async to Stream.Process

* fix: kill process if daed instance was detected

* fix: correctly handle failures

* fix: consistence of difference interfaces

* fix: add stacktrace to panic

* fix: only trigger once  event

* fix: ensure plugin runtime was shutdown

* feat: cleanup install tasks

* fix: add scale logs

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-11-18 17:28:02 +08:00
非法操作 70ba852ecc feat: cli tool support create trigger plugins (#485)
* feat: cli tool support create trigger plugins

* fix(trigger): update placeholder comment in SubscriptionConstructor for webhook registration

---------

Co-authored-by: Harry <xh001x@hotmail.com>
2025-11-05 15:45:58 +08:00
CrabSAMA 2d81bb254a fix: datasource plugin template typo (#464) 2025-09-29 19:03:59 +08:00
crazywoola dbbc4a29cc 454 bump cli template (#455)
* feat: update template

* feat: update ja_JP

* feat: update GUIDE.md
2025-09-22 14:41:47 +08:00
Tianyi Jing 1dacb201ff feat(cmd): add datasource template (#449)
* feat: add template for datasource plugins

Signed-off-by: jingfelix <jingfelix@outlook.com>

* fix: description and missing category

Signed-off-by: jingfelix <jingfelix@outlook.com>

---------

Signed-off-by: jingfelix <jingfelix@outlook.com>
2025-09-17 09:40:09 +08:00
kenwoodjw bb83075acd feat: add max-size flag (#445)
Signed-off-by: kenwoodjw <blackxin55+@gmail.com>
2025-09-12 19:26:29 +08:00
Yeuoly 178e7649ba fix(env): update REMOTE_INSTALL_URL format in .env.example (#412)
- Combined REMOTE_INSTALL_URL and REMOTE_INSTALL_PORT into a single line for clarity.
- This change improves the configuration format for easier understanding and usage.
2025-07-23 18:21:42 +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
Yeuoly 7f463e32f6 feat(plugin_decoder): add support for internationalized readme files (#393)
* feat(plugin_decoder): add support for internationalized readme files

- Introduced the AvailableI18nReadme method in the PluginDecoder interface to retrieve available readme files in multiple languages.
- Implemented the method in FSPluginDecoder and ZipPluginDecoder to read localized readme files from the filesystem and zip archives.
- Enhanced UnixPluginDecoder to handle readme files in a structured manner, including support for reading from a dedicated "readme" directory.
- Added unit tests to verify the functionality of the AvailableI18nReadme method and ensure correct retrieval of localized readme content.

* feat(plugin): add support for multilingual README generation

- Introduced functionality to create README files in multiple languages (Simplified Chinese, Japanese, Portuguese) based on user selection.
- Enhanced the profile management to include options for enabling internationalized README and selecting languages.
- Added new language choice structure to manage language options and their selection state.
- Implemented rendering and writing of language-specific README files during plugin creation.
- Included new README template files for each supported language.

* feat(plugin): add README command and list functionality

- Introduced a new `readme` command to the plugin CLI for managing README files.
- Added `list` subcommand to display available README languages for a specified plugin path.
- Implemented functionality to read and list supported README languages in a tabular format.
- Enhanced error handling for plugin file reading and decoding processes.
2025-07-21 16:02:26 +08:00
Maries 3b0a8679f4 feat/tool oauth cli template (#407)
* feat(cli): update OAuth handling and requirements for dify_plugin

* feat(oauth): update OAuth support and adjust dify_plugin version constraints
2025-07-21 15:37:13 +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
Tianyi Jing af3fec6f32 fix: prevent duplicate packaging (#367)
fixes: https://github.com/langgenius/dify-plugins/issues/612
fixes: https://github.com/langgenius/dify-plugins/issues/234

Signed-off-by: jingfelix <jingfelix@outlook.com>
2025-06-26 17:45:59 +08:00
Ganondorf ff875c7e7a Split REMOTE_INSTALL_ADDRESS into HOST and PORT in .env.example to align with the official docs (#356)
Co-authored-by: lizb <lizb@sugon.com>
2025-06-20 10:33:28 +08:00
Yeuoly 3918b377f2 refactor: streamline plugin initialization and update YAML templates for consistency (#313)
- Removed redundant flag retrieval in the plugin initialization process, simplifying the code.
- Updated permission handling to use a single `permissionRequirement` structure for better clarity and maintainability.
- Enhanced YAML templates by adding quotes around dynamic values to ensure proper formatting and prevent potential parsing issues.
2025-05-27 19:48:11 +08:00
Byron.wang b3c68cbeec add packaged file info when plugin package larger than max size (#312) 2025-05-27 13:02:25 +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 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 31d7c7417e feat[0.1.0]: introduce 'run' command for local plugin execution (#283)
* 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
2025-05-16 14:20:29 +08:00
Bowen Liang fa2ac6dd2c dep: bump dify_plugin in plugin dependency template to 0.2.x (#278)
* bump dify_plugin to 0.2.x

* dify_plugin>=0.2.0,<0.3.0
2025-05-13 17:13:56 +08:00
Bowen Liang e655881e6f feat: support REMOTE_INSTALL_URL in plugin cli template (#279)
* set REMOTE_INSTALL_URL in .env.example

* update GUIDE.md

* remove REMOTE_INSTALL_PORT config in GUIDE.md

* remove REMOTE_INSTALL_PORT config in GUIDE.md

* update REMOTE_INSTALL_URL config in GUIDE.md

* update REMOTE_INSTALL_URL config in GUIDE.md
2025-05-13 14:24:23 +08:00
Yeuoly d02885674a feat: add repository URL support for plugin manifest (#262)
* feat: add repository URL support for plugin manifest

- Introduced a new optional flag for specifying the plugin repository URL during initialization.
- Updated the InitPluginWithFlags function to handle the new repository parameter.
- Enhanced profile management to include repository input.
- Modified related tests to validate the new repository functionality.

* fix: improve input validation in profile checkRule method

- Updated the checkRule method to ensure cursor is within valid range before checking for empty input values. This change prevents potential out-of-bounds errors and enhances the robustness of the input validation process.
2025-05-07 18:35:38 +08:00
Yeuoly 18a251a823 fix: update moderation model docstring to reflect plugin name correctly (#250)
- Modified the docstring in the moderation model to use the correct format for the plugin name, enhancing clarity and consistency in the documentation.
2025-04-27 18:11:37 +08:00
Yeuoly ad71e7ae26 refactor: move validation logic for plugin initialization under quick flag (#249)
- Updated the InitPluginWithFlags function to conditionally validate the plugin name, author, and description only when the quick flag is set.
- This change improves the flexibility of the plugin initialization process by allowing bypassing validation in certain scenarios.
2025-04-27 17:59:03 +08:00
Yeuoly ee540bc220 feat: enhance plugin initialization with configurable parameters (#248)
* feat: enhance plugin initialization with configurable parameters

- Added new flags for plugin initialization, allowing users to specify author, name, description, and various permissions.
- Implemented InitPluginWithFlags function to handle the new parameters and validate input.
- Introduced methods to set category, language, and minimal Dify version within the plugin model.
- Enhanced profile management by adding methods to set author and name directly.
- Improved category and language selection with dedicated setter methods.

* add enum

* add tests
2025-04-27 17:29:26 +08:00
cirtron e2a11dd600 chore: update macos gitignore (#228) 2025-04-22 13:22:00 +08:00
Novice 63a12615ab feat(cli): add github ci to template (#183)
* feat(cli): add github ci to template

* chore: change the trigger condition to release

* feat: add guide document

* fix: add .github to .gitignore

---------

Co-authored-by: Yeuoly <admin@srmxy.cn>
2025-04-15 13:34:29 +08:00
Yeuoly c952664139 Feat/support minimal dify version required (#203)
* feat(plugin): add version requirement functionality to plugin initialization

- Introduced a new `version_require` sub-menu to handle minimal Dify version input.
- Updated the plugin initialization process to include the new version requirement.
- Enhanced the `PluginMeta` struct to store the minimal Dify version.
- Added validation for the minimal Dify version input to ensure correctness.

* fix(plugin): rename MinimalDifyVersion to MinimumDifyVersion for consistency

- Updated the `PluginMeta` struct to change the field name from `MinimalDifyVersion` to `MinimumDifyVersion`.
- Adjusted the plugin initialization logic to reflect the new field name, ensuring proper handling of version requirements.
2025-04-14 20:02:34 +08:00
Yeuoly 1563fc40b2 fix(requirements): update dify_plugin version constraint (#191) 2025-04-10 15:16:10 +08:00
crazywoola 4d9d74c7f1 Chore/update docs and refine wording (#190)
* fix: remove deprecated docs

* chore: polish the wording
2025-04-10 12:45:15 +08:00
kurokobo 01747753f7 feat: add tests for third-party signature verification 2025-04-02 13:48:08 +00: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
kurokobo ee1a0dca15 feat: add signature subcommand to cli to generate key pair, sign, and verify difypkg file 2025-04-01 14:20:23 +00:00
Yeuoly b3f389d37a fix: Update links in Python plugin guide to point to the correct schema definition documentation 2025-03-18 16:08:48 +08:00
Yeuoly 6ce5373848 fix: bump cli sdk template to 0.0.1b72 (#86) 2025-03-10 17:57:37 +08:00
Yeuoly 41ff75a976 LICENSE (#42)
* LICENSE

* LICENSE
2025-02-28 14:50:36 +08:00
eux 0636968f84 fix: add missing import for llm template (#26) 2025-02-17 11:23:35 +08:00
Yeuoly b6fdcabbf0 fix: disable invalid author and formal release 2025-02-17 11:18:31 +08:00
Yeuoly 975f9d5c31 fix: move packager to pkg 2025-02-06 18:16:49 +08:00
非法操作 2f8d22fcc6 add ide config to .gitignore (#18) 2025-01-24 14:51:02 +08:00
kurokobo 12d5795cf7 docs: bump minimal python version to 3.11 to follow changes on dify-plugin-sdks (#5) 2025-01-22 17:42:40 +08:00
非法操作 caf5251e5e only allow lowercase letters 2025-01-21 16:11:59 +08:00
Yeuoly 52ad267ff6 fix: lock the version of dify_plugin to 0.0.1b60 in cli templates 2025-01-14 17:57:08 +08:00
Yeuoly 0f94beb9ff feat: add command line support to agent 2025-01-08 15:11:08 +08:00
Yeuoly 15060ee312 refactor: move entities to pkg 2025-01-06 14:52:02 +08:00
Yeuoly 80f4d1c056 feat: support privacy policy 2024-12-27 18:20:14 +08:00
Yeuoly d55e0ba81a optimize: difyignore, add .git/.gitignore/.DS_Store/Thumbs.db 2024-12-24 20:15:01 +08:00
Yeuoly d784e1acfa fix: strict the pakcage size of uncompressed files 2024-12-16 17:12:57 +08:00
Yeuoly e91068d61f feat: add agent template to cli 2024-12-13 22:41:12 +08:00