@denizokcu/haze 1.2.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/CHANGELOG.md +86 -1
  2. package/README.md +23 -10
  3. package/SECURITY.md +1 -1
  4. package/bin/haze.js +27 -7
  5. package/dist/buildInfo.json +3 -3
  6. package/dist/cli/chat/BusyBar.d.ts +7 -0
  7. package/dist/cli/chat/BusyBar.js +8 -0
  8. package/dist/cli/chat/DynamicFrame.d.ts +37 -0
  9. package/dist/cli/chat/DynamicFrame.js +43 -0
  10. package/dist/cli/chat/busyIndicator.d.ts +3 -1
  11. package/dist/cli/chat/busyIndicator.js +11 -9
  12. package/dist/cli/chat/chatMetrics.d.ts +1 -1
  13. package/dist/cli/chat/chatMetrics.js +3 -3
  14. package/dist/cli/chat/inputSuggestions.js +4 -0
  15. package/dist/cli/chat/liveMessages.d.ts +36 -0
  16. package/dist/cli/chat/liveMessages.js +64 -0
  17. package/dist/cli/chat/liveRegion.js +1 -1
  18. package/dist/cli/chat/messages.js +27 -16
  19. package/dist/cli/chat/sessionLifecycle.d.ts +5 -2
  20. package/dist/cli/chat/sessionLifecycle.js +36 -4
  21. package/dist/cli/chat/sessionRecorder.d.ts +2 -1
  22. package/dist/cli/chat/sessionRecorder.js +8 -0
  23. package/dist/cli/chat/shutdown.d.ts +27 -0
  24. package/dist/cli/chat/shutdown.js +79 -0
  25. package/dist/cli/chat/terminalControl.d.ts +45 -0
  26. package/dist/cli/chat/terminalControl.js +107 -0
  27. package/dist/cli/chat/tips.js +1 -0
  28. package/dist/cli/chat/userInput.d.ts +43 -0
  29. package/dist/cli/chat/userInput.js +63 -0
  30. package/dist/cli/chat/wizard/sessionThemeHandlers.d.ts +1 -1
  31. package/dist/cli/chat/wizard/sessionThemeHandlers.js +24 -1
  32. package/dist/cli/chat/wizard/types.d.ts +8 -1
  33. package/dist/cli/chat/wizardDispatch.js +1 -1
  34. package/dist/cli/commands/chat.js +277 -193
  35. package/dist/cli/commands/commandHelp.js +6 -0
  36. package/dist/cli/commands/commands.d.ts +8 -0
  37. package/dist/cli/commands/commands.js +13 -0
  38. package/dist/cli/commands/formatters.d.ts +1 -1
  39. package/dist/cli/commands/formatters.js +25 -3
  40. package/dist/cli/commands/logsCommand.js +21 -2
  41. package/dist/cli/commands/ndjsonSink.d.ts +12 -0
  42. package/dist/cli/commands/ndjsonSink.js +29 -0
  43. package/dist/cli/commands/reasoningCommand.d.ts +44 -0
  44. package/dist/cli/commands/reasoningCommand.js +79 -0
  45. package/dist/cli/commands/runCommand.d.ts +14 -0
  46. package/dist/cli/commands/runCommand.js +56 -22
  47. package/dist/cli/commands/settingsSummary.js +2 -0
  48. package/dist/cli/commands/streaming/agentAttempt.d.ts +3 -0
  49. package/dist/cli/commands/streaming/agentAttempt.js +2 -2
  50. package/dist/cli/commands/streaming/assistantSegments.d.ts +0 -7
  51. package/dist/cli/commands/streaming/assistantSegments.js +1 -1
  52. package/dist/cli/commands/streaming/attemptLifecycle.js +13 -9
  53. package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
  54. package/dist/cli/commands/streaming/attemptOutcome.js +24 -9
  55. package/dist/cli/commands/streaming/attemptSetup.d.ts +4 -0
  56. package/dist/cli/commands/streaming/attemptSetup.js +21 -7
  57. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +14 -1
  58. package/dist/cli/commands/streaming/goalCheckpoint.js +4 -2
  59. package/dist/cli/commands/streaming/goalSupervisor.d.ts +9 -0
  60. package/dist/cli/commands/streaming/goalSupervisor.js +51 -10
  61. package/dist/cli/commands/streaming/prepareStep.d.ts +0 -3
  62. package/dist/cli/commands/streaming/prepareStep.js +14 -5
  63. package/dist/cli/commands/streaming/streamLoop.d.ts +5 -0
  64. package/dist/cli/commands/streaming/streamLoop.js +3 -0
  65. package/dist/cli/commands/streaming/toolPartHandlers.js +6 -0
  66. package/dist/cli/commands/streaming.d.ts +8 -3
  67. package/dist/cli/commands/streaming.js +46 -21
  68. package/dist/cli/commands/wizardFlow.d.ts +10 -0
  69. package/dist/cli/commands/wizardFlow.js +34 -5
  70. package/dist/cli/index.js +22 -2
  71. package/dist/config/contextFiles.d.ts +9 -0
  72. package/dist/config/contextFiles.js +21 -1
  73. package/dist/config/modelCatalog.d.ts +3 -0
  74. package/dist/config/modelCatalog.js +29 -0
  75. package/dist/config/modelDiscovery.js +68 -5
  76. package/dist/config/providerPresets.d.ts +1 -1
  77. package/dist/config/providerPresets.js +42 -3
  78. package/dist/config/settings.d.ts +14 -6
  79. package/dist/config/settings.js +16 -1
  80. package/dist/core/agent/budgets.d.ts +13 -17
  81. package/dist/core/agent/budgets.js +15 -19
  82. package/dist/core/agent/completionController.d.ts +14 -2
  83. package/dist/core/agent/completionController.js +48 -3
  84. package/dist/core/agent/events.d.ts +2 -1
  85. package/dist/core/agent/goalPolicy.d.ts +17 -0
  86. package/dist/core/agent/goalPolicy.js +53 -6
  87. package/dist/core/agent/projectPreflight.d.ts +2 -0
  88. package/dist/core/agent/projectPreflight.js +56 -0
  89. package/dist/core/agent/reasoningPolicy.d.ts +76 -10
  90. package/dist/core/agent/reasoningPolicy.js +72 -9
  91. package/dist/core/agent/toolCapabilities.d.ts +3 -3
  92. package/dist/core/agent/toolCapabilities.js +31 -7
  93. package/dist/core/agent/workState.d.ts +14 -4
  94. package/dist/core/agent/workState.js +229 -34
  95. package/dist/core/deadline.js +22 -24
  96. package/dist/core/providerContracts.d.ts +29 -0
  97. package/dist/core/providerContracts.js +1 -0
  98. package/dist/core/safety/secretPaths.js +10 -7
  99. package/dist/core/safety/shellClassifier.d.ts +2 -0
  100. package/dist/core/safety/shellClassifier.js +9 -1
  101. package/dist/core/session/sessionReport.d.ts +33 -0
  102. package/dist/core/session/sessionReport.js +121 -0
  103. package/dist/core/session/sessionSlimming.d.ts +2 -0
  104. package/dist/core/session/sessionSlimming.js +59 -4
  105. package/dist/core/session/sessionStore.d.ts +16 -8
  106. package/dist/core/session/sessionStore.js +71 -34
  107. package/dist/core/shellOutput/reducers/git.js +7 -2
  108. package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
  109. package/dist/core/shellOutput/reducers/validation.js +14 -1
  110. package/dist/core/shellOutput/registry.js +3 -2
  111. package/dist/core/subagent/contracts.d.ts +3 -18
  112. package/dist/core/subagent/executionProfiles.js +4 -4
  113. package/dist/core/tasks/taskStorage.js +8 -1
  114. package/dist/core/validation/outputParser.d.ts +6 -1
  115. package/dist/core/validation/outputParser.js +30 -2
  116. package/dist/llm/client.d.ts +6 -3
  117. package/dist/llm/client.js +28 -11
  118. package/dist/llm/hazeTools.d.ts +9161 -7135
  119. package/dist/llm/hazeTools.js +6 -462
  120. package/dist/llm/lsp/client.d.ts +7 -1
  121. package/dist/llm/lsp/client.js +58 -9
  122. package/dist/llm/lsp/pool.d.ts +11 -0
  123. package/dist/llm/lsp/pool.js +61 -4
  124. package/dist/llm/lsp/protocol.d.ts +6 -23
  125. package/dist/llm/lsp/requests.d.ts +54 -60
  126. package/dist/llm/lsp/requests.js +152 -28
  127. package/dist/llm/lsp/symbols.d.ts +16 -0
  128. package/dist/llm/lsp/symbols.js +70 -0
  129. package/dist/llm/lsp/workspaceEdit.d.ts +43 -0
  130. package/dist/llm/lsp/workspaceEdit.js +117 -0
  131. package/dist/llm/lspTools.d.ts +7518 -2859
  132. package/dist/llm/lspTools.js +195 -110
  133. package/dist/llm/mcp.js +3 -0
  134. package/dist/llm/requestContext.d.ts +4 -3
  135. package/dist/llm/requestContext.js +9 -5
  136. package/dist/{core/subagent → llm}/subagentRunner.d.ts +13 -9
  137. package/dist/{core/subagent → llm}/subagentRunner.js +54 -49
  138. package/dist/llm/systemPrompt.d.ts +11 -1
  139. package/dist/llm/systemPrompt.js +4 -13
  140. package/dist/llm/tools/fetchTool.d.ts +34 -30
  141. package/dist/llm/tools/fileTools.d.ts +7768 -0
  142. package/dist/llm/tools/fileTools.js +510 -0
  143. package/dist/llm/tools/processTool.d.ts +34 -30
  144. package/dist/llm/tools/replaceInFiles.d.ts +105 -0
  145. package/dist/llm/tools/replaceInFiles.js +131 -0
  146. package/dist/llm/tools/shellTool.d.ts +34 -30
  147. package/dist/llm/tools/shellTool.js +8 -4
  148. package/dist/llm/tools/storedOutputTool.d.ts +4 -0
  149. package/dist/llm/tools/taskTool.d.ts +4 -0
  150. package/dist/llm/tools/toolContext.d.ts +3 -29
  151. package/dist/llm/tools/toolContext.js +56 -53
  152. package/dist/llm/tools/toolContextState.d.ts +40 -0
  153. package/dist/llm/tools/toolContextState.js +34 -0
  154. package/dist/llm/workerContext.d.ts +7 -0
  155. package/dist/llm/workerContext.js +18 -1
  156. package/dist/skills/SkillLoader.js +30 -4
  157. package/dist/skills/SkillRegistry.js +3 -3
  158. package/dist/skills/builder/SkillBuilder.js +3 -3
  159. package/dist/skills/confinement.d.ts +7 -0
  160. package/dist/skills/confinement.js +15 -0
  161. package/dist/ui/codeHighlight.js +4 -4
  162. package/dist/ui/components/MarkdownText.js +7 -8
  163. package/dist/ui/components/NativeIndicators.d.ts +15 -0
  164. package/dist/ui/components/NativeIndicators.js +32 -0
  165. package/dist/ui/components/StreamingMarkdownText.d.ts +9 -0
  166. package/dist/ui/components/StreamingMarkdownText.js +38 -0
  167. package/dist/ui/components/TextInput.d.ts +7 -2
  168. package/dist/ui/components/TextInput.js +103 -46
  169. package/dist/ui/components/WizardChoices.d.ts +18 -0
  170. package/dist/ui/components/WizardChoices.js +32 -0
  171. package/dist/ui/components/useInputSuggestions.js +18 -6
  172. package/dist/ui/inputBuffer.js +12 -6
  173. package/dist/ui/textGeometry.d.ts +14 -0
  174. package/dist/ui/textGeometry.js +31 -0
  175. package/dist/utils/buildInfo.js +29 -8
  176. package/dist/utils/fs.js +5 -1
  177. package/package.json +23 -22
  178. /package/dist/cli/{contextReport.d.ts → contextReportCli.d.ts} +0 -0
  179. /package/dist/cli/{contextReport.js → contextReportCli.js} +0 -0
@@ -0,0 +1,121 @@
1
+ function record(value) {
2
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
3
+ }
4
+ /** Summarize a session without copying prompts, commands, paths, or tool output. */
5
+ export function summarizeSessionEntries(entries) {
6
+ const report = {
7
+ models: [], peakInputTokens: 0, steps: 0, toolCalls: {}, failedToolCalls: 0,
8
+ failedValidations: {}, continuations: 0, compactions: 0, budgetBoundaries: 0, goals: [],
9
+ };
10
+ const goals = new Map();
11
+ const finalEvidence = new Map();
12
+ const hasCompactEntries = entries.some(entry => entry.type === 'compact');
13
+ for (const entry of entries) {
14
+ if (entry.type === 'header') {
15
+ report.sessionId = entry.id;
16
+ report.version = entry.hazeVersion;
17
+ }
18
+ else if (entry.type === 'compact') {
19
+ report.compactions++;
20
+ }
21
+ else if (entry.type === 'goal') {
22
+ let goal = goals.get(entry.goalId);
23
+ if (!goal) {
24
+ goal = { id: entry.goalId, intent: entry.intent, cycles: 0, status: 'active', validation: 'not_applicable', openTasks: 0, mutations: 0, openCheckCount: 0 };
25
+ goals.set(entry.goalId, goal);
26
+ report.goals.push(goal);
27
+ }
28
+ goal.cycles = Math.max(goal.cycles, entry.cycle);
29
+ goal.validation = entry.validationOutcome;
30
+ goal.mutations = entry.mutationCount;
31
+ goal.openTasks = (entry.taskCounts?.pending ?? 0) + (entry.taskCounts?.inProgress ?? 0);
32
+ goal.openCheckCount = entry.failedCheckIds?.length ?? 0;
33
+ if (entry.phase === 'goal_end') {
34
+ goal.status = entry.status ?? 'unknown';
35
+ goal.stopReason = entry.stopReason;
36
+ goal.gateDecision = entry.gateDecision;
37
+ }
38
+ else {
39
+ goal.status = 'active';
40
+ delete goal.stopReason;
41
+ delete goal.gateDecision;
42
+ finalEvidence.delete(entry.goalId);
43
+ }
44
+ }
45
+ else if (entry.type === 'event' && entry.text) {
46
+ let event;
47
+ try {
48
+ event = record(JSON.parse(entry.text));
49
+ }
50
+ catch {
51
+ continue;
52
+ }
53
+ if (!event)
54
+ continue;
55
+ if (entry.name === 'step_end') {
56
+ report.steps++;
57
+ if (typeof event.responseModel === 'string') {
58
+ report.model = event.responseModel;
59
+ if (!report.models.includes(event.responseModel))
60
+ report.models.push(event.responseModel);
61
+ }
62
+ const usage = record(event.usage);
63
+ if (typeof usage?.inputTokens === 'number')
64
+ report.peakInputTokens = Math.max(report.peakInputTokens, usage.inputTokens);
65
+ }
66
+ else if (entry.name === 'tool_end') {
67
+ const name = typeof event.name === 'string' ? event.name : 'unknown';
68
+ report.toolCalls[name] = (report.toolCalls[name] ?? 0) + 1;
69
+ if (event.success === false)
70
+ report.failedToolCalls++;
71
+ const summary = record(event.validation) ?? record(record(event.output)?.validationSummary);
72
+ if (summary?.status === 'failed') {
73
+ const kind = typeof summary.kind === 'string' ? summary.kind : 'generic';
74
+ report.failedValidations[kind] = (report.failedValidations[kind] ?? 0) + 1;
75
+ }
76
+ }
77
+ else if (entry.name === 'goal_continue') {
78
+ report.continuations++;
79
+ }
80
+ else if (entry.name === 'turn_end' && record(event.evidence)?.budgetBoundary === true) {
81
+ report.budgetBoundaries++;
82
+ }
83
+ else if (entry.name === 'goal_end' && typeof event.goalId === 'string') {
84
+ const evidence = record(event.evidence);
85
+ if (evidence)
86
+ finalEvidence.set(event.goalId, evidence);
87
+ }
88
+ else if (entry.name === 'reasoning_policy' && typeof event.effective === 'string') {
89
+ report.reasoning = event.effective;
90
+ }
91
+ else if (entry.name === 'context_budget' && typeof event.contextWindowTokens === 'number') {
92
+ report.contextWindowTokens = event.contextWindowTokens;
93
+ }
94
+ else if (!hasCompactEntries && entry.name === 'compaction_end' && event.compacted === true) {
95
+ report.compactions++;
96
+ }
97
+ }
98
+ }
99
+ for (const goal of report.goals) {
100
+ const evidence = finalEvidence.get(goal.id);
101
+ if (!evidence || goal.status === 'active')
102
+ continue;
103
+ const tasks = record(evidence.taskProgress);
104
+ const eventOpenTasks = (typeof tasks?.pending === 'number' ? tasks.pending : 0) + (typeof tasks?.inProgress === 'number' ? tasks.inProgress : 0);
105
+ if (evidence.validationOutcome !== goal.validation || evidence.mutationCount !== goal.mutations || eventOpenTasks !== goal.openTasks)
106
+ goal.evidenceMismatch = true;
107
+ }
108
+ return report;
109
+ }
110
+ export function formatSessionReport(report, parseErrors = 0) {
111
+ const toolLines = Object.entries(report.toolCalls).sort((a, b) => b[1] - a[1]).map(([name, count]) => ` ${name}: ${count}`);
112
+ const goalLines = report.goals.map(goal => ` ${goal.id}: ${goal.status}${goal.stopReason ? ` (${goal.stopReason})` : ''} · ${goal.intent} · ${goal.cycles} cycle(s) · gate ${goal.gateDecision ?? 'unknown'} · validation ${goal.validation} · ${goal.openTasks} open task(s) · ${goal.openCheckCount} open check(s)${goal.evidenceMismatch ? ' · terminal evidence mismatch' : ''}`);
113
+ return [
114
+ `Session ${report.sessionId ?? 'unknown'}${report.version ? ` · Haze ${report.version}` : ''}`,
115
+ `Models: ${report.models.join(' → ') || report.model || 'unknown'}${report.reasoning ? ` · reasoning ${report.reasoning}` : ''}${report.contextWindowTokens ? ` · context ${report.contextWindowTokens}` : ''}`,
116
+ `Steps: ${report.steps} · peak input: ${report.peakInputTokens} tokens · continuations: ${report.continuations} · budget boundaries: ${report.budgetBoundaries} · compactions: ${report.compactions}`,
117
+ `Tool failures: ${report.failedToolCalls} · failed validations: ${Object.entries(report.failedValidations).map(([kind, count]) => `${kind} ${count}`).join(', ') || '0'}`,
118
+ ...(parseErrors ? [`Parse errors: ${parseErrors}`] : []),
119
+ 'Goals:', ...goalLines, 'Tool calls:', ...toolLines,
120
+ ].join('\n');
121
+ }
@@ -1,2 +1,4 @@
1
+ import type { ModelMessage } from 'ai';
1
2
  import type { SessionEntry } from './sessionStore.js';
3
+ export declare function repairRestoredConversation(messages: ModelMessage[]): ModelMessage[];
2
4
  export declare function prepareSessionEntryForWrite(entry: SessionEntry): SessionEntry | undefined;
@@ -37,6 +37,21 @@ function slimImageFilePart(part) {
37
37
  text: `[image omitted from session:${name} ${part.mediaType}, ${formatBytes(bytes)} — ask the user to re-attach it if needed]`,
38
38
  };
39
39
  }
40
+ function isRecord(value) {
41
+ return typeof value === 'object' && value != null && !Array.isArray(value);
42
+ }
43
+ /**
44
+ * Slim a tool-result output while preserving the AI SDK output envelope.
45
+ * Restored snapshots are re-sent to providers, and `modelMessageSchema` requires
46
+ * a tool-result output to be `{type: 'json'|'text'|... , value}`; a bare slim
47
+ * marker as the output made every resumed session fail with
48
+ * AI_InvalidPromptError (F-09 regression).
49
+ */
50
+ function slimToolResultOutput(output) {
51
+ if (!isRecord(output) || typeof output.type !== 'string' || !('value' in output))
52
+ return slimLargeValue(output);
53
+ return { ...output, value: slimLargeValue(output.value) };
54
+ }
40
55
  function slimUnknown(value, seen = new WeakSet()) {
41
56
  if (typeof value === 'string') {
42
57
  if (value.length <= LARGE_STRING_CHARS)
@@ -56,7 +71,7 @@ function slimUnknown(value, seen = new WeakSet()) {
56
71
  if (record.type === 'tool-result') {
57
72
  return {
58
73
  ...record,
59
- output: slimLargeValue(record.output),
74
+ output: slimToolResultOutput(record.output),
60
75
  result: slimLargeValue(record.result),
61
76
  };
62
77
  }
@@ -65,6 +80,40 @@ function slimUnknown(value, seen = new WeakSet()) {
65
80
  next[key] = slimUnknown(child, seen);
66
81
  return next;
67
82
  }
83
+ /**
84
+ * Restore-side repair (F-09): sessions written before the envelope fix store
85
+ * bare `{omitted, reason, originalBytes, preview}` slim markers as tool-result
86
+ * outputs. Re-sending those to a provider fails `modelMessageSchema`, so wrap
87
+ * each legacy marker back into the required `{type, value}` envelope. Already
88
+ * valid outputs pass through untouched.
89
+ */
90
+ function repairLegacySlimmedMessages(messages) {
91
+ let changed = false;
92
+ const repaired = messages.map(message => {
93
+ if (message.role !== 'tool' || !Array.isArray(message.content))
94
+ return message;
95
+ let messageChanged = false;
96
+ const content = message.content.map(part => {
97
+ if (!isRecord(part) || part.type !== 'tool-result')
98
+ return part;
99
+ if (!isLegacySlimMarker(part.output))
100
+ return part;
101
+ messageChanged = true;
102
+ return { ...part, output: { type: 'json', value: part.output } };
103
+ });
104
+ if (!messageChanged)
105
+ return message;
106
+ changed = true;
107
+ return { ...message, content: content };
108
+ });
109
+ return changed ? repaired : messages;
110
+ }
111
+ function isLegacySlimMarker(value) {
112
+ return isRecord(value) && value.omitted === true && value.reason === 'session_size_limit' && !('type' in value);
113
+ }
114
+ export function repairRestoredConversation(messages) {
115
+ return repairLegacySlimmedMessages(messages);
116
+ }
68
117
  function slimConversationSnapshot(messages) {
69
118
  return slimUnknown(messages);
70
119
  }
@@ -96,11 +145,17 @@ export function prepareSessionEntryForWrite(entry) {
96
145
  if (entry.name === 'tool_end' && entry.text) {
97
146
  try {
98
147
  const event = JSON.parse(entry.text);
148
+ const output = isRecord(event.output) ? event.output : undefined;
149
+ const validation = isRecord(output?.validationSummary) ? output.validationSummary : undefined;
150
+ // Keep the outcome even when the output body is replaced by a preview.
151
+ // The report needs only these enums, never command text or diagnostics.
152
+ if (validation && typeof validation.kind === 'string' && (validation.status === 'passed' || validation.status === 'failed')) {
153
+ event.validation = { kind: validation.kind, status: validation.status };
154
+ }
99
155
  if (event.name === 'subagent' && typeof event.output === 'object' && event.output != null) {
100
- const output = event.output;
101
- const telemetry = typeof output.telemetry === 'object' && output.telemetry != null ? output.telemetry : undefined;
156
+ const telemetry = typeof output?.telemetry === 'object' && output.telemetry != null ? output.telemetry : undefined;
102
157
  event.output = {
103
- capsule: output.capsule,
158
+ capsule: output?.capsule,
104
159
  coordinator: telemetry ? { modelSelector: telemetry.modelSelector, profile: telemetry.profile, durationMs: telemetry.durationMs, queueMs: telemetry.queueMs, toolCallCount: telemetry.toolCallCount } : undefined,
105
160
  };
106
161
  }
@@ -1,5 +1,10 @@
1
1
  import type { ModelMessage } from 'ai';
2
2
  import type { WorkState } from '../agent/workState.js';
3
+ import type { ValidationKind } from '../../llm/toolResultTypes.js';
4
+ export interface SessionModelSelection {
5
+ provider: string;
6
+ model: string;
7
+ }
3
8
  export type SessionEntry = {
4
9
  type: 'header';
5
10
  id: string;
@@ -24,6 +29,10 @@ export type SessionEntry = {
24
29
  type: 'work_state_snapshot';
25
30
  at: string;
26
31
  state: WorkState;
32
+ } | {
33
+ type: 'model_selection';
34
+ at: string;
35
+ selection: SessionModelSelection;
27
36
  } | {
28
37
  type: 'event';
29
38
  at: string;
@@ -62,8 +71,11 @@ export type SessionEntry = {
62
71
  commandKey: string;
63
72
  summary: string;
64
73
  };
74
+ validationKind?: ValidationKind;
75
+ failedCheckIds?: string[];
65
76
  stopReason?: string;
66
77
  status?: string;
78
+ gateDecision?: string;
67
79
  };
68
80
  /** Durable goal-ledger entry (P1): one append per supervisor boundary. */
69
81
  export type GoalLedgerEntry = Extract<SessionEntry, {
@@ -82,6 +94,9 @@ export interface GoalLedgerFrontier {
82
94
  taskCounts?: GoalLedgerEntry['taskCounts'];
83
95
  /** Unresolved red evidence carried so crash resume preserves the pending same-check green requirement. */
84
96
  redEvidence?: GoalLedgerEntry['redEvidence'];
97
+ /** Kind of the frontier's carried validation, when one rode the ledger (R2-03). */
98
+ validationKind?: ValidationKind;
99
+ failedCheckIds?: string[];
85
100
  at: string;
86
101
  }
87
102
  type SessionHeader = Extract<SessionEntry, {
@@ -142,14 +157,6 @@ export interface ReadSessionEntriesResult {
142
157
  * loss in debug mode instead of silently dropping messages.
143
158
  */
144
159
  export declare function readSessionEntries(session: HazeSession): Promise<ReadSessionEntriesResult>;
145
- /**
146
- * Pure frontier detection over parsed session entries (P1): the append-only
147
- * goal ledger's frontier is the last entry of the most recent goal id that has
148
- * no `goal_end` entry. A truncated or malformed tail line parses as absent, so
149
- * a crash mid-write can never resurrect a half-written boundary
150
- * (autoprompt's "treat half-written artifacts as absent").
151
- */
152
- export declare function findGoalLedgerFrontier(entries: readonly SessionEntry[]): GoalLedgerFrontier | undefined;
153
160
  /** Read the goal-ledger frontier of a stored session (one file scan). */
154
161
  export declare function readGoalLedgerFrontier(session: HazeSession): Promise<GoalLedgerFrontier | undefined>;
155
162
  export interface RestoreConversationResult {
@@ -158,6 +165,7 @@ export interface RestoreConversationResult {
158
165
  }
159
166
  export interface RestoreSessionStateResult {
160
167
  messages: ModelMessage[];
168
+ modelSelection?: SessionModelSelection;
161
169
  workState: WorkState | undefined;
162
170
  parseErrors: string[];
163
171
  /** Unterminated goal frontier from the durable ledger, if any (P1 resume path). */
@@ -2,7 +2,7 @@ import crypto from 'node:crypto';
2
2
  import path from 'node:path';
3
3
  import fs from 'fs-extra';
4
4
  import { HAZE_DIR } from '../../config/paths.js';
5
- import { prepareSessionEntryForWrite } from './sessionSlimming.js';
5
+ import { prepareSessionEntryForWrite, repairRestoredConversation } from './sessionSlimming.js';
6
6
  import { appendPrivateFile, ensurePrivateDir, tightenPrivateFile, writePrivateFileAtomic } from '../../config/privateStorage.js';
7
7
  import { JSONL_LINE_BYTES } from '../limits.js';
8
8
  import { iterateBoundedUtf8Lines } from '../io/boundedRead.js';
@@ -113,7 +113,7 @@ export async function appendSessionEntry(session, entry) {
113
113
  * type, so dropping superseded ones is lossless for restore; summaries keep
114
114
  * their ui_message/event history). Atomic replace, never partial.
115
115
  */
116
- export const SESSION_VACUUM_THRESHOLD_BYTES = 16 * 1024 * 1024;
116
+ export const SESSION_VACUUM_THRESHOLD_BYTES = 5 * 1024 * 1024;
117
117
  let effectiveVacuumThresholdBytes = SESSION_VACUUM_THRESHOLD_BYTES;
118
118
  /** Test-only override for the vacuum trigger; tests restore the original. */
119
119
  export function setSessionVacuumThresholdForTests(bytes) {
@@ -143,7 +143,10 @@ export async function vacuumSessionFileIfLarge(session, thresholdBytes = effecti
143
143
  // turn; intermediate `goal_continue` entries of superseded cycles are audit
144
144
  // trail only. Keep the trailing few per goal id — the frontier and the
145
145
  // terminal entry are always among them — so a very long-lived session file
146
- // stays bounded without ever losing a live frontier.
146
+ // stays bounded without ever losing a live frontier. The keep decision and
147
+ // `keepGoal` must both use original `entries` indexes (R2-01): filtering a
148
+ // candidate array first would shift positions whenever snapshots precede or
149
+ // interleave goal entries, silently dropping the live frontier.
147
150
  const keepGoal = new Set();
148
151
  const goalIndexesByGoal = new Map();
149
152
  entries.forEach((entry, index) => {
@@ -157,11 +160,11 @@ export async function vacuumSessionFileIfLarge(session, thresholdBytes = effecti
157
160
  // Malformed lines are dropped by the rewrite: they were already unusable
158
161
  // (and reported as parse errors on read) and keeping them would defeat the
159
162
  // size bound the vacuum exists to enforce.
160
- const candidate = entries.filter((entry, index) => (entry.type !== 'conversation_snapshot' && entry.type !== 'work_state_snapshot')
163
+ const kept = entries.filter((entry, index) => ((entry.type !== 'conversation_snapshot' && entry.type !== 'work_state_snapshot')
161
164
  || index === lastConversation
162
- || index === lastWorkState);
163
- const kept = candidate.filter((entry, index) => entry.type !== 'goal' || keepGoal.has(index));
164
- const droppedGoalBytes = candidate
165
+ || index === lastWorkState)
166
+ && (entry.type !== 'goal' || keepGoal.has(index)));
167
+ const droppedGoalBytes = entries
165
168
  .filter((entry, index) => entry.type === 'goal' && !keepGoal.has(index))
166
169
  .reduce((sum, entry) => sum + Buffer.byteLength(JSON.stringify(entry), 'utf8'), 0);
167
170
  const serialized = kept.map(entry => JSON.stringify(entry)).join('\n') + '\n';
@@ -198,6 +201,13 @@ function optionalTaskCounts(value) {
198
201
  function optionalLedgerRedEvidence(value) {
199
202
  return value === undefined || parseLedgerRedEvidence(value) !== undefined;
200
203
  }
204
+ const LEDGER_VALIDATION_KINDS = new Set(['test', 'typecheck', 'lint', 'build', 'generic']);
205
+ function optionalLedgerValidationKind(value) {
206
+ return value === undefined || (typeof value === 'string' && LEDGER_VALIDATION_KINDS.has(value));
207
+ }
208
+ function optionalFailedCheckIds(value) {
209
+ return value === undefined || (Array.isArray(value) && value.every(id => typeof id === 'string' && /^[0-9a-f]{16}$/.test(id)));
210
+ }
201
211
  function frontierFromGoalEntry(entry) {
202
212
  return {
203
213
  goalId: entry.goalId,
@@ -210,6 +220,8 @@ function frontierFromGoalEntry(entry) {
210
220
  progressSignature: entry.progressSignature,
211
221
  ...(entry.taskCounts ? { taskCounts: entry.taskCounts } : {}),
212
222
  ...(entry.redEvidence ? { redEvidence: entry.redEvidence } : {}),
223
+ ...(entry.validationKind ? { validationKind: entry.validationKind } : {}),
224
+ ...(entry.failedCheckIds?.length ? { failedCheckIds: [...entry.failedCheckIds] } : {}),
213
225
  at: entry.at,
214
226
  };
215
227
  }
@@ -242,6 +254,12 @@ function parseSessionEntry(value) {
242
254
  && MODEL_MESSAGE_ROLES.has(message.role)))
243
255
  return invalid('conversation_snapshot contains an invalid message role');
244
256
  return value;
257
+ case 'model_selection':
258
+ if (typeof value.at !== 'string' || !isRecord(value.selection)
259
+ || typeof value.selection.provider !== 'string' || !value.selection.provider.trim()
260
+ || typeof value.selection.model !== 'string' || !value.selection.model.trim())
261
+ return invalid('invalid model_selection');
262
+ return value;
245
263
  case 'work_state_snapshot':
246
264
  if (typeof value.at !== 'string' || !isRecord(value.state))
247
265
  return invalid('work_state_snapshot state must be an object');
@@ -263,8 +281,10 @@ function parseSessionEntry(value) {
263
281
  || typeof value.cycle !== 'number' || typeof value.mutationCount !== 'number'
264
282
  || typeof value.validationOutcome !== 'string' || typeof value.progressSignature !== 'string'
265
283
  || !optionalTaskCounts(value.taskCounts)
266
- || !optionalString(value.stopReason) || !optionalString(value.status)
267
- || !optionalLedgerRedEvidence(value.redEvidence))
284
+ || !optionalString(value.stopReason) || !optionalString(value.status) || !optionalString(value.gateDecision)
285
+ || !optionalLedgerRedEvidence(value.redEvidence)
286
+ || !optionalLedgerValidationKind(value.validationKind)
287
+ || !optionalFailedCheckIds(value.failedCheckIds))
268
288
  return invalid('invalid goal');
269
289
  return value;
270
290
  default:
@@ -321,19 +341,34 @@ export async function readSessionEntries(session) {
321
341
  * a crash mid-write can never resurrect a half-written boundary
322
342
  * (autoprompt's "treat half-written artifacts as absent").
323
343
  */
324
- export function findGoalLedgerFrontier(entries) {
325
- let frontier;
326
- for (const entry of entries) {
344
+ /**
345
+ * Ordered frontier state shared by list-based lookup and streaming restore
346
+ * (SU-01): a later start/continue of the same goal id REOPENS it, because an
347
+ * explicit resume reuses the goalId after an orderly pause (`goal_end`). Only
348
+ * the newest goal id can hold the frontier; a terminal end closes exactly that
349
+ * goal. Both consumers must return identical results for any entry sequence.
350
+ */
351
+ class GoalLedgerFrontierTracker {
352
+ frontier;
353
+ observe(entry) {
327
354
  if (entry.type !== 'goal')
328
- continue;
355
+ return;
329
356
  if (entry.phase === 'goal_end') {
330
- if (frontier?.goalId === entry.goalId)
331
- frontier = undefined;
332
- continue;
357
+ if (this.frontier?.goalId === entry.goalId)
358
+ this.frontier = undefined;
359
+ return;
333
360
  }
334
- frontier = frontierFromGoalEntry(entry);
361
+ this.frontier = frontierFromGoalEntry(entry);
362
+ }
363
+ result() {
364
+ return this.frontier;
335
365
  }
336
- return frontier;
366
+ }
367
+ function findGoalLedgerFrontier(entries) {
368
+ const tracker = new GoalLedgerFrontierTracker();
369
+ for (const entry of entries)
370
+ tracker.observe(entry);
371
+ return tracker.result();
337
372
  }
338
373
  /** Read the goal-ledger frontier of a stored session (one file scan). */
339
374
  export async function readGoalLedgerFrontier(session) {
@@ -348,27 +383,27 @@ export async function readGoalLedgerFrontier(session) {
348
383
  export async function restoreSessionState(session) {
349
384
  let messages = [];
350
385
  let workState;
351
- let goalFrontier;
352
- const terminatedGoals = new Set();
386
+ let modelSelection;
387
+ const tracker = new GoalLedgerFrontierTracker();
353
388
  const parseErrors = await scanSessionEntries(session, entry => {
389
+ // Legacy slim markers (pre-envelope-fix) are re-wrapped so the restored
390
+ // conversation is a protocol-safe ModelMessage[] for the next provider
391
+ // request (F-09).
354
392
  if (entry.type === 'conversation_snapshot')
355
- messages = entry.messages;
393
+ messages = repairRestoredConversation(entry.messages);
394
+ // SU-02: a durable clear marker means "no conversation after this line";
395
+ // later snapshots (if any) re-materialize it, otherwise restore yields [].
396
+ if (entry.type === 'event' && entry.name === 'clear') {
397
+ messages = [];
398
+ workState = undefined;
399
+ }
400
+ if (entry.type === 'model_selection')
401
+ modelSelection = entry.selection;
356
402
  if (entry.type === 'work_state_snapshot')
357
403
  workState = entry.state;
358
- if (entry.type === 'goal') {
359
- if (entry.phase === 'goal_end') {
360
- terminatedGoals.add(entry.goalId);
361
- if (goalFrontier?.goalId === entry.goalId)
362
- goalFrontier = undefined;
363
- }
364
- else {
365
- goalFrontier = frontierFromGoalEntry(entry);
366
- }
367
- }
404
+ tracker.observe(entry);
368
405
  });
369
- if (goalFrontier && terminatedGoals.has(goalFrontier.goalId))
370
- goalFrontier = undefined;
371
- return { messages, workState, parseErrors, goalFrontier };
406
+ return { messages, workState, parseErrors, goalFrontier: tracker.result(), ...(modelSelection ? { modelSelection } : {}) };
372
407
  }
373
408
  export async function restoreConversation(session) {
374
409
  const { messages, parseErrors } = await restoreSessionState(session);
@@ -481,6 +516,8 @@ export async function forkSession(source, options = {}) {
481
516
  throw new Error(`Session ${source.id} has no conversation snapshot to fork.`);
482
517
  const session = await createSession({ cwd: source.cwd, sessionsDir: options.sessionsDir, hazeVersion: options.hazeVersion, forkedFrom: source.id, ...(options.build ? { build: options.build } : {}) });
483
518
  const at = new Date().toISOString();
519
+ if (restored.modelSelection)
520
+ await appendSessionEntry(session, { type: 'model_selection', at, selection: restored.modelSelection });
484
521
  await appendSessionEntry(session, { type: 'conversation_snapshot', at, messages: restored.messages });
485
522
  if (restored.workState)
486
523
  await appendSessionEntry(session, { type: 'work_state_snapshot', at, state: restored.workState });
@@ -1,9 +1,10 @@
1
1
  import { commandCandidates } from '../command.js';
2
+ import { isSingleForegroundCommand } from '../../safety/shellClassifier.js';
2
3
  function gitSubcommand(command) {
3
4
  for (const candidate of commandCandidates(command)) {
4
5
  const words = candidate.toLowerCase().split(/\s+/).filter(Boolean);
5
6
  const gitIndex = words.indexOf('git');
6
- if (gitIndex === -1)
7
+ if (gitIndex !== 0)
7
8
  continue;
8
9
  for (let index = gitIndex + 1; index < words.length; index++) {
9
10
  const word = words[index] ?? '';
@@ -19,7 +20,9 @@ function gitSubcommand(command) {
19
20
  return undefined;
20
21
  }
21
22
  export function reduceGitOutput(command, stdout, stderr) {
22
- const text = stdout || stderr;
23
+ if (!isSingleForegroundCommand(command) || stderr.trim())
24
+ return undefined;
25
+ const text = stdout;
23
26
  const subcommand = gitSubcommand(command);
24
27
  if (subcommand === 'status')
25
28
  return reduceGitStatus(text);
@@ -66,6 +69,8 @@ function reduceGitStatus(text) {
66
69
  items.push(inUntracked && !/^\w+:/.test(item) ? `?? ${item}` : item);
67
70
  }
68
71
  }
72
+ if (!branch && items.length === 0)
73
+ return undefined;
69
74
  const untracked = items.filter(line => line.startsWith('?? ')).length;
70
75
  const changed = items.length - untracked;
71
76
  const shown = items.slice(0, 30);
@@ -1,2 +1,2 @@
1
1
  import type { ValidationSummary } from '../../../llm/toolResultTypes.js';
2
- export declare function renderValidationReduction(summary: ValidationSummary, rawHandle?: string): string;
2
+ export declare function renderValidationReduction(summary: ValidationSummary, rawHandle?: string, raw?: string): string;
@@ -6,7 +6,17 @@ function groupDiagnostics(summary) {
6
6
  }
7
7
  return grouped;
8
8
  }
9
- export function renderValidationReduction(summary, rawHandle) {
9
+ /** Inline cap for small raw output kept alongside the summary (RT-04). */
10
+ const INLINE_RAW_CHARS = 800;
11
+ const INLINE_RAW_LINES = 12;
12
+ /** Small failing-command output is the diagnostic itself (RT-04): keep it inline so a readToolOutput round-trip (a full model step) is saved. */
13
+ function inlineRawLines(raw) {
14
+ if (raw.length === 0 || raw.length > INLINE_RAW_CHARS)
15
+ return [];
16
+ const lines = raw.split(/\r?\n/).map(line => line.trimEnd()).filter(Boolean);
17
+ return lines.length === 0 || lines.length > INLINE_RAW_LINES ? [] : lines;
18
+ }
19
+ export function renderValidationReduction(summary, rawHandle, raw = '') {
10
20
  const lines = [summary.summaryText];
11
21
  if (summary.failedTests.length) {
12
22
  lines.push('', 'failed tests:');
@@ -35,6 +45,9 @@ export function renderValidationReduction(summary, rawHandle) {
35
45
  }
36
46
  if (summary.suggestedNextStep)
37
47
  lines.push('', `next: ${summary.suggestedNextStep}`);
48
+ const inline = inlineRawLines(raw);
49
+ if (inline.length)
50
+ lines.push('', ...inline);
38
51
  if (rawHandle)
39
52
  lines.push('', `raw output: use readToolOutput with handle ${rawHandle}`);
40
53
  return lines.join('\n');
@@ -1,3 +1,4 @@
1
+ import { isSingleForegroundCommand } from '../safety/shellClassifier.js';
1
2
  import { applyLineFilter, findLineFilter } from './lineFilter.js';
2
3
  import { renderValidationReduction } from './reducers/validation.js';
3
4
  import { reduceGitOutput } from './reducers/git.js';
@@ -70,10 +71,10 @@ export function filterShellOutput(input) {
70
71
  filterName = `validation-${input.validationSummary.kind}`;
71
72
  const raw = `${input.stdout}${input.stderr ? `\n${input.stderr}` : ''}`;
72
73
  const rawHandle = input.storeRawOutput?.(raw);
73
- stdout = makeReduction(input.stdout, renderValidationReduction(input.validationSummary, rawHandle), true, filterName, input, undefined, 'validation');
74
+ stdout = makeReduction(input.stdout, renderValidationReduction(input.validationSummary, rawHandle, raw), true, filterName, input, undefined, 'validation');
74
75
  stderr = makeReduction(input.stderr, '', input.stderr.length > 0, filterName, input, undefined, 'validation');
75
76
  }
76
- else {
77
+ else if (isSingleForegroundCommand(input.command)) {
77
78
  const stdoutIn = capOutputForProcessing(input.stdout);
78
79
  const stderrIn = capOutputForProcessing(input.stderr);
79
80
  const git = reduceGitOutput(input.command, stdoutIn, stderrIn);
@@ -1,5 +1,7 @@
1
- import type { JSONValue, LanguageModel } from 'ai';
1
+ import type { LanguageModel } from 'ai';
2
2
  import { z } from 'zod';
3
+ import type { ProviderCapabilities, ProviderRequestOptions } from '../providerContracts.js';
4
+ export type { ProviderCapabilities, ProviderRequestOptions } from '../providerContracts.js';
3
5
  declare const workerModes: readonly ["inspect", "research", "implement", "validate"];
4
6
  export type WorkerMode = typeof workerModes[number];
5
7
  export declare const subagentInputSchema: z.ZodObject<{
@@ -76,22 +78,6 @@ export interface SubagentExecutionResult {
76
78
  durationMs: number;
77
79
  error?: string;
78
80
  }
79
- export interface ProviderCapabilities {
80
- reportsCacheUsage: boolean;
81
- supportsPromptCacheKey: boolean;
82
- supportsExtendedCacheRetention: boolean;
83
- supportsStickySessionId: boolean;
84
- supportsServerCompaction: boolean;
85
- supportsTextVerbosity: boolean;
86
- /** Protocol accepts an OpenAI-style reasoning-effort provider option. */
87
- supportsReasoningEffort: boolean;
88
- }
89
- export interface ProviderRequestOptions {
90
- providerOptions?: Record<string, Record<string, JSONValue | undefined>>;
91
- headers?: Record<string, string>;
92
- /** Codex subscription requests let the provider manage the output limit. */
93
- omitMaxOutputTokens?: boolean;
94
- }
95
81
  export interface WorkerRuntime {
96
82
  model: LanguageModel;
97
83
  selector: string;
@@ -105,4 +91,3 @@ export declare function fallbackProviderCapabilities(): ProviderCapabilities;
105
91
  export declare function fallbackWorkerRuntime(model: WorkerRuntime['model'], selector?: string, providerName?: string): WorkerRuntime;
106
92
  export declare function normalizeSubagentInput(input: SubagentToolInput, id: string): SubagentTaskCapsule;
107
93
  export declare function withLegacyProjection(capsule: SubagentResultCapsule, telemetry: SubagentTelemetry, error?: string): SubagentExecutionResult;
108
- export {};
@@ -17,10 +17,10 @@ export const COMPATIBILITY_PROFILE = {
17
17
  deadlineMs: SUBAGENT_DEFAULT_DEADLINE_MS, maxRetries: 2,
18
18
  };
19
19
  export const BUILT_IN_SUBAGENT_PROFILES = {
20
- 'local-safe': { ...COMPATIBILITY_PROFILE, name: 'local-safe', maxConcurrency: 1, maxSteps: 16, maxToolCalls: 12, maxOutputTokens: 2_048, maxInputTokens: 20_000, maxRetries: 0 },
21
- 'local-throughput': { ...COMPATIBILITY_PROFILE, name: 'local-throughput', maxConcurrency: 2, maxSteps: 20, maxToolCalls: 16, maxOutputTokens: 3_072, maxInputTokens: 24_000, maxRetries: 0 },
22
- 'cloud-balanced': { ...COMPATIBILITY_PROFILE, name: 'cloud-balanced', maxConcurrency: 3, deadlineMs: 180_000 },
23
- 'cloud-fast': { ...COMPATIBILITY_PROFILE, name: 'cloud-fast', maxConcurrency: 5, deadlineMs: 120_000, maxRetries: 1 },
20
+ 'local-safe': { ...COMPATIBILITY_PROFILE, name: 'local-safe', maxConcurrency: 1, maxSteps: 32, maxToolCalls: 24, maxOutputTokens: 4_096, maxInputTokens: 40_000, maxRetries: 0 },
21
+ 'local-throughput': { ...COMPATIBILITY_PROFILE, name: 'local-throughput', maxConcurrency: 2, maxSteps: 40, maxToolCalls: 32, maxOutputTokens: 6_144, maxInputTokens: 48_000, maxRetries: 0 },
22
+ 'cloud-balanced': { ...COMPATIBILITY_PROFILE, name: 'cloud-balanced', maxConcurrency: 3, deadlineMs: 360_000 },
23
+ 'cloud-fast': { ...COMPATIBILITY_PROFILE, name: 'cloud-fast', maxConcurrency: 5, deadlineMs: 240_000, maxRetries: 1 },
24
24
  };
25
25
  export const MODE_TOOL_NAMES = {
26
26
  inspect: ['listFiles', 'readFile', 'grep', 'readToolOutput'],
@@ -3,6 +3,7 @@ import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { z } from 'zod';
5
5
  import { resolveWorkspacePath } from '../../utils/path.js';
6
+ import { assertRealPathInsideWorkspace, assertWritablePathInsideWorkspace } from '../../utils/path.js';
6
7
  const taskSchema = z.object({
7
8
  id: z.string(),
8
9
  title: z.string(),
@@ -23,7 +24,11 @@ export function generateTaskId() {
23
24
  }
24
25
  export async function loadTasks() {
25
26
  try {
26
- const content = await fs.readFile(getTasksFilePath(), 'utf-8');
27
+ const filePath = getTasksFilePath();
28
+ // CI-05: real-path confinement — a symlinked `.haze`/`tasks.json` must not
29
+ // redirect task state outside the workspace. Refusal is nonfatal (CR-012).
30
+ await assertRealPathInsideWorkspace(filePath, filePath);
31
+ const content = await fs.readFile(filePath, 'utf-8');
27
32
  return tasksSchema.parse(JSON.parse(content));
28
33
  }
29
34
  catch {
@@ -32,6 +37,8 @@ export async function loadTasks() {
32
37
  }
33
38
  export async function saveTasks(tasks) {
34
39
  const filePath = getTasksFilePath();
40
+ // Mutation guards fail closed: an escaped real path throws instead of writing.
41
+ await assertWritablePathInsideWorkspace(filePath, filePath);
35
42
  await fs.mkdir(path.dirname(filePath), { recursive: true });
36
43
  await fs.writeFile(filePath, JSON.stringify(tasks, null, 2), 'utf-8');
37
44
  }