@denizokcu/haze 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/CHANGELOG.md +133 -17
  2. package/README.md +164 -68
  3. package/SECURITY.md +22 -0
  4. package/bin/haze.js +102 -1
  5. package/dist/buildInfo.json +7 -0
  6. package/dist/cli/chat/TaskBar.d.ts +2 -1
  7. package/dist/cli/chat/TaskBar.js +7 -4
  8. package/dist/cli/chat/chatMetrics.d.ts +17 -1
  9. package/dist/cli/chat/chatMetrics.js +22 -5
  10. package/dist/cli/chat/contextReport.d.ts +11 -0
  11. package/dist/cli/chat/contextReport.js +46 -0
  12. package/dist/cli/chat/fileMentionSuggestions.d.ts +29 -0
  13. package/dist/cli/chat/fileMentionSuggestions.js +92 -0
  14. package/dist/cli/chat/inputSuggestions.d.ts +5 -0
  15. package/dist/cli/chat/inputSuggestions.js +17 -3
  16. package/dist/cli/chat/liveRegion.d.ts +25 -0
  17. package/dist/cli/chat/liveRegion.js +48 -0
  18. package/dist/cli/chat/messages.d.ts +33 -2
  19. package/dist/cli/chat/messages.js +216 -33
  20. package/dist/cli/chat/sessionLifecycle.d.ts +67 -0
  21. package/dist/cli/chat/sessionLifecycle.js +205 -0
  22. package/dist/cli/chat/sessionRecorder.js +80 -14
  23. package/dist/cli/chat/startupInfo.js +11 -4
  24. package/dist/cli/chat/tips.d.ts +21 -0
  25. package/dist/cli/chat/tips.js +43 -0
  26. package/dist/cli/chat/wizardDispatch.d.ts +64 -0
  27. package/dist/cli/chat/wizardDispatch.js +744 -0
  28. package/dist/cli/commands/chat.d.ts +6 -0
  29. package/dist/cli/commands/chat.js +373 -790
  30. package/dist/cli/commands/chatModes.d.ts +1 -1
  31. package/dist/cli/commands/chatModes.js +7 -2
  32. package/dist/cli/commands/commandHelp.js +5 -3
  33. package/dist/cli/commands/commands.d.ts +5 -2
  34. package/dist/cli/commands/commands.js +22 -18
  35. package/dist/cli/commands/doctor.d.ts +19 -0
  36. package/dist/cli/commands/doctor.js +76 -0
  37. package/dist/cli/commands/fleetCommand.d.ts +14 -0
  38. package/dist/cli/commands/fleetCommand.js +46 -0
  39. package/dist/cli/commands/formatters.d.ts +5 -0
  40. package/dist/cli/commands/formatters.js +35 -6
  41. package/dist/cli/commands/logsCommand.js +1 -7
  42. package/dist/cli/commands/modelCommand.js +1 -1
  43. package/dist/cli/commands/ndjsonSink.d.ts +23 -0
  44. package/dist/cli/commands/ndjsonSink.js +38 -0
  45. package/dist/cli/commands/providerWizard.d.ts +10 -2
  46. package/dist/cli/commands/providerWizard.js +50 -4
  47. package/dist/cli/commands/runCommand.d.ts +4 -0
  48. package/dist/cli/commands/runCommand.js +142 -16
  49. package/dist/cli/commands/sessionPicker.d.ts +9 -0
  50. package/dist/cli/commands/sessionPicker.js +29 -0
  51. package/dist/cli/commands/settingsSummary.js +6 -4
  52. package/dist/cli/commands/skillConfirmRemove.js +4 -3
  53. package/dist/cli/commands/skillWizard.d.ts +2 -0
  54. package/dist/cli/commands/skillWizard.js +16 -6
  55. package/dist/cli/commands/streaming/abortCause.d.ts +24 -0
  56. package/dist/cli/commands/streaming/abortCause.js +16 -0
  57. package/dist/cli/commands/streaming/assistantText.js +9 -2
  58. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +65 -0
  59. package/dist/cli/commands/streaming/goalCheckpoint.js +23 -0
  60. package/dist/cli/commands/streaming/goalSupervisor.d.ts +64 -0
  61. package/dist/cli/commands/streaming/goalSupervisor.js +127 -0
  62. package/dist/cli/commands/streaming/idleTimer.d.ts +26 -0
  63. package/dist/cli/commands/streaming/idleTimer.js +24 -0
  64. package/dist/cli/commands/streaming/toolCallRecovery.d.ts +2 -0
  65. package/dist/cli/commands/streaming/toolCallRecovery.js +24 -0
  66. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -0
  67. package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -2
  68. package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
  69. package/dist/cli/commands/streaming/toolResultState.js +29 -7
  70. package/dist/cli/commands/streaming/turnOutcome.d.ts +17 -0
  71. package/dist/cli/commands/streaming/turnOutcome.js +27 -11
  72. package/dist/cli/commands/streaming/turnRuntime.js +6 -4
  73. package/dist/cli/commands/streaming.d.ts +82 -3
  74. package/dist/cli/commands/streaming.js +528 -91
  75. package/dist/cli/commands/wizardActions.d.ts +7 -0
  76. package/dist/cli/commands/wizardActions.js +7 -0
  77. package/dist/cli/commands/wizardPrompts.js +7 -1
  78. package/dist/cli/commands/wizardSuggestions.d.ts +8 -0
  79. package/dist/cli/commands/wizardSuggestions.js +64 -14
  80. package/dist/cli/commands/wizardTransition.d.ts +4 -0
  81. package/dist/cli/commands/wizardTransition.js +1 -2
  82. package/dist/cli/index.js +82 -22
  83. package/dist/cli/terminalTitle.d.ts +6 -0
  84. package/dist/cli/terminalTitle.js +36 -0
  85. package/dist/config/inputHistory.d.ts +3 -3
  86. package/dist/config/inputHistory.js +12 -18
  87. package/dist/config/modelDiscovery.d.ts +71 -0
  88. package/dist/config/modelDiscovery.js +214 -0
  89. package/dist/config/privateStorage.js +28 -2
  90. package/dist/config/providerAuth.d.ts +14 -0
  91. package/dist/config/providerAuth.js +49 -0
  92. package/dist/config/providerPresets.d.ts +49 -5
  93. package/dist/config/providerPresets.js +573 -73
  94. package/dist/config/providers.d.ts +2 -0
  95. package/dist/config/providers.js +9 -0
  96. package/dist/config/settings.d.ts +58 -0
  97. package/dist/config/settings.js +38 -1
  98. package/dist/config/skillSettings.d.ts +6 -13
  99. package/dist/config/skillSettings.js +20 -19
  100. package/dist/core/agent/budgets.d.ts +36 -0
  101. package/dist/core/agent/budgets.js +44 -0
  102. package/dist/core/agent/compaction.d.ts +38 -0
  103. package/dist/core/agent/compaction.js +108 -19
  104. package/dist/core/agent/completionController.d.ts +230 -0
  105. package/dist/core/agent/completionController.js +287 -0
  106. package/dist/core/agent/contextBudget.d.ts +46 -0
  107. package/dist/core/agent/contextBudget.js +89 -7
  108. package/dist/core/agent/errors.js +6 -2
  109. package/dist/core/agent/events.d.ts +86 -0
  110. package/dist/core/agent/reasoningPolicy.d.ts +31 -0
  111. package/dist/core/agent/reasoningPolicy.js +27 -0
  112. package/dist/core/agent/toolCapabilities.d.ts +27 -0
  113. package/dist/core/agent/toolCapabilities.js +58 -0
  114. package/dist/core/agent/toolExecutionBudget.d.ts +35 -0
  115. package/dist/core/agent/toolExecutionBudget.js +49 -0
  116. package/dist/core/agent/toolOutputStore.d.ts +13 -0
  117. package/dist/core/agent/toolOutputStore.js +27 -10
  118. package/dist/core/agent/toolResults.d.ts +12 -0
  119. package/dist/core/agent/toolResults.js +38 -0
  120. package/dist/core/agent/turnBudget.d.ts +35 -0
  121. package/dist/core/agent/turnBudget.js +27 -0
  122. package/dist/core/agent/turnPolicy.d.ts +11 -0
  123. package/dist/core/agent/turnPolicy.js +19 -0
  124. package/dist/core/agent/workState.d.ts +76 -1
  125. package/dist/core/agent/workState.js +120 -13
  126. package/dist/core/attachments/imageAttachments.d.ts +90 -0
  127. package/dist/core/attachments/imageAttachments.js +245 -0
  128. package/dist/core/attachments/readBlessings.d.ts +37 -0
  129. package/dist/core/attachments/readBlessings.js +79 -0
  130. package/dist/core/deadline.d.ts +33 -0
  131. package/dist/core/deadline.js +74 -0
  132. package/dist/core/goal/completionPolicy.d.ts +27 -0
  133. package/dist/core/goal/completionPolicy.js +37 -1
  134. package/dist/core/goal/requestClassifier.d.ts +0 -3
  135. package/dist/core/goal/requestClassifier.js +0 -13
  136. package/dist/core/io/boundedRead.js +76 -29
  137. package/dist/core/limits/byteBudgets.d.ts +7 -0
  138. package/dist/core/limits/byteBudgets.js +7 -0
  139. package/dist/core/limits/textBudgets.d.ts +25 -0
  140. package/dist/core/limits/textBudgets.js +25 -0
  141. package/dist/core/log/llmLog.js +7 -0
  142. package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
  143. package/dist/core/persistence/orderedFileWriter.js +16 -2
  144. package/dist/core/process/backgroundRegistry.d.ts +35 -0
  145. package/dist/core/process/backgroundRegistry.js +195 -0
  146. package/dist/core/process/runBoundedProcess.d.ts +9 -0
  147. package/dist/core/process/runBoundedProcess.js +74 -29
  148. package/dist/core/safety/missingExecutable.d.ts +42 -0
  149. package/dist/core/safety/missingExecutable.js +77 -0
  150. package/dist/core/safety/urlGuard.d.ts +2 -1
  151. package/dist/core/safety/urlGuard.js +3 -2
  152. package/dist/core/session/sessionSlimming.js +47 -4
  153. package/dist/core/session/sessionStore.d.ts +74 -0
  154. package/dist/core/session/sessionStore.js +268 -18
  155. package/dist/core/subagent/contracts.d.ts +120 -0
  156. package/dist/core/subagent/contracts.js +55 -0
  157. package/dist/core/subagent/executionProfiles.d.ts +28 -0
  158. package/dist/core/subagent/executionProfiles.js +45 -0
  159. package/dist/core/subagent/subagentCoordinator.d.ts +78 -0
  160. package/dist/core/subagent/subagentCoordinator.js +164 -0
  161. package/dist/core/subagent/subagentRunner.d.ts +211 -145
  162. package/dist/core/subagent/subagentRunner.js +208 -98
  163. package/dist/core/subagent/workspaceMutationPolicy.d.ts +11 -0
  164. package/dist/core/subagent/workspaceMutationPolicy.js +52 -0
  165. package/dist/core/tasks/taskStorage.js +12 -1
  166. package/dist/llm/client.d.ts +36 -29
  167. package/dist/llm/client.js +102 -33
  168. package/dist/llm/hazeTools.d.ts +2559 -150
  169. package/dist/llm/hazeTools.js +119 -31
  170. package/dist/llm/lsp.d.ts +26 -4
  171. package/dist/llm/lsp.js +90 -14
  172. package/dist/llm/lspTools.d.ts +2366 -0
  173. package/dist/llm/lspTools.js +87 -79
  174. package/dist/llm/openaiCodex.d.ts +3 -0
  175. package/dist/llm/openaiCodex.js +47 -0
  176. package/dist/llm/openaiCodexOAuth.d.ts +54 -0
  177. package/dist/llm/openaiCodexOAuth.js +214 -0
  178. package/dist/llm/requestContext.d.ts +25 -1
  179. package/dist/llm/requestContext.js +51 -8
  180. package/dist/llm/systemPrompt.d.ts +15 -1
  181. package/dist/llm/systemPrompt.js +24 -8
  182. package/dist/llm/toolResultTypes.d.ts +8 -1
  183. package/dist/llm/tools/bashTool.d.ts +906 -32
  184. package/dist/llm/tools/bashTool.js +30 -4
  185. package/dist/llm/tools/editMatch.d.ts +14 -0
  186. package/dist/llm/tools/editMatch.js +72 -0
  187. package/dist/llm/tools/failures.d.ts +2 -0
  188. package/dist/llm/tools/failures.js +1 -0
  189. package/dist/llm/tools/fetchTool.d.ts +42 -26
  190. package/dist/llm/tools/fetchTool.js +1 -1
  191. package/dist/llm/tools/fileToolShared.d.ts +6 -4
  192. package/dist/llm/tools/fileToolShared.js +18 -23
  193. package/dist/llm/tools/gitIgnore.d.ts +49 -0
  194. package/dist/llm/tools/gitIgnore.js +129 -0
  195. package/dist/llm/tools/grepRunner.d.ts +5 -0
  196. package/dist/llm/tools/grepRunner.js +52 -71
  197. package/dist/llm/tools/outputCap.d.ts +2 -6
  198. package/dist/llm/tools/outputCap.js +2 -6
  199. package/dist/llm/tools/processTool.d.ts +1077 -0
  200. package/dist/llm/tools/processTool.js +41 -0
  201. package/dist/llm/tools/readRecovery.d.ts +10 -0
  202. package/dist/llm/tools/readRecovery.js +135 -0
  203. package/dist/llm/tools/toolContext.d.ts +9 -1
  204. package/dist/llm/tools/toolContext.js +83 -43
  205. package/dist/llm/tools/workspaceFile.d.ts +9 -1
  206. package/dist/llm/tools/workspaceFile.js +33 -4
  207. package/dist/llm/webFetch.d.ts +17 -0
  208. package/dist/llm/webFetch.js +66 -86
  209. package/dist/llm/workerContext.d.ts +18 -0
  210. package/dist/llm/workerContext.js +55 -0
  211. package/dist/skills/SkillLoader.d.ts +2 -2
  212. package/dist/skills/SkillRegistry.d.ts +3 -2
  213. package/dist/skills/SkillRegistry.js +43 -13
  214. package/dist/skills/builder/SkillBuilder.d.ts +3 -0
  215. package/dist/skills/builder/SkillBuilder.js +23 -5
  216. package/dist/skills/skillTools.js +11 -4
  217. package/dist/skills/types.d.ts +6 -1
  218. package/dist/ui/codeHighlight.d.ts +4 -0
  219. package/dist/ui/codeHighlight.js +31 -0
  220. package/dist/ui/components/Header.d.ts +1 -1
  221. package/dist/ui/components/MarkdownText.d.ts +16 -2
  222. package/dist/ui/components/MarkdownText.js +244 -34
  223. package/dist/ui/components/TextInput.d.ts +12 -2
  224. package/dist/ui/components/TextInput.js +80 -8
  225. package/dist/ui/theme.d.ts +4 -3
  226. package/dist/ui/theme.js +5 -4
  227. package/dist/utils/buildInfo.d.ts +104 -0
  228. package/dist/utils/buildInfo.js +253 -0
  229. package/dist/utils/format.d.ts +2 -0
  230. package/dist/utils/format.js +8 -0
  231. package/dist/utils/fs.d.ts +9 -1
  232. package/dist/utils/fs.js +87 -29
  233. package/dist/utils/openPath.d.ts +2 -0
  234. package/dist/utils/openPath.js +22 -0
  235. package/dist/utils/path.d.ts +2 -0
  236. package/dist/utils/path.js +5 -1
  237. package/dist/utils/utf8.d.ts +22 -0
  238. package/dist/utils/utf8.js +54 -0
  239. package/dist/utils/version.d.ts +9 -3
  240. package/dist/utils/version.js +28 -2
  241. package/package.json +24 -19
@@ -6,9 +6,16 @@ export declare const PROVIDER_ACTIONS: {
6
6
  readonly useProvider: "use provider";
7
7
  readonly addModels: "add models";
8
8
  readonly setApiKey: "set API key";
9
+ readonly signInChatGpt: "sign in with ChatGPT";
10
+ readonly markImageCapable: "mark image-capable";
11
+ readonly clearImageCapable: "clear image-capable";
9
12
  readonly removeModels: "remove models";
10
13
  readonly removeProvider: "remove provider";
11
14
  };
15
+ export declare const MODEL_CHOICES: {
16
+ readonly addModels: "add models";
17
+ readonly enterModelNames: "enter model names";
18
+ };
12
19
  export declare const SERVER_CHOICES: {
13
20
  readonly addServer: "add server";
14
21
  readonly custom: "custom";
@@ -6,9 +6,16 @@ export const PROVIDER_ACTIONS = {
6
6
  useProvider: 'use provider',
7
7
  addModels: 'add models',
8
8
  setApiKey: 'set API key',
9
+ signInChatGpt: 'sign in with ChatGPT',
10
+ markImageCapable: 'mark image-capable',
11
+ clearImageCapable: 'clear image-capable',
9
12
  removeModels: 'remove models',
10
13
  removeProvider: 'remove provider',
11
14
  };
15
+ export const MODEL_CHOICES = {
16
+ addModels: 'add models',
17
+ enterModelNames: 'enter model names',
18
+ };
12
19
  export const SERVER_CHOICES = {
13
20
  addServer: 'add server',
14
21
  custom: 'custom',
@@ -1,5 +1,6 @@
1
1
  import { configuredLspServers } from '../../config/lspSettings.js';
2
2
  import { findMcpServer } from '../../config/mcpSettings.js';
3
+ import { CHATGPT_CODEX_BASE_URL } from '../../llm/openaiCodexOAuth.js';
3
4
  import { MCP_TRANSPORTS } from './wizardActions.js';
4
5
  import { commandParts, isValidUrl } from './wizardInput.js';
5
6
  export function captureProviderName(settings, value) {
@@ -29,7 +30,12 @@ export function captureMcpName(settings, value) {
29
30
  export function captureProviderUrl(value) {
30
31
  if (!isValidUrl(value))
31
32
  return { message: 'Enter a valid URL, for example http://localhost:1234/v1.' };
32
- return { draft: { url: value.trim() }, nextMode: 'providerAddKey', systemMessage: 'API key? Leave blank for local/keyless providers.' };
33
+ // The Codex endpoint only accepts ChatGPT sign-in, never API keys; point
34
+ // users at the preset instead of a custom provider that cannot work (F-14).
35
+ const codexHint = value.trim() === CHATGPT_CODEX_BASE_URL
36
+ ? `\nNote: ${CHATGPT_CODEX_BASE_URL} serves ChatGPT sign-in only. To use it, add the OpenAI Subscription preset via /provider instead of a custom API-key provider.`
37
+ : '';
38
+ return { draft: { url: value.trim() }, nextMode: 'providerAddKey', systemMessage: `API key? Leave blank for local/keyless providers.${codexHint}` };
33
39
  }
34
40
  export function captureMcpUrl(value) {
35
41
  if (!isValidUrl(value))
@@ -12,6 +12,13 @@ export declare function providerSuggestions(settings: HazeSettings): TextInputSu
12
12
  export declare function providerActionSuggestions(settings: HazeSettings, selectedProviderName: string | undefined): TextInputSuggestion[];
13
13
  export declare function presetSuggestions(): TextInputSuggestion[];
14
14
  export declare function modelSuggestions(settings: HazeSettings, modelProviderFilter: string | undefined): TextInputSuggestion[];
15
+ export declare function modelAddProviderSuggestions(settings: HazeSettings): TextInputSuggestion[];
16
+ /**
17
+ * Model picker fed by live /models discovery. Curated `suggestedModels`
18
+ * (from provider presets) are pinned atop the discovered list when the
19
+ * endpoint actually serves them — stale curation entries simply don't pin.
20
+ */
21
+ export declare function modelPickSuggestions(settings: HazeSettings, providerName: string | undefined, discoveredModels: string[], suggestedModels?: string[]): TextInputSuggestion[];
15
22
  export declare function lspSuggestions(settings: HazeSettings): TextInputSuggestion[];
16
23
  export declare function lspActionSuggestions(settings: HazeSettings, selectedLspName: string | undefined): TextInputSuggestion[];
17
24
  export declare function lspPresetSuggestions(): TextInputSuggestion[];
@@ -20,4 +27,5 @@ export declare function mcpActionSuggestions(settings: HazeSettings, selectedMcp
20
27
  export declare function mcpPresetSuggestions(): TextInputSuggestion[];
21
28
  export declare function mcpTransportSuggestions(): TextInputSuggestion[];
22
29
  export declare function skillsSuggestions(settings: HazeSettings, skills: LoadedSkill[]): TextInputSuggestion[];
30
+ export declare function skillScopeSuggestions(): TextInputSuggestion[];
23
31
  export declare function skillsActionSuggestions(settings: HazeSettings, skills: LoadedSkill[], selectedSkillName: string | undefined): TextInputSuggestion[];
@@ -1,9 +1,10 @@
1
- import { configuredProviders, findProvider, modelSelector } from '../../config/providers.js';
1
+ import { configuredProviders, findProvider, modelSelector, providerImageCapable } from '../../config/providers.js';
2
2
  import { configuredLspServers, LSP_PRESETS } from '../../config/lspSettings.js';
3
3
  import { configuredMcpServers, findMcpServer, findMcpPreset, presetIds } from '../../config/mcpSettings.js';
4
4
  import { isSkillEnabled } from '../../config/skillSettings.js';
5
5
  import { PROVIDER_PRESETS } from '../../config/providerPresets.js';
6
- import { COMMON_ACTIONS, LSP_ACTIONS, MCP_ACTIONS, MCP_TRANSPORTS, PROVIDER_ACTIONS, PROVIDER_CHOICES, SERVER_CHOICES, SKILL_ACTIONS, SKILL_CHOICES } from './wizardActions.js';
6
+ import { COMMON_ACTIONS, LSP_ACTIONS, MCP_ACTIONS, MCP_TRANSPORTS, MODEL_CHOICES, PROVIDER_ACTIONS, PROVIDER_CHOICES, SERVER_CHOICES, SKILL_ACTIONS, SKILL_CHOICES } from './wizardActions.js';
7
+ import { findSelectedSkill, skillPickerValue } from './skillWizard.js';
7
8
  /**
8
9
  * Pure suggestion builders for the chat wizard pickers (provider / model / LSP /
9
10
  * MCP / skills). Extracted from the React component so they are unit-testable
@@ -25,8 +26,15 @@ export function providerActionSuggestions(settings, selectedProviderName) {
25
26
  const provider = selectedProviderName ? findProvider(settings, selectedProviderName) : undefined;
26
27
  return [
27
28
  { value: PROVIDER_ACTIONS.useProvider, description: 'Set this provider and choose a model', kind: 'provider' },
28
- { value: PROVIDER_ACTIONS.addModels, description: 'Append comma-separated model names', kind: 'provider' },
29
- { value: PROVIDER_ACTIONS.setApiKey, description: provider?.key ? 'Update the saved API key' : 'Add an API key', kind: 'provider' },
29
+ { value: PROVIDER_ACTIONS.addModels, description: provider?.kind === 'chatgpt-codex' ? 'Add a supported Codex model name' : 'Fetch the provider model list and add models', kind: 'provider' },
30
+ ...(provider?.kind === 'chatgpt-codex'
31
+ ? [{ value: PROVIDER_ACTIONS.signInChatGpt, description: 'Sign in again or switch ChatGPT account', kind: 'provider' }]
32
+ : [{ value: PROVIDER_ACTIONS.setApiKey, description: provider?.key ? 'Update the saved API key' : 'Add an API key', kind: 'provider' }]),
33
+ provider
34
+ ? (providerImageCapable(provider)
35
+ ? { value: PROVIDER_ACTIONS.clearImageCapable, description: 'Stop sending attached images to this provider', kind: 'provider' }
36
+ : { value: PROVIDER_ACTIONS.markImageCapable, description: 'Allow attached images to be sent to this provider', kind: 'provider' })
37
+ : { value: PROVIDER_ACTIONS.markImageCapable, description: 'Allow attached images to be sent to this provider', kind: 'provider' },
30
38
  ...(provider?.models?.length ? [{ value: PROVIDER_ACTIONS.removeModels, description: 'Remove models from this provider', kind: 'provider' }] : []),
31
39
  { value: PROVIDER_ACTIONS.removeProvider, description: 'Delete this provider from settings', kind: 'provider' },
32
40
  ];
@@ -37,7 +45,7 @@ export function presetSuggestions() {
37
45
  return [
38
46
  ...cloudPresets.map(preset => ({
39
47
  value: preset.id,
40
- description: `${preset.baseUrl}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
48
+ description: `${preset.baseUrl}${preset.auth === 'chatgpt-oauth' ? ' · browser sign-in' : ''}${preset.suggestedModels?.length ? ' · e.g. ' + preset.suggestedModels.slice(0, 2).join(', ') : ''}`,
41
49
  kind: 'provider',
42
50
  })),
43
51
  ...localPresets.map(preset => ({
@@ -50,11 +58,47 @@ export function presetSuggestions() {
50
58
  }
51
59
  export function modelSuggestions(settings, modelProviderFilter) {
52
60
  const providers = configuredProviders(settings).filter(provider => !modelProviderFilter || provider.name === modelProviderFilter);
53
- return providers.flatMap(provider => provider.models.map(model => ({
54
- value: modelProviderFilter ? model : modelSelector(provider, model),
55
- description: provider.name,
56
- kind: 'model',
57
- })));
61
+ return [
62
+ ...providers.flatMap(provider => provider.models.map(model => ({
63
+ value: modelProviderFilter ? model : modelSelector(provider, model),
64
+ description: provider.name,
65
+ kind: 'model',
66
+ }))),
67
+ { value: MODEL_CHOICES.addModels, description: modelProviderFilter ? `Add models to ${modelProviderFilter} (fetched from its models endpoint)` : 'Add models to a provider (fetched from its models endpoint)', kind: 'model' },
68
+ ];
69
+ }
70
+ export function modelAddProviderSuggestions(settings) {
71
+ return configuredProviders(settings).map(provider => ({
72
+ value: provider.name,
73
+ description: `${provider.models.length} model${provider.models.length === 1 ? '' : 's'} configured`,
74
+ kind: 'provider',
75
+ }));
76
+ }
77
+ /**
78
+ * Model picker fed by live /models discovery. Curated `suggestedModels`
79
+ * (from provider presets) are pinned atop the discovered list when the
80
+ * endpoint actually serves them — stale curation entries simply don't pin.
81
+ */
82
+ export function modelPickSuggestions(settings, providerName, discoveredModels, suggestedModels = []) {
83
+ const provider = providerName ? findProvider(settings, providerName) : undefined;
84
+ const configured = new Set(provider?.models ?? []);
85
+ const available = discoveredModels.filter(model => !configured.has(model));
86
+ const availableSet = new Set(available);
87
+ const pinned = suggestedModels.filter(model => availableSet.has(model));
88
+ const pinnedSet = new Set(pinned);
89
+ return [
90
+ ...pinned.map(model => ({
91
+ value: model,
92
+ description: 'suggested',
93
+ kind: 'model',
94
+ })),
95
+ ...available.filter(model => !pinnedSet.has(model)).map(model => ({
96
+ value: model,
97
+ description: providerName,
98
+ kind: 'model',
99
+ })),
100
+ { value: MODEL_CHOICES.enterModelNames, description: 'Type comma-separated model names instead', kind: 'model' },
101
+ ];
58
102
  }
59
103
  export function lspSuggestions(settings) {
60
104
  const servers = configuredLspServers(settings);
@@ -121,16 +165,22 @@ export function mcpTransportSuggestions() {
121
165
  export function skillsSuggestions(settings, skills) {
122
166
  return [{ value: SKILL_CHOICES.addSkill, description: 'describe a new skill for haze to generate', kind: 'skill' },
123
167
  ...skills.map(skill => ({
124
- value: skill.name,
125
- description: `${skill.description}${isSkillEnabled(settings, skill.name) ? '' : ' · disabled'}`,
168
+ value: skills.some(candidate => candidate !== skill && candidate.name === skill.name) ? skillPickerValue(skill) : skill.name,
169
+ description: `${skill.description} · ${skill.source}${isSkillEnabled(settings, skill.name, skill.source) ? '' : ' · disabled'}`,
126
170
  kind: 'skill',
127
171
  }))];
128
172
  }
173
+ export function skillScopeSuggestions() {
174
+ return [
175
+ { value: 'this project', description: 'create .haze/skills/<name>/SKILL.md for this repository', kind: 'skill' },
176
+ { value: 'global', description: 'create ~/.haze/skills/<name>/SKILL.md for your user', kind: 'skill' },
177
+ ];
178
+ }
129
179
  export function skillsActionSuggestions(settings, skills, selectedSkillName) {
130
- const skill = selectedSkillName ? skills.find(candidate => candidate.name === selectedSkillName) : undefined;
180
+ const skill = findSelectedSkill(skills, selectedSkillName);
131
181
  const result = [];
132
182
  if (skill) {
133
- const enabled = isSkillEnabled(settings, skill.name);
183
+ const enabled = isSkillEnabled(settings, skill.name, skill.source);
134
184
  result.push({ value: enabled ? COMMON_ACTIONS.disable : COMMON_ACTIONS.enable, description: `${enabled ? COMMON_ACTIONS.disable : COMMON_ACTIONS.enable} this skill`, kind: 'skill' });
135
185
  result.push({ value: SKILL_ACTIONS.showInfo, description: 'show description, references, and path', kind: 'skill' });
136
186
  result.push({ value: SKILL_ACTIONS.validate, description: 're-load and validate SKILL.md', kind: 'skill' });
@@ -11,6 +11,9 @@ export type ProviderWizardEffect = SharedWizardEffect | {
11
11
  type: 'provider-draft';
12
12
  patch: Partial<HazeProviderSettings>;
13
13
  replace?: boolean;
14
+ } | {
15
+ type: 'discover-provider-models';
16
+ draft: Partial<HazeProviderSettings>;
14
17
  };
15
18
  export type McpWizardEffect = SharedWizardEffect | {
16
19
  type: 'mcp-draft';
@@ -23,6 +26,7 @@ export declare function transitionProviderField(input: {
23
26
  mode: Mode;
24
27
  value: string;
25
28
  settings: HazeSettings;
29
+ draft: Partial<HazeProviderSettings>;
26
30
  }): ProviderWizardEffect[] | undefined;
27
31
  export declare function transitionMcpField(input: {
28
32
  mode: Mode;
@@ -4,8 +4,7 @@ export function transitionProviderField(input) {
4
4
  const key = input.value.trim();
5
5
  return [
6
6
  { type: 'provider-draft', patch: key ? { key } : {} },
7
- { type: 'mode', mode: 'providerAddModels' },
8
- { type: 'message', text: 'Comma-separated model names? Example: llama3.1, qwen2.5-coder, gpt-4o' },
7
+ { type: 'discover-provider-models', draft: { ...input.draft, ...(key ? { key } : {}) } },
9
8
  ];
10
9
  }
11
10
  const result = input.mode === 'providerAddName' ? captureProviderName(input.settings, input.value)
package/dist/cli/index.js CHANGED
@@ -1,23 +1,30 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync } from 'node:fs';
3
- import { fileURLToPath } from 'node:url';
4
- import { dirname, join } from 'node:path';
5
2
  import { Command, Option } from 'commander';
6
3
  import { chatCommand } from './commands/chat.js';
7
4
  import { runHeadless } from './commands/runCommand.js';
8
- const __dirname = dirname(fileURLToPath(import.meta.url));
9
- const pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8'));
5
+ import { installTerminalTitle, terminalTitleLabel } from './terminalTitle.js';
6
+ import { findSession } from '../core/session/sessionStore.js';
7
+ import { installBackgroundProcessSignalHandlers, teardownBackgroundProcesses } from '../core/process/backgroundRegistry.js';
8
+ import { STDIN_PROMPT_BYTES } from '../core/limits/byteBudgets.js';
9
+ import { readPackageVersion } from '../utils/version.js';
10
+ import { formatVersionVerbose, readBuildInfo } from '../utils/buildInfo.js';
11
+ import { runDoctor } from './commands/doctor.js';
12
+ installBackgroundProcessSignalHandlers();
13
+ const version = readPackageVersion() ?? '0.0.0';
10
14
  const program = new Command();
11
15
  program
12
16
  .name('haze')
13
17
  .description('A pragmatic, intentionally limited agentic CLI.')
14
- .version(pkg.version)
18
+ .option('-V, --version', 'print the haze version (add --verbose for build provenance: commit, runtime paths, capabilities)')
19
+ .option('--verbose', 'with --version: also print commit, runtime/executable paths, and the capability registry')
15
20
  .option('--debug', 'show model/tool debug logs and write a detailed JSONL log to ~/.haze/logs/')
16
21
  .option('-c, --continue', 'resume the latest saved session for this workspace')
22
+ .addOption(new Option('--resume <id>', 'resume an exact saved session id for this workspace').conflicts(['continue', 'session']))
17
23
  .option('--no-session', 'run without saving or resuming a durable session')
18
24
  .option('-p, --prompt <text>', 'print mode: run a single non-interactive turn and print the result (falls back to piped stdin)')
19
25
  .option('-m, --model <selector>', 'override the model for this run only — a registered model name or provider:name')
20
- .addOption(new Option('--output <format>', 'print-mode output: plain text, a single JSON result envelope, or a stream-json NDJSON event stream').choices(['text', 'json', 'stream-json']).default('text'));
26
+ .addOption(new Option('--output <format>', 'print-mode output: plain text, a single JSON result envelope, or a stream-json NDJSON event stream').choices(['text', 'json', 'stream-json']).default('text'))
27
+ .option('--timeout <duration>', 'print-mode absolute turn deadline (e.g. 30s, 10m, 2h); bounds total elapsed time so a busy tool cannot run indefinitely');
21
28
  program.addHelpText('after', `
22
29
  Examples:
23
30
  $ haze start the interactive chat
@@ -26,57 +33,110 @@ Examples:
26
33
  $ haze -p "list the top 3 bugs" --output json emit a JSON envelope { type, status, result, usage }
27
34
  $ haze -p "audit src/" --output stream-json stream NDJSON events live, then the final result envelope
28
35
  $ haze -p "summarize" --model openai:gpt-4o-mini override the model for this run only
36
+ $ haze --resume <id> -p "continue the review" load a saved context for one print-mode turn
29
37
  $ haze -p "audit auth.ts" --debug also write a detailed JSONL log to ~/.haze/logs/
30
38
 
31
39
  Print mode (-p):
32
40
  Runs a single agentic turn with the full toolset and guardrails, prints the final assistant
33
41
  text, then exits (0 = complete; non-zero = aborted/failed, so CI can gate on the exit code).
34
- The prompt comes from -p, otherwise from piped stdin. With --output json the reply is wrapped
35
- in a single-line { type, status, result, usage } envelope. With --output stream-json haze streams
36
- one NDJSON agent event per line (turn_start, message_*, tool_*, retry, turn_end) as the run
37
- progresses, then prints that same { type:'result', ... } envelope as the final line — giving
38
- harnesses live progress and stagnation detection. --model overrides the model for this
42
+ The prompt comes from -p, otherwise from piped stdin. Piped prompts over 256 KiB are rejected;
43
+ pass a file path and ask haze to read it instead. With --output json the reply is wrapped in a
44
+ single-line { type, status, result, usage } envelope. With --output stream-json haze streams
45
+ one NDJSON agent event per line (turn_start, step_*, message_*, tool_*, retry, turn_end) as the
46
+ run progresses, then prints that same { type:'result', ... } envelope as the final line — giving
47
+ harnesses live progress, per-step usage, bounded tool-failure diagnostics, and stagnation
48
+ detection without raw tool inputs or outputs. --model overrides the model for this
39
49
  run only (no settings change) and must already be registered under a provider (add it once via
40
50
  the /provider picker). Print-mode runs are non-durable: --continue is ignored and no session is
41
- saved, and there is no automatic context-overflow recovery.
51
+ saved. --resume <id> loads saved context for the turn without changing that session. On a
52
+ provider context overflow, haze compacts the conversation and retries the request once; when
53
+ compaction is unavailable, the error says so explicitly.
42
54
  `);
43
55
  async function readStdinPrompt() {
44
56
  // Only read stdin when it is piped (non-TTY); never hang waiting on an interactive terminal.
45
- if (process.stdin.isTTY === false) {
46
- return new Promise((resolve) => {
57
+ if (!process.stdin.isTTY) {
58
+ return new Promise((resolve, reject) => {
47
59
  let data = '';
48
- process.stdin.setEncoding('utf8');
49
- process.stdin.on('data', (chunk) => {
60
+ let bytes = 0;
61
+ const cleanup = () => {
62
+ process.stdin.removeListener('data', onData);
63
+ process.stdin.removeListener('end', onEnd);
64
+ process.stdin.removeListener('error', onError);
65
+ };
66
+ const onData = (chunk) => {
67
+ bytes += Buffer.byteLength(chunk, 'utf8');
68
+ if (bytes > STDIN_PROMPT_BYTES) {
69
+ cleanup();
70
+ process.stdin.pause();
71
+ reject(new Error(`stdin prompt exceeds ${STDIN_PROMPT_BYTES} bytes; pass a file path and ask haze to read it instead.`));
72
+ return;
73
+ }
50
74
  data += chunk;
51
- });
52
- process.stdin.on('end', () => resolve(data.trim() ? data : undefined));
53
- process.stdin.on('error', () => resolve(undefined));
75
+ };
76
+ const onEnd = () => {
77
+ cleanup();
78
+ resolve(data.trim() ? data : undefined);
79
+ };
80
+ const onError = () => {
81
+ cleanup();
82
+ resolve(undefined);
83
+ };
84
+ process.stdin.setEncoding('utf8');
85
+ process.stdin.on('data', onData);
86
+ process.stdin.on('end', onEnd);
87
+ process.stdin.on('error', onError);
54
88
  });
55
89
  }
56
90
  return undefined;
57
91
  }
92
+ program.command('doctor')
93
+ .description('print runtime provenance (version, commit, executable/runtime paths), verify build integrity, and show the capability registry')
94
+ .action(async () => {
95
+ process.exitCode = await runDoctor();
96
+ });
58
97
  program.action(async () => {
59
98
  const opts = program.opts();
99
+ if (opts.version) {
100
+ // Handled here (not via commander's built-in .version()) so --verbose can
101
+ // enrich it and the bin launcher can answer without loading dist.
102
+ process.stdout.write(opts.verbose ? `${formatVersionVerbose()}\n` : `${version}\n`);
103
+ return;
104
+ }
105
+ // Name the terminal tab for the run; no-op unless stdout is a real TTY.
106
+ installTerminalTitle(terminalTitleLabel(process.cwd()));
60
107
  // -p takes precedence; otherwise fall back to piped stdin. An empty stdin yields no prompt.
61
108
  const prompt = opts.prompt?.trim() ? opts.prompt : await readStdinPrompt();
109
+ if (opts.resume && !await findSession(opts.resume)) {
110
+ throw new Error(`No session named ${opts.resume} exists for this workspace.`);
111
+ }
62
112
  if (prompt) {
63
113
  // One-shot runs are always fresh and non-durable; --continue is ignored in this mode.
64
114
  const code = await runHeadless({
65
115
  prompt,
66
116
  modelOverride: opts.model,
117
+ resumeSessionId: opts.resume,
67
118
  // commander validates --output against the choices above, so opts.output is one of
68
119
  // 'text' | 'json' | 'stream-json'; default to text for piped/stdin runs without the flag.
69
120
  output: opts.output === 'json' || opts.output === 'stream-json' ? opts.output : 'text',
70
121
  debug: Boolean(opts.debug),
122
+ timeout: opts.timeout,
71
123
  });
72
124
  // Set the exit code and return instead of process.exit(code): the latter does not wait
73
125
  // for stdout to drain and can truncate piped/redirected output (e.g. `haze -p ... | jq`).
74
126
  process.exitCode = code;
75
127
  return;
76
128
  }
77
- await chatCommand({ debug: Boolean(opts.debug), continueSession: Boolean(opts.continue), noSession: opts.session === false, version: pkg.version });
129
+ await chatCommand({ debug: Boolean(opts.debug), continueSession: Boolean(opts.continue), resumeSessionId: opts.resume, noSession: opts.session === false, version, build: sessionBuildProvenance() });
78
130
  });
79
- program.parseAsync().catch((error) => {
131
+ /** Safe build provenance recorded into session headers (commit + build time only). */
132
+ function sessionBuildProvenance() {
133
+ const info = readBuildInfo();
134
+ if (!info?.commit && !info?.builtAt)
135
+ return undefined;
136
+ return { ...(info?.commit ? { commit: info.commit } : {}), ...(info?.builtAt ? { builtAt: info.builtAt } : {}) };
137
+ }
138
+ program.parseAsync().catch(async (error) => {
80
139
  console.error(error instanceof Error ? error.message : error);
140
+ await teardownBackgroundProcesses().catch(() => undefined);
81
141
  process.exit(1);
82
142
  });
@@ -0,0 +1,6 @@
1
+ export declare function terminalTitleLabel(cwd: string): string;
2
+ /**
3
+ * Set the terminal title for the duration of this run. No-op when stdout is
4
+ * not a TTY (headless, piped, or redirected runs).
5
+ */
6
+ export declare function installTerminalTitle(label: string): void;
@@ -0,0 +1,36 @@
1
+ import { basename } from 'node:path';
2
+ /**
3
+ * Terminal tab/window title for interactive runs. Uses the OSC 0 escape
4
+ * sequence, understood by xterm-compatible terminals (Terminal.app, iTerm2,
5
+ * VS Code, etc.). Guarded to real TTYs so piped/redirected output is never
6
+ * polluted, and cleared on exit so the tab falls back to the shell's own
7
+ * naming instead of showing a stale haze title.
8
+ */
9
+ function titleEscape(label) {
10
+ return `\u001B]0;${label}\u0007`;
11
+ }
12
+ export function terminalTitleLabel(cwd) {
13
+ // eslint-disable-next-line no-control-regex -- stripping control characters is the point here.
14
+ const dir = basename(cwd).replace(/[\u0000-\u001F\u007F-\u009F]/g, '').trim();
15
+ return `haze${dir ? ` - ${dir}` : ''}`;
16
+ }
17
+ /**
18
+ * Set the terminal title for the duration of this run. No-op when stdout is
19
+ * not a TTY (headless, piped, or redirected runs).
20
+ */
21
+ export function installTerminalTitle(label) {
22
+ if (!process.stdout.isTTY)
23
+ return;
24
+ process.stdout.write(titleEscape(label));
25
+ process.once('exit', () => {
26
+ // Re-check at exit time: the terminal may no longer be attached.
27
+ if (!process.stdout.isTTY)
28
+ return;
29
+ try {
30
+ process.stdout.write(titleEscape(''));
31
+ }
32
+ catch {
33
+ // Best effort only: title restoration must never break shutdown.
34
+ }
35
+ });
36
+ }
@@ -1,4 +1,4 @@
1
1
  export declare const INPUT_HISTORY_FILE: string;
2
- export declare function readInputHistory(): Promise<string[]>;
3
- export declare function writeInputHistory(history: string[]): Promise<void>;
4
- export declare function addInputHistoryItem(item: string): Promise<string[]>;
2
+ export declare function readInputHistory(file?: string): Promise<string[]>;
3
+ export declare function writeInputHistory(history: string[], file?: string): Promise<void>;
4
+ export declare function addInputHistoryItem(item: string, file?: string): Promise<string[]>;
@@ -5,35 +5,29 @@ import { tightenPrivateFile, writePrivateJsonAtomic } from './privateStorage.js'
5
5
  const HISTORY_DIR = path.join(HAZE_DIR, 'history');
6
6
  export const INPUT_HISTORY_FILE = path.join(HISTORY_DIR, 'input-history.json');
7
7
  const MAX_HISTORY_ITEMS = 500;
8
- const DISABLE_PERSISTENT_HISTORY = process.env.VITEST === 'true' || process.env.NODE_ENV === 'test';
9
- let testHistory = [];
10
8
  function normalizeHistory(value) {
11
9
  if (!Array.isArray(value))
12
10
  return [];
13
11
  return value.filter((item) => typeof item === 'string' && item.trim().length > 0);
14
12
  }
15
- export async function readInputHistory() {
16
- if (DISABLE_PERSISTENT_HISTORY)
17
- return testHistory.slice(-MAX_HISTORY_ITEMS);
18
- if (await fs.pathExists(INPUT_HISTORY_FILE))
19
- await tightenPrivateFile(INPUT_HISTORY_FILE);
20
- const data = await fs.readJson(INPUT_HISTORY_FILE).catch(() => []);
13
+ // The storage path is injectable so tests isolate via temp files instead of
14
+ // production switches on test-env globals (CR-011).
15
+ export async function readInputHistory(file = INPUT_HISTORY_FILE) {
16
+ if (await fs.pathExists(file))
17
+ await tightenPrivateFile(file);
18
+ const data = await fs.readJson(file).catch(() => []);
21
19
  return normalizeHistory(data).slice(-MAX_HISTORY_ITEMS);
22
20
  }
23
- export async function writeInputHistory(history) {
21
+ export async function writeInputHistory(history, file = INPUT_HISTORY_FILE) {
24
22
  const normalized = normalizeHistory(history).slice(-MAX_HISTORY_ITEMS);
25
- if (DISABLE_PERSISTENT_HISTORY) {
26
- testHistory = normalized;
27
- return;
28
- }
29
- await writePrivateJsonAtomic(INPUT_HISTORY_FILE, normalized);
23
+ await writePrivateJsonAtomic(file, normalized);
30
24
  }
31
- export async function addInputHistoryItem(item) {
25
+ export async function addInputHistoryItem(item, file = INPUT_HISTORY_FILE) {
32
26
  const trimmed = item.trim();
33
27
  if (!trimmed)
34
- return readInputHistory();
35
- const current = await readInputHistory();
28
+ return readInputHistory(file);
29
+ const current = await readInputHistory(file);
36
30
  const next = current[current.length - 1] === trimmed ? current : [...current, trimmed];
37
- await writeInputHistory(next);
31
+ await writeInputHistory(next, file);
38
32
  return next.slice(-MAX_HISTORY_ITEMS);
39
33
  }
@@ -0,0 +1,71 @@
1
+ import type { HazeProviderSettings } from './settings.js';
2
+ /** Per-model limits harvested from a provider's /models listing. */
3
+ export type HarvestedModelLimits = Record<string, {
4
+ contextWindowTokens?: number;
5
+ maxOutputTokens?: number;
6
+ }>;
7
+ /**
8
+ * Model discovery against the OpenAI-compatible `/models` endpoint every
9
+ * provider in haze exposes. Used to turn "add models" from a memorize-and-type
10
+ * step into a pick-from-list step; callers fall back to manual input when the
11
+ * endpoint is unavailable.
12
+ */
13
+ export type ModelDiscoveryResult = {
14
+ status: 'ok';
15
+ models: string[];
16
+ modelLimits?: HarvestedModelLimits;
17
+ } | {
18
+ status: 'failed';
19
+ error: string;
20
+ };
21
+ export declare function modelsEndpointUrl(baseUrl: string): string;
22
+ export declare function parseModelsBody(body: unknown): string[];
23
+ /**
24
+ * Ollama native enrichment. Ollama's OpenAI-compatible /v1/models returns no
25
+ * context fields (verified against ollama 0.32), but its native API does, with
26
+ * different fidelity levels — resolved best-first per model:
27
+ * 1. GET /api/ps — the ACTUAL runtime context of a currently-loaded model
28
+ * (reflects OLLAMA_CONTEXT_LENGTH and Ollama's vram-based auto-sizing);
29
+ * only available while the model stays loaded (keep_alive window).
30
+ * 2. POST /api/show parameters `num_ctx N` — the user's explicit per-model
31
+ * setting (Modelfile), capped by the model's trained maximum.
32
+ * 3. POST /api/show model_info `<arch>.context_length` — the model's
33
+ * theoretical maximum. The effective runtime window may be smaller
34
+ * (auto-sized to VRAM), so it is capped at the conservative local
35
+ * fallback rather than trusted outright (silent truncation guard).
36
+ */
37
+ export declare const OLLAMA_PROBE_TIMEOUT_MS = 4000;
38
+ interface OllamaShowFacts {
39
+ max?: number;
40
+ numCtx?: number;
41
+ }
42
+ /** Extract context facts from an /api/show response body. */
43
+ export declare function ollamaContextFromShow(show: unknown): OllamaShowFacts;
44
+ /**
45
+ * Probe a local Ollama server for the effective context of the given models.
46
+ * Best-effort: any failing request simply omits that model. Only call for
47
+ * loopback base URLs (the /api/* surface is Ollama-specific).
48
+ */
49
+ export declare function ollamaModelLimits(input: {
50
+ baseUrl: string;
51
+ models: readonly string[];
52
+ conservativeCap: number;
53
+ fetchImpl?: typeof fetch;
54
+ timeoutMs?: number;
55
+ }): Promise<HarvestedModelLimits>;
56
+ /**
57
+ * Harvest non-standard context/output fields from an OpenAI-compatible
58
+ * `/models` response. The official schema carries only `id`/`created`/`object`,
59
+ * but several providers add extensions (OpenRouter `context_length`, Groq
60
+ * `context_window`, LM Studio `max_context_length`, plus the usual
61
+ * `max_output_tokens`/`max_completion_tokens`/`max_tokens` output caps).
62
+ * Values are sanity-clamped so a quirky proxy cannot poison request budgeting;
63
+ * models with no recognizable fields are simply omitted. This is the only
64
+ * source that can know a local server's actually-configured window.
65
+ */
66
+ export declare function harvestModelLimits(body: unknown): HarvestedModelLimits;
67
+ export declare function discoverProviderModels(provider: Pick<HazeProviderSettings, 'url' | 'key'>, options?: {
68
+ timeoutMs?: number;
69
+ fetchImpl?: typeof fetch;
70
+ }): Promise<ModelDiscoveryResult>;
71
+ export {};