@denizokcu/haze 0.10.0 → 1.0.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 +100 -1
- package/README.md +77 -27
- 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 +2 -2
- package/dist/cli/chat/chatMetrics.js +1 -1
- package/dist/cli/chat/contextReport.js +2 -0
- package/dist/cli/chat/fileMentionSuggestions.js +3 -2
- package/dist/cli/chat/inputSuggestions.d.ts +8 -16
- package/dist/cli/chat/inputSuggestions.js +9 -41
- 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 -4
- package/dist/cli/chat/messages.js +218 -35
- package/dist/cli/chat/sessionLifecycle.d.ts +11 -1
- package/dist/cli/chat/sessionLifecycle.js +64 -14
- package/dist/cli/chat/sessionRecorder.js +75 -7
- package/dist/cli/chat/startupInfo.d.ts +0 -1
- package/dist/cli/chat/startupInfo.js +11 -15
- package/dist/cli/chat/turnState.d.ts +1 -1
- package/dist/cli/chat/wizardDispatch.d.ts +90 -28
- package/dist/cli/chat/wizardDispatch.js +349 -133
- package/dist/cli/commands/chat.d.ts +5 -0
- package/dist/cli/commands/chat.js +216 -172
- package/dist/cli/commands/chatModes.d.ts +8 -1
- package/dist/cli/commands/chatModes.js +9 -44
- package/dist/cli/commands/commands.d.ts +2 -0
- package/dist/cli/commands/commands.js +10 -5
- package/dist/cli/commands/doctor.d.ts +19 -0
- package/dist/cli/commands/doctor.js +76 -0
- package/dist/cli/commands/formatters.d.ts +3 -3
- package/dist/cli/commands/formatters.js +8 -25
- package/dist/cli/commands/ndjsonSink.d.ts +23 -0
- package/dist/cli/commands/ndjsonSink.js +38 -0
- package/dist/cli/commands/providerWizard.d.ts +9 -2
- package/dist/cli/commands/providerWizard.js +39 -7
- package/dist/cli/commands/runCommand.d.ts +3 -0
- package/dist/cli/commands/runCommand.js +117 -11
- package/dist/cli/commands/serverWizard.d.ts +34 -0
- package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
- package/dist/cli/commands/skillsWizard.d.ts +41 -0
- package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
- package/dist/cli/commands/streaming/abortCause.d.ts +25 -0
- package/dist/cli/commands/streaming/abortCause.js +16 -0
- package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
- package/dist/cli/commands/streaming/agentAttempt.js +79 -0
- package/dist/cli/commands/streaming/assistantText.js +9 -2
- package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
- package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
- package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
- package/dist/cli/commands/streaming/attemptSetup.js +167 -0
- 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 +130 -0
- package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
- package/dist/cli/commands/streaming/stallRecovery.js +105 -0
- package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
- package/dist/cli/commands/streaming/streamLoop.js +448 -0
- package/dist/cli/commands/streaming/toolCallRecovery.d.ts +16 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +80 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -1
- package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -4
- package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
- package/dist/cli/commands/streaming/toolResultState.js +29 -7
- package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
- package/dist/cli/commands/streaming/turnRuntime.js +6 -0
- package/dist/cli/commands/streaming.d.ts +65 -9
- package/dist/cli/commands/streaming.js +133 -430
- package/dist/cli/commands/wizardFlow.d.ts +334 -0
- package/dist/cli/commands/wizardFlow.js +377 -0
- package/dist/cli/contextReport.js +3 -0
- package/dist/cli/index.js +68 -22
- package/dist/cli/terminalTitle.js +1 -1
- package/dist/config/contextFiles.js +9 -3
- package/dist/config/inputHistory.d.ts +0 -1
- package/dist/config/inputHistory.js +1 -1
- package/dist/config/modelDiscovery.d.ts +36 -0
- package/dist/config/modelDiscovery.js +164 -1
- 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 +39 -7
- package/dist/config/providerPresets.js +371 -100
- package/dist/config/providers.js +2 -0
- package/dist/config/settings.d.ts +43 -0
- package/dist/config/settings.js +12 -0
- package/dist/config/skillSettings.js +4 -4
- package/dist/config/updateCheck.d.ts +0 -1
- package/dist/config/updateCheck.js +1 -1
- package/dist/core/agent/budgets.d.ts +73 -1
- package/dist/core/agent/budgets.js +94 -1
- package/dist/core/agent/compaction.d.ts +38 -0
- package/dist/core/agent/compaction.js +92 -17
- package/dist/core/agent/completionController.d.ts +224 -0
- package/dist/core/agent/completionController.js +296 -0
- package/dist/core/agent/contextBudget.d.ts +36 -2
- package/dist/core/agent/contextBudget.js +62 -9
- package/dist/core/agent/errors.d.ts +0 -1
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/events.d.ts +78 -0
- package/dist/core/agent/goalPolicy.d.ts +47 -0
- package/dist/core/agent/goalPolicy.js +106 -0
- package/dist/core/agent/reasoningPolicy.d.ts +31 -0
- package/dist/core/agent/reasoningPolicy.js +27 -0
- package/dist/core/agent/requestAssembly.d.ts +2 -2
- package/dist/core/agent/requestAssembly.js +16 -4
- package/dist/core/agent/toolCapabilities.d.ts +27 -0
- package/dist/core/agent/toolCapabilities.js +58 -0
- package/dist/core/agent/toolOutputStore.d.ts +8 -0
- package/dist/core/agent/toolOutputStore.js +11 -11
- package/dist/core/agent/toolResults.d.ts +12 -0
- package/dist/core/agent/toolResults.js +38 -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 +81 -3
- package/dist/core/agent/workState.js +176 -10
- package/dist/core/attachments/imageAttachments.js +90 -42
- package/dist/core/deadline.d.ts +27 -0
- package/dist/core/deadline.js +74 -0
- package/dist/core/io/boundedRead.js +1 -1
- package/dist/core/limits.d.ts +51 -0
- package/dist/core/limits.js +51 -0
- package/dist/core/log/llmLog.js +8 -1
- package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
- package/dist/core/persistence/orderedFileWriter.js +16 -2
- package/dist/core/process/backgroundRegistry.d.ts +2 -3
- package/dist/core/process/backgroundRegistry.js +15 -10
- package/dist/core/process/runBoundedProcess.d.ts +8 -2
- package/dist/core/process/runBoundedProcess.js +15 -6
- package/dist/core/process/userShell.d.ts +16 -0
- package/dist/core/process/userShell.js +59 -0
- package/dist/core/safety/missingExecutable.d.ts +42 -0
- package/dist/core/safety/missingExecutable.js +77 -0
- package/dist/core/safety/shellClassifier.d.ts +11 -0
- package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
- package/dist/core/safety/urlGuard.d.ts +1 -1
- package/dist/core/session/sessionSlimming.d.ts +0 -3
- package/dist/core/session/sessionSlimming.js +2 -3
- package/dist/core/session/sessionStore.d.ts +38 -0
- package/dist/core/session/sessionStore.js +242 -59
- package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
- package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
- package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
- package/dist/core/shellOutput/registry.d.ts +2 -0
- package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
- package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
- package/dist/core/subagent/contracts.d.ts +6 -14
- package/dist/core/subagent/contracts.js +4 -3
- package/dist/core/subagent/executionProfiles.js +2 -2
- package/dist/core/subagent/subagentCoordinator.d.ts +4 -0
- package/dist/core/subagent/subagentCoordinator.js +32 -2
- package/dist/core/subagent/subagentRunner.js +19 -40
- package/dist/core/toolOutput/reduction.d.ts +0 -12
- package/dist/core/toolOutput/reduction.js +1 -1
- package/dist/core/validation/outputParser.d.ts +2 -2
- package/dist/llm/client.d.ts +17 -1
- package/dist/llm/client.js +86 -14
- package/dist/llm/hazeTools.d.ts +693 -204
- package/dist/llm/hazeTools.js +110 -28
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp/client.d.ts +45 -0
- package/dist/llm/lsp/client.js +195 -0
- package/dist/llm/lsp/pool.d.ts +23 -0
- package/dist/llm/lsp/pool.js +86 -0
- package/dist/llm/lsp/protocol.d.ts +64 -0
- package/dist/llm/lsp/protocol.js +128 -0
- package/dist/llm/lsp/requests.d.ts +94 -0
- package/dist/llm/lsp/requests.js +119 -0
- package/dist/llm/lspTools.d.ts +5653 -33
- package/dist/llm/lspTools.js +152 -80
- package/dist/llm/openaiCodex.d.ts +1 -0
- package/dist/llm/openaiCodex.js +43 -0
- package/dist/llm/openaiCodexOAuth.d.ts +51 -0
- package/dist/llm/openaiCodexOAuth.js +217 -0
- package/dist/llm/requestContext.d.ts +7 -0
- package/dist/llm/requestContext.js +30 -4
- package/dist/llm/systemPrompt.d.ts +12 -0
- package/dist/llm/systemPrompt.js +24 -11
- package/dist/llm/toolResultTypes.d.ts +7 -14
- package/dist/llm/toolResultTypes.js +1 -4
- package/dist/llm/tools/editMatch.d.ts +14 -9
- package/dist/llm/tools/editMatch.js +73 -1
- package/dist/llm/tools/failures.d.ts +2 -0
- package/dist/llm/tools/failures.js +1 -0
- package/dist/llm/tools/fetchTool.d.ts +16 -0
- package/dist/llm/tools/fetchTool.js +1 -1
- package/dist/llm/tools/fileToolShared.d.ts +8 -5
- package/dist/llm/tools/fileToolShared.js +22 -23
- package/dist/llm/tools/gitIgnore.d.ts +42 -0
- package/dist/llm/tools/gitIgnore.js +247 -0
- package/dist/llm/tools/grepParse.d.ts +2 -1
- package/dist/llm/tools/grepRunner.d.ts +1 -1
- package/dist/llm/tools/grepRunner.js +2 -2
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -3
- package/dist/llm/tools/processTool.d.ts +16 -16
- package/dist/llm/tools/processTool.js +1 -1
- package/dist/llm/tools/readRecovery.d.ts +8 -0
- package/dist/llm/tools/readRecovery.js +135 -0
- package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +171 -123
- package/dist/llm/tools/{bashTool.js → shellTool.js} +20 -14
- package/dist/llm/tools/toolContext.d.ts +1 -1
- package/dist/llm/tools/toolContext.js +66 -37
- package/dist/llm/tools/workspaceFile.d.ts +0 -1
- package/dist/llm/tools/workspaceFile.js +1 -6
- package/dist/llm/webFetch.d.ts +18 -1
- package/dist/llm/webFetch.js +64 -97
- package/dist/skills/SkillLoader.d.ts +1 -11
- package/dist/skills/SkillLoader.js +1 -2
- package/dist/skills/types.d.ts +2 -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 +8 -1
- package/dist/ui/components/TextInput.js +6 -2
- package/dist/ui/theme.d.ts +4 -3
- package/dist/ui/theme.js +5 -4
- package/dist/utils/buildInfo.d.ts +97 -0
- package/dist/utils/buildInfo.js +244 -0
- package/dist/utils/fs.d.ts +11 -0
- package/dist/utils/fs.js +91 -26
- package/dist/utils/openPath.d.ts +2 -2
- package/dist/utils/openPath.js +19 -6
- package/dist/utils/path.d.ts +2 -1
- package/dist/utils/path.js +6 -2
- 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 +28 -21
- package/dist/cli/commands/lspWizard.d.ts +0 -14
- package/dist/cli/commands/lspWizard.js +0 -44
- package/dist/cli/commands/mcpWizard.d.ts +0 -15
- package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
- package/dist/cli/commands/skillConfirmRemove.js +0 -20
- package/dist/cli/commands/skillCreation.d.ts +0 -12
- package/dist/cli/commands/skillCreation.js +0 -14
- package/dist/cli/commands/skillWizard.d.ts +0 -17
- package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
- package/dist/cli/commands/streaming/idleTimer.js +0 -24
- package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -10
- package/dist/cli/commands/streaming/turnOutcome.js +0 -13
- package/dist/cli/commands/wizardActions.d.ts +0 -46
- package/dist/cli/commands/wizardActions.js +0 -46
- package/dist/cli/commands/wizardInput.d.ts +0 -4
- package/dist/cli/commands/wizardInput.js +0 -19
- package/dist/cli/commands/wizardPrompts.d.ts +0 -22
- package/dist/cli/commands/wizardPrompts.js +0 -52
- package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
- package/dist/cli/commands/wizardSuggestions.js +0 -188
- package/dist/cli/commands/wizardTransition.d.ts +0 -37
- package/dist/cli/commands/wizardTransition.js +0 -43
- package/dist/core/bashOutput/ansi.d.ts +0 -1
- package/dist/core/bashOutput/ansi.js +0 -7
- package/dist/core/bashOutput/registry.d.ts +0 -4
- package/dist/core/goal/completionPolicy.d.ts +0 -2
- package/dist/core/goal/completionPolicy.js +0 -7
- package/dist/core/goal/requestClassifier.d.ts +0 -3
- package/dist/core/goal/requestClassifier.js +0 -18
- package/dist/core/goal/sessionGoal.d.ts +0 -8
- package/dist/core/goal/sessionGoal.js +0 -30
- package/dist/core/limits/byteBudgets.d.ts +0 -18
- package/dist/core/limits/byteBudgets.js +0 -18
- package/dist/core/limits/textBudgets.d.ts +0 -23
- package/dist/core/limits/textBudgets.js +0 -23
- package/dist/core/safety/bashClassifier.d.ts +0 -10
- package/dist/llm/lsp.d.ts +0 -129
- package/dist/llm/lsp.js +0 -307
- package/dist/ui/components/ErrorView.d.ts +0 -4
- package/dist/ui/components/ErrorView.js +0 -7
- package/dist/utils/yaml.d.ts +0 -2
- package/dist/utils/yaml.js +0 -8
- package/examples/skills/files/SKILL.md +0 -16
- package/examples/skills/files/examples/file-editing.md +0 -3
- /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
- /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
- /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { type WizardStepId } from './wizardFlow.js';
|
|
2
|
+
/**
|
|
3
|
+
* Input-mode classification derived from the wizard flow table
|
|
4
|
+
* (`wizardFlow.ts`): the `Mode` union, the picker/masked/empty-submit sets,
|
|
5
|
+
* and per-mode placeholders all follow from the step definitions, so adding a
|
|
6
|
+
* step updates every classification from its single table entry.
|
|
7
|
+
*/
|
|
8
|
+
export type Mode = 'chat' | WizardStepId;
|
|
2
9
|
/** Modes that show an always-on suggestion picker (server/preset lists). */
|
|
3
10
|
export declare const PICKER_MODES: ReadonlySet<Mode>;
|
|
4
11
|
/** Modes that mask input (secrets/API keys). */
|
|
@@ -1,49 +1,14 @@
|
|
|
1
|
+
import { WIZARD_STEPS } from './wizardFlow.js';
|
|
2
|
+
/** Wizard steps viewed through their definition type, for uniform property access. */
|
|
3
|
+
const STEPS = WIZARD_STEPS;
|
|
4
|
+
const stepIds = (steps) => steps.map(step => step.id);
|
|
1
5
|
/** Modes that show an always-on suggestion picker (server/preset lists). */
|
|
2
|
-
export const PICKER_MODES = new Set(
|
|
6
|
+
export const PICKER_MODES = new Set(stepIds(STEPS.filter(step => step.kind === 'pick')));
|
|
3
7
|
/** Modes that mask input (secrets/API keys). */
|
|
4
|
-
export const MASKED_MODES = new Set(
|
|
8
|
+
export const MASKED_MODES = new Set(stepIds(STEPS.filter(step => step.kind === 'masked-input')));
|
|
5
9
|
/** Modes where submitting an empty value is valid (optional steps). */
|
|
6
|
-
export const SUBMIT_EMPTY_MODES = new Set(
|
|
7
|
-
const PLACEHOLDERS = {
|
|
8
|
-
sessions: 'Choose a saved session',
|
|
9
|
-
sessionAction: 'Resume or fork this session',
|
|
10
|
-
provider: 'Choose provider',
|
|
11
|
-
providerAction: 'Choose provider action',
|
|
12
|
-
providerAddPreset: 'Choose a provider preset or custom',
|
|
13
|
-
model: 'Choose model, or add model',
|
|
14
|
-
modelAddProvider: 'Choose a provider to add models to',
|
|
15
|
-
modelPick: 'Choose a model to add',
|
|
16
|
-
providerAddName: 'Provider name',
|
|
17
|
-
providerAddUrl: 'https://example.com/v1',
|
|
18
|
-
providerAddKey: 'API key, or blank for local',
|
|
19
|
-
providerSetKey: 'API key',
|
|
20
|
-
providerAddModels: 'model-a, model-b',
|
|
21
|
-
providerAppendModels: 'model-a, model-b',
|
|
22
|
-
providerRemoveModels: 'model-a, model-b',
|
|
23
|
-
providerConfirmRemove: 'Type "yes" to confirm',
|
|
24
|
-
skills: 'Choose a skill or add skill',
|
|
25
|
-
skillsAction: 'show info, enable, disable, validate, or remove',
|
|
26
|
-
skillsAddName: 'Skill name (kebab-case, e.g. security-review)',
|
|
27
|
-
skillsAddScope: 'Choose this project or global',
|
|
28
|
-
skillsAddDescription: 'Describe what the skill should do',
|
|
29
|
-
skillsConfirmRemove: 'Type "yes" to confirm',
|
|
30
|
-
lsp: 'Choose LSP server or add server',
|
|
31
|
-
lspAction: 'enable, disable, or remove server',
|
|
32
|
-
lspAddPreset: 'Choose an LSP preset or custom',
|
|
33
|
-
lspAddName: 'LSP server name (e.g. typescript)',
|
|
34
|
-
lspAddCommand: 'Command (e.g. typescript-language-server --stdio)',
|
|
35
|
-
lspConfirmRemove: 'Type "yes" to confirm',
|
|
36
|
-
mcp: 'Choose MCP server or add server',
|
|
37
|
-
mcpAction: 'enable, disable, remove, or set key',
|
|
38
|
-
mcpAddPreset: 'Choose an MCP preset or custom',
|
|
39
|
-
mcpAddName: 'MCP server name (e.g. context7)',
|
|
40
|
-
mcpAddTransport: 'http, sse, or stdio',
|
|
41
|
-
mcpAddUrl: 'https://mcp.example.com/mcp',
|
|
42
|
-
mcpAddCommand: 'Command (e.g. npx -y @pkg/server)',
|
|
43
|
-
mcpAddKey: 'API key, or blank to skip',
|
|
44
|
-
mcpSetKey: 'API key',
|
|
45
|
-
mcpConfirmRemove: 'Type "yes" to confirm',
|
|
46
|
-
};
|
|
10
|
+
export const SUBMIT_EMPTY_MODES = new Set(stepIds(STEPS.filter(step => step.optional)));
|
|
47
11
|
export function placeholderForMode(mode, busy) {
|
|
48
|
-
|
|
12
|
+
const step = WIZARD_STEPS.find(candidate => candidate.id === mode);
|
|
13
|
+
return step?.placeholder ?? (busy ? 'Queue a follow-up, or Esc to interrupt' : 'Ask haze to help build your app');
|
|
49
14
|
}
|
|
@@ -13,6 +13,8 @@ export type CommandContext = {
|
|
|
13
13
|
resumeSession?: (id?: string) => Promise<void>;
|
|
14
14
|
sessionInfo?: () => string;
|
|
15
15
|
compactConversation?: (instructions?: string) => boolean;
|
|
16
|
+
/** LLM-summarized /compact (F-09); preferred over `compactConversation` when present. */
|
|
17
|
+
compactConversationLlm?: (instructions?: string) => Promise<boolean>;
|
|
16
18
|
runAgentTurn: (prompt: string, displayValue?: string, options?: TurnExecutionOptions) => Promise<void>;
|
|
17
19
|
refreshContextFiles: () => Promise<ContextFile[]>;
|
|
18
20
|
updateSettings: (patch: Partial<HazeSettings>) => Promise<HazeSettings>;
|
|
@@ -33,15 +33,20 @@ const SLASH_COMMANDS = [
|
|
|
33
33
|
await ctx.newSession();
|
|
34
34
|
else
|
|
35
35
|
ctx.addSystemMessage('Session persistence is unavailable.'); return HANDLED; } },
|
|
36
|
-
{ match: exactOrArgs('/compact'), run: (args, ctx) => {
|
|
37
|
-
ctx.
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
} },
|
|
40
45
|
{ match: exact('/clear'), run: async (_args, ctx) => { await ctx.clearConversation(); await clearTasks(); return HANDLED; } },
|
|
41
46
|
{ match: exactOrArgs('/logs'), run: async (args, ctx) => await handleLogsCommand(args, ctx) },
|
|
42
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; } },
|
|
43
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; } },
|
|
44
|
-
{ 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; } },
|
|
45
50
|
{ match: exact('/settings'), run: async (_args, ctx) => { ctx.addSystemMessage(await formatSettingsSummary(ctx.settings, ctx.contextFiles)); return HANDLED; } },
|
|
46
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; } },
|
|
47
52
|
{ match: exact('/init'), run: async (_args, ctx) => await handleInitCommand(ctx) },
|
|
@@ -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.goalSupervisorAvailable) {
|
|
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
|
+
}
|
|
@@ -19,9 +19,8 @@ export declare function imageAttachmentLine(attachment: {
|
|
|
19
19
|
}): string;
|
|
20
20
|
export declare function formatElapsedTime(milliseconds: number): string;
|
|
21
21
|
export declare function formatElapsedTimeWhole(milliseconds: number): string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export interface ContextReportTool {
|
|
22
|
+
type ContextReportCategory = 'builtin' | 'lsp' | 'skill' | 'subagent' | 'mcp';
|
|
23
|
+
interface ContextReportTool {
|
|
25
24
|
name: string;
|
|
26
25
|
tokens: number;
|
|
27
26
|
category: ContextReportCategory;
|
|
@@ -47,3 +46,4 @@ export interface ContextReportData {
|
|
|
47
46
|
}
|
|
48
47
|
/** Render a detailed, /context-style token breakdown. Pure for testability. */
|
|
49
48
|
export declare function formatContextReport(data: ContextReportData): string;
|
|
49
|
+
export {};
|
|
@@ -18,9 +18,9 @@ export function compact(value, maxLength = 180) {
|
|
|
18
18
|
}
|
|
19
19
|
export function toolCallSummary(toolName, input) {
|
|
20
20
|
const data = input;
|
|
21
|
-
if (toolName === '
|
|
21
|
+
if (toolName === 'shell' && typeof data?.command === 'string') {
|
|
22
22
|
const mode = data.background === true ? ' (background)' : typeof data.timeoutSeconds === 'number' ? ` (timeout ${data.timeoutSeconds}s)` : '';
|
|
23
|
-
return `
|
|
23
|
+
return `shell $ ${data.command}${mode}`;
|
|
24
24
|
}
|
|
25
25
|
if (toolName === 'process' && typeof data?.action === 'string')
|
|
26
26
|
return `process ${data.action}${typeof data.backgroundId === 'string' ? ` ${data.backgroundId}` : ''}`;
|
|
@@ -60,7 +60,9 @@ export function toolCallSummary(toolName, input) {
|
|
|
60
60
|
return `lspWorkspaceSymbols "${data.query}"`;
|
|
61
61
|
if (toolName === 'lspSymbols' && typeof data?.path === 'string')
|
|
62
62
|
return `lspSymbols ${data.path}`;
|
|
63
|
-
if (
|
|
63
|
+
if (toolName === 'lspDiagnostics' && typeof data?.path === 'string')
|
|
64
|
+
return `lspDiagnostics ${data.path}`;
|
|
65
|
+
if ((toolName === 'lspDefinition' || toolName === 'lspTypeDefinition' || toolName === 'lspImplementation' || toolName === 'lspReferences') && typeof data?.path === 'string')
|
|
64
66
|
return `${toolName} ${data.path}:${data.line}:${data.column}`;
|
|
65
67
|
return `${toolName} ${compact(input)}`;
|
|
66
68
|
}
|
|
@@ -122,6 +124,8 @@ export function toolResultSummary(event) {
|
|
|
122
124
|
return compact(output.summary, 120);
|
|
123
125
|
}
|
|
124
126
|
if (output.ok) {
|
|
127
|
+
if (output.noChange === true)
|
|
128
|
+
return 'No changes made';
|
|
125
129
|
if (typeof output.addedLines === 'number' || typeof output.removedLines === 'number') {
|
|
126
130
|
const added = typeof output.addedLines === 'number' ? output.addedLines : 0;
|
|
127
131
|
const removed = typeof output.removedLines === 'number' ? output.removedLines : 0;
|
|
@@ -143,7 +147,7 @@ export function busyToolLabel(toolName, input) {
|
|
|
143
147
|
const data = input;
|
|
144
148
|
const pathLabel = typeof data?.path === 'string' ? compact(data.path, 80) : undefined;
|
|
145
149
|
switch (toolName) {
|
|
146
|
-
case '
|
|
150
|
+
case 'shell':
|
|
147
151
|
return data?.background === true ? 'Starting background process' : 'Running command';
|
|
148
152
|
case 'process':
|
|
149
153
|
return 'Managing background process';
|
|
@@ -207,27 +211,6 @@ export function formatElapsedTimeWhole(milliseconds) {
|
|
|
207
211
|
return `${minutes}m ${seconds}s`;
|
|
208
212
|
return `${seconds}s`;
|
|
209
213
|
}
|
|
210
|
-
export function toolOutputDetails(value) {
|
|
211
|
-
if (!value || typeof value !== 'object')
|
|
212
|
-
return '';
|
|
213
|
-
const output = value;
|
|
214
|
-
const stdout = output.stdout?.text?.trim();
|
|
215
|
-
const stderr = output.stderr?.text?.trim();
|
|
216
|
-
const meta = [
|
|
217
|
-
output.cwd ? `cwd: ${output.cwd}` : '',
|
|
218
|
-
output.classification?.riskLevel ? `classification: ${output.classification.riskLevel}${output.classification.reason ? ` — ${output.classification.reason}` : ''}` : '',
|
|
219
|
-
output.validationSummary?.summaryText ? `validation: ${output.validationSummary.summaryText}${output.validationSummary.suggestedNextStep ? `\nnext: ${output.validationSummary.suggestedNextStep}` : ''}` : '',
|
|
220
|
-
].filter(Boolean).join('\n');
|
|
221
|
-
const parts = [
|
|
222
|
-
meta,
|
|
223
|
-
stdout ? `stdout:\n${compact(stdout, 1200)}` : '',
|
|
224
|
-
stderr ? `stderr:\n${compact(stderr, 1200)}` : '',
|
|
225
|
-
].filter(Boolean);
|
|
226
|
-
if (parts.length === 0)
|
|
227
|
-
return '';
|
|
228
|
-
const truncated = output.stdout?.truncated || output.stderr?.truncated;
|
|
229
|
-
return `${parts.join('\n\n')}${truncated ? '\n… output truncated' : ''}`;
|
|
230
|
-
}
|
|
231
214
|
const CONTEXT_CATEGORY_LABEL = {
|
|
232
215
|
builtin: 'Built-in',
|
|
233
216
|
lsp: 'LSP',
|
|
@@ -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[];
|
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
import { configuredProviders, findProvider, upsertProvider } from '../../config/providers.js';
|
|
2
|
-
import { PROVIDER_ACTIONS } from './
|
|
3
|
-
import { commaList } from './wizardInput.js';
|
|
2
|
+
import { PROVIDER_ACTIONS, commaList } from './wizardFlow.js';
|
|
4
3
|
import { assertCredentialedEndpointSecure } from '../../config/endpointSecurity.js';
|
|
5
|
-
|
|
4
|
+
import { presetModelLimitsForModels } from '../../config/providerPresets.js';
|
|
5
|
+
import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
|
|
6
|
+
/**
|
|
7
|
+
* Warning when a `chatgpt-codex` provider's configured URL diverges from the
|
|
8
|
+
* canonical endpoint (F-14): requests always route to the registered OAuth
|
|
9
|
+
* client's endpoint, so a hand-edited URL (e.g. a proxy) is silently ignored.
|
|
10
|
+
*/
|
|
11
|
+
export function chatgptCodexUrlWarning(provider) {
|
|
12
|
+
if (provider.kind !== 'chatgpt-codex' || provider.url === CHATGPT_CODEX_BASE_URL)
|
|
13
|
+
return undefined;
|
|
14
|
+
return `Note: ${provider.name} uses ChatGPT sign-in, which always sends requests to ${CHATGPT_CODEX_BASE_URL}. The configured URL (${provider.url}) is ignored for requests.`;
|
|
15
|
+
}
|
|
16
|
+
/** Merge order for per-model limits on add: preset-curated < live-discovered < existing user settings. */
|
|
17
|
+
function mergedModelLimits(curated, models, discovered, existing) {
|
|
18
|
+
const discoveredSubset = {};
|
|
19
|
+
for (const model of models)
|
|
20
|
+
if (discovered?.[model])
|
|
21
|
+
discoveredSubset[model] = discovered[model];
|
|
22
|
+
const merged = { ...curated, ...discoveredSubset, ...existing };
|
|
23
|
+
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
24
|
+
}
|
|
25
|
+
export function providerAppendModels(settings, providerName, modelsValue, discoveredLimits) {
|
|
6
26
|
const provider = providerName ? findProvider(settings, providerName) : undefined;
|
|
7
27
|
const models = commaList(modelsValue);
|
|
8
28
|
if (!provider)
|
|
9
29
|
return { message: 'No provider selected.' };
|
|
10
30
|
if (models.length === 0)
|
|
11
31
|
return { provider, models, message: 'Enter at least one model name.' };
|
|
12
|
-
|
|
32
|
+
// Preset-curated limits (models.dev) flow into settings so request budgeting
|
|
33
|
+
// uses the real window without the user configuring anything. Live values the
|
|
34
|
+
// provider itself reported in /models discovery win over the static catalog
|
|
35
|
+
// (this is the only source that knows a local server's configured window);
|
|
36
|
+
// existing user-configured keys always win over both.
|
|
37
|
+
const curatedLimits = presetModelLimitsForModels({ name: provider.name, url: provider.url }, models);
|
|
38
|
+
const modelLimits = mergedModelLimits(curatedLimits, models, discoveredLimits, provider.modelLimits);
|
|
39
|
+
const nextProvider = { ...provider, models: [...new Set([...provider.models, ...models])], ...(modelLimits ? { modelLimits } : {}) };
|
|
13
40
|
return {
|
|
14
41
|
provider,
|
|
15
42
|
models,
|
|
@@ -17,7 +44,7 @@ export function providerAppendModels(settings, providerName, modelsValue) {
|
|
|
17
44
|
message: `Added ${models.length} model${models.length === 1 ? '' : 's'} to ${provider.name}. Choose a model.`,
|
|
18
45
|
};
|
|
19
46
|
}
|
|
20
|
-
export function providerFinishAdd(settings, draft, modelsValue) {
|
|
47
|
+
export function providerFinishAdd(settings, draft, modelsValue, discoveredLimits) {
|
|
21
48
|
const models = commaList(modelsValue);
|
|
22
49
|
if (!draft.name || !draft.url || models.length === 0) {
|
|
23
50
|
return { models, message: 'Provider name, URL, and at least one model are required.' };
|
|
@@ -28,17 +55,22 @@ export function providerFinishAdd(settings, draft, modelsValue) {
|
|
|
28
55
|
catch (error) {
|
|
29
56
|
return { models, message: error instanceof Error ? error.message : String(error) };
|
|
30
57
|
}
|
|
58
|
+
const curatedLimits = presetModelLimitsForModels({ name: draft.name, url: draft.url }, models);
|
|
59
|
+
const modelLimits = mergedModelLimits(curatedLimits, models, discoveredLimits, undefined);
|
|
31
60
|
const provider = {
|
|
32
61
|
name: draft.name,
|
|
33
62
|
url: draft.url,
|
|
34
63
|
...(draft.key ? { key: draft.key } : {}),
|
|
64
|
+
...(draft.kind ? { kind: draft.kind } : {}),
|
|
35
65
|
models: [...new Set(models)],
|
|
66
|
+
...(modelLimits ? { modelLimits } : {}),
|
|
36
67
|
};
|
|
68
|
+
const divergence = chatgptCodexUrlWarning(provider);
|
|
37
69
|
return {
|
|
38
70
|
provider,
|
|
39
71
|
models,
|
|
40
72
|
settingsPatch: { providers: upsertProvider(settings, provider), provider: provider.name },
|
|
41
|
-
message: `Added provider ${provider.name}. Choose a model
|
|
73
|
+
message: `Added provider ${provider.name}. Choose a model.${divergence ? ` ${divergence}` : ''}`,
|
|
42
74
|
};
|
|
43
75
|
}
|
|
44
76
|
export function providerRemoveModels(settings, providerName, modelsValue) {
|
|
@@ -130,7 +162,7 @@ export function providerActionResult(action, provider) {
|
|
|
130
162
|
return { message: '', selectedName: undefined, mode: 'model' };
|
|
131
163
|
if (action === PROVIDER_ACTIONS.addModels)
|
|
132
164
|
return { message: `Comma-separated model names to add to ${provider.name}?`, mode: 'providerAppendModels' };
|
|
133
|
-
if (action === PROVIDER_ACTIONS.
|
|
165
|
+
if (action === PROVIDER_ACTIONS.manageAccess)
|
|
134
166
|
return { message: `New API key for ${provider.name}? (current: ${provider.key ? 'saved' : 'not set'})`, mode: 'providerSetKey' };
|
|
135
167
|
if (action === PROVIDER_ACTIONS.removeModels)
|
|
136
168
|
return { message: `Comma-separated model names to remove from ${provider.name}?\nCurrent models: ${provider.models.join(', ')}`, mode: 'providerRemoveModels' };
|
|
@@ -5,6 +5,7 @@ export interface HeadlessOptions {
|
|
|
5
5
|
resumeSessionId?: string;
|
|
6
6
|
output: HeadlessOutput;
|
|
7
7
|
debug?: boolean;
|
|
8
|
+
timeout?: string;
|
|
8
9
|
}
|
|
9
10
|
/** Pinned, documented usage shape emitted in `--output json` (avoids leaking internal estimates). */
|
|
10
11
|
export interface HeadlessUsage {
|
|
@@ -14,4 +15,6 @@ export interface HeadlessUsage {
|
|
|
14
15
|
cacheWriteTokens: number;
|
|
15
16
|
reasoningTokens: number;
|
|
16
17
|
}
|
|
18
|
+
/** Parse a `--timeout` duration like `30s`, `10m`, `2h`, or raw ms. Throws on invalid input. */
|
|
19
|
+
export declare function parseTurnTimeoutMs(raw: string | undefined): number | undefined;
|
|
17
20
|
export declare function runHeadless(options: HeadlessOptions): Promise<number>;
|