@denizokcu/haze 1.7.10 → 1.7.12
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 +25 -0
- package/README.md +125 -99
- package/assets/graph-grammars/NOTICE.md +21 -0
- package/assets/graph-grammars/tree-sitter-javascript.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-tsx.wasm +0 -0
- package/assets/graph-grammars/tree-sitter-typescript.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.cjs +4116 -0
- package/assets/graph-grammars/web-tree-sitter.cjs.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.js +4056 -0
- package/assets/graph-grammars/web-tree-sitter.js.map +7 -0
- package/assets/graph-grammars/web-tree-sitter.wasm +0 -0
- package/assets/graph-grammars/web-tree-sitter.wasm.map +55 -0
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +2 -1
- package/dist/cli/chat/BusyBar.js +2 -2
- package/dist/cli/chat/chatMetrics.d.ts +25 -0
- package/dist/cli/chat/chatMetrics.js +36 -0
- package/dist/cli/chat/inputSuggestions.js +1 -0
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
- package/dist/cli/chat/sessionLifecycle.js +29 -19
- package/dist/cli/chat/sessionRecorder.d.ts +2 -1
- package/dist/cli/chat/sessionRecorder.js +29 -9
- package/dist/cli/chat/startupSequence.d.ts +2 -0
- package/dist/cli/chat/startupSequence.js +6 -0
- package/dist/cli/chat/transcriptPartition.js +10 -4
- package/dist/cli/chat/wizard/providerHandlers.js +57 -9
- package/dist/cli/chat/wizard/sessionThemeHandlers.js +5 -1
- package/dist/cli/commands/chat.js +44 -9
- package/dist/cli/commands/commandHelp.js +6 -3
- package/dist/cli/commands/commands.js +2 -0
- package/dist/cli/commands/formatters.js +28 -0
- package/dist/cli/commands/graphCommand.d.ts +2 -0
- package/dist/cli/commands/graphCommand.js +60 -0
- package/dist/cli/commands/initCommand.js +14 -0
- package/dist/cli/commands/providerWizard.js +9 -17
- package/dist/cli/commands/reasoningCommand.d.ts +1 -0
- package/dist/cli/commands/reasoningCommand.js +32 -4
- package/dist/cli/commands/runCommand.js +7 -1
- package/dist/cli/commands/streaming/agentAttempt.js +11 -1
- package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +6 -2
- package/dist/cli/commands/streaming/attemptSetup.d.ts +3 -0
- package/dist/cli/commands/streaming/attemptSetup.js +13 -6
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +1 -1
- package/dist/cli/commands/streaming/goalSupervisor.js +22 -1
- package/dist/cli/commands/streaming/prepareStep.js +1 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +2 -0
- package/dist/cli/commands/streaming/streamLoop.js +14 -10
- package/dist/cli/commands/streaming/toolPartHandlers.js +7 -1
- package/dist/cli/commands/streaming.d.ts +2 -0
- package/dist/cli/commands/streaming.js +5 -0
- package/dist/cli/commands/wizardFlow.d.ts +1 -0
- package/dist/cli/commands/wizardFlow.js +10 -4
- package/dist/cli/index.js +5 -3
- package/dist/config/hazeBuild.d.ts +2 -2
- package/dist/config/hazeBuild.js +2 -2
- package/dist/config/modelDiscovery.d.ts +1 -1
- package/dist/config/modelDiscovery.js +8 -8
- package/dist/config/{modelCatalog.d.ts → providerModelFacts.d.ts} +13 -2
- package/dist/config/{modelCatalog.js → providerModelFacts.js} +145 -21
- package/dist/config/providerPresets.d.ts +8 -19
- package/dist/config/providerPresets.js +86 -555
- package/dist/config/providerReasoning.d.ts +16 -0
- package/dist/config/providerReasoning.js +56 -0
- package/dist/config/providers.d.ts +4 -0
- package/dist/config/providers.js +19 -2
- package/dist/config/settings.d.ts +14 -0
- package/dist/config/settings.js +5 -0
- package/dist/core/agent/compaction.d.ts +1 -0
- package/dist/core/agent/compaction.js +3 -0
- package/dist/core/agent/events.d.ts +1 -1
- package/dist/core/agent/providerTransition.d.ts +8 -0
- package/dist/core/agent/providerTransition.js +47 -0
- package/dist/core/agent/reasoningPolicy.d.ts +1 -1
- package/dist/core/agent/reasoningPolicy.js +4 -2
- package/dist/core/graph/analyze.d.ts +61 -0
- package/dist/core/graph/analyze.js +274 -0
- package/dist/core/graph/buildGraph.d.ts +44 -0
- package/dist/core/graph/buildGraph.js +290 -0
- package/dist/core/graph/digest.d.ts +2 -0
- package/dist/core/graph/digest.js +40 -0
- package/dist/core/graph/extract.d.ts +58 -0
- package/dist/core/graph/extract.js +394 -0
- package/dist/core/graph/model.d.ts +63 -0
- package/dist/core/graph/model.js +96 -0
- package/dist/core/graph/query.d.ts +69 -0
- package/dist/core/graph/query.js +391 -0
- package/dist/core/graph/store.d.ts +64 -0
- package/dist/core/graph/store.js +171 -0
- package/dist/core/limits.d.ts +0 -2
- package/dist/core/limits.js +0 -2
- package/dist/core/process/runBoundedProcess.js +12 -6
- package/dist/core/providerContracts.d.ts +9 -8
- package/dist/core/providerContracts.js +21 -1
- package/dist/core/safety/redaction.js +12 -2
- package/dist/core/safety/untrustedEnvelopes.d.ts +6 -0
- package/dist/core/safety/untrustedEnvelopes.js +17 -2
- package/dist/core/session/sessionSlimming.js +5 -59
- package/dist/core/session/sessionStore.d.ts +4 -0
- package/dist/core/session/sessionStore.js +149 -9
- package/dist/core/session/snapshotCodec.d.ts +5 -0
- package/dist/core/session/snapshotCodec.js +47 -0
- package/dist/core/shellOutput/registry.js +2 -46
- package/dist/core/subagent/executionProfiles.js +8 -5
- package/dist/core/tasks/taskStorage.js +11 -1
- package/dist/core/toolOutput/reduction.d.ts +55 -2
- package/dist/core/toolOutput/reduction.js +77 -2
- package/dist/core/validation/outputParser.js +16 -8
- package/dist/llm/client.d.ts +4 -2
- package/dist/llm/client.js +104 -55
- package/dist/llm/hazeTools.d.ts +2 -12426
- package/dist/llm/hazeTools.js +2 -0
- package/dist/llm/lspTools.d.ts +3 -12622
- package/dist/llm/mistralReasoning.d.ts +2 -0
- package/dist/llm/mistralReasoning.js +17 -0
- package/dist/llm/mistralVibeAuth.d.ts +5 -0
- package/dist/llm/mistralVibeAuth.js +63 -0
- package/dist/llm/requestContext.d.ts +3 -0
- package/dist/llm/requestContext.js +21 -11
- package/dist/llm/subagentRunner.d.ts +2 -308
- package/dist/llm/subagentRunner.js +15 -7
- package/dist/llm/systemPrompt.js +7 -4
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/toolResultTypes.js +7 -1
- package/dist/llm/tools/fetchTool.d.ts +2 -1221
- package/dist/llm/tools/fileTools.d.ts +2 -7768
- package/dist/llm/tools/graphAdvisory.d.ts +22 -0
- package/dist/llm/tools/graphAdvisory.js +68 -0
- package/dist/llm/tools/graphTools.d.ts +13 -0
- package/dist/llm/tools/graphTools.js +195 -0
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -11
- package/dist/llm/tools/processTool.d.ts +2 -1081
- package/dist/llm/tools/replaceInFiles.js +5 -0
- package/dist/llm/tools/shellTool.d.ts +2 -1513
- package/dist/llm/tools/storedOutputTool.d.ts +2 -355
- package/dist/llm/tools/taskTool.d.ts +2 -489
- package/dist/llm/tools/toolContext.js +24 -9
- package/dist/llm/tools/toolContextState.d.ts +3 -0
- package/dist/llm/tools/toolContextState.js +2 -1
- package/dist/skills/skillTools.js +4 -1
- package/package.json +24 -15
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useReducer, useRef, useState } from 'react';
|
|
3
3
|
import { Box, render, Static, Text, useApp, useWindowSize } from 'ink';
|
|
4
|
-
import { StatusNotice } from '../../ui/components/NativeIndicators.js';
|
|
4
|
+
import { ActivitySpinner, StatusNotice } from '../../ui/components/NativeIndicators.js';
|
|
5
5
|
import { BusyBar } from '../chat/BusyBar.js';
|
|
6
6
|
import { readContextFiles } from '../../config/contextFiles.js';
|
|
7
7
|
import { addInputHistoryItem, readInputHistory } from '../../config/inputHistory.js';
|
|
8
8
|
import { loadTasks as loadTasksFromStore, clearTasks as clearTasksFromStore } from '../../core/tasks/taskStorage.js';
|
|
9
9
|
import { readSettings, updateSettings } from '../../config/settings.js';
|
|
10
|
-
import { activeModel } from '../../config/providers.js';
|
|
10
|
+
import { activeModel, providerEndpointFingerprint, resolveModelSelector } from '../../config/providers.js';
|
|
11
11
|
import { isSkillEnabled } from '../../config/skillSettings.js';
|
|
12
12
|
import { Header } from '../../ui/components/Header.js';
|
|
13
13
|
import { TextInput } from '../../ui/components/TextInput.js';
|
|
@@ -33,18 +33,20 @@ import { createWizardDispatch, initialWizardUiState, wizardUiReducer } from '../
|
|
|
33
33
|
import { buildContextReport } from '../chat/contextReport.js';
|
|
34
34
|
import { TIPS, randomTipIndex, tipsEnabled } from '../chat/tips.js';
|
|
35
35
|
import { fileMentionSuggestions } from '../chat/fileMentionSuggestions.js';
|
|
36
|
-
import { compactHomePath, statusBarMetrics } from '../chat/chatMetrics.js';
|
|
36
|
+
import { busyDetailLabel, compactHomePath, nextFleetStatus, statusBarMetrics } from '../chat/chatMetrics.js';
|
|
37
37
|
import { formatTokenCount } from '../../utils/format.js';
|
|
38
38
|
import { accumulateTokenUsage, EMPTY_TOKEN_USAGE, shouldClearCompletedTasks } from '../chat/turnState.js';
|
|
39
39
|
import { MASKED_MODES, PICKER_MODES, SUBMIT_EMPTY_MODES, placeholderForMode } from './chatModes.js';
|
|
40
40
|
import { contextFileSignatureMap, isPausedGoalRecoveryCommand, mergeSettingsSelection, prepareUserInput as prepareUserInputPolicy, resumeKindFor } from '../chat/userInput.js';
|
|
41
41
|
import { isStoredReasoning, resolveReasoningChoice } from '../../core/agent/reasoningPolicy.js';
|
|
42
|
+
import { resolveProviderReasoning } from '../../config/providerReasoning.js';
|
|
42
43
|
import { inputSuggestionsForState } from '../chat/inputSuggestions.js';
|
|
43
44
|
import { currentBranchName, runStartupSequence } from '../chat/startupSequence.js';
|
|
44
45
|
import { useFollowUpQueue } from '../chat/followUpQueue.js';
|
|
45
46
|
import { useBusyIndicator } from '../chat/busyIndicator.js';
|
|
46
47
|
import { useTerminalControl } from '../chat/terminalControl.js';
|
|
47
48
|
import { modelThinkingLabel } from '../../utils/modelName.js';
|
|
49
|
+
import { transitionProviderConversation } from '../../core/agent/providerTransition.js';
|
|
48
50
|
import { commandParts } from './wizardFlow.js';
|
|
49
51
|
import { backgroundProcessCount, subscribeBackgroundProcesses, teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
|
|
50
52
|
import { MAX_SESSION_PICKER_RESULTS } from './sessionPicker.js';
|
|
@@ -78,21 +80,31 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
78
80
|
const settingsRef = useRef({});
|
|
79
81
|
const defaultSelectionRef = useRef({});
|
|
80
82
|
function setSettings(next, patch) {
|
|
83
|
+
const previousSelection = currentModelSelection();
|
|
84
|
+
const previousProvider = activeModel(settingsRef.current)?.provider;
|
|
81
85
|
// The ref records the global default from `next` (what updateSettings
|
|
82
86
|
// returned) before the patch merge; unrelated settings writes must not
|
|
83
87
|
// replace a resumed session's model (merge policy in chat/userInput.ts).
|
|
84
88
|
defaultSelectionRef.current = { provider: next.provider, model: next.model };
|
|
85
89
|
settingsRef.current = patch ? mergeSettingsSelection(next, settingsRef.current, patch) : next;
|
|
90
|
+
const selected = currentModelSelection();
|
|
91
|
+
const selectedProvider = activeModel(settingsRef.current)?.provider;
|
|
92
|
+
const changedEndpoint = selectedProvider && (!previousProvider || previousProvider.url !== selectedProvider.url || previousProvider.kind !== selectedProvider.kind);
|
|
93
|
+
if (patch && previousSelection && selected && (previousSelection.provider !== selected.provider || previousSelection.model !== selected.model || changedEndpoint) && conversationRef.current.length) {
|
|
94
|
+
conversationRef.current = transitionProviderConversation(conversationRef.current);
|
|
95
|
+
sessionRecorderRef.current?.recordModelTransition(conversationRef.current, selected);
|
|
96
|
+
setMessages(messages => [...messages, { role: 'system', text: 'Model changed: previous tool history was converted to text and provider reasoning state was cleared.' }]);
|
|
97
|
+
}
|
|
86
98
|
setSettingsRaw(settingsRef.current);
|
|
87
99
|
if (patch && ('provider' in patch || 'model' in patch)) {
|
|
88
|
-
const selected = currentModelSelection();
|
|
89
100
|
if (selected)
|
|
90
101
|
sessionRecorderRef.current?.recordModelSelection(selected);
|
|
91
102
|
}
|
|
92
103
|
}
|
|
93
104
|
function currentModelSelection() {
|
|
94
105
|
const { provider, model } = settingsRef.current;
|
|
95
|
-
|
|
106
|
+
const selected = activeModel(settingsRef.current);
|
|
107
|
+
return provider && model ? { provider, model, ...(selected ? { endpointFingerprint: providerEndpointFingerprint(selected.provider) } : {}) } : undefined;
|
|
96
108
|
}
|
|
97
109
|
const [settingsError, setSettingsError] = useState();
|
|
98
110
|
const conversationRef = useRef([]);
|
|
@@ -139,6 +151,9 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
139
151
|
// the developer always sees rolling activity (elapsed turn time) even when
|
|
140
152
|
// the model is thinking with no streamed output and no tool is running.
|
|
141
153
|
const { busy, setBusy: setBusyWithHeartbeat, elapsed: busyElapsed } = useBusyIndicator();
|
|
154
|
+
// Fleet depth for the busy row; folded from coordinator events so a
|
|
155
|
+
// minutes-long fan-out turn visibly progresses (workers running/queued).
|
|
156
|
+
const [fleet, setFleet] = useState(undefined);
|
|
142
157
|
const terminalControl = useTerminalControl();
|
|
143
158
|
const [backgroundCount, setBackgroundCount] = useState(backgroundProcessCount);
|
|
144
159
|
const [busyLabel, setBusyLabel] = useState(() => thinkingLabelForSettings(settings));
|
|
@@ -153,6 +168,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
153
168
|
const [pausedResume, setPausedResume] = useState(undefined);
|
|
154
169
|
const [skills, setSkills] = useState([]);
|
|
155
170
|
const [branchName, setBranchName] = useState();
|
|
171
|
+
const [graphBuilding, setGraphBuilding] = useState(false);
|
|
156
172
|
const shutdownRef = useRef(undefined);
|
|
157
173
|
if (!shutdownRef.current)
|
|
158
174
|
shutdownRef.current = createChatShutdown({
|
|
@@ -239,6 +255,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
239
255
|
initializeSession: () => sessionLifecycle.initializeSession(),
|
|
240
256
|
refreshSkills,
|
|
241
257
|
addSystemMessage: text => setMessages(m => [...m, { role: 'system', text }]),
|
|
258
|
+
onGraphActivity: setGraphBuilding,
|
|
242
259
|
}).catch(() => undefined);
|
|
243
260
|
readInputHistory().then(setInputHistory).catch(() => undefined);
|
|
244
261
|
loadTasksFromStore().then(setVisibleTasks).catch(() => undefined);
|
|
@@ -308,8 +325,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
308
325
|
debug,
|
|
309
326
|
contextFiles: () => contextFiles,
|
|
310
327
|
modelSelection: currentModelSelection,
|
|
328
|
+
reasoningByModel: () => currentPromptSession().reasoningByModel,
|
|
311
329
|
onModelSelection: selection => {
|
|
312
|
-
|
|
330
|
+
const model = selection ? { provider: selection.provider, model: selection.model } : defaultSelectionRef.current;
|
|
331
|
+
settingsRef.current = { ...settingsRef.current, ...model };
|
|
313
332
|
setSettingsRaw(settingsRef.current);
|
|
314
333
|
},
|
|
315
334
|
sessionRef,
|
|
@@ -620,6 +639,11 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
620
639
|
conversationRef.current = msgs;
|
|
621
640
|
sessionRecorder.recordConversation(msgs);
|
|
622
641
|
},
|
|
642
|
+
onModelTransition: (selector, msgs) => {
|
|
643
|
+
const resolved = resolveModelSelector(settingsRef.current, selector);
|
|
644
|
+
if (resolved.status === 'found')
|
|
645
|
+
sessionRecorder.recordModelTransition(msgs, { provider: resolved.provider.name, model: resolved.model, endpointFingerprint: providerEndpointFingerprint(resolved.provider) });
|
|
646
|
+
},
|
|
623
647
|
setBusy: setBusyWithHeartbeat,
|
|
624
648
|
setBusyLabel,
|
|
625
649
|
debugLog,
|
|
@@ -642,6 +666,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
642
666
|
},
|
|
643
667
|
onEvent: event => {
|
|
644
668
|
sessionRecorder.recordEvent(event);
|
|
669
|
+
if (event.type === 'subagent_state')
|
|
670
|
+
setFleet(current => nextFleetStatus(current, event));
|
|
671
|
+
else if (event.type === 'goal_end')
|
|
672
|
+
setFleet(undefined);
|
|
645
673
|
},
|
|
646
674
|
onTasksChanged: () => {
|
|
647
675
|
loadTasksFromStore().then(t => {
|
|
@@ -688,6 +716,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
688
716
|
}
|
|
689
717
|
const visible = messages.filter(message => !message.hidden);
|
|
690
718
|
const activeLiveMessages = liveMessages.filter(message => !message.hidden);
|
|
719
|
+
// Recomputed each busy heartbeat (1 Hz) alongside the elapsed label; the
|
|
720
|
+
// streaming-rate estimate rides the already-live message text, so no extra
|
|
721
|
+
// timer or token bookkeeping is introduced.
|
|
722
|
+
const busyDetail = busy ? busyDetailLabel({ messages: activeLiveMessages, fleet }) : undefined;
|
|
691
723
|
const { staticItems: staticTranscriptItems, streamingItems } = partitionDisplayMessages([...visible, ...activeLiveMessages]);
|
|
692
724
|
const activeSelection = activeModel(settings);
|
|
693
725
|
const placeholder = placeholderForMode(mode, busy);
|
|
@@ -706,7 +738,9 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
706
738
|
const reasoningSuffix = effectiveReasoning
|
|
707
739
|
? effectiveReasoning.level === undefined
|
|
708
740
|
? ' (no reasoning parameter)'
|
|
709
|
-
:
|
|
741
|
+
: activeSelection && resolveProviderReasoning(activeSelection.provider, activeSelection.model, effectiveReasoning.level).effective === 'disabled'
|
|
742
|
+
? ' (provider default)'
|
|
743
|
+
: ` (${effectiveReasoning.level})`
|
|
710
744
|
: '';
|
|
711
745
|
const headerSubtitle = (_jsxs(Text, { children: ['A minimal coding agent for your terminal.\n\nStart with chat. Turn repeated work into Markdown skills:\n', _jsx(Text, { color: theme.command, children: "/skills" }), ' — create, enable, disable, validate, or remove skills.\n\nType ', _jsx(Text, { color: theme.command, children: "@" }), ' to browse workspace files. To grant read-only access to a file or directory outside the workspace for this turn, mention a path containing ', _jsx(Text, { color: theme.command, children: "/" }), ' (for example, ', _jsx(Text, { color: theme.command, children: "@../shared/file.ts" }), ' or ', _jsx(Text, { color: theme.command, children: "/tmp/reference.md" }), ').\n\nImage mentions require a vision-capable model. File edits and writes stay inside the workspace.\n\nhaze runs tool calls without confirmation gates. Supervise consequential work as you would any shell session.\n\nShape haze around your workflow as you go.\n\nUse ', _jsx(Text, { color: theme.command, children: "/help" }), ' for commands.'] }));
|
|
712
746
|
const workspaceLabel = `${compactHomePath(process.cwd())}${branchName ? ` (${branchName})` : ''}`;
|
|
@@ -741,8 +775,9 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
|
|
|
741
775
|
})()] }) : undefined,
|
|
742
776
|
queue: followUps.queued.length > 0 ? _jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: ["Queued follow-ups: ", followUps.queued.length] }), followUps.queued.map((item, index) => _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: [index + 1, ". ", item] }, `${index}-${item}`))] }) : undefined,
|
|
743
777
|
tasks: visibleTasks.length > 0 ? _jsx(TaskBar, { tasks: visibleTasks, width: contentWidth, expanded: tasksExpanded, padding: taskBarPadding, maxRows: Math.max(1, terminalRows - 8) }) : undefined,
|
|
744
|
-
activity: busy ? _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, tip: showingTip ? TIPS[tipIndex] : undefined })
|
|
745
|
-
:
|
|
778
|
+
activity: busy ? _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, detail: busyDetail, tip: showingTip ? TIPS[tipIndex] : undefined })
|
|
779
|
+
: graphBuilding ? _jsxs(Box, { overflow: "hidden", children: [_jsx(ActivitySpinner, {}), _jsx(Box, { flexShrink: 0, width: 1 }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: "Building code graph in the background\u2026" })] })
|
|
780
|
+
: pausedResume ? _jsxs(StatusNotice, { variant: "warning", children: ["Press R to resume \u00B7 unfinished goal paused", pausedResume.pauseReason ? ` (${pausedResume.pauseReason})` : ''] }) : undefined,
|
|
746
781
|
status: _jsxs(_Fragment, { children: [_jsxs(Box, { width: "100%", flexDirection: "row", justifyContent: "space-between", flexShrink: 0, children: [_jsx(Text, { color: theme.muted, wrap: "truncate-end", children: workspaceLabel }), _jsxs(Text, { color: theme.muted, wrap: "truncate-start", children: [activeModelName, reasoningSuffix] })] }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: metrics.statusDetailLabel })] }),
|
|
747
782
|
}, input: ({ width: inputWidth, inputRows, suggestionRows, onRowsChange }) => _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: inputWidth, inputRows: inputRows, suggestionRows: suggestionRows, onRowsChange: onRowsChange, getMentionSuggestions: fileMentionSuggestions, onHistoryAdd: persistInputHistory, onToggleTasks: () => {
|
|
748
783
|
if (!tasksExpanded) {
|
|
@@ -9,9 +9,9 @@ export const COMMAND_HELP_ENTRIES = [
|
|
|
9
9
|
{ usage: '/settings edit', description: 'Open ~/.haze/settings.json in $VISUAL/$EDITOR in a fullscreen terminal handoff; falls back to the OS default app when no editor is configured. Restart haze to apply external changes.' },
|
|
10
10
|
{ usage: '/themes', description: 'Choose a terminal theme from the built-in registry (light palettes and oh-my-zsh ports included); applies immediately.' },
|
|
11
11
|
{ usage: '/themes <name>', description: 'Set the theme directly, e.g. /themes robbyrussell. Saved to ~/.haze/settings.json; text already on screen keeps its old colors.' },
|
|
12
|
-
{ usage: '/reasoning', description: 'Choose a reasoning effort level (none, minimal, low, medium, high, xhigh) for the active model, for this session; unset sends no parameter, reset falls back to the saved/default level.' },
|
|
12
|
+
{ usage: '/reasoning', description: 'Choose a reasoning effort level (none, minimal, low, medium, high, xhigh, max) for the active model, for this session; unset sends no parameter, reset falls back to the saved/default level.' },
|
|
13
13
|
{ usage: '/reasoning <level|unset|reset|status>', description: 'Set the reasoning effort for the active model for this session, send no parameter with unset, remove the override with reset, or show the current level with status. Low is the default. Endpoints without native support ignore the parameter.' },
|
|
14
|
-
{ usage: '/thinking', description: 'Alias for /reasoning. Choose a reasoning effort level (none, minimal, low, medium, high, xhigh) for the active model, for this session; unset sends no parameter, reset falls back to the saved/default level.' },
|
|
14
|
+
{ usage: '/thinking', description: 'Alias for /reasoning. Choose a reasoning effort level (none, minimal, low, medium, high, xhigh, max) for the active model, for this session; unset sends no parameter, reset falls back to the saved/default level.' },
|
|
15
15
|
{ usage: '/thinking <level|unset|reset|status>', description: 'Alias for /reasoning. Set the reasoning effort for the active model for this session, send no parameter with unset, remove the override with reset, or show the current level with status. Low is the default. Endpoints without native support ignore the parameter.' },
|
|
16
16
|
{ usage: '/skills', description: 'Manage Markdown skills: generate a custom skill, show info, enable/disable, validate, or remove.' },
|
|
17
17
|
{ usage: '/plugin', description: 'Open the plugin picker: install or inspect a local plugin/collection, or manage installed project plugins. /kit is an alias.' },
|
|
@@ -19,7 +19,7 @@ export const COMMAND_HELP_ENTRIES = [
|
|
|
19
19
|
{ usage: '/plugin list|remove <name>', description: 'List project-installed plugins or remove one, preserving modified and seed files. /kit is an alias.' },
|
|
20
20
|
{ usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
|
|
21
21
|
{ usage: '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>', description: 'Run genuinely independent tasks through disposable contexts. Runtime enforces profile concurrency, deadlines, and mutation serialization; control guidance is not persisted. Declines non-parallel work.' },
|
|
22
|
-
{ usage: '/init', description: 'Inspect the current workspace
|
|
22
|
+
{ usage: '/init', description: 'Inspect the current workspace, create or update AGENTS.md project instructions, and build/refresh the workspace code graph.' },
|
|
23
23
|
{ usage: '/context', description: 'Show a token breakdown of the current request: system prompt, project context, tools (incl. MCP), and chat messages.' },
|
|
24
24
|
{ usage: '/session', description: 'Show the current durable session file.' },
|
|
25
25
|
{ usage: '/resume [id]', description: 'Browse this workspace’s saved sessions, or resume an exact session id.' },
|
|
@@ -27,6 +27,9 @@ export const COMMAND_HELP_ENTRIES = [
|
|
|
27
27
|
{ usage: '/logs', description: 'List recent log files with sizes and dates.' },
|
|
28
28
|
{ usage: '/lsp', description: 'Configure Language Server Protocol navigation tools (interactive picker).' },
|
|
29
29
|
{ usage: '/mcp', description: 'Configure Model Context Protocol servers like Context7 (interactive picker).' },
|
|
30
|
+
{ usage: '/graph', description: 'Build or refresh the persistent workspace code graph (deterministic tree-sitter extraction, incremental after the first build) and show an orientation report: subsystems, hub symbols, import cycles.' },
|
|
31
|
+
{ usage: '/graph status', description: 'Show the current code graph state (nodes, edges, build time, staleness) without rebuilding. /graph force rebuilds from scratch.' },
|
|
32
|
+
{ usage: '/graph delete', description: 'Delete the persisted workspace code graph (rebuilt on the next /graph).' },
|
|
30
33
|
{ usage: '/logs <id>', description: 'Show summary of a specific log: entry counts by type, total tokens, tool calls.' },
|
|
31
34
|
{ usage: '/logs <id> view', description: 'Page the raw log JSONL through $PAGER in a fullscreen terminal handoff.' },
|
|
32
35
|
{ usage: '/editor', description: 'Compose a prompt in $EDITOR, then submit it as the next message.' },
|
|
@@ -6,6 +6,7 @@ import { COMMAND_HELP_ENTRIES, formatCommandHelp } from './commandHelp.js';
|
|
|
6
6
|
import { handleFleetCommand } from './fleetCommand.js';
|
|
7
7
|
import { handleInitCommand } from './initCommand.js';
|
|
8
8
|
import { handleLogsCommand } from './logsCommand.js';
|
|
9
|
+
import { handleGraphCommand } from './graphCommand.js';
|
|
9
10
|
import { handleModelCommand } from './modelCommand.js';
|
|
10
11
|
import { handleReasoningCommand } from './reasoningCommand.js';
|
|
11
12
|
import { handleThemesCommand } from './themesCommand.js';
|
|
@@ -87,6 +88,7 @@ const SLASH_COMMANDS = [
|
|
|
87
88
|
{ match: exactOrArgs('/reasoning'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
|
|
88
89
|
{ match: exactOrArgs('/thinking'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
|
|
89
90
|
{ match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
|
|
91
|
+
{ match: exactOrArgs('/graph'), run: async (args, ctx) => await handleGraphCommand(args, ctx) },
|
|
90
92
|
];
|
|
91
93
|
export async function handleSlashCommand(value, ctx) {
|
|
92
94
|
for (const command of SLASH_COMMANDS) {
|
|
@@ -77,6 +77,14 @@ function toolCallSummaryText(toolName, input) {
|
|
|
77
77
|
return `lspDiagnostics ${data.path}`;
|
|
78
78
|
if ((toolName === 'lspDefinition' || toolName === 'lspTypeDefinition' || toolName === 'lspImplementation' || toolName === 'lspReferences') && typeof data?.path === 'string')
|
|
79
79
|
return `${toolName} ${data.path}:${data.line}:${data.column}`;
|
|
80
|
+
if (toolName === 'graphQuery' && typeof data?.question === 'string')
|
|
81
|
+
return `map: query "${compact(data.question, 60)}"`;
|
|
82
|
+
if ((toolName === 'graphExplain' || toolName === 'graphAffected') && typeof data?.symbol === 'string')
|
|
83
|
+
return `map: ${toolName === 'graphExplain' ? 'explain' : 'affected'} ${data.symbol}`;
|
|
84
|
+
if (toolName === 'graphPath' && typeof data?.from === 'string' && typeof data?.to === 'string')
|
|
85
|
+
return `map: path ${data.from} -> ${data.to}`;
|
|
86
|
+
if (toolName === 'graphRebuild')
|
|
87
|
+
return 'map: rebuild';
|
|
80
88
|
return `${toolName} ${compact(input)}`;
|
|
81
89
|
}
|
|
82
90
|
/**
|
|
@@ -138,6 +146,19 @@ function toolResultSummaryText(event) {
|
|
|
138
146
|
const count = output.locations.length;
|
|
139
147
|
return `${count} location${count === 1 ? '' : 's'} from ${output.server}`;
|
|
140
148
|
}
|
|
149
|
+
if (typeof output?.answer === 'string' && typeof output?.graph === 'object') {
|
|
150
|
+
// graphQuery/graphPath answers
|
|
151
|
+
const stale = output.graph.stale === true ? ' · stale graph' : '';
|
|
152
|
+
const seeds = typeof output.seeds === 'number' ? `${output.seeds} seed${output.seeds === 1 ? '' : 's'}` : typeof output.hops === 'number' ? `${output.hops} hop${output.hops === 1 ? '' : 's'}` : '';
|
|
153
|
+
return `${seeds}${stale}: ${compact(output.answer, 120)}`;
|
|
154
|
+
}
|
|
155
|
+
if (Array.isArray(output?.affected) && typeof output.symbol === 'string') {
|
|
156
|
+
const count = output.affected.length;
|
|
157
|
+
return count === 0 ? `no reverse relationships for ${output.symbol}` : `${count} affected by ${output.symbol}`;
|
|
158
|
+
}
|
|
159
|
+
if (typeof output?.nodes === 'number' && typeof output?.edges === 'number' && output?.toolName === 'graphRebuild') {
|
|
160
|
+
return `graph built: ${output.nodes} nodes · ${output.edges} edges · ${output.files} files`;
|
|
161
|
+
}
|
|
141
162
|
if (typeof output?.ok === 'boolean') {
|
|
142
163
|
// writeTasks result
|
|
143
164
|
if (output.ok && typeof output.summary === 'string') {
|
|
@@ -213,6 +234,13 @@ export function busyToolLabel(toolName, input) {
|
|
|
213
234
|
return 'Running subagent';
|
|
214
235
|
case 'writeTasks':
|
|
215
236
|
return 'Updating tasks';
|
|
237
|
+
case 'graphQuery':
|
|
238
|
+
case 'graphExplain':
|
|
239
|
+
case 'graphPath':
|
|
240
|
+
case 'graphAffected':
|
|
241
|
+
return 'Querying code graph';
|
|
242
|
+
case 'graphRebuild':
|
|
243
|
+
return 'Building code graph';
|
|
216
244
|
case 'skill':
|
|
217
245
|
return 'Loading skill';
|
|
218
246
|
default:
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/graph` — build or refresh the workspace code graph and print the
|
|
3
|
+
* orientation report (subsystems, hub symbols, import cycles).
|
|
4
|
+
*
|
|
5
|
+
* `/graph status` only reports the current graph state without rebuilding.
|
|
6
|
+
* `/graph force` rebuilds from scratch. `/graph delete` removes the persisted
|
|
7
|
+
* graph for this workspace. Deterministic tree-sitter extraction; no LLM cost.
|
|
8
|
+
*/
|
|
9
|
+
import { buildGraphIndex } from '../../core/graph/model.js';
|
|
10
|
+
import { deleteGraph, graphStatus, graphStoreFor } from '../../core/graph/store.js';
|
|
11
|
+
import { buildWorkspaceGraph } from '../../core/graph/buildGraph.js';
|
|
12
|
+
import { renderGraphReport } from '../../core/graph/analyze.js';
|
|
13
|
+
import { workspaceRoot } from '../../utils/path.js';
|
|
14
|
+
export async function handleGraphCommand(args, ctx) {
|
|
15
|
+
const store = graphStoreFor(workspaceRoot());
|
|
16
|
+
const arg = args.trim();
|
|
17
|
+
if (arg === 'status') {
|
|
18
|
+
const status = await graphStatus(store);
|
|
19
|
+
if (!status.exists) {
|
|
20
|
+
ctx.addSystemMessage('No code graph for this workspace yet. Run /graph to build one (deterministic, no LLM cost).');
|
|
21
|
+
return 'handled';
|
|
22
|
+
}
|
|
23
|
+
const builtAt = status.builtAt ? new Date(status.builtAt).toISOString().replace('T', ' ').slice(0, 16) : 'unknown';
|
|
24
|
+
ctx.addSystemMessage([
|
|
25
|
+
`Code graph: ${status.nodeCount} nodes · ${status.edgeCount} edges · ${status.fileCount} files`,
|
|
26
|
+
`Built at ${builtAt} (UTC)${status.stale ? ' · STALE: files changed since; run /graph to refresh' : ' · fresh'}`,
|
|
27
|
+
].join('\n'));
|
|
28
|
+
return 'handled';
|
|
29
|
+
}
|
|
30
|
+
if (arg === 'delete') {
|
|
31
|
+
const removed = await deleteGraph(store);
|
|
32
|
+
ctx.addSystemMessage(removed
|
|
33
|
+
? 'Deleted the code graph for this workspace. Run /graph to rebuild it.'
|
|
34
|
+
: 'No code graph for this workspace; nothing to delete.');
|
|
35
|
+
return 'handled';
|
|
36
|
+
}
|
|
37
|
+
const force = arg === 'force';
|
|
38
|
+
ctx.addSystemMessage(force ? 'Rebuilding the code graph from scratch…' : 'Building the code graph…');
|
|
39
|
+
try {
|
|
40
|
+
const result = await buildWorkspaceGraph({ force });
|
|
41
|
+
if (result.graph.nodes.length === 0) {
|
|
42
|
+
ctx.addSystemMessage('No supported source files found (js/ts/tsx/jsx). Nothing to map.');
|
|
43
|
+
return 'handled';
|
|
44
|
+
}
|
|
45
|
+
const report = renderGraphReport(buildGraphIndex(result.graph), {
|
|
46
|
+
graph: result.graph,
|
|
47
|
+
files: result.files,
|
|
48
|
+
parsedFiles: result.parsedFiles,
|
|
49
|
+
cachedFiles: result.cachedFiles,
|
|
50
|
+
durationMs: result.durationMs,
|
|
51
|
+
stale: false,
|
|
52
|
+
});
|
|
53
|
+
ctx.addSystemMessage(report);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
ctx.addSystemMessage(`Code graph build failed: ${message}`);
|
|
58
|
+
}
|
|
59
|
+
return 'handled';
|
|
60
|
+
}
|
|
@@ -3,6 +3,7 @@ import { pathExists } from '../../utils/fs.js';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { MAX_CONTEXT_FILE_CHARS } from '../../config/contextFiles.js';
|
|
5
5
|
import { buildInitPrompt } from '../../llm/initPrompt.js';
|
|
6
|
+
import { buildWorkspaceGraph } from '../../core/graph/buildGraph.js';
|
|
6
7
|
export async function handleInitCommand(ctx) {
|
|
7
8
|
await ctx.runAgentTurn(buildInitPrompt(), '/init');
|
|
8
9
|
await ctx.refreshContextFiles();
|
|
@@ -16,5 +17,18 @@ export async function handleInitCommand(ctx) {
|
|
|
16
17
|
: `AGENTS.md validation: ${chars.toLocaleString()} chars / ${lines} lines — within the ${MAX_CONTEXT_FILE_CHARS.toLocaleString()}-char context budget.`;
|
|
17
18
|
ctx.addSystemMessage(msg);
|
|
18
19
|
}
|
|
20
|
+
// /init also builds/refreshes the workspace code graph so graph tools work
|
|
21
|
+
// from the start; incremental, deterministic, no LLM cost. Failures never
|
|
22
|
+
// block /init — the model can rebuild later via graphRebuild or /graph.
|
|
23
|
+
try {
|
|
24
|
+
const graph = await buildWorkspaceGraph();
|
|
25
|
+
if (graph.graph.nodes.length > 0) {
|
|
26
|
+
ctx.addSystemMessage(`Code graph: ${graph.graph.nodes.length} nodes · ${graph.graph.edges.length} edges · ${graph.files} files (${(graph.durationMs / 1000).toFixed(1)}s, ${graph.cachedFiles} cached / ${graph.parsedFiles} parsed).`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
31
|
+
ctx.addSystemMessage(`Code graph build skipped: ${message}`);
|
|
32
|
+
}
|
|
19
33
|
return 'handled';
|
|
20
34
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { configuredProviders, findProvider, upsertProvider } from '../../config/providers.js';
|
|
2
2
|
import { PROVIDER_ACTIONS, commaList } from './wizardFlow.js';
|
|
3
3
|
import { assertCredentialedEndpointSecure } from '../../config/endpointSecurity.js';
|
|
4
|
-
import { presetModelLimitsForModels } from '../../config/providerPresets.js';
|
|
5
4
|
import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
|
|
6
5
|
/**
|
|
7
6
|
* Warning when a `chatgpt-codex` provider's configured URL diverges from the
|
|
@@ -13,13 +12,12 @@ export function chatgptCodexUrlWarning(provider) {
|
|
|
13
12
|
return undefined;
|
|
14
13
|
return `Note: ${provider.name} uses ChatGPT sign-in, which always sends requests to ${CHATGPT_CODEX_BASE_URL}. The configured URL (${provider.url}) is ignored for requests.`;
|
|
15
14
|
}
|
|
16
|
-
/**
|
|
17
|
-
function mergedModelLimits(
|
|
18
|
-
const
|
|
15
|
+
/** Refresh discovered facts field by field without touching explicit user limits. */
|
|
16
|
+
function mergedModelLimits(models, discovered, existing) {
|
|
17
|
+
const merged = { ...existing };
|
|
19
18
|
for (const model of models)
|
|
20
19
|
if (discovered?.[model])
|
|
21
|
-
|
|
22
|
-
const merged = { ...curated, ...discoveredSubset, ...existing };
|
|
20
|
+
merged[model] = { ...merged[model], ...discovered[model] };
|
|
23
21
|
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
24
22
|
}
|
|
25
23
|
export function providerAppendModels(settings, providerName, modelsValue, discoveredLimits) {
|
|
@@ -29,14 +27,9 @@ export function providerAppendModels(settings, providerName, modelsValue, discov
|
|
|
29
27
|
return { message: 'No provider selected.' };
|
|
30
28
|
if (models.length === 0)
|
|
31
29
|
return { provider, models, message: 'Enter at least one model name.' };
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// (this is the only source that knows a local server's configured window);
|
|
36
|
-
// existing user-configured keys always win over both.
|
|
37
|
-
const curatedLimits = presetModelLimitsForModels({ name: provider.name, url: provider.url }, models);
|
|
38
|
-
const modelLimits = mergedModelLimits(curatedLimits, models, discoveredLimits, provider.modelLimits);
|
|
39
|
-
const nextProvider = { ...provider, models: [...new Set([...provider.models, ...models])], ...(modelLimits ? { modelLimits } : {}) };
|
|
30
|
+
// Keep discovery separate so later refreshes do not overwrite user limits.
|
|
31
|
+
const discoveredModelLimits = mergedModelLimits(models, discoveredLimits, provider.discoveredModelLimits);
|
|
32
|
+
const nextProvider = { ...provider, models: [...new Set([...provider.models, ...models])], ...(discoveredModelLimits ? { discoveredModelLimits } : {}) };
|
|
40
33
|
return {
|
|
41
34
|
provider,
|
|
42
35
|
models,
|
|
@@ -55,15 +48,14 @@ export function providerFinishAdd(settings, draft, modelsValue, discoveredLimits
|
|
|
55
48
|
catch (error) {
|
|
56
49
|
return { models, message: error instanceof Error ? error.message : String(error) };
|
|
57
50
|
}
|
|
58
|
-
const
|
|
59
|
-
const modelLimits = mergedModelLimits(curatedLimits, models, discoveredLimits, undefined);
|
|
51
|
+
const discoveredModelLimits = mergedModelLimits(models, discoveredLimits, undefined);
|
|
60
52
|
const provider = {
|
|
61
53
|
name: draft.name,
|
|
62
54
|
url: draft.url,
|
|
63
55
|
...(draft.key ? { key: draft.key } : {}),
|
|
64
56
|
...(draft.kind ? { kind: draft.kind } : {}),
|
|
65
57
|
models: [...new Set(models)],
|
|
66
|
-
...(
|
|
58
|
+
...(discoveredModelLimits ? { discoveredModelLimits } : {}),
|
|
67
59
|
};
|
|
68
60
|
const divergence = chatgptCodexUrlWarning(provider);
|
|
69
61
|
return {
|
|
@@ -25,5 +25,6 @@ export declare function resolveReasoningCommand(args: string, input: {
|
|
|
25
25
|
current: ResolvedReasoningChoice;
|
|
26
26
|
stored: StoredReasoningSetting | undefined;
|
|
27
27
|
modelSelector?: string;
|
|
28
|
+
supportedLevels?: readonly import('../../core/agent/reasoningPolicy.js').ReasoningLevel[];
|
|
28
29
|
}): ReasoningCommandResult;
|
|
29
30
|
export declare function handleReasoningCommand(args: string, ctx: CommandContext): Promise<CommandResult>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { REASONING_LEVELS, REASONING_PROVIDER_DEFAULT, isReasoningLevel, isReasoningUnsetAlias, isStoredReasoning, resolveReasoningChoice } from '../../core/agent/reasoningPolicy.js';
|
|
2
|
+
import { activeModel } from '../../config/providers.js';
|
|
3
|
+
import { reasoningCapabilitiesForProvider, reasoningLevelsForProvider } from '../../config/providerReasoning.js';
|
|
2
4
|
/**
|
|
3
5
|
* `/reasoning` — per-model, per-session reasoning-effort picker and direct
|
|
4
6
|
* set, modeled on `/themes`. The picker is one step in the `wizardFlow.ts`
|
|
@@ -28,7 +30,8 @@ function describeChoice(choice) {
|
|
|
28
30
|
* per-model map (`PromptSession.reasoningByModel`); nothing touches settings.
|
|
29
31
|
*/
|
|
30
32
|
export function resolveReasoningCommand(args, input) {
|
|
31
|
-
const
|
|
33
|
+
const rawValue = args.trim().toLowerCase();
|
|
34
|
+
const value = rawValue === 'off' ? 'none' : rawValue;
|
|
32
35
|
const scope = input.modelSelector ? ` for ${input.modelSelector}` : '';
|
|
33
36
|
if (!value)
|
|
34
37
|
return { action: 'open-picker' };
|
|
@@ -37,7 +40,10 @@ export function resolveReasoningCommand(args, input) {
|
|
|
37
40
|
}
|
|
38
41
|
if (value === REASONING_RESET) {
|
|
39
42
|
const fallback = resolveReasoningChoice(undefined, input.stored);
|
|
40
|
-
|
|
43
|
+
const applied = fallback.level && input.supportedLevels && !input.supportedLevels.includes(fallback.level)
|
|
44
|
+
? `${describeChoice(fallback)} is unsupported; provider default applies`
|
|
45
|
+
: `${describeChoice(fallback)} applies`;
|
|
46
|
+
return { action: 'reset', message: `Session reasoning override removed${scope}. ${applied} from the next turn.` };
|
|
41
47
|
}
|
|
42
48
|
if (isReasoningUnsetAlias(value)) {
|
|
43
49
|
return { action: 'set', setting: REASONING_PROVIDER_DEFAULT, message: `Reasoning effort unset${scope}: no reasoning parameter is sent from the next turn; the provider default applies (this model, this session).` };
|
|
@@ -45,6 +51,8 @@ export function resolveReasoningCommand(args, input) {
|
|
|
45
51
|
if (!isReasoningLevel(value)) {
|
|
46
52
|
return { action: 'error', message: `Unknown reasoning level "${value}". Valid levels: ${LEVELS_LIST} — unset sends no reasoning parameter, reset falls back to the saved/default level.` };
|
|
47
53
|
}
|
|
54
|
+
if (input.supportedLevels && !input.supportedLevels.includes(value))
|
|
55
|
+
return { action: 'error', message: input.supportedLevels.length ? `Supported reasoning levels${scope}: ${input.supportedLevels.join(', ')}. Use /reasoning unset for the provider default.` : `No documented reasoning levels${scope}; use /reasoning unset for the provider default.` };
|
|
48
56
|
return { action: 'set', setting: value, message: `Reasoning effort set to ${value}${scope}. Applies to this model for the current session; each model keeps its own level. Not written to ~/.haze/settings.json.` };
|
|
49
57
|
}
|
|
50
58
|
/** `provider:model` key for the settings-configured active model, or undefined when unconfigured. */
|
|
@@ -56,7 +64,13 @@ export async function handleReasoningCommand(args, ctx) {
|
|
|
56
64
|
const modelSelector = activeModelSelector(ctx);
|
|
57
65
|
if (!args.trim()) {
|
|
58
66
|
ctx.setMode('reasoning');
|
|
59
|
-
|
|
67
|
+
const selected = activeModel(ctx.settings);
|
|
68
|
+
if (selected && reasoningLevelsForProvider(selected.provider, selected.model).length === 0) {
|
|
69
|
+
ctx.addSystemMessage(`No adjustable reasoning levels are known for ${selected.model}. Choose a supported model via /model or configure its reasoning levels; unset sends no parameter.`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
ctx.addSystemMessage('Choose a reasoning effort level for the active model, for this session. unset sends no reasoning parameter (provider default); reset falls back to the saved or default level.');
|
|
73
|
+
}
|
|
60
74
|
return 'handled';
|
|
61
75
|
}
|
|
62
76
|
if (!modelSelector) {
|
|
@@ -65,7 +79,21 @@ export async function handleReasoningCommand(args, ctx) {
|
|
|
65
79
|
}
|
|
66
80
|
const stored = isStoredReasoning(ctx.settings.reasoning) ? ctx.settings.reasoning : undefined;
|
|
67
81
|
const current = resolveReasoningChoice(ctx.getSessionReasoning(modelSelector), stored);
|
|
68
|
-
const
|
|
82
|
+
const active = activeModel(ctx.settings);
|
|
83
|
+
if (active) {
|
|
84
|
+
const { levels, support } = reasoningCapabilitiesForProvider(active.provider, active.model);
|
|
85
|
+
const value = args.trim().toLowerCase() === 'off' ? 'none' : args.trim().toLowerCase();
|
|
86
|
+
if (isReasoningLevel(value) && !levels.includes(value)) {
|
|
87
|
+
ctx.addSystemMessage(levels.length ? `${active.model} supports reasoning levels: ${levels.join(', ')}. Use /reasoning unset for the provider default.` : `Reasoning levels are not documented for ${active.model}; use /reasoning unset for the provider default.`);
|
|
88
|
+
return 'handled';
|
|
89
|
+
}
|
|
90
|
+
if (value === 'status') {
|
|
91
|
+
const applied = current.level && levels.includes(current.level) ? describeChoice(current) : 'provider default (no parameter sent)';
|
|
92
|
+
ctx.addSystemMessage(`Reasoning effort for ${modelSelector}: ${applied}. ${levels.length ? `Supported levels: ${levels.join(', ')}.` : support === 'unknown' ? 'Reasoning support is unknown for this model.' : 'Reasoning effort is unsupported for this model.'}`);
|
|
93
|
+
return 'handled';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const result = resolveReasoningCommand(args, { current, stored, modelSelector, supportedLevels: active ? reasoningLevelsForProvider(active.provider, active.model) : [] });
|
|
69
97
|
if (result.action === 'set')
|
|
70
98
|
ctx.setSessionReasoning(modelSelector, result.setting);
|
|
71
99
|
else if (result.action === 'reset')
|
|
@@ -3,11 +3,12 @@ import { runAgentGoal } from './streaming/goalSupervisor.js';
|
|
|
3
3
|
import { parseReasoningOverride } from '../../core/agent/reasoningPolicy.js';
|
|
4
4
|
import { EMPTY_TOKEN_USAGE, accumulateTokenUsage } from '../chat/turnState.js';
|
|
5
5
|
import { readSettings } from '../../config/settings.js';
|
|
6
|
-
import { activeModel, modelSelector, resolveModelSelector } from '../../config/providers.js';
|
|
6
|
+
import { activeModel, modelSelector, providerEndpointFingerprint, resolveModelSelector } from '../../config/providers.js';
|
|
7
7
|
import { createLog, endLog } from '../../core/log/llmLog.js';
|
|
8
8
|
import { agentEvent } from '../../core/agent/events.js';
|
|
9
9
|
import { findSession, restoreSessionState } from '../../core/session/sessionStore.js';
|
|
10
10
|
import { compactModelMessages } from '../../core/agent/compaction.js';
|
|
11
|
+
import { transitionProviderConversation } from '../../core/agent/providerTransition.js';
|
|
11
12
|
import { FALLBACK_CONTEXT_WINDOW_TOKENS } from '../../core/agent/contextBudget.js';
|
|
12
13
|
import { teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
|
|
13
14
|
import { MAX_TURN_DEADLINE_MS } from '../../core/agent/budgets.js';
|
|
@@ -184,6 +185,11 @@ export async function runHeadless(options) {
|
|
|
184
185
|
const contextFiles = await readContextFiles(process.cwd());
|
|
185
186
|
const session = { start: new Date(), cwd: process.cwd() };
|
|
186
187
|
let conversation = restored?.messages ?? [];
|
|
188
|
+
const endpointChanged = resolvedModel?.status === 'found' && (!savedModel?.endpointFingerprint || savedModel.endpointFingerprint !== providerEndpointFingerprint(resolvedModel.provider));
|
|
189
|
+
if (resumed && sessionModel && ((!savedModel || `${savedModel.provider}:${savedModel.model}` !== sessionModel) || endpointChanged) && conversation.length) {
|
|
190
|
+
conversation = transitionProviderConversation(conversation);
|
|
191
|
+
process.stderr.write('Model changed: previous tool history was converted to text and provider reasoning state was cleared.\n');
|
|
192
|
+
}
|
|
187
193
|
for (const error of restored?.parseErrors ?? [])
|
|
188
194
|
process.stderr.write(`Session parse error: ${error}\n`);
|
|
189
195
|
// Assistant text is delivered in two stages by runAgentTurn: an initial streaming
|
|
@@ -47,7 +47,7 @@ export async function runAgentAttempt(input) {
|
|
|
47
47
|
let stallGuard;
|
|
48
48
|
let setup;
|
|
49
49
|
try {
|
|
50
|
-
setup = await prepareAttempt({ value, contextFiles, callbacks, retryingExistingRequest, overflowShrinkFactor: input.overflowShrinkFactor, session, modelOverride, reasoningOverride, abortController, turnOptions, turnScope, turnBudget, globalBudget, sliceBudget, goal, onContextFileRead: path => toolDisplay.addContextFileRead(path), usageAnchor });
|
|
50
|
+
setup = await prepareAttempt({ value, contextFiles, callbacks, retryingExistingRequest, overflowShrinkFactor: input.overflowShrinkFactor, session, modelOverride, reasoningOverride, abortController, turnOptions, turnScope, turnState, turnBudget, globalBudget, sliceBudget, goal, onContextFileRead: path => toolDisplay.addContextFileRead(path), usageAnchor });
|
|
51
51
|
if (!setup)
|
|
52
52
|
return { status: 'failed' };
|
|
53
53
|
const attemptSetupResult = setup;
|
|
@@ -72,6 +72,16 @@ export async function runAgentAttempt(input) {
|
|
|
72
72
|
debugLog: callbacks.debugLog,
|
|
73
73
|
});
|
|
74
74
|
const stream = await runAttemptStream({ setup, callbacks, abortController, retryAttempt, recoverySlice: turnOptions.recoverySlice, turnState, turnBudget, globalBudget, goal, stallGuard, loopState, toolDisplay, salvage, usageAnchor });
|
|
75
|
+
// An abort that lands in the epoch-boundary window — most easily during
|
|
76
|
+
// mid-turn LLM compaction, whose internal abort is caught — exits the
|
|
77
|
+
// stream loop normally instead of throwing. Route it through the same
|
|
78
|
+
// cause-aware failure classification as a thrown abort, so the recorded
|
|
79
|
+
// cause (user / turn-deadline / idle stall) decides retry, pause, or
|
|
80
|
+
// aborted; a finalize on an aborted controller would otherwise trust the
|
|
81
|
+
// last finish shape and could report a cancelled goal as complete.
|
|
82
|
+
if (abortController.signal.aborted) {
|
|
83
|
+
return handleAttemptFailure({ value, callbacks, abortController, turnState, retryAttempt, progressSinceLastRetry: input.progressSinceLastRetry, overflowRetries: input.overflowRetries, abortCause, stallGuard, salvage, error: new Error('aborted between model steps'), maxRetries: attemptSetupResult.modelRetries, retryBaseDelayMs: attemptSetupResult.retryBaseDelayMs, idleTimeoutMs: attemptSetupResult.streamIdleTimeoutMs, goal, turnOptions });
|
|
84
|
+
}
|
|
75
85
|
return finalizeAttemptOutcome({ value, callbacks, abortController, turnOptions, turnState, turnBudget, goal, remainingTurnDeadlineMs, stream, retryAttempt, overflowRetries: input.overflowRetries });
|
|
76
86
|
}
|
|
77
87
|
catch (error) {
|
|
@@ -48,6 +48,7 @@ export function createQuarantinableCallbacks(callbacks) {
|
|
|
48
48
|
addMessage: whileLive(callbacks.addMessage),
|
|
49
49
|
updateMessage: whileLive(callbacks.updateMessage),
|
|
50
50
|
setConversation: whileLive(callbacks.setConversation),
|
|
51
|
+
onModelTransition: callbacks.onModelTransition && whileLive(callbacks.onModelTransition),
|
|
51
52
|
setBusy: whileLive(callbacks.setBusy),
|
|
52
53
|
setLastAssistantText: whileLive(callbacks.setLastAssistantText),
|
|
53
54
|
setBusyLabel: callbacks.setBusyLabel && whileLive(callbacks.setBusyLabel),
|
|
@@ -70,10 +70,9 @@ export function finalizeAttemptOutcome(deps) {
|
|
|
70
70
|
const completionEvidence = { sawToolCall: stream.sawToolCall, assistantText: stream.assistantText, lastToolOk: stream.lastToolOk, lastFailedToolWasValidation: stream.lastFailedToolWasValidation, unresolvedToolInputError: stream.unresolvedToolInputError };
|
|
71
71
|
const readiness = assessCompletionReadiness(turnState, completionEvidence);
|
|
72
72
|
const classification = classifyTerminalOutcome(turnState, completionEvidence);
|
|
73
|
-
const turnStatus = terminalTurnStatus({ aborted:
|
|
73
|
+
const turnStatus = terminalTurnStatus({ aborted: abortController.signal.aborted, assistantText: stream.assistantText, sawToolCall: stream.sawToolCall, lastToolOk: stream.lastToolOk, lastFailedToolWasValidation: stream.lastFailedToolWasValidation, finishReason: stream.finishReason, budgetReached: turnState.budgetBoundary, unresolvedToolInputError: stream.unresolvedToolInputError, intent: turnState.intent, mutationCount: turnState.mutationCount, validationOutcome: turnState.validationOutcome, taskProgress: turnState.taskProgress, requiresTaskLedger: turnState.requiresTaskLedger, ...(turnState.redPair ? { redPair: turnState.redPair } : {}) });
|
|
74
74
|
if (stream.unresolvedMalformedToolName)
|
|
75
75
|
callbacks.addMessage({ role: 'system', text: `${stream.unresolvedMalformedToolName} did not execute because its generated input remained invalid or truncated${stream.unresolvedMalformedToolProblem ? ` — ${stream.unresolvedMalformedToolProblem}` : ''}. The requested work is incomplete.` });
|
|
76
|
-
goal.phase = 'done';
|
|
77
76
|
// Non-error overflow recovery (Pillar 1.2/1.4): a silent overflow completed
|
|
78
77
|
// its response, so compact only — the next physical turn (or the supervisor)
|
|
79
78
|
// continues from the smaller history; a length-stop overflow dropped the
|
|
@@ -161,6 +160,11 @@ export function finalizeAttemptOutcome(deps) {
|
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
}
|
|
163
|
+
// Terminal state: reached only when the attempt neither retries, proposes a
|
|
164
|
+
// recovery slice, nor checkpoints — so the goal is genuinely finished. Set the
|
|
165
|
+
// 'done' phase here (not unconditionally at the top) so retry, continue, and
|
|
166
|
+
// checkpoint paths keep the goal active.
|
|
167
|
+
goal.phase = 'done';
|
|
164
168
|
return { status: turnStatus };
|
|
165
169
|
}
|
|
166
170
|
/**
|