(id: string)
| 1878 | // Task history |
| 1879 | |
| 1880 | async getTaskWithId(id: string): Promise<{ |
| 1881 | historyItem: HistoryItem |
| 1882 | taskDirPath: string |
| 1883 | apiConversationHistoryFilePath: string |
| 1884 | uiMessagesFilePath: string |
| 1885 | apiConversationHistory: Anthropic.MessageParam[] |
| 1886 | }> { |
| 1887 | const historyItem = |
| 1888 | this.taskHistoryStore.get(id) ?? (this.getGlobalState("taskHistory") ?? []).find((item) => item.id === id) |
| 1889 | |
| 1890 | if (!historyItem) { |
| 1891 | throw new Error("Task not found") |
| 1892 | } |
| 1893 | |
| 1894 | const { getTaskDirectoryPath } = await import("../../utils/storage") |
| 1895 | const globalStoragePath = this.contextProxy.globalStorageUri.fsPath |
| 1896 | const taskDirPath = await getTaskDirectoryPath(globalStoragePath, id) |
| 1897 | const apiConversationHistoryFilePath = path.join(taskDirPath, GlobalFileNames.apiConversationHistory) |
| 1898 | const uiMessagesFilePath = path.join(taskDirPath, GlobalFileNames.uiMessages) |
| 1899 | const fileExists = await fileExistsAtPath(apiConversationHistoryFilePath) |
| 1900 | |
| 1901 | let apiConversationHistory: Anthropic.MessageParam[] = [] |
| 1902 | |
| 1903 | if (fileExists) { |
| 1904 | try { |
| 1905 | apiConversationHistory = JSON.parse(await fs.readFile(apiConversationHistoryFilePath, "utf8")) |
| 1906 | } catch (error) { |
| 1907 | console.warn( |
| 1908 | `[getTaskWithId] api_conversation_history.json corrupted for task ${id}, returning empty history: ${error instanceof Error ? error.message : String(error)}`, |
| 1909 | ) |
| 1910 | } |
| 1911 | } else { |
| 1912 | console.warn( |
| 1913 | `[getTaskWithId] api_conversation_history.json missing for task ${id}, returning empty history`, |
| 1914 | ) |
| 1915 | } |
| 1916 | |
| 1917 | return { |
| 1918 | historyItem, |
| 1919 | taskDirPath, |
| 1920 | apiConversationHistoryFilePath, |
| 1921 | uiMessagesFilePath, |
| 1922 | apiConversationHistory, |
| 1923 | } |
| 1924 | } |
| 1925 | |
| 1926 | async getTaskWithAggregatedCosts(taskId: string): Promise<{ |
| 1927 | historyItem: HistoryItem |
no test coverage detected