@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
  });
@@ -5577,6 +5603,8 @@ var MessageEntity_Type;
5577
5603
  MessageEntity_Type2[MessageEntity_Type2["CODE"] = 8] = "CODE";
5578
5604
  MessageEntity_Type2[MessageEntity_Type2["PRE"] = 9] = "PRE";
5579
5605
  MessageEntity_Type2[MessageEntity_Type2["PHONE_NUMBER"] = 10] = "PHONE_NUMBER";
5606
+ MessageEntity_Type2[MessageEntity_Type2["THREAD"] = 11] = "THREAD";
5607
+ MessageEntity_Type2[MessageEntity_Type2["THREAD_TITLE"] = 12] = "THREAD_TITLE";
5580
5608
  })(MessageEntity_Type || (MessageEntity_Type = {}));
5581
5609
  var Member_Role;
5582
5610
  (function(Member_Role2) {
@@ -5584,6 +5612,15 @@ var Member_Role;
5584
5612
  Member_Role2[Member_Role2["ADMIN"] = 1] = "ADMIN";
5585
5613
  Member_Role2[Member_Role2["MEMBER"] = 2] = "MEMBER";
5586
5614
  })(Member_Role || (Member_Role = {}));
5615
+ var UrlPreview_MediaType;
5616
+ (function(UrlPreview_MediaType2) {
5617
+ UrlPreview_MediaType2[UrlPreview_MediaType2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
5618
+ UrlPreview_MediaType2[UrlPreview_MediaType2["ARTICLE"] = 1] = "ARTICLE";
5619
+ UrlPreview_MediaType2[UrlPreview_MediaType2["IMAGE"] = 2] = "IMAGE";
5620
+ UrlPreview_MediaType2[UrlPreview_MediaType2["VIDEO"] = 3] = "VIDEO";
5621
+ UrlPreview_MediaType2[UrlPreview_MediaType2["DOCUMENT"] = 4] = "DOCUMENT";
5622
+ UrlPreview_MediaType2[UrlPreview_MediaType2["EMBED"] = 5] = "EMBED";
5623
+ })(UrlPreview_MediaType || (UrlPreview_MediaType = {}));
5587
5624
  var MessageAttachmentExternalTask_Status;
5588
5625
  (function(MessageAttachmentExternalTask_Status2) {
5589
5626
  MessageAttachmentExternalTask_Status2[MessageAttachmentExternalTask_Status2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
@@ -5726,6 +5763,9 @@ var Method;
5726
5763
  Method2[Method2["REVOKE_SESSION"] = 50] = "REVOKE_SESSION";
5727
5764
  Method2[Method2["UPDATE_DIALOG_OPEN"] = 51] = "UPDATE_DIALOG_OPEN";
5728
5765
  Method2[Method2["UPDATE_DIALOG_ORDER"] = 52] = "UPDATE_DIALOG_ORDER";
5766
+ Method2[Method2["CLEAR_CHAT_HISTORY"] = 53] = "CLEAR_CHAT_HISTORY";
5767
+ Method2[Method2["DELETE_BOT"] = 54] = "DELETE_BOT";
5768
+ Method2[Method2["DELETE_MESSAGE_ATTACHMENT"] = 55] = "DELETE_MESSAGE_ATTACHMENT";
5729
5769
  })(Method || (Method = {}));
5730
5770
  var PushNotificationProvider;
5731
5771
  (function(PushNotificationProvider2) {
@@ -7695,7 +7735,9 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7695
7735
  { no: 3, name: "length", kind: "scalar", T: 3, L: 0 },
7696
7736
  { no: 4, name: "mention", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityMention },
7697
7737
  { no: 5, name: "text_url", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityTextUrl },
7698
- { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre }
7738
+ { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre },
7739
+ { no: 7, name: "thread", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityThread },
7740
+ { no: 8, name: "thread_title", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityThreadTitle }
7699
7741
  ]);
7700
7742
  }
7701
7743
  create(value) {
@@ -7740,6 +7782,18 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7740
7782
  pre: MessageEntity_MessageEntityPre.internalBinaryRead(reader, reader.uint32(), options, message.entity.pre)
7741
7783
  };
7742
7784
  break;
7785
+ case 7:
7786
+ message.entity = {
7787
+ oneofKind: "thread",
7788
+ thread: MessageEntity_MessageEntityThread.internalBinaryRead(reader, reader.uint32(), options, message.entity.thread)
7789
+ };
7790
+ break;
7791
+ case 8:
7792
+ message.entity = {
7793
+ oneofKind: "threadTitle",
7794
+ threadTitle: MessageEntity_MessageEntityThreadTitle.internalBinaryRead(reader, reader.uint32(), options, message.entity.threadTitle)
7795
+ };
7796
+ break;
7743
7797
  default:
7744
7798
  let u = options.readUnknownField;
7745
7799
  if (u === "throw")
@@ -7764,6 +7818,10 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7764
7818
  MessageEntity_MessageEntityTextUrl.internalBinaryWrite(message.entity.textUrl, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
7765
7819
  if (message.entity.oneofKind === "pre")
7766
7820
  MessageEntity_MessageEntityPre.internalBinaryWrite(message.entity.pre, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
7821
+ if (message.entity.oneofKind === "thread")
7822
+ MessageEntity_MessageEntityThread.internalBinaryWrite(message.entity.thread, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
7823
+ if (message.entity.oneofKind === "threadTitle")
7824
+ MessageEntity_MessageEntityThreadTitle.internalBinaryWrite(message.entity.threadTitle, writer.tag(8, import_runtime.WireType.LengthDelimited).fork(), options).join();
7767
7825
  let u = options.writeUnknownFields;
7768
7826
  if (u !== false)
7769
7827
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -7901,6 +7959,99 @@ class MessageEntity_MessageEntityPre$Type extends import_runtime4.MessageType {
7901
7959
  }
7902
7960
  var MessageEntity_MessageEntityPre = new MessageEntity_MessageEntityPre$Type;
7903
7961
 
7962
+ class MessageEntity_MessageEntityThread$Type extends import_runtime4.MessageType {
7963
+ constructor() {
7964
+ super("MessageEntity.MessageEntityThread", [
7965
+ { no: 1, name: "chat_id", kind: "scalar", T: 3, L: 0 }
7966
+ ]);
7967
+ }
7968
+ create(value) {
7969
+ const message = globalThis.Object.create(this.messagePrototype);
7970
+ message.chatId = 0n;
7971
+ if (value !== undefined)
7972
+ import_runtime3.reflectionMergePartial(this, message, value);
7973
+ return message;
7974
+ }
7975
+ internalBinaryRead(reader, length, options, target) {
7976
+ let message = target ?? this.create(), end = reader.pos + length;
7977
+ while (reader.pos < end) {
7978
+ let [fieldNo, wireType] = reader.tag();
7979
+ switch (fieldNo) {
7980
+ case 1:
7981
+ message.chatId = reader.int64().toBigInt();
7982
+ break;
7983
+ default:
7984
+ let u = options.readUnknownField;
7985
+ if (u === "throw")
7986
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
7987
+ let d = reader.skip(wireType);
7988
+ if (u !== false)
7989
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
7990
+ }
7991
+ }
7992
+ return message;
7993
+ }
7994
+ internalBinaryWrite(message, writer, options) {
7995
+ if (message.chatId !== 0n)
7996
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.chatId);
7997
+ let u = options.writeUnknownFields;
7998
+ if (u !== false)
7999
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8000
+ return writer;
8001
+ }
8002
+ }
8003
+ var MessageEntity_MessageEntityThread = new MessageEntity_MessageEntityThread$Type;
8004
+
8005
+ class MessageEntity_MessageEntityThreadTitle$Type extends import_runtime4.MessageType {
8006
+ constructor() {
8007
+ super("MessageEntity.MessageEntityThreadTitle", [
8008
+ { no: 1, name: "space_id", kind: "scalar", T: 3, L: 0 },
8009
+ { no: 2, name: "title", kind: "scalar", T: 9 }
8010
+ ]);
8011
+ }
8012
+ create(value) {
8013
+ const message = globalThis.Object.create(this.messagePrototype);
8014
+ message.spaceId = 0n;
8015
+ message.title = "";
8016
+ if (value !== undefined)
8017
+ import_runtime3.reflectionMergePartial(this, message, value);
8018
+ return message;
8019
+ }
8020
+ internalBinaryRead(reader, length, options, target) {
8021
+ let message = target ?? this.create(), end = reader.pos + length;
8022
+ while (reader.pos < end) {
8023
+ let [fieldNo, wireType] = reader.tag();
8024
+ switch (fieldNo) {
8025
+ case 1:
8026
+ message.spaceId = reader.int64().toBigInt();
8027
+ break;
8028
+ case 2:
8029
+ message.title = reader.string();
8030
+ break;
8031
+ default:
8032
+ let u = options.readUnknownField;
8033
+ if (u === "throw")
8034
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8035
+ let d = reader.skip(wireType);
8036
+ if (u !== false)
8037
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8038
+ }
8039
+ }
8040
+ return message;
8041
+ }
8042
+ internalBinaryWrite(message, writer, options) {
8043
+ if (message.spaceId !== 0n)
8044
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.spaceId);
8045
+ if (message.title !== "")
8046
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.title);
8047
+ let u = options.writeUnknownFields;
8048
+ if (u !== false)
8049
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8050
+ return writer;
8051
+ }
8052
+ }
8053
+ var MessageEntity_MessageEntityThreadTitle = new MessageEntity_MessageEntityThreadTitle$Type;
8054
+
7904
8055
  class MessageReactions$Type extends import_runtime4.MessageType {
7905
8056
  constructor() {
7906
8057
  super("MessageReactions", [
@@ -8098,7 +8249,8 @@ class Space$Type extends import_runtime4.MessageType {
8098
8249
  { no: 1, name: "id", kind: "scalar", T: 3, L: 0 },
8099
8250
  { no: 2, name: "name", kind: "scalar", T: 9 },
8100
8251
  { no: 3, name: "creator", kind: "scalar", T: 8 },
8101
- { no: 4, name: "date", kind: "scalar", T: 3, L: 0 }
8252
+ { no: 4, name: "date", kind: "scalar", T: 3, L: 0 },
8253
+ { no: 5, name: "is_public", kind: "scalar", opt: true, T: 8 }
8102
8254
  ]);
8103
8255
  }
8104
8256
  create(value) {
@@ -8128,6 +8280,9 @@ class Space$Type extends import_runtime4.MessageType {
8128
8280
  case 4:
8129
8281
  message.date = reader.int64().toBigInt();
8130
8282
  break;
8283
+ case 5:
8284
+ message.isPublic = reader.bool();
8285
+ break;
8131
8286
  default:
8132
8287
  let u = options.readUnknownField;
8133
8288
  if (u === "throw")
@@ -8148,6 +8303,8 @@ class Space$Type extends import_runtime4.MessageType {
8148
8303
  writer.tag(3, import_runtime.WireType.Varint).bool(message.creator);
8149
8304
  if (message.date !== 0n)
8150
8305
  writer.tag(4, import_runtime.WireType.Varint).int64(message.date);
8306
+ if (message.isPublic !== undefined)
8307
+ writer.tag(5, import_runtime.WireType.Varint).bool(message.isPublic);
8151
8308
  let u = options.writeUnknownFields;
8152
8309
  if (u !== false)
8153
8310
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8468,7 +8625,13 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8468
8625
  { no: 4, name: "title", kind: "scalar", opt: true, T: 9 },
8469
8626
  { no: 5, name: "description", kind: "scalar", opt: true, T: 9 },
8470
8627
  { no: 6, name: "photo", kind: "message", T: () => Photo },
8471
- { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 }
8628
+ { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 },
8629
+ { no: 8, name: "media_type", kind: "enum", opt: true, T: () => ["UrlPreview.MediaType", UrlPreview_MediaType, "MEDIA_TYPE_"] },
8630
+ { no: 9, name: "display_url", kind: "scalar", opt: true, T: 9 },
8631
+ { no: 10, name: "provider", kind: "scalar", opt: true, T: 9 },
8632
+ { no: 11, name: "author", kind: "scalar", opt: true, T: 9 },
8633
+ { no: 12, name: "media", kind: "message", T: () => UrlPreviewMedia },
8634
+ { no: 13, name: "layout", kind: "message", T: () => UrlPreviewLayout }
8472
8635
  ]);
8473
8636
  }
8474
8637
  create(value) {
@@ -8504,6 +8667,24 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8504
8667
  case 7:
8505
8668
  message.duration = reader.int64().toBigInt();
8506
8669
  break;
8670
+ case 8:
8671
+ message.mediaType = reader.int32();
8672
+ break;
8673
+ case 9:
8674
+ message.displayUrl = reader.string();
8675
+ break;
8676
+ case 10:
8677
+ message.provider = reader.string();
8678
+ break;
8679
+ case 11:
8680
+ message.author = reader.string();
8681
+ break;
8682
+ case 12:
8683
+ message.media = UrlPreviewMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
8684
+ break;
8685
+ case 13:
8686
+ message.layout = UrlPreviewLayout.internalBinaryRead(reader, reader.uint32(), options, message.layout);
8687
+ break;
8507
8688
  default:
8508
8689
  let u = options.readUnknownField;
8509
8690
  if (u === "throw")
@@ -8530,6 +8711,18 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8530
8711
  Photo.internalBinaryWrite(message.photo, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
8531
8712
  if (message.duration !== undefined)
8532
8713
  writer.tag(7, import_runtime.WireType.Varint).int64(message.duration);
8714
+ if (message.mediaType !== undefined)
8715
+ writer.tag(8, import_runtime.WireType.Varint).int32(message.mediaType);
8716
+ if (message.displayUrl !== undefined)
8717
+ writer.tag(9, import_runtime.WireType.LengthDelimited).string(message.displayUrl);
8718
+ if (message.provider !== undefined)
8719
+ writer.tag(10, import_runtime.WireType.LengthDelimited).string(message.provider);
8720
+ if (message.author !== undefined)
8721
+ writer.tag(11, import_runtime.WireType.LengthDelimited).string(message.author);
8722
+ if (message.media)
8723
+ UrlPreviewMedia.internalBinaryWrite(message.media, writer.tag(12, import_runtime.WireType.LengthDelimited).fork(), options).join();
8724
+ if (message.layout)
8725
+ UrlPreviewLayout.internalBinaryWrite(message.layout, writer.tag(13, import_runtime.WireType.LengthDelimited).fork(), options).join();
8533
8726
  let u = options.writeUnknownFields;
8534
8727
  if (u !== false)
8535
8728
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8538,6 +8731,272 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8538
8731
  }
8539
8732
  var UrlPreview = new UrlPreview$Type;
8540
8733
 
8734
+ class UrlPreviewMedia$Type extends import_runtime4.MessageType {
8735
+ constructor() {
8736
+ super("UrlPreviewMedia", [
8737
+ { no: 1, name: "photo", kind: "message", oneof: "media", T: () => Photo },
8738
+ { no: 2, name: "video", kind: "message", oneof: "media", T: () => Video },
8739
+ { no: 3, name: "document", kind: "message", oneof: "media", T: () => Document },
8740
+ { no: 4, name: "external_video", kind: "message", oneof: "media", T: () => UrlPreviewExternalVideo },
8741
+ { no: 5, name: "embed", kind: "message", oneof: "media", T: () => UrlPreviewEmbed }
8742
+ ]);
8743
+ }
8744
+ create(value) {
8745
+ const message = globalThis.Object.create(this.messagePrototype);
8746
+ message.media = { oneofKind: undefined };
8747
+ if (value !== undefined)
8748
+ import_runtime3.reflectionMergePartial(this, message, value);
8749
+ return message;
8750
+ }
8751
+ internalBinaryRead(reader, length, options, target) {
8752
+ let message = target ?? this.create(), end = reader.pos + length;
8753
+ while (reader.pos < end) {
8754
+ let [fieldNo, wireType] = reader.tag();
8755
+ switch (fieldNo) {
8756
+ case 1:
8757
+ message.media = {
8758
+ oneofKind: "photo",
8759
+ photo: Photo.internalBinaryRead(reader, reader.uint32(), options, message.media.photo)
8760
+ };
8761
+ break;
8762
+ case 2:
8763
+ message.media = {
8764
+ oneofKind: "video",
8765
+ video: Video.internalBinaryRead(reader, reader.uint32(), options, message.media.video)
8766
+ };
8767
+ break;
8768
+ case 3:
8769
+ message.media = {
8770
+ oneofKind: "document",
8771
+ document: Document.internalBinaryRead(reader, reader.uint32(), options, message.media.document)
8772
+ };
8773
+ break;
8774
+ case 4:
8775
+ message.media = {
8776
+ oneofKind: "externalVideo",
8777
+ externalVideo: UrlPreviewExternalVideo.internalBinaryRead(reader, reader.uint32(), options, message.media.externalVideo)
8778
+ };
8779
+ break;
8780
+ case 5:
8781
+ message.media = {
8782
+ oneofKind: "embed",
8783
+ embed: UrlPreviewEmbed.internalBinaryRead(reader, reader.uint32(), options, message.media.embed)
8784
+ };
8785
+ break;
8786
+ default:
8787
+ let u = options.readUnknownField;
8788
+ if (u === "throw")
8789
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8790
+ let d = reader.skip(wireType);
8791
+ if (u !== false)
8792
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8793
+ }
8794
+ }
8795
+ return message;
8796
+ }
8797
+ internalBinaryWrite(message, writer, options) {
8798
+ if (message.media.oneofKind === "photo")
8799
+ Photo.internalBinaryWrite(message.media.photo, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
8800
+ if (message.media.oneofKind === "video")
8801
+ Video.internalBinaryWrite(message.media.video, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
8802
+ if (message.media.oneofKind === "document")
8803
+ Document.internalBinaryWrite(message.media.document, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
8804
+ if (message.media.oneofKind === "externalVideo")
8805
+ UrlPreviewExternalVideo.internalBinaryWrite(message.media.externalVideo, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
8806
+ if (message.media.oneofKind === "embed")
8807
+ UrlPreviewEmbed.internalBinaryWrite(message.media.embed, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
8808
+ let u = options.writeUnknownFields;
8809
+ if (u !== false)
8810
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8811
+ return writer;
8812
+ }
8813
+ }
8814
+ var UrlPreviewMedia = new UrlPreviewMedia$Type;
8815
+
8816
+ class UrlPreviewExternalVideo$Type extends import_runtime4.MessageType {
8817
+ constructor() {
8818
+ super("UrlPreviewExternalVideo", [
8819
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8820
+ { no: 2, name: "mime_type", kind: "scalar", opt: true, T: 9 },
8821
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8822
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8823
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8824
+ ]);
8825
+ }
8826
+ create(value) {
8827
+ const message = globalThis.Object.create(this.messagePrototype);
8828
+ message.url = "";
8829
+ if (value !== undefined)
8830
+ import_runtime3.reflectionMergePartial(this, message, value);
8831
+ return message;
8832
+ }
8833
+ internalBinaryRead(reader, length, options, target) {
8834
+ let message = target ?? this.create(), end = reader.pos + length;
8835
+ while (reader.pos < end) {
8836
+ let [fieldNo, wireType] = reader.tag();
8837
+ switch (fieldNo) {
8838
+ case 1:
8839
+ message.url = reader.string();
8840
+ break;
8841
+ case 2:
8842
+ message.mimeType = reader.string();
8843
+ break;
8844
+ case 3:
8845
+ message.w = reader.int32();
8846
+ break;
8847
+ case 4:
8848
+ message.h = reader.int32();
8849
+ break;
8850
+ case 5:
8851
+ message.duration = reader.int32();
8852
+ break;
8853
+ default:
8854
+ let u = options.readUnknownField;
8855
+ if (u === "throw")
8856
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8857
+ let d = reader.skip(wireType);
8858
+ if (u !== false)
8859
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8860
+ }
8861
+ }
8862
+ return message;
8863
+ }
8864
+ internalBinaryWrite(message, writer, options) {
8865
+ if (message.url !== "")
8866
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8867
+ if (message.mimeType !== undefined)
8868
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.mimeType);
8869
+ if (message.w !== undefined)
8870
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8871
+ if (message.h !== undefined)
8872
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8873
+ if (message.duration !== undefined)
8874
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8875
+ let u = options.writeUnknownFields;
8876
+ if (u !== false)
8877
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8878
+ return writer;
8879
+ }
8880
+ }
8881
+ var UrlPreviewExternalVideo = new UrlPreviewExternalVideo$Type;
8882
+
8883
+ class UrlPreviewEmbed$Type extends import_runtime4.MessageType {
8884
+ constructor() {
8885
+ super("UrlPreviewEmbed", [
8886
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8887
+ { no: 2, name: "type", kind: "scalar", opt: true, T: 9 },
8888
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8889
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8890
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8891
+ ]);
8892
+ }
8893
+ create(value) {
8894
+ const message = globalThis.Object.create(this.messagePrototype);
8895
+ message.url = "";
8896
+ if (value !== undefined)
8897
+ import_runtime3.reflectionMergePartial(this, message, value);
8898
+ return message;
8899
+ }
8900
+ internalBinaryRead(reader, length, options, target) {
8901
+ let message = target ?? this.create(), end = reader.pos + length;
8902
+ while (reader.pos < end) {
8903
+ let [fieldNo, wireType] = reader.tag();
8904
+ switch (fieldNo) {
8905
+ case 1:
8906
+ message.url = reader.string();
8907
+ break;
8908
+ case 2:
8909
+ message.type = reader.string();
8910
+ break;
8911
+ case 3:
8912
+ message.w = reader.int32();
8913
+ break;
8914
+ case 4:
8915
+ message.h = reader.int32();
8916
+ break;
8917
+ case 5:
8918
+ message.duration = reader.int32();
8919
+ break;
8920
+ default:
8921
+ let u = options.readUnknownField;
8922
+ if (u === "throw")
8923
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8924
+ let d = reader.skip(wireType);
8925
+ if (u !== false)
8926
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8927
+ }
8928
+ }
8929
+ return message;
8930
+ }
8931
+ internalBinaryWrite(message, writer, options) {
8932
+ if (message.url !== "")
8933
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8934
+ if (message.type !== undefined)
8935
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.type);
8936
+ if (message.w !== undefined)
8937
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8938
+ if (message.h !== undefined)
8939
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8940
+ if (message.duration !== undefined)
8941
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8942
+ let u = options.writeUnknownFields;
8943
+ if (u !== false)
8944
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8945
+ return writer;
8946
+ }
8947
+ }
8948
+ var UrlPreviewEmbed = new UrlPreviewEmbed$Type;
8949
+
8950
+ class UrlPreviewLayout$Type extends import_runtime4.MessageType {
8951
+ constructor() {
8952
+ super("UrlPreviewLayout", [
8953
+ { no: 1, name: "has_large_media", kind: "scalar", T: 8 },
8954
+ { no: 2, name: "show_large_media", kind: "scalar", T: 8 }
8955
+ ]);
8956
+ }
8957
+ create(value) {
8958
+ const message = globalThis.Object.create(this.messagePrototype);
8959
+ message.hasLargeMedia = false;
8960
+ message.showLargeMedia = false;
8961
+ if (value !== undefined)
8962
+ import_runtime3.reflectionMergePartial(this, message, value);
8963
+ return message;
8964
+ }
8965
+ internalBinaryRead(reader, length, options, target) {
8966
+ let message = target ?? this.create(), end = reader.pos + length;
8967
+ while (reader.pos < end) {
8968
+ let [fieldNo, wireType] = reader.tag();
8969
+ switch (fieldNo) {
8970
+ case 1:
8971
+ message.hasLargeMedia = reader.bool();
8972
+ break;
8973
+ case 2:
8974
+ message.showLargeMedia = reader.bool();
8975
+ break;
8976
+ default:
8977
+ let u = options.readUnknownField;
8978
+ if (u === "throw")
8979
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8980
+ let d = reader.skip(wireType);
8981
+ if (u !== false)
8982
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8983
+ }
8984
+ }
8985
+ return message;
8986
+ }
8987
+ internalBinaryWrite(message, writer, options) {
8988
+ if (message.hasLargeMedia !== false)
8989
+ writer.tag(1, import_runtime.WireType.Varint).bool(message.hasLargeMedia);
8990
+ if (message.showLargeMedia !== false)
8991
+ writer.tag(2, import_runtime.WireType.Varint).bool(message.showLargeMedia);
8992
+ let u = options.writeUnknownFields;
8993
+ if (u !== false)
8994
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8995
+ return writer;
8996
+ }
8997
+ }
8998
+ var UrlPreviewLayout = new UrlPreviewLayout$Type;
8999
+
8541
9000
  class MessageAttachmentExternalTask$Type extends import_runtime4.MessageType {
8542
9001
  constructor() {
8543
9002
  super("MessageAttachmentExternalTask", [
@@ -9431,7 +9890,10 @@ class RpcCall$Type extends import_runtime4.MessageType {
9431
9890
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "input", T: () => AnswerMessageActionInput },
9432
9891
  { no: 51, name: "revokeSession", kind: "message", oneof: "input", T: () => RevokeSessionInput },
9433
9892
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "input", T: () => UpdateDialogOpenInput },
9434
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput }
9893
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput },
9894
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "input", T: () => ClearChatHistoryInput },
9895
+ { no: 55, name: "deleteBot", kind: "message", oneof: "input", T: () => DeleteBotInput },
9896
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "input", T: () => DeleteMessageAttachmentInput }
9435
9897
  ]);
9436
9898
  }
9437
9899
  create(value) {
@@ -9762,6 +10224,24 @@ class RpcCall$Type extends import_runtime4.MessageType {
9762
10224
  updateDialogOrder: UpdateDialogOrderInput.internalBinaryRead(reader, reader.uint32(), options, message.input.updateDialogOrder)
9763
10225
  };
9764
10226
  break;
10227
+ case 54:
10228
+ message.input = {
10229
+ oneofKind: "clearChatHistory",
10230
+ clearChatHistory: ClearChatHistoryInput.internalBinaryRead(reader, reader.uint32(), options, message.input.clearChatHistory)
10231
+ };
10232
+ break;
10233
+ case 55:
10234
+ message.input = {
10235
+ oneofKind: "deleteBot",
10236
+ deleteBot: DeleteBotInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteBot)
10237
+ };
10238
+ break;
10239
+ case 56:
10240
+ message.input = {
10241
+ oneofKind: "deleteMessageAttachment",
10242
+ deleteMessageAttachment: DeleteMessageAttachmentInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteMessageAttachment)
10243
+ };
10244
+ break;
9765
10245
  default:
9766
10246
  let u = options.readUnknownField;
9767
10247
  if (u === "throw")
@@ -9880,6 +10360,12 @@ class RpcCall$Type extends import_runtime4.MessageType {
9880
10360
  UpdateDialogOpenInput.internalBinaryWrite(message.input.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
9881
10361
  if (message.input.oneofKind === "updateDialogOrder")
9882
10362
  UpdateDialogOrderInput.internalBinaryWrite(message.input.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10363
+ if (message.input.oneofKind === "clearChatHistory")
10364
+ ClearChatHistoryInput.internalBinaryWrite(message.input.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10365
+ if (message.input.oneofKind === "deleteBot")
10366
+ DeleteBotInput.internalBinaryWrite(message.input.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10367
+ if (message.input.oneofKind === "deleteMessageAttachment")
10368
+ DeleteMessageAttachmentInput.internalBinaryWrite(message.input.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
9883
10369
  let u = options.writeUnknownFields;
9884
10370
  if (u !== false)
9885
10371
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -9943,7 +10429,10 @@ class RpcResult$Type extends import_runtime4.MessageType {
9943
10429
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "result", T: () => AnswerMessageActionResult },
9944
10430
  { no: 51, name: "revokeSession", kind: "message", oneof: "result", T: () => RevokeSessionResult },
9945
10431
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "result", T: () => UpdateDialogOpenResult },
9946
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult }
10432
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult },
10433
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "result", T: () => ClearChatHistoryResult },
10434
+ { no: 55, name: "deleteBot", kind: "message", oneof: "result", T: () => DeleteBotResult },
10435
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "result", T: () => DeleteMessageAttachmentResult }
9947
10436
  ]);
9948
10437
  }
9949
10438
  create(value) {
@@ -10274,6 +10763,24 @@ class RpcResult$Type extends import_runtime4.MessageType {
10274
10763
  updateDialogOrder: UpdateDialogOrderResult.internalBinaryRead(reader, reader.uint32(), options, message.result.updateDialogOrder)
10275
10764
  };
10276
10765
  break;
10766
+ case 54:
10767
+ message.result = {
10768
+ oneofKind: "clearChatHistory",
10769
+ clearChatHistory: ClearChatHistoryResult.internalBinaryRead(reader, reader.uint32(), options, message.result.clearChatHistory)
10770
+ };
10771
+ break;
10772
+ case 55:
10773
+ message.result = {
10774
+ oneofKind: "deleteBot",
10775
+ deleteBot: DeleteBotResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteBot)
10776
+ };
10777
+ break;
10778
+ case 56:
10779
+ message.result = {
10780
+ oneofKind: "deleteMessageAttachment",
10781
+ deleteMessageAttachment: DeleteMessageAttachmentResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteMessageAttachment)
10782
+ };
10783
+ break;
10277
10784
  default:
10278
10785
  let u = options.readUnknownField;
10279
10786
  if (u === "throw")
@@ -10392,6 +10899,12 @@ class RpcResult$Type extends import_runtime4.MessageType {
10392
10899
  UpdateDialogOpenResult.internalBinaryWrite(message.result.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
10393
10900
  if (message.result.oneofKind === "updateDialogOrder")
10394
10901
  UpdateDialogOrderResult.internalBinaryWrite(message.result.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10902
+ if (message.result.oneofKind === "clearChatHistory")
10903
+ ClearChatHistoryResult.internalBinaryWrite(message.result.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10904
+ if (message.result.oneofKind === "deleteBot")
10905
+ DeleteBotResult.internalBinaryWrite(message.result.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10906
+ if (message.result.oneofKind === "deleteMessageAttachment")
10907
+ DeleteMessageAttachmentResult.internalBinaryWrite(message.result.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
10395
10908
  let u = options.writeUnknownFields;
10396
10909
  if (u !== false)
10397
10910
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -10577,7 +11090,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10577
11090
  { no: 1, name: "bucket", kind: "message", T: () => UpdateBucket },
10578
11091
  { no: 2, name: "start_seq", kind: "scalar", T: 3, L: 0 },
10579
11092
  { no: 3, name: "total_limit", kind: "scalar", T: 5 },
10580
- { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 }
11093
+ { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 },
11094
+ { no: 5, name: "limit", kind: "scalar", T: 5 }
10581
11095
  ]);
10582
11096
  }
10583
11097
  create(value) {
@@ -10585,6 +11099,7 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10585
11099
  message.startSeq = 0n;
10586
11100
  message.totalLimit = 0;
10587
11101
  message.seqEnd = 0n;
11102
+ message.limit = 0;
10588
11103
  if (value !== undefined)
10589
11104
  import_runtime3.reflectionMergePartial(this, message, value);
10590
11105
  return message;
@@ -10606,6 +11121,9 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10606
11121
  case 4:
10607
11122
  message.seqEnd = reader.int64().toBigInt();
10608
11123
  break;
11124
+ case 5:
11125
+ message.limit = reader.int32();
11126
+ break;
10609
11127
  default:
10610
11128
  let u = options.readUnknownField;
10611
11129
  if (u === "throw")
@@ -10626,6 +11144,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10626
11144
  writer.tag(3, import_runtime.WireType.Varint).int32(message.totalLimit);
10627
11145
  if (message.seqEnd !== 0n)
10628
11146
  writer.tag(4, import_runtime.WireType.Varint).int64(message.seqEnd);
11147
+ if (message.limit !== 0)
11148
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.limit);
10629
11149
  let u = options.writeUnknownFields;
10630
11150
  if (u !== false)
10631
11151
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -11752,6 +12272,191 @@ class ListBotsResult$Type extends import_runtime4.MessageType {
11752
12272
  }
11753
12273
  var ListBotsResult = new ListBotsResult$Type;
11754
12274
 
12275
+ class DeleteBotInput$Type extends import_runtime4.MessageType {
12276
+ constructor() {
12277
+ super("DeleteBotInput", [
12278
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12279
+ ]);
12280
+ }
12281
+ create(value) {
12282
+ const message = globalThis.Object.create(this.messagePrototype);
12283
+ message.botUserId = 0n;
12284
+ if (value !== undefined)
12285
+ import_runtime3.reflectionMergePartial(this, message, value);
12286
+ return message;
12287
+ }
12288
+ internalBinaryRead(reader, length, options, target) {
12289
+ let message = target ?? this.create(), end = reader.pos + length;
12290
+ while (reader.pos < end) {
12291
+ let [fieldNo, wireType] = reader.tag();
12292
+ switch (fieldNo) {
12293
+ case 1:
12294
+ message.botUserId = reader.int64().toBigInt();
12295
+ break;
12296
+ default:
12297
+ let u = options.readUnknownField;
12298
+ if (u === "throw")
12299
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12300
+ let d = reader.skip(wireType);
12301
+ if (u !== false)
12302
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12303
+ }
12304
+ }
12305
+ return message;
12306
+ }
12307
+ internalBinaryWrite(message, writer, options) {
12308
+ if (message.botUserId !== 0n)
12309
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12310
+ let u = options.writeUnknownFields;
12311
+ if (u !== false)
12312
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12313
+ return writer;
12314
+ }
12315
+ }
12316
+ var DeleteBotInput = new DeleteBotInput$Type;
12317
+
12318
+ class DeleteBotResult$Type extends import_runtime4.MessageType {
12319
+ constructor() {
12320
+ super("DeleteBotResult", [
12321
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12322
+ ]);
12323
+ }
12324
+ create(value) {
12325
+ const message = globalThis.Object.create(this.messagePrototype);
12326
+ message.botUserId = 0n;
12327
+ if (value !== undefined)
12328
+ import_runtime3.reflectionMergePartial(this, message, value);
12329
+ return message;
12330
+ }
12331
+ internalBinaryRead(reader, length, options, target) {
12332
+ let message = target ?? this.create(), end = reader.pos + length;
12333
+ while (reader.pos < end) {
12334
+ let [fieldNo, wireType] = reader.tag();
12335
+ switch (fieldNo) {
12336
+ case 1:
12337
+ message.botUserId = reader.int64().toBigInt();
12338
+ break;
12339
+ default:
12340
+ let u = options.readUnknownField;
12341
+ if (u === "throw")
12342
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12343
+ let d = reader.skip(wireType);
12344
+ if (u !== false)
12345
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12346
+ }
12347
+ }
12348
+ return message;
12349
+ }
12350
+ internalBinaryWrite(message, writer, options) {
12351
+ if (message.botUserId !== 0n)
12352
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12353
+ let u = options.writeUnknownFields;
12354
+ if (u !== false)
12355
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12356
+ return writer;
12357
+ }
12358
+ }
12359
+ var DeleteBotResult = new DeleteBotResult$Type;
12360
+
12361
+ class DeleteMessageAttachmentInput$Type extends import_runtime4.MessageType {
12362
+ constructor() {
12363
+ super("DeleteMessageAttachmentInput", [
12364
+ { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
12365
+ { no: 2, name: "message_id", kind: "scalar", T: 3, L: 0 },
12366
+ { no: 3, name: "attachment_id", kind: "scalar", T: 3, L: 0 }
12367
+ ]);
12368
+ }
12369
+ create(value) {
12370
+ const message = globalThis.Object.create(this.messagePrototype);
12371
+ message.messageId = 0n;
12372
+ message.attachmentId = 0n;
12373
+ if (value !== undefined)
12374
+ import_runtime3.reflectionMergePartial(this, message, value);
12375
+ return message;
12376
+ }
12377
+ internalBinaryRead(reader, length, options, target) {
12378
+ let message = target ?? this.create(), end = reader.pos + length;
12379
+ while (reader.pos < end) {
12380
+ let [fieldNo, wireType] = reader.tag();
12381
+ switch (fieldNo) {
12382
+ case 1:
12383
+ message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
12384
+ break;
12385
+ case 2:
12386
+ message.messageId = reader.int64().toBigInt();
12387
+ break;
12388
+ case 3:
12389
+ message.attachmentId = reader.int64().toBigInt();
12390
+ break;
12391
+ default:
12392
+ let u = options.readUnknownField;
12393
+ if (u === "throw")
12394
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12395
+ let d = reader.skip(wireType);
12396
+ if (u !== false)
12397
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12398
+ }
12399
+ }
12400
+ return message;
12401
+ }
12402
+ internalBinaryWrite(message, writer, options) {
12403
+ if (message.peerId)
12404
+ InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12405
+ if (message.messageId !== 0n)
12406
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.messageId);
12407
+ if (message.attachmentId !== 0n)
12408
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.attachmentId);
12409
+ let u = options.writeUnknownFields;
12410
+ if (u !== false)
12411
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12412
+ return writer;
12413
+ }
12414
+ }
12415
+ var DeleteMessageAttachmentInput = new DeleteMessageAttachmentInput$Type;
12416
+
12417
+ class DeleteMessageAttachmentResult$Type extends import_runtime4.MessageType {
12418
+ constructor() {
12419
+ super("DeleteMessageAttachmentResult", [
12420
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
12421
+ ]);
12422
+ }
12423
+ create(value) {
12424
+ const message = globalThis.Object.create(this.messagePrototype);
12425
+ message.updates = [];
12426
+ if (value !== undefined)
12427
+ import_runtime3.reflectionMergePartial(this, message, value);
12428
+ return message;
12429
+ }
12430
+ internalBinaryRead(reader, length, options, target) {
12431
+ let message = target ?? this.create(), end = reader.pos + length;
12432
+ while (reader.pos < end) {
12433
+ let [fieldNo, wireType] = reader.tag();
12434
+ switch (fieldNo) {
12435
+ case 1:
12436
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
12437
+ break;
12438
+ default:
12439
+ let u = options.readUnknownField;
12440
+ if (u === "throw")
12441
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12442
+ let d = reader.skip(wireType);
12443
+ if (u !== false)
12444
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12445
+ }
12446
+ }
12447
+ return message;
12448
+ }
12449
+ internalBinaryWrite(message, writer, options) {
12450
+ for (let i = 0;i < message.updates.length; i++)
12451
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12452
+ let u = options.writeUnknownFields;
12453
+ if (u !== false)
12454
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12455
+ return writer;
12456
+ }
12457
+ }
12458
+ var DeleteMessageAttachmentResult = new DeleteMessageAttachmentResult$Type;
12459
+
11755
12460
  class RevokeSessionInput$Type extends import_runtime4.MessageType {
11756
12461
  constructor() {
11757
12462
  super("RevokeSessionInput", [
@@ -13768,6 +14473,118 @@ class DeleteMessagesResult$Type extends import_runtime4.MessageType {
13768
14473
  }
13769
14474
  var DeleteMessagesResult = new DeleteMessagesResult$Type;
13770
14475
 
14476
+ class ClearChatHistoryInput$Type extends import_runtime4.MessageType {
14477
+ constructor() {
14478
+ super("ClearChatHistoryInput", [
14479
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => InputPeer },
14480
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
14481
+ { no: 2, name: "keep_last_days", kind: "scalar", T: 5 },
14482
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 }
14483
+ ]);
14484
+ }
14485
+ create(value) {
14486
+ const message = globalThis.Object.create(this.messagePrototype);
14487
+ message.target = { oneofKind: undefined };
14488
+ message.keepLastDays = 0;
14489
+ message.deleteReplyThreads = false;
14490
+ if (value !== undefined)
14491
+ import_runtime3.reflectionMergePartial(this, message, value);
14492
+ return message;
14493
+ }
14494
+ internalBinaryRead(reader, length, options, target) {
14495
+ let message = target ?? this.create(), end = reader.pos + length;
14496
+ while (reader.pos < end) {
14497
+ let [fieldNo, wireType] = reader.tag();
14498
+ switch (fieldNo) {
14499
+ case 1:
14500
+ message.target = {
14501
+ oneofKind: "peerId",
14502
+ peerId: InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
14503
+ };
14504
+ break;
14505
+ case 4:
14506
+ message.target = {
14507
+ oneofKind: "spaceId",
14508
+ spaceId: reader.int64().toBigInt()
14509
+ };
14510
+ break;
14511
+ case 2:
14512
+ message.keepLastDays = reader.int32();
14513
+ break;
14514
+ case 3:
14515
+ message.deleteReplyThreads = reader.bool();
14516
+ break;
14517
+ default:
14518
+ let u = options.readUnknownField;
14519
+ if (u === "throw")
14520
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14521
+ let d = reader.skip(wireType);
14522
+ if (u !== false)
14523
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14524
+ }
14525
+ }
14526
+ return message;
14527
+ }
14528
+ internalBinaryWrite(message, writer, options) {
14529
+ if (message.target.oneofKind === "peerId")
14530
+ InputPeer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14531
+ if (message.target.oneofKind === "spaceId")
14532
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
14533
+ if (message.keepLastDays !== 0)
14534
+ writer.tag(2, import_runtime.WireType.Varint).int32(message.keepLastDays);
14535
+ if (message.deleteReplyThreads !== false)
14536
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
14537
+ let u = options.writeUnknownFields;
14538
+ if (u !== false)
14539
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14540
+ return writer;
14541
+ }
14542
+ }
14543
+ var ClearChatHistoryInput = new ClearChatHistoryInput$Type;
14544
+
14545
+ class ClearChatHistoryResult$Type extends import_runtime4.MessageType {
14546
+ constructor() {
14547
+ super("ClearChatHistoryResult", [
14548
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
14549
+ ]);
14550
+ }
14551
+ create(value) {
14552
+ const message = globalThis.Object.create(this.messagePrototype);
14553
+ message.updates = [];
14554
+ if (value !== undefined)
14555
+ import_runtime3.reflectionMergePartial(this, message, value);
14556
+ return message;
14557
+ }
14558
+ internalBinaryRead(reader, length, options, target) {
14559
+ let message = target ?? this.create(), end = reader.pos + length;
14560
+ while (reader.pos < end) {
14561
+ let [fieldNo, wireType] = reader.tag();
14562
+ switch (fieldNo) {
14563
+ case 1:
14564
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
14565
+ break;
14566
+ default:
14567
+ let u = options.readUnknownField;
14568
+ if (u === "throw")
14569
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14570
+ let d = reader.skip(wireType);
14571
+ if (u !== false)
14572
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14573
+ }
14574
+ }
14575
+ return message;
14576
+ }
14577
+ internalBinaryWrite(message, writer, options) {
14578
+ for (let i = 0;i < message.updates.length; i++)
14579
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14580
+ let u = options.writeUnknownFields;
14581
+ if (u !== false)
14582
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14583
+ return writer;
14584
+ }
14585
+ }
14586
+ var ClearChatHistoryResult = new ClearChatHistoryResult$Type;
14587
+
13771
14588
  class EditMessageInput$Type extends import_runtime4.MessageType {
13772
14589
  constructor() {
13773
14590
  super("EditMessageInput", [
@@ -15509,7 +16326,8 @@ class Update$Type extends import_runtime4.MessageType {
15509
16326
  { no: 33, name: "dialog_notification_settings", kind: "message", oneof: "update", T: () => UpdateDialogNotificationSettings },
15510
16327
  { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen },
15511
16328
  { no: 35, name: "message_action_invoked", kind: "message", oneof: "update", T: () => UpdateMessageActionInvoked },
15512
- { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered }
16329
+ { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered },
16330
+ { no: 37, name: "clear_chat_history", kind: "message", oneof: "update", T: () => UpdateClearChatHistory }
15513
16331
  ]);
15514
16332
  }
15515
16333
  create(value) {
@@ -15728,6 +16546,12 @@ class Update$Type extends import_runtime4.MessageType {
15728
16546
  messageActionAnswered: UpdateMessageActionAnswered.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionAnswered)
15729
16547
  };
15730
16548
  break;
16549
+ case 37:
16550
+ message.update = {
16551
+ oneofKind: "clearChatHistory",
16552
+ clearChatHistory: UpdateClearChatHistory.internalBinaryRead(reader, reader.uint32(), options, message.update.clearChatHistory)
16553
+ };
16554
+ break;
15731
16555
  default:
15732
16556
  let u = options.readUnknownField;
15733
16557
  if (u === "throw")
@@ -15810,6 +16634,8 @@ class Update$Type extends import_runtime4.MessageType {
15810
16634
  UpdateMessageActionInvoked.internalBinaryWrite(message.update.messageActionInvoked, writer.tag(35, import_runtime.WireType.LengthDelimited).fork(), options).join();
15811
16635
  if (message.update.oneofKind === "messageActionAnswered")
15812
16636
  UpdateMessageActionAnswered.internalBinaryWrite(message.update.messageActionAnswered, writer.tag(36, import_runtime.WireType.LengthDelimited).fork(), options).join();
16637
+ if (message.update.oneofKind === "clearChatHistory")
16638
+ UpdateClearChatHistory.internalBinaryWrite(message.update.clearChatHistory, writer.tag(37, import_runtime.WireType.LengthDelimited).fork(), options).join();
15813
16639
  let u = options.writeUnknownFields;
15814
16640
  if (u !== false)
15815
16641
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -17076,6 +17902,119 @@ class UpdateDeleteMessages$Type extends import_runtime4.MessageType {
17076
17902
  }
17077
17903
  var UpdateDeleteMessages = new UpdateDeleteMessages$Type;
17078
17904
 
17905
+ class UpdateClearChatHistory$Type extends import_runtime4.MessageType {
17906
+ constructor() {
17907
+ super("UpdateClearChatHistory", [
17908
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => Peer },
17909
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
17910
+ { no: 2, name: "before_date", kind: "scalar", opt: true, T: 3, L: 0 },
17911
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 },
17912
+ { no: 5, name: "deleted_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17913
+ { no: 6, name: "orphaned_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17914
+ { no: 7, name: "detached_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 }
17915
+ ]);
17916
+ }
17917
+ create(value) {
17918
+ const message = globalThis.Object.create(this.messagePrototype);
17919
+ message.target = { oneofKind: undefined };
17920
+ message.deleteReplyThreads = false;
17921
+ message.deletedChatIds = [];
17922
+ message.orphanedChatIds = [];
17923
+ message.detachedChatIds = [];
17924
+ if (value !== undefined)
17925
+ import_runtime3.reflectionMergePartial(this, message, value);
17926
+ return message;
17927
+ }
17928
+ internalBinaryRead(reader, length, options, target) {
17929
+ let message = target ?? this.create(), end = reader.pos + length;
17930
+ while (reader.pos < end) {
17931
+ let [fieldNo, wireType] = reader.tag();
17932
+ switch (fieldNo) {
17933
+ case 1:
17934
+ message.target = {
17935
+ oneofKind: "peerId",
17936
+ peerId: Peer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
17937
+ };
17938
+ break;
17939
+ case 4:
17940
+ message.target = {
17941
+ oneofKind: "spaceId",
17942
+ spaceId: reader.int64().toBigInt()
17943
+ };
17944
+ break;
17945
+ case 2:
17946
+ message.beforeDate = reader.int64().toBigInt();
17947
+ break;
17948
+ case 3:
17949
+ message.deleteReplyThreads = reader.bool();
17950
+ break;
17951
+ case 5:
17952
+ if (wireType === import_runtime.WireType.LengthDelimited)
17953
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17954
+ message.deletedChatIds.push(reader.int64().toBigInt());
17955
+ else
17956
+ message.deletedChatIds.push(reader.int64().toBigInt());
17957
+ break;
17958
+ case 6:
17959
+ if (wireType === import_runtime.WireType.LengthDelimited)
17960
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17961
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17962
+ else
17963
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17964
+ break;
17965
+ case 7:
17966
+ if (wireType === import_runtime.WireType.LengthDelimited)
17967
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17968
+ message.detachedChatIds.push(reader.int64().toBigInt());
17969
+ else
17970
+ message.detachedChatIds.push(reader.int64().toBigInt());
17971
+ break;
17972
+ default:
17973
+ let u = options.readUnknownField;
17974
+ if (u === "throw")
17975
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
17976
+ let d = reader.skip(wireType);
17977
+ if (u !== false)
17978
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
17979
+ }
17980
+ }
17981
+ return message;
17982
+ }
17983
+ internalBinaryWrite(message, writer, options) {
17984
+ if (message.target.oneofKind === "peerId")
17985
+ Peer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
17986
+ if (message.target.oneofKind === "spaceId")
17987
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
17988
+ if (message.beforeDate !== undefined)
17989
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.beforeDate);
17990
+ if (message.deleteReplyThreads !== false)
17991
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
17992
+ if (message.deletedChatIds.length) {
17993
+ writer.tag(5, import_runtime.WireType.LengthDelimited).fork();
17994
+ for (let i = 0;i < message.deletedChatIds.length; i++)
17995
+ writer.int64(message.deletedChatIds[i]);
17996
+ writer.join();
17997
+ }
17998
+ if (message.orphanedChatIds.length) {
17999
+ writer.tag(6, import_runtime.WireType.LengthDelimited).fork();
18000
+ for (let i = 0;i < message.orphanedChatIds.length; i++)
18001
+ writer.int64(message.orphanedChatIds[i]);
18002
+ writer.join();
18003
+ }
18004
+ if (message.detachedChatIds.length) {
18005
+ writer.tag(7, import_runtime.WireType.LengthDelimited).fork();
18006
+ for (let i = 0;i < message.detachedChatIds.length; i++)
18007
+ writer.int64(message.detachedChatIds[i]);
18008
+ writer.join();
18009
+ }
18010
+ let u = options.writeUnknownFields;
18011
+ if (u !== false)
18012
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
18013
+ return writer;
18014
+ }
18015
+ }
18016
+ var UpdateClearChatHistory = new UpdateClearChatHistory$Type;
18017
+
17079
18018
  class UpdateMessageId$Type extends import_runtime4.MessageType {
17080
18019
  constructor() {
17081
18020
  super("UpdateMessageId", [
@@ -19216,7 +20155,7 @@ function describeConnectionError(error) {
19216
20155
  return `server connection error${code != null ? ` (code=${code})` : ""}: ${message}`;
19217
20156
  }
19218
20157
 
19219
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/wrapper.mjs
20158
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/wrapper.mjs
19220
20159
  var import_stream = __toESM(require_stream(), 1);
19221
20160
  var import_extension = __toESM(require_extension(), 1);
19222
20161
  var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
@@ -19510,7 +20449,8 @@ var rpcInputKindByMethod = {
19510
20449
  37: "updateBotProfile",
19511
20450
  38: "getMessages",
19512
20451
  48: "invokeMessageAction",
19513
- 49: "answerMessageAction"
20452
+ 49: "answerMessageAction",
20453
+ 53: "clearChatHistory"
19514
20454
  };
19515
20455
  var rpcResultKindByMethod = {
19516
20456
  0: undefined,
@@ -19553,7 +20493,8 @@ var rpcResultKindByMethod = {
19553
20493
  37: "updateBotProfile",
19554
20494
  38: "getMessages",
19555
20495
  48: "invokeMessageAction",
19556
- 49: "answerMessageAction"
20496
+ 49: "answerMessageAction",
20497
+ 53: "clearChatHistory"
19557
20498
  };
19558
20499
 
19559
20500
  // ../sdk/dist/sdk/logger.js
@@ -19590,6 +20531,7 @@ var defaultApiBaseUrl = "https://api.inline.chat";
19590
20531
  var defaultVideoWidth = 1280;
19591
20532
  var defaultVideoHeight = 720;
19592
20533
  var defaultVideoDuration = 1;
20534
+ var defaultCatchUpPageLimit = 200;
19593
20535
  var defaultCatchUpTotalLimit = 1000;
19594
20536
  var defaultColdStartCatchUpWindow = defaultCatchUpTotalLimit;
19595
20537
  function extractFirstMessageId(updates) {
@@ -19728,7 +20670,12 @@ class InlineSdkClient {
19728
20670
  const chat = result.getChat.chat;
19729
20671
  if (!chat)
19730
20672
  throw new Error("getChat: missing chat");
19731
- return { chatId: chat.id, peer: chat.peerId, title: chat.title };
20673
+ return {
20674
+ chatId: chat.id,
20675
+ peer: chat.peerId,
20676
+ title: chat.title,
20677
+ ...chat.lastMsgId != null ? { lastMsgId: chat.lastMsgId } : {}
20678
+ };
19732
20679
  }
19733
20680
  async getMessages(params) {
19734
20681
  const peerId = this.inputPeerFromTarget(params, "getMessages");
@@ -19742,6 +20689,18 @@ class InlineSdkClient {
19742
20689
  });
19743
20690
  return { messages: result.getMessages.messages };
19744
20691
  }
20692
+ async clearChatHistory(params) {
20693
+ const keepLastDays = normalizeKeepLastDays(params.keepLastDays);
20694
+ const target = this.clearHistoryTargetFromParams(params);
20695
+ await this.invoke(Method.CLEAR_CHAT_HISTORY, {
20696
+ oneofKind: "clearChatHistory",
20697
+ clearChatHistory: {
20698
+ target,
20699
+ keepLastDays,
20700
+ deleteReplyThreads: params.deleteReplyThreads ?? false
20701
+ }
20702
+ });
20703
+ }
19745
20704
  async sendMessage(params) {
19746
20705
  if (params.entities != null && params.parseMarkdown != null) {
19747
20706
  throw new Error("sendMessage: provide either `entities` or `parseMarkdown`, not both");
@@ -20043,6 +21002,36 @@ class InlineSdkClient {
20043
21002
  });
20044
21003
  return;
20045
21004
  }
21005
+ case "clearChatHistory": {
21006
+ const payload = update.update.clearChatHistory;
21007
+ if (payload.target.oneofKind === "spaceId") {
21008
+ await this.eventStream.send({
21009
+ kind: "space.history.clear",
21010
+ spaceId: payload.target.spaceId,
21011
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
21012
+ deleteReplyThreads: payload.deleteReplyThreads,
21013
+ seq,
21014
+ date
21015
+ });
21016
+ return;
21017
+ }
21018
+ const peerId = payload.target.oneofKind === "peerId" ? payload.target.peerId : undefined;
21019
+ const chatId = peerId?.type.oneofKind === "chat" ? peerId.type.chat.chatId : null;
21020
+ if (!chatId) {
21021
+ this.log.warn?.("Skipping clearChatHistory update without chat peer", peerId);
21022
+ return;
21023
+ }
21024
+ this.bumpChatSeq(chatId, seq);
21025
+ await this.eventStream.send({
21026
+ kind: "message.history.clear",
21027
+ chatId,
21028
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
21029
+ deleteReplyThreads: payload.deleteReplyThreads,
21030
+ seq,
21031
+ date
21032
+ });
21033
+ return;
21034
+ }
20046
21035
  case "updateReaction": {
20047
21036
  const reaction = update.update.updateReaction.reaction;
20048
21037
  if (!reaction)
@@ -20186,7 +21175,8 @@ class InlineSdkClient {
20186
21175
  }
20187
21176
  }),
20188
21177
  startSeq: BigInt(cursor),
20189
- totalLimit: defaultCatchUpTotalLimit
21178
+ totalLimit: defaultCatchUpTotalLimit,
21179
+ limit: defaultCatchUpPageLimit
20190
21180
  })
20191
21181
  });
20192
21182
  const payload = result.getUpdates;
@@ -20283,7 +21273,8 @@ class InlineSdkClient {
20283
21273
  }),
20284
21274
  startSeq: BigInt(cursor),
20285
21275
  seqEnd: BigInt(endSeq),
20286
- totalLimit: defaultCatchUpTotalLimit
21276
+ totalLimit: defaultCatchUpTotalLimit,
21277
+ limit: defaultCatchUpPageLimit
20287
21278
  })
20288
21279
  });
20289
21280
  const payload = result.getUpdates;
@@ -20347,6 +21338,18 @@ class InlineSdkClient {
20347
21338
  type: { oneofKind: "chat", chat: { chatId: asInlineId(params.chatId, "chatId") } }
20348
21339
  });
20349
21340
  }
21341
+ clearHistoryTargetFromParams(params) {
21342
+ const hasChatId = params.chatId != null;
21343
+ const hasUserId = params.userId != null;
21344
+ const hasSpaceId = params.spaceId != null;
21345
+ if ([hasChatId, hasUserId, hasSpaceId].filter(Boolean).length !== 1) {
21346
+ throw new Error("clearChatHistory: provide exactly one of `chatId`, `userId`, or `spaceId`");
21347
+ }
21348
+ if (hasSpaceId) {
21349
+ return { oneofKind: "spaceId", spaceId: asInlineId(params.spaceId, "spaceId") };
21350
+ }
21351
+ return { oneofKind: "peerId", peerId: this.inputPeerFromTarget(params, "clearChatHistory") };
21352
+ }
20350
21353
  async loadState() {
20351
21354
  const store = this.options.state;
20352
21355
  if (!store)
@@ -20523,6 +21526,12 @@ function normalizePositiveInt(value, field) {
20523
21526
  }
20524
21527
  return value;
20525
21528
  }
21529
+ function normalizeKeepLastDays(value) {
21530
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > 36500) {
21531
+ throw new Error("clearChatHistory: `keepLastDays` must be 0 or a positive integer up to 36500");
21532
+ }
21533
+ return value;
21534
+ }
20526
21535
  async function parseJsonResponse(response) {
20527
21536
  const contentType = response.headers.get("content-type") ?? "";
20528
21537
  if (!contentType.includes("application/json")) {
@@ -35176,10 +36185,15 @@ var InlineActionsSchema = exports_external.object({
35176
36185
  var InlineCapabilitiesSchema = exports_external.object({
35177
36186
  replyThreads: exports_external.boolean().optional()
35178
36187
  }).strict();
36188
+ var InlineReplyThreadModeSchema = exports_external.enum(["auto", "thread", "main"]);
35179
36189
  var InlineTargetSchema = exports_external.union([exports_external.string(), exports_external.number()]);
35180
36190
  var InlineAllowEntrySchema = exports_external.union([exports_external.string(), exports_external.number()]);
35181
36191
  var InlineGroupSchema = exports_external.object({
35182
36192
  requireMention: exports_external.boolean().optional(),
36193
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36194
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36195
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36196
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35183
36197
  allowFrom: exports_external.array(InlineAllowEntrySchema).optional(),
35184
36198
  systemPrompt: exports_external.string().optional(),
35185
36199
  tools: ToolPolicySchema.optional(),
@@ -35219,6 +36233,7 @@ var InlineStreamingSchema = exports_external.union([
35219
36233
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35220
36234
  labels: exports_external.array(exports_external.string()).optional(),
35221
36235
  maxLines: exports_external.number().int().positive().optional(),
36236
+ maxLineChars: exports_external.number().int().positive().optional(),
35222
36237
  render: exports_external.enum(["text", "rich"]).optional(),
35223
36238
  toolProgress: exports_external.boolean().optional(),
35224
36239
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35246,6 +36261,7 @@ var InlineRuntimeStreamingSchema = exports_external.union([
35246
36261
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35247
36262
  labels: exports_external.array(exports_external.string()).optional(),
35248
36263
  maxLines: exports_external.number().int().positive().optional(),
36264
+ maxLineChars: exports_external.number().int().positive().optional(),
35249
36265
  render: exports_external.enum(["text", "rich"]).optional(),
35250
36266
  toolProgress: exports_external.boolean().optional(),
35251
36267
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35271,6 +36287,10 @@ var InlineAccountSchemaBase = exports_external.object({
35271
36287
  groupPolicy: GroupPolicySchema.optional().default("allowlist"),
35272
36288
  groups: exports_external.record(exports_external.string(), InlineGroupSchema.optional()).optional(),
35273
36289
  requireMention: exports_external.boolean().optional(),
36290
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36291
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36292
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36293
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35274
36294
  replyToBotWithoutMention: exports_external.boolean().optional(),
35275
36295
  historyLimit: exports_external.number().int().min(0).optional(),
35276
36296
  dmHistoryLimit: exports_external.number().int().min(0).optional(),
@@ -35542,9 +36562,7 @@ function inspectInlineAccount(params) {
35542
36562
  }
35543
36563
  const tokenFile = account.tokenFile?.trim() ?? "";
35544
36564
  if (tokenFile) {
35545
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35546
- rejectSymlink: true
35547
- }) ?? "";
36565
+ const token = tryReadInlineTokenFile(tokenFile);
35548
36566
  return {
35549
36567
  ...account,
35550
36568
  token: token || null,
@@ -35604,37 +36622,30 @@ async function resolveInlineToken(account) {
35604
36622
  }
35605
36623
  throw new Error("Inline token missing (set channels.inline.token, channels.inline.tokenFile, INLINE_TOKEN, or INLINE_BOT_TOKEN)");
35606
36624
  }
35607
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35608
- rejectSymlink: true
35609
- });
36625
+ const token = readInlineTokenFile(tokenFile);
35610
36626
  if (!token)
35611
36627
  throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`);
35612
36628
  return token;
35613
36629
  }
35614
-
35615
- // src/inline/normalize.ts
35616
- function normalizeInlineTarget(raw) {
35617
- let normalized = raw.trim();
35618
- if (!normalized)
35619
- return;
35620
- const lowered = normalized.toLowerCase();
35621
- if (lowered.startsWith("inline:")) {
35622
- normalized = normalized.slice("inline:".length).trim();
35623
- }
35624
- const userMatch = normalized.match(/^user:\s*([0-9]+)\s*$/i);
35625
- if (userMatch?.[1]) {
35626
- return `user:${userMatch[1]}`;
36630
+ function tryReadInlineTokenFile(tokenFile) {
36631
+ try {
36632
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36633
+ rejectSymlink: true
36634
+ }) ?? "";
36635
+ } catch {
36636
+ return "";
35627
36637
  }
35628
- normalized = normalized.replace(/^chat:/i, "").trim();
35629
- return normalized || undefined;
35630
36638
  }
35631
- function looksLikeInlineTargetId(raw, normalizedInput) {
35632
- const normalized = normalizedInput?.trim() || normalizeInlineTarget(raw);
35633
- if (!normalized)
35634
- return false;
35635
- if (/^user:[0-9]+$/i.test(normalized))
35636
- return true;
35637
- return /^[0-9]+$/.test(normalized);
36639
+ function readInlineTokenFile(tokenFile) {
36640
+ try {
36641
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36642
+ rejectSymlink: true
36643
+ }) ?? "";
36644
+ } catch (error51) {
36645
+ throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`, {
36646
+ cause: error51
36647
+ });
36648
+ }
35638
36649
  }
35639
36650
 
35640
36651
  // src/inline/outbound-sanitize.ts
@@ -35877,6 +36888,135 @@ function sanitizeInlineActionCallbackData(raw) {
35877
36888
  return text;
35878
36889
  }
35879
36890
 
36891
+ // src/inline/normalize.ts
36892
+ function normalizeInlineTarget(raw) {
36893
+ let normalized = raw.trim();
36894
+ if (!normalized)
36895
+ return;
36896
+ const lowered = normalized.toLowerCase();
36897
+ if (lowered.startsWith("inline:")) {
36898
+ normalized = normalized.slice("inline:".length).trim();
36899
+ }
36900
+ const userMatch = normalized.match(/^user:\s*([0-9]+)\s*$/i);
36901
+ if (userMatch?.[1]) {
36902
+ return `user:${userMatch[1]}`;
36903
+ }
36904
+ normalized = normalized.replace(/^chat:/i, "").trim();
36905
+ return normalized || undefined;
36906
+ }
36907
+ function looksLikeInlineTargetId(raw, normalizedInput) {
36908
+ const normalized = normalizedInput?.trim() || normalizeInlineTarget(raw);
36909
+ if (!normalized)
36910
+ return false;
36911
+ if (/^user:[0-9]+$/i.test(normalized))
36912
+ return true;
36913
+ return /^[0-9]+$/.test(normalized);
36914
+ }
36915
+
36916
+ // src/inline/tool-targets.ts
36917
+ function parseInlineId(raw, label) {
36918
+ if (typeof raw === "bigint") {
36919
+ if (raw < 0n)
36920
+ throw new Error(`inline tool: invalid ${label} "${raw.toString()}"`);
36921
+ return raw;
36922
+ }
36923
+ if (typeof raw === "number") {
36924
+ if (!Number.isFinite(raw) || !Number.isInteger(raw) || raw < 0) {
36925
+ throw new Error(`inline tool: invalid ${label} "${String(raw)}"`);
36926
+ }
36927
+ return BigInt(raw);
36928
+ }
36929
+ if (typeof raw === "string") {
36930
+ const trimmed = raw.trim();
36931
+ if (!trimmed)
36932
+ throw new Error(`inline tool: missing ${label}`);
36933
+ if (!/^[0-9]+$/.test(trimmed))
36934
+ throw new Error(`inline tool: invalid ${label} "${raw}"`);
36935
+ return BigInt(trimmed);
36936
+ }
36937
+ throw new Error(`inline tool: missing ${label}`);
36938
+ }
36939
+ function parseOptionalInlineId(raw, label) {
36940
+ if (raw == null)
36941
+ return null;
36942
+ if (typeof raw === "string" && !raw.trim())
36943
+ return null;
36944
+ return parseInlineId(raw, label);
36945
+ }
36946
+ function parseInlineTarget(raw, label) {
36947
+ const normalized = normalizeInlineTarget(raw) ?? raw.trim();
36948
+ const userMatch = normalized.match(/^user:([0-9]+)$/i);
36949
+ if (userMatch?.[1]) {
36950
+ return {
36951
+ normalized: `user:${userMatch[1]}`,
36952
+ peerId: {
36953
+ type: {
36954
+ oneofKind: "user",
36955
+ user: { userId: BigInt(userMatch[1]) }
36956
+ }
36957
+ }
36958
+ };
36959
+ }
36960
+ if (!/^[0-9]+$/.test(normalized)) {
36961
+ throw new Error(`inline tool: invalid ${label} "${raw}"`);
36962
+ }
36963
+ return {
36964
+ normalized,
36965
+ peerId: {
36966
+ type: {
36967
+ oneofKind: "chat",
36968
+ chat: { chatId: BigInt(normalized) }
36969
+ }
36970
+ }
36971
+ };
36972
+ }
36973
+ function parseCurrentInlineSession(ctx) {
36974
+ if ((ctx.messageChannel ?? "").trim().toLowerCase() !== "inline")
36975
+ return null;
36976
+ const sessionKey = ctx.sessionKey?.trim();
36977
+ if (!sessionKey)
36978
+ return null;
36979
+ const explicitMatch = sessionKey.match(/^agent:[^:]+:inline:(chat|group|user|direct):([0-9]+)(?::thread:([0-9]+))?$/i);
36980
+ if (explicitMatch?.[1] && explicitMatch[2]) {
36981
+ const kind = explicitMatch[1].toLowerCase();
36982
+ const threadId = explicitMatch[3];
36983
+ if ((kind === "chat" || kind === "group") && threadId) {
36984
+ return {
36985
+ target: parseInlineTarget(threadId, "current chat"),
36986
+ parentChatId: parseInlineId(explicitMatch[2], "current parent chat"),
36987
+ threadId: parseInlineId(threadId, "current thread")
36988
+ };
36989
+ }
36990
+ return {
36991
+ target: parseInlineTarget(kind === "user" || kind === "direct" ? `user:${explicitMatch[2]}` : explicitMatch[2], "current chat"),
36992
+ parentChatId: null,
36993
+ threadId: null
36994
+ };
36995
+ }
36996
+ const legacyMatch = sessionKey.match(/^agent:[^:]+:inline:([0-9]+)(?::thread:([0-9]+))?$/i);
36997
+ if (legacyMatch?.[1]) {
36998
+ return {
36999
+ target: parseInlineTarget(legacyMatch[2] ?? legacyMatch[1], "current chat"),
37000
+ parentChatId: legacyMatch[2] ? parseInlineId(legacyMatch[1], "current parent chat") : null,
37001
+ threadId: legacyMatch[2] ? parseInlineId(legacyMatch[2], "current thread") : null
37002
+ };
37003
+ }
37004
+ return null;
37005
+ }
37006
+ function parseCurrentInlineTarget(ctx) {
37007
+ return parseCurrentInlineSession(ctx)?.target ?? null;
37008
+ }
37009
+ function readStringCandidate(...values) {
37010
+ for (const value of values) {
37011
+ if (typeof value !== "string")
37012
+ continue;
37013
+ const trimmed = value.trim();
37014
+ if (trimmed)
37015
+ return trimmed;
37016
+ }
37017
+ return;
37018
+ }
37019
+
35880
37020
  // src/inline/message-tools.ts
35881
37021
  var InlineNudgeToolParameters = {
35882
37022
  type: "object",
@@ -35978,87 +37118,6 @@ var InlineForwardToolParameters = {
35978
37118
  },
35979
37119
  required: ["to"]
35980
37120
  };
35981
- function parseInlineId(raw, label) {
35982
- if (typeof raw === "bigint") {
35983
- if (raw < 0n)
35984
- throw new Error(`inline tool: invalid ${label} "${raw.toString()}"`);
35985
- return raw;
35986
- }
35987
- if (typeof raw === "number") {
35988
- if (!Number.isFinite(raw) || !Number.isInteger(raw) || raw < 0) {
35989
- throw new Error(`inline tool: invalid ${label} "${String(raw)}"`);
35990
- }
35991
- return BigInt(raw);
35992
- }
35993
- if (typeof raw === "string") {
35994
- const trimmed = raw.trim();
35995
- if (!trimmed)
35996
- throw new Error(`inline tool: missing ${label}`);
35997
- if (!/^[0-9]+$/.test(trimmed))
35998
- throw new Error(`inline tool: invalid ${label} "${raw}"`);
35999
- return BigInt(trimmed);
36000
- }
36001
- throw new Error(`inline tool: missing ${label}`);
36002
- }
36003
- function parseInlineTarget(raw, label) {
36004
- const normalized = normalizeInlineTarget(raw) ?? raw.trim();
36005
- const userMatch = normalized.match(/^user:([0-9]+)$/i);
36006
- if (userMatch?.[1]) {
36007
- return {
36008
- normalized: `user:${userMatch[1]}`,
36009
- peerId: {
36010
- type: {
36011
- oneofKind: "user",
36012
- user: { userId: BigInt(userMatch[1]) }
36013
- }
36014
- }
36015
- };
36016
- }
36017
- if (!/^[0-9]+$/.test(normalized)) {
36018
- throw new Error(`inline tool: invalid ${label} "${raw}"`);
36019
- }
36020
- return {
36021
- normalized,
36022
- peerId: {
36023
- type: {
36024
- oneofKind: "chat",
36025
- chat: { chatId: BigInt(normalized) }
36026
- }
36027
- }
36028
- };
36029
- }
36030
- function parseCurrentInlineTarget(ctx) {
36031
- if ((ctx.messageChannel ?? "").trim().toLowerCase() !== "inline") {
36032
- return null;
36033
- }
36034
- const sessionKey = ctx.sessionKey?.trim();
36035
- if (!sessionKey)
36036
- return null;
36037
- const explicitMatch = sessionKey.match(/^agent:[^:]+:inline:(chat|group|user|direct):([0-9]+)(?::thread:([0-9]+))?$/i);
36038
- if (explicitMatch?.[1] && explicitMatch[2]) {
36039
- const kind = explicitMatch[1].toLowerCase();
36040
- const threadId = explicitMatch[3];
36041
- if ((kind === "chat" || kind === "group") && threadId) {
36042
- return parseInlineTarget(threadId, "current chat");
36043
- }
36044
- return parseInlineTarget(kind === "user" || kind === "direct" ? `user:${explicitMatch[2]}` : explicitMatch[2], "current chat");
36045
- }
36046
- const legacyMatch = sessionKey.match(/^agent:[^:]+:inline:([0-9]+)(?::thread:([0-9]+))?$/i);
36047
- if (legacyMatch?.[1]) {
36048
- return parseInlineTarget(legacyMatch[2] ?? legacyMatch[1], "current chat");
36049
- }
36050
- return null;
36051
- }
36052
- function readStringCandidate(...values) {
36053
- for (const value of values) {
36054
- if (typeof value !== "string")
36055
- continue;
36056
- const trimmed = value.trim();
36057
- if (trimmed)
36058
- return trimmed;
36059
- }
36060
- return;
36061
- }
36062
37121
  function resolvePeerTarget(params) {
36063
37122
  if (params.direct) {
36064
37123
  return {
@@ -36456,6 +37515,687 @@ function createInlineMembersTool(ctx) {
36456
37515
  };
36457
37516
  }
36458
37517
 
37518
+ // src/inline/message-content.ts
37519
+ var INLINE_MESSAGE_ENTITY_TYPE = {
37520
+ MENTION: 1,
37521
+ URL: 2,
37522
+ TEXT_URL: 3,
37523
+ EMAIL: 4,
37524
+ BOLD: 5,
37525
+ ITALIC: 6,
37526
+ USERNAME_MENTION: 7,
37527
+ CODE: 8,
37528
+ PRE: 9,
37529
+ PHONE_NUMBER: 10
37530
+ };
37531
+ function compactWhitespace(raw) {
37532
+ return (raw ?? "").replace(/\s+/g, " ").trim();
37533
+ }
37534
+ function bestPhotoSize(photo) {
37535
+ let best = {
37536
+ cdnUrl: null,
37537
+ width: null,
37538
+ height: null,
37539
+ sizeBytes: null
37540
+ };
37541
+ let bestArea = -1;
37542
+ for (const size of photo.sizes ?? []) {
37543
+ const width = typeof size.w === "number" ? size.w : null;
37544
+ const height = typeof size.h === "number" ? size.h : null;
37545
+ const area = Math.max(0, width ?? 0) * Math.max(0, height ?? 0);
37546
+ if (size.cdnUrl && area >= bestArea) {
37547
+ bestArea = area;
37548
+ best = {
37549
+ cdnUrl: size.cdnUrl,
37550
+ width,
37551
+ height,
37552
+ sizeBytes: typeof size.size === "number" ? size.size : null
37553
+ };
37554
+ }
37555
+ }
37556
+ return best;
37557
+ }
37558
+ function messageMediaSummary(message) {
37559
+ const mediaContainer = message.media;
37560
+ const media = mediaContainer && typeof mediaContainer === "object" ? "media" in mediaContainer && mediaContainer.media && typeof mediaContainer.media === "object" && "oneofKind" in mediaContainer.media ? mediaContainer.media : ("oneofKind" in mediaContainer) ? mediaContainer : null : null;
37561
+ if (!media)
37562
+ return null;
37563
+ if (media.oneofKind === "photo") {
37564
+ const photo = media.photo?.photo;
37565
+ const bestSize = photo ? bestPhotoSize(photo) : { cdnUrl: null, width: null, height: null, sizeBytes: null };
37566
+ return {
37567
+ kind: "photo",
37568
+ id: photo?.id?.toString() ?? null,
37569
+ url: bestSize.cdnUrl,
37570
+ sizeBytes: bestSize.sizeBytes,
37571
+ width: bestSize.width,
37572
+ height: bestSize.height
37573
+ };
37574
+ }
37575
+ if (media.oneofKind === "video") {
37576
+ const video = media.video?.video;
37577
+ return {
37578
+ kind: "video",
37579
+ id: video?.id?.toString() ?? null,
37580
+ url: video?.cdnUrl ?? null,
37581
+ sizeBytes: video?.size ?? null,
37582
+ width: video?.w ?? null,
37583
+ height: video?.h ?? null,
37584
+ durationSeconds: video?.duration ?? null
37585
+ };
37586
+ }
37587
+ if (media.oneofKind === "document") {
37588
+ const document = media.document?.document;
37589
+ return {
37590
+ kind: "document",
37591
+ id: document?.id?.toString() ?? null,
37592
+ url: document?.cdnUrl ?? null,
37593
+ fileName: document?.fileName ?? null,
37594
+ mimeType: document?.mimeType ?? null,
37595
+ sizeBytes: document?.size ?? null
37596
+ };
37597
+ }
37598
+ if (media.oneofKind === "voice") {
37599
+ const voice = media.voice?.voice;
37600
+ return {
37601
+ kind: "voice",
37602
+ id: voice?.id?.toString() ?? null,
37603
+ url: voice?.cdnUrl ?? null,
37604
+ mimeType: voice?.mimeType ?? null,
37605
+ sizeBytes: voice?.size ?? null,
37606
+ durationSeconds: voice?.duration ?? null
37607
+ };
37608
+ }
37609
+ return {
37610
+ kind: "nudge",
37611
+ id: null,
37612
+ url: null
37613
+ };
37614
+ }
37615
+ function messageAttachmentSummaries(message) {
37616
+ const attachments = [];
37617
+ for (const item of message.attachments?.attachments ?? []) {
37618
+ if (item.attachment.oneofKind === "urlPreview") {
37619
+ const preview = item.attachment.urlPreview;
37620
+ const previewPhoto = preview.photo ? bestPhotoSize(preview.photo).cdnUrl : null;
37621
+ attachments.push({
37622
+ kind: "urlPreview",
37623
+ id: preview.id?.toString() ?? null,
37624
+ url: preview.url ?? null,
37625
+ siteName: preview.siteName ?? null,
37626
+ title: preview.title ?? null,
37627
+ description: preview.description ?? null,
37628
+ previewImageUrl: previewPhoto
37629
+ });
37630
+ continue;
37631
+ }
37632
+ if (item.attachment.oneofKind === "externalTask") {
37633
+ const task = item.attachment.externalTask;
37634
+ attachments.push({
37635
+ kind: "externalTask",
37636
+ id: task.id?.toString() ?? null,
37637
+ url: task.url ?? null,
37638
+ application: task.application ?? null,
37639
+ title: task.title ?? null,
37640
+ taskId: task.taskId ?? null,
37641
+ number: task.number ?? null
37642
+ });
37643
+ }
37644
+ }
37645
+ return attachments;
37646
+ }
37647
+ function extractMessageUrls(message, attachments) {
37648
+ const urls = new Set;
37649
+ for (const entity of message.entities?.entities ?? []) {
37650
+ if (entity.type !== INLINE_MESSAGE_ENTITY_TYPE.URL && entity.type !== INLINE_MESSAGE_ENTITY_TYPE.TEXT_URL)
37651
+ continue;
37652
+ if (entity.entity.oneofKind === "textUrl") {
37653
+ const candidate2 = entity.entity.textUrl.url?.trim();
37654
+ if (candidate2)
37655
+ urls.add(candidate2);
37656
+ continue;
37657
+ }
37658
+ if (typeof message.message !== "string")
37659
+ continue;
37660
+ const offset = Number(entity.offset);
37661
+ const length = Number(entity.length);
37662
+ if (!Number.isFinite(offset) || !Number.isFinite(length) || offset < 0 || length <= 0)
37663
+ continue;
37664
+ const candidate = message.message.slice(offset, offset + length).trim();
37665
+ if (candidate)
37666
+ urls.add(candidate);
37667
+ }
37668
+ for (const attachment of attachments) {
37669
+ const candidate = attachment.url?.trim();
37670
+ if (candidate)
37671
+ urls.add(candidate);
37672
+ }
37673
+ return Array.from(urls);
37674
+ }
37675
+ function mapEntityType(type) {
37676
+ switch (type) {
37677
+ case INLINE_MESSAGE_ENTITY_TYPE.MENTION:
37678
+ return "mention";
37679
+ case INLINE_MESSAGE_ENTITY_TYPE.URL:
37680
+ return "url";
37681
+ case INLINE_MESSAGE_ENTITY_TYPE.TEXT_URL:
37682
+ return "text_link";
37683
+ case INLINE_MESSAGE_ENTITY_TYPE.EMAIL:
37684
+ return "email";
37685
+ case INLINE_MESSAGE_ENTITY_TYPE.BOLD:
37686
+ return "bold";
37687
+ case INLINE_MESSAGE_ENTITY_TYPE.ITALIC:
37688
+ return "italic";
37689
+ case INLINE_MESSAGE_ENTITY_TYPE.USERNAME_MENTION:
37690
+ return "username_mention";
37691
+ case INLINE_MESSAGE_ENTITY_TYPE.CODE:
37692
+ return "code";
37693
+ case INLINE_MESSAGE_ENTITY_TYPE.PRE:
37694
+ return "pre";
37695
+ case INLINE_MESSAGE_ENTITY_TYPE.PHONE_NUMBER:
37696
+ return "phone_number";
37697
+ default:
37698
+ return "unknown";
37699
+ }
37700
+ }
37701
+ function readEntitySlice(messageText, entity) {
37702
+ if (!messageText)
37703
+ return;
37704
+ const offset = Number(entity.offset);
37705
+ const length = Number(entity.length);
37706
+ if (!Number.isFinite(offset) || !Number.isFinite(length) || offset < 0 || length <= 0)
37707
+ return;
37708
+ const slice = compactWhitespace(messageText.slice(offset, offset + length));
37709
+ return slice || undefined;
37710
+ }
37711
+ function messageEntitySummaries(message) {
37712
+ const rawText = message.message ?? "";
37713
+ const entities = [];
37714
+ for (const entity of message.entities?.entities ?? []) {
37715
+ const offset = Number(entity.offset);
37716
+ const length = Number(entity.length);
37717
+ if (!Number.isFinite(offset) || !Number.isFinite(length) || offset < 0 || length < 0)
37718
+ continue;
37719
+ const summary = {
37720
+ type: mapEntityType(entity.type),
37721
+ offset,
37722
+ length
37723
+ };
37724
+ const text = readEntitySlice(rawText, entity);
37725
+ if (text) {
37726
+ summary.text = text;
37727
+ }
37728
+ if (entity.entity.oneofKind === "mention") {
37729
+ summary.userId = entity.entity.mention.userId.toString();
37730
+ } else if (entity.entity.oneofKind === "textUrl") {
37731
+ const url2 = entity.entity.textUrl.url?.trim();
37732
+ if (url2)
37733
+ summary.url = url2;
37734
+ } else if (entity.entity.oneofKind === "pre") {
37735
+ const language = compactWhitespace(entity.entity.pre.language);
37736
+ if (language)
37737
+ summary.language = language;
37738
+ }
37739
+ entities.push(summary);
37740
+ }
37741
+ return entities;
37742
+ }
37743
+ function formatMediaSummary(media) {
37744
+ if (media.kind === "nudge")
37745
+ return "nudge";
37746
+ if (media.kind === "photo") {
37747
+ return media.url ? `image attachment: ${media.url}` : "image attachment";
37748
+ }
37749
+ if (media.kind === "video") {
37750
+ return media.url ? `video attachment: ${media.url}` : "video attachment";
37751
+ }
37752
+ if (media.kind === "voice") {
37753
+ return media.url ? `audio attachment: ${media.url}` : "audio attachment";
37754
+ }
37755
+ const label = media.fileName ? `document attachment (${media.fileName})` : "document attachment";
37756
+ return media.url ? `${label}: ${media.url}` : label;
37757
+ }
37758
+ function formatAttachmentSummary(attachment) {
37759
+ if (attachment.kind === "urlPreview") {
37760
+ const title2 = compactWhitespace(attachment.title ?? undefined);
37761
+ const url3 = attachment.url?.trim() ?? "";
37762
+ if (title2 && url3)
37763
+ return `link preview (${title2}): ${url3}`;
37764
+ if (url3)
37765
+ return `link preview: ${url3}`;
37766
+ if (title2)
37767
+ return `link preview (${title2})`;
37768
+ return "link preview";
37769
+ }
37770
+ const title = compactWhitespace(attachment.title ?? undefined);
37771
+ const source = compactWhitespace(attachment.application ?? undefined);
37772
+ const url2 = attachment.url?.trim() ?? "";
37773
+ const label = [source, title].filter(Boolean).join(": ");
37774
+ if (label && url2)
37775
+ return `task attachment (${label}): ${url2}`;
37776
+ if (url2)
37777
+ return `task attachment: ${url2}`;
37778
+ if (label)
37779
+ return `task attachment (${label})`;
37780
+ return "task attachment";
37781
+ }
37782
+ function formatEntitySummary(entity) {
37783
+ const text = compactWhitespace(entity.text);
37784
+ const quotedText = text ? ` "${text}"` : "";
37785
+ switch (entity.type) {
37786
+ case "mention":
37787
+ return entity.userId ? `mention${quotedText} -> user:${entity.userId}` : `mention${quotedText}`;
37788
+ case "text_link":
37789
+ return entity.url ? `text link${quotedText} -> ${entity.url}` : `text link${quotedText}`;
37790
+ case "pre":
37791
+ return entity.language ? `preformatted block${quotedText} (language: ${entity.language})` : `preformatted block${quotedText}`;
37792
+ case "username_mention":
37793
+ return `username mention${quotedText}`;
37794
+ case "phone_number":
37795
+ return `phone number${quotedText}`;
37796
+ default:
37797
+ return `${entity.type.replace(/_/g, " ")}${quotedText}`;
37798
+ }
37799
+ }
37800
+ function summarizeInlineMessageContent(message) {
37801
+ const rawText = compactWhitespace(message.message);
37802
+ const media = messageMediaSummary(message);
37803
+ const attachments = messageAttachmentSummaries(message);
37804
+ const entities = messageEntitySummaries(message);
37805
+ const attachmentParts = [];
37806
+ if (media) {
37807
+ attachmentParts.push(formatMediaSummary(media));
37808
+ }
37809
+ for (const attachment of attachments) {
37810
+ attachmentParts.push(formatAttachmentSummary(attachment));
37811
+ }
37812
+ const attachmentText = attachmentParts.filter(Boolean).join(" | ");
37813
+ const entityText = entities.map((entity) => formatEntitySummary(entity)).filter(Boolean).join(" | ");
37814
+ const links = extractMessageUrls(message, attachments);
37815
+ const attachmentUrls = Array.from(new Set([
37816
+ ...media?.url ? [media.url] : [],
37817
+ ...links,
37818
+ ...attachments.flatMap((attachment) => attachment.kind === "urlPreview" && attachment.previewImageUrl ? [attachment.previewImageUrl] : [])
37819
+ ]));
37820
+ const parts = [rawText, attachmentText];
37821
+ return {
37822
+ text: parts.filter(Boolean).join(" | "),
37823
+ rawText,
37824
+ attachmentText,
37825
+ entityText,
37826
+ links,
37827
+ attachmentUrls,
37828
+ media,
37829
+ attachments,
37830
+ entities
37831
+ };
37832
+ }
37833
+
37834
+ // src/inline/reply-threads.ts
37835
+ var GET_CHAT_METHOD = typeof Method.GET_CHAT === "number" && Number.isInteger(Method.GET_CHAT) && Method.GET_CHAT > 0 ? Method.GET_CHAT : 25;
37836
+ 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;
37837
+ var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : 38;
37838
+ var CREATE_SUBTHREAD_METHOD = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 42;
37839
+ function buildChatPeer(chatId) {
37840
+ return {
37841
+ type: {
37842
+ oneofKind: "chat",
37843
+ chat: { chatId }
37844
+ }
37845
+ };
37846
+ }
37847
+ function getInlineReplyThreadsCapabilityConfig(params) {
37848
+ return { replyThreads: true };
37849
+ }
37850
+ function isInlineReplyThreadsEnabled(params) {
37851
+ return getInlineReplyThreadsCapabilityConfig(params).replyThreads;
37852
+ }
37853
+ function resolveInlineReplyThreadChatId(params) {
37854
+ params.cfg;
37855
+ params.accountId;
37856
+ if (params.parentChatId == null) {
37857
+ return null;
37858
+ }
37859
+ if (params.threadId == null) {
37860
+ return params.parentChatId;
37861
+ }
37862
+ 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() ? (() => {
37863
+ try {
37864
+ return BigInt(params.threadId.trim());
37865
+ } catch {
37866
+ return null;
37867
+ }
37868
+ })() : null : null;
37869
+ return normalized ?? params.parentChatId;
37870
+ }
37871
+ async function loadInlineReplyThreadMetadata(params) {
37872
+ const result = await params.client.invokeRaw(GET_CHAT_METHOD, {
37873
+ oneofKind: "getChat",
37874
+ getChat: { peerId: buildChatPeer(params.chatId) }
37875
+ }).catch(() => null);
37876
+ if (result?.oneofKind !== "getChat") {
37877
+ return null;
37878
+ }
37879
+ const chat = result.getChat.chat;
37880
+ const parentChatId = chat?.parentChatId;
37881
+ if (parentChatId == null) {
37882
+ return null;
37883
+ }
37884
+ return {
37885
+ childChatId: chat?.id ?? params.chatId,
37886
+ parentChatId,
37887
+ parentMessageId: chat?.parentMessageId ?? null,
37888
+ title: chat?.title?.trim() || null
37889
+ };
37890
+ }
37891
+ async function loadInlineReplyThreadAnchorMessage(params) {
37892
+ const directResult = await params.client.invokeRaw(GET_MESSAGES_METHOD, {
37893
+ oneofKind: "getMessages",
37894
+ getMessages: {
37895
+ peerId: buildChatPeer(params.parentChatId),
37896
+ messageIds: [params.parentMessageId]
37897
+ }
37898
+ }).catch(() => null);
37899
+ if (directResult?.oneofKind === "getMessages") {
37900
+ const directTarget = (directResult.getMessages.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
37901
+ if (directTarget) {
37902
+ return directTarget;
37903
+ }
37904
+ }
37905
+ const historyResult = await params.client.invokeRaw(GET_CHAT_HISTORY_METHOD, {
37906
+ oneofKind: "getChatHistory",
37907
+ getChatHistory: {
37908
+ peerId: buildChatPeer(params.parentChatId),
37909
+ offsetId: params.parentMessageId + 1n,
37910
+ limit: 8
37911
+ }
37912
+ }).catch(() => null);
37913
+ if (historyResult?.oneofKind !== "getChatHistory") {
37914
+ return null;
37915
+ }
37916
+ return (historyResult.getChatHistory.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
37917
+ }
37918
+ async function createInlineReplyThreadForMessage(params) {
37919
+ const result = await params.client.invokeRaw(CREATE_SUBTHREAD_METHOD, {
37920
+ oneofKind: "createSubthread",
37921
+ createSubthread: {
37922
+ parentChatId: params.parentChatId,
37923
+ parentMessageId: params.parentMessageId,
37924
+ participants: []
37925
+ }
37926
+ });
37927
+ if (result.oneofKind !== "createSubthread") {
37928
+ return null;
37929
+ }
37930
+ const chat = result.createSubthread.chat;
37931
+ if (!chat?.id) {
37932
+ return null;
37933
+ }
37934
+ return {
37935
+ childChatId: chat.id,
37936
+ parentChatId: chat.parentChatId ?? params.parentChatId,
37937
+ parentMessageId: chat.parentMessageId ?? params.parentMessageId,
37938
+ title: chat.title?.trim() || null,
37939
+ anchorMessage: result.createSubthread.anchorMessage ?? null
37940
+ };
37941
+ }
37942
+
37943
+ // src/inline/parent-context-tool.ts
37944
+ var GET_CHAT_HISTORY_METHOD2 = typeof Method.GET_CHAT_HISTORY === "number" && Number.isInteger(Method.GET_CHAT_HISTORY) && Method.GET_CHAT_HISTORY > 0 ? Method.GET_CHAT_HISTORY : 5;
37945
+ var InlineParentContextToolParameters = {
37946
+ type: "object",
37947
+ additionalProperties: false,
37948
+ properties: {
37949
+ threadId: {
37950
+ type: "string",
37951
+ description: "Optional Inline reply-thread chat id. Defaults to the current reply-thread chat when invoked from one."
37952
+ },
37953
+ parentChatId: {
37954
+ type: "string",
37955
+ description: "Optional parent chat id override. Usually inferred from the current reply thread."
37956
+ },
37957
+ chatId: {
37958
+ type: "string",
37959
+ description: "Alias for `parentChatId`."
37960
+ },
37961
+ parentMessageId: {
37962
+ type: "string",
37963
+ description: "Optional parent/root anchor message id. Usually inferred from reply-thread metadata."
37964
+ },
37965
+ anchorMessageId: {
37966
+ type: "string",
37967
+ description: "Alias for `parentMessageId`."
37968
+ },
37969
+ beforeMessageId: {
37970
+ type: "string",
37971
+ description: "Optional message id to page older parent-chat context before. Defaults to the reply-thread anchor when known."
37972
+ },
37973
+ limit: {
37974
+ type: "number",
37975
+ description: "Number of parent-chat messages to return, clamped to 1..100. Defaults to 50."
37976
+ },
37977
+ includeAnchor: {
37978
+ type: "boolean",
37979
+ description: "Whether to include the reply-thread anchor/root message when parentMessageId is known. Defaults to true."
37980
+ },
37981
+ accountId: {
37982
+ type: "string",
37983
+ description: "Optional Inline account id override."
37984
+ }
37985
+ }
37986
+ };
37987
+ function buildChatPeer2(chatId) {
37988
+ return {
37989
+ type: {
37990
+ oneofKind: "chat",
37991
+ chat: { chatId }
37992
+ }
37993
+ };
37994
+ }
37995
+ function readLimit(raw, fallback) {
37996
+ if (raw == null)
37997
+ return fallback;
37998
+ const value = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw.trim()) : Number.NaN;
37999
+ if (!Number.isFinite(value) || !Number.isInteger(value)) {
38000
+ throw new Error("inline_parent_context: limit must be an integer");
38001
+ }
38002
+ return Math.max(1, Math.min(100, value));
38003
+ }
38004
+ function readIdCandidate(...values) {
38005
+ for (const value of values) {
38006
+ if (value == null)
38007
+ continue;
38008
+ if (typeof value === "string") {
38009
+ const trimmed = value.trim();
38010
+ if (trimmed)
38011
+ return trimmed;
38012
+ continue;
38013
+ }
38014
+ if (typeof value === "number" || typeof value === "bigint")
38015
+ return value;
38016
+ }
38017
+ return;
38018
+ }
38019
+ function parseOptionalChatId(raw, label) {
38020
+ if (raw == null)
38021
+ return null;
38022
+ if (typeof raw === "string") {
38023
+ if (!raw.trim())
38024
+ return null;
38025
+ const target = parseInlineTarget(raw, label);
38026
+ if (target.peerId.type.oneofKind !== "chat") {
38027
+ throw new Error(`inline_parent_context: ${label} must be a chat target`);
38028
+ }
38029
+ return target.peerId.type.chat.chatId;
38030
+ }
38031
+ return parseOptionalInlineId(raw, label);
38032
+ }
38033
+ function mapContextMessage(message, parentMessageId) {
38034
+ const content = summarizeInlineMessageContent(message);
38035
+ return {
38036
+ id: String(message.id),
38037
+ fromId: String(message.fromId),
38038
+ date: Number(message.date) * 1000,
38039
+ text: content.text,
38040
+ rawText: content.rawText,
38041
+ attachmentText: content.attachmentText,
38042
+ entityText: content.entityText,
38043
+ out: Boolean(message.out),
38044
+ replyToId: message.replyToMsgId != null ? String(message.replyToMsgId) : undefined,
38045
+ isAnchor: parentMessageId != null && message.id === parentMessageId,
38046
+ attachmentUrls: content.attachmentUrls,
38047
+ links: content.links,
38048
+ media: content.media,
38049
+ attachments: content.attachments,
38050
+ entities: content.entities
38051
+ };
38052
+ }
38053
+ function sortMessages(messages) {
38054
+ return messages.slice().sort((a, b) => {
38055
+ const byDate = Number(a.date - b.date);
38056
+ if (byDate !== 0)
38057
+ return byDate;
38058
+ if (a.id === b.id)
38059
+ return 0;
38060
+ return a.id < b.id ? -1 : 1;
38061
+ });
38062
+ }
38063
+ function dedupeMessages(messages) {
38064
+ const seen = new Set;
38065
+ const out = [];
38066
+ for (const message of messages) {
38067
+ const id = String(message.id);
38068
+ if (seen.has(id))
38069
+ continue;
38070
+ seen.add(id);
38071
+ out.push(message);
38072
+ }
38073
+ return out;
38074
+ }
38075
+ async function withInlineClient3(params) {
38076
+ const account = resolveInlineAccount({ cfg: params.cfg, accountId: params.accountId ?? null });
38077
+ if (!account.configured || !account.baseUrl) {
38078
+ throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
38079
+ }
38080
+ const token = await resolveInlineToken(account);
38081
+ const client = new InlineSdkClient({
38082
+ baseUrl: account.baseUrl,
38083
+ token
38084
+ });
38085
+ await client.connect();
38086
+ try {
38087
+ return await params.fn(client, account.accountId);
38088
+ } finally {
38089
+ await client.close().catch(() => {});
38090
+ }
38091
+ }
38092
+ async function loadParentHistory(params) {
38093
+ if (params.limit <= 0)
38094
+ return [];
38095
+ const result = await params.client.invokeRaw(GET_CHAT_HISTORY_METHOD2, {
38096
+ oneofKind: "getChatHistory",
38097
+ getChatHistory: {
38098
+ peerId: buildChatPeer2(params.parentChatId),
38099
+ ...params.offsetId != null ? { offsetId: params.offsetId } : {},
38100
+ limit: params.limit
38101
+ }
38102
+ });
38103
+ if (result.oneofKind !== "getChatHistory") {
38104
+ throw new Error(`inline_parent_context: expected getChatHistory result, got ${String(result.oneofKind)}`);
38105
+ }
38106
+ return result.getChatHistory.messages ?? [];
38107
+ }
38108
+ async function loadParentContextMessages(params) {
38109
+ if (params.beforeMessageId != null) {
38110
+ return sortMessages(await loadParentHistory({
38111
+ client: params.client,
38112
+ parentChatId: params.parentChatId,
38113
+ offsetId: params.beforeMessageId,
38114
+ limit: params.limit
38115
+ }));
38116
+ }
38117
+ if (params.parentMessageId == null) {
38118
+ return sortMessages(await loadParentHistory({
38119
+ client: params.client,
38120
+ parentChatId: params.parentChatId,
38121
+ offsetId: null,
38122
+ limit: params.limit
38123
+ }));
38124
+ }
38125
+ const anchor = params.includeAnchor ? await loadInlineReplyThreadAnchorMessage({
38126
+ client: params.client,
38127
+ parentChatId: params.parentChatId,
38128
+ parentMessageId: params.parentMessageId
38129
+ }) : null;
38130
+ const historyLimit = Math.max(0, params.limit - (anchor ? 1 : 0));
38131
+ const history = await loadParentHistory({
38132
+ client: params.client,
38133
+ parentChatId: params.parentChatId,
38134
+ offsetId: params.parentMessageId,
38135
+ limit: historyLimit
38136
+ });
38137
+ return sortMessages(dedupeMessages([...history, ...anchor ? [anchor] : []]));
38138
+ }
38139
+ function createInlineParentContextTool(ctx) {
38140
+ if (!ctx.config)
38141
+ return null;
38142
+ return {
38143
+ name: "inline_parent_context",
38144
+ label: "Inline Parent Context",
38145
+ description: "Fetch additional parent-chat messages for the current Inline reply thread. Use this when the thread's built-in parent context is not enough to answer from the discussion that happened before the thread anchor.",
38146
+ parameters: InlineParentContextToolParameters,
38147
+ execute: async (_toolCallId, rawArgs) => {
38148
+ const args = rawArgs;
38149
+ const currentSession = parseCurrentInlineSession(ctx);
38150
+ const explicitThreadId = readStringCandidate(args.threadId);
38151
+ const threadId = explicitThreadId != null ? parseInlineId(explicitThreadId, "threadId") : currentSession?.threadId ?? null;
38152
+ let parentChatId = parseOptionalChatId(readIdCandidate(args.parentChatId, args.chatId), "parentChatId") ?? currentSession?.parentChatId ?? null;
38153
+ let parentMessageId = parseOptionalInlineId(readIdCandidate(args.parentMessageId, args.anchorMessageId), "parentMessageId");
38154
+ const beforeMessageId = parseOptionalInlineId(readIdCandidate(args.beforeMessageId), "beforeMessageId");
38155
+ const limit = readLimit(args.limit, 50);
38156
+ const includeAnchor = args.includeAnchor !== false;
38157
+ return await withInlineClient3({
38158
+ cfg: ctx.config,
38159
+ accountId: args.accountId ?? ctx.agentAccountId ?? null,
38160
+ fn: async (client, resolvedAccountId) => {
38161
+ let threadTitle = null;
38162
+ if (threadId != null) {
38163
+ const metadata = await loadInlineReplyThreadMetadata({ client, chatId: threadId });
38164
+ parentChatId = metadata?.parentChatId ?? parentChatId;
38165
+ parentMessageId = parentMessageId ?? metadata?.parentMessageId ?? null;
38166
+ threadTitle = metadata?.title ?? null;
38167
+ }
38168
+ if (parentChatId == null) {
38169
+ throw new Error("inline_parent_context: parentChatId is required outside an Inline reply-thread session");
38170
+ }
38171
+ const messages = (await loadParentContextMessages({
38172
+ client,
38173
+ parentChatId,
38174
+ parentMessageId,
38175
+ beforeMessageId,
38176
+ includeAnchor,
38177
+ limit
38178
+ })).map((message) => mapContextMessage(message, parentMessageId));
38179
+ const oldest = messages[0];
38180
+ return jsonResult({
38181
+ ok: true,
38182
+ accountId: resolvedAccountId,
38183
+ parentChatId: String(parentChatId),
38184
+ threadId: threadId != null ? String(threadId) : null,
38185
+ threadTitle,
38186
+ parentMessageId: parentMessageId != null ? String(parentMessageId) : null,
38187
+ limit,
38188
+ includeAnchor,
38189
+ usedCurrentThreadDefault: explicitThreadId == null && currentSession?.threadId != null,
38190
+ nextBeforeMessageId: oldest?.id ?? null,
38191
+ messages
38192
+ });
38193
+ }
38194
+ });
38195
+ }
38196
+ };
38197
+ }
38198
+
36459
38199
  // src/inline/message-formatting.ts
36460
38200
  var INLINE_FORMATTING_RULES = [
36461
38201
  "Use Inline markdown.",
@@ -36507,20 +38247,16 @@ function sanitizeInlineOutgoingText(text) {
36507
38247
  }
36508
38248
 
36509
38249
  // src/runtime.ts
36510
- var runtimeKey = "__inlineOpenClawRuntime";
36511
- function runtimeStore() {
36512
- return globalThis;
36513
- }
36514
- function setInlineRuntime(next) {
36515
- runtimeStore()[runtimeKey] = next;
36516
- }
36517
- function getInlineRuntime() {
36518
- const runtime = runtimeStore()[runtimeKey];
36519
- if (!runtime) {
36520
- throw new Error("Inline runtime not initialized");
36521
- }
36522
- return runtime;
36523
- }
38250
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
38251
+ var {
38252
+ setRuntime: setInlineRuntime,
38253
+ clearRuntime: clearInlineRuntime,
38254
+ tryGetRuntime: getOptionalInlineRuntime,
38255
+ getRuntime: getInlineRuntime
38256
+ } = createPluginRuntimeStore({
38257
+ pluginId: "inline",
38258
+ errorMessage: "Inline runtime not initialized"
38259
+ });
36524
38260
 
36525
38261
  // src/inline/profile-tool.ts
36526
38262
  var InlineProfileToolParameters = {
@@ -36560,7 +38296,7 @@ function jsonResult3(payload) {
36560
38296
  details: payload
36561
38297
  };
36562
38298
  }
36563
- async function withInlineClient3(params) {
38299
+ async function withInlineClient4(params) {
36564
38300
  const account = resolveInlineAccount({ cfg: params.cfg, accountId: params.accountId ?? null });
36565
38301
  if (!account.configured || !account.baseUrl) {
36566
38302
  throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
@@ -36627,7 +38363,7 @@ function createInlineProfileTool(ctx) {
36627
38363
  if (!name && !existingPhotoFileUniqueId && !photoSource) {
36628
38364
  throw new Error("inline_update_profile: provide `name` and/or `photo`");
36629
38365
  }
36630
- return await withInlineClient3({
38366
+ return await withInlineClient4({
36631
38367
  cfg: ctx.config,
36632
38368
  accountId: args.accountId ?? ctx.agentAccountId ?? null,
36633
38369
  fn: async (client, resolvedAccountId) => {
@@ -37055,6 +38791,9 @@ function registerInlinePluginFull(api2) {
37055
38791
  api2.registerTool((ctx) => createInlineMessageTools(ctx), {
37056
38792
  names: ["inline_nudge", "inline_forward"]
37057
38793
  });
38794
+ api2.registerTool((ctx) => createInlineParentContextTool(ctx), {
38795
+ names: ["inline_parent_context"]
38796
+ });
37058
38797
  api2.on("message_sending", (event, ctx) => {
37059
38798
  if (ctx.channelId !== "inline")
37060
38799
  return;
@@ -37082,5 +38821,5 @@ export {
37082
38821
  registerInlinePluginFull
37083
38822
  };
37084
38823
 
37085
- //# debugId=5ACEE44315B26ABD64756E2164756E21
38824
+ //# debugId=D767F13C52B346E664756E2164756E21
37086
38825
  //# sourceMappingURL=runtime-register-api.js.map