fix(ai): Codex CLI provider reliability fixes for DBX Desktop
* fix(ai): resolve Codex CLI from shell PATH on macOS * fix(ai): hide Codex CLI subprocess windows on Windows * feat(ai): allow to set environment variable for Codex CLI * fix(ai): parse Codex MCP tool events * fix(mcp): honor Postgres TLS settings in direct queries
This commit is contained in:
1 parent
2759480331
commit
034cce47e0
17 files changed
+613
-30
No files matched your search
@@ -30,6 +30,7 @@ export interface AiConfig {
|
||||
reasoningLevel?: AiReasoningLevel;
|
||||
contextWindow?: number;
|
||||
codexCliPath?: string | null;
|
||||
codexCliEnv?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface AiTestConnectionResult {
|
||||
@@ -195,11 +196,23 @@ const defaultConfigs: Record<AiProvider, Omit<AiConfig, "apiKey">> = Object.from
|
||||
) as Record<AiProvider, Omit<AiConfig, "apiKey">>;
|
||||
|
||||
const AI_REASONING_LEVELS: AiReasoningLevel[] = ["default", "minimal", "low", "medium", "high"];
|
||||
const AI_ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
||||
|
||||
function normalizeAiReasoningLevel(value: unknown): AiReasoningLevel {
|
||||
return typeof value === "string" && AI_REASONING_LEVELS.includes(value as AiReasoningLevel) ? (value as AiReasoningLevel) : "default";
|
||||
}
|
||||
|
||||
export function normalizeAiEnv(value: unknown): Record<string, string> {
|
||||
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
||||
const result: Record<string, string> = {};
|
||||
for (const [rawKey, rawValue] of Object.entries(value as Record<string, unknown>)) {
|
||||
const key = rawKey.trim();
|
||||
if (!key || !AI_ENV_KEY_RE.test(key)) continue;
|
||||
result[key] = rawValue == null ? "" : String(rawValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function normalizeAiConfig(config: Partial<AiConfig> | null | undefined): AiConfig {
|
||||
const provider = config?.provider && config.provider in AI_PROVIDER_PRESETS ? config.provider : inferAiProviderFromConfig(config);
|
||||
return {
|
||||
@@ -215,6 +228,7 @@ export function normalizeAiConfig(config: Partial<AiConfig> | null | undefined):
|
||||
reasoningLevel: normalizeAiReasoningLevel(config?.reasoningLevel),
|
||||
contextWindow: config?.contextWindow ?? undefined,
|
||||
codexCliPath: config?.codexCliPath?.trim() || undefined,
|
||||
codexCliEnv: normalizeAiEnv(config?.codexCliEnv),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user