@denizokcu/haze 1.7.10 → 1.7.12

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +125 -99
  3. package/assets/graph-grammars/NOTICE.md +21 -0
  4. package/assets/graph-grammars/tree-sitter-javascript.wasm +0 -0
  5. package/assets/graph-grammars/tree-sitter-tsx.wasm +0 -0
  6. package/assets/graph-grammars/tree-sitter-typescript.wasm +0 -0
  7. package/assets/graph-grammars/web-tree-sitter.cjs +4116 -0
  8. package/assets/graph-grammars/web-tree-sitter.cjs.map +7 -0
  9. package/assets/graph-grammars/web-tree-sitter.js +4056 -0
  10. package/assets/graph-grammars/web-tree-sitter.js.map +7 -0
  11. package/assets/graph-grammars/web-tree-sitter.wasm +0 -0
  12. package/assets/graph-grammars/web-tree-sitter.wasm.map +55 -0
  13. package/dist/buildInfo.json +3 -3
  14. package/dist/cli/chat/BusyBar.d.ts +2 -1
  15. package/dist/cli/chat/BusyBar.js +2 -2
  16. package/dist/cli/chat/chatMetrics.d.ts +25 -0
  17. package/dist/cli/chat/chatMetrics.js +36 -0
  18. package/dist/cli/chat/inputSuggestions.js +1 -0
  19. package/dist/cli/chat/sessionLifecycle.d.ts +2 -0
  20. package/dist/cli/chat/sessionLifecycle.js +29 -19
  21. package/dist/cli/chat/sessionRecorder.d.ts +2 -1
  22. package/dist/cli/chat/sessionRecorder.js +29 -9
  23. package/dist/cli/chat/startupSequence.d.ts +2 -0
  24. package/dist/cli/chat/startupSequence.js +6 -0
  25. package/dist/cli/chat/transcriptPartition.js +10 -4
  26. package/dist/cli/chat/wizard/providerHandlers.js +57 -9
  27. package/dist/cli/chat/wizard/sessionThemeHandlers.js +5 -1
  28. package/dist/cli/commands/chat.js +44 -9
  29. package/dist/cli/commands/commandHelp.js +6 -3
  30. package/dist/cli/commands/commands.js +2 -0
  31. package/dist/cli/commands/formatters.js +28 -0
  32. package/dist/cli/commands/graphCommand.d.ts +2 -0
  33. package/dist/cli/commands/graphCommand.js +60 -0
  34. package/dist/cli/commands/initCommand.js +14 -0
  35. package/dist/cli/commands/providerWizard.js +9 -17
  36. package/dist/cli/commands/reasoningCommand.d.ts +1 -0
  37. package/dist/cli/commands/reasoningCommand.js +32 -4
  38. package/dist/cli/commands/runCommand.js +7 -1
  39. package/dist/cli/commands/streaming/agentAttempt.js +11 -1
  40. package/dist/cli/commands/streaming/attemptLifecycle.js +1 -0
  41. package/dist/cli/commands/streaming/attemptOutcome.js +6 -2
  42. package/dist/cli/commands/streaming/attemptSetup.d.ts +3 -0
  43. package/dist/cli/commands/streaming/attemptSetup.js +13 -6
  44. package/dist/cli/commands/streaming/goalSupervisor.d.ts +1 -1
  45. package/dist/cli/commands/streaming/goalSupervisor.js +22 -1
  46. package/dist/cli/commands/streaming/prepareStep.js +1 -0
  47. package/dist/cli/commands/streaming/streamLoop.d.ts +2 -0
  48. package/dist/cli/commands/streaming/streamLoop.js +14 -10
  49. package/dist/cli/commands/streaming/toolPartHandlers.js +7 -1
  50. package/dist/cli/commands/streaming.d.ts +2 -0
  51. package/dist/cli/commands/streaming.js +5 -0
  52. package/dist/cli/commands/wizardFlow.d.ts +1 -0
  53. package/dist/cli/commands/wizardFlow.js +10 -4
  54. package/dist/cli/index.js +5 -3
  55. package/dist/config/hazeBuild.d.ts +2 -2
  56. package/dist/config/hazeBuild.js +2 -2
  57. package/dist/config/modelDiscovery.d.ts +1 -1
  58. package/dist/config/modelDiscovery.js +8 -8
  59. package/dist/config/{modelCatalog.d.ts → providerModelFacts.d.ts} +13 -2
  60. package/dist/config/{modelCatalog.js → providerModelFacts.js} +145 -21
  61. package/dist/config/providerPresets.d.ts +8 -19
  62. package/dist/config/providerPresets.js +86 -555
  63. package/dist/config/providerReasoning.d.ts +16 -0
  64. package/dist/config/providerReasoning.js +56 -0
  65. package/dist/config/providers.d.ts +4 -0
  66. package/dist/config/providers.js +19 -2
  67. package/dist/config/settings.d.ts +14 -0
  68. package/dist/config/settings.js +5 -0
  69. package/dist/core/agent/compaction.d.ts +1 -0
  70. package/dist/core/agent/compaction.js +3 -0
  71. package/dist/core/agent/events.d.ts +1 -1
  72. package/dist/core/agent/providerTransition.d.ts +8 -0
  73. package/dist/core/agent/providerTransition.js +47 -0
  74. package/dist/core/agent/reasoningPolicy.d.ts +1 -1
  75. package/dist/core/agent/reasoningPolicy.js +4 -2
  76. package/dist/core/graph/analyze.d.ts +61 -0
  77. package/dist/core/graph/analyze.js +274 -0
  78. package/dist/core/graph/buildGraph.d.ts +44 -0
  79. package/dist/core/graph/buildGraph.js +290 -0
  80. package/dist/core/graph/digest.d.ts +2 -0
  81. package/dist/core/graph/digest.js +40 -0
  82. package/dist/core/graph/extract.d.ts +58 -0
  83. package/dist/core/graph/extract.js +394 -0
  84. package/dist/core/graph/model.d.ts +63 -0
  85. package/dist/core/graph/model.js +96 -0
  86. package/dist/core/graph/query.d.ts +69 -0
  87. package/dist/core/graph/query.js +391 -0
  88. package/dist/core/graph/store.d.ts +64 -0
  89. package/dist/core/graph/store.js +171 -0
  90. package/dist/core/limits.d.ts +0 -2
  91. package/dist/core/limits.js +0 -2
  92. package/dist/core/process/runBoundedProcess.js +12 -6
  93. package/dist/core/providerContracts.d.ts +9 -8
  94. package/dist/core/providerContracts.js +21 -1
  95. package/dist/core/safety/redaction.js +12 -2
  96. package/dist/core/safety/untrustedEnvelopes.d.ts +6 -0
  97. package/dist/core/safety/untrustedEnvelopes.js +17 -2
  98. package/dist/core/session/sessionSlimming.js +5 -59
  99. package/dist/core/session/sessionStore.d.ts +4 -0
  100. package/dist/core/session/sessionStore.js +149 -9
  101. package/dist/core/session/snapshotCodec.d.ts +5 -0
  102. package/dist/core/session/snapshotCodec.js +47 -0
  103. package/dist/core/shellOutput/registry.js +2 -46
  104. package/dist/core/subagent/executionProfiles.js +8 -5
  105. package/dist/core/tasks/taskStorage.js +11 -1
  106. package/dist/core/toolOutput/reduction.d.ts +55 -2
  107. package/dist/core/toolOutput/reduction.js +77 -2
  108. package/dist/core/validation/outputParser.js +16 -8
  109. package/dist/llm/client.d.ts +4 -2
  110. package/dist/llm/client.js +104 -55
  111. package/dist/llm/hazeTools.d.ts +2 -12426
  112. package/dist/llm/hazeTools.js +2 -0
  113. package/dist/llm/lspTools.d.ts +3 -12622
  114. package/dist/llm/mistralReasoning.d.ts +2 -0
  115. package/dist/llm/mistralReasoning.js +17 -0
  116. package/dist/llm/mistralVibeAuth.d.ts +5 -0
  117. package/dist/llm/mistralVibeAuth.js +63 -0
  118. package/dist/llm/requestContext.d.ts +3 -0
  119. package/dist/llm/requestContext.js +21 -11
  120. package/dist/llm/subagentRunner.d.ts +2 -308
  121. package/dist/llm/subagentRunner.js +15 -7
  122. package/dist/llm/systemPrompt.js +7 -4
  123. package/dist/llm/toolResultTypes.d.ts +1 -1
  124. package/dist/llm/toolResultTypes.js +7 -1
  125. package/dist/llm/tools/fetchTool.d.ts +2 -1221
  126. package/dist/llm/tools/fileTools.d.ts +2 -7768
  127. package/dist/llm/tools/graphAdvisory.d.ts +22 -0
  128. package/dist/llm/tools/graphAdvisory.js +68 -0
  129. package/dist/llm/tools/graphTools.d.ts +13 -0
  130. package/dist/llm/tools/graphTools.js +195 -0
  131. package/dist/llm/tools/outputCap.d.ts +2 -7
  132. package/dist/llm/tools/outputCap.js +3 -11
  133. package/dist/llm/tools/processTool.d.ts +2 -1081
  134. package/dist/llm/tools/replaceInFiles.js +5 -0
  135. package/dist/llm/tools/shellTool.d.ts +2 -1513
  136. package/dist/llm/tools/storedOutputTool.d.ts +2 -355
  137. package/dist/llm/tools/taskTool.d.ts +2 -489
  138. package/dist/llm/tools/toolContext.js +24 -9
  139. package/dist/llm/tools/toolContextState.d.ts +3 -0
  140. package/dist/llm/tools/toolContextState.js +2 -1
  141. package/dist/skills/skillTools.js +4 -1
  142. package/package.json +24 -15
@@ -1,24 +1,148 @@
1
- /**
2
- * Curated model metadata catalog (Pillar 1.8 of the Pi learning roadmap).
3
- *
4
- * Keys are **model-name patterns** (not provider names) because haze reaches
5
- * most models through user-configured OpenAI-compatible gateways where the
6
- * provider name is arbitrary — the model id is the only stable identity.
7
- *
8
- * Precedence (enforced in `llm/client.ts`): per-model `modelLimits` settings →
9
- * this catalog → user-set context-window fallback → built-in default fallback.
10
- * Values are deliberately conservative (input-safe): when a family differs
11
- * between variants, the smaller window wins — under-budgeting only compacts a
12
- * little earlier, over-budgeting hard-fails the request. First match wins, so
13
- * keep more specific patterns before broader family prefixes.
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
- *
18
- * Local inference servers (localhost URLs) never consult the catalog: their
19
- * effective window is set by server configuration (often far below the model's
20
- * nominal window) and silent truncation there is undetectable.
21
- */
1
+ const ENDPOINT_MODEL_LIMITS = {
2
+ 'https://openrouter.ai/api/v1': {
3
+ 'anthropic/claude-opus-5.5': [1_000_000, 128_000],
4
+ 'anthropic/claude-sonnet-5.5': [1_000_000, 128_000],
5
+ 'openai/gpt-6.1-sol': [922_000, 128_000],
6
+ 'openai/gpt-6-luna': [922_000, 128_000],
7
+ 'google/gemini-4-argon': [1_048_576, 32_768],
8
+ 'google/gemini-3.8-flash': [1_048_576, 65_536],
9
+ 'mistralai/mistral-large-4-0': [1_048_576, 262_144],
10
+ 'deepseek/deepseek-v4.1-flash': [1_048_576, 393_216],
11
+ 'moonshotai/kimi-k3.1-pro': [1_048_576, 131_072],
12
+ 'z-ai/glm-5.3': [1_000_000, 131_072],
13
+ 'qwen/qwen3.8-2.4t-a95b': [1_048_576, 131_072],
14
+ 'minimax/minimax-m3.1-flash': [1_048_576, 524_288],
15
+ 'x-ai/grok-4.7': [500_000, 450_000],
16
+ },
17
+ 'https://api.openai.com/v1': {
18
+ 'gpt-6.1-sol': [922_000, 128_000],
19
+ 'gpt-6-astra': [922_000, 128_000],
20
+ 'gpt-6-luna': [922_000, 128_000],
21
+ },
22
+ 'https://chatgpt.com/backend-api/codex': {
23
+ 'gpt-6.1-sol': [500_000, 128_000],
24
+ 'gpt-6.1-terra': [500_000, 128_000],
25
+ 'gpt-6-luna': [272_000, 128_000],
26
+ 'gpt-5.6-sol': [272_000, 128_000],
27
+ 'gpt-5.6-terra': [272_000, 128_000],
28
+ 'gpt-5.6-luna': [272_000, 128_000],
29
+ },
30
+ 'https://generativelanguage.googleapis.com/v1beta/openai': {
31
+ 'gemini-4-argon': [1_048_576, 32_768],
32
+ 'gemini-3.8-flash': [1_048_576, 65_536],
33
+ },
34
+ 'https://api.mistral.ai/v1': {
35
+ 'mistral-large-4': [1_048_576, 262_144],
36
+ },
37
+ 'https://api.deepseek.com/v1': {
38
+ 'deepseek-v4-pro': [1_048_576, 393_216],
39
+ 'deepseek-flash': [1_048_576, 393_216],
40
+ },
41
+ 'https://api.x.ai/v1': {
42
+ 'grok-4.7': [500_000, 500_000],
43
+ 'grok-4.6': [500_000, 500_000],
44
+ },
45
+ 'https://api.z.ai/api/paas/v4': {
46
+ 'glm-5.3': [1_000_000, 131_072],
47
+ 'glm-5.3-flash': [1_000_000, 131_072],
48
+ },
49
+ 'https://api.z.ai/api/coding/paas/v4': {
50
+ 'glm-5.3': [1_000_000, 131_072],
51
+ 'glm-5.2-highspeed': [1_000_000, 131_072],
52
+ },
53
+ 'https://api.moonshot.ai/v1': {
54
+ 'kimi-k3.1-pro': [1_048_576, 131_072],
55
+ 'kimi-k3': [1_048_576, 131_072],
56
+ },
57
+ 'https://api.kimi.com/coding/v1': {
58
+ 'k3': [1_048_576, 131_072],
59
+ 'k3.1-pro': [1_048_576, 131_072],
60
+ },
61
+ 'https://api.groq.com/openai/v1': {
62
+ 'openai/gpt-oss-120b': [131_072, 65_536],
63
+ 'qwen/qwen3.8-27b': [131_072, 16_384],
64
+ },
65
+ 'https://api.together.ai/v1': {
66
+ 'deepseek-ai/DeepSeek-V4-Pro-0813': [1_048_576, 384_000],
67
+ 'moonshotai/Kimi-K3.1-Pro': [1_048_576, 131_072],
68
+ },
69
+ };
70
+ function documentedReasoningLevels(url, model) {
71
+ let host;
72
+ try {
73
+ host = new URL(url).hostname.toLowerCase();
74
+ }
75
+ catch {
76
+ return undefined;
77
+ }
78
+ if (host === 'api.mistral.ai') {
79
+ switch (model.toLowerCase()) {
80
+ case 'mistral-small-2603':
81
+ case 'mistral-small-latest':
82
+ case 'mistral-medium-latest':
83
+ case 'mistral-medium-3-5':
84
+ case 'mistral-vibe-cli-latest': return ['none', 'high'];
85
+ case 'mistral-large-4':
86
+ case 'mistral-large-4-0': return ['low', 'medium', 'high'];
87
+ case 'zai-glm-5-3':
88
+ case 'zai-glm-5-3-flash': return ['low', 'high', 'max'];
89
+ default: return undefined;
90
+ }
91
+ }
92
+ if (host === 'api.openai.com') {
93
+ if (/^gpt-4(?:o|\.1)(?:-|$)/i.test(model))
94
+ return [];
95
+ if (/^gpt-5\.(?:2|4)(?:-mini)?(?:-\d{4}-\d{2}-\d{2})?$/i.test(model))
96
+ return ['none', 'low', 'medium', 'high', 'xhigh'];
97
+ if (/^gpt-5\.6(?:-(?:sol|terra|luna))?$/i.test(model))
98
+ return ['none', 'low', 'medium', 'high', 'xhigh', 'max'];
99
+ if (/^gpt-5\.5$/i.test(model))
100
+ return ['none', 'low', 'medium', 'high', 'xhigh'];
101
+ if (/^gpt-6(?:\.1)?-(?:astra|sol|terra|luna)$/i.test(model)) {
102
+ return /^gpt-6(?:-sol|-luna|\.1-terra)$/i.test(model) ? ['none', 'low', 'medium', 'high', 'xhigh', 'max'] : ['low', 'medium', 'high', 'xhigh', 'max'];
103
+ }
104
+ }
105
+ if (host === 'generativelanguage.googleapis.com') {
106
+ if (/^gemini-3\.(?:7|8)-flash(?:-|$)/i.test(model))
107
+ return ['low', 'medium', 'high'];
108
+ if (/^gemini-3-pro(?:-|$)/i.test(model))
109
+ return ['low', 'high'];
110
+ if (/^gemini-3\.1-pro(?:-|$)/i.test(model))
111
+ return ['low', 'medium', 'high'];
112
+ if (/^gemini-3(?:\.1)?-(?:pro|flash)(?:-lite)?(?:-|$)/i.test(model))
113
+ return ['minimal', 'low', 'medium', 'high'];
114
+ if (/^gemini-2\.5-pro(?:-|$)/i.test(model))
115
+ return ['low', 'medium', 'high'];
116
+ if (/^gemini-2\.5-flash(?:-lite)?(?:-|$)/i.test(model))
117
+ return ['none', 'low', 'medium', 'high'];
118
+ }
119
+ if (host === 'api.deepseek.com' && /^(?:deepseek-flash|deepseek-v4(?:\.1)?-(?:flash|pro))$/i.test(model))
120
+ return ['none', 'low', 'high', 'max'];
121
+ if (host === 'api.groq.com') {
122
+ if (/^openai\/gpt-oss-(?:20b|120b)$/i.test(model))
123
+ return ['low', 'medium', 'high'];
124
+ if (model.toLowerCase() === 'qwen/qwen3.8-27b')
125
+ return ['none', 'low', 'medium', 'high'];
126
+ }
127
+ if ((host === 'api.x.ai' || host.endsWith('.api.x.ai')) && /^grok-4\.[67]$/i.test(model))
128
+ return ['low', 'medium', 'high', 'xhigh'];
129
+ // The coding subscription and direct API have always-thinking K3 variants;
130
+ // use the shared subset instead of sending unsupported none to workers.
131
+ if ((host === 'api.moonshot.ai' && /^kimi-k3(?:\.1-pro)?$/i.test(model))
132
+ || ((host === 'api.kimi.com' || host === 'api.kimi.ai') && /^k3(?:\.1-pro)?$/i.test(model)))
133
+ return ['low', 'high', 'max'];
134
+ return undefined;
135
+ }
136
+ /** Lookup uses the actual endpoint and exact model ID; documented aliases are handled by the reasoning profiles. */
137
+ export function endpointModelFacts(url, model) {
138
+ const endpoint = url.replace(/\/+$/, '').toLowerCase();
139
+ const entries = ENDPOINT_MODEL_LIMITS[endpoint];
140
+ const key = model.toLowerCase();
141
+ const values = entries && Object.entries(entries).find(([id]) => id.toLowerCase() === key)?.[1];
142
+ const limits = values ? { contextWindowTokens: values[0], maxOutputTokens: values[1] } : undefined;
143
+ const reasoningLevels = documentedReasoningLevels(url, model);
144
+ return { ...(limits ? { limits } : {}), ...(reasoningLevels !== undefined ? { reasoningLevels } : {}) };
145
+ }
22
146
  const MODEL_CATALOG = [
23
147
  // ── OpenAI ────────────────────────────────────────────────────────────────
24
148
  { match: 'gpt-6.1-sol', contextWindowTokens: 1_050_000, maxOutputTokens: 128_000 },
@@ -6,19 +6,14 @@
6
6
  * Hosted presets carry a pre-configured base URL so users only need to supply an API key
7
7
  * and model names. Local/keyless providers have sensible localhost defaults.
8
8
  *
9
- * Presets are authored in a compact definition form (`ProviderPresetDefinition`) and
10
- * expanded once into the public `ProviderPreset` records: each curated model is a single
11
- * `[id, contextWindowTokens, maxOutputTokens]` tuple instead of appearing twice (once in
12
- * `suggestedModels`, once in `modelLimits`), and `needsApiKey` is derived from the
13
- * category (cloud presets need a key unless they carry an explicit OAuth flow; local
14
- * ones never do).
9
+ * Presets list model IDs; limits and reasoning capabilities live in the shared
10
+ * endpoint/model facts. `needsApiKey` is derived from category and auth flow.
15
11
  *
16
- * `modelLimits` values are curated from models.dev (the same catalog pi and nanocoder
17
- * consume; recent releases refreshed 2026-10-04 from https://models.dev/api.json). They are keyed by the exact suggested model id for
12
+ * `modelLimits` values are curated from provider catalogs and models.dev. They are keyed by the exact suggested model id for
18
13
  * THIS preset: aggregators may cap context below the origin model's capability (e.g.
19
14
  * Together serves DeepSeek-V4-Pro at 512K vs DeepSeek's own 1M), so limits never
20
- * transfer between providers. When the wizard adds a suggested model, these values are
21
- * written into the provider's settings `modelLimits`, where they remain user-editable.
15
+ * transfer between providers. These values remain in the shared facts and are resolved at
16
+ * runtime after explicit settings and live discovery.
22
17
  * Local providers (Ollama/llama.cpp/MLX/LM Studio) intentionally carry no limits: their
23
18
  * effective context depends on the local server configuration, not the model.
24
19
  */
@@ -38,7 +33,7 @@ export interface ProviderPreset {
38
33
  /** Whether an API key is typically required. Local and OAuth providers use false. */
39
34
  needsApiKey: boolean;
40
35
  /** Provider-specific sign-in flow, when setup is not an API-key prompt. */
41
- auth?: 'chatgpt-oauth';
36
+ auth?: 'chatgpt-oauth' | 'mistral-vibe';
42
37
  /** Hint shown when prompting for the API key. */
43
38
  apiKeyHint?: string;
44
39
  /**
@@ -61,15 +56,9 @@ export interface ProviderPreset {
61
56
  /** Category for grouping in the picker. */
62
57
  category: 'cloud' | 'local';
63
58
  }
64
- export declare const PROVIDER_PRESETS: ProviderPreset[];
59
+ export declare const PROVIDER_PRESETS: readonly ProviderPreset[];
65
60
  export declare function findPreset(id: string): ProviderPreset | undefined;
66
- /**
67
- * Limits for models a wizard flow is adding to a provider, matched by the
68
- * provider's base URL or its name (a provider created from a preset keeps the
69
- * preset's name unless the user renamed it). Returns only entries the caller
70
- * should merge into the provider's settings `modelLimits`; user-configured
71
- * limits always win because callers merge without overwriting existing keys.
72
- */
61
+ /** Only copy limits for selected models and an unambiguous provider endpoint. */
73
62
  export declare function presetModelLimitsForModels(provider: {
74
63
  name?: string;
75
64
  url?: string;