@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.
- package/CHANGELOG.md +33 -1
- package/README.md +13 -8
- package/SECURITY.md +1 -1
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +7 -0
- package/dist/cli/chat/BusyBar.js +8 -0
- package/dist/cli/chat/DynamicFrame.d.ts +37 -0
- package/dist/cli/chat/DynamicFrame.js +43 -0
- package/dist/cli/chat/busyIndicator.d.ts +3 -1
- package/dist/cli/chat/busyIndicator.js +11 -9
- package/dist/cli/chat/chatMetrics.d.ts +1 -1
- package/dist/cli/chat/chatMetrics.js +3 -3
- package/dist/cli/chat/inputSuggestions.js +2 -1
- package/dist/cli/chat/liveRegion.js +1 -1
- package/dist/cli/chat/messages.js +27 -16
- package/dist/cli/chat/sessionLifecycle.d.ts +3 -1
- package/dist/cli/chat/sessionLifecycle.js +13 -2
- package/dist/cli/chat/sessionRecorder.d.ts +2 -1
- package/dist/cli/chat/sessionRecorder.js +8 -0
- package/dist/cli/chat/shutdown.d.ts +27 -0
- package/dist/cli/chat/shutdown.js +79 -0
- package/dist/cli/chat/terminalControl.d.ts +45 -0
- package/dist/cli/chat/terminalControl.js +107 -0
- package/dist/cli/chat/tips.js +1 -0
- package/dist/cli/chat/userInput.d.ts +43 -0
- package/dist/cli/chat/userInput.js +63 -0
- package/dist/cli/chat/wizard/sessionThemeHandlers.js +14 -6
- package/dist/cli/chat/wizard/types.d.ts +8 -1
- package/dist/cli/chat/wizardDispatch.js +1 -1
- package/dist/cli/commands/chat.js +251 -172
- package/dist/cli/commands/commandHelp.js +6 -2
- package/dist/cli/commands/commands.d.ts +8 -0
- package/dist/cli/commands/commands.js +11 -0
- package/dist/cli/commands/formatters.d.ts +1 -1
- package/dist/cli/commands/formatters.js +20 -2
- package/dist/cli/commands/logsCommand.js +21 -2
- package/dist/cli/commands/reasoningCommand.d.ts +23 -14
- package/dist/cli/commands/reasoningCommand.js +53 -20
- package/dist/cli/commands/runCommand.js +19 -11
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +11 -6
- package/dist/cli/commands/streaming/attemptSetup.d.ts +1 -0
- package/dist/cli/commands/streaming/attemptSetup.js +11 -5
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +8 -1
- package/dist/cli/commands/streaming/goalCheckpoint.js +3 -2
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +4 -0
- package/dist/cli/commands/streaming/goalSupervisor.js +43 -7
- package/dist/cli/commands/streaming/prepareStep.js +7 -3
- package/dist/cli/commands/streaming/streamLoop.d.ts +5 -0
- package/dist/cli/commands/streaming/streamLoop.js +3 -0
- package/dist/cli/commands/streaming/toolPartHandlers.js +6 -0
- package/dist/cli/commands/streaming.d.ts +1 -1
- package/dist/cli/commands/streaming.js +23 -17
- package/dist/cli/commands/wizardFlow.d.ts +5 -2
- package/dist/cli/commands/wizardFlow.js +17 -10
- package/dist/cli/index.js +17 -1
- package/dist/config/contextFiles.d.ts +9 -0
- package/dist/config/contextFiles.js +21 -1
- package/dist/config/modelCatalog.d.ts +3 -0
- package/dist/config/modelCatalog.js +29 -0
- package/dist/config/providerPresets.d.ts +1 -1
- package/dist/config/providerPresets.js +42 -3
- package/dist/config/settings.d.ts +7 -3
- package/dist/config/settings.js +8 -0
- package/dist/core/agent/budgets.d.ts +13 -15
- package/dist/core/agent/budgets.js +15 -17
- package/dist/core/agent/completionController.d.ts +6 -2
- package/dist/core/agent/completionController.js +16 -3
- package/dist/core/agent/goalPolicy.d.ts +10 -0
- package/dist/core/agent/goalPolicy.js +44 -6
- package/dist/core/agent/projectPreflight.d.ts +2 -0
- package/dist/core/agent/projectPreflight.js +56 -0
- package/dist/core/agent/reasoningPolicy.d.ts +34 -4
- package/dist/core/agent/reasoningPolicy.js +27 -4
- package/dist/core/agent/workState.d.ts +8 -0
- package/dist/core/agent/workState.js +191 -8
- package/dist/core/providerContracts.d.ts +29 -0
- package/dist/core/providerContracts.js +1 -0
- package/dist/core/session/sessionReport.d.ts +33 -0
- package/dist/core/session/sessionReport.js +121 -0
- package/dist/core/session/sessionSlimming.js +9 -3
- package/dist/core/session/sessionStore.d.ts +12 -0
- package/dist/core/session/sessionStore.js +20 -4
- package/dist/core/subagent/contracts.d.ts +3 -25
- package/dist/core/subagent/executionProfiles.js +4 -4
- package/dist/core/validation/outputParser.d.ts +6 -1
- package/dist/core/validation/outputParser.js +6 -2
- package/dist/llm/client.d.ts +4 -2
- package/dist/llm/client.js +17 -10
- package/dist/llm/hazeTools.d.ts +8553 -8550
- package/dist/llm/hazeTools.js +6 -503
- package/dist/llm/lspTools.d.ts +120 -120
- package/dist/llm/mcp.js +3 -0
- package/dist/llm/requestContext.d.ts +1 -1
- package/dist/llm/requestContext.js +1 -1
- package/dist/{core/subagent → llm}/subagentRunner.d.ts +9 -9
- package/dist/{core/subagent → llm}/subagentRunner.js +22 -25
- package/dist/llm/systemPrompt.d.ts +11 -1
- package/dist/llm/systemPrompt.js +2 -11
- package/dist/llm/tools/fetchTool.d.ts +30 -30
- package/dist/llm/tools/fileTools.d.ts +7768 -0
- package/dist/llm/tools/fileTools.js +510 -0
- package/dist/llm/tools/processTool.d.ts +30 -30
- package/dist/llm/tools/shellTool.d.ts +30 -30
- package/dist/llm/tools/shellTool.js +8 -4
- package/dist/llm/tools/toolContext.d.ts +3 -32
- package/dist/llm/tools/toolContext.js +33 -52
- package/dist/llm/tools/toolContextState.d.ts +40 -0
- package/dist/llm/tools/toolContextState.js +34 -0
- package/dist/llm/workerContext.d.ts +7 -0
- package/dist/llm/workerContext.js +18 -1
- package/dist/skills/SkillLoader.js +3 -3
- package/dist/skills/SkillRegistry.js +3 -3
- package/dist/skills/builder/SkillBuilder.js +3 -3
- package/dist/skills/confinement.d.ts +7 -0
- package/dist/skills/confinement.js +15 -0
- package/dist/ui/codeHighlight.js +4 -4
- package/dist/ui/components/MarkdownText.js +7 -8
- package/dist/ui/components/NativeIndicators.d.ts +15 -0
- package/dist/ui/components/NativeIndicators.js +32 -0
- package/dist/ui/components/StreamingMarkdownText.d.ts +9 -0
- package/dist/ui/components/StreamingMarkdownText.js +38 -0
- package/dist/ui/components/TextInput.d.ts +7 -2
- package/dist/ui/components/TextInput.js +103 -46
- package/dist/ui/components/WizardChoices.d.ts +18 -0
- package/dist/ui/components/WizardChoices.js +32 -0
- package/dist/ui/inputBuffer.js +12 -6
- package/dist/ui/textGeometry.d.ts +14 -0
- package/dist/ui/textGeometry.js +31 -0
- package/package.json +14 -13
- /package/dist/cli/{contextReport.d.ts → contextReportCli.d.ts} +0 -0
- /package/dist/cli/{contextReport.js → contextReportCli.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 1.5.0 - 2026-10-04
|
|
4
|
+
|
|
5
|
+
Ink 8 terminal modernization with formatted streamed Markdown, per-model session-scoped reasoning, model steering for compact models, and pinned session model selections.
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Streaming assistant Markdown is rendered as formatted terminal rows: the active root block is rendered through the settled Markdown renderer offscreen and shown in the dynamic tail, clamped to the live-region budget. Whole-block parsing is preserved so later text can still reclassify a block; only parser-stable preceding roots enter the static transcript, and clamped rows are never lost — they enter `<Static>` verbatim once settled.
|
|
10
|
+
- `/reasoning` is now per-model and session-scoped: each `provider:model` keeps its own in-memory level for the session, with `unset` sending no parameter and `reset` dropping the override. `/thinking` is an alias. The built-in default level is now `medium` (was `high`).
|
|
11
|
+
- Model steering for compact models (`steeringProfile: "compact"` setting): nearby package-script names are listed for smaller working slices, validation reminders arrive earlier, and history compacts at 70% of the usual message budget. Completion evidence is not weakened.
|
|
12
|
+
- `escalationModel` setting (registered `provider:model` selector): after a goal makes no measurable progress or exhausts context recovery, haze tries this explicitly configured model exactly once, keeping the conversation and goal evidence and announcing the switch. Haze never picks a fallback model on its own.
|
|
13
|
+
- `haze report [id] [--json]`: a metadata-only summary of the latest workspace session (or one by id) — model, goal outcomes, tool/validation counts, context size, and evidence mismatches — without printing prompts, commands, paths, or tool output.
|
|
14
|
+
- The live busy indicator for the shell tool shows the running command (e.g. `Running npm test`), reduced to the program plus its first non-flag argument so multi-file commands do not echo whole file lists into the one-line label.
|
|
15
|
+
- Session model pinning: sessions record a `model_selection` entry restored on resume, continue, and fork, so changing the global default never rewrites an active session's model. Headless `--resume` follows the saved selection unless `--model` is explicit.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Upgrade to pinned Ink 8.0.0, retaining normal-screen scrollback, incremental rendering, the 15 FPS cap, and application-owned interrupts. Startup now clears only the viewport, not preexisting scrollback.
|
|
20
|
+
- Budget the complete dynamic chat frame, including multiline drafts, suggestions, tasks, queued follow-ups, pause hints, debug panels, and live previews. Tiny terminals use a borderless prompt; clipped previews never truncate finalized transcript/session content.
|
|
21
|
+
- Use native bracketed paste so pasted newlines, slash commands, probe-shaped text, and control bytes remain data rather than shortcuts. Unsafe control characters are replaced only in the input display; submitted data keeps its normalized content.
|
|
22
|
+
- Edit and wrap input by graphemes and terminal cells, with Unicode-aware table/code widths and background padding. Unsupported Ctrl combinations no longer insert letters; masked values are excluded from input history.
|
|
23
|
+
- Route `/exit`, `/quit`, and legacy/Kitty Ctrl+C through one bounded shutdown that aborts active work, quarantines late callbacks, flushes owned persistence, and cleans resources. Terminal defaults are restored even when rendering or exit waiting fails.
|
|
24
|
+
- Native Ink indicators replace the `ink-spinner` dependency: `ActivitySpinner`, `StatusNotice`, and `BusyBar` ride Ink 8's shared animation timer, busy heartbeat included, instead of `setInterval` timers; screen-reader mode gets a static spinner glyph and a paused elapsed ticker.
|
|
25
|
+
- Terminal interaction is modernized on Ink 8 capabilities: `/editor` composes in `$EDITOR` and `/logs <id>` pages raw JSONL through `$PAGER` via a suspended-terminal handoff, IME composition positions the real hardware cursor at the editing point, and the shutdown path waits for a render flush so the final frame reaches the TTY before unmount and OSC 10/11 restore.
|
|
26
|
+
- The absolute 30-minute per-turn cap is removed: a turn now runs until the model finishes, the user cancels, or an idle-stall / step / tool budget boundary ends it. The headless `--timeout` deadline remains the explicit opt-in whole-goal budget, and the goal supervisor clamps each physical turn to the remaining goal budget.
|
|
27
|
+
- Refreshed the model catalog and provider preset limits; runtime and development dependencies upgraded.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Completion evidence stays honest across repairs and compounding: a validation-only goal whose check failed keeps its truthful `tool_failure` classification instead of escalating into a repair continuation; a failed edit/write after a failed check no longer inherits the validation-repair affordance; `npm cd`/`--prefix` commands normalize to a shared validation identity only when they are a single foreground command, so compounds and redirects stay distinct checks; and carried failed-check identities are no longer truncated at eight — only the model-facing preview is bounded, with the true count reported.
|
|
32
|
+
- Goal status reopens when the ledger restarts: a `goal_start`/`goal_continue` entry after a terminal `goal_end` reopens the goal for reporting and clears stale stop reason, gate decision, and old event evidence, so a new terminal boundary is compared only against its own evidence. The ledger validator no longer rejects more than eight unresolved failed check ids.
|
|
33
|
+
- Suspended child launching is hardened: `less` values are split into executable plus quoted arguments instead of being spawned as one literal path, and a pager quitting early (EPIPE on its input pipe) no longer rejects the suspended run. `/logs <id>` shows a bounded inline preview whenever paging is unavailable (short logs or screen-reader mode) instead of only reporting the summary.
|
|
34
|
+
- Wizard/settings writes carry their patch so unrelated changes keep the session model, the status bar shows the session selection, and the per-session reasoning map is read from the current session identity instead of a stale ref.
|
|
35
|
+
- The IME composition cursor sits at the editing point (measured frame-origin coordinates), covered by a VT-emulator test asserting the final cursor cell from real escape output.
|
|
4
36
|
|
|
5
37
|
## 1.4.0 - 2026-09-24
|
|
6
38
|
|
package/README.md
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
A minimal LLM harness for your terminal.
|
|
4
4
|
|
|
5
|
-
## What's new in 1.
|
|
5
|
+
## What's new in 1.5.0
|
|
6
6
|
|
|
7
|
-
haze 1.
|
|
7
|
+
haze 1.5.0 modernizes the terminal experience on Ink 8 — formatted streamed Markdown, native spinners and busy indicators, `$EDITOR`/`$PAGER` handoffs, and IME-aware cursor placement — and adds model steering for compact models, per-model session-scoped `/reasoning` (with the `/thinking` alias), pinned session model selections, and a metadata-only `haze report`.
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
9
|
+
- Formatted streaming: assistant Markdown renders as formatted terminal rows while it streams, clamped to the viewport budget; clamped rows settle into the transcript verbatim, never lost.
|
|
10
|
+
- Model steering: `steeringProfile: "compact"` lists nearby package-script names, asks for smaller working slices, reminds about validation earlier, and compacts history at 70% of the usual budget — completion evidence stays just as strict. `escalationModel` hands a stuck goal to one explicitly configured model, once, with the conversation and evidence intact.
|
|
11
|
+
- Reasoning control: `/reasoning` (alias `/thinking`) keeps a per-model level for the session — `unset` sends no parameter, `reset` drops the override — and the status bar shows the effective level. Headless runs keep `--reasoning <level|unset>` as a run-scoped override.
|
|
12
|
+
- Session model pinning: each session remembers its model selection on resume, continue, and fork; changing the global default never rewrites an active session. Headless `--resume` follows the saved selection unless `--model` is explicit.
|
|
13
|
+
- `haze report [id] [--json]`: goal outcomes, tool/validation counts, context size, and evidence mismatches from session metadata — never prompts, commands, paths, or tool output.
|
|
14
|
+
- Terminal modernization: Ink 8 with native bracketed paste, grapheme/cell-aware editing, one bounded shutdown path, suspended-terminal `$EDITOR`/`$PAGER` handoffs, and screen-reader-aware indicators. The implicit 30-minute per-turn cap is gone; `--timeout` remains the explicit opt-in goal budget.
|
|
15
15
|
|
|
16
16
|
Previous releases:
|
|
17
17
|
|
|
18
|
+
- `1.4.0`: per-run reasoning control (`--reasoning` for headless runs and a live status-bar indicator) on top of the 1.3.0 hardening pass — uniform secret/file boundaries, evidence that survives failed exits, durable session lifecycle fixes, credential-safe provider discovery, and honest output reduction.
|
|
18
19
|
- `1.2.1`: edit-recovery instructs instead of restricting — the model is told which path to read and why, while the execution-time gate enforces the fresh read.
|
|
19
20
|
- `1.2.0`: provider-usage context accounting, recoverable compact-and-retry overflow handling, model-written split-turn-aware compaction, `pipefail` validation truthfulness, and a configurable retry pool.
|
|
20
21
|
- `1.1.1`: durable goal ledgers and crash-resume frontiers; headless `--until-done` relaunches with bounded notices and a no-progress guard; proportional task/validation completion gates; and smaller orchestration internals.
|
|
@@ -86,6 +87,8 @@ On first run, create or choose a provider, then choose your first model:
|
|
|
86
87
|
/model local:llama3.1
|
|
87
88
|
```
|
|
88
89
|
|
|
90
|
+
Sessions remember their provider and model across resume, continue, and fork, even if the global default changes. `/model` explicitly changes the current session's selection and the default for new sessions. Headless resume uses the saved selection unless `--model` overrides it for that run. If the saved model is no longer configured, choose or re-add it rather than silently switching models. Older sessions without model metadata adopt the current default when resumed.
|
|
91
|
+
|
|
89
92
|
### MCP servers
|
|
90
93
|
|
|
91
94
|
Use `/mcp` to connect [Model Context Protocol](https://modelcontextprotocol.io) servers and give the agent more tools. The interactive picker works like `/provider`: enable, disable, or remove a server; set its API key; or add one from a preset or custom configuration. The built-in Context7 preset provides current library documentation.
|
|
@@ -395,6 +398,8 @@ Use `AGENTS.md` for project conventions, commands, architecture notes, and anyth
|
|
|
395
398
|
|
|
396
399
|
Most haze behaviour needs no configuration; a few optional keys in `~/.haze/settings.json` tune reliability and context handling. All are validated loudly — malformed values fail with a clear settings error instead of being silently ignored.
|
|
397
400
|
|
|
401
|
+
- `steeringProfile` (`"standard"` default, or `"compact"`): compact lists nearby package script names, asks for smaller working slices, gives earlier validation reminders, and compacts history at 70% of the usual message budget. Choose it for models that struggle with long contexts or large tool batches; completion checks stay the same.
|
|
402
|
+
- `escalationModel` (registered model selector, optional): after a goal makes no measurable progress or exhausts its context recovery, haze tries this explicitly configured model once. It keeps the same conversation and goal evidence, and announces the switch. Haze never chooses a fallback model on its own.
|
|
398
403
|
- `modelRetries` (integer 0–10, default 2): size of the shared bounded retry pool for transient model errors and idle-stream stalls. Raise it for providers that terminate long streams aggressively; `0` disables automatic retries (a stalled stream pauses with the goal preserved for a one-key resume). The effective value is reported in `timeout` and `retry` stream events as `maxRetries`.
|
|
399
404
|
- `retryBaseDelayMs` (integer 250–60000, default 1000): base delay for the shared retry pool's exponential backoff (`base × 2^attempt`, capped at 4× the base). The pool resets whenever a failed attempt completed steps since the previous retry, so intermittent blips on a long turn never exhaust it.
|
|
400
405
|
- `contextWindowFallbackTokens` / `localContextWindowFallbackTokens` (default 128K hosted / 32K local): context-window guess for models without limits metadata or a curated catalog entry. Every turn emits a `context_budget` event naming the window and its source, and the interactive warning fires once per model per session when the built-in default was used.
|
package/SECURITY.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| Version | Supported |
|
|
6
6
|
|---------|-----------|
|
|
7
|
-
| Latest minor (`1.
|
|
7
|
+
| Latest minor (`1.5.x`) | Yes — security fixes |
|
|
8
8
|
| Older minors and pre-1.0 (`0.x`) | No — upgrade required |
|
|
9
9
|
|
|
10
10
|
Security fixes are provided for the latest published minor release. Upgrade to the newest release before reporting an issue that may already have been fixed.
|
package/dist/buildInfo.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denizokcu/haze",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"commit": "
|
|
5
|
-
"builtAt": "2026-
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"commit": "cd0daa845cacfe4aee5adb0cd8f521c9885acf79",
|
|
5
|
+
"builtAt": "2026-10-04T20:57:37.360Z",
|
|
6
6
|
"sourceRoot": "/Users/deniz.okcu/development/haze"
|
|
7
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { ActivitySpinner } from '../../ui/components/NativeIndicators.js';
|
|
4
|
+
import { theme } from '../../ui/theme.js';
|
|
5
|
+
/** Spinner ticks stay within this subtree, not the transcript orchestrator. */
|
|
6
|
+
export function BusyBar({ label, elapsed, tip }) {
|
|
7
|
+
return _jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsxs(Box, { overflow: "hidden", children: [_jsx(ActivitySpinner, {}), _jsx(Box, { flexShrink: 0, width: 1 }), _jsxs(Text, { wrap: "truncate-end", children: [_jsxs(Text, { color: theme.command, bold: true, children: [label, elapsed ? _jsxs(Text, { color: theme.muted, children: [" \u00B7 ", elapsed] }) : null] }), _jsx(Text, { color: theme.muted, children: " \u00B7 type to queue follow-up \u00B7 esc to interrupt" })] })] }), tip && _jsxs(Text, { color: theme.muted, wrap: "truncate-end", children: [_jsx(Text, { bold: true, children: "Tip:" }), " ", tip] })] });
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FrameSections {
|
|
3
|
+
live?: React.ReactNode | ((rows: number) => React.ReactNode);
|
|
4
|
+
tasks?: React.ReactNode;
|
|
5
|
+
queue?: React.ReactNode;
|
|
6
|
+
debug?: React.ReactNode;
|
|
7
|
+
status?: React.ReactNode;
|
|
8
|
+
activity?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export interface InputDemand {
|
|
11
|
+
input: number;
|
|
12
|
+
suggestions: number;
|
|
13
|
+
}
|
|
14
|
+
/** Allocate the entire normal-screen dynamic frame, never Static history. */
|
|
15
|
+
export declare function allocateFrame(rows: number, columns: number, sections: FrameSections, demand?: InputDemand): {
|
|
16
|
+
compact: boolean;
|
|
17
|
+
input: number;
|
|
18
|
+
border: number;
|
|
19
|
+
activity: number;
|
|
20
|
+
status: number;
|
|
21
|
+
suggestions: number;
|
|
22
|
+
tasks: number;
|
|
23
|
+
queue: number;
|
|
24
|
+
debug: number;
|
|
25
|
+
live: number;
|
|
26
|
+
};
|
|
27
|
+
export declare function DynamicFrame({ rows, columns, sections, input }: {
|
|
28
|
+
rows: number;
|
|
29
|
+
columns: number;
|
|
30
|
+
sections: FrameSections;
|
|
31
|
+
input: (limits: {
|
|
32
|
+
width: number;
|
|
33
|
+
inputRows: number;
|
|
34
|
+
suggestionRows: number;
|
|
35
|
+
onRowsChange: (demand: InputDemand) => void;
|
|
36
|
+
}) => React.ReactNode;
|
|
37
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import { Box, useBoxMetrics } from 'ink';
|
|
4
|
+
import { theme } from '../../ui/theme.js';
|
|
5
|
+
/** Allocate the entire normal-screen dynamic frame, never Static history. */
|
|
6
|
+
export function allocateFrame(rows, columns, sections, demand = { input: 1, suggestions: 0 }) {
|
|
7
|
+
// Keep normal-screen output below Ink's fullscreen threshold, including long
|
|
8
|
+
// live previews. One-cell terminals still get an editable input row.
|
|
9
|
+
let remaining = Math.max(1, Math.floor(rows) - 1);
|
|
10
|
+
const take = (wanted) => {
|
|
11
|
+
const granted = Math.min(remaining, wanted);
|
|
12
|
+
remaining -= granted;
|
|
13
|
+
return granted;
|
|
14
|
+
};
|
|
15
|
+
const compact = columns < 12 || rows < 6;
|
|
16
|
+
const input = take(compact ? 1 : Math.min(4, Math.max(1, demand.input), Math.max(1, rows - 5)));
|
|
17
|
+
const border = compact ? 0 : take(2);
|
|
18
|
+
const activity = sections.activity ? take(1) : 0;
|
|
19
|
+
const status = sections.status ? take(compact ? 1 : 2) : 0;
|
|
20
|
+
const suggestions = take(Math.min(5, demand.suggestions, Math.floor(remaining / 3)));
|
|
21
|
+
const tasks = sections.tasks ? take(Math.min(6, Math.floor(remaining / 3))) : 0;
|
|
22
|
+
const queue = sections.queue ? take(Math.min(3, Math.floor(remaining / 4))) : 0;
|
|
23
|
+
const debug = sections.debug ? take(Math.min(4, Math.floor(remaining / 4))) : 0;
|
|
24
|
+
const live = sections.live ? take(remaining) : 0;
|
|
25
|
+
return { compact, input, border, activity, status, suggestions, tasks, queue, debug, live };
|
|
26
|
+
}
|
|
27
|
+
/** Cap panel geometry without stretching short output into a fullscreen frame. */
|
|
28
|
+
function Panel({ rows, children }) {
|
|
29
|
+
if (rows === 0)
|
|
30
|
+
return null;
|
|
31
|
+
return _jsx(Box, { flexDirection: "column", maxHeight: rows, flexShrink: 0, overflow: "hidden", children: _jsx(Box, { flexDirection: "column", flexShrink: 0, width: "100%", children: children }) });
|
|
32
|
+
}
|
|
33
|
+
export function DynamicFrame({ rows, columns, sections, input }) {
|
|
34
|
+
const [demand, setDemand] = useState({ input: 1, suggestions: 0 });
|
|
35
|
+
const inputRef = useRef(null);
|
|
36
|
+
const metrics = useBoxMetrics(inputRef);
|
|
37
|
+
const budget = allocateFrame(rows, columns, sections, demand);
|
|
38
|
+
const safeWidth = Math.max(1, columns - (budget.border ? 4 : 0));
|
|
39
|
+
// Previous measurements may be wider on shrink: first-render arithmetic stays authoritative.
|
|
40
|
+
const inputWidth = metrics.hasMeasured && metrics.clientWidth > 0 ? Math.min(safeWidth, metrics.clientWidth) : safeWidth;
|
|
41
|
+
const onRowsChange = (next) => setDemand(previous => previous.input === next.input && previous.suggestions === next.suggestions ? previous : next);
|
|
42
|
+
return _jsxs(Box, { flexDirection: "column", width: Math.max(1, columns), flexShrink: 0, children: [_jsx(Panel, { rows: budget.live, children: typeof sections.live === 'function' ? sections.live(budget.live) : sections.live }), _jsx(Panel, { rows: budget.debug, children: sections.debug }), _jsx(Panel, { rows: budget.queue, children: sections.queue }), _jsx(Panel, { rows: budget.tasks, children: sections.tasks }), _jsx(Panel, { rows: budget.activity, children: sections.activity }), _jsx(Box, { flexDirection: "column", height: budget.input + budget.suggestions + budget.border, flexShrink: 0, overflow: "hidden", borderStyle: budget.border ? 'round' : undefined, borderColor: theme.border, paddingX: budget.border ? 1 : 0, children: _jsx(Box, { ref: inputRef, width: "100%", flexDirection: "column", minWidth: 0, children: input({ width: inputWidth, inputRows: budget.input, suggestionRows: budget.suggestions, onRowsChange }) }) }), _jsx(Panel, { rows: budget.status, children: sections.status })] });
|
|
43
|
+
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Busy state with a one-second heartbeat. The tick re-renders the elapsed-time
|
|
3
3
|
* label so the developer always sees rolling activity even when the model is
|
|
4
4
|
* thinking with no streamed output and no tool is running (the "looks stuck"
|
|
5
|
-
* problem). Extracted from ChatScreen alongside BusyBar.
|
|
5
|
+
* problem). Extracted from ChatScreen alongside BusyBar. The heartbeat rides
|
|
6
|
+
* Ink 8's shared animation timer so every animated component (spinners,
|
|
7
|
+
* elapsed labels) consolidates into one render cycle under maxFps.
|
|
6
8
|
*/
|
|
7
9
|
export declare function useBusyIndicator(): {
|
|
8
10
|
busy: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
import { useAnimation, useIsScreenReaderEnabled } from 'ink';
|
|
2
3
|
import { formatElapsedTimeWhole } from '../../utils/format.js';
|
|
3
4
|
/** Elapsed-time label for the busy indicator heartbeat, or '' when no turn is active. */
|
|
4
5
|
function busyElapsedLabel(startedAt) {
|
|
@@ -11,18 +12,19 @@ function busyElapsedLabel(startedAt) {
|
|
|
11
12
|
* Busy state with a one-second heartbeat. The tick re-renders the elapsed-time
|
|
12
13
|
* label so the developer always sees rolling activity even when the model is
|
|
13
14
|
* thinking with no streamed output and no tool is running (the "looks stuck"
|
|
14
|
-
* problem). Extracted from ChatScreen alongside BusyBar.
|
|
15
|
+
* problem). Extracted from ChatScreen alongside BusyBar. The heartbeat rides
|
|
16
|
+
* Ink 8's shared animation timer so every animated component (spinners,
|
|
17
|
+
* elapsed labels) consolidates into one render cycle under maxFps.
|
|
15
18
|
*/
|
|
16
19
|
export function useBusyIndicator() {
|
|
17
20
|
const [busy, setBusyState] = useState(false);
|
|
18
21
|
const turnStartedAtRef = useRef(undefined);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}, [busy]);
|
|
22
|
+
const screenReader = useIsScreenReaderEnabled();
|
|
23
|
+
// Whole-second elapsed labels: one shared-timer frame per second is enough.
|
|
24
|
+
// Screen-reader mode keeps the elapsed text static between turns instead
|
|
25
|
+
// of announcing a re-render every second. The animation state update itself
|
|
26
|
+
// re-renders this component, refreshing the elapsed label below.
|
|
27
|
+
useAnimation({ interval: 1000, isActive: busy && !screenReader });
|
|
26
28
|
function setBusy(nextBusy) {
|
|
27
29
|
if (nextBusy && !busy)
|
|
28
30
|
turnStartedAtRef.current = Date.now();
|
|
@@ -45,7 +45,7 @@ export function estimateConversationTokens(messages) {
|
|
|
45
45
|
/** Status-bar numbers for the transcript, extracted so render stays declarative (CR-006). */
|
|
46
46
|
export function statusBarMetrics(input) {
|
|
47
47
|
const { messages, tokenUsage, enabledSkillCount } = input;
|
|
48
|
-
const
|
|
48
|
+
const assistantMessages = messages.filter(message => message.role === 'assistant' && !message.hidden).length;
|
|
49
49
|
const toolsUsed = toolCallCount(messages);
|
|
50
50
|
const fallbackTokens = estimateConversationTokens(messages);
|
|
51
51
|
const estimatedLogicalInput = tokenUsage.logicalInputEstimate || fallbackTokens.input || 0;
|
|
@@ -55,7 +55,7 @@ export function statusBarMetrics(input) {
|
|
|
55
55
|
const inputEstimated = providerInput == null || effectiveInput !== providerInput;
|
|
56
56
|
const outputEstimated = tokenUsage.outputTokens == null;
|
|
57
57
|
const backgroundLabel = input.backgroundProcessCount ? ` / ⏵ ${input.backgroundProcessCount} bg` : '';
|
|
58
|
-
const statusDetailLabel = `${
|
|
58
|
+
const statusDetailLabel = `${assistantMessages} message${assistantMessages === 1 ? '' : 's'} / ${toolsUsed} tool calls / LLM ${inputEstimated ? '~' : ''}↑${formatTokenCount(effectiveInput)} ${outputEstimated ? '~' : ''}↓${formatTokenCount(effectiveOutput)} / ${enabledSkillCount} skill${enabledSkillCount === 1 ? '' : 's'}${backgroundLabel}`;
|
|
59
59
|
const hasTokenBreakdown = tokenUsage.systemPrompt > 0 || tokenUsage.messages > 0 || tokenUsage.toolSchemas > 0 || effectiveInput > 0 || effectiveOutput > 0;
|
|
60
|
-
return {
|
|
60
|
+
return { assistantMessages, toolsUsed, effectiveInput, effectiveOutput, inputEstimated, outputEstimated, statusDetailLabel, hasTokenBreakdown };
|
|
61
61
|
}
|
|
@@ -8,7 +8,8 @@ const CHAT_COMMAND_SUGGESTIONS = [
|
|
|
8
8
|
{ value: '/mcp', description: 'Manage MCP servers (Context7, etc.)', kind: 'command' },
|
|
9
9
|
{ value: '/settings', description: 'Show provider, model, API key, and context status', kind: 'command' },
|
|
10
10
|
{ value: '/themes', description: 'Choose a terminal theme (light palettes and oh-my-zsh ports included)', kind: 'command' },
|
|
11
|
-
{ value: '/reasoning', description: 'Set reasoning effort
|
|
11
|
+
{ value: '/reasoning', description: 'Set reasoning effort for the active model, this session (none…xhigh), unset, or reset', kind: 'command' },
|
|
12
|
+
{ value: '/thinking', description: 'Alias for /reasoning. Set reasoning effort for the active model, this session', kind: 'command' },
|
|
12
13
|
{ value: '/context', description: 'Show token breakdown of system, tools, MCP, and messages', kind: 'command' },
|
|
13
14
|
{ value: '/skills', description: 'Manage Markdown skills (add, enable/disable, validate, remove)', kind: 'command' },
|
|
14
15
|
{ value: '/tips', description: 'Toggle the rotating tips shown while the model is thinking', kind: 'command' },
|
|
@@ -33,7 +33,7 @@ export function clampTextTail(text, width, maxLines) {
|
|
|
33
33
|
const total = rows.reduce((sum, count) => sum + count, 0);
|
|
34
34
|
if (total <= maxLines)
|
|
35
35
|
return { text, hiddenLineCount: 0 };
|
|
36
|
-
const visibleBudget = Math.max(
|
|
36
|
+
const visibleBudget = Math.max(0, maxLines - 1); // reserve the indicator row
|
|
37
37
|
let used = 0;
|
|
38
38
|
let start = logical.length;
|
|
39
39
|
while (start > 0) {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Box, Text } from 'ink';
|
|
4
|
-
import
|
|
4
|
+
import { ActivitySpinner } from '../../ui/components/NativeIndicators.js';
|
|
5
5
|
import { formatElapsedTime, formatElapsedTimeWhole } from '../../utils/format.js';
|
|
6
6
|
import { MarkdownText } from '../../ui/components/MarkdownText.js';
|
|
7
|
+
import { StreamingMarkdownText } from '../../ui/components/StreamingMarkdownText.js';
|
|
7
8
|
import { clampTextTail, wrapLine } from './liveRegion.js';
|
|
8
9
|
import { isSubstantiveAssistantText } from '../commands/streaming/assistantText.js';
|
|
9
10
|
import { theme } from '../../ui/theme.js';
|
|
11
|
+
import { cellWidth } from '../../ui/textGeometry.js';
|
|
10
12
|
import { highlightedCodeLine, languageForPath } from '../../ui/codeHighlight.js';
|
|
11
13
|
function fullWidthLines(text, width, leftPadding = 0) {
|
|
12
14
|
const safeWidth = Math.max(1, width);
|
|
13
15
|
const prefix = ' '.repeat(leftPadding);
|
|
14
|
-
return text.replace(/\r\n|\r/g, '\n').split('\n').map(line => `${prefix}${line}
|
|
16
|
+
return text.replace(/\r\n|\r/g, '\n').split('\n').map(line => `${prefix}${line}${' '.repeat(Math.max(0, safeWidth - cellWidth(line) - leftPadding))}`);
|
|
15
17
|
}
|
|
16
18
|
function fullWidthBlankLine(width) {
|
|
17
19
|
return ''.padEnd(Math.max(1, width));
|
|
@@ -95,10 +97,12 @@ const TOOL_ROW_PATTERN = /^(\s*)([✓✗…])\s+(\S+)(.*)$/;
|
|
|
95
97
|
* settings, see liveRegion.ts) and continuation rows are padded to align
|
|
96
98
|
* under the tool name instead of dropping back to the left edge.
|
|
97
99
|
*/
|
|
98
|
-
function toolGroupLineRows(line, width) {
|
|
100
|
+
function toolGroupLineRows(line, width, spinner = false) {
|
|
99
101
|
const match = TOOL_ROW_PATTERN.exec(line);
|
|
100
102
|
if (!match)
|
|
101
|
-
return
|
|
103
|
+
return spinner && width > 2
|
|
104
|
+
? wrapLine(line, width - 2).map(row => ` ${row}`)
|
|
105
|
+
: wrapLine(line, width);
|
|
102
106
|
const [, indent, icon, toolName, rest] = match;
|
|
103
107
|
const hang = indent.length + 2; // icon + separating space
|
|
104
108
|
const rows = wrapLine(`${toolName}${rest}`, Math.max(1, width - hang));
|
|
@@ -110,14 +114,14 @@ function toolGroupLineRows(line, width) {
|
|
|
110
114
|
* top and whole diff previews from the bottom, with one indicator row each.
|
|
111
115
|
* The finalized group still enters the static transcript verbatim.
|
|
112
116
|
*/
|
|
113
|
-
function clampToolDisplay({ text, width, toolDiffs, maxVisibleLines }) {
|
|
117
|
+
function clampToolDisplay({ text, width, toolDiffs, maxVisibleLines, streaming }) {
|
|
114
118
|
const allLines = text.split('\n');
|
|
115
119
|
const allDiffs = toolDiffs ?? [];
|
|
116
120
|
if (maxVisibleLines == null)
|
|
117
121
|
return { lines: allLines, hiddenTextRowCount: 0, visibleDiffs: allDiffs, hiddenDiffCount: 0 };
|
|
118
122
|
// Row counts must mirror toolGroupLineRows so the budget matches what is
|
|
119
123
|
// actually rendered (icon rows consume one extra hang indent column).
|
|
120
|
-
const rows = allLines.map(line => toolGroupLineRows(line, width).length);
|
|
124
|
+
const rows = allLines.map((line, index) => toolGroupLineRows(line, width, streaming && index === 0).length);
|
|
121
125
|
const total = rows.reduce((sum, count) => sum + count, 0);
|
|
122
126
|
let lines = allLines;
|
|
123
127
|
let hiddenTextRowCount = 0;
|
|
@@ -151,13 +155,16 @@ function clampToolDisplay({ text, width, toolDiffs, maxVisibleLines }) {
|
|
|
151
155
|
return { lines, hiddenTextRowCount, visibleDiffs, hiddenDiffCount: allDiffs.length - visibleDiffs.length };
|
|
152
156
|
}
|
|
153
157
|
function ToolMessageText({ text, streaming, width, toolDiffs, maxVisibleLines }) {
|
|
154
|
-
const clamped = clampToolDisplay({ text, width, toolDiffs, maxVisibleLines });
|
|
158
|
+
const clamped = clampToolDisplay({ text, width, toolDiffs, maxVisibleLines, streaming });
|
|
155
159
|
return _jsxs(Box, { flexDirection: "column", children: [clamped.hiddenTextRowCount > 0 ? _jsx(Text, { color: theme.muted, children: `⋯ +${clamped.hiddenTextRowCount} line${clamped.hiddenTextRowCount === 1 ? '' : 's'} above` }) : null, clamped.lines.flatMap((line, index) => {
|
|
156
160
|
const match = TOOL_ROW_PATTERN.exec(line);
|
|
157
161
|
if (!match) {
|
|
158
162
|
// Summary header / caption rows: plain muted rows (spinner on the
|
|
159
163
|
// first row while streaming).
|
|
160
|
-
|
|
164
|
+
const spinner = !!streaming && index === 0 && clamped.hiddenTextRowCount === 0 && width > 2;
|
|
165
|
+
return toolGroupLineRows(line, width, spinner).map((row, rowIndex) => spinner && rowIndex === 0
|
|
166
|
+
? _jsxs(Box, { width: width, overflow: "hidden", children: [_jsx(ActivitySpinner, { color: theme.muted }), _jsx(Box, { flexShrink: 0, width: 1 }), _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: row.slice(2) })] }, `${index}-${rowIndex}`)
|
|
167
|
+
: _jsx(Text, { color: theme.muted, children: row }, `${index}-${rowIndex}`));
|
|
161
168
|
}
|
|
162
169
|
const [, indent, icon, toolName] = match;
|
|
163
170
|
const iconColor = icon === '✓' ? theme.success : icon === '✗' ? theme.danger : theme.muted;
|
|
@@ -193,19 +200,23 @@ export const AssistantMarkdownChunkView = React.memo(function AssistantMarkdownC
|
|
|
193
200
|
/** Streaming assistant tail clamped to the live-region budget; the full text enters the static transcript once the root settles. */
|
|
194
201
|
function StreamingClampedText({ text, width, maxVisibleLines }) {
|
|
195
202
|
const clamped = clampTextTail(text, width, maxVisibleLines);
|
|
196
|
-
return _jsxs(Box, { flexDirection: "column", children: [clamped.hiddenLineCount > 0 ? _jsx(Text, { color: theme.muted, children: `⋯ +${clamped.hiddenLineCount} line${clamped.hiddenLineCount === 1 ? '' : 's'} above` }) : null, _jsx(Text, { children: clamped.text })] });
|
|
203
|
+
return _jsxs(Box, { flexDirection: "column", children: [clamped.hiddenLineCount > 0 ? _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: `⋯ +${clamped.hiddenLineCount} line${clamped.hiddenLineCount === 1 ? '' : 's'} above` }) : null, clamped.text || clamped.hiddenLineCount === 0 ? _jsx(Text, { children: clamped.text }) : null] });
|
|
197
204
|
}
|
|
198
205
|
export const MessageView = React.memo(function MessageView({ message, width, showHeader = true, maxVisibleLines }) {
|
|
206
|
+
if (maxVisibleLines != null && message.role !== 'tool') {
|
|
207
|
+
return _jsxs(Box, { flexDirection: "column", flexShrink: 0, maxHeight: maxVisibleLines + (showHeader ? 1 : 0), overflow: "hidden", children: [showHeader && _jsx(Text, { color: theme.muted, wrap: "truncate-end", children: message.role === 'assistant' ? 'haze' : message.role === 'user' ? 'You asked' : 'Info' }), message.role === 'assistant'
|
|
208
|
+
? _jsx(StreamingMarkdownText, { content: message.text, width: width, maxVisibleLines: maxVisibleLines })
|
|
209
|
+
: _jsx(StreamingClampedText, { text: message.text, width: width, maxVisibleLines: maxVisibleLines })] });
|
|
210
|
+
}
|
|
199
211
|
if (message.role === 'user') {
|
|
200
212
|
return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { backgroundColor: theme.surfaceBg, children: fullWidthBlankLine(width) }), _jsx(Text, { color: theme.success, bold: true, backgroundColor: theme.surfaceBg, children: ' You asked'.padEnd(width) }), fullWidthLines(message.text, width, 2).map((line, lineIndex) => _jsx(Text, { color: theme.foreground, backgroundColor: theme.surfaceBg, children: line }, lineIndex)), _jsx(Text, { backgroundColor: theme.surfaceBg, children: fullWidthBlankLine(width) })] });
|
|
201
213
|
}
|
|
202
214
|
return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [showHeader ? _jsxs(Text, { children: [_jsx(Text, { color: message.role === 'assistant' ? theme.accent : message.role === 'tool' ? theme.info : message.role === 'system' ? theme.success : theme.muted, bold: true, children: message.role === 'assistant' ? 'haze' : message.role === 'tool' ? 'Tool' : 'Info' }), messageElapsedLabel(message) ? _jsxs(Text, { color: theme.muted, bold: false, children: [" \u00B7 ", messageElapsedLabel(message)] }) : null] }) : null, message.role === 'tool'
|
|
203
|
-
? _jsx(ToolMessageText, { text: message.text, streaming: message.streaming, width: width, toolDiffs: message.toolDiffs, maxVisibleLines:
|
|
204
|
-
: message.role === 'assistant'
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
? _jsx(MarkdownText, { content: message.text, width: width })
|
|
215
|
+
? _jsx(ToolMessageText, { text: message.text, streaming: message.streaming, width: width, toolDiffs: message.toolDiffs, maxVisibleLines: maxVisibleLines })
|
|
216
|
+
: message.role === 'assistant'
|
|
217
|
+
? message.streaming
|
|
218
|
+
? _jsx(StreamingMarkdownText, { content: message.text, width: width })
|
|
219
|
+
: _jsx(MarkdownText, { content: message.text, width: width })
|
|
209
220
|
: message.role === 'system'
|
|
210
221
|
? _jsx(SystemMessageText, { text: message.text })
|
|
211
222
|
: message.streaming && maxVisibleLines != null
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ModelMessage } from 'ai';
|
|
2
2
|
import type { ContextFile } from '../../config/contextFiles.js';
|
|
3
3
|
import type { WorkState } from '../../core/agent/workState.js';
|
|
4
|
-
import { type GoalLedgerFrontier, type HazeSession } from '../../core/session/sessionStore.js';
|
|
4
|
+
import { type GoalLedgerFrontier, type HazeSession, type SessionModelSelection } from '../../core/session/sessionStore.js';
|
|
5
5
|
import { type LlmLog } from '../../core/log/llmLog.js';
|
|
6
6
|
import type { Message } from '../commands/streaming.js';
|
|
7
7
|
import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
|
|
@@ -24,6 +24,8 @@ export interface SessionLifecycleDeps {
|
|
|
24
24
|
noSession: boolean;
|
|
25
25
|
debug: boolean;
|
|
26
26
|
contextFiles: () => ContextFile[];
|
|
27
|
+
modelSelection?: () => SessionModelSelection | undefined;
|
|
28
|
+
onModelSelection?: (selection: SessionModelSelection | undefined) => void;
|
|
27
29
|
sessionRef: {
|
|
28
30
|
current: HazeSession | undefined;
|
|
29
31
|
};
|
|
@@ -29,12 +29,16 @@ export function createSessionLifecycle(deps) {
|
|
|
29
29
|
deps.contextFileSignaturesRef.current = new Map(deps.contextFiles().flatMap(file => file.signature ? [[file.path, file.signature]] : []));
|
|
30
30
|
deps.workStateRef.current = undefined;
|
|
31
31
|
deps.sessionStartRef.current = new Date();
|
|
32
|
+
deps.onModelSelection?.(undefined);
|
|
32
33
|
if (deps.noSession) {
|
|
33
34
|
deps.sessionRef.current = undefined;
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
const session = await createSession({ hazeVersion: deps.version, ...(deps.build ? { build: deps.build } : {}) });
|
|
37
38
|
deps.sessionRef.current = session;
|
|
39
|
+
const selection = deps.modelSelection?.();
|
|
40
|
+
if (selection)
|
|
41
|
+
deps.sessionRecorder()?.recordModelSelection(selection);
|
|
38
42
|
deps.setTokenUsage({ ...EMPTY_TOKEN_USAGE });
|
|
39
43
|
await startNewLog();
|
|
40
44
|
const status = `${message}\nSession: ${session.file}`;
|
|
@@ -47,8 +51,14 @@ export function createSessionLifecycle(deps) {
|
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
53
|
async function resumeSession(session, replaceTranscript) {
|
|
50
|
-
const { messages: conversation, workState, parseErrors, goalFrontier } = await restoreSessionState(session);
|
|
54
|
+
const { messages: conversation, workState, parseErrors, goalFrontier, modelSelection } = await restoreSessionState(session);
|
|
51
55
|
deps.sessionRef.current = session;
|
|
56
|
+
deps.onModelSelection?.(modelSelection);
|
|
57
|
+
if (!modelSelection) {
|
|
58
|
+
const selection = deps.modelSelection?.();
|
|
59
|
+
if (selection)
|
|
60
|
+
deps.sessionRecorder()?.recordModelSelection(selection);
|
|
61
|
+
}
|
|
52
62
|
deps.conversationRef.current = conversation;
|
|
53
63
|
deps.clearLiveMessages();
|
|
54
64
|
const restoredMessages = displayMessagesFromConversation(conversation);
|
|
@@ -194,7 +204,8 @@ export function createSessionLifecycle(deps) {
|
|
|
194
204
|
// overwritten — the stale compaction is reported and discarded instead.
|
|
195
205
|
const sessionAtStart = deps.sessionRef.current;
|
|
196
206
|
try {
|
|
197
|
-
const
|
|
207
|
+
const selection = deps.modelSelection?.();
|
|
208
|
+
const runtime = await modelWithConfig(selection ? { modelSelector: `${selection.provider}:${selection.model}` } : undefined);
|
|
198
209
|
if (!runtime?.model)
|
|
199
210
|
throw new Error('no model provider configured');
|
|
200
211
|
const summarization = await generateText({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ModelMessage } from 'ai';
|
|
2
|
-
import { type HazeSession } from '../../core/session/sessionStore.js';
|
|
2
|
+
import { type HazeSession, type SessionModelSelection } from '../../core/session/sessionStore.js';
|
|
3
3
|
import type { GoalLedgerAppend } from '../commands/streaming/goalCheckpoint.js';
|
|
4
4
|
import type { AgentEvent } from '../../core/agent/events.js';
|
|
5
5
|
import type { WorkState } from '../../core/agent/workState.js';
|
|
6
6
|
import type { Message } from '../commands/streaming.js';
|
|
7
7
|
export declare function createSessionRecorder(getSession: () => HazeSession | undefined): {
|
|
8
|
+
recordModelSelection(selection: SessionModelSelection): void;
|
|
8
9
|
recordUiMessage(message: Message): void;
|
|
9
10
|
recordConversation(messages: ModelMessage[]): void;
|
|
10
11
|
recordWorkState(state: WorkState): void;
|
|
@@ -60,7 +60,15 @@ export function createSessionRecorder(getSession) {
|
|
|
60
60
|
pendingWorkState = undefined;
|
|
61
61
|
writeWorkState(snapshot);
|
|
62
62
|
};
|
|
63
|
+
let lastModelSelection;
|
|
63
64
|
return {
|
|
65
|
+
recordModelSelection(selection) {
|
|
66
|
+
const session = getSession();
|
|
67
|
+
if (!session || (lastModelSelection?.session === session && lastModelSelection.provider === selection.provider && lastModelSelection.model === selection.model))
|
|
68
|
+
return;
|
|
69
|
+
lastModelSelection = { session, ...selection };
|
|
70
|
+
appendEntry({ type: 'model_selection', at: new Date().toISOString(), selection });
|
|
71
|
+
},
|
|
64
72
|
recordUiMessage(message) {
|
|
65
73
|
appendEntry({ type: 'ui_message', at: new Date().toISOString(), role: message.role, text: message.text });
|
|
66
74
|
},
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ShutdownOwners {
|
|
2
|
+
stop: () => void;
|
|
3
|
+
abort: () => void;
|
|
4
|
+
settle: () => Promise<unknown> | undefined;
|
|
5
|
+
seal: () => void;
|
|
6
|
+
flush: () => Promise<unknown> | undefined;
|
|
7
|
+
endLog: () => Promise<unknown> | undefined;
|
|
8
|
+
cleanup: () => Promise<unknown>;
|
|
9
|
+
exit: () => void;
|
|
10
|
+
report: (message: string) => void;
|
|
11
|
+
}
|
|
12
|
+
/** One owner for slash exit and interrupt; late rejection is consumed by the race. */
|
|
13
|
+
export declare function createChatShutdown(owners: ShutdownOwners, settlementMs?: number, cleanupMs?: number): () => Promise<void>;
|
|
14
|
+
export interface TerminalApp {
|
|
15
|
+
waitUntilExit: () => Promise<unknown>;
|
|
16
|
+
unmount: () => void;
|
|
17
|
+
cleanup: () => void;
|
|
18
|
+
/** Ink 8: settles once pending render output is flushed to stdout. */
|
|
19
|
+
waitUntilRenderFlush?: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/** Adoption and synchronous render failures share the same restoration boundary. */
|
|
22
|
+
export declare function runTerminalSession(owners: {
|
|
23
|
+
adopt: () => void;
|
|
24
|
+
create: () => TerminalApp;
|
|
25
|
+
shutdown: () => Promise<void> | undefined;
|
|
26
|
+
restore: () => void;
|
|
27
|
+
}): Promise<void>;
|