@denizokcu/haze 1.4.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 (132) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/README.md +13 -8
  3. package/SECURITY.md +1 -1
  4. package/dist/buildInfo.json +3 -3
  5. package/dist/cli/chat/BusyBar.d.ts +7 -0
  6. package/dist/cli/chat/BusyBar.js +8 -0
  7. package/dist/cli/chat/DynamicFrame.d.ts +37 -0
  8. package/dist/cli/chat/DynamicFrame.js +43 -0
  9. package/dist/cli/chat/busyIndicator.d.ts +3 -1
  10. package/dist/cli/chat/busyIndicator.js +11 -9
  11. package/dist/cli/chat/chatMetrics.d.ts +1 -1
  12. package/dist/cli/chat/chatMetrics.js +3 -3
  13. package/dist/cli/chat/inputSuggestions.js +2 -1
  14. package/dist/cli/chat/liveRegion.js +1 -1
  15. package/dist/cli/chat/messages.js +27 -16
  16. package/dist/cli/chat/sessionLifecycle.d.ts +3 -1
  17. package/dist/cli/chat/sessionLifecycle.js +13 -2
  18. package/dist/cli/chat/sessionRecorder.d.ts +2 -1
  19. package/dist/cli/chat/sessionRecorder.js +8 -0
  20. package/dist/cli/chat/shutdown.d.ts +27 -0
  21. package/dist/cli/chat/shutdown.js +79 -0
  22. package/dist/cli/chat/terminalControl.d.ts +45 -0
  23. package/dist/cli/chat/terminalControl.js +107 -0
  24. package/dist/cli/chat/tips.js +1 -0
  25. package/dist/cli/chat/userInput.d.ts +43 -0
  26. package/dist/cli/chat/userInput.js +63 -0
  27. package/dist/cli/chat/wizard/sessionThemeHandlers.js +14 -6
  28. package/dist/cli/chat/wizard/types.d.ts +8 -1
  29. package/dist/cli/chat/wizardDispatch.js +1 -1
  30. package/dist/cli/commands/chat.js +251 -172
  31. package/dist/cli/commands/commandHelp.js +6 -2
  32. package/dist/cli/commands/commands.d.ts +8 -0
  33. package/dist/cli/commands/commands.js +11 -0
  34. package/dist/cli/commands/formatters.d.ts +1 -1
  35. package/dist/cli/commands/formatters.js +20 -2
  36. package/dist/cli/commands/logsCommand.js +21 -2
  37. package/dist/cli/commands/reasoningCommand.d.ts +23 -14
  38. package/dist/cli/commands/reasoningCommand.js +53 -20
  39. package/dist/cli/commands/runCommand.js +19 -11
  40. package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
  41. package/dist/cli/commands/streaming/attemptOutcome.js +11 -6
  42. package/dist/cli/commands/streaming/attemptSetup.d.ts +1 -0
  43. package/dist/cli/commands/streaming/attemptSetup.js +11 -5
  44. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +8 -1
  45. package/dist/cli/commands/streaming/goalCheckpoint.js +3 -2
  46. package/dist/cli/commands/streaming/goalSupervisor.d.ts +4 -0
  47. package/dist/cli/commands/streaming/goalSupervisor.js +43 -7
  48. package/dist/cli/commands/streaming/prepareStep.js +7 -3
  49. package/dist/cli/commands/streaming/streamLoop.d.ts +5 -0
  50. package/dist/cli/commands/streaming/streamLoop.js +3 -0
  51. package/dist/cli/commands/streaming/toolPartHandlers.js +6 -0
  52. package/dist/cli/commands/streaming.d.ts +1 -1
  53. package/dist/cli/commands/streaming.js +23 -17
  54. package/dist/cli/commands/wizardFlow.d.ts +5 -2
  55. package/dist/cli/commands/wizardFlow.js +17 -10
  56. package/dist/cli/index.js +17 -1
  57. package/dist/config/contextFiles.d.ts +9 -0
  58. package/dist/config/contextFiles.js +21 -1
  59. package/dist/config/modelCatalog.d.ts +3 -0
  60. package/dist/config/modelCatalog.js +29 -0
  61. package/dist/config/providerPresets.d.ts +1 -1
  62. package/dist/config/providerPresets.js +42 -3
  63. package/dist/config/settings.d.ts +7 -3
  64. package/dist/config/settings.js +8 -0
  65. package/dist/core/agent/budgets.d.ts +13 -15
  66. package/dist/core/agent/budgets.js +15 -17
  67. package/dist/core/agent/completionController.d.ts +6 -2
  68. package/dist/core/agent/completionController.js +16 -3
  69. package/dist/core/agent/goalPolicy.d.ts +10 -0
  70. package/dist/core/agent/goalPolicy.js +44 -6
  71. package/dist/core/agent/projectPreflight.d.ts +2 -0
  72. package/dist/core/agent/projectPreflight.js +56 -0
  73. package/dist/core/agent/reasoningPolicy.d.ts +34 -4
  74. package/dist/core/agent/reasoningPolicy.js +27 -4
  75. package/dist/core/agent/workState.d.ts +8 -0
  76. package/dist/core/agent/workState.js +191 -8
  77. package/dist/core/providerContracts.d.ts +29 -0
  78. package/dist/core/providerContracts.js +1 -0
  79. package/dist/core/session/sessionReport.d.ts +33 -0
  80. package/dist/core/session/sessionReport.js +121 -0
  81. package/dist/core/session/sessionSlimming.js +9 -3
  82. package/dist/core/session/sessionStore.d.ts +12 -0
  83. package/dist/core/session/sessionStore.js +20 -4
  84. package/dist/core/subagent/contracts.d.ts +3 -25
  85. package/dist/core/subagent/executionProfiles.js +4 -4
  86. package/dist/core/validation/outputParser.d.ts +6 -1
  87. package/dist/core/validation/outputParser.js +6 -2
  88. package/dist/llm/client.d.ts +4 -2
  89. package/dist/llm/client.js +17 -10
  90. package/dist/llm/hazeTools.d.ts +8553 -8550
  91. package/dist/llm/hazeTools.js +6 -503
  92. package/dist/llm/lspTools.d.ts +120 -120
  93. package/dist/llm/mcp.js +3 -0
  94. package/dist/llm/requestContext.d.ts +1 -1
  95. package/dist/llm/requestContext.js +1 -1
  96. package/dist/{core/subagent → llm}/subagentRunner.d.ts +9 -9
  97. package/dist/{core/subagent → llm}/subagentRunner.js +22 -25
  98. package/dist/llm/systemPrompt.d.ts +11 -1
  99. package/dist/llm/systemPrompt.js +2 -11
  100. package/dist/llm/tools/fetchTool.d.ts +30 -30
  101. package/dist/llm/tools/fileTools.d.ts +7768 -0
  102. package/dist/llm/tools/fileTools.js +510 -0
  103. package/dist/llm/tools/processTool.d.ts +30 -30
  104. package/dist/llm/tools/shellTool.d.ts +30 -30
  105. package/dist/llm/tools/shellTool.js +8 -4
  106. package/dist/llm/tools/toolContext.d.ts +3 -32
  107. package/dist/llm/tools/toolContext.js +33 -52
  108. package/dist/llm/tools/toolContextState.d.ts +40 -0
  109. package/dist/llm/tools/toolContextState.js +34 -0
  110. package/dist/llm/workerContext.d.ts +7 -0
  111. package/dist/llm/workerContext.js +18 -1
  112. package/dist/skills/SkillLoader.js +3 -3
  113. package/dist/skills/SkillRegistry.js +3 -3
  114. package/dist/skills/builder/SkillBuilder.js +3 -3
  115. package/dist/skills/confinement.d.ts +7 -0
  116. package/dist/skills/confinement.js +15 -0
  117. package/dist/ui/codeHighlight.js +4 -4
  118. package/dist/ui/components/MarkdownText.js +7 -8
  119. package/dist/ui/components/NativeIndicators.d.ts +15 -0
  120. package/dist/ui/components/NativeIndicators.js +32 -0
  121. package/dist/ui/components/StreamingMarkdownText.d.ts +9 -0
  122. package/dist/ui/components/StreamingMarkdownText.js +38 -0
  123. package/dist/ui/components/TextInput.d.ts +7 -2
  124. package/dist/ui/components/TextInput.js +103 -46
  125. package/dist/ui/components/WizardChoices.d.ts +18 -0
  126. package/dist/ui/components/WizardChoices.js +32 -0
  127. package/dist/ui/inputBuffer.js +12 -6
  128. package/dist/ui/textGeometry.d.ts +14 -0
  129. package/dist/ui/textGeometry.js +31 -0
  130. package/package.json +14 -13
  131. /package/dist/cli/{contextReport.d.ts → contextReportCli.d.ts} +0 -0
  132. /package/dist/cli/{contextReport.js → contextReportCli.js} +0 -0
@@ -0,0 +1,79 @@
1
+ async function bounded(action, timeoutMs) {
2
+ let timer;
3
+ try {
4
+ await Promise.race([
5
+ Promise.resolve().then(action),
6
+ new Promise((_resolve, reject) => {
7
+ timer = setTimeout(() => reject(new Error('Shutdown deadline exceeded')), timeoutMs);
8
+ }),
9
+ ]);
10
+ }
11
+ finally {
12
+ if (timer)
13
+ clearTimeout(timer);
14
+ }
15
+ }
16
+ /** One owner for slash exit and interrupt; late rejection is consumed by the race. */
17
+ export function createChatShutdown(owners, settlementMs = 12_000, cleanupMs = 5_000) {
18
+ let pending;
19
+ return () => {
20
+ if (pending)
21
+ return pending;
22
+ owners.stop();
23
+ pending = (async () => {
24
+ const attempt = async (label, action, timeout) => {
25
+ try {
26
+ await bounded(action, timeout);
27
+ }
28
+ catch {
29
+ owners.report(`Shutdown warning: ${label} failed or exceeded its deadline.`);
30
+ }
31
+ };
32
+ try {
33
+ await attempt('abort', owners.abort, cleanupMs);
34
+ await attempt('active turn settlement', owners.settle, settlementMs);
35
+ owners.seal();
36
+ await attempt('session persistence', owners.flush, cleanupMs);
37
+ await attempt('log persistence', owners.endLog, cleanupMs);
38
+ await attempt('resource cleanup', owners.cleanup, cleanupMs);
39
+ }
40
+ finally {
41
+ owners.exit();
42
+ }
43
+ })();
44
+ return pending;
45
+ };
46
+ }
47
+ /** Adoption and synchronous render failures share the same restoration boundary. */
48
+ export async function runTerminalSession(owners) {
49
+ let app;
50
+ try {
51
+ owners.adopt();
52
+ app = owners.create();
53
+ await app.waitUntilExit();
54
+ }
55
+ finally {
56
+ try {
57
+ await owners.shutdown();
58
+ }
59
+ finally {
60
+ // Flush the final frame before teardown so the last rendered state
61
+ // (goodbye line, final status) actually reaches the TTY.
62
+ try {
63
+ await app?.waitUntilRenderFlush?.();
64
+ }
65
+ catch { /* terminal already gone */ }
66
+ try {
67
+ app?.unmount();
68
+ }
69
+ finally {
70
+ try {
71
+ app?.cleanup();
72
+ }
73
+ finally {
74
+ owners.restore();
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Pure helpers for interactive child-process handoff via Ink 8's
3
+ * `suspendTerminal`. Kept free of Ink/React imports so they stay testable.
4
+ */
5
+ export interface EditorLaunch {
6
+ command: string;
7
+ args: string[];
8
+ }
9
+ /**
10
+ * Resolve the editor command for an external `$EDITOR` compose. Follows the
11
+ * common `VISUAL` over `EDITOR` precedence; `false` means the environment has
12
+ * no editor configured. Composite EDITOR values (`code -w`, `vim -f`) are
13
+ * split into a command and args so no shell is needed.
14
+ */
15
+ export declare function resolveEditorCommand(env?: NodeJS.ProcessEnv): EditorLaunch | false;
16
+ /**
17
+ * Resolve a pager for viewing long text: `$PAGER`, else `less` (POSIX) or
18
+ * `more` (Windows). Returns undefined when the text plausibly fits one screen
19
+ * and a pager would only add a keypress.
20
+ */
21
+ export declare function resolvePager(text: string, terminalRows: number, env?: NodeJS.ProcessEnv): {
22
+ command: string;
23
+ args: string[];
24
+ } | undefined;
25
+ /**
26
+ * Run a child process while Ink has suspended the terminal (raw mode off,
27
+ * child owns the TTY). Resolves with the exit code; rejects on spawn or
28
+ * unexpected input-stream errors. Early pager closure (EPIPE) is normal. `stdinText` pipes text into the child (pager);
29
+ * without it the child inherits the terminal stdin (editor).
30
+ */
31
+ export declare function runSuspendedChild(launch: {
32
+ command: string;
33
+ args: string[];
34
+ }, stdinText?: string): Promise<number | null>;
35
+ /**
36
+ * `suspendTerminal` affordances for ChatScreen: run a fullscreen child
37
+ * ($EDITOR, pager) with the terminal handed over, then restore Ink state and
38
+ * force a full redraw. `composeInEditor` returns the composed text (or
39
+ * undefined when no editor is configured / nothing was typed); `viewInPager`
40
+ * returns whether a pager actually ran.
41
+ */
42
+ export declare function useTerminalControl(): {
43
+ composeInEditor: () => Promise<string | undefined>;
44
+ viewInPager: (text: string) => Promise<boolean>;
45
+ };
@@ -0,0 +1,107 @@
1
+ import { spawn } from 'node:child_process';
2
+ /** Split an editor/pager executable and quoted arguments without invoking a shell. */
3
+ function parseTerminalCommand(raw) {
4
+ const parts = raw.match(/"([^"]+)"|'([^']+)'|(\S+)/g) ?? [];
5
+ const words = parts.map(part => part.replace(/^["']|["']$/g, '')).filter(Boolean);
6
+ const command = words[0];
7
+ return command ? { command, args: words.slice(1) } : false;
8
+ }
9
+ /**
10
+ * Resolve the editor command for an external `$EDITOR` compose. Follows the
11
+ * common `VISUAL` over `EDITOR` precedence; `false` means the environment has
12
+ * no editor configured. Composite EDITOR values (`code -w`, `vim -f`) are
13
+ * split into a command and args so no shell is needed.
14
+ */
15
+ export function resolveEditorCommand(env = process.env) {
16
+ const raw = (env['VISUAL'] || env['EDITOR'] || '').trim();
17
+ return parseTerminalCommand(raw);
18
+ }
19
+ /**
20
+ * Resolve a pager for viewing long text: `$PAGER`, else `less` (POSIX) or
21
+ * `more` (Windows). Returns undefined when the text plausibly fits one screen
22
+ * and a pager would only add a keypress.
23
+ */
24
+ export function resolvePager(text, terminalRows, env = process.env) {
25
+ if (text.split('\n').length <= Math.max(1, terminalRows - 1))
26
+ return undefined;
27
+ const pager = env['PAGER']?.trim() || (process.platform === 'win32' ? 'more' : 'less');
28
+ const launch = parseTerminalCommand(pager);
29
+ if (!launch)
30
+ return undefined;
31
+ return launch.command === 'less' && launch.args.length === 0
32
+ ? { command: launch.command, args: ['-R', '-X'] } : launch;
33
+ }
34
+ /**
35
+ * Run a child process while Ink has suspended the terminal (raw mode off,
36
+ * child owns the TTY). Resolves with the exit code; rejects on spawn or
37
+ * unexpected input-stream errors. Early pager closure (EPIPE) is normal. `stdinText` pipes text into the child (pager);
38
+ * without it the child inherits the terminal stdin (editor).
39
+ */
40
+ export function runSuspendedChild(launch, stdinText) {
41
+ return new Promise((resolve, reject) => {
42
+ const child = stdinText == null
43
+ ? spawn(launch.command, launch.args, { stdio: 'inherit' })
44
+ : spawn(launch.command, launch.args, { stdio: ['pipe', 'inherit', 'inherit'] });
45
+ child.once('error', reject);
46
+ child.once('close', code => resolve(code));
47
+ if (stdinText != null && child.stdin) {
48
+ // Quitting a pager can close its pipe while a large write is pending.
49
+ // Stream errors are separate from the child's spawn error event.
50
+ child.stdin.on('error', (error) => {
51
+ if (error.code !== 'EPIPE')
52
+ reject(error);
53
+ });
54
+ child.stdin.end(stdinText);
55
+ }
56
+ });
57
+ }
58
+ // Ink-side wiring lives in chat.tsx via useApp(); this module deliberately
59
+ // stays React-free. The interactive hook is defined in terminalControlHook.tsx.
60
+ // --- Ink-side wiring (React, no JSX) -------------------------------------
61
+ import { useCallback } from 'react';
62
+ import { useApp, useIsScreenReaderEnabled, useWindowSize } from 'ink';
63
+ import os from 'node:os';
64
+ import path from 'node:path';
65
+ import fs from 'fs-extra';
66
+ import { randomUUID } from 'node:crypto';
67
+ /**
68
+ * `suspendTerminal` affordances for ChatScreen: run a fullscreen child
69
+ * ($EDITOR, pager) with the terminal handed over, then restore Ink state and
70
+ * force a full redraw. `composeInEditor` returns the composed text (or
71
+ * undefined when no editor is configured / nothing was typed); `viewInPager`
72
+ * returns whether a pager actually ran.
73
+ */
74
+ export function useTerminalControl() {
75
+ const { suspendTerminal } = useApp();
76
+ const { rows } = useWindowSize();
77
+ const screenReader = useIsScreenReaderEnabled();
78
+ const composeInEditor = useCallback(async () => {
79
+ const editor = resolveEditorCommand();
80
+ if (editor === false)
81
+ return undefined;
82
+ const file = path.join(os.tmpdir(), `haze-compose-${randomUUID()}.md`);
83
+ await fs.writeFile(file, '', 'utf8');
84
+ try {
85
+ await suspendTerminal(async () => {
86
+ await runSuspendedChild({ command: editor.command, args: [...editor.args, file] });
87
+ });
88
+ const text = (await fs.readFile(file, 'utf8')).trim();
89
+ return text || undefined;
90
+ }
91
+ finally {
92
+ await fs.remove(file).catch(() => undefined);
93
+ }
94
+ }, [suspendTerminal]);
95
+ const viewInPager = useCallback(async (text) => {
96
+ if (screenReader)
97
+ return false;
98
+ const pager = resolvePager(text, rows);
99
+ if (!pager)
100
+ return false;
101
+ await suspendTerminal(async () => {
102
+ await runSuspendedChild(pager, text);
103
+ });
104
+ return true;
105
+ }, [rows, screenReader, suspendTerminal]);
106
+ return { composeInEditor, viewInPager };
107
+ }
@@ -24,6 +24,7 @@ export const TIPS = [
24
24
  '/context shows a token breakdown — system, project context, tools, and messages.',
25
25
  '/model <name> sets a model directly (e.g. /model sonnet); selecting one also sets its provider.',
26
26
  '/tips toggles this hint line off if you find it distracting.',
27
+ '/editor composes long prompts in your $EDITOR; /logs <id> view pages a raw log through $PAGER.',
27
28
  ];
28
29
  /**
29
30
  * Pick a random tip index, avoiding the previous one when possible so the
@@ -0,0 +1,43 @@
1
+ import type { ContextFile } from '../../config/contextFiles.js';
2
+ import type { HazeSettings } from '../../config/settings.js';
3
+ import type { TurnExecutionOptions } from '../commands/streaming.js';
4
+ /**
5
+ * Pure user-input policies extracted from ChatScreen so they are unit-testable
6
+ * outside React (architecture-review round 1): attachment gating (F03), the
7
+ * paused-goal recovery-command classification (SU-04), the session
8
+ * model-selection patch policy, and the context-file signature map.
9
+ */
10
+ /** F03: resolve @image mentions into attachments, gated on provider image capability. */
11
+ export declare function prepareUserInput(value: string, settings: HazeSettings): Promise<{
12
+ value: string;
13
+ displayValue?: string;
14
+ options: TurnExecutionOptions;
15
+ error?: string;
16
+ } | undefined>;
17
+ /** SU-04: recovery/configuration commands keep the paused-goal resume affordance alive. */
18
+ export declare function isPausedGoalRecoveryCommand(mode: string, value: string): boolean;
19
+ /**
20
+ * Preserve a resumed session's model selection across unrelated settings
21
+ * writes: the patched fields win, untouched fields keep the current selection.
22
+ */
23
+ export declare function mergeSettingsSelection(next: HazeSettings, current: {
24
+ provider?: string;
25
+ model?: string;
26
+ }, patch?: HazeSettings): HazeSettings;
27
+ /** Signature map for context files (path → `size:mtimeMs`), shared by startup and /context refresh. */
28
+ export declare function contextFileSignatureMap(files: readonly ContextFile[]): Map<string, string>;
29
+ /**
30
+ * One-key resume kind: an incomplete-goal checkpoint restarts the supervisor
31
+ * from its checkpoint; anything else continues the idle-stall retry pool.
32
+ */
33
+ export declare function resumeKindFor(resume: {
34
+ kind: 'model-stream-idle' | 'incomplete-goal';
35
+ retryAttempt: number;
36
+ checkpoint?: unknown;
37
+ }): {
38
+ kind: 'incomplete-goal';
39
+ checkpoint: unknown;
40
+ } | {
41
+ kind: 'model-stream-idle';
42
+ retryAttempt: number;
43
+ };
@@ -0,0 +1,63 @@
1
+ import { activeProvider } from '../../config/providers.js';
2
+ import { imageAttachmentLine } from '../commands/formatters.js';
3
+ import { imageCapabilityError, IMAGE_ONLY_PROMPT_TEXT, resolveImageAttachments } from '../../core/attachments/imageAttachments.js';
4
+ import { resolveReadBlessings } from '../../core/attachments/readBlessings.js';
5
+ /**
6
+ * Pure user-input policies extracted from ChatScreen so they are unit-testable
7
+ * outside React (architecture-review round 1): attachment gating (F03), the
8
+ * paused-goal recovery-command classification (SU-04), the session
9
+ * model-selection patch policy, and the context-file signature map.
10
+ */
11
+ /** F03: resolve @image mentions into attachments, gated on provider image capability. */
12
+ export async function prepareUserInput(value, settings) {
13
+ let resolved;
14
+ try {
15
+ resolved = await resolveImageAttachments(value);
16
+ }
17
+ catch (error) {
18
+ return { value: '', options: {}, error: error instanceof Error ? error.message : String(error) };
19
+ }
20
+ const blessed = await resolveReadBlessings(resolved.text);
21
+ if (resolved.attachments.length === 0 && blessed.blessedPaths.length === 0)
22
+ return { value, options: {} };
23
+ const gateError = imageCapabilityError(activeProvider(settings));
24
+ if (resolved.attachments.length > 0 && gateError) {
25
+ return { value: '', options: {}, error: gateError };
26
+ }
27
+ const displayValue = [resolved.text, ...resolved.attachments.map(imageAttachmentLine)].filter(Boolean).join('\n');
28
+ return {
29
+ value: resolved.text || IMAGE_ONLY_PROMPT_TEXT,
30
+ displayValue,
31
+ options: { attachments: resolved.attachments, blessedPaths: blessed.blessedPaths },
32
+ };
33
+ }
34
+ /** SU-04: recovery/configuration commands keep the paused-goal resume affordance alive. */
35
+ export function isPausedGoalRecoveryCommand(mode, value) {
36
+ return mode !== 'chat' || /^(?:\/compact|\/model|\/provider|\/settings|\/themes|\/resume|\/sessions)\b/.test(value.trim());
37
+ }
38
+ /**
39
+ * Preserve a resumed session's model selection across unrelated settings
40
+ * writes: the patched fields win, untouched fields keep the current selection.
41
+ */
42
+ export function mergeSettingsSelection(next, current, patch) {
43
+ if (!patch)
44
+ return next;
45
+ return {
46
+ ...next,
47
+ provider: 'provider' in patch ? next.provider : current.provider,
48
+ model: 'model' in patch ? next.model : current.model,
49
+ };
50
+ }
51
+ /** Signature map for context files (path → `size:mtimeMs`), shared by startup and /context refresh. */
52
+ export function contextFileSignatureMap(files) {
53
+ return new Map(files.flatMap(file => file.signature ? [[file.path, file.signature]] : []));
54
+ }
55
+ /**
56
+ * One-key resume kind: an incomplete-goal checkpoint restarts the supervisor
57
+ * from its checkpoint; anything else continues the idle-stall retry pool.
58
+ */
59
+ export function resumeKindFor(resume) {
60
+ return resume.kind === 'incomplete-goal' && resume.checkpoint
61
+ ? { kind: 'incomplete-goal', checkpoint: resume.checkpoint }
62
+ : { kind: 'model-stream-idle', retryAttempt: resume.retryAttempt };
63
+ }
@@ -1,3 +1,4 @@
1
+ import { isStoredReasoning, resolveReasoningChoice } from '../../../core/agent/reasoningPolicy.js';
1
2
  import { resolveReasoningCommand } from '../../commands/reasoningCommand.js';
2
3
  import { selectThemeResult } from '../../commands/themesCommand.js';
3
4
  import { SESSION_ACTIONS } from '../../commands/sessionPicker.js';
@@ -42,15 +43,22 @@ export function createSessionThemeHandlers(deps, ctx) {
42
43
  showMessage(result.message);
43
44
  }
44
45
  async function selectReasoning(value) {
45
- const result = resolveReasoningCommand(value, deps.settings.reasoning);
46
- if (result.action === 'set' || result.action === 'clear') {
47
- await ctx.applySettings(result.settingsPatch);
46
+ const hook = deps.sessionReasoning;
47
+ const modelSelector = hook?.modelSelector();
48
+ if (!hook || !modelSelector) {
49
+ showMessage('No provider/model configured. /reasoning sets a per-model level; run /provider and /model first.');
48
50
  setMode('chat');
49
- showMessage(result.message);
50
51
  return;
51
52
  }
52
- // Unreachable from the picker (its values always set or clear) but narrows
53
- // the remaining variants for the type checker.
53
+ const stored = isStoredReasoning(deps.settings.reasoning) ? deps.settings.reasoning : undefined;
54
+ const result = resolveReasoningCommand(value, { current: resolveReasoningChoice(hook.get(modelSelector), stored), stored, modelSelector });
55
+ if (result.action === 'set')
56
+ hook.set(modelSelector, result.setting);
57
+ else if (result.action === 'reset')
58
+ hook.set(modelSelector, undefined);
59
+ setMode('chat');
60
+ // Unreachable from the picker (its values always set or reset) but narrows
61
+ // the open-picker variant away for the type checker.
54
62
  if (result.action !== 'open-picker')
55
63
  showMessage(result.message);
56
64
  }
@@ -2,6 +2,7 @@ import type { HazeMcpServer, HazeProviderSettings, HazeSettings } from '../../..
2
2
  import type { HazeLspServer } from '../../../config/lspSettings.js';
3
3
  import type { LoadedSkill, SkillSource } from '../../../skills/types.js';
4
4
  import type { SessionSummary } from '../../../core/session/sessionStore.js';
5
+ import type { StoredReasoningSetting } from '../../../core/agent/reasoningPolicy.js';
5
6
  import type { Mode } from '../../commands/chatModes.js';
6
7
  import type { WizardUiAction, WizardUiState } from './uiState.js';
7
8
  /**
@@ -16,7 +17,7 @@ export interface WizardDispatchDeps {
16
17
  wizard: WizardUiState;
17
18
  updateWizard: (action: WizardUiAction) => void;
18
19
  setMode: (mode: Mode) => void;
19
- setSettings: (next: HazeSettings) => void;
20
+ setSettings: (next: HazeSettings, patch?: HazeSettings) => void;
20
21
  showMessage: (message: string | undefined) => void;
21
22
  resumeSessionById?: (id: string) => Promise<boolean>;
22
23
  forkSessionById?: (id: string) => Promise<boolean>;
@@ -25,6 +26,12 @@ export interface WizardDispatchDeps {
25
26
  setBusy: (busy: boolean) => void;
26
27
  /** Busy label to restore when a skill creation finishes. */
27
28
  idleBusyLabel: string;
29
+ /** Session-scoped per-model reasoning overrides (`/reasoning`); interactive screen only. */
30
+ sessionReasoning?: {
31
+ modelSelector: () => string | undefined;
32
+ get: (modelSelector: string) => StoredReasoningSetting | undefined;
33
+ set: (modelSelector: string, setting: StoredReasoningSetting | undefined) => void;
34
+ };
28
35
  }
29
36
  /** Setter shims over the single wizard-state reducer, shared by every handler family. */
30
37
  export interface WizardSetterContext {
@@ -17,7 +17,7 @@ export function createWizardDispatch(deps) {
17
17
  showMessage,
18
18
  applySettings: async (patch) => {
19
19
  const next = await updateSettings(patch);
20
- setSettings(next);
20
+ setSettings(next, patch);
21
21
  return next;
22
22
  },
23
23
  setSelectedSessionId: id => deps.updateWizard({ type: 'set', key: 'selectedSessionId', value: id }),