[TypeScript client] feat: RPC & in-memory clients#155
Draft
0xpolarzero wants to merge 54 commits into
Draft
Conversation
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 stacked on top of #153 (
[TypeScript client] feat: RPC & in-memory transports). Becausewevm/incurdoes not have that base branch and this PR targetsmain, the diff includes the commits from that prerequisite branch as well.This PR adds the public typed client surface on top of the runtime and transport foundation from PR #8.
Check the PR on my fork for reviewing from a stacked diff.
API
Full API example is available in this gist.
HTTP clients call a served CLI through a
HttpTransport, while exposing a command-aware client API:The command name,
args,options, anddatatype all come fromCommands.When the CLI is available in the same process, memory clients infer command names, args, and options directly from the concrete CLI:
Generated
Commandsdeclarations still provide the richest client surface, including declared output data and streaming metadata.Callers can also create a client directly from a transport factory:
Streaming
Streaming commands return an async iterable for chunks, plus a
finalpromise for the terminal result:Callers that need raw protocol records can use
records():Resources
The public client exposes resource discovery as methods rather than raw
transport.discover(...)requests:Resource scopes are typed from the command map, so command groups such as
'project'and leaf commands such as'project status'are accepted while unknown scopes are rejected.Local methods
Memory clients also expose local-only setup methods. These are intentionally not available on HTTP clients.
The
skillsandmcpnamespaces merge resource methods and memory-local methods on memory clients:Type generation
Typegen now emits an exported
Commandstype and augments bothincurandincur/clientwith the same command map:That lets users either pass
Commandsexplicitly:or rely on module augmentation when the generated declarations are loaded:
Changes
incur/clientnamespace surface forClient,HttpClient,MemoryClient,Run,Resources,Local,Rpc,Transport,HttpTransport, andMemoryTransport.Client.create(...),HttpClient.create(...), andMemoryClient.create(...).client.run(...)with command-name inference, required input enforcement, exact top-level/inner input key checks, output selection behavior, pagination helpers, CTA follow-up runs, and streaming return types.llms,llmsFull,schema,help,openapi, generated skills, and MCP tools.client/actions/*Actions.ts.ClientErrorand transport error handling to use the canonicalRpc.Errortype.Commandstype and augmentincur/client.incur/clientto TypeScript path resolution.Tests
Client.create,HttpClient.create,MemoryClient.create, run actions, resource actions, local actions, and transport/client composition.Client,HttpClient,MemoryClient,Run,Resources,Local, andTransport.unknown, streaming commands, resource scope narrowing, local-only method visibility, and transport capability types.Notes
HttpClient.create(...)exposes resource methods but not memory-local methods.MemoryClient.create(cli)exposes the same resource methods and also localskills.add/listandmcp.add.MemoryClient.create(cli)can infer command names, args, and options from a concrete CLI; callers can still pass an explicit command map when they need declared output or stream metadata.'project'narrow LLM manifests to that subtree.