(chunk: StreamChunk)
| 807 | } |
| 808 | |
| 809 | observeChunk(chunk: StreamChunk): void { |
| 810 | if (chunk.type === 'RUN_STARTED') { |
| 811 | this.beginRun(chunk.runId, chunk.threadId) |
| 812 | return |
| 813 | } |
| 814 | |
| 815 | if (chunk.type === 'RUN_FINISHED' || chunk.type === 'RUN_ERROR') { |
| 816 | const runId = |
| 817 | chunk.type === 'RUN_FINISHED' |
| 818 | ? chunk.runId |
| 819 | : (chunk as { runId?: string }).runId |
| 820 | if (!runId || runId === this.currentRunId) { |
| 821 | const context = this.getCurrentRunEventContext() |
| 822 | if (context) { |
| 823 | this.lastRunEventContext = context |
| 824 | } |
| 825 | this.currentRunId = null |
| 826 | this.currentRunThreadId = null |
| 827 | } |
| 828 | } |
| 829 | } |
| 830 | |
| 831 | getCurrentRunEventContext(): ChatClientRunEventContext | undefined { |
| 832 | if (!this.currentRunId) return undefined |
no test coverage detected