From 6eea9b7420f5a570d00c0da88a88e2c35f36d04c Mon Sep 17 00:00:00 2001 From: Will Curran Date: Wed, 8 Jul 2026 15:08:24 -0700 Subject: [PATCH 1/5] feat(hermes): upgrade to v0.18 with Slack Block Kit Upgrade Hermes to v2026.7.1 / 0.18.0. Apply schema 32 migration and enable upstream Slack rich blocks. Verify native Block Kit table rendering in the existing live probe. Fixes #6443 Refs #5591 Signed-off-by: Will Curran --- agents/hermes/Dockerfile | 8 ++-- agents/hermes/Dockerfile.base | 10 ++--- agents/hermes/config/hermes-config.ts | 6 ++- agents/hermes/hermes-wrapper.py | 6 +-- agents/hermes/manifest.yaml | 6 +-- agents/hermes/patch-session-list-preview.py | 4 +- docs/manage-sandboxes/messaging-channels.mdx | 4 ++ src/lib/messaging/channels/manifests.test.ts | 1 + src/lib/messaging/channels/slack/manifest.ts | 3 ++ test/e2e/live/hermes-slack-e2e-helpers.ts | 43 ++++++++++++++++++++ test/generate-hermes-config.test.ts | 13 ++++-- test/hermes-doctor-config-hash.test.ts | 4 +- test/update-hermes-agent-script.test.ts | 8 ++-- 13 files changed, 89 insertions(+), 27 deletions(-) diff --git a/agents/hermes/Dockerfile b/agents/hermes/Dockerfile index afb144f068d..263be1f2028 100644 --- a/agents/hermes/Dockerfile +++ b/agents/hermes/Dockerfile @@ -175,7 +175,7 @@ RUN chmod 755 /usr/local/bin/nemoclaw-start /usr/local/lib/nemoclaw/sandbox-init RUN test -x /usr/local/lib/nemoclaw/validate-hermes-env-secret-boundary.py \ || { echo "ERROR: validate-hermes-env-secret-boundary.py missing or not executable" >&2; exit 1; } -# Hermes v0.17.0 computes `sessions list` preview from the first user message, +# Hermes v0.18.0 computes `sessions list` preview from the first user message, # while #5254's user-facing expectation is that the existing row reflects the # latest resumed/continued one-shot turn. Patch only the pinned query shape and # prove the SessionDB list contract at build time so a Hermes update cannot @@ -203,7 +203,7 @@ PY # chain tampering of the build context (an attacker rewriting the file has to # also rewrite the Dockerfile-committed hash, which reviewers gate). Regenerate # with `sha256sum agents/hermes/{hermes-wrapper.py,validate-env-secret-boundary.py}`. -ARG NEMOCLAW_HERMES_WRAPPER_SHA256=34ef50ea993c776f28312bcf659e908eeae3c07e4094a49e513cb320eee6538f +ARG NEMOCLAW_HERMES_WRAPPER_SHA256=ec8b0e4d6254175929d5a02240acd6af25e94774a30b36ba5c6f5a69c32fb9d7 ARG NEMOCLAW_HERMES_VALIDATOR_SHA256=970d7ff03bc409ff1d5ca46bfdbd2a42ac28a32a810ccc147a508301bff38496 # hadolint ignore=DL4006 RUN printf '%s %s\n' \ @@ -232,10 +232,10 @@ RUN hermes_version_output="$(/usr/local/bin/hermes --version)" \ echo "ERROR: could not parse Hermes semver from: $hermes_version_output" >&2; \ exit 1; \ fi \ - && if [ "$hermes_semver" != "0.17.0" ] \ + && if [ "$hermes_semver" != "0.18.0" ] \ && { grep -q '_translate_resumed_oneshot' /usr/local/lib/nemoclaw/hermes-wrapper.py \ || grep -q 'EXPECTED_OCCURRENCES' /usr/local/lib/nemoclaw/patch-hermes-session-list-preview.py; }; then \ - echo "ERROR: installed Hermes ${hermes_semver} but Hermes v0.17.0 compatibility workarounds are still installed; re-review #5254 workaround removal before upgrading Hermes" >&2; \ + echo "ERROR: installed Hermes ${hermes_semver} but Hermes v0.18.0 compatibility workarounds are still installed; re-review #5254 workaround removal before upgrading Hermes" >&2; \ exit 1; \ fi # This runs before `/usr/local/bin/hermes` is moved to `hermes.real`, so the diff --git a/agents/hermes/Dockerfile.base b/agents/hermes/Dockerfile.base index b191bde74de..1281cf4b7b7 100644 --- a/agents/hermes/Dockerfile.base +++ b/agents/hermes/Dockerfile.base @@ -28,11 +28,11 @@ ENV DEBIAN_FRONTEND=noninteractive # pyproject.toml, HERMES_TARBALL_SHA256 the GitHub tarball checksum, and # HERMES_NPM_INTEGRITY the `npm view hermes-agent@ dist.integrity` # sha512 used as a registry cross-check at build time. -# Calver tag v2026.6.19 = Hermes Agent v0.17.0. -ARG HERMES_VERSION=v2026.6.19 -ARG HERMES_SEMVER=0.17.0 -ARG HERMES_TARBALL_SHA256=69b805ec0a7a7be880068ba8a3b17479d7ba29f0cac0a2e9c6692c02f346ba91 -ARG HERMES_NPM_INTEGRITY=sha512-PzSJiYqmwpTudmakYs2oCJ57OW3VwEJYf8buTuKvuRvcYEUf/KOTu2dD6pLf2XYgDKErpvcDaoSAJ1nGCyvzAA== +# Calver tag v2026.7.1 = Hermes Agent v0.18.0. +ARG HERMES_VERSION=v2026.7.1 +ARG HERMES_SEMVER=0.18.0 +ARG HERMES_TARBALL_SHA256=ec8a380629cc2f3f2102dd92cad50c4ded706fe59c0e359a05681166a0ae2991 +ARG HERMES_NPM_INTEGRITY=sha512-fS+8MsE69shNPmFnKDrE1a+KUDEEXgbyN/QM7J+2nh294gTjh2wCknk2tfMsD03GhSxl7YwyDmp6e5HLYzw8yA== ARG HERMES_UV_EXTRAS="anthropic messaging web pty mcp" ARG UV_VERSION=0.11.8 diff --git a/agents/hermes/config/hermes-config.ts b/agents/hermes/config/hermes-config.ts index 4bf2cc30564..694a33525e3 100644 --- a/agents/hermes/config/hermes-config.ts +++ b/agents/hermes/config/hermes-config.ts @@ -103,7 +103,7 @@ export function buildHermesConfig( }; const config: Record = { - _config_version: 30, + _config_version: 32, _nemoclaw_upstream: upstream, model: modelConfig, providers: { @@ -117,6 +117,10 @@ export function buildHermesConfig( agent: { max_turns: 60, reasoning_effort: "medium", + // Hermes config migrations v30 -> v32 disable the old implicit + // verify-on-stop behavior once. Generated configs start at v32, so + // persist the same migrated value instead of inheriting "auto". + verify_on_stop: false, }, tools: { tool_search: { diff --git a/agents/hermes/hermes-wrapper.py b/agents/hermes/hermes-wrapper.py index a707f5e4035..3879b6b2fcb 100755 --- a/agents/hermes/hermes-wrapper.py +++ b/agents/hermes/hermes-wrapper.py @@ -289,9 +289,9 @@ def _run_gateway_guard(guard_path: str) -> int: "--resume": "--resume", } # Keep this allowlist aligned with the top-level flags accepted by the pinned -# Hermes Agent CLI in agents/hermes/Dockerfile.base (HERMES_VERSION=v2026.6.19, -# HERMES_SEMVER=0.17.0) and agents/hermes/manifest.yaml (expected_version -# "0.17.0"). Unknown flags deliberately fail closed by passing the original argv +# Hermes Agent CLI in agents/hermes/Dockerfile.base (HERMES_VERSION=v2026.7.1, +# HERMES_SEMVER=0.18.0) and agents/hermes/manifest.yaml (expected_version +# "0.18.0"). Unknown flags deliberately fail closed by passing the original argv # through to upstream Hermes. _BOOLEAN_FLAGS = { "--worktree", diff --git a/agents/hermes/manifest.yaml b/agents/hermes/manifest.yaml index e9e6e01bee0..2cf9fb4e8a6 100644 --- a/agents/hermes/manifest.yaml +++ b/agents/hermes/manifest.yaml @@ -16,9 +16,9 @@ homepage: "https://github.com/NousResearch/hermes-agent" install_method: curl # curl install.sh | bash binary_path: /usr/local/bin/hermes version_command: "hermes --version" -expected_version: "0.17.0" -# Hermes reports semver from `hermes --version` (e.g. `0.17.0`) even though its -# GitHub release cadence is calendar-based (`v2026.6.19`). Declaring the +expected_version: "0.18.0" +# Hermes reports semver from `hermes --version` (e.g. `0.18.0`) even though its +# GitHub release cadence is calendar-based (`v2026.7.1`). Declaring the # scheme keeps the staleness check off the shape heuristic when a manifest # could otherwise straddle both schemes (#6049). version_scheme: semver diff --git a/agents/hermes/patch-session-list-preview.py b/agents/hermes/patch-session-list-preview.py index 6203513911a..be26b35763b 100755 --- a/agents/hermes/patch-session-list-preview.py +++ b/agents/hermes/patch-session-list-preview.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -"""Patch pinned Hermes v0.17.0 session-list previews to show the latest user turn. +"""Patch pinned Hermes v0.18.0 session-list previews to show the latest user turn. Source-of-truth note for this localized Hermes runtime patch: - - Invalid state: Hermes v0.17.0 computes `sessions list` preview text from + - Invalid state: Hermes v0.18.0 computes `sessions list` preview text from the first user message, but #5254's resumed/continued one-shot UX expects the original row to reflect the latest appended turn. - Value being patched: pinned/prebuilt `/opt/hermes/hermes_state.py` diff --git a/docs/manage-sandboxes/messaging-channels.mdx b/docs/manage-sandboxes/messaging-channels.mdx index 934dc8559ea..9e9486a24a1 100644 --- a/docs/manage-sandboxes/messaging-channels.mdx +++ b/docs/manage-sandboxes/messaging-channels.mdx @@ -101,6 +101,10 @@ When both Slack allowlists are set, NemoClaw requires the mention to come from o Channel messages still require an explicit bot mention. When a Slack channel `@mention` is denied by these allowlists, NemoClaw sends a denial notice back to the sender instead of dropping the message silently. During sandbox startup, NemoClaw normalizes OpenShell credential placeholders into the environment shape expected by the Slack runtime, so post-rebuild Slack starts use the gateway-managed tokens instead of literal placeholder strings. + +NemoClaw enables Hermes rich Slack rendering. Final responses can use Slack Block Kit, including native table blocks for Markdown tables. +This uses the existing Slack credentials and does not require additional scopes or reinstalling the Slack app. + Slack Socket Mode allows one active connection per app-level token. If another sandbox on the same gateway already uses the same Slack app token, onboarding and `channels add slack` warn before continuing in interactive mode and abort in non-interactive mode. Use `--force` only when you intentionally want to move the Slack Socket Mode session to the new sandbox. diff --git a/src/lib/messaging/channels/manifests.test.ts b/src/lib/messaging/channels/manifests.test.ts index e1ce5ec1c75..1aeb0442ac3 100644 --- a/src/lib/messaging/channels/manifests.test.ts +++ b/src/lib/messaging/channels/manifests.test.ts @@ -535,6 +535,7 @@ describe("built-in channel manifests", () => { expect(renderJson(slackManifest)).toContain('"path":"channels.slack"'); expect(renderJson(slackManifest)).toContain('"accounts"'); expect(renderJson(slackManifest)).toContain("allowedIds.slack.channels"); + expect(renderJson(slackManifest)).toContain('"rich_blocks":true'); expectSlackSocketModeGatewayConflictHook(); expectOpenClawNodePreload(slackManifest, "slack-channel-guard"); expect(JSON.stringify(slackManifest.runtime?.openclaw)).toContain("slack-channel-guard"); diff --git a/src/lib/messaging/channels/slack/manifest.ts b/src/lib/messaging/channels/slack/manifest.ts index 9d52b834881..fd254f230bc 100644 --- a/src/lib/messaging/channels/slack/manifest.ts +++ b/src/lib/messaging/channels/slack/manifest.ts @@ -168,6 +168,9 @@ export const slackManifest = { path: "platforms.slack", value: { enabled: true, + extra: { + rich_blocks: true, + }, }, }, }, diff --git a/test/e2e/live/hermes-slack-e2e-helpers.ts b/test/e2e/live/hermes-slack-e2e-helpers.ts index 2fbc5db158b..df23454dcb8 100644 --- a/test/e2e/live/hermes-slack-e2e-helpers.ts +++ b/test/e2e/live/hermes-slack-e2e-helpers.ts @@ -312,6 +312,11 @@ else: errors.append("platforms.slack missing or not a mapping") elif slack.get("enabled") is not True: errors.append(f"platforms.slack.enabled is not true ({slack!r})") + elif ( + not isinstance(slack.get("extra"), dict) + or slack["extra"].get("rich_blocks") is not True + ): + errors.append(f"platforms.slack.extra.rich_blocks is not true ({slack!r})") if "SLACK_BOT_TOKEN" in config_text or "SLACK_APP_TOKEN" in config_text: errors.append("config.yaml contains Slack token env keys") if errors: @@ -329,6 +334,43 @@ PY`, expectExitZero(configProbe, "Hermes Slack config shape probe"); expect(configProbe.stdout.trim()).toBe("OK"); + const rendererProbe = await sandboxEncodedSh( + sandbox, + SANDBOX_NAME, + String.raw`python3 - <<'PY' +import importlib.util +from pathlib import Path + +renderer_path = Path("/opt/hermes/plugins/platforms/slack/block_kit.py") +if not renderer_path.is_file(): + print(f"FAIL Hermes Slack Block Kit renderer missing: {renderer_path}") + raise SystemExit + +spec = importlib.util.spec_from_file_location("hermes_slack_block_kit", renderer_path) +if spec is None or spec.loader is None: + print("FAIL cannot load Hermes Slack Block Kit renderer") + raise SystemExit +module = importlib.util.module_from_spec(spec) +spec.loader.exec_module(module) + +markdown = "# Results\n\n| Check | Result |\n|:------|:------:|\n| Hermes | Pass |" +blocks = module.render_blocks(markdown) +types = [block.get("type") for block in blocks or []] +if "header" not in types or "table" not in types: + print(f"FAIL expected header and native table Block Kit blocks, got {types!r}") +else: + print("OK") +PY`, + [], + { + artifactName: "phase-4-rich-block-renderer", + redactionValues, + timeoutMs: 60_000, + }, + ); + expectExitZero(rendererProbe, "Hermes Slack Block Kit renderer probe"); + expect(rendererProbe.stdout.trim()).toBe("OK"); + const envProbe = await sandboxEncodedSh( sandbox, SANDBOX_NAME, @@ -644,6 +686,7 @@ PY`, slackProvidersCreated: true, hermesHealthOk: true, hermesSlackConfigShape: true, + hermesSlackRichBlockTableRendering: true, resolverPlaceholders: true, rawTokensAbsentFromFilesLogsAndProcesses: true, hermesScopedSlackPolicy: true, diff --git a/test/generate-hermes-config.test.ts b/test/generate-hermes-config.test.ts index aa28c7549fe..cfe9aa3ea74 100644 --- a/test/generate-hermes-config.test.ts +++ b/test/generate-hermes-config.test.ts @@ -382,7 +382,8 @@ describe("agents/hermes/generate-config.ts", () => { it("generates API server config without messaging platform token blocks", () => { const { config, envFile } = runConfigScript(); - expect(config._config_version).toBe(30); + expect(config._config_version).toBe(32); + expect(config.agent?.verify_on_stop).toBe(false); expect(config.display).toMatchObject({ compact: false, tool_progress: "all", @@ -926,7 +927,10 @@ describe("agents/hermes/generate-config.ts", () => { expect(config.telegram).toEqual({ require_mention: true }); expect(config.platforms.telegram).toEqual({ enabled: true }); - expect(config.platforms.slack).toEqual({ enabled: true }); + expect(config.platforms.slack).toEqual({ + enabled: true, + extra: { rich_blocks: true }, + }); expectRemotePlatformToolsets(config.platform_toolsets.telegram); expectRemotePlatformToolsets(config.platform_toolsets.slack); expect(envFile).toContain("TELEGRAM_BOT_TOKEN=openshell:resolve:env:TELEGRAM_BOT_TOKEN\n"); @@ -953,7 +957,10 @@ describe("agents/hermes/generate-config.ts", () => { NEMOCLAW_MESSAGING_CHANNELS_B64: encodeJson(["slack"]), }); - expect(config.platforms.slack).toEqual({ enabled: true }); + expect(config.platforms.slack).toEqual({ + enabled: true, + extra: { rich_blocks: true }, + }); expect(config.platforms.api_server.enabled).toBe(true); }); diff --git a/test/hermes-doctor-config-hash.test.ts b/test/hermes-doctor-config-hash.test.ts index 35e8cf318e1..df95cd880ae 100644 --- a/test/hermes-doctor-config-hash.test.ts +++ b/test/hermes-doctor-config-hash.test.ts @@ -38,7 +38,7 @@ describe("Hermes doctor and config hash boundary", () => { try { fs.mkdirSync(path.dirname(hermesBin), { recursive: true }); fs.mkdirSync(path.dirname(wrapper), { recursive: true }); - fs.writeFileSync(hermesBin, "#!/usr/bin/env bash\nprintf 'hermes v0.18.0\\n'\n", { + fs.writeFileSync(hermesBin, "#!/usr/bin/env bash\nprintf 'hermes v0.19.0\\n'\n", { mode: 0o755, }); fs.writeFileSync(wrapper, "# wrapper fixture without resumed oneshot marker\n"); @@ -52,7 +52,7 @@ describe("Hermes doctor and config hash boundary", () => { expect(result.status).toBe(1); expect(result.stderr).toContain( - "Hermes v0.17.0 compatibility workarounds are still installed", + "Hermes v0.18.0 compatibility workarounds are still installed", ); } finally { fs.rmSync(tmp, { recursive: true, force: true }); diff --git a/test/update-hermes-agent-script.test.ts b/test/update-hermes-agent-script.test.ts index 6d91dea7e1e..31e40c28572 100644 --- a/test/update-hermes-agent-script.test.ts +++ b/test/update-hermes-agent-script.test.ts @@ -16,7 +16,7 @@ const HERMES_BASE_DOCKERFILE = path.join( "Dockerfile.base", ); const HERMES_MANIFEST = path.join(import.meta.dirname, "..", "agents", "hermes", "manifest.yaml"); -const TARGET_TAG = "v2026.6.19"; +const TARGET_TAG = "v2026.7.1"; const CURRENT_INSTALLED_BASE = [ "# Calver tag v2026.6.5 = Hermes Agent v0.16.0.", @@ -88,7 +88,7 @@ printf 'fake archive' > "$output" ); writeExecutable( path.join(fakeBin, "tar"), - "#!/usr/bin/env bash\nprintf 'version = \"0.17.0\"\\n'\n", + "#!/usr/bin/env bash\nprintf 'version = \"0.18.0\"\\n'\n", ); writeExecutable(path.join(fakeBin, "npm"), "#!/usr/bin/env bash\nprintf 'sha512-test\\n'\n"); writeExecutable( @@ -107,7 +107,7 @@ esac set -euo pipefail printf '%s|%s\\n' "\${NEMOCLAW_HERMES_SANDBOX_BASE_IMAGE_REF:-}" "$*" >> "$FAKE_NEMOHERMES_LOG" if [[ "$*" == "hermes exec -- hermes --version" ]]; then - printf '0.17.0\\n' + printf '0.18.0\\n' fi `, ); @@ -130,7 +130,7 @@ fi expect(run.status, `${run.stdout}\n${run.stderr}`).toBe(0); expect(fs.readFileSync(dockerLog, "utf8")).toContain(`tag ${baseRef} ${pinnedRef}`); expect(fs.readFileSync(nemohermesLog, "utf8")).toContain(`${pinnedRef}|hermes rebuild`); - expect(run.stdout).toContain("OK: sandbox reports Hermes Agent v0.17.0"); + expect(run.stdout).toContain("OK: sandbox reports Hermes Agent v0.18.0"); } finally { fs.rmSync(tmp, { recursive: true, force: true }); } From bdff22dd32c7a72bf45c5085808b3057fdbc75e6 Mon Sep 17 00:00:00 2001 From: Will Curran Date: Wed, 8 Jul 2026 15:55:48 -0700 Subject: [PATCH 2/5] chore(hermes): pin v0.18 sandbox base image Pin the published Hermes v0.18 multi-architecture base image. Use the digest produced by workflow run 28979264697. Signed-off-by: Will Curran --- agents/hermes/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/hermes/Dockerfile b/agents/hermes/Dockerfile index 263be1f2028..546ff5acf4c 100644 --- a/agents/hermes/Dockerfile +++ b/agents/hermes/Dockerfile @@ -6,7 +6,7 @@ # Layers PR-specific code (plugin, config, startup script) on top of the # pre-built Hermes base image. Mirrors the OpenClaw Dockerfile structure. -ARG BASE_IMAGE=ghcr.io/nvidia/nemoclaw/hermes-sandbox-base@sha256:d6ce792eb302a73fc7e32e6ade18dcf21aaa425bcecdde8999e90b437fb6186a +ARG BASE_IMAGE=ghcr.io/nvidia/nemoclaw/hermes-sandbox-base@sha256:fa05221f5c7bcafea7e263c84e5d06f87e37d1ccb78dc28c113f1a4066aa544c # hadolint ignore=DL3006 FROM ${BASE_IMAGE} From 1c82046e6a554f81a076994633d38442fb171a22 Mon Sep 17 00:00:00 2001 From: Will Curran Date: Wed, 8 Jul 2026 16:41:19 -0700 Subject: [PATCH 3/5] docs(hermes): follow MDX sentence style Apply the repository one-sentence-per-line convention. Clarify the Hermes rich Slack rendering note. Signed-off-by: Will Curran --- docs/manage-sandboxes/messaging-channels.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/manage-sandboxes/messaging-channels.mdx b/docs/manage-sandboxes/messaging-channels.mdx index 9e9486a24a1..7372ff125cd 100644 --- a/docs/manage-sandboxes/messaging-channels.mdx +++ b/docs/manage-sandboxes/messaging-channels.mdx @@ -102,7 +102,8 @@ Channel messages still require an explicit bot mention. When a Slack channel `@mention` is denied by these allowlists, NemoClaw sends a denial notice back to the sender instead of dropping the message silently. During sandbox startup, NemoClaw normalizes OpenShell credential placeholders into the environment shape expected by the Slack runtime, so post-rebuild Slack starts use the gateway-managed tokens instead of literal placeholder strings. -NemoClaw enables Hermes rich Slack rendering. Final responses can use Slack Block Kit, including native table blocks for Markdown tables. +NemoClaw enables rich Slack rendering for Hermes. +Final responses can use Slack Block Kit, including native table blocks for Markdown tables. This uses the existing Slack credentials and does not require additional scopes or reinstalling the Slack app. Slack Socket Mode allows one active connection per app-level token. From 38044d24c3aa1c5c4c43fbfd906c94f56fe11abe Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Thu, 9 Jul 2026 13:34:11 -0700 Subject: [PATCH 4/5] test(hermes): cover Slack rich-block lifecycle --- .../compiler/workflow-planner.test.ts | 68 ++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/src/lib/messaging/compiler/workflow-planner.test.ts b/src/lib/messaging/compiler/workflow-planner.test.ts index 9b38bd8506f..c960a192720 100644 --- a/src/lib/messaging/compiler/workflow-planner.test.ts +++ b/src/lib/messaging/compiler/workflow-planner.test.ts @@ -3,12 +3,17 @@ import { describe, expect, it } from "vitest"; +import { applyMessagingAgentRenderToObject } from "../applier/build/messaging-build-applier.mts"; import { createBuiltInChannelManifestRegistry, createBuiltInRenderTemplateResolver, } from "../channels"; import { createBuiltInMessagingHookRegistry, MessagingHookRegistry } from "../hooks"; -import { type ChannelManifest, createChannelManifestRegistry } from "../manifest"; +import { + type ChannelManifest, + createChannelManifestRegistry, + type SandboxMessagingPlan, +} from "../manifest"; import { MessagingWorkflowPlanner } from "./workflow-planner"; const TEST_CREDENTIALS: Readonly> = { @@ -101,6 +106,12 @@ function planner(): MessagingWorkflowPlanner { ); } +function renderHermesPlatforms(plan: SandboxMessagingPlan): Record { + const config: { platforms: Record } = { platforms: {} }; + applyMessagingAgentRenderToObject(config, plan, "~/.hermes/config.yaml"); + return config.platforms; +} + function findFunctionPaths(value: unknown, prefix = "$"): string[] { if (typeof value === "function") return [prefix]; if (Array.isArray(value)) { @@ -666,6 +677,61 @@ describe("MessagingWorkflowPlanner", () => { ).toBe(true); }); + it("renders Hermes Slack rich blocks only while Slack is active across stop/start (#6443)", async () => { + const lifecyclePlanner = planner(); + const existingPlan = await lifecyclePlanner.buildPlan({ + sandboxName: "demo", + agent: "hermes", + workflow: "onboard", + isInteractive: false, + configuredChannels: ["slack"], + credentialAvailability: { + SLACK_BOT_TOKEN: true, + SLACK_APP_TOKEN: true, + }, + }); + + expect(renderHermesPlatforms(existingPlan).slack).toEqual({ + enabled: true, + extra: { rich_blocks: true }, + }); + + const stopped = await lifecyclePlanner.buildChannelStopPlanFromSandboxEntry({ + sandboxName: "demo", + agent: "hermes", + sandboxEntry: { + name: "demo", + messaging: { schemaVersion: 1, plan: existingPlan }, + }, + channelId: "slack", + }); + + expect(stopped?.channels.find((channel) => channel.channelId === "slack")).toMatchObject({ + active: false, + disabled: true, + }); + expect(renderHermesPlatforms(stopped!).slack).toBeUndefined(); + + const started = await lifecyclePlanner.buildChannelStartPlanFromSandboxEntry({ + sandboxName: "demo", + agent: "hermes", + sandboxEntry: { + name: "demo", + messaging: { schemaVersion: 1, plan: stopped! }, + }, + channelId: "slack", + }); + + expect(started?.channels.find((channel) => channel.channelId === "slack")).toMatchObject({ + active: true, + disabled: false, + }); + expect(renderHermesPlatforms(started!).slack).toEqual({ + enabled: true, + extra: { rich_blocks: true }, + }); + }); + it("removes Teams host forwarding while the channel is disabled", async () => { await withEnv( { From 4bcd130733f792f3c53443728d06d335f09f4f8c Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Thu, 9 Jul 2026 13:44:33 -0700 Subject: [PATCH 5/5] test(hermes): isolate Slack lifecycle coverage --- .../workflow-planner-hermes-slack.test.ts | 118 ++++++++++++++++++ .../compiler/workflow-planner.test.ts | 68 +--------- 2 files changed, 119 insertions(+), 67 deletions(-) create mode 100644 src/lib/messaging/compiler/workflow-planner-hermes-slack.test.ts diff --git a/src/lib/messaging/compiler/workflow-planner-hermes-slack.test.ts b/src/lib/messaging/compiler/workflow-planner-hermes-slack.test.ts new file mode 100644 index 00000000000..2e6454d4bd5 --- /dev/null +++ b/src/lib/messaging/compiler/workflow-planner-hermes-slack.test.ts @@ -0,0 +1,118 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { describe, expect, it } from "vitest"; + +import { applyMessagingAgentRenderToObject } from "../applier/build/messaging-build-applier.mts"; +import { + createBuiltInChannelManifestRegistry, + createBuiltInRenderTemplateResolver, +} from "../channels"; +import { createBuiltInMessagingHookRegistry } from "../hooks"; +import type { SandboxMessagingPlan } from "../manifest"; +import { MessagingWorkflowPlanner } from "./workflow-planner"; + +const TEST_CREDENTIALS: Readonly> = { + SLACK_BOT_TOKEN: "xoxb-test-slack-token", + SLACK_APP_TOKEN: "xapp-test-slack-token", +}; + +function planner(): MessagingWorkflowPlanner { + return new MessagingWorkflowPlanner( + createBuiltInChannelManifestRegistry(), + createBuiltInMessagingHookRegistry({ + common: { + env: {}, + getCredential: (key) => TEST_CREDENTIALS[key] ?? null, + saveCredential: () => {}, + prompt: async () => "unused", + log: () => {}, + }, + slack: { + validateCredentials: { + log: () => {}, + validateCredentials: () => ({ ok: true }), + }, + }, + }), + createBuiltInRenderTemplateResolver(), + ); +} + +function renderHermesPlatforms(plan: SandboxMessagingPlan): Record { + const config: { platforms: Record } = { platforms: {} }; + applyMessagingAgentRenderToObject(config, plan, "~/.hermes/config.yaml"); + return config.platforms; +} + +function sandboxEntry(plan: SandboxMessagingPlan) { + return { + name: "demo", + messaging: { schemaVersion: 1 as const, plan }, + }; +} + +describe("Hermes Slack lifecycle rendering", () => { + it("renders rich blocks only while Slack is active and removes every Slack entry (#6443)", async () => { + const lifecyclePlanner = planner(); + const existingPlan = await lifecyclePlanner.buildPlan({ + sandboxName: "demo", + agent: "hermes", + workflow: "onboard", + isInteractive: false, + configuredChannels: ["slack"], + credentialAvailability: { + SLACK_BOT_TOKEN: true, + SLACK_APP_TOKEN: true, + }, + }); + + expect(renderHermesPlatforms(existingPlan).slack).toEqual({ + enabled: true, + extra: { rich_blocks: true }, + }); + + const stopped = await lifecyclePlanner.buildChannelStopPlanFromSandboxEntry({ + sandboxName: "demo", + agent: "hermes", + sandboxEntry: sandboxEntry(existingPlan), + channelId: "slack", + }); + + expect(stopped?.channels.find((channel) => channel.channelId === "slack")).toMatchObject({ + active: false, + disabled: true, + }); + expect(renderHermesPlatforms(stopped!).slack).toBeUndefined(); + + const started = await lifecyclePlanner.buildChannelStartPlanFromSandboxEntry({ + sandboxName: "demo", + agent: "hermes", + sandboxEntry: sandboxEntry(stopped!), + channelId: "slack", + }); + + expect(started?.channels.find((channel) => channel.channelId === "slack")).toMatchObject({ + active: true, + disabled: false, + }); + expect(renderHermesPlatforms(started!).slack).toEqual({ + enabled: true, + extra: { rich_blocks: true }, + }); + + const removed = await lifecyclePlanner.buildChannelRemovePlanFromSandboxEntry({ + sandboxName: "demo", + agent: "hermes", + sandboxEntry: sandboxEntry(started!), + channelId: "slack", + }); + + expect(removed?.workflow).toBe("remove-channel"); + expect(removed?.channels).toEqual([]); + expect(renderHermesPlatforms(removed!).slack).toBeUndefined(); + expect(removed?.credentialBindings.some((entry) => entry.channelId === "slack")).toBe(false); + expect(removed?.networkPolicy.entries.some((entry) => entry.channelId === "slack")).toBe(false); + expect(removed?.agentRender.some((entry) => entry.channelId === "slack")).toBe(false); + }); +}); diff --git a/src/lib/messaging/compiler/workflow-planner.test.ts b/src/lib/messaging/compiler/workflow-planner.test.ts index c960a192720..9b38bd8506f 100644 --- a/src/lib/messaging/compiler/workflow-planner.test.ts +++ b/src/lib/messaging/compiler/workflow-planner.test.ts @@ -3,17 +3,12 @@ import { describe, expect, it } from "vitest"; -import { applyMessagingAgentRenderToObject } from "../applier/build/messaging-build-applier.mts"; import { createBuiltInChannelManifestRegistry, createBuiltInRenderTemplateResolver, } from "../channels"; import { createBuiltInMessagingHookRegistry, MessagingHookRegistry } from "../hooks"; -import { - type ChannelManifest, - createChannelManifestRegistry, - type SandboxMessagingPlan, -} from "../manifest"; +import { type ChannelManifest, createChannelManifestRegistry } from "../manifest"; import { MessagingWorkflowPlanner } from "./workflow-planner"; const TEST_CREDENTIALS: Readonly> = { @@ -106,12 +101,6 @@ function planner(): MessagingWorkflowPlanner { ); } -function renderHermesPlatforms(plan: SandboxMessagingPlan): Record { - const config: { platforms: Record } = { platforms: {} }; - applyMessagingAgentRenderToObject(config, plan, "~/.hermes/config.yaml"); - return config.platforms; -} - function findFunctionPaths(value: unknown, prefix = "$"): string[] { if (typeof value === "function") return [prefix]; if (Array.isArray(value)) { @@ -677,61 +666,6 @@ describe("MessagingWorkflowPlanner", () => { ).toBe(true); }); - it("renders Hermes Slack rich blocks only while Slack is active across stop/start (#6443)", async () => { - const lifecyclePlanner = planner(); - const existingPlan = await lifecyclePlanner.buildPlan({ - sandboxName: "demo", - agent: "hermes", - workflow: "onboard", - isInteractive: false, - configuredChannels: ["slack"], - credentialAvailability: { - SLACK_BOT_TOKEN: true, - SLACK_APP_TOKEN: true, - }, - }); - - expect(renderHermesPlatforms(existingPlan).slack).toEqual({ - enabled: true, - extra: { rich_blocks: true }, - }); - - const stopped = await lifecyclePlanner.buildChannelStopPlanFromSandboxEntry({ - sandboxName: "demo", - agent: "hermes", - sandboxEntry: { - name: "demo", - messaging: { schemaVersion: 1, plan: existingPlan }, - }, - channelId: "slack", - }); - - expect(stopped?.channels.find((channel) => channel.channelId === "slack")).toMatchObject({ - active: false, - disabled: true, - }); - expect(renderHermesPlatforms(stopped!).slack).toBeUndefined(); - - const started = await lifecyclePlanner.buildChannelStartPlanFromSandboxEntry({ - sandboxName: "demo", - agent: "hermes", - sandboxEntry: { - name: "demo", - messaging: { schemaVersion: 1, plan: stopped! }, - }, - channelId: "slack", - }); - - expect(started?.channels.find((channel) => channel.channelId === "slack")).toMatchObject({ - active: true, - disabled: false, - }); - expect(renderHermesPlatforms(started!).slack).toEqual({ - enabled: true, - extra: { rich_blocks: true }, - }); - }); - it("removes Teams host forwarding while the channel is disabled", async () => { await withEnv( {