Skip to content

feat: auto-detect pip mirror#750

Open
BeautyyuYanli wants to merge 6 commits into
mainfrom
feat/auto-mirror
Open

feat: auto-detect pip mirror#750
BeautyyuYanli wants to merge 6 commits into
mainfrom
feat/auto-mirror

Conversation

@BeautyyuYanli

@BeautyyuYanli BeautyyuYanli commented May 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds startup-time automatic PyPI mirror selection for plugin dependency installation.

Environment variables

  • PIP_MIRROR_AUTO_DETECT

    • Default: true
    • Controls whether the daemon should try to auto-select a suitable PyPI mirror during startup.
    • When enabled and no explicit mirror is configured, the daemon detects the public IP region and may assign a local mirror for regions with poor network connectivity.
  • PIP_MIRROR_URL

    • Default: empty
    • Manually specifies the PyPI mirror used for plugin dependency resolution.
    • When set, it takes precedence over auto detection and disables the auto-selected mirror.

Detection behavior

  • The daemon uses https://cloudflare.com/cdn-cgi/trace at startup to detect the public IP region.
  • If the detected region needs a local mirror, config.PipMirrorUrl is populated before plugin runtimes install Python dependencies.
  • Regions that do not need a mirror keep the default behavior.
  • Detection failures are non-fatal: the daemon logs a warning and continues startup without changing the mirror configuration.

Documentation and tests

  • Updates .env.example and README.md to describe the mirror-related configuration behavior.
  • Adds tests for config defaults, env overrides, trace parsing, mirror precedence, region-based application, and non-blocking failure handling.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

Testing

  • I have tested the changes locally and confirmed they work as expected
  • I have added unit tests where necessary and they pass successfully

Bug Fix (if applicable)

  • I have used GitHub syntax to close the related issue (e.g., Fixes #123 or Closes #123)

Additional Information

Local verification performed:

go build -o /tmp/opencode/dify-plugin-daemon-server cmd/server/main.go
go test ./cmd/server ./internal/types/app

This PR is drafted by gpt-5.4 and gpt-5.5. I'm responsible for all the changes. I have reviewed the code and varified the behavior, while breaks may still exist. Reach me to fix in this case.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request go Pull requests that update go code plugin-daemon labels May 29, 2026
gemini-code-assist[bot]

This comment was marked as low quality.

Comment thread cmd/server/main.go Outdated
@wylswz wylswz marked this pull request as draft June 1, 2026 01:17
@wylswz wylswz marked this pull request as ready for review June 8, 2026 05:53
@dosubot dosubot Bot added the documentation Improvements or additions to documentation label Jun 8, 2026
@wylswz wylswz marked this pull request as draft June 8, 2026 05:54
@wylswz wylswz marked this pull request as ready for review June 8, 2026 07:13
@wylswz wylswz requested a review from fatelei June 8, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request go Pull requests that update go code plugin-daemon size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants