Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions crates/nemoclaw-e2e/cases/docker-openclaw-hermes-interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
# SPDX-License-Identifier: Apache-2.0

# OpenClaw's Control UI and Hermes's API server and dashboard behind a managed
# Docker gateway, on a stub model that answers every chat completion with the
# same reply, followed by the skills whose markers the request holds, and
# refuses any request without the run's key. Apply reports each interface; a
# person reaches it with the pinned OpenShell CLI's forward and the token
# apply names. cargo ci live-docker gives each run a fresh identity, gateway
# port and subnet, stub address, volume names, and agent images. Only claw
# grants python3 the stub's /health, which the managed inference grant leaves
# out. Each agent's skills.directories lists a writable folder of skills and
# Docker gateway, on a stub model that answers every chat completion and
# Anthropic Messages request with the same reply, followed by the skills whose
# markers the request holds, and refuses any request without the run's key.
# A second Hermes agent, in hermes-messages, reaches the stub through an
# anthropic provider: Hermes calls the Messages API, and the provider places
# the key in x-api-key. Apply reports each interface; a person reaches it with
# the pinned OpenShell CLI's forward and the token apply names. cargo ci
# live-docker gives each run a fresh identity, gateway port and subnet, stub
# address, volume names, and agent images. Only claw grants python3 the
# stub's /health, which the managed inference grant leaves out. The claw and
# hermes agents' skills.directories each list a writable folder of skills and
# a skill on its own volume, read-only for claw and writable for hermes, and
# refuses duplicate names; Hermes's folder is empty.
# refuse duplicate names; Hermes's folder is empty.
apiVersion: nemoclaw.nvidia.com/v1alpha1
kind: NemoClawConfig
metadata:
Expand All @@ -36,6 +39,17 @@ spec:
endpoint: http://172.30.123.1:17699/v1
credential:
env: NEMOCLAW_TEST_INTERFACES_MODEL_KEY
# The stub serves the Messages API under /anthropic, as Anthropic-compatible
# gateways do. Hermes calls https://api.anthropic.com instead of an
# anthropic provider's endpoint unless the endpoint's host is an
# Anthropic, Claude, or Azure host or its path ends in /anthropic or
# /anthropic/v1.
messages:
provider: anthropic
api: anthropic-messages
endpoint: http://172.30.123.1:17699/anthropic/v1
credential:
env: NEMOCLAW_TEST_INTERFACES_MODEL_KEY
sandboxes:
claw:
image:
Expand Down Expand Up @@ -125,3 +139,22 @@ spec:
providerRef: model
overrides:
model: fixture-model
hermes-messages:
image:
ref: nc-fabric-hermes@sha256:0000000000000000000000000000000000000000000000000000000000000000
network:
tier: isolated
harness:
kind: nvidia.fabric.hermes
settings:
interfaces:
api:
port: 8642
agent:
name: hermes-messages
inference:
routes:
- name: primary
providerRef: messages
overrides:
model: fixture-model
79 changes: 67 additions & 12 deletions crates/nemoclaw-e2e/tests/e2e/hcl/model/main.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# A stub OpenAI-compatible model for a Docker case, run with the bundled
# Docker provider on the case's engine before its first apply: the pinned
# nginx-unprivileged image the development issuer runs, on the host network
# at the port the case's `model` provider names. It lists one model and
# answers every chat completion with `reply`, streamed when the request asks,
# followed by the name of each of `markers` that the request holds, so a
# test can see what an agent sent the model. It refuses any request without
# `Authorization: Bearer KEY`. The test runner removes it after the case.
# A stub model for a Docker case, run with the bundled Docker provider on the
# case's engine before its first apply: the pinned nginx-unprivileged image
# the development issuer runs, on the host network at the port the case's
# `model` provider names. It lists one model and answers every OpenAI chat
# completion, and every Anthropic Messages request at /anthropic/v1/messages
# as Anthropic-compatible gateways serve them, with `reply`, streamed when the
# request asks, followed by the name of each of `markers` that the request
# holds, so a test can see what an agent sent the model. It refuses a
# Messages request without `x-api-key: KEY`, where Anthropic's API takes the
# key, and any other request without `Authorization: Bearer KEY`. The test
# runner removes it after the case.

terraform {
required_version = "= 1.13.9"
Expand All @@ -33,7 +36,7 @@ variable "key" {
}

variable "reply" {
description = "The text that starts every completion."
description = "The text that starts every completion and message."
type = string
# nginx puts the reply in a header and in the completion's JSON unescaped.
validation {
Expand All @@ -43,7 +46,7 @@ variable "reply" {
}

variable "markers" {
description = "By name, text to look for in each chat completion request. The completion names each marker its request holds, in name order, after the reply."
description = "By name, text to look for in each chat completion or Messages request. The completion or message names each marker its request holds, in name order, after the reply."
type = map(string)
default = {}
# nginx matches the text as a regular expression and puts the name in the
Expand Down Expand Up @@ -94,7 +97,41 @@ locals {
choices = [{ index = 0, delta = chunk.delta, finish_reason = chunk.finish }]
}, chunk.usage == null ? {} : { usage = chunk.usage }))}\\n\\n"
], ["data: [DONE]\\n\\n"]))
# The request body selects a streamed reply and the completion's text. nginx
# A Messages reply, and the events that stream it.
message = jsonencode({
id = "msg_nemoclaw_stub"
type = "message"
role = "assistant"
model = "fixture-model"
content = [{ type = "text", text = "$http_x_reply" }]
stop_reason = "end_turn"
stop_sequence = null
usage = { input_tokens = 1, output_tokens = 1 }
})
events = [
{
type = "message_start"
message = {
id = "msg_nemoclaw_stub"
type = "message"
role = "assistant"
model = "fixture-model"
content = []
stop_reason = null
stop_sequence = null
usage = { input_tokens = 1, output_tokens = 0 }
}
},
{ type = "content_block_start", index = 0, content_block = { type = "text", text = "" } },
{ type = "content_block_delta", index = 0, delta = { type = "text_delta", text = "$http_x_reply" } },
{ type = "content_block_stop", index = 0 },
{ type = "message_delta", delta = { stop_reason = "end_turn", stop_sequence = null }, usage = { output_tokens = 1 } },
{ type = "message_stop" },
]
message_stream = join("", [
for event in local.events : "event: ${event.type}\\ndata: ${jsonencode(event)}\\n\\n"
])
# The request body selects a streamed reply and the reply's text. nginx
# reads the body before it sends the proxied request, so the second server
# sees both as headers.
config = <<-EOT
Expand All @@ -116,7 +153,9 @@ locals {
${local.marker_maps}
server {
listen ${local.port};
if ($http_authorization != "Bearer ${var.key}") { return 401; }
set $credential $http_authorization;
if ($uri = /anthropic/v1/messages) { set $credential "Bearer $http_x_api_key"; }
if ($credential != "Bearer ${var.key}") { return 401; }
location = /v1/models {
default_type application/json;
return 200 '${local.models}';
Expand All @@ -128,6 +167,13 @@ locals {
proxy_set_header X-Reply "${local.text}";
proxy_pass http://unix:/tmp/stub.sock:/completion;
}
location = /anthropic/v1/messages {
client_body_buffer_size 1m;
client_body_in_single_buffer on;
proxy_set_header X-Reply-Kind $reply_kind;
proxy_set_header X-Reply "${local.text}";
proxy_pass http://unix:/tmp/stub.sock:/message;
}
location / { return 404; }
}
server {
Expand All @@ -141,6 +187,15 @@ locals {
default_type text/event-stream;
return 200 '${local.stream}';
}
location = /message {
if ($http_x_reply_kind = stream) { rewrite ^ /message-stream last; }
default_type application/json;
return 200 '${local.message}';
}
location = /message-stream {
default_type text/event-stream;
return 200 '${local.message_stream}';
}
}
}
EOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
# it. OpenClaw's terminal UI, opened with the dashboard's token through
# `openshell sandbox exec --tty`, shows the stub's reply to a prompt and exits
# on Ctrl-D. The stub refuses requests without the run's key, so the reply
# also shows NemoClaw sent the configured key. In each sandbox,
# also shows NemoClaw sent the configured key. In hermes-messages, whose
# agent reaches the stub through an anthropic provider, Hermes's API server
# answers a chat completion with the stub's reply too; the stub accepts a
# Messages request's key only in x-api-key, so the reply shows that Hermes
# called Anthropic's Messages API with the key where the provider places it.
# In claw and hermes,
# the agent's user can write and read a file in the agent's workspace, and
# the key is not in the environment a command sees. In hermes, a command can
# open a pseudo-terminal, as browser chat does. In claw, python3 reaches
Expand Down Expand Up @@ -95,6 +100,7 @@ run "apply" {
"claw/dashboard/18789/token_in_url_fragment/true",
"hermes/api/8642/bearer_token/true",
"hermes/dashboard/9119/none/false",
"hermes-messages/api/8642/bearer_token/true",
])
error_message = "Apply must report each interface with its port, sign-in, and token file."
}
Expand Down Expand Up @@ -140,6 +146,18 @@ run "interfaces" {
}
answer = "nemoclaw-stub-reply notes"
}
# This agent has no skills, so the reply names none.
messages_chat = {
sandbox = "hermes-messages"
port = 8642
token_path = one([for access in run.apply.result.interfaces : access.tokenPath if access.sandbox == "hermes-messages"])
path = "/v1/chat/completions"
body = {
model = "hermes-agent"
messages = [{ role = "user", content = "Reply to this NemoClaw live test." }]
}
answer = "nemoclaw-stub-reply"
}
dashboard = {
sandbox = "hermes"
port = 9119
Expand Down
4 changes: 3 additions & 1 deletion image/fabric/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ COPY --from=hermes-assets --chmod=0644 /sources/hermes.tar.gz /opt/nemoclaw/sour
COPY --from=switchyard-assets /opt/nemo-relay /opt/nemo-relay
# Hermes owns its dependencies: its own lock, with the mcp extra, settles the
# packages it shares with Fabric, as Fabric installs into Hermes's environment.
# Hermes needs the anthropic extra's SDK to call a model through an anthropic
# provider, and can't install it later because lazy installs are disabled.
# From the messaging extra, only aiohttp, which Hermes's API server needs, is
# installed; the messaging platform clients are pruned.
# Hermes's lock overrides some dependencies' requirements, such as
Expand All @@ -154,7 +156,7 @@ COPY --from=switchyard-assets /opt/nemo-relay /opt/nemo-relay
# check failures those overrides cause, as Hermes's installer does.
# Hermes resolves bundled assets relative to its source checkout.
RUN --mount=from=uv,source=/uv,target=/usr/local/bin/uv --mount=type=cache,target=/root/.cache/uv \
uv export --project /opt/hermes --frozen --no-dev --extra mcp --extra messaging \
uv export --project /opt/hermes --frozen --no-dev --extra anthropic --extra mcp --extra messaging \
--prune discord-py --prune python-telegram-bot --prune slack-bolt --prune slack-sdk --prune qrcode --prune brotlicffi \
--no-emit-project --format requirements-txt --output-file /opt/nemoclaw/source/hermes-requirements.txt \
&& uv pip install --python /opt/fabric/bin/python --require-hashes --no-deps -r /opt/nemoclaw/source/hermes-requirements.txt \
Expand Down
Loading
Loading