@inline-openclaw/inline 0.0.38 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +36 -25
  2. package/dist/account-inspect-api.js +34 -7
  3. package/dist/account-inspect-api.js.map +4 -4
  4. package/dist/approval-handler.runtime.js +1550 -205
  5. package/dist/approval-handler.runtime.js.map +16 -15
  6. package/dist/channel-plugin-api.js +2356 -364
  7. package/dist/channel-plugin-api.js.map +19 -17
  8. package/dist/index.d.ts +1 -1
  9. package/dist/inline/accounts.d.ts.map +1 -1
  10. package/dist/inline/actions.d.ts +1 -1
  11. package/dist/inline/actions.d.ts.map +1 -1
  12. package/dist/inline/approval-native.d.ts.map +1 -1
  13. package/dist/inline/channel.d.ts.map +1 -1
  14. package/dist/inline/config-schema.d.ts +125 -0
  15. package/dist/inline/config-schema.d.ts.map +1 -1
  16. package/dist/inline/exec-approvals.d.ts.map +1 -1
  17. package/dist/inline/message-tools.d.ts.map +1 -1
  18. package/dist/inline/monitor.d.ts.map +1 -1
  19. package/dist/inline/parent-context-tool.d.ts +10 -0
  20. package/dist/inline/parent-context-tool.d.ts.map +1 -0
  21. package/dist/inline/policy.d.ts +30 -1
  22. package/dist/inline/policy.d.ts.map +1 -1
  23. package/dist/inline/reply-threads.d.ts +12 -0
  24. package/dist/inline/reply-threads.d.ts.map +1 -1
  25. package/dist/inline/shared.d.ts +1 -1
  26. package/dist/inline/thread-participation.d.ts +10 -0
  27. package/dist/inline/thread-participation.d.ts.map +1 -0
  28. package/dist/inline/thread-routes.d.ts +28 -0
  29. package/dist/inline/thread-routes.d.ts.map +1 -0
  30. package/dist/inline/tool-targets.d.ts +36 -0
  31. package/dist/inline/tool-targets.d.ts.map +1 -0
  32. package/dist/runtime-register-api.d.ts.map +1 -1
  33. package/dist/runtime-register-api.js +1891 -152
  34. package/dist/runtime-register-api.js.map +19 -15
  35. package/dist/runtime-setter-api.js +11 -15
  36. package/dist/runtime-setter-api.js.map +3 -3
  37. package/dist/runtime.d.ts +2 -2
  38. package/dist/runtime.d.ts.map +1 -1
  39. package/dist/setup-entry.d.ts +1 -1
  40. package/dist/setup-plugin-api.js +34 -7
  41. package/dist/setup-plugin-api.js.map +4 -4
  42. package/openclaw.plugin.json +725 -58
  43. package/package.json +6 -6
@@ -2695,7 +2695,7 @@ var require_commonjs = __commonJS((exports) => {
2695
2695
  } });
2696
2696
  });
2697
2697
 
2698
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/constants.js
2698
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/constants.js
2699
2699
  var require_constants = __commonJS((exports, module) => {
2700
2700
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
2701
2701
  var hasBlob = typeof Blob !== "undefined";
@@ -2715,7 +2715,7 @@ var require_constants = __commonJS((exports, module) => {
2715
2715
  };
2716
2716
  });
2717
2717
 
2718
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/buffer-util.js
2718
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/buffer-util.js
2719
2719
  var require_buffer_util = __commonJS((exports, module) => {
2720
2720
  var { EMPTY_BUFFER } = require_constants();
2721
2721
  var FastBuffer = Buffer[Symbol.species];
@@ -2793,7 +2793,7 @@ var require_buffer_util = __commonJS((exports, module) => {
2793
2793
  }
2794
2794
  });
2795
2795
 
2796
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/limiter.js
2796
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/limiter.js
2797
2797
  var require_limiter = __commonJS((exports, module) => {
2798
2798
  var kDone = Symbol("kDone");
2799
2799
  var kRun = Symbol("kRun");
@@ -2825,7 +2825,7 @@ var require_limiter = __commonJS((exports, module) => {
2825
2825
  module.exports = Limiter;
2826
2826
  });
2827
2827
 
2828
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/permessage-deflate.js
2828
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/permessage-deflate.js
2829
2829
  var require_permessage_deflate = __commonJS((exports, module) => {
2830
2830
  var zlib = __require("zlib");
2831
2831
  var bufferUtil = require_buffer_util();
@@ -3089,7 +3089,7 @@ var require_permessage_deflate = __commonJS((exports, module) => {
3089
3089
  }
3090
3090
  });
3091
3091
 
3092
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/validation.js
3092
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/validation.js
3093
3093
  var require_validation = __commonJS((exports, module) => {
3094
3094
  var { isUtf8 } = __require("buffer");
3095
3095
  var { hasBlob } = require_constants();
@@ -3276,7 +3276,7 @@ var require_validation = __commonJS((exports, module) => {
3276
3276
  }
3277
3277
  });
3278
3278
 
3279
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/receiver.js
3279
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/receiver.js
3280
3280
  var require_receiver = __commonJS((exports, module) => {
3281
3281
  var { Writable } = __require("stream");
3282
3282
  var PerMessageDeflate = require_permessage_deflate();
@@ -3304,6 +3304,8 @@ var require_receiver = __commonJS((exports, module) => {
3304
3304
  this._binaryType = options.binaryType || BINARY_TYPES[0];
3305
3305
  this._extensions = options.extensions || {};
3306
3306
  this._isServer = !!options.isServer;
3307
+ this._maxBufferedChunks = options.maxBufferedChunks | 0;
3308
+ this._maxFragments = options.maxFragments | 0;
3307
3309
  this._maxPayload = options.maxPayload | 0;
3308
3310
  this._skipUTF8Validation = !!options.skipUTF8Validation;
3309
3311
  this[kWebSocket] = undefined;
@@ -3326,6 +3328,10 @@ var require_receiver = __commonJS((exports, module) => {
3326
3328
  _write(chunk, encoding, cb) {
3327
3329
  if (this._opcode === 8 && this._state == GET_INFO)
3328
3330
  return cb();
3331
+ if (this._maxBufferedChunks > 0 && this._buffers.length >= this._maxBufferedChunks) {
3332
+ cb(this.createError(RangeError, "Too many buffered chunks", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS"));
3333
+ return;
3334
+ }
3329
3335
  this._bufferedBytes += chunk.length;
3330
3336
  this._buffers.push(chunk);
3331
3337
  this.startLoop(cb);
@@ -3529,6 +3535,11 @@ var require_receiver = __commonJS((exports, module) => {
3529
3535
  return;
3530
3536
  }
3531
3537
  if (data.length) {
3538
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
3539
+ const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
3540
+ cb(error);
3541
+ return;
3542
+ }
3532
3543
  this._messageLength = this._totalPayloadLength;
3533
3544
  this._fragments.push(data);
3534
3545
  }
@@ -3546,6 +3557,11 @@ var require_receiver = __commonJS((exports, module) => {
3546
3557
  cb(error);
3547
3558
  return;
3548
3559
  }
3560
+ if (this._maxFragments > 0 && this._fragments.length >= this._maxFragments) {
3561
+ const error = this.createError(RangeError, "Too many message fragments", false, 1008, "WS_ERR_TOO_MANY_BUFFERED_PARTS");
3562
+ cb(error);
3563
+ return;
3564
+ }
3549
3565
  this._fragments.push(buf);
3550
3566
  }
3551
3567
  this.dataMessage(cb);
@@ -3657,7 +3673,7 @@ var require_receiver = __commonJS((exports, module) => {
3657
3673
  module.exports = Receiver;
3658
3674
  });
3659
3675
 
3660
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/sender.js
3676
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/sender.js
3661
3677
  var require_sender = __commonJS((exports, module) => {
3662
3678
  var { Duplex } = __require("stream");
3663
3679
  var { randomFillSync } = __require("crypto");
@@ -4016,7 +4032,7 @@ var require_sender = __commonJS((exports, module) => {
4016
4032
  }
4017
4033
  });
4018
4034
 
4019
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/event-target.js
4035
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/event-target.js
4020
4036
  var require_event_target = __commonJS((exports, module) => {
4021
4037
  var { kForOnEventAttribute, kListener } = require_constants();
4022
4038
  var kCode = Symbol("kCode");
@@ -4167,7 +4183,7 @@ var require_event_target = __commonJS((exports, module) => {
4167
4183
  }
4168
4184
  });
4169
4185
 
4170
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/extension.js
4186
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/extension.js
4171
4187
  var require_extension = __commonJS((exports, module) => {
4172
4188
  var { tokenChars } = require_validation();
4173
4189
  function push(dest, name, elem) {
@@ -4332,7 +4348,7 @@ var require_extension = __commonJS((exports, module) => {
4332
4348
  module.exports = { format, parse };
4333
4349
  });
4334
4350
 
4335
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/websocket.js
4351
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/websocket.js
4336
4352
  var require_websocket = __commonJS((exports, module) => {
4337
4353
  var EventEmitter = __require("events");
4338
4354
  var https = __require("https");
@@ -4453,6 +4469,8 @@ var require_websocket = __commonJS((exports, module) => {
4453
4469
  binaryType: this.binaryType,
4454
4470
  extensions: this._extensions,
4455
4471
  isServer: this._isServer,
4472
+ maxBufferedChunks: options.maxBufferedChunks,
4473
+ maxFragments: options.maxFragments,
4456
4474
  maxPayload: options.maxPayload,
4457
4475
  skipUTF8Validation: options.skipUTF8Validation
4458
4476
  });
@@ -4695,6 +4713,8 @@ var require_websocket = __commonJS((exports, module) => {
4695
4713
  autoPong: true,
4696
4714
  closeTimeout: CLOSE_TIMEOUT,
4697
4715
  protocolVersion: protocolVersions[1],
4716
+ maxBufferedChunks: 1024 * 1024,
4717
+ maxFragments: 128 * 1024,
4698
4718
  maxPayload: 100 * 1024 * 1024,
4699
4719
  skipUTF8Validation: false,
4700
4720
  perMessageDeflate: true,
@@ -4933,6 +4953,8 @@ var require_websocket = __commonJS((exports, module) => {
4933
4953
  websocket.setSocket(socket, head, {
4934
4954
  allowSynchronousEvents: opts.allowSynchronousEvents,
4935
4955
  generateMask: opts.generateMask,
4956
+ maxBufferedChunks: opts.maxBufferedChunks,
4957
+ maxFragments: opts.maxFragments,
4936
4958
  maxPayload: opts.maxPayload,
4937
4959
  skipUTF8Validation: opts.skipUTF8Validation
4938
4960
  });
@@ -5098,7 +5120,7 @@ var require_websocket = __commonJS((exports, module) => {
5098
5120
  }
5099
5121
  });
5100
5122
 
5101
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/stream.js
5123
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/stream.js
5102
5124
  var require_stream = __commonJS((exports, module) => {
5103
5125
  var WebSocket = require_websocket();
5104
5126
  var { Duplex } = __require("stream");
@@ -5201,7 +5223,7 @@ var require_stream = __commonJS((exports, module) => {
5201
5223
  module.exports = createWebSocketStream;
5202
5224
  });
5203
5225
 
5204
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/subprotocol.js
5226
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/subprotocol.js
5205
5227
  var require_subprotocol = __commonJS((exports, module) => {
5206
5228
  var { tokenChars } = require_validation();
5207
5229
  function parse(header) {
@@ -5246,7 +5268,7 @@ var require_subprotocol = __commonJS((exports, module) => {
5246
5268
  module.exports = { parse };
5247
5269
  });
5248
5270
 
5249
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/lib/websocket-server.js
5271
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/lib/websocket-server.js
5250
5272
  var require_websocket_server = __commonJS((exports, module) => {
5251
5273
  var EventEmitter = __require("events");
5252
5274
  var http = __require("http");
@@ -5268,6 +5290,8 @@ var require_websocket_server = __commonJS((exports, module) => {
5268
5290
  options = {
5269
5291
  allowSynchronousEvents: true,
5270
5292
  autoPong: true,
5293
+ maxBufferedChunks: 1024 * 1024,
5294
+ maxFragments: 128 * 1024,
5271
5295
  maxPayload: 100 * 1024 * 1024,
5272
5296
  skipUTF8Validation: false,
5273
5297
  perMessageDeflate: false,
@@ -5494,6 +5518,8 @@ var require_websocket_server = __commonJS((exports, module) => {
5494
5518
  socket.removeListener("error", socketOnError);
5495
5519
  ws.setSocket(socket, head, {
5496
5520
  allowSynchronousEvents: this.options.allowSynchronousEvents,
5521
+ maxBufferedChunks: this.options.maxBufferedChunks,
5522
+ maxFragments: this.options.maxFragments,
5497
5523
  maxPayload: this.options.maxPayload,
5498
5524
  skipUTF8Validation: this.options.skipUTF8Validation
5499
5525
  });
@@ -5563,7 +5589,7 @@ function hasInlineConfiguredState(params) {
5563
5589
 
5564
5590
  // src/inline/channel.ts
5565
5591
  import { unlink } from "node:fs/promises";
5566
- import path3 from "node:path";
5592
+ import path5 from "node:path";
5567
5593
  import {
5568
5594
  buildChannelOutboundSessionRoute,
5569
5595
  buildThreadAwareOutboundSessionRoute
@@ -5604,6 +5630,8 @@ var MessageEntity_Type;
5604
5630
  MessageEntity_Type2[MessageEntity_Type2["CODE"] = 8] = "CODE";
5605
5631
  MessageEntity_Type2[MessageEntity_Type2["PRE"] = 9] = "PRE";
5606
5632
  MessageEntity_Type2[MessageEntity_Type2["PHONE_NUMBER"] = 10] = "PHONE_NUMBER";
5633
+ MessageEntity_Type2[MessageEntity_Type2["THREAD"] = 11] = "THREAD";
5634
+ MessageEntity_Type2[MessageEntity_Type2["THREAD_TITLE"] = 12] = "THREAD_TITLE";
5607
5635
  })(MessageEntity_Type || (MessageEntity_Type = {}));
5608
5636
  var Member_Role;
5609
5637
  (function(Member_Role2) {
@@ -5611,6 +5639,15 @@ var Member_Role;
5611
5639
  Member_Role2[Member_Role2["ADMIN"] = 1] = "ADMIN";
5612
5640
  Member_Role2[Member_Role2["MEMBER"] = 2] = "MEMBER";
5613
5641
  })(Member_Role || (Member_Role = {}));
5642
+ var UrlPreview_MediaType;
5643
+ (function(UrlPreview_MediaType2) {
5644
+ UrlPreview_MediaType2[UrlPreview_MediaType2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
5645
+ UrlPreview_MediaType2[UrlPreview_MediaType2["ARTICLE"] = 1] = "ARTICLE";
5646
+ UrlPreview_MediaType2[UrlPreview_MediaType2["IMAGE"] = 2] = "IMAGE";
5647
+ UrlPreview_MediaType2[UrlPreview_MediaType2["VIDEO"] = 3] = "VIDEO";
5648
+ UrlPreview_MediaType2[UrlPreview_MediaType2["DOCUMENT"] = 4] = "DOCUMENT";
5649
+ UrlPreview_MediaType2[UrlPreview_MediaType2["EMBED"] = 5] = "EMBED";
5650
+ })(UrlPreview_MediaType || (UrlPreview_MediaType = {}));
5614
5651
  var MessageAttachmentExternalTask_Status;
5615
5652
  (function(MessageAttachmentExternalTask_Status2) {
5616
5653
  MessageAttachmentExternalTask_Status2[MessageAttachmentExternalTask_Status2["UNSPECIFIED"] = 0] = "UNSPECIFIED";
@@ -5753,6 +5790,9 @@ var Method;
5753
5790
  Method2[Method2["REVOKE_SESSION"] = 50] = "REVOKE_SESSION";
5754
5791
  Method2[Method2["UPDATE_DIALOG_OPEN"] = 51] = "UPDATE_DIALOG_OPEN";
5755
5792
  Method2[Method2["UPDATE_DIALOG_ORDER"] = 52] = "UPDATE_DIALOG_ORDER";
5793
+ Method2[Method2["CLEAR_CHAT_HISTORY"] = 53] = "CLEAR_CHAT_HISTORY";
5794
+ Method2[Method2["DELETE_BOT"] = 54] = "DELETE_BOT";
5795
+ Method2[Method2["DELETE_MESSAGE_ATTACHMENT"] = 55] = "DELETE_MESSAGE_ATTACHMENT";
5756
5796
  })(Method || (Method = {}));
5757
5797
  var PushNotificationProvider;
5758
5798
  (function(PushNotificationProvider2) {
@@ -7722,7 +7762,9 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7722
7762
  { no: 3, name: "length", kind: "scalar", T: 3, L: 0 },
7723
7763
  { no: 4, name: "mention", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityMention },
7724
7764
  { no: 5, name: "text_url", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityTextUrl },
7725
- { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre }
7765
+ { no: 6, name: "pre", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityPre },
7766
+ { no: 7, name: "thread", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityThread },
7767
+ { no: 8, name: "thread_title", kind: "message", oneof: "entity", T: () => MessageEntity_MessageEntityThreadTitle }
7726
7768
  ]);
7727
7769
  }
7728
7770
  create(value) {
@@ -7767,6 +7809,18 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7767
7809
  pre: MessageEntity_MessageEntityPre.internalBinaryRead(reader, reader.uint32(), options, message.entity.pre)
7768
7810
  };
7769
7811
  break;
7812
+ case 7:
7813
+ message.entity = {
7814
+ oneofKind: "thread",
7815
+ thread: MessageEntity_MessageEntityThread.internalBinaryRead(reader, reader.uint32(), options, message.entity.thread)
7816
+ };
7817
+ break;
7818
+ case 8:
7819
+ message.entity = {
7820
+ oneofKind: "threadTitle",
7821
+ threadTitle: MessageEntity_MessageEntityThreadTitle.internalBinaryRead(reader, reader.uint32(), options, message.entity.threadTitle)
7822
+ };
7823
+ break;
7770
7824
  default:
7771
7825
  let u = options.readUnknownField;
7772
7826
  if (u === "throw")
@@ -7791,6 +7845,10 @@ class MessageEntity$Type extends import_runtime4.MessageType {
7791
7845
  MessageEntity_MessageEntityTextUrl.internalBinaryWrite(message.entity.textUrl, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
7792
7846
  if (message.entity.oneofKind === "pre")
7793
7847
  MessageEntity_MessageEntityPre.internalBinaryWrite(message.entity.pre, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
7848
+ if (message.entity.oneofKind === "thread")
7849
+ MessageEntity_MessageEntityThread.internalBinaryWrite(message.entity.thread, writer.tag(7, import_runtime.WireType.LengthDelimited).fork(), options).join();
7850
+ if (message.entity.oneofKind === "threadTitle")
7851
+ MessageEntity_MessageEntityThreadTitle.internalBinaryWrite(message.entity.threadTitle, writer.tag(8, import_runtime.WireType.LengthDelimited).fork(), options).join();
7794
7852
  let u = options.writeUnknownFields;
7795
7853
  if (u !== false)
7796
7854
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -7928,6 +7986,99 @@ class MessageEntity_MessageEntityPre$Type extends import_runtime4.MessageType {
7928
7986
  }
7929
7987
  var MessageEntity_MessageEntityPre = new MessageEntity_MessageEntityPre$Type;
7930
7988
 
7989
+ class MessageEntity_MessageEntityThread$Type extends import_runtime4.MessageType {
7990
+ constructor() {
7991
+ super("MessageEntity.MessageEntityThread", [
7992
+ { no: 1, name: "chat_id", kind: "scalar", T: 3, L: 0 }
7993
+ ]);
7994
+ }
7995
+ create(value) {
7996
+ const message = globalThis.Object.create(this.messagePrototype);
7997
+ message.chatId = 0n;
7998
+ if (value !== undefined)
7999
+ import_runtime3.reflectionMergePartial(this, message, value);
8000
+ return message;
8001
+ }
8002
+ internalBinaryRead(reader, length, options, target) {
8003
+ let message = target ?? this.create(), end = reader.pos + length;
8004
+ while (reader.pos < end) {
8005
+ let [fieldNo, wireType] = reader.tag();
8006
+ switch (fieldNo) {
8007
+ case 1:
8008
+ message.chatId = reader.int64().toBigInt();
8009
+ break;
8010
+ default:
8011
+ let u = options.readUnknownField;
8012
+ if (u === "throw")
8013
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8014
+ let d = reader.skip(wireType);
8015
+ if (u !== false)
8016
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8017
+ }
8018
+ }
8019
+ return message;
8020
+ }
8021
+ internalBinaryWrite(message, writer, options) {
8022
+ if (message.chatId !== 0n)
8023
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.chatId);
8024
+ let u = options.writeUnknownFields;
8025
+ if (u !== false)
8026
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8027
+ return writer;
8028
+ }
8029
+ }
8030
+ var MessageEntity_MessageEntityThread = new MessageEntity_MessageEntityThread$Type;
8031
+
8032
+ class MessageEntity_MessageEntityThreadTitle$Type extends import_runtime4.MessageType {
8033
+ constructor() {
8034
+ super("MessageEntity.MessageEntityThreadTitle", [
8035
+ { no: 1, name: "space_id", kind: "scalar", T: 3, L: 0 },
8036
+ { no: 2, name: "title", kind: "scalar", T: 9 }
8037
+ ]);
8038
+ }
8039
+ create(value) {
8040
+ const message = globalThis.Object.create(this.messagePrototype);
8041
+ message.spaceId = 0n;
8042
+ message.title = "";
8043
+ if (value !== undefined)
8044
+ import_runtime3.reflectionMergePartial(this, message, value);
8045
+ return message;
8046
+ }
8047
+ internalBinaryRead(reader, length, options, target) {
8048
+ let message = target ?? this.create(), end = reader.pos + length;
8049
+ while (reader.pos < end) {
8050
+ let [fieldNo, wireType] = reader.tag();
8051
+ switch (fieldNo) {
8052
+ case 1:
8053
+ message.spaceId = reader.int64().toBigInt();
8054
+ break;
8055
+ case 2:
8056
+ message.title = reader.string();
8057
+ break;
8058
+ default:
8059
+ let u = options.readUnknownField;
8060
+ if (u === "throw")
8061
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8062
+ let d = reader.skip(wireType);
8063
+ if (u !== false)
8064
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8065
+ }
8066
+ }
8067
+ return message;
8068
+ }
8069
+ internalBinaryWrite(message, writer, options) {
8070
+ if (message.spaceId !== 0n)
8071
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.spaceId);
8072
+ if (message.title !== "")
8073
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.title);
8074
+ let u = options.writeUnknownFields;
8075
+ if (u !== false)
8076
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8077
+ return writer;
8078
+ }
8079
+ }
8080
+ var MessageEntity_MessageEntityThreadTitle = new MessageEntity_MessageEntityThreadTitle$Type;
8081
+
7931
8082
  class MessageReactions$Type extends import_runtime4.MessageType {
7932
8083
  constructor() {
7933
8084
  super("MessageReactions", [
@@ -8125,7 +8276,8 @@ class Space$Type extends import_runtime4.MessageType {
8125
8276
  { no: 1, name: "id", kind: "scalar", T: 3, L: 0 },
8126
8277
  { no: 2, name: "name", kind: "scalar", T: 9 },
8127
8278
  { no: 3, name: "creator", kind: "scalar", T: 8 },
8128
- { no: 4, name: "date", kind: "scalar", T: 3, L: 0 }
8279
+ { no: 4, name: "date", kind: "scalar", T: 3, L: 0 },
8280
+ { no: 5, name: "is_public", kind: "scalar", opt: true, T: 8 }
8129
8281
  ]);
8130
8282
  }
8131
8283
  create(value) {
@@ -8155,6 +8307,9 @@ class Space$Type extends import_runtime4.MessageType {
8155
8307
  case 4:
8156
8308
  message.date = reader.int64().toBigInt();
8157
8309
  break;
8310
+ case 5:
8311
+ message.isPublic = reader.bool();
8312
+ break;
8158
8313
  default:
8159
8314
  let u = options.readUnknownField;
8160
8315
  if (u === "throw")
@@ -8175,6 +8330,8 @@ class Space$Type extends import_runtime4.MessageType {
8175
8330
  writer.tag(3, import_runtime.WireType.Varint).bool(message.creator);
8176
8331
  if (message.date !== 0n)
8177
8332
  writer.tag(4, import_runtime.WireType.Varint).int64(message.date);
8333
+ if (message.isPublic !== undefined)
8334
+ writer.tag(5, import_runtime.WireType.Varint).bool(message.isPublic);
8178
8335
  let u = options.writeUnknownFields;
8179
8336
  if (u !== false)
8180
8337
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8495,7 +8652,13 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8495
8652
  { no: 4, name: "title", kind: "scalar", opt: true, T: 9 },
8496
8653
  { no: 5, name: "description", kind: "scalar", opt: true, T: 9 },
8497
8654
  { no: 6, name: "photo", kind: "message", T: () => Photo },
8498
- { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 }
8655
+ { no: 7, name: "duration", kind: "scalar", opt: true, T: 3, L: 0 },
8656
+ { no: 8, name: "media_type", kind: "enum", opt: true, T: () => ["UrlPreview.MediaType", UrlPreview_MediaType, "MEDIA_TYPE_"] },
8657
+ { no: 9, name: "display_url", kind: "scalar", opt: true, T: 9 },
8658
+ { no: 10, name: "provider", kind: "scalar", opt: true, T: 9 },
8659
+ { no: 11, name: "author", kind: "scalar", opt: true, T: 9 },
8660
+ { no: 12, name: "media", kind: "message", T: () => UrlPreviewMedia },
8661
+ { no: 13, name: "layout", kind: "message", T: () => UrlPreviewLayout }
8499
8662
  ]);
8500
8663
  }
8501
8664
  create(value) {
@@ -8531,6 +8694,24 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8531
8694
  case 7:
8532
8695
  message.duration = reader.int64().toBigInt();
8533
8696
  break;
8697
+ case 8:
8698
+ message.mediaType = reader.int32();
8699
+ break;
8700
+ case 9:
8701
+ message.displayUrl = reader.string();
8702
+ break;
8703
+ case 10:
8704
+ message.provider = reader.string();
8705
+ break;
8706
+ case 11:
8707
+ message.author = reader.string();
8708
+ break;
8709
+ case 12:
8710
+ message.media = UrlPreviewMedia.internalBinaryRead(reader, reader.uint32(), options, message.media);
8711
+ break;
8712
+ case 13:
8713
+ message.layout = UrlPreviewLayout.internalBinaryRead(reader, reader.uint32(), options, message.layout);
8714
+ break;
8534
8715
  default:
8535
8716
  let u = options.readUnknownField;
8536
8717
  if (u === "throw")
@@ -8557,6 +8738,18 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8557
8738
  Photo.internalBinaryWrite(message.photo, writer.tag(6, import_runtime.WireType.LengthDelimited).fork(), options).join();
8558
8739
  if (message.duration !== undefined)
8559
8740
  writer.tag(7, import_runtime.WireType.Varint).int64(message.duration);
8741
+ if (message.mediaType !== undefined)
8742
+ writer.tag(8, import_runtime.WireType.Varint).int32(message.mediaType);
8743
+ if (message.displayUrl !== undefined)
8744
+ writer.tag(9, import_runtime.WireType.LengthDelimited).string(message.displayUrl);
8745
+ if (message.provider !== undefined)
8746
+ writer.tag(10, import_runtime.WireType.LengthDelimited).string(message.provider);
8747
+ if (message.author !== undefined)
8748
+ writer.tag(11, import_runtime.WireType.LengthDelimited).string(message.author);
8749
+ if (message.media)
8750
+ UrlPreviewMedia.internalBinaryWrite(message.media, writer.tag(12, import_runtime.WireType.LengthDelimited).fork(), options).join();
8751
+ if (message.layout)
8752
+ UrlPreviewLayout.internalBinaryWrite(message.layout, writer.tag(13, import_runtime.WireType.LengthDelimited).fork(), options).join();
8560
8753
  let u = options.writeUnknownFields;
8561
8754
  if (u !== false)
8562
8755
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -8565,6 +8758,272 @@ class UrlPreview$Type extends import_runtime4.MessageType {
8565
8758
  }
8566
8759
  var UrlPreview = new UrlPreview$Type;
8567
8760
 
8761
+ class UrlPreviewMedia$Type extends import_runtime4.MessageType {
8762
+ constructor() {
8763
+ super("UrlPreviewMedia", [
8764
+ { no: 1, name: "photo", kind: "message", oneof: "media", T: () => Photo },
8765
+ { no: 2, name: "video", kind: "message", oneof: "media", T: () => Video },
8766
+ { no: 3, name: "document", kind: "message", oneof: "media", T: () => Document },
8767
+ { no: 4, name: "external_video", kind: "message", oneof: "media", T: () => UrlPreviewExternalVideo },
8768
+ { no: 5, name: "embed", kind: "message", oneof: "media", T: () => UrlPreviewEmbed }
8769
+ ]);
8770
+ }
8771
+ create(value) {
8772
+ const message = globalThis.Object.create(this.messagePrototype);
8773
+ message.media = { oneofKind: undefined };
8774
+ if (value !== undefined)
8775
+ import_runtime3.reflectionMergePartial(this, message, value);
8776
+ return message;
8777
+ }
8778
+ internalBinaryRead(reader, length, options, target) {
8779
+ let message = target ?? this.create(), end = reader.pos + length;
8780
+ while (reader.pos < end) {
8781
+ let [fieldNo, wireType] = reader.tag();
8782
+ switch (fieldNo) {
8783
+ case 1:
8784
+ message.media = {
8785
+ oneofKind: "photo",
8786
+ photo: Photo.internalBinaryRead(reader, reader.uint32(), options, message.media.photo)
8787
+ };
8788
+ break;
8789
+ case 2:
8790
+ message.media = {
8791
+ oneofKind: "video",
8792
+ video: Video.internalBinaryRead(reader, reader.uint32(), options, message.media.video)
8793
+ };
8794
+ break;
8795
+ case 3:
8796
+ message.media = {
8797
+ oneofKind: "document",
8798
+ document: Document.internalBinaryRead(reader, reader.uint32(), options, message.media.document)
8799
+ };
8800
+ break;
8801
+ case 4:
8802
+ message.media = {
8803
+ oneofKind: "externalVideo",
8804
+ externalVideo: UrlPreviewExternalVideo.internalBinaryRead(reader, reader.uint32(), options, message.media.externalVideo)
8805
+ };
8806
+ break;
8807
+ case 5:
8808
+ message.media = {
8809
+ oneofKind: "embed",
8810
+ embed: UrlPreviewEmbed.internalBinaryRead(reader, reader.uint32(), options, message.media.embed)
8811
+ };
8812
+ break;
8813
+ default:
8814
+ let u = options.readUnknownField;
8815
+ if (u === "throw")
8816
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8817
+ let d = reader.skip(wireType);
8818
+ if (u !== false)
8819
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8820
+ }
8821
+ }
8822
+ return message;
8823
+ }
8824
+ internalBinaryWrite(message, writer, options) {
8825
+ if (message.media.oneofKind === "photo")
8826
+ Photo.internalBinaryWrite(message.media.photo, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
8827
+ if (message.media.oneofKind === "video")
8828
+ Video.internalBinaryWrite(message.media.video, writer.tag(2, import_runtime.WireType.LengthDelimited).fork(), options).join();
8829
+ if (message.media.oneofKind === "document")
8830
+ Document.internalBinaryWrite(message.media.document, writer.tag(3, import_runtime.WireType.LengthDelimited).fork(), options).join();
8831
+ if (message.media.oneofKind === "externalVideo")
8832
+ UrlPreviewExternalVideo.internalBinaryWrite(message.media.externalVideo, writer.tag(4, import_runtime.WireType.LengthDelimited).fork(), options).join();
8833
+ if (message.media.oneofKind === "embed")
8834
+ UrlPreviewEmbed.internalBinaryWrite(message.media.embed, writer.tag(5, import_runtime.WireType.LengthDelimited).fork(), options).join();
8835
+ let u = options.writeUnknownFields;
8836
+ if (u !== false)
8837
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8838
+ return writer;
8839
+ }
8840
+ }
8841
+ var UrlPreviewMedia = new UrlPreviewMedia$Type;
8842
+
8843
+ class UrlPreviewExternalVideo$Type extends import_runtime4.MessageType {
8844
+ constructor() {
8845
+ super("UrlPreviewExternalVideo", [
8846
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8847
+ { no: 2, name: "mime_type", kind: "scalar", opt: true, T: 9 },
8848
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8849
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8850
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8851
+ ]);
8852
+ }
8853
+ create(value) {
8854
+ const message = globalThis.Object.create(this.messagePrototype);
8855
+ message.url = "";
8856
+ if (value !== undefined)
8857
+ import_runtime3.reflectionMergePartial(this, message, value);
8858
+ return message;
8859
+ }
8860
+ internalBinaryRead(reader, length, options, target) {
8861
+ let message = target ?? this.create(), end = reader.pos + length;
8862
+ while (reader.pos < end) {
8863
+ let [fieldNo, wireType] = reader.tag();
8864
+ switch (fieldNo) {
8865
+ case 1:
8866
+ message.url = reader.string();
8867
+ break;
8868
+ case 2:
8869
+ message.mimeType = reader.string();
8870
+ break;
8871
+ case 3:
8872
+ message.w = reader.int32();
8873
+ break;
8874
+ case 4:
8875
+ message.h = reader.int32();
8876
+ break;
8877
+ case 5:
8878
+ message.duration = reader.int32();
8879
+ break;
8880
+ default:
8881
+ let u = options.readUnknownField;
8882
+ if (u === "throw")
8883
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8884
+ let d = reader.skip(wireType);
8885
+ if (u !== false)
8886
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8887
+ }
8888
+ }
8889
+ return message;
8890
+ }
8891
+ internalBinaryWrite(message, writer, options) {
8892
+ if (message.url !== "")
8893
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8894
+ if (message.mimeType !== undefined)
8895
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.mimeType);
8896
+ if (message.w !== undefined)
8897
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8898
+ if (message.h !== undefined)
8899
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8900
+ if (message.duration !== undefined)
8901
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8902
+ let u = options.writeUnknownFields;
8903
+ if (u !== false)
8904
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8905
+ return writer;
8906
+ }
8907
+ }
8908
+ var UrlPreviewExternalVideo = new UrlPreviewExternalVideo$Type;
8909
+
8910
+ class UrlPreviewEmbed$Type extends import_runtime4.MessageType {
8911
+ constructor() {
8912
+ super("UrlPreviewEmbed", [
8913
+ { no: 1, name: "url", kind: "scalar", T: 9 },
8914
+ { no: 2, name: "type", kind: "scalar", opt: true, T: 9 },
8915
+ { no: 3, name: "w", kind: "scalar", opt: true, T: 5 },
8916
+ { no: 4, name: "h", kind: "scalar", opt: true, T: 5 },
8917
+ { no: 5, name: "duration", kind: "scalar", opt: true, T: 5 }
8918
+ ]);
8919
+ }
8920
+ create(value) {
8921
+ const message = globalThis.Object.create(this.messagePrototype);
8922
+ message.url = "";
8923
+ if (value !== undefined)
8924
+ import_runtime3.reflectionMergePartial(this, message, value);
8925
+ return message;
8926
+ }
8927
+ internalBinaryRead(reader, length, options, target) {
8928
+ let message = target ?? this.create(), end = reader.pos + length;
8929
+ while (reader.pos < end) {
8930
+ let [fieldNo, wireType] = reader.tag();
8931
+ switch (fieldNo) {
8932
+ case 1:
8933
+ message.url = reader.string();
8934
+ break;
8935
+ case 2:
8936
+ message.type = reader.string();
8937
+ break;
8938
+ case 3:
8939
+ message.w = reader.int32();
8940
+ break;
8941
+ case 4:
8942
+ message.h = reader.int32();
8943
+ break;
8944
+ case 5:
8945
+ message.duration = reader.int32();
8946
+ break;
8947
+ default:
8948
+ let u = options.readUnknownField;
8949
+ if (u === "throw")
8950
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
8951
+ let d = reader.skip(wireType);
8952
+ if (u !== false)
8953
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
8954
+ }
8955
+ }
8956
+ return message;
8957
+ }
8958
+ internalBinaryWrite(message, writer, options) {
8959
+ if (message.url !== "")
8960
+ writer.tag(1, import_runtime.WireType.LengthDelimited).string(message.url);
8961
+ if (message.type !== undefined)
8962
+ writer.tag(2, import_runtime.WireType.LengthDelimited).string(message.type);
8963
+ if (message.w !== undefined)
8964
+ writer.tag(3, import_runtime.WireType.Varint).int32(message.w);
8965
+ if (message.h !== undefined)
8966
+ writer.tag(4, import_runtime.WireType.Varint).int32(message.h);
8967
+ if (message.duration !== undefined)
8968
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.duration);
8969
+ let u = options.writeUnknownFields;
8970
+ if (u !== false)
8971
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
8972
+ return writer;
8973
+ }
8974
+ }
8975
+ var UrlPreviewEmbed = new UrlPreviewEmbed$Type;
8976
+
8977
+ class UrlPreviewLayout$Type extends import_runtime4.MessageType {
8978
+ constructor() {
8979
+ super("UrlPreviewLayout", [
8980
+ { no: 1, name: "has_large_media", kind: "scalar", T: 8 },
8981
+ { no: 2, name: "show_large_media", kind: "scalar", T: 8 }
8982
+ ]);
8983
+ }
8984
+ create(value) {
8985
+ const message = globalThis.Object.create(this.messagePrototype);
8986
+ message.hasLargeMedia = false;
8987
+ message.showLargeMedia = false;
8988
+ if (value !== undefined)
8989
+ import_runtime3.reflectionMergePartial(this, message, value);
8990
+ return message;
8991
+ }
8992
+ internalBinaryRead(reader, length, options, target) {
8993
+ let message = target ?? this.create(), end = reader.pos + length;
8994
+ while (reader.pos < end) {
8995
+ let [fieldNo, wireType] = reader.tag();
8996
+ switch (fieldNo) {
8997
+ case 1:
8998
+ message.hasLargeMedia = reader.bool();
8999
+ break;
9000
+ case 2:
9001
+ message.showLargeMedia = reader.bool();
9002
+ break;
9003
+ default:
9004
+ let u = options.readUnknownField;
9005
+ if (u === "throw")
9006
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
9007
+ let d = reader.skip(wireType);
9008
+ if (u !== false)
9009
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
9010
+ }
9011
+ }
9012
+ return message;
9013
+ }
9014
+ internalBinaryWrite(message, writer, options) {
9015
+ if (message.hasLargeMedia !== false)
9016
+ writer.tag(1, import_runtime.WireType.Varint).bool(message.hasLargeMedia);
9017
+ if (message.showLargeMedia !== false)
9018
+ writer.tag(2, import_runtime.WireType.Varint).bool(message.showLargeMedia);
9019
+ let u = options.writeUnknownFields;
9020
+ if (u !== false)
9021
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
9022
+ return writer;
9023
+ }
9024
+ }
9025
+ var UrlPreviewLayout = new UrlPreviewLayout$Type;
9026
+
8568
9027
  class MessageAttachmentExternalTask$Type extends import_runtime4.MessageType {
8569
9028
  constructor() {
8570
9029
  super("MessageAttachmentExternalTask", [
@@ -9458,7 +9917,10 @@ class RpcCall$Type extends import_runtime4.MessageType {
9458
9917
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "input", T: () => AnswerMessageActionInput },
9459
9918
  { no: 51, name: "revokeSession", kind: "message", oneof: "input", T: () => RevokeSessionInput },
9460
9919
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "input", T: () => UpdateDialogOpenInput },
9461
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput }
9920
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "input", T: () => UpdateDialogOrderInput },
9921
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "input", T: () => ClearChatHistoryInput },
9922
+ { no: 55, name: "deleteBot", kind: "message", oneof: "input", T: () => DeleteBotInput },
9923
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "input", T: () => DeleteMessageAttachmentInput }
9462
9924
  ]);
9463
9925
  }
9464
9926
  create(value) {
@@ -9789,6 +10251,24 @@ class RpcCall$Type extends import_runtime4.MessageType {
9789
10251
  updateDialogOrder: UpdateDialogOrderInput.internalBinaryRead(reader, reader.uint32(), options, message.input.updateDialogOrder)
9790
10252
  };
9791
10253
  break;
10254
+ case 54:
10255
+ message.input = {
10256
+ oneofKind: "clearChatHistory",
10257
+ clearChatHistory: ClearChatHistoryInput.internalBinaryRead(reader, reader.uint32(), options, message.input.clearChatHistory)
10258
+ };
10259
+ break;
10260
+ case 55:
10261
+ message.input = {
10262
+ oneofKind: "deleteBot",
10263
+ deleteBot: DeleteBotInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteBot)
10264
+ };
10265
+ break;
10266
+ case 56:
10267
+ message.input = {
10268
+ oneofKind: "deleteMessageAttachment",
10269
+ deleteMessageAttachment: DeleteMessageAttachmentInput.internalBinaryRead(reader, reader.uint32(), options, message.input.deleteMessageAttachment)
10270
+ };
10271
+ break;
9792
10272
  default:
9793
10273
  let u = options.readUnknownField;
9794
10274
  if (u === "throw")
@@ -9907,6 +10387,12 @@ class RpcCall$Type extends import_runtime4.MessageType {
9907
10387
  UpdateDialogOpenInput.internalBinaryWrite(message.input.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
9908
10388
  if (message.input.oneofKind === "updateDialogOrder")
9909
10389
  UpdateDialogOrderInput.internalBinaryWrite(message.input.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10390
+ if (message.input.oneofKind === "clearChatHistory")
10391
+ ClearChatHistoryInput.internalBinaryWrite(message.input.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10392
+ if (message.input.oneofKind === "deleteBot")
10393
+ DeleteBotInput.internalBinaryWrite(message.input.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10394
+ if (message.input.oneofKind === "deleteMessageAttachment")
10395
+ DeleteMessageAttachmentInput.internalBinaryWrite(message.input.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
9910
10396
  let u = options.writeUnknownFields;
9911
10397
  if (u !== false)
9912
10398
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -9970,7 +10456,10 @@ class RpcResult$Type extends import_runtime4.MessageType {
9970
10456
  { no: 50, name: "answerMessageAction", kind: "message", oneof: "result", T: () => AnswerMessageActionResult },
9971
10457
  { no: 51, name: "revokeSession", kind: "message", oneof: "result", T: () => RevokeSessionResult },
9972
10458
  { no: 52, name: "updateDialogOpen", kind: "message", oneof: "result", T: () => UpdateDialogOpenResult },
9973
- { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult }
10459
+ { no: 53, name: "updateDialogOrder", kind: "message", oneof: "result", T: () => UpdateDialogOrderResult },
10460
+ { no: 54, name: "clearChatHistory", kind: "message", oneof: "result", T: () => ClearChatHistoryResult },
10461
+ { no: 55, name: "deleteBot", kind: "message", oneof: "result", T: () => DeleteBotResult },
10462
+ { no: 56, name: "deleteMessageAttachment", kind: "message", oneof: "result", T: () => DeleteMessageAttachmentResult }
9974
10463
  ]);
9975
10464
  }
9976
10465
  create(value) {
@@ -10301,6 +10790,24 @@ class RpcResult$Type extends import_runtime4.MessageType {
10301
10790
  updateDialogOrder: UpdateDialogOrderResult.internalBinaryRead(reader, reader.uint32(), options, message.result.updateDialogOrder)
10302
10791
  };
10303
10792
  break;
10793
+ case 54:
10794
+ message.result = {
10795
+ oneofKind: "clearChatHistory",
10796
+ clearChatHistory: ClearChatHistoryResult.internalBinaryRead(reader, reader.uint32(), options, message.result.clearChatHistory)
10797
+ };
10798
+ break;
10799
+ case 55:
10800
+ message.result = {
10801
+ oneofKind: "deleteBot",
10802
+ deleteBot: DeleteBotResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteBot)
10803
+ };
10804
+ break;
10805
+ case 56:
10806
+ message.result = {
10807
+ oneofKind: "deleteMessageAttachment",
10808
+ deleteMessageAttachment: DeleteMessageAttachmentResult.internalBinaryRead(reader, reader.uint32(), options, message.result.deleteMessageAttachment)
10809
+ };
10810
+ break;
10304
10811
  default:
10305
10812
  let u = options.readUnknownField;
10306
10813
  if (u === "throw")
@@ -10419,6 +10926,12 @@ class RpcResult$Type extends import_runtime4.MessageType {
10419
10926
  UpdateDialogOpenResult.internalBinaryWrite(message.result.updateDialogOpen, writer.tag(52, import_runtime.WireType.LengthDelimited).fork(), options).join();
10420
10927
  if (message.result.oneofKind === "updateDialogOrder")
10421
10928
  UpdateDialogOrderResult.internalBinaryWrite(message.result.updateDialogOrder, writer.tag(53, import_runtime.WireType.LengthDelimited).fork(), options).join();
10929
+ if (message.result.oneofKind === "clearChatHistory")
10930
+ ClearChatHistoryResult.internalBinaryWrite(message.result.clearChatHistory, writer.tag(54, import_runtime.WireType.LengthDelimited).fork(), options).join();
10931
+ if (message.result.oneofKind === "deleteBot")
10932
+ DeleteBotResult.internalBinaryWrite(message.result.deleteBot, writer.tag(55, import_runtime.WireType.LengthDelimited).fork(), options).join();
10933
+ if (message.result.oneofKind === "deleteMessageAttachment")
10934
+ DeleteMessageAttachmentResult.internalBinaryWrite(message.result.deleteMessageAttachment, writer.tag(56, import_runtime.WireType.LengthDelimited).fork(), options).join();
10422
10935
  let u = options.writeUnknownFields;
10423
10936
  if (u !== false)
10424
10937
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -10604,7 +11117,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10604
11117
  { no: 1, name: "bucket", kind: "message", T: () => UpdateBucket },
10605
11118
  { no: 2, name: "start_seq", kind: "scalar", T: 3, L: 0 },
10606
11119
  { no: 3, name: "total_limit", kind: "scalar", T: 5 },
10607
- { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 }
11120
+ { no: 4, name: "seq_end", kind: "scalar", T: 3, L: 0 },
11121
+ { no: 5, name: "limit", kind: "scalar", T: 5 }
10608
11122
  ]);
10609
11123
  }
10610
11124
  create(value) {
@@ -10612,6 +11126,7 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10612
11126
  message.startSeq = 0n;
10613
11127
  message.totalLimit = 0;
10614
11128
  message.seqEnd = 0n;
11129
+ message.limit = 0;
10615
11130
  if (value !== undefined)
10616
11131
  import_runtime3.reflectionMergePartial(this, message, value);
10617
11132
  return message;
@@ -10633,6 +11148,9 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10633
11148
  case 4:
10634
11149
  message.seqEnd = reader.int64().toBigInt();
10635
11150
  break;
11151
+ case 5:
11152
+ message.limit = reader.int32();
11153
+ break;
10636
11154
  default:
10637
11155
  let u = options.readUnknownField;
10638
11156
  if (u === "throw")
@@ -10653,6 +11171,8 @@ class GetUpdatesInput$Type extends import_runtime4.MessageType {
10653
11171
  writer.tag(3, import_runtime.WireType.Varint).int32(message.totalLimit);
10654
11172
  if (message.seqEnd !== 0n)
10655
11173
  writer.tag(4, import_runtime.WireType.Varint).int64(message.seqEnd);
11174
+ if (message.limit !== 0)
11175
+ writer.tag(5, import_runtime.WireType.Varint).int32(message.limit);
10656
11176
  let u = options.writeUnknownFields;
10657
11177
  if (u !== false)
10658
11178
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -11779,6 +12299,191 @@ class ListBotsResult$Type extends import_runtime4.MessageType {
11779
12299
  }
11780
12300
  var ListBotsResult = new ListBotsResult$Type;
11781
12301
 
12302
+ class DeleteBotInput$Type extends import_runtime4.MessageType {
12303
+ constructor() {
12304
+ super("DeleteBotInput", [
12305
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12306
+ ]);
12307
+ }
12308
+ create(value) {
12309
+ const message = globalThis.Object.create(this.messagePrototype);
12310
+ message.botUserId = 0n;
12311
+ if (value !== undefined)
12312
+ import_runtime3.reflectionMergePartial(this, message, value);
12313
+ return message;
12314
+ }
12315
+ internalBinaryRead(reader, length, options, target) {
12316
+ let message = target ?? this.create(), end = reader.pos + length;
12317
+ while (reader.pos < end) {
12318
+ let [fieldNo, wireType] = reader.tag();
12319
+ switch (fieldNo) {
12320
+ case 1:
12321
+ message.botUserId = reader.int64().toBigInt();
12322
+ break;
12323
+ default:
12324
+ let u = options.readUnknownField;
12325
+ if (u === "throw")
12326
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12327
+ let d = reader.skip(wireType);
12328
+ if (u !== false)
12329
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12330
+ }
12331
+ }
12332
+ return message;
12333
+ }
12334
+ internalBinaryWrite(message, writer, options) {
12335
+ if (message.botUserId !== 0n)
12336
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12337
+ let u = options.writeUnknownFields;
12338
+ if (u !== false)
12339
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12340
+ return writer;
12341
+ }
12342
+ }
12343
+ var DeleteBotInput = new DeleteBotInput$Type;
12344
+
12345
+ class DeleteBotResult$Type extends import_runtime4.MessageType {
12346
+ constructor() {
12347
+ super("DeleteBotResult", [
12348
+ { no: 1, name: "bot_user_id", kind: "scalar", T: 3, L: 0 }
12349
+ ]);
12350
+ }
12351
+ create(value) {
12352
+ const message = globalThis.Object.create(this.messagePrototype);
12353
+ message.botUserId = 0n;
12354
+ if (value !== undefined)
12355
+ import_runtime3.reflectionMergePartial(this, message, value);
12356
+ return message;
12357
+ }
12358
+ internalBinaryRead(reader, length, options, target) {
12359
+ let message = target ?? this.create(), end = reader.pos + length;
12360
+ while (reader.pos < end) {
12361
+ let [fieldNo, wireType] = reader.tag();
12362
+ switch (fieldNo) {
12363
+ case 1:
12364
+ message.botUserId = reader.int64().toBigInt();
12365
+ break;
12366
+ default:
12367
+ let u = options.readUnknownField;
12368
+ if (u === "throw")
12369
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12370
+ let d = reader.skip(wireType);
12371
+ if (u !== false)
12372
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12373
+ }
12374
+ }
12375
+ return message;
12376
+ }
12377
+ internalBinaryWrite(message, writer, options) {
12378
+ if (message.botUserId !== 0n)
12379
+ writer.tag(1, import_runtime.WireType.Varint).int64(message.botUserId);
12380
+ let u = options.writeUnknownFields;
12381
+ if (u !== false)
12382
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12383
+ return writer;
12384
+ }
12385
+ }
12386
+ var DeleteBotResult = new DeleteBotResult$Type;
12387
+
12388
+ class DeleteMessageAttachmentInput$Type extends import_runtime4.MessageType {
12389
+ constructor() {
12390
+ super("DeleteMessageAttachmentInput", [
12391
+ { no: 1, name: "peer_id", kind: "message", T: () => InputPeer },
12392
+ { no: 2, name: "message_id", kind: "scalar", T: 3, L: 0 },
12393
+ { no: 3, name: "attachment_id", kind: "scalar", T: 3, L: 0 }
12394
+ ]);
12395
+ }
12396
+ create(value) {
12397
+ const message = globalThis.Object.create(this.messagePrototype);
12398
+ message.messageId = 0n;
12399
+ message.attachmentId = 0n;
12400
+ if (value !== undefined)
12401
+ import_runtime3.reflectionMergePartial(this, message, value);
12402
+ return message;
12403
+ }
12404
+ internalBinaryRead(reader, length, options, target) {
12405
+ let message = target ?? this.create(), end = reader.pos + length;
12406
+ while (reader.pos < end) {
12407
+ let [fieldNo, wireType] = reader.tag();
12408
+ switch (fieldNo) {
12409
+ case 1:
12410
+ message.peerId = InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.peerId);
12411
+ break;
12412
+ case 2:
12413
+ message.messageId = reader.int64().toBigInt();
12414
+ break;
12415
+ case 3:
12416
+ message.attachmentId = reader.int64().toBigInt();
12417
+ break;
12418
+ default:
12419
+ let u = options.readUnknownField;
12420
+ if (u === "throw")
12421
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12422
+ let d = reader.skip(wireType);
12423
+ if (u !== false)
12424
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12425
+ }
12426
+ }
12427
+ return message;
12428
+ }
12429
+ internalBinaryWrite(message, writer, options) {
12430
+ if (message.peerId)
12431
+ InputPeer.internalBinaryWrite(message.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12432
+ if (message.messageId !== 0n)
12433
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.messageId);
12434
+ if (message.attachmentId !== 0n)
12435
+ writer.tag(3, import_runtime.WireType.Varint).int64(message.attachmentId);
12436
+ let u = options.writeUnknownFields;
12437
+ if (u !== false)
12438
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12439
+ return writer;
12440
+ }
12441
+ }
12442
+ var DeleteMessageAttachmentInput = new DeleteMessageAttachmentInput$Type;
12443
+
12444
+ class DeleteMessageAttachmentResult$Type extends import_runtime4.MessageType {
12445
+ constructor() {
12446
+ super("DeleteMessageAttachmentResult", [
12447
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
12448
+ ]);
12449
+ }
12450
+ create(value) {
12451
+ const message = globalThis.Object.create(this.messagePrototype);
12452
+ message.updates = [];
12453
+ if (value !== undefined)
12454
+ import_runtime3.reflectionMergePartial(this, message, value);
12455
+ return message;
12456
+ }
12457
+ internalBinaryRead(reader, length, options, target) {
12458
+ let message = target ?? this.create(), end = reader.pos + length;
12459
+ while (reader.pos < end) {
12460
+ let [fieldNo, wireType] = reader.tag();
12461
+ switch (fieldNo) {
12462
+ case 1:
12463
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
12464
+ break;
12465
+ default:
12466
+ let u = options.readUnknownField;
12467
+ if (u === "throw")
12468
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
12469
+ let d = reader.skip(wireType);
12470
+ if (u !== false)
12471
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
12472
+ }
12473
+ }
12474
+ return message;
12475
+ }
12476
+ internalBinaryWrite(message, writer, options) {
12477
+ for (let i = 0;i < message.updates.length; i++)
12478
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
12479
+ let u = options.writeUnknownFields;
12480
+ if (u !== false)
12481
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
12482
+ return writer;
12483
+ }
12484
+ }
12485
+ var DeleteMessageAttachmentResult = new DeleteMessageAttachmentResult$Type;
12486
+
11782
12487
  class RevokeSessionInput$Type extends import_runtime4.MessageType {
11783
12488
  constructor() {
11784
12489
  super("RevokeSessionInput", [
@@ -13795,6 +14500,118 @@ class DeleteMessagesResult$Type extends import_runtime4.MessageType {
13795
14500
  }
13796
14501
  var DeleteMessagesResult = new DeleteMessagesResult$Type;
13797
14502
 
14503
+ class ClearChatHistoryInput$Type extends import_runtime4.MessageType {
14504
+ constructor() {
14505
+ super("ClearChatHistoryInput", [
14506
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => InputPeer },
14507
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
14508
+ { no: 2, name: "keep_last_days", kind: "scalar", T: 5 },
14509
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 }
14510
+ ]);
14511
+ }
14512
+ create(value) {
14513
+ const message = globalThis.Object.create(this.messagePrototype);
14514
+ message.target = { oneofKind: undefined };
14515
+ message.keepLastDays = 0;
14516
+ message.deleteReplyThreads = false;
14517
+ if (value !== undefined)
14518
+ import_runtime3.reflectionMergePartial(this, message, value);
14519
+ return message;
14520
+ }
14521
+ internalBinaryRead(reader, length, options, target) {
14522
+ let message = target ?? this.create(), end = reader.pos + length;
14523
+ while (reader.pos < end) {
14524
+ let [fieldNo, wireType] = reader.tag();
14525
+ switch (fieldNo) {
14526
+ case 1:
14527
+ message.target = {
14528
+ oneofKind: "peerId",
14529
+ peerId: InputPeer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
14530
+ };
14531
+ break;
14532
+ case 4:
14533
+ message.target = {
14534
+ oneofKind: "spaceId",
14535
+ spaceId: reader.int64().toBigInt()
14536
+ };
14537
+ break;
14538
+ case 2:
14539
+ message.keepLastDays = reader.int32();
14540
+ break;
14541
+ case 3:
14542
+ message.deleteReplyThreads = reader.bool();
14543
+ break;
14544
+ default:
14545
+ let u = options.readUnknownField;
14546
+ if (u === "throw")
14547
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14548
+ let d = reader.skip(wireType);
14549
+ if (u !== false)
14550
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14551
+ }
14552
+ }
14553
+ return message;
14554
+ }
14555
+ internalBinaryWrite(message, writer, options) {
14556
+ if (message.target.oneofKind === "peerId")
14557
+ InputPeer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14558
+ if (message.target.oneofKind === "spaceId")
14559
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
14560
+ if (message.keepLastDays !== 0)
14561
+ writer.tag(2, import_runtime.WireType.Varint).int32(message.keepLastDays);
14562
+ if (message.deleteReplyThreads !== false)
14563
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
14564
+ let u = options.writeUnknownFields;
14565
+ if (u !== false)
14566
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14567
+ return writer;
14568
+ }
14569
+ }
14570
+ var ClearChatHistoryInput = new ClearChatHistoryInput$Type;
14571
+
14572
+ class ClearChatHistoryResult$Type extends import_runtime4.MessageType {
14573
+ constructor() {
14574
+ super("ClearChatHistoryResult", [
14575
+ { no: 1, name: "updates", kind: "message", repeat: 1, T: () => Update }
14576
+ ]);
14577
+ }
14578
+ create(value) {
14579
+ const message = globalThis.Object.create(this.messagePrototype);
14580
+ message.updates = [];
14581
+ if (value !== undefined)
14582
+ import_runtime3.reflectionMergePartial(this, message, value);
14583
+ return message;
14584
+ }
14585
+ internalBinaryRead(reader, length, options, target) {
14586
+ let message = target ?? this.create(), end = reader.pos + length;
14587
+ while (reader.pos < end) {
14588
+ let [fieldNo, wireType] = reader.tag();
14589
+ switch (fieldNo) {
14590
+ case 1:
14591
+ message.updates.push(Update.internalBinaryRead(reader, reader.uint32(), options));
14592
+ break;
14593
+ default:
14594
+ let u = options.readUnknownField;
14595
+ if (u === "throw")
14596
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
14597
+ let d = reader.skip(wireType);
14598
+ if (u !== false)
14599
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
14600
+ }
14601
+ }
14602
+ return message;
14603
+ }
14604
+ internalBinaryWrite(message, writer, options) {
14605
+ for (let i = 0;i < message.updates.length; i++)
14606
+ Update.internalBinaryWrite(message.updates[i], writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
14607
+ let u = options.writeUnknownFields;
14608
+ if (u !== false)
14609
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
14610
+ return writer;
14611
+ }
14612
+ }
14613
+ var ClearChatHistoryResult = new ClearChatHistoryResult$Type;
14614
+
13798
14615
  class EditMessageInput$Type extends import_runtime4.MessageType {
13799
14616
  constructor() {
13800
14617
  super("EditMessageInput", [
@@ -15536,7 +16353,8 @@ class Update$Type extends import_runtime4.MessageType {
15536
16353
  { no: 33, name: "dialog_notification_settings", kind: "message", oneof: "update", T: () => UpdateDialogNotificationSettings },
15537
16354
  { no: 34, name: "chat_open", kind: "message", oneof: "update", T: () => UpdateChatOpen },
15538
16355
  { no: 35, name: "message_action_invoked", kind: "message", oneof: "update", T: () => UpdateMessageActionInvoked },
15539
- { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered }
16356
+ { no: 36, name: "message_action_answered", kind: "message", oneof: "update", T: () => UpdateMessageActionAnswered },
16357
+ { no: 37, name: "clear_chat_history", kind: "message", oneof: "update", T: () => UpdateClearChatHistory }
15540
16358
  ]);
15541
16359
  }
15542
16360
  create(value) {
@@ -15755,6 +16573,12 @@ class Update$Type extends import_runtime4.MessageType {
15755
16573
  messageActionAnswered: UpdateMessageActionAnswered.internalBinaryRead(reader, reader.uint32(), options, message.update.messageActionAnswered)
15756
16574
  };
15757
16575
  break;
16576
+ case 37:
16577
+ message.update = {
16578
+ oneofKind: "clearChatHistory",
16579
+ clearChatHistory: UpdateClearChatHistory.internalBinaryRead(reader, reader.uint32(), options, message.update.clearChatHistory)
16580
+ };
16581
+ break;
15758
16582
  default:
15759
16583
  let u = options.readUnknownField;
15760
16584
  if (u === "throw")
@@ -15837,6 +16661,8 @@ class Update$Type extends import_runtime4.MessageType {
15837
16661
  UpdateMessageActionInvoked.internalBinaryWrite(message.update.messageActionInvoked, writer.tag(35, import_runtime.WireType.LengthDelimited).fork(), options).join();
15838
16662
  if (message.update.oneofKind === "messageActionAnswered")
15839
16663
  UpdateMessageActionAnswered.internalBinaryWrite(message.update.messageActionAnswered, writer.tag(36, import_runtime.WireType.LengthDelimited).fork(), options).join();
16664
+ if (message.update.oneofKind === "clearChatHistory")
16665
+ UpdateClearChatHistory.internalBinaryWrite(message.update.clearChatHistory, writer.tag(37, import_runtime.WireType.LengthDelimited).fork(), options).join();
15840
16666
  let u = options.writeUnknownFields;
15841
16667
  if (u !== false)
15842
16668
  (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
@@ -17103,6 +17929,119 @@ class UpdateDeleteMessages$Type extends import_runtime4.MessageType {
17103
17929
  }
17104
17930
  var UpdateDeleteMessages = new UpdateDeleteMessages$Type;
17105
17931
 
17932
+ class UpdateClearChatHistory$Type extends import_runtime4.MessageType {
17933
+ constructor() {
17934
+ super("UpdateClearChatHistory", [
17935
+ { no: 1, name: "peer_id", kind: "message", oneof: "target", T: () => Peer },
17936
+ { no: 4, name: "space_id", kind: "scalar", oneof: "target", T: 3, L: 0 },
17937
+ { no: 2, name: "before_date", kind: "scalar", opt: true, T: 3, L: 0 },
17938
+ { no: 3, name: "delete_reply_threads", kind: "scalar", T: 8 },
17939
+ { no: 5, name: "deleted_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17940
+ { no: 6, name: "orphaned_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 },
17941
+ { no: 7, name: "detached_chat_ids", kind: "scalar", repeat: 1, T: 3, L: 0 }
17942
+ ]);
17943
+ }
17944
+ create(value) {
17945
+ const message = globalThis.Object.create(this.messagePrototype);
17946
+ message.target = { oneofKind: undefined };
17947
+ message.deleteReplyThreads = false;
17948
+ message.deletedChatIds = [];
17949
+ message.orphanedChatIds = [];
17950
+ message.detachedChatIds = [];
17951
+ if (value !== undefined)
17952
+ import_runtime3.reflectionMergePartial(this, message, value);
17953
+ return message;
17954
+ }
17955
+ internalBinaryRead(reader, length, options, target) {
17956
+ let message = target ?? this.create(), end = reader.pos + length;
17957
+ while (reader.pos < end) {
17958
+ let [fieldNo, wireType] = reader.tag();
17959
+ switch (fieldNo) {
17960
+ case 1:
17961
+ message.target = {
17962
+ oneofKind: "peerId",
17963
+ peerId: Peer.internalBinaryRead(reader, reader.uint32(), options, message.target.peerId)
17964
+ };
17965
+ break;
17966
+ case 4:
17967
+ message.target = {
17968
+ oneofKind: "spaceId",
17969
+ spaceId: reader.int64().toBigInt()
17970
+ };
17971
+ break;
17972
+ case 2:
17973
+ message.beforeDate = reader.int64().toBigInt();
17974
+ break;
17975
+ case 3:
17976
+ message.deleteReplyThreads = reader.bool();
17977
+ break;
17978
+ case 5:
17979
+ if (wireType === import_runtime.WireType.LengthDelimited)
17980
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17981
+ message.deletedChatIds.push(reader.int64().toBigInt());
17982
+ else
17983
+ message.deletedChatIds.push(reader.int64().toBigInt());
17984
+ break;
17985
+ case 6:
17986
+ if (wireType === import_runtime.WireType.LengthDelimited)
17987
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17988
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17989
+ else
17990
+ message.orphanedChatIds.push(reader.int64().toBigInt());
17991
+ break;
17992
+ case 7:
17993
+ if (wireType === import_runtime.WireType.LengthDelimited)
17994
+ for (let e = reader.int32() + reader.pos;reader.pos < e; )
17995
+ message.detachedChatIds.push(reader.int64().toBigInt());
17996
+ else
17997
+ message.detachedChatIds.push(reader.int64().toBigInt());
17998
+ break;
17999
+ default:
18000
+ let u = options.readUnknownField;
18001
+ if (u === "throw")
18002
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
18003
+ let d = reader.skip(wireType);
18004
+ if (u !== false)
18005
+ (u === true ? import_runtime2.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
18006
+ }
18007
+ }
18008
+ return message;
18009
+ }
18010
+ internalBinaryWrite(message, writer, options) {
18011
+ if (message.target.oneofKind === "peerId")
18012
+ Peer.internalBinaryWrite(message.target.peerId, writer.tag(1, import_runtime.WireType.LengthDelimited).fork(), options).join();
18013
+ if (message.target.oneofKind === "spaceId")
18014
+ writer.tag(4, import_runtime.WireType.Varint).int64(message.target.spaceId);
18015
+ if (message.beforeDate !== undefined)
18016
+ writer.tag(2, import_runtime.WireType.Varint).int64(message.beforeDate);
18017
+ if (message.deleteReplyThreads !== false)
18018
+ writer.tag(3, import_runtime.WireType.Varint).bool(message.deleteReplyThreads);
18019
+ if (message.deletedChatIds.length) {
18020
+ writer.tag(5, import_runtime.WireType.LengthDelimited).fork();
18021
+ for (let i = 0;i < message.deletedChatIds.length; i++)
18022
+ writer.int64(message.deletedChatIds[i]);
18023
+ writer.join();
18024
+ }
18025
+ if (message.orphanedChatIds.length) {
18026
+ writer.tag(6, import_runtime.WireType.LengthDelimited).fork();
18027
+ for (let i = 0;i < message.orphanedChatIds.length; i++)
18028
+ writer.int64(message.orphanedChatIds[i]);
18029
+ writer.join();
18030
+ }
18031
+ if (message.detachedChatIds.length) {
18032
+ writer.tag(7, import_runtime.WireType.LengthDelimited).fork();
18033
+ for (let i = 0;i < message.detachedChatIds.length; i++)
18034
+ writer.int64(message.detachedChatIds[i]);
18035
+ writer.join();
18036
+ }
18037
+ let u = options.writeUnknownFields;
18038
+ if (u !== false)
18039
+ (u == true ? import_runtime2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
18040
+ return writer;
18041
+ }
18042
+ }
18043
+ var UpdateClearChatHistory = new UpdateClearChatHistory$Type;
18044
+
17106
18045
  class UpdateMessageId$Type extends import_runtime4.MessageType {
17107
18046
  constructor() {
17108
18047
  super("UpdateMessageId", [
@@ -19243,7 +20182,7 @@ function describeConnectionError(error) {
19243
20182
  return `server connection error${code != null ? ` (code=${code})` : ""}: ${message}`;
19244
20183
  }
19245
20184
 
19246
- // ../../node_modules/.bun/ws@8.20.1/node_modules/ws/wrapper.mjs
20185
+ // ../../node_modules/.bun/ws@8.21.0/node_modules/ws/wrapper.mjs
19247
20186
  var import_stream = __toESM(require_stream(), 1);
19248
20187
  var import_extension = __toESM(require_extension(), 1);
19249
20188
  var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
@@ -19537,7 +20476,8 @@ var rpcInputKindByMethod = {
19537
20476
  37: "updateBotProfile",
19538
20477
  38: "getMessages",
19539
20478
  48: "invokeMessageAction",
19540
- 49: "answerMessageAction"
20479
+ 49: "answerMessageAction",
20480
+ 53: "clearChatHistory"
19541
20481
  };
19542
20482
  var rpcResultKindByMethod = {
19543
20483
  0: undefined,
@@ -19580,7 +20520,8 @@ var rpcResultKindByMethod = {
19580
20520
  37: "updateBotProfile",
19581
20521
  38: "getMessages",
19582
20522
  48: "invokeMessageAction",
19583
- 49: "answerMessageAction"
20523
+ 49: "answerMessageAction",
20524
+ 53: "clearChatHistory"
19584
20525
  };
19585
20526
 
19586
20527
  // ../sdk/dist/sdk/logger.js
@@ -19617,6 +20558,7 @@ var defaultApiBaseUrl = "https://api.inline.chat";
19617
20558
  var defaultVideoWidth = 1280;
19618
20559
  var defaultVideoHeight = 720;
19619
20560
  var defaultVideoDuration = 1;
20561
+ var defaultCatchUpPageLimit = 200;
19620
20562
  var defaultCatchUpTotalLimit = 1000;
19621
20563
  var defaultColdStartCatchUpWindow = defaultCatchUpTotalLimit;
19622
20564
  function extractFirstMessageId(updates) {
@@ -19755,7 +20697,12 @@ class InlineSdkClient {
19755
20697
  const chat = result.getChat.chat;
19756
20698
  if (!chat)
19757
20699
  throw new Error("getChat: missing chat");
19758
- return { chatId: chat.id, peer: chat.peerId, title: chat.title };
20700
+ return {
20701
+ chatId: chat.id,
20702
+ peer: chat.peerId,
20703
+ title: chat.title,
20704
+ ...chat.lastMsgId != null ? { lastMsgId: chat.lastMsgId } : {}
20705
+ };
19759
20706
  }
19760
20707
  async getMessages(params) {
19761
20708
  const peerId = this.inputPeerFromTarget(params, "getMessages");
@@ -19769,6 +20716,18 @@ class InlineSdkClient {
19769
20716
  });
19770
20717
  return { messages: result.getMessages.messages };
19771
20718
  }
20719
+ async clearChatHistory(params) {
20720
+ const keepLastDays = normalizeKeepLastDays(params.keepLastDays);
20721
+ const target = this.clearHistoryTargetFromParams(params);
20722
+ await this.invoke(Method.CLEAR_CHAT_HISTORY, {
20723
+ oneofKind: "clearChatHistory",
20724
+ clearChatHistory: {
20725
+ target,
20726
+ keepLastDays,
20727
+ deleteReplyThreads: params.deleteReplyThreads ?? false
20728
+ }
20729
+ });
20730
+ }
19772
20731
  async sendMessage(params) {
19773
20732
  if (params.entities != null && params.parseMarkdown != null) {
19774
20733
  throw new Error("sendMessage: provide either `entities` or `parseMarkdown`, not both");
@@ -20070,6 +21029,36 @@ class InlineSdkClient {
20070
21029
  });
20071
21030
  return;
20072
21031
  }
21032
+ case "clearChatHistory": {
21033
+ const payload = update.update.clearChatHistory;
21034
+ if (payload.target.oneofKind === "spaceId") {
21035
+ await this.eventStream.send({
21036
+ kind: "space.history.clear",
21037
+ spaceId: payload.target.spaceId,
21038
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
21039
+ deleteReplyThreads: payload.deleteReplyThreads,
21040
+ seq,
21041
+ date
21042
+ });
21043
+ return;
21044
+ }
21045
+ const peerId = payload.target.oneofKind === "peerId" ? payload.target.peerId : undefined;
21046
+ const chatId = peerId?.type.oneofKind === "chat" ? peerId.type.chat.chatId : null;
21047
+ if (!chatId) {
21048
+ this.log.warn?.("Skipping clearChatHistory update without chat peer", peerId);
21049
+ return;
21050
+ }
21051
+ this.bumpChatSeq(chatId, seq);
21052
+ await this.eventStream.send({
21053
+ kind: "message.history.clear",
21054
+ chatId,
21055
+ ...payload.beforeDate != null ? { beforeDate: payload.beforeDate } : {},
21056
+ deleteReplyThreads: payload.deleteReplyThreads,
21057
+ seq,
21058
+ date
21059
+ });
21060
+ return;
21061
+ }
20073
21062
  case "updateReaction": {
20074
21063
  const reaction = update.update.updateReaction.reaction;
20075
21064
  if (!reaction)
@@ -20213,7 +21202,8 @@ class InlineSdkClient {
20213
21202
  }
20214
21203
  }),
20215
21204
  startSeq: BigInt(cursor),
20216
- totalLimit: defaultCatchUpTotalLimit
21205
+ totalLimit: defaultCatchUpTotalLimit,
21206
+ limit: defaultCatchUpPageLimit
20217
21207
  })
20218
21208
  });
20219
21209
  const payload = result.getUpdates;
@@ -20310,7 +21300,8 @@ class InlineSdkClient {
20310
21300
  }),
20311
21301
  startSeq: BigInt(cursor),
20312
21302
  seqEnd: BigInt(endSeq),
20313
- totalLimit: defaultCatchUpTotalLimit
21303
+ totalLimit: defaultCatchUpTotalLimit,
21304
+ limit: defaultCatchUpPageLimit
20314
21305
  })
20315
21306
  });
20316
21307
  const payload = result.getUpdates;
@@ -20374,6 +21365,18 @@ class InlineSdkClient {
20374
21365
  type: { oneofKind: "chat", chat: { chatId: asInlineId(params.chatId, "chatId") } }
20375
21366
  });
20376
21367
  }
21368
+ clearHistoryTargetFromParams(params) {
21369
+ const hasChatId = params.chatId != null;
21370
+ const hasUserId = params.userId != null;
21371
+ const hasSpaceId = params.spaceId != null;
21372
+ if ([hasChatId, hasUserId, hasSpaceId].filter(Boolean).length !== 1) {
21373
+ throw new Error("clearChatHistory: provide exactly one of `chatId`, `userId`, or `spaceId`");
21374
+ }
21375
+ if (hasSpaceId) {
21376
+ return { oneofKind: "spaceId", spaceId: asInlineId(params.spaceId, "spaceId") };
21377
+ }
21378
+ return { oneofKind: "peerId", peerId: this.inputPeerFromTarget(params, "clearChatHistory") };
21379
+ }
20377
21380
  async loadState() {
20378
21381
  const store = this.options.state;
20379
21382
  if (!store)
@@ -20550,6 +21553,12 @@ function normalizePositiveInt(value, field) {
20550
21553
  }
20551
21554
  return value;
20552
21555
  }
21556
+ function normalizeKeepLastDays(value) {
21557
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > 36500) {
21558
+ throw new Error("clearChatHistory: `keepLastDays` must be 0 or a positive integer up to 36500");
21559
+ }
21560
+ return value;
21561
+ }
20553
21562
  async function parseJsonResponse(response) {
20554
21563
  const contentType = response.headers.get("content-type") ?? "";
20555
21564
  if (!contentType.includes("application/json")) {
@@ -35203,10 +36212,15 @@ var InlineActionsSchema = exports_external.object({
35203
36212
  var InlineCapabilitiesSchema = exports_external.object({
35204
36213
  replyThreads: exports_external.boolean().optional()
35205
36214
  }).strict();
36215
+ var InlineReplyThreadModeSchema = exports_external.enum(["auto", "thread", "main"]);
35206
36216
  var InlineTargetSchema = exports_external.union([exports_external.string(), exports_external.number()]);
35207
36217
  var InlineAllowEntrySchema = exports_external.union([exports_external.string(), exports_external.number()]);
35208
36218
  var InlineGroupSchema = exports_external.object({
35209
36219
  requireMention: exports_external.boolean().optional(),
36220
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36221
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36222
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36223
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35210
36224
  allowFrom: exports_external.array(InlineAllowEntrySchema).optional(),
35211
36225
  systemPrompt: exports_external.string().optional(),
35212
36226
  tools: ToolPolicySchema.optional(),
@@ -35246,6 +36260,7 @@ var InlineStreamingSchema = exports_external.union([
35246
36260
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35247
36261
  labels: exports_external.array(exports_external.string()).optional(),
35248
36262
  maxLines: exports_external.number().int().positive().optional(),
36263
+ maxLineChars: exports_external.number().int().positive().optional(),
35249
36264
  render: exports_external.enum(["text", "rich"]).optional(),
35250
36265
  toolProgress: exports_external.boolean().optional(),
35251
36266
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35273,6 +36288,7 @@ var InlineRuntimeStreamingSchema = exports_external.union([
35273
36288
  label: exports_external.union([exports_external.string(), exports_external.literal(false)]).optional(),
35274
36289
  labels: exports_external.array(exports_external.string()).optional(),
35275
36290
  maxLines: exports_external.number().int().positive().optional(),
36291
+ maxLineChars: exports_external.number().int().positive().optional(),
35276
36292
  render: exports_external.enum(["text", "rich"]).optional(),
35277
36293
  toolProgress: exports_external.boolean().optional(),
35278
36294
  commandText: InlineStreamingCommandTextSchema.optional()
@@ -35298,6 +36314,10 @@ var InlineAccountSchemaBase = exports_external.object({
35298
36314
  groupPolicy: GroupPolicySchema.optional().default("allowlist"),
35299
36315
  groups: exports_external.record(exports_external.string(), InlineGroupSchema.optional()).optional(),
35300
36316
  requireMention: exports_external.boolean().optional(),
36317
+ replyThreadMode: InlineReplyThreadModeSchema.optional(),
36318
+ replyThreadAutoCreateMinMessages: exports_external.number().int().min(0).optional(),
36319
+ replyThreadRequireExplicitMention: exports_external.boolean().optional(),
36320
+ replyThreadParentHistoryLimit: exports_external.number().int().min(0).optional(),
35301
36321
  replyToBotWithoutMention: exports_external.boolean().optional(),
35302
36322
  historyLimit: exports_external.number().int().min(0).optional(),
35303
36323
  dmHistoryLimit: exports_external.number().int().min(0).optional(),
@@ -35569,9 +36589,7 @@ function inspectInlineAccount(params) {
35569
36589
  }
35570
36590
  const tokenFile = account.tokenFile?.trim() ?? "";
35571
36591
  if (tokenFile) {
35572
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35573
- rejectSymlink: true
35574
- }) ?? "";
36592
+ const token = tryReadInlineTokenFile(tokenFile);
35575
36593
  return {
35576
36594
  ...account,
35577
36595
  token: token || null,
@@ -35631,18 +36649,37 @@ async function resolveInlineToken(account) {
35631
36649
  }
35632
36650
  throw new Error("Inline token missing (set channels.inline.token, channels.inline.tokenFile, INLINE_TOKEN, or INLINE_BOT_TOKEN)");
35633
36651
  }
35634
- const token = tryReadSecretFileSync(tokenFile, "Inline bot token", {
35635
- rejectSymlink: true
35636
- });
36652
+ const token = readInlineTokenFile(tokenFile);
35637
36653
  if (!token)
35638
36654
  throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`);
35639
36655
  return token;
35640
36656
  }
36657
+ function tryReadInlineTokenFile(tokenFile) {
36658
+ try {
36659
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36660
+ rejectSymlink: true
36661
+ }) ?? "";
36662
+ } catch {
36663
+ return "";
36664
+ }
36665
+ }
36666
+ function readInlineTokenFile(tokenFile) {
36667
+ try {
36668
+ return tryReadSecretFileSync(tokenFile, "Inline bot token", {
36669
+ rejectSymlink: true
36670
+ }) ?? "";
36671
+ } catch (error51) {
36672
+ throw new Error(`Inline tokenFile is empty or unreadable: ${tokenFile}`, {
36673
+ cause: error51
36674
+ });
36675
+ }
36676
+ }
35641
36677
 
35642
36678
  // src/inline/reply-threads.ts
35643
36679
  var GET_CHAT_METHOD = typeof Method.GET_CHAT === "number" && Number.isInteger(Method.GET_CHAT) && Method.GET_CHAT > 0 ? Method.GET_CHAT : 25;
35644
36680
  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;
35645
36681
  var GET_MESSAGES_METHOD = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : 38;
36682
+ var CREATE_SUBTHREAD_METHOD = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 42;
35646
36683
  function buildChatPeer(chatId) {
35647
36684
  return {
35648
36685
  type: {
@@ -35652,21 +36689,14 @@ function buildChatPeer(chatId) {
35652
36689
  };
35653
36690
  }
35654
36691
  function getInlineReplyThreadsCapabilityConfig(params) {
35655
- const account = resolveInlineAccount({
35656
- cfg: params.cfg,
35657
- accountId: params.accountId ?? null
35658
- });
35659
- return {
35660
- replyThreads: account.config.capabilities?.replyThreads === true
35661
- };
36692
+ return { replyThreads: true };
35662
36693
  }
35663
36694
  function isInlineReplyThreadsEnabled(params) {
35664
36695
  return getInlineReplyThreadsCapabilityConfig(params).replyThreads;
35665
36696
  }
35666
36697
  function resolveInlineReplyThreadChatId(params) {
35667
- if (!isInlineReplyThreadsEnabled({ cfg: params.cfg, accountId: params.accountId ?? null })) {
35668
- return params.parentChatId;
35669
- }
36698
+ params.cfg;
36699
+ params.accountId;
35670
36700
  if (params.parentChatId == null) {
35671
36701
  return null;
35672
36702
  }
@@ -35729,6 +36759,30 @@ async function loadInlineReplyThreadAnchorMessage(params) {
35729
36759
  }
35730
36760
  return (historyResult.getChatHistory.messages ?? []).find((item) => item.id === params.parentMessageId) ?? null;
35731
36761
  }
36762
+ async function createInlineReplyThreadForMessage(params) {
36763
+ const result = await params.client.invokeRaw(CREATE_SUBTHREAD_METHOD, {
36764
+ oneofKind: "createSubthread",
36765
+ createSubthread: {
36766
+ parentChatId: params.parentChatId,
36767
+ parentMessageId: params.parentMessageId,
36768
+ participants: []
36769
+ }
36770
+ });
36771
+ if (result.oneofKind !== "createSubthread") {
36772
+ return null;
36773
+ }
36774
+ const chat = result.createSubthread.chat;
36775
+ if (!chat?.id) {
36776
+ return null;
36777
+ }
36778
+ return {
36779
+ childChatId: chat.id,
36780
+ parentChatId: chat.parentChatId ?? params.parentChatId,
36781
+ parentMessageId: chat.parentMessageId ?? params.parentMessageId,
36782
+ title: chat.title?.trim() || null,
36783
+ anchorMessage: result.createSubthread.anchorMessage ?? null
36784
+ };
36785
+ }
35732
36786
 
35733
36787
  // src/inline/normalize.ts
35734
36788
  function normalizeInlineTarget(raw) {
@@ -35757,7 +36811,7 @@ function looksLikeInlineTargetId(raw, normalizedInput) {
35757
36811
 
35758
36812
  // src/inline/monitor.ts
35759
36813
  import { mkdir } from "node:fs/promises";
35760
- import path2 from "node:path";
36814
+ import path4 from "node:path";
35761
36815
  import {
35762
36816
  buildCommandTextFromArgs,
35763
36817
  findCommandByNativeName,
@@ -35779,7 +36833,9 @@ import {
35779
36833
  createTransportActivityStatusPatch
35780
36834
  } from "openclaw/plugin-sdk/gateway-runtime";
35781
36835
  import {
36836
+ classifyChannelInboundEvent,
35782
36837
  createChannelInboundDebouncer,
36838
+ resolveUnmentionedGroupInboundPolicy,
35783
36839
  shouldDebounceTextInbound
35784
36840
  } from "openclaw/plugin-sdk/channel-inbound";
35785
36841
  import {
@@ -35799,6 +36855,16 @@ import { buildModelsProviderData } from "openclaw/plugin-sdk/models-provider-run
35799
36855
  import { listSkillCommandsForAgents as listSkillCommandsForAgents2 } from "openclaw/plugin-sdk/skill-commands-runtime";
35800
36856
  import { getPluginCommandSpecs as getPluginCommandSpecs2 } from "openclaw/plugin-sdk/plugin-runtime";
35801
36857
  import { isReasoningReplyPayload } from "openclaw/plugin-sdk/reply-payload";
36858
+ import {
36859
+ buildChannelProgressDraftLine,
36860
+ buildChannelProgressDraftLineForEntry,
36861
+ createChannelProgressDraftGate,
36862
+ formatChannelProgressDraftText,
36863
+ isChannelProgressDraftWorkToolName,
36864
+ mergeChannelProgressDraftLine,
36865
+ resolveChannelProgressDraftMaxLines,
36866
+ resolveChannelStreamingPreviewToolProgress
36867
+ } from "openclaw/plugin-sdk/channel-streaming";
35802
36868
  import {
35803
36869
  findCodeRegions,
35804
36870
  isInsideCode,
@@ -35807,8 +36873,6 @@ import {
35807
36873
  } from "openclaw/plugin-sdk/text-runtime";
35808
36874
 
35809
36875
  // src/sdk-runtime-compat.ts
35810
- var HISTORY_CONTEXT_MARKER = "[Chat messages since your last reply - for context]";
35811
- var CURRENT_MESSAGE_MARKER = "[Current message - respond to this]";
35812
36876
  var MAX_HISTORY_KEYS = 1000;
35813
36877
  var DEFAULT_GROUP_HISTORY_LIMIT = 50;
35814
36878
  function evictOldHistoryKeys(historyMap, maxKeys = MAX_HISTORY_KEYS) {
@@ -35824,20 +36888,6 @@ function evictOldHistoryKeys(historyMap, maxKeys = MAX_HISTORY_KEYS) {
35824
36888
  }
35825
36889
  }
35826
36890
  }
35827
- function buildHistoryContext(params) {
35828
- const lineBreak = params.lineBreak ?? `
35829
- `;
35830
- if (!params.historyText.trim()) {
35831
- return params.currentMessage;
35832
- }
35833
- return [
35834
- HISTORY_CONTEXT_MARKER,
35835
- params.historyText,
35836
- "",
35837
- CURRENT_MESSAGE_MARKER,
35838
- params.currentMessage
35839
- ].join(lineBreak);
35840
- }
35841
36891
  function appendHistoryEntry(params) {
35842
36892
  if (params.limit <= 0) {
35843
36893
  return [];
@@ -35854,32 +36904,6 @@ function appendHistoryEntry(params) {
35854
36904
  evictOldHistoryKeys(params.historyMap);
35855
36905
  return history;
35856
36906
  }
35857
- function buildHistoryContextFromEntries(params) {
35858
- const lineBreak = params.lineBreak ?? `
35859
- `;
35860
- const entries = params.excludeLast === false ? params.entries : params.entries.slice(0, -1);
35861
- if (entries.length === 0) {
35862
- return params.currentMessage;
35863
- }
35864
- return buildHistoryContext({
35865
- historyText: entries.map(params.formatEntry).join(lineBreak),
35866
- currentMessage: params.currentMessage,
35867
- lineBreak
35868
- });
35869
- }
35870
- function buildPendingHistoryContextFromMap(params) {
35871
- if (params.limit <= 0) {
35872
- return params.currentMessage;
35873
- }
35874
- const entries = params.historyMap.get(params.historyKey) ?? [];
35875
- return buildHistoryContextFromEntries({
35876
- entries,
35877
- currentMessage: params.currentMessage,
35878
- formatEntry: params.formatEntry,
35879
- ...params.lineBreak !== undefined ? { lineBreak: params.lineBreak } : {},
35880
- excludeLast: false
35881
- });
35882
- }
35883
36907
  function clearHistoryEntriesIfEnabled(params) {
35884
36908
  if (params.limit <= 0) {
35885
36909
  return;
@@ -36009,20 +37033,16 @@ import {
36009
37033
  import path from "node:path";
36010
37034
 
36011
37035
  // src/runtime.ts
36012
- var runtimeKey = "__inlineOpenClawRuntime";
36013
- function runtimeStore() {
36014
- return globalThis;
36015
- }
36016
- function setInlineRuntime(next) {
36017
- runtimeStore()[runtimeKey] = next;
36018
- }
36019
- function getInlineRuntime() {
36020
- const runtime = runtimeStore()[runtimeKey];
36021
- if (!runtime) {
36022
- throw new Error("Inline runtime not initialized");
36023
- }
36024
- return runtime;
36025
- }
37036
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
37037
+ var {
37038
+ setRuntime: setInlineRuntime,
37039
+ clearRuntime: clearInlineRuntime,
37040
+ tryGetRuntime: getOptionalInlineRuntime,
37041
+ getRuntime: getInlineRuntime
37042
+ } = createPluginRuntimeStore({
37043
+ pluginId: "inline",
37044
+ errorMessage: "Inline runtime not initialized"
37045
+ });
36026
37046
 
36027
37047
  // src/inline/media.ts
36028
37048
  var DEFAULT_MEDIA_MAX_MB = 300;
@@ -36594,6 +37614,315 @@ function sanitizeInlineOutgoingText(text) {
36594
37614
  });
36595
37615
  }
36596
37616
 
37617
+ // src/inline/thread-routes.ts
37618
+ import path2 from "node:path";
37619
+ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
37620
+ import { readJsonFileWithFallback, writeJsonFileAtomically } from "openclaw/plugin-sdk/json-store";
37621
+ var TTL_MS = 7 * 24 * 60 * 60 * 1000;
37622
+ var MAX_ENTRIES = 5000;
37623
+ var PERSISTENT_MAX_ENTRIES = 2000;
37624
+ var STORE_VERSION = 1;
37625
+ var PERSISTENT_NAMESPACE = "inline.reply-thread-routes";
37626
+ var INLINE_REPLY_THREAD_ROUTE_KEY = Symbol.for("openclaw.inlineReplyThreadRoutes");
37627
+ var DEFAULT_AGENT_KEY = "__any__";
37628
+ var DEFAULT_STORE_KEY = "__default__";
37629
+ var routeState;
37630
+ var persistentStore;
37631
+ var persistentStoreDisabled = false;
37632
+ function getRouteState() {
37633
+ if (routeState)
37634
+ return routeState;
37635
+ const globalStore = globalThis;
37636
+ const existing = globalStore[INLINE_REPLY_THREAD_ROUTE_KEY];
37637
+ routeState = existing ?? {
37638
+ memory: new Map,
37639
+ fileWrites: new Map
37640
+ };
37641
+ globalStore[INLINE_REPLY_THREAD_ROUTE_KEY] = routeState;
37642
+ return routeState;
37643
+ }
37644
+ function normalizePositiveId(raw) {
37645
+ if (raw == null)
37646
+ return;
37647
+ if (typeof raw === "bigint")
37648
+ return raw >= 0n ? String(raw) : undefined;
37649
+ if (typeof raw === "number") {
37650
+ return Number.isInteger(raw) && raw >= 0 ? String(raw) : undefined;
37651
+ }
37652
+ const trimmed = raw.trim();
37653
+ if (!/^\d+$/.test(trimmed))
37654
+ return;
37655
+ return trimmed;
37656
+ }
37657
+ function normalizeOptionalText(raw) {
37658
+ const trimmed = raw?.trim();
37659
+ return trimmed || undefined;
37660
+ }
37661
+ function safePathSegment(value) {
37662
+ return value.trim().replace(/[^a-z0-9._-]+/gi, "_").slice(0, 80) || "global";
37663
+ }
37664
+ function isRecord3(value) {
37665
+ return typeof value === "object" && value !== null && !Array.isArray(value);
37666
+ }
37667
+ function readString(record2, key) {
37668
+ const value = record2[key];
37669
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
37670
+ }
37671
+ function readTimestamp(record2, key, fallback) {
37672
+ const value = record2[key];
37673
+ return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : fallback;
37674
+ }
37675
+ function normalizeRecord(value) {
37676
+ if (!isRecord3(value))
37677
+ return null;
37678
+ const accountId = readString(value, "accountId");
37679
+ const parentChatId = normalizePositiveId(readString(value, "parentChatId"));
37680
+ const threadId = normalizePositiveId(readString(value, "threadId"));
37681
+ if (!accountId || !parentChatId || !threadId)
37682
+ return null;
37683
+ const now = Date.now();
37684
+ const parentMessageId = normalizePositiveId(readString(value, "parentMessageId"));
37685
+ const title = normalizeOptionalText(readString(value, "title"));
37686
+ const threadLabel = normalizeOptionalText(readString(value, "threadLabel"));
37687
+ const agentId = normalizeOptionalText(readString(value, "agentId"));
37688
+ return {
37689
+ accountId,
37690
+ parentChatId,
37691
+ threadId,
37692
+ createdAt: readTimestamp(value, "createdAt", now),
37693
+ updatedAt: readTimestamp(value, "updatedAt", now),
37694
+ ...parentMessageId ? { parentMessageId } : {},
37695
+ ...title ? { title } : {},
37696
+ ...threadLabel ? { threadLabel } : {},
37697
+ ...agentId ? { agentId } : {}
37698
+ };
37699
+ }
37700
+ function isExpired(record2, now) {
37701
+ return now - record2.updatedAt > TTL_MS;
37702
+ }
37703
+ function reportRouteStateError(error51) {
37704
+ try {
37705
+ getOptionalInlineRuntime()?.logging.getChildLogger({ plugin: "inline", feature: "reply-thread-route-state" }).warn("Inline reply-thread route state failed", { error: String(error51) });
37706
+ } catch {}
37707
+ }
37708
+ function disablePersistentStore(error51) {
37709
+ persistentStoreDisabled = true;
37710
+ persistentStore = undefined;
37711
+ if (!String(error51).includes("openKeyedStore is only available")) {
37712
+ reportRouteStateError(error51);
37713
+ }
37714
+ }
37715
+ function getPersistentStore() {
37716
+ if (persistentStoreDisabled)
37717
+ return;
37718
+ if (persistentStore)
37719
+ return persistentStore;
37720
+ const openKeyedStore = getOptionalInlineRuntime()?.state?.openKeyedStore;
37721
+ if (typeof openKeyedStore !== "function")
37722
+ return;
37723
+ try {
37724
+ persistentStore = openKeyedStore({
37725
+ namespace: PERSISTENT_NAMESPACE,
37726
+ maxEntries: PERSISTENT_MAX_ENTRIES,
37727
+ defaultTtlMs: TTL_MS
37728
+ });
37729
+ return persistentStore;
37730
+ } catch (error51) {
37731
+ disablePersistentStore(error51);
37732
+ return;
37733
+ }
37734
+ }
37735
+ function resolveRoutesPath(accountId) {
37736
+ const resolveStateDir = getOptionalInlineRuntime()?.state?.resolveStateDir;
37737
+ if (typeof resolveStateDir !== "function")
37738
+ return;
37739
+ return path2.join(resolveStateDir(), "inline", "reply-thread-routes", `${safePathSegment(accountId)}.json`);
37740
+ }
37741
+ function activeKey(accountId, parentChatId, agentId) {
37742
+ return `${accountId}:parent:${parentChatId}:agent:${agentId || DEFAULT_AGENT_KEY}`;
37743
+ }
37744
+ function messageKey(accountId, parentChatId, parentMessageId) {
37745
+ return `${accountId}:parent:${parentChatId}:message:${parentMessageId}`;
37746
+ }
37747
+ function keysForRecord(record2) {
37748
+ const keys = new Set;
37749
+ if (record2.parentMessageId) {
37750
+ keys.add(messageKey(record2.accountId, record2.parentChatId, record2.parentMessageId));
37751
+ }
37752
+ if (record2.agentId) {
37753
+ keys.add(activeKey(record2.accountId, record2.parentChatId, record2.agentId));
37754
+ }
37755
+ keys.add(activeKey(record2.accountId, record2.parentChatId));
37756
+ return [...keys];
37757
+ }
37758
+ function keysForLookup(params) {
37759
+ const keys = new Set;
37760
+ if (params.parentMessageId) {
37761
+ keys.add(messageKey(params.accountId, params.parentChatId, params.parentMessageId));
37762
+ }
37763
+ if (params.agentId) {
37764
+ keys.add(activeKey(params.accountId, params.parentChatId, params.agentId));
37765
+ }
37766
+ keys.add(activeKey(params.accountId, params.parentChatId));
37767
+ return [...keys];
37768
+ }
37769
+ function setMemory(key, value, now) {
37770
+ const memory = getRouteState().memory;
37771
+ memory.delete(key);
37772
+ memory.set(key, { value, updatedAt: now });
37773
+ pruneMapToMaxSize(memory, MAX_ENTRIES);
37774
+ }
37775
+ function getMemory(key, now) {
37776
+ const memory = getRouteState().memory;
37777
+ const entry = memory.get(key);
37778
+ if (!entry)
37779
+ return;
37780
+ if (now - entry.updatedAt > TTL_MS) {
37781
+ memory.delete(key);
37782
+ return;
37783
+ }
37784
+ memory.delete(key);
37785
+ memory.set(key, { ...entry, updatedAt: now });
37786
+ return entry.value;
37787
+ }
37788
+ async function readFileRoutes(accountId) {
37789
+ const filePath = resolveRoutesPath(accountId);
37790
+ if (!filePath)
37791
+ return new Map;
37792
+ const fallback = { version: STORE_VERSION, routes: {} };
37793
+ const now = Date.now();
37794
+ try {
37795
+ const { value } = await readJsonFileWithFallback(filePath, fallback);
37796
+ if (value.version !== STORE_VERSION || !isRecord3(value.routes)) {
37797
+ return new Map;
37798
+ }
37799
+ const routes = new Map;
37800
+ for (const [key, raw] of Object.entries(value.routes)) {
37801
+ const route = normalizeRecord(raw);
37802
+ if (route && !isExpired(route, now))
37803
+ routes.set(key, route);
37804
+ }
37805
+ return routes;
37806
+ } catch (error51) {
37807
+ reportRouteStateError(error51);
37808
+ return new Map;
37809
+ }
37810
+ }
37811
+ async function writeFileRoutes(accountId, routes) {
37812
+ const filePath = resolveRoutesPath(accountId);
37813
+ if (!filePath)
37814
+ return;
37815
+ const pruned = [...routes.entries()].sort((left, right) => right[1].updatedAt - left[1].updatedAt).slice(0, PERSISTENT_MAX_ENTRIES);
37816
+ await writeJsonFileAtomically(filePath, {
37817
+ version: STORE_VERSION,
37818
+ routes: Object.fromEntries(pruned)
37819
+ });
37820
+ }
37821
+ function rememberFileRoutes(params) {
37822
+ const state = getRouteState();
37823
+ const queueKey = params.accountId || DEFAULT_STORE_KEY;
37824
+ const previous = state.fileWrites.get(queueKey) ?? Promise.resolve();
37825
+ const next = previous.catch(() => {
37826
+ return;
37827
+ }).then(async () => {
37828
+ const routes = await readFileRoutes(params.accountId);
37829
+ for (const key of params.keys) {
37830
+ routes.set(key, params.record);
37831
+ }
37832
+ await writeFileRoutes(params.accountId, routes);
37833
+ });
37834
+ state.fileWrites.set(queueKey, next);
37835
+ const cleanup = () => {
37836
+ if (state.fileWrites.get(queueKey) === next) {
37837
+ state.fileWrites.delete(queueKey);
37838
+ }
37839
+ };
37840
+ next.then(cleanup, cleanup);
37841
+ next.catch(reportRouteStateError);
37842
+ }
37843
+ function rememberInlineReplyThreadRoute(params) {
37844
+ const accountId = params.accountId.trim();
37845
+ const parentChatId = normalizePositiveId(params.parentChatId);
37846
+ const threadId = normalizePositiveId(params.threadId);
37847
+ if (!accountId || !parentChatId || !threadId)
37848
+ return null;
37849
+ const now = Date.now();
37850
+ const parentMessageId = normalizePositiveId(params.parentMessageId);
37851
+ const title = normalizeOptionalText(params.title);
37852
+ const threadLabel = normalizeOptionalText(params.threadLabel);
37853
+ const agentId = normalizeOptionalText(params.agentId);
37854
+ const record2 = {
37855
+ accountId,
37856
+ parentChatId,
37857
+ threadId,
37858
+ createdAt: now,
37859
+ updatedAt: now,
37860
+ ...parentMessageId ? { parentMessageId } : {},
37861
+ ...title ? { title } : {},
37862
+ ...threadLabel ? { threadLabel } : {},
37863
+ ...agentId ? { agentId } : {}
37864
+ };
37865
+ const keys = keysForRecord(record2);
37866
+ for (const key of keys) {
37867
+ setMemory(key, record2, now);
37868
+ }
37869
+ const store = getPersistentStore();
37870
+ if (store) {
37871
+ for (const key of keys) {
37872
+ store.register(key, record2, { ttlMs: TTL_MS }).catch(disablePersistentStore);
37873
+ }
37874
+ return record2;
37875
+ }
37876
+ rememberFileRoutes({ accountId, keys, record: record2 });
37877
+ return record2;
37878
+ }
37879
+ async function lookupInlineReplyThreadRoute(params) {
37880
+ const accountId = params.accountId.trim();
37881
+ const parentChatId = normalizePositiveId(params.parentChatId);
37882
+ if (!accountId || !parentChatId)
37883
+ return null;
37884
+ const parentMessageId = normalizePositiveId(params.parentMessageId);
37885
+ const agentId = normalizeOptionalText(params.agentId);
37886
+ const keys = keysForLookup({
37887
+ accountId,
37888
+ parentChatId,
37889
+ ...parentMessageId ? { parentMessageId } : {},
37890
+ ...agentId ? { agentId } : {}
37891
+ });
37892
+ const now = Date.now();
37893
+ for (const key of keys) {
37894
+ const cached3 = getMemory(key, now);
37895
+ if (cached3)
37896
+ return cached3;
37897
+ }
37898
+ const store = getPersistentStore();
37899
+ if (store) {
37900
+ for (const key of keys) {
37901
+ try {
37902
+ const found = await store.lookup(key);
37903
+ const normalized = normalizeRecord(found);
37904
+ if (normalized && !isExpired(normalized, now)) {
37905
+ setMemory(key, normalized, now);
37906
+ return normalized;
37907
+ }
37908
+ } catch (error51) {
37909
+ disablePersistentStore(error51);
37910
+ break;
37911
+ }
37912
+ }
37913
+ }
37914
+ const fileRoutes = await readFileRoutes(accountId);
37915
+ for (const key of keys) {
37916
+ const found = fileRoutes.get(key);
37917
+ const normalized = normalizeRecord(found);
37918
+ if (normalized) {
37919
+ setMemory(key, normalized, now);
37920
+ return normalized;
37921
+ }
37922
+ }
37923
+ return null;
37924
+ }
37925
+
36597
37926
  // src/inline/outbound-sanitize.ts
36598
37927
  var HEARTBEAT_TOKEN = "HEARTBEAT_OK";
36599
37928
  var OPENCLAW_RUNTIME_CONTEXT_NOTICE = "This context is runtime-generated, not user-authored. Keep internal details private.";
@@ -36967,7 +38296,7 @@ for (const group of ACTION_GROUPS) {
36967
38296
  }
36968
38297
  var SUPPORTED_ACTIONS = Array.from(ACTION_TO_GATE_KEY.keys());
36969
38298
  var GET_MESSAGES_METHOD2 = typeof Method.GET_MESSAGES === "number" && Number.isInteger(Method.GET_MESSAGES) && Method.GET_MESSAGES > 0 ? Method.GET_MESSAGES : null;
36970
- var CREATE_SUBTHREAD_METHOD = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 43;
38299
+ var CREATE_SUBTHREAD_METHOD2 = typeof Method.CREATE_SUBTHREAD === "number" && Number.isInteger(Method.CREATE_SUBTHREAD) && Method.CREATE_SUBTHREAD > 0 ? Method.CREATE_SUBTHREAD : 42;
36971
38300
  var INLINE_ACTION_MAX_ROWS = 8;
36972
38301
  var INLINE_ACTION_MAX_PER_ROW = 8;
36973
38302
  function suppressedInternalTextResult() {
@@ -37007,7 +38336,7 @@ function optionalVisibleActionText(raw, label) {
37007
38336
  }
37008
38337
  return visible.text.trim() || undefined;
37009
38338
  }
37010
- function isRecord3(value) {
38339
+ function isRecord4(value) {
37011
38340
  return typeof value === "object" && value !== null;
37012
38341
  }
37013
38342
  function normalizeReplyMarkupButtons(raw) {
@@ -37019,7 +38348,7 @@ function normalizeReplyMarkupButtons(raw) {
37019
38348
  continue;
37020
38349
  const row = [];
37021
38350
  for (const candidateButton of candidateRow) {
37022
- if (!isRecord3(candidateButton))
38351
+ if (!isRecord4(candidateButton))
37023
38352
  continue;
37024
38353
  const text = sanitizeInlineActionLabel(typeof candidateButton.text === "string" ? candidateButton.text : "");
37025
38354
  const callbackData = sanitizeInlineActionCallbackData(typeof candidateButton.callback_data === "string" ? candidateButton.callback_data : "");
@@ -37213,6 +38542,20 @@ function resolveReactionMessageId(params) {
37213
38542
  }
37214
38543
  return;
37215
38544
  }
38545
+ function resolveThreadParentMessageId(params) {
38546
+ const explicit = readFlexibleId(params.args, "parentMessageId") ?? readFlexibleId(params.args, "messageId") ?? readFlexibleId(params.args, "replyTo") ?? readFlexibleId(params.args, "replyToId") ?? readStringParam(params.args, "parentMessageId") ?? readStringParam(params.args, "messageId") ?? readStringParam(params.args, "replyTo") ?? readStringParam(params.args, "replyToId");
38547
+ if (explicit)
38548
+ return explicit;
38549
+ const fromContext = params.toolContext?.currentMessageId;
38550
+ if (typeof fromContext === "number" && Number.isFinite(fromContext)) {
38551
+ return String(Math.trunc(fromContext));
38552
+ }
38553
+ if (typeof fromContext === "string") {
38554
+ const trimmed = fromContext.trim();
38555
+ return trimmed || undefined;
38556
+ }
38557
+ return;
38558
+ }
37216
38559
  function parseOptionalInlineId(raw, label) {
37217
38560
  if (raw == null)
37218
38561
  return;
@@ -37587,7 +38930,7 @@ async function withInlineClient(params) {
37587
38930
  });
37588
38931
  await client.connect();
37589
38932
  try {
37590
- return await params.fn(client);
38933
+ return await params.fn(client, account);
37591
38934
  } finally {
37592
38935
  await client.close().catch(() => {});
37593
38936
  }
@@ -37856,16 +39199,16 @@ var inlineMessageActions = {
37856
39199
  }
37857
39200
  if (normalizedAction === "reply" || normalizedAction === "thread-reply") {
37858
39201
  const parseMarkdown = resolveInlineAccount({ cfg, accountId: accountId ?? null }).config.parseMarkdown ?? true;
37859
- const replyThreadsEnabled = normalizedAction === "thread-reply" && isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null });
39202
+ const isThreadReply = normalizedAction === "thread-reply";
37860
39203
  return await withInlineClient({
37861
39204
  cfg,
37862
39205
  accountId,
37863
39206
  fn: async (client) => {
37864
39207
  const actions = resolveInlineMessageActionsParam(params);
37865
- if (replyThreadsEnabled) {
39208
+ if (isThreadReply) {
37866
39209
  const rawThreadId = readFlexibleId(params, "threadId") ?? readStringParam(params, "threadId");
37867
39210
  if (!rawThreadId) {
37868
- throw new Error("inline thread-reply: threadId is required when reply threads are enabled");
39211
+ throw new Error("inline thread-reply: threadId is required. Call thread-create first or use reply for the parent chat.");
37869
39212
  }
37870
39213
  const chatId2 = parseInlineId(rawThreadId, "threadId");
37871
39214
  const replyToMsgId2 = parseOptionalInlineId(readFlexibleId(params, "messageId") ?? readFlexibleId(params, "replyTo") ?? readFlexibleId(params, "replyToId") ?? readStringParam(params, "messageId") ?? readStringParam(params, "replyTo") ?? readStringParam(params, "replyToId"), "messageId");
@@ -37889,7 +39232,7 @@ var inlineMessageActions = {
37889
39232
  replyToId: replyToMsgId2 != null ? String(replyToMsgId2) : null
37890
39233
  });
37891
39234
  }
37892
- const replyParams = normalizedAction === "thread-reply" && params.threadId != null && params.to == null && params.chatId == null && params.channelId == null ? { ...params, to: params.threadId } : params;
39235
+ const replyParams = params;
37893
39236
  const chatId = resolveChatIdFromParams(replyParams);
37894
39237
  const replyToMsgId = parseInlineId(readFlexibleId(replyParams, "messageId") ?? readFlexibleId(replyParams, "replyTo") ?? readFlexibleId(replyParams, "replyToId") ?? readStringParam(replyParams, "messageId") ?? readStringParam(replyParams, "replyTo") ?? readStringParam(replyParams, "replyToId", { required: true }), "messageId");
37895
39238
  const text = resolveInlineActionText(replyParams, { required: true });
@@ -38228,11 +39571,11 @@ var inlineMessageActions = {
38228
39571
  });
38229
39572
  }
38230
39573
  if (normalizedAction === "channel-create" || normalizedAction === "thread-create") {
38231
- const replyThreadsEnabled = normalizedAction === "thread-create" && isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null });
39574
+ const isThreadCreate = normalizedAction === "thread-create";
38232
39575
  return await withInlineClient({
38233
39576
  cfg,
38234
39577
  accountId,
38235
- fn: async (client) => {
39578
+ fn: async (client, account) => {
38236
39579
  const title = requireVisibleActionText(readStringParam(params, "title") ?? readStringParam(params, "name") ?? readStringParam(params, "threadName") ?? readStringParam(params, "message", { required: true }), "title");
38237
39580
  const description = optionalVisibleActionText(readStringParam(params, "description"), "description");
38238
39581
  const emoji3 = readStringParam(params, "emoji");
@@ -38251,10 +39594,13 @@ var inlineMessageActions = {
38251
39594
  values: participantRefs,
38252
39595
  label: "participant"
38253
39596
  });
38254
- if (replyThreadsEnabled) {
39597
+ if (isThreadCreate) {
38255
39598
  const parentChatId = resolveChatIdFromParams(params);
38256
- const parentMessageId = parseOptionalInlineId(readFlexibleId(params, "parentMessageId") ?? readFlexibleId(params, "messageId") ?? readFlexibleId(params, "replyTo") ?? readFlexibleId(params, "replyToId") ?? readStringParam(params, "parentMessageId") ?? readStringParam(params, "messageId") ?? readStringParam(params, "replyTo") ?? readStringParam(params, "replyToId"), "parentMessageId");
38257
- const result2 = await client.invokeRaw(CREATE_SUBTHREAD_METHOD, {
39599
+ const parentMessageId = parseOptionalInlineId(resolveThreadParentMessageId({
39600
+ args: params,
39601
+ ...toolContext != null ? { toolContext: { currentMessageId: toolContext.currentMessageId } } : {}
39602
+ }), "parentMessageId");
39603
+ const result2 = await client.invokeRaw(CREATE_SUBTHREAD_METHOD2, {
38258
39604
  oneofKind: "createSubthread",
38259
39605
  createSubthread: {
38260
39606
  parentChatId,
@@ -38268,12 +39614,23 @@ var inlineMessageActions = {
38268
39614
  if (result2.oneofKind !== "createSubthread") {
38269
39615
  throw new Error(`inline action: expected createSubthread result, got ${String(result2.oneofKind)}`);
38270
39616
  }
39617
+ const createdChat = result2.createSubthread.chat ?? null;
39618
+ if (createdChat?.id != null) {
39619
+ const routeParentMessageId = createdChat.parentMessageId ?? parentMessageId;
39620
+ rememberInlineReplyThreadRoute({
39621
+ accountId: account.accountId,
39622
+ parentChatId: createdChat.parentChatId ?? parentChatId,
39623
+ threadId: createdChat.id,
39624
+ title: createdChat.title ?? title,
39625
+ ...routeParentMessageId != null ? { parentMessageId: routeParentMessageId } : {}
39626
+ });
39627
+ }
38271
39628
  return jsonResult(toJsonSafe({
38272
39629
  ok: true,
38273
39630
  title,
38274
39631
  parentChatId: String(parentChatId),
38275
39632
  parentMessageId: parentMessageId != null ? String(parentMessageId) : null,
38276
- chat: result2.createSubthread.chat ?? null,
39633
+ chat: createdChat,
38277
39634
  dialog: result2.createSubthread.dialog ?? null,
38278
39635
  anchorMessage: result2.createSubthread.anchorMessage ?? null
38279
39636
  }));
@@ -38873,6 +40230,36 @@ function resolveInlineGroupRequireMention(params) {
38873
40230
  return defaultConfig.requireMention;
38874
40231
  return params.requireMentionDefault;
38875
40232
  }
40233
+ function resolveInlineGroupReplyThreadMode(params) {
40234
+ const groups = resolveInlineGroups(params.cfg, params.accountId);
40235
+ const groupConfig = resolveGroupConfig(groups, params.groupId);
40236
+ const defaultConfig = groups?.["*"];
40237
+ return groupConfig?.replyThreadMode ?? defaultConfig?.replyThreadMode ?? params.defaultMode;
40238
+ }
40239
+ function resolveInlineGroupReplyThreadAutoCreateMinMessages(params) {
40240
+ const groups = resolveInlineGroups(params.cfg, params.accountId);
40241
+ const groupConfig = resolveGroupConfig(groups, params.groupId);
40242
+ const defaultConfig = groups?.["*"];
40243
+ return groupConfig?.replyThreadAutoCreateMinMessages ?? defaultConfig?.replyThreadAutoCreateMinMessages ?? params.defaultMinMessages;
40244
+ }
40245
+ function resolveInlineGroupReplyThreadRequireExplicitMention(params) {
40246
+ const groups = resolveInlineGroups(params.cfg, params.accountId);
40247
+ const groupConfig = resolveGroupConfig(groups, params.groupId);
40248
+ const defaultConfig = groups?.["*"];
40249
+ if (typeof groupConfig?.replyThreadRequireExplicitMention === "boolean") {
40250
+ return groupConfig.replyThreadRequireExplicitMention;
40251
+ }
40252
+ if (typeof defaultConfig?.replyThreadRequireExplicitMention === "boolean") {
40253
+ return defaultConfig.replyThreadRequireExplicitMention;
40254
+ }
40255
+ return params.defaultRequireExplicitMention;
40256
+ }
40257
+ function resolveInlineGroupReplyThreadParentHistoryLimit(params) {
40258
+ const groups = resolveInlineGroups(params.cfg, params.accountId);
40259
+ const groupConfig = resolveGroupConfig(groups, params.groupId);
40260
+ const defaultConfig = groups?.["*"];
40261
+ return groupConfig?.replyThreadParentHistoryLimit ?? defaultConfig?.replyThreadParentHistoryLimit ?? params.defaultLimit;
40262
+ }
38876
40263
  function resolveInlineGroupSystemPrompt(params) {
38877
40264
  return resolveGroupConfig(params.groups, params.groupId)?.systemPrompt?.trim() || undefined;
38878
40265
  }
@@ -39071,6 +40458,134 @@ function buildInlineModelBrowseChannelData() {
39071
40458
  return inlineChannelData([[{ text: "Browse providers", callback_data: "mdl_prov" }]]);
39072
40459
  }
39073
40460
 
40461
+ // src/inline/thread-participation.ts
40462
+ import path3 from "node:path";
40463
+ import { resolveGlobalDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
40464
+ import { createPersistentDedupe } from "openclaw/plugin-sdk/persistent-dedupe";
40465
+ var TTL_MS2 = 24 * 60 * 60 * 1000;
40466
+ var MAX_ENTRIES2 = 5000;
40467
+ var PERSISTENT_MAX_ENTRIES2 = 1000;
40468
+ var PERSISTENT_NAMESPACE2 = "inline.thread-participation";
40469
+ var PERSISTENT_DEDUPE_NAMESPACE = "participation";
40470
+ var INLINE_THREAD_PARTICIPATION_KEY = Symbol.for("openclaw.inlineThreadParticipation");
40471
+ var threadParticipation = resolveGlobalDedupeCache(INLINE_THREAD_PARTICIPATION_KEY, {
40472
+ ttlMs: TTL_MS2,
40473
+ maxSize: MAX_ENTRIES2
40474
+ });
40475
+ var persistentStore2;
40476
+ var persistentStoreDisabled2 = false;
40477
+ var persistentDedupe;
40478
+ function makeKey(accountId, parentChatId, threadId) {
40479
+ return `${accountId}:${String(parentChatId)}:${String(threadId)}`;
40480
+ }
40481
+ function safePathSegment2(value) {
40482
+ return value.trim().replace(/[^a-z0-9._-]+/gi, "_").slice(0, 80) || "global";
40483
+ }
40484
+ function isExpectedOpenKeyedStoreUnavailable(error51) {
40485
+ return String(error51).includes("openKeyedStore is only available");
40486
+ }
40487
+ function reportPersistentThreadParticipationError(error51) {
40488
+ try {
40489
+ getOptionalInlineRuntime()?.logging.getChildLogger({ plugin: "inline", feature: "thread-participation-state" }).warn("Inline persistent thread participation state failed", { error: String(error51) });
40490
+ } catch {}
40491
+ }
40492
+ function disablePersistentThreadParticipation(error51) {
40493
+ persistentStoreDisabled2 = true;
40494
+ persistentStore2 = undefined;
40495
+ if (!isExpectedOpenKeyedStoreUnavailable(error51)) {
40496
+ reportPersistentThreadParticipationError(error51);
40497
+ }
40498
+ }
40499
+ function getPersistentThreadParticipationStore() {
40500
+ if (persistentStoreDisabled2)
40501
+ return;
40502
+ if (persistentStore2)
40503
+ return persistentStore2;
40504
+ const runtime = getOptionalInlineRuntime();
40505
+ const openKeyedStore = runtime?.state?.openKeyedStore;
40506
+ if (typeof openKeyedStore !== "function")
40507
+ return;
40508
+ try {
40509
+ persistentStore2 = openKeyedStore({
40510
+ namespace: PERSISTENT_NAMESPACE2,
40511
+ maxEntries: PERSISTENT_MAX_ENTRIES2,
40512
+ defaultTtlMs: TTL_MS2
40513
+ });
40514
+ return persistentStore2;
40515
+ } catch (error51) {
40516
+ disablePersistentThreadParticipation(error51);
40517
+ return;
40518
+ }
40519
+ }
40520
+ function getPersistentThreadParticipationDedupe() {
40521
+ if (persistentDedupe)
40522
+ return persistentDedupe;
40523
+ const resolveStateDir = getOptionalInlineRuntime()?.state?.resolveStateDir;
40524
+ if (typeof resolveStateDir !== "function")
40525
+ return;
40526
+ try {
40527
+ const stateDir = resolveStateDir();
40528
+ persistentDedupe = createPersistentDedupe({
40529
+ ttlMs: TTL_MS2,
40530
+ memoryMaxSize: MAX_ENTRIES2,
40531
+ fileMaxEntries: PERSISTENT_MAX_ENTRIES2,
40532
+ resolveFilePath: (namespace) => path3.join(stateDir, "inline", "thread-participation", `${safePathSegment2(namespace)}.json`),
40533
+ onDiskError: reportPersistentThreadParticipationError
40534
+ });
40535
+ return persistentDedupe;
40536
+ } catch (error51) {
40537
+ reportPersistentThreadParticipationError(error51);
40538
+ return;
40539
+ }
40540
+ }
40541
+ function rememberPersistentThreadParticipation(params) {
40542
+ const store = getPersistentThreadParticipationStore();
40543
+ if (store) {
40544
+ store.register(params.key, {
40545
+ ...params.agentId ? { agentId: params.agentId } : {},
40546
+ repliedAt: Date.now()
40547
+ }, { ttlMs: TTL_MS2 }).catch(disablePersistentThreadParticipation);
40548
+ return;
40549
+ }
40550
+ getPersistentThreadParticipationDedupe()?.checkAndRecord(params.key, { namespace: PERSISTENT_DEDUPE_NAMESPACE }).catch(reportPersistentThreadParticipationError);
40551
+ }
40552
+ async function lookupPersistentThreadParticipation(key) {
40553
+ const store = getPersistentThreadParticipationStore();
40554
+ if (!store) {
40555
+ return await getPersistentThreadParticipationDedupe()?.hasRecent(key, { namespace: PERSISTENT_DEDUPE_NAMESPACE }).catch((error51) => {
40556
+ reportPersistentThreadParticipationError(error51);
40557
+ return false;
40558
+ }) ?? false;
40559
+ }
40560
+ try {
40561
+ return Boolean(await store.lookup(key));
40562
+ } catch (error51) {
40563
+ disablePersistentThreadParticipation(error51);
40564
+ return false;
40565
+ }
40566
+ }
40567
+ function recordInlineThreadParticipation(accountId, parentChatId, threadId, opts) {
40568
+ if (!accountId || parentChatId < 0n || threadId < 0n)
40569
+ return;
40570
+ const key = makeKey(accountId, parentChatId, threadId);
40571
+ threadParticipation.check(key);
40572
+ rememberPersistentThreadParticipation({
40573
+ key,
40574
+ ...opts?.agentId ? { agentId: opts.agentId } : {}
40575
+ });
40576
+ }
40577
+ async function hasInlineThreadParticipationWithPersistence(params) {
40578
+ if (!params.accountId || params.parentChatId < 0n || params.threadId < 0n)
40579
+ return false;
40580
+ const key = makeKey(params.accountId, params.parentChatId, params.threadId);
40581
+ if (threadParticipation.peek(key))
40582
+ return true;
40583
+ const found = await lookupPersistentThreadParticipation(key);
40584
+ if (found)
40585
+ threadParticipation.check(key);
40586
+ return found;
40587
+ }
40588
+
39074
40589
  // src/inline/bot-commands-sync.ts
39075
40590
  import { listNativeCommandSpecsForConfig } from "openclaw/plugin-sdk/native-command-registry";
39076
40591
  import { getPluginCommandSpecs } from "openclaw/plugin-sdk/plugin-runtime";
@@ -39298,6 +40813,23 @@ var INLINE_NATIVE_COMMAND_PROVIDER2 = CHANNEL_ID;
39298
40813
  var INLINE_NATIVE_COMMAND_CALLBACK_PREFIX = "icmd:";
39299
40814
  var INLINE_REQUEST_ERROR_FALLBACK = "OpenClaw could not process that request. Please try again.";
39300
40815
  var INLINE_DEBOUNCE_ERROR_FALLBACK = "OpenClaw could not process those messages. Please try again.";
40816
+ var DEFAULT_REPLY_THREAD_AUTO_CREATE_MIN_MESSAGES = 50;
40817
+ var DEFAULT_REPLY_THREAD_PARENT_HISTORY_LIMIT = 10;
40818
+ function buildInlineTypingDispatcherOptions(typingCallbacks) {
40819
+ if (!typingCallbacks) {
40820
+ return {};
40821
+ }
40822
+ return {
40823
+ typingCallbacks,
40824
+ onReplyStart: typingCallbacks.onReplyStart,
40825
+ ...typingCallbacks.onIdle ? { onIdle: typingCallbacks.onIdle } : {},
40826
+ ...typingCallbacks.onCleanup ? { onCleanup: typingCallbacks.onCleanup } : {}
40827
+ };
40828
+ }
40829
+ function buildInlineReplyThreadSessionKey(parentSessionKey, threadChatId) {
40830
+ const suffix = `:thread:${String(threadChatId)}`;
40831
+ return parentSessionKey.endsWith(suffix) ? parentSessionKey : `${parentSessionKey}${suffix}`;
40832
+ }
39301
40833
  function summarizeSdkMeta(meta3) {
39302
40834
  if (meta3 == null)
39303
40835
  return "";
@@ -39320,6 +40852,7 @@ function formatSdkLogLine(message, meta3) {
39320
40852
  }
39321
40853
  var DEFAULT_DM_HISTORY_LIMIT = 6;
39322
40854
  var HISTORY_LINE_MAX_CHARS = 280;
40855
+ var REPLY_THREAD_LABEL_MAX_CHARS = 72;
39323
40856
  var URL_LIKE_PATTERN = /https?:\/\/\S+/i;
39324
40857
  var BOT_MESSAGE_CACHE_LIMIT = 500;
39325
40858
  var REACTION_TARGET_LOOKUP_LIMIT = 8;
@@ -39665,10 +41198,12 @@ function resolveInlineMentionSource(params) {
39665
41198
  return "explicit_bot";
39666
41199
  if (params.shouldBypassMention)
39667
41200
  return "command_bypass";
39668
- if (params.patternMentioned || params.wasMentioned)
41201
+ if (params.patternMentioned)
39669
41202
  return "mention_pattern";
39670
41203
  if (params.implicitMention)
39671
41204
  return "implicit_thread";
41205
+ if (params.wasMentioned)
41206
+ return "mention_pattern";
39672
41207
  return "none";
39673
41208
  }
39674
41209
  function callbackDataToBase64(data) {
@@ -39702,7 +41237,7 @@ function buildSyntheticInlineTextMessage(params) {
39702
41237
  }
39703
41238
  var INLINE_ACTION_MAX_ROWS2 = 8;
39704
41239
  var INLINE_ACTION_MAX_PER_ROW2 = 8;
39705
- function isRecord4(value) {
41240
+ function isRecord5(value) {
39706
41241
  return typeof value === "object" && value !== null && !Array.isArray(value);
39707
41242
  }
39708
41243
  function normalizeOptionalString2(value) {
@@ -39722,9 +41257,12 @@ function normalizeInlineStreamingMode(value) {
39722
41257
  return null;
39723
41258
  }
39724
41259
  }
41260
+ function resolveExplicitInlineStreamingMode(config2) {
41261
+ const streaming = isRecord5(config2.streaming) ? config2.streaming : null;
41262
+ return normalizeInlineStreamingMode(streaming?.mode) ?? normalizeInlineStreamingMode(config2.streaming) ?? normalizeInlineStreamingMode(config2.streamMode);
41263
+ }
39725
41264
  function resolveInlineStreamingMode(config2) {
39726
- const streaming = isRecord4(config2.streaming) ? config2.streaming : null;
39727
- const mode = normalizeInlineStreamingMode(streaming?.mode) ?? normalizeInlineStreamingMode(config2.streaming) ?? normalizeInlineStreamingMode(config2.streamMode);
41265
+ const mode = resolveExplicitInlineStreamingMode(config2);
39728
41266
  if (mode)
39729
41267
  return mode;
39730
41268
  if (typeof config2.streaming === "boolean") {
@@ -39732,10 +41270,22 @@ function resolveInlineStreamingMode(config2) {
39732
41270
  }
39733
41271
  return config2.streamViaEditMessage === true ? "partial" : "off";
39734
41272
  }
41273
+ function resolveInlineProgressPlaceholderEnabled(config2) {
41274
+ const mode = resolveExplicitInlineStreamingMode(config2);
41275
+ if (mode === "off")
41276
+ return false;
41277
+ if (mode === "progress")
41278
+ return true;
41279
+ if (config2.streaming === false)
41280
+ return false;
41281
+ if (isRecord5(config2.streaming) && isRecord5(config2.streaming.progress))
41282
+ return true;
41283
+ return config2.streaming === undefined && config2.streamMode === undefined && config2.streamViaEditMessage !== true;
41284
+ }
39735
41285
  function resolveInlineBlockStreamingEnabled(config2) {
39736
41286
  const mode = resolveInlineStreamingMode(config2);
39737
- const streaming = isRecord4(config2.streaming) ? config2.streaming : null;
39738
- const block = streaming && isRecord4(streaming.block) ? streaming.block : null;
41287
+ const streaming = isRecord5(config2.streaming) ? config2.streaming : null;
41288
+ const block = streaming && isRecord5(streaming.block) ? streaming.block : null;
39739
41289
  if (typeof block?.enabled === "boolean")
39740
41290
  return block.enabled;
39741
41291
  if (typeof config2.blockStreaming === "boolean")
@@ -39746,6 +41296,9 @@ function resolveInlineBlockStreamingEnabled(config2) {
39746
41296
  return false;
39747
41297
  return;
39748
41298
  }
41299
+ function shouldStartInlineProgressPlaceholderNow(line) {
41300
+ return typeof line === "object" && line?.kind === "patch" && Boolean(line.detail);
41301
+ }
39749
41302
  function resolveInlineCommandMenuModelContext(params) {
39750
41303
  if (!params.sessionKey.trim()) {
39751
41304
  return {};
@@ -39956,7 +41509,7 @@ function normalizeReplyMarkupButtonsWith(raw, options) {
39956
41509
  continue;
39957
41510
  const row = [];
39958
41511
  for (const candidateButton of candidateRow) {
39959
- if (!isRecord4(candidateButton))
41512
+ if (!isRecord5(candidateButton))
39960
41513
  continue;
39961
41514
  const text = sanitizeInlineActionLabel(typeof candidateButton.text === "string" ? candidateButton.text : "");
39962
41515
  const callbackDataRaw = typeof candidateButton.callback_data === "string" ? candidateButton.callback_data.trim() : "";
@@ -39977,9 +41530,9 @@ function normalizeReplyMarkupButtonsWith(raw, options) {
39977
41530
  return rows;
39978
41531
  }
39979
41532
  function resolveInlineReplyActions(payload) {
39980
- const channelData = isRecord4(payload.channelData) ? payload.channelData : undefined;
39981
- const inlineData = channelData && isRecord4(channelData.inline) ? channelData.inline : undefined;
39982
- const telegramData = channelData && isRecord4(channelData.telegram) ? channelData.telegram : undefined;
41533
+ const channelData = isRecord5(payload.channelData) ? payload.channelData : undefined;
41534
+ const inlineData = channelData && isRecord5(channelData.inline) ? channelData.inline : undefined;
41535
+ const telegramData = channelData && isRecord5(channelData.telegram) ? channelData.telegram : undefined;
39983
41536
  let rawButtons = undefined;
39984
41537
  let hasExplicitButtons = false;
39985
41538
  let mapCallbackData;
@@ -40070,10 +41623,27 @@ function rememberBotMessageId(cache, chatId, messageId) {
40070
41623
  }
40071
41624
  cache.set(key, list);
40072
41625
  }
41626
+ function rememberInlineBotDelivery(params) {
41627
+ rememberBotMessageId(params.botMessageIdsByChat, params.chatId, params.messageId);
41628
+ if (!params.replyThreadContext || params.chatId !== params.replyThreadContext.childChatId)
41629
+ return;
41630
+ recordInlineThreadParticipation(params.accountId, params.replyThreadContext.parentChatId, params.replyThreadContext.childChatId, { agentId: params.agentId });
41631
+ rememberInlineReplyThreadRoute({
41632
+ accountId: params.accountId,
41633
+ parentChatId: params.replyThreadContext.parentChatId,
41634
+ threadId: params.replyThreadContext.childChatId,
41635
+ parentMessageId: params.replyThreadContext.parentMessageId,
41636
+ threadLabel: params.replyThreadContext.threadLabel,
41637
+ agentId: params.agentId
41638
+ });
41639
+ }
40073
41640
  function hasBotMessageId(cache, chatId, messageId) {
40074
41641
  const key = String(chatId);
40075
41642
  return (cache.get(key) ?? []).includes(String(messageId));
40076
41643
  }
41644
+ function hasKnownBotMessageInChat(cache, chatId) {
41645
+ return (cache.get(String(chatId)) ?? []).length > 0;
41646
+ }
40077
41647
  function rememberBotMessagesFromList(params) {
40078
41648
  for (const item of params.messages) {
40079
41649
  if (item.fromId === params.meId) {
@@ -40165,6 +41735,17 @@ function normalizeHistoryText(raw) {
40165
41735
  return compact;
40166
41736
  return `${compact.slice(0, HISTORY_LINE_MAX_CHARS - 1)}…`;
40167
41737
  }
41738
+ function buildInlineReplyThreadLabel(params) {
41739
+ const title = params.title?.trim();
41740
+ if (title)
41741
+ return title;
41742
+ if (!params.anchorMessage)
41743
+ return "Re: Message";
41744
+ const anchorText = buildInlineInboundBodyText(summarizeInlineMessageContent(params.anchorMessage)).replace(/\s+/g, " ").trim();
41745
+ if (!anchorText)
41746
+ return "Re: Message";
41747
+ return `Re: ${anchorText.slice(0, REPLY_THREAD_LABEL_MAX_CHARS)}`;
41748
+ }
40168
41749
  function drainCompleteParagraphs(buffer) {
40169
41750
  const paragraphs = [];
40170
41751
  let rest = buffer;
@@ -40312,6 +41893,24 @@ function prependLabeledHistoryLine(params) {
40312
41893
  return existingBody ? `${prefix}${params.line}
40313
41894
  ${existingBody}` : `${prefix}${params.line}`;
40314
41895
  }
41896
+ function stripLabeledHistoryHeading(text, heading) {
41897
+ if (!text)
41898
+ return null;
41899
+ const prefix = `${heading}
41900
+ `;
41901
+ const body = text.startsWith(prefix) ? text.slice(prefix.length) : text;
41902
+ return body.trim() || null;
41903
+ }
41904
+ function prependLabeledHistoryBlock(params) {
41905
+ const block = stripLabeledHistoryHeading(params.block, params.heading);
41906
+ if (!block)
41907
+ return params.existing;
41908
+ const prefix = `${params.heading}
41909
+ `;
41910
+ const existingBody = stripLabeledHistoryHeading(params.existing, params.heading);
41911
+ return existingBody ? `${prefix}${block}
41912
+ ${existingBody}` : `${prefix}${block}`;
41913
+ }
40315
41914
  function prependInlineReplyThreadAnchor(params) {
40316
41915
  const entry = buildInlineHistoryEntryPayload({
40317
41916
  message: params.anchorMessage,
@@ -40319,12 +41918,17 @@ function prependInlineReplyThreadAnchor(params) {
40319
41918
  meId: params.meId,
40320
41919
  syntheticMessageId: `anchor:${String(params.parentChatId)}:${String(params.anchorMessage.id)}`
40321
41920
  });
41921
+ const hasBotMessage = params.historyContext.hasBotMessage || params.anchorMessage.fromId === params.meId;
40322
41922
  if (!entry.inboundEntry || !entry.line) {
40323
- return params.historyContext;
41923
+ return {
41924
+ ...params.historyContext,
41925
+ hasBotMessage
41926
+ };
40324
41927
  }
40325
41928
  return {
40326
41929
  ...params.historyContext,
40327
41930
  inboundHistory: [entry.inboundEntry, ...params.historyContext.inboundHistory],
41931
+ hasBotMessage,
40328
41932
  historyText: prependLabeledHistoryLine({
40329
41933
  existing: params.historyContext.historyText,
40330
41934
  heading: "Recent thread messages (oldest -> newest):",
@@ -40342,61 +41946,51 @@ function prependInlineReplyThreadAnchor(params) {
40342
41946
  })
40343
41947
  };
40344
41948
  }
40345
- function buildInlineBodyForAgent(params) {
40346
- return [
40347
- params.rawBody,
40348
- params.currentAttachmentText && params.currentAttachmentText !== params.rawBody ? `Current media/attachments:
40349
- ${params.currentAttachmentText}` : null,
40350
- params.currentEntityText ? `Current message entities:
40351
- ${params.currentEntityText}` : null
40352
- ].filter(Boolean).join(`
40353
-
40354
- `) || params.rawBody;
40355
- }
40356
- function normalizeInlineAgentMetadataValue(value) {
40357
- if (typeof value === "boolean")
40358
- return value;
40359
- const normalized = value?.replace(/\r\n|\r|\n/g, " ").replace(/\s+/g, " ").trim();
40360
- return normalized || undefined;
41949
+ function prependInlineParentHistoryContext(params) {
41950
+ return {
41951
+ ...params.historyContext,
41952
+ inboundHistory: [
41953
+ ...params.parentHistoryContext.inboundHistory,
41954
+ ...params.historyContext.inboundHistory
41955
+ ],
41956
+ hasBotMessage: params.historyContext.hasBotMessage || params.parentHistoryContext.hasBotMessage,
41957
+ historyText: prependLabeledHistoryBlock({
41958
+ existing: params.historyContext.historyText,
41959
+ heading: "Recent thread messages (oldest -> newest):",
41960
+ block: params.parentHistoryContext.historyText
41961
+ }),
41962
+ attachmentText: prependLabeledHistoryBlock({
41963
+ existing: params.historyContext.attachmentText,
41964
+ heading: "Recent media/attachments:",
41965
+ block: params.parentHistoryContext.attachmentText
41966
+ }),
41967
+ entityText: prependLabeledHistoryBlock({
41968
+ existing: params.historyContext.entityText,
41969
+ heading: "Recent message entities:",
41970
+ block: params.parentHistoryContext.entityText
41971
+ })
41972
+ };
40361
41973
  }
40362
- function buildInlineBodyForAgentPrompt(params) {
40363
- const metadata = {
40364
- schema: "inline.current_message.v1",
40365
- channel: normalizeInlineAgentMetadataValue(params.channel),
40366
- surface: normalizeInlineAgentMetadataValue(params.surface),
40367
- chat_type: normalizeInlineAgentMetadataValue(params.chatType),
40368
- chat_id: normalizeInlineAgentMetadataValue(params.chatId),
40369
- chat_ref: normalizeInlineAgentMetadataValue(params.chatRef),
40370
- conversation_label: normalizeInlineAgentMetadataValue(params.conversationLabel),
40371
- message_id: normalizeInlineAgentMetadataValue(params.messageId),
40372
- event_type: normalizeInlineAgentMetadataValue(params.eventType),
40373
- sender_id: normalizeInlineAgentMetadataValue(params.senderId),
40374
- sender_label: normalizeInlineAgentMetadataValue(params.senderLabel),
40375
- sender_name: normalizeInlineAgentMetadataValue(params.senderName ?? undefined),
40376
- sender_username: normalizeInlineAgentMetadataValue(params.senderUsername ?? undefined),
40377
- was_mentioned: params.wasMentioned,
40378
- explicitly_mentioned_bot: params.explicitlyMentionedBot === undefined ? undefined : normalizeInlineAgentMetadataValue(params.explicitlyMentionedBot),
40379
- mentioned_user_ids: params.mentionedUserIds?.length ? [...params.mentionedUserIds] : undefined,
40380
- implicit_mention_kinds: params.implicitMentionKinds?.length ? [...params.implicitMentionKinds] : undefined,
40381
- mention_source: normalizeInlineAgentMetadataValue(params.mentionSource ?? undefined),
40382
- reply_to_id: normalizeInlineAgentMetadataValue(params.replyToId ?? undefined),
40383
- reply_to_sender_id: normalizeInlineAgentMetadataValue(params.replyToSenderId ?? undefined),
40384
- reply_to_was_bot: params.replyToWasBot === undefined ? undefined : normalizeInlineAgentMetadataValue(params.replyToWasBot),
40385
- thread_id: normalizeInlineAgentMetadataValue(params.threadId ?? undefined),
40386
- thread_label: normalizeInlineAgentMetadataValue(params.threadLabel ?? undefined),
40387
- message_action_interaction_id: normalizeInlineAgentMetadataValue(params.messageActionInteractionId ?? undefined),
40388
- message_action_id: normalizeInlineAgentMetadataValue(params.messageActionId ?? undefined)
40389
- };
40390
- const payload = Object.fromEntries(Object.entries(metadata).filter(([, value]) => value !== undefined));
40391
- return [
40392
- "Inline current message metadata (generated by the Inline channel adapter):",
40393
- "```json",
40394
- JSON.stringify(payload, null, 2),
40395
- "```",
40396
- params.body
40397
- ].filter(Boolean).join(`
40398
-
40399
- `);
41974
+ function buildInlineUntrustedStructuredContext(params) {
41975
+ const entries = [];
41976
+ const append = (label, type, summary) => {
41977
+ if (!summary)
41978
+ return;
41979
+ const normalized = normalizeHistoryText(summary);
41980
+ if (!normalized || normalized === params.currentBody)
41981
+ return;
41982
+ entries.push({
41983
+ label,
41984
+ source: CHANNEL_ID,
41985
+ type,
41986
+ payload: { summary: normalized }
41987
+ });
41988
+ };
41989
+ append("Current Inline media/attachments", "current_media_attachments", params.currentAttachmentText);
41990
+ append("Current Inline message entities", "current_message_entities", params.currentEntityText);
41991
+ append("Recent Inline media/attachments", "recent_media_attachments", params.historyAttachmentText);
41992
+ append("Recent Inline message entities", "recent_message_entities", params.historyEntityText);
41993
+ return entries;
40400
41994
  }
40401
41995
  function resolveInlineMediaMaxBytes(params) {
40402
41996
  return resolveChannelMediaMaxBytes({
@@ -40443,13 +42037,20 @@ function buildInlineInboundBodyText(content) {
40443
42037
  `).trim();
40444
42038
  return textWithPlaceholder || content.text;
40445
42039
  }
42040
+ function hasDownloadableInlineMedia(content) {
42041
+ if (!content)
42042
+ return false;
42043
+ if (content.media?.url)
42044
+ return true;
42045
+ return content.attachments.some((attachment) => attachment.kind === "urlPreview" && Boolean(attachment.previewImageUrl));
42046
+ }
40446
42047
  function resolveFilePathHint(params) {
40447
42048
  const preferred = params.preferredName?.trim();
40448
42049
  if (preferred)
40449
42050
  return preferred;
40450
42051
  try {
40451
42052
  const pathname = new URL(params.sourceUrl).pathname;
40452
- const base = path2.basename(pathname).trim();
42053
+ const base = path4.basename(pathname).trim();
40453
42054
  if (base)
40454
42055
  return base;
40455
42056
  } catch {}
@@ -40516,14 +42117,80 @@ async function resolveInlineInboundReplyThreadContext(params) {
40516
42117
  childChatId: metadata.childChatId,
40517
42118
  parentChatId: metadata.parentChatId,
40518
42119
  parentChatTitle: parentChatInfo.title ?? null,
40519
- threadLabel: metadata.title ?? params.chatInfo.title ?? null,
42120
+ parentMessageId: metadata.parentMessageId,
42121
+ threadLabel: buildInlineReplyThreadLabel({
42122
+ title: metadata.title ?? params.chatInfo.title ?? null,
42123
+ anchorMessage
42124
+ }),
42125
+ anchorMessage
42126
+ };
42127
+ }
42128
+ function parseCachedInlineId(raw) {
42129
+ if (!raw || !/^\d+$/.test(raw))
42130
+ return null;
42131
+ try {
42132
+ return BigInt(raw);
42133
+ } catch {
42134
+ return null;
42135
+ }
42136
+ }
42137
+ async function resolveInlineReplyThreadContextFromRoute(params) {
42138
+ const parentChatId = parseCachedInlineId(params.route.parentChatId);
42139
+ const childChatId = parseCachedInlineId(params.route.threadId);
42140
+ if (parentChatId == null || childChatId == null) {
42141
+ return null;
42142
+ }
42143
+ const parentMessageId = parseCachedInlineId(params.route.parentMessageId);
42144
+ const parentChatInfo = await resolveChatInfo(params.client, params.chatCache, parentChatId).catch(() => ({
42145
+ kind: "group",
42146
+ title: params.fallbackParentChatTitle
42147
+ }));
42148
+ const anchorMessage = parentMessageId != null ? await loadInlineReplyThreadAnchorMessage({
42149
+ client: params.client,
42150
+ parentChatId,
42151
+ parentMessageId
42152
+ }).catch(() => null) : null;
42153
+ const labelSource = params.route.threadLabel ?? params.route.title ?? null;
42154
+ return {
42155
+ childChatId,
42156
+ parentChatId,
42157
+ parentChatTitle: parentChatInfo.title ?? params.fallbackParentChatTitle,
42158
+ parentMessageId,
42159
+ threadLabel: buildInlineReplyThreadLabel({
42160
+ title: labelSource,
42161
+ anchorMessage
42162
+ }),
40520
42163
  anchorMessage
40521
42164
  };
40522
42165
  }
40523
- async function buildHistoryContext2(params) {
42166
+ function normalizeInlineReplyThreadMode(raw) {
42167
+ return raw === "thread" || raw === "main" ? raw : "auto";
42168
+ }
42169
+ function shouldAutoCreateInlineReplyThread(params) {
42170
+ if (params.minMessages <= 0)
42171
+ return true;
42172
+ return params.messageId >= BigInt(params.minMessages);
42173
+ }
42174
+ async function buildReplyThreadParentHistoryContext(params) {
42175
+ if (params.parentHistoryLimit <= 0 || params.replyThreadContext.parentMessageId == null) {
42176
+ return null;
42177
+ }
42178
+ return buildHistoryContext({
42179
+ client: params.client,
42180
+ chatId: params.replyThreadContext.parentChatId,
42181
+ currentMessageId: params.replyThreadContext.parentMessageId,
42182
+ replyToMsgId: params.replyThreadContext.anchorMessage?.replyToMsgId,
42183
+ senderProfilesById: params.senderProfilesById,
42184
+ meId: params.meId,
42185
+ historyLimit: params.parentHistoryLimit,
42186
+ botMessageIdsByChat: params.botMessageIdsByChat
42187
+ });
42188
+ }
42189
+ async function buildHistoryContext(params) {
40524
42190
  const cachedReplyToBot = params.replyToMsgId != null && hasBotMessageId(params.botMessageIdsByChat, params.chatId, params.replyToMsgId);
40525
42191
  let repliedToBot = cachedReplyToBot;
40526
42192
  let replyToSenderId = null;
42193
+ let hasBotMessage = hasKnownBotMessageInChat(params.botMessageIdsByChat, params.chatId);
40527
42194
  let foundReplyTargetInHistory = false;
40528
42195
  const lines = [];
40529
42196
  const attachmentLines = [];
@@ -40539,6 +42206,7 @@ async function buildHistoryContext2(params) {
40539
42206
  if (messages) {
40540
42207
  for (const item of messages) {
40541
42208
  if (item.fromId === params.meId) {
42209
+ hasBotMessage = true;
40542
42210
  rememberBotMessageId(params.botMessageIdsByChat, params.chatId, item.id);
40543
42211
  }
40544
42212
  }
@@ -40581,6 +42249,7 @@ async function buildHistoryContext2(params) {
40581
42249
  if (replyTarget) {
40582
42250
  replyToSenderId = String(replyTarget.fromId);
40583
42251
  repliedToBot = replyTarget.fromId === params.meId;
42252
+ hasBotMessage = hasBotMessage || repliedToBot;
40584
42253
  } else if (!cachedReplyToBot) {
40585
42254
  repliedToBot = false;
40586
42255
  }
@@ -40594,7 +42263,8 @@ async function buildHistoryContext2(params) {
40594
42263
  `) : null,
40595
42264
  inboundHistory,
40596
42265
  repliedToBot,
40597
- replyToSenderId
42266
+ replyToSenderId,
42267
+ hasBotMessage
40598
42268
  };
40599
42269
  }
40600
42270
  return {
@@ -40609,7 +42279,8 @@ ${entityLines.slice(-ATTACHMENT_CONTEXT_LIMIT).join(`
40609
42279
  `)}` : null,
40610
42280
  inboundHistory,
40611
42281
  repliedToBot,
40612
- replyToSenderId
42282
+ replyToSenderId,
42283
+ hasBotMessage
40613
42284
  };
40614
42285
  }
40615
42286
  async function monitorInlineProvider(params) {
@@ -40620,8 +42291,8 @@ async function monitorInlineProvider(params) {
40620
42291
  }
40621
42292
  const token = await resolveInlineToken(account);
40622
42293
  const stateDir = core3.state.resolveStateDir();
40623
- const statePath = path2.join(stateDir, "channels", "inline", `${account.accountId}.json`);
40624
- await mkdir(path2.dirname(statePath), { recursive: true });
42294
+ const statePath = path4.join(stateDir, "channels", "inline", `${account.accountId}.json`);
42295
+ await mkdir(path4.dirname(statePath), { recursive: true });
40625
42296
  let client = null;
40626
42297
  const pushDiagnostics = (patch) => {
40627
42298
  statusSink?.({
@@ -40733,7 +42404,7 @@ async function monitorInlineProvider(params) {
40733
42404
  statusSink?.({ lastError: `getChat failed: ${String(err)}` });
40734
42405
  }
40735
42406
  const isGroup = chatInfo.kind !== "direct";
40736
- const replyThreadsEnabled = account.config.capabilities?.replyThreads === true || isInlineReplyThreadsEnabled({ cfg, accountId: account.accountId });
42407
+ const replyThreadsEnabled = isInlineReplyThreadsEnabled({ cfg, accountId: account.accountId });
40737
42408
  const replyThreadContext = await resolveInlineInboundReplyThreadContext({
40738
42409
  replyThreadsEnabled,
40739
42410
  client,
@@ -40799,7 +42470,7 @@ async function monitorInlineProvider(params) {
40799
42470
  chatInfo: effectiveChatInfo,
40800
42471
  effectiveChatId
40801
42472
  }),
40802
- sessionKey: route2.sessionKey
42473
+ sessionKey: replyThreadContext ? buildInlineReplyThreadSessionKey(route2.sessionKey, replyThreadContext.childChatId) : route2.sessionKey
40803
42474
  };
40804
42475
  }
40805
42476
  const peerUserId = senderId ?? (chatInfo.peerUserId != null ? String(chatInfo.peerUserId) : null);
@@ -40898,18 +42569,19 @@ async function monitorInlineProvider(params) {
40898
42569
  senderName: senderProfile?.name ?? (chatInfo?.kind === "direct" ? chatInfo.title ?? undefined : undefined),
40899
42570
  senderUsername: senderProfile?.username
40900
42571
  });
42572
+ const eventOptions = {
42573
+ sessionKey: ingress.sessionKey,
42574
+ contextKey: buildInlineReactionContextKey(params2),
42575
+ forceSenderIsOwnerFalse: true,
42576
+ trusted: false
42577
+ };
40901
42578
  core3.system.enqueueSystemEvent(describeInlineReactionSystemEvent({
40902
42579
  action: params2.action,
40903
42580
  emoji: params2.emoji,
40904
42581
  senderLabel,
40905
42582
  channelLabel: ingress.channelLabel,
40906
42583
  messageId: params2.messageId
40907
- }), {
40908
- sessionKey: ingress.sessionKey,
40909
- contextKey: buildInlineReactionContextKey(params2),
40910
- forceSenderIsOwnerFalse: true,
40911
- trusted: false
40912
- });
42584
+ }), eventOptions);
40913
42585
  };
40914
42586
  const shouldQueueInlineReactionSystemEvent = async (params2) => {
40915
42587
  const mode = account.config.reactionNotifications ?? "own";
@@ -40972,7 +42644,7 @@ async function monitorInlineProvider(params) {
40972
42644
  statusSink?.({ lastError: `getChat failed: ${String(err)}` });
40973
42645
  }
40974
42646
  const isGroup = chatInfo.kind !== "direct";
40975
- const replyThreadsEnabled = account.config.capabilities?.replyThreads === true || isInlineReplyThreadsEnabled({ cfg, accountId: account.accountId });
42647
+ const replyThreadsEnabled = isInlineReplyThreadsEnabled({ cfg, accountId: account.accountId });
40976
42648
  const replyThreadContext = await resolveInlineInboundReplyThreadContext({
40977
42649
  replyThreadsEnabled,
40978
42650
  client,
@@ -40985,6 +42657,30 @@ async function monitorInlineProvider(params) {
40985
42657
  });
40986
42658
  const effectiveChatId = replyThreadContext?.parentChatId ?? chatId;
40987
42659
  const effectiveGroupTitle = replyThreadContext?.parentChatTitle ?? chatInfo.title ?? null;
42660
+ const replyThreadMode = isGroup && replyThreadsEnabled ? resolveInlineGroupReplyThreadMode({
42661
+ cfg,
42662
+ accountId: account.accountId,
42663
+ groupId: String(effectiveChatId),
42664
+ defaultMode: normalizeInlineReplyThreadMode(account.config.replyThreadMode)
42665
+ }) : "auto";
42666
+ const replyThreadAutoCreateMinMessages = isGroup && replyThreadsEnabled ? resolveInlineGroupReplyThreadAutoCreateMinMessages({
42667
+ cfg,
42668
+ accountId: account.accountId,
42669
+ groupId: String(effectiveChatId),
42670
+ defaultMinMessages: account.config.replyThreadAutoCreateMinMessages ?? DEFAULT_REPLY_THREAD_AUTO_CREATE_MIN_MESSAGES
42671
+ }) : DEFAULT_REPLY_THREAD_AUTO_CREATE_MIN_MESSAGES;
42672
+ const replyThreadRequireExplicitMention = isGroup && replyThreadsEnabled ? resolveInlineGroupReplyThreadRequireExplicitMention({
42673
+ cfg,
42674
+ accountId: account.accountId,
42675
+ groupId: String(effectiveChatId),
42676
+ defaultRequireExplicitMention: account.config.replyThreadRequireExplicitMention ?? false
42677
+ }) : false;
42678
+ const replyThreadParentHistoryLimit = isGroup && replyThreadsEnabled ? resolveInlineGroupReplyThreadParentHistoryLimit({
42679
+ cfg,
42680
+ accountId: account.accountId,
42681
+ groupId: String(effectiveChatId),
42682
+ defaultLimit: account.config.replyThreadParentHistoryLimit ?? DEFAULT_REPLY_THREAD_PARENT_HISTORY_LIMIT
42683
+ }) : DEFAULT_REPLY_THREAD_PARENT_HISTORY_LIMIT;
40988
42684
  const senderId = String(msg.fromId);
40989
42685
  await hydrateChatParticipants(chatId);
40990
42686
  const senderProfile = senderProfilesById.get(senderId);
@@ -40992,18 +42688,7 @@ async function monitorInlineProvider(params) {
40992
42688
  const senderName = senderProfile?.name ?? (!isGroup ? chatInfo.title ?? undefined : undefined);
40993
42689
  if (callbackActionEvent) {
40994
42690
  const actor = senderUsername != null && senderUsername.length > 0 ? `@${senderUsername}` : senderName ?? `user:${senderId}`;
40995
- const payload = {
40996
- type: "inline_message_action_callback",
40997
- interaction_id: String(callbackActionEvent.interactionId),
40998
- actor_user_id: senderId,
40999
- chat_id: String(chatId),
41000
- message_id: String(callbackActionEvent.targetMessageId),
41001
- action_id: callbackActionEvent.actionId,
41002
- data_base64: callbackDataToBase64(callbackActionEvent.data),
41003
- data_utf8: callbackDataToUtf8(callbackActionEvent.data) ?? null
41004
- };
41005
- rawBody = `${actor} pressed a button on message #${String(callbackActionEvent.targetMessageId)}
41006
- ${JSON.stringify(payload)}`;
42691
+ rawBody = `${actor} pressed "${callbackActionEvent.actionId}" on message #${String(callbackActionEvent.targetMessageId)}`;
41007
42692
  }
41008
42693
  const dmPolicy = account.config.dmPolicy ?? "pairing";
41009
42694
  const defaultGroupPolicy = cfg.channels?.defaults?.groupPolicy;
@@ -41055,6 +42740,29 @@ ${JSON.stringify(payload)}`;
41055
42740
  id: isGroup ? String(effectiveChatId) : senderId
41056
42741
  }
41057
42742
  });
42743
+ const inboundSessionKey = replyThreadContext && isGroup ? buildInlineReplyThreadSessionKey(route.sessionKey, replyThreadContext.childChatId) : route.sessionKey;
42744
+ if (replyThreadContext && isGroup) {
42745
+ rememberInlineReplyThreadRoute({
42746
+ accountId: account.accountId,
42747
+ parentChatId: replyThreadContext.parentChatId,
42748
+ threadId: replyThreadContext.childChatId,
42749
+ parentMessageId: replyThreadContext.parentMessageId,
42750
+ threadLabel: replyThreadContext.threadLabel,
42751
+ agentId: route.agentId
42752
+ });
42753
+ }
42754
+ const rememberSentBotMessage = (params2) => {
42755
+ if (params2.messageId == null)
42756
+ return;
42757
+ rememberInlineBotDelivery({
42758
+ botMessageIdsByChat,
42759
+ chatId: params2.chatId,
42760
+ messageId: params2.messageId,
42761
+ accountId: account.accountId,
42762
+ agentId: route.agentId,
42763
+ replyThreadContext: params2.replyThreadContext ?? null
42764
+ });
42765
+ };
41058
42766
  const nativeCallbackCommandBody = callbackActionEvent ? parseInlineNativeCommandCallbackData(callbackDataToUtf8(callbackActionEvent.data)) : null;
41059
42767
  const hasControlCommand = core3.channel.text.hasControlCommand(callbackCommandBody ?? rawBody, cfg, botUsername ? { botUsername } : undefined);
41060
42768
  const commandSource = hasControlCommand ? (nativeCallbackCommandBody != null || !callbackActionEvent) && isInlineNativeCommandBody({
@@ -41178,7 +42886,8 @@ ${JSON.stringify(payload)}`;
41178
42886
  const patternMentioned = mentionRegexes.length ? core3.channel.mentions.matchesMentionPatterns(rawBody, mentionRegexes) : false;
41179
42887
  const wasMentioned = nativeMentioned || patternMentioned;
41180
42888
  const messageTimestamp = Number(msg.date) * 1000;
41181
- const groupHistoryKey = isGroup ? replyThreadContext ? `${route.sessionKey}:thread:${String(replyThreadContext.childChatId)}` : route.sessionKey : null;
42889
+ const pendingReplyThreadContext = replyThreadContext;
42890
+ const pendingGroupHistoryKey = isGroup ? pendingReplyThreadContext ? inboundSessionKey : route.sessionKey : null;
41182
42891
  const senderLabel = resolveInlineSenderLabel({
41183
42892
  senderId,
41184
42893
  senderName,
@@ -41191,7 +42900,7 @@ ${JSON.stringify(payload)}`;
41191
42900
  historyLimit: account.config.historyLimit,
41192
42901
  dmHistoryLimit: account.config.dmHistoryLimit
41193
42902
  });
41194
- const historyContext = await buildHistoryContext2({
42903
+ const historyContext = await buildHistoryContext({
41195
42904
  client,
41196
42905
  chatId,
41197
42906
  currentMessageId: msg.id,
@@ -41208,17 +42917,25 @@ ${JSON.stringify(payload)}`;
41208
42917
  entityText: null,
41209
42918
  inboundHistory: [],
41210
42919
  repliedToBot: false,
41211
- replyToSenderId: null
42920
+ replyToSenderId: null,
42921
+ hasBotMessage: false
41212
42922
  };
41213
42923
  });
41214
- const effectiveHistoryContext = replyThreadContext?.anchorMessage != null ? prependInlineReplyThreadAnchor({
42924
+ let effectiveHistoryContext = replyThreadContext?.anchorMessage != null ? prependInlineReplyThreadAnchor({
41215
42925
  historyContext,
41216
42926
  anchorMessage: replyThreadContext.anchorMessage,
41217
42927
  parentChatId: replyThreadContext.parentChatId,
41218
42928
  senderProfilesById,
41219
42929
  meId
41220
42930
  }) : historyContext;
41221
- const implicitMention = callbackActionEvent != null && isGroup || isGroup && (account.config.replyToBotWithoutMention ?? false) && msg.replyToMsgId != null && effectiveHistoryContext.repliedToBot;
42931
+ const hasReplyThreadParticipation = isGroup && replyThreadContext != null && !replyThreadRequireExplicitMention && (effectiveHistoryContext.hasBotMessage || await hasInlineThreadParticipationWithPersistence({
42932
+ accountId: account.accountId,
42933
+ parentChatId: replyThreadContext.parentChatId,
42934
+ threadId: replyThreadContext.childChatId
42935
+ }));
42936
+ const replyThreadImplicitMention = hasReplyThreadParticipation;
42937
+ const replyToBotImplicitMention = isGroup && (account.config.replyToBotWithoutMention ?? false) && msg.replyToMsgId != null && effectiveHistoryContext.repliedToBot;
42938
+ const implicitMention = callbackActionEvent != null && isGroup || replyThreadImplicitMention || replyToBotImplicitMention;
41222
42939
  const requireMention = isGroup ? resolveInlineGroupRequireMention({
41223
42940
  cfg,
41224
42941
  groupId: String(effectiveChatId),
@@ -41237,7 +42954,8 @@ ${JSON.stringify(payload)}`;
41237
42954
  });
41238
42955
  const implicitMentionKinds = isGroup && implicitMention ? [
41239
42956
  ...callbackActionEvent != null ? ["message_action"] : [],
41240
- ...msg.replyToMsgId != null && effectiveHistoryContext.repliedToBot ? ["reply_to_bot"] : []
42957
+ ...replyThreadImplicitMention ? ["reply_thread"] : [],
42958
+ ...replyToBotImplicitMention ? ["reply_to_bot"] : []
41241
42959
  ] : [];
41242
42960
  const mentionedUserIds = isGroup ? collectInlineMentionedUserIds(currentContent) : [];
41243
42961
  const mentionSource = isGroup ? resolveInlineMentionSource({
@@ -41252,9 +42970,9 @@ ${JSON.stringify(payload)}`;
41252
42970
  const pendingBody = normalizeHistoryText(currentContent?.text) ?? normalizeHistoryText(rawBody);
41253
42971
  recordPendingHistoryEntryIfEnabled({
41254
42972
  historyMap: groupPendingHistories,
41255
- historyKey: groupHistoryKey ?? "",
42973
+ historyKey: pendingGroupHistoryKey ?? "",
41256
42974
  limit: historyLimit,
41257
- entry: groupHistoryKey && pendingBody ? {
42975
+ entry: pendingGroupHistoryKey && pendingBody ? {
41258
42976
  sender: pendingHistorySender,
41259
42977
  body: pendingBody,
41260
42978
  timestamp: messageTimestamp || Date.now(),
@@ -41310,9 +43028,7 @@ ${JSON.stringify(payload)}`;
41310
43028
  actions,
41311
43029
  parseMarkdown
41312
43030
  });
41313
- if (sent.messageId != null) {
41314
- rememberBotMessageId(botMessageIdsByChat, chatId, sent.messageId);
41315
- }
43031
+ rememberSentBotMessage({ chatId, messageId: sent.messageId, replyThreadContext });
41316
43032
  }
41317
43033
  statusSink?.({ lastOutboundAt: Date.now() });
41318
43034
  return;
@@ -41321,7 +43037,7 @@ ${JSON.stringify(payload)}`;
41321
43037
  commandBody: normalizedCommandBody,
41322
43038
  cfg,
41323
43039
  agentId: route.agentId,
41324
- sessionKey: route.sessionKey
43040
+ sessionKey: inboundSessionKey
41325
43041
  });
41326
43042
  if (nativeCommandMenu) {
41327
43043
  const menuActions = resolveInlineReplyActions({
@@ -41359,9 +43075,7 @@ ${JSON.stringify(payload)}`;
41359
43075
  text: menuText,
41360
43076
  ...menuActions ? { actions: menuActions } : {}
41361
43077
  });
41362
- if (sent.messageId != null) {
41363
- rememberBotMessageId(botMessageIdsByChat, chatId, sent.messageId);
41364
- }
43078
+ rememberSentBotMessage({ chatId, messageId: sent.messageId, replyThreadContext });
41365
43079
  }
41366
43080
  statusSink?.({ lastOutboundAt: Date.now() });
41367
43081
  await answerCallbackIfNeeded().catch((error51) => {
@@ -41403,9 +43117,7 @@ ${JSON.stringify(payload)}`;
41403
43117
  actions,
41404
43118
  parseMarkdown
41405
43119
  });
41406
- if (sent.messageId != null) {
41407
- rememberBotMessageId(botMessageIdsByChat, chatId, sent.messageId);
41408
- }
43120
+ rememberSentBotMessage({ chatId, messageId: sent.messageId, replyThreadContext });
41409
43121
  }
41410
43122
  };
41411
43123
  const { byProvider, providers } = await buildModelsProviderData(cfg, route.agentId);
@@ -41437,11 +43149,11 @@ Select a provider:`, providerButtons);
41437
43149
  });
41438
43150
  const isDefaultSelection = selection.provider === resolvedDefault.provider && selection.model === resolvedDefault.model;
41439
43151
  await updateSessionStore(storePath2, (store) => {
41440
- const entry = store[route.sessionKey] ?? {
41441
- sessionId: route.sessionKey,
43152
+ const entry = store[inboundSessionKey] ?? {
43153
+ sessionId: inboundSessionKey,
41442
43154
  updatedAt: Date.now()
41443
43155
  };
41444
- store[route.sessionKey] = entry;
43156
+ store[inboundSessionKey] = entry;
41445
43157
  applyModelOverrideToSessionEntry({
41446
43158
  entry,
41447
43159
  selection: {
@@ -41466,12 +43178,139 @@ This model will be used for your next message.`, []);
41466
43178
  });
41467
43179
  return;
41468
43180
  }
43181
+ let deliveryReplyThreadContext = replyThreadContext;
43182
+ const shouldCreateDeliveryThread = isGroup && replyThreadsEnabled && replyThreadMode === "thread" && !deliveryReplyThreadContext && shouldAutoCreateInlineReplyThread({
43183
+ messageId: msg.id,
43184
+ minMessages: replyThreadAutoCreateMinMessages
43185
+ }) && !shouldEditCallbackTargetInPlace;
43186
+ if (shouldCreateDeliveryThread) {
43187
+ const cachedRoute = await lookupInlineReplyThreadRoute({
43188
+ accountId: account.accountId,
43189
+ parentChatId: effectiveChatId,
43190
+ parentMessageId: msg.id,
43191
+ agentId: route.agentId
43192
+ }).catch((error51) => {
43193
+ statusSink?.({ lastError: `reply-thread route lookup failed: ${String(error51)}` });
43194
+ runtime.error?.(`inline reply-thread route lookup failed: ${String(error51)}`);
43195
+ return null;
43196
+ });
43197
+ if (cachedRoute) {
43198
+ deliveryReplyThreadContext = await resolveInlineReplyThreadContextFromRoute({
43199
+ route: cachedRoute,
43200
+ client,
43201
+ chatCache,
43202
+ fallbackParentChatTitle: effectiveGroupTitle
43203
+ }).catch((error51) => {
43204
+ statusSink?.({ lastError: `reply-thread route restore failed: ${String(error51)}` });
43205
+ runtime.error?.(`inline reply-thread route restore failed: ${String(error51)}`);
43206
+ return null;
43207
+ });
43208
+ }
43209
+ }
43210
+ if (shouldCreateDeliveryThread && !deliveryReplyThreadContext) {
43211
+ const createdThread = await createInlineReplyThreadForMessage({
43212
+ client,
43213
+ parentChatId: effectiveChatId,
43214
+ parentMessageId: msg.id
43215
+ }).catch((error51) => {
43216
+ statusSink?.({ lastError: `createSubthread failed: ${String(error51)}` });
43217
+ runtime.error?.(`inline create reply thread failed: ${String(error51)}`);
43218
+ return null;
43219
+ });
43220
+ if (createdThread) {
43221
+ deliveryReplyThreadContext = {
43222
+ childChatId: createdThread.childChatId,
43223
+ parentChatId: createdThread.parentChatId,
43224
+ parentChatTitle: effectiveGroupTitle,
43225
+ parentMessageId: createdThread.parentMessageId,
43226
+ threadLabel: buildInlineReplyThreadLabel({
43227
+ title: createdThread.title,
43228
+ anchorMessage: createdThread.anchorMessage
43229
+ }),
43230
+ anchorMessage: createdThread.anchorMessage
43231
+ };
43232
+ rememberInlineReplyThreadRoute({
43233
+ accountId: account.accountId,
43234
+ parentChatId: deliveryReplyThreadContext.parentChatId,
43235
+ threadId: deliveryReplyThreadContext.childChatId,
43236
+ parentMessageId: deliveryReplyThreadContext.parentMessageId,
43237
+ title: createdThread.title,
43238
+ threadLabel: deliveryReplyThreadContext.threadLabel,
43239
+ agentId: route.agentId
43240
+ });
43241
+ }
43242
+ }
43243
+ if (shouldCreateDeliveryThread && !deliveryReplyThreadContext) {
43244
+ const cachedRoute = await lookupInlineReplyThreadRoute({
43245
+ accountId: account.accountId,
43246
+ parentChatId: effectiveChatId,
43247
+ parentMessageId: msg.id,
43248
+ agentId: route.agentId
43249
+ }).catch(() => null);
43250
+ if (cachedRoute) {
43251
+ deliveryReplyThreadContext = await resolveInlineReplyThreadContextFromRoute({
43252
+ route: cachedRoute,
43253
+ client,
43254
+ chatCache,
43255
+ fallbackParentChatTitle: effectiveGroupTitle
43256
+ }).catch(() => null);
43257
+ }
43258
+ }
43259
+ if (shouldCreateDeliveryThread && !deliveryReplyThreadContext) {
43260
+ runtime.error?.("inline create reply thread failed; falling back to parent chat delivery");
43261
+ }
43262
+ if (!replyThreadContext && deliveryReplyThreadContext?.anchorMessage != null) {
43263
+ effectiveHistoryContext = prependInlineReplyThreadAnchor({
43264
+ historyContext: {
43265
+ historyText: null,
43266
+ attachmentText: null,
43267
+ entityText: null,
43268
+ inboundHistory: [],
43269
+ repliedToBot: effectiveHistoryContext.repliedToBot,
43270
+ replyToSenderId: effectiveHistoryContext.replyToSenderId,
43271
+ hasBotMessage: effectiveHistoryContext.hasBotMessage
43272
+ },
43273
+ anchorMessage: deliveryReplyThreadContext.anchorMessage,
43274
+ parentChatId: deliveryReplyThreadContext.parentChatId,
43275
+ senderProfilesById,
43276
+ meId
43277
+ });
43278
+ }
43279
+ if (deliveryReplyThreadContext) {
43280
+ const parentHistoryContext = await buildReplyThreadParentHistoryContext({
43281
+ client,
43282
+ replyThreadContext: deliveryReplyThreadContext,
43283
+ parentHistoryLimit: replyThreadParentHistoryLimit,
43284
+ senderProfilesById,
43285
+ meId,
43286
+ botMessageIdsByChat
43287
+ }).catch((err) => {
43288
+ statusSink?.({ lastError: `getChatHistory (reply thread parent) failed: ${String(err)}` });
43289
+ return null;
43290
+ });
43291
+ if (parentHistoryContext) {
43292
+ effectiveHistoryContext = prependInlineParentHistoryContext({
43293
+ historyContext: effectiveHistoryContext,
43294
+ parentHistoryContext
43295
+ });
43296
+ }
43297
+ }
43298
+ const deliveryChatId = deliveryReplyThreadContext?.childChatId ?? chatId;
43299
+ const deliverySessionKey = deliveryReplyThreadContext && isGroup ? buildInlineReplyThreadSessionKey(route.sessionKey, deliveryReplyThreadContext.childChatId) : route.sessionKey;
43300
+ const groupHistoryKey = isGroup ? deliveryReplyThreadContext ? deliverySessionKey : route.sessionKey : null;
41469
43301
  const inboundMedia = await resolveInlineInboundMedia({
41470
43302
  core: core3,
41471
43303
  message: msg,
41472
43304
  maxBytes: inboundMediaMaxBytes,
41473
43305
  ...log ? { log } : {}
41474
43306
  });
43307
+ const inheritedAnchorMedia = deliveryReplyThreadContext?.anchorMessage != null && currentContent != null && !hasDownloadableInlineMedia(currentContent) ? await resolveInlineInboundMedia({
43308
+ core: core3,
43309
+ message: deliveryReplyThreadContext.anchorMessage,
43310
+ maxBytes: inboundMediaMaxBytes,
43311
+ ...log ? { log } : {}
43312
+ }) : [];
43313
+ const mediaForAgent = inboundMedia.length > 0 ? inboundMedia : inheritedAnchorMedia;
41475
43314
  const timestamp = messageTimestamp;
41476
43315
  const fromLabel = resolveInlineConversationLabel({
41477
43316
  isGroup,
@@ -41480,61 +43319,31 @@ This model will be used for your next message.`, []);
41480
43319
  senderLabel
41481
43320
  });
41482
43321
  const storePath = core3.channel.session.resolveStorePath(cfg.session?.store, { agentId: route.agentId });
41483
- const envelopeOptions = core3.channel.reply.resolveEnvelopeFormatOptions(cfg);
41484
- const previousTimestamp = core3.channel.session.readSessionUpdatedAt({ storePath, sessionKey: route.sessionKey });
41485
- const rawBodyForAgent = isGroup && wasMentioned ? stripInlineBotMention(rawBody, botUsername) : rawBody;
41486
- const currentEntityTextForAgent = isGroup && wasMentioned ? stripInlineBotMentionEntityText(currentEntityText, botUsername) : currentEntityText;
41487
- const currentBody = buildInlineBodyForAgent({
41488
- rawBody: rawBodyForAgent,
41489
- currentAttachmentText,
41490
- currentEntityText: currentEntityTextForAgent
41491
- });
41492
- const contextBody = [
41493
- effectiveHistoryContext.historyText,
41494
- effectiveHistoryContext.attachmentText,
41495
- effectiveHistoryContext.entityText
41496
- ].filter(Boolean).join(`
41497
-
41498
- `);
41499
- const currentEnvelope = core3.channel.reply.formatInboundEnvelope({
41500
- channel: "Inline",
41501
- from: fromLabel,
41502
- timestamp,
41503
- chatType: isGroup ? "group" : "direct",
41504
- sender: {
41505
- id: senderId,
41506
- ...senderName ? { name: senderName } : {},
41507
- ...senderUsername ? { username: senderUsername } : {}
41508
- },
41509
- ...previousTimestamp != null ? { previousTimestamp } : {},
41510
- envelope: envelopeOptions,
41511
- body: currentBody || rawBodyForAgent
41512
- });
41513
- let body = [contextBody, currentEnvelope].filter(Boolean).join(`
41514
-
41515
- `);
41516
- if (isGroup && groupHistoryKey) {
41517
- body = buildPendingHistoryContextFromMap({
41518
- historyMap: groupPendingHistories,
41519
- historyKey: groupHistoryKey,
41520
- limit: historyLimit,
41521
- currentMessage: body,
41522
- formatEntry: (entry) => core3.channel.reply.formatInboundEnvelope({
41523
- channel: "Inline",
41524
- from: fromLabel,
41525
- chatType: "group",
41526
- senderLabel: entry.sender,
41527
- ...entry.timestamp != null ? { timestamp: entry.timestamp } : {},
41528
- envelope: envelopeOptions,
41529
- body: `${entry.body}${entry.messageId ? ` [id:${entry.messageId} chat:${String(chatId)}]` : ""}`
41530
- })
41531
- });
41532
- }
43322
+ const rawBodyForAgent = isGroup && mentionGate.effectiveWasMentioned ? stripInlineBotMention(rawBody, botUsername) : rawBody;
43323
+ const currentEntityTextForAgent = isGroup && mentionGate.effectiveWasMentioned ? stripInlineBotMentionEntityText(currentEntityText, botUsername) : currentEntityText;
43324
+ const currentBody = rawBodyForAgent || rawBody;
41533
43325
  const inboundHistory = isGroup && groupHistoryKey ? mergeInboundHistoryEntries({
41534
43326
  historyContextEntries: effectiveHistoryContext.inboundHistory,
41535
43327
  pendingEntries: groupPendingHistories.get(groupHistoryKey) ?? [],
41536
43328
  limit: historyLimit
41537
- }) : [];
43329
+ }) : effectiveHistoryContext.inboundHistory;
43330
+ const untrustedStructuredContext = buildInlineUntrustedStructuredContext({
43331
+ currentAttachmentText,
43332
+ currentEntityText: currentEntityTextForAgent,
43333
+ currentBody,
43334
+ historyAttachmentText: effectiveHistoryContext.attachmentText,
43335
+ historyEntityText: effectiveHistoryContext.entityText
43336
+ });
43337
+ const inboundEventKind = classifyChannelInboundEvent({
43338
+ conversation: { kind: isGroup ? "group" : "direct" },
43339
+ unmentionedGroupPolicy: resolveUnmentionedGroupInboundPolicy({
43340
+ cfg,
43341
+ agentId: route.agentId
43342
+ }),
43343
+ ...isGroup ? { wasMentioned: mentionGate.effectiveWasMentioned } : {},
43344
+ hasControlCommand,
43345
+ ...commandSource ? { commandSource } : {}
43346
+ });
41538
43347
  const effectiveSurface = CHANNEL_ID;
41539
43348
  const systemPrompt = resolveInlineSystemPrompt({
41540
43349
  account,
@@ -41544,49 +43353,18 @@ This model will be used for your next message.`, []);
41544
43353
  msgId: msg.id,
41545
43354
  ...callbackActionEvent ? { callbackActionEvent } : {}
41546
43355
  });
41547
- const eventType = callbackActionEvent ? "message_action" : "message";
41548
- const bodyForAgent = buildInlineBodyForAgentPrompt({
41549
- body,
41550
- channel: CHANNEL_ID,
41551
- surface: effectiveSurface,
41552
- chatType: isGroup ? "group" : "direct",
41553
- chatId: String(effectiveChatId),
41554
- chatRef: `inline:${String(effectiveChatId)}`,
41555
- conversationLabel: fromLabel,
41556
- messageId: messageSid,
41557
- eventType,
41558
- senderId,
41559
- senderLabel,
41560
- wasMentioned: mentionGate.effectiveWasMentioned,
41561
- ...isGroup ? {
41562
- explicitlyMentionedBot: nativeMentioned,
41563
- mentionedUserIds,
41564
- implicitMentionKinds,
41565
- mentionSource
41566
- } : {},
41567
- ...senderName ? { senderName } : {},
41568
- ...senderUsername ? { senderUsername } : {},
41569
- ...msg.replyToMsgId != null ? { replyToId: String(msg.replyToMsgId) } : {},
41570
- ...effectiveHistoryContext.replyToSenderId != null ? { replyToSenderId: effectiveHistoryContext.replyToSenderId } : {},
41571
- ...msg.replyToMsgId != null ? { replyToWasBot: effectiveHistoryContext.repliedToBot } : {},
41572
- ...replyThreadContext ? { threadId: String(replyThreadContext.childChatId) } : {},
41573
- ...replyThreadContext?.threadLabel ? { threadLabel: replyThreadContext.threadLabel } : {},
41574
- ...callbackActionEvent ? {
41575
- messageActionInteractionId: String(callbackActionEvent.interactionId),
41576
- messageActionId: callbackActionEvent.actionId
41577
- } : {}
41578
- });
41579
43356
  const ctxPayload = core3.channel.reply.finalizeInboundContext({
41580
- Body: body,
41581
- BodyForAgent: bodyForAgent,
43357
+ Body: rawBody,
43358
+ InboundEventKind: inboundEventKind,
43359
+ BodyForAgent: currentBody,
41582
43360
  BodyForCommands: normalizedCommandBody,
41583
- ...isGroup ? { InboundHistory: inboundHistory } : {},
43361
+ InboundHistory: inboundHistory,
41584
43362
  RawBody: rawBody,
41585
43363
  CommandBody: normalizedCommandBody,
41586
43364
  From: isGroup ? `inline:chat:${String(effectiveChatId)}` : `inline:${senderId}`,
41587
43365
  To: `inline:${String(effectiveChatId)}`,
41588
- SessionKey: route.sessionKey,
41589
- ...replyThreadContext ? { ParentSessionKey: route.sessionKey } : {},
43366
+ SessionKey: deliverySessionKey,
43367
+ ...deliveryReplyThreadContext ? { ParentSessionKey: route.sessionKey } : {},
41590
43368
  AccountId: route.accountId,
41591
43369
  ChatType: isGroup ? "group" : "direct",
41592
43370
  ConversationLabel: fromLabel,
@@ -41609,20 +43387,21 @@ This model will be used for your next message.`, []);
41609
43387
  authorized: false,
41610
43388
  body: normalizedCommandBody
41611
43389
  },
41612
- ...replyThreadContext ? { MessageThreadId: String(replyThreadContext.childChatId) } : {},
41613
- ...replyThreadContext?.threadLabel ? { ThreadLabel: replyThreadContext.threadLabel } : {},
43390
+ ...deliveryReplyThreadContext ? { MessageThreadId: String(deliveryReplyThreadContext.childChatId) } : {},
43391
+ ...deliveryReplyThreadContext?.threadLabel ? { ThreadLabel: deliveryReplyThreadContext.threadLabel } : {},
41614
43392
  ...msg.replyToMsgId != null ? { ReplyToId: String(msg.replyToMsgId) } : {},
41615
43393
  ...effectiveHistoryContext.replyToSenderId != null ? { ReplyToSenderId: effectiveHistoryContext.replyToSenderId } : {},
41616
43394
  ...msg.replyToMsgId != null ? { ReplyToWasBot: effectiveHistoryContext.repliedToBot } : {},
43395
+ ...untrustedStructuredContext.length > 0 ? { UntrustedStructuredContext: untrustedStructuredContext } : {},
41617
43396
  ...callbackActionEvent ? {
41618
43397
  MessageActionInteractionId: String(callbackActionEvent.interactionId),
41619
43398
  MessageActionId: callbackActionEvent.actionId,
41620
43399
  MessageActionDataBase64: callbackDataToBase64(callbackActionEvent.data),
41621
43400
  ...callbackDataToUtf8(callbackActionEvent.data) ? { MessageActionDataUtf8: callbackDataToUtf8(callbackActionEvent.data) } : {}
41622
43401
  } : {},
41623
- ...buildInlineInboundMediaPayload(inboundMedia),
43402
+ ...buildInlineInboundMediaPayload(mediaForAgent),
41624
43403
  Timestamp: timestamp || Date.now(),
41625
- WasMentioned: mentionGate.effectiveWasMentioned,
43404
+ ...isGroup ? { WasMentioned: mentionGate.effectiveWasMentioned } : {},
41626
43405
  ...isGroup ? {
41627
43406
  ExplicitlyMentionedBot: nativeMentioned,
41628
43407
  ...mentionedUserIds.length > 0 ? { MentionedUserIds: mentionedUserIds } : {},
@@ -41636,7 +43415,7 @@ This model will be used for your next message.`, []);
41636
43415
  });
41637
43416
  await core3.channel.session.recordInboundSession({
41638
43417
  storePath,
41639
- sessionKey: ctxPayload.SessionKey ?? route.sessionKey,
43418
+ sessionKey: ctxPayload.SessionKey ?? deliverySessionKey,
41640
43419
  ctx: ctxPayload,
41641
43420
  ...!isGroup ? {
41642
43421
  updateLastRoute: {
@@ -41654,8 +43433,8 @@ This model will be used for your next message.`, []);
41654
43433
  channel: CHANNEL_ID,
41655
43434
  accountId: account.accountId,
41656
43435
  typing: {
41657
- start: () => client.sendTyping({ chatId, typing: true }),
41658
- stop: () => client.sendTyping({ chatId, typing: false }),
43436
+ start: () => client.sendTyping({ chatId: deliveryChatId, typing: true }),
43437
+ stop: () => client.sendTyping({ chatId: deliveryChatId, typing: false }),
41659
43438
  onStartError: (err) => runtime.error?.(`inline typing start failed: ${String(err)}`),
41660
43439
  onStopError: (err) => runtime.error?.(`inline typing stop failed: ${String(err)}`)
41661
43440
  }
@@ -41678,10 +43457,14 @@ This model will be used for your next message.`, []);
41678
43457
  botMessageIdsByChat
41679
43458
  }).catch(() => null) : null;
41680
43459
  const inlineStreamingMode = resolveInlineStreamingMode(account.config);
41681
- const streamViaEditMessage = (inlineStreamingMode === "partial" || inlineStreamingMode === "progress") && !shouldEditCallbackTargetInPlace;
41682
- const defaultReplyToMsgId = isGroup && msg.replyToMsgId != null ? msg.id : undefined;
43460
+ const streamViaEditMessage = inlineStreamingMode === "partial" && !shouldEditCallbackTargetInPlace;
43461
+ const progressPlaceholderEnabled = resolveInlineProgressPlaceholderEnabled(account.config) && !shouldEditCallbackTargetInPlace;
43462
+ const progressToolProgressEnabled = progressPlaceholderEnabled && resolveChannelStreamingPreviewToolProgress(account.config);
43463
+ const suppressDefaultToolProgressMessages = progressPlaceholderEnabled;
43464
+ const canReplyToSourceMessage = deliveryChatId === chatId;
43465
+ const defaultReplyToMsgId = canReplyToSourceMessage && isGroup && msg.replyToMsgId != null ? msg.id : undefined;
41683
43466
  const inlineBlockStreamingEnabled = resolveInlineBlockStreamingEnabled(account.config);
41684
- const disableBlockStreaming = streamViaEditMessage ? true : typeof inlineBlockStreamingEnabled === "boolean" ? !inlineBlockStreamingEnabled : undefined;
43467
+ const disableBlockStreaming = progressPlaceholderEnabled || streamViaEditMessage ? true : typeof inlineBlockStreamingEnabled === "boolean" ? !inlineBlockStreamingEnabled : undefined;
41685
43468
  const editStreamState = {
41686
43469
  messageId: shouldEditCallbackTargetInPlace ? callbackActionEvent?.targetMessageId ?? null : null,
41687
43470
  accumulatedText: callbackTargetMessage?.message ?? "",
@@ -41690,6 +43473,117 @@ This model will be used for your next message.`, []);
41690
43473
  failed: false,
41691
43474
  opChain: Promise.resolve()
41692
43475
  };
43476
+ const progressSeed = `${account.accountId}:${String(deliveryChatId)}:${String(msg.id)}`;
43477
+ const progressState = {
43478
+ messageId: null,
43479
+ text: "",
43480
+ lines: [],
43481
+ opChain: Promise.resolve(),
43482
+ closing: false
43483
+ };
43484
+ const renderInlineProgressPlaceholder = async () => {
43485
+ if (!progressPlaceholderEnabled || progressState.closing)
43486
+ return;
43487
+ const text = sanitizeInlineDeliveryText(formatChannelProgressDraftText({
43488
+ entry: account.config,
43489
+ lines: progressState.lines,
43490
+ seed: progressSeed
43491
+ })).trim();
43492
+ if (!text || text === progressState.text)
43493
+ return;
43494
+ progressState.opChain = progressState.opChain.then(async () => {
43495
+ if (progressState.closing || text === progressState.text)
43496
+ return;
43497
+ if (progressState.messageId == null) {
43498
+ const sent = await client.sendMessage({
43499
+ chatId: deliveryChatId,
43500
+ text,
43501
+ sendMode: "silent"
43502
+ });
43503
+ if (sent.messageId == null) {
43504
+ throw new Error("inline progress placeholder: sendMessage returned no messageId");
43505
+ }
43506
+ progressState.messageId = sent.messageId;
43507
+ rememberSentBotMessage({
43508
+ chatId: deliveryChatId,
43509
+ messageId: sent.messageId,
43510
+ replyThreadContext: deliveryReplyThreadContext
43511
+ });
43512
+ } else {
43513
+ const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
43514
+ oneofKind: "editMessage",
43515
+ editMessage: {
43516
+ messageId: progressState.messageId,
43517
+ peerId: buildChatPeer3(deliveryChatId),
43518
+ text
43519
+ }
43520
+ });
43521
+ if (result.oneofKind !== "editMessage") {
43522
+ throw new Error(`inline progress placeholder: expected editMessage result, got ${String(result.oneofKind)}`);
43523
+ }
43524
+ }
43525
+ progressState.text = text;
43526
+ statusSink?.({ lastOutboundAt: Date.now() });
43527
+ }).catch((error51) => {
43528
+ runtime.error?.(`inline progress placeholder failed: ${String(error51)}`);
43529
+ });
43530
+ await progressState.opChain;
43531
+ };
43532
+ const progressDraftGate = createChannelProgressDraftGate({
43533
+ onStart: renderInlineProgressPlaceholder
43534
+ });
43535
+ const pushInlineProgressPlaceholder = async (line, options) => {
43536
+ if (!progressPlaceholderEnabled || progressState.closing)
43537
+ return;
43538
+ if (options?.toolName !== undefined && !isChannelProgressDraftWorkToolName(options.toolName)) {
43539
+ return;
43540
+ }
43541
+ const normalized = typeof line === "string" ? line.replace(/\s+/g, " ").trim() : line?.text.trim();
43542
+ if (line && !normalized)
43543
+ return;
43544
+ if (progressToolProgressEnabled && line && normalized) {
43545
+ const nextLines = mergeChannelProgressDraftLine(progressState.lines, line, {
43546
+ maxLines: resolveChannelProgressDraftMaxLines(account.config)
43547
+ });
43548
+ if (nextLines !== progressState.lines) {
43549
+ progressState.lines = nextLines;
43550
+ }
43551
+ }
43552
+ const alreadyStarted = progressDraftGate.hasStarted;
43553
+ if (options?.startImmediately || shouldStartInlineProgressPlaceholderNow(line)) {
43554
+ await progressDraftGate.startNow();
43555
+ } else {
43556
+ await progressDraftGate.noteWork();
43557
+ }
43558
+ if (alreadyStarted && progressDraftGate.hasStarted) {
43559
+ await renderInlineProgressPlaceholder();
43560
+ }
43561
+ };
43562
+ const cleanupInlineProgressPlaceholder = async () => {
43563
+ progressDraftGate.cancel();
43564
+ progressState.closing = true;
43565
+ await progressState.opChain;
43566
+ const messageId = progressState.messageId;
43567
+ if (messageId == null)
43568
+ return;
43569
+ try {
43570
+ const result = await client.invokeRaw(Method.DELETE_MESSAGES, {
43571
+ oneofKind: "deleteMessages",
43572
+ deleteMessages: {
43573
+ peerId: buildChatPeer3(deliveryChatId),
43574
+ messageIds: [messageId]
43575
+ }
43576
+ });
43577
+ if (result.oneofKind !== "deleteMessages") {
43578
+ throw new Error(`inline progress placeholder: expected deleteMessages result, got ${String(result.oneofKind)}`);
43579
+ }
43580
+ } catch (error51) {
43581
+ runtime.error?.(`inline progress placeholder cleanup failed: ${String(error51)}`);
43582
+ } finally {
43583
+ progressState.messageId = null;
43584
+ progressState.text = "";
43585
+ }
43586
+ };
41693
43587
  let finalDeliveredForCurrentAssistantMessage = false;
41694
43588
  const resetEditStreamForAssistantMessage = async () => {
41695
43589
  await editStreamState.opChain;
@@ -41731,7 +43625,7 @@ This model will be used for your next message.`, []);
41731
43625
  try {
41732
43626
  if (editStreamState.messageId == null) {
41733
43627
  const sent = await client.sendMessage({
41734
- chatId,
43628
+ chatId: deliveryChatId,
41735
43629
  text: nextText,
41736
43630
  ...defaultReplyToMsgId != null ? { replyToMsgId: defaultReplyToMsgId } : {},
41737
43631
  parseMarkdown
@@ -41740,13 +43634,17 @@ This model will be used for your next message.`, []);
41740
43634
  throw new Error("inline edit stream: sendMessage returned no messageId");
41741
43635
  }
41742
43636
  editStreamState.messageId = sent.messageId;
41743
- rememberBotMessageId(botMessageIdsByChat, chatId, sent.messageId);
43637
+ rememberSentBotMessage({
43638
+ chatId: deliveryChatId,
43639
+ messageId: sent.messageId,
43640
+ replyThreadContext: deliveryReplyThreadContext
43641
+ });
41744
43642
  } else {
41745
43643
  const result = await client.invokeRaw(Method.EDIT_MESSAGE, {
41746
43644
  oneofKind: "editMessage",
41747
43645
  editMessage: {
41748
43646
  messageId: editStreamState.messageId,
41749
- peerId: buildChatPeer3(chatId),
43647
+ peerId: buildChatPeer3(deliveryChatId),
41750
43648
  text: nextText,
41751
43649
  parseMarkdown
41752
43650
  }
@@ -41764,6 +43662,7 @@ This model will be used for your next message.`, []);
41764
43662
  });
41765
43663
  await editStreamState.opChain;
41766
43664
  };
43665
+ const buildInlineProgressLineForEntry = (input2, options) => buildChannelProgressDraftLineForEntry(account.config, input2, options);
41767
43666
  const replyOptions = {
41768
43667
  ...onModelSelected ? { onModelSelected } : {},
41769
43668
  blockReplyTimeoutMs: 25000,
@@ -41777,21 +43676,109 @@ This model will be used for your next message.`, []);
41777
43676
  await handlePartialStreamPayload(payload);
41778
43677
  }
41779
43678
  } : {},
41780
- ...streamViaEditMessage ? {
41781
- onToolStart: async () => {
43679
+ ...progressPlaceholderEnabled ? {
43680
+ onReasoningStream: async () => {
43681
+ await pushInlineProgressPlaceholder();
43682
+ }
43683
+ } : {},
43684
+ ...streamViaEditMessage || progressPlaceholderEnabled ? {
43685
+ onToolStart: async (payload) => {
41782
43686
  await resetEditStreamOnBoundary();
43687
+ const toolName = payload.name?.trim();
43688
+ await pushInlineProgressPlaceholder(buildInlineProgressLineForEntry({
43689
+ event: "tool",
43690
+ ...toolName ? { name: toolName } : {},
43691
+ ...payload.phase !== undefined ? { phase: payload.phase } : {},
43692
+ ...payload.args !== undefined ? { args: payload.args } : {}
43693
+ }, payload.detailMode ? { detailMode: payload.detailMode } : undefined), {
43694
+ ...toolName ? { toolName } : {},
43695
+ startImmediately: true
43696
+ });
41783
43697
  }
41784
43698
  } : {},
41785
- ...streamViaEditMessage ? {
43699
+ ...progressPlaceholderEnabled ? {
43700
+ onItemEvent: async (payload) => {
43701
+ await pushInlineProgressPlaceholder(buildInlineProgressLineForEntry({
43702
+ event: "item",
43703
+ ...payload.itemId !== undefined ? { itemId: payload.itemId } : {},
43704
+ ...payload.kind !== undefined ? { itemKind: payload.kind } : {},
43705
+ ...payload.title !== undefined ? { title: payload.title } : {},
43706
+ ...payload.name !== undefined ? { name: payload.name } : {},
43707
+ ...payload.phase !== undefined ? { phase: payload.phase } : {},
43708
+ ...payload.status !== undefined ? { status: payload.status } : {},
43709
+ ...payload.summary !== undefined ? { summary: payload.summary } : {},
43710
+ ...payload.progressText !== undefined ? { progressText: payload.progressText } : {},
43711
+ ...payload.meta !== undefined ? { meta: payload.meta } : {}
43712
+ }));
43713
+ },
43714
+ onPlanUpdate: async (payload) => {
43715
+ if (payload.phase !== "update")
43716
+ return;
43717
+ await pushInlineProgressPlaceholder(buildChannelProgressDraftLine({
43718
+ event: "plan",
43719
+ ...payload.phase !== undefined ? { phase: payload.phase } : {},
43720
+ ...payload.title !== undefined ? { title: payload.title } : {},
43721
+ ...payload.explanation !== undefined ? { explanation: payload.explanation } : {},
43722
+ ...payload.steps !== undefined ? { steps: payload.steps } : {}
43723
+ }));
43724
+ },
43725
+ onApprovalEvent: async (payload) => {
43726
+ if (payload.phase !== "requested")
43727
+ return;
43728
+ await pushInlineProgressPlaceholder(buildChannelProgressDraftLine({
43729
+ event: "approval",
43730
+ ...payload.phase !== undefined ? { phase: payload.phase } : {},
43731
+ ...payload.title !== undefined ? { title: payload.title } : {},
43732
+ ...payload.command !== undefined ? { command: payload.command } : {},
43733
+ ...payload.reason !== undefined ? { reason: payload.reason } : {},
43734
+ ...payload.message !== undefined ? { message: payload.message } : {}
43735
+ }), { startImmediately: true });
43736
+ },
43737
+ onCommandOutput: async (payload) => {
43738
+ if (payload.phase !== "end")
43739
+ return;
43740
+ await pushInlineProgressPlaceholder(buildChannelProgressDraftLine({
43741
+ event: "command-output",
43742
+ ...payload.phase !== undefined ? { phase: payload.phase } : {},
43743
+ ...payload.title !== undefined ? { title: payload.title } : {},
43744
+ ...payload.name !== undefined ? { name: payload.name } : {},
43745
+ ...payload.status !== undefined ? { status: payload.status } : {},
43746
+ ...payload.exitCode !== undefined ? { exitCode: payload.exitCode } : {}
43747
+ }));
43748
+ },
43749
+ onPatchSummary: async (payload) => {
43750
+ if (payload.phase !== "end")
43751
+ return;
43752
+ await pushInlineProgressPlaceholder(buildChannelProgressDraftLine({
43753
+ event: "patch",
43754
+ ...payload.phase !== undefined ? { phase: payload.phase } : {},
43755
+ ...payload.title !== undefined ? { title: payload.title } : {},
43756
+ ...payload.name !== undefined ? { name: payload.name } : {},
43757
+ ...payload.added !== undefined ? { added: payload.added } : {},
43758
+ ...payload.modified !== undefined ? { modified: payload.modified } : {},
43759
+ ...payload.deleted !== undefined ? { deleted: payload.deleted } : {},
43760
+ ...payload.summary !== undefined ? { summary: payload.summary } : {}
43761
+ }));
43762
+ }
43763
+ } : {},
43764
+ ...streamViaEditMessage || progressPlaceholderEnabled ? {
41786
43765
  onCompactionStart: async () => {
41787
43766
  await resetEditStreamOnBoundary();
43767
+ await pushInlineProgressPlaceholder("Compacting context", {
43768
+ startImmediately: true
43769
+ });
41788
43770
  }
41789
43771
  } : {},
41790
- ...streamViaEditMessage ? {
43772
+ ...streamViaEditMessage || progressPlaceholderEnabled ? {
41791
43773
  onCompactionEnd: async () => {
41792
43774
  await resetEditStreamOnBoundary();
43775
+ await pushInlineProgressPlaceholder("Resuming", {
43776
+ startImmediately: true
43777
+ });
41793
43778
  }
41794
43779
  } : {},
43780
+ ...suppressDefaultToolProgressMessages ? { suppressDefaultToolProgressMessages: true } : {},
43781
+ ...progressPlaceholderEnabled ? { allowProgressCallbacksWhenSourceDeliverySuppressed: true } : {},
41795
43782
  ...typeof disableBlockStreaming === "boolean" ? { disableBlockStreaming } : {}
41796
43783
  };
41797
43784
  try {
@@ -41805,11 +43792,12 @@ This model will be used for your next message.`, []);
41805
43792
  cfg,
41806
43793
  dispatcherOptions: {
41807
43794
  ...dispatcherPipelineOptions,
41808
- ...typingCallbacks ? { typingCallbacks } : {},
43795
+ ...buildInlineTypingDispatcherOptions(typingCallbacks),
41809
43796
  deliver: async (payload, info) => {
41810
43797
  const visiblePayload = resolveInlineChatVisibleReplyPayload(payload);
41811
43798
  if (!visiblePayload)
41812
43799
  return;
43800
+ await cleanupInlineProgressPlaceholder();
41813
43801
  const payloadRecord = visiblePayload;
41814
43802
  const rawText = resolveInlineInteractiveTextFallback({
41815
43803
  text: visiblePayload.text,
@@ -41823,23 +43811,25 @@ This model will be used for your next message.`, []);
41823
43811
  let replyToMsgId;
41824
43812
  if (visiblePayload.replyToId != null) {
41825
43813
  try {
41826
- replyToMsgId = BigInt(visiblePayload.replyToId);
43814
+ replyToMsgId = canReplyToSourceMessage ? BigInt(visiblePayload.replyToId) : undefined;
41827
43815
  } catch {}
41828
43816
  }
41829
- if (replyToMsgId == null && isGroup && msg.replyToMsgId != null) {
43817
+ if (replyToMsgId == null && canReplyToSourceMessage && isGroup && msg.replyToMsgId != null) {
41830
43818
  replyToMsgId = msg.id;
41831
43819
  }
41832
43820
  const rememberSent = (messageId) => {
41833
- if (messageId != null) {
41834
- rememberBotMessageId(botMessageIdsByChat, chatId, messageId);
41835
- }
43821
+ rememberSentBotMessage({
43822
+ chatId: deliveryChatId,
43823
+ messageId,
43824
+ replyThreadContext: deliveryReplyThreadContext
43825
+ });
41836
43826
  };
41837
43827
  const sendTextFallback = async (text, includeReplyTo, includeActions) => {
41838
43828
  const outbound = sanitizeInlineDeliveryText(text);
41839
43829
  if (!outbound.trim())
41840
43830
  return;
41841
43831
  const sent = await client.sendMessage({
41842
- chatId,
43832
+ chatId: deliveryChatId,
41843
43833
  text: outbound,
41844
43834
  ...includeReplyTo && replyToMsgId != null ? { replyToMsgId } : {},
41845
43835
  ...includeActions && outboundActions !== undefined ? { actions: outboundActions } : {},
@@ -41863,7 +43853,7 @@ This model will be used for your next message.`, []);
41863
43853
  oneofKind: "editMessage",
41864
43854
  editMessage: {
41865
43855
  messageId: editStreamState.messageId,
41866
- peerId: buildChatPeer3(chatId),
43856
+ peerId: buildChatPeer3(deliveryChatId),
41867
43857
  text: textForEdit,
41868
43858
  parseMarkdown,
41869
43859
  ...actions !== undefined ? { actions } : {}
@@ -41932,7 +43922,7 @@ This model will be used for your next message.`, []);
41932
43922
  mediaUrl
41933
43923
  });
41934
43924
  const sent = await client.sendMessage({
41935
- chatId,
43925
+ chatId: deliveryChatId,
41936
43926
  ...caption ? { text: caption } : {},
41937
43927
  media,
41938
43928
  ...isFirst && replyToMsgId != null ? { replyToMsgId } : {},
@@ -41967,20 +43957,23 @@ Attachment: ${mediaUrl}` : `Attachment: ${mediaUrl}`;
41967
43957
  dispatchError = error51;
41968
43958
  runtime.error?.(`inline dispatch failed: ${String(error51)}`);
41969
43959
  }
43960
+ await cleanupInlineProgressPlaceholder();
41970
43961
  if (!delivered && streamViaEditMessage && editStreamState.messageId != null) {
41971
43962
  delivered = true;
41972
43963
  }
41973
43964
  if (!delivered && (dispatchError != null || skippedNonSilent || failedNonSilent)) {
41974
43965
  const fallbackText = dispatchError != null ? INLINE_REQUEST_ERROR_FALLBACK : EMPTY_RESPONSE_FALLBACK;
41975
43966
  const sent = await client.sendMessage({
41976
- chatId,
43967
+ chatId: deliveryChatId,
41977
43968
  text: fallbackText,
41978
43969
  ...defaultReplyToMsgId != null ? { replyToMsgId: defaultReplyToMsgId } : {},
41979
43970
  parseMarkdown
41980
43971
  });
41981
- if (sent.messageId != null) {
41982
- rememberBotMessageId(botMessageIdsByChat, chatId, sent.messageId);
41983
- }
43972
+ rememberSentBotMessage({
43973
+ chatId: deliveryChatId,
43974
+ messageId: sent.messageId,
43975
+ replyThreadContext: deliveryReplyThreadContext
43976
+ });
41984
43977
  statusSink?.({ lastOutboundAt: Date.now() });
41985
43978
  }
41986
43979
  } finally {
@@ -42202,7 +44195,7 @@ Attachment: ${mediaUrl}` : `Attachment: ${mediaUrl}`;
42202
44195
  }
42203
44196
 
42204
44197
  // src/inline/doctor.ts
42205
- function isRecord5(value) {
44198
+ function isRecord6(value) {
42206
44199
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
42207
44200
  }
42208
44201
  function readInherited(account, parent, key) {
@@ -42213,12 +44206,12 @@ function hasEntries(value) {
42213
44206
  }
42214
44207
  function hasConfiguredGroups(account, parent) {
42215
44208
  const groups = readInherited(account, parent, "groups");
42216
- return isRecord5(groups) && Object.keys(groups).length > 0;
44209
+ return isRecord6(groups) && Object.keys(groups).length > 0;
42217
44210
  }
42218
44211
  function hasGroupScopedSenders(groups) {
42219
- if (!isRecord5(groups))
44212
+ if (!isRecord6(groups))
42220
44213
  return false;
42221
- return Object.values(groups).some((group) => isRecord5(group) && hasEntries(group.allowFrom));
44214
+ return Object.values(groups).some((group) => isRecord6(group) && hasEntries(group.allowFrom));
42222
44215
  }
42223
44216
  function hasGroupSenders(account, parent) {
42224
44217
  return hasEntries(readInherited(account, parent, "groupAllowFrom")) || hasGroupScopedSenders(readInherited(account, parent, "groups"));
@@ -42805,11 +44798,11 @@ async function probeInlineAccount(account, timeoutMs) {
42805
44798
  }
42806
44799
 
42807
44800
  // src/inline/status-issues.ts
42808
- import { asString, isRecord as isRecord6 } from "openclaw/plugin-sdk/status-helpers";
44801
+ import { asString, isRecord as isRecord7 } from "openclaw/plugin-sdk/status-helpers";
42809
44802
  var RECENT_RUNTIME_ISSUE_MS = 30 * 60 * 1000;
42810
44803
  var INLINE_CONNECT_GRACE_MS = 120 * 1000;
42811
44804
  function readInlineProbeSummary(value) {
42812
- if (!isRecord6(value)) {
44805
+ if (!isRecord7(value)) {
42813
44806
  return {};
42814
44807
  }
42815
44808
  const summary = {};
@@ -42826,12 +44819,12 @@ function looksLikeAuthError(text) {
42826
44819
  return /(401|403|unauth|forbidden|invalid token|token invalid|unauthorized)/i.test(text);
42827
44820
  }
42828
44821
  function readInlineDiagnosticsSummary(value) {
42829
- if (!isRecord6(value)) {
44822
+ if (!isRecord7(value)) {
42830
44823
  return {};
42831
44824
  }
42832
- const protocolValue = isRecord6(value.protocol) ? value.protocol : undefined;
42833
- const transportValue = (protocolValue && isRecord6(protocolValue.transport) ? protocolValue.transport : undefined) ?? (isRecord6(value.transport) ? value.transport : undefined);
42834
- const pingValue = protocolValue && isRecord6(protocolValue.ping) ? protocolValue.ping : undefined;
44825
+ const protocolValue = isRecord7(value.protocol) ? value.protocol : undefined;
44826
+ const transportValue = (protocolValue && isRecord7(protocolValue.transport) ? protocolValue.transport : undefined) ?? (isRecord7(value.transport) ? value.transport : undefined);
44827
+ const pingValue = protocolValue && isRecord7(protocolValue.ping) ? protocolValue.ping : undefined;
42835
44828
  return {
42836
44829
  ...protocolValue ? {
42837
44830
  protocol: {
@@ -42863,7 +44856,7 @@ function asFiniteNumber(value) {
42863
44856
  function collectInlineStatusIssues(accounts) {
42864
44857
  const issues = [];
42865
44858
  for (const entry of accounts) {
42866
- if (!isRecord6(entry)) {
44859
+ if (!isRecord7(entry)) {
42867
44860
  continue;
42868
44861
  }
42869
44862
  const accountId = asString(entry.accountId);
@@ -43362,7 +45355,7 @@ var inlineNativeApprovalAdapter = splitChannelApprovalCapability(inlineApprovalC
43362
45355
  // src/inline/channel.ts
43363
45356
  var activeMonitors = new Map;
43364
45357
  function resolveInlineStatePath(accountId) {
43365
- return path3.join(getInlineRuntime().state.resolveStateDir(), "channels", "inline", `${accountId}.json`);
45358
+ return path5.join(getInlineRuntime().state.resolveStateDir(), "channels", "inline", `${accountId}.json`);
43366
45359
  }
43367
45360
  async function deleteInlineAccountState(accountId) {
43368
45361
  try {
@@ -44488,11 +46481,10 @@ var inlineChannelPlugin = {
44488
46481
  ] : [],
44489
46482
  "- Inline history tools: `read` and `search` return media-aware message payloads (`media`, `attachments`, `attachmentUrls`) so image-only history remains discoverable. `search` is chat-scoped; run it per chat.",
44490
46483
  "- Inline special tools: use `inline_nudge` to send a nudge, and `inline_forward` to forward message ids between chats or users.",
44491
- ...isInlineReplyThreadsEnabled({ cfg, accountId: accountId ?? null }) ? [
44492
- "- Inline reply threads are enabled: use `thread-reply` to send into a real reply thread, with `threadId` set to the reply-thread chat id."
44493
- ] : [
44494
- "- Inline reply threads are disabled: `thread-reply` uses the legacy reply path and `thread-create` creates a normal chat, not a dedicated Inline reply-thread chat."
44495
- ]
46484
+ "- Inline reply threads: use normal `reply` for short or newly started parent-chat conversations unless the user asks for a thread.",
46485
+ "- Inline reply threads: use `thread-create` to create or reuse a real reply thread under the current/target chat. On inbound turns, omit `messageId` to anchor it to the current message, or pass `messageId`/`parentMessageId` explicitly.",
46486
+ "- Inline reply threads: use `thread-reply` to send into a real reply thread, with `threadId` set to the reply-thread chat id returned by `thread-create`. Reuse that `threadId`; do not create one thread per message.",
46487
+ "- Inline reply-thread turns include nearby parent-chat context by default. If that context is incomplete, call `inline_parent_context` before answering."
44496
46488
  ]
44497
46489
  },
44498
46490
  messaging: {
@@ -44855,5 +46847,5 @@ export {
44855
46847
  inlineChannelPlugin
44856
46848
  };
44857
46849
 
44858
- //# debugId=F677CBD78FB5C51A64756E2164756E21
46850
+ //# debugId=A439BD5C99EA226864756E2164756E21
44859
46851
  //# sourceMappingURL=channel-plugin-api.js.map