feat: TypeScript RPC client#5
Closed
0xpolarzero wants to merge 6 commits into
Closed
Conversation
87299d9 to
2bd19e0
Compare
e49c1d1 to
01d974e
Compare
2bd19e0 to
80462ea
Compare
This was referenced May 22, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
This PR is part of a stacked PR chain.
Upstream merge PRs:
wevm/incur#144 ->
wevm/incur#145 ->
wevm/incur#143 ->
wevm/incur#147
Correctly based review stack in this fork:
#3 ->
#4 ->
#5 ->
#2
Overview
Adds a typed TypeScript client for incur RPC servers, including async-generator streaming support for generated clients and the structured RPC route.
OpenAPI-mounted fetch gateways are supported as typed client commands because the OpenAPI spec gives incur operation names, input shapes, and response types. Raw fetch gateways are not typed client commands because they accept arbitrary HTTP requests, not a known command schema. Calling a raw fetch gateway through structured RPC returns
FETCH_GATEWAY_UNSUPPORTED.Maintainer Note: Client Error Compatibility
ClientErroris now exported, but itsdataanderrorfields intentionally stay broad at the class boundary. Existing client failures can carry non-ideal shapes: malformed JSON leaves raw response text indata, malformed envelopes leave arbitrary payloads indata, and failed RPC envelopes may expose whatever the server returned inerror.That compatibility slop is deliberate for this PR. We can remove it later by making
ClientErroronly expose strongly typed RPC envelopes/errors, but that would be a breaking change for callers that already inspect the current thrown shape.Maintainer Note: Stream Detection
Streaming typegen detection is based on actual
async *runhandlers. A wrapper likerun() { return stream() }is not emitted asstream: true.API
Changes
createClient({ baseUrl, fetch? }).createClientgeneric over a generated command map.Commandswhile preservingRegister.commandsaugmentation.outputtypes for client return values..command(..., { fetch, openapi })registration, soTypegen.fromCli(cli)andincur gensee those operations without first serving the CLI. This moves local spec dereferencing/schema construction to CLI construction time for OpenAPI mounts.stream: truemetadata in typegen.application/x-ndjsonhandling for RPC stream responses.Tests
createClient.