HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
Environments: an npm range is a name with no pin, so its check does not call it unpublished (#491)
Rudy Mizrahi Celeklie8f9b0eab6a1
diff --git a/runner/environments.py b/runner/environments.pyindex 4fdfbfd3..1d419c75 100644--- a/runner/environments.py+++ b/runner/environments.py@@ -579,6 +579,7 @@ _apt_lists_at = 0.0_RANGE_OPS = (">=", "<=", "~=", "!=", ">", "<")+_NPM_RANGE = re.compile(r"[\^~<>*|\s]|(?:^|\.)[xX](?:\.|$)")def spec_parts(spec: str, manager: str) -> tuple[str, str]:@@ -588,7 +589,12 @@ def spec_parts(spec: str, manager: str) -> tuple[str, str]:s = spec.strip()if manager == "npm":i = s.rfind("@")- return (s[:i], s[i + 1:]) if i > 0 else (s, "")+ if i <= 0:+ return s, ""+ # npm's ranges (^4.17.0, ~4.17, >=1, 1.x, *) are not one version either: the registry's+ # `versions` names exact ones, so a range read as a pin was "not published".+ v = s[i + 1:]+ return s[:i], ("" if _NPM_RANGE.search(v) else v)# Ranges before the pin operators: `>=`, `<=`, `~=` and `!=` each end in `=`, so looking for a# pin first read `jq>=1.6` as the name `jq>` with the pin `1.6` — neither what the owner# declared nor something apt-get, pip or a registry will answer for.diff --git a/runner/tests/test_environments.py b/runner/tests/test_environments.pyindex 114d80d9..aa3f4eb4 100644--- a/runner/tests/test_environments.py+++ b/runner/tests/test_environments.py@@ -706,3 +706,19 @@ def test_a_write_waiting_on_a_snapshot_or_a_slow_import_leaves_the_runner_answerg.join(10)assert waited is not None and waited < 1.0, f"the runner did not answer while a git import ran ({waited})"assert done["g"].status_code == 200+++def test_an_npm_range_is_a_name_with_no_pin(monkeypatch):+ """npm's ranges went through as exact pins, so `lodash@^4.17.0` was checked against the+ registry's exact versions and refused as "not published" though npm installs it."""+ for spec in ("lodash@^4.17.0", "lodash@~4.17", "lodash@>=4", "[email protected]", "lodash@*", "lodash@1 || 2"):+ assert E.spec_parts(spec, "npm") == ("lodash", ""), spec+ for spec, want in (("[email protected]", ("lodash", "4.17.21")), ("@types/[email protected]", ("@types/node", "24.1.0")),+ ("[email protected]", ("lodash", "1.0.0-rc.1")), ("lodash", ("lodash", ""))):+ assert E.spec_parts(spec, "npm") == want, spec+ answers = {"https://registry.npmjs.org/lodash": (200, {"dist-tags": {"latest": "4.17.21"},+ "versions": {"4.17.21": {}, "4.17.20": {}}})}+ monkeypatch.setattr(E, "_http_json", lambda url: answers.get(url, (503, {})))+ ranged = E.check_package("npm", "lodash@^4.17.0")+ assert ranged["exists"] is True and ranged["error"] == "" and ranged["version"] == ""+ assert "not published" in E.check_package("npm", "[email protected]")["error"]