mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-03 17:27:37 +08:00
Match classic CLI perceived startup behavior: show the TUI shell and composer before constructing the full AIAgent. session.create now returns a lightweight placeholder session with lazy=true and no longer starts _make_agent eagerly. The first method that needs the agent triggers _start_agent_build() via _sess(); prompt.submit is routed through the RPC worker pool so that the initial wait for agent construction does not block the stdio dispatcher. The intro panel renders skeleton rows for tools/skills while the real session.info payload is absent, then hydrates to the real tools/skills panel once AIAgent initialization completes. Also skip the startup /voice status probe and avoid the input.detect_drop RPC for ordinary plain-text prompts to keep early startup/first-submit paths cheap. Measurements on macOS Terminal.app: - Previous full ready p50 after earlier PR commits: ~1537ms - Lazy skeleton panel p50: ~794ms - Original baseline full ready p50: ~1843ms So the visible startup surface is now ~743ms faster than the prior PR state and ~1.05s faster than the original baseline. First prompt still pays the same agent construction cost if it races the background/skeleton state, matching classic CLI's deferred behavior. Tests: - python -m py_compile tui_gateway/server.py - cd ui-tui && npm run type-check && npm run build - scripts/run_tests.sh tests/tui_gateway/test_protocol.py::test_sess_found tests/tools/test_code_execution_modes.py tests/tools/test_code_execution.py - cd ui-tui && npm test -- --run src/__tests__/useSessionLifecycle.test.ts src/__tests__/useConfigSync.test.ts
205 lines
4.3 KiB
TypeScript
205 lines
4.3 KiB
TypeScript
export interface ActiveTool {
|
|
context?: string
|
|
id: string
|
|
name: string
|
|
startedAt?: number
|
|
}
|
|
|
|
export interface TodoItem {
|
|
content: string
|
|
id: string
|
|
status: 'cancelled' | 'completed' | 'in_progress' | 'pending'
|
|
}
|
|
|
|
export interface ActivityItem {
|
|
id: number
|
|
text: string
|
|
tone: 'error' | 'info' | 'warn'
|
|
}
|
|
|
|
export interface SubagentProgress {
|
|
apiCalls?: number
|
|
costUsd?: number
|
|
depth: number
|
|
durationSeconds?: number
|
|
filesRead?: string[]
|
|
filesWritten?: string[]
|
|
goal: string
|
|
id: string
|
|
index: number
|
|
inputTokens?: number
|
|
iteration?: number
|
|
model?: string
|
|
notes: string[]
|
|
outputTail?: SubagentOutputEntry[]
|
|
outputTokens?: number
|
|
parentId: null | string
|
|
reasoningTokens?: number
|
|
startedAt?: number
|
|
status: 'completed' | 'failed' | 'interrupted' | 'queued' | 'running'
|
|
summary?: string
|
|
taskCount: number
|
|
thinking: string[]
|
|
toolCount: number
|
|
tools: string[]
|
|
toolsets?: string[]
|
|
}
|
|
|
|
export interface SubagentOutputEntry {
|
|
isError: boolean
|
|
preview: string
|
|
tool: string
|
|
}
|
|
|
|
export interface SubagentNode {
|
|
aggregate: SubagentAggregate
|
|
children: SubagentNode[]
|
|
item: SubagentProgress
|
|
}
|
|
|
|
export interface SubagentAggregate {
|
|
activeCount: number
|
|
costUsd: number
|
|
descendantCount: number
|
|
filesTouched: number
|
|
hotness: number
|
|
inputTokens: number
|
|
maxDepthFromHere: number
|
|
outputTokens: number
|
|
totalDuration: number
|
|
totalTools: number
|
|
}
|
|
|
|
export interface DelegationStatus {
|
|
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 ApprovalReq {
|
|
command: string
|
|
description: string
|
|
}
|
|
|
|
export interface ConfirmReq {
|
|
cancelLabel?: string
|
|
confirmLabel?: string
|
|
danger?: boolean
|
|
detail?: string
|
|
onConfirm: () => void
|
|
title: string
|
|
}
|
|
|
|
export interface ClarifyReq {
|
|
choices: string[] | null
|
|
question: string
|
|
requestId: string
|
|
}
|
|
|
|
export interface Msg {
|
|
info?: SessionInfo
|
|
kind?: 'diff' | 'intro' | 'panel' | 'slash' | 'trail'
|
|
panelData?: PanelData
|
|
role: Role
|
|
text: string
|
|
thinking?: string
|
|
thinkingTokens?: number
|
|
toolTokens?: number
|
|
tools?: string[]
|
|
todos?: TodoItem[]
|
|
todoIncomplete?: boolean
|
|
todoCollapsedByDefault?: boolean
|
|
}
|
|
|
|
export type Role = 'assistant' | 'system' | 'tool' | 'user'
|
|
export type DetailsMode = 'hidden' | 'collapsed' | 'expanded'
|
|
export type ThinkingMode = 'collapsed' | 'truncated' | 'full'
|
|
|
|
// Per-section overrides for the agent details accordion. Resolution order
|
|
// at lookup time is: explicit `display.sections.<name>` → built-in
|
|
// SECTION_DEFAULTS → global `details_mode`. Today the built-in defaults
|
|
// expand `thinking`/`tools` and hide `activity`; `subagents` falls through
|
|
// to the global mode. Any explicit value still wins for that one section.
|
|
export type SectionName = 'thinking' | 'tools' | 'subagents' | 'activity'
|
|
export type SectionVisibility = Partial<Record<SectionName, DetailsMode>>
|
|
|
|
export interface McpServerStatus {
|
|
connected: boolean
|
|
name: string
|
|
tools: number
|
|
transport: string
|
|
}
|
|
|
|
export interface SessionInfo {
|
|
cwd?: string
|
|
fast?: boolean
|
|
lazy?: boolean
|
|
mcp_servers?: McpServerStatus[]
|
|
model: string
|
|
reasoning_effort?: string
|
|
release_date?: string
|
|
service_tier?: string
|
|
skills: Record<string, string[]>
|
|
tools: Record<string, string[]>
|
|
update_behind?: number | null
|
|
update_command?: string
|
|
usage?: Usage
|
|
version?: string
|
|
}
|
|
|
|
export interface Usage {
|
|
calls: number
|
|
context_max?: number
|
|
context_percent?: number
|
|
context_used?: number
|
|
cost_usd?: number
|
|
input: number
|
|
output: number
|
|
total: number
|
|
}
|
|
|
|
export interface SudoReq {
|
|
requestId: string
|
|
}
|
|
|
|
export interface SecretReq {
|
|
envVar: string
|
|
prompt: string
|
|
requestId: string
|
|
}
|
|
|
|
export interface PanelData {
|
|
sections: PanelSection[]
|
|
title: string
|
|
}
|
|
|
|
export interface PanelSection {
|
|
items?: string[]
|
|
rows?: [string, string][]
|
|
text?: string
|
|
title?: string
|
|
}
|
|
|
|
export interface SlashCatalog {
|
|
canon: Record<string, string>
|
|
categories: SlashCategory[]
|
|
pairs: [string, string][]
|
|
skillCount: number
|
|
sub: Record<string, string[]>
|
|
}
|
|
|
|
export interface SlashCategory {
|
|
name: string
|
|
pairs: [string, string][]
|
|
}
|