| 145 | } |
| 146 | |
| 147 | async cancelCurrentRun(): Promise<CancelRunResult> { |
| 148 | const run = this.currentRun |
| 149 | |
| 150 | if (!run) { |
| 151 | return { cancelled: false, reason: "No active run to cancel." } |
| 152 | } |
| 153 | |
| 154 | if (!run.supports("cancel")) { |
| 155 | return { |
| 156 | cancelled: false, |
| 157 | reason: run.unsupportedReason("cancel") ?? "This run cannot be cancelled.", |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | await run.cancel() |
| 162 | return { cancelled: true } |
| 163 | } |
| 164 | |
| 165 | async sendPrompt({ prompt, onEvent }: SendPromptOptions) { |
| 166 | await this.ensureAgentFresh() |