Repository navigation
refactor(ai): reuse JsonObject, ProviderMetadata, and responseHttp across protocols and gateways - #57615
Merged
Conversation
…ross protocols and gateways
Contributor
There was a problem hiding this comment.
This looks sound to me. I checked each replaced inline schema against the shared definition, and they match: JsonObject and ProviderOptions are Record(String, Unknown), and ProviderMetadata is the same nested record. ProviderShared.totalTokens(in, out, undefined) also matches the old inline sum. responseHttp now turns header values into strings, as the executor path already did. Moving it into executor-service.ts doesn't create a new import cycle. In packages/ai, bun run typecheck passes and bun test gives 1826 pass, 0 fail.
Public API: unchanged. route/index.ts still re-exports only responseHttp and Service from executor.ts, so headerDetails stays internal.
This was referenced Oct 21, 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.
Problem
Several AI gateway, experimental, media, and protocol modules duplicated inline
Schema.Record(...)definitions (JsonObject,ProviderMetadata,ProviderOptions), manualHttpContextconstruction fromHttpClientResponse, and manualtotalTokenssummation instead of reusing the shared helpers inprotocols/shared.ts,schema/options.ts, androute/executor.ts.Change
Reuse
JsonObject,ProviderMetadata,ProviderOptions,ProviderShared.totalTokens, andresponseHttpacrosssystem-one.ts,vercel-ai-gateway.ts,realtime.ts,route/media-protocol.ts,media.ts, andprotocols/venice-chat.ts.packages/ai/src/ ├── experimental/ │ ├── realtime.ts # RequestExecutor.responseHttp(res) │ └── system-one.ts # JsonObject, ProviderMetadata, RequestExecutor.responseHttp, ProviderShared.totalTokens ├── media.ts # responseHttp(response) via route/executor-service.ts ├── protocols/ │ └── venice-chat.ts # [JsonObject] rest schemas ├── providers/ │ └── vercel-ai-gateway.ts # ProviderMetadata, ProviderOptions, JsonObject, RequestExecutor.responseHttp └── route/ ├── executor-service.ts # hosts leaf responseHttp + headerDetails to avoid schema/media cycle ├── executor.ts # re-exports responseHttp └── media-protocol.ts # RequestExecutor.responseHttp(response)system-one,vercel-ai-gateway,venice-chat)[Schema.Record(Schema.String, Schema.Any | Schema.Unknown)][JsonObject]system-one,vercel-ai-gateway)Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Unknown))ProviderMetadataproviderOptions(vercel-ai-gateway)Schema.Record(Schema.String, Schema.Unknown)ProviderOptionssystem-one,vercel-ai-gateway,realtime,media-protocol,media)new HttpContext({ url, status, headers })RequestExecutor.responseHttp(res)/responseHttp(res)system-one)input_tokens + output_tokensProviderShared.totalTokens(...)Out of scope