feat: add thinking option support and autonomous run handling
This commit is contained in:
@@ -17,6 +17,7 @@ export function createProviderCommand(): Command {
|
||||
.command('models')
|
||||
.description('List models for a provider')
|
||||
.argument('<provider>', 'Provider name (claude, codex, opencode)')
|
||||
.option('--thinking', 'Include thinking option IDs for each model')
|
||||
.option('--json', 'Output in JSON format')
|
||||
.option('--host <host>', 'Daemon host:port (default: localhost:6767)')
|
||||
.action(withOutput(runModelsCommand))
|
||||
|
||||
@@ -7,10 +7,11 @@ export interface ModelListItem {
|
||||
model: string
|
||||
id: string
|
||||
description: string
|
||||
thinkingOptionIds: string[]
|
||||
defaultThinkingOptionId: string | null
|
||||
thinkingOptions: string
|
||||
}
|
||||
|
||||
const VALID_PROVIDERS = ['claude', 'codex', 'opencode']
|
||||
|
||||
/** Schema for provider models output */
|
||||
export const providerModelsSchema: OutputSchema<ModelListItem> = {
|
||||
idField: 'id',
|
||||
@@ -21,10 +22,25 @@ export const providerModelsSchema: OutputSchema<ModelListItem> = {
|
||||
],
|
||||
}
|
||||
|
||||
const providerModelsWithThinkingSchema: OutputSchema<ModelListItem> = {
|
||||
idField: 'id',
|
||||
columns: [
|
||||
{ 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',
|
||||
width: 18,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
export type ProviderModelsResult = ListResult<ModelListItem>
|
||||
|
||||
export interface ProviderModelsOptions extends CommandOptions {
|
||||
host?: string
|
||||
thinking?: boolean
|
||||
}
|
||||
|
||||
export async function runModelsCommand(
|
||||
@@ -34,14 +50,6 @@ export async function runModelsCommand(
|
||||
): Promise<ProviderModelsResult> {
|
||||
const normalizedProvider = provider.toLowerCase()
|
||||
|
||||
if (!VALID_PROVIDERS.includes(normalizedProvider)) {
|
||||
throw {
|
||||
code: 'UNKNOWN_PROVIDER',
|
||||
message: `Unknown provider: ${provider}`,
|
||||
details: `Valid providers: ${VALID_PROVIDERS.join(', ')}`,
|
||||
}
|
||||
}
|
||||
|
||||
const client = await connectToDaemon({ host: options.host })
|
||||
try {
|
||||
const result = await client.listProviderModels(normalizedProvider)
|
||||
@@ -57,12 +65,16 @@ export async function runModelsCommand(
|
||||
model: m.label,
|
||||
id: m.id,
|
||||
description: m.description ?? '',
|
||||
thinkingOptionIds: (m.thinkingOptions ?? []).map((option) => option.id),
|
||||
defaultThinkingOptionId: m.defaultThinkingOptionId ?? null,
|
||||
thinkingOptions:
|
||||
(m.thinkingOptions ?? []).map((option) => option.id).join(', ') || 'none',
|
||||
}))
|
||||
|
||||
return {
|
||||
type: 'list',
|
||||
data: models,
|
||||
schema: providerModelsSchema,
|
||||
schema: options.thinking ? providerModelsWithThinkingSchema : providerModelsSchema,
|
||||
}
|
||||
} finally {
|
||||
await client.close()
|
||||
|
||||
Reference in New Issue
Block a user