core: generate type definitions for node import

This commit is contained in:
Brendan Allan
2026-04-09 15:29:28 +08:00
parent 847fc9d268
commit 407825bdad
17 changed files with 129 additions and 61496 deletions

View File

@@ -2,5 +2,4 @@ research
dist
gen
app.log
src/provider/models-snapshot.js
src/provider/models-snapshot.d.ts
src/provider/models-snapshot.ts

View File

@@ -69,6 +69,7 @@
"@typescript/native-preview": "catalog:",
"drizzle-kit": "catalog:",
"drizzle-orm": "catalog:",
"openapi-types": "12.1.3",
"typescript": "catalog:",
"vscode-languageserver-types": "3.17.5",
"why-is-node-running": "3.2.2",

View File

@@ -21,12 +21,8 @@ const modelsData = process.env.MODELS_DEV_API_JSON
? await Bun.file(process.env.MODELS_DEV_API_JSON).text()
: await fetch(`${modelsUrl}/api.json`).then((x) => x.text())
await Bun.write(
path.join(dir, "src/provider/models-snapshot.js"),
`// @ts-nocheck\n// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData}\n`,
)
await Bun.write(
path.join(dir, "src/provider/models-snapshot.d.ts"),
`// Auto-generated by build.ts - do not edit\nexport declare const snapshot: Record<string, unknown>\n`,
path.join(dir, "src/provider/models-snapshot.ts"),
`// Auto-generated by build.ts - do not edit\nexport const snapshot = ${modelsData} as Record<string, unknown>\n`,
)
console.log("Generated models-snapshot.js")

View File

@@ -1,2 +0,0 @@
// Auto-generated by build.ts - do not edit
export declare const snapshot: Record<string, unknown>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,6 @@
import { resolver } from "hono-openapi"
import z from "zod"
import "openapi-types"
import { NotFoundError } from "../storage/db"
export const ERRORS = {

View File

@@ -192,7 +192,9 @@ export const ExperimentalRoutes = lazy(() =>
id: t.id,
description: t.description,
// Handle both Zod schemas and plain JSON schemas
parameters: (t.parameters as any)?._def ? zodToJsonSchema(t.parameters as any) : t.parameters,
parameters: (t.parameters as any)?._def
? (zodToJsonSchema(t.parameters as any) as any)
: (t.parameters as any),
})),
)
},
@@ -350,7 +352,7 @@ export const ExperimentalRoutes = lazy(() =>
const hasMore = sessions.length > limit
const list = hasMore ? sessions.slice(0, limit) : sessions
if (hasMore && list.length > 0) {
c.header("x-next-cursor", String(list[list.length - 1].time.updated))
c.header("x-next-cursor", String(list[list.length - 1]!.time.updated))
}
return c.json(list)
},

View File

@@ -1,7 +1,6 @@
import { Provider } from "@/provider/provider"
import { Log } from "@/util/log"
import { Cause, Effect, Layer, Record, ServiceMap } from "effect"
import * as Queue from "effect/Queue"
import { Effect, Layer, Record, ServiceMap } from "effect"
import * as Stream from "effect/Stream"
import { streamText, wrapLanguageModel, type ModelMessage, type Tool, tool, jsonSchema } from "ai"
import { mergeDeep, pipe } from "remeda"

View File

@@ -7,7 +7,7 @@ import { Truncate } from "./truncate"
import { Agent } from "@/agent/agent"
export namespace Tool {
interface Metadata {
export interface Metadata {
[key: string]: any
}

View File

@@ -17,7 +17,7 @@ export const withStatics =
Object.assign(schema, methods(schema))
declare const NewtypeBrand: unique symbol
type NewtypeBrand<Tag extends string> = { readonly [NewtypeBrand]: Tag }
export type NewtypeBrand<Tag extends string> = { readonly [NewtypeBrand]: Tag }
/**
* Nominal wrapper for scalar types. The class itself is a valid schema —

View File

@@ -18,6 +18,12 @@
"transform": "@effect/language-service/transform",
"namespaceImportPackages": ["effect", "@effect/*"]
}
]
}
],
"outDir": "dist/types",
"rootDir": ".",
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["src"]
}