@resolveio/server-lib 22.3.109 → 22.3.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "22.3.109",
3
+ "version": "22.3.110",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
@@ -19,6 +19,7 @@ export interface CodexRunOptions {
19
19
  threadKey?: string;
20
20
  reuseThread?: boolean;
21
21
  fallbackModels?: string[];
22
+ failOnStreamHandlerError?: boolean;
22
23
  onStreamEvent?: StreamEventHandler;
23
24
  onStreamText?: StreamTextHandler;
24
25
  onUsage?: UsageHandler;
@@ -323,6 +323,9 @@ var CodexClient = /** @class */ (function () {
323
323
  error_2 = _h.sent();
324
324
  message = error_2 instanceof Error ? error_2.message : String(error_2 || 'Unknown error');
325
325
  this.log("onStreamEvent failed: ".concat(message));
326
+ if (options === null || options === void 0 ? void 0 : options.failOnStreamHandlerError) {
327
+ throw error_2;
328
+ }
326
329
  return [3 /*break*/, 10];
327
330
  case 10: return [4 /*yield*/, this.handleStreamEvent(event_1, function (text) { return __awaiter(_this, void 0, void 0, function () {
328
331
  var next, delta, error_4, message;
@@ -348,6 +351,9 @@ var CodexClient = /** @class */ (function () {
348
351
  error_4 = _a.sent();
349
352
  message = error_4 instanceof Error ? error_4.message : String(error_4 || 'Unknown error');
350
353
  this.log("onStreamText failed: ".concat(message));
354
+ if (options === null || options === void 0 ? void 0 : options.failOnStreamHandlerError) {
355
+ throw error_4;
356
+ }
351
357
  return [3 /*break*/, 4];
352
358
  case 4:
353
359
  lastText = next;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/codex-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAA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CAAC,MAAM,EAAE,EAAE,sCAAsC,CAAhE,AAAiE,CAAC;IACjG,4CAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAjB,AAAqB,CAAC;IACtD,wCAA4B,GAAG,EAAE,GAAG,IAAR,AAAY,CAAC;IACzC,oCAAwB,GAAG,IAAI,GAAG,EAAV,AAAkD,CAAC;IACpF,0CAA8B,GAAG,KAAH,AAAQ,CAAC;IACvC,+CAAmC,GAAyB,IAAzB,AAA6B,CAAC;IACjE,8BAAkB,GAAG,KAAH,AAAQ,CAAC;IAkoC3C,kBAAC;CA1oCD,AA0oCC,IAAA;AA1oCY,kCAAW","file":"codex-client.js","sourcesContent":["import { promises as fs } from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { setTimeout as sleepTimeout } from 'timers/promises';\nexport interface CodexConfig {\n\tapiKey?: string;\n\tbaseUrl?: string;\n\tmodel?: string;\n\tfallbackModel?: string;\n\tfallbackModels?: string[];\n\tmaxRetries?: number;\n\tretryDelayMs?: number;\n}\n\n/* eslint-disable no-unused-vars -- Function type params are required for clarity. */\ntype StreamEventHandler = (event: any) => void | Promise<void>;\ntype StreamTextHandler = (delta: string, fullText: string) => void | Promise<void>;\ntype AgentMessageHandler = (text: string) => void | Promise<void>;\ntype UsageHandler = (usage: CodexUsageSummary | null) => void | Promise<void>;\ntype DynamicImport = (specifier: string) => Promise<any>;\n/* eslint-enable no-unused-vars */\n\ntype CodexModelFallbackPreference = {\n\tfallbackModel: string;\n\texpiresAt: number;\n\tupdatedAt: number;\n};\n\nexport interface CodexRunOptions {\n\ttimeoutMs?: number;\n\tstreamIdleTimeoutMs?: number;\n\tmaxRetries?: number;\n\tprocessWorkingDirectory?: string;\n\tthreadOptions?: CodexThreadOptions;\n\tthreadKey?: string;\n\treuseThread?: boolean;\n\tfallbackModels?: string[];\n\tonStreamEvent?: StreamEventHandler;\n\tonStreamText?: StreamTextHandler;\n\tonUsage?: UsageHandler;\n}\n\nexport interface CodexUsageSummary {\n\tinputTokens: number;\n\tcachedInputTokens: number;\n\toutputTokens: number;\n}\n\nexport type CodexThreadOptions = {\n\tmodel?: string;\n\tsandboxMode?: 'read-only' | 'workspace-write' | 'danger-full-access';\n\tworkingDirectory?: string;\n\tskipGitRepoCheck?: boolean;\n\tmodelReasoningEffort?: 'minimal' | 'none' | 'low' | 'medium' | 'high' | 'xhigh';\n\tnetworkAccessEnabled?: boolean;\n\twebSearchMode?: 'disabled' | 'cached' | 'live';\n\twebSearchEnabled?: boolean;\n\tapprovalPolicy?: 'never' | 'on-request' | 'on-failure' | 'untrusted';\n\tadditionalDirectories?: string[];\n};\n\nexport class CodexClient {\n\tprivate static readonly PING_PROMPT = \"Say 'pong'\";\n\tprivate static readonly MODEL_UNAVAILABLE_FALLBACK_FILE = path.join(os.tmpdir(), 'resolveio-codex-model-fallbacks.json');\n\tprivate static readonly DEFAULT_MODEL_UNAVAILABLE_TTL_MS = 6 * 60 * 60 * 1000;\n\tprivate static readonly MIN_MODEL_UNAVAILABLE_TTL_MS = 60 * 1000;\n\tprivate static readonly modelFallbackPreferences = new Map<string, CodexModelFallbackPreference>();\n\tprivate static modelFallbackPreferencesLoaded = false;\n\tprivate static modelFallbackPreferencesLoadPromise: Promise<void> | null = null;\n\tprivate static cwdFallbackRunning = false;\n\tprivate codex: any | null = null;\n\tprivate codexInit: Promise<void> | null = null;\n\tprivate readonly threadCache = new Map<string, { thread: any; optionsKey: string; modelKey: string }>();\n\tprivate readonly debugEnabled = (process.env.AI_DASHBOARD_DEBUG || '').trim().toLowerCase() === 'true';\n\tprivate readonly streamEnabled = this.resolveStreamEnabled();\n\tprivate readonly cleanZdotdirEnabled = this.resolveCleanZdotdirEnabled();\n\tprivate zDotDir: string | null = null;\n\tprivate readonly defaultTimeoutMs = this.resolveDefaultTimeoutMs();\n\tprivate readonly pingEnabled = this.resolvePingEnabled();\n\tprivate readonly pingTimeoutMs = this.resolvePingTimeoutMs();\n\tprivate readonly modelUnavailableTtlMs = this.resolveModelUnavailableTtlMs();\n\tprivate readonly config: CodexConfig;\n\tprivate readonly defaultThreadOptions: CodexThreadOptions;\n\n\tconstructor(config: CodexConfig) {\n\t\tthis.config = config;\n\t\tif (!this.config.apiKey) {\n\t\t\tthrow new Error('AI API key is required for AI client');\n\t\t}\n\t\tthis.defaultThreadOptions = this.resolveDefaultThreadOptions();\n\t}\n\n\tasync run(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tawait this.ensureModelFallbackPreferencesLoaded();\n\t\tconst maxRetries = this.normalizeRetryCount(options?.maxRetries ?? this.config.maxRetries);\n\t\tconst retryDelayMs = this.normalizeRetryDelay(this.config.retryDelayMs);\n\t\tlet lastError: unknown = null;\n\t\tconst modelSequence = this.resolveModelSequence(options);\n\t\tfor (let modelIndex = 0; modelIndex < modelSequence.length; modelIndex += 1) {\n\t\t\tconst model = modelSequence[modelIndex];\n\t\t\tconst nextModel = modelSequence[modelIndex + 1];\n\t\t\tconst modelOptions = this.applyModelOverride(options, model);\n\t\t\tlet processCwdFallbackApplied = false;\n\t\t\tlet attempt = 0;\n\t\t\twhile (attempt <= maxRetries) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.log(`run model=${model || this.config.model || 'default'} attempt ${attempt + 1}/${maxRetries + 1}`);\n\t\t\t\t\tif (this.pingEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\t\tawait this.runPing(modelOptions?.threadOptions);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.streamEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\t\tconst result = await this.runStreamedOnce(prompt, modelOptions);\n\t\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await this.runOnce(prompt, modelOptions);\n\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\t\tcatch (error) {\n\t\t\t\t\t\tlastError = error;\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\t\t\tthis.log(`run model=${model || this.config.model || 'default'} attempt ${attempt + 1} failed: ${message}`);\n\t\t\t\t\t\tif (!processCwdFallbackApplied && this.shouldApplyProcessCwdFallback(error, modelOptions)) {\n\t\t\t\t\t\t\tprocessCwdFallbackApplied = true;\n\t\t\t\t\t\t\tconst workingDirectory = this.resolveProcessWorkingDirectory(modelOptions);\n\t\t\t\t\t\t\tconst fallbackOptions = this.applyProcessCwdFallback(modelOptions);\n\t\t\t\t\t\t\tthis.log('codex workingDirectory launch failed with os error 2; retrying from process cwd without CLI workingDirectory.');\n\t\t\t\t\t\t\treturn await this.withProcessWorkingDirectoryFallback(workingDirectory, async () => {\n\t\t\t\t\t\t\t\tif (this.streamEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\t\t\t\t\tconst fallbackResult = await this.runStreamedOnce(prompt, fallbackOptions);\n\t\t\t\t\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\t\t\t\t\treturn fallbackResult;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst fallbackResult = await this.runOnce(prompt, fallbackOptions);\n\t\t\t\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\t\t\t\treturn fallbackResult;\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (nextModel && this.isModelAvailabilityError(error)) {\n\t\t\t\t\t\t\tawait this.rememberModelFallbackPreference(model, nextModel);\n\t\t\t\t\t\t\tthis.log(`model unavailable; retrying with fallback model ${nextModel}`);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.isCodexEnvironmentError(error)) {\n\t\t\t\t\t\t\tthis.recoverCodexEnvironment(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (attempt >= maxRetries || !this.isRetryableError(error)) {\n\t\t\t\t\t\t\tthrow lastError;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst delay = retryDelayMs * Math.pow(2, attempt);\n\t\t\t\t\t\tawait this.sleep(delay);\n\t\t\t\t\tattempt += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow lastError;\n\t}\n\n\tprivate async runStreamedOnce(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tconst startedAt = Date.now();\n\t\tthis.log(`runStreamed start (promptLength=${prompt.length})`);\n\t\tconst thread = await this.startThread(options?.threadOptions, options?.threadKey, options?.reuseThread);\n\t\tconst timeoutMs = options?.timeoutMs ?? this.defaultTimeoutMs;\n\t\tconst streamIdleTimeoutMs = this.normalizeStreamIdleTimeoutMs(options?.streamIdleTimeoutMs);\n\t\tconst controller = typeof AbortController !== 'undefined' ? new AbortController() : null;\n\t\tconst timeoutId = controller\n\t\t\t? setTimeout(() => controller.abort(), timeoutMs)\n\t\t\t: null;\n\t\tlet lastStreamActivityAt = Date.now();\n\t\tconst idleTimeoutId = controller && streamIdleTimeoutMs > 0\n\t\t\t? setInterval(() => {\n\t\t\t\tif (Date.now() - lastStreamActivityAt >= streamIdleTimeoutMs) {\n\t\t\t\t\tcontroller.abort();\n\t\t\t\t}\n\t\t\t}, Math.max(15_000, Math.min(60_000, Math.floor(streamIdleTimeoutMs / 4))))\n\t\t\t: null;\n\t\tlet finalResponse = '';\n\t\tlet lastText = '';\n\t\tlet usageSummary: CodexUsageSummary | null = null;\n\t\ttry {\n\t\t\tconst { events } = await thread.runStreamed(prompt, controller ? { signal: controller.signal } : undefined);\n\t\t\tfor await (const event of events) {\n\t\t\t\tlastStreamActivityAt = Date.now();\n\t\t\t\tif (event?.type === 'turn.completed') {\n\t\t\t\t\tusageSummary = this.normalizeUsageSummary(event?.usage);\n\t\t\t\t}\n\t\t\t\tif (options?.onStreamEvent) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait options.onStreamEvent(event);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (error) {\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\t\t\tthis.log(`onStreamEvent failed: ${message}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait this.handleStreamEvent(event, async (text: string) => {\n\t\t\t\t\tconst next = text || '';\n\t\t\t\t\tif (!next) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst delta = next.startsWith(lastText) ? next.slice(lastText.length) : next;\n\t\t\t\t\tif (delta) {\n\t\t\t\t\t\tthis.logStreamText(delta);\n\t\t\t\t\t\tif (options?.onStreamText) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait options.onStreamText(delta, next);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (error) {\n\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\t\t\t\t\tthis.log(`onStreamText failed: ${message}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tlastText = next;\n\t\t\t\t\tfinalResponse = next;\n\t\t\t\t});\n\t\t\t\tif (event?.type === 'turn.failed') {\n\t\t\t\t\tthrow new Error(event.error?.message || 'AI run failed.');\n\t\t\t\t}\n\t\t\t\tif (event?.type === 'error') {\n\t\t\t\t\tthrow new Error(event.message || 'AI stream error.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (error) {\n\t\t\tif (controller?.signal?.aborted) {\n\t\t\t\tconst idleForMs = Date.now() - lastStreamActivityAt;\n\t\t\t\tif (streamIdleTimeoutMs > 0 && idleForMs >= streamIdleTimeoutMs) {\n\t\t\t\t\tthis.log(`runStreamed idle timed out (durationMs=${Date.now() - startedAt}, idleForMs=${idleForMs})`);\n\t\t\t\t\tthrow new Error(`AI stream stalled with no activity for ${idleForMs}ms.`);\n\t\t\t\t}\n\t\t\t\tthis.log(`runStreamed timed out (durationMs=${Date.now() - startedAt})`);\n\t\t\t\tthrow new Error('AI request timed out.');\n\t\t\t}\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`runStreamed failed (durationMs=${Date.now() - startedAt}): ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t\tfinally {\n\t\t\tif (timeoutId) {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t}\n\t\t\tif (idleTimeoutId) {\n\t\t\t\tclearInterval(idleTimeoutId);\n\t\t\t}\n\t\t}\n\t\tif (!finalResponse) {\n\t\t\tthrow new Error('AI returned no completion content.');\n\t\t}\n\t\tawait this.emitUsageSummary(options, usageSummary);\n\t\tthis.log(`runStreamed complete (contentLength=${finalResponse.length}, durationMs=${Date.now() - startedAt})`);\n\t\treturn finalResponse.trim();\n\t}\n\n\tprivate normalizeStreamIdleTimeoutMs(value: any): number {\n\t\tconst parsed = Number(value || 0);\n\t\tif (!Number.isFinite(parsed) || parsed < 60_000) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn Math.floor(parsed);\n\t}\n\n\tprivate async runOnce(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tconst startedAt = Date.now();\n\t\tthis.log(`runOnce start (promptLength=${prompt.length})`);\n\t\ttry {\n\t\t\tconst thread = await this.startThread(options?.threadOptions, options?.threadKey, options?.reuseThread);\n\t\t\tconst runPromise = thread.run(prompt);\n\t\t\tconst timeoutMs = options?.timeoutMs ?? this.defaultTimeoutMs;\n\t\t\tthis.log(`runOnce awaiting result (timeoutMs=${timeoutMs})`);\n\t\t\tconst result: any = await this.withTimeout(runPromise, timeoutMs);\n\t\t\tconst content = this.extractContent(result);\n\t\t\tif (!content) {\n\t\t\t\tthrow new Error('AI returned no completion content.');\n\t\t\t}\n\t\t\tawait this.emitUsageSummary(options, this.normalizeUsageSummary(result?.usage));\n\t\t\tthis.log(`runOnce complete (contentLength=${content.length}, durationMs=${Date.now() - startedAt})`);\n\t\t\treturn content;\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`runOnce failed (durationMs=${Date.now() - startedAt}): ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate async startThread(threadOptions?: CodexThreadOptions, threadKey?: string, reuseThread = true): Promise<any> {\n\t\tawait this.ensureCodex();\n\t\tconst mergedOptions = this.mergeThreadOptions(threadOptions);\n\t\tconst optionsKey = this.buildThreadOptionsKey(mergedOptions);\n\t\tconst effectiveModel = mergedOptions?.model || this.config.model || 'default';\n\t\tconst modelKey = this.normalizeOptionalString(effectiveModel).toLowerCase() || 'default';\n\t\tconst cacheKey = this.buildThreadCacheKey(threadKey, mergedOptions);\n\t\tconst explicitThreadKey = (threadKey || '').trim();\n\t\tconst hasExplicitThreadKey = explicitThreadKey.length > 0;\n\t\tif (reuseThread && cacheKey) {\n\t\t\tconst existing = this.threadCache.get(cacheKey);\n\t\t\tif (existing) {\n\t\t\t\tconst sameOptions = existing.optionsKey === optionsKey;\n\t\t\t\tconst sameModel = existing.modelKey === modelKey;\n\t\t\t\tif (sameOptions || (hasExplicitThreadKey && sameModel)) {\n\t\t\t\t\tif (hasExplicitThreadKey && existing.optionsKey !== optionsKey) {\n\t\t\t\t\t\tthis.log(`startThread reuse explicit key (${cacheKey}) despite option change`);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.log(`startThread reuse (${cacheKey})`);\n\t\t\t\t\t}\n\t\t\t\t\treturn existing.thread;\n\t\t\t\t}\n\t\t\t\tif (hasExplicitThreadKey && !sameModel) {\n\t\t\t\t\tthis.log(`startThread explicit key (${cacheKey}) model changed (${existing.modelKey} -> ${modelKey}); creating new thread`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.log(`startThread (model=${effectiveModel})`);\n\t\tif (mergedOptions?.model) {\n\t\t\tthis.log(`startThread options: ${this.formatThreadOptions(mergedOptions)}`);\n\t\t\tconst thread = this.codex.startThread(mergedOptions);\n\t\t\tthis.log('startThread created with model override');\n\t\t\tif (cacheKey) {\n\t\t\t\tthis.threadCache.set(cacheKey, { thread, optionsKey, modelKey });\n\t\t\t}\n\t\t\treturn thread;\n\t\t}\n\t\tif (mergedOptions && Object.keys(mergedOptions).length) {\n\t\t\tthis.log(`startThread options: ${this.formatThreadOptions(mergedOptions)}`);\n\t\t}\n\t\tconst thread = this.codex.startThread(mergedOptions);\n\t\tthis.log('startThread created');\n\t\tif (cacheKey) {\n\t\t\tthis.threadCache.set(cacheKey, { thread, optionsKey, modelKey });\n\t\t}\n\t\treturn thread;\n\t}\n\n\tprivate extractContent(result: any): string {\n\t\tif (!result) {\n\t\t\treturn '';\n\t\t}\n\t\tif (typeof result.finalResponse === 'string') {\n\t\t\treturn result.finalResponse.trim();\n\t\t}\n\t\tif (typeof result === 'string') {\n\t\t\treturn result.trim();\n\t\t}\n\t\tif (Array.isArray(result.items)) {\n\t\t\tconst lastMessage = [...result.items].reverse().find((item: any) => item?.type === 'agent_message' && typeof item.text === 'string');\n\t\t\tif (lastMessage?.text) {\n\t\t\t\treturn lastMessage.text.trim();\n\t\t\t}\n\t\t}\n\t\tif (typeof result.output_text === 'string') {\n\t\t\treturn result.output_text.trim();\n\t\t}\n\t\tif (typeof result.outputText === 'string') {\n\t\t\treturn result.outputText.trim();\n\t\t}\n\t\tif (typeof result.content === 'string') {\n\t\t\treturn result.content.trim();\n\t\t}\n\t\tif (typeof result.text === 'string') {\n\t\t\treturn result.text.trim();\n\t\t}\n\t\tif (Array.isArray(result.content)) {\n\t\t\tconst text = result.content\n\t\t\t\t.map((part: any) => this.extractPartText(part))\n\t\t\t\t.join('')\n\t\t\t\t.trim();\n\t\t\tif (text) {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t}\n\t\tif (Array.isArray(result.output)) {\n\t\t\tconst text = result.output\n\t\t\t\t.map((item: any) => {\n\t\t\t\t\tif (!item) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof item === 'string') {\n\t\t\t\t\t\treturn item;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof item.text === 'string') {\n\t\t\t\t\t\treturn item.text;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof item.content === 'string') {\n\t\t\t\t\t\treturn item.content;\n\t\t\t\t\t}\n\t\t\t\t\tif (Array.isArray(item.content)) {\n\t\t\t\t\t\treturn item.content.map((part: any) => this.extractPartText(part)).join('');\n\t\t\t\t\t}\n\t\t\t\t\treturn '';\n\t\t\t\t})\n\t\t\t\t.join('')\n\t\t\t\t.trim();\n\t\t\tif (text) {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t}\n\t\treturn '';\n\t}\n\n\tprivate async handleStreamEvent(event: any, onAgentMessage: AgentMessageHandler): Promise<void> {\n\t\tif (!event || !event.type) {\n\t\t\treturn;\n\t\t}\n\t\tswitch (event.type) {\n\t\t\tcase 'thread.started':\n\t\t\t\tthis.log(`stream thread.started (id=${event.thread_id || 'unknown'})`);\n\t\t\t\tbreak;\n\t\t\tcase 'turn.started':\n\t\t\t\tthis.log('stream turn.started');\n\t\t\t\tbreak;\n\t\t\tcase 'turn.completed':\n\t\t\t\tthis.log('stream turn.completed');\n\t\t\t\tbreak;\n\t\t\tcase 'item.started':\n\t\t\tcase 'item.updated':\n\t\t\tcase 'item.completed':\n\t\t\t\tawait this.handleStreamItem(event.item, onAgentMessage);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate normalizeUsageSummary(raw: any): CodexUsageSummary | null {\n\t\tif (!raw || typeof raw !== 'object') {\n\t\t\treturn null;\n\t\t}\n\t\tconst inputTokens = this.normalizeUsageToken(raw.input_tokens ?? raw.inputTokens);\n\t\tconst cachedInputTokens = this.normalizeUsageToken(raw.cached_input_tokens ?? raw.cachedInputTokens);\n\t\tconst outputTokens = this.normalizeUsageToken(raw.output_tokens ?? raw.outputTokens);\n\t\tif (inputTokens <= 0 && cachedInputTokens <= 0 && outputTokens <= 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn {\n\t\t\tinputTokens,\n\t\t\tcachedInputTokens,\n\t\t\toutputTokens\n\t\t};\n\t}\n\n\tprivate normalizeUsageToken(value: any): number {\n\t\tconst parsed = Number(value);\n\t\tif (!Number.isFinite(parsed) || parsed <= 0) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn Math.floor(parsed);\n\t}\n\n\tprivate async emitUsageSummary(options: CodexRunOptions | undefined, usage: CodexUsageSummary | null): Promise<void> {\n\t\tif (!options?.onUsage) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait options.onUsage(usage);\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`onUsage failed: ${message}`);\n\t\t}\n\t}\n\n\tprivate async handleStreamItem(item: any, onAgentMessage: AgentMessageHandler): Promise<void> {\n\t\tif (!item || !item.type) {\n\t\t\treturn;\n\t\t}\n\t\tswitch (item.type) {\n\t\t\tcase 'agent_message':\n\t\t\t\tawait onAgentMessage(item.text || '');\n\t\t\t\tbreak;\n\t\t\tcase 'command_execution':\n\t\t\t\tif (item.command) {\n\t\t\t\t\tthis.log(`stream command: ${item.command} (${item.status || 'unknown'})`);\n\t\t\t\t}\n\t\t\t\tif (item.aggregated_output) {\n\t\t\t\t\tconst output = item.aggregated_output.length > 800\n\t\t\t\t\t\t? `${item.aggregated_output.slice(0, 800)}...`\n\t\t\t\t\t\t: item.aggregated_output;\n\t\t\t\t\tthis.log(`stream command output: ${output}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'file_change':\n\t\t\t\tif (Array.isArray(item.changes) && item.changes.length) {\n\t\t\t\t\tconst summary = item.changes.map((change: any) => `${change.kind}:${change.path}`).join(', ');\n\t\t\t\t\tthis.log(`stream file_change (${item.status || 'unknown'}): ${summary}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'mcp_tool_call':\n\t\t\t\tif (item.tool) {\n\t\t\t\t\tthis.log(`stream tool_call: ${item.tool} (${item.status || 'unknown'})`);\n\t\t\t\t}\n\t\t\t\tif (item.error?.message) {\n\t\t\t\t\tthis.log(`stream tool_call error: ${item.error.message}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'web_search':\n\t\t\t\tif (item.query) {\n\t\t\t\t\tthis.log(`stream web_search: ${item.query}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'todo_list':\n\t\t\t\tif (Array.isArray(item.items)) {\n\t\t\t\t\tconst total = item.items.length;\n\t\t\t\t\tconst done = item.items.filter((entry: any) => entry?.completed).length;\n\t\t\t\t\tthis.log(`stream todo_list: ${done}/${total} completed`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'reasoning':\n\t\t\t\tif (item.text) {\n\t\t\t\t\tconst snippet = item.text.length > 200 ? `${item.text.slice(0, 200)}...` : item.text;\n\t\t\t\t\tthis.log(`stream reasoning: ${snippet}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'error':\n\t\t\t\tif (item.message) {\n\t\t\t\t\tthis.log(`stream error: ${item.message}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate logStreamText(text: string): void {\n\t\tif (!this.debugEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tconst lines = text.split(/\\r?\\n/);\n\t\tfor (const line of lines) {\n\t\t\tthis.log(`stream: ${line}`);\n\t\t}\n\t}\n\n\tprivate extractPartText(part: any): string {\n\t\tif (!part) {\n\t\t\treturn '';\n\t\t}\n\t\tif (typeof part === 'string') {\n\t\t\treturn part;\n\t\t}\n\t\tif (typeof part.text === 'string') {\n\t\t\treturn part.text;\n\t\t}\n\t\tif (typeof part.content === 'string') {\n\t\t\treturn part.content;\n\t\t}\n\t\treturn '';\n\t}\n\n\tprivate async withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {\n\t\tlet done = false;\n\t\tconst startedAt = Date.now();\n\t\tconst heartbeatMs = Math.max(10000, Math.min(30000, Math.floor(timeoutMs / 4)));\n\t\tconst timeoutPromise = (async (): Promise<T> => {\n\t\t\twhile (!done) {\n\t\t\t\tconst elapsed = Date.now() - startedAt;\n\t\t\t\tif (elapsed >= timeoutMs) {\n\t\t\t\t\tthrow new Error('AI request timed out.');\n\t\t\t\t}\n\t\t\t\tconst remaining = timeoutMs - elapsed;\n\t\t\t\tawait sleepTimeout(Math.min(heartbeatMs, remaining));\n\t\t\t\tif (done) {\n\t\t\t\t\treturn await promise;\n\t\t\t\t}\n\t\t\t\tconst currentElapsed = Date.now() - startedAt;\n\t\t\t\tif (currentElapsed >= timeoutMs) {\n\t\t\t\t\tthrow new Error('AI request timed out.');\n\t\t\t\t}\n\t\t\t\tconst currentRemaining = Math.max(0, timeoutMs - currentElapsed);\n\t\t\t\tthis.log(`runOnce waiting (elapsedMs=${currentElapsed}, remainingMs=${currentRemaining})`);\n\t\t\t}\n\t\t\treturn await promise;\n\t\t})();\n\t\ttry {\n\t\t\treturn await Promise.race([promise, timeoutPromise]);\n\t\t}\n\t\tfinally {\n\t\t\tdone = true;\n\t\t}\n\t}\n\n\tprivate normalizeRetryCount(value?: number): number {\n\t\tif (typeof value !== 'number' || Number.isNaN(value)) {\n\t\t\treturn 2;\n\t\t}\n\t\treturn Math.max(0, Math.floor(value));\n\t}\n\n\tprivate normalizeRetryDelay(value?: number): number {\n\t\tif (typeof value !== 'number' || Number.isNaN(value)) {\n\t\t\treturn 500;\n\t\t}\n\t\treturn Math.max(100, Math.floor(value));\n\t}\n\n\tprivate resolveModelSequence(options?: CodexRunOptions): string[] {\n\t\tconst primary = this.normalizeOptionalString(options?.threadOptions?.model || this.config.model);\n\t\tconst fallbackModels = this.collectFallbackModels(options?.fallbackModels);\n\t\tconst sequence: string[] = [];\n\t\tconst push = (value: any) => {\n\t\t\tconst normalized = this.normalizeOptionalString(value);\n\t\t\tif (!normalized || sequence.includes(normalized)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsequence.push(normalized);\n\t\t};\n\t\tconst preferredFallback = this.getModelFallbackPreference(primary);\n\t\tif (preferredFallback) {\n\t\t\tpush(preferredFallback);\n\t\t\tthis.log(`sticky model fallback active: ${primary} -> ${preferredFallback}`);\n\t\t}\n\t\tpush(primary);\n\t\tfallbackModels.forEach(push);\n\t\tif (!sequence.length) {\n\t\t\tsequence.push('');\n\t\t}\n\t\treturn sequence;\n\t}\n\n\tprivate collectFallbackModels(runFallbackModels?: string[]): string[] {\n\t\tconst models: string[] = [];\n\t\tconst push = (value: any) => {\n\t\t\tconst normalized = this.normalizeOptionalString(value);\n\t\t\tif (!normalized || models.includes(normalized)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmodels.push(normalized);\n\t\t};\n\t\tthis.normalizeModelList(runFallbackModels).forEach(push);\n\t\tthis.normalizeModelList(this.config.fallbackModels).forEach(push);\n\t\tpush(this.config.fallbackModel);\n\t\tthis.normalizeModelList(process.env.AI_ASSISTANT_CODEX_FALLBACK_MODELS).forEach(push);\n\t\tpush(process.env.AI_ASSISTANT_CODEX_FALLBACK_MODEL);\n\t\tthis.normalizeModelList(process.env.AI_TERMINAL_CODEX_FALLBACK_MODELS).forEach(push);\n\t\tpush(process.env.AI_TERMINAL_CODEX_FALLBACK_MODEL);\n\t\tthis.normalizeModelList(process.env.AI_DASHBOARD_CODEX_FALLBACK_MODELS).forEach(push);\n\t\tpush(process.env.AI_DASHBOARD_CODEX_FALLBACK_MODEL);\n\t\tconst primaryModel = this.normalizeOptionalString(\n\t\t\tthis.config.model\n\t\t\t|| runFallbackModels?.[0]\n\t\t\t|| ''\n\t\t);\n\t\tif (/^gpt-5(?:\\.\\d+)?-codex$/i.test(primaryModel)) {\n\t\t\tpush('gpt-5-codex');\n\t\t}\n\t\tif (/^gpt-5(?:-codex|\\.\\d+-codex)$/i.test(primaryModel)) {\n\t\t\tpush('gpt-5.5');\n\t\t}\n\t\treturn models;\n\t}\n\n\tprivate normalizeModelList(value: any): string[] {\n\t\tif (Array.isArray(value)) {\n\t\t\treturn value\n\t\t\t\t.map(entry => this.normalizeOptionalString(entry))\n\t\t\t\t.filter(Boolean);\n\t\t}\n\t\tconst raw = this.normalizeOptionalString(value);\n\t\tif (!raw) {\n\t\t\treturn [];\n\t\t}\n\t\treturn raw\n\t\t\t.split(',')\n\t\t\t.map(entry => this.normalizeOptionalString(entry))\n\t\t\t.filter(Boolean);\n\t}\n\n\tprivate applyModelOverride(options: CodexRunOptions | undefined, model: string): CodexRunOptions {\n\t\tconst nextThreadOptions: CodexThreadOptions = {\n\t\t\t...(options?.threadOptions || {})\n\t\t};\n\t\tif (model) {\n\t\t\tnextThreadOptions.model = model;\n\t\t}\n\t\telse {\n\t\t\tdelete nextThreadOptions.model;\n\t\t}\n\t\treturn {\n\t\t\t...(options || {}),\n\t\t\tthreadOptions: nextThreadOptions\n\t\t};\n\t}\n\n\tprivate isModelAvailabilityError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\tconst normalized = message.toLowerCase();\n\t\tif (!normalized.includes('model')) {\n\t\t\treturn false;\n\t\t}\n\t\tif (/does not exist|not found|unknown model|invalid model|unsupported model|model_not_found|no such model/.test(normalized)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (/not available|unavailable|not enabled|not allowed|do not have access|don't have access|insufficient permissions/.test(normalized)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn /404/.test(normalized) && /model/.test(normalized);\n\t}\n\n\tprivate isRetryableError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\tif (/AI returned no completion content|Codex returned no completion content/i.test(message)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.isCodexEnvironmentError(error)) {\n\t\t\treturn true;\n\t\t}\n\t\tconst statusMatch = message.match(/\\\\b(429|5\\\\d{2})\\\\b/);\n\t\tif (statusMatch) {\n\t\t\treturn true;\n\t\t}\n\t\treturn /ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|fetch failed|timed out|timeout/i.test(message);\n\t}\n\n\tprivate isCodexEnvironmentError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\treturn /error finding codex home|could not update path: no such file or directory/i.test(message);\n\t}\n\n\tprivate recoverCodexEnvironment(error: unknown): void {\n\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\tthis.log(`recovering codex environment after error: ${message}`);\n\t\tthis.threadCache.clear();\n\t\tthis.codex = null;\n\t\tthis.codexInit = null;\n\t\tthis.zDotDir = null;\n\t}\n\n\tprivate shouldApplyProcessCwdFallback(error: unknown, options?: CodexRunOptions): boolean {\n\t\tconst workingDirectory = this.resolveProcessWorkingDirectory(options);\n\t\tif (!workingDirectory) {\n\t\t\treturn false;\n\t\t}\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\treturn /no such file or directory \\(os error 2\\)/i.test(message);\n\t}\n\n\tprivate resolveProcessWorkingDirectory(options?: CodexRunOptions): string {\n\t\treturn this.normalizeOptionalString(options?.processWorkingDirectory || options?.threadOptions?.workingDirectory);\n\t}\n\n\tprivate applyProcessCwdFallback(options?: CodexRunOptions): CodexRunOptions {\n\t\tconst nextThreadOptions: CodexThreadOptions = {\n\t\t\t...(options?.threadOptions || {})\n\t\t};\n\t\tdelete nextThreadOptions.workingDirectory;\n\t\treturn {\n\t\t\t...(options || {}),\n\t\t\tthreadOptions: nextThreadOptions\n\t\t};\n\t}\n\n\tprivate async withProcessWorkingDirectoryFallback<T>(workingDirectory: string, runner: () => Promise<T>): Promise<T> {\n\t\tconst normalizedWorkingDirectory = this.normalizeOptionalString(workingDirectory);\n\t\tif (!normalizedWorkingDirectory) {\n\t\t\treturn await runner();\n\t\t}\n\n\t\twhile (CodexClient.cwdFallbackRunning) {\n\t\t\tawait this.sleep(50);\n\t\t}\n\t\tCodexClient.cwdFallbackRunning = true;\n\n\t\tconst originalCwd = process.cwd();\n\t\ttry {\n\t\t\tprocess.chdir(normalizedWorkingDirectory);\n\t\t\tthis.log(`running Codex fallback from process cwd ${normalizedWorkingDirectory}`);\n\t\t\treturn await runner();\n\t\t}\n\t\tfinally {\n\t\t\ttry {\n\t\t\t\tprocess.chdir(originalCwd);\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\tthis.log(`failed to restore process cwd to ${originalCwd}: ${message}`);\n\t\t\t}\n\t\t\tCodexClient.cwdFallbackRunning = false;\n\t\t}\n\t}\n\n\tprivate normalizeOptionalString(value: any): string {\n\t\treturn typeof value === 'string' ? value.trim() : '';\n\t}\n\n\tprivate resolveModelUnavailableTtlMs(): number {\n\t\tconst raw = Number(\n\t\t\tprocess.env.AI_DASHBOARD_CODEX_MODEL_UNAVAILABLE_TTL_MS\n\t\t\t|| process.env.AI_ASSISTANT_CODEX_MODEL_UNAVAILABLE_TTL_MS\n\t\t);\n\t\tif (Number.isFinite(raw) && raw >= CodexClient.MIN_MODEL_UNAVAILABLE_TTL_MS) {\n\t\t\treturn Math.floor(raw);\n\t\t}\n\t\treturn CodexClient.DEFAULT_MODEL_UNAVAILABLE_TTL_MS;\n\t}\n\n\tprivate async ensureModelFallbackPreferencesLoaded(): Promise<void> {\n\t\tif (CodexClient.modelFallbackPreferencesLoaded) {\n\t\t\tthis.pruneModelFallbackPreferences();\n\t\t\treturn;\n\t\t}\n\t\tif (CodexClient.modelFallbackPreferencesLoadPromise !== null) {\n\t\t\tawait CodexClient.modelFallbackPreferencesLoadPromise;\n\t\t\tthis.pruneModelFallbackPreferences();\n\t\t\treturn;\n\t\t}\n\t\tCodexClient.modelFallbackPreferencesLoadPromise = (async () => {\n\t\t\ttry {\n\t\t\t\tconst raw = await fs.readFile(CodexClient.MODEL_UNAVAILABLE_FALLBACK_FILE, 'utf8');\n\t\t\t\tconst parsed = JSON.parse(raw);\n\t\t\t\tif (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tObject.entries(parsed).forEach(([model, entry]) => {\n\t\t\t\t\tconst key = this.normalizeOptionalString(model);\n\t\t\t\t\tif (!key) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst fallbackModel = this.normalizeOptionalString((entry as any)?.fallbackModel);\n\t\t\t\t\tconst expiresAt = Number((entry as any)?.expiresAt);\n\t\t\t\t\tconst updatedAt = Number((entry as any)?.updatedAt);\n\t\t\t\t\tif (!fallbackModel || !Number.isFinite(expiresAt) || expiresAt <= Date.now()) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tCodexClient.modelFallbackPreferences.set(key, {\n\t\t\t\t\t\tfallbackModel,\n\t\t\t\t\t\texpiresAt: Math.floor(expiresAt),\n\t\t\t\t\t\tupdatedAt: Number.isFinite(updatedAt) ? Math.floor(updatedAt) : Date.now()\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t// Ignore cache load errors.\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tCodexClient.modelFallbackPreferencesLoaded = true;\n\t\t\t\tCodexClient.modelFallbackPreferencesLoadPromise = null;\n\t\t\t}\n\t\t})();\n\t\tawait CodexClient.modelFallbackPreferencesLoadPromise;\n\t\tthis.pruneModelFallbackPreferences();\n\t}\n\n\tprivate pruneModelFallbackPreferences(now = Date.now()): void {\n\t\tArray.from(CodexClient.modelFallbackPreferences.entries()).forEach(([model, entry]) => {\n\t\t\tif (!entry || !Number.isFinite(entry.expiresAt) || entry.expiresAt <= now) {\n\t\t\t\tCodexClient.modelFallbackPreferences.delete(model);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate getModelFallbackPreference(model: string): string {\n\t\tconst normalizedModel = this.normalizeOptionalString(model);\n\t\tif (!normalizedModel) {\n\t\t\treturn '';\n\t\t}\n\t\tthis.pruneModelFallbackPreferences();\n\t\tconst entry = CodexClient.modelFallbackPreferences.get(normalizedModel);\n\t\tif (!entry || entry.expiresAt <= Date.now()) {\n\t\t\tif (entry) {\n\t\t\t\tCodexClient.modelFallbackPreferences.delete(normalizedModel);\n\t\t\t}\n\t\t\treturn '';\n\t\t}\n\t\treturn entry.fallbackModel;\n\t}\n\n\tprivate async rememberModelFallbackPreference(model: string, fallbackModel: string): Promise<void> {\n\t\tconst normalizedModel = this.normalizeOptionalString(model);\n\t\tconst normalizedFallback = this.normalizeOptionalString(fallbackModel);\n\t\tif (!normalizedModel || !normalizedFallback || normalizedModel === normalizedFallback) {\n\t\t\treturn;\n\t\t}\n\t\tconst now = Date.now();\n\t\tCodexClient.modelFallbackPreferences.set(normalizedModel, {\n\t\t\tfallbackModel: normalizedFallback,\n\t\t\texpiresAt: now + this.modelUnavailableTtlMs,\n\t\t\tupdatedAt: now\n\t\t});\n\t\tthis.pruneModelFallbackPreferences(now);\n\t\tawait this.persistModelFallbackPreferences();\n\t}\n\n\tprivate async clearModelFallbackPreference(model: string): Promise<void> {\n\t\tconst normalizedModel = this.normalizeOptionalString(model);\n\t\tif (!normalizedModel) {\n\t\t\treturn;\n\t\t}\n\t\tif (!CodexClient.modelFallbackPreferences.has(normalizedModel)) {\n\t\t\treturn;\n\t\t}\n\t\tCodexClient.modelFallbackPreferences.delete(normalizedModel);\n\t\tawait this.persistModelFallbackPreferences();\n\t}\n\n\tprivate async persistModelFallbackPreferences(): Promise<void> {\n\t\tthis.pruneModelFallbackPreferences();\n\t\tif (!CodexClient.modelFallbackPreferences.size) {\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(CodexClient.MODEL_UNAVAILABLE_FALLBACK_FILE);\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t// Ignore file cleanup errors.\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst serialized: Record<string, CodexModelFallbackPreference> = {};\n\t\tCodexClient.modelFallbackPreferences.forEach((entry, model) => {\n\t\t\tserialized[model] = entry;\n\t\t});\n\t\ttry {\n\t\t\tawait fs.writeFile(CodexClient.MODEL_UNAVAILABLE_FALLBACK_FILE, JSON.stringify(serialized), 'utf8');\n\t\t}\n\t\tcatch {\n\t\t\t// Ignore cache persistence errors.\n\t\t}\n\t}\n\n\tprivate async sleep(ms: number): Promise<void> {\n\t\tawait sleepTimeout(ms);\n\t}\n\n\tprivate async ensureCodex(): Promise<void> {\n\t\tif (this.codex) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.codexInit !== null) {\n\t\t\tawait this.codexInit;\n\t\t\treturn;\n\t\t}\n\t\tthis.codexInit = (async () => {\n\t\t\tthis.log('Loading AI SDK module...');\n\t\t\tconst importer = new Function('specifier', 'return import(specifier)') as DynamicImport;\n\t\t\tconst mod = await importer('@openai/codex-sdk');\n\t\t\tconst CodexCtor = mod?.Codex || mod?.default?.Codex || mod?.default || mod;\n\t\t\tif (!CodexCtor) {\n\t\t\t\tthrow new Error('AI SDK export not found.');\n\t\t\t}\n\t\t\tthis.log('AI SDK module loaded.');\n\t\t\tconst env = await this.buildCodexEnv();\n\t\t\tthis.codex = new CodexCtor({\n\t\t\t\tapiKey: this.config.apiKey,\n\t\t\t\tbaseUrl: this.config.baseUrl,\n\t\t\t\tmodel: this.config.model,\n\t\t\t\tenv\n\t\t\t});\n\t\t\tthis.log('AI client initialized.');\n\t\t})();\n\t\tawait this.codexInit;\n\t}\n\n\tprivate log(message: string): void {\n\t\tif (!this.debugEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tconsole.log(`[AI-Dashboard][AI] ${message}`);\n\t}\n\n\tprivate resolveDefaultTimeoutMs(): number {\n\t\tconst raw = Number(process.env.AI_DASHBOARD_CODEX_TIMEOUT_MS || process.env.AI_DASHBOARD_AGENT_TIMEOUT_MS);\n\t\tif (Number.isFinite(raw) && raw > 0) {\n\t\t\treturn Math.floor(raw);\n\t\t}\n\t\treturn 600000;\n\t}\n\n\tprivate resolveStreamEnabled(): boolean {\n\t\tconst raw = (process.env.AI_DASHBOARD_CODEX_STREAM || '').trim().toLowerCase();\n\t\tif (!raw) {\n\t\t\treturn this.debugEnabled;\n\t\t}\n\t\tif (['true', '1', 'yes', 'y', 'on'].includes(raw)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (['false', '0', 'no', 'n', 'off'].includes(raw)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.debugEnabled;\n\t}\n\n\tprivate resolveCleanZdotdirEnabled(): boolean {\n\t\tconst raw = (process.env.AI_DASHBOARD_CODEX_CLEAN_ZDOTDIR ?? '').trim().toLowerCase();\n\t\tif (!raw) {\n\t\t\treturn true;\n\t\t}\n\t\tif (['false', '0', 'no', 'n', 'off'].includes(raw)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (['true', '1', 'yes', 'y', 'on'].includes(raw)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate async buildCodexEnv(): Promise<Record<string, string>> {\n\t\tconst env: Record<string, string> = {};\n\t\tfor (const [key, value] of Object.entries(process.env)) {\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tenv[key] = value;\n\t\t\t}\n\t\t}\n\t\tif (!this.normalizeOptionalString(env.HOME)) {\n\t\t\tconst fallbackHome = this.normalizeOptionalString(process.env.HOME || os.homedir());\n\t\t\tif (fallbackHome) {\n\t\t\t\tenv.HOME = fallbackHome;\n\t\t\t}\n\t\t}\n\t\tawait this.ensureCodexHome(env);\n\t\tif (this.cleanZdotdirEnabled) {\n\t\t\tenv.ZDOTDIR = await this.ensureZdotdir();\n\t\t}\n\t\treturn env;\n\t}\n\n\tprivate async ensureCodexHome(env: Record<string, string>): Promise<void> {\n\t\tconst current = this.normalizeOptionalString(env.CODEX_HOME || process.env.CODEX_HOME);\n\t\tconst homeRoot = this.normalizeOptionalString(env.HOME || process.env.HOME || os.homedir());\n\t\tconst primary = current || (homeRoot ? path.join(homeRoot, '.codex') : path.join(os.tmpdir(), 'resolveio-codex-home'));\n\t\ttry {\n\t\t\tawait fs.mkdir(path.join(primary, 'sessions'), { recursive: true });\n\t\t\tenv.CODEX_HOME = primary;\n\t\t\tprocess.env.CODEX_HOME = primary;\n\t\t\treturn;\n\t\t}\n\t\tcatch {\n\t\t\tconst fallback = path.join(os.tmpdir(), 'resolveio-codex-home');\n\t\t\tawait fs.mkdir(path.join(fallback, 'sessions'), { recursive: true });\n\t\t\tenv.CODEX_HOME = fallback;\n\t\t\tprocess.env.CODEX_HOME = fallback;\n\t\t}\n\t}\n\n\tprivate async ensureZdotdir(): Promise<string> {\n\t\tif (this.zDotDir) {\n\t\t\treturn this.zDotDir;\n\t\t}\n\t\tconst override = (process.env.AI_DASHBOARD_CODEX_ZDOTDIR || '').trim();\n\t\tconst dir = override || path.join(os.tmpdir(), 'codex-zdotdir');\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait Promise.allSettled([\n\t\t\tfs.writeFile(path.join(dir, '.zshrc'), '', { flag: 'a' }),\n\t\t\tfs.writeFile(path.join(dir, '.zprofile'), '', { flag: 'a' })\n\t\t]);\n\t\tthis.zDotDir = dir;\n\t\treturn dir;\n\t}\n\n\tprivate resolvePingEnabled(): boolean {\n\t\treturn this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_PING, false);\n\t}\n\n\tprivate resolvePingTimeoutMs(): number {\n\t\tconst raw = Number(process.env.AI_DASHBOARD_CODEX_PING_TIMEOUT_MS);\n\t\tif (Number.isFinite(raw) && raw > 0) {\n\t\t\treturn Math.floor(raw);\n\t\t}\n\t\treturn 10000;\n\t}\n\n\tprivate resolveDefaultThreadOptions(): CodexThreadOptions {\n\t\tconst approvalPolicy = this.normalizeApprovalPolicy(process.env.AI_DASHBOARD_CODEX_APPROVAL_POLICY);\n\t\tconst sandboxMode = this.normalizeSandboxMode(process.env.AI_DASHBOARD_CODEX_SANDBOX_MODE, 'workspace-write');\n\t\tconst skipGitRepoCheck = this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_SKIP_GIT_CHECK, true);\n\t\tconst webSearchMode = this.normalizeWebSearchMode(process.env.AI_DASHBOARD_CODEX_WEB_SEARCH_MODE);\n\t\tconst webSearchEnabled = this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_WEB_SEARCH_ENABLED, false);\n\t\tconst networkAccessEnabled = this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_NETWORK_ACCESS_ENABLED, false);\n\t\tconst modelReasoningEffort = this.normalizeModelReasoningEffort(process.env.AI_DASHBOARD_CODEX_REASONING_EFFORT);\n\t\treturn {\n\t\t\tmodel: this.config.model,\n\t\t\tapprovalPolicy,\n\t\t\tsandboxMode,\n\t\t\tskipGitRepoCheck,\n\t\t\twebSearchMode,\n\t\t\twebSearchEnabled,\n\t\t\tnetworkAccessEnabled,\n\t\t\tmodelReasoningEffort\n\t\t};\n\t}\n\n\tprivate mergeThreadOptions(overrides?: CodexThreadOptions): CodexThreadOptions | undefined {\n\t\tconst merged: CodexThreadOptions = {\n\t\t\t...this.defaultThreadOptions,\n\t\t\t...(overrides || {})\n\t\t};\n\t\tconst effectiveModel = this.normalizeOptionalString(merged.model || this.config.model);\n\t\tconst normalizedEffort = this.normalizeModelReasoningEffortForModel(effectiveModel, merged.modelReasoningEffort);\n\t\tif (normalizedEffort && normalizedEffort !== merged.modelReasoningEffort) {\n\t\t\tthis.log(`normalized reasoning effort for model=${effectiveModel || 'default'}: ${merged.modelReasoningEffort} -> ${normalizedEffort}`);\n\t\t\tmerged.modelReasoningEffort = normalizedEffort;\n\t\t}\n\t\tconst cleaned = Object.entries(merged).reduce((acc, [key, value]) => {\n\t\t\tif (value === undefined || value === null || value === '') {\n\t\t\t\treturn acc;\n\t\t\t}\n\t\t\t(acc as any)[key] = value;\n\t\t\treturn acc;\n\t\t}, {} as CodexThreadOptions);\n\t\treturn Object.keys(cleaned).length ? cleaned : undefined;\n\t}\n\n\tprivate normalizeApprovalPolicy(value?: string): CodexThreadOptions['approvalPolicy'] {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'never' || normalized === 'on-request' || normalized === 'on-failure' || normalized === 'untrusted') {\n\t\t\treturn normalized as CodexThreadOptions['approvalPolicy'];\n\t\t}\n\t\treturn 'never';\n\t}\n\n\tprivate normalizeSandboxMode(value?: string, fallback: CodexThreadOptions['sandboxMode'] = 'read-only'): CodexThreadOptions['sandboxMode'] {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'read-only' || normalized === 'workspace-write' || normalized === 'danger-full-access') {\n\t\t\treturn normalized as CodexThreadOptions['sandboxMode'];\n\t\t}\n\t\treturn fallback;\n\t}\n\n\tprivate normalizeWebSearchMode(value?: string): CodexThreadOptions['webSearchMode'] | undefined {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'disabled' || normalized === 'cached' || normalized === 'live') {\n\t\t\treturn normalized as CodexThreadOptions['webSearchMode'];\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate normalizeModelReasoningEffort(value?: string): CodexThreadOptions['modelReasoningEffort'] | undefined {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'minimal' || normalized === 'none' || normalized === 'low' || normalized === 'medium' || normalized === 'high' || normalized === 'xhigh') {\n\t\t\treturn normalized as CodexThreadOptions['modelReasoningEffort'];\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate normalizeModelReasoningEffortForModel(\n\t\tmodel: string,\n\t\teffort?: CodexThreadOptions['modelReasoningEffort']\n\t): CodexThreadOptions['modelReasoningEffort'] | undefined {\n\t\tif (!effort) {\n\t\t\treturn effort;\n\t\t}\n\t\tconst normalizedModel = this.normalizeOptionalString(model).toLowerCase();\n\t\tif (effort === 'minimal' && (!normalizedModel || normalizedModel.startsWith('gpt-5') || normalizedModel.includes('codex'))) {\n\t\t\treturn 'low';\n\t\t}\n\t\treturn effort;\n\t}\n\n\tprivate normalizeBoolean(value: string | undefined, fallback: boolean): boolean {\n\t\tif (!value) {\n\t\t\treturn fallback;\n\t\t}\n\t\tconst normalized = value.trim().toLowerCase();\n\t\tif (['true', '1', 'yes', 'y', 'on'].includes(normalized)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (['false', '0', 'no', 'n', 'off'].includes(normalized)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn fallback;\n\t}\n\n\tprivate formatThreadOptions(options: CodexThreadOptions): string {\n\t\tconst summary: Record<string, string> = {};\n\t\tObject.entries(options).forEach(([key, value]) => {\n\t\t\tif (value === undefined || value === null) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsummary[key] = String(value);\n\t\t});\n\t\treturn JSON.stringify(summary);\n\t}\n\n\tprivate buildThreadOptionsKey(options?: CodexThreadOptions): string {\n\t\tif (!options) {\n\t\t\treturn '';\n\t\t}\n\t\tconst ordered: Record<string, string> = {};\n\t\tObject.keys(options)\n\t\t\t.sort()\n\t\t\t.forEach((key) => {\n\t\t\t\tconst value = (options as Record<string, unknown>)[key];\n\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tordered[key] = Array.isArray(value) ? JSON.stringify(value) : String(value);\n\t\t\t});\n\t\treturn JSON.stringify(ordered);\n\t}\n\n\tprivate buildThreadCacheKey(threadKey: string | undefined, options?: CodexThreadOptions): string | null {\n\t\tif (threadKey) {\n\t\t\treturn `thread:${threadKey}`;\n\t\t}\n\t\tconst model = options?.model || this.config.model;\n\t\tconst workingDirectory = options?.workingDirectory;\n\t\tif (!model && !workingDirectory) {\n\t\t\treturn null;\n\t\t}\n\t\treturn `thread:auto:${model || 'default'}:${workingDirectory || 'root'}`;\n\t}\n\n\tprivate isPingPrompt(prompt: string): boolean {\n\t\treturn prompt.trim() === CodexClient.PING_PROMPT;\n\t}\n\n\tprivate async runPing(threadOptions?: CodexThreadOptions): Promise<void> {\n\t\tthis.log(`runPing start (timeoutMs=${this.pingTimeoutMs})`);\n\t\ttry {\n\t\t\tconst content = await this.runOnce(CodexClient.PING_PROMPT, {\n\t\t\t\ttimeoutMs: this.pingTimeoutMs,\n\t\t\t\tthreadOptions,\n\t\t\t\treuseThread: false\n\t\t\t});\n\t\t\tconst trimmed = content.trim();\n\t\t\tconst preview = trimmed.length > 80 ? `${trimmed.slice(0, 80)}…` : trimmed;\n\t\t\tthis.log(`runPing response: ${preview}`);\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`runPing failed: ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../src/services/codex-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAoC;AACpC,uBAAyB;AACzB,2BAA6B;AAC7B,4CAA6D;AA2D7D;IAuBC,qBAAY,MAAmB;QAdvB,UAAK,GAAe,IAAI,CAAC;QACzB,cAAS,GAAyB,IAAI,CAAC;QAC9B,gBAAW,GAAG,IAAI,GAAG,EAAiE,CAAC;QACvF,iBAAY,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;QACtF,kBAAa,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5C,wBAAmB,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACjE,YAAO,GAAkB,IAAI,CAAC;QACrB,qBAAgB,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAClD,gBAAW,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxC,kBAAa,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5C,0BAAqB,GAAG,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAK5E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,C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gCAC3D,SAAS,EAAE,IAAI,CAAC,aAAa;gCAC7B,aAAa,eAAA;gCACb,WAAW,EAAE,KAAK;6BAClB,CAAC,EAAA;;wBAJI,OAAO,GAAG,SAId;wBACI,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;wBACzB,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,UAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,WAAG,CAAC,CAAC,CAAC,OAAO,CAAC;wBAC3E,IAAI,CAAC,GAAG,CAAC,4BAAqB,OAAO,CAAE,CAAC,CAAC;;;;wBAGnC,OAAO,GAAG,OAAK,YAAY,KAAK,CAAC,CAAC,CAAC,OAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAK,IAAI,eAAe,CAAC,CAAC;wBAC1F,IAAI,CAAC,GAAG,CAAC,0BAAmB,OAAO,CAAE,CAAC,CAAC;wBACvC,MAAM,OAAK,CAAC;;;;;KAEb;IA9oCuB,uBAAW,GAAG,YAAH,AAAe,CAAC;IAC3B,2CAA+B,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,sCAAsC,CAAhE,AAAiE,CAAC;IACjG,4CAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAjB,AAAqB,CAAC;IACtD,wCAA4B,GAAG,EAAE,GAAG,IAAR,AAAY,CAAC;IACzC,oCAAwB,GAAG,IAAI,GAAG,EAAV,AAAkD,CAAC;IACpF,0CAA8B,GAAG,KAAH,AAAQ,CAAC;IACvC,+CAAmC,GAAyB,IAAzB,AAA6B,CAAC;IACjE,8BAAkB,GAAG,KAAH,AAAQ,CAAC;IAwoC3C,kBAAC;CAhpCD,AAgpCC,IAAA;AAhpCY,kCAAW","file":"codex-client.js","sourcesContent":["import { promises as fs } from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { setTimeout as sleepTimeout } from 'timers/promises';\nexport interface CodexConfig {\n\tapiKey?: string;\n\tbaseUrl?: string;\n\tmodel?: string;\n\tfallbackModel?: string;\n\tfallbackModels?: string[];\n\tmaxRetries?: number;\n\tretryDelayMs?: number;\n}\n\n/* eslint-disable no-unused-vars -- Function type params are required for clarity. */\ntype StreamEventHandler = (event: any) => void | Promise<void>;\ntype StreamTextHandler = (delta: string, fullText: string) => void | Promise<void>;\ntype AgentMessageHandler = (text: string) => void | Promise<void>;\ntype UsageHandler = (usage: CodexUsageSummary | null) => void | Promise<void>;\ntype DynamicImport = (specifier: string) => Promise<any>;\n/* eslint-enable no-unused-vars */\n\ntype CodexModelFallbackPreference = {\n\tfallbackModel: string;\n\texpiresAt: number;\n\tupdatedAt: number;\n};\n\nexport interface CodexRunOptions {\n\ttimeoutMs?: number;\n\tstreamIdleTimeoutMs?: number;\n\tmaxRetries?: number;\n\tprocessWorkingDirectory?: string;\n\tthreadOptions?: CodexThreadOptions;\n\tthreadKey?: string;\n\treuseThread?: boolean;\n\tfallbackModels?: string[];\n\tfailOnStreamHandlerError?: boolean;\n\tonStreamEvent?: StreamEventHandler;\n\tonStreamText?: StreamTextHandler;\n\tonUsage?: UsageHandler;\n}\n\nexport interface CodexUsageSummary {\n\tinputTokens: number;\n\tcachedInputTokens: number;\n\toutputTokens: number;\n}\n\nexport type CodexThreadOptions = {\n\tmodel?: string;\n\tsandboxMode?: 'read-only' | 'workspace-write' | 'danger-full-access';\n\tworkingDirectory?: string;\n\tskipGitRepoCheck?: boolean;\n\tmodelReasoningEffort?: 'minimal' | 'none' | 'low' | 'medium' | 'high' | 'xhigh';\n\tnetworkAccessEnabled?: boolean;\n\twebSearchMode?: 'disabled' | 'cached' | 'live';\n\twebSearchEnabled?: boolean;\n\tapprovalPolicy?: 'never' | 'on-request' | 'on-failure' | 'untrusted';\n\tadditionalDirectories?: string[];\n};\n\nexport class CodexClient {\n\tprivate static readonly PING_PROMPT = \"Say 'pong'\";\n\tprivate static readonly MODEL_UNAVAILABLE_FALLBACK_FILE = path.join(os.tmpdir(), 'resolveio-codex-model-fallbacks.json');\n\tprivate static readonly DEFAULT_MODEL_UNAVAILABLE_TTL_MS = 6 * 60 * 60 * 1000;\n\tprivate static readonly MIN_MODEL_UNAVAILABLE_TTL_MS = 60 * 1000;\n\tprivate static readonly modelFallbackPreferences = new Map<string, CodexModelFallbackPreference>();\n\tprivate static modelFallbackPreferencesLoaded = false;\n\tprivate static modelFallbackPreferencesLoadPromise: Promise<void> | null = null;\n\tprivate static cwdFallbackRunning = false;\n\tprivate codex: any | null = null;\n\tprivate codexInit: Promise<void> | null = null;\n\tprivate readonly threadCache = new Map<string, { thread: any; optionsKey: string; modelKey: string }>();\n\tprivate readonly debugEnabled = (process.env.AI_DASHBOARD_DEBUG || '').trim().toLowerCase() === 'true';\n\tprivate readonly streamEnabled = this.resolveStreamEnabled();\n\tprivate readonly cleanZdotdirEnabled = this.resolveCleanZdotdirEnabled();\n\tprivate zDotDir: string | null = null;\n\tprivate readonly defaultTimeoutMs = this.resolveDefaultTimeoutMs();\n\tprivate readonly pingEnabled = this.resolvePingEnabled();\n\tprivate readonly pingTimeoutMs = this.resolvePingTimeoutMs();\n\tprivate readonly modelUnavailableTtlMs = this.resolveModelUnavailableTtlMs();\n\tprivate readonly config: CodexConfig;\n\tprivate readonly defaultThreadOptions: CodexThreadOptions;\n\n\tconstructor(config: CodexConfig) {\n\t\tthis.config = config;\n\t\tif (!this.config.apiKey) {\n\t\t\tthrow new Error('AI API key is required for AI client');\n\t\t}\n\t\tthis.defaultThreadOptions = this.resolveDefaultThreadOptions();\n\t}\n\n\tasync run(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tawait this.ensureModelFallbackPreferencesLoaded();\n\t\tconst maxRetries = this.normalizeRetryCount(options?.maxRetries ?? this.config.maxRetries);\n\t\tconst retryDelayMs = this.normalizeRetryDelay(this.config.retryDelayMs);\n\t\tlet lastError: unknown = null;\n\t\tconst modelSequence = this.resolveModelSequence(options);\n\t\tfor (let modelIndex = 0; modelIndex < modelSequence.length; modelIndex += 1) {\n\t\t\tconst model = modelSequence[modelIndex];\n\t\t\tconst nextModel = modelSequence[modelIndex + 1];\n\t\t\tconst modelOptions = this.applyModelOverride(options, model);\n\t\t\tlet processCwdFallbackApplied = false;\n\t\t\tlet attempt = 0;\n\t\t\twhile (attempt <= maxRetries) {\n\t\t\t\ttry {\n\t\t\t\t\tthis.log(`run model=${model || this.config.model || 'default'} attempt ${attempt + 1}/${maxRetries + 1}`);\n\t\t\t\t\tif (this.pingEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\t\tawait this.runPing(modelOptions?.threadOptions);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.streamEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\t\tconst result = await this.runStreamedOnce(prompt, modelOptions);\n\t\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await this.runOnce(prompt, modelOptions);\n\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\t\tcatch (error) {\n\t\t\t\t\t\tlastError = error;\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\t\t\tthis.log(`run model=${model || this.config.model || 'default'} attempt ${attempt + 1} failed: ${message}`);\n\t\t\t\t\t\tif (!processCwdFallbackApplied && this.shouldApplyProcessCwdFallback(error, modelOptions)) {\n\t\t\t\t\t\t\tprocessCwdFallbackApplied = true;\n\t\t\t\t\t\t\tconst workingDirectory = this.resolveProcessWorkingDirectory(modelOptions);\n\t\t\t\t\t\t\tconst fallbackOptions = this.applyProcessCwdFallback(modelOptions);\n\t\t\t\t\t\t\tthis.log('codex workingDirectory launch failed with os error 2; retrying from process cwd without CLI workingDirectory.');\n\t\t\t\t\t\t\treturn await this.withProcessWorkingDirectoryFallback(workingDirectory, async () => {\n\t\t\t\t\t\t\t\tif (this.streamEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\t\t\t\t\tconst fallbackResult = await this.runStreamedOnce(prompt, fallbackOptions);\n\t\t\t\t\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\t\t\t\t\treturn fallbackResult;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst fallbackResult = await this.runOnce(prompt, fallbackOptions);\n\t\t\t\t\t\t\t\tawait this.clearModelFallbackPreference(model);\n\t\t\t\t\t\t\t\treturn fallbackResult;\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (nextModel && this.isModelAvailabilityError(error)) {\n\t\t\t\t\t\t\tawait this.rememberModelFallbackPreference(model, nextModel);\n\t\t\t\t\t\t\tthis.log(`model unavailable; retrying with fallback model ${nextModel}`);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.isCodexEnvironmentError(error)) {\n\t\t\t\t\t\t\tthis.recoverCodexEnvironment(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (attempt >= maxRetries || !this.isRetryableError(error)) {\n\t\t\t\t\t\t\tthrow lastError;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst delay = retryDelayMs * Math.pow(2, attempt);\n\t\t\t\t\t\tawait this.sleep(delay);\n\t\t\t\t\tattempt += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow lastError;\n\t}\n\n\tprivate async runStreamedOnce(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tconst startedAt = Date.now();\n\t\tthis.log(`runStreamed start (promptLength=${prompt.length})`);\n\t\tconst thread = await this.startThread(options?.threadOptions, options?.threadKey, options?.reuseThread);\n\t\tconst timeoutMs = options?.timeoutMs ?? this.defaultTimeoutMs;\n\t\tconst streamIdleTimeoutMs = this.normalizeStreamIdleTimeoutMs(options?.streamIdleTimeoutMs);\n\t\tconst controller = typeof AbortController !== 'undefined' ? new AbortController() : null;\n\t\tconst timeoutId = controller\n\t\t\t? setTimeout(() => controller.abort(), timeoutMs)\n\t\t\t: null;\n\t\tlet lastStreamActivityAt = Date.now();\n\t\tconst idleTimeoutId = controller && streamIdleTimeoutMs > 0\n\t\t\t? setInterval(() => {\n\t\t\t\tif (Date.now() - lastStreamActivityAt >= streamIdleTimeoutMs) {\n\t\t\t\t\tcontroller.abort();\n\t\t\t\t}\n\t\t\t}, Math.max(15_000, Math.min(60_000, Math.floor(streamIdleTimeoutMs / 4))))\n\t\t\t: null;\n\t\tlet finalResponse = '';\n\t\tlet lastText = '';\n\t\tlet usageSummary: CodexUsageSummary | null = null;\n\t\ttry {\n\t\t\tconst { events } = await thread.runStreamed(prompt, controller ? { signal: controller.signal } : undefined);\n\t\t\tfor await (const event of events) {\n\t\t\t\tlastStreamActivityAt = Date.now();\n\t\t\t\tif (event?.type === 'turn.completed') {\n\t\t\t\t\tusageSummary = this.normalizeUsageSummary(event?.usage);\n\t\t\t\t}\n\t\t\t\tif (options?.onStreamEvent) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait options.onStreamEvent(event);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (error) {\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\t\t\tthis.log(`onStreamEvent failed: ${message}`);\n\t\t\t\t\t\tif (options?.failOnStreamHandlerError) {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait this.handleStreamEvent(event, async (text: string) => {\n\t\t\t\t\tconst next = text || '';\n\t\t\t\t\tif (!next) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst delta = next.startsWith(lastText) ? next.slice(lastText.length) : next;\n\t\t\t\t\tif (delta) {\n\t\t\t\t\t\tthis.logStreamText(delta);\n\t\t\t\t\t\tif (options?.onStreamText) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait options.onStreamText(delta, next);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (error) {\n\t\t\t\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\t\t\t\t\tthis.log(`onStreamText failed: ${message}`);\n\t\t\t\t\t\t\t\tif (options?.failOnStreamHandlerError) {\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tlastText = next;\n\t\t\t\t\tfinalResponse = next;\n\t\t\t\t});\n\t\t\t\tif (event?.type === 'turn.failed') {\n\t\t\t\t\tthrow new Error(event.error?.message || 'AI run failed.');\n\t\t\t\t}\n\t\t\t\tif (event?.type === 'error') {\n\t\t\t\t\tthrow new Error(event.message || 'AI stream error.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (error) {\n\t\t\tif (controller?.signal?.aborted) {\n\t\t\t\tconst idleForMs = Date.now() - lastStreamActivityAt;\n\t\t\t\tif (streamIdleTimeoutMs > 0 && idleForMs >= streamIdleTimeoutMs) {\n\t\t\t\t\tthis.log(`runStreamed idle timed out (durationMs=${Date.now() - startedAt}, idleForMs=${idleForMs})`);\n\t\t\t\t\tthrow new Error(`AI stream stalled with no activity for ${idleForMs}ms.`);\n\t\t\t\t}\n\t\t\t\tthis.log(`runStreamed timed out (durationMs=${Date.now() - startedAt})`);\n\t\t\t\tthrow new Error('AI request timed out.');\n\t\t\t}\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`runStreamed failed (durationMs=${Date.now() - startedAt}): ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t\tfinally {\n\t\t\tif (timeoutId) {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t}\n\t\t\tif (idleTimeoutId) {\n\t\t\t\tclearInterval(idleTimeoutId);\n\t\t\t}\n\t\t}\n\t\tif (!finalResponse) {\n\t\t\tthrow new Error('AI returned no completion content.');\n\t\t}\n\t\tawait this.emitUsageSummary(options, usageSummary);\n\t\tthis.log(`runStreamed complete (contentLength=${finalResponse.length}, durationMs=${Date.now() - startedAt})`);\n\t\treturn finalResponse.trim();\n\t}\n\n\tprivate normalizeStreamIdleTimeoutMs(value: any): number {\n\t\tconst parsed = Number(value || 0);\n\t\tif (!Number.isFinite(parsed) || parsed < 60_000) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn Math.floor(parsed);\n\t}\n\n\tprivate async runOnce(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tconst startedAt = Date.now();\n\t\tthis.log(`runOnce start (promptLength=${prompt.length})`);\n\t\ttry {\n\t\t\tconst thread = await this.startThread(options?.threadOptions, options?.threadKey, options?.reuseThread);\n\t\t\tconst runPromise = thread.run(prompt);\n\t\t\tconst timeoutMs = options?.timeoutMs ?? this.defaultTimeoutMs;\n\t\t\tthis.log(`runOnce awaiting result (timeoutMs=${timeoutMs})`);\n\t\t\tconst result: any = await this.withTimeout(runPromise, timeoutMs);\n\t\t\tconst content = this.extractContent(result);\n\t\t\tif (!content) {\n\t\t\t\tthrow new Error('AI returned no completion content.');\n\t\t\t}\n\t\t\tawait this.emitUsageSummary(options, this.normalizeUsageSummary(result?.usage));\n\t\t\tthis.log(`runOnce complete (contentLength=${content.length}, durationMs=${Date.now() - startedAt})`);\n\t\t\treturn content;\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`runOnce failed (durationMs=${Date.now() - startedAt}): ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate async startThread(threadOptions?: CodexThreadOptions, threadKey?: string, reuseThread = true): Promise<any> {\n\t\tawait this.ensureCodex();\n\t\tconst mergedOptions = this.mergeThreadOptions(threadOptions);\n\t\tconst optionsKey = this.buildThreadOptionsKey(mergedOptions);\n\t\tconst effectiveModel = mergedOptions?.model || this.config.model || 'default';\n\t\tconst modelKey = this.normalizeOptionalString(effectiveModel).toLowerCase() || 'default';\n\t\tconst cacheKey = this.buildThreadCacheKey(threadKey, mergedOptions);\n\t\tconst explicitThreadKey = (threadKey || '').trim();\n\t\tconst hasExplicitThreadKey = explicitThreadKey.length > 0;\n\t\tif (reuseThread && cacheKey) {\n\t\t\tconst existing = this.threadCache.get(cacheKey);\n\t\t\tif (existing) {\n\t\t\t\tconst sameOptions = existing.optionsKey === optionsKey;\n\t\t\t\tconst sameModel = existing.modelKey === modelKey;\n\t\t\t\tif (sameOptions || (hasExplicitThreadKey && sameModel)) {\n\t\t\t\t\tif (hasExplicitThreadKey && existing.optionsKey !== optionsKey) {\n\t\t\t\t\t\tthis.log(`startThread reuse explicit key (${cacheKey}) despite option change`);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.log(`startThread reuse (${cacheKey})`);\n\t\t\t\t\t}\n\t\t\t\t\treturn existing.thread;\n\t\t\t\t}\n\t\t\t\tif (hasExplicitThreadKey && !sameModel) {\n\t\t\t\t\tthis.log(`startThread explicit key (${cacheKey}) model changed (${existing.modelKey} -> ${modelKey}); creating new thread`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.log(`startThread (model=${effectiveModel})`);\n\t\tif (mergedOptions?.model) {\n\t\t\tthis.log(`startThread options: ${this.formatThreadOptions(mergedOptions)}`);\n\t\t\tconst thread = this.codex.startThread(mergedOptions);\n\t\t\tthis.log('startThread created with model override');\n\t\t\tif (cacheKey) {\n\t\t\t\tthis.threadCache.set(cacheKey, { thread, optionsKey, modelKey });\n\t\t\t}\n\t\t\treturn thread;\n\t\t}\n\t\tif (mergedOptions && Object.keys(mergedOptions).length) {\n\t\t\tthis.log(`startThread options: ${this.formatThreadOptions(mergedOptions)}`);\n\t\t}\n\t\tconst thread = this.codex.startThread(mergedOptions);\n\t\tthis.log('startThread created');\n\t\tif (cacheKey) {\n\t\t\tthis.threadCache.set(cacheKey, { thread, optionsKey, modelKey });\n\t\t}\n\t\treturn thread;\n\t}\n\n\tprivate extractContent(result: any): string {\n\t\tif (!result) {\n\t\t\treturn '';\n\t\t}\n\t\tif (typeof result.finalResponse === 'string') {\n\t\t\treturn result.finalResponse.trim();\n\t\t}\n\t\tif (typeof result === 'string') {\n\t\t\treturn result.trim();\n\t\t}\n\t\tif (Array.isArray(result.items)) {\n\t\t\tconst lastMessage = [...result.items].reverse().find((item: any) => item?.type === 'agent_message' && typeof item.text === 'string');\n\t\t\tif (lastMessage?.text) {\n\t\t\t\treturn lastMessage.text.trim();\n\t\t\t}\n\t\t}\n\t\tif (typeof result.output_text === 'string') {\n\t\t\treturn result.output_text.trim();\n\t\t}\n\t\tif (typeof result.outputText === 'string') {\n\t\t\treturn result.outputText.trim();\n\t\t}\n\t\tif (typeof result.content === 'string') {\n\t\t\treturn result.content.trim();\n\t\t}\n\t\tif (typeof result.text === 'string') {\n\t\t\treturn result.text.trim();\n\t\t}\n\t\tif (Array.isArray(result.content)) {\n\t\t\tconst text = result.content\n\t\t\t\t.map((part: any) => this.extractPartText(part))\n\t\t\t\t.join('')\n\t\t\t\t.trim();\n\t\t\tif (text) {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t}\n\t\tif (Array.isArray(result.output)) {\n\t\t\tconst text = result.output\n\t\t\t\t.map((item: any) => {\n\t\t\t\t\tif (!item) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof item === 'string') {\n\t\t\t\t\t\treturn item;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof item.text === 'string') {\n\t\t\t\t\t\treturn item.text;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof item.content === 'string') {\n\t\t\t\t\t\treturn item.content;\n\t\t\t\t\t}\n\t\t\t\t\tif (Array.isArray(item.content)) {\n\t\t\t\t\t\treturn item.content.map((part: any) => this.extractPartText(part)).join('');\n\t\t\t\t\t}\n\t\t\t\t\treturn '';\n\t\t\t\t})\n\t\t\t\t.join('')\n\t\t\t\t.trim();\n\t\t\tif (text) {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t}\n\t\treturn '';\n\t}\n\n\tprivate async handleStreamEvent(event: any, onAgentMessage: AgentMessageHandler): Promise<void> {\n\t\tif (!event || !event.type) {\n\t\t\treturn;\n\t\t}\n\t\tswitch (event.type) {\n\t\t\tcase 'thread.started':\n\t\t\t\tthis.log(`stream thread.started (id=${event.thread_id || 'unknown'})`);\n\t\t\t\tbreak;\n\t\t\tcase 'turn.started':\n\t\t\t\tthis.log('stream turn.started');\n\t\t\t\tbreak;\n\t\t\tcase 'turn.completed':\n\t\t\t\tthis.log('stream turn.completed');\n\t\t\t\tbreak;\n\t\t\tcase 'item.started':\n\t\t\tcase 'item.updated':\n\t\t\tcase 'item.completed':\n\t\t\t\tawait this.handleStreamItem(event.item, onAgentMessage);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate normalizeUsageSummary(raw: any): CodexUsageSummary | null {\n\t\tif (!raw || typeof raw !== 'object') {\n\t\t\treturn null;\n\t\t}\n\t\tconst inputTokens = this.normalizeUsageToken(raw.input_tokens ?? raw.inputTokens);\n\t\tconst cachedInputTokens = this.normalizeUsageToken(raw.cached_input_tokens ?? raw.cachedInputTokens);\n\t\tconst outputTokens = this.normalizeUsageToken(raw.output_tokens ?? raw.outputTokens);\n\t\tif (inputTokens <= 0 && cachedInputTokens <= 0 && outputTokens <= 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn {\n\t\t\tinputTokens,\n\t\t\tcachedInputTokens,\n\t\t\toutputTokens\n\t\t};\n\t}\n\n\tprivate normalizeUsageToken(value: any): number {\n\t\tconst parsed = Number(value);\n\t\tif (!Number.isFinite(parsed) || parsed <= 0) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn Math.floor(parsed);\n\t}\n\n\tprivate async emitUsageSummary(options: CodexRunOptions | undefined, usage: CodexUsageSummary | null): Promise<void> {\n\t\tif (!options?.onUsage) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait options.onUsage(usage);\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`onUsage failed: ${message}`);\n\t\t}\n\t}\n\n\tprivate async handleStreamItem(item: any, onAgentMessage: AgentMessageHandler): Promise<void> {\n\t\tif (!item || !item.type) {\n\t\t\treturn;\n\t\t}\n\t\tswitch (item.type) {\n\t\t\tcase 'agent_message':\n\t\t\t\tawait onAgentMessage(item.text || '');\n\t\t\t\tbreak;\n\t\t\tcase 'command_execution':\n\t\t\t\tif (item.command) {\n\t\t\t\t\tthis.log(`stream command: ${item.command} (${item.status || 'unknown'})`);\n\t\t\t\t}\n\t\t\t\tif (item.aggregated_output) {\n\t\t\t\t\tconst output = item.aggregated_output.length > 800\n\t\t\t\t\t\t? `${item.aggregated_output.slice(0, 800)}...`\n\t\t\t\t\t\t: item.aggregated_output;\n\t\t\t\t\tthis.log(`stream command output: ${output}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'file_change':\n\t\t\t\tif (Array.isArray(item.changes) && item.changes.length) {\n\t\t\t\t\tconst summary = item.changes.map((change: any) => `${change.kind}:${change.path}`).join(', ');\n\t\t\t\t\tthis.log(`stream file_change (${item.status || 'unknown'}): ${summary}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'mcp_tool_call':\n\t\t\t\tif (item.tool) {\n\t\t\t\t\tthis.log(`stream tool_call: ${item.tool} (${item.status || 'unknown'})`);\n\t\t\t\t}\n\t\t\t\tif (item.error?.message) {\n\t\t\t\t\tthis.log(`stream tool_call error: ${item.error.message}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'web_search':\n\t\t\t\tif (item.query) {\n\t\t\t\t\tthis.log(`stream web_search: ${item.query}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'todo_list':\n\t\t\t\tif (Array.isArray(item.items)) {\n\t\t\t\t\tconst total = item.items.length;\n\t\t\t\t\tconst done = item.items.filter((entry: any) => entry?.completed).length;\n\t\t\t\t\tthis.log(`stream todo_list: ${done}/${total} completed`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'reasoning':\n\t\t\t\tif (item.text) {\n\t\t\t\t\tconst snippet = item.text.length > 200 ? `${item.text.slice(0, 200)}...` : item.text;\n\t\t\t\t\tthis.log(`stream reasoning: ${snippet}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'error':\n\t\t\t\tif (item.message) {\n\t\t\t\t\tthis.log(`stream error: ${item.message}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate logStreamText(text: string): void {\n\t\tif (!this.debugEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tconst lines = text.split(/\\r?\\n/);\n\t\tfor (const line of lines) {\n\t\t\tthis.log(`stream: ${line}`);\n\t\t}\n\t}\n\n\tprivate extractPartText(part: any): string {\n\t\tif (!part) {\n\t\t\treturn '';\n\t\t}\n\t\tif (typeof part === 'string') {\n\t\t\treturn part;\n\t\t}\n\t\tif (typeof part.text === 'string') {\n\t\t\treturn part.text;\n\t\t}\n\t\tif (typeof part.content === 'string') {\n\t\t\treturn part.content;\n\t\t}\n\t\treturn '';\n\t}\n\n\tprivate async withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {\n\t\tlet done = false;\n\t\tconst startedAt = Date.now();\n\t\tconst heartbeatMs = Math.max(10000, Math.min(30000, Math.floor(timeoutMs / 4)));\n\t\tconst timeoutPromise = (async (): Promise<T> => {\n\t\t\twhile (!done) {\n\t\t\t\tconst elapsed = Date.now() - startedAt;\n\t\t\t\tif (elapsed >= timeoutMs) {\n\t\t\t\t\tthrow new Error('AI request timed out.');\n\t\t\t\t}\n\t\t\t\tconst remaining = timeoutMs - elapsed;\n\t\t\t\tawait sleepTimeout(Math.min(heartbeatMs, remaining));\n\t\t\t\tif (done) {\n\t\t\t\t\treturn await promise;\n\t\t\t\t}\n\t\t\t\tconst currentElapsed = Date.now() - startedAt;\n\t\t\t\tif (currentElapsed >= timeoutMs) {\n\t\t\t\t\tthrow new Error('AI request timed out.');\n\t\t\t\t}\n\t\t\t\tconst currentRemaining = Math.max(0, timeoutMs - currentElapsed);\n\t\t\t\tthis.log(`runOnce waiting (elapsedMs=${currentElapsed}, remainingMs=${currentRemaining})`);\n\t\t\t}\n\t\t\treturn await promise;\n\t\t})();\n\t\ttry {\n\t\t\treturn await Promise.race([promise, timeoutPromise]);\n\t\t}\n\t\tfinally {\n\t\t\tdone = true;\n\t\t}\n\t}\n\n\tprivate normalizeRetryCount(value?: number): number {\n\t\tif (typeof value !== 'number' || Number.isNaN(value)) {\n\t\t\treturn 2;\n\t\t}\n\t\treturn Math.max(0, Math.floor(value));\n\t}\n\n\tprivate normalizeRetryDelay(value?: number): number {\n\t\tif (typeof value !== 'number' || Number.isNaN(value)) {\n\t\t\treturn 500;\n\t\t}\n\t\treturn Math.max(100, Math.floor(value));\n\t}\n\n\tprivate resolveModelSequence(options?: CodexRunOptions): string[] {\n\t\tconst primary = this.normalizeOptionalString(options?.threadOptions?.model || this.config.model);\n\t\tconst fallbackModels = this.collectFallbackModels(options?.fallbackModels);\n\t\tconst sequence: string[] = [];\n\t\tconst push = (value: any) => {\n\t\t\tconst normalized = this.normalizeOptionalString(value);\n\t\t\tif (!normalized || sequence.includes(normalized)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsequence.push(normalized);\n\t\t};\n\t\tconst preferredFallback = this.getModelFallbackPreference(primary);\n\t\tif (preferredFallback) {\n\t\t\tpush(preferredFallback);\n\t\t\tthis.log(`sticky model fallback active: ${primary} -> ${preferredFallback}`);\n\t\t}\n\t\tpush(primary);\n\t\tfallbackModels.forEach(push);\n\t\tif (!sequence.length) {\n\t\t\tsequence.push('');\n\t\t}\n\t\treturn sequence;\n\t}\n\n\tprivate collectFallbackModels(runFallbackModels?: string[]): string[] {\n\t\tconst models: string[] = [];\n\t\tconst push = (value: any) => {\n\t\t\tconst normalized = this.normalizeOptionalString(value);\n\t\t\tif (!normalized || models.includes(normalized)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmodels.push(normalized);\n\t\t};\n\t\tthis.normalizeModelList(runFallbackModels).forEach(push);\n\t\tthis.normalizeModelList(this.config.fallbackModels).forEach(push);\n\t\tpush(this.config.fallbackModel);\n\t\tthis.normalizeModelList(process.env.AI_ASSISTANT_CODEX_FALLBACK_MODELS).forEach(push);\n\t\tpush(process.env.AI_ASSISTANT_CODEX_FALLBACK_MODEL);\n\t\tthis.normalizeModelList(process.env.AI_TERMINAL_CODEX_FALLBACK_MODELS).forEach(push);\n\t\tpush(process.env.AI_TERMINAL_CODEX_FALLBACK_MODEL);\n\t\tthis.normalizeModelList(process.env.AI_DASHBOARD_CODEX_FALLBACK_MODELS).forEach(push);\n\t\tpush(process.env.AI_DASHBOARD_CODEX_FALLBACK_MODEL);\n\t\tconst primaryModel = this.normalizeOptionalString(\n\t\t\tthis.config.model\n\t\t\t|| runFallbackModels?.[0]\n\t\t\t|| ''\n\t\t);\n\t\tif (/^gpt-5(?:\\.\\d+)?-codex$/i.test(primaryModel)) {\n\t\t\tpush('gpt-5-codex');\n\t\t}\n\t\tif (/^gpt-5(?:-codex|\\.\\d+-codex)$/i.test(primaryModel)) {\n\t\t\tpush('gpt-5.5');\n\t\t}\n\t\treturn models;\n\t}\n\n\tprivate normalizeModelList(value: any): string[] {\n\t\tif (Array.isArray(value)) {\n\t\t\treturn value\n\t\t\t\t.map(entry => this.normalizeOptionalString(entry))\n\t\t\t\t.filter(Boolean);\n\t\t}\n\t\tconst raw = this.normalizeOptionalString(value);\n\t\tif (!raw) {\n\t\t\treturn [];\n\t\t}\n\t\treturn raw\n\t\t\t.split(',')\n\t\t\t.map(entry => this.normalizeOptionalString(entry))\n\t\t\t.filter(Boolean);\n\t}\n\n\tprivate applyModelOverride(options: CodexRunOptions | undefined, model: string): CodexRunOptions {\n\t\tconst nextThreadOptions: CodexThreadOptions = {\n\t\t\t...(options?.threadOptions || {})\n\t\t};\n\t\tif (model) {\n\t\t\tnextThreadOptions.model = model;\n\t\t}\n\t\telse {\n\t\t\tdelete nextThreadOptions.model;\n\t\t}\n\t\treturn {\n\t\t\t...(options || {}),\n\t\t\tthreadOptions: nextThreadOptions\n\t\t};\n\t}\n\n\tprivate isModelAvailabilityError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\tconst normalized = message.toLowerCase();\n\t\tif (!normalized.includes('model')) {\n\t\t\treturn false;\n\t\t}\n\t\tif (/does not exist|not found|unknown model|invalid model|unsupported model|model_not_found|no such model/.test(normalized)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (/not available|unavailable|not enabled|not allowed|do not have access|don't have access|insufficient permissions/.test(normalized)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn /404/.test(normalized) && /model/.test(normalized);\n\t}\n\n\tprivate isRetryableError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\tif (/AI returned no completion content|Codex returned no completion content/i.test(message)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.isCodexEnvironmentError(error)) {\n\t\t\treturn true;\n\t\t}\n\t\tconst statusMatch = message.match(/\\\\b(429|5\\\\d{2})\\\\b/);\n\t\tif (statusMatch) {\n\t\t\treturn true;\n\t\t}\n\t\treturn /ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|fetch failed|timed out|timeout/i.test(message);\n\t}\n\n\tprivate isCodexEnvironmentError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\treturn /error finding codex home|could not update path: no such file or directory/i.test(message);\n\t}\n\n\tprivate recoverCodexEnvironment(error: unknown): void {\n\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\tthis.log(`recovering codex environment after error: ${message}`);\n\t\tthis.threadCache.clear();\n\t\tthis.codex = null;\n\t\tthis.codexInit = null;\n\t\tthis.zDotDir = null;\n\t}\n\n\tprivate shouldApplyProcessCwdFallback(error: unknown, options?: CodexRunOptions): boolean {\n\t\tconst workingDirectory = this.resolveProcessWorkingDirectory(options);\n\t\tif (!workingDirectory) {\n\t\t\treturn false;\n\t\t}\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\treturn /no such file or directory \\(os error 2\\)/i.test(message);\n\t}\n\n\tprivate resolveProcessWorkingDirectory(options?: CodexRunOptions): string {\n\t\treturn this.normalizeOptionalString(options?.processWorkingDirectory || options?.threadOptions?.workingDirectory);\n\t}\n\n\tprivate applyProcessCwdFallback(options?: CodexRunOptions): CodexRunOptions {\n\t\tconst nextThreadOptions: CodexThreadOptions = {\n\t\t\t...(options?.threadOptions || {})\n\t\t};\n\t\tdelete nextThreadOptions.workingDirectory;\n\t\treturn {\n\t\t\t...(options || {}),\n\t\t\tthreadOptions: nextThreadOptions\n\t\t};\n\t}\n\n\tprivate async withProcessWorkingDirectoryFallback<T>(workingDirectory: string, runner: () => Promise<T>): Promise<T> {\n\t\tconst normalizedWorkingDirectory = this.normalizeOptionalString(workingDirectory);\n\t\tif (!normalizedWorkingDirectory) {\n\t\t\treturn await runner();\n\t\t}\n\n\t\twhile (CodexClient.cwdFallbackRunning) {\n\t\t\tawait this.sleep(50);\n\t\t}\n\t\tCodexClient.cwdFallbackRunning = true;\n\n\t\tconst originalCwd = process.cwd();\n\t\ttry {\n\t\t\tprocess.chdir(normalizedWorkingDirectory);\n\t\t\tthis.log(`running Codex fallback from process cwd ${normalizedWorkingDirectory}`);\n\t\t\treturn await runner();\n\t\t}\n\t\tfinally {\n\t\t\ttry {\n\t\t\t\tprocess.chdir(originalCwd);\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\tthis.log(`failed to restore process cwd to ${originalCwd}: ${message}`);\n\t\t\t}\n\t\t\tCodexClient.cwdFallbackRunning = false;\n\t\t}\n\t}\n\n\tprivate normalizeOptionalString(value: any): string {\n\t\treturn typeof value === 'string' ? value.trim() : '';\n\t}\n\n\tprivate resolveModelUnavailableTtlMs(): number {\n\t\tconst raw = Number(\n\t\t\tprocess.env.AI_DASHBOARD_CODEX_MODEL_UNAVAILABLE_TTL_MS\n\t\t\t|| process.env.AI_ASSISTANT_CODEX_MODEL_UNAVAILABLE_TTL_MS\n\t\t);\n\t\tif (Number.isFinite(raw) && raw >= CodexClient.MIN_MODEL_UNAVAILABLE_TTL_MS) {\n\t\t\treturn Math.floor(raw);\n\t\t}\n\t\treturn CodexClient.DEFAULT_MODEL_UNAVAILABLE_TTL_MS;\n\t}\n\n\tprivate async ensureModelFallbackPreferencesLoaded(): Promise<void> {\n\t\tif (CodexClient.modelFallbackPreferencesLoaded) {\n\t\t\tthis.pruneModelFallbackPreferences();\n\t\t\treturn;\n\t\t}\n\t\tif (CodexClient.modelFallbackPreferencesLoadPromise !== null) {\n\t\t\tawait CodexClient.modelFallbackPreferencesLoadPromise;\n\t\t\tthis.pruneModelFallbackPreferences();\n\t\t\treturn;\n\t\t}\n\t\tCodexClient.modelFallbackPreferencesLoadPromise = (async () => {\n\t\t\ttry {\n\t\t\t\tconst raw = await fs.readFile(CodexClient.MODEL_UNAVAILABLE_FALLBACK_FILE, 'utf8');\n\t\t\t\tconst parsed = JSON.parse(raw);\n\t\t\t\tif (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tObject.entries(parsed).forEach(([model, entry]) => {\n\t\t\t\t\tconst key = this.normalizeOptionalString(model);\n\t\t\t\t\tif (!key) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst fallbackModel = this.normalizeOptionalString((entry as any)?.fallbackModel);\n\t\t\t\t\tconst expiresAt = Number((entry as any)?.expiresAt);\n\t\t\t\t\tconst updatedAt = Number((entry as any)?.updatedAt);\n\t\t\t\t\tif (!fallbackModel || !Number.isFinite(expiresAt) || expiresAt <= Date.now()) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tCodexClient.modelFallbackPreferences.set(key, {\n\t\t\t\t\t\tfallbackModel,\n\t\t\t\t\t\texpiresAt: Math.floor(expiresAt),\n\t\t\t\t\t\tupdatedAt: Number.isFinite(updatedAt) ? Math.floor(updatedAt) : Date.now()\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t// Ignore cache load errors.\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tCodexClient.modelFallbackPreferencesLoaded = true;\n\t\t\t\tCodexClient.modelFallbackPreferencesLoadPromise = null;\n\t\t\t}\n\t\t})();\n\t\tawait CodexClient.modelFallbackPreferencesLoadPromise;\n\t\tthis.pruneModelFallbackPreferences();\n\t}\n\n\tprivate pruneModelFallbackPreferences(now = Date.now()): void {\n\t\tArray.from(CodexClient.modelFallbackPreferences.entries()).forEach(([model, entry]) => {\n\t\t\tif (!entry || !Number.isFinite(entry.expiresAt) || entry.expiresAt <= now) {\n\t\t\t\tCodexClient.modelFallbackPreferences.delete(model);\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate getModelFallbackPreference(model: string): string {\n\t\tconst normalizedModel = this.normalizeOptionalString(model);\n\t\tif (!normalizedModel) {\n\t\t\treturn '';\n\t\t}\n\t\tthis.pruneModelFallbackPreferences();\n\t\tconst entry = CodexClient.modelFallbackPreferences.get(normalizedModel);\n\t\tif (!entry || entry.expiresAt <= Date.now()) {\n\t\t\tif (entry) {\n\t\t\t\tCodexClient.modelFallbackPreferences.delete(normalizedModel);\n\t\t\t}\n\t\t\treturn '';\n\t\t}\n\t\treturn entry.fallbackModel;\n\t}\n\n\tprivate async rememberModelFallbackPreference(model: string, fallbackModel: string): Promise<void> {\n\t\tconst normalizedModel = this.normalizeOptionalString(model);\n\t\tconst normalizedFallback = this.normalizeOptionalString(fallbackModel);\n\t\tif (!normalizedModel || !normalizedFallback || normalizedModel === normalizedFallback) {\n\t\t\treturn;\n\t\t}\n\t\tconst now = Date.now();\n\t\tCodexClient.modelFallbackPreferences.set(normalizedModel, {\n\t\t\tfallbackModel: normalizedFallback,\n\t\t\texpiresAt: now + this.modelUnavailableTtlMs,\n\t\t\tupdatedAt: now\n\t\t});\n\t\tthis.pruneModelFallbackPreferences(now);\n\t\tawait this.persistModelFallbackPreferences();\n\t}\n\n\tprivate async clearModelFallbackPreference(model: string): Promise<void> {\n\t\tconst normalizedModel = this.normalizeOptionalString(model);\n\t\tif (!normalizedModel) {\n\t\t\treturn;\n\t\t}\n\t\tif (!CodexClient.modelFallbackPreferences.has(normalizedModel)) {\n\t\t\treturn;\n\t\t}\n\t\tCodexClient.modelFallbackPreferences.delete(normalizedModel);\n\t\tawait this.persistModelFallbackPreferences();\n\t}\n\n\tprivate async persistModelFallbackPreferences(): Promise<void> {\n\t\tthis.pruneModelFallbackPreferences();\n\t\tif (!CodexClient.modelFallbackPreferences.size) {\n\t\t\ttry {\n\t\t\t\tawait fs.unlink(CodexClient.MODEL_UNAVAILABLE_FALLBACK_FILE);\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t// Ignore file cleanup errors.\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst serialized: Record<string, CodexModelFallbackPreference> = {};\n\t\tCodexClient.modelFallbackPreferences.forEach((entry, model) => {\n\t\t\tserialized[model] = entry;\n\t\t});\n\t\ttry {\n\t\t\tawait fs.writeFile(CodexClient.MODEL_UNAVAILABLE_FALLBACK_FILE, JSON.stringify(serialized), 'utf8');\n\t\t}\n\t\tcatch {\n\t\t\t// Ignore cache persistence errors.\n\t\t}\n\t}\n\n\tprivate async sleep(ms: number): Promise<void> {\n\t\tawait sleepTimeout(ms);\n\t}\n\n\tprivate async ensureCodex(): Promise<void> {\n\t\tif (this.codex) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.codexInit !== null) {\n\t\t\tawait this.codexInit;\n\t\t\treturn;\n\t\t}\n\t\tthis.codexInit = (async () => {\n\t\t\tthis.log('Loading AI SDK module...');\n\t\t\tconst importer = new Function('specifier', 'return import(specifier)') as DynamicImport;\n\t\t\tconst mod = await importer('@openai/codex-sdk');\n\t\t\tconst CodexCtor = mod?.Codex || mod?.default?.Codex || mod?.default || mod;\n\t\t\tif (!CodexCtor) {\n\t\t\t\tthrow new Error('AI SDK export not found.');\n\t\t\t}\n\t\t\tthis.log('AI SDK module loaded.');\n\t\t\tconst env = await this.buildCodexEnv();\n\t\t\tthis.codex = new CodexCtor({\n\t\t\t\tapiKey: this.config.apiKey,\n\t\t\t\tbaseUrl: this.config.baseUrl,\n\t\t\t\tmodel: this.config.model,\n\t\t\t\tenv\n\t\t\t});\n\t\t\tthis.log('AI client initialized.');\n\t\t})();\n\t\tawait this.codexInit;\n\t}\n\n\tprivate log(message: string): void {\n\t\tif (!this.debugEnabled) {\n\t\t\treturn;\n\t\t}\n\t\tconsole.log(`[AI-Dashboard][AI] ${message}`);\n\t}\n\n\tprivate resolveDefaultTimeoutMs(): number {\n\t\tconst raw = Number(process.env.AI_DASHBOARD_CODEX_TIMEOUT_MS || process.env.AI_DASHBOARD_AGENT_TIMEOUT_MS);\n\t\tif (Number.isFinite(raw) && raw > 0) {\n\t\t\treturn Math.floor(raw);\n\t\t}\n\t\treturn 600000;\n\t}\n\n\tprivate resolveStreamEnabled(): boolean {\n\t\tconst raw = (process.env.AI_DASHBOARD_CODEX_STREAM || '').trim().toLowerCase();\n\t\tif (!raw) {\n\t\t\treturn this.debugEnabled;\n\t\t}\n\t\tif (['true', '1', 'yes', 'y', 'on'].includes(raw)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (['false', '0', 'no', 'n', 'off'].includes(raw)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn this.debugEnabled;\n\t}\n\n\tprivate resolveCleanZdotdirEnabled(): boolean {\n\t\tconst raw = (process.env.AI_DASHBOARD_CODEX_CLEAN_ZDOTDIR ?? '').trim().toLowerCase();\n\t\tif (!raw) {\n\t\t\treturn true;\n\t\t}\n\t\tif (['false', '0', 'no', 'n', 'off'].includes(raw)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (['true', '1', 'yes', 'y', 'on'].includes(raw)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn true;\n\t}\n\n\tprivate async buildCodexEnv(): Promise<Record<string, string>> {\n\t\tconst env: Record<string, string> = {};\n\t\tfor (const [key, value] of Object.entries(process.env)) {\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tenv[key] = value;\n\t\t\t}\n\t\t}\n\t\tif (!this.normalizeOptionalString(env.HOME)) {\n\t\t\tconst fallbackHome = this.normalizeOptionalString(process.env.HOME || os.homedir());\n\t\t\tif (fallbackHome) {\n\t\t\t\tenv.HOME = fallbackHome;\n\t\t\t}\n\t\t}\n\t\tawait this.ensureCodexHome(env);\n\t\tif (this.cleanZdotdirEnabled) {\n\t\t\tenv.ZDOTDIR = await this.ensureZdotdir();\n\t\t}\n\t\treturn env;\n\t}\n\n\tprivate async ensureCodexHome(env: Record<string, string>): Promise<void> {\n\t\tconst current = this.normalizeOptionalString(env.CODEX_HOME || process.env.CODEX_HOME);\n\t\tconst homeRoot = this.normalizeOptionalString(env.HOME || process.env.HOME || os.homedir());\n\t\tconst primary = current || (homeRoot ? path.join(homeRoot, '.codex') : path.join(os.tmpdir(), 'resolveio-codex-home'));\n\t\ttry {\n\t\t\tawait fs.mkdir(path.join(primary, 'sessions'), { recursive: true });\n\t\t\tenv.CODEX_HOME = primary;\n\t\t\tprocess.env.CODEX_HOME = primary;\n\t\t\treturn;\n\t\t}\n\t\tcatch {\n\t\t\tconst fallback = path.join(os.tmpdir(), 'resolveio-codex-home');\n\t\t\tawait fs.mkdir(path.join(fallback, 'sessions'), { recursive: true });\n\t\t\tenv.CODEX_HOME = fallback;\n\t\t\tprocess.env.CODEX_HOME = fallback;\n\t\t}\n\t}\n\n\tprivate async ensureZdotdir(): Promise<string> {\n\t\tif (this.zDotDir) {\n\t\t\treturn this.zDotDir;\n\t\t}\n\t\tconst override = (process.env.AI_DASHBOARD_CODEX_ZDOTDIR || '').trim();\n\t\tconst dir = override || path.join(os.tmpdir(), 'codex-zdotdir');\n\t\tawait fs.mkdir(dir, { recursive: true });\n\t\tawait Promise.allSettled([\n\t\t\tfs.writeFile(path.join(dir, '.zshrc'), '', { flag: 'a' }),\n\t\t\tfs.writeFile(path.join(dir, '.zprofile'), '', { flag: 'a' })\n\t\t]);\n\t\tthis.zDotDir = dir;\n\t\treturn dir;\n\t}\n\n\tprivate resolvePingEnabled(): boolean {\n\t\treturn this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_PING, false);\n\t}\n\n\tprivate resolvePingTimeoutMs(): number {\n\t\tconst raw = Number(process.env.AI_DASHBOARD_CODEX_PING_TIMEOUT_MS);\n\t\tif (Number.isFinite(raw) && raw > 0) {\n\t\t\treturn Math.floor(raw);\n\t\t}\n\t\treturn 10000;\n\t}\n\n\tprivate resolveDefaultThreadOptions(): CodexThreadOptions {\n\t\tconst approvalPolicy = this.normalizeApprovalPolicy(process.env.AI_DASHBOARD_CODEX_APPROVAL_POLICY);\n\t\tconst sandboxMode = this.normalizeSandboxMode(process.env.AI_DASHBOARD_CODEX_SANDBOX_MODE, 'workspace-write');\n\t\tconst skipGitRepoCheck = this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_SKIP_GIT_CHECK, true);\n\t\tconst webSearchMode = this.normalizeWebSearchMode(process.env.AI_DASHBOARD_CODEX_WEB_SEARCH_MODE);\n\t\tconst webSearchEnabled = this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_WEB_SEARCH_ENABLED, false);\n\t\tconst networkAccessEnabled = this.normalizeBoolean(process.env.AI_DASHBOARD_CODEX_NETWORK_ACCESS_ENABLED, false);\n\t\tconst modelReasoningEffort = this.normalizeModelReasoningEffort(process.env.AI_DASHBOARD_CODEX_REASONING_EFFORT);\n\t\treturn {\n\t\t\tmodel: this.config.model,\n\t\t\tapprovalPolicy,\n\t\t\tsandboxMode,\n\t\t\tskipGitRepoCheck,\n\t\t\twebSearchMode,\n\t\t\twebSearchEnabled,\n\t\t\tnetworkAccessEnabled,\n\t\t\tmodelReasoningEffort\n\t\t};\n\t}\n\n\tprivate mergeThreadOptions(overrides?: CodexThreadOptions): CodexThreadOptions | undefined {\n\t\tconst merged: CodexThreadOptions = {\n\t\t\t...this.defaultThreadOptions,\n\t\t\t...(overrides || {})\n\t\t};\n\t\tconst effectiveModel = this.normalizeOptionalString(merged.model || this.config.model);\n\t\tconst normalizedEffort = this.normalizeModelReasoningEffortForModel(effectiveModel, merged.modelReasoningEffort);\n\t\tif (normalizedEffort && normalizedEffort !== merged.modelReasoningEffort) {\n\t\t\tthis.log(`normalized reasoning effort for model=${effectiveModel || 'default'}: ${merged.modelReasoningEffort} -> ${normalizedEffort}`);\n\t\t\tmerged.modelReasoningEffort = normalizedEffort;\n\t\t}\n\t\tconst cleaned = Object.entries(merged).reduce((acc, [key, value]) => {\n\t\t\tif (value === undefined || value === null || value === '') {\n\t\t\t\treturn acc;\n\t\t\t}\n\t\t\t(acc as any)[key] = value;\n\t\t\treturn acc;\n\t\t}, {} as CodexThreadOptions);\n\t\treturn Object.keys(cleaned).length ? cleaned : undefined;\n\t}\n\n\tprivate normalizeApprovalPolicy(value?: string): CodexThreadOptions['approvalPolicy'] {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'never' || normalized === 'on-request' || normalized === 'on-failure' || normalized === 'untrusted') {\n\t\t\treturn normalized as CodexThreadOptions['approvalPolicy'];\n\t\t}\n\t\treturn 'never';\n\t}\n\n\tprivate normalizeSandboxMode(value?: string, fallback: CodexThreadOptions['sandboxMode'] = 'read-only'): CodexThreadOptions['sandboxMode'] {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'read-only' || normalized === 'workspace-write' || normalized === 'danger-full-access') {\n\t\t\treturn normalized as CodexThreadOptions['sandboxMode'];\n\t\t}\n\t\treturn fallback;\n\t}\n\n\tprivate normalizeWebSearchMode(value?: string): CodexThreadOptions['webSearchMode'] | undefined {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'disabled' || normalized === 'cached' || normalized === 'live') {\n\t\t\treturn normalized as CodexThreadOptions['webSearchMode'];\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate normalizeModelReasoningEffort(value?: string): CodexThreadOptions['modelReasoningEffort'] | undefined {\n\t\tconst normalized = (value || '').trim().toLowerCase();\n\t\tif (normalized === 'minimal' || normalized === 'none' || normalized === 'low' || normalized === 'medium' || normalized === 'high' || normalized === 'xhigh') {\n\t\t\treturn normalized as CodexThreadOptions['modelReasoningEffort'];\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate normalizeModelReasoningEffortForModel(\n\t\tmodel: string,\n\t\teffort?: CodexThreadOptions['modelReasoningEffort']\n\t): CodexThreadOptions['modelReasoningEffort'] | undefined {\n\t\tif (!effort) {\n\t\t\treturn effort;\n\t\t}\n\t\tconst normalizedModel = this.normalizeOptionalString(model).toLowerCase();\n\t\tif (effort === 'minimal' && (!normalizedModel || normalizedModel.startsWith('gpt-5') || normalizedModel.includes('codex'))) {\n\t\t\treturn 'low';\n\t\t}\n\t\treturn effort;\n\t}\n\n\tprivate normalizeBoolean(value: string | undefined, fallback: boolean): boolean {\n\t\tif (!value) {\n\t\t\treturn fallback;\n\t\t}\n\t\tconst normalized = value.trim().toLowerCase();\n\t\tif (['true', '1', 'yes', 'y', 'on'].includes(normalized)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (['false', '0', 'no', 'n', 'off'].includes(normalized)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn fallback;\n\t}\n\n\tprivate formatThreadOptions(options: CodexThreadOptions): string {\n\t\tconst summary: Record<string, string> = {};\n\t\tObject.entries(options).forEach(([key, value]) => {\n\t\t\tif (value === undefined || value === null) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsummary[key] = String(value);\n\t\t});\n\t\treturn JSON.stringify(summary);\n\t}\n\n\tprivate buildThreadOptionsKey(options?: CodexThreadOptions): string {\n\t\tif (!options) {\n\t\t\treturn '';\n\t\t}\n\t\tconst ordered: Record<string, string> = {};\n\t\tObject.keys(options)\n\t\t\t.sort()\n\t\t\t.forEach((key) => {\n\t\t\t\tconst value = (options as Record<string, unknown>)[key];\n\t\t\t\tif (value === undefined || value === null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tordered[key] = Array.isArray(value) ? JSON.stringify(value) : String(value);\n\t\t\t});\n\t\treturn JSON.stringify(ordered);\n\t}\n\n\tprivate buildThreadCacheKey(threadKey: string | undefined, options?: CodexThreadOptions): string | null {\n\t\tif (threadKey) {\n\t\t\treturn `thread:${threadKey}`;\n\t\t}\n\t\tconst model = options?.model || this.config.model;\n\t\tconst workingDirectory = options?.workingDirectory;\n\t\tif (!model && !workingDirectory) {\n\t\t\treturn null;\n\t\t}\n\t\treturn `thread:auto:${model || 'default'}:${workingDirectory || 'root'}`;\n\t}\n\n\tprivate isPingPrompt(prompt: string): boolean {\n\t\treturn prompt.trim() === CodexClient.PING_PROMPT;\n\t}\n\n\tprivate async runPing(threadOptions?: CodexThreadOptions): Promise<void> {\n\t\tthis.log(`runPing start (timeoutMs=${this.pingTimeoutMs})`);\n\t\ttry {\n\t\t\tconst content = await this.runOnce(CodexClient.PING_PROMPT, {\n\t\t\t\ttimeoutMs: this.pingTimeoutMs,\n\t\t\t\tthreadOptions,\n\t\t\t\treuseThread: false\n\t\t\t});\n\t\t\tconst trimmed = content.trim();\n\t\t\tconst preview = trimmed.length > 80 ? `${trimmed.slice(0, 80)}…` : trimmed;\n\t\t\tthis.log(`runPing response: ${preview}`);\n\t\t}\n\t\tcatch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\tthis.log(`runPing failed: ${message}`);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n"]}
@@ -128,7 +128,7 @@ function buildResolveIOQaPolicyRules(options) {
128
128
  var policy = normalizeResolveIOQaPolicyOptions(options);
129
129
  var rules = [];
130
130
  if (policy.includeDevServerRules) {
131
- rules.push('When browser/localhost QA needs long-running commands like `npm run server`, `npm run client`, `npm run dev`, `ng serve`, `vite`, or `nodemon`, start them as managed background processes with log files and PIDs; do not leave foreground dev-server commands as the active shell tool.', 'Before localhost/browser QA, source `.resolveio-support-tools/env.sh` or `.resolveio-ai-runner-tools/env.sh` when present. It supplies shared EC2 browser cache settings, `PUPPETEER_EXECUTABLE_PATH`/`CHROME_BIN`, Mongo wrappers, and non-conflicting localhost QA ports/URLs.', 'For ResolveIO app login during browser QA, use the shared AI-runner auth bootstrap when staged: `node ./.resolveio-support-tools/qa-auth-bootstrap.js <project-root> /target-route`, `node ./.resolveio-ai-runner-tools/qa-auth-bootstrap.js <project-root> /target-route`, or the same command from an app root with `../`. It must use the exact localhost client origin, log out/clear stale browser credentials first, call `/login` then `/accessToken`, seed auth storage, repair the local QA user settings/tour flags if the app forces the post-login settings/tour gate, verify the browser reached the requested target route, and emit `qa-artifacts/auth-bootstrap-result.json`, `qa-artifacts/auth-bootstrap-storage-state.json`, plus a screenshot. For every fresh Puppeteer/Playwright page, open the localhost origin, set localStorage from `auth-bootstrap-storage-state.json`, then navigate to the target route. The storage artifact may expose top-level object `localStorage`, array `localStorageEntries`, or Playwright-style `origins[].localStorage`; normalize all three shapes before setting storage (`Object.entries` for objects, `{key,value}` or `{name,value}` for arrays). Never run `for...of` directly on top-level `localStorage` unless it is already an array. A login-shell screenshot after bootstrap means the QA script failed to seed auth and must rerun the same row with storage seeded before returning needs-fix.', 'For ResolveIO browser checks, do not use Puppeteer/Playwright `networkidle0` or `networkidle2` as the page-ready condition; ResolveIO pages can keep background API/socket/polling activity open. Navigate with `domcontentloaded`, then wait for concrete route/workflow DOM text, buttons, table rows, dialogs, saved records, or persisted data assertions before screenshots.', 'Use browser API compatibility helpers instead of version-fragile calls: every row-level Puppeteer script must declare `const delay = ms => new Promise(resolve => setTimeout(resolve, ms));` before navigation and use `await delay(...)` for fixed waits. Do not use `page.$x`, `page.waitForTimeout`, `networkidle0`, or `networkidle2`. Use `page.evaluateHandle`/DOM traversal or Playwright `locator` when definitely using Playwright. If a browser helper call throws because the current runtime lacks that API, fix the QA script and rerun the same matrix row before marking it failed.', 'Browser click targeting must prefer exact interactive controls: `button`, `a[href]`, `[role="button"]`, `input[type="button"]`, `input[type="submit"]`, `select`, option/combobox controls, and app-specific clickable elements with a small visible bounding box. Do not include broad `div`, `span`, `body`, or `*` elements in click-by-text helpers; they often match whole-page containers and produce false progress. If a text match has a huge bounding box or contains unrelated page/navigation text, skip it and find a smaller descendant/control.', 'For QA row probes, use broad DOM text scans only for read-only diagnostics. Do not drive workflow clicks from broad `document.querySelectorAll("*")` or generic container matches. After at most two focused selector attempts on the seeded route/data, either capture the blocker screenshot and return `needs-fix`, or switch to persisted data assertions if the row can be proven without another UI click.', 'When launching Puppeteer or Playwright on workers, pass `executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || process.env.CHROME_BIN` if either env var is set. If either env var points to an executable, do not run `npx puppeteer browsers install`, `puppeteer browsers install`, Playwright install, or any browser download. If the staged browser is missing or not executable, return one precise dependency blocker instead of downloading inside the QA owner turn.', 'Do not scan broad roots such as `/var/app/resolveio-ai-workspace`, `/tmp/resolveio-support-qa`, or `/var/lib/resolveio` to rediscover Puppeteer, Playwright, or Chromium. Source the staged env file and use its `PUPPETEER_EXECUTABLE_PATH`/`CHROME_BIN`; if the staged browser/runtime is missing, return a precise dependency blocker.', 'When the current directory is an app/project root, shared QA tools may be staged one directory up. Prefer `../.resolveio-support-tools/env.sh` or `../.resolveio-ai-runner-tools/env.sh` before writing custom browser code. Do not use bare `require("puppeteer")` from an app root until checking the project/server node_modules or the staged helper pattern.', 'Secret handling: never print, cat, paste, or summarize `.env`, `.env.runtime`, `.env.codex`, `settings.json`, `.mongo-runtime.json`, Mongo URLs, API keys, tokens, or passwords in command output, QA artifacts, screenshots, captions, or final notes. Source staged env files or read only the named QA artifacts; redact connection strings if a tool emits one.', 'For targeted QA row repair, read `qa-artifacts/qa-live-data-seed-result.json`, `qa-artifacts/auth-bootstrap-result.json`, `qa-artifacts/auth-bootstrap-storage-state.json`, and `qa-artifacts/qa-workflow-probe-result.json` before writing browser probes. Use seeded `selected` ids/names directly; do not guess customer filters, invoice numbers, or dropdown options when the seed artifact already provides the exact QA fixture. After route navigation, wait for concrete route/workflow DOM text or controls for up to the row timeout before calling a page shell-only; a 1-2 second fixed delay is not enough evidence that a ResolveIO route failed to hydrate.', 'When the live seed artifact contains `selected.truck_treating_bol_context`, use the seeded ids/statuses directly instead of guessing customer data. If `primary_bol_status` or `bol_statuses[]` says Delivered, the direct `browser_routes.delivery` URL is an action route that may correctly redirect with `BOL has already been delivered`; do not treat that alone as an application defect. For delivered BOLs, test the delivered Open File/detail/Deliveries evidence path, or create the smallest localhost-only deliverable fixture from the fetched live BOL/route/delivery/treatment-plan context and record the fixture ids in the matrix. If `route_hint_matched === false`, the source database disproved the ticket route-name hint; use the seeded BOL-linked `bol_ids`, `route_ids`, `truck_treating_route_ids`, `linked_truck_treating_routes`, and usable browser route/fixture as the QA target, record the route-name mismatch in the row caption/assertion, and do not block only because the original route label is not visible.', 'QA owner source-code boundary: browser QA may write only QA artifacts, screenshots, traces, captions, coverage matrices, temporary row probe scripts, and localhost-only fixture data. Do not edit application source files, generated wrappers, package files, migrations, or tests from the QA lane. If QA proves a code/data/publication defect, return `needs-fix` with the exact matrix row, screenshot/log/data evidence, suspected files, and smallest repair hint so the build lane can fix it.', 'For Billing Dashboard QA rows, use seeded `qa_billing_fixture.customerId`, `psoId`, `deliveryId`, `invoiceId`, and `itemId` to choose/filter/open the exact row. If the page hides seeded rows behind filters, the QA row script should select by the seeded customer/id or return a data-seed/filter blocker with a screenshot instead of cycling through generic dropdown options.', 'For invoice edit, saved invoice, and inventory side-effect QA rows, prefer direct navigation to `/invoice/edit/${qa_billing_fixture.invoiceId}` or open invoice detail and click the explicit Edit control. Do not use Billing Dashboard or invoice-list `Open Invoice` as proof of the edit workflow; in ResolveIO that action can open/generated-preview invoice output instead of the edit component. If direct edit route redirects to a list/shell, return one precise route/data blocker with screenshot instead of retrying the same Open Invoice path.', 'When updating `qa-artifacts/qa-coverage-matrix.json`, verify the target row index still matches the active workflow before writing. If the row at that index has a different workflow, locate the row by exact workflow text; if multiple rows share a workflow, update only the row whose route/assertion matches the active row. Never overwrite an unrelated passing row or create duplicate workflow rows to work around a cursor mismatch.', 'Use the managed-server pattern for localhost QA: `command > .build-output/<name>.log 2>&1 & PID=$!; trap "kill $PID 2>/dev/null || true" EXIT; wait for the port with curl; run browser checks; then kill/wait the PID`. Prefer `npm run client` or `./start_client.sh`; those scripts honor `RESOLVEIO_SUPPORT_QA_CLIENT_PORT` and `PORT`. Never run `ng serve ... | tee ...` or another dev server as a foreground command.');
131
+ rules.push('When browser/localhost QA needs long-running commands like `npm run server`, `npm run client`, `npm run dev`, `ng serve`, `vite`, or `nodemon`, start them as managed background processes with log files and PIDs; do not leave foreground dev-server commands as the active shell tool.', 'Before localhost/browser QA, source `.resolveio-support-tools/env.sh` or `.resolveio-ai-runner-tools/env.sh` when present. It supplies shared EC2 browser cache settings, `PUPPETEER_EXECUTABLE_PATH`/`CHROME_BIN`, Mongo wrappers, and non-conflicting localhost QA ports/URLs.', 'For ResolveIO app login during browser QA, use the shared AI-runner auth bootstrap when staged: `node ./.resolveio-support-tools/qa-auth-bootstrap.js <project-root> /target-route`, `node ./.resolveio-ai-runner-tools/qa-auth-bootstrap.js <project-root> /target-route`, or the same command from an app root with `../`. It must use the exact localhost client origin, log out/clear stale browser credentials first, call `/login` then `/accessToken`, seed auth storage, repair the local QA user settings/tour flags if the app forces the post-login settings/tour gate, verify the browser reached the requested target route, and emit `qa-artifacts/auth-bootstrap-result.json`, `qa-artifacts/auth-bootstrap-storage-state.json`, plus a screenshot. For support-ticket QA, use Puppeteer first when `PUPPETEER_EXECUTABLE_PATH` or `CHROME_BIN` is set; `PLAYWRIGHT_MISSING` is not a blocker while that Puppeteer env exists. For every fresh Puppeteer/Playwright page, open the localhost origin, set localStorage from `auth-bootstrap-storage-state.json`, then navigate to the target route. The storage artifact may expose top-level object `localStorage`, array `localStorageEntries`, or Playwright-style `origins[].localStorage`; normalize all three shapes before setting storage (`Object.entries` for objects, `{key,value}` or `{name,value}` for arrays). Never run `for...of` directly on top-level `localStorage` unless it is already an array. A login-shell screenshot after bootstrap means the QA script failed to seed auth and must rerun the same row with storage seeded before returning needs-fix.', 'For support-ticket QA, run the browser as the ticket reporter whenever possible; if the ticket or latest customer response names another affected user, run as that affected user instead. Use `qa-live-data-seed-result.json.selected.qa_user_context` and `auth-bootstrap-result.json.user` to record the chosen user. Generic admin/dev QA is acceptable only when no reporter/affected user can be identified or copied into localhost QA; in that case the matrix must say why.', 'For ResolveIO browser checks, do not use Puppeteer/Playwright `networkidle0` or `networkidle2` as the page-ready condition; ResolveIO pages can keep background API/socket/polling activity open. Navigate with `domcontentloaded`, then wait for concrete route/workflow DOM text, buttons, table rows, dialogs, saved records, or persisted data assertions before screenshots.', 'Use browser API compatibility helpers instead of version-fragile calls: every row-level Puppeteer script must declare `const delay = ms => new Promise(resolve => setTimeout(resolve, ms));` before navigation and use `await delay(...)` for fixed waits. Do not use `page.$x`, `page.waitForTimeout`, `networkidle0`, or `networkidle2`. Use `page.evaluateHandle`/DOM traversal or Playwright `locator` when definitely using Playwright. If a browser helper call throws because the current runtime lacks that API, fix the QA script and rerun the same matrix row before marking it failed.', 'Browser click targeting must prefer exact interactive controls: `button`, `a[href]`, `[role="button"]`, `input[type="button"]`, `input[type="submit"]`, `select`, option/combobox controls, and app-specific clickable elements with a small visible bounding box. Do not include broad `div`, `span`, `body`, or `*` elements in click-by-text helpers; they often match whole-page containers and produce false progress. If a text match has a huge bounding box or contains unrelated page/navigation text, skip it and find a smaller descendant/control.', 'For QA row probes, use broad DOM text scans only for read-only diagnostics. Do not drive workflow clicks from broad `document.querySelectorAll("*")` or generic container matches. After at most two focused selector attempts on the seeded route/data, either capture the blocker screenshot and return `needs-fix`, or switch to persisted data assertions if the row can be proven without another UI click.', 'When launching Puppeteer on workers, pass `executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || process.env.CHROME_BIN` if either env var is set. If either env var points to an executable, do not run `npx puppeteer browsers install`, `puppeteer browsers install`, Playwright install, or any browser download. Do not connect to `localhost:9223`, `/json/version`, or any Chrome remote-debug endpoint unless `RESOLVEIO_SUPPORT_QA_BROWSER_URL` or `RESOLVEIO_RUNNER_QA_BROWSER_URL` is explicitly set after sourcing the staged env and the endpoint responds; otherwise launch a scoped Puppeteer browser from the staged executable. If Playwright is missing but Puppeteer env exists, continue with Puppeteer instead of returning `PLAYWRIGHT_MISSING`. If the staged browser is missing or not executable, return one precise dependency blocker instead of downloading inside the QA owner turn.', 'Do not scan broad roots such as `/var/app/resolveio-ai-workspace`, `/tmp/resolveio-support-qa`, or `/var/lib/resolveio` to rediscover Puppeteer, Playwright, or Chromium. Source the staged env file and use its `PUPPETEER_EXECUTABLE_PATH`/`CHROME_BIN`; if the staged browser/runtime is missing, return a precise dependency blocker.', 'When the current directory is an app/project root, shared QA tools may be staged one directory up. Prefer `../.resolveio-support-tools/env.sh` or `../.resolveio-ai-runner-tools/env.sh` before writing custom browser code. Do not use bare `require("puppeteer")` from an app root until checking the project/server node_modules or the staged helper pattern.', 'Secret handling: never print, cat, paste, or summarize `.env`, `.env.runtime`, `.env.codex`, `settings.json`, `.mongo-runtime.json`, Mongo URLs, API keys, tokens, or passwords in command output, QA artifacts, screenshots, captions, or final notes. Source staged env files or read only the named QA artifacts; redact connection strings if a tool emits one.', 'For targeted QA row repair, read `qa-artifacts/qa-live-data-seed-result.json`, `qa-artifacts/auth-bootstrap-result.json`, `qa-artifacts/auth-bootstrap-storage-state.json`, and `qa-artifacts/qa-workflow-probe-result.json` before writing browser probes. Use seeded `selected` ids/names directly; do not guess customer filters, invoice numbers, or dropdown options when the seed artifact already provides the exact QA fixture. After route navigation, wait for concrete route/workflow DOM text or controls for up to the row timeout before calling a page shell-only; a 1-2 second fixed delay is not enough evidence that a ResolveIO route failed to hydrate.', 'When the live seed artifact contains `selected.truck_treating_bol_context`, use the seeded ids/statuses directly instead of guessing customer data. If `primary_bol_status` or `bol_statuses[]` says Delivered, the direct `browser_routes.delivery` URL is an action route that may correctly redirect with `BOL has already been delivered`; do not treat that alone as an application defect. For delivered BOLs, test the delivered Open File/detail/Deliveries evidence path, or create the smallest localhost-only deliverable fixture from the fetched live BOL/route/delivery/treatment-plan context and record the fixture ids in the matrix. If `route_hint_matched === false`, the source database disproved the ticket route-name hint; use the seeded BOL-linked `bol_ids`, `route_ids`, `truck_treating_route_ids`, `linked_truck_treating_routes`, and usable browser route/fixture as the QA target, record the route-name mismatch in the row caption/assertion, and do not block only because the original route label is not visible.', 'QA owner source-code boundary: browser QA may write only QA artifacts, screenshots, traces, captions, coverage matrices, temporary row probe scripts, and localhost-only fixture data. Do not edit application source files, generated wrappers, package files, migrations, or tests from the QA lane. If QA proves a code/data/publication defect, return `needs-fix` with the exact matrix row, screenshot/log/data evidence, suspected files, and smallest repair hint so the build lane can fix it.', 'For Billing Dashboard QA rows, use seeded `qa_billing_fixture.customerId`, `psoId`, `deliveryId`, `invoiceId`, and `itemId` to choose/filter/open the exact row. If the page hides seeded rows behind filters, the QA row script should select by the seeded customer/id or return a data-seed/filter blocker with a screenshot instead of cycling through generic dropdown options.', 'For invoice edit, saved invoice, and inventory side-effect QA rows, prefer direct navigation to `/invoice/edit/${qa_billing_fixture.invoiceId}` or open invoice detail and click the explicit Edit control. Do not use Billing Dashboard or invoice-list `Open Invoice` as proof of the edit workflow; in ResolveIO that action can open/generated-preview invoice output instead of the edit component. If direct edit route redirects to a list/shell, return one precise route/data blocker with screenshot instead of retrying the same Open Invoice path.', 'When updating `qa-artifacts/qa-coverage-matrix.json`, verify the target row index still matches the active workflow before writing. If the row at that index has a different workflow, locate the row by exact workflow text; if multiple rows share a workflow, update only the row whose route/assertion matches the active row. Never overwrite an unrelated passing row or create duplicate workflow rows to work around a cursor mismatch.', 'Use the managed-server pattern for localhost QA: `command > .build-output/<name>.log 2>&1 & PID=$!; trap "kill $PID 2>/dev/null || true" EXIT; wait for the port with curl; run browser checks; then kill/wait the PID`. Prefer `npm run client` or `./start_client.sh`; those scripts honor `RESOLVEIO_SUPPORT_QA_CLIENT_PORT` and `PORT`. Never run `ng serve ... | tee ...` or another dev server as a foreground command.');
132
132
  if (policy.context === 'support_ticket') {
133
133
  rules.push('For support-ticket QA validation, the manager normally runs compile/startup preflight and keeps the local harness alive before the QA owner starts. In that mode, the QA owner must not run `run-local-qa.sh`, `npm run server`, `npm run client`, `ng serve`, `mongod`, `gulp`, or compile/build commands again; probe the existing localhost URLs and proceed to auth/browser proof.', 'If the preflighted support-ticket harness is not reachable, return a precise blocked/needs-fix result with the probed URL, HTTP/socket error, and qa-artifacts log paths. Do not start a duplicate server, duplicate client, duplicate Mongo, or duplicate compile from inside the browser QA owner.');
134
134
  }
@@ -144,8 +144,15 @@ function buildResolveIOQaPolicyRules(options) {
144
144
  rules.push('For bug fixes and data/publication changes, test against available live app data or a faithful seeded record; do not rely only on static inspection when the user reported a runtime workflow problem.');
145
145
  rules.push('Local QA may create, update, or delete representative seed records only in the localhost QA Mongo/database started for the run. Production/live customer databases are read-only for QA unless explicit human approval is provided.');
146
146
  rules.push('If the localhost QA database has no records for the workflow under test, seed the smallest faithful record set needed to exercise the customer action and identify the seeded fixture IDs/names in the QA Coverage Matrix. Do not return blocked only because local QA data is empty.');
147
+ rules.push('When a ticket or customer response names concrete entities such as users, units, assets, BOLs, invoices, chemicals, yards, customers, routes, or order numbers, live-data seeding must fetch those exact production records into localhost QA where possible. QA must prove every named entity or return a seed/query blocker; representative substitute records are not pass evidence for named-record bug reports.');
147
148
  rules.push('For import/export/form-submit/data workflows, QA must drive the actual customer action with representative data: capture the relevant starting state, the dialog/form/file selection or action state, and the submitted/resulting state with a row/count/value assertion that proves the bug or feature works.');
149
+ rules.push('For file upload/import QA, write a checkpoint artifact before launch, after route load, after file selection/upload, after parsing, after clicking the import/submit action, and after the final result. If the browser page/frame/process dies during file selection or parse, mark the row failed with that exact upload-stage blocker; do not silently retry as a pass or count route-load screenshots as proof.');
148
150
  rules.push('A navigation-only screenshot of an empty page, shell, table header, or unchanged screen is not sufficient evidence for data workflow fixes. If the page has no records, seed or choose a faithful test record and identify the record or fixture used.');
151
+ rules.push('For pricing import/upload tickets, validator scripts are not enough. Browser QA must use the Manage Pricing import UI with both blank and pre-populated templates when the ticket mentions both, click the import action, and prove persisted pricing row/count/value changes in localhost QA Mongo.');
152
+ rules.push('For pricing import/upload tickets, expand the exact visible Ready accordion/control, then click the small enabled `Import Production Prices` button or equivalent submit control. Do not click broad page containers, nav/sidebar text, or generic div/span text matches. Do not treat static headings like `Production Prices With Errors`, `Ready For Import`, or unchanged table text as success or blocker evidence; wait for a real result dialog/message, button disabled/enabled state change, page error, or persisted Mongo row/count/value change.');
153
+ rules.push('For asset location/current-yard rename tickets, browser QA must prove the exact asset/unit on list, detail, and edit/save screens, and must include a joined/canonical yard record assertion showing the new yard name is used and the stale old yard name is absent.');
154
+ rules.push('For asset location/current-yard rename tickets that name multiple assets or units, QA must prove every named asset/unit, not one representative row. Captions/data assertions must name each requested unit number, its canonical joined yard, and the absence of each stale yard name before the row can pass.');
155
+ rules.push('For Update Interchangeables or Mass Update chemical tickets, browser QA must select the real source and target chemicals, run the update action, and assert before/after treatment-plan/tank document counts or ids in localhost QA Mongo. Route load, visible controls, or selected dropdowns alone are not pass evidence.');
149
156
  }
150
157
  rules.push('Before passing QA, create a QA Coverage Matrix from the approved scope, changed files, generated/publication changes, and touched collections/models. Each matrix row must name the workflow, route/screen, data used, assertion, screenshot/trace artifact, and pass/fail result.');
151
158
  rules.push('When updating `qa-artifacts/qa-coverage-matrix.json`, support both matrix schemas: the file may be an array or an object with a `rows` array. Use `const rows = Array.isArray(matrix) ? matrix : matrix.rows` for row updates and preserve the original schema when writing it back. Never skip row updates because only `Array.isArray(matrix)` is false.');
@@ -161,6 +168,7 @@ function buildResolveIOQaPolicyRules(options) {
161
168
  rules.push('Before every screenshot, settle the ResolveIO shell: press Escape, blur active controls, move the mouse away from the top/side nav, wait at least 750ms, and verify the target row/control/value has a visible bounding box inside the viewport. If the target text exists in DOM but is covered by the menu, sidebar, header, or a dark overlay, close the overlay or adjust the QA user/menu setting and recapture; do not count the covered screenshot as proof.');
162
169
  rules.push('For table/list evidence, a pass screenshot must show the actual target row cells and the changed value in the same frame. Header-only, pagination-only, covered-row, or DOM-only proof can diagnose a failure, but cannot be used as customer-facing pass evidence.');
163
170
  rules.push('For select/dropdown/filter workflows, a pass screenshot must show the relevant control with a real non-placeholder selected value, an open dropdown with the specific live option used, or a resulting data row/action state caused by that selection. Screenshots where required controls still show only placeholders such as Select Chemical, Select Customer, Select Yard, or Select Treatment Plan Type are empty-state evidence and must be failed or recaptured before pass.');
171
+ rules.push('A matrix shortcut may only pass after all row-specific evidence gates pass. If any row was rejected for shallow proof, missing selected values, missing persisted data, or stale/contradictory matrix data, keep the row failed and trigger a targeted repair/retest instead of marking the matrix complete.');
164
172
  rules.push('Route/screen screenshots are valid only when they show the specific workflow being tested. If a route redirects to a generic shell, default manage page, menu-only view, auth screen, or a different feature screen, mark that matrix row failed/blocked with the mismatch; never count that screenshot as pass evidence.');
165
173
  if (policy.qaDistinctScreenshotRequired) {
166
174
  rules.push('Capture one screenshot or trace for each distinct changed customer-facing feature, screen, workflow state, or data result. Do not repeat equivalent screenshots for multiple records unless record-specific behavior changed.');