@denizokcu/haze 0.7.0 → 0.9.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 +35 -9
- package/README.md +37 -35
- package/dist/cli/chat/inputSuggestions.js +2 -2
- package/dist/cli/chat/sessionRecorder.d.ts +3 -0
- package/dist/cli/chat/sessionRecorder.js +23 -8
- package/dist/cli/commands/chat.js +136 -124
- package/dist/cli/commands/chatModes.js +1 -1
- package/dist/cli/commands/commandHelp.js +2 -2
- package/dist/cli/commands/commands.d.ts +1 -1
- package/dist/cli/commands/commands.js +1 -1
- package/dist/cli/commands/formatters.d.ts +6 -0
- package/dist/cli/commands/formatters.js +41 -3
- package/dist/cli/commands/logsCommand.js +7 -21
- package/dist/cli/commands/mcpWizard.js +24 -2
- package/dist/cli/commands/providerWizard.js +18 -5
- package/dist/cli/commands/runCommand.js +7 -15
- package/dist/cli/commands/settingsSummary.js +3 -1
- package/dist/cli/commands/streaming/turnOutcome.d.ts +10 -0
- package/dist/cli/commands/streaming/turnOutcome.js +13 -0
- package/dist/cli/commands/streaming.js +99 -51
- package/dist/cli/commands/wizardPrompts.js +1 -1
- package/dist/cli/commands/wizardSuggestions.js +3 -2
- package/dist/cli/commands/wizardTransition.d.ts +33 -0
- package/dist/cli/commands/wizardTransition.js +44 -0
- package/dist/config/contextFiles.js +6 -3
- package/dist/config/endpointSecurity.d.ts +2 -0
- package/dist/config/endpointSecurity.js +28 -0
- package/dist/config/inputHistory.js +4 -2
- package/dist/config/privateStorage.d.ts +6 -0
- package/dist/config/privateStorage.js +61 -0
- package/dist/config/providers.js +5 -9
- package/dist/config/settings.d.ts +1 -0
- package/dist/config/settings.js +55 -3
- package/dist/config/updateCheck.js +4 -2
- package/dist/core/agent/compaction.js +2 -2
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/requestAssembly.d.ts +1 -0
- package/dist/core/agent/requestAssembly.js +13 -0
- package/dist/core/agent/toolOutputStore.d.ts +3 -0
- package/dist/core/agent/toolOutputStore.js +32 -11
- package/dist/core/bashOutput/registry.js +11 -9
- package/dist/core/goal/completionPolicy.d.ts +0 -28
- package/dist/core/goal/completionPolicy.js +1 -89
- package/dist/core/io/boundedRead.d.ts +15 -0
- package/dist/core/io/boundedRead.js +97 -0
- package/dist/core/limits/byteBudgets.d.ts +13 -0
- package/dist/core/limits/byteBudgets.js +13 -0
- package/dist/core/log/llmLog.d.ts +10 -0
- package/dist/core/log/llmLog.js +59 -13
- package/dist/core/persistence/orderedFileWriter.d.ts +11 -0
- package/dist/core/persistence/orderedFileWriter.js +29 -0
- package/dist/core/process/runBoundedProcess.d.ts +27 -0
- package/dist/core/process/runBoundedProcess.js +80 -0
- package/dist/core/session/sessionStore.js +48 -25
- package/dist/core/subagent/subagentRunner.d.ts +252 -9
- package/dist/core/subagent/subagentRunner.js +14 -19
- package/dist/core/toolOutput/reduction.d.ts +2 -0
- package/dist/core/toolOutput/reduction.js +12 -0
- package/dist/core/validation/outputParser.js +5 -3
- package/dist/llm/client.d.ts +2 -2
- package/dist/llm/client.js +19 -3
- package/dist/llm/hazeTools.d.ts +8103 -364
- package/dist/llm/hazeTools.js +43 -33
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp.d.ts +21 -3
- package/dist/llm/lsp.js +65 -14
- package/dist/llm/lspTools.d.ts +2358 -101
- package/dist/llm/mcp.d.ts +1 -1
- package/dist/llm/mcp.js +65 -16
- package/dist/llm/requestContext.d.ts +1 -0
- package/dist/llm/requestContext.js +6 -3
- package/dist/llm/systemPrompt.js +2 -2
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/bashTool.d.ts +603 -5
- package/dist/llm/tools/bashTool.js +23 -60
- package/dist/llm/tools/fetchTool.d.ts +1201 -65
- package/dist/llm/tools/fetchTool.js +2 -1
- package/dist/llm/tools/grepRunner.d.ts +15 -0
- package/dist/llm/tools/grepRunner.js +85 -0
- package/dist/llm/tools/storedOutputTool.d.ts +351 -10
- package/dist/llm/tools/taskTool.d.ts +629 -28
- package/dist/llm/tools/toolContext.d.ts +7 -2
- package/dist/llm/tools/toolContext.js +11 -2
- package/dist/llm/webFetch.js +31 -21
- package/dist/skills/SkillLoader.js +17 -5
- package/dist/skills/SkillRegistry.js +19 -6
- package/dist/skills/builder/SkillBuilder.js +7 -7
- package/dist/skills/types.d.ts +5 -0
- package/dist/ui/components/TextInput.d.ts +7 -0
- package/dist/ui/components/TextInput.js +10 -0
- package/dist/utils/modelName.d.ts +2 -0
- package/dist/utils/modelName.js +15 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +9 -4
- package/examples/skills/files/SKILL.md +1 -1
- package/package.json +14 -14
|
@@ -19,12 +19,12 @@ import { TextInput } from '../../ui/components/TextInput.js';
|
|
|
19
19
|
import { theme } from '../../ui/theme.js';
|
|
20
20
|
import { handleSlashCommand } from './commands.js';
|
|
21
21
|
import { runAgentTurn } from './streaming.js';
|
|
22
|
-
import { formatContextReport } from './formatters.js';
|
|
22
|
+
import { formatContextReport, formatElapsedTimeWhole } from './formatters.js';
|
|
23
23
|
import { createLog as createLlmLog, endLog as endLlmLog } from '../../core/log/llmLog.js';
|
|
24
24
|
import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
|
|
25
25
|
import { createSkill, toSkillDirName } from '../../skills/builder/SkillBuilder.js';
|
|
26
26
|
import { findPreset } from '../../config/providerPresets.js';
|
|
27
|
-
import {
|
|
27
|
+
import { createSession, formatSession, latestSession, restoreConversation, restoreWorkState } from '../../core/session/sessionStore.js';
|
|
28
28
|
import { compactModelMessages } from '../../core/agent/compaction.js';
|
|
29
29
|
import { contextBreakdown } from '../../core/agent/contextBudget.js';
|
|
30
30
|
import { stripSyntheticControls } from '../../core/agent/requestAssembly.js';
|
|
@@ -40,8 +40,10 @@ import { compactHomePath, displayMessagesFromConversation, estimateConversationT
|
|
|
40
40
|
import { accumulateTokenUsage, EMPTY_TOKEN_USAGE, shouldClearCompletedTasks } from '../chat/turnState.js';
|
|
41
41
|
import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES, placeholderForMode } from './chatModes.js';
|
|
42
42
|
import { inputSuggestionsForState } from '../chat/inputSuggestions.js';
|
|
43
|
+
import { modelThinkingLabel } from '../../utils/modelName.js';
|
|
43
44
|
import { PROVIDER_ACTIONS, PROVIDER_CHOICES, SERVER_CHOICES } from './wizardActions.js';
|
|
44
|
-
import { captureLspName
|
|
45
|
+
import { captureLspName } from './wizardPrompts.js';
|
|
46
|
+
import { transitionMcpField, transitionProviderField } from './wizardTransition.js';
|
|
45
47
|
import { finishLspCustomResult, selectLspActionResult, selectLspPresetResult, selectLspServerResult } from './lspWizard.js';
|
|
46
48
|
import { finishMcpCustomResult, selectMcpActionResult, selectMcpPresetResult, selectMcpServerResult, setMcpServerKeyResult } from './mcpWizard.js';
|
|
47
49
|
import { providerActionResult, providerAppendModels, providerFinishAdd, providerRemove, providerRemoveModels, providerSetKey } from './providerWizard.js';
|
|
@@ -59,6 +61,16 @@ async function currentBranchName() {
|
|
|
59
61
|
return undefined;
|
|
60
62
|
}
|
|
61
63
|
}
|
|
64
|
+
/** Elapsed-time label for the busy indicator heartbeat, or '' when no turn is active. */
|
|
65
|
+
function busyElapsedLabel(startedAt) {
|
|
66
|
+
if (startedAt == null)
|
|
67
|
+
return '';
|
|
68
|
+
const elapsed = Date.now() - startedAt;
|
|
69
|
+
return elapsed > 0 ? formatElapsedTimeWhole(elapsed) : '';
|
|
70
|
+
}
|
|
71
|
+
function thinkingLabelForSettings(settings) {
|
|
72
|
+
return modelThinkingLabel(activeModel(settings)?.model);
|
|
73
|
+
}
|
|
62
74
|
function ChatScreen({ debug = false, version, continueSession = false, noSession = false }) {
|
|
63
75
|
const { exit } = useApp();
|
|
64
76
|
const { stdout } = useStdout();
|
|
@@ -71,7 +83,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
71
83
|
};
|
|
72
84
|
const withDisplayOrders = (next) => next.map(withDisplayOrder);
|
|
73
85
|
const [messages, setMessagesRaw] = useState([
|
|
74
|
-
{ role: 'system', text: 'Welcome to
|
|
86
|
+
{ role: 'system', text: 'Welcome to haze. Use /help for commands.', displayOrder: 0 }
|
|
75
87
|
]);
|
|
76
88
|
const setMessages = (updater) => {
|
|
77
89
|
setMessagesRaw(previous => withDisplayOrders(typeof updater === 'function' ? updater(previous) : updater));
|
|
@@ -86,13 +98,19 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
86
98
|
});
|
|
87
99
|
};
|
|
88
100
|
const [settings, setSettings] = useState({});
|
|
101
|
+
const [settingsError, setSettingsError] = useState();
|
|
89
102
|
const conversationRef = useRef([]);
|
|
90
103
|
const lastAssistantTextRef = useRef('');
|
|
91
104
|
const abortControllerRef = useRef(null);
|
|
92
105
|
const sessionRef = useRef(undefined);
|
|
106
|
+
const sessionRecorderRef = useRef(undefined);
|
|
107
|
+
if (!sessionRecorderRef.current)
|
|
108
|
+
sessionRecorderRef.current = createSessionRecorder(() => sessionRef.current);
|
|
93
109
|
const sessionStartRef = useRef(new Date());
|
|
94
110
|
const workStateRef = useRef(undefined);
|
|
95
111
|
const llmLogRef = useRef(undefined);
|
|
112
|
+
const persistenceWarningShownRef = useRef(false);
|
|
113
|
+
const skillErrorSignatureRef = useRef('');
|
|
96
114
|
const contextFileSignaturesRef = useRef(new Map());
|
|
97
115
|
const followUpQueueRef = useRef([]);
|
|
98
116
|
const [inputHistory, setInputHistory] = useState([]);
|
|
@@ -100,12 +118,15 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
100
118
|
const [contextFiles, setContextFiles] = useState([]);
|
|
101
119
|
const [mode, setMode] = useState('chat');
|
|
102
120
|
const [busy, setBusy] = useState(false);
|
|
103
|
-
const [busyLabel, setBusyLabel] = useState(
|
|
104
|
-
|
|
121
|
+
const [busyLabel, setBusyLabel] = useState(() => thinkingLabelForSettings(settings));
|
|
122
|
+
// Heartbeat for the busy indicator: ticks every second while haze is working
|
|
123
|
+
// so the developer always sees rolling activity (elapsed turn time) even when
|
|
124
|
+
// the model is thinking with no streamed output and no tool is running.
|
|
125
|
+
const turnStartedAtRef = useRef(undefined);
|
|
126
|
+
const [, setBusyTick] = useState(0);
|
|
105
127
|
const [visibleTasks, setVisibleTasks] = useState([]);
|
|
106
128
|
const [tasksExpanded, setTasksExpanded] = useState(false);
|
|
107
129
|
const [taskBarPadding, setTaskBarPadding] = useState(0);
|
|
108
|
-
const [, setSessionLabel] = useState();
|
|
109
130
|
const [tokenUsage, setTokenUsage] = useState({ ...EMPTY_TOKEN_USAGE });
|
|
110
131
|
const [queuedFollowUps, setQueuedFollowUps] = useState([]);
|
|
111
132
|
const [skills, setSkills] = useState([]);
|
|
@@ -119,17 +140,36 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
119
140
|
const [lspDraft, setLspDraft] = useState({});
|
|
120
141
|
const [selectedMcpName, setSelectedMcpName] = useState();
|
|
121
142
|
const [mcpDraft, setMcpDraft] = useState({});
|
|
143
|
+
// Wrap setBusy so the busy indicator knows when the turn started, and tick a
|
|
144
|
+
// heartbeat every second while busy so elapsed time keeps rolling. This keeps
|
|
145
|
+
// the UI visibly alive during long model thinking / blocked tool runs where
|
|
146
|
+
// otherwise no streamed output is produced (the "looks stuck" problem).
|
|
147
|
+
const setBusyWithHeartbeat = (nextBusy) => {
|
|
148
|
+
if (nextBusy && !busy)
|
|
149
|
+
turnStartedAtRef.current = Date.now();
|
|
150
|
+
if (!nextBusy)
|
|
151
|
+
turnStartedAtRef.current = undefined;
|
|
152
|
+
setBusy(nextBusy);
|
|
153
|
+
};
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!busy)
|
|
156
|
+
return;
|
|
157
|
+
const heartbeat = setInterval(() => setBusyTick(tick => tick + 1), 1000);
|
|
158
|
+
return () => clearInterval(heartbeat);
|
|
159
|
+
}, [busy]);
|
|
122
160
|
useEffect(() => {
|
|
123
161
|
Promise.all([
|
|
124
|
-
readSettings().
|
|
162
|
+
readSettings().then(value => ({ value, error: undefined })).catch(error => ({ value: {}, error: error instanceof Error ? error.message : String(error) })),
|
|
125
163
|
currentBranchName().catch(() => undefined),
|
|
126
164
|
readContextFiles().catch(() => []),
|
|
127
|
-
]).then(([
|
|
165
|
+
]).then(([settingsResult, branch, files]) => {
|
|
166
|
+
const next = settingsResult.value;
|
|
128
167
|
setSettings(next);
|
|
168
|
+
setSettingsError(settingsResult.error);
|
|
129
169
|
setBranchName(branch);
|
|
130
170
|
setContextFiles(files);
|
|
131
171
|
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)}` }]);
|
|
172
|
+
setMessages(m => [...m, { role: 'system', text: settingsResult.error ? settingsResult.error : `${startupProviderInfo(next)}\n\n${startupContextInfo(files)}` }]);
|
|
133
173
|
}).catch(() => undefined);
|
|
134
174
|
initializeSession().catch(error => {
|
|
135
175
|
const text = error instanceof Error ? error.message : String(error);
|
|
@@ -142,7 +182,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
142
182
|
checkForUpdate({ currentVersion: version, packageName: '@denizokcu/haze' })
|
|
143
183
|
.then(result => {
|
|
144
184
|
if (result?.isOutdated) {
|
|
145
|
-
setMessages(m => [...m, { role: 'system', text: `A new version of
|
|
185
|
+
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
186
|
}
|
|
147
187
|
})
|
|
148
188
|
.catch(() => undefined);
|
|
@@ -159,6 +199,11 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
159
199
|
const registry = await loadSkillRegistry();
|
|
160
200
|
const nextSkills = [...registry.skills.values()];
|
|
161
201
|
setSkills(nextSkills);
|
|
202
|
+
const errorSignature = registry.errors.map(error => `${error.directory}: ${error.message}`).join('\n');
|
|
203
|
+
if (errorSignature && errorSignature !== skillErrorSignatureRef.current) {
|
|
204
|
+
setMessages(messages => [...messages, { role: 'system', text: `Invalid skills were isolated:\n${errorSignature}` }]);
|
|
205
|
+
}
|
|
206
|
+
skillErrorSignatureRef.current = errorSignature;
|
|
162
207
|
return nextSkills;
|
|
163
208
|
}
|
|
164
209
|
function skillInvocation(value) {
|
|
@@ -177,36 +222,41 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
177
222
|
return;
|
|
178
223
|
setDebugLogs(current => [...current.slice(-7), line]);
|
|
179
224
|
}
|
|
225
|
+
function showPersistenceWarning(error) {
|
|
226
|
+
if (persistenceWarningShownRef.current)
|
|
227
|
+
return;
|
|
228
|
+
persistenceWarningShownRef.current = true;
|
|
229
|
+
const text = error instanceof Error ? error.message : String(error);
|
|
230
|
+
setMessages(messages => [...messages, { role: 'system', text: `Persistence warning: ${text}` }]);
|
|
231
|
+
}
|
|
180
232
|
async function startNewLog() {
|
|
181
233
|
if (!debug)
|
|
182
234
|
return undefined;
|
|
183
235
|
if (llmLogRef.current) {
|
|
184
|
-
await endLlmLog(llmLogRef.current).catch(
|
|
236
|
+
await endLlmLog(llmLogRef.current).catch(showPersistenceWarning);
|
|
185
237
|
}
|
|
186
238
|
const log = await createLlmLog();
|
|
187
239
|
llmLogRef.current = log;
|
|
188
240
|
return log;
|
|
189
241
|
}
|
|
190
242
|
async function startNewSession(message = 'Started a new session.') {
|
|
243
|
+
await sessionRecorderRef.current?.flush().catch(showPersistenceWarning);
|
|
191
244
|
clearToolOutputs();
|
|
192
245
|
contextFileSignaturesRef.current = new Map(contextFiles.flatMap(file => file.signature ? [[file.path, file.signature]] : []));
|
|
193
246
|
workStateRef.current = undefined;
|
|
194
247
|
sessionStartRef.current = new Date();
|
|
195
248
|
if (noSession) {
|
|
196
249
|
sessionRef.current = undefined;
|
|
197
|
-
setSessionLabel('session off');
|
|
198
250
|
return;
|
|
199
251
|
}
|
|
200
252
|
const session = await createSession({ hazeVersion: version });
|
|
201
253
|
sessionRef.current = session;
|
|
202
254
|
setTokenUsage({ ...EMPTY_TOKEN_USAGE });
|
|
203
255
|
await startNewLog();
|
|
204
|
-
setSessionLabel(session.id);
|
|
205
256
|
setMessages(m => [...m, { role: 'system', text: `${message}\nSession saved: ${session.file}` }]);
|
|
206
257
|
}
|
|
207
258
|
async function initializeSession() {
|
|
208
259
|
if (noSession) {
|
|
209
|
-
setSessionLabel('session off');
|
|
210
260
|
return;
|
|
211
261
|
}
|
|
212
262
|
if (continueSession) {
|
|
@@ -216,7 +266,6 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
216
266
|
sessionRef.current = session;
|
|
217
267
|
sessionStartRef.current = new Date();
|
|
218
268
|
conversationRef.current = conversation;
|
|
219
|
-
setSessionLabel(session.id);
|
|
220
269
|
setLiveMessagesState(() => []);
|
|
221
270
|
const restoredMessages = displayMessagesFromConversation(conversation);
|
|
222
271
|
setTokenUsage({ ...EMPTY_TOKEN_USAGE, messages: estimateConversationTokens(restoredMessages).input, outputEstimate: estimateConversationTokens(restoredMessages).output });
|
|
@@ -232,7 +281,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
232
281
|
}
|
|
233
282
|
await startNewSession(continueSession ? 'No previous session found. Started a new session.' : 'Started a new session.');
|
|
234
283
|
}
|
|
235
|
-
function clearConversation() {
|
|
284
|
+
async function clearConversation() {
|
|
236
285
|
clearToolOutputs();
|
|
237
286
|
conversationRef.current = [];
|
|
238
287
|
lastAssistantTextRef.current = '';
|
|
@@ -240,10 +289,9 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
240
289
|
workStateRef.current = undefined;
|
|
241
290
|
setLiveMessagesState(() => []);
|
|
242
291
|
setMessages([{ role: 'system', text: 'Cleared. The void is productive.' }]);
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
void appendSessionEntry(session, { type: 'event', at: new Date().toISOString(), name: 'clear', text: 'Conversation cleared' }).catch(() => undefined);
|
|
292
|
+
sessionRecorderRef.current?.recordNamedEvent('clear', 'Conversation cleared');
|
|
293
|
+
await sessionRecorderRef.current?.flush().catch(showPersistenceWarning);
|
|
294
|
+
await startNewLog().catch(showPersistenceWarning);
|
|
247
295
|
}
|
|
248
296
|
function compactConversation(instructions) {
|
|
249
297
|
const result = compactModelMessages(conversationRef.current, { instructions, tokenBudget: 40_000, workState: workStateRef.current });
|
|
@@ -252,15 +300,13 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
252
300
|
return false;
|
|
253
301
|
}
|
|
254
302
|
conversationRef.current = result.messages;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
void appendSessionEntry(session, { type: 'event', at: new Date().toISOString(), name: 'compact', text: `Compacted ${result.olderCount} messages; kept ${result.keptCount}.` }).catch(() => undefined);
|
|
258
|
-
void appendSessionEntry(session, { type: 'conversation_snapshot', at: new Date().toISOString(), messages: result.messages }).catch(() => undefined);
|
|
259
|
-
}
|
|
303
|
+
sessionRecorderRef.current?.recordNamedEvent('compact', `Compacted ${result.olderCount} messages; kept ${result.keptCount}.`);
|
|
304
|
+
sessionRecorderRef.current?.recordConversation(result.messages);
|
|
260
305
|
setMessages(m => [...m, { role: 'system', text: `Compacted context: summarized ${result.olderCount} older model messages and kept the last ${result.keptCount}.` }]);
|
|
261
306
|
return true;
|
|
262
307
|
}
|
|
263
308
|
async function resumeLatestSession() {
|
|
309
|
+
await sessionRecorderRef.current?.flush().catch(showPersistenceWarning);
|
|
264
310
|
const session = await latestSession();
|
|
265
311
|
if (!session) {
|
|
266
312
|
setMessages(m => [...m, { role: 'system', text: 'No previous session found for this workspace.' }]);
|
|
@@ -275,7 +321,6 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
275
321
|
sessionRef.current = session;
|
|
276
322
|
conversationRef.current = conversation;
|
|
277
323
|
workStateRef.current = workState;
|
|
278
|
-
setSessionLabel(session.id);
|
|
279
324
|
setTokenUsage({ ...EMPTY_TOKEN_USAGE });
|
|
280
325
|
setLiveMessagesState(() => []);
|
|
281
326
|
setMessages([{ role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...displayMessagesFromConversation(conversation)]);
|
|
@@ -323,7 +368,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
323
368
|
setQueuedFollowUps([]);
|
|
324
369
|
setMessages(m => [...m, { role: 'system', text: 'Cleared queued follow-ups after interrupt.' }]);
|
|
325
370
|
}
|
|
326
|
-
|
|
371
|
+
setBusyWithHeartbeat(false);
|
|
327
372
|
}
|
|
328
373
|
function queueFollowUp(value) {
|
|
329
374
|
const trimmed = value.trim();
|
|
@@ -565,8 +610,8 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
565
610
|
setMode(result.mode);
|
|
566
611
|
showWizardMessage(result.message);
|
|
567
612
|
}
|
|
568
|
-
async function finishMcpCustom(keyValue) {
|
|
569
|
-
const result = finishMcpCustomResult(settings,
|
|
613
|
+
async function finishMcpCustom(keyValue, draft = mcpDraft) {
|
|
614
|
+
const result = finishMcpCustomResult(settings, draft, keyValue);
|
|
570
615
|
if (result.settingsPatch)
|
|
571
616
|
setSettings(await updateSettings(result.settingsPatch));
|
|
572
617
|
if (result.clearDraft)
|
|
@@ -647,7 +692,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
647
692
|
const name = result.draftName;
|
|
648
693
|
const description = result.description;
|
|
649
694
|
setBusyLabel(result.busyLabel ?? 'Creating skill');
|
|
650
|
-
|
|
695
|
+
setBusyWithHeartbeat(true);
|
|
651
696
|
try {
|
|
652
697
|
const created = await createSkill({ name, description });
|
|
653
698
|
setMessages(m => [...m, { role: 'system', text: skillCreationMessage(created.name, created.file) }]);
|
|
@@ -657,17 +702,62 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
657
702
|
setMessages(m => [...m, { role: 'system', text: skillCreationFailure(error) }]);
|
|
658
703
|
}
|
|
659
704
|
finally {
|
|
660
|
-
|
|
661
|
-
setBusyLabel(
|
|
705
|
+
setBusyWithHeartbeat(false);
|
|
706
|
+
setBusyLabel(thinkingLabelForSettings(settings));
|
|
662
707
|
}
|
|
663
708
|
}
|
|
664
709
|
}
|
|
665
710
|
async function submit(value) {
|
|
711
|
+
if (settingsError) {
|
|
712
|
+
try {
|
|
713
|
+
const repaired = await readSettings();
|
|
714
|
+
setSettings(repaired);
|
|
715
|
+
setSettingsError(undefined);
|
|
716
|
+
}
|
|
717
|
+
catch (error) {
|
|
718
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
719
|
+
setSettingsError(message);
|
|
720
|
+
if (!/^\/(?:settings\s+(?:open|edit)|help|exit|quit)\b/i.test(value.trim())) {
|
|
721
|
+
setMessages(messages => [...messages, { role: 'system', text: `${message}\nRepair settings, then retry. /settings open, /help, and /exit remain available.` }]);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
666
726
|
if (busy) {
|
|
667
727
|
if (mode === 'chat')
|
|
668
728
|
queueFollowUp(value);
|
|
669
729
|
return;
|
|
670
730
|
}
|
|
731
|
+
const providerEffects = transitionProviderField({ mode, value, settings });
|
|
732
|
+
if (providerEffects) {
|
|
733
|
+
for (const effect of providerEffects) {
|
|
734
|
+
if (effect.type === 'message')
|
|
735
|
+
showWizardMessage(effect.text);
|
|
736
|
+
else if (effect.type === 'mode')
|
|
737
|
+
setMode(effect.mode);
|
|
738
|
+
else if (effect.type === 'provider-draft') {
|
|
739
|
+
if (effect.replace)
|
|
740
|
+
setProviderDraft(effect.patch);
|
|
741
|
+
else
|
|
742
|
+
setProviderDraft(draft => ({ ...draft, ...effect.patch }));
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
const mcpEffects = transitionMcpField({ mode, value, settings, draft: mcpDraft });
|
|
748
|
+
if (mcpEffects) {
|
|
749
|
+
for (const effect of mcpEffects) {
|
|
750
|
+
if (effect.type === 'message')
|
|
751
|
+
showWizardMessage(effect.text);
|
|
752
|
+
else if (effect.type === 'mode')
|
|
753
|
+
setMode(effect.mode);
|
|
754
|
+
else if (effect.type === 'mcp-draft')
|
|
755
|
+
setMcpDraft(draft => ({ ...draft, ...effect.patch }));
|
|
756
|
+
else if (effect.type === 'finish-mcp-stdio')
|
|
757
|
+
await finishMcpCustom(undefined, effect.draft);
|
|
758
|
+
}
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
671
761
|
if (mode === 'skills') {
|
|
672
762
|
await selectSkill(value);
|
|
673
763
|
return;
|
|
@@ -718,38 +808,6 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
718
808
|
await selectModel(value);
|
|
719
809
|
return;
|
|
720
810
|
}
|
|
721
|
-
if (mode === 'providerAddName') {
|
|
722
|
-
const result = captureProviderName(settings, value);
|
|
723
|
-
if (result.message) {
|
|
724
|
-
showWizardMessage(result.message);
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
if (result.draft)
|
|
728
|
-
setProviderDraft({ name: result.draft.name });
|
|
729
|
-
if (result.nextMode)
|
|
730
|
-
setMode(result.nextMode);
|
|
731
|
-
showWizardMessage(result.systemMessage);
|
|
732
|
-
return;
|
|
733
|
-
}
|
|
734
|
-
if (mode === 'providerAddUrl') {
|
|
735
|
-
const result = captureProviderUrl(value);
|
|
736
|
-
if (result.message) {
|
|
737
|
-
showWizardMessage(result.message);
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (result.draft)
|
|
741
|
-
setProviderDraft(draft => ({ ...draft, ...result.draft }));
|
|
742
|
-
if (result.nextMode)
|
|
743
|
-
setMode(result.nextMode);
|
|
744
|
-
showWizardMessage(result.systemMessage);
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
if (mode === 'providerAddKey') {
|
|
748
|
-
setProviderDraft(draft => ({ ...draft, ...(value.trim() ? { key: value.trim() } : {}) }));
|
|
749
|
-
setMode('providerAddModels');
|
|
750
|
-
setMessages(m => [...m, { role: 'system', text: 'Comma-separated model names? Example: llama3.1, qwen2.5-coder, gpt-4o' }]);
|
|
751
|
-
return;
|
|
752
|
-
}
|
|
753
811
|
if (mode === 'providerAddModels') {
|
|
754
812
|
await finishProviderAdd(value);
|
|
755
813
|
return;
|
|
@@ -873,58 +931,6 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
873
931
|
await selectMcpPreset(value);
|
|
874
932
|
return;
|
|
875
933
|
}
|
|
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
934
|
if (mode === 'mcpAddKey') {
|
|
929
935
|
await finishMcpCustom(value);
|
|
930
936
|
return;
|
|
@@ -997,8 +1003,12 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
997
1003
|
setMessages(m => [...m, { role: 'system', text: `Command failed: ${text}` }]);
|
|
998
1004
|
return;
|
|
999
1005
|
}
|
|
1000
|
-
if (result === 'exit')
|
|
1006
|
+
if (result === 'exit') {
|
|
1007
|
+
await sessionRecorderRef.current?.flush().catch(showPersistenceWarning);
|
|
1008
|
+
if (llmLogRef.current)
|
|
1009
|
+
await endLlmLog(llmLogRef.current).catch(showPersistenceWarning);
|
|
1001
1010
|
return exit();
|
|
1011
|
+
}
|
|
1002
1012
|
if (result === 'handled') {
|
|
1003
1013
|
if (value === '/clear') {
|
|
1004
1014
|
loadTasksFromStore().then(t => { setVisibleTasks(t); setTaskBarPadding(0); }).catch(() => undefined);
|
|
@@ -1028,7 +1038,7 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
1028
1038
|
}
|
|
1029
1039
|
}
|
|
1030
1040
|
async function runSingleAgentTurn(value, displayValue) {
|
|
1031
|
-
const sessionRecorder =
|
|
1041
|
+
const sessionRecorder = sessionRecorderRef.current;
|
|
1032
1042
|
const finalizeMessage = (msg) => {
|
|
1033
1043
|
if (msg.hidden)
|
|
1034
1044
|
return;
|
|
@@ -1063,14 +1073,13 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
1063
1073
|
conversationRef.current = msgs;
|
|
1064
1074
|
sessionRecorder.recordConversation(msgs);
|
|
1065
1075
|
},
|
|
1066
|
-
setBusy,
|
|
1076
|
+
setBusy: setBusyWithHeartbeat,
|
|
1067
1077
|
setBusyLabel,
|
|
1068
1078
|
debugLog,
|
|
1069
1079
|
getConversation: () => conversationRef.current,
|
|
1070
1080
|
getLastAssistantText: () => lastAssistantTextRef.current,
|
|
1071
1081
|
setLastAssistantText: text => { lastAssistantTextRef.current = text; },
|
|
1072
1082
|
setAbortController: controller => { abortControllerRef.current = controller; },
|
|
1073
|
-
setGoalStatus: setActiveGoalStatus,
|
|
1074
1083
|
setWorkState: state => {
|
|
1075
1084
|
workStateRef.current = state;
|
|
1076
1085
|
sessionRecorder.recordWorkState(state);
|
|
@@ -1086,6 +1095,8 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
1086
1095
|
contextFileSignatures: contextFileSignaturesRef.current,
|
|
1087
1096
|
log: llmLogRef.current,
|
|
1088
1097
|
}, 0, false, false, { start: sessionStartRef.current, cwd: process.cwd() });
|
|
1098
|
+
await sessionRecorder.flush().catch(showPersistenceWarning);
|
|
1099
|
+
await llmLogRef.current?.writer?.flush().catch(showPersistenceWarning);
|
|
1089
1100
|
}
|
|
1090
1101
|
const visible = messages.filter(message => !message.hidden);
|
|
1091
1102
|
const activeLiveMessages = liveMessages.filter(message => !message.hidden);
|
|
@@ -1098,12 +1109,12 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
1098
1109
|
const headerSubtitle = [
|
|
1099
1110
|
'A minimal LLM harness for growing your own workflows while you work.',
|
|
1100
1111
|
'',
|
|
1101
|
-
'Start with simple chat, then teach
|
|
1112
|
+
'Start with simple chat, then teach haze your habits with skills:',
|
|
1102
1113
|
'/skills — add, enable/disable, validate, or remove Markdown skills.',
|
|
1103
1114
|
'',
|
|
1104
1115
|
'The most adaptive workflow is the one you shape as you go.',
|
|
1105
1116
|
'',
|
|
1106
|
-
'Guardrails are light:
|
|
1117
|
+
'Guardrails are light: haze lets the LLM work from the terminal almost like you,',
|
|
1107
1118
|
'while trying to stay scoped to this project.',
|
|
1108
1119
|
].join('\n');
|
|
1109
1120
|
const workspaceLabel = `${compactHomePath(process.cwd())}${branchName ? ` (${branchName})` : ''}`;
|
|
@@ -1125,9 +1136,10 @@ function ChatScreen({ debug = false, version, continueSession = false, noSession
|
|
|
1125
1136
|
{ kind: 'header', key: `header-${activeModelName}`, subtitle: headerSubtitle },
|
|
1126
1137
|
...transcriptItems.map(item => ({ kind: 'message', ...item })),
|
|
1127
1138
|
];
|
|
1139
|
+
const busyElapsed = busyElapsedLabel(turnStartedAtRef.current);
|
|
1128
1140
|
return _jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: staticItems, children: item => item.kind === 'header'
|
|
1129
1141
|
? _jsx(Header, { subtitle: item.subtitle, version: version }, item.key)
|
|
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: () => {
|
|
1142
|
+
: _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, busyElapsed ? _jsxs(Text, { color: theme.muted, dimColor: true, children: [" \u00B7 ", busyElapsed] }) : null] }), _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: () => {
|
|
1131
1143
|
if (!tasksExpanded) {
|
|
1132
1144
|
setTaskBarPadding(0);
|
|
1133
1145
|
setTasksExpanded(true);
|
|
@@ -40,5 +40,5 @@ const PLACEHOLDERS = {
|
|
|
40
40
|
mcpConfirmRemove: 'Type "yes" to confirm',
|
|
41
41
|
};
|
|
42
42
|
export function placeholderForMode(mode, busy) {
|
|
43
|
-
return PLACEHOLDERS[mode] ?? (busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask
|
|
43
|
+
return PLACEHOLDERS[mode] ?? (busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask haze to help build your app');
|
|
44
44
|
}
|
|
@@ -17,8 +17,8 @@ export const COMMAND_HELP_ENTRIES = [
|
|
|
17
17
|
{ usage: '/logs <id>', description: 'Show summary of a specific log: entry counts by type, total tokens, tool calls.' },
|
|
18
18
|
{ usage: '/compact [instructions]', description: 'Summarize older model context and keep recent messages.' },
|
|
19
19
|
{ usage: '/clear', description: 'Clear the current chat conversation history.' },
|
|
20
|
-
{ usage: '/exit', description: 'Exit
|
|
21
|
-
{ usage: '/quit', description: 'Exit
|
|
20
|
+
{ usage: '/exit', description: 'Exit haze.' },
|
|
21
|
+
{ usage: '/quit', description: 'Exit haze.' },
|
|
22
22
|
];
|
|
23
23
|
export function formatCommandHelp(entries = COMMAND_HELP_ENTRIES) {
|
|
24
24
|
return ['Commands:', ...entries.flatMap(entry => [entry.usage, ` ${entry.description}`])].join('\n');
|
|
@@ -7,7 +7,7 @@ export type CommandContext = {
|
|
|
7
7
|
setMode: (mode: Mode) => void;
|
|
8
8
|
setModelProviderFilter?: (providerName: string | undefined) => void;
|
|
9
9
|
addSystemMessage: (text: string) => void;
|
|
10
|
-
clearConversation: () => void
|
|
10
|
+
clearConversation: () => void | Promise<void>;
|
|
11
11
|
newSession?: () => Promise<void>;
|
|
12
12
|
resumeSession?: () => Promise<void>;
|
|
13
13
|
sessionInfo?: () => string;
|
|
@@ -45,7 +45,7 @@ const SLASH_COMMANDS = [
|
|
|
45
45
|
ctx.compactConversation(args || undefined);
|
|
46
46
|
else
|
|
47
47
|
ctx.addSystemMessage('Compaction is unavailable.'); return HANDLED; } },
|
|
48
|
-
{ match: exact('/clear'), run: async (_args, ctx) => { ctx.clearConversation(); await clearTasks(); ctx.addSystemMessage('Cleared. The void is productive.'); return HANDLED; } },
|
|
48
|
+
{ match: exact('/clear'), run: async (_args, ctx) => { await ctx.clearConversation(); await clearTasks(); ctx.addSystemMessage('Cleared. The void is productive.'); return HANDLED; } },
|
|
49
49
|
{ match: exactOrArgs('/logs'), run: async (args, ctx) => await handleLogsCommand(args, ctx) },
|
|
50
50
|
{ match: exactOrArgs('/lsp'), run: (_args, ctx) => { ctx.setMode('lsp'); ctx.addSystemMessage('Choose an LSP server to enable, disable, or remove it. Choose "add server" to add one from presets (e.g. typescript) or enter a custom command.'); return HANDLED; } },
|
|
51
51
|
{ match: exactOrArgs('/mcp'), run: (_args, ctx) => { ctx.setMode('mcp'); ctx.addSystemMessage('Choose an MCP server to enable, disable, remove, or set a key for it. Choose "add server" to add one from presets (e.g. context7) or enter custom details.'); return HANDLED; } },
|
|
@@ -5,6 +5,12 @@ export declare function toolResultSummary(event: {
|
|
|
5
5
|
output?: unknown;
|
|
6
6
|
error?: unknown;
|
|
7
7
|
}): string;
|
|
8
|
+
/**
|
|
9
|
+
* A short, human label for the live busy indicator while a tool is running,
|
|
10
|
+
* e.g. "Running command", "Reading src/foo.ts", "Searching".
|
|
11
|
+
* Lets the developer see *what* is happening, not just that something is.
|
|
12
|
+
*/
|
|
13
|
+
export declare function busyToolLabel(toolName: string, input: unknown): string;
|
|
8
14
|
export declare function formatSeconds(milliseconds: number): string;
|
|
9
15
|
export declare function formatElapsedTime(milliseconds: number): string;
|
|
10
16
|
export declare function formatElapsedTimeWhole(milliseconds: number): string;
|
|
@@ -59,14 +59,14 @@ export function toolCallSummary(toolName, input) {
|
|
|
59
59
|
return `${toolName} ${compact(input)}`;
|
|
60
60
|
}
|
|
61
61
|
export function toolResultSummary(event) {
|
|
62
|
-
if (!event.success)
|
|
63
|
-
return `failed: ${compact(event.error)}`;
|
|
64
62
|
const output = event.output;
|
|
63
|
+
if (!event.success)
|
|
64
|
+
return `failed: ${compact(event.error ?? output?.error ?? event.output)}`;
|
|
65
65
|
if (output?.duplicateSkipped === true)
|
|
66
66
|
return 'skipped duplicate';
|
|
67
67
|
if (typeof output?.totalMatches === 'number') {
|
|
68
68
|
const count = output.totalMatches;
|
|
69
|
-
return count === 0 ? 'no matches' : `${count} match${count === 1 ? '' : 'es'}`;
|
|
69
|
+
return count === 0 ? 'no matches' : `${output.matchCountIsLowerBound === true ? 'at least ' : ''}${count} match${count === 1 ? '' : 'es'}`;
|
|
70
70
|
}
|
|
71
71
|
if (typeof output?.validationSummary === 'object' && output.validationSummary != null && 'summaryText' in output.validationSummary) {
|
|
72
72
|
const summary = output.validationSummary;
|
|
@@ -113,6 +113,44 @@ export function toolResultSummary(event) {
|
|
|
113
113
|
}
|
|
114
114
|
return 'completed';
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* A short, human label for the live busy indicator while a tool is running,
|
|
118
|
+
* e.g. "Running command", "Reading src/foo.ts", "Searching".
|
|
119
|
+
* Lets the developer see *what* is happening, not just that something is.
|
|
120
|
+
*/
|
|
121
|
+
export function busyToolLabel(toolName, input) {
|
|
122
|
+
const data = input;
|
|
123
|
+
const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
|
|
124
|
+
switch (toolName) {
|
|
125
|
+
case 'bash':
|
|
126
|
+
return 'Running command';
|
|
127
|
+
case 'grep':
|
|
128
|
+
return 'Searching';
|
|
129
|
+
case 'listFiles':
|
|
130
|
+
return 'Listing files';
|
|
131
|
+
case 'readFile':
|
|
132
|
+
return pathLabel ? `Reading ${pathLabel}` : 'Reading file';
|
|
133
|
+
case 'writeFile':
|
|
134
|
+
return pathLabel ? `Writing ${pathLabel}` : 'Writing file';
|
|
135
|
+
case 'editFile':
|
|
136
|
+
case 'replaceLines':
|
|
137
|
+
return pathLabel ? `Editing ${pathLabel}` : 'Editing file';
|
|
138
|
+
case 'fetch':
|
|
139
|
+
return 'Fetching URL';
|
|
140
|
+
case 'subagent':
|
|
141
|
+
return 'Running subagent';
|
|
142
|
+
case 'writeTasks':
|
|
143
|
+
return 'Updating tasks';
|
|
144
|
+
case 'skill':
|
|
145
|
+
return 'Loading skill';
|
|
146
|
+
default:
|
|
147
|
+
if (toolName.startsWith('lsp'))
|
|
148
|
+
return 'Querying LSP';
|
|
149
|
+
if (toolName.startsWith('mcp'))
|
|
150
|
+
return 'Running MCP tool';
|
|
151
|
+
return `Running ${toolName}`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
116
154
|
export function formatSeconds(milliseconds) {
|
|
117
155
|
return `${(milliseconds / 1000).toFixed(1)}s`;
|
|
118
156
|
}
|