@denizokcu/haze 0.9.0 → 0.11.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 +133 -17
- package/README.md +164 -68
- package/SECURITY.md +22 -0
- package/bin/haze.js +102 -1
- package/dist/buildInfo.json +7 -0
- package/dist/cli/chat/TaskBar.d.ts +2 -1
- package/dist/cli/chat/TaskBar.js +7 -4
- package/dist/cli/chat/chatMetrics.d.ts +17 -1
- package/dist/cli/chat/chatMetrics.js +22 -5
- package/dist/cli/chat/contextReport.d.ts +11 -0
- package/dist/cli/chat/contextReport.js +46 -0
- package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
- package/dist/cli/chat/fileMentionSuggestions.js +92 -0
- package/dist/cli/chat/inputSuggestions.d.ts +5 -0
- package/dist/cli/chat/inputSuggestions.js +17 -3
- package/dist/cli/chat/liveRegion.d.ts +25 -0
- package/dist/cli/chat/liveRegion.js +48 -0
- package/dist/cli/chat/messages.d.ts +33 -2
- package/dist/cli/chat/messages.js +216 -33
- package/dist/cli/chat/sessionLifecycle.d.ts +67 -0
- package/dist/cli/chat/sessionLifecycle.js +205 -0
- package/dist/cli/chat/sessionRecorder.js +80 -14
- package/dist/cli/chat/startupInfo.js +11 -4
- package/dist/cli/chat/tips.d.ts +21 -0
- package/dist/cli/chat/tips.js +43 -0
- package/dist/cli/chat/wizardDispatch.d.ts +64 -0
- package/dist/cli/chat/wizardDispatch.js +744 -0
- package/dist/cli/commands/chat.d.ts +6 -0
- package/dist/cli/commands/chat.js +373 -790
- package/dist/cli/commands/chatModes.d.ts +1 -1
- package/dist/cli/commands/chatModes.js +7 -2
- package/dist/cli/commands/commandHelp.js +5 -3
- package/dist/cli/commands/commands.d.ts +5 -2
- package/dist/cli/commands/commands.js +22 -18
- package/dist/cli/commands/doctor.d.ts +19 -0
- package/dist/cli/commands/doctor.js +76 -0
- package/dist/cli/commands/fleetCommand.d.ts +14 -0
- package/dist/cli/commands/fleetCommand.js +46 -0
- package/dist/cli/commands/formatters.d.ts +5 -0
- package/dist/cli/commands/formatters.js +35 -6
- package/dist/cli/commands/logsCommand.js +1 -7
- package/dist/cli/commands/modelCommand.js +1 -1
- package/dist/cli/commands/ndjsonSink.d.ts +23 -0
- package/dist/cli/commands/ndjsonSink.js +38 -0
- package/dist/cli/commands/providerWizard.d.ts +10 -2
- package/dist/cli/commands/providerWizard.js +50 -4
- package/dist/cli/commands/runCommand.d.ts +4 -0
- package/dist/cli/commands/runCommand.js +142 -16
- package/dist/cli/commands/sessionPicker.d.ts +9 -0
- package/dist/cli/commands/sessionPicker.js +29 -0
- package/dist/cli/commands/settingsSummary.js +6 -4
- package/dist/cli/commands/skillConfirmRemove.js +4 -3
- package/dist/cli/commands/skillWizard.d.ts +2 -0
- package/dist/cli/commands/skillWizard.js +16 -6
- package/dist/cli/commands/streaming/abortCause.d.ts +24 -0
- package/dist/cli/commands/streaming/abortCause.js +16 -0
- package/dist/cli/commands/streaming/assistantText.js +9 -2
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +65 -0
- package/dist/cli/commands/streaming/goalCheckpoint.js +23 -0
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +64 -0
- package/dist/cli/commands/streaming/goalSupervisor.js +127 -0
- package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
- package/dist/cli/commands/streaming/idleTimer.js +24 -0
- package/dist/cli/commands/streaming/toolCallRecovery.d.ts +2 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +24 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -2
- package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
- package/dist/cli/commands/streaming/toolResultState.js +29 -7
- package/dist/cli/commands/streaming/turnOutcome.d.ts +17 -0
- package/dist/cli/commands/streaming/turnOutcome.js +27 -11
- package/dist/cli/commands/streaming/turnRuntime.js +6 -4
- package/dist/cli/commands/streaming.d.ts +82 -3
- package/dist/cli/commands/streaming.js +528 -91
- package/dist/cli/commands/wizardActions.d.ts +7 -0
- package/dist/cli/commands/wizardActions.js +7 -0
- package/dist/cli/commands/wizardPrompts.js +7 -1
- package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
- package/dist/cli/commands/wizardSuggestions.js +64 -14
- package/dist/cli/commands/wizardTransition.d.ts +4 -0
- package/dist/cli/commands/wizardTransition.js +1 -2
- package/dist/cli/index.js +82 -22
- package/dist/cli/terminalTitle.d.ts +6 -0
- package/dist/cli/terminalTitle.js +36 -0
- package/dist/config/inputHistory.d.ts +3 -3
- package/dist/config/inputHistory.js +12 -18
- package/dist/config/modelDiscovery.d.ts +71 -0
- package/dist/config/modelDiscovery.js +214 -0
- package/dist/config/privateStorage.js +28 -2
- package/dist/config/providerAuth.d.ts +14 -0
- package/dist/config/providerAuth.js +49 -0
- package/dist/config/providerPresets.d.ts +49 -5
- package/dist/config/providerPresets.js +573 -73
- package/dist/config/providers.d.ts +2 -0
- package/dist/config/providers.js +9 -0
- package/dist/config/settings.d.ts +58 -0
- package/dist/config/settings.js +38 -1
- package/dist/config/skillSettings.d.ts +6 -13
- package/dist/config/skillSettings.js +20 -19
- package/dist/core/agent/budgets.d.ts +36 -0
- package/dist/core/agent/budgets.js +44 -0
- package/dist/core/agent/compaction.d.ts +38 -0
- package/dist/core/agent/compaction.js +108 -19
- package/dist/core/agent/completionController.d.ts +230 -0
- package/dist/core/agent/completionController.js +287 -0
- package/dist/core/agent/contextBudget.d.ts +46 -0
- package/dist/core/agent/contextBudget.js +89 -7
- package/dist/core/agent/errors.js +6 -2
- package/dist/core/agent/events.d.ts +86 -0
- package/dist/core/agent/reasoningPolicy.d.ts +31 -0
- package/dist/core/agent/reasoningPolicy.js +27 -0
- package/dist/core/agent/toolCapabilities.d.ts +27 -0
- package/dist/core/agent/toolCapabilities.js +58 -0
- package/dist/core/agent/toolExecutionBudget.d.ts +35 -0
- package/dist/core/agent/toolExecutionBudget.js +49 -0
- package/dist/core/agent/toolOutputStore.d.ts +13 -0
- package/dist/core/agent/toolOutputStore.js +27 -10
- package/dist/core/agent/toolResults.d.ts +12 -0
- package/dist/core/agent/toolResults.js +38 -0
- package/dist/core/agent/turnBudget.d.ts +35 -0
- package/dist/core/agent/turnBudget.js +27 -0
- package/dist/core/agent/turnPolicy.d.ts +11 -0
- package/dist/core/agent/turnPolicy.js +19 -0
- package/dist/core/agent/workState.d.ts +76 -1
- package/dist/core/agent/workState.js +120 -13
- package/dist/core/attachments/imageAttachments.d.ts +90 -0
- package/dist/core/attachments/imageAttachments.js +245 -0
- package/dist/core/attachments/readBlessings.d.ts +37 -0
- package/dist/core/attachments/readBlessings.js +79 -0
- package/dist/core/deadline.d.ts +33 -0
- package/dist/core/deadline.js +74 -0
- package/dist/core/goal/completionPolicy.d.ts +27 -0
- package/dist/core/goal/completionPolicy.js +37 -1
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -13
- package/dist/core/io/boundedRead.js +76 -29
- package/dist/core/limits/byteBudgets.d.ts +7 -0
- package/dist/core/limits/byteBudgets.js +7 -0
- package/dist/core/limits/textBudgets.d.ts +25 -0
- package/dist/core/limits/textBudgets.js +25 -0
- package/dist/core/log/llmLog.js +7 -0
- package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
- package/dist/core/persistence/orderedFileWriter.js +16 -2
- package/dist/core/process/backgroundRegistry.d.ts +35 -0
- package/dist/core/process/backgroundRegistry.js +195 -0
- package/dist/core/process/runBoundedProcess.d.ts +9 -0
- package/dist/core/process/runBoundedProcess.js +74 -29
- package/dist/core/safety/missingExecutable.d.ts +42 -0
- package/dist/core/safety/missingExecutable.js +77 -0
- package/dist/core/safety/urlGuard.d.ts +2 -1
- package/dist/core/safety/urlGuard.js +3 -2
- package/dist/core/session/sessionSlimming.js +47 -4
- package/dist/core/session/sessionStore.d.ts +74 -0
- package/dist/core/session/sessionStore.js +268 -18
- package/dist/core/subagent/contracts.d.ts +120 -0
- package/dist/core/subagent/contracts.js +55 -0
- package/dist/core/subagent/executionProfiles.d.ts +28 -0
- package/dist/core/subagent/executionProfiles.js +45 -0
- package/dist/core/subagent/subagentCoordinator.d.ts +78 -0
- package/dist/core/subagent/subagentCoordinator.js +164 -0
- package/dist/core/subagent/subagentRunner.d.ts +211 -145
- package/dist/core/subagent/subagentRunner.js +208 -98
- package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
- package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
- package/dist/core/tasks/taskStorage.js +12 -1
- package/dist/llm/client.d.ts +36 -29
- package/dist/llm/client.js +102 -33
- package/dist/llm/hazeTools.d.ts +2559 -150
- package/dist/llm/hazeTools.js +119 -31
- package/dist/llm/lsp.d.ts +26 -4
- package/dist/llm/lsp.js +90 -14
- package/dist/llm/lspTools.d.ts +2366 -0
- package/dist/llm/lspTools.js +87 -79
- package/dist/llm/openaiCodex.d.ts +3 -0
- package/dist/llm/openaiCodex.js +47 -0
- package/dist/llm/openaiCodexOAuth.d.ts +54 -0
- package/dist/llm/openaiCodexOAuth.js +214 -0
- package/dist/llm/requestContext.d.ts +25 -1
- package/dist/llm/requestContext.js +51 -8
- package/dist/llm/systemPrompt.d.ts +15 -1
- package/dist/llm/systemPrompt.js +24 -8
- package/dist/llm/toolResultTypes.d.ts +8 -1
- package/dist/llm/tools/bashTool.d.ts +906 -32
- package/dist/llm/tools/bashTool.js +30 -4
- package/dist/llm/tools/editMatch.d.ts +14 -0
- package/dist/llm/tools/editMatch.js +72 -0
- package/dist/llm/tools/failures.d.ts +2 -0
- package/dist/llm/tools/failures.js +1 -0
- package/dist/llm/tools/fetchTool.d.ts +42 -26
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +6 -4
- package/dist/llm/tools/fileToolShared.js +18 -23
- package/dist/llm/tools/gitIgnore.d.ts +49 -0
- package/dist/llm/tools/gitIgnore.js +129 -0
- package/dist/llm/tools/grepRunner.d.ts +5 -0
- package/dist/llm/tools/grepRunner.js +52 -71
- package/dist/llm/tools/outputCap.d.ts +2 -6
- package/dist/llm/tools/outputCap.js +2 -6
- package/dist/llm/tools/processTool.d.ts +1077 -0
- package/dist/llm/tools/processTool.js +41 -0
- package/dist/llm/tools/readRecovery.d.ts +10 -0
- package/dist/llm/tools/readRecovery.js +135 -0
- package/dist/llm/tools/toolContext.d.ts +9 -1
- package/dist/llm/tools/toolContext.js +83 -43
- package/dist/llm/tools/workspaceFile.d.ts +9 -1
- package/dist/llm/tools/workspaceFile.js +33 -4
- package/dist/llm/webFetch.d.ts +17 -0
- package/dist/llm/webFetch.js +66 -86
- package/dist/llm/workerContext.d.ts +18 -0
- package/dist/llm/workerContext.js +55 -0
- package/dist/skills/SkillLoader.d.ts +2 -2
- package/dist/skills/SkillRegistry.d.ts +3 -2
- package/dist/skills/SkillRegistry.js +43 -13
- package/dist/skills/builder/SkillBuilder.d.ts +3 -0
- package/dist/skills/builder/SkillBuilder.js +23 -5
- package/dist/skills/skillTools.js +11 -4
- package/dist/skills/types.d.ts +6 -1
- package/dist/ui/codeHighlight.d.ts +4 -0
- package/dist/ui/codeHighlight.js +31 -0
- package/dist/ui/components/Header.d.ts +1 -1
- package/dist/ui/components/MarkdownText.d.ts +16 -2
- package/dist/ui/components/MarkdownText.js +244 -34
- package/dist/ui/components/TextInput.d.ts +12 -2
- package/dist/ui/components/TextInput.js +80 -8
- package/dist/ui/theme.d.ts +4 -3
- package/dist/ui/theme.js +5 -4
- package/dist/utils/buildInfo.d.ts +104 -0
- package/dist/utils/buildInfo.js +253 -0
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/format.js +8 -0
- package/dist/utils/fs.d.ts +9 -1
- package/dist/utils/fs.js +87 -29
- package/dist/utils/openPath.d.ts +2 -0
- package/dist/utils/openPath.js +22 -0
- package/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +5 -1
- package/dist/utils/utf8.d.ts +22 -0
- package/dist/utils/utf8.js +54 -0
- package/dist/utils/version.d.ts +9 -3
- package/dist/utils/version.js +28 -2
- package/package.json +24 -19
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Mode = 'chat' | 'provider' | 'providerAction' | 'model' | 'providerAddPreset' | 'providerAddName' | 'providerAddUrl' | 'providerAddKey' | 'providerAddModels' | 'providerAppendModels' | 'providerSetKey' | 'providerRemoveModels' | 'providerConfirmRemove' | 'skills' | 'skillsAction' | 'skillsAddName' | 'skillsAddDescription' | 'skillsConfirmRemove' | 'lsp' | 'lspAction' | 'lspAddPreset' | 'lspAddName' | 'lspAddCommand' | 'lspConfirmRemove' | 'mcp' | 'mcpAction' | 'mcpAddPreset' | 'mcpAddName' | 'mcpAddTransport' | 'mcpAddUrl' | 'mcpAddCommand' | 'mcpAddKey' | 'mcpSetKey' | 'mcpConfirmRemove';
|
|
1
|
+
export type Mode = 'chat' | 'sessions' | 'sessionAction' | 'provider' | 'providerAction' | 'model' | 'modelAddProvider' | 'modelPick' | 'providerAddPreset' | 'providerAddName' | 'providerAddUrl' | 'providerAddKey' | 'providerAddModels' | 'providerAppendModels' | 'providerSetKey' | 'providerRemoveModels' | 'providerConfirmRemove' | 'skills' | 'skillsAction' | 'skillsAddName' | 'skillsAddScope' | 'skillsAddDescription' | 'skillsConfirmRemove' | 'lsp' | 'lspAction' | 'lspAddPreset' | 'lspAddName' | 'lspAddCommand' | 'lspConfirmRemove' | 'mcp' | 'mcpAction' | 'mcpAddPreset' | 'mcpAddName' | 'mcpAddTransport' | 'mcpAddUrl' | 'mcpAddCommand' | 'mcpAddKey' | 'mcpSetKey' | 'mcpConfirmRemove';
|
|
2
2
|
/** Modes that show an always-on suggestion picker (server/preset lists). */
|
|
3
3
|
export declare const PICKER_MODES: ReadonlySet<Mode>;
|
|
4
4
|
/** Modes that mask input (secrets/API keys). */
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/** Modes that show an always-on suggestion picker (server/preset lists). */
|
|
2
|
-
export const PICKER_MODES = new Set(['provider', 'providerAction', 'providerAddPreset', 'model', 'skills', 'skillsAction', 'lsp', 'lspAction', 'lspAddPreset', 'mcp', 'mcpAction', 'mcpAddPreset', 'mcpAddTransport']);
|
|
2
|
+
export const PICKER_MODES = new Set(['sessions', 'sessionAction', 'provider', 'providerAction', 'providerAddPreset', 'model', 'modelAddProvider', 'modelPick', 'skills', 'skillsAction', 'skillsAddScope', 'lsp', 'lspAction', 'lspAddPreset', 'mcp', 'mcpAction', 'mcpAddPreset', 'mcpAddTransport']);
|
|
3
3
|
/** Modes that mask input (secrets/API keys). */
|
|
4
4
|
export const MASKED_MODES = new Set(['providerAddKey', 'providerSetKey', 'mcpAddKey', 'mcpSetKey']);
|
|
5
5
|
/** Modes where submitting an empty value is valid (optional steps). */
|
|
6
6
|
export const SUBMIT_EMPTY_MODES = new Set(['providerAddKey', 'mcpAddKey']);
|
|
7
7
|
const PLACEHOLDERS = {
|
|
8
|
+
sessions: 'Choose a saved session',
|
|
9
|
+
sessionAction: 'Resume or fork this session',
|
|
8
10
|
provider: 'Choose provider',
|
|
9
11
|
providerAction: 'Choose provider action',
|
|
10
12
|
providerAddPreset: 'Choose a provider preset or custom',
|
|
11
|
-
model: 'Choose model',
|
|
13
|
+
model: 'Choose model, or add model',
|
|
14
|
+
modelAddProvider: 'Choose a provider to add models to',
|
|
15
|
+
modelPick: 'Choose a model to add',
|
|
12
16
|
providerAddName: 'Provider name',
|
|
13
17
|
providerAddUrl: 'https://example.com/v1',
|
|
14
18
|
providerAddKey: 'API key, or blank for local',
|
|
@@ -20,6 +24,7 @@ const PLACEHOLDERS = {
|
|
|
20
24
|
skills: 'Choose a skill or add skill',
|
|
21
25
|
skillsAction: 'show info, enable, disable, validate, or remove',
|
|
22
26
|
skillsAddName: 'Skill name (kebab-case, e.g. security-review)',
|
|
27
|
+
skillsAddScope: 'Choose this project or global',
|
|
23
28
|
skillsAddDescription: 'Describe what the skill should do',
|
|
24
29
|
skillsConfirmRemove: 'Type "yes" to confirm',
|
|
25
30
|
lsp: 'Choose LSP server or add server',
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export const COMMAND_HELP_ENTRIES = [
|
|
2
2
|
{ usage: '/help', description: 'Show all available slash commands and what they do.' },
|
|
3
|
-
{ usage: '/provider', description: 'Choose a provider, then use it, add/remove models, set API key, or remove it.' },
|
|
4
|
-
{ usage: '/model', description: 'Choose a model from
|
|
3
|
+
{ usage: '/provider', description: 'Choose a provider, then use it, add/remove models, set API key, toggle image input, or remove it.' },
|
|
4
|
+
{ usage: '/model', description: 'Choose a model, or add models from a provider\'s models endpoint.' },
|
|
5
5
|
{ usage: '/model <name-or-provider:name>', description: 'Set a model directly. Selecting a model also sets its provider.' },
|
|
6
6
|
{ usage: '/settings', description: 'Show the configured provider, model, API key status, LSP/MCP servers, skills, and loaded context files.' },
|
|
7
7
|
{ usage: '/settings open', description: 'Open ~/.haze/settings.json with the OS default app.' },
|
|
8
8
|
{ usage: '/skills', description: 'Manage Markdown skills: generate a custom skill, show info, enable/disable, validate, or remove.' },
|
|
9
|
+
{ usage: '/tips', description: 'Toggle the rotating tips shown under the busy label while the model is thinking.' },
|
|
10
|
+
{ usage: '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>', description: 'Run genuinely independent tasks through disposable contexts. Runtime enforces profile concurrency, deadlines, and mutation serialization; control guidance is not persisted. Declines non-parallel work.' },
|
|
9
11
|
{ usage: '/init', description: 'Inspect the current workspace and create or update AGENTS.md project instructions.' },
|
|
10
12
|
{ usage: '/context', description: 'Show a token breakdown of the current request: system prompt, project context, tools (incl. MCP), and chat messages.' },
|
|
11
13
|
{ usage: '/session', description: 'Show the current durable session file.' },
|
|
12
|
-
{ usage: '/resume', description: '
|
|
14
|
+
{ usage: '/resume [id]', description: 'Browse this workspace’s saved sessions, or resume an exact session id.' },
|
|
13
15
|
{ usage: '/new', description: 'Start a fresh durable session.' },
|
|
14
16
|
{ usage: '/logs', description: 'List recent log files with sizes and dates.' },
|
|
15
17
|
{ usage: '/lsp', description: 'Configure Language Server Protocol navigation tools (interactive picker).' },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ContextFile } from '../../config/contextFiles.js';
|
|
2
2
|
import { type HazeSettings } from '../../config/settings.js';
|
|
3
3
|
import type { Mode } from './chatModes.js';
|
|
4
|
+
import type { TurnExecutionOptions } from './streaming.js';
|
|
4
5
|
export type CommandContext = {
|
|
5
6
|
settings: HazeSettings;
|
|
6
7
|
contextFiles: ContextFile[];
|
|
@@ -9,10 +10,12 @@ export type CommandContext = {
|
|
|
9
10
|
addSystemMessage: (text: string) => void;
|
|
10
11
|
clearConversation: () => void | Promise<void>;
|
|
11
12
|
newSession?: () => Promise<void>;
|
|
12
|
-
resumeSession?: () => Promise<void>;
|
|
13
|
+
resumeSession?: (id?: string) => Promise<void>;
|
|
13
14
|
sessionInfo?: () => string;
|
|
14
15
|
compactConversation?: (instructions?: string) => boolean;
|
|
15
|
-
|
|
16
|
+
/** LLM-summarized /compact (F-09); preferred over `compactConversation` when present. */
|
|
17
|
+
compactConversationLlm?: (instructions?: string) => Promise<boolean>;
|
|
18
|
+
runAgentTurn: (prompt: string, displayValue?: string, options?: TurnExecutionOptions) => Promise<void>;
|
|
16
19
|
refreshContextFiles: () => Promise<ContextFile[]>;
|
|
17
20
|
updateSettings: (patch: Partial<HazeSettings>) => Promise<HazeSettings>;
|
|
18
21
|
getContextReport?: () => Promise<string>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import fs from 'fs-extra';
|
|
3
2
|
import { SETTINGS_FILE, writeSettings } from '../../config/settings.js';
|
|
3
|
+
import { openPath } from '../../utils/openPath.js';
|
|
4
4
|
import { clearTasks } from '../../core/tasks/taskStorage.js';
|
|
5
5
|
import { COMMAND_HELP_ENTRIES, formatCommandHelp } from './commandHelp.js';
|
|
6
|
+
import { handleFleetCommand } from './fleetCommand.js';
|
|
6
7
|
import { handleInitCommand } from './initCommand.js';
|
|
7
8
|
import { handleLogsCommand } from './logsCommand.js';
|
|
8
9
|
import { handleModelCommand } from './modelCommand.js';
|
|
@@ -12,15 +13,6 @@ async function ensureSettingsFile(settings) {
|
|
|
12
13
|
await writeSettings(settings);
|
|
13
14
|
return SETTINGS_FILE;
|
|
14
15
|
}
|
|
15
|
-
function openPath(filePath) {
|
|
16
|
-
if (process.env.VITEST || process.env.NODE_ENV === 'test')
|
|
17
|
-
return;
|
|
18
|
-
const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
19
|
-
const args = process.platform === 'win32' ? ['/c', 'start', '', filePath] : [filePath];
|
|
20
|
-
const child = spawn(command, args, { stdio: 'ignore', detached: true });
|
|
21
|
-
child.on('error', () => undefined);
|
|
22
|
-
child.unref();
|
|
23
|
-
}
|
|
24
16
|
const HANDLED = 'handled';
|
|
25
17
|
function exact(command) {
|
|
26
18
|
return value => value === command ? { args: '' } : false;
|
|
@@ -33,27 +25,39 @@ const SLASH_COMMANDS = [
|
|
|
33
25
|
{ match: exact('/help'), run: (_args, ctx) => { ctx.addSystemMessage(formatCommandHelp(COMMAND_HELP_ENTRIES)); return HANDLED; } },
|
|
34
26
|
{ match: exact('/context'), run: async (_args, ctx) => { ctx.addSystemMessage(ctx.getContextReport ? await ctx.getContextReport() : 'Context overview is unavailable.'); return HANDLED; } },
|
|
35
27
|
{ match: exact('/session'), run: (_args, ctx) => { ctx.addSystemMessage(ctx.sessionInfo?.() ?? 'Session persistence is unavailable.'); return HANDLED; } },
|
|
36
|
-
{ match:
|
|
37
|
-
await ctx.resumeSession();
|
|
28
|
+
{ match: exactOrArgs('/resume'), run: async (args, ctx) => { if (ctx.resumeSession)
|
|
29
|
+
await ctx.resumeSession(args || undefined);
|
|
38
30
|
else
|
|
39
31
|
ctx.addSystemMessage('Session persistence is unavailable.'); return HANDLED; } },
|
|
40
32
|
{ match: exact('/new'), run: async (_args, ctx) => { if (ctx.newSession)
|
|
41
33
|
await ctx.newSession();
|
|
42
34
|
else
|
|
43
35
|
ctx.addSystemMessage('Session persistence is unavailable.'); return HANDLED; } },
|
|
44
|
-
{ match: exactOrArgs('/compact'), run: (args, ctx) => {
|
|
45
|
-
ctx.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
{ match: exactOrArgs('/compact'), run: async (args, ctx) => {
|
|
37
|
+
if (ctx.compactConversationLlm)
|
|
38
|
+
await ctx.compactConversationLlm(args || undefined);
|
|
39
|
+
else if (ctx.compactConversation)
|
|
40
|
+
ctx.compactConversation(args || undefined);
|
|
41
|
+
else
|
|
42
|
+
ctx.addSystemMessage('Compaction is unavailable.');
|
|
43
|
+
return HANDLED;
|
|
44
|
+
} },
|
|
45
|
+
{ match: exact('/clear'), run: async (_args, ctx) => { await ctx.clearConversation(); await clearTasks(); return HANDLED; } },
|
|
49
46
|
{ match: exactOrArgs('/logs'), run: async (args, ctx) => await handleLogsCommand(args, ctx) },
|
|
50
47
|
{ match: exactOrArgs('/lsp'), run: (_args, ctx) => { ctx.setMode('lsp'); ctx.addSystemMessage('Choose an LSP server to enable, disable, or remove it. Choose "add server" to add one from presets (e.g. typescript) or enter a custom command.'); return HANDLED; } },
|
|
51
48
|
{ match: exactOrArgs('/mcp'), run: (_args, ctx) => { ctx.setMode('mcp'); ctx.addSystemMessage('Choose an MCP server to enable, disable, remove, or set a key for it. Choose "add server" to add one from presets (e.g. context7) or enter custom details.'); return HANDLED; } },
|
|
52
|
-
{ match: value => value === '/settings open' || value === '/settings edit' ? { args: '' } : false, run: async (_args, ctx) => { const file = await ensureSettingsFile(ctx.settings); openPath(file); ctx.addSystemMessage(`Opened settings file: ${file}`); return HANDLED; } },
|
|
49
|
+
{ match: value => value === '/settings open' || value === '/settings edit' ? { args: '' } : false, run: async (_args, ctx) => { const file = await ensureSettingsFile(ctx.settings); await openPath(file); ctx.addSystemMessage(`Opened settings file: ${file}`); return HANDLED; } },
|
|
53
50
|
{ match: exact('/settings'), run: async (_args, ctx) => { ctx.addSystemMessage(await formatSettingsSummary(ctx.settings, ctx.contextFiles)); return HANDLED; } },
|
|
54
51
|
{ match: exact('/provider'), run: (_args, ctx) => { ctx.setModelProviderFilter?.(undefined); ctx.setMode('provider'); ctx.addSystemMessage('Choose a provider. Selecting one opens provider actions. Choose "add provider" to pick from presets or enter custom details.'); return HANDLED; } },
|
|
55
52
|
{ match: exact('/init'), run: async (_args, ctx) => await handleInitCommand(ctx) },
|
|
56
53
|
{ match: exact('/skills'), run: (_args, ctx) => { ctx.setMode('skills'); ctx.addSystemMessage('Choose a skill to show info, enable/disable, or remove it. Choose "add skill" to generate a new one from a description.'); return HANDLED; } },
|
|
54
|
+
{ match: exact('/tips'), run: async (_args, ctx) => {
|
|
55
|
+
const currentlyEnabled = ctx.settings.tips?.enabled !== false;
|
|
56
|
+
await ctx.updateSettings({ tips: { enabled: !currentlyEnabled } });
|
|
57
|
+
ctx.addSystemMessage(`Tips rotation ${currentlyEnabled ? 'disabled' : 'enabled'}.`);
|
|
58
|
+
return HANDLED;
|
|
59
|
+
} },
|
|
60
|
+
{ match: exactOrArgs('/fleet'), run: (args, ctx) => handleFleetCommand(args, ctx) },
|
|
57
61
|
];
|
|
58
62
|
export async function handleSlashCommand(value, ctx) {
|
|
59
63
|
for (const command of SLASH_COMMANDS) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `haze doctor`: runtime provenance and integrity diagnostics. Reports the
|
|
3
|
+
* version/commit actually executing, verifies compiled artifacts and manifest
|
|
4
|
+
* consistency, prints the capability registry, and warns when a nearby source
|
|
5
|
+
* checkout diverges from the running installation. Pure diagnostics — it
|
|
6
|
+
* never switches or repairs anything.
|
|
7
|
+
*
|
|
8
|
+
* Exit code: 1 when the running build itself is broken (missing artifacts,
|
|
9
|
+
* stale manifest); 0 otherwise (a checkout mismatch is a warning, not a
|
|
10
|
+
* failure of the running runtime).
|
|
11
|
+
*/
|
|
12
|
+
export interface DoctorDeps {
|
|
13
|
+
stdout?: {
|
|
14
|
+
write(line: string): void;
|
|
15
|
+
};
|
|
16
|
+
runtimeRoot?: string;
|
|
17
|
+
cwd?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function runDoctor(deps?: DoctorDeps): Promise<number>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { detectCheckoutMismatch, formatCapabilities, formatMismatchWarning, formatVersionVerbose, gitHeadCommit, GOAL_SUPERVISOR_ARTIFACT, readBuildInfo, readPackageVersionAt, resolveExecutable, resolvePackageRoot, runtimeCapabilities, } from '../../utils/buildInfo.js';
|
|
4
|
+
export async function runDoctor(deps = {}) {
|
|
5
|
+
const out = deps.stdout ?? process.stdout;
|
|
6
|
+
const runtimeRoot = deps.runtimeRoot ?? resolvePackageRoot();
|
|
7
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
8
|
+
const write = (line = '') => out.write(`${line}\n`);
|
|
9
|
+
const version = runtimeRoot ? readPackageVersionAt(runtimeRoot) : undefined;
|
|
10
|
+
const build = runtimeRoot ? readBuildInfo([join(runtimeRoot, 'dist', 'buildInfo.json')]) : undefined;
|
|
11
|
+
const capabilities = runtimeCapabilities(runtimeRoot ?? cwd);
|
|
12
|
+
const headCommit = runtimeRoot ? gitHeadCommit(runtimeRoot) : undefined;
|
|
13
|
+
write(formatVersionVerbose({
|
|
14
|
+
version: build?.version ?? version ?? 'unknown',
|
|
15
|
+
build,
|
|
16
|
+
runtimeRoot,
|
|
17
|
+
executable: resolveExecutable(),
|
|
18
|
+
capabilities,
|
|
19
|
+
}));
|
|
20
|
+
write();
|
|
21
|
+
write('Installation');
|
|
22
|
+
write(` root: ${runtimeRoot ?? 'unknown'}`);
|
|
23
|
+
write(` kind: ${headCommit ? 'development checkout (linked or run in place)' : 'installed package (no git metadata)'}`);
|
|
24
|
+
write();
|
|
25
|
+
write('Capabilities');
|
|
26
|
+
for (const [name, enabled] of Object.entries(capabilities)) {
|
|
27
|
+
write(` ${name}: ${enabled ? 'enabled' : 'disabled'}`);
|
|
28
|
+
}
|
|
29
|
+
write();
|
|
30
|
+
const checks = [];
|
|
31
|
+
for (const artifact of ['dist/cli/index.js', GOAL_SUPERVISOR_ARTIFACT, 'dist/buildInfo.json']) {
|
|
32
|
+
const present = runtimeRoot ? existsSync(join(runtimeRoot, artifact)) : false;
|
|
33
|
+
checks.push({ label: `artifact ${artifact}`, state: present ? 'ok' : 'fail', detail: present ? 'present' : 'missing' });
|
|
34
|
+
}
|
|
35
|
+
if (build && version) {
|
|
36
|
+
checks.push(build.version === version
|
|
37
|
+
? { label: 'package/build version', state: 'ok', detail: `${version} == ${version}` }
|
|
38
|
+
: { label: 'package/build version', state: 'fail', detail: `package.json ${version} vs dist/buildInfo.json ${build.version} — rebuild with npm run build` });
|
|
39
|
+
}
|
|
40
|
+
else if (!build) {
|
|
41
|
+
checks.push({ label: 'build manifest', state: 'fail', detail: 'dist/buildInfo.json missing or unreadable — rebuild with npm run build' });
|
|
42
|
+
}
|
|
43
|
+
if (headCommit) {
|
|
44
|
+
checks.push(build?.commit && build.commit !== headCommit
|
|
45
|
+
? { label: 'build commit', state: 'fail', detail: `built from ${build.commit.slice(0, 7)}, checkout HEAD is ${headCommit.slice(0, 7)} — rebuild with npm run build` }
|
|
46
|
+
: { label: 'build commit', state: 'ok', detail: `${(build?.commit ?? headCommit).slice(0, 7)} matches HEAD` });
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
checks.push({ label: 'build commit', state: 'warn', detail: 'no git metadata at the installation root (normal for installed packages)' });
|
|
50
|
+
}
|
|
51
|
+
write('Checks');
|
|
52
|
+
for (const check of checks) {
|
|
53
|
+
const marker = check.state === 'ok' ? 'ok' : check.state === 'warn' ? 'warning' : 'FAIL';
|
|
54
|
+
write(` [${marker}] ${check.label}: ${check.detail}`);
|
|
55
|
+
}
|
|
56
|
+
write();
|
|
57
|
+
const mismatch = detectCheckoutMismatch({ executingRoot: runtimeRoot, cwd });
|
|
58
|
+
if (mismatch) {
|
|
59
|
+
write('Checkout mismatch');
|
|
60
|
+
for (const line of formatMismatchWarning(mismatch).split('\n'))
|
|
61
|
+
write(` ${line}`);
|
|
62
|
+
write();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
write('Checkout mismatch: none');
|
|
66
|
+
write();
|
|
67
|
+
}
|
|
68
|
+
if (!capabilities.logicalGoalSupervisor) {
|
|
69
|
+
write('Warning: the goal supervisor is unavailable in this runtime; exhausting a');
|
|
70
|
+
write("turn's step/tool budget may pause the goal instead of continuing automatically.");
|
|
71
|
+
write();
|
|
72
|
+
}
|
|
73
|
+
write(`capability summary: ${formatCapabilities(capabilities)}`);
|
|
74
|
+
const failed = checks.some(check => check.state === 'fail');
|
|
75
|
+
return failed ? 1 : 0;
|
|
76
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TurnExecutionOptions } from './streaming.js';
|
|
2
|
+
import type { CommandContext, CommandResult } from './commands.js';
|
|
3
|
+
export interface ParsedFleetCommand {
|
|
4
|
+
prompt: string;
|
|
5
|
+
options: TurnExecutionOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseFleetArgs(args: string): {
|
|
8
|
+
ok: true;
|
|
9
|
+
value: ParsedFleetCommand;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
error: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function handleFleetCommand(args: string, ctx: CommandContext): Promise<CommandResult>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SUBAGENT_MAX_CONCURRENCY } from '../../core/agent/budgets.js';
|
|
2
|
+
const FLEET_CONTROL = `This is an ephemeral /fleet parallel-only control. Decompose the durable request into genuinely independent, self-contained subagent capsules; decline if fewer than two exist and never invent tasks. For a repository-wide request, first do one bounded structure lookup, then give workers focused directory/file scope hints instead of all of src. Every call requires objective, deliverable, and mode; keep objective under 1000 characters, prefer at most 12 scope paths, and put output formatting in deliverable/acceptanceCriteria. Mode is inspect, research, implement, or validate. Never call subagent with {}. Runtime owns queueing, concurrency, deadlines, provider policy, and mutation serialization. Submit independent read-only calls together; submit mutation conservatively and validate after it settles. Aggregate every capsule truthfully by termination, usability, truncation, changed paths, validation, and coverage gaps. Retry a failed/limited worker at most once, only with materially narrower scope; otherwise report the gap. Never request private worker transcripts.`;
|
|
3
|
+
export function parseFleetArgs(args) {
|
|
4
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
5
|
+
const overrides = {};
|
|
6
|
+
let index = 0;
|
|
7
|
+
while (index < tokens.length && tokens[index].startsWith('-')) {
|
|
8
|
+
const flag = tokens[index++];
|
|
9
|
+
if (flag === '--')
|
|
10
|
+
break;
|
|
11
|
+
if (flag === '--review') {
|
|
12
|
+
overrides.forceMode = 'inspect';
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (!['--profile', '--workers', '--concurrency'].includes(flag))
|
|
16
|
+
return { ok: false, error: `Unknown /fleet flag: ${flag}` };
|
|
17
|
+
const value = tokens[index++];
|
|
18
|
+
if (!value || value.startsWith('--'))
|
|
19
|
+
return { ok: false, error: `${flag} requires a value.` };
|
|
20
|
+
if (flag === '--profile')
|
|
21
|
+
overrides.profile = value;
|
|
22
|
+
if (flag === '--workers')
|
|
23
|
+
overrides.workerModel = value;
|
|
24
|
+
if (flag === '--concurrency') {
|
|
25
|
+
const concurrency = Number(value);
|
|
26
|
+
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > SUBAGENT_MAX_CONCURRENCY)
|
|
27
|
+
return { ok: false, error: `--concurrency must be an integer from 1 to ${SUBAGENT_MAX_CONCURRENCY}.` };
|
|
28
|
+
overrides.maxConcurrency = concurrency;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const prompt = tokens.slice(index).join(' ').trim();
|
|
32
|
+
if (!prompt)
|
|
33
|
+
return { ok: false, error: '/fleet needs a prompt describing parallel work.' };
|
|
34
|
+
return { ok: true, value: { prompt, options: { ephemeralControl: FLEET_CONTROL, subagentOverrides: overrides } } };
|
|
35
|
+
}
|
|
36
|
+
const USAGE = '/fleet [--review] [--profile <name>] [--workers <provider:model>] [--concurrency <n>] [--] <prompt>';
|
|
37
|
+
export async function handleFleetCommand(args, ctx) {
|
|
38
|
+
const parsed = parseFleetArgs(args);
|
|
39
|
+
if (!parsed.ok) {
|
|
40
|
+
ctx.addSystemMessage(`${parsed.error} Usage: ${USAGE}`);
|
|
41
|
+
return 'handled';
|
|
42
|
+
}
|
|
43
|
+
const durable = `/fleet ${args.trim()}`;
|
|
44
|
+
await ctx.runAgentTurn(durable, durable, parsed.value.options);
|
|
45
|
+
return 'handled';
|
|
46
|
+
}
|
|
@@ -12,6 +12,11 @@ export declare function toolResultSummary(event: {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function busyToolLabel(toolName: string, input: unknown): string;
|
|
14
14
|
export declare function formatSeconds(milliseconds: number): string;
|
|
15
|
+
/** Compact transcript row for a user-attached image (F03); never dumps bytes. */
|
|
16
|
+
export declare function imageAttachmentLine(attachment: {
|
|
17
|
+
fileName: string;
|
|
18
|
+
bytes: number;
|
|
19
|
+
}): string;
|
|
15
20
|
export declare function formatElapsedTime(milliseconds: number): string;
|
|
16
21
|
export declare function formatElapsedTimeWhole(milliseconds: number): string;
|
|
17
22
|
export declare function toolOutputDetails(value: unknown): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatBytes } from '../../utils/format.js';
|
|
1
2
|
export function compact(value, maxLength = 180) {
|
|
2
3
|
let text;
|
|
3
4
|
if (value instanceof Error) {
|
|
@@ -18,9 +19,11 @@ export function compact(value, maxLength = 180) {
|
|
|
18
19
|
export function toolCallSummary(toolName, input) {
|
|
19
20
|
const data = input;
|
|
20
21
|
if (toolName === 'bash' && typeof data?.command === 'string') {
|
|
21
|
-
const
|
|
22
|
-
return `bash $ ${data.command}${
|
|
22
|
+
const mode = data.background === true ? ' (background)' : typeof data.timeoutSeconds === 'number' ? ` (timeout ${data.timeoutSeconds}s)` : '';
|
|
23
|
+
return `bash $ ${data.command}${mode}`;
|
|
23
24
|
}
|
|
25
|
+
if (toolName === 'process' && typeof data?.action === 'string')
|
|
26
|
+
return `process ${data.action}${typeof data.backgroundId === 'string' ? ` ${data.backgroundId}` : ''}`;
|
|
24
27
|
if (toolName === 'grep' && typeof data?.pattern === 'string') {
|
|
25
28
|
const path = typeof data.path === 'string' && data.path !== '.' ? ` in ${data.path}` : '';
|
|
26
29
|
const glob = typeof data.glob === 'string' ? ` (${data.glob})` : '';
|
|
@@ -42,9 +45,12 @@ export function toolCallSummary(toolName, input) {
|
|
|
42
45
|
return `replaceLines ${data.path}:${data.startLine}-${data.endLine}`;
|
|
43
46
|
if ((toolName === 'editFile' || toolName === 'replaceLines') && (data == null || (typeof data === 'object' && Object.keys(data).length === 0)))
|
|
44
47
|
return toolName;
|
|
45
|
-
if (toolName === 'subagent'
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
+
if (toolName === 'subagent') {
|
|
49
|
+
const task = typeof data?.objective === 'string' ? data.objective : typeof data?.task === 'string' ? data.task : undefined;
|
|
50
|
+
if (task) {
|
|
51
|
+
const taskPreview = task.length > 60 ? `${task.slice(0, 60).trimEnd()}…` : task;
|
|
52
|
+
return `subagent "${taskPreview}"`;
|
|
53
|
+
}
|
|
48
54
|
}
|
|
49
55
|
if (toolName === 'writeTasks') {
|
|
50
56
|
const tasks = Array.isArray(data?.tasks) ? data.tasks : [];
|
|
@@ -64,6 +70,9 @@ export function toolResultSummary(event) {
|
|
|
64
70
|
return `failed: ${compact(event.error ?? output?.error ?? event.output)}`;
|
|
65
71
|
if (output?.duplicateSkipped === true)
|
|
66
72
|
return 'skipped duplicate';
|
|
73
|
+
if (output?.background === true && typeof output.backgroundId === 'string') {
|
|
74
|
+
return `⏵ ${output.backgroundId} ${compact(output.command, 80)}${typeof output.pid === 'number' ? ` (pid ${output.pid})` : ''}`;
|
|
75
|
+
}
|
|
67
76
|
if (typeof output?.totalMatches === 'number') {
|
|
68
77
|
const count = output.totalMatches;
|
|
69
78
|
return count === 0 ? 'no matches' : `${output.matchCountIsLowerBound === true ? 'at least ' : ''}${count} match${count === 1 ? '' : 'es'}`;
|
|
@@ -79,6 +88,18 @@ export function toolResultSummary(event) {
|
|
|
79
88
|
: '';
|
|
80
89
|
return `exited with code ${output.code}${risk}`;
|
|
81
90
|
}
|
|
91
|
+
const resultOutput = output ?? {};
|
|
92
|
+
const capsule = typeof resultOutput.capsule === 'object' && resultOutput.capsule != null ? resultOutput.capsule : undefined;
|
|
93
|
+
if (capsule && typeof capsule.termination === 'string' && typeof capsule.deliverable === 'string') {
|
|
94
|
+
const summary = capsule.deliverable.split('\n')[0] ?? '';
|
|
95
|
+
const preview = summary.length > 120 ? `${summary.slice(0, 120).trimEnd()}…` : summary;
|
|
96
|
+
const telemetry = typeof resultOutput.telemetry === 'object' && resultOutput.telemetry != null ? resultOutput.telemetry : undefined;
|
|
97
|
+
const calls = typeof telemetry?.toolCallCount === 'number' ? telemetry.toolCallCount : typeof resultOutput.toolCallCount === 'number' ? resultOutput.toolCallCount : 0;
|
|
98
|
+
const durationMs = typeof telemetry?.durationMs === 'number' ? telemetry.durationMs : resultOutput.durationMs;
|
|
99
|
+
const duration = typeof durationMs === 'number' ? ` in ${(durationMs / 1000).toFixed(1)}s` : '';
|
|
100
|
+
const meta = calls > 0 ? ` (${calls} call${calls === 1 ? '' : 's'}${duration})` : '';
|
|
101
|
+
return `${capsule.termination}${capsule.usable === false ? ' · unusable' : ''}${capsule.truncated === true ? ' · truncated' : ''}${meta}: ${preview}`;
|
|
102
|
+
}
|
|
82
103
|
if (typeof output?.status === 'string' && typeof output?.summary === 'string') {
|
|
83
104
|
const summary = output.summary.split('\n')[0] ?? '';
|
|
84
105
|
const preview = summary.length > 120 ? `${summary.slice(0, 120).trimEnd()}…` : summary;
|
|
@@ -101,6 +122,8 @@ export function toolResultSummary(event) {
|
|
|
101
122
|
return compact(output.summary, 120);
|
|
102
123
|
}
|
|
103
124
|
if (output.ok) {
|
|
125
|
+
if (output.noChange === true)
|
|
126
|
+
return 'No changes made';
|
|
104
127
|
if (typeof output.addedLines === 'number' || typeof output.removedLines === 'number') {
|
|
105
128
|
const added = typeof output.addedLines === 'number' ? output.addedLines : 0;
|
|
106
129
|
const removed = typeof output.removedLines === 'number' ? output.removedLines : 0;
|
|
@@ -123,7 +146,9 @@ export function busyToolLabel(toolName, input) {
|
|
|
123
146
|
const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
|
|
124
147
|
switch (toolName) {
|
|
125
148
|
case 'bash':
|
|
126
|
-
return 'Running command';
|
|
149
|
+
return data?.background === true ? 'Starting background process' : 'Running command';
|
|
150
|
+
case 'process':
|
|
151
|
+
return 'Managing background process';
|
|
127
152
|
case 'grep':
|
|
128
153
|
return 'Searching';
|
|
129
154
|
case 'listFiles':
|
|
@@ -154,6 +179,10 @@ export function busyToolLabel(toolName, input) {
|
|
|
154
179
|
export function formatSeconds(milliseconds) {
|
|
155
180
|
return `${(milliseconds / 1000).toFixed(1)}s`;
|
|
156
181
|
}
|
|
182
|
+
/** Compact transcript row for a user-attached image (F03); never dumps bytes. */
|
|
183
|
+
export function imageAttachmentLine(attachment) {
|
|
184
|
+
return `🖼 ${attachment.fileName} (${formatBytes(attachment.bytes)})`;
|
|
185
|
+
}
|
|
157
186
|
export function formatElapsedTime(milliseconds) {
|
|
158
187
|
const totalSeconds = Math.max(0, milliseconds / 1000);
|
|
159
188
|
const wholeSeconds = Math.floor(totalSeconds);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { listLogs, summarizeLog } from '../../core/log/llmLog.js';
|
|
2
|
-
|
|
3
|
-
if (bytes < 1024)
|
|
4
|
-
return `${bytes} B`;
|
|
5
|
-
if (bytes < 1024 * 1024)
|
|
6
|
-
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
7
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
8
|
-
}
|
|
2
|
+
import { formatBytes } from '../../utils/format.js';
|
|
9
3
|
export async function handleLogsCommand(args, ctx) {
|
|
10
4
|
const id = args.trim();
|
|
11
5
|
if (!id) {
|
|
@@ -3,7 +3,7 @@ export async function handleModelCommand(value, ctx) {
|
|
|
3
3
|
if (value === '/model') {
|
|
4
4
|
ctx.setModelProviderFilter?.(undefined);
|
|
5
5
|
ctx.setMode('model');
|
|
6
|
-
ctx.addSystemMessage('Choose a model. Selecting a model also sets its provider.');
|
|
6
|
+
ctx.addSystemMessage('Choose a model, or select "add models" to fetch a provider\'s model list and pick from it. Selecting a model also sets its provider.');
|
|
7
7
|
return 'handled';
|
|
8
8
|
}
|
|
9
9
|
if (value === '/model list') {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordered, backpressure-aware NDJSON sink for headless `--output stream-json`
|
|
3
|
+
* (RH-006). Writes are serialized in arrival order and each line awaits stdout
|
|
4
|
+
* drain when the stream returns false, so a slow/redirected consumer cannot
|
|
5
|
+
* reorder or lose events and the final result line always lands after all
|
|
6
|
+
* streamed events.
|
|
7
|
+
*/
|
|
8
|
+
export interface WritableSink {
|
|
9
|
+
write(chunk: string): boolean;
|
|
10
|
+
once(event: 'drain' | 'error', listener: () => void): unknown;
|
|
11
|
+
off?(event: 'drain' | 'error', listener: () => void): unknown;
|
|
12
|
+
}
|
|
13
|
+
export declare class NdjsonSink {
|
|
14
|
+
private readonly stream;
|
|
15
|
+
private tail;
|
|
16
|
+
private firstError;
|
|
17
|
+
constructor(stream: WritableSink);
|
|
18
|
+
/** Serialize one value as an NDJSON line, preserving order and awaiting drain. */
|
|
19
|
+
write(value: unknown): Promise<void>;
|
|
20
|
+
private writeLine;
|
|
21
|
+
/** Wait for every queued line to finish writing. Rejects on the first error. */
|
|
22
|
+
flush(): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export class NdjsonSink {
|
|
2
|
+
stream;
|
|
3
|
+
tail = Promise.resolve();
|
|
4
|
+
firstError;
|
|
5
|
+
constructor(stream) {
|
|
6
|
+
this.stream = stream;
|
|
7
|
+
}
|
|
8
|
+
/** Serialize one value as an NDJSON line, preserving order and awaiting drain. */
|
|
9
|
+
write(value) {
|
|
10
|
+
const line = `${JSON.stringify(value)}\n`;
|
|
11
|
+
const next = this.tail.then(() => this.writeLine(line));
|
|
12
|
+
// Keep the chain draining even if one line fails; surface the first error on flush.
|
|
13
|
+
this.tail = next.catch(error => {
|
|
14
|
+
this.firstError ??= error instanceof Error ? error : new Error(String(error));
|
|
15
|
+
});
|
|
16
|
+
return next;
|
|
17
|
+
}
|
|
18
|
+
writeLine(line) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
if (this.stream.write(line))
|
|
21
|
+
return resolve();
|
|
22
|
+
const onDrain = () => { cleanup(); resolve(); };
|
|
23
|
+
const onError = (error) => { cleanup(); reject(error ?? new Error('stream error')); };
|
|
24
|
+
const cleanup = () => {
|
|
25
|
+
this.stream.off?.('drain', onDrain);
|
|
26
|
+
this.stream.off?.('error', onError);
|
|
27
|
+
};
|
|
28
|
+
this.stream.once('drain', onDrain);
|
|
29
|
+
this.stream.once('error', onError);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** Wait for every queued line to finish writing. Rejects on the first error. */
|
|
33
|
+
async flush() {
|
|
34
|
+
await this.tail;
|
|
35
|
+
if (this.firstError)
|
|
36
|
+
throw this.firstError;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { HazeProviderSettings, HazeSettings } from '../../config/settings.js';
|
|
2
2
|
import type { Mode } from './chatModes.js';
|
|
3
|
+
import type { HarvestedModelLimits } from '../../config/modelDiscovery.js';
|
|
4
|
+
/**
|
|
5
|
+
* Warning when a `chatgpt-codex` provider's configured URL diverges from the
|
|
6
|
+
* canonical endpoint (F-14): requests always route to the registered OAuth
|
|
7
|
+
* client's endpoint, so a hand-edited URL (e.g. a proxy) is silently ignored.
|
|
8
|
+
*/
|
|
9
|
+
export declare function chatgptCodexUrlWarning(provider: HazeProviderSettings): string | undefined;
|
|
3
10
|
type WizardPatch = {
|
|
4
11
|
settingsPatch?: Partial<HazeSettings>;
|
|
5
12
|
message: string;
|
|
@@ -7,8 +14,8 @@ type WizardPatch = {
|
|
|
7
14
|
providers?: HazeProviderSettings[];
|
|
8
15
|
models?: string[];
|
|
9
16
|
};
|
|
10
|
-
export declare function providerAppendModels(settings: HazeSettings, providerName: string | undefined, modelsValue: string): WizardPatch;
|
|
11
|
-
export declare function providerFinishAdd(settings: HazeSettings, draft: Partial<HazeProviderSettings>, modelsValue: string): WizardPatch;
|
|
17
|
+
export declare function providerAppendModels(settings: HazeSettings, providerName: string | undefined, modelsValue: string, discoveredLimits?: HarvestedModelLimits): WizardPatch;
|
|
18
|
+
export declare function providerFinishAdd(settings: HazeSettings, draft: Partial<HazeProviderSettings>, modelsValue: string, discoveredLimits?: HarvestedModelLimits): WizardPatch;
|
|
12
19
|
export declare function providerRemoveModels(settings: HazeSettings, providerName: string | undefined, modelsValue: string): WizardPatch & {
|
|
13
20
|
remaining?: string[];
|
|
14
21
|
removed?: string[];
|
|
@@ -18,6 +25,7 @@ export declare function providerRemoveModels(settings: HazeSettings, providerNam
|
|
|
18
25
|
export declare function providerRemove(settings: HazeSettings, providerName: string | undefined): WizardPatch & {
|
|
19
26
|
wasActiveProvider?: boolean;
|
|
20
27
|
};
|
|
28
|
+
export declare function providerSetImageCapable(settings: HazeSettings, providerName: string | undefined, enabled: boolean): WizardPatch;
|
|
21
29
|
export declare function providerSetKey(settings: HazeSettings, providerName: string | undefined, value: string): WizardPatch & {
|
|
22
30
|
key?: string;
|
|
23
31
|
};
|