mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-20 05:01:30 +00:00
/goal was silently broken outside the classic CLI.
TUI: /goal was routed through the HermesCLI slash-worker subprocess,
which set the goal row in SessionDB but then called
_pending_input.put(state.goal) — the subprocess has no reader for that
queue, so the kickoff message was discarded. No post-turn judge was
wired into prompt.submit either, so even a manual kickoff would not
continue the goal loop. Intercept /goal in command.dispatch instead,
drive GoalManager directly, and return {type: send, notice, message}
so the TUI client renders the Goal-set notice and fires the kickoff.
Run the judge in _run_prompt_submit after message.complete, surface
the verdict via status.update {kind: goal}, and chain the continuation
turn after the running guard is released.
Gateway: _post_turn_goal_continuation was gated on
hasattr(adapter, 'send_message'), but adapters only expose send().
That branch was dead on every platform — users never saw
'✓ Goal achieved', 'Continuing toward goal', or budget-exhausted
messages. Replace the dead call with adapter.send(chat_id, content,
metadata) and drop a broken reference to self._loop.
Tests:
- tests/tui_gateway/test_goal_command.py — full /goal dispatch matrix
(set / status / pause / resume / clear / stop / done / whitespace)
plus regressions for slash.exec → 4018 and 'goal' staying in
_PENDING_INPUT_COMMANDS.
- tests/gateway/test_goal_verdict_send.py — locks in the adapter.send
path for done / continue / budget-exhausted and verifies the hook
no-ops when no goal is set or the adapter lacks send().
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import type { CommandDispatchResponse } from '../gatewayTypes.js'
|
|
|
|
export type RpcResult = Record<string, any>
|
|
|
|
export const asRpcResult = <T extends RpcResult = RpcResult>(value: unknown): T | null =>
|
|
!value || typeof value !== 'object' || Array.isArray(value) ? null : (value as T)
|
|
|
|
export const asCommandDispatch = (value: unknown): CommandDispatchResponse | null => {
|
|
const o = asRpcResult(value)
|
|
|
|
if (!o || typeof o.type !== 'string') {
|
|
return null
|
|
}
|
|
|
|
const t = o.type
|
|
|
|
if (t === 'exec' || t === 'plugin') {
|
|
return { type: t, output: typeof o.output === 'string' ? o.output : undefined }
|
|
}
|
|
|
|
if (t === 'alias' && typeof o.target === 'string') {
|
|
return { type: 'alias', target: o.target }
|
|
}
|
|
|
|
if (t === 'skill' && typeof o.name === 'string') {
|
|
return { type: 'skill', name: o.name, message: typeof o.message === 'string' ? o.message : undefined }
|
|
}
|
|
|
|
if (t === 'send' && typeof o.message === 'string') {
|
|
return {
|
|
type: 'send',
|
|
message: o.message,
|
|
notice: typeof o.notice === 'string' ? o.notice : undefined,
|
|
}
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
export const rpcErrorMessage = (err: unknown) =>
|
|
err instanceof Error && err.message ? err.message : typeof err === 'string' && err.trim() ? err : 'request failed'
|