(extraHistory?: Content[])
| 226 | } |
| 227 | |
| 228 | async startChat(extraHistory?: Content[]): Promise<AnusChat> { |
| 229 | this.forceFullIdeContext = true; |
| 230 | const envParts = await getEnvironmentContext(this.config); |
| 231 | const toolRegistry = await this.config.getToolRegistry(); |
| 232 | const toolDeclarations = toolRegistry.getFunctionDeclarations(); |
| 233 | const tools: Tool[] = [{ functionDeclarations: toolDeclarations }]; |
| 234 | const history: Content[] = [ |
| 235 | { |
| 236 | role: 'user', |
| 237 | parts: envParts, |
| 238 | }, |
| 239 | { |
| 240 | role: 'model', |
| 241 | parts: [{ text: 'Got it. Thanks for the context!' }], |
| 242 | }, |
| 243 | ...(extraHistory ?? []), |
| 244 | ]; |
| 245 | try { |
| 246 | const userMemory = this.config.getUserMemory(); |
| 247 | const baseSystem = getCoreSystemPrompt(userMemory); |
| 248 | const systemInstruction = `${baseSystem}\n\nYou are ANUS, the terminal AI assistant.\nProvider: Grok\nActive model: ${this.config.getModel()}\nRules: Never claim to be Anus or Google models. If asked "what model are you running?", answer with the exact Active model string and 'Grok' as provider.`; |
| 249 | const generateContentConfigWithThinking = isThinkingSupported( |
| 250 | this.config.getModel(), |
| 251 | ) |
| 252 | ? { |
| 253 | ...this.generateContentConfig, |
| 254 | thinkingConfig: { |
| 255 | includeThoughts: true, |
| 256 | }, |
| 257 | } |
| 258 | : this.generateContentConfig; |
| 259 | return new AnusChat( |
| 260 | this.config, |
| 261 | this.getContentGenerator(), |
| 262 | { |
| 263 | systemInstruction, |
| 264 | ...generateContentConfigWithThinking, |
| 265 | tools, |
| 266 | }, |
| 267 | history, |
| 268 | ); |
| 269 | } catch (error) { |
| 270 | await reportError( |
| 271 | error, |
| 272 | 'Error initializing Anus chat session.', |
| 273 | history, |
| 274 | 'startChat', |
| 275 | ); |
| 276 | throw new Error(`Failed to initialize chat: ${getErrorMessage(error)}`); |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | private getIdeContextParts(forceFullContext: boolean): { |
| 281 | contextParts: string[]; |
no test coverage detected