The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: canonical TUI honours the hermes --tui -v / -Q tool-progress launch pin
Teknium2841c85e6714
diff --git a/ui-tui/src/__tests__/gatewayClient.test.ts b/ui-tui/src/__tests__/gatewayClient.test.tsindex 3cd862706c4..ecc1388f746 100644--- a/ui-tui/src/__tests__/gatewayClient.test.ts+++ b/ui-tui/src/__tests__/gatewayClient.test.ts@@ -237,6 +237,48 @@ describe('GatewayClient websocket attach mode', () => {} finally { gw.kill(); vi.useRealTimers() }})+ it('pins the launcher tool-progress mode (hermes --tui -v) on the created session before returning it', async () => {+ vi.useFakeTimers()+ delete process.env.HERMES_TUI_GATEWAY_URL+ vi.stubEnv('HERMES_TUI_TOOL_PROGRESS', 'verbose')+ const gw = new GatewayClient(async () => ({ url: 'ws://gateway.test/api/ws', protocols: [], instance_id: 'owner', profile_id: 'fixture' }))+ gw.on('event', () => undefined)++ try {+ gw.start(); gw.drain()+ await vi.advanceTimersByTimeAsync(0)+ const socket = FakeWebSocket.instances[0]!+ socket.open()+ await vi.advanceTimersByTimeAsync(0)+ const frames = () => socket.sent.map(text => JSON.parse(text) as { id: number; method: string; params: any })++ const reply = (method: string, result: unknown) => {+ const frame = frames().filter(f => f.method === method).at(-1)!++ socket.message(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result }))+ }++ reply('runtime.describe', { session_create: { sources: ['tui'], parameters: ['source', 'request_id'] } })+ await vi.advanceTimersByTimeAsync(0)+ let settled = false++ const created = gw.request<{ session_id: string }>('session.create', {}).then(r => {+ settled = true++ return r+ })+++ await vi.advanceTimersByTimeAsync(0)+ reply('session.create', { session_id: 'fresh', info: {} })+ await vi.advanceTimersByTimeAsync(0)+ expect(settled).toBe(false)+ expect(frames().at(-1)).toMatchObject({ method: 'config.set', params: { key: 'verbose', session_id: 'fresh', value: 'verbose' } })+ reply('config.set', { key: 'verbose', value: 'verbose', scope: 'session' })+ await expect(created).resolves.toMatchObject({ session_id: 'fresh' })+ } finally { gw.kill(); vi.unstubAllEnvs(); vi.useRealTimers() }+ })+it('re-ensures a crashed owner on a bounded number of reconnects, then stays discovery-only', async () => {vi.useFakeTimers()delete process.env.HERMES_TUI_GATEWAY_URLdiff --git a/ui-tui/src/canonicalGateway.ts b/ui-tui/src/canonicalGateway.tsindex b67a1182383..11c54932e59 100644--- a/ui-tui/src/canonicalGateway.ts+++ b/ui-tui/src/canonicalGateway.ts@@ -115,3 +115,18 @@ export function localCreationOptions(env = process.env): Record<string, unknown>return options}++const TOOL_PROGRESS_MODES = new Set(['off', 'new', 'all', 'verbose'])++/** `hermes --tui -v` / `-Q` export HERMES_TUI_TOOL_PROGRESS (verbose / off). The owner carries it as the+ * session-scoped tool-progress mode (`config.set key=verbose`, the same control `/verbose` writes), so a+ * fresh session is pinned right after creation. An unreadable value refuses the launch, never drops it. */+export function launchToolProgress(env = process.env): string | undefined {+ const raw = env.HERMES_TUI_TOOL_PROGRESS?.trim().toLowerCase()++ if (!raw) { return undefined }++ if (!TOOL_PROGRESS_MODES.has(raw)) { throw new Error(`invalid HERMES_TUI_TOOL_PROGRESS: ${raw}`) }++ return raw+}diff --git a/ui-tui/src/gatewayClient.ts b/ui-tui/src/gatewayClient.tsindex a5a1a2cb528..cdbac9d8bda 100644--- a/ui-tui/src/gatewayClient.ts+++ b/ui-tui/src/gatewayClient.ts@@ -14,7 +14,13 @@ import {import { reconnectBackoffDelayMs } from '@hermes/shared/reconnect-backoff'import { WebSocket as UndiciWebSocket } from 'undici'-import { canonicalEvent, canonicalRequest, canonicalResult, type CreationContract } from './canonicalGateway.js'+import {+ canonicalEvent,+ canonicalRequest,+ canonicalResult,+ type CreationContract,+ launchToolProgress+} from './canonicalGateway.js'import type { AnyGatewayEvent } from './gatewayTypes.js'import { t } from './i18n/runtime.js'import { CircularBuffer } from './lib/circularBuffer.js'@@ -834,9 +840,17 @@ export class GatewayClient extends EventEmitter {if (method === 'session.create' && !this.creationContract) { await this.describeRuntime() }const request = canonicalRequest(method, params, this.creationContract)+ const toolProgress = method === 'session.create' ? launchToolProgress() : undefined+ const value = await this.requestOverWebSocket<T>(request.method, request.params, timeoutMs)++ if (toolProgress) {+ // Launch pin, before the caller can submit: a refusal fails this create visibly.+ const sid = (value as { session_id?: string } | null)?.session_id++ await this.requestOverWebSocket('config.set', { key: 'verbose', session_id: sid, value: toolProgress })+ }- return this.requestOverWebSocket<T>(request.method, request.params, timeoutMs)- .then(value => canonicalResult(method, value, request.params))+ return canonicalResult(method, value, request.params)})}