@denizokcu/haze 0.5.0 → 0.7.0
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.
- package/CHANGELOG.md +36 -1
- package/README.md +101 -24
- package/dist/cli/chat/TaskBar.d.ts +9 -0
- package/dist/cli/chat/TaskBar.js +40 -0
- package/dist/cli/chat/chatMetrics.d.ts +11 -0
- package/dist/cli/chat/chatMetrics.js +50 -0
- package/dist/cli/chat/inputSuggestions.d.ts +16 -0
- package/dist/cli/chat/inputSuggestions.js +55 -0
- package/dist/cli/chat/messages.d.ts +9 -0
- package/dist/cli/chat/messages.js +76 -0
- package/dist/cli/chat/sessionRecorder.d.ts +12 -0
- package/dist/cli/chat/sessionRecorder.js +21 -0
- package/dist/cli/chat/startupInfo.d.ts +4 -0
- package/dist/cli/chat/startupInfo.js +53 -0
- package/dist/cli/chat/turnState.d.ts +5 -0
- package/dist/cli/chat/turnState.js +20 -0
- package/dist/cli/commands/chat.d.ts +0 -1
- package/dist/cli/commands/chat.js +519 -495
- package/dist/cli/commands/chatModes.d.ts +8 -0
- package/dist/cli/commands/chatModes.js +44 -0
- package/dist/cli/commands/commandHelp.d.ts +6 -0
- package/dist/cli/commands/commandHelp.js +25 -0
- package/dist/cli/commands/commands.d.ts +3 -2
- package/dist/cli/commands/commands.js +55 -320
- package/dist/cli/commands/formatters.d.ts +27 -0
- package/dist/cli/commands/formatters.js +149 -4
- package/dist/cli/commands/initCommand.d.ts +2 -0
- package/dist/cli/commands/initCommand.js +19 -0
- package/dist/cli/commands/logsCommand.d.ts +2 -0
- package/dist/cli/commands/logsCommand.js +63 -0
- package/dist/cli/commands/lspWizard.d.ts +14 -0
- package/dist/cli/commands/lspWizard.js +44 -0
- package/dist/cli/commands/mcpWizard.d.ts +15 -0
- package/dist/cli/commands/mcpWizard.js +69 -0
- package/dist/cli/commands/modelCommand.d.ts +2 -0
- package/dist/cli/commands/modelCommand.js +36 -0
- package/dist/cli/commands/providerWizard.d.ts +30 -0
- package/dist/cli/commands/providerWizard.js +114 -0
- package/dist/cli/commands/runCommand.d.ts +16 -0
- package/dist/cli/commands/runCommand.js +170 -0
- package/dist/cli/commands/settingsSummary.d.ts +3 -0
- package/dist/cli/commands/settingsSummary.js +40 -0
- package/dist/cli/commands/skillConfirmRemove.d.ts +11 -0
- package/dist/cli/commands/skillConfirmRemove.js +19 -0
- package/dist/cli/commands/skillCreation.d.ts +12 -0
- package/dist/cli/commands/skillCreation.js +14 -0
- package/dist/cli/commands/skillWizard.d.ts +15 -0
- package/dist/cli/commands/skillWizard.js +38 -0
- package/dist/cli/commands/streaming/assistantText.d.ts +17 -0
- package/dist/cli/commands/streaming/assistantText.js +115 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +55 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +102 -0
- package/dist/cli/commands/streaming/toolResultState.d.ts +13 -0
- package/dist/cli/commands/streaming/toolResultState.js +25 -0
- package/dist/cli/commands/streaming/turnRuntime.d.ts +78 -0
- package/dist/cli/commands/streaming/turnRuntime.js +86 -0
- package/dist/cli/commands/streaming.d.ts +10 -29
- package/dist/cli/commands/streaming.js +249 -911
- package/dist/cli/commands/wizardActions.d.ts +40 -0
- package/dist/cli/commands/wizardActions.js +40 -0
- package/dist/cli/commands/wizardInput.d.ts +4 -0
- package/dist/cli/commands/wizardInput.js +19 -0
- package/dist/cli/commands/wizardPrompts.d.ts +22 -0
- package/dist/cli/commands/wizardPrompts.js +52 -0
- package/dist/cli/commands/wizardSuggestions.d.ts +23 -0
- package/dist/cli/commands/wizardSuggestions.js +139 -0
- package/dist/cli/index.js +62 -4
- package/dist/config/contextFiles.d.ts +8 -1
- package/dist/config/contextFiles.js +25 -12
- package/dist/config/lspSettings.d.ts +16 -0
- package/dist/config/lspSettings.js +95 -0
- package/dist/config/mcpSettings.d.ts +24 -0
- package/dist/config/mcpSettings.js +100 -0
- package/dist/config/providers.js +4 -4
- package/dist/config/settings.d.ts +34 -0
- package/dist/config/skillSettings.d.ts +15 -0
- package/dist/config/skillSettings.js +32 -0
- package/dist/config/updateCheck.d.ts +44 -0
- package/dist/config/updateCheck.js +83 -0
- package/dist/core/agent/budgets.d.ts +6 -0
- package/dist/core/agent/budgets.js +6 -0
- package/dist/core/agent/compaction.js +1 -1
- package/dist/core/agent/requestAssembly.d.ts +0 -7
- package/dist/core/agent/requestAssembly.js +27 -5
- package/dist/core/agent/toolOutputStore.js +5 -4
- package/dist/core/agent/toolResults.d.ts +31 -0
- package/dist/core/agent/toolResults.js +42 -0
- package/dist/core/agent/turnPolicy.d.ts +8 -0
- package/dist/core/agent/turnPolicy.js +23 -0
- package/dist/core/agent/workState.d.ts +18 -5
- package/dist/core/agent/workState.js +39 -20
- package/dist/core/bashOutput/reducers/content.d.ts +1 -0
- package/dist/core/bashOutput/reducers/content.js +1 -1
- package/dist/core/bashOutput/reducers/gh.d.ts +1 -0
- package/dist/core/bashOutput/reducers/gh.js +77 -0
- package/dist/core/bashOutput/registry.js +8 -0
- package/dist/core/goal/sessionGoal.d.ts +6 -30
- package/dist/core/goal/sessionGoal.js +3 -68
- package/dist/core/safety/bashClassifier.js +30 -0
- package/dist/core/safety/urlGuard.d.ts +1 -0
- package/dist/core/safety/urlGuard.js +6 -1
- package/dist/core/session/sessionSlimming.d.ts +5 -0
- package/dist/core/session/sessionSlimming.js +78 -0
- package/dist/core/session/sessionStore.d.ts +23 -3
- package/dist/core/session/sessionStore.js +30 -10
- package/dist/core/subagent/subagentRunner.d.ts +11 -1
- package/dist/core/subagent/subagentRunner.js +1 -0
- package/dist/llm/capabilities.d.ts +12 -0
- package/dist/llm/capabilities.js +10 -0
- package/dist/llm/client.d.ts +1 -0
- package/dist/llm/client.js +11 -2
- package/dist/llm/hazeTools.d.ts +31 -32
- package/dist/llm/hazeTools.js +40 -567
- package/dist/llm/lsp.d.ts +109 -0
- package/dist/llm/lsp.js +241 -0
- package/dist/llm/lspTools.d.ts +104 -0
- package/dist/llm/lspTools.js +115 -0
- package/dist/llm/mcp.d.ts +19 -0
- package/dist/llm/mcp.js +73 -0
- package/dist/llm/requestContext.d.ts +28 -0
- package/dist/llm/requestContext.js +41 -0
- package/dist/llm/systemPrompt.d.ts +5 -1
- package/dist/llm/systemPrompt.js +9 -3
- package/dist/llm/tools/bashTool.d.ts +5 -0
- package/dist/llm/tools/bashTool.js +81 -0
- package/dist/llm/tools/editMatch.d.ts +55 -0
- package/dist/llm/tools/editMatch.js +99 -0
- package/dist/llm/tools/failures.d.ts +36 -0
- package/dist/llm/tools/failures.js +38 -0
- package/dist/llm/tools/fetchTool.d.ts +65 -0
- package/dist/llm/tools/fetchTool.js +45 -0
- package/dist/llm/tools/fileToolShared.d.ts +10 -0
- package/dist/llm/tools/fileToolShared.js +43 -0
- package/dist/llm/tools/grepParse.d.ts +13 -0
- package/dist/llm/tools/grepParse.js +67 -0
- package/dist/llm/tools/outputCap.d.ts +53 -0
- package/dist/llm/tools/outputCap.js +67 -0
- package/dist/llm/tools/storedOutputTool.d.ts +10 -0
- package/dist/llm/tools/storedOutputTool.js +17 -0
- package/dist/llm/tools/taskTool.d.ts +28 -0
- package/dist/llm/tools/taskTool.js +41 -0
- package/dist/llm/tools/toolContext.d.ts +69 -0
- package/dist/llm/tools/toolContext.js +187 -0
- package/dist/llm/tools/workspaceFile.d.ts +33 -0
- package/dist/llm/tools/workspaceFile.js +27 -0
- package/dist/llm/webFetch.d.ts +13 -1
- package/dist/llm/webFetch.js +91 -7
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +24 -45
- package/dist/ui/components/TextInput.d.ts +1 -1
- package/dist/ui/components/TextInput.js +1 -99
- package/dist/ui/inputBuffer.d.ts +28 -0
- package/dist/ui/inputBuffer.js +99 -0
- package/dist/utils/collections.d.ts +6 -0
- package/dist/utils/collections.js +9 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +40 -0
- package/dist/utils/version.d.ts +20 -0
- package/dist/utils/version.js +72 -0
- package/package.json +2 -2
- package/dist/cli/commands/skills.d.ts +0 -4
- package/dist/cli/commands/skills.js +0 -38
|
@@ -1,31 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { execFile as execFileCallback } from 'node:child_process';
|
|
4
|
-
import os from 'node:os';
|
|
5
4
|
import { promisify } from 'node:util';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
6
|
import { Box, render, Static, Text, useApp, useStdout } from 'ink';
|
|
7
7
|
import Spinner from 'ink-spinner';
|
|
8
8
|
import { readContextFiles } from '../../config/contextFiles.js';
|
|
9
|
+
import { checkForUpdate } from '../../config/updateCheck.js';
|
|
9
10
|
import { addInputHistoryItem, readInputHistory } from '../../config/inputHistory.js';
|
|
10
11
|
import { loadTasks as loadTasksFromStore, clearTasks as clearTasksFromStore } from '../../core/tasks/taskStorage.js';
|
|
11
12
|
import { readSettings, updateSettings } from '../../config/settings.js';
|
|
12
|
-
import { activeModel,
|
|
13
|
+
import { activeModel, findProvider, modelSelector, resolveModelSelector } from '../../config/providers.js';
|
|
14
|
+
import { removeLspServer } from '../../config/lspSettings.js';
|
|
15
|
+
import { removeMcpServer } from '../../config/mcpSettings.js';
|
|
16
|
+
import { isSkillEnabled } from '../../config/skillSettings.js';
|
|
13
17
|
import { Header } from '../../ui/components/Header.js';
|
|
14
18
|
import { TextInput } from '../../ui/components/TextInput.js';
|
|
15
|
-
import { MarkdownText } from '../../ui/components/MarkdownText.js';
|
|
16
19
|
import { theme } from '../../ui/theme.js';
|
|
17
20
|
import { handleSlashCommand } from './commands.js';
|
|
18
21
|
import { runAgentTurn } from './streaming.js';
|
|
22
|
+
import { formatContextReport } from './formatters.js';
|
|
19
23
|
import { createLog as createLlmLog, endLog as endLlmLog } from '../../core/log/llmLog.js';
|
|
20
|
-
import { formatElapsedTime, formatElapsedTimeWhole } from './formatters.js';
|
|
21
24
|
import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
|
|
22
25
|
import { createSkill, toSkillDirName } from '../../skills/builder/SkillBuilder.js';
|
|
23
|
-
import {
|
|
26
|
+
import { findPreset } from '../../config/providerPresets.js';
|
|
24
27
|
import { appendSessionEntry, createSession, formatSession, latestSession, restoreConversation, restoreWorkState } from '../../core/session/sessionStore.js';
|
|
25
|
-
import { compactModelMessages
|
|
28
|
+
import { compactModelMessages } from '../../core/agent/compaction.js';
|
|
29
|
+
import { contextBreakdown } from '../../core/agent/contextBudget.js';
|
|
30
|
+
import { stripSyntheticControls } from '../../core/agent/requestAssembly.js';
|
|
31
|
+
import { modelWithConfig } from '../../llm/client.js';
|
|
32
|
+
import { assembleRequestContext } from '../../llm/requestContext.js';
|
|
33
|
+
import { closeMcpClients } from '../../llm/mcp.js';
|
|
34
|
+
import { MAX_VISIBLE_TASKS, TaskBar } from '../chat/TaskBar.js';
|
|
26
35
|
import { clearToolOutputs } from '../../core/agent/toolOutputStore.js';
|
|
36
|
+
import { MessageView, messageKey, orderedDisplayMessages } from '../chat/messages.js';
|
|
37
|
+
import { createSessionRecorder } from '../chat/sessionRecorder.js';
|
|
38
|
+
import { startupContextInfo, startupProviderInfo } from '../chat/startupInfo.js';
|
|
39
|
+
import { compactHomePath, displayMessagesFromConversation, estimateConversationTokens, formatTokenCount, toolCallCount } from '../chat/chatMetrics.js';
|
|
40
|
+
import { accumulateTokenUsage, EMPTY_TOKEN_USAGE, shouldClearCompletedTasks } from '../chat/turnState.js';
|
|
41
|
+
import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES, placeholderForMode } from './chatModes.js';
|
|
42
|
+
import { inputSuggestionsForState } from '../chat/inputSuggestions.js';
|
|
43
|
+
import { PROVIDER_ACTIONS, PROVIDER_CHOICES, SERVER_CHOICES } from './wizardActions.js';
|
|
44
|
+
import { captureLspName, captureMcpCommand, captureMcpName, captureMcpTransport, captureMcpUrl, captureProviderName, captureProviderUrl } from './wizardPrompts.js';
|
|
45
|
+
import { finishLspCustomResult, selectLspActionResult, selectLspPresetResult, selectLspServerResult } from './lspWizard.js';
|
|
46
|
+
import { finishMcpCustomResult, selectMcpActionResult, selectMcpPresetResult, selectMcpServerResult, setMcpServerKeyResult } from './mcpWizard.js';
|
|
47
|
+
import { providerActionResult, providerAppendModels, providerFinishAdd, providerRemove, providerRemoveModels, providerSetKey } from './providerWizard.js';
|
|
48
|
+
import { selectSkillActionResult, selectSkillResult } from './skillWizard.js';
|
|
49
|
+
import { captureSkillDescription as captureSkillDescriptionResult, skillCreationFailure, skillCreationMessage } from './skillCreation.js';
|
|
50
|
+
import { skillConfirmRemoveResult as skillConfirmRemove } from './skillConfirmRemove.js';
|
|
51
|
+
import { commandParts, isYesConfirmation } from './wizardInput.js';
|
|
27
52
|
const execFile = promisify(execFileCallback);
|
|
28
|
-
const EMPTY_TOKEN_USAGE = { inputTokens: undefined, outputTokens: undefined, systemPrompt: 0, messages: 0, toolSchemas: 0, outputEstimate: 0, cacheReadTokens: 0, cacheWriteTokens: 0, noCacheTokens: 0, reasoningTokens: 0, logicalInputEstimate: 0, effectiveNonCachedInput: undefined };
|
|
29
53
|
async function currentBranchName() {
|
|
30
54
|
try {
|
|
31
55
|
const { stdout } = await execFile('git', ['branch', '--show-current'], { cwd: process.cwd() });
|
|
@@ -35,191 +59,6 @@ async function currentBranchName() {
|
|
|
35
59
|
return undefined;
|
|
36
60
|
}
|
|
37
61
|
}
|
|
38
|
-
function toolCallCount(messages) {
|
|
39
|
-
return messages.reduce((total, message) => {
|
|
40
|
-
if (message.role !== 'tool')
|
|
41
|
-
return total;
|
|
42
|
-
const headerCount = /Tools: (\d+) calls?/.exec(message.text)?.[1];
|
|
43
|
-
if (headerCount)
|
|
44
|
-
return total + Number(headerCount);
|
|
45
|
-
const rows = message.text.split('\n').filter(line => /^\s+[✓✗…]\s/.test(line));
|
|
46
|
-
return total + rows.reduce((rowTotal, row) => rowTotal + Number(/×(\d+)/.exec(row)?.[1] ?? 1), 0);
|
|
47
|
-
}, 0);
|
|
48
|
-
}
|
|
49
|
-
function estimateTokens(text) {
|
|
50
|
-
return Math.ceil(text.length / 4);
|
|
51
|
-
}
|
|
52
|
-
function compactHomePath(filePath) {
|
|
53
|
-
const home = os.homedir();
|
|
54
|
-
if (filePath === home)
|
|
55
|
-
return '~';
|
|
56
|
-
return filePath.startsWith(`${home}/`) ? `~/${filePath.slice(home.length + 1)}` : filePath;
|
|
57
|
-
}
|
|
58
|
-
function formatTokenCount(tokens) {
|
|
59
|
-
if (tokens >= 1_000_000)
|
|
60
|
-
return `${(tokens / 1_000_000).toFixed(tokens >= 10_000_000 ? 0 : 1).replace(/\.0$/, '')}m`;
|
|
61
|
-
if (tokens >= 1_000)
|
|
62
|
-
return `${(tokens / 1_000).toFixed(tokens >= 10_000 ? 0 : 1).replace(/\.0$/, '')}k`;
|
|
63
|
-
return String(tokens);
|
|
64
|
-
}
|
|
65
|
-
function displayMessagesFromConversation(conversation) {
|
|
66
|
-
return conversation.flatMap(message => {
|
|
67
|
-
if (message.role !== 'user' && message.role !== 'assistant')
|
|
68
|
-
return [];
|
|
69
|
-
const text = modelMessageText(message).trim();
|
|
70
|
-
return text ? [{ role: message.role, text }] : [];
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
function estimateConversationTokens(messages) {
|
|
74
|
-
const inputText = messages
|
|
75
|
-
.filter(message => message.role === 'user' || message.role === 'tool')
|
|
76
|
-
.map(message => message.text)
|
|
77
|
-
.join('\n');
|
|
78
|
-
const outputText = messages
|
|
79
|
-
.filter(message => message.role === 'assistant')
|
|
80
|
-
.map(message => message.text)
|
|
81
|
-
.join('\n');
|
|
82
|
-
return {
|
|
83
|
-
input: estimateTokens(inputText),
|
|
84
|
-
output: estimateTokens(outputText),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function fullWidthLines(text, width, leftPadding = 0) {
|
|
88
|
-
const safeWidth = Math.max(1, width);
|
|
89
|
-
const prefix = ' '.repeat(leftPadding);
|
|
90
|
-
return text.replace(/\r\n|\r/g, '\n').split('\n').map(line => `${prefix}${line}`.padEnd(Math.max(safeWidth, line.length + leftPadding)));
|
|
91
|
-
}
|
|
92
|
-
function fullWidthBlankLine(width) {
|
|
93
|
-
return ''.padEnd(Math.max(1, width));
|
|
94
|
-
}
|
|
95
|
-
function ToolMessageText({ text, streaming }) {
|
|
96
|
-
const lines = text.split('\n');
|
|
97
|
-
return _jsx(Box, { flexDirection: "column", children: lines.map((line, index) => {
|
|
98
|
-
const diffRow = /^(\s*\d+\s+)([+-])(.*)$/.exec(line);
|
|
99
|
-
if (diffRow) {
|
|
100
|
-
const [, prefix, marker, rest] = diffRow;
|
|
101
|
-
const isAdd = marker === '+';
|
|
102
|
-
return _jsxs(Text, { color: "white", backgroundColor: isAdd ? theme.successBg : theme.dangerBg, children: [_jsxs(Text, { color: isAdd ? theme.success : theme.danger, backgroundColor: isAdd ? theme.successBg : theme.dangerBg, children: [prefix, marker] }), rest] }, `${index}-${line}`);
|
|
103
|
-
}
|
|
104
|
-
const contextRow = /^(\s*\d+\s+)\s(.*)$/.exec(line);
|
|
105
|
-
if (contextRow) {
|
|
106
|
-
const [, prefix, rest] = contextRow;
|
|
107
|
-
return _jsxs(Text, { color: "white", children: [_jsxs(Text, { color: theme.muted, children: [prefix, " "] }), rest] }, `${index}-${line}`);
|
|
108
|
-
}
|
|
109
|
-
const row = /^(\s*)([✓✗…])\s+(\S+)(.*)$/.exec(line);
|
|
110
|
-
if (!row) {
|
|
111
|
-
const timer = /(.*) (\([0-9]+(?:h [0-9]+m [0-9]+(?:\.[0-9])?s|m [0-9]+(?:\.[0-9])?s|(?:\.[0-9])?s)\))$/.exec(line);
|
|
112
|
-
return _jsxs(Text, { color: theme.muted, children: [index === 0 && streaming ? _jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), " "] }) : null, timer ? timer[1] : line, timer ? _jsxs(Text, { color: theme.muted, bold: false, children: [" ", timer[2]] }) : null] }, `${index}-${line}`);
|
|
113
|
-
}
|
|
114
|
-
const [, indent, icon, toolName, rest] = row;
|
|
115
|
-
const iconColor = icon === '✓' ? theme.success : icon === '✗' ? theme.danger : theme.muted;
|
|
116
|
-
const timer = /(.*) (\([0-9]+(?:h [0-9]+m [0-9]+(?:\.[0-9])?s|m [0-9]+(?:\.[0-9])?s|(?:\.[0-9])?s)\))$/.exec(rest);
|
|
117
|
-
return _jsxs(Text, { color: theme.muted, children: [indent, _jsx(Text, { color: iconColor, children: icon }), " ", _jsx(Text, { color: theme.purple, children: toolName }), timer ? timer[1] : rest, timer ? _jsxs(Text, { color: theme.muted, bold: false, children: [" ", timer[2]] }) : null] }, `${index}-${line}`);
|
|
118
|
-
}) });
|
|
119
|
-
}
|
|
120
|
-
function messageElapsedLabel(message) {
|
|
121
|
-
if (message.startedAt == null)
|
|
122
|
-
return '';
|
|
123
|
-
const end = message.finishedAt ?? (message.streaming ? Date.now() : message.startedAt);
|
|
124
|
-
const elapsed = end - message.startedAt;
|
|
125
|
-
if (message.role === 'assistant' && !message.streaming && message.tokensPerSecond != null) {
|
|
126
|
-
return `✓ Done in ${formatElapsedTime(elapsed)} · ${Math.round(message.tokensPerSecond)} tok/s`;
|
|
127
|
-
}
|
|
128
|
-
return message.streaming ? formatElapsedTimeWhole(elapsed) : formatElapsedTime(elapsed);
|
|
129
|
-
}
|
|
130
|
-
function MessageView({ message, width, suppressAssistantHeader = false }) {
|
|
131
|
-
if (message.role === 'user') {
|
|
132
|
-
return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { backgroundColor: theme.quoteBg, children: fullWidthBlankLine(width) }), _jsx(Text, { color: theme.success, bold: true, backgroundColor: theme.quoteBg, children: ' You asked'.padEnd(width) }), fullWidthLines(message.text, width, 2).map((line, lineIndex) => _jsx(Text, { color: "white", backgroundColor: theme.quoteBg, children: line }, lineIndex)), _jsx(Text, { backgroundColor: theme.quoteBg, children: fullWidthBlankLine(width) })] });
|
|
133
|
-
}
|
|
134
|
-
return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [!suppressAssistantHeader && _jsxs(Text, { children: [_jsx(Text, { color: message.role === 'assistant' ? theme.purple : message.role === 'tool' ? theme.blue : theme.muted, bold: true, children: message.role === 'assistant' ? 'haze' : message.role === 'tool' ? 'Tool' : 'Info' }), messageElapsedLabel(message) ? _jsxs(Text, { color: theme.muted, bold: false, children: [" \u00B7 ", messageElapsedLabel(message)] }) : null] }), message.role === 'tool'
|
|
135
|
-
? _jsx(ToolMessageText, { text: message.text, streaming: message.streaming })
|
|
136
|
-
: message.role === 'assistant' && !message.streaming
|
|
137
|
-
? _jsx(MarkdownText, { content: message.text })
|
|
138
|
-
: _jsx(Text, { children: message.text })] });
|
|
139
|
-
}
|
|
140
|
-
function messageKey(message, index) {
|
|
141
|
-
return message.id ?? `${index}-${message.role}-${message.text}`;
|
|
142
|
-
}
|
|
143
|
-
function orderedDisplayMessages(messages) {
|
|
144
|
-
return messages
|
|
145
|
-
.map((message, index) => ({ message, index }))
|
|
146
|
-
.sort((a, b) => {
|
|
147
|
-
if (a.message.displayOrder != null && b.message.displayOrder != null && a.message.displayOrder !== b.message.displayOrder) {
|
|
148
|
-
return a.message.displayOrder - b.message.displayOrder;
|
|
149
|
-
}
|
|
150
|
-
return a.index - b.index;
|
|
151
|
-
})
|
|
152
|
-
.map(item => item.message);
|
|
153
|
-
}
|
|
154
|
-
function annotateTurnHeaders(messages) {
|
|
155
|
-
return messages.map(message => ({ message, suppressAssistantHeader: false }));
|
|
156
|
-
}
|
|
157
|
-
function startupProviderInfo(settings) {
|
|
158
|
-
const selection = activeModel(settings);
|
|
159
|
-
const configuredCount = configuredProviders(settings).length;
|
|
160
|
-
if (!selection) {
|
|
161
|
-
return [
|
|
162
|
-
'Provider configuration',
|
|
163
|
-
'- Provider: not configured',
|
|
164
|
-
'- Model: not set',
|
|
165
|
-
'- Base URL: not configured',
|
|
166
|
-
'- API key: missing',
|
|
167
|
-
`- Configured providers: ${configuredCount}`,
|
|
168
|
-
'',
|
|
169
|
-
'Run /provider to choose or add a provider, then select a model.',
|
|
170
|
-
].join('\n');
|
|
171
|
-
}
|
|
172
|
-
const model = selection.model;
|
|
173
|
-
const modelSource = settings.model ? 'settings' : 'provider default';
|
|
174
|
-
const baseURL = selection.provider.url;
|
|
175
|
-
const apiKeySource = providerHasKey(settings, selection.provider) ? `provider ${selection.provider.name}` : 'missing';
|
|
176
|
-
const provider = selection.provider.name;
|
|
177
|
-
return [
|
|
178
|
-
'Provider configuration',
|
|
179
|
-
`- Provider: ${provider}`,
|
|
180
|
-
`- Model: ${model} (${modelSource})`,
|
|
181
|
-
`- Base URL: ${baseURL} (settings)`,
|
|
182
|
-
`- API key: ${apiKeySource === 'missing' ? 'not configured; local providers may not need one' : `configured via ${apiKeySource}`}`,
|
|
183
|
-
`- Configured providers: ${configuredCount}`,
|
|
184
|
-
].join('\n');
|
|
185
|
-
}
|
|
186
|
-
const TASK_STATUS_ICON = {
|
|
187
|
-
pending: '\u25CB',
|
|
188
|
-
in_progress: '\u25D0',
|
|
189
|
-
completed: '\u2713',
|
|
190
|
-
};
|
|
191
|
-
function taskStatusColor(status) {
|
|
192
|
-
switch (status) {
|
|
193
|
-
case 'completed': return theme.success;
|
|
194
|
-
case 'in_progress': return theme.warning;
|
|
195
|
-
default: return theme.muted;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const MAX_VISIBLE_TASKS = 5;
|
|
199
|
-
function TaskBarContent({ tasks, width, expanded, padding }) {
|
|
200
|
-
const maxTitleWidth = Math.max(10, width - 6);
|
|
201
|
-
const inProgress = tasks.filter(t => t.status === 'in_progress');
|
|
202
|
-
const pending = tasks.filter(t => t.status === 'pending');
|
|
203
|
-
const completed = tasks.filter(t => t.status === 'completed');
|
|
204
|
-
const limit = expanded ? tasks.length : MAX_VISIBLE_TASKS;
|
|
205
|
-
const ordered = [];
|
|
206
|
-
for (const t of inProgress) {
|
|
207
|
-
if (ordered.length < limit)
|
|
208
|
-
ordered.push(t);
|
|
209
|
-
}
|
|
210
|
-
for (const t of pending) {
|
|
211
|
-
if (ordered.length < limit)
|
|
212
|
-
ordered.push(t);
|
|
213
|
-
}
|
|
214
|
-
for (let i = completed.length - 1; i >= 0 && ordered.length < limit; i--) {
|
|
215
|
-
ordered.push(completed[i]);
|
|
216
|
-
}
|
|
217
|
-
const counts = `${inProgress.length > 0 ? `${inProgress.length} active` : ''}${pending.length > 0 ? `${inProgress.length > 0 ? ', ' : ''}${pending.length} pending` : ''}${completed.length > 0 ? `${inProgress.length + pending.length > 0 ? ', ' : ''}${completed.length} done` : ''}`;
|
|
218
|
-
return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [padding > 0 && Array.from({ length: padding }, (_, i) => _jsx(Text, { children: ' ' }, `pad-${i}`)), _jsxs(Text, { children: [_jsx(Text, { color: theme.purple, bold: true, children: "Tasks" }), counts ? _jsxs(Text, { color: theme.muted, children: [" (", counts, ")"] }) : null, tasks.length > MAX_VISIBLE_TASKS ? _jsxs(Text, { color: theme.muted, dimColor: true, children: [" \u00B7 ctrl+o ", expanded ? 'collapse' : 'expand'] }) : null] }), ordered.map(task => {
|
|
219
|
-
const title = task.title.length > maxTitleWidth ? task.title.slice(0, maxTitleWidth - 1) + '\u2026' : task.title;
|
|
220
|
-
return (_jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: taskStatusColor(task.status), children: [TASK_STATUS_ICON[task.status], " "] }), _jsx(Text, { color: task.status === 'completed' ? theme.muted : 'white', children: title })] }, task.id));
|
|
221
|
-
})] }));
|
|
222
|
-
}
|
|
223
62
|
function ChatScreen({ debug = false, version, continueSession = false, noSession = false }) {
|
|
224
63
|
const { exit } = useApp();
|
|
225
64
|
const { stdout } = useStdout();
|
|
@@ -254,6 +93,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
254
93
|
const sessionStartRef = useRef(new Date());
|
|
255
94
|
const workStateRef = useRef(undefined);
|
|
256
95
|
const llmLogRef = useRef(undefined);
|
|
96
|
+
const contextFileSignaturesRef = useRef(new Map());
|
|
257
97
|
const followUpQueueRef = useRef([]);
|
|
258
98
|
const [inputHistory, setInputHistory] = useState([]);
|
|
259
99
|
const [debugLogs, setDebugLogs] = useState([]);
|
|
@@ -261,7 +101,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
261
101
|
const [mode, setMode] = useState('chat');
|
|
262
102
|
const [busy, setBusy] = useState(false);
|
|
263
103
|
const [busyLabel, setBusyLabel] = useState('Haze is thinking');
|
|
264
|
-
const [
|
|
104
|
+
const [, setActiveGoalStatus] = useState();
|
|
265
105
|
const [visibleTasks, setVisibleTasks] = useState([]);
|
|
266
106
|
const [tasksExpanded, setTasksExpanded] = useState(false);
|
|
267
107
|
const [taskBarPadding, setTaskBarPadding] = useState(0);
|
|
@@ -273,28 +113,40 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
273
113
|
const [modelProviderFilter, setModelProviderFilter] = useState();
|
|
274
114
|
const [selectedProviderName, setSelectedProviderName] = useState();
|
|
275
115
|
const [providerDraft, setProviderDraft] = useState({});
|
|
276
|
-
const [
|
|
116
|
+
const [skillDraft, setSkillDraft] = useState({});
|
|
117
|
+
const [selectedSkillName, setSelectedSkillName] = useState();
|
|
118
|
+
const [selectedLspName, setSelectedLspName] = useState();
|
|
119
|
+
const [lspDraft, setLspDraft] = useState({});
|
|
120
|
+
const [selectedMcpName, setSelectedMcpName] = useState();
|
|
121
|
+
const [mcpDraft, setMcpDraft] = useState({});
|
|
277
122
|
useEffect(() => {
|
|
278
|
-
Promise.all([
|
|
123
|
+
Promise.all([
|
|
124
|
+
readSettings().catch(() => ({})),
|
|
125
|
+
currentBranchName().catch(() => undefined),
|
|
126
|
+
readContextFiles().catch(() => []),
|
|
127
|
+
]).then(([next, branch, files]) => {
|
|
279
128
|
setSettings(next);
|
|
280
129
|
setBranchName(branch);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
setMessages(m => [...m, { role: 'system', text: startupProviderInfo({}) }]);
|
|
286
|
-
}).catch(() => {
|
|
287
|
-
setMessages(m => [...m, { role: 'system', text: startupProviderInfo({}) }]);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
130
|
+
setContextFiles(files);
|
|
131
|
+
contextFileSignaturesRef.current = new Map(files.flatMap(file => file.signature ? [[file.path, file.signature]] : []));
|
|
132
|
+
setMessages(m => [...m, { role: 'system', text: `${startupProviderInfo(next)}\n\n${startupContextInfo(files)}` }]);
|
|
133
|
+
}).catch(() => undefined);
|
|
290
134
|
initializeSession().catch(error => {
|
|
291
135
|
const text = error instanceof Error ? error.message : String(error);
|
|
292
136
|
setMessages(m => [...m, { role: 'system', text: `Session disabled: ${text}` }]);
|
|
293
137
|
});
|
|
294
138
|
readInputHistory().then(setInputHistory).catch(() => undefined);
|
|
295
|
-
readContextFiles().then(setContextFiles).catch(() => undefined);
|
|
296
139
|
refreshSkills().catch(() => undefined);
|
|
297
140
|
loadTasksFromStore().then(setVisibleTasks).catch(() => undefined);
|
|
141
|
+
if (version) {
|
|
142
|
+
checkForUpdate({ currentVersion: version, packageName: '@denizokcu/haze' })
|
|
143
|
+
.then(result => {
|
|
144
|
+
if (result?.isOutdated) {
|
|
145
|
+
setMessages(m => [...m, { role: 'system', text: `A new version of Haze is available: ${result.latestVersion} (you have ${version}). Update with: npm i -g @denizokcu/haze` }]);
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
.catch(() => undefined);
|
|
149
|
+
}
|
|
298
150
|
const branchTimer = setInterval(() => {
|
|
299
151
|
currentBranchName().then(setBranchName).catch(() => setBranchName(undefined));
|
|
300
152
|
}, 3000);
|
|
@@ -312,11 +164,13 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
312
164
|
function skillInvocation(value) {
|
|
313
165
|
if (!value.startsWith('/'))
|
|
314
166
|
return undefined;
|
|
315
|
-
const [name, ...args] = value.slice(1)
|
|
167
|
+
const [name, ...args] = commandParts(value.slice(1));
|
|
316
168
|
if (!name)
|
|
317
169
|
return undefined;
|
|
318
170
|
const skill = skills.find(candidate => candidate.name === name);
|
|
319
|
-
|
|
171
|
+
// Disabled skills are not invocable: they are absent from the model catalog,
|
|
172
|
+
// mirroring how disabled LSP/MCP tools never load.
|
|
173
|
+
return skill && isSkillEnabled(settings, skill.name) ? { skill, args: args.join(' ') } : undefined;
|
|
320
174
|
}
|
|
321
175
|
function debugLog(line) {
|
|
322
176
|
if (!debug)
|
|
@@ -335,6 +189,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
335
189
|
}
|
|
336
190
|
async function startNewSession(message = 'Started a new session.') {
|
|
337
191
|
clearToolOutputs();
|
|
192
|
+
contextFileSignaturesRef.current = new Map(contextFiles.flatMap(file => file.signature ? [[file.path, file.signature]] : []));
|
|
338
193
|
workStateRef.current = undefined;
|
|
339
194
|
sessionStartRef.current = new Date();
|
|
340
195
|
if (noSession) {
|
|
@@ -357,7 +212,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
357
212
|
if (continueSession) {
|
|
358
213
|
const session = await latestSession();
|
|
359
214
|
if (session) {
|
|
360
|
-
const conversation = await restoreConversation(session);
|
|
215
|
+
const { messages: conversation, parseErrors: conversationErrors } = await restoreConversation(session);
|
|
361
216
|
sessionRef.current = session;
|
|
362
217
|
sessionStartRef.current = new Date();
|
|
363
218
|
conversationRef.current = conversation;
|
|
@@ -365,7 +220,11 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
365
220
|
setLiveMessagesState(() => []);
|
|
366
221
|
const restoredMessages = displayMessagesFromConversation(conversation);
|
|
367
222
|
setTokenUsage({ ...EMPTY_TOKEN_USAGE, messages: estimateConversationTokens(restoredMessages).input, outputEstimate: estimateConversationTokens(restoredMessages).output });
|
|
368
|
-
|
|
223
|
+
const { state: workState, parseErrors: workStateErrors } = await restoreWorkState(session);
|
|
224
|
+
workStateRef.current = workState;
|
|
225
|
+
for (const error of [...conversationErrors, ...workStateErrors]) {
|
|
226
|
+
debugLog(`Session parse error: ${error}`);
|
|
227
|
+
}
|
|
369
228
|
setMessages(m => [...m, { role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...restoredMessages]);
|
|
370
229
|
await startNewLog();
|
|
371
230
|
return;
|
|
@@ -407,16 +266,54 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
407
266
|
setMessages(m => [...m, { role: 'system', text: 'No previous session found for this workspace.' }]);
|
|
408
267
|
return;
|
|
409
268
|
}
|
|
410
|
-
const conversation = await restoreConversation(session);
|
|
269
|
+
const { messages: conversation, parseErrors: conversationErrors } = await restoreConversation(session);
|
|
270
|
+
const { state: workState, parseErrors: workStateErrors } = await restoreWorkState(session);
|
|
271
|
+
for (const error of [...conversationErrors, ...workStateErrors]) {
|
|
272
|
+
debugLog(`Session parse error: ${error}`);
|
|
273
|
+
}
|
|
411
274
|
clearToolOutputs();
|
|
412
275
|
sessionRef.current = session;
|
|
413
276
|
conversationRef.current = conversation;
|
|
414
|
-
workStateRef.current =
|
|
277
|
+
workStateRef.current = workState;
|
|
415
278
|
setSessionLabel(session.id);
|
|
416
279
|
setTokenUsage({ ...EMPTY_TOKEN_USAGE });
|
|
417
280
|
setLiveMessagesState(() => []);
|
|
418
281
|
setMessages([{ role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...displayMessagesFromConversation(conversation)]);
|
|
419
282
|
}
|
|
283
|
+
async function buildContextReport() {
|
|
284
|
+
const runtime = await modelWithConfig({ cwd: process.cwd() });
|
|
285
|
+
if (!runtime?.model) {
|
|
286
|
+
return 'No model provider configured. Run /provider to choose or add a provider before /context can estimate tokens.';
|
|
287
|
+
}
|
|
288
|
+
const session = { start: sessionStartRef.current, cwd: process.cwd() };
|
|
289
|
+
const assembled = await assembleRequestContext({ contextFiles, session, model: runtime.model });
|
|
290
|
+
try {
|
|
291
|
+
const messages = stripSyntheticControls(conversationRef.current);
|
|
292
|
+
const breakdown = contextBreakdown({ system: assembled.systemPrompt, contextFiles, messages, tools: assembled.availableTools });
|
|
293
|
+
const tools = breakdown.toolSchemas.map(tool => ({
|
|
294
|
+
name: tool.name,
|
|
295
|
+
tokens: tool.tokens,
|
|
296
|
+
category: assembled.toolCategories.get(tool.name) ?? 'builtin',
|
|
297
|
+
}));
|
|
298
|
+
return formatContextReport({
|
|
299
|
+
modelLabel: `${runtime.config.providerName}:${runtime.config.modelName}`,
|
|
300
|
+
systemTokens: breakdown.system,
|
|
301
|
+
projectContext: breakdown.projectContext,
|
|
302
|
+
tools,
|
|
303
|
+
messagesByRole: breakdown.messagesByRole,
|
|
304
|
+
toolResults: breakdown.toolResults,
|
|
305
|
+
toolInputs: breakdown.toolInputs,
|
|
306
|
+
syntheticControl: breakdown.syntheticControl,
|
|
307
|
+
logicalInputEstimate: breakdown.logicalInputEstimate,
|
|
308
|
+
messageCount: messages.length,
|
|
309
|
+
mcpErrors: assembled.loadedMcp?.errors ?? [],
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
if (assembled.loadedMcp?.clients.length)
|
|
314
|
+
await closeMcpClients(assembled.loadedMcp.clients);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
420
317
|
function cancelThinking() {
|
|
421
318
|
if (!busy)
|
|
422
319
|
return;
|
|
@@ -442,56 +339,16 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
442
339
|
setModelProviderFilter(undefined);
|
|
443
340
|
setSelectedProviderName(undefined);
|
|
444
341
|
setProviderDraft({});
|
|
445
|
-
|
|
342
|
+
setSkillDraft({});
|
|
343
|
+
setSelectedSkillName(undefined);
|
|
344
|
+
setSelectedLspName(undefined);
|
|
345
|
+
setLspDraft({});
|
|
346
|
+
setSelectedMcpName(undefined);
|
|
347
|
+
setMcpDraft({});
|
|
446
348
|
}
|
|
447
349
|
}
|
|
448
|
-
function providerSuggestions() {
|
|
449
|
-
return [
|
|
450
|
-
...configuredProviders(settings).map(provider => ({
|
|
451
|
-
value: provider.name,
|
|
452
|
-
description: `${provider.url} · ${provider.models.length} model${provider.models.length === 1 ? '' : 's'}`,
|
|
453
|
-
kind: 'provider',
|
|
454
|
-
})),
|
|
455
|
-
{ value: 'add provider', description: 'Add a new provider (presets available)', kind: 'provider' },
|
|
456
|
-
];
|
|
457
|
-
}
|
|
458
|
-
function providerActionSuggestions() {
|
|
459
|
-
const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
|
|
460
|
-
return [
|
|
461
|
-
{ value: 'use provider', description: 'Set this provider and choose a model', kind: 'provider' },
|
|
462
|
-
{ value: 'add models', description: 'Append comma-separated model names', kind: 'provider' },
|
|
463
|
-
{ value: 'set API key', description: provider?.key ? 'Update the saved API key' : 'Add an API key', kind: 'provider' },
|
|
464
|
-
...(provider?.models?.length ? [{ value: 'remove models', description: 'Remove models from this provider', kind: 'provider' }] : []),
|
|
465
|
-
{ value: 'remove provider', description: 'Delete this provider from settings', kind: 'provider' },
|
|
466
|
-
];
|
|
467
|
-
}
|
|
468
|
-
function presetSuggestions() {
|
|
469
|
-
const cloudPresets = PROVIDER_PRESETS.filter(p => p.category === 'cloud');
|
|
470
|
-
const localPresets = PROVIDER_PRESETS.filter(p => p.category === 'local');
|
|
471
|
-
return [
|
|
472
|
-
...cloudPresets.map(preset => ({
|
|
473
|
-
value: preset.id,
|
|
474
|
-
description: `${preset.baseUrl}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
|
|
475
|
-
kind: 'provider',
|
|
476
|
-
})),
|
|
477
|
-
...localPresets.map(preset => ({
|
|
478
|
-
value: preset.id,
|
|
479
|
-
description: `${preset.baseUrl} · local, no API key needed`,
|
|
480
|
-
kind: 'provider',
|
|
481
|
-
})),
|
|
482
|
-
{ value: 'custom', description: 'Enter provider name, URL, and API key manually', kind: 'provider' },
|
|
483
|
-
];
|
|
484
|
-
}
|
|
485
|
-
function modelSuggestions() {
|
|
486
|
-
const providers = configuredProviders(settings).filter(provider => !modelProviderFilter || provider.name === modelProviderFilter);
|
|
487
|
-
return providers.flatMap(provider => provider.models.map(model => ({
|
|
488
|
-
value: modelProviderFilter ? model : modelSelector(provider, model),
|
|
489
|
-
description: provider.name,
|
|
490
|
-
kind: 'model',
|
|
491
|
-
})));
|
|
492
|
-
}
|
|
493
350
|
async function selectProvider(providerName) {
|
|
494
|
-
if (providerName ===
|
|
351
|
+
if (providerName === PROVIDER_CHOICES.addProvider) {
|
|
495
352
|
setProviderDraft({});
|
|
496
353
|
setMode('providerAddPreset');
|
|
497
354
|
setMessages(m => [...m, { role: 'system', text: 'Choose a provider preset, or select "custom" to enter details manually.' }]);
|
|
@@ -508,7 +365,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
508
365
|
setMessages(m => [...m, { role: 'system', text: `${provider.name}: choose an action.` }]);
|
|
509
366
|
}
|
|
510
367
|
async function selectPreset(presetId) {
|
|
511
|
-
if (presetId ===
|
|
368
|
+
if (presetId === PROVIDER_CHOICES.custom) {
|
|
512
369
|
setProviderDraft({});
|
|
513
370
|
setMode('providerAddName');
|
|
514
371
|
setMessages(m => [...m, { role: 'system', text: 'Provider name? Example: openrouter, local, lmstudio.' }]);
|
|
@@ -567,31 +424,16 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
567
424
|
setSelectedProviderName(undefined);
|
|
568
425
|
return;
|
|
569
426
|
}
|
|
570
|
-
if (action ===
|
|
427
|
+
if (action === PROVIDER_ACTIONS.useProvider) {
|
|
571
428
|
await useProvider(selectedProviderName);
|
|
572
429
|
return;
|
|
573
430
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
setMode('providerSetKey');
|
|
581
|
-
setMessages(m => [...m, { role: 'system', text: `New API key for ${selectedProviderName}? (current: ${provider.key ? 'saved' : 'not set'})` }]);
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
if (action === 'remove models') {
|
|
585
|
-
setMode('providerRemoveModels');
|
|
586
|
-
setMessages(m => [...m, { role: 'system', text: `Comma-separated model names to remove from ${selectedProviderName}?\nCurrent models: ${provider.models.join(', ')}` }]);
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
if (action === 'remove provider') {
|
|
590
|
-
setMode('providerConfirmRemove');
|
|
591
|
-
setMessages(m => [...m, { role: 'system', text: `Remove provider ${selectedProviderName}? Type "yes" to confirm. Esc to cancel.` }]);
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
setMessages(m => [...m, { role: 'system', text: `Unknown provider action: ${action}` }]);
|
|
431
|
+
const actionResult = providerActionResult(action, provider);
|
|
432
|
+
if (actionResult.selectedName === undefined)
|
|
433
|
+
setSelectedProviderName(undefined);
|
|
434
|
+
if (actionResult.mode)
|
|
435
|
+
setMode(actionResult.mode);
|
|
436
|
+
showWizardMessage(actionResult.message);
|
|
595
437
|
}
|
|
596
438
|
async function selectModel(selector) {
|
|
597
439
|
const scopedSelector = modelProviderFilter ? `${modelProviderFilter}:${selector}` : selector;
|
|
@@ -611,45 +453,170 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
611
453
|
setMessages(m => [...m, { role: 'system', text: `Model set to ${resolved.model} on ${resolved.provider.name}.\n\n${startupProviderInfo(next)}` }]);
|
|
612
454
|
}
|
|
613
455
|
async function appendModelsToProvider(modelsValue) {
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
setMessages(m => [...m, { role: 'system', text: 'No provider selected.' }]);
|
|
456
|
+
const result = providerAppendModels(settings, selectedProviderName, modelsValue);
|
|
457
|
+
if (!result.provider) {
|
|
458
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
618
459
|
setMode('chat');
|
|
619
460
|
return;
|
|
620
461
|
}
|
|
621
|
-
if (
|
|
622
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
462
|
+
if (!result.settingsPatch) {
|
|
463
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
623
464
|
return;
|
|
624
465
|
}
|
|
625
|
-
const
|
|
626
|
-
const next = await updateSettings({ providers: upsertProvider(settings, nextProvider), provider: provider.name });
|
|
466
|
+
const next = await updateSettings(result.settingsPatch);
|
|
627
467
|
setSettings(next);
|
|
628
468
|
setSelectedProviderName(undefined);
|
|
629
|
-
setModelProviderFilter(provider.name);
|
|
469
|
+
setModelProviderFilter(result.provider.name);
|
|
630
470
|
setMode('model');
|
|
631
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
471
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
632
472
|
}
|
|
633
473
|
async function finishProviderAdd(modelsValue) {
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
636
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
474
|
+
const result = providerFinishAdd(settings, providerDraft, modelsValue);
|
|
475
|
+
if (!result.provider || !result.settingsPatch) {
|
|
476
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
637
477
|
setMode('chat');
|
|
638
478
|
setProviderDraft({});
|
|
639
479
|
return;
|
|
640
480
|
}
|
|
641
|
-
const
|
|
642
|
-
name: providerDraft.name,
|
|
643
|
-
url: providerDraft.url,
|
|
644
|
-
...(providerDraft.key ? { key: providerDraft.key } : {}),
|
|
645
|
-
models: [...new Set(models)],
|
|
646
|
-
};
|
|
647
|
-
const next = await updateSettings({ providers: upsertProvider(settings, provider), provider: provider.name });
|
|
481
|
+
const next = await updateSettings(result.settingsPatch);
|
|
648
482
|
setSettings(next);
|
|
649
483
|
setProviderDraft({});
|
|
650
|
-
setModelProviderFilter(provider.name);
|
|
484
|
+
setModelProviderFilter(result.provider.name);
|
|
651
485
|
setMode('model');
|
|
652
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
486
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
487
|
+
}
|
|
488
|
+
// --- LSP wizard handlers (mirror the provider wizard) ---
|
|
489
|
+
function showWizardMessage(message) {
|
|
490
|
+
if (message)
|
|
491
|
+
setMessages(m => [...m, { role: 'system', text: message }]);
|
|
492
|
+
}
|
|
493
|
+
async function selectLspServer(serverName) {
|
|
494
|
+
const result = selectLspServerResult(settings, serverName);
|
|
495
|
+
if (result.clearDraft)
|
|
496
|
+
setLspDraft({});
|
|
497
|
+
if (serverName === SERVER_CHOICES.addServer)
|
|
498
|
+
setMode('lspAddPreset');
|
|
499
|
+
else if (result.mode)
|
|
500
|
+
setMode(result.mode);
|
|
501
|
+
if (result.selectedName !== undefined)
|
|
502
|
+
setSelectedLspName(result.selectedName);
|
|
503
|
+
showWizardMessage(result.message);
|
|
504
|
+
}
|
|
505
|
+
async function selectLspPreset(presetId) {
|
|
506
|
+
const result = selectLspPresetResult(settings, presetId);
|
|
507
|
+
if (result.clearDraft)
|
|
508
|
+
setLspDraft({});
|
|
509
|
+
if (result.settingsPatch)
|
|
510
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
511
|
+
if (result.mode)
|
|
512
|
+
setMode(result.mode);
|
|
513
|
+
showWizardMessage(result.message);
|
|
514
|
+
}
|
|
515
|
+
async function selectLspAction(action) {
|
|
516
|
+
const result = selectLspActionResult(settings, selectedLspName, action);
|
|
517
|
+
if (result.settingsPatch)
|
|
518
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
519
|
+
if ('selectedName' in result)
|
|
520
|
+
setSelectedLspName(result.selectedName);
|
|
521
|
+
if (result.mode)
|
|
522
|
+
setMode(result.mode);
|
|
523
|
+
showWizardMessage(result.message);
|
|
524
|
+
}
|
|
525
|
+
async function finishLspCustom(commandLine) {
|
|
526
|
+
const result = finishLspCustomResult(settings, lspDraft.name, commandLine);
|
|
527
|
+
if (result.settingsPatch)
|
|
528
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
529
|
+
if (result.clearDraft)
|
|
530
|
+
setLspDraft({});
|
|
531
|
+
if (result.mode)
|
|
532
|
+
setMode(result.mode);
|
|
533
|
+
showWizardMessage(result.message);
|
|
534
|
+
}
|
|
535
|
+
// --- MCP wizard handlers (mirror the provider wizard) ---
|
|
536
|
+
async function selectMcpServer(serverName) {
|
|
537
|
+
const result = selectMcpServerResult(settings, serverName);
|
|
538
|
+
if (result.clearDraft)
|
|
539
|
+
setMcpDraft({});
|
|
540
|
+
if (serverName === SERVER_CHOICES.addServer)
|
|
541
|
+
setMode('mcpAddPreset');
|
|
542
|
+
else if (result.mode)
|
|
543
|
+
setMode(result.mode);
|
|
544
|
+
if (result.selectedName !== undefined)
|
|
545
|
+
setSelectedMcpName(result.selectedName);
|
|
546
|
+
showWizardMessage(result.message);
|
|
547
|
+
}
|
|
548
|
+
async function selectMcpPreset(presetId) {
|
|
549
|
+
const result = selectMcpPresetResult(settings, presetId);
|
|
550
|
+
if (result.clearDraft)
|
|
551
|
+
setMcpDraft({});
|
|
552
|
+
if (result.draft)
|
|
553
|
+
setMcpDraft(result.draft);
|
|
554
|
+
if (result.mode)
|
|
555
|
+
setMode(result.mode);
|
|
556
|
+
showWizardMessage(result.message);
|
|
557
|
+
}
|
|
558
|
+
async function selectMcpAction(action) {
|
|
559
|
+
const result = selectMcpActionResult(settings, selectedMcpName, action);
|
|
560
|
+
if (result.settingsPatch)
|
|
561
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
562
|
+
if ('selectedName' in result)
|
|
563
|
+
setSelectedMcpName(result.selectedName);
|
|
564
|
+
if (result.mode)
|
|
565
|
+
setMode(result.mode);
|
|
566
|
+
showWizardMessage(result.message);
|
|
567
|
+
}
|
|
568
|
+
async function finishMcpCustom(keyValue) {
|
|
569
|
+
const result = finishMcpCustomResult(settings, mcpDraft, keyValue);
|
|
570
|
+
if (result.settingsPatch)
|
|
571
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
572
|
+
if (result.clearDraft)
|
|
573
|
+
setMcpDraft({});
|
|
574
|
+
if (result.mode)
|
|
575
|
+
setMode(result.mode);
|
|
576
|
+
showWizardMessage(result.message);
|
|
577
|
+
}
|
|
578
|
+
async function setMcpServerKey(keyValue) {
|
|
579
|
+
const result = setMcpServerKeyResult(settings, selectedMcpName, keyValue);
|
|
580
|
+
if (result.settingsPatch)
|
|
581
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
582
|
+
if ('selectedName' in result)
|
|
583
|
+
setSelectedMcpName(result.selectedName);
|
|
584
|
+
if (result.mode)
|
|
585
|
+
setMode(result.mode);
|
|
586
|
+
showWizardMessage(result.message);
|
|
587
|
+
}
|
|
588
|
+
// --- Skills wizard handlers (mirror the provider/LSP/MCP wizards) ---
|
|
589
|
+
async function selectSkill(name) {
|
|
590
|
+
const result = selectSkillResult(skills, name);
|
|
591
|
+
if (result.clearDraft)
|
|
592
|
+
setSkillDraft({});
|
|
593
|
+
if ('selectedName' in result)
|
|
594
|
+
setSelectedSkillName(result.selectedName);
|
|
595
|
+
if (result.mode)
|
|
596
|
+
setMode(result.mode);
|
|
597
|
+
showWizardMessage(result.message);
|
|
598
|
+
}
|
|
599
|
+
async function selectSkillAction(action) {
|
|
600
|
+
const result = selectSkillActionResult(settings, skills, selectedSkillName, action);
|
|
601
|
+
if (result.settingsPatch)
|
|
602
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
603
|
+
if ('selectedName' in result)
|
|
604
|
+
setSelectedSkillName(result.selectedName);
|
|
605
|
+
if (result.mode)
|
|
606
|
+
setMode(result.mode);
|
|
607
|
+
if (result.validate && result.skill) {
|
|
608
|
+
const { loadSkill } = await import('../../skills/SkillLoader.js');
|
|
609
|
+
try {
|
|
610
|
+
const loaded = await loadSkill(result.skill.dir, 'global');
|
|
611
|
+
showWizardMessage(loaded ? `Valid: ${loaded.name}` : 'No SKILL.md found');
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
615
|
+
showWizardMessage(`Invalid skill: ${text}`);
|
|
616
|
+
}
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
showWizardMessage(result.message);
|
|
653
620
|
}
|
|
654
621
|
async function captureSkillName(value) {
|
|
655
622
|
const dirName = toSkillDirName(value);
|
|
@@ -662,45 +629,37 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
662
629
|
setMessages(m => [...m, { role: 'system', text: `A skill named "${dirName}" already exists. Pick another name, or press ESC to cancel.` }]);
|
|
663
630
|
return;
|
|
664
631
|
}
|
|
665
|
-
|
|
666
|
-
setMode('
|
|
667
|
-
setMessages(m => [...m, { role: 'system', text: `
|
|
668
|
-
}
|
|
669
|
-
function captureSkillRole(value) {
|
|
670
|
-
const role = value.trim();
|
|
671
|
-
setSkillCreateDraft(d => ({ ...d, ...(role ? { role } : {}) }));
|
|
672
|
-
setMode('skillCreateDescription');
|
|
673
|
-
setMessages(m => [...m, { role: 'system', text: `Skill wizard — step 3/3: Describe what the skill should do. This is the work the LLM will expand into the skill body.` }]);
|
|
632
|
+
setSkillDraft(d => ({ ...d, name: dirName }));
|
|
633
|
+
setMode('skillsAddDescription');
|
|
634
|
+
setMessages(m => [...m, { role: 'system', text: `Describe what "${dirName}" should do. This is the work the LLM will expand into the skill body.` }]);
|
|
674
635
|
}
|
|
675
636
|
async function captureSkillDescription(value) {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
|
|
679
|
-
|
|
637
|
+
const result = captureSkillDescriptionResult(value, skillDraft.name);
|
|
638
|
+
if (result.message) {
|
|
639
|
+
const message = result.message;
|
|
640
|
+
setMessages(m => [...m, { role: 'system', text: message }]);
|
|
680
641
|
}
|
|
681
|
-
|
|
682
|
-
if (!name) {
|
|
642
|
+
if (result.mode === 'chat')
|
|
683
643
|
setMode('chat');
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
setBusyLabel('Haze is thinking');
|
|
644
|
+
if (result.clearDraft)
|
|
645
|
+
setSkillDraft({});
|
|
646
|
+
if (result.description && result.draftName) {
|
|
647
|
+
const name = result.draftName;
|
|
648
|
+
const description = result.description;
|
|
649
|
+
setBusyLabel(result.busyLabel ?? 'Creating skill');
|
|
650
|
+
setBusy(true);
|
|
651
|
+
try {
|
|
652
|
+
const created = await createSkill({ name, description });
|
|
653
|
+
setMessages(m => [...m, { role: 'system', text: skillCreationMessage(created.name, created.file) }]);
|
|
654
|
+
await refreshSkills();
|
|
655
|
+
}
|
|
656
|
+
catch (error) {
|
|
657
|
+
setMessages(m => [...m, { role: 'system', text: skillCreationFailure(error) }]);
|
|
658
|
+
}
|
|
659
|
+
finally {
|
|
660
|
+
setBusy(false);
|
|
661
|
+
setBusyLabel('Haze is thinking');
|
|
662
|
+
}
|
|
704
663
|
}
|
|
705
664
|
}
|
|
706
665
|
async function submit(value) {
|
|
@@ -709,18 +668,40 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
709
668
|
queueFollowUp(value);
|
|
710
669
|
return;
|
|
711
670
|
}
|
|
712
|
-
if (mode === '
|
|
713
|
-
await
|
|
671
|
+
if (mode === 'skills') {
|
|
672
|
+
await selectSkill(value);
|
|
714
673
|
return;
|
|
715
674
|
}
|
|
716
|
-
if (mode === '
|
|
717
|
-
|
|
675
|
+
if (mode === 'skillsAction') {
|
|
676
|
+
await selectSkillAction(value);
|
|
718
677
|
return;
|
|
719
678
|
}
|
|
720
|
-
if (mode === '
|
|
679
|
+
if (mode === 'skillsAddName') {
|
|
680
|
+
await captureSkillName(value);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
if (mode === 'skillsAddDescription') {
|
|
721
684
|
await captureSkillDescription(value);
|
|
722
685
|
return;
|
|
723
686
|
}
|
|
687
|
+
if (mode === 'skillsConfirmRemove') {
|
|
688
|
+
const result = skillConfirmRemove(settings, skills, selectedSkillName, value);
|
|
689
|
+
if (result.message) {
|
|
690
|
+
const message = result.message;
|
|
691
|
+
setMessages(m => [...m, { role: 'system', text: message }]);
|
|
692
|
+
}
|
|
693
|
+
if (result.selectedName === undefined)
|
|
694
|
+
setSelectedSkillName(undefined);
|
|
695
|
+
if (result.mode === 'chat')
|
|
696
|
+
setMode('chat');
|
|
697
|
+
if (result.removedDir)
|
|
698
|
+
await fs.remove(result.removedDir);
|
|
699
|
+
if (result.settingsPatch)
|
|
700
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
701
|
+
if (result.removedDir)
|
|
702
|
+
await refreshSkills();
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
724
705
|
if (mode === 'provider') {
|
|
725
706
|
await selectProvider(value);
|
|
726
707
|
return;
|
|
@@ -738,31 +719,29 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
738
719
|
return;
|
|
739
720
|
}
|
|
740
721
|
if (mode === 'providerAddName') {
|
|
741
|
-
const
|
|
742
|
-
if (
|
|
743
|
-
|
|
722
|
+
const result = captureProviderName(settings, value);
|
|
723
|
+
if (result.message) {
|
|
724
|
+
showWizardMessage(result.message);
|
|
744
725
|
return;
|
|
745
726
|
}
|
|
746
|
-
if (
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
setMode('providerAddUrl');
|
|
752
|
-
setMessages(m => [...m, { role: 'system', text: 'OpenAI-compatible base URL? Example: https://openrouter.ai/api/v1 or http://localhost:1234/v1' }]);
|
|
727
|
+
if (result.draft)
|
|
728
|
+
setProviderDraft({ name: result.draft.name });
|
|
729
|
+
if (result.nextMode)
|
|
730
|
+
setMode(result.nextMode);
|
|
731
|
+
showWizardMessage(result.systemMessage);
|
|
753
732
|
return;
|
|
754
733
|
}
|
|
755
734
|
if (mode === 'providerAddUrl') {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
catch {
|
|
760
|
-
setMessages(m => [...m, { role: 'system', text: 'Enter a valid URL, for example http://localhost:1234/v1.' }]);
|
|
735
|
+
const result = captureProviderUrl(value);
|
|
736
|
+
if (result.message) {
|
|
737
|
+
showWizardMessage(result.message);
|
|
761
738
|
return;
|
|
762
739
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
740
|
+
if (result.draft)
|
|
741
|
+
setProviderDraft(draft => ({ ...draft, ...result.draft }));
|
|
742
|
+
if (result.nextMode)
|
|
743
|
+
setMode(result.nextMode);
|
|
744
|
+
showWizardMessage(result.systemMessage);
|
|
766
745
|
return;
|
|
767
746
|
}
|
|
768
747
|
if (mode === 'providerAddKey') {
|
|
@@ -780,59 +759,38 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
780
759
|
return;
|
|
781
760
|
}
|
|
782
761
|
if (mode === 'providerSetKey') {
|
|
783
|
-
const
|
|
784
|
-
if (!provider) {
|
|
785
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
762
|
+
const result = providerSetKey(settings, selectedProviderName, value);
|
|
763
|
+
if (!result.provider) {
|
|
764
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
786
765
|
setMode('chat');
|
|
787
766
|
return;
|
|
788
767
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
setMessages(m => [...m, { role: 'system', text: 'API key cannot be empty. Esc to cancel.' }]);
|
|
768
|
+
if (!result.settingsPatch) {
|
|
769
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
792
770
|
return;
|
|
793
771
|
}
|
|
794
|
-
|
|
795
|
-
const next = await updateSettings({ providers: upsertProvider(settings, updated) });
|
|
796
|
-
setSettings(next);
|
|
772
|
+
setSettings(await updateSettings(result.settingsPatch));
|
|
797
773
|
setSelectedProviderName(undefined);
|
|
798
774
|
setMode('chat');
|
|
799
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
775
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
800
776
|
return;
|
|
801
777
|
}
|
|
802
778
|
if (mode === 'providerRemoveModels') {
|
|
803
|
-
const
|
|
804
|
-
if (!provider) {
|
|
805
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
779
|
+
const result = providerRemoveModels(settings, selectedProviderName, value);
|
|
780
|
+
if (!result.provider) {
|
|
781
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
806
782
|
setMode('chat');
|
|
807
783
|
return;
|
|
808
784
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
setMessages(m => [...m, { role: 'system', text: 'Enter at least one model name. Esc to cancel.' }]);
|
|
812
|
-
return;
|
|
813
|
-
}
|
|
814
|
-
const remaining = provider.models.filter(m => !toRemove.includes(m));
|
|
815
|
-
if (remaining.length === 0) {
|
|
816
|
-
setMessages(m => [...m, { role: 'system', text: 'A provider must have at least one model. Remove the provider instead.' }]);
|
|
785
|
+
if (!result.settingsPatch) {
|
|
786
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
817
787
|
return;
|
|
818
788
|
}
|
|
819
|
-
const
|
|
820
|
-
const notFound = toRemove.filter(m => !provider.models.includes(m));
|
|
821
|
-
const updated = { ...provider, models: remaining };
|
|
822
|
-
const wasActive = settings.model && provider.models.includes(settings.model) && !remaining.includes(settings.model);
|
|
823
|
-
const next = await updateSettings({
|
|
824
|
-
providers: upsertProvider(settings, updated),
|
|
825
|
-
...(wasActive ? { model: remaining[0] } : {}),
|
|
826
|
-
});
|
|
789
|
+
const next = await updateSettings(result.settingsPatch);
|
|
827
790
|
setSettings(next);
|
|
828
791
|
setSelectedProviderName(undefined);
|
|
829
792
|
setMode('chat');
|
|
830
|
-
|
|
831
|
-
if (notFound.length)
|
|
832
|
-
parts.push(`Not found: ${notFound.join(', ')}.`);
|
|
833
|
-
if (wasActive)
|
|
834
|
-
parts.push(`Active model updated to ${remaining[0]}.`);
|
|
835
|
-
setMessages(m => [...m, { role: 'system', text: parts.join(' ') }]);
|
|
793
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
836
794
|
return;
|
|
837
795
|
}
|
|
838
796
|
if (mode === 'providerConfirmRemove') {
|
|
@@ -842,22 +800,155 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
842
800
|
setMode('chat');
|
|
843
801
|
return;
|
|
844
802
|
}
|
|
845
|
-
if (value
|
|
803
|
+
if (!isYesConfirmation(value)) {
|
|
846
804
|
setMessages(m => [...m, { role: 'system', text: 'Cancelled. Provider not removed.' }]);
|
|
847
805
|
setSelectedProviderName(undefined);
|
|
848
806
|
setMode('chat');
|
|
849
807
|
return;
|
|
850
808
|
}
|
|
851
|
-
const
|
|
852
|
-
const
|
|
853
|
-
const next = await updateSettings({
|
|
854
|
-
providers,
|
|
855
|
-
...(wasActiveProvider ? { provider: providers[0]?.name, model: providers[0]?.models[0] } : {}),
|
|
856
|
-
});
|
|
809
|
+
const result = providerRemove(settings, selectedProviderName);
|
|
810
|
+
const next = await updateSettings(result.settingsPatch ?? {});
|
|
857
811
|
setSettings(next);
|
|
858
812
|
setSelectedProviderName(undefined);
|
|
859
813
|
setMode('chat');
|
|
860
|
-
setMessages(m => [...m, { role: 'system', text:
|
|
814
|
+
setMessages(m => [...m, { role: 'system', text: result.message }]);
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
if (mode === 'lsp') {
|
|
818
|
+
await selectLspServer(value);
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
if (mode === 'lspAction') {
|
|
822
|
+
await selectLspAction(value);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if (mode === 'lspAddPreset') {
|
|
826
|
+
await selectLspPreset(value);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (mode === 'lspAddName') {
|
|
830
|
+
const result = captureLspName(settings, value);
|
|
831
|
+
if (result.message) {
|
|
832
|
+
showWizardMessage(result.message);
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
if (result.draft)
|
|
836
|
+
setLspDraft({ name: result.draft.name });
|
|
837
|
+
if (result.nextMode)
|
|
838
|
+
setMode(result.nextMode);
|
|
839
|
+
showWizardMessage(result.systemMessage);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
if (mode === 'lspAddCommand') {
|
|
843
|
+
await finishLspCustom(value);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
if (mode === 'lspConfirmRemove') {
|
|
847
|
+
if (!selectedLspName) {
|
|
848
|
+
setMode('chat');
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
if (!isYesConfirmation(value)) {
|
|
852
|
+
setMessages(m => [...m, { role: 'system', text: 'Cancelled. LSP server not removed.' }]);
|
|
853
|
+
setSelectedLspName(undefined);
|
|
854
|
+
setMode('chat');
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
const next = await updateSettings({ lspServers: removeLspServer(settings, selectedLspName) });
|
|
858
|
+
setSettings(next);
|
|
859
|
+
setMessages(m => [...m, { role: 'system', text: `Removed LSP server ${selectedLspName}.` }]);
|
|
860
|
+
setSelectedLspName(undefined);
|
|
861
|
+
setMode('chat');
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
if (mode === 'mcp') {
|
|
865
|
+
await selectMcpServer(value);
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (mode === 'mcpAction') {
|
|
869
|
+
await selectMcpAction(value);
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (mode === 'mcpAddPreset') {
|
|
873
|
+
await selectMcpPreset(value);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
if (mode === 'mcpAddName') {
|
|
877
|
+
const result = captureMcpName(settings, value);
|
|
878
|
+
if (result.message) {
|
|
879
|
+
showWizardMessage(result.message);
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
if (result.draft)
|
|
883
|
+
setMcpDraft({ name: result.draft.name });
|
|
884
|
+
if (result.nextMode)
|
|
885
|
+
setMode(result.nextMode);
|
|
886
|
+
showWizardMessage(result.systemMessage);
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
if (mode === 'mcpAddTransport') {
|
|
890
|
+
const result = captureMcpTransport(value);
|
|
891
|
+
if (result.message) {
|
|
892
|
+
showWizardMessage(result.message);
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
if (result.draft)
|
|
896
|
+
setMcpDraft(draft => ({ ...draft, ...result.draft }));
|
|
897
|
+
if (result.nextMode)
|
|
898
|
+
setMode(result.nextMode);
|
|
899
|
+
showWizardMessage(result.systemMessage);
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
if (mode === 'mcpAddUrl') {
|
|
903
|
+
const result = captureMcpUrl(value);
|
|
904
|
+
if (result.message) {
|
|
905
|
+
showWizardMessage(result.message);
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
if (result.draft)
|
|
909
|
+
setMcpDraft(draft => ({ ...draft, ...result.draft }));
|
|
910
|
+
if (result.nextMode)
|
|
911
|
+
setMode(result.nextMode);
|
|
912
|
+
showWizardMessage(result.systemMessage);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
if (mode === 'mcpAddCommand') {
|
|
916
|
+
const result = captureMcpCommand(value);
|
|
917
|
+
if (result.message) {
|
|
918
|
+
showWizardMessage(result.message);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
if (result.draft)
|
|
922
|
+
setMcpDraft(draft => ({ ...draft, ...result.draft }));
|
|
923
|
+
if (result.nextMode)
|
|
924
|
+
setMode(result.nextMode);
|
|
925
|
+
showWizardMessage(result.systemMessage);
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (mode === 'mcpAddKey') {
|
|
929
|
+
await finishMcpCustom(value);
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
if (mode === 'mcpSetKey') {
|
|
933
|
+
await setMcpServerKey(value);
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
if (mode === 'mcpConfirmRemove') {
|
|
937
|
+
if (!selectedMcpName) {
|
|
938
|
+
setMode('chat');
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
if (!isYesConfirmation(value)) {
|
|
942
|
+
setMessages(m => [...m, { role: 'system', text: 'Cancelled. MCP server not removed.' }]);
|
|
943
|
+
setSelectedMcpName(undefined);
|
|
944
|
+
setMode('chat');
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
const next = await updateSettings({ mcpServers: removeMcpServer(settings, selectedMcpName) });
|
|
948
|
+
setSettings(next);
|
|
949
|
+
setMessages(m => [...m, { role: 'system', text: `Removed MCP server ${selectedMcpName}.` }]);
|
|
950
|
+
setSelectedMcpName(undefined);
|
|
951
|
+
setMode('chat');
|
|
861
952
|
return;
|
|
862
953
|
}
|
|
863
954
|
const invokedSkill = skillInvocation(value);
|
|
@@ -884,12 +975,18 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
884
975
|
sessionInfo: () => sessionRef.current ? formatSession(sessionRef.current) : 'Session persistence is off.',
|
|
885
976
|
compactConversation,
|
|
886
977
|
runAgentTurn: (prompt, displayValue) => doAgentTurn(prompt, displayValue),
|
|
887
|
-
refreshContextFiles: async () => {
|
|
978
|
+
refreshContextFiles: async () => {
|
|
979
|
+
const files = await readContextFiles().catch(() => contextFiles);
|
|
980
|
+
setContextFiles(files);
|
|
981
|
+
contextFileSignaturesRef.current = new Map(files.flatMap(file => file.signature ? [[file.path, file.signature]] : []));
|
|
982
|
+
return files;
|
|
983
|
+
},
|
|
888
984
|
updateSettings: async (patch) => {
|
|
889
985
|
const next = await updateSettings(patch);
|
|
890
986
|
setSettings(next);
|
|
891
987
|
return next;
|
|
892
988
|
},
|
|
989
|
+
getContextReport: async () => buildContextReport(),
|
|
893
990
|
};
|
|
894
991
|
let result;
|
|
895
992
|
try {
|
|
@@ -903,9 +1000,6 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
903
1000
|
if (result === 'exit')
|
|
904
1001
|
return exit();
|
|
905
1002
|
if (result === 'handled') {
|
|
906
|
-
if (value.startsWith('/remove-skill ')) {
|
|
907
|
-
await refreshSkills().catch(() => undefined);
|
|
908
|
-
}
|
|
909
1003
|
if (value === '/clear') {
|
|
910
1004
|
loadTasksFromStore().then(t => { setVisibleTasks(t); setTaskBarPadding(0); }).catch(() => undefined);
|
|
911
1005
|
}
|
|
@@ -918,7 +1012,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
918
1012
|
// When every task is already completed, start the new turn with a clean
|
|
919
1013
|
// slate: the task bar clears (nothing shown for simple questions) and the
|
|
920
1014
|
// model may create fresh todos via writeTasks if the new question warrants.
|
|
921
|
-
if (visibleTasks
|
|
1015
|
+
if (shouldClearCompletedTasks(visibleTasks)) {
|
|
922
1016
|
setVisibleTasks([]);
|
|
923
1017
|
setTasksExpanded(false);
|
|
924
1018
|
setTaskBarPadding(0);
|
|
@@ -934,17 +1028,13 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
934
1028
|
}
|
|
935
1029
|
}
|
|
936
1030
|
async function runSingleAgentTurn(value, displayValue) {
|
|
937
|
-
const
|
|
938
|
-
const session = sessionRef.current;
|
|
939
|
-
if (session)
|
|
940
|
-
void appendSessionEntry(session, { type: 'ui_message', at: new Date().toISOString(), role: msg.role, text: msg.text }).catch(() => undefined);
|
|
941
|
-
};
|
|
1031
|
+
const sessionRecorder = createSessionRecorder(() => sessionRef.current);
|
|
942
1032
|
const finalizeMessage = (msg) => {
|
|
943
1033
|
if (msg.hidden)
|
|
944
1034
|
return;
|
|
945
1035
|
const ordered = withDisplayOrder(msg);
|
|
946
1036
|
setMessages(m => [...m, ordered]);
|
|
947
|
-
|
|
1037
|
+
sessionRecorder.recordUiMessage(ordered);
|
|
948
1038
|
};
|
|
949
1039
|
await runAgentTurn(value, displayValue, contextFiles, {
|
|
950
1040
|
addMessage: msg => {
|
|
@@ -971,9 +1061,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
971
1061
|
},
|
|
972
1062
|
setConversation: msgs => {
|
|
973
1063
|
conversationRef.current = msgs;
|
|
974
|
-
|
|
975
|
-
if (session)
|
|
976
|
-
void appendSessionEntry(session, { type: 'conversation_snapshot', at: new Date().toISOString(), messages: msgs }).catch(() => undefined);
|
|
1064
|
+
sessionRecorder.recordConversation(msgs);
|
|
977
1065
|
},
|
|
978
1066
|
setBusy,
|
|
979
1067
|
setBusyLabel,
|
|
@@ -985,77 +1073,33 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
985
1073
|
setGoalStatus: setActiveGoalStatus,
|
|
986
1074
|
setWorkState: state => {
|
|
987
1075
|
workStateRef.current = state;
|
|
988
|
-
|
|
989
|
-
if (session)
|
|
990
|
-
void appendSessionEntry(session, { type: 'work_state_snapshot', at: new Date().toISOString(), state }).catch(() => undefined);
|
|
1076
|
+
sessionRecorder.recordWorkState(state);
|
|
991
1077
|
},
|
|
992
1078
|
compactConversation,
|
|
993
1079
|
recordTokenUsage: usage => {
|
|
994
|
-
setTokenUsage(current => (
|
|
995
|
-
inputTokens: (current.inputTokens ?? 0) + (usage.inputTokens ?? 0) || usage.inputTokens,
|
|
996
|
-
outputTokens: (current.outputTokens ?? 0) + (usage.outputTokens ?? 0) || usage.outputTokens,
|
|
997
|
-
systemPrompt: current.systemPrompt + usage.systemPrompt,
|
|
998
|
-
messages: current.messages + usage.messages,
|
|
999
|
-
toolSchemas: current.toolSchemas + usage.toolSchemas,
|
|
1000
|
-
outputEstimate: current.outputEstimate + usage.outputEstimate,
|
|
1001
|
-
cacheReadTokens: current.cacheReadTokens + usage.cacheReadTokens,
|
|
1002
|
-
cacheWriteTokens: current.cacheWriteTokens + usage.cacheWriteTokens,
|
|
1003
|
-
noCacheTokens: current.noCacheTokens + usage.noCacheTokens,
|
|
1004
|
-
reasoningTokens: current.reasoningTokens + usage.reasoningTokens,
|
|
1005
|
-
logicalInputEstimate: current.logicalInputEstimate + usage.logicalInputEstimate,
|
|
1006
|
-
effectiveNonCachedInput: (current.effectiveNonCachedInput ?? 0) + (usage.effectiveNonCachedInput ?? 0) || usage.effectiveNonCachedInput,
|
|
1007
|
-
}));
|
|
1080
|
+
setTokenUsage(current => accumulateTokenUsage(current, usage));
|
|
1008
1081
|
},
|
|
1009
1082
|
onEvent: event => {
|
|
1010
|
-
|
|
1011
|
-
if (session)
|
|
1012
|
-
void appendSessionEntry(session, { type: 'event', at: event.at, name: event.type, text: JSON.stringify(event) }).catch(() => undefined);
|
|
1083
|
+
sessionRecorder.recordEvent(event);
|
|
1013
1084
|
},
|
|
1014
1085
|
onTasksChanged: () => { loadTasksFromStore().then(t => { setVisibleTasks(t); setTaskBarPadding(0); }).catch(() => undefined); },
|
|
1086
|
+
contextFileSignatures: contextFileSignaturesRef.current,
|
|
1015
1087
|
log: llmLogRef.current,
|
|
1016
1088
|
}, 0, false, false, { start: sessionStartRef.current, cwd: process.cwd() });
|
|
1017
1089
|
}
|
|
1018
1090
|
const visible = messages.filter(message => !message.hidden);
|
|
1019
1091
|
const activeLiveMessages = liveMessages.filter(message => !message.hidden);
|
|
1020
1092
|
const orderedVisibleMessages = orderedDisplayMessages([...visible, ...activeLiveMessages]);
|
|
1021
|
-
const
|
|
1022
|
-
const
|
|
1023
|
-
const transcriptItems = staticDisplayItems.map((item, index) => ({ key: messageKey(item.message, index), ...item }));
|
|
1024
|
-
const activeLiveItems = annotatedDisplayMessages.filter(item => item.message.streaming);
|
|
1093
|
+
const transcriptItems = orderedVisibleMessages.filter(message => !message.streaming).map((message, index) => ({ key: messageKey(message, index), message }));
|
|
1094
|
+
const streamingItems = orderedVisibleMessages.filter(message => message.streaming);
|
|
1025
1095
|
const activeSelection = activeModel(settings);
|
|
1026
|
-
const placeholder = mode
|
|
1027
|
-
? 'Choose provider'
|
|
1028
|
-
: mode === 'providerAction'
|
|
1029
|
-
? 'Choose provider action'
|
|
1030
|
-
: mode === 'providerAddPreset'
|
|
1031
|
-
? 'Choose a provider preset or custom'
|
|
1032
|
-
: mode === 'model'
|
|
1033
|
-
? 'Choose model'
|
|
1034
|
-
: mode === 'providerAddName'
|
|
1035
|
-
? 'Provider name'
|
|
1036
|
-
: mode === 'providerAddUrl'
|
|
1037
|
-
? 'https://example.com/v1'
|
|
1038
|
-
: mode === 'providerAddKey' || mode === 'providerSetKey'
|
|
1039
|
-
? 'API key, or blank for local'
|
|
1040
|
-
: mode === 'providerAddModels' || mode === 'providerAppendModels'
|
|
1041
|
-
? 'model-a, model-b'
|
|
1042
|
-
: mode === 'providerRemoveModels'
|
|
1043
|
-
? 'model-a, model-b'
|
|
1044
|
-
: mode === 'providerConfirmRemove'
|
|
1045
|
-
? 'Type "yes" to confirm'
|
|
1046
|
-
: mode === 'skillCreateName'
|
|
1047
|
-
? 'Skill name (kebab-case, e.g. security-review)'
|
|
1048
|
-
: mode === 'skillCreateRole'
|
|
1049
|
-
? 'Role (optional — Enter to skip)'
|
|
1050
|
-
: mode === 'skillCreateDescription'
|
|
1051
|
-
? 'Describe what the skill should do'
|
|
1052
|
-
: busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask Haze to help build your app';
|
|
1096
|
+
const placeholder = placeholderForMode(mode, busy);
|
|
1053
1097
|
const activeModelName = activeSelection ? `${activeSelection.provider.name}:${activeSelection.model}` : 'unconfigured';
|
|
1054
1098
|
const headerSubtitle = [
|
|
1055
1099
|
'A minimal LLM harness for growing your own workflows while you work.',
|
|
1056
1100
|
'',
|
|
1057
1101
|
'Start with simple chat, then teach Haze your habits with skills:',
|
|
1058
|
-
'/
|
|
1102
|
+
'/skills — add, enable/disable, validate, or remove Markdown skills.',
|
|
1059
1103
|
'',
|
|
1060
1104
|
'The most adaptive workflow is the one you shape as you go.',
|
|
1061
1105
|
'',
|
|
@@ -1073,37 +1117,17 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
1073
1117
|
const effectiveOutput = tokenUsage.outputTokens ?? (fallbackTokens.output || 0);
|
|
1074
1118
|
const inputEstimated = providerInput == null || effectiveInput !== providerInput;
|
|
1075
1119
|
const outputEstimated = tokenUsage.outputTokens == null;
|
|
1076
|
-
const
|
|
1120
|
+
const enabledSkills = skills.filter(skill => isSkillEnabled(settings, skill.name));
|
|
1121
|
+
const statusDetailLabel = `${hazeMessages} haze message${hazeMessages === 1 ? '' : 's'} / ${toolsUsed} tool call${toolsUsed === 1 ? '' : 's'} / LLM ${inputEstimated ? '~' : ''}↑${formatTokenCount(effectiveInput)} ${outputEstimated ? '~' : ''}↓${formatTokenCount(effectiveOutput)} / ${enabledSkills.length} skill${enabledSkills.length === 1 ? '' : 's'}`;
|
|
1077
1122
|
const hasTokenBreakdown = tokenUsage.systemPrompt > 0 || tokenUsage.messages > 0 || tokenUsage.toolSchemas > 0 || effectiveInput > 0 || effectiveOutput > 0;
|
|
1078
|
-
const
|
|
1079
|
-
// Goal tracking is internal; display removed in favor of task bar
|
|
1080
|
-
void goalText;
|
|
1081
|
-
const inputSuggestions = mode === 'provider' ? providerSuggestions() : mode === 'providerAction' ? providerActionSuggestions() : mode === 'providerAddPreset' ? presetSuggestions() : mode === 'model' ? modelSuggestions() : mode === 'chat' ? [
|
|
1082
|
-
{ value: '/help', description: 'Show commands', kind: 'command' },
|
|
1083
|
-
{ value: '/provider', description: 'Choose a provider', kind: 'command' },
|
|
1084
|
-
{ value: '/model', description: 'Choose a model', kind: 'command' },
|
|
1085
|
-
{ value: '/settings', description: 'Show provider, model, API key, and context status', kind: 'command' },
|
|
1086
|
-
{ value: '/create-skill ', description: 'Launch the skill wizard', kind: 'command' },
|
|
1087
|
-
{ value: '/skill-info ', description: 'Show details for a skill', kind: 'command' },
|
|
1088
|
-
{ value: '/validate-skill ', description: 'Validate a skill', kind: 'command' },
|
|
1089
|
-
{ value: '/remove-skill ', description: 'Remove a skill with --yes', kind: 'command' },
|
|
1090
|
-
{ value: '/init', description: 'Create or update AGENTS.md project instructions', kind: 'command' },
|
|
1091
|
-
{ value: '/session', description: 'Show current session path', kind: 'command' },
|
|
1092
|
-
{ value: '/resume', description: 'Resume latest session for this workspace', kind: 'command' },
|
|
1093
|
-
{ value: '/new', description: 'Start a new session', kind: 'command' },
|
|
1094
|
-
{ value: '/compact ', description: 'Summarize older context and keep recent messages', kind: 'command' },
|
|
1095
|
-
{ value: '/clear', description: 'Clear conversation history', kind: 'command' },
|
|
1096
|
-
{ value: '/exit', description: 'Exit Haze', kind: 'command' },
|
|
1097
|
-
{ value: '/quit', description: 'Exit Haze', kind: 'command' },
|
|
1098
|
-
...skills.map(skill => ({ value: `/${skill.name}`, description: skill.description, kind: 'skill' })),
|
|
1099
|
-
] : [];
|
|
1123
|
+
const inputSuggestions = inputSuggestionsForState({ mode, settings, skills, selectedProviderName, modelProviderFilter, selectedSkillName, selectedLspName, selectedMcpName });
|
|
1100
1124
|
const staticItems = [
|
|
1101
1125
|
{ kind: 'header', key: `header-${activeModelName}`, subtitle: headerSubtitle },
|
|
1102
1126
|
...transcriptItems.map(item => ({ kind: 'message', ...item })),
|
|
1103
1127
|
];
|
|
1104
1128
|
return _jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: staticItems, children: item => item.kind === 'header'
|
|
1105
1129
|
? _jsx(Header, { subtitle: item.subtitle, version: version }, item.key)
|
|
1106
|
-
: _jsx(MessageView, { message: item.message, width: width
|
|
1130
|
+
: _jsx(MessageView, { message: item.message, width: width }, item.key) }), streamingItems.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, children: streamingItems.map((message, index) => _jsx(MessageView, { message: message, width: width }, messageKey(message, index))) }), debug && debugLogs.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, borderStyle: "round", borderColor: theme.muted, paddingX: 1, children: [_jsx(Text, { color: theme.muted, bold: true, children: "Debug" }), debugLogs.map((line, index) => _jsxs(Text, { color: theme.muted, children: ["\u2022 ", line] }, index))] }), queuedFollowUps.length > 0 && _jsxs(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: [_jsx(Text, { color: theme.muted, children: "Queued follow-ups:" }), queuedFollowUps.map((item, index) => _jsxs(Text, { color: theme.muted, dimColor: true, children: [" ", index + 1, ". ", item] }, `${index}-${item}`))] }), visibleTasks.length > 0 && _jsx(Box, { flexDirection: "column", flexShrink: 0, marginBottom: 1, children: _jsx(TaskBar, { tasks: visibleTasks, width: width, expanded: tasksExpanded, padding: taskBarPadding }) }), busy && _jsx(Box, { flexShrink: 0, children: _jsxs(Text, { children: [_jsxs(Text, { color: theme.orange, bold: true, children: [_jsx(Spinner, { type: "dots" }), " ", busyLabel] }), _jsx(Text, { color: theme.muted, dimColor: true, children: " \u00B7 type to queue follow-up \u00B7 esc to interrupt" })] }) }), _jsx(Box, { borderStyle: "round", borderColor: theme.deepPurple, paddingX: 1, flexShrink: 0, children: _jsx(Box, { flexGrow: 1, minWidth: 0, children: _jsx(TextInput, { placeholder: placeholder, disabled: busy && mode !== 'chat', mask: MASKED_MODES.has(mode), historyItems: inputHistory, recordHistory: mode === 'chat', suggestions: inputSuggestions, suggestionMode: PICKER_MODES.has(mode) ? 'always' : 'slash', submitOnEmpty: SUBMIT_EMPTY_MODES.has(mode), width: Math.max(20, width - 4), onHistoryAdd: persistInputHistory, onToggleTasks: () => {
|
|
1107
1131
|
if (!tasksExpanded) {
|
|
1108
1132
|
setTaskBarPadding(0);
|
|
1109
1133
|
setTasksExpanded(true);
|