fix(core): preserve provider metadata namespaces (#35817)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
opencode-agent[bot] 2026-07-07 21:45:58 -05:00 committed by GitHub
commit ed4f833813
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 201 additions and 46 deletions

View file

@ -876,6 +876,7 @@ export const protocol = Protocol.make({
export const route = Route.make({
id: ADAPTER,
provider: "anthropic",
providerMetadataKey: "anthropic",
protocol,
endpoint: Endpoint.path(PATH, { baseURL: DEFAULT_BASE_URL }),
auth: Auth.none,

View file

@ -657,6 +657,7 @@ export const protocol = Protocol.make({
export const route = Route.make({
id: ADAPTER,
provider: "bedrock",
providerMetadataKey: "bedrock",
protocol,
// Bedrock's URL embeds the region in the route endpoint host and the
// validated modelId in the path. We read the validated body so the URL

View file

@ -500,6 +500,7 @@ export const protocol = Protocol.make({
export const route = Route.make({
id: ADAPTER,
provider: "google",
providerMetadataKey: "google",
protocol,
// Gemini's path embeds the model id and pins SSE framing at the URL level.
endpoint: Endpoint.path(({ request }) => `/models/${request.model.id}:streamGenerateContent?alt=sse`, {

View file

@ -493,6 +493,7 @@ export const httpTransport = HttpTransport.sseJson.with<OpenAIChatBody>()
export const route = Route.make({
id: ADAPTER,
provider: "openai",
providerMetadataKey: "openai",
protocol,
endpoint: Endpoint.path(PATH, { baseURL: DEFAULT_BASE_URL }),
auth: Auth.none,

View file

@ -16,6 +16,7 @@ export type OpenAICompatibleChatModelInput = RouteRoutedModelInput
*/
export const route = Route.make({
id: ADAPTER,
providerMetadataKey: "openai",
protocol: OpenAIChat.protocol,
endpoint: Endpoint.path("/chat/completions"),
framing: Framing.sse,

View file

@ -990,6 +990,7 @@ export const httpTransport = HttpTransport.sseJson.with<OpenAIResponsesBody>()
export const route = Route.make({
id: ADAPTER,
provider: "openai",
providerMetadataKey: "openai",
protocol,
endpoint,
auth,
@ -1018,6 +1019,7 @@ export const webSocketTransport = WebSocketTransport.jsonTransport.with<
export const webSocketRoute = Route.make({
id: `${ADAPTER}-websocket`,
provider: "openai",
providerMetadataKey: "openai",
protocol,
endpoint,
auth,

View file

@ -36,6 +36,8 @@ export interface RouteBody<Body> {
export interface Route<Body, Prepared = unknown> {
readonly id: string
readonly provider?: ProviderID
/** ProviderMetadata namespace emitted and consumed by this route. */
readonly providerMetadataKey?: string
readonly protocol: ProtocolID
readonly endpoint: Endpoint<Body>
readonly auth: AuthDef
@ -184,6 +186,8 @@ export interface MakeInput<Body, Frame, Event, State> {
readonly id: string
/** Provider identity for route-owned model construction. */
readonly provider?: string | ProviderID
/** ProviderMetadata namespace emitted and consumed by this route. */
readonly providerMetadataKey?: string
/** Semantic API contract — owns body construction, body schema, and parsing. */
readonly protocol: Protocol<Body, Frame, Event, State>
/** Where the request is sent. */
@ -203,6 +207,8 @@ export interface MakeTransportInput<Body, Prepared, Frame, Event, State> {
readonly id: string
/** Provider identity for route-owned model construction. */
readonly provider?: string | ProviderID
/** ProviderMetadata namespace emitted and consumed by this route. */
readonly providerMetadataKey?: string
/** Semantic API contract — owns body construction, body schema, and parsing. */
readonly protocol: Protocol<Body, Frame, Event, State>
/** Where the request is sent. */
@ -248,6 +254,7 @@ function makeFromTransport<Body, Prepared, Frame, Event, State>(
const route: Route<Body, Prepared> = {
id: routeInput.id,
provider: routeInput.provider === undefined ? undefined : ProviderID.make(routeInput.provider),
providerMetadataKey: routeInput.providerMetadataKey,
protocol: protocol.id,
endpoint: routeInput.endpoint,
auth: routeInput.auth ?? Auth.none,
@ -329,6 +336,7 @@ export function make<Body, Prepared, Frame, Event, State>(
return makeFromTransport({
id: input.id,
provider: input.provider,
providerMetadataKey: input.providerMetadataKey,
protocol,
endpoint: input.endpoint,
auth: input.auth,