LoopForge icon indicating copy to clipboard operation
LoopForge copied to clipboard

[Bug]: ensureDockerCLI does not forward NPM_CONFIG_REGISTRY from sandbox environment during npm CLI install

Open 77zane opened this issue 2 days ago • 1 comments

Component / host

Platform — runner / sandbox

Edition

Platform

LoopForge version

v0.4.3 (ghcr.io/tencent/loopforge:0.4.3), verified still present on main (96ed7da4)

What happened?

When ensureDockerCLI (internal/runtime/conversation_sandbox.go:242-251) installs an on-demand npm CLI (opencode-ai, @anthropic-ai/claude-code, @moonshot-ai/kimi-code, @earendil-works/pi-coding-agent, etc.) inside a Docker conversation workspace container via docker exec --user 0:0, it forwards proxy variables from s.profile.Environment:

for _, key := range []string{"HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "NO_PROXY", "http_proxy", "https_proxy", "all_proxy", "no_proxy"} {
    if value, ok := s.profile.Environment[key]; ok {
        setupArgs = append(setupArgs, "-e", key+"="+value)
    }
}

However, it does not forward NPM_CONFIG_REGISTRY / npm_config_registry (nor fall back to the platform process's NPM_CONFIG_REGISTRY / npm_config_registry if configured).

Actual behavior: Even when an operator configures NPM_CONFIG_REGISTRY (e.g., a regional mirror such as https://registry.npmmirror.com or an internal corporate npm registry) in the Docker sandbox profile's environment variables, ensureDockerCLI ignores it and always fetches packages directly from https://registry.npmjs.org, causing very slow downloads or timeouts in mainland China / intranet environments.

Expected behavior: ensureDockerCLI should forward NPM_CONFIG_REGISTRY and npm_config_registry from s.profile.Environment (and optionally inherit from the platform environment when unset on the sandbox profile) into the docker exec installation command, consistent with how proxy variables are already forwarded for npm install.

Reproduction

  1. Deploy LoopForge with Docker Compose (ghcr.io/tencent/loopforge:0.4.3).
  2. Add NPM_CONFIG_REGISTRY=https://registry.npmmirror.com (or a private mirror URL) to the generic-docker sandbox profile's environment variables.
  3. Open a Docker conversation workspace using an on-demand npm CLI not bundled in the image (e.g., opencode).
  4. Inspect the docker exec command launched by ensureDockerCLI: NPM_CONFIG_REGISTRY is not passed via -e, and npm install still connects to registry.npmjs.org.

Sanitized diagnostics

# internal/runtime/conversation_sandbox.go:242-250 (main @ 96ed7da4)
setupArgs := []string{"exec", "--user", "0:0", "--workdir", "/"}
for _, key := range []string{"HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "NO_PROXY", "http_proxy", "https_proxy", "all_proxy", "no_proxy"} {
    if value, ok := s.profile.Environment[key]; ok {
        setupArgs = append(setupArgs, "-e", key+"="+value)
    }
}

Safety checks

  • [x] I removed credentials, private endpoints, internal identifiers, and personal data.
  • [x] I searched existing issues for duplicates. (Related to #892 which mentioned npm registry configurability for platform-side Claude Code install, whereas this issue targets the ensureDockerCLI env allowlist inside Docker conversation sandboxes.)

If this is accepted, I'd be happy to submit a minimal PR with unit tests forwarding NPM_CONFIG_REGISTRY / npm_config_registry in ensureDockerCLI.

77zane avatar Dec 01 '26 15:12 77zane

Thank you for the report. We understand that when ensureDockerCLI installs an on-demand npm CLI in a Docker conversation workspace, it forwards proxy variables but not NPM_CONFIG_REGISTRY, so the install still uses the public npm registry even if a sandbox mirror is configured.

This has been noted and will be reviewed with the current issue queue.

cocofhu00 avatar Dec 01 '26 16:12 cocofhu00