feat(ai): add Models runtime with provider-owned auth (phase 1)

New Models/MutableModels/createModels collection: provider map, async
model listing (best-effort aggregation), getAuth decision tree with
double-checked locked OAuth refresh, stream/complete with per-field
auth merge over lazyStream.

Auth substrate: ProviderAuth { apiKey?, oauth? }, one type-tagged
credential per provider, CredentialStore (read/modify/delete; modify
is the only write path, serialized RMW), OAuthAuth login/refresh/toAuth
split, prompt()/notify() login callbacks, browser-safe default
AuthContext.

types.ts: Provider alias renamed to ProviderId; ApiOptionsMap and
ApiStreamOptions<TApi> for typed per-API stream options; hasApi()
runtime narrowing guard.
This commit is contained in:
Mario Zechner
2026-06-10 18:49:10 +02:00
parent 7498b216d9
commit f63095cfff
10 changed files with 1427 additions and 92 deletions
+4
View File
@@ -1,7 +1,11 @@
export type { Static, TSchema } from "typebox";
export { Type } from "typebox";
export * from "./api/lazy.ts";
export * from "./api-registry.ts";
export * from "./auth/context.ts";
export * from "./auth/credential-store.ts";
export * from "./auth/types.ts";
export * from "./env-api-keys.ts";
export * from "./image-models.ts";
export * from "./images.ts";