@denizokcu/haze 1.7.9 → 1.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +22 -8
  3. package/dist/buildInfo.json +3 -3
  4. package/dist/cli/chat/BusyBar.d.ts +2 -1
  5. package/dist/cli/chat/BusyBar.js +2 -2
  6. package/dist/cli/chat/chatMetrics.d.ts +25 -0
  7. package/dist/cli/chat/chatMetrics.js +36 -0
  8. package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
  9. package/dist/cli/chat/sessionLifecycle.js +27 -18
  10. package/dist/cli/chat/sessionRecorder.d.ts +2 -1
  11. package/dist/cli/chat/sessionRecorder.js +25 -8
  12. package/dist/cli/chat/transcriptPartition.js +10 -4
  13. package/dist/cli/chat/wizard/providerHandlers.js +57 -9
  14. package/dist/cli/chat/wizard/sessionThemeHandlers.js +5 -1
  15. package/dist/cli/commands/chat.js +39 -7
  16. package/dist/cli/commands/commandHelp.js +2 -2
  17. package/dist/cli/commands/providerWizard.js +9 -17
  18. package/dist/cli/commands/reasoningCommand.d.ts +1 -0
  19. package/dist/cli/commands/reasoningCommand.js +32 -4
  20. package/dist/cli/commands/runCommand.js +7 -1
  21. package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
  22. package/dist/cli/commands/streaming/attemptOutcome.js +5 -1
  23. package/dist/cli/commands/streaming/attemptSetup.js +5 -3
  24. package/dist/cli/commands/streaming/goalSupervisor.d.ts +1 -1
  25. package/dist/cli/commands/streaming/goalSupervisor.js +20 -1
  26. package/dist/cli/commands/streaming/streamLoop.js +11 -10
  27. package/dist/cli/commands/streaming.d.ts +2 -0
  28. package/dist/cli/commands/wizardFlow.d.ts +1 -0
  29. package/dist/cli/commands/wizardFlow.js +10 -4
  30. package/dist/cli/index.js +5 -3
  31. package/dist/config/hazeBuild.d.ts +2 -2
  32. package/dist/config/hazeBuild.js +6 -3
  33. package/dist/config/modelDiscovery.d.ts +1 -1
  34. package/dist/config/modelDiscovery.js +8 -8
  35. package/dist/config/{modelCatalog.d.ts → providerModelFacts.d.ts} +13 -2
  36. package/dist/config/{modelCatalog.js → providerModelFacts.js} +145 -21
  37. package/dist/config/providerPresets.d.ts +8 -19
  38. package/dist/config/providerPresets.js +86 -555
  39. package/dist/config/providerReasoning.d.ts +16 -0
  40. package/dist/config/providerReasoning.js +56 -0
  41. package/dist/config/providers.d.ts +4 -0
  42. package/dist/config/providers.js +19 -2
  43. package/dist/config/settings.d.ts +14 -0
  44. package/dist/config/settings.js +5 -0
  45. package/dist/core/agent/events.d.ts +1 -1
  46. package/dist/core/agent/providerTransition.d.ts +8 -0
  47. package/dist/core/agent/providerTransition.js +47 -0
  48. package/dist/core/agent/reasoningPolicy.d.ts +1 -1
  49. package/dist/core/agent/reasoningPolicy.js +4 -2
  50. package/dist/core/limits.d.ts +0 -2
  51. package/dist/core/limits.js +0 -2
  52. package/dist/core/providerContracts.d.ts +9 -8
  53. package/dist/core/providerContracts.js +21 -1
  54. package/dist/core/safety/redaction.js +12 -2
  55. package/dist/core/session/sessionSlimming.js +5 -59
  56. package/dist/core/session/sessionStore.d.ts +4 -0
  57. package/dist/core/session/sessionStore.js +149 -9
  58. package/dist/core/session/snapshotCodec.d.ts +5 -0
  59. package/dist/core/session/snapshotCodec.js +47 -0
  60. package/dist/core/shellOutput/registry.js +2 -46
  61. package/dist/core/subagent/executionProfiles.js +4 -1
  62. package/dist/core/toolOutput/reduction.d.ts +55 -2
  63. package/dist/core/toolOutput/reduction.js +77 -2
  64. package/dist/llm/client.d.ts +4 -2
  65. package/dist/llm/client.js +115 -56
  66. package/dist/llm/hazeTools.d.ts +16 -16
  67. package/dist/llm/mistralReasoning.d.ts +2 -0
  68. package/dist/llm/mistralReasoning.js +17 -0
  69. package/dist/llm/mistralVibeAuth.d.ts +5 -0
  70. package/dist/llm/mistralVibeAuth.js +63 -0
  71. package/dist/llm/requestContext.js +8 -7
  72. package/dist/llm/subagentRunner.js +15 -7
  73. package/dist/llm/toolResultTypes.js +7 -1
  74. package/dist/llm/tools/fetchTool.d.ts +16 -16
  75. package/dist/llm/tools/outputCap.d.ts +2 -7
  76. package/dist/llm/tools/outputCap.js +3 -11
  77. package/dist/llm/tools/replaceInFiles.js +5 -0
  78. package/package.json +14 -8
@@ -7,7 +7,7 @@ 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
- return provider && model ? { provider, model } : undefined;
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));
@@ -308,8 +323,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
308
323
  debug,
309
324
  contextFiles: () => contextFiles,
310
325
  modelSelection: currentModelSelection,
326
+ reasoningByModel: () => currentPromptSession().reasoningByModel,
311
327
  onModelSelection: selection => {
312
- settingsRef.current = { ...settingsRef.current, ...(selection ?? defaultSelectionRef.current) };
328
+ const model = selection ? { provider: selection.provider, model: selection.model } : defaultSelectionRef.current;
329
+ settingsRef.current = { ...settingsRef.current, ...model };
313
330
  setSettingsRaw(settingsRef.current);
314
331
  },
315
332
  sessionRef,
@@ -620,6 +637,11 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
620
637
  conversationRef.current = msgs;
621
638
  sessionRecorder.recordConversation(msgs);
622
639
  },
640
+ onModelTransition: (selector, msgs) => {
641
+ const resolved = resolveModelSelector(settingsRef.current, selector);
642
+ if (resolved.status === 'found')
643
+ sessionRecorder.recordModelTransition(msgs, { provider: resolved.provider.name, model: resolved.model, endpointFingerprint: providerEndpointFingerprint(resolved.provider) });
644
+ },
623
645
  setBusy: setBusyWithHeartbeat,
624
646
  setBusyLabel,
625
647
  debugLog,
@@ -642,6 +664,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
642
664
  },
643
665
  onEvent: event => {
644
666
  sessionRecorder.recordEvent(event);
667
+ if (event.type === 'subagent_state')
668
+ setFleet(current => nextFleetStatus(current, event));
669
+ else if (event.type === 'goal_end')
670
+ setFleet(undefined);
645
671
  },
646
672
  onTasksChanged: () => {
647
673
  loadTasksFromStore().then(t => {
@@ -688,6 +714,10 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
688
714
  }
689
715
  const visible = messages.filter(message => !message.hidden);
690
716
  const activeLiveMessages = liveMessages.filter(message => !message.hidden);
717
+ // Recomputed each busy heartbeat (1 Hz) alongside the elapsed label; the
718
+ // streaming-rate estimate rides the already-live message text, so no extra
719
+ // timer or token bookkeeping is introduced.
720
+ const busyDetail = busy ? busyDetailLabel({ messages: activeLiveMessages, fleet }) : undefined;
691
721
  const { staticItems: staticTranscriptItems, streamingItems } = partitionDisplayMessages([...visible, ...activeLiveMessages]);
692
722
  const activeSelection = activeModel(settings);
693
723
  const placeholder = placeholderForMode(mode, busy);
@@ -706,7 +736,9 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
706
736
  const reasoningSuffix = effectiveReasoning
707
737
  ? effectiveReasoning.level === undefined
708
738
  ? ' (no reasoning parameter)'
709
- : ` (${effectiveReasoning.level})`
739
+ : activeSelection && resolveProviderReasoning(activeSelection.provider, activeSelection.model, effectiveReasoning.level).effective === 'disabled'
740
+ ? ' (provider default)'
741
+ : ` (${effectiveReasoning.level})`
710
742
  : '';
711
743
  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
744
  const workspaceLabel = `${compactHomePath(process.cwd())}${branchName ? ` (${branchName})` : ''}`;
@@ -741,7 +773,7 @@ function ChatScreen({ debug = false, version, build, continueSession = false, re
741
773
  })()] }) : undefined,
742
774
  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
775
  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 })
776
+ activity: busy ? _jsx(BusyBar, { label: busyLabel, elapsed: busyElapsed, detail: busyDetail, tip: showingTip ? TIPS[tipIndex] : undefined })
745
777
  : pausedResume ? _jsxs(StatusNotice, { variant: "warning", children: ["Press R to resume \u00B7 unfinished goal paused", pausedResume.pauseReason ? ` (${pausedResume.pauseReason})` : ''] }) : undefined,
746
778
  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
779
  }, 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: () => {
@@ -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.' },
@@ -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
- /** Merge order for per-model limits on add: preset-curated < live-discovered < existing user settings. */
17
- function mergedModelLimits(curated, models, discovered, existing) {
18
- const discoveredSubset = {};
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
- discoveredSubset[model] = discovered[model];
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
- // Preset-curated limits (models.dev) flow into settings so request budgeting
33
- // uses the real window without the user configuring anything. Live values the
34
- // provider itself reported in /models discovery win over the static catalog
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 curatedLimits = presetModelLimitsForModels({ name: draft.name, url: draft.url }, models);
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
- ...(modelLimits ? { modelLimits } : {}),
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 value = args.trim().toLowerCase();
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
- return { action: 'reset', message: `Session reasoning override removed${scope}. ${describeChoice(fallback)} applies from the next turn.` };
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
- 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.');
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 result = resolveReasoningCommand(args, { current, stored, modelSelector });
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
@@ -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),
@@ -73,7 +73,6 @@ export function finalizeAttemptOutcome(deps) {
73
73
  const turnStatus = terminalTurnStatus({ aborted: false, 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
  /**
@@ -60,6 +60,8 @@ export async function prepareAttempt(deps) {
60
60
  const reasoningPolicy = runtime.config.reasoningPolicy;
61
61
  if (reasoningPolicy)
62
62
  callbacks.onEvent?.(agentEvent({ type: 'reasoning_policy', requested: reasoningPolicy.requested, effective: reasoningPolicy.effective, reason: reasoningPolicy.reason }));
63
+ if (reasoningPolicy?.effective === 'disabled' && reasoningPolicy.requested && (reasoningOverride || session?.reasoningByModel?.[runtime.selector] || turnSettings.reasoning))
64
+ callbacks.addMessage({ role: 'system', text: `Reasoning ${reasoningPolicy.requested} was not applied: ${reasoningPolicy.reason}.` });
63
65
  // Make the context-budget guess observable: a stream event every turn
64
66
  // (headless consumers can gate on it), and — interactively — a system
65
67
  // message only when the built-in default was used for a model this session
@@ -99,8 +101,8 @@ export async function prepareAttempt(deps) {
99
101
  // Keep the active provider history exact. Routine tool-history slimming used
100
102
  // to rewrite older successful calls/results here, invalidating provider
101
103
  // prompt-cache prefixes before the context budget required compaction.
102
- // Durable session snapshots are slimmed independently at the persistence
103
- // boundary; only the model-aware compaction below may rewrite active history.
104
+ // Durable session snapshots preserve this history; only model-aware
105
+ // compaction or an explicit provider transition may rewrite it.
104
106
  const durableRequestMessages = retryingExistingRequest
105
107
  ? stripSyntheticControls(callbacks.getConversation())
106
108
  : [...stripSyntheticControls(callbacks.getConversation()), userTurnMessage(value, turnOptions.attachments ?? [])];
@@ -195,7 +197,7 @@ export async function prepareAttempt(deps) {
195
197
  toolCategories,
196
198
  modelRetries: typeof turnSettings.modelRetries === 'number' ? turnSettings.modelRetries : DEFAULT_MODEL_RETRIES,
197
199
  retryBaseDelayMs: typeof turnSettings.retryBaseDelayMs === 'number' ? turnSettings.retryBaseDelayMs : DEFAULT_RETRY_BASE_DELAY_MS,
198
- streamIdleTimeoutMs: resolveStreamIdleTimeoutMs(turnSettings.streamIdleTimeoutMs, usesPatientIdleWindow(isLocalProviderUrl(runtime.config.baseURL), runtime.config.providerKind)),
200
+ streamIdleTimeoutMs: resolveStreamIdleTimeoutMs(turnSettings.streamIdleTimeoutMs, usesPatientIdleWindow(runtime.config.isLocal ?? isLocalProviderUrl(runtime.config.baseURL), runtime.config.providerKind)),
199
201
  steeringProfile,
200
202
  };
201
203
  }
@@ -5,7 +5,7 @@ import type { StoredReasoningSetting } from '../../../core/agent/reasoningPolicy
5
5
  import { type StreamCallbacks, type TurnExecutionOptions } from '../streaming.js';
6
6
  import { type GoalCheckpoint, type GoalLedgerAppend } from './goalCheckpoint.js';
7
7
  /** Why a logical goal stopped. `completed` is the only success. */
8
- export type GoalStopReason = 'completed' | 'no-progress' | 'goal-deadline' | 'blocked' | 'model-error' | 'model-stream-idle' | 'user-aborted' | 'context-exhausted';
8
+ export type GoalStopReason = 'completed' | 'no-progress' | 'goal-deadline' | 'blocked' | 'model-error' | 'model-stream-idle' | 'user-aborted' | 'context-exhausted' | 'cycle-limit';
9
9
  export type { GoalLedgerAppend };
10
10
  /** Authoritative outcome of a logical goal (one or more physical turns). */
11
11
  export interface GoalRunResult {
@@ -1,4 +1,5 @@
1
1
  import { agentEvent } from '../../../core/agent/events.js';
2
+ import { transitionProviderConversation } from '../../../core/agent/providerTransition.js';
2
3
  import { describeCompletionReadiness } from '../../../core/agent/completionController.js';
3
4
  import { checkKindsOfIds } from '../../../core/agent/workState.js';
4
5
  import { classifyRequestIntent, goalContinuationPrompt } from '../../../core/agent/goalPolicy.js';
@@ -6,6 +7,10 @@ import { runAgentTurn } from '../streaming.js';
6
7
  import { goalCheckpointSignature, hashRequest } from './goalCheckpoint.js';
7
8
  /** Pause after one corrective physical turn without measurable outcome progress. */
8
9
  const GOAL_NO_PROGRESS_LIMIT = 1;
10
+ /** Hard ceiling on physical turns for a single logical goal. The no-progress
11
+ * guard above stops most stuck goals; this is a backstop so a goal that keeps
12
+ * inching forward without completing cannot run unbounded. */
13
+ const GOAL_MAX_CYCLES = 12;
9
14
  function checkpointFromResume(resume, noProgressCount) {
10
15
  const validationOutcome = resume.validationOutcome ?? 'not_applicable';
11
16
  return {
@@ -85,13 +90,19 @@ export async function runAgentGoal(options) {
85
90
  if (!selected || escalated || selected === activeModelOverride)
86
91
  return false;
87
92
  escalated = true;
93
+ const history = callbacks.getConversation();
94
+ if (history.length) {
95
+ const portable = transitionProviderConversation(history);
96
+ callbacks.setConversation(portable);
97
+ callbacks.onModelTransition?.(selected, portable);
98
+ }
88
99
  activeModelOverride = selected;
89
100
  noProgressCount = 0;
90
101
  prevSignature = undefined;
91
102
  // The model switch is a supervisor boundary like any other: it must reach
92
103
  // the durable ledger so a crash resume does not silently lose it.
93
104
  appendLedger('goal_continue');
94
- callbacks.onEvent?.(agentEvent({ type: 'goal_notice', text: `Continuing with explicitly configured escalation model ${selected} after ${reason}.` }));
105
+ callbacks.onEvent?.(agentEvent({ type: 'goal_notice', text: `Continuing with explicitly configured escalation model ${selected} after ${reason}. Previous tool history was converted to text and provider reasoning state was cleared.` }));
95
106
  return true;
96
107
  };
97
108
  const appendLedger = (phase, extra = {}) => {
@@ -124,6 +135,11 @@ export async function runAgentGoal(options) {
124
135
  // guessed from semantic versions.
125
136
  callbacks.debugLog('goal supervisor enabled; automatic continuation across physical-turn budgets');
126
137
  const finish = (status, stopReason, resume) => {
138
+ if (escalated && options.modelOverride) {
139
+ const portable = transitionProviderConversation(callbacks.getConversation());
140
+ callbacks.setConversation(portable);
141
+ callbacks.onModelTransition?.(options.modelOverride, portable);
142
+ }
127
143
  appendLedger('goal_end', {
128
144
  status,
129
145
  gateDecision: status === 'complete' ? 'ready' : ['no-progress', 'context-exhausted', 'goal-deadline'].includes(stopReason) ? checkpoint?.readiness : undefined,
@@ -175,6 +191,9 @@ export async function runAgentGoal(options) {
175
191
  const result = await runAgentTurn(request, continuing ? undefined : options.displayValue, contextFiles, callbacks, initialRetryAttempt, continuing, false, options.session, activeModelOverride, turnOptions, options.reasoningOverride);
176
192
  initialRetryAttempt = 0;
177
193
  cycle += 1;
194
+ if (cycle >= GOAL_MAX_CYCLES) {
195
+ return finish('failed', 'cycle-limit', checkpoint ? { kind: 'incomplete-goal', checkpoint } : undefined);
196
+ }
178
197
  lastEvidence = result.evidence;
179
198
  if (result.checkpoint)
180
199
  checkpoint = result.checkpoint;
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { ToolLoopAgent, generateText, isStepCount } from 'ai';
2
+ import { ToolLoopAgent, streamText, isStepCount } from 'ai';
3
3
  import { agentEvent } from '../../../core/agent/events.js';
4
+ import { auxiliaryRequestOptions } from '../../../core/providerContracts.js';
4
5
  import { contextTokensFromUsage, estimateConversationTokens, estimateValueTokens } from '../../../core/agent/contextBudget.js';
5
6
  import { stripSyntheticControls } from '../../../core/agent/requestAssembly.js';
6
7
  import { buildLlmCompactionPrompt, chooseBoundaryCompactionMethod, compactModelMessages, compactModelMessagesWithSummary, extractExistingCompactionSummary } from '../../../core/agent/compaction.js';
@@ -367,14 +368,14 @@ async function compactAtEpochBoundary(deps, providerMessages) {
367
368
  previousSummary: extractExistingCompactionSummary(providerMessages),
368
369
  splitTurn: split.splitTurn,
369
370
  });
370
- const summarization = await generateText({
371
+ const summarization = streamText({
371
372
  model: setup.runtime.model,
372
373
  prompt,
373
- ...(setup.runtime.config.providerKind === 'haze-build' ? { ...setup.providerSettings, reasoning: 'none' } : {}),
374
- maxOutputTokens: Math.min(COMPACTION_LLM_MAX_OUTPUT_TOKENS, setup.runtime.config.maxOutputTokens ?? COMPACTION_LLM_MAX_OUTPUT_TOKENS),
374
+ ...auxiliaryRequestOptions({ ...setup.providerSettings, omitMaxOutputTokens: setup.omitMaxOutputTokens }, setup.runtime.config.capabilities, 'compaction', Math.min(COMPACTION_LLM_MAX_OUTPUT_TOKENS, setup.runtime.config.maxOutputTokens ?? COMPACTION_LLM_MAX_OUTPUT_TOKENS)),
375
375
  abortSignal: abortController.signal,
376
376
  });
377
- const summaryText = summarization.text.trim();
377
+ const summaryText = (await summarization.text).trim();
378
+ const usage = await summarization.usage;
378
379
  if (!summaryText)
379
380
  throw new Error('model returned an empty summary');
380
381
  const result = compactModelMessagesWithSummary(providerMessages, { summaryText, tokenBudget, workState: goal });
@@ -382,16 +383,16 @@ async function compactAtEpochBoundary(deps, providerMessages) {
382
383
  throw new Error('nothing older to compact');
383
384
  callbacks.onEvent?.(agentEvent({ type: 'compaction_end', reason: 'threshold', method: 'llm', compacted: true, olderCount: result.olderCount, keptCount: result.keptCount }));
384
385
  callbacks.recordTokenUsage?.({
385
- inputTokens: summarization.usage?.inputTokens,
386
- outputTokens: summarization.usage?.outputTokens,
386
+ inputTokens: usage?.inputTokens,
387
+ outputTokens: usage?.outputTokens,
387
388
  systemPrompt: 0,
388
389
  messages: 0,
389
390
  toolSchemas: 0,
390
391
  outputEstimate: 0,
391
- cacheReadTokens: summarization.usage?.inputTokenDetails?.cacheReadTokens ?? 0,
392
- cacheWriteTokens: summarization.usage?.inputTokenDetails?.cacheWriteTokens ?? 0,
392
+ cacheReadTokens: usage?.inputTokenDetails?.cacheReadTokens ?? 0,
393
+ cacheWriteTokens: usage?.inputTokenDetails?.cacheWriteTokens ?? 0,
393
394
  noCacheTokens: 0,
394
- reasoningTokens: summarization.usage?.outputTokenDetails?.reasoningTokens ?? 0,
395
+ reasoningTokens: usage?.outputTokenDetails?.reasoningTokens ?? 0,
395
396
  logicalInputEstimate: 0,
396
397
  effectiveNonCachedInput: undefined,
397
398
  });
@@ -102,6 +102,8 @@ export interface StreamCallbacks {
102
102
  addMessage: (msg: Message) => void;
103
103
  updateMessage: (id: string, update: Partial<Message>) => void;
104
104
  setConversation: (messages: ModelMessage[]) => void;
105
+ /** Persist an atomic portable boundary when the supervisor switches models. */
106
+ onModelTransition?: (selector: string, messages: ModelMessage[]) => void;
105
107
  setBusy: (busy: boolean) => void;
106
108
  setBusyLabel?: (label: string) => void;
107
109
  debugLog: (line: string) => void;
@@ -24,6 +24,7 @@ export declare const PROVIDER_ACTIONS: {
24
24
  readonly addModels: "add models";
25
25
  readonly manageAccess: "set API key";
26
26
  readonly signInChatGpt: "sign in with ChatGPT";
27
+ readonly signInMistral: "sign in with Mistral Vibe";
27
28
  readonly markImageCapable: "mark image-capable";
28
29
  readonly clearImageCapable: "clear image-capable";
29
30
  readonly removeModels: "remove models";
@@ -4,7 +4,8 @@ import { configuredMcpServers, findMcpServer, findMcpPreset, presetIds } from '.
4
4
  import { isSkillEnabled } from '../../config/skillSettings.js';
5
5
  import { PROVIDER_PRESETS } from '../../config/providerPresets.js';
6
6
  import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
7
- import { isStoredReasoning, resolveReasoningChoice, REASONING_LEVELS } from '../../core/agent/reasoningPolicy.js';
7
+ import { isStoredReasoning, resolveReasoningChoice } from '../../core/agent/reasoningPolicy.js';
8
+ import { reasoningLevelsForProvider } from '../../config/providerReasoning.js';
8
9
  import { BUILT_IN_THEME_SPECS, DEFAULT_THEME_NAME, resolveTheme } from '../../ui/theme.js';
9
10
  import { sessionActionSuggestions, sessionSuggestions } from './sessionPicker.js';
10
11
  /**
@@ -29,6 +30,7 @@ export const PROVIDER_ACTIONS = {
29
30
  addModels: 'add models',
30
31
  manageAccess: 'set API key',
31
32
  signInChatGpt: 'sign in with ChatGPT',
33
+ signInMistral: 'sign in with Mistral Vibe',
32
34
  markImageCapable: 'mark image-capable',
33
35
  clearImageCapable: 'clear image-capable',
34
36
  removeModels: 'remove models',
@@ -181,6 +183,7 @@ export function providerActionSuggestions(settings, selectedProviderName) {
181
183
  ...(provider?.kind === 'chatgpt-codex'
182
184
  ? [{ value: PROVIDER_ACTIONS.signInChatGpt, description: 'Sign in again or switch ChatGPT account', kind: 'provider' }]
183
185
  : [{ value: PROVIDER_ACTIONS.manageAccess, description: provider?.key ? 'Update the saved API key' : 'Add an API key', kind: 'provider' }]),
186
+ ...(provider?.url === 'https://api.mistral.ai/v1' ? [{ value: PROVIDER_ACTIONS.signInMistral, description: 'Sign in or switch Mistral Vibe account', kind: 'provider' }] : []),
184
187
  provider
185
188
  ? (providerImageCapable(provider)
186
189
  ? { value: PROVIDER_ACTIONS.clearImageCapable, description: 'Stop sending attached images to this provider', kind: 'provider' }
@@ -196,7 +199,7 @@ export function presetSuggestions() {
196
199
  return [
197
200
  ...cloudPresets.map(preset => ({
198
201
  value: preset.id,
199
- description: `${preset.baseUrl}${preset.auth === 'chatgpt-oauth' ? ' · browser sign-in' : ''}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
202
+ description: `${preset.baseUrl}${preset.auth ? ' · browser sign-in' : ''}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
200
203
  kind: 'provider',
201
204
  })),
202
205
  ...localPresets.map(preset => ({
@@ -388,13 +391,16 @@ export function reasoningSuggestions(settings, sessionReasoning) {
388
391
  medium: 'moderate reasoning',
389
392
  high: 'deep reasoning',
390
393
  xhigh: 'maximum reasoning',
394
+ max: 'maximum reasoning (supported models)',
391
395
  };
392
396
  const active = activeModel(settings);
397
+ const binary = active?.provider.kind === 'haze-build' || active?.provider.reasoningFormat === 'thinking' || active?.provider.reasoningFormat === 'enable-thinking';
398
+ const levels = active ? reasoningLevelsForProvider(active.provider, active.model) : [];
393
399
  const choice = resolveReasoningChoice(active ? sessionReasoning?.[modelSelector(active.provider, active.model)] : undefined, isStoredReasoning(settings.reasoning) ? settings.reasoning : undefined);
394
400
  return [
395
- ...REASONING_LEVELS.map(level => ({
401
+ ...levels.map(level => ({
396
402
  value: level,
397
- description: `${descriptions[level] ?? 'reasoning level'}${choice.level === level ? ' · active' : ''}`,
403
+ description: `${binary ? (level === 'none' ? 'thinking off' : 'thinking on') : descriptions[level] ?? 'reasoning level'}${choice.level === level ? ' · active' : ''}`,
398
404
  kind: 'command',
399
405
  })),
400
406
  { value: 'unset', description: 'provider default — sends no reasoning parameter', kind: 'command' },