talon-agent 1.5.0 → 1.6.0

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.
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import { escapeHtml } from "./formatting.js";
6
+ import { getModels } from "../../core/models.js";
6
7
  const DEFAULT_PULSE_INTERVAL_MS = 5 * 60 * 1000;
7
8
 
8
9
  /** Parse a duration string like "30m", "2h", "1h30m" into milliseconds. */
@@ -60,22 +61,19 @@ export function renderSettingsKeyboard(
60
61
  effort: string,
61
62
  proactive: boolean,
62
63
  ): Array<Array<{ text: string; callback_data: string }>> {
63
- const isModel = (id: string) => model.includes(id);
64
+ // Build model buttons dynamically from the registry, chunked into rows of 3
65
+ const modelButtons = getModels().map((m) => ({
66
+ text: model.includes(m.id)
67
+ ? `\u2713 ${m.displayName.split(" ")[0]}`
68
+ : m.displayName.split(" ")[0],
69
+ callback_data: `settings:model:${m.aliases[0] ?? m.id}`,
70
+ }));
71
+ const modelRows: Array<Array<{ text: string; callback_data: string }>> = [];
72
+ for (let i = 0; i < modelButtons.length; i += 3) {
73
+ modelRows.push(modelButtons.slice(i, i + 3));
74
+ }
64
75
  return [
65
- [
66
- {
67
- text: isModel("sonnet") ? "\u2713 Sonnet" : "Sonnet",
68
- callback_data: "settings:model:sonnet",
69
- },
70
- {
71
- text: isModel("opus") ? "\u2713 Opus" : "Opus",
72
- callback_data: "settings:model:opus",
73
- },
74
- {
75
- text: isModel("haiku") ? "\u2713 Haiku" : "Haiku",
76
- callback_data: "settings:model:haiku",
77
- },
78
- ],
76
+ ...modelRows,
79
77
  [
80
78
  {
81
79
  text: effort === "low" ? "\u2713 Low" : "Low",
@@ -75,7 +75,7 @@ export function createTelegramFrontend(
75
75
  adminUserId: config.adminUserId,
76
76
  });
77
77
 
78
- registerCommands(bot, config);
78
+ registerCommands(bot, config, gateway);
79
79
  registerMiddleware(bot, config);
80
80
  registerCallbacks(bot, config);
81
81
 
@@ -90,14 +90,17 @@ export function registerBuiltinCommands(): void {
90
90
  registerCommand({
91
91
  name: "model",
92
92
  argHint: "[name]",
93
- description: "Switch model (opus, sonnet, haiku)",
93
+ description: "Switch model",
94
94
  async handler(args, ctx) {
95
95
  const { getChatSettings, setChatModel, resolveModelName } =
96
96
  await import("../../storage/chat-settings.js");
97
97
  if (!args) {
98
- ctx.renderer.writeSystem(
99
- `Model: ${getChatSettings(ctx.chatId()).model ?? ctx.config.model}`,
100
- );
98
+ const { getModels } = await import("../../core/models.js");
99
+ const current = getChatSettings(ctx.chatId()).model ?? ctx.config.model;
100
+ const names = getModels()
101
+ .map((m) => m.aliases[0] ?? m.id)
102
+ .join(", ");
103
+ ctx.renderer.writeSystem(`Model: ${current} (available: ${names})`);
101
104
  } else {
102
105
  setChatModel(ctx.chatId(), resolveModelName(args));
103
106
  ctx.renderer.writeSystem(`Model → ${resolveModelName(args)}`);
package/src/index.ts CHANGED
@@ -66,7 +66,8 @@ if (selectedFrontend === "terminal") {
66
66
 
67
67
  // ── Create backend + wire dispatcher ─────────────────────────────────────────
68
68
 
69
- await initBackendAndDispatcher(config, frontend);
69
+ const { backend } = await initBackendAndDispatcher(config, frontend);
70
+ gateway.backend = backend;
70
71
 
71
72
  // ── Graceful shutdown ────────────────────────────────────────────────────────
72
73
 
@@ -220,22 +220,8 @@ export const EFFORT_LEVELS: EffortLevel[] = [
220
220
  "max",
221
221
  ];
222
222
 
223
- /** Known model aliases. */
224
- export const MODEL_ALIASES: Record<string, string> = {
225
- sonnet: "claude-sonnet-4-6",
226
- opus: "claude-opus-4-6",
227
- haiku: "claude-haiku-4-5",
228
- "sonnet-4.6": "claude-sonnet-4-6",
229
- "opus-4.6": "claude-opus-4-6",
230
- "haiku-4.5": "claude-haiku-4-5",
231
- "sonnet-4-6": "claude-sonnet-4-6",
232
- "opus-4-6": "claude-opus-4-6",
233
- "haiku-4-5": "claude-haiku-4-5",
234
- };
235
-
236
- export function resolveModelName(input: string): string {
237
- const lower = input.trim().toLowerCase();
238
- return Object.hasOwn(MODEL_ALIASES, lower)
239
- ? MODEL_ALIASES[lower]
240
- : input.trim();
241
- }
223
+ /**
224
+ * Resolve a user-provided model name (alias or full ID) to the canonical model ID.
225
+ * Delegates to the model registry; falls through unknown names unchanged.
226
+ */
227
+ export { resolveModelId as resolveModelName } from "../core/models.js";