@denizokcu/haze 1.2.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +86 -1
  2. package/README.md +23 -10
  3. package/SECURITY.md +1 -1
  4. package/bin/haze.js +27 -7
  5. package/dist/buildInfo.json +3 -3
  6. package/dist/cli/chat/BusyBar.d.ts +7 -0
  7. package/dist/cli/chat/BusyBar.js +8 -0
  8. package/dist/cli/chat/DynamicFrame.d.ts +37 -0
  9. package/dist/cli/chat/DynamicFrame.js +43 -0
  10. package/dist/cli/chat/busyIndicator.d.ts +3 -1
  11. package/dist/cli/chat/busyIndicator.js +11 -9
  12. package/dist/cli/chat/chatMetrics.d.ts +1 -1
  13. package/dist/cli/chat/chatMetrics.js +3 -3
  14. package/dist/cli/chat/inputSuggestions.js +4 -0
  15. package/dist/cli/chat/liveMessages.d.ts +36 -0
  16. package/dist/cli/chat/liveMessages.js +64 -0
  17. package/dist/cli/chat/liveRegion.js +1 -1
  18. package/dist/cli/chat/messages.js +27 -16
  19. package/dist/cli/chat/sessionLifecycle.d.ts +5 -2
  20. package/dist/cli/chat/sessionLifecycle.js +36 -4
  21. package/dist/cli/chat/sessionRecorder.d.ts +2 -1
  22. package/dist/cli/chat/sessionRecorder.js +8 -0
  23. package/dist/cli/chat/shutdown.d.ts +27 -0
  24. package/dist/cli/chat/shutdown.js +79 -0
  25. package/dist/cli/chat/terminalControl.d.ts +45 -0
  26. package/dist/cli/chat/terminalControl.js +107 -0
  27. package/dist/cli/chat/tips.js +1 -0
  28. package/dist/cli/chat/userInput.d.ts +43 -0
  29. package/dist/cli/chat/userInput.js +63 -0
  30. package/dist/cli/chat/wizard/sessionThemeHandlers.d.ts +1 -1
  31. package/dist/cli/chat/wizard/sessionThemeHandlers.js +24 -1
  32. package/dist/cli/chat/wizard/types.d.ts +8 -1
  33. package/dist/cli/chat/wizardDispatch.js +1 -1
  34. package/dist/cli/commands/chat.js +277 -193
  35. package/dist/cli/commands/commandHelp.js +6 -0
  36. package/dist/cli/commands/commands.d.ts +8 -0
  37. package/dist/cli/commands/commands.js +13 -0
  38. package/dist/cli/commands/formatters.d.ts +1 -1
  39. package/dist/cli/commands/formatters.js +25 -3
  40. package/dist/cli/commands/logsCommand.js +21 -2
  41. package/dist/cli/commands/ndjsonSink.d.ts +12 -0
  42. package/dist/cli/commands/ndjsonSink.js +29 -0
  43. package/dist/cli/commands/reasoningCommand.d.ts +44 -0
  44. package/dist/cli/commands/reasoningCommand.js +79 -0
  45. package/dist/cli/commands/runCommand.d.ts +14 -0
  46. package/dist/cli/commands/runCommand.js +56 -22
  47. package/dist/cli/commands/settingsSummary.js +2 -0
  48. package/dist/cli/commands/streaming/agentAttempt.d.ts +3 -0
  49. package/dist/cli/commands/streaming/agentAttempt.js +2 -2
  50. package/dist/cli/commands/streaming/assistantSegments.d.ts +0 -7
  51. package/dist/cli/commands/streaming/assistantSegments.js +1 -1
  52. package/dist/cli/commands/streaming/attemptLifecycle.js +13 -9
  53. package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
  54. package/dist/cli/commands/streaming/attemptOutcome.js +24 -9
  55. package/dist/cli/commands/streaming/attemptSetup.d.ts +4 -0
  56. package/dist/cli/commands/streaming/attemptSetup.js +21 -7
  57. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +14 -1
  58. package/dist/cli/commands/streaming/goalCheckpoint.js +4 -2
  59. package/dist/cli/commands/streaming/goalSupervisor.d.ts +9 -0
  60. package/dist/cli/commands/streaming/goalSupervisor.js +51 -10
  61. package/dist/cli/commands/streaming/prepareStep.d.ts +0 -3
  62. package/dist/cli/commands/streaming/prepareStep.js +14 -5
  63. package/dist/cli/commands/streaming/streamLoop.d.ts +5 -0
  64. package/dist/cli/commands/streaming/streamLoop.js +3 -0
  65. package/dist/cli/commands/streaming/toolPartHandlers.js +6 -0
  66. package/dist/cli/commands/streaming.d.ts +8 -3
  67. package/dist/cli/commands/streaming.js +46 -21
  68. package/dist/cli/commands/wizardFlow.d.ts +10 -0
  69. package/dist/cli/commands/wizardFlow.js +34 -5
  70. package/dist/cli/index.js +22 -2
  71. package/dist/config/contextFiles.d.ts +9 -0
  72. package/dist/config/contextFiles.js +21 -1
  73. package/dist/config/modelCatalog.d.ts +3 -0
  74. package/dist/config/modelCatalog.js +29 -0
  75. package/dist/config/modelDiscovery.js +68 -5
  76. package/dist/config/providerPresets.d.ts +1 -1
  77. package/dist/config/providerPresets.js +42 -3
  78. package/dist/config/settings.d.ts +14 -6
  79. package/dist/config/settings.js +16 -1
  80. package/dist/core/agent/budgets.d.ts +13 -17
  81. package/dist/core/agent/budgets.js +15 -19
  82. package/dist/core/agent/completionController.d.ts +14 -2
  83. package/dist/core/agent/completionController.js +48 -3
  84. package/dist/core/agent/events.d.ts +2 -1
  85. package/dist/core/agent/goalPolicy.d.ts +17 -0
  86. package/dist/core/agent/goalPolicy.js +53 -6
  87. package/dist/core/agent/projectPreflight.d.ts +2 -0
  88. package/dist/core/agent/projectPreflight.js +56 -0
  89. package/dist/core/agent/reasoningPolicy.d.ts +76 -10
  90. package/dist/core/agent/reasoningPolicy.js +72 -9
  91. package/dist/core/agent/toolCapabilities.d.ts +3 -3
  92. package/dist/core/agent/toolCapabilities.js +31 -7
  93. package/dist/core/agent/workState.d.ts +14 -4
  94. package/dist/core/agent/workState.js +229 -34
  95. package/dist/core/deadline.js +22 -24
  96. package/dist/core/providerContracts.d.ts +29 -0
  97. package/dist/core/providerContracts.js +1 -0
  98. package/dist/core/safety/secretPaths.js +10 -7
  99. package/dist/core/safety/shellClassifier.d.ts +2 -0
  100. package/dist/core/safety/shellClassifier.js +9 -1
  101. package/dist/core/session/sessionReport.d.ts +33 -0
  102. package/dist/core/session/sessionReport.js +121 -0
  103. package/dist/core/session/sessionSlimming.d.ts +2 -0
  104. package/dist/core/session/sessionSlimming.js +59 -4
  105. package/dist/core/session/sessionStore.d.ts +16 -8
  106. package/dist/core/session/sessionStore.js +71 -34
  107. package/dist/core/shellOutput/reducers/git.js +7 -2
  108. package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
  109. package/dist/core/shellOutput/reducers/validation.js +14 -1
  110. package/dist/core/shellOutput/registry.js +3 -2
  111. package/dist/core/subagent/contracts.d.ts +3 -18
  112. package/dist/core/subagent/executionProfiles.js +4 -4
  113. package/dist/core/tasks/taskStorage.js +8 -1
  114. package/dist/core/validation/outputParser.d.ts +6 -1
  115. package/dist/core/validation/outputParser.js +30 -2
  116. package/dist/llm/client.d.ts +6 -3
  117. package/dist/llm/client.js +28 -11
  118. package/dist/llm/hazeTools.d.ts +9161 -7135
  119. package/dist/llm/hazeTools.js +6 -462
  120. package/dist/llm/lsp/client.d.ts +7 -1
  121. package/dist/llm/lsp/client.js +58 -9
  122. package/dist/llm/lsp/pool.d.ts +11 -0
  123. package/dist/llm/lsp/pool.js +61 -4
  124. package/dist/llm/lsp/protocol.d.ts +6 -23
  125. package/dist/llm/lsp/requests.d.ts +54 -60
  126. package/dist/llm/lsp/requests.js +152 -28
  127. package/dist/llm/lsp/symbols.d.ts +16 -0
  128. package/dist/llm/lsp/symbols.js +70 -0
  129. package/dist/llm/lsp/workspaceEdit.d.ts +43 -0
  130. package/dist/llm/lsp/workspaceEdit.js +117 -0
  131. package/dist/llm/lspTools.d.ts +7518 -2859
  132. package/dist/llm/lspTools.js +195 -110
  133. package/dist/llm/mcp.js +3 -0
  134. package/dist/llm/requestContext.d.ts +4 -3
  135. package/dist/llm/requestContext.js +9 -5
  136. package/dist/{core/subagent → llm}/subagentRunner.d.ts +13 -9
  137. package/dist/{core/subagent → llm}/subagentRunner.js +54 -49
  138. package/dist/llm/systemPrompt.d.ts +11 -1
  139. package/dist/llm/systemPrompt.js +4 -13
  140. package/dist/llm/tools/fetchTool.d.ts +34 -30
  141. package/dist/llm/tools/fileTools.d.ts +7768 -0
  142. package/dist/llm/tools/fileTools.js +510 -0
  143. package/dist/llm/tools/processTool.d.ts +34 -30
  144. package/dist/llm/tools/replaceInFiles.d.ts +105 -0
  145. package/dist/llm/tools/replaceInFiles.js +131 -0
  146. package/dist/llm/tools/shellTool.d.ts +34 -30
  147. package/dist/llm/tools/shellTool.js +8 -4
  148. package/dist/llm/tools/storedOutputTool.d.ts +4 -0
  149. package/dist/llm/tools/taskTool.d.ts +4 -0
  150. package/dist/llm/tools/toolContext.d.ts +3 -29
  151. package/dist/llm/tools/toolContext.js +56 -53
  152. package/dist/llm/tools/toolContextState.d.ts +40 -0
  153. package/dist/llm/tools/toolContextState.js +34 -0
  154. package/dist/llm/workerContext.d.ts +7 -0
  155. package/dist/llm/workerContext.js +18 -1
  156. package/dist/skills/SkillLoader.js +30 -4
  157. package/dist/skills/SkillRegistry.js +3 -3
  158. package/dist/skills/builder/SkillBuilder.js +3 -3
  159. package/dist/skills/confinement.d.ts +7 -0
  160. package/dist/skills/confinement.js +15 -0
  161. package/dist/ui/codeHighlight.js +4 -4
  162. package/dist/ui/components/MarkdownText.js +7 -8
  163. package/dist/ui/components/NativeIndicators.d.ts +15 -0
  164. package/dist/ui/components/NativeIndicators.js +32 -0
  165. package/dist/ui/components/StreamingMarkdownText.d.ts +9 -0
  166. package/dist/ui/components/StreamingMarkdownText.js +38 -0
  167. package/dist/ui/components/TextInput.d.ts +7 -2
  168. package/dist/ui/components/TextInput.js +103 -46
  169. package/dist/ui/components/WizardChoices.d.ts +18 -0
  170. package/dist/ui/components/WizardChoices.js +32 -0
  171. package/dist/ui/components/useInputSuggestions.js +18 -6
  172. package/dist/ui/inputBuffer.js +12 -6
  173. package/dist/ui/textGeometry.d.ts +14 -0
  174. package/dist/ui/textGeometry.js +31 -0
  175. package/dist/utils/buildInfo.js +29 -8
  176. package/dist/utils/fs.js +5 -1
  177. package/package.json +23 -22
  178. /package/dist/cli/{contextReport.d.ts → contextReportCli.d.ts} +0 -0
  179. /package/dist/cli/{contextReport.js → contextReportCli.js} +0 -0
@@ -7,6 +7,10 @@ export const COMMAND_HELP_ENTRIES = [
7
7
  { usage: '/settings open', description: 'Open ~/.haze/settings.json with the OS default app.' },
8
8
  { usage: '/themes', description: 'Choose a terminal theme from the built-in registry (light palettes and oh-my-zsh ports included); applies immediately.' },
9
9
  { 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.' },
10
+ { 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.' },
11
+ { 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. Medium is the default. Endpoints without native support ignore the parameter.' },
12
+ { 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.' },
13
+ { 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. Medium is the default. Endpoints without native support ignore the parameter.' },
10
14
  { usage: '/skills', description: 'Manage Markdown skills: generate a custom skill, show info, enable/disable, validate, or remove.' },
11
15
  { usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
12
16
  { 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.' },
@@ -19,6 +23,8 @@ export const COMMAND_HELP_ENTRIES = [
19
23
  { usage: '/lsp', description: 'Configure Language Server Protocol navigation tools (interactive picker).' },
20
24
  { usage: '/mcp', description: 'Configure Model Context Protocol servers like Context7 (interactive picker).' },
21
25
  { usage: '/logs <id>', description: 'Show summary of a specific log: entry counts by type, total tokens, tool calls.' },
26
+ { usage: '/logs <id> view', description: 'Page the raw log JSONL through $PAGER in a fullscreen terminal handoff.' },
27
+ { usage: '/editor', description: 'Compose a prompt in $EDITOR, then submit it as the next message.' },
22
28
  { usage: '/compact [instructions]', description: 'Summarize older model context and keep recent messages.' },
23
29
  { usage: '/clear', description: 'Clear the current chat conversation history.' },
24
30
  { usage: '/exit', description: 'Exit haze.' },
@@ -1,6 +1,7 @@
1
1
  import type { ContextFile } from '../../config/contextFiles.js';
2
2
  import { type HazeSettings } from '../../config/settings.js';
3
3
  import type { Mode } from './chatModes.js';
4
+ import type { StoredReasoningSetting } from '../../core/agent/reasoningPolicy.js';
4
5
  import type { TurnExecutionOptions } from './streaming.js';
5
6
  export type CommandContext = {
6
7
  settings: HazeSettings;
@@ -16,8 +17,15 @@ export type CommandContext = {
16
17
  /** LLM-summarized /compact (F-09); preferred over `compactConversation` when present. */
17
18
  compactConversationLlm?: (instructions?: string) => Promise<boolean>;
18
19
  runAgentTurn: (prompt: string, displayValue?: string, options?: TurnExecutionOptions) => Promise<void>;
20
+ /** Ink 8 `suspendTerminal` affordances; provided by the interactive screen only. */
21
+ composeInEditor?: () => Promise<string | undefined>;
22
+ viewInPager?: (text: string) => Promise<boolean>;
19
23
  refreshContextFiles: () => Promise<ContextFile[]>;
20
24
  updateSettings: (patch: Partial<HazeSettings>) => Promise<HazeSettings>;
25
+ /** Read the session-scoped per-model reasoning override (`provider:model` key). */
26
+ getSessionReasoning: (modelSelector: string) => StoredReasoningSetting | undefined;
27
+ /** Write (or clear, with undefined) the session-scoped per-model reasoning override. */
28
+ setSessionReasoning: (modelSelector: string, setting: StoredReasoningSetting | undefined) => void;
21
29
  getContextReport?: () => Promise<string>;
22
30
  };
23
31
  export type CommandResult = 'handled' | 'unhandled' | 'exit';
@@ -7,6 +7,7 @@ import { handleFleetCommand } from './fleetCommand.js';
7
7
  import { handleInitCommand } from './initCommand.js';
8
8
  import { handleLogsCommand } from './logsCommand.js';
9
9
  import { handleModelCommand } from './modelCommand.js';
10
+ import { handleReasoningCommand } from './reasoningCommand.js';
10
11
  import { handleThemesCommand } from './themesCommand.js';
11
12
  import { formatSettingsSummary } from './settingsSummary.js';
12
13
  async function ensureSettingsFile(settings) {
@@ -45,6 +46,16 @@ const SLASH_COMMANDS = [
45
46
  } },
46
47
  { match: exact('/clear'), run: async (_args, ctx) => { await ctx.clearConversation(); await clearTasks(); return HANDLED; } },
47
48
  { match: exactOrArgs('/logs'), run: async (args, ctx) => await handleLogsCommand(args, ctx) },
49
+ { match: exact('/editor'), run: async (_args, ctx) => {
50
+ if (!ctx.composeInEditor) {
51
+ ctx.addSystemMessage('/editor needs an interactive terminal.');
52
+ return HANDLED;
53
+ }
54
+ const text = await ctx.composeInEditor();
55
+ if (text)
56
+ await ctx.runAgentTurn(text);
57
+ return HANDLED;
58
+ } },
48
59
  { match: exactOrArgs('/lsp'), run: (_args, ctx) => { ctx.setMode('lsp'); ctx.addSystemMessage('Choose an LSP server to enable, disable, or remove it. Choose "add server" to add one from presets (e.g. typescript) or enter a custom command.'); return HANDLED; } },
49
60
  { match: exactOrArgs('/mcp'), run: (_args, ctx) => { ctx.setMode('mcp'); ctx.addSystemMessage('Choose an MCP server to enable, disable, remove, or set a key for it. Choose "add server" to add one from presets (e.g. context7) or enter custom details.'); return HANDLED; } },
50
61
  { match: value => value === '/settings open' || value === '/settings edit' ? { args: '' } : false, run: async (_args, ctx) => { const file = await ensureSettingsFile(ctx.settings); await openPath(file); ctx.addSystemMessage(`Opened settings file: ${file}`); return HANDLED; } },
@@ -59,6 +70,8 @@ const SLASH_COMMANDS = [
59
70
  return HANDLED;
60
71
  } },
61
72
  { match: exactOrArgs('/themes'), run: async (args, ctx) => await handleThemesCommand(args, ctx) },
73
+ { match: exactOrArgs('/reasoning'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
74
+ { match: exactOrArgs('/thinking'), run: async (args, ctx) => await handleReasoningCommand(args, ctx) },
62
75
  { match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
63
76
  ];
64
77
  export async function handleSlashCommand(value, ctx) {
@@ -7,7 +7,7 @@ export declare function toolResultSummary(event: {
7
7
  }): string;
8
8
  /**
9
9
  * A short, human label for the live busy indicator while a tool is running,
10
- * e.g. "Running command", "Reading src/foo.ts", "Searching".
10
+ * e.g. "Running npm test", "Reading src/foo.ts", "Searching".
11
11
  * Lets the developer see *what* is happening, not just that something is.
12
12
  */
13
13
  export declare function busyToolLabel(toolName: string, input: unknown): string;
@@ -41,9 +41,11 @@ export function toolCallSummary(toolName, input) {
41
41
  const edits = Array.isArray(data.edits) ? ` (${data.edits.length} edit${data.edits.length === 1 ? '' : 's'})` : '';
42
42
  return `${toolName} ${data.path}${edits}`;
43
43
  }
44
+ if (toolName === 'replaceInFiles' && typeof data?.needle === 'string')
45
+ return `replaceInFiles "${compact(data.needle, 60)}"${typeof data.path === 'string' && data.path !== '.' ? ` in ${data.path}` : ''}${data.dryRun === false ? '' : ' (dry run)'}`;
44
46
  if (toolName === 'replaceLines' && typeof data?.path === 'string')
45
47
  return `replaceLines ${data.path}:${data.startLine}-${data.endLine}`;
46
- if ((toolName === 'editFile' || toolName === 'replaceLines') && (data == null || (typeof data === 'object' && Object.keys(data).length === 0)))
48
+ if ((toolName === 'editFile' || toolName === 'replaceInFiles' || toolName === 'replaceLines') && (data == null || (typeof data === 'object' && Object.keys(data).length === 0)))
47
49
  return toolName;
48
50
  if (toolName === 'subagent') {
49
51
  const task = typeof data?.objective === 'string' ? data.objective : typeof data?.task === 'string' ? data.task : undefined;
@@ -60,6 +62,8 @@ export function toolCallSummary(toolName, input) {
60
62
  return `lspWorkspaceSymbols "${data.query}"`;
61
63
  if (toolName === 'lspSymbols' && typeof data?.path === 'string')
62
64
  return `lspSymbols ${data.path}`;
65
+ if ((toolName === 'lspFindSymbol' || toolName === 'lspRenameSymbol' || toolName === 'lspSafeDeleteSymbol' || toolName === 'lspDiagnosticsForSymbol') && typeof data?.namePath === 'string')
66
+ return `${toolName} ${typeof data.path === 'string' ? `${data.path}:` : ''}${data.namePath}`;
63
67
  if (toolName === 'lspDiagnostics' && typeof data?.path === 'string')
64
68
  return `lspDiagnostics ${data.path}`;
65
69
  if ((toolName === 'lspDefinition' || toolName === 'lspTypeDefinition' || toolName === 'lspImplementation' || toolName === 'lspReferences') && typeof data?.path === 'string')
@@ -144,9 +148,25 @@ export function toolResultSummary(event) {
144
148
  }
145
149
  return 'completed';
146
150
  }
151
+ /**
152
+ * The short head of a shell command for the busy label: the program plus its
153
+ * first non-flag argument ("git diff", "npm test") — enough to identify the
154
+ * action without echoing the full (possibly long or sensitive) command line.
155
+ */
156
+ function commandHead(command) {
157
+ const parts = command.trim().split(/\s+/);
158
+ const head = [parts[0]];
159
+ for (const part of parts.slice(1)) {
160
+ if (part.startsWith('-'))
161
+ continue;
162
+ head.push(part);
163
+ break;
164
+ }
165
+ return compact(head.filter(Boolean).join(' '), 80);
166
+ }
147
167
  /**
148
168
  * A short, human label for the live busy indicator while a tool is running,
149
- * e.g. "Running command", "Reading src/foo.ts", "Searching".
169
+ * e.g. "Running npm test", "Reading src/foo.ts", "Searching".
150
170
  * Lets the developer see *what* is happening, not just that something is.
151
171
  */
152
172
  export function busyToolLabel(toolName, input) {
@@ -154,7 +174,9 @@ export function busyToolLabel(toolName, input) {
154
174
  const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
155
175
  switch (toolName) {
156
176
  case 'shell':
157
- return data?.background === true ? 'Starting background process' : 'Running command';
177
+ if (data?.background === true)
178
+ return 'Starting background process';
179
+ return typeof data?.command === 'string' && data.command ? `Running ${commandHead(data.command)}` : 'Running command';
158
180
  case 'process':
159
181
  return 'Managing background process';
160
182
  case 'grep':
@@ -1,7 +1,12 @@
1
- import { listLogs, summarizeLog } from '../../core/log/llmLog.js';
1
+ import { listLogs, readLogEntries, summarizeLog } from '../../core/log/llmLog.js';
2
2
  import { formatBytes } from '../../utils/format.js';
3
+ import { SESSION_PREVIEW_CHARS } from '../../core/limits.js';
3
4
  export async function handleLogsCommand(args, ctx) {
4
- const id = args.trim();
5
+ const trimmed = args.trim();
6
+ // `/logs <id> view` pages the raw JSONL through $PAGER; the suffix is part
7
+ // of haze's syntax, not the log id.
8
+ const viewRaw = /^(\S+)\s+view$/i.exec(trimmed);
9
+ const id = viewRaw ? viewRaw[1] : trimmed;
5
10
  if (!id) {
6
11
  const logs = await listLogs();
7
12
  if (logs.length === 0) {
@@ -20,6 +25,20 @@ export async function handleLogsCommand(args, ctx) {
20
25
  ctx.addSystemMessage(`No log found with id ${id}.`);
21
26
  return 'handled';
22
27
  }
28
+ // Page raw transcripts when possible; short logs and screen-reader mode
29
+ // still get the requested content through a bounded inline preview.
30
+ if (viewRaw) {
31
+ const entries = await readLogEntries(id);
32
+ const text = entries.map(entry => JSON.stringify(entry)).join('\n');
33
+ const paged = await ctx.viewInPager?.(text);
34
+ if (!paged) {
35
+ const preview = text.length > SESSION_PREVIEW_CHARS
36
+ ? `${text.slice(0, SESSION_PREVIEW_CHARS)}\n[Raw log preview truncated; /logs ${id} shows the summary.]`
37
+ : text || '(empty log)';
38
+ ctx.addSystemMessage(`Log: ${id} (inline view; pager not used)\n${preview}`);
39
+ }
40
+ return 'handled';
41
+ }
23
42
  const typeLines = Object.entries(summary.typeCounts)
24
43
  .sort(([a], [b]) => a.localeCompare(b))
25
44
  .map(([type, count]) => ` ${type}: ${count}`);
@@ -4,16 +4,28 @@
4
4
  * drain when the stream returns false, so a slow/redirected consumer cannot
5
5
  * reorder or lose events and the final result line always lands after all
6
6
  * streamed events.
7
+ *
8
+ * SU-05: stream errors are captured permanently (an asynchronous error after a
9
+ * `true` return has a listener here), so `flush()` rejects and the caller can
10
+ * report an output-delivery failure instead of exiting 0 with a broken stream.
7
11
  */
8
12
  export interface WritableSink {
9
13
  write(chunk: string): boolean;
10
14
  once(event: 'drain' | 'error', listener: () => void): unknown;
11
15
  off?(event: 'drain' | 'error', listener: () => void): unknown;
12
16
  }
17
+ /**
18
+ * Queue a best-effort event write without creating an unhandled rejection.
19
+ * NdjsonSink retains the first delivery error, so the caller's final flush still
20
+ * reports failure and can return a non-zero exit code.
21
+ */
22
+ export declare function queueNdjsonWrite(sink: NdjsonSink, value: unknown): void;
13
23
  export declare class NdjsonSink {
14
24
  private readonly stream;
15
25
  private tail;
16
26
  private firstError;
27
+ private pendingLines;
28
+ private permanentError;
17
29
  constructor(stream: WritableSink);
18
30
  /** Serialize one value as an NDJSON line, preserving order and awaiting drain. */
19
31
  write(value: unknown): Promise<void>;
@@ -1,17 +1,44 @@
1
+ /** Upper bound on queued lines: an unbounded producer would grow without limit under a stalled consumer. */
2
+ const MAX_PENDING_LINES = 1000;
3
+ /**
4
+ * Queue a best-effort event write without creating an unhandled rejection.
5
+ * NdjsonSink retains the first delivery error, so the caller's final flush still
6
+ * reports failure and can return a non-zero exit code.
7
+ */
8
+ export function queueNdjsonWrite(sink, value) {
9
+ void sink.write(value).catch(() => undefined);
10
+ }
1
11
  export class NdjsonSink {
2
12
  stream;
3
13
  tail = Promise.resolve();
4
14
  firstError;
15
+ pendingLines = 0;
16
+ permanentError;
5
17
  constructor(stream) {
6
18
  this.stream = stream;
19
+ // Permanent stream-error capture: errors between writes (true returns) or
20
+ // after close also fail the flush instead of vanishing (SU-05).
21
+ stream.once('error', () => {
22
+ this.permanentError ??= new Error('output stream failed');
23
+ });
7
24
  }
8
25
  /** Serialize one value as an NDJSON line, preserving order and awaiting drain. */
9
26
  write(value) {
10
27
  const line = `${JSON.stringify(value)}\n`;
28
+ if (this.permanentError)
29
+ return Promise.reject(this.permanentError);
30
+ if (this.pendingLines >= MAX_PENDING_LINES) {
31
+ const error = new Error(`output stream stalled; more than ${MAX_PENDING_LINES} lines are waiting to drain`);
32
+ this.permanentError ??= error;
33
+ return Promise.reject(error);
34
+ }
35
+ this.pendingLines += 1;
11
36
  const next = this.tail.then(() => this.writeLine(line));
12
37
  // Keep the chain draining even if one line fails; surface the first error on flush.
13
38
  this.tail = next.catch(error => {
14
39
  this.firstError ??= error instanceof Error ? error : new Error(String(error));
40
+ }).finally(() => {
41
+ this.pendingLines -= 1;
15
42
  });
16
43
  return next;
17
44
  }
@@ -32,6 +59,8 @@ export class NdjsonSink {
32
59
  /** Wait for every queued line to finish writing. Rejects on the first error. */
33
60
  async flush() {
34
61
  await this.tail;
62
+ if (this.permanentError)
63
+ throw this.permanentError;
35
64
  if (this.firstError)
36
65
  throw this.firstError;
37
66
  }
@@ -0,0 +1,44 @@
1
+ import { type ResolvedReasoningChoice, type StoredReasoningSetting } from '../../core/agent/reasoningPolicy.js';
2
+ import type { CommandContext, CommandResult } from './commands.js';
3
+ /**
4
+ * `/reasoning` — per-model, per-session reasoning-effort picker and direct
5
+ * set, modeled on `/themes`. The picker is one step in the `wizardFlow.ts`
6
+ * table (mode `reasoning`); this module holds the pure result function shared
7
+ * by the slash path and the wizard submit handler. The chosen level applies to
8
+ * the active `provider:model` for the current session only — kept in memory on
9
+ * the `PromptSession` object, never written to `~/.haze/settings.json` — and
10
+ * applies from the next turn (reasoning is resolved once per attempt in
11
+ * `attemptSetup`). A model without a session override falls back to the saved
12
+ * global `reasoning` setting, then the built-in default.
13
+ */
14
+ /** Picker value that stops sending a reasoning parameter (also accepted as `off` on the slash path). */
15
+ export declare const REASONING_UNSET = "unset";
16
+ /** Picker/slash value that removes the session override and inherits the saved/default level. */
17
+ export declare const REASONING_RESET = "reset";
18
+ export type ReasoningCommandResult = {
19
+ action: 'status';
20
+ message: string;
21
+ } | {
22
+ action: 'set';
23
+ setting: StoredReasoningSetting;
24
+ message: string;
25
+ } | {
26
+ action: 'reset';
27
+ message: string;
28
+ } | {
29
+ action: 'error';
30
+ message: string;
31
+ } | {
32
+ action: 'open-picker';
33
+ };
34
+ /**
35
+ * Resolve a `/reasoning` invocation against the current choice for the active
36
+ * model. Pure: the caller applies `set`/`reset` to the session-scoped
37
+ * per-model map (`PromptSession.reasoningByModel`); nothing touches settings.
38
+ */
39
+ export declare function resolveReasoningCommand(args: string, input: {
40
+ current: ResolvedReasoningChoice;
41
+ stored: StoredReasoningSetting | undefined;
42
+ modelSelector?: string;
43
+ }): ReasoningCommandResult;
44
+ export declare function handleReasoningCommand(args: string, ctx: CommandContext): Promise<CommandResult>;
@@ -0,0 +1,79 @@
1
+ import { REASONING_LEVELS, REASONING_PROVIDER_DEFAULT, isReasoningLevel, isReasoningUnsetAlias, isStoredReasoning, resolveReasoningChoice } from '../../core/agent/reasoningPolicy.js';
2
+ /**
3
+ * `/reasoning` — per-model, per-session reasoning-effort picker and direct
4
+ * set, modeled on `/themes`. The picker is one step in the `wizardFlow.ts`
5
+ * table (mode `reasoning`); this module holds the pure result function shared
6
+ * by the slash path and the wizard submit handler. The chosen level applies to
7
+ * the active `provider:model` for the current session only — kept in memory on
8
+ * the `PromptSession` object, never written to `~/.haze/settings.json` — and
9
+ * applies from the next turn (reasoning is resolved once per attempt in
10
+ * `attemptSetup`). A model without a session override falls back to the saved
11
+ * global `reasoning` setting, then the built-in default.
12
+ */
13
+ /** Picker value that stops sending a reasoning parameter (also accepted as `off` on the slash path). */
14
+ export const REASONING_UNSET = 'unset';
15
+ /** Picker/slash value that removes the session override and inherits the saved/default level. */
16
+ export const REASONING_RESET = 'reset';
17
+ const LEVELS_LIST = REASONING_LEVELS.join(', ');
18
+ function describeChoice(choice) {
19
+ if (choice.level === undefined)
20
+ return 'provider default (no parameter sent)';
21
+ if (choice.source === 'session')
22
+ return `${choice.level} (session override)`;
23
+ if (choice.source === 'settings')
24
+ return `${choice.level} (from settings)`;
25
+ return `${choice.level} (default)`;
26
+ }
27
+ /**
28
+ * Resolve a `/reasoning` invocation against the current choice for the active
29
+ * model. Pure: the caller applies `set`/`reset` to the session-scoped
30
+ * per-model map (`PromptSession.reasoningByModel`); nothing touches settings.
31
+ */
32
+ export function resolveReasoningCommand(args, input) {
33
+ const value = args.trim().toLowerCase();
34
+ const scope = input.modelSelector ? ` for ${input.modelSelector}` : '';
35
+ if (!value)
36
+ return { action: 'open-picker' };
37
+ if (value === 'status') {
38
+ return { action: 'status', message: `Reasoning effort${scope}: ${describeChoice(input.current)}. Set with /reasoning <level> (this model, this session), /reasoning unset to send no reasoning parameter, or /reasoning reset to fall back to the saved/default level. Levels: ${LEVELS_LIST}.` };
39
+ }
40
+ if (value === REASONING_RESET) {
41
+ const fallback = resolveReasoningChoice(undefined, input.stored);
42
+ return { action: 'reset', message: `Session reasoning override removed${scope}. ${describeChoice(fallback)} applies from the next turn.` };
43
+ }
44
+ if (isReasoningUnsetAlias(value)) {
45
+ 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).` };
46
+ }
47
+ if (!isReasoningLevel(value)) {
48
+ 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.` };
49
+ }
50
+ 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.` };
51
+ }
52
+ /** `provider:model` key for the settings-configured active model, or undefined when unconfigured. */
53
+ function activeModelSelector(context) {
54
+ const { provider, model } = context.settings;
55
+ return provider && model ? `${provider}:${model}` : undefined;
56
+ }
57
+ export async function handleReasoningCommand(args, ctx) {
58
+ const modelSelector = activeModelSelector(ctx);
59
+ if (!args.trim()) {
60
+ ctx.setMode('reasoning');
61
+ 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.');
62
+ return 'handled';
63
+ }
64
+ if (!modelSelector) {
65
+ ctx.addSystemMessage('No provider/model configured. /reasoning sets a per-model level; run /provider and /model first.');
66
+ return 'handled';
67
+ }
68
+ const stored = isStoredReasoning(ctx.settings.reasoning) ? ctx.settings.reasoning : undefined;
69
+ const current = resolveReasoningChoice(ctx.getSessionReasoning(modelSelector), stored);
70
+ const result = resolveReasoningCommand(args, { current, stored, modelSelector });
71
+ if (result.action === 'set')
72
+ ctx.setSessionReasoning(modelSelector, result.setting);
73
+ else if (result.action === 'reset')
74
+ ctx.setSessionReasoning(modelSelector, undefined);
75
+ // Unreachable (args are non-empty here) but narrows the open-picker variant away.
76
+ if (result.action !== 'open-picker')
77
+ ctx.addSystemMessage(result.message);
78
+ return 'handled';
79
+ }
@@ -1,7 +1,10 @@
1
+ import { type StoredReasoningSetting } from '../../core/agent/reasoningPolicy.js';
1
2
  export type HeadlessOutput = 'text' | 'json' | 'stream-json';
2
3
  export interface HeadlessOptions {
3
4
  prompt: string;
4
5
  modelOverride?: string;
6
+ /** Raw `--reasoning` value (level or unset alias); validated in `runHeadless` so the error path is testable. */
7
+ reasoning?: string;
5
8
  resumeSessionId?: string;
6
9
  output: HeadlessOutput;
7
10
  debug?: boolean;
@@ -19,4 +22,15 @@ export interface HeadlessUsage {
19
22
  }
20
23
  /** Parse a `--timeout` duration like `30s`, `10m`, `2h`, or raw ms. Throws on invalid input. */
21
24
  export declare function parseTurnTimeoutMs(raw: string | undefined): number | undefined;
25
+ /**
26
+ * Resolve the model the run will use *before* invoking the agent, so a bad `--model`
27
+ * selector or a missing provider produces a precise error (not the generic no-provider
28
+ * message) with a non-zero exit. Returns an error string when the run cannot proceed.
29
+ */
30
+ /** Parse a `--reasoning` value into the run-scoped override. Returns an error string when invalid. */
31
+ export declare function parseHeadlessReasoning(raw: string | undefined): {
32
+ setting: StoredReasoningSetting | undefined;
33
+ } | {
34
+ error: string;
35
+ };
22
36
  export declare function runHeadless(options: HeadlessOptions): Promise<number>;
@@ -1,5 +1,6 @@
1
1
  import { readContextFiles } from '../../config/contextFiles.js';
2
2
  import { runAgentGoal } from './streaming/goalSupervisor.js';
3
+ import { parseReasoningOverride } from '../../core/agent/reasoningPolicy.js';
3
4
  import { EMPTY_TOKEN_USAGE, accumulateTokenUsage } from '../chat/turnState.js';
4
5
  import { readSettings } from '../../config/settings.js';
5
6
  import { activeModel, modelSelector, resolveModelSelector } from '../../config/providers.js';
@@ -10,7 +11,7 @@ import { compactModelMessages } from '../../core/agent/compaction.js';
10
11
  import { FALLBACK_CONTEXT_WINDOW_TOKENS } from '../../core/agent/contextBudget.js';
11
12
  import { teardownBackgroundProcesses } from '../../core/process/backgroundRegistry.js';
12
13
  import { MAX_TURN_DEADLINE_MS } from '../../core/agent/budgets.js';
13
- import { NdjsonSink } from './ndjsonSink.js';
14
+ import { NdjsonSink, queueNdjsonWrite } from './ndjsonSink.js';
14
15
  function pinnedUsage(usage) {
15
16
  // Normalize every field to a number: TokenUsage seeds most fields to 0 but
16
17
  // inputTokens/outputTokens may be undefined until the first report. A uniform ?? 0
@@ -116,8 +117,14 @@ function messageUpdateDelta(event, emitted) {
116
117
  * selector or a missing provider produces a precise error (not the generic no-provider
117
118
  * message) with a non-zero exit. Returns an error string when the run cannot proceed.
118
119
  */
119
- async function resolveModelOrError(modelOverride) {
120
- const settings = await readSettings();
120
+ /** Parse a `--reasoning` value into the run-scoped override. Returns an error string when invalid. */
121
+ export function parseHeadlessReasoning(raw) {
122
+ if (raw === undefined || raw.trim() === '')
123
+ return { setting: undefined };
124
+ const parsed = parseReasoningOverride(raw);
125
+ return parsed.ok ? { setting: parsed.setting } : { error: parsed.error };
126
+ }
127
+ function resolveModelOrError(settings, modelOverride) {
121
128
  const override = modelOverride?.trim();
122
129
  if (override) {
123
130
  const resolved = resolveModelSelector(settings, override);
@@ -148,11 +155,27 @@ export async function runHeadless(options) {
148
155
  process.stderr.write(`No session named ${options.resumeSessionId} exists for this workspace.\n`);
149
156
  return 1;
150
157
  }
151
- const modelError = await resolveModelOrError(options.modelOverride);
158
+ const reasoning = parseHeadlessReasoning(options.reasoning);
159
+ if ('error' in reasoning) {
160
+ process.stderr.write(`${reasoning.error}\n`);
161
+ return 2;
162
+ }
163
+ const restored = resumed ? await restoreSessionState(resumed) : undefined;
164
+ const savedModel = restored?.modelSelection;
165
+ const runSettings = await readSettings();
166
+ const defaultModel = activeModel(runSettings);
167
+ const requestedModel = options.modelOverride?.trim()
168
+ || (savedModel ? `${savedModel.provider}:${savedModel.model}` : undefined)
169
+ || (defaultModel ? modelSelector(defaultModel.provider, defaultModel.model) : undefined);
170
+ const modelError = resolveModelOrError(runSettings, requestedModel);
152
171
  if (modelError) {
153
172
  process.stderr.write(`${modelError}\n`);
154
173
  return 1;
155
174
  }
175
+ // Resolve bare --model selectors to a provider-qualified selection once,
176
+ // so retries cannot follow changes to the global default.
177
+ const resolvedModel = requestedModel ? resolveModelSelector(runSettings, requestedModel) : undefined;
178
+ const sessionModel = resolvedModel?.status === 'found' ? modelSelector(resolvedModel.provider, resolvedModel.model) : requestedModel;
156
179
  // stderr keeps stdout clean for --output json/stream-json consumers.
157
180
  const debugLog = (line) => {
158
181
  if (options.debug)
@@ -160,13 +183,9 @@ export async function runHeadless(options) {
160
183
  };
161
184
  const contextFiles = await readContextFiles(process.cwd());
162
185
  const session = { start: new Date(), cwd: process.cwd() };
163
- let conversation = [];
164
- if (resumed) {
165
- const restored = await restoreSessionState(resumed);
166
- conversation = restored.messages;
167
- for (const error of restored.parseErrors)
168
- process.stderr.write(`Session parse error: ${error}\n`);
169
- }
186
+ let conversation = restored?.messages ?? [];
187
+ for (const error of restored?.parseErrors ?? [])
188
+ process.stderr.write(`Session parse error: ${error}\n`);
170
189
  // Assistant text is delivered in two stages by runAgentTurn: an initial streaming
171
190
  // `addMessage`, then a finalizing `updateMessage` with the complete text. We key
172
191
  // segments by id and patch them on update so finalized (and multi-segment) text is captured.
@@ -185,14 +204,14 @@ export async function runHeadless(options) {
185
204
  if (event.type === 'message_update') {
186
205
  const delta = messageUpdateDelta(event, emittedSegmentText);
187
206
  if (delta)
188
- void streamSink.write(delta);
207
+ queueNdjsonWrite(streamSink, delta);
189
208
  return;
190
209
  }
191
210
  if (event.type === 'message_end')
192
211
  emittedSegmentText.delete(event.id);
193
212
  const headlessEvent = toHeadlessStreamEvent(event);
194
213
  if (headlessEvent)
195
- void streamSink.write(headlessEvent);
214
+ queueNdjsonWrite(streamSink, headlessEvent);
196
215
  }
197
216
  : undefined;
198
217
  // Bounded, cross-output-mode collection of gate decisions and pauses so
@@ -269,7 +288,9 @@ export async function runHeadless(options) {
269
288
  contextFiles,
270
289
  callbacks,
271
290
  session,
272
- modelOverride: options.modelOverride,
291
+ modelOverride: sessionModel,
292
+ escalationModel: runSettings.escalationModel,
293
+ ...(reasoning.setting !== undefined ? { reasoningOverride: reasoning.setting } : {}),
273
294
  ...(turnDeadlineMs != null ? { goalDeadlineMs: Math.max(1, deadlineAt - Date.now()) } : {}),
274
295
  ...(relaunchOptions.resumeFrom ? { resumeFrom: relaunchOptions.resumeFrom } : {}),
275
296
  ...(relaunchOptions.conversationCarriesRequest ? { conversationCarriesRequest: true } : {}),
@@ -296,12 +317,11 @@ export async function runHeadless(options) {
296
317
  callbacks.onEvent?.(agentEvent({ type: 'goal_resume', goalId: `relaunch-${relaunches}`, relaunch: relaunches, stopReason: goalResult.stopReason, reason: `transient ${goalResult.stopReason}; relaunching with ${delayMs}ms backoff` }));
297
318
  process.stderr.write(`haze --until-done: ${goalResult.stopReason} on cycle ${goalResult.cycles}; relaunching (attempt ${relaunches}, backoff ${delayMs}ms).\n`);
298
319
  await new Promise(resolve => setTimeout(resolve, delayMs));
299
- // A paused checkpoint (idle stall) resumes it; a hard model error has
300
- // no checkpoint, but the conversation is preserved — re-enter against
301
- // it without duplicating the user request.
320
+ // Relaunch with the same obligations and history. A new bounded retry
321
+ // pool is intentional after headless backoff, not a new user request.
302
322
  goalResult = await runOnce({
303
- ...(goalResult.resume?.kind === 'incomplete-goal' ? { resumeFrom: goalResult.resume } : {}),
304
- ...(goalResult.resume ? {} : { conversationCarriesRequest: conversation.length > 0 }),
323
+ ...(goalResult.resume ? { resumeFrom: goalResult.resume.kind === 'model-stream-idle' ? { ...goalResult.resume, retryAttempt: 0 } : goalResult.resume } : {}),
324
+ conversationCarriesRequest: conversation.length > 0,
305
325
  });
306
326
  }
307
327
  }
@@ -311,6 +331,7 @@ export async function runHeadless(options) {
311
331
  cycles: goalResult.cycles,
312
332
  stopReason: goalResult.stopReason,
313
333
  mutations: goalResult.evidence?.mutationCount ?? 0,
334
+ ...(goalResult.escalations ? { escalations: goalResult.escalations } : {}),
314
335
  ...(goalResult.evidence && goalResult.evidence.validationOutcome !== 'not_applicable' ? { validationOutcome: goalResult.evidence.validationOutcome } : {}),
315
336
  ...(goalResult.evidence?.taskProgress ? { taskProgress: goalResult.evidence.taskProgress } : {}),
316
337
  };
@@ -336,16 +357,29 @@ export async function runHeadless(options) {
336
357
  if (options.output === 'json' || options.output === 'stream-json') {
337
358
  // For stream-json the authoritative agent events have already streamed; flush
338
359
  // them before the terminal result so ordering is preserved under backpressure.
360
+ // A broken output stream is a delivery failure: report it and exit non-zero
361
+ // instead of claiming success with an unusable stream (SU-05).
362
+ let outputError;
339
363
  if (streamSink)
340
- await streamSink.flush().catch(() => undefined);
364
+ await streamSink.flush().catch(error => {
365
+ outputError = error instanceof Error ? error.message : String(error);
366
+ });
341
367
  // This terminal line is byte-identical to the --output json envelope, so harnesses can parse the last line the same way.
342
368
  const resultLine = { type: 'result', status, result, usage: pinnedUsage(usage), ...(evidence ? { evidence } : {}), ...(goal ? { goal } : {}), ...(goalNotices.length > 0 ? { notices: goalNotices.slice(-5) } : {}) };
343
369
  if (streamSink)
344
- await streamSink.write(resultLine).catch(() => undefined);
370
+ await streamSink.write(resultLine).catch(error => {
371
+ outputError ??= error instanceof Error ? error.message : String(error);
372
+ });
345
373
  else
346
374
  writeNdjson(resultLine);
347
375
  if (streamSink)
348
- await streamSink.flush().catch(() => undefined);
376
+ await streamSink.flush().catch(error => {
377
+ outputError ??= error instanceof Error ? error.message : String(error);
378
+ });
379
+ if (outputError) {
380
+ process.stderr.write(`haze output error: failed to deliver stream-json output (${outputError}).\n`);
381
+ return 1;
382
+ }
349
383
  }
350
384
  else if (status === 'complete') {
351
385
  process.stdout.write(result + (result.endsWith('\n') ? '' : '\n'));
@@ -3,6 +3,7 @@ import { configuredLspServers } from '../../config/lspSettings.js';
3
3
  import { configuredMcpServers } from '../../config/mcpSettings.js';
4
4
  import { activeProvider as resolveActiveProvider, configuredProviders, providerHasKey, providerImageCapable } from '../../config/providers.js';
5
5
  import { isSkillEnabled } from '../../config/skillSettings.js';
6
+ import { DEFAULT_REASONING_LEVEL, isReasoningLevel, REASONING_PROVIDER_DEFAULT } from '../../core/agent/reasoningPolicy.js';
6
7
  import { DEFAULT_THEME_NAME } from '../../ui/theme.js';
7
8
  import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
8
9
  export async function formatSettingsSummary(settings, contextFiles) {
@@ -32,6 +33,7 @@ export async function formatSettingsSummary(settings, contextFiles) {
32
33
  `Base URL: ${activeProvider?.url ?? settings.baseURL ?? 'not configured'}`,
33
34
  `API key: ${activeProvider && providerHasKey(settings, activeProvider) ? 'saved' : 'missing'}`,
34
35
  `Theme: ${settings.theme ?? `${DEFAULT_THEME_NAME} (default)`}`,
36
+ `Reasoning: ${isReasoningLevel(settings.reasoning) ? settings.reasoning : settings.reasoning === REASONING_PROVIDER_DEFAULT ? 'provider default (no parameter sent)' : `${DEFAULT_REASONING_LEVEL} (default)`}`,
35
37
  `Configured providers: ${providers.map(provider => `${provider.name}${providerImageCapable(provider) ? ' (images)' : ''}`).join(', ') || 'none'}`,
36
38
  `LSP servers: ${lspServers.map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,
37
39
  `MCP servers: ${configuredMcpServers(settings).map(server => `${server.name}${server.enabled === false ? ' (disabled)' : ''}`).join(', ') || 'none'}`,
@@ -8,6 +8,7 @@ import type { SessionGoal } from '../../../core/agent/goalPolicy.js';
8
8
  import { type AgentAttemptResult } from './attemptOutcome.js';
9
9
  import type { AttemptCleanupRegistry } from './attemptLifecycle.js';
10
10
  import type { TurnAbortCause } from './abortCause.js';
11
+ import type { StoredReasoningSetting } from '../../../core/agent/reasoningPolicy.js';
11
12
  import type { StreamCallbacks, TurnExecutionOptions } from '../streaming.js';
12
13
  export interface AgentAttemptInput {
13
14
  value: string;
@@ -23,6 +24,8 @@ export interface AgentAttemptInput {
23
24
  progressSinceLastRetry: boolean;
24
25
  session: PromptSession | undefined;
25
26
  modelOverride: string | undefined;
27
+ /** Run-scoped reasoning level/sentinel (CLI `--reasoning`); overrides the stored setting for this run. */
28
+ reasoningOverride: StoredReasoningSetting | undefined;
26
29
  abortController: AbortController;
27
30
  turnOptions: TurnExecutionOptions;
28
31
  turnScope: {