@denizokcu/haze 1.5.0 → 1.6.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 +23 -0
- package/README.md +74 -5
- package/SECURITY.md +1 -1
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/DynamicFrame.d.ts +0 -13
- package/dist/cli/chat/DynamicFrame.js +7 -2
- package/dist/cli/chat/inputSuggestions.js +2 -0
- package/dist/cli/chat/resizeGuard.d.ts +20 -0
- package/dist/cli/chat/resizeGuard.js +25 -0
- package/dist/cli/chat/terminalControl.d.ts +4 -2
- package/dist/cli/chat/terminalControl.js +16 -5
- package/dist/cli/chat/wizard/pluginHandlers.d.ts +10 -0
- package/dist/cli/chat/wizard/pluginHandlers.js +156 -0
- package/dist/cli/chat/wizard/skillsHandlers.js +2 -2
- package/dist/cli/chat/wizard/types.d.ts +20 -0
- package/dist/cli/chat/wizard/uiState.d.ts +25 -1
- package/dist/cli/chat/wizard/uiState.js +3 -1
- package/dist/cli/chat/wizardDispatch.js +6 -0
- package/dist/cli/commands/chat.js +27 -5
- package/dist/cli/commands/commandHelp.js +7 -2
- package/dist/cli/commands/commands.d.ts +5 -0
- package/dist/cli/commands/commands.js +17 -3
- package/dist/cli/commands/initCommand.js +3 -2
- package/dist/cli/commands/pluginCommand.d.ts +16 -0
- package/dist/cli/commands/pluginCommand.js +127 -0
- package/dist/cli/commands/reasoningCommand.d.ts +0 -15
- package/dist/cli/commands/reasoningCommand.js +1 -3
- package/dist/cli/commands/skillsWizard.js +4 -0
- package/dist/cli/commands/streaming/agentAttempt.js +2 -1
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +4 -3
- package/dist/cli/commands/streaming/attemptSetup.d.ts +2 -0
- package/dist/cli/commands/streaming/attemptSetup.js +3 -2
- package/dist/cli/commands/streaming/stallRecovery.d.ts +6 -0
- package/dist/cli/commands/streaming/stallRecovery.js +6 -5
- package/dist/cli/commands/streaming/turnRuntime.js +2 -4
- package/dist/cli/commands/wizardFlow.d.ts +59 -0
- package/dist/cli/commands/wizardFlow.js +40 -0
- package/dist/cli/contextReportCli.js +4 -3
- package/dist/cli/index.js +19 -2
- package/dist/config/contextFiles.js +3 -2
- package/dist/config/inputHistory.js +3 -3
- package/dist/config/paths.d.ts +1 -0
- package/dist/config/paths.js +1 -0
- package/dist/config/providerAuth.js +3 -3
- package/dist/config/settings.d.ts +14 -2
- package/dist/config/settings.js +8 -4
- package/dist/config/updateCheck.js +3 -3
- package/dist/core/agent/budgets.d.ts +17 -0
- package/dist/core/agent/budgets.js +19 -0
- package/dist/core/agent/reasoningPolicy.js +1 -1
- package/dist/core/agent/workState.d.ts +0 -2
- package/dist/core/agent/workState.js +1 -1
- package/dist/core/log/llmLog.js +1 -1
- package/dist/core/providerContracts.d.ts +6 -3
- package/dist/core/session/sessionStore.js +4 -3
- package/dist/core/subagent/contracts.d.ts +1 -11
- package/dist/core/subagent/contracts.js +0 -22
- package/dist/llm/client.js +28 -7
- package/dist/llm/subagentRunner.d.ts +1 -6
- package/dist/llm/subagentRunner.js +11 -23
- package/dist/llm/tools/fileTools.js +2 -3
- package/dist/llm/tools/gitIgnore.js +1 -1
- package/dist/llm/tools/grepRunner.d.ts +10 -0
- package/dist/llm/tools/grepRunner.js +24 -0
- package/dist/llm/tools/toolContext.d.ts +2 -3
- package/dist/llm/tools/toolContext.js +2 -3
- package/dist/llm/tools/toolContextState.d.ts +0 -1
- package/dist/llm/tools/toolContextState.js +1 -4
- package/dist/llm/workerContext.d.ts +0 -7
- package/dist/llm/workerContext.js +0 -17
- package/dist/skills/SkillLoader.js +3 -2
- package/dist/skills/SkillRegistry.js +7 -4
- package/dist/skills/builder/SkillBuilder.js +11 -10
- package/dist/skills/plugins/installer.d.ts +25 -0
- package/dist/skills/plugins/installer.js +272 -0
- package/dist/skills/plugins/package.d.ts +41 -0
- package/dist/skills/plugins/package.js +275 -0
- package/dist/skills/plugins/runtime.d.ts +3 -0
- package/dist/skills/plugins/runtime.js +108 -0
- package/dist/skills/skillTools.js +10 -5
- package/dist/skills/types.d.ts +4 -0
- package/dist/ui/codeHighlight.d.ts +1 -1
- package/dist/ui/codeHighlight.js +112 -4
- package/dist/ui/components/StreamingMarkdownText.d.ts +0 -2
- package/dist/ui/components/StreamingMarkdownText.js +1 -1
- package/dist/ui/components/TextInput.d.ts +1 -1
- package/dist/utils/fs.d.ts +10 -0
- package/dist/utils/fs.js +37 -2
- package/package.json +17 -20
|
@@ -56,6 +56,14 @@ export declare const MCP_TRANSPORTS: {
|
|
|
56
56
|
export declare const SKILL_CHOICES: {
|
|
57
57
|
readonly addSkill: "add skill";
|
|
58
58
|
};
|
|
59
|
+
export declare const PLUGIN_CHOICES: {
|
|
60
|
+
readonly installPlugin: "install plugin";
|
|
61
|
+
readonly inspectPlugin: "inspect plugin";
|
|
62
|
+
};
|
|
63
|
+
export declare const PLUGIN_ACTIONS: {
|
|
64
|
+
readonly showInfo: "show info";
|
|
65
|
+
readonly removePlugin: "remove plugin";
|
|
66
|
+
};
|
|
59
67
|
export declare const SKILL_ACTIONS: {
|
|
60
68
|
readonly showInfo: "show info";
|
|
61
69
|
readonly validate: "validate";
|
|
@@ -107,6 +115,17 @@ export declare function mcpTransportSuggestions(): TextInputSuggestion[];
|
|
|
107
115
|
export declare function skillsSuggestions(settings: HazeSettings, skills: LoadedSkill[]): TextInputSuggestion[];
|
|
108
116
|
export declare function skillScopeSuggestions(): TextInputSuggestion[];
|
|
109
117
|
export declare function skillsActionSuggestions(settings: HazeSettings, skills: LoadedSkill[], selectedSkillName: string | undefined): TextInputSuggestion[];
|
|
118
|
+
export interface PluginPickerPlugin {
|
|
119
|
+
name: string;
|
|
120
|
+
version?: string;
|
|
121
|
+
}
|
|
122
|
+
export interface PluginPickerEntry {
|
|
123
|
+
name: string;
|
|
124
|
+
description?: string;
|
|
125
|
+
}
|
|
126
|
+
export declare function pluginSuggestions(plugins: PluginPickerPlugin[]): TextInputSuggestion[];
|
|
127
|
+
export declare function pluginActionSuggestions(): TextInputSuggestion[];
|
|
128
|
+
export declare function pluginCollectionSuggestions(entries: PluginPickerEntry[]): TextInputSuggestion[];
|
|
110
129
|
/** Every built-in theme with its palette brightness and the active one marked (`resolveTheme` validates names). */
|
|
111
130
|
export declare function themeSuggestions(settings: HazeSettings): TextInputSuggestion[];
|
|
112
131
|
/** Reasoning-effort picker values: every level plus the unset/reset actions. The active marker resolves the session override → saved setting → default. */
|
|
@@ -125,6 +144,11 @@ export interface WizardSuggestionState {
|
|
|
125
144
|
selectedSkillName?: string;
|
|
126
145
|
selectedLspName?: string;
|
|
127
146
|
selectedMcpName?: string;
|
|
147
|
+
/** Installed project plugins (`/plugin` picker), loaded when the picker opens. */
|
|
148
|
+
plugins?: PluginPickerPlugin[];
|
|
149
|
+
selectedPluginName?: string;
|
|
150
|
+
/** Collection entries offered after pointing install/inspect at a collection. */
|
|
151
|
+
pluginCollectionEntries?: PluginPickerEntry[];
|
|
128
152
|
/** Session per-model reasoning overrides (`/reasoning`); shown as the active level in the picker. */
|
|
129
153
|
sessionReasoning?: Record<string, StoredReasoningSetting>;
|
|
130
154
|
}
|
|
@@ -334,6 +358,41 @@ export declare const WIZARD_STEPS: readonly [{
|
|
|
334
358
|
readonly kind: "confirm";
|
|
335
359
|
readonly placeholder: "Type \"yes\" to confirm";
|
|
336
360
|
readonly suggestions: () => never[];
|
|
361
|
+
}, {
|
|
362
|
+
readonly id: "plugins";
|
|
363
|
+
readonly kind: "pick";
|
|
364
|
+
readonly placeholder: "Choose install, inspect, or an installed plugin";
|
|
365
|
+
readonly suggestions: (s: WizardSuggestionState) => TextInputSuggestion[];
|
|
366
|
+
}, {
|
|
367
|
+
readonly id: "pluginAction";
|
|
368
|
+
readonly kind: "pick";
|
|
369
|
+
readonly placeholder: "show info or remove plugin";
|
|
370
|
+
readonly suggestions: () => TextInputSuggestion[];
|
|
371
|
+
}, {
|
|
372
|
+
readonly id: "pluginInstallSource";
|
|
373
|
+
readonly kind: "input";
|
|
374
|
+
readonly placeholder: "Local plugin directory (e.g. ../haze-kits)";
|
|
375
|
+
readonly suggestions: () => never[];
|
|
376
|
+
}, {
|
|
377
|
+
readonly id: "pluginInstallName";
|
|
378
|
+
readonly kind: "pick";
|
|
379
|
+
readonly placeholder: "Choose a plugin from the collection";
|
|
380
|
+
readonly suggestions: (s: WizardSuggestionState) => TextInputSuggestion[];
|
|
381
|
+
}, {
|
|
382
|
+
readonly id: "pluginInspectSource";
|
|
383
|
+
readonly kind: "input";
|
|
384
|
+
readonly placeholder: "Local plugin directory (e.g. ../haze-kits)";
|
|
385
|
+
readonly suggestions: () => never[];
|
|
386
|
+
}, {
|
|
387
|
+
readonly id: "pluginInspectName";
|
|
388
|
+
readonly kind: "pick";
|
|
389
|
+
readonly placeholder: "Choose a plugin from the collection";
|
|
390
|
+
readonly suggestions: (s: WizardSuggestionState) => TextInputSuggestion[];
|
|
391
|
+
}, {
|
|
392
|
+
readonly id: "pluginConfirmRemove";
|
|
393
|
+
readonly kind: "confirm";
|
|
394
|
+
readonly placeholder: "Type \"yes\" to confirm";
|
|
395
|
+
readonly suggestions: () => never[];
|
|
337
396
|
}, {
|
|
338
397
|
readonly id: "themes";
|
|
339
398
|
readonly kind: "pick";
|
|
@@ -61,6 +61,14 @@ export const MCP_TRANSPORTS = {
|
|
|
61
61
|
export const SKILL_CHOICES = {
|
|
62
62
|
addSkill: 'add skill',
|
|
63
63
|
};
|
|
64
|
+
export const PLUGIN_CHOICES = {
|
|
65
|
+
installPlugin: 'install plugin',
|
|
66
|
+
inspectPlugin: 'inspect plugin',
|
|
67
|
+
};
|
|
68
|
+
export const PLUGIN_ACTIONS = {
|
|
69
|
+
showInfo: 'show info',
|
|
70
|
+
removePlugin: 'remove plugin',
|
|
71
|
+
};
|
|
64
72
|
export const SKILL_ACTIONS = {
|
|
65
73
|
showInfo: 'show info',
|
|
66
74
|
validate: 'validate',
|
|
@@ -330,6 +338,30 @@ export function skillsActionSuggestions(settings, skills, selectedSkillName) {
|
|
|
330
338
|
result.push({ value: SKILL_ACTIONS.removeSkill, description: 'delete this skill directory', kind: 'skill' });
|
|
331
339
|
return result;
|
|
332
340
|
}
|
|
341
|
+
export function pluginSuggestions(plugins) {
|
|
342
|
+
return [
|
|
343
|
+
{ value: PLUGIN_CHOICES.installPlugin, description: 'install a local plugin package or collection', kind: 'plugin' },
|
|
344
|
+
{ value: PLUGIN_CHOICES.inspectPlugin, description: 'inspect a local plugin package or collection first', kind: 'plugin' },
|
|
345
|
+
...plugins.map(plugin => ({
|
|
346
|
+
value: plugin.name,
|
|
347
|
+
description: plugin.version ? `installed · ${plugin.version}` : 'installed',
|
|
348
|
+
kind: 'plugin',
|
|
349
|
+
})),
|
|
350
|
+
];
|
|
351
|
+
}
|
|
352
|
+
export function pluginActionSuggestions() {
|
|
353
|
+
return [
|
|
354
|
+
{ value: PLUGIN_ACTIONS.showInfo, description: 'show description, skills, and file count', kind: 'plugin' },
|
|
355
|
+
{ value: PLUGIN_ACTIONS.removePlugin, description: 'remove this plugin, preserving modified and seed files', kind: 'plugin' },
|
|
356
|
+
];
|
|
357
|
+
}
|
|
358
|
+
export function pluginCollectionSuggestions(entries) {
|
|
359
|
+
return entries.map(entry => ({
|
|
360
|
+
value: entry.name,
|
|
361
|
+
description: entry.description ?? 'collection plugin',
|
|
362
|
+
kind: 'plugin',
|
|
363
|
+
}));
|
|
364
|
+
}
|
|
333
365
|
/** Perceptual-luminance check on a `#rrggbb` background so the theme picker can label light vs dark palettes. */
|
|
334
366
|
function isLightBackground(hex) {
|
|
335
367
|
const channels = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex);
|
|
@@ -413,6 +445,14 @@ export const WIZARD_STEPS = [
|
|
|
413
445
|
{ id: 'mcpAddKey', kind: 'masked-input', placeholder: 'API key, or blank to skip', optional: true, suggestions: () => [] },
|
|
414
446
|
{ id: 'mcpSetKey', kind: 'masked-input', placeholder: 'API key', suggestions: () => [] },
|
|
415
447
|
{ id: 'mcpConfirmRemove', kind: 'confirm', placeholder: 'Type "yes" to confirm', suggestions: () => [] },
|
|
448
|
+
// Plugins
|
|
449
|
+
{ id: 'plugins', kind: 'pick', placeholder: 'Choose install, inspect, or an installed plugin', suggestions: (s) => pluginSuggestions(s.plugins ?? []) },
|
|
450
|
+
{ id: 'pluginAction', kind: 'pick', placeholder: 'show info or remove plugin', suggestions: () => pluginActionSuggestions() },
|
|
451
|
+
{ id: 'pluginInstallSource', kind: 'input', placeholder: 'Local plugin directory (e.g. ../haze-kits)', suggestions: () => [] },
|
|
452
|
+
{ id: 'pluginInstallName', kind: 'pick', placeholder: 'Choose a plugin from the collection', suggestions: (s) => pluginCollectionSuggestions(s.pluginCollectionEntries ?? []) },
|
|
453
|
+
{ id: 'pluginInspectSource', kind: 'input', placeholder: 'Local plugin directory (e.g. ../haze-kits)', suggestions: () => [] },
|
|
454
|
+
{ id: 'pluginInspectName', kind: 'pick', placeholder: 'Choose a plugin from the collection', suggestions: (s) => pluginCollectionSuggestions(s.pluginCollectionEntries ?? []) },
|
|
455
|
+
{ id: 'pluginConfirmRemove', kind: 'confirm', placeholder: 'Type "yes" to confirm', suggestions: () => [] },
|
|
416
456
|
// Themes
|
|
417
457
|
{ id: 'themes', kind: 'pick', placeholder: 'Choose a theme', suggestions: (s) => themeSuggestions(s.settings) },
|
|
418
458
|
// Reasoning effort
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import fs from 'fs
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { pathExists, readJson } from '../utils/fs.js';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { buildSystemPrompt } from '../llm/systemPrompt.js';
|
|
4
5
|
import { hazeTools } from '../llm/hazeTools.js';
|
|
@@ -14,7 +15,7 @@ async function loadFiles(paths) {
|
|
|
14
15
|
const files = [];
|
|
15
16
|
for (const candidate of candidates) {
|
|
16
17
|
const absolute = path.resolve(candidate);
|
|
17
|
-
if (!await
|
|
18
|
+
if (!await pathExists(absolute) || !(await fs.stat(absolute)).isFile())
|
|
18
19
|
continue;
|
|
19
20
|
files.push({ path: path.relative(process.cwd(), absolute) || path.basename(absolute), content: await fs.readFile(absolute, 'utf8') });
|
|
20
21
|
}
|
|
@@ -27,7 +28,7 @@ if (traceIndex >= 0) {
|
|
|
27
28
|
const tracePath = args[traceIndex + 1];
|
|
28
29
|
if (!tracePath)
|
|
29
30
|
throw new Error('--trace requires a JSON fixture path');
|
|
30
|
-
const raw = await
|
|
31
|
+
const raw = await readJson(path.resolve(tracePath));
|
|
31
32
|
const messages = raw.messages ?? [];
|
|
32
33
|
const pruned = compactToolHistory(messages);
|
|
33
34
|
const compacted = compactModelMessages(pruned.messages, { tokenBudget: 4_000 });
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command, Option } from 'commander';
|
|
3
|
-
import { chatCommand } from './commands/chat.js';
|
|
4
|
-
import { runHeadless } from './commands/runCommand.js';
|
|
5
3
|
import { installTerminalTitle, terminalTitleLabel } from './terminalTitle.js';
|
|
6
4
|
import { findSession, latestSession, readSessionEntries } from '../core/session/sessionStore.js';
|
|
7
5
|
import { formatSessionReport, summarizeSessionEntries } from '../core/session/sessionReport.js';
|
|
@@ -10,6 +8,7 @@ import { STDIN_PROMPT_BYTES } from '../core/limits.js';
|
|
|
10
8
|
import { readPackageVersion } from '../utils/version.js';
|
|
11
9
|
import { formatVersionVerbose, readBuildInfo } from '../utils/buildInfo.js';
|
|
12
10
|
import { runDoctor } from './commands/doctor.js';
|
|
11
|
+
import { runPluginCommand } from './commands/pluginCommand.js';
|
|
13
12
|
installBackgroundProcessSignalHandlers();
|
|
14
13
|
const version = readPackageVersion() ?? '0.0.0';
|
|
15
14
|
const program = new Command();
|
|
@@ -101,6 +100,20 @@ program.command('doctor')
|
|
|
101
100
|
.action(async () => {
|
|
102
101
|
process.exitCode = await runDoctor();
|
|
103
102
|
});
|
|
103
|
+
const plugins = program.command('plugin').alias('kit')
|
|
104
|
+
.description('inspect and install local Claude/Agent Plugins packages and collections (skills only)');
|
|
105
|
+
plugins.command('inspect <directory> [name]').action(async (directory, name) => {
|
|
106
|
+
process.stdout.write(`${await runPluginCommand(['inspect', directory, ...(name ? [name] : [])])}\n`);
|
|
107
|
+
});
|
|
108
|
+
plugins.command('install <directory> [name]').action(async (directory, name) => {
|
|
109
|
+
process.stdout.write(`${await runPluginCommand(['install', directory, ...(name ? [name] : [])])}\n`);
|
|
110
|
+
});
|
|
111
|
+
plugins.command('list').action(async () => {
|
|
112
|
+
process.stdout.write(`${await runPluginCommand(['list'])}\n`);
|
|
113
|
+
});
|
|
114
|
+
plugins.command('remove <name>').action(async (name) => {
|
|
115
|
+
process.stdout.write(`${await runPluginCommand(['remove', name])}\n`);
|
|
116
|
+
});
|
|
104
117
|
program.command('report [id]')
|
|
105
118
|
.description('summarize a saved session without exposing prompts or tool output (defaults to the latest session in this workspace)')
|
|
106
119
|
.option('--json', 'print the structured report')
|
|
@@ -132,6 +145,7 @@ program.action(async () => {
|
|
|
132
145
|
}
|
|
133
146
|
if (prompt) {
|
|
134
147
|
// One-shot runs are always fresh and non-durable; --continue is ignored in this mode.
|
|
148
|
+
const { runHeadless } = await import('./commands/runCommand.js');
|
|
135
149
|
const code = await runHeadless({
|
|
136
150
|
prompt,
|
|
137
151
|
modelOverride: opts.model,
|
|
@@ -149,6 +163,9 @@ program.action(async () => {
|
|
|
149
163
|
process.exitCode = code;
|
|
150
164
|
return;
|
|
151
165
|
}
|
|
166
|
+
// Chat and headless pull the full React/Ink/AI-SDK graph; import them only
|
|
167
|
+
// when a turn actually runs so --help/report/doctor stay fast to boot.
|
|
168
|
+
const { chatCommand } = await import('./commands/chat.js');
|
|
152
169
|
await chatCommand({ debug: Boolean(opts.debug), continueSession: Boolean(opts.continue), resumeSessionId: opts.resume, noSession: opts.session === false, version, build: sessionBuildProvenance() });
|
|
153
170
|
});
|
|
154
171
|
/** Safe build provenance recorded into session headers (commit + build time only). */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import fs from 'fs
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { pathExists } from '../utils/fs.js';
|
|
2
3
|
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import crypto from 'node:crypto';
|
|
@@ -45,7 +46,7 @@ async function readContextCandidates(candidates, seen = new Set(), options = {},
|
|
|
45
46
|
if (seen.has(absolute))
|
|
46
47
|
continue;
|
|
47
48
|
seen.add(absolute);
|
|
48
|
-
if (!await
|
|
49
|
+
if (!await pathExists(absolute))
|
|
49
50
|
continue;
|
|
50
51
|
const stat = await fs.stat(absolute).catch(() => null);
|
|
51
52
|
if (!stat?.isFile())
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { pathExists, readJson } from '../utils/fs.js';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { HAZE_DIR } from './paths.js';
|
|
4
4
|
import { tightenPrivateFile, writePrivateJsonAtomic } from './privateStorage.js';
|
|
@@ -13,9 +13,9 @@ function normalizeHistory(value) {
|
|
|
13
13
|
// The storage path is injectable so tests isolate via temp files instead of
|
|
14
14
|
// production switches on test-env globals (CR-011).
|
|
15
15
|
export async function readInputHistory(file = INPUT_HISTORY_FILE) {
|
|
16
|
-
if (await
|
|
16
|
+
if (await pathExists(file))
|
|
17
17
|
await tightenPrivateFile(file);
|
|
18
|
-
const data = await
|
|
18
|
+
const data = await readJson(file).catch(() => []);
|
|
19
19
|
return normalizeHistory(data).slice(-MAX_HISTORY_ITEMS);
|
|
20
20
|
}
|
|
21
21
|
export async function writeInputHistory(history, file = INPUT_HISTORY_FILE) {
|
package/dist/config/paths.d.ts
CHANGED
package/dist/config/paths.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { pathExists, readJson } from '../utils/fs.js';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { HAZE_DIR } from './paths.js';
|
|
@@ -18,9 +18,9 @@ function authReadError(error) {
|
|
|
18
18
|
}
|
|
19
19
|
export async function readProviderAuthStore() {
|
|
20
20
|
try {
|
|
21
|
-
if (await
|
|
21
|
+
if (await pathExists(PROVIDER_AUTH_FILE))
|
|
22
22
|
await tightenPrivateFile(PROVIDER_AUTH_FILE);
|
|
23
|
-
const raw = await
|
|
23
|
+
const raw = await readJson(PROVIDER_AUTH_FILE);
|
|
24
24
|
return providerAuthStoreSchema.parse(raw);
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
@@ -19,10 +19,13 @@ export interface HazeProviderSettings {
|
|
|
19
19
|
kind?: 'openai-compatible' | 'chatgpt-codex';
|
|
20
20
|
/**
|
|
21
21
|
* Explicit endpoint capabilities. Never inferred: images are only sent to
|
|
22
|
-
* providers the user marked image-capable (F03)
|
|
22
|
+
* providers the user marked image-capable (F03); `reasoningEffort: false`
|
|
23
|
+
* stops the reasoning-effort parameter from being sent at all (for
|
|
24
|
+
* endpoints whose own reasoning switch coerces unknown levels).
|
|
23
25
|
*/
|
|
24
26
|
capabilities?: {
|
|
25
27
|
images?: boolean;
|
|
28
|
+
reasoningEffort?: boolean;
|
|
26
29
|
};
|
|
27
30
|
/**
|
|
28
31
|
* Optional per-model capacity metadata used for request budgeting (RH-005).
|
|
@@ -81,7 +84,7 @@ export interface HazeSettings {
|
|
|
81
84
|
mcpServers?: HazeMcpServer[];
|
|
82
85
|
skills?: HazeSkillSetting[];
|
|
83
86
|
subagents?: HazeSubagentSettings;
|
|
84
|
-
/** Optional reasoning depth; absent means the built-in default (`
|
|
87
|
+
/** Optional reasoning depth; absent means the built-in default (`low`), the `provider-default` sentinel sends no parameter. */
|
|
85
88
|
reasoning?: StoredReasoningSetting;
|
|
86
89
|
/** `compact` keeps working context small for models with limited reliable context/tool calling. Default: `standard`. */
|
|
87
90
|
steeringProfile?: 'standard' | 'compact';
|
|
@@ -109,6 +112,15 @@ export interface HazeSettings {
|
|
|
109
112
|
* successful step, so intermittent blips never exhaust it.
|
|
110
113
|
*/
|
|
111
114
|
retryBaseDelayMs?: number;
|
|
115
|
+
/**
|
|
116
|
+
* Idle-stream stall window in milliseconds: how long the model stream may
|
|
117
|
+
* emit nothing before the attempt is aborted (and retried while the shared
|
|
118
|
+
* model-retry pool lasts). Unset means the built-in class-aware default —
|
|
119
|
+
* 5 minutes for hosted endpoints, 30 minutes for loopback/local inference
|
|
120
|
+
* servers, whose prompt ingestion and hidden reasoning can emit no bytes
|
|
121
|
+
* (no SSE keepalives) for many minutes.
|
|
122
|
+
*/
|
|
123
|
+
streamIdleTimeoutMs?: number;
|
|
112
124
|
/**
|
|
113
125
|
* Manual `/compact` mode (F-09): `llm-summary` (default) asks the active
|
|
114
126
|
* model to summarize the older history; `heuristic` keeps the bounded
|
package/dist/config/settings.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { pathExists, readJson } from '../utils/fs.js';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { HAZE_DIR } from './paths.js';
|
|
@@ -7,7 +7,7 @@ import { customProfileSchema } from '../core/subagent/executionProfiles.js';
|
|
|
7
7
|
import { REASONING_LEVELS, REASONING_PROVIDER_DEFAULT } from '../core/agent/reasoningPolicy.js';
|
|
8
8
|
/**
|
|
9
9
|
* Optional, explicitly user-controlled reasoning depth (provider/protocol
|
|
10
|
-
* gated). Absent means the built-in default (`
|
|
10
|
+
* gated). Absent means the built-in default (`low`); the `provider-default`
|
|
11
11
|
* sentinel stores an explicit "send no parameter" opt-out.
|
|
12
12
|
*/
|
|
13
13
|
const storedReasoningValues = [...REASONING_LEVELS, REASONING_PROVIDER_DEFAULT];
|
|
@@ -15,6 +15,7 @@ export const reasoningLevelSchema = z.enum(storedReasoningValues);
|
|
|
15
15
|
export const SETTINGS_FILE = path.join(HAZE_DIR, 'settings.json');
|
|
16
16
|
const providerCapabilitiesSchema = z.object({
|
|
17
17
|
images: z.boolean().optional(),
|
|
18
|
+
reasoningEffort: z.boolean().optional(),
|
|
18
19
|
}).passthrough();
|
|
19
20
|
const providerSchema = z.object({
|
|
20
21
|
name: z.string(),
|
|
@@ -55,6 +56,8 @@ const contextWindowFallbackSchema = z.number().int().min(1_000).max(10_000_000);
|
|
|
55
56
|
const modelRetriesSchema = z.number().int().min(0).max(10);
|
|
56
57
|
/** Retry backoff base must be a plausible delay (not fractions/junk). */
|
|
57
58
|
const retryBaseDelaySchema = z.number().int().min(250).max(60_000);
|
|
59
|
+
/** Idle-stall window must be a plausible wait (≥ 1s for tests, capped at the 24h turn-deadline ceiling). */
|
|
60
|
+
const streamIdleTimeoutSchema = z.number().int().min(1_000).max(24 * 60 * 60_000);
|
|
58
61
|
/**
|
|
59
62
|
* An escalation model is an explicit `provider:model` selector (KISS: shape
|
|
60
63
|
* only — whether the provider/model actually resolves is checked by the
|
|
@@ -76,6 +79,7 @@ const settingsSchema = z.object({
|
|
|
76
79
|
localContextWindowFallbackTokens: contextWindowFallbackSchema.optional(),
|
|
77
80
|
modelRetries: modelRetriesSchema.optional(),
|
|
78
81
|
retryBaseDelayMs: retryBaseDelaySchema.optional(),
|
|
82
|
+
streamIdleTimeoutMs: streamIdleTimeoutSchema.optional(),
|
|
79
83
|
manualCompaction: z.enum(['llm-summary', 'heuristic']).optional(),
|
|
80
84
|
tips: z.object({ enabled: z.boolean().optional() }).optional(),
|
|
81
85
|
theme: z.string().optional(),
|
|
@@ -88,9 +92,9 @@ function settingsReadError(error) {
|
|
|
88
92
|
}
|
|
89
93
|
export async function readSettings() {
|
|
90
94
|
try {
|
|
91
|
-
if (await
|
|
95
|
+
if (await pathExists(SETTINGS_FILE))
|
|
92
96
|
await tightenPrivateFile(SETTINGS_FILE);
|
|
93
|
-
const raw = await
|
|
97
|
+
const raw = await readJson(SETTINGS_FILE);
|
|
94
98
|
return settingsSchema.parse(raw);
|
|
95
99
|
}
|
|
96
100
|
catch (error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFile as execFileCallback } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
-
import
|
|
3
|
+
import { pathExists, readJson } from '../utils/fs.js';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { HAZE_DIR } from './paths.js';
|
|
6
6
|
import { isNewer } from '../utils/version.js';
|
|
@@ -14,9 +14,9 @@ async function defaultExecVersion(packageName, options) {
|
|
|
14
14
|
return stdout;
|
|
15
15
|
}
|
|
16
16
|
async function defaultReadStore(file) {
|
|
17
|
-
if (await
|
|
17
|
+
if (await pathExists(file))
|
|
18
18
|
await tightenPrivateFile(file);
|
|
19
|
-
return
|
|
19
|
+
return readJson(file).catch(() => ({}));
|
|
20
20
|
}
|
|
21
21
|
async function defaultWriteStore(file, store) {
|
|
22
22
|
await writePrivateJsonAtomic(file, store);
|
|
@@ -2,7 +2,24 @@ import type { ToolSet } from 'ai';
|
|
|
2
2
|
export declare const DEFAULT_MAX_OUTPUT_TOKENS = 16384;
|
|
3
3
|
/** Keep generated file payloads comfortably below a model's output-token ceiling. */
|
|
4
4
|
export declare const WRITE_FILE_CHUNK_BYTES: number;
|
|
5
|
+
/** Built-in idle-stream stall window for hosted endpoints (`streamIdleTimeoutMs` setting overrides). */
|
|
5
6
|
export declare const IDLE_TIMEOUT_MS: number;
|
|
7
|
+
/**
|
|
8
|
+
* Built-in idle-stream stall window for loopback/local inference servers.
|
|
9
|
+
* Their time-to-first-token includes prompt ingestion and hidden reasoning
|
|
10
|
+
* with zero bytes emitted — LM Studio and Ollama send no SSE keepalives — so
|
|
11
|
+
* a healthy local model is indistinguishable from a dead stream for minutes.
|
|
12
|
+
* Aborting and retrying would discard the prefill work and re-do it, so the
|
|
13
|
+
* local default is deliberately patient; a genuine local hang is better
|
|
14
|
+
* resolved by the user than by three wasted re-prefills.
|
|
15
|
+
*/
|
|
16
|
+
export declare const LOCAL_IDLE_TIMEOUT_MS: number;
|
|
17
|
+
/**
|
|
18
|
+
* Effective idle-stream stall window: the explicit `streamIdleTimeoutMs`
|
|
19
|
+
* setting wins; otherwise local inference servers get the patient local
|
|
20
|
+
* default and hosted endpoints the hosted one.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveStreamIdleTimeoutMs(setting: number | undefined, localProvider: boolean): number;
|
|
6
23
|
/** Default per-tool execution deadline; an uncooperative tool cannot defer the turn indefinitely (RH-004). */
|
|
7
24
|
export declare const DEFAULT_TOOL_DEADLINE_MS: number;
|
|
8
25
|
/** Subagents legitimately run long; give their wrapper a larger deadline. */
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
export const DEFAULT_MAX_OUTPUT_TOKENS = 16384;
|
|
2
2
|
/** Keep generated file payloads comfortably below a model's output-token ceiling. */
|
|
3
3
|
export const WRITE_FILE_CHUNK_BYTES = 16 * 1024;
|
|
4
|
+
/** Built-in idle-stream stall window for hosted endpoints (`streamIdleTimeoutMs` setting overrides). */
|
|
4
5
|
export const IDLE_TIMEOUT_MS = 5 * 60_000;
|
|
6
|
+
/**
|
|
7
|
+
* Built-in idle-stream stall window for loopback/local inference servers.
|
|
8
|
+
* Their time-to-first-token includes prompt ingestion and hidden reasoning
|
|
9
|
+
* with zero bytes emitted — LM Studio and Ollama send no SSE keepalives — so
|
|
10
|
+
* a healthy local model is indistinguishable from a dead stream for minutes.
|
|
11
|
+
* Aborting and retrying would discard the prefill work and re-do it, so the
|
|
12
|
+
* local default is deliberately patient; a genuine local hang is better
|
|
13
|
+
* resolved by the user than by three wasted re-prefills.
|
|
14
|
+
*/
|
|
15
|
+
export const LOCAL_IDLE_TIMEOUT_MS = 30 * 60_000;
|
|
16
|
+
/**
|
|
17
|
+
* Effective idle-stream stall window: the explicit `streamIdleTimeoutMs`
|
|
18
|
+
* setting wins; otherwise local inference servers get the patient local
|
|
19
|
+
* default and hosted endpoints the hosted one.
|
|
20
|
+
*/
|
|
21
|
+
export function resolveStreamIdleTimeoutMs(setting, localProvider) {
|
|
22
|
+
return setting ?? (localProvider ? LOCAL_IDLE_TIMEOUT_MS : IDLE_TIMEOUT_MS);
|
|
23
|
+
}
|
|
5
24
|
/** Default per-tool execution deadline; an uncooperative tool cannot defer the turn indefinitely (RH-004). */
|
|
6
25
|
export const DEFAULT_TOOL_DEADLINE_MS = 10 * 60_000;
|
|
7
26
|
/** Subagents legitimately run long; give their wrapper a larger deadline. */
|
|
@@ -5,7 +5,7 @@ export const REASONING_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xh
|
|
|
5
5
|
* `none` (reasoning off) or the stored `provider-default` sentinel (written by
|
|
6
6
|
* `/reasoning unset`); key-absent means this default.
|
|
7
7
|
*/
|
|
8
|
-
export const DEFAULT_REASONING_LEVEL = '
|
|
8
|
+
export const DEFAULT_REASONING_LEVEL = 'low';
|
|
9
9
|
/** Stored sentinel meaning "send no reasoning parameter at all". */
|
|
10
10
|
export const REASONING_PROVIDER_DEFAULT = 'provider-default';
|
|
11
11
|
export function isStoredReasoning(value) {
|
|
@@ -22,8 +22,6 @@ export declare function intentExpectsValidation(intent: RequestIntent): boolean;
|
|
|
22
22
|
* a lone line-continuation backslash, and a trailing `--` separator are noise.
|
|
23
23
|
*/
|
|
24
24
|
export declare function validationCommandKey(command: string): string;
|
|
25
|
-
/** Stable, non-reversible identity safe to carry in a goal checkpoint. */
|
|
26
|
-
export declare function validationCheckId(command: string): string;
|
|
27
25
|
/**
|
|
28
26
|
* Opportunistic red→green state for fix intents: no failing repro is required,
|
|
29
27
|
* but when a pre-mutation validation did fail, that same check must pass after
|
|
@@ -114,7 +114,7 @@ function failedCheckScope(command) {
|
|
|
114
114
|
return `direct@${workspacePathKey('.')}:${executable}`;
|
|
115
115
|
}
|
|
116
116
|
/** Stable, non-reversible identity safe to carry in a goal checkpoint. */
|
|
117
|
-
|
|
117
|
+
function validationCheckId(command) {
|
|
118
118
|
return crypto.createHash('sha256').update(validationCommandKey(command)).digest('hex').slice(0, 16);
|
|
119
119
|
}
|
|
120
120
|
/** Encode check identity as `scope:kind:hash`. Self-describing so a pass can pair against carried ids without keeping raw commands. */
|
package/dist/core/log/llmLog.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import fs from 'fs
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
3
|
import { HAZE_DIR } from '../../config/paths.js';
|
|
4
4
|
import { appendPrivateFile, ensurePrivateFile, ensurePrivateDir, tightenPrivateFile } from '../../config/privateStorage.js';
|
|
5
5
|
import { OrderedFileWriter } from '../persistence/orderedFileWriter.js';
|
|
@@ -13,9 +13,12 @@ export interface ProviderCapabilities {
|
|
|
13
13
|
supportsServerCompaction: boolean;
|
|
14
14
|
supportsTextVerbosity: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* Protocol accepts a reasoning-effort request.
|
|
17
|
-
* `
|
|
18
|
-
* the
|
|
16
|
+
* Protocol accepts a reasoning-effort request. Explicit-first: a provider
|
|
17
|
+
* `capabilities.reasoningEffort` override in settings wins. The default is
|
|
18
|
+
* the SDK pass-through (`true`) for hosted OpenAI-compatible endpoints and
|
|
19
|
+
* `false` for loopback/local inference servers, whose own reasoning switches
|
|
20
|
+
* (e.g. LM Studio's `on`/`off`) coerce unsupported levels — even `none` — to
|
|
21
|
+
* `on`, silently inverting the request. `false` omits the parameter entirely.
|
|
19
22
|
*/
|
|
20
23
|
supportsReasoningEffort: boolean;
|
|
21
24
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import fs from 'fs
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import { pathExists } from '../../utils/fs.js';
|
|
4
5
|
import { HAZE_DIR } from '../../config/paths.js';
|
|
5
6
|
import { prepareSessionEntryForWrite, repairRestoredConversation } from './sessionSlimming.js';
|
|
6
7
|
import { appendPrivateFile, ensurePrivateDir, tightenPrivateFile, writePrivateFileAtomic } from '../../config/privateStorage.js';
|
|
@@ -68,7 +69,7 @@ export async function findSession(id, cwd = process.cwd(), sessionsDir = DEFAULT
|
|
|
68
69
|
if (!normalizedId || normalizedId !== id || normalizedId === '.' || normalizedId === '..' || normalizedId.includes('/') || normalizedId.includes('\\') || path.isAbsolute(normalizedId))
|
|
69
70
|
return undefined;
|
|
70
71
|
const file = sessionFile(normalizedId, cwd, sessionsDir);
|
|
71
|
-
if (!await
|
|
72
|
+
if (!await pathExists(file))
|
|
72
73
|
return undefined;
|
|
73
74
|
return { id: normalizedId, file, cwd: path.resolve(cwd), sessionsDir: path.resolve(sessionsDir) };
|
|
74
75
|
}
|
|
@@ -293,7 +294,7 @@ function parseSessionEntry(value) {
|
|
|
293
294
|
}
|
|
294
295
|
async function scanSessionEntries(session, onEntry) {
|
|
295
296
|
const file = validatedSessionFile(session);
|
|
296
|
-
if (session.deferredWrite && !await
|
|
297
|
+
if (session.deferredWrite && !await pathExists(file))
|
|
297
298
|
return [];
|
|
298
299
|
await tightenPrivateFile(file);
|
|
299
300
|
const parseErrors = [];
|
|
@@ -24,7 +24,6 @@ export interface SubagentTaskCapsule {
|
|
|
24
24
|
mode: WorkerMode;
|
|
25
25
|
scope: string[];
|
|
26
26
|
acceptanceCriteria: string[];
|
|
27
|
-
legacyMaxSteps?: number;
|
|
28
27
|
}
|
|
29
28
|
export type WorkerTermination = 'completed' | 'no_output' | 'step_limit' | 'tool_limit' | 'deadline_exceeded' | 'cancelled' | 'provider_error' | 'policy_blocked';
|
|
30
29
|
export interface SubagentResultCapsule {
|
|
@@ -67,15 +66,7 @@ export interface SubagentTelemetry {
|
|
|
67
66
|
export interface SubagentExecutionResult {
|
|
68
67
|
capsule: SubagentResultCapsule;
|
|
69
68
|
telemetry: SubagentTelemetry;
|
|
70
|
-
|
|
71
|
-
summary: string;
|
|
72
|
-
toolCalls: SubagentTelemetry['toolCalls'];
|
|
73
|
-
toolCallCount: number;
|
|
74
|
-
tokens: {
|
|
75
|
-
in?: number;
|
|
76
|
-
out?: number;
|
|
77
|
-
};
|
|
78
|
-
durationMs: number;
|
|
69
|
+
/** Raw provider message on provider errors; kept for machine consumers (RT-03). */
|
|
79
70
|
error?: string;
|
|
80
71
|
}
|
|
81
72
|
export interface WorkerRuntime {
|
|
@@ -90,4 +81,3 @@ export declare function fallbackProviderCapabilities(): ProviderCapabilities;
|
|
|
90
81
|
/** Single source for the placeholder runtime used when only a bare model is available (CR-018). */
|
|
91
82
|
export declare function fallbackWorkerRuntime(model: WorkerRuntime['model'], selector?: string, providerName?: string): WorkerRuntime;
|
|
92
83
|
export declare function normalizeSubagentInput(input: SubagentToolInput, id: string): SubagentTaskCapsule;
|
|
93
|
-
export declare function withLegacyProjection(capsule: SubagentResultCapsule, telemetry: SubagentTelemetry, error?: string): SubagentExecutionResult;
|
|
@@ -31,25 +31,3 @@ export function fallbackWorkerRuntime(model, selector = 'active-model', provider
|
|
|
31
31
|
export function normalizeSubagentInput(input, id) {
|
|
32
32
|
return { id, objective: input.objective, deliverable: input.deliverable, mode: input.mode, scope: input.scope ?? [], acceptanceCriteria: input.acceptanceCriteria ?? [] };
|
|
33
33
|
}
|
|
34
|
-
function legacyStatus(termination) {
|
|
35
|
-
if (termination === 'completed' || termination === 'no_output')
|
|
36
|
-
return 'ok';
|
|
37
|
-
if (termination === 'cancelled')
|
|
38
|
-
return 'cancelled';
|
|
39
|
-
if (termination === 'step_limit' || termination === 'tool_limit' || termination === 'deadline_exceeded')
|
|
40
|
-
return 'timeout';
|
|
41
|
-
return 'error';
|
|
42
|
-
}
|
|
43
|
-
export function withLegacyProjection(capsule, telemetry, error) {
|
|
44
|
-
return {
|
|
45
|
-
capsule,
|
|
46
|
-
telemetry,
|
|
47
|
-
status: legacyStatus(capsule.termination),
|
|
48
|
-
summary: capsule.deliverable,
|
|
49
|
-
toolCalls: telemetry.toolCalls,
|
|
50
|
-
toolCallCount: telemetry.toolCallCount,
|
|
51
|
-
tokens: { in: telemetry.usage.inputTokens, out: telemetry.usage.outputTokens },
|
|
52
|
-
durationMs: telemetry.durationMs,
|
|
53
|
-
...(error ? { error } : {}),
|
|
54
|
-
};
|
|
55
|
-
}
|