(history: ChatHistoryItem[] = [])
| 555 | * Start a new session with a new sessionId |
| 556 | */ |
| 557 | export function startNewSession(history: ChatHistoryItem[] = []): Session { |
| 558 | const manager = SessionManager.getInstance(); |
| 559 | |
| 560 | // Clear the current session from memory (don't delete the file) |
| 561 | manager.clear(); |
| 562 | |
| 563 | // Create a new session with a new sessionId |
| 564 | const newSession: Session = { |
| 565 | sessionId: uuidv4(), |
| 566 | title: DEFAULT_SESSION_TITLE, |
| 567 | workspaceDirectory: process.cwd(), |
| 568 | history, |
| 569 | usage: { |
| 570 | totalCost: 0, |
| 571 | promptTokens: 0, |
| 572 | completionTokens: 0, |
| 573 | promptTokensDetails: { |
| 574 | cachedTokens: 0, |
| 575 | cacheWriteTokens: 0, |
| 576 | }, |
| 577 | }, |
| 578 | }; |
| 579 | |
| 580 | manager.setSession(newSession); |
| 581 | return newSession; |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Track cost for the current session |
no test coverage detected