diff --git a/adapters/README.md b/adapters/README.md index 673d2214a..8ecad5263 100644 --- a/adapters/README.md +++ b/adapters/README.md @@ -65,7 +65,7 @@ build, and packaging conventions. | [Pi](typescript/pi/README.md) | `nvidia.fabric.pi` | `nemo-fabric-adapters-pi` | Node.js 22.19+ | | [Qwen Code](typescript/qwen/README.md) | `nvidia.fabric.qwen` | `nemo-fabric-adapters-qwen` | Node.js 22.19+ | -OpenCode, Qwen Code, and Kilo Code require HTTPS for remote model endpoints by default. To use a trusted Docker or Kubernetes HTTP gateway, configure `harness.settings.insecure_http_model_hosts` as described in their adapter READMEs. Kilo Code also supports its existing private IPv4 opt-in. +OpenCode, Qwen Code, and Kilo Code require HTTPS for remote model endpoints by default. To use a trusted Docker or Kubernetes HTTP gateway, configure `harness.settings.insecure_http_model_hosts` as described in their adapter READMEs. Kilo Code also supports its existing private IPv4 opt-in. Relay-enabled Codex, Claude, and Pi also support this setting with NeMo Relay CLI 0.11.x. Their remote HTTP path is credential-free: Relay strips credential headers before forwarding. HTTPS remains the default, and model content is unencrypted when HTTP is explicitly enabled. Shared TypeScript lifecycle utilities live under [`typescript/common`](typescript/common/README.md). @@ -209,7 +209,7 @@ Agent Trajectory Interchange Format (ATIF). | [Cline](typescript/cline/README.md) | Local `ClineCore` and interactive Cline session | Not supported | Starts on the first prompt, then calls `send()` with the retained session ID | Stops the session, disposes the core, and removes runtime-scoped plugin and data directories | Not implemented | | [Factory Droid](typescript/droid/README.md) | TypeScript SDK `DroidSession` | Not supported | Calls `stream()` for each ordered prompt on the retained session | Closes the session and its caller-installed CLI subprocess | Not implemented | | [OpenCode](typescript/opencode/README.md) | Embedded OpenCode host and session | Not supported | Reuses the session and calls `prompt()`, `wait()`, and `context()` for ordered text input | Removes the session and closes the host | Not implemented | -| [Pi](typescript/pi/README.md) | In-memory Pi `AgentSession` | Runtime-owned Relay 0.9 or 0.10 CLI gateway and explicit Pi extension | Reuses the session and calls `prompt()` for ordered text input; with `streaming=True`, routes per-invocation model-turn ATOF for successful redirects through the embedded collector; startup `model_redirect` marks remain in configured Relay ATOF artifacts and are not included in `invoke_stream()`; `relay_artifacts` does not include local ATIF | Aborts work, emits extension shutdown so local ATIF finalizes on disk, disposes the session, and then stops the gateway | Not implemented | +| [Pi](typescript/pi/README.md) | In-memory Pi `AgentSession` | Runtime-owned Relay 0.9, 0.10, or 0.11 CLI gateway and explicit Pi extension | Reuses the session and calls `prompt()` for ordered text input; with `streaming=True`, routes per-invocation model-turn ATOF for successful redirects through the embedded collector; startup `model_redirect` marks remain in configured Relay ATOF artifacts and are not included in `invoke_stream()`; `relay_artifacts` does not include local ATIF | Aborts work, emits extension shutdown so local ATIF finalizes on disk, disposes the session, and then stops the gateway | Not implemented | | [Qwen Code](typescript/qwen/README.md) | SDK query and bundled Qwen CLI child process | Not supported | Reuses one live SDK query across ordered text turns | Closes the query and removes isolated temporary settings | Not implemented | | [Remote Agent](python/remote-agent/README.md) | `httpx.AsyncClient` and user/assistant transcript | Remote Relay publishes to a shared ATOF collector | Registers the request ID, maps it into body metadata, sends one HTTP request, and retains the completed transcript | Closes the HTTP client | Implemented over HTTP(S) | diff --git a/adapters/python/claude/README.md b/adapters/python/claude/README.md index a6b8ac271..afd1fa345 100644 --- a/adapters/python/claude/README.md +++ b/adapters/python/claude/README.md @@ -154,7 +154,7 @@ Harbor; a Relay trajectory's totals are recorded separately and never fill them. ## Relay Observability -Relay requires a NeMo Relay CLI in the `>=0.9,<0.11` range on `PATH`. The +Relay requires a NeMo Relay CLI in the `>=0.9,<0.12` range on `PATH`. The Claude adapter does not provide a separate `relay` extra; its `harness` and `full` extras install the compatible CLI through `nemo-relay-cli-bin`. The root `nemo-fabric[relay]` extra installs only the Relay Python package. @@ -182,6 +182,31 @@ The NeMo Fabric result includes `relay_runtime.gateway_config_path`, startup failures return a stable adapter error and retain the gateway log for diagnosis. +### Credential-free HTTP model gateways + +For Relay-enabled runs, NeMo Relay CLI 0.11.x supports explicit trust for +HTTP model hosts. Set `harness.settings.insecure_http_model_hosts` to the exact +hostnames or IP addresses of your private inference gateways: + +```python +config.harness.settings["insecure_http_model_hosts"] = ["inference.internal", "10.0.0.10"] +``` + +Entries contain no scheme, port, path, or wildcard. Matching ignores DNS case +and a trailing dot, permits any port or path on that host, and does not infer +trust from DNS resolution. The adapter passes this list to Relay's runtime +`[upstream]` configuration. An explicit empty list clears inherited HTTP trust; +omitting the setting preserves Relay's existing configuration behavior. System +Relay configuration takes precedence and can enforce an empty list. + +This path is for unauthenticated model endpoints: Relay strips authorization, +API-key, cookie, and other credential headers before remote HTTP forwarding, +including model credentials supplied to the harness. Relay rejects conflicting +upstream authorization configuration. Prompts and responses still travel over +plaintext HTTP. HTTPS remains the default. This setting affects Relay-enabled +Codex, Claude, and Pi model forwarding; MCP policy is unchanged. Older Relay CLIs +reject the setting with an upgrade message. + ## Typed Configuration Build the agent configuration with the typed SDK models before invoking diff --git a/adapters/python/claude/claude.fabric-adapter.json b/adapters/python/claude/claude.fabric-adapter.json index 5af1a312f..e60511e9a 100644 --- a/adapters/python/claude/claude.fabric-adapter.json +++ b/adapters/python/claude/claude.fabric-adapter.json @@ -34,6 +34,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "insecure_http_model_hosts": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$", + "format": "ipv6" + } + ] + }, + "uniqueItems": true, + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers." + }, "setting_sources": { "type": "array", "items": { diff --git a/adapters/python/claude/pyproject.toml b/adapters/python/claude/pyproject.toml index c2d0ee278..fc5f295b2 100644 --- a/adapters/python/claude/pyproject.toml +++ b/adapters/python/claude/pyproject.toml @@ -33,11 +33,11 @@ dependencies = [ [project.optional-dependencies] harness = [ "claude-agent-sdk==0.2.165", - "nemo-relay-cli-bin>=0.9,<0.11", + "nemo-relay-cli-bin>=0.9,<0.12", ] full = [ "claude-agent-sdk==0.2.165", - "nemo-relay-cli-bin>=0.9,<0.11", + "nemo-relay-cli-bin>=0.9,<0.12", ] [project.urls] diff --git a/adapters/python/claude/src/nemo_fabric_adapters/claude/adapter.py b/adapters/python/claude/src/nemo_fabric_adapters/claude/adapter.py index 458a58cde..2f51a4a38 100644 --- a/adapters/python/claude/src/nemo_fabric_adapters/claude/adapter.py +++ b/adapters/python/claude/src/nemo_fabric_adapters/claude/adapter.py @@ -45,6 +45,10 @@ from nemo_fabric_adapters.common import lifecycle from nemo_fabric_adapters.common import relay_artifacts from nemo_fabric_adapters.common import relay_gateway +from nemo_fabric_adapters.common.relay_http import ( + RelayHttpModelError, + relay_http_model_config, +) from nemo_fabric_adapters.common import relay_hooks from nemo_fabric_adapters.common import utils as common_utils @@ -515,6 +519,8 @@ def prepare_claude_relay( model: AgentModelConfig, runtime_context: RuntimeContext, base_dir: str, + *, + settings: dict[str, Any] | None = None, ) -> ClaudeRelaySettings | None: """Generate Relay gateway and Claude hook configuration.""" @@ -533,7 +539,8 @@ def prepare_claude_relay( ) from error try: - relay_gateway.relay_cli_contract(executable) + contract = relay_gateway.relay_cli_contract(executable) + http_config = relay_http_model_config(settings or {}, contract) plugin_config = common_utils.load_relay_plugin_config( { "agent_name": agent_name, @@ -543,9 +550,13 @@ def prepare_claude_relay( } ) config_path, plugin_config_path = common_utils.write_relay_configs( - relay_config={"agents": {"claude": {"command": "claude"}}}, + relay_config={"agents": {"claude": {"command": "claude"}}, **http_config}, plugin_config=plugin_config, ) + except RelayHttpModelError as error: + raise AdapterRelayError( + "claude_relay_invalid_http_model_hosts", str(error) + ) from error except ( OSError, RuntimeError, @@ -1082,7 +1093,11 @@ async def start(self, payload: dict[str, Any]) -> None: model = _selected_model_config(agent_config) fabric_runtime_id = runtime_context.runtime_id relay = prepare_claude_relay( - common_utils.agent_name(payload), model, runtime_context, base_dir + common_utils.agent_name(payload), + model, + runtime_context, + base_dir, + settings=_settings(agent_config), ) self._relay = relay self._gateway_process = _start_relay_gateway( @@ -1282,7 +1297,9 @@ def _invocation_cost( ): total = None self._cost_total = total - reset = any(isinstance(message, ConversationResetMessage) for message in messages) + reset = any( + isinstance(message, ConversationResetMessage) for message in messages + ) if total is None or previous is None or reset or total < previous: return None # Drop float subtraction noise such as 0.19999999999999998. A tenth of a diff --git a/adapters/python/claude/uv.lock b/adapters/python/claude/uv.lock index 8a5e2cd61..a660c3745 100644 --- a/adapters/python/claude/uv.lock +++ b/adapters/python/claude/uv.lock @@ -384,8 +384,8 @@ requires-dist = [ { name = "claude-agent-sdk", marker = "extra == 'harness'", specifier = "==0.2.165" }, { name = "nemo-fabric-adapter-contract", editable = "../../../adapter-contract/python" }, { name = "nemo-fabric-adapters-common", editable = "../common" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.11" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.11" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.12" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.12" }, { name = "tomli-w", specifier = "~=1.2" }, ] provides-extras = ["harness", "full"] diff --git a/adapters/python/codex/README.md b/adapters/python/codex/README.md index 3cf1de779..34ee5966e 100644 --- a/adapters/python/codex/README.md +++ b/adapters/python/codex/README.md @@ -147,7 +147,7 @@ while clearing unrelated parent-process secrets. ## Relay Integration -Relay requires a NeMo Relay CLI in the `>=0.9,<0.11` range on `PATH`. The +Relay requires a NeMo Relay CLI in the `>=0.9,<0.12` range on `PATH`. The Codex adapter does not provide a separate `relay` extra; its `harness` and `full` extras install the compatible CLI through `nemo-relay-cli-bin`. The root `nemo-fabric[relay]` extra installs only the Relay Python package. @@ -159,6 +159,31 @@ NeMo Fabric routes the selected Responses-compatible provider through the gateway and passes its explicit `base_url` to Relay as the upstream endpoint. +### Credential-free HTTP model gateways + +For Relay-enabled runs, NeMo Relay CLI 0.11.x supports explicit trust for +HTTP model hosts. Set `harness.settings.insecure_http_model_hosts` to the exact +hostnames or IP addresses of your private inference gateways: + +```python +config.harness.settings["insecure_http_model_hosts"] = ["inference.internal", "10.0.0.10"] +``` + +Entries contain no scheme, port, path, or wildcard. Matching ignores DNS case +and a trailing dot, permits any port or path on that host, and does not infer +trust from DNS resolution. The adapter passes this list to Relay's runtime +`[upstream]` configuration. An explicit empty list clears inherited HTTP trust; +omitting the setting preserves Relay's existing configuration behavior. System +Relay configuration takes precedence and can enforce an empty list. + +This path is for unauthenticated model endpoints: Relay strips authorization, +API-key, cookie, and other credential headers before remote HTTP forwarding, +including model credentials supplied to the harness. Relay rejects conflicting +upstream authorization configuration. Prompts and responses still travel over +plaintext HTTP. HTTPS remains the default. This setting affects Relay-enabled +Codex, Claude, and Pi model forwarding; MCP policy is unchanged. Older Relay CLIs +reject the setting with an upgrade message. + ## Testing Run the unit and opt-in real SDK tests separately: diff --git a/adapters/python/codex/codex.fabric-adapter.json b/adapters/python/codex/codex.fabric-adapter.json index 03819ee12..a7dc4ae03 100644 --- a/adapters/python/codex/codex.fabric-adapter.json +++ b/adapters/python/codex/codex.fabric-adapter.json @@ -34,6 +34,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "insecure_http_model_hosts": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$", + "format": "ipv6" + } + ] + }, + "uniqueItems": true, + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers." + }, "sandbox": { "type": "string", "enum": ["read-only", "workspace-write", "danger-full-access"], diff --git a/adapters/python/codex/pyproject.toml b/adapters/python/codex/pyproject.toml index 9f95f84bf..9353e9d2f 100644 --- a/adapters/python/codex/pyproject.toml +++ b/adapters/python/codex/pyproject.toml @@ -33,11 +33,11 @@ dependencies = [ [project.optional-dependencies] harness = [ "openai-codex==0.154.0", - "nemo-relay-cli-bin>=0.9,<0.11", + "nemo-relay-cli-bin>=0.9,<0.12", ] full = [ "openai-codex==0.154.0", - "nemo-relay-cli-bin>=0.9,<0.11", + "nemo-relay-cli-bin>=0.9,<0.12", ] [project.urls] diff --git a/adapters/python/codex/src/nemo_fabric_adapters/codex/adapter.py b/adapters/python/codex/src/nemo_fabric_adapters/codex/adapter.py index eb698eb5c..b1623d923 100644 --- a/adapters/python/codex/src/nemo_fabric_adapters/codex/adapter.py +++ b/adapters/python/codex/src/nemo_fabric_adapters/codex/adapter.py @@ -55,6 +55,10 @@ from nemo_fabric_adapter_contract.models import RuntimeContext from nemo_fabric_adapters.common import instructions as common_instructions import nemo_fabric_adapters.common.relay_gateway as relay_gateway +from nemo_fabric_adapters.common.relay_http import ( + RelayHttpModelError, + relay_http_model_config, +) import nemo_fabric_adapters.common.relay_hooks as relay_hooks import nemo_fabric_adapters.common.relay_artifacts as relay_artifacts import nemo_fabric_adapters.common.utils as common_utils @@ -790,7 +794,8 @@ def prepare_codex_relay( ) from error try: - relay_gateway.relay_cli_contract(executable) + contract = relay_gateway.relay_cli_contract(executable) + http_config = relay_http_model_config(_settings(config), contract) plugin_config = common_utils.load_relay_plugin_config( { "agent_name": agent_name, @@ -801,9 +806,13 @@ def prepare_codex_relay( ) config_path, plugin_config_path = common_utils.write_relay_configs( # Codex execution remains SDK-owned; Relay runs only as a gateway. - relay_config={}, + relay_config=http_config, plugin_config=plugin_config, ) + except RelayHttpModelError as error: + raise AdapterRelayError( + "codex_relay_invalid_http_model_hosts", str(error) + ) from error except (OSError, RuntimeError, ValueError, json.JSONDecodeError) as error: raise AdapterRelayError( "codex_relay_configuration_failed", diff --git a/adapters/python/codex/uv.lock b/adapters/python/codex/uv.lock index 3d08886dc..bad6b0f8f 100644 --- a/adapters/python/codex/uv.lock +++ b/adapters/python/codex/uv.lock @@ -44,8 +44,8 @@ harness = [ requires-dist = [ { name = "nemo-fabric-adapter-contract", editable = "../../../adapter-contract/python" }, { name = "nemo-fabric-adapters-common", editable = "../common" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.11" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.11" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.12" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.12" }, { name = "openai-codex", marker = "extra == 'full'", specifier = "==0.154.0" }, { name = "openai-codex", marker = "extra == 'harness'", specifier = "==0.154.0" }, { name = "tomli-w", specifier = "~=1.2" }, diff --git a/adapters/python/common/src/nemo_fabric_adapters/common/relay_gateway.py b/adapters/python/common/src/nemo_fabric_adapters/common/relay_gateway.py index 45cf04faa..091fc76b7 100644 --- a/adapters/python/common/src/nemo_fabric_adapters/common/relay_gateway.py +++ b/adapters/python/common/src/nemo_fabric_adapters/common/relay_gateway.py @@ -17,7 +17,7 @@ from pathlib import Path from typing import Any -from nemo_fabric_adapters.common.relay_version import is_supported_relay_version +from nemo_fabric_adapters.common.relay_version import RELAY_MINIMUM_VERSION RELAY_HEALTH_TIMEOUT_SECONDS = 10.0 @@ -97,11 +97,11 @@ def relay_cli_contract(executable: Path) -> RelayCliContract: raise RelayGatewayError("NeMo Relay CLI version could not be determined") major, minor, patch = (int(value) for value in match.groups()[:3]) version = (major, minor, patch) - if match.group(4) is not None or not is_supported_relay_version(version): + if match.group(4) is not None or not RELAY_MINIMUM_VERSION <= version < (0, 12, 0): raise RelayGatewayError( "unsupported NeMo Relay CLI version " f"{'.'.join(str(value) for value in version)}; " - "NeMo Fabric requires >=0.9.0,<0.11.0" + "NeMo Fabric requires >=0.9.0,<0.12.0" ) return RelayCliContract(version=version) diff --git a/adapters/python/common/src/nemo_fabric_adapters/common/relay_http.py b/adapters/python/common/src/nemo_fabric_adapters/common/relay_http.py new file mode 100644 index 000000000..d01eeae52 --- /dev/null +++ b/adapters/python/common/src/nemo_fabric_adapters/common/relay_http.py @@ -0,0 +1,72 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Explicit host trust for credential-free Relay model forwarding.""" + +from __future__ import annotations + +import ipaddress +import re +from typing import Any + +from .relay_gateway import RelayCliContract + +_HOSTNAME = re.compile( + r"[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\.?\Z" +) + + +class RelayHttpModelError(ValueError): + """Invalid or unsupported explicit model-host trust.""" + + +def relay_http_model_config( + settings: dict[str, Any], contract: RelayCliContract +) -> dict[str, Any]: + """Translate explicit harness trust into Relay's upstream configuration.""" + key = "insecure_http_model_hosts" + if key not in settings: + return {} + hosts = settings[key] + if not isinstance(hosts, list): + raise RelayHttpModelError( + f"harness.settings.{key} must be a list of bare hostnames or IP addresses" + ) + normalized: list[str] = [] + for index, host in enumerate(hosts): + if not isinstance(host, str) or not host or len(host) > 253: + raise RelayHttpModelError( + f"harness.settings.{key}[{index}] must be a bare hostname or IP address" + ) + if host.count(":") >= 2: + try: + if "%" in host: + raise ipaddress.AddressValueError( + "scoped addresses are unsupported" + ) + host = str(ipaddress.IPv6Address(host)) + except ipaddress.AddressValueError as error: + raise RelayHttpModelError( + f"harness.settings.{key}[{index}] must be a bare IPv6 address without brackets or a zone identifier" + ) from error + else: + if not _HOSTNAME.fullmatch(host): + raise RelayHttpModelError( + f"harness.settings.{key}[{index}] must be a bare hostname or IP address without a scheme, port, path, or wildcard" + ) + host = host.lower().removesuffix(".") + # Do not reinterpret numeric DNS spellings as alternate IPv4 addresses. + if re.fullmatch(r"(?:[0-9]+|0x[0-9a-f]*)", host.rsplit(".", 1)[-1]): + try: + host = str(ipaddress.IPv4Address(host)) + except ipaddress.AddressValueError as error: + raise RelayHttpModelError( + f"harness.settings.{key}[{index}] must use a canonical IPv4 address" + ) from error + if host not in normalized: + normalized.append(host) + if contract.version < (0, 11, 0): + raise RelayHttpModelError( + f"harness.settings.{key} requires NeMo Relay CLI >=0.11.0; upgrade Relay or remove the setting" + ) + return {"upstream": {key: normalized}} diff --git a/adapters/typescript/pi/README.md b/adapters/typescript/pi/README.md index 98d50a19e..3d6813f9c 100644 --- a/adapters/typescript/pi/README.md +++ b/adapters/typescript/pi/README.md @@ -31,7 +31,7 @@ The adapter supports: - Explicit local `.ts` or `.js` extension files contained by the NeMo Fabric workspace - Slash commands registered by those explicit extensions -- NeMo Relay 0.9 or 0.10 telemetry through a runtime-owned gateway and an explicitly +- NeMo Relay 0.9, 0.10, or 0.11 telemetry through a runtime-owned gateway and an explicitly configured Relay Pi extension - Live model-turn ATOF records for successful Relay redirects through the default embedded NeMo Fabric collector. Startup `model_redirect` marks remain @@ -84,11 +84,11 @@ The full build installs its own dependencies, so you do not need to run ### Install NeMo Relay -Relay-enabled Pi runs require `nemo-relay>=0.9.0,<0.11.0` on `PATH`. Install it +Relay-enabled Pi runs require `nemo-relay>=0.9.0,<0.12.0` on `PATH`. Install it separately from the npm adapter: ```bash -pip install "nemo-relay-cli-bin>=0.9.0,<0.11.0" +pip install "nemo-relay-cli-bin>=0.9.0,<0.12.0" ``` To select a specific Relay executable instead of relying on `PATH`, set @@ -98,10 +98,10 @@ To select a specific Relay executable instead of relying on `PATH`, set FABRIC_NEMO_RELAY_COMMAND="/absolute/path/to/nemo-relay" uv run python your_app.py ``` -The adapter does not bundle the Relay Pi extension. Obtain the -[`crates/cli/assets/pi-extension`](https://github.com/NVIDIA/NeMo-Relay/tree/0.10.0/crates/cli/assets/pi-extension) -directory from the Relay release that matches the CLI and configure its path as described in the -next section. +The adapter does not bundle the Relay Pi extension. Check `nemo-relay --version` +and open the [matching Relay release](https://github.com/NVIDIA/NeMo-Relay/releases). +Extract `crates/cli/assets/pi-extension` from that release's source archive and +configure its path as described in the next section. ## Configure the Adapter @@ -296,3 +296,16 @@ create divergent implementations. `typescript` and `@types/node` are exact-pinned build inputs and are absent from the published production dependency graph. + + +## Credential-free HTTP model gateways + +For Relay-enabled runs, set `harness.settings.insecure_http_model_hosts` to the exact bare DNS hostnames or IP addresses of trusted inference gateways. This requires NeMo Relay CLI 0.11.x; older supported CLIs remain compatible when the setting is omitted. + +```python +config.harness.settings["insecure_http_model_hosts"] = ["inference.internal", "10.0.0.10"] +``` + +Entries have no scheme, port, path, wildcard, brackets, or IPv6 zone identifier. DNS matching ignores case and a trailing dot. Each listed host may use custom ports and paths. NeMo Fabric writes explicit `[]` to revoke inherited trust and preserves omission when the setting is absent. System Relay configuration has higher priority and can enforce an empty list. + +Relay strips authorization, API-key, cookie, custom credential headers, and middleware-added credentials before forwarding remote HTTP model requests, including model credentials supplied to Pi. Configured upstream authentication conflicts with HTTP. Prompts and responses remain unencrypted. HTTPS is the default; this opt-in does not authorize MCP or observability endpoints, caller-selected destinations, or remote HTTP WebSockets. diff --git a/adapters/typescript/pi/pi.fabric-adapter.json b/adapters/typescript/pi/pi.fabric-adapter.json index db31bde6c..54053b7ae 100644 --- a/adapters/typescript/pi/pi.fabric-adapter.json +++ b/adapters/typescript/pi/pi.fabric-adapter.json @@ -26,6 +26,25 @@ "settings_schema": { "type": "object", "properties": { + "insecure_http_model_hosts": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$", + "format": "ipv6" + } + ] + }, + "uniqueItems": true, + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers." + }, "extensions": { "type": "array", "items": { @@ -37,7 +56,7 @@ "relay_extension_path": { "type": "string", "minLength": 1, - "description": "Absolute path or environment.workspace-relative path to the NeMo Relay 0.9 or 0.10 Pi extension" + "description": "Absolute path or environment.workspace-relative path to the NeMo Relay 0.9, 0.10, or 0.11 Pi extension" } }, "additionalProperties": false diff --git a/adapters/typescript/pi/src/pi-sdk.ts b/adapters/typescript/pi/src/pi-sdk.ts index 7bfe57342..81e4a230e 100644 --- a/adapters/typescript/pi/src/pi-sdk.ts +++ b/adapters/typescript/pi/src/pi-sdk.ts @@ -1027,7 +1027,10 @@ export class PiSdkSessionFactory implements PiSessionFactory { const existing = modelRuntime.getModel(selected.provider, selected.model); const catalogEntry = buildCatalogModel(selected, existing); try { - modelRuntime.registerProvider(selected.provider, { models: [catalogEntry] }); + // Keep the endpoint at provider scope so Relay can redirect it without a + // per-model baseUrl taking precedence over the extension's provider override. + const { baseUrl, ...modelDefinition } = catalogEntry; + modelRuntime.registerProvider(selected.provider, { baseUrl, models: [modelDefinition] }); } catch (error) { const cause = error instanceof Error ? error.message : String(error); // Pi throws here with a 'no "api" specified' message when it can't resolve the model's @@ -1119,7 +1122,7 @@ export class PiSdkSessionFactory implements PiSessionFactory { if (relayErrors.length > 0) { throw new LifecycleError( "pi_relay_extension_load_failed", - "The configured NeMo Relay Pi extension failed to load; use the Pi extension from a NeMo Relay 0.9 or 0.10 release", + "The configured NeMo Relay Pi extension failed to load; use the Pi extension from a NeMo Relay 0.9, 0.10, or 0.11 release", { metadata: { count: relayErrors.length, diff --git a/adapters/typescript/pi/src/relay-config.ts b/adapters/typescript/pi/src/relay-config.ts index 4f057cd9a..5fb678148 100644 --- a/adapters/typescript/pi/src/relay-config.ts +++ b/adapters/typescript/pi/src/relay-config.ts @@ -381,7 +381,7 @@ export function encodeToml(value: Record): string { .replace(/\n{3,}/g, "\n\n")}\n`; } -export async function writeRelayConfigs(pluginConfig: RelayPluginConfig): Promise { +export async function writeRelayConfigs(pluginConfig: RelayPluginConfig, gatewayConfig: Record = {}): Promise { const runtimeConfigPath = process.env.FABRIC_RELAY_CONFIG_PATH; if (!runtimeConfigPath) { throw new Error("FABRIC_RELAY_CONFIG_PATH is required when Relay is enabled"); @@ -399,7 +399,7 @@ export async function writeRelayConfigs(pluginConfig: RelayPluginConfig): Promis const pluginConfigPath = join(configDir, "plugins.toml"); await mkdir(configDir, { recursive: true }); await Promise.all([ - writeFile(configPath, encodeToml({}), "utf8"), + writeFile(configPath, encodeToml(gatewayConfig), "utf8"), writeFile(pluginConfigPath, encodeToml(enabledPluginConfig), "utf8"), ]); return { configPath, pluginConfigPath }; diff --git a/adapters/typescript/pi/src/relay-gateway.ts b/adapters/typescript/pi/src/relay-gateway.ts index 163bcac09..5712b97a9 100644 --- a/adapters/typescript/pi/src/relay-gateway.ts +++ b/adapters/typescript/pi/src/relay-gateway.ts @@ -122,9 +122,9 @@ export async function relayCliContract( throw new RelayGatewayError("NeMo Relay CLI version could not be determined"); } const version: [number, number, number] = [Number(match[1]), Number(match[2]), Number(match[3])]; - if (match[4] !== undefined || version[0] !== 0 || (version[1] !== 9 && version[1] !== 10)) { + if (match[4] !== undefined || version[0] !== 0 || (version[1] < 9 || version[1] > 11)) { throw new RelayGatewayError( - `unsupported NeMo Relay CLI version ${version.join(".")}; NeMo Fabric Pi requires >=0.9.0,<0.11.0`, + `unsupported NeMo Relay CLI version ${version.join(".")}; NeMo Fabric Pi requires >=0.9.0,<0.12.0`, ); } return { version }; diff --git a/adapters/typescript/pi/src/relay-http.ts b/adapters/typescript/pi/src/relay-http.ts new file mode 100644 index 000000000..6265c6357 --- /dev/null +++ b/adapters/typescript/pi/src/relay-http.ts @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { isIP } from "node:net"; +import { LifecycleError } from "nemo-fabric-adapters-common"; +import type { JsonObject } from "nemo-fabric-adapter-contract"; +import type { RelayCliContract } from "./relay-gateway.js"; + +const HOSTNAME = + /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\.?$/; + +export function relayHttpModelConfig(settings: JsonObject, contract: RelayCliContract): JsonObject { + const key = "insecure_http_model_hosts"; + if (!Object.hasOwn(settings, key)) { + return {}; + } + const invalid = (detail: string) => + new LifecycleError("pi_relay_invalid_http_model_hosts", `harness.settings.${key} ${detail}`); + const hosts = settings[key]; + if (!Array.isArray(hosts)) { + throw invalid("must be a list of bare hostnames or IP addresses"); + } + const normalized: string[] = []; + for (const [index, host] of hosts.entries()) { + if (typeof host !== "string" || host.length === 0 || host.length > 253 || host.includes("%")) { + throw invalid(`[${index}] must be a bare hostname or IP address`); + } + let value: string; + if (isIP(host) === 6) { + value = new URL(`http://[${host}]`).hostname.slice(1, -1); + } else { + if (!HOSTNAME.test(host)) { + throw invalid(`[${index}] must not include a scheme, port, path, or wildcard`); + } + value = host.toLowerCase().replace(/\.$/, ""); + // WHATWG parsing detects alternate IPv4 spellings and invalid numeric DNS tails. + let parsed: URL; + try { + parsed = new URL(`http://${value}`); + } catch { + throw invalid(`[${index}] must be a bare hostname or canonical IP address`); + } + if (parsed.hostname !== value) { + throw invalid(`[${index}] must use a canonical IP address`); + } + } + if (!normalized.includes(value)) { + normalized.push(value); + } + } + if (contract.version[0] === 0 && contract.version[1] < 11) { + throw invalid("requires NeMo Relay CLI >=0.11.0; upgrade Relay or remove the setting"); + } + return { upstream: { [key]: normalized } }; +} diff --git a/adapters/typescript/pi/src/relay.ts b/adapters/typescript/pi/src/relay.ts index 99e021b40..7f3e7c7d7 100644 --- a/adapters/typescript/pi/src/relay.ts +++ b/adapters/typescript/pi/src/relay.ts @@ -24,14 +24,18 @@ import { startRelayGateway, stopRelayGateway, type RelayGatewayLaunch, + type RelayCliContract, } from "./relay-gateway.js"; +import { relayHttpModelConfig } from "./relay-http.js"; + const RELAY_INSTALL_COMMAND = - 'Install "nemo-relay-cli-bin>=0.9.0,<0.11.0" and ensure nemo-relay is on PATH'; + 'Install "nemo-relay-cli-bin>=0.9.0,<0.12.0" and ensure nemo-relay is on PATH'; const RELAY_EXTENSION_REMEDIATION = - "set harness.settings.relay_extension_path to the NeMo Relay 0.9 or 0.10 Pi extension file or package directory"; + "set harness.settings.relay_extension_path to the NeMo Relay 0.9, 0.10, or 0.11 Pi extension file or package directory"; const RELAY_ENV_NAMES = [ "NEMO_RELAY_PI_GATEWAY_URL", + "NEMO_RELAY_PI_COMMAND", "NEMO_RELAY_PI_OPENAI_UPSTREAM", "NEMO_RELAY_PI_ANTHROPIC_UPSTREAM", ] as const; @@ -122,6 +126,7 @@ function setRelayEnvironment( gatewayUrl: string, model: PiRelayModel, releaseReservation: () => void, + executable: string, ): () => void { const previous = new Map(); for (const name of RELAY_ENV_NAMES) { @@ -129,6 +134,7 @@ function setRelayEnvironment( delete process.env[name]; } process.env.NEMO_RELAY_PI_GATEWAY_URL = gatewayUrl; + process.env.NEMO_RELAY_PI_COMMAND = executable; if (model.api === "openai-completions" || model.api === "openai-responses") { process.env.NEMO_RELAY_PI_OPENAI_UPSTREAM = model.baseUrl; } else if (model.api === "anthropic-messages") { @@ -257,8 +263,9 @@ export class PiRelayFactory implements PiRelayControllerFactory { { metadata: relayErrorMetadata(error) }, ); } + let contract: RelayCliContract; try { - await this.dependencies.checkContract(executable); + contract = await this.dependencies.checkContract(executable); } catch (error) { throw new LifecycleError( "pi_relay_incompatible", @@ -267,13 +274,14 @@ export class PiRelayFactory implements PiRelayControllerFactory { ); } + const gatewayConfig = relayHttpModelConfig(input.config.harness?.settings ?? {}, contract); let pluginConfig: RelayPluginConfig; let atifMatchers: RelayAtifMatcher[]; let configPath: string; let pluginConfigPath: string; try { pluginConfig = await this.dependencies.loadPluginConfig(input); - ({ configPath, pluginConfigPath } = await this.dependencies.writeConfigs(pluginConfig)); + ({ configPath, pluginConfigPath } = await this.dependencies.writeConfigs(pluginConfig, gatewayConfig)); atifMatchers = await prepareRelayAtifMatchers(pluginConfig); } catch (error) { throw new LifecycleError( @@ -312,7 +320,7 @@ export class PiRelayFactory implements PiRelayControllerFactory { metadata: relayErrorMetadata(error, { gateway_log_path: launch.logPath }), }); } - restoreEnvironment = setRelayEnvironment(launch.url, model, releaseEnvironment); + restoreEnvironment = setRelayEnvironment(launch.url, model, releaseEnvironment, launch.executable); const runtime = new PiRelayRuntime({ extensionPath, pluginConfig, diff --git a/adapters/typescript/pi/test/pi-sdk.test.mjs b/adapters/typescript/pi/test/pi-sdk.test.mjs index c5b164251..9f63a8dbb 100644 --- a/adapters/typescript/pi/test/pi-sdk.test.mjs +++ b/adapters/typescript/pi/test/pi-sdk.test.mjs @@ -899,7 +899,7 @@ test("reports an adapter-injected Relay extension load failure separately", asyn }), (error) => error.code === "pi_relay_extension_load_failed" && - error.message.includes("NeMo Relay 0.9 or 0.10 release") && + error.message.includes("NeMo Relay 0.9, 0.10, or 0.11 release") && error.metadata.relay_error.length > 0, ); assert.equal(relayStopped, true); diff --git a/adapters/typescript/pi/test/relay-http.test.mjs b/adapters/typescript/pi/test/relay-http.test.mjs new file mode 100644 index 000000000..b18986df7 --- /dev/null +++ b/adapters/typescript/pi/test/relay-http.test.mjs @@ -0,0 +1,177 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import assert from "node:assert/strict"; +import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import test from "node:test"; +import { relayHttpModelConfig } from "../dist/relay-http.js"; +import { PiRelayFactory } from "../dist/relay.js"; +import { writeRelayConfigs } from "../dist/relay-config.js"; + +const current = { version: [0, 11, 0] }; +const old = { version: [0, 10, 4] }; + +test("preserves omitted trust, explicit denial, and normalized exact hosts", () => { + assert.deepEqual(relayHttpModelConfig({}, old), {}); + assert.deepEqual( + relayHttpModelConfig({ insecure_http_model_hosts: [] }, current), + { + upstream: { insecure_http_model_hosts: [] }, + }, + ); + assert.deepEqual( + relayHttpModelConfig( + { + insecure_http_model_hosts: [ + "MODEL.TEST.", + "model.test", + "192.168.1.10", + "2001:0DB8:0:0::1", + ], + }, + current, + ), + { + upstream: { + insecure_http_model_hosts: [ + "model.test", + "192.168.1.10", + "2001:db8::1", + ], + }, + }, + ); +}); + +for (const hosts of [ + null, + true, + "model.test", + [1], + [""], + ["http://model.test"], + ["model.test:80"], + ["model.test/v1"], + ["*.test"], + ["010.0.0.1"], + ["10.1"], + ["0x7f000001"], + ["0x"], + ["model.0x"], + [" secret"], + ["[2001:db8::1]"], + ["fe80::1%eth0"], + ["2001:db8::g"], +]) { + test(`rejects malformed model-host trust ${JSON.stringify(hosts)}`, () => { + assert.throws( + () => relayHttpModelConfig({ insecure_http_model_hosts: hosts }, current), + { + code: "pi_relay_invalid_http_model_hosts", + }, + ); + }); +} + +for (const hosts of [[], ["model.test"]]) { + test(`requires Relay 0.11 for explicit trust ${JSON.stringify(hosts)}`, () => { + assert.throws( + () => relayHttpModelConfig({ insecure_http_model_hosts: hosts }, old), + /requires NeMo Relay CLI >=0\.11\.0/, + ); + }); +} + +test("factory writes explicit hosts into gateway TOML and rejects old Relay before launch", async () => { + const root = await mkdtemp(join(tmpdir(), "fabric-pi-http-")); + const previous = process.env.FABRIC_RELAY_CONFIG_PATH; + process.env.FABRIC_RELAY_CONFIG_PATH = join(root, "relay.json"); + await writeFile( + join(root, "extension.js"), + "export default function () {}\n", + ); + let version = current; + let launches = 0; + const factory = new PiRelayFactory({ + async resolveCommand() { + return "/opt/bin/nemo-relay"; + }, + async checkContract() { + return version; + }, + async loadPluginConfig() { + return { version: 1, components: [] }; + }, + writeConfigs: writeRelayConfigs, + async findPort() { + return 41001; + }, + async startGateway() { + launches += 1; + return {}; + }, + async stopGateway() {}, + }); + const input = { + agentName: "pi-http", + baseDir: root, + config: { + harness: { + settings: { + relay_extension_path: join(root, "extension.js"), + insecure_http_model_hosts: [], + }, + }, + }, + runtimeContext: { + environment: { workspace: root }, + runtime_id: "pi-http", + telemetry: { relay_enabled: true }, + }, + }; + try { + for (const hosts of [[], ["MODEL.TEST."]]) { + input.config.harness.settings.insecure_http_model_hosts = hosts; + const runtime = await factory.start(input, { + api: "openai-responses", + baseUrl: "http://model.test:8000/v1", + }); + try { + const toml = await readFile( + join(root, "relay-config", "config.toml"), + "utf8", + ); + assert.match(toml, /\[upstream\]/); + assert.ok( + toml.includes( + `insecure_http_model_hosts = ${JSON.stringify(hosts.length === 0 ? [] : ["model.test"])}`, + ), + ); + } finally { + await runtime.stop(); + } + } + version = old; + await assert.rejects( + factory.start(input, { + api: "openai-responses", + baseUrl: "http://model.test:8000/v1", + }), + { code: "pi_relay_invalid_http_model_hosts" }, + ); + assert.equal(launches, 2); + version = current; + const restarted = await factory.start(input, { + api: "openai-responses", + baseUrl: "http://model.test:8000/v1", + }); + await restarted.stop(); + assert.equal(launches, 3); + } finally { + if (previous === undefined) delete process.env.FABRIC_RELAY_CONFIG_PATH; + else process.env.FABRIC_RELAY_CONFIG_PATH = previous; + await rm(root, { recursive: true, force: true }); + } +}); diff --git a/adapters/typescript/pi/test/relay-smoke.test.mjs b/adapters/typescript/pi/test/relay-smoke.test.mjs index 6412be45e..8a628f3c5 100644 --- a/adapters/typescript/pi/test/relay-smoke.test.mjs +++ b/adapters/typescript/pi/test/relay-smoke.test.mjs @@ -15,6 +15,7 @@ import { PiAdapterRuntime } from "../dist/runtime.js"; const execFileAsync = promisify(execFile); const relayCommand = process.env.FABRIC_TEST_NEMO_RELAY_COMMAND; +const remoteHost = process.env.FABRIC_TEST_HTTP_MODEL_HOST; function openAiStream(content) { const chunk = (delta, finishReason = null) => @@ -28,14 +29,14 @@ function openAiStream(content) { return `${chunk({ role: "assistant" })}${chunk({ content })}${chunk({}, "stop")}data: [DONE]\n\n`; } -async function listen(server) { +async function listen(server, host = "127.0.0.1") { await new Promise((resolve, reject) => { server.once("error", reject); - server.listen(0, "127.0.0.1", resolve); + server.listen(0, host, resolve); }); const address = server.address(); assert.notEqual(typeof address, "string"); - return `http://127.0.0.1:${address.port}`; + return `http://${host}:${address.port}`; } async function waitForRecord(records, predicate, timeoutMillis = 1_000) { @@ -51,7 +52,7 @@ async function waitForRecord(records, predicate, timeoutMillis = 1_000) { } test( - "runs the released Relay CLI and shipped Pi extension end to end", + `runs Relay and the shipped Pi extension over ${remoteHost ? "trusted remote HTTP" : "loopback"}`, { skip: relayCommand === undefined ? "set FABRIC_TEST_NEMO_RELAY_COMMAND to the released CLI" : false }, async () => { const root = await realpath(await mkdtemp(join(tmpdir(), "fabric-pi-relay-smoke-"))); @@ -59,6 +60,7 @@ test( const piAgentDir = join(root, "pi-agent"); const runtimeConfigPath = join(root, "relay-runtime.json"); const providerRequests = []; + const providerHeaders = []; const atofRecords = []; const upstream = createServer(async (request, response) => { if (request.method !== "POST" || request.url !== "/v1/chat/completions") { @@ -71,10 +73,11 @@ test( } const payload = JSON.parse(Buffer.concat(chunks).toString("utf8")); providerRequests.push(payload); + providerHeaders.push(request.headers); response.writeHead(200, { "content-type": "text/event-stream" }); response.end(openAiStream("relay smoke ok")); }); - const upstreamUrl = await listen(upstream); + const upstreamUrl = await listen(upstream, remoteHost); const collector = createServer(async (request, response) => { if (request.method !== "POST" || request.url !== "/v1/atof") { response.writeHead(404).end(); @@ -166,7 +169,12 @@ test( agentName: "pi-relay-smoke", baseDir: root, config: { - harness: { settings: { relay_extension_path: extensionPath } }, + harness: { + settings: { + relay_extension_path: extensionPath, + ...(remoteHost ? { insecure_http_model_hosts: [remoteHost] } : {}), + }, + }, models: { default: { api_key_env: "TEST_API_KEY", @@ -205,6 +213,21 @@ test( assert.ok(firstSettled.receivedAt - firstCompletedAt < 1_000); assert.ok(secondSettled.receivedAt - secondCompletedAt < 1_000); assert.equal(providerRequests.length, 2); + assert.equal( + atofRecords.filter( + ({ record }) => record.kind === "scope" && record.category === "llm" && record.scope_category === "start", + ).length, + 2, + ); + for (const headers of providerHeaders) { + if (remoteHost) { + assert.equal(headers.authorization, undefined); + assert.equal(headers["x-api-key"], undefined); + assert.equal(headers.cookie, undefined); + } else { + assert.equal(headers.authorization, "Bearer credential-free-smoke"); + } + } assert.equal(providerRequests[0].model, "openai/gpt-oss-20b"); assert.equal(first.output.relay_artifacts.some((artifact) => artifact.kind === "atif"), false); assert.equal(second.output.relay_artifacts.some((artifact) => artifact.kind === "atif"), false); diff --git a/adapters/typescript/pi/test/relay.test.mjs b/adapters/typescript/pi/test/relay.test.mjs index ee0d541d5..eb6bf99c1 100644 --- a/adapters/typescript/pi/test/relay.test.mjs +++ b/adapters/typescript/pi/test/relay.test.mjs @@ -85,8 +85,8 @@ class MockChild extends EventEmitter { } } -test("accepts only stable NeMo Relay 0.9 and 0.10 CLI versions", async () => { - for (const version of ["0.9.0", "0.9.4", "0.10.0", "0.10.7", "0.10.0+build.4"]) { +test("accepts only stable NeMo Relay 0.9 through 0.11 CLI versions", async () => { + for (const version of ["0.9.0", "0.9.4", "0.10.0", "0.10.7", "0.10.0+build.4", "0.11.0"]) { const contract = await relayCliContract("nemo-relay", async () => ({ stdout: `nemo-relay ${version}\n`, exitCode: 0, @@ -94,13 +94,13 @@ test("accepts only stable NeMo Relay 0.9 and 0.10 CLI versions", async () => { const [, minor, patch] = version.split("+")[0].split(".").map(Number); assert.deepEqual(contract.version, [0, minor, patch]); } - for (const version of ["0.8.9", "0.11.0", "1.0.0", "0.9.0-rc.1", "0.10.0-rc.1"]) { + for (const version of ["0.8.9", "0.12.0", "1.0.0", "0.9.0-rc.1", "0.10.0-rc.1"]) { await assert.rejects( relayCliContract("nemo-relay", async () => ({ stdout: `nemo-relay ${version}\n`, exitCode: 0, })), - />=0\.9\.0,<0\.11\.0/, + />=0\.9\.0,<0\.12\.0/, ); } await assert.rejects( @@ -971,12 +971,14 @@ test("keeps non-Relay startup inert and allows one Relay runtime per process", a await writeFile(extensionPath, "export default function () {}\n", "utf8"); const previous = { gateway: process.env.NEMO_RELAY_PI_GATEWAY_URL, + hookCommand: process.env.NEMO_RELAY_PI_COMMAND, openai: process.env.NEMO_RELAY_PI_OPENAI_UPSTREAM, anthropic: process.env.NEMO_RELAY_PI_ANTHROPIC_UPSTREAM, relayCommand: process.env.FABRIC_NEMO_RELAY_COMMAND, testRelayCommand: process.env.FABRIC_TEST_NEMO_RELAY_COMMAND, }; process.env.NEMO_RELAY_PI_GATEWAY_URL = "http://ambient.invalid"; + process.env.NEMO_RELAY_PI_COMMAND = "/ambient/nemo-relay"; process.env.NEMO_RELAY_PI_ANTHROPIC_UPSTREAM = "https://ambient.invalid"; process.env.FABRIC_NEMO_RELAY_COMMAND = "/opt/relay-0.10/bin/nemo-relay"; process.env.FABRIC_TEST_NEMO_RELAY_COMMAND = "/opt/test/bin/nemo-relay"; @@ -993,6 +995,7 @@ test("keeps non-Relay startup inert and allows one Relay runtime per process", a undefined, ); assert.equal(process.env.NEMO_RELAY_PI_GATEWAY_URL, "http://ambient.invalid"); + assert.equal(process.env.NEMO_RELAY_PI_COMMAND, "/ambient/nemo-relay"); const mockChild = new MockChild(); let startAttempts = 0; @@ -1037,6 +1040,7 @@ test("keeps non-Relay startup inert and allows one Relay runtime per process", a }; const runtime = await factory.start(input, model); assert.equal(process.env.NEMO_RELAY_PI_GATEWAY_URL, "http://127.0.0.1:41001"); + assert.equal(process.env.NEMO_RELAY_PI_COMMAND, "/opt/bin/nemo-relay"); assert.equal(process.env.NEMO_RELAY_PI_OPENAI_UPSTREAM, "https://api.openai.com/v1"); assert.equal(process.env.NEMO_RELAY_PI_ANTHROPIC_UPSTREAM, undefined); await assert.rejects( @@ -1052,10 +1056,12 @@ test("keeps non-Relay startup inert and allows one Relay runtime per process", a ); assert.equal(stopAttempts, 1); assert.equal(process.env.NEMO_RELAY_PI_GATEWAY_URL, "http://127.0.0.1:41001"); + assert.equal(process.env.NEMO_RELAY_PI_COMMAND, "/opt/bin/nemo-relay"); await runtime.stop(); await runtime.stop(); assert.equal(stopAttempts, 2); assert.equal(process.env.NEMO_RELAY_PI_GATEWAY_URL, "http://ambient.invalid"); + assert.equal(process.env.NEMO_RELAY_PI_COMMAND, "/ambient/nemo-relay"); assert.equal(process.env.NEMO_RELAY_PI_OPENAI_UPSTREAM, undefined); assert.equal(process.env.NEMO_RELAY_PI_ANTHROPIC_UPSTREAM, "https://ambient.invalid"); @@ -1064,9 +1070,11 @@ test("keeps non-Relay startup inert and allows one Relay runtime per process", a await restarted.stop(); assert.equal(stopAttempts, 3); assert.equal(process.env.NEMO_RELAY_PI_GATEWAY_URL, "http://ambient.invalid"); + assert.equal(process.env.NEMO_RELAY_PI_COMMAND, "/ambient/nemo-relay"); } finally { for (const [name, value] of [ ["NEMO_RELAY_PI_GATEWAY_URL", previous.gateway], + ["NEMO_RELAY_PI_COMMAND", previous.hookCommand], ["NEMO_RELAY_PI_OPENAI_UPSTREAM", previous.openai], ["NEMO_RELAY_PI_ANTHROPIC_UPSTREAM", previous.anthropic], ["FABRIC_NEMO_RELAY_COMMAND", previous.relayCommand], @@ -1104,7 +1112,7 @@ test("maps Relay setup failures to stable Pi adapter errors", async () => { }).start(input, model), (error) => error.code === "pi_relay_unavailable" && - error.message.includes('Install "nemo-relay-cli-bin>=0.9.0,<0.11.0"') && + error.message.includes('Install "nemo-relay-cli-bin>=0.9.0,<0.12.0"') && error.metadata.relay_error === "missing", ); await assert.rejects( diff --git a/adapters/typescript/scripts/check-package.mjs b/adapters/typescript/scripts/check-package.mjs index ef6c77b2f..77bfd5a67 100644 --- a/adapters/typescript/scripts/check-package.mjs +++ b/adapters/typescript/scripts/check-package.mjs @@ -67,6 +67,8 @@ const expectedByPackage = { "dist/relay-config.js", "dist/relay-gateway.d.ts", "dist/relay-gateway.js", + "dist/relay-http.d.ts", + "dist/relay-http.js", "dist/relay.d.ts", "dist/relay.js", "dist/runtime.d.ts", diff --git a/crates/fabric-cli/assets/adapters/claude/claude.fabric-adapter.json b/crates/fabric-cli/assets/adapters/claude/claude.fabric-adapter.json index 5af1a312f..e60511e9a 100644 --- a/crates/fabric-cli/assets/adapters/claude/claude.fabric-adapter.json +++ b/crates/fabric-cli/assets/adapters/claude/claude.fabric-adapter.json @@ -34,6 +34,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "insecure_http_model_hosts": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$", + "format": "ipv6" + } + ] + }, + "uniqueItems": true, + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers." + }, "setting_sources": { "type": "array", "items": { diff --git a/crates/fabric-cli/assets/adapters/codex/codex.fabric-adapter.json b/crates/fabric-cli/assets/adapters/codex/codex.fabric-adapter.json index 03819ee12..a7dc4ae03 100644 --- a/crates/fabric-cli/assets/adapters/codex/codex.fabric-adapter.json +++ b/crates/fabric-cli/assets/adapters/codex/codex.fabric-adapter.json @@ -34,6 +34,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "insecure_http_model_hosts": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$", + "format": "ipv6" + } + ] + }, + "uniqueItems": true, + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers." + }, "sandbox": { "type": "string", "enum": ["read-only", "workspace-write", "danger-full-access"], diff --git a/docs/getting-started/install.mdx b/docs/getting-started/install.mdx index d474aae42..ec7c0c011 100644 --- a/docs/getting-started/install.mdx +++ b/docs/getting-started/install.mdx @@ -325,10 +325,10 @@ removed `RelayOtlpConfig` model with `RelayOpenTelemetryConfig` and one or more Claude and Codex harness extras install their compatible CLI binary without the Relay Python package. Pi requires a separate CLI installation alongside -the npm adapter. Install the `>=0.9,<0.11` range: +the npm adapter. Install the `>=0.9,<0.12` range: ```bash -pip install "nemo-relay-cli-bin>=0.9,<0.11" +pip install "nemo-relay-cli-bin>=0.9,<0.12" ``` If `cargo-binstall` is available, install the pinned CLI with Cargo: @@ -338,13 +338,18 @@ cargo binstall nemo-relay-cli --version 0.10.0 ``` After installation, run `nemo-relay --version` and confirm the version is in -the `>=0.9,<0.11` range. When Relay is enabled with +the `>=0.9,<0.12` range. When Relay is enabled with `FabricConfig.enable_relay(...)`, the Claude, Codex, and Pi adapters start and supervise the CLI gateway automatically. -The Pi adapter also requires a user-supplied path to the -[Relay Pi extension](https://github.com/NVIDIA/NeMo-Relay/tree/0.10.0/crates/cli/assets/pi-extension) -from the Relay release that matches the CLI. +Explicit `harness.settings.insecure_http_model_hosts` requires Relay CLI 0.11.x. +It permits credential-free remote HTTP model traffic, with unencrypted prompts +and responses. Omit the setting to retain compatibility with older CLIs. + +The Pi adapter also requires a user-supplied extension path. Check +`nemo-relay --version` and open the +[matching Relay release](https://github.com/NVIDIA/NeMo-Relay/releases). +Extract `crates/cli/assets/pi-extension` from that release's source archive. Set `harness.settings.relay_extension_path` to the extension file or package directory; relative paths resolve from `environment.workspace`. Relay-enabled diff --git a/docs/integrations/harness/claude.mdx b/docs/integrations/harness/claude.mdx index f83fde4c3..d86d62c9c 100644 --- a/docs/integrations/harness/claude.mdx +++ b/docs/integrations/harness/claude.mdx @@ -176,8 +176,26 @@ gateway is scoped to that single invocation. Claude still resolves its credentia through the selected mode, and NeMo Fabric does not write authentication values to Relay configuration or artifacts. -NeMo Fabric supports the external NeMo Relay CLI in the `>=0.9,<0.11` range. +NeMo Fabric supports the external NeMo Relay CLI in the `>=0.9,<0.12` range. NeMo Fabric's `relay` extra installs only the Relay Python library and does not install the CLI. NeMo Fabric owns sidecar supervision, Claude configuration, and upstream selection. Relay owns the gateway transport and semantic observability pipeline. + +## Private HTTP model gateways with Relay + +Relay-enabled runs can set `harness.settings.insecure_http_model_hosts` to an +explicit list of hostnames or IP addresses, for example +`["inference.internal", "10.0.0.10"]`. This requires NeMo Relay CLI 0.11.x. +Entries have no scheme, port, path, or wildcard; matching ignores DNS case and a +trailing dot and permits any port or path on the listed host. An explicit empty +list clears inherited HTTP trust. Omitting the setting preserves existing Relay +configuration behavior. System Relay configuration takes precedence and can +enforce an empty list. + +Use this for unauthenticated inference gateways. Relay strips authorization, +API-key, cookie, and other credential headers before remote HTTP forwarding, +including credentials provided to the harness, and rejects conflicting upstream +authorization configuration. Prompts and responses travel unencrypted. HTTPS +remains the default, and MCP policy is unchanged. This option applies to +Relay-enabled Codex, Claude, and Pi runs. diff --git a/docs/integrations/harness/codex.mdx b/docs/integrations/harness/codex.mdx index a8c4b3564..867db62ef 100644 --- a/docs/integrations/harness/codex.mdx +++ b/docs/integrations/harness/codex.mdx @@ -193,7 +193,7 @@ NeMo Fabric supplies runtime-scoped Relay configuration to the SDK. It does not copy the Codex credential store into Relay configuration or persist credentials in Relay artifacts. -NeMo Fabric supports the external NeMo Relay CLI in the `>=0.9,<0.11` range. +NeMo Fabric supports the external NeMo Relay CLI in the `>=0.9,<0.12` range. NeMo Fabric's `relay` extra installs only the Relay Python library and does not install the CLI. NeMo Fabric owns sidecar supervision and runtime-scoped SDK configuration. Relay owns gateway transport behavior, @@ -229,3 +229,21 @@ Relay produces a chain root with LLM and tool children, decoded request and response values, and token usage. This is the recommended mode for reviewing an agent turn in Phoenix. Use native Codex OpenTelemetry only when the raw app-server trace is the required diagnostic surface. + +## Private HTTP model gateways with Relay + +Relay-enabled runs can set `harness.settings.insecure_http_model_hosts` to an +explicit list of hostnames or IP addresses, for example +`["inference.internal", "10.0.0.10"]`. This requires NeMo Relay CLI 0.11.x. +Entries have no scheme, port, path, or wildcard; matching ignores DNS case and a +trailing dot and permits any port or path on the listed host. An explicit empty +list clears inherited HTTP trust. Omitting the setting preserves existing Relay +configuration behavior. System Relay configuration takes precedence and can +enforce an empty list. + +Use this for unauthenticated inference gateways. Relay strips authorization, +API-key, cookie, and other credential headers before remote HTTP forwarding, +including credentials provided to the harness, and rejects conflicting upstream +authorization configuration. Prompts and responses travel unencrypted. HTTPS +remains the default, and MCP policy is unchanged. This option applies to +Relay-enabled Codex, Claude, and Pi runs. diff --git a/docs/integrations/harness/pi.mdx b/docs/integrations/harness/pi.mdx index 41e8bc760..ce8fb7f93 100644 --- a/docs/integrations/harness/pi.mdx +++ b/docs/integrations/harness/pi.mdx @@ -46,11 +46,11 @@ The full build installs its own dependencies, so you do not need to run ### Install NeMo Relay -Relay-enabled Pi runs require `nemo-relay>=0.9.0,<0.11.0` on `PATH`. Install it +Relay-enabled Pi runs require `nemo-relay>=0.9.0,<0.12.0` on `PATH`. Install it separately from the npm adapter: ```bash -pip install "nemo-relay-cli-bin>=0.9.0,<0.11.0" +pip install "nemo-relay-cli-bin>=0.9.0,<0.12.0" ``` To select a specific Relay executable instead of relying on `PATH`, set @@ -60,10 +60,10 @@ To select a specific Relay executable instead of relying on `PATH`, set FABRIC_NEMO_RELAY_COMMAND="/absolute/path/to/nemo-relay" uv run python your_app.py ``` -The adapter does not bundle the Relay Pi extension. Obtain the -[`crates/cli/assets/pi-extension`](https://github.com/NVIDIA/NeMo-Relay/tree/0.10.0/crates/cli/assets/pi-extension) -directory from the Relay release that matches the CLI and configure its path as described in the -next section. +The adapter does not bundle the Relay Pi extension. Check `nemo-relay --version` +and open the [matching Relay release](https://github.com/NVIDIA/NeMo-Relay/releases). +Extract `crates/cli/assets/pi-extension` from that release's source archive and +configure its path as described in the next section. ## Configure the Adapter @@ -244,7 +244,7 @@ adapter process, so concurrent NeMo Fabric runtimes remain isolated. Direct embedders must likewise place concurrent Relay-enabled Pi runtimes in separate processes. -The released Relay 0.9 and 0.10 Pi extensions emit `turn_end` and close the per-turn +The Relay 0.9, 0.10, and 0.11 Pi extensions emit `turn_end` and close the per-turn scope, but its local ATIF trajectory remains attached to Pi's session-level agent scope. Relay therefore finalizes that trajectory only after the Pi session closes. It is not included in the invocation's `relay_artifacts`. The adapter @@ -360,3 +360,16 @@ resources remain disabled. The Relay extension does not add those resources. The Relay Pi hook route is available only on the loopback gateway and does not authenticate hook posts. Treat the loopback port as a local trust boundary. + + +## Credential-free HTTP model gateways + +For Relay-enabled runs, set `harness.settings.insecure_http_model_hosts` to the exact bare DNS hostnames or IP addresses of trusted inference gateways. This requires NeMo Relay CLI 0.11.x; older supported CLIs remain compatible when the setting is omitted. + +```python +config.harness.settings["insecure_http_model_hosts"] = ["inference.internal", "10.0.0.10"] +``` + +Entries have no scheme, port, path, wildcard, brackets, or IPv6 zone identifier. DNS matching ignores case and a trailing dot. Each listed host may use custom ports and paths. NeMo Fabric writes explicit `[]` to revoke inherited trust and preserves omission when the setting is absent. System Relay configuration has higher priority and can enforce an empty list. + +Relay strips authorization, API-key, cookie, custom credential headers, and middleware-added credentials before forwarding remote HTTP model requests, including model credentials supplied to Pi. Configured upstream authentication conflicts with HTTP. Prompts and responses remain unencrypted. HTTPS is the default; this opt-in does not authorize MCP or observability endpoints, caller-selected destinations, or remote HTTP WebSockets. diff --git a/docs/sdk/python.mdx b/docs/sdk/python.mdx index fce63d695..3a83178d7 100644 --- a/docs/sdk/python.mdx +++ b/docs/sdk/python.mdx @@ -902,7 +902,7 @@ Streaming has the following v0.1 constraints: when it is deployed beyond a trusted local boundary. Claude and Codex streaming use the NeMo Relay `nemo-relay` gateway CLI and -require a release in the `>=0.9,<0.11` range. Their adapter `harness` and +require a release in the `>=0.9,<0.12` range. Their adapter `harness` and `full` extras install the supported CLI. Deep Agents uses its in-process NeMo Relay integration. Hermes Agent uses its in-process Relay integration when installed from the merged Relay 0.10 Hermes revision in a separate Python 3.14 diff --git a/examples/README.md b/examples/README.md index b4e936dc0..8c84ac528 100644 --- a/examples/README.md +++ b/examples/README.md @@ -38,7 +38,7 @@ just build-all --input "Reply with exactly: NeMo Fabric works" ``` -The Pi variant supports Relay telemetry with `nemo-relay>=0.9.0,<0.11.0` and an +The Pi variant supports Relay telemetry with `nemo-relay-cli-bin>=0.9.0,<0.12.0` and an explicit extension path. Pass `--variant pi --relay --stream --pi-relay-extension-path ` to collect per-invocation model-turn ATOF records for successful Relay redirects, then diff --git a/examples/code_review_agent/README.md b/examples/code_review_agent/README.md index f34f546bb..7f7794d41 100644 --- a/examples/code_review_agent/README.md +++ b/examples/code_review_agent/README.md @@ -131,7 +131,7 @@ harness supports. Codex and Claude omit the default code-review skill; add `--skill-path ./skills/code-review` to retain it. Relay configurations for -Codex, Claude, and Pi require a NeMo Relay CLI in the `>=0.9,<0.11` range. +Codex, Claude, and Pi require a NeMo Relay CLI in the `>=0.9,<0.12` range. Pi also requires its Relay Pi extension. Hermes Agent and Deep Agents require the `nemo-relay>=0.9,<0.11` Python package. Cline does not support Relay telemetry in this initial adapter. @@ -422,7 +422,7 @@ This variant adds an explicit `read` tool to the default code-review skill and uses `NVIDIA_API_KEY`. Pi supports normalized stdio and streamable HTTP MCP servers. -For Relay telemetry, install `nemo-relay-cli-bin>=0.9.0,<0.11.0` as described in the +For Relay telemetry, install `nemo-relay-cli-bin>=0.9.0,<0.12.0` as described in the [Pi adapter instructions](../../adapters/typescript/pi/README.md#install-nemo-relay) and pass the Relay Pi extension path explicitly: diff --git a/examples/code_review_agent/__main__.py b/examples/code_review_agent/__main__.py index bb26f4f51..007eed4cf 100644 --- a/examples/code_review_agent/__main__.py +++ b/examples/code_review_agent/__main__.py @@ -86,7 +86,7 @@ async def main() -> None: parser.add_argument( "--pi-relay-extension-path", metavar="PATH", - help="Path to the NeMo Relay 0.9 or 0.10 Pi extension file or package directory.", + help="Path to the NeMo Relay 0.9, 0.10, or 0.11 Pi extension file or package directory.", ) skill_group = parser.add_mutually_exclusive_group() skill_group.add_argument( @@ -162,7 +162,10 @@ async def main() -> None: parser.error("--stream requires --relay") if args.stream and args.plan: parser.error("--stream cannot be combined with --plan") - if args.variant in {"cline", "droid", "kilo", "openclaw", "openhands", "qwen"} and args.relay: + if ( + args.variant in {"cline", "droid", "kilo", "openclaw", "openhands", "qwen"} + and args.relay + ): display_name = { "cline": "Cline", "droid": "Factory Droid", diff --git a/examples/harbor/README.md b/examples/harbor/README.md index ca7a9a085..10bf34a60 100644 --- a/examples/harbor/README.md +++ b/examples/harbor/README.md @@ -76,8 +76,8 @@ version `0.6.0`. | Claude task without Relay | `nemo-fabric[claude]==0.6.0` | NeMo Fabric runner, Claude adapter, and supported Claude harness | | Codex task | `nemo-fabric[codex]==0.6.0` | NeMo Fabric runner, Codex adapter, and SDK-managed app-server; the calculator image installs the local adapter source with its `harness` extra | | Pi task | `nemo-fabric==0.6.0`, `nemo-fabric-adapters-pi@0.6.0`, and a compatible Pi SDK harness | NeMo Fabric runner and task-local Pi adapter descriptor; the calculator image builds both from the vendored source | -| Claude task with Relay | `nemo-fabric[claude]==0.6.0` plus a NeMo Relay CLI in the `>=0.9,<0.11` range on `PATH` | NeMo Fabric runner, Claude adapter and harness, and the adapter-managed Relay gateway and hooks | -| Pi task with Relay | `nemo-fabric==0.6.0`, `nemo-fabric-adapters-pi@0.6.0`, a compatible Pi SDK harness, `nemo-relay-cli-bin>=0.9.0,<0.11.0` on `PATH`, and the matching Relay Pi extension | NeMo Fabric runner, Pi adapter and harness, and the adapter-managed Relay gateway and extension | +| Claude task with Relay | `nemo-fabric[claude]==0.6.0` plus a NeMo Relay CLI in the `>=0.9,<0.12` range on `PATH` | NeMo Fabric runner, Claude adapter and harness, and the adapter-managed Relay gateway and hooks | +| Pi task with Relay | `nemo-fabric==0.6.0`, `nemo-fabric-adapters-pi@0.6.0`, a compatible Pi SDK harness, `nemo-relay-cli-bin>=0.9.0,<0.12.0` on `PATH`, and the matching Relay Pi extension | NeMo Fabric runner, Pi adapter and harness, and the adapter-managed Relay gateway and extension | | Hermes Agent task with Relay | Task image with a Relay 0.10-compatible Hermes Agent, `nemo-fabric==0.6.0`, `nemo-fabric-adapters-hermes==0.6.0`, and `nemo-relay>=0.10,<0.11` | NeMo Fabric runner, preinstalled Hermes Agent and adapter, and the NeMo Relay Python package | | OpenClaw task | Node.js 24.16+ or 26.1+, OpenClaw, `nemo-fabric==0.6.0`, and `nemo-fabric-adapters-openclaw==0.6.0` | NeMo Fabric runner, OpenClaw adapter, and the adapter-managed local OpenClaw Gateway | | NOOA BenchAgent task | `nemo-fabric==0.6.0` and `nemo-fabric-adapters-nooa[harness]==0.6.0` | NeMo Fabric runner, the packaged BenchAgent adapter and descriptors, and tested NOOA harness packages | diff --git a/examples/harbor/swebench/adapters/claude/claude.fabric-adapter.json b/examples/harbor/swebench/adapters/claude/claude.fabric-adapter.json index 5af1a312f..e60511e9a 100644 --- a/examples/harbor/swebench/adapters/claude/claude.fabric-adapter.json +++ b/examples/harbor/swebench/adapters/claude/claude.fabric-adapter.json @@ -34,6 +34,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "insecure_http_model_hosts": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$", + "format": "ipv6" + } + ] + }, + "uniqueItems": true, + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers." + }, "setting_sources": { "type": "array", "items": { diff --git a/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json b/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json index 4c15e1112..79c007019 100644 --- a/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json +++ b/sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json @@ -136,6 +136,25 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": false, "properties": { + "insecure_http_model_hosts": { + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers.", + "items": { + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "format": "ipv6", + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$" + } + ], + "maxLength": 253, + "minLength": 1, + "type": "string" + }, + "type": "array", + "uniqueItems": true + }, "max_budget_usd": { "description": "Maximum amount in US dollars that Claude may spend during one invocation.", "exclusiveMinimum": 0, @@ -196,7 +215,7 @@ "name": "nemo-fabric-adapters-claude", "version": "0.6.0" }, - "sha256": "cded65f1e927f3b7154f79b3eb6312a5fa34551265ffe6df1ec271e55de9c407", + "sha256": "21ec5223d90e45a7ed5fec497aae1053abc9e1cd9c187c6232391b3121e7f826", "source": "adapters/python/claude/claude.fabric-adapter.json" }, "nvidia.fabric.cline": { @@ -460,6 +479,25 @@ "minLength": 1, "type": "string" }, + "insecure_http_model_hosts": { + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers.", + "items": { + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "format": "ipv6", + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$" + } + ], + "maxLength": 253, + "minLength": 1, + "type": "string" + }, + "type": "array", + "uniqueItems": true + }, "output_schema": { "description": "JSON Schema that constrains the final assistant message for each turn.", "type": "object" @@ -530,7 +568,7 @@ "name": "nemo-fabric-adapters-codex", "version": "0.6.0" }, - "sha256": "f66fb66d3a366977619bc9e88a4d926e0b71bbc28ac965b9a416bf2559106ce5", + "sha256": "9774ce9ece27435ac81db07abdd144e80bb6e9bcaaf5d27ea90522b27925009b", "source": "adapters/python/codex/codex.fabric-adapter.json" }, "nvidia.fabric.droid": { @@ -2054,8 +2092,27 @@ "type": "array", "uniqueItems": true }, + "insecure_http_model_hosts": { + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay >=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone identifiers.", + "items": { + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "format": "ipv6", + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$" + } + ], + "maxLength": 253, + "minLength": 1, + "type": "string" + }, + "type": "array", + "uniqueItems": true + }, "relay_extension_path": { - "description": "Absolute path or environment.workspace-relative path to the NeMo Relay 0.9 or 0.10 Pi extension", + "description": "Absolute path or environment.workspace-relative path to the NeMo Relay 0.9, 0.10, or 0.11 Pi extension", "minLength": 1, "type": "string" } @@ -2101,7 +2158,7 @@ "name": "nemo-fabric-adapters-pi", "version": "0.6.0" }, - "sha256": "3cb85c7a0e52e49827e889631da96ca7936c7260d52aac8b52835484a0cafad9", + "sha256": "2c95a4cc2290969eab023f537bd35fec9dc78d51b88214d694417a278eaedc2c", "source": "adapters/typescript/pi/pi.fabric-adapter.json" }, "nvidia.fabric.qwen": { diff --git a/sdk/python/nemo-fabric/uv.lock b/sdk/python/nemo-fabric/uv.lock index 0742bcb06..83d6f84e1 100644 --- a/sdk/python/nemo-fabric/uv.lock +++ b/sdk/python/nemo-fabric/uv.lock @@ -1978,8 +1978,8 @@ requires-dist = [ { name = "claude-agent-sdk", marker = "extra == 'harness'", specifier = "==0.2.165" }, { name = "nemo-fabric-adapter-contract", editable = "../../../adapter-contract/python" }, { name = "nemo-fabric-adapters-common", editable = "../../../adapters/python/common" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.11" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.11" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.12" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.12" }, { name = "tomli-w", specifier = "~=1.2" }, ] provides-extras = ["harness", "full"] @@ -2004,8 +2004,8 @@ harness = [ requires-dist = [ { name = "nemo-fabric-adapter-contract", editable = "../../../adapter-contract/python" }, { name = "nemo-fabric-adapters-common", editable = "../../../adapters/python/common" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.11" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.11" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.12" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.12" }, { name = "openai-codex", marker = "extra == 'full'", specifier = "==0.154.0" }, { name = "openai-codex", marker = "extra == 'harness'", specifier = "==0.154.0" }, { name = "tomli-w", specifier = "~=1.2" }, diff --git a/tests/adapters/test_adapters_common_relay_gateway.py b/tests/adapters/test_adapters_common_relay_gateway.py index c307254ae..0b542e761 100644 --- a/tests/adapters/test_adapters_common_relay_gateway.py +++ b/tests/adapters/test_adapters_common_relay_gateway.py @@ -54,6 +54,7 @@ def test_resolve_relay_command_rejects_missing_executable(monkeypatch, tmp_path) ("nemo-relay 0.10.0\n", (0, 10, 0)), ("nemo-relay 0.10.0+build.1\n", (0, 10, 0)), ("nemo-relay 0.10.99\n", (0, 10, 99)), + ("nemo-relay 0.11.0\n", (0, 11, 0)), ], ) def test_relay_cli_contract_selects_compatible_contract( @@ -76,7 +77,7 @@ def test_relay_cli_contract_selects_compatible_contract( "nemo-relay 0.8.3", "nemo-relay 0.9.0-alpha.20260811", "nemo-relay 0.10.0-alpha.20260918", - "nemo-relay 0.11.0", + "nemo-relay 0.12.0", "nemo-relay 1.0.0", ], ) @@ -89,7 +90,7 @@ def test_relay_cli_contract_rejects_unsupported_version(monkeypatch, tmp_path, o with pytest.raises( relay_gateway.RelayGatewayError, - match=r"NeMo Fabric requires >=0\.9\.0,<0\.11\.0", + match=r"NeMo Fabric requires >=0\.9\.0,<0\.12\.0", ): relay_gateway.relay_cli_contract(tmp_path / "nemo-relay") diff --git a/tests/adapters/test_claude_adapter.py b/tests/adapters/test_claude_adapter.py index e7b17060f..7bab23824 100644 --- a/tests/adapters/test_claude_adapter.py +++ b/tests/adapters/test_claude_adapter.py @@ -103,6 +103,7 @@ def prepare_claude_relay(payload: dict[str, Any]): adapter._selected_model_config(config), runtime_context(payload), payload["base_dir"], + settings=adapter._settings(config), ) @@ -183,6 +184,27 @@ def test_claude_descriptor_is_narrow_and_versioned(): "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { + "insecure_http_model_hosts": { + "type": "array", + "items": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "anyOf": [ + { + "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\.?$" + }, + { + "pattern": "^[0-9A-Fa-f:.]*:[0-9A-Fa-f:.]*$", + "format": "ipv6", + }, + ], + }, + "uniqueItems": True, + "description": "Hosts trusted for credential-free HTTP model forwarding through NeMo Relay " + ">=0.11.0; no schemes, ports, paths, wildcards, brackets, or zone " + "identifiers.", + }, "setting_sources": { "type": "array", "items": { @@ -507,8 +529,7 @@ async def test_claude_invoke_passes_remaining_budget_to_query( after = loop.time() invocation_deadline = remaining_timeout.call_args.args[0] expected_timeout = ( - claude_payload["runtime_context"]["deadline_millis"] / 1000 - - time.time() + claude_payload["runtime_context"]["deadline_millis"] / 1000 - time.time() ) assert ( before + expected_timeout - 0.1 @@ -2123,3 +2144,62 @@ def test_main_serves_persistent_runtime(monkeypatch): serve.assert_called_once_with( adapter.ClaudeRuntime, config_loader=AgentConfig.from_mapping ) + + +@pytest.mark.parametrize("hosts", [["MODEL.TEST."], []]) +def test_claude_relay_propagates_explicit_http_model_hosts( + relay_payload, monkeypatch, tmp_path, hosts +): + relay_payload["config"]["harness"]["settings"]["insecure_http_model_hosts"] = hosts + monkeypatch.setattr( + adapter.relay_gateway, + "resolve_relay_command", + MagicMock(return_value=tmp_path / "nemo-relay"), + ) + monkeypatch.setattr( + adapter.relay_gateway, + "relay_cli_contract", + MagicMock( + return_value=adapter.relay_gateway.RelayCliContract(version=(0, 11, 0)) + ), + ) + monkeypatch.setattr(adapter, "_stage_relay_plugin", MagicMock()) + relay = prepare_claude_relay(relay_payload) + with relay.gateway.config_path.open("rb") as stream: + config = tomllib.load(stream) + assert config["upstream"]["insecure_http_model_hosts"] == ( + ["model.test"] if hosts else [] + ) + assert config["agents"]["claude"]["command"] == "claude" + + +@pytest.mark.parametrize( + ("hosts", "version", "message"), + [ + (["model.test:80"], (0, 11, 0), "insecure_http_model_hosts"), + (["model.test"], (0, 10, 4), ">=0.11.0"), + ([], (0, 10, 4), ">=0.11.0"), + ], +) +def test_claude_relay_reports_invalid_or_unsupported_http_model_hosts( + relay_payload, monkeypatch, tmp_path, hosts, version, message +): + relay_payload["config"]["harness"]["settings"]["insecure_http_model_hosts"] = hosts + monkeypatch.setattr( + adapter.relay_gateway, + "resolve_relay_command", + MagicMock(return_value=tmp_path / "nemo-relay"), + ) + monkeypatch.setattr( + adapter.relay_gateway, + "relay_cli_contract", + MagicMock(return_value=adapter.relay_gateway.RelayCliContract(version=version)), + ) + write_configs = MagicMock() + monkeypatch.setattr(adapter.common_utils, "write_relay_configs", write_configs) + with pytest.raises(adapter.AdapterRelayError, match=message) as caught: + prepare_claude_relay(relay_payload) + + assert caught.value.code == "claude_relay_invalid_http_model_hosts" + assert isinstance(caught.value.__cause__, adapter.RelayHttpModelError) + write_configs.assert_not_called() diff --git a/tests/adapters/test_codex_adapter.py b/tests/adapters/test_codex_adapter.py index ec62b55ac..5c38b8676 100644 --- a/tests/adapters/test_codex_adapter.py +++ b/tests/adapters/test_codex_adapter.py @@ -2105,3 +2105,78 @@ def test_main_serves_persistent_runtime(monkeypatch): serve.assert_called_once_with( adapter.CodexRuntime, config_loader=AgentConfig.from_mapping ) + + +@pytest.mark.parametrize("hosts", [["MODEL.TEST."], []]) +def test_codex_relay_propagates_explicit_http_model_hosts( + codex_payload, monkeypatch, tmp_path, hosts +): + import tomllib + + codex_payload["config"]["harness"]["settings"]["insecure_http_model_hosts"] = hosts + codex_payload["runtime_context"]["telemetry"] = { + "relay_enabled": True, + "metadata": {"telemetry_providers": ["relay"]}, + } + intent = tmp_path / "relay.json" + intent.write_text( + json.dumps({"relay": {"config": {"version": 1, "components": []}}}) + ) + os.environ["FABRIC_RELAY_CONFIG_PATH"] = str(intent) + monkeypatch.setattr( + adapter.relay_gateway, + "resolve_relay_command", + MagicMock(return_value=tmp_path / "nemo-relay"), + ) + monkeypatch.setattr( + adapter.relay_gateway, + "relay_cli_contract", + MagicMock( + return_value=adapter.relay_gateway.RelayCliContract(version=(0, 11, 0)) + ), + ) + config, context, base_dir = runtime_input(codex_payload) + relay = adapter.prepare_codex_relay( + codex_payload["agent_name"], config, context, base_dir + ) + with relay.gateway.config_path.open("rb") as stream: + gateway_config = tomllib.load(stream) + assert gateway_config == { + "upstream": {"insecure_http_model_hosts": (["model.test"] if hosts else [])} + } + + +@pytest.mark.parametrize( + ("hosts", "version", "message"), + [ + (["model.test:80"], (0, 11, 0), "insecure_http_model_hosts"), + (["model.test"], (0, 10, 4), ">=0.11.0"), + ([], (0, 10, 4), ">=0.11.0"), + ], +) +def test_codex_relay_reports_invalid_or_unsupported_http_model_hosts( + codex_payload, monkeypatch, tmp_path, hosts, version, message +): + codex_payload["config"]["harness"]["settings"]["insecure_http_model_hosts"] = hosts + codex_payload["runtime_context"]["telemetry"] = {"relay_enabled": True} + monkeypatch.setattr( + adapter.relay_gateway, + "resolve_relay_command", + MagicMock(return_value=tmp_path / "nemo-relay"), + ) + monkeypatch.setattr( + adapter.relay_gateway, + "relay_cli_contract", + MagicMock(return_value=adapter.relay_gateway.RelayCliContract(version=version)), + ) + write_configs = MagicMock() + monkeypatch.setattr(adapter.common_utils, "write_relay_configs", write_configs) + config, context, base_dir = runtime_input(codex_payload) + with pytest.raises(adapter.AdapterRelayError, match=message) as caught: + adapter.prepare_codex_relay( + codex_payload["agent_name"], config, context, base_dir + ) + + assert caught.value.code == "codex_relay_invalid_http_model_hosts" + assert isinstance(caught.value.__cause__, adapter.RelayHttpModelError) + write_configs.assert_not_called() diff --git a/tests/adapters/test_pi_adapter.py b/tests/adapters/test_pi_adapter.py index c5fca8ec5..64b59b12e 100644 --- a/tests/adapters/test_pi_adapter.py +++ b/tests/adapters/test_pi_adapter.py @@ -71,7 +71,7 @@ def test_pi_descriptor_declares_the_supported_surface(): "minLength": 1, "description": ( "Absolute path or environment.workspace-relative path to the " - "NeMo Relay 0.9 or 0.10 Pi extension" + "NeMo Relay 0.9, 0.10, or 0.11 Pi extension" ), } assert descriptor["extension_schemas"]["run_result"] == { diff --git a/tests/adapters/test_relay_http_model_hosts.py b/tests/adapters/test_relay_http_model_hosts.py new file mode 100644 index 000000000..b71bd544a --- /dev/null +++ b/tests/adapters/test_relay_http_model_hosts.py @@ -0,0 +1,83 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +import pytest +from nemo_fabric_adapters.common.relay_gateway import RelayCliContract +from nemo_fabric_adapters.common.relay_http import ( + RelayHttpModelError, + relay_http_model_config, +) + + +def test_relay_http_hosts_preserve_absence_and_explicit_revocation(): + old = RelayCliContract(version=(0, 10, 4)) + new = RelayCliContract(version=(0, 11, 0)) + assert relay_http_model_config({}, old) == {} + assert relay_http_model_config({"insecure_http_model_hosts": []}, new) == { + "upstream": {"insecure_http_model_hosts": []} + } + assert relay_http_model_config( + { + "insecure_http_model_hosts": [ + "MODEL.TEST.", + "model.test", + "192.168.1.10", + "2001:0DB8:0:0::1", + ] + }, + new, + ) == { + "upstream": { + "insecure_http_model_hosts": ["model.test", "192.168.1.10", "2001:db8::1"] + } + } + + +@pytest.mark.parametrize( + "hosts", + [ + None, + True, + "model.test", + [1], + [""], + ["http://model.test"], + ["model.test:80"], + ["model.test/v1"], + ["*.test"], + ["010.0.0.1"], + ["10.1"], + ["0x7f000001"], + ["0x"], + ["model.0x"], + [" secret"], + ["[2001:db8::1]"], + ["fe80::1%eth0"], + ["2001:db8::g"], + ], +) +def test_relay_http_hosts_reject_invalid_trust(hosts): + with pytest.raises(RelayHttpModelError, match="insecure_http_model_hosts"): + relay_http_model_config( + {"insecure_http_model_hosts": hosts}, RelayCliContract(version=(0, 11, 0)) + ) + + +@pytest.mark.parametrize("hosts", [[], ["model.test"]]) +def test_relay_http_hosts_require_supported_relay(hosts): + with pytest.raises(RelayHttpModelError, match=">=0.11.0"): + relay_http_model_config( + {"insecure_http_model_hosts": hosts}, RelayCliContract(version=(0, 10, 4)) + ) + + +@pytest.mark.parametrize( + "host", ["model.test:80", "http://model.test", "https://model.test"] +) +def test_relay_http_hosts_diagnose_schemes_and_ports(host): + with pytest.raises( + RelayHttpModelError, match="without a scheme, port, path, or wildcard" + ): + relay_http_model_config( + {"insecure_http_model_hosts": [host]}, RelayCliContract(version=(0, 11, 0)) + ) diff --git a/tests/e2e/test_relay_http_models.py b/tests/e2e/test_relay_http_models.py new file mode 100644 index 000000000..5046cf0e5 --- /dev/null +++ b/tests/e2e/test_relay_http_models.py @@ -0,0 +1,151 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Local-model integration gate using real coding harnesses and Relay >=0.11. + +RUN_FABRIC_RELAY_HTTP_INTEGRATION=1 FABRIC_TEST_NEMO_RELAY_COMMAND=/path/to/nemo-relay \ + uv run pytest tests/e2e/test_relay_http_models.py +""" + +import json +import os +import socket +import threading +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer + +import pytest +from _utils.mock_api_server import _messages_text_events, _responses_text_events +from nemo_fabric import ( + EnvironmentConfig, + Fabric, + FabricConfig, + FabricRuntimeError, + HarnessConfig, + MetadataConfig, + ModelConfig, + RelayAtifConfig, + RelayObservabilityConfig, + RuntimeConfig, +) + +pytestmark = pytest.mark.skipif( + os.environ.get("RUN_FABRIC_RELAY_HTTP_INTEGRATION") != "1", + reason="set RUN_FABRIC_RELAY_HTTP_INTEGRATION=1 and select a Relay >=0.11 CLI", +) + + +@pytest.fixture(name="http_model_endpoint") +def http_model_endpoint_fixture(): + # Use this machine's non-loopback address so Relay's remote-HTTP policy runs. + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as route: + route.connect(("192.0.2.1", 80)) + host = route.getsockname()[0] + captured = [] + + class ModelHandler(BaseHTTPRequestHandler): + def log_message(self, *_args): + pass + + def do_POST(self): + payload = json.loads(self.rfile.read(int(self.headers["Content-Length"]))) + captured.append({key.lower(): value for key, value in self.headers.items()}) + events = ( + _responses_text_events(payload, "echo response") + if self.path == "/v1/responses" + else _messages_text_events(payload, "echo response") + ) + body = "".join(events).encode() + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + with ThreadingHTTPServer((host, 0), ModelHandler) as server: + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + try: + yield host, f"http://{host}:{server.server_port}/v1", captured + finally: + server.shutdown() + thread.join(timeout=5) + + +@pytest.mark.parametrize("adapter_id", ["codex", "claude"]) +@pytest.mark.parametrize( + "trust", ["allowed", "omitted", "wrong-host", "relay-disabled"] +) +async def test_relay_http_model_forwarding( + http_model_endpoint, tmp_path, adapter_id, trust +): + host, base_url, captured = http_model_endpoint + settings = {} + if trust in {"allowed", "wrong-host"}: + settings["insecure_http_model_hosts"] = [ + host if trust == "allowed" else "other.invalid" + ] + os.environ["XDG_CONFIG_HOME"] = str(tmp_path / "xdg") + os.environ["NEMO_RELAY_CONFIG_SCOPE"] = "user" + config = FabricConfig( + metadata=MetadataConfig(name="relay-http-smoke"), + harness=HarnessConfig( + adapter_id=f"nvidia.fabric.{adapter_id}", + resolution="preinstalled", + settings=settings, + ), + models={ + "default": ModelConfig( + provider="fabric-test", + model="fabric-echo", + api_key_env="FABRIC_TEST_API_KEY", + base_url=base_url, + ) + }, + runtime=RuntimeConfig( + input_schema="text" if adapter_id == "codex" else "chat", + output_schema="message", + artifacts=tmp_path / "artifacts", + ), + environment=EnvironmentConfig( + provider="local", + workspace=tmp_path, + artifacts=tmp_path / "artifacts", + env={"FABRIC_TEST_API_KEY": "dummy-private-model-key"}, + ), + ) + if trust != "relay-disabled": + config.enable_relay( + output_dir=tmp_path / "telemetry", + observability=RelayObservabilityConfig( + atif=RelayAtifConfig( + enabled=True, output_directory=tmp_path / "telemetry" + ) + ), + ) + if trust in {"omitted", "wrong-host"}: + with pytest.raises( + FabricRuntimeError, match=f"{adapter_id}_relay_start_failed" + ): + await Fabric().run(config, base_dir=tmp_path, input="Reply echo response.") + assert captured == [] + return + + result = await Fabric().run(config, base_dir=tmp_path, input="Reply echo response.") + assert result.status == "succeeded", result.to_mapping() + assert result.output["response"] == "echo response" + assert captured + if trust == "relay-disabled": + assert any( + headers.get("authorization") == "Bearer dummy-private-model-key" + or headers.get("x-api-key") == "dummy-private-model-key" + for headers in captured + ) + return + for headers in captured: + assert ( + not {"authorization", "x-api-key", "cookie", "proxy-authorization"} + & headers.keys() + ) + assert any( + artifact["kind"] == "atif" for artifact in result.output["relay_artifacts"] + ) diff --git a/uv.lock b/uv.lock index 4dc516537..84b7b24ba 100644 --- a/uv.lock +++ b/uv.lock @@ -2412,8 +2412,8 @@ requires-dist = [ { name = "claude-agent-sdk", marker = "extra == 'harness'", specifier = "==0.2.165" }, { name = "nemo-fabric-adapter-contract", editable = "adapter-contract/python" }, { name = "nemo-fabric-adapters-common", editable = "adapters/python/common" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.11" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.11" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.12" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.12" }, { name = "tomli-w", specifier = "~=1.2" }, ] provides-extras = ["harness", "full"] @@ -2438,8 +2438,8 @@ harness = [ requires-dist = [ { name = "nemo-fabric-adapter-contract", editable = "adapter-contract/python" }, { name = "nemo-fabric-adapters-common", editable = "adapters/python/common" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.11" }, - { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.11" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'full'", specifier = ">=0.9,<0.12" }, + { name = "nemo-relay-cli-bin", marker = "extra == 'harness'", specifier = ">=0.9,<0.12" }, { name = "openai-codex", marker = "extra == 'full'", specifier = "==0.154.0" }, { name = "openai-codex", marker = "extra == 'harness'", specifier = "==0.154.0" }, { name = "tomli-w", specifier = "~=1.2" },