@denizokcu/haze 0.10.0 → 1.0.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 (294) hide show
  1. package/CHANGELOG.md +100 -1
  2. package/README.md +77 -27
  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 +2 -2
  9. package/dist/cli/chat/chatMetrics.js +1 -1
  10. package/dist/cli/chat/contextReport.js +2 -0
  11. package/dist/cli/chat/fileMentionSuggestions.js +3 -2
  12. package/dist/cli/chat/inputSuggestions.d.ts +8 -16
  13. package/dist/cli/chat/inputSuggestions.js +9 -41
  14. package/dist/cli/chat/liveRegion.d.ts +25 -0
  15. package/dist/cli/chat/liveRegion.js +48 -0
  16. package/dist/cli/chat/messages.d.ts +33 -4
  17. package/dist/cli/chat/messages.js +218 -35
  18. package/dist/cli/chat/sessionLifecycle.d.ts +11 -1
  19. package/dist/cli/chat/sessionLifecycle.js +64 -14
  20. package/dist/cli/chat/sessionRecorder.js +75 -7
  21. package/dist/cli/chat/startupInfo.d.ts +0 -1
  22. package/dist/cli/chat/startupInfo.js +11 -15
  23. package/dist/cli/chat/turnState.d.ts +1 -1
  24. package/dist/cli/chat/wizardDispatch.d.ts +90 -28
  25. package/dist/cli/chat/wizardDispatch.js +349 -133
  26. package/dist/cli/commands/chat.d.ts +5 -0
  27. package/dist/cli/commands/chat.js +216 -172
  28. package/dist/cli/commands/chatModes.d.ts +8 -1
  29. package/dist/cli/commands/chatModes.js +9 -44
  30. package/dist/cli/commands/commands.d.ts +2 -0
  31. package/dist/cli/commands/commands.js +10 -5
  32. package/dist/cli/commands/doctor.d.ts +19 -0
  33. package/dist/cli/commands/doctor.js +76 -0
  34. package/dist/cli/commands/formatters.d.ts +3 -3
  35. package/dist/cli/commands/formatters.js +8 -25
  36. package/dist/cli/commands/ndjsonSink.d.ts +23 -0
  37. package/dist/cli/commands/ndjsonSink.js +38 -0
  38. package/dist/cli/commands/providerWizard.d.ts +9 -2
  39. package/dist/cli/commands/providerWizard.js +39 -7
  40. package/dist/cli/commands/runCommand.d.ts +3 -0
  41. package/dist/cli/commands/runCommand.js +117 -11
  42. package/dist/cli/commands/serverWizard.d.ts +34 -0
  43. package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
  44. package/dist/cli/commands/skillsWizard.d.ts +41 -0
  45. package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
  46. package/dist/cli/commands/streaming/abortCause.d.ts +25 -0
  47. package/dist/cli/commands/streaming/abortCause.js +16 -0
  48. package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
  49. package/dist/cli/commands/streaming/agentAttempt.js +79 -0
  50. package/dist/cli/commands/streaming/assistantText.js +9 -2
  51. package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
  52. package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
  53. package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
  54. package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
  55. package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
  56. package/dist/cli/commands/streaming/attemptSetup.js +167 -0
  57. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +65 -0
  58. package/dist/cli/commands/streaming/goalCheckpoint.js +23 -0
  59. package/dist/cli/commands/streaming/goalSupervisor.d.ts +64 -0
  60. package/dist/cli/commands/streaming/goalSupervisor.js +130 -0
  61. package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
  62. package/dist/cli/commands/streaming/stallRecovery.js +105 -0
  63. package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
  64. package/dist/cli/commands/streaming/streamLoop.js +448 -0
  65. package/dist/cli/commands/streaming/toolCallRecovery.d.ts +16 -0
  66. package/dist/cli/commands/streaming/toolCallRecovery.js +80 -0
  67. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +31 -1
  68. package/dist/cli/commands/streaming/toolGroupRenderer.js +50 -4
  69. package/dist/cli/commands/streaming/toolResultState.d.ts +6 -1
  70. package/dist/cli/commands/streaming/toolResultState.js +29 -7
  71. package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
  72. package/dist/cli/commands/streaming/turnRuntime.js +6 -0
  73. package/dist/cli/commands/streaming.d.ts +65 -9
  74. package/dist/cli/commands/streaming.js +133 -430
  75. package/dist/cli/commands/wizardFlow.d.ts +334 -0
  76. package/dist/cli/commands/wizardFlow.js +377 -0
  77. package/dist/cli/contextReport.js +3 -0
  78. package/dist/cli/index.js +68 -22
  79. package/dist/cli/terminalTitle.js +1 -1
  80. package/dist/config/contextFiles.js +9 -3
  81. package/dist/config/inputHistory.d.ts +0 -1
  82. package/dist/config/inputHistory.js +1 -1
  83. package/dist/config/modelDiscovery.d.ts +36 -0
  84. package/dist/config/modelDiscovery.js +164 -1
  85. package/dist/config/privateStorage.js +28 -2
  86. package/dist/config/providerAuth.d.ts +14 -0
  87. package/dist/config/providerAuth.js +49 -0
  88. package/dist/config/providerPresets.d.ts +39 -7
  89. package/dist/config/providerPresets.js +371 -100
  90. package/dist/config/providers.js +2 -0
  91. package/dist/config/settings.d.ts +43 -0
  92. package/dist/config/settings.js +12 -0
  93. package/dist/config/skillSettings.js +4 -4
  94. package/dist/config/updateCheck.d.ts +0 -1
  95. package/dist/config/updateCheck.js +1 -1
  96. package/dist/core/agent/budgets.d.ts +73 -1
  97. package/dist/core/agent/budgets.js +94 -1
  98. package/dist/core/agent/compaction.d.ts +38 -0
  99. package/dist/core/agent/compaction.js +92 -17
  100. package/dist/core/agent/completionController.d.ts +224 -0
  101. package/dist/core/agent/completionController.js +296 -0
  102. package/dist/core/agent/contextBudget.d.ts +36 -2
  103. package/dist/core/agent/contextBudget.js +62 -9
  104. package/dist/core/agent/errors.d.ts +0 -1
  105. package/dist/core/agent/errors.js +1 -1
  106. package/dist/core/agent/events.d.ts +78 -0
  107. package/dist/core/agent/goalPolicy.d.ts +47 -0
  108. package/dist/core/agent/goalPolicy.js +106 -0
  109. package/dist/core/agent/reasoningPolicy.d.ts +31 -0
  110. package/dist/core/agent/reasoningPolicy.js +27 -0
  111. package/dist/core/agent/requestAssembly.d.ts +2 -2
  112. package/dist/core/agent/requestAssembly.js +16 -4
  113. package/dist/core/agent/toolCapabilities.d.ts +27 -0
  114. package/dist/core/agent/toolCapabilities.js +58 -0
  115. package/dist/core/agent/toolOutputStore.d.ts +8 -0
  116. package/dist/core/agent/toolOutputStore.js +11 -11
  117. package/dist/core/agent/toolResults.d.ts +12 -0
  118. package/dist/core/agent/toolResults.js +38 -0
  119. package/dist/core/agent/turnPolicy.d.ts +11 -0
  120. package/dist/core/agent/turnPolicy.js +19 -0
  121. package/dist/core/agent/workState.d.ts +81 -3
  122. package/dist/core/agent/workState.js +176 -10
  123. package/dist/core/attachments/imageAttachments.js +90 -42
  124. package/dist/core/deadline.d.ts +27 -0
  125. package/dist/core/deadline.js +74 -0
  126. package/dist/core/io/boundedRead.js +1 -1
  127. package/dist/core/limits.d.ts +51 -0
  128. package/dist/core/limits.js +51 -0
  129. package/dist/core/log/llmLog.js +8 -1
  130. package/dist/core/persistence/orderedFileWriter.d.ts +10 -0
  131. package/dist/core/persistence/orderedFileWriter.js +16 -2
  132. package/dist/core/process/backgroundRegistry.d.ts +2 -3
  133. package/dist/core/process/backgroundRegistry.js +15 -10
  134. package/dist/core/process/runBoundedProcess.d.ts +8 -2
  135. package/dist/core/process/runBoundedProcess.js +15 -6
  136. package/dist/core/process/userShell.d.ts +16 -0
  137. package/dist/core/process/userShell.js +59 -0
  138. package/dist/core/safety/missingExecutable.d.ts +42 -0
  139. package/dist/core/safety/missingExecutable.js +77 -0
  140. package/dist/core/safety/shellClassifier.d.ts +11 -0
  141. package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
  142. package/dist/core/safety/urlGuard.d.ts +1 -1
  143. package/dist/core/session/sessionSlimming.d.ts +0 -3
  144. package/dist/core/session/sessionSlimming.js +2 -3
  145. package/dist/core/session/sessionStore.d.ts +38 -0
  146. package/dist/core/session/sessionStore.js +242 -59
  147. package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
  148. package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
  149. package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
  150. package/dist/core/shellOutput/registry.d.ts +2 -0
  151. package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
  152. package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
  153. package/dist/core/subagent/contracts.d.ts +6 -14
  154. package/dist/core/subagent/contracts.js +4 -3
  155. package/dist/core/subagent/executionProfiles.js +2 -2
  156. package/dist/core/subagent/subagentCoordinator.d.ts +4 -0
  157. package/dist/core/subagent/subagentCoordinator.js +32 -2
  158. package/dist/core/subagent/subagentRunner.js +19 -40
  159. package/dist/core/toolOutput/reduction.d.ts +0 -12
  160. package/dist/core/toolOutput/reduction.js +1 -1
  161. package/dist/core/validation/outputParser.d.ts +2 -2
  162. package/dist/llm/client.d.ts +17 -1
  163. package/dist/llm/client.js +86 -14
  164. package/dist/llm/hazeTools.d.ts +693 -204
  165. package/dist/llm/hazeTools.js +110 -28
  166. package/dist/llm/initPrompt.js +1 -1
  167. package/dist/llm/lsp/client.d.ts +45 -0
  168. package/dist/llm/lsp/client.js +195 -0
  169. package/dist/llm/lsp/pool.d.ts +23 -0
  170. package/dist/llm/lsp/pool.js +86 -0
  171. package/dist/llm/lsp/protocol.d.ts +64 -0
  172. package/dist/llm/lsp/protocol.js +128 -0
  173. package/dist/llm/lsp/requests.d.ts +94 -0
  174. package/dist/llm/lsp/requests.js +119 -0
  175. package/dist/llm/lspTools.d.ts +5653 -33
  176. package/dist/llm/lspTools.js +152 -80
  177. package/dist/llm/openaiCodex.d.ts +1 -0
  178. package/dist/llm/openaiCodex.js +43 -0
  179. package/dist/llm/openaiCodexOAuth.d.ts +51 -0
  180. package/dist/llm/openaiCodexOAuth.js +217 -0
  181. package/dist/llm/requestContext.d.ts +7 -0
  182. package/dist/llm/requestContext.js +30 -4
  183. package/dist/llm/systemPrompt.d.ts +12 -0
  184. package/dist/llm/systemPrompt.js +24 -11
  185. package/dist/llm/toolResultTypes.d.ts +7 -14
  186. package/dist/llm/toolResultTypes.js +1 -4
  187. package/dist/llm/tools/editMatch.d.ts +14 -9
  188. package/dist/llm/tools/editMatch.js +73 -1
  189. package/dist/llm/tools/failures.d.ts +2 -0
  190. package/dist/llm/tools/failures.js +1 -0
  191. package/dist/llm/tools/fetchTool.d.ts +16 -0
  192. package/dist/llm/tools/fetchTool.js +1 -1
  193. package/dist/llm/tools/fileToolShared.d.ts +8 -5
  194. package/dist/llm/tools/fileToolShared.js +22 -23
  195. package/dist/llm/tools/gitIgnore.d.ts +42 -0
  196. package/dist/llm/tools/gitIgnore.js +247 -0
  197. package/dist/llm/tools/grepParse.d.ts +2 -1
  198. package/dist/llm/tools/grepRunner.d.ts +1 -1
  199. package/dist/llm/tools/grepRunner.js +2 -2
  200. package/dist/llm/tools/outputCap.d.ts +2 -7
  201. package/dist/llm/tools/outputCap.js +3 -3
  202. package/dist/llm/tools/processTool.d.ts +16 -16
  203. package/dist/llm/tools/processTool.js +1 -1
  204. package/dist/llm/tools/readRecovery.d.ts +8 -0
  205. package/dist/llm/tools/readRecovery.js +135 -0
  206. package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +171 -123
  207. package/dist/llm/tools/{bashTool.js → shellTool.js} +20 -14
  208. package/dist/llm/tools/toolContext.d.ts +1 -1
  209. package/dist/llm/tools/toolContext.js +66 -37
  210. package/dist/llm/tools/workspaceFile.d.ts +0 -1
  211. package/dist/llm/tools/workspaceFile.js +1 -6
  212. package/dist/llm/webFetch.d.ts +18 -1
  213. package/dist/llm/webFetch.js +64 -97
  214. package/dist/skills/SkillLoader.d.ts +1 -11
  215. package/dist/skills/SkillLoader.js +1 -2
  216. package/dist/skills/types.d.ts +2 -1
  217. package/dist/ui/codeHighlight.d.ts +4 -0
  218. package/dist/ui/codeHighlight.js +31 -0
  219. package/dist/ui/components/Header.d.ts +1 -1
  220. package/dist/ui/components/MarkdownText.d.ts +16 -2
  221. package/dist/ui/components/MarkdownText.js +244 -34
  222. package/dist/ui/components/TextInput.d.ts +8 -1
  223. package/dist/ui/components/TextInput.js +6 -2
  224. package/dist/ui/theme.d.ts +4 -3
  225. package/dist/ui/theme.js +5 -4
  226. package/dist/utils/buildInfo.d.ts +97 -0
  227. package/dist/utils/buildInfo.js +244 -0
  228. package/dist/utils/fs.d.ts +11 -0
  229. package/dist/utils/fs.js +91 -26
  230. package/dist/utils/openPath.d.ts +2 -2
  231. package/dist/utils/openPath.js +19 -6
  232. package/dist/utils/path.d.ts +2 -1
  233. package/dist/utils/path.js +6 -2
  234. package/dist/utils/utf8.d.ts +22 -0
  235. package/dist/utils/utf8.js +54 -0
  236. package/dist/utils/version.d.ts +9 -3
  237. package/dist/utils/version.js +28 -2
  238. package/package.json +28 -21
  239. package/dist/cli/commands/lspWizard.d.ts +0 -14
  240. package/dist/cli/commands/lspWizard.js +0 -44
  241. package/dist/cli/commands/mcpWizard.d.ts +0 -15
  242. package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
  243. package/dist/cli/commands/skillConfirmRemove.js +0 -20
  244. package/dist/cli/commands/skillCreation.d.ts +0 -12
  245. package/dist/cli/commands/skillCreation.js +0 -14
  246. package/dist/cli/commands/skillWizard.d.ts +0 -17
  247. package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
  248. package/dist/cli/commands/streaming/idleTimer.js +0 -24
  249. package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -10
  250. package/dist/cli/commands/streaming/turnOutcome.js +0 -13
  251. package/dist/cli/commands/wizardActions.d.ts +0 -46
  252. package/dist/cli/commands/wizardActions.js +0 -46
  253. package/dist/cli/commands/wizardInput.d.ts +0 -4
  254. package/dist/cli/commands/wizardInput.js +0 -19
  255. package/dist/cli/commands/wizardPrompts.d.ts +0 -22
  256. package/dist/cli/commands/wizardPrompts.js +0 -52
  257. package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
  258. package/dist/cli/commands/wizardSuggestions.js +0 -188
  259. package/dist/cli/commands/wizardTransition.d.ts +0 -37
  260. package/dist/cli/commands/wizardTransition.js +0 -43
  261. package/dist/core/bashOutput/ansi.d.ts +0 -1
  262. package/dist/core/bashOutput/ansi.js +0 -7
  263. package/dist/core/bashOutput/registry.d.ts +0 -4
  264. package/dist/core/goal/completionPolicy.d.ts +0 -2
  265. package/dist/core/goal/completionPolicy.js +0 -7
  266. package/dist/core/goal/requestClassifier.d.ts +0 -3
  267. package/dist/core/goal/requestClassifier.js +0 -18
  268. package/dist/core/goal/sessionGoal.d.ts +0 -8
  269. package/dist/core/goal/sessionGoal.js +0 -30
  270. package/dist/core/limits/byteBudgets.d.ts +0 -18
  271. package/dist/core/limits/byteBudgets.js +0 -18
  272. package/dist/core/limits/textBudgets.d.ts +0 -23
  273. package/dist/core/limits/textBudgets.js +0 -23
  274. package/dist/core/safety/bashClassifier.d.ts +0 -10
  275. package/dist/llm/lsp.d.ts +0 -129
  276. package/dist/llm/lsp.js +0 -307
  277. package/dist/ui/components/ErrorView.d.ts +0 -4
  278. package/dist/ui/components/ErrorView.js +0 -7
  279. package/dist/utils/yaml.d.ts +0 -2
  280. package/dist/utils/yaml.js +0 -8
  281. package/examples/skills/files/SKILL.md +0 -16
  282. package/examples/skills/files/examples/file-editing.md +0 -3
  283. /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
  284. /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
  285. /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
  286. /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
  287. /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
  288. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
  289. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
  290. /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
  291. /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
  292. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
  293. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
  294. /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
@@ -3,7 +3,8 @@ import { tool } from 'ai';
3
3
  import { z } from 'zod';
4
4
  import { readSettings } from '../config/settings.js';
5
5
  import { configuredLspServers } from '../config/lspSettings.js';
6
- import { lspDefinition, lspDocumentSymbols, lspReferences, lspWorkspaceSymbols, pickLspServer } from './lsp.js';
6
+ import { pickLspServer } from './lsp/pool.js';
7
+ import { lspDefinition, lspDiagnostics, lspDocumentSymbols, lspImplementation, lspReferences, lspTypeDefinition, lspWorkspaceSymbols } from './lsp/requests.js';
7
8
  async function serverFor(filePath) {
8
9
  const servers = configuredLspServers(await readSettings()).filter(server => server.enabled !== false);
9
10
  return pickLspServer(servers, filePath);
@@ -30,86 +31,157 @@ function lspFailure(error) {
30
31
  const message = error instanceof Error ? error.message : String(error);
31
32
  return { ok: false, error: cleanLspError(message) };
32
33
  }
33
- export const lspTools = {
34
- lspWorkspaceSymbols: tool({
35
- description: 'Use a configured language server to search workspace symbols by name. Read-only. Best first LSP tool when the user names a function/class but you do not yet have a precise reference position. If this fails with no project or returns empty, use grep/listFiles to find candidate files, then lspSymbols on those files.',
36
- inputSchema: z.object({
37
- query: z.string().min(1).describe('Symbol name or prefix to search for'),
38
- server: z.string().optional().describe('Optional configured LSP server name. If omitted, the first enabled server is used.'),
39
- maxSymbols: z.number().int().positive().max(100).default(50).describe('Maximum symbols to return'),
34
+ export const lspTools = buildLspTools();
35
+ /**
36
+ * Build the LSP tool set bound to a shared turn-scoped client pool so repeated
37
+ * symbols/definition/references calls reuse one initialized server and its
38
+ * opened documents instead of paying startup + indexing per call (RH-009).
39
+ */
40
+ export function buildLspTools(pool) {
41
+ return {
42
+ lspWorkspaceSymbols: tool({
43
+ description: 'Use a configured language server to search workspace symbols by name. Read-only. Best first LSP tool when the user names a function/class but you do not yet have a precise reference position. If this fails with no project or returns empty, use grep/listFiles to find candidate files, then lspSymbols on those files.',
44
+ inputSchema: z.object({
45
+ query: z.string().min(1).describe('Symbol name or prefix to search for'),
46
+ server: z.string().optional().describe('Optional configured LSP server name. If omitted, the first enabled server is used.'),
47
+ maxSymbols: z.number().int().positive().max(100).default(50).describe('Maximum symbols to return'),
48
+ }),
49
+ execute: async ({ query, server: serverName, maxSymbols }) => {
50
+ const server = await namedOrFirstServer(serverName);
51
+ if (!server)
52
+ return { ok: false, error: serverName ? `No enabled LSP server named ${serverName}.` : 'No enabled LSP server configured. Use /lsp add <preset>.' };
53
+ try {
54
+ const symbols = await lspWorkspaceSymbols(server, query, maxSymbols, pool);
55
+ return { ok: true, server: server.name, query, symbols, truncated: symbols.length >= maxSymbols };
56
+ }
57
+ catch (error) {
58
+ return lspFailure(error);
59
+ }
60
+ },
40
61
  }),
41
- execute: async ({ query, server: serverName, maxSymbols }) => {
42
- const server = await namedOrFirstServer(serverName);
43
- if (!server)
44
- return { ok: false, error: serverName ? `No enabled LSP server named ${serverName}.` : 'No enabled LSP server configured. Use /lsp add <preset>.' };
45
- try {
46
- const symbols = await lspWorkspaceSymbols(server, query, maxSymbols);
47
- return { ok: true, server: server.name, query, symbols, truncated: symbols.length >= maxSymbols };
48
- }
49
- catch (error) {
50
- return lspFailure(error);
51
- }
52
- },
53
- }),
54
- lspSymbols: tool({
55
- description: 'Use a configured language server to list semantic symbols in a source file. Read-only. Use this after grep/listFiles identifies a likely file, especially when workspace symbol search fails or is not indexed.',
56
- inputSchema: z.object({
57
- path: z.string().min(1).describe('Workspace-relative source file path'),
58
- maxSymbols: z.number().int().positive().max(200).default(80).describe('Maximum symbols to return'),
62
+ lspSymbols: tool({
63
+ description: 'Use a configured language server to list semantic symbols in a source file. Read-only. Use this after grep/listFiles identifies a likely file, especially when workspace symbol search fails or is not indexed.',
64
+ inputSchema: z.object({
65
+ path: z.string().min(1).describe('Workspace-relative source file path'),
66
+ maxSymbols: z.number().int().positive().max(200).default(80).describe('Maximum symbols to return'),
67
+ }),
68
+ execute: async ({ path: filePath, maxSymbols }) => {
69
+ const server = await serverFor(filePath);
70
+ if (!server)
71
+ return noServer(filePath);
72
+ try {
73
+ const symbols = await lspDocumentSymbols(server, filePath, maxSymbols, pool);
74
+ return { ok: true, server: server.name, path: filePath, symbols, truncated: symbols.length >= maxSymbols };
75
+ }
76
+ catch (error) {
77
+ return lspFailure(error);
78
+ }
79
+ },
59
80
  }),
60
- execute: async ({ path: filePath, maxSymbols }) => {
61
- const server = await serverFor(filePath);
62
- if (!server)
63
- return noServer(filePath);
64
- try {
65
- const symbols = await lspDocumentSymbols(server, filePath, maxSymbols);
66
- return { ok: true, server: server.name, path: filePath, symbols, truncated: symbols.length >= maxSymbols };
67
- }
68
- catch (error) {
69
- return lspFailure(error);
70
- }
71
- },
72
- }),
73
- lspDefinition: tool({
74
- description: 'Use a configured language server to find the definition at a 1-based line/column in a source file. Read-only.',
75
- inputSchema: z.object({
76
- path: z.string().min(1).describe('Workspace-relative source file path'),
77
- line: z.number().int().positive().describe('1-based line number'),
78
- column: z.number().int().positive().describe('1-based column/character number'),
79
- maxResults: z.number().int().positive().max(50).default(20).describe('Maximum locations to return'),
81
+ lspDefinition: tool({
82
+ description: 'Use a configured language server to find the definition at a 1-based line/column in a source file. Read-only.',
83
+ inputSchema: z.object({
84
+ path: z.string().min(1).describe('Workspace-relative source file path'),
85
+ line: z.number().int().positive().describe('1-based line number'),
86
+ column: z.number().int().positive().describe('1-based column/character number'),
87
+ maxResults: z.number().int().positive().max(50).default(20).describe('Maximum locations to return'),
88
+ }),
89
+ execute: async ({ path: filePath, line, column, maxResults }) => {
90
+ const server = await serverFor(filePath);
91
+ if (!server)
92
+ return noServer(filePath);
93
+ try {
94
+ const locations = await lspDefinition(server, filePath, line, column, maxResults, pool);
95
+ return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
96
+ }
97
+ catch (error) {
98
+ return lspFailure(error);
99
+ }
100
+ },
80
101
  }),
81
- execute: async ({ path: filePath, line, column, maxResults }) => {
82
- const server = await serverFor(filePath);
83
- if (!server)
84
- return noServer(filePath);
85
- try {
86
- const locations = await lspDefinition(server, filePath, line, column, maxResults);
87
- return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
88
- }
89
- catch (error) {
90
- return lspFailure(error);
91
- }
92
- },
93
- }),
94
- lspReferences: tool({
95
- description: 'Use a configured language server to find references at a 1-based line/column in a source file. Read-only.',
96
- inputSchema: z.object({
97
- path: z.string().min(1).describe('Workspace-relative source file path'),
98
- line: z.number().int().positive().describe('1-based line number'),
99
- column: z.number().int().positive().describe('1-based column/character number'),
100
- maxResults: z.number().int().positive().max(100).default(50).describe('Maximum locations to return'),
102
+ lspReferences: tool({
103
+ description: 'Use a configured language server to find references at a 1-based line/column in a source file. Read-only.',
104
+ inputSchema: z.object({
105
+ path: z.string().min(1).describe('Workspace-relative source file path'),
106
+ line: z.number().int().positive().describe('1-based line number'),
107
+ column: z.number().int().positive().describe('1-based column/character number'),
108
+ maxResults: z.number().int().positive().max(100).default(50).describe('Maximum locations to return'),
109
+ }),
110
+ execute: async ({ path: filePath, line, column, maxResults }) => {
111
+ const server = await serverFor(filePath);
112
+ if (!server)
113
+ return noServer(filePath);
114
+ try {
115
+ const locations = await lspReferences(server, filePath, line, column, maxResults, pool);
116
+ return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
117
+ }
118
+ catch (error) {
119
+ return lspFailure(error);
120
+ }
121
+ },
101
122
  }),
102
- execute: async ({ path: filePath, line, column, maxResults }) => {
103
- const server = await serverFor(filePath);
104
- if (!server)
105
- return noServer(filePath);
106
- try {
107
- const locations = await lspReferences(server, filePath, line, column, maxResults);
108
- return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
109
- }
110
- catch (error) {
111
- return lspFailure(error);
112
- }
113
- },
114
- }),
115
- };
123
+ lspTypeDefinition: tool({
124
+ description: 'Use a configured language server to find the type definition (e.g. interface, type alias, class) for the symbol at a 1-based line/column. Read-only. Useful for generics and annotated values where lspDefinition lands on the annotated name instead of its type.',
125
+ inputSchema: z.object({
126
+ path: z.string().min(1).describe('Workspace-relative source file path'),
127
+ line: z.number().int().positive().describe('1-based line number'),
128
+ column: z.number().int().positive().describe('1-based column/character number'),
129
+ maxResults: z.number().int().positive().max(50).default(20).describe('Maximum locations to return'),
130
+ }),
131
+ execute: async ({ path: filePath, line, column, maxResults }) => {
132
+ const server = await serverFor(filePath);
133
+ if (!server)
134
+ return noServer(filePath);
135
+ try {
136
+ const locations = await lspTypeDefinition(server, filePath, line, column, maxResults, pool);
137
+ return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
138
+ }
139
+ catch (error) {
140
+ return lspFailure(error);
141
+ }
142
+ },
143
+ }),
144
+ lspImplementation: tool({
145
+ description: 'Use a configured language server to find implementations of an interface, abstract member, or generic signature at a 1-based line/column. Read-only.',
146
+ inputSchema: z.object({
147
+ path: z.string().min(1).describe('Workspace-relative source file path'),
148
+ line: z.number().int().positive().describe('1-based line number'),
149
+ column: z.number().int().positive().describe('1-based column/character number'),
150
+ maxResults: z.number().int().positive().max(100).default(50).describe('Maximum locations to return'),
151
+ }),
152
+ execute: async ({ path: filePath, line, column, maxResults }) => {
153
+ const server = await serverFor(filePath);
154
+ if (!server)
155
+ return noServer(filePath);
156
+ try {
157
+ const locations = await lspImplementation(server, filePath, line, column, maxResults, pool);
158
+ return { ok: true, server: server.name, path: filePath, locations, truncated: locations.length >= maxResults };
159
+ }
160
+ catch (error) {
161
+ return lspFailure(error);
162
+ }
163
+ },
164
+ }),
165
+ lspDiagnostics: tool({
166
+ description: 'Use a configured language server to get diagnostics (errors/warnings) for one source file. Read-only. Best for a quick post-edit check of a single touched file; prefer the relevant build/test command for authoritative whole-project validation.',
167
+ inputSchema: z.object({
168
+ path: z.string().min(1).describe('Workspace-relative source file path'),
169
+ maxResults: z.number().int().positive().max(100).default(50).describe('Maximum diagnostics to return'),
170
+ }),
171
+ execute: async ({ path: filePath, maxResults }) => {
172
+ const server = await serverFor(filePath);
173
+ if (!server)
174
+ return noServer(filePath);
175
+ try {
176
+ const result = await lspDiagnostics(server, filePath, maxResults, pool);
177
+ if (!result.ok)
178
+ return { ok: false, error: result.error };
179
+ return { ok: true, server: server.name, path: filePath, diagnostics: result.diagnostics, truncated: result.diagnostics.length >= maxResults };
180
+ }
181
+ catch (error) {
182
+ return lspFailure(error);
183
+ }
184
+ },
185
+ }),
186
+ };
187
+ }
@@ -0,0 +1 @@
1
+ export declare function createChatGptCodexFetch(providerName: string, fetchImpl?: typeof fetch): typeof fetch;
@@ -0,0 +1,43 @@
1
+ import { getProviderAuth, setProviderAuth } from '../config/providerAuth.js';
2
+ import { CHATGPT_CODEX_RESPONSES_URL, refreshChatGptAuth } from './openaiCodexOAuth.js';
3
+ const REFRESH_MARGIN_MS = 60_000;
4
+ const refreshes = new Map();
5
+ async function currentAuth(providerName) {
6
+ const stored = await getProviderAuth(providerName);
7
+ if (!stored || stored.type !== 'oauth')
8
+ throw new Error(`ChatGPT is not connected for provider ${providerName}. Run /provider and choose "sign in with ChatGPT".`);
9
+ if (stored.expires > Date.now() + REFRESH_MARGIN_MS)
10
+ return stored;
11
+ let pending = refreshes.get(providerName);
12
+ if (!pending) {
13
+ pending = refreshChatGptAuth(stored)
14
+ .then(async (auth) => {
15
+ // Re-read the store before writing back so a concurrent sign-out on
16
+ // another haze instance (or this one) wins. Without this, an in-flight
17
+ // refresh would resurrect credentials the user just removed.
18
+ const current = await getProviderAuth(providerName);
19
+ if (!current || current.type !== 'oauth')
20
+ return auth;
21
+ await setProviderAuth(providerName, auth);
22
+ return auth;
23
+ })
24
+ .finally(() => refreshes.delete(providerName));
25
+ refreshes.set(providerName, pending);
26
+ }
27
+ return pending;
28
+ }
29
+ function authenticatedHeaders(init, auth) {
30
+ const headers = new Headers(init?.headers);
31
+ headers.delete('authorization');
32
+ headers.set('authorization', `Bearer ${auth.access}`);
33
+ if (auth.accountId)
34
+ headers.set('ChatGPT-Account-Id', auth.accountId);
35
+ headers.set('originator', 'haze');
36
+ return headers;
37
+ }
38
+ export function createChatGptCodexFetch(providerName, fetchImpl = fetch) {
39
+ return async (_input, init) => {
40
+ const auth = await currentAuth(providerName);
41
+ return fetchImpl(CHATGPT_CODEX_RESPONSES_URL, { ...init, headers: authenticatedHeaders(init, auth) });
42
+ };
43
+ }
@@ -0,0 +1,51 @@
1
+ import type { OAuthProviderAuth } from '../config/providerAuth.js';
2
+ export declare const CHATGPT_CODEX_BASE_URL = "https://chatgpt.com/backend-api/codex";
3
+ export declare const CHATGPT_CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
4
+ interface PkceCodes {
5
+ verifier: string;
6
+ challenge: string;
7
+ }
8
+ interface TokenResponse {
9
+ id_token?: string;
10
+ access_token?: string;
11
+ refresh_token?: string;
12
+ expires_in?: number;
13
+ }
14
+ export interface ChatGptBrowserLogin {
15
+ url: string;
16
+ complete: () => Promise<OAuthProviderAuth>;
17
+ close: () => Promise<void>;
18
+ }
19
+ export interface StartChatGptBrowserLoginOptions {
20
+ issuer?: string;
21
+ port?: number;
22
+ timeoutMs?: number;
23
+ fetchImpl?: typeof fetch;
24
+ signal?: AbortSignal;
25
+ }
26
+ export interface IdTokenClaims {
27
+ chatgpt_account_id?: string;
28
+ organizations?: Array<{
29
+ id: string;
30
+ }>;
31
+ 'https://api.openai.com/auth'?: {
32
+ chatgpt_account_id?: string;
33
+ };
34
+ }
35
+ export declare function generatePkce(): Promise<PkceCodes>;
36
+ export declare function buildChatGptAuthorizeUrl(input: {
37
+ issuer?: string;
38
+ redirectUri: string;
39
+ pkce: PkceCodes;
40
+ state: string;
41
+ }): string;
42
+ export declare function parseJwtClaims(token: string): IdTokenClaims | undefined;
43
+ export declare function extractChatGptAccountId(tokens: Pick<TokenResponse, 'id_token' | 'access_token'>): string | undefined;
44
+ export declare function refreshChatGptAuth(auth: OAuthProviderAuth, options?: {
45
+ issuer?: string;
46
+ fetchImpl?: typeof fetch;
47
+ signal?: AbortSignal;
48
+ }): Promise<OAuthProviderAuth>;
49
+ export declare function startChatGptBrowserLogin(options?: StartChatGptBrowserLoginOptions): Promise<ChatGptBrowserLogin>;
50
+ export declare function openBrowser(url: string): Promise<boolean>;
51
+ export {};
@@ -0,0 +1,217 @@
1
+ import crypto from 'node:crypto';
2
+ import { createServer } from 'node:http';
3
+ import { openPath } from '../utils/openPath.js';
4
+ const CHATGPT_OAUTH_CLIENT_ID = 'app_EMoamEEZ73f0CkXaXp7hrann';
5
+ const CHATGPT_OAUTH_ISSUER = 'https://auth.openai.com';
6
+ export const CHATGPT_CODEX_BASE_URL = 'https://chatgpt.com/backend-api/codex';
7
+ export const CHATGPT_CODEX_RESPONSES_URL = `${CHATGPT_CODEX_BASE_URL}/responses`;
8
+ // Fixed by the registered ChatGPT OAuth client: the redirect_uri must match
9
+ // exactly. Do not switch to an ephemeral port — the auth server would reject
10
+ // the callback.
11
+ const CHATGPT_OAUTH_CALLBACK_PORT = 1455;
12
+ const CALLBACK_PATH = '/auth/callback';
13
+ const DEFAULT_TIMEOUT_MS = 5 * 60 * 1000;
14
+ function base64UrlEncode(value) {
15
+ return Buffer.from(value instanceof Uint8Array ? value : new Uint8Array(value)).toString('base64url');
16
+ }
17
+ export async function generatePkce() {
18
+ const verifier = base64UrlEncode(crypto.randomBytes(32));
19
+ const challenge = base64UrlEncode(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier)));
20
+ return { verifier, challenge };
21
+ }
22
+ export function buildChatGptAuthorizeUrl(input) {
23
+ const params = new URLSearchParams({
24
+ response_type: 'code',
25
+ client_id: CHATGPT_OAUTH_CLIENT_ID,
26
+ redirect_uri: input.redirectUri,
27
+ scope: 'openid profile email offline_access',
28
+ code_challenge: input.pkce.challenge,
29
+ code_challenge_method: 'S256',
30
+ id_token_add_organizations: 'true',
31
+ codex_cli_simplified_flow: 'true',
32
+ state: input.state,
33
+ originator: 'haze',
34
+ });
35
+ return `${input.issuer ?? CHATGPT_OAUTH_ISSUER}/oauth/authorize?${params.toString()}`;
36
+ }
37
+ export function parseJwtClaims(token) {
38
+ const parts = token.split('.');
39
+ if (parts.length !== 3)
40
+ return undefined;
41
+ try {
42
+ return JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8'));
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
48
+ export function extractChatGptAccountId(tokens) {
49
+ for (const token of [tokens.id_token, tokens.access_token]) {
50
+ if (!token)
51
+ continue;
52
+ const claims = parseJwtClaims(token);
53
+ const accountId = claims?.chatgpt_account_id
54
+ ?? claims?.['https://api.openai.com/auth']?.chatgpt_account_id
55
+ ?? claims?.organizations?.[0]?.id;
56
+ if (accountId)
57
+ return accountId;
58
+ }
59
+ return undefined;
60
+ }
61
+ async function tokenRequest(issuer, body, fetchImpl, signal) {
62
+ const response = await fetchImpl(`${issuer}/oauth/token`, {
63
+ method: 'POST',
64
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
65
+ body: body.toString(),
66
+ signal,
67
+ });
68
+ if (!response.ok)
69
+ throw new Error(`ChatGPT token request failed with HTTP ${response.status}.`);
70
+ return response.json();
71
+ }
72
+ function credentialsFromTokens(tokens, previous) {
73
+ const access = tokens.access_token;
74
+ const refresh = tokens.refresh_token ?? previous?.refresh;
75
+ if (!access || !refresh)
76
+ throw new Error('ChatGPT authorization returned incomplete credentials. Sign in again.');
77
+ const extracted = extractChatGptAccountId(tokens);
78
+ // When the new tokens carry no account claim (e.g., an opaque access token
79
+ // without JWT claims), fall back to the previous accountId so refresh keeps
80
+ // the same account context. Theoretically stale if the user switched account
81
+ // since the original login; requires a fresh sign-in to correct.
82
+ const accountId = extracted ?? previous?.accountId;
83
+ return {
84
+ type: 'oauth',
85
+ access,
86
+ refresh,
87
+ expires: Date.now() + (tokens.expires_in ?? 3600) * 1000,
88
+ ...(accountId ? { accountId } : {}),
89
+ };
90
+ }
91
+ export async function refreshChatGptAuth(auth, options = {}) {
92
+ const tokens = await tokenRequest(options.issuer ?? CHATGPT_OAUTH_ISSUER, new URLSearchParams({
93
+ grant_type: 'refresh_token',
94
+ refresh_token: auth.refresh,
95
+ client_id: CHATGPT_OAUTH_CLIENT_ID,
96
+ }), options.fetchImpl ?? fetch, options.signal);
97
+ return credentialsFromTokens(tokens, auth);
98
+ }
99
+ function callbackHtml(success) {
100
+ const title = success ? 'ChatGPT connected' : 'ChatGPT sign-in failed';
101
+ const detail = success ? 'You can close this window and return to haze.' : 'Return to haze for details and try again.';
102
+ return `<!doctype html><html><head><meta charset="utf-8"><title>${title}</title></head><body><main><h1>${title}</h1><p>${detail}</p></main></body></html>`;
103
+ }
104
+ async function closeServer(server) {
105
+ if (!server.listening)
106
+ return;
107
+ // Force-close idle keep-alive connections so the event loop can settle
108
+ // promptly (server.close alone only stops listening).
109
+ server.closeAllConnections?.();
110
+ await new Promise(resolve => server.close(() => resolve()));
111
+ }
112
+ export async function startChatGptBrowserLogin(options = {}) {
113
+ const issuer = options.issuer ?? CHATGPT_OAUTH_ISSUER;
114
+ const port = options.port ?? CHATGPT_OAUTH_CALLBACK_PORT;
115
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
116
+ const fetchImpl = options.fetchImpl ?? fetch;
117
+ // RFC 8252 loopback redirects intentionally use HTTP: traffic never leaves
118
+ // the host, while PKCE and the random state protect the authorization code.
119
+ const redirectUri = `http://localhost:${port}${CALLBACK_PATH}`;
120
+ const pkce = await generatePkce();
121
+ const state = base64UrlEncode(crypto.randomBytes(32));
122
+ const controller = new AbortController();
123
+ const signal = options.signal ? AbortSignal.any([options.signal, controller.signal]) : controller.signal;
124
+ let settled = false;
125
+ let resolveLogin;
126
+ let rejectLogin;
127
+ const completion = new Promise((resolve, reject) => {
128
+ resolveLogin = resolve;
129
+ rejectLogin = reject;
130
+ });
131
+ // The browser may redirect before the UI starts awaiting complete(). Keep the
132
+ // rejection observed while preserving it for the eventual caller.
133
+ void completion.catch(() => undefined);
134
+ const settleError = (error) => {
135
+ if (settled)
136
+ return;
137
+ settled = true;
138
+ rejectLogin(error);
139
+ };
140
+ const settleSuccess = (auth) => {
141
+ if (settled)
142
+ return;
143
+ settled = true;
144
+ resolveLogin(auth);
145
+ };
146
+ const server = createServer((request, response) => {
147
+ void (async () => {
148
+ const url = new URL(request.url ?? '/', `http://localhost:${port}`);
149
+ if (url.pathname !== CALLBACK_PATH) {
150
+ response.writeHead(404).end('Not found');
151
+ return;
152
+ }
153
+ const oauthError = url.searchParams.get('error_description') ?? url.searchParams.get('error');
154
+ const code = url.searchParams.get('code');
155
+ if (oauthError || !code || url.searchParams.get('state') !== state) {
156
+ const message = oauthError ?? (!code ? 'ChatGPT callback did not include an authorization code.' : 'ChatGPT callback state did not match.');
157
+ settleError(new Error(message));
158
+ response.writeHead(400, { 'Content-Type': 'text/html; charset=utf-8' }).end(callbackHtml(false));
159
+ return;
160
+ }
161
+ try {
162
+ const tokens = await tokenRequest(issuer, new URLSearchParams({
163
+ grant_type: 'authorization_code',
164
+ code,
165
+ redirect_uri: redirectUri,
166
+ client_id: CHATGPT_OAUTH_CLIENT_ID,
167
+ code_verifier: pkce.verifier,
168
+ }), fetchImpl, signal);
169
+ const auth = credentialsFromTokens(tokens);
170
+ settleSuccess(auth);
171
+ response.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }).end(callbackHtml(true));
172
+ }
173
+ catch (error) {
174
+ const failure = error instanceof Error ? error : new Error(String(error));
175
+ settleError(failure);
176
+ response.writeHead(500, { 'Content-Type': 'text/html; charset=utf-8' }).end(callbackHtml(false));
177
+ }
178
+ })();
179
+ });
180
+ await new Promise((resolve, reject) => {
181
+ server.once('error', reject);
182
+ // Bind only to the loopback hostname registered in redirectUri.
183
+ server.listen(port, 'localhost', resolve);
184
+ }).catch(error => {
185
+ controller.abort();
186
+ throw new Error(`Could not start the ChatGPT sign-in callback on localhost:${port}: ${error instanceof Error ? error.message : String(error)}`);
187
+ });
188
+ const timeout = setTimeout(() => {
189
+ controller.abort();
190
+ settleError(new Error('ChatGPT sign-in timed out. Run /provider and try again.'));
191
+ }, timeoutMs);
192
+ const onAbort = () => settleError(new Error('ChatGPT sign-in was cancelled.'));
193
+ options.signal?.addEventListener('abort', onAbort, { once: true });
194
+ const close = async () => {
195
+ if (!settled)
196
+ settleError(new Error('ChatGPT sign-in was cancelled.'));
197
+ clearTimeout(timeout);
198
+ options.signal?.removeEventListener('abort', onAbort);
199
+ controller.abort();
200
+ await closeServer(server);
201
+ };
202
+ return {
203
+ url: buildChatGptAuthorizeUrl({ issuer, redirectUri, pkce, state }),
204
+ complete: async () => {
205
+ try {
206
+ return await completion;
207
+ }
208
+ finally {
209
+ await close();
210
+ }
211
+ },
212
+ close,
213
+ };
214
+ }
215
+ export async function openBrowser(url) {
216
+ return openPath(url);
217
+ }
@@ -1,4 +1,5 @@
1
1
  import type { ToolSet } from 'ai';
2
+ import { LspPool } from './lsp/pool.js';
2
3
  import { type PromptSession } from './systemPrompt.js';
3
4
  import { readSettings } from '../config/settings.js';
4
5
  import { type ModelRuntimeSelection } from './client.js';
@@ -20,12 +21,16 @@ export interface TurnExecutionScope {
20
21
  coordinator: SubagentCoordinator;
21
22
  mutationPolicy: WorkspaceMutationPolicy;
22
23
  }
24
+ /** Keep the common coding path lean while preserving explicitly relevant capabilities. */
25
+ export declare function selectToolsForRequest(tools: ToolSet, request?: string): ToolSet;
23
26
  export interface AssembledRequestContext {
24
27
  systemPrompt: string;
25
28
  availableTools: ToolSet;
26
29
  /** Tool name -> coarse origin bucket, used by /context to group token estimates. */
27
30
  toolCategories: Map<string, ToolCategory>;
28
31
  loadedMcp?: LoadedMcpTools;
32
+ /** Turn-scoped LSP client pool; callers close it once the turn/context is done. */
33
+ lspPool?: LspPool;
29
34
  executionScope: TurnExecutionScope;
30
35
  }
31
36
  /**
@@ -45,6 +50,8 @@ export declare function assembleRequestContext(input: {
45
50
  onSubagentEvent?: (event: CoordinatorEvent) => void;
46
51
  abortSignal?: AbortSignal;
47
52
  executionScope?: TurnExecutionScope;
53
+ /** Current user request, used only to omit irrelevant heavyweight built-ins. */
54
+ request?: string;
48
55
  /** Pre-read settings so a turn performs a single settings read (CR-024). */
49
56
  settings?: Awaited<ReturnType<typeof readSettings>>;
50
57
  }): Promise<AssembledRequestContext>;