Skip to content

The agent that grows with you

Merge remote-tracking branch 'origin/main' into feat/store-guest-onboarding

ethernet3724ace0c881
diff --cc agent/skill_commands.py
index b0502307876,164a369a40e..bfbf7976548
--- a/agent/skill_commands.py
+++ b/agent/skill_commands.py
@@@ -6,10 -6,9 +6,10 @@@ import o
import re
import threading
from pathlib import Path
- from typing import Any, Dict, Optional
+ from typing import Any, Dict, Mapping, Optional
from hermes_constants import display_hermes_home
+from agent.initiate_setup_prompt import HEADER as INITIATE_SETUP_HEADER
from agent.prompt_cache_boundary import register_stable_prefix
from agent.skill_preprocessing import load_skills_config as _load_skills_config, preprocess_skill_content
from agent.skill_utils import AMBIGUOUS_SKILL_PREFIX
diff --cc apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.ts
index 37a737328fc,7ce9b6af0e1..9113291a368
--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.ts
@@@ -377,7 -374,7 +377,8 @@@ export function handleMessageStreamEven
payload?.persisted_turn,
Boolean(payload?.response_transformed),
typeof payload?.status === 'string' ? payload.status : undefined,
- payload?.attachments
++ payload?.attachments,
+ payload?.response_reused === true
)
// Onboarding's first build: between turns is the only moment Setup may
diff --cc apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/types.ts
index 19df5cc2a76,0cb8b6e24a3..75f38a55ef9
--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/types.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/types.ts
@@@ -29,7 -24,7 +29,8 @@@ export interface GatewayEventDeps
persistedTurn?: PersistedTurn | null,
responseTransformed?: boolean,
status?: string,
- attachments?: MediaAttachment[] | null
++ attachments?: MediaAttachment[] | null,
+ responseReused?: boolean
) => void
failAssistantMessage: (
sessionId: string,
diff --cc apps/desktop/src/app/session/hooks/use-message-stream/index.ts
index d57461a5340,90707a010e2..77b20aed8d4
--- a/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
@@@ -12,12 -13,13 +12,14 @@@ import
completeOpenTimelineParts,
type GatewayEventPayload,
mergeFinalAssistantText,
+ normalizeWs,
+ partsText,
reasoningPart,
- renderMediaTags,
sealOpenToolParts,
+ textPart,
toolCallOwnerMessageId,
- upsertToolPart
+ upsertToolPart,
+ withAttachmentParts
} from '@/lib/chat-messages'
import type { ErrorSurface } from '@/lib/error-surface'
import {
@@@ -742,7 -728,7 +744,8 @@@ export function useMessageStream(
persistedTurn?: PersistedTurn | null,
responseTransformed?: boolean,
status?: string,
- attachments?: MediaAttachment[] | null
++ attachments?: MediaAttachment[] | null,
+ responseReused?: boolean
) => {
let shouldHydrate = false
diff --cc apps/desktop/src/lib/chat-messages/index.ts
index f2bfb7d68c1,73f646c1b07..50544f1119c
--- a/apps/desktop/src/lib/chat-messages/index.ts
+++ b/apps/desktop/src/lib/chat-messages/index.ts
@@@ -9,15 -9,15 +9,16 @@@ export
completeOpenTimelineParts,
dedupeRepeatedTextInParts,
finalizeInterruptedMessages,
+ isAttachmentPart,
mergeFinalAssistantText,
normalizeWs,
+ partsText,
reasoningPart,
reasoningTextFromDetails,
- renderMediaTags,
- textPart
+ textPart,
+ withAttachmentParts
} from './parts'
-export type { UnspokenTurnSpeech } from './parts'
+export type { AttachmentPart, UnspokenTurnSpeech } from './parts'
export {
branchGroupForUser,
preserveLocalAssistantErrors,
diff --cc apps/desktop/src/lib/chat-messages/parts.ts
index 0cd7c4fb452,dd468f9b1fa..196bff32e49
--- a/apps/desktop/src/lib/chat-messages/parts.ts
+++ b/apps/desktop/src/lib/chat-messages/parts.ts
@@@ -114,48 -112,202 +114,48 @@@ export function reasoningTextFromDetail
return text.join('\n\n').trim()
}
-/**
- * Known deliverable file extensions — mirrors the Python-side
- * `MEDIA_DELIVERY_EXTS` in `gateway/platforms/base.py` so the two surfaces
- * agree on which `MEDIA:` paths are valid. Used to anchor the end of an
- * unquoted path that may contain interior spaces (#96657).
- */
-const MEDIA_DELIVERY_EXTS = [
- 'png',
- 'jpg',
- 'jpeg',
- 'gif',
- 'webp',
- 'bmp',
- 'tiff',
- 'svg',
- 'mp4',
- 'mov',
- 'avi',
- 'mkv',
- 'webm',
- '3gp',
- 'mp3',
- 'm2a',
- 'wav',
- 'ogg',
- 'opus',
- 'm4a',
- 'flac',
- 'pdf',
- 'docx',
- 'doc',
- 'odt',
- 'rtf',
- 'txt',
- 'md',
- 'epub',
- 'xlsx',
- 'xls',
- 'ods',
- 'csv',
- 'tsv',
- 'json',
- 'xml',
- 'yaml',
- 'yml',
- 'kmz',
- 'kml',
- 'geojson',
- 'gpx',
- 'pptx',
- 'ppt',
- 'odp',
- 'key',
- 'zip',
- 'tar',
- 'gz',
- 'tgz',
- 'bz2',
- 'xz',
- '7z',
- 'rar',
- 'apk',
- 'ipa',
- 'html',
- 'htm'
-] as const
-
-// Sort longest-first so the alternation never matches a shorter ext as a
-// prefix of a longer one (e.g. `tar` before a hypothetical `tar.gz`).
-const _MEDIA_EXT_ALTERNATION = [...MEDIA_DELIVERY_EXTS].sort((a, b) => b.length - a.length).join('|')
-
-/**
- * Unquoted path branch: starts with a path anchor (`~/`, `/`, `X:\` or `X:/`),
- * allows interior whitespace, and anchors the end on a known deliverable
- * extension. Matches the Python-side `MEDIA_TAG_CLEANUP_RE` behavior where
- * `(?:[^\S\n]+\S+?)*?\.(?:EXT)` permits spaces inside filenames (#96657).
- */
-const _MEDIA_PATH_ANCHORED = `(?:~/|/|[A-Za-z]:[/\\\\])\\S+?(?:[^\\S\\n]+\\S+?)*?\\.(?:${_MEDIA_EXT_ALTERNATION})(?=[\\s\`"'*_,;:)\\]}]|MEDIA:|$)`
-
-// Bare-word fallback for paths the anchored branch misses (relative paths,
-// unknown extensions). Stop before backtick and double-quote so an inline-code
-// closer is not swallowed. Apostrophes stay legal inside the path.
-const _MEDIA_PATH_BARE = '[^\\s`"]+'
-
-// Sentence punctuation that can trail a bare capture when the tag sits in
-// prose (`open MEDIA:/tmp/a.pdf.`).
-const _MEDIA_TRAILING_PUNCTUATION = '.,;:!?'
+/** A file a `MEDIA:` tag delivered. The gateway parses the tag once and sends
+ * it as an attachment beside clean text; the transcript shows it as a card. */
+export const ATTACHMENT_PART = 'attachment'
-/**
- * Whether a capture can name a real deliverable: a path separator, or a dot
- * with file content after it (an extension or a dotfile — `report.md`,
- * `.env`, `../a.png`). Anything else (`...`, a lone quote, a bare English
- * word) renders as prose: a dead `#media:` link for a non-path is worse
- * than no link (#84361).
- */
-function isPlausibleMediaPath(value: string): boolean {
- return value.includes('/') || value.includes('\\') || /\.[^.]/.test(value)
+export type AttachmentPart = Extract<ChatMessagePart, { type: 'data' }> & {
+ data: MediaAttachment
+ name: typeof ATTACHMENT_PART
}
-const MEDIA_LINE_RE = new RegExp(
- `(^|\\n)[\\t ]*[\`"']?MEDIA:\\s*(?<line>\`[^\`\n]+\`|"[^"\n]+"|'[^'\n]+'|${_MEDIA_PATH_ANCHORED}|${_MEDIA_PATH_BARE})[\`"']?[\\t ]*(\\n|$)`,
- 'g'
-)
-
-const MEDIA_TAG_RE = new RegExp(
- `[\`"']?MEDIA:\\s*(?<inline>\`[^\`\n]+\`|"[^"\n]+"|'[^'\n]+'|${_MEDIA_PATH_ANCHORED}|${_MEDIA_PATH_BARE})[\`"']?`,
- 'g'
-)
+export function attachmentPart(attachment: MediaAttachment): ChatMessagePart {
+ return { type: 'data', name: ATTACHMENT_PART, data: { path: attachment.path } }
+}
-function unquoteMediaPath(value: string): string {
- const trimmed = value.trim()
- const quote = trimmed[0]
+export function isAttachmentPart(part: ChatMessagePart): part is AttachmentPart {
+ return part.type === 'data' && part.name === ATTACHMENT_PART
+}
- if (quote && quote === trimmed.at(-1) && ['"', "'", '`'].includes(quote)) {
- return trimmed.slice(1, -1)
+/** Add each delivered file once, after everything already in `parts`. A file
+ * that echoes a generated image stays in the tool slot only. */
+export function withAttachmentParts(
+ parts: ChatMessagePart[],
+ attachments: readonly MediaAttachment[] | null | undefined
+): ChatMessagePart[] {
+ if (!attachments?.length) {
+ return parts
}
- // A trailing backtick or double-quote left in the value is formatting residue,
- // not part of the path. Apostrophes are not residue (`john's.md`).
- const last = trimmed.at(-1)
-
- return last === '`' || last === '"' ? trimmed.slice(0, -1) : trimmed
-}
-
-/**
- * Split a bare (unquoted) capture into its path and the sentence punctuation
- * that trailed it in prose: `open MEDIA:/tmp/a.pdf.` captures `/tmp/a.pdf.` —
- * the period belongs to the sentence, not the path. Punctuation is only
- * prose while what precedes it still names a path, so an ellipsis
- * (`MEDIA:...`) is never split into a degenerate capture. Quoted captures are
- * exempt (quotes are the documented escape hatch for odd names:
- * `MEDIA:'/tmp/stop!.md'` keeps its `!`).
- */
-function splitTrailingPunctuation(value: string): { path: string; punctuation: string } {
- let end = value.length
+ const shown = new Set([...parts.filter(isAttachmentPart).map(part => part.data.path), ...generatedImageEchoSources(parts)])
+ const fresh: ChatMessagePart[] = []
- while (end > 0 && _MEDIA_TRAILING_PUNCTUATION.includes(value[end - 1] ?? '')) {
- if (!isPlausibleMediaPath(value.slice(0, end - 1))) {
- break
+ for (const attachment of attachments) {
+ if (!shown.has(attachment.path)) {
+ shown.add(attachment.path)
+ fresh.push(attachmentPart(attachment))
}
-
- end -= 1
}
- return { path: value.slice(0, end), punctuation: value.slice(end) }
-}
-
-function mediaLink(value: string): string | null {
- const raw = value.trim()
- const quote = raw[0]
- const quoted = quote && quote === raw.at(-1) && ['"', "'", '`'].includes(quote)
-
- // Quoted captures are the escape hatch for odd names — punctuation inside
- // the quotes is part of the path, so only a BARE capture is split.
- const { path, punctuation } = quoted
- ? { path: unquoteMediaPath(raw), punctuation: '' }
- : splitTrailingPunctuation(unquoteMediaPath(raw))
-
- return isPlausibleMediaPath(path) ? `[${mediaDisplayLabel(path)}](${mediaMarkdownHref(path)})${punctuation}` : null
-}
-
-export function renderMediaTags(text: string): string {
- return text
- .replace(MEDIA_LINE_RE, (match, lead: string, value: string, trailer: string) => {
- const link = mediaLink(value)
-
- return link ? `${lead}${link}${trailer}` : match
- })
- .replace(MEDIA_TAG_RE, (match, value: string) => mediaLink(value) ?? match)
-}
-
-/** Raw `MEDIA:` values in `text`, quotes intact — the one parser Artifacts and chat share.
- * Bare captures shed trailing sentence punctuation (same rule as
- * {@link renderMediaTags}); degenerate non-path captures are dropped. */
-export function mediaTagValues(text: string): string[] {
- return [...text.matchAll(MEDIA_TAG_RE)]
- .map(match => match[1] ?? '')
- .flatMap(value => {
- const { path, punctuation } = splitTrailingPunctuation(unquoteMediaPath(value))
-
- if (!isPlausibleMediaPath(path)) {
- return []
- }
-
- // Bare captures shed the prose punctuation (it trails the raw value
- // too); quoted captures keep every character inside their quotes.
- return [punctuation ? value.slice(0, -punctuation.length || undefined) : value]
- })
-}
-
-export function assistantTextPart(text: string, timestamp?: number): ChatMessagePart {
- return textPart(renderMediaTags(text), timestamp)
+ return fresh.length ? [...parts, ...fresh] : parts
}
- export function chatMessageText(message: ChatMessage): string {
- return message.parts
+ export function partsText(parts: ChatMessagePart[]): string {
+ return parts
.filter((part): part is Extract<ChatMessagePart, { type: 'text' }> => part.type === 'text')
.map(part => part.text)
.join('')
diff --cc apps/desktop/src/plugins/hermes-bots/group-round-members.ts
index 8935a075497,394f7452f2c..4cf6cce42c5
--- a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-round-members.ts
@@@ -180,9 -187,22 +191,24 @@@ export async function runGroupRoundMemb
let accepted = false
try {
- reply = await runVisibleMemberTurn(context, member, prompt, deltaImages)
+ reply = await runVisibleMemberTurn(context, member, prompt, deltaImages, attachments => {
+ replyAttachments = attachments
+ })
+
+ // #129443: the participation rules ("reply only with something new,
+ // else (pass)") let a directly addressed member pass just because a
+ // teammate already answered — the room then settles as ordinary
+ // consensus and the user's explicit address silently disappears. One
+ // bounded nudge re-asks with the directive spelled out; the recovered
+ // reply replaces the pass and flows through the exact same commit path
+ // below. A nudge that throws falls into the catch like any failed turn.
+ // `isCurrent()` (not the bare binding): a superseded drive's pass is
+ // discarded by the epoch check right below anyway, so nudging it would
+ // burn a model call whose result can never be committed.
+ if (context.isCurrent() && reply !== null && isGroupPassText(reply) && context.addressedKeys?.has(memberKey)) {
+ reply = await runVisibleMemberTurn(context, member, `${prompt}${GROUP_ADDRESSED_NUDGE_SUFFIX}`, deltaImages)
+ }
+
accepted = true
// Needs-attention hook (#93091 item 3): a turn that produced a real
@@@ -280,10 -300,27 +306,27 @@@
})
}
- const spoke = reply !== null && !isGroupPassText(reply)
+ const spoke = reply !== null && (!isGroupPassText(reply) || replyAttachments.length > 0)
if (reply !== null && spoke) {
- appendGroupChatEntry(context.group, groupMemberAuthor(member), reply, thread)
+ appendGroupChatEntry(context.group, groupMemberAuthor(member), reply, thread, undefined, replyAttachments)
+ } else if (reply !== null && context.isCurrent() && context.addressedKeys?.has(memberKey)) {
+ // #129443: the nudge was passed on too. Record the noncompliance where
+ // the user looks (activity row + roster badge) instead of letting the
+ // user's explicit address settle as ordinary quiet consensus. Only a
+ // CURRENT drive's pass is disclosed: a turn the epoch check just
+ // tolerated committing (a cross-thread send superseded its drive) is
+ // stale residue, and flagging it would point the user at an address
+ // their newer send already moved past.
+ const reason = 'explicitly addressed member passed twice'
+
+ recordGroupActivity(context.group, {
+ kind: 'failed',
+ member: groupMemberKey(member),
+ reason,
+ thread
+ })
+ noteBotAttention(groupMemberKey(member), reason)
}
// A member's own entries — its reply, and the rows group-external-writes.ts
diff --cc hermes_cli/plugins_cmd_install.py
index fe3e8bb5c55,3befb589784..7417bcf76ca
--- a/hermes_cli/plugins_cmd_install.py
+++ b/hermes_cli/plugins_cmd_install.py
@@@ -388,13 -400,9 +400,12 @@@ def _install_plugin_core
_refuse_unavailable_portable_plugin(plugin_name, tmp_target)
if target.exists() and not force:
+ from pm.environments import cli_command_name
+ from pm.paths import repo_root
+
raise _pc().PluginOperationError(
f"Plugin '{plugin_name}' already exists. Use force reinstall "
- f"or run `hermes plugins update {plugin_name}`.")
+ f"or run `{cli_command_name(repo_root())} plugins update {plugin_name}`.")
- prior = old_metadata.get(plugin_name)
if target.exists() and requested_revision is None and isinstance(prior, dict) and prior.get("pinned") is True:
raise _pc().PluginOperationError(
f"Plugin '{plugin_name}' is pinned. Reinstall it with an explicit "
diff --cc pm/environments.py
index 02a303a3bbf,95423b67e43..c1fe127569a
--- a/pm/environments.py
+++ b/pm/environments.py
@@@ -142,18 -165,28 +195,26 @@@ def base_venv(project_root: Path) -> Pa
return payload_venv(project_root) or project_venv_dir(Path(project_root).resolve()) or Path(project_root).resolve() / "venv"
- def store_root(project_root: Path) -> Path:
- """Resolve a payload-relative or stamped store before PM imports."""
- override = os.environ.get("HERMES_RUNTIME_DIR")
- if override:
- return Path(override).resolve()
+ def store_root(project_root: Path, *, honor_runtime_override: bool = True) -> Path:
+ """Resolve a payload-relative or stamped store before PM imports.
+
+ ``HERMES_RUNTIME_DIR`` exists so a running process can point PM at a
+ non-default runtime location. Publication paths must pass
+ ``honor_runtime_override=False``: a persisted artifact (an installed
+ launcher) has to bind the store of the tree it serves, never a runtime
+ directory inherited through the environment.
+ """
+ if honor_runtime_override:
+ override = os.environ.get("HERMES_RUNTIME_DIR")
+ if override:
+ return Path(override).resolve()
root = Path(project_root).resolve()
- manifest_path = root.parent / "manifest.json"
- if manifest_path.is_file():
- manifest = json.loads(manifest_path.read_text(encoding="utf-8-sig"))
- if (root.parent / manifest.get("repo", "")).resolve() == root:
- store = (root.parent / manifest["store"]).resolve()
- if not store.is_relative_to(root.parent):
- raise RuntimeError("payload store escapes its root")
- return store
+ manifest = _payload_manifest(root)
+ if manifest is not None:
+ store = (root.parent / manifest["store"]).resolve()
+ if not store.is_relative_to(root.parent):
+ raise RuntimeError("payload store escapes its root")
+ return store
from pm.paths import install_stamp_path
for directory in (root, *root.parents):