@denizokcu/haze 0.11.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 (230) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +23 -14
  3. package/SECURITY.md +3 -3
  4. package/dist/buildInfo.json +3 -3
  5. package/dist/cli/chat/chatMetrics.d.ts +2 -2
  6. package/dist/cli/chat/chatMetrics.js +1 -1
  7. package/dist/cli/chat/fileMentionSuggestions.js +1 -1
  8. package/dist/cli/chat/inputSuggestions.d.ts +8 -16
  9. package/dist/cli/chat/inputSuggestions.js +9 -41
  10. package/dist/cli/chat/messages.d.ts +0 -2
  11. package/dist/cli/chat/messages.js +2 -2
  12. package/dist/cli/chat/sessionLifecycle.d.ts +2 -1
  13. package/dist/cli/chat/turnState.d.ts +1 -1
  14. package/dist/cli/chat/wizardDispatch.d.ts +90 -28
  15. package/dist/cli/chat/wizardDispatch.js +250 -133
  16. package/dist/cli/commands/chat.js +14 -72
  17. package/dist/cli/commands/chatModes.d.ts +8 -1
  18. package/dist/cli/commands/chatModes.js +9 -44
  19. package/dist/cli/commands/doctor.js +1 -1
  20. package/dist/cli/commands/formatters.d.ts +3 -3
  21. package/dist/cli/commands/formatters.js +6 -25
  22. package/dist/cli/commands/providerWizard.js +2 -3
  23. package/dist/cli/commands/runCommand.js +1 -1
  24. package/dist/cli/commands/serverWizard.d.ts +34 -0
  25. package/dist/cli/commands/{mcpWizard.js → serverWizard.js} +44 -2
  26. package/dist/cli/commands/skillsWizard.d.ts +41 -0
  27. package/dist/cli/commands/{skillWizard.js → skillsWizard.js} +33 -11
  28. package/dist/cli/commands/streaming/abortCause.d.ts +2 -1
  29. package/dist/cli/commands/streaming/agentAttempt.d.ts +43 -0
  30. package/dist/cli/commands/streaming/agentAttempt.js +79 -0
  31. package/dist/cli/commands/streaming/attemptLifecycle.d.ts +56 -0
  32. package/dist/cli/commands/streaming/attemptLifecycle.js +110 -0
  33. package/dist/cli/commands/streaming/attemptOutcome.d.ts +96 -0
  34. package/dist/cli/commands/streaming/attemptOutcome.js +206 -0
  35. package/dist/cli/commands/streaming/attemptSetup.d.ts +78 -0
  36. package/dist/cli/commands/streaming/attemptSetup.js +167 -0
  37. package/dist/cli/commands/streaming/goalCheckpoint.d.ts +1 -1
  38. package/dist/cli/commands/streaming/goalCheckpoint.js +2 -2
  39. package/dist/cli/commands/streaming/goalSupervisor.js +9 -6
  40. package/dist/cli/commands/streaming/stallRecovery.d.ts +94 -0
  41. package/dist/cli/commands/streaming/stallRecovery.js +105 -0
  42. package/dist/cli/commands/streaming/streamLoop.d.ts +72 -0
  43. package/dist/cli/commands/streaming/streamLoop.js +448 -0
  44. package/dist/cli/commands/streaming/toolCallRecovery.d.ts +14 -0
  45. package/dist/cli/commands/streaming/toolCallRecovery.js +56 -0
  46. package/dist/cli/commands/streaming/toolGroupRenderer.d.ts +2 -1
  47. package/dist/cli/commands/streaming/turnRuntime.d.ts +4 -0
  48. package/dist/cli/commands/streaming/turnRuntime.js +6 -0
  49. package/dist/cli/commands/streaming.d.ts +14 -25
  50. package/dist/cli/commands/streaming.js +43 -754
  51. package/dist/cli/commands/wizardFlow.d.ts +334 -0
  52. package/dist/cli/commands/wizardFlow.js +377 -0
  53. package/dist/cli/contextReport.js +3 -0
  54. package/dist/cli/index.js +1 -1
  55. package/dist/config/contextFiles.js +9 -3
  56. package/dist/config/inputHistory.d.ts +0 -1
  57. package/dist/config/inputHistory.js +1 -1
  58. package/dist/config/modelDiscovery.d.ts +0 -15
  59. package/dist/config/modelDiscovery.js +1 -1
  60. package/dist/config/settings.d.ts +7 -0
  61. package/dist/config/settings.js +3 -0
  62. package/dist/config/skillSettings.js +4 -4
  63. package/dist/config/updateCheck.d.ts +0 -1
  64. package/dist/config/updateCheck.js +1 -1
  65. package/dist/core/agent/budgets.d.ts +63 -1
  66. package/dist/core/agent/budgets.js +84 -1
  67. package/dist/core/agent/compaction.js +1 -1
  68. package/dist/core/agent/completionController.d.ts +7 -13
  69. package/dist/core/agent/completionController.js +17 -8
  70. package/dist/core/agent/contextBudget.d.ts +0 -4
  71. package/dist/core/agent/contextBudget.js +3 -3
  72. package/dist/core/agent/errors.d.ts +0 -1
  73. package/dist/core/agent/errors.js +1 -1
  74. package/dist/core/agent/events.d.ts +5 -1
  75. package/dist/core/{goal/completionPolicy.d.ts → agent/goalPolicy.d.ts} +18 -0
  76. package/dist/core/agent/goalPolicy.js +106 -0
  77. package/dist/core/agent/requestAssembly.d.ts +2 -2
  78. package/dist/core/agent/requestAssembly.js +16 -4
  79. package/dist/core/agent/toolCapabilities.d.ts +2 -2
  80. package/dist/core/agent/toolCapabilities.js +5 -5
  81. package/dist/core/agent/toolOutputStore.js +1 -1
  82. package/dist/core/agent/toolResults.js +1 -1
  83. package/dist/core/agent/workState.d.ts +6 -3
  84. package/dist/core/agent/workState.js +62 -7
  85. package/dist/core/attachments/imageAttachments.js +90 -42
  86. package/dist/core/deadline.d.ts +0 -6
  87. package/dist/core/deadline.js +1 -1
  88. package/dist/core/io/boundedRead.js +1 -1
  89. package/dist/core/limits.d.ts +51 -0
  90. package/dist/core/limits.js +51 -0
  91. package/dist/core/log/llmLog.js +1 -1
  92. package/dist/core/process/backgroundRegistry.d.ts +2 -3
  93. package/dist/core/process/backgroundRegistry.js +10 -6
  94. package/dist/core/process/userShell.d.ts +16 -0
  95. package/dist/core/process/userShell.js +59 -0
  96. package/dist/core/safety/shellClassifier.d.ts +11 -0
  97. package/dist/core/safety/{bashClassifier.js → shellClassifier.js} +5 -3
  98. package/dist/core/safety/urlGuard.d.ts +1 -1
  99. package/dist/core/session/sessionSlimming.d.ts +0 -3
  100. package/dist/core/session/sessionSlimming.js +2 -3
  101. package/dist/core/session/sessionStore.d.ts +1 -0
  102. package/dist/core/session/sessionStore.js +39 -20
  103. package/dist/core/{bashOutput → shellOutput}/lineFilter.js +8 -2
  104. package/dist/core/{bashOutput → shellOutput}/reducers/search.d.ts +0 -1
  105. package/dist/core/{bashOutput → shellOutput}/reducers/search.js +1 -1
  106. package/dist/core/shellOutput/registry.d.ts +2 -0
  107. package/dist/core/{bashOutput → shellOutput}/registry.js +3 -3
  108. package/dist/core/{bashOutput → shellOutput}/types.d.ts +6 -5
  109. package/dist/core/subagent/contracts.d.ts +2 -14
  110. package/dist/core/subagent/contracts.js +3 -3
  111. package/dist/core/subagent/executionProfiles.js +2 -2
  112. package/dist/core/subagent/subagentRunner.js +3 -4
  113. package/dist/core/toolOutput/reduction.d.ts +0 -12
  114. package/dist/core/toolOutput/reduction.js +1 -1
  115. package/dist/core/validation/outputParser.d.ts +2 -2
  116. package/dist/llm/client.js +5 -1
  117. package/dist/llm/hazeTools.d.ts +139 -124
  118. package/dist/llm/hazeTools.js +14 -11
  119. package/dist/llm/initPrompt.js +1 -1
  120. package/dist/llm/lsp/client.d.ts +45 -0
  121. package/dist/llm/lsp/client.js +195 -0
  122. package/dist/llm/lsp/pool.d.ts +23 -0
  123. package/dist/llm/lsp/pool.js +86 -0
  124. package/dist/llm/lsp/protocol.d.ts +64 -0
  125. package/dist/llm/lsp/protocol.js +128 -0
  126. package/dist/llm/lsp/requests.d.ts +94 -0
  127. package/dist/llm/lsp/requests.js +119 -0
  128. package/dist/llm/lspTools.d.ts +3824 -570
  129. package/dist/llm/lspTools.js +65 -1
  130. package/dist/llm/openaiCodex.d.ts +0 -2
  131. package/dist/llm/openaiCodex.js +0 -4
  132. package/dist/llm/openaiCodexOAuth.d.ts +0 -3
  133. package/dist/llm/openaiCodexOAuth.js +6 -3
  134. package/dist/llm/requestContext.d.ts +5 -1
  135. package/dist/llm/requestContext.js +25 -2
  136. package/dist/llm/systemPrompt.d.ts +1 -0
  137. package/dist/llm/systemPrompt.js +13 -6
  138. package/dist/llm/toolResultTypes.d.ts +0 -14
  139. package/dist/llm/toolResultTypes.js +1 -4
  140. package/dist/llm/tools/editMatch.d.ts +0 -9
  141. package/dist/llm/tools/editMatch.js +1 -1
  142. package/dist/llm/tools/fetchTool.js +1 -1
  143. package/dist/llm/tools/fileToolShared.d.ts +4 -2
  144. package/dist/llm/tools/fileToolShared.js +9 -5
  145. package/dist/llm/tools/gitIgnore.d.ts +25 -32
  146. package/dist/llm/tools/gitIgnore.js +216 -98
  147. package/dist/llm/tools/grepParse.d.ts +2 -1
  148. package/dist/llm/tools/grepRunner.d.ts +1 -1
  149. package/dist/llm/tools/grepRunner.js +2 -2
  150. package/dist/llm/tools/outputCap.d.ts +2 -7
  151. package/dist/llm/tools/outputCap.js +3 -3
  152. package/dist/llm/tools/processTool.d.ts +16 -16
  153. package/dist/llm/tools/processTool.js +1 -1
  154. package/dist/llm/tools/readRecovery.d.ts +0 -2
  155. package/dist/llm/tools/readRecovery.js +2 -2
  156. package/dist/llm/tools/{bashTool.d.ts → shellTool.d.ts} +123 -107
  157. package/dist/llm/tools/{bashTool.js → shellTool.js} +15 -14
  158. package/dist/llm/tools/toolContext.js +5 -5
  159. package/dist/llm/tools/workspaceFile.d.ts +0 -1
  160. package/dist/llm/tools/workspaceFile.js +1 -6
  161. package/dist/llm/webFetch.d.ts +1 -1
  162. package/dist/skills/SkillLoader.d.ts +1 -11
  163. package/dist/skills/SkillLoader.js +1 -2
  164. package/dist/skills/types.d.ts +2 -1
  165. package/dist/utils/buildInfo.d.ts +6 -13
  166. package/dist/utils/buildInfo.js +6 -15
  167. package/dist/utils/fs.d.ts +7 -5
  168. package/dist/utils/fs.js +5 -2
  169. package/dist/utils/path.d.ts +0 -1
  170. package/dist/utils/path.js +1 -1
  171. package/package.json +6 -4
  172. package/dist/cli/commands/lspWizard.d.ts +0 -14
  173. package/dist/cli/commands/lspWizard.js +0 -44
  174. package/dist/cli/commands/mcpWizard.d.ts +0 -15
  175. package/dist/cli/commands/skillConfirmRemove.d.ts +0 -11
  176. package/dist/cli/commands/skillConfirmRemove.js +0 -20
  177. package/dist/cli/commands/skillCreation.d.ts +0 -12
  178. package/dist/cli/commands/skillCreation.js +0 -14
  179. package/dist/cli/commands/skillWizard.d.ts +0 -17
  180. package/dist/cli/commands/streaming/idleTimer.d.ts +0 -26
  181. package/dist/cli/commands/streaming/idleTimer.js +0 -24
  182. package/dist/cli/commands/streaming/turnOutcome.d.ts +0 -27
  183. package/dist/cli/commands/streaming/turnOutcome.js +0 -29
  184. package/dist/cli/commands/wizardActions.d.ts +0 -47
  185. package/dist/cli/commands/wizardActions.js +0 -47
  186. package/dist/cli/commands/wizardInput.d.ts +0 -4
  187. package/dist/cli/commands/wizardInput.js +0 -19
  188. package/dist/cli/commands/wizardPrompts.d.ts +0 -22
  189. package/dist/cli/commands/wizardPrompts.js +0 -58
  190. package/dist/cli/commands/wizardSuggestions.d.ts +0 -31
  191. package/dist/cli/commands/wizardSuggestions.js +0 -190
  192. package/dist/cli/commands/wizardTransition.d.ts +0 -37
  193. package/dist/cli/commands/wizardTransition.js +0 -43
  194. package/dist/core/agent/toolExecutionBudget.d.ts +0 -35
  195. package/dist/core/agent/toolExecutionBudget.js +0 -49
  196. package/dist/core/agent/turnBudget.d.ts +0 -35
  197. package/dist/core/agent/turnBudget.js +0 -27
  198. package/dist/core/bashOutput/ansi.d.ts +0 -1
  199. package/dist/core/bashOutput/ansi.js +0 -7
  200. package/dist/core/bashOutput/registry.d.ts +0 -4
  201. package/dist/core/goal/completionPolicy.js +0 -43
  202. package/dist/core/goal/requestClassifier.d.ts +0 -3
  203. package/dist/core/goal/requestClassifier.js +0 -18
  204. package/dist/core/goal/sessionGoal.d.ts +0 -8
  205. package/dist/core/goal/sessionGoal.js +0 -30
  206. package/dist/core/limits/byteBudgets.d.ts +0 -20
  207. package/dist/core/limits/byteBudgets.js +0 -20
  208. package/dist/core/limits/textBudgets.d.ts +0 -25
  209. package/dist/core/limits/textBudgets.js +0 -25
  210. package/dist/core/safety/bashClassifier.d.ts +0 -10
  211. package/dist/llm/lsp.d.ts +0 -149
  212. package/dist/llm/lsp.js +0 -368
  213. package/dist/ui/components/ErrorView.d.ts +0 -4
  214. package/dist/ui/components/ErrorView.js +0 -7
  215. package/dist/utils/yaml.d.ts +0 -2
  216. package/dist/utils/yaml.js +0 -8
  217. package/examples/skills/files/SKILL.md +0 -16
  218. package/examples/skills/files/examples/file-editing.md +0 -3
  219. /package/dist/core/{bashOutput → shellOutput}/command.d.ts +0 -0
  220. /package/dist/core/{bashOutput → shellOutput}/command.js +0 -0
  221. /package/dist/core/{bashOutput → shellOutput}/lineFilter.d.ts +0 -0
  222. /package/dist/core/{bashOutput → shellOutput}/reducers/content.d.ts +0 -0
  223. /package/dist/core/{bashOutput → shellOutput}/reducers/content.js +0 -0
  224. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.d.ts +0 -0
  225. /package/dist/core/{bashOutput → shellOutput}/reducers/gh.js +0 -0
  226. /package/dist/core/{bashOutput → shellOutput}/reducers/git.d.ts +0 -0
  227. /package/dist/core/{bashOutput → shellOutput}/reducers/git.js +0 -0
  228. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.d.ts +0 -0
  229. /package/dist/core/{bashOutput → shellOutput}/reducers/validation.js +0 -0
  230. /package/dist/core/{bashOutput → shellOutput}/types.js +0 -0
@@ -4,7 +4,7 @@ function has(command, pattern) {
4
4
  function uniq(values) {
5
5
  return [...new Set(values)];
6
6
  }
7
- export function classifyBashCommand(command) {
7
+ export function classifyShellCommand(command) {
8
8
  const trimmed = command.trim();
9
9
  const traits = [];
10
10
  const lower = trimmed.toLowerCase();
@@ -63,11 +63,13 @@ export function classifyBashCommand(command) {
63
63
  traits.push('reads_files');
64
64
  return { riskLevel: 'unknown', traits: uniq(traits), confidence: 'low', reason: 'find -exec / xargs runs an embedded command' };
65
65
  }
66
- if (has(lower, /(^|[;&|]\s*)(npm\s+test|npm\s+run\s+(test|typecheck|lint|build)|pnpm\s+(test|run\s+(test|typecheck|lint|build))|yarn\s+(test|run\s+(test|typecheck|lint|build))|vitest\b|jest\b|tsc\b|eslint\b)/)) {
67
- if (has(lower, /test|vitest|jest/))
66
+ if (has(lower, /(^|[;&|]\s*)(npm\s+test|npm\s+run\s+(test|typecheck|lint|build)|pnpm\s+(test|run\s+(test|typecheck|lint|build))|yarn\s+(test|run\s+(test|typecheck|lint|build))|vitest\b|jest\b|tsc\b|eslint\b|pytest\b|(?:uv|poetry)\s+run\s+pytest\b|python3?\s+-m\s+(pytest|unittest|nose2?)\b|go\s+test\b|cargo\s+(test|nextest)\b|make\s+(test|check)\b|(?:mvn|\.\/mvnw)\s+(test|verify)\b|(?:gradle|gradlew|\.\/gradlew)\s+test\b|rspec\b|bundle\s+exec\s+rspec\b|dotnet\s+test\b|deno\s+(test|lint)\b|bun\s+(test|lint)\b|node\s+--test\b|phpunit\b|composer\s+test\b|mix\s+test\b|swift\s+test\b|ctest\b|xcodebuild\b[^;&|]*\btest\b)/)) {
67
+ if (has(lower, /test|vitest|jest|rspec|make\s+check|mvn\s+verify/))
68
68
  traits.push('runs_tests');
69
69
  if (has(lower, /build|tsc|typecheck|lint|eslint/))
70
70
  traits.push('runs_build');
71
+ if (traits.length === 0)
72
+ traits.push('runs_tests');
71
73
  return { riskLevel: 'read_only', traits: uniq(traits), confidence: complex ? 'medium' : 'high', reason: 'validation command' };
72
74
  }
73
75
  if (has(lower, /(^|[;&|]\s*)(git\s+(status|diff|log|show|branch)\b|rg\b|grep\b|find\b|ls\b|pwd\b|cat\b|head\b|tail\b|node\s+--version|npm\s+--version|which\b)/)) {
@@ -6,7 +6,7 @@
6
6
  * blocking + DNS-resolution check (defeats DNS rebinding to internal IPs).
7
7
  *
8
8
  * This module is pure safety logic under `core/safety/`, parallel to
9
- * `bashClassifier.ts`. It must not import anything from `ai`, `hazeTools`, or
9
+ * `shellClassifier.ts`. It must not import anything from `ai`, `hazeTools`, or
10
10
  * the UI — keep it auditable in one place.
11
11
  */
12
12
  export type UrlValidation = {
@@ -1,5 +1,2 @@
1
- import type { ModelMessage } from 'ai';
2
1
  import type { SessionEntry } from './sessionStore.js';
3
- export declare function slimConversationSnapshot(messages: ModelMessage[]): ModelMessage[];
4
2
  export declare function prepareSessionEntryForWrite(entry: SessionEntry): SessionEntry | undefined;
5
- export declare const SESSION_INLINE_VALUE_BYTES: number;
@@ -1,4 +1,4 @@
1
- import { SESSION_INLINE_VALUE_BYTES as INLINE_VALUE_BYTES, SESSION_LARGE_STRING_CHARS as LARGE_STRING_CHARS, SESSION_PREVIEW_CHARS as PREVIEW_CHARS } from '../limits/textBudgets.js';
1
+ import { SESSION_INLINE_VALUE_BYTES as INLINE_VALUE_BYTES, SESSION_LARGE_STRING_CHARS as LARGE_STRING_CHARS, SESSION_PREVIEW_CHARS as PREVIEW_CHARS } from '../limits.js';
2
2
  import { imageFilePartBytes, isImageFilePart } from '../attachments/imageAttachments.js';
3
3
  import { formatBytes } from '../../utils/format.js';
4
4
  function jsonByteLength(value) {
@@ -65,7 +65,7 @@ function slimUnknown(value, seen = new WeakSet()) {
65
65
  next[key] = slimUnknown(child, seen);
66
66
  return next;
67
67
  }
68
- export function slimConversationSnapshot(messages) {
68
+ function slimConversationSnapshot(messages) {
69
69
  return slimUnknown(messages);
70
70
  }
71
71
  function slimToolStartInput(input) {
@@ -118,4 +118,3 @@ export function prepareSessionEntryForWrite(entry) {
118
118
  }
119
119
  return entry;
120
120
  }
121
- export const SESSION_INLINE_VALUE_BYTES = INLINE_VALUE_BYTES;
@@ -41,6 +41,7 @@ export interface HazeSession {
41
41
  id: string;
42
42
  file: string;
43
43
  cwd: string;
44
+ sessionsDir: string;
44
45
  /** New sessions stay memory-only until they contain a resumable message. */
45
46
  deferredWrite?: DeferredSessionWrite;
46
47
  }
@@ -4,7 +4,7 @@ import fs from 'fs-extra';
4
4
  import { HAZE_DIR } from '../../config/paths.js';
5
5
  import { prepareSessionEntryForWrite } from './sessionSlimming.js';
6
6
  import { appendPrivateFile, ensurePrivateDir, tightenPrivateFile, writePrivateFileAtomic } from '../../config/privateStorage.js';
7
- import { JSONL_LINE_BYTES } from '../limits/byteBudgets.js';
7
+ import { JSONL_LINE_BYTES } from '../limits.js';
8
8
  import { iterateBoundedUtf8Lines } from '../io/boundedRead.js';
9
9
  const DEFAULT_SESSIONS_DIR = path.join(HAZE_DIR, 'sessions');
10
10
  function cwdHash(cwd = process.cwd()) {
@@ -16,6 +16,20 @@ function sessionDir(cwd = process.cwd(), sessionsDir = DEFAULT_SESSIONS_DIR) {
16
16
  function sessionFile(id, cwd = process.cwd(), sessionsDir = DEFAULT_SESSIONS_DIR) {
17
17
  return path.join(sessionDir(cwd, sessionsDir), `${id}.jsonl`);
18
18
  }
19
+ function validatedSessionFile(session) {
20
+ const id = session.id.trim();
21
+ if (!id || id !== session.id || id === '.' || id === '..' || id.includes('/') || id.includes('\\') || path.isAbsolute(id)) {
22
+ throw new Error(`Invalid session id: ${session.id}`);
23
+ }
24
+ const sessionsDir = path.resolve(session.sessionsDir);
25
+ const expected = path.resolve(sessionFile(id, session.cwd, sessionsDir));
26
+ const resolved = path.resolve(session.file);
27
+ const relative = path.relative(sessionsDir, resolved);
28
+ if (relative.startsWith('..') || path.isAbsolute(relative) || resolved !== expected) {
29
+ throw new Error(`Session file is outside its configured session directory: ${session.file}`);
30
+ }
31
+ return expected;
32
+ }
19
33
  function newSessionId(now = new Date()) {
20
34
  // Timestamp prefix keeps latestSession() lexicographic ordering; the random
21
35
  // suffix prevents same-millisecond collisions (CR-025).
@@ -24,12 +38,14 @@ function newSessionId(now = new Date()) {
24
38
  export async function createSession(options = {}) {
25
39
  const cwd = path.resolve(options.cwd ?? process.cwd());
26
40
  const id = newSessionId();
27
- const file = sessionFile(id, cwd, options.sessionsDir);
41
+ const sessionsDir = path.resolve(options.sessionsDir ?? DEFAULT_SESSIONS_DIR);
42
+ const file = sessionFile(id, cwd, sessionsDir);
28
43
  await ensurePrivateDir(path.dirname(file));
29
44
  return {
30
45
  id,
31
46
  file,
32
47
  cwd,
48
+ sessionsDir,
33
49
  deferredWrite: {
34
50
  header: { type: 'header', id, cwd, createdAt: new Date().toISOString(), hazeVersion: options.hazeVersion, forkedFrom: options.forkedFrom, ...(options.build ? { build: options.build } : {}) },
35
51
  entries: [],
@@ -38,21 +54,20 @@ export async function createSession(options = {}) {
38
54
  }
39
55
  export async function findSession(id, cwd = process.cwd(), sessionsDir = DEFAULT_SESSIONS_DIR) {
40
56
  const normalizedId = id.trim();
41
- // basename equality is the actual invariant: it rejects any id containing a
42
- // path separator (POSIX or Windows), which is what prevents escaping the
43
- // workspace's sessions/<hash>/ directory via `..` or absolute paths.
44
- if (!normalizedId || path.basename(normalizedId) !== normalizedId)
57
+ // Reject both platform-native and foreign separators so session IDs remain
58
+ // single filenames if a session is moved between operating systems.
59
+ if (!normalizedId || normalizedId !== id || normalizedId === '.' || normalizedId === '..' || normalizedId.includes('/') || normalizedId.includes('\\') || path.isAbsolute(normalizedId))
45
60
  return undefined;
46
61
  const file = sessionFile(normalizedId, cwd, sessionsDir);
47
62
  if (!await fs.pathExists(file))
48
63
  return undefined;
49
- return { id: normalizedId, file, cwd: path.resolve(cwd) };
64
+ return { id: normalizedId, file, cwd: path.resolve(cwd), sessionsDir: path.resolve(sessionsDir) };
50
65
  }
51
66
  export async function latestSession(cwd = process.cwd(), sessionsDir = DEFAULT_SESSIONS_DIR) {
52
67
  const latest = (await listSessions(cwd, sessionsDir))[0];
53
68
  if (!latest)
54
69
  return undefined;
55
- return { id: latest.id, file: sessionFile(latest.id, cwd, sessionsDir), cwd: path.resolve(cwd) };
70
+ return { id: latest.id, file: sessionFile(latest.id, cwd, sessionsDir), cwd: path.resolve(cwd), sessionsDir: path.resolve(sessionsDir) };
56
71
  }
57
72
  function entryMakesSessionResumable(entry) {
58
73
  if (entry.type === 'ui_message')
@@ -60,6 +75,7 @@ function entryMakesSessionResumable(entry) {
60
75
  return entry.type === 'conversation_snapshot' && entry.messages.length > 0;
61
76
  }
62
77
  export async function appendSessionEntry(session, entry) {
78
+ const file = validatedSessionFile(session);
63
79
  const prepared = prepareSessionEntryForWrite(entry);
64
80
  if (!prepared)
65
81
  return;
@@ -70,11 +86,11 @@ export async function appendSessionEntry(session, entry) {
70
86
  return;
71
87
  }
72
88
  const entries = [deferred.header, ...deferred.entries, prepared];
73
- await appendPrivateFile(session.file, entries.map(item => JSON.stringify(item)).join('\n') + '\n');
89
+ await appendPrivateFile(file, entries.map(item => JSON.stringify(item)).join('\n') + '\n');
74
90
  session.deferredWrite = undefined;
75
91
  return;
76
92
  }
77
- await appendPrivateFile(session.file, `${JSON.stringify(prepared)}\n`);
93
+ await appendPrivateFile(file, `${JSON.stringify(prepared)}\n`);
78
94
  // Snapshot deduplication runs inside the same serialized writer as the
79
95
  // append, so ordering with subsequent entries is preserved (F-03).
80
96
  await vacuumSessionFileIfLarge(session).catch(() => undefined);
@@ -95,9 +111,10 @@ export function setSessionVacuumThresholdForTests(bytes) {
95
111
  effectiveVacuumThresholdBytes = bytes;
96
112
  }
97
113
  export async function vacuumSessionFileIfLarge(session, thresholdBytes = effectiveVacuumThresholdBytes) {
114
+ const file = validatedSessionFile(session);
98
115
  if (session.deferredWrite)
99
116
  return false;
100
- const stat = await fs.stat(session.file).catch(() => undefined);
117
+ const stat = await fs.stat(file).catch(() => undefined);
101
118
  if (!stat || stat.size < thresholdBytes)
102
119
  return false;
103
120
  const { entries } = await readSessionEntries(session);
@@ -120,7 +137,7 @@ export async function vacuumSessionFileIfLarge(session, thresholdBytes = effecti
120
137
  // dominant snapshot would trigger a full rewrite on every append.
121
138
  if (serialized.length > stat.size / 2)
122
139
  return false;
123
- await writePrivateFileAtomic(session.file, serialized);
140
+ await writePrivateFileAtomic(file, serialized);
124
141
  return true;
125
142
  }
126
143
  const MAX_PARSE_ERRORS = 100;
@@ -180,9 +197,10 @@ function parseSessionEntry(value) {
180
197
  }
181
198
  }
182
199
  async function scanSessionEntries(session, onEntry) {
183
- if (session.deferredWrite && !await fs.pathExists(session.file))
200
+ const file = validatedSessionFile(session);
201
+ if (session.deferredWrite && !await fs.pathExists(file))
184
202
  return [];
185
- await tightenPrivateFile(session.file);
203
+ await tightenPrivateFile(file);
186
204
  const parseErrors = [];
187
205
  let omittedErrors = 0;
188
206
  const report = (message) => {
@@ -191,7 +209,7 @@ async function scanSessionEntries(session, onEntry) {
191
209
  else
192
210
  omittedErrors++;
193
211
  };
194
- for await (const { line, lineNumber, oversized } of iterateBoundedUtf8Lines(session.file, JSONL_LINE_BYTES)) {
212
+ for await (const { line, lineNumber, oversized } of iterateBoundedUtf8Lines(file, JSONL_LINE_BYTES)) {
195
213
  if (!line && !oversized)
196
214
  continue;
197
215
  if (oversized) {
@@ -326,14 +344,15 @@ export async function listSessions(cwd = process.cwd(), sessionsDir = DEFAULT_SE
326
344
  }
327
345
  const summaries = await Promise.all(files.map(async (fileName) => {
328
346
  const id = path.basename(fileName, '.jsonl');
329
- const session = { id, file: path.join(dir, fileName), cwd: path.resolve(cwd) };
330
- await tightenPrivateFile(session.file);
331
- const stat = await fs.stat(session.file);
332
- const cached = cachedSessionSummary(session.file, stat);
347
+ const session = { id, file: path.join(dir, fileName), cwd: path.resolve(cwd), sessionsDir: path.resolve(sessionsDir) };
348
+ const file = validatedSessionFile(session);
349
+ await tightenPrivateFile(file);
350
+ const stat = await fs.stat(file);
351
+ const cached = cachedSessionSummary(file, stat);
333
352
  if (cached)
334
353
  return cached;
335
354
  const summary = await summarizeSession(session, stat);
336
- cacheSessionSummary(session.file, stat, summary);
355
+ cacheSessionSummary(file, stat, summary);
337
356
  return summary;
338
357
  }));
339
358
  return summaries
@@ -1,5 +1,11 @@
1
- import { stripAnsi as stripAnsiCodes } from './ansi.js';
2
1
  import { commandMatches } from './command.js';
2
+ /* eslint-disable no-control-regex */
3
+ /** Strip common CSI/OSC escape sequences emitted by CLIs (central ANSI handling for reducers/filters). */
4
+ function stripAnsi(text) {
5
+ return text
6
+ .replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g, '')
7
+ .replace(/[\u001B\u009B][[\]()#;?]*(?:(?:(?:[a-zA-Z\d]*(?:;[a-zA-Z\d]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g, '');
8
+ }
3
9
  function matchesCommand(definition, command) {
4
10
  return commandMatches(command, definition.matchCommand);
5
11
  }
@@ -26,7 +32,7 @@ export function applyLineFilter(definition, command, text) {
26
32
  try {
27
33
  let next = text;
28
34
  if (definition.stripAnsi)
29
- next = stripAnsiCodes(next);
35
+ next = stripAnsi(next);
30
36
  for (const replacement of definition.replace ?? [])
31
37
  next = next.replace(replacement.pattern, replacement.replacement);
32
38
  const matched = definition.matchOutput?.test(next) ?? false;
@@ -3,5 +3,4 @@ export interface SearchReductionOptions {
3
3
  maxMatchesPerFile?: number;
4
4
  maxTotalMatches?: number;
5
5
  }
6
- export declare function isSearchCommand(command: string): boolean;
7
6
  export declare function reduceSearchOutput(command: string, stdout: string, stderr: string, options?: SearchReductionOptions): string | undefined;
@@ -3,7 +3,7 @@ const DEFAULT_OPTIONS = { maxFiles: 15, maxMatchesPerFile: 5, maxTotalMatches: 3
3
3
  const SEARCH_COMMAND = /^(?:rg|grep|git\s+grep|ag|ack)(?:\s|$)/;
4
4
  const SIGNAL_LINE = /\b(error|fail(?:ed|ure)?|warn(?:ing)?|exception|panic|fatal|todo|fixme)\b/i;
5
5
  const MATCH_LINE = /^(.+?)([:-])(\d+)\2(.*)$/;
6
- export function isSearchCommand(command) {
6
+ function isSearchCommand(command) {
7
7
  return commandMatches(command, SEARCH_COMMAND);
8
8
  }
9
9
  function parseSearchLine(line, index) {
@@ -0,0 +1,2 @@
1
+ import type { ShellOutputFilterInput, ShellOutputFilterResult } from './types.js';
2
+ export declare function filterShellOutput(input: ShellOutputFilterInput): ShellOutputFilterResult;
@@ -5,7 +5,7 @@ import { reduceGhOutput } from './reducers/gh.js';
5
5
  import { reduceSearchOutput } from './reducers/search.js';
6
6
  import { reduceGenericLogOutput, reduceJsonOutput, reduceUnifiedDiffOutput } from './reducers/content.js';
7
7
  import { capOutputForProcessing, isInflating, reductionMetrics, retrievalHint } from '../toolOutput/reduction.js';
8
- export const builtInLineFilters = [
8
+ const builtInLineFilters = [
9
9
  { name: 'markdownlint', matchCommand: /(^|[;&|]\s*)markdownlint\b/, stripAnsi: true, truncateLinesAt: 200, maxLines: 80, onEmpty: 'markdownlint: ok' },
10
10
  { name: 'shellcheck', matchCommand: /(^|[;&|]\s*)shellcheck\b/, stripAnsi: true, stripLinesMatching: [/^In .* line \d+:/], truncateLinesAt: 200, maxLines: 100, onEmpty: 'shellcheck: ok' },
11
11
  { name: 'docker-list', matchCommand: /(^|[;&|]\s*)docker\s+(?:ps|images)\b/, stripAnsi: true, truncateLinesAt: 180, maxLines: 40, onEmpty: 'docker: no rows' },
@@ -61,7 +61,7 @@ function passthroughReduction(raw, input) {
61
61
  ...reductionMetrics(raw, compacted.text),
62
62
  };
63
63
  }
64
- export function filterBashOutput(input) {
64
+ export function filterShellOutput(input) {
65
65
  try {
66
66
  let stdout;
67
67
  let stderr;
@@ -129,7 +129,7 @@ export function filterBashOutput(input) {
129
129
  const warning = error instanceof Error ? error.message : String(error);
130
130
  const stdout = passthroughReduction(input.stdout, input);
131
131
  const stderr = passthroughReduction(input.stderr, input);
132
- stdout.warning = `bash output filter failed: ${warning}`;
132
+ stdout.warning = `shell output filter failed: ${warning}`;
133
133
  stdout.parseTier = 'degraded';
134
134
  return { stdout, stderr, summary: input.validationSummary };
135
135
  }
@@ -1,14 +1,14 @@
1
- import type { BashClassification } from '../safety/bashClassifier.js';
1
+ import type { ShellClassification } from '../safety/shellClassifier.js';
2
2
  import type { ValidationSummary } from '../../llm/toolResultTypes.js';
3
3
  import type { ReductionContentKind, ReductionParseTier } from '../toolOutput/reduction.js';
4
- export type ParseTier = ReductionParseTier;
5
- export interface BashOutputFilterInput {
4
+ type ParseTier = ReductionParseTier;
5
+ export interface ShellOutputFilterInput {
6
6
  command: string;
7
7
  code: number | null;
8
8
  stdout: string;
9
9
  stderr: string;
10
10
  timedOut: boolean;
11
- classification?: BashClassification;
11
+ classification?: ShellClassification;
12
12
  validationSummary?: ValidationSummary;
13
13
  storeRawOutput?: (content: string) => string;
14
14
  fallbackCompact: (text: string, maxChars?: number) => {
@@ -39,8 +39,9 @@ export interface StreamReduction {
39
39
  estimatedSavedTokens?: number;
40
40
  savingsPct?: number;
41
41
  }
42
- export interface BashOutputFilterResult {
42
+ export interface ShellOutputFilterResult {
43
43
  stdout: StreamReduction;
44
44
  stderr: StreamReduction;
45
45
  summary?: ValidationSummary;
46
46
  }
47
+ export {};
@@ -1,19 +1,7 @@
1
1
  import type { JSONValue, LanguageModel } from 'ai';
2
2
  import { z } from 'zod';
3
- export declare const workerModes: readonly ["inspect", "research", "implement", "validate"];
3
+ declare const workerModes: readonly ["inspect", "research", "implement", "validate"];
4
4
  export type WorkerMode = typeof workerModes[number];
5
- export declare const subagentTaskInputV2Schema: z.ZodObject<{
6
- objective: z.ZodString;
7
- deliverable: z.ZodString;
8
- mode: z.ZodEnum<{
9
- inspect: "inspect";
10
- research: "research";
11
- implement: "implement";
12
- validate: "validate";
13
- }>;
14
- scope: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
- acceptanceCriteria: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
- }, z.core.$strip>;
17
5
  export declare const subagentInputSchema: z.ZodObject<{
18
6
  objective: z.ZodString;
19
7
  deliverable: z.ZodString;
@@ -116,5 +104,5 @@ export declare function fallbackProviderCapabilities(): ProviderCapabilities;
116
104
  /** Single source for the placeholder runtime used when only a bare model is available (CR-018). */
117
105
  export declare function fallbackWorkerRuntime(model: WorkerRuntime['model'], selector?: string, providerName?: string): WorkerRuntime;
118
106
  export declare function normalizeSubagentInput(input: SubagentToolInput, id: string): SubagentTaskCapsule;
119
- export declare function legacyStatus(termination: WorkerTermination): SubagentExecutionResult['status'];
120
107
  export declare function withLegacyProjection(capsule: SubagentResultCapsule, telemetry: SubagentTelemetry, error?: string): SubagentExecutionResult;
108
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { SUBAGENT_ACCEPTANCE_CHARS, SUBAGENT_ACCEPTANCE_ITEMS, SUBAGENT_DELIVERABLE_CHARS, SUBAGENT_OBJECTIVE_CHARS, SUBAGENT_SCOPE_CHARS, SUBAGENT_SCOPE_ITEMS, } from '../agent/budgets.js';
3
- export const workerModes = ['inspect', 'research', 'implement', 'validate'];
4
- export const subagentTaskInputV2Schema = z.object({
3
+ const workerModes = ['inspect', 'research', 'implement', 'validate'];
4
+ const subagentTaskInputV2Schema = z.object({
5
5
  objective: z.string().trim().min(1).max(SUBAGENT_OBJECTIVE_CHARS).describe('Self-contained outcome for the worker. Keep it under 1000 characters; do not paste conversation history or file contents.'),
6
6
  deliverable: z.string().trim().min(1).max(SUBAGENT_DELIVERABLE_CHARS).describe('Exact compact result the worker must return to the main agent.'),
7
7
  mode: z.enum(workerModes).describe('inspect/research are read-only; implement may edit; validate may run commands.'),
@@ -31,7 +31,7 @@ export function fallbackWorkerRuntime(model, selector = 'active-model', provider
31
31
  export function normalizeSubagentInput(input, id) {
32
32
  return { id, objective: input.objective, deliverable: input.deliverable, mode: input.mode, scope: input.scope ?? [], acceptanceCriteria: input.acceptanceCriteria ?? [] };
33
33
  }
34
- export function legacyStatus(termination) {
34
+ function legacyStatus(termination) {
35
35
  if (termination === 'completed' || termination === 'no_output')
36
36
  return 'ok';
37
37
  if (termination === 'cancelled')
@@ -25,8 +25,8 @@ export const BUILT_IN_SUBAGENT_PROFILES = {
25
25
  export const MODE_TOOL_NAMES = {
26
26
  inspect: ['listFiles', 'readFile', 'grep', 'readToolOutput'],
27
27
  research: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'fetch'],
28
- implement: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile', 'bash'],
29
- validate: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'bash'],
28
+ implement: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile', 'shell'],
29
+ validate: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'shell'],
30
30
  };
31
31
  export function isMutationMode(mode) {
32
32
  return mode === 'implement' || mode === 'validate';
@@ -1,10 +1,9 @@
1
1
  import { generateText, isStepCount, tool } from 'ai';
2
2
  import { estimateToolSchemas, estimateValueTokens } from '../agent/contextBudget.js';
3
- import { SUBAGENT_MAX_STEPS, SUBAGENT_MIN_STEPS, SUBAGENT_SYNTHESIS_RESERVE, SUBAGENT_TOOL_ONLY_LIMIT, } from '../agent/budgets.js';
3
+ import { SUBAGENT_MAX_STEPS, SUBAGENT_MIN_STEPS, SUBAGENT_SYNTHESIS_RESERVE, SUBAGENT_TOOL_ONLY_LIMIT, createToolExecutionBudget, isToolBudgetBlocked, withToolExecutionBudget, } from '../agent/budgets.js';
4
4
  import { storeToolOutput } from '../agent/toolOutputStore.js';
5
5
  import { withSyntheticControl } from '../agent/requestAssembly.js';
6
6
  import { toolOnlyStepCount } from '../agent/turnPolicy.js';
7
- import { createToolExecutionBudget, isToolBudgetBlocked, withToolExecutionBudget } from '../agent/toolExecutionBudget.js';
8
7
  import { assembleWorkerContext, workerTaskMessage } from '../../llm/workerContext.js';
9
8
  import { buildSubagentPrompt, projectContextSection } from '../../llm/systemPrompt.js';
10
9
  import { hazeTools } from '../../llm/hazeTools.js';
@@ -54,7 +53,7 @@ function changedPathFromOutput(name, output) {
54
53
  }
55
54
  }
56
55
  function validationFromOutput(name, output) {
57
- if (name !== 'bash' || typeof output !== 'object' || output == null)
56
+ if (name !== 'shell' || typeof output !== 'object' || output == null)
58
57
  return undefined;
59
58
  const value = output;
60
59
  if (typeof value.command !== 'string' || typeof value.validationSummary !== 'object' || value.validationSummary == null)
@@ -74,7 +73,7 @@ export async function runSubagent(taskInput, options) {
74
73
  const profile = options.profile ?? COMPATIBILITY_PROFILE;
75
74
  const runtime = options.runtime ?? fallbackWorkerRuntime(options.model);
76
75
  const task = typeof taskInput === 'string'
77
- ? { id: 'worker', objective: taskInput, deliverable: 'Return a concise self-contained result.', mode: options.allowedTools ? (options.allowedTools.some(name => ['editFile', 'replaceLines', 'writeFile'].includes(name)) ? 'implement' : options.allowedTools.includes('bash') ? 'validate' : options.allowedTools.includes('fetch') ? 'research' : 'inspect') : 'implement', scope: [], acceptanceCriteria: [], legacyMaxSteps: options.maxSteps }
76
+ ? { id: 'worker', objective: taskInput, deliverable: 'Return a concise self-contained result.', mode: options.allowedTools ? (options.allowedTools.some(name => ['editFile', 'replaceLines', 'writeFile'].includes(name)) ? 'implement' : options.allowedTools.includes('shell') ? 'validate' : options.allowedTools.includes('fetch') ? 'research' : 'inspect') : 'implement', scope: [], acceptanceCriteria: [], legacyMaxSteps: options.maxSteps }
78
77
  : taskInput;
79
78
  const requestedSteps = task.legacyMaxSteps ?? options.maxSteps;
80
79
  if (requestedSteps != null && (requestedSteps < SUBAGENT_MIN_STEPS || requestedSteps > SUBAGENT_MAX_STEPS))
@@ -1,4 +1,3 @@
1
- export type ReductionPressure = 'conservative' | 'normal' | 'aggressive';
2
1
  export declare const PROCESSING_OUTPUT_CHAR_LIMIT = 200000;
3
2
  export type ReductionContentKind = 'validation' | 'log' | 'search' | 'diff' | 'json' | 'table' | 'web' | 'source-outline' | 'generic';
4
3
  export type ReductionParseTier = 'full' | 'degraded' | 'passthrough';
@@ -10,17 +9,6 @@ export interface ReductionMetrics {
10
9
  estimatedSavedTokens: number;
11
10
  savingsPct: number;
12
11
  }
13
- export interface ToolOutputReductionMetadata extends ReductionMetrics {
14
- reducerName: string;
15
- contentKind: ReductionContentKind;
16
- lossy: boolean;
17
- parseTier: ReductionParseTier;
18
- rawHandle?: string;
19
- handle?: string;
20
- omittedChars: number;
21
- warning?: string;
22
- }
23
- export declare function estimateReductionTokens(text: string): number;
24
12
  export declare function capOutputForProcessing(text: string, maxChars?: number): string;
25
13
  export declare function reductionMetrics(raw: string, returned: string): ReductionMetrics;
26
14
  export declare function retrievalHint(handle: string): string;
@@ -1,6 +1,6 @@
1
1
  export const PROCESSING_OUTPUT_CHAR_LIMIT = 200_000;
2
2
  const PROCESSING_TRUNCATION_MARKER = '\n[... output truncated for processing ...]\n';
3
- export function estimateReductionTokens(text) {
3
+ function estimateReductionTokens(text) {
4
4
  return Math.ceil(text.length / 4);
5
5
  }
6
6
  export function capOutputForProcessing(text, maxChars = PROCESSING_OUTPUT_CHAR_LIMIT) {
@@ -1,4 +1,4 @@
1
- import type { BashClassification } from '../safety/bashClassifier.js';
1
+ import type { ShellClassification } from '../safety/shellClassifier.js';
2
2
  import type { ValidationSummary } from '../../llm/toolResultTypes.js';
3
3
  export declare function parseValidationOutput(input: {
4
4
  command: string;
@@ -8,5 +8,5 @@ export declare function parseValidationOutput(input: {
8
8
  timedOut?: boolean;
9
9
  stdoutTruncated?: boolean;
10
10
  stderrTruncated?: boolean;
11
- classification?: BashClassification;
11
+ classification?: ShellClassification;
12
12
  }): ValidationSummary;
@@ -8,6 +8,10 @@ import { FALLBACK_CONTEXT_WINDOW_TOKENS, FALLBACK_LOCAL_CONTEXT_TOKENS } from '.
8
8
  import { createChatGptCodexFetch } from './openaiCodex.js';
9
9
  const HAZE_SITE_URL = 'https://denizokcu.github.io/haze/';
10
10
  const HAZE_TITLE = 'Haze';
11
+ // The SDK requires a non-empty apiKey even though the OAuth fetch adapter
12
+ // replaces authentication. Generate a non-credential sentinel at runtime so
13
+ // static scanners cannot mistake a fixed placeholder for a shipped secret.
14
+ const OAUTH_SDK_SENTINEL = `oauth-sentinel-${crypto.randomUUID()}`;
11
15
  function isOpenRouter(providerName, baseURL) {
12
16
  return providerName === 'openrouter' || /openrouter\.ai/i.test(baseURL);
13
17
  }
@@ -55,7 +59,7 @@ function runtimeForSelection(settings, selection, cwd) {
55
59
  const requestedReasoning = isReasoningLevel(settings.reasoning) ? settings.reasoning : undefined;
56
60
  const reasoningPolicy = resolveReasoningPolicy({ requested: requestedReasoning, capabilities: caps });
57
61
  const openai = providerKind === 'chatgpt-codex'
58
- ? createOpenAI({ apiKey: 'haze-oauth-placeholder', baseURL, fetch: createChatGptCodexFetch(selection.provider.name) })
62
+ ? createOpenAI({ apiKey: OAUTH_SDK_SENTINEL, baseURL, fetch: createChatGptCodexFetch(selection.provider.name) })
59
63
  : createOpenAI({ apiKey, baseURL, headers: openRouterHeaders(selection.provider.name, baseURL) });
60
64
  const limits = modelLimitsFor(selection.provider, name);
61
65
  // Class-aware fallback so unknown local models (server-configured window,