| 3531 | : defaultElicitationHandler; |
| 3532 | |
| 3533 | const buildElicit = ( |
| 3534 | address: ToolAddress, |
| 3535 | args: unknown, |
| 3536 | handler: ElicitationHandler, |
| 3537 | ): Elicit => { |
| 3538 | return (request: ElicitationRequest) => |
| 3539 | Effect.gen(function* () { |
| 3540 | const response: ElicitationResponse = yield* handler({ |
| 3541 | address, |
| 3542 | args, |
| 3543 | request, |
| 3544 | }); |
| 3545 | if (response.action !== "accept") { |
| 3546 | return yield* new ElicitationDeclinedError({ |
| 3547 | address, |
| 3548 | action: response.action, |
| 3549 | }); |
| 3550 | } |
| 3551 | return response; |
| 3552 | }); |
| 3553 | }; |
| 3554 | |
| 3555 | // The single source of truth for "will enforceApproval pause this call". |
| 3556 | // Read before pre-approval arg validation so the extra validation pass |