The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): /timestamps on the owner; refuse client-local commands with what to use
Tekniumf6e647421bd2
diff --git a/gateway/session_commands.py b/gateway/session_commands.pyindex 729d9931869..3c0443b8141 100644--- a/gateway/session_commands.py+++ b/gateway/session_commands.py@@ -101,6 +101,21 @@ _REFUSED_ARGUMENTS = {}+# What to use instead, for the client-local commands a shared-gateway session cannot run: they act+# on the host's profiles, state snapshots, terminal or git checkout, which the gateway may not share+# with the client. Rides the ``unsupported_command`` refusal as ``data.detail`` (the reason stays the+# same, so shipped clients keep working); Ink and Desktop print it under the refusal.+REFUSAL_HINTS = {+ 'export': 'Run `hermes profile export [name] -o <file>` in a terminal.',+ 'import': 'Run `hermes profile import <archive> [--name <name>]` in a terminal.',+ 'snapshot': 'Run `hermes backup --quick` in a terminal (restore: `hermes --cli`, then /snapshot restore).',+ 'handoff': 'Hand off from the classic CLI: `hermes --cli --resume <session>`, then /handoff <platform>.',+ 'hatch': 'Generate a pet from the classic CLI (`hermes --cli`, then /hatch), or use /pet to pick one.',+ 'worktree': 'Start in a fresh worktree with `hermes -w`, or use the classic CLI (`hermes --cli`).',+ 'palette': 'Type / to search commands (the composer completes and filters them).',+}++def command_verdict(name, arg=''):"""``read`` / ``control`` / ``refused`` for a canonical registry command on a local session."""if _REFUSED_ARGUMENTS.get(name, lambda _a: False)(arg):@@ -422,7 +437,7 @@ async def execute_command(connection, ref, params, *, dispatch=False):'session:control' if definition or runner_command else 'session:submit')authority.authorize(actor, ref, capability)if verdict == 'refused':- raise RuntimeStoreError('unsupported_command')+ raise RuntimeStoreError('unsupported_command', detail=REFUSAL_HINTS.get(canonical))from gateway.session_local import authorize_local_sourcelive = authority.sessions[ref.session_id]if authorize_local_source(authority.runner, live.source) is not True:diff --git a/gateway/session_tui_config.py b/gateway/session_tui_config.pyindex 006f31df8b8..27af22abdd3 100644--- a/gateway/session_tui_config.py+++ b/gateway/session_tui_config.py@@ -46,6 +46,8 @@ def _toggles():'density': ('tui_compact', {'on': True, 'off': False},lambda d: not bool(d.get('tui_compact', False)), on_off),'battery': ('battery', _BOOL_WORDS, lambda d: not bool(d.get('battery', False)), on_off),+ # The classic CLI's /timestamps key: [HH:MM] on transcript rows (T10).+ 'timestamps': ('timestamps', _BOOL_WORDS, lambda d: not bool(d.get('timestamps', False)), on_off),'statusbar': ('tui_statusbar', {'on': 'top', **{m: m for m in _STATUSBAR_MODES}},lambda d: 'top' if _statusbar(d.get('tui_statusbar', 'top')) == 'off' else 'off', str),'mouse': ('mouse_tracking', _MOUSE_TRACKING_ALIASES,diff --git a/tests/gateway/test_session_tui_config.py b/tests/gateway/test_session_tui_config.pyindex 960b20c8138..d90872fd017 100644--- a/tests/gateway/test_session_tui_config.py+++ b/tests/gateway/test_session_tui_config.py@@ -162,3 +162,19 @@ def test_personality_persists_to_the_profile_and_drives_the_next_turn(tmp_path):assert result.get('result', {}).get('value') == 'none', resultassert _display(home)['personality'] == ''asyncio.run(probe())++[email protected]("linux")+def test_timestamps_toggle_persists_display_timestamps(tmp_path):+ """T10: Ink's /timestamps writes ``display.timestamps`` (the classic CLI's key) through the+ owner's config.set; on|off|toggle like the other display toggles."""+ with owner(tmp_path) as (home, _peer, desc):+ async def probe():+ async with websocket(home, desc) as ws:+ assert (await rpc(ws, 'config.set', key='timestamps', value='on'))['result'] == {+ 'key': 'timestamps', 'value': 'on'}+ assert _display(home)['timestamps'] is True+ assert (await rpc(ws, 'config.set', key='timestamps', value=''))['result']['value'] == 'off'+ assert _display(home)['timestamps'] is False+ assert (await rpc(ws, 'config.set', key='timestamps', value='maybe'))['error']['message'] == 'invalid_params'+ asyncio.run(probe())diff --git a/tests/gateway/test_session_tui_ops.py b/tests/gateway/test_session_tui_ops.pyindex f42d3ec15a1..9a446ece64d 100644--- a/tests/gateway/test_session_tui_ops.py+++ b/tests/gateway/test_session_tui_ops.py@@ -302,3 +302,21 @@ def test_voice_record_follows_the_sessions_gateway_voice_mode(tmp_path):again = await rpc(ws, 'voice.record', action='start', session_id=sid)assert again.get('error', {}).get('code') == 4015, againasyncio.run(probe())++[email protected]("linux")+def test_cli_only_commands_refuse_with_what_to_use_instead(tmp_path):+ """T10: the commands a local session cannot run on the shared gateway keep the+ ``unsupported_command`` reason, and the refusal now names the alternative in ``data.detail``."""+ with owner(tmp_path) as (home, _peer, desc):+ async def probe():+ async with websocket(home, desc) as ws:+ sid = (await rpc(ws, 'session.create', request_id='refuse', source='tui', toolsets=[]))['result']['session_id']+ for command, hint in [('export', 'hermes profile export'), ('import x.tar.gz', 'hermes profile import'),+ ('snapshot', 'hermes backup'), ('snap list', 'hermes backup'),+ ('handoff telegram', 'hermes --cli'), ('hatch a cat', 'hermes --cli'),+ ('worktree new', 'hermes -w'), ('palette', 'Type /')]:+ refused = (await rpc(ws, 'slash.exec', command=command, session_id=sid))['error']+ assert refused['message'] == 'unsupported_command', (command, refused)+ assert hint in refused['data'].get('detail', ''), (command, refused)+ asyncio.run(probe())diff --git a/ui-tui/src/__tests__/canonicalSlashCommands.test.ts b/ui-tui/src/__tests__/canonicalSlashCommands.test.tsindex a5ffd67f33d..c3d13ec84ed 100644--- a/ui-tui/src/__tests__/canonicalSlashCommands.test.ts+++ b/ui-tui/src/__tests__/canonicalSlashCommands.test.ts@@ -419,3 +419,24 @@ it('/config pages the owner\'s presentation config (config.get full), never slasexpect(text).toContain(' skin: ares')expect(text).toContain(' record_key: ctrl+b')})++it('/timestamps toggles display.timestamps on the owner (config.set) and the transcript at once (T10)', async () => {+ const { request, slash, sys } = harness()++ slash('/timestamps on')+ await flush()+ expect(getUiState().timestamps).toBe(true)+ expect(request).toHaveBeenCalledWith('config.set', { key: 'timestamps', value: 'on' })++ slash('/ts')+ await flush()+ expect(getUiState().timestamps).toBe(false)+ expect(request).toHaveBeenCalledWith('config.set', { key: 'timestamps', value: 'off' })++ slash('/timestamps status')+ await flush()+ const notices = sys.mock.calls.map(([text]) => String(text))+ expect(notices).toContain('timestamps off')+ expect(notices.some(line => /not available/.test(line))).toBe(false)+ expect(request.mock.calls.some(([method]) => method === 'slash.exec')).toBe(false)+})diff --git a/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.ts b/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.tsindex b421311c002..1a6ebb13549 100644--- a/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.ts+++ b/ui-tui/src/__tests__/canonicalUnsupportedCommand.test.ts@@ -42,3 +42,36 @@ it.each([expect(sys.mock.calls.map(([line]) => String(line))).toEqual([`/${name} is not available on the shared gateway yet`])})++it.each([+ ['/export', 'export', 'Run `hermes profile export [name] -o <file>` in a terminal.'],+ ['/worktree new', 'worktree', 'Start in a fresh worktree with `hermes -w`, or use the classic CLI (`hermes --cli`).'],+ ['/palette', 'palette', 'Type / to search commands (the composer completes and filters them).']+])('%s names the refusal and what to use instead (T10)', async (cmd, name, hint) => {+ const request = vi.fn(async (method: string) => {+ if (method === 'slash.exec') {+ throw new JsonRpcGatewayError('unsupported_command', {+ code: 4001,+ data: { detail: hint, reason: 'unsupported_command' }+ })+ }++ return {}+ })++ const sys = vi.fn()++ createSlashHandler({+ composer: { enqueue: vi.fn() },+ gateway: { gw: { isCanonical: true, request }, rpc: request },+ local: { catalog: { canon: { [`/${name}`]: `/${name}` } }, getHistoryItems: () => [], getLastUserMsg: () => '' },+ session: {},+ slashFlightRef: { current: 0 },+ transcript: { page: vi.fn(), panel: vi.fn(), send: vi.fn(), setHistoryItems: vi.fn(), sys }+ } as never)(cmd)+ await flush()++ expect(sys.mock.calls.map(([line]) => String(line))).toEqual([+ `/${name} is not available on the shared gateway yet\n${hint}`+ ])+})diff --git a/ui-tui/src/app/slash/commands/core.ts b/ui-tui/src/app/slash/commands/core.tsindex 02f9a5b6c15..3017cdd9a7b 100644--- a/ui-tui/src/app/slash/commands/core.ts+++ b/ui-tui/src/app/slash/commands/core.ts@@ -337,6 +337,32 @@ export const coreCommands: SlashCommand[] = [}},+ {+ aliases: ['ts'],+ help: 'toggle [HH:MM] timestamps on transcript messages [on|off|status]',+ name: 'timestamps',+ run: (arg, ctx) => {+ const mode = arg.trim().toLowerCase()+ const current = ctx.ui.timestamps++ // T10: `display.timestamps` (the classic CLI's key) through the owner's config.set; the+ // transcript repaints on the same frame, as /density does.+ if (mode === 'status') {+ return ctx.transcript.sys(`timestamps ${current ? 'on' : 'off'}`)+ }++ const next = flagFromArg(mode, current)++ if (next === null) {+ return ctx.transcript.sys('usage: /timestamps [on|off|status]')+ }++ patchUiState({ timestamps: next })+ ctx.transcript.sys(`timestamps ${next ? 'on' : 'off'}`)+ saveDisplayPref(ctx, 'timestamps', next ? 'on' : 'off')+ }+ },+{help: 'show the presentation settings the gateway serves for this profile',name: 'config',diff --git a/ui-tui/src/app/userMessages.ts b/ui-tui/src/app/userMessages.tsindex 94beaa5afd6..f242def114b 100644--- a/ui-tui/src/app/userMessages.ts+++ b/ui-tui/src/app/userMessages.ts@@ -185,7 +185,12 @@ export const describeSlashExecError = (command: string, err: unknown): string =>const text = message ?? ''if (isUnsupportedCommand(err)) {- return t('canonical.controls.notAvailable', command)+ // The owner names what to use instead for its client-local refusals (gateway/session_commands.py+ // REFUSAL_HINTS) in `data.detail`; print it under the refusal.+ const detail = (err as { data?: { detail?: unknown } } | null)?.data?.detail+ const refusal = t('canonical.controls.notAvailable', command)++ return typeof detail === 'string' && detail.trim() ? `${refusal}\n${detail.trim()}` : refusal}if (/slash worker timed out/.test(text)) {diff --git a/website/docs/developer-guide/gateway-command-parity.md b/website/docs/developer-guide/gateway-command-parity.mdindex fa8c337ab16..39333cb5357 100644--- a/website/docs/developer-guide/gateway-command-parity.md+++ b/website/docs/developer-guide/gateway-command-parity.md@@ -117,7 +117,7 @@ handler does; `client-local (cli_only)` commands are terminal/UI features of a c| `/subgoal` | control | HermesCLI._handle_subgoal_command | slash.exec | slash.exec | slash.exec | || `/subscription` (/upgrade) | refused | HermesCLI._show_subscription | sidecar: subscription.state | slash.exec: refused | slash.exec: refused | client-local (cli_only) || `/suggestions` (/suggest) | read (bare only) | HermesCLI._handle_suggestions_command | slash.exec | slash.exec | slash.exec | |-| `/timestamps` (/ts) | refused | HermesCLI._handle_timestamps_command | slash.exec: refused | slash.exec: refused | slash.exec: refused | client-local (cli_only) |+| `/timestamps` (/ts) | refused | HermesCLI._handle_timestamps_command | local (preference not saved) | slash.exec: refused | slash.exec: refused | client-local (cli_only) || `/title` | control | HermesCLI._cmd_title | canonical route | action: title | session.mutate rename (bare: slash.exec) | || `/tools` | refused | HermesCLI._handle_tools_command | refused: not available yet | slash.exec: refused | session.info | client-local (cli_only) || `/toolsets` | read | HermesCLI.show_toolsets | slash.exec | unavailable: terminal | slash.exec | client-local (cli_only) |