@inline-openclaw/inline 0.0.38 → 0.0.39

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 (41) hide show
  1. package/README.md +20 -3
  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 +1032 -92
  5. package/dist/approval-handler.runtime.js.map +14 -14
  6. package/dist/channel-plugin-api.js +1807 -319
  7. package/dist/channel-plugin-api.js.map +18 -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/tool-targets.d.ts +36 -0
  29. package/dist/inline/tool-targets.d.ts.map +1 -0
  30. package/dist/runtime-register-api.d.ts.map +1 -1
  31. package/dist/runtime-register-api.js +1805 -151
  32. package/dist/runtime-register-api.js.map +19 -15
  33. package/dist/runtime-setter-api.js +11 -15
  34. package/dist/runtime-setter-api.js.map +3 -3
  35. package/dist/runtime.d.ts +2 -2
  36. package/dist/runtime.d.ts.map +1 -1
  37. package/dist/setup-entry.d.ts +1 -1
  38. package/dist/setup-plugin-api.js +34 -7
  39. package/dist/setup-plugin-api.js.map +4 -4
  40. package/openclaw.plugin.json +723 -56
  41. 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
  });
@@ -5584,6 +5610,15 @@ var Member_Role;
5584
5610
  Member_Role2[Member_Role2["ADMIN"] = 1] = "ADMIN";
5585
5611
  Member_Role2[Member_Role2["MEMBER"] = 2] = "MEMBER";
5586
5612
  })(Member_Role || (Member_Role = {}));
5613
+ var UrlPreview_MediaType;
5614
+ (function(UrlPreview_MediaType2) {
5615
+ UrlPreview_MediaType2[UrlPreview_MediaType2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
5616
+ UrlPreview_MediaType2[UrlPreview_MediaType2["ARTICLE"] = 1] = "ARTICLE";
5617
+ UrlPreview_MediaType2[UrlPreview_MediaType2["IMAGE"] = 2] = "IMAGE";
5618
+ UrlPreview_MediaType2[UrlPreview_MediaType2["VIDEO"] = 3] = "VIDEO";
5619
+ UrlPreview_MediaType2[UrlPreview_MediaType2["DOCUMENT"] = 4] = "DOCUMENT";
5620
+ UrlPreview_MediaType2[UrlPreview_MediaType2["EMBED"] = 5] = "EMBED";
5621
+ })(UrlPreview_MediaType || (UrlPreview_MediaType = {}));
5587
5622
  var MessageAttachmentExternalTask_Status;
5588
5623
  (function(MessageAttachmentExternalTask_Status2) {
5589
5624
  MessageAttachmentExternalTask_Status2[MessageAttachmentExternalTask_Status2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
@@ -5726,6 +5761,9 @@ var Method;
5726
5761
  Method2[Method2["REVOKE_SESSION"] = 50] = "REVOKE_SESSION";
5727
5762
  Method2[Method2["UPDATE_DIALOG_OPEN"] = 51] = "UPDATE_DIALOG_OPEN";
5728
5763
  Method2[Method2["UPDATE_DIALOG_ORDER"] = 52] = "UPDATE_DIALOG_ORDER";
5764
+ Method2[Method2["CLEAR_CHAT_HISTORY"] = 53] = "CLEAR_CHAT_HISTORY";
5765
+ Method2[Method2["DELETE_BOT"] = 54] = "DELETE_BOT";
5766
+ Method2[Method2["DELETE_MESSAGE_ATTACHMENT"] = 55] = "DELETE_MESSAGE_ATTACHMENT";
5729
5767
  })(Method || (Method = {}));
5730
5768
  var PushNotificationProvider;
5731
5769
  (function(PushNotificationProvider2) {
@@ -8098,7 +8136,8 @@ class Space$Type extends import_runtime4.MessageType {
8098
8136
  { no: 1, name: "id", kind: "scalar", T: 3, L: 0 },
8099
8137
  { no: 2, name: "name", kind: "scalar", T: 9 },
8100
8138
  { no: 3, name: "creator", kind: "scalar", T: 8 },
8101
- { no: 4, name: "date", kind: "scalar", T: 3, L: 0 }
8139
+ { no: 4, name: "date", kind: "scalar", T: 3, L: 0 },
8140
+ { no: 5, name: "is_public", kind: "scalar", opt: true, T: 8 }
8102
8141
  ]);
8103
8142
  }
8104
8143
  create(value) {
@@ -8128,6 +8167,9 @@ class Space$Type extends import_runtime4.MessageType {
8128
8167
  case 4:
8129
8168
  message.date = reader.int64().toBigInt();
8130
8169
  break;
8170
+ case 5:
8171
+ message.isPublic = reader.bool();
8172
+ break;
8131
8173
  default:
8132
8174
  let u = options.readUnknownField;
8133
8175
  if (u === "throw")
@@ -8148,6 +8190,8 @@ class Space$Type extends import_runtime4.MessageType {
8148
8190
  writer.tag(3, import_runtime.WireType.Varint).bool(message.creator);
8149
8191
  if (message.date !== 0n)
8150
8192
  writer.tag(4, import_runtime.WireType.Varint).int64(message.date);
8193
+ if (message.isPublic !== undefined)
8194
+ writer.tag(5, import_runtime.WireType.Varint).bool(message.isPublic);
8151
8195
  let u = options.writeUnknownFields;
8152
8196
  if (u !== false)
8153
8197
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8468,7 +8512,13 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8468
8512
  { no: 4, name: "title", kind: "scalar", opt: true, T: 9 },
8469
8513
  { no: 5, name: "description", kind: "scalar", opt: true, T: 9 },
8470
8514
  { no: 6, name: "photo", kind: "message", T: () => Photo },
8471
- { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 }
8515
+ { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 },
8516
+ { no: 8, name: "media_type", kind: "enum", opt: true, T: () => ["UrlPreview.MediaType", UrlPreview_MediaType, "MEDIA_TYPE_"] },
8517
+ { no: 9, name: "display_url", kind: "scalar", opt: true, T: 9 },
8518
+ { no: 10, name: "provider", kind: "scalar", opt: true, T: 9 },
8519
+ { no: 11, name: "author", kind: "scalar", opt: true, T: 9 },
8520
+ { no: 12, name: "media", kind: "message", T: () => UrlPreviewMedia },
8521
+ { no: 13, name: "layout", kind: "message", T: () => UrlPreviewLayout }
8472
8522
  ]);
8473
8523
  }
8474
8524
  create(value) {
@@ -8504,6 +8554,24 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8504
8554
  case 7:
8505
8555
  message.duration = reader.int64().toBigInt();
8506
8556
  break;
8557
+ case 8:
8558
+ message.mediaType = reader.int32();
8559
+ break;
8560
+ case 9:
8561
+ message.displayUrl = reader.string();
8562
+ break;
8563
+ case 10:
8564
+ message.provider = reader.string();
8565
+ break;
8566
+ case 11:
8567
+ message.author = reader.string();
8568
+ break;
8569
+ case 12:
8570
+ message.media = UrlPreviewMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
8571
+ break;
8572
+ case 13:
8573
+ message.layout = UrlPreviewLayout.internalBinaryRead(reader, reader.uint32(), options, message.layout);
8574
+ break;
8507
8575
  default:
8508
8576
  let u = options.readUnknownField;
8509
8577
  if (u === "throw")
@@ -8530,6 +8598,18 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8530
8598
  Photo.internalBinaryWrite(message.photo, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
8531
8599
  if (message.duration !== undefined)
8532
8600
  writer.tag(7, import_runtime.WireType.Varint).int64(message.duration);
8601
+ if (message.mediaType !== undefined)
8602
+ writer.tag(8, import_runtime.WireType.Varint).int32(message.mediaType);
8603
+ if (message.displayUrl !== undefined)
8604
+ writer.tag(9, import_runtime.WireType.LengthDelimited).string(message.displayUrl);
8605
+ if (message.provider !== undefined)
8606
+ writer.tag(10, import_runtime.WireType.LengthDelimited).string(message.provider);
8607
+ if (message.author !== undefined)
8608
+ writer.tag(11, import_runtime.WireType.LengthDelimited).string(message.author);
8609
+ if (message.media)
8610
+ UrlPreviewMedia.internalBinaryWrite(message.media, writer.tag(12, import_runtime.WireType.LengthDelimited).fork(), options).join();
8611
+ if (message.layout)
8612
+ UrlPreviewLayout.internalBinaryWrite(message.layout, writer.tag(13, import_runtime.WireType.LengthDelimited).fork(), options).join();
8533
8613
  let u = options.writeUnknownFields;
8534
8614
  if (u !== false)
8535
8615
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8538,6 +8618,272 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8538
8618
  }
8539
8619
  var UrlPreview = new UrlPreview$Type;
8540
8620
 
8621
+ class UrlPreviewMedia$Type extends import_runtime4.MessageType {
8622
+ constructor() {
8623
+ super("UrlPreviewMedia", [
8624
+ { no: 1, name: "photo", kind: "message", oneof: "media", T: () => Photo },
8625
+ { no: 2, name: "video", kind: "message", oneof: "media", T: () => Video },
8626
+ { no: 3, name: "document", kind: "message", oneof: "media", T: () => Document },
8627
+ { no: 4, name: "external_video", kind: "message", oneof: "media", T: () => UrlPreviewExternalVideo },
8628
+ { no: 5, name: "embed", kind: "message", oneof: "media", T: () => UrlPreviewEmbed }
8629
+ ]);
8630
+ }
8631
+ create(value) {
8632
+ const message = globalThis.Object.create(this.messagePrototype);
8633
+ message.media = { oneofKind: undefined };
8634
+ if (value !== undefined)
8635
+ import_runtime3.reflectionMergePartial(this, message, value);
8636
+ return message;
8637
+ }
8638
+ internalBinaryRead(reader, length, options, target) {
8639
+ let message = target ?? this.create(), end = reader.pos + length;
8640
+ while (reader.pos < end) {
8641
+ let [fieldNo, wireType] = reader.tag();
8642
+ switch (fieldNo) {
8643
+ case 1:
8644
+ message.media = {
8645
+ oneofKind: "photo",
8646
+ photo: Photo.internalBinaryRead(reader, reader.uint32(), options, message.media.photo)
8647
+ };
8648
+ break;
8649
+ case 2:
8650
+ message.media = {
8651
+ oneofKind: "video",
8652
+ video: Video.internalBinaryRead(reader, reader.uint32(), options, message.media.video)
8653
+ };
8654
+ break;
8655
+ case 3:
8656
+ message.media = {
8657
+ oneofKind: "document",
8658
+ document: Document.internalBinaryRead(reader, reader.uint32(), options, message.media.document)
8659
+ };
8660
+ break;
8661
+ case 4:
8662
+ message.media = {
8663
+ oneofKind: "externalVideo",
8664
+ externalVideo: UrlPreviewExternalVideo.internalBinaryRead(reader, reader.uint32(), options, message.media.externalVideo)
8665
+ };
8666
+ break;
8667
+ case 5:
8668
+ message.media = {
8669
+ oneofKind: "embed",
8670
+ embed: UrlPreviewEmbed.internalBinaryRead(reader, reader.uint32(), options, message.media.embed)
8671
+ };
8672
+ break;
8673
+ default:
8674
+ let u = options.readUnknownField;
8675
+ if (u === "throw")
8676
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8677
+ let d = reader.skip(wireType);
8678
+ if (u !== false)
8679
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8680
+ }
8681
+ }
8682
+ return message;
8683
+ }
8684
+ internalBinaryWrite(message, writer, options) {
8685
+ if (message.media.oneofKind === "photo")
8686
+ Photo.internalBinaryWrite(message.media.photo, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
8687
+ if (message.media.oneofKind === "video")
8688
+ Video.internalBinaryWrite(message.media.video, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
8689
+ if (message.media.oneofKind === "document")
8690
+ Document.internalBinaryWrite(message.media.document, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
8691
+ if (message.media.oneofKind === "externalVideo")
8692
+ UrlPreviewExternalVideo.internalBinaryWrite(message.media.externalVideo, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
8693
+ if (message.media.oneofKind === "embed")
8694
+ UrlPreviewEmbed.internalBinaryWrite(message.media.embed, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
8695
+ let u = options.writeUnknownFields;
8696
+ if (u !== false)
8697
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8698
+ return writer;
8699
+ }
8700
+ }
8701
+ var UrlPreviewMedia = new UrlPreviewMedia$Type;
8702
+
8703
+ class UrlPreviewExternalVideo$Type extends import_runtime4.MessageType {
8704
+ constructor() {
8705
+ super("UrlPreviewExternalVideo", [
8706
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8707
+ { no: 2, name: "mime_type", kind: "scalar", opt: true, T: 9 },
8708
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8709
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8710
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8711
+ ]);
8712
+ }
8713
+ create(value) {
8714
+ const message = globalThis.Object.create(this.messagePrototype);
8715
+ message.url = "";
8716
+ if (value !== undefined)
8717
+ import_runtime3.reflectionMergePartial(this, message, value);
8718
+ return message;
8719
+ }
8720
+ internalBinaryRead(reader, length, options, target) {
8721
+ let message = target ?? this.create(), end = reader.pos + length;
8722
+ while (reader.pos < end) {
8723
+ let [fieldNo, wireType] = reader.tag();
8724
+ switch (fieldNo) {
8725
+ case 1:
8726
+ message.url = reader.string();
8727
+ break;
8728
+ case 2:
8729
+ message.mimeType = reader.string();
8730
+ break;
8731
+ case 3:
8732
+ message.w = reader.int32();
8733
+ break;
8734
+ case 4:
8735
+ message.h = reader.int32();
8736
+ break;
8737
+ case 5:
8738
+ message.duration = reader.int32();
8739
+ break;
8740
+ default:
8741
+ let u = options.readUnknownField;
8742
+ if (u === "throw")
8743
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8744
+ let d = reader.skip(wireType);
8745
+ if (u !== false)
8746
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8747
+ }
8748
+ }
8749
+ return message;
8750
+ }
8751
+ internalBinaryWrite(message, writer, options) {
8752
+ if (message.url !== "")
8753
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8754
+ if (message.mimeType !== undefined)
8755
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.mimeType);
8756
+ if (message.w !== undefined)
8757
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8758
+ if (message.h !== undefined)
8759
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8760
+ if (message.duration !== undefined)
8761
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8762
+ let u = options.writeUnknownFields;
8763
+ if (u !== false)
8764
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8765
+ return writer;
8766
+ }
8767
+ }
8768
+ var UrlPreviewExternalVideo = new UrlPreviewExternalVideo$Type;
8769
+
8770
+ class UrlPreviewEmbed$Type extends import_runtime4.MessageType {
8771
+ constructor() {
8772
+ super("UrlPreviewEmbed", [
8773
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8774
+ { no: 2, name: "type", kind: "scalar", opt: true, T: 9 },
8775
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8776
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8777
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8778
+ ]);
8779
+ }
8780
+ create(value) {
8781
+ const message = globalThis.Object.create(this.messagePrototype);
8782
+ message.url = "";
8783
+ if (value !== undefined)
8784
+ import_runtime3.reflectionMergePartial(this, message, value);
8785
+ return message;
8786
+ }
8787
+ internalBinaryRead(reader, length, options, target) {
8788
+ let message = target ?? this.create(), end = reader.pos + length;
8789
+ while (reader.pos < end) {
8790
+ let [fieldNo, wireType] = reader.tag();
8791
+ switch (fieldNo) {
8792
+ case 1:
8793
+ message.url = reader.string();
8794
+ break;
8795
+ case 2:
8796
+ message.type = reader.string();
8797
+ break;
8798
+ case 3:
8799
+ message.w = reader.int32();
8800
+ break;
8801
+ case 4:
8802
+ message.h = reader.int32();
8803
+ break;
8804
+ case 5:
8805
+ message.duration = reader.int32();
8806
+ break;
8807
+ default:
8808
+ let u = options.readUnknownField;
8809
+ if (u === "throw")
8810
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8811
+ let d = reader.skip(wireType);
8812
+ if (u !== false)
8813
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8814
+ }
8815
+ }
8816
+ return message;
8817
+ }
8818
+ internalBinaryWrite(message, writer, options) {
8819
+ if (message.url !== "")
8820
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8821
+ if (message.type !== undefined)
8822
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.type);
8823
+ if (message.w !== undefined)
8824
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8825
+ if (message.h !== undefined)
8826
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8827
+ if (message.duration !== undefined)
8828
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8829
+ let u = options.writeUnknownFields;
8830
+ if (u !== false)
8831
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8832
+ return writer;
8833
+ }
8834
+ }
8835
+ var UrlPreviewEmbed = new UrlPreviewEmbed$Type;
8836
+
8837
+ class UrlPreviewLayout$Type extends import_runtime4.MessageType {
8838
+ constructor() {
8839
+ super("UrlPreviewLayout", [
8840
+ { no: 1, name: "has_large_media", kind: "scalar", T: 8 },
8841
+ { no: 2, name: "show_large_media", kind: "scalar", T: 8 }
8842
+ ]);
8843
+ }
8844
+ create(value) {
8845
+ const message = globalThis.Object.create(this.messagePrototype);
8846
+ message.hasLargeMedia = false;
8847
+ message.showLargeMedia = false;
8848
+ if (value !== undefined)
8849
+ import_runtime3.reflectionMergePartial(this, message, value);
8850
+ return message;
8851
+ }
8852
+ internalBinaryRead(reader, length, options, target) {
8853
+ let message = target ?? this.create(), end = reader.pos + length;
8854
+ while (reader.pos < end) {
8855
+ let [fieldNo, wireType] = reader.tag();
8856
+ switch (fieldNo) {
8857
+ case 1:
8858
+ message.hasLargeMedia = reader.bool();
8859
+ break;
8860
+ case 2:
8861
+ message.showLargeMedia = reader.bool();
8862
+ break;
8863
+ default:
8864
+ let u = options.readUnknownField;
8865
+ if (u === "throw")
8866
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8867
+ let d = reader.skip(wireType);
8868
+ if (u !== false)
8869
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8870
+ }
8871
+ }
8872
+ return message;
8873
+ }
8874
+ internalBinaryWrite(message, writer, options) {
8875
+ if (message.hasLargeMedia !== false)
8876
+ writer.tag(1, import_runtime.WireType.Varint).bool(message.hasLargeMedia);
8877
+ if (message.showLargeMedia !== false)
8878
+ writer.tag(2, import_runtime.WireType.Varint).bool(message.showLargeMedia);
8879
+ let u = options.writeUnknownFields;
8880
+ if (u !== false)
8881
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8882
+ return writer;
8883
+ }
8884
+ }
8885
+ var UrlPreviewLayout = new UrlPreviewLayout$Type;
8886
+
8541
8887
  class MessageAttachmentExternalTask$Type extends import_runtime4.MessageType {
8542
8888
  constructor() {
8543
8889
  super("MessageAttachmentExternalTask", [
@@ -9431,7 +9777,10 @@ class RpcCall$Type extends import_runtime4.MessageType {
9431
9777
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "input", T: () => AnswerMessageActionInput },
9432
9778
  { no: 51, name: "revokeSession", kind: "message", oneof: "input", T: () => RevokeSessionInput },
9433
9779
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "input", T: () => UpdateDialogOpenInput },
9434
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput }
9780
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput },
9781
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "input", T: () => ClearChatHistoryInput },
9782
+ { no: 55, name: "deleteBot", kind: "message", oneof: "input", T: () => DeleteBotInput },
9783
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "input", T: () => DeleteMessageAttachmentInput }
9435
9784
  ]);
9436
9785
  }
9437
9786
  create(value) {
@@ -9762,6 +10111,24 @@ class RpcCall$Type extends import_runtime4.MessageType {
9762
10111
  updateDialogOrder: UpdateDialogOrderInput.internalBinaryRead(reader, reader.uint32(), options, message.input.updateDialogOrder)
9763
10112
  };
9764
10113
  break;
10114
+ case 54:
10115
+ message.input = {
10116
+ oneofKind: "clearChatHistory",
10117
+ clearChatHistory: ClearChatHistoryInput.internalBinaryRead(reader, reader.uint32(), options, message.input.clearChatHistory)
10118
+ };
10119
+ break;
10120
+ case 55:
10121
+ message.input = {
10122
+ oneofKind: "deleteBot",
10123
+ deleteBot: DeleteBotInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteBot)
10124
+ };
10125
+ break;
10126
+ case 56:
10127
+ message.input = {
10128
+ oneofKind: "deleteMessageAttachment",
10129
+ deleteMessageAttachment: DeleteMessageAttachmentInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteMessageAttachment)
10130
+ };
10131
+ break;
9765
10132
  default:
9766
10133
  let u = options.readUnknownField;
9767
10134
  if (u === "throw")
@@ -9880,6 +10247,12 @@ class RpcCall$Type extends import_runtime4.MessageType {
9880
10247
  UpdateDialogOpenInput.internalBinaryWrite(message.input.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
9881
10248
  if (message.input.oneofKind === "updateDialogOrder")
9882
10249
  UpdateDialogOrderInput.internalBinaryWrite(message.input.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10250
+ if (message.input.oneofKind === "clearChatHistory")
10251
+ ClearChatHistoryInput.internalBinaryWrite(message.input.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10252
+ if (message.input.oneofKind === "deleteBot")
10253
+ DeleteBotInput.internalBinaryWrite(message.input.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10254
+ if (message.input.oneofKind === "deleteMessageAttachment")
10255
+ DeleteMessageAttachmentInput.internalBinaryWrite(message.input.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
9883
10256
  let u = options.writeUnknownFields;
9884
10257
  if (u !== false)
9885
10258
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -9943,7 +10316,10 @@ class RpcResult$Type extends import_runtime4.MessageType {
9943
10316
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "result", T: () => AnswerMessageActionResult },
9944
10317
  { no: 51, name: "revokeSession", kind: "message", oneof: "result", T: () => RevokeSessionResult },
9945
10318
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "result", T: () => UpdateDialogOpenResult },
9946
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult }
10319
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult },
10320
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "result", T: () => ClearChatHistoryResult },
10321
+ { no: 55, name: "deleteBot", kind: "message", oneof: "result", T: () => DeleteBotResult },
10322
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "result", T: () => DeleteMessageAttachmentResult }
9947
10323
  ]);
9948
10324
  }
9949
10325
  create(value) {
@@ -10274,6 +10650,24 @@ class RpcResult$Type extends import_runtime4.MessageType {
10274
10650
  updateDialogOrder: UpdateDialogOrderResult.internalBinaryRead(reader, reader.uint32(), options, message.result.updateDialogOrder)
10275
10651
  };
10276
10652
  break;
10653
+ case 54:
10654
+ message.result = {
10655
+ oneofKind: "clearChatHistory",
10656
+ clearChatHistory: ClearChatHistoryResult.internalBinaryRead(reader, reader.uint32(), options, message.result.clearChatHistory)
10657
+ };
10658
+ break;
10659
+ case 55:
10660
+ message.result = {
10661
+ oneofKind: "deleteBot",
10662
+ deleteBot: DeleteBotResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteBot)
10663
+ };
10664
+ break;
10665
+ case 56:
10666
+ message.result = {
10667
+ oneofKind: "deleteMessageAttachment",
10668
+ deleteMessageAttachment: DeleteMessageAttachmentResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteMessageAttachment)
10669
+ };
10670
+ break;
10277
10671
  default:
10278
10672
  let u = options.readUnknownField;
10279
10673
  if (u === "throw")
@@ -10392,6 +10786,12 @@ class RpcResult$Type extends import_runtime4.MessageType {
10392
10786
  UpdateDialogOpenResult.internalBinaryWrite(message.result.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
10393
10787
  if (message.result.oneofKind === "updateDialogOrder")
10394
10788
  UpdateDialogOrderResult.internalBinaryWrite(message.result.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10789
+ if (message.result.oneofKind === "clearChatHistory")
10790
+ ClearChatHistoryResult.internalBinaryWrite(message.result.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10791
+ if (message.result.oneofKind === "deleteBot")
10792
+ DeleteBotResult.internalBinaryWrite(message.result.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10793
+ if (message.result.oneofKind === "deleteMessageAttachment")
10794
+ DeleteMessageAttachmentResult.internalBinaryWrite(message.result.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
10395
10795
  let u = options.writeUnknownFields;
10396
10796
  if (u !== false)
10397
10797
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -10577,7 +10977,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10577
10977
  { no: 1, name: "bucket", kind: "message", T: () => UpdateBucket },
10578
10978
  { no: 2, name: "start_seq", kind: "scalar", T: 3, L: 0 },
10579
10979
  { no: 3, name: "total_limit", kind: "scalar", T: 5 },
10580
- { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 }
10980
+ { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 },
10981
+ { no: 5, name: "limit", kind: "scalar", T: 5 }
10581
10982
  ]);
10582
10983
  }
10583
10984
  create(value) {
@@ -10585,6 +10986,7 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10585
10986
  message.startSeq = 0n;
10586
10987
  message.totalLimit = 0;
10587
10988
  message.seqEnd = 0n;
10989
+ message.limit = 0;
10588
10990
  if (value !== undefined)
10589
10991
  import_runtime3.reflectionMergePartial(this, message, value);
10590
10992
  return message;
@@ -10606,6 +11008,9 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10606
11008
  case 4:
10607
11009
  message.seqEnd = reader.int64().toBigInt();
10608
11010
  break;
11011
+ case 5:
11012
+ message.limit = reader.int32();
11013
+ break;
10609
11014
  default:
10610
11015
  let u = options.readUnknownField;
10611
11016
  if (u === "throw")
@@ -10626,6 +11031,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10626
11031
  writer.tag(3, import_runtime.WireType.Varint).int32(message.totalLimit);
10627
11032
  if (message.seqEnd !== 0n)
10628
11033
  writer.tag(4, import_runtime.WireType.Varint).int64(message.seqEnd);
11034
+ if (message.limit !== 0)
11035
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.limit);
10629
11036
  let u = options.writeUnknownFields;
10630
11037
  if (u !== false)
10631
11038
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -11752,6 +12159,191 @@ class ListBotsResult$Type extends import_runtime4.MessageType {
11752
12159
  }
11753
12160
  var ListBotsResult = new ListBotsResult$Type;
11754
12161
 
12162
+ class DeleteBotInput$Type extends import_runtime4.MessageType {
12163
+ constructor() {
12164
+ super("DeleteBotInput", [
12165
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12166
+ ]);
12167
+ }
12168
+ create(value) {
12169
+ const message = globalThis.Object.create(this.messagePrototype);
12170
+ message.botUserId = 0n;
12171
+ if (value !== undefined)
12172
+ import_runtime3.reflectionMergePartial(this, message, value);
12173
+ return message;
12174
+ }
12175
+ internalBinaryRead(reader, length, options, target) {
12176
+ let message = target ?? this.create(), end = reader.pos + length;
12177
+ while (reader.pos < end) {
12178
+ let [fieldNo, wireType] = reader.tag();
12179
+ switch (fieldNo) {
12180
+ case 1:
12181
+ message.botUserId = reader.int64().toBigInt();
12182
+ break;
12183
+ default:
12184
+ let u = options.readUnknownField;
12185
+ if (u === "throw")
12186
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12187
+ let d = reader.skip(wireType);
12188
+ if (u !== false)
12189
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12190
+ }
12191
+ }
12192
+ return message;
12193
+ }
12194
+ internalBinaryWrite(message, writer, options) {
12195
+ if (message.botUserId !== 0n)
12196
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12197
+ let u = options.writeUnknownFields;
12198
+ if (u !== false)
12199
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12200
+ return writer;
12201
+ }
12202
+ }
12203
+ var DeleteBotInput = new DeleteBotInput$Type;
12204
+
12205
+ class DeleteBotResult$Type extends import_runtime4.MessageType {
12206
+ constructor() {
12207
+ super("DeleteBotResult", [
12208
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12209
+ ]);
12210
+ }
12211
+ create(value) {
12212
+ const message = globalThis.Object.create(this.messagePrototype);
12213
+ message.botUserId = 0n;
12214
+ if (value !== undefined)
12215
+ import_runtime3.reflectionMergePartial(this, message, value);
12216
+ return message;
12217
+ }
12218
+ internalBinaryRead(reader, length, options, target) {
12219
+ let message = target ?? this.create(), end = reader.pos + length;
12220
+ while (reader.pos < end) {
12221
+ let [fieldNo, wireType] = reader.tag();
12222
+ switch (fieldNo) {
12223
+ case 1:
12224
+ message.botUserId = reader.int64().toBigInt();
12225
+ break;
12226
+ default:
12227
+ let u = options.readUnknownField;
12228
+ if (u === "throw")
12229
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12230
+ let d = reader.skip(wireType);
12231
+ if (u !== false)
12232
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12233
+ }
12234
+ }
12235
+ return message;
12236
+ }
12237
+ internalBinaryWrite(message, writer, options) {
12238
+ if (message.botUserId !== 0n)
12239
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12240
+ let u = options.writeUnknownFields;
12241
+ if (u !== false)
12242
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12243
+ return writer;
12244
+ }
12245
+ }
12246
+ var DeleteBotResult = new DeleteBotResult$Type;
12247
+
12248
+ class DeleteMessageAttachmentInput$Type extends import_runtime4.MessageType {
12249
+ constructor() {
12250
+ super("DeleteMessageAttachmentInput", [
12251
+ { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
12252
+ { no: 2, name: "message_id", kind: "scalar", T: 3, L: 0 },
12253
+ { no: 3, name: "attachment_id", kind: "scalar", T: 3, L: 0 }
12254
+ ]);
12255
+ }
12256
+ create(value) {
12257
+ const message = globalThis.Object.create(this.messagePrototype);
12258
+ message.messageId = 0n;
12259
+ message.attachmentId = 0n;
12260
+ if (value !== undefined)
12261
+ import_runtime3.reflectionMergePartial(this, message, value);
12262
+ return message;
12263
+ }
12264
+ internalBinaryRead(reader, length, options, target) {
12265
+ let message = target ?? this.create(), end = reader.pos + length;
12266
+ while (reader.pos < end) {
12267
+ let [fieldNo, wireType] = reader.tag();
12268
+ switch (fieldNo) {
12269
+ case 1:
12270
+ message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
12271
+ break;
12272
+ case 2:
12273
+ message.messageId = reader.int64().toBigInt();
12274
+ break;
12275
+ case 3:
12276
+ message.attachmentId = reader.int64().toBigInt();
12277
+ break;
12278
+ default:
12279
+ let u = options.readUnknownField;
12280
+ if (u === "throw")
12281
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12282
+ let d = reader.skip(wireType);
12283
+ if (u !== false)
12284
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12285
+ }
12286
+ }
12287
+ return message;
12288
+ }
12289
+ internalBinaryWrite(message, writer, options) {
12290
+ if (message.peerId)
12291
+ InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12292
+ if (message.messageId !== 0n)
12293
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.messageId);
12294
+ if (message.attachmentId !== 0n)
12295
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.attachmentId);
12296
+ let u = options.writeUnknownFields;
12297
+ if (u !== false)
12298
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12299
+ return writer;
12300
+ }
12301
+ }
12302
+ var DeleteMessageAttachmentInput = new DeleteMessageAttachmentInput$Type;
12303
+
12304
+ class DeleteMessageAttachmentResult$Type extends import_runtime4.MessageType {
12305
+ constructor() {
12306
+ super("DeleteMessageAttachmentResult", [
12307
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
12308
+ ]);
12309
+ }
12310
+ create(value) {
12311
+ const message = globalThis.Object.create(this.messagePrototype);
12312
+ message.updates = [];
12313
+ if (value !== undefined)
12314
+ import_runtime3.reflectionMergePartial(this, message, value);
12315
+ return message;
12316
+ }
12317
+ internalBinaryRead(reader, length, options, target) {
12318
+ let message = target ?? this.create(), end = reader.pos + length;
12319
+ while (reader.pos < end) {
12320
+ let [fieldNo, wireType] = reader.tag();
12321
+ switch (fieldNo) {
12322
+ case 1:
12323
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
12324
+ break;
12325
+ default:
12326
+ let u = options.readUnknownField;
12327
+ if (u === "throw")
12328
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12329
+ let d = reader.skip(wireType);
12330
+ if (u !== false)
12331
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12332
+ }
12333
+ }
12334
+ return message;
12335
+ }
12336
+ internalBinaryWrite(message, writer, options) {
12337
+ for (let i = 0;i < message.updates.length; i++)
12338
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12339
+ let u = options.writeUnknownFields;
12340
+ if (u !== false)
12341
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12342
+ return writer;
12343
+ }
12344
+ }
12345
+ var DeleteMessageAttachmentResult = new DeleteMessageAttachmentResult$Type;
12346
+
11755
12347
  class RevokeSessionInput$Type extends import_runtime4.MessageType {
11756
12348
  constructor() {
11757
12349
  super("RevokeSessionInput", [
@@ -13768,6 +14360,118 @@ class DeleteMessagesResult$Type extends import_runtime4.MessageType {
13768
14360
  }
13769
14361
  var DeleteMessagesResult = new DeleteMessagesResult$Type;
13770
14362
 
14363
+ class ClearChatHistoryInput$Type extends import_runtime4.MessageType {
14364
+ constructor() {
14365
+ super("ClearChatHistoryInput", [
14366
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => InputPeer },
14367
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
14368
+ { no: 2, name: "keep_last_days", kind: "scalar", T: 5 },
14369
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 }
14370
+ ]);
14371
+ }
14372
+ create(value) {
14373
+ const message = globalThis.Object.create(this.messagePrototype);
14374
+ message.target = { oneofKind: undefined };
14375
+ message.keepLastDays = 0;
14376
+ message.deleteReplyThreads = false;
14377
+ if (value !== undefined)
14378
+ import_runtime3.reflectionMergePartial(this, message, value);
14379
+ return message;
14380
+ }
14381
+ internalBinaryRead(reader, length, options, target) {
14382
+ let message = target ?? this.create(), end = reader.pos + length;
14383
+ while (reader.pos < end) {
14384
+ let [fieldNo, wireType] = reader.tag();
14385
+ switch (fieldNo) {
14386
+ case 1:
14387
+ message.target = {
14388
+ oneofKind: "peerId",
14389
+ peerId: InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
14390
+ };
14391
+ break;
14392
+ case 4:
14393
+ message.target = {
14394
+ oneofKind: "spaceId",
14395
+ spaceId: reader.int64().toBigInt()
14396
+ };
14397
+ break;
14398
+ case 2:
14399
+ message.keepLastDays = reader.int32();
14400
+ break;
14401
+ case 3:
14402
+ message.deleteReplyThreads = reader.bool();
14403
+ break;
14404
+ default:
14405
+ let u = options.readUnknownField;
14406
+ if (u === "throw")
14407
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14408
+ let d = reader.skip(wireType);
14409
+ if (u !== false)
14410
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14411
+ }
14412
+ }
14413
+ return message;
14414
+ }
14415
+ internalBinaryWrite(message, writer, options) {
14416
+ if (message.target.oneofKind === "peerId")
14417
+ InputPeer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14418
+ if (message.target.oneofKind === "spaceId")
14419
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
14420
+ if (message.keepLastDays !== 0)
14421
+ writer.tag(2, import_runtime.WireType.Varint).int32(message.keepLastDays);
14422
+ if (message.deleteReplyThreads !== false)
14423
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
14424
+ let u = options.writeUnknownFields;
14425
+ if (u !== false)
14426
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14427
+ return writer;
14428
+ }
14429
+ }
14430
+ var ClearChatHistoryInput = new ClearChatHistoryInput$Type;
14431
+
14432
+ class ClearChatHistoryResult$Type extends import_runtime4.MessageType {
14433
+ constructor() {
14434
+ super("ClearChatHistoryResult", [
14435
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
14436
+ ]);
14437
+ }
14438
+ create(value) {
14439
+ const message = globalThis.Object.create(this.messagePrototype);
14440
+ message.updates = [];
14441
+ if (value !== undefined)
14442
+ import_runtime3.reflectionMergePartial(this, message, value);
14443
+ return message;
14444
+ }
14445
+ internalBinaryRead(reader, length, options, target) {
14446
+ let message = target ?? this.create(), end = reader.pos + length;
14447
+ while (reader.pos < end) {
14448
+ let [fieldNo, wireType] = reader.tag();
14449
+ switch (fieldNo) {
14450
+ case 1:
14451
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
14452
+ break;
14453
+ default:
14454
+ let u = options.readUnknownField;
14455
+ if (u === "throw")
14456
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14457
+ let d = reader.skip(wireType);
14458
+ if (u !== false)
14459
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14460
+ }
14461
+ }
14462
+ return message;
14463
+ }
14464
+ internalBinaryWrite(message, writer, options) {
14465
+ for (let i = 0;i < message.updates.length; i++)
14466
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14467
+ let u = options.writeUnknownFields;
14468
+ if (u !== false)
14469
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14470
+ return writer;
14471
+ }
14472
+ }
14473
+ var ClearChatHistoryResult = new ClearChatHistoryResult$Type;
14474
+
13771
14475
  class EditMessageInput$Type extends import_runtime4.MessageType {
13772
14476
  constructor() {
13773
14477
  super("EditMessageInput", [
@@ -15509,7 +16213,8 @@ class Update$Type extends import_runtime4.MessageType {
15509
16213
  { no: 33, name: "dialog_notification_settings", kind: "message", oneof: "update", T: () => UpdateDialogNotificationSettings },
15510
16214
  { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen },
15511
16215
  { 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 }
16216
+ { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered },
16217
+ { no: 37, name: "clear_chat_history", kind: "message", oneof: "update", T: () => UpdateClearChatHistory }
15513
16218
  ]);
15514
16219
  }
15515
16220
  create(value) {
@@ -15728,6 +16433,12 @@ class Update$Type extends import_runtime4.MessageType {
15728
16433
  messageActionAnswered: UpdateMessageActionAnswered.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionAnswered)
15729
16434
  };
15730
16435
  break;
16436
+ case 37:
16437
+ message.update = {
16438
+ oneofKind: "clearChatHistory",
16439
+ clearChatHistory: UpdateClearChatHistory.internalBinaryRead(reader, reader.uint32(), options, message.update.clearChatHistory)
16440
+ };
16441
+ break;
15731
16442
  default:
15732
16443
  let u = options.readUnknownField;
15733
16444
  if (u === "throw")
@@ -15810,6 +16521,8 @@ class Update$Type extends import_runtime4.MessageType {
15810
16521
  UpdateMessageActionInvoked.internalBinaryWrite(message.update.messageActionInvoked, writer.tag(35, import_runtime.WireType.LengthDelimited).fork(), options).join();
15811
16522
  if (message.update.oneofKind === "messageActionAnswered")
15812
16523
  UpdateMessageActionAnswered.internalBinaryWrite(message.update.messageActionAnswered, writer.tag(36, import_runtime.WireType.LengthDelimited).fork(), options).join();
16524
+ if (message.update.oneofKind === "clearChatHistory")
16525
+ UpdateClearChatHistory.internalBinaryWrite(message.update.clearChatHistory, writer.tag(37, import_runtime.WireType.LengthDelimited).fork(), options).join();
15813
16526
  let u = options.writeUnknownFields;
15814
16527
  if (u !== false)
15815
16528
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -17076,6 +17789,119 @@ class UpdateDeleteMessages$Type extends import_runtime4.MessageType {
17076
17789
  }
17077
17790
  var UpdateDeleteMessages = new UpdateDeleteMessages$Type;
17078
17791
 
17792
+ class UpdateClearChatHistory$Type extends import_runtime4.MessageType {
17793
+ constructor() {
17794
+ super("UpdateClearChatHistory", [
17795
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => Peer },
17796
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
17797
+ { no: 2, name: "before_date", kind: "scalar", opt: true, T: 3, L: 0 },
17798
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 },
17799
+ { no: 5, name: "deleted_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17800
+ { no: 6, name: "orphaned_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17801
+ { no: 7, name: "detached_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 }
17802
+ ]);
17803
+ }
17804
+ create(value) {
17805
+ const message = globalThis.Object.create(this.messagePrototype);
17806
+ message.target = { oneofKind: undefined };
17807
+ message.deleteReplyThreads = false;
17808
+ message.deletedChatIds = [];
17809
+ message.orphanedChatIds = [];
17810
+ message.detachedChatIds = [];
17811
+ if (value !== undefined)
17812
+ import_runtime3.reflectionMergePartial(this, message, value);
17813
+ return message;
17814
+ }
17815
+ internalBinaryRead(reader, length, options, target) {
17816
+ let message = target ?? this.create(), end = reader.pos + length;
17817
+ while (reader.pos < end) {
17818
+ let [fieldNo, wireType] = reader.tag();
17819
+ switch (fieldNo) {
17820
+ case 1:
17821
+ message.target = {
17822
+ oneofKind: "peerId",
17823
+ peerId: Peer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
17824
+ };
17825
+ break;
17826
+ case 4:
17827
+ message.target = {
17828
+ oneofKind: "spaceId",
17829
+ spaceId: reader.int64().toBigInt()
17830
+ };
17831
+ break;
17832
+ case 2:
17833
+ message.beforeDate = reader.int64().toBigInt();
17834
+ break;
17835
+ case 3:
17836
+ message.deleteReplyThreads = reader.bool();
17837
+ break;
17838
+ case 5:
17839
+ if (wireType === import_runtime.WireType.LengthDelimited)
17840
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17841
+ message.deletedChatIds.push(reader.int64().toBigInt());
17842
+ else
17843
+ message.deletedChatIds.push(reader.int64().toBigInt());
17844
+ break;
17845
+ case 6:
17846
+ if (wireType === import_runtime.WireType.LengthDelimited)
17847
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17848
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17849
+ else
17850
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17851
+ break;
17852
+ case 7:
17853
+ if (wireType === import_runtime.WireType.LengthDelimited)
17854
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17855
+ message.detachedChatIds.push(reader.int64().toBigInt());
17856
+ else
17857
+ message.detachedChatIds.push(reader.int64().toBigInt());
17858
+ break;
17859
+ default:
17860
+ let u = options.readUnknownField;
17861
+ if (u === "throw")
17862
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
17863
+ let d = reader.skip(wireType);
17864
+ if (u !== false)
17865
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
17866
+ }
17867
+ }
17868
+ return message;
17869
+ }
17870
+ internalBinaryWrite(message, writer, options) {
17871
+ if (message.target.oneofKind === "peerId")
17872
+ Peer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
17873
+ if (message.target.oneofKind === "spaceId")
17874
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
17875
+ if (message.beforeDate !== undefined)
17876
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.beforeDate);
17877
+ if (message.deleteReplyThreads !== false)
17878
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
17879
+ if (message.deletedChatIds.length) {
17880
+ writer.tag(5, import_runtime.WireType.LengthDelimited).fork();
17881
+ for (let i = 0;i < message.deletedChatIds.length; i++)
17882
+ writer.int64(message.deletedChatIds[i]);
17883
+ writer.join();
17884
+ }
17885
+ if (message.orphanedChatIds.length) {
17886
+ writer.tag(6, import_runtime.WireType.LengthDelimited).fork();
17887
+ for (let i = 0;i < message.orphanedChatIds.length; i++)
17888
+ writer.int64(message.orphanedChatIds[i]);
17889
+ writer.join();
17890
+ }
17891
+ if (message.detachedChatIds.length) {
17892
+ writer.tag(7, import_runtime.WireType.LengthDelimited).fork();
17893
+ for (let i = 0;i < message.detachedChatIds.length; i++)
17894
+ writer.int64(message.detachedChatIds[i]);
17895
+ writer.join();
17896
+ }
17897
+ let u = options.writeUnknownFields;
17898
+ if (u !== false)
17899
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
17900
+ return writer;
17901
+ }
17902
+ }
17903
+ var UpdateClearChatHistory = new UpdateClearChatHistory$Type;
17904
+
17079
17905
  class UpdateMessageId$Type extends import_runtime4.MessageType {
17080
17906
  constructor() {
17081
17907
  super("UpdateMessageId", [
@@ -19216,7 +20042,7 @@ function describeConnectionError(error) {
19216
20042
  return `server connection error${code != null ? ` (code=${code})` : ""}: ${message}`;
19217
20043
  }
19218
20044
 
19219
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/wrapper.mjs
20045
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/wrapper.mjs
19220
20046
  var import_stream = __toESM(require_stream(), 1);
19221
20047
  var import_extension = __toESM(require_extension(), 1);
19222
20048
  var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
@@ -19510,7 +20336,8 @@ var rpcInputKindByMethod = {
19510
20336
  37: "updateBotProfile",
19511
20337
  38: "getMessages",
19512
20338
  48: "invokeMessageAction",
19513
- 49: "answerMessageAction"
20339
+ 49: "answerMessageAction",
20340
+ 53: "clearChatHistory"
19514
20341
  };
19515
20342
  var rpcResultKindByMethod = {
19516
20343
  0: undefined,
@@ -19553,7 +20380,8 @@ var rpcResultKindByMethod = {
19553
20380
  37: "updateBotProfile",
19554
20381
  38: "getMessages",
19555
20382
  48: "invokeMessageAction",
19556
- 49: "answerMessageAction"
20383
+ 49: "answerMessageAction",
20384
+ 53: "clearChatHistory"
19557
20385
  };
19558
20386
 
19559
20387
  // ../sdk/dist/sdk/logger.js
@@ -19590,6 +20418,7 @@ var defaultApiBaseUrl = "https://api.inline.chat";
19590
20418
  var defaultVideoWidth = 1280;
19591
20419
  var defaultVideoHeight = 720;
19592
20420
  var defaultVideoDuration = 1;
20421
+ var defaultCatchUpPageLimit = 200;
19593
20422
  var defaultCatchUpTotalLimit = 1000;
19594
20423
  var defaultColdStartCatchUpWindow = defaultCatchUpTotalLimit;
19595
20424
  function extractFirstMessageId(updates) {
@@ -19728,7 +20557,12 @@ class InlineSdkClient {
19728
20557
  const chat = result.getChat.chat;
19729
20558
  if (!chat)
19730
20559
  throw new Error("getChat: missing chat");
19731
- return { chatId: chat.id, peer: chat.peerId, title: chat.title };
20560
+ return {
20561
+ chatId: chat.id,
20562
+ peer: chat.peerId,
20563
+ title: chat.title,
20564
+ ...chat.lastMsgId != null ? { lastMsgId: chat.lastMsgId } : {}
20565
+ };
19732
20566
  }
19733
20567
  async getMessages(params) {
19734
20568
  const peerId = this.inputPeerFromTarget(params, "getMessages");
@@ -19742,6 +20576,18 @@ class InlineSdkClient {
19742
20576
  });
19743
20577
  return { messages: result.getMessages.messages };
19744
20578
  }
20579
+ async clearChatHistory(params) {
20580
+ const keepLastDays = normalizeKeepLastDays(params.keepLastDays);
20581
+ const target = this.clearHistoryTargetFromParams(params);
20582
+ await this.invoke(Method.CLEAR_CHAT_HISTORY, {
20583
+ oneofKind: "clearChatHistory",
20584
+ clearChatHistory: {
20585
+ target,
20586
+ keepLastDays,
20587
+ deleteReplyThreads: params.deleteReplyThreads ?? false
20588
+ }
20589
+ });
20590
+ }
19745
20591
  async sendMessage(params) {
19746
20592
  if (params.entities != null && params.parseMarkdown != null) {
19747
20593
  throw new Error("sendMessage: provide either `entities` or `parseMarkdown`, not both");
@@ -20043,6 +20889,36 @@ class InlineSdkClient {
20043
20889
  });
20044
20890
  return;
20045
20891
  }
20892
+ case "clearChatHistory": {
20893
+ const payload = update.update.clearChatHistory;
20894
+ if (payload.target.oneofKind === "spaceId") {
20895
+ await this.eventStream.send({
20896
+ kind: "space.history.clear",
20897
+ spaceId: payload.target.spaceId,
20898
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
20899
+ deleteReplyThreads: payload.deleteReplyThreads,
20900
+ seq,
20901
+ date
20902
+ });
20903
+ return;
20904
+ }
20905
+ const peerId = payload.target.oneofKind === "peerId" ? payload.target.peerId : undefined;
20906
+ const chatId = peerId?.type.oneofKind === "chat" ? peerId.type.chat.chatId : null;
20907
+ if (!chatId) {
20908
+ this.log.warn?.("Skipping clearChatHistory update without chat peer", peerId);
20909
+ return;
20910
+ }
20911
+ this.bumpChatSeq(chatId, seq);
20912
+ await this.eventStream.send({
20913
+ kind: "message.history.clear",
20914
+ chatId,
20915
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
20916
+ deleteReplyThreads: payload.deleteReplyThreads,
20917
+ seq,
20918
+ date
20919
+ });
20920
+ return;
20921
+ }
20046
20922
  case "updateReaction": {
20047
20923
  const reaction = update.update.updateReaction.reaction;
20048
20924
  if (!reaction)
@@ -20186,7 +21062,8 @@ class InlineSdkClient {
20186
21062
  }
20187
21063
  }),
20188
21064
  startSeq: BigInt(cursor),
20189
- totalLimit: defaultCatchUpTotalLimit
21065
+ totalLimit: defaultCatchUpTotalLimit,
21066
+ limit: defaultCatchUpPageLimit
20190
21067
  })
20191
21068
  });
20192
21069
  const payload = result.getUpdates;
@@ -20283,7 +21160,8 @@ class InlineSdkClient {
20283
21160
  }),
20284
21161
  startSeq: BigInt(cursor),
20285
21162
  seqEnd: BigInt(endSeq),
20286
- totalLimit: defaultCatchUpTotalLimit
21163
+ totalLimit: defaultCatchUpTotalLimit,
21164
+ limit: defaultCatchUpPageLimit
20287
21165
  })
20288
21166
  });
20289
21167
  const payload = result.getUpdates;
@@ -20347,6 +21225,18 @@ class InlineSdkClient {
20347
21225
  type: { oneofKind: "chat", chat: { chatId: asInlineId(params.chatId, "chatId") } }
20348
21226
  });
20349
21227
  }
21228
+ clearHistoryTargetFromParams(params) {
21229
+ const hasChatId = params.chatId != null;
21230
+ const hasUserId = params.userId != null;
21231
+ const hasSpaceId = params.spaceId != null;
21232
+ if ([hasChatId, hasUserId, hasSpaceId].filter(Boolean).length !== 1) {
21233
+ throw new Error("clearChatHistory: provide exactly one of `chatId`, `userId`, or `spaceId`");
21234
+ }
21235
+ if (hasSpaceId) {
21236
+ return { oneofKind: "spaceId", spaceId: asInlineId(params.spaceId, "spaceId") };
21237
+ }
21238
+ return { oneofKind: "peerId", peerId: this.inputPeerFromTarget(params, "clearChatHistory") };
21239
+ }
20350
21240
  async loadState() {
20351
21241
  const store = this.options.state;
20352
21242
  if (!store)
@@ -20523,6 +21413,12 @@ function normalizePositiveInt(value, field) {
20523
21413
  }
20524
21414
  return value;
20525
21415
  }
21416
+ function normalizeKeepLastDays(value) {
21417
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > 36500) {
21418
+ throw new Error("clearChatHistory: `keepLastDays` must be 0 or a positive integer up to 36500");
21419
+ }
21420
+ return value;
21421
+ }
20526
21422
  async function parseJsonResponse(response) {
20527
21423
  const contentType = response.headers.get("content-type") ?? "";
20528
21424
  if (!contentType.includes("application/json")) {
@@ -35176,10 +36072,15 @@ var InlineActionsSchema = exports_external.object({
35176
36072
  var InlineCapabilitiesSchema = exports_external.object({
35177
36073
  replyThreads: exports_external.boolean().optional()
35178
36074
  }).strict();
36075
+ var InlineReplyThreadModeSchema = exports_external.enum(["auto", "thread", "main"]);
35179
36076
  var InlineTargetSchema = exports_external.union([exports_external.string(), exports_external.number()]);
35180
36077
  var InlineAllowEntrySchema = exports_external.union([exports_external.string(), exports_external.number()]);
35181
36078
  var InlineGroupSchema = exports_external.object({
35182
36079
  requireMention: exports_external.boolean().optional(),
36080
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36081
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36082
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36083
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35183
36084
  allowFrom: exports_external.array(InlineAllowEntrySchema).optional(),
35184
36085
  systemPrompt: exports_external.string().optional(),
35185
36086
  tools: ToolPolicySchema.optional(),
@@ -35219,6 +36120,7 @@ var InlineStreamingSchema = exports_external.union([
35219
36120
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35220
36121
  labels: exports_external.array(exports_external.string()).optional(),
35221
36122
  maxLines: exports_external.number().int().positive().optional(),
36123
+ maxLineChars: exports_external.number().int().positive().optional(),
35222
36124
  render: exports_external.enum(["text", "rich"]).optional(),
35223
36125
  toolProgress: exports_external.boolean().optional(),
35224
36126
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35246,6 +36148,7 @@ var InlineRuntimeStreamingSchema = exports_external.union([
35246
36148
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35247
36149
  labels: exports_external.array(exports_external.string()).optional(),
35248
36150
  maxLines: exports_external.number().int().positive().optional(),
36151
+ maxLineChars: exports_external.number().int().positive().optional(),
35249
36152
  render: exports_external.enum(["text", "rich"]).optional(),
35250
36153
  toolProgress: exports_external.boolean().optional(),
35251
36154
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35271,6 +36174,10 @@ var InlineAccountSchemaBase = exports_external.object({
35271
36174
  groupPolicy: GroupPolicySchema.optional().default("allowlist"),
35272
36175
  groups: exports_external.record(exports_external.string(), InlineGroupSchema.optional()).optional(),
35273
36176
  requireMention: exports_external.boolean().optional(),
36177
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36178
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36179
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36180
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35274
36181
  replyToBotWithoutMention: exports_external.boolean().optional(),
35275
36182
  historyLimit: exports_external.number().int().min(0).optional(),
35276
36183
  dmHistoryLimit: exports_external.number().int().min(0).optional(),
@@ -35542,9 +36449,7 @@ function inspectInlineAccount(params) {
35542
36449
  }
35543
36450
  const tokenFile = account.tokenFile?.trim() ?? "";
35544
36451
  if (tokenFile) {
35545
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35546
- rejectSymlink: true
35547
- }) ?? "";
36452
+ const token = tryReadInlineTokenFile(tokenFile);
35548
36453
  return {
35549
36454
  ...account,
35550
36455
  token: token || null,
@@ -35604,37 +36509,30 @@ async function resolveInlineToken(account) {
35604
36509
  }
35605
36510
  throw new Error("Inline token missing (set channels.inline.token, channels.inline.tokenFile, INLINE_TOKEN, or INLINE_BOT_TOKEN)");
35606
36511
  }
35607
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35608
- rejectSymlink: true
35609
- });
36512
+ const token = readInlineTokenFile(tokenFile);
35610
36513
  if (!token)
35611
36514
  throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`);
35612
36515
  return token;
35613
36516
  }
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]}`;
36517
+ function tryReadInlineTokenFile(tokenFile) {
36518
+ try {
36519
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36520
+ rejectSymlink: true
36521
+ }) ?? "";
36522
+ } catch {
36523
+ return "";
35627
36524
  }
35628
- normalized = normalized.replace(/^chat:/i, "").trim();
35629
- return normalized || undefined;
35630
36525
  }
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);
36526
+ function readInlineTokenFile(tokenFile) {
36527
+ try {
36528
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36529
+ rejectSymlink: true
36530
+ }) ?? "";
36531
+ } catch (error51) {
36532
+ throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`, {
36533
+ cause: error51
36534
+ });
36535
+ }
35638
36536
  }
35639
36537
 
35640
36538
  // src/inline/outbound-sanitize.ts
@@ -35877,6 +36775,135 @@ function sanitizeInlineActionCallbackData(raw) {
35877
36775
  return text;
35878
36776
  }
35879
36777
 
36778
+ // src/inline/normalize.ts
36779
+ function normalizeInlineTarget(raw) {
36780
+ let normalized = raw.trim();
36781
+ if (!normalized)
36782
+ return;
36783
+ const lowered = normalized.toLowerCase();
36784
+ if (lowered.startsWith("inline:")) {
36785
+ normalized = normalized.slice("inline:".length).trim();
36786
+ }
36787
+ const userMatch = normalized.match(/^user:\s*([0-9]+)\s*$/i);
36788
+ if (userMatch?.[1]) {
36789
+ return `user:${userMatch[1]}`;
36790
+ }
36791
+ normalized = normalized.replace(/^chat:/i, "").trim();
36792
+ return normalized || undefined;
36793
+ }
36794
+ function looksLikeInlineTargetId(raw, normalizedInput) {
36795
+ const normalized = normalizedInput?.trim() || normalizeInlineTarget(raw);
36796
+ if (!normalized)
36797
+ return false;
36798
+ if (/^user:[0-9]+$/i.test(normalized))
36799
+ return true;
36800
+ return /^[0-9]+$/.test(normalized);
36801
+ }
36802
+
36803
+ // src/inline/tool-targets.ts
36804
+ function parseInlineId(raw, label) {
36805
+ if (typeof raw === "bigint") {
36806
+ if (raw < 0n)
36807
+ throw new Error(`inline tool: invalid ${label} "${raw.toString()}"`);
36808
+ return raw;
36809
+ }
36810
+ if (typeof raw === "number") {
36811
+ if (!Number.isFinite(raw) || !Number.isInteger(raw) || raw < 0) {
36812
+ throw new Error(`inline tool: invalid ${label} "${String(raw)}"`);
36813
+ }
36814
+ return BigInt(raw);
36815
+ }
36816
+ if (typeof raw === "string") {
36817
+ const trimmed = raw.trim();
36818
+ if (!trimmed)
36819
+ throw new Error(`inline tool: missing ${label}`);
36820
+ if (!/^[0-9]+$/.test(trimmed))
36821
+ throw new Error(`inline tool: invalid ${label} "${raw}"`);
36822
+ return BigInt(trimmed);
36823
+ }
36824
+ throw new Error(`inline tool: missing ${label}`);
36825
+ }
36826
+ function parseOptionalInlineId(raw, label) {
36827
+ if (raw == null)
36828
+ return null;
36829
+ if (typeof raw === "string" && !raw.trim())
36830
+ return null;
36831
+ return parseInlineId(raw, label);
36832
+ }
36833
+ function parseInlineTarget(raw, label) {
36834
+ const normalized = normalizeInlineTarget(raw) ?? raw.trim();
36835
+ const userMatch = normalized.match(/^user:([0-9]+)$/i);
36836
+ if (userMatch?.[1]) {
36837
+ return {
36838
+ normalized: `user:${userMatch[1]}`,
36839
+ peerId: {
36840
+ type: {
36841
+ oneofKind: "user",
36842
+ user: { userId: BigInt(userMatch[1]) }
36843
+ }
36844
+ }
36845
+ };
36846
+ }
36847
+ if (!/^[0-9]+$/.test(normalized)) {
36848
+ throw new Error(`inline tool: invalid ${label} "${raw}"`);
36849
+ }
36850
+ return {
36851
+ normalized,
36852
+ peerId: {
36853
+ type: {
36854
+ oneofKind: "chat",
36855
+ chat: { chatId: BigInt(normalized) }
36856
+ }
36857
+ }
36858
+ };
36859
+ }
36860
+ function parseCurrentInlineSession(ctx) {
36861
+ if ((ctx.messageChannel ?? "").trim().toLowerCase() !== "inline")
36862
+ return null;
36863
+ const sessionKey = ctx.sessionKey?.trim();
36864
+ if (!sessionKey)
36865
+ return null;
36866
+ const explicitMatch = sessionKey.match(/^agent:[^:]+:inline:(chat|group|user|direct):([0-9]+)(?::thread:([0-9]+))?$/i);
36867
+ if (explicitMatch?.[1] && explicitMatch[2]) {
36868
+ const kind = explicitMatch[1].toLowerCase();
36869
+ const threadId = explicitMatch[3];
36870
+ if ((kind === "chat" || kind === "group") && threadId) {
36871
+ return {
36872
+ target: parseInlineTarget(threadId, "current chat"),
36873
+ parentChatId: parseInlineId(explicitMatch[2], "current parent chat"),
36874
+ threadId: parseInlineId(threadId, "current thread")
36875
+ };
36876
+ }
36877
+ return {
36878
+ target: parseInlineTarget(kind === "user" || kind === "direct" ? `user:${explicitMatch[2]}` : explicitMatch[2], "current chat"),
36879
+ parentChatId: null,
36880
+ threadId: null
36881
+ };
36882
+ }
36883
+ const legacyMatch = sessionKey.match(/^agent:[^:]+:inline:([0-9]+)(?::thread:([0-9]+))?$/i);
36884
+ if (legacyMatch?.[1]) {
36885
+ return {
36886
+ target: parseInlineTarget(legacyMatch[2] ?? legacyMatch[1], "current chat"),
36887
+ parentChatId: legacyMatch[2] ? parseInlineId(legacyMatch[1], "current parent chat") : null,
36888
+ threadId: legacyMatch[2] ? parseInlineId(legacyMatch[2], "current thread") : null
36889
+ };
36890
+ }
36891
+ return null;
36892
+ }
36893
+ function parseCurrentInlineTarget(ctx) {
36894
+ return parseCurrentInlineSession(ctx)?.target ?? null;
36895
+ }
36896
+ function readStringCandidate(...values) {
36897
+ for (const value of values) {
36898
+ if (typeof value !== "string")
36899
+ continue;
36900
+ const trimmed = value.trim();
36901
+ if (trimmed)
36902
+ return trimmed;
36903
+ }
36904
+ return;
36905
+ }
36906
+
35880
36907
  // src/inline/message-tools.ts
35881
36908
  var InlineNudgeToolParameters = {
35882
36909
  type: "object",
@@ -35978,87 +37005,6 @@ var InlineForwardToolParameters = {
35978
37005
  },
35979
37006
  required: ["to"]
35980
37007
  };
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
37008
  function resolvePeerTarget(params) {
36063
37009
  if (params.direct) {
36064
37010
  return {
@@ -36456,6 +37402,715 @@ function createInlineMembersTool(ctx) {
36456
37402
  };
36457
37403
  }
36458
37404
 
37405
+ // src/inline/message-content.ts
37406
+ var INLINE_MESSAGE_ENTITY_TYPE = {
37407
+ MENTION: 1,
37408
+ URL: 2,
37409
+ TEXT_URL: 3,
37410
+ EMAIL: 4,
37411
+ BOLD: 5,
37412
+ ITALIC: 6,
37413
+ USERNAME_MENTION: 7,
37414
+ CODE: 8,
37415
+ PRE: 9,
37416
+ PHONE_NUMBER: 10
37417
+ };
37418
+ function compactWhitespace(raw) {
37419
+ return (raw ?? "").replace(/\s+/g, " ").trim();
37420
+ }
37421
+ function bestPhotoSize(photo) {
37422
+ let best = {
37423
+ cdnUrl: null,
37424
+ width: null,
37425
+ height: null,
37426
+ sizeBytes: null
37427
+ };
37428
+ let bestArea = -1;
37429
+ for (const size of photo.sizes ?? []) {
37430
+ const width = typeof size.w === "number" ? size.w : null;
37431
+ const height = typeof size.h === "number" ? size.h : null;
37432
+ const area = Math.max(0, width ?? 0) * Math.max(0, height ?? 0);
37433
+ if (size.cdnUrl && area >= bestArea) {
37434
+ bestArea = area;
37435
+ best = {
37436
+ cdnUrl: size.cdnUrl,
37437
+ width,
37438
+ height,
37439
+ sizeBytes: typeof size.size === "number" ? size.size : null
37440
+ };
37441
+ }
37442
+ }
37443
+ return best;
37444
+ }
37445
+ function messageMediaSummary(message) {
37446
+ const mediaContainer = message.media;
37447
+ 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;
37448
+ if (!media)
37449
+ return null;
37450
+ if (media.oneofKind === "photo") {
37451
+ const photo = media.photo?.photo;
37452
+ const bestSize = photo ? bestPhotoSize(photo) : { cdnUrl: null, width: null, height: null, sizeBytes: null };
37453
+ return {
37454
+ kind: "photo",
37455
+ id: photo?.id?.toString() ?? null,
37456
+ url: bestSize.cdnUrl,
37457
+ sizeBytes: bestSize.sizeBytes,
37458
+ width: bestSize.width,
37459
+ height: bestSize.height
37460
+ };
37461
+ }
37462
+ if (media.oneofKind === "video") {
37463
+ const video = media.video?.video;
37464
+ return {
37465
+ kind: "video",
37466
+ id: video?.id?.toString() ?? null,
37467
+ url: video?.cdnUrl ?? null,
37468
+ sizeBytes: video?.size ?? null,
37469
+ width: video?.w ?? null,
37470
+ height: video?.h ?? null,
37471
+ durationSeconds: video?.duration ?? null
37472
+ };
37473
+ }
37474
+ if (media.oneofKind === "document") {
37475
+ const document = media.document?.document;
37476
+ return {
37477
+ kind: "document",
37478
+ id: document?.id?.toString() ?? null,
37479
+ url: document?.cdnUrl ?? null,
37480
+ fileName: document?.fileName ?? null,
37481
+ mimeType: document?.mimeType ?? null,
37482
+ sizeBytes: document?.size ?? null
37483
+ };
37484
+ }
37485
+ if (media.oneofKind === "voice") {
37486
+ const voice = media.voice?.voice;
37487
+ return {
37488
+ kind: "voice",
37489
+ id: voice?.id?.toString() ?? null,
37490
+ url: voice?.cdnUrl ?? null,
37491
+ mimeType: voice?.mimeType ?? null,
37492
+ sizeBytes: voice?.size ?? null,
37493
+ durationSeconds: voice?.duration ?? null
37494
+ };
37495
+ }
37496
+ return {
37497
+ kind: "nudge",
37498
+ id: null,
37499
+ url: null
37500
+ };
37501
+ }
37502
+ function messageAttachmentSummaries(message) {
37503
+ const attachments = [];
37504
+ for (const item of message.attachments?.attachments ?? []) {
37505
+ if (item.attachment.oneofKind === "urlPreview") {
37506
+ const preview = item.attachment.urlPreview;
37507
+ const previewPhoto = preview.photo ? bestPhotoSize(preview.photo).cdnUrl : null;
37508
+ attachments.push({
37509
+ kind: "urlPreview",
37510
+ id: preview.id?.toString() ?? null,
37511
+ url: preview.url ?? null,
37512
+ siteName: preview.siteName ?? null,
37513
+ title: preview.title ?? null,
37514
+ description: preview.description ?? null,
37515
+ previewImageUrl: previewPhoto
37516
+ });
37517
+ continue;
37518
+ }
37519
+ if (item.attachment.oneofKind === "externalTask") {
37520
+ const task = item.attachment.externalTask;
37521
+ attachments.push({
37522
+ kind: "externalTask",
37523
+ id: task.id?.toString() ?? null,
37524
+ url: task.url ?? null,
37525
+ application: task.application ?? null,
37526
+ title: task.title ?? null,
37527
+ taskId: task.taskId ?? null,
37528
+ number: task.number ?? null
37529
+ });
37530
+ }
37531
+ }
37532
+ return attachments;
37533
+ }
37534
+ function extractMessageUrls(message, attachments) {
37535
+ const urls = new Set;
37536
+ for (const entity of message.entities?.entities ?? []) {
37537
+ if (entity.type !== INLINE_MESSAGE_ENTITY_TYPE.URL && entity.type !== INLINE_MESSAGE_ENTITY_TYPE.TEXT_URL)
37538
+ continue;
37539
+ if (entity.entity.oneofKind === "textUrl") {
37540
+ const candidate2 = entity.entity.textUrl.url?.trim();
37541
+ if (candidate2)
37542
+ urls.add(candidate2);
37543
+ continue;
37544
+ }
37545
+ if (typeof message.message !== "string")
37546
+ continue;
37547
+ const offset = Number(entity.offset);
37548
+ const length = Number(entity.length);
37549
+ if (!Number.isFinite(offset) || !Number.isFinite(length) || offset < 0 || length <= 0)
37550
+ continue;
37551
+ const candidate = message.message.slice(offset, offset + length).trim();
37552
+ if (candidate)
37553
+ urls.add(candidate);
37554
+ }
37555
+ for (const attachment of attachments) {
37556
+ const candidate = attachment.url?.trim();
37557
+ if (candidate)
37558
+ urls.add(candidate);
37559
+ }
37560
+ return Array.from(urls);
37561
+ }
37562
+ function mapEntityType(type) {
37563
+ switch (type) {
37564
+ case INLINE_MESSAGE_ENTITY_TYPE.MENTION:
37565
+ return "mention";
37566
+ case INLINE_MESSAGE_ENTITY_TYPE.URL:
37567
+ return "url";
37568
+ case INLINE_MESSAGE_ENTITY_TYPE.TEXT_URL:
37569
+ return "text_link";
37570
+ case INLINE_MESSAGE_ENTITY_TYPE.EMAIL:
37571
+ return "email";
37572
+ case INLINE_MESSAGE_ENTITY_TYPE.BOLD:
37573
+ return "bold";
37574
+ case INLINE_MESSAGE_ENTITY_TYPE.ITALIC:
37575
+ return "italic";
37576
+ case INLINE_MESSAGE_ENTITY_TYPE.USERNAME_MENTION:
37577
+ return "username_mention";
37578
+ case INLINE_MESSAGE_ENTITY_TYPE.CODE:
37579
+ return "code";
37580
+ case INLINE_MESSAGE_ENTITY_TYPE.PRE:
37581
+ return "pre";
37582
+ case INLINE_MESSAGE_ENTITY_TYPE.PHONE_NUMBER:
37583
+ return "phone_number";
37584
+ default:
37585
+ return "unknown";
37586
+ }
37587
+ }
37588
+ function readEntitySlice(messageText, entity) {
37589
+ if (!messageText)
37590
+ return;
37591
+ const offset = Number(entity.offset);
37592
+ const length = Number(entity.length);
37593
+ if (!Number.isFinite(offset) || !Number.isFinite(length) || offset < 0 || length <= 0)
37594
+ return;
37595
+ const slice = compactWhitespace(messageText.slice(offset, offset + length));
37596
+ return slice || undefined;
37597
+ }
37598
+ function messageEntitySummaries(message) {
37599
+ const rawText = message.message ?? "";
37600
+ const entities = [];
37601
+ for (const entity of message.entities?.entities ?? []) {
37602
+ const offset = Number(entity.offset);
37603
+ const length = Number(entity.length);
37604
+ if (!Number.isFinite(offset) || !Number.isFinite(length) || offset < 0 || length < 0)
37605
+ continue;
37606
+ const summary = {
37607
+ type: mapEntityType(entity.type),
37608
+ offset,
37609
+ length
37610
+ };
37611
+ const text = readEntitySlice(rawText, entity);
37612
+ if (text) {
37613
+ summary.text = text;
37614
+ }
37615
+ if (entity.entity.oneofKind === "mention") {
37616
+ summary.userId = entity.entity.mention.userId.toString();
37617
+ } else if (entity.entity.oneofKind === "textUrl") {
37618
+ const url2 = entity.entity.textUrl.url?.trim();
37619
+ if (url2)
37620
+ summary.url = url2;
37621
+ } else if (entity.entity.oneofKind === "pre") {
37622
+ const language = compactWhitespace(entity.entity.pre.language);
37623
+ if (language)
37624
+ summary.language = language;
37625
+ }
37626
+ entities.push(summary);
37627
+ }
37628
+ return entities;
37629
+ }
37630
+ function formatMediaSummary(media) {
37631
+ if (media.kind === "nudge")
37632
+ return "nudge";
37633
+ if (media.kind === "photo") {
37634
+ return media.url ? `image attachment: ${media.url}` : "image attachment";
37635
+ }
37636
+ if (media.kind === "video") {
37637
+ return media.url ? `video attachment: ${media.url}` : "video attachment";
37638
+ }
37639
+ if (media.kind === "voice") {
37640
+ return media.url ? `audio attachment: ${media.url}` : "audio attachment";
37641
+ }
37642
+ const label = media.fileName ? `document attachment (${media.fileName})` : "document attachment";
37643
+ return media.url ? `${label}: ${media.url}` : label;
37644
+ }
37645
+ function formatAttachmentSummary(attachment) {
37646
+ if (attachment.kind === "urlPreview") {
37647
+ const title2 = compactWhitespace(attachment.title ?? undefined);
37648
+ const url3 = attachment.url?.trim() ?? "";
37649
+ if (title2 && url3)
37650
+ return `link preview (${title2}): ${url3}`;
37651
+ if (url3)
37652
+ return `link preview: ${url3}`;
37653
+ if (title2)
37654
+ return `link preview (${title2})`;
37655
+ return "link preview";
37656
+ }
37657
+ const title = compactWhitespace(attachment.title ?? undefined);
37658
+ const source = compactWhitespace(attachment.application ?? undefined);
37659
+ const url2 = attachment.url?.trim() ?? "";
37660
+ const label = [source, title].filter(Boolean).join(": ");
37661
+ if (label && url2)
37662
+ return `task attachment (${label}): ${url2}`;
37663
+ if (url2)
37664
+ return `task attachment: ${url2}`;
37665
+ if (label)
37666
+ return `task attachment (${label})`;
37667
+ return "task attachment";
37668
+ }
37669
+ function formatEntitySummary(entity) {
37670
+ const text = compactWhitespace(entity.text);
37671
+ const quotedText = text ? ` "${text}"` : "";
37672
+ switch (entity.type) {
37673
+ case "mention":
37674
+ return entity.userId ? `mention${quotedText} -> user:${entity.userId}` : `mention${quotedText}`;
37675
+ case "text_link":
37676
+ return entity.url ? `text link${quotedText} -> ${entity.url}` : `text link${quotedText}`;
37677
+ case "pre":
37678
+ return entity.language ? `preformatted block${quotedText} (language: ${entity.language})` : `preformatted block${quotedText}`;
37679
+ case "username_mention":
37680
+ return `username mention${quotedText}`;
37681
+ case "phone_number":
37682
+ return `phone number${quotedText}`;
37683
+ default:
37684
+ return `${entity.type.replace(/_/g, " ")}${quotedText}`;
37685
+ }
37686
+ }
37687
+ function summarizeInlineMessageContent(message) {
37688
+ const rawText = compactWhitespace(message.message);
37689
+ const media = messageMediaSummary(message);
37690
+ const attachments = messageAttachmentSummaries(message);
37691
+ const entities = messageEntitySummaries(message);
37692
+ const attachmentParts = [];
37693
+ if (media) {
37694
+ attachmentParts.push(formatMediaSummary(media));
37695
+ }
37696
+ for (const attachment of attachments) {
37697
+ attachmentParts.push(formatAttachmentSummary(attachment));
37698
+ }
37699
+ const attachmentText = attachmentParts.filter(Boolean).join(" | ");
37700
+ const entityText = entities.map((entity) => formatEntitySummary(entity)).filter(Boolean).join(" | ");
37701
+ const links = extractMessageUrls(message, attachments);
37702
+ const attachmentUrls = Array.from(new Set([
37703
+ ...media?.url ? [media.url] : [],
37704
+ ...links,
37705
+ ...attachments.flatMap((attachment) => attachment.kind === "urlPreview" && attachment.previewImageUrl ? [attachment.previewImageUrl] : [])
37706
+ ]));
37707
+ const parts = [rawText, attachmentText];
37708
+ return {
37709
+ text: parts.filter(Boolean).join(" | "),
37710
+ rawText,
37711
+ attachmentText,
37712
+ entityText,
37713
+ links,
37714
+ attachmentUrls,
37715
+ media,
37716
+ attachments,
37717
+ entities
37718
+ };
37719
+ }
37720
+
37721
+ // src/inline/reply-threads.ts
37722
+ var GET_CHAT_METHOD = typeof Method.GET_CHAT === "number" && Number.isInteger(Method.GET_CHAT) && Method.GET_CHAT > 0 ? Method.GET_CHAT : 25;
37723
+ 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;
37724
+ var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : 38;
37725
+ var CREATE_SUBTHREAD_METHOD = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 42;
37726
+ function isPlacementMode(raw) {
37727
+ return raw === "thread" || raw === "main";
37728
+ }
37729
+ function hasReplyThreadConfig(config2) {
37730
+ if (isPlacementMode(config2.replyThreadMode))
37731
+ return true;
37732
+ if (typeof config2.replyThreadAutoCreateMinMessages === "number")
37733
+ return true;
37734
+ if (typeof config2.replyThreadRequireExplicitMention === "boolean")
37735
+ return true;
37736
+ if (typeof config2.replyThreadParentHistoryLimit === "number")
37737
+ return true;
37738
+ if (!config2.groups || typeof config2.groups !== "object" || Array.isArray(config2.groups))
37739
+ return false;
37740
+ return Object.values(config2.groups).some((group) => {
37741
+ if (!group || typeof group !== "object" || Array.isArray(group))
37742
+ return false;
37743
+ const groupConfig = group;
37744
+ return isPlacementMode(groupConfig.replyThreadMode) || typeof groupConfig.replyThreadAutoCreateMinMessages === "number" || typeof groupConfig.replyThreadRequireExplicitMention === "boolean" || typeof groupConfig.replyThreadParentHistoryLimit === "number";
37745
+ });
37746
+ }
37747
+ function buildChatPeer(chatId) {
37748
+ return {
37749
+ type: {
37750
+ oneofKind: "chat",
37751
+ chat: { chatId }
37752
+ }
37753
+ };
37754
+ }
37755
+ function getInlineReplyThreadsCapabilityConfig(params) {
37756
+ const account = resolveInlineAccount({
37757
+ cfg: params.cfg,
37758
+ accountId: params.accountId ?? null
37759
+ });
37760
+ return {
37761
+ replyThreads: account.config.capabilities?.replyThreads === true || hasReplyThreadConfig(account.config)
37762
+ };
37763
+ }
37764
+ function isInlineReplyThreadsEnabled(params) {
37765
+ return getInlineReplyThreadsCapabilityConfig(params).replyThreads;
37766
+ }
37767
+ function resolveInlineReplyThreadChatId(params) {
37768
+ if (!isInlineReplyThreadsEnabled({ cfg: params.cfg, accountId: params.accountId ?? null })) {
37769
+ return params.parentChatId;
37770
+ }
37771
+ if (params.parentChatId == null) {
37772
+ return null;
37773
+ }
37774
+ if (params.threadId == null) {
37775
+ return params.parentChatId;
37776
+ }
37777
+ 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() ? (() => {
37778
+ try {
37779
+ return BigInt(params.threadId.trim());
37780
+ } catch {
37781
+ return null;
37782
+ }
37783
+ })() : null : null;
37784
+ return normalized ?? params.parentChatId;
37785
+ }
37786
+ async function loadInlineReplyThreadMetadata(params) {
37787
+ const result = await params.client.invokeRaw(GET_CHAT_METHOD, {
37788
+ oneofKind: "getChat",
37789
+ getChat: { peerId: buildChatPeer(params.chatId) }
37790
+ }).catch(() => null);
37791
+ if (result?.oneofKind !== "getChat") {
37792
+ return null;
37793
+ }
37794
+ const chat = result.getChat.chat;
37795
+ const parentChatId = chat?.parentChatId;
37796
+ if (parentChatId == null) {
37797
+ return null;
37798
+ }
37799
+ return {
37800
+ childChatId: chat?.id ?? params.chatId,
37801
+ parentChatId,
37802
+ parentMessageId: chat?.parentMessageId ?? null,
37803
+ title: chat?.title?.trim() || null
37804
+ };
37805
+ }
37806
+ async function loadInlineReplyThreadAnchorMessage(params) {
37807
+ const directResult = await params.client.invokeRaw(GET_MESSAGES_METHOD, {
37808
+ oneofKind: "getMessages",
37809
+ getMessages: {
37810
+ peerId: buildChatPeer(params.parentChatId),
37811
+ messageIds: [params.parentMessageId]
37812
+ }
37813
+ }).catch(() => null);
37814
+ if (directResult?.oneofKind === "getMessages") {
37815
+ const directTarget = (directResult.getMessages.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
37816
+ if (directTarget) {
37817
+ return directTarget;
37818
+ }
37819
+ }
37820
+ const historyResult = await params.client.invokeRaw(GET_CHAT_HISTORY_METHOD, {
37821
+ oneofKind: "getChatHistory",
37822
+ getChatHistory: {
37823
+ peerId: buildChatPeer(params.parentChatId),
37824
+ offsetId: params.parentMessageId + 1n,
37825
+ limit: 8
37826
+ }
37827
+ }).catch(() => null);
37828
+ if (historyResult?.oneofKind !== "getChatHistory") {
37829
+ return null;
37830
+ }
37831
+ return (historyResult.getChatHistory.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
37832
+ }
37833
+ async function createInlineReplyThreadForMessage(params) {
37834
+ const result = await params.client.invokeRaw(CREATE_SUBTHREAD_METHOD, {
37835
+ oneofKind: "createSubthread",
37836
+ createSubthread: {
37837
+ parentChatId: params.parentChatId,
37838
+ parentMessageId: params.parentMessageId,
37839
+ participants: []
37840
+ }
37841
+ });
37842
+ if (result.oneofKind !== "createSubthread") {
37843
+ return null;
37844
+ }
37845
+ const chat = result.createSubthread.chat;
37846
+ if (!chat?.id) {
37847
+ return null;
37848
+ }
37849
+ return {
37850
+ childChatId: chat.id,
37851
+ parentChatId: chat.parentChatId ?? params.parentChatId,
37852
+ parentMessageId: chat.parentMessageId ?? params.parentMessageId,
37853
+ title: chat.title?.trim() || null,
37854
+ anchorMessage: result.createSubthread.anchorMessage ?? null
37855
+ };
37856
+ }
37857
+
37858
+ // src/inline/parent-context-tool.ts
37859
+ 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;
37860
+ var InlineParentContextToolParameters = {
37861
+ type: "object",
37862
+ additionalProperties: false,
37863
+ properties: {
37864
+ threadId: {
37865
+ type: "string",
37866
+ description: "Optional Inline reply-thread chat id. Defaults to the current reply-thread chat when invoked from one."
37867
+ },
37868
+ parentChatId: {
37869
+ type: "string",
37870
+ description: "Optional parent chat id override. Usually inferred from the current reply thread."
37871
+ },
37872
+ chatId: {
37873
+ type: "string",
37874
+ description: "Alias for `parentChatId`."
37875
+ },
37876
+ parentMessageId: {
37877
+ type: "string",
37878
+ description: "Optional parent/root anchor message id. Usually inferred from reply-thread metadata."
37879
+ },
37880
+ anchorMessageId: {
37881
+ type: "string",
37882
+ description: "Alias for `parentMessageId`."
37883
+ },
37884
+ beforeMessageId: {
37885
+ type: "string",
37886
+ description: "Optional message id to page older parent-chat context before. Defaults to the reply-thread anchor when known."
37887
+ },
37888
+ limit: {
37889
+ type: "number",
37890
+ description: "Number of parent-chat messages to return, clamped to 1..100. Defaults to 50."
37891
+ },
37892
+ includeAnchor: {
37893
+ type: "boolean",
37894
+ description: "Whether to include the reply-thread anchor/root message when parentMessageId is known. Defaults to true."
37895
+ },
37896
+ accountId: {
37897
+ type: "string",
37898
+ description: "Optional Inline account id override."
37899
+ }
37900
+ }
37901
+ };
37902
+ function buildChatPeer2(chatId) {
37903
+ return {
37904
+ type: {
37905
+ oneofKind: "chat",
37906
+ chat: { chatId }
37907
+ }
37908
+ };
37909
+ }
37910
+ function readLimit(raw, fallback) {
37911
+ if (raw == null)
37912
+ return fallback;
37913
+ const value = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw.trim()) : Number.NaN;
37914
+ if (!Number.isFinite(value) || !Number.isInteger(value)) {
37915
+ throw new Error("inline_parent_context: limit must be an integer");
37916
+ }
37917
+ return Math.max(1, Math.min(100, value));
37918
+ }
37919
+ function readIdCandidate(...values) {
37920
+ for (const value of values) {
37921
+ if (value == null)
37922
+ continue;
37923
+ if (typeof value === "string") {
37924
+ const trimmed = value.trim();
37925
+ if (trimmed)
37926
+ return trimmed;
37927
+ continue;
37928
+ }
37929
+ if (typeof value === "number" || typeof value === "bigint")
37930
+ return value;
37931
+ }
37932
+ return;
37933
+ }
37934
+ function parseOptionalChatId(raw, label) {
37935
+ if (raw == null)
37936
+ return null;
37937
+ if (typeof raw === "string") {
37938
+ if (!raw.trim())
37939
+ return null;
37940
+ const target = parseInlineTarget(raw, label);
37941
+ if (target.peerId.type.oneofKind !== "chat") {
37942
+ throw new Error(`inline_parent_context: ${label} must be a chat target`);
37943
+ }
37944
+ return target.peerId.type.chat.chatId;
37945
+ }
37946
+ return parseOptionalInlineId(raw, label);
37947
+ }
37948
+ function mapContextMessage(message, parentMessageId) {
37949
+ const content = summarizeInlineMessageContent(message);
37950
+ return {
37951
+ id: String(message.id),
37952
+ fromId: String(message.fromId),
37953
+ date: Number(message.date) * 1000,
37954
+ text: content.text,
37955
+ rawText: content.rawText,
37956
+ attachmentText: content.attachmentText,
37957
+ entityText: content.entityText,
37958
+ out: Boolean(message.out),
37959
+ replyToId: message.replyToMsgId != null ? String(message.replyToMsgId) : undefined,
37960
+ isAnchor: parentMessageId != null && message.id === parentMessageId,
37961
+ attachmentUrls: content.attachmentUrls,
37962
+ links: content.links,
37963
+ media: content.media,
37964
+ attachments: content.attachments,
37965
+ entities: content.entities
37966
+ };
37967
+ }
37968
+ function sortMessages(messages) {
37969
+ return messages.slice().sort((a, b) => {
37970
+ const byDate = Number(a.date - b.date);
37971
+ if (byDate !== 0)
37972
+ return byDate;
37973
+ if (a.id === b.id)
37974
+ return 0;
37975
+ return a.id < b.id ? -1 : 1;
37976
+ });
37977
+ }
37978
+ function dedupeMessages(messages) {
37979
+ const seen = new Set;
37980
+ const out = [];
37981
+ for (const message of messages) {
37982
+ const id = String(message.id);
37983
+ if (seen.has(id))
37984
+ continue;
37985
+ seen.add(id);
37986
+ out.push(message);
37987
+ }
37988
+ return out;
37989
+ }
37990
+ async function withInlineClient3(params) {
37991
+ const account = resolveInlineAccount({ cfg: params.cfg, accountId: params.accountId ?? null });
37992
+ if (!account.configured || !account.baseUrl) {
37993
+ throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
37994
+ }
37995
+ const token = await resolveInlineToken(account);
37996
+ const client = new InlineSdkClient({
37997
+ baseUrl: account.baseUrl,
37998
+ token
37999
+ });
38000
+ await client.connect();
38001
+ try {
38002
+ return await params.fn(client, account.accountId);
38003
+ } finally {
38004
+ await client.close().catch(() => {});
38005
+ }
38006
+ }
38007
+ async function loadParentHistory(params) {
38008
+ if (params.limit <= 0)
38009
+ return [];
38010
+ const result = await params.client.invokeRaw(GET_CHAT_HISTORY_METHOD2, {
38011
+ oneofKind: "getChatHistory",
38012
+ getChatHistory: {
38013
+ peerId: buildChatPeer2(params.parentChatId),
38014
+ ...params.offsetId != null ? { offsetId: params.offsetId } : {},
38015
+ limit: params.limit
38016
+ }
38017
+ });
38018
+ if (result.oneofKind !== "getChatHistory") {
38019
+ throw new Error(`inline_parent_context: expected getChatHistory result, got ${String(result.oneofKind)}`);
38020
+ }
38021
+ return result.getChatHistory.messages ?? [];
38022
+ }
38023
+ async function loadParentContextMessages(params) {
38024
+ if (params.beforeMessageId != null) {
38025
+ return sortMessages(await loadParentHistory({
38026
+ client: params.client,
38027
+ parentChatId: params.parentChatId,
38028
+ offsetId: params.beforeMessageId,
38029
+ limit: params.limit
38030
+ }));
38031
+ }
38032
+ if (params.parentMessageId == null) {
38033
+ return sortMessages(await loadParentHistory({
38034
+ client: params.client,
38035
+ parentChatId: params.parentChatId,
38036
+ offsetId: null,
38037
+ limit: params.limit
38038
+ }));
38039
+ }
38040
+ const anchor = params.includeAnchor ? await loadInlineReplyThreadAnchorMessage({
38041
+ client: params.client,
38042
+ parentChatId: params.parentChatId,
38043
+ parentMessageId: params.parentMessageId
38044
+ }) : null;
38045
+ const historyLimit = Math.max(0, params.limit - (anchor ? 1 : 0));
38046
+ const history = await loadParentHistory({
38047
+ client: params.client,
38048
+ parentChatId: params.parentChatId,
38049
+ offsetId: params.parentMessageId,
38050
+ limit: historyLimit
38051
+ });
38052
+ return sortMessages(dedupeMessages([...history, ...anchor ? [anchor] : []]));
38053
+ }
38054
+ function createInlineParentContextTool(ctx) {
38055
+ if (!ctx.config)
38056
+ return null;
38057
+ return {
38058
+ name: "inline_parent_context",
38059
+ label: "Inline Parent Context",
38060
+ 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.",
38061
+ parameters: InlineParentContextToolParameters,
38062
+ execute: async (_toolCallId, rawArgs) => {
38063
+ const args = rawArgs;
38064
+ const currentSession = parseCurrentInlineSession(ctx);
38065
+ const explicitThreadId = readStringCandidate(args.threadId);
38066
+ const threadId = explicitThreadId != null ? parseInlineId(explicitThreadId, "threadId") : currentSession?.threadId ?? null;
38067
+ let parentChatId = parseOptionalChatId(readIdCandidate(args.parentChatId, args.chatId), "parentChatId") ?? currentSession?.parentChatId ?? null;
38068
+ let parentMessageId = parseOptionalInlineId(readIdCandidate(args.parentMessageId, args.anchorMessageId), "parentMessageId");
38069
+ const beforeMessageId = parseOptionalInlineId(readIdCandidate(args.beforeMessageId), "beforeMessageId");
38070
+ const limit = readLimit(args.limit, 50);
38071
+ const includeAnchor = args.includeAnchor !== false;
38072
+ return await withInlineClient3({
38073
+ cfg: ctx.config,
38074
+ accountId: args.accountId ?? ctx.agentAccountId ?? null,
38075
+ fn: async (client, resolvedAccountId) => {
38076
+ let threadTitle = null;
38077
+ if (threadId != null) {
38078
+ const metadata = await loadInlineReplyThreadMetadata({ client, chatId: threadId });
38079
+ parentChatId = metadata?.parentChatId ?? parentChatId;
38080
+ parentMessageId = parentMessageId ?? metadata?.parentMessageId ?? null;
38081
+ threadTitle = metadata?.title ?? null;
38082
+ }
38083
+ if (parentChatId == null) {
38084
+ throw new Error("inline_parent_context: parentChatId is required outside an Inline reply-thread session");
38085
+ }
38086
+ const messages = (await loadParentContextMessages({
38087
+ client,
38088
+ parentChatId,
38089
+ parentMessageId,
38090
+ beforeMessageId,
38091
+ includeAnchor,
38092
+ limit
38093
+ })).map((message) => mapContextMessage(message, parentMessageId));
38094
+ const oldest = messages[0];
38095
+ return jsonResult({
38096
+ ok: true,
38097
+ accountId: resolvedAccountId,
38098
+ parentChatId: String(parentChatId),
38099
+ threadId: threadId != null ? String(threadId) : null,
38100
+ threadTitle,
38101
+ parentMessageId: parentMessageId != null ? String(parentMessageId) : null,
38102
+ limit,
38103
+ includeAnchor,
38104
+ usedCurrentThreadDefault: explicitThreadId == null && currentSession?.threadId != null,
38105
+ nextBeforeMessageId: oldest?.id ?? null,
38106
+ messages
38107
+ });
38108
+ }
38109
+ });
38110
+ }
38111
+ };
38112
+ }
38113
+
36459
38114
  // src/inline/message-formatting.ts
36460
38115
  var INLINE_FORMATTING_RULES = [
36461
38116
  "Use Inline markdown.",
@@ -36507,20 +38162,16 @@ function sanitizeInlineOutgoingText(text) {
36507
38162
  }
36508
38163
 
36509
38164
  // 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
- }
38165
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
38166
+ var {
38167
+ setRuntime: setInlineRuntime,
38168
+ clearRuntime: clearInlineRuntime,
38169
+ tryGetRuntime: getOptionalInlineRuntime,
38170
+ getRuntime: getInlineRuntime
38171
+ } = createPluginRuntimeStore({
38172
+ pluginId: "inline",
38173
+ errorMessage: "Inline runtime not initialized"
38174
+ });
36524
38175
 
36525
38176
  // src/inline/profile-tool.ts
36526
38177
  var InlineProfileToolParameters = {
@@ -36560,7 +38211,7 @@ function jsonResult3(payload) {
36560
38211
  details: payload
36561
38212
  };
36562
38213
  }
36563
- async function withInlineClient3(params) {
38214
+ async function withInlineClient4(params) {
36564
38215
  const account = resolveInlineAccount({ cfg: params.cfg, accountId: params.accountId ?? null });
36565
38216
  if (!account.configured || !account.baseUrl) {
36566
38217
  throw new Error(`Inline not configured for account "${account.accountId}" (missing token or baseUrl)`);
@@ -36627,7 +38278,7 @@ function createInlineProfileTool(ctx) {
36627
38278
  if (!name && !existingPhotoFileUniqueId && !photoSource) {
36628
38279
  throw new Error("inline_update_profile: provide `name` and/or `photo`");
36629
38280
  }
36630
- return await withInlineClient3({
38281
+ return await withInlineClient4({
36631
38282
  cfg: ctx.config,
36632
38283
  accountId: args.accountId ?? ctx.agentAccountId ?? null,
36633
38284
  fn: async (client, resolvedAccountId) => {
@@ -37055,6 +38706,9 @@ function registerInlinePluginFull(api2) {
37055
38706
  api2.registerTool((ctx) => createInlineMessageTools(ctx), {
37056
38707
  names: ["inline_nudge", "inline_forward"]
37057
38708
  });
38709
+ api2.registerTool((ctx) => createInlineParentContextTool(ctx), {
38710
+ names: ["inline_parent_context"]
38711
+ });
37058
38712
  api2.on("message_sending", (event, ctx) => {
37059
38713
  if (ctx.channelId !== "inline")
37060
38714
  return;
@@ -37082,5 +38736,5 @@ export {
37082
38736
  registerInlinePluginFull
37083
38737
  };
37084
38738
 
37085
- //# debugId=5ACEE44315B26ABD64756E2164756E21
38739
+ //# debugId=5E9A1238DFA90DDE64756E2164756E21
37086
38740
  //# sourceMappingURL=runtime-register-api.js.map