Initialize a new CopilotClient. All process-management options (``working_directory``, ``log_level``, ``env``, ``github_token``, …) apply only when the SDK spawns the runtime (stdio / tcp connections). They are ignored when connecting to an existing runtime
(
self,
*,
connection: RuntimeConnection | None = None,
working_directory: str | None = None,
log_level: LogLevel = "info",
env: dict[str, str] | None = None,
github_token: str | None = None,
base_directory: str | None = None,
use_logged_in_user: bool | None = None,
telemetry: TelemetryConfig | None = None,
session_fs: SessionFsConfig | None = None,
request_handler: CopilotRequestHandler | None = None,
session_idle_timeout_seconds: int | None = None,
enable_remote_sessions: bool = False,
on_list_models: Callable[[], list[ModelInfo] | Awaitable[list[ModelInfo]]] | None = None,
mode: CopilotClientMode = "copilot-cli",
)
| 1094 | """ |
| 1095 | |
| 1096 | def __init__( |
| 1097 | self, |
| 1098 | *, |
| 1099 | connection: RuntimeConnection | None = None, |
| 1100 | working_directory: str | None = None, |
| 1101 | log_level: LogLevel = "info", |
| 1102 | env: dict[str, str] | None = None, |
| 1103 | github_token: str | None = None, |
| 1104 | base_directory: str | None = None, |
| 1105 | use_logged_in_user: bool | None = None, |
| 1106 | telemetry: TelemetryConfig | None = None, |
| 1107 | session_fs: SessionFsConfig | None = None, |
| 1108 | request_handler: CopilotRequestHandler | None = None, |
| 1109 | session_idle_timeout_seconds: int | None = None, |
| 1110 | enable_remote_sessions: bool = False, |
| 1111 | on_list_models: Callable[[], list[ModelInfo] | Awaitable[list[ModelInfo]]] | None = None, |
| 1112 | mode: CopilotClientMode = "copilot-cli", |
| 1113 | ): |
| 1114 | """ |
| 1115 | Initialize a new CopilotClient. |
| 1116 | |
| 1117 | All process-management options (``working_directory``, ``log_level``, |
| 1118 | ``env``, ``github_token``, …) apply only when the SDK spawns the runtime |
| 1119 | (stdio / tcp connections). They are ignored when connecting to an |
| 1120 | existing runtime via :meth:`RuntimeConnection.for_uri`. |
| 1121 | |
| 1122 | Args: |
| 1123 | connection: How to reach the runtime. Defaults to |
| 1124 | :meth:`RuntimeConnection.for_stdio` with the bundled binary. |
| 1125 | working_directory: Working directory for the runtime process. |
| 1126 | ``None`` uses the current directory. |
| 1127 | log_level: Log level for the runtime process. Defaults to ``"info"``. |
| 1128 | env: Environment variables for the runtime process. ``None`` inherits |
| 1129 | the current env. |
| 1130 | github_token: GitHub token for authentication. Takes priority over |
| 1131 | other auth methods. |
| 1132 | base_directory: Base directory for Copilot data (session state, |
| 1133 | config, etc.). Sets the ``COPILOT_HOME`` environment variable on |
| 1134 | the spawned runtime. When ``None``, the runtime defaults to |
| 1135 | ``~/.copilot``. |
| 1136 | use_logged_in_user: Use the logged-in user for authentication. |
| 1137 | ``None`` (default) resolves to ``True`` unless ``github_token`` |
| 1138 | is set. |
| 1139 | telemetry: OpenTelemetry configuration. Providing this enables |
| 1140 | telemetry. |
| 1141 | session_fs: Connection-level session filesystem provider |
| 1142 | configuration. |
| 1143 | request_handler: Connection-level request handler. When set, the |
| 1144 | supplied handler services every model-layer HTTP/WebSocket |
| 1145 | request the runtime would otherwise issue (both BYOK and CAPI). |
| 1146 | session_idle_timeout_seconds: Server-wide session idle timeout in |
| 1147 | seconds. Sessions without activity for this duration are |
| 1148 | automatically cleaned up. Set to ``None`` or ``0`` to disable. |
| 1149 | enable_remote_sessions: Enable remote session support (Mission |
| 1150 | Control integration). When ``True``, sessions in a GitHub |
| 1151 | repository working directory are accessible from GitHub web |
| 1152 | and mobile. |
| 1153 | on_list_models: Custom handler for :meth:`list_models`. When |
no test coverage detected