Created
December 31, 2025 19:05
-
-
Save DogPawHat/93657dca392e8303b19e59146809617b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mapAgentStatusToAgentResponse = Effect.flatMap( | |
| (response: AgentStatusResponse) => | |
| Match.value(response).pipe( | |
| Match.when({ status: "completed" }, (mappedResponse) => | |
| Schema.decodeUnknown(AgentResponseCompleted)({ | |
| data: mappedResponse?.data, | |
| expiresAt: mappedResponse?.expiresAt, | |
| }), | |
| ), | |
| Match.when({ status: "processing" }, (mappedResponse) => | |
| Schema.decodeUnknown(AgentResponsePending)({ | |
| expiresAt: mappedResponse?.expiresAt, | |
| }), | |
| ), | |
| Match.when({ status: "failed" }, (mappedResponse) => | |
| Effect.gen(function* () { | |
| // Ok, this shit is hilarious. | |
| return yield* yield* Schema.decodeUnknown(AgentResponseFailedError)({ | |
| errorMessage: mappedResponse?.error, | |
| expiresAt: mappedResponse?.expiresAt, | |
| }); | |
| }), | |
| ), | |
| Match.exhaustive, | |
| ), | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment