({
cwd,
mcpServers,
}: acp.NewSessionRequest)
| 109 | } |
| 110 | |
| 111 | async newSession({ |
| 112 | cwd, |
| 113 | mcpServers, |
| 114 | }: acp.NewSessionRequest): Promise<acp.NewSessionResponse> { |
| 115 | const sessionId = randomUUID(); |
| 116 | const config = await this.newSessionConfig(sessionId, cwd, mcpServers); |
| 117 | |
| 118 | let isAuthenticated = false; |
| 119 | if (this.settings.merged.selectedAuthType) { |
| 120 | try { |
| 121 | await config.refreshAuth(this.settings.merged.selectedAuthType); |
| 122 | isAuthenticated = true; |
| 123 | } catch (e) { |
| 124 | console.error(`Authentication failed: ${e}`); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | if (!isAuthenticated) { |
| 129 | throw acp.RequestError.authRequired(); |
| 130 | } |
| 131 | |
| 132 | const anusClient = config.getAnusClient(); |
| 133 | const chat = await anusClient.startChat(); |
| 134 | const session = new Session(sessionId, chat, config, this.client); |
| 135 | this.sessions.set(sessionId, session); |
| 136 | |
| 137 | return { |
| 138 | sessionId, |
| 139 | }; |
| 140 | } |
| 141 | |
| 142 | async newSessionConfig( |
| 143 | sessionId: string, |
nothing calls this directly
no test coverage detected