feat: add native provider packages

This commit is contained in:
Shoubhit Dash 2026-06-29 22:18:04 +05:30
commit 3b63568da2
88 changed files with 1946 additions and 1751 deletions

View file

@ -1,9 +1,8 @@
export * as Model from "./model"
import { Schema } from "effect"
import { optional } from "./schema"
import { optional, statics } from "./schema"
import { Provider } from "./provider"
import { statics } from "./schema"
export const ID = Schema.String.pipe(Schema.brand("ModelV2.ID"))
export type ID = typeof ID.Type
@ -42,36 +41,23 @@ export const Cost = Schema.Struct({
}),
}).annotate({ identifier: "Model.Cost" })
export const Api = Schema.Union([
Schema.Struct({
id: ID,
...Provider.AISDK.fields,
}),
Schema.Struct({
id: ID,
...Provider.Native.fields,
}),
])
.pipe(Schema.toTaggedUnion("type"))
.annotate({ identifier: "Model.Api" })
export type Api = typeof Api.Type
export interface Variant extends Schema.Schema.Type<typeof Variant> {}
export const Variant = Schema.Struct({
id: VariantID,
...Provider.Overlays,
}).annotate({ identifier: "Model.Variant" })
export interface Info extends Schema.Schema.Type<typeof Info> {}
export const Info = Schema.Struct({
id: ID,
modelID: ID.pipe(optional),
providerID: Provider.ID,
family: Family.pipe(optional),
name: Schema.String,
api: Api,
package: Provider.Package.pipe(optional),
...Provider.Overlays,
capabilities: Capabilities,
request: Schema.Struct({
...Provider.Request.fields,
variant: Schema.String.pipe(optional),
}),
variants: Schema.Struct({
id: VariantID,
...Provider.Request.fields,
}).pipe(Schema.Array),
variants: Schema.Array(Variant).pipe(optional),
time: Schema.Struct({
released: Schema.Finite,
}),
@ -87,15 +73,12 @@ export const Info = Schema.Struct({
.annotate({ identifier: "ModelV2.Info" })
.pipe(
statics((schema) => ({
empty: (providerID: Provider.ID, modelID: ID) =>
empty: (providerID: Provider.ID, id: ID) =>
schema.make({
id: modelID,
id,
providerID,
name: modelID,
api: { id: modelID, type: "native", settings: {} },
name: id,
capabilities: { tools: false, input: [], output: [] },
request: { headers: {}, body: {} },
variants: [],
time: { released: 0 },
cost: [],
status: "active",

View file

@ -1,9 +1,8 @@
export * as Provider from "./provider"
import { Schema } from "effect"
import { optional } from "./schema"
import { Integration } from "./integration"
import { statics } from "./schema"
import { optional, statics } from "./schema"
export const ID = Schema.String.pipe(
Schema.brand("ProviderV2.ID"),
@ -23,25 +22,14 @@ export const ID = Schema.String.pipe(
)
export type ID = typeof ID.Type
export interface AISDK extends Schema.Schema.Type<typeof AISDK> {}
export const AISDK = Schema.Struct({
type: Schema.Literal("aisdk"),
package: Schema.String,
url: Schema.String.pipe(optional),
export const Package = Schema.String
export type Package = typeof Package.Type
export const Overlays = {
settings: Schema.Record(Schema.String, Schema.Unknown).pipe(optional),
}).annotate({ identifier: "Provider.AISDK" })
export interface Native extends Schema.Schema.Type<typeof Native> {}
export const Native = Schema.Struct({
type: Schema.Literal("native"),
url: Schema.String.pipe(optional),
settings: Schema.Record(Schema.String, Schema.Unknown),
}).annotate({ identifier: "Provider.Native" })
export const Api = Schema.Union([AISDK, Native])
.pipe(Schema.toTaggedUnion("type"))
.annotate({ identifier: "Provider.Api" })
export type Api = typeof Api.Type
headers: Schema.Record(Schema.String, Schema.String).pipe(optional),
body: Schema.Record(Schema.String, Schema.Unknown).pipe(optional),
}
export interface Request extends Schema.Schema.Type<typeof Request> {}
export const Request = Schema.Struct({
@ -55,18 +43,12 @@ export const Info = Schema.Struct({
integrationID: Integration.ID.pipe(optional),
name: Schema.String,
disabled: Schema.Boolean.pipe(optional),
api: Api,
request: Request,
package: Package,
...Overlays,
})
.annotate({ identifier: "ProviderV2.Info" })
.pipe(
statics((schema) => ({
empty: (id: ID) =>
schema.make({
id,
name: id,
api: { type: "native", settings: {} },
request: { headers: {}, body: {} },
}),
empty: (id: ID) => schema.make({ id, name: id, package: "" }),
})),
)

View file

@ -40,7 +40,7 @@ describe("contract hygiene", () => {
Model.Ref,
Model.Capabilities,
Model.Cost,
Model.Api,
Model.Variant,
Project.Icon,
Project.Commands,
Project.Time,