metheus-governance-mcp-cli 0.2.78 → 0.2.80

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.
package/README.md CHANGED
@@ -226,12 +226,13 @@ metheus-governance-mcp-cli bot verify --provider telegram --bot-key main
226
226
  Behavior:
227
227
 
228
228
  - `bot setup` asks for `Telegram / Slack / KakaoTalk` first, then prompts with numbered actions.
229
- - `bot add` without flags now uses the shortest practical guided flow: provider -> token -> verify -> optional save-anyway only when verify fails -> optional username fallback only when verify cannot discover it -> optional default bot.
229
+ - `bot add` without flags now uses the shortest practical guided flow: provider -> token -> verify -> optional save-anyway only when verify fails -> optional username fallback only when verify cannot discover it -> optional AI model selection when the resolved defaults leave it blank -> optional default bot.
230
230
  - In the normal Telegram path, `bot add` does not ask for a local bot key, a server bot UUID, or an approval / worker / review / monitor choice.
231
231
  - For Telegram, the local env key is auto-generated from the matched server bot name or verified username, so you do not have to invent a separate local nickname first.
232
232
  - For Telegram, the CLI tries to match the verified bot identity against the server `me/bots` list first. If the server exposes one logical bot name with multiple roles such as `approval`, `worker`, `review`, and `monitor`, the CLI does not ask you to choose one UUID. It binds by server bot name and keeps the local role/AI fields empty so runtime can use the server bot role for each route.
233
233
  - When the Telegram username matches exactly one server bot role, the CLI still auto-fills the local `role_profile` and blank AI defaults from your local `bot-runner.json` `role_profiles` mapping.
234
234
  - `bot edit` without flags now uses the same sequential flow every time: provider -> bot entry -> username/token review -> grouped server-role review when needed -> AI field choices -> default choice -> save.
235
+ - when the CLI asks for `AI model`, it now shows client-specific model choices first and still allows manual entry when you need a custom model name.
235
236
  - if one server bot name maps to multiple server roles, `bot edit` keeps the Telegram env entry bound to the server identity and lets you review the local `role_profiles` for each detected role instead of forcing one role/profile UUID choice up front.
236
237
  - In the normal Telegram edit path, the CLI keeps or re-resolves the server bot binding automatically. It no longer asks you to pick `approval / worker / review / monitor` or a server bot UUID first.
237
238
  - `bot set-default` without flags starts a guided numbered flow: provider -> bot entry -> confirm default change.
@@ -832,7 +832,7 @@ async function editTelegramBotGuided(ui, parsed, selected, current, flags, deps)
832
832
  defaultValue: current.model ? "keep" : "change",
833
833
  });
834
834
  if (modelAction === "change") {
835
- current.model = await promptLine(ui, "AI model", current.model);
835
+ current.model = await promptAIModel(ui, deps, current.client, current.model);
836
836
  } else if (modelAction === "clear") {
837
837
  current.model = "";
838
838
  }
@@ -1123,19 +1123,16 @@ function printBotShow(provider, state, entry, deps, extras = {}) {
1123
1123
  process.stdout.write(` token: ${token ? maskSecret(token) : "(not configured)"}\n`);
1124
1124
  }
1125
1125
 
1126
- async function chooseTelegramEntry(ui, parsedEnv, deps, title = "Select Telegram bot entry") {
1126
+ async function chooseTelegramEntry(ui, parsedEnv, deps, title = "Select Telegram bot entry", flags = {}) {
1127
1127
  const entries = telegramEntriesForDisplay(parsedEnv, deps);
1128
1128
  if (!entries.length) {
1129
1129
  throw new Error("no Telegram bot entries are configured");
1130
1130
  }
1131
+ const displayRows = await buildTelegramEntrySelectionRows(entries, flags, deps);
1131
1132
  const selected = await promptChoice(
1132
1133
  ui,
1133
1134
  title,
1134
- entries.map((entry) => ({
1135
- value: entry.key,
1136
- label: `${telegramEntryDisplayName(entry)}${entry.isDefault ? " [default]" : ""}`,
1137
- description: telegramEntryDisplayDescription(entry),
1138
- })),
1135
+ displayRows,
1139
1136
  { defaultIndex: 0 },
1140
1137
  );
1141
1138
  return entries.find((entry) => entry.key === selected.value) || entries[0];
@@ -1164,7 +1161,7 @@ async function resolveTelegramEntryForShow(ui, parsedEnv, flags, deps) {
1164
1161
  if (nonInteractive) {
1165
1162
  throw new Error("Telegram bot selector is required when multiple entries exist; pass --bot-key, --bot-id, or --bot-name");
1166
1163
  }
1167
- return chooseTelegramEntry(ui, parsedEnv, deps, "Select Telegram bot entry");
1164
+ return chooseTelegramEntry(ui, parsedEnv, deps, "Select Telegram bot entry", flags);
1168
1165
  }
1169
1166
 
1170
1167
  async function chooseServerBot(ui, provider, baseURL, timeoutSeconds, deps, options = {}) {
@@ -1452,6 +1449,60 @@ async function promptAIClient(ui, deps, defaultValue = "") {
1452
1449
  return String(selected?.value || "").trim();
1453
1450
  }
1454
1451
 
1452
+ function suggestedAIModelsForClient(clientName) {
1453
+ const normalizedClient = String(clientName || "").trim().toLowerCase();
1454
+ if (normalizedClient === "codex") {
1455
+ return [
1456
+ { value: "gpt-5-codex", label: "gpt-5-codex", description: "recommended Codex model" },
1457
+ ];
1458
+ }
1459
+ if (normalizedClient === "claude") {
1460
+ return [
1461
+ { value: "claude-sonnet-4", label: "claude-sonnet-4", description: "recommended Claude model" },
1462
+ { value: "claude-3.7-sonnet", label: "claude-3.7-sonnet", description: "older Claude Sonnet variant" },
1463
+ ];
1464
+ }
1465
+ if (normalizedClient === "gemini") {
1466
+ return [
1467
+ { value: "gemini-2.5-pro", label: "gemini-2.5-pro", description: "recommended Gemini model" },
1468
+ ];
1469
+ }
1470
+ if (normalizedClient === "sample") {
1471
+ return [
1472
+ { value: "sample", label: "sample", description: "sample adapter model placeholder" },
1473
+ ];
1474
+ }
1475
+ return [];
1476
+ }
1477
+
1478
+ async function promptAIModel(ui, deps, clientName, defaultValue = "", title = "Select AI model") {
1479
+ const normalizedClient = requireDependency(deps, "normalizeLocalAIClientName")(clientName || "", "");
1480
+ const currentValue = String(defaultValue || "").trim();
1481
+ const suggestions = suggestedAIModelsForClient(normalizedClient);
1482
+ const options = [
1483
+ { value: "", label: "(blank)", description: "leave AI model empty" },
1484
+ ];
1485
+ if (currentValue && !suggestions.some((item) => item.value === currentValue)) {
1486
+ options.push({
1487
+ value: currentValue,
1488
+ label: currentValue,
1489
+ description: "current saved model",
1490
+ });
1491
+ }
1492
+ options.push(...suggestions);
1493
+ options.push({
1494
+ value: "__manual__",
1495
+ label: "Manual entry",
1496
+ description: "type the model name yourself",
1497
+ });
1498
+ const selectedIndex = Math.max(0, options.findIndex((item) => item.value === currentValue));
1499
+ const selected = await promptChoice(ui, title, options, { defaultIndex: selectedIndex >= 0 ? selectedIndex : 0 });
1500
+ if (String(selected?.value || "") === "__manual__") {
1501
+ return String(await promptRequiredLine(ui, "AI model", currentValue)).trim();
1502
+ }
1503
+ return String(selected?.value || "").trim();
1504
+ }
1505
+
1455
1506
  async function promptPermissionMode(ui, defaultValue = "") {
1456
1507
  const options = [
1457
1508
  { value: "", label: "(blank)", description: "leave permission mode empty" },
@@ -1635,7 +1686,7 @@ async function promptRoleExecutionProfile(ui, roleName, deps) {
1635
1686
  await promptAIClient(ui, deps, current.client),
1636
1687
  "",
1637
1688
  );
1638
- current.model = await promptLine(ui, `AI model for role "${current.role}"`, current.model);
1689
+ current.model = await promptAIModel(ui, deps, current.client, current.model, `Select AI model for role "${current.role}"`);
1639
1690
  current.permissionMode = requireDependency(deps, "normalizeLocalAIPermissionMode")(
1640
1691
  await promptPermissionMode(ui, current.permissionMode),
1641
1692
  "",
@@ -1725,34 +1776,11 @@ async function maybePromptGroupedServerRoleProfiles(ui, serverBot, deps) {
1725
1776
  return true;
1726
1777
  }
1727
1778
 
1728
- async function resolveTelegramServerBindingDetails(envConfig, flags, deps) {
1779
+ function resolveTelegramServerBindingDetailsFromBots(envConfig, bots, deps) {
1729
1780
  const current = safeObject(envConfig);
1730
1781
  if (!String(current.serverBotID || "").trim() && !String(current.botUsername || "").trim() && !String(current.botKey || "").trim()) {
1731
1782
  return null;
1732
1783
  }
1733
- const lookup = await requireDependency(deps, "listServerBots")({
1734
- provider: "telegram",
1735
- baseURL: flags["base-url"] || deps.defaultSiteURL,
1736
- timeoutSeconds: intFromRaw(flags["timeout-seconds"], 15) || 15,
1737
- });
1738
- if (!lookup?.ok) {
1739
- return {
1740
- ok: false,
1741
- mode: "lookup_error",
1742
- matchedBy: "",
1743
- name: "",
1744
- role: "",
1745
- roles: [],
1746
- effectiveRoleProfile: null,
1747
- effectiveRoleProfiles: {},
1748
- detail: `server bot lookup unavailable: ${lookup?.error || "unknown error"}`,
1749
- };
1750
- }
1751
- const bots = ensureArray(lookup.bots).map((bot) => ({
1752
- id: String(bot?.id || "").trim(),
1753
- role: String(bot?.role || bot?.bot_role || "").trim(),
1754
- name: String(bot?.name || "").trim(),
1755
- })).filter((bot) => bot.id);
1756
1784
  const resolveGroupedPayload = (matches, matchedBy) => {
1757
1785
  const roles = preferredRoleSort(summarizeServerBotRoles(matches));
1758
1786
  return {
@@ -1837,6 +1865,88 @@ async function resolveTelegramServerBindingDetails(envConfig, flags, deps) {
1837
1865
  };
1838
1866
  }
1839
1867
 
1868
+ async function resolveTelegramServerBindingDetails(envConfig, flags, deps) {
1869
+ const lookup = await requireDependency(deps, "listServerBots")({
1870
+ provider: "telegram",
1871
+ baseURL: flags["base-url"] || deps.defaultSiteURL,
1872
+ timeoutSeconds: intFromRaw(flags["timeout-seconds"], 15) || 15,
1873
+ });
1874
+ if (!lookup?.ok) {
1875
+ return {
1876
+ ok: false,
1877
+ mode: "lookup_error",
1878
+ matchedBy: "",
1879
+ name: "",
1880
+ role: "",
1881
+ roles: [],
1882
+ effectiveRoleProfile: null,
1883
+ effectiveRoleProfiles: {},
1884
+ detail: `server bot lookup unavailable: ${lookup?.error || "unknown error"}`,
1885
+ };
1886
+ }
1887
+ const bots = ensureArray(lookup.bots).map((bot) => ({
1888
+ id: String(bot?.id || "").trim(),
1889
+ role: String(bot?.role || bot?.bot_role || "").trim(),
1890
+ name: String(bot?.name || "").trim(),
1891
+ })).filter((bot) => bot.id);
1892
+ return resolveTelegramServerBindingDetailsFromBots(envConfig, bots, deps);
1893
+ }
1894
+
1895
+ async function buildTelegramEntrySelectionRows(entries, flags, deps) {
1896
+ const listServerBots = requireDependency(deps, "listServerBots");
1897
+ let bots = [];
1898
+ try {
1899
+ const lookup = await listServerBots({
1900
+ provider: "telegram",
1901
+ baseURL: flags["base-url"] || deps.defaultSiteURL,
1902
+ timeoutSeconds: intFromRaw(flags["timeout-seconds"], 15) || 15,
1903
+ });
1904
+ bots = ensureArray(lookup?.bots).map((bot) => ({
1905
+ id: String(bot?.id || "").trim(),
1906
+ role: String(bot?.role || bot?.bot_role || "").trim(),
1907
+ name: String(bot?.name || "").trim(),
1908
+ })).filter((bot) => bot.id);
1909
+ } catch {
1910
+ bots = [];
1911
+ }
1912
+ return ensureArray(entries).map((entry) => {
1913
+ const current = safeObject(entry);
1914
+ const binding = bots.length
1915
+ ? resolveTelegramServerBindingDetailsFromBots(
1916
+ {
1917
+ serverBotID: current.serverBotID,
1918
+ botUsername: current.username,
1919
+ botKey: current.key,
1920
+ roleProfile: current.roleProfile,
1921
+ },
1922
+ bots,
1923
+ deps,
1924
+ )
1925
+ : null;
1926
+ const serverName = String(binding?.name || "").trim();
1927
+ const singleRole = String(binding?.role || "").trim();
1928
+ const groupedRoles = ensureArray(binding?.roles).filter(Boolean);
1929
+ let label = telegramEntryDisplayName(entry);
1930
+ if (serverName && singleRole) {
1931
+ label = `${serverName} [${singleRole}]`;
1932
+ } else if (serverName && groupedRoles.length) {
1933
+ label = `${serverName} [${groupedRoles.join(", ")}]`;
1934
+ } else if (serverName) {
1935
+ label = serverName;
1936
+ }
1937
+ const descriptionParts = [
1938
+ current.key ? `local:${current.key}` : "",
1939
+ current.serverBotID ? `server:${current.serverBotID}` : "",
1940
+ current.client ? `AI:${current.client}` : "",
1941
+ ].filter(Boolean);
1942
+ return {
1943
+ value: current.key,
1944
+ label: `${label}${current.isDefault ? " [default]" : ""}`,
1945
+ description: descriptionParts.join(" "),
1946
+ };
1947
+ });
1948
+ }
1949
+
1840
1950
  function buildTemporaryTelegramEnvConfig({ token, apiBaseURL }) {
1841
1951
  return {
1842
1952
  ok: true,
@@ -2030,8 +2140,8 @@ async function addTelegramBot(ui, flags, deps) {
2030
2140
  : (autoUseServerRoleRouting
2031
2141
  ? getAIModelFlag(flags)
2032
2142
  : (autoApplyRoleDefaults
2033
- ? firstNonEmptyString([getAIModelFlag(flags), roleProfileDefaults.model])
2034
- : await promptLine(ui, "AI model", firstNonEmptyString([getAIModelFlag(flags), roleProfileDefaults.model]))));
2143
+ ? await promptAIModel(ui, deps, client, firstNonEmptyString([getAIModelFlag(flags), roleProfileDefaults.model]))
2144
+ : await promptAIModel(ui, deps, client, firstNonEmptyString([getAIModelFlag(flags), roleProfileDefaults.model]))));
2035
2145
  const permissionMode = requireDependency(deps, "normalizeLocalAIPermissionMode")(
2036
2146
  nonInteractive
2037
2147
  ? firstNonEmptyString([getAIPermissionModeFlag(flags), roleProfileDefaults.permissionMode])
@@ -2053,6 +2163,17 @@ async function addTelegramBot(ui, flags, deps) {
2053
2163
  "",
2054
2164
  );
2055
2165
 
2166
+ if (serverGroupMatched) {
2167
+ await maybePromptGroupedServerRoleProfiles(
2168
+ ui,
2169
+ {
2170
+ name: String(serverBot.name || username || botKey).trim(),
2171
+ roles: preferredRoleSort(serverBot.roles),
2172
+ },
2173
+ deps,
2174
+ );
2175
+ }
2176
+
2056
2177
  const nextParsed = upsertTelegramEntry(parsed, {
2057
2178
  key: botKey,
2058
2179
  serverBotID: String(getServerBotIDFlag(flags) || serverBot.botID || "").trim(),
@@ -2125,7 +2246,7 @@ async function editTelegramGlobalSettings(ui, flags, deps) {
2125
2246
  process.stdout.write("No Telegram bot entries exist yet.\n");
2126
2247
  return;
2127
2248
  }
2128
- const selected = await chooseTelegramEntry(ui, parsed, deps, "Select default Telegram bot");
2249
+ const selected = await chooseTelegramEntry(ui, parsed, deps, "Select default Telegram bot", flags);
2129
2250
  parsed.TELEGRAM_DEFAULT_BOT_KEY = selected.key;
2130
2251
  }
2131
2252
  const filePath = writeProviderEnvState("telegram", parsed, deps);
@@ -2138,7 +2259,7 @@ async function editTelegramBot(ui, flags, deps) {
2138
2259
  const nonInteractive = boolFromRaw(flags["non-interactive"] ?? flags.yes, false);
2139
2260
  const selected = nonInteractive
2140
2261
  ? findTelegramEntryByFlags(parsed, flags, deps)
2141
- : await chooseTelegramEntry(ui, parsed, deps);
2262
+ : await chooseTelegramEntry(ui, parsed, deps, "Select Telegram bot entry", flags);
2142
2263
  if (!selected) {
2143
2264
  throw new Error("Telegram bot selector is required for non-interactive edit");
2144
2265
  }
@@ -2178,10 +2299,10 @@ async function editTelegramBot(ui, flags, deps) {
2178
2299
  await editTelegramBotGuided(ui, parsed, selected, current, flags, deps);
2179
2300
  }
2180
2301
 
2181
- async function removeTelegramBot(ui, deps) {
2302
+ async function removeTelegramBot(ui, flags, deps) {
2182
2303
  const state = loadProviderEnvState("telegram", deps);
2183
2304
  const parsed = { ...state.parsed };
2184
- const selected = await chooseTelegramEntry(ui, parsed, deps, "Select Telegram bot entry to remove");
2305
+ const selected = await chooseTelegramEntry(ui, parsed, deps, "Select Telegram bot entry to remove", flags);
2185
2306
  if (!selected) return;
2186
2307
  if (!await promptConfirmChoice(ui, `Remove Telegram bot "${selected.key}"?`, {
2187
2308
  confirmLabel: "Remove bot",
@@ -2216,7 +2337,7 @@ async function verifyProviderEntry(ui, provider, flags, deps) {
2216
2337
  botName: requestedBotName,
2217
2338
  };
2218
2339
  } else {
2219
- const selected = await chooseTelegramEntry(ui, state.parsed, deps, "Select Telegram bot entry to verify");
2340
+ const selected = await chooseTelegramEntry(ui, state.parsed, deps, "Select Telegram bot entry to verify", flags);
2220
2341
  selectors = {
2221
2342
  botKey: selected.key,
2222
2343
  botID: selected.serverBotID,
@@ -2556,7 +2677,7 @@ async function runBotRemove(ui, flags, deps) {
2556
2677
  process.stdout.write(`Removed Telegram bot "${selected.key}" from ${filePath}\n`);
2557
2678
  return;
2558
2679
  }
2559
- await removeTelegramBot(ui, deps);
2680
+ await removeTelegramBot(ui, flags, deps);
2560
2681
  return;
2561
2682
  }
2562
2683
  await removeTokenOnlyProvider(ui, provider, flags, deps);
@@ -2583,7 +2704,7 @@ async function runBotSetDefault(ui, flags, deps) {
2583
2704
  const nonInteractive = boolFromRaw(flags["non-interactive"] ?? flags.yes, false);
2584
2705
  const selected = nonInteractive
2585
2706
  ? findTelegramEntryByFlags(parsed, flags, deps)
2586
- : await chooseTelegramEntry(ui, parsed, deps, "Select default Telegram bot");
2707
+ : await chooseTelegramEntry(ui, parsed, deps, "Select default Telegram bot", flags);
2587
2708
  if (!selected) {
2588
2709
  throw new Error("Telegram bot selector is required for set-default");
2589
2710
  }
@@ -364,14 +364,14 @@ export async function runSelftestBotCommands(push, deps) {
364
364
  "3", // select role to edit: worker
365
365
  "2", // worker: edit settings
366
366
  "3", // worker AI client: claude
367
- "worker-sonnet-4",
367
+ "2", // worker AI model: claude-sonnet-4
368
368
  "4", // worker permission: danger_full_access
369
369
  "4", // worker reasoning: high
370
370
  "y", // edit another role
371
371
  "3", // select role to edit: approval
372
372
  "2", // approval: edit settings
373
373
  "4", // approval AI client: gemini
374
- "approval-pro-2",
374
+ "2", // approval AI model: gemini-2.5-pro
375
375
  "4", // approval permission: danger_full_access
376
376
  "4", // approval reasoning: high
377
377
  "n", // stop editing roles
@@ -390,11 +390,11 @@ export async function runSelftestBotCommands(push, deps) {
390
390
  push(
391
391
  "bot_edit_grouped_server_roles_updates_role_profiles",
392
392
  String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).worker).client || "") === "claude"
393
- && String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).worker).model || "") === "worker-sonnet-4"
393
+ && String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).worker).model || "") === "claude-sonnet-4"
394
394
  && String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).worker).permission_mode || "") === "danger_full_access"
395
395
  && String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).worker).reasoning_effort || "") === "high"
396
396
  && String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).approval).client || "") === "gemini"
397
- && String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).approval).model || "") === "approval-pro-2",
397
+ && String(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).approval).model || "") === "gemini-2.5-pro",
398
398
  `worker=${JSON.stringify(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).worker))} approval=${JSON.stringify(safeObject(safeObject(groupedRunnerConfig.role_profiles || {}).approval))}`,
399
399
  );
400
400
 
@@ -503,7 +503,7 @@ export async function runSelftestBotCommands(push, deps) {
503
503
  "2", // change AI client
504
504
  "4", // gemini
505
505
  "2", // change AI model
506
- "guided-gemini-pro",
506
+ "2", // gemini model: gemini-2.5-pro
507
507
  "2", // change permission mode
508
508
  "3", // workspace_write
509
509
  "2", // change reasoning effort
@@ -522,7 +522,7 @@ export async function runSelftestBotCommands(push, deps) {
522
522
  push(
523
523
  "bot_edit_guided_prompts_update_ai_binding_fields",
524
524
  String(guidedState.TELEGRAM_BOT_MONITORSELFTESTBOT_AI_CLIENT || "") === "gemini"
525
- && String(guidedState.TELEGRAM_BOT_MONITORSELFTESTBOT_AI_MODEL || "") === "guided-gemini-pro"
525
+ && String(guidedState.TELEGRAM_BOT_MONITORSELFTESTBOT_AI_MODEL || "") === "gemini-2.5-pro"
526
526
  && String(guidedState.TELEGRAM_BOT_MONITORSELFTESTBOT_AI_PERMISSION_MODE || "") === "workspace_write"
527
527
  && String(guidedState.TELEGRAM_BOT_MONITORSELFTESTBOT_AI_REASONING_EFFORT || "") === "medium",
528
528
  `client=${String(guidedState.TELEGRAM_BOT_MONITORSELFTESTBOT_AI_CLIENT || "")} model=${String(guidedState.TELEGRAM_BOT_MONITORSELFTESTBOT_AI_MODEL || "")}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metheus-governance-mcp-cli",
3
- "version": "0.2.78",
3
+ "version": "0.2.80",
4
4
  "description": "Metheus Governance MCP CLI (setup + stdio proxy)",
5
5
  "type": "module",
6
6
  "files": [