feat(core): add embedded v2 session runtime and tool foundation (#30632)

This commit is contained in:
Kit Langton 2026-06-03 23:02:17 -04:00 committed by GitHub
commit 76ee87ead8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
215 changed files with 31398 additions and 3332 deletions

View file

@ -41,6 +41,20 @@ export const Native = Schema.Struct({
export const Api = Schema.Union([AISDK, Native]).pipe(Schema.toTaggedUnion("type"))
export type Api = typeof Api.Type
export const PublicAISDK = Schema.Struct({
type: Schema.Literal("aisdk"),
package: Schema.String,
url: Schema.String.pipe(Schema.optional),
})
export const PublicNative = Schema.Struct({
type: Schema.Literal("native"),
url: Schema.String.pipe(Schema.optional),
})
export const PublicApi = Schema.Union([PublicAISDK, PublicNative]).pipe(Schema.toTaggedUnion("type"))
export type PublicApi = typeof PublicApi.Type
export const Request = Schema.Struct({
headers: Schema.Record(Schema.String, Schema.String),
body: Schema.Record(Schema.String, Schema.Any),
@ -86,3 +100,49 @@ export class Info extends Schema.Class<Info>("ProviderV2.Info")({
})
}
}
export class PublicInfo extends Schema.Class<PublicInfo>("ProviderV2.PublicInfo")({
id: ID,
name: Schema.String,
enabled: Schema.Union([
Schema.Literal(false),
Schema.Struct({
via: Schema.Literal("env"),
name: Schema.String,
}),
Schema.Struct({
via: Schema.Literal("account"),
service: Schema.String,
}),
Schema.Struct({
via: Schema.Literal("custom"),
}),
]),
env: Schema.String.pipe(Schema.Array),
api: PublicApi,
}) {}
export function sanitizePublicUrl(value: string | undefined): string | undefined {
if (!value) return undefined
try {
const url = new URL(value)
return url.protocol === "http:" || url.protocol === "https:" ? url.origin : undefined
} catch {
return undefined
}
}
export function toPublic(info: Info): PublicInfo {
const enabled = info.enabled === false || info.enabled.via !== "custom" ? info.enabled : { via: "custom" as const }
const api =
info.api.type === "aisdk"
? { type: info.api.type, package: info.api.package, url: sanitizePublicUrl(info.api.url) }
: { type: info.api.type, url: sanitizePublicUrl(info.api.url) }
return new PublicInfo({
id: info.id,
name: info.name,
enabled,
env: [...info.env],
api,
})
}