herm-tui 1.0.0-dev.1 → 1.0.0-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +8 -4
  2. package/assets/eikons/ares.eikon +367 -0
  3. package/assets/eikons/default.eikon +398 -0
  4. package/assets/eikons/mono.eikon +395 -0
  5. package/db.worker.js +81 -0
  6. package/highlights-eq9cgrbb.scm +604 -0
  7. package/highlights-ghv9g403.scm +205 -0
  8. package/highlights-hk7bwhj4.scm +284 -0
  9. package/highlights-r812a2qc.scm +150 -0
  10. package/highlights-x6tmsnaa.scm +115 -0
  11. package/index.js +4151 -0
  12. package/injections-73j83es3.scm +27 -0
  13. package/package.json +14 -64
  14. package/parser.worker.js +8 -0
  15. package/tree-sitter-3jzf13jk.wasm +0 -0
  16. package/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  17. package/tree-sitter-markdown-411r6y9b.wasm +0 -0
  18. package/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  19. package/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  20. package/tree-sitter-zig-e78zbjpm.wasm +0 -0
  21. package/scripts/postinstall.ts +0 -29
  22. package/src/app/gateway.tsx +0 -83
  23. package/src/app/gatewayEvents.ts +0 -203
  24. package/src/app/launch.ts +0 -41
  25. package/src/app/skin.tsx +0 -31
  26. package/src/app/spawnHistory.ts +0 -75
  27. package/src/app/tabs.ts +0 -23
  28. package/src/app/turnReducer.ts +0 -390
  29. package/src/app/useAppKeys.ts +0 -268
  30. package/src/app/useAtRefPopover.ts +0 -99
  31. package/src/app/useInputHistory.ts +0 -66
  32. package/src/app/useSession.ts +0 -102
  33. package/src/app/useSlashCommands.ts +0 -70
  34. package/src/app/useSlashPopover.ts +0 -48
  35. package/src/app.tsx +0 -917
  36. package/src/commands/slash.ts +0 -151
  37. package/src/components/avatar/AnimatedAvatar.tsx +0 -66
  38. package/src/components/avatar/eikon.ts +0 -144
  39. package/src/components/avatar/states/error.ts +0 -1155
  40. package/src/components/avatar/states/idle.ts +0 -1155
  41. package/src/components/avatar/states/index.ts +0 -30
  42. package/src/components/avatar/states/listening.ts +0 -1155
  43. package/src/components/avatar/states/speaking.ts +0 -1155
  44. package/src/components/avatar/states/thinking.ts +0 -1155
  45. package/src/components/avatar/states/working.ts +0 -1155
  46. package/src/components/chat/AtRefPopover.tsx +0 -54
  47. package/src/components/chat/CodeBlock.tsx +0 -67
  48. package/src/components/chat/Composer.tsx +0 -347
  49. package/src/components/chat/DiffBlock.tsx +0 -116
  50. package/src/components/chat/ErrorBlock.tsx +0 -70
  51. package/src/components/chat/MediaChip.tsx +0 -114
  52. package/src/components/chat/MessageItem.tsx +0 -282
  53. package/src/components/chat/MessageList.tsx +0 -114
  54. package/src/components/chat/PromptCard.tsx +0 -359
  55. package/src/components/chat/SlashPopover.tsx +0 -158
  56. package/src/components/chat/ThoughtCloud.tsx +0 -185
  57. package/src/components/chat/TypingIndicator.tsx +0 -25
  58. package/src/components/chat/tool/Subagent.tsx +0 -75
  59. package/src/components/chat/tool/frame.tsx +0 -69
  60. package/src/components/chat/tool/index.tsx +0 -65
  61. package/src/components/chat/tool/preview.ts +0 -57
  62. package/src/components/sidebar/ContextGauge.tsx +0 -102
  63. package/src/components/sidebar/Sidebar.tsx +0 -143
  64. package/src/components/tabs/TabBar.tsx +0 -50
  65. package/src/components/ui/FileLink.tsx +0 -52
  66. package/src/config/index.ts +0 -156
  67. package/src/config/lane.ts +0 -161
  68. package/src/config/models.ts +0 -95
  69. package/src/config/rules.ts +0 -80
  70. package/src/config/schema.ts +0 -308
  71. package/src/dialogs/alert.tsx +0 -52
  72. package/src/dialogs/chafa.tsx +0 -72
  73. package/src/dialogs/confirm.tsx +0 -58
  74. package/src/dialogs/curator.tsx +0 -153
  75. package/src/dialogs/eikon-picker.tsx +0 -95
  76. package/src/dialogs/help.tsx +0 -80
  77. package/src/dialogs/history.tsx +0 -92
  78. package/src/dialogs/info.tsx +0 -115
  79. package/src/dialogs/keys.tsx +0 -170
  80. package/src/dialogs/logs.tsx +0 -42
  81. package/src/dialogs/message.tsx +0 -38
  82. package/src/dialogs/model-picker.tsx +0 -123
  83. package/src/dialogs/new-profile.tsx +0 -69
  84. package/src/dialogs/new-task.tsx +0 -103
  85. package/src/dialogs/profile.tsx +0 -55
  86. package/src/dialogs/rollback.tsx +0 -190
  87. package/src/dialogs/spawn-history.tsx +0 -80
  88. package/src/dialogs/text-prompt.tsx +0 -68
  89. package/src/dialogs/theme-picker.tsx +0 -50
  90. package/src/home/index.ts +0 -23
  91. package/src/home/store.ts +0 -267
  92. package/src/index.tsx +0 -113
  93. package/src/keys/catalog.ts +0 -115
  94. package/src/keys/chord.ts +0 -125
  95. package/src/keys/conflicts.ts +0 -48
  96. package/src/keys/context.tsx +0 -112
  97. package/src/keys/index.ts +0 -5
  98. package/src/keys/list.ts +0 -94
  99. package/src/keys/oc-compat.ts +0 -87
  100. package/src/tabs/Agents.tsx +0 -607
  101. package/src/tabs/Analytics.tsx +0 -154
  102. package/src/tabs/Chat.tsx +0 -50
  103. package/src/tabs/Config.tsx +0 -605
  104. package/src/tabs/Context.tsx +0 -599
  105. package/src/tabs/Cron.tsx +0 -294
  106. package/src/tabs/Env.tsx +0 -227
  107. package/src/tabs/Kanban.tsx +0 -367
  108. package/src/tabs/Memory.tsx +0 -294
  109. package/src/tabs/Sessions.tsx +0 -786
  110. package/src/tabs/Skills.tsx +0 -507
  111. package/src/tabs/Toolsets.tsx +0 -266
  112. package/src/theme/builtin.ts +0 -78
  113. package/src/theme/context.tsx +0 -106
  114. package/src/theme/index.ts +0 -4
  115. package/src/theme/resolve.ts +0 -134
  116. package/src/theme/syntax.ts +0 -31
  117. package/src/theme/themes/aura.json +0 -69
  118. package/src/theme/themes/ayu.json +0 -80
  119. package/src/theme/themes/carbonfox.json +0 -248
  120. package/src/theme/themes/catppuccin-frappe.json +0 -233
  121. package/src/theme/themes/catppuccin-macchiato.json +0 -233
  122. package/src/theme/themes/catppuccin.json +0 -112
  123. package/src/theme/themes/cobalt2.json +0 -228
  124. package/src/theme/themes/cursor.json +0 -249
  125. package/src/theme/themes/dracula.json +0 -219
  126. package/src/theme/themes/everforest.json +0 -241
  127. package/src/theme/themes/flexoki.json +0 -237
  128. package/src/theme/themes/github.json +0 -233
  129. package/src/theme/themes/gruvbox.json +0 -242
  130. package/src/theme/themes/kanagawa.json +0 -77
  131. package/src/theme/themes/lucent-orng.json +0 -237
  132. package/src/theme/themes/material.json +0 -235
  133. package/src/theme/themes/matrix.json +0 -77
  134. package/src/theme/themes/mercury.json +0 -252
  135. package/src/theme/themes/monokai.json +0 -221
  136. package/src/theme/themes/nightowl.json +0 -221
  137. package/src/theme/themes/nord.json +0 -223
  138. package/src/theme/themes/one-dark.json +0 -84
  139. package/src/theme/themes/opencode.json +0 -245
  140. package/src/theme/themes/orng.json +0 -249
  141. package/src/theme/themes/osaka-jade.json +0 -93
  142. package/src/theme/themes/palenight.json +0 -222
  143. package/src/theme/themes/rosepine.json +0 -234
  144. package/src/theme/themes/solarized.json +0 -223
  145. package/src/theme/themes/synthwave84.json +0 -226
  146. package/src/theme/themes/tokyonight.json +0 -243
  147. package/src/theme/themes/vercel.json +0 -245
  148. package/src/theme/themes/vesper.json +0 -218
  149. package/src/theme/themes/zenburn.json +0 -223
  150. package/src/theme/types.ts +0 -119
  151. package/src/types/message.ts +0 -97
  152. package/src/ui/ChafaImage.tsx +0 -64
  153. package/src/ui/Splash.tsx +0 -118
  154. package/src/ui/borders.ts +0 -28
  155. package/src/ui/command.tsx +0 -104
  156. package/src/ui/dialog-select.tsx +0 -164
  157. package/src/ui/dialog.tsx +0 -102
  158. package/src/ui/fmt.ts +0 -82
  159. package/src/ui/kv.tsx +0 -28
  160. package/src/ui/shell.tsx +0 -45
  161. package/src/ui/spinner.tsx +0 -59
  162. package/src/ui/splash-art.ts +0 -123
  163. package/src/ui/table.tsx +0 -117
  164. package/src/ui/ticker.tsx +0 -90
  165. package/src/ui/toast.tsx +0 -130
  166. package/src/utils/categorical.ts +0 -77
  167. package/src/utils/chafa.ts +0 -173
  168. package/src/utils/clipboard.ts +0 -67
  169. package/src/utils/context-segments.ts +0 -317
  170. package/src/utils/control.ts +0 -495
  171. package/src/utils/drop.ts +0 -25
  172. package/src/utils/editor.ts +0 -33
  173. package/src/utils/fuzzy.ts +0 -45
  174. package/src/utils/gateway-client.ts +0 -253
  175. package/src/utils/gateway-types.ts +0 -282
  176. package/src/utils/git.ts +0 -57
  177. package/src/utils/hermes-analytics.ts +0 -134
  178. package/src/utils/hermes-home.ts +0 -821
  179. package/src/utils/hermes-kanban.ts +0 -154
  180. package/src/utils/hermes-profiles.ts +0 -217
  181. package/src/utils/interpolate.ts +0 -31
  182. package/src/utils/math-unicode.ts +0 -818
  183. package/src/utils/memory-activity.ts +0 -140
  184. package/src/utils/open-file.ts +0 -13
  185. package/src/utils/paths.ts +0 -52
  186. package/src/utils/perf.ts +0 -235
  187. package/src/utils/preferences.ts +0 -150
  188. package/src/utils/sessions-db.ts +0 -396
  189. package/src/utils/subagent-tree.ts +0 -146
  190. package/src/utils/terminal-reset.ts +0 -129
  191. package/src/utils/tips.ts +0 -67
  192. package/src/utils/tokens.ts +0 -87
@@ -1,143 +0,0 @@
1
- import { useState, memo, type ReactNode } from "react"
2
- import { AnimatedAvatar } from "../avatar/AnimatedAvatar"
3
- import type { ParsedEikon } from "../avatar/eikon"
4
- import { useTheme } from "../../theme"
5
- import type { AvatarState } from "../avatar/states"
6
- import type { SessionInfo } from "../../utils/gateway-types"
7
- import type { Usage } from "../../types/message"
8
- import { useGitBranch, rtrunc } from "../../utils/git"
9
- import { Tail } from "../chat/ThoughtCloud"
10
- import { ContextGauge } from "./ContextGauge"
11
-
12
- // The pillar body carries a compact identity block, the MCP operational
13
- // section, and a context-usage gauge at the bottom. Stats/Memory/Recent/
14
- // Identity wrapper and the Plugins section were removed — they duplicated
15
- // dedicated tabs and cluttered the most-visible surface.
16
-
17
- const WIDTH = 48
18
- const PAD_L = 12
19
-
20
- const trunc = (s: string, max: number) => s.length <= max ? s : s.slice(0, max - 1) + "…"
21
-
22
- // ─── Primitives (pillar-colored) ─────────────────────────────────────
23
-
24
- const Section = memo((props: {
25
- title: string; hint?: string
26
- open: boolean; onToggle: () => void
27
- children: ReactNode
28
- }) => {
29
- const theme = useTheme().theme
30
- const [hover, setHover] = useState(false)
31
- return (
32
- <box flexDirection="column" marginBottom={props.open ? 1 : 0}>
33
- <box height={1}
34
- onMouseDown={props.onToggle}
35
- onMouseOver={() => setHover(true)}
36
- onMouseOut={() => setHover(false)}>
37
- <text>
38
- <span fg={hover ? theme.hermBodyText : theme.hermBodyTextMuted}>
39
- {props.open ? "▾ " : "▸ "}
40
- </span>
41
- <span fg={theme.hermBodyText}><strong>{props.title}</strong></span>
42
- {props.hint ? <span fg={theme.hermBodyTextMuted}>{` ${props.hint}`}</span> : null}
43
- </text>
44
- </box>
45
- {props.open ? <box flexDirection="column">{props.children}</box> : null}
46
- </box>
47
- )
48
- })
49
-
50
- const Row = (props: { label: string; value: string; strong?: boolean }) => {
51
- const theme = useTheme().theme
52
- return (
53
- <box height={1}>
54
- <text>
55
- <span fg={theme.hermBodyTextMuted}>{` ${props.label.padEnd(PAD_L)}`}</span>
56
- {props.strong
57
- ? <span fg={theme.hermBodyText}><strong>{trunc(props.value, WIDTH - PAD_L - 4)}</strong></span>
58
- : <span fg={theme.hermBodyText}>{trunc(props.value, WIDTH - PAD_L - 4)}</span>}
59
- </text>
60
- </box>
61
- )
62
- }
63
-
64
- // ─── Main ────────────────────────────────────────────────────────────
65
-
66
- export const Sidebar = memo((props: {
67
- agentState?: AvatarState
68
- info?: SessionInfo | null
69
- usage?: Usage
70
- eikon?: ParsedEikon
71
- profile?: string
72
- title?: string
73
- cloud?: boolean
74
- pulse?: boolean
75
- onAvatar?: () => void
76
- }) => {
77
- const theme = useTheme().theme
78
- const state = props.agentState ?? "idle"
79
- const info = props.info
80
-
81
- const [mcpOpen, setMcpOpen] = useState(false)
82
-
83
- const cwd = info?.cwd ?? process.cwd()
84
- const branch = useGitBranch(cwd)
85
-
86
- return (
87
- <box width={WIDTH} flexDirection="column">
88
- {/* Avatar (bust) — also the anchor for the thought-cloud tail */}
89
- <box position="relative" flexDirection="column" height={24} overflow="hidden"
90
- onMouseDown={props.onAvatar}>
91
- <AnimatedAvatar state={state} eikon={props.eikon} />
92
- {props.cloud ? (
93
- <box position="absolute" left={0} top={0}>
94
- <Tail run={!!props.pulse} />
95
- </box>
96
- ) : null}
97
- </box>
98
-
99
- {/* Body (pillar) */}
100
- <box padding={1} flexDirection="column" flexGrow={1}
101
- backgroundColor={theme.hermBody} overflow="hidden">
102
-
103
- {/* Flat identity block — Title is primary (always rendered so the
104
- block doesn't reflow when `/title` fires), then Profile
105
- (which IS agent lineage — each profile is an isolated
106
- HERMES_HOME), then model/cwd/branch. */}
107
- <Row label="Title" value={props.title || "—"} strong={!!props.title} />
108
- <Row label="Profile" value={props.profile ?? "default"}
109
- strong={!!props.profile && props.profile !== "default"} />
110
- <Row label="Model" value={info?.model ?? "—"} />
111
- {info?.cwd ? <Row label="cwd" value={info.cwd} /> : null}
112
- {branch ? <Row label="Branch" value={rtrunc(branch, WIDTH - PAD_L - 4)} /> : null}
113
-
114
- {(info?.mcp_servers?.length ?? 0) > 0 ? (() => {
115
- const srv = info!.mcp_servers!
116
- const ok = srv.filter(s => s.connected).length
117
- return (
118
- <Section title="MCP"
119
- hint={`${ok}/${srv.length} up`}
120
- open={mcpOpen} onToggle={() => setMcpOpen(o => !o)}>
121
- {srv.map(s => (
122
- <box key={s.name} height={1}>
123
- <text>
124
- <span fg={theme.hermBodyTextMuted}>{" "}</span>
125
- <span fg={s.connected ? theme.hermBodyText : theme.hermBodyTextMuted}>
126
- {(s.connected ? "● " : "○ ") + trunc(s.name, 16).padEnd(16)}
127
- </span>
128
- <span fg={theme.hermBodyTextMuted}>
129
- {s.connected ? ` ${s.transport} · ${s.tools}t` : " failed"}
130
- </span>
131
- </text>
132
- </box>
133
- ))}
134
- </Section>
135
- )
136
- })() : null}
137
-
138
- <box flexGrow={1} />
139
- <ContextGauge info={info} usage={props.usage} width={WIDTH - 4} />
140
- </box>
141
- </box>
142
- )
143
- })
@@ -1,50 +0,0 @@
1
- import { memo } from "react"
2
- import { useTheme } from "../../theme"
3
- import { useKeys } from "../../keys"
4
-
5
- type Tab = {
6
- name: string
7
- description: string
8
- }
9
-
10
- type TabBarProps = {
11
- tabs: ReadonlyArray<Tab>
12
- activeTab: number
13
- onTabChange: (index: number) => void
14
- }
15
-
16
- // 1..9, 0, - — mirrors the <leader>+digit map in useAppKeys.
17
- const idx = (i: number) => i < 9 ? String(i + 1) : i === 9 ? "0" : "-"
18
-
19
- export const TabBar = memo(({ tabs, activeTab, onTabChange }: TabBarProps) => {
20
- const theme = useTheme().theme
21
- const keys = useKeys()
22
-
23
- return (
24
- <box width="100%" flexDirection="column" height={1}>
25
- <box flexDirection="row" overflow="hidden">
26
- {tabs.map((tab, i) => (
27
- <box
28
- key={i}
29
- onMouseDown={() => onTabChange(i)}
30
- paddingX={2}
31
- marginRight={1}
32
- flexShrink={0}
33
- backgroundColor={i === activeTab ? theme.backgroundElement : undefined}
34
- >
35
- <text attributes={3}>
36
- <span fg={theme.borderSubtle}>{idx(i)} </span>
37
- <span fg={i === activeTab ? theme.primary : theme.textMuted}>{tab.name}</span>
38
- </text>
39
- </box>
40
- ))}
41
- <box flexGrow={1} minWidth={0} />
42
- <box paddingX={1} flexShrink={1} minWidth={0} overflow="hidden">
43
- <text fg={theme.borderSubtle}>
44
- {`${keys.print("tab.prev")}/${keys.print("tab.next")} or ${keys.print("leader")} N`}
45
- </text>
46
- </box>
47
- </box>
48
- </box>
49
- )
50
- })
@@ -1,52 +0,0 @@
1
- /**
2
- * FileLink — Generic clickable file reference.
3
- *
4
- * Wraps in a box for mouse hit-testing. Opens the source file
5
- * in the OS default handler when clicked. Underlines on hover.
6
- */
7
-
8
- import { useState, memo } from "react";
9
- import { TextAttributes } from "@opentui/core";
10
- import type { Source } from "../../utils/hermes-home";
11
- import { openFile } from "../../utils/open-file";
12
- import { useTheme } from "../../theme";
13
-
14
- interface FileLinkProps {
15
- source: Source;
16
- children?: string;
17
- }
18
-
19
- export const FileLink = memo(({ source, children }: FileLinkProps) => {
20
- const theme = useTheme().theme;
21
- const [hovered, setHovered] = useState(false);
22
-
23
- return (
24
- <box
25
- height={1}
26
- onMouseDown={() => openFile(source.file)}
27
- onMouseOver={() => setHovered(true)}
28
- onMouseOut={() => setHovered(false)}
29
- >
30
- <text
31
- fg={theme.info}
32
- attributes={hovered ? TextAttributes.UNDERLINE : TextAttributes.NONE}
33
- >
34
- {children ?? source.label}
35
- </text>
36
- </box>
37
- );
38
- });
39
-
40
- // KV row whose value is a clickable FileLink. Lives beside FileLink
41
- // rather than in ui/kv so that module stays free of data-layer deps.
42
- export const KVLink = (props: { label: string; source: Source; text?: string }) => {
43
- const theme = useTheme().theme;
44
- return (
45
- <box height={1} flexDirection="row">
46
- <box width={13} flexShrink={0}><text fg={theme.textMuted}>{props.label}</text></box>
47
- <box flexGrow={1} minWidth={0} height={1} overflow="hidden">
48
- <FileLink source={props.source}>{props.text ?? props.source.label}</FileLink>
49
- </box>
50
- </box>
51
- );
52
- };
@@ -1,156 +0,0 @@
1
- import { SCHEMA, SCHEMA_KEYS, type ConfigEffect } from "./schema"
2
- import { route } from "./lane"
3
-
4
- export type FieldType = "boolean" | "select" | "number" | "string" | "readonly"
5
-
6
- export type Field = {
7
- key: string
8
- label: string
9
- type: FieldType
10
- value: unknown
11
- /** True when the user's config.yaml has this key; false when
12
- * falling through to the schema default. */
13
- set: boolean
14
- doc: string
15
- effect: ConfigEffect
16
- options?: string[]
17
- }
18
-
19
- // Enum-valued string fields the schema doesn't carry options for.
20
- // Kept minimal — most enums are validated by rules.ts on commit; these
21
- // are the ones worth cycling with [h/l] instead of free-typing.
22
- const SELECTS: Record<string, string[]> = {
23
- "terminal.backend": ["local", "docker", "ssh", "modal", "daytona", "singularity", "vercel_sandbox"],
24
- "tts.provider": ["edge", "elevenlabs", "openai", "neutts", "xai", "mistral"],
25
- "display.skin": ["default", "ares", "mono", "slate"],
26
- "logging.level": ["DEBUG", "INFO", "WARNING", "ERROR"],
27
- "agent.reasoning_effort": ["", "none", "minimal", "low", "medium", "high", "xhigh"],
28
- "display.busy_input_mode": ["queue", "steer", "interrupt"],
29
- "display.details_mode": ["hidden", "collapsed", "expanded"],
30
- "display.thinking_mode": ["collapsed", "truncated", "full"],
31
- "display.tool_progress": ["off", "new", "all", "verbose"],
32
- "approvals.mode": ["manual", "ask", "yolo", "deny"],
33
- }
34
-
35
- const get = (obj: Record<string, unknown>, path: string): unknown => {
36
- let cur: unknown = obj
37
- for (const p of path.split(".")) {
38
- if (cur && typeof cur === "object" && !Array.isArray(cur)) cur = (cur as Record<string, unknown>)[p]
39
- else return undefined
40
- }
41
- return cur
42
- }
43
-
44
- const classify = (key: string, t: string): FieldType => {
45
- if (route(key).via === "readonly") return "readonly"
46
- if (SELECTS[key]) return "select"
47
- if (t === "bool") return "boolean"
48
- if (t === "int" || t === "float") return "number"
49
- return "string"
50
- }
51
-
52
- const labelOf = (key: string): string => {
53
- const raw = SCHEMA[key]?.group ?? key.split(".")[0]
54
- return key.startsWith(`${raw}.`) ? key.slice(raw.length + 1) : key
55
- }
56
-
57
- /** Build the full field model: every schema key, value = user-set
58
- * else default, plus any user keys the schema doesn't know about
59
- * (so surprises in config.yaml still surface). */
60
- export const buildFields = (user: Record<string, unknown>): Field[] => {
61
- const seen = new Set<string>()
62
- const out: Field[] = []
63
-
64
- for (const key of SCHEMA_KEYS) {
65
- const s = SCHEMA[key]
66
- const uv = get(user, key)
67
- const set = uv !== undefined
68
- out.push({
69
- key,
70
- label: labelOf(key),
71
- type: classify(key, s.type),
72
- value: set ? uv : s.default,
73
- set,
74
- doc: s.doc,
75
- effect: s.effect,
76
- options: SELECTS[key],
77
- })
78
- seen.add(key)
79
- }
80
-
81
- // Unknown user keys (future agent version, hand-edits, plugins).
82
- const walk = (obj: Record<string, unknown>, prefix = "") => {
83
- for (const [k, v] of Object.entries(obj)) {
84
- const key = prefix ? `${prefix}.${k}` : k
85
- if (v && typeof v === "object" && !Array.isArray(v)) {
86
- // Don't recurse into a dict that's itself a known readonly leaf.
87
- if (SCHEMA[key]?.type === "dict") { seen.add(key); continue }
88
- walk(v as Record<string, unknown>, key)
89
- continue
90
- }
91
- if (seen.has(key)) continue
92
- out.push({
93
- key,
94
- label: labelOf(key),
95
- type: Array.isArray(v) ? "readonly"
96
- : typeof v === "boolean" ? "boolean"
97
- : typeof v === "number" ? "number"
98
- : "string",
99
- value: v, set: true, doc: "", effect: "live",
100
- })
101
- }
102
- }
103
- walk(user)
104
-
105
- return out
106
- }
107
-
108
- // Small/satellite groups fold into a parent. This is a UX decision,
109
- // not derivable from source — keeps the sidebar to ~18 entries instead
110
- // of 34 with a dozen 1-field groups.
111
- const MERGE: Record<string, string> = {
112
- approvals: "security", privacy: "security",
113
- checkpoints: "agent", context: "agent", cron: "agent", network: "agent",
114
- model_catalog: "general", onboarding: "general",
115
- human_delay: "display", dashboard: "display",
116
- tool_output: "agent", prompt_caching: "compression", code_execution: "terminal",
117
- slack: "platforms", telegram: "platforms", mattermost: "platforms",
118
- discord: "platforms", whatsapp: "platforms",
119
- }
120
-
121
- export const rawGroupOf = (key: string): string =>
122
- SCHEMA[key]?.group ?? (key.includes(".") ? key.split(".")[0] : "general")
123
-
124
- export const groupOf = (key: string): string => {
125
- const raw = rawGroupOf(key)
126
- return MERGE[raw] ?? raw
127
- }
128
-
129
- export type Section = { head: string | null; items: Field[] }
130
-
131
- /** Chunk a merged-group field list by its raw (pre-merge) groups so the
132
- * UI can render sub-headers. Single-chunk → head=null. Multi-chunk →
133
- * the self-named chunk (raw === merged name) floats to the front. */
134
- export const sections = (group: string, fields: Field[]): Section[] => {
135
- const by = new Map<string, Field[]>()
136
- for (const f of fields) {
137
- const r = rawGroupOf(f.key)
138
- if (!by.has(r)) by.set(r, [])
139
- by.get(r)!.push(f)
140
- }
141
- if (by.size <= 1) return [{ head: null, items: fields }]
142
- const order = [...by.keys()].sort((a, b) =>
143
- a === group ? -1 : b === group ? 1 : a.localeCompare(b))
144
- return order.map(r => ({ head: r, items: by.get(r)! }))
145
- }
146
-
147
- /** Distinct groups in schema after merging, 'general' pinned first. */
148
- export const GROUPS: string[] = (() => {
149
- const g = new Set<string>(["general"])
150
- for (const k of SCHEMA_KEYS) g.add(groupOf(k))
151
- return [...g]
152
- })()
153
-
154
- export const EFFECT_GLYPH: Record<ConfigEffect, string> = {
155
- live: "", session: "↻", restart: "⟳",
156
- }
@@ -1,161 +0,0 @@
1
- import { SCHEMA, type ConfigSchemaEntry, type ConfigEffect } from "./schema"
2
-
3
- // ─── RPC alias map ───────────────────────────────────────────────────
4
- //
5
- // `config.set` on the gateway accepts a short whitelist of ALIAS keys,
6
- // not dotted paths (anything else → 4002). Several of these mutate the
7
- // live agent in place (reasoning effort, model, tool verbosity, …), so
8
- // routing those through the RPC lane is what makes Config-tab edits
9
- // apply to the running conversation without a new session.
10
-
11
- type RpcAlias = {
12
- alias: string
13
- /** Map the schema-typed value to the wire value the alias expects. */
14
- toWire?: (v: unknown) => string
15
- }
16
-
17
- const onOff = (v: unknown) => (v ? "on" : "off")
18
-
19
- export const RPC_ALIAS: Record<string, RpcAlias> = {
20
- model: { alias: "model" },
21
- provider: { alias: "model" },
22
- "agent.service_tier": { alias: "fast" },
23
- "agent.reasoning_effort": { alias: "reasoning" },
24
- "display.show_reasoning": { alias: "reasoning", toWire: v => (v ? "show" : "hide") },
25
- "display.tool_progress": { alias: "verbose" },
26
- "display.busy_input_mode": { alias: "busy" },
27
- "display.details_mode": { alias: "details_mode" },
28
- "display.thinking_mode": { alias: "thinking_mode" },
29
- "display.tui_compact": { alias: "compact", toWire: onOff },
30
- "display.tui_statusbar": { alias: "statusbar" },
31
- "display.tui_mouse": { alias: "mouse", toWire: onOff },
32
- "display.skin": { alias: "skin" },
33
- "display.personality": { alias: "personality" },
34
- custom_prompt: { alias: "prompt" },
35
- }
36
-
37
- // ─── lane routing ────────────────────────────────────────────────────
38
-
39
- export type Lane =
40
- | { via: "rpc"; alias: string; toWire?: (v: unknown) => string }
41
- | { via: "cli" }
42
- | { via: "readonly" }
43
-
44
- export const route = (key: string): Lane => {
45
- const a = RPC_ALIAS[key]
46
- if (a) return { via: "rpc", alias: a.alias, toWire: a.toWire }
47
- if (key.startsWith("display.sections."))
48
- return { via: "rpc", alias: `details_mode.${key.slice("display.sections.".length)}` }
49
- const s = SCHEMA[key]
50
- if (s && (s.type === "list" || s.type === "dict")) return { via: "readonly" }
51
- return { via: "cli" }
52
- }
53
-
54
- // ─── value coercion for cli.exec ─────────────────────────────────────
55
- //
56
- // `hermes config set` parses the string argv[2] with heuristics
57
- // (true/false/on/off/yes/no → bool, all-digits → int, digits.digits →
58
- // float, else raw string). We pre-format so the heuristic lands on the
59
- // schema's declared type — in particular, a str-typed field whose
60
- // value *looks* numeric stays a string by going through the cli raw.
61
-
62
- export const toCliString = (key: string, v: unknown): string => {
63
- const t: ConfigSchemaEntry["type"] = SCHEMA[key]?.type ?? "str"
64
- if (t === "bool") return v ? "true" : "false"
65
- if (t === "int") return String(Math.trunc(Number(v)))
66
- if (t === "float") return String(Number(v))
67
- return String(v ?? "")
68
- }
69
-
70
- // ─── write engine ────────────────────────────────────────────────────
71
-
72
- export type Diff = { key: string; to: unknown }
73
- export type WriteResult = {
74
- ok: string[]
75
- failed: { key: string; err: string }[]
76
- warnings: { key: string; msg: string }[]
77
- }
78
-
79
- type Gw = {
80
- request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>
81
- }
82
-
83
- /** Apply a batch of config edits, routing each through its lane. RPC
84
- * calls run first (they may refuse with a structured error and carry
85
- * optional `warning`), then cli calls run serially — each one rewrites
86
- * the whole config file, so Promise.all would last-write-wins. */
87
- export const writeConfig = async (gw: Gw, diffs: Diff[]): Promise<WriteResult> => {
88
- const ok: string[] = []
89
- const failed: WriteResult["failed"] = []
90
- const warnings: WriteResult["warnings"] = []
91
-
92
- const rpc = diffs.filter(d => route(d.key).via === "rpc")
93
- const cli = diffs.filter(d => route(d.key).via === "cli")
94
- const ro = diffs.filter(d => route(d.key).via === "readonly")
95
- for (const d of ro) failed.push({ key: d.key, err: "structured value — edit in YAML mode" })
96
-
97
- for (const d of rpc) {
98
- const lane = route(d.key) as Extract<Lane, { via: "rpc" }>
99
- const value = lane.toWire ? lane.toWire(d.to) : String(d.to ?? "")
100
- try {
101
- const res = await gw.request<{ warning?: string }>("config.set", { key: lane.alias, value })
102
- ok.push(d.key)
103
- if (res?.warning) warnings.push({ key: d.key, msg: res.warning })
104
- } catch (e) {
105
- failed.push({ key: d.key, err: e instanceof Error ? e.message : String(e) })
106
- }
107
- }
108
-
109
- for (const d of cli) {
110
- try {
111
- const res = await gw.request<{ code: number; output: string; blocked?: boolean; hint?: string }>(
112
- "cli.exec", { argv: ["config", "set", d.key, toCliString(d.key, d.to)], timeout: 30 },
113
- )
114
- if (res.blocked) failed.push({ key: d.key, err: res.hint ?? "blocked" })
115
- else if (res.code !== 0) failed.push({ key: d.key, err: res.output.split("\n")[0] || `exit ${res.code}` })
116
- else ok.push(d.key)
117
- } catch (e) {
118
- failed.push({ key: d.key, err: e instanceof Error ? e.message : String(e) })
119
- }
120
- }
121
-
122
- return { ok, failed, warnings }
123
- }
124
-
125
- // ─── effect aggregation ──────────────────────────────────────────────
126
-
127
- const EFFECT_RANK: Record<ConfigEffect, number> = { live: 0, session: 1, restart: 2 }
128
-
129
- export const maxEffect = (keys: string[]): ConfigEffect =>
130
- keys.reduce<ConfigEffect>((acc, k) => {
131
- const e = SCHEMA[k]?.effect ?? "live"
132
- return EFFECT_RANK[e] > EFFECT_RANK[acc] ? e : acc
133
- }, "live")
134
-
135
- // ─── verification ────────────────────────────────────────────────────
136
-
137
- const get = (obj: Record<string, unknown>, path: string): unknown => {
138
- let cur: unknown = obj
139
- for (const p of path.split(".")) {
140
- if (cur && typeof cur === "object" && !Array.isArray(cur)) cur = (cur as Record<string, unknown>)[p]
141
- else return undefined
142
- }
143
- return cur
144
- }
145
-
146
- const eq = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
147
-
148
- /** After a write, compare intended values against a fresh config.get.
149
- * RPC-aliased keys are skipped — several aliases write to a different
150
- * dotted path than the one edited (e.g. reasoning:show →
151
- * display.show_reasoning), so a literal readback would false-positive. */
152
- export const verifyWrite = async (gw: Gw, applied: Diff[]): Promise<string[]> => {
153
- const res = await gw.request<{ config?: Record<string, unknown> }>("config.get", { key: "full" })
154
- const cfg = res.config ?? {}
155
- const miss: string[] = []
156
- for (const d of applied) {
157
- if (route(d.key).via !== "cli") continue
158
- if (!eq(get(cfg, d.key), d.to)) miss.push(d.key)
159
- }
160
- return miss
161
- }
@@ -1,95 +0,0 @@
1
- // Model-slot view over config.yaml — the "Models" category in Config.
2
- //
3
- // Reads are pure projections over the `config.get {key:"full"}` object
4
- // Config.tsx already holds, so there's no second RPC. Writes route
5
- // through the existing lanes: main → `config.set key=model` (rpc lane,
6
- // hot-swaps the live agent and persists with --global); aux →
7
- // `writeConfig()` (cli lane, `hermes config set auxiliary.<t>.…`).
8
- //
9
- // Intentionally NOT a gateway client of /api/model/auxiliary or
10
- // /api/model/set — those are web_server-only endpoints. Everything
11
- // here is derivable from config + the stock tui_gateway surface.
12
-
13
- import { writeConfig, type WriteResult } from "./lane"
14
- import type { ConfigSetResponse } from "../utils/gateway-types"
15
-
16
- type Gw = {
17
- request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>
18
- }
19
-
20
- // Mirrors _AUX_TASK_SLOTS in hermes_cli/web_server.py — ordering kept
21
- // so herm and the webui read the same top-to-bottom.
22
- export const AUX_TASKS = [
23
- { key: "vision", label: "Vision", hint: "Image analysis" },
24
- { key: "web_extract", label: "Web Extract", hint: "Page summarization" },
25
- { key: "compression", label: "Compression", hint: "Context compaction" },
26
- { key: "session_search", label: "Session Search", hint: "Recall queries" },
27
- { key: "skills_hub", label: "Skills Hub", hint: "Skill search" },
28
- { key: "approval", label: "Approval", hint: "Smart auto-approve" },
29
- { key: "mcp", label: "MCP", hint: "MCP tool routing" },
30
- { key: "title_generation", label: "Title Gen", hint: "Session titles" },
31
- { key: "curator", label: "Curator", hint: "Skill-usage review" },
32
- ] as const
33
-
34
- export type AuxKey = typeof AUX_TASKS[number]["key"]
35
-
36
- export type Slot =
37
- | { kind: "main"; key: "main"; label: string; hint: string
38
- provider: string; model: string; auto: false }
39
- | { kind: "aux"; key: AuxKey; label: string; hint: string
40
- provider: string; model: string; auto: boolean }
41
-
42
- const dig = (o: unknown, ...path: string[]): unknown =>
43
- path.reduce<unknown>((c, p) =>
44
- c && typeof c === "object" ? (c as Record<string, unknown>)[p] : undefined, o)
45
-
46
- const str = (v: unknown) => typeof v === "string" ? v : ""
47
-
48
- /** Project config.yaml → 1 main + 9 aux slots. */
49
- export const readSlots = (raw: Record<string, unknown>): Slot[] => {
50
- const main: Slot = {
51
- kind: "main", key: "main", label: "Main model", hint: "Primary agent model",
52
- provider: str(dig(raw, "model", "provider")),
53
- model: str(dig(raw, "model", "default")) || str(dig(raw, "model", "name")),
54
- auto: false,
55
- }
56
- const aux = AUX_TASKS.map<Slot>(t => {
57
- const p = str(dig(raw, "auxiliary", t.key, "provider"))
58
- return {
59
- kind: "aux", key: t.key, label: t.label, hint: t.hint,
60
- provider: p, model: str(dig(raw, "auxiliary", t.key, "model")),
61
- auto: p === "" || p === "auto",
62
- }
63
- })
64
- return [main, ...aux]
65
- }
66
-
67
- export type AssignResult = WriteResult & { warning?: string }
68
-
69
- /** Write a slot. Main goes via the rpc `config.set key=model` alias
70
- * (same path as /model --global — live-applies and clears stale
71
- * base_url/context_length upstream). Aux writes two cli-lane keys. */
72
- export const assign = async (
73
- gw: Gw, slot: Slot["key"], provider: string, model: string,
74
- ): Promise<AssignResult> => {
75
- if (slot === "main") {
76
- const r = await gw.request<ConfigSetResponse>("config.set", {
77
- key: "model", value: `${model} --provider ${provider} --global`,
78
- session_id: undefined,
79
- })
80
- return { ok: ["model.default", "model.provider"], failed: [], warnings: [], warning: r.warning }
81
- }
82
- return writeConfig(gw, [
83
- { key: `auxiliary.${slot}.provider`, to: provider },
84
- { key: `auxiliary.${slot}.model`, to: model },
85
- ])
86
- }
87
-
88
- /** Reset one aux slot (or all) to provider="auto", model="". */
89
- export const resetAux = (gw: Gw, slot: AuxKey | "all"): Promise<WriteResult> => {
90
- const keys = slot === "all" ? AUX_TASKS.map(t => t.key) : [slot]
91
- return writeConfig(gw, keys.flatMap(k => [
92
- { key: `auxiliary.${k}.provider`, to: "auto" },
93
- { key: `auxiliary.${k}.model`, to: "" },
94
- ]))
95
- }