@inline-openclaw/inline 0.0.19 → 0.0.21

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 (45) hide show
  1. package/README.md +15 -0
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +2335 -181
  5. package/dist/index.js.map +20 -14
  6. package/dist/inline/accounts.d.ts +20 -0
  7. package/dist/inline/accounts.d.ts.map +1 -0
  8. package/dist/inline/actions.d.ts +4 -0
  9. package/dist/inline/actions.d.ts.map +1 -0
  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 +4 -0
  17. package/dist/inline/channel.d.ts.map +1 -0
  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 +495 -0
  21. package/dist/inline/config-schema.d.ts.map +1 -0
  22. package/dist/inline/media.d.ts +9 -0
  23. package/dist/inline/media.d.ts.map +1 -0
  24. package/dist/inline/members-tool.d.ts +6 -0
  25. package/dist/inline/members-tool.d.ts.map +1 -0
  26. package/dist/inline/message-content.d.ts +51 -0
  27. package/dist/inline/message-content.d.ts.map +1 -0
  28. package/dist/inline/message-formatting.d.ts +4 -0
  29. package/dist/inline/message-formatting.d.ts.map +1 -0
  30. package/dist/inline/message-tools.d.ts +10 -0
  31. package/dist/inline/message-tools.d.ts.map +1 -0
  32. package/dist/inline/monitor.d.ts +26 -0
  33. package/dist/inline/monitor.d.ts.map +1 -0
  34. package/dist/inline/normalize.d.ts +3 -0
  35. package/dist/inline/normalize.d.ts.map +1 -0
  36. package/dist/inline/policy.d.ts +19 -0
  37. package/dist/inline/policy.d.ts.map +1 -0
  38. package/dist/inline/profile-tool.d.ts +6 -0
  39. package/dist/inline/profile-tool.d.ts.map +1 -0
  40. package/dist/inline/space-members.d.ts +22 -0
  41. package/dist/inline/space-members.d.ts.map +1 -0
  42. package/dist/runtime.d.ts +4 -0
  43. package/dist/runtime.d.ts.map +1 -0
  44. package/dist/tsconfig.tsbuildinfo +1 -0
  45. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -5711,6 +5711,9 @@ var Method;
5711
5711
  Method2[Method2["SET_BOT_COMMANDS"] = 44] = "SET_BOT_COMMANDS";
5712
5712
  Method2[Method2["GET_PEER_BOT_COMMANDS"] = 45] = "GET_PEER_BOT_COMMANDS";
5713
5713
  Method2[Method2["SHOW_CHAT_IN_SIDEBAR"] = 46] = "SHOW_CHAT_IN_SIDEBAR";
5714
+ Method2[Method2["RESERVE_CHAT_IDS"] = 47] = "RESERVE_CHAT_IDS";
5715
+ Method2[Method2["INVOKE_MESSAGE_ACTION"] = 48] = "INVOKE_MESSAGE_ACTION";
5716
+ Method2[Method2["ANSWER_MESSAGE_ACTION"] = 49] = "ANSWER_MESSAGE_ACTION";
5714
5717
  })(Method || (Method = {}));
5715
5718
  var PushNotificationProvider;
5716
5719
  (function(PushNotificationProvider2) {
@@ -7013,6 +7016,336 @@ class MessageReplies$Type extends import_runtime4.MessageType {
7013
7016
  }
7014
7017
  var MessageReplies = new MessageReplies$Type;
7015
7018
 
7019
+ class MessageActions$Type extends import_runtime4.MessageType {
7020
+ constructor() {
7021
+ super("MessageActions", [
7022
+ { no: 1, name: "rows", kind: "message", repeat: 1, T: () => MessageActionRow }
7023
+ ]);
7024
+ }
7025
+ create(value) {
7026
+ const message = globalThis.Object.create(this.messagePrototype);
7027
+ message.rows = [];
7028
+ if (value !== undefined)
7029
+ import_runtime3.reflectionMergePartial(this, message, value);
7030
+ return message;
7031
+ }
7032
+ internalBinaryRead(reader, length, options, target) {
7033
+ let message = target ?? this.create(), end = reader.pos + length;
7034
+ while (reader.pos < end) {
7035
+ let [fieldNo, wireType] = reader.tag();
7036
+ switch (fieldNo) {
7037
+ case 1:
7038
+ message.rows.push(MessageActionRow.internalBinaryRead(reader, reader.uint32(), options));
7039
+ break;
7040
+ default:
7041
+ let u = options.readUnknownField;
7042
+ if (u === "throw")
7043
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7044
+ let d = reader.skip(wireType);
7045
+ if (u !== false)
7046
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7047
+ }
7048
+ }
7049
+ return message;
7050
+ }
7051
+ internalBinaryWrite(message, writer, options) {
7052
+ for (let i = 0;i < message.rows.length; i++)
7053
+ MessageActionRow.internalBinaryWrite(message.rows[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7054
+ let u = options.writeUnknownFields;
7055
+ if (u !== false)
7056
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7057
+ return writer;
7058
+ }
7059
+ }
7060
+ var MessageActions = new MessageActions$Type;
7061
+
7062
+ class MessageActionRow$Type extends import_runtime4.MessageType {
7063
+ constructor() {
7064
+ super("MessageActionRow", [
7065
+ { no: 1, name: "actions", kind: "message", repeat: 1, T: () => MessageAction }
7066
+ ]);
7067
+ }
7068
+ create(value) {
7069
+ const message = globalThis.Object.create(this.messagePrototype);
7070
+ message.actions = [];
7071
+ if (value !== undefined)
7072
+ import_runtime3.reflectionMergePartial(this, message, value);
7073
+ return message;
7074
+ }
7075
+ internalBinaryRead(reader, length, options, target) {
7076
+ let message = target ?? this.create(), end = reader.pos + length;
7077
+ while (reader.pos < end) {
7078
+ let [fieldNo, wireType] = reader.tag();
7079
+ switch (fieldNo) {
7080
+ case 1:
7081
+ message.actions.push(MessageAction.internalBinaryRead(reader, reader.uint32(), options));
7082
+ break;
7083
+ default:
7084
+ let u = options.readUnknownField;
7085
+ if (u === "throw")
7086
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7087
+ let d = reader.skip(wireType);
7088
+ if (u !== false)
7089
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7090
+ }
7091
+ }
7092
+ return message;
7093
+ }
7094
+ internalBinaryWrite(message, writer, options) {
7095
+ for (let i = 0;i < message.actions.length; i++)
7096
+ MessageAction.internalBinaryWrite(message.actions[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7097
+ let u = options.writeUnknownFields;
7098
+ if (u !== false)
7099
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7100
+ return writer;
7101
+ }
7102
+ }
7103
+ var MessageActionRow = new MessageActionRow$Type;
7104
+
7105
+ class MessageAction$Type extends import_runtime4.MessageType {
7106
+ constructor() {
7107
+ super("MessageAction", [
7108
+ { no: 1, name: "action_id", kind: "scalar", T: 9 },
7109
+ { no: 2, name: "text", kind: "scalar", T: 9 },
7110
+ { no: 3, name: "callback", kind: "message", oneof: "action", T: () => MessageActionCallback },
7111
+ { no: 4, name: "copy_text", kind: "message", oneof: "action", T: () => MessageActionCopyText }
7112
+ ]);
7113
+ }
7114
+ create(value) {
7115
+ const message = globalThis.Object.create(this.messagePrototype);
7116
+ message.actionId = "";
7117
+ message.text = "";
7118
+ message.action = { oneofKind: undefined };
7119
+ if (value !== undefined)
7120
+ import_runtime3.reflectionMergePartial(this, message, value);
7121
+ return message;
7122
+ }
7123
+ internalBinaryRead(reader, length, options, target) {
7124
+ let message = target ?? this.create(), end = reader.pos + length;
7125
+ while (reader.pos < end) {
7126
+ let [fieldNo, wireType] = reader.tag();
7127
+ switch (fieldNo) {
7128
+ case 1:
7129
+ message.actionId = reader.string();
7130
+ break;
7131
+ case 2:
7132
+ message.text = reader.string();
7133
+ break;
7134
+ case 3:
7135
+ message.action = {
7136
+ oneofKind: "callback",
7137
+ callback: MessageActionCallback.internalBinaryRead(reader, reader.uint32(), options, message.action.callback)
7138
+ };
7139
+ break;
7140
+ case 4:
7141
+ message.action = {
7142
+ oneofKind: "copyText",
7143
+ copyText: MessageActionCopyText.internalBinaryRead(reader, reader.uint32(), options, message.action.copyText)
7144
+ };
7145
+ break;
7146
+ default:
7147
+ let u = options.readUnknownField;
7148
+ if (u === "throw")
7149
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7150
+ let d = reader.skip(wireType);
7151
+ if (u !== false)
7152
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7153
+ }
7154
+ }
7155
+ return message;
7156
+ }
7157
+ internalBinaryWrite(message, writer, options) {
7158
+ if (message.actionId !== "")
7159
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.actionId);
7160
+ if (message.text !== "")
7161
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.text);
7162
+ if (message.action.oneofKind === "callback")
7163
+ MessageActionCallback.internalBinaryWrite(message.action.callback, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
7164
+ if (message.action.oneofKind === "copyText")
7165
+ MessageActionCopyText.internalBinaryWrite(message.action.copyText, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
7166
+ let u = options.writeUnknownFields;
7167
+ if (u !== false)
7168
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7169
+ return writer;
7170
+ }
7171
+ }
7172
+ var MessageAction = new MessageAction$Type;
7173
+
7174
+ class MessageActionCallback$Type extends import_runtime4.MessageType {
7175
+ constructor() {
7176
+ super("MessageActionCallback", [
7177
+ { no: 1, name: "data", kind: "scalar", T: 12 }
7178
+ ]);
7179
+ }
7180
+ create(value) {
7181
+ const message = globalThis.Object.create(this.messagePrototype);
7182
+ message.data = new Uint8Array(0);
7183
+ if (value !== undefined)
7184
+ import_runtime3.reflectionMergePartial(this, message, value);
7185
+ return message;
7186
+ }
7187
+ internalBinaryRead(reader, length, options, target) {
7188
+ let message = target ?? this.create(), end = reader.pos + length;
7189
+ while (reader.pos < end) {
7190
+ let [fieldNo, wireType] = reader.tag();
7191
+ switch (fieldNo) {
7192
+ case 1:
7193
+ message.data = reader.bytes();
7194
+ break;
7195
+ default:
7196
+ let u = options.readUnknownField;
7197
+ if (u === "throw")
7198
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7199
+ let d = reader.skip(wireType);
7200
+ if (u !== false)
7201
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7202
+ }
7203
+ }
7204
+ return message;
7205
+ }
7206
+ internalBinaryWrite(message, writer, options) {
7207
+ if (message.data.length)
7208
+ writer.tag(1, import_runtime.WireType.LengthDelimited).bytes(message.data);
7209
+ let u = options.writeUnknownFields;
7210
+ if (u !== false)
7211
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7212
+ return writer;
7213
+ }
7214
+ }
7215
+ var MessageActionCallback = new MessageActionCallback$Type;
7216
+
7217
+ class MessageActionCopyText$Type extends import_runtime4.MessageType {
7218
+ constructor() {
7219
+ super("MessageActionCopyText", [
7220
+ { no: 1, name: "text", kind: "scalar", T: 9 }
7221
+ ]);
7222
+ }
7223
+ create(value) {
7224
+ const message = globalThis.Object.create(this.messagePrototype);
7225
+ message.text = "";
7226
+ if (value !== undefined)
7227
+ import_runtime3.reflectionMergePartial(this, message, value);
7228
+ return message;
7229
+ }
7230
+ internalBinaryRead(reader, length, options, target) {
7231
+ let message = target ?? this.create(), end = reader.pos + length;
7232
+ while (reader.pos < end) {
7233
+ let [fieldNo, wireType] = reader.tag();
7234
+ switch (fieldNo) {
7235
+ case 1:
7236
+ message.text = reader.string();
7237
+ break;
7238
+ default:
7239
+ let u = options.readUnknownField;
7240
+ if (u === "throw")
7241
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7242
+ let d = reader.skip(wireType);
7243
+ if (u !== false)
7244
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7245
+ }
7246
+ }
7247
+ return message;
7248
+ }
7249
+ internalBinaryWrite(message, writer, options) {
7250
+ if (message.text !== "")
7251
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.text);
7252
+ let u = options.writeUnknownFields;
7253
+ if (u !== false)
7254
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7255
+ return writer;
7256
+ }
7257
+ }
7258
+ var MessageActionCopyText = new MessageActionCopyText$Type;
7259
+
7260
+ class MessageActionResponseUi$Type extends import_runtime4.MessageType {
7261
+ constructor() {
7262
+ super("MessageActionResponseUi", [
7263
+ { no: 1, name: "toast", kind: "message", oneof: "kind", T: () => MessageActionToast }
7264
+ ]);
7265
+ }
7266
+ create(value) {
7267
+ const message = globalThis.Object.create(this.messagePrototype);
7268
+ message.kind = { oneofKind: undefined };
7269
+ if (value !== undefined)
7270
+ import_runtime3.reflectionMergePartial(this, message, value);
7271
+ return message;
7272
+ }
7273
+ internalBinaryRead(reader, length, options, target) {
7274
+ let message = target ?? this.create(), end = reader.pos + length;
7275
+ while (reader.pos < end) {
7276
+ let [fieldNo, wireType] = reader.tag();
7277
+ switch (fieldNo) {
7278
+ case 1:
7279
+ message.kind = {
7280
+ oneofKind: "toast",
7281
+ toast: MessageActionToast.internalBinaryRead(reader, reader.uint32(), options, message.kind.toast)
7282
+ };
7283
+ break;
7284
+ default:
7285
+ let u = options.readUnknownField;
7286
+ if (u === "throw")
7287
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7288
+ let d = reader.skip(wireType);
7289
+ if (u !== false)
7290
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7291
+ }
7292
+ }
7293
+ return message;
7294
+ }
7295
+ internalBinaryWrite(message, writer, options) {
7296
+ if (message.kind.oneofKind === "toast")
7297
+ MessageActionToast.internalBinaryWrite(message.kind.toast, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
7298
+ let u = options.writeUnknownFields;
7299
+ if (u !== false)
7300
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7301
+ return writer;
7302
+ }
7303
+ }
7304
+ var MessageActionResponseUi = new MessageActionResponseUi$Type;
7305
+
7306
+ class MessageActionToast$Type extends import_runtime4.MessageType {
7307
+ constructor() {
7308
+ super("MessageActionToast", [
7309
+ { no: 1, name: "text", kind: "scalar", T: 9 }
7310
+ ]);
7311
+ }
7312
+ create(value) {
7313
+ const message = globalThis.Object.create(this.messagePrototype);
7314
+ message.text = "";
7315
+ if (value !== undefined)
7316
+ import_runtime3.reflectionMergePartial(this, message, value);
7317
+ return message;
7318
+ }
7319
+ internalBinaryRead(reader, length, options, target) {
7320
+ let message = target ?? this.create(), end = reader.pos + length;
7321
+ while (reader.pos < end) {
7322
+ let [fieldNo, wireType] = reader.tag();
7323
+ switch (fieldNo) {
7324
+ case 1:
7325
+ message.text = reader.string();
7326
+ break;
7327
+ default:
7328
+ let u = options.readUnknownField;
7329
+ if (u === "throw")
7330
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7331
+ let d = reader.skip(wireType);
7332
+ if (u !== false)
7333
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7334
+ }
7335
+ }
7336
+ return message;
7337
+ }
7338
+ internalBinaryWrite(message, writer, options) {
7339
+ if (message.text !== "")
7340
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.text);
7341
+ let u = options.writeUnknownFields;
7342
+ if (u !== false)
7343
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
7344
+ return writer;
7345
+ }
7346
+ }
7347
+ var MessageActionToast = new MessageActionToast$Type;
7348
+
7016
7349
  class Message$Type extends import_runtime4.MessageType {
7017
7350
  constructor() {
7018
7351
  super("Message", [
@@ -7035,7 +7368,8 @@ class Message$Type extends import_runtime4.MessageType {
7035
7368
  { no: 16, name: "entities", kind: "message", T: () => MessageEntities },
7036
7369
  { no: 17, name: "send_mode", kind: "enum", opt: true, T: () => ["MessageSendMode", MessageSendMode] },
7037
7370
  { no: 18, name: "fwd_from", kind: "message", T: () => MessageFwdHeader },
7038
- { no: 19, name: "replies", kind: "message", T: () => MessageReplies }
7371
+ { no: 19, name: "replies", kind: "message", T: () => MessageReplies },
7372
+ { no: 20, name: "actions", kind: "message", T: () => MessageActions }
7039
7373
  ]);
7040
7374
  }
7041
7375
  create(value) {
@@ -7114,6 +7448,9 @@ class Message$Type extends import_runtime4.MessageType {
7114
7448
  case 19:
7115
7449
  message.replies = MessageReplies.internalBinaryRead(reader, reader.uint32(), options, message.replies);
7116
7450
  break;
7451
+ case 20:
7452
+ message.actions = MessageActions.internalBinaryRead(reader, reader.uint32(), options, message.actions);
7453
+ break;
7117
7454
  default:
7118
7455
  let u = options.readUnknownField;
7119
7456
  if (u === "throw")
@@ -7166,6 +7503,8 @@ class Message$Type extends import_runtime4.MessageType {
7166
7503
  MessageFwdHeader.internalBinaryWrite(message.fwdFrom, writer.tag(18, import_runtime.WireType.LengthDelimited).fork(), options).join();
7167
7504
  if (message.replies)
7168
7505
  MessageReplies.internalBinaryWrite(message.replies, writer.tag(19, import_runtime.WireType.LengthDelimited).fork(), options).join();
7506
+ if (message.actions)
7507
+ MessageActions.internalBinaryWrite(message.actions, writer.tag(20, import_runtime.WireType.LengthDelimited).fork(), options).join();
7169
7508
  let u = options.writeUnknownFields;
7170
7509
  if (u !== false)
7171
7510
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -9011,7 +9350,10 @@ class RpcCall$Type extends import_runtime4.MessageType {
9011
9350
  { no: 44, name: "getBotCommands", kind: "message", oneof: "input", T: () => GetBotCommandsInput },
9012
9351
  { no: 45, name: "setBotCommands", kind: "message", oneof: "input", T: () => SetBotCommandsInput },
9013
9352
  { no: 46, name: "getPeerBotCommands", kind: "message", oneof: "input", T: () => GetPeerBotCommandsInput },
9014
- { no: 47, name: "showChatInSidebar", kind: "message", oneof: "input", T: () => ShowChatInSidebarInput }
9353
+ { no: 47, name: "showChatInSidebar", kind: "message", oneof: "input", T: () => ShowChatInSidebarInput },
9354
+ { no: 48, name: "reserveChatIds", kind: "message", oneof: "input", T: () => ReserveChatIdsInput },
9355
+ { no: 49, name: "invokeMessageAction", kind: "message", oneof: "input", T: () => InvokeMessageActionInput },
9356
+ { no: 50, name: "answerMessageAction", kind: "message", oneof: "input", T: () => AnswerMessageActionInput }
9015
9357
  ]);
9016
9358
  }
9017
9359
  create(value) {
@@ -9306,6 +9648,24 @@ class RpcCall$Type extends import_runtime4.MessageType {
9306
9648
  showChatInSidebar: ShowChatInSidebarInput.internalBinaryRead(reader, reader.uint32(), options, message.input.showChatInSidebar)
9307
9649
  };
9308
9650
  break;
9651
+ case 48:
9652
+ message.input = {
9653
+ oneofKind: "reserveChatIds",
9654
+ reserveChatIds: ReserveChatIdsInput.internalBinaryRead(reader, reader.uint32(), options, message.input.reserveChatIds)
9655
+ };
9656
+ break;
9657
+ case 49:
9658
+ message.input = {
9659
+ oneofKind: "invokeMessageAction",
9660
+ invokeMessageAction: InvokeMessageActionInput.internalBinaryRead(reader, reader.uint32(), options, message.input.invokeMessageAction)
9661
+ };
9662
+ break;
9663
+ case 50:
9664
+ message.input = {
9665
+ oneofKind: "answerMessageAction",
9666
+ answerMessageAction: AnswerMessageActionInput.internalBinaryRead(reader, reader.uint32(), options, message.input.answerMessageAction)
9667
+ };
9668
+ break;
9309
9669
  default:
9310
9670
  let u = options.readUnknownField;
9311
9671
  if (u === "throw")
@@ -9412,6 +9772,12 @@ class RpcCall$Type extends import_runtime4.MessageType {
9412
9772
  GetPeerBotCommandsInput.internalBinaryWrite(message.input.getPeerBotCommands, writer.tag(46, import_runtime.WireType.LengthDelimited).fork(), options).join();
9413
9773
  if (message.input.oneofKind === "showChatInSidebar")
9414
9774
  ShowChatInSidebarInput.internalBinaryWrite(message.input.showChatInSidebar, writer.tag(47, import_runtime.WireType.LengthDelimited).fork(), options).join();
9775
+ if (message.input.oneofKind === "reserveChatIds")
9776
+ ReserveChatIdsInput.internalBinaryWrite(message.input.reserveChatIds, writer.tag(48, import_runtime.WireType.LengthDelimited).fork(), options).join();
9777
+ if (message.input.oneofKind === "invokeMessageAction")
9778
+ InvokeMessageActionInput.internalBinaryWrite(message.input.invokeMessageAction, writer.tag(49, import_runtime.WireType.LengthDelimited).fork(), options).join();
9779
+ if (message.input.oneofKind === "answerMessageAction")
9780
+ AnswerMessageActionInput.internalBinaryWrite(message.input.answerMessageAction, writer.tag(50, import_runtime.WireType.LengthDelimited).fork(), options).join();
9415
9781
  let u = options.writeUnknownFields;
9416
9782
  if (u !== false)
9417
9783
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -9469,7 +9835,10 @@ class RpcResult$Type extends import_runtime4.MessageType {
9469
9835
  { no: 44, name: "getBotCommands", kind: "message", oneof: "result", T: () => GetBotCommandsResult },
9470
9836
  { no: 45, name: "setBotCommands", kind: "message", oneof: "result", T: () => SetBotCommandsResult },
9471
9837
  { no: 46, name: "getPeerBotCommands", kind: "message", oneof: "result", T: () => GetPeerBotCommandsResult },
9472
- { no: 47, name: "showChatInSidebar", kind: "message", oneof: "result", T: () => ShowChatInSidebarResult }
9838
+ { no: 47, name: "showChatInSidebar", kind: "message", oneof: "result", T: () => ShowChatInSidebarResult },
9839
+ { no: 48, name: "reserveChatIds", kind: "message", oneof: "result", T: () => ReserveChatIdsResult },
9840
+ { no: 49, name: "invokeMessageAction", kind: "message", oneof: "result", T: () => InvokeMessageActionResult },
9841
+ { no: 50, name: "answerMessageAction", kind: "message", oneof: "result", T: () => AnswerMessageActionResult }
9473
9842
  ]);
9474
9843
  }
9475
9844
  create(value) {
@@ -9764,6 +10133,24 @@ class RpcResult$Type extends import_runtime4.MessageType {
9764
10133
  showChatInSidebar: ShowChatInSidebarResult.internalBinaryRead(reader, reader.uint32(), options, message.result.showChatInSidebar)
9765
10134
  };
9766
10135
  break;
10136
+ case 48:
10137
+ message.result = {
10138
+ oneofKind: "reserveChatIds",
10139
+ reserveChatIds: ReserveChatIdsResult.internalBinaryRead(reader, reader.uint32(), options, message.result.reserveChatIds)
10140
+ };
10141
+ break;
10142
+ case 49:
10143
+ message.result = {
10144
+ oneofKind: "invokeMessageAction",
10145
+ invokeMessageAction: InvokeMessageActionResult.internalBinaryRead(reader, reader.uint32(), options, message.result.invokeMessageAction)
10146
+ };
10147
+ break;
10148
+ case 50:
10149
+ message.result = {
10150
+ oneofKind: "answerMessageAction",
10151
+ answerMessageAction: AnswerMessageActionResult.internalBinaryRead(reader, reader.uint32(), options, message.result.answerMessageAction)
10152
+ };
10153
+ break;
9767
10154
  default:
9768
10155
  let u = options.readUnknownField;
9769
10156
  if (u === "throw")
@@ -9870,6 +10257,12 @@ class RpcResult$Type extends import_runtime4.MessageType {
9870
10257
  GetPeerBotCommandsResult.internalBinaryWrite(message.result.getPeerBotCommands, writer.tag(46, import_runtime.WireType.LengthDelimited).fork(), options).join();
9871
10258
  if (message.result.oneofKind === "showChatInSidebar")
9872
10259
  ShowChatInSidebarResult.internalBinaryWrite(message.result.showChatInSidebar, writer.tag(47, import_runtime.WireType.LengthDelimited).fork(), options).join();
10260
+ if (message.result.oneofKind === "reserveChatIds")
10261
+ ReserveChatIdsResult.internalBinaryWrite(message.result.reserveChatIds, writer.tag(48, import_runtime.WireType.LengthDelimited).fork(), options).join();
10262
+ if (message.result.oneofKind === "invokeMessageAction")
10263
+ InvokeMessageActionResult.internalBinaryWrite(message.result.invokeMessageAction, writer.tag(49, import_runtime.WireType.LengthDelimited).fork(), options).join();
10264
+ if (message.result.oneofKind === "answerMessageAction")
10265
+ AnswerMessageActionResult.internalBinaryWrite(message.result.answerMessageAction, writer.tag(50, import_runtime.WireType.LengthDelimited).fork(), options).join();
9873
10266
  let u = options.writeUnknownFields;
9874
10267
  if (u !== false)
9875
10268
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -12930,7 +13323,8 @@ class EditMessageInput$Type extends import_runtime4.MessageType {
12930
13323
  { no: 2, name: "peer_id", kind: "message", T: () => InputPeer },
12931
13324
  { no: 3, name: "text", kind: "scalar", T: 9 },
12932
13325
  { no: 7, name: "entities", kind: "message", T: () => MessageEntities },
12933
- { no: 8, name: "parse_markdown", kind: "scalar", opt: true, T: 8 }
13326
+ { no: 8, name: "parse_markdown", kind: "scalar", opt: true, T: 8 },
13327
+ { no: 9, name: "actions", kind: "message", T: () => MessageActions }
12934
13328
  ]);
12935
13329
  }
12936
13330
  create(value) {
@@ -12961,6 +13355,9 @@ class EditMessageInput$Type extends import_runtime4.MessageType {
12961
13355
  case 8:
12962
13356
  message.parseMarkdown = reader.bool();
12963
13357
  break;
13358
+ case 9:
13359
+ message.actions = MessageActions.internalBinaryRead(reader, reader.uint32(), options, message.actions);
13360
+ break;
12964
13361
  default:
12965
13362
  let u = options.readUnknownField;
12966
13363
  if (u === "throw")
@@ -12983,6 +13380,8 @@ class EditMessageInput$Type extends import_runtime4.MessageType {
12983
13380
  MessageEntities.internalBinaryWrite(message.entities, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
12984
13381
  if (message.parseMarkdown !== undefined)
12985
13382
  writer.tag(8, import_runtime.WireType.Varint).bool(message.parseMarkdown);
13383
+ if (message.actions)
13384
+ MessageActions.internalBinaryWrite(message.actions, writer.tag(9, import_runtime.WireType.LengthDelimited).fork(), options).join();
12986
13385
  let u = options.writeUnknownFields;
12987
13386
  if (u !== false)
12988
13387
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -13323,7 +13722,8 @@ class SendMessageInput$Type extends import_runtime4.MessageType {
13323
13722
  { no: 6000, name: "has_link", kind: "scalar", opt: true, T: 8 },
13324
13723
  { no: 7, name: "entities", kind: "message", T: () => MessageEntities },
13325
13724
  { no: 8, name: "parse_markdown", kind: "scalar", opt: true, T: 8 },
13326
- { no: 9, name: "send_mode", kind: "enum", opt: true, T: () => ["MessageSendMode", MessageSendMode] }
13725
+ { no: 9, name: "send_mode", kind: "enum", opt: true, T: () => ["MessageSendMode", MessageSendMode] },
13726
+ { no: 10, name: "actions", kind: "message", T: () => MessageActions }
13327
13727
  ]);
13328
13728
  }
13329
13729
  create(value) {
@@ -13370,6 +13770,9 @@ class SendMessageInput$Type extends import_runtime4.MessageType {
13370
13770
  case 9:
13371
13771
  message.sendMode = reader.int32();
13372
13772
  break;
13773
+ case 10:
13774
+ message.actions = MessageActions.internalBinaryRead(reader, reader.uint32(), options, message.actions);
13775
+ break;
13373
13776
  default:
13374
13777
  let u = options.readUnknownField;
13375
13778
  if (u === "throw")
@@ -13404,23 +13807,168 @@ class SendMessageInput$Type extends import_runtime4.MessageType {
13404
13807
  writer.tag(8, import_runtime.WireType.Varint).bool(message.parseMarkdown);
13405
13808
  if (message.sendMode !== undefined)
13406
13809
  writer.tag(9, import_runtime.WireType.Varint).int32(message.sendMode);
13810
+ if (message.actions)
13811
+ MessageActions.internalBinaryWrite(message.actions, writer.tag(10, import_runtime.WireType.LengthDelimited).fork(), options).join();
13812
+ let u = options.writeUnknownFields;
13813
+ if (u !== false)
13814
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13815
+ return writer;
13816
+ }
13817
+ }
13818
+ var SendMessageInput = new SendMessageInput$Type;
13819
+
13820
+ class SendMessageResult$Type extends import_runtime4.MessageType {
13821
+ constructor() {
13822
+ super("SendMessageResult", [
13823
+ { no: 2, name: "updates", kind: "message", repeat: 1, T: () => Update }
13824
+ ]);
13825
+ }
13826
+ create(value) {
13827
+ const message = globalThis.Object.create(this.messagePrototype);
13828
+ message.updates = [];
13829
+ if (value !== undefined)
13830
+ import_runtime3.reflectionMergePartial(this, message, value);
13831
+ return message;
13832
+ }
13833
+ internalBinaryRead(reader, length, options, target) {
13834
+ let message = target ?? this.create(), end = reader.pos + length;
13835
+ while (reader.pos < end) {
13836
+ let [fieldNo, wireType] = reader.tag();
13837
+ switch (fieldNo) {
13838
+ case 2:
13839
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
13840
+ break;
13841
+ default:
13842
+ let u = options.readUnknownField;
13843
+ if (u === "throw")
13844
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13845
+ let d = reader.skip(wireType);
13846
+ if (u !== false)
13847
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13848
+ }
13849
+ }
13850
+ return message;
13851
+ }
13852
+ internalBinaryWrite(message, writer, options) {
13853
+ for (let i = 0;i < message.updates.length; i++)
13854
+ Update.internalBinaryWrite(message.updates[i], writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
13855
+ let u = options.writeUnknownFields;
13856
+ if (u !== false)
13857
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13858
+ return writer;
13859
+ }
13860
+ }
13861
+ var SendMessageResult = new SendMessageResult$Type;
13862
+
13863
+ class InvokeMessageActionInput$Type extends import_runtime4.MessageType {
13864
+ constructor() {
13865
+ super("InvokeMessageActionInput", [
13866
+ { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
13867
+ { no: 2, name: "message_id", kind: "scalar", T: 3, L: 0 },
13868
+ { no: 3, name: "action_id", kind: "scalar", T: 9 }
13869
+ ]);
13870
+ }
13871
+ create(value) {
13872
+ const message = globalThis.Object.create(this.messagePrototype);
13873
+ message.messageId = 0n;
13874
+ message.actionId = "";
13875
+ if (value !== undefined)
13876
+ import_runtime3.reflectionMergePartial(this, message, value);
13877
+ return message;
13878
+ }
13879
+ internalBinaryRead(reader, length, options, target) {
13880
+ let message = target ?? this.create(), end = reader.pos + length;
13881
+ while (reader.pos < end) {
13882
+ let [fieldNo, wireType] = reader.tag();
13883
+ switch (fieldNo) {
13884
+ case 1:
13885
+ message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
13886
+ break;
13887
+ case 2:
13888
+ message.messageId = reader.int64().toBigInt();
13889
+ break;
13890
+ case 3:
13891
+ message.actionId = reader.string();
13892
+ break;
13893
+ default:
13894
+ let u = options.readUnknownField;
13895
+ if (u === "throw")
13896
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13897
+ let d = reader.skip(wireType);
13898
+ if (u !== false)
13899
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13900
+ }
13901
+ }
13902
+ return message;
13903
+ }
13904
+ internalBinaryWrite(message, writer, options) {
13905
+ if (message.peerId)
13906
+ InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
13907
+ if (message.messageId !== 0n)
13908
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.messageId);
13909
+ if (message.actionId !== "")
13910
+ writer.tag(3, import_runtime.WireType.LengthDelimited).string(message.actionId);
13911
+ let u = options.writeUnknownFields;
13912
+ if (u !== false)
13913
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13914
+ return writer;
13915
+ }
13916
+ }
13917
+ var InvokeMessageActionInput = new InvokeMessageActionInput$Type;
13918
+
13919
+ class InvokeMessageActionResult$Type extends import_runtime4.MessageType {
13920
+ constructor() {
13921
+ super("InvokeMessageActionResult", [
13922
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 }
13923
+ ]);
13924
+ }
13925
+ create(value) {
13926
+ const message = globalThis.Object.create(this.messagePrototype);
13927
+ message.interactionId = 0n;
13928
+ if (value !== undefined)
13929
+ import_runtime3.reflectionMergePartial(this, message, value);
13930
+ return message;
13931
+ }
13932
+ internalBinaryRead(reader, length, options, target) {
13933
+ let message = target ?? this.create(), end = reader.pos + length;
13934
+ while (reader.pos < end) {
13935
+ let [fieldNo, wireType] = reader.tag();
13936
+ switch (fieldNo) {
13937
+ case 1:
13938
+ message.interactionId = reader.int64().toBigInt();
13939
+ break;
13940
+ default:
13941
+ let u = options.readUnknownField;
13942
+ if (u === "throw")
13943
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
13944
+ let d = reader.skip(wireType);
13945
+ if (u !== false)
13946
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
13947
+ }
13948
+ }
13949
+ return message;
13950
+ }
13951
+ internalBinaryWrite(message, writer, options) {
13952
+ if (message.interactionId !== 0n)
13953
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
13407
13954
  let u = options.writeUnknownFields;
13408
13955
  if (u !== false)
13409
13956
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13410
13957
  return writer;
13411
13958
  }
13412
13959
  }
13413
- var SendMessageInput = new SendMessageInput$Type;
13960
+ var InvokeMessageActionResult = new InvokeMessageActionResult$Type;
13414
13961
 
13415
- class SendMessageResult$Type extends import_runtime4.MessageType {
13962
+ class AnswerMessageActionInput$Type extends import_runtime4.MessageType {
13416
13963
  constructor() {
13417
- super("SendMessageResult", [
13418
- { no: 2, name: "updates", kind: "message", repeat: 1, T: () => Update }
13964
+ super("AnswerMessageActionInput", [
13965
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 },
13966
+ { no: 2, name: "ui", kind: "message", T: () => MessageActionResponseUi }
13419
13967
  ]);
13420
13968
  }
13421
13969
  create(value) {
13422
13970
  const message = globalThis.Object.create(this.messagePrototype);
13423
- message.updates = [];
13971
+ message.interactionId = 0n;
13424
13972
  if (value !== undefined)
13425
13973
  import_runtime3.reflectionMergePartial(this, message, value);
13426
13974
  return message;
@@ -13430,8 +13978,11 @@ class SendMessageResult$Type extends import_runtime4.MessageType {
13430
13978
  while (reader.pos < end) {
13431
13979
  let [fieldNo, wireType] = reader.tag();
13432
13980
  switch (fieldNo) {
13981
+ case 1:
13982
+ message.interactionId = reader.int64().toBigInt();
13983
+ break;
13433
13984
  case 2:
13434
- message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
13985
+ message.ui = MessageActionResponseUi.internalBinaryRead(reader, reader.uint32(), options, message.ui);
13435
13986
  break;
13436
13987
  default:
13437
13988
  let u = options.readUnknownField;
@@ -13445,15 +13996,39 @@ class SendMessageResult$Type extends import_runtime4.MessageType {
13445
13996
  return message;
13446
13997
  }
13447
13998
  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();
13999
+ if (message.interactionId !== 0n)
14000
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
14001
+ if (message.ui)
14002
+ MessageActionResponseUi.internalBinaryWrite(message.ui, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
13450
14003
  let u = options.writeUnknownFields;
13451
14004
  if (u !== false)
13452
14005
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
13453
14006
  return writer;
13454
14007
  }
13455
14008
  }
13456
- var SendMessageResult = new SendMessageResult$Type;
14009
+ var AnswerMessageActionInput = new AnswerMessageActionInput$Type;
14010
+
14011
+ class AnswerMessageActionResult$Type extends import_runtime4.MessageType {
14012
+ constructor() {
14013
+ super("AnswerMessageActionResult", []);
14014
+ }
14015
+ create(value) {
14016
+ const message = globalThis.Object.create(this.messagePrototype);
14017
+ if (value !== undefined)
14018
+ import_runtime3.reflectionMergePartial(this, message, value);
14019
+ return message;
14020
+ }
14021
+ internalBinaryRead(reader, length, options, target) {
14022
+ return target ?? this.create();
14023
+ }
14024
+ internalBinaryWrite(message, writer, options) {
14025
+ let u = options.writeUnknownFields;
14026
+ if (u !== false)
14027
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14028
+ return writer;
14029
+ }
14030
+ }
14031
+ var AnswerMessageActionResult = new AnswerMessageActionResult$Type;
13457
14032
 
13458
14033
  class ForwardMessagesInput$Type extends import_runtime4.MessageType {
13459
14034
  constructor() {
@@ -13959,6 +14534,142 @@ class InputChatParticipant$Type extends import_runtime4.MessageType {
13959
14534
  }
13960
14535
  var InputChatParticipant = new InputChatParticipant$Type;
13961
14536
 
14537
+ class ReserveChatIdsInput$Type extends import_runtime4.MessageType {
14538
+ constructor() {
14539
+ super("ReserveChatIdsInput", [
14540
+ { no: 1, name: "count", kind: "scalar", T: 5 }
14541
+ ]);
14542
+ }
14543
+ create(value) {
14544
+ const message = globalThis.Object.create(this.messagePrototype);
14545
+ message.count = 0;
14546
+ if (value !== undefined)
14547
+ import_runtime3.reflectionMergePartial(this, message, value);
14548
+ return message;
14549
+ }
14550
+ internalBinaryRead(reader, length, options, target) {
14551
+ let message = target ?? this.create(), end = reader.pos + length;
14552
+ while (reader.pos < end) {
14553
+ let [fieldNo, wireType] = reader.tag();
14554
+ switch (fieldNo) {
14555
+ case 1:
14556
+ message.count = reader.int32();
14557
+ break;
14558
+ default:
14559
+ let u = options.readUnknownField;
14560
+ if (u === "throw")
14561
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14562
+ let d = reader.skip(wireType);
14563
+ if (u !== false)
14564
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14565
+ }
14566
+ }
14567
+ return message;
14568
+ }
14569
+ internalBinaryWrite(message, writer, options) {
14570
+ if (message.count !== 0)
14571
+ writer.tag(1, import_runtime.WireType.Varint).int32(message.count);
14572
+ let u = options.writeUnknownFields;
14573
+ if (u !== false)
14574
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14575
+ return writer;
14576
+ }
14577
+ }
14578
+ var ReserveChatIdsInput = new ReserveChatIdsInput$Type;
14579
+
14580
+ class ReservedChatId$Type extends import_runtime4.MessageType {
14581
+ constructor() {
14582
+ super("ReservedChatId", [
14583
+ { no: 1, name: "chat_id", kind: "scalar", T: 3, L: 0 },
14584
+ { no: 2, name: "expires_at", kind: "scalar", T: 3, L: 0 }
14585
+ ]);
14586
+ }
14587
+ create(value) {
14588
+ const message = globalThis.Object.create(this.messagePrototype);
14589
+ message.chatId = 0n;
14590
+ message.expiresAt = 0n;
14591
+ if (value !== undefined)
14592
+ import_runtime3.reflectionMergePartial(this, message, value);
14593
+ return message;
14594
+ }
14595
+ internalBinaryRead(reader, length, options, target) {
14596
+ let message = target ?? this.create(), end = reader.pos + length;
14597
+ while (reader.pos < end) {
14598
+ let [fieldNo, wireType] = reader.tag();
14599
+ switch (fieldNo) {
14600
+ case 1:
14601
+ message.chatId = reader.int64().toBigInt();
14602
+ break;
14603
+ case 2:
14604
+ message.expiresAt = reader.int64().toBigInt();
14605
+ break;
14606
+ default:
14607
+ let u = options.readUnknownField;
14608
+ if (u === "throw")
14609
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14610
+ let d = reader.skip(wireType);
14611
+ if (u !== false)
14612
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14613
+ }
14614
+ }
14615
+ return message;
14616
+ }
14617
+ internalBinaryWrite(message, writer, options) {
14618
+ if (message.chatId !== 0n)
14619
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.chatId);
14620
+ if (message.expiresAt !== 0n)
14621
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.expiresAt);
14622
+ let u = options.writeUnknownFields;
14623
+ if (u !== false)
14624
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14625
+ return writer;
14626
+ }
14627
+ }
14628
+ var ReservedChatId = new ReservedChatId$Type;
14629
+
14630
+ class ReserveChatIdsResult$Type extends import_runtime4.MessageType {
14631
+ constructor() {
14632
+ super("ReserveChatIdsResult", [
14633
+ { no: 1, name: "reservations", kind: "message", repeat: 1, T: () => ReservedChatId }
14634
+ ]);
14635
+ }
14636
+ create(value) {
14637
+ const message = globalThis.Object.create(this.messagePrototype);
14638
+ message.reservations = [];
14639
+ if (value !== undefined)
14640
+ import_runtime3.reflectionMergePartial(this, message, value);
14641
+ return message;
14642
+ }
14643
+ internalBinaryRead(reader, length, options, target) {
14644
+ let message = target ?? this.create(), end = reader.pos + length;
14645
+ while (reader.pos < end) {
14646
+ let [fieldNo, wireType] = reader.tag();
14647
+ switch (fieldNo) {
14648
+ case 1:
14649
+ message.reservations.push(ReservedChatId.internalBinaryRead(reader, reader.uint32(), options));
14650
+ break;
14651
+ default:
14652
+ let u = options.readUnknownField;
14653
+ if (u === "throw")
14654
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14655
+ let d = reader.skip(wireType);
14656
+ if (u !== false)
14657
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14658
+ }
14659
+ }
14660
+ return message;
14661
+ }
14662
+ internalBinaryWrite(message, writer, options) {
14663
+ for (let i = 0;i < message.reservations.length; i++)
14664
+ ReservedChatId.internalBinaryWrite(message.reservations[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14665
+ let u = options.writeUnknownFields;
14666
+ if (u !== false)
14667
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14668
+ return writer;
14669
+ }
14670
+ }
14671
+ var ReserveChatIdsResult = new ReserveChatIdsResult$Type;
14672
+
13962
14673
  class CreateChatInput$Type extends import_runtime4.MessageType {
13963
14674
  constructor() {
13964
14675
  super("CreateChatInput", [
@@ -13967,7 +14678,8 @@ class CreateChatInput$Type extends import_runtime4.MessageType {
13967
14678
  { no: 3, name: "description", kind: "scalar", opt: true, T: 9 },
13968
14679
  { no: 4, name: "emoji", kind: "scalar", opt: true, T: 9 },
13969
14680
  { no: 5, name: "is_public", kind: "scalar", T: 8 },
13970
- { no: 6, name: "participants", kind: "message", repeat: 1, T: () => InputChatParticipant }
14681
+ { no: 6, name: "participants", kind: "message", repeat: 1, T: () => InputChatParticipant },
14682
+ { no: 7, name: "reserved_chat_id", kind: "scalar", opt: true, T: 3, L: 0 }
13971
14683
  ]);
13972
14684
  }
13973
14685
  create(value) {
@@ -14002,6 +14714,9 @@ class CreateChatInput$Type extends import_runtime4.MessageType {
14002
14714
  case 6:
14003
14715
  message.participants.push(InputChatParticipant.internalBinaryRead(reader, reader.uint32(), options));
14004
14716
  break;
14717
+ case 7:
14718
+ message.reservedChatId = reader.int64().toBigInt();
14719
+ break;
14005
14720
  default:
14006
14721
  let u = options.readUnknownField;
14007
14722
  if (u === "throw")
@@ -14026,6 +14741,8 @@ class CreateChatInput$Type extends import_runtime4.MessageType {
14026
14741
  writer.tag(5, import_runtime.WireType.Varint).bool(message.isPublic);
14027
14742
  for (let i = 0;i < message.participants.length; i++)
14028
14743
  InputChatParticipant.internalBinaryWrite(message.participants[i], writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
14744
+ if (message.reservedChatId !== undefined)
14745
+ writer.tag(7, import_runtime.WireType.Varint).int64(message.reservedChatId);
14029
14746
  let u = options.writeUnknownFields;
14030
14747
  if (u !== false)
14031
14748
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -14338,7 +15055,9 @@ class Update$Type extends import_runtime4.MessageType {
14338
15055
  { no: 31, name: "pinned_messages", kind: "message", oneof: "update", T: () => UpdatePinnedMessages },
14339
15056
  { no: 32, name: "chat_moved", kind: "message", oneof: "update", T: () => UpdateChatMoved },
14340
15057
  { no: 33, name: "dialog_notification_settings", kind: "message", oneof: "update", T: () => UpdateDialogNotificationSettings },
14341
- { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen }
15058
+ { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen },
15059
+ { no: 35, name: "message_action_invoked", kind: "message", oneof: "update", T: () => UpdateMessageActionInvoked },
15060
+ { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered }
14342
15061
  ]);
14343
15062
  }
14344
15063
  create(value) {
@@ -14545,6 +15264,18 @@ class Update$Type extends import_runtime4.MessageType {
14545
15264
  chatOpen: UpdateChatOpen.internalBinaryRead(reader, reader.uint32(), options, message.update.chatOpen)
14546
15265
  };
14547
15266
  break;
15267
+ case 35:
15268
+ message.update = {
15269
+ oneofKind: "messageActionInvoked",
15270
+ messageActionInvoked: UpdateMessageActionInvoked.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionInvoked)
15271
+ };
15272
+ break;
15273
+ case 36:
15274
+ message.update = {
15275
+ oneofKind: "messageActionAnswered",
15276
+ messageActionAnswered: UpdateMessageActionAnswered.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionAnswered)
15277
+ };
15278
+ break;
14548
15279
  default:
14549
15280
  let u = options.readUnknownField;
14550
15281
  if (u === "throw")
@@ -14623,6 +15354,10 @@ class Update$Type extends import_runtime4.MessageType {
14623
15354
  UpdateDialogNotificationSettings.internalBinaryWrite(message.update.dialogNotificationSettings, writer.tag(33, import_runtime.WireType.LengthDelimited).fork(), options).join();
14624
15355
  if (message.update.oneofKind === "chatOpen")
14625
15356
  UpdateChatOpen.internalBinaryWrite(message.update.chatOpen, writer.tag(34, import_runtime.WireType.LengthDelimited).fork(), options).join();
15357
+ if (message.update.oneofKind === "messageActionInvoked")
15358
+ UpdateMessageActionInvoked.internalBinaryWrite(message.update.messageActionInvoked, writer.tag(35, import_runtime.WireType.LengthDelimited).fork(), options).join();
15359
+ if (message.update.oneofKind === "messageActionAnswered")
15360
+ UpdateMessageActionAnswered.internalBinaryWrite(message.update.messageActionAnswered, writer.tag(36, import_runtime.WireType.LengthDelimited).fork(), options).join();
14626
15361
  let u = options.writeUnknownFields;
14627
15362
  if (u !== false)
14628
15363
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -15496,10 +16231,134 @@ class UpdateNewChat$Type extends import_runtime4.MessageType {
15496
16231
  let [fieldNo, wireType] = reader.tag();
15497
16232
  switch (fieldNo) {
15498
16233
  case 1:
15499
- message.chat = Chat.internalBinaryRead(reader, reader.uint32(), options, message.chat);
16234
+ message.chat = Chat.internalBinaryRead(reader, reader.uint32(), options, message.chat);
16235
+ break;
16236
+ case 3:
16237
+ message.user = User.internalBinaryRead(reader, reader.uint32(), options, message.user);
16238
+ break;
16239
+ default:
16240
+ let u = options.readUnknownField;
16241
+ if (u === "throw")
16242
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
16243
+ let d = reader.skip(wireType);
16244
+ if (u !== false)
16245
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
16246
+ }
16247
+ }
16248
+ return message;
16249
+ }
16250
+ internalBinaryWrite(message, writer, options) {
16251
+ if (message.chat)
16252
+ Chat.internalBinaryWrite(message.chat, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
16253
+ if (message.user)
16254
+ User.internalBinaryWrite(message.user, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
16255
+ let u = options.writeUnknownFields;
16256
+ if (u !== false)
16257
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
16258
+ return writer;
16259
+ }
16260
+ }
16261
+ var UpdateNewChat = new UpdateNewChat$Type;
16262
+
16263
+ class UpdateChatOpen$Type extends import_runtime4.MessageType {
16264
+ constructor() {
16265
+ super("UpdateChatOpen", [
16266
+ { no: 1, name: "chat", kind: "message", T: () => Chat },
16267
+ { no: 2, name: "dialog", kind: "message", T: () => Dialog },
16268
+ { no: 3, name: "user", kind: "message", T: () => User }
16269
+ ]);
16270
+ }
16271
+ create(value) {
16272
+ const message = globalThis.Object.create(this.messagePrototype);
16273
+ if (value !== undefined)
16274
+ import_runtime3.reflectionMergePartial(this, message, value);
16275
+ return message;
16276
+ }
16277
+ internalBinaryRead(reader, length, options, target) {
16278
+ let message = target ?? this.create(), end = reader.pos + length;
16279
+ while (reader.pos < end) {
16280
+ let [fieldNo, wireType] = reader.tag();
16281
+ switch (fieldNo) {
16282
+ case 1:
16283
+ message.chat = Chat.internalBinaryRead(reader, reader.uint32(), options, message.chat);
16284
+ break;
16285
+ case 2:
16286
+ message.dialog = Dialog.internalBinaryRead(reader, reader.uint32(), options, message.dialog);
16287
+ break;
16288
+ case 3:
16289
+ message.user = User.internalBinaryRead(reader, reader.uint32(), options, message.user);
16290
+ break;
16291
+ default:
16292
+ let u = options.readUnknownField;
16293
+ if (u === "throw")
16294
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
16295
+ let d = reader.skip(wireType);
16296
+ if (u !== false)
16297
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
16298
+ }
16299
+ }
16300
+ return message;
16301
+ }
16302
+ internalBinaryWrite(message, writer, options) {
16303
+ if (message.chat)
16304
+ Chat.internalBinaryWrite(message.chat, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
16305
+ if (message.dialog)
16306
+ Dialog.internalBinaryWrite(message.dialog, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
16307
+ if (message.user)
16308
+ User.internalBinaryWrite(message.user, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
16309
+ let u = options.writeUnknownFields;
16310
+ if (u !== false)
16311
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
16312
+ return writer;
16313
+ }
16314
+ }
16315
+ var UpdateChatOpen = new UpdateChatOpen$Type;
16316
+
16317
+ class UpdateMessageActionInvoked$Type extends import_runtime4.MessageType {
16318
+ constructor() {
16319
+ super("UpdateMessageActionInvoked", [
16320
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 },
16321
+ { no: 2, name: "chat_id", kind: "scalar", T: 3, L: 0 },
16322
+ { no: 3, name: "message_id", kind: "scalar", T: 3, L: 0 },
16323
+ { no: 4, name: "actor_user_id", kind: "scalar", T: 3, L: 0 },
16324
+ { no: 5, name: "action_id", kind: "scalar", T: 9 },
16325
+ { no: 6, name: "data", kind: "scalar", T: 12 }
16326
+ ]);
16327
+ }
16328
+ create(value) {
16329
+ const message = globalThis.Object.create(this.messagePrototype);
16330
+ message.interactionId = 0n;
16331
+ message.chatId = 0n;
16332
+ message.messageId = 0n;
16333
+ message.actorUserId = 0n;
16334
+ message.actionId = "";
16335
+ message.data = new Uint8Array(0);
16336
+ if (value !== undefined)
16337
+ import_runtime3.reflectionMergePartial(this, message, value);
16338
+ return message;
16339
+ }
16340
+ internalBinaryRead(reader, length, options, target) {
16341
+ let message = target ?? this.create(), end = reader.pos + length;
16342
+ while (reader.pos < end) {
16343
+ let [fieldNo, wireType] = reader.tag();
16344
+ switch (fieldNo) {
16345
+ case 1:
16346
+ message.interactionId = reader.int64().toBigInt();
16347
+ break;
16348
+ case 2:
16349
+ message.chatId = reader.int64().toBigInt();
15500
16350
  break;
15501
16351
  case 3:
15502
- message.user = User.internalBinaryRead(reader, reader.uint32(), options, message.user);
16352
+ message.messageId = reader.int64().toBigInt();
16353
+ break;
16354
+ case 4:
16355
+ message.actorUserId = reader.int64().toBigInt();
16356
+ break;
16357
+ case 5:
16358
+ message.actionId = reader.string();
16359
+ break;
16360
+ case 6:
16361
+ message.data = reader.bytes();
15503
16362
  break;
15504
16363
  default:
15505
16364
  let u = options.readUnknownField;
@@ -15513,28 +16372,36 @@ class UpdateNewChat$Type extends import_runtime4.MessageType {
15513
16372
  return message;
15514
16373
  }
15515
16374
  internalBinaryWrite(message, writer, options) {
15516
- if (message.chat)
15517
- Chat.internalBinaryWrite(message.chat, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
15518
- if (message.user)
15519
- User.internalBinaryWrite(message.user, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
16375
+ if (message.interactionId !== 0n)
16376
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
16377
+ if (message.chatId !== 0n)
16378
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.chatId);
16379
+ if (message.messageId !== 0n)
16380
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.messageId);
16381
+ if (message.actorUserId !== 0n)
16382
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.actorUserId);
16383
+ if (message.actionId !== "")
16384
+ writer.tag(5, import_runtime.WireType.LengthDelimited).string(message.actionId);
16385
+ if (message.data.length)
16386
+ writer.tag(6, import_runtime.WireType.LengthDelimited).bytes(message.data);
15520
16387
  let u = options.writeUnknownFields;
15521
16388
  if (u !== false)
15522
16389
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
15523
16390
  return writer;
15524
16391
  }
15525
16392
  }
15526
- var UpdateNewChat = new UpdateNewChat$Type;
16393
+ var UpdateMessageActionInvoked = new UpdateMessageActionInvoked$Type;
15527
16394
 
15528
- class UpdateChatOpen$Type extends import_runtime4.MessageType {
16395
+ class UpdateMessageActionAnswered$Type extends import_runtime4.MessageType {
15529
16396
  constructor() {
15530
- super("UpdateChatOpen", [
15531
- { no: 1, name: "chat", kind: "message", T: () => Chat },
15532
- { no: 2, name: "dialog", kind: "message", T: () => Dialog },
15533
- { no: 3, name: "user", kind: "message", T: () => User }
16397
+ super("UpdateMessageActionAnswered", [
16398
+ { no: 1, name: "interaction_id", kind: "scalar", T: 3, L: 0 },
16399
+ { no: 2, name: "ui", kind: "message", T: () => MessageActionResponseUi }
15534
16400
  ]);
15535
16401
  }
15536
16402
  create(value) {
15537
16403
  const message = globalThis.Object.create(this.messagePrototype);
16404
+ message.interactionId = 0n;
15538
16405
  if (value !== undefined)
15539
16406
  import_runtime3.reflectionMergePartial(this, message, value);
15540
16407
  return message;
@@ -15545,13 +16412,10 @@ class UpdateChatOpen$Type extends import_runtime4.MessageType {
15545
16412
  let [fieldNo, wireType] = reader.tag();
15546
16413
  switch (fieldNo) {
15547
16414
  case 1:
15548
- message.chat = Chat.internalBinaryRead(reader, reader.uint32(), options, message.chat);
16415
+ message.interactionId = reader.int64().toBigInt();
15549
16416
  break;
15550
16417
  case 2:
15551
- message.dialog = Dialog.internalBinaryRead(reader, reader.uint32(), options, message.dialog);
15552
- break;
15553
- case 3:
15554
- message.user = User.internalBinaryRead(reader, reader.uint32(), options, message.user);
16418
+ message.ui = MessageActionResponseUi.internalBinaryRead(reader, reader.uint32(), options, message.ui);
15555
16419
  break;
15556
16420
  default:
15557
16421
  let u = options.readUnknownField;
@@ -15565,19 +16429,17 @@ class UpdateChatOpen$Type extends import_runtime4.MessageType {
15565
16429
  return message;
15566
16430
  }
15567
16431
  internalBinaryWrite(message, writer, options) {
15568
- if (message.chat)
15569
- Chat.internalBinaryWrite(message.chat, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
15570
- if (message.dialog)
15571
- Dialog.internalBinaryWrite(message.dialog, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
15572
- if (message.user)
15573
- User.internalBinaryWrite(message.user, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
16432
+ if (message.interactionId !== 0n)
16433
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.interactionId);
16434
+ if (message.ui)
16435
+ MessageActionResponseUi.internalBinaryWrite(message.ui, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
15574
16436
  let u = options.writeUnknownFields;
15575
16437
  if (u !== false)
15576
16438
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
15577
16439
  return writer;
15578
16440
  }
15579
16441
  }
15580
- var UpdateChatOpen = new UpdateChatOpen$Type;
16442
+ var UpdateMessageActionAnswered = new UpdateMessageActionAnswered$Type;
15581
16443
 
15582
16444
  class UpdateDeleteChat$Type extends import_runtime4.MessageType {
15583
16445
  constructor() {
@@ -18052,7 +18914,9 @@ var rpcInputKindByMethod = {
18052
18914
  35: "moveThread",
18053
18915
  36: "rotateBotToken",
18054
18916
  37: "updateBotProfile",
18055
- 38: "getMessages"
18917
+ 38: "getMessages",
18918
+ 48: "invokeMessageAction",
18919
+ 49: "answerMessageAction"
18056
18920
  };
18057
18921
  var rpcResultKindByMethod = {
18058
18922
  0: undefined,
@@ -18093,7 +18957,9 @@ var rpcResultKindByMethod = {
18093
18957
  35: "moveThread",
18094
18958
  36: "rotateBotToken",
18095
18959
  37: "updateBotProfile",
18096
- 38: "getMessages"
18960
+ 38: "getMessages",
18961
+ 48: "invokeMessageAction",
18962
+ 49: "answerMessageAction"
18097
18963
  };
18098
18964
 
18099
18965
  // ../sdk/dist/sdk/logger.js
@@ -18103,19 +18969,23 @@ var noopLogger = {};
18103
18969
  import { readFileSync } from "node:fs";
18104
18970
  var cached = null;
18105
18971
  var getSdkVersion = () => {
18106
- if (cached)
18972
+ if (cached !== null)
18107
18973
  return cached;
18108
18974
  try {
18109
18975
  const pkgUrl = new URL("../../package.json", import.meta.url);
18110
18976
  const raw = readFileSync(pkgUrl, "utf8");
18111
18977
  const parsed = JSON.parse(raw);
18112
18978
  if (typeof parsed === "object" && parsed !== null && "version" in parsed && typeof parsed.version === "string") {
18113
- const version = parsed.version;
18979
+ const version = parsed.version.trim();
18980
+ if (!version) {
18981
+ cached = undefined;
18982
+ return cached;
18983
+ }
18114
18984
  cached = version;
18115
18985
  return version;
18116
18986
  }
18117
18987
  } catch {}
18118
- cached = "unknown";
18988
+ cached = undefined;
18119
18989
  return cached;
18120
18990
  };
18121
18991
 
@@ -18126,6 +18996,8 @@ var defaultApiBaseUrl = "https://api.inline.chat";
18126
18996
  var defaultVideoWidth = 1280;
18127
18997
  var defaultVideoHeight = 720;
18128
18998
  var defaultVideoDuration = 1;
18999
+ var defaultCatchUpTotalLimit = 1000;
19000
+ var defaultColdStartCatchUpWindow = defaultCatchUpTotalLimit;
18129
19001
  function extractFirstMessageId(updates) {
18130
19002
  for (const update of updates ?? []) {
18131
19003
  if (update.update.oneofKind === "newMessage") {
@@ -18153,6 +19025,7 @@ class InlineSdkClient {
18153
19025
  saveTimer = null;
18154
19026
  saveInFlight = null;
18155
19027
  catchUpInFlightByChatId = new Map;
19028
+ catchUpRequestedByChatId = new Map;
18156
19029
  constructor(options) {
18157
19030
  this.options = options;
18158
19031
  this.log = options.logger ?? noopLogger;
@@ -18160,12 +19033,13 @@ class InlineSdkClient {
18160
19033
  this.fetchImpl = options.fetch ?? fetch;
18161
19034
  const url = resolveRealtimeUrl(this.httpBaseUrl);
18162
19035
  this.transport = options.transport ?? new WebSocketTransport({ url, logger: options.logger });
19036
+ const sdkVersion = getSdkVersion();
18163
19037
  this.protocol = new ProtocolClient({
18164
19038
  transport: this.transport,
18165
19039
  getConnectionInit: () => ({
18166
19040
  token: options.token,
18167
19041
  layer: sdkLayer,
18168
- clientVersion: getSdkVersion()
19042
+ ...sdkVersion ? { clientVersion: sdkVersion } : {}
18169
19043
  }),
18170
19044
  logger: options.logger,
18171
19045
  defaultRpcTimeoutMs: options.rpcTimeoutMs
@@ -18292,6 +19166,7 @@ class InlineSdkClient {
18292
19166
  ...params.replyToMsgId != null ? { replyToMsgId: asInlineId(params.replyToMsgId, "replyToMsgId") } : {},
18293
19167
  ...params.parseMarkdown != null ? { parseMarkdown: params.parseMarkdown } : {},
18294
19168
  ...params.entities != null ? { entities: params.entities } : {},
19169
+ ...params.actions != null ? { actions: params.actions } : {},
18295
19170
  ...params.sendMode === "silent" ? { sendMode: MessageSendMode.MODE_SILENT } : {}
18296
19171
  }
18297
19172
  });
@@ -18399,6 +19274,33 @@ class InlineSdkClient {
18399
19274
  }
18400
19275
  });
18401
19276
  }
19277
+ async invokeMessageAction(params) {
19278
+ const peerId = this.inputPeerFromTarget(params, "invokeMessageAction");
19279
+ const actionId = params.actionId.trim();
19280
+ if (!actionId) {
19281
+ throw new Error("invokeMessageAction: `actionId` must be non-empty");
19282
+ }
19283
+ const result = await this.invoke(Method.INVOKE_MESSAGE_ACTION, {
19284
+ oneofKind: "invokeMessageAction",
19285
+ invokeMessageAction: {
19286
+ peerId,
19287
+ messageId: asInlineId(params.messageId, "messageId"),
19288
+ actionId
19289
+ }
19290
+ });
19291
+ return {
19292
+ interactionId: result.invokeMessageAction.interactionId
19293
+ };
19294
+ }
19295
+ async answerMessageAction(params) {
19296
+ await this.invoke(Method.ANSWER_MESSAGE_ACTION, {
19297
+ oneofKind: "answerMessageAction",
19298
+ answerMessageAction: {
19299
+ interactionId: asInlineId(params.interactionId, "interactionId"),
19300
+ ...params.ui != null ? { ui: params.ui } : {}
19301
+ }
19302
+ });
19303
+ }
18402
19304
  async invokeRaw(method, input = { oneofKind: undefined }, options) {
18403
19305
  if (hasMethodMapping(method)) {
18404
19306
  this.assertMethodInputMatch(method, input);
@@ -18565,6 +19467,32 @@ class InlineSdkClient {
18565
19467
  });
18566
19468
  return;
18567
19469
  }
19470
+ case "messageActionInvoked": {
19471
+ const payload = update.update.messageActionInvoked;
19472
+ await this.eventStream.send({
19473
+ kind: "message.action.invoke",
19474
+ interactionId: payload.interactionId,
19475
+ chatId: payload.chatId,
19476
+ messageId: payload.messageId,
19477
+ actorUserId: payload.actorUserId,
19478
+ actionId: payload.actionId,
19479
+ data: payload.data,
19480
+ seq,
19481
+ date
19482
+ });
19483
+ return;
19484
+ }
19485
+ case "messageActionAnswered": {
19486
+ const payload = update.update.messageActionAnswered;
19487
+ await this.eventStream.send({
19488
+ kind: "message.action.answered",
19489
+ interactionId: payload.interactionId,
19490
+ ui: payload.ui,
19491
+ seq,
19492
+ date
19493
+ });
19494
+ return;
19495
+ }
18568
19496
  case "chatHasNewUpdates": {
18569
19497
  const payload = update.update.chatHasNewUpdates;
18570
19498
  await this.eventStream.send({
@@ -18573,7 +19501,7 @@ class InlineSdkClient {
18573
19501
  seq,
18574
19502
  date
18575
19503
  });
18576
- await this.catchUpChat({ chatId: payload.chatId, peer: payload.peerId, updateSeq: payload.updateSeq, update });
19504
+ this.requestCatchUpChat({ chatId: payload.chatId, peer: payload.peerId, updateSeq: payload.updateSeq });
18577
19505
  return;
18578
19506
  }
18579
19507
  case "spaceHasNewUpdates": {
@@ -18602,21 +19530,50 @@ class InlineSdkClient {
18602
19530
  this.scheduleStateSave();
18603
19531
  }
18604
19532
  }
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;
19533
+ requestCatchUpChat(params) {
19534
+ const previous = this.catchUpRequestedByChatId.get(params.chatId);
19535
+ this.catchUpRequestedByChatId.set(params.chatId, {
19536
+ endSeq: Math.max(previous?.endSeq ?? 0, params.updateSeq),
19537
+ peer: params.peer ?? previous?.peer
19538
+ });
18611
19539
  if (this.catchUpInFlightByChatId.has(params.chatId)) {
18612
- await this.catchUpInFlightByChatId.get(params.chatId);
18613
19540
  return;
18614
19541
  }
18615
- const task = this.doCatchUpChat(params.chatId, params.peer, startSeq, params.updateSeq).finally(() => {
19542
+ const task = this.drainCatchUpChat(params.chatId).catch((error) => {
19543
+ this.catchUpRequestedByChatId.delete(params.chatId);
19544
+ this.log.warn?.("GET_UPDATES catch-up failed; continuing live delivery", {
19545
+ chatId: params.chatId.toString(),
19546
+ error: extractErrorMessage(error)
19547
+ });
19548
+ }).finally(() => {
18616
19549
  this.catchUpInFlightByChatId.delete(params.chatId);
18617
19550
  });
18618
19551
  this.catchUpInFlightByChatId.set(params.chatId, task);
18619
- await task;
19552
+ }
19553
+ async drainCatchUpChat(chatId) {
19554
+ const key = chatId.toString();
19555
+ while (true) {
19556
+ const request = this.catchUpRequestedByChatId.get(chatId);
19557
+ if (!request)
19558
+ return;
19559
+ const lastSeq = this.state.lastSeqByChatId?.[key];
19560
+ const startSeq = lastSeq ?? Math.max(0, request.endSeq - defaultColdStartCatchUpWindow);
19561
+ if (request.endSeq <= startSeq) {
19562
+ this.catchUpRequestedByChatId.delete(chatId);
19563
+ return;
19564
+ }
19565
+ const stop = await this.doCatchUpChat(chatId, request.peer, startSeq, request.endSeq);
19566
+ if (stop) {
19567
+ this.catchUpRequestedByChatId.delete(chatId);
19568
+ return;
19569
+ }
19570
+ const latest = this.catchUpRequestedByChatId.get(chatId);
19571
+ const syncedSeq = this.state.lastSeqByChatId?.[key] ?? 0;
19572
+ if (!latest || latest.endSeq <= syncedSeq) {
19573
+ this.catchUpRequestedByChatId.delete(chatId);
19574
+ return;
19575
+ }
19576
+ }
18620
19577
  }
18621
19578
  async doCatchUpChat(chatId, peer, startSeq, endSeq) {
18622
19579
  let cursor = startSeq;
@@ -18634,7 +19591,7 @@ class InlineSdkClient {
18634
19591
  }),
18635
19592
  startSeq: BigInt(cursor),
18636
19593
  seqEnd: BigInt(endSeq),
18637
- totalLimit: 1000
19594
+ totalLimit: defaultCatchUpTotalLimit
18638
19595
  })
18639
19596
  });
18640
19597
  const payload = result.getUpdates;
@@ -18645,12 +19602,12 @@ class InlineSdkClient {
18645
19602
  this.state.dateCursor = payload.date;
18646
19603
  }
18647
19604
  this.scheduleStateSave();
18648
- return;
19605
+ return true;
18649
19606
  }
18650
19607
  const deliveredSeq = Number(payload.seq ?? 0n);
18651
19608
  if (!Number.isSafeInteger(deliveredSeq)) {
18652
19609
  this.log.warn?.("GET_UPDATES returned non-integer seq; aborting catch-up", { chatId: chatId.toString() });
18653
- return;
19610
+ return true;
18654
19611
  }
18655
19612
  this.bumpChatSeq(chatId, deliveredSeq);
18656
19613
  for (const update of payload.updates) {
@@ -18661,13 +19618,14 @@ class InlineSdkClient {
18661
19618
  }
18662
19619
  this.scheduleStateSave();
18663
19620
  if (payload.final)
18664
- return;
19621
+ return true;
18665
19622
  if (deliveredSeq <= cursor) {
18666
19623
  this.log.warn?.("GET_UPDATES made no progress; aborting catch-up", { chatId: chatId.toString(), cursor, deliveredSeq });
18667
- return;
19624
+ return true;
18668
19625
  }
18669
19626
  cursor = deliveredSeq;
18670
19627
  }
19628
+ return false;
18671
19629
  }
18672
19630
  peerToInputPeer(peer, chatId) {
18673
19631
  if (!peer) {
@@ -32559,9 +33517,14 @@ var InlineActionsSchema = exports_external.object({
32559
33517
  }).strict();
32560
33518
  var InlineGroupSchema = exports_external.object({
32561
33519
  requireMention: exports_external.boolean().optional(),
33520
+ systemPrompt: exports_external.string().optional(),
32562
33521
  tools: ToolPolicySchema,
32563
33522
  toolsBySender: exports_external.record(exports_external.string(), ToolPolicySchema).optional()
32564
33523
  }).strict();
33524
+ var InlineCommandsSchema = exports_external.object({
33525
+ native: exports_external.union([exports_external.boolean(), exports_external.literal("auto")]).optional(),
33526
+ nativeSkills: exports_external.union([exports_external.boolean(), exports_external.literal("auto")]).optional()
33527
+ }).strict();
32565
33528
  var InlineAccountSchemaBase = exports_external.object({
32566
33529
  name: exports_external.string().optional(),
32567
33530
  enabled: exports_external.boolean().optional(),
@@ -32570,6 +33533,7 @@ var InlineAccountSchemaBase = exports_external.object({
32570
33533
  tokenFile: exports_external.string().optional(),
32571
33534
  dmPolicy: DmPolicySchema.optional().default("pairing"),
32572
33535
  allowFrom: exports_external.array(exports_external.string()).optional(),
33536
+ systemPrompt: exports_external.string().optional(),
32573
33537
  groupAllowFrom: exports_external.array(exports_external.string()).optional(),
32574
33538
  groupPolicy: GroupPolicySchema.optional().default("allowlist"),
32575
33539
  groups: exports_external.record(exports_external.string(), InlineGroupSchema.optional()).optional(),
@@ -32584,7 +33548,8 @@ var InlineAccountSchemaBase = exports_external.object({
32584
33548
  chunkMode: exports_external.enum(["length", "newline"]).optional(),
32585
33549
  blockStreaming: exports_external.boolean().optional(),
32586
33550
  streamViaEditMessage: exports_external.boolean().optional(),
32587
- blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional()
33551
+ blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
33552
+ commands: InlineCommandsSchema.optional()
32588
33553
  }).strict();
32589
33554
  var InlineRuntimeAccountSchema = InlineAccountSchemaBase.passthrough();
32590
33555
  var InlineAccountSchema = InlineAccountSchemaBase.superRefine((value, ctx) => {
@@ -32719,14 +33684,41 @@ function looksLikeInlineTargetId(raw, normalizedInput) {
32719
33684
  import { mkdir } from "node:fs/promises";
32720
33685
  import path2 from "node:path";
32721
33686
  import {
33687
+ buildPendingHistoryContextFromMap,
33688
+ clearHistoryEntriesIfEnabled,
32722
33689
  createReplyPrefixOptions,
32723
33690
  createTypingCallbacks,
32724
33691
  logInboundDrop,
33692
+ recordPendingHistoryEntryIfEnabled,
32725
33693
  resolveChannelMediaMaxBytes as resolveChannelMediaMaxBytes2,
32726
33694
  resolveControlCommandGate,
32727
33695
  resolveMentionGatingWithBypass
32728
33696
  } from "openclaw/plugin-sdk";
32729
33697
 
33698
+ // src/inline/message-formatting.ts
33699
+ 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.";
33700
+ 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.";
33701
+ function isBareHttpUrl(text) {
33702
+ if (!/^https?:\/\/\S+$/i.test(text))
33703
+ return false;
33704
+ try {
33705
+ const url2 = new URL(text);
33706
+ return url2.protocol === "http:" || url2.protocol === "https:";
33707
+ } catch {
33708
+ return false;
33709
+ }
33710
+ }
33711
+ function buildInlineSystemPrompt(extraPrompt) {
33712
+ return [INLINE_SYSTEM_PROMPT_BASE, extraPrompt?.trim() || null].filter((entry) => Boolean(entry)).join(`
33713
+
33714
+ `);
33715
+ }
33716
+ function sanitizeInlineOutgoingText(text) {
33717
+ return text.replace(/`([^`\n]+)`/g, (full, content) => {
33718
+ return isBareHttpUrl(content) ? content : full;
33719
+ });
33720
+ }
33721
+
32730
33722
  // src/inline/policy.ts
32731
33723
  import { normalizeAccountId as normalizePluginAccountId } from "openclaw/plugin-sdk";
32732
33724
  function normalizeAccountId2(raw) {
@@ -33007,7 +33999,7 @@ async function uploadInlineMediaFromUrl(params) {
33007
33999
  }));
33008
34000
  const normalizedExt = normalizeExt(loaded.fileName);
33009
34001
  uploadType = chooseUploadType({
33010
- kind: loaded.kind,
34002
+ kind: loaded.kind ?? "unknown",
33011
34003
  ...detectedMime ? { mime: detectedMime } : {},
33012
34004
  ...normalizedExt ? { ext: normalizedExt } : {}
33013
34005
  });
@@ -33351,6 +34343,244 @@ function summarizeInlineMessageContent(message) {
33351
34343
  };
33352
34344
  }
33353
34345
 
34346
+ // src/inline/command-menu-compat.ts
34347
+ var THINKING_LEVEL_CHOICES = ["off", "minimal", "low", "medium", "high", "xhigh"];
34348
+ var COMPAT_COMMANDS = [
34349
+ {
34350
+ key: "tts",
34351
+ nativeName: "tts",
34352
+ args: [
34353
+ {
34354
+ name: "action",
34355
+ description: "TTS action",
34356
+ choices: [
34357
+ { value: "on", label: "On" },
34358
+ { value: "off", label: "Off" },
34359
+ { value: "status", label: "Status" },
34360
+ { value: "provider", label: "Provider" },
34361
+ { value: "limit", label: "Limit" },
34362
+ { value: "summary", label: "Summary" },
34363
+ { value: "audio", label: "Audio" },
34364
+ { value: "help", label: "Help" }
34365
+ ]
34366
+ },
34367
+ { name: "value", description: "Provider, limit, or text" }
34368
+ ],
34369
+ argsMenu: {
34370
+ arg: "action",
34371
+ title: "Choose TTS action:"
34372
+ }
34373
+ },
34374
+ {
34375
+ key: "session",
34376
+ nativeName: "session",
34377
+ args: [
34378
+ { name: "action", description: "idle | max-age", choices: ["idle", "max-age"] },
34379
+ { name: "value", description: "Duration or off" }
34380
+ ],
34381
+ argsMenu: "auto"
34382
+ },
34383
+ {
34384
+ key: "subagents",
34385
+ nativeName: "subagents",
34386
+ args: [
34387
+ {
34388
+ name: "action",
34389
+ description: "list | kill | log | info | send | steer | spawn",
34390
+ choices: ["list", "kill", "log", "info", "send", "steer", "spawn"]
34391
+ },
34392
+ { name: "target", description: "Run id, index, or session key" },
34393
+ { name: "value", description: "Additional input" }
34394
+ ],
34395
+ argsMenu: "auto"
34396
+ },
34397
+ {
34398
+ key: "acp",
34399
+ nativeName: "acp",
34400
+ args: [
34401
+ {
34402
+ name: "action",
34403
+ description: "Action to run",
34404
+ choices: [
34405
+ "spawn",
34406
+ "cancel",
34407
+ "steer",
34408
+ "close",
34409
+ "sessions",
34410
+ "status",
34411
+ "set-mode",
34412
+ "set",
34413
+ "cwd",
34414
+ "permissions",
34415
+ "timeout",
34416
+ "model",
34417
+ "reset-options",
34418
+ "doctor",
34419
+ "install",
34420
+ "help"
34421
+ ]
34422
+ },
34423
+ { name: "value", description: "Action arguments" }
34424
+ ],
34425
+ argsMenu: "auto"
34426
+ },
34427
+ {
34428
+ key: "usage",
34429
+ nativeName: "usage",
34430
+ args: [{ name: "mode", description: "off, tokens, full, or cost", choices: ["off", "tokens", "full", "cost"] }],
34431
+ argsMenu: "auto"
34432
+ },
34433
+ {
34434
+ key: "activation",
34435
+ nativeName: "activation",
34436
+ args: [{ name: "mode", description: "mention or always", choices: ["mention", "always"] }],
34437
+ argsMenu: "auto"
34438
+ },
34439
+ {
34440
+ key: "send",
34441
+ nativeName: "send",
34442
+ args: [{ name: "mode", description: "on, off, or inherit", choices: ["on", "off", "inherit"] }],
34443
+ argsMenu: "auto"
34444
+ },
34445
+ {
34446
+ key: "think",
34447
+ nativeName: "think",
34448
+ args: [{ name: "level", description: "thinking level", choices: [...THINKING_LEVEL_CHOICES] }],
34449
+ argsMenu: "auto"
34450
+ },
34451
+ {
34452
+ key: "verbose",
34453
+ nativeName: "verbose",
34454
+ args: [{ name: "mode", description: "on or off", choices: ["on", "off"] }],
34455
+ argsMenu: "auto"
34456
+ },
34457
+ {
34458
+ key: "fast",
34459
+ nativeName: "fast",
34460
+ args: [{ name: "mode", description: "status, on, or off", choices: ["status", "on", "off"] }],
34461
+ argsMenu: "auto"
34462
+ },
34463
+ {
34464
+ key: "reasoning",
34465
+ nativeName: "reasoning",
34466
+ args: [{ name: "mode", description: "on, off, or stream", choices: ["on", "off", "stream"] }],
34467
+ argsMenu: "auto"
34468
+ },
34469
+ {
34470
+ key: "elevated",
34471
+ nativeName: "elevated",
34472
+ args: [{ name: "mode", description: "on, off, ask, or full", choices: ["on", "off", "ask", "full"] }],
34473
+ argsMenu: "auto"
34474
+ }
34475
+ ];
34476
+ function parsePositionalArgs(definitions, raw) {
34477
+ const values = {};
34478
+ const trimmed = raw.trim();
34479
+ if (!trimmed)
34480
+ return values;
34481
+ const tokens = trimmed.split(/\s+/).filter(Boolean);
34482
+ let index = 0;
34483
+ for (const definition of definitions) {
34484
+ if (index >= tokens.length)
34485
+ break;
34486
+ const token = tokens[index];
34487
+ if (!token)
34488
+ break;
34489
+ values[definition.name] = token;
34490
+ index += 1;
34491
+ }
34492
+ return values;
34493
+ }
34494
+ function parseCommandArgs(command, raw) {
34495
+ const trimmed = raw?.trim();
34496
+ if (!trimmed)
34497
+ return;
34498
+ if (!command.args || command.argsParsing === "none") {
34499
+ return { raw: trimmed };
34500
+ }
34501
+ return {
34502
+ raw: trimmed,
34503
+ values: parsePositionalArgs(command.args, trimmed)
34504
+ };
34505
+ }
34506
+ function findCommandByNativeName(name) {
34507
+ const normalized = name.trim().toLowerCase();
34508
+ return COMPAT_COMMANDS.find((command) => command.nativeName.toLowerCase() === normalized);
34509
+ }
34510
+ function resolveCommandArgChoices(arg) {
34511
+ const raw = arg.choices ?? [];
34512
+ return raw.map((choice) => typeof choice === "string" ? { value: choice, label: choice } : choice);
34513
+ }
34514
+ function resolveCommandArgMenu(params) {
34515
+ const { command, args } = params;
34516
+ if (!command.args || !command.argsMenu)
34517
+ return null;
34518
+ if (command.argsParsing === "none")
34519
+ return null;
34520
+ const argName = command.argsMenu === "auto" ? command.args.find((arg2) => resolveCommandArgChoices(arg2).length > 0)?.name : command.argsMenu.arg;
34521
+ if (!argName)
34522
+ return null;
34523
+ if (args?.values && args.values[argName] != null)
34524
+ return null;
34525
+ if (args?.raw && !args.values)
34526
+ return null;
34527
+ const arg = command.args.find((entry) => entry.name === argName);
34528
+ if (!arg)
34529
+ return null;
34530
+ const choices = resolveCommandArgChoices(arg);
34531
+ if (choices.length === 0)
34532
+ return null;
34533
+ const title = command.argsMenu !== "auto" ? command.argsMenu.title : undefined;
34534
+ return {
34535
+ arg,
34536
+ choices,
34537
+ ...title ? { title } : {}
34538
+ };
34539
+ }
34540
+ function buildCommandTextFromArgs(command, args) {
34541
+ const values = args?.values ?? {};
34542
+ const argDefs = command.args ?? [];
34543
+ const renderedArgs = [];
34544
+ for (const argDef of argDefs) {
34545
+ const value = values[argDef.name];
34546
+ if (value == null)
34547
+ continue;
34548
+ const normalized = typeof value === "string" ? value.trim() : String(value);
34549
+ if (!normalized)
34550
+ continue;
34551
+ renderedArgs.push(normalized);
34552
+ }
34553
+ return renderedArgs.length > 0 ? `/${command.nativeName} ${renderedArgs.join(" ")}` : `/${command.nativeName}`;
34554
+ }
34555
+ function resolveInlineCompatNativeCommandMenu(commandBody) {
34556
+ const normalized = commandBody.trim();
34557
+ const match = normalized.match(/^\/([^\s]+)(?:\s+([\s\S]+))?$/);
34558
+ if (!match?.[1])
34559
+ return null;
34560
+ const command = findCommandByNativeName(match[1]);
34561
+ if (!command)
34562
+ return null;
34563
+ const args = parseCommandArgs(command, match[2]);
34564
+ const menu = resolveCommandArgMenu({
34565
+ command,
34566
+ ...args ? { args } : {}
34567
+ });
34568
+ if (!menu)
34569
+ return null;
34570
+ const title = menu.title ?? `Choose ${menu.arg.description || menu.arg.name} for /${command.nativeName}.`;
34571
+ const rows = [];
34572
+ for (let index = 0;index < menu.choices.length; index += 2) {
34573
+ const slice = menu.choices.slice(index, index + 2);
34574
+ rows.push(slice.map((choice) => ({
34575
+ text: choice.label,
34576
+ callback_data: buildCommandTextFromArgs(command, {
34577
+ values: { [menu.arg.name]: choice.value }
34578
+ })
34579
+ })));
34580
+ }
34581
+ return { title, buttons: rows };
34582
+ }
34583
+
33354
34584
  // src/inline/monitor.ts
33355
34585
  var CHANNEL_ID = "inline";
33356
34586
  var DEFAULT_GROUP_HISTORY_LIMIT = 12;
@@ -33361,7 +34591,6 @@ var REACTION_TARGET_LOOKUP_LIMIT = 8;
33361
34591
  var REPLY_TARGET_LOOKUP_LIMIT = 8;
33362
34592
  var ATTACHMENT_CONTEXT_LIMIT = 6;
33363
34593
  var DEFAULT_INLINE_MEDIA_MAX_BYTES = 300 * 1024 * 1024;
33364
- 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.";
33365
34594
  var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
33366
34595
  function normalizeAllowEntry(raw) {
33367
34596
  return raw.trim().replace(/^inline:/i, "").replace(/^user:/i, "");
@@ -33404,10 +34633,156 @@ function normalizeInlineCommandBody(raw, botUsername) {
33404
34633
  }
33405
34634
  return normalized;
33406
34635
  }
34636
+ function callbackDataToBase64(data) {
34637
+ return Buffer.from(data).toString("base64");
34638
+ }
34639
+ function callbackDataToUtf8(data) {
34640
+ try {
34641
+ const decoded = new TextDecoder("utf-8", { fatal: true }).decode(data).trim();
34642
+ return decoded || undefined;
34643
+ } catch {
34644
+ return;
34645
+ }
34646
+ }
34647
+ var INLINE_ACTION_MAX_ROWS = 8;
34648
+ var INLINE_ACTION_MAX_PER_ROW = 8;
34649
+ function isRecord3(value) {
34650
+ return typeof value === "object" && value !== null;
34651
+ }
34652
+ function mapInlineModelPickerCallbackToCommand(raw) {
34653
+ const trimmed = raw.trim();
34654
+ if (!trimmed)
34655
+ return;
34656
+ if (trimmed === "mdl_prov" || trimmed === "mdl_back") {
34657
+ return "/models";
34658
+ }
34659
+ const listMatch = trimmed.match(/^mdl_list_([a-z0-9_-]+)_(\d+)$/i);
34660
+ if (listMatch?.[1] && listMatch[2]) {
34661
+ const provider = listMatch[1].trim();
34662
+ const page = Number.parseInt(listMatch[2], 10);
34663
+ if (provider && Number.isFinite(page) && page > 0) {
34664
+ return `/models ${provider} ${String(page)}`;
34665
+ }
34666
+ }
34667
+ const standardSelectionMatch = trimmed.match(/^mdl_sel_(.+)$/);
34668
+ if (standardSelectionMatch?.[1]?.trim()) {
34669
+ return `/model ${standardSelectionMatch[1].trim()}`;
34670
+ }
34671
+ const compactSelectionMatch = trimmed.match(/^mdl_sel\/(.+)$/);
34672
+ if (compactSelectionMatch?.[1]?.trim()) {
34673
+ return `/model ${compactSelectionMatch[1].trim()}`;
34674
+ }
34675
+ return;
34676
+ }
34677
+ function normalizeInlineActionCallbackData(raw) {
34678
+ const trimmed = raw.trim();
34679
+ if (!trimmed)
34680
+ return "";
34681
+ return mapInlineModelPickerCallbackToCommand(trimmed) ?? trimmed;
34682
+ }
34683
+ function normalizeReplyMarkupButtonsWith(raw, options) {
34684
+ if (!Array.isArray(raw))
34685
+ return [];
34686
+ const rows = [];
34687
+ for (const candidateRow of raw) {
34688
+ if (!Array.isArray(candidateRow))
34689
+ continue;
34690
+ const row = [];
34691
+ for (const candidateButton of candidateRow) {
34692
+ if (!isRecord3(candidateButton))
34693
+ continue;
34694
+ const text = typeof candidateButton.text === "string" ? candidateButton.text.trim() : "";
34695
+ const callbackDataRaw = typeof candidateButton.callback_data === "string" ? candidateButton.callback_data.trim() : "";
34696
+ const callbackData = options?.mapCallbackData ? options.mapCallbackData(callbackDataRaw) : callbackDataRaw;
34697
+ if (!text || !callbackData)
34698
+ continue;
34699
+ row.push({ text, callback_data: callbackData });
34700
+ if (row.length >= INLINE_ACTION_MAX_PER_ROW)
34701
+ break;
34702
+ }
34703
+ if (row.length === 0)
34704
+ continue;
34705
+ rows.push(row);
34706
+ if (rows.length >= INLINE_ACTION_MAX_ROWS)
34707
+ break;
34708
+ }
34709
+ return rows;
34710
+ }
34711
+ function resolveInlineReplyActions(payload) {
34712
+ const channelData = isRecord3(payload.channelData) ? payload.channelData : undefined;
34713
+ const inlineData = channelData && isRecord3(channelData.inline) ? channelData.inline : undefined;
34714
+ const telegramData = channelData && isRecord3(channelData.telegram) ? channelData.telegram : undefined;
34715
+ let rawButtons = undefined;
34716
+ let hasExplicitButtons = false;
34717
+ let mapCallbackData;
34718
+ if (inlineData && Object.prototype.hasOwnProperty.call(inlineData, "buttons")) {
34719
+ rawButtons = inlineData.buttons;
34720
+ hasExplicitButtons = true;
34721
+ } else if (telegramData && Object.prototype.hasOwnProperty.call(telegramData, "buttons")) {
34722
+ rawButtons = telegramData.buttons;
34723
+ hasExplicitButtons = true;
34724
+ mapCallbackData = normalizeInlineActionCallbackData;
34725
+ } else if (Object.prototype.hasOwnProperty.call(payload, "buttons")) {
34726
+ rawButtons = payload.buttons;
34727
+ hasExplicitButtons = true;
34728
+ }
34729
+ if (!hasExplicitButtons)
34730
+ return;
34731
+ const rows = normalizeReplyMarkupButtonsWith(rawButtons, {
34732
+ ...mapCallbackData ? { mapCallbackData } : {}
34733
+ });
34734
+ return {
34735
+ rows: rows.map((row, rowIndex) => ({
34736
+ actions: row.map((button, buttonIndex) => ({
34737
+ actionId: `btn_${rowIndex + 1}_${buttonIndex + 1}`,
34738
+ text: button.text,
34739
+ action: {
34740
+ oneofKind: "callback",
34741
+ callback: {
34742
+ data: new TextEncoder().encode(button.callback_data)
34743
+ }
34744
+ }
34745
+ }))
34746
+ }))
34747
+ };
34748
+ }
34749
+ async function answerInlineMessageAction(client, interactionId) {
34750
+ const withAnswer = client;
34751
+ if (typeof withAnswer.answerMessageAction === "function") {
34752
+ await withAnswer.answerMessageAction({ interactionId });
34753
+ return;
34754
+ }
34755
+ const answerMethod = Method["ANSWER_MESSAGE_ACTION"];
34756
+ if (typeof answerMethod === "number" && typeof withAnswer.invokeUncheckedRaw === "function") {
34757
+ await withAnswer.invokeUncheckedRaw(answerMethod, {
34758
+ oneofKind: "answerMessageAction",
34759
+ answerMessageAction: { interactionId }
34760
+ });
34761
+ }
34762
+ }
34763
+ function resolveCallbackCommandBodyFromActionData(params) {
34764
+ const decoded = callbackDataToUtf8(params.data);
34765
+ if (!decoded)
34766
+ return;
34767
+ const normalized = normalizeInlineActionCallbackData(decoded);
34768
+ if (!normalized.startsWith("/"))
34769
+ return;
34770
+ return normalizeInlineCommandBody(normalized, params.botUsername);
34771
+ }
34772
+ function shouldUseTelegramSurfaceForModelCommands(commandBody) {
34773
+ const normalized = commandBody.trim().toLowerCase();
34774
+ return normalized === "/model" || normalized.startsWith("/model ") || normalized === "/models" || normalized.startsWith("/models ");
34775
+ }
33407
34776
  function buildInlineSenderName(params) {
33408
34777
  const name = [params.firstName, params.lastName].filter(Boolean).join(" ").trim();
33409
34778
  return name || undefined;
33410
34779
  }
34780
+ function resolveInlineSystemPrompt(params) {
34781
+ const groupPrompt = params.groupId ? params.account.config.groups?.[params.groupId]?.systemPrompt?.trim() : undefined;
34782
+ return [buildInlineSystemPrompt(params.account.config.systemPrompt), groupPrompt].filter((entry) => Boolean(entry)).join(`
34783
+
34784
+ `);
34785
+ }
33411
34786
  function rewriteNumericMentionsToUsernames(text, senderProfilesById) {
33412
34787
  if (!text.includes("@"))
33413
34788
  return text;
@@ -33794,6 +35169,7 @@ async function monitorInlineProvider(params) {
33794
35169
  const chatCache = new Map;
33795
35170
  const senderProfilesById = new Map;
33796
35171
  const botMessageIdsByChat = new Map;
35172
+ const groupPendingHistories = new Map;
33797
35173
  const hydratedParticipantChats = new Set;
33798
35174
  const participantFetches = new Map;
33799
35175
  const inboundMediaMaxBytes = resolveInlineMediaMaxBytes({ cfg, account });
@@ -33839,13 +35215,20 @@ async function monitorInlineProvider(params) {
33839
35215
  for await (const event of client.events()) {
33840
35216
  if (abortSignal.aborted)
33841
35217
  break;
35218
+ const rawEvent = event;
33842
35219
  let msg;
33843
35220
  let rawBody = "";
33844
35221
  let currentAttachmentText = null;
33845
35222
  let currentEntityText = null;
33846
35223
  let reactionEvent = null;
35224
+ let inboundChatId = null;
35225
+ let callbackActionEvent = null;
33847
35226
  if (event.kind === "message.new") {
33848
- msg = event.message;
35227
+ inboundChatId = event.chatId;
35228
+ msg = {
35229
+ ...event.message,
35230
+ chatId: event.chatId
35231
+ };
33849
35232
  const content = summarizeInlineMessageContent(msg);
33850
35233
  rawBody = buildInlineInboundBodyText(content);
33851
35234
  currentAttachmentText = content.attachmentText || null;
@@ -33855,6 +35238,7 @@ async function monitorInlineProvider(params) {
33855
35238
  if (msg.out || msg.fromId === meId)
33856
35239
  continue;
33857
35240
  } else if (event.kind === "reaction.add") {
35241
+ inboundChatId = event.chatId;
33858
35242
  if (event.reaction.userId === meId)
33859
35243
  continue;
33860
35244
  const onBotMessage = await isReactionTargetBotMessage({
@@ -33885,6 +35269,7 @@ async function monitorInlineProvider(params) {
33885
35269
  replyToMsgId: event.reaction.messageId
33886
35270
  };
33887
35271
  } else if (event.kind === "reaction.delete") {
35272
+ inboundChatId = event.chatId;
33888
35273
  if (event.userId === meId)
33889
35274
  continue;
33890
35275
  const onBotMessage = await isReactionTargetBotMessage({
@@ -33914,10 +35299,42 @@ async function monitorInlineProvider(params) {
33914
35299
  mentioned: false,
33915
35300
  replyToMsgId: event.messageId
33916
35301
  };
35302
+ } else if (rawEvent["kind"] === "message.action.invoke") {
35303
+ const actorUserId = rawEvent["actorUserId"];
35304
+ const interactionId = rawEvent["interactionId"];
35305
+ const actionId = rawEvent["actionId"];
35306
+ const targetMessageId = rawEvent["messageId"];
35307
+ const data = rawEvent["data"];
35308
+ const eventChatId = rawEvent["chatId"];
35309
+ const eventDate = rawEvent["date"];
35310
+ if (!actorUserId || !interactionId || !actionId || !targetMessageId || !eventChatId || !eventDate || !data) {
35311
+ continue;
35312
+ }
35313
+ inboundChatId = eventChatId;
35314
+ if (actorUserId === meId)
35315
+ continue;
35316
+ callbackActionEvent = {
35317
+ interactionId,
35318
+ actionId,
35319
+ targetMessageId,
35320
+ data
35321
+ };
35322
+ msg = {
35323
+ id: targetMessageId,
35324
+ chatId: eventChatId,
35325
+ date: eventDate,
35326
+ fromId: actorUserId,
35327
+ message: "",
35328
+ out: false,
35329
+ mentioned: false,
35330
+ replyToMsgId: targetMessageId
35331
+ };
33917
35332
  } else {
33918
35333
  continue;
33919
35334
  }
33920
- const chatId = event.chatId;
35335
+ if (!inboundChatId)
35336
+ continue;
35337
+ const chatId = inboundChatId;
33921
35338
  statusSink?.({ lastInboundAt: Date.now() });
33922
35339
  let chatInfo;
33923
35340
  try {
@@ -33941,19 +35358,49 @@ async function monitorInlineProvider(params) {
33941
35358
  } else {
33942
35359
  rawBody = `${actor} removed ${emoji3} from your message #${messageId}`;
33943
35360
  }
35361
+ } else if (callbackActionEvent) {
35362
+ const actor = senderUsername != null && senderUsername.length > 0 ? `@${senderUsername}` : senderName ?? `user:${senderId}`;
35363
+ const payload = {
35364
+ type: "inline_message_action_callback",
35365
+ interaction_id: String(callbackActionEvent.interactionId),
35366
+ actor_user_id: senderId,
35367
+ chat_id: String(chatId),
35368
+ message_id: String(callbackActionEvent.targetMessageId),
35369
+ action_id: callbackActionEvent.actionId,
35370
+ data_base64: callbackDataToBase64(callbackActionEvent.data),
35371
+ data_utf8: callbackDataToUtf8(callbackActionEvent.data) ?? null
35372
+ };
35373
+ rawBody = `${actor} pressed a button on message #${String(callbackActionEvent.targetMessageId)}
35374
+ ${JSON.stringify(payload)}`;
33944
35375
  }
33945
35376
  const dmPolicy = account.config.dmPolicy ?? "pairing";
33946
35377
  const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
33947
35378
  const groupPolicy = account.config.groupPolicy ?? defaultGroupPolicy ?? "allowlist";
33948
35379
  const configAllowFrom = normalizeAllowlist(account.config.allowFrom);
33949
35380
  const configGroupAllowFrom = normalizeAllowlist(account.config.groupAllowFrom);
33950
- const storeAllowFrom = await core3.channel.pairing.readAllowFromStore(CHANNEL_ID).catch(() => []);
35381
+ const storeAllowFrom = await core3.channel.pairing.readAllowFromStore({
35382
+ channel: CHANNEL_ID,
35383
+ accountId: account.accountId
35384
+ }).catch(() => []);
33951
35385
  const storeAllowList = normalizeAllowlist(storeAllowFrom);
33952
35386
  const effectiveAllowFrom = [...configAllowFrom, ...storeAllowList].filter(Boolean);
33953
35387
  const effectiveGroupAllowFrom = [
33954
35388
  ...configGroupAllowFrom.length > 0 ? configGroupAllowFrom : configAllowFrom,
33955
35389
  ...storeAllowList
33956
35390
  ].filter(Boolean);
35391
+ const callbackCommandBody = callbackActionEvent ? resolveCallbackCommandBodyFromActionData({
35392
+ data: callbackActionEvent.data,
35393
+ ...botUsername ? { botUsername } : {}
35394
+ }) : undefined;
35395
+ let callbackActionAnswered = false;
35396
+ const answerCallbackIfNeeded = async () => {
35397
+ if (!callbackActionEvent || callbackActionAnswered)
35398
+ return;
35399
+ await answerInlineMessageAction(client, callbackActionEvent.interactionId);
35400
+ callbackActionAnswered = true;
35401
+ };
35402
+ const shouldEditCallbackTargetInPlace = false;
35403
+ const normalizedCommandBody = callbackCommandBody ?? normalizeInlineCommandBody(rawBody, botUsername);
33957
35404
  const allowTextCommands = core3.channel.commands.shouldHandleTextCommands({
33958
35405
  cfg,
33959
35406
  surface: CHANNEL_ID
@@ -33961,7 +35408,7 @@ async function monitorInlineProvider(params) {
33961
35408
  const useAccessGroups = cfg.commands?.useAccessGroups !== false;
33962
35409
  const allowForCommands = isGroup ? effectiveGroupAllowFrom : effectiveAllowFrom;
33963
35410
  const senderAllowedForCommands = allowlistMatch({ allowFrom: allowForCommands, senderId });
33964
- const hasControlCommand = core3.channel.text.hasControlCommand(rawBody, cfg, botUsername ? { botUsername } : undefined);
35411
+ const hasControlCommand = core3.channel.text.hasControlCommand(callbackCommandBody ?? rawBody, cfg, botUsername ? { botUsername } : undefined);
33965
35412
  const commandGate = resolveControlCommandGate({
33966
35413
  useAccessGroups,
33967
35414
  authorizers: [{ configured: allowForCommands.length > 0, allowed: senderAllowedForCommands }],
@@ -33972,18 +35419,27 @@ async function monitorInlineProvider(params) {
33972
35419
  if (isGroup) {
33973
35420
  if (groupPolicy === "disabled") {
33974
35421
  log?.info(`[${account.accountId}] inline: drop group chat=${String(chatId)} (groupPolicy=disabled)`);
35422
+ await answerCallbackIfNeeded().catch((error48) => {
35423
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35424
+ });
33975
35425
  continue;
33976
35426
  }
33977
35427
  if (groupPolicy === "allowlist") {
33978
35428
  const allowed = allowlistMatch({ allowFrom: effectiveGroupAllowFrom, senderId });
33979
35429
  if (!allowed) {
33980
35430
  log?.info(`[${account.accountId}] inline: drop group sender=${senderId} (groupPolicy=allowlist)`);
35431
+ await answerCallbackIfNeeded().catch((error48) => {
35432
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35433
+ });
33981
35434
  continue;
33982
35435
  }
33983
35436
  }
33984
35437
  } else {
33985
35438
  if (dmPolicy === "disabled") {
33986
35439
  log?.info(`[${account.accountId}] inline: drop DM sender=${senderId} (dmPolicy=disabled)`);
35440
+ await answerCallbackIfNeeded().catch((error48) => {
35441
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35442
+ });
33987
35443
  continue;
33988
35444
  }
33989
35445
  if (dmPolicy !== "open") {
@@ -33993,6 +35449,7 @@ async function monitorInlineProvider(params) {
33993
35449
  const { code, created } = await core3.channel.pairing.upsertPairingRequest({
33994
35450
  channel: CHANNEL_ID,
33995
35451
  id: senderId,
35452
+ accountId: account.accountId,
33996
35453
  meta: {},
33997
35454
  pairingAdapter: { idLabel: "inlineUserId", normalizeAllowEntry }
33998
35455
  });
@@ -34013,6 +35470,9 @@ async function monitorInlineProvider(params) {
34013
35470
  }
34014
35471
  }
34015
35472
  log?.info(`[${account.accountId}] inline: drop DM sender=${senderId} (dmPolicy=${dmPolicy})`);
35473
+ await answerCallbackIfNeeded().catch((error48) => {
35474
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35475
+ });
34016
35476
  continue;
34017
35477
  }
34018
35478
  }
@@ -34024,6 +35484,9 @@ async function monitorInlineProvider(params) {
34024
35484
  reason: "control command (unauthorized)",
34025
35485
  target: senderId
34026
35486
  });
35487
+ await answerCallbackIfNeeded().catch((error48) => {
35488
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35489
+ });
34027
35490
  continue;
34028
35491
  }
34029
35492
  const route = core3.channel.routing.resolveAgentRoute({
@@ -34036,7 +35499,12 @@ async function monitorInlineProvider(params) {
34036
35499
  }
34037
35500
  });
34038
35501
  const mentionRegexes = core3.channel.mentions.buildMentionRegexes(cfg, route.agentId);
34039
- const wasMentioned = typeof msg.mentioned === "boolean" ? msg.mentioned : mentionRegexes.length ? core3.channel.mentions.matchesMentionPatterns(rawBody, mentionRegexes) : false;
35502
+ const nativeMentioned = typeof msg.mentioned === "boolean" ? msg.mentioned : false;
35503
+ const patternMentioned = mentionRegexes.length ? core3.channel.mentions.matchesMentionPatterns(rawBody, mentionRegexes) : false;
35504
+ const wasMentioned = nativeMentioned || patternMentioned;
35505
+ const messageTimestamp = Number(msg.date) * 1000;
35506
+ const groupHistoryKey = isGroup ? route.sessionKey : null;
35507
+ const pendingHistorySender = senderUsername ? `@${senderUsername}` : senderName ?? `user:${senderId}`;
34040
35508
  const historyLimit = resolveHistoryLimit({
34041
35509
  isGroup,
34042
35510
  historyLimit: account.config.historyLimit,
@@ -34055,7 +35523,7 @@ async function monitorInlineProvider(params) {
34055
35523
  statusSink?.({ lastError: `getChatHistory failed: ${String(err)}` });
34056
35524
  return { historyText: null, attachmentText: null, entityText: null, repliedToBot: false, replyToSenderId: null };
34057
35525
  });
34058
- const implicitMention = reactionEvent != null && isGroup || isGroup && (account.config.replyToBotWithoutMention ?? false) && msg.replyToMsgId != null && historyContext.repliedToBot;
35526
+ const implicitMention = (reactionEvent != null || callbackActionEvent != null) && isGroup || isGroup && (account.config.replyToBotWithoutMention ?? false) && msg.replyToMsgId != null && historyContext.repliedToBot;
34059
35527
  const requireMention = isGroup ? resolveInlineGroupRequireMention({
34060
35528
  cfg,
34061
35529
  groupId: String(chatId),
@@ -34074,6 +35542,44 @@ async function monitorInlineProvider(params) {
34074
35542
  });
34075
35543
  if (isGroup && mentionGate.shouldSkip) {
34076
35544
  runtime2.log?.(`inline: drop group chat ${String(chatId)} (no mention)`);
35545
+ recordPendingHistoryEntryIfEnabled({
35546
+ historyMap: groupPendingHistories,
35547
+ historyKey: groupHistoryKey ?? "",
35548
+ limit: historyLimit,
35549
+ entry: groupHistoryKey && rawBody.trim() ? {
35550
+ sender: pendingHistorySender,
35551
+ body: rawBody.trim(),
35552
+ timestamp: messageTimestamp || Date.now(),
35553
+ messageId: String(msg.id)
35554
+ } : null
35555
+ });
35556
+ await answerCallbackIfNeeded().catch((error48) => {
35557
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35558
+ });
35559
+ continue;
35560
+ }
35561
+ const parseMarkdown = account.config.parseMarkdown ?? true;
35562
+ const nativeCommandMenu = resolveInlineCompatNativeCommandMenu(normalizedCommandBody);
35563
+ if (nativeCommandMenu) {
35564
+ const menuActions = resolveInlineReplyActions({
35565
+ channelData: {
35566
+ inline: {
35567
+ buttons: nativeCommandMenu.buttons
35568
+ }
35569
+ }
35570
+ });
35571
+ const sent = await client.sendMessage({
35572
+ chatId,
35573
+ text: nativeCommandMenu.title,
35574
+ ...menuActions ? { actions: menuActions } : {}
35575
+ });
35576
+ if (sent.messageId != null) {
35577
+ rememberBotMessageId(botMessageIdsByChat, chatId, sent.messageId);
35578
+ }
35579
+ statusSink?.({ lastOutboundAt: Date.now() });
35580
+ await answerCallbackIfNeeded().catch((error48) => {
35581
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35582
+ });
34077
35583
  continue;
34078
35584
  }
34079
35585
  const inboundMedia = reactionEvent ? [] : await resolveInlineInboundMedia({
@@ -34082,7 +35588,7 @@ async function monitorInlineProvider(params) {
34082
35588
  maxBytes: inboundMediaMaxBytes,
34083
35589
  ...log ? { log } : {}
34084
35590
  });
34085
- const timestamp = Number(msg.date) * 1000;
35591
+ const timestamp = messageTimestamp;
34086
35592
  const fromLabel = isGroup ? `chat:${chatInfo.title ?? String(chatId)}` : `user:${senderId}`;
34087
35593
  const storePath = core3.channel.session.resolveStorePath(cfg.session?.store, { agentId: route.agentId });
34088
35594
  const envelopeOptions = core3.channel.reply.resolveEnvelopeFormatOptions(cfg);
@@ -34101,7 +35607,7 @@ ${currentEntityText}` : null
34101
35607
  ].filter(Boolean).join(`
34102
35608
 
34103
35609
  `);
34104
- const body = core3.channel.reply.formatAgentEnvelope({
35610
+ let body = core3.channel.reply.formatAgentEnvelope({
34105
35611
  channel: "Inline",
34106
35612
  from: fromLabel,
34107
35613
  timestamp,
@@ -34109,11 +35615,30 @@ ${currentEntityText}` : null
34109
35615
  envelope: envelopeOptions,
34110
35616
  body: combinedBody || rawBody
34111
35617
  });
34112
- const commandBody = normalizeInlineCommandBody(rawBody, botUsername);
35618
+ if (isGroup && groupHistoryKey) {
35619
+ body = buildPendingHistoryContextFromMap({
35620
+ historyMap: groupPendingHistories,
35621
+ historyKey: groupHistoryKey,
35622
+ limit: historyLimit,
35623
+ currentMessage: body,
35624
+ formatEntry: (entry) => core3.channel.reply.formatAgentEnvelope({
35625
+ channel: "Inline",
35626
+ from: fromLabel,
35627
+ ...entry.timestamp != null ? { timestamp: entry.timestamp } : {},
35628
+ envelope: envelopeOptions,
35629
+ body: `${entry.body}${entry.messageId ? ` [id:${entry.messageId} chat:${String(chatId)}]` : ""}`
35630
+ })
35631
+ });
35632
+ }
35633
+ const effectiveSurface = shouldUseTelegramSurfaceForModelCommands(normalizedCommandBody) ? "telegram" : CHANNEL_ID;
35634
+ const systemPrompt = resolveInlineSystemPrompt({
35635
+ account,
35636
+ ...isGroup ? { groupId: String(chatId) } : {}
35637
+ });
34113
35638
  const ctxPayload = core3.channel.reply.finalizeInboundContext({
34114
35639
  Body: body,
34115
35640
  RawBody: rawBody,
34116
- CommandBody: commandBody,
35641
+ CommandBody: normalizedCommandBody,
34117
35642
  From: isGroup ? `inline:chat:${String(chatId)}` : `inline:${senderId}`,
34118
35643
  To: `inline:${String(chatId)}`,
34119
35644
  SessionKey: route.sessionKey,
@@ -34125,15 +35650,22 @@ ${currentEntityText}` : null
34125
35650
  ...senderName ? { SenderName: senderName } : {},
34126
35651
  ...senderUsername ? { SenderUsername: senderUsername } : {},
34127
35652
  Provider: CHANNEL_ID,
34128
- Surface: CHANNEL_ID,
35653
+ Surface: effectiveSurface,
34129
35654
  MessageSid: String(msg.id),
34130
35655
  ...msg.replyToMsgId != null ? { ReplyToId: String(msg.replyToMsgId) } : {},
34131
35656
  ...historyContext.replyToSenderId != null ? { ReplyToSenderId: historyContext.replyToSenderId } : {},
34132
35657
  ...msg.replyToMsgId != null ? { ReplyToWasBot: historyContext.repliedToBot } : {},
35658
+ ...callbackActionEvent ? {
35659
+ MessageActionInteractionId: String(callbackActionEvent.interactionId),
35660
+ MessageActionId: callbackActionEvent.actionId,
35661
+ MessageActionDataBase64: callbackDataToBase64(callbackActionEvent.data),
35662
+ ...callbackDataToUtf8(callbackActionEvent.data) ? { MessageActionDataUtf8: callbackDataToUtf8(callbackActionEvent.data) } : {}
35663
+ } : {},
34133
35664
  ...buildInlineInboundMediaPayload(inboundMedia),
34134
35665
  Timestamp: timestamp || Date.now(),
34135
35666
  WasMentioned: mentionGate.effectiveWasMentioned,
34136
35667
  CommandAuthorized: commandAuthorized,
35668
+ GroupSystemPrompt: systemPrompt,
34137
35669
  OriginatingChannel: CHANNEL_ID,
34138
35670
  OriginatingTo: `inline:${String(chatId)}`
34139
35671
  });
@@ -34165,8 +35697,7 @@ ${currentEntityText}` : null
34165
35697
  onStartError: (err) => runtime2.error?.(`inline typing start failed: ${String(err)}`),
34166
35698
  onStopError: (err) => runtime2.error?.(`inline typing stop failed: ${String(err)}`)
34167
35699
  }) : {};
34168
- const parseMarkdown = account.config.parseMarkdown ?? true;
34169
- const streamViaEditMessage = account.config.streamViaEditMessage === true;
35700
+ const streamViaEditMessage = account.config.streamViaEditMessage === true && !shouldEditCallbackTargetInPlace;
34170
35701
  const defaultReplyToMsgId = isGroup && msg.replyToMsgId != null ? msg.id : undefined;
34171
35702
  const disableBlockStreaming = streamViaEditMessage ? true : typeof account.config.blockStreaming === "boolean" ? !account.config.blockStreaming : undefined;
34172
35703
  const editStreamState = {
@@ -34237,118 +35768,149 @@ ${currentEntityText}` : null
34237
35768
  } : {},
34238
35769
  ...typeof disableBlockStreaming === "boolean" ? { disableBlockStreaming } : {}
34239
35770
  };
34240
- await core3.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
34241
- ctx: ctxPayload,
34242
- cfg,
34243
- dispatcherOptions: {
34244
- ...prefixOptions,
34245
- ...typingCallbacks,
34246
- deliver: async (payload) => {
34247
- const rawText = payload.text ?? "";
34248
- const mediaList = payload.mediaUrls?.length ? payload.mediaUrls : payload.mediaUrl ? [payload.mediaUrl] : [];
34249
- const outboundText = rewriteNumericMentionsToUsernames(rawText, senderProfilesById);
34250
- let replyToMsgId;
34251
- if (payload.replyToId != null) {
34252
- try {
34253
- replyToMsgId = BigInt(payload.replyToId);
34254
- } catch {}
34255
- }
34256
- if (replyToMsgId == null && isGroup && msg.replyToMsgId != null) {
34257
- replyToMsgId = msg.id;
34258
- }
34259
- const rememberSent = (messageId) => {
34260
- if (messageId != null) {
34261
- rememberBotMessageId(botMessageIdsByChat, chatId, messageId);
34262
- }
34263
- };
34264
- const sendTextFallback = async (text, includeReplyTo) => {
34265
- if (!text.trim())
34266
- return;
34267
- const sent = await client.sendMessage({
34268
- chatId,
34269
- text,
34270
- ...includeReplyTo && replyToMsgId != null ? { replyToMsgId } : {},
34271
- parseMarkdown
34272
- });
34273
- rememberSent(sent.messageId);
34274
- };
34275
- const updateStreamedMessage = async (text) => {
34276
- await editStreamState.opChain;
34277
- if (editStreamState.messageId == null)
34278
- return false;
34279
- const nextText = text.trim();
34280
- if (!nextText)
34281
- return true;
34282
- if (!editStreamState.failed && nextText === editStreamState.accumulatedText)
34283
- return true;
34284
- const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
34285
- oneofKind: "editMessage",
34286
- editMessage: {
34287
- messageId: editStreamState.messageId,
34288
- peerId: buildChatPeer(chatId),
34289
- text: nextText,
34290
- parseMarkdown
34291
- }
34292
- });
34293
- if (result.oneofKind !== "editMessage") {
34294
- throw new Error(`inline edit stream: expected editMessage result, got ${String(result.oneofKind)}`);
35771
+ try {
35772
+ await core3.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
35773
+ ctx: ctxPayload,
35774
+ cfg,
35775
+ dispatcherOptions: {
35776
+ ...prefixOptions,
35777
+ ...typingCallbacks,
35778
+ deliver: async (payload) => {
35779
+ const rawText = payload.text ?? "";
35780
+ const mediaList = payload.mediaUrls?.length ? payload.mediaUrls : payload.mediaUrl ? [payload.mediaUrl] : [];
35781
+ const outboundText = rewriteNumericMentionsToUsernames(rawText, senderProfilesById);
35782
+ const outboundActions = resolveInlineReplyActions(payload);
35783
+ let replyToMsgId;
35784
+ if (payload.replyToId != null) {
35785
+ try {
35786
+ replyToMsgId = BigInt(payload.replyToId);
35787
+ } catch {}
34295
35788
  }
34296
- editStreamState.accumulatedText = nextText;
34297
- editStreamState.lastPartialText = nextText;
34298
- editStreamState.failed = false;
34299
- return true;
34300
- };
34301
- if (mediaList.length === 0) {
34302
- if (!outboundText.trim())
34303
- return;
34304
- if (streamViaEditMessage && editStreamState.messageId != null) {
34305
- editStreamState.finalTextAccumulator += outboundText;
34306
- await updateStreamedMessage(editStreamState.finalTextAccumulator);
34307
- statusSink?.({ lastOutboundAt: Date.now() });
34308
- return;
35789
+ if (replyToMsgId == null && isGroup && msg.replyToMsgId != null) {
35790
+ replyToMsgId = msg.id;
34309
35791
  }
34310
- await sendTextFallback(outboundText, true);
34311
- statusSink?.({ lastOutboundAt: Date.now() });
34312
- return;
34313
- }
34314
- if (streamViaEditMessage && editStreamState.messageId != null && outboundText.trim()) {
34315
- await updateStreamedMessage(outboundText);
34316
- }
34317
- for (let index = 0;index < mediaList.length; index++) {
34318
- const mediaUrl = mediaList[index];
34319
- if (!mediaUrl?.trim())
34320
- continue;
34321
- const isFirst = index === 0;
34322
- const caption = isFirst && !(streamViaEditMessage && editStreamState.messageId != null) ? outboundText : "";
34323
- try {
34324
- const media = await uploadInlineMediaFromUrl({
34325
- client,
34326
- cfg,
34327
- accountId: account.accountId,
34328
- mediaUrl
34329
- });
35792
+ const rememberSent = (messageId) => {
35793
+ if (messageId != null) {
35794
+ rememberBotMessageId(botMessageIdsByChat, chatId, messageId);
35795
+ }
35796
+ };
35797
+ const sendTextFallback = async (text, includeReplyTo, includeActions) => {
35798
+ if (!text.trim())
35799
+ return;
34330
35800
  const sent = await client.sendMessage({
34331
35801
  chatId,
34332
- ...caption ? { text: caption } : {},
34333
- media,
34334
- ...isFirst && replyToMsgId != null ? { replyToMsgId } : {},
34335
- ...caption ? { parseMarkdown } : {}
35802
+ text,
35803
+ ...includeReplyTo && replyToMsgId != null ? { replyToMsgId } : {},
35804
+ ...includeActions && outboundActions !== undefined ? { actions: outboundActions } : {},
35805
+ parseMarkdown
34336
35806
  });
34337
35807
  rememberSent(sent.messageId);
34338
- } catch (error48) {
34339
- runtime2.error?.(`inline media upload failed; falling back to url text (${String(error48)})`);
34340
- const fallbackText = caption ? `${caption}
35808
+ };
35809
+ const updateStreamedMessage = async (text, actions) => {
35810
+ await editStreamState.opChain;
35811
+ if (editStreamState.messageId == null)
35812
+ return false;
35813
+ const nextText = text.trim();
35814
+ const textForEdit = nextText || editStreamState.accumulatedText;
35815
+ if (!textForEdit)
35816
+ return true;
35817
+ const shouldSkipTextUpdate = !editStreamState.failed && textForEdit === editStreamState.accumulatedText;
35818
+ if (shouldSkipTextUpdate && actions === undefined)
35819
+ return true;
35820
+ const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
35821
+ oneofKind: "editMessage",
35822
+ editMessage: {
35823
+ messageId: editStreamState.messageId,
35824
+ peerId: buildChatPeer(chatId),
35825
+ text: textForEdit,
35826
+ parseMarkdown,
35827
+ ...actions !== undefined ? { actions } : {}
35828
+ }
35829
+ });
35830
+ if (result.oneofKind !== "editMessage") {
35831
+ throw new Error(`inline edit stream: expected editMessage result, got ${String(result.oneofKind)}`);
35832
+ }
35833
+ if (!shouldSkipTextUpdate) {
35834
+ editStreamState.accumulatedText = textForEdit;
35835
+ editStreamState.lastPartialText = textForEdit;
35836
+ }
35837
+ editStreamState.failed = false;
35838
+ return true;
35839
+ };
35840
+ if (mediaList.length === 0) {
35841
+ if (streamViaEditMessage && editStreamState.messageId != null) {
35842
+ if (outboundText.trim()) {
35843
+ editStreamState.finalTextAccumulator += outboundText;
35844
+ }
35845
+ if (!editStreamState.finalTextAccumulator.trim() && outboundActions === undefined) {
35846
+ return;
35847
+ }
35848
+ await updateStreamedMessage(editStreamState.finalTextAccumulator, outboundActions);
35849
+ statusSink?.({ lastOutboundAt: Date.now() });
35850
+ return;
35851
+ }
35852
+ if (!outboundText.trim())
35853
+ return;
35854
+ await sendTextFallback(outboundText, true, true);
35855
+ statusSink?.({ lastOutboundAt: Date.now() });
35856
+ return;
35857
+ }
35858
+ if (streamViaEditMessage && editStreamState.messageId != null && outboundText.trim()) {
35859
+ await updateStreamedMessage(outboundText, outboundActions);
35860
+ }
35861
+ for (let index = 0;index < mediaList.length; index++) {
35862
+ const mediaUrl = mediaList[index];
35863
+ if (!mediaUrl?.trim())
35864
+ continue;
35865
+ const isFirst = index === 0;
35866
+ const shouldAttachActionsToMedia = isFirst && (!(streamViaEditMessage && editStreamState.messageId != null) || !outboundText.trim());
35867
+ const caption = isFirst && !(streamViaEditMessage && editStreamState.messageId != null) ? outboundText : "";
35868
+ try {
35869
+ const media = await uploadInlineMediaFromUrl({
35870
+ client,
35871
+ cfg,
35872
+ accountId: account.accountId,
35873
+ mediaUrl
35874
+ });
35875
+ const sent = await client.sendMessage({
35876
+ chatId,
35877
+ ...caption ? { text: caption } : {},
35878
+ media,
35879
+ ...isFirst && replyToMsgId != null ? { replyToMsgId } : {},
35880
+ ...shouldAttachActionsToMedia && outboundActions !== undefined ? { actions: outboundActions } : {},
35881
+ ...caption ? { parseMarkdown } : {}
35882
+ });
35883
+ rememberSent(sent.messageId);
35884
+ } catch (error48) {
35885
+ runtime2.error?.(`inline media upload failed; falling back to url text (${String(error48)})`);
35886
+ const fallbackText = caption ? `${caption}
34341
35887
 
34342
35888
  Attachment: ${mediaUrl}` : `Attachment: ${mediaUrl}`;
34343
- await sendTextFallback(fallbackText, isFirst);
35889
+ await sendTextFallback(fallbackText, isFirst, isFirst);
35890
+ }
34344
35891
  }
34345
- }
34346
- statusSink?.({ lastOutboundAt: Date.now() });
35892
+ statusSink?.({ lastOutboundAt: Date.now() });
35893
+ },
35894
+ onError: (err, info) => runtime2.error?.(`inline ${info.kind} reply failed: ${String(err)}`)
34347
35895
  },
34348
- onError: (err, info) => runtime2.error?.(`inline ${info.kind} reply failed: ${String(err)}`)
34349
- },
34350
- replyOptions
34351
- });
35896
+ replyOptions
35897
+ });
35898
+ } finally {
35899
+ if (callbackActionEvent && !callbackActionAnswered) {
35900
+ try {
35901
+ await answerCallbackIfNeeded();
35902
+ } catch (error48) {
35903
+ runtime2.error?.(`inline callback answer failed: ${String(error48)}`);
35904
+ }
35905
+ }
35906
+ }
35907
+ if (isGroup && groupHistoryKey) {
35908
+ clearHistoryEntriesIfEnabled({
35909
+ historyMap: groupPendingHistories,
35910
+ historyKey: groupHistoryKey,
35911
+ limit: historyLimit
35912
+ });
35913
+ }
34352
35914
  }
34353
35915
  } catch (err) {
34354
35916
  statusSink?.({ lastError: String(err) });
@@ -34477,6 +36039,77 @@ for (const group of ACTION_GROUPS) {
34477
36039
  }
34478
36040
  var SUPPORTED_ACTIONS = Array.from(ACTION_TO_GATE_KEY.keys());
34479
36041
  var GET_MESSAGES_METHOD2 = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
36042
+ var INLINE_ACTION_MAX_ROWS2 = 8;
36043
+ var INLINE_ACTION_MAX_PER_ROW2 = 8;
36044
+ function isRecord4(value) {
36045
+ return typeof value === "object" && value !== null;
36046
+ }
36047
+ function normalizeReplyMarkupButtons(raw) {
36048
+ if (!Array.isArray(raw))
36049
+ return [];
36050
+ const rows = [];
36051
+ for (const candidateRow of raw) {
36052
+ if (!Array.isArray(candidateRow))
36053
+ continue;
36054
+ const row = [];
36055
+ for (const candidateButton of candidateRow) {
36056
+ if (!isRecord4(candidateButton))
36057
+ continue;
36058
+ const text = typeof candidateButton.text === "string" ? candidateButton.text.trim() : "";
36059
+ const callbackData = typeof candidateButton.callback_data === "string" ? candidateButton.callback_data.trim() : "";
36060
+ if (!text || !callbackData)
36061
+ continue;
36062
+ row.push({ text, callback_data: callbackData });
36063
+ if (row.length >= INLINE_ACTION_MAX_PER_ROW2)
36064
+ break;
36065
+ }
36066
+ if (row.length === 0)
36067
+ continue;
36068
+ rows.push(row);
36069
+ if (rows.length >= INLINE_ACTION_MAX_ROWS2)
36070
+ break;
36071
+ }
36072
+ return rows;
36073
+ }
36074
+ function resolveInlineMessageActionsParam(params) {
36075
+ if (!Object.prototype.hasOwnProperty.call(params, "buttons")) {
36076
+ return;
36077
+ }
36078
+ let rawButtons = params.buttons;
36079
+ if (typeof rawButtons === "string") {
36080
+ const trimmed = rawButtons.trim();
36081
+ if (!trimmed) {
36082
+ rawButtons = [];
36083
+ } else {
36084
+ try {
36085
+ rawButtons = JSON.parse(trimmed);
36086
+ } catch {
36087
+ throw new Error("inline action: buttons must be valid JSON");
36088
+ }
36089
+ }
36090
+ }
36091
+ if (rawButtons == null) {
36092
+ rawButtons = [];
36093
+ }
36094
+ if (!Array.isArray(rawButtons)) {
36095
+ throw new Error("inline action: buttons must be an array of button rows");
36096
+ }
36097
+ const rows = normalizeReplyMarkupButtons(rawButtons);
36098
+ return {
36099
+ rows: rows.map((row, rowIndex) => ({
36100
+ actions: row.map((button, buttonIndex) => ({
36101
+ actionId: `btn_${rowIndex + 1}_${buttonIndex + 1}`,
36102
+ text: button.text,
36103
+ action: {
36104
+ oneofKind: "callback",
36105
+ callback: {
36106
+ data: new TextEncoder().encode(button.callback_data)
36107
+ }
36108
+ }
36109
+ }))
36110
+ }))
36111
+ };
36112
+ }
34480
36113
  function normalizeChatId(raw) {
34481
36114
  const normalized = normalizeInlineTarget(raw) ?? raw.trim();
34482
36115
  if (!/^[0-9]+$/.test(normalized)) {
@@ -35000,6 +36633,7 @@ var inlineMessageActions = {
35000
36633
  accountId,
35001
36634
  fn: async (client) => {
35002
36635
  const target = resolveMessageSendTargetFromParams(params);
36636
+ const actions = resolveInlineMessageActionsParam(params);
35003
36637
  const sendTarget = target.chatId != null ? { chatId: target.chatId } : target.userId != null ? { userId: target.userId } : null;
35004
36638
  if (!sendTarget) {
35005
36639
  throw new Error("inline action: missing message target");
@@ -35015,6 +36649,7 @@ var inlineMessageActions = {
35015
36649
  const sent = await client.sendMessage({
35016
36650
  ...sendTarget,
35017
36651
  text: message,
36652
+ ...actions !== undefined ? { actions } : {},
35018
36653
  ...replyToMsgId != null ? { replyToMsgId } : {},
35019
36654
  parseMarkdown
35020
36655
  });
@@ -35040,6 +36675,7 @@ var inlineMessageActions = {
35040
36675
  ...sendTarget,
35041
36676
  ...index === 0 && text ? { text } : {},
35042
36677
  media,
36678
+ ...index === 0 && actions !== undefined ? { actions } : {},
35043
36679
  ...index === 0 && replyToMsgId != null ? { replyToMsgId } : {},
35044
36680
  ...index === 0 && text ? { parseMarkdown } : {}
35045
36681
  });
@@ -35060,6 +36696,7 @@ var inlineMessageActions = {
35060
36696
  cfg,
35061
36697
  accountId,
35062
36698
  fn: async (client) => {
36699
+ const actions = resolveInlineMessageActionsParam(params);
35063
36700
  const replyParams = normalizedAction === "thread-reply" && params.threadId != null && params.to == null && params.chatId == null && params.channelId == null ? { ...params, to: params.threadId } : params;
35064
36701
  const chatId = resolveChatIdFromParams(replyParams);
35065
36702
  const replyToMsgId = parseInlineId(readFlexibleId(replyParams, "messageId") ?? readFlexibleId(replyParams, "replyTo") ?? readFlexibleId(replyParams, "replyToId") ?? readStringParam(replyParams, "messageId") ?? readStringParam(replyParams, "replyTo") ?? readStringParam(replyParams, "replyToId", { required: true }), "messageId");
@@ -35067,6 +36704,7 @@ var inlineMessageActions = {
35067
36704
  const sent = await client.sendMessage({
35068
36705
  chatId,
35069
36706
  text,
36707
+ ...actions !== undefined ? { actions } : {},
35070
36708
  replyToMsgId,
35071
36709
  parseMarkdown
35072
36710
  });
@@ -35212,6 +36850,7 @@ var inlineMessageActions = {
35212
36850
  accountId,
35213
36851
  fn: async (client) => {
35214
36852
  const chatId = resolveChatIdFromParams(params);
36853
+ const actions = resolveInlineMessageActionsParam(params);
35215
36854
  const messageId = parseInlineId(readFlexibleId(params, "messageId") ?? readStringParam(params, "messageId", { required: true }), "messageId");
35216
36855
  const text = readStringParam(params, "message", { required: true, allowEmpty: true });
35217
36856
  const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
@@ -35220,6 +36859,7 @@ var inlineMessageActions = {
35220
36859
  messageId,
35221
36860
  peerId: buildChatPeer2(chatId),
35222
36861
  text,
36862
+ ...actions !== undefined ? { actions } : {},
35223
36863
  parseMarkdown
35224
36864
  }
35225
36865
  });
@@ -36136,7 +37776,7 @@ var inlineChannelPlugin = {
36136
37776
  reply: true,
36137
37777
  groupManagement: true,
36138
37778
  threads: false,
36139
- nativeCommands: false,
37779
+ nativeCommands: true,
36140
37780
  blockStreaming: true
36141
37781
  },
36142
37782
  streaming: {
@@ -37039,6 +38679,500 @@ function createInlineMembersTool(ctx) {
37039
38679
  };
37040
38680
  }
37041
38681
 
38682
+ // src/inline/profile-tool.ts
38683
+ import {
38684
+ detectMime as detectMime2,
38685
+ loadWebMedia as loadWebMedia2
38686
+ } from "openclaw/plugin-sdk";
38687
+ var InlineProfileToolParameters = {
38688
+ type: "object",
38689
+ additionalProperties: false,
38690
+ properties: {
38691
+ name: {
38692
+ type: "string",
38693
+ description: "Optional new display name for the authenticated Inline bot."
38694
+ },
38695
+ photoUrl: {
38696
+ type: "string",
38697
+ description: "Optional remote image URL to upload as the bot profile photo."
38698
+ },
38699
+ photoPath: {
38700
+ type: "string",
38701
+ description: "Optional local image path to upload as the bot profile photo."
38702
+ },
38703
+ photoFileUniqueId: {
38704
+ type: "string",
38705
+ description: "Optional existing Inline file unique id to use as the bot profile photo."
38706
+ },
38707
+ accountId: {
38708
+ type: "string",
38709
+ description: "Optional Inline account id override."
38710
+ }
38711
+ }
38712
+ };
38713
+ function jsonResult4(payload) {
38714
+ return {
38715
+ content: [
38716
+ {
38717
+ type: "text",
38718
+ text: JSON.stringify(payload, (_key, value) => typeof value === "bigint" ? value.toString() : value, 2)
38719
+ }
38720
+ ],
38721
+ details: payload
38722
+ };
38723
+ }
38724
+ async function withInlineClient5(params) {
38725
+ const account = resolveInlineAccount({ cfg: params.cfg, accountId: params.accountId ?? null });
38726
+ if (!account.configured || !account.baseUrl) {
38727
+ throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
38728
+ }
38729
+ const token = await resolveInlineToken(account);
38730
+ const client = new InlineSdkClient({
38731
+ baseUrl: account.baseUrl,
38732
+ token
38733
+ });
38734
+ await client.connect();
38735
+ try {
38736
+ return await params.fn(client, account.accountId);
38737
+ } finally {
38738
+ await client.close().catch(() => {});
38739
+ }
38740
+ }
38741
+ function readTrimmedString(value) {
38742
+ if (typeof value !== "string")
38743
+ return;
38744
+ const trimmed = value.trim();
38745
+ return trimmed || undefined;
38746
+ }
38747
+ function resolvePhotoSource(args) {
38748
+ return readTrimmedString(args.photoPath) ?? readTrimmedString(args.photoUrl);
38749
+ }
38750
+ async function uploadProfilePhoto(client, rawSource) {
38751
+ const loaded = await loadWebMedia2(rawSource);
38752
+ const contentType = loaded.contentType ?? await detectMime2({
38753
+ buffer: loaded.buffer,
38754
+ ...loaded.fileName ? { filePath: loaded.fileName } : {}
38755
+ }) ?? undefined;
38756
+ const fileName = loaded.fileName?.trim() || "profile-photo.png";
38757
+ const uploaded = await client.uploadFile({
38758
+ type: "photo",
38759
+ file: loaded.buffer,
38760
+ fileName,
38761
+ ...contentType ? { contentType } : {}
38762
+ });
38763
+ if (!uploaded.fileUniqueId) {
38764
+ throw new Error("inline_update_profile: upload did not return fileUniqueId");
38765
+ }
38766
+ return uploaded.fileUniqueId;
38767
+ }
38768
+ function createInlineProfileTool(ctx) {
38769
+ if (!ctx.config) {
38770
+ return null;
38771
+ }
38772
+ return {
38773
+ name: "inline_update_profile",
38774
+ label: "Inline Update Profile",
38775
+ description: "Update the authenticated Inline bot profile name and/or profile photo.",
38776
+ parameters: InlineProfileToolParameters,
38777
+ execute: async (_toolCallId, rawArgs) => {
38778
+ const args = rawArgs;
38779
+ const name = readTrimmedString(args.name);
38780
+ const existingPhotoFileUniqueId = readTrimmedString(args.photoFileUniqueId);
38781
+ const photoSource = resolvePhotoSource(args);
38782
+ if (!name && !existingPhotoFileUniqueId && !photoSource) {
38783
+ throw new Error("inline_update_profile: provide `name` and/or `photo`");
38784
+ }
38785
+ return await withInlineClient5({
38786
+ cfg: ctx.config,
38787
+ accountId: args.accountId ?? ctx.agentAccountId ?? null,
38788
+ fn: async (client, resolvedAccountId) => {
38789
+ const me = await client.getMe();
38790
+ const photoFileUniqueId = existingPhotoFileUniqueId ?? (photoSource ? await uploadProfilePhoto(client, photoSource) : undefined);
38791
+ const result = await client.invokeRaw(Method.UPDATE_BOT_PROFILE, {
38792
+ oneofKind: "updateBotProfile",
38793
+ updateBotProfile: {
38794
+ botUserId: me.userId,
38795
+ ...name ? { name } : {},
38796
+ ...photoFileUniqueId ? { photoFileUniqueId } : {}
38797
+ }
38798
+ });
38799
+ if (result.oneofKind !== "updateBotProfile") {
38800
+ throw new Error(`inline_update_profile: expected updateBotProfile result, got ${String(result.oneofKind)}`);
38801
+ }
38802
+ return jsonResult4({
38803
+ ok: true,
38804
+ accountId: resolvedAccountId,
38805
+ botUserId: String(me.userId),
38806
+ updated: {
38807
+ ...name ? { name } : {},
38808
+ photo: photoFileUniqueId != null
38809
+ },
38810
+ bot: result.updateBotProfile.bot ?? null
38811
+ });
38812
+ }
38813
+ });
38814
+ }
38815
+ };
38816
+ }
38817
+
38818
+ // src/inline/bot-commands-tool.ts
38819
+ import { jsonResult as jsonResult5 } from "openclaw/plugin-sdk";
38820
+
38821
+ // src/inline/bot-commands-api.ts
38822
+ function normalizeInlineBotBaseUrl(baseUrl) {
38823
+ return baseUrl.replace(/\/+$/, "");
38824
+ }
38825
+ function normalizeInlineBotCommandName(raw) {
38826
+ return raw.trim().replace(/^\/+/, "");
38827
+ }
38828
+ async function callInlineBotApi(params) {
38829
+ const baseUrl = normalizeInlineBotBaseUrl(params.baseUrl);
38830
+ const invoke = async (authMode) => {
38831
+ const url2 = authMode === "header" ? `${baseUrl}/bot/${params.methodName}` : `${baseUrl}/bot${encodeURIComponent(params.token)}/${params.methodName}`;
38832
+ const request = {
38833
+ method: params.method,
38834
+ headers: {
38835
+ ...authMode === "header" ? { authorization: `Bearer ${params.token}` } : {},
38836
+ ...params.body !== undefined ? { "content-type": "application/json" } : {}
38837
+ }
38838
+ };
38839
+ if (params.body !== undefined) {
38840
+ request.body = JSON.stringify(params.body);
38841
+ }
38842
+ const response = await fetch(url2, request);
38843
+ const payload = await response.json().catch(() => null);
38844
+ return { response, payload };
38845
+ };
38846
+ const resolve = (result) => {
38847
+ if (!result.response.ok) {
38848
+ const message = result.payload?.description ?? `HTTP ${result.response.status}`;
38849
+ throw new Error(`inline_bot_commands: ${message}`);
38850
+ }
38851
+ if (!result.payload || result.payload.ok !== true) {
38852
+ const message = result.payload?.description ?? "bot api call failed";
38853
+ throw new Error(`inline_bot_commands: ${message}`);
38854
+ }
38855
+ return result.payload.result ?? {};
38856
+ };
38857
+ const shouldRetryWithPathToken = (result) => {
38858
+ if (result.response.status === 401)
38859
+ return true;
38860
+ if (result.payload?.error_code === 401)
38861
+ return true;
38862
+ const description = result.payload?.description?.toLowerCase() ?? "";
38863
+ return description.includes("unauthorized");
38864
+ };
38865
+ const headerResult = await invoke("header");
38866
+ if (shouldRetryWithPathToken(headerResult)) {
38867
+ const pathResult = await invoke("path");
38868
+ return resolve(pathResult);
38869
+ }
38870
+ return resolve(headerResult);
38871
+ }
38872
+
38873
+ // src/inline/bot-commands-tool.ts
38874
+ var BOT_COMMAND_LIMIT = 100;
38875
+ var BOT_COMMAND_RE = /^[a-z0-9_]+$/;
38876
+ var InlineBotCommandsToolParameters = {
38877
+ type: "object",
38878
+ additionalProperties: false,
38879
+ properties: {
38880
+ action: {
38881
+ type: "string",
38882
+ enum: ["get", "set", "delete"],
38883
+ description: "Command operation to run (`get`, `set`, or `delete`)."
38884
+ },
38885
+ commands: {
38886
+ type: "array",
38887
+ description: "Required for `set`. Telegram-style command list to register.",
38888
+ items: {
38889
+ type: "object",
38890
+ additionalProperties: false,
38891
+ properties: {
38892
+ command: {
38893
+ type: "string",
38894
+ description: "Slash command name without leading slash (`a-z`, `0-9`, `_`, max 32)."
38895
+ },
38896
+ description: {
38897
+ type: "string",
38898
+ description: "Human-friendly command description (max 256)."
38899
+ },
38900
+ sort_order: {
38901
+ type: "number",
38902
+ description: "Optional command ordering hint."
38903
+ }
38904
+ },
38905
+ required: ["command", "description"]
38906
+ }
38907
+ },
38908
+ accountId: {
38909
+ type: "string",
38910
+ description: "Optional Inline account id override."
38911
+ }
38912
+ },
38913
+ required: ["action"]
38914
+ };
38915
+ function parseSortOrder(raw, fallback) {
38916
+ if (typeof raw === "number" && Number.isFinite(raw)) {
38917
+ return Math.trunc(raw);
38918
+ }
38919
+ return fallback;
38920
+ }
38921
+ function normalizeCommands(raw) {
38922
+ if (!Array.isArray(raw)) {
38923
+ throw new Error("inline_bot_commands: `commands` must be an array");
38924
+ }
38925
+ if (raw.length > BOT_COMMAND_LIMIT) {
38926
+ throw new Error(`inline_bot_commands: too many commands (${raw.length}); max is ${BOT_COMMAND_LIMIT}`);
38927
+ }
38928
+ const seen = new Set;
38929
+ return raw.map((entry, index) => {
38930
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
38931
+ throw new Error(`inline_bot_commands: commands[${index}] must be an object`);
38932
+ }
38933
+ const row = entry;
38934
+ const rawCommand = row.command;
38935
+ const rawDescription = row.description;
38936
+ const rawSortOrder = row.sort_order ?? row.sortOrder;
38937
+ if (typeof rawCommand !== "string" || typeof rawDescription !== "string") {
38938
+ throw new Error(`inline_bot_commands: commands[${index}] requires string command and description`);
38939
+ }
38940
+ const command = normalizeInlineBotCommandName(rawCommand);
38941
+ const description = rawDescription.trim();
38942
+ if (command.length < 1 || command.length > 32 || !BOT_COMMAND_RE.test(command)) {
38943
+ throw new Error(`inline_bot_commands: commands[${index}].command must match /^[a-z0-9_]+$/ and be <= 32 chars`);
38944
+ }
38945
+ if (description.length < 1 || description.length > 256) {
38946
+ throw new Error(`inline_bot_commands: commands[${index}].description must be 1..256 chars`);
38947
+ }
38948
+ if (seen.has(command)) {
38949
+ throw new Error(`inline_bot_commands: duplicate command "${command}"`);
38950
+ }
38951
+ seen.add(command);
38952
+ const sortOrder = parseSortOrder(rawSortOrder, index);
38953
+ return {
38954
+ command,
38955
+ description,
38956
+ ...sortOrder !== index ? { sort_order: sortOrder } : {}
38957
+ };
38958
+ });
38959
+ }
38960
+ function createInlineBotCommandsTool(ctx) {
38961
+ if (!ctx.config) {
38962
+ return null;
38963
+ }
38964
+ return {
38965
+ name: "inline_bot_commands",
38966
+ label: "Inline Bot Commands",
38967
+ description: "Manage Inline bot slash commands via Bot API (`getMyCommands`, `setMyCommands`, `deleteMyCommands`).",
38968
+ parameters: InlineBotCommandsToolParameters,
38969
+ execute: async (_toolCallId, rawArgs) => {
38970
+ const args = rawArgs ?? {};
38971
+ const action = args.action;
38972
+ if (!action) {
38973
+ throw new Error("inline_bot_commands: `action` is required");
38974
+ }
38975
+ const account = resolveInlineAccount({
38976
+ cfg: ctx.config,
38977
+ accountId: args.accountId ?? ctx.agentAccountId ?? null
38978
+ });
38979
+ if (!account.configured || !account.baseUrl) {
38980
+ throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
38981
+ }
38982
+ const token = await resolveInlineToken(account);
38983
+ if (action === "get") {
38984
+ const result = await callInlineBotApi({
38985
+ baseUrl: account.baseUrl,
38986
+ token,
38987
+ methodName: "getMyCommands",
38988
+ method: "GET"
38989
+ });
38990
+ const commands = Array.isArray(result.commands) ? result.commands : [];
38991
+ return jsonResult5({
38992
+ ok: true,
38993
+ action,
38994
+ accountId: account.accountId,
38995
+ count: commands.length,
38996
+ commands
38997
+ });
38998
+ }
38999
+ if (action === "set") {
39000
+ const commands = normalizeCommands(args.commands);
39001
+ await callInlineBotApi({
39002
+ baseUrl: account.baseUrl,
39003
+ token,
39004
+ methodName: "setMyCommands",
39005
+ method: "POST",
39006
+ body: { commands }
39007
+ });
39008
+ return jsonResult5({
39009
+ ok: true,
39010
+ action,
39011
+ accountId: account.accountId,
39012
+ count: commands.length,
39013
+ commands
39014
+ });
39015
+ }
39016
+ await callInlineBotApi({
39017
+ baseUrl: account.baseUrl,
39018
+ token,
39019
+ methodName: "deleteMyCommands",
39020
+ method: "POST"
39021
+ });
39022
+ return jsonResult5({
39023
+ ok: true,
39024
+ action,
39025
+ accountId: account.accountId
39026
+ });
39027
+ }
39028
+ };
39029
+ }
39030
+
39031
+ // src/inline/bot-commands-sync.ts
39032
+ import * as pluginSdk from "openclaw/plugin-sdk";
39033
+ var INLINE_BASE_NATIVE_COMMANDS = [
39034
+ { command: "help", description: "Show available commands." },
39035
+ { command: "commands", description: "List all slash commands." },
39036
+ { command: "skill", description: "Run a skill by name." },
39037
+ { command: "status", description: "Show current status." },
39038
+ { command: "approve", description: "Approve or deny exec requests." },
39039
+ { command: "context", description: "Explain how context is built and used." },
39040
+ { command: "tts", description: "Control text-to-speech (TTS)." },
39041
+ { command: "whoami", description: "Show your sender id." },
39042
+ { command: "subagents", description: "List/stop/log/info subagent runs for this session." },
39043
+ { command: "usage", description: "Usage footer or cost summary." },
39044
+ { command: "stop", description: "Stop the current run." },
39045
+ { command: "restart", description: "Restart OpenClaw." },
39046
+ { command: "activation", description: "Set group activation mode." },
39047
+ { command: "send", description: "Set send policy." },
39048
+ { command: "reset", description: "Reset the current session." },
39049
+ { command: "new", description: "Start a new session." },
39050
+ { command: "compact", description: "Compact the session context." },
39051
+ { command: "think", description: "Set thinking level." },
39052
+ { command: "verbose", description: "Toggle verbose mode." },
39053
+ { command: "reasoning", description: "Toggle reasoning visibility." },
39054
+ { command: "elevated", description: "Toggle elevated mode." },
39055
+ { command: "exec", description: "Set exec defaults for this session." },
39056
+ { command: "model", description: "Show or set the model." },
39057
+ { command: "models", description: "List model providers or provider models." },
39058
+ { command: "queue", description: "Adjust queue settings." }
39059
+ ];
39060
+ var INLINE_COMMAND_NAME_RE = /^[a-z0-9_]{1,32}$/;
39061
+ var INLINE_COMMAND_LIMIT = 100;
39062
+ function getPluginSdkFunction(name) {
39063
+ const raw = pluginSdk[name];
39064
+ if (typeof raw !== "function")
39065
+ return null;
39066
+ return raw;
39067
+ }
39068
+ function normalizeDynamicCommandName(raw) {
39069
+ const trimmed = raw.trim().toLowerCase();
39070
+ const withoutSlash = trimmed.startsWith("/") ? trimmed.slice(1) : trimmed;
39071
+ return withoutSlash.trim();
39072
+ }
39073
+ function appendUniqueCommand(out, seen, command, description) {
39074
+ const normalized = normalizeDynamicCommandName(command);
39075
+ if (!INLINE_COMMAND_NAME_RE.test(normalized) || seen.has(normalized))
39076
+ return;
39077
+ const trimmedDescription = description.trim();
39078
+ if (!trimmedDescription)
39079
+ return;
39080
+ seen.add(normalized);
39081
+ out.push({ command: normalized, description: trimmedDescription });
39082
+ }
39083
+ function shouldSyncInlineNativeCommands(cfg) {
39084
+ const inlineNativeSetting = cfg.channels?.inline?.commands?.native;
39085
+ const effective = inlineNativeSetting ?? cfg.commands?.native ?? "auto";
39086
+ return effective !== false;
39087
+ }
39088
+ function shouldSyncInlineNativeSkills(cfg) {
39089
+ const inlineNativeSkillsSetting = cfg.channels?.inline?.commands?.nativeSkills;
39090
+ const effective = inlineNativeSkillsSetting ?? cfg.commands?.nativeSkills ?? "auto";
39091
+ return effective !== false;
39092
+ }
39093
+ function buildInlineNativeCommandsForConfig(cfg) {
39094
+ const listNativeCommandSpecsForConfig = getPluginSdkFunction("listNativeCommandSpecsForConfig");
39095
+ const listSkillCommandsForAgents = getPluginSdkFunction("listSkillCommandsForAgents");
39096
+ const getPluginCommandSpecs = getPluginSdkFunction("getPluginCommandSpecs");
39097
+ if (!listNativeCommandSpecsForConfig) {
39098
+ const commands2 = [...INLINE_BASE_NATIVE_COMMANDS];
39099
+ if (cfg.commands?.config === true) {
39100
+ commands2.push({ command: "config", description: "Show or set config values." });
39101
+ }
39102
+ if (cfg.commands?.debug === true) {
39103
+ commands2.push({ command: "debug", description: "Set runtime debug overrides." });
39104
+ }
39105
+ return commands2;
39106
+ }
39107
+ const skillCommands = shouldSyncInlineNativeSkills(cfg) && listSkillCommandsForAgents ? listSkillCommandsForAgents({ cfg }) : [];
39108
+ const nativeSpecs = listNativeCommandSpecsForConfig(cfg, { skillCommands });
39109
+ const pluginSpecs = getPluginCommandSpecs?.() ?? [];
39110
+ const commands = [];
39111
+ const seen = new Set;
39112
+ for (const spec of nativeSpecs) {
39113
+ appendUniqueCommand(commands, seen, spec.name, spec.description);
39114
+ }
39115
+ for (const spec of pluginSpecs) {
39116
+ appendUniqueCommand(commands, seen, spec.name, spec.description);
39117
+ }
39118
+ return commands;
39119
+ }
39120
+ function isSdkNativeCommandSourceAvailable() {
39121
+ return Boolean(getPluginSdkFunction("listNativeCommandSpecsForConfig"));
39122
+ }
39123
+ async function syncInlineNativeCommands(params) {
39124
+ const accountIds = listInlineAccountIds(params.cfg);
39125
+ const nativeEnabled = shouldSyncInlineNativeCommands(params.cfg);
39126
+ const usingSdkSource = isSdkNativeCommandSourceAvailable();
39127
+ const allCommands = nativeEnabled ? buildInlineNativeCommandsForConfig(params.cfg) : [];
39128
+ const commands = allCommands.slice(0, INLINE_COMMAND_LIMIT);
39129
+ if (allCommands.length > INLINE_COMMAND_LIMIT) {
39130
+ params.logger?.warn?.(`[inline] native command sync truncating ${allCommands.length} commands to ${INLINE_COMMAND_LIMIT}`);
39131
+ }
39132
+ params.logger?.info?.(`[inline] native command source: ${usingSdkSource ? "plugin-sdk" : "fallback"}`);
39133
+ let synced = 0;
39134
+ let failed = 0;
39135
+ for (const accountId of accountIds) {
39136
+ const account = resolveInlineAccount({ cfg: params.cfg, accountId });
39137
+ if (!account.enabled || !account.configured || !account.baseUrl) {
39138
+ continue;
39139
+ }
39140
+ let token;
39141
+ try {
39142
+ token = await resolveInlineToken(account);
39143
+ } catch (err) {
39144
+ failed += 1;
39145
+ params.logger?.warn?.(`[inline] native command sync skipped for account "${account.accountId}": ${String(err)}`);
39146
+ continue;
39147
+ }
39148
+ try {
39149
+ await callInlineBotApi({
39150
+ baseUrl: account.baseUrl,
39151
+ token,
39152
+ methodName: "deleteMyCommands",
39153
+ method: "POST"
39154
+ });
39155
+ await callInlineBotApi({
39156
+ baseUrl: account.baseUrl,
39157
+ token,
39158
+ methodName: "setMyCommands",
39159
+ method: "POST",
39160
+ body: { commands }
39161
+ });
39162
+ synced += 1;
39163
+ params.logger?.info?.(`[inline] native commands synced for account "${account.accountId}" (${commands.length} command${commands.length === 1 ? "" : "s"})`);
39164
+ } catch (err) {
39165
+ failed += 1;
39166
+ params.logger?.warn?.(`[inline] native command sync failed for account "${account.accountId}": ${String(err)}`);
39167
+ }
39168
+ }
39169
+ return {
39170
+ attempted: accountIds.length,
39171
+ synced,
39172
+ failed
39173
+ };
39174
+ }
39175
+
37042
39176
  // src/index.ts
37043
39177
  var plugin = {
37044
39178
  id: "inline",
@@ -37051,9 +39185,29 @@ var plugin = {
37051
39185
  api2.registerTool((ctx) => createInlineMembersTool(ctx), {
37052
39186
  names: ["inline_members"]
37053
39187
  });
39188
+ api2.registerTool((ctx) => createInlineProfileTool(ctx), {
39189
+ names: ["inline_update_profile"]
39190
+ });
39191
+ api2.registerTool((ctx) => createInlineBotCommandsTool(ctx), {
39192
+ names: ["inline_bot_commands"]
39193
+ });
37054
39194
  api2.registerTool((ctx) => createInlineMessageTools(ctx), {
37055
39195
  names: ["inline_nudge", "inline_forward"]
37056
39196
  });
39197
+ api2.on("message_sending", (event, ctx) => {
39198
+ if (ctx.channelId !== "inline")
39199
+ return;
39200
+ const content = sanitizeInlineOutgoingText(event.content);
39201
+ if (content === event.content)
39202
+ return;
39203
+ return { content };
39204
+ });
39205
+ api2.on("gateway_start", async () => {
39206
+ await syncInlineNativeCommands({
39207
+ cfg: api2.config,
39208
+ logger: api2.logger
39209
+ });
39210
+ });
37057
39211
  }
37058
39212
  };
37059
39213
  var src_default = plugin;
@@ -37061,5 +39215,5 @@ export {
37061
39215
  src_default as default
37062
39216
  };
37063
39217
 
37064
- //# debugId=ADE72751DC5C086C64756E2164756E21
39218
+ //# debugId=ECFAEB3746DF293B64756E2164756E21
37065
39219
  //# sourceMappingURL=index.js.map