@denizokcu/haze 1.2.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -1
- package/README.md +23 -10
- package/SECURITY.md +1 -1
- package/bin/haze.js +27 -7
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +7 -0
- package/dist/cli/chat/BusyBar.js +8 -0
- package/dist/cli/chat/DynamicFrame.d.ts +37 -0
- package/dist/cli/chat/DynamicFrame.js +43 -0
- package/dist/cli/chat/busyIndicator.d.ts +3 -1
- package/dist/cli/chat/busyIndicator.js +11 -9
- package/dist/cli/chat/chatMetrics.d.ts +1 -1
- package/dist/cli/chat/chatMetrics.js +3 -3
- package/dist/cli/chat/inputSuggestions.js +4 -0
- package/dist/cli/chat/liveMessages.d.ts +36 -0
- package/dist/cli/chat/liveMessages.js +64 -0
- package/dist/cli/chat/liveRegion.js +1 -1
- package/dist/cli/chat/messages.js +27 -16
- package/dist/cli/chat/sessionLifecycle.d.ts +5 -2
- package/dist/cli/chat/sessionLifecycle.js +36 -4
- package/dist/cli/chat/sessionRecorder.d.ts +2 -1
- package/dist/cli/chat/sessionRecorder.js +8 -0
- package/dist/cli/chat/shutdown.d.ts +27 -0
- package/dist/cli/chat/shutdown.js +79 -0
- package/dist/cli/chat/terminalControl.d.ts +45 -0
- package/dist/cli/chat/terminalControl.js +107 -0
- package/dist/cli/chat/tips.js +1 -0
- package/dist/cli/chat/userInput.d.ts +43 -0
- package/dist/cli/chat/userInput.js +63 -0
- package/dist/cli/chat/wizard/sessionThemeHandlers.d.ts +1 -1
- package/dist/cli/chat/wizard/sessionThemeHandlers.js +24 -1
- package/dist/cli/chat/wizard/types.d.ts +8 -1
- package/dist/cli/chat/wizardDispatch.js +1 -1
- package/dist/cli/commands/chat.js +277 -193
- package/dist/cli/commands/commandHelp.js +6 -0
- package/dist/cli/commands/commands.d.ts +8 -0
- package/dist/cli/commands/commands.js +13 -0
- package/dist/cli/commands/formatters.d.ts +1 -1
- package/dist/cli/commands/formatters.js +25 -3
- package/dist/cli/commands/logsCommand.js +21 -2
- package/dist/cli/commands/ndjsonSink.d.ts +12 -0
- package/dist/cli/commands/ndjsonSink.js +29 -0
- package/dist/cli/commands/reasoningCommand.d.ts +44 -0
- package/dist/cli/commands/reasoningCommand.js +79 -0
- package/dist/cli/commands/runCommand.d.ts +14 -0
- package/dist/cli/commands/runCommand.js +56 -22
- package/dist/cli/commands/settingsSummary.js +2 -0
- package/dist/cli/commands/streaming/agentAttempt.d.ts +3 -0
- package/dist/cli/commands/streaming/agentAttempt.js +2 -2
- package/dist/cli/commands/streaming/assistantSegments.d.ts +0 -7
- package/dist/cli/commands/streaming/assistantSegments.js +1 -1
- package/dist/cli/commands/streaming/attemptLifecycle.js +13 -9
- package/dist/cli/commands/streaming/attemptOutcome.d.ts +2 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +24 -9
- package/dist/cli/commands/streaming/attemptSetup.d.ts +4 -0
- package/dist/cli/commands/streaming/attemptSetup.js +21 -7
- package/dist/cli/commands/streaming/goalCheckpoint.d.ts +14 -1
- package/dist/cli/commands/streaming/goalCheckpoint.js +4 -2
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +9 -0
- package/dist/cli/commands/streaming/goalSupervisor.js +51 -10
- package/dist/cli/commands/streaming/prepareStep.d.ts +0 -3
- package/dist/cli/commands/streaming/prepareStep.js +14 -5
- package/dist/cli/commands/streaming/streamLoop.d.ts +5 -0
- package/dist/cli/commands/streaming/streamLoop.js +3 -0
- package/dist/cli/commands/streaming/toolPartHandlers.js +6 -0
- package/dist/cli/commands/streaming.d.ts +8 -3
- package/dist/cli/commands/streaming.js +46 -21
- package/dist/cli/commands/wizardFlow.d.ts +10 -0
- package/dist/cli/commands/wizardFlow.js +34 -5
- package/dist/cli/index.js +22 -2
- package/dist/config/contextFiles.d.ts +9 -0
- package/dist/config/contextFiles.js +21 -1
- package/dist/config/modelCatalog.d.ts +3 -0
- package/dist/config/modelCatalog.js +29 -0
- package/dist/config/modelDiscovery.js +68 -5
- package/dist/config/providerPresets.d.ts +1 -1
- package/dist/config/providerPresets.js +42 -3
- package/dist/config/settings.d.ts +14 -6
- package/dist/config/settings.js +16 -1
- package/dist/core/agent/budgets.d.ts +13 -17
- package/dist/core/agent/budgets.js +15 -19
- package/dist/core/agent/completionController.d.ts +14 -2
- package/dist/core/agent/completionController.js +48 -3
- package/dist/core/agent/events.d.ts +2 -1
- package/dist/core/agent/goalPolicy.d.ts +17 -0
- package/dist/core/agent/goalPolicy.js +53 -6
- package/dist/core/agent/projectPreflight.d.ts +2 -0
- package/dist/core/agent/projectPreflight.js +56 -0
- package/dist/core/agent/reasoningPolicy.d.ts +76 -10
- package/dist/core/agent/reasoningPolicy.js +72 -9
- package/dist/core/agent/toolCapabilities.d.ts +3 -3
- package/dist/core/agent/toolCapabilities.js +31 -7
- package/dist/core/agent/workState.d.ts +14 -4
- package/dist/core/agent/workState.js +229 -34
- package/dist/core/deadline.js +22 -24
- package/dist/core/providerContracts.d.ts +29 -0
- package/dist/core/providerContracts.js +1 -0
- package/dist/core/safety/secretPaths.js +10 -7
- package/dist/core/safety/shellClassifier.d.ts +2 -0
- package/dist/core/safety/shellClassifier.js +9 -1
- package/dist/core/session/sessionReport.d.ts +33 -0
- package/dist/core/session/sessionReport.js +121 -0
- package/dist/core/session/sessionSlimming.d.ts +2 -0
- package/dist/core/session/sessionSlimming.js +59 -4
- package/dist/core/session/sessionStore.d.ts +16 -8
- package/dist/core/session/sessionStore.js +71 -34
- package/dist/core/shellOutput/reducers/git.js +7 -2
- package/dist/core/shellOutput/reducers/validation.d.ts +1 -1
- package/dist/core/shellOutput/reducers/validation.js +14 -1
- package/dist/core/shellOutput/registry.js +3 -2
- package/dist/core/subagent/contracts.d.ts +3 -18
- package/dist/core/subagent/executionProfiles.js +4 -4
- package/dist/core/tasks/taskStorage.js +8 -1
- package/dist/core/validation/outputParser.d.ts +6 -1
- package/dist/core/validation/outputParser.js +30 -2
- package/dist/llm/client.d.ts +6 -3
- package/dist/llm/client.js +28 -11
- package/dist/llm/hazeTools.d.ts +9161 -7135
- package/dist/llm/hazeTools.js +6 -462
- package/dist/llm/lsp/client.d.ts +7 -1
- package/dist/llm/lsp/client.js +58 -9
- package/dist/llm/lsp/pool.d.ts +11 -0
- package/dist/llm/lsp/pool.js +61 -4
- package/dist/llm/lsp/protocol.d.ts +6 -23
- package/dist/llm/lsp/requests.d.ts +54 -60
- package/dist/llm/lsp/requests.js +152 -28
- package/dist/llm/lsp/symbols.d.ts +16 -0
- package/dist/llm/lsp/symbols.js +70 -0
- package/dist/llm/lsp/workspaceEdit.d.ts +43 -0
- package/dist/llm/lsp/workspaceEdit.js +117 -0
- package/dist/llm/lspTools.d.ts +7518 -2859
- package/dist/llm/lspTools.js +195 -110
- package/dist/llm/mcp.js +3 -0
- package/dist/llm/requestContext.d.ts +4 -3
- package/dist/llm/requestContext.js +9 -5
- package/dist/{core/subagent → llm}/subagentRunner.d.ts +13 -9
- package/dist/{core/subagent → llm}/subagentRunner.js +54 -49
- package/dist/llm/systemPrompt.d.ts +11 -1
- package/dist/llm/systemPrompt.js +4 -13
- package/dist/llm/tools/fetchTool.d.ts +34 -30
- package/dist/llm/tools/fileTools.d.ts +7768 -0
- package/dist/llm/tools/fileTools.js +510 -0
- package/dist/llm/tools/processTool.d.ts +34 -30
- package/dist/llm/tools/replaceInFiles.d.ts +105 -0
- package/dist/llm/tools/replaceInFiles.js +131 -0
- package/dist/llm/tools/shellTool.d.ts +34 -30
- package/dist/llm/tools/shellTool.js +8 -4
- package/dist/llm/tools/storedOutputTool.d.ts +4 -0
- package/dist/llm/tools/taskTool.d.ts +4 -0
- package/dist/llm/tools/toolContext.d.ts +3 -29
- package/dist/llm/tools/toolContext.js +56 -53
- package/dist/llm/tools/toolContextState.d.ts +40 -0
- package/dist/llm/tools/toolContextState.js +34 -0
- package/dist/llm/workerContext.d.ts +7 -0
- package/dist/llm/workerContext.js +18 -1
- package/dist/skills/SkillLoader.js +30 -4
- package/dist/skills/SkillRegistry.js +3 -3
- package/dist/skills/builder/SkillBuilder.js +3 -3
- package/dist/skills/confinement.d.ts +7 -0
- package/dist/skills/confinement.js +15 -0
- package/dist/ui/codeHighlight.js +4 -4
- package/dist/ui/components/MarkdownText.js +7 -8
- package/dist/ui/components/NativeIndicators.d.ts +15 -0
- package/dist/ui/components/NativeIndicators.js +32 -0
- package/dist/ui/components/StreamingMarkdownText.d.ts +9 -0
- package/dist/ui/components/StreamingMarkdownText.js +38 -0
- package/dist/ui/components/TextInput.d.ts +7 -2
- package/dist/ui/components/TextInput.js +103 -46
- package/dist/ui/components/WizardChoices.d.ts +18 -0
- package/dist/ui/components/WizardChoices.js +32 -0
- package/dist/ui/components/useInputSuggestions.js +18 -6
- package/dist/ui/inputBuffer.js +12 -6
- package/dist/ui/textGeometry.d.ts +14 -0
- package/dist/ui/textGeometry.js +31 -0
- package/dist/utils/buildInfo.js +29 -8
- package/dist/utils/fs.js +5 -1
- package/package.json +23 -22
- /package/dist/cli/{contextReport.d.ts → contextReportCli.d.ts} +0 -0
- /package/dist/cli/{contextReport.js → contextReportCli.js} +0 -0
|
@@ -12,12 +12,25 @@
|
|
|
12
12
|
* little earlier, over-budgeting hard-fails the request. First match wins, so
|
|
13
13
|
* keep more specific patterns before broader family prefixes.
|
|
14
14
|
*
|
|
15
|
+
* Refreshed 2026-10-04 against https://models.dev/api.json. Provider-specific
|
|
16
|
+
* caps belong in provider presets/settings, not these conservative family entries.
|
|
17
|
+
*
|
|
15
18
|
* Local inference servers (localhost URLs) never consult the catalog: their
|
|
16
19
|
* effective window is set by server configuration (often far below the model's
|
|
17
20
|
* nominal window) and silent truncation there is undetectable.
|
|
18
21
|
*/
|
|
19
22
|
const MODEL_CATALOG = [
|
|
20
23
|
// ── OpenAI ────────────────────────────────────────────────────────────────
|
|
24
|
+
{ match: 'gpt-6.1-sol', contextWindowTokens: 1_050_000, maxOutputTokens: 128_000 },
|
|
25
|
+
{ match: 'gpt-6-astra', contextWindowTokens: 1_050_000, maxOutputTokens: 128_000 },
|
|
26
|
+
{ match: 'gpt-6-sol', contextWindowTokens: 1_050_000, maxOutputTokens: 128_000 },
|
|
27
|
+
{ match: 'gpt-6-luna', contextWindowTokens: 1_050_000, maxOutputTokens: 128_000 },
|
|
28
|
+
{ match: 'gpt-5.6', contextWindowTokens: 1_050_000, maxOutputTokens: 128_000 },
|
|
29
|
+
{ match: 'gpt-5.5', contextWindowTokens: 400_000, maxOutputTokens: 128_000, note: 'Poe caps this family at 400K; origin limits belong in presets' },
|
|
30
|
+
{ match: 'gpt-5.4-mini', contextWindowTokens: 400_000, maxOutputTokens: 128_000 },
|
|
31
|
+
{ match: 'gpt-5.4-nano', contextWindowTokens: 400_000, maxOutputTokens: 128_000 },
|
|
32
|
+
{ match: 'gpt-5.4', contextWindowTokens: 1_050_000, maxOutputTokens: 128_000 },
|
|
33
|
+
{ match: 'gpt-5.3-codex-spark', contextWindowTokens: 128_000, maxOutputTokens: 32_000 },
|
|
21
34
|
{ match: 'gpt-5.1-codex', contextWindowTokens: 400_000, maxOutputTokens: 128_000 },
|
|
22
35
|
{ match: 'gpt-5.1-codex-mini', contextWindowTokens: 400_000, maxOutputTokens: 128_000 },
|
|
23
36
|
{ match: 'gpt-5', contextWindowTokens: 400_000, maxOutputTokens: 128_000 },
|
|
@@ -27,6 +40,9 @@ const MODEL_CATALOG = [
|
|
|
27
40
|
{ match: 'o3', contextWindowTokens: 200_000, maxOutputTokens: 100_000 },
|
|
28
41
|
{ match: 'o1', contextWindowTokens: 200_000, maxOutputTokens: 100_000 },
|
|
29
42
|
// ── Anthropic ─────────────────────────────────────────────────────────────
|
|
43
|
+
{ match: 'claude-opus-5', contextWindowTokens: 1_000_000, maxOutputTokens: 128_000 },
|
|
44
|
+
{ match: 'claude-sonnet-5', contextWindowTokens: 1_000_000, maxOutputTokens: 128_000 },
|
|
45
|
+
{ match: 'claude-fable-5', contextWindowTokens: 1_000_000, maxOutputTokens: 128_000 },
|
|
30
46
|
{ match: 'claude-opus-4', contextWindowTokens: 200_000, maxOutputTokens: 32_000 },
|
|
31
47
|
{ match: 'claude-sonnet-4', contextWindowTokens: 200_000, maxOutputTokens: 64_000 },
|
|
32
48
|
{ match: 'claude-haiku-4', contextWindowTokens: 200_000, maxOutputTokens: 32_000 },
|
|
@@ -37,17 +53,30 @@ const MODEL_CATALOG = [
|
|
|
37
53
|
{ match: 'gemini-2.5', contextWindowTokens: 1_048_576, maxOutputTokens: 65_536 },
|
|
38
54
|
{ match: 'gemini-2.0', contextWindowTokens: 1_048_576, maxOutputTokens: 8_192 },
|
|
39
55
|
// ── xAI ───────────────────────────────────────────────────────────────────
|
|
56
|
+
{ match: 'grok-4.7', contextWindowTokens: 500_000, maxOutputTokens: 450_000, note: 'smaller OpenRouter output cap' },
|
|
57
|
+
{ match: 'grok-4.6', contextWindowTokens: 500_000, maxOutputTokens: 500_000 },
|
|
58
|
+
{ match: 'grok-4.5', contextWindowTokens: 500_000, maxOutputTokens: 500_000 },
|
|
40
59
|
{ match: 'grok-4', contextWindowTokens: 256_000, maxOutputTokens: 32_768 },
|
|
41
60
|
{ match: 'grok-3', contextWindowTokens: 131_072, maxOutputTokens: 32_768 },
|
|
42
61
|
// ── DeepSeek ──────────────────────────────────────────────────────────────
|
|
62
|
+
{ match: 'deepseek-v4.1', contextWindowTokens: 1_000_000, maxOutputTokens: 384_000, note: 'smaller gateway window and output cap' },
|
|
63
|
+
{ match: 'deepseek-v4', contextWindowTokens: 512_000, maxOutputTokens: 384_000, note: 'Together caps V4 Pro at 512K' },
|
|
64
|
+
{ match: 'deepseek-flash', contextWindowTokens: 1_000_000, maxOutputTokens: 393_216 },
|
|
43
65
|
{ match: 'deepseek-reasoner', contextWindowTokens: 128_000, maxOutputTokens: 32_768, note: 'R1/reasoner family' },
|
|
44
66
|
{ match: 'deepseek-r1', contextWindowTokens: 128_000, maxOutputTokens: 32_768 },
|
|
45
67
|
{ match: 'deepseek', contextWindowTokens: 128_000, maxOutputTokens: 8_192 },
|
|
46
68
|
// ── Alibaba / Moonshot / Zhipu / MiniMax ─────────────────────────────────
|
|
69
|
+
{ match: 'qwen3.8-max', contextWindowTokens: 262_144, maxOutputTokens: 131_072, note: 'smaller OpenCode window' },
|
|
47
70
|
{ match: 'qwen3-coder', contextWindowTokens: 262_144, maxOutputTokens: 32_768 },
|
|
48
71
|
{ match: 'qwen3', contextWindowTokens: 131_072, maxOutputTokens: 32_768, note: 'native window without YaRN extension' },
|
|
49
72
|
{ match: 'qwen', contextWindowTokens: 131_072, maxOutputTokens: 8_192 },
|
|
73
|
+
{ match: 'kimi-k3', contextWindowTokens: 1_048_576, maxOutputTokens: 131_072, note: 'smaller gateway output cap' },
|
|
50
74
|
{ match: 'kimi-k2', contextWindowTokens: 131_072, maxOutputTokens: 32_768, note: 'input-safe half of the 256K total' },
|
|
75
|
+
{ match: 'glm-5.3', contextWindowTokens: 1_000_000, maxOutputTokens: 131_072 },
|
|
76
|
+
{ match: 'glm-5.2', contextWindowTokens: 262_144, maxOutputTokens: 131_072, note: 'smaller Hugging Face window' },
|
|
77
|
+
{ match: 'glm-5.1', contextWindowTokens: 200_000, maxOutputTokens: 131_072 },
|
|
78
|
+
{ match: 'glm-5-turbo', contextWindowTokens: 200_000, maxOutputTokens: 131_072 },
|
|
79
|
+
{ match: 'glm-4.7', contextWindowTokens: 200_000, maxOutputTokens: 131_072 },
|
|
51
80
|
{ match: 'glm-4.6', contextWindowTokens: 200_000, maxOutputTokens: 32_768 },
|
|
52
81
|
{ match: 'glm-4.5', contextWindowTokens: 131_072, maxOutputTokens: 32_768 },
|
|
53
82
|
{ match: 'minimax-m2', contextWindowTokens: 204_800, maxOutputTokens: 1_048_576, note: 'output budget exceeds window in interleave mode' },
|
|
@@ -1,6 +1,45 @@
|
|
|
1
|
+
import { assertCredentialedEndpointSecure } from './endpointSecurity.js';
|
|
1
2
|
const DEFAULT_TIMEOUT_MS = 5000;
|
|
2
3
|
/** Discovery feeds a type-filtered picker; cap the stored list, not the UX. */
|
|
3
4
|
const MAX_DISCOVERED_MODELS = 500;
|
|
5
|
+
/** Redirect hops followed; each hop re-validates the credential transport policy. */
|
|
6
|
+
const MAX_DISCOVERY_REDIRECTS = 2;
|
|
7
|
+
/** CI-04: bound the JSON body before parsing so an oversized response fails loudly. */
|
|
8
|
+
const MAX_DISCOVERY_BODY_BYTES = 1_000_000;
|
|
9
|
+
/** Read a discovery response body as bounded UTF-8; an oversized body fails. */
|
|
10
|
+
async function readBodyBounded(response) {
|
|
11
|
+
if (response.body == null)
|
|
12
|
+
return await response.json();
|
|
13
|
+
const read = await readUtf8PrefixFromStream(response.body, MAX_DISCOVERY_BODY_BYTES);
|
|
14
|
+
if (read.truncated)
|
|
15
|
+
throw new Error(`endpoint response exceeds ${MAX_DISCOVERY_BODY_BYTES} bytes`);
|
|
16
|
+
return JSON.parse(read.content);
|
|
17
|
+
}
|
|
18
|
+
function readUtf8PrefixFromStream(stream, maxBytes) {
|
|
19
|
+
const reader = stream.getReader();
|
|
20
|
+
const chunks = [];
|
|
21
|
+
let received = 0;
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
const pump = () => {
|
|
24
|
+
reader.read().then(({ done, value }) => {
|
|
25
|
+
if (done) {
|
|
26
|
+
resolve({ content: Buffer.concat(chunks).toString('utf8'), truncated: false });
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
received += value.byteLength;
|
|
30
|
+
if (received > maxBytes) {
|
|
31
|
+
// Cancel and resolve truncated; the caller decides what that means.
|
|
32
|
+
void reader.cancel().catch(() => undefined);
|
|
33
|
+
resolve({ content: '', truncated: true });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
chunks.push(value);
|
|
37
|
+
pump();
|
|
38
|
+
}, reject);
|
|
39
|
+
};
|
|
40
|
+
pump();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
4
43
|
export function modelsEndpointUrl(baseUrl) {
|
|
5
44
|
return `${baseUrl.trim().replace(/\/+$/, '')}/models`;
|
|
6
45
|
}
|
|
@@ -187,12 +226,36 @@ function describeFetchError(error) {
|
|
|
187
226
|
export async function discoverProviderModels(provider, options = {}) {
|
|
188
227
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
189
228
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
229
|
+
let url = modelsEndpointUrl(provider.url);
|
|
230
|
+
// CI-01: validate before the first network call — a draft key must never be
|
|
231
|
+
// transmitted to a remote plaintext endpoint just because the user is still
|
|
232
|
+
// in a wizard. Re-checked on every redirect hop (downgrades are refused).
|
|
233
|
+
try {
|
|
234
|
+
assertCredentialedEndpointSecure(url, provider.key);
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
return { status: 'failed', error: error instanceof Error ? error.message : String(error) };
|
|
238
|
+
}
|
|
190
239
|
let response;
|
|
191
240
|
try {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
241
|
+
for (let hop = 0;; hop += 1) {
|
|
242
|
+
response = await fetchImpl(url, {
|
|
243
|
+
headers: { accept: 'application/json', ...(provider.key ? { authorization: `Bearer ${provider.key}` } : {}) },
|
|
244
|
+
redirect: 'manual',
|
|
245
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
246
|
+
});
|
|
247
|
+
const location = response.status >= 300 && response.status < 400 ? response.headers?.get('location') : null;
|
|
248
|
+
if (!location)
|
|
249
|
+
break;
|
|
250
|
+
if (hop >= MAX_DISCOVERY_REDIRECTS)
|
|
251
|
+
return { status: 'failed', error: `endpoint redirected more than ${MAX_DISCOVERY_REDIRECTS} times` };
|
|
252
|
+
const nextUrl = new URL(location, url).toString();
|
|
253
|
+
if (provider.key && new URL(nextUrl).origin !== new URL(url).origin) {
|
|
254
|
+
return { status: 'failed', error: 'credentialed endpoint redirected to a different origin' };
|
|
255
|
+
}
|
|
256
|
+
url = nextUrl;
|
|
257
|
+
assertCredentialedEndpointSecure(url, provider.key);
|
|
258
|
+
}
|
|
196
259
|
}
|
|
197
260
|
catch (error) {
|
|
198
261
|
return { status: 'failed', error: describeFetchError(error) };
|
|
@@ -201,7 +264,7 @@ export async function discoverProviderModels(provider, options = {}) {
|
|
|
201
264
|
return { status: 'failed', error: `endpoint returned HTTP ${response.status}` };
|
|
202
265
|
let body;
|
|
203
266
|
try {
|
|
204
|
-
body = await response
|
|
267
|
+
body = await readBodyBounded(response);
|
|
205
268
|
}
|
|
206
269
|
catch {
|
|
207
270
|
return { status: 'failed', error: 'endpoint returned no JSON' };
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* ones never do).
|
|
15
15
|
*
|
|
16
16
|
* `modelLimits` values are curated from models.dev (the same catalog pi and nanocoder
|
|
17
|
-
* consume; refreshed 2026-
|
|
17
|
+
* consume; recent releases refreshed 2026-10-04 from https://models.dev/api.json). They are keyed by the exact suggested model id for
|
|
18
18
|
* THIS preset: aggregators may cap context below the origin model's capability (e.g.
|
|
19
19
|
* Together serves DeepSeek-V4-Pro at 512K vs DeepSeek's own 1M), so limits never
|
|
20
20
|
* transfer between providers. When the wizard adds a suggested model, these values are
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* ones never do).
|
|
15
15
|
*
|
|
16
16
|
* `modelLimits` values are curated from models.dev (the same catalog pi and nanocoder
|
|
17
|
-
* consume; refreshed 2026-
|
|
17
|
+
* consume; recent releases refreshed 2026-10-04 from https://models.dev/api.json). They are keyed by the exact suggested model id for
|
|
18
18
|
* THIS preset: aggregators may cap context below the origin model's capability (e.g.
|
|
19
19
|
* Together serves DeepSeek-V4-Pro at 512K vs DeepSeek's own 1M), so limits never
|
|
20
20
|
* transfer between providers. When the wizard adds a suggested model, these values are
|
|
@@ -31,12 +31,22 @@ const PRESET_DEFINITIONS = [
|
|
|
31
31
|
apiKeyEnvVar: 'OPENROUTER_API_KEY',
|
|
32
32
|
models: [
|
|
33
33
|
// SOTA
|
|
34
|
+
['openai/gpt-6.1-sol', 1_050_000, 128_000],
|
|
35
|
+
['openai/gpt-6-astra', 1_050_000, 128_000],
|
|
36
|
+
['anthropic/claude-opus-5.5', 1_000_000, 128_000],
|
|
37
|
+
['anthropic/claude-sonnet-5.5', 1_000_000, 128_000],
|
|
38
|
+
['anthropic/claude-fable-5.1', 1_000_000, 128_000],
|
|
39
|
+
['google/gemini-3.8-flash', 1_048_576, 65_536],
|
|
34
40
|
['anthropic/claude-opus-5', 1_048_576, 128_000],
|
|
35
41
|
['openai/gpt-5.6', 1_050_000, 128_000],
|
|
36
42
|
['google/gemini-3.7-flash', 1_048_576, 65_536],
|
|
37
43
|
['anthropic/claude-sonnet-5', 1_000_000, 128_000],
|
|
38
44
|
['qwen/qwen3.8-2.4t-a95b', 1_048_576, 262_144],
|
|
39
45
|
// Fast
|
|
46
|
+
['openai/gpt-6-luna', 1_050_000, 128_000],
|
|
47
|
+
['x-ai/grok-4.7', 500_000, 450_000],
|
|
48
|
+
['deepseek/deepseek-v4.1-flash', 1_048_576, 943_718],
|
|
49
|
+
['z-ai/glm-5.3-prime', 1_000_000, 131_072],
|
|
40
50
|
['x-ai/grok-4.6', 500_000, 500_000],
|
|
41
51
|
['openai/gpt-5.4-mini', 400_000, 128_000],
|
|
42
52
|
['google/gemini-3.5-flash', 1_048_576, 65_536],
|
|
@@ -51,6 +61,10 @@ const PRESET_DEFINITIONS = [
|
|
|
51
61
|
apiKeyEnvVar: 'OPENAI_API_KEY',
|
|
52
62
|
models: [
|
|
53
63
|
// SOTA
|
|
64
|
+
['gpt-6.1-sol', 1_050_000, 128_000],
|
|
65
|
+
['gpt-6-astra', 1_050_000, 128_000],
|
|
66
|
+
['gpt-6-sol', 1_050_000, 128_000],
|
|
67
|
+
['gpt-6-luna', 1_050_000, 128_000],
|
|
54
68
|
['gpt-5.6', 1_050_000, 128_000],
|
|
55
69
|
['gpt-5.6-sol', 1_050_000, 128_000],
|
|
56
70
|
['gpt-5.6-terra', 1_050_000, 128_000],
|
|
@@ -72,6 +86,7 @@ const PRESET_DEFINITIONS = [
|
|
|
72
86
|
apiKeyEnvVar: 'GEMINI_API_KEY',
|
|
73
87
|
models: [
|
|
74
88
|
// SOTA
|
|
89
|
+
['gemini-3.8-flash', 1_048_576, 65_536],
|
|
75
90
|
['gemini-3.1-pro-preview', 1_048_576, 65_536],
|
|
76
91
|
['gemini-3.7-flash', 1_048_576, 65_536],
|
|
77
92
|
// Fast
|
|
@@ -105,9 +120,10 @@ const PRESET_DEFINITIONS = [
|
|
|
105
120
|
apiKeyEnvVar: 'DEEPSEEK_API_KEY',
|
|
106
121
|
models: [
|
|
107
122
|
// SOTA
|
|
108
|
-
['deepseek-v4-pro', 1_000_000,
|
|
123
|
+
['deepseek-v4-pro', 1_000_000, 393_216],
|
|
109
124
|
// Fast
|
|
110
|
-
['deepseek-
|
|
125
|
+
['deepseek-flash', 1_000_000, 393_216],
|
|
126
|
+
['deepseek-v4-flash', 1_000_000, 393_216],
|
|
111
127
|
],
|
|
112
128
|
category: 'cloud',
|
|
113
129
|
},
|
|
@@ -118,6 +134,7 @@ const PRESET_DEFINITIONS = [
|
|
|
118
134
|
apiKeyEnvVar: 'XAI_API_KEY',
|
|
119
135
|
models: [
|
|
120
136
|
// SOTA
|
|
137
|
+
['grok-4.7', 500_000, 500_000],
|
|
121
138
|
['grok-4.6', 500_000, 500_000],
|
|
122
139
|
['grok-4.5', 500_000, 500_000],
|
|
123
140
|
['grok-4.3', 1_000_000, 30_000],
|
|
@@ -132,6 +149,8 @@ const PRESET_DEFINITIONS = [
|
|
|
132
149
|
baseUrl: 'https://api.z.ai/api/paas/v4/',
|
|
133
150
|
apiKeyEnvVar: 'ZAI_API_KEY',
|
|
134
151
|
models: [
|
|
152
|
+
['glm-5.3-flash', 1_000_000, 131_072],
|
|
153
|
+
['glm-5.3-flashx', 1_000_000, 131_072],
|
|
135
154
|
['glm-5.2', 1_000_000, 131_072],
|
|
136
155
|
['glm-5.1', 200_000, 131_072],
|
|
137
156
|
['glm-5-turbo', 200_000, 131_072],
|
|
@@ -294,6 +313,11 @@ const PRESET_DEFINITIONS = [
|
|
|
294
313
|
apiKeyEnvVar: 'OPENCODE_API_KEY',
|
|
295
314
|
models: [
|
|
296
315
|
// SOTA
|
|
316
|
+
['gpt-6.1-sol', 1_050_000, 128_000],
|
|
317
|
+
['gpt-6-astra', 1_050_000, 128_000],
|
|
318
|
+
['claude-opus-5-5', 1_000_000, 128_000],
|
|
319
|
+
['claude-sonnet-5-5', 1_000_000, 128_000],
|
|
320
|
+
['gemini-3.8-flash', 1_048_576, 65_536],
|
|
297
321
|
['claude-opus-5', 1_000_000, 128_000],
|
|
298
322
|
['gpt-5.5', 1_050_000, 128_000],
|
|
299
323
|
['claude-opus-4-8', 1_000_000, 128_000],
|
|
@@ -311,6 +335,12 @@ const PRESET_DEFINITIONS = [
|
|
|
311
335
|
baseUrl: 'https://router.requesty.ai/v1',
|
|
312
336
|
apiKeyHint: 'API Key (from https://app.requesty.ai/api-keys)',
|
|
313
337
|
models: [
|
|
338
|
+
['gpt-6.1-sol', 1_050_000, 128_000],
|
|
339
|
+
['gpt-6.1-sol@eu', 1_050_000, 128_000],
|
|
340
|
+
['claude-opus-5-5', 1_000_000, 128_000],
|
|
341
|
+
['claude-sonnet-5-5', 1_000_000, 128_000],
|
|
342
|
+
['gemini-3.8-flash', 1_048_576, 65_535],
|
|
343
|
+
['deepseek-v4.1-flash', 1_048_576, 393_216],
|
|
314
344
|
['claude-opus-4-8', 1_000_000, 128_000],
|
|
315
345
|
['gpt-5.5@eu', 1_050_000, 128_000],
|
|
316
346
|
['gemini-3.5-flash', 1_048_576, 65_535],
|
|
@@ -346,6 +376,10 @@ const PRESET_DEFINITIONS = [
|
|
|
346
376
|
baseUrl: 'https://chatgpt.com/backend-api/codex',
|
|
347
377
|
auth: 'chatgpt-oauth',
|
|
348
378
|
models: [
|
|
379
|
+
['gpt-6.1-sol', 1_050_000, 128_000],
|
|
380
|
+
['gpt-6-astra', 1_050_000, 128_000],
|
|
381
|
+
['gpt-6-sol', 1_050_000, 128_000],
|
|
382
|
+
['gpt-6-luna', 1_050_000, 128_000],
|
|
349
383
|
['gpt-5.6-sol', 1_050_000, 128_000],
|
|
350
384
|
['gpt-5.6-terra', 1_050_000, 128_000],
|
|
351
385
|
['gpt-5.6-luna', 1_050_000, 128_000],
|
|
@@ -383,6 +417,11 @@ const PRESET_DEFINITIONS = [
|
|
|
383
417
|
apiKeyEnvVar: 'KILO_API_KEY',
|
|
384
418
|
models: [
|
|
385
419
|
// SOTA
|
|
420
|
+
['openai/gpt-6.1-sol', 1_050_000, 128_000],
|
|
421
|
+
['anthropic/claude-opus-5.5', 1_000_000, 128_000],
|
|
422
|
+
['anthropic/claude-sonnet-5.5', 1_000_000, 128_000],
|
|
423
|
+
['google/gemini-3.8-flash', 1_048_576, 65_536],
|
|
424
|
+
['deepseek/deepseek-v4.1-flash', 1_048_576, 943_718],
|
|
386
425
|
['anthropic/claude-opus-5', 1_000_000, 128_000],
|
|
387
426
|
['openai/gpt-5.6-sol', 1_050_000, 128_000],
|
|
388
427
|
['moonshotai/kimi-k3', 1_048_576, 1_048_576],
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
export type ReasoningLevel
|
|
2
|
+
import { type ReasoningLevel, type StoredReasoningSetting } from '../core/agent/reasoningPolicy.js';
|
|
3
|
+
export type { ReasoningLevel, StoredReasoningSetting };
|
|
4
4
|
export declare const reasoningLevelSchema: z.ZodEnum<{
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
none: "none";
|
|
6
|
+
minimal: "minimal";
|
|
7
7
|
low: "low";
|
|
8
|
+
medium: "medium";
|
|
9
|
+
high: "high";
|
|
10
|
+
xhigh: "xhigh";
|
|
11
|
+
"provider-default": "provider-default";
|
|
8
12
|
}>;
|
|
9
13
|
export interface HazeProviderSettings {
|
|
10
14
|
name: string;
|
|
@@ -77,8 +81,12 @@ export interface HazeSettings {
|
|
|
77
81
|
mcpServers?: HazeMcpServer[];
|
|
78
82
|
skills?: HazeSkillSetting[];
|
|
79
83
|
subagents?: HazeSubagentSettings;
|
|
80
|
-
/** Optional reasoning depth;
|
|
81
|
-
reasoning?:
|
|
84
|
+
/** Optional reasoning depth; absent means the built-in default (`high`), the `provider-default` sentinel sends no parameter. */
|
|
85
|
+
reasoning?: StoredReasoningSetting;
|
|
86
|
+
/** `compact` keeps working context small for models with limited reliable context/tool calling. Default: `standard`. */
|
|
87
|
+
steeringProfile?: 'standard' | 'compact';
|
|
88
|
+
/** Optional, explicitly configured model to try once after a stalled goal. */
|
|
89
|
+
escalationModel?: string;
|
|
82
90
|
/**
|
|
83
91
|
* Context-window fallback for models without `modelLimits` metadata, in
|
|
84
92
|
* tokens. Unset means the built-in default (128K hosted / 32K local —
|
package/dist/config/settings.js
CHANGED
|
@@ -4,7 +4,14 @@ import { z } from 'zod';
|
|
|
4
4
|
import { HAZE_DIR } from './paths.js';
|
|
5
5
|
import { tightenPrivateFile, writePrivateJsonAtomic } from './privateStorage.js';
|
|
6
6
|
import { customProfileSchema } from '../core/subagent/executionProfiles.js';
|
|
7
|
-
|
|
7
|
+
import { REASONING_LEVELS, REASONING_PROVIDER_DEFAULT } from '../core/agent/reasoningPolicy.js';
|
|
8
|
+
/**
|
|
9
|
+
* Optional, explicitly user-controlled reasoning depth (provider/protocol
|
|
10
|
+
* gated). Absent means the built-in default (`high`); the `provider-default`
|
|
11
|
+
* sentinel stores an explicit "send no parameter" opt-out.
|
|
12
|
+
*/
|
|
13
|
+
const storedReasoningValues = [...REASONING_LEVELS, REASONING_PROVIDER_DEFAULT];
|
|
14
|
+
export const reasoningLevelSchema = z.enum(storedReasoningValues);
|
|
8
15
|
export const SETTINGS_FILE = path.join(HAZE_DIR, 'settings.json');
|
|
9
16
|
const providerCapabilitiesSchema = z.object({
|
|
10
17
|
images: z.boolean().optional(),
|
|
@@ -48,6 +55,12 @@ const contextWindowFallbackSchema = z.number().int().min(1_000).max(10_000_000);
|
|
|
48
55
|
const modelRetriesSchema = z.number().int().min(0).max(10);
|
|
49
56
|
/** Retry backoff base must be a plausible delay (not fractions/junk). */
|
|
50
57
|
const retryBaseDelaySchema = z.number().int().min(250).max(60_000);
|
|
58
|
+
/**
|
|
59
|
+
* An escalation model is an explicit `provider:model` selector (KISS: shape
|
|
60
|
+
* only — whether the provider/model actually resolves is checked by the
|
|
61
|
+
* provider layer when the switch is attempted).
|
|
62
|
+
*/
|
|
63
|
+
const escalationModelSchema = z.string().trim().regex(/^[^\s:]+:.+$/, 'must be a provider:model selector');
|
|
51
64
|
const settingsSchema = z.object({
|
|
52
65
|
provider: z.string().optional(),
|
|
53
66
|
model: z.string().optional(),
|
|
@@ -57,6 +70,8 @@ const settingsSchema = z.object({
|
|
|
57
70
|
skills: z.array(skillSettingSchema).optional(),
|
|
58
71
|
subagents: subagentSettingsSchema.optional(),
|
|
59
72
|
reasoning: reasoningLevelSchema.optional(),
|
|
73
|
+
steeringProfile: z.enum(['standard', 'compact']).optional(),
|
|
74
|
+
escalationModel: escalationModelSchema.optional(),
|
|
60
75
|
contextWindowFallbackTokens: contextWindowFallbackSchema.optional(),
|
|
61
76
|
localContextWindowFallbackTokens: contextWindowFallbackSchema.optional(),
|
|
62
77
|
modelRetries: modelRetriesSchema.optional(),
|
|
@@ -7,9 +7,7 @@ export declare const IDLE_TIMEOUT_MS: number;
|
|
|
7
7
|
export declare const DEFAULT_TOOL_DEADLINE_MS: number;
|
|
8
8
|
/** Subagents legitimately run long; give their wrapper a larger deadline. */
|
|
9
9
|
export declare const SUBAGENT_TOOL_DEADLINE_MS: number;
|
|
10
|
-
/**
|
|
11
|
-
export declare const DEFAULT_TURN_DEADLINE_MS: number;
|
|
12
|
-
/** Maximum accepted explicit `--timeout` value (24 hours). */
|
|
10
|
+
/** Maximum accepted explicit `--timeout` value (24 hours). No deadline is imposed unless the user sets one. */
|
|
13
11
|
export declare const MAX_TURN_DEADLINE_MS: number;
|
|
14
12
|
export declare const MAIN_STEP_LIMIT = 64;
|
|
15
13
|
export declare const MAIN_TOOL_CALL_LIMIT = 120;
|
|
@@ -23,27 +21,25 @@ export declare const SUBAGENT_SCOPE_CHARS = 240;
|
|
|
23
21
|
export declare const SUBAGENT_ACCEPTANCE_ITEMS = 8;
|
|
24
22
|
export declare const SUBAGENT_ACCEPTANCE_CHARS = 300;
|
|
25
23
|
export declare const SUBAGENT_MIN_STEPS = 4;
|
|
26
|
-
export declare const SUBAGENT_DEFAULT_STEPS =
|
|
27
|
-
export declare const SUBAGENT_MAX_STEPS =
|
|
28
|
-
export declare const SUBAGENT_DEFAULT_TOOL_CALLS =
|
|
29
|
-
export declare const SUBAGENT_MAX_TOOL_CALLS =
|
|
30
|
-
export declare const SUBAGENT_TOOL_ONLY_LIMIT =
|
|
24
|
+
export declare const SUBAGENT_DEFAULT_STEPS = 50;
|
|
25
|
+
export declare const SUBAGENT_MAX_STEPS = 100;
|
|
26
|
+
export declare const SUBAGENT_DEFAULT_TOOL_CALLS = 40;
|
|
27
|
+
export declare const SUBAGENT_MAX_TOOL_CALLS = 100;
|
|
28
|
+
export declare const SUBAGENT_TOOL_ONLY_LIMIT = 24;
|
|
31
29
|
export declare const SUBAGENT_SYNTHESIS_RESERVE = 2;
|
|
32
|
-
export declare const SUBAGENT_DEFAULT_OUTPUT_TOKENS =
|
|
33
|
-
export declare const SUBAGENT_MAX_OUTPUT_TOKENS =
|
|
34
|
-
export declare const SUBAGENT_DEFAULT_SUMMARY_CHARS =
|
|
35
|
-
export declare const SUBAGENT_MAX_SUMMARY_CHARS =
|
|
36
|
-
export declare const SUBAGENT_DEFAULT_INPUT_TOKENS =
|
|
37
|
-
export declare const SUBAGENT_MAX_INPUT_TOKENS =
|
|
38
|
-
export declare const SUBAGENT_DEFAULT_DEADLINE_MS =
|
|
30
|
+
export declare const SUBAGENT_DEFAULT_OUTPUT_TOKENS = 8192;
|
|
31
|
+
export declare const SUBAGENT_MAX_OUTPUT_TOKENS = 32768;
|
|
32
|
+
export declare const SUBAGENT_DEFAULT_SUMMARY_CHARS = 8000;
|
|
33
|
+
export declare const SUBAGENT_MAX_SUMMARY_CHARS = 24000;
|
|
34
|
+
export declare const SUBAGENT_DEFAULT_INPUT_TOKENS = 80000;
|
|
35
|
+
export declare const SUBAGENT_MAX_INPUT_TOKENS = 400000;
|
|
36
|
+
export declare const SUBAGENT_DEFAULT_DEADLINE_MS = 600000;
|
|
39
37
|
export declare const SUBAGENT_MIN_DEADLINE_MS = 1000;
|
|
40
38
|
export declare const SUBAGENT_MAX_DEADLINE_MS: number;
|
|
41
39
|
export declare const SUBAGENT_MAX_CONCURRENCY = 10;
|
|
42
40
|
export declare const SUBAGENT_MAX_RETRIES = 5;
|
|
43
41
|
/** Default size of the shared bounded model-retry pool for transient model errors and idle-stream stalls, per turn. Configurable via the `modelRetries` setting (0 disables automatic retries). */
|
|
44
42
|
export declare const DEFAULT_MODEL_RETRIES = 2;
|
|
45
|
-
/** Upper bound accepted for the `modelRetries` setting (mirrors the settings schema). */
|
|
46
|
-
export declare const MAX_MODEL_RETRIES_SETTING = 10;
|
|
47
43
|
/** Default base delay for the shared model-retry pool backoff (`base * 2^attempt`, capped at 4× the base). Configurable via the `retryBaseDelayMs` setting. */
|
|
48
44
|
export declare const DEFAULT_RETRY_BASE_DELAY_MS = 1000;
|
|
49
45
|
/** Each context-overflow retry multiplies the message-token budget by this factor (Pillar 1.4: 0.6 → 0.36 → checkpoint). */
|
|
@@ -5,10 +5,8 @@ export const IDLE_TIMEOUT_MS = 5 * 60_000;
|
|
|
5
5
|
/** Default per-tool execution deadline; an uncooperative tool cannot defer the turn indefinitely (RH-004). */
|
|
6
6
|
export const DEFAULT_TOOL_DEADLINE_MS = 10 * 60_000;
|
|
7
7
|
/** Subagents legitimately run long; give their wrapper a larger deadline. */
|
|
8
|
-
export const SUBAGENT_TOOL_DEADLINE_MS =
|
|
9
|
-
/**
|
|
10
|
-
export const DEFAULT_TURN_DEADLINE_MS = 30 * 60_000;
|
|
11
|
-
/** Maximum accepted explicit `--timeout` value (24 hours). */
|
|
8
|
+
export const SUBAGENT_TOOL_DEADLINE_MS = 40 * 60_000;
|
|
9
|
+
/** Maximum accepted explicit `--timeout` value (24 hours). No deadline is imposed unless the user sets one. */
|
|
12
10
|
export const MAX_TURN_DEADLINE_MS = 24 * 60 * 60_000;
|
|
13
11
|
export const MAIN_STEP_LIMIT = 64;
|
|
14
12
|
export const MAIN_TOOL_CALL_LIMIT = 120;
|
|
@@ -30,27 +28,25 @@ export const SUBAGENT_SCOPE_CHARS = 240;
|
|
|
30
28
|
export const SUBAGENT_ACCEPTANCE_ITEMS = 8;
|
|
31
29
|
export const SUBAGENT_ACCEPTANCE_CHARS = 300;
|
|
32
30
|
export const SUBAGENT_MIN_STEPS = 4;
|
|
33
|
-
export const SUBAGENT_DEFAULT_STEPS =
|
|
34
|
-
export const SUBAGENT_MAX_STEPS =
|
|
35
|
-
export const SUBAGENT_DEFAULT_TOOL_CALLS =
|
|
36
|
-
export const SUBAGENT_MAX_TOOL_CALLS =
|
|
37
|
-
export const SUBAGENT_TOOL_ONLY_LIMIT =
|
|
31
|
+
export const SUBAGENT_DEFAULT_STEPS = 50;
|
|
32
|
+
export const SUBAGENT_MAX_STEPS = 100;
|
|
33
|
+
export const SUBAGENT_DEFAULT_TOOL_CALLS = 40;
|
|
34
|
+
export const SUBAGENT_MAX_TOOL_CALLS = 100;
|
|
35
|
+
export const SUBAGENT_TOOL_ONLY_LIMIT = 24;
|
|
38
36
|
export const SUBAGENT_SYNTHESIS_RESERVE = 2;
|
|
39
|
-
export const SUBAGENT_DEFAULT_OUTPUT_TOKENS =
|
|
40
|
-
export const SUBAGENT_MAX_OUTPUT_TOKENS =
|
|
41
|
-
export const SUBAGENT_DEFAULT_SUMMARY_CHARS =
|
|
42
|
-
export const SUBAGENT_MAX_SUMMARY_CHARS =
|
|
43
|
-
export const SUBAGENT_DEFAULT_INPUT_TOKENS =
|
|
44
|
-
export const SUBAGENT_MAX_INPUT_TOKENS =
|
|
45
|
-
export const SUBAGENT_DEFAULT_DEADLINE_MS =
|
|
37
|
+
export const SUBAGENT_DEFAULT_OUTPUT_TOKENS = 8_192;
|
|
38
|
+
export const SUBAGENT_MAX_OUTPUT_TOKENS = 32_768;
|
|
39
|
+
export const SUBAGENT_DEFAULT_SUMMARY_CHARS = 8_000;
|
|
40
|
+
export const SUBAGENT_MAX_SUMMARY_CHARS = 24_000;
|
|
41
|
+
export const SUBAGENT_DEFAULT_INPUT_TOKENS = 80_000;
|
|
42
|
+
export const SUBAGENT_MAX_INPUT_TOKENS = 400_000;
|
|
43
|
+
export const SUBAGENT_DEFAULT_DEADLINE_MS = 600_000;
|
|
46
44
|
export const SUBAGENT_MIN_DEADLINE_MS = 1_000;
|
|
47
|
-
export const SUBAGENT_MAX_DEADLINE_MS =
|
|
45
|
+
export const SUBAGENT_MAX_DEADLINE_MS = 60 * 60_000;
|
|
48
46
|
export const SUBAGENT_MAX_CONCURRENCY = 10;
|
|
49
47
|
export const SUBAGENT_MAX_RETRIES = 5;
|
|
50
48
|
/** Default size of the shared bounded model-retry pool for transient model errors and idle-stream stalls, per turn. Configurable via the `modelRetries` setting (0 disables automatic retries). */
|
|
51
49
|
export const DEFAULT_MODEL_RETRIES = 2;
|
|
52
|
-
/** Upper bound accepted for the `modelRetries` setting (mirrors the settings schema). */
|
|
53
|
-
export const MAX_MODEL_RETRIES_SETTING = 10;
|
|
54
50
|
/** Default base delay for the shared model-retry pool backoff (`base * 2^attempt`, capped at 4× the base). Configurable via the `retryBaseDelayMs` setting. */
|
|
55
51
|
export const DEFAULT_RETRY_BASE_DELAY_MS = 1_000;
|
|
56
52
|
/** Each context-overflow retry multiplies the message-token budget by this factor (Pillar 1.4: 0.6 → 0.36 → checkpoint). */
|
|
@@ -35,6 +35,7 @@ export interface TurnExecutionState {
|
|
|
35
35
|
intent: RequestIntent;
|
|
36
36
|
/** Latest current-turn task-list evidence from a successful writeTasks call. */
|
|
37
37
|
taskProgress: WorkTaskProgress | undefined;
|
|
38
|
+
requiresTaskLedger: boolean;
|
|
38
39
|
/** Goal-continuation cycles issued this turn (bounded by the global budget + progress guard). */
|
|
39
40
|
goalContinuationsUsed: number;
|
|
40
41
|
/** Whether the single focused post-edit validation-repair slice was admitted. */
|
|
@@ -83,6 +84,8 @@ export interface CompletionEvidence {
|
|
|
83
84
|
sawToolCall: boolean;
|
|
84
85
|
assistantText: string;
|
|
85
86
|
lastToolOk: boolean | undefined;
|
|
87
|
+
/** True when the last failed tool call was the classifier-confirmed validation check itself. */
|
|
88
|
+
lastFailedToolWasValidation: boolean;
|
|
86
89
|
unresolvedToolInputError: boolean;
|
|
87
90
|
}
|
|
88
91
|
export type TurnStatus = 'complete' | 'aborted' | 'failed';
|
|
@@ -93,7 +96,7 @@ export type TurnStatus = 'complete' | 'aborted' | 'failed';
|
|
|
93
96
|
* mutation, validation, red→green, tool, and budget evidence is
|
|
94
97
|
* authoritative).
|
|
95
98
|
*/
|
|
96
|
-
export type CompletionReadiness = 'ready' | 'pending_tasks' | 'validation_failed' | 'validation_stale' | 'validation_absent_after_mutation' | 'red_check_not_green' | 'tool_failure' | 'unresolved_tool_input' | 'aborted'
|
|
99
|
+
export type CompletionReadiness = 'ready' | 'pending_tasks' | 'task_ledger_absent' | 'validation_failed' | 'validation_stale' | 'validation_absent_after_mutation' | 'red_check_not_green' | 'tool_failure' | 'unresolved_tool_input' | 'aborted'
|
|
97
100
|
/** Produced only by the context-overflow exhaustion path (Pillar 1.4): the window stayed full after bounded compact-and-retry attempts. */
|
|
98
101
|
| 'context_exhausted';
|
|
99
102
|
/** Inputs `assessCompletionReadiness` needs; matches the TurnExecutionState projection. */
|
|
@@ -103,6 +106,7 @@ export interface CompletionReadinessInput {
|
|
|
103
106
|
mutationCount: number;
|
|
104
107
|
validationOutcome: ValidationOutcome;
|
|
105
108
|
taskProgress: WorkTaskProgress | undefined;
|
|
109
|
+
requiresTaskLedger?: boolean;
|
|
106
110
|
/** Red→green pair state; absent/not-required disables the gate. */
|
|
107
111
|
redPair?: 'not-required' | 'missing' | 'satisfied';
|
|
108
112
|
}
|
|
@@ -114,7 +118,7 @@ export interface CompletionReadinessInput {
|
|
|
114
118
|
* the fix-intent red→green pair. A task list is enforced only when this turn
|
|
115
119
|
* declared one via a successful writeTasks call.
|
|
116
120
|
*/
|
|
117
|
-
export declare function assessCompletionReadiness(state: CompletionReadinessInput, evidence: Pick<CompletionEvidence, 'lastToolOk' | 'unresolvedToolInputError'>): CompletionReadiness;
|
|
121
|
+
export declare function assessCompletionReadiness(state: CompletionReadinessInput, evidence: Pick<CompletionEvidence, 'lastToolOk' | 'lastFailedToolWasValidation' | 'unresolvedToolInputError'>): CompletionReadiness;
|
|
118
122
|
/** Human-readable, safe (no commands/content) description of a readiness result. */
|
|
119
123
|
export declare function describeCompletionReadiness(readiness: CompletionReadiness, taskProgress?: WorkTaskProgress): string;
|
|
120
124
|
/**
|
|
@@ -141,6 +145,14 @@ export declare function hasRemainingRecoveryBudget(state: Pick<TurnExecutionStat
|
|
|
141
145
|
* failure (length-continuation lands in Increment 2 and only flips on when a
|
|
142
146
|
* recovery credit is both available and warranted).
|
|
143
147
|
*/
|
|
148
|
+
/**
|
|
149
|
+
* Explicit, persisted cause for a failed turn (RT-05): the live session's
|
|
150
|
+
* second goal failed in 20s with zero assistant output and no timeout/retry
|
|
151
|
+
* events, and with `--debug` off the ledger held nothing diagnosable. Pure and
|
|
152
|
+
* bounded; safe metadata only. Undefined when the finish explains itself
|
|
153
|
+
* (normal failed readiness with a substantive answer).
|
|
154
|
+
*/
|
|
155
|
+
export declare function describeTurnFailure(state: Pick<TurnExecutionState, 'finishCause' | 'aborted' | 'budgetBoundary'>, lastAssistantText: string): string | undefined;
|
|
144
156
|
export declare function decideTerminalStatus(state: TurnExecutionState, evidence: CompletionEvidence, budgetExhausted: boolean): TurnStatus;
|
|
145
157
|
type RecoveryAction = 'continue' | 'stop';
|
|
146
158
|
interface RecoverySlice {
|
|
@@ -25,6 +25,7 @@ export function createTurnExecutionState() {
|
|
|
25
25
|
validationAfterMutation: false,
|
|
26
26
|
intent: 'unknown',
|
|
27
27
|
taskProgress: undefined,
|
|
28
|
+
requiresTaskLedger: false,
|
|
28
29
|
goalContinuationsUsed: 0,
|
|
29
30
|
validationContinuationUsed: false,
|
|
30
31
|
goalContinuationProgress: undefined,
|
|
@@ -61,11 +62,21 @@ export function assessCompletionReadiness(state, evidence) {
|
|
|
61
62
|
return 'aborted';
|
|
62
63
|
if (evidence.unresolvedToolInputError)
|
|
63
64
|
return 'unresolved_tool_input';
|
|
64
|
-
|
|
65
|
+
// A validation-only goal is fulfilled by running the check and reporting its
|
|
66
|
+
// failure, not by repairing code. Keep the failed status, but do not turn a
|
|
67
|
+
// truthful report into an automatic repair slice (even after another read).
|
|
68
|
+
if (state.intent === 'test' && state.mutationCount === 0 && state.validationOutcome === 'failed')
|
|
65
69
|
return 'tool_failure';
|
|
70
|
+
// A failing validation command is repairable work, not a terminal tool
|
|
71
|
+
// failure — but only when the failed call *is* that validation check. A
|
|
72
|
+
// failed edit/write after a failed validation stays a hard tool failure.
|
|
73
|
+
if (evidence.lastToolOk === false && !(state.validationOutcome === 'failed' && evidence.lastFailedToolWasValidation))
|
|
74
|
+
return 'tool_failure';
|
|
75
|
+
if (state.requiresTaskLedger && (!state.taskProgress || state.taskProgress.total === 0))
|
|
76
|
+
return 'task_ledger_absent';
|
|
66
77
|
if (state.taskProgress && (state.taskProgress.pending > 0 || state.taskProgress.inProgress > 0))
|
|
67
78
|
return 'pending_tasks';
|
|
68
|
-
if (intentExpectsValidation(state.intent)) {
|
|
79
|
+
if (intentExpectsValidation(state.intent) || (state.intent === 'unknown' && state.mutationCount > 0)) {
|
|
69
80
|
if (state.validationOutcome === 'failed')
|
|
70
81
|
return 'validation_failed';
|
|
71
82
|
if (state.validationOutcome === 'stale')
|
|
@@ -84,6 +95,7 @@ export function describeCompletionReadiness(readiness, taskProgress) {
|
|
|
84
95
|
const open = taskProgress ? taskProgress.pending + taskProgress.inProgress : 0;
|
|
85
96
|
return `${open} declared task${open === 1 ? '' : 's'} still pending or in progress`;
|
|
86
97
|
}
|
|
98
|
+
case 'task_ledger_absent': return 'this broad request has no declared outcome list';
|
|
87
99
|
case 'validation_failed': return 'the latest validation failed and remains unresolved';
|
|
88
100
|
case 'validation_stale': return 'edits landed after the latest validation';
|
|
89
101
|
case 'validation_absent_after_mutation': return 'edits landed without any relevant validation';
|
|
@@ -126,9 +138,41 @@ export function hasRemainingRecoveryBudget(state, budget) {
|
|
|
126
138
|
* failure (length-continuation lands in Increment 2 and only flips on when a
|
|
127
139
|
* recovery credit is both available and warranted).
|
|
128
140
|
*/
|
|
141
|
+
/**
|
|
142
|
+
* Explicit, persisted cause for a failed turn (RT-05): the live session's
|
|
143
|
+
* second goal failed in 20s with zero assistant output and no timeout/retry
|
|
144
|
+
* events, and with `--debug` off the ledger held nothing diagnosable. Pure and
|
|
145
|
+
* bounded; safe metadata only. Undefined when the finish explains itself
|
|
146
|
+
* (normal failed readiness with a substantive answer).
|
|
147
|
+
*/
|
|
148
|
+
export function describeTurnFailure(state, lastAssistantText) {
|
|
149
|
+
if (!state.aborted && state.finishCause === 'stop' && lastAssistantText.trim().length === 0)
|
|
150
|
+
return 'model-returned-no-output';
|
|
151
|
+
if (state.finishCause === 'length')
|
|
152
|
+
return 'output-length-truncation';
|
|
153
|
+
if (state.finishCause === 'error')
|
|
154
|
+
return 'model-error';
|
|
155
|
+
if (state.finishCause === 'content-filter')
|
|
156
|
+
return 'content-filter';
|
|
157
|
+
if (state.finishCause === 'tool-calls' && state.budgetBoundary)
|
|
158
|
+
return 'tool-budget-boundary';
|
|
159
|
+
if (state.finishCause === 'unknown')
|
|
160
|
+
return 'unknown-finish';
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
129
163
|
export function decideTerminalStatus(state, evidence, budgetExhausted) {
|
|
130
164
|
if (state.aborted)
|
|
131
165
|
return 'aborted';
|
|
166
|
+
// A voluntary `stop` final whose structured completion evidence is ready is
|
|
167
|
+
// complete even at a budget boundary: a turn that finished its declared work
|
|
168
|
+
// and answered substantively must not be reported failed merely because it
|
|
169
|
+
// also used its whole budget (RT-02 — the review session's goal 1 ended
|
|
170
|
+
// failed/blocked with finishCause 'stop', 5/5 tasks, and a delivered report).
|
|
171
|
+
// `classifyTerminalOutcome` already treats this exact shape as goal-complete;
|
|
172
|
+
// keep the two authorities aligned. Non-stop finishes (length/error) and
|
|
173
|
+
// non-ready evidence still fail as before.
|
|
174
|
+
if (state.finishCause === 'stop' && evidence.assistantText.trim().length > 0 && assessCompletionReadiness(state, evidence) === 'ready')
|
|
175
|
+
return 'complete';
|
|
132
176
|
if (budgetExhausted || state.finishCause === 'length' || state.finishCause === 'error')
|
|
133
177
|
return 'failed';
|
|
134
178
|
if (assessCompletionReadiness(state, evidence) !== 'ready')
|
|
@@ -206,6 +250,7 @@ const VALIDATION_CONTINUATION_SLICE = { steps: 3, toolCalls: 3 };
|
|
|
206
250
|
/** Readiness reasons a bounded continuation can plausibly resolve with more work. */
|
|
207
251
|
export function goalContinuationRecoverable(readiness) {
|
|
208
252
|
return readiness === 'pending_tasks'
|
|
253
|
+
|| readiness === 'task_ledger_absent'
|
|
209
254
|
|| readiness === 'validation_failed'
|
|
210
255
|
|| readiness === 'validation_stale'
|
|
211
256
|
|| readiness === 'validation_absent_after_mutation'
|
|
@@ -270,7 +315,7 @@ export function decideGoalContinuation(state, evidence, budget) {
|
|
|
270
315
|
return stop('finish shape is not recoverable');
|
|
271
316
|
if (evidence.assistantText.trim().length === 0)
|
|
272
317
|
return stop('no substantive final to reject');
|
|
273
|
-
if (evidence.lastToolOk === false || evidence.unresolvedToolInputError)
|
|
318
|
+
if ((evidence.lastToolOk === false && !(state.validationOutcome === 'failed' && evidence.lastFailedToolWasValidation)) || evidence.unresolvedToolInputError)
|
|
274
319
|
return stop('unresolved tool failure');
|
|
275
320
|
const readiness = assessCompletionReadiness(state, evidence);
|
|
276
321
|
if (readiness === 'ready')
|