* Disconnects this session and releases all in-memory resources (event handlers, * tool handlers, permission handlers). * * Session state on disk (conversation history, planning state, artifacts) is * preserved, so the conversation can be resumed later by calling * {@link Co
()
| 1299 | * ``` |
| 1300 | */ |
| 1301 | async disconnect(): Promise<void> { |
| 1302 | if (this.disconnected) { |
| 1303 | return; |
| 1304 | } |
| 1305 | await this.connection.sendRequest("session.destroy", { |
| 1306 | sessionId: this.sessionId, |
| 1307 | }); |
| 1308 | this._markDisconnected(); |
| 1309 | } |
| 1310 | |
| 1311 | /** Enables `await using session = ...` syntax for automatic cleanup. */ |
| 1312 | async [Symbol.asyncDispose](): Promise<void> { |