refactor: move voice-call realtime providers into extensions

This commit is contained in:
Peter Steinberger
2026-04-04 12:04:37 +09:00
parent 61f93540b2
commit a23ab9b906
90 changed files with 3134 additions and 792 deletions

View File

@@ -127,6 +127,8 @@
"kimi-coding",
"kilocode",
"reply-history",
"realtime-transcription",
"realtime-voice",
"media-understanding",
"request-url",
"runtime-store",

View File

@@ -1,7 +1,8 @@
import { spawnSync } from "node:child_process";
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { renderRootHelpText } from "../src/cli/program/root-help.ts";
import { fileURLToPath, pathToFileURL } from "node:url";
import { renderRootHelpText as renderSourceRootHelpText } from "../src/cli/program/root-help.ts";
function dedupe(values: string[]): string[] {
const seen = new Set<string>();
@@ -82,7 +83,37 @@ export function readBundledChannelCatalogIds(
export async function renderBundledRootHelpText(
_distDirOverride: string = distDir,
): Promise<string> {
return await renderRootHelpText({ pluginDescriptors: [] });
const bundleName = readdirSync(distDirOverride).find(
(entry) => entry.startsWith("root-help-") && entry.endsWith(".js"),
);
if (!bundleName) {
throw new Error("No root-help bundle found in dist; cannot write CLI startup metadata.");
}
const moduleUrl = pathToFileURL(path.join(distDirOverride, bundleName)).href;
const inlineModule = [
`const mod = await import(${JSON.stringify(moduleUrl)});`,
"if (typeof mod.outputRootHelp !== 'function') {",
` throw new Error(${JSON.stringify(`Bundle ${bundleName} does not export outputRootHelp.`)});`,
"}",
"await mod.outputRootHelp();",
"process.exit(0);",
].join("\n");
const result = spawnSync(process.execPath, ["--input-type=module", "--eval", inlineModule], {
cwd: distDirOverride,
encoding: "utf8",
timeout: 30_000,
});
if (result.error) {
throw result.error;
}
if (result.status !== 0) {
const stderr = result.stderr?.trim();
throw new Error(
`Failed to render bundled root help from ${bundleName}` +
(stderr ? `: ${stderr}` : result.signal ? `: terminated by ${result.signal}` : ""),
);
}
return result.stdout ?? "";
}
export async function writeCliStartupMetadata(options?: {
@@ -95,7 +126,13 @@ export async function writeCliStartupMetadata(options?: {
const resolvedExtensionsDir = options?.extensionsDir ?? extensionsDir;
const catalog = readBundledChannelCatalogIds(resolvedExtensionsDir);
const channelOptions = dedupe([...CORE_CHANNEL_ORDER, ...catalog]);
const rootHelpText = await renderBundledRootHelpText(resolvedDistDir);
const useSourceRootHelp =
resolvedDistDir === distDir &&
resolvedOutputPath === outputPath &&
resolvedExtensionsDir === extensionsDir;
const rootHelpText = useSourceRootHelp
? await renderSourceRootHelpText({ pluginSdkResolution: "src" })
: await renderBundledRootHelpText(resolvedDistDir);
mkdirSync(resolvedDistDir, { recursive: true });
writeFileSync(
@@ -115,4 +152,5 @@ export async function writeCliStartupMetadata(options?: {
if (process.argv[1] && path.resolve(process.argv[1]) === scriptPath) {
await writeCliStartupMetadata();
process.exit(0);
}