@inline-openclaw/inline 0.0.38 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +36 -25
  2. package/dist/account-inspect-api.js +34 -7
  3. package/dist/account-inspect-api.js.map +4 -4
  4. package/dist/approval-handler.runtime.js +1550 -205
  5. package/dist/approval-handler.runtime.js.map +16 -15
  6. package/dist/channel-plugin-api.js +2356 -364
  7. package/dist/channel-plugin-api.js.map +19 -17
  8. package/dist/index.d.ts +1 -1
  9. package/dist/inline/accounts.d.ts.map +1 -1
  10. package/dist/inline/actions.d.ts +1 -1
  11. package/dist/inline/actions.d.ts.map +1 -1
  12. package/dist/inline/approval-native.d.ts.map +1 -1
  13. package/dist/inline/channel.d.ts.map +1 -1
  14. package/dist/inline/config-schema.d.ts +125 -0
  15. package/dist/inline/config-schema.d.ts.map +1 -1
  16. package/dist/inline/exec-approvals.d.ts.map +1 -1
  17. package/dist/inline/message-tools.d.ts.map +1 -1
  18. package/dist/inline/monitor.d.ts.map +1 -1
  19. package/dist/inline/parent-context-tool.d.ts +10 -0
  20. package/dist/inline/parent-context-tool.d.ts.map +1 -0
  21. package/dist/inline/policy.d.ts +30 -1
  22. package/dist/inline/policy.d.ts.map +1 -1
  23. package/dist/inline/reply-threads.d.ts +12 -0
  24. package/dist/inline/reply-threads.d.ts.map +1 -1
  25. package/dist/inline/shared.d.ts +1 -1
  26. package/dist/inline/thread-participation.d.ts +10 -0
  27. package/dist/inline/thread-participation.d.ts.map +1 -0
  28. package/dist/inline/thread-routes.d.ts +28 -0
  29. package/dist/inline/thread-routes.d.ts.map +1 -0
  30. package/dist/inline/tool-targets.d.ts +36 -0
  31. package/dist/inline/tool-targets.d.ts.map +1 -0
  32. package/dist/runtime-register-api.d.ts.map +1 -1
  33. package/dist/runtime-register-api.js +1891 -152
  34. package/dist/runtime-register-api.js.map +19 -15
  35. package/dist/runtime-setter-api.js +11 -15
  36. package/dist/runtime-setter-api.js.map +3 -3
  37. package/dist/runtime.d.ts +2 -2
  38. package/dist/runtime.d.ts.map +1 -1
  39. package/dist/setup-entry.d.ts +1 -1
  40. package/dist/setup-plugin-api.js +34 -7
  41. package/dist/setup-plugin-api.js.map +4 -4
  42. package/openclaw.plugin.json +725 -58
  43. package/package.json +6 -6
@@ -2695,7 +2695,7 @@ var require_commonjs = __commonJS((exports) => {
2695
2695
  } });
2696
2696
  });
2697
2697
 
2698
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/constants.js
2698
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/constants.js
2699
2699
  var require_constants = __commonJS((exports, module) => {
2700
2700
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
2701
2701
  var hasBlob = typeof Blob !== "undefined";
@@ -2715,7 +2715,7 @@ var require_constants = __commonJS((exports, module) => {
2715
2715
  };
2716
2716
  });
2717
2717
 
2718
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/buffer-util.js
2718
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/buffer-util.js
2719
2719
  var require_buffer_util = __commonJS((exports, module) => {
2720
2720
  var { EMPTY_BUFFER } = require_constants();
2721
2721
  var FastBuffer = Buffer[Symbol.species];
@@ -2793,7 +2793,7 @@ var require_buffer_util = __commonJS((exports, module) => {
2793
2793
  }
2794
2794
  });
2795
2795
 
2796
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/limiter.js
2796
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/limiter.js
2797
2797
  var require_limiter = __commonJS((exports, module) => {
2798
2798
  var kDone = Symbol("kDone");
2799
2799
  var kRun = Symbol("kRun");
@@ -2825,7 +2825,7 @@ var require_limiter = __commonJS((exports, module) => {
2825
2825
  module.exports = Limiter;
2826
2826
  });
2827
2827
 
2828
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/permessage-deflate.js
2828
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/permessage-deflate.js
2829
2829
  var require_permessage_deflate = __commonJS((exports, module) => {
2830
2830
  var zlib = __require("zlib");
2831
2831
  var bufferUtil = require_buffer_util();
@@ -3089,7 +3089,7 @@ var require_permessage_deflate = __commonJS((exports, module) => {
3089
3089
  }
3090
3090
  });
3091
3091
 
3092
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/validation.js
3092
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/validation.js
3093
3093
  var require_validation = __commonJS((exports, module) => {
3094
3094
  var { isUtf8 } = __require("buffer");
3095
3095
  var { hasBlob } = require_constants();
@@ -3276,7 +3276,7 @@ var require_validation = __commonJS((exports, module) => {
3276
3276
  }
3277
3277
  });
3278
3278
 
3279
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/receiver.js
3279
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/receiver.js
3280
3280
  var require_receiver = __commonJS((exports, module) => {
3281
3281
  var { Writable } = __require("stream");
3282
3282
  var PerMessageDeflate = require_permessage_deflate();
@@ -3304,6 +3304,8 @@ var require_receiver = __commonJS((exports, module) => {
3304
3304
  this._binaryType = options.binaryType || BINARY_TYPES[0];
3305
3305
  this._extensions = options.extensions || {};
3306
3306
  this._isServer = !!options.isServer;
3307
+ this._maxBufferedChunks = options.maxBufferedChunks | 0;
3308
+ this._maxFragments = options.maxFragments | 0;
3307
3309
  this._maxPayload = options.maxPayload | 0;
3308
3310
  this._skipUTF8Validation = !!options.skipUTF8Validation;
3309
3311
  this[kWebSocket] = undefined;
@@ -3326,6 +3328,10 @@ var require_receiver = __commonJS((exports, module) => {
3326
3328
  _write(chunk, encoding, cb) {
3327
3329
  if (this._opcode === 8 && this._state == GET_INFO)
3328
3330
  return cb();
3331
+ if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
3332
+ cb(this.createError(RangeError, "Too many buffered chunks", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
3333
+ return;
3334
+ }
3329
3335
  this._bufferedBytes += chunk.length;
3330
3336
  this._buffers.push(chunk);
3331
3337
  this.startLoop(cb);
@@ -3529,6 +3535,11 @@ var require_receiver = __commonJS((exports, module) => {
3529
3535
  return;
3530
3536
  }
3531
3537
  if (data.length) {
3538
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
3539
+ const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
3540
+ cb(error);
3541
+ return;
3542
+ }
3532
3543
  this._messageLength = this._totalPayloadLength;
3533
3544
  this._fragments.push(data);
3534
3545
  }
@@ -3546,6 +3557,11 @@ var require_receiver = __commonJS((exports, module) => {
3546
3557
  cb(error);
3547
3558
  return;
3548
3559
  }
3560
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
3561
+ const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
3562
+ cb(error);
3563
+ return;
3564
+ }
3549
3565
  this._fragments.push(buf);
3550
3566
  }
3551
3567
  this.dataMessage(cb);
@@ -3657,7 +3673,7 @@ var require_receiver = __commonJS((exports, module) => {
3657
3673
  module.exports = Receiver;
3658
3674
  });
3659
3675
 
3660
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/sender.js
3676
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/sender.js
3661
3677
  var require_sender = __commonJS((exports, module) => {
3662
3678
  var { Duplex } = __require("stream");
3663
3679
  var { randomFillSync } = __require("crypto");
@@ -4016,7 +4032,7 @@ var require_sender = __commonJS((exports, module) => {
4016
4032
  }
4017
4033
  });
4018
4034
 
4019
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/event-target.js
4035
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/event-target.js
4020
4036
  var require_event_target = __commonJS((exports, module) => {
4021
4037
  var { kForOnEventAttribute, kListener } = require_constants();
4022
4038
  var kCode = Symbol("kCode");
@@ -4167,7 +4183,7 @@ var require_event_target = __commonJS((exports, module) => {
4167
4183
  }
4168
4184
  });
4169
4185
 
4170
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/extension.js
4186
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/extension.js
4171
4187
  var require_extension = __commonJS((exports, module) => {
4172
4188
  var { tokenChars } = require_validation();
4173
4189
  function push(dest, name, elem) {
@@ -4332,7 +4348,7 @@ var require_extension = __commonJS((exports, module) => {
4332
4348
  module.exports = { format, parse };
4333
4349
  });
4334
4350
 
4335
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/websocket.js
4351
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/websocket.js
4336
4352
  var require_websocket = __commonJS((exports, module) => {
4337
4353
  var EventEmitter = __require("events");
4338
4354
  var https = __require("https");
@@ -4453,6 +4469,8 @@ var require_websocket = __commonJS((exports, module) => {
4453
4469
  binaryType: this.binaryType,
4454
4470
  extensions: this._extensions,
4455
4471
  isServer: this._isServer,
4472
+ maxBufferedChunks: options.maxBufferedChunks,
4473
+ maxFragments: options.maxFragments,
4456
4474
  maxPayload: options.maxPayload,
4457
4475
  skipUTF8Validation: options.skipUTF8Validation
4458
4476
  });
@@ -4695,6 +4713,8 @@ var require_websocket = __commonJS((exports, module) => {
4695
4713
  autoPong: true,
4696
4714
  closeTimeout: CLOSE_TIMEOUT,
4697
4715
  protocolVersion: protocolVersions[1],
4716
+ maxBufferedChunks: 1024 * 1024,
4717
+ maxFragments: 128 * 1024,
4698
4718
  maxPayload: 100 * 1024 * 1024,
4699
4719
  skipUTF8Validation: false,
4700
4720
  perMessageDeflate: true,
@@ -4933,6 +4953,8 @@ var require_websocket = __commonJS((exports, module) => {
4933
4953
  websocket.setSocket(socket, head, {
4934
4954
  allowSynchronousEvents: opts.allowSynchronousEvents,
4935
4955
  generateMask: opts.generateMask,
4956
+ maxBufferedChunks: opts.maxBufferedChunks,
4957
+ maxFragments: opts.maxFragments,
4936
4958
  maxPayload: opts.maxPayload,
4937
4959
  skipUTF8Validation: opts.skipUTF8Validation
4938
4960
  });
@@ -5098,7 +5120,7 @@ var require_websocket = __commonJS((exports, module) => {
5098
5120
  }
5099
5121
  });
5100
5122
 
5101
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/stream.js
5123
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/stream.js
5102
5124
  var require_stream = __commonJS((exports, module) => {
5103
5125
  var WebSocket = require_websocket();
5104
5126
  var { Duplex } = __require("stream");
@@ -5201,7 +5223,7 @@ var require_stream = __commonJS((exports, module) => {
5201
5223
  module.exports = createWebSocketStream;
5202
5224
  });
5203
5225
 
5204
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/subprotocol.js
5226
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/subprotocol.js
5205
5227
  var require_subprotocol = __commonJS((exports, module) => {
5206
5228
  var { tokenChars } = require_validation();
5207
5229
  function parse(header) {
@@ -5246,7 +5268,7 @@ var require_subprotocol = __commonJS((exports, module) => {
5246
5268
  module.exports = { parse };
5247
5269
  });
5248
5270
 
5249
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/websocket-server.js
5271
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/websocket-server.js
5250
5272
  var require_websocket_server = __commonJS((exports, module) => {
5251
5273
  var EventEmitter = __require("events");
5252
5274
  var http = __require("http");
@@ -5268,6 +5290,8 @@ var require_websocket_server = __commonJS((exports, module) => {
5268
5290
  options = {
5269
5291
  allowSynchronousEvents: true,
5270
5292
  autoPong: true,
5293
+ maxBufferedChunks: 1024 * 1024,
5294
+ maxFragments: 128 * 1024,
5271
5295
  maxPayload: 100 * 1024 * 1024,
5272
5296
  skipUTF8Validation: false,
5273
5297
  perMessageDeflate: false,
@@ -5494,6 +5518,8 @@ var require_websocket_server = __commonJS((exports, module) => {
5494
5518
  socket.removeListener("error", socketOnError);
5495
5519
  ws.setSocket(socket, head, {
5496
5520
  allowSynchronousEvents: this.options.allowSynchronousEvents,
5521
+ maxBufferedChunks: this.options.maxBufferedChunks,
5522
+ maxFragments: this.options.maxFragments,
5497
5523
  maxPayload: this.options.maxPayload,
5498
5524
  skipUTF8Validation: this.options.skipUTF8Validation
5499
5525
  });
@@ -5587,6 +5613,8 @@ var MessageEntity_Type;
5587
5613
  MessageEntity_Type2[MessageEntity_Type2["CODE"] = 8] = "CODE";
5588
5614
  MessageEntity_Type2[MessageEntity_Type2["PRE"] = 9] = "PRE";
5589
5615
  MessageEntity_Type2[MessageEntity_Type2["PHONE_NUMBER"] = 10] = "PHONE_NUMBER";
5616
+ MessageEntity_Type2[MessageEntity_Type2["THREAD"] = 11] = "THREAD";
5617
+ MessageEntity_Type2[MessageEntity_Type2["THREAD_TITLE"] = 12] = "THREAD_TITLE";
5590
5618
  })(MessageEntity_Type || (MessageEntity_Type = {}));
5591
5619
  var Member_Role;
5592
5620
  (function(Member_Role2) {
@@ -5594,6 +5622,15 @@ var Member_Role;
5594
5622
  Member_Role2[Member_Role2["ADMIN"] = 1] = "ADMIN";
5595
5623
  Member_Role2[Member_Role2["MEMBER"] = 2] = "MEMBER";
5596
5624
  })(Member_Role || (Member_Role = {}));
5625
+ var UrlPreview_MediaType;
5626
+ (function(UrlPreview_MediaType2) {
5627
+ UrlPreview_MediaType2[UrlPreview_MediaType2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
5628
+ UrlPreview_MediaType2[UrlPreview_MediaType2["ARTICLE"] = 1] = "ARTICLE";
5629
+ UrlPreview_MediaType2[UrlPreview_MediaType2["IMAGE"] = 2] = "IMAGE";
5630
+ UrlPreview_MediaType2[UrlPreview_MediaType2["VIDEO"] = 3] = "VIDEO";
5631
+ UrlPreview_MediaType2[UrlPreview_MediaType2["DOCUMENT"] = 4] = "DOCUMENT";
5632
+ UrlPreview_MediaType2[UrlPreview_MediaType2["EMBED"] = 5] = "EMBED";
5633
+ })(UrlPreview_MediaType || (UrlPreview_MediaType = {}));
5597
5634
  var MessageAttachmentExternalTask_Status;
5598
5635
  (function(MessageAttachmentExternalTask_Status2) {
5599
5636
  MessageAttachmentExternalTask_Status2[MessageAttachmentExternalTask_Status2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
@@ -5736,6 +5773,9 @@ var Method;
5736
5773
  Method2[Method2["REVOKE_SESSION"] = 50] = "REVOKE_SESSION";
5737
5774
  Method2[Method2["UPDATE_DIALOG_OPEN"] = 51] = "UPDATE_DIALOG_OPEN";
5738
5775
  Method2[Method2["UPDATE_DIALOG_ORDER"] = 52] = "UPDATE_DIALOG_ORDER";
5776
+ Method2[Method2["CLEAR_CHAT_HISTORY"] = 53] = "CLEAR_CHAT_HISTORY";
5777
+ Method2[Method2["DELETE_BOT"] = 54] = "DELETE_BOT";
5778
+ Method2[Method2["DELETE_MESSAGE_ATTACHMENT"] = 55] = "DELETE_MESSAGE_ATTACHMENT";
5739
5779
  })(Method || (Method = {}));
5740
5780
  var PushNotificationProvider;
5741
5781
  (function(PushNotificationProvider2) {
@@ -7705,7 +7745,9 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7705
7745
  { no: 3, name: "length", kind: "scalar", T: 3, L: 0 },
7706
7746
  { no: 4, name: "mention", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityMention },
7707
7747
  { no: 5, name: "text_url", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityTextUrl },
7708
- { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre }
7748
+ { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre },
7749
+ { no: 7, name: "thread", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityThread },
7750
+ { no: 8, name: "thread_title", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityThreadTitle }
7709
7751
  ]);
7710
7752
  }
7711
7753
  create(value) {
@@ -7750,6 +7792,18 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7750
7792
  pre: MessageEntity_MessageEntityPre.internalBinaryRead(reader, reader.uint32(), options, message.entity.pre)
7751
7793
  };
7752
7794
  break;
7795
+ case 7:
7796
+ message.entity = {
7797
+ oneofKind: "thread",
7798
+ thread: MessageEntity_MessageEntityThread.internalBinaryRead(reader, reader.uint32(), options, message.entity.thread)
7799
+ };
7800
+ break;
7801
+ case 8:
7802
+ message.entity = {
7803
+ oneofKind: "threadTitle",
7804
+ threadTitle: MessageEntity_MessageEntityThreadTitle.internalBinaryRead(reader, reader.uint32(), options, message.entity.threadTitle)
7805
+ };
7806
+ break;
7753
7807
  default:
7754
7808
  let u = options.readUnknownField;
7755
7809
  if (u === "throw")
@@ -7774,6 +7828,10 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7774
7828
  MessageEntity_MessageEntityTextUrl.internalBinaryWrite(message.entity.textUrl, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
7775
7829
  if (message.entity.oneofKind === "pre")
7776
7830
  MessageEntity_MessageEntityPre.internalBinaryWrite(message.entity.pre, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
7831
+ if (message.entity.oneofKind === "thread")
7832
+ MessageEntity_MessageEntityThread.internalBinaryWrite(message.entity.thread, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
7833
+ if (message.entity.oneofKind === "threadTitle")
7834
+ MessageEntity_MessageEntityThreadTitle.internalBinaryWrite(message.entity.threadTitle, writer.tag(8, import_runtime.WireType.LengthDelimited).fork(), options).join();
7777
7835
  let u = options.writeUnknownFields;
7778
7836
  if (u !== false)
7779
7837
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -7911,6 +7969,99 @@ class MessageEntity_MessageEntityPre$Type extends import_runtime4.MessageType {
7911
7969
  }
7912
7970
  var MessageEntity_MessageEntityPre = new MessageEntity_MessageEntityPre$Type;
7913
7971
 
7972
+ class MessageEntity_MessageEntityThread$Type extends import_runtime4.MessageType {
7973
+ constructor() {
7974
+ super("MessageEntity.MessageEntityThread", [
7975
+ { no: 1, name: "chat_id", kind: "scalar", T: 3, L: 0 }
7976
+ ]);
7977
+ }
7978
+ create(value) {
7979
+ const message = globalThis.Object.create(this.messagePrototype);
7980
+ message.chatId = 0n;
7981
+ if (value !== undefined)
7982
+ import_runtime3.reflectionMergePartial(this, message, value);
7983
+ return message;
7984
+ }
7985
+ internalBinaryRead(reader, length, options, target) {
7986
+ let message = target ?? this.create(), end = reader.pos + length;
7987
+ while (reader.pos < end) {
7988
+ let [fieldNo, wireType] = reader.tag();
7989
+ switch (fieldNo) {
7990
+ case 1:
7991
+ message.chatId = reader.int64().toBigInt();
7992
+ break;
7993
+ default:
7994
+ let u = options.readUnknownField;
7995
+ if (u === "throw")
7996
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7997
+ let d = reader.skip(wireType);
7998
+ if (u !== false)
7999
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8000
+ }
8001
+ }
8002
+ return message;
8003
+ }
8004
+ internalBinaryWrite(message, writer, options) {
8005
+ if (message.chatId !== 0n)
8006
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.chatId);
8007
+ let u = options.writeUnknownFields;
8008
+ if (u !== false)
8009
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8010
+ return writer;
8011
+ }
8012
+ }
8013
+ var MessageEntity_MessageEntityThread = new MessageEntity_MessageEntityThread$Type;
8014
+
8015
+ class MessageEntity_MessageEntityThreadTitle$Type extends import_runtime4.MessageType {
8016
+ constructor() {
8017
+ super("MessageEntity.MessageEntityThreadTitle", [
8018
+ { no: 1, name: "space_id", kind: "scalar", T: 3, L: 0 },
8019
+ { no: 2, name: "title", kind: "scalar", T: 9 }
8020
+ ]);
8021
+ }
8022
+ create(value) {
8023
+ const message = globalThis.Object.create(this.messagePrototype);
8024
+ message.spaceId = 0n;
8025
+ message.title = "";
8026
+ if (value !== undefined)
8027
+ import_runtime3.reflectionMergePartial(this, message, value);
8028
+ return message;
8029
+ }
8030
+ internalBinaryRead(reader, length, options, target) {
8031
+ let message = target ?? this.create(), end = reader.pos + length;
8032
+ while (reader.pos < end) {
8033
+ let [fieldNo, wireType] = reader.tag();
8034
+ switch (fieldNo) {
8035
+ case 1:
8036
+ message.spaceId = reader.int64().toBigInt();
8037
+ break;
8038
+ case 2:
8039
+ message.title = reader.string();
8040
+ break;
8041
+ default:
8042
+ let u = options.readUnknownField;
8043
+ if (u === "throw")
8044
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8045
+ let d = reader.skip(wireType);
8046
+ if (u !== false)
8047
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8048
+ }
8049
+ }
8050
+ return message;
8051
+ }
8052
+ internalBinaryWrite(message, writer, options) {
8053
+ if (message.spaceId !== 0n)
8054
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.spaceId);
8055
+ if (message.title !== "")
8056
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.title);
8057
+ let u = options.writeUnknownFields;
8058
+ if (u !== false)
8059
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8060
+ return writer;
8061
+ }
8062
+ }
8063
+ var MessageEntity_MessageEntityThreadTitle = new MessageEntity_MessageEntityThreadTitle$Type;
8064
+
7914
8065
  class MessageReactions$Type extends import_runtime4.MessageType {
7915
8066
  constructor() {
7916
8067
  super("MessageReactions", [
@@ -8108,7 +8259,8 @@ class Space$Type extends import_runtime4.MessageType {
8108
8259
  { no: 1, name: "id", kind: "scalar", T: 3, L: 0 },
8109
8260
  { no: 2, name: "name", kind: "scalar", T: 9 },
8110
8261
  { no: 3, name: "creator", kind: "scalar", T: 8 },
8111
- { no: 4, name: "date", kind: "scalar", T: 3, L: 0 }
8262
+ { no: 4, name: "date", kind: "scalar", T: 3, L: 0 },
8263
+ { no: 5, name: "is_public", kind: "scalar", opt: true, T: 8 }
8112
8264
  ]);
8113
8265
  }
8114
8266
  create(value) {
@@ -8138,6 +8290,9 @@ class Space$Type extends import_runtime4.MessageType {
8138
8290
  case 4:
8139
8291
  message.date = reader.int64().toBigInt();
8140
8292
  break;
8293
+ case 5:
8294
+ message.isPublic = reader.bool();
8295
+ break;
8141
8296
  default:
8142
8297
  let u = options.readUnknownField;
8143
8298
  if (u === "throw")
@@ -8158,6 +8313,8 @@ class Space$Type extends import_runtime4.MessageType {
8158
8313
  writer.tag(3, import_runtime.WireType.Varint).bool(message.creator);
8159
8314
  if (message.date !== 0n)
8160
8315
  writer.tag(4, import_runtime.WireType.Varint).int64(message.date);
8316
+ if (message.isPublic !== undefined)
8317
+ writer.tag(5, import_runtime.WireType.Varint).bool(message.isPublic);
8161
8318
  let u = options.writeUnknownFields;
8162
8319
  if (u !== false)
8163
8320
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8478,7 +8635,13 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8478
8635
  { no: 4, name: "title", kind: "scalar", opt: true, T: 9 },
8479
8636
  { no: 5, name: "description", kind: "scalar", opt: true, T: 9 },
8480
8637
  { no: 6, name: "photo", kind: "message", T: () => Photo },
8481
- { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 }
8638
+ { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 },
8639
+ { no: 8, name: "media_type", kind: "enum", opt: true, T: () => ["UrlPreview.MediaType", UrlPreview_MediaType, "MEDIA_TYPE_"] },
8640
+ { no: 9, name: "display_url", kind: "scalar", opt: true, T: 9 },
8641
+ { no: 10, name: "provider", kind: "scalar", opt: true, T: 9 },
8642
+ { no: 11, name: "author", kind: "scalar", opt: true, T: 9 },
8643
+ { no: 12, name: "media", kind: "message", T: () => UrlPreviewMedia },
8644
+ { no: 13, name: "layout", kind: "message", T: () => UrlPreviewLayout }
8482
8645
  ]);
8483
8646
  }
8484
8647
  create(value) {
@@ -8514,6 +8677,24 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8514
8677
  case 7:
8515
8678
  message.duration = reader.int64().toBigInt();
8516
8679
  break;
8680
+ case 8:
8681
+ message.mediaType = reader.int32();
8682
+ break;
8683
+ case 9:
8684
+ message.displayUrl = reader.string();
8685
+ break;
8686
+ case 10:
8687
+ message.provider = reader.string();
8688
+ break;
8689
+ case 11:
8690
+ message.author = reader.string();
8691
+ break;
8692
+ case 12:
8693
+ message.media = UrlPreviewMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
8694
+ break;
8695
+ case 13:
8696
+ message.layout = UrlPreviewLayout.internalBinaryRead(reader, reader.uint32(), options, message.layout);
8697
+ break;
8517
8698
  default:
8518
8699
  let u = options.readUnknownField;
8519
8700
  if (u === "throw")
@@ -8540,6 +8721,18 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8540
8721
  Photo.internalBinaryWrite(message.photo, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
8541
8722
  if (message.duration !== undefined)
8542
8723
  writer.tag(7, import_runtime.WireType.Varint).int64(message.duration);
8724
+ if (message.mediaType !== undefined)
8725
+ writer.tag(8, import_runtime.WireType.Varint).int32(message.mediaType);
8726
+ if (message.displayUrl !== undefined)
8727
+ writer.tag(9, import_runtime.WireType.LengthDelimited).string(message.displayUrl);
8728
+ if (message.provider !== undefined)
8729
+ writer.tag(10, import_runtime.WireType.LengthDelimited).string(message.provider);
8730
+ if (message.author !== undefined)
8731
+ writer.tag(11, import_runtime.WireType.LengthDelimited).string(message.author);
8732
+ if (message.media)
8733
+ UrlPreviewMedia.internalBinaryWrite(message.media, writer.tag(12, import_runtime.WireType.LengthDelimited).fork(), options).join();
8734
+ if (message.layout)
8735
+ UrlPreviewLayout.internalBinaryWrite(message.layout, writer.tag(13, import_runtime.WireType.LengthDelimited).fork(), options).join();
8543
8736
  let u = options.writeUnknownFields;
8544
8737
  if (u !== false)
8545
8738
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8548,6 +8741,272 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8548
8741
  }
8549
8742
  var UrlPreview = new UrlPreview$Type;
8550
8743
 
8744
+ class UrlPreviewMedia$Type extends import_runtime4.MessageType {
8745
+ constructor() {
8746
+ super("UrlPreviewMedia", [
8747
+ { no: 1, name: "photo", kind: "message", oneof: "media", T: () => Photo },
8748
+ { no: 2, name: "video", kind: "message", oneof: "media", T: () => Video },
8749
+ { no: 3, name: "document", kind: "message", oneof: "media", T: () => Document },
8750
+ { no: 4, name: "external_video", kind: "message", oneof: "media", T: () => UrlPreviewExternalVideo },
8751
+ { no: 5, name: "embed", kind: "message", oneof: "media", T: () => UrlPreviewEmbed }
8752
+ ]);
8753
+ }
8754
+ create(value) {
8755
+ const message = globalThis.Object.create(this.messagePrototype);
8756
+ message.media = { oneofKind: undefined };
8757
+ if (value !== undefined)
8758
+ import_runtime3.reflectionMergePartial(this, message, value);
8759
+ return message;
8760
+ }
8761
+ internalBinaryRead(reader, length, options, target) {
8762
+ let message = target ?? this.create(), end = reader.pos + length;
8763
+ while (reader.pos < end) {
8764
+ let [fieldNo, wireType] = reader.tag();
8765
+ switch (fieldNo) {
8766
+ case 1:
8767
+ message.media = {
8768
+ oneofKind: "photo",
8769
+ photo: Photo.internalBinaryRead(reader, reader.uint32(), options, message.media.photo)
8770
+ };
8771
+ break;
8772
+ case 2:
8773
+ message.media = {
8774
+ oneofKind: "video",
8775
+ video: Video.internalBinaryRead(reader, reader.uint32(), options, message.media.video)
8776
+ };
8777
+ break;
8778
+ case 3:
8779
+ message.media = {
8780
+ oneofKind: "document",
8781
+ document: Document.internalBinaryRead(reader, reader.uint32(), options, message.media.document)
8782
+ };
8783
+ break;
8784
+ case 4:
8785
+ message.media = {
8786
+ oneofKind: "externalVideo",
8787
+ externalVideo: UrlPreviewExternalVideo.internalBinaryRead(reader, reader.uint32(), options, message.media.externalVideo)
8788
+ };
8789
+ break;
8790
+ case 5:
8791
+ message.media = {
8792
+ oneofKind: "embed",
8793
+ embed: UrlPreviewEmbed.internalBinaryRead(reader, reader.uint32(), options, message.media.embed)
8794
+ };
8795
+ break;
8796
+ default:
8797
+ let u = options.readUnknownField;
8798
+ if (u === "throw")
8799
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8800
+ let d = reader.skip(wireType);
8801
+ if (u !== false)
8802
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8803
+ }
8804
+ }
8805
+ return message;
8806
+ }
8807
+ internalBinaryWrite(message, writer, options) {
8808
+ if (message.media.oneofKind === "photo")
8809
+ Photo.internalBinaryWrite(message.media.photo, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
8810
+ if (message.media.oneofKind === "video")
8811
+ Video.internalBinaryWrite(message.media.video, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
8812
+ if (message.media.oneofKind === "document")
8813
+ Document.internalBinaryWrite(message.media.document, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
8814
+ if (message.media.oneofKind === "externalVideo")
8815
+ UrlPreviewExternalVideo.internalBinaryWrite(message.media.externalVideo, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
8816
+ if (message.media.oneofKind === "embed")
8817
+ UrlPreviewEmbed.internalBinaryWrite(message.media.embed, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
8818
+ let u = options.writeUnknownFields;
8819
+ if (u !== false)
8820
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8821
+ return writer;
8822
+ }
8823
+ }
8824
+ var UrlPreviewMedia = new UrlPreviewMedia$Type;
8825
+
8826
+ class UrlPreviewExternalVideo$Type extends import_runtime4.MessageType {
8827
+ constructor() {
8828
+ super("UrlPreviewExternalVideo", [
8829
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8830
+ { no: 2, name: "mime_type", kind: "scalar", opt: true, T: 9 },
8831
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8832
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8833
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8834
+ ]);
8835
+ }
8836
+ create(value) {
8837
+ const message = globalThis.Object.create(this.messagePrototype);
8838
+ message.url = "";
8839
+ if (value !== undefined)
8840
+ import_runtime3.reflectionMergePartial(this, message, value);
8841
+ return message;
8842
+ }
8843
+ internalBinaryRead(reader, length, options, target) {
8844
+ let message = target ?? this.create(), end = reader.pos + length;
8845
+ while (reader.pos < end) {
8846
+ let [fieldNo, wireType] = reader.tag();
8847
+ switch (fieldNo) {
8848
+ case 1:
8849
+ message.url = reader.string();
8850
+ break;
8851
+ case 2:
8852
+ message.mimeType = reader.string();
8853
+ break;
8854
+ case 3:
8855
+ message.w = reader.int32();
8856
+ break;
8857
+ case 4:
8858
+ message.h = reader.int32();
8859
+ break;
8860
+ case 5:
8861
+ message.duration = reader.int32();
8862
+ break;
8863
+ default:
8864
+ let u = options.readUnknownField;
8865
+ if (u === "throw")
8866
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8867
+ let d = reader.skip(wireType);
8868
+ if (u !== false)
8869
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8870
+ }
8871
+ }
8872
+ return message;
8873
+ }
8874
+ internalBinaryWrite(message, writer, options) {
8875
+ if (message.url !== "")
8876
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8877
+ if (message.mimeType !== undefined)
8878
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.mimeType);
8879
+ if (message.w !== undefined)
8880
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8881
+ if (message.h !== undefined)
8882
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8883
+ if (message.duration !== undefined)
8884
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8885
+ let u = options.writeUnknownFields;
8886
+ if (u !== false)
8887
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8888
+ return writer;
8889
+ }
8890
+ }
8891
+ var UrlPreviewExternalVideo = new UrlPreviewExternalVideo$Type;
8892
+
8893
+ class UrlPreviewEmbed$Type extends import_runtime4.MessageType {
8894
+ constructor() {
8895
+ super("UrlPreviewEmbed", [
8896
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8897
+ { no: 2, name: "type", kind: "scalar", opt: true, T: 9 },
8898
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8899
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8900
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8901
+ ]);
8902
+ }
8903
+ create(value) {
8904
+ const message = globalThis.Object.create(this.messagePrototype);
8905
+ message.url = "";
8906
+ if (value !== undefined)
8907
+ import_runtime3.reflectionMergePartial(this, message, value);
8908
+ return message;
8909
+ }
8910
+ internalBinaryRead(reader, length, options, target) {
8911
+ let message = target ?? this.create(), end = reader.pos + length;
8912
+ while (reader.pos < end) {
8913
+ let [fieldNo, wireType] = reader.tag();
8914
+ switch (fieldNo) {
8915
+ case 1:
8916
+ message.url = reader.string();
8917
+ break;
8918
+ case 2:
8919
+ message.type = reader.string();
8920
+ break;
8921
+ case 3:
8922
+ message.w = reader.int32();
8923
+ break;
8924
+ case 4:
8925
+ message.h = reader.int32();
8926
+ break;
8927
+ case 5:
8928
+ message.duration = reader.int32();
8929
+ break;
8930
+ default:
8931
+ let u = options.readUnknownField;
8932
+ if (u === "throw")
8933
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8934
+ let d = reader.skip(wireType);
8935
+ if (u !== false)
8936
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8937
+ }
8938
+ }
8939
+ return message;
8940
+ }
8941
+ internalBinaryWrite(message, writer, options) {
8942
+ if (message.url !== "")
8943
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8944
+ if (message.type !== undefined)
8945
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.type);
8946
+ if (message.w !== undefined)
8947
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8948
+ if (message.h !== undefined)
8949
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8950
+ if (message.duration !== undefined)
8951
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8952
+ let u = options.writeUnknownFields;
8953
+ if (u !== false)
8954
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8955
+ return writer;
8956
+ }
8957
+ }
8958
+ var UrlPreviewEmbed = new UrlPreviewEmbed$Type;
8959
+
8960
+ class UrlPreviewLayout$Type extends import_runtime4.MessageType {
8961
+ constructor() {
8962
+ super("UrlPreviewLayout", [
8963
+ { no: 1, name: "has_large_media", kind: "scalar", T: 8 },
8964
+ { no: 2, name: "show_large_media", kind: "scalar", T: 8 }
8965
+ ]);
8966
+ }
8967
+ create(value) {
8968
+ const message = globalThis.Object.create(this.messagePrototype);
8969
+ message.hasLargeMedia = false;
8970
+ message.showLargeMedia = false;
8971
+ if (value !== undefined)
8972
+ import_runtime3.reflectionMergePartial(this, message, value);
8973
+ return message;
8974
+ }
8975
+ internalBinaryRead(reader, length, options, target) {
8976
+ let message = target ?? this.create(), end = reader.pos + length;
8977
+ while (reader.pos < end) {
8978
+ let [fieldNo, wireType] = reader.tag();
8979
+ switch (fieldNo) {
8980
+ case 1:
8981
+ message.hasLargeMedia = reader.bool();
8982
+ break;
8983
+ case 2:
8984
+ message.showLargeMedia = reader.bool();
8985
+ break;
8986
+ default:
8987
+ let u = options.readUnknownField;
8988
+ if (u === "throw")
8989
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8990
+ let d = reader.skip(wireType);
8991
+ if (u !== false)
8992
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8993
+ }
8994
+ }
8995
+ return message;
8996
+ }
8997
+ internalBinaryWrite(message, writer, options) {
8998
+ if (message.hasLargeMedia !== false)
8999
+ writer.tag(1, import_runtime.WireType.Varint).bool(message.hasLargeMedia);
9000
+ if (message.showLargeMedia !== false)
9001
+ writer.tag(2, import_runtime.WireType.Varint).bool(message.showLargeMedia);
9002
+ let u = options.writeUnknownFields;
9003
+ if (u !== false)
9004
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
9005
+ return writer;
9006
+ }
9007
+ }
9008
+ var UrlPreviewLayout = new UrlPreviewLayout$Type;
9009
+
8551
9010
  class MessageAttachmentExternalTask$Type extends import_runtime4.MessageType {
8552
9011
  constructor() {
8553
9012
  super("MessageAttachmentExternalTask", [
@@ -9441,7 +9900,10 @@ class RpcCall$Type extends import_runtime4.MessageType {
9441
9900
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "input", T: () => AnswerMessageActionInput },
9442
9901
  { no: 51, name: "revokeSession", kind: "message", oneof: "input", T: () => RevokeSessionInput },
9443
9902
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "input", T: () => UpdateDialogOpenInput },
9444
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput }
9903
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput },
9904
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "input", T: () => ClearChatHistoryInput },
9905
+ { no: 55, name: "deleteBot", kind: "message", oneof: "input", T: () => DeleteBotInput },
9906
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "input", T: () => DeleteMessageAttachmentInput }
9445
9907
  ]);
9446
9908
  }
9447
9909
  create(value) {
@@ -9772,6 +10234,24 @@ class RpcCall$Type extends import_runtime4.MessageType {
9772
10234
  updateDialogOrder: UpdateDialogOrderInput.internalBinaryRead(reader, reader.uint32(), options, message.input.updateDialogOrder)
9773
10235
  };
9774
10236
  break;
10237
+ case 54:
10238
+ message.input = {
10239
+ oneofKind: "clearChatHistory",
10240
+ clearChatHistory: ClearChatHistoryInput.internalBinaryRead(reader, reader.uint32(), options, message.input.clearChatHistory)
10241
+ };
10242
+ break;
10243
+ case 55:
10244
+ message.input = {
10245
+ oneofKind: "deleteBot",
10246
+ deleteBot: DeleteBotInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteBot)
10247
+ };
10248
+ break;
10249
+ case 56:
10250
+ message.input = {
10251
+ oneofKind: "deleteMessageAttachment",
10252
+ deleteMessageAttachment: DeleteMessageAttachmentInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteMessageAttachment)
10253
+ };
10254
+ break;
9775
10255
  default:
9776
10256
  let u = options.readUnknownField;
9777
10257
  if (u === "throw")
@@ -9890,6 +10370,12 @@ class RpcCall$Type extends import_runtime4.MessageType {
9890
10370
  UpdateDialogOpenInput.internalBinaryWrite(message.input.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
9891
10371
  if (message.input.oneofKind === "updateDialogOrder")
9892
10372
  UpdateDialogOrderInput.internalBinaryWrite(message.input.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10373
+ if (message.input.oneofKind === "clearChatHistory")
10374
+ ClearChatHistoryInput.internalBinaryWrite(message.input.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10375
+ if (message.input.oneofKind === "deleteBot")
10376
+ DeleteBotInput.internalBinaryWrite(message.input.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10377
+ if (message.input.oneofKind === "deleteMessageAttachment")
10378
+ DeleteMessageAttachmentInput.internalBinaryWrite(message.input.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
9893
10379
  let u = options.writeUnknownFields;
9894
10380
  if (u !== false)
9895
10381
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -9953,7 +10439,10 @@ class RpcResult$Type extends import_runtime4.MessageType {
9953
10439
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "result", T: () => AnswerMessageActionResult },
9954
10440
  { no: 51, name: "revokeSession", kind: "message", oneof: "result", T: () => RevokeSessionResult },
9955
10441
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "result", T: () => UpdateDialogOpenResult },
9956
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult }
10442
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult },
10443
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "result", T: () => ClearChatHistoryResult },
10444
+ { no: 55, name: "deleteBot", kind: "message", oneof: "result", T: () => DeleteBotResult },
10445
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "result", T: () => DeleteMessageAttachmentResult }
9957
10446
  ]);
9958
10447
  }
9959
10448
  create(value) {
@@ -10284,6 +10773,24 @@ class RpcResult$Type extends import_runtime4.MessageType {
10284
10773
  updateDialogOrder: UpdateDialogOrderResult.internalBinaryRead(reader, reader.uint32(), options, message.result.updateDialogOrder)
10285
10774
  };
10286
10775
  break;
10776
+ case 54:
10777
+ message.result = {
10778
+ oneofKind: "clearChatHistory",
10779
+ clearChatHistory: ClearChatHistoryResult.internalBinaryRead(reader, reader.uint32(), options, message.result.clearChatHistory)
10780
+ };
10781
+ break;
10782
+ case 55:
10783
+ message.result = {
10784
+ oneofKind: "deleteBot",
10785
+ deleteBot: DeleteBotResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteBot)
10786
+ };
10787
+ break;
10788
+ case 56:
10789
+ message.result = {
10790
+ oneofKind: "deleteMessageAttachment",
10791
+ deleteMessageAttachment: DeleteMessageAttachmentResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteMessageAttachment)
10792
+ };
10793
+ break;
10287
10794
  default:
10288
10795
  let u = options.readUnknownField;
10289
10796
  if (u === "throw")
@@ -10402,6 +10909,12 @@ class RpcResult$Type extends import_runtime4.MessageType {
10402
10909
  UpdateDialogOpenResult.internalBinaryWrite(message.result.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
10403
10910
  if (message.result.oneofKind === "updateDialogOrder")
10404
10911
  UpdateDialogOrderResult.internalBinaryWrite(message.result.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10912
+ if (message.result.oneofKind === "clearChatHistory")
10913
+ ClearChatHistoryResult.internalBinaryWrite(message.result.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10914
+ if (message.result.oneofKind === "deleteBot")
10915
+ DeleteBotResult.internalBinaryWrite(message.result.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10916
+ if (message.result.oneofKind === "deleteMessageAttachment")
10917
+ DeleteMessageAttachmentResult.internalBinaryWrite(message.result.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
10405
10918
  let u = options.writeUnknownFields;
10406
10919
  if (u !== false)
10407
10920
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -10587,7 +11100,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10587
11100
  { no: 1, name: "bucket", kind: "message", T: () => UpdateBucket },
10588
11101
  { no: 2, name: "start_seq", kind: "scalar", T: 3, L: 0 },
10589
11102
  { no: 3, name: "total_limit", kind: "scalar", T: 5 },
10590
- { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 }
11103
+ { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 },
11104
+ { no: 5, name: "limit", kind: "scalar", T: 5 }
10591
11105
  ]);
10592
11106
  }
10593
11107
  create(value) {
@@ -10595,6 +11109,7 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10595
11109
  message.startSeq = 0n;
10596
11110
  message.totalLimit = 0;
10597
11111
  message.seqEnd = 0n;
11112
+ message.limit = 0;
10598
11113
  if (value !== undefined)
10599
11114
  import_runtime3.reflectionMergePartial(this, message, value);
10600
11115
  return message;
@@ -10616,6 +11131,9 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10616
11131
  case 4:
10617
11132
  message.seqEnd = reader.int64().toBigInt();
10618
11133
  break;
11134
+ case 5:
11135
+ message.limit = reader.int32();
11136
+ break;
10619
11137
  default:
10620
11138
  let u = options.readUnknownField;
10621
11139
  if (u === "throw")
@@ -10636,6 +11154,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10636
11154
  writer.tag(3, import_runtime.WireType.Varint).int32(message.totalLimit);
10637
11155
  if (message.seqEnd !== 0n)
10638
11156
  writer.tag(4, import_runtime.WireType.Varint).int64(message.seqEnd);
11157
+ if (message.limit !== 0)
11158
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.limit);
10639
11159
  let u = options.writeUnknownFields;
10640
11160
  if (u !== false)
10641
11161
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -11762,6 +12282,191 @@ class ListBotsResult$Type extends import_runtime4.MessageType {
11762
12282
  }
11763
12283
  var ListBotsResult = new ListBotsResult$Type;
11764
12284
 
12285
+ class DeleteBotInput$Type extends import_runtime4.MessageType {
12286
+ constructor() {
12287
+ super("DeleteBotInput", [
12288
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12289
+ ]);
12290
+ }
12291
+ create(value) {
12292
+ const message = globalThis.Object.create(this.messagePrototype);
12293
+ message.botUserId = 0n;
12294
+ if (value !== undefined)
12295
+ import_runtime3.reflectionMergePartial(this, message, value);
12296
+ return message;
12297
+ }
12298
+ internalBinaryRead(reader, length, options, target) {
12299
+ let message = target ?? this.create(), end = reader.pos + length;
12300
+ while (reader.pos < end) {
12301
+ let [fieldNo, wireType] = reader.tag();
12302
+ switch (fieldNo) {
12303
+ case 1:
12304
+ message.botUserId = reader.int64().toBigInt();
12305
+ break;
12306
+ default:
12307
+ let u = options.readUnknownField;
12308
+ if (u === "throw")
12309
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12310
+ let d = reader.skip(wireType);
12311
+ if (u !== false)
12312
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12313
+ }
12314
+ }
12315
+ return message;
12316
+ }
12317
+ internalBinaryWrite(message, writer, options) {
12318
+ if (message.botUserId !== 0n)
12319
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12320
+ let u = options.writeUnknownFields;
12321
+ if (u !== false)
12322
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12323
+ return writer;
12324
+ }
12325
+ }
12326
+ var DeleteBotInput = new DeleteBotInput$Type;
12327
+
12328
+ class DeleteBotResult$Type extends import_runtime4.MessageType {
12329
+ constructor() {
12330
+ super("DeleteBotResult", [
12331
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12332
+ ]);
12333
+ }
12334
+ create(value) {
12335
+ const message = globalThis.Object.create(this.messagePrototype);
12336
+ message.botUserId = 0n;
12337
+ if (value !== undefined)
12338
+ import_runtime3.reflectionMergePartial(this, message, value);
12339
+ return message;
12340
+ }
12341
+ internalBinaryRead(reader, length, options, target) {
12342
+ let message = target ?? this.create(), end = reader.pos + length;
12343
+ while (reader.pos < end) {
12344
+ let [fieldNo, wireType] = reader.tag();
12345
+ switch (fieldNo) {
12346
+ case 1:
12347
+ message.botUserId = reader.int64().toBigInt();
12348
+ break;
12349
+ default:
12350
+ let u = options.readUnknownField;
12351
+ if (u === "throw")
12352
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12353
+ let d = reader.skip(wireType);
12354
+ if (u !== false)
12355
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12356
+ }
12357
+ }
12358
+ return message;
12359
+ }
12360
+ internalBinaryWrite(message, writer, options) {
12361
+ if (message.botUserId !== 0n)
12362
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12363
+ let u = options.writeUnknownFields;
12364
+ if (u !== false)
12365
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12366
+ return writer;
12367
+ }
12368
+ }
12369
+ var DeleteBotResult = new DeleteBotResult$Type;
12370
+
12371
+ class DeleteMessageAttachmentInput$Type extends import_runtime4.MessageType {
12372
+ constructor() {
12373
+ super("DeleteMessageAttachmentInput", [
12374
+ { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
12375
+ { no: 2, name: "message_id", kind: "scalar", T: 3, L: 0 },
12376
+ { no: 3, name: "attachment_id", kind: "scalar", T: 3, L: 0 }
12377
+ ]);
12378
+ }
12379
+ create(value) {
12380
+ const message = globalThis.Object.create(this.messagePrototype);
12381
+ message.messageId = 0n;
12382
+ message.attachmentId = 0n;
12383
+ if (value !== undefined)
12384
+ import_runtime3.reflectionMergePartial(this, message, value);
12385
+ return message;
12386
+ }
12387
+ internalBinaryRead(reader, length, options, target) {
12388
+ let message = target ?? this.create(), end = reader.pos + length;
12389
+ while (reader.pos < end) {
12390
+ let [fieldNo, wireType] = reader.tag();
12391
+ switch (fieldNo) {
12392
+ case 1:
12393
+ message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
12394
+ break;
12395
+ case 2:
12396
+ message.messageId = reader.int64().toBigInt();
12397
+ break;
12398
+ case 3:
12399
+ message.attachmentId = reader.int64().toBigInt();
12400
+ break;
12401
+ default:
12402
+ let u = options.readUnknownField;
12403
+ if (u === "throw")
12404
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12405
+ let d = reader.skip(wireType);
12406
+ if (u !== false)
12407
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12408
+ }
12409
+ }
12410
+ return message;
12411
+ }
12412
+ internalBinaryWrite(message, writer, options) {
12413
+ if (message.peerId)
12414
+ InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12415
+ if (message.messageId !== 0n)
12416
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.messageId);
12417
+ if (message.attachmentId !== 0n)
12418
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.attachmentId);
12419
+ let u = options.writeUnknownFields;
12420
+ if (u !== false)
12421
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12422
+ return writer;
12423
+ }
12424
+ }
12425
+ var DeleteMessageAttachmentInput = new DeleteMessageAttachmentInput$Type;
12426
+
12427
+ class DeleteMessageAttachmentResult$Type extends import_runtime4.MessageType {
12428
+ constructor() {
12429
+ super("DeleteMessageAttachmentResult", [
12430
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
12431
+ ]);
12432
+ }
12433
+ create(value) {
12434
+ const message = globalThis.Object.create(this.messagePrototype);
12435
+ message.updates = [];
12436
+ if (value !== undefined)
12437
+ import_runtime3.reflectionMergePartial(this, message, value);
12438
+ return message;
12439
+ }
12440
+ internalBinaryRead(reader, length, options, target) {
12441
+ let message = target ?? this.create(), end = reader.pos + length;
12442
+ while (reader.pos < end) {
12443
+ let [fieldNo, wireType] = reader.tag();
12444
+ switch (fieldNo) {
12445
+ case 1:
12446
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
12447
+ break;
12448
+ default:
12449
+ let u = options.readUnknownField;
12450
+ if (u === "throw")
12451
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12452
+ let d = reader.skip(wireType);
12453
+ if (u !== false)
12454
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12455
+ }
12456
+ }
12457
+ return message;
12458
+ }
12459
+ internalBinaryWrite(message, writer, options) {
12460
+ for (let i = 0;i < message.updates.length; i++)
12461
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12462
+ let u = options.writeUnknownFields;
12463
+ if (u !== false)
12464
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12465
+ return writer;
12466
+ }
12467
+ }
12468
+ var DeleteMessageAttachmentResult = new DeleteMessageAttachmentResult$Type;
12469
+
11765
12470
  class RevokeSessionInput$Type extends import_runtime4.MessageType {
11766
12471
  constructor() {
11767
12472
  super("RevokeSessionInput", [
@@ -13778,6 +14483,118 @@ class DeleteMessagesResult$Type extends import_runtime4.MessageType {
13778
14483
  }
13779
14484
  var DeleteMessagesResult = new DeleteMessagesResult$Type;
13780
14485
 
14486
+ class ClearChatHistoryInput$Type extends import_runtime4.MessageType {
14487
+ constructor() {
14488
+ super("ClearChatHistoryInput", [
14489
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => InputPeer },
14490
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
14491
+ { no: 2, name: "keep_last_days", kind: "scalar", T: 5 },
14492
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 }
14493
+ ]);
14494
+ }
14495
+ create(value) {
14496
+ const message = globalThis.Object.create(this.messagePrototype);
14497
+ message.target = { oneofKind: undefined };
14498
+ message.keepLastDays = 0;
14499
+ message.deleteReplyThreads = false;
14500
+ if (value !== undefined)
14501
+ import_runtime3.reflectionMergePartial(this, message, value);
14502
+ return message;
14503
+ }
14504
+ internalBinaryRead(reader, length, options, target) {
14505
+ let message = target ?? this.create(), end = reader.pos + length;
14506
+ while (reader.pos < end) {
14507
+ let [fieldNo, wireType] = reader.tag();
14508
+ switch (fieldNo) {
14509
+ case 1:
14510
+ message.target = {
14511
+ oneofKind: "peerId",
14512
+ peerId: InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
14513
+ };
14514
+ break;
14515
+ case 4:
14516
+ message.target = {
14517
+ oneofKind: "spaceId",
14518
+ spaceId: reader.int64().toBigInt()
14519
+ };
14520
+ break;
14521
+ case 2:
14522
+ message.keepLastDays = reader.int32();
14523
+ break;
14524
+ case 3:
14525
+ message.deleteReplyThreads = reader.bool();
14526
+ break;
14527
+ default:
14528
+ let u = options.readUnknownField;
14529
+ if (u === "throw")
14530
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14531
+ let d = reader.skip(wireType);
14532
+ if (u !== false)
14533
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14534
+ }
14535
+ }
14536
+ return message;
14537
+ }
14538
+ internalBinaryWrite(message, writer, options) {
14539
+ if (message.target.oneofKind === "peerId")
14540
+ InputPeer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14541
+ if (message.target.oneofKind === "spaceId")
14542
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
14543
+ if (message.keepLastDays !== 0)
14544
+ writer.tag(2, import_runtime.WireType.Varint).int32(message.keepLastDays);
14545
+ if (message.deleteReplyThreads !== false)
14546
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
14547
+ let u = options.writeUnknownFields;
14548
+ if (u !== false)
14549
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14550
+ return writer;
14551
+ }
14552
+ }
14553
+ var ClearChatHistoryInput = new ClearChatHistoryInput$Type;
14554
+
14555
+ class ClearChatHistoryResult$Type extends import_runtime4.MessageType {
14556
+ constructor() {
14557
+ super("ClearChatHistoryResult", [
14558
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
14559
+ ]);
14560
+ }
14561
+ create(value) {
14562
+ const message = globalThis.Object.create(this.messagePrototype);
14563
+ message.updates = [];
14564
+ if (value !== undefined)
14565
+ import_runtime3.reflectionMergePartial(this, message, value);
14566
+ return message;
14567
+ }
14568
+ internalBinaryRead(reader, length, options, target) {
14569
+ let message = target ?? this.create(), end = reader.pos + length;
14570
+ while (reader.pos < end) {
14571
+ let [fieldNo, wireType] = reader.tag();
14572
+ switch (fieldNo) {
14573
+ case 1:
14574
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
14575
+ break;
14576
+ default:
14577
+ let u = options.readUnknownField;
14578
+ if (u === "throw")
14579
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14580
+ let d = reader.skip(wireType);
14581
+ if (u !== false)
14582
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14583
+ }
14584
+ }
14585
+ return message;
14586
+ }
14587
+ internalBinaryWrite(message, writer, options) {
14588
+ for (let i = 0;i < message.updates.length; i++)
14589
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14590
+ let u = options.writeUnknownFields;
14591
+ if (u !== false)
14592
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14593
+ return writer;
14594
+ }
14595
+ }
14596
+ var ClearChatHistoryResult = new ClearChatHistoryResult$Type;
14597
+
13781
14598
  class EditMessageInput$Type extends import_runtime4.MessageType {
13782
14599
  constructor() {
13783
14600
  super("EditMessageInput", [
@@ -15519,7 +16336,8 @@ class Update$Type extends import_runtime4.MessageType {
15519
16336
  { no: 33, name: "dialog_notification_settings", kind: "message", oneof: "update", T: () => UpdateDialogNotificationSettings },
15520
16337
  { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen },
15521
16338
  { no: 35, name: "message_action_invoked", kind: "message", oneof: "update", T: () => UpdateMessageActionInvoked },
15522
- { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered }
16339
+ { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered },
16340
+ { no: 37, name: "clear_chat_history", kind: "message", oneof: "update", T: () => UpdateClearChatHistory }
15523
16341
  ]);
15524
16342
  }
15525
16343
  create(value) {
@@ -15738,6 +16556,12 @@ class Update$Type extends import_runtime4.MessageType {
15738
16556
  messageActionAnswered: UpdateMessageActionAnswered.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionAnswered)
15739
16557
  };
15740
16558
  break;
16559
+ case 37:
16560
+ message.update = {
16561
+ oneofKind: "clearChatHistory",
16562
+ clearChatHistory: UpdateClearChatHistory.internalBinaryRead(reader, reader.uint32(), options, message.update.clearChatHistory)
16563
+ };
16564
+ break;
15741
16565
  default:
15742
16566
  let u = options.readUnknownField;
15743
16567
  if (u === "throw")
@@ -15820,6 +16644,8 @@ class Update$Type extends import_runtime4.MessageType {
15820
16644
  UpdateMessageActionInvoked.internalBinaryWrite(message.update.messageActionInvoked, writer.tag(35, import_runtime.WireType.LengthDelimited).fork(), options).join();
15821
16645
  if (message.update.oneofKind === "messageActionAnswered")
15822
16646
  UpdateMessageActionAnswered.internalBinaryWrite(message.update.messageActionAnswered, writer.tag(36, import_runtime.WireType.LengthDelimited).fork(), options).join();
16647
+ if (message.update.oneofKind === "clearChatHistory")
16648
+ UpdateClearChatHistory.internalBinaryWrite(message.update.clearChatHistory, writer.tag(37, import_runtime.WireType.LengthDelimited).fork(), options).join();
15823
16649
  let u = options.writeUnknownFields;
15824
16650
  if (u !== false)
15825
16651
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -17086,6 +17912,119 @@ class UpdateDeleteMessages$Type extends import_runtime4.MessageType {
17086
17912
  }
17087
17913
  var UpdateDeleteMessages = new UpdateDeleteMessages$Type;
17088
17914
 
17915
+ class UpdateClearChatHistory$Type extends import_runtime4.MessageType {
17916
+ constructor() {
17917
+ super("UpdateClearChatHistory", [
17918
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => Peer },
17919
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
17920
+ { no: 2, name: "before_date", kind: "scalar", opt: true, T: 3, L: 0 },
17921
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 },
17922
+ { no: 5, name: "deleted_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17923
+ { no: 6, name: "orphaned_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17924
+ { no: 7, name: "detached_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 }
17925
+ ]);
17926
+ }
17927
+ create(value) {
17928
+ const message = globalThis.Object.create(this.messagePrototype);
17929
+ message.target = { oneofKind: undefined };
17930
+ message.deleteReplyThreads = false;
17931
+ message.deletedChatIds = [];
17932
+ message.orphanedChatIds = [];
17933
+ message.detachedChatIds = [];
17934
+ if (value !== undefined)
17935
+ import_runtime3.reflectionMergePartial(this, message, value);
17936
+ return message;
17937
+ }
17938
+ internalBinaryRead(reader, length, options, target) {
17939
+ let message = target ?? this.create(), end = reader.pos + length;
17940
+ while (reader.pos < end) {
17941
+ let [fieldNo, wireType] = reader.tag();
17942
+ switch (fieldNo) {
17943
+ case 1:
17944
+ message.target = {
17945
+ oneofKind: "peerId",
17946
+ peerId: Peer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
17947
+ };
17948
+ break;
17949
+ case 4:
17950
+ message.target = {
17951
+ oneofKind: "spaceId",
17952
+ spaceId: reader.int64().toBigInt()
17953
+ };
17954
+ break;
17955
+ case 2:
17956
+ message.beforeDate = reader.int64().toBigInt();
17957
+ break;
17958
+ case 3:
17959
+ message.deleteReplyThreads = reader.bool();
17960
+ break;
17961
+ case 5:
17962
+ if (wireType === import_runtime.WireType.LengthDelimited)
17963
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17964
+ message.deletedChatIds.push(reader.int64().toBigInt());
17965
+ else
17966
+ message.deletedChatIds.push(reader.int64().toBigInt());
17967
+ break;
17968
+ case 6:
17969
+ if (wireType === import_runtime.WireType.LengthDelimited)
17970
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17971
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17972
+ else
17973
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17974
+ break;
17975
+ case 7:
17976
+ if (wireType === import_runtime.WireType.LengthDelimited)
17977
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17978
+ message.detachedChatIds.push(reader.int64().toBigInt());
17979
+ else
17980
+ message.detachedChatIds.push(reader.int64().toBigInt());
17981
+ break;
17982
+ default:
17983
+ let u = options.readUnknownField;
17984
+ if (u === "throw")
17985
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
17986
+ let d = reader.skip(wireType);
17987
+ if (u !== false)
17988
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
17989
+ }
17990
+ }
17991
+ return message;
17992
+ }
17993
+ internalBinaryWrite(message, writer, options) {
17994
+ if (message.target.oneofKind === "peerId")
17995
+ Peer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
17996
+ if (message.target.oneofKind === "spaceId")
17997
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
17998
+ if (message.beforeDate !== undefined)
17999
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.beforeDate);
18000
+ if (message.deleteReplyThreads !== false)
18001
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
18002
+ if (message.deletedChatIds.length) {
18003
+ writer.tag(5, import_runtime.WireType.LengthDelimited).fork();
18004
+ for (let i = 0;i < message.deletedChatIds.length; i++)
18005
+ writer.int64(message.deletedChatIds[i]);
18006
+ writer.join();
18007
+ }
18008
+ if (message.orphanedChatIds.length) {
18009
+ writer.tag(6, import_runtime.WireType.LengthDelimited).fork();
18010
+ for (let i = 0;i < message.orphanedChatIds.length; i++)
18011
+ writer.int64(message.orphanedChatIds[i]);
18012
+ writer.join();
18013
+ }
18014
+ if (message.detachedChatIds.length) {
18015
+ writer.tag(7, import_runtime.WireType.LengthDelimited).fork();
18016
+ for (let i = 0;i < message.detachedChatIds.length; i++)
18017
+ writer.int64(message.detachedChatIds[i]);
18018
+ writer.join();
18019
+ }
18020
+ let u = options.writeUnknownFields;
18021
+ if (u !== false)
18022
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
18023
+ return writer;
18024
+ }
18025
+ }
18026
+ var UpdateClearChatHistory = new UpdateClearChatHistory$Type;
18027
+
17089
18028
  class UpdateMessageId$Type extends import_runtime4.MessageType {
17090
18029
  constructor() {
17091
18030
  super("UpdateMessageId", [
@@ -19226,7 +20165,7 @@ function describeConnectionError(error) {
19226
20165
  return `server connection error${code != null ? ` (code=${code})` : ""}: ${message}`;
19227
20166
  }
19228
20167
 
19229
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/wrapper.mjs
20168
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/wrapper.mjs
19230
20169
  var import_stream = __toESM(require_stream(), 1);
19231
20170
  var import_extension = __toESM(require_extension(), 1);
19232
20171
  var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
@@ -19520,7 +20459,8 @@ var rpcInputKindByMethod = {
19520
20459
  37: "updateBotProfile",
19521
20460
  38: "getMessages",
19522
20461
  48: "invokeMessageAction",
19523
- 49: "answerMessageAction"
20462
+ 49: "answerMessageAction",
20463
+ 53: "clearChatHistory"
19524
20464
  };
19525
20465
  var rpcResultKindByMethod = {
19526
20466
  0: undefined,
@@ -19563,7 +20503,8 @@ var rpcResultKindByMethod = {
19563
20503
  37: "updateBotProfile",
19564
20504
  38: "getMessages",
19565
20505
  48: "invokeMessageAction",
19566
- 49: "answerMessageAction"
20506
+ 49: "answerMessageAction",
20507
+ 53: "clearChatHistory"
19567
20508
  };
19568
20509
 
19569
20510
  // ../sdk/dist/sdk/logger.js
@@ -19600,6 +20541,7 @@ var defaultApiBaseUrl = "https://api.inline.chat";
19600
20541
  var defaultVideoWidth = 1280;
19601
20542
  var defaultVideoHeight = 720;
19602
20543
  var defaultVideoDuration = 1;
20544
+ var defaultCatchUpPageLimit = 200;
19603
20545
  var defaultCatchUpTotalLimit = 1000;
19604
20546
  var defaultColdStartCatchUpWindow = defaultCatchUpTotalLimit;
19605
20547
  function extractFirstMessageId(updates) {
@@ -19738,7 +20680,12 @@ class InlineSdkClient {
19738
20680
  const chat = result.getChat.chat;
19739
20681
  if (!chat)
19740
20682
  throw new Error("getChat: missing chat");
19741
- return { chatId: chat.id, peer: chat.peerId, title: chat.title };
20683
+ return {
20684
+ chatId: chat.id,
20685
+ peer: chat.peerId,
20686
+ title: chat.title,
20687
+ ...chat.lastMsgId != null ? { lastMsgId: chat.lastMsgId } : {}
20688
+ };
19742
20689
  }
19743
20690
  async getMessages(params) {
19744
20691
  const peerId = this.inputPeerFromTarget(params, "getMessages");
@@ -19752,6 +20699,18 @@ class InlineSdkClient {
19752
20699
  });
19753
20700
  return { messages: result.getMessages.messages };
19754
20701
  }
20702
+ async clearChatHistory(params) {
20703
+ const keepLastDays = normalizeKeepLastDays(params.keepLastDays);
20704
+ const target = this.clearHistoryTargetFromParams(params);
20705
+ await this.invoke(Method.CLEAR_CHAT_HISTORY, {
20706
+ oneofKind: "clearChatHistory",
20707
+ clearChatHistory: {
20708
+ target,
20709
+ keepLastDays,
20710
+ deleteReplyThreads: params.deleteReplyThreads ?? false
20711
+ }
20712
+ });
20713
+ }
19755
20714
  async sendMessage(params) {
19756
20715
  if (params.entities != null && params.parseMarkdown != null) {
19757
20716
  throw new Error("sendMessage: provide either `entities` or `parseMarkdown`, not both");
@@ -20053,6 +21012,36 @@ class InlineSdkClient {
20053
21012
  });
20054
21013
  return;
20055
21014
  }
21015
+ case "clearChatHistory": {
21016
+ const payload = update.update.clearChatHistory;
21017
+ if (payload.target.oneofKind === "spaceId") {
21018
+ await this.eventStream.send({
21019
+ kind: "space.history.clear",
21020
+ spaceId: payload.target.spaceId,
21021
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
21022
+ deleteReplyThreads: payload.deleteReplyThreads,
21023
+ seq,
21024
+ date
21025
+ });
21026
+ return;
21027
+ }
21028
+ const peerId = payload.target.oneofKind === "peerId" ? payload.target.peerId : undefined;
21029
+ const chatId = peerId?.type.oneofKind === "chat" ? peerId.type.chat.chatId : null;
21030
+ if (!chatId) {
21031
+ this.log.warn?.("Skipping clearChatHistory update without chat peer", peerId);
21032
+ return;
21033
+ }
21034
+ this.bumpChatSeq(chatId, seq);
21035
+ await this.eventStream.send({
21036
+ kind: "message.history.clear",
21037
+ chatId,
21038
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
21039
+ deleteReplyThreads: payload.deleteReplyThreads,
21040
+ seq,
21041
+ date
21042
+ });
21043
+ return;
21044
+ }
20056
21045
  case "updateReaction": {
20057
21046
  const reaction = update.update.updateReaction.reaction;
20058
21047
  if (!reaction)
@@ -20196,7 +21185,8 @@ class InlineSdkClient {
20196
21185
  }
20197
21186
  }),
20198
21187
  startSeq: BigInt(cursor),
20199
- totalLimit: defaultCatchUpTotalLimit
21188
+ totalLimit: defaultCatchUpTotalLimit,
21189
+ limit: defaultCatchUpPageLimit
20200
21190
  })
20201
21191
  });
20202
21192
  const payload = result.getUpdates;
@@ -20293,7 +21283,8 @@ class InlineSdkClient {
20293
21283
  }),
20294
21284
  startSeq: BigInt(cursor),
20295
21285
  seqEnd: BigInt(endSeq),
20296
- totalLimit: defaultCatchUpTotalLimit
21286
+ totalLimit: defaultCatchUpTotalLimit,
21287
+ limit: defaultCatchUpPageLimit
20297
21288
  })
20298
21289
  });
20299
21290
  const payload = result.getUpdates;
@@ -20357,6 +21348,18 @@ class InlineSdkClient {
20357
21348
  type: { oneofKind: "chat", chat: { chatId: asInlineId(params.chatId, "chatId") } }
20358
21349
  });
20359
21350
  }
21351
+ clearHistoryTargetFromParams(params) {
21352
+ const hasChatId = params.chatId != null;
21353
+ const hasUserId = params.userId != null;
21354
+ const hasSpaceId = params.spaceId != null;
21355
+ if ([hasChatId, hasUserId, hasSpaceId].filter(Boolean).length !== 1) {
21356
+ throw new Error("clearChatHistory: provide exactly one of `chatId`, `userId`, or `spaceId`");
21357
+ }
21358
+ if (hasSpaceId) {
21359
+ return { oneofKind: "spaceId", spaceId: asInlineId(params.spaceId, "spaceId") };
21360
+ }
21361
+ return { oneofKind: "peerId", peerId: this.inputPeerFromTarget(params, "clearChatHistory") };
21362
+ }
20360
21363
  async loadState() {
20361
21364
  const store = this.options.state;
20362
21365
  if (!store)
@@ -20533,6 +21536,12 @@ function normalizePositiveInt(value, field) {
20533
21536
  }
20534
21537
  return value;
20535
21538
  }
21539
+ function normalizeKeepLastDays(value) {
21540
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > 36500) {
21541
+ throw new Error("clearChatHistory: `keepLastDays` must be 0 or a positive integer up to 36500");
21542
+ }
21543
+ return value;
21544
+ }
20536
21545
  async function parseJsonResponse(response) {
20537
21546
  const contentType = response.headers.get("content-type") ?? "";
20538
21547
  if (!contentType.includes("application/json")) {
@@ -35193,10 +36202,15 @@ var InlineActionsSchema = exports_external.object({
35193
36202
  var InlineCapabilitiesSchema = exports_external.object({
35194
36203
  replyThreads: exports_external.boolean().optional()
35195
36204
  }).strict();
36205
+ var InlineReplyThreadModeSchema = exports_external.enum(["auto", "thread", "main"]);
35196
36206
  var InlineTargetSchema = exports_external.union([exports_external.string(), exports_external.number()]);
35197
36207
  var InlineAllowEntrySchema = exports_external.union([exports_external.string(), exports_external.number()]);
35198
36208
  var InlineGroupSchema = exports_external.object({
35199
36209
  requireMention: exports_external.boolean().optional(),
36210
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36211
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36212
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36213
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35200
36214
  allowFrom: exports_external.array(InlineAllowEntrySchema).optional(),
35201
36215
  systemPrompt: exports_external.string().optional(),
35202
36216
  tools: ToolPolicySchema.optional(),
@@ -35236,6 +36250,7 @@ var InlineStreamingSchema = exports_external.union([
35236
36250
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35237
36251
  labels: exports_external.array(exports_external.string()).optional(),
35238
36252
  maxLines: exports_external.number().int().positive().optional(),
36253
+ maxLineChars: exports_external.number().int().positive().optional(),
35239
36254
  render: exports_external.enum(["text", "rich"]).optional(),
35240
36255
  toolProgress: exports_external.boolean().optional(),
35241
36256
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35263,6 +36278,7 @@ var InlineRuntimeStreamingSchema = exports_external.union([
35263
36278
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35264
36279
  labels: exports_external.array(exports_external.string()).optional(),
35265
36280
  maxLines: exports_external.number().int().positive().optional(),
36281
+ maxLineChars: exports_external.number().int().positive().optional(),
35266
36282
  render: exports_external.enum(["text", "rich"]).optional(),
35267
36283
  toolProgress: exports_external.boolean().optional(),
35268
36284
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35288,6 +36304,10 @@ var InlineAccountSchemaBase = exports_external.object({
35288
36304
  groupPolicy: GroupPolicySchema.optional().default("allowlist"),
35289
36305
  groups: exports_external.record(exports_external.string(), InlineGroupSchema.optional()).optional(),
35290
36306
  requireMention: exports_external.boolean().optional(),
36307
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36308
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36309
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36310
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35291
36311
  replyToBotWithoutMention: exports_external.boolean().optional(),
35292
36312
  historyLimit: exports_external.number().int().min(0).optional(),
35293
36313
  dmHistoryLimit: exports_external.number().int().min(0).optional(),
@@ -35559,9 +36579,7 @@ function inspectInlineAccount(params) {
35559
36579
  }
35560
36580
  const tokenFile = account.tokenFile?.trim() ?? "";
35561
36581
  if (tokenFile) {
35562
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35563
- rejectSymlink: true
35564
- }) ?? "";
36582
+ const token = tryReadInlineTokenFile(tokenFile);
35565
36583
  return {
35566
36584
  ...account,
35567
36585
  token: token || null,
@@ -35621,111 +36639,36 @@ async function resolveInlineToken(account) {
35621
36639
  }
35622
36640
  throw new Error("Inline token missing (set channels.inline.token, channels.inline.tokenFile, INLINE_TOKEN, or INLINE_BOT_TOKEN)");
35623
36641
  }
35624
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35625
- rejectSymlink: true
35626
- });
36642
+ const token = readInlineTokenFile(tokenFile);
35627
36643
  if (!token)
35628
36644
  throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`);
35629
36645
  return token;
35630
36646
  }
35631
-
35632
- // src/inline/reply-threads.ts
35633
- var GET_CHAT_METHOD = typeof Method.GET_CHAT === "number" && Number.isInteger(Method.GET_CHAT) && Method.GET_CHAT > 0 ? Method.GET_CHAT : 25;
35634
- var GET_CHAT_HISTORY_METHOD = typeof Method.GET_CHAT_HISTORY === "number" && Number.isInteger(Method.GET_CHAT_HISTORY) && Method.GET_CHAT_HISTORY > 0 ? Method.GET_CHAT_HISTORY : 5;
35635
- var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : 38;
35636
- function buildChatPeer(chatId) {
35637
- return {
35638
- type: {
35639
- oneofKind: "chat",
35640
- chat: { chatId }
35641
- }
35642
- };
35643
- }
35644
- function getInlineReplyThreadsCapabilityConfig(params) {
35645
- const account = resolveInlineAccount({
35646
- cfg: params.cfg,
35647
- accountId: params.accountId ?? null
35648
- });
35649
- return {
35650
- replyThreads: account.config.capabilities?.replyThreads === true
35651
- };
35652
- }
35653
- function isInlineReplyThreadsEnabled(params) {
35654
- return getInlineReplyThreadsCapabilityConfig(params).replyThreads;
35655
- }
35656
- function resolveInlineReplyThreadChatId(params) {
35657
- if (!isInlineReplyThreadsEnabled({ cfg: params.cfg, accountId: params.accountId ?? null })) {
35658
- return params.parentChatId;
35659
- }
35660
- if (params.parentChatId == null) {
35661
- return null;
35662
- }
35663
- if (params.threadId == null) {
35664
- return params.parentChatId;
35665
- }
35666
- const normalized = typeof params.threadId === "number" ? Number.isFinite(params.threadId) && Number.isInteger(params.threadId) && params.threadId >= 0 ? BigInt(params.threadId) : null : typeof params.threadId === "string" ? params.threadId.trim() ? (() => {
35667
- try {
35668
- return BigInt(params.threadId.trim());
35669
- } catch {
35670
- return null;
35671
- }
35672
- })() : null : null;
35673
- return normalized ?? params.parentChatId;
35674
- }
35675
- async function loadInlineReplyThreadMetadata(params) {
35676
- const result = await params.client.invokeRaw(GET_CHAT_METHOD, {
35677
- oneofKind: "getChat",
35678
- getChat: { peerId: buildChatPeer(params.chatId) }
35679
- }).catch(() => null);
35680
- if (result?.oneofKind !== "getChat") {
35681
- return null;
35682
- }
35683
- const chat = result.getChat.chat;
35684
- const parentChatId = chat?.parentChatId;
35685
- if (parentChatId == null) {
35686
- return null;
36647
+ function tryReadInlineTokenFile(tokenFile) {
36648
+ try {
36649
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36650
+ rejectSymlink: true
36651
+ }) ?? "";
36652
+ } catch {
36653
+ return "";
35687
36654
  }
35688
- return {
35689
- childChatId: chat?.id ?? params.chatId,
35690
- parentChatId,
35691
- parentMessageId: chat?.parentMessageId ?? null,
35692
- title: chat?.title?.trim() || null
35693
- };
35694
36655
  }
35695
- async function loadInlineReplyThreadAnchorMessage(params) {
35696
- const directResult = await params.client.invokeRaw(GET_MESSAGES_METHOD, {
35697
- oneofKind: "getMessages",
35698
- getMessages: {
35699
- peerId: buildChatPeer(params.parentChatId),
35700
- messageIds: [params.parentMessageId]
35701
- }
35702
- }).catch(() => null);
35703
- if (directResult?.oneofKind === "getMessages") {
35704
- const directTarget = (directResult.getMessages.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
35705
- if (directTarget) {
35706
- return directTarget;
35707
- }
35708
- }
35709
- const historyResult = await params.client.invokeRaw(GET_CHAT_HISTORY_METHOD, {
35710
- oneofKind: "getChatHistory",
35711
- getChatHistory: {
35712
- peerId: buildChatPeer(params.parentChatId),
35713
- offsetId: params.parentMessageId + 1n,
35714
- limit: 8
35715
- }
35716
- }).catch(() => null);
35717
- if (historyResult?.oneofKind !== "getChatHistory") {
35718
- return null;
36656
+ function readInlineTokenFile(tokenFile) {
36657
+ try {
36658
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36659
+ rejectSymlink: true
36660
+ }) ?? "";
36661
+ } catch (error51) {
36662
+ throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`, {
36663
+ cause: error51
36664
+ });
35719
36665
  }
35720
- return (historyResult.getChatHistory.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
35721
36666
  }
35722
36667
 
35723
36668
  // src/inline/media.ts
35724
36669
  import path from "node:path";
35725
36670
 
35726
36671
  // src/sdk-runtime-compat.ts
35727
- var HISTORY_CONTEXT_MARKER = "[Chat messages since your last reply - for context]";
35728
- var CURRENT_MESSAGE_MARKER = "[Current message - respond to this]";
35729
36672
  var MAX_HISTORY_KEYS = 1000;
35730
36673
  var DEFAULT_GROUP_HISTORY_LIMIT = 50;
35731
36674
  function evictOldHistoryKeys(historyMap, maxKeys = MAX_HISTORY_KEYS) {
@@ -35741,20 +36684,6 @@ function evictOldHistoryKeys(historyMap, maxKeys = MAX_HISTORY_KEYS) {
35741
36684
  }
35742
36685
  }
35743
36686
  }
35744
- function buildHistoryContext(params) {
35745
- const lineBreak = params.lineBreak ?? `
35746
- `;
35747
- if (!params.historyText.trim()) {
35748
- return params.currentMessage;
35749
- }
35750
- return [
35751
- HISTORY_CONTEXT_MARKER,
35752
- params.historyText,
35753
- "",
35754
- CURRENT_MESSAGE_MARKER,
35755
- params.currentMessage
35756
- ].join(lineBreak);
35757
- }
35758
36687
  function appendHistoryEntry(params) {
35759
36688
  if (params.limit <= 0) {
35760
36689
  return [];
@@ -35771,32 +36700,6 @@ function appendHistoryEntry(params) {
35771
36700
  evictOldHistoryKeys(params.historyMap);
35772
36701
  return history;
35773
36702
  }
35774
- function buildHistoryContextFromEntries(params) {
35775
- const lineBreak = params.lineBreak ?? `
35776
- `;
35777
- const entries = params.excludeLast === false ? params.entries : params.entries.slice(0, -1);
35778
- if (entries.length === 0) {
35779
- return params.currentMessage;
35780
- }
35781
- return buildHistoryContext({
35782
- historyText: entries.map(params.formatEntry).join(lineBreak),
35783
- currentMessage: params.currentMessage,
35784
- lineBreak
35785
- });
35786
- }
35787
- function buildPendingHistoryContextFromMap(params) {
35788
- if (params.limit <= 0) {
35789
- return params.currentMessage;
35790
- }
35791
- const entries = params.historyMap.get(params.historyKey) ?? [];
35792
- return buildHistoryContextFromEntries({
35793
- entries,
35794
- currentMessage: params.currentMessage,
35795
- formatEntry: params.formatEntry,
35796
- ...params.lineBreak !== undefined ? { lineBreak: params.lineBreak } : {},
35797
- excludeLast: false
35798
- });
35799
- }
35800
36703
  function clearHistoryEntriesIfEnabled(params) {
35801
36704
  if (params.limit <= 0) {
35802
36705
  return;
@@ -35916,20 +36819,16 @@ async function createChannelReplyPipelineCompat(params) {
35916
36819
  }
35917
36820
 
35918
36821
  // src/runtime.ts
35919
- var runtimeKey = "__inlineOpenClawRuntime";
35920
- function runtimeStore() {
35921
- return globalThis;
35922
- }
35923
- function setInlineRuntime(next) {
35924
- runtimeStore()[runtimeKey] = next;
35925
- }
35926
- function getInlineRuntime() {
35927
- const runtime = runtimeStore()[runtimeKey];
35928
- if (!runtime) {
35929
- throw new Error("Inline runtime not initialized");
35930
- }
35931
- return runtime;
35932
- }
36822
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
36823
+ var {
36824
+ setRuntime: setInlineRuntime,
36825
+ clearRuntime: clearInlineRuntime,
36826
+ tryGetRuntime: getOptionalInlineRuntime,
36827
+ getRuntime: getInlineRuntime
36828
+ } = createPluginRuntimeStore({
36829
+ pluginId: "inline",
36830
+ errorMessage: "Inline runtime not initialized"
36831
+ });
35933
36832
 
35934
36833
  // src/inline/media.ts
35935
36834
  var DEFAULT_MEDIA_MAX_MB = 300;
@@ -36526,6 +37425,315 @@ function looksLikeInlineTargetId(raw, normalizedInput) {
36526
37425
  return /^[0-9]+$/.test(normalized);
36527
37426
  }
36528
37427
 
37428
+ // src/inline/thread-routes.ts
37429
+ import path2 from "node:path";
37430
+ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
37431
+ import { readJsonFileWithFallback, writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
37432
+ var TTL_MS = 7 * 24 * 60 * 60 * 1000;
37433
+ var MAX_ENTRIES = 5000;
37434
+ var PERSISTENT_MAX_ENTRIES = 2000;
37435
+ var STORE_VERSION = 1;
37436
+ var PERSISTENT_NAMESPACE = "inline.reply-thread-routes";
37437
+ var INLINE_REPLY_THREAD_ROUTE_KEY = Symbol.for("openclaw.inlineReplyThreadRoutes");
37438
+ var DEFAULT_AGENT_KEY = "__any__";
37439
+ var DEFAULT_STORE_KEY = "__default__";
37440
+ var routeState;
37441
+ var persistentStore;
37442
+ var persistentStoreDisabled = false;
37443
+ function getRouteState() {
37444
+ if (routeState)
37445
+ return routeState;
37446
+ const globalStore = globalThis;
37447
+ const existing = globalStore[INLINE_REPLY_THREAD_ROUTE_KEY];
37448
+ routeState = existing ?? {
37449
+ memory: new Map,
37450
+ fileWrites: new Map
37451
+ };
37452
+ globalStore[INLINE_REPLY_THREAD_ROUTE_KEY] = routeState;
37453
+ return routeState;
37454
+ }
37455
+ function normalizePositiveId(raw) {
37456
+ if (raw == null)
37457
+ return;
37458
+ if (typeof raw === "bigint")
37459
+ return raw >= 0n ? String(raw) : undefined;
37460
+ if (typeof raw === "number") {
37461
+ return Number.isInteger(raw) && raw >= 0 ? String(raw) : undefined;
37462
+ }
37463
+ const trimmed = raw.trim();
37464
+ if (!/^\d+$/.test(trimmed))
37465
+ return;
37466
+ return trimmed;
37467
+ }
37468
+ function normalizeOptionalText(raw) {
37469
+ const trimmed = raw?.trim();
37470
+ return trimmed || undefined;
37471
+ }
37472
+ function safePathSegment(value) {
37473
+ return value.trim().replace(/[^a-z0-9._-]+/gi, "_").slice(0, 80) || "global";
37474
+ }
37475
+ function isRecord3(value) {
37476
+ return typeof value === "object" && value !== null && !Array.isArray(value);
37477
+ }
37478
+ function readString(record2, key) {
37479
+ const value = record2[key];
37480
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
37481
+ }
37482
+ function readTimestamp(record2, key, fallback) {
37483
+ const value = record2[key];
37484
+ return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : fallback;
37485
+ }
37486
+ function normalizeRecord(value) {
37487
+ if (!isRecord3(value))
37488
+ return null;
37489
+ const accountId = readString(value, "accountId");
37490
+ const parentChatId = normalizePositiveId(readString(value, "parentChatId"));
37491
+ const threadId = normalizePositiveId(readString(value, "threadId"));
37492
+ if (!accountId || !parentChatId || !threadId)
37493
+ return null;
37494
+ const now = Date.now();
37495
+ const parentMessageId = normalizePositiveId(readString(value, "parentMessageId"));
37496
+ const title = normalizeOptionalText(readString(value, "title"));
37497
+ const threadLabel = normalizeOptionalText(readString(value, "threadLabel"));
37498
+ const agentId = normalizeOptionalText(readString(value, "agentId"));
37499
+ return {
37500
+ accountId,
37501
+ parentChatId,
37502
+ threadId,
37503
+ createdAt: readTimestamp(value, "createdAt", now),
37504
+ updatedAt: readTimestamp(value, "updatedAt", now),
37505
+ ...parentMessageId ? { parentMessageId } : {},
37506
+ ...title ? { title } : {},
37507
+ ...threadLabel ? { threadLabel } : {},
37508
+ ...agentId ? { agentId } : {}
37509
+ };
37510
+ }
37511
+ function isExpired(record2, now) {
37512
+ return now - record2.updatedAt > TTL_MS;
37513
+ }
37514
+ function reportRouteStateError(error51) {
37515
+ try {
37516
+ getOptionalInlineRuntime()?.logging.getChildLogger({ plugin: "inline", feature: "reply-thread-route-state" }).warn("Inline reply-thread route state failed", { error: String(error51) });
37517
+ } catch {}
37518
+ }
37519
+ function disablePersistentStore(error51) {
37520
+ persistentStoreDisabled = true;
37521
+ persistentStore = undefined;
37522
+ if (!String(error51).includes("openKeyedStore is only available")) {
37523
+ reportRouteStateError(error51);
37524
+ }
37525
+ }
37526
+ function getPersistentStore() {
37527
+ if (persistentStoreDisabled)
37528
+ return;
37529
+ if (persistentStore)
37530
+ return persistentStore;
37531
+ const openKeyedStore = getOptionalInlineRuntime()?.state?.openKeyedStore;
37532
+ if (typeof openKeyedStore !== "function")
37533
+ return;
37534
+ try {
37535
+ persistentStore = openKeyedStore({
37536
+ namespace: PERSISTENT_NAMESPACE,
37537
+ maxEntries: PERSISTENT_MAX_ENTRIES,
37538
+ defaultTtlMs: TTL_MS
37539
+ });
37540
+ return persistentStore;
37541
+ } catch (error51) {
37542
+ disablePersistentStore(error51);
37543
+ return;
37544
+ }
37545
+ }
37546
+ function resolveRoutesPath(accountId) {
37547
+ const resolveStateDir = getOptionalInlineRuntime()?.state?.resolveStateDir;
37548
+ if (typeof resolveStateDir !== "function")
37549
+ return;
37550
+ return path2.join(resolveStateDir(), "inline", "reply-thread-routes", `${safePathSegment(accountId)}.json`);
37551
+ }
37552
+ function activeKey(accountId, parentChatId, agentId) {
37553
+ return `${accountId}:parent:${parentChatId}:agent:${agentId || DEFAULT_AGENT_KEY}`;
37554
+ }
37555
+ function messageKey(accountId, parentChatId, parentMessageId) {
37556
+ return `${accountId}:parent:${parentChatId}:message:${parentMessageId}`;
37557
+ }
37558
+ function keysForRecord(record2) {
37559
+ const keys = new Set;
37560
+ if (record2.parentMessageId) {
37561
+ keys.add(messageKey(record2.accountId, record2.parentChatId, record2.parentMessageId));
37562
+ }
37563
+ if (record2.agentId) {
37564
+ keys.add(activeKey(record2.accountId, record2.parentChatId, record2.agentId));
37565
+ }
37566
+ keys.add(activeKey(record2.accountId, record2.parentChatId));
37567
+ return [...keys];
37568
+ }
37569
+ function keysForLookup(params) {
37570
+ const keys = new Set;
37571
+ if (params.parentMessageId) {
37572
+ keys.add(messageKey(params.accountId, params.parentChatId, params.parentMessageId));
37573
+ }
37574
+ if (params.agentId) {
37575
+ keys.add(activeKey(params.accountId, params.parentChatId, params.agentId));
37576
+ }
37577
+ keys.add(activeKey(params.accountId, params.parentChatId));
37578
+ return [...keys];
37579
+ }
37580
+ function setMemory(key, value, now) {
37581
+ const memory = getRouteState().memory;
37582
+ memory.delete(key);
37583
+ memory.set(key, { value, updatedAt: now });
37584
+ pruneMapToMaxSize(memory, MAX_ENTRIES);
37585
+ }
37586
+ function getMemory(key, now) {
37587
+ const memory = getRouteState().memory;
37588
+ const entry = memory.get(key);
37589
+ if (!entry)
37590
+ return;
37591
+ if (now - entry.updatedAt > TTL_MS) {
37592
+ memory.delete(key);
37593
+ return;
37594
+ }
37595
+ memory.delete(key);
37596
+ memory.set(key, { ...entry, updatedAt: now });
37597
+ return entry.value;
37598
+ }
37599
+ async function readFileRoutes(accountId) {
37600
+ const filePath = resolveRoutesPath(accountId);
37601
+ if (!filePath)
37602
+ return new Map;
37603
+ const fallback = { version: STORE_VERSION, routes: {} };
37604
+ const now = Date.now();
37605
+ try {
37606
+ const { value } = await readJsonFileWithFallback(filePath, fallback);
37607
+ if (value.version !== STORE_VERSION || !isRecord3(value.routes)) {
37608
+ return new Map;
37609
+ }
37610
+ const routes = new Map;
37611
+ for (const [key, raw] of Object.entries(value.routes)) {
37612
+ const route = normalizeRecord(raw);
37613
+ if (route && !isExpired(route, now))
37614
+ routes.set(key, route);
37615
+ }
37616
+ return routes;
37617
+ } catch (error51) {
37618
+ reportRouteStateError(error51);
37619
+ return new Map;
37620
+ }
37621
+ }
37622
+ async function writeFileRoutes(accountId, routes) {
37623
+ const filePath = resolveRoutesPath(accountId);
37624
+ if (!filePath)
37625
+ return;
37626
+ const pruned = [...routes.entries()].sort((left, right) => right[1].updatedAt - left[1].updatedAt).slice(0, PERSISTENT_MAX_ENTRIES);
37627
+ await writeJsonFileAtomically(filePath, {
37628
+ version: STORE_VERSION,
37629
+ routes: Object.fromEntries(pruned)
37630
+ });
37631
+ }
37632
+ function rememberFileRoutes(params) {
37633
+ const state = getRouteState();
37634
+ const queueKey = params.accountId || DEFAULT_STORE_KEY;
37635
+ const previous = state.fileWrites.get(queueKey) ?? Promise.resolve();
37636
+ const next = previous.catch(() => {
37637
+ return;
37638
+ }).then(async () => {
37639
+ const routes = await readFileRoutes(params.accountId);
37640
+ for (const key of params.keys) {
37641
+ routes.set(key, params.record);
37642
+ }
37643
+ await writeFileRoutes(params.accountId, routes);
37644
+ });
37645
+ state.fileWrites.set(queueKey, next);
37646
+ const cleanup = () => {
37647
+ if (state.fileWrites.get(queueKey) === next) {
37648
+ state.fileWrites.delete(queueKey);
37649
+ }
37650
+ };
37651
+ next.then(cleanup, cleanup);
37652
+ next.catch(reportRouteStateError);
37653
+ }
37654
+ function rememberInlineReplyThreadRoute(params) {
37655
+ const accountId = params.accountId.trim();
37656
+ const parentChatId = normalizePositiveId(params.parentChatId);
37657
+ const threadId = normalizePositiveId(params.threadId);
37658
+ if (!accountId || !parentChatId || !threadId)
37659
+ return null;
37660
+ const now = Date.now();
37661
+ const parentMessageId = normalizePositiveId(params.parentMessageId);
37662
+ const title = normalizeOptionalText(params.title);
37663
+ const threadLabel = normalizeOptionalText(params.threadLabel);
37664
+ const agentId = normalizeOptionalText(params.agentId);
37665
+ const record2 = {
37666
+ accountId,
37667
+ parentChatId,
37668
+ threadId,
37669
+ createdAt: now,
37670
+ updatedAt: now,
37671
+ ...parentMessageId ? { parentMessageId } : {},
37672
+ ...title ? { title } : {},
37673
+ ...threadLabel ? { threadLabel } : {},
37674
+ ...agentId ? { agentId } : {}
37675
+ };
37676
+ const keys = keysForRecord(record2);
37677
+ for (const key of keys) {
37678
+ setMemory(key, record2, now);
37679
+ }
37680
+ const store = getPersistentStore();
37681
+ if (store) {
37682
+ for (const key of keys) {
37683
+ store.register(key, record2, { ttlMs: TTL_MS }).catch(disablePersistentStore);
37684
+ }
37685
+ return record2;
37686
+ }
37687
+ rememberFileRoutes({ accountId, keys, record: record2 });
37688
+ return record2;
37689
+ }
37690
+ async function lookupInlineReplyThreadRoute(params) {
37691
+ const accountId = params.accountId.trim();
37692
+ const parentChatId = normalizePositiveId(params.parentChatId);
37693
+ if (!accountId || !parentChatId)
37694
+ return null;
37695
+ const parentMessageId = normalizePositiveId(params.parentMessageId);
37696
+ const agentId = normalizeOptionalText(params.agentId);
37697
+ const keys = keysForLookup({
37698
+ accountId,
37699
+ parentChatId,
37700
+ ...parentMessageId ? { parentMessageId } : {},
37701
+ ...agentId ? { agentId } : {}
37702
+ });
37703
+ const now = Date.now();
37704
+ for (const key of keys) {
37705
+ const cached3 = getMemory(key, now);
37706
+ if (cached3)
37707
+ return cached3;
37708
+ }
37709
+ const store = getPersistentStore();
37710
+ if (store) {
37711
+ for (const key of keys) {
37712
+ try {
37713
+ const found = await store.lookup(key);
37714
+ const normalized = normalizeRecord(found);
37715
+ if (normalized && !isExpired(normalized, now)) {
37716
+ setMemory(key, normalized, now);
37717
+ return normalized;
37718
+ }
37719
+ } catch (error51) {
37720
+ disablePersistentStore(error51);
37721
+ break;
37722
+ }
37723
+ }
37724
+ }
37725
+ const fileRoutes = await readFileRoutes(accountId);
37726
+ for (const key of keys) {
37727
+ const found = fileRoutes.get(key);
37728
+ const normalized = normalizeRecord(found);
37729
+ if (normalized) {
37730
+ setMemory(key, normalized, now);
37731
+ return normalized;
37732
+ }
37733
+ }
37734
+ return null;
37735
+ }
37736
+
36529
37737
  // src/inline/outbound-sanitize.ts
36530
37738
  var HEARTBEAT_TOKEN = "HEARTBEAT_OK";
36531
37739
  var OPENCLAW_RUNTIME_CONTEXT_NOTICE = "This context is runtime-generated, not user-authored. Keep internal details private.";
@@ -36898,8 +38106,8 @@ for (const group of ACTION_GROUPS) {
36898
38106
  }
36899
38107
  }
36900
38108
  var SUPPORTED_ACTIONS = Array.from(ACTION_TO_GATE_KEY.keys());
36901
- var GET_MESSAGES_METHOD2 = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
36902
- var CREATE_SUBTHREAD_METHOD = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 43;
38109
+ var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
38110
+ var CREATE_SUBTHREAD_METHOD = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 42;
36903
38111
  var INLINE_ACTION_MAX_ROWS = 8;
36904
38112
  var INLINE_ACTION_MAX_PER_ROW = 8;
36905
38113
  function suppressedInternalTextResult() {
@@ -36939,7 +38147,7 @@ function optionalVisibleActionText(raw, label) {
36939
38147
  }
36940
38148
  return visible.text.trim() || undefined;
36941
38149
  }
36942
- function isRecord3(value) {
38150
+ function isRecord4(value) {
36943
38151
  return typeof value === "object" && value !== null;
36944
38152
  }
36945
38153
  function normalizeReplyMarkupButtons(raw) {
@@ -36951,7 +38159,7 @@ function normalizeReplyMarkupButtons(raw) {
36951
38159
  continue;
36952
38160
  const row = [];
36953
38161
  for (const candidateButton of candidateRow) {
36954
- if (!isRecord3(candidateButton))
38162
+ if (!isRecord4(candidateButton))
36955
38163
  continue;
36956
38164
  const text = sanitizeInlineActionLabel(typeof candidateButton.text === "string" ? candidateButton.text : "");
36957
38165
  const callbackData = sanitizeInlineActionCallbackData(typeof candidateButton.callback_data === "string" ? candidateButton.callback_data : "");
@@ -37145,6 +38353,20 @@ function resolveReactionMessageId(params) {
37145
38353
  }
37146
38354
  return;
37147
38355
  }
38356
+ function resolveThreadParentMessageId(params) {
38357
+ const explicit = readFlexibleId(params.args, "parentMessageId") ?? readFlexibleId(params.args, "messageId") ?? readFlexibleId(params.args, "replyTo") ?? readFlexibleId(params.args, "replyToId") ?? readStringParam(params.args, "parentMessageId") ?? readStringParam(params.args, "messageId") ?? readStringParam(params.args, "replyTo") ?? readStringParam(params.args, "replyToId");
38358
+ if (explicit)
38359
+ return explicit;
38360
+ const fromContext = params.toolContext?.currentMessageId;
38361
+ if (typeof fromContext === "number" && Number.isFinite(fromContext)) {
38362
+ return String(Math.trunc(fromContext));
38363
+ }
38364
+ if (typeof fromContext === "string") {
38365
+ const trimmed = fromContext.trim();
38366
+ return trimmed || undefined;
38367
+ }
38368
+ return;
38369
+ }
37148
38370
  function parseOptionalInlineId(raw, label) {
37149
38371
  if (raw == null)
37150
38372
  return;
@@ -37354,7 +38576,7 @@ function resolveMessageSendTargetFromParams(params) {
37354
38576
  chatId: BigInt(normalized)
37355
38577
  };
37356
38578
  }
37357
- function buildChatPeer2(chatId) {
38579
+ function buildChatPeer(chatId) {
37358
38580
  return {
37359
38581
  type: {
37360
38582
  oneofKind: "chat",
@@ -37484,10 +38706,10 @@ async function reactionAlreadyExists(params) {
37484
38706
  return reactions.some((reaction) => reaction.emoji === params.emoji && reaction.userIds.includes(myId));
37485
38707
  }
37486
38708
  async function findMessageById(params) {
37487
- const directResult = GET_MESSAGES_METHOD2 == null ? null : await params.client.invokeRaw(GET_MESSAGES_METHOD2, {
38709
+ const directResult = GET_MESSAGES_METHOD == null ? null : await params.client.invokeRaw(GET_MESSAGES_METHOD, {
37488
38710
  oneofKind: "getMessages",
37489
38711
  getMessages: {
37490
- peerId: buildChatPeer2(params.chatId),
38712
+ peerId: buildChatPeer(params.chatId),
37491
38713
  messageIds: [params.messageId]
37492
38714
  }
37493
38715
  }).catch(() => null);
@@ -37497,7 +38719,7 @@ async function findMessageById(params) {
37497
38719
  const result = await params.client.invokeRaw(Method.GET_CHAT_HISTORY, {
37498
38720
  oneofKind: "getChatHistory",
37499
38721
  getChatHistory: {
37500
- peerId: buildChatPeer2(params.chatId),
38722
+ peerId: buildChatPeer(params.chatId),
37501
38723
  offsetId: params.messageId + 1n,
37502
38724
  limit: 8
37503
38725
  }
@@ -37519,7 +38741,7 @@ async function withInlineClient(params) {
37519
38741
  });
37520
38742
  await client.connect();
37521
38743
  try {
37522
- return await params.fn(client);
38744
+ return await params.fn(client, account);
37523
38745
  } finally {
37524
38746
  await client.close().catch(() => {});
37525
38747
  }
@@ -37571,7 +38793,7 @@ async function resolveSpaceIdFromParams(params) {
37571
38793
  const chatId = BigInt(normalizeChatId(chatTarget));
37572
38794
  const chatResult = await params.client.invokeRaw(Method.GET_CHAT, {
37573
38795
  oneofKind: "getChat",
37574
- getChat: { peerId: buildChatPeer2(chatId) }
38796
+ getChat: { peerId: buildChatPeer(chatId) }
37575
38797
  });
37576
38798
  if (chatResult.oneofKind !== "getChat") {
37577
38799
  throw new Error(`inline action: expected getChat result, got ${String(chatResult.oneofKind)}`);
@@ -37788,16 +39010,16 @@ var inlineMessageActions = {
37788
39010
  }
37789
39011
  if (normalizedAction === "reply" || normalizedAction === "thread-reply") {
37790
39012
  const parseMarkdown = resolveInlineAccount({ cfg, accountId: accountId ?? null }).config.parseMarkdown ?? true;
37791
- const replyThreadsEnabled = normalizedAction === "thread-reply" && isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null });
39013
+ const isThreadReply = normalizedAction === "thread-reply";
37792
39014
  return await withInlineClient({
37793
39015
  cfg,
37794
39016
  accountId,
37795
39017
  fn: async (client) => {
37796
39018
  const actions = resolveInlineMessageActionsParam(params);
37797
- if (replyThreadsEnabled) {
39019
+ if (isThreadReply) {
37798
39020
  const rawThreadId = readFlexibleId(params, "threadId") ?? readStringParam(params, "threadId");
37799
39021
  if (!rawThreadId) {
37800
- throw new Error("inline thread-reply: threadId is required when reply threads are enabled");
39022
+ throw new Error("inline thread-reply: threadId is required. Call thread-create first or use reply for the parent chat.");
37801
39023
  }
37802
39024
  const chatId2 = parseInlineId(rawThreadId, "threadId");
37803
39025
  const replyToMsgId2 = parseOptionalInlineId(readFlexibleId(params, "messageId") ?? readFlexibleId(params, "replyTo") ?? readFlexibleId(params, "replyToId") ?? readStringParam(params, "messageId") ?? readStringParam(params, "replyTo") ?? readStringParam(params, "replyToId"), "messageId");
@@ -37821,7 +39043,7 @@ var inlineMessageActions = {
37821
39043
  replyToId: replyToMsgId2 != null ? String(replyToMsgId2) : null
37822
39044
  });
37823
39045
  }
37824
- const replyParams = normalizedAction === "thread-reply" && params.threadId != null && params.to == null && params.chatId == null && params.channelId == null ? { ...params, to: params.threadId } : params;
39046
+ const replyParams = params;
37825
39047
  const chatId = resolveChatIdFromParams(replyParams);
37826
39048
  const replyToMsgId = parseInlineId(readFlexibleId(replyParams, "messageId") ?? readFlexibleId(replyParams, "replyTo") ?? readFlexibleId(replyParams, "replyToId") ?? readStringParam(replyParams, "messageId") ?? readStringParam(replyParams, "replyTo") ?? readStringParam(replyParams, "replyToId", { required: true }), "messageId");
37827
39049
  const text = resolveInlineActionText(replyParams, { required: true });
@@ -37881,7 +39103,7 @@ var inlineMessageActions = {
37881
39103
  oneofKind: "deleteReaction",
37882
39104
  deleteReaction: {
37883
39105
  emoji: emoji3,
37884
- peerId: buildChatPeer2(chatId),
39106
+ peerId: buildChatPeer(chatId),
37885
39107
  messageId
37886
39108
  }
37887
39109
  });
@@ -37919,7 +39141,7 @@ var inlineMessageActions = {
37919
39141
  addReaction: {
37920
39142
  emoji: emoji3,
37921
39143
  messageId,
37922
- peerId: buildChatPeer2(chatId)
39144
+ peerId: buildChatPeer(chatId)
37923
39145
  }
37924
39146
  });
37925
39147
  if (result.oneofKind !== "addReaction") {
@@ -37986,7 +39208,7 @@ var inlineMessageActions = {
37986
39208
  const result = await client.invokeRaw(Method.GET_CHAT_HISTORY, {
37987
39209
  oneofKind: "getChatHistory",
37988
39210
  getChatHistory: {
37989
- peerId: buildChatPeer2(chatId),
39211
+ peerId: buildChatPeer(chatId),
37990
39212
  ...offsetId != null ? { offsetId } : {},
37991
39213
  limit
37992
39214
  }
@@ -38014,7 +39236,7 @@ var inlineMessageActions = {
38014
39236
  const result = await client.invokeRaw(Method.SEARCH_MESSAGES, {
38015
39237
  oneofKind: "searchMessages",
38016
39238
  searchMessages: {
38017
- peerId: buildChatPeer2(chatId),
39239
+ peerId: buildChatPeer(chatId),
38018
39240
  queries: [query],
38019
39241
  limit,
38020
39242
  ...offsetId != null ? { offsetId } : {}
@@ -38050,7 +39272,7 @@ var inlineMessageActions = {
38050
39272
  oneofKind: "editMessage",
38051
39273
  editMessage: {
38052
39274
  messageId,
38053
- peerId: buildChatPeer2(chatId),
39275
+ peerId: buildChatPeer(chatId),
38054
39276
  text: visibleText.text,
38055
39277
  ...actions !== undefined ? { actions } : {},
38056
39278
  parseMarkdown
@@ -38077,7 +39299,7 @@ var inlineMessageActions = {
38077
39299
  const chatId = resolveChatIdFromParams(params);
38078
39300
  const result = await client.invokeRaw(Method.GET_CHAT, {
38079
39301
  oneofKind: "getChat",
38080
- getChat: { peerId: buildChatPeer2(chatId) }
39302
+ getChat: { peerId: buildChatPeer(chatId) }
38081
39303
  });
38082
39304
  if (result.oneofKind !== "getChat") {
38083
39305
  throw new Error(`inline action: expected getChat result, got ${String(result.oneofKind)}`);
@@ -38160,11 +39382,11 @@ var inlineMessageActions = {
38160
39382
  });
38161
39383
  }
38162
39384
  if (normalizedAction === "channel-create" || normalizedAction === "thread-create") {
38163
- const replyThreadsEnabled = normalizedAction === "thread-create" && isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null });
39385
+ const isThreadCreate = normalizedAction === "thread-create";
38164
39386
  return await withInlineClient({
38165
39387
  cfg,
38166
39388
  accountId,
38167
- fn: async (client) => {
39389
+ fn: async (client, account) => {
38168
39390
  const title = requireVisibleActionText(readStringParam(params, "title") ?? readStringParam(params, "name") ?? readStringParam(params, "threadName") ?? readStringParam(params, "message", { required: true }), "title");
38169
39391
  const description = optionalVisibleActionText(readStringParam(params, "description"), "description");
38170
39392
  const emoji3 = readStringParam(params, "emoji");
@@ -38183,9 +39405,12 @@ var inlineMessageActions = {
38183
39405
  values: participantRefs,
38184
39406
  label: "participant"
38185
39407
  });
38186
- if (replyThreadsEnabled) {
39408
+ if (isThreadCreate) {
38187
39409
  const parentChatId = resolveChatIdFromParams(params);
38188
- const parentMessageId = parseOptionalInlineId(readFlexibleId(params, "parentMessageId") ?? readFlexibleId(params, "messageId") ?? readFlexibleId(params, "replyTo") ?? readFlexibleId(params, "replyToId") ?? readStringParam(params, "parentMessageId") ?? readStringParam(params, "messageId") ?? readStringParam(params, "replyTo") ?? readStringParam(params, "replyToId"), "parentMessageId");
39410
+ const parentMessageId = parseOptionalInlineId(resolveThreadParentMessageId({
39411
+ args: params,
39412
+ ...toolContext != null ? { toolContext: { currentMessageId: toolContext.currentMessageId } } : {}
39413
+ }), "parentMessageId");
38189
39414
  const result2 = await client.invokeRaw(CREATE_SUBTHREAD_METHOD, {
38190
39415
  oneofKind: "createSubthread",
38191
39416
  createSubthread: {
@@ -38200,12 +39425,23 @@ var inlineMessageActions = {
38200
39425
  if (result2.oneofKind !== "createSubthread") {
38201
39426
  throw new Error(`inline action: expected createSubthread result, got ${String(result2.oneofKind)}`);
38202
39427
  }
39428
+ const createdChat = result2.createSubthread.chat ?? null;
39429
+ if (createdChat?.id != null) {
39430
+ const routeParentMessageId = createdChat.parentMessageId ?? parentMessageId;
39431
+ rememberInlineReplyThreadRoute({
39432
+ accountId: account.accountId,
39433
+ parentChatId: createdChat.parentChatId ?? parentChatId,
39434
+ threadId: createdChat.id,
39435
+ title: createdChat.title ?? title,
39436
+ ...routeParentMessageId != null ? { parentMessageId: routeParentMessageId } : {}
39437
+ });
39438
+ }
38203
39439
  return jsonResult(toJsonSafe({
38204
39440
  ok: true,
38205
39441
  title,
38206
39442
  parentChatId: String(parentChatId),
38207
39443
  parentMessageId: parentMessageId != null ? String(parentMessageId) : null,
38208
- chat: result2.createSubthread.chat ?? null,
39444
+ chat: createdChat,
38209
39445
  dialog: result2.createSubthread.dialog ?? null,
38210
39446
  anchorMessage: result2.createSubthread.anchorMessage ?? null
38211
39447
  }));
@@ -38245,7 +39481,7 @@ var inlineMessageActions = {
38245
39481
  const result = await client.invokeRaw(Method.DELETE_CHAT, {
38246
39482
  oneofKind: "deleteChat",
38247
39483
  deleteChat: {
38248
- peerId: buildChatPeer2(chatId)
39484
+ peerId: buildChatPeer(chatId)
38249
39485
  }
38250
39486
  });
38251
39487
  if (result.oneofKind !== "deleteChat") {
@@ -38455,7 +39691,7 @@ var inlineMessageActions = {
38455
39691
  const result = await client.invokeRaw(Method.DELETE_MESSAGES, {
38456
39692
  oneofKind: "deleteMessages",
38457
39693
  deleteMessages: {
38458
- peerId: buildChatPeer2(chatId),
39694
+ peerId: buildChatPeer(chatId),
38459
39695
  messageIds: deduped
38460
39696
  }
38461
39697
  });
@@ -38481,7 +39717,7 @@ var inlineMessageActions = {
38481
39717
  const result = await client.invokeRaw(Method.PIN_MESSAGE, {
38482
39718
  oneofKind: "pinMessage",
38483
39719
  pinMessage: {
38484
- peerId: buildChatPeer2(chatId),
39720
+ peerId: buildChatPeer(chatId),
38485
39721
  messageId,
38486
39722
  unpin
38487
39723
  }
@@ -38506,7 +39742,7 @@ var inlineMessageActions = {
38506
39742
  const chatId = resolveChatIdFromParams(params);
38507
39743
  const result = await client.invokeRaw(Method.GET_CHAT, {
38508
39744
  oneofKind: "getChat",
38509
- getChat: { peerId: buildChatPeer2(chatId) }
39745
+ getChat: { peerId: buildChatPeer(chatId) }
38510
39746
  });
38511
39747
  if (result.oneofKind !== "getChat") {
38512
39748
  throw new Error(`inline action: expected getChat result, got ${String(result.oneofKind)}`);
@@ -38719,6 +39955,115 @@ function isInlineExecApprovalHandlerConfigured(params) {
38719
39955
  });
38720
39956
  }
38721
39957
 
39958
+ // src/inline/reply-threads.ts
39959
+ var GET_CHAT_METHOD = typeof Method.GET_CHAT === "number" && Number.isInteger(Method.GET_CHAT) && Method.GET_CHAT > 0 ? Method.GET_CHAT : 25;
39960
+ var GET_CHAT_HISTORY_METHOD = typeof Method.GET_CHAT_HISTORY === "number" && Number.isInteger(Method.GET_CHAT_HISTORY) && Method.GET_CHAT_HISTORY > 0 ? Method.GET_CHAT_HISTORY : 5;
39961
+ var GET_MESSAGES_METHOD2 = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : 38;
39962
+ var CREATE_SUBTHREAD_METHOD2 = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 42;
39963
+ function buildChatPeer2(chatId) {
39964
+ return {
39965
+ type: {
39966
+ oneofKind: "chat",
39967
+ chat: { chatId }
39968
+ }
39969
+ };
39970
+ }
39971
+ function getInlineReplyThreadsCapabilityConfig(params) {
39972
+ return { replyThreads: true };
39973
+ }
39974
+ function isInlineReplyThreadsEnabled(params) {
39975
+ return getInlineReplyThreadsCapabilityConfig(params).replyThreads;
39976
+ }
39977
+ function resolveInlineReplyThreadChatId(params) {
39978
+ params.cfg;
39979
+ params.accountId;
39980
+ if (params.parentChatId == null) {
39981
+ return null;
39982
+ }
39983
+ if (params.threadId == null) {
39984
+ return params.parentChatId;
39985
+ }
39986
+ const normalized = typeof params.threadId === "number" ? Number.isFinite(params.threadId) && Number.isInteger(params.threadId) && params.threadId >= 0 ? BigInt(params.threadId) : null : typeof params.threadId === "string" ? params.threadId.trim() ? (() => {
39987
+ try {
39988
+ return BigInt(params.threadId.trim());
39989
+ } catch {
39990
+ return null;
39991
+ }
39992
+ })() : null : null;
39993
+ return normalized ?? params.parentChatId;
39994
+ }
39995
+ async function loadInlineReplyThreadMetadata(params) {
39996
+ const result = await params.client.invokeRaw(GET_CHAT_METHOD, {
39997
+ oneofKind: "getChat",
39998
+ getChat: { peerId: buildChatPeer2(params.chatId) }
39999
+ }).catch(() => null);
40000
+ if (result?.oneofKind !== "getChat") {
40001
+ return null;
40002
+ }
40003
+ const chat = result.getChat.chat;
40004
+ const parentChatId = chat?.parentChatId;
40005
+ if (parentChatId == null) {
40006
+ return null;
40007
+ }
40008
+ return {
40009
+ childChatId: chat?.id ?? params.chatId,
40010
+ parentChatId,
40011
+ parentMessageId: chat?.parentMessageId ?? null,
40012
+ title: chat?.title?.trim() || null
40013
+ };
40014
+ }
40015
+ async function loadInlineReplyThreadAnchorMessage(params) {
40016
+ const directResult = await params.client.invokeRaw(GET_MESSAGES_METHOD2, {
40017
+ oneofKind: "getMessages",
40018
+ getMessages: {
40019
+ peerId: buildChatPeer2(params.parentChatId),
40020
+ messageIds: [params.parentMessageId]
40021
+ }
40022
+ }).catch(() => null);
40023
+ if (directResult?.oneofKind === "getMessages") {
40024
+ const directTarget = (directResult.getMessages.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
40025
+ if (directTarget) {
40026
+ return directTarget;
40027
+ }
40028
+ }
40029
+ const historyResult = await params.client.invokeRaw(GET_CHAT_HISTORY_METHOD, {
40030
+ oneofKind: "getChatHistory",
40031
+ getChatHistory: {
40032
+ peerId: buildChatPeer2(params.parentChatId),
40033
+ offsetId: params.parentMessageId + 1n,
40034
+ limit: 8
40035
+ }
40036
+ }).catch(() => null);
40037
+ if (historyResult?.oneofKind !== "getChatHistory") {
40038
+ return null;
40039
+ }
40040
+ return (historyResult.getChatHistory.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
40041
+ }
40042
+ async function createInlineReplyThreadForMessage(params) {
40043
+ const result = await params.client.invokeRaw(CREATE_SUBTHREAD_METHOD2, {
40044
+ oneofKind: "createSubthread",
40045
+ createSubthread: {
40046
+ parentChatId: params.parentChatId,
40047
+ parentMessageId: params.parentMessageId,
40048
+ participants: []
40049
+ }
40050
+ });
40051
+ if (result.oneofKind !== "createSubthread") {
40052
+ return null;
40053
+ }
40054
+ const chat = result.createSubthread.chat;
40055
+ if (!chat?.id) {
40056
+ return null;
40057
+ }
40058
+ return {
40059
+ childChatId: chat.id,
40060
+ parentChatId: chat.parentChatId ?? params.parentChatId,
40061
+ parentMessageId: chat.parentMessageId ?? params.parentMessageId,
40062
+ title: chat.title?.trim() || null,
40063
+ anchorMessage: result.createSubthread.anchorMessage ?? null
40064
+ };
40065
+ }
40066
+
38722
40067
  // src/inline/approval-handler.runtime.ts
38723
40068
  var log = createSubsystemLogger("inline/approvals");
38724
40069
  function resolveHandlerContext(params) {
@@ -38938,5 +40283,5 @@ export {
38938
40283
  inlineApprovalNativeRuntime
38939
40284
  };
38940
40285
 
38941
- //# debugId=4122BE0AA913DC7F64756E2164756E21
40286
+ //# debugId=9CC8894E01E42C4C64756E2164756E21
38942
40287
  //# sourceMappingURL=approval-handler.runtime.js.map