Pass environment variables to the Claude CLI via options.

This commit is contained in:
Lee YongSeok 2025-07-01 21:31:41 +09:00
parent 4af210ee8f
commit a3511eb526
2 changed files with 3 additions and 2 deletions

View file

@ -129,7 +129,7 @@ class SubprocessCLITransport(Transport):
stdout=PIPE, stdout=PIPE,
stderr=PIPE, stderr=PIPE,
cwd=self._cwd, cwd=self._cwd,
env={**os.environ, "CLAUDE_CODE_ENTRYPOINT": "sdk-py"}, env={**os.environ, **self._options.envvars, "CLAUDE_CODE_ENTRYPOINT": "sdk-py"},
) )
if self._process.stdout: if self._process.stdout:

View file

@ -2,7 +2,7 @@
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import Any, Literal, TypedDict from typing import Any, Literal, TypedDict, Dict
from typing_extensions import NotRequired # For Python < 3.11 compatibility from typing_extensions import NotRequired # For Python < 3.11 compatibility
@ -127,3 +127,4 @@ class ClaudeCodeOptions:
model: str | None = None model: str | None = None
permission_prompt_tool_name: str | None = None permission_prompt_tool_name: str | None = None
cwd: str | Path | None = None cwd: str | Path | None = None
envvars: Dict[str, str] | None = None