@iletai/nzb 1.5.1 → 1.5.2

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.
@@ -25,13 +25,62 @@ function getUptimeStr() {
25
25
  const seconds = uptime % 60;
26
26
  return hours > 0 ? `${hours}h ${minutes}m ${seconds}s` : minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
27
27
  }
28
+ // Worker timeout presets (ms → display label)
29
+ const TIMEOUT_PRESETS = [
30
+ { ms: 600_000, label: "10min" },
31
+ { ms: 1_200_000, label: "20min" },
32
+ { ms: 1_800_000, label: "30min" },
33
+ { ms: 3_600_000, label: "60min" },
34
+ { ms: 7_200_000, label: "120min" },
35
+ ];
36
+ const MODEL_PRESETS = [
37
+ "claude-sonnet-4-20250514",
38
+ "claude-haiku-4-20250414",
39
+ "claude-opus-4-20250115",
40
+ ];
41
+ function getTimeoutLabel() {
42
+ const preset = TIMEOUT_PRESETS.find((p) => p.ms === config.workerTimeoutMs);
43
+ return preset ? preset.label : `${Math.round(config.workerTimeoutMs / 60_000)}min`;
44
+ }
45
+ function buildSettingsText() {
46
+ return ("⚙️ Settings\n\n" +
47
+ `⏱ Worker Timeout: ${getTimeoutLabel()}\n` +
48
+ `🤖 Model: ${config.copilotModel}\n` +
49
+ `🔧 Show Reasoning: ${config.showReasoning ? "✅ ON" : "❌ OFF"}\n\n` +
50
+ `📌 v${process.env.npm_package_version || "?"} · uptime ${getUptimeStr()}`);
51
+ }
28
52
  // Settings sub-menu
29
53
  const settingsMenu = new Menu("settings-menu")
30
- .text((ctx) => `${config.showReasoning ? "✅" : "❌"} Show Reasoning`, async (ctx) => {
54
+ .text(() => `⏱ Timeout: ${getTimeoutLabel()}`, async (ctx) => {
55
+ const idx = TIMEOUT_PRESETS.findIndex((p) => p.ms === config.workerTimeoutMs);
56
+ const next = TIMEOUT_PRESETS[(idx + 1) % TIMEOUT_PRESETS.length];
57
+ config.workerTimeoutMs = next.ms;
58
+ persistEnvVar("WORKER_TIMEOUT", String(next.ms));
59
+ ctx.menu.update();
60
+ await ctx.editMessageText(buildSettingsText());
61
+ await ctx.answerCallbackQuery(`Timeout → ${next.label}`);
62
+ })
63
+ .row()
64
+ .text(() => `🤖 ${config.copilotModel}`, async (ctx) => {
65
+ const idx = MODEL_PRESETS.indexOf(config.copilotModel);
66
+ const next = MODEL_PRESETS[(idx + 1) % MODEL_PRESETS.length];
67
+ config.copilotModel = next;
68
+ persistModel(next);
69
+ ctx.menu.update();
70
+ await ctx.editMessageText(buildSettingsText());
71
+ await ctx.answerCallbackQuery(`Model → ${next}`);
72
+ })
73
+ .row()
74
+ .text(() => `${config.showReasoning ? "✅" : "❌"} Show Reasoning`, async (ctx) => {
31
75
  config.showReasoning = !config.showReasoning;
32
76
  persistEnvVar("SHOW_REASONING", config.showReasoning ? "true" : "false");
33
77
  ctx.menu.update();
78
+ await ctx.editMessageText(buildSettingsText());
34
79
  await ctx.answerCallbackQuery(`Reasoning ${config.showReasoning ? "ON" : "OFF"}`);
80
+ })
81
+ .row()
82
+ .text(() => `📌 v${process.env.npm_package_version || "?"} · uptime ${getUptimeStr()}`, async (ctx) => {
83
+ await ctx.answerCallbackQuery(`Uptime: ${getUptimeStr()}`);
35
84
  })
36
85
  .row()
37
86
  .back("🔙 Back", async (ctx) => {
@@ -90,11 +139,7 @@ const mainMenu = new Menu("main-menu")
90
139
  }
91
140
  })
92
141
  .submenu("⚙️ Settings", "settings-menu", async (ctx) => {
93
- await ctx.editMessageText("⚙️ Settings\n\n" +
94
- `🔧 Show Reasoning: ${config.showReasoning ? "✅ ON" : "❌ OFF"}\n` +
95
- ` └ Hiển thị tools đã dùng + thời gian cuối mỗi phản hồi\n\n` +
96
- `🤖 Model: ${config.copilotModel}\n` +
97
- ` └ Dùng /model <name> để đổi`);
142
+ await ctx.editMessageText(buildSettingsText());
98
143
  })
99
144
  .row()
100
145
  .text("❌ Cancel", async (ctx) => {
@@ -289,11 +334,7 @@ export function createBot() {
289
334
  }, 500);
290
335
  });
291
336
  bot.command("settings", async (ctx) => {
292
- await ctx.reply("⚙️ Settings\n\n" +
293
- `🔧 Show Reasoning: ${config.showReasoning ? "✅ ON" : "❌ OFF"}\n` +
294
- ` └ Hiển thị tools đã dùng + thời gian cuối mỗi phản hồi\n\n` +
295
- `🤖 Model: ${config.copilotModel}\n` +
296
- ` └ Dùng /model <name> để đổi`, { reply_markup: settingsMenu });
337
+ await ctx.reply(buildSettingsText(), { reply_markup: settingsMenu });
297
338
  });
298
339
  // Reply keyboard button handlers — intercept before general text handler
299
340
  bot.hears("📊 Status", async (ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iletai/nzb",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
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"