@resolveio/server-lib 20.14.1 → 20.14.3
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/methods/ai-terminal.js +55 -6
- package/methods/ai-terminal.js.map +1 -1
- package/methods/report-builder.js +145 -57
- package/methods/report-builder.js.map +1 -1
- package/package.json +1 -1
- package/services/codex-client.d.ts +1 -1
- package/services/codex-client.js +1 -1
- package/services/codex-client.js.map +1 -1
package/package.json
CHANGED
|
@@ -37,10 +37,10 @@ export declare class CodexClient {
|
|
|
37
37
|
private readonly cleanZdotdirEnabled;
|
|
38
38
|
private zDotDir;
|
|
39
39
|
private readonly defaultTimeoutMs;
|
|
40
|
-
private readonly defaultThreadOptions;
|
|
41
40
|
private readonly pingEnabled;
|
|
42
41
|
private readonly pingTimeoutMs;
|
|
43
42
|
private readonly config;
|
|
43
|
+
private readonly defaultThreadOptions;
|
|
44
44
|
constructor(config: CodexConfig);
|
|
45
45
|
run(prompt: string, options?: CodexRunOptions): Promise<string>;
|
|
46
46
|
private runStreamedOnce;
|
package/services/codex-client.js
CHANGED
|
@@ -105,13 +105,13 @@ var CodexClient = /** @class */ (function () {
|
|
|
105
105
|
this.cleanZdotdirEnabled = this.resolveCleanZdotdirEnabled();
|
|
106
106
|
this.zDotDir = null;
|
|
107
107
|
this.defaultTimeoutMs = this.resolveDefaultTimeoutMs();
|
|
108
|
-
this.defaultThreadOptions = this.resolveDefaultThreadOptions();
|
|
109
108
|
this.pingEnabled = this.resolvePingEnabled();
|
|
110
109
|
this.pingTimeoutMs = this.resolvePingTimeoutMs();
|
|
111
110
|
this.config = config;
|
|
112
111
|
if (!this.config.apiKey) {
|
|
113
112
|
throw new Error('OPENAI_API_KEY is required for CodexClient');
|
|
114
113
|
}
|
|
114
|
+
this.defaultThreadOptions = this.resolveDefaultThreadOptions();
|
|
115
115
|
}
|
|
116
116
|
CodexClient.prototype.run = function (prompt, options) {
|
|
117
117
|
return __awaiter(this, void 0, void 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Content":["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\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 DynamicImport = (specifier: string) => Promise<any>;\n/* eslint-enable no-unused-vars */\n\nexport interface CodexRunOptions {\n\ttimeoutMs?: number;\n\tthreadOptions?: CodexThreadOptions;\n\tthreadKey?: string;\n\treuseThread?: boolean;\n\tonStreamEvent?: StreamEventHandler;\n\tonStreamText?: StreamTextHandler;\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' | '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 codex: any | null = null;\n\tprivate codexInit: Promise<void> | null = null;\n\tprivate readonly threadCache = new Map<string, { thread: any; optionsKey: 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 defaultThreadOptions = this.resolveDefaultThreadOptions();\n\tprivate readonly pingEnabled = this.resolvePingEnabled();\n\tprivate readonly pingTimeoutMs = this.resolvePingTimeoutMs();\n\tprivate readonly config: CodexConfig;\n\n\tconstructor(config: CodexConfig) {\n\t\tthis.config = config;\n\t\tif (!this.config.apiKey) {\n\t\t\tthrow new Error('OPENAI_API_KEY is required for CodexClient');\n\t\t}\n\t}\n\n\tasync run(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tconst maxRetries = this.normalizeRetryCount(this.config.maxRetries);\n\t\tconst retryDelayMs = this.normalizeRetryDelay(this.config.retryDelayMs);\n\t\tlet attempt = 0;\n\t\tlet lastError: unknown = null;\n\t\tif (this.pingEnabled && !this.isPingPrompt(prompt)) {\n\t\t\tawait this.runPing(options?.threadOptions);\n\t\t}\n\t\twhile (attempt <= maxRetries) {\n\t\t\ttry {\n\t\t\t\tthis.log(`run attempt ${attempt + 1}/${maxRetries + 1}`);\n\t\t\t\tif (this.streamEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\treturn await this.runStreamedOnce(prompt, options);\n\t\t\t\t}\n\t\t\t\treturn await this.runOnce(prompt, options);\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tlastError = error;\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\tthis.log(`run attempt ${attempt + 1} failed: ${message}`);\n\t\t\t\tif (attempt >= maxRetries || !this.isRetryableError(error)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst delay = retryDelayMs * Math.pow(2, attempt);\n\t\t\t\tawait this.sleep(delay);\n\t\t\t\tattempt += 1;\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 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 finalResponse = '';\n\t\tlet lastText = '';\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\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 || 'Codex turn failed.');\n\t\t\t\t}\n\t\t\t\tif (event?.type === 'error') {\n\t\t\t\t\tthrow new Error(event.message || 'Codex 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\tthis.log(`runStreamed timed out (durationMs=${Date.now() - startedAt})`);\n\t\t\t\tthrow new Error('Codex 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}\n\t\tif (!finalResponse) {\n\t\t\tthrow new Error('Codex returned no completion content.');\n\t\t}\n\t\tthis.log(`runStreamed complete (contentLength=${finalResponse.length}, durationMs=${Date.now() - startedAt})`);\n\t\treturn finalResponse.trim();\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 = 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('Codex returned no completion content.');\n\t\t\t}\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 cacheKey = this.buildThreadCacheKey(threadKey, mergedOptions);\n\t\tif (reuseThread && cacheKey) {\n\t\t\tconst existing = this.threadCache.get(cacheKey);\n\t\t\tif (existing && existing.optionsKey === this.buildThreadOptionsKey(mergedOptions)) {\n\t\t\t\tthis.log(`startThread reuse (${cacheKey})`);\n\t\t\t\treturn existing.thread;\n\t\t\t}\n\t\t}\n\t\tthis.log(`startThread (model=${this.config.model || 'default'})`);\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: this.buildThreadOptionsKey(mergedOptions) });\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: this.buildThreadOptionsKey(mergedOptions) });\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 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('Codex 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('Codex 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 isRetryableError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\tif (/Codex returned no completion content/i.test(message)) {\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 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 Codex 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('Codex SDK export not found.');\n\t\t\t}\n\t\t\tthis.log('Codex 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('Codex 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][Codex] ${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.cleanZdotdirEnabled) {\n\t\t\tenv.ZDOTDIR = await this.ensureZdotdir();\n\t\t}\n\t\treturn env;\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\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 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 === '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 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;AAsC7D;IAeC,q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K,WAAW,CAAC,WAAW,CAAC;IAClD,CAAC;IAEa,6BAAO,GAArB,UAAsB,aAAkC;;;;;;wBACvD,IAAI,CAAC,GAAG,CAAC,mCAA4B,IAAI,CAAC,aAAa,MAAG,CAAC,CAAC;;;;wBAE3C,qBAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE;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;IA9pBuB,uBAAW,GAAG,YAAH,AAAe,CAAC;IA+pBpD,kBAAC;CAhqBD,AAgqBC,IAAA;AAhqBY,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\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 DynamicImport = (specifier: string) => Promise<any>;\n/* eslint-enable no-unused-vars */\n\nexport interface CodexRunOptions {\n\ttimeoutMs?: number;\n\tthreadOptions?: CodexThreadOptions;\n\tthreadKey?: string;\n\treuseThread?: boolean;\n\tonStreamEvent?: StreamEventHandler;\n\tonStreamText?: StreamTextHandler;\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' | '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 codex: any | null = null;\n\tprivate codexInit: Promise<void> | null = null;\n\tprivate readonly threadCache = new Map<string, { thread: any; optionsKey: 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 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('OPENAI_API_KEY is required for CodexClient');\n\t\t}\n\t\tthis.defaultThreadOptions = this.resolveDefaultThreadOptions();\n\t}\n\n\tasync run(prompt: string, options?: CodexRunOptions): Promise<string> {\n\t\tconst maxRetries = this.normalizeRetryCount(this.config.maxRetries);\n\t\tconst retryDelayMs = this.normalizeRetryDelay(this.config.retryDelayMs);\n\t\tlet attempt = 0;\n\t\tlet lastError: unknown = null;\n\t\tif (this.pingEnabled && !this.isPingPrompt(prompt)) {\n\t\t\tawait this.runPing(options?.threadOptions);\n\t\t}\n\t\twhile (attempt <= maxRetries) {\n\t\t\ttry {\n\t\t\t\tthis.log(`run attempt ${attempt + 1}/${maxRetries + 1}`);\n\t\t\t\tif (this.streamEnabled && !this.isPingPrompt(prompt)) {\n\t\t\t\t\treturn await this.runStreamedOnce(prompt, options);\n\t\t\t\t}\n\t\t\t\treturn await this.runOnce(prompt, options);\n\t\t\t}\n\t\t\tcatch (error) {\n\t\t\t\tlastError = error;\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error || 'Unknown error');\n\t\t\t\tthis.log(`run attempt ${attempt + 1} failed: ${message}`);\n\t\t\t\tif (attempt >= maxRetries || !this.isRetryableError(error)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst delay = retryDelayMs * Math.pow(2, attempt);\n\t\t\t\tawait this.sleep(delay);\n\t\t\t\tattempt += 1;\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 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 finalResponse = '';\n\t\tlet lastText = '';\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\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 || 'Codex turn failed.');\n\t\t\t\t}\n\t\t\t\tif (event?.type === 'error') {\n\t\t\t\t\tthrow new Error(event.message || 'Codex 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\tthis.log(`runStreamed timed out (durationMs=${Date.now() - startedAt})`);\n\t\t\t\tthrow new Error('Codex 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}\n\t\tif (!finalResponse) {\n\t\t\tthrow new Error('Codex returned no completion content.');\n\t\t}\n\t\tthis.log(`runStreamed complete (contentLength=${finalResponse.length}, durationMs=${Date.now() - startedAt})`);\n\t\treturn finalResponse.trim();\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 = 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('Codex returned no completion content.');\n\t\t\t}\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 cacheKey = this.buildThreadCacheKey(threadKey, mergedOptions);\n\t\tif (reuseThread && cacheKey) {\n\t\t\tconst existing = this.threadCache.get(cacheKey);\n\t\t\tif (existing && existing.optionsKey === this.buildThreadOptionsKey(mergedOptions)) {\n\t\t\t\tthis.log(`startThread reuse (${cacheKey})`);\n\t\t\t\treturn existing.thread;\n\t\t\t}\n\t\t}\n\t\tthis.log(`startThread (model=${this.config.model || 'default'})`);\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: this.buildThreadOptionsKey(mergedOptions) });\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: this.buildThreadOptionsKey(mergedOptions) });\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 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('Codex 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('Codex 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 isRetryableError(error: unknown): boolean {\n\t\tconst message = error instanceof Error ? error.message : String(error || '');\n\t\tif (/Codex returned no completion content/i.test(message)) {\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 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 Codex 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('Codex SDK export not found.');\n\t\t\t}\n\t\t\tthis.log('Codex 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('Codex 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][Codex] ${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.cleanZdotdirEnabled) {\n\t\t\tenv.ZDOTDIR = await this.ensureZdotdir();\n\t\t}\n\t\treturn env;\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\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 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 === '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 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"]}
|