mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix(tui): render MEDIA: as a clickable file chip, drop audio directive
The agent emits `MEDIA:<path>` to signal file delivery to the gateway, and `[[audio_as_voice]]` as a voice-delivery hint. The gateway strips both before sending to Telegram/Discord/Slack, but the TUI was rendering them raw through markdown — which is also how the intraword underscore bug originally surfaced (`browser_screenshot_ecc…`). At the `Md` layer, detect both sentinels on their own line: - `MEDIA:<path>` → `▸ <path>` with the path rendered literal and wrapped in a `Link` for OSC 8 hyperlink support (absolute paths get a `file://` URL, so modern terminals make them click-to-open). - `[[audio_as_voice]]` → dropped silently; it has no meaning in TUI. Covers tests for quoted/backticked MEDIA variants, Windows drive paths, whitespace, and the inline-in-prose case (left untouched — still protected by the intraword-underscore guard).
This commit is contained in:
parent
b17eb94907
commit
97c2da2112
2 changed files with 55 additions and 1 deletions
|
|
@ -12,6 +12,9 @@ const DEF_RE = /^\s*:\s+(.+)$/
|
|||
const TABLE_DIVIDER_CELL_RE = /^:?-{3,}:?$/
|
||||
const MD_URL_RE = '((?:[^\\s()]|\\([^\\s()]*\\))+?)'
|
||||
|
||||
export const MEDIA_LINE_RE = /^\s*[`"']?MEDIA:\s*(\S+?)[`"']?\s*$/
|
||||
export const AUDIO_DIRECTIVE_RE = /^\s*\[\[audio_as_voice\]\]\s*$/
|
||||
|
||||
export const INLINE_RE = new RegExp(
|
||||
`(!\\[(.*?)\\]\\(${MD_URL_RE}\\)|\\[(.+?)\\]\\(${MD_URL_RE}\\)|<((?:https?:\\/\\/|mailto:)[^>\\s]+|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})>|~~(.+?)~~|\`([^\\\`]+)\`|\\*\\*(.+?)\\*\\*|(?<!\\w)__(.+?)__(?!\\w)|\\*(.+?)\\*|(?<!\\w)_(.+?)_(?!\\w)|==(.+?)==|\\[\\^([^\\]]+)\\]|\\^([^^\\s][^^]*?)\\^|~([^~\\s][^~]*?)~|(https?:\\/\\/[^\\s<]+))`,
|
||||
'g'
|
||||
|
|
@ -267,6 +270,35 @@ function MdImpl({ compact, t, text }: MdProps) {
|
|||
continue
|
||||
}
|
||||
|
||||
if (AUDIO_DIRECTIVE_RE.test(line)) {
|
||||
i++
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
const media = line.match(MEDIA_LINE_RE)
|
||||
|
||||
if (media) {
|
||||
start('paragraph')
|
||||
|
||||
const path = media[1]!
|
||||
const url = /^(?:\/|[a-z]:[\\/])/i.test(path) ? `file://${path}` : path
|
||||
|
||||
nodes.push(
|
||||
<Text color={t.color.dim} key={key}>
|
||||
{'▸ '}
|
||||
<Link url={url}>
|
||||
<Text color={t.color.amber} underline>
|
||||
{path}
|
||||
</Text>
|
||||
</Link>
|
||||
</Text>
|
||||
)
|
||||
i++
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
const fence = parseFence(line)
|
||||
|
||||
if (fence) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue