@denizokcu/haze 1.7.10 → 1.7.11
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 +7 -0
- package/README.md +18 -8
- package/dist/buildInfo.json +3 -3
- package/dist/cli/chat/BusyBar.d.ts +2 -1
- package/dist/cli/chat/BusyBar.js +2 -2
- package/dist/cli/chat/chatMetrics.d.ts +25 -0
- package/dist/cli/chat/chatMetrics.js +36 -0
- package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
- package/dist/cli/chat/sessionLifecycle.js +27 -18
- package/dist/cli/chat/sessionRecorder.d.ts +2 -1
- package/dist/cli/chat/sessionRecorder.js +25 -8
- package/dist/cli/chat/transcriptPartition.js +10 -4
- package/dist/cli/chat/wizard/providerHandlers.js +57 -9
- package/dist/cli/chat/wizard/sessionThemeHandlers.js +5 -1
- package/dist/cli/commands/chat.js +39 -7
- package/dist/cli/commands/commandHelp.js +2 -2
- package/dist/cli/commands/providerWizard.js +9 -17
- package/dist/cli/commands/reasoningCommand.d.ts +1 -0
- package/dist/cli/commands/reasoningCommand.js +32 -4
- package/dist/cli/commands/runCommand.js +7 -1
- package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
- package/dist/cli/commands/streaming/attemptOutcome.js +5 -1
- package/dist/cli/commands/streaming/attemptSetup.js +5 -3
- package/dist/cli/commands/streaming/goalSupervisor.d.ts +1 -1
- package/dist/cli/commands/streaming/goalSupervisor.js +20 -1
- package/dist/cli/commands/streaming/streamLoop.js +11 -10
- package/dist/cli/commands/streaming.d.ts +2 -0
- package/dist/cli/commands/wizardFlow.d.ts +1 -0
- package/dist/cli/commands/wizardFlow.js +10 -4
- package/dist/cli/index.js +5 -3
- package/dist/config/hazeBuild.d.ts +2 -2
- package/dist/config/hazeBuild.js +2 -2
- package/dist/config/modelDiscovery.d.ts +1 -1
- package/dist/config/modelDiscovery.js +8 -8
- package/dist/config/{modelCatalog.d.ts → providerModelFacts.d.ts} +13 -2
- package/dist/config/{modelCatalog.js → providerModelFacts.js} +145 -21
- package/dist/config/providerPresets.d.ts +8 -19
- package/dist/config/providerPresets.js +86 -555
- package/dist/config/providerReasoning.d.ts +16 -0
- package/dist/config/providerReasoning.js +56 -0
- package/dist/config/providers.d.ts +4 -0
- package/dist/config/providers.js +19 -2
- package/dist/config/settings.d.ts +14 -0
- package/dist/config/settings.js +5 -0
- package/dist/core/agent/events.d.ts +1 -1
- package/dist/core/agent/providerTransition.d.ts +8 -0
- package/dist/core/agent/providerTransition.js +47 -0
- package/dist/core/agent/reasoningPolicy.d.ts +1 -1
- package/dist/core/agent/reasoningPolicy.js +4 -2
- package/dist/core/limits.d.ts +0 -2
- package/dist/core/limits.js +0 -2
- package/dist/core/providerContracts.d.ts +9 -8
- package/dist/core/providerContracts.js +21 -1
- package/dist/core/safety/redaction.js +12 -2
- package/dist/core/session/sessionSlimming.js +5 -59
- package/dist/core/session/sessionStore.d.ts +4 -0
- package/dist/core/session/sessionStore.js +149 -9
- package/dist/core/session/snapshotCodec.d.ts +5 -0
- package/dist/core/session/snapshotCodec.js +47 -0
- package/dist/core/shellOutput/registry.js +2 -46
- package/dist/core/subagent/executionProfiles.js +4 -1
- package/dist/core/toolOutput/reduction.d.ts +55 -2
- package/dist/core/toolOutput/reduction.js +77 -2
- package/dist/llm/client.d.ts +4 -2
- package/dist/llm/client.js +104 -55
- package/dist/llm/hazeTools.d.ts +16 -16
- package/dist/llm/mistralReasoning.d.ts +2 -0
- package/dist/llm/mistralReasoning.js +17 -0
- package/dist/llm/mistralVibeAuth.d.ts +5 -0
- package/dist/llm/mistralVibeAuth.js +63 -0
- package/dist/llm/requestContext.js +8 -7
- package/dist/llm/subagentRunner.js +15 -7
- package/dist/llm/toolResultTypes.js +7 -1
- package/dist/llm/tools/fetchTool.d.ts +16 -16
- package/dist/llm/tools/outputCap.d.ts +2 -7
- package/dist/llm/tools/outputCap.js +3 -11
- package/dist/llm/tools/replaceInFiles.js +5 -0
- package/package.json +14 -8
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReasoningLevel } from '../core/agent/reasoningPolicy.js';
|
|
2
|
+
import { type ResolvedReasoningPolicy } from '../core/agent/reasoningPolicy.js';
|
|
3
|
+
import type { HazeProviderSettings } from './settings.js';
|
|
4
|
+
/** Apply Mistral-specific transport only to its direct API. */
|
|
5
|
+
export declare function isMistralApi(url: string): boolean;
|
|
6
|
+
/** Known effort levels for direct endpoints; gateways retain their own policy. */
|
|
7
|
+
export declare function providerReasoningLevels(url: string, model: string): readonly ReasoningLevel[] | undefined;
|
|
8
|
+
export interface ReasoningCapabilities {
|
|
9
|
+
support: 'supported' | 'unsupported' | 'unknown';
|
|
10
|
+
levels: readonly ReasoningLevel[];
|
|
11
|
+
}
|
|
12
|
+
/** One shared profile for the UI, main request, and auxiliary calls. */
|
|
13
|
+
export declare function reasoningCapabilitiesForProvider(provider: HazeProviderSettings, model: string): ReasoningCapabilities;
|
|
14
|
+
export declare function reasoningLevelsForProvider(provider: HazeProviderSettings, model: string): readonly ReasoningLevel[];
|
|
15
|
+
/** Shared requested-versus-sent decision for UI and all request paths. */
|
|
16
|
+
export declare function resolveProviderReasoning(provider: HazeProviderSettings, model: string, requested: ReasoningLevel | undefined): ResolvedReasoningPolicy;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { REASONING_LEVELS } from '../core/agent/reasoningPolicy.js';
|
|
2
|
+
import { endpointModelFacts } from './providerModelFacts.js';
|
|
3
|
+
/** Apply Mistral-specific transport only to its direct API. */
|
|
4
|
+
export function isMistralApi(url) {
|
|
5
|
+
try {
|
|
6
|
+
return new URL(url).hostname.toLowerCase() === 'api.mistral.ai';
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Known effort levels for direct endpoints; gateways retain their own policy. */
|
|
13
|
+
export function providerReasoningLevels(url, model) {
|
|
14
|
+
return endpointModelFacts(url, model).reasoningLevels;
|
|
15
|
+
}
|
|
16
|
+
/** One shared profile for the UI, main request, and auxiliary calls. */
|
|
17
|
+
export function reasoningCapabilitiesForProvider(provider, model) {
|
|
18
|
+
const known = (levels) => ({ support: levels.length ? 'supported' : 'unsupported', levels });
|
|
19
|
+
if (provider.capabilities?.reasoningEffort === false)
|
|
20
|
+
return known([]);
|
|
21
|
+
const override = provider.modelReasoningLevels?.[model] ?? provider.reasoningLevels;
|
|
22
|
+
if (override)
|
|
23
|
+
return known(provider.reasoningFormat === 'thinking' || provider.reasoningFormat === 'enable-thinking' ? override.filter(level => level === 'none' || level === 'high') : override);
|
|
24
|
+
if (provider.reasoningFormat === 'thinking' || provider.reasoningFormat === 'enable-thinking')
|
|
25
|
+
return known(['none', 'high']);
|
|
26
|
+
if (provider.capabilities?.reasoningEffort === true)
|
|
27
|
+
return known(REASONING_LEVELS);
|
|
28
|
+
const documented = providerReasoningLevels(provider.kind === 'chatgpt-codex' ? 'https://api.openai.com' : provider.url, model);
|
|
29
|
+
if (documented)
|
|
30
|
+
return known(documented);
|
|
31
|
+
if (provider.kind === 'haze-build')
|
|
32
|
+
return known(['none', 'high']);
|
|
33
|
+
// Official OpenAI and OpenRouter protocols support portable effort settings.
|
|
34
|
+
// A model-specific profile above narrows the choices when documented.
|
|
35
|
+
try {
|
|
36
|
+
const host = new URL(provider.url).hostname.toLowerCase();
|
|
37
|
+
if (host === 'openrouter.ai')
|
|
38
|
+
return known(['none', 'minimal', 'low', 'medium', 'high', 'xhigh']);
|
|
39
|
+
}
|
|
40
|
+
catch { /* Invalid URLs are rejected when creating the runtime. */ }
|
|
41
|
+
return { support: 'unknown', levels: [] };
|
|
42
|
+
}
|
|
43
|
+
export function reasoningLevelsForProvider(provider, model) {
|
|
44
|
+
return reasoningCapabilitiesForProvider(provider, model).levels;
|
|
45
|
+
}
|
|
46
|
+
/** Shared requested-versus-sent decision for UI and all request paths. */
|
|
47
|
+
export function resolveProviderReasoning(provider, model, requested) {
|
|
48
|
+
if (!requested)
|
|
49
|
+
return { requested, effective: 'disabled', reason: 'no reasoning depth requested' };
|
|
50
|
+
const { support, levels } = reasoningCapabilitiesForProvider(provider, model);
|
|
51
|
+
if (!levels.length)
|
|
52
|
+
return { requested, effective: 'disabled', reason: support === 'unknown' ? 'reasoning support is unknown; parameter omitted (provider default)' : 'reasoning effort is unsupported; parameter omitted (provider default)' };
|
|
53
|
+
if (!levels.includes(requested))
|
|
54
|
+
return { requested, effective: 'disabled', reason: `${model} does not support reasoning effort ${requested}; parameter omitted (provider default). Choose ${levels.join(', ')}, or unset.` };
|
|
55
|
+
return { requested, effective: requested, reason: 'applied via supported provider protocol' };
|
|
56
|
+
}
|
|
@@ -19,7 +19,11 @@ export declare function activeModel(settings: HazeSettings): {
|
|
|
19
19
|
} | undefined;
|
|
20
20
|
export declare function resolveModelSelector(settings: HazeSettings, selector: string): ModelResolution;
|
|
21
21
|
export declare function modelSelector(provider: HazeProviderSettings, model: string): string;
|
|
22
|
+
/** Stable non-secret endpoint identity for detecting changes across resume. */
|
|
23
|
+
export declare function providerEndpointFingerprint(provider: Pick<HazeProviderSettings, 'url' | 'kind'>): string;
|
|
22
24
|
export declare function upsertProvider(settings: HazeSettings, provider: HazeProviderSettings): HazeProviderSettings[];
|
|
23
25
|
export declare function providerHasKey(settings: HazeSettings, provider: HazeProviderSettings): boolean;
|
|
26
|
+
/** Legacy API keys are scoped to the legacy OpenRouter provider. */
|
|
27
|
+
export declare function providerApiKey(settings: HazeSettings, provider: HazeProviderSettings): string | undefined;
|
|
24
28
|
/** Image input is explicit-only (F03): never inferred from URL or model name. */
|
|
25
29
|
export declare function providerImageCapable(provider: HazeProviderSettings): boolean;
|
package/dist/config/providers.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { findByName, upsertByName } from '../utils/collections.js';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
2
3
|
// Used only to migrate legacy single-provider OpenRouter settings (apiKey/baseURL)
|
|
3
4
|
// into the providers array. There is no default provider or model anymore: users
|
|
4
5
|
// must configure a provider themselves via /provider.
|
|
@@ -21,16 +22,23 @@ function normalizeProvider(provider, fallbackModel) {
|
|
|
21
22
|
const key = provider.key?.trim();
|
|
22
23
|
// Capabilities are explicit only: an absent/false flag means "not capable".
|
|
23
24
|
const capabilities = provider.capabilities ?? undefined;
|
|
24
|
-
|
|
25
|
+
const normalized = {
|
|
26
|
+
...provider,
|
|
25
27
|
name,
|
|
26
28
|
url,
|
|
27
29
|
...(key ? { key } : {}),
|
|
28
30
|
...(provider.kind ? { kind: provider.kind } : {}),
|
|
29
31
|
...(capabilities ? { capabilities } : {}),
|
|
32
|
+
...(provider.reasoningLevels ? { reasoningLevels: provider.reasoningLevels } : {}),
|
|
33
|
+
...(provider.modelReasoningLevels ? { modelReasoningLevels: provider.modelReasoningLevels } : {}),
|
|
34
|
+
...(provider.reasoningFormat ? { reasoningFormat: provider.reasoningFormat } : {}),
|
|
30
35
|
...(provider.modelLimits ? { modelLimits: provider.modelLimits } : {}),
|
|
31
36
|
...(provider.trustedDeployments ? { trustedDeployments: provider.trustedDeployments } : {}),
|
|
32
37
|
models: normalizeModels(provider.models, fallbackModel),
|
|
33
38
|
};
|
|
39
|
+
if (!key)
|
|
40
|
+
delete normalized.key;
|
|
41
|
+
return normalized;
|
|
34
42
|
}
|
|
35
43
|
export function configuredProviders(settings) {
|
|
36
44
|
const providers = (settings.providers ?? [])
|
|
@@ -86,11 +94,20 @@ export function resolveModelSelector(settings, selector) {
|
|
|
86
94
|
export function modelSelector(provider, model) {
|
|
87
95
|
return `${provider.name}:${model}`;
|
|
88
96
|
}
|
|
97
|
+
/** Stable non-secret endpoint identity for detecting changes across resume. */
|
|
98
|
+
export function providerEndpointFingerprint(provider) {
|
|
99
|
+
return createHash('sha256').update(`${provider.kind ?? 'openai-compatible'}\0${provider.url}`).digest('hex');
|
|
100
|
+
}
|
|
89
101
|
export function upsertProvider(settings, provider) {
|
|
90
102
|
return upsertByName(configuredProviders(settings), provider);
|
|
91
103
|
}
|
|
92
104
|
export function providerHasKey(settings, provider) {
|
|
93
|
-
return Boolean(
|
|
105
|
+
return Boolean(providerApiKey(settings, provider));
|
|
106
|
+
}
|
|
107
|
+
/** Legacy API keys are scoped to the legacy OpenRouter provider. */
|
|
108
|
+
export function providerApiKey(settings, provider) {
|
|
109
|
+
const legacyUrl = settings.baseURL ?? LEGACY_OPENROUTER_URL;
|
|
110
|
+
return provider.key ?? (provider.name === 'openrouter' && provider.url.replace(/\/+$/, '') === legacyUrl.replace(/\/+$/, '') ? settings.apiKey : undefined);
|
|
94
111
|
}
|
|
95
112
|
/** Image input is explicit-only (F03): never inferred from URL or model name. */
|
|
96
113
|
export function providerImageCapable(provider) {
|
|
@@ -8,6 +8,7 @@ export declare const reasoningLevelSchema: z.ZodEnum<{
|
|
|
8
8
|
medium: "medium";
|
|
9
9
|
high: "high";
|
|
10
10
|
xhigh: "xhigh";
|
|
11
|
+
max: "max";
|
|
11
12
|
"provider-default": "provider-default";
|
|
12
13
|
}>;
|
|
13
14
|
export interface HazeProviderSettings {
|
|
@@ -17,6 +18,8 @@ export interface HazeProviderSettings {
|
|
|
17
18
|
models: string[];
|
|
18
19
|
/** Explicit runtime/auth protocol. Omitted means a normal OpenAI-compatible endpoint. */
|
|
19
20
|
kind?: 'openai-compatible' | 'chatgpt-codex' | 'haze-build';
|
|
21
|
+
/** Override automatic local/hosted inference for custom endpoints. */
|
|
22
|
+
location?: 'local' | 'hosted';
|
|
20
23
|
/**
|
|
21
24
|
* Explicit endpoint capabilities. Never inferred: images are only sent to
|
|
22
25
|
* providers the user marked image-capable (F03); `reasoningEffort: false`
|
|
@@ -27,6 +30,12 @@ export interface HazeProviderSettings {
|
|
|
27
30
|
images?: boolean;
|
|
28
31
|
reasoningEffort?: boolean;
|
|
29
32
|
};
|
|
33
|
+
/** Explicit supported effort levels for compatible custom endpoints. */
|
|
34
|
+
reasoningLevels?: ReasoningLevel[];
|
|
35
|
+
/** Per-model overrides, keyed by the exact model ID. An empty list disables the parameter. */
|
|
36
|
+
modelReasoningLevels?: Record<string, ReasoningLevel[]>;
|
|
37
|
+
/** Wire format for custom OpenAI-compatible servers with a binary switch. */
|
|
38
|
+
reasoningFormat?: 'effort' | 'thinking' | 'enable-thinking';
|
|
30
39
|
/** Additional exact deployment identities explicitly approved for this native provider. */
|
|
31
40
|
trustedDeployments?: Array<{
|
|
32
41
|
modelRepository: string;
|
|
@@ -43,6 +52,11 @@ export interface HazeProviderSettings {
|
|
|
43
52
|
contextWindowTokens?: number;
|
|
44
53
|
maxOutputTokens?: number;
|
|
45
54
|
}>;
|
|
55
|
+
/** Last discovered endpoint limits, separate from explicit user overrides. */
|
|
56
|
+
discoveredModelLimits?: Record<string, {
|
|
57
|
+
contextWindowTokens?: number;
|
|
58
|
+
maxOutputTokens?: number;
|
|
59
|
+
}>;
|
|
46
60
|
}
|
|
47
61
|
export interface HazeLspServerSettings {
|
|
48
62
|
name: string;
|
package/dist/config/settings.js
CHANGED
|
@@ -23,9 +23,14 @@ const providerSchema = z.object({
|
|
|
23
23
|
key: z.string().optional(),
|
|
24
24
|
models: z.array(z.string()),
|
|
25
25
|
kind: z.enum(['openai-compatible', 'chatgpt-codex', 'haze-build']).optional(),
|
|
26
|
+
location: z.enum(['local', 'hosted']).optional(),
|
|
26
27
|
capabilities: providerCapabilitiesSchema.optional(),
|
|
28
|
+
reasoningLevels: z.array(z.enum(REASONING_LEVELS)).optional(),
|
|
29
|
+
modelReasoningLevels: z.record(z.string(), z.array(z.enum(REASONING_LEVELS))).optional(),
|
|
30
|
+
reasoningFormat: z.enum(['effort', 'thinking', 'enable-thinking']).optional(),
|
|
27
31
|
trustedDeployments: z.array(z.object({ modelRepository: z.string().min(1).max(256), modelRevision: z.string().regex(/^[a-f0-9]{40}$/), templateSha256: z.string().regex(/^[a-f0-9]{64}$/), runtimeVersion: z.string().regex(/^\d+\.\d+\.\d+$/) })).max(8).optional(),
|
|
28
32
|
modelLimits: z.record(z.string(), z.object({ contextWindowTokens: z.number().int().positive(), maxOutputTokens: z.number().int().positive() }).partial()).optional(),
|
|
33
|
+
discoveredModelLimits: z.record(z.string(), z.object({ contextWindowTokens: z.number().int().positive(), maxOutputTokens: z.number().int().positive() }).partial()).optional(),
|
|
29
34
|
}).passthrough();
|
|
30
35
|
const lspServerSchema = z.object({
|
|
31
36
|
name: z.string(),
|
|
@@ -119,7 +119,7 @@ export type AgentEvent = {
|
|
|
119
119
|
} | {
|
|
120
120
|
type: 'context_budget';
|
|
121
121
|
contextWindowTokens: number;
|
|
122
|
-
source: 'settings' | 'catalog' | 'user-fallback' | 'default-fallback' | 'deployment';
|
|
122
|
+
source: 'settings' | 'discovery' | 'preset' | 'catalog' | 'user-fallback' | 'default-fallback' | 'deployment';
|
|
123
123
|
at: string;
|
|
124
124
|
} | {
|
|
125
125
|
type: 'context_overflow';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ModelMessage } from 'ai';
|
|
2
|
+
/**
|
|
3
|
+
* Start a portable conversation boundary when the model changes. Provider
|
|
4
|
+
* reasoning and signatures cannot be reused across protocols; tool calls and
|
|
5
|
+
* results become labeled text so the new provider never receives an orphaned
|
|
6
|
+
* native call or assumes it can replay the old provider's hidden state.
|
|
7
|
+
*/
|
|
8
|
+
export declare function transitionProviderConversation(messages: ModelMessage[]): ModelMessage[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { escapeEnvelopeClosers } from '../safety/untrustedEnvelopes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Start a portable conversation boundary when the model changes. Provider
|
|
4
|
+
* reasoning and signatures cannot be reused across protocols; tool calls and
|
|
5
|
+
* results become labeled text so the new provider never receives an orphaned
|
|
6
|
+
* native call or assumes it can replay the old provider's hidden state.
|
|
7
|
+
*/
|
|
8
|
+
export function transitionProviderConversation(messages) {
|
|
9
|
+
const out = [];
|
|
10
|
+
for (const message of messages) {
|
|
11
|
+
if (message.role === 'tool') {
|
|
12
|
+
const data = JSON.stringify(message.content.map(part => {
|
|
13
|
+
if (part.type !== 'tool-result')
|
|
14
|
+
return part;
|
|
15
|
+
const clean = { ...part };
|
|
16
|
+
delete clean.providerOptions;
|
|
17
|
+
return clean;
|
|
18
|
+
}));
|
|
19
|
+
out.push({ role: 'user', content: `Previous tool results (data):\n<haze_compaction source="data">${escapeEnvelopeClosers(data)}</haze_compaction>` });
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const plain = { ...message };
|
|
23
|
+
delete plain.providerOptions;
|
|
24
|
+
if (!Array.isArray(message.content)) {
|
|
25
|
+
out.push(plain);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (message.role === 'assistant') {
|
|
29
|
+
const parts = [];
|
|
30
|
+
for (const part of message.content) {
|
|
31
|
+
if (part.type === 'text')
|
|
32
|
+
parts.push(part.text);
|
|
33
|
+
else if (part.type === 'tool-call')
|
|
34
|
+
parts.push(`Previous tool call ${part.toolName} (${part.toolCallId}): ${JSON.stringify(part.input)}`);
|
|
35
|
+
}
|
|
36
|
+
if (parts.length)
|
|
37
|
+
out.push({ role: 'assistant', content: parts.join('\n') });
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
out.push({ ...plain, content: message.content.map(part => {
|
|
41
|
+
const rest = { ...part };
|
|
42
|
+
delete rest.providerOptions;
|
|
43
|
+
return rest;
|
|
44
|
+
}) });
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
@@ -5,7 +5,7 @@ export type { ProviderCapabilities } from '../providerContracts.js';
|
|
|
5
5
|
* `provider-default`). `'none'` is an explicit request to disable reasoning;
|
|
6
6
|
* the stored `provider-default` sentinel means "send no parameter at all".
|
|
7
7
|
*/
|
|
8
|
-
export type ReasoningLevel = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
8
|
+
export type ReasoningLevel = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
9
9
|
export declare const REASONING_LEVELS: readonly ReasoningLevel[];
|
|
10
10
|
/**
|
|
11
11
|
* Level applied when nothing more specific exists: no session per-model
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const REASONING_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh'];
|
|
1
|
+
export const REASONING_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
2
2
|
/**
|
|
3
3
|
* Level applied when nothing more specific exists: no session per-model
|
|
4
4
|
* override and no `reasoning` settings key. Users opt out with an explicit
|
|
@@ -73,7 +73,7 @@ export function isReasoningLevel(value) {
|
|
|
73
73
|
}
|
|
74
74
|
/** Aliases accepted by CLI paths (`/reasoning`, `--reasoning`) for "send no reasoning parameter". */
|
|
75
75
|
export function isReasoningUnsetAlias(value) {
|
|
76
|
-
return value === 'unset' || value ===
|
|
76
|
+
return value === 'unset' || value === REASONING_PROVIDER_DEFAULT;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Parse a `--reasoning` CLI value (case-insensitive): a level maps directly,
|
|
@@ -82,6 +82,8 @@ export function isReasoningUnsetAlias(value) {
|
|
|
82
82
|
*/
|
|
83
83
|
export function parseReasoningOverride(raw) {
|
|
84
84
|
const value = raw.trim().toLowerCase();
|
|
85
|
+
if (value === 'off')
|
|
86
|
+
return { ok: true, setting: 'none' };
|
|
85
87
|
if (isReasoningUnsetAlias(value))
|
|
86
88
|
return { ok: true, setting: REASONING_PROVIDER_DEFAULT };
|
|
87
89
|
if (isReasoningLevel(value))
|
package/dist/core/limits.d.ts
CHANGED
|
@@ -49,5 +49,3 @@ export declare const COMPACTION_LLM_TRANSCRIPT_CHARS = 60000;
|
|
|
49
49
|
export declare const SESSION_INLINE_VALUE_BYTES: number;
|
|
50
50
|
/** Preview length for slimmed session values. */
|
|
51
51
|
export declare const SESSION_PREVIEW_CHARS: number;
|
|
52
|
-
/** Strings longer than this are truncated in session snapshots. */
|
|
53
|
-
export declare const SESSION_LARGE_STRING_CHARS: number;
|
package/dist/core/limits.js
CHANGED
|
@@ -49,5 +49,3 @@ export const COMPACTION_LLM_TRANSCRIPT_CHARS = 60_000;
|
|
|
49
49
|
export const SESSION_INLINE_VALUE_BYTES = 32 * 1024;
|
|
50
50
|
/** Preview length for slimmed session values. */
|
|
51
51
|
export const SESSION_PREVIEW_CHARS = 4 * 1024;
|
|
52
|
-
/** Strings longer than this are truncated in session snapshots. */
|
|
53
|
-
export const SESSION_LARGE_STRING_CHARS = 8 * 1024;
|
|
@@ -12,15 +12,12 @@ export interface ProviderCapabilities {
|
|
|
12
12
|
supportsStickySessionId: boolean;
|
|
13
13
|
supportsServerCompaction: boolean;
|
|
14
14
|
supportsTextVerbosity: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Protocol accepts a reasoning-effort request. Explicit-first: a provider
|
|
17
|
-
* `capabilities.reasoningEffort` override in settings wins. The default is
|
|
18
|
-
* the SDK pass-through (`true`) for hosted OpenAI-compatible endpoints and
|
|
19
|
-
* `false` for loopback/local inference servers, whose own reasoning switches
|
|
20
|
-
* (e.g. LM Studio's `on`/`off`) coerce unsupported levels — even `none` — to
|
|
21
|
-
* `on`, silently inverting the request. `false` omits the parameter entirely.
|
|
22
|
-
*/
|
|
15
|
+
/** The resolved model profile has at least one supported reasoning choice. */
|
|
23
16
|
supportsReasoningEffort: boolean;
|
|
17
|
+
/** Lowest supported worker effort when the model does not accept none. */
|
|
18
|
+
workerReasoningEffort?: ReasoningLevel;
|
|
19
|
+
/** OpenRouter accepts effort inside its provider-specific reasoning object. */
|
|
20
|
+
reasoningTransport?: 'openrouter';
|
|
24
21
|
/** Native template switch, independently of OpenAI effort pass-through. */
|
|
25
22
|
supportsBinaryThinking?: boolean;
|
|
26
23
|
}
|
|
@@ -32,3 +29,7 @@ export interface ProviderRequestOptions {
|
|
|
32
29
|
/** Codex subscription requests let the provider manage the output limit. */
|
|
33
30
|
omitMaxOutputTokens?: boolean;
|
|
34
31
|
}
|
|
32
|
+
/** Apply the same output-limit and purpose-specific reasoning rules to auxiliary calls. */
|
|
33
|
+
export declare function auxiliaryRequestOptions(options: ProviderRequestOptions, capabilities: ProviderCapabilities, purpose: 'worker' | 'compaction', maxOutputTokens: number): Omit<ProviderRequestOptions, 'omitMaxOutputTokens'> & {
|
|
34
|
+
maxOutputTokens?: number;
|
|
35
|
+
};
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/** Apply the same output-limit and purpose-specific reasoning rules to auxiliary calls. */
|
|
2
|
+
export function auxiliaryRequestOptions(options, capabilities, purpose, maxOutputTokens) {
|
|
3
|
+
const { omitMaxOutputTokens, ...result } = options;
|
|
4
|
+
if (purpose === 'worker') {
|
|
5
|
+
const effort = capabilities.workerReasoningEffort;
|
|
6
|
+
if (capabilities.reasoningTransport === 'openrouter') {
|
|
7
|
+
const openrouter = { ...result.providerOptions?.openrouter };
|
|
8
|
+
if (effort)
|
|
9
|
+
openrouter.reasoning = { effort };
|
|
10
|
+
else
|
|
11
|
+
delete openrouter.reasoning;
|
|
12
|
+
result.providerOptions = { ...result.providerOptions, openrouter };
|
|
13
|
+
delete result.reasoning;
|
|
14
|
+
}
|
|
15
|
+
else if (effort)
|
|
16
|
+
result.reasoning = effort;
|
|
17
|
+
else
|
|
18
|
+
delete result.reasoning;
|
|
19
|
+
}
|
|
20
|
+
return { ...result, ...(!omitMaxOutputTokens ? { maxOutputTokens } : {}) };
|
|
21
|
+
}
|
|
@@ -17,8 +17,18 @@ const SECRET_PATTERNS = [
|
|
|
17
17
|
{ kind: 'aws-key', pattern: /AKIA[0-9A-Z]{16}/g },
|
|
18
18
|
// Slack tokens (bot, app, refresh, user tokens).
|
|
19
19
|
{ kind: 'slack-token', pattern: /xox[baprs]-[A-Za-z0-9-]{10,}/g },
|
|
20
|
-
// JWTs (three base64url segments starting with a JSON header).
|
|
21
|
-
|
|
20
|
+
// JWTs (three base64url segments starting with a JSON header). Per-segment
|
|
21
|
+
// minimums cut false positives on short token-shaped strings while still
|
|
22
|
+
// matching real JWTs, whose segments are far longer than this.
|
|
23
|
+
{ kind: 'jwt', pattern: /eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g },
|
|
24
|
+
// GitHub fine-grained / long-lived personal access tokens (github_pat_ prefix).
|
|
25
|
+
{ kind: 'github-token', pattern: /github_pat_[A-Za-z0-9_]{20,}/g },
|
|
26
|
+
// GCP API keys (AIza prefix).
|
|
27
|
+
{ kind: 'gcp-api-key', pattern: /AIza[0-9A-Za-z_-]{30,}/g },
|
|
28
|
+
// Google OAuth client secrets (GOCSPX prefix).
|
|
29
|
+
{ kind: 'oauth-client-secret', pattern: /GOCSPX-[A-Za-z0-9_-]{20,}/g },
|
|
30
|
+
// Stripe restricted keys (rk_live_ / rk_test_ prefix).
|
|
31
|
+
{ kind: 'stripe-key', pattern: /rk_(live|test)_[A-Za-z0-9]{20,}/g },
|
|
22
32
|
];
|
|
23
33
|
/** Replace common secret token shapes in a string with `[redacted:<kind>]`. */
|
|
24
34
|
export function redactSecrets(text) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { SESSION_INLINE_VALUE_BYTES as INLINE_VALUE_BYTES,
|
|
2
|
-
import {
|
|
1
|
+
import { SESSION_INLINE_VALUE_BYTES as INLINE_VALUE_BYTES, SESSION_PREVIEW_CHARS as PREVIEW_CHARS } from '../limits.js';
|
|
2
|
+
import { encodeSnapshotMessages } from './snapshotCodec.js';
|
|
3
3
|
import { redactUnknown } from '../safety/redaction.js';
|
|
4
|
-
import { formatBytes } from '../../utils/format.js';
|
|
5
4
|
function jsonByteLength(value) {
|
|
6
5
|
try {
|
|
7
6
|
return Buffer.byteLength(JSON.stringify(value), 'utf8');
|
|
@@ -25,62 +24,9 @@ function slimLargeValue(value) {
|
|
|
25
24
|
preview: previewText(value),
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Image file parts become text placeholders (F03): resumed sessions must not
|
|
30
|
-
* replay megabytes of base64, and the placeholder stays a protocol-safe
|
|
31
|
-
* ModelMessage part for any provider. The model re-asks if it needs the image.
|
|
32
|
-
*/
|
|
33
|
-
function slimImageFilePart(part) {
|
|
34
|
-
const bytes = imageFilePartBytes(part.data);
|
|
35
|
-
const name = typeof part.filename === 'string' && part.filename ? ` ${part.filename}` : '';
|
|
36
|
-
return {
|
|
37
|
-
type: 'text',
|
|
38
|
-
text: `[image omitted from session:${name} ${part.mediaType}, ${formatBytes(bytes)} — ask the user to re-attach it if needed]`,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
27
|
function isRecord(value) {
|
|
42
28
|
return typeof value === 'object' && value != null && !Array.isArray(value);
|
|
43
29
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Slim a tool-result output while preserving the AI SDK output envelope.
|
|
46
|
-
* Restored snapshots are re-sent to providers, and `modelMessageSchema` requires
|
|
47
|
-
* a tool-result output to be `{type: 'json'|'text'|... , value}`; a bare slim
|
|
48
|
-
* marker as the output made every resumed session fail with
|
|
49
|
-
* AI_InvalidPromptError (F-09 regression).
|
|
50
|
-
*/
|
|
51
|
-
function slimToolResultOutput(output) {
|
|
52
|
-
if (!isRecord(output) || typeof output.type !== 'string' || !('value' in output))
|
|
53
|
-
return slimLargeValue(output);
|
|
54
|
-
return { ...output, value: slimLargeValue(output.value) };
|
|
55
|
-
}
|
|
56
|
-
function slimUnknown(value, seen = new WeakSet()) {
|
|
57
|
-
if (typeof value === 'string') {
|
|
58
|
-
if (value.length <= LARGE_STRING_CHARS)
|
|
59
|
-
return value;
|
|
60
|
-
return `${value.slice(0, PREVIEW_CHARS)}\n\n[Session value truncated: ${value.length - PREVIEW_CHARS} characters omitted]`;
|
|
61
|
-
}
|
|
62
|
-
if (value == null || typeof value !== 'object')
|
|
63
|
-
return value;
|
|
64
|
-
if (seen.has(value))
|
|
65
|
-
return '[Circular]';
|
|
66
|
-
seen.add(value);
|
|
67
|
-
if (Array.isArray(value))
|
|
68
|
-
return value.map(item => slimUnknown(item, seen));
|
|
69
|
-
const record = value;
|
|
70
|
-
if (isImageFilePart(record))
|
|
71
|
-
return slimImageFilePart(record);
|
|
72
|
-
if (record.type === 'tool-result') {
|
|
73
|
-
return {
|
|
74
|
-
...record,
|
|
75
|
-
output: slimToolResultOutput(record.output),
|
|
76
|
-
result: slimLargeValue(record.result),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
const next = {};
|
|
80
|
-
for (const [key, child] of Object.entries(record))
|
|
81
|
-
next[key] = slimUnknown(child, seen);
|
|
82
|
-
return next;
|
|
83
|
-
}
|
|
84
30
|
/**
|
|
85
31
|
* Restore-side repair (F-09): sessions written before the envelope fix store
|
|
86
32
|
* bare `{omitted, reason, originalBytes, preview}` slim markers as tool-result
|
|
@@ -115,8 +61,8 @@ function isLegacySlimMarker(value) {
|
|
|
115
61
|
export function repairRestoredConversation(messages) {
|
|
116
62
|
return repairLegacySlimmedMessages(messages);
|
|
117
63
|
}
|
|
118
|
-
function
|
|
119
|
-
return
|
|
64
|
+
function prepareConversationSnapshot(messages) {
|
|
65
|
+
return encodeSnapshotMessages(messages);
|
|
120
66
|
}
|
|
121
67
|
function slimToolStartInput(input) {
|
|
122
68
|
// Full tool inputs (writeFile/editFile payloads can be tens of KB) are replaced
|
|
@@ -180,7 +126,7 @@ function slimSessionEntry(entry) {
|
|
|
180
126
|
return entry;
|
|
181
127
|
}
|
|
182
128
|
if (entry.type === 'conversation_snapshot') {
|
|
183
|
-
return { ...entry, messages:
|
|
129
|
+
return { ...entry, messages: prepareConversationSnapshot(entry.messages) };
|
|
184
130
|
}
|
|
185
131
|
// Goal-ledger entries are small bounded metadata; only the request text is
|
|
186
132
|
// capped (a pathological 256 KiB piped prompt must not bloat every boundary
|
|
@@ -4,6 +4,7 @@ import type { ValidationKind } from '../../llm/toolResultTypes.js';
|
|
|
4
4
|
export interface SessionModelSelection {
|
|
5
5
|
provider: string;
|
|
6
6
|
model: string;
|
|
7
|
+
endpointFingerprint?: string;
|
|
7
8
|
}
|
|
8
9
|
export type SessionEntry = {
|
|
9
10
|
type: 'header';
|
|
@@ -25,6 +26,7 @@ export type SessionEntry = {
|
|
|
25
26
|
type: 'conversation_snapshot';
|
|
26
27
|
at: string;
|
|
27
28
|
messages: ModelMessage[];
|
|
29
|
+
selection?: SessionModelSelection;
|
|
28
30
|
} | {
|
|
29
31
|
type: 'work_state_snapshot';
|
|
30
32
|
at: string;
|
|
@@ -119,6 +121,8 @@ export interface HazeSession {
|
|
|
119
121
|
* resumed; default (absent/false) persists entries verbatim.
|
|
120
122
|
*/
|
|
121
123
|
redactSecrets?: boolean;
|
|
124
|
+
/** Internal: the existing JSONL tail has been checked before appending. */
|
|
125
|
+
tailChecked?: boolean;
|
|
122
126
|
}
|
|
123
127
|
export declare function createSession(options?: {
|
|
124
128
|
cwd?: string;
|