Files
Aiden Cline e337b7da60 feat(v2)!: make tools.updates a list of tool changes (#13856)
* feat(v2)!: make tools.updates a list of tool changes

* chore: keep comment-only tools.updates wording out of this change

* fix(openrouter): keep tool removals on Claude Messages

* fix(providers): set tools.updates from live checks on Vercel, OpenRouter and Bedrock

* fix(openrouter): set tools.updates on GPT aliases and Pro models from live checks

* chore: move new tools.updates values to a follow-up PR

* docs(providers): record the live evidence for tools.updates add, remove and replace

* fix: match the Copilot sync test and Vercel comments to the data

* fix(providers): add tools.updates where live checks show OpenAI tool changes work (#13867)
2026-11-16 23:54:42 -06:00

107 lines
3.9 KiB
TypeScript
Executable File

#!/usr/bin/env bun
import { generate } from "../src/generate";
import { generateV2 } from "../src/generate-v2";
import { explicitFalseFlags, isSchemaV2, readLabMetadata } from "../src/translate";
import { logoErrors } from "../src/logo";
import { limitErrors, type LimitEntry } from "../src/limits";
import path from "path";
import { ZodError } from "zod";
try {
const providersDir = path.join(
import.meta.dirname,
"..",
"..",
"..",
"providers",
);
const rootDir = path.dirname(providersDir);
const notV2: string[] = [];
const falseFlags: string[] = [];
for (const pattern of ["models/**/*.toml", "providers/*/models/**/*.toml", "labs/*/lab.toml"]) {
for await (const file of new Bun.Glob(pattern).scan({
cwd: rootDir,
followSymlinks: true,
})) {
const toml = await import(path.join(rootDir, file), {
with: { type: "toml" },
}).then((mod) => mod.default);
if (!isSchemaV2(toml)) notV2.push(file);
for (const flag of explicitFalseFlags(toml)) falseFlags.push(`${file}: ${flag}`);
}
}
if (notV2.length > 0) {
console.error(
"Model and lab files must be v2. Add `schema = 2` and write them in the v2 format (see AGENTS.md):\n" +
notV2.map((file) => ` ${file}`).join("\n"),
);
process.exit(1);
}
if (falseFlags.length > 0) {
console.error(
"system_updates and effort_updates default to false, and tools.updates to none. Leave them out instead of writing `= false` or `tools = { updates = [] }` (see AGENTS.md):\n" +
falseFlags.map((flag) => ` ${flag}`).join("\n"),
);
process.exit(1);
}
const unsafeLogos: string[] = [];
const logos = await Array.fromAsync(new Bun.Glob("{providers,labs}/*/logo.svg").scan({ cwd: rootDir }));
for (const file of ["providers/logo.svg", ...logos]) {
for (const error of logoErrors(await Bun.file(path.join(rootDir, file)).text())) unsafeLogos.push(`${file}: ${error}`);
}
if (unsafeLogos.length > 0) {
console.error(
"Logos may only use plain SVG drawing markup (see AGENTS.md):\n" +
unsafeLogos.map((error) => ` ${error}`).join("\n"),
);
process.exit(1);
}
for await (const file of new Bun.Glob("labs/*/lab.toml").scan({ cwd: rootDir })) {
readLabMetadata(path.join(rootDir, file));
}
const result = await generate(providersDir);
const v2 = await generateV2(providersDir);
const labLimits: LimitEntry[] = [];
for await (const file of new Bun.Glob("models/**/*.toml").scan({ cwd: rootDir, followSymlinks: true })) {
const toml = await import(path.join(rootDir, file), { with: { type: "toml" } }).then((mod) => mod.default);
labLimits.push({ file, limit: toml.limit, modalities: toml.modalities });
}
const overLimit = limitErrors([
...labLimits,
...Object.entries(v2).flatMap(([providerID, provider]) =>
Object.entries(provider.models).map(([id, model]) => ({
file: `providers/${providerID}/models/${id}.toml`,
limit: model.limit,
modalities: model.modalities,
})),
),
]);
if (overLimit.length > 0) {
console.error(
"A model's output and input limits can't be larger than its context (resolved after base_model merge):\n" +
overLimit.map((error) => ` ${error}`).join("\n"),
);
process.exit(1);
}
// OpenCode inference serves each protocol under its own path, so the
// provider-level `api` only works for OpenAI-format models.
const missing = ["opencode", "opencode-go"].flatMap((providerID) =>
Object.values(result[providerID]?.models ?? {})
.filter((model) => !model.provider?.api)
.map((model) => `${providerID}/${model.id}`),
);
if (missing.length > 0) {
console.error("Missing [provider] api:", missing.join(", "));
process.exit(1);
}
console.log(JSON.stringify(result, null, 2));
} catch (e: any) {
if (e instanceof ZodError) {
console.error("Validation error:", e.errors);
console.error("When parsing:", e.cause);
process.exit(1);
}
throw e;
}