openhorizon-cli 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +40 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -234,7 +234,7 @@ async function* streamCompletion(baseUrl, apiKey, model, messages) {
234
234
  Authorization: `Bearer ${apiKey}`,
235
235
  "x-api-key": apiKey,
236
236
  "x-client": "openhorizon-cli",
237
- "x-client-version": "1.0.12"
237
+ "x-client-version": "1.0.14"
238
238
  },
239
239
  body: JSON.stringify({
240
240
  model,
@@ -330,12 +330,12 @@ async function runChatLoop(options) {
330
330
  }
331
331
  if (trimmed === "/version") {
332
332
  console.log(chalk3.blue(`
333
- OpenHorizon CLI version: ${chalk3.bold("1.0.12")}
333
+ OpenHorizon CLI version: ${chalk3.bold("1.0.14")}
334
334
  `));
335
335
  continue;
336
336
  }
337
337
  if (trimmed === "/update") {
338
- await runUpdate("1.0.12");
338
+ await runUpdate("1.0.14");
339
339
  continue;
340
340
  }
341
341
  if (trimmed.startsWith("/history")) {
@@ -427,7 +427,7 @@ async function runChatLoop(options) {
427
427
  // src/index.ts
428
428
  dotenv.config();
429
429
  var program = new Command();
430
- var version = "1.0.12";
430
+ var version = "1.0.14";
431
431
  program.name("openhorizon").description("CLI to interact with OpenHorizon AI Models").version(version, "-v, --version", "Output the current version");
432
432
  program.command("version").description("Show the current CLI version").action(() => {
433
433
  console.log(chalk4.blue(`OpenHorizon CLI version: ${chalk4.bold(version)}`));
@@ -456,13 +456,47 @@ program.command("chat", { isDefault: true }).description("Start an interactive c
456
456
  const baseUrl = options.baseUrl || process.env.OPENHORIZON_API_URL || "https://api.openhorizon.devwtf.in/v1";
457
457
  await runChatLoop({ apiKey, model, baseUrl });
458
458
  });
459
- program.command("model").description("Get or set the default AI model").argument("[modelName]", "The name of the model to set as default").action((modelName) => {
459
+ program.command("model").description("Get or set the default AI model").argument("[modelName]", "The name of the model to set as default").action(async (modelName) => {
460
460
  const config = getConfig();
461
461
  if (modelName) {
462
462
  saveConfig({ defaultModel: modelName });
463
463
  console.log(chalk4.green(`\u2713 Default model set to: ${chalk4.bold(modelName)}`));
464
- } else {
464
+ return;
465
+ }
466
+ try {
467
+ const baseUrl = process.env.OPENHORIZON_API_URL || "https://api.openhorizon.devwtf.in/v1";
468
+ console.log(chalk4.gray("\u27F3 Fetching available models..."));
469
+ const response = await fetch(`${baseUrl}/models`);
470
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
471
+ const json = await response.json();
472
+ if (!json.success || !Array.isArray(json.data)) throw new Error("Invalid response format");
473
+ const choices = json.data.flatMap(
474
+ (model) => model.versions.map((v) => ({
475
+ name: `${v.name} ${chalk4.gray(`(${v.size}, ${v.context} context)`)}`,
476
+ value: v.name,
477
+ description: model.description
478
+ }))
479
+ );
480
+ if (choices.length === 0) {
481
+ console.log(chalk4.yellow("! No models available on the server."));
482
+ console.log(chalk4.blue(`Current default model: ${chalk4.bold(config.defaultModel ?? "(not set)")}`));
483
+ return;
484
+ }
485
+ const { select } = await import("@inquirer/prompts");
486
+ const selected = await select({
487
+ message: "Select default AI model:",
488
+ choices,
489
+ pageSize: 10,
490
+ default: config.defaultModel
491
+ });
492
+ saveConfig({ defaultModel: selected });
493
+ console.log(chalk4.green(`\u2713 Default model set to: ${chalk4.bold(selected)}`));
494
+ } catch (error) {
495
+ console.log(chalk4.yellow(`
496
+ ! Could not fetch models from server: ${error instanceof Error ? error.message : String(error)}`));
465
497
  console.log(chalk4.blue(`Current default model: ${chalk4.bold(config.defaultModel ?? "(not set)")}`));
498
+ console.log(chalk4.gray(`To set manually, use: ${chalk4.white("openhorizon model <name>")}
499
+ `));
466
500
  }
467
501
  });
468
502
  program.command("login").description("Save your OpenHorizon API Key securely to local config").argument("[apiKey]", "Your OpenHorizon API Key").action(async (apiKeyInput) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openhorizon-cli",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Official CLI for OpenHorizon — chat with AI models directly from your terminal",
5
5
  "type": "module",
6
6
  "bin": {