Switch to double quotes and reformat codebase with Biome
This commit is contained in:
@@ -1,25 +1,23 @@
|
||||
import { Command } from 'commander'
|
||||
import { runLsCommand } from './ls.js'
|
||||
import { runModelsCommand } from './models.js'
|
||||
import { withOutput } from '../../output/index.js'
|
||||
import { addJsonAndDaemonHostOptions } from '../../utils/command-options.js'
|
||||
import { Command } from "commander";
|
||||
import { runLsCommand } from "./ls.js";
|
||||
import { runModelsCommand } from "./models.js";
|
||||
import { withOutput } from "../../output/index.js";
|
||||
import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
|
||||
|
||||
export function createProviderCommand(): Command {
|
||||
const provider = new Command('provider').description('Manage agent providers')
|
||||
const provider = new Command("provider").description("Manage agent providers");
|
||||
|
||||
addJsonAndDaemonHostOptions(
|
||||
provider.command("ls").description("List available providers and status"),
|
||||
).action(withOutput(runLsCommand));
|
||||
|
||||
addJsonAndDaemonHostOptions(
|
||||
provider
|
||||
.command('ls')
|
||||
.description('List available providers and status')
|
||||
).action(withOutput(runLsCommand))
|
||||
.command("models")
|
||||
.description("List models for a provider")
|
||||
.argument("<provider>", "Provider name (claude, codex, opencode)")
|
||||
.option("--thinking", "Include thinking option IDs for each model"),
|
||||
).action(withOutput(runModelsCommand));
|
||||
|
||||
addJsonAndDaemonHostOptions(
|
||||
provider
|
||||
.command('models')
|
||||
.description('List models for a provider')
|
||||
.argument('<provider>', 'Provider name (claude, codex, opencode)')
|
||||
.option('--thinking', 'Include thinking option IDs for each model')
|
||||
).action(withOutput(runModelsCommand))
|
||||
|
||||
return provider
|
||||
return provider;
|
||||
}
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
import type { Command } from 'commander'
|
||||
import type { CommandOptions, ListResult, OutputSchema } from '../../output/index.js'
|
||||
import type { Command } from "commander";
|
||||
import type { CommandOptions, ListResult, OutputSchema } from "../../output/index.js";
|
||||
|
||||
/** Provider list item for display */
|
||||
export interface ProviderListItem {
|
||||
provider: string
|
||||
status: string
|
||||
defaultMode: string
|
||||
modes: string
|
||||
provider: string;
|
||||
status: string;
|
||||
defaultMode: string;
|
||||
modes: string;
|
||||
}
|
||||
|
||||
/** Static provider data - providers are built-in and don't require daemon */
|
||||
const PROVIDERS: ProviderListItem[] = [
|
||||
{
|
||||
provider: 'claude',
|
||||
status: 'available',
|
||||
defaultMode: 'default',
|
||||
modes: 'plan, default, bypass',
|
||||
provider: "claude",
|
||||
status: "available",
|
||||
defaultMode: "default",
|
||||
modes: "plan, default, bypass",
|
||||
},
|
||||
{
|
||||
provider: 'codex',
|
||||
status: 'available',
|
||||
defaultMode: 'auto',
|
||||
modes: 'read-only, auto, full-access',
|
||||
provider: "codex",
|
||||
status: "available",
|
||||
defaultMode: "auto",
|
||||
modes: "read-only, auto, full-access",
|
||||
},
|
||||
{
|
||||
provider: 'opencode',
|
||||
status: 'available',
|
||||
defaultMode: 'default',
|
||||
modes: 'plan, default, bypass',
|
||||
provider: "opencode",
|
||||
status: "available",
|
||||
defaultMode: "default",
|
||||
modes: "plan, default, bypass",
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
/** Schema for provider ls output */
|
||||
export const providerLsSchema: OutputSchema<ProviderListItem> = {
|
||||
idField: 'provider',
|
||||
idField: "provider",
|
||||
columns: [
|
||||
{ header: 'PROVIDER', field: 'provider', width: 12 },
|
||||
{ header: "PROVIDER", field: "provider", width: 12 },
|
||||
{
|
||||
header: 'STATUS',
|
||||
field: 'status',
|
||||
header: "STATUS",
|
||||
field: "status",
|
||||
width: 12,
|
||||
color: (value) => {
|
||||
if (value === 'available') return 'green'
|
||||
if (value === 'unavailable') return 'red'
|
||||
return undefined
|
||||
if (value === "available") return "green";
|
||||
if (value === "unavailable") return "red";
|
||||
return undefined;
|
||||
},
|
||||
},
|
||||
{ header: 'DEFAULT MODE', field: 'defaultMode', width: 14 },
|
||||
{ header: 'MODES', field: 'modes', width: 30 },
|
||||
{ header: "DEFAULT MODE", field: "defaultMode", width: 14 },
|
||||
{ header: "MODES", field: "modes", width: 30 },
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
export type ProviderLsResult = ListResult<ProviderListItem>
|
||||
export type ProviderLsResult = ListResult<ProviderListItem>;
|
||||
|
||||
export interface ProviderLsOptions extends CommandOptions {
|
||||
host?: string
|
||||
host?: string;
|
||||
}
|
||||
|
||||
export async function runLsCommand(
|
||||
_options: ProviderLsOptions,
|
||||
_command: Command
|
||||
_command: Command,
|
||||
): Promise<ProviderLsResult> {
|
||||
// Provider data is static - no daemon connection needed
|
||||
return {
|
||||
type: 'list',
|
||||
type: "list",
|
||||
data: PROVIDERS,
|
||||
schema: providerLsSchema,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user