@n1creator/openacp-cli 2026.712.10 → 2026.712.12

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/dist/index.d.ts CHANGED
@@ -5195,7 +5195,7 @@ interface TelegramChannelConfig extends ChannelConfig {
5195
5195
  * API calls while keeping the response live.
5196
5196
  * - **Callback routing**:
5197
5197
  * - `p:<key>:<optionId>` — permission approval buttons
5198
- * - `c/<command>` (or `c/#<id>` for long commands) — command button actions
5198
+ * - `c/<command>` (or `c/#<id>`) — command actions with optional allow-listed return context
5199
5199
  * - `m:<itemId>` — MenuRegistry item dispatch
5200
5200
  * - Domain prefixes (`d:`, `v:`, `ns:`, `sw:`, etc.) — specific feature flows
5201
5201
  * - **Two-phase startup**: Phase 1 starts the bot and registers handlers.
@@ -5330,6 +5330,8 @@ declare class TelegramAdapter extends MessagingAdapter {
5330
5330
  private renderCommandResponse;
5331
5331
  private toCallbackData;
5332
5332
  private fromCallbackData;
5333
+ private returnMarkup;
5334
+ private appendReturnButton;
5333
5335
  private setupRoutes;
5334
5336
  /**
5335
5337
  * Per-session serial dispatch queues.
package/dist/index.js CHANGED
@@ -10024,6 +10024,37 @@ var init_resume = __esm({
10024
10024
  }
10025
10025
  });
10026
10026
 
10027
+ // src/plugins/telegram/callback-navigation.ts
10028
+ function contextualCommandCallback(command, target) {
10029
+ if (!command.startsWith("/")) throw new Error("Telegram navigation commands must start with /");
10030
+ const data = target === "settings" ? `${SETTINGS_PREFIX}${command}` : void 0;
10031
+ return data && Buffer.byteLength(data, "utf8") <= 64 ? data : void 0;
10032
+ }
10033
+ function settingsCommandCallback(command) {
10034
+ const data = contextualCommandCallback(command, "settings");
10035
+ if (!data) throw new Error("Telegram navigation callback exceeds 64 bytes");
10036
+ return data;
10037
+ }
10038
+ function decodeCommandCallback(data) {
10039
+ if (data.startsWith(SETTINGS_PREFIX)) {
10040
+ return { command: data.slice(SETTINGS_PREFIX.length), returnTarget: "settings" };
10041
+ }
10042
+ return { command: data.slice(2) };
10043
+ }
10044
+ function returnButton(target) {
10045
+ switch (target) {
10046
+ case "settings":
10047
+ return { text: "\u25C0\uFE0F Back to Settings", callback_data: "s:back:refresh" };
10048
+ }
10049
+ }
10050
+ var SETTINGS_PREFIX;
10051
+ var init_callback_navigation = __esm({
10052
+ "src/plugins/telegram/callback-navigation.ts"() {
10053
+ "use strict";
10054
+ SETTINGS_PREFIX = "c/@settings:";
10055
+ }
10056
+ });
10057
+
10027
10058
  // src/plugins/telegram/commands/menu.ts
10028
10059
  var menu_exports = {};
10029
10060
  __export(menu_exports, {
@@ -10136,6 +10167,7 @@ async function buildSettingsKeyboard(core) {
10136
10167
  kb.text(`${label}`, `s:input:${field.path}`).row();
10137
10168
  }
10138
10169
  }
10170
+ kb.text("\u{1F310} Proxy Management", settingsCommandCallback("/proxy")).row();
10139
10171
  kb.text("\u25C0\uFE0F Back to Menu", "s:back");
10140
10172
  return kb;
10141
10173
  }
@@ -10328,6 +10360,7 @@ var init_settings = __esm({
10328
10360
  "use strict";
10329
10361
  init_config_registry();
10330
10362
  init_log();
10363
+ init_callback_navigation();
10331
10364
  log29 = createChildLogger({ module: "telegram-settings" });
10332
10365
  }
10333
10366
  });
@@ -12301,6 +12334,7 @@ var init_adapter = __esm({
12301
12334
  init_command_sync();
12302
12335
  init_command_ownership_store();
12303
12336
  init_instance_context();
12337
+ init_callback_navigation();
12304
12338
  log38 = createChildLogger({ module: "telegram" });
12305
12339
  HISTORICAL_OPENACP_COMMAND_NAMES = /* @__PURE__ */ new Set([
12306
12340
  ...STATIC_COMMANDS.map((command) => command.command),
@@ -12629,7 +12663,13 @@ var init_adapter = __esm({
12629
12663
  }
12630
12664
  });
12631
12665
  if (response.type !== "silent" && response.type !== "delegated") {
12632
- await this.renderCommandResponse(response, ctx.chat.id, topicIdForInput, String(ctx.from?.id));
12666
+ await this.renderCommandResponse(
12667
+ response,
12668
+ ctx.chat.id,
12669
+ topicIdForInput,
12670
+ String(ctx.from?.id),
12671
+ pending.returnTarget
12672
+ );
12633
12673
  }
12634
12674
  return;
12635
12675
  }
@@ -12712,7 +12752,8 @@ var init_adapter = __esm({
12712
12752
  return;
12713
12753
  }
12714
12754
  const data = ctx.callbackQuery.data;
12715
- const command = this.fromCallbackData(data);
12755
+ const callback = this.fromCallbackData(data);
12756
+ const command = callback.command;
12716
12757
  const registry = this.core.lifecycleManager?.serviceRegistry?.get(
12717
12758
  "command-registry"
12718
12759
  );
@@ -12741,16 +12782,23 @@ var init_adapter = __esm({
12741
12782
  await ctx.answerCallbackQuery();
12742
12783
  if (response.type !== "silent" && response.type !== "delegated") {
12743
12784
  if (response.type === "input") {
12744
- await this.renderCommandResponse(response, chatId, topicId, String(ctx.from?.id));
12785
+ await this.renderCommandResponse(
12786
+ response,
12787
+ chatId,
12788
+ topicId,
12789
+ String(ctx.from?.id),
12790
+ callback.returnTarget
12791
+ );
12745
12792
  return;
12746
12793
  }
12747
12794
  if (response.type === "menu") {
12748
12795
  const keyboard = response.options.map((opt) => [
12749
12796
  {
12750
12797
  text: `${opt.label}${opt.hint ? ` \u2014 ${opt.hint}` : ""}`,
12751
- callback_data: this.toCallbackData(opt.command)
12798
+ callback_data: this.toCallbackData(opt.command, callback.returnTarget)
12752
12799
  }
12753
12800
  ]);
12801
+ this.appendReturnButton(keyboard, callback.returnTarget);
12754
12802
  try {
12755
12803
  await ctx.editMessageText(response.title, {
12756
12804
  reply_markup: { inline_keyboard: keyboard }
@@ -12769,7 +12817,11 @@ var init_adapter = __esm({
12769
12817
  parseMode = "Markdown";
12770
12818
  }
12771
12819
  try {
12772
- await ctx.editMessageText(text3, { ...parseMode && { parse_mode: parseMode } });
12820
+ const returnMarkup = this.returnMarkup(callback.returnTarget);
12821
+ await ctx.editMessageText(text3, {
12822
+ ...parseMode && { parse_mode: parseMode },
12823
+ ...returnMarkup && { reply_markup: returnMarkup }
12824
+ });
12773
12825
  } catch {
12774
12826
  }
12775
12827
  }
@@ -13370,11 +13422,13 @@ System topics have been created. Tap${assistantTopicLink} to get started.`,
13370
13422
  log38.info("Telegram bot stopped");
13371
13423
  }
13372
13424
  // --- CommandRegistry response rendering ---
13373
- async renderCommandResponse(response, chatId, topicId, userId) {
13425
+ async renderCommandResponse(response, chatId, topicId, userId, returnTarget) {
13426
+ const returnMarkup = this.returnMarkup(returnTarget);
13374
13427
  switch (response.type) {
13375
13428
  case "text":
13376
13429
  await this.bot.api.sendMessage(chatId, response.text, {
13377
- message_thread_id: topicId
13430
+ message_thread_id: topicId,
13431
+ ...returnMarkup && { reply_markup: returnMarkup }
13378
13432
  });
13379
13433
  break;
13380
13434
  case "adaptive": {
@@ -13382,7 +13436,8 @@ System topics have been created. Tap${assistantTopicLink} to get started.`,
13382
13436
  const text3 = variant?.text ?? response.fallback;
13383
13437
  await this.bot.api.sendMessage(chatId, text3, {
13384
13438
  message_thread_id: topicId,
13385
- ...variant?.parse_mode && { parse_mode: variant.parse_mode }
13439
+ ...variant?.parse_mode && { parse_mode: variant.parse_mode },
13440
+ ...returnMarkup && { reply_markup: returnMarkup }
13386
13441
  });
13387
13442
  break;
13388
13443
  }
@@ -13390,16 +13445,17 @@ System topics have been created. Tap${assistantTopicLink} to get started.`,
13390
13445
  await this.bot.api.sendMessage(
13391
13446
  chatId,
13392
13447
  `\u26A0\uFE0F ${response.message}`,
13393
- { message_thread_id: topicId }
13448
+ { message_thread_id: topicId, ...returnMarkup && { reply_markup: returnMarkup } }
13394
13449
  );
13395
13450
  break;
13396
13451
  case "menu": {
13397
13452
  const keyboard = response.options.map((opt) => [
13398
13453
  {
13399
13454
  text: `${opt.label}${opt.hint ? ` \u2014 ${opt.hint}` : ""}`,
13400
- callback_data: this.toCallbackData(opt.command)
13455
+ callback_data: this.toCallbackData(opt.command, returnTarget)
13401
13456
  }
13402
13457
  ]);
13458
+ this.appendReturnButton(keyboard, returnTarget);
13403
13459
  await this.bot.api.sendMessage(chatId, response.title, {
13404
13460
  message_thread_id: topicId,
13405
13461
  reply_markup: { inline_keyboard: keyboard }
@@ -13413,7 +13469,8 @@ System topics have been created. Tap${assistantTopicLink} to get started.`,
13413
13469
  const text3 = `${response.title}
13414
13470
  ${lines.join("\n")}`;
13415
13471
  await this.bot.api.sendMessage(chatId, text3, {
13416
- message_thread_id: topicId
13472
+ message_thread_id: topicId,
13473
+ ...returnMarkup && { reply_markup: returnMarkup }
13417
13474
  });
13418
13475
  break;
13419
13476
  }
@@ -13422,16 +13479,17 @@ ${lines.join("\n")}`;
13422
13479
  [
13423
13480
  {
13424
13481
  text: "\u2705 Yes",
13425
- callback_data: this.toCallbackData(response.onYes)
13482
+ callback_data: this.toCallbackData(response.onYes, returnTarget)
13426
13483
  }
13427
13484
  ]
13428
13485
  ];
13429
13486
  if (response.onNo) {
13430
13487
  buttons[0].push({
13431
13488
  text: "\u274C No",
13432
- callback_data: this.toCallbackData(response.onNo)
13489
+ callback_data: this.toCallbackData(response.onNo, returnTarget)
13433
13490
  });
13434
13491
  }
13492
+ this.appendReturnButton(buttons, returnTarget);
13435
13493
  await this.bot.api.sendMessage(chatId, response.question, {
13436
13494
  message_thread_id: topicId,
13437
13495
  reply_markup: { inline_keyboard: buttons }
@@ -13440,7 +13498,10 @@ ${lines.join("\n")}`;
13440
13498
  }
13441
13499
  case "input": {
13442
13500
  if (!userId) {
13443
- await this.bot.api.sendMessage(chatId, response.fallback, { message_thread_id: topicId });
13501
+ await this.bot.api.sendMessage(chatId, response.fallback, {
13502
+ message_thread_id: topicId,
13503
+ ...returnMarkup && { reply_markup: returnMarkup }
13504
+ });
13444
13505
  break;
13445
13506
  }
13446
13507
  const key = `${chatId}:${userId}:${topicId ?? 0}`;
@@ -13462,7 +13523,8 @@ ${lines.join("\n")}`;
13462
13523
  sensitive: response.sensitive === true,
13463
13524
  fallback: response.fallback,
13464
13525
  expiresAt: Date.now() + (response.expiresInMs ?? 10 * 6e4),
13465
- promptMessageId: promptMessage.message_id
13526
+ promptMessageId: promptMessage.message_id,
13527
+ returnTarget
13466
13528
  });
13467
13529
  break;
13468
13530
  }
@@ -13470,11 +13532,15 @@ ${lines.join("\n")}`;
13470
13532
  break;
13471
13533
  }
13472
13534
  }
13473
- toCallbackData(command) {
13535
+ toCallbackData(command, returnTarget) {
13474
13536
  const data = `c/${command}`;
13475
- if (data.length <= 64) return data;
13537
+ if (!returnTarget && Buffer.byteLength(data, "utf8") <= 64) return data;
13538
+ if (returnTarget) {
13539
+ const contextual = contextualCommandCallback(command, returnTarget);
13540
+ if (contextual) return contextual;
13541
+ }
13476
13542
  const id = String(++this.callbackCounter);
13477
- this.callbackCache.set(id, command);
13543
+ this.callbackCache.set(id, { command, returnTarget });
13478
13544
  if (this.callbackCache.size > 1e3) {
13479
13545
  const first = this.callbackCache.keys().next().value;
13480
13546
  if (first) this.callbackCache.delete(first);
@@ -13483,9 +13549,15 @@ ${lines.join("\n")}`;
13483
13549
  }
13484
13550
  fromCallbackData(data) {
13485
13551
  if (data.startsWith("c/#")) {
13486
- return this.callbackCache.get(data.slice(3)) ?? data.slice(2);
13552
+ return this.callbackCache.get(data.slice(3)) ?? { command: data.slice(2) };
13487
13553
  }
13488
- return data.slice(2);
13554
+ return decodeCommandCallback(data);
13555
+ }
13556
+ returnMarkup(returnTarget) {
13557
+ return returnTarget ? { inline_keyboard: [[returnButton(returnTarget)]] } : void 0;
13558
+ }
13559
+ appendReturnButton(keyboard, returnTarget) {
13560
+ if (returnTarget) keyboard.push([returnButton(returnTarget)]);
13489
13561
  }
13490
13562
  setupRoutes() {
13491
13563
  this.bot.on("message:text", async (ctx) => {
@@ -20776,7 +20848,9 @@ function registerCoreMenuItems(registry) {
20776
20848
  label: "\u{1F310} Proxy Routing",
20777
20849
  priority: 32,
20778
20850
  group: "config",
20779
- action: { type: "command", command: "/proxy" }
20851
+ action: { type: "command", command: "/proxy" },
20852
+ // Keep already-sent m:core:proxy buttons valid while nesting new entry points under Settings.
20853
+ visible: () => false
20780
20854
  });
20781
20855
  registry.register({
20782
20856
  id: "core:restart",