@inline-openclaw/inline 0.0.20 → 0.0.22

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.
Files changed (43) hide show
  1. package/README.md +16 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3145 -620
  5. package/dist/index.js.map +26 -19
  6. package/dist/inline/accounts.d.ts +1 -1
  7. package/dist/inline/accounts.d.ts.map +1 -1
  8. package/dist/inline/actions.d.ts +30 -3
  9. package/dist/inline/actions.d.ts.map +1 -1
  10. package/dist/inline/bot-commands-api.d.ts +16 -0
  11. package/dist/inline/bot-commands-api.d.ts.map +1 -0
  12. package/dist/inline/bot-commands-sync.d.ts +16 -0
  13. package/dist/inline/bot-commands-sync.d.ts.map +1 -0
  14. package/dist/inline/bot-commands-tool.d.ts +6 -0
  15. package/dist/inline/bot-commands-tool.d.ts.map +1 -0
  16. package/dist/inline/channel.d.ts +1 -1
  17. package/dist/inline/channel.d.ts.map +1 -1
  18. package/dist/inline/command-menu-compat.d.ts +24 -0
  19. package/dist/inline/command-menu-compat.d.ts.map +1 -0
  20. package/dist/inline/config-schema.d.ts +42 -0
  21. package/dist/inline/config-schema.d.ts.map +1 -1
  22. package/dist/inline/media.d.ts +1 -1
  23. package/dist/inline/media.d.ts.map +1 -1
  24. package/dist/inline/members-tool.d.ts +1 -1
  25. package/dist/inline/members-tool.d.ts.map +1 -1
  26. package/dist/inline/message-formatting.d.ts +4 -0
  27. package/dist/inline/message-formatting.d.ts.map +1 -0
  28. package/dist/inline/message-tools.d.ts +1 -1
  29. package/dist/inline/message-tools.d.ts.map +1 -1
  30. package/dist/inline/monitor.d.ts +2 -1
  31. package/dist/inline/monitor.d.ts.map +1 -1
  32. package/dist/inline/policy.d.ts +1 -1
  33. package/dist/inline/policy.d.ts.map +1 -1
  34. package/dist/inline/profile-tool.d.ts +1 -1
  35. package/dist/inline/profile-tool.d.ts.map +1 -1
  36. package/dist/openclaw-compat.d.ts +141 -0
  37. package/dist/openclaw-compat.d.ts.map +1 -0
  38. package/dist/runtime.d.ts +1 -1
  39. package/dist/runtime.d.ts.map +1 -1
  40. package/dist/sdk-runtime-compat.d.ts +83 -0
  41. package/dist/sdk-runtime-compat.d.ts.map +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -5539,17 +5539,6 @@ var require_websocket_server = __commonJS((exports, module) => {
5539
5539
  }
5540
5540
  });
5541
5541
 
5542
- // src/index.ts
5543
- import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
5544
-
5545
- // src/inline/channel.ts
5546
- import {
5547
- buildChannelConfigSchema,
5548
- DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID2,
5549
- formatPairingApproveHint,
5550
- PAIRING_APPROVED_MESSAGE
5551
- } from "openclaw/plugin-sdk";
5552
-
5553
5542
  // ../protocol/dist/core.js
5554
5543
  var import_runtime = __toESM(require_commonjs(), 1);
5555
5544
  var import_runtime2 = __toESM(require_commonjs(), 1);
@@ -5711,6 +5700,9 @@ var Method;
5711
5700
  Method2[Method2["SET_BOT_COMMANDS"] = 44] = "SET_BOT_COMMANDS";
5712
5701
  Method2[Method2["GET_PEER_BOT_COMMANDS"] = 45] = "GET_PEER_BOT_COMMANDS";
5713
5702
  Method2[Method2["SHOW_CHAT_IN_SIDEBAR"] = 46] = "SHOW_CHAT_IN_SIDEBAR";
5703
+ Method2[Method2["RESERVE_CHAT_IDS"] = 47] = "RESERVE_CHAT_IDS";
5704
+ Method2[Method2["INVOKE_MESSAGE_ACTION"] = 48] = "INVOKE_MESSAGE_ACTION";
5705
+ Method2[Method2["ANSWER_MESSAGE_ACTION"] = 49] = "ANSWER_MESSAGE_ACTION";
5714
5706
  })(Method || (Method = {}));
5715
5707
  var PushNotificationProvider;
5716
5708
  (function(PushNotificationProvider2) {
@@ -7013,38 +7005,15 @@ class MessageReplies$Type extends import_runtime4.MessageType {
7013
7005
  }
7014
7006
  var MessageReplies = new MessageReplies$Type;
7015
7007
 
7016
- class Message$Type extends import_runtime4.MessageType {
7008
+ class MessageActions$Type extends import_runtime4.MessageType {
7017
7009
  constructor() {
7018
- super("Message", [
7019
- { no: 1, name: "id", kind: "scalar", T: 3, L: 0 },
7020
- { no: 2, name: "from_id", kind: "scalar", T: 3, L: 0 },
7021
- { no: 3, name: "peer_id", kind: "message", T: () => Peer },
7022
- { no: 4, name: "chat_id", kind: "scalar", T: 3, L: 0 },
7023
- { no: 5, name: "message", kind: "scalar", opt: true, T: 9 },
7024
- { no: 6, name: "out", kind: "scalar", T: 8 },
7025
- { no: 7, name: "date", kind: "scalar", T: 3, L: 0 },
7026
- { no: 8, name: "mentioned", kind: "scalar", opt: true, T: 8 },
7027
- { no: 9, name: "reply_to_msg_id", kind: "scalar", opt: true, T: 3, L: 0 },
7028
- { no: 10, name: "media", kind: "message", T: () => MessageMedia },
7029
- { no: 11, name: "edit_date", kind: "scalar", opt: true, T: 3, L: 0 },
7030
- { no: 12, name: "grouped_id", kind: "scalar", opt: true, T: 3, L: 0 },
7031
- { no: 13, name: "attachments", kind: "message", T: () => MessageAttachments },
7032
- { no: 14, name: "reactions", kind: "message", T: () => MessageReactions },
7033
- { no: 15, name: "is_sticker", kind: "scalar", opt: true, T: 8 },
7034
- { no: 6000, name: "has_link", kind: "scalar", opt: true, T: 8 },
7035
- { no: 16, name: "entities", kind: "message", T: () => MessageEntities },
7036
- { no: 17, name: "send_mode", kind: "enum", opt: true, T: () => ["MessageSendMode", MessageSendMode] },
7037
- { no: 18, name: "fwd_from", kind: "message", T: () => MessageFwdHeader },
7038
- { no: 19, name: "replies", kind: "message", T: () => MessageReplies }
7010
+ super("MessageActions", [
7011
+ { no: 1, name: "rows", kind: "message", repeat: 1, T: () => MessageActionRow }
7039
7012
  ]);
7040
7013
  }
7041
7014
  create(value) {
7042
7015
  const message = globalThis.Object.create(this.messagePrototype);
7043
- message.id = 0n;
7044
- message.fromId = 0n;
7045
- message.chatId = 0n;
7046
- message.out = false;
7047
- message.date = 0n;
7016
+ message.rows = [];
7048
7017
  if (value !== undefined)
7049
7018
  import_runtime3.reflectionMergePartial(this, message, value);
7050
7019
  return message;
@@ -7055,64 +7024,7 @@ class Message$Type extends import_runtime4.MessageType {
7055
7024
  let [fieldNo, wireType] = reader.tag();
7056
7025
  switch (fieldNo) {
7057
7026
  case 1:
7058
- message.id = reader.int64().toBigInt();
7059
- break;
7060
- case 2:
7061
- message.fromId = reader.int64().toBigInt();
7062
- break;
7063
- case 3:
7064
- message.peerId = Peer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
7065
- break;
7066
- case 4:
7067
- message.chatId = reader.int64().toBigInt();
7068
- break;
7069
- case 5:
7070
- message.message = reader.string();
7071
- break;
7072
- case 6:
7073
- message.out = reader.bool();
7074
- break;
7075
- case 7:
7076
- message.date = reader.int64().toBigInt();
7077
- break;
7078
- case 8:
7079
- message.mentioned = reader.bool();
7080
- break;
7081
- case 9:
7082
- message.replyToMsgId = reader.int64().toBigInt();
7083
- break;
7084
- case 10:
7085
- message.media = MessageMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
7086
- break;
7087
- case 11:
7088
- message.editDate = reader.int64().toBigInt();
7089
- break;
7090
- case 12:
7091
- message.groupedId = reader.int64().toBigInt();
7092
- break;
7093
- case 13:
7094
- message.attachments = MessageAttachments.internalBinaryRead(reader, reader.uint32(), options, message.attachments);
7095
- break;
7096
- case 14:
7097
- message.reactions = MessageReactions.internalBinaryRead(reader, reader.uint32(), options, message.reactions);
7098
- break;
7099
- case 15:
7100
- message.isSticker = reader.bool();
7101
- break;
7102
- case 6000:
7103
- message.hasLink = reader.bool();
7104
- break;
7105
- case 16:
7106
- message.entities = MessageEntities.internalBinaryRead(reader, reader.uint32(), options, message.entities);
7107
- break;
7108
- case 17:
7109
- message.sendMode = reader.int32();
7110
- break;
7111
- case 18:
7112
- message.fwdFrom = MessageFwdHeader.internalBinaryRead(reader, reader.uint32(), options, message.fwdFrom);
7113
- break;
7114
- case 19:
7115
- message.replies = MessageReplies.internalBinaryRead(reader, reader.uint32(), options, message.replies);
7027
+ message.rows.push(MessageActionRow.internalBinaryRead(reader, reader.uint32(), options));
7116
7028
  break;
7117
7029
  default:
7118
7030
  let u = options.readUnknownField;
@@ -7126,66 +7038,25 @@ class Message$Type extends import_runtime4.MessageType {
7126
7038
  return message;
7127
7039
  }
7128
7040
  internalBinaryWrite(message, writer, options) {
7129
- if (message.id !== 0n)
7130
- writer.tag(1, import_runtime.WireType.Varint).int64(message.id);
7131
- if (message.fromId !== 0n)
7132
- writer.tag(2, import_runtime.WireType.Varint).int64(message.fromId);
7133
- if (message.peerId)
7134
- Peer.internalBinaryWrite(message.peerId, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
7135
- if (message.chatId !== 0n)
7136
- writer.tag(4, import_runtime.WireType.Varint).int64(message.chatId);
7137
- if (message.message !== undefined)
7138
- writer.tag(5, import_runtime.WireType.LengthDelimited).string(message.message);
7139
- if (message.out !== false)
7140
- writer.tag(6, import_runtime.WireType.Varint).bool(message.out);
7141
- if (message.date !== 0n)
7142
- writer.tag(7, import_runtime.WireType.Varint).int64(message.date);
7143
- if (message.mentioned !== undefined)
7144
- writer.tag(8, import_runtime.WireType.Varint).bool(message.mentioned);
7145
- if (message.replyToMsgId !== undefined)
7146
- writer.tag(9, import_runtime.WireType.Varint).int64(message.replyToMsgId);
7147
- if (message.media)
7148
- MessageMedia.internalBinaryWrite(message.media, writer.tag(10, import_runtime.WireType.LengthDelimited).fork(), options).join();
7149
- if (message.editDate !== undefined)
7150
- writer.tag(11, import_runtime.WireType.Varint).int64(message.editDate);
7151
- if (message.groupedId !== undefined)
7152
- writer.tag(12, import_runtime.WireType.Varint).int64(message.groupedId);
7153
- if (message.attachments)
7154
- MessageAttachments.internalBinaryWrite(message.attachments, writer.tag(13, import_runtime.WireType.LengthDelimited).fork(), options).join();
7155
- if (message.reactions)
7156
- MessageReactions.internalBinaryWrite(message.reactions, writer.tag(14, import_runtime.WireType.LengthDelimited).fork(), options).join();
7157
- if (message.isSticker !== undefined)
7158
- writer.tag(15, import_runtime.WireType.Varint).bool(message.isSticker);
7159
- if (message.hasLink !== undefined)
7160
- writer.tag(6000, import_runtime.WireType.Varint).bool(message.hasLink);
7161
- if (message.entities)
7162
- MessageEntities.internalBinaryWrite(message.entities, writer.tag(16, import_runtime.WireType.LengthDelimited).fork(), options).join();
7163
- if (message.sendMode !== undefined)
7164
- writer.tag(17, import_runtime.WireType.Varint).int32(message.sendMode);
7165
- if (message.fwdFrom)
7166
- MessageFwdHeader.internalBinaryWrite(message.fwdFrom, writer.tag(18, import_runtime.WireType.LengthDelimited).fork(), options).join();
7167
- if (message.replies)
7168
- MessageReplies.internalBinaryWrite(message.replies, writer.tag(19, import_runtime.WireType.LengthDelimited).fork(), options).join();
7041
+ for (let i = 0;i < message.rows.length; i++)
7042
+ MessageActionRow.internalBinaryWrite(message.rows[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7169
7043
  let u = options.writeUnknownFields;
7170
7044
  if (u !== false)
7171
7045
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7172
7046
  return writer;
7173
7047
  }
7174
7048
  }
7175
- var Message = new Message$Type;
7049
+ var MessageActions = new MessageActions$Type;
7176
7050
 
7177
- class MessageFwdHeader$Type extends import_runtime4.MessageType {
7051
+ class MessageActionRow$Type extends import_runtime4.MessageType {
7178
7052
  constructor() {
7179
- super("MessageFwdHeader", [
7180
- { no: 1, name: "from_peer_id", kind: "message", T: () => Peer },
7181
- { no: 2, name: "from_id", kind: "scalar", T: 3, L: 0 },
7182
- { no: 3, name: "from_message_id", kind: "scalar", T: 3, L: 0 }
7053
+ super("MessageActionRow", [
7054
+ { no: 1, name: "actions", kind: "message", repeat: 1, T: () => MessageAction }
7183
7055
  ]);
7184
7056
  }
7185
7057
  create(value) {
7186
7058
  const message = globalThis.Object.create(this.messagePrototype);
7187
- message.fromId = 0n;
7188
- message.fromMessageId = 0n;
7059
+ message.actions = [];
7189
7060
  if (value !== undefined)
7190
7061
  import_runtime3.reflectionMergePartial(this, message, value);
7191
7062
  return message;
@@ -7196,13 +7067,7 @@ class MessageFwdHeader$Type extends import_runtime4.MessageType {
7196
7067
  let [fieldNo, wireType] = reader.tag();
7197
7068
  switch (fieldNo) {
7198
7069
  case 1:
7199
- message.fromPeerId = Peer.internalBinaryRead(reader, reader.uint32(), options, message.fromPeerId);
7200
- break;
7201
- case 2:
7202
- message.fromId = reader.int64().toBigInt();
7203
- break;
7204
- case 3:
7205
- message.fromMessageId = reader.int64().toBigInt();
7070
+ message.actions.push(MessageAction.internalBinaryRead(reader, reader.uint32(), options));
7206
7071
  break;
7207
7072
  default:
7208
7073
  let u = options.readUnknownField;
@@ -7216,29 +7081,30 @@ class MessageFwdHeader$Type extends import_runtime4.MessageType {
7216
7081
  return message;
7217
7082
  }
7218
7083
  internalBinaryWrite(message, writer, options) {
7219
- if (message.fromPeerId)
7220
- Peer.internalBinaryWrite(message.fromPeerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7221
- if (message.fromId !== 0n)
7222
- writer.tag(2, import_runtime.WireType.Varint).int64(message.fromId);
7223
- if (message.fromMessageId !== 0n)
7224
- writer.tag(3, import_runtime.WireType.Varint).int64(message.fromMessageId);
7084
+ for (let i = 0;i < message.actions.length; i++)
7085
+ MessageAction.internalBinaryWrite(message.actions[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7225
7086
  let u = options.writeUnknownFields;
7226
7087
  if (u !== false)
7227
7088
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7228
7089
  return writer;
7229
7090
  }
7230
7091
  }
7231
- var MessageFwdHeader = new MessageFwdHeader$Type;
7092
+ var MessageActionRow = new MessageActionRow$Type;
7232
7093
 
7233
- class MessageEntities$Type extends import_runtime4.MessageType {
7094
+ class MessageAction$Type extends import_runtime4.MessageType {
7234
7095
  constructor() {
7235
- super("MessageEntities", [
7236
- { no: 1, name: "entities", kind: "message", repeat: 1, T: () => MessageEntity }
7096
+ super("MessageAction", [
7097
+ { no: 1, name: "action_id", kind: "scalar", T: 9 },
7098
+ { no: 2, name: "text", kind: "scalar", T: 9 },
7099
+ { no: 3, name: "callback", kind: "message", oneof: "action", T: () => MessageActionCallback },
7100
+ { no: 4, name: "copy_text", kind: "message", oneof: "action", T: () => MessageActionCopyText }
7237
7101
  ]);
7238
7102
  }
7239
7103
  create(value) {
7240
7104
  const message = globalThis.Object.create(this.messagePrototype);
7241
- message.entities = [];
7105
+ message.actionId = "";
7106
+ message.text = "";
7107
+ message.action = { oneofKind: undefined };
7242
7108
  if (value !== undefined)
7243
7109
  import_runtime3.reflectionMergePartial(this, message, value);
7244
7110
  return message;
@@ -7249,7 +7115,22 @@ class MessageEntities$Type extends import_runtime4.MessageType {
7249
7115
  let [fieldNo, wireType] = reader.tag();
7250
7116
  switch (fieldNo) {
7251
7117
  case 1:
7252
- message.entities.push(MessageEntity.internalBinaryRead(reader, reader.uint32(), options));
7118
+ message.actionId = reader.string();
7119
+ break;
7120
+ case 2:
7121
+ message.text = reader.string();
7122
+ break;
7123
+ case 3:
7124
+ message.action = {
7125
+ oneofKind: "callback",
7126
+ callback: MessageActionCallback.internalBinaryRead(reader, reader.uint32(), options, message.action.callback)
7127
+ };
7128
+ break;
7129
+ case 4:
7130
+ message.action = {
7131
+ oneofKind: "copyText",
7132
+ copyText: MessageActionCopyText.internalBinaryRead(reader, reader.uint32(), options, message.action.copyText)
7133
+ };
7253
7134
  break;
7254
7135
  default:
7255
7136
  let u = options.readUnknownField;
@@ -7263,33 +7144,31 @@ class MessageEntities$Type extends import_runtime4.MessageType {
7263
7144
  return message;
7264
7145
  }
7265
7146
  internalBinaryWrite(message, writer, options) {
7266
- for (let i = 0;i < message.entities.length; i++)
7267
- MessageEntity.internalBinaryWrite(message.entities[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7147
+ if (message.actionId !== "")
7148
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.actionId);
7149
+ if (message.text !== "")
7150
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.text);
7151
+ if (message.action.oneofKind === "callback")
7152
+ MessageActionCallback.internalBinaryWrite(message.action.callback, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
7153
+ if (message.action.oneofKind === "copyText")
7154
+ MessageActionCopyText.internalBinaryWrite(message.action.copyText, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
7268
7155
  let u = options.writeUnknownFields;
7269
7156
  if (u !== false)
7270
7157
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7271
7158
  return writer;
7272
7159
  }
7273
7160
  }
7274
- var MessageEntities = new MessageEntities$Type;
7161
+ var MessageAction = new MessageAction$Type;
7275
7162
 
7276
- class MessageEntity$Type extends import_runtime4.MessageType {
7163
+ class MessageActionCallback$Type extends import_runtime4.MessageType {
7277
7164
  constructor() {
7278
- super("MessageEntity", [
7279
- { no: 1, name: "type", kind: "enum", T: () => ["MessageEntity.Type", MessageEntity_Type, "TYPE_"] },
7280
- { no: 2, name: "offset", kind: "scalar", T: 3, L: 0 },
7281
- { no: 3, name: "length", kind: "scalar", T: 3, L: 0 },
7282
- { no: 4, name: "mention", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityMention },
7283
- { no: 5, name: "text_url", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityTextUrl },
7284
- { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre }
7165
+ super("MessageActionCallback", [
7166
+ { no: 1, name: "data", kind: "scalar", T: 12 }
7285
7167
  ]);
7286
7168
  }
7287
7169
  create(value) {
7288
7170
  const message = globalThis.Object.create(this.messagePrototype);
7289
- message.type = 0;
7290
- message.offset = 0n;
7291
- message.length = 0n;
7292
- message.entity = { oneofKind: undefined };
7171
+ message.data = new Uint8Array(0);
7293
7172
  if (value !== undefined)
7294
7173
  import_runtime3.reflectionMergePartial(this, message, value);
7295
7174
  return message;
@@ -7300,31 +7179,7 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7300
7179
  let [fieldNo, wireType] = reader.tag();
7301
7180
  switch (fieldNo) {
7302
7181
  case 1:
7303
- message.type = reader.int32();
7304
- break;
7305
- case 2:
7306
- message.offset = reader.int64().toBigInt();
7307
- break;
7308
- case 3:
7309
- message.length = reader.int64().toBigInt();
7310
- break;
7311
- case 4:
7312
- message.entity = {
7313
- oneofKind: "mention",
7314
- mention: MessageEntity_MessageEntityMention.internalBinaryRead(reader, reader.uint32(), options, message.entity.mention)
7315
- };
7316
- break;
7317
- case 5:
7318
- message.entity = {
7319
- oneofKind: "textUrl",
7320
- textUrl: MessageEntity_MessageEntityTextUrl.internalBinaryRead(reader, reader.uint32(), options, message.entity.textUrl)
7321
- };
7322
- break;
7323
- case 6:
7324
- message.entity = {
7325
- oneofKind: "pre",
7326
- pre: MessageEntity_MessageEntityPre.internalBinaryRead(reader, reader.uint32(), options, message.entity.pre)
7327
- };
7182
+ message.data = reader.bytes();
7328
7183
  break;
7329
7184
  default:
7330
7185
  let u = options.readUnknownField;
@@ -7338,35 +7193,25 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7338
7193
  return message;
7339
7194
  }
7340
7195
  internalBinaryWrite(message, writer, options) {
7341
- if (message.type !== 0)
7342
- writer.tag(1, import_runtime.WireType.Varint).int32(message.type);
7343
- if (message.offset !== 0n)
7344
- writer.tag(2, import_runtime.WireType.Varint).int64(message.offset);
7345
- if (message.length !== 0n)
7346
- writer.tag(3, import_runtime.WireType.Varint).int64(message.length);
7347
- if (message.entity.oneofKind === "mention")
7348
- MessageEntity_MessageEntityMention.internalBinaryWrite(message.entity.mention, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
7349
- if (message.entity.oneofKind === "textUrl")
7350
- MessageEntity_MessageEntityTextUrl.internalBinaryWrite(message.entity.textUrl, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
7351
- if (message.entity.oneofKind === "pre")
7352
- MessageEntity_MessageEntityPre.internalBinaryWrite(message.entity.pre, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
7196
+ if (message.data.length)
7197
+ writer.tag(1, import_runtime.WireType.LengthDelimited).bytes(message.data);
7353
7198
  let u = options.writeUnknownFields;
7354
7199
  if (u !== false)
7355
7200
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7356
7201
  return writer;
7357
7202
  }
7358
7203
  }
7359
- var MessageEntity = new MessageEntity$Type;
7204
+ var MessageActionCallback = new MessageActionCallback$Type;
7360
7205
 
7361
- class MessageEntity_MessageEntityMention$Type extends import_runtime4.MessageType {
7206
+ class MessageActionCopyText$Type extends import_runtime4.MessageType {
7362
7207
  constructor() {
7363
- super("MessageEntity.MessageEntityMention", [
7364
- { no: 1, name: "user_id", kind: "scalar", T: 3, L: 0 }
7208
+ super("MessageActionCopyText", [
7209
+ { no: 1, name: "text", kind: "scalar", T: 9 }
7365
7210
  ]);
7366
7211
  }
7367
7212
  create(value) {
7368
7213
  const message = globalThis.Object.create(this.messagePrototype);
7369
- message.userId = 0n;
7214
+ message.text = "";
7370
7215
  if (value !== undefined)
7371
7216
  import_runtime3.reflectionMergePartial(this, message, value);
7372
7217
  return message;
@@ -7377,7 +7222,7 @@ class MessageEntity_MessageEntityMention$Type extends import_runtime4.MessageTyp
7377
7222
  let [fieldNo, wireType] = reader.tag();
7378
7223
  switch (fieldNo) {
7379
7224
  case 1:
7380
- message.userId = reader.int64().toBigInt();
7225
+ message.text = reader.string();
7381
7226
  break;
7382
7227
  default:
7383
7228
  let u = options.readUnknownField;
@@ -7391,25 +7236,25 @@ class MessageEntity_MessageEntityMention$Type extends import_runtime4.MessageTyp
7391
7236
  return message;
7392
7237
  }
7393
7238
  internalBinaryWrite(message, writer, options) {
7394
- if (message.userId !== 0n)
7395
- writer.tag(1, import_runtime.WireType.Varint).int64(message.userId);
7239
+ if (message.text !== "")
7240
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.text);
7396
7241
  let u = options.writeUnknownFields;
7397
7242
  if (u !== false)
7398
7243
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7399
7244
  return writer;
7400
7245
  }
7401
7246
  }
7402
- var MessageEntity_MessageEntityMention = new MessageEntity_MessageEntityMention$Type;
7247
+ var MessageActionCopyText = new MessageActionCopyText$Type;
7403
7248
 
7404
- class MessageEntity_MessageEntityTextUrl$Type extends import_runtime4.MessageType {
7249
+ class MessageActionResponseUi$Type extends import_runtime4.MessageType {
7405
7250
  constructor() {
7406
- super("MessageEntity.MessageEntityTextUrl", [
7407
- { no: 1, name: "url", kind: "scalar", T: 9 }
7251
+ super("MessageActionResponseUi", [
7252
+ { no: 1, name: "toast", kind: "message", oneof: "kind", T: () => MessageActionToast }
7408
7253
  ]);
7409
7254
  }
7410
7255
  create(value) {
7411
7256
  const message = globalThis.Object.create(this.messagePrototype);
7412
- message.url = "";
7257
+ message.kind = { oneofKind: undefined };
7413
7258
  if (value !== undefined)
7414
7259
  import_runtime3.reflectionMergePartial(this, message, value);
7415
7260
  return message;
@@ -7420,7 +7265,10 @@ class MessageEntity_MessageEntityTextUrl$Type extends import_runtime4.MessageTyp
7420
7265
  let [fieldNo, wireType] = reader.tag();
7421
7266
  switch (fieldNo) {
7422
7267
  case 1:
7423
- message.url = reader.string();
7268
+ message.kind = {
7269
+ oneofKind: "toast",
7270
+ toast: MessageActionToast.internalBinaryRead(reader, reader.uint32(), options, message.kind.toast)
7271
+ };
7424
7272
  break;
7425
7273
  default:
7426
7274
  let u = options.readUnknownField;
@@ -7434,25 +7282,25 @@ class MessageEntity_MessageEntityTextUrl$Type extends import_runtime4.MessageTyp
7434
7282
  return message;
7435
7283
  }
7436
7284
  internalBinaryWrite(message, writer, options) {
7437
- if (message.url !== "")
7438
- writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
7285
+ if (message.kind.oneofKind === "toast")
7286
+ MessageActionToast.internalBinaryWrite(message.kind.toast, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7439
7287
  let u = options.writeUnknownFields;
7440
7288
  if (u !== false)
7441
7289
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7442
7290
  return writer;
7443
7291
  }
7444
7292
  }
7445
- var MessageEntity_MessageEntityTextUrl = new MessageEntity_MessageEntityTextUrl$Type;
7293
+ var MessageActionResponseUi = new MessageActionResponseUi$Type;
7446
7294
 
7447
- class MessageEntity_MessageEntityPre$Type extends import_runtime4.MessageType {
7295
+ class MessageActionToast$Type extends import_runtime4.MessageType {
7448
7296
  constructor() {
7449
- super("MessageEntity.MessageEntityPre", [
7450
- { no: 1, name: "language", kind: "scalar", T: 9 }
7297
+ super("MessageActionToast", [
7298
+ { no: 1, name: "text", kind: "scalar", T: 9 }
7451
7299
  ]);
7452
7300
  }
7453
7301
  create(value) {
7454
7302
  const message = globalThis.Object.create(this.messagePrototype);
7455
- message.language = "";
7303
+ message.text = "";
7456
7304
  if (value !== undefined)
7457
7305
  import_runtime3.reflectionMergePartial(this, message, value);
7458
7306
  return message;
@@ -7463,7 +7311,7 @@ class MessageEntity_MessageEntityPre$Type extends import_runtime4.MessageType {
7463
7311
  let [fieldNo, wireType] = reader.tag();
7464
7312
  switch (fieldNo) {
7465
7313
  case 1:
7466
- message.language = reader.string();
7314
+ message.text = reader.string();
7467
7315
  break;
7468
7316
  default:
7469
7317
  let u = options.readUnknownField;
@@ -7477,20 +7325,500 @@ class MessageEntity_MessageEntityPre$Type extends import_runtime4.MessageType {
7477
7325
  return message;
7478
7326
  }
7479
7327
  internalBinaryWrite(message, writer, options) {
7480
- if (message.language !== "")
7481
- writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.language);
7328
+ if (message.text !== "")
7329
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.text);
7482
7330
  let u = options.writeUnknownFields;
7483
7331
  if (u !== false)
7484
7332
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7485
7333
  return writer;
7486
7334
  }
7487
7335
  }
7488
- var MessageEntity_MessageEntityPre = new MessageEntity_MessageEntityPre$Type;
7336
+ var MessageActionToast = new MessageActionToast$Type;
7489
7337
 
7490
- class MessageReactions$Type extends import_runtime4.MessageType {
7338
+ class Message$Type extends import_runtime4.MessageType {
7491
7339
  constructor() {
7492
- super("MessageReactions", [
7493
- { no: 1, name: "reactions", kind: "message", repeat: 1, T: () => Reaction }
7340
+ super("Message", [
7341
+ { no: 1, name: "id", kind: "scalar", T: 3, L: 0 },
7342
+ { no: 2, name: "from_id", kind: "scalar", T: 3, L: 0 },
7343
+ { no: 3, name: "peer_id", kind: "message", T: () => Peer },
7344
+ { no: 4, name: "chat_id", kind: "scalar", T: 3, L: 0 },
7345
+ { no: 5, name: "message", kind: "scalar", opt: true, T: 9 },
7346
+ { no: 6, name: "out", kind: "scalar", T: 8 },
7347
+ { no: 7, name: "date", kind: "scalar", T: 3, L: 0 },
7348
+ { no: 8, name: "mentioned", kind: "scalar", opt: true, T: 8 },
7349
+ { no: 9, name: "reply_to_msg_id", kind: "scalar", opt: true, T: 3, L: 0 },
7350
+ { no: 10, name: "media", kind: "message", T: () => MessageMedia },
7351
+ { no: 11, name: "edit_date", kind: "scalar", opt: true, T: 3, L: 0 },
7352
+ { no: 12, name: "grouped_id", kind: "scalar", opt: true, T: 3, L: 0 },
7353
+ { no: 13, name: "attachments", kind: "message", T: () => MessageAttachments },
7354
+ { no: 14, name: "reactions", kind: "message", T: () => MessageReactions },
7355
+ { no: 15, name: "is_sticker", kind: "scalar", opt: true, T: 8 },
7356
+ { no: 6000, name: "has_link", kind: "scalar", opt: true, T: 8 },
7357
+ { no: 16, name: "entities", kind: "message", T: () => MessageEntities },
7358
+ { no: 17, name: "send_mode", kind: "enum", opt: true, T: () => ["MessageSendMode", MessageSendMode] },
7359
+ { no: 18, name: "fwd_from", kind: "message", T: () => MessageFwdHeader },
7360
+ { no: 19, name: "replies", kind: "message", T: () => MessageReplies },
7361
+ { no: 20, name: "actions", kind: "message", T: () => MessageActions }
7362
+ ]);
7363
+ }
7364
+ create(value) {
7365
+ const message = globalThis.Object.create(this.messagePrototype);
7366
+ message.id = 0n;
7367
+ message.fromId = 0n;
7368
+ message.chatId = 0n;
7369
+ message.out = false;
7370
+ message.date = 0n;
7371
+ if (value !== undefined)
7372
+ import_runtime3.reflectionMergePartial(this, message, value);
7373
+ return message;
7374
+ }
7375
+ internalBinaryRead(reader, length, options, target) {
7376
+ let message = target ?? this.create(), end = reader.pos + length;
7377
+ while (reader.pos < end) {
7378
+ let [fieldNo, wireType] = reader.tag();
7379
+ switch (fieldNo) {
7380
+ case 1:
7381
+ message.id = reader.int64().toBigInt();
7382
+ break;
7383
+ case 2:
7384
+ message.fromId = reader.int64().toBigInt();
7385
+ break;
7386
+ case 3:
7387
+ message.peerId = Peer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
7388
+ break;
7389
+ case 4:
7390
+ message.chatId = reader.int64().toBigInt();
7391
+ break;
7392
+ case 5:
7393
+ message.message = reader.string();
7394
+ break;
7395
+ case 6:
7396
+ message.out = reader.bool();
7397
+ break;
7398
+ case 7:
7399
+ message.date = reader.int64().toBigInt();
7400
+ break;
7401
+ case 8:
7402
+ message.mentioned = reader.bool();
7403
+ break;
7404
+ case 9:
7405
+ message.replyToMsgId = reader.int64().toBigInt();
7406
+ break;
7407
+ case 10:
7408
+ message.media = MessageMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
7409
+ break;
7410
+ case 11:
7411
+ message.editDate = reader.int64().toBigInt();
7412
+ break;
7413
+ case 12:
7414
+ message.groupedId = reader.int64().toBigInt();
7415
+ break;
7416
+ case 13:
7417
+ message.attachments = MessageAttachments.internalBinaryRead(reader, reader.uint32(), options, message.attachments);
7418
+ break;
7419
+ case 14:
7420
+ message.reactions = MessageReactions.internalBinaryRead(reader, reader.uint32(), options, message.reactions);
7421
+ break;
7422
+ case 15:
7423
+ message.isSticker = reader.bool();
7424
+ break;
7425
+ case 6000:
7426
+ message.hasLink = reader.bool();
7427
+ break;
7428
+ case 16:
7429
+ message.entities = MessageEntities.internalBinaryRead(reader, reader.uint32(), options, message.entities);
7430
+ break;
7431
+ case 17:
7432
+ message.sendMode = reader.int32();
7433
+ break;
7434
+ case 18:
7435
+ message.fwdFrom = MessageFwdHeader.internalBinaryRead(reader, reader.uint32(), options, message.fwdFrom);
7436
+ break;
7437
+ case 19:
7438
+ message.replies = MessageReplies.internalBinaryRead(reader, reader.uint32(), options, message.replies);
7439
+ break;
7440
+ case 20:
7441
+ message.actions = MessageActions.internalBinaryRead(reader, reader.uint32(), options, message.actions);
7442
+ break;
7443
+ default:
7444
+ let u = options.readUnknownField;
7445
+ if (u === "throw")
7446
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7447
+ let d = reader.skip(wireType);
7448
+ if (u !== false)
7449
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7450
+ }
7451
+ }
7452
+ return message;
7453
+ }
7454
+ internalBinaryWrite(message, writer, options) {
7455
+ if (message.id !== 0n)
7456
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.id);
7457
+ if (message.fromId !== 0n)
7458
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.fromId);
7459
+ if (message.peerId)
7460
+ Peer.internalBinaryWrite(message.peerId, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
7461
+ if (message.chatId !== 0n)
7462
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.chatId);
7463
+ if (message.message !== undefined)
7464
+ writer.tag(5, import_runtime.WireType.LengthDelimited).string(message.message);
7465
+ if (message.out !== false)
7466
+ writer.tag(6, import_runtime.WireType.Varint).bool(message.out);
7467
+ if (message.date !== 0n)
7468
+ writer.tag(7, import_runtime.WireType.Varint).int64(message.date);
7469
+ if (message.mentioned !== undefined)
7470
+ writer.tag(8, import_runtime.WireType.Varint).bool(message.mentioned);
7471
+ if (message.replyToMsgId !== undefined)
7472
+ writer.tag(9, import_runtime.WireType.Varint).int64(message.replyToMsgId);
7473
+ if (message.media)
7474
+ MessageMedia.internalBinaryWrite(message.media, writer.tag(10, import_runtime.WireType.LengthDelimited).fork(), options).join();
7475
+ if (message.editDate !== undefined)
7476
+ writer.tag(11, import_runtime.WireType.Varint).int64(message.editDate);
7477
+ if (message.groupedId !== undefined)
7478
+ writer.tag(12, import_runtime.WireType.Varint).int64(message.groupedId);
7479
+ if (message.attachments)
7480
+ MessageAttachments.internalBinaryWrite(message.attachments, writer.tag(13, import_runtime.WireType.LengthDelimited).fork(), options).join();
7481
+ if (message.reactions)
7482
+ MessageReactions.internalBinaryWrite(message.reactions, writer.tag(14, import_runtime.WireType.LengthDelimited).fork(), options).join();
7483
+ if (message.isSticker !== undefined)
7484
+ writer.tag(15, import_runtime.WireType.Varint).bool(message.isSticker);
7485
+ if (message.hasLink !== undefined)
7486
+ writer.tag(6000, import_runtime.WireType.Varint).bool(message.hasLink);
7487
+ if (message.entities)
7488
+ MessageEntities.internalBinaryWrite(message.entities, writer.tag(16, import_runtime.WireType.LengthDelimited).fork(), options).join();
7489
+ if (message.sendMode !== undefined)
7490
+ writer.tag(17, import_runtime.WireType.Varint).int32(message.sendMode);
7491
+ if (message.fwdFrom)
7492
+ MessageFwdHeader.internalBinaryWrite(message.fwdFrom, writer.tag(18, import_runtime.WireType.LengthDelimited).fork(), options).join();
7493
+ if (message.replies)
7494
+ MessageReplies.internalBinaryWrite(message.replies, writer.tag(19, import_runtime.WireType.LengthDelimited).fork(), options).join();
7495
+ if (message.actions)
7496
+ MessageActions.internalBinaryWrite(message.actions, writer.tag(20, import_runtime.WireType.LengthDelimited).fork(), options).join();
7497
+ let u = options.writeUnknownFields;
7498
+ if (u !== false)
7499
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7500
+ return writer;
7501
+ }
7502
+ }
7503
+ var Message = new Message$Type;
7504
+
7505
+ class MessageFwdHeader$Type extends import_runtime4.MessageType {
7506
+ constructor() {
7507
+ super("MessageFwdHeader", [
7508
+ { no: 1, name: "from_peer_id", kind: "message", T: () => Peer },
7509
+ { no: 2, name: "from_id", kind: "scalar", T: 3, L: 0 },
7510
+ { no: 3, name: "from_message_id", kind: "scalar", T: 3, L: 0 }
7511
+ ]);
7512
+ }
7513
+ create(value) {
7514
+ const message = globalThis.Object.create(this.messagePrototype);
7515
+ message.fromId = 0n;
7516
+ message.fromMessageId = 0n;
7517
+ if (value !== undefined)
7518
+ import_runtime3.reflectionMergePartial(this, message, value);
7519
+ return message;
7520
+ }
7521
+ internalBinaryRead(reader, length, options, target) {
7522
+ let message = target ?? this.create(), end = reader.pos + length;
7523
+ while (reader.pos < end) {
7524
+ let [fieldNo, wireType] = reader.tag();
7525
+ switch (fieldNo) {
7526
+ case 1:
7527
+ message.fromPeerId = Peer.internalBinaryRead(reader, reader.uint32(), options, message.fromPeerId);
7528
+ break;
7529
+ case 2:
7530
+ message.fromId = reader.int64().toBigInt();
7531
+ break;
7532
+ case 3:
7533
+ message.fromMessageId = reader.int64().toBigInt();
7534
+ break;
7535
+ default:
7536
+ let u = options.readUnknownField;
7537
+ if (u === "throw")
7538
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7539
+ let d = reader.skip(wireType);
7540
+ if (u !== false)
7541
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7542
+ }
7543
+ }
7544
+ return message;
7545
+ }
7546
+ internalBinaryWrite(message, writer, options) {
7547
+ if (message.fromPeerId)
7548
+ Peer.internalBinaryWrite(message.fromPeerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7549
+ if (message.fromId !== 0n)
7550
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.fromId);
7551
+ if (message.fromMessageId !== 0n)
7552
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.fromMessageId);
7553
+ let u = options.writeUnknownFields;
7554
+ if (u !== false)
7555
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7556
+ return writer;
7557
+ }
7558
+ }
7559
+ var MessageFwdHeader = new MessageFwdHeader$Type;
7560
+
7561
+ class MessageEntities$Type extends import_runtime4.MessageType {
7562
+ constructor() {
7563
+ super("MessageEntities", [
7564
+ { no: 1, name: "entities", kind: "message", repeat: 1, T: () => MessageEntity }
7565
+ ]);
7566
+ }
7567
+ create(value) {
7568
+ const message = globalThis.Object.create(this.messagePrototype);
7569
+ message.entities = [];
7570
+ if (value !== undefined)
7571
+ import_runtime3.reflectionMergePartial(this, message, value);
7572
+ return message;
7573
+ }
7574
+ internalBinaryRead(reader, length, options, target) {
7575
+ let message = target ?? this.create(), end = reader.pos + length;
7576
+ while (reader.pos < end) {
7577
+ let [fieldNo, wireType] = reader.tag();
7578
+ switch (fieldNo) {
7579
+ case 1:
7580
+ message.entities.push(MessageEntity.internalBinaryRead(reader, reader.uint32(), options));
7581
+ break;
7582
+ default:
7583
+ let u = options.readUnknownField;
7584
+ if (u === "throw")
7585
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7586
+ let d = reader.skip(wireType);
7587
+ if (u !== false)
7588
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7589
+ }
7590
+ }
7591
+ return message;
7592
+ }
7593
+ internalBinaryWrite(message, writer, options) {
7594
+ for (let i = 0;i < message.entities.length; i++)
7595
+ MessageEntity.internalBinaryWrite(message.entities[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7596
+ let u = options.writeUnknownFields;
7597
+ if (u !== false)
7598
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7599
+ return writer;
7600
+ }
7601
+ }
7602
+ var MessageEntities = new MessageEntities$Type;
7603
+
7604
+ class MessageEntity$Type extends import_runtime4.MessageType {
7605
+ constructor() {
7606
+ super("MessageEntity", [
7607
+ { no: 1, name: "type", kind: "enum", T: () => ["MessageEntity.Type", MessageEntity_Type, "TYPE_"] },
7608
+ { no: 2, name: "offset", kind: "scalar", T: 3, L: 0 },
7609
+ { no: 3, name: "length", kind: "scalar", T: 3, L: 0 },
7610
+ { no: 4, name: "mention", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityMention },
7611
+ { no: 5, name: "text_url", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityTextUrl },
7612
+ { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre }
7613
+ ]);
7614
+ }
7615
+ create(value) {
7616
+ const message = globalThis.Object.create(this.messagePrototype);
7617
+ message.type = 0;
7618
+ message.offset = 0n;
7619
+ message.length = 0n;
7620
+ message.entity = { oneofKind: undefined };
7621
+ if (value !== undefined)
7622
+ import_runtime3.reflectionMergePartial(this, message, value);
7623
+ return message;
7624
+ }
7625
+ internalBinaryRead(reader, length, options, target) {
7626
+ let message = target ?? this.create(), end = reader.pos + length;
7627
+ while (reader.pos < end) {
7628
+ let [fieldNo, wireType] = reader.tag();
7629
+ switch (fieldNo) {
7630
+ case 1:
7631
+ message.type = reader.int32();
7632
+ break;
7633
+ case 2:
7634
+ message.offset = reader.int64().toBigInt();
7635
+ break;
7636
+ case 3:
7637
+ message.length = reader.int64().toBigInt();
7638
+ break;
7639
+ case 4:
7640
+ message.entity = {
7641
+ oneofKind: "mention",
7642
+ mention: MessageEntity_MessageEntityMention.internalBinaryRead(reader, reader.uint32(), options, message.entity.mention)
7643
+ };
7644
+ break;
7645
+ case 5:
7646
+ message.entity = {
7647
+ oneofKind: "textUrl",
7648
+ textUrl: MessageEntity_MessageEntityTextUrl.internalBinaryRead(reader, reader.uint32(), options, message.entity.textUrl)
7649
+ };
7650
+ break;
7651
+ case 6:
7652
+ message.entity = {
7653
+ oneofKind: "pre",
7654
+ pre: MessageEntity_MessageEntityPre.internalBinaryRead(reader, reader.uint32(), options, message.entity.pre)
7655
+ };
7656
+ break;
7657
+ default:
7658
+ let u = options.readUnknownField;
7659
+ if (u === "throw")
7660
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7661
+ let d = reader.skip(wireType);
7662
+ if (u !== false)
7663
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7664
+ }
7665
+ }
7666
+ return message;
7667
+ }
7668
+ internalBinaryWrite(message, writer, options) {
7669
+ if (message.type !== 0)
7670
+ writer.tag(1, import_runtime.WireType.Varint).int32(message.type);
7671
+ if (message.offset !== 0n)
7672
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.offset);
7673
+ if (message.length !== 0n)
7674
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.length);
7675
+ if (message.entity.oneofKind === "mention")
7676
+ MessageEntity_MessageEntityMention.internalBinaryWrite(message.entity.mention, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
7677
+ if (message.entity.oneofKind === "textUrl")
7678
+ MessageEntity_MessageEntityTextUrl.internalBinaryWrite(message.entity.textUrl, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
7679
+ if (message.entity.oneofKind === "pre")
7680
+ MessageEntity_MessageEntityPre.internalBinaryWrite(message.entity.pre, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
7681
+ let u = options.writeUnknownFields;
7682
+ if (u !== false)
7683
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7684
+ return writer;
7685
+ }
7686
+ }
7687
+ var MessageEntity = new MessageEntity$Type;
7688
+
7689
+ class MessageEntity_MessageEntityMention$Type extends import_runtime4.MessageType {
7690
+ constructor() {
7691
+ super("MessageEntity.MessageEntityMention", [
7692
+ { no: 1, name: "user_id", kind: "scalar", T: 3, L: 0 }
7693
+ ]);
7694
+ }
7695
+ create(value) {
7696
+ const message = globalThis.Object.create(this.messagePrototype);
7697
+ message.userId = 0n;
7698
+ if (value !== undefined)
7699
+ import_runtime3.reflectionMergePartial(this, message, value);
7700
+ return message;
7701
+ }
7702
+ internalBinaryRead(reader, length, options, target) {
7703
+ let message = target ?? this.create(), end = reader.pos + length;
7704
+ while (reader.pos < end) {
7705
+ let [fieldNo, wireType] = reader.tag();
7706
+ switch (fieldNo) {
7707
+ case 1:
7708
+ message.userId = reader.int64().toBigInt();
7709
+ break;
7710
+ default:
7711
+ let u = options.readUnknownField;
7712
+ if (u === "throw")
7713
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7714
+ let d = reader.skip(wireType);
7715
+ if (u !== false)
7716
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7717
+ }
7718
+ }
7719
+ return message;
7720
+ }
7721
+ internalBinaryWrite(message, writer, options) {
7722
+ if (message.userId !== 0n)
7723
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.userId);
7724
+ let u = options.writeUnknownFields;
7725
+ if (u !== false)
7726
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7727
+ return writer;
7728
+ }
7729
+ }
7730
+ var MessageEntity_MessageEntityMention = new MessageEntity_MessageEntityMention$Type;
7731
+
7732
+ class MessageEntity_MessageEntityTextUrl$Type extends import_runtime4.MessageType {
7733
+ constructor() {
7734
+ super("MessageEntity.MessageEntityTextUrl", [
7735
+ { no: 1, name: "url", kind: "scalar", T: 9 }
7736
+ ]);
7737
+ }
7738
+ create(value) {
7739
+ const message = globalThis.Object.create(this.messagePrototype);
7740
+ message.url = "";
7741
+ if (value !== undefined)
7742
+ import_runtime3.reflectionMergePartial(this, message, value);
7743
+ return message;
7744
+ }
7745
+ internalBinaryRead(reader, length, options, target) {
7746
+ let message = target ?? this.create(), end = reader.pos + length;
7747
+ while (reader.pos < end) {
7748
+ let [fieldNo, wireType] = reader.tag();
7749
+ switch (fieldNo) {
7750
+ case 1:
7751
+ message.url = reader.string();
7752
+ break;
7753
+ default:
7754
+ let u = options.readUnknownField;
7755
+ if (u === "throw")
7756
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7757
+ let d = reader.skip(wireType);
7758
+ if (u !== false)
7759
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7760
+ }
7761
+ }
7762
+ return message;
7763
+ }
7764
+ internalBinaryWrite(message, writer, options) {
7765
+ if (message.url !== "")
7766
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
7767
+ let u = options.writeUnknownFields;
7768
+ if (u !== false)
7769
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7770
+ return writer;
7771
+ }
7772
+ }
7773
+ var MessageEntity_MessageEntityTextUrl = new MessageEntity_MessageEntityTextUrl$Type;
7774
+
7775
+ class MessageEntity_MessageEntityPre$Type extends import_runtime4.MessageType {
7776
+ constructor() {
7777
+ super("MessageEntity.MessageEntityPre", [
7778
+ { no: 1, name: "language", kind: "scalar", T: 9 }
7779
+ ]);
7780
+ }
7781
+ create(value) {
7782
+ const message = globalThis.Object.create(this.messagePrototype);
7783
+ message.language = "";
7784
+ if (value !== undefined)
7785
+ import_runtime3.reflectionMergePartial(this, message, value);
7786
+ return message;
7787
+ }
7788
+ internalBinaryRead(reader, length, options, target) {
7789
+ let message = target ?? this.create(), end = reader.pos + length;
7790
+ while (reader.pos < end) {
7791
+ let [fieldNo, wireType] = reader.tag();
7792
+ switch (fieldNo) {
7793
+ case 1:
7794
+ message.language = reader.string();
7795
+ break;
7796
+ default:
7797
+ let u = options.readUnknownField;
7798
+ if (u === "throw")
7799
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7800
+ let d = reader.skip(wireType);
7801
+ if (u !== false)
7802
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7803
+ }
7804
+ }
7805
+ return message;
7806
+ }
7807
+ internalBinaryWrite(message, writer, options) {
7808
+ if (message.language !== "")
7809
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.language);
7810
+ let u = options.writeUnknownFields;
7811
+ if (u !== false)
7812
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7813
+ return writer;
7814
+ }
7815
+ }
7816
+ var MessageEntity_MessageEntityPre = new MessageEntity_MessageEntityPre$Type;
7817
+
7818
+ class MessageReactions$Type extends import_runtime4.MessageType {
7819
+ constructor() {
7820
+ super("MessageReactions", [
7821
+ { no: 1, name: "reactions", kind: "message", repeat: 1, T: () => Reaction }
7494
7822
  ]);
7495
7823
  }
7496
7824
  create(value) {
@@ -9011,7 +9339,10 @@ class RpcCall$Type extends import_runtime4.MessageType {
9011
9339
  { no: 44, name: "getBotCommands", kind: "message", oneof: "input", T: () => GetBotCommandsInput },
9012
9340
  { no: 45, name: "setBotCommands", kind: "message", oneof: "input", T: () => SetBotCommandsInput },
9013
9341
  { no: 46, name: "getPeerBotCommands", kind: "message", oneof: "input", T: () => GetPeerBotCommandsInput },
9014
- { no: 47, name: "showChatInSidebar", kind: "message", oneof: "input", T: () => ShowChatInSidebarInput }
9342
+ { no: 47, name: "showChatInSidebar", kind: "message", oneof: "input", T: () => ShowChatInSidebarInput },
9343
+ { no: 48, name: "reserveChatIds", kind: "message", oneof: "input", T: () => ReserveChatIdsInput },
9344
+ { no: 49, name: "invokeMessageAction", kind: "message", oneof: "input", T: () => InvokeMessageActionInput },
9345
+ { no: 50, name: "answerMessageAction", kind: "message", oneof: "input", T: () => AnswerMessageActionInput }
9015
9346
  ]);
9016
9347
  }
9017
9348
  create(value) {
@@ -9306,6 +9637,24 @@ class RpcCall$Type extends import_runtime4.MessageType {
9306
9637
  showChatInSidebar: ShowChatInSidebarInput.internalBinaryRead(reader, reader.uint32(), options, message.input.showChatInSidebar)
9307
9638
  };
9308
9639
  break;
9640
+ case 48:
9641
+ message.input = {
9642
+ oneofKind: "reserveChatIds",
9643
+ reserveChatIds: ReserveChatIdsInput.internalBinaryRead(reader, reader.uint32(), options, message.input.reserveChatIds)
9644
+ };
9645
+ break;
9646
+ case 49:
9647
+ message.input = {
9648
+ oneofKind: "invokeMessageAction",
9649
+ invokeMessageAction: InvokeMessageActionInput.internalBinaryRead(reader, reader.uint32(), options, message.input.invokeMessageAction)
9650
+ };
9651
+ break;
9652
+ case 50:
9653
+ message.input = {
9654
+ oneofKind: "answerMessageAction",
9655
+ answerMessageAction: AnswerMessageActionInput.internalBinaryRead(reader, reader.uint32(), options, message.input.answerMessageAction)
9656
+ };
9657
+ break;
9309
9658
  default:
9310
9659
  let u = options.readUnknownField;
9311
9660
  if (u === "throw")
@@ -9412,6 +9761,12 @@ class RpcCall$Type extends import_runtime4.MessageType {
9412
9761
  GetPeerBotCommandsInput.internalBinaryWrite(message.input.getPeerBotCommands, writer.tag(46, import_runtime.WireType.LengthDelimited).fork(), options).join();
9413
9762
  if (message.input.oneofKind === "showChatInSidebar")
9414
9763
  ShowChatInSidebarInput.internalBinaryWrite(message.input.showChatInSidebar, writer.tag(47, import_runtime.WireType.LengthDelimited).fork(), options).join();
9764
+ if (message.input.oneofKind === "reserveChatIds")
9765
+ ReserveChatIdsInput.internalBinaryWrite(message.input.reserveChatIds, writer.tag(48, import_runtime.WireType.LengthDelimited).fork(), options).join();
9766
+ if (message.input.oneofKind === "invokeMessageAction")
9767
+ InvokeMessageActionInput.internalBinaryWrite(message.input.invokeMessageAction, writer.tag(49, import_runtime.WireType.LengthDelimited).fork(), options).join();
9768
+ if (message.input.oneofKind === "answerMessageAction")
9769
+ AnswerMessageActionInput.internalBinaryWrite(message.input.answerMessageAction, writer.tag(50, import_runtime.WireType.LengthDelimited).fork(), options).join();
9415
9770
  let u = options.writeUnknownFields;
9416
9771
  if (u !== false)
9417
9772
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -9469,7 +9824,10 @@ class RpcResult$Type extends import_runtime4.MessageType {
9469
9824
  { no: 44, name: "getBotCommands", kind: "message", oneof: "result", T: () => GetBotCommandsResult },
9470
9825
  { no: 45, name: "setBotCommands", kind: "message", oneof: "result", T: () => SetBotCommandsResult },
9471
9826
  { no: 46, name: "getPeerBotCommands", kind: "message", oneof: "result", T: () => GetPeerBotCommandsResult },
9472
- { no: 47, name: "showChatInSidebar", kind: "message", oneof: "result", T: () => ShowChatInSidebarResult }
9827
+ { no: 47, name: "showChatInSidebar", kind: "message", oneof: "result", T: () => ShowChatInSidebarResult },
9828
+ { no: 48, name: "reserveChatIds", kind: "message", oneof: "result", T: () => ReserveChatIdsResult },
9829
+ { no: 49, name: "invokeMessageAction", kind: "message", oneof: "result", T: () => InvokeMessageActionResult },
9830
+ { no: 50, name: "answerMessageAction", kind: "message", oneof: "result", T: () => AnswerMessageActionResult }
9473
9831
  ]);
9474
9832
  }
9475
9833
  create(value) {
@@ -9764,6 +10122,24 @@ class RpcResult$Type extends import_runtime4.MessageType {
9764
10122
  showChatInSidebar: ShowChatInSidebarResult.internalBinaryRead(reader, reader.uint32(), options, message.result.showChatInSidebar)
9765
10123
  };
9766
10124
  break;
10125
+ case 48:
10126
+ message.result = {
10127
+ oneofKind: "reserveChatIds",
10128
+ reserveChatIds: ReserveChatIdsResult.internalBinaryRead(reader, reader.uint32(), options, message.result.reserveChatIds)
10129
+ };
10130
+ break;
10131
+ case 49:
10132
+ message.result = {
10133
+ oneofKind: "invokeMessageAction",
10134
+ invokeMessageAction: InvokeMessageActionResult.internalBinaryRead(reader, reader.uint32(), options, message.result.invokeMessageAction)
10135
+ };
10136
+ break;
10137
+ case 50:
10138
+ message.result = {
10139
+ oneofKind: "answerMessageAction",
10140
+ answerMessageAction: AnswerMessageActionResult.internalBinaryRead(reader, reader.uint32(), options, message.result.answerMessageAction)
10141
+ };
10142
+ break;
9767
10143
  default:
9768
10144
  let u = options.readUnknownField;
9769
10145
  if (u === "throw")
@@ -9870,6 +10246,12 @@ class RpcResult$Type extends import_runtime4.MessageType {
9870
10246
  GetPeerBotCommandsResult.internalBinaryWrite(message.result.getPeerBotCommands, writer.tag(46, import_runtime.WireType.LengthDelimited).fork(), options).join();
9871
10247
  if (message.result.oneofKind === "showChatInSidebar")
9872
10248
  ShowChatInSidebarResult.internalBinaryWrite(message.result.showChatInSidebar, writer.tag(47, import_runtime.WireType.LengthDelimited).fork(), options).join();
10249
+ if (message.result.oneofKind === "reserveChatIds")
10250
+ ReserveChatIdsResult.internalBinaryWrite(message.result.reserveChatIds, writer.tag(48, import_runtime.WireType.LengthDelimited).fork(), options).join();
10251
+ if (message.result.oneofKind === "invokeMessageAction")
10252
+ InvokeMessageActionResult.internalBinaryWrite(message.result.invokeMessageAction, writer.tag(49, import_runtime.WireType.LengthDelimited).fork(), options).join();
10253
+ if (message.result.oneofKind === "answerMessageAction")
10254
+ AnswerMessageActionResult.internalBinaryWrite(message.result.answerMessageAction, writer.tag(50, import_runtime.WireType.LengthDelimited).fork(), options).join();
9873
10255
  let u = options.writeUnknownFields;
9874
10256
  if (u !== false)
9875
10257
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -12930,7 +13312,8 @@ class EditMessageInput$Type extends import_runtime4.MessageType {
12930
13312
  { no: 2, name: "peer_id", kind: "message", T: () => InputPeer },
12931
13313
  { no: 3, name: "text", kind: "scalar", T: 9 },
12932
13314
  { no: 7, name: "entities", kind: "message", T: () => MessageEntities },
12933
- { no: 8, name: "parse_markdown", kind: "scalar", opt: true, T: 8 }
13315
+ { no: 8, name: "parse_markdown", kind: "scalar", opt: true, T: 8 },
13316
+ { no: 9, name: "actions", kind: "message", T: () => MessageActions }
12934
13317
  ]);
12935
13318
  }
12936
13319
  create(value) {
@@ -12961,6 +13344,9 @@ class EditMessageInput$Type extends import_runtime4.MessageType {
12961
13344
  case 8:
12962
13345
  message.parseMarkdown = reader.bool();
12963
13346
  break;
13347
+ case 9:
13348
+ message.actions = MessageActions.internalBinaryRead(reader, reader.uint32(), options, message.actions);
13349
+ break;
12964
13350
  default:
12965
13351
  let u = options.readUnknownField;
12966
13352
  if (u === "throw")
@@ -12983,6 +13369,8 @@ class EditMessageInput$Type extends import_runtime4.MessageType {
12983
13369
  MessageEntities.internalBinaryWrite(message.entities, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
12984
13370
  if (message.parseMarkdown !== undefined)
12985
13371
  writer.tag(8, import_runtime.WireType.Varint).bool(message.parseMarkdown);
13372
+ if (message.actions)
13373
+ MessageActions.internalBinaryWrite(message.actions, writer.tag(9, import_runtime.WireType.LengthDelimited).fork(), options).join();
12986
13374
  let u = options.writeUnknownFields;
12987
13375
  if (u !== false)
12988
13376
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -13221,7 +13609,275 @@ class InputMediaDocument$Type extends import_runtime4.MessageType {
13221
13609
  let [fieldNo, wireType] = reader.tag();
13222
13610
  switch (fieldNo) {
13223
13611
  case 1:
13224
- message.documentId = reader.int64().toBigInt();
13612
+ message.documentId = reader.int64().toBigInt();
13613
+ break;
13614
+ default:
13615
+ let u = options.readUnknownField;
13616
+ if (u === "throw")
13617
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13618
+ let d = reader.skip(wireType);
13619
+ if (u !== false)
13620
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13621
+ }
13622
+ }
13623
+ return message;
13624
+ }
13625
+ internalBinaryWrite(message, writer, options) {
13626
+ if (message.documentId !== 0n)
13627
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.documentId);
13628
+ let u = options.writeUnknownFields;
13629
+ if (u !== false)
13630
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13631
+ return writer;
13632
+ }
13633
+ }
13634
+ var InputMediaDocument = new InputMediaDocument$Type;
13635
+
13636
+ class InputMediaVoice$Type extends import_runtime4.MessageType {
13637
+ constructor() {
13638
+ super("InputMediaVoice", [
13639
+ { no: 1, name: "voice_id", kind: "scalar", T: 3, L: 0 }
13640
+ ]);
13641
+ }
13642
+ create(value) {
13643
+ const message = globalThis.Object.create(this.messagePrototype);
13644
+ message.voiceId = 0n;
13645
+ if (value !== undefined)
13646
+ import_runtime3.reflectionMergePartial(this, message, value);
13647
+ return message;
13648
+ }
13649
+ internalBinaryRead(reader, length, options, target) {
13650
+ let message = target ?? this.create(), end = reader.pos + length;
13651
+ while (reader.pos < end) {
13652
+ let [fieldNo, wireType] = reader.tag();
13653
+ switch (fieldNo) {
13654
+ case 1:
13655
+ message.voiceId = reader.int64().toBigInt();
13656
+ break;
13657
+ default:
13658
+ let u = options.readUnknownField;
13659
+ if (u === "throw")
13660
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13661
+ let d = reader.skip(wireType);
13662
+ if (u !== false)
13663
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13664
+ }
13665
+ }
13666
+ return message;
13667
+ }
13668
+ internalBinaryWrite(message, writer, options) {
13669
+ if (message.voiceId !== 0n)
13670
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.voiceId);
13671
+ let u = options.writeUnknownFields;
13672
+ if (u !== false)
13673
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13674
+ return writer;
13675
+ }
13676
+ }
13677
+ var InputMediaVoice = new InputMediaVoice$Type;
13678
+
13679
+ class InputMediaNudge$Type extends import_runtime4.MessageType {
13680
+ constructor() {
13681
+ super("InputMediaNudge", []);
13682
+ }
13683
+ create(value) {
13684
+ const message = globalThis.Object.create(this.messagePrototype);
13685
+ if (value !== undefined)
13686
+ import_runtime3.reflectionMergePartial(this, message, value);
13687
+ return message;
13688
+ }
13689
+ internalBinaryRead(reader, length, options, target) {
13690
+ return target ?? this.create();
13691
+ }
13692
+ internalBinaryWrite(message, writer, options) {
13693
+ let u = options.writeUnknownFields;
13694
+ if (u !== false)
13695
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13696
+ return writer;
13697
+ }
13698
+ }
13699
+ var InputMediaNudge = new InputMediaNudge$Type;
13700
+
13701
+ class SendMessageInput$Type extends import_runtime4.MessageType {
13702
+ constructor() {
13703
+ super("SendMessageInput", [
13704
+ { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
13705
+ { no: 2, name: "message", kind: "scalar", opt: true, T: 9 },
13706
+ { no: 3, name: "reply_to_msg_id", kind: "scalar", opt: true, T: 3, L: 0 },
13707
+ { no: 4, name: "random_id", kind: "scalar", opt: true, T: 3, L: 0 },
13708
+ { no: 5, name: "media", kind: "message", T: () => InputMedia },
13709
+ { no: 1000, name: "temporary_send_date", kind: "scalar", opt: true, T: 3, L: 0 },
13710
+ { no: 6, name: "is_sticker", kind: "scalar", opt: true, T: 8 },
13711
+ { no: 6000, name: "has_link", kind: "scalar", opt: true, T: 8 },
13712
+ { no: 7, name: "entities", kind: "message", T: () => MessageEntities },
13713
+ { no: 8, name: "parse_markdown", kind: "scalar", opt: true, T: 8 },
13714
+ { no: 9, name: "send_mode", kind: "enum", opt: true, T: () => ["MessageSendMode", MessageSendMode] },
13715
+ { no: 10, name: "actions", kind: "message", T: () => MessageActions }
13716
+ ]);
13717
+ }
13718
+ create(value) {
13719
+ const message = globalThis.Object.create(this.messagePrototype);
13720
+ if (value !== undefined)
13721
+ import_runtime3.reflectionMergePartial(this, message, value);
13722
+ return message;
13723
+ }
13724
+ internalBinaryRead(reader, length, options, target) {
13725
+ let message = target ?? this.create(), end = reader.pos + length;
13726
+ while (reader.pos < end) {
13727
+ let [fieldNo, wireType] = reader.tag();
13728
+ switch (fieldNo) {
13729
+ case 1:
13730
+ message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
13731
+ break;
13732
+ case 2:
13733
+ message.message = reader.string();
13734
+ break;
13735
+ case 3:
13736
+ message.replyToMsgId = reader.int64().toBigInt();
13737
+ break;
13738
+ case 4:
13739
+ message.randomId = reader.int64().toBigInt();
13740
+ break;
13741
+ case 5:
13742
+ message.media = InputMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
13743
+ break;
13744
+ case 1000:
13745
+ message.temporarySendDate = reader.int64().toBigInt();
13746
+ break;
13747
+ case 6:
13748
+ message.isSticker = reader.bool();
13749
+ break;
13750
+ case 6000:
13751
+ message.hasLink = reader.bool();
13752
+ break;
13753
+ case 7:
13754
+ message.entities = MessageEntities.internalBinaryRead(reader, reader.uint32(), options, message.entities);
13755
+ break;
13756
+ case 8:
13757
+ message.parseMarkdown = reader.bool();
13758
+ break;
13759
+ case 9:
13760
+ message.sendMode = reader.int32();
13761
+ break;
13762
+ case 10:
13763
+ message.actions = MessageActions.internalBinaryRead(reader, reader.uint32(), options, message.actions);
13764
+ break;
13765
+ default:
13766
+ let u = options.readUnknownField;
13767
+ if (u === "throw")
13768
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13769
+ let d = reader.skip(wireType);
13770
+ if (u !== false)
13771
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13772
+ }
13773
+ }
13774
+ return message;
13775
+ }
13776
+ internalBinaryWrite(message, writer, options) {
13777
+ if (message.peerId)
13778
+ InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
13779
+ if (message.message !== undefined)
13780
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.message);
13781
+ if (message.replyToMsgId !== undefined)
13782
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.replyToMsgId);
13783
+ if (message.randomId !== undefined)
13784
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.randomId);
13785
+ if (message.media)
13786
+ InputMedia.internalBinaryWrite(message.media, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
13787
+ if (message.temporarySendDate !== undefined)
13788
+ writer.tag(1000, import_runtime.WireType.Varint).int64(message.temporarySendDate);
13789
+ if (message.isSticker !== undefined)
13790
+ writer.tag(6, import_runtime.WireType.Varint).bool(message.isSticker);
13791
+ if (message.hasLink !== undefined)
13792
+ writer.tag(6000, import_runtime.WireType.Varint).bool(message.hasLink);
13793
+ if (message.entities)
13794
+ MessageEntities.internalBinaryWrite(message.entities, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
13795
+ if (message.parseMarkdown !== undefined)
13796
+ writer.tag(8, import_runtime.WireType.Varint).bool(message.parseMarkdown);
13797
+ if (message.sendMode !== undefined)
13798
+ writer.tag(9, import_runtime.WireType.Varint).int32(message.sendMode);
13799
+ if (message.actions)
13800
+ MessageActions.internalBinaryWrite(message.actions, writer.tag(10, import_runtime.WireType.LengthDelimited).fork(), options).join();
13801
+ let u = options.writeUnknownFields;
13802
+ if (u !== false)
13803
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13804
+ return writer;
13805
+ }
13806
+ }
13807
+ var SendMessageInput = new SendMessageInput$Type;
13808
+
13809
+ class SendMessageResult$Type extends import_runtime4.MessageType {
13810
+ constructor() {
13811
+ super("SendMessageResult", [
13812
+ { no: 2, name: "updates", kind: "message", repeat: 1, T: () => Update }
13813
+ ]);
13814
+ }
13815
+ create(value) {
13816
+ const message = globalThis.Object.create(this.messagePrototype);
13817
+ message.updates = [];
13818
+ if (value !== undefined)
13819
+ import_runtime3.reflectionMergePartial(this, message, value);
13820
+ return message;
13821
+ }
13822
+ internalBinaryRead(reader, length, options, target) {
13823
+ let message = target ?? this.create(), end = reader.pos + length;
13824
+ while (reader.pos < end) {
13825
+ let [fieldNo, wireType] = reader.tag();
13826
+ switch (fieldNo) {
13827
+ case 2:
13828
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
13829
+ break;
13830
+ default:
13831
+ let u = options.readUnknownField;
13832
+ if (u === "throw")
13833
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13834
+ let d = reader.skip(wireType);
13835
+ if (u !== false)
13836
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13837
+ }
13838
+ }
13839
+ return message;
13840
+ }
13841
+ internalBinaryWrite(message, writer, options) {
13842
+ for (let i = 0;i < message.updates.length; i++)
13843
+ Update.internalBinaryWrite(message.updates[i], writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
13844
+ let u = options.writeUnknownFields;
13845
+ if (u !== false)
13846
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13847
+ return writer;
13848
+ }
13849
+ }
13850
+ var SendMessageResult = new SendMessageResult$Type;
13851
+
13852
+ class InvokeMessageActionInput$Type extends import_runtime4.MessageType {
13853
+ constructor() {
13854
+ super("InvokeMessageActionInput", [
13855
+ { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
13856
+ { no: 2, name: "message_id", kind: "scalar", T: 3, L: 0 },
13857
+ { no: 3, name: "action_id", kind: "scalar", T: 9 }
13858
+ ]);
13859
+ }
13860
+ create(value) {
13861
+ const message = globalThis.Object.create(this.messagePrototype);
13862
+ message.messageId = 0n;
13863
+ message.actionId = "";
13864
+ if (value !== undefined)
13865
+ import_runtime3.reflectionMergePartial(this, message, value);
13866
+ return message;
13867
+ }
13868
+ internalBinaryRead(reader, length, options, target) {
13869
+ let message = target ?? this.create(), end = reader.pos + length;
13870
+ while (reader.pos < end) {
13871
+ let [fieldNo, wireType] = reader.tag();
13872
+ switch (fieldNo) {
13873
+ case 1:
13874
+ message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
13875
+ break;
13876
+ case 2:
13877
+ message.messageId = reader.int64().toBigInt();
13878
+ break;
13879
+ case 3:
13880
+ message.actionId = reader.string();
13225
13881
  break;
13226
13882
  default:
13227
13883
  let u = options.readUnknownField;
@@ -13235,25 +13891,29 @@ class InputMediaDocument$Type extends import_runtime4.MessageType {
13235
13891
  return message;
13236
13892
  }
13237
13893
  internalBinaryWrite(message, writer, options) {
13238
- if (message.documentId !== 0n)
13239
- writer.tag(1, import_runtime.WireType.Varint).int64(message.documentId);
13894
+ if (message.peerId)
13895
+ InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
13896
+ if (message.messageId !== 0n)
13897
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.messageId);
13898
+ if (message.actionId !== "")
13899
+ writer.tag(3, import_runtime.WireType.LengthDelimited).string(message.actionId);
13240
13900
  let u = options.writeUnknownFields;
13241
13901
  if (u !== false)
13242
13902
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13243
13903
  return writer;
13244
13904
  }
13245
13905
  }
13246
- var InputMediaDocument = new InputMediaDocument$Type;
13906
+ var InvokeMessageActionInput = new InvokeMessageActionInput$Type;
13247
13907
 
13248
- class InputMediaVoice$Type extends import_runtime4.MessageType {
13908
+ class InvokeMessageActionResult$Type extends import_runtime4.MessageType {
13249
13909
  constructor() {
13250
- super("InputMediaVoice", [
13251
- { no: 1, name: "voice_id", kind: "scalar", T: 3, L: 0 }
13910
+ super("InvokeMessageActionResult", [
13911
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 }
13252
13912
  ]);
13253
13913
  }
13254
13914
  create(value) {
13255
13915
  const message = globalThis.Object.create(this.messagePrototype);
13256
- message.voiceId = 0n;
13916
+ message.interactionId = 0n;
13257
13917
  if (value !== undefined)
13258
13918
  import_runtime3.reflectionMergePartial(this, message, value);
13259
13919
  return message;
@@ -13264,7 +13924,7 @@ class InputMediaVoice$Type extends import_runtime4.MessageType {
13264
13924
  let [fieldNo, wireType] = reader.tag();
13265
13925
  switch (fieldNo) {
13266
13926
  case 1:
13267
- message.voiceId = reader.int64().toBigInt();
13927
+ message.interactionId = reader.int64().toBigInt();
13268
13928
  break;
13269
13929
  default:
13270
13930
  let u = options.readUnknownField;
@@ -13278,56 +13938,26 @@ class InputMediaVoice$Type extends import_runtime4.MessageType {
13278
13938
  return message;
13279
13939
  }
13280
13940
  internalBinaryWrite(message, writer, options) {
13281
- if (message.voiceId !== 0n)
13282
- writer.tag(1, import_runtime.WireType.Varint).int64(message.voiceId);
13283
- let u = options.writeUnknownFields;
13284
- if (u !== false)
13285
- (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13286
- return writer;
13287
- }
13288
- }
13289
- var InputMediaVoice = new InputMediaVoice$Type;
13290
-
13291
- class InputMediaNudge$Type extends import_runtime4.MessageType {
13292
- constructor() {
13293
- super("InputMediaNudge", []);
13294
- }
13295
- create(value) {
13296
- const message = globalThis.Object.create(this.messagePrototype);
13297
- if (value !== undefined)
13298
- import_runtime3.reflectionMergePartial(this, message, value);
13299
- return message;
13300
- }
13301
- internalBinaryRead(reader, length, options, target) {
13302
- return target ?? this.create();
13303
- }
13304
- internalBinaryWrite(message, writer, options) {
13941
+ if (message.interactionId !== 0n)
13942
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
13305
13943
  let u = options.writeUnknownFields;
13306
13944
  if (u !== false)
13307
13945
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13308
13946
  return writer;
13309
13947
  }
13310
13948
  }
13311
- var InputMediaNudge = new InputMediaNudge$Type;
13949
+ var InvokeMessageActionResult = new InvokeMessageActionResult$Type;
13312
13950
 
13313
- class SendMessageInput$Type extends import_runtime4.MessageType {
13951
+ class AnswerMessageActionInput$Type extends import_runtime4.MessageType {
13314
13952
  constructor() {
13315
- super("SendMessageInput", [
13316
- { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
13317
- { no: 2, name: "message", kind: "scalar", opt: true, T: 9 },
13318
- { no: 3, name: "reply_to_msg_id", kind: "scalar", opt: true, T: 3, L: 0 },
13319
- { no: 4, name: "random_id", kind: "scalar", opt: true, T: 3, L: 0 },
13320
- { no: 5, name: "media", kind: "message", T: () => InputMedia },
13321
- { no: 1000, name: "temporary_send_date", kind: "scalar", opt: true, T: 3, L: 0 },
13322
- { no: 6, name: "is_sticker", kind: "scalar", opt: true, T: 8 },
13323
- { no: 6000, name: "has_link", kind: "scalar", opt: true, T: 8 },
13324
- { no: 7, name: "entities", kind: "message", T: () => MessageEntities },
13325
- { no: 8, name: "parse_markdown", kind: "scalar", opt: true, T: 8 },
13326
- { no: 9, name: "send_mode", kind: "enum", opt: true, T: () => ["MessageSendMode", MessageSendMode] }
13953
+ super("AnswerMessageActionInput", [
13954
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 },
13955
+ { no: 2, name: "ui", kind: "message", T: () => MessageActionResponseUi }
13327
13956
  ]);
13328
13957
  }
13329
13958
  create(value) {
13330
13959
  const message = globalThis.Object.create(this.messagePrototype);
13960
+ message.interactionId = 0n;
13331
13961
  if (value !== undefined)
13332
13962
  import_runtime3.reflectionMergePartial(this, message, value);
13333
13963
  return message;
@@ -13338,37 +13968,10 @@ class SendMessageInput$Type extends import_runtime4.MessageType {
13338
13968
  let [fieldNo, wireType] = reader.tag();
13339
13969
  switch (fieldNo) {
13340
13970
  case 1:
13341
- message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
13971
+ message.interactionId = reader.int64().toBigInt();
13342
13972
  break;
13343
13973
  case 2:
13344
- message.message = reader.string();
13345
- break;
13346
- case 3:
13347
- message.replyToMsgId = reader.int64().toBigInt();
13348
- break;
13349
- case 4:
13350
- message.randomId = reader.int64().toBigInt();
13351
- break;
13352
- case 5:
13353
- message.media = InputMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
13354
- break;
13355
- case 1000:
13356
- message.temporarySendDate = reader.int64().toBigInt();
13357
- break;
13358
- case 6:
13359
- message.isSticker = reader.bool();
13360
- break;
13361
- case 6000:
13362
- message.hasLink = reader.bool();
13363
- break;
13364
- case 7:
13365
- message.entities = MessageEntities.internalBinaryRead(reader, reader.uint32(), options, message.entities);
13366
- break;
13367
- case 8:
13368
- message.parseMarkdown = reader.bool();
13369
- break;
13370
- case 9:
13371
- message.sendMode = reader.int32();
13974
+ message.ui = MessageActionResponseUi.internalBinaryRead(reader, reader.uint32(), options, message.ui);
13372
13975
  break;
13373
13976
  default:
13374
13977
  let u = options.readUnknownField;
@@ -13382,78 +13985,39 @@ class SendMessageInput$Type extends import_runtime4.MessageType {
13382
13985
  return message;
13383
13986
  }
13384
13987
  internalBinaryWrite(message, writer, options) {
13385
- if (message.peerId)
13386
- InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
13387
- if (message.message !== undefined)
13388
- writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.message);
13389
- if (message.replyToMsgId !== undefined)
13390
- writer.tag(3, import_runtime.WireType.Varint).int64(message.replyToMsgId);
13391
- if (message.randomId !== undefined)
13392
- writer.tag(4, import_runtime.WireType.Varint).int64(message.randomId);
13393
- if (message.media)
13394
- InputMedia.internalBinaryWrite(message.media, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
13395
- if (message.temporarySendDate !== undefined)
13396
- writer.tag(1000, import_runtime.WireType.Varint).int64(message.temporarySendDate);
13397
- if (message.isSticker !== undefined)
13398
- writer.tag(6, import_runtime.WireType.Varint).bool(message.isSticker);
13399
- if (message.hasLink !== undefined)
13400
- writer.tag(6000, import_runtime.WireType.Varint).bool(message.hasLink);
13401
- if (message.entities)
13402
- MessageEntities.internalBinaryWrite(message.entities, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
13403
- if (message.parseMarkdown !== undefined)
13404
- writer.tag(8, import_runtime.WireType.Varint).bool(message.parseMarkdown);
13405
- if (message.sendMode !== undefined)
13406
- writer.tag(9, import_runtime.WireType.Varint).int32(message.sendMode);
13988
+ if (message.interactionId !== 0n)
13989
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
13990
+ if (message.ui)
13991
+ MessageActionResponseUi.internalBinaryWrite(message.ui, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
13407
13992
  let u = options.writeUnknownFields;
13408
13993
  if (u !== false)
13409
13994
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13410
13995
  return writer;
13411
13996
  }
13412
13997
  }
13413
- var SendMessageInput = new SendMessageInput$Type;
13998
+ var AnswerMessageActionInput = new AnswerMessageActionInput$Type;
13414
13999
 
13415
- class SendMessageResult$Type extends import_runtime4.MessageType {
14000
+ class AnswerMessageActionResult$Type extends import_runtime4.MessageType {
13416
14001
  constructor() {
13417
- super("SendMessageResult", [
13418
- { no: 2, name: "updates", kind: "message", repeat: 1, T: () => Update }
13419
- ]);
14002
+ super("AnswerMessageActionResult", []);
13420
14003
  }
13421
14004
  create(value) {
13422
14005
  const message = globalThis.Object.create(this.messagePrototype);
13423
- message.updates = [];
13424
14006
  if (value !== undefined)
13425
14007
  import_runtime3.reflectionMergePartial(this, message, value);
13426
14008
  return message;
13427
14009
  }
13428
14010
  internalBinaryRead(reader, length, options, target) {
13429
- let message = target ?? this.create(), end = reader.pos + length;
13430
- while (reader.pos < end) {
13431
- let [fieldNo, wireType] = reader.tag();
13432
- switch (fieldNo) {
13433
- case 2:
13434
- message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
13435
- break;
13436
- default:
13437
- let u = options.readUnknownField;
13438
- if (u === "throw")
13439
- throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13440
- let d = reader.skip(wireType);
13441
- if (u !== false)
13442
- (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13443
- }
13444
- }
13445
- return message;
14011
+ return target ?? this.create();
13446
14012
  }
13447
14013
  internalBinaryWrite(message, writer, options) {
13448
- for (let i = 0;i < message.updates.length; i++)
13449
- Update.internalBinaryWrite(message.updates[i], writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
13450
14014
  let u = options.writeUnknownFields;
13451
14015
  if (u !== false)
13452
14016
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13453
14017
  return writer;
13454
14018
  }
13455
14019
  }
13456
- var SendMessageResult = new SendMessageResult$Type;
14020
+ var AnswerMessageActionResult = new AnswerMessageActionResult$Type;
13457
14021
 
13458
14022
  class ForwardMessagesInput$Type extends import_runtime4.MessageType {
13459
14023
  constructor() {
@@ -13906,25 +14470,161 @@ class SearchMessagesResult$Type extends import_runtime4.MessageType {
13906
14470
  return message;
13907
14471
  }
13908
14472
  internalBinaryWrite(message, writer, options) {
13909
- for (let i = 0;i < message.messages.length; i++)
13910
- Message.internalBinaryWrite(message.messages[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14473
+ for (let i = 0;i < message.messages.length; i++)
14474
+ Message.internalBinaryWrite(message.messages[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14475
+ let u = options.writeUnknownFields;
14476
+ if (u !== false)
14477
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14478
+ return writer;
14479
+ }
14480
+ }
14481
+ var SearchMessagesResult = new SearchMessagesResult$Type;
14482
+
14483
+ class InputChatParticipant$Type extends import_runtime4.MessageType {
14484
+ constructor() {
14485
+ super("InputChatParticipant", [
14486
+ { no: 1, name: "user_id", kind: "scalar", T: 3, L: 0 }
14487
+ ]);
14488
+ }
14489
+ create(value) {
14490
+ const message = globalThis.Object.create(this.messagePrototype);
14491
+ message.userId = 0n;
14492
+ if (value !== undefined)
14493
+ import_runtime3.reflectionMergePartial(this, message, value);
14494
+ return message;
14495
+ }
14496
+ internalBinaryRead(reader, length, options, target) {
14497
+ let message = target ?? this.create(), end = reader.pos + length;
14498
+ while (reader.pos < end) {
14499
+ let [fieldNo, wireType] = reader.tag();
14500
+ switch (fieldNo) {
14501
+ case 1:
14502
+ message.userId = reader.int64().toBigInt();
14503
+ break;
14504
+ default:
14505
+ let u = options.readUnknownField;
14506
+ if (u === "throw")
14507
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14508
+ let d = reader.skip(wireType);
14509
+ if (u !== false)
14510
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14511
+ }
14512
+ }
14513
+ return message;
14514
+ }
14515
+ internalBinaryWrite(message, writer, options) {
14516
+ if (message.userId !== 0n)
14517
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.userId);
14518
+ let u = options.writeUnknownFields;
14519
+ if (u !== false)
14520
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14521
+ return writer;
14522
+ }
14523
+ }
14524
+ var InputChatParticipant = new InputChatParticipant$Type;
14525
+
14526
+ class ReserveChatIdsInput$Type extends import_runtime4.MessageType {
14527
+ constructor() {
14528
+ super("ReserveChatIdsInput", [
14529
+ { no: 1, name: "count", kind: "scalar", T: 5 }
14530
+ ]);
14531
+ }
14532
+ create(value) {
14533
+ const message = globalThis.Object.create(this.messagePrototype);
14534
+ message.count = 0;
14535
+ if (value !== undefined)
14536
+ import_runtime3.reflectionMergePartial(this, message, value);
14537
+ return message;
14538
+ }
14539
+ internalBinaryRead(reader, length, options, target) {
14540
+ let message = target ?? this.create(), end = reader.pos + length;
14541
+ while (reader.pos < end) {
14542
+ let [fieldNo, wireType] = reader.tag();
14543
+ switch (fieldNo) {
14544
+ case 1:
14545
+ message.count = reader.int32();
14546
+ break;
14547
+ default:
14548
+ let u = options.readUnknownField;
14549
+ if (u === "throw")
14550
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14551
+ let d = reader.skip(wireType);
14552
+ if (u !== false)
14553
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14554
+ }
14555
+ }
14556
+ return message;
14557
+ }
14558
+ internalBinaryWrite(message, writer, options) {
14559
+ if (message.count !== 0)
14560
+ writer.tag(1, import_runtime.WireType.Varint).int32(message.count);
14561
+ let u = options.writeUnknownFields;
14562
+ if (u !== false)
14563
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14564
+ return writer;
14565
+ }
14566
+ }
14567
+ var ReserveChatIdsInput = new ReserveChatIdsInput$Type;
14568
+
14569
+ class ReservedChatId$Type extends import_runtime4.MessageType {
14570
+ constructor() {
14571
+ super("ReservedChatId", [
14572
+ { no: 1, name: "chat_id", kind: "scalar", T: 3, L: 0 },
14573
+ { no: 2, name: "expires_at", kind: "scalar", T: 3, L: 0 }
14574
+ ]);
14575
+ }
14576
+ create(value) {
14577
+ const message = globalThis.Object.create(this.messagePrototype);
14578
+ message.chatId = 0n;
14579
+ message.expiresAt = 0n;
14580
+ if (value !== undefined)
14581
+ import_runtime3.reflectionMergePartial(this, message, value);
14582
+ return message;
14583
+ }
14584
+ internalBinaryRead(reader, length, options, target) {
14585
+ let message = target ?? this.create(), end = reader.pos + length;
14586
+ while (reader.pos < end) {
14587
+ let [fieldNo, wireType] = reader.tag();
14588
+ switch (fieldNo) {
14589
+ case 1:
14590
+ message.chatId = reader.int64().toBigInt();
14591
+ break;
14592
+ case 2:
14593
+ message.expiresAt = reader.int64().toBigInt();
14594
+ break;
14595
+ default:
14596
+ let u = options.readUnknownField;
14597
+ if (u === "throw")
14598
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14599
+ let d = reader.skip(wireType);
14600
+ if (u !== false)
14601
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14602
+ }
14603
+ }
14604
+ return message;
14605
+ }
14606
+ internalBinaryWrite(message, writer, options) {
14607
+ if (message.chatId !== 0n)
14608
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.chatId);
14609
+ if (message.expiresAt !== 0n)
14610
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.expiresAt);
13911
14611
  let u = options.writeUnknownFields;
13912
14612
  if (u !== false)
13913
14613
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13914
14614
  return writer;
13915
14615
  }
13916
14616
  }
13917
- var SearchMessagesResult = new SearchMessagesResult$Type;
14617
+ var ReservedChatId = new ReservedChatId$Type;
13918
14618
 
13919
- class InputChatParticipant$Type extends import_runtime4.MessageType {
14619
+ class ReserveChatIdsResult$Type extends import_runtime4.MessageType {
13920
14620
  constructor() {
13921
- super("InputChatParticipant", [
13922
- { no: 1, name: "user_id", kind: "scalar", T: 3, L: 0 }
14621
+ super("ReserveChatIdsResult", [
14622
+ { no: 1, name: "reservations", kind: "message", repeat: 1, T: () => ReservedChatId }
13923
14623
  ]);
13924
14624
  }
13925
14625
  create(value) {
13926
14626
  const message = globalThis.Object.create(this.messagePrototype);
13927
- message.userId = 0n;
14627
+ message.reservations = [];
13928
14628
  if (value !== undefined)
13929
14629
  import_runtime3.reflectionMergePartial(this, message, value);
13930
14630
  return message;
@@ -13935,7 +14635,7 @@ class InputChatParticipant$Type extends import_runtime4.MessageType {
13935
14635
  let [fieldNo, wireType] = reader.tag();
13936
14636
  switch (fieldNo) {
13937
14637
  case 1:
13938
- message.userId = reader.int64().toBigInt();
14638
+ message.reservations.push(ReservedChatId.internalBinaryRead(reader, reader.uint32(), options));
13939
14639
  break;
13940
14640
  default:
13941
14641
  let u = options.readUnknownField;
@@ -13949,15 +14649,15 @@ class InputChatParticipant$Type extends import_runtime4.MessageType {
13949
14649
  return message;
13950
14650
  }
13951
14651
  internalBinaryWrite(message, writer, options) {
13952
- if (message.userId !== 0n)
13953
- writer.tag(1, import_runtime.WireType.Varint).int64(message.userId);
14652
+ for (let i = 0;i < message.reservations.length; i++)
14653
+ ReservedChatId.internalBinaryWrite(message.reservations[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
13954
14654
  let u = options.writeUnknownFields;
13955
14655
  if (u !== false)
13956
14656
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13957
14657
  return writer;
13958
14658
  }
13959
14659
  }
13960
- var InputChatParticipant = new InputChatParticipant$Type;
14660
+ var ReserveChatIdsResult = new ReserveChatIdsResult$Type;
13961
14661
 
13962
14662
  class CreateChatInput$Type extends import_runtime4.MessageType {
13963
14663
  constructor() {
@@ -13967,7 +14667,8 @@ class CreateChatInput$Type extends import_runtime4.MessageType {
13967
14667
  { no: 3, name: "description", kind: "scalar", opt: true, T: 9 },
13968
14668
  { no: 4, name: "emoji", kind: "scalar", opt: true, T: 9 },
13969
14669
  { no: 5, name: "is_public", kind: "scalar", T: 8 },
13970
- { no: 6, name: "participants", kind: "message", repeat: 1, T: () => InputChatParticipant }
14670
+ { no: 6, name: "participants", kind: "message", repeat: 1, T: () => InputChatParticipant },
14671
+ { no: 7, name: "reserved_chat_id", kind: "scalar", opt: true, T: 3, L: 0 }
13971
14672
  ]);
13972
14673
  }
13973
14674
  create(value) {
@@ -14002,6 +14703,9 @@ class CreateChatInput$Type extends import_runtime4.MessageType {
14002
14703
  case 6:
14003
14704
  message.participants.push(InputChatParticipant.internalBinaryRead(reader, reader.uint32(), options));
14004
14705
  break;
14706
+ case 7:
14707
+ message.reservedChatId = reader.int64().toBigInt();
14708
+ break;
14005
14709
  default:
14006
14710
  let u = options.readUnknownField;
14007
14711
  if (u === "throw")
@@ -14026,6 +14730,8 @@ class CreateChatInput$Type extends import_runtime4.MessageType {
14026
14730
  writer.tag(5, import_runtime.WireType.Varint).bool(message.isPublic);
14027
14731
  for (let i = 0;i < message.participants.length; i++)
14028
14732
  InputChatParticipant.internalBinaryWrite(message.participants[i], writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
14733
+ if (message.reservedChatId !== undefined)
14734
+ writer.tag(7, import_runtime.WireType.Varint).int64(message.reservedChatId);
14029
14735
  let u = options.writeUnknownFields;
14030
14736
  if (u !== false)
14031
14737
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -14338,7 +15044,9 @@ class Update$Type extends import_runtime4.MessageType {
14338
15044
  { no: 31, name: "pinned_messages", kind: "message", oneof: "update", T: () => UpdatePinnedMessages },
14339
15045
  { no: 32, name: "chat_moved", kind: "message", oneof: "update", T: () => UpdateChatMoved },
14340
15046
  { no: 33, name: "dialog_notification_settings", kind: "message", oneof: "update", T: () => UpdateDialogNotificationSettings },
14341
- { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen }
15047
+ { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen },
15048
+ { no: 35, name: "message_action_invoked", kind: "message", oneof: "update", T: () => UpdateMessageActionInvoked },
15049
+ { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered }
14342
15050
  ]);
14343
15051
  }
14344
15052
  create(value) {
@@ -14545,6 +15253,18 @@ class Update$Type extends import_runtime4.MessageType {
14545
15253
  chatOpen: UpdateChatOpen.internalBinaryRead(reader, reader.uint32(), options, message.update.chatOpen)
14546
15254
  };
14547
15255
  break;
15256
+ case 35:
15257
+ message.update = {
15258
+ oneofKind: "messageActionInvoked",
15259
+ messageActionInvoked: UpdateMessageActionInvoked.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionInvoked)
15260
+ };
15261
+ break;
15262
+ case 36:
15263
+ message.update = {
15264
+ oneofKind: "messageActionAnswered",
15265
+ messageActionAnswered: UpdateMessageActionAnswered.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionAnswered)
15266
+ };
15267
+ break;
14548
15268
  default:
14549
15269
  let u = options.readUnknownField;
14550
15270
  if (u === "throw")
@@ -14623,6 +15343,10 @@ class Update$Type extends import_runtime4.MessageType {
14623
15343
  UpdateDialogNotificationSettings.internalBinaryWrite(message.update.dialogNotificationSettings, writer.tag(33, import_runtime.WireType.LengthDelimited).fork(), options).join();
14624
15344
  if (message.update.oneofKind === "chatOpen")
14625
15345
  UpdateChatOpen.internalBinaryWrite(message.update.chatOpen, writer.tag(34, import_runtime.WireType.LengthDelimited).fork(), options).join();
15346
+ if (message.update.oneofKind === "messageActionInvoked")
15347
+ UpdateMessageActionInvoked.internalBinaryWrite(message.update.messageActionInvoked, writer.tag(35, import_runtime.WireType.LengthDelimited).fork(), options).join();
15348
+ if (message.update.oneofKind === "messageActionAnswered")
15349
+ UpdateMessageActionAnswered.internalBinaryWrite(message.update.messageActionAnswered, writer.tag(36, import_runtime.WireType.LengthDelimited).fork(), options).join();
14626
15350
  let u = options.writeUnknownFields;
14627
15351
  if (u !== false)
14628
15352
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -15579,6 +16303,133 @@ class UpdateChatOpen$Type extends import_runtime4.MessageType {
15579
16303
  }
15580
16304
  var UpdateChatOpen = new UpdateChatOpen$Type;
15581
16305
 
16306
+ class UpdateMessageActionInvoked$Type extends import_runtime4.MessageType {
16307
+ constructor() {
16308
+ super("UpdateMessageActionInvoked", [
16309
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 },
16310
+ { no: 2, name: "chat_id", kind: "scalar", T: 3, L: 0 },
16311
+ { no: 3, name: "message_id", kind: "scalar", T: 3, L: 0 },
16312
+ { no: 4, name: "actor_user_id", kind: "scalar", T: 3, L: 0 },
16313
+ { no: 5, name: "action_id", kind: "scalar", T: 9 },
16314
+ { no: 6, name: "data", kind: "scalar", T: 12 }
16315
+ ]);
16316
+ }
16317
+ create(value) {
16318
+ const message = globalThis.Object.create(this.messagePrototype);
16319
+ message.interactionId = 0n;
16320
+ message.chatId = 0n;
16321
+ message.messageId = 0n;
16322
+ message.actorUserId = 0n;
16323
+ message.actionId = "";
16324
+ message.data = new Uint8Array(0);
16325
+ if (value !== undefined)
16326
+ import_runtime3.reflectionMergePartial(this, message, value);
16327
+ return message;
16328
+ }
16329
+ internalBinaryRead(reader, length, options, target) {
16330
+ let message = target ?? this.create(), end = reader.pos + length;
16331
+ while (reader.pos < end) {
16332
+ let [fieldNo, wireType] = reader.tag();
16333
+ switch (fieldNo) {
16334
+ case 1:
16335
+ message.interactionId = reader.int64().toBigInt();
16336
+ break;
16337
+ case 2:
16338
+ message.chatId = reader.int64().toBigInt();
16339
+ break;
16340
+ case 3:
16341
+ message.messageId = reader.int64().toBigInt();
16342
+ break;
16343
+ case 4:
16344
+ message.actorUserId = reader.int64().toBigInt();
16345
+ break;
16346
+ case 5:
16347
+ message.actionId = reader.string();
16348
+ break;
16349
+ case 6:
16350
+ message.data = reader.bytes();
16351
+ break;
16352
+ default:
16353
+ let u = options.readUnknownField;
16354
+ if (u === "throw")
16355
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
16356
+ let d = reader.skip(wireType);
16357
+ if (u !== false)
16358
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
16359
+ }
16360
+ }
16361
+ return message;
16362
+ }
16363
+ internalBinaryWrite(message, writer, options) {
16364
+ if (message.interactionId !== 0n)
16365
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
16366
+ if (message.chatId !== 0n)
16367
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.chatId);
16368
+ if (message.messageId !== 0n)
16369
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.messageId);
16370
+ if (message.actorUserId !== 0n)
16371
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.actorUserId);
16372
+ if (message.actionId !== "")
16373
+ writer.tag(5, import_runtime.WireType.LengthDelimited).string(message.actionId);
16374
+ if (message.data.length)
16375
+ writer.tag(6, import_runtime.WireType.LengthDelimited).bytes(message.data);
16376
+ let u = options.writeUnknownFields;
16377
+ if (u !== false)
16378
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
16379
+ return writer;
16380
+ }
16381
+ }
16382
+ var UpdateMessageActionInvoked = new UpdateMessageActionInvoked$Type;
16383
+
16384
+ class UpdateMessageActionAnswered$Type extends import_runtime4.MessageType {
16385
+ constructor() {
16386
+ super("UpdateMessageActionAnswered", [
16387
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 },
16388
+ { no: 2, name: "ui", kind: "message", T: () => MessageActionResponseUi }
16389
+ ]);
16390
+ }
16391
+ create(value) {
16392
+ const message = globalThis.Object.create(this.messagePrototype);
16393
+ message.interactionId = 0n;
16394
+ if (value !== undefined)
16395
+ import_runtime3.reflectionMergePartial(this, message, value);
16396
+ return message;
16397
+ }
16398
+ internalBinaryRead(reader, length, options, target) {
16399
+ let message = target ?? this.create(), end = reader.pos + length;
16400
+ while (reader.pos < end) {
16401
+ let [fieldNo, wireType] = reader.tag();
16402
+ switch (fieldNo) {
16403
+ case 1:
16404
+ message.interactionId = reader.int64().toBigInt();
16405
+ break;
16406
+ case 2:
16407
+ message.ui = MessageActionResponseUi.internalBinaryRead(reader, reader.uint32(), options, message.ui);
16408
+ break;
16409
+ default:
16410
+ let u = options.readUnknownField;
16411
+ if (u === "throw")
16412
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
16413
+ let d = reader.skip(wireType);
16414
+ if (u !== false)
16415
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
16416
+ }
16417
+ }
16418
+ return message;
16419
+ }
16420
+ internalBinaryWrite(message, writer, options) {
16421
+ if (message.interactionId !== 0n)
16422
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
16423
+ if (message.ui)
16424
+ MessageActionResponseUi.internalBinaryWrite(message.ui, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
16425
+ let u = options.writeUnknownFields;
16426
+ if (u !== false)
16427
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
16428
+ return writer;
16429
+ }
16430
+ }
16431
+ var UpdateMessageActionAnswered = new UpdateMessageActionAnswered$Type;
16432
+
15582
16433
  class UpdateDeleteChat$Type extends import_runtime4.MessageType {
15583
16434
  constructor() {
15584
16435
  super("UpdateDeleteChat", [
@@ -18052,7 +18903,9 @@ var rpcInputKindByMethod = {
18052
18903
  35: "moveThread",
18053
18904
  36: "rotateBotToken",
18054
18905
  37: "updateBotProfile",
18055
- 38: "getMessages"
18906
+ 38: "getMessages",
18907
+ 48: "invokeMessageAction",
18908
+ 49: "answerMessageAction"
18056
18909
  };
18057
18910
  var rpcResultKindByMethod = {
18058
18911
  0: undefined,
@@ -18093,7 +18946,9 @@ var rpcResultKindByMethod = {
18093
18946
  35: "moveThread",
18094
18947
  36: "rotateBotToken",
18095
18948
  37: "updateBotProfile",
18096
- 38: "getMessages"
18949
+ 38: "getMessages",
18950
+ 48: "invokeMessageAction",
18951
+ 49: "answerMessageAction"
18097
18952
  };
18098
18953
 
18099
18954
  // ../sdk/dist/sdk/logger.js
@@ -18103,19 +18958,23 @@ var noopLogger = {};
18103
18958
  import { readFileSync } from "node:fs";
18104
18959
  var cached = null;
18105
18960
  var getSdkVersion = () => {
18106
- if (cached)
18961
+ if (cached !== null)
18107
18962
  return cached;
18108
18963
  try {
18109
18964
  const pkgUrl = new URL("../../package.json", import.meta.url);
18110
18965
  const raw = readFileSync(pkgUrl, "utf8");
18111
18966
  const parsed = JSON.parse(raw);
18112
18967
  if (typeof parsed === "object" && parsed !== null && "version" in parsed && typeof parsed.version === "string") {
18113
- const version = parsed.version;
18968
+ const version = parsed.version.trim();
18969
+ if (!version) {
18970
+ cached = undefined;
18971
+ return cached;
18972
+ }
18114
18973
  cached = version;
18115
18974
  return version;
18116
18975
  }
18117
18976
  } catch {}
18118
- cached = "unknown";
18977
+ cached = undefined;
18119
18978
  return cached;
18120
18979
  };
18121
18980
 
@@ -18126,6 +18985,8 @@ var defaultApiBaseUrl = "https://api.inline.chat";
18126
18985
  var defaultVideoWidth = 1280;
18127
18986
  var defaultVideoHeight = 720;
18128
18987
  var defaultVideoDuration = 1;
18988
+ var defaultCatchUpTotalLimit = 1000;
18989
+ var defaultColdStartCatchUpWindow = defaultCatchUpTotalLimit;
18129
18990
  function extractFirstMessageId(updates) {
18130
18991
  for (const update of updates ?? []) {
18131
18992
  if (update.update.oneofKind === "newMessage") {
@@ -18153,6 +19014,7 @@ class InlineSdkClient {
18153
19014
  saveTimer = null;
18154
19015
  saveInFlight = null;
18155
19016
  catchUpInFlightByChatId = new Map;
19017
+ catchUpRequestedByChatId = new Map;
18156
19018
  constructor(options) {
18157
19019
  this.options = options;
18158
19020
  this.log = options.logger ?? noopLogger;
@@ -18160,12 +19022,13 @@ class InlineSdkClient {
18160
19022
  this.fetchImpl = options.fetch ?? fetch;
18161
19023
  const url = resolveRealtimeUrl(this.httpBaseUrl);
18162
19024
  this.transport = options.transport ?? new WebSocketTransport({ url, logger: options.logger });
19025
+ const sdkVersion = getSdkVersion();
18163
19026
  this.protocol = new ProtocolClient({
18164
19027
  transport: this.transport,
18165
19028
  getConnectionInit: () => ({
18166
19029
  token: options.token,
18167
19030
  layer: sdkLayer,
18168
- clientVersion: getSdkVersion()
19031
+ ...sdkVersion ? { clientVersion: sdkVersion } : {}
18169
19032
  }),
18170
19033
  logger: options.logger,
18171
19034
  defaultRpcTimeoutMs: options.rpcTimeoutMs
@@ -18292,6 +19155,7 @@ class InlineSdkClient {
18292
19155
  ...params.replyToMsgId != null ? { replyToMsgId: asInlineId(params.replyToMsgId, "replyToMsgId") } : {},
18293
19156
  ...params.parseMarkdown != null ? { parseMarkdown: params.parseMarkdown } : {},
18294
19157
  ...params.entities != null ? { entities: params.entities } : {},
19158
+ ...params.actions != null ? { actions: params.actions } : {},
18295
19159
  ...params.sendMode === "silent" ? { sendMode: MessageSendMode.MODE_SILENT } : {}
18296
19160
  }
18297
19161
  });
@@ -18399,6 +19263,33 @@ class InlineSdkClient {
18399
19263
  }
18400
19264
  });
18401
19265
  }
19266
+ async invokeMessageAction(params) {
19267
+ const peerId = this.inputPeerFromTarget(params, "invokeMessageAction");
19268
+ const actionId = params.actionId.trim();
19269
+ if (!actionId) {
19270
+ throw new Error("invokeMessageAction: `actionId` must be non-empty");
19271
+ }
19272
+ const result = await this.invoke(Method.INVOKE_MESSAGE_ACTION, {
19273
+ oneofKind: "invokeMessageAction",
19274
+ invokeMessageAction: {
19275
+ peerId,
19276
+ messageId: asInlineId(params.messageId, "messageId"),
19277
+ actionId
19278
+ }
19279
+ });
19280
+ return {
19281
+ interactionId: result.invokeMessageAction.interactionId
19282
+ };
19283
+ }
19284
+ async answerMessageAction(params) {
19285
+ await this.invoke(Method.ANSWER_MESSAGE_ACTION, {
19286
+ oneofKind: "answerMessageAction",
19287
+ answerMessageAction: {
19288
+ interactionId: asInlineId(params.interactionId, "interactionId"),
19289
+ ...params.ui != null ? { ui: params.ui } : {}
19290
+ }
19291
+ });
19292
+ }
18402
19293
  async invokeRaw(method, input = { oneofKind: undefined }, options) {
18403
19294
  if (hasMethodMapping(method)) {
18404
19295
  this.assertMethodInputMatch(method, input);
@@ -18565,6 +19456,32 @@ class InlineSdkClient {
18565
19456
  });
18566
19457
  return;
18567
19458
  }
19459
+ case "messageActionInvoked": {
19460
+ const payload = update.update.messageActionInvoked;
19461
+ await this.eventStream.send({
19462
+ kind: "message.action.invoke",
19463
+ interactionId: payload.interactionId,
19464
+ chatId: payload.chatId,
19465
+ messageId: payload.messageId,
19466
+ actorUserId: payload.actorUserId,
19467
+ actionId: payload.actionId,
19468
+ data: payload.data,
19469
+ seq,
19470
+ date
19471
+ });
19472
+ return;
19473
+ }
19474
+ case "messageActionAnswered": {
19475
+ const payload = update.update.messageActionAnswered;
19476
+ await this.eventStream.send({
19477
+ kind: "message.action.answered",
19478
+ interactionId: payload.interactionId,
19479
+ ui: payload.ui,
19480
+ seq,
19481
+ date
19482
+ });
19483
+ return;
19484
+ }
18568
19485
  case "chatHasNewUpdates": {
18569
19486
  const payload = update.update.chatHasNewUpdates;
18570
19487
  await this.eventStream.send({
@@ -18573,7 +19490,7 @@ class InlineSdkClient {
18573
19490
  seq,
18574
19491
  date
18575
19492
  });
18576
- await this.catchUpChat({ chatId: payload.chatId, peer: payload.peerId, updateSeq: payload.updateSeq, update });
19493
+ this.requestCatchUpChat({ chatId: payload.chatId, peer: payload.peerId, updateSeq: payload.updateSeq });
18577
19494
  return;
18578
19495
  }
18579
19496
  case "spaceHasNewUpdates": {
@@ -18602,21 +19519,50 @@ class InlineSdkClient {
18602
19519
  this.scheduleStateSave();
18603
19520
  }
18604
19521
  }
18605
- async catchUpChat(params) {
18606
- const key = params.chatId.toString();
18607
- const lastSeq = this.state.lastSeqByChatId?.[key];
18608
- const startSeq = lastSeq ?? params.updateSeq;
18609
- if (params.updateSeq <= startSeq)
18610
- return;
19522
+ requestCatchUpChat(params) {
19523
+ const previous = this.catchUpRequestedByChatId.get(params.chatId);
19524
+ this.catchUpRequestedByChatId.set(params.chatId, {
19525
+ endSeq: Math.max(previous?.endSeq ?? 0, params.updateSeq),
19526
+ peer: params.peer ?? previous?.peer
19527
+ });
18611
19528
  if (this.catchUpInFlightByChatId.has(params.chatId)) {
18612
- await this.catchUpInFlightByChatId.get(params.chatId);
18613
19529
  return;
18614
19530
  }
18615
- const task = this.doCatchUpChat(params.chatId, params.peer, startSeq, params.updateSeq).finally(() => {
19531
+ const task = this.drainCatchUpChat(params.chatId).catch((error) => {
19532
+ this.catchUpRequestedByChatId.delete(params.chatId);
19533
+ this.log.warn?.("GET_UPDATES catch-up failed; continuing live delivery", {
19534
+ chatId: params.chatId.toString(),
19535
+ error: extractErrorMessage(error)
19536
+ });
19537
+ }).finally(() => {
18616
19538
  this.catchUpInFlightByChatId.delete(params.chatId);
18617
19539
  });
18618
19540
  this.catchUpInFlightByChatId.set(params.chatId, task);
18619
- await task;
19541
+ }
19542
+ async drainCatchUpChat(chatId) {
19543
+ const key = chatId.toString();
19544
+ while (true) {
19545
+ const request = this.catchUpRequestedByChatId.get(chatId);
19546
+ if (!request)
19547
+ return;
19548
+ const lastSeq = this.state.lastSeqByChatId?.[key];
19549
+ const startSeq = lastSeq ?? Math.max(0, request.endSeq - defaultColdStartCatchUpWindow);
19550
+ if (request.endSeq <= startSeq) {
19551
+ this.catchUpRequestedByChatId.delete(chatId);
19552
+ return;
19553
+ }
19554
+ const stop = await this.doCatchUpChat(chatId, request.peer, startSeq, request.endSeq);
19555
+ if (stop) {
19556
+ this.catchUpRequestedByChatId.delete(chatId);
19557
+ return;
19558
+ }
19559
+ const latest = this.catchUpRequestedByChatId.get(chatId);
19560
+ const syncedSeq = this.state.lastSeqByChatId?.[key] ?? 0;
19561
+ if (!latest || latest.endSeq <= syncedSeq) {
19562
+ this.catchUpRequestedByChatId.delete(chatId);
19563
+ return;
19564
+ }
19565
+ }
18620
19566
  }
18621
19567
  async doCatchUpChat(chatId, peer, startSeq, endSeq) {
18622
19568
  let cursor = startSeq;
@@ -18634,7 +19580,7 @@ class InlineSdkClient {
18634
19580
  }),
18635
19581
  startSeq: BigInt(cursor),
18636
19582
  seqEnd: BigInt(endSeq),
18637
- totalLimit: 1000
19583
+ totalLimit: defaultCatchUpTotalLimit
18638
19584
  })
18639
19585
  });
18640
19586
  const payload = result.getUpdates;
@@ -18645,12 +19591,12 @@ class InlineSdkClient {
18645
19591
  this.state.dateCursor = payload.date;
18646
19592
  }
18647
19593
  this.scheduleStateSave();
18648
- return;
19594
+ return true;
18649
19595
  }
18650
19596
  const deliveredSeq = Number(payload.seq ?? 0n);
18651
19597
  if (!Number.isSafeInteger(deliveredSeq)) {
18652
19598
  this.log.warn?.("GET_UPDATES returned non-integer seq; aborting catch-up", { chatId: chatId.toString() });
18653
- return;
19599
+ return true;
18654
19600
  }
18655
19601
  this.bumpChatSeq(chatId, deliveredSeq);
18656
19602
  for (const update of payload.updates) {
@@ -18661,13 +19607,14 @@ class InlineSdkClient {
18661
19607
  }
18662
19608
  this.scheduleStateSave();
18663
19609
  if (payload.final)
18664
- return;
19610
+ return true;
18665
19611
  if (deliveredSeq <= cursor) {
18666
19612
  this.log.warn?.("GET_UPDATES made no progress; aborting catch-up", { chatId: chatId.toString(), cursor, deliveredSeq });
18667
- return;
19613
+ return true;
18668
19614
  }
18669
19615
  cursor = deliveredSeq;
18670
19616
  }
19617
+ return false;
18671
19618
  }
18672
19619
  peerToInputPeer(peer, chatId) {
18673
19620
  if (!peer) {
@@ -19002,15 +19949,6 @@ class JsonFileStateStore {
19002
19949
  await rename(tempPath, this.path);
19003
19950
  }
19004
19951
  }
19005
- // src/inline/config-schema.ts
19006
- import {
19007
- BlockStreamingCoalesceSchema,
19008
- DmPolicySchema,
19009
- GroupPolicySchema,
19010
- ToolPolicySchema,
19011
- requireOpenAllowFrom
19012
- } from "openclaw/plugin-sdk";
19013
-
19014
19952
  // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
19015
19953
  var exports_external = {};
19016
19954
  __export(exports_external, {
@@ -32534,15 +33472,255 @@ function number3(params) {
32534
33472
  function boolean3(params) {
32535
33473
  return _coercedBoolean(ZodBoolean, params);
32536
33474
  }
32537
- function bigint3(params) {
32538
- return _coercedBigint(ZodBigInt, params);
33475
+ function bigint3(params) {
33476
+ return _coercedBigint(ZodBigInt, params);
33477
+ }
33478
+ function date4(params) {
33479
+ return _coercedDate(ZodDate, params);
33480
+ }
33481
+
33482
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
33483
+ config(en_default());
33484
+ // src/openclaw-compat.ts
33485
+ var MB = 1024 * 1024;
33486
+ var VALID_ACCOUNT_ID_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/i;
33487
+ var INVALID_ACCOUNT_ID_CHARS_RE = /[^a-z0-9_-]+/g;
33488
+ var LEADING_DASH_RE = /^-+/g;
33489
+ var TRAILING_DASH_RE = /-+$/g;
33490
+ var BLOCKED_OBJECT_KEYS = new Set(["__proto__", "constructor", "prototype"]);
33491
+ var DEFAULT_ACCOUNT_ID = "default";
33492
+ var PAIRING_APPROVED_MESSAGE = "✅ OpenClaw access approved. Send a message to start chatting.";
33493
+ function normalizeAccountId(value) {
33494
+ const trimmed = (value ?? "").trim();
33495
+ if (!trimmed)
33496
+ return DEFAULT_ACCOUNT_ID;
33497
+ const normalized = VALID_ACCOUNT_ID_RE.test(trimmed) ? trimmed.toLowerCase() : trimmed.toLowerCase().replace(INVALID_ACCOUNT_ID_CHARS_RE, "-").replace(LEADING_DASH_RE, "").replace(TRAILING_DASH_RE, "").slice(0, 64);
33498
+ if (!normalized || BLOCKED_OBJECT_KEYS.has(normalized)) {
33499
+ return DEFAULT_ACCOUNT_ID;
33500
+ }
33501
+ return normalized;
33502
+ }
33503
+ function emptyPluginConfigSchema() {
33504
+ function error48(message) {
33505
+ return { success: false, error: { issues: [{ path: [], message }] } };
33506
+ }
33507
+ return {
33508
+ safeParse(value) {
33509
+ if (value === undefined) {
33510
+ return { success: true, data: undefined };
33511
+ }
33512
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
33513
+ return error48("expected config object");
33514
+ }
33515
+ if (Object.keys(value).length > 0) {
33516
+ return error48("config must be empty");
33517
+ }
33518
+ return { success: true, data: value };
33519
+ },
33520
+ jsonSchema: {
33521
+ type: "object",
33522
+ additionalProperties: false,
33523
+ properties: {}
33524
+ }
33525
+ };
33526
+ }
33527
+ function buildChannelConfigSchema(schema) {
33528
+ const schemaWithJson = schema;
33529
+ if (typeof schemaWithJson.toJSONSchema === "function") {
33530
+ return {
33531
+ schema: schemaWithJson.toJSONSchema({
33532
+ target: "draft-07",
33533
+ unrepresentable: "any"
33534
+ })
33535
+ };
33536
+ }
33537
+ return {
33538
+ schema: {
33539
+ type: "object",
33540
+ additionalProperties: true
33541
+ }
33542
+ };
33543
+ }
33544
+ function formatPairingApproveHint(channelId) {
33545
+ return `Approve via: openclaw pairing list ${channelId} / openclaw pairing approve ${channelId} <code>`;
33546
+ }
33547
+ var GroupPolicySchema = exports_external.enum(["open", "disabled", "allowlist"]);
33548
+ var DmPolicySchema = exports_external.enum(["pairing", "allowlist", "open", "disabled"]);
33549
+ var BlockStreamingCoalesceSchema = exports_external.object({
33550
+ minChars: exports_external.number().int().positive().optional(),
33551
+ maxChars: exports_external.number().int().positive().optional(),
33552
+ idleMs: exports_external.number().int().nonnegative().optional()
33553
+ }).strict();
33554
+ var ToolPolicyBaseSchema = exports_external.object({
33555
+ allow: exports_external.array(exports_external.string()).optional(),
33556
+ alsoAllow: exports_external.array(exports_external.string()).optional(),
33557
+ deny: exports_external.array(exports_external.string()).optional()
33558
+ }).strict();
33559
+ var ToolPolicySchema = ToolPolicyBaseSchema.superRefine((value, ctx) => {
33560
+ if (value.allow && value.allow.length > 0 && value.alsoAllow && value.alsoAllow.length > 0) {
33561
+ ctx.addIssue({
33562
+ code: exports_external.ZodIssueCode.custom,
33563
+ message: "tools policy cannot set both allow and alsoAllow in the same scope (merge alsoAllow into allow, or remove allow and use profile + alsoAllow)"
33564
+ });
33565
+ }
33566
+ }).optional();
33567
+ function requireOpenAllowFrom(params) {
33568
+ if (params.policy !== "open") {
33569
+ return;
33570
+ }
33571
+ const allow = (params.allowFrom ?? []).map((entry) => String(entry).trim()).filter(Boolean);
33572
+ if (allow.includes("*")) {
33573
+ return;
33574
+ }
33575
+ params.ctx.addIssue({
33576
+ code: exports_external.ZodIssueCode.custom,
33577
+ path: params.path,
33578
+ message: params.message
33579
+ });
33580
+ }
33581
+ function resolveControlCommandGate(params) {
33582
+ const mode = params.modeWhenAccessGroupsOff ?? "allow";
33583
+ let commandAuthorized = false;
33584
+ if (!params.useAccessGroups) {
33585
+ if (mode === "allow") {
33586
+ commandAuthorized = true;
33587
+ } else if (mode === "deny") {
33588
+ commandAuthorized = false;
33589
+ } else {
33590
+ const anyConfigured = params.authorizers.some((entry) => entry.configured);
33591
+ commandAuthorized = !anyConfigured || params.authorizers.some((entry) => entry.configured && entry.allowed);
33592
+ }
33593
+ } else {
33594
+ commandAuthorized = params.authorizers.some((entry) => entry.configured && entry.allowed);
33595
+ }
33596
+ return {
33597
+ commandAuthorized,
33598
+ shouldBlock: params.allowTextCommands && params.hasControlCommand && !commandAuthorized
33599
+ };
33600
+ }
33601
+ function resolveMentionGatingWithBypass(params) {
33602
+ const shouldBypassMention = params.isGroup && params.requireMention && !params.wasMentioned && !(params.hasAnyMention ?? false) && params.allowTextCommands && params.commandAuthorized && params.hasControlCommand;
33603
+ const effectiveWasMentioned = params.wasMentioned || params.implicitMention === true || shouldBypassMention;
33604
+ return {
33605
+ effectiveWasMentioned,
33606
+ shouldSkip: params.requireMention && params.canDetectMention && !effectiveWasMentioned,
33607
+ shouldBypassMention
33608
+ };
33609
+ }
33610
+ function logInboundDrop(params) {
33611
+ const target = params.target ? ` target=${params.target}` : "";
33612
+ params.log(`${params.channel}: drop ${params.reason}${target}`);
33613
+ }
33614
+ function resolveChannelMediaMaxBytes(params) {
33615
+ const accountId = normalizeAccountId(params.accountId);
33616
+ const channelLimit = params.resolveChannelLimitMb({
33617
+ cfg: params.cfg,
33618
+ accountId
33619
+ });
33620
+ if (channelLimit) {
33621
+ return channelLimit * MB;
33622
+ }
33623
+ if (params.cfg.agents?.defaults?.mediaMaxMb) {
33624
+ return params.cfg.agents.defaults.mediaMaxMb * MB;
33625
+ }
33626
+ return;
33627
+ }
33628
+ function createActionGate(actions) {
33629
+ return (key, defaultValue = true) => {
33630
+ const value = actions?.[key];
33631
+ if (value === undefined) {
33632
+ return defaultValue;
33633
+ }
33634
+ return value !== false;
33635
+ };
33636
+ }
33637
+ function toSnakeCaseKey(key) {
33638
+ return key.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
33639
+ }
33640
+ function readSnakeCaseParamRaw(params, key) {
33641
+ if (Object.hasOwn(params, key)) {
33642
+ return params[key];
33643
+ }
33644
+ const snakeKey = toSnakeCaseKey(key);
33645
+ if (snakeKey !== key && Object.hasOwn(params, snakeKey)) {
33646
+ return params[snakeKey];
33647
+ }
33648
+ return;
33649
+ }
33650
+
33651
+ class ToolInputError extends Error {
33652
+ status = 400;
33653
+ constructor(message) {
33654
+ super(message);
33655
+ this.name = "ToolInputError";
33656
+ }
33657
+ }
33658
+ function readStringParam(params, key, options = {}) {
33659
+ const { required: required2 = false, trim = true, label = key, allowEmpty = false } = options;
33660
+ const raw = readSnakeCaseParamRaw(params, key);
33661
+ if (typeof raw !== "string") {
33662
+ if (required2) {
33663
+ throw new ToolInputError(`${label} required`);
33664
+ }
33665
+ return;
33666
+ }
33667
+ const value = trim ? raw.trim() : raw;
33668
+ if (!value && !allowEmpty) {
33669
+ if (required2) {
33670
+ throw new ToolInputError(`${label} required`);
33671
+ }
33672
+ return;
33673
+ }
33674
+ return value;
33675
+ }
33676
+ function readNumberParam(params, key, options = {}) {
33677
+ const { required: required2 = false, label = key, integer: integer2 = false, strict = false } = options;
33678
+ const raw = readSnakeCaseParamRaw(params, key);
33679
+ let value;
33680
+ if (typeof raw === "number" && Number.isFinite(raw)) {
33681
+ value = raw;
33682
+ } else if (typeof raw === "string") {
33683
+ const trimmed = raw.trim();
33684
+ if (trimmed) {
33685
+ const parsed = strict ? Number(trimmed) : Number.parseFloat(trimmed);
33686
+ if (Number.isFinite(parsed)) {
33687
+ value = parsed;
33688
+ }
33689
+ }
33690
+ }
33691
+ if (value === undefined) {
33692
+ if (required2) {
33693
+ throw new ToolInputError(`${label} required`);
33694
+ }
33695
+ return;
33696
+ }
33697
+ return integer2 ? Math.trunc(value) : value;
33698
+ }
33699
+ function readReactionParams(params, options) {
33700
+ const emojiKey = options.emojiKey ?? "emoji";
33701
+ const removeKey = options.removeKey ?? "remove";
33702
+ const remove = typeof params[removeKey] === "boolean" ? params[removeKey] : false;
33703
+ const emoji3 = readStringParam(params, emojiKey, {
33704
+ required: true,
33705
+ allowEmpty: true
33706
+ });
33707
+ if (remove && !emoji3) {
33708
+ throw new ToolInputError(options.removeErrorMessage);
33709
+ }
33710
+ return { emoji: emoji3 ?? "", remove, isEmpty: !emoji3 };
32539
33711
  }
32540
- function date4(params) {
32541
- return _coercedDate(ZodDate, params);
33712
+ function jsonResult(payload) {
33713
+ return {
33714
+ content: [
33715
+ {
33716
+ type: "text",
33717
+ text: JSON.stringify(payload, (_key, value) => typeof value === "bigint" ? value.toString() : value, 2)
33718
+ }
33719
+ ],
33720
+ details: payload
33721
+ };
32542
33722
  }
32543
33723
 
32544
- // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
32545
- config(en_default());
32546
33724
  // src/inline/config-schema.ts
32547
33725
  var InlineActionsSchema = exports_external.object({
32548
33726
  send: exports_external.boolean().optional(),
@@ -32559,9 +33737,14 @@ var InlineActionsSchema = exports_external.object({
32559
33737
  }).strict();
32560
33738
  var InlineGroupSchema = exports_external.object({
32561
33739
  requireMention: exports_external.boolean().optional(),
33740
+ systemPrompt: exports_external.string().optional(),
32562
33741
  tools: ToolPolicySchema,
32563
33742
  toolsBySender: exports_external.record(exports_external.string(), ToolPolicySchema).optional()
32564
33743
  }).strict();
33744
+ var InlineCommandsSchema = exports_external.object({
33745
+ native: exports_external.union([exports_external.boolean(), exports_external.literal("auto")]).optional(),
33746
+ nativeSkills: exports_external.union([exports_external.boolean(), exports_external.literal("auto")]).optional()
33747
+ }).strict();
32565
33748
  var InlineAccountSchemaBase = exports_external.object({
32566
33749
  name: exports_external.string().optional(),
32567
33750
  enabled: exports_external.boolean().optional(),
@@ -32570,6 +33753,7 @@ var InlineAccountSchemaBase = exports_external.object({
32570
33753
  tokenFile: exports_external.string().optional(),
32571
33754
  dmPolicy: DmPolicySchema.optional().default("pairing"),
32572
33755
  allowFrom: exports_external.array(exports_external.string()).optional(),
33756
+ systemPrompt: exports_external.string().optional(),
32573
33757
  groupAllowFrom: exports_external.array(exports_external.string()).optional(),
32574
33758
  groupPolicy: GroupPolicySchema.optional().default("allowlist"),
32575
33759
  groups: exports_external.record(exports_external.string(), InlineGroupSchema.optional()).optional(),
@@ -32584,7 +33768,8 @@ var InlineAccountSchemaBase = exports_external.object({
32584
33768
  chunkMode: exports_external.enum(["length", "newline"]).optional(),
32585
33769
  blockStreaming: exports_external.boolean().optional(),
32586
33770
  streamViaEditMessage: exports_external.boolean().optional(),
32587
- blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional()
33771
+ blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
33772
+ commands: InlineCommandsSchema.optional()
32588
33773
  }).strict();
32589
33774
  var InlineRuntimeAccountSchema = InlineAccountSchemaBase.passthrough();
32590
33775
  var InlineAccountSchema = InlineAccountSchemaBase.superRefine((value, ctx) => {
@@ -32612,7 +33797,6 @@ var InlineConfigSchema = InlineAccountSchemaBase.extend({
32612
33797
  });
32613
33798
 
32614
33799
  // src/inline/accounts.ts
32615
- import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk";
32616
33800
  import { readFile as readFile2 } from "node:fs/promises";
32617
33801
  var DEFAULT_BASE_URL = "https://api.inline.chat";
32618
33802
  function normalizeInlineAccountId(raw) {
@@ -32718,22 +33902,283 @@ function looksLikeInlineTargetId(raw, normalizedInput) {
32718
33902
  // src/inline/monitor.ts
32719
33903
  import { mkdir } from "node:fs/promises";
32720
33904
  import path2 from "node:path";
32721
- import {
32722
- buildPendingHistoryContextFromMap,
32723
- clearHistoryEntriesIfEnabled,
32724
- createReplyPrefixOptions,
32725
- createTypingCallbacks,
32726
- logInboundDrop,
32727
- recordPendingHistoryEntryIfEnabled,
32728
- resolveChannelMediaMaxBytes as resolveChannelMediaMaxBytes2,
32729
- resolveControlCommandGate,
32730
- resolveMentionGatingWithBypass
32731
- } from "openclaw/plugin-sdk";
33905
+
33906
+ // src/sdk-runtime-compat.ts
33907
+ var HISTORY_CONTEXT_MARKER = "[Chat messages since your last reply - for context]";
33908
+ var CURRENT_MESSAGE_MARKER = "[Current message - respond to this]";
33909
+ var MAX_HISTORY_KEYS = 1000;
33910
+ var DEFAULT_GROUP_HISTORY_LIMIT = 50;
33911
+ function evictOldHistoryKeys(historyMap, maxKeys = MAX_HISTORY_KEYS) {
33912
+ if (historyMap.size <= maxKeys) {
33913
+ return;
33914
+ }
33915
+ const keysToDelete = historyMap.size - maxKeys;
33916
+ const iterator = historyMap.keys();
33917
+ for (let index = 0;index < keysToDelete; index += 1) {
33918
+ const key = iterator.next().value;
33919
+ if (key !== undefined) {
33920
+ historyMap.delete(key);
33921
+ }
33922
+ }
33923
+ }
33924
+ function buildHistoryContext(params) {
33925
+ const lineBreak = params.lineBreak ?? `
33926
+ `;
33927
+ if (!params.historyText.trim()) {
33928
+ return params.currentMessage;
33929
+ }
33930
+ return [
33931
+ HISTORY_CONTEXT_MARKER,
33932
+ params.historyText,
33933
+ "",
33934
+ CURRENT_MESSAGE_MARKER,
33935
+ params.currentMessage
33936
+ ].join(lineBreak);
33937
+ }
33938
+ function appendHistoryEntry(params) {
33939
+ if (params.limit <= 0) {
33940
+ return [];
33941
+ }
33942
+ const history = params.historyMap.get(params.historyKey) ?? [];
33943
+ history.push(params.entry);
33944
+ while (history.length > params.limit) {
33945
+ history.shift();
33946
+ }
33947
+ if (params.historyMap.has(params.historyKey)) {
33948
+ params.historyMap.delete(params.historyKey);
33949
+ }
33950
+ params.historyMap.set(params.historyKey, history);
33951
+ evictOldHistoryKeys(params.historyMap);
33952
+ return history;
33953
+ }
33954
+ function buildHistoryContextFromEntries(params) {
33955
+ const lineBreak = params.lineBreak ?? `
33956
+ `;
33957
+ const entries = params.excludeLast === false ? params.entries : params.entries.slice(0, -1);
33958
+ if (entries.length === 0) {
33959
+ return params.currentMessage;
33960
+ }
33961
+ return buildHistoryContext({
33962
+ historyText: entries.map(params.formatEntry).join(lineBreak),
33963
+ currentMessage: params.currentMessage,
33964
+ lineBreak
33965
+ });
33966
+ }
33967
+ function buildPendingHistoryContextFromMap(params) {
33968
+ if (params.limit <= 0) {
33969
+ return params.currentMessage;
33970
+ }
33971
+ const entries = params.historyMap.get(params.historyKey) ?? [];
33972
+ return buildHistoryContextFromEntries({
33973
+ entries,
33974
+ currentMessage: params.currentMessage,
33975
+ formatEntry: params.formatEntry,
33976
+ ...params.lineBreak !== undefined ? { lineBreak: params.lineBreak } : {},
33977
+ excludeLast: false
33978
+ });
33979
+ }
33980
+ function clearHistoryEntriesIfEnabled(params) {
33981
+ if (params.limit <= 0) {
33982
+ return;
33983
+ }
33984
+ params.historyMap.set(params.historyKey, []);
33985
+ }
33986
+ function recordPendingHistoryEntryIfEnabled(params) {
33987
+ if (!params.entry || params.limit <= 0) {
33988
+ return [];
33989
+ }
33990
+ return appendHistoryEntry({
33991
+ historyMap: params.historyMap,
33992
+ historyKey: params.historyKey,
33993
+ entry: params.entry,
33994
+ limit: params.limit
33995
+ });
33996
+ }
33997
+ function createMessageToolButtonsSchemaCompat() {
33998
+ return {
33999
+ type: "array",
34000
+ description: "Button rows for channels that support button-style actions.",
34001
+ items: {
34002
+ type: "array",
34003
+ items: {
34004
+ type: "object",
34005
+ additionalProperties: false,
34006
+ required: ["text", "callback_data"],
34007
+ properties: {
34008
+ text: { type: "string" },
34009
+ callback_data: { type: "string" },
34010
+ style: { type: "string", enum: ["danger", "success", "primary"] }
34011
+ }
34012
+ }
34013
+ }
34014
+ };
34015
+ }
34016
+ function extensionForMimeCompat(mime) {
34017
+ const normalized = mime?.trim().toLowerCase();
34018
+ if (!normalized)
34019
+ return;
34020
+ const directMap = {
34021
+ "image/jpeg": "jpg",
34022
+ "image/jpg": "jpg",
34023
+ "image/png": "png",
34024
+ "image/gif": "gif",
34025
+ "image/webp": "webp",
34026
+ "video/mp4": "mp4",
34027
+ "audio/mpeg": "mp3",
34028
+ "audio/mp4": "m4a",
34029
+ "audio/wav": "wav",
34030
+ "audio/ogg": "ogg",
34031
+ "application/pdf": "pdf",
34032
+ "text/plain": "txt"
34033
+ };
34034
+ const mapped = directMap[normalized];
34035
+ if (mapped)
34036
+ return mapped;
34037
+ const [, subtype] = normalized.split("/", 2);
34038
+ return subtype?.split("+", 1)[0] || undefined;
34039
+ }
34040
+ function createInlineTypingCallbacks(params) {
34041
+ const keepaliveIntervalMs = params.keepaliveIntervalMs ?? 3000;
34042
+ const maxConsecutiveFailures = Math.max(1, params.maxConsecutiveFailures ?? 2);
34043
+ const maxDurationMs = params.maxDurationMs ?? 60000;
34044
+ let closed = false;
34045
+ let stopSent = false;
34046
+ let consecutiveFailures = 0;
34047
+ let keepaliveTimer;
34048
+ let ttlTimer;
34049
+ const clearTimers = () => {
34050
+ if (keepaliveTimer) {
34051
+ clearInterval(keepaliveTimer);
34052
+ keepaliveTimer = undefined;
34053
+ }
34054
+ if (ttlTimer) {
34055
+ clearTimeout(ttlTimer);
34056
+ ttlTimer = undefined;
34057
+ }
34058
+ };
34059
+ const fireStop = () => {
34060
+ closed = true;
34061
+ clearTimers();
34062
+ if (!params.stop || stopSent) {
34063
+ return;
34064
+ }
34065
+ stopSent = true;
34066
+ params.stop().catch((err) => (params.onStopError ?? params.onStartError)(err));
34067
+ };
34068
+ const fireStart = async () => {
34069
+ if (closed)
34070
+ return;
34071
+ try {
34072
+ await params.start();
34073
+ consecutiveFailures = 0;
34074
+ } catch (err) {
34075
+ consecutiveFailures += 1;
34076
+ params.onStartError(err);
34077
+ if (consecutiveFailures >= maxConsecutiveFailures) {
34078
+ fireStop();
34079
+ }
34080
+ }
34081
+ };
34082
+ return {
34083
+ onReplyStart: async () => {
34084
+ if (closed)
34085
+ return;
34086
+ stopSent = false;
34087
+ consecutiveFailures = 0;
34088
+ clearTimers();
34089
+ await fireStart();
34090
+ if (closed)
34091
+ return;
34092
+ keepaliveTimer = setInterval(() => {
34093
+ fireStart();
34094
+ }, keepaliveIntervalMs);
34095
+ if (maxDurationMs > 0) {
34096
+ ttlTimer = setTimeout(() => {
34097
+ fireStop();
34098
+ }, maxDurationMs);
34099
+ }
34100
+ },
34101
+ onIdle: fireStop,
34102
+ onCleanup: fireStop
34103
+ };
34104
+ }
34105
+ async function createChannelReplyPipelineCompat(params) {
34106
+ try {
34107
+ const sdk = await import("openclaw/plugin-sdk/channel-reply-pipeline");
34108
+ return sdk.createChannelReplyPipeline(params);
34109
+ } catch {
34110
+ return {
34111
+ onModelSelected: () => {},
34112
+ ...params.typingCallbacks ? { typingCallbacks: params.typingCallbacks } : params.typing ? { typingCallbacks: createInlineTypingCallbacks(params.typing) } : {}
34113
+ };
34114
+ }
34115
+ }
34116
+ async function loadNativeCommandHelpersCompat() {
34117
+ try {
34118
+ const sdk = await import("openclaw/plugin-sdk/command-auth");
34119
+ const listNativeCommandSpecsForConfig = typeof sdk.listNativeCommandSpecsForConfig === "function" ? sdk.listNativeCommandSpecsForConfig : null;
34120
+ const listSkillCommandsForAgents = typeof sdk.listSkillCommandsForAgents === "function" ? sdk.listSkillCommandsForAgents : null;
34121
+ if (!listNativeCommandSpecsForConfig || !listSkillCommandsForAgents) {
34122
+ throw new Error("command-auth helpers unavailable");
34123
+ }
34124
+ return {
34125
+ available: true,
34126
+ listNativeCommandSpecsForConfig,
34127
+ listSkillCommandsForAgents
34128
+ };
34129
+ } catch {
34130
+ return {
34131
+ available: false,
34132
+ listNativeCommandSpecsForConfig: () => [],
34133
+ listSkillCommandsForAgents: () => []
34134
+ };
34135
+ }
34136
+ }
34137
+ async function loadPluginCommandSpecsCompat(provider) {
34138
+ try {
34139
+ const sdk = await import("openclaw/plugin-sdk/plugin-runtime");
34140
+ if (typeof sdk.getPluginCommandSpecs !== "function") {
34141
+ throw new Error("plugin runtime command helper unavailable");
34142
+ }
34143
+ return {
34144
+ available: true,
34145
+ specs: sdk.getPluginCommandSpecs(provider)
34146
+ };
34147
+ } catch {
34148
+ return {
34149
+ available: false,
34150
+ specs: []
34151
+ };
34152
+ }
34153
+ }
34154
+
34155
+ // src/inline/message-formatting.ts
34156
+ var INLINE_FORMATTING_NOTE = "Inline formatting note: prefer bullet lists over markdown tables. If a table is necessary, render it inside a fenced code block. Do not wrap bare URLs in inline code or backticks. Use plain URLs or markdown links. Use inline code only for actual code, commands, file paths, env vars, or identifiers.";
34157
+ var INLINE_SYSTEM_PROMPT_BASE = "Format replies for Inline. Prefer bullet lists over markdown tables. If a table is necessary, render it inside a fenced code block. Do not wrap bare URLs in inline code or backticks. Use plain URLs or markdown links. Use inline code only for actual code, commands, file paths, env vars, or identifiers.";
34158
+ function isBareHttpUrl(text) {
34159
+ if (!/^https?:\/\/\S+$/i.test(text))
34160
+ return false;
34161
+ try {
34162
+ const url2 = new URL(text);
34163
+ return url2.protocol === "http:" || url2.protocol === "https:";
34164
+ } catch {
34165
+ return false;
34166
+ }
34167
+ }
34168
+ function buildInlineSystemPrompt(extraPrompt) {
34169
+ return [INLINE_SYSTEM_PROMPT_BASE, extraPrompt?.trim() || null].filter((entry) => Boolean(entry)).join(`
34170
+
34171
+ `);
34172
+ }
34173
+ function sanitizeInlineOutgoingText(text) {
34174
+ return text.replace(/`([^`\n]+)`/g, (full, content) => {
34175
+ return isBareHttpUrl(content) ? content : full;
34176
+ });
34177
+ }
32732
34178
 
32733
34179
  // src/inline/policy.ts
32734
- import { normalizeAccountId as normalizePluginAccountId } from "openclaw/plugin-sdk";
32735
34180
  function normalizeAccountId2(raw) {
32736
- return normalizePluginAccountId(raw);
34181
+ return normalizeAccountId(raw);
32737
34182
  }
32738
34183
  function resolveInlineGroups(cfg, accountId) {
32739
34184
  const inline = cfg.channels?.inline;
@@ -32851,19 +34296,12 @@ function getInlineRuntime() {
32851
34296
 
32852
34297
  // src/inline/media.ts
32853
34298
  import path from "node:path";
32854
- import {
32855
- detectMime,
32856
- extensionForMime,
32857
- loadWebMedia,
32858
- resolveChannelMediaMaxBytes
32859
- } from "openclaw/plugin-sdk";
32860
34299
  var DEFAULT_MEDIA_MAX_MB = 300;
32861
34300
  var SUPPORTED_INLINE_PHOTO_MIME = new Set(["image/jpeg", "image/png", "image/gif"]);
32862
34301
  var SUPPORTED_INLINE_VIDEO_MIME = new Set(["video/mp4"]);
32863
34302
  var DEFAULT_VIDEO_WIDTH = 1280;
32864
34303
  var DEFAULT_VIDEO_HEIGHT = 720;
32865
34304
  var DEFAULT_VIDEO_DURATION = 1;
32866
- var loadWebMediaCompat = loadWebMedia;
32867
34305
  function looksLikeLocalMediaSource(mediaUrl) {
32868
34306
  return !/^https?:\/\//i.test(mediaUrl.trim());
32869
34307
  }
@@ -32906,7 +34344,7 @@ function ensureUploadFileName(params) {
32906
34344
  if (ext)
32907
34345
  return baseName;
32908
34346
  }
32909
- const inferredExt = params.ext ?? extensionForMime(params.mime) ?? undefined;
34347
+ const inferredExt = params.ext ?? extensionForMimeCompat(params.mime) ?? undefined;
32910
34348
  const fallbackExt = inferredExt ?? (params.uploadType === "photo" ? "jpg" : params.uploadType === "video" ? "mp4" : "bin");
32911
34349
  return `attachment.${fallbackExt}`;
32912
34350
  }
@@ -32984,13 +34422,15 @@ async function uploadInlineMediaFromUrl(params) {
32984
34422
  cfg: params.cfg,
32985
34423
  accountId: params.accountId ?? null
32986
34424
  });
34425
+ const runtimeMedia = getInlineRuntime().media;
34426
+ const loadWebMediaCompat = runtimeMedia.loadWebMedia;
32987
34427
  let loaded;
32988
34428
  let detectedMime;
32989
34429
  let uploadType;
32990
34430
  let fileName;
32991
34431
  try {
32992
34432
  try {
32993
- loaded = await loadWebMedia(params.mediaUrl, maxBytes);
34433
+ loaded = await runtimeMedia.loadWebMedia(params.mediaUrl, maxBytes);
32994
34434
  } catch (error48) {
32995
34435
  const message = String(error48);
32996
34436
  const deniedLocalPath = /not under an allowed directory/i.test(message);
@@ -33004,13 +34444,13 @@ async function uploadInlineMediaFromUrl(params) {
33004
34444
  if (!loaded) {
33005
34445
  throw new Error("inline media upload: media load returned no data");
33006
34446
  }
33007
- detectedMime = normalizeMime(loaded.contentType ?? await detectMime({
34447
+ detectedMime = normalizeMime(loaded.contentType ?? await runtimeMedia.detectMime({
33008
34448
  buffer: loaded.buffer,
33009
34449
  ...loaded.fileName ? { filePath: loaded.fileName } : {}
33010
34450
  }));
33011
34451
  const normalizedExt = normalizeExt(loaded.fileName);
33012
34452
  uploadType = chooseUploadType({
33013
- kind: loaded.kind,
34453
+ kind: loaded.kind ?? "unknown",
33014
34454
  ...detectedMime ? { mime: detectedMime } : {},
33015
34455
  ...normalizedExt ? { ext: normalizedExt } : {}
33016
34456
  });
@@ -33354,9 +34794,246 @@ function summarizeInlineMessageContent(message) {
33354
34794
  };
33355
34795
  }
33356
34796
 
34797
+ // src/inline/command-menu-compat.ts
34798
+ var THINKING_LEVEL_CHOICES = ["off", "minimal", "low", "medium", "high", "xhigh"];
34799
+ var COMPAT_COMMANDS = [
34800
+ {
34801
+ key: "tts",
34802
+ nativeName: "tts",
34803
+ args: [
34804
+ {
34805
+ name: "action",
34806
+ description: "TTS action",
34807
+ choices: [
34808
+ { value: "on", label: "On" },
34809
+ { value: "off", label: "Off" },
34810
+ { value: "status", label: "Status" },
34811
+ { value: "provider", label: "Provider" },
34812
+ { value: "limit", label: "Limit" },
34813
+ { value: "summary", label: "Summary" },
34814
+ { value: "audio", label: "Audio" },
34815
+ { value: "help", label: "Help" }
34816
+ ]
34817
+ },
34818
+ { name: "value", description: "Provider, limit, or text" }
34819
+ ],
34820
+ argsMenu: {
34821
+ arg: "action",
34822
+ title: "Choose TTS action:"
34823
+ }
34824
+ },
34825
+ {
34826
+ key: "session",
34827
+ nativeName: "session",
34828
+ args: [
34829
+ { name: "action", description: "idle | max-age", choices: ["idle", "max-age"] },
34830
+ { name: "value", description: "Duration or off" }
34831
+ ],
34832
+ argsMenu: "auto"
34833
+ },
34834
+ {
34835
+ key: "subagents",
34836
+ nativeName: "subagents",
34837
+ args: [
34838
+ {
34839
+ name: "action",
34840
+ description: "list | kill | log | info | send | steer | spawn",
34841
+ choices: ["list", "kill", "log", "info", "send", "steer", "spawn"]
34842
+ },
34843
+ { name: "target", description: "Run id, index, or session key" },
34844
+ { name: "value", description: "Additional input" }
34845
+ ],
34846
+ argsMenu: "auto"
34847
+ },
34848
+ {
34849
+ key: "acp",
34850
+ nativeName: "acp",
34851
+ args: [
34852
+ {
34853
+ name: "action",
34854
+ description: "Action to run",
34855
+ choices: [
34856
+ "spawn",
34857
+ "cancel",
34858
+ "steer",
34859
+ "close",
34860
+ "sessions",
34861
+ "status",
34862
+ "set-mode",
34863
+ "set",
34864
+ "cwd",
34865
+ "permissions",
34866
+ "timeout",
34867
+ "model",
34868
+ "reset-options",
34869
+ "doctor",
34870
+ "install",
34871
+ "help"
34872
+ ]
34873
+ },
34874
+ { name: "value", description: "Action arguments" }
34875
+ ],
34876
+ argsMenu: "auto"
34877
+ },
34878
+ {
34879
+ key: "usage",
34880
+ nativeName: "usage",
34881
+ args: [{ name: "mode", description: "off, tokens, full, or cost", choices: ["off", "tokens", "full", "cost"] }],
34882
+ argsMenu: "auto"
34883
+ },
34884
+ {
34885
+ key: "activation",
34886
+ nativeName: "activation",
34887
+ args: [{ name: "mode", description: "mention or always", choices: ["mention", "always"] }],
34888
+ argsMenu: "auto"
34889
+ },
34890
+ {
34891
+ key: "send",
34892
+ nativeName: "send",
34893
+ args: [{ name: "mode", description: "on, off, or inherit", choices: ["on", "off", "inherit"] }],
34894
+ argsMenu: "auto"
34895
+ },
34896
+ {
34897
+ key: "think",
34898
+ nativeName: "think",
34899
+ args: [{ name: "level", description: "thinking level", choices: [...THINKING_LEVEL_CHOICES] }],
34900
+ argsMenu: "auto"
34901
+ },
34902
+ {
34903
+ key: "verbose",
34904
+ nativeName: "verbose",
34905
+ args: [{ name: "mode", description: "on or off", choices: ["on", "off"] }],
34906
+ argsMenu: "auto"
34907
+ },
34908
+ {
34909
+ key: "fast",
34910
+ nativeName: "fast",
34911
+ args: [{ name: "mode", description: "status, on, or off", choices: ["status", "on", "off"] }],
34912
+ argsMenu: "auto"
34913
+ },
34914
+ {
34915
+ key: "reasoning",
34916
+ nativeName: "reasoning",
34917
+ args: [{ name: "mode", description: "on, off, or stream", choices: ["on", "off", "stream"] }],
34918
+ argsMenu: "auto"
34919
+ },
34920
+ {
34921
+ key: "elevated",
34922
+ nativeName: "elevated",
34923
+ args: [{ name: "mode", description: "on, off, ask, or full", choices: ["on", "off", "ask", "full"] }],
34924
+ argsMenu: "auto"
34925
+ }
34926
+ ];
34927
+ function parsePositionalArgs(definitions, raw) {
34928
+ const values = {};
34929
+ const trimmed = raw.trim();
34930
+ if (!trimmed)
34931
+ return values;
34932
+ const tokens = trimmed.split(/\s+/).filter(Boolean);
34933
+ let index = 0;
34934
+ for (const definition of definitions) {
34935
+ if (index >= tokens.length)
34936
+ break;
34937
+ const token = tokens[index];
34938
+ if (!token)
34939
+ break;
34940
+ values[definition.name] = token;
34941
+ index += 1;
34942
+ }
34943
+ return values;
34944
+ }
34945
+ function parseCommandArgs(command, raw) {
34946
+ const trimmed = raw?.trim();
34947
+ if (!trimmed)
34948
+ return;
34949
+ if (!command.args || command.argsParsing === "none") {
34950
+ return { raw: trimmed };
34951
+ }
34952
+ return {
34953
+ raw: trimmed,
34954
+ values: parsePositionalArgs(command.args, trimmed)
34955
+ };
34956
+ }
34957
+ function findCommandByNativeName(name) {
34958
+ const normalized = name.trim().toLowerCase();
34959
+ return COMPAT_COMMANDS.find((command) => command.nativeName.toLowerCase() === normalized);
34960
+ }
34961
+ function resolveCommandArgChoices(arg) {
34962
+ const raw = arg.choices ?? [];
34963
+ return raw.map((choice) => typeof choice === "string" ? { value: choice, label: choice } : choice);
34964
+ }
34965
+ function resolveCommandArgMenu(params) {
34966
+ const { command, args } = params;
34967
+ if (!command.args || !command.argsMenu)
34968
+ return null;
34969
+ if (command.argsParsing === "none")
34970
+ return null;
34971
+ const argName = command.argsMenu === "auto" ? command.args.find((arg2) => resolveCommandArgChoices(arg2).length > 0)?.name : command.argsMenu.arg;
34972
+ if (!argName)
34973
+ return null;
34974
+ if (args?.values && args.values[argName] != null)
34975
+ return null;
34976
+ if (args?.raw && !args.values)
34977
+ return null;
34978
+ const arg = command.args.find((entry) => entry.name === argName);
34979
+ if (!arg)
34980
+ return null;
34981
+ const choices = resolveCommandArgChoices(arg);
34982
+ if (choices.length === 0)
34983
+ return null;
34984
+ const title = command.argsMenu !== "auto" ? command.argsMenu.title : undefined;
34985
+ return {
34986
+ arg,
34987
+ choices,
34988
+ ...title ? { title } : {}
34989
+ };
34990
+ }
34991
+ function buildCommandTextFromArgs(command, args) {
34992
+ const values = args?.values ?? {};
34993
+ const argDefs = command.args ?? [];
34994
+ const renderedArgs = [];
34995
+ for (const argDef of argDefs) {
34996
+ const value = values[argDef.name];
34997
+ if (value == null)
34998
+ continue;
34999
+ const normalized = typeof value === "string" ? value.trim() : String(value);
35000
+ if (!normalized)
35001
+ continue;
35002
+ renderedArgs.push(normalized);
35003
+ }
35004
+ return renderedArgs.length > 0 ? `/${command.nativeName} ${renderedArgs.join(" ")}` : `/${command.nativeName}`;
35005
+ }
35006
+ function resolveInlineCompatNativeCommandMenu(commandBody) {
35007
+ const normalized = commandBody.trim();
35008
+ const match = normalized.match(/^\/([^\s]+)(?:\s+([\s\S]+))?$/);
35009
+ if (!match?.[1])
35010
+ return null;
35011
+ const command = findCommandByNativeName(match[1]);
35012
+ if (!command)
35013
+ return null;
35014
+ const args = parseCommandArgs(command, match[2]);
35015
+ const menu = resolveCommandArgMenu({
35016
+ command,
35017
+ ...args ? { args } : {}
35018
+ });
35019
+ if (!menu)
35020
+ return null;
35021
+ const title = menu.title ?? `Choose ${menu.arg.description || menu.arg.name} for /${command.nativeName}.`;
35022
+ const rows = [];
35023
+ for (let index = 0;index < menu.choices.length; index += 2) {
35024
+ const slice = menu.choices.slice(index, index + 2);
35025
+ rows.push(slice.map((choice) => ({
35026
+ text: choice.label,
35027
+ callback_data: buildCommandTextFromArgs(command, {
35028
+ values: { [menu.arg.name]: choice.value }
35029
+ })
35030
+ })));
35031
+ }
35032
+ return { title, buttons: rows };
35033
+ }
35034
+
33357
35035
  // src/inline/monitor.ts
33358
35036
  var CHANNEL_ID = "inline";
33359
- var DEFAULT_GROUP_HISTORY_LIMIT = 12;
33360
35037
  var DEFAULT_DM_HISTORY_LIMIT = 6;
33361
35038
  var HISTORY_LINE_MAX_CHARS = 280;
33362
35039
  var BOT_MESSAGE_CACHE_LIMIT = 500;
@@ -33364,7 +35041,6 @@ var REACTION_TARGET_LOOKUP_LIMIT = 8;
33364
35041
  var REPLY_TARGET_LOOKUP_LIMIT = 8;
33365
35042
  var ATTACHMENT_CONTEXT_LIMIT = 6;
33366
35043
  var DEFAULT_INLINE_MEDIA_MAX_BYTES = 300 * 1024 * 1024;
33367
- var INLINE_FORMATTING_NOTE = "Inline formatting note: prefer bullet lists over markdown tables. If a table is necessary, render it inside a fenced code block.";
33368
35044
  var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
33369
35045
  function normalizeAllowEntry(raw) {
33370
35046
  return raw.trim().replace(/^inline:/i, "").replace(/^user:/i, "");
@@ -33407,10 +35083,156 @@ function normalizeInlineCommandBody(raw, botUsername) {
33407
35083
  }
33408
35084
  return normalized;
33409
35085
  }
35086
+ function callbackDataToBase64(data) {
35087
+ return Buffer.from(data).toString("base64");
35088
+ }
35089
+ function callbackDataToUtf8(data) {
35090
+ try {
35091
+ const decoded = new TextDecoder("utf-8", { fatal: true }).decode(data).trim();
35092
+ return decoded || undefined;
35093
+ } catch {
35094
+ return;
35095
+ }
35096
+ }
35097
+ var INLINE_ACTION_MAX_ROWS = 8;
35098
+ var INLINE_ACTION_MAX_PER_ROW = 8;
35099
+ function isRecord3(value) {
35100
+ return typeof value === "object" && value !== null;
35101
+ }
35102
+ function mapInlineModelPickerCallbackToCommand(raw) {
35103
+ const trimmed = raw.trim();
35104
+ if (!trimmed)
35105
+ return;
35106
+ if (trimmed === "mdl_prov" || trimmed === "mdl_back") {
35107
+ return "/models";
35108
+ }
35109
+ const listMatch = trimmed.match(/^mdl_list_([a-z0-9_-]+)_(\d+)$/i);
35110
+ if (listMatch?.[1] && listMatch[2]) {
35111
+ const provider = listMatch[1].trim();
35112
+ const page = Number.parseInt(listMatch[2], 10);
35113
+ if (provider && Number.isFinite(page) && page > 0) {
35114
+ return `/models ${provider} ${String(page)}`;
35115
+ }
35116
+ }
35117
+ const standardSelectionMatch = trimmed.match(/^mdl_sel_(.+)$/);
35118
+ if (standardSelectionMatch?.[1]?.trim()) {
35119
+ return `/model ${standardSelectionMatch[1].trim()}`;
35120
+ }
35121
+ const compactSelectionMatch = trimmed.match(/^mdl_sel\/(.+)$/);
35122
+ if (compactSelectionMatch?.[1]?.trim()) {
35123
+ return `/model ${compactSelectionMatch[1].trim()}`;
35124
+ }
35125
+ return;
35126
+ }
35127
+ function normalizeInlineActionCallbackData(raw) {
35128
+ const trimmed = raw.trim();
35129
+ if (!trimmed)
35130
+ return "";
35131
+ return mapInlineModelPickerCallbackToCommand(trimmed) ?? trimmed;
35132
+ }
35133
+ function normalizeReplyMarkupButtonsWith(raw, options) {
35134
+ if (!Array.isArray(raw))
35135
+ return [];
35136
+ const rows = [];
35137
+ for (const candidateRow of raw) {
35138
+ if (!Array.isArray(candidateRow))
35139
+ continue;
35140
+ const row = [];
35141
+ for (const candidateButton of candidateRow) {
35142
+ if (!isRecord3(candidateButton))
35143
+ continue;
35144
+ const text = typeof candidateButton.text === "string" ? candidateButton.text.trim() : "";
35145
+ const callbackDataRaw = typeof candidateButton.callback_data === "string" ? candidateButton.callback_data.trim() : "";
35146
+ const callbackData = options?.mapCallbackData ? options.mapCallbackData(callbackDataRaw) : callbackDataRaw;
35147
+ if (!text || !callbackData)
35148
+ continue;
35149
+ row.push({ text, callback_data: callbackData });
35150
+ if (row.length >= INLINE_ACTION_MAX_PER_ROW)
35151
+ break;
35152
+ }
35153
+ if (row.length === 0)
35154
+ continue;
35155
+ rows.push(row);
35156
+ if (rows.length >= INLINE_ACTION_MAX_ROWS)
35157
+ break;
35158
+ }
35159
+ return rows;
35160
+ }
35161
+ function resolveInlineReplyActions(payload) {
35162
+ const channelData = isRecord3(payload.channelData) ? payload.channelData : undefined;
35163
+ const inlineData = channelData && isRecord3(channelData.inline) ? channelData.inline : undefined;
35164
+ const telegramData = channelData && isRecord3(channelData.telegram) ? channelData.telegram : undefined;
35165
+ let rawButtons = undefined;
35166
+ let hasExplicitButtons = false;
35167
+ let mapCallbackData;
35168
+ if (inlineData && Object.prototype.hasOwnProperty.call(inlineData, "buttons")) {
35169
+ rawButtons = inlineData.buttons;
35170
+ hasExplicitButtons = true;
35171
+ } else if (telegramData && Object.prototype.hasOwnProperty.call(telegramData, "buttons")) {
35172
+ rawButtons = telegramData.buttons;
35173
+ hasExplicitButtons = true;
35174
+ mapCallbackData = normalizeInlineActionCallbackData;
35175
+ } else if (Object.prototype.hasOwnProperty.call(payload, "buttons")) {
35176
+ rawButtons = payload.buttons;
35177
+ hasExplicitButtons = true;
35178
+ }
35179
+ if (!hasExplicitButtons)
35180
+ return;
35181
+ const rows = normalizeReplyMarkupButtonsWith(rawButtons, {
35182
+ ...mapCallbackData ? { mapCallbackData } : {}
35183
+ });
35184
+ return {
35185
+ rows: rows.map((row, rowIndex) => ({
35186
+ actions: row.map((button, buttonIndex) => ({
35187
+ actionId: `btn_${rowIndex + 1}_${buttonIndex + 1}`,
35188
+ text: button.text,
35189
+ action: {
35190
+ oneofKind: "callback",
35191
+ callback: {
35192
+ data: new TextEncoder().encode(button.callback_data)
35193
+ }
35194
+ }
35195
+ }))
35196
+ }))
35197
+ };
35198
+ }
35199
+ async function answerInlineMessageAction(client, interactionId) {
35200
+ const withAnswer = client;
35201
+ if (typeof withAnswer.answerMessageAction === "function") {
35202
+ await withAnswer.answerMessageAction({ interactionId });
35203
+ return;
35204
+ }
35205
+ const answerMethod = Method["ANSWER_MESSAGE_ACTION"];
35206
+ if (typeof answerMethod === "number" && typeof withAnswer.invokeUncheckedRaw === "function") {
35207
+ await withAnswer.invokeUncheckedRaw(answerMethod, {
35208
+ oneofKind: "answerMessageAction",
35209
+ answerMessageAction: { interactionId }
35210
+ });
35211
+ }
35212
+ }
35213
+ function resolveCallbackCommandBodyFromActionData(params) {
35214
+ const decoded = callbackDataToUtf8(params.data);
35215
+ if (!decoded)
35216
+ return;
35217
+ const normalized = normalizeInlineActionCallbackData(decoded);
35218
+ if (!normalized.startsWith("/"))
35219
+ return;
35220
+ return normalizeInlineCommandBody(normalized, params.botUsername);
35221
+ }
35222
+ function shouldUseTelegramSurfaceForModelCommands(commandBody) {
35223
+ const normalized = commandBody.trim().toLowerCase();
35224
+ return normalized === "/model" || normalized.startsWith("/model ") || normalized === "/models" || normalized.startsWith("/models ");
35225
+ }
33410
35226
  function buildInlineSenderName(params) {
33411
35227
  const name = [params.firstName, params.lastName].filter(Boolean).join(" ").trim();
33412
35228
  return name || undefined;
33413
35229
  }
35230
+ function resolveInlineSystemPrompt(params) {
35231
+ const groupPrompt = params.groupId ? params.account.config.groups?.[params.groupId]?.systemPrompt?.trim() : undefined;
35232
+ return [buildInlineSystemPrompt(params.account.config.systemPrompt), groupPrompt].filter((entry) => Boolean(entry)).join(`
35233
+
35234
+ `);
35235
+ }
33414
35236
  function rewriteNumericMentionsToUsernames(text, senderProfilesById) {
33415
35237
  if (!text.includes("@"))
33416
35238
  return text;
@@ -33567,12 +35389,46 @@ function resolveHistorySenderLabel(params) {
33567
35389
  }
33568
35390
  function resolveHistoryLimit(params) {
33569
35391
  if (params.isGroup) {
33570
- return params.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT;
35392
+ return Math.max(0, params.historyLimit ?? params.cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT);
35393
+ }
35394
+ return Math.max(0, params.dmHistoryLimit ?? params.historyLimit ?? DEFAULT_DM_HISTORY_LIMIT);
35395
+ }
35396
+ function historyEntryDedupeKey(entry) {
35397
+ if (entry.messageId)
35398
+ return `id:${entry.messageId}`;
35399
+ return `ts:${entry.timestamp ?? "unknown"}:${entry.sender}:${entry.body}`;
35400
+ }
35401
+ function mergeInboundHistoryEntries(params) {
35402
+ if (params.limit <= 0)
35403
+ return [];
35404
+ const deduped = [];
35405
+ const seen = new Set;
35406
+ for (const entry of [...params.historyContextEntries, ...params.pendingEntries]) {
35407
+ const key = historyEntryDedupeKey(entry);
35408
+ if (seen.has(key))
35409
+ continue;
35410
+ seen.add(key);
35411
+ deduped.push(entry);
33571
35412
  }
33572
- return params.dmHistoryLimit ?? params.historyLimit ?? DEFAULT_DM_HISTORY_LIMIT;
35413
+ return deduped.slice(-params.limit).map((entry) => ({
35414
+ sender: entry.sender,
35415
+ body: entry.body,
35416
+ ...entry.timestamp != null ? { timestamp: entry.timestamp } : {}
35417
+ }));
35418
+ }
35419
+ function buildInlineBodyForAgent(params) {
35420
+ return [
35421
+ params.rawBody,
35422
+ params.currentAttachmentText && params.currentAttachmentText !== params.rawBody ? `Current media/attachments:
35423
+ ${params.currentAttachmentText}` : null,
35424
+ params.currentEntityText ? `Current message entities:
35425
+ ${params.currentEntityText}` : null
35426
+ ].filter(Boolean).join(`
35427
+
35428
+ `) || params.rawBody;
33573
35429
  }
33574
35430
  function resolveInlineMediaMaxBytes(params) {
33575
- return resolveChannelMediaMaxBytes2({
35431
+ return resolveChannelMediaMaxBytes({
33576
35432
  cfg: params.cfg,
33577
35433
  accountId: params.account.accountId,
33578
35434
  resolveChannelLimitMb: ({ accountId }) => {
@@ -33663,7 +35519,7 @@ async function resolveInlineInboundMedia(params) {
33663
35519
  }
33664
35520
  return out;
33665
35521
  }
33666
- async function buildHistoryContext(params) {
35522
+ async function buildHistoryContext2(params) {
33667
35523
  const cachedReplyToBot = params.replyToMsgId != null && hasBotMessageId(params.botMessageIdsByChat, params.chatId, params.replyToMsgId);
33668
35524
  let repliedToBot = cachedReplyToBot;
33669
35525
  let replyToSenderId = null;
@@ -33671,6 +35527,7 @@ async function buildHistoryContext(params) {
33671
35527
  const lines = [];
33672
35528
  const attachmentLines = [];
33673
35529
  const entityLines = [];
35530
+ const inboundHistory = [];
33674
35531
  if (params.historyLimit > 0) {
33675
35532
  const messages = await loadChatHistoryMessages({
33676
35533
  client: params.client,
@@ -33707,6 +35564,12 @@ async function buildHistoryContext(params) {
33707
35564
  meId: params.meId,
33708
35565
  senderProfilesById: params.senderProfilesById
33709
35566
  });
35567
+ inboundHistory.push({
35568
+ sender: label,
35569
+ body: text,
35570
+ ...item.date != null ? { timestamp: Number(item.date) * 1000 } : {},
35571
+ messageId: String(item.id)
35572
+ });
33710
35573
  const replySuffix = item.replyToMsgId != null ? ` ->${String(item.replyToMsgId)}` : "";
33711
35574
  lines.push(`#${String(item.id)}${replySuffix} ${label}: ${text}`);
33712
35575
  const attachmentText = normalizeHistoryText(content.attachmentText);
@@ -33743,6 +35606,7 @@ async function buildHistoryContext(params) {
33743
35606
  `) : null,
33744
35607
  entityText: entityLines.length ? entityLines.slice(-ATTACHMENT_CONTEXT_LIMIT).join(`
33745
35608
  `) : null,
35609
+ inboundHistory,
33746
35610
  repliedToBot,
33747
35611
  replyToSenderId
33748
35612
  };
@@ -33757,6 +35621,7 @@ ${attachmentLines.slice(-ATTACHMENT_CONTEXT_LIMIT).join(`
33757
35621
  entityText: entityLines.length ? `Recent message entities:
33758
35622
  ${entityLines.slice(-ATTACHMENT_CONTEXT_LIMIT).join(`
33759
35623
  `)}` : null,
35624
+ inboundHistory,
33760
35625
  repliedToBot,
33761
35626
  replyToSenderId
33762
35627
  };
@@ -33843,13 +35708,20 @@ async function monitorInlineProvider(params) {
33843
35708
  for await (const event of client.events()) {
33844
35709
  if (abortSignal.aborted)
33845
35710
  break;
35711
+ const rawEvent = event;
33846
35712
  let msg;
33847
35713
  let rawBody = "";
33848
35714
  let currentAttachmentText = null;
33849
35715
  let currentEntityText = null;
33850
35716
  let reactionEvent = null;
35717
+ let inboundChatId = null;
35718
+ let callbackActionEvent = null;
33851
35719
  if (event.kind === "message.new") {
33852
- msg = event.message;
35720
+ inboundChatId = event.chatId;
35721
+ msg = {
35722
+ ...event.message,
35723
+ chatId: event.chatId
35724
+ };
33853
35725
  const content = summarizeInlineMessageContent(msg);
33854
35726
  rawBody = buildInlineInboundBodyText(content);
33855
35727
  currentAttachmentText = content.attachmentText || null;
@@ -33859,6 +35731,7 @@ async function monitorInlineProvider(params) {
33859
35731
  if (msg.out || msg.fromId === meId)
33860
35732
  continue;
33861
35733
  } else if (event.kind === "reaction.add") {
35734
+ inboundChatId = event.chatId;
33862
35735
  if (event.reaction.userId === meId)
33863
35736
  continue;
33864
35737
  const onBotMessage = await isReactionTargetBotMessage({
@@ -33889,6 +35762,7 @@ async function monitorInlineProvider(params) {
33889
35762
  replyToMsgId: event.reaction.messageId
33890
35763
  };
33891
35764
  } else if (event.kind === "reaction.delete") {
35765
+ inboundChatId = event.chatId;
33892
35766
  if (event.userId === meId)
33893
35767
  continue;
33894
35768
  const onBotMessage = await isReactionTargetBotMessage({
@@ -33918,10 +35792,42 @@ async function monitorInlineProvider(params) {
33918
35792
  mentioned: false,
33919
35793
  replyToMsgId: event.messageId
33920
35794
  };
35795
+ } else if (rawEvent["kind"] === "message.action.invoke") {
35796
+ const actorUserId = rawEvent["actorUserId"];
35797
+ const interactionId = rawEvent["interactionId"];
35798
+ const actionId = rawEvent["actionId"];
35799
+ const targetMessageId = rawEvent["messageId"];
35800
+ const data = rawEvent["data"];
35801
+ const eventChatId = rawEvent["chatId"];
35802
+ const eventDate = rawEvent["date"];
35803
+ if (!actorUserId || !interactionId || !actionId || !targetMessageId || !eventChatId || !eventDate || !data) {
35804
+ continue;
35805
+ }
35806
+ inboundChatId = eventChatId;
35807
+ if (actorUserId === meId)
35808
+ continue;
35809
+ callbackActionEvent = {
35810
+ interactionId,
35811
+ actionId,
35812
+ targetMessageId,
35813
+ data
35814
+ };
35815
+ msg = {
35816
+ id: targetMessageId,
35817
+ chatId: eventChatId,
35818
+ date: eventDate,
35819
+ fromId: actorUserId,
35820
+ message: "",
35821
+ out: false,
35822
+ mentioned: false,
35823
+ replyToMsgId: targetMessageId
35824
+ };
33921
35825
  } else {
33922
35826
  continue;
33923
35827
  }
33924
- const chatId = event.chatId;
35828
+ if (!inboundChatId)
35829
+ continue;
35830
+ const chatId = inboundChatId;
33925
35831
  statusSink?.({ lastInboundAt: Date.now() });
33926
35832
  let chatInfo;
33927
35833
  try {
@@ -33945,19 +35851,49 @@ async function monitorInlineProvider(params) {
33945
35851
  } else {
33946
35852
  rawBody = `${actor} removed ${emoji3} from your message #${messageId}`;
33947
35853
  }
35854
+ } else if (callbackActionEvent) {
35855
+ const actor = senderUsername != null && senderUsername.length > 0 ? `@${senderUsername}` : senderName ?? `user:${senderId}`;
35856
+ const payload = {
35857
+ type: "inline_message_action_callback",
35858
+ interaction_id: String(callbackActionEvent.interactionId),
35859
+ actor_user_id: senderId,
35860
+ chat_id: String(chatId),
35861
+ message_id: String(callbackActionEvent.targetMessageId),
35862
+ action_id: callbackActionEvent.actionId,
35863
+ data_base64: callbackDataToBase64(callbackActionEvent.data),
35864
+ data_utf8: callbackDataToUtf8(callbackActionEvent.data) ?? null
35865
+ };
35866
+ rawBody = `${actor} pressed a button on message #${String(callbackActionEvent.targetMessageId)}
35867
+ ${JSON.stringify(payload)}`;
33948
35868
  }
33949
35869
  const dmPolicy = account.config.dmPolicy ?? "pairing";
33950
35870
  const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
33951
35871
  const groupPolicy = account.config.groupPolicy ?? defaultGroupPolicy ?? "allowlist";
33952
35872
  const configAllowFrom = normalizeAllowlist(account.config.allowFrom);
33953
35873
  const configGroupAllowFrom = normalizeAllowlist(account.config.groupAllowFrom);
33954
- const storeAllowFrom = await core3.channel.pairing.readAllowFromStore(CHANNEL_ID).catch(() => []);
35874
+ const storeAllowFrom = await core3.channel.pairing.readAllowFromStore({
35875
+ channel: CHANNEL_ID,
35876
+ accountId: account.accountId
35877
+ }).catch(() => []);
33955
35878
  const storeAllowList = normalizeAllowlist(storeAllowFrom);
33956
35879
  const effectiveAllowFrom = [...configAllowFrom, ...storeAllowList].filter(Boolean);
33957
35880
  const effectiveGroupAllowFrom = [
33958
35881
  ...configGroupAllowFrom.length > 0 ? configGroupAllowFrom : configAllowFrom,
33959
35882
  ...storeAllowList
33960
35883
  ].filter(Boolean);
35884
+ const callbackCommandBody = callbackActionEvent ? resolveCallbackCommandBodyFromActionData({
35885
+ data: callbackActionEvent.data,
35886
+ ...botUsername ? { botUsername } : {}
35887
+ }) : undefined;
35888
+ let callbackActionAnswered = false;
35889
+ const answerCallbackIfNeeded = async () => {
35890
+ if (!callbackActionEvent || callbackActionAnswered)
35891
+ return;
35892
+ await answerInlineMessageAction(client, callbackActionEvent.interactionId);
35893
+ callbackActionAnswered = true;
35894
+ };
35895
+ const shouldEditCallbackTargetInPlace = false;
35896
+ const normalizedCommandBody = callbackCommandBody ?? normalizeInlineCommandBody(rawBody, botUsername);
33961
35897
  const allowTextCommands = core3.channel.commands.shouldHandleTextCommands({
33962
35898
  cfg,
33963
35899
  surface: CHANNEL_ID
@@ -33965,7 +35901,7 @@ async function monitorInlineProvider(params) {
33965
35901
  const useAccessGroups = cfg.commands?.useAccessGroups !== false;
33966
35902
  const allowForCommands = isGroup ? effectiveGroupAllowFrom : effectiveAllowFrom;
33967
35903
  const senderAllowedForCommands = allowlistMatch({ allowFrom: allowForCommands, senderId });
33968
- const hasControlCommand = core3.channel.text.hasControlCommand(rawBody, cfg, botUsername ? { botUsername } : undefined);
35904
+ const hasControlCommand = core3.channel.text.hasControlCommand(callbackCommandBody ?? rawBody, cfg, botUsername ? { botUsername } : undefined);
33969
35905
  const commandGate = resolveControlCommandGate({
33970
35906
  useAccessGroups,
33971
35907
  authorizers: [{ configured: allowForCommands.length > 0, allowed: senderAllowedForCommands }],
@@ -33976,18 +35912,27 @@ async function monitorInlineProvider(params) {
33976
35912
  if (isGroup) {
33977
35913
  if (groupPolicy === "disabled") {
33978
35914
  log?.info(`[${account.accountId}] inline: drop group chat=${String(chatId)} (groupPolicy=disabled)`);
35915
+ await answerCallbackIfNeeded().catch((error48) => {
35916
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35917
+ });
33979
35918
  continue;
33980
35919
  }
33981
35920
  if (groupPolicy === "allowlist") {
33982
35921
  const allowed = allowlistMatch({ allowFrom: effectiveGroupAllowFrom, senderId });
33983
35922
  if (!allowed) {
33984
35923
  log?.info(`[${account.accountId}] inline: drop group sender=${senderId} (groupPolicy=allowlist)`);
35924
+ await answerCallbackIfNeeded().catch((error48) => {
35925
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35926
+ });
33985
35927
  continue;
33986
35928
  }
33987
35929
  }
33988
35930
  } else {
33989
35931
  if (dmPolicy === "disabled") {
33990
35932
  log?.info(`[${account.accountId}] inline: drop DM sender=${senderId} (dmPolicy=disabled)`);
35933
+ await answerCallbackIfNeeded().catch((error48) => {
35934
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35935
+ });
33991
35936
  continue;
33992
35937
  }
33993
35938
  if (dmPolicy !== "open") {
@@ -33997,6 +35942,7 @@ async function monitorInlineProvider(params) {
33997
35942
  const { code, created } = await core3.channel.pairing.upsertPairingRequest({
33998
35943
  channel: CHANNEL_ID,
33999
35944
  id: senderId,
35945
+ accountId: account.accountId,
34000
35946
  meta: {},
34001
35947
  pairingAdapter: { idLabel: "inlineUserId", normalizeAllowEntry }
34002
35948
  });
@@ -34017,17 +35963,23 @@ async function monitorInlineProvider(params) {
34017
35963
  }
34018
35964
  }
34019
35965
  log?.info(`[${account.accountId}] inline: drop DM sender=${senderId} (dmPolicy=${dmPolicy})`);
35966
+ await answerCallbackIfNeeded().catch((error48) => {
35967
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35968
+ });
34020
35969
  continue;
34021
35970
  }
34022
35971
  }
34023
35972
  }
34024
- if (commandGate.shouldBlock) {
35973
+ if (isGroup && commandGate.shouldBlock) {
34025
35974
  logInboundDrop({
34026
35975
  log: (m) => runtime2.log?.(m),
34027
35976
  channel: CHANNEL_ID,
34028
35977
  reason: "control command (unauthorized)",
34029
35978
  target: senderId
34030
35979
  });
35980
+ await answerCallbackIfNeeded().catch((error48) => {
35981
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35982
+ });
34031
35983
  continue;
34032
35984
  }
34033
35985
  const route = core3.channel.routing.resolveAgentRoute({
@@ -34047,11 +35999,12 @@ async function monitorInlineProvider(params) {
34047
35999
  const groupHistoryKey = isGroup ? route.sessionKey : null;
34048
36000
  const pendingHistorySender = senderUsername ? `@${senderUsername}` : senderName ?? `user:${senderId}`;
34049
36001
  const historyLimit = resolveHistoryLimit({
36002
+ cfg,
34050
36003
  isGroup,
34051
36004
  historyLimit: account.config.historyLimit,
34052
36005
  dmHistoryLimit: account.config.dmHistoryLimit
34053
36006
  });
34054
- const historyContext = await buildHistoryContext({
36007
+ const historyContext = await buildHistoryContext2({
34055
36008
  client,
34056
36009
  chatId,
34057
36010
  currentMessageId: msg.id,
@@ -34062,9 +36015,16 @@ async function monitorInlineProvider(params) {
34062
36015
  botMessageIdsByChat
34063
36016
  }).catch((err) => {
34064
36017
  statusSink?.({ lastError: `getChatHistory failed: ${String(err)}` });
34065
- return { historyText: null, attachmentText: null, entityText: null, repliedToBot: false, replyToSenderId: null };
36018
+ return {
36019
+ historyText: null,
36020
+ attachmentText: null,
36021
+ entityText: null,
36022
+ inboundHistory: [],
36023
+ repliedToBot: false,
36024
+ replyToSenderId: null
36025
+ };
34066
36026
  });
34067
- const implicitMention = reactionEvent != null && isGroup || isGroup && (account.config.replyToBotWithoutMention ?? false) && msg.replyToMsgId != null && historyContext.repliedToBot;
36027
+ const implicitMention = (reactionEvent != null || callbackActionEvent != null) && isGroup || isGroup && (account.config.replyToBotWithoutMention ?? false) && msg.replyToMsgId != null && historyContext.repliedToBot;
34068
36028
  const requireMention = isGroup ? resolveInlineGroupRequireMention({
34069
36029
  cfg,
34070
36030
  groupId: String(chatId),
@@ -34094,6 +36054,33 @@ async function monitorInlineProvider(params) {
34094
36054
  messageId: String(msg.id)
34095
36055
  } : null
34096
36056
  });
36057
+ await answerCallbackIfNeeded().catch((error48) => {
36058
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
36059
+ });
36060
+ continue;
36061
+ }
36062
+ const parseMarkdown = account.config.parseMarkdown ?? true;
36063
+ const nativeCommandMenu = resolveInlineCompatNativeCommandMenu(normalizedCommandBody);
36064
+ if (nativeCommandMenu) {
36065
+ const menuActions = resolveInlineReplyActions({
36066
+ channelData: {
36067
+ inline: {
36068
+ buttons: nativeCommandMenu.buttons
36069
+ }
36070
+ }
36071
+ });
36072
+ const sent = await client.sendMessage({
36073
+ chatId,
36074
+ text: nativeCommandMenu.title,
36075
+ ...menuActions ? { actions: menuActions } : {}
36076
+ });
36077
+ if (sent.messageId != null) {
36078
+ rememberBotMessageId(botMessageIdsByChat, chatId, sent.messageId);
36079
+ }
36080
+ statusSink?.({ lastOutboundAt: Date.now() });
36081
+ await answerCallbackIfNeeded().catch((error48) => {
36082
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
36083
+ });
34097
36084
  continue;
34098
36085
  }
34099
36086
  const inboundMedia = reactionEvent ? [] : await resolveInlineInboundMedia({
@@ -34144,11 +36131,27 @@ ${currentEntityText}` : null
34144
36131
  })
34145
36132
  });
34146
36133
  }
34147
- const commandBody = normalizeInlineCommandBody(rawBody, botUsername);
36134
+ const inboundHistory = isGroup && groupHistoryKey ? mergeInboundHistoryEntries({
36135
+ historyContextEntries: historyContext.inboundHistory,
36136
+ pendingEntries: groupPendingHistories.get(groupHistoryKey) ?? [],
36137
+ limit: historyLimit
36138
+ }) : [];
36139
+ const bodyForAgent = buildInlineBodyForAgent({
36140
+ rawBody,
36141
+ currentAttachmentText,
36142
+ currentEntityText
36143
+ });
36144
+ const effectiveSurface = shouldUseTelegramSurfaceForModelCommands(normalizedCommandBody) ? "telegram" : CHANNEL_ID;
36145
+ const systemPrompt = resolveInlineSystemPrompt({
36146
+ account,
36147
+ ...isGroup ? { groupId: String(chatId) } : {}
36148
+ });
34148
36149
  const ctxPayload = core3.channel.reply.finalizeInboundContext({
34149
36150
  Body: body,
36151
+ BodyForAgent: bodyForAgent,
36152
+ ...isGroup ? { InboundHistory: inboundHistory } : {},
34150
36153
  RawBody: rawBody,
34151
- CommandBody: commandBody,
36154
+ CommandBody: normalizedCommandBody,
34152
36155
  From: isGroup ? `inline:chat:${String(chatId)}` : `inline:${senderId}`,
34153
36156
  To: `inline:${String(chatId)}`,
34154
36157
  SessionKey: route.sessionKey,
@@ -34160,15 +36163,22 @@ ${currentEntityText}` : null
34160
36163
  ...senderName ? { SenderName: senderName } : {},
34161
36164
  ...senderUsername ? { SenderUsername: senderUsername } : {},
34162
36165
  Provider: CHANNEL_ID,
34163
- Surface: CHANNEL_ID,
36166
+ Surface: effectiveSurface,
34164
36167
  MessageSid: String(msg.id),
34165
36168
  ...msg.replyToMsgId != null ? { ReplyToId: String(msg.replyToMsgId) } : {},
34166
36169
  ...historyContext.replyToSenderId != null ? { ReplyToSenderId: historyContext.replyToSenderId } : {},
34167
36170
  ...msg.replyToMsgId != null ? { ReplyToWasBot: historyContext.repliedToBot } : {},
36171
+ ...callbackActionEvent ? {
36172
+ MessageActionInteractionId: String(callbackActionEvent.interactionId),
36173
+ MessageActionId: callbackActionEvent.actionId,
36174
+ MessageActionDataBase64: callbackDataToBase64(callbackActionEvent.data),
36175
+ ...callbackDataToUtf8(callbackActionEvent.data) ? { MessageActionDataUtf8: callbackDataToUtf8(callbackActionEvent.data) } : {}
36176
+ } : {},
34168
36177
  ...buildInlineInboundMediaPayload(inboundMedia),
34169
36178
  Timestamp: timestamp || Date.now(),
34170
36179
  WasMentioned: mentionGate.effectiveWasMentioned,
34171
36180
  CommandAuthorized: commandAuthorized,
36181
+ GroupSystemPrompt: systemPrompt,
34172
36182
  OriginatingChannel: CHANNEL_ID,
34173
36183
  OriginatingTo: `inline:${String(chatId)}`
34174
36184
  });
@@ -34186,22 +36196,28 @@ ${currentEntityText}` : null
34186
36196
  } : {},
34187
36197
  onRecordError: (err) => runtime2.error?.(`inline: failed updating session meta: ${String(err)}`)
34188
36198
  });
34189
- const prefixConfig = typeof createReplyPrefixOptions === "function" ? createReplyPrefixOptions({
36199
+ const replyPipeline = await createChannelReplyPipelineCompat({
34190
36200
  cfg,
34191
36201
  agentId: route.agentId,
34192
36202
  channel: CHANNEL_ID,
34193
- accountId: account.accountId
34194
- }) : {};
34195
- const onModelSelected = typeof prefixConfig.onModelSelected === "function" ? prefixConfig.onModelSelected : undefined;
34196
- const { onModelSelected: _ignoredOnModelSelected, ...prefixOptions } = prefixConfig;
34197
- const typingCallbacks = typeof createTypingCallbacks === "function" ? createTypingCallbacks({
34198
- start: () => client.sendTyping({ chatId, typing: true }),
34199
- stop: () => client.sendTyping({ chatId, typing: false }),
34200
- onStartError: (err) => runtime2.error?.(`inline typing start failed: ${String(err)}`),
34201
- onStopError: (err) => runtime2.error?.(`inline typing stop failed: ${String(err)}`)
34202
- }) : {};
34203
- const parseMarkdown = account.config.parseMarkdown ?? true;
34204
- const streamViaEditMessage = account.config.streamViaEditMessage === true;
36203
+ accountId: account.accountId,
36204
+ typing: {
36205
+ start: () => client.sendTyping({ chatId, typing: true }),
36206
+ stop: () => client.sendTyping({ chatId, typing: false }),
36207
+ onStartError: (err) => runtime2.error?.(`inline typing start failed: ${String(err)}`),
36208
+ onStopError: (err) => runtime2.error?.(`inline typing stop failed: ${String(err)}`)
36209
+ }
36210
+ });
36211
+ const onModelSelected = replyPipeline.onModelSelected;
36212
+ const typingCallbacks = replyPipeline.typingCallbacks;
36213
+ const prefixOptions = {
36214
+ ...replyPipeline.responsePrefix !== undefined ? { responsePrefix: replyPipeline.responsePrefix } : {},
36215
+ ...replyPipeline.enableSlackInteractiveReplies !== undefined ? { enableSlackInteractiveReplies: replyPipeline.enableSlackInteractiveReplies } : {},
36216
+ ...replyPipeline.responsePrefixContextProvider ? {
36217
+ responsePrefixContextProvider: replyPipeline.responsePrefixContextProvider
36218
+ } : {}
36219
+ };
36220
+ const streamViaEditMessage = account.config.streamViaEditMessage === true && !shouldEditCallbackTargetInPlace;
34205
36221
  const defaultReplyToMsgId = isGroup && msg.replyToMsgId != null ? msg.id : undefined;
34206
36222
  const disableBlockStreaming = streamViaEditMessage ? true : typeof account.config.blockStreaming === "boolean" ? !account.config.blockStreaming : undefined;
34207
36223
  const editStreamState = {
@@ -34272,118 +36288,142 @@ ${currentEntityText}` : null
34272
36288
  } : {},
34273
36289
  ...typeof disableBlockStreaming === "boolean" ? { disableBlockStreaming } : {}
34274
36290
  };
34275
- await core3.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
34276
- ctx: ctxPayload,
34277
- cfg,
34278
- dispatcherOptions: {
34279
- ...prefixOptions,
34280
- ...typingCallbacks,
34281
- deliver: async (payload) => {
34282
- const rawText = payload.text ?? "";
34283
- const mediaList = payload.mediaUrls?.length ? payload.mediaUrls : payload.mediaUrl ? [payload.mediaUrl] : [];
34284
- const outboundText = rewriteNumericMentionsToUsernames(rawText, senderProfilesById);
34285
- let replyToMsgId;
34286
- if (payload.replyToId != null) {
34287
- try {
34288
- replyToMsgId = BigInt(payload.replyToId);
34289
- } catch {}
34290
- }
34291
- if (replyToMsgId == null && isGroup && msg.replyToMsgId != null) {
34292
- replyToMsgId = msg.id;
34293
- }
34294
- const rememberSent = (messageId) => {
34295
- if (messageId != null) {
34296
- rememberBotMessageId(botMessageIdsByChat, chatId, messageId);
34297
- }
34298
- };
34299
- const sendTextFallback = async (text, includeReplyTo) => {
34300
- if (!text.trim())
34301
- return;
34302
- const sent = await client.sendMessage({
34303
- chatId,
34304
- text,
34305
- ...includeReplyTo && replyToMsgId != null ? { replyToMsgId } : {},
34306
- parseMarkdown
34307
- });
34308
- rememberSent(sent.messageId);
34309
- };
34310
- const updateStreamedMessage = async (text) => {
34311
- await editStreamState.opChain;
34312
- if (editStreamState.messageId == null)
34313
- return false;
34314
- const nextText = text.trim();
34315
- if (!nextText)
34316
- return true;
34317
- if (!editStreamState.failed && nextText === editStreamState.accumulatedText)
34318
- return true;
34319
- const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
34320
- oneofKind: "editMessage",
34321
- editMessage: {
34322
- messageId: editStreamState.messageId,
34323
- peerId: buildChatPeer(chatId),
34324
- text: nextText,
34325
- parseMarkdown
34326
- }
34327
- });
34328
- if (result.oneofKind !== "editMessage") {
34329
- throw new Error(`inline edit stream: expected editMessage result, got ${String(result.oneofKind)}`);
36291
+ try {
36292
+ await core3.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
36293
+ ctx: ctxPayload,
36294
+ cfg,
36295
+ dispatcherOptions: {
36296
+ ...prefixOptions,
36297
+ ...typingCallbacks ? { typingCallbacks } : {},
36298
+ deliver: async (payload) => {
36299
+ const rawText = payload.text ?? "";
36300
+ const mediaList = payload.mediaUrls?.length ? payload.mediaUrls : payload.mediaUrl ? [payload.mediaUrl] : [];
36301
+ const outboundText = rewriteNumericMentionsToUsernames(rawText, senderProfilesById);
36302
+ const outboundActions = resolveInlineReplyActions(payload);
36303
+ let replyToMsgId;
36304
+ if (payload.replyToId != null) {
36305
+ try {
36306
+ replyToMsgId = BigInt(payload.replyToId);
36307
+ } catch {}
34330
36308
  }
34331
- editStreamState.accumulatedText = nextText;
34332
- editStreamState.lastPartialText = nextText;
34333
- editStreamState.failed = false;
34334
- return true;
34335
- };
34336
- if (mediaList.length === 0) {
34337
- if (!outboundText.trim())
34338
- return;
34339
- if (streamViaEditMessage && editStreamState.messageId != null) {
34340
- editStreamState.finalTextAccumulator += outboundText;
34341
- await updateStreamedMessage(editStreamState.finalTextAccumulator);
34342
- statusSink?.({ lastOutboundAt: Date.now() });
34343
- return;
36309
+ if (replyToMsgId == null && isGroup && msg.replyToMsgId != null) {
36310
+ replyToMsgId = msg.id;
34344
36311
  }
34345
- await sendTextFallback(outboundText, true);
34346
- statusSink?.({ lastOutboundAt: Date.now() });
34347
- return;
34348
- }
34349
- if (streamViaEditMessage && editStreamState.messageId != null && outboundText.trim()) {
34350
- await updateStreamedMessage(outboundText);
34351
- }
34352
- for (let index = 0;index < mediaList.length; index++) {
34353
- const mediaUrl = mediaList[index];
34354
- if (!mediaUrl?.trim())
34355
- continue;
34356
- const isFirst = index === 0;
34357
- const caption = isFirst && !(streamViaEditMessage && editStreamState.messageId != null) ? outboundText : "";
34358
- try {
34359
- const media = await uploadInlineMediaFromUrl({
34360
- client,
34361
- cfg,
34362
- accountId: account.accountId,
34363
- mediaUrl
34364
- });
36312
+ const rememberSent = (messageId) => {
36313
+ if (messageId != null) {
36314
+ rememberBotMessageId(botMessageIdsByChat, chatId, messageId);
36315
+ }
36316
+ };
36317
+ const sendTextFallback = async (text, includeReplyTo, includeActions) => {
36318
+ if (!text.trim())
36319
+ return;
34365
36320
  const sent = await client.sendMessage({
34366
36321
  chatId,
34367
- ...caption ? { text: caption } : {},
34368
- media,
34369
- ...isFirst && replyToMsgId != null ? { replyToMsgId } : {},
34370
- ...caption ? { parseMarkdown } : {}
36322
+ text,
36323
+ ...includeReplyTo && replyToMsgId != null ? { replyToMsgId } : {},
36324
+ ...includeActions && outboundActions !== undefined ? { actions: outboundActions } : {},
36325
+ parseMarkdown
34371
36326
  });
34372
36327
  rememberSent(sent.messageId);
34373
- } catch (error48) {
34374
- runtime2.error?.(`inline media upload failed; falling back to url text (${String(error48)})`);
34375
- const fallbackText = caption ? `${caption}
36328
+ };
36329
+ const updateStreamedMessage = async (text, actions) => {
36330
+ await editStreamState.opChain;
36331
+ if (editStreamState.messageId == null)
36332
+ return false;
36333
+ const nextText = text.trim();
36334
+ const textForEdit = nextText || editStreamState.accumulatedText;
36335
+ if (!textForEdit)
36336
+ return true;
36337
+ const shouldSkipTextUpdate = !editStreamState.failed && textForEdit === editStreamState.accumulatedText;
36338
+ if (shouldSkipTextUpdate && actions === undefined)
36339
+ return true;
36340
+ const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
36341
+ oneofKind: "editMessage",
36342
+ editMessage: {
36343
+ messageId: editStreamState.messageId,
36344
+ peerId: buildChatPeer(chatId),
36345
+ text: textForEdit,
36346
+ parseMarkdown,
36347
+ ...actions !== undefined ? { actions } : {}
36348
+ }
36349
+ });
36350
+ if (result.oneofKind !== "editMessage") {
36351
+ throw new Error(`inline edit stream: expected editMessage result, got ${String(result.oneofKind)}`);
36352
+ }
36353
+ if (!shouldSkipTextUpdate) {
36354
+ editStreamState.accumulatedText = textForEdit;
36355
+ editStreamState.lastPartialText = textForEdit;
36356
+ }
36357
+ editStreamState.failed = false;
36358
+ return true;
36359
+ };
36360
+ if (mediaList.length === 0) {
36361
+ if (streamViaEditMessage && editStreamState.messageId != null) {
36362
+ if (outboundText.trim()) {
36363
+ editStreamState.finalTextAccumulator += outboundText;
36364
+ }
36365
+ if (!editStreamState.finalTextAccumulator.trim() && outboundActions === undefined) {
36366
+ return;
36367
+ }
36368
+ await updateStreamedMessage(editStreamState.finalTextAccumulator, outboundActions);
36369
+ statusSink?.({ lastOutboundAt: Date.now() });
36370
+ return;
36371
+ }
36372
+ if (!outboundText.trim())
36373
+ return;
36374
+ await sendTextFallback(outboundText, true, true);
36375
+ statusSink?.({ lastOutboundAt: Date.now() });
36376
+ return;
36377
+ }
36378
+ if (streamViaEditMessage && editStreamState.messageId != null && outboundText.trim()) {
36379
+ await updateStreamedMessage(outboundText, outboundActions);
36380
+ }
36381
+ for (let index = 0;index < mediaList.length; index++) {
36382
+ const mediaUrl = mediaList[index];
36383
+ if (!mediaUrl?.trim())
36384
+ continue;
36385
+ const isFirst = index === 0;
36386
+ const shouldAttachActionsToMedia = isFirst && (!(streamViaEditMessage && editStreamState.messageId != null) || !outboundText.trim());
36387
+ const caption = isFirst && !(streamViaEditMessage && editStreamState.messageId != null) ? outboundText : "";
36388
+ try {
36389
+ const media = await uploadInlineMediaFromUrl({
36390
+ client,
36391
+ cfg,
36392
+ accountId: account.accountId,
36393
+ mediaUrl
36394
+ });
36395
+ const sent = await client.sendMessage({
36396
+ chatId,
36397
+ ...caption ? { text: caption } : {},
36398
+ media,
36399
+ ...isFirst && replyToMsgId != null ? { replyToMsgId } : {},
36400
+ ...shouldAttachActionsToMedia && outboundActions !== undefined ? { actions: outboundActions } : {},
36401
+ ...caption ? { parseMarkdown } : {}
36402
+ });
36403
+ rememberSent(sent.messageId);
36404
+ } catch (error48) {
36405
+ runtime2.error?.(`inline media upload failed; falling back to url text (${String(error48)})`);
36406
+ const fallbackText = caption ? `${caption}
34376
36407
 
34377
36408
  Attachment: ${mediaUrl}` : `Attachment: ${mediaUrl}`;
34378
- await sendTextFallback(fallbackText, isFirst);
36409
+ await sendTextFallback(fallbackText, isFirst, isFirst);
36410
+ }
34379
36411
  }
34380
- }
34381
- statusSink?.({ lastOutboundAt: Date.now() });
36412
+ statusSink?.({ lastOutboundAt: Date.now() });
36413
+ },
36414
+ onError: (err, info) => runtime2.error?.(`inline ${info.kind} reply failed: ${String(err)}`)
34382
36415
  },
34383
- onError: (err, info) => runtime2.error?.(`inline ${info.kind} reply failed: ${String(err)}`)
34384
- },
34385
- replyOptions
34386
- });
36416
+ replyOptions
36417
+ });
36418
+ } finally {
36419
+ if (callbackActionEvent && !callbackActionAnswered) {
36420
+ try {
36421
+ await answerCallbackIfNeeded();
36422
+ } catch (error48) {
36423
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
36424
+ }
36425
+ }
36426
+ }
34387
36427
  if (isGroup && groupHistoryKey) {
34388
36428
  clearHistoryEntriesIfEnabled({
34389
36429
  historyMap: groupPendingHistories,
@@ -34415,15 +36455,6 @@ Attachment: ${mediaUrl}` : `Attachment: ${mediaUrl}`;
34415
36455
  return { stop, done: loop.catch(() => {}) };
34416
36456
  }
34417
36457
 
34418
- // src/inline/actions.ts
34419
- import {
34420
- createActionGate,
34421
- jsonResult,
34422
- readReactionParams,
34423
- readNumberParam,
34424
- readStringParam
34425
- } from "openclaw/plugin-sdk";
34426
-
34427
36458
  // src/inline/space-members.ts
34428
36459
  function buildInlineUserDisplayName(user) {
34429
36460
  const explicit = [user.firstName?.trim(), user.lastName?.trim()].filter(Boolean).join(" ");
@@ -34519,6 +36550,77 @@ for (const group of ACTION_GROUPS) {
34519
36550
  }
34520
36551
  var SUPPORTED_ACTIONS = Array.from(ACTION_TO_GATE_KEY.keys());
34521
36552
  var GET_MESSAGES_METHOD2 = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
36553
+ var INLINE_ACTION_MAX_ROWS2 = 8;
36554
+ var INLINE_ACTION_MAX_PER_ROW2 = 8;
36555
+ function isRecord4(value) {
36556
+ return typeof value === "object" && value !== null;
36557
+ }
36558
+ function normalizeReplyMarkupButtons(raw) {
36559
+ if (!Array.isArray(raw))
36560
+ return [];
36561
+ const rows = [];
36562
+ for (const candidateRow of raw) {
36563
+ if (!Array.isArray(candidateRow))
36564
+ continue;
36565
+ const row = [];
36566
+ for (const candidateButton of candidateRow) {
36567
+ if (!isRecord4(candidateButton))
36568
+ continue;
36569
+ const text = typeof candidateButton.text === "string" ? candidateButton.text.trim() : "";
36570
+ const callbackData = typeof candidateButton.callback_data === "string" ? candidateButton.callback_data.trim() : "";
36571
+ if (!text || !callbackData)
36572
+ continue;
36573
+ row.push({ text, callback_data: callbackData });
36574
+ if (row.length >= INLINE_ACTION_MAX_PER_ROW2)
36575
+ break;
36576
+ }
36577
+ if (row.length === 0)
36578
+ continue;
36579
+ rows.push(row);
36580
+ if (rows.length >= INLINE_ACTION_MAX_ROWS2)
36581
+ break;
36582
+ }
36583
+ return rows;
36584
+ }
36585
+ function resolveInlineMessageActionsParam(params) {
36586
+ if (!Object.prototype.hasOwnProperty.call(params, "buttons")) {
36587
+ return;
36588
+ }
36589
+ let rawButtons = params.buttons;
36590
+ if (typeof rawButtons === "string") {
36591
+ const trimmed = rawButtons.trim();
36592
+ if (!trimmed) {
36593
+ rawButtons = [];
36594
+ } else {
36595
+ try {
36596
+ rawButtons = JSON.parse(trimmed);
36597
+ } catch {
36598
+ throw new Error("inline action: buttons must be valid JSON");
36599
+ }
36600
+ }
36601
+ }
36602
+ if (rawButtons == null) {
36603
+ rawButtons = [];
36604
+ }
36605
+ if (!Array.isArray(rawButtons)) {
36606
+ throw new Error("inline action: buttons must be an array of button rows");
36607
+ }
36608
+ const rows = normalizeReplyMarkupButtons(rawButtons);
36609
+ return {
36610
+ rows: rows.map((row, rowIndex) => ({
36611
+ actions: row.map((button, buttonIndex) => ({
36612
+ actionId: `btn_${rowIndex + 1}_${buttonIndex + 1}`,
36613
+ text: button.text,
36614
+ action: {
36615
+ oneofKind: "callback",
36616
+ callback: {
36617
+ data: new TextEncoder().encode(button.callback_data)
36618
+ }
36619
+ }
36620
+ }))
36621
+ }))
36622
+ };
36623
+ }
34522
36624
  function normalizeChatId(raw) {
34523
36625
  const normalized = normalizeInlineTarget(raw) ?? raw.trim();
34524
36626
  if (!/^[0-9]+$/.test(normalized)) {
@@ -34984,6 +37086,50 @@ function listAllActions() {
34984
37086
  }
34985
37087
  return Array.from(out);
34986
37088
  }
37089
+ function listEnabledInlineActions(cfg) {
37090
+ const account = resolveInlineAccount({ cfg, accountId: null });
37091
+ if (!account.enabled || !account.configured)
37092
+ return [];
37093
+ const gate = createActionGate(account.config.actions ?? {});
37094
+ const actions = new Set;
37095
+ for (const group of ACTION_GROUPS) {
37096
+ if (!gate(group.key, group.defaultEnabled))
37097
+ continue;
37098
+ for (const action of group.actions) {
37099
+ actions.add(action);
37100
+ }
37101
+ }
37102
+ return Array.from(actions);
37103
+ }
37104
+ function supportsInlineMessageButtons(actions) {
37105
+ return actions.some((action) => action === "send" || action === "reply" || action === "thread-reply" || action === "edit");
37106
+ }
37107
+ function describeInlineMessageTool({
37108
+ cfg
37109
+ }) {
37110
+ const actions = listEnabledInlineActions(cfg);
37111
+ if (actions.length === 0) {
37112
+ return {
37113
+ actions: [],
37114
+ capabilities: [],
37115
+ schema: null
37116
+ };
37117
+ }
37118
+ const buttonsEnabled = supportsInlineMessageButtons(actions);
37119
+ const capabilities = buttonsEnabled ? ["interactive", "buttons"] : [];
37120
+ const schema = buttonsEnabled ? [
37121
+ {
37122
+ properties: {
37123
+ buttons: createMessageToolButtonsSchemaCompat()
37124
+ }
37125
+ }
37126
+ ] : [];
37127
+ return {
37128
+ actions,
37129
+ capabilities,
37130
+ schema
37131
+ };
37132
+ }
34987
37133
  function isActionEnabled(params) {
34988
37134
  const key = ACTION_TO_GATE_KEY.get(params.action);
34989
37135
  if (!key)
@@ -34999,21 +37145,10 @@ function isActionEnabled(params) {
34999
37145
  return gate(key, group.defaultEnabled);
35000
37146
  }
35001
37147
  var inlineMessageActions = {
35002
- listActions: ({ cfg }) => {
35003
- const account = resolveInlineAccount({ cfg, accountId: null });
35004
- if (!account.enabled || !account.configured)
35005
- return [];
35006
- const gate = createActionGate(account.config.actions ?? {});
35007
- const actions = new Set;
35008
- for (const group of ACTION_GROUPS) {
35009
- if (!gate(group.key, group.defaultEnabled))
35010
- continue;
35011
- for (const action of group.actions) {
35012
- actions.add(action);
35013
- }
35014
- }
35015
- return Array.from(actions);
35016
- },
37148
+ describeMessageTool: describeInlineMessageTool,
37149
+ listActions: ({ cfg }) => listEnabledInlineActions(cfg),
37150
+ supportsButtons: ({ cfg }) => supportsInlineMessageButtons(listEnabledInlineActions(cfg)),
37151
+ supportsCards: () => false,
35017
37152
  supportsAction: ({ action }) => SUPPORTED_ACTIONS.includes(action),
35018
37153
  extractToolSend: ({ args }) => {
35019
37154
  const action = typeof args.action === "string" ? args.action.trim() : "";
@@ -35042,6 +37177,7 @@ var inlineMessageActions = {
35042
37177
  accountId,
35043
37178
  fn: async (client) => {
35044
37179
  const target = resolveMessageSendTargetFromParams(params);
37180
+ const actions = resolveInlineMessageActionsParam(params);
35045
37181
  const sendTarget = target.chatId != null ? { chatId: target.chatId } : target.userId != null ? { userId: target.userId } : null;
35046
37182
  if (!sendTarget) {
35047
37183
  throw new Error("inline action: missing message target");
@@ -35057,6 +37193,7 @@ var inlineMessageActions = {
35057
37193
  const sent = await client.sendMessage({
35058
37194
  ...sendTarget,
35059
37195
  text: message,
37196
+ ...actions !== undefined ? { actions } : {},
35060
37197
  ...replyToMsgId != null ? { replyToMsgId } : {},
35061
37198
  parseMarkdown
35062
37199
  });
@@ -35082,6 +37219,7 @@ var inlineMessageActions = {
35082
37219
  ...sendTarget,
35083
37220
  ...index === 0 && text ? { text } : {},
35084
37221
  media,
37222
+ ...index === 0 && actions !== undefined ? { actions } : {},
35085
37223
  ...index === 0 && replyToMsgId != null ? { replyToMsgId } : {},
35086
37224
  ...index === 0 && text ? { parseMarkdown } : {}
35087
37225
  });
@@ -35102,6 +37240,7 @@ var inlineMessageActions = {
35102
37240
  cfg,
35103
37241
  accountId,
35104
37242
  fn: async (client) => {
37243
+ const actions = resolveInlineMessageActionsParam(params);
35105
37244
  const replyParams = normalizedAction === "thread-reply" && params.threadId != null && params.to == null && params.chatId == null && params.channelId == null ? { ...params, to: params.threadId } : params;
35106
37245
  const chatId = resolveChatIdFromParams(replyParams);
35107
37246
  const replyToMsgId = parseInlineId(readFlexibleId(replyParams, "messageId") ?? readFlexibleId(replyParams, "replyTo") ?? readFlexibleId(replyParams, "replyToId") ?? readStringParam(replyParams, "messageId") ?? readStringParam(replyParams, "replyTo") ?? readStringParam(replyParams, "replyToId", { required: true }), "messageId");
@@ -35109,6 +37248,7 @@ var inlineMessageActions = {
35109
37248
  const sent = await client.sendMessage({
35110
37249
  chatId,
35111
37250
  text,
37251
+ ...actions !== undefined ? { actions } : {},
35112
37252
  replyToMsgId,
35113
37253
  parseMarkdown
35114
37254
  });
@@ -35254,6 +37394,7 @@ var inlineMessageActions = {
35254
37394
  accountId,
35255
37395
  fn: async (client) => {
35256
37396
  const chatId = resolveChatIdFromParams(params);
37397
+ const actions = resolveInlineMessageActionsParam(params);
35257
37398
  const messageId = parseInlineId(readFlexibleId(params, "messageId") ?? readStringParam(params, "messageId", { required: true }), "messageId");
35258
37399
  const text = readStringParam(params, "message", { required: true, allowEmpty: true });
35259
37400
  const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
@@ -35262,6 +37403,7 @@ var inlineMessageActions = {
35262
37403
  messageId,
35263
37404
  peerId: buildChatPeer2(chatId),
35264
37405
  text,
37406
+ ...actions !== undefined ? { actions } : {},
35265
37407
  parseMarkdown
35266
37408
  }
35267
37409
  });
@@ -36178,7 +38320,7 @@ var inlineChannelPlugin = {
36178
38320
  reply: true,
36179
38321
  groupManagement: true,
36180
38322
  threads: false,
36181
- nativeCommands: false,
38323
+ nativeCommands: true,
36182
38324
  blockStreaming: true
36183
38325
  },
36184
38326
  streaming: {
@@ -36211,7 +38353,7 @@ var inlineChannelPlugin = {
36211
38353
  },
36212
38354
  security: {
36213
38355
  resolveDmPolicy: ({ cfg, accountId, account }) => {
36214
- const resolvedAccountId = accountId ?? account.accountId ?? DEFAULT_ACCOUNT_ID2;
38356
+ const resolvedAccountId = accountId ?? account.accountId ?? DEFAULT_ACCOUNT_ID;
36215
38357
  const useAccountPath = Boolean(cfg.channels?.inline?.accounts?.[resolvedAccountId]);
36216
38358
  const basePath = useAccountPath ? `channels.inline.accounts.${resolvedAccountId}.` : "channels.inline.";
36217
38359
  return {
@@ -36476,7 +38618,7 @@ var inlineChannelPlugin = {
36476
38618
  },
36477
38619
  status: {
36478
38620
  defaultRuntime: {
36479
- accountId: DEFAULT_ACCOUNT_ID2,
38621
+ accountId: DEFAULT_ACCOUNT_ID,
36480
38622
  running: false,
36481
38623
  lastStartAt: null,
36482
38624
  lastStopAt: null,
@@ -36561,9 +38703,6 @@ var inlineChannelPlugin = {
36561
38703
  };
36562
38704
 
36563
38705
  // src/inline/message-tools.ts
36564
- import {
36565
- jsonResult as jsonResult2
36566
- } from "openclaw/plugin-sdk";
36567
38706
  var InlineNudgeToolParameters = {
36568
38707
  type: "object",
36569
38708
  additionalProperties: false,
@@ -36875,7 +39014,7 @@ function createInlineNudgeTool(ctx) {
36875
39014
  }
36876
39015
  });
36877
39016
  const messageId = result.oneofKind === "sendMessage" ? extractFirstMessageId2(result.sendMessage.updates) : null;
36878
- return jsonResult2({
39017
+ return jsonResult({
36879
39018
  ok: true,
36880
39019
  accountId: resolvedAccountId,
36881
39020
  nudged: true,
@@ -36929,7 +39068,7 @@ function createInlineForwardTool(ctx) {
36929
39068
  }
36930
39069
  });
36931
39070
  const forwardedMessageId = result.oneofKind === "forwardMessages" ? extractFirstMessageId2(result.forwardMessages.updates) : null;
36932
- return jsonResult2({
39071
+ return jsonResult({
36933
39072
  ok: true,
36934
39073
  accountId: resolvedAccountId,
36935
39074
  from: source.normalized,
@@ -37015,7 +39154,7 @@ function filterSpaceMembers(params) {
37015
39154
  target: `user:${member.userId}`
37016
39155
  }));
37017
39156
  }
37018
- function jsonResult3(payload) {
39157
+ function jsonResult2(payload) {
37019
39158
  return {
37020
39159
  content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
37021
39160
  details: payload
@@ -37066,7 +39205,7 @@ function createInlineMembersTool(ctx) {
37066
39205
  userId,
37067
39206
  limit
37068
39207
  });
37069
- return jsonResult3({
39208
+ return jsonResult2({
37070
39209
  ok: true,
37071
39210
  accountId: resolvedAccountId,
37072
39211
  spaceId: String(spaceId),
@@ -37082,10 +39221,6 @@ function createInlineMembersTool(ctx) {
37082
39221
  }
37083
39222
 
37084
39223
  // src/inline/profile-tool.ts
37085
- import {
37086
- detectMime as detectMime2,
37087
- loadWebMedia as loadWebMedia2
37088
- } from "openclaw/plugin-sdk";
37089
39224
  var InlineProfileToolParameters = {
37090
39225
  type: "object",
37091
39226
  additionalProperties: false,
@@ -37112,7 +39247,7 @@ var InlineProfileToolParameters = {
37112
39247
  }
37113
39248
  }
37114
39249
  };
37115
- function jsonResult4(payload) {
39250
+ function jsonResult3(payload) {
37116
39251
  return {
37117
39252
  content: [
37118
39253
  {
@@ -37149,9 +39284,24 @@ function readTrimmedString(value) {
37149
39284
  function resolvePhotoSource(args) {
37150
39285
  return readTrimmedString(args.photoPath) ?? readTrimmedString(args.photoUrl);
37151
39286
  }
39287
+ function looksLikeLocalMediaSource2(mediaUrl) {
39288
+ return !/^https?:\/\//i.test(mediaUrl.trim());
39289
+ }
37152
39290
  async function uploadProfilePhoto(client, rawSource) {
37153
- const loaded = await loadWebMedia2(rawSource);
37154
- const contentType = loaded.contentType ?? await detectMime2({
39291
+ const runtimeMedia = getInlineRuntime().media;
39292
+ const loadWebMediaCompat = runtimeMedia.loadWebMedia;
39293
+ let loaded;
39294
+ try {
39295
+ loaded = await runtimeMedia.loadWebMedia(rawSource);
39296
+ } catch (error48) {
39297
+ const message = String(error48);
39298
+ const deniedLocalPath = /not under an allowed directory/i.test(message);
39299
+ if (!deniedLocalPath || !looksLikeLocalMediaSource2(rawSource)) {
39300
+ throw error48;
39301
+ }
39302
+ loaded = await loadWebMediaCompat(rawSource, undefined, { localRoots: "any" });
39303
+ }
39304
+ const contentType = loaded.contentType ?? await runtimeMedia.detectMime({
37155
39305
  buffer: loaded.buffer,
37156
39306
  ...loaded.fileName ? { filePath: loaded.fileName } : {}
37157
39307
  }) ?? undefined;
@@ -37201,7 +39351,7 @@ function createInlineProfileTool(ctx) {
37201
39351
  if (result.oneofKind !== "updateBotProfile") {
37202
39352
  throw new Error(`inline_update_profile: expected updateBotProfile result, got ${String(result.oneofKind)}`);
37203
39353
  }
37204
- return jsonResult4({
39354
+ return jsonResult3({
37205
39355
  ok: true,
37206
39356
  accountId: resolvedAccountId,
37207
39357
  botUserId: String(me.userId),
@@ -37217,6 +39367,364 @@ function createInlineProfileTool(ctx) {
37217
39367
  };
37218
39368
  }
37219
39369
 
39370
+ // src/inline/bot-commands-api.ts
39371
+ function normalizeInlineBotBaseUrl(baseUrl) {
39372
+ return baseUrl.replace(/\/+$/, "");
39373
+ }
39374
+ function normalizeInlineBotCommandName(raw) {
39375
+ return raw.trim().replace(/^\/+/, "");
39376
+ }
39377
+ async function callInlineBotApi(params) {
39378
+ const baseUrl = normalizeInlineBotBaseUrl(params.baseUrl);
39379
+ const invoke = async (authMode) => {
39380
+ const url2 = authMode === "header" ? `${baseUrl}/bot/${params.methodName}` : `${baseUrl}/bot${encodeURIComponent(params.token)}/${params.methodName}`;
39381
+ const request = {
39382
+ method: params.method,
39383
+ headers: {
39384
+ ...authMode === "header" ? { authorization: `Bearer ${params.token}` } : {},
39385
+ ...params.body !== undefined ? { "content-type": "application/json" } : {}
39386
+ }
39387
+ };
39388
+ if (params.body !== undefined) {
39389
+ request.body = JSON.stringify(params.body);
39390
+ }
39391
+ const response = await fetch(url2, request);
39392
+ const payload = await response.json().catch(() => null);
39393
+ return { response, payload };
39394
+ };
39395
+ const resolve = (result) => {
39396
+ if (!result.response.ok) {
39397
+ const message = result.payload?.description ?? `HTTP ${result.response.status}`;
39398
+ throw new Error(`inline_bot_commands: ${message}`);
39399
+ }
39400
+ if (!result.payload || result.payload.ok !== true) {
39401
+ const message = result.payload?.description ?? "bot api call failed";
39402
+ throw new Error(`inline_bot_commands: ${message}`);
39403
+ }
39404
+ return result.payload.result ?? {};
39405
+ };
39406
+ const shouldRetryWithPathToken = (result) => {
39407
+ if (result.response.status === 401)
39408
+ return true;
39409
+ if (result.payload?.error_code === 401)
39410
+ return true;
39411
+ const description = result.payload?.description?.toLowerCase() ?? "";
39412
+ return description.includes("unauthorized");
39413
+ };
39414
+ const headerResult = await invoke("header");
39415
+ if (shouldRetryWithPathToken(headerResult)) {
39416
+ const pathResult = await invoke("path");
39417
+ return resolve(pathResult);
39418
+ }
39419
+ return resolve(headerResult);
39420
+ }
39421
+
39422
+ // src/inline/bot-commands-tool.ts
39423
+ var BOT_COMMAND_LIMIT = 100;
39424
+ var BOT_COMMAND_RE = /^[a-z0-9_]+$/;
39425
+ var InlineBotCommandsToolParameters = {
39426
+ type: "object",
39427
+ additionalProperties: false,
39428
+ properties: {
39429
+ action: {
39430
+ type: "string",
39431
+ enum: ["get", "set", "delete"],
39432
+ description: "Command operation to run (`get`, `set`, or `delete`)."
39433
+ },
39434
+ commands: {
39435
+ type: "array",
39436
+ description: "Required for `set`. Telegram-style command list to register.",
39437
+ items: {
39438
+ type: "object",
39439
+ additionalProperties: false,
39440
+ properties: {
39441
+ command: {
39442
+ type: "string",
39443
+ description: "Slash command name without leading slash (`a-z`, `0-9`, `_`, max 32)."
39444
+ },
39445
+ description: {
39446
+ type: "string",
39447
+ description: "Human-friendly command description (max 256)."
39448
+ },
39449
+ sort_order: {
39450
+ type: "number",
39451
+ description: "Optional command ordering hint."
39452
+ }
39453
+ },
39454
+ required: ["command", "description"]
39455
+ }
39456
+ },
39457
+ accountId: {
39458
+ type: "string",
39459
+ description: "Optional Inline account id override."
39460
+ }
39461
+ },
39462
+ required: ["action"]
39463
+ };
39464
+ function parseSortOrder(raw, fallback) {
39465
+ if (typeof raw === "number" && Number.isFinite(raw)) {
39466
+ return Math.trunc(raw);
39467
+ }
39468
+ return fallback;
39469
+ }
39470
+ function normalizeCommands(raw) {
39471
+ if (!Array.isArray(raw)) {
39472
+ throw new Error("inline_bot_commands: `commands` must be an array");
39473
+ }
39474
+ if (raw.length > BOT_COMMAND_LIMIT) {
39475
+ throw new Error(`inline_bot_commands: too many commands (${raw.length}); max is ${BOT_COMMAND_LIMIT}`);
39476
+ }
39477
+ const seen = new Set;
39478
+ return raw.map((entry, index) => {
39479
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
39480
+ throw new Error(`inline_bot_commands: commands[${index}] must be an object`);
39481
+ }
39482
+ const row = entry;
39483
+ const rawCommand = row.command;
39484
+ const rawDescription = row.description;
39485
+ const rawSortOrder = row.sort_order ?? row.sortOrder;
39486
+ if (typeof rawCommand !== "string" || typeof rawDescription !== "string") {
39487
+ throw new Error(`inline_bot_commands: commands[${index}] requires string command and description`);
39488
+ }
39489
+ const command = normalizeInlineBotCommandName(rawCommand);
39490
+ const description = rawDescription.trim();
39491
+ if (command.length < 1 || command.length > 32 || !BOT_COMMAND_RE.test(command)) {
39492
+ throw new Error(`inline_bot_commands: commands[${index}].command must match /^[a-z0-9_]+$/ and be <= 32 chars`);
39493
+ }
39494
+ if (description.length < 1 || description.length > 256) {
39495
+ throw new Error(`inline_bot_commands: commands[${index}].description must be 1..256 chars`);
39496
+ }
39497
+ if (seen.has(command)) {
39498
+ throw new Error(`inline_bot_commands: duplicate command "${command}"`);
39499
+ }
39500
+ seen.add(command);
39501
+ const sortOrder = parseSortOrder(rawSortOrder, index);
39502
+ return {
39503
+ command,
39504
+ description,
39505
+ ...sortOrder !== index ? { sort_order: sortOrder } : {}
39506
+ };
39507
+ });
39508
+ }
39509
+ function createInlineBotCommandsTool(ctx) {
39510
+ if (!ctx.config) {
39511
+ return null;
39512
+ }
39513
+ return {
39514
+ name: "inline_bot_commands",
39515
+ label: "Inline Bot Commands",
39516
+ description: "Manage Inline bot slash commands via Bot API (`getMyCommands`, `setMyCommands`, `deleteMyCommands`).",
39517
+ parameters: InlineBotCommandsToolParameters,
39518
+ execute: async (_toolCallId, rawArgs) => {
39519
+ const args = rawArgs ?? {};
39520
+ const action = args.action;
39521
+ if (!action) {
39522
+ throw new Error("inline_bot_commands: `action` is required");
39523
+ }
39524
+ const account = resolveInlineAccount({
39525
+ cfg: ctx.config,
39526
+ accountId: args.accountId ?? ctx.agentAccountId ?? null
39527
+ });
39528
+ if (!account.configured || !account.baseUrl) {
39529
+ throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
39530
+ }
39531
+ const token = await resolveInlineToken(account);
39532
+ if (action === "get") {
39533
+ const result = await callInlineBotApi({
39534
+ baseUrl: account.baseUrl,
39535
+ token,
39536
+ methodName: "getMyCommands",
39537
+ method: "GET"
39538
+ });
39539
+ const commands = Array.isArray(result.commands) ? result.commands : [];
39540
+ return jsonResult({
39541
+ ok: true,
39542
+ action,
39543
+ accountId: account.accountId,
39544
+ count: commands.length,
39545
+ commands
39546
+ });
39547
+ }
39548
+ if (action === "set") {
39549
+ const commands = normalizeCommands(args.commands);
39550
+ await callInlineBotApi({
39551
+ baseUrl: account.baseUrl,
39552
+ token,
39553
+ methodName: "setMyCommands",
39554
+ method: "POST",
39555
+ body: { commands }
39556
+ });
39557
+ return jsonResult({
39558
+ ok: true,
39559
+ action,
39560
+ accountId: account.accountId,
39561
+ count: commands.length,
39562
+ commands
39563
+ });
39564
+ }
39565
+ await callInlineBotApi({
39566
+ baseUrl: account.baseUrl,
39567
+ token,
39568
+ methodName: "deleteMyCommands",
39569
+ method: "POST"
39570
+ });
39571
+ return jsonResult({
39572
+ ok: true,
39573
+ action,
39574
+ accountId: account.accountId
39575
+ });
39576
+ }
39577
+ };
39578
+ }
39579
+
39580
+ // src/inline/bot-commands-sync.ts
39581
+ var INLINE_BASE_NATIVE_COMMANDS = [
39582
+ { command: "help", description: "Show available commands." },
39583
+ { command: "commands", description: "List all slash commands." },
39584
+ { command: "skill", description: "Run a skill by name." },
39585
+ { command: "status", description: "Show current status." },
39586
+ { command: "approve", description: "Approve or deny exec requests." },
39587
+ { command: "context", description: "Explain how context is built and used." },
39588
+ { command: "tts", description: "Control text-to-speech (TTS)." },
39589
+ { command: "whoami", description: "Show your sender id." },
39590
+ { command: "subagents", description: "List/stop/log/info subagent runs for this session." },
39591
+ { command: "usage", description: "Usage footer or cost summary." },
39592
+ { command: "stop", description: "Stop the current run." },
39593
+ { command: "restart", description: "Restart OpenClaw." },
39594
+ { command: "activation", description: "Set group activation mode." },
39595
+ { command: "send", description: "Set send policy." },
39596
+ { command: "reset", description: "Reset the current session." },
39597
+ { command: "new", description: "Start a new session." },
39598
+ { command: "compact", description: "Compact the session context." },
39599
+ { command: "think", description: "Set thinking level." },
39600
+ { command: "verbose", description: "Toggle verbose mode." },
39601
+ { command: "reasoning", description: "Toggle reasoning visibility." },
39602
+ { command: "elevated", description: "Toggle elevated mode." },
39603
+ { command: "exec", description: "Set exec defaults for this session." },
39604
+ { command: "model", description: "Show or set the model." },
39605
+ { command: "models", description: "List model providers or provider models." },
39606
+ { command: "queue", description: "Adjust queue settings." }
39607
+ ];
39608
+ var INLINE_COMMAND_NAME_RE = /^[a-z0-9_]{1,32}$/;
39609
+ var INLINE_COMMAND_LIMIT = 100;
39610
+ var FALLBACK_NATIVE_COMMAND_HELPERS = {
39611
+ available: false,
39612
+ listNativeCommandSpecsForConfig: () => [],
39613
+ listSkillCommandsForAgents: () => []
39614
+ };
39615
+ var FALLBACK_PLUGIN_COMMAND_SPECS = {
39616
+ available: false,
39617
+ specs: []
39618
+ };
39619
+ function normalizeDynamicCommandName(raw) {
39620
+ const trimmed = raw.trim().toLowerCase();
39621
+ const withoutSlash = trimmed.startsWith("/") ? trimmed.slice(1) : trimmed;
39622
+ return withoutSlash.trim();
39623
+ }
39624
+ function appendUniqueCommand(out, seen, command, description) {
39625
+ const normalized = normalizeDynamicCommandName(command);
39626
+ if (!INLINE_COMMAND_NAME_RE.test(normalized) || seen.has(normalized))
39627
+ return;
39628
+ const trimmedDescription = description.trim();
39629
+ if (!trimmedDescription)
39630
+ return;
39631
+ seen.add(normalized);
39632
+ out.push({ command: normalized, description: trimmedDescription });
39633
+ }
39634
+ function shouldSyncInlineNativeCommands(cfg) {
39635
+ const inlineNativeSetting = cfg.channels?.inline?.commands?.native;
39636
+ const effective = inlineNativeSetting ?? cfg.commands?.native ?? "auto";
39637
+ return effective !== false;
39638
+ }
39639
+ function shouldSyncInlineNativeSkills(cfg) {
39640
+ const inlineNativeSkillsSetting = cfg.channels?.inline?.commands?.nativeSkills;
39641
+ const effective = inlineNativeSkillsSetting ?? cfg.commands?.nativeSkills ?? "auto";
39642
+ return effective !== false;
39643
+ }
39644
+ async function buildInlineNativeCommandsForConfig(params) {
39645
+ const commands = [...INLINE_BASE_NATIVE_COMMANDS];
39646
+ if (params.cfg.commands?.config === true) {
39647
+ commands.push({ command: "config", description: "Show or set config values." });
39648
+ }
39649
+ if (params.cfg.commands?.debug === true) {
39650
+ commands.push({ command: "debug", description: "Set runtime debug overrides." });
39651
+ }
39652
+ const { listNativeCommandSpecsForConfig, listSkillCommandsForAgents } = params.nativeHelpers;
39653
+ const skillCommands = shouldSyncInlineNativeSkills(params.cfg) ? listSkillCommandsForAgents({ cfg: params.cfg }) : [];
39654
+ const nativeSpecs = listNativeCommandSpecsForConfig(params.cfg, { skillCommands });
39655
+ const { specs: pluginSpecs } = params.pluginSpecs;
39656
+ const seen = new Set;
39657
+ const resolved = [];
39658
+ for (const base of commands) {
39659
+ appendUniqueCommand(resolved, seen, base.command, base.description);
39660
+ }
39661
+ for (const spec of nativeSpecs) {
39662
+ appendUniqueCommand(resolved, seen, spec.name, spec.description);
39663
+ }
39664
+ for (const spec of pluginSpecs) {
39665
+ appendUniqueCommand(resolved, seen, spec.name, spec.description);
39666
+ }
39667
+ return resolved;
39668
+ }
39669
+ async function syncInlineNativeCommands(params) {
39670
+ const accountIds = listInlineAccountIds(params.cfg);
39671
+ const nativeEnabled = shouldSyncInlineNativeCommands(params.cfg);
39672
+ const nativeHelpers = nativeEnabled ? await loadNativeCommandHelpersCompat() : FALLBACK_NATIVE_COMMAND_HELPERS;
39673
+ const pluginSpecs = nativeEnabled ? await loadPluginCommandSpecsCompat("inline") : FALLBACK_PLUGIN_COMMAND_SPECS;
39674
+ const usingSdkSource = nativeHelpers.available || pluginSpecs.available;
39675
+ const allCommands = nativeEnabled ? await buildInlineNativeCommandsForConfig({
39676
+ cfg: params.cfg,
39677
+ nativeHelpers,
39678
+ pluginSpecs
39679
+ }) : [];
39680
+ const commands = allCommands.slice(0, INLINE_COMMAND_LIMIT);
39681
+ if (allCommands.length > INLINE_COMMAND_LIMIT) {
39682
+ params.logger?.warn?.(`[inline] native command sync truncating ${allCommands.length} commands to ${INLINE_COMMAND_LIMIT}`);
39683
+ }
39684
+ params.logger?.info?.(`[inline] native command source: ${usingSdkSource ? "plugin-sdk" : "fallback"}`);
39685
+ let synced = 0;
39686
+ let failed = 0;
39687
+ for (const accountId of accountIds) {
39688
+ const account = resolveInlineAccount({ cfg: params.cfg, accountId });
39689
+ if (!account.enabled || !account.configured || !account.baseUrl) {
39690
+ continue;
39691
+ }
39692
+ let token;
39693
+ try {
39694
+ token = await resolveInlineToken(account);
39695
+ } catch (err) {
39696
+ failed += 1;
39697
+ params.logger?.warn?.(`[inline] native command sync skipped for account "${account.accountId}": ${String(err)}`);
39698
+ continue;
39699
+ }
39700
+ try {
39701
+ await callInlineBotApi({
39702
+ baseUrl: account.baseUrl,
39703
+ token,
39704
+ methodName: "deleteMyCommands",
39705
+ method: "POST"
39706
+ });
39707
+ await callInlineBotApi({
39708
+ baseUrl: account.baseUrl,
39709
+ token,
39710
+ methodName: "setMyCommands",
39711
+ method: "POST",
39712
+ body: { commands }
39713
+ });
39714
+ synced += 1;
39715
+ params.logger?.info?.(`[inline] native commands synced for account "${account.accountId}" (${commands.length} command${commands.length === 1 ? "" : "s"})`);
39716
+ } catch (err) {
39717
+ failed += 1;
39718
+ params.logger?.warn?.(`[inline] native command sync failed for account "${account.accountId}": ${String(err)}`);
39719
+ }
39720
+ }
39721
+ return {
39722
+ attempted: accountIds.length,
39723
+ synced,
39724
+ failed
39725
+ };
39726
+ }
39727
+
37220
39728
  // src/index.ts
37221
39729
  var plugin = {
37222
39730
  id: "inline",
@@ -37232,9 +39740,26 @@ var plugin = {
37232
39740
  api2.registerTool((ctx) => createInlineProfileTool(ctx), {
37233
39741
  names: ["inline_update_profile"]
37234
39742
  });
39743
+ api2.registerTool((ctx) => createInlineBotCommandsTool(ctx), {
39744
+ names: ["inline_bot_commands"]
39745
+ });
37235
39746
  api2.registerTool((ctx) => createInlineMessageTools(ctx), {
37236
39747
  names: ["inline_nudge", "inline_forward"]
37237
39748
  });
39749
+ api2.on("message_sending", (event, ctx) => {
39750
+ if (ctx.channelId !== "inline")
39751
+ return;
39752
+ const content = sanitizeInlineOutgoingText(event.content);
39753
+ if (content === event.content)
39754
+ return;
39755
+ return { content };
39756
+ });
39757
+ api2.on("gateway_start", async () => {
39758
+ await syncInlineNativeCommands({
39759
+ cfg: api2.config,
39760
+ logger: api2.logger
39761
+ });
39762
+ });
37238
39763
  }
37239
39764
  };
37240
39765
  var src_default = plugin;
@@ -37242,5 +39767,5 @@ export {
37242
39767
  src_default as default
37243
39768
  };
37244
39769
 
37245
- //# debugId=442A6C0FCB2305FD64756E2164756E21
39770
+ //# debugId=7535F56BE481336764756E2164756E21
37246
39771
  //# sourceMappingURL=index.js.map