| 676 | const runId = randomUUID(); |
| 677 | let unsubscribe = () => undefined; |
| 678 | const waitForQueuedAgentEvents = async (): Promise<void> => { |
| 679 | const maybeQueue = (cs.session as { _agentEventQueue?: unknown }) |
| 680 | ._agentEventQueue; |
| 681 | if ( |
| 682 | !maybeQueue || |
| 683 | typeof (maybeQueue as Promise<unknown>).then !== "function" |
| 684 | ) { |
| 685 | return; |
| 686 | } |
| 687 | |
| 688 | try { |
| 689 | await maybeQueue; |
| 690 | } catch (error) { |
| 691 | log("[PackAgent] Waiting for queued agent events failed:", error); |
| 692 | } |
| 693 | }; |
| 694 | |
| 695 | try { |
| 696 | if (this.pendingAbortChannels.delete(channelId)) { |