(payload: {
clientId?: string
threadId?: string
runId?: string
streamId: string
messageId: string
requestId?: string
timestamp: number
source?: string
status: 'streaming' | 'complete' | 'error'
raw?: string
partial?: unknown
data?: unknown
reasoning?: string
errorMessage?: string
delta?: string
})
| 1869 | ) |
| 1870 | |
| 1871 | const recordStructuredOutput = (payload: { |
| 1872 | clientId?: string |
| 1873 | threadId?: string |
| 1874 | runId?: string |
| 1875 | streamId: string |
| 1876 | messageId: string |
| 1877 | requestId?: string |
| 1878 | timestamp: number |
| 1879 | source?: string |
| 1880 | status: 'streaming' | 'complete' | 'error' |
| 1881 | raw?: string |
| 1882 | partial?: unknown |
| 1883 | data?: unknown |
| 1884 | reasoning?: string |
| 1885 | errorMessage?: string |
| 1886 | delta?: string |
| 1887 | }) => { |
| 1888 | const { |
| 1889 | clientId, |
| 1890 | threadId, |
| 1891 | runId, |
| 1892 | streamId, |
| 1893 | messageId, |
| 1894 | requestId, |
| 1895 | timestamp, |
| 1896 | } = payload |
| 1897 | |
| 1898 | if (clientId && streamId) { |
| 1899 | streamToConversation.set(streamId, clientId) |
| 1900 | } |
| 1901 | |
| 1902 | const source = normalizeMessageSource( |
| 1903 | payload.source, |
| 1904 | clientId ? 'client' : 'server', |
| 1905 | ) |
| 1906 | const conversationIds = getStructuredOutputConversationIds({ |
| 1907 | clientId, |
| 1908 | threadId, |
| 1909 | streamId, |
| 1910 | messageId, |
| 1911 | }) |
| 1912 | |
| 1913 | for (const conversationId of conversationIds) { |
| 1914 | if (!state.conversations[conversationId]) { |
| 1915 | getOrCreateConversation( |
| 1916 | conversationId, |
| 1917 | conversationId === clientId && source === 'client' |
| 1918 | ? 'client' |
| 1919 | : 'server', |
| 1920 | conversationId === clientId && source === 'client' |
| 1921 | ? `Client Chat (${conversationId.substring(0, 8)})` |
| 1922 | : `Server Chat (${conversationId.substring(0, 8)})`, |
| 1923 | ) |
| 1924 | } |
| 1925 | |
| 1926 | attachRunToConversation(conversationId, runId) |
| 1927 | const messageIndex = upsertStructuredOutputPart(conversationId, { |
| 1928 | messageId, |
no test coverage detected