@denizokcu/haze 0.10.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 +77 -1
- package/README.md +66 -25
- 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/contextReport.js +2 -0
- package/dist/cli/chat/fileMentionSuggestions.js +3 -2
- 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 +9 -0
- 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/wizardDispatch.js +111 -12
- package/dist/cli/commands/chat.d.ts +5 -0
- package/dist/cli/commands/chat.js +203 -101
- 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.js +2 -0
- 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 +37 -4
- package/dist/cli/commands/runCommand.d.ts +3 -0
- package/dist/cli/commands/runCommand.js +117 -11
- 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/toolCallRecovery.d.ts +2 -0
- package/dist/cli/commands/streaming/toolCallRecovery.js +24 -0
- package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +29 -0
- 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/turnOutcome.d.ts +17 -0
- package/dist/cli/commands/streaming/turnOutcome.js +27 -11
- package/dist/cli/commands/streaming.d.ts +70 -3
- package/dist/cli/commands/streaming.js +491 -77
- package/dist/cli/commands/wizardActions.d.ts +1 -0
- package/dist/cli/commands/wizardActions.js +1 -0
- package/dist/cli/commands/wizardPrompts.js +7 -1
- package/dist/cli/commands/wizardSuggestions.js +5 -3
- package/dist/cli/index.js +68 -22
- package/dist/cli/terminalTitle.js +1 -1
- package/dist/config/modelDiscovery.d.ts +51 -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 +36 -0
- package/dist/config/settings.js +9 -0
- package/dist/core/agent/budgets.d.ts +10 -0
- package/dist/core/agent/budgets.js +10 -0
- package/dist/core/agent/compaction.d.ts +38 -0
- package/dist/core/agent/compaction.js +92 -17
- package/dist/core/agent/completionController.d.ts +230 -0
- package/dist/core/agent/completionController.js +287 -0
- package/dist/core/agent/contextBudget.d.ts +38 -0
- package/dist/core/agent/contextBudget.js +60 -7
- package/dist/core/agent/events.d.ts +74 -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 +8 -0
- package/dist/core/agent/toolOutputStore.js +10 -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 +75 -0
- package/dist/core/agent/workState.js +120 -9
- 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/limits/byteBudgets.d.ts +2 -0
- package/dist/core/limits/byteBudgets.js +2 -0
- package/dist/core/limits/textBudgets.d.ts +2 -0
- package/dist/core/limits/textBudgets.js +2 -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.js +8 -7
- package/dist/core/process/runBoundedProcess.d.ts +8 -2
- package/dist/core/process/runBoundedProcess.js +15 -6
- package/dist/core/safety/missingExecutable.d.ts +42 -0
- package/dist/core/safety/missingExecutable.js +77 -0
- package/dist/core/session/sessionStore.d.ts +37 -0
- package/dist/core/session/sessionStore.js +215 -51
- package/dist/core/subagent/contracts.d.ts +4 -0
- package/dist/core/subagent/contracts.js +1 -0
- package/dist/core/subagent/subagentCoordinator.d.ts +4 -0
- package/dist/core/subagent/subagentCoordinator.js +32 -2
- package/dist/core/subagent/subagentRunner.js +17 -37
- package/dist/llm/client.d.ts +17 -1
- package/dist/llm/client.js +82 -14
- package/dist/llm/hazeTools.d.ts +554 -80
- package/dist/llm/hazeTools.js +103 -24
- package/dist/llm/lsp.d.ts +24 -4
- package/dist/llm/lsp.js +72 -11
- 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 +3 -0
- package/dist/llm/requestContext.js +7 -4
- package/dist/llm/systemPrompt.d.ts +11 -0
- package/dist/llm/systemPrompt.js +12 -6
- package/dist/llm/toolResultTypes.d.ts +8 -1
- package/dist/llm/tools/bashTool.d.ts +48 -16
- package/dist/llm/tools/bashTool.js +5 -0
- 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 +16 -0
- package/dist/llm/tools/fileToolShared.d.ts +4 -3
- package/dist/llm/tools/fileToolShared.js +16 -21
- package/dist/llm/tools/gitIgnore.d.ts +49 -0
- package/dist/llm/tools/gitIgnore.js +129 -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 +1 -1
- package/dist/llm/tools/toolContext.js +61 -32
- package/dist/llm/webFetch.d.ts +17 -0
- package/dist/llm/webFetch.js +64 -97
- 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 +104 -0
- package/dist/utils/buildInfo.js +253 -0
- package/dist/utils/fs.d.ts +9 -0
- package/dist/utils/fs.js +87 -25
- package/dist/utils/openPath.d.ts +2 -2
- package/dist/utils/openPath.js +19 -6
- 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,5 +1,4 @@
|
|
|
1
1
|
import type { HazeSettings } from '../../config/settings.js';
|
|
2
2
|
import type { ContextFile } from '../../config/contextFiles.js';
|
|
3
3
|
export declare function startupContextInfo(contextFiles: ContextFile[]): string;
|
|
4
|
-
export declare function startupInputTips(): string;
|
|
5
4
|
export declare function startupProviderInfo(settings: HazeSettings): string;
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { activeModel, configuredProviders, providerHasKey } from '../../config/providers.js';
|
|
2
2
|
import { configuredLspServers } from '../../config/lspSettings.js';
|
|
3
3
|
import { configuredMcpServers } from '../../config/mcpSettings.js';
|
|
4
|
+
import { chatgptCodexUrlWarning } from '../commands/providerWizard.js';
|
|
4
5
|
export function startupContextInfo(contextFiles) {
|
|
5
6
|
const lines = contextFiles.map(file => `- ${file.path}`);
|
|
6
7
|
return [
|
|
7
|
-
'Context files
|
|
8
|
+
'Context files included with the first request:',
|
|
8
9
|
...(lines.length > 0 ? lines : ['- none']),
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export function startupInputTips() {
|
|
12
|
-
return [
|
|
13
|
-
'Type @path/to/image.png (or any path with a /) to send images to models with vision capabilities.',
|
|
14
|
-
'',
|
|
15
|
-
'Tab through files in your working directory after typing @',
|
|
16
|
-
'',
|
|
17
|
-
'Mentioning a file or directory with @path, or any /-containing path, lets the model read it, even outside the working directory.',
|
|
18
|
-
'',
|
|
19
|
-
'Edits and writes stay inside the workspace.',
|
|
10
|
+
'Nested AGENTS.md and CLAUDE.md files load when haze works in their subfolders.',
|
|
20
11
|
].join('\n');
|
|
21
12
|
}
|
|
22
13
|
export function startupProviderInfo(settings) {
|
|
@@ -26,12 +17,12 @@ export function startupProviderInfo(settings) {
|
|
|
26
17
|
const enabledLsp = lspServers.filter(server => server.enabled !== false);
|
|
27
18
|
const lspLine = enabledLsp.length > 0
|
|
28
19
|
? `- LSP: ${enabledLsp.length} configured (${enabledLsp.map(server => server.name).join(', ')}; tools appear only when the command is installed)`
|
|
29
|
-
: '- LSP:
|
|
20
|
+
: '- LSP: not configured (optional: use /lsp presets, then /lsp add typescript)';
|
|
30
21
|
const mcpServers = configuredMcpServers(settings);
|
|
31
22
|
const enabledMcp = mcpServers.filter(server => server.enabled !== false);
|
|
32
23
|
const mcpLine = enabledMcp.length > 0
|
|
33
24
|
? `- MCP: ${enabledMcp.length} configured (${enabledMcp.map(server => server.name).join(', ')}; tools load each turn)`
|
|
34
|
-
: '- MCP:
|
|
25
|
+
: '- MCP: not configured (optional: use /mcp add context7 for current library docs)';
|
|
35
26
|
if (!selection) {
|
|
36
27
|
return [
|
|
37
28
|
'Provider configuration',
|
|
@@ -51,12 +42,17 @@ export function startupProviderInfo(settings) {
|
|
|
51
42
|
const baseURL = selection.provider.url;
|
|
52
43
|
const apiKeySource = providerHasKey(settings, selection.provider) ? `provider ${selection.provider.name}` : 'missing';
|
|
53
44
|
const provider = selection.provider.name;
|
|
45
|
+
const authLine = selection.provider.kind === 'chatgpt-codex'
|
|
46
|
+
? '- Authentication: ChatGPT OAuth credentials stored separately'
|
|
47
|
+
: `- API key: ${apiKeySource === 'missing' ? 'not configured; local providers may not need one' : `configured via ${apiKeySource}`}`;
|
|
48
|
+
const divergence = chatgptCodexUrlWarning(selection.provider);
|
|
54
49
|
return [
|
|
55
50
|
'Provider configuration',
|
|
56
51
|
`- Provider: ${provider}`,
|
|
57
52
|
`- Model: ${model} (${modelSource})`,
|
|
58
53
|
`- Base URL: ${baseURL} (settings)`,
|
|
59
|
-
|
|
54
|
+
...(divergence ? [divergence] : []),
|
|
55
|
+
authLine,
|
|
60
56
|
`- Configured providers: ${configuredCount}`,
|
|
61
57
|
lspLine,
|
|
62
58
|
mcpLine,
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import { updateSettings } from '../../config/settings.js';
|
|
3
|
-
import {
|
|
3
|
+
import { removeProviderAuth, setProviderAuth } from '../../config/providerAuth.js';
|
|
4
|
+
import { findProvider, modelSelector, resolveModelSelector, upsertProvider } from '../../config/providers.js';
|
|
4
5
|
import { discoverProviderModels } from '../../config/modelDiscovery.js';
|
|
5
6
|
import { removeLspServer } from '../../config/lspSettings.js';
|
|
6
7
|
import { removeMcpServer } from '../../config/mcpSettings.js';
|
|
7
|
-
import { findPreset, PROVIDER_PRESETS } from '../../config/providerPresets.js';
|
|
8
|
+
import { findPreset, presetModelLimitsForModels, PROVIDER_PRESETS } from '../../config/providerPresets.js';
|
|
9
|
+
import { ollamaModelLimits } from '../../config/modelDiscovery.js';
|
|
10
|
+
import { isLocalProviderUrl } from '../../llm/client.js';
|
|
11
|
+
import { FALLBACK_LOCAL_CONTEXT_TOKENS } from '../../core/agent/contextBudget.js';
|
|
8
12
|
import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
|
|
9
13
|
import { createSkill, toSkillDirName } from '../../skills/builder/SkillBuilder.js';
|
|
10
14
|
import { PROVIDER_ACTIONS, PROVIDER_CHOICES, MODEL_CHOICES, SERVER_CHOICES } from '../commands/wizardActions.js';
|
|
11
15
|
import { captureLspName } from '../commands/wizardPrompts.js';
|
|
12
16
|
import { finishLspCustomResult, selectLspActionResult, selectLspPresetResult, selectLspServerResult } from '../commands/lspWizard.js';
|
|
13
17
|
import { finishMcpCustomResult, selectMcpActionResult, selectMcpPresetResult, selectMcpServerResult, setMcpServerKeyResult } from '../commands/mcpWizard.js';
|
|
14
|
-
import { providerActionResult, providerAppendModels, providerFinishAdd, providerRemove, providerRemoveModels, providerSetImageCapable, providerSetKey } from '../commands/providerWizard.js';
|
|
18
|
+
import { chatgptCodexUrlWarning, providerActionResult, providerAppendModels, providerFinishAdd, providerRemove, providerRemoveModels, providerSetImageCapable, providerSetKey } from '../commands/providerWizard.js';
|
|
15
19
|
import { selectSkillActionResult, selectSkillResult } from '../commands/skillWizard.js';
|
|
16
20
|
import { captureSkillDescription as captureSkillDescriptionResult, skillCreationFailure, skillCreationMessage } from '../commands/skillCreation.js';
|
|
17
21
|
import { skillConfirmRemoveResult as skillConfirmRemove } from '../commands/skillConfirmRemove.js';
|
|
18
|
-
import { isYesConfirmation } from '../commands/wizardInput.js';
|
|
22
|
+
import { commaList, isYesConfirmation } from '../commands/wizardInput.js';
|
|
19
23
|
import { startupProviderInfo } from './startupInfo.js';
|
|
20
24
|
import { SESSION_ACTIONS } from '../commands/sessionPicker.js';
|
|
25
|
+
import { openBrowser, startChatGptBrowserLogin } from '../../llm/openaiCodexOAuth.js';
|
|
21
26
|
export function createWizardDispatch(deps) {
|
|
22
27
|
const { setMode, setSettings, showMessage } = deps;
|
|
28
|
+
// Limits harvested from the provider's own /models listing during the most
|
|
29
|
+
// recent discovery. Written through with the models being added (provider-
|
|
30
|
+
// specific and fresher than the static preset catalog) and cleared when a
|
|
31
|
+
// flow restarts, so stale harvests never leak into a later add.
|
|
32
|
+
let lastDiscoveredLimits = {};
|
|
23
33
|
// Shared applier for the uniform wizard result shape (CR-006 / useSettingsPatch).
|
|
24
34
|
async function applyResult(result) {
|
|
25
35
|
if (result.settingsPatch)
|
|
@@ -71,7 +81,46 @@ export function createWizardDispatch(deps) {
|
|
|
71
81
|
}
|
|
72
82
|
deps.setSelectedProviderName(provider.name);
|
|
73
83
|
setMode('providerAction');
|
|
74
|
-
|
|
84
|
+
// Surface canonical-endpoint divergence for ChatGPT sign-in providers up
|
|
85
|
+
// front: a hand-edited URL is silently ignored by the Codex fetch (F-14).
|
|
86
|
+
const divergence = chatgptCodexUrlWarning(provider);
|
|
87
|
+
showMessage(`${provider.name}: choose an action.${divergence ? `\n${divergence}` : ''}`);
|
|
88
|
+
}
|
|
89
|
+
async function loginWithChatGpt(input) {
|
|
90
|
+
deps.setBusyLabel('Waiting for ChatGPT sign-in');
|
|
91
|
+
deps.setBusy(true);
|
|
92
|
+
let login;
|
|
93
|
+
try {
|
|
94
|
+
login = await startChatGptBrowserLogin();
|
|
95
|
+
showMessage(`Complete ChatGPT sign-in in your browser.\nIf it does not open, visit:\n${login.url}`);
|
|
96
|
+
await openBrowser(login.url);
|
|
97
|
+
const auth = await login.complete();
|
|
98
|
+
await setProviderAuth(input.name, auth);
|
|
99
|
+
if (input.existing) {
|
|
100
|
+
showMessage(`ChatGPT sign-in updated for ${input.name}.`);
|
|
101
|
+
deps.setSelectedProviderName(undefined);
|
|
102
|
+
setMode('chat');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const provider = { name: input.name, url: input.url, kind: 'chatgpt-codex', models: input.models, ...presetModelLimitsForModels({ name: input.name, url: input.url }, input.models) };
|
|
106
|
+
const next = await updateSettings({ providers: upsertProvider(deps.settings, provider), provider: provider.name, model: undefined });
|
|
107
|
+
setSettings(next);
|
|
108
|
+
deps.setProviderDraft({});
|
|
109
|
+
deps.setSuggestedModels([]);
|
|
110
|
+
deps.setModelProviderFilter(provider.name);
|
|
111
|
+
setMode('model');
|
|
112
|
+
showMessage(`ChatGPT connected as ${provider.name}. Choose a model explicitly.`);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
await login?.close().catch(() => undefined);
|
|
116
|
+
showMessage(`ChatGPT sign-in failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
117
|
+
deps.setProviderDraft({});
|
|
118
|
+
setMode('chat');
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
deps.setBusy(false);
|
|
122
|
+
deps.setBusyLabel(deps.idleBusyLabel);
|
|
123
|
+
}
|
|
75
124
|
}
|
|
76
125
|
async function selectPreset(presetId) {
|
|
77
126
|
if (presetId === PROVIDER_CHOICES.custom) {
|
|
@@ -94,9 +143,12 @@ export function createWizardDispatch(deps) {
|
|
|
94
143
|
deps.setProviderDraft({});
|
|
95
144
|
return;
|
|
96
145
|
}
|
|
97
|
-
deps.setProviderDraft({ name: existingName, url: preset.baseUrl });
|
|
146
|
+
deps.setProviderDraft({ name: existingName, url: preset.baseUrl, ...(preset.auth === 'chatgpt-oauth' ? { kind: 'chatgpt-codex' } : {}) });
|
|
98
147
|
deps.setSuggestedModels(preset.suggestedModels ?? []);
|
|
99
|
-
if (preset.
|
|
148
|
+
if (preset.auth === 'chatgpt-oauth') {
|
|
149
|
+
await loginWithChatGpt({ name: existingName, url: preset.baseUrl, models: preset.suggestedModels ?? [] });
|
|
150
|
+
}
|
|
151
|
+
else if (preset.needsApiKey) {
|
|
100
152
|
setMode('providerAddKey');
|
|
101
153
|
const keyHint = preset.apiKeyHint ?? (preset.apiKeyEnvVar ? `commonly ${preset.apiKeyEnvVar}` : undefined);
|
|
102
154
|
showMessage(`${preset.name} (${preset.baseUrl})\nAPI key${keyHint ? ` (${keyHint})` : ''}?`);
|
|
@@ -149,7 +201,16 @@ export function createWizardDispatch(deps) {
|
|
|
149
201
|
}
|
|
150
202
|
if (action === PROVIDER_ACTIONS.addModels) {
|
|
151
203
|
deps.setSelectedProviderName(provider.name);
|
|
152
|
-
|
|
204
|
+
if (provider.kind === 'chatgpt-codex') {
|
|
205
|
+
setMode('providerAppendModels');
|
|
206
|
+
showMessage(`Comma-separated supported Codex model names to add to ${provider.name}?`);
|
|
207
|
+
}
|
|
208
|
+
else
|
|
209
|
+
await discoverModelsFor(provider, `Comma-separated model names to add to ${provider.name}?`);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (action === PROVIDER_ACTIONS.signInChatGpt && provider.kind === 'chatgpt-codex') {
|
|
213
|
+
await loginWithChatGpt({ name: provider.name, url: provider.url, models: provider.models, existing: provider });
|
|
153
214
|
return;
|
|
154
215
|
}
|
|
155
216
|
const actionResult = providerActionResult(action, provider);
|
|
@@ -170,6 +231,13 @@ export function createWizardDispatch(deps) {
|
|
|
170
231
|
setMode('chat');
|
|
171
232
|
return;
|
|
172
233
|
}
|
|
234
|
+
const existing = findProvider(deps.settings, target.name);
|
|
235
|
+
if (target.kind === 'chatgpt-codex' || existing?.kind === 'chatgpt-codex') {
|
|
236
|
+
deps.setSelectedProviderName(target.name);
|
|
237
|
+
setMode(existing ? 'providerAppendModels' : 'providerAddModels');
|
|
238
|
+
showMessage(fallbackPrompt);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
173
241
|
deps.setBusyLabel(`Discovering models on ${target.name}`);
|
|
174
242
|
deps.setBusy(true);
|
|
175
243
|
let result;
|
|
@@ -182,11 +250,12 @@ export function createWizardDispatch(deps) {
|
|
|
182
250
|
}
|
|
183
251
|
if (result.status === 'ok') {
|
|
184
252
|
deps.setDiscoveredModels(result.models);
|
|
253
|
+
lastDiscoveredLimits = result.modelLimits ?? {};
|
|
185
254
|
setMode('modelPick');
|
|
186
255
|
showMessage(`Found ${result.models.length} model${result.models.length === 1 ? '' : 's'} on ${target.name}. Choose one to add, or select "${MODEL_CHOICES.enterModelNames}".`);
|
|
187
256
|
return;
|
|
188
257
|
}
|
|
189
|
-
|
|
258
|
+
lastDiscoveredLimits = {};
|
|
190
259
|
setMode(existing ? 'providerAppendModels' : 'providerAddModels');
|
|
191
260
|
showMessage(`Could not list models on ${target.name} (${result.error}).\n${fallbackPrompt}`);
|
|
192
261
|
}
|
|
@@ -233,6 +302,7 @@ export function createWizardDispatch(deps) {
|
|
|
233
302
|
if (value === MODEL_CHOICES.enterModelNames) {
|
|
234
303
|
deps.setDiscoveredModels([]);
|
|
235
304
|
deps.setSuggestedModels([]);
|
|
305
|
+
lastDiscoveredLimits = {};
|
|
236
306
|
if (provider) {
|
|
237
307
|
setMode('providerAppendModels');
|
|
238
308
|
showMessage(`Comma-separated model names to add to ${provider.name}?`);
|
|
@@ -259,13 +329,35 @@ export function createWizardDispatch(deps) {
|
|
|
259
329
|
// Preset match by URL restores curated hints on the cloud key-step path.
|
|
260
330
|
const preset = PROVIDER_PRESETS.find(candidate => draft.url === candidate.baseUrl);
|
|
261
331
|
const hint = preset?.suggestedModels?.length ? ` Example: ${preset.suggestedModels.join(', ')}` : '';
|
|
262
|
-
await discoverModelsFor({ name: draft.name, url: draft.url, key: draft.key }, `Comma-separated model names?${hint}`);
|
|
332
|
+
await discoverModelsFor({ name: draft.name, url: draft.url, key: draft.key, kind: draft.kind }, `Comma-separated model names?${hint}`);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Native Ollama enrichment at save time (the one place that knows the exact
|
|
336
|
+
* model ids being added): /v1/models reports nothing for Ollama, but /api/ps
|
|
337
|
+
* exposes the actually-loaded runtime context and /api/show the model's
|
|
338
|
+
* declared maximum. Probed only for the user's loopback server; the cap for
|
|
339
|
+
* a declared maximum (which may exceed the VRAM-sized effective window) is
|
|
340
|
+
* the user's own local fallback setting, defaulting to 32K. Failures are
|
|
341
|
+
* ignored — providers that are not Ollama simply 404 the /api/* paths.
|
|
342
|
+
*/
|
|
343
|
+
async function localNativeLimits(url, models) {
|
|
344
|
+
if (!url || !isLocalProviderUrl(url) || models.length === 0)
|
|
345
|
+
return {};
|
|
346
|
+
const conservativeCap = deps.settings.localContextWindowFallbackTokens ?? FALLBACK_LOCAL_CONTEXT_TOKENS;
|
|
347
|
+
return await ollamaModelLimits({ baseUrl: url, models, conservativeCap }).catch(() => ({}));
|
|
263
348
|
}
|
|
264
349
|
async function appendModelsToProvider(modelsValue) {
|
|
265
|
-
const
|
|
350
|
+
const provider = deps.selectedProviderName ? findProvider(deps.settings, deps.selectedProviderName) : undefined;
|
|
351
|
+
if (provider) {
|
|
352
|
+
const native = await localNativeLimits(provider.url, commaList(modelsValue));
|
|
353
|
+
if (Object.keys(native).length > 0)
|
|
354
|
+
lastDiscoveredLimits = { ...lastDiscoveredLimits, ...native };
|
|
355
|
+
}
|
|
356
|
+
const result = providerAppendModels(deps.settings, deps.selectedProviderName, modelsValue, lastDiscoveredLimits);
|
|
266
357
|
if (!result.provider) {
|
|
267
358
|
deps.setDiscoveredModels([]);
|
|
268
359
|
deps.setSuggestedModels([]);
|
|
360
|
+
lastDiscoveredLimits = {};
|
|
269
361
|
showMessage(result.message);
|
|
270
362
|
setMode('chat');
|
|
271
363
|
return;
|
|
@@ -279,18 +371,23 @@ export function createWizardDispatch(deps) {
|
|
|
279
371
|
deps.setSelectedProviderName(undefined);
|
|
280
372
|
deps.setDiscoveredModels([]);
|
|
281
373
|
deps.setSuggestedModels([]);
|
|
374
|
+
lastDiscoveredLimits = {};
|
|
282
375
|
deps.setModelProviderFilter(result.provider.name);
|
|
283
376
|
setMode('model');
|
|
284
377
|
showMessage(result.message);
|
|
285
378
|
}
|
|
286
379
|
async function finishProviderAdd(modelsValue) {
|
|
287
|
-
const
|
|
380
|
+
const native = await localNativeLimits(deps.providerDraft.url, commaList(modelsValue));
|
|
381
|
+
if (Object.keys(native).length > 0)
|
|
382
|
+
lastDiscoveredLimits = { ...lastDiscoveredLimits, ...native };
|
|
383
|
+
const result = providerFinishAdd(deps.settings, deps.providerDraft, modelsValue, lastDiscoveredLimits);
|
|
288
384
|
if (!result.provider || !result.settingsPatch) {
|
|
289
385
|
showMessage(result.message);
|
|
290
386
|
setMode('chat');
|
|
291
387
|
deps.setProviderDraft({});
|
|
292
388
|
deps.setDiscoveredModels([]);
|
|
293
389
|
deps.setSuggestedModels([]);
|
|
390
|
+
lastDiscoveredLimits = {};
|
|
294
391
|
return;
|
|
295
392
|
}
|
|
296
393
|
const next = await updateSettings(result.settingsPatch);
|
|
@@ -298,6 +395,7 @@ export function createWizardDispatch(deps) {
|
|
|
298
395
|
deps.setProviderDraft({});
|
|
299
396
|
deps.setDiscoveredModels([]);
|
|
300
397
|
deps.setSuggestedModels([]);
|
|
398
|
+
lastDiscoveredLimits = {};
|
|
301
399
|
deps.setModelProviderFilter(result.provider.name);
|
|
302
400
|
setMode('model');
|
|
303
401
|
showMessage(result.message);
|
|
@@ -350,6 +448,7 @@ export function createWizardDispatch(deps) {
|
|
|
350
448
|
}
|
|
351
449
|
const result = providerRemove(deps.settings, deps.selectedProviderName);
|
|
352
450
|
const next = await updateSettings(result.settingsPatch ?? {});
|
|
451
|
+
await removeProviderAuth(provider.name);
|
|
353
452
|
setSettings(next);
|
|
354
453
|
deps.setSelectedProviderName(undefined);
|
|
355
454
|
setMode('chat');
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
interface ChatOptions {
|
|
2
2
|
debug?: boolean;
|
|
3
3
|
version?: string;
|
|
4
|
+
/** Safe build provenance (commit, build time) recorded into session headers. */
|
|
5
|
+
build?: {
|
|
6
|
+
commit?: string;
|
|
7
|
+
builtAt?: string;
|
|
8
|
+
};
|
|
4
9
|
continueSession?: boolean;
|
|
5
10
|
resumeSessionId?: string;
|
|
6
11
|
noSession?: boolean;
|