| 145 | } |
| 146 | |
| 147 | func handleProgressEvent(event any) { |
| 148 | switch e := event.(type) { |
| 149 | case *types.ProgressTextChunkEvent: |
| 150 | fmt.Print(e.Delta) |
| 151 | case *types.ProgressTextChunkStartEvent: |
| 152 | fmt.Print("\n[Assistant] ") |
| 153 | case *types.ProgressTextChunkEndEvent: |
| 154 | // 文本块结束 |
| 155 | case *types.ProgressToolStartEvent: |
| 156 | fmt.Printf("\n[Tool Start] %s (ID: %s)\n", e.Call.Name, e.Call.ID) |
| 157 | case *types.ProgressToolEndEvent: |
| 158 | fmt.Printf("[Tool End] %s - State: %s\n", e.Call.Name, e.Call.State) |
| 159 | case *types.ProgressToolErrorEvent: |
| 160 | fmt.Printf("[Tool Error] %s - Error: %s\n", e.Call.Name, e.Error) |
| 161 | case *types.ProgressDoneEvent: |
| 162 | fmt.Printf("\n[Done] Step %d - Reason: %s\n", e.Step, e.Reason) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | func handleMonitorEvent(event any) { |
| 167 | switch e := event.(type) { |