@cxyhhhhh/openclaw-qqbot 2.0.0-dev.202607101939 → 2.0.0-dev.202607131536

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 (50) hide show
  1. package/README.md +188 -3
  2. package/README.zh.md +190 -3
  3. package/dist/index.cjs +879 -109
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +6 -0
  6. package/package.json +1 -1
  7. package/scripts/postinstall-link-sdk.js +170 -0
  8. package/skills/qqbot-media/SKILL.md +60 -0
  9. package/src/admin-resolver.ts +181 -0
  10. package/src/api.ts +1333 -0
  11. package/src/approval-handler.ts +505 -0
  12. package/src/credential-backup.ts +72 -0
  13. package/src/deliver-debounce.ts +229 -0
  14. package/src/dispatch/dispatch.ts +95 -75
  15. package/src/gateway.ts +2272 -0
  16. package/src/group-history.ts +328 -0
  17. package/src/image-server.ts +675 -0
  18. package/src/inbound-attachments.ts +321 -0
  19. package/src/known-users.ts +353 -0
  20. package/src/message-gating.ts +190 -0
  21. package/src/message-queue.ts +354 -0
  22. package/src/onboarding.ts +282 -0
  23. package/src/outbound/streaming-controller.ts +12 -0
  24. package/src/outbound-deliver.ts +486 -0
  25. package/src/outbound.ts +1179 -0
  26. package/src/proactive.ts +530 -0
  27. package/src/ref-index-store.ts +412 -0
  28. package/src/reply-dispatcher.ts +334 -0
  29. package/src/session-store.ts +303 -0
  30. package/src/setup/finalize.ts +1 -1
  31. package/src/slash-commands.ts +2431 -0
  32. package/src/startup-greeting.ts +120 -0
  33. package/src/streaming.ts +1077 -0
  34. package/src/stt.ts +86 -0
  35. package/src/tools/channel.ts +275 -0
  36. package/src/transport/index.ts +11 -0
  37. package/src/transport/webhook-transport.ts +332 -0
  38. package/src/transport/webhook-verify.ts +119 -0
  39. package/src/typing-keepalive.ts +59 -0
  40. package/src/typings/openclaw-webhook-ingress.d.ts +66 -0
  41. package/src/update-checker.ts +186 -0
  42. package/src/utils/audio-convert.ts +887 -0
  43. package/src/utils/chunked-upload.ts +483 -0
  44. package/src/utils/file-utils.ts +193 -0
  45. package/src/utils/image-size.ts +266 -0
  46. package/src/utils/media-send.ts +636 -0
  47. package/src/utils/media-tags.ts +183 -0
  48. package/src/utils/payload.ts +265 -0
  49. package/src/utils/text-parsing.ts +85 -0
  50. package/src/utils/upload-cache.ts +128 -0
package/dist/index.cjs CHANGED
@@ -5535,7 +5535,7 @@ async function finalizeQQBotSetup(params) {
5535
5535
  function applyAccountDefaults(cfg, accountId, userOpenid) {
5536
5536
  const next = { ...cfg, channels: { ...cfg.channels } };
5537
5537
  const qqbot = { ...next.channels?.qqbot ?? {} };
5538
- const defaults = { streaming: true, dmPolicy: "allowlist" };
5538
+ const defaults = { streaming: true, dmPolicy: "allowlist", mediaMaxMb: 200 };
5539
5539
  if (userOpenid) defaults.allowFrom = [userOpenid];
5540
5540
  if (accountId === DEFAULT_ACCOUNT_ID2) {
5541
5541
  Object.assign(qqbot, defaults);
@@ -5557,6 +5557,764 @@ var init_finalize = __esm({
5557
5557
  }
5558
5558
  });
5559
5559
 
5560
+ // node_modules/.pnpm/silk-wasm@3.7.1/node_modules/silk-wasm/lib/index.mjs
5561
+ var lib_exports = {};
5562
+ __export(lib_exports, {
5563
+ decode: () => decode,
5564
+ encode: () => encode,
5565
+ getDuration: () => getDuration,
5566
+ getWavFileInfo: () => getWavFileInfo2,
5567
+ isSilk: () => isSilk,
5568
+ isWav: () => isWav
5569
+ });
5570
+ function isWavFile(fileData) {
5571
+ try {
5572
+ let chunks = unpackWavFileChunks(fileData), fmt = decodeFormatChunk(chunks.get("fmt")), data = chunks.get("data");
5573
+ return getWavFileType(fmt), verifyDataChunkLength(data, fmt), true;
5574
+ } catch {
5575
+ return false;
5576
+ }
5577
+ }
5578
+ function decodeWavFile(fileData) {
5579
+ let chunks = unpackWavFileChunks(fileData), fmt = decodeFormatChunk(chunks.get("fmt")), data = chunks.get("data"), wavFileType = getWavFileType(fmt), audioEncoding = wavFileTypeAudioEncodings[wavFileType], wavFileTypeName = audioEncodingNames[audioEncoding] + fmt.bitsPerSample;
5580
+ return verifyDataChunkLength(data, fmt), { channelData: decodeDataChunk(data, fmt, wavFileType), sampleRate: fmt.sampleRate, numberOfChannels: fmt.numberOfChannels, audioEncoding, bitsPerSample: fmt.bitsPerSample, wavFileTypeName };
5581
+ }
5582
+ function unpackWavFileChunks(fileData) {
5583
+ let dataView;
5584
+ fileData instanceof ArrayBuffer ? dataView = new DataView(fileData) : dataView = new DataView(fileData.buffer, fileData.byteOffset, fileData.byteLength);
5585
+ let fileLength = dataView.byteLength;
5586
+ if (fileLength < 20) throw new Error("WAV file is too short.");
5587
+ if (getString(dataView, 0, 4) != "RIFF") throw new Error("Not a valid WAV file (no RIFF header).");
5588
+ let mainChunkLength = dataView.getUint32(4, true);
5589
+ if (8 + mainChunkLength != fileLength) throw new Error(`Main chunk length of WAV file (${8 + mainChunkLength}) does not match file size (${fileLength}).`);
5590
+ if (getString(dataView, 8, 4) != "WAVE") throw new Error("RIFF file is not a WAV file.");
5591
+ let chunks = /* @__PURE__ */ new Map(), fileOffset = 12;
5592
+ for (; fileOffset < fileLength; ) {
5593
+ if (fileOffset + 8 > fileLength) throw new Error(`Incomplete chunk prefix in WAV file at offset ${fileOffset}.`);
5594
+ let chunkId = getString(dataView, fileOffset, 4).trim(), chunkLength = dataView.getUint32(fileOffset + 4, true);
5595
+ if (fileOffset + 8 + chunkLength > fileLength) throw new Error(`Incomplete chunk data in WAV file at offset ${fileOffset}.`);
5596
+ let chunkData = new DataView(dataView.buffer, dataView.byteOffset + fileOffset + 8, chunkLength);
5597
+ chunks.set(chunkId, chunkData);
5598
+ let padLength = chunkLength % 2;
5599
+ fileOffset += 8 + chunkLength + padLength;
5600
+ }
5601
+ return chunks;
5602
+ }
5603
+ function getString(dataView, offset, length) {
5604
+ let a = new Uint8Array(dataView.buffer, dataView.byteOffset + offset, length);
5605
+ return String.fromCharCode.apply(null, a);
5606
+ }
5607
+ function getInt24(dataView, offset) {
5608
+ let b0 = dataView.getInt8(offset + 2) * 65536, b12 = dataView.getUint16(offset, true);
5609
+ return b0 + b12;
5610
+ }
5611
+ function decodeFormatChunk(dataView) {
5612
+ if (!dataView) throw new Error("No format chunk found in WAV file.");
5613
+ if (dataView.byteLength < 16) throw new Error("Format chunk of WAV file is too short.");
5614
+ let fmt = {};
5615
+ return fmt.formatCode = dataView.getUint16(0, true), fmt.numberOfChannels = dataView.getUint16(2, true), fmt.sampleRate = dataView.getUint32(4, true), fmt.bytesPerSec = dataView.getUint32(8, true), fmt.bytesPerFrame = dataView.getUint16(12, true), fmt.bitsPerSample = dataView.getUint16(14, true), fmt;
5616
+ }
5617
+ function getWavFileType(fmt) {
5618
+ if (fmt.numberOfChannels < 1 || fmt.numberOfChannels > 999) throw new Error("Invalid number of channels in WAV file.");
5619
+ let bytesPerSample = Math.ceil(fmt.bitsPerSample / 8), expectedBytesPerFrame = fmt.numberOfChannels * bytesPerSample;
5620
+ if (fmt.formatCode == 1 && fmt.bitsPerSample >= 1 && fmt.bitsPerSample <= 8 && fmt.bytesPerFrame == expectedBytesPerFrame) return 0;
5621
+ if (fmt.formatCode == 1 && fmt.bitsPerSample >= 9 && fmt.bitsPerSample <= 16 && fmt.bytesPerFrame == expectedBytesPerFrame) return 1;
5622
+ if (fmt.formatCode == 1 && fmt.bitsPerSample >= 17 && fmt.bitsPerSample <= 24 && fmt.bytesPerFrame == expectedBytesPerFrame) return 2;
5623
+ if (fmt.formatCode == 3 && fmt.bitsPerSample == 32 && fmt.bytesPerFrame == expectedBytesPerFrame) return 3;
5624
+ throw new Error(`Unsupported WAV file type, formatCode=${fmt.formatCode}, bitsPerSample=${fmt.bitsPerSample}, bytesPerFrame=${fmt.bytesPerFrame}, numberOfChannels=${fmt.numberOfChannels}.`);
5625
+ }
5626
+ function decodeDataChunk(data, fmt, wavFileType) {
5627
+ switch (wavFileType) {
5628
+ case 0:
5629
+ return decodeDataChunk_uint8(data, fmt);
5630
+ case 1:
5631
+ return decodeDataChunk_int16(data, fmt);
5632
+ case 2:
5633
+ return decodeDataChunk_int24(data, fmt);
5634
+ case 3:
5635
+ return decodeDataChunk_float32(data, fmt);
5636
+ default:
5637
+ throw new Error("No decoder.");
5638
+ }
5639
+ }
5640
+ function decodeDataChunk_int16(data, fmt) {
5641
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5642
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5643
+ let sampleValueFloat = data.getInt16(offs, true) / 32768;
5644
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 2;
5645
+ }
5646
+ return channelData;
5647
+ }
5648
+ function decodeDataChunk_uint8(data, fmt) {
5649
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5650
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5651
+ let sampleValueFloat = (data.getUint8(offs) - 128) / 128;
5652
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 1;
5653
+ }
5654
+ return channelData;
5655
+ }
5656
+ function decodeDataChunk_int24(data, fmt) {
5657
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5658
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5659
+ let sampleValueFloat = getInt24(data, offs) / 8388608;
5660
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 3;
5661
+ }
5662
+ return channelData;
5663
+ }
5664
+ function decodeDataChunk_float32(data, fmt) {
5665
+ let channelData = allocateChannelDataArrays(data.byteLength, fmt), numberOfChannels = fmt.numberOfChannels, numberOfFrames = channelData[0].length, offs = 0;
5666
+ for (let frameNo = 0; frameNo < numberOfFrames; frameNo++) for (let channelNo = 0; channelNo < numberOfChannels; channelNo++) {
5667
+ let sampleValueFloat = data.getFloat32(offs, true);
5668
+ channelData[channelNo][frameNo] = sampleValueFloat, offs += 4;
5669
+ }
5670
+ return channelData;
5671
+ }
5672
+ function allocateChannelDataArrays(dataLength, fmt) {
5673
+ let numberOfFrames = Math.floor(dataLength / fmt.bytesPerFrame), channelData = new Array(fmt.numberOfChannels);
5674
+ for (let channelNo = 0; channelNo < fmt.numberOfChannels; channelNo++) channelData[channelNo] = new Float32Array(numberOfFrames);
5675
+ return channelData;
5676
+ }
5677
+ function verifyDataChunkLength(data, fmt) {
5678
+ if (!data) throw new Error("No data chunk found in WAV file.");
5679
+ if (data.byteLength % fmt.bytesPerFrame != 0) throw new Error("WAV file data chunk length is not a multiple of frame size.");
5680
+ }
5681
+ function getWavFileInfo(fileData) {
5682
+ let chunks = unpackWavFileChunks(fileData), chunkInfo = getChunkInfo(chunks), fmt = decodeFormatChunk(chunks.get("fmt"));
5683
+ return { chunkInfo, fmt };
5684
+ }
5685
+ function getChunkInfo(chunks) {
5686
+ let chunkInfo = [];
5687
+ for (let e of chunks) {
5688
+ let ci = {};
5689
+ ci.chunkId = e[0], ci.dataOffset = e[1].byteOffset, ci.dataLength = e[1].byteLength, chunkInfo.push(ci);
5690
+ }
5691
+ return chunkInfo.sort((e1, e2) => e1.dataOffset - e2.dataOffset), chunkInfo;
5692
+ }
5693
+ function ensureMonoPcm(channelData) {
5694
+ let { length: numberOfChannels } = channelData;
5695
+ if (numberOfChannels === 1) return channelData[0];
5696
+ let monoData = new Float32Array(channelData[0].length);
5697
+ for (let i = 0; i < monoData.length; i++) {
5698
+ let sum = 0;
5699
+ for (let j = 0; j < numberOfChannels; j++) sum += channelData[j][i];
5700
+ monoData[i] = sum / numberOfChannels;
5701
+ }
5702
+ return monoData;
5703
+ }
5704
+ function ensureS16lePcm(input) {
5705
+ let int16Array = new Int16Array(input.length);
5706
+ for (let offset = 0; offset < input.length; offset++) {
5707
+ let x = ~~(input[offset] * 32768);
5708
+ int16Array[offset] = x > 32767 ? 32767 : x;
5709
+ }
5710
+ return int16Array.buffer;
5711
+ }
5712
+ function toUTF8String(input, start = 0, end = input.byteLength) {
5713
+ return new TextDecoder().decode(input.slice(start, end));
5714
+ }
5715
+ function binaryFromSource(source) {
5716
+ return ArrayBuffer.isView(source) ? source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength) : source;
5717
+ }
5718
+ async function encode(input, sampleRate) {
5719
+ let instance = await silk_default(), buffer = binaryFromSource(input);
5720
+ if (!buffer?.byteLength) throw new Error("input data length is 0");
5721
+ if (isWavFile(input)) {
5722
+ let { channelData, sampleRate: wavSampleRate } = decodeWavFile(input);
5723
+ sampleRate ||= wavSampleRate, buffer = ensureS16lePcm(ensureMonoPcm(channelData));
5724
+ }
5725
+ let data = new Uint8Array(), duration = instance.silk_encode(buffer, sampleRate, (output) => {
5726
+ data = output.slice();
5727
+ });
5728
+ if (duration === 0) throw new Error("silk encoding failure");
5729
+ return { data, duration };
5730
+ }
5731
+ async function decode(input, sampleRate) {
5732
+ let instance = await silk_default(), buffer = binaryFromSource(input);
5733
+ if (!buffer?.byteLength) throw new Error("input data length is 0");
5734
+ let data = new Uint8Array(), duration = instance.silk_decode(buffer, sampleRate, (output) => {
5735
+ output.length > 0 && (data = output.slice());
5736
+ });
5737
+ if (duration === 0) throw new Error("silk decoding failure");
5738
+ return { data, duration };
5739
+ }
5740
+ function getDuration(data, frameMs = 20) {
5741
+ let buffer = binaryFromSource(data), view = new DataView(buffer), byteLength = view.byteLength, offset = view.getUint8(0) === 2 ? 10 : 9, blocks = 0;
5742
+ for (; offset < byteLength; ) {
5743
+ let size = view.getUint16(offset, true);
5744
+ blocks += 1, offset += size + 2;
5745
+ }
5746
+ return blocks * frameMs;
5747
+ }
5748
+ function isWav(data) {
5749
+ return isWavFile(data);
5750
+ }
5751
+ function getWavFileInfo2(data) {
5752
+ return getWavFileInfo(data);
5753
+ }
5754
+ function isSilk(data) {
5755
+ let buffer = binaryFromSource(data);
5756
+ return buffer.byteLength < 7 ? false : toUTF8String(buffer, 0, 7).includes("#!SILK");
5757
+ }
5758
+ var import_meta, Module, silk_default, audioEncodingNames, wavFileTypeAudioEncodings;
5759
+ var init_lib = __esm({
5760
+ "node_modules/.pnpm/silk-wasm@3.7.1/node_modules/silk-wasm/lib/index.mjs"() {
5761
+ "use strict";
5762
+ import_meta = {};
5763
+ Module = async function(moduleArg = {}) {
5764
+ var moduleRtn, g2 = moduleArg, aa, q, ba = new Promise((a, b2) => {
5765
+ aa = a, q = b2;
5766
+ }), ca = typeof window == "object", da = typeof WorkerGlobalScope < "u", t = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
5767
+ if (t) {
5768
+ let { createRequire: a } = await import("module");
5769
+ var require2 = a(import_meta.url);
5770
+ }
5771
+ var u2 = (a, b2) => {
5772
+ throw b2;
5773
+ }, ea = import_meta.url, v = "", fa, w2;
5774
+ if (t) {
5775
+ var fs21 = require2("fs"), ha = require2("path");
5776
+ ea.startsWith("file:") && (v = ha.dirname(require2("url").fileURLToPath(ea)) + "/"), w2 = (a) => (a = y2(a) ? new URL(a) : a, fs21.readFileSync(a)), fa = async (a) => (a = y2(a) ? new URL(a) : a, fs21.readFileSync(a, void 0)), process.argv.slice(2), u2 = (a, b2) => {
5777
+ throw process.exitCode = a, b2;
5778
+ };
5779
+ } else if (ca || da) {
5780
+ try {
5781
+ v = new URL(".", ea).href;
5782
+ } catch {
5783
+ }
5784
+ da && (w2 = (a) => {
5785
+ var b2 = new XMLHttpRequest();
5786
+ return b2.open("GET", a, false), b2.responseType = "arraybuffer", b2.send(null), new Uint8Array(b2.response);
5787
+ }), fa = async (a) => {
5788
+ if (y2(a)) return new Promise((d3, c) => {
5789
+ var e = new XMLHttpRequest();
5790
+ e.open("GET", a, true), e.responseType = "arraybuffer", e.onload = () => {
5791
+ e.status == 200 || e.status == 0 && e.response ? d3(e.response) : c(e.status);
5792
+ }, e.onerror = c, e.send(null);
5793
+ });
5794
+ var b2 = await fetch(a, { credentials: "same-origin" });
5795
+ if (b2.ok) return b2.arrayBuffer();
5796
+ throw Error(b2.status + " : " + b2.url);
5797
+ };
5798
+ }
5799
+ console.log.bind(console);
5800
+ var A = console.error.bind(console), C2, D, E3 = false, ia, ja, F2, G, H, I, J, ka, la, ma, na, y2 = (a) => a.startsWith("file://");
5801
+ function pa() {
5802
+ var a = D.buffer;
5803
+ ja = new Int8Array(a), G = new Int16Array(a), F2 = new Uint8Array(a), H = new Uint16Array(a), I = new Int32Array(a), J = new Uint32Array(a), ka = new Float32Array(a), na = new Float64Array(a), la = new BigInt64Array(a), ma = new BigUint64Array(a);
5804
+ }
5805
+ var K = 0, L = null;
5806
+ function qa(a) {
5807
+ throw g2.onAbort?.(a), a = "Aborted(" + a + ")", A(a), E3 = true, a = new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info."), q(a), a;
5808
+ }
5809
+ var ra;
5810
+ async function sa(a) {
5811
+ if (!C2) try {
5812
+ var b2 = await fa(a);
5813
+ return new Uint8Array(b2);
5814
+ } catch {
5815
+ }
5816
+ if (a == ra && C2) a = new Uint8Array(C2);
5817
+ else if (w2) a = w2(a);
5818
+ else throw "both async and sync fetching of the wasm failed";
5819
+ return a;
5820
+ }
5821
+ async function ta(a, b2) {
5822
+ try {
5823
+ var d3 = await sa(a);
5824
+ return await WebAssembly.instantiate(d3, b2);
5825
+ } catch (c) {
5826
+ A(`failed to asynchronously prepare wasm: ${c}`), qa(c);
5827
+ }
5828
+ }
5829
+ async function ua(a) {
5830
+ var b2 = ra;
5831
+ if (!C2 && typeof WebAssembly.instantiateStreaming == "function" && !y2(b2) && !t) try {
5832
+ var d3 = fetch(b2, { credentials: "same-origin" });
5833
+ return await WebAssembly.instantiateStreaming(d3, a);
5834
+ } catch (c) {
5835
+ A(`wasm streaming compile failed: ${c}`), A("falling back to ArrayBuffer instantiation");
5836
+ }
5837
+ return ta(b2, a);
5838
+ }
5839
+ class va {
5840
+ name = "ExitStatus";
5841
+ constructor(a) {
5842
+ this.message = `Program terminated with exit(${a})`, this.status = a;
5843
+ }
5844
+ }
5845
+ var wa = (a) => {
5846
+ for (; 0 < a.length; ) a.shift()(g2);
5847
+ }, xa = [], ya = [], za = () => {
5848
+ var a = g2.preRun.shift();
5849
+ ya.push(a);
5850
+ }, O = true;
5851
+ class Aa {
5852
+ constructor(a) {
5853
+ this.I = a - 24;
5854
+ }
5855
+ }
5856
+ var Ba = 0, Ca = 0, Da, P = (a) => {
5857
+ for (var b2 = ""; F2[a]; ) b2 += Da[F2[a++]];
5858
+ return b2;
5859
+ }, Q = {}, R = {}, S = {}, T = g2.BindingError = class extends Error {
5860
+ constructor(a) {
5861
+ super(a), this.name = "BindingError";
5862
+ }
5863
+ }, Ea = (a) => {
5864
+ throw new T(a);
5865
+ };
5866
+ function Fa(a, b2, d3 = {}) {
5867
+ var c = b2.name;
5868
+ if (!a) throw new T(`type "${c}" must have a positive integer typeid pointer`);
5869
+ if (R.hasOwnProperty(a)) {
5870
+ if (d3.K) return;
5871
+ throw new T(`Cannot register type '${c}' twice`);
5872
+ }
5873
+ R[a] = b2, delete S[a], Q.hasOwnProperty(a) && (b2 = Q[a], delete Q[a], b2.forEach((e) => e()));
5874
+ }
5875
+ function U(a, b2, d3 = {}) {
5876
+ return Fa(a, b2, d3);
5877
+ }
5878
+ var Ga = (a, b2, d3) => {
5879
+ switch (b2) {
5880
+ case 1:
5881
+ return d3 ? (c) => ja[c] : (c) => F2[c];
5882
+ case 2:
5883
+ return d3 ? (c) => G[c >> 1] : (c) => H[c >> 1];
5884
+ case 4:
5885
+ return d3 ? (c) => I[c >> 2] : (c) => J[c >> 2];
5886
+ case 8:
5887
+ return d3 ? (c) => la[c >> 3] : (c) => ma[c >> 3];
5888
+ default:
5889
+ throw new TypeError(`invalid integer width (${b2}): ${a}`);
5890
+ }
5891
+ }, Ha = [], V = [], Ia = (a) => {
5892
+ 9 < a && --V[a + 1] === 0 && (V[a] = void 0, Ha.push(a));
5893
+ }, Ja = (a) => {
5894
+ if (!a) throw new T(`Cannot use deleted val. handle = ${a}`);
5895
+ return V[a];
5896
+ }, Ka = (a) => {
5897
+ switch (a) {
5898
+ case void 0:
5899
+ return 2;
5900
+ case null:
5901
+ return 4;
5902
+ case true:
5903
+ return 6;
5904
+ case false:
5905
+ return 8;
5906
+ default:
5907
+ let b2 = Ha.pop() || V.length;
5908
+ return V[b2] = a, V[b2 + 1] = 1, b2;
5909
+ }
5910
+ };
5911
+ function La(a) {
5912
+ return this.fromWireType(J[a >> 2]);
5913
+ }
5914
+ var Ma = { name: "emscripten::val", fromWireType: (a) => {
5915
+ var b2 = Ja(a);
5916
+ return Ia(a), b2;
5917
+ }, toWireType: (a, b2) => Ka(b2), H: 8, readValueFromPointer: La, G: null }, Na = (a, b2) => {
5918
+ switch (b2) {
5919
+ case 4:
5920
+ return function(d3) {
5921
+ return this.fromWireType(ka[d3 >> 2]);
5922
+ };
5923
+ case 8:
5924
+ return function(d3) {
5925
+ return this.fromWireType(na[d3 >> 3]);
5926
+ };
5927
+ default:
5928
+ throw new TypeError(`invalid float width (${b2}): ${a}`);
5929
+ }
5930
+ }, Oa = (a) => {
5931
+ for (; a.length; ) {
5932
+ var b2 = a.pop();
5933
+ a.pop()(b2);
5934
+ }
5935
+ };
5936
+ function Pa(a) {
5937
+ for (var b2 = 1; b2 < a.length; ++b2) if (a[b2] !== null && a[b2].G === void 0) return true;
5938
+ return false;
5939
+ }
5940
+ var Sa = (a, b2) => {
5941
+ if (g2[a].F === void 0) {
5942
+ var d3 = g2[a];
5943
+ g2[a] = function(...c) {
5944
+ if (!g2[a].F.hasOwnProperty(c.length)) throw new T(`Function '${b2}' called with an invalid number of arguments (${c.length}) - expects one of (${g2[a].F})!`);
5945
+ return g2[a].F[c.length].apply(this, c);
5946
+ }, g2[a].F = [], g2[a].F[d3.J] = d3;
5947
+ }
5948
+ }, Ta = (a, b2, d3) => {
5949
+ if (g2.hasOwnProperty(a)) {
5950
+ if (d3 === void 0 || g2[a].F !== void 0 && g2[a].F[d3] !== void 0) throw new T(`Cannot register public name '${a}' twice`);
5951
+ if (Sa(a, a), g2[a].F.hasOwnProperty(d3)) throw new T(`Cannot register multiple overloads of a function with the same number of arguments (${d3})!`);
5952
+ g2[a].F[d3] = b2;
5953
+ } else g2[a] = b2, g2[a].J = d3;
5954
+ }, Ua = (a, b2) => {
5955
+ for (var d3 = [], c = 0; c < a; c++) d3.push(J[b2 + 4 * c >> 2]);
5956
+ return d3;
5957
+ }, Va = g2.InternalError = class extends Error {
5958
+ constructor(a) {
5959
+ super(a), this.name = "InternalError";
5960
+ }
5961
+ }, Wa = [], Xa, Ya = (a, b2) => {
5962
+ a = P(a);
5963
+ var d3;
5964
+ if ((d3 = Wa[b2]) || (Wa[b2] = d3 = Xa.get(b2)), typeof d3 != "function") throw new T(`unknown function pointer with signature ${a}: ${b2}`);
5965
+ return d3;
5966
+ };
5967
+ class Za extends Error {
5968
+ }
5969
+ for (var ab = (a) => {
5970
+ a = $a(a);
5971
+ var b2 = P(a);
5972
+ return W(a), b2;
5973
+ }, bb = (a, b2) => {
5974
+ function d3(f) {
5975
+ e[f] || R[f] || (S[f] ? S[f].forEach(d3) : (c.push(f), e[f] = true));
5976
+ }
5977
+ var c = [], e = {};
5978
+ throw b2.forEach(d3), new Za(`${a}: ` + c.map(ab).join([", "]));
5979
+ }, cb = (a, b2) => {
5980
+ function d3(h2) {
5981
+ if (h2 = b2(h2), h2.length !== c.length) throw new Va("Mismatched type converter count");
5982
+ for (var l3 = 0; l3 < c.length; ++l3) U(c[l3], h2[l3]);
5983
+ }
5984
+ var c = [];
5985
+ c.forEach((h2) => S[h2] = a);
5986
+ var e = Array(a.length), f = [], m3 = 0;
5987
+ a.forEach((h2, l3) => {
5988
+ R.hasOwnProperty(h2) ? e[l3] = R[h2] : (f.push(h2), Q.hasOwnProperty(h2) || (Q[h2] = []), Q[h2].push(() => {
5989
+ e[l3] = R[h2], ++m3, m3 === f.length && d3(e);
5990
+ }));
5991
+ }), f.length === 0 && d3(e);
5992
+ }, db = (a) => {
5993
+ a = a.trim();
5994
+ let b2 = a.indexOf("(");
5995
+ return b2 === -1 ? a : a.slice(0, b2);
5996
+ }, eb = typeof TextDecoder < "u" ? new TextDecoder() : void 0, fb = (a = 0, b2 = NaN) => {
5997
+ var d3 = F2, c = a + b2;
5998
+ for (b2 = a; d3[b2] && !(b2 >= c); ) ++b2;
5999
+ if (16 < b2 - a && d3.buffer && eb) return eb.decode(d3.subarray(a, b2));
6000
+ for (c = ""; a < b2; ) {
6001
+ var e = d3[a++];
6002
+ if (e & 128) {
6003
+ var f = d3[a++] & 63;
6004
+ if ((e & 224) == 192) c += String.fromCharCode((e & 31) << 6 | f);
6005
+ else {
6006
+ var m3 = d3[a++] & 63;
6007
+ e = (e & 240) == 224 ? (e & 15) << 12 | f << 6 | m3 : (e & 7) << 18 | f << 12 | m3 << 6 | d3[a++] & 63, 65536 > e ? c += String.fromCharCode(e) : (e -= 65536, c += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
6008
+ }
6009
+ } else c += String.fromCharCode(e);
6010
+ }
6011
+ return c;
6012
+ }, gb = typeof TextDecoder < "u" ? new TextDecoder("utf-16le") : void 0, hb = (a, b2) => {
6013
+ for (var d3 = a >> 1, c = d3 + b2 / 2; !(d3 >= c) && H[d3]; ) ++d3;
6014
+ if (d3 <<= 1, 32 < d3 - a && gb) return gb.decode(F2.subarray(a, d3));
6015
+ for (d3 = "", c = 0; !(c >= b2 / 2); ++c) {
6016
+ var e = G[a + 2 * c >> 1];
6017
+ if (e == 0) break;
6018
+ d3 += String.fromCharCode(e);
6019
+ }
6020
+ return d3;
6021
+ }, ib = (a, b2, d3) => {
6022
+ if (d3 ??= 2147483647, 2 > d3) return 0;
6023
+ d3 -= 2;
6024
+ var c = b2;
6025
+ d3 = d3 < 2 * a.length ? d3 / 2 : a.length;
6026
+ for (var e = 0; e < d3; ++e) G[b2 >> 1] = a.charCodeAt(e), b2 += 2;
6027
+ return G[b2 >> 1] = 0, b2 - c;
6028
+ }, jb = (a) => 2 * a.length, kb = (a, b2) => {
6029
+ for (var d3 = 0, c = ""; !(d3 >= b2 / 4); ) {
6030
+ var e = I[a + 4 * d3 >> 2];
6031
+ if (e == 0) break;
6032
+ ++d3, 65536 <= e ? (e -= 65536, c += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023)) : c += String.fromCharCode(e);
6033
+ }
6034
+ return c;
6035
+ }, lb = (a, b2, d3) => {
6036
+ if (d3 ??= 2147483647, 4 > d3) return 0;
6037
+ var c = b2;
6038
+ d3 = c + d3 - 4;
6039
+ for (var e = 0; e < a.length; ++e) {
6040
+ var f = a.charCodeAt(e);
6041
+ if (55296 <= f && 57343 >= f) {
6042
+ var m3 = a.charCodeAt(++e);
6043
+ f = 65536 + ((f & 1023) << 10) | m3 & 1023;
6044
+ }
6045
+ if (I[b2 >> 2] = f, b2 += 4, b2 + 4 > d3) break;
6046
+ }
6047
+ return I[b2 >> 2] = 0, b2 - c;
6048
+ }, mb = (a) => {
6049
+ for (var b2 = 0, d3 = 0; d3 < a.length; ++d3) {
6050
+ var c = a.charCodeAt(d3);
6051
+ 55296 <= c && 57343 >= c && ++d3, b2 += 4;
6052
+ }
6053
+ return b2;
6054
+ }, nb = 0, ob = [], pb = (a) => {
6055
+ var b2 = ob.length;
6056
+ return ob.push(a), b2;
6057
+ }, qb = (a, b2) => {
6058
+ var d3 = R[a];
6059
+ if (d3 === void 0) throw a = `${b2} has unknown type ${ab(a)}`, new T(a);
6060
+ return d3;
6061
+ }, rb = (a, b2) => {
6062
+ for (var d3 = Array(a), c = 0; c < a; ++c) d3[c] = qb(J[b2 + 4 * c >> 2], `parameter ${c}`);
6063
+ return d3;
6064
+ }, sb = (a, b2, d3) => {
6065
+ var c = [];
6066
+ return a = a.toWireType(c, d3), c.length && (J[b2 >> 2] = Ka(c)), a;
6067
+ }, X = {}, tb = (a) => {
6068
+ ia = a, O || 0 < nb || (g2.onExit?.(a), E3 = true), u2(a, new va(a));
6069
+ }, ub = (a) => {
6070
+ if (!E3) try {
6071
+ if (a(), !(O || 0 < nb)) try {
6072
+ ia = a = ia, tb(a);
6073
+ } catch (b2) {
6074
+ b2 instanceof va || b2 == "unwind" || u2(1, b2);
6075
+ }
6076
+ } catch (b2) {
6077
+ b2 instanceof va || b2 == "unwind" || u2(1, b2);
6078
+ }
6079
+ }, vb = Array(256), Y = 0; 256 > Y; ++Y) vb[Y] = String.fromCharCode(Y);
6080
+ Da = vb, V.push(0, 1, void 0, 1, null, 1, true, 1, false, 1), g2.count_emval_handles = () => V.length / 2 - 5 - Ha.length, g2.noExitRuntime && (O = g2.noExitRuntime), g2.printErr && (A = g2.printErr), g2.wasmBinary && (C2 = g2.wasmBinary);
6081
+ var Ab = { u: (a, b2, d3) => {
6082
+ var c = new Aa(a);
6083
+ throw J[c.I + 16 >> 2] = 0, J[c.I + 4 >> 2] = b2, J[c.I + 8 >> 2] = d3, Ba = a, Ca++, Ba;
6084
+ }, v: () => qa(""), l: (a, b2, d3) => {
6085
+ b2 = P(b2), U(a, { name: b2, fromWireType: (c) => c, toWireType: function(c, e) {
6086
+ if (typeof e != "bigint" && typeof e != "number") throw e === null ? e = "null" : (c = typeof e, e = c === "object" || c === "array" || c === "function" ? e.toString() : "" + e), new TypeError(`Cannot convert "${e}" to ${this.name}`);
6087
+ return typeof e == "number" && (e = BigInt(e)), e;
6088
+ }, H: 8, readValueFromPointer: Ga(b2, d3, b2.indexOf("u") == -1), G: null });
6089
+ }, o: (a, b2, d3, c) => {
6090
+ b2 = P(b2), U(a, { name: b2, fromWireType: function(e) {
6091
+ return !!e;
6092
+ }, toWireType: function(e, f) {
6093
+ return f ? d3 : c;
6094
+ }, H: 8, readValueFromPointer: function(e) {
6095
+ return this.fromWireType(F2[e]);
6096
+ }, G: null });
6097
+ }, m: (a) => U(a, Ma), k: (a, b2, d3) => {
6098
+ b2 = P(b2), U(a, { name: b2, fromWireType: (c) => c, toWireType: (c, e) => e, H: 8, readValueFromPointer: Na(b2, d3), G: null });
6099
+ }, c: (a, b2, d3, c, e, f, m3) => {
6100
+ var h2 = Ua(b2, d3);
6101
+ a = P(a), a = db(a), e = Ya(c, e), Ta(a, function() {
6102
+ bb(`Cannot call ${a} due to unbound types`, h2);
6103
+ }, b2 - 1), cb(h2, (l3) => {
6104
+ var k = [l3[0], null].concat(l3.slice(1));
6105
+ l3 = a;
6106
+ var p2 = a, z = e, n = k.length;
6107
+ if (2 > n) throw new T("argTypes array size mismatch! Must at least get return value and 'this' types!");
6108
+ var B = k[1] !== null && false, M = Pa(k), Qa = k[0].name !== "void";
6109
+ z = [p2, Ea, z, f, Oa, k[0], k[1]];
6110
+ for (var x = 0; x < n - 2; ++x) z.push(k[x + 2]);
6111
+ if (!M) for (x = B ? 1 : 2; x < k.length; ++x) k[x].G !== null && z.push(k[x].G);
6112
+ M = Pa(k), x = k.length - 2;
6113
+ var r = [], N = ["fn"];
6114
+ for (B && N.push("thisWired"), n = 0; n < x; ++n) r.push(`arg${n}`), N.push(`arg${n}Wired`);
6115
+ r = r.join(","), N = N.join(","), r = `return function (${r}) {
6116
+ `, M && (r += `var destructors = [];
6117
+ `);
6118
+ var Ra = M ? "destructors" : "null", oa = "humanName throwBindingError invoker fn runDestructors retType classParam".split(" ");
6119
+ for (B && (r += `var thisWired = classParam['toWireType'](${Ra}, this);
6120
+ `), n = 0; n < x; ++n) r += `var arg${n}Wired = argType${n}['toWireType'](${Ra}, arg${n});
6121
+ `, oa.push(`argType${n}`);
6122
+ if (r += (Qa || m3 ? "var rv = " : "") + `invoker(${N});
6123
+ `, M) r += `runDestructors(destructors);
6124
+ `;
6125
+ else for (n = B ? 1 : 2; n < k.length; ++n) B = n === 1 ? "thisWired" : "arg" + (n - 2) + "Wired", k[n].G !== null && (r += `${B}_dtor(${B});
6126
+ `, oa.push(`${B}_dtor`));
6127
+ Qa && (r += `var ret = retType['fromWireType'](rv);
6128
+ return ret;
6129
+ `);
6130
+ let [yb, zb] = [oa, r + `}
6131
+ `];
6132
+ if (k = new _F(...yb, zb)(...z), p2 = Object.defineProperty(k, "name", { value: p2 }), k = b2 - 1, !g2.hasOwnProperty(l3)) throw new Va("Replacing nonexistent public symbol");
6133
+ return g2[l3].F !== void 0 && k !== void 0 ? g2[l3].F[k] = p2 : (g2[l3] = p2, g2[l3].J = k), [];
6134
+ });
6135
+ }, b: (a, b2, d3, c, e) => {
6136
+ if (b2 = P(b2), e === -1 && (e = 4294967295), e = (h2) => h2, c === 0) {
6137
+ var f = 32 - 8 * d3;
6138
+ e = (h2) => h2 << f >>> f;
6139
+ }
6140
+ var m3 = b2.includes("unsigned") ? function(h2, l3) {
6141
+ return l3 >>> 0;
6142
+ } : function(h2, l3) {
6143
+ return l3;
6144
+ };
6145
+ U(a, { name: b2, fromWireType: e, toWireType: m3, H: 8, readValueFromPointer: Ga(b2, d3, c !== 0), G: null });
6146
+ }, a: (a, b2, d3) => {
6147
+ function c(f) {
6148
+ return new e(ja.buffer, J[f + 4 >> 2], J[f >> 2]);
6149
+ }
6150
+ var e = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array][b2];
6151
+ d3 = P(d3), U(a, { name: d3, fromWireType: c, H: 8, readValueFromPointer: c }, { K: true });
6152
+ }, n: (a, b2) => {
6153
+ b2 = P(b2), U(a, { name: b2, fromWireType: function(d3) {
6154
+ for (var c = J[d3 >> 2], e = d3 + 4, f, m3 = e, h2 = 0; h2 <= c; ++h2) {
6155
+ var l3 = e + h2;
6156
+ (h2 == c || F2[l3] == 0) && (m3 = m3 ? fb(m3, l3 - m3) : "", f === void 0 ? f = m3 : (f += "\0", f += m3), m3 = l3 + 1);
6157
+ }
6158
+ return W(d3), f;
6159
+ }, toWireType: function(d3, c) {
6160
+ c instanceof ArrayBuffer && (c = new Uint8Array(c));
6161
+ var e, f = typeof c == "string";
6162
+ if (!(f || ArrayBuffer.isView(c) && c.BYTES_PER_ELEMENT == 1)) throw new T("Cannot pass non-string to std::string");
6163
+ var m3;
6164
+ if (f) for (e = m3 = 0; e < c.length; ++e) {
6165
+ var h2 = c.charCodeAt(e);
6166
+ 127 >= h2 ? m3++ : 2047 >= h2 ? m3 += 2 : 55296 <= h2 && 57343 >= h2 ? (m3 += 4, ++e) : m3 += 3;
6167
+ }
6168
+ else m3 = c.length;
6169
+ if (e = m3, m3 = wb(4 + e + 1), h2 = m3 + 4, J[m3 >> 2] = e, f) {
6170
+ if (f = h2, h2 = e + 1, e = F2, 0 < h2) {
6171
+ h2 = f + h2 - 1;
6172
+ for (var l3 = 0; l3 < c.length; ++l3) {
6173
+ var k = c.charCodeAt(l3);
6174
+ if (55296 <= k && 57343 >= k) {
6175
+ var p2 = c.charCodeAt(++l3);
6176
+ k = 65536 + ((k & 1023) << 10) | p2 & 1023;
6177
+ }
6178
+ if (127 >= k) {
6179
+ if (f >= h2) break;
6180
+ e[f++] = k;
6181
+ } else {
6182
+ if (2047 >= k) {
6183
+ if (f + 1 >= h2) break;
6184
+ e[f++] = 192 | k >> 6;
6185
+ } else {
6186
+ if (65535 >= k) {
6187
+ if (f + 2 >= h2) break;
6188
+ e[f++] = 224 | k >> 12;
6189
+ } else {
6190
+ if (f + 3 >= h2) break;
6191
+ e[f++] = 240 | k >> 18, e[f++] = 128 | k >> 12 & 63;
6192
+ }
6193
+ e[f++] = 128 | k >> 6 & 63;
6194
+ }
6195
+ e[f++] = 128 | k & 63;
6196
+ }
6197
+ }
6198
+ e[f] = 0;
6199
+ }
6200
+ } else F2.set(c, h2);
6201
+ return d3 !== null && d3.push(W, m3), m3;
6202
+ }, H: 8, readValueFromPointer: La, G(d3) {
6203
+ W(d3);
6204
+ } });
6205
+ }, e: (a, b2, d3) => {
6206
+ if (d3 = P(d3), b2 === 2) var c = hb, e = ib, f = jb, m3 = (h2) => H[h2 >> 1];
6207
+ else b2 === 4 && (c = kb, e = lb, f = mb, m3 = (h2) => J[h2 >> 2]);
6208
+ U(a, { name: d3, fromWireType: (h2) => {
6209
+ for (var l3 = J[h2 >> 2], k, p2 = h2 + 4, z = 0; z <= l3; ++z) {
6210
+ var n = h2 + 4 + z * b2;
6211
+ (z == l3 || m3(n) == 0) && (p2 = c(p2, n - p2), k === void 0 ? k = p2 : (k += "\0", k += p2), p2 = n + b2);
6212
+ }
6213
+ return W(h2), k;
6214
+ }, toWireType: (h2, l3) => {
6215
+ if (typeof l3 != "string") throw new T(`Cannot pass non-string to C++ string type ${d3}`);
6216
+ var k = f(l3), p2 = wb(4 + k + b2);
6217
+ return J[p2 >> 2] = k / b2, e(l3, p2 + 4, k + b2), h2 !== null && h2.push(W, p2), p2;
6218
+ }, H: 8, readValueFromPointer: La, G(h2) {
6219
+ W(h2);
6220
+ } });
6221
+ }, f: (a) => {
6222
+ U(a, Ma);
6223
+ }, p: (a, b2) => {
6224
+ b2 = P(b2), U(a, { L: true, name: b2, H: 0, fromWireType: () => {
6225
+ }, toWireType: () => {
6226
+ } });
6227
+ }, s: () => {
6228
+ O = false, nb = 0;
6229
+ }, i: (a, b2, d3, c) => (a = ob[a], b2 = Ja(b2), a(null, b2, d3, c)), d: Ia, h: (a, b2, d3) => {
6230
+ b2 = rb(a, b2);
6231
+ var c = b2.shift();
6232
+ a--;
6233
+ var e = `return function (obj, func, destructorsRef, args) {
6234
+ `, f = 0, m3 = [];
6235
+ d3 === 0 && m3.push("obj");
6236
+ for (var h2 = ["retType"], l3 = [c], k = 0; k < a; ++k) m3.push(`arg${k}`), h2.push(`argType${k}`), l3.push(b2[k]), e += ` var arg${k} = argType${k}.readValueFromPointer(args${f ? "+" + f : ""});
6237
+ `, f += b2[k].H;
6238
+ return e += ` var rv = ${d3 === 1 ? "new func" : "func.call"}(${m3.join(", ")});
6239
+ `, c.L || (h2.push("emval_returnValue"), l3.push(sb), e += ` return emval_returnValue(retType, destructorsRef, rv);
6240
+ `), a = new _F(...h2, e + `};
6241
+ `)(...l3), d3 = `methodCaller<(${b2.map((p2) => p2.name).join(", ")}) => ${c.name}>`, pb(Object.defineProperty(a, "name", { value: d3 }));
6242
+ }, q: (a) => {
6243
+ 9 < a && (V[a + 1] += 1);
6244
+ }, g: (a) => {
6245
+ var b2 = Ja(a);
6246
+ Oa(b2), Ia(a);
6247
+ }, j: (a, b2) => (a = qb(a, "_emval_take_value"), a = a.readValueFromPointer(b2), Ka(a)), t: (a, b2) => {
6248
+ if (X[a] && (clearTimeout(X[a].id), delete X[a]), !b2) return 0;
6249
+ var d3 = setTimeout(() => {
6250
+ delete X[a], ub(() => xb(a, performance.now()));
6251
+ }, b2);
6252
+ return X[a] = { id: d3, M: b2 }, 0;
6253
+ }, w: (a) => {
6254
+ var b2 = F2.length;
6255
+ if (a >>>= 0, 2147483648 < a) return false;
6256
+ for (var d3 = 1; 4 >= d3; d3 *= 2) {
6257
+ var c = b2 * (1 + 0.2 / d3);
6258
+ c = Math.min(c, a + 100663296);
6259
+ a: {
6260
+ c = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, c) / 65536)) - D.buffer.byteLength + 65535) / 65536 | 0;
6261
+ try {
6262
+ D.grow(c), pa();
6263
+ var e = 1;
6264
+ break a;
6265
+ } catch {
6266
+ }
6267
+ e = void 0;
6268
+ }
6269
+ if (e) return true;
6270
+ }
6271
+ return false;
6272
+ }, r: tb }, Z = await (async function() {
6273
+ function a(c) {
6274
+ return Z = c.exports, D = Z.x, pa(), Xa = Z.D, K--, g2.monitorRunDependencies?.(K), K == 0 && L && (c = L, L = null, c()), Z;
6275
+ }
6276
+ K++, g2.monitorRunDependencies?.(K);
6277
+ var b2 = { a: Ab };
6278
+ if (g2.instantiateWasm) return new Promise((c) => {
6279
+ g2.instantiateWasm(b2, (e, f) => {
6280
+ c(a(e, f));
6281
+ });
6282
+ });
6283
+ ra ??= g2.locateFile ? g2.locateFile ? g2.locateFile("silk.wasm", v) : v + "silk.wasm" : new URL("silk.wasm", import_meta.url).href;
6284
+ try {
6285
+ var d3 = await ua(b2);
6286
+ return a(d3.instance);
6287
+ } catch (c) {
6288
+ return q(c), Promise.reject(c);
6289
+ }
6290
+ })(), $a = Z.z, wb = Z.A, W = Z.B, xb = Z.C;
6291
+ function Bb() {
6292
+ function a() {
6293
+ if (g2.calledRun = true, !E3) {
6294
+ if (Z.y(), aa(g2), g2.onRuntimeInitialized?.(), g2.postRun) for (typeof g2.postRun == "function" && (g2.postRun = [g2.postRun]); g2.postRun.length; ) {
6295
+ var b2 = g2.postRun.shift();
6296
+ xa.push(b2);
6297
+ }
6298
+ wa(xa);
6299
+ }
6300
+ }
6301
+ if (0 < K) L = Bb;
6302
+ else {
6303
+ if (g2.preRun) for (typeof g2.preRun == "function" && (g2.preRun = [g2.preRun]); g2.preRun.length; ) za();
6304
+ wa(ya), 0 < K ? L = Bb : g2.setStatus ? (g2.setStatus("Running..."), setTimeout(() => {
6305
+ setTimeout(() => g2.setStatus(""), 1), a();
6306
+ }, 1)) : a();
6307
+ }
6308
+ }
6309
+ if (g2.preInit) for (typeof g2.preInit == "function" && (g2.preInit = [g2.preInit]); 0 < g2.preInit.length; ) g2.preInit.shift()();
6310
+ return Bb(), moduleRtn = ba, moduleRtn;
6311
+ };
6312
+ silk_default = Module;
6313
+ audioEncodingNames = ["int", "float"];
6314
+ wavFileTypeAudioEncodings = [0, 0, 0, 1];
6315
+ }
6316
+ });
6317
+
5560
6318
  // index.ts
5561
6319
  var index_exports = {};
5562
6320
  __export(index_exports, {
@@ -5616,11 +6374,11 @@ var import_node_os = __toESM(require("os"), 1);
5616
6374
  // src/outbound/outbound-service.ts
5617
6375
  var path3 = __toESM(require("path"), 1);
5618
6376
 
5619
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
6377
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
5620
6378
  var fs3 = __toESM(require("fs"), 1);
5621
6379
  var path = __toESM(require("path"), 1);
5622
6380
 
5623
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/types.js
6381
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/types.js
5624
6382
  function resolvePolicy(ctx, path22, explicit, defaultValue) {
5625
6383
  if (explicit !== void 0 && explicit !== null) {
5626
6384
  return explicit;
@@ -5696,7 +6454,7 @@ function createMiddlewareContext(params) {
5696
6454
  return ctx;
5697
6455
  }
5698
6456
 
5699
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/types.js
6457
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/types.js
5700
6458
  var ApiError = class extends Error {
5701
6459
  httpStatus;
5702
6460
  path;
@@ -5729,7 +6487,7 @@ var StreamContentType = {
5729
6487
  MARKDOWN: "markdown"
5730
6488
  };
5731
6489
 
5732
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/format.js
6490
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/format.js
5733
6491
  function formatErrorMessage(err) {
5734
6492
  if (err instanceof Error) {
5735
6493
  let formatted = err.message || err.name || "Error";
@@ -5776,7 +6534,7 @@ function formatFileSize(bytes) {
5776
6534
  return `${(bytes / 1024 / 1024 / 1024).toFixed(2)} GB`;
5777
6535
  }
5778
6536
 
5779
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/api-client.js
6537
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/api-client.js
5780
6538
  var DEFAULT_BASE_URL = "https://api.sgroup.qq.com";
5781
6539
  var DEFAULT_TIMEOUT_MS = 3e4;
5782
6540
  var FILE_UPLOAD_TIMEOUT_MS = 12e4;
@@ -5871,12 +6629,12 @@ var ApiClient = class {
5871
6629
  }
5872
6630
  };
5873
6631
 
5874
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
6632
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
5875
6633
  var crypto = __toESM(require("crypto"), 1);
5876
6634
  var fs = __toESM(require("fs"), 1);
5877
6635
  var https = __toESM(require("https"), 1);
5878
6636
 
5879
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/retry.js
6637
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/retry.js
5880
6638
  async function withRetry(fn, policy, persistentPolicy, logger) {
5881
6639
  let lastError = null;
5882
6640
  for (let attempt = 0; attempt <= policy.maxRetries; attempt++) {
@@ -5968,7 +6726,7 @@ function buildPartFinishPersistentPolicy(retryTimeoutMs, retryableCodes = PART_F
5968
6726
  var PART_FINISH_RETRYABLE_CODES = /* @__PURE__ */ new Set([40093001]);
5969
6727
  var UPLOAD_PREPARE_FALLBACK_CODE = 40093002;
5970
6728
 
5971
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/routes.js
6729
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/routes.js
5972
6730
  function messagePath(scope, targetId) {
5973
6731
  return scope === "c2c" ? `/v2/users/${targetId}/messages` : `/v2/groups/${targetId}/messages`;
5974
6732
  }
@@ -6005,7 +6763,7 @@ function getNextMsgSeq(_msgId) {
6005
6763
  return (timePart ^ random) % 65536;
6006
6764
  }
6007
6765
 
6008
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
6766
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media-chunked.js
6009
6767
  var UploadDailyLimitExceededError = class extends Error {
6010
6768
  filePath;
6011
6769
  fileSize;
@@ -6267,10 +7025,10 @@ function sleep2(ms) {
6267
7025
  return new Promise((resolve2) => setTimeout(resolve2, ms));
6268
7026
  }
6269
7027
 
6270
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
7028
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
6271
7029
  var fs2 = __toESM(require("fs"), 1);
6272
7030
 
6273
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/file-utils.js
7031
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/file-utils.js
6274
7032
  var MAX_UPLOAD_SIZE = 20 * 1024 * 1024;
6275
7033
  var CHUNKED_UPLOAD_MAX_SIZE = 100 * 1024 * 1024;
6276
7034
  var LARGE_FILE_THRESHOLD = 5 * 1024 * 1024;
@@ -6288,7 +7046,7 @@ function sanitizeFileName(name) {
6288
7046
  return cleaned || "file";
6289
7047
  }
6290
7048
 
6291
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
7049
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/media.js
6292
7050
  var MAX_BASE64_CHECK_SIZE = Math.ceil(MAX_UPLOAD_SIZE * 1.4);
6293
7051
  function formatUploadSize() {
6294
7052
  return formatFileSize(MAX_UPLOAD_SIZE);
@@ -6376,7 +7134,7 @@ var MediaApi = class {
6376
7134
  }
6377
7135
  };
6378
7136
 
6379
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/messages.js
7137
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/messages.js
6380
7138
  var MessageApi = class {
6381
7139
  client;
6382
7140
  tokenManager;
@@ -6564,7 +7322,7 @@ var MessageApi = class {
6564
7322
  }
6565
7323
  };
6566
7324
 
6567
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/token.js
7325
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/api/token.js
6568
7326
  var DEFAULT_TOKEN_BASE_URL = "https://bots.qq.com";
6569
7327
  var TOKEN_PATH = "/app/getAppAccessToken";
6570
7328
  var TokenManager = class {
@@ -6751,7 +7509,7 @@ var import_websocket = __toESM(require_websocket(), 1);
6751
7509
  var import_websocket_server = __toESM(require_websocket_server(), 1);
6752
7510
  var wrapper_default = import_websocket.default;
6753
7511
 
6754
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/codec.js
7512
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/codec.js
6755
7513
  function decodeGatewayMessageData(data) {
6756
7514
  if (typeof data === "string") {
6757
7515
  return data;
@@ -6778,7 +7536,7 @@ function readOptionalMessageSceneExt(event) {
6778
7536
  return scene?.ext;
6779
7537
  }
6780
7538
 
6781
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/constants.js
7539
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/constants.js
6782
7540
  var INTENTS = {
6783
7541
  GUILDS: 1 << 0,
6784
7542
  GUILD_MEMBERS: 1 << 1,
@@ -6851,7 +7609,7 @@ var GatewayEvent = {
6851
7609
  MESSAGE_REACTION_REMOVE: "MESSAGE_REACTION_REMOVE"
6852
7610
  };
6853
7611
 
6854
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/event-dispatcher.js
7612
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/event-dispatcher.js
6855
7613
  var REF_INDEX_KEY = "msg_idx";
6856
7614
  function parseRefIndices(ext, msgType, msgElements) {
6857
7615
  let refMsgIdx;
@@ -6992,7 +7750,7 @@ function dispatchEvent(eventType, data, _accountId, _log) {
6992
7750
  return { action: "raw", type: eventType, data };
6993
7751
  }
6994
7752
 
6995
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/reconnect.js
7753
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/reconnect.js
6996
7754
  var ReconnectState = class {
6997
7755
  accountId;
6998
7756
  log;
@@ -7103,7 +7861,7 @@ var ReconnectState = class {
7103
7861
  }
7104
7862
  };
7105
7863
 
7106
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/gateway-connection.js
7864
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/gateway/gateway-connection.js
7107
7865
  var GatewayConnection = class {
7108
7866
  isAborted = false;
7109
7867
  currentWs = null;
@@ -7361,7 +8119,7 @@ function previewPayload(data) {
7361
8119
  }
7362
8120
  }
7363
8121
 
7364
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-verify.js
8122
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-verify.js
7365
8123
  var crypto2 = __toESM(require("crypto"), 1);
7366
8124
  function deriveSeed(botSecret) {
7367
8125
  let seed = botSecret;
@@ -7413,7 +8171,7 @@ function signValidationResponse(params) {
7413
8171
  };
7414
8172
  }
7415
8173
 
7416
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-server-node.js
8174
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook-server-node.js
7417
8175
  var http = __toESM(require("http"), 1);
7418
8176
  var NodeHttpWebhookServer = class {
7419
8177
  server = null;
@@ -7461,7 +8219,7 @@ var NodeHttpWebhookServer = class {
7461
8219
  }
7462
8220
  };
7463
8221
 
7464
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook.js
8222
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/transport/webhook.js
7465
8223
  var OP_DISPATCH = 0;
7466
8224
  var OP_HTTP_CALLBACK_ACK = 12;
7467
8225
  var OP_VALIDATION = 13;
@@ -7605,7 +8363,7 @@ function getHeader(headers, key) {
7605
8363
  return val;
7606
8364
  }
7607
8365
 
7608
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/upload-cache.js
8366
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/upload-cache.js
7609
8367
  var crypto3 = __toESM(require("crypto"), 1);
7610
8368
  var MAX_CACHE_SIZE = 500;
7611
8369
  function computeFileHash(data) {
@@ -7670,7 +8428,7 @@ var UploadCache = class {
7670
8428
  }
7671
8429
  };
7672
8430
 
7673
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/streaming.js
8431
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/streaming.js
7674
8432
  var DEFAULT_THROTTLE_MS = 500;
7675
8433
  var MIN_THROTTLE_MS = 300;
7676
8434
  var MAX_FLUSH_RETRIES = 3;
@@ -7838,7 +8596,7 @@ var StreamSession = class {
7838
8596
  }
7839
8597
  };
7840
8598
 
7841
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
8599
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/QQBot.js
7842
8600
  var MsgType = {
7843
8601
  /** Plain text. */
7844
8602
  TEXT: 0,
@@ -8526,7 +9284,7 @@ var QQBot = class {
8526
9284
  }
8527
9285
  };
8528
9286
 
8529
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/message-filter.js
9287
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/message-filter.js
8530
9288
  function messageFilter(options = {}) {
8531
9289
  const skipSelfEcho = options.skipSelfEcho ?? true;
8532
9290
  const dedupOpts = options.dedup !== false ? { windowMs: 5e3, maxSize: 1e3, ...options.dedup ?? {} } : null;
@@ -8564,7 +9322,7 @@ function messageFilter(options = {}) {
8564
9322
  };
8565
9323
  }
8566
9324
 
8567
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/content-sanitizer.js
9325
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/content-sanitizer.js
8568
9326
  function contentSanitizer(options = {}) {
8569
9327
  const { stripBotMention = true, stripAllMentions = false, collapseWhitespace = false, parseFaceTags: parseFaceTags2 = false, transform } = options;
8570
9328
  return async (ctx, next) => {
@@ -8659,7 +9417,7 @@ function faceToEmoji(id) {
8659
9417
  return map[id];
8660
9418
  }
8661
9419
 
8662
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/rate-limiter.js
9420
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/rate-limiter.js
8663
9421
  var SlidingWindow = class {
8664
9422
  buckets = /* @__PURE__ */ new Map();
8665
9423
  max;
@@ -8713,7 +9471,7 @@ function rateLimiter(options = {}) {
8713
9471
  };
8714
9472
  }
8715
9473
 
8716
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/concurrency-guard.js
9474
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/concurrency-guard.js
8717
9475
  function concurrencyGuard(options = {}) {
8718
9476
  const strategy = options.strategy ?? "queue";
8719
9477
  const maxQueue = options.maxQueue ?? 3;
@@ -8948,7 +9706,7 @@ function concurrencyGuard(options = {}) {
8948
9706
  return guard;
8949
9707
  }
8950
9708
 
8951
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/mention-gate.js
9709
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/mention-gate.js
8952
9710
  function detectMentionInContent(content, appId) {
8953
9711
  if (!content || !appId)
8954
9712
  return false;
@@ -9004,7 +9762,7 @@ function mentionGate(options = {}) {
9004
9762
  };
9005
9763
  }
9006
9764
 
9007
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/quote-ref.js
9765
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/quote-ref.js
9008
9766
  var MemoryRefIndexStore = class {
9009
9767
  map = /* @__PURE__ */ new Map();
9010
9768
  maxSize;
@@ -9122,7 +9880,7 @@ function buildText(content, attachments) {
9122
9880
  return parts.join("\n") || "[empty message]";
9123
9881
  }
9124
9882
 
9125
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/envelope-formatter.js
9883
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/envelope-formatter.js
9126
9884
  function envelopeFormatter(options = {}) {
9127
9885
  const { historyLimit = 5, includeQuote = true, includeSender = true, format } = options;
9128
9886
  return async (ctx, next) => {
@@ -9194,7 +9952,7 @@ ${parts.join("\n")}
9194
9952
  return sections.join("\n\n");
9195
9953
  }
9196
9954
 
9197
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/slash-command.js
9955
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/slash-command.js
9198
9956
  function slashCommand(options = {}) {
9199
9957
  const prefixes = options.prefixes ?? ["/"];
9200
9958
  const catchErrors = options.catchErrors ?? true;
@@ -9347,7 +10105,7 @@ async function sendCommandResult(ctx, result) {
9347
10105
  }
9348
10106
  }
9349
10107
 
9350
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/history-buffer.js
10108
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/history-buffer.js
9351
10109
  var MemoryHistoryStore = class {
9352
10110
  buffers = /* @__PURE__ */ new Map();
9353
10111
  append(groupKey, entry, limit) {
@@ -9412,7 +10170,7 @@ function historyBuffer(options = {}) {
9412
10170
  return m3;
9413
10171
  }
9414
10172
 
9415
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/typing-indicator.js
10173
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/typing-indicator.js
9416
10174
  var DEFAULT_DURATION_SEC = 60;
9417
10175
  var DEFAULT_KEEPALIVE_INTERVAL_MS = 5e4;
9418
10176
  function typingIndicator(options = {}) {
@@ -9449,7 +10207,7 @@ function typingIndicator(options = {}) {
9449
10207
  };
9450
10208
  }
9451
10209
 
9452
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/error-handler.js
10210
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/middleware/error-handler.js
9453
10211
  var DEFAULT_FORMAT = (err) => {
9454
10212
  if (err instanceof ApiError) {
9455
10213
  if (err.bizMessage)
@@ -9487,7 +10245,7 @@ function errorHandler(options = {}) {
9487
10245
  };
9488
10246
  }
9489
10247
 
9490
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/kv-store.js
10248
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/kv-store.js
9491
10249
  var import_node_fs = __toESM(require("fs"), 1);
9492
10250
  var import_node_path = __toESM(require("path"), 1);
9493
10251
  var FileKVStore = class {
@@ -9597,7 +10355,7 @@ var FileKVStore = class {
9597
10355
  }
9598
10356
  };
9599
10357
 
9600
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/session-adapter.js
10358
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/storage/session-adapter.js
9601
10359
  function kvSessionPersistence(opts) {
9602
10360
  const prefix = opts.prefix ?? "qqbot:session:";
9603
10361
  const key = `${prefix}${opts.accountId}`;
@@ -9824,7 +10582,7 @@ var import_node_path2 = __toESM(require("path"), 1);
9824
10582
  var import_node_fs2 = __toESM(require("fs"), 1);
9825
10583
  var _cachedOpenclawVersion;
9826
10584
  function getPackageVersion() {
9827
- return true ? "2.0.0-dev.202607101939" : "unknown";
10585
+ return true ? "2.0.0-dev.202607131536" : "unknown";
9828
10586
  }
9829
10587
  function getOpenclawVersion(runtimeVersion) {
9830
10588
  if (_cachedOpenclawVersion) return _cachedOpenclawVersion;
@@ -11801,10 +12559,10 @@ function buildCommandList(account, opts) {
11801
12559
  // src/middleware/attachment.ts
11802
12560
  var path17 = __toESM(require("path"), 1);
11803
12561
 
11804
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/reply-limiter.js
12562
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/reply-limiter.js
11805
12563
  var DEFAULT_TTL_MS = 60 * 60 * 1e3;
11806
12564
 
11807
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-tags.js
12565
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-tags.js
11808
12566
  var VALID_TAGS = ["qqimg", "qqvoice", "qqvideo", "qqfile", "qqmedia"];
11809
12567
  var TAG_ALIASES = {
11810
12568
  qq_img: "qqimg",
@@ -11853,30 +12611,30 @@ var SELF_CLOSING_TAG_REGEX = new RegExp("`?" + LEFT_BRACKET + "\\s*(" + TAG_NAME
11853
12611
  var FUZZY_MEDIA_TAG_REGEX = new RegExp("`?" + LEFT_BRACKET + "\\s*(" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + `["']?\\s*([^<\uFF1C<\uFF1E>"'\`]+?)\\s*["']?` + LEFT_BRACKET + "\\s*/?\\s*(?:" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + "`?", "gi");
11854
12612
  var MULTILINE_TAG_CLEANUP = new RegExp("(" + LEFT_BRACKET + "\\s*(?:" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + ")([\\s\\S]*?)(" + LEFT_BRACKET + "\\s*/?\\s*(?:" + TAG_NAME_PATTERN + ")\\s*" + RIGHT_BRACKET + ")", "gi");
11855
12613
 
11856
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ref-index-store.js
12614
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ref-index-store.js
11857
12615
  var import_node_fs6 = __toESM(require("fs"), 1);
11858
12616
  var DEFAULT_TTL_MS2 = 7 * 24 * 60 * 60 * 1e3;
11859
12617
 
11860
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/session-store.js
12618
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/session-store.js
11861
12619
  var import_node_fs7 = __toESM(require("fs"), 1);
11862
12620
  var import_node_path7 = __toESM(require("path"), 1);
11863
12621
  var DEFAULT_EXPIRE_MS = 5 * 60 * 1e3;
11864
12622
 
11865
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/text-parsing.js
12623
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/text-parsing.js
11866
12624
  var MAX_FACE_EXT_BYTES = 64 * 1024;
11867
12625
 
11868
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-source.js
12626
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/media-source.js
11869
12627
  var fs14 = __toESM(require("fs"), 1);
11870
12628
 
11871
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/image-size.js
12629
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/image-size.js
11872
12630
  var import_node_buffer = require("buffer");
11873
12631
 
11874
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ffmpeg.js
12632
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/ffmpeg.js
11875
12633
  var import_node_child_process = require("child_process");
11876
12634
  var fs15 = __toESM(require("fs"), 1);
11877
12635
  var path13 = __toESM(require("path"), 1);
11878
12636
 
11879
- // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/audio.js
12637
+ // node_modules/.pnpm/@cxyhhhhh+qqbot-nodejs@1.0.2-dev.202607101530_mpg123-decoder@1.0.3_silk-wasm@3.7.1/node_modules/@cxyhhhhh/qqbot-nodejs/dist/protocol/utils/audio.js
11880
12638
  var import_node_child_process2 = require("child_process");
11881
12639
  var fs16 = __toESM(require("fs"), 1);
11882
12640
  var path14 = __toESM(require("path"), 1);
@@ -11887,7 +12645,7 @@ function loadSilkWasm() {
11887
12645
  }
11888
12646
  _silkWasmPromise = (async () => {
11889
12647
  try {
11890
- const mod = await import("silk-wasm");
12648
+ const mod = await Promise.resolve().then(() => (init_lib(), lib_exports));
11891
12649
  return mod;
11892
12650
  } catch {
11893
12651
  return null;
@@ -13097,12 +13855,22 @@ var StreamingController = class {
13097
13855
  lastAcceptedFull = "";
13098
13856
  /** 已成功发送的分片数(降级:=0 则走静态消息兜底) */
13099
13857
  sentChunkCount = 0;
13858
+ /** 同步标志:收到第一个 onPartialReply 即置 true(不等 async 完成) */
13859
+ _hasStarted = false;
13100
13860
  /** 串行队列 */
13101
13861
  chain = Promise.resolve();
13102
13862
  // ── 公共访问器 ──
13103
13863
  get currentPhase() {
13104
13864
  return this.phase;
13105
13865
  }
13866
+ /** 是否已成功发送至少一个流式分片 */
13867
+ get hasSentChunks() {
13868
+ return this.sentChunkCount > 0;
13869
+ }
13870
+ /** 同步标志:流式已启动(不等异步完成),用于 final 去重 */
13871
+ get hasStarted() {
13872
+ return this._hasStarted;
13873
+ }
13106
13874
  get isTerminal() {
13107
13875
  return this.phase === "done" || this.phase === "failed";
13108
13876
  }
@@ -13111,14 +13879,17 @@ var StreamingController = class {
13111
13879
  }
13112
13880
  // ── 入口 ──
13113
13881
  onPartialReply(text) {
13882
+ this._hasStarted = true;
13114
13883
  this.chain = this.chain.then(() => this.handleChunk(text)).catch((err) => {
13115
13884
  this.deps.log?.error(`onPartialReply error: ${err instanceof Error ? err.message : String(err)}`);
13885
+ this.transition("failed", "chunk_error");
13116
13886
  });
13117
13887
  return this.chain;
13118
13888
  }
13119
13889
  finalize() {
13120
13890
  this.chain = this.chain.then(() => this.handleFinalize()).catch((err) => {
13121
13891
  this.deps.log?.error(`finalize error: ${err instanceof Error ? err.message : String(err)}`);
13892
+ this.transition("failed", "finalize_error");
13122
13893
  });
13123
13894
  return this.chain;
13124
13895
  }
@@ -13291,6 +14062,8 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13291
14062
  if (streamingController) {
13292
14063
  dlog?.debug(`streaming enabled for ${envelope.senderId}`);
13293
14064
  }
14065
+ const deliveredMediaUrls = /* @__PURE__ */ new Set();
14066
+ const deliveredTexts = /* @__PURE__ */ new Set();
13294
14067
  if (!adapters.inboundRun) {
13295
14068
  if (adapters.recordInboundSession) {
13296
14069
  try {
@@ -13307,11 +14080,24 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13307
14080
  cfg,
13308
14081
  dispatcherOptions: {
13309
14082
  deliver: async (payload, info) => {
13310
- await deliverReply(payload, info, deliverCtx);
14083
+ const text = payload.text?.trim() ?? "";
14084
+ if (!payload.mediaUrl && !payload.mediaUrls?.length && text && (deliveredTexts.has(text) || streamingController?.hasStarted && !streamingController?.shouldFallbackToStatic)) {
14085
+ return;
14086
+ }
14087
+ const filteredPayload = deliveredMediaUrls.size > 0 ? {
14088
+ ...payload,
14089
+ mediaUrl: payload.mediaUrl && !deliveredMediaUrls.has(payload.mediaUrl) ? payload.mediaUrl : void 0,
14090
+ mediaUrls: payload.mediaUrls?.filter((u2) => !deliveredMediaUrls.has(u2))
14091
+ } : payload;
14092
+ await deliverReply(filteredPayload, info, deliverCtx);
14093
+ if (text) deliveredTexts.add(text);
14094
+ for (const u2 of filteredPayload.mediaUrls ?? []) deliveredMediaUrls.add(u2);
14095
+ if (filteredPayload.mediaUrl) deliveredMediaUrls.add(filteredPayload.mediaUrl);
13311
14096
  }
13312
14097
  },
13313
14098
  replyOptions: {
13314
14099
  abortSignal: ctx.signal,
14100
+ runId: envelope.messageId,
13315
14101
  ...streamingController ? {
13316
14102
  onPartialReply: async (p2) => {
13317
14103
  if (p2.text) await streamingController.onPartialReply(p2.text);
@@ -13349,8 +14135,6 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13349
14135
  }
13350
14136
  },
13351
14137
  runDispatch: () => {
13352
- let blockDelivered = false;
13353
- const deliveredMediaUrls = /* @__PURE__ */ new Set();
13354
14138
  return adapters.dispatchReply({
13355
14139
  ctx: ctxPayload,
13356
14140
  cfg,
@@ -13358,77 +14142,33 @@ async function dispatchToOpenClaw(ctx, msg, account, runtime2, log4) {
13358
14142
  deliver: async (payload, info) => {
13359
14143
  try {
13360
14144
  const kind = info?.kind;
13361
- dlog?.debug(`deliver kind=${kind ?? "none"} textLen=${payload.text?.length ?? 0} audioAsVoice=${payload.audioAsVoice ?? false} mediaUrl=${payload.mediaUrl?.slice(0, 60) ?? "none"} mediaUrls=${payload.mediaUrls?.length ?? 0}`);
14145
+ const text = payload.text?.trim() ?? "";
14146
+ const hasMedia = !!(payload.mediaUrl || payload.mediaUrls?.length);
14147
+ dlog?.debug(`deliver kind=${kind ?? "none"} textLen=${text.length} voice=${!!payload.audioAsVoice} media=${hasMedia}`);
13362
14148
  if (kind === "block") {
13363
14149
  if (payload.audioAsVoice) {
13364
14150
  await deliverReply(payload, info, deliverCtx);
13365
14151
  } else {
13366
- const urls = payload.mediaUrls?.length ? payload.mediaUrls : payload.mediaUrl ? [payload.mediaUrl] : [];
13367
- for (const url of urls) {
13368
- try {
13369
- await sendMedia2({
13370
- to: deliverCtx.qualifiedTarget,
13371
- source: url,
13372
- text: "",
13373
- replyToId: deliverCtx.replyToId,
13374
- accountId: deliverCtx.accountId,
13375
- log: deliverCtx.log,
13376
- agentId: deliverCtx.agentId
13377
- });
13378
- deliveredMediaUrls.add(url);
13379
- } catch (err) {
13380
- dlog?.error(`block media failed: ${err instanceof Error ? err.message : String(err)}`);
13381
- }
13382
- }
14152
+ await forwardMediaUrls(payload, deliverCtx, deliveredMediaUrls, dlog);
13383
14153
  }
13384
14154
  }
13385
- if (streamingController && !streamingController.shouldFallbackToStatic) {
13386
- if (kind !== "block") {
13387
- await streamingController.finalize();
13388
- }
13389
- if (!streamingController.shouldFallbackToStatic) {
13390
- if (kind === "block") return;
13391
- return;
13392
- }
14155
+ if (streamingController?.hasStarted && !streamingController.shouldFallbackToStatic) {
14156
+ if (kind !== "block") await streamingController.finalize();
14157
+ if (!streamingController.shouldFallbackToStatic) return;
13393
14158
  dlog?.warn(`streaming fallback to static`);
13394
14159
  }
13395
- if (kind === "block") {
13396
- blockDelivered = true;
13397
- } else if (kind === "final" && blockDelivered) {
14160
+ if (kind === "final" && !hasMedia && text && deliveredTexts.has(text)) {
13398
14161
  return;
13399
14162
  }
13400
14163
  if (kind === "tool") {
13401
- const toolMediaUrls = [];
13402
- if (payload.mediaUrls?.length) toolMediaUrls.push(...payload.mediaUrls);
13403
- if (payload.mediaUrl && !toolMediaUrls.includes(payload.mediaUrl)) toolMediaUrls.push(payload.mediaUrl);
13404
- const newUrls = toolMediaUrls.filter((u2) => !deliveredMediaUrls.has(u2));
13405
- for (const mediaUrl of newUrls) {
13406
- try {
13407
- await sendMedia2({
13408
- to: deliverCtx.qualifiedTarget,
13409
- source: mediaUrl,
13410
- text: "",
13411
- replyToId: deliverCtx.replyToId,
13412
- accountId: deliverCtx.accountId,
13413
- log: deliverCtx.log,
13414
- agentId: deliverCtx.agentId
13415
- });
13416
- deliveredMediaUrls.add(mediaUrl);
13417
- dlog?.info(`tool media forwarded url=${mediaUrl.slice(0, 60)}`);
13418
- } catch (err) {
13419
- dlog?.error(`tool media forward failed: ${err instanceof Error ? err.message : String(err)}`);
13420
- }
13421
- }
14164
+ await forwardMediaUrls(payload, deliverCtx, deliveredMediaUrls, dlog);
13422
14165
  return;
13423
14166
  }
13424
- const filteredPayload = deliveredMediaUrls.size > 0 ? {
13425
- ...payload,
13426
- mediaUrl: payload.mediaUrl && !deliveredMediaUrls.has(payload.mediaUrl) ? payload.mediaUrl : void 0,
13427
- mediaUrls: payload.mediaUrls?.filter((u2) => !deliveredMediaUrls.has(u2))
13428
- } : payload;
14167
+ const filteredPayload = filterDeliveredMedia(payload, deliveredMediaUrls);
13429
14168
  await deliverReply(filteredPayload, info, deliverCtx);
14169
+ if (text) deliveredTexts.add(text);
13430
14170
  } catch (err) {
13431
- dlog?.error(`error: ${err instanceof Error ? err.message : String(err)}`);
14171
+ dlog?.error(`deliver error: ${err instanceof Error ? err.message : String(err)}`);
13432
14172
  }
13433
14173
  }
13434
14174
  },
@@ -13476,6 +14216,36 @@ function createStreamingController(envelope, account, log4) {
13476
14216
  log: log4
13477
14217
  });
13478
14218
  }
14219
+ async function forwardMediaUrls(payload, ctx, delivered, log4) {
14220
+ const urls = [];
14221
+ if (payload.mediaUrls?.length) urls.push(...payload.mediaUrls);
14222
+ if (payload.mediaUrl && !urls.includes(payload.mediaUrl)) urls.push(payload.mediaUrl);
14223
+ const newUrls = urls.filter((u2) => !delivered.has(u2));
14224
+ for (const url of newUrls) {
14225
+ try {
14226
+ await sendMedia2({
14227
+ to: ctx.qualifiedTarget,
14228
+ source: url,
14229
+ text: "",
14230
+ replyToId: ctx.replyToId,
14231
+ accountId: ctx.accountId,
14232
+ log: ctx.log,
14233
+ agentId: ctx.agentId
14234
+ });
14235
+ delivered.add(url);
14236
+ } catch (err) {
14237
+ log4?.error(`media forward failed: ${err instanceof Error ? err.message : String(err)}`);
14238
+ }
14239
+ }
14240
+ }
14241
+ function filterDeliveredMedia(payload, delivered) {
14242
+ if (delivered.size === 0) return payload;
14243
+ return {
14244
+ ...payload,
14245
+ mediaUrl: payload.mediaUrl && !delivered.has(payload.mediaUrl) ? payload.mediaUrl : void 0,
14246
+ mediaUrls: payload.mediaUrls?.filter((u2) => !delivered.has(u2))
14247
+ };
14248
+ }
13479
14249
 
13480
14250
  // src/adapter/gateway.ts
13481
14251
  var import_node_module5 = require("module");