| 3515 | : defaultElicitationHandler; |
| 3516 | |
| 3517 | const buildElicit = ( |
| 3518 | address: ToolAddress, |
| 3519 | args: unknown, |
| 3520 | handler: ElicitationHandler, |
| 3521 | ): Elicit => { |
| 3522 | return (request: ElicitationRequest) => |
| 3523 | Effect.gen(function* () { |
| 3524 | const response: ElicitationResponse = yield* handler({ |
| 3525 | address, |
| 3526 | args, |
| 3527 | request, |
| 3528 | }); |
| 3529 | if (response.action !== "accept") { |
| 3530 | return yield* new ElicitationDeclinedError({ |
| 3531 | address, |
| 3532 | action: response.action, |
| 3533 | }); |
| 3534 | } |
| 3535 | return response; |
| 3536 | }); |
| 3537 | }; |
| 3538 | |
| 3539 | // The single source of truth for "will enforceApproval pause this call". |
| 3540 | // Read before pre-approval arg validation so the extra validation pass |