@denizokcu/haze 0.11.0 → 1.0.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 +23 -0
- package/README.md +23 -14
- package/SECURITY.md +3 -3
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/chatMetrics.d.ts +2 -2
- package/dist/cli/chat/chatMetrics.js +1 -1
- package/dist/cli/chat/fileMentionSuggestions.js +1 -1
- package/dist/cli/chat/inputSuggestions.d.ts +8 -16
- package/dist/cli/chat/inputSuggestions.js +9 -41
- package/dist/cli/chat/messages.d.ts +0 -2
- package/dist/cli/chat/messages.js +2 -2
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -1
- package/dist/cli/chat/turnState.d.ts +1 -1
- package/dist/cli/chat/wizardDispatch.d.ts +90 -28
- package/dist/cli/chat/wizardDispatch.js +250 -133
- package/dist/cli/commands/chat.js +14 -72
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +6 -25
- package/dist/cli/commands/providerWizard.js +2 -3
- package/dist/cli/commands/runCommand.js +1 -1
- package/dist/cli/commands/serverWizard.d.ts +34 -0
- package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
- package/dist/cli/commands/skillsWizard.d.ts +41 -0
- package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
- package/dist/cli/commands/streaming/abortCause.d.ts +2 -1
- package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
- package/dist/cli/commands/streaming/agentAttempt.js +79 -0
- package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
- package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
- package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
- package/dist/cli/commands/streaming/attemptSetup.js +167 -0
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
- package/dist/cli/commands/streaming/goalCheckpoint.js +2 -2
- package/dist/cli/commands/streaming/goalSupervisor.js +9 -6
- package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
- package/dist/cli/commands/streaming/stallRecovery.js +105 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
- package/dist/cli/commands/streaming/streamLoop.js +448 -0
- package/dist/cli/commands/streaming/toolCallRecovery.d.ts +14 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +56 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -1
- package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -0
- package/dist/cli/commands/streaming.d.ts +14 -25
- package/dist/cli/commands/streaming.js +43 -754
- package/dist/cli/commands/wizardFlow.d.ts +334 -0
- package/dist/cli/commands/wizardFlow.js +377 -0
- package/dist/cli/contextReport.js +3 -0
- package/dist/cli/index.js +1 -1
- package/dist/config/contextFiles.js +9 -3
- package/dist/config/inputHistory.d.ts +0 -1
- package/dist/config/inputHistory.js +1 -1
- package/dist/config/modelDiscovery.d.ts +0 -15
- package/dist/config/modelDiscovery.js +1 -1
- package/dist/config/settings.d.ts +7 -0
- package/dist/config/settings.js +3 -0
- package/dist/config/skillSettings.js +4 -4
- package/dist/config/updateCheck.d.ts +0 -1
- package/dist/config/updateCheck.js +1 -1
- package/dist/core/agent/budgets.d.ts +63 -1
- package/dist/core/agent/budgets.js +84 -1
- package/dist/core/agent/compaction.js +1 -1
- package/dist/core/agent/completionController.d.ts +7 -13
- package/dist/core/agent/completionController.js +17 -8
- package/dist/core/agent/contextBudget.d.ts +0 -4
- package/dist/core/agent/contextBudget.js +3 -3
- package/dist/core/agent/errors.d.ts +0 -1
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/events.d.ts +5 -1
- package/dist/core/{goal/completionPolicy.d.ts → agent/goalPolicy.d.ts} +18 -0
- package/dist/core/agent/goalPolicy.js +106 -0
- package/dist/core/agent/requestAssembly.d.ts +2 -2
- package/dist/core/agent/requestAssembly.js +16 -4
- package/dist/core/agent/toolCapabilities.d.ts +2 -2
- package/dist/core/agent/toolCapabilities.js +5 -5
- package/dist/core/agent/toolOutputStore.js +1 -1
- package/dist/core/agent/toolResults.js +1 -1
- package/dist/core/agent/workState.d.ts +6 -3
- package/dist/core/agent/workState.js +62 -7
- package/dist/core/attachments/imageAttachments.js +90 -42
- package/dist/core/deadline.d.ts +0 -6
- package/dist/core/deadline.js +1 -1
- package/dist/core/io/boundedRead.js +1 -1
- package/dist/core/limits.d.ts +51 -0
- package/dist/core/limits.js +51 -0
- package/dist/core/log/llmLog.js +1 -1
- package/dist/core/process/backgroundRegistry.d.ts +2 -3
- package/dist/core/process/backgroundRegistry.js +10 -6
- package/dist/core/process/userShell.d.ts +16 -0
- package/dist/core/process/userShell.js +59 -0
- package/dist/core/safety/shellClassifier.d.ts +11 -0
- package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
- package/dist/core/safety/urlGuard.d.ts +1 -1
- package/dist/core/session/sessionSlimming.d.ts +0 -3
- package/dist/core/session/sessionSlimming.js +2 -3
- package/dist/core/session/sessionStore.d.ts +1 -0
- package/dist/core/session/sessionStore.js +39 -20
- package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
- package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
- package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
- package/dist/core/shellOutput/registry.d.ts +2 -0
- package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
- package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
- package/dist/core/subagent/contracts.d.ts +2 -14
- package/dist/core/subagent/contracts.js +3 -3
- package/dist/core/subagent/executionProfiles.js +2 -2
- package/dist/core/subagent/subagentRunner.js +3 -4
- package/dist/core/toolOutput/reduction.d.ts +0 -12
- package/dist/core/toolOutput/reduction.js +1 -1
- package/dist/core/validation/outputParser.d.ts +2 -2
- package/dist/llm/client.js +5 -1
- package/dist/llm/hazeTools.d.ts +139 -124
- package/dist/llm/hazeTools.js +14 -11
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp/client.d.ts +45 -0
- package/dist/llm/lsp/client.js +195 -0
- package/dist/llm/lsp/pool.d.ts +23 -0
- package/dist/llm/lsp/pool.js +86 -0
- package/dist/llm/lsp/protocol.d.ts +64 -0
- package/dist/llm/lsp/protocol.js +128 -0
- package/dist/llm/lsp/requests.d.ts +94 -0
- package/dist/llm/lsp/requests.js +119 -0
- package/dist/llm/lspTools.d.ts +3824 -570
- package/dist/llm/lspTools.js +65 -1
- package/dist/llm/openaiCodex.d.ts +0 -2
- package/dist/llm/openaiCodex.js +0 -4
- package/dist/llm/openaiCodexOAuth.d.ts +0 -3
- package/dist/llm/openaiCodexOAuth.js +6 -3
- package/dist/llm/requestContext.d.ts +5 -1
- package/dist/llm/requestContext.js +25 -2
- package/dist/llm/systemPrompt.d.ts +1 -0
- package/dist/llm/systemPrompt.js +13 -6
- package/dist/llm/toolResultTypes.d.ts +0 -14
- package/dist/llm/toolResultTypes.js +1 -4
- package/dist/llm/tools/editMatch.d.ts +0 -9
- package/dist/llm/tools/editMatch.js +1 -1
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +4 -2
- package/dist/llm/tools/fileToolShared.js +9 -5
- package/dist/llm/tools/gitIgnore.d.ts +25 -32
- package/dist/llm/tools/gitIgnore.js +216 -98
- package/dist/llm/tools/grepParse.d.ts +2 -1
- package/dist/llm/tools/grepRunner.d.ts +1 -1
- package/dist/llm/tools/grepRunner.js +2 -2
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -3
- package/dist/llm/tools/processTool.d.ts +16 -16
- package/dist/llm/tools/processTool.js +1 -1
- package/dist/llm/tools/readRecovery.d.ts +0 -2
- package/dist/llm/tools/readRecovery.js +2 -2
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
- package/dist/llm/tools/{bashTool.js → shellTool.js} +15 -14
- package/dist/llm/tools/toolContext.js +5 -5
- package/dist/llm/tools/workspaceFile.d.ts +0 -1
- package/dist/llm/tools/workspaceFile.js +1 -6
- package/dist/llm/webFetch.d.ts +1 -1
- package/dist/skills/SkillLoader.d.ts +1 -11
- package/dist/skills/SkillLoader.js +1 -2
- package/dist/skills/types.d.ts +2 -1
- package/dist/utils/buildInfo.d.ts +6 -13
- package/dist/utils/buildInfo.js +6 -15
- package/dist/utils/fs.d.ts +7 -5
- package/dist/utils/fs.js +5 -2
- package/dist/utils/path.d.ts +0 -1
- package/dist/utils/path.js +1 -1
- package/package.json +6 -4
- package/dist/cli/commands/lspWizard.d.ts +0 -14
- package/dist/cli/commands/lspWizard.js +0 -44
- package/dist/cli/commands/mcpWizard.d.ts +0 -15
- package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
- package/dist/cli/commands/skillConfirmRemove.js +0 -20
- package/dist/cli/commands/skillCreation.d.ts +0 -12
- package/dist/cli/commands/skillCreation.js +0 -14
- package/dist/cli/commands/skillWizard.d.ts +0 -17
- package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
- package/dist/cli/commands/streaming/idleTimer.js +0 -24
- package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -27
- package/dist/cli/commands/streaming/turnOutcome.js +0 -29
- package/dist/cli/commands/wizardActions.d.ts +0 -47
- package/dist/cli/commands/wizardActions.js +0 -47
- package/dist/cli/commands/wizardInput.d.ts +0 -4
- package/dist/cli/commands/wizardInput.js +0 -19
- package/dist/cli/commands/wizardPrompts.d.ts +0 -22
- package/dist/cli/commands/wizardPrompts.js +0 -58
- package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
- package/dist/cli/commands/wizardSuggestions.js +0 -190
- package/dist/cli/commands/wizardTransition.d.ts +0 -37
- package/dist/cli/commands/wizardTransition.js +0 -43
- package/dist/core/agent/toolExecutionBudget.d.ts +0 -35
- package/dist/core/agent/toolExecutionBudget.js +0 -49
- package/dist/core/agent/turnBudget.d.ts +0 -35
- package/dist/core/agent/turnBudget.js +0 -27
- package/dist/core/bashOutput/ansi.d.ts +0 -1
- package/dist/core/bashOutput/ansi.js +0 -7
- package/dist/core/bashOutput/registry.d.ts +0 -4
- package/dist/core/goal/completionPolicy.js +0 -43
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -18
- package/dist/core/goal/sessionGoal.d.ts +0 -8
- package/dist/core/goal/sessionGoal.js +0 -30
- package/dist/core/limits/byteBudgets.d.ts +0 -20
- package/dist/core/limits/byteBudgets.js +0 -20
- package/dist/core/limits/textBudgets.d.ts +0 -25
- package/dist/core/limits/textBudgets.js +0 -25
- package/dist/core/safety/bashClassifier.d.ts +0 -10
- package/dist/llm/lsp.d.ts +0 -149
- package/dist/llm/lsp.js +0 -368
- package/dist/ui/components/ErrorView.d.ts +0 -4
- package/dist/ui/components/ErrorView.js +0 -7
- package/dist/utils/yaml.d.ts +0 -2
- package/dist/utils/yaml.js +0 -8
- package/examples/skills/files/SKILL.md +0 -16
- package/examples/skills/files/examples/file-editing.md +0 -3
- /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useEffect, useReducer, useRef, useState } from 'react';
|
|
3
3
|
import { execFile as execFileCallback } from 'node:child_process';
|
|
4
4
|
import { promisify } from 'node:util';
|
|
5
5
|
import { Box, render, Static, Text, useApp, useWindowSize } from 'ink';
|
|
@@ -26,7 +26,7 @@ import { MAX_VISIBLE_TASKS, TaskBar } from '../chat/TaskBar.js';
|
|
|
26
26
|
import { AssistantMarkdownChunkView, MessageView, partitionDisplayMessages } from '../chat/messages.js';
|
|
27
27
|
import { createSessionRecorder } from '../chat/sessionRecorder.js';
|
|
28
28
|
import { createSessionLifecycle } from '../chat/sessionLifecycle.js';
|
|
29
|
-
import { createWizardDispatch } from '../chat/wizardDispatch.js';
|
|
29
|
+
import { createWizardDispatch, initialWizardUiState, wizardUiReducer } from '../chat/wizardDispatch.js';
|
|
30
30
|
import { buildContextReport } from '../chat/contextReport.js';
|
|
31
31
|
import { startupContextInfo, startupProviderInfo } from '../chat/startupInfo.js';
|
|
32
32
|
import { TIPS, randomTipIndex, tipsEnabled } from '../chat/tips.js';
|
|
@@ -37,8 +37,7 @@ import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES, placeholderForMode } fr
|
|
|
37
37
|
import { inputSuggestionsForState } from '../chat/inputSuggestions.js';
|
|
38
38
|
import { modelThinkingLabel } from '../../utils/modelName.js';
|
|
39
39
|
import { detectCheckoutMismatch, formatMismatchWarning, runtimeCapabilities } from '../../utils/buildInfo.js';
|
|
40
|
-
import {
|
|
41
|
-
import { commandParts } from './wizardInput.js';
|
|
40
|
+
import { commandParts } from './wizardFlow.js';
|
|
42
41
|
import { backgroundProcessCount, subscribeBackgroundProcesses, teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
|
|
43
42
|
import { MAX_SESSION_PICKER_RESULTS } from './sessionPicker.js';
|
|
44
43
|
const execFile = promisify(execFileCallback);
|
|
@@ -121,7 +120,6 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
121
120
|
const [contextFiles, setContextFiles] = useState([]);
|
|
122
121
|
const [mode, setMode] = useState('chat');
|
|
123
122
|
const [sessions, setSessions] = useState([]);
|
|
124
|
-
const [selectedSessionId, setSelectedSessionId] = useState();
|
|
125
123
|
const [busy, setBusy] = useState(false);
|
|
126
124
|
const [backgroundCount, setBackgroundCount] = useState(backgroundProcessCount);
|
|
127
125
|
const [busyLabel, setBusyLabel] = useState(() => thinkingLabelForSettings(settings));
|
|
@@ -142,17 +140,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
142
140
|
const [pausedResume, setPausedResume] = useState(undefined);
|
|
143
141
|
const [skills, setSkills] = useState([]);
|
|
144
142
|
const [branchName, setBranchName] = useState();
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const [
|
|
148
|
-
const
|
|
149
|
-
const [providerDraft, setProviderDraft] = useState({});
|
|
150
|
-
const [skillDraft, setSkillDraft] = useState({});
|
|
151
|
-
const [selectedSkillName, setSelectedSkillName] = useState();
|
|
152
|
-
const [selectedLspName, setSelectedLspName] = useState();
|
|
153
|
-
const [lspDraft, setLspDraft] = useState({});
|
|
154
|
-
const [selectedMcpName, setSelectedMcpName] = useState();
|
|
155
|
-
const [mcpDraft, setMcpDraft] = useState({});
|
|
143
|
+
// Wizard flow state (selection, drafts, model discovery) in one reducer;
|
|
144
|
+
// this replaced twelve individual useState hooks.
|
|
145
|
+
const [wizardState, updateWizard] = useReducer(wizardUiReducer, undefined, initialWizardUiState);
|
|
146
|
+
const { modelProviderFilter, discoveredModels, suggestedModels, selectedProviderName, providerDraft, selectedSkillName, selectedLspName, selectedMcpName } = wizardState;
|
|
156
147
|
// Wrap setBusy so the busy indicator knows when the turn started, and tick a
|
|
157
148
|
// heartbeat every second while busy so elapsed time keeps rolling. This keeps
|
|
158
149
|
// the UI visibly alive during long model thinking / blocked tool runs where
|
|
@@ -221,7 +212,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
221
212
|
if (mismatch) {
|
|
222
213
|
setMessages(m => [...m, { role: 'system', text: formatMismatchWarning(mismatch) }]);
|
|
223
214
|
}
|
|
224
|
-
else if (!runtimeCapabilities().
|
|
215
|
+
else if (!runtimeCapabilities().goalSupervisorAvailable) {
|
|
225
216
|
setMessages(m => [...m, { role: 'system', text: 'Warning: this haze build lacks the goal supervisor module; exhausting a turn step/tool budget may pause the goal instead of continuing automatically. Reinstall or relink haze (npm run dev:link in the checkout).' }]);
|
|
226
217
|
}
|
|
227
218
|
})().catch(() => undefined);
|
|
@@ -305,7 +296,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
305
296
|
await sessionRecorderRef.current?.flush().catch(showPersistenceWarning);
|
|
306
297
|
const next = await listSessions();
|
|
307
298
|
setSessions(next);
|
|
308
|
-
|
|
299
|
+
updateWizard({ type: 'set', key: 'selectedSessionId', value: undefined });
|
|
309
300
|
if (next.length === 0) {
|
|
310
301
|
setMessages(m => [...m, { role: 'system', text: 'No saved sessions found for this workspace.' }]);
|
|
311
302
|
setMode('chat');
|
|
@@ -338,18 +329,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
338
329
|
if (mode !== 'chat') {
|
|
339
330
|
setMode('chat');
|
|
340
331
|
setSessions([]);
|
|
341
|
-
|
|
342
|
-
setModelProviderFilter(undefined);
|
|
343
|
-
setDiscoveredModels([]);
|
|
344
|
-
setSuggestedModels([]);
|
|
345
|
-
setSelectedProviderName(undefined);
|
|
346
|
-
setProviderDraft({});
|
|
347
|
-
setSkillDraft({});
|
|
348
|
-
setSelectedSkillName(undefined);
|
|
349
|
-
setSelectedLspName(undefined);
|
|
350
|
-
setLspDraft({});
|
|
351
|
-
setSelectedMcpName(undefined);
|
|
352
|
-
setMcpDraft({});
|
|
332
|
+
updateWizard({ type: 'reset' });
|
|
353
333
|
}
|
|
354
334
|
}
|
|
355
335
|
function showWizardMessage(message) {
|
|
@@ -360,15 +340,12 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
360
340
|
// shared settings-patch applier (CR-006). Rebuilt every render so handlers
|
|
361
341
|
// see current state without new React state.
|
|
362
342
|
const wizard = createWizardDispatch({
|
|
363
|
-
settings, skills,
|
|
364
|
-
|
|
365
|
-
providerDraft, lspDraft, mcpDraft, skillDraft,
|
|
343
|
+
settings, skills, sessions,
|
|
344
|
+
wizard: wizardState, updateWizard,
|
|
366
345
|
setMode, setSettings,
|
|
367
|
-
|
|
346
|
+
showMessage: showWizardMessage, refreshSkills,
|
|
368
347
|
resumeSessionById: sessionLifecycle.resumeSessionById,
|
|
369
348
|
forkSessionById: sessionLifecycle.forkSessionById,
|
|
370
|
-
setModelProviderFilter, setProviderDraft, setSkillDraft, setLspDraft, setMcpDraft, setDiscoveredModels, setSuggestedModels,
|
|
371
|
-
showMessage: showWizardMessage, refreshSkills,
|
|
372
349
|
setBusyLabel, setBusy: setBusyWithHeartbeat,
|
|
373
350
|
idleBusyLabel: thinkingLabelForSettings(settings),
|
|
374
351
|
});
|
|
@@ -396,41 +373,6 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
396
373
|
// Any new submission supersedes a paused-task resume affordance.
|
|
397
374
|
if (pausedResume)
|
|
398
375
|
setPausedResume(undefined);
|
|
399
|
-
const providerEffects = transitionProviderField({ mode, value, settings, draft: providerDraft });
|
|
400
|
-
if (providerEffects) {
|
|
401
|
-
for (const effect of providerEffects) {
|
|
402
|
-
if (effect.type === 'message')
|
|
403
|
-
showWizardMessage(effect.text);
|
|
404
|
-
else if (effect.type === 'mode')
|
|
405
|
-
setMode(effect.mode);
|
|
406
|
-
else if (effect.type === 'provider-draft') {
|
|
407
|
-
if (effect.replace)
|
|
408
|
-
setProviderDraft(effect.patch);
|
|
409
|
-
else
|
|
410
|
-
setProviderDraft(draft => ({ ...draft, ...effect.patch }));
|
|
411
|
-
}
|
|
412
|
-
else if (effect.type === 'discover-provider-models') {
|
|
413
|
-
// The draft patch above is still pending React state, so discovery
|
|
414
|
-
// receives the merged draft explicitly (same pattern as MCP stdio).
|
|
415
|
-
await wizard.discoverProviderModelsForDraft(effect.draft);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return;
|
|
419
|
-
}
|
|
420
|
-
const mcpEffects = transitionMcpField({ mode, value, settings, draft: mcpDraft });
|
|
421
|
-
if (mcpEffects) {
|
|
422
|
-
for (const effect of mcpEffects) {
|
|
423
|
-
if (effect.type === 'message')
|
|
424
|
-
showWizardMessage(effect.text);
|
|
425
|
-
else if (effect.type === 'mode')
|
|
426
|
-
setMode(effect.mode);
|
|
427
|
-
else if (effect.type === 'mcp-draft')
|
|
428
|
-
setMcpDraft(draft => ({ ...draft, ...effect.patch }));
|
|
429
|
-
else if (effect.type === 'finish-mcp-stdio')
|
|
430
|
-
await wizard.finishMcpCustom(undefined, effect.draft);
|
|
431
|
-
}
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
376
|
if (await wizard.dispatch(mode, value))
|
|
435
377
|
return;
|
|
436
378
|
const invokedSkill = skillInvocation(value);
|
|
@@ -443,7 +385,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
443
385
|
settings,
|
|
444
386
|
contextFiles,
|
|
445
387
|
setMode,
|
|
446
|
-
setModelProviderFilter,
|
|
388
|
+
setModelProviderFilter: (filter) => updateWizard({ type: 'set', key: 'modelProviderFilter', value: filter }),
|
|
447
389
|
addSystemMessage: text => setMessages(m => [...m, { role: 'system', text }]),
|
|
448
390
|
clearConversation,
|
|
449
391
|
newSession: async () => {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { type WizardStepId } from './wizardFlow.js';
|
|
2
|
+
/**
|
|
3
|
+
* Input-mode classification derived from the wizard flow table
|
|
4
|
+
* (`wizardFlow.ts`): the `Mode` union, the picker/masked/empty-submit sets,
|
|
5
|
+
* and per-mode placeholders all follow from the step definitions, so adding a
|
|
6
|
+
* step updates every classification from its single table entry.
|
|
7
|
+
*/
|
|
8
|
+
export type Mode = 'chat' | WizardStepId;
|
|
2
9
|
/** Modes that show an always-on suggestion picker (server/preset lists). */
|
|
3
10
|
export declare const PICKER_MODES: ReadonlySet<Mode>;
|
|
4
11
|
/** Modes that mask input (secrets/API keys). */
|
|
@@ -1,49 +1,14 @@
|
|
|
1
|
+
import { WIZARD_STEPS } from './wizardFlow.js';
|
|
2
|
+
/** Wizard steps viewed through their definition type, for uniform property access. */
|
|
3
|
+
const STEPS = WIZARD_STEPS;
|
|
4
|
+
const stepIds = (steps) => steps.map(step => step.id);
|
|
1
5
|
/** Modes that show an always-on suggestion picker (server/preset lists). */
|
|
2
|
-
export const PICKER_MODES = new Set(
|
|
6
|
+
export const PICKER_MODES = new Set(stepIds(STEPS.filter(step => step.kind === 'pick')));
|
|
3
7
|
/** Modes that mask input (secrets/API keys). */
|
|
4
|
-
export const MASKED_MODES = new Set(
|
|
8
|
+
export const MASKED_MODES = new Set(stepIds(STEPS.filter(step => step.kind === 'masked-input')));
|
|
5
9
|
/** Modes where submitting an empty value is valid (optional steps). */
|
|
6
|
-
export const SUBMIT_EMPTY_MODES = new Set(
|
|
7
|
-
const PLACEHOLDERS = {
|
|
8
|
-
sessions: 'Choose a saved session',
|
|
9
|
-
sessionAction: 'Resume or fork this session',
|
|
10
|
-
provider: 'Choose provider',
|
|
11
|
-
providerAction: 'Choose provider action',
|
|
12
|
-
providerAddPreset: 'Choose a provider preset or custom',
|
|
13
|
-
model: 'Choose model, or add model',
|
|
14
|
-
modelAddProvider: 'Choose a provider to add models to',
|
|
15
|
-
modelPick: 'Choose a model to add',
|
|
16
|
-
providerAddName: 'Provider name',
|
|
17
|
-
providerAddUrl: 'https://example.com/v1',
|
|
18
|
-
providerAddKey: 'API key, or blank for local',
|
|
19
|
-
providerSetKey: 'API key',
|
|
20
|
-
providerAddModels: 'model-a, model-b',
|
|
21
|
-
providerAppendModels: 'model-a, model-b',
|
|
22
|
-
providerRemoveModels: 'model-a, model-b',
|
|
23
|
-
providerConfirmRemove: 'Type "yes" to confirm',
|
|
24
|
-
skills: 'Choose a skill or add skill',
|
|
25
|
-
skillsAction: 'show info, enable, disable, validate, or remove',
|
|
26
|
-
skillsAddName: 'Skill name (kebab-case, e.g. security-review)',
|
|
27
|
-
skillsAddScope: 'Choose this project or global',
|
|
28
|
-
skillsAddDescription: 'Describe what the skill should do',
|
|
29
|
-
skillsConfirmRemove: 'Type "yes" to confirm',
|
|
30
|
-
lsp: 'Choose LSP server or add server',
|
|
31
|
-
lspAction: 'enable, disable, or remove server',
|
|
32
|
-
lspAddPreset: 'Choose an LSP preset or custom',
|
|
33
|
-
lspAddName: 'LSP server name (e.g. typescript)',
|
|
34
|
-
lspAddCommand: 'Command (e.g. typescript-language-server --stdio)',
|
|
35
|
-
lspConfirmRemove: 'Type "yes" to confirm',
|
|
36
|
-
mcp: 'Choose MCP server or add server',
|
|
37
|
-
mcpAction: 'enable, disable, remove, or set key',
|
|
38
|
-
mcpAddPreset: 'Choose an MCP preset or custom',
|
|
39
|
-
mcpAddName: 'MCP server name (e.g. context7)',
|
|
40
|
-
mcpAddTransport: 'http, sse, or stdio',
|
|
41
|
-
mcpAddUrl: 'https://mcp.example.com/mcp',
|
|
42
|
-
mcpAddCommand: 'Command (e.g. npx -y @pkg/server)',
|
|
43
|
-
mcpAddKey: 'API key, or blank to skip',
|
|
44
|
-
mcpSetKey: 'API key',
|
|
45
|
-
mcpConfirmRemove: 'Type "yes" to confirm',
|
|
46
|
-
};
|
|
10
|
+
export const SUBMIT_EMPTY_MODES = new Set(stepIds(STEPS.filter(step => step.optional)));
|
|
47
11
|
export function placeholderForMode(mode, busy) {
|
|
48
|
-
|
|
12
|
+
const step = WIZARD_STEPS.find(candidate => candidate.id === mode);
|
|
13
|
+
return step?.placeholder ?? (busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask haze to help build your app');
|
|
49
14
|
}
|
|
@@ -65,7 +65,7 @@ export async function runDoctor(deps = {}) {
|
|
|
65
65
|
write('Checkout mismatch: none');
|
|
66
66
|
write();
|
|
67
67
|
}
|
|
68
|
-
if (!capabilities.
|
|
68
|
+
if (!capabilities.goalSupervisorAvailable) {
|
|
69
69
|
write('Warning: the goal supervisor is unavailable in this runtime; exhausting a');
|
|
70
70
|
write("turn's step/tool budget may pause the goal instead of continuing automatically.");
|
|
71
71
|
write();
|
|
@@ -19,9 +19,8 @@ export declare function imageAttachmentLine(attachment: {
|
|
|
19
19
|
}): string;
|
|
20
20
|
export declare function formatElapsedTime(milliseconds: number): string;
|
|
21
21
|
export declare function formatElapsedTimeWhole(milliseconds: number): string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export interface ContextReportTool {
|
|
22
|
+
type ContextReportCategory = 'builtin' | 'lsp' | 'skill' | 'subagent' | 'mcp';
|
|
23
|
+
interface ContextReportTool {
|
|
25
24
|
name: string;
|
|
26
25
|
tokens: number;
|
|
27
26
|
category: ContextReportCategory;
|
|
@@ -47,3 +46,4 @@ export interface ContextReportData {
|
|
|
47
46
|
}
|
|
48
47
|
/** Render a detailed, /context-style token breakdown. Pure for testability. */
|
|
49
48
|
export declare function formatContextReport(data: ContextReportData): string;
|
|
49
|
+
export {};
|
|
@@ -18,9 +18,9 @@ export function compact(value, maxLength = 180) {
|
|
|
18
18
|
}
|
|
19
19
|
export function toolCallSummary(toolName, input) {
|
|
20
20
|
const data = input;
|
|
21
|
-
if (toolName === '
|
|
21
|
+
if (toolName === 'shell' && typeof data?.command === 'string') {
|
|
22
22
|
const mode = data.background === true ? ' (background)' : typeof data.timeoutSeconds === 'number' ? ` (timeout ${data.timeoutSeconds}s)` : '';
|
|
23
|
-
return `
|
|
23
|
+
return `shell $ ${data.command}${mode}`;
|
|
24
24
|
}
|
|
25
25
|
if (toolName === 'process' && typeof data?.action === 'string')
|
|
26
26
|
return `process ${data.action}${typeof data.backgroundId === 'string' ? ` ${data.backgroundId}` : ''}`;
|
|
@@ -60,7 +60,9 @@ export function toolCallSummary(toolName, input) {
|
|
|
60
60
|
return `lspWorkspaceSymbols "${data.query}"`;
|
|
61
61
|
if (toolName === 'lspSymbols' && typeof data?.path === 'string')
|
|
62
62
|
return `lspSymbols ${data.path}`;
|
|
63
|
-
if (
|
|
63
|
+
if (toolName === 'lspDiagnostics' && typeof data?.path === 'string')
|
|
64
|
+
return `lspDiagnostics ${data.path}`;
|
|
65
|
+
if ((toolName === 'lspDefinition' || toolName === 'lspTypeDefinition' || toolName === 'lspImplementation' || toolName === 'lspReferences') && typeof data?.path === 'string')
|
|
64
66
|
return `${toolName} ${data.path}:${data.line}:${data.column}`;
|
|
65
67
|
return `${toolName} ${compact(input)}`;
|
|
66
68
|
}
|
|
@@ -145,7 +147,7 @@ export function busyToolLabel(toolName, input) {
|
|
|
145
147
|
const data = input;
|
|
146
148
|
const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
|
|
147
149
|
switch (toolName) {
|
|
148
|
-
case '
|
|
150
|
+
case 'shell':
|
|
149
151
|
return data?.background === true ? 'Starting background process' : 'Running command';
|
|
150
152
|
case 'process':
|
|
151
153
|
return 'Managing background process';
|
|
@@ -209,27 +211,6 @@ export function formatElapsedTimeWhole(milliseconds) {
|
|
|
209
211
|
return `${minutes}m ${seconds}s`;
|
|
210
212
|
return `${seconds}s`;
|
|
211
213
|
}
|
|
212
|
-
export function toolOutputDetails(value) {
|
|
213
|
-
if (!value || typeof value !== 'object')
|
|
214
|
-
return '';
|
|
215
|
-
const output = value;
|
|
216
|
-
const stdout = output.stdout?.text?.trim();
|
|
217
|
-
const stderr = output.stderr?.text?.trim();
|
|
218
|
-
const meta = [
|
|
219
|
-
output.cwd ? `cwd: ${output.cwd}` : '',
|
|
220
|
-
output.classification?.riskLevel ? `classification: ${output.classification.riskLevel}${output.classification.reason ? ` — ${output.classification.reason}` : ''}` : '',
|
|
221
|
-
output.validationSummary?.summaryText ? `validation: ${output.validationSummary.summaryText}${output.validationSummary.suggestedNextStep ? `\nnext: ${output.validationSummary.suggestedNextStep}` : ''}` : '',
|
|
222
|
-
].filter(Boolean).join('\n');
|
|
223
|
-
const parts = [
|
|
224
|
-
meta,
|
|
225
|
-
stdout ? `stdout:\n${compact(stdout, 1200)}` : '',
|
|
226
|
-
stderr ? `stderr:\n${compact(stderr, 1200)}` : '',
|
|
227
|
-
].filter(Boolean);
|
|
228
|
-
if (parts.length === 0)
|
|
229
|
-
return '';
|
|
230
|
-
const truncated = output.stdout?.truncated || output.stderr?.truncated;
|
|
231
|
-
return `${parts.join('\n\n')}${truncated ? '\n… output truncated' : ''}`;
|
|
232
|
-
}
|
|
233
214
|
const CONTEXT_CATEGORY_LABEL = {
|
|
234
215
|
builtin: 'Built-in',
|
|
235
216
|
lsp: 'LSP',
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { configuredProviders, findProvider, upsertProvider } from '../../config/providers.js';
|
|
2
|
-
import { PROVIDER_ACTIONS } from './
|
|
3
|
-
import { commaList } from './wizardInput.js';
|
|
2
|
+
import { PROVIDER_ACTIONS, commaList } from './wizardFlow.js';
|
|
4
3
|
import { assertCredentialedEndpointSecure } from '../../config/endpointSecurity.js';
|
|
5
4
|
import { presetModelLimitsForModels } from '../../config/providerPresets.js';
|
|
6
5
|
import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
|
|
@@ -163,7 +162,7 @@ export function providerActionResult(action, provider) {
|
|
|
163
162
|
return { message: '', selectedName: undefined, mode: 'model' };
|
|
164
163
|
if (action === PROVIDER_ACTIONS.addModels)
|
|
165
164
|
return { message: `Comma-separated model names to add to ${provider.name}?`, mode: 'providerAppendModels' };
|
|
166
|
-
if (action === PROVIDER_ACTIONS.
|
|
165
|
+
if (action === PROVIDER_ACTIONS.manageAccess)
|
|
167
166
|
return { message: `New API key for ${provider.name}? (current: ${provider.key ? 'saved' : 'not set'})`, mode: 'providerSetKey' };
|
|
168
167
|
if (action === PROVIDER_ACTIONS.removeModels)
|
|
169
168
|
return { message: `Comma-separated model names to remove from ${provider.name}?\nCurrent models: ${provider.models.join(', ')}`, mode: 'providerRemoveModels' };
|
|
@@ -59,7 +59,7 @@ function toHeadlessStreamEvent(event) {
|
|
|
59
59
|
case 'step_start':
|
|
60
60
|
return { type: 'step_start', attempt: event.attempt, step: event.step, at: event.at };
|
|
61
61
|
case 'step_end':
|
|
62
|
-
return { type: 'step_end', attempt: event.attempt, step: event.step, finishReason: event.finishReason, toolCallCount: event.toolCallCount, usage: event.usage, at: event.at };
|
|
62
|
+
return { type: 'step_end', attempt: event.attempt, step: event.step, finishReason: event.finishReason, toolCallCount: event.toolCallCount, usage: event.usage, ...(event.responseModel ? { responseModel: event.responseModel } : {}), at: event.at };
|
|
63
63
|
case 'message_start':
|
|
64
64
|
return { type: 'message_start', id: event.id, role: event.role, at: event.at };
|
|
65
65
|
case 'message_update':
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type HazeLspServer } from '../../config/lspSettings.js';
|
|
2
|
+
import type { HazeMcpServer, HazeSettings } from '../../config/settings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pure result functions for the LSP and MCP server wizard flows. The
|
|
5
|
+
* corresponding steps (placeholders, kinds, suggestions) live in
|
|
6
|
+
* `wizardFlow.ts`; the submit orchestration lives in
|
|
7
|
+
* `chat/wizardDispatch.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export type LspWizardResult = {
|
|
10
|
+
message?: string;
|
|
11
|
+
mode?: 'chat' | 'lsp' | 'lspAction' | 'lspAddName' | 'lspConfirmRemove';
|
|
12
|
+
selectedName?: string;
|
|
13
|
+
settingsPatch?: Partial<HazeSettings>;
|
|
14
|
+
server?: HazeLspServer;
|
|
15
|
+
clearDraft?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function selectLspServerResult(settings: HazeSettings, serverName: string): LspWizardResult;
|
|
18
|
+
export declare function selectLspPresetResult(settings: HazeSettings, presetId: string): LspWizardResult;
|
|
19
|
+
export declare function selectLspActionResult(settings: HazeSettings, selectedName: string | undefined, action: string): LspWizardResult;
|
|
20
|
+
export declare function finishLspCustomResult(settings: HazeSettings, draftName: string | undefined, commandLine: string): LspWizardResult;
|
|
21
|
+
export type McpWizardResult = {
|
|
22
|
+
message?: string;
|
|
23
|
+
mode?: 'chat' | 'mcp' | 'mcpAction' | 'mcpAddName' | 'mcpAddKey' | 'mcpSetKey' | 'mcpConfirmRemove';
|
|
24
|
+
selectedName?: string;
|
|
25
|
+
draft?: Partial<HazeMcpServer>;
|
|
26
|
+
settingsPatch?: Partial<HazeSettings>;
|
|
27
|
+
server?: HazeMcpServer;
|
|
28
|
+
clearDraft?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function selectMcpServerResult(settings: HazeSettings, serverName: string): McpWizardResult;
|
|
31
|
+
export declare function selectMcpPresetResult(settings: HazeSettings, presetId: string): McpWizardResult;
|
|
32
|
+
export declare function selectMcpActionResult(settings: HazeSettings, selectedName: string | undefined, action: string): McpWizardResult;
|
|
33
|
+
export declare function finishMcpCustomResult(settings: HazeSettings, draft: Partial<HazeMcpServer>, keyValue?: string): McpWizardResult;
|
|
34
|
+
export declare function setMcpServerKeyResult(settings: HazeSettings, selectedName: string | undefined, keyValue: string): McpWizardResult;
|
|
@@ -1,6 +1,48 @@
|
|
|
1
|
+
import { configuredLspServers, lspPreset, upsertLspServer, setLspServerEnabled } from '../../config/lspSettings.js';
|
|
1
2
|
import { findMcpPreset, findMcpServer, toggleMcpServer, upsertMcpServer } from '../../config/mcpSettings.js';
|
|
2
|
-
import { COMMON_ACTIONS, MCP_ACTIONS, MCP_TRANSPORTS, SERVER_CHOICES } from './wizardActions.js';
|
|
3
3
|
import { assertCredentialedEndpointSecure } from '../../config/endpointSecurity.js';
|
|
4
|
+
import { COMMON_ACTIONS, LSP_ACTIONS, MCP_ACTIONS, MCP_TRANSPORTS, SERVER_CHOICES, commandParts } from './wizardFlow.js';
|
|
5
|
+
export function selectLspServerResult(settings, serverName) {
|
|
6
|
+
if (serverName === SERVER_CHOICES.addServer)
|
|
7
|
+
return { mode: 'lspAddName', clearDraft: true, message: 'Choose an LSP preset, or select "custom" to enter a name and command manually.' };
|
|
8
|
+
const server = configuredLspServers(settings).find(candidate => candidate.name === serverName);
|
|
9
|
+
if (!server)
|
|
10
|
+
return { mode: 'chat', message: `No LSP server named ${serverName}. Use /lsp and choose add server.` };
|
|
11
|
+
return { mode: 'lspAction', selectedName: server.name, message: `${server.name}: choose an action.` };
|
|
12
|
+
}
|
|
13
|
+
export function selectLspPresetResult(settings, presetId) {
|
|
14
|
+
if (presetId === SERVER_CHOICES.custom)
|
|
15
|
+
return { mode: 'lspAddName', clearDraft: true, message: 'LSP server name? Example: typescript, rust, my-lsp.' };
|
|
16
|
+
const preset = lspPreset(presetId);
|
|
17
|
+
if (!preset)
|
|
18
|
+
return { message: `Unknown preset: ${presetId}.` };
|
|
19
|
+
if (configuredLspServers(settings).some(server => server.name === preset.name))
|
|
20
|
+
return { mode: 'chat', message: `LSP server ${preset.name} already exists. Use /lsp to manage existing servers.` };
|
|
21
|
+
return { mode: 'chat', server: preset, settingsPatch: { lspServers: upsertLspServer(settings, preset) }, message: `Added LSP preset ${preset.name}. Ensure ${preset.command} is installed and on PATH; tools appear once it is.` };
|
|
22
|
+
}
|
|
23
|
+
export function selectLspActionResult(settings, selectedName, action) {
|
|
24
|
+
if (!selectedName)
|
|
25
|
+
return { mode: 'lsp' };
|
|
26
|
+
const server = configuredLspServers(settings).find(candidate => candidate.name === selectedName);
|
|
27
|
+
if (!server)
|
|
28
|
+
return { mode: 'chat', selectedName: undefined, message: `LSP server ${selectedName} not found.` };
|
|
29
|
+
if (action === COMMON_ACTIONS.enable || action === COMMON_ACTIONS.disable) {
|
|
30
|
+
const enabled = action === COMMON_ACTIONS.enable;
|
|
31
|
+
return { mode: 'chat', selectedName: undefined, settingsPatch: { lspServers: setLspServerEnabled(settings, selectedName, enabled) }, message: `LSP server ${selectedName} ${enabled ? 'enabled' : 'disabled'}.` };
|
|
32
|
+
}
|
|
33
|
+
if (action === LSP_ACTIONS.removeServer)
|
|
34
|
+
return { mode: 'lspConfirmRemove', message: `Remove LSP server ${selectedName}? Type "yes" to confirm. Esc to cancel.` };
|
|
35
|
+
return { message: `Unknown LSP action: ${action}` };
|
|
36
|
+
}
|
|
37
|
+
export function finishLspCustomResult(settings, draftName, commandLine) {
|
|
38
|
+
const name = draftName?.trim();
|
|
39
|
+
const parts = commandParts(commandLine);
|
|
40
|
+
const command = parts[0];
|
|
41
|
+
if (!name || !command)
|
|
42
|
+
return { mode: 'chat', clearDraft: true, message: 'LSP server name and command are required.' };
|
|
43
|
+
const server = { name, command, args: parts.slice(1), extensions: [], rootPatterns: ['.git'], enabled: true };
|
|
44
|
+
return { mode: 'chat', clearDraft: true, server, settingsPatch: { lspServers: upsertLspServer(settings, server) }, message: `Added LSP server ${name} (${command}${parts.length > 1 ? ` ${parts.slice(1).join(' ')}` : ''}). Add extensions in ~/.haze/settings.json so tools can auto-select it.` };
|
|
45
|
+
}
|
|
4
46
|
export function selectMcpServerResult(settings, serverName) {
|
|
5
47
|
if (serverName === SERVER_CHOICES.addServer)
|
|
6
48
|
return { mode: 'mcpAddName', clearDraft: true, message: 'Choose an MCP preset, or select "custom" to enter details manually.' };
|
|
@@ -33,7 +75,7 @@ export function selectMcpActionResult(settings, selectedName, action) {
|
|
|
33
75
|
const enabled = action === COMMON_ACTIONS.enable;
|
|
34
76
|
return { mode: 'chat', selectedName: undefined, settingsPatch: { mcpServers: toggleMcpServer(settings, selectedName, enabled) ?? [] }, message: `MCP server ${selectedName} ${enabled ? 'enabled' : 'disabled'}.` };
|
|
35
77
|
}
|
|
36
|
-
if (action === MCP_ACTIONS.
|
|
78
|
+
if (action === MCP_ACTIONS.manageAccess) {
|
|
37
79
|
if (server.transport === 'stdio')
|
|
38
80
|
return { mode: 'chat', selectedName: undefined, message: 'Stdio MCP authentication must be handled by its command or wrapper; HTTP headers do not apply.' };
|
|
39
81
|
return { mode: 'mcpSetKey', message: `New API key for ${selectedName}? (current: ${server.headers?.length ? 'saved' : 'not set'}) Sent as Authorization: Bearer <value>.` };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { HazeSettings } from '../../config/settings.js';
|
|
2
|
+
import type { LoadedSkill } from '../../skills/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pure result functions for the skills wizard flow: selection, actions,
|
|
5
|
+
* creation-from-description, and confirm-remove. Steps live in
|
|
6
|
+
* `wizardFlow.ts`; submit orchestration in `chat/wizardDispatch.ts`.
|
|
7
|
+
*/
|
|
8
|
+
export type SkillWizardResult = {
|
|
9
|
+
message?: string;
|
|
10
|
+
mode?: 'chat' | 'skills' | 'skillsAction' | 'skillsAddName' | 'skillsConfirmRemove';
|
|
11
|
+
selectedName?: string;
|
|
12
|
+
settingsPatch?: Partial<HazeSettings>;
|
|
13
|
+
clearDraft?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function selectSkillResult(skills: LoadedSkill[], name: string): SkillWizardResult;
|
|
16
|
+
export declare function skillInfoMessage(settings: HazeSettings, skill: LoadedSkill): string;
|
|
17
|
+
export declare function selectSkillActionResult(settings: HazeSettings, skills: LoadedSkill[], selectedName: string | undefined, action: string): SkillWizardResult & {
|
|
18
|
+
skill?: LoadedSkill;
|
|
19
|
+
validate?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type SkillCreationResult = {
|
|
22
|
+
busy?: boolean;
|
|
23
|
+
busyLabel?: string;
|
|
24
|
+
message?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
draftName?: string;
|
|
27
|
+
mode?: 'chat';
|
|
28
|
+
clearDraft?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function captureSkillDescription(value: string, draftName: string | undefined): SkillCreationResult;
|
|
31
|
+
export declare function skillCreationMessage(name: string, file: string): string;
|
|
32
|
+
export declare function skillCreationFailure(error: unknown): string;
|
|
33
|
+
export type SkillConfirmRemoveResult = {
|
|
34
|
+
message?: string;
|
|
35
|
+
mode?: 'chat';
|
|
36
|
+
settingsPatch?: Partial<HazeSettings>;
|
|
37
|
+
removedDir?: string;
|
|
38
|
+
selectedName?: string;
|
|
39
|
+
skill?: LoadedSkill;
|
|
40
|
+
};
|
|
41
|
+
export declare function skillConfirmRemoveResult(settings: HazeSettings, skills: LoadedSkill[], selectedName: string | undefined, value: string): SkillConfirmRemoveResult;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { isSkillEnabled, setSkillEnabled } from '../../config/skillSettings.js';
|
|
2
|
-
import { COMMON_ACTIONS, SKILL_ACTIONS, SKILL_CHOICES } from './
|
|
3
|
-
export function skillPickerValue(skill) {
|
|
4
|
-
return `${skill.name} · ${skill.source}`;
|
|
5
|
-
}
|
|
6
|
-
export function findSelectedSkill(skills, selection) {
|
|
7
|
-
if (!selection)
|
|
8
|
-
return undefined;
|
|
9
|
-
return skills.find(skill => skillPickerValue(skill) === selection)
|
|
10
|
-
?? skills.find(skill => skill.name === selection);
|
|
11
|
-
}
|
|
1
|
+
import { isSkillEnabled, removeSkillSetting, setSkillEnabled } from '../../config/skillSettings.js';
|
|
2
|
+
import { COMMON_ACTIONS, SKILL_ACTIONS, SKILL_CHOICES, findSelectedSkill, isYesConfirmation, skillPickerValue } from './wizardFlow.js';
|
|
12
3
|
export function selectSkillResult(skills, name) {
|
|
13
4
|
if (name === SKILL_CHOICES.addSkill)
|
|
14
5
|
return { mode: 'skillsAddName', clearDraft: true, message: 'Name the skill (kebab-case, e.g. security-review). ESC cancels.' };
|
|
@@ -46,3 +37,34 @@ export function selectSkillActionResult(settings, skills, selectedName, action)
|
|
|
46
37
|
return { mode: 'skillsConfirmRemove', message: `Remove ${skill.source} skill ${skill.name}? This deletes ${skill.dir}. Type "yes" to confirm. Esc to cancel.`, skill };
|
|
47
38
|
return { message: `Unknown skill action: ${action}`, skill };
|
|
48
39
|
}
|
|
40
|
+
export function captureSkillDescription(value, draftName) {
|
|
41
|
+
const description = value.trim();
|
|
42
|
+
if (!description)
|
|
43
|
+
return { message: 'Description is required. Try again, or press ESC to cancel.' };
|
|
44
|
+
if (!draftName)
|
|
45
|
+
return { mode: 'chat', clearDraft: true, message: 'Skill wizard lost the name. Start over with /skills.' };
|
|
46
|
+
return { description, draftName, busy: true, busyLabel: 'Creating skill' };
|
|
47
|
+
}
|
|
48
|
+
export function skillCreationMessage(name, file) {
|
|
49
|
+
return `Created skill ${name} at ${file}. Invoke it with /${name}. Edit SKILL.md to refine its workflow.`;
|
|
50
|
+
}
|
|
51
|
+
export function skillCreationFailure(error) {
|
|
52
|
+
return `Skill creation failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
53
|
+
}
|
|
54
|
+
export function skillConfirmRemoveResult(settings, skills, selectedName, value) {
|
|
55
|
+
if (!selectedName)
|
|
56
|
+
return { mode: 'chat' };
|
|
57
|
+
if (!isYesConfirmation(value))
|
|
58
|
+
return { mode: 'chat', selectedName: undefined, message: 'Cancelled. Skill not removed.' };
|
|
59
|
+
const skill = findSelectedSkill(skills, selectedName);
|
|
60
|
+
if (!skill)
|
|
61
|
+
return { mode: 'chat', selectedName: undefined, message: `Skill ${selectedName} not found.` };
|
|
62
|
+
return {
|
|
63
|
+
mode: 'chat',
|
|
64
|
+
selectedName: undefined,
|
|
65
|
+
skill,
|
|
66
|
+
removedDir: skill.dir,
|
|
67
|
+
settingsPatch: { skills: removeSkillSetting(settings, skill.name, skill.source) },
|
|
68
|
+
message: skill.source === 'global' ? `Removed skill ${skill.name}.` : `Removed project skill ${skill.name}.`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* mutable holder set by whichever internal site aborts first. A user abort
|
|
9
9
|
* never sets it and therefore stays `'user'` (the default).
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
type TurnAbortCauseKind = 'user' | 'turn-deadline' | 'model-stream-idle';
|
|
12
12
|
export interface TurnAbortCause {
|
|
13
13
|
kind: TurnAbortCauseKind;
|
|
14
14
|
/** Window of the timer that fired (idle window or turn deadline), for messages and diagnostics. */
|
|
@@ -22,3 +22,4 @@ export declare function createUserAbortCause(): TurnAbortCause;
|
|
|
22
22
|
* idle timeout keeps whichever cause actually fired first.
|
|
23
23
|
*/
|
|
24
24
|
export declare function abortForTurn(cause: TurnAbortCause, next: TurnAbortCause, controller: AbortController, reason: string): void;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ContextFile } from '../../../config/contextFiles.js';
|
|
2
|
+
import type { PromptSession } from '../../../llm/systemPrompt.js';
|
|
3
|
+
import type { TurnExecutionScope } from '../../../llm/requestContext.js';
|
|
4
|
+
import type { ToolExecutionBudgetState, TurnBudget } from '../../../core/agent/budgets.js';
|
|
5
|
+
import type { TurnExecutionState } from '../../../core/agent/completionController.js';
|
|
6
|
+
import type { SessionGoal } from '../../../core/agent/goalPolicy.js';
|
|
7
|
+
import { type AgentAttemptResult } from './attemptOutcome.js';
|
|
8
|
+
import type { AttemptCleanupRegistry } from './attemptLifecycle.js';
|
|
9
|
+
import type { TurnAbortCause } from './abortCause.js';
|
|
10
|
+
import type { StreamCallbacks, TurnExecutionOptions } from '../streaming.js';
|
|
11
|
+
export interface AgentAttemptInput {
|
|
12
|
+
value: string;
|
|
13
|
+
contextFiles: ContextFile[];
|
|
14
|
+
callbacks: StreamCallbacks;
|
|
15
|
+
retryAttempt: number;
|
|
16
|
+
retryingExistingRequest: boolean;
|
|
17
|
+
contextOverflowRecovered: boolean;
|
|
18
|
+
session: PromptSession | undefined;
|
|
19
|
+
modelOverride: string | undefined;
|
|
20
|
+
abortController: AbortController;
|
|
21
|
+
turnOptions: TurnExecutionOptions;
|
|
22
|
+
turnScope: {
|
|
23
|
+
executionScope?: TurnExecutionScope;
|
|
24
|
+
};
|
|
25
|
+
turnState: TurnExecutionState;
|
|
26
|
+
turnBudget: TurnBudget;
|
|
27
|
+
globalBudget: ToolExecutionBudgetState;
|
|
28
|
+
/** Slice execution budget shared by every attempt in the current slice (main phase or one recovery slice); reset when a new slice is admitted. */
|
|
29
|
+
sliceBudget: ToolExecutionBudgetState;
|
|
30
|
+
goal: SessionGoal;
|
|
31
|
+
abortCause: TurnAbortCause;
|
|
32
|
+
/** Exactly-once teardown registry; shared with the turn's forced-settlement path. */
|
|
33
|
+
cleanup: AttemptCleanupRegistry;
|
|
34
|
+
remainingTurnDeadlineMs: () => number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run one agent attempt end to end: setup (`attemptSetup`), the stream loop
|
|
38
|
+
* (`streamLoop`), then terminal classification and recovery decisions
|
|
39
|
+
* (`attemptOutcome`). Failures are classified from the abort cause and error
|
|
40
|
+
* in one catch; MCP clients, the LSP pool, the stall guard, and the tool
|
|
41
|
+
* display are always torn down.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runAgentAttempt(input: AgentAttemptInput): Promise<AgentAttemptResult>;
|