hermes - ✅(Solved) Fix [Bug]: `hermes --tui` fails to build on main — TS2322 in ops.ts /reload-mcp params [3 pull requests, 3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#17773Fetched 2026-05-01 05:55:58
View on GitHub
Comments
3
Participants
3
Timeline
16
Reactions
0
Author
Timeline (top)
cross-referenced ×4commented ×3labeled ×3referenced ×2

On main (current HEAD 828d3a320, after 4d7fc0f37), hermes --tui fails to build out of the box with a TypeScript error. First invocation on a fresh install dies during the auto-build step:

❯ hermes --tui
Installing TUI dependencies…
TUI build failed.
> [email protected] build
> npm run build --prefix packages/hermes-ink && tsc -p tsconfig.build.json && npm run build:compile && chmod +x dist/entry.js

> @hermes/[email protected] build
> esbuild src/entry-exports.ts --bundle --platform=node --format=esm --packages=external --outfile=dist/ink-bundle.js

src/app/slash/commands/ops.ts(86,9): error TS2322: Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.

  dist/ink-bundle.js  416.8kb

⚡ Done in 21ms

dist/entry.js is never produced → subsequent hermes --tui attempts re-run npm run build and fail the same way. TUI is effectively unusable on current main.

Error Message

On main (current HEAD 828d3a320, after 4d7fc0f37), hermes --tui fails to build out of the box with a TypeScript error. First invocation on a fresh install dies during the auto-build step: src/app/slash/commands/ops.ts(86,9): error TS2322: Type 'string | null' is not assignable to type 'string'. Introduced in 4d7fc0f37feat(gateway,cli): confirm /reload-mcp to warn about prompt cache invalidation.

Root Cause

ui-tui/src/app/slash/commands/ops.ts (introduced in 4d7fc0f37):

const params: { session_id: string; confirm?: boolean; always?: boolean } = {
  session_id: ctx.sid
}

But in ui-tui/src/app/slash/types.ts:

sid: null | string

Every other slash command that forwards ctx.sidprompt.background, config.set, session.compress, session.branch, image.attach in session.ts — just passes it through without type-narrowing; the gateway already handles a null session_id. ops.ts is the outlier that declares the narrower string, so strict TS rejects the assignment.

Fix Action

Fix

Widen the param type to string | null to match the rest of the codebase and the actual ctx.sid type. PR: #NNN (replace with link).

PR fix notes

PR #17774: fix(tui): allow nullable session_id in /reload-mcp params

Description (problem / solution / changelog)

Fixes #17773.

Problem

hermes --tui fails to build on current main because the /reload-mcp slash command declares its params with a non-nullable session_id: string, but ctx.sid is typed as string | null:

src/app/slash/commands/ops.ts(86,9): error TS2322: Type 'string | null' is not assignable to type 'string'.

First invocation on a fresh install dies during the auto-build step; dist/entry.js is never produced; TUI is effectively unusable.

Fix

Widen the param type to string | null to match ctx.sid and the convention used by every other slash command that forwards the session id (e.g. session.tsprompt.background, config.set, session.compress, session.branch, image.attach all just spread session_id: ctx.sid without narrowing, and the gateway already handles null).

Smallest correct change; no runtime behavior difference.

Verification

cd ui-tui && npm run build   # now clean
hermes --tui -z "smoke test" # → responds normally

Regression introduced in

4d7fc0f37feat(gateway,cli): confirm /reload-mcp to warn about prompt cache invalidation. The TUI dev loop (tsx --watch) skips tsc -p tsconfig.build.json, so the build-time typecheck only fires when end users hit the launcher's on-demand build path. A CI job running npm run build on the TUI would catch future regressions of this class.

Changed files

  • ui-tui/src/app/slash/commands/ops.ts (modified, +1/-1)

PR #17822: fix(tui): add null guard for ctx.sid in /reload-mcp slash command

Description (problem / solution / changelog)

Summary

Add a null guard for ctx.sid in the /reload-mcp slash command handler, matching the existing pattern used by /rollback and /save.

Problem

When ctx.sid is null (no active session), /reload-mcp crashes because it passes null as session_id: string to the reload.mcp RPC call. The TypeScript type for params.session_id is string, but ctx.sid is string | null.

Fix

Added an early-return null check at the top of the run handler, before building the RPC params:

if (!ctx.sid) {
  return ctx.transcript.sys("/reload-mcp requires an active session")
}

This matches the guard pattern already used by /rollback (line 193) and /save in the same file.

Changed Files

  • ui-tui/src/app/slash/commands/ops.ts — 3 lines added

Closes #17794

Changed files

  • ui-tui/src/app/slash/commands/ops.ts (modified, +3/-0)

PR #17821: fix(tui): guard /reload-mcp against null ctx.sid

Description (problem / solution / changelog)

What does this PR do?

/reload-mcp declared params.session_id: string but read it directly from ctx.sid, which is typed as string | null. Triggering the command before a session was active crashed the TUI. Mirrors the null-guard pattern that /rollback (and /save) already use — surface a sys message instead of hitting the RPC with a null id.

Related Issue

Fixes #17794

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • ui-tui/src/app/slash/commands/ops.ts — early-return with ctx.transcript.sys('/reload-mcp requires an active session') when ctx.sid is null, before constructing params.
  • ui-tui/src/__tests__/createSlashHandler.test.ts:
    • removed the table row that asserted reload.mcp is called with session_id: null (that was the bug — the typed string field was getting null).
    • added a positive test: active sid → RPC routed with the sid.
    • added a regression test: no sid → sys message, RPC not invoked.

How to Test

  1. cd ui-tui && npm install
  2. npm run build --prefix packages/hermes-ink
  3. npx vitest run createSlashHandler — 45 / 45 pass, including the two new cases.
  4. Full TUI suite (npx vitest run) — 539 / 539.
  5. npm run type-check — clean.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • Targeted vitest run + full TUI suite + tsc --noEmit pass locally
  • I've added tests for my changes
  • I've tested on my platform: macOS 15 (Darwin 23.2)

Documentation & Housekeeping

  • I've updated relevant documentation — N/A (no behavior change for users beyond the new sys message)
  • I've updated cli-config.yaml.example — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md — N/A
  • I've considered cross-platform impact — guard is platform-agnostic
  • I've updated tool descriptions/schemas — N/A

Changed files

  • ui-tui/src/__tests__/createSlashHandler.test.ts (modified, +20/-1)
  • ui-tui/src/app/slash/commands/ops.ts (modified, +4/-0)

Code Example

❯ hermes --tui
Installing TUI dependencies…
TUI build failed.
> hermes-tui@0.0.1 build
> npm run build --prefix packages/hermes-ink && tsc -p tsconfig.build.json && npm run build:compile && chmod +x dist/entry.js

> @hermes/ink@0.0.1 build
> esbuild src/entry-exports.ts --bundle --platform=node --format=esm --packages=external --outfile=dist/ink-bundle.js

src/app/slash/commands/ops.ts(86,9): error TS2322: Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.

  dist/ink-bundle.js  416.8kb

Done in 21ms

---

const params: { session_id: string; confirm?: boolean; always?: boolean } = {
  session_id: ctx.sid
}

---

sid: null | string
RAW_BUFFERClick to expand / collapse

Summary

On main (current HEAD 828d3a320, after 4d7fc0f37), hermes --tui fails to build out of the box with a TypeScript error. First invocation on a fresh install dies during the auto-build step:

❯ hermes --tui
Installing TUI dependencies…
TUI build failed.
> [email protected] build
> npm run build --prefix packages/hermes-ink && tsc -p tsconfig.build.json && npm run build:compile && chmod +x dist/entry.js

> @hermes/[email protected] build
> esbuild src/entry-exports.ts --bundle --platform=node --format=esm --packages=external --outfile=dist/ink-bundle.js

src/app/slash/commands/ops.ts(86,9): error TS2322: Type 'string | null' is not assignable to type 'string'.
  Type 'null' is not assignable to type 'string'.

  dist/ink-bundle.js  416.8kb

⚡ Done in 21ms

dist/entry.js is never produced → subsequent hermes --tui attempts re-run npm run build and fail the same way. TUI is effectively unusable on current main.

Environment

  • hermes-agent main @ 828d3a320 (PR context)
  • macOS 14, Node v22.22.2, npm 11.6.4
  • Clean node_modules (post npm install)

Root cause

ui-tui/src/app/slash/commands/ops.ts (introduced in 4d7fc0f37):

const params: { session_id: string; confirm?: boolean; always?: boolean } = {
  session_id: ctx.sid
}

But in ui-tui/src/app/slash/types.ts:

sid: null | string

Every other slash command that forwards ctx.sidprompt.background, config.set, session.compress, session.branch, image.attach in session.ts — just passes it through without type-narrowing; the gateway already handles a null session_id. ops.ts is the outlier that declares the narrower string, so strict TS rejects the assignment.

Fix

Widen the param type to string | null to match the rest of the codebase and the actual ctx.sid type. PR: #NNN (replace with link).

Regression

Introduced in 4d7fc0f37feat(gateway,cli): confirm /reload-mcp to warn about prompt cache invalidation.

Probably slipped through because the TUI dev loop (npm run devtsx --watch) doesn't run tsc -p tsconfig.build.json, so the stricter build-time typecheck never fires until end users hit hermes --tui's on-demand build path.

extent analysis

TL;DR

Update the params type in ui-tui/src/app/slash/commands/ops.ts to string | null to match the type of ctx.sid.

Guidance

  • Identify the line causing the TypeScript error: src/app/slash/commands/ops.ts(86,9).
  • Update the params type to string | null to match the type of ctx.sid in ui-tui/src/app/slash/types.ts.
  • Verify the fix by running hermes --tui and checking that the TUI build completes successfully.
  • Review other parts of the codebase to ensure consistent type handling for ctx.sid.

Example

const params: { session_id: string | null; confirm?: boolean; always?: boolean } = {
  session_id: ctx.sid
}

Notes

This fix assumes that the ctx.sid can be null and that the code handles this case correctly. If ctx.sid should never be null, additional checks or type narrowing may be necessary.

Recommendation

Apply the workaround by updating the params type to string | null. This fix is necessary to resolve the TypeScript error and allow the TUI to build correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: `hermes --tui` fails to build on main — TS2322 in ops.ts /reload-mcp params [3 pull requests, 3 comments, 3 participants]