Emit ``system/init`` — the first message the client sees on connect.
(self)
| 154 | # ─── init ────────────────────────────────────────────────────────────── |
| 155 | |
| 156 | def emit_init(self) -> None: |
| 157 | """Emit ``system/init`` — the first message the client sees on connect.""" |
| 158 | tools = _tool_schemas(self.tool_registry) |
| 159 | self._emit({ |
| 160 | "type": "system", |
| 161 | "subtype": "init", |
| 162 | "session_id": self.session_id, |
| 163 | "protocol_version": PROTOCOL_VERSION, |
| 164 | "model": getattr(self.provider, "model", self.config.model), |
| 165 | "provider": self.provider_name, |
| 166 | "cwd": self.cwd, |
| 167 | "tools": tools, |
| 168 | "permission_mode": _current_mode(self.tool_context, self.config.permission_mode), |
| 169 | "apiKeySource": "config", |
| 170 | }) |
| 171 | if self.init_error is not None: |
| 172 | self._emit(_system_message(self.session_id, self.init_error, level="error")) |
| 173 | |
| 174 | # ─── inbound (main loop) ─────────────────────────────────────────────── |
| 175 |
no test coverage detected