* Handles an elicitation.requested broadcast event. * Invokes the registered handler and responds via handlePendingElicitation RPC. * @internal
(context: ElicitationContext, requestId: string)
| 940 | * @internal |
| 941 | */ |
| 942 | async _handleElicitationRequest(context: ElicitationContext, requestId: string): Promise<void> { |
| 943 | if (!this.elicitationHandler) { |
| 944 | return; |
| 945 | } |
| 946 | try { |
| 947 | const result = await this.elicitationHandler(context); |
| 948 | await this.rpc.ui.handlePendingElicitation({ requestId, result }); |
| 949 | } catch { |
| 950 | // Handler failed — attempt to cancel so the request doesn't hang |
| 951 | try { |
| 952 | await this.rpc.ui.handlePendingElicitation({ |
| 953 | requestId, |
| 954 | result: { action: "cancel" }, |
| 955 | }); |
| 956 | } catch (rpcError) { |
| 957 | if (!(rpcError instanceof ConnectionError || rpcError instanceof ResponseError)) { |
| 958 | throw rpcError; |
| 959 | } |
| 960 | // Connection lost or RPC error — nothing we can do |
| 961 | } |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | /** |
| 966 | * Handles an exitPlanMode.request callback from the runtime. |
no test coverage detected