@iletai/nzb 1.5.2 → 1.5.3

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.
@@ -33,11 +33,29 @@ const TIMEOUT_PRESETS = [
33
33
  { ms: 3_600_000, label: "60min" },
34
34
  { ms: 7_200_000, label: "120min" },
35
35
  ];
36
- const MODEL_PRESETS = [
37
- "claude-sonnet-4-20250514",
38
- "claude-haiku-4-20250414",
39
- "claude-opus-4-20250115",
40
- ];
36
+ // Dynamic model list — fetched from Copilot SDK, cached for 5 minutes
37
+ let cachedModels;
38
+ let cachedModelsAt = 0;
39
+ const MODEL_CACHE_TTL = 5 * 60_000;
40
+ async function getAvailableModels() {
41
+ if (cachedModels && Date.now() - cachedModelsAt < MODEL_CACHE_TTL) {
42
+ return cachedModels;
43
+ }
44
+ try {
45
+ const { getClient } = await import("../copilot/client.js");
46
+ const client = await getClient();
47
+ const models = await client.listModels();
48
+ if (models.length > 0) {
49
+ cachedModels = models.map((m) => m.id);
50
+ cachedModelsAt = Date.now();
51
+ return cachedModels;
52
+ }
53
+ }
54
+ catch {
55
+ /* fall through to fallback */
56
+ }
57
+ return cachedModels ?? [config.copilotModel];
58
+ }
41
59
  function getTimeoutLabel() {
42
60
  const preset = TIMEOUT_PRESETS.find((p) => p.ms === config.workerTimeoutMs);
43
61
  return preset ? preset.label : `${Math.round(config.workerTimeoutMs / 60_000)}min`;
@@ -62,8 +80,13 @@ const settingsMenu = new Menu("settings-menu")
62
80
  })
63
81
  .row()
64
82
  .text(() => `🤖 ${config.copilotModel}`, async (ctx) => {
65
- const idx = MODEL_PRESETS.indexOf(config.copilotModel);
66
- const next = MODEL_PRESETS[(idx + 1) % MODEL_PRESETS.length];
83
+ const models = await getAvailableModels();
84
+ if (models.length === 0) {
85
+ await ctx.answerCallbackQuery("No models available");
86
+ return;
87
+ }
88
+ const idx = models.indexOf(config.copilotModel);
89
+ const next = models[(idx + 1) % models.length];
67
90
  config.copilotModel = next;
68
91
  persistModel(next);
69
92
  ctx.menu.update();
@@ -244,7 +267,8 @@ export function createBot() {
244
267
  "⚡ Breakthrough Features:\n" +
245
268
  "• @bot query — Use me inline in any chat!\n" +
246
269
  "• React to any message to trigger AI:\n" +
247
- getReactionHelpText() + "\n" +
270
+ getReactionHelpText() +
271
+ "\n" +
248
272
  "• Smart suggestions appear after each response", { reply_markup: mainMenu }));
249
273
  bot.command("cancel", async (ctx) => {
250
274
  const cancelled = await cancelCurrentMessage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iletai/nzb",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "NZB — a personal AI assistant for developers, built on the GitHub Copilot SDK",
5
5
  "bin": {
6
6
  "nzb": "dist/cli.js"
@@ -67,4 +67,4 @@
67
67
  "typescript": "^5.9.3",
68
68
  "vitest": "^4.1.0"
69
69
  }
70
- }
70
+ }