Commit Graph

17 Commits

Author SHA1 Message Date
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
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
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
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 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
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 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
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 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 e91068d61f feat: add agent template to cli 2024-12-13 22:41:12 +08:00
Yeuoly c6d7fa1074 feat: add bundle cli commands 2024-11-13 21:27:04 +08:00
Yeuoly b195b93ae3 refactor: commandline 2024-11-13 20:38:47 +08:00