mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Adds an "Environment variables" editor to each Agent Mode backend (Claude, Codex, opencode) so users can inject vars like CLAUDE_CONFIG_DIR, CODEX_HOME, XDG_CONFIG_HOME, or HTTPS_PROXY without polluting the parent shell. Overrides are merged onto process.env at spawn (Codex, opencode) or per prompt() (Claude SDK), and persisted through a shared sanitizer that enforces POSIX-style names, drops control chars, and caps the record at 64 entries. The editor debounces commits to avoid rewriting settings on every keystroke. Also relocates BinaryPathSetting into src/agentMode/backends/shared/ to honor the agent-mode layer boundaries. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
39 lines
1.6 KiB
TypeScript
39 lines
1.6 KiB
TypeScript
import { EnvOverridesSetting } from "@/agentMode/backends/shared/EnvOverridesSetting";
|
|
import type CopilotPlugin from "@/main";
|
|
import { getSettings, useSettingsValue } from "@/settings/model";
|
|
import type { App } from "obsidian";
|
|
import React from "react";
|
|
import { SimpleBackendSettingsPanel } from "@/agentMode/backends/shared/SimpleBackendSettingsPanel";
|
|
import { CodexInstallModal } from "./CodexInstallModal";
|
|
import { CODEX_BINARY_NAME, CODEX_INSTALL_COMMAND, updateCodexFields } from "./descriptor";
|
|
|
|
interface Props {
|
|
plugin: CopilotPlugin;
|
|
app: App;
|
|
}
|
|
|
|
export const CodexSettingsPanel: React.FC<Props> = ({ app }) => {
|
|
const settings = useSettingsValue();
|
|
return (
|
|
<>
|
|
<SimpleBackendSettingsPanel
|
|
displayName="Codex"
|
|
binaryName={CODEX_BINARY_NAME}
|
|
installCommand={CODEX_INSTALL_COMMAND}
|
|
pathPlaceholder="/absolute/path/to/codex-acp"
|
|
customPathTitle="Custom codex-acp path"
|
|
customPathDescription="Point Agent Mode at the codex-acp binary. Codex inherits auth from your local `codex login` credentials, or from `OPENAI_API_KEY` / `CODEX_API_KEY` exported in your shell."
|
|
readStoredPath={() => getSettings().agentMode?.backends?.codex?.binaryPath ?? ""}
|
|
persistPath={(path) => updateCodexFields({ binaryPath: path })}
|
|
openInstallModal={() => new CodexInstallModal(app).open()}
|
|
/>
|
|
|
|
<EnvOverridesSetting
|
|
backendDisplayName="Codex"
|
|
value={settings.agentMode?.backends?.codex?.envOverrides}
|
|
onChange={(next) => updateCodexFields({ envOverrides: next })}
|
|
hintExamples={["CODEX_HOME", "OPENAI_BASE_URL"]}
|
|
/>
|
|
</>
|
|
);
|
|
};
|