@denizokcu/haze 1.1.0 → 1.2.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 +49 -1
- package/README.md +17 -10
- package/SECURITY.md +1 -1
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/busyIndicator.d.ts +11 -0
- package/dist/cli/chat/busyIndicator.js +34 -0
- package/dist/cli/chat/chatMetrics.d.ts +0 -1
- package/dist/cli/chat/chatMetrics.js +1 -7
- package/dist/cli/chat/followUpQueue.d.ts +11 -0
- package/dist/cli/chat/followUpQueue.js +38 -0
- package/dist/cli/chat/messages.d.ts +0 -22
- package/dist/cli/chat/messages.js +40 -85
- package/dist/cli/chat/sessionLifecycle.d.ts +3 -1
- package/dist/cli/chat/sessionLifecycle.js +8 -1
- package/dist/cli/chat/sessionRecorder.d.ts +9 -0
- package/dist/cli/chat/sessionRecorder.js +12 -0
- package/dist/cli/chat/startupSequence.d.ts +29 -0
- package/dist/cli/chat/startupSequence.js +59 -0
- package/dist/cli/chat/transcriptPartition.d.ts +23 -0
- package/dist/cli/chat/transcriptPartition.js +78 -0
- package/dist/cli/chat/wizard/fieldTransitions.d.ts +38 -0
- package/dist/cli/chat/wizard/fieldTransitions.js +43 -0
- package/dist/cli/chat/wizard/lspHandlers.d.ts +4 -0
- package/dist/cli/chat/wizard/lspHandlers.js +85 -0
- package/dist/cli/chat/wizard/mcpHandlers.d.ts +8 -0
- package/dist/cli/chat/wizard/mcpHandlers.js +82 -0
- package/dist/cli/chat/wizard/providerHandlers.d.ts +12 -0
- package/dist/cli/chat/wizard/providerHandlers.js +420 -0
- package/dist/cli/chat/wizard/sessionThemeHandlers.d.ts +4 -0
- package/dist/cli/chat/wizard/sessionThemeHandlers.js +48 -0
- package/dist/cli/chat/wizard/skillsHandlers.d.ts +4 -0
- package/dist/cli/chat/wizard/skillsHandlers.js +125 -0
- package/dist/cli/chat/wizard/types.d.ts +63 -0
- package/dist/cli/chat/wizard/types.js +24 -0
- package/dist/cli/chat/wizard/uiState.d.ts +56 -0
- package/dist/cli/chat/wizard/uiState.js +15 -0
- package/dist/cli/chat/wizardDispatch.d.ts +11 -113
- package/dist/cli/chat/wizardDispatch.js +41 -815
- package/dist/cli/commands/chat.js +69 -110
- package/dist/cli/commands/formatters.d.ts +0 -3
- package/dist/cli/commands/formatters.js +0 -29
- package/dist/cli/commands/runCommand.d.ts +2 -0
- package/dist/cli/commands/runCommand.js +73 -4
- package/dist/cli/commands/streaming/agentAttempt.d.ts +11 -1
- package/dist/cli/commands/streaming/agentAttempt.js +9 -5
- package/dist/cli/commands/streaming/assistantSegments.d.ts +19 -0
- package/dist/cli/commands/streaming/assistantSegments.js +48 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +25 -5
- package/dist/cli/commands/streaming/attemptOutcome.js +69 -16
- package/dist/cli/commands/streaming/attemptSetup.d.ts +10 -3
- package/dist/cli/commands/streaming/attemptSetup.js +30 -13
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +69 -8
- package/dist/cli/commands/streaming/goalCheckpoint.js +36 -1
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +18 -3
- package/dist/cli/commands/streaming/goalSupervisor.js +71 -12
- package/dist/cli/commands/streaming/prepareStep.d.ts +40 -0
- package/dist/cli/commands/streaming/prepareStep.js +116 -0
- package/dist/cli/commands/streaming/recoverySlices.d.ts +15 -0
- package/dist/cli/commands/streaming/recoverySlices.js +29 -0
- package/dist/cli/commands/streaming/stallRecovery.d.ts +0 -1
- package/dist/cli/commands/streaming/stallRecovery.js +2 -6
- package/dist/cli/commands/streaming/streamLoop.d.ts +31 -4
- package/dist/cli/commands/streaming/streamLoop.js +283 -268
- package/dist/cli/commands/streaming/toolGroupRenderer.js +2 -1
- package/dist/cli/commands/streaming/toolPartHandlers.d.ts +19 -0
- package/dist/cli/commands/streaming/toolPartHandlers.js +108 -0
- package/dist/cli/commands/streaming/turnRuntime.d.ts +1 -1
- package/dist/cli/commands/streaming/turnRuntime.js +3 -2
- package/dist/cli/commands/streaming.d.ts +12 -1
- package/dist/cli/commands/streaming.js +20 -25
- package/dist/cli/index.js +6 -3
- package/dist/config/modelCatalog.d.ts +32 -0
- package/dist/config/modelCatalog.js +84 -0
- package/dist/config/providerPresets.d.ts +7 -0
- package/dist/config/providerPresets.js +195 -391
- package/dist/config/settings.d.ts +10 -2
- package/dist/config/settings.js +3 -0
- package/dist/core/agent/budgets.d.ts +10 -0
- package/dist/core/agent/budgets.js +10 -0
- package/dist/core/agent/compaction.d.ts +42 -3
- package/dist/core/agent/compaction.js +53 -5
- package/dist/core/agent/completionController.d.ts +16 -7
- package/dist/core/agent/completionController.js +13 -6
- package/dist/core/agent/contextBudget.d.ts +56 -0
- package/dist/core/agent/contextBudget.js +53 -0
- package/dist/core/agent/errors.js +2 -2
- package/dist/core/agent/events.d.ts +36 -1
- package/dist/core/agent/goalPolicy.d.ts +4 -3
- package/dist/core/agent/goalPolicy.js +9 -4
- package/dist/core/agent/overflow.d.ts +45 -0
- package/dist/core/agent/overflow.js +91 -0
- package/dist/core/agent/requestAssembly.d.ts +7 -0
- package/dist/core/agent/requestAssembly.js +15 -7
- package/dist/core/agent/workState.d.ts +25 -15
- package/dist/core/agent/workState.js +84 -44
- package/dist/core/safety/shellClassifier.d.ts +16 -0
- package/dist/core/safety/shellClassifier.js +31 -0
- package/dist/core/session/sessionSlimming.js +8 -0
- package/dist/core/session/sessionStore.d.ts +71 -1
- package/dist/core/session/sessionStore.js +121 -6
- package/dist/core/validation/outputParser.d.ts +1 -1
- package/dist/core/validation/outputParser.js +6 -1
- package/dist/llm/client.d.ts +2 -2
- package/dist/llm/client.js +14 -6
- package/dist/llm/hazeTools.d.ts +64 -208
- package/dist/llm/tools/shellTool.js +27 -8
- package/dist/llm/tools/taskTool.d.ts +64 -208
- package/dist/llm/tools/taskTool.js +22 -10
- package/dist/ui/components/TextInput.d.ts +18 -1
- package/dist/ui/components/TextInput.js +50 -73
- package/dist/ui/components/useInputSuggestions.d.ts +27 -0
- package/dist/ui/components/useInputSuggestions.js +98 -0
- package/dist/ui/theme.d.ts +8 -8
- package/dist/ui/theme.js +11 -12
- package/dist/ui/themes/registry.d.ts +5 -0
- package/dist/ui/themes/registry.js +436 -0
- package/dist/utils/format.d.ts +10 -0
- package/dist/utils/format.js +45 -0
- package/package.json +16 -15
- package/dist/ui/themes/af-magic.d.ts +0 -7
- package/dist/ui/themes/af-magic.js +0 -25
- package/dist/ui/themes/agnoster.d.ts +0 -10
- package/dist/ui/themes/agnoster.js +0 -40
- package/dist/ui/themes/bira.d.ts +0 -10
- package/dist/ui/themes/bira.js +0 -28
- package/dist/ui/themes/bureau.d.ts +0 -10
- package/dist/ui/themes/bureau.js +0 -28
- package/dist/ui/themes/clean.d.ts +0 -9
- package/dist/ui/themes/clean.js +0 -27
- package/dist/ui/themes/cloud.d.ts +0 -6
- package/dist/ui/themes/cloud.js +0 -24
- package/dist/ui/themes/dst.d.ts +0 -10
- package/dist/ui/themes/dst.js +0 -28
- package/dist/ui/themes/fishy.d.ts +0 -7
- package/dist/ui/themes/fishy.js +0 -25
- package/dist/ui/themes/index.d.ts +0 -8
- package/dist/ui/themes/index.js +0 -36
- package/dist/ui/themes/light.d.ts +0 -3
- package/dist/ui/themes/light.js +0 -21
- package/dist/ui/themes/purple.d.ts +0 -7
- package/dist/ui/themes/purple.js +0 -26
- package/dist/ui/themes/robbyrussell.d.ts +0 -8
- package/dist/ui/themes/robbyrussell.js +0 -26
- package/dist/ui/themes/solarized-dark.d.ts +0 -16
- package/dist/ui/themes/solarized-dark.js +0 -44
- package/dist/ui/themes/solarized-light.d.ts +0 -12
- package/dist/ui/themes/solarized-light.js +0 -40
- package/dist/ui/themes/steeef.d.ts +0 -11
- package/dist/ui/themes/steeef.js +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,60 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 1.2.0 - 2026-08-31
|
|
6
|
+
|
|
7
|
+
Context truthfulness and never-stop-for-recoverable-reasons. A model-backed eval harness drove the changes: the completion gate's trust in real process results had four independent ways to be fed false positives, and the recovery paths still hard-failed on recoverable context conditions.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Model-backed eval harness: `npm run eval` runs the real turn stack (goal supervisor, tools, budgets, compaction) against the configured provider in throwaway workspaces and asserts on the structured goal envelope plus deterministic ground truth (fixture test commands, file hashes) — never on response text. Five canonical scenarios including an honesty invariant (an unsatisfiable, tamper-protected task can never be reported `complete`). Evals skip under plain `npm test`, serialize process-wide, and write transcripts under gitignored `.eval/`.
|
|
12
|
+
- Curated model catalog: known model families carry real context-window and output-cap metadata keyed by model-name pattern (gateway-style `vendor/model` ids match on the final segment), slotted between per-model `modelLimits` and the user fallback. Values are input-safe (the smaller window wins when variants differ); local inference servers never consult the catalog because their effective window is server-configured.
|
|
13
|
+
- Compaction observability: `compaction_start` / `compaction_end` stream events (reason, method, counts, `willRetry`) and durable `compact` session entries (method, older/kept counts, summary) make every compaction — manual, threshold, or overflow-recovery — observable and auditable.
|
|
14
|
+
- `retryBaseDelayMs` setting (integer 250–60000, default 1000): base delay for the shared model-retry pool's exponential backoff, capped at 4× the base.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Context estimation prefers the provider's own accounting: each completed step re-anchors the estimate on reported usage (convention-robust across OpenAI-style and Anthropic-style cache reporting, so cache-heavy finishes are never double-counted), with chars/4 estimates only for trailing messages. Silent overflows (usage over the window on a successful finish) and length-stop overflows (truncated input filling the window) are detected from usage and route through the same compact-and-retry recovery as thrown overflow errors, alongside a 25-family provider error-pattern table with rate-limit exclusions.
|
|
19
|
+
- Context-overflow recovery no longer hard-fails: retries shrink the message budget progressively (60%, then 36%); once the bounded retries are exhausted the goal checkpoints (`context_exhausted`) and the supervisor pauses with a one-key resume instead of relaunching the same oversized request.
|
|
20
|
+
- Mid-turn compaction runs at epoch boundaries and prefers an LLM-written summary for large older halves — chained from any previous compaction summary and split-turn aware (a recent window landing mid-turn preserves the unfinished task's request, progress, and next action) — with the deterministic heuristic excerpt for small trims and as the fallback on any summarization failure.
|
|
21
|
+
- The shared model-retry pool resets whenever a failed attempt completed steps since the previous retry, so a long turn with intermittent provider blips never exhausts it; consecutive failures still chain backoff.
|
|
22
|
+
- Settings are re-read per attempt, so a provider or model switch made mid-goal applies from the next attempt.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Validation exit codes are truthful evidence (found by adversarial model-backed evals): validation-classified commands run under `pipefail` so a pipeline like `npm test | tail` can no longer report the final stage's success while the suite failed; a passing validation whose unquoted command can mask a failing stage (`;`, `||`, or single `&` list operators — redirections like `2>&1` are not) is demoted to unconfirmed; validation-kind inference matches only the unquoted command shape, so a quoted payload mentioning "test" cannot claim tool authority; and a passing self-declared custom check can no longer clear a failed classifier-confirmed validation, including one carried from a goal checkpoint.
|
|
27
|
+
|
|
28
|
+
## 1.1.1 - 2026-08-26
|
|
29
|
+
|
|
30
|
+
Durable goal resume and a smaller autonomy core. This patch keeps the concrete headless/recovery gains developed after 1.1.0 while removing unproven completion ceremony before publication.
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- Durable goal ledger and crash-resume frontier: every logical-goal boundary can append bounded state to the session JSONL, including the exact request and its hash, cycle, mutation/validation outcome, task counts, and unresolved pre-edit failure evidence. Session restore finds the newest unfinished frontier without making goal-only files resumable, tolerates a truncated final line, and keeps the frontier through bounded ledger vacuuming.
|
|
35
|
+
- Headless `--until-done`: print mode can relaunch the preserved logical goal after transient provider failures with exponential backoff, `goal_resume` stream events, the existing absolute goal timeout, and a three-strike no-progress poison guard. Relaunches reuse the conversation and frontier without duplicating the original request or granting additional authority.
|
|
36
|
+
- Headless goal observability: `goal_notice` events and a bounded `notices` array expose continuation/pause decisions to stream and single-envelope consumers; `goal_continue` carries readable text.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- Completion remains structural but proportional: pending model-declared tasks and missing/stale/failed post-mutation validation reject a final. Red→green evidence is opportunistic — fixes do not need a pre-edit failing repro, but a recognized validation that fails before the first mutation must be rerun successfully after the edit. The completing check is sequence-bound so a pre-edit pass cannot satisfy the rule.
|
|
41
|
+
- `writeTasks` is task-only again. The experimental ask gate/refinement/amendment flow, independent verifier, goal shapes, multi-lane hints, final sweep, mandatory repro/depth prompt, waiver, and successor-command protocol were evaluated and removed before release. A three-attempt Harbor `csv-query` A/B found no success gain from the added ceremony and materially higher token/time cost; the final trimmed arms remained correct, but efficiency varied enough that this release makes no benchmark-speed claim.
|
|
42
|
+
- Large orchestration modules were split into focused helpers: chat startup/transcript/follow-up handling, wizard fields and per-domain handlers, input suggestions, and streaming preparation/tool dispatch/assistant segments/recovery slices. Public CLI behavior is unchanged.
|
|
43
|
+
- Theme definitions are consolidated into one typed registry, and provider presets use compact model tuples while preserving the resolved palette and preset data.
|
|
44
|
+
- All built-in tool rows align wrapped output beneath the tool name, and shared formatting helpers replace duplicate elapsed-time/path logic.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- Overlong `writeTasks` titles are truncated in `execute` instead of causing a whole-call `AI_TypeValidationError` retry loop.
|
|
49
|
+
- Unresolved same-check red evidence survives physical-turn and crash-resume boundaries, while a satisfied pair is dropped from carried state so later turns do not inherit obsolete completion debt.
|
|
50
|
+
|
|
3
51
|
## 1.1.0 - 2026-08-19
|
|
4
52
|
|
|
5
53
|
Theming and secrets. Two user-facing layers landed in this release: a full terminal theme system (14 built-in palettes, live switching, terminal-default adoption) and hard secret-file protection across every file tool.
|
|
6
54
|
|
|
7
55
|
### Added
|
|
8
56
|
|
|
9
|
-
- Terminal theming: `src/ui/theme.ts` is the shared palette singleton (semantic roles — accent, command, muted, success/danger pairs, surface backgrounds — resolved through the oh-my-zsh/zsh color vocabulary of zsh names, xterm-256 indices, or `#rrggbb` hex), and `src/ui/themes/` is a one-file-per-theme registry keyed by settings name, seeded with the default `purple` and `light` palettes plus oh-my-zsh ports (`robbyrussell`, `af-magic`, `agnoster`, `bira`, `bureau`, `clean`, `cloud`, `dst`, `fishy`, `solarized-dark`, `solarized-light`, `steeef`). Themes own both terminal defaults: haze adopts the theme's foreground and background via OSC 10/11 at startup and restores them (OSC 110/111) on exit, so light palettes never paint a light canvas under dark-default text. A `theme` key in `~/.haze/settings.json` selects the palette (validated loudly at startup with the valid names listed), and the new `/themes` command switches it: the picker labels each theme light/dark and marks the active one, `/themes <name>` sets one directly, and switching applies live without a restart — already-printed transcript text keeps its old colors (Ink `<Static>` stays as-rendered), which is accepted behavior.
|
|
57
|
+
- Terminal theming: `src/ui/theme.ts` is the shared palette singleton (semantic roles — accent, command, muted, success/danger pairs, surface backgrounds — resolved through the oh-my-zsh/zsh color vocabulary of zsh names, xterm-256 indices, or `#rrggbb` hex), and `src/ui/themes/` is a one-file-per-theme registry keyed by settings name, seeded with the default `purple` and `light` palettes plus oh-my-zsh ports (`robbyrussell`, `af-magic`, `agnoster`, `bira`, `bureau`, `clean`, `cloud`, `dst`, `fishy`, `solarized-dark`, `solarized-light`, `steeef`). Themes own both terminal defaults: haze adopts the theme's foreground and background via OSC 10/11 at startup and restores them (OSC 110/111) on exit, so light palettes never paint a light canvas under dark-default text. A `theme` key in `~/.haze/settings.json` selects the palette (validated loudly at startup with the valid names listed), and the new `/themes` command switches it: the picker labels each theme light/dark and marks the active one, `/themes <name>` sets one directly, and switching applies live without a restart — already-printed transcript text keeps its old colors (Ink `<Static>` stays as-rendered), which is accepted behavior. The conversion guides for porting oh-my-zsh, VS Code, and Sublime themes live in `src/ui/themes/AGENTS.md`.
|
|
10
58
|
|
|
11
59
|
- Hard secret-file protection in every file tool: SSH keys (`~/.ssh/**`, `id_*` private keys), shell history files, `.env`/`.envrc` files (excluding `.example`/`.sample`/`.template` documentation variants), `*.pem`/`*.key`, `secrets.{json,yaml,yml,toml}`, and common home credential stores (`~/.aws`, `~/.gnupg`, `~/.netrc`, `~/.git-credentials`, and others; see `src/core/safety/secretPaths.ts`) are refused for reads *and* mutations before any filesystem access. The check covers lexical and real paths (symlink-proof in both directions), wins over user-typed `@path` read blessings and `allowIgnored`, and grep traversal excludes the protected names with negated-only globs appended after any model-supplied glob (a later ripgrep glob takes precedence, so an explicit glob cannot re-include secrets; positive re-include globs would whitelist the search, which is why documentation variants are excluded from traversal but stay readable via targeted `readFile`). Refusals are terminal structured results (`secret_file_protected`, `recoverable: false`, ask-the-user next step, no content echoed) so models do not burn steps retrying, and the transcript shows them as `blocked: protected secret file (path)`, distinct from ordinary failures. The `shell` tool is deliberately not command-filtered: secret avoidance in shell is instructed through the system prompt (`SECRET_FILE_RULE`), aligned with the file-tool refusal wording.
|
|
12
60
|
|
package/README.md
CHANGED
|
@@ -2,15 +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.2.0
|
|
6
6
|
|
|
7
|
-
haze 1.
|
|
7
|
+
haze 1.2.0 makes long-running work more truthful under context pressure and provider instability.
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
9
|
+
- Provider-aware context accounting: completed steps re-anchor estimates on provider usage, a curated model catalog supplies known context/output limits, and live or user-configured model metadata still takes precedence.
|
|
10
|
+
- Recoverable overflow handling: thrown, silent, and length-stop context overflows compact and retry with progressively smaller budgets. Exhausted recovery checkpoints the goal as `context_exhausted` instead of hard-failing or looping on the same request.
|
|
11
|
+
- Better continuity: large mid-turn compactions use model-written, split-turn-aware summaries; every compaction emits stream events and a durable session entry for auditability.
|
|
12
|
+
- Truthful validation: validation pipelines run with `pipefail`; masking command lists and quoted lookalikes cannot claim validation authority; and a generic custom pass cannot erase a real classified failure.
|
|
13
|
+
- Resilient retries: `retryBaseDelayMs` configures exponential backoff, the retry pool resets after measurable step progress, and provider/model settings are re-read for each attempt.
|
|
11
14
|
|
|
12
15
|
Previous releases:
|
|
13
16
|
|
|
17
|
+
- `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.
|
|
18
|
+
- `1.1.0`: terminal theming with 14 built-in palettes and live `/themes` switching; hard secret-file protection across every file tool, including symlink, read-blessing, ignore-override, and grep-traversal defenses.
|
|
14
19
|
- `1.0.0`: first stable release — the CLI flags, settings schema, `stream-json` event contract, session format, skill layout, and structured tool-result shape under the 1.x compatibility promise; a configurable model-retry pool; and four benchmark-driven reliability fixes (validated with the Harbor differential benchmark: 17/17 verifier tests, fewest input tokens of the reporting harnesses, zero stalls).
|
|
15
20
|
- `0.11.0`: goal-level autonomy across physical-turn budgets (logical-goal supervisor, evidence-gated completion, `goal_*` stream events, cumulative goal envelope), runtime provenance and `haze doctor` (embedded build info, stale-build refusal, session build headers), model-aware context budgeting (per-preset limits, live discovery, 128K fallback, self-healing context overflow), headless `--timeout` with per-tool deadlines and abort-cause typing, performance work (batched ignore checks, LSP reuse, coalesced/vacuumed sessions, memoized estimates, incremental streaming, viewport-clamped live region), and model-written `/compact` summaries with a heuristic fallback.
|
|
16
21
|
- `0.10.1`: OpenAI Subscription OAuth preset, SECURITY.md and the attended-use threat model, bounded completion recovery, compact colorized diffs, prompt-injection framing, hardened fetch/stdin/sessions, and a multi-page docs site.
|
|
@@ -243,12 +248,13 @@ haze -p "summarize this repo" --model openai:gpt-4o-mini
|
|
|
243
248
|
haze --resume <id> -p "continue the investigation"
|
|
244
249
|
haze -p "list the top 3 bugs in src/api.ts" --output json
|
|
245
250
|
haze -p "audit src/auth.ts" --output stream-json # live NDJSON events, then the result envelope
|
|
251
|
+
haze -p "migrate the config loader" --until-done --timeout 2h # relaunch through transient provider failures
|
|
246
252
|
echo "what does this project do?" | haze
|
|
247
253
|
```
|
|
248
254
|
|
|
249
255
|
`-p` and `--prompt` run one agentic turn with the full tool set and print the final assistant text. `--model` accepts a bare model name or `provider:name` and overrides the active model for that run without changing `~/.haze/settings.json`. The model must already be registered under a provider's `models`; add it once with `/provider`. Unknown or ambiguous selectors print a specific error to stderr and exit nonzero.
|
|
250
256
|
|
|
251
|
-
If you pipe stdin without `-p`, haze reads the prompt from stdin. Piped prompts are limited to 256 KiB; for larger input, pass a file path and ask haze to read it. One-shot runs do not create or update durable sessions, and they ignore `--continue`; `--resume <id>` can load an exact saved context for the turn without changing the original session. On a provider context overflow they compact the loaded conversation
|
|
257
|
+
If you pipe stdin without `-p`, haze reads the prompt from stdin. Piped prompts are limited to 256 KiB; for larger input, pass a file path and ask haze to read it. One-shot runs do not create or update durable sessions, and they ignore `--continue`; `--resume <id>` can load an exact saved context for the turn without changing the original session. On a provider context overflow they compact the loaded conversation and retry at a progressively smaller message budget (up to twice), like the interactive path; if the window stays full the run ends failed with a resumable `context_exhausted` checkpoint, and when compaction is unavailable the error says so explicitly. Add `--debug` to write a detailed JSONL log under `~/.haze/logs/`.
|
|
252
258
|
|
|
253
259
|
`--output` controls the result format: `text` is the default, `json` prints one final envelope, and `stream-json` writes live NDJSON events followed by the same envelope.
|
|
254
260
|
|
|
@@ -269,7 +275,7 @@ If you pipe stdin without `-p`, haze reads the prompt from stdin. Piped prompts
|
|
|
269
275
|
}
|
|
270
276
|
```
|
|
271
277
|
|
|
272
|
-
The `status` field is authoritative (driven by the agent's terminal state, not by parsing `result`), and the exit code mirrors it: `0` only for `complete`. A run that ends without a substantive final answer, after an unresolved final tool failure, with declared tasks or required validation still unfinished
|
|
278
|
+
The `status` field is authoritative (driven by the agent's terminal state, not by parsing `result`), and the exit code mirrors it: `0` only for `complete`. A run that ends without a substantive final answer, after an unresolved final tool failure, or with declared tasks or required validation still unfinished is `failed` even if the provider returned normally; the evidence envelope carries the task counts and validation outcome that gated it. For fixes, red→green evidence is opportunistic: haze does not require a pre-edit failing repro, but if a recognized validation fails before the first mutation, that same command must pass after the fix. Long tool loops use one bounded Vercel AI SDK step at a time, releasing request-local SDK state while appending the exact provider message prefix for prompt-cache reuse. Per-turn step/tool budgets are safety boundaries, not completion: haze automatically continues the logical goal in fresh turns while measurable progress remains, so a budget boundary alone never fails a run. `--timeout` bounds the entire logical goal (not each internal turn), and `--until-done` additionally relaunches the goal after transient provider failures (exponential backoff, `goal_resume` events, a three-strike no-progress guard) until it structurally completes or the deadline hits — without granting any extra authority. The result envelope additionally carries a `goal` object (physical turns used, stop reason, total mutations, final validation outcome and task counts) when goal-level continuation was involved, and a bounded `notices` array with the gate decisions the run made (such as pause reasons) so scripts can see why a goal continued or stopped — the same decisions stream live as `goal_notice` events in `--output stream-json`.
|
|
273
279
|
|
|
274
280
|
`--output stream-json` writes progress as the run happens. Each public event is one newline-delimited JSON object on stdout. The last line uses the same `{ type: "result", status, result, usage }` envelope as `--output json`, so consumers can display progress and parse the final result in the same way:
|
|
275
281
|
|
|
@@ -284,7 +290,7 @@ The `status` field is authoritative (driven by the agent's terminal state, not b
|
|
|
284
290
|
{"type":"result","status":"complete","result":"Here are the findings…","usage":{"inputTokens":0,"outputTokens":0,"cacheReadTokens":0,"cacheWriteTokens":0,"reasoningTokens":0}}
|
|
285
291
|
```
|
|
286
292
|
|
|
287
|
-
Each line is valid JSON and can be piped through `jq -c .`. Event types include `turn_start`, `message_start` / `message_update` / `message_end`, `tool_start` / `tool_end`, `retry`, `context_overflow`, and `turn_end`. Every event has an ISO-8601 `at` timestamp. Tool events omit raw inputs and outputs because CI and harness logs often capture stdout; use `--debug` for detailed local JSONL logs.
|
|
293
|
+
Each line is valid JSON and can be piped through `jq -c .`. Event types include `turn_start`, `message_start` / `message_update` / `message_end`, `tool_start` / `tool_end`, `resource_rollover`, `retry`, `context_overflow`, `compaction_start` / `compaction_end`, and `turn_end`. `resource_rollover` reports bounded SDK-step transitions and whether the provider prefix was preserved, without exposing prompts or tool output. Every event has an ISO-8601 `at` timestamp. Tool events omit raw inputs and outputs because CI and harness logs often capture stdout; use `--debug` for detailed local JSONL logs.
|
|
288
294
|
|
|
289
295
|
This mode is intended for harnesses that run haze without a person at the terminal. A supervisor can watch stdout for progress, stalls, or loops. The final `result` envelope contains the authoritative status, text, and usage. The `text` and `json` formats are unchanged.
|
|
290
296
|
|
|
@@ -360,7 +366,7 @@ Keep trivial, conversation-coupled, sequential, user-interactive, or uncertain s
|
|
|
360
366
|
|
|
361
367
|
## Context files
|
|
362
368
|
|
|
363
|
-
haze saves durable workspace sessions in `~/.haze/sessions`. It writes a session after the first resumable message, so empty sessions do not create files or appear under `/resume`. Settings, history, sessions, and debug logs use private POSIX directory/file permissions (`0700`/`0600`) and ordered, flushable writes. Use `/session` to see the current file, `/new` to start fresh, and `/resume` to browse workspace sessions, resume one, or fork its latest snapshot into a new session. `/resume <id>` and `haze --resume <id>` select an exact session. Use `/compact` to condense older model context: by default the active model writes a continuity summary of the older history (set `manualCompaction: "heuristic"` in settings to keep the model-free bounded excerpt instead); automatic mid-turn compaction
|
|
369
|
+
haze saves durable workspace sessions in `~/.haze/sessions`. It writes a session after the first resumable message, so empty sessions do not create files or appear under `/resume`. Settings, history, sessions, and debug logs use private POSIX directory/file permissions (`0700`/`0600`) and ordered, flushable writes. Use `/session` to see the current file, `/new` to start fresh, and `/resume` to browse workspace sessions, resume one, or fork its latest snapshot into a new session. `/resume <id>` and `haze --resume <id>` select an exact session. Use `/compact` to condense older model context: by default the active model writes a continuity summary of the older history (set `manualCompaction: "heuristic"` in settings to keep the model-free bounded excerpt instead); automatic mid-turn compaction also prefers a model-written summary once the older history is large, keeping the bounded excerpt for small trims and as the fallback when summarization fails. Sessions also persist compact structured work state: the active goal, touched files, validation evidence, blockers, and next action.
|
|
364
370
|
|
|
365
371
|
Snapshots are written at turn boundaries, not per tool call. If haze crashes or is killed mid-turn, the session resumes from the last completed turn: work already on disk (file edits, command side effects) is not reflected in the session record, so after a crash verify the working tree (`git status`, `git diff`) before continuing. To keep long sessions from growing quadratically — every turn appends the full history again — session files are automatically compacted once superseded snapshots dominate the file: only the newest conversation and work-state snapshots are kept and the file is rewritten atomically.
|
|
366
372
|
|
|
@@ -383,7 +389,8 @@ Use `AGENTS.md` for project conventions, commands, architecture notes, and anyth
|
|
|
383
389
|
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.
|
|
384
390
|
|
|
385
391
|
- `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`.
|
|
386
|
-
- `
|
|
392
|
+
- `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.
|
|
393
|
+
- `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.
|
|
387
394
|
- `manualCompaction` (`"llm-summary"` default, or `"heuristic"`): whether manual `/compact` asks the active model for a continuity summary or keeps the model-free bounded excerpt.
|
|
388
395
|
- `theme` (string, default `purple`): name of a built-in palette (`/themes` lists and sets them, with `light` and oh-my-zsh ports like `robbyrussell` included). Unknown names fail loudly at startup with the valid names listed.
|
|
389
396
|
|
|
@@ -448,7 +455,7 @@ Package check:
|
|
|
448
455
|
npm pack --dry-run
|
|
449
456
|
```
|
|
450
457
|
|
|
451
|
-
The npm package ships `bin`, `dist`, README,
|
|
458
|
+
The npm package ships `bin`, `dist`, README, SECURITY.md, license, and changelog.
|
|
452
459
|
|
|
453
460
|
## Release
|
|
454
461
|
|
package/SECURITY.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| Version | Supported |
|
|
6
6
|
|---------|-----------|
|
|
7
|
-
| Latest minor (`1.
|
|
7
|
+
| Latest minor (`1.2.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-08-
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"commit": "667c1c325d41e1f9811d9de0d19361e95a969d0e",
|
|
5
|
+
"builtAt": "2026-08-31T22:00:27.789Z",
|
|
6
6
|
"sourceRoot": "/Users/deniz.okcu/development/haze"
|
|
7
7
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Busy state with a one-second heartbeat. The tick re-renders the elapsed-time
|
|
3
|
+
* label so the developer always sees rolling activity even when the model is
|
|
4
|
+
* thinking with no streamed output and no tool is running (the "looks stuck"
|
|
5
|
+
* problem). Extracted from ChatScreen alongside BusyBar.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useBusyIndicator(): {
|
|
8
|
+
busy: boolean;
|
|
9
|
+
setBusy: (nextBusy: boolean) => void;
|
|
10
|
+
elapsed: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { formatElapsedTimeWhole } from '../../utils/format.js';
|
|
3
|
+
/** Elapsed-time label for the busy indicator heartbeat, or '' when no turn is active. */
|
|
4
|
+
function busyElapsedLabel(startedAt) {
|
|
5
|
+
if (startedAt == null)
|
|
6
|
+
return '';
|
|
7
|
+
const elapsed = Date.now() - startedAt;
|
|
8
|
+
return elapsed > 0 ? formatElapsedTimeWhole(elapsed) : '';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Busy state with a one-second heartbeat. The tick re-renders the elapsed-time
|
|
12
|
+
* label so the developer always sees rolling activity even when the model is
|
|
13
|
+
* thinking with no streamed output and no tool is running (the "looks stuck"
|
|
14
|
+
* problem). Extracted from ChatScreen alongside BusyBar.
|
|
15
|
+
*/
|
|
16
|
+
export function useBusyIndicator() {
|
|
17
|
+
const [busy, setBusyState] = useState(false);
|
|
18
|
+
const turnStartedAtRef = useRef(undefined);
|
|
19
|
+
const [, setBusyTick] = useState(0);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!busy)
|
|
22
|
+
return;
|
|
23
|
+
const heartbeat = setInterval(() => setBusyTick(tick => tick + 1), 1000);
|
|
24
|
+
return () => clearInterval(heartbeat);
|
|
25
|
+
}, [busy]);
|
|
26
|
+
function setBusy(nextBusy) {
|
|
27
|
+
if (nextBusy && !busy)
|
|
28
|
+
turnStartedAtRef.current = Date.now();
|
|
29
|
+
if (!nextBusy)
|
|
30
|
+
turnStartedAtRef.current = undefined;
|
|
31
|
+
setBusyState(nextBusy);
|
|
32
|
+
}
|
|
33
|
+
return { busy, setBusy, elapsed: busyElapsedLabel(turnStartedAtRef.current) };
|
|
34
|
+
}
|
|
@@ -3,7 +3,6 @@ import type { Message } from '../commands/streaming.js';
|
|
|
3
3
|
import type { TokenUsage } from '../commands/streaming/turnRuntime.js';
|
|
4
4
|
export declare function toolCallCount(messages: Message[]): number;
|
|
5
5
|
export declare function compactHomePath(filePath: string, home?: string): string;
|
|
6
|
-
export declare function formatTokenCount(tokens: number): string;
|
|
7
6
|
export declare function displayMessagesFromConversation(conversation: ModelMessage[]): Message[];
|
|
8
7
|
export declare function estimateConversationTokens(messages: Message[]): {
|
|
9
8
|
input: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import { modelMessageText } from '../../core/agent/compaction.js';
|
|
3
|
+
import { formatTokenCount } from '../../utils/format.js';
|
|
3
4
|
export function toolCallCount(messages) {
|
|
4
5
|
return messages.reduce((total, message) => {
|
|
5
6
|
if (message.role !== 'tool')
|
|
@@ -19,13 +20,6 @@ export function compactHomePath(filePath, home = os.homedir()) {
|
|
|
19
20
|
return '~';
|
|
20
21
|
return filePath.startsWith(`${home}/`) ? `~/${filePath.slice(home.length + 1)}` : filePath;
|
|
21
22
|
}
|
|
22
|
-
export function formatTokenCount(tokens) {
|
|
23
|
-
if (tokens >= 1_000_000)
|
|
24
|
-
return `${(tokens / 1_000_000).toFixed(tokens >= 10_000_000 ? 0 : 1).replace(/\.0$/, '')}m`;
|
|
25
|
-
if (tokens >= 1_000)
|
|
26
|
-
return `${(tokens / 1_000).toFixed(tokens >= 10_000 ? 0 : 1).replace(/\.0$/, '')}k`;
|
|
27
|
-
return String(tokens);
|
|
28
|
-
}
|
|
29
23
|
export function displayMessagesFromConversation(conversation) {
|
|
30
24
|
return conversation.flatMap(message => {
|
|
31
25
|
if (message.role !== 'user' && message.role !== 'assistant')
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The follow-up queue for messages submitted while a turn is running (typed
|
|
3
|
+
* input is queued, Esc clears). Extracted from ChatScreen so queue mechanics
|
|
4
|
+
* (ref + mirrored state + transcript notices) live in one place.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useFollowUpQueue(addSystemMessage: (text: string) => void): {
|
|
7
|
+
queued: string[];
|
|
8
|
+
queue: (value: string) => void;
|
|
9
|
+
takeNext: () => string | undefined;
|
|
10
|
+
clear: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The follow-up queue for messages submitted while a turn is running (typed
|
|
4
|
+
* input is queued, Esc clears). Extracted from ChatScreen so queue mechanics
|
|
5
|
+
* (ref + mirrored state + transcript notices) live in one place.
|
|
6
|
+
*/
|
|
7
|
+
export function useFollowUpQueue(addSystemMessage) {
|
|
8
|
+
const queueRef = useRef([]);
|
|
9
|
+
const [queued, setQueued] = useState([]);
|
|
10
|
+
/** Queue a submitted value; empty values are ignored. */
|
|
11
|
+
function queue(value) {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if (!trimmed)
|
|
14
|
+
return;
|
|
15
|
+
queueRef.current = [...queueRef.current, trimmed];
|
|
16
|
+
setQueued(queueRef.current);
|
|
17
|
+
addSystemMessage(`Queued follow-up (${queueRef.current.length}): ${trimmed}`);
|
|
18
|
+
}
|
|
19
|
+
/** Dequeue the next follow-up (announcing it), or undefined when empty. */
|
|
20
|
+
function takeNext() {
|
|
21
|
+
const next = queueRef.current[0];
|
|
22
|
+
if (next === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
queueRef.current = queueRef.current.slice(1);
|
|
25
|
+
setQueued(queueRef.current);
|
|
26
|
+
addSystemMessage(`Running queued follow-up: ${next}`);
|
|
27
|
+
return next;
|
|
28
|
+
}
|
|
29
|
+
/** Drop every queued follow-up (user interrupt); reports the clear when anything was dropped. */
|
|
30
|
+
function clear() {
|
|
31
|
+
if (queueRef.current.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
queueRef.current = [];
|
|
34
|
+
setQueued([]);
|
|
35
|
+
addSystemMessage('Cleared queued follow-ups after interrupt.');
|
|
36
|
+
}
|
|
37
|
+
return { queued, queue, takeNext, clear };
|
|
38
|
+
}
|
|
@@ -14,25 +14,3 @@ export declare const MessageView: React.MemoExoticComponent<({ message, width, s
|
|
|
14
14
|
showHeader?: boolean;
|
|
15
15
|
maxVisibleLines?: number;
|
|
16
16
|
}) => React.JSX.Element>;
|
|
17
|
-
export type TranscriptStaticItem = {
|
|
18
|
-
kind: 'message';
|
|
19
|
-
key: string;
|
|
20
|
-
message: Message;
|
|
21
|
-
} | {
|
|
22
|
-
kind: 'assistant-markdown';
|
|
23
|
-
key: string;
|
|
24
|
-
message: Message;
|
|
25
|
-
content: string;
|
|
26
|
-
first: boolean;
|
|
27
|
-
final: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type TranscriptStreamingItem = {
|
|
30
|
-
key: string;
|
|
31
|
-
message: Message;
|
|
32
|
-
showHeader?: boolean;
|
|
33
|
-
};
|
|
34
|
-
/** Partition display messages into append-only static Markdown roots and the active streaming tail. */
|
|
35
|
-
export declare function partitionDisplayMessages(messages: Message[]): {
|
|
36
|
-
staticItems: TranscriptStaticItem[];
|
|
37
|
-
streamingItems: TranscriptStreamingItem[];
|
|
38
|
-
};
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Box, Text } from 'ink';
|
|
4
4
|
import Spinner from 'ink-spinner';
|
|
5
|
-
import { formatElapsedTime, formatElapsedTimeWhole } from '
|
|
6
|
-
import { MarkdownText
|
|
7
|
-
import {
|
|
5
|
+
import { formatElapsedTime, formatElapsedTimeWhole } from '../../utils/format.js';
|
|
6
|
+
import { MarkdownText } from '../../ui/components/MarkdownText.js';
|
|
7
|
+
import { clampTextTail, wrapLine } from './liveRegion.js';
|
|
8
8
|
import { isSubstantiveAssistantText } from '../commands/streaming/assistantText.js';
|
|
9
9
|
import { theme } from '../../ui/theme.js';
|
|
10
10
|
import { highlightedCodeLine, languageForPath } from '../../ui/codeHighlight.js';
|
|
@@ -88,6 +88,22 @@ function ToolDiffView({ diff, width }) {
|
|
|
88
88
|
function toolDiffRows(diff) {
|
|
89
89
|
return 1 + diff.lines.length + (diff.handle ? 1 : 0) + (diff.complete === false ? 1 : 0) + 1;
|
|
90
90
|
}
|
|
91
|
+
const TOOL_ROW_PATTERN = /^(\s*)([✓✗…])\s+(\S+)(.*)$/;
|
|
92
|
+
/**
|
|
93
|
+
* Wrapped display rows for one tool-group line. Ink's wrapping has no hanging
|
|
94
|
+
* indent, so icon rows are pre-wrapped here (mirroring Ink's own wrap-ansi
|
|
95
|
+
* settings, see liveRegion.ts) and continuation rows are padded to align
|
|
96
|
+
* under the tool name instead of dropping back to the left edge.
|
|
97
|
+
*/
|
|
98
|
+
function toolGroupLineRows(line, width) {
|
|
99
|
+
const match = TOOL_ROW_PATTERN.exec(line);
|
|
100
|
+
if (!match)
|
|
101
|
+
return wrapLine(line, width);
|
|
102
|
+
const [, indent, icon, toolName, rest] = match;
|
|
103
|
+
const hang = indent.length + 2; // icon + separating space
|
|
104
|
+
const rows = wrapLine(`${toolName}${rest}`, Math.max(1, width - hang));
|
|
105
|
+
return rows.map((row, index) => (index === 0 ? `${indent}${icon} ${row}` : `${' '.repeat(hang)}${row}`));
|
|
106
|
+
}
|
|
91
107
|
/**
|
|
92
108
|
* Live-region clamp for the streaming tool group (see liveRegion.ts): keep only
|
|
93
109
|
* the rows that fit the viewport budget, dropping whole logical lines from the
|
|
@@ -99,7 +115,9 @@ function clampToolDisplay({ text, width, toolDiffs, maxVisibleLines }) {
|
|
|
99
115
|
const allDiffs = toolDiffs ?? [];
|
|
100
116
|
if (maxVisibleLines == null)
|
|
101
117
|
return { lines: allLines, hiddenTextRowCount: 0, visibleDiffs: allDiffs, hiddenDiffCount: 0 };
|
|
102
|
-
|
|
118
|
+
// Row counts must mirror toolGroupLineRows so the budget matches what is
|
|
119
|
+
// actually rendered (icon rows consume one extra hang indent column).
|
|
120
|
+
const rows = allLines.map(line => toolGroupLineRows(line, width).length);
|
|
103
121
|
const total = rows.reduce((sum, count) => sum + count, 0);
|
|
104
122
|
let lines = allLines;
|
|
105
123
|
let hiddenTextRowCount = 0;
|
|
@@ -134,17 +152,26 @@ function clampToolDisplay({ text, width, toolDiffs, maxVisibleLines }) {
|
|
|
134
152
|
}
|
|
135
153
|
function ToolMessageText({ text, streaming, width, toolDiffs, maxVisibleLines }) {
|
|
136
154
|
const clamped = clampToolDisplay({ text, width, toolDiffs, maxVisibleLines });
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return _jsxs(Text, { color: theme.muted, children: [index === 0 && streaming ? _jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), " "] }) : null,
|
|
155
|
+
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
|
+
const match = TOOL_ROW_PATTERN.exec(line);
|
|
157
|
+
if (!match) {
|
|
158
|
+
// Summary header / caption rows: plain muted rows (spinner on the
|
|
159
|
+
// first row while streaming).
|
|
160
|
+
return toolGroupLineRows(line, width).map((row, rowIndex) => _jsxs(Text, { color: theme.muted, children: [index === 0 && rowIndex === 0 && streaming ? _jsxs(_Fragment, { children: [_jsx(Spinner, { type: "dots" }), " "] }) : null, row] }, `${index}-${rowIndex}`));
|
|
143
161
|
}
|
|
144
|
-
const [, indent, icon, toolName
|
|
162
|
+
const [, indent, icon, toolName] = match;
|
|
145
163
|
const iconColor = icon === '✓' ? theme.success : icon === '✗' ? theme.danger : theme.muted;
|
|
146
|
-
const
|
|
147
|
-
return
|
|
164
|
+
const hang = indent.length + 2; // icon + separating space
|
|
165
|
+
return toolGroupLineRows(line, width).map((row, rowIndex) => {
|
|
166
|
+
// Rows already carry their prefix; slice the content off to re-apply
|
|
167
|
+
// icon/tool-name colors on the first row.
|
|
168
|
+
const content = row.slice(hang);
|
|
169
|
+
return rowIndex === 0
|
|
170
|
+
? _jsxs(Text, { color: theme.muted, children: [indent, _jsx(Text, { color: iconColor, children: icon }), " ", _jsx(Text, { color: theme.accent, children: content.slice(0, toolName.length) }), content.slice(toolName.length)] }, `${index}-${rowIndex}`)
|
|
171
|
+
// Continuation rows keep the hanging indent so wrapped tool lines
|
|
172
|
+
// stay aligned under the tool name.
|
|
173
|
+
: _jsx(Text, { color: theme.muted, children: row }, `${index}-${rowIndex}`);
|
|
174
|
+
});
|
|
148
175
|
}), clamped.visibleDiffs.map(diff => _jsx(ToolDiffView, { diff: diff, width: width }, diff.id)), clamped.hiddenDiffCount > 0 ? _jsx(Text, { color: theme.muted, children: `⋯ ${clamped.hiddenDiffCount} diff preview${clamped.hiddenDiffCount === 1 ? '' : 's'} hidden` }) : null] });
|
|
149
176
|
}
|
|
150
177
|
export function messageElapsedLabel(message) {
|
|
@@ -185,75 +212,3 @@ export const MessageView = React.memo(function MessageView({ message, width, sho
|
|
|
185
212
|
? _jsx(StreamingClampedText, { text: message.text, width: width, maxVisibleLines: maxVisibleLines })
|
|
186
213
|
: _jsx(Text, { children: message.text })] });
|
|
187
214
|
});
|
|
188
|
-
function messageKey(message, index) {
|
|
189
|
-
return message.id ?? `${index}-${message.role}-${message.text}`;
|
|
190
|
-
}
|
|
191
|
-
/** Partition display messages into append-only static Markdown roots and the active streaming tail. */
|
|
192
|
-
export function partitionDisplayMessages(messages) {
|
|
193
|
-
const staticItems = [];
|
|
194
|
-
const streamingItems = [];
|
|
195
|
-
let reachedDynamicTail = false;
|
|
196
|
-
orderedDisplayMessages(messages).forEach((message, index) => {
|
|
197
|
-
const key = messageKey(message, index);
|
|
198
|
-
// Static output must remain an ordered prefix. A settled notification that
|
|
199
|
-
// follows live text stays in the dynamic frame until that text is complete.
|
|
200
|
-
if (reachedDynamicTail) {
|
|
201
|
-
streamingItems.push({ key, message });
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (message.role !== 'assistant') {
|
|
205
|
-
if (message.streaming) {
|
|
206
|
-
reachedDynamicTail = true;
|
|
207
|
-
streamingItems.push({ key, message });
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
staticItems.push({ kind: 'message', key, message });
|
|
211
|
-
}
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const chunks = markdownRootChunks(message.text);
|
|
215
|
-
if (chunks.length === 0) {
|
|
216
|
-
if (message.streaming) {
|
|
217
|
-
reachedDynamicTail = true;
|
|
218
|
-
streamingItems.push({ key, message });
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
staticItems.push({ kind: 'message', key, message });
|
|
222
|
-
}
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
// Marked may still reclassify the final root while the stream grows. Keep
|
|
226
|
-
// only that root dynamic; every preceding root is now safe to append once.
|
|
227
|
-
const staticChunkCount = message.streaming ? Math.max(0, chunks.length - 1) : chunks.length;
|
|
228
|
-
for (let chunkIndex = 0; chunkIndex < staticChunkCount; chunkIndex++) {
|
|
229
|
-
staticItems.push({
|
|
230
|
-
kind: 'assistant-markdown',
|
|
231
|
-
key: `${key}-markdown-${chunkIndex}`,
|
|
232
|
-
message,
|
|
233
|
-
content: chunks[chunkIndex] ?? '',
|
|
234
|
-
first: chunkIndex === 0,
|
|
235
|
-
final: !message.streaming && chunkIndex === chunks.length - 1,
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
if (message.streaming) {
|
|
239
|
-
reachedDynamicTail = true;
|
|
240
|
-
streamingItems.push({
|
|
241
|
-
key,
|
|
242
|
-
message: { ...message, text: chunks.at(-1) ?? message.text },
|
|
243
|
-
showHeader: staticChunkCount === 0,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
return { staticItems, streamingItems };
|
|
248
|
-
}
|
|
249
|
-
function orderedDisplayMessages(messages) {
|
|
250
|
-
return messages
|
|
251
|
-
.map((message, index) => ({ message, index }))
|
|
252
|
-
.sort((a, b) => {
|
|
253
|
-
if (a.message.displayOrder != null && b.message.displayOrder != null && a.message.displayOrder !== b.message.displayOrder) {
|
|
254
|
-
return a.message.displayOrder - b.message.displayOrder;
|
|
255
|
-
}
|
|
256
|
-
return a.index - b.index;
|
|
257
|
-
})
|
|
258
|
-
.map(item => item.message);
|
|
259
|
-
}
|
|
@@ -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 HazeSession } from '../../core/session/sessionStore.js';
|
|
4
|
+
import { type GoalLedgerFrontier, type HazeSession } 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';
|
|
@@ -51,6 +51,8 @@ export interface SessionLifecycleDeps {
|
|
|
51
51
|
setTokenUsage: (usage: TokenUsage) => void;
|
|
52
52
|
/** Manual /compact mode: model-written summary (default) or heuristic excerpt. */
|
|
53
53
|
manualCompaction?: () => 'llm-summary' | 'heuristic';
|
|
54
|
+
/** Called when a resumed session carries an unterminated goal frontier (P1): the UI offers the one-key continue. */
|
|
55
|
+
onGoalFrontier?: (frontier: GoalLedgerFrontier) => void;
|
|
54
56
|
debugLog: (line: string) => void;
|
|
55
57
|
showPersistenceWarning: (error: unknown) => void;
|
|
56
58
|
}
|
|
@@ -44,7 +44,7 @@ export function createSessionLifecycle(deps) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
async function resumeSession(session, replaceTranscript) {
|
|
47
|
-
const { messages: conversation, workState, parseErrors } = await restoreSessionState(session);
|
|
47
|
+
const { messages: conversation, workState, parseErrors, goalFrontier } = await restoreSessionState(session);
|
|
48
48
|
deps.sessionRef.current = session;
|
|
49
49
|
deps.conversationRef.current = conversation;
|
|
50
50
|
deps.setLiveMessagesState(() => []);
|
|
@@ -58,6 +58,11 @@ export function createSessionLifecycle(deps) {
|
|
|
58
58
|
const restored = [{ role: 'system', text: `Resumed session: ${formatSession(session)}` }, ...restoredMessages];
|
|
59
59
|
return replaceTranscript ? restored : [...messages, ...restored];
|
|
60
60
|
});
|
|
61
|
+
// P1 resume path: a durable, unterminated goal frontier surfaces in the
|
|
62
|
+
// resume flow (system note + one-key continue, mirroring the R-resume UX)
|
|
63
|
+
// instead of silently starting fresh.
|
|
64
|
+
if (goalFrontier)
|
|
65
|
+
deps.onGoalFrontier?.(goalFrontier);
|
|
61
66
|
}
|
|
62
67
|
/** Heuristic-excerpt compaction shared by the sync path and the LLM fallback (F-09). */
|
|
63
68
|
function compactConversationSync(instructions) {
|
|
@@ -70,6 +75,7 @@ export function createSessionLifecycle(deps) {
|
|
|
70
75
|
}
|
|
71
76
|
deps.conversationRef.current = result.messages;
|
|
72
77
|
deps.sessionRecorder()?.recordNamedEvent('compact', `Compacted ${result.olderCount} messages; kept ${result.keptCount}.`);
|
|
78
|
+
deps.sessionRecorder()?.recordCompactEntry({ method: 'heuristic', olderCount: result.olderCount, keptCount: result.keptCount, ...(instructions ? { instructions } : {}), summary: result.summary ?? '' });
|
|
73
79
|
deps.sessionRecorder()?.recordConversation(result.messages);
|
|
74
80
|
deps.setMessages(m => [...m, { role: 'system', text: `Compacted context: condensed ${result.olderCount} older model messages into a bounded excerpt and kept the last ${result.keptCount}.` }]);
|
|
75
81
|
return true;
|
|
@@ -192,6 +198,7 @@ export function createSessionLifecycle(deps) {
|
|
|
192
198
|
throw new Error('nothing older to compact');
|
|
193
199
|
deps.conversationRef.current = result.messages;
|
|
194
200
|
deps.sessionRecorder()?.recordNamedEvent('compact', `Compacted ${result.olderCount} messages with a model-written summary; kept ${result.keptCount}.`);
|
|
201
|
+
deps.sessionRecorder()?.recordCompactEntry({ method: 'llm', olderCount: result.olderCount, keptCount: result.keptCount, ...(instructions ? { instructions } : {}), summary: result.summary ?? '' });
|
|
195
202
|
deps.sessionRecorder()?.recordConversation(result.messages);
|
|
196
203
|
deps.setMessages(m => [...m, { role: 'system', text: `Compacted context: replaced ${result.olderCount} older model messages with a model-written summary and kept the last ${result.keptCount}.` }]);
|
|
197
204
|
return true;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ModelMessage } from 'ai';
|
|
2
2
|
import { type HazeSession } from '../../core/session/sessionStore.js';
|
|
3
|
+
import type { GoalLedgerAppend } from '../commands/streaming/goalCheckpoint.js';
|
|
3
4
|
import type { AgentEvent } from '../../core/agent/events.js';
|
|
4
5
|
import type { WorkState } from '../../core/agent/workState.js';
|
|
5
6
|
import type { Message } from '../commands/streaming.js';
|
|
@@ -8,7 +9,15 @@ export declare function createSessionRecorder(getSession: () => HazeSession | un
|
|
|
8
9
|
recordConversation(messages: ModelMessage[]): void;
|
|
9
10
|
recordWorkState(state: WorkState): void;
|
|
10
11
|
recordEvent(event: AgentEvent): void;
|
|
12
|
+
recordGoalEntry(entry: GoalLedgerAppend): void;
|
|
11
13
|
recordNamedEvent(name: string, text: string): void;
|
|
14
|
+
recordCompactEntry(entry: {
|
|
15
|
+
method: "heuristic" | "llm";
|
|
16
|
+
olderCount: number;
|
|
17
|
+
keptCount: number;
|
|
18
|
+
instructions?: string;
|
|
19
|
+
summary: string;
|
|
20
|
+
}): void;
|
|
12
21
|
flush(): Promise<void>;
|
|
13
22
|
error(): Error | undefined;
|
|
14
23
|
};
|
|
@@ -80,9 +80,21 @@ export function createSessionRecorder(getSession) {
|
|
|
80
80
|
return;
|
|
81
81
|
appendEntry({ type: 'event', at: event.at, name: event.type, text: JSON.stringify(event) });
|
|
82
82
|
},
|
|
83
|
+
// Durable goal-ledger append (P1): the supervisor calls this once per
|
|
84
|
+
// boundary (start/continue/end); the append-only frontier is the last
|
|
85
|
+
// non-terminal entry, and a truncated tail line parses as absent.
|
|
86
|
+
recordGoalEntry(entry) {
|
|
87
|
+
appendEntry({ type: 'goal', at: new Date().toISOString(), ...entry });
|
|
88
|
+
},
|
|
83
89
|
recordNamedEvent(name, text) {
|
|
84
90
|
appendEntry({ type: 'event', at: new Date().toISOString(), name, text });
|
|
85
91
|
},
|
|
92
|
+
// First-class compaction audit entry (Pillar 1.7): what was compacted,
|
|
93
|
+
// when, how, and the summary that replaced it. Snapshots stay the restore
|
|
94
|
+
// source of truth; this entry is the durable narrative.
|
|
95
|
+
recordCompactEntry(entry) {
|
|
96
|
+
appendEntry({ type: 'compact', at: new Date().toISOString(), method: entry.method, olderCount: entry.olderCount, keptCount: entry.keptCount, ...(entry.instructions ? { instructions: entry.instructions } : {}), summary: entry.summary });
|
|
97
|
+
},
|
|
86
98
|
async flush() {
|
|
87
99
|
// Fold coalesced snapshots into the writer queue, then wait for the queue
|
|
88
100
|
// to drain. Loop because a write completing mid-flush may have queued a
|