Switch to double quotes and reformat codebase with Biome

This commit is contained in:
Mohamed Boudra
2026-03-21 20:22:15 +07:00
parent ab40786882
commit f6579dbeb4
805 changed files with 38132 additions and 40175 deletions
+36 -37
View File
@@ -1,82 +1,81 @@
import type { Command } from 'commander'
import { connectToDaemon } from '../../utils/client.js'
import type { CommandOptions, ListResult, OutputSchema } from '../../output/index.js'
import type { Command } from "commander";
import { connectToDaemon } from "../../utils/client.js";
import type { CommandOptions, ListResult, OutputSchema } from "../../output/index.js";
/** Model list item for display */
export interface ModelListItem {
model: string
id: string
description: string
thinkingOptionIds: string[]
defaultThinkingOptionId: string | null
thinkingOptions: string
model: string;
id: string;
description: string;
thinkingOptionIds: string[];
defaultThinkingOptionId: string | null;
thinkingOptions: string;
}
/** Schema for provider models output */
export const providerModelsSchema: OutputSchema<ModelListItem> = {
idField: 'id',
idField: "id",
columns: [
{ header: 'ID', field: 'id', width: 30 },
{ header: 'MODEL', field: 'model', width: 30 },
{ header: 'DESCRIPTION', field: 'description', width: 40 },
{ header: "ID", field: "id", width: 30 },
{ header: "MODEL", field: "model", width: 30 },
{ header: "DESCRIPTION", field: "description", width: 40 },
],
}
};
const providerModelsWithThinkingSchema: OutputSchema<ModelListItem> = {
idField: 'id',
idField: "id",
columns: [
{ header: 'ID', field: 'id', width: 30 },
{ header: 'MODEL', field: 'model', width: 30 },
{ header: 'THINKING IDS', field: 'thinkingOptions', width: 40 },
{ header: "ID", field: "id", width: 30 },
{ header: "MODEL", field: "model", width: 30 },
{ header: "THINKING IDS", field: "thinkingOptions", width: 40 },
{
header: 'DEFAULT THINKING',
field: (item) => item.defaultThinkingOptionId ?? 'auto',
header: "DEFAULT THINKING",
field: (item) => item.defaultThinkingOptionId ?? "auto",
width: 18,
},
],
}
};
export type ProviderModelsResult = ListResult<ModelListItem>
export type ProviderModelsResult = ListResult<ModelListItem>;
export interface ProviderModelsOptions extends CommandOptions {
host?: string
thinking?: boolean
host?: string;
thinking?: boolean;
}
export async function runModelsCommand(
provider: string,
options: ProviderModelsOptions,
_command: Command
_command: Command,
): Promise<ProviderModelsResult> {
const normalizedProvider = provider.toLowerCase()
const normalizedProvider = provider.toLowerCase();
const client = await connectToDaemon({ host: options.host })
const client = await connectToDaemon({ host: options.host });
try {
const result = await client.listProviderModels(normalizedProvider)
const result = await client.listProviderModels(normalizedProvider);
if (result.error) {
throw {
code: 'PROVIDER_ERROR',
code: "PROVIDER_ERROR",
message: `Failed to fetch models for ${provider}: ${result.error}`,
}
};
}
const models: ModelListItem[] = (result.models ?? []).map((m) => ({
model: m.label,
id: m.id,
description: m.description ?? '',
description: m.description ?? "",
thinkingOptionIds: (m.thinkingOptions ?? []).map((option) => option.id),
defaultThinkingOptionId: m.defaultThinkingOptionId ?? null,
thinkingOptions:
(m.thinkingOptions ?? []).map((option) => option.id).join(', ') || 'none',
}))
thinkingOptions: (m.thinkingOptions ?? []).map((option) => option.id).join(", ") || "none",
}));
return {
type: 'list',
type: "list",
data: models,
schema: options.thinking ? providerModelsWithThinkingSchema : providerModelsSchema,
}
};
} finally {
await client.close()
await client.close();
}
}