@phren/agent 0.1.8 → 0.1.10

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 (58) hide show
  1. package/dist/commands/info.js +1 -0
  2. package/dist/commands/model.js +5 -4
  3. package/dist/commands/session.js +24 -2
  4. package/dist/commands.js +36 -1
  5. package/dist/config.js +27 -11
  6. package/dist/cost.js +11 -74
  7. package/dist/index.js +92 -35
  8. package/dist/mcp-client.js +4 -2
  9. package/dist/memory/context.js +56 -24
  10. package/dist/memory/session.js +21 -88
  11. package/dist/models.js +390 -0
  12. package/dist/multi/agent-types.js +170 -0
  13. package/dist/multi/child-entry.js +248 -78
  14. package/dist/multi/coordinator.js +69 -1
  15. package/dist/multi/diff-renderer.js +193 -17
  16. package/dist/multi/markdown.js +49 -23
  17. package/dist/multi/model-picker.js +12 -21
  18. package/dist/multi/multi-events.js +17 -0
  19. package/dist/multi/multi-render.js +1 -0
  20. package/dist/multi/provider-manager.js +23 -13
  21. package/dist/multi/spawner.js +84 -7
  22. package/dist/multi/syntax-highlight.js +64 -48
  23. package/dist/multi/worktree.js +43 -0
  24. package/dist/package-metadata.js +11 -0
  25. package/dist/permissions/checker.js +21 -1
  26. package/dist/providers/codex-auth.js +48 -34
  27. package/dist/providers/codex.js +110 -40
  28. package/dist/providers/ollama.js +5 -4
  29. package/dist/providers/openrouter.js +12 -5
  30. package/dist/providers/resolve.js +50 -32
  31. package/dist/providers/types.js +0 -1
  32. package/dist/repl.js +19 -34
  33. package/dist/tools/grep.js +111 -23
  34. package/dist/tools/mcp-resources.js +32 -0
  35. package/dist/tools/registry.js +13 -2
  36. package/dist/tools/shell.js +101 -3
  37. package/dist/tools/skill.js +44 -0
  38. package/dist/tools/spawn-agent.js +158 -0
  39. package/dist/tui/ansi.js +15 -11
  40. package/dist/tui/components/App.js +180 -20
  41. package/dist/tui/components/Banner.js +7 -4
  42. package/dist/tui/components/InputArea.js +54 -12
  43. package/dist/tui/components/PhrenInput.js +329 -0
  44. package/dist/tui/components/StatusBar.js +3 -1
  45. package/dist/tui/components/SteerQueue.js +4 -2
  46. package/dist/tui/components/ThinkingIndicator.js +12 -11
  47. package/dist/tui/components/ToolCall.js +17 -11
  48. package/dist/tui/components/ToolSpinner.js +13 -0
  49. package/dist/tui/hooks/useKeyboardShortcuts.js +65 -24
  50. package/dist/tui/hooks/useSearch.js +47 -0
  51. package/dist/tui/hooks/useSlashCommands.js +16 -19
  52. package/dist/tui/ink-entry.js +317 -18
  53. package/dist/tui/mouse.js +71 -0
  54. package/dist/tui/terminal-control.js +62 -0
  55. package/dist/tui/themes.js +398 -0
  56. package/dist/tui/tool-render.js +12 -1
  57. package/dist/tui.js +2 -1
  58. package/package.json +1 -3
@@ -1,18 +1,131 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState, useCallback } from "react";
3
- import { Static, Box, Text, useApp } from "ink";
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState, useCallback, useEffect } from "react";
3
+ import { Static, Box, Text, useApp, useInput } from "ink";
4
4
  import { Banner } from "./Banner.js";
5
5
  import { ToolCall } from "./ToolCall.js";
6
+ import { ToolSpinner } from "./ToolSpinner.js";
6
7
  import { ThinkingIndicator } from "./ThinkingIndicator.js";
7
8
  import { SteerQueue } from "./SteerQueue.js";
8
9
  import { InputArea, PermissionsLine } from "./InputArea.js";
9
10
  import { useKeyboardShortcuts } from "../hooks/useKeyboardShortcuts.js";
10
- export function App({ state, completedMessages, streamingText, completedToolCalls, thinking, thinkStartTime, thinkElapsed, steerQueue, running, showBanner, inputHistory, verbose, onSubmit, onPermissionCycle, onCancelTurn, onExit, }) {
11
+ import { renderMarkdown } from "../../multi/markdown.js";
12
+ import { useSearch, highlightMatches } from "../hooks/useSearch.js";
13
+ export function App({ state, completedMessages, streamingText, completedToolCalls, activeTool, thinking, thinkStartTime, thinkElapsed, steerQueue, running, showBanner, inputHistory, verbose, theme, onSubmit, onPermissionCycle, onCancelTurn, onExit, agents, selectedAgentId, onSelectAgent, onCancelAgent, }) {
11
14
  const { exit } = useApp();
12
15
  const [inputValue, setInputValue] = useState("");
13
16
  const [bashMode, setBashMode] = useState(false);
14
17
  const [historyIndex, setHistoryIndex] = useState(-1);
15
18
  const [ctrlCCount, setCtrlCCount] = useState(0);
19
+ const [tabFocused, setTabFocused] = useState(false);
20
+ const [highlightedTabIndex, setHighlightedTabIndex] = useState(0);
21
+ const [stashedInput, setStashedInput] = useState("");
22
+ const [historySearchMode, setHistorySearchMode] = useState(false);
23
+ const [historySearchQuery, setHistorySearchQuery] = useState("");
24
+ const [historySearchIndex, setHistorySearchIndex] = useState(0);
25
+ // ── Ctrl+F content search ────────────────────────────────────────────────
26
+ const search = useSearch();
27
+ // When the query changes, recompute total match count across all completed messages
28
+ useEffect(() => {
29
+ if (!search.state.active || !search.state.query) {
30
+ search.setMatchInfo(0, 0);
31
+ return;
32
+ }
33
+ let total = 0;
34
+ for (const msg of completedMessages) {
35
+ if (msg.kind === "user" || msg.kind === "status") {
36
+ const { count } = highlightMatches(msg.text, search.state.query);
37
+ total += count;
38
+ }
39
+ else if (msg.kind === "assistant") {
40
+ const { count } = highlightMatches(msg.text, search.state.query);
41
+ total += count;
42
+ }
43
+ }
44
+ search.setMatchInfo(total, 0);
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
46
+ }, [search.state.query, search.state.active, completedMessages]);
47
+ // Handle keypresses while search mode is active
48
+ useInput((input, key) => {
49
+ if (!search.state.active)
50
+ return;
51
+ // Escape: deactivate search
52
+ if (key.escape) {
53
+ search.deactivate();
54
+ return;
55
+ }
56
+ // Enter or n: next match
57
+ if (key.return || input === "n") {
58
+ search.nextMatch();
59
+ return;
60
+ }
61
+ // N (shift+n): previous match
62
+ if (input === "N") {
63
+ search.prevMatch();
64
+ return;
65
+ }
66
+ // Backspace: remove last char from query
67
+ if (key.backspace || key.delete) {
68
+ search.setQuery(search.state.query.slice(0, -1));
69
+ return;
70
+ }
71
+ // Skip ctrl/meta combinations
72
+ if (key.ctrl || key.meta)
73
+ return;
74
+ // Regular character: append to query
75
+ if (input.length > 0 && !key.upArrow && !key.downArrow && !key.leftArrow && !key.rightArrow && !key.tab) {
76
+ search.setQuery(search.state.query + input);
77
+ }
78
+ }, { isActive: search.state.active });
79
+ // History search: compute matches from current query
80
+ const historyMatches = historySearchMode
81
+ ? inputHistory.filter((h) => h.toLowerCase().includes(historySearchQuery.toLowerCase()))
82
+ : [];
83
+ const currentMatch = historyMatches.length > 0
84
+ ? historyMatches[historySearchIndex % historyMatches.length]
85
+ : null;
86
+ // Handle keypresses while in history search mode
87
+ useInput((input, key) => {
88
+ if (!historySearchMode)
89
+ return;
90
+ // Ctrl+R again: cycle to next match
91
+ if (key.ctrl && input === "r") {
92
+ if (historyMatches.length > 0) {
93
+ setHistorySearchIndex((i) => (i + 1) % historyMatches.length);
94
+ }
95
+ return;
96
+ }
97
+ // Enter: accept match
98
+ if (key.return) {
99
+ if (currentMatch) {
100
+ setInputValue(currentMatch);
101
+ }
102
+ setHistorySearchMode(false);
103
+ setHistorySearchQuery("");
104
+ setHistorySearchIndex(0);
105
+ return;
106
+ }
107
+ // Escape: cancel search
108
+ if (key.escape) {
109
+ setHistorySearchMode(false);
110
+ setHistorySearchQuery("");
111
+ setHistorySearchIndex(0);
112
+ return;
113
+ }
114
+ // Backspace: remove last char from query
115
+ if (key.backspace || key.delete) {
116
+ setHistorySearchQuery((q) => q.slice(0, -1));
117
+ setHistorySearchIndex(0);
118
+ return;
119
+ }
120
+ // Skip ctrl/meta combinations (except already handled)
121
+ if (key.ctrl || key.meta)
122
+ return;
123
+ // Regular character: append to query
124
+ if (input.length > 0 && !key.upArrow && !key.downArrow && !key.leftArrow && !key.rightArrow && !key.tab) {
125
+ setHistorySearchQuery((q) => q + input);
126
+ setHistorySearchIndex(0);
127
+ }
128
+ }, { isActive: historySearchMode });
16
129
  const handleSubmit = useCallback((value) => {
17
130
  setInputValue("");
18
131
  setHistoryIndex(-1);
@@ -26,6 +139,7 @@ export function App({ state, completedMessages, streamingText, completedToolCall
26
139
  onSubmit(bashMode ? `!${value}` : value);
27
140
  setBashMode(false);
28
141
  }, [bashMode, onSubmit]);
142
+ const isAnyModeActive = search.state.active || historySearchMode;
29
143
  useKeyboardShortcuts({
30
144
  isRunning: running,
31
145
  inputValue,
@@ -40,29 +154,75 @@ export function App({ state, completedMessages, streamingText, completedToolCall
40
154
  onExit: () => { onExit(); exit(); },
41
155
  onCyclePermissions: onPermissionCycle,
42
156
  onCancelTurn,
157
+ onEscCancelAgent: onCancelAgent,
158
+ onHistorySearch: () => {
159
+ setHistorySearchMode(true);
160
+ setHistorySearchQuery("");
161
+ setHistorySearchIndex(0);
162
+ },
163
+ onContentSearch: () => {
164
+ search.activate();
165
+ },
166
+ onOpenEditor: () => {
167
+ // Write input to temp file, open $EDITOR, read back
168
+ const tmpFile = `/tmp/phren-input-${Date.now()}.md`;
169
+ try {
170
+ const fs = require("fs");
171
+ const { execSync } = require("child_process");
172
+ fs.writeFileSync(tmpFile, inputValue);
173
+ const editor = process.env.VISUAL || process.env.EDITOR || "vi";
174
+ execSync(`${editor} ${tmpFile}`, { stdio: "inherit" });
175
+ const result = fs.readFileSync(tmpFile, "utf-8");
176
+ fs.unlinkSync(tmpFile);
177
+ setInputValue(result.replace(/\n$/, ""));
178
+ }
179
+ catch { /* editor cancelled or failed */ }
180
+ },
181
+ stashedInput,
182
+ onStash: (text) => { setStashedInput(text); },
183
+ onUnstash: () => { const s = stashedInput; setStashedInput(""); return s || null; },
184
+ tabFocused,
185
+ onEnterTabBar: agents && agents.length > 0 ? () => { setTabFocused(true); setHighlightedTabIndex(0); } : undefined,
186
+ onExitTabBar: () => { setTabFocused(false); },
187
+ onTabLeft: () => { setHighlightedTabIndex((p) => Math.max(0, p - 1)); },
188
+ onTabRight: () => { setHighlightedTabIndex((p) => Math.min((agents?.length ?? 1) - 1, p + 1)); },
189
+ onTabSelect: () => {
190
+ if (agents && agents[highlightedTabIndex]) {
191
+ const id = agents[highlightedTabIndex].id;
192
+ onSelectAgent?.(id === "__main__" ? null : id);
193
+ }
194
+ },
43
195
  });
44
- // Build Static items — banner first, then completed messages
45
- const staticItems = [];
46
- if (showBanner) {
47
- staticItems.push({ id: "banner", kind: "banner" });
48
- }
49
- for (const msg of completedMessages) {
50
- staticItems.push(msg);
51
- }
52
- return (_jsxs(_Fragment, { children: [_jsx(Static, { items: staticItems, children: (item) => {
53
- if (item.kind === "banner") {
54
- return (_jsx(Box, { flexDirection: "column", children: _jsx(Banner, { version: state.version }) }, "banner"));
55
- }
196
+ // Helper: apply search highlighting to a text string (ANSI only works in
197
+ // non-Ink raw text mode). Since Ink's <Text> will escape ANSI we pass raw
198
+ // strings to renderMarkdown which outputs ANSI directly.
199
+ const applySearch = useCallback((text) => {
200
+ if (!search.state.active || !search.state.query)
201
+ return text;
202
+ return highlightMatches(text, search.state.query).highlighted;
203
+ }, [search.state.active, search.state.query]);
204
+ return (_jsxs(_Fragment, { children: [_jsx(Static, { items: completedMessages, children: (item) => {
56
205
  if (item.kind === "user") {
57
- return (_jsx(Box, { flexDirection: "column", children: _jsxs(Text, { bold: true, children: ["\u276f", " ", item.text] }) }, item.id));
206
+ return (_jsx(Box, { flexDirection: "column", children: _jsxs(Text, { bold: theme.user.bold ?? true, color: theme.user.color, children: [theme.user.label, " ", applySearch(item.text)] }) }, item.id));
58
207
  }
59
208
  if (item.kind === "assistant") {
60
209
  const aMsg = item;
61
- return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [aMsg.text ? (_jsxs(Box, { children: [_jsxs(Text, { color: "magenta", children: ["\u25c6", " "] }), _jsx(Text, { children: aMsg.text })] })) : null, aMsg.toolCalls?.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose }, i)))] }, item.id));
210
+ const renderedText = aMsg.text
211
+ ? applySearch(renderMarkdown(aMsg.text, theme.markdown))
212
+ : "";
213
+ return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [aMsg.toolCalls?.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose, theme: theme }, i))), renderedText ? (_jsxs(Box, { children: [_jsxs(Text, { color: theme.agent.color, wrap: "truncate", children: [theme.agent.label, " "] }), _jsx(Text, { wrap: "wrap", children: renderedText })] })) : null] }, item.id));
62
214
  }
63
215
  if (item.kind === "status") {
64
- return _jsx(Text, { dimColor: true, children: item.text }, item.id);
216
+ return _jsx(Text, { color: theme.system.color, dimColor: true, children: applySearch(item.text) }, item.id);
65
217
  }
66
218
  return null;
67
- } }), _jsxs(Box, { flexDirection: "column", children: [completedToolCalls.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose }, `tc-${i}`))), streamingText !== "" && (_jsxs(Box, { children: [_jsxs(Text, { color: "magenta", children: ["\u25c6", " "] }), _jsx(Text, { children: streamingText })] })), thinking && _jsx(ThinkingIndicator, { startTime: thinkStartTime }), thinkElapsed !== null && (_jsxs(Text, { dimColor: true, children: [" ", "\u25c6", " thought for ", thinkElapsed, "s"] })), ctrlCCount > 0 && !running && (_jsxs(Text, { dimColor: true, children: [" ", "Press Ctrl+C again to exit."] })), _jsx(SteerQueue, { items: steerQueue }), _jsx(InputArea, { value: inputValue, onChange: setInputValue, onSubmit: handleSubmit, bashMode: bashMode, focus: true }), _jsx(PermissionsLine, { mode: state.permMode })] })] }));
219
+ } }), _jsxs(Box, { flexDirection: "column", children: [showBanner && completedMessages.length === 0 && _jsx(Banner, { version: state.version, theme: theme }), completedToolCalls.map((tc, i) => (_jsx(ToolCall, { ...tc, verbose: verbose, theme: theme }, `tc-${i}`))), activeTool && (_jsxs(Box, { paddingLeft: 2, children: [_jsx(ToolSpinner, { theme: theme }), _jsx(Text, { bold: true, color: theme.tool.name, children: activeTool.name }), activeTool.preview ? _jsxs(Text, { color: theme.tool.preview ?? theme.separator, children: [" ", activeTool.preview] }) : null] })), streamingText !== "" && (_jsxs(Box, { marginTop: 1, children: [_jsxs(Text, { color: theme.agent.color, wrap: "truncate", children: [theme.agent.label, " "] }), _jsx(Text, { wrap: "wrap", children: renderMarkdown(streamingText, theme.markdown) })] })), thinking && _jsx(Box, { marginTop: 1, children: _jsx(ThinkingIndicator, { startTime: thinkStartTime, theme: theme }) }), thinkElapsed !== null && (_jsxs(Text, { color: theme.dim, dimColor: true, children: [" ", "\u25c8", " ", thinkElapsed] })), ctrlCCount > 0 && !running && (_jsxs(Text, { dimColor: true, children: [" ", "Press Ctrl+C again to exit."] })), _jsx(SteerQueue, { items: steerQueue, theme: theme }), search.state.active && (_jsxs(Box, { children: [_jsxs(Text, { color: theme.search?.prompt ?? "cyan", children: [" ", "find: ", search.state.query, _jsx(Text, { inverse: true, children: " " })] }), search.state.matchCount > 0
220
+ ? _jsxs(Text, { dimColor: true, color: theme.search?.match ?? undefined, children: [" (", search.state.currentMatch + 1, " of ", search.state.matchCount, ")"] })
221
+ : search.state.query.length > 0
222
+ ? _jsx(Text, { dimColor: true, color: theme.search?.noMatch ?? "red", children: " (no matches)" })
223
+ : _jsx(Text, { dimColor: true, children: " (type to search)" })] })), historySearchMode && (_jsxs(Box, { children: [_jsxs(Text, { color: theme.search?.prompt ?? "cyan", children: [" ", "search: ", historySearchQuery, _jsx(Text, { inverse: true, children: " " })] }), historyMatches.length > 0
224
+ ? _jsxs(Text, { dimColor: true, color: theme.search?.match ?? undefined, children: [" (match ", (historySearchIndex % historyMatches.length) + 1, " of ", historyMatches.length, ")"] })
225
+ : historySearchQuery.length > 0
226
+ ? _jsx(Text, { dimColor: true, color: theme.search?.noMatch ?? "red", children: " (no matches)" })
227
+ : _jsx(Text, { dimColor: true, children: " (type to search history)" })] })), historySearchMode && currentMatch && (_jsx(Box, { children: _jsxs(Text, { dimColor: true, children: [" ", "\u25b8", " ", currentMatch] }) })), _jsx(InputArea, { value: inputValue, onChange: setInputValue, onSubmit: handleSubmit, bashMode: bashMode, focus: !isAnyModeActive, separatorColor: theme.separator, theme: theme }), _jsx(PermissionsLine, { mode: state.permMode, theme: theme, agents: agents, selectedAgentId: selectedAgentId, highlightedTabId: agents?.[highlightedTabIndex]?.id ?? null, tabFocused: tabFocused })] })] }));
68
228
  }
@@ -21,14 +21,17 @@ function getArtLines() {
21
21
  function stripAnsi(t) {
22
22
  return t.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "");
23
23
  }
24
- export function Banner({ version }) {
24
+ export function Banner({ version, theme }) {
25
25
  const cwd = process.cwd().replace(os.homedir(), "~");
26
26
  const artLines = getArtLines();
27
27
  const maxArtWidth = 26;
28
+ const logoColor = theme?.banner.logo ?? "magenta";
29
+ const versionColor = theme?.banner.version ?? "gray";
30
+ const cwdColor = theme?.banner.cwd ?? "cyan";
28
31
  const infoLines = [
29
- { key: "title", node: _jsx(Text, { bold: true, color: "magenta", children: "◆ phren" }) },
30
- { key: "version", node: _jsx(Text, { dimColor: true, children: " v" + version }) },
31
- { key: "cwd", node: _jsx(Text, { dimColor: true, children: cwd }) },
32
+ { key: "title", node: _jsx(Text, { bold: true, color: logoColor, children: "◆ phren" }) },
33
+ { key: "version", node: _jsx(Text, { color: versionColor, dimColor: true, children: " v" + version }) },
34
+ { key: "cwd", node: _jsx(Text, { color: cwdColor, dimColor: true, children: cwd }) },
32
35
  ];
33
36
  if (artLines.length > 0) {
34
37
  const rowCount = Math.max(artLines.length, infoLines.length);
@@ -1,23 +1,65 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text, useStdout } from "ink";
3
- import TextInput from "ink-text-input";
3
+ import { PhrenInput } from "./PhrenInput.js";
4
4
  import { PERMISSION_LABELS, PERMISSION_ICONS } from "../ansi.js";
5
- export function InputArea({ value, onChange, onSubmit, bashMode, focus }) {
5
+ export function InputArea({ value, onChange, onSubmit, bashMode, focus, separatorColor, theme }) {
6
6
  const { stdout } = useStdout();
7
7
  const columns = stdout?.columns || 80;
8
8
  const sep = "\u2500".repeat(columns);
9
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: sep }), _jsxs(Box, { children: [bashMode
10
- ? _jsx(Text, { color: "yellow", children: "! " })
11
- : _jsxs(Text, { dimColor: true, children: ["\u25b8", " "] }), _jsx(TextInput, { value: value, onChange: onChange, onSubmit: onSubmit, focus: focus, showCursor: true })] }), _jsx(Text, { dimColor: true, children: sep })] }));
9
+ const sepColor = theme?.input.separator ?? separatorColor ?? "gray";
10
+ const promptColor = theme?.input.prompt ?? undefined;
11
+ const bashPromptColor = theme?.input.bashPrompt ?? "yellow";
12
+ return (_jsx(Box, { flexDirection: "column", marginTop: 1, children: _jsxs(Box, { children: [bashMode
13
+ ? _jsx(Text, { color: bashPromptColor, children: "! " })
14
+ : _jsxs(Text, { color: promptColor, dimColor: true, children: ["\u276f", " "] }), _jsx(PhrenInput, { value: value, onChange: onChange, onSubmit: onSubmit, focus: focus })] }) }));
12
15
  }
13
- const PERM_COLOR_MAP = {
14
- "suggest": "cyan",
15
- "auto-confirm": "green",
16
- "full-auto": "yellow",
16
+ const STATUS_ICON = {
17
+ running: "\u25cf", // ●
18
+ idle: "\u25cb", // ○
19
+ done: "\u2713", // ✓
20
+ error: "\u2717", // ✗
21
+ starting: "\u25cc", // ◌
22
+ cancelled: "\u2500", // ─
17
23
  };
18
- export function PermissionsLine({ mode }) {
24
+ export function PermissionsLine({ mode, theme, agents, selectedAgentId, highlightedTabId, tabFocused }) {
19
25
  const icon = PERMISSION_ICONS[mode];
20
26
  const label = PERMISSION_LABELS[mode];
21
- const color = PERM_COLOR_MAP[mode];
22
- return (_jsxs(Text, { children: [" ", _jsxs(Text, { color: color, children: [icon, " ", label, " permissions"] }), " ", _jsxs(Text, { dimColor: true, children: ["(shift+tab toggle ", "\u00b7", " esc to interrupt)"] })] }));
27
+ const permColors = theme?.permission;
28
+ const color = mode === "suggest"
29
+ ? (permColors?.suggest ?? "")
30
+ : mode === "auto-confirm"
31
+ ? (permColors?.auto ?? "yellow")
32
+ : mode === "plan"
33
+ ? (permColors?.plan ?? "magenta")
34
+ : (permColors?.fullAuto ?? "green");
35
+ const showPerm = mode !== "suggest";
36
+ const hasAgents = agents && agents.length > 0;
37
+ // Agent tab status → theme color
38
+ const tabColors = theme?.agentTab;
39
+ function agentTabColor(agent) {
40
+ if (tabColors) {
41
+ if (agent.status === "running")
42
+ return tabColors.running;
43
+ if (agent.status === "idle")
44
+ return tabColors.idle;
45
+ if (agent.status === "done")
46
+ return tabColors.done;
47
+ if (agent.status === "error")
48
+ return tabColors.error;
49
+ }
50
+ return agent.color;
51
+ }
52
+ return (_jsxs(Box, { children: [showPerm ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: color, children: [icon, " ", label] }), _jsx(Text, { dimColor: true, children: " (shift+tab to cycle)" })] })) : (_jsx(Text, { children: " " })), hasAgents ? (_jsxs(Text, { children: [" ", agents.map((agent, i) => {
53
+ const isActive = agent.id === selectedAgentId;
54
+ const isHighlighted = tabFocused && agent.id === highlightedTabId;
55
+ const statusIcon = STATUS_ICON[agent.status];
56
+ const resolvedColor = agentTabColor(agent);
57
+ return (_jsxs(Text, { children: [i > 0 ? " " : "", isHighlighted
58
+ ? _jsx(Text, { bold: true, inverse: true, color: resolvedColor, children: ` ${statusIcon} ${agent.name} ` })
59
+ : isActive
60
+ ? _jsxs(Text, { bold: true, underline: true, color: resolvedColor, children: [statusIcon, " ", agent.name] })
61
+ : _jsxs(Text, { color: resolvedColor, dimColor: agent.status === "idle" || agent.status === "done", children: [statusIcon, " ", agent.name] })] }, agent.id));
62
+ }), tabFocused
63
+ ? _jsx(Text, { dimColor: true, children: " \u2190\u2192 enter \u2191 back" })
64
+ : _jsx(Text, { dimColor: true, children: " \u2193" })] })) : null] }));
23
65
  }