On Windows WSL2, ConPTY implicitly enables mouse event injection when the alternate screen buffer (DEC 1049) is entered, causing raw escape sequences to appear in the transcript as ghost characters. Fix (two parts): 1. ConPTY fix: send DISABLE_MOUSE_TRACKING immediately after entering alt screen when mouse tracking is off (AlternateScreen.tsx) 2. Runtime toggle: add /mouse [on|off|toggle] slash command with config persistence (display.tui_mouse) so users can manage this at runtime The env var HERMES_TUI_DISABLE_MOUSE continues to work as the initial default, but can now be overridden via /mouse and persisted to config. Closes: upstream ConPTY mouse injection issue Credits: OutThisLife / PR #13716 for the toggle concept
416 lines
12 KiB
TypeScript
416 lines
12 KiB
TypeScript
import type { SessionInfo, SlashCategory, Usage } from './types.js'
|
|
|
|
export interface GatewaySkin {
|
|
banner_hero?: string
|
|
banner_logo?: string
|
|
branding?: Record<string, string>
|
|
colors?: Record<string, string>
|
|
help_header?: string
|
|
tool_prefix?: string
|
|
}
|
|
|
|
export interface GatewayCompletionItem {
|
|
display: string
|
|
meta?: string
|
|
text: string
|
|
}
|
|
|
|
export interface GatewayTranscriptMessage {
|
|
context?: string
|
|
name?: string
|
|
role: 'assistant' | 'system' | 'tool' | 'user'
|
|
text?: string
|
|
}
|
|
|
|
// ── Commands / completion ────────────────────────────────────────────
|
|
|
|
export interface CommandsCatalogResponse {
|
|
canon?: Record<string, string>
|
|
categories?: SlashCategory[]
|
|
pairs?: [string, string][]
|
|
skill_count?: number
|
|
sub?: Record<string, string[]>
|
|
warning?: string
|
|
}
|
|
|
|
export interface CompletionResponse {
|
|
items?: GatewayCompletionItem[]
|
|
replace_from?: number
|
|
}
|
|
|
|
export interface SlashExecResponse {
|
|
output?: string
|
|
warning?: string
|
|
}
|
|
|
|
export type CommandDispatchResponse =
|
|
| { output?: string; type: 'exec' | 'plugin' }
|
|
| { target: string; type: 'alias' }
|
|
| { message?: string; name: string; type: 'skill' }
|
|
| { message: string; type: 'send' }
|
|
|
|
// ── Config ───────────────────────────────────────────────────────────
|
|
|
|
export interface ConfigDisplayConfig {
|
|
bell_on_complete?: boolean
|
|
details_mode?: string
|
|
inline_diffs?: boolean
|
|
sections?: Record<string, string>
|
|
show_cost?: boolean
|
|
show_reasoning?: boolean
|
|
streaming?: boolean
|
|
thinking_mode?: string
|
|
tui_compact?: boolean
|
|
tui_mouse?: boolean
|
|
tui_statusbar?: 'bottom' | 'off' | 'on' | 'top' | boolean
|
|
}
|
|
|
|
export interface ConfigFullResponse {
|
|
config?: { display?: ConfigDisplayConfig }
|
|
}
|
|
|
|
export interface ConfigMtimeResponse {
|
|
mtime?: number
|
|
}
|
|
|
|
export interface ConfigGetValueResponse {
|
|
display?: string
|
|
home?: string
|
|
value?: string
|
|
}
|
|
|
|
export interface ConfigSetResponse {
|
|
credential_warning?: string
|
|
history_reset?: boolean
|
|
info?: SessionInfo
|
|
value?: string
|
|
warning?: string
|
|
}
|
|
|
|
export interface SetupStatusResponse {
|
|
provider_configured?: boolean
|
|
}
|
|
|
|
// ── Session lifecycle ────────────────────────────────────────────────
|
|
|
|
export interface SessionCreateResponse {
|
|
info?: SessionInfo & { config_warning?: string; credential_warning?: string }
|
|
session_id: string
|
|
}
|
|
|
|
export interface SessionResumeResponse {
|
|
info?: SessionInfo
|
|
message_count?: number
|
|
messages: GatewayTranscriptMessage[]
|
|
resumed?: string
|
|
session_id: string
|
|
}
|
|
|
|
export interface SessionListItem {
|
|
id: string
|
|
message_count: number
|
|
preview: string
|
|
source?: string
|
|
started_at: number
|
|
title: string
|
|
}
|
|
|
|
export interface SessionListResponse {
|
|
sessions?: SessionListItem[]
|
|
}
|
|
|
|
export interface SessionUndoResponse {
|
|
removed?: number
|
|
}
|
|
|
|
export interface SessionUsageResponse {
|
|
cache_read?: number
|
|
cache_write?: number
|
|
calls?: number
|
|
compressions?: number
|
|
context_max?: number
|
|
context_percent?: number
|
|
context_used?: number
|
|
cost_status?: 'estimated' | 'exact'
|
|
cost_usd?: number
|
|
input?: number
|
|
model?: string
|
|
output?: number
|
|
total?: number
|
|
}
|
|
|
|
export interface SessionCompressResponse {
|
|
info?: SessionInfo
|
|
messages?: GatewayTranscriptMessage[]
|
|
removed?: number
|
|
usage?: Usage
|
|
}
|
|
|
|
export interface SessionBranchResponse {
|
|
session_id?: string
|
|
title?: string
|
|
}
|
|
|
|
export interface SessionCloseResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
export interface SessionInterruptResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
export interface SessionSteerResponse {
|
|
status?: 'queued' | 'rejected'
|
|
text?: string
|
|
}
|
|
|
|
// ── Prompt / submission ──────────────────────────────────────────────
|
|
|
|
export interface PromptSubmitResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
export interface BackgroundStartResponse {
|
|
task_id?: string
|
|
}
|
|
|
|
export interface BtwStartResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
export interface ClarifyRespondResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
export interface ApprovalRespondResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
export interface SudoRespondResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
export interface SecretRespondResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
// ── Shell / clipboard / input ────────────────────────────────────────
|
|
|
|
export interface ShellExecResponse {
|
|
code: number
|
|
stderr?: string
|
|
stdout?: string
|
|
}
|
|
|
|
export interface ClipboardPasteResponse {
|
|
attached?: boolean
|
|
count?: number
|
|
height?: number
|
|
message?: string
|
|
token_estimate?: number
|
|
width?: number
|
|
}
|
|
|
|
export interface InputDetectDropResponse {
|
|
height?: number
|
|
is_image?: boolean
|
|
matched?: boolean
|
|
name?: string
|
|
text?: string
|
|
token_estimate?: number
|
|
width?: number
|
|
}
|
|
|
|
export interface TerminalResizeResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
// ── Image attach ─────────────────────────────────────────────────────
|
|
|
|
export interface ImageAttachResponse {
|
|
height?: number
|
|
name?: string
|
|
remainder?: string
|
|
token_estimate?: number
|
|
width?: number
|
|
}
|
|
|
|
// ── Voice ────────────────────────────────────────────────────────────
|
|
|
|
export interface VoiceToggleResponse {
|
|
audio_available?: boolean
|
|
available?: boolean
|
|
details?: string
|
|
enabled?: boolean
|
|
stt_available?: boolean
|
|
tts?: boolean
|
|
}
|
|
|
|
export interface VoiceRecordResponse {
|
|
status?: string
|
|
text?: string
|
|
}
|
|
|
|
// ── Tools (TS keeps configure since it resets local history) ─────────
|
|
|
|
export interface ToolsConfigureResponse {
|
|
changed?: string[]
|
|
enabled_toolsets?: string[]
|
|
info?: SessionInfo
|
|
missing_servers?: string[]
|
|
reset?: boolean
|
|
unknown?: string[]
|
|
}
|
|
|
|
// ── Model picker ─────────────────────────────────────────────────────
|
|
|
|
export interface ModelOptionProvider {
|
|
is_current?: boolean
|
|
models?: string[]
|
|
name: string
|
|
slug: string
|
|
total_models?: number
|
|
warning?: string
|
|
}
|
|
|
|
export interface ModelOptionsResponse {
|
|
model?: string
|
|
provider?: string
|
|
providers?: ModelOptionProvider[]
|
|
}
|
|
|
|
// ── MCP ──────────────────────────────────────────────────────────────
|
|
|
|
export interface ReloadMcpResponse {
|
|
ok?: boolean
|
|
}
|
|
|
|
// ── Subagent events ──────────────────────────────────────────────────
|
|
|
|
export interface SubagentEventPayload {
|
|
api_calls?: number
|
|
cost_usd?: number
|
|
depth?: number
|
|
duration_seconds?: number
|
|
files_read?: string[]
|
|
files_written?: string[]
|
|
goal: string
|
|
input_tokens?: number
|
|
iteration?: number
|
|
model?: string
|
|
output_tail?: { is_error?: boolean; preview?: string; tool?: string }[]
|
|
output_tokens?: number
|
|
parent_id?: null | string
|
|
reasoning_tokens?: number
|
|
status?: 'completed' | 'failed' | 'interrupted' | 'queued' | 'running'
|
|
subagent_id?: string
|
|
summary?: string
|
|
task_count?: number
|
|
task_index: number
|
|
text?: string
|
|
tool_count?: number
|
|
tool_name?: string
|
|
tool_preview?: string
|
|
toolsets?: string[]
|
|
}
|
|
|
|
// ── Delegation control RPCs ──────────────────────────────────────────
|
|
|
|
export interface DelegationStatusResponse {
|
|
active?: {
|
|
depth?: number
|
|
goal?: string
|
|
model?: null | string
|
|
parent_id?: null | string
|
|
started_at?: number
|
|
status?: string
|
|
subagent_id?: string
|
|
tool_count?: number
|
|
}[]
|
|
max_concurrent_children?: number
|
|
max_spawn_depth?: number
|
|
paused?: boolean
|
|
}
|
|
|
|
export interface DelegationPauseResponse {
|
|
paused?: boolean
|
|
}
|
|
|
|
export interface SubagentInterruptResponse {
|
|
found?: boolean
|
|
subagent_id?: string
|
|
}
|
|
|
|
// ── Spawn-tree snapshots ─────────────────────────────────────────────
|
|
|
|
export interface SpawnTreeListEntry {
|
|
count: number
|
|
finished_at?: number
|
|
label?: string
|
|
path: string
|
|
session_id?: string
|
|
started_at?: number | null
|
|
}
|
|
|
|
export interface SpawnTreeListResponse {
|
|
entries?: SpawnTreeListEntry[]
|
|
}
|
|
|
|
export interface SpawnTreeLoadResponse {
|
|
finished_at?: number
|
|
label?: string
|
|
session_id?: string
|
|
started_at?: null | number
|
|
subagents?: unknown[]
|
|
}
|
|
|
|
export interface SpawnTreeSaveResponse {
|
|
path?: string
|
|
session_id?: string
|
|
}
|
|
|
|
export type GatewayEvent =
|
|
| { payload?: { skin?: GatewaySkin }; session_id?: string; type: 'gateway.ready' }
|
|
| { payload?: GatewaySkin; session_id?: string; type: 'skin.changed' }
|
|
| { payload: SessionInfo; session_id?: string; type: 'session.info' }
|
|
| { payload?: { text?: string }; session_id?: string; type: 'thinking.delta' }
|
|
| { payload?: undefined; session_id?: string; type: 'message.start' }
|
|
| { payload?: { kind?: string; text?: string }; session_id?: string; type: 'status.update' }
|
|
| { payload?: { state?: 'idle' | 'listening' | 'transcribing' }; session_id?: string; type: 'voice.status' }
|
|
| { payload?: { no_speech_limit?: boolean; text?: string }; session_id?: string; type: 'voice.transcript' }
|
|
| { payload: { line: string }; session_id?: string; type: 'gateway.stderr' }
|
|
| { payload?: { cwd?: string; python?: string }; session_id?: string; type: 'gateway.start_timeout' }
|
|
| { payload?: { preview?: string }; session_id?: string; type: 'gateway.protocol_error' }
|
|
| { payload?: { text?: string }; session_id?: string; type: 'reasoning.delta' | 'reasoning.available' }
|
|
| { payload: { name?: string; preview?: string }; session_id?: string; type: 'tool.progress' }
|
|
| { payload: { name?: string }; session_id?: string; type: 'tool.generating' }
|
|
| { payload: { context?: string; name?: string; tool_id: string }; session_id?: string; type: 'tool.start' }
|
|
| {
|
|
payload: { error?: string; inline_diff?: string; name?: string; summary?: string; tool_id: string }
|
|
session_id?: string
|
|
type: 'tool.complete'
|
|
}
|
|
| {
|
|
payload: { choices: string[] | null; question: string; request_id: string }
|
|
session_id?: string
|
|
type: 'clarify.request'
|
|
}
|
|
| { payload: { command: string; description: string }; session_id?: string; type: 'approval.request' }
|
|
| { payload: { request_id: string }; session_id?: string; type: 'sudo.request' }
|
|
| { payload: { env_var: string; prompt: string; request_id: string }; session_id?: string; type: 'secret.request' }
|
|
| { payload: { task_id: string; text: string }; session_id?: string; type: 'background.complete' }
|
|
| { payload: { text: string }; session_id?: string; type: 'btw.complete' }
|
|
| { payload: SubagentEventPayload; session_id?: string; type: 'subagent.spawn_requested' }
|
|
| { payload: SubagentEventPayload; session_id?: string; type: 'subagent.start' }
|
|
| { payload: SubagentEventPayload; session_id?: string; type: 'subagent.thinking' }
|
|
| { payload: SubagentEventPayload; session_id?: string; type: 'subagent.tool' }
|
|
| { payload: SubagentEventPayload; session_id?: string; type: 'subagent.progress' }
|
|
| { payload: SubagentEventPayload; session_id?: string; type: 'subagent.complete' }
|
|
| { payload: { rendered?: string; text?: string }; session_id?: string; type: 'message.delta' }
|
|
| {
|
|
payload?: { reasoning?: string; rendered?: string; text?: string; usage?: Usage }
|
|
session_id?: string
|
|
type: 'message.complete'
|
|
}
|
|
| { payload?: { message?: string }; session_id?: string; type: 'error' }
|