Skip to content

The agent that grows with you

refactor: keep main.py and the overlay under the code-health caps

Siddharth Balyan18f68923c353
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index ef0ea302d18..e4be6cdd64e 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -389,7 +389,6 @@ from hermes_cli.subcommands.skills import build_skills_parser
from hermes_cli.subcommands.pairing import build_pairing_parser
from hermes_cli.subcommands.plugins import build_plugins_parser
from hermes_cli.subcommands.mcp import build_mcp_parser
-from hermes_cli.subcommands.connectors import build_connectors_parser
from hermes_cli.subcommands.claw import build_claw_parser
from hermes_cli.subcommands.vault import build_vault_parser
from hermes_cli.subcommands.moa import build_moa_parser
@@ -3453,7 +3452,6 @@ def _build_cli_parser():
build_tools_parser(subparsers, cmd_tools=cmd_tools)
build_computer_use_parser(subparsers)
build_mcp_parser(subparsers, cmd_mcp=cmd_mcp)
- build_connectors_parser(subparsers)
build_sessions_parser(subparsers, cmd_sessions=_cmd_sessions_lazy)
build_insights_parser(subparsers, cmd_insights=cmd_insights)
build_usage_parser(subparsers)
diff --git a/hermes_cli/subcommands/mcp.py b/hermes_cli/subcommands/mcp.py
index 9702d7be16b..8b03dbf60eb 100644
--- a/hermes_cli/subcommands/mcp.py
+++ b/hermes_cli/subcommands/mcp.py
@@ -77,3 +77,8 @@ def build_mcp_parser(subparsers, *, cmd_mcp: Callable) -> None:
add_accept_hooks_flag(mcp_parser)
mcp_parser.set_defaults(func=cmd_mcp)
+
+ # Hosted connector accounts sit next to MCP servers in `hermes --help`.
+ from hermes_cli.subcommands.connectors import build_connectors_parser
+
+ build_connectors_parser(subparsers)
diff --git a/ui-tui/src/app/overlayStore.ts b/ui-tui/src/app/overlayStore.ts
index 347e024b091..e43dd821f64 100644
--- a/ui-tui/src/app/overlayStore.ts
+++ b/ui-tui/src/app/overlayStore.ts
@@ -31,55 +31,32 @@ const buildOverlayState = (): OverlayState => ({
export const $overlayState = atom<OverlayState>(buildOverlayState())
-export const $isBlocked = computed(
- $overlayState,
- ({
- agents,
- approval,
- billing,
- clarify,
- confirm,
- connection,
- connectors,
- journey,
- modelPicker,
- pager,
- petPicker,
- pluginsHub,
- secret,
- sessions,
- skillsHub,
- subscription,
- sudo,
- vaultCode,
- vaultSaveLogin,
- vaultUnlock,
- widget
- }) =>
- Boolean(
- agents ||
- approval ||
- billing ||
- clarify ||
- confirm ||
- connection ||
- connectors ||
- journey ||
- modelPicker ||
- pager ||
- petPicker ||
- pluginsHub ||
- secret ||
- sessions ||
- skillsHub ||
- subscription ||
- sudo ||
- vaultCode ||
- vaultSaveLogin ||
- vaultUnlock ||
- widget
- )
-)
+// Every overlay that suspends text input. `ambient` is the one non-blocking key.
+const BLOCKING_KEYS = [
+ 'agents',
+ 'approval',
+ 'billing',
+ 'clarify',
+ 'confirm',
+ 'connection',
+ 'connectors',
+ 'journey',
+ 'modelPicker',
+ 'pager',
+ 'petPicker',
+ 'pluginsHub',
+ 'secret',
+ 'sessions',
+ 'skillsHub',
+ 'subscription',
+ 'sudo',
+ 'vaultCode',
+ 'vaultSaveLogin',
+ 'vaultUnlock',
+ 'widget'
+] as const satisfies readonly (keyof OverlayState)[]
+
+export const $isBlocked = computed($overlayState, overlay => BLOCKING_KEYS.some(key => Boolean(overlay[key])))
/**
* Does an open overlay actually PAINT OVER the status rule?
diff --git a/ui-tui/src/components/connectorsOverlay.tsx b/ui-tui/src/components/connectorsOverlay.tsx
index 5145f5b582b..0916176483b 100644
--- a/ui-tui/src/components/connectorsOverlay.tsx
+++ b/ui-tui/src/components/connectorsOverlay.tsx
@@ -8,7 +8,7 @@ import type {
ConnectorsListResult
} from '@hermes/shared/gateway-events'
import { JsonRpcGatewayError } from '@hermes/shared/json-rpc-channel'
-import { useEffect, useState } from 'react'
+import { type ReactNode, useEffect, useState } from 'react'
import {
accountName,
@@ -300,6 +300,35 @@ export function ConnectorsOverlay({ gw, maxWidth, onClose, t }: ConnectorsOverla
}
}
+ const addAppKey = (current: Extract<Stage, { kind: 'addApp' }>, key: KeyLike & { return: boolean }) => {
+ if (key.escape) {
+ return setStage({ kind: 'list' })
+ }
+
+ if (key.upArrow || key.downArrow) {
+ const next = (current.idx + (key.upArrow ? -1 : 1) + current.apps.length) % current.apps.length
+
+ return setStage({ ...current, idx: next })
+ }
+
+ if (key.return) {
+ setErr('')
+ setStage({ app: current.apps[current.idx]!, draft: '', kind: 'addName' })
+ }
+ }
+
+ const linkKey = (current: Extract<Stage, { kind: 'link' }>, key: KeyLike & { return: boolean }) => {
+ if (key.escape) {
+ setStage({ kind: 'list' })
+
+ return setNotice(T.connectors.notice.stopped)
+ }
+
+ if (key.return && current.target?.connect_url) {
+ setNotice(openExternalUrl(current.target.connect_url) ? '' : T.connectors.notice.browserDidNotOpen)
+ }
+ }
+
useInput((ch, key) => {
if (busy) {
return
@@ -321,23 +350,7 @@ export function ConnectorsOverlay({ gw, maxWidth, onClose, t }: ConnectorsOverla
return
case 'addApp':
- if (key.escape) {
- return setStage({ kind: 'list' })
- }
-
- if (key.upArrow || key.downArrow) {
- const next = (stage.idx + (key.upArrow ? -1 : 1) + stage.apps.length) % stage.apps.length
-
- return setStage({ ...stage, idx: next })
- }
-
- if (key.return) {
- setErr('')
-
- return setStage({ app: stage.apps[stage.idx]!, draft: '', kind: 'addName' })
- }
-
- return
+ return addAppKey(stage, key)
case 'confirm':
if (ch === 'y' || ch === 'Y') {
@@ -345,16 +358,9 @@ export function ConnectorsOverlay({ gw, maxWidth, onClose, t }: ConnectorsOverla
}
return setStage({ kind: 'list' })
- case 'link':
- if (key.escape) {
- setStage({ kind: 'list' })
-
- return setNotice(T.connectors.notice.stopped)
- }
- if (key.return && stage.target?.connect_url) {
- setNotice(openExternalUrl(stage.target.connect_url) ? '' : T.connectors.notice.browserDidNotOpen)
- }
+ case 'link':
+ return linkKey(stage, key)
}
})
@@ -412,44 +418,11 @@ export function ConnectorsOverlay({ gw, maxWidth, onClose, t }: ConnectorsOverla
}
if (stage.kind === 'addApp') {
- const { items, offset } = windowItems(stage.apps, stage.idx, VISIBLE)
-
- return (
- <Box flexDirection="column" width={width}>
- {title}
- <Text color={t.color.text}>{T.connectors.add.pickApp}</Text>
- {items.map((app, i) => (
- <Text color={t.color.muted} {...chipRowProps(t, offset + i === stage.idx)} key={app} wrap="truncate-end">
- {offset + i === stage.idx ? '▸ ' : ' '}
- {app}
- </Text>
- ))}
- {footer}
- <OverlayHint t={t}>{T.connectors.add.pickHint}</OverlayHint>
- </Box>
- )
+ return <AppPicker footer={footer} stage={stage} t={t} title={title} width={width} />
}
if (stage.kind === 'link') {
- const heading = stage.reconnect
- ? T.connectors.link.reconnectTitle(stage.app, stage.name)
- : T.connectors.link.title(stage.app, stage.name)
-
- return (
- <Box flexDirection="column" width={width}>
- {title}
- <Text color={t.color.text}>{heading}</Text>
- {stage.target?.connect_url ? (
- <Text color={t.color.accent}>{stage.target.connect_url}</Text>
- ) : (
- <Text color={t.color.muted}>{T.connectors.link.starting}</Text>
- )}
- {stage.target?.detail ? <Text color={t.color.error}>{stage.target.detail}</Text> : null}
- <Text color={t.color.muted}>{T.connectors.link.waiting}</Text>
- {footer}
- <OverlayHint t={t}>{T.connectors.link.hint}</OverlayHint>
- </Box>
- )
+ return <LinkView footer={footer} stage={stage} t={t} title={title} width={width} />
}
const labels = view.rows.map(row => accountRowText(row, statusLabel(T, row), T.connectors.unnamedTag))
@@ -489,6 +462,58 @@ export function ConnectorsOverlay({ gw, maxWidth, onClose, t }: ConnectorsOverla
)
}
+interface StageViewProps<K extends Stage['kind']> {
+ footer: ReactNode
+ stage: Extract<Stage, { kind: K }>
+ t: Theme
+ title: ReactNode
+ width: number
+}
+
+function AppPicker({ footer, stage, t, title, width }: StageViewProps<'addApp'>) {
+ const T = useT()
+ const { items, offset } = windowItems(stage.apps, stage.idx, VISIBLE)
+
+ return (
+ <Box flexDirection="column" width={width}>
+ {title}
+ <Text color={t.color.text}>{T.connectors.add.pickApp}</Text>
+ {items.map((app, i) => (
+ <Text color={t.color.muted} {...chipRowProps(t, offset + i === stage.idx)} key={app} wrap="truncate-end">
+ {offset + i === stage.idx ? '▸ ' : ' '}
+ {app}
+ </Text>
+ ))}
+ {footer}
+ <OverlayHint t={t}>{T.connectors.add.pickHint}</OverlayHint>
+ </Box>
+ )
+}
+
+function LinkView({ footer, stage, t, title, width }: StageViewProps<'link'>) {
+ const T = useT()
+
+ const heading = stage.reconnect
+ ? T.connectors.link.reconnectTitle(stage.app, stage.name)
+ : T.connectors.link.title(stage.app, stage.name)
+
+ return (
+ <Box flexDirection="column" width={width}>
+ {title}
+ <Text color={t.color.text}>{heading}</Text>
+ {stage.target?.connect_url ? (
+ <Text color={t.color.accent}>{stage.target.connect_url}</Text>
+ ) : (
+ <Text color={t.color.muted}>{T.connectors.link.starting}</Text>
+ )}
+ {stage.target?.detail ? <Text color={t.color.error}>{stage.target.detail}</Text> : null}
+ <Text color={t.color.muted}>{T.connectors.link.waiting}</Text>
+ {footer}
+ <OverlayHint t={t}>{T.connectors.link.hint}</OverlayHint>
+ </Box>
+ )
+}
+
interface KeyLike {
downArrow: boolean
escape: boolean