| 3267 | : defaultElicitationHandler; |
| 3268 | |
| 3269 | const buildElicit = ( |
| 3270 | address: ToolAddress, |
| 3271 | args: unknown, |
| 3272 | handler: ElicitationHandler, |
| 3273 | ): Elicit => { |
| 3274 | return (request: ElicitationRequest) => |
| 3275 | Effect.gen(function* () { |
| 3276 | const response: ElicitationResponse = yield* handler({ |
| 3277 | address, |
| 3278 | args, |
| 3279 | request, |
| 3280 | }); |
| 3281 | if (response.action !== "accept") { |
| 3282 | return yield* new ElicitationDeclinedError({ |
| 3283 | address, |
| 3284 | action: response.action, |
| 3285 | }); |
| 3286 | } |
| 3287 | return response; |
| 3288 | }); |
| 3289 | }; |
| 3290 | |
| 3291 | // The single source of truth for "will enforceApproval pause this call". |
| 3292 | // Read before pre-approval arg validation so the extra validation pass |