@wirecat/tg-cli 0.113.0 → 0.115.0

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 (118) hide show
  1. package/dist/bin/tg.js +6 -2
  2. package/dist/bin/tg.js.map +1 -1
  3. package/dist/bundle/{adapter-EQKEFGPB.js → adapter-ODK7R4LY.js} +56 -53
  4. package/dist/bundle/{all-profiles-TTBFF663.js → all-profiles-AQYM65BS.js} +9 -8
  5. package/dist/bundle/{anthropic-XPZS7267.js → anthropic-VBDSVNIM.js} +6 -5
  6. package/dist/bundle/{app-server-ZSZ7KRAY.js → app-server-YOIHLBNS.js} +47 -43
  7. package/dist/bundle/{bot-api-X7BOVNIO.js → bot-api-TRYLGQKK.js} +51 -47
  8. package/dist/bundle/{bot-history-DWIUIPN5.js → bot-history-7DTJLBBJ.js} +18 -16
  9. package/dist/bundle/{bun-ZGZVAJU2.js → bun-XIMM6EHD.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-UN2UJ6SI.js → bun-sqlite-6B3BL5IV.js} +5 -4
  11. package/dist/bundle/{chunk-K3F46QVN.js → chunk-2TC76TLJ.js} +4 -4
  12. package/dist/bundle/{chunk-JRTZ5I6M.js → chunk-5ROWSRK7.js} +2 -2
  13. package/dist/bundle/{chunk-PHYDBR5M.js → chunk-63YKD7YA.js} +2 -2
  14. package/dist/bundle/{chunk-PCRLXJRH.js → chunk-77M3IAVU.js} +193 -129
  15. package/dist/bundle/{chunk-VDATXIO4.js → chunk-A4BQGSKI.js} +9 -9
  16. package/dist/bundle/{chunk-HO53POQG.js → chunk-AICS3TSF.js} +8 -41
  17. package/dist/bundle/{chunk-AVUIWZTP.js → chunk-AVWPMJ6E.js} +2 -2
  18. package/dist/bundle/{chunk-G74QMORP.js → chunk-BEQPZA3S.js} +2 -2
  19. package/dist/bundle/{chunk-JO45BOYE.js → chunk-BIEBJLYO.js} +8 -3
  20. package/dist/bundle/{chunk-J6USEBA6.js → chunk-BPPRR7TV.js} +2200 -945
  21. package/dist/bundle/chunk-CCHHEMPM.js +71 -0
  22. package/dist/bundle/{chunk-T4TTRFP5.js → chunk-CNO3R4O4.js} +10 -8
  23. package/dist/bundle/{chunk-IDUYRTPF.js → chunk-D4E345BC.js} +2 -2
  24. package/dist/bundle/{chunk-OYNSFQ7K.js → chunk-D72URWJE.js} +1 -39
  25. package/dist/bundle/{chunk-T5RM4Y35.js → chunk-DIABP7ZP.js} +3 -3
  26. package/dist/bundle/chunk-EW3XTUPB.js +166 -0
  27. package/dist/bundle/{chunk-KOWQVHXI.js → chunk-GCFU6WBE.js} +3 -3
  28. package/dist/bundle/{chunk-6WJ5M2Q4.js → chunk-GWDMKEDY.js} +4 -4
  29. package/dist/bundle/{chunk-TQ6EA7TB.js → chunk-GX4DMI4H.js} +17 -16
  30. package/dist/bundle/{chunk-KK3JVOOV.js → chunk-HZKWB6WS.js} +36 -35
  31. package/dist/bundle/chunk-ILHTNOIV.js +23 -0
  32. package/dist/bundle/{chunk-JDQSX2JQ.js → chunk-IUDIRZVU.js} +8443 -7398
  33. package/dist/bundle/{chunk-TUD4MU7S.js → chunk-JZXQZW2D.js} +2 -2
  34. package/dist/bundle/{chunk-Q264PYGE.js → chunk-KDOBY524.js} +55 -20
  35. package/dist/bundle/{chunk-OQR442B6.js → chunk-KIZT2MI6.js} +1 -1
  36. package/dist/bundle/chunk-L4CMCC3V.js +34 -0
  37. package/dist/bundle/{chunk-IYKRHDX6.js → chunk-LUIPXRKN.js} +188 -57
  38. package/dist/bundle/{chunk-GX4LRLVD.js → chunk-M7B5IMH3.js} +5103 -937
  39. package/dist/bundle/{chunk-4GLMEES6.js → chunk-MUZ4KYGY.js} +4 -2
  40. package/dist/bundle/{chunk-KQ23JWLJ.js → chunk-NTW5ZE47.js} +164 -276
  41. package/dist/bundle/{chunk-UIVLDKWT.js → chunk-O7CBGHI7.js} +1 -1
  42. package/dist/bundle/{chunk-KVLCIZUK.js → chunk-OMP6ALBT.js} +3 -3
  43. package/dist/bundle/{chunk-VVA4555T.js → chunk-OSP335AJ.js} +8 -8
  44. package/dist/bundle/{chunk-EGR5IJCG.js → chunk-OUX3QMYI.js} +39 -31
  45. package/dist/bundle/{chunk-VDEXNNMH.js → chunk-PEJHI7QO.js} +6 -4
  46. package/dist/bundle/{chunk-6F6K3LWV.js → chunk-PEKTB3FQ.js} +18 -15
  47. package/dist/bundle/{chunk-Z6TRIW2O.js → chunk-POKTQZOM.js} +11 -9
  48. package/dist/bundle/chunk-PQLBPYJR.js +46 -0
  49. package/dist/bundle/{chunk-BI5YJZJB.js → chunk-PZAEI4NM.js} +115 -29
  50. package/dist/bundle/{chunk-HNN7EKIM.js → chunk-QK6VLKG5.js} +338 -169
  51. package/dist/bundle/{chunk-5NF7M4MN.js → chunk-RFRI2HFT.js} +1 -1
  52. package/dist/bundle/{chunk-OC4RRFKH.js → chunk-RHUNMU4Q.js} +6 -6
  53. package/dist/bundle/{chunk-PHPNA2HU.js → chunk-TMATSEP5.js} +14 -12
  54. package/dist/bundle/{chunk-JW7BMJ6O.js → chunk-TQYMLXDS.js} +5 -3
  55. package/dist/bundle/{chunk-MTX5EDYJ.js → chunk-U67TSAAO.js} +1136 -535
  56. package/dist/bundle/{chunk-7IWDS2CM.js → chunk-UBQ3LOF6.js} +4 -4
  57. package/dist/bundle/{chunk-UE75KPAC.js → chunk-UY7GJRGY.js} +4 -4
  58. package/dist/bundle/{chunk-OSBAISA5.js → chunk-VQCWVZWG.js} +8 -13
  59. package/dist/bundle/{chunk-XZ2ZHIAO.js → chunk-VVKEWWSO.js} +1 -1
  60. package/dist/bundle/{chunk-ENXO43TV.js → chunk-WDNNN3J4.js} +8 -8
  61. package/dist/bundle/{chunk-AGUCXSSM.js → chunk-WINKEV4F.js} +7 -20
  62. package/dist/bundle/{chunk-XXNJF3ZM.js → chunk-WMG4IGEB.js} +75 -33
  63. package/dist/bundle/{chunk-6OKGHHRL.js → chunk-WMRFAK5B.js} +35 -35
  64. package/dist/bundle/{chunk-4SQB5VKL.js → chunk-WOQGUIXE.js} +1 -1
  65. package/dist/bundle/{chunk-U3MJQLZQ.js → chunk-XIYRHIBK.js} +13 -13
  66. package/dist/bundle/{chunk-ZID2Y4XU.js → chunk-XY7IGVVS.js} +2 -2
  67. package/dist/bundle/{chunk-3MAYYFKY.js → chunk-Y3AQHPAJ.js} +1 -1
  68. package/dist/bundle/{chunk-WSAHUQ6K.js → chunk-YCUQKFGD.js} +3 -3
  69. package/dist/bundle/command-contract-YF4KGFXC.js +32 -0
  70. package/dist/bundle/{decode-AMQVTEMW.js → decode-2GATBZGH.js} +7 -6
  71. package/dist/bundle/dispatch-MJMW7WDH.js +411 -0
  72. package/dist/bundle/{echarts-ECYONFQJ.js → echarts-GKEZEAL7.js} +2 -2
  73. package/dist/bundle/{embed-VZYBZEWI.js → embed-TBQPLA4Y.js} +6 -5
  74. package/dist/bundle/{embedder-GSWBGHRK.js → embedder-B5DTNCRO.js} +11 -10
  75. package/dist/bundle/entry-A6DEW2TD.js +18 -0
  76. package/dist/bundle/failure-TLF3SISS.js +24 -0
  77. package/dist/bundle/first-run-3N5AABEY.js +27 -0
  78. package/dist/bundle/first-screen-HANARM67.js +30 -0
  79. package/dist/bundle/{instructions-AXLQQS3G.js → instructions-P5E34PQR.js} +1 -1
  80. package/dist/bundle/{mcp-VVMPUDSL.js → mcp-MNI62HHE.js} +5 -3
  81. package/dist/bundle/{node-7JHC5K77.js → node-GKPRXS5Y.js} +2 -2
  82. package/dist/bundle/{node-sqlite-LYJEK46T.js → node-sqlite-GIDPALK3.js} +11 -4
  83. package/dist/bundle/{oauth-BROPKI3K.js → oauth-C57W4IMD.js} +7 -6
  84. package/dist/bundle/{open-C6XQ46JK.js → open-E6Q4WRPU.js} +5 -3
  85. package/dist/bundle/{openai-VWSU7ZDD.js → openai-5WMXY2KP.js} +15 -14
  86. package/dist/bundle/{process-QKEFL5HL.js → process-U2P5Z6UF.js} +1 -1
  87. package/dist/bundle/{program-ACY7O33O.js → program-FEUDU6GF.js} +62 -57
  88. package/dist/bundle/{prompt-EGULVW2F.js → prompt-4NGAZGHE.js} +5 -4
  89. package/dist/bundle/{proxy-transport-KIMADLQ2.js → proxy-transport-MGCJ7JAW.js} +5 -4
  90. package/dist/bundle/{recognize-UMTKLWVR.js → recognize-EUHRBA7V.js} +4 -3
  91. package/dist/bundle/{remote-DABI7PSQ.js → remote-3JHLB2FV.js} +7 -6
  92. package/dist/bundle/{rerank-ZFATWWBE.js → rerank-ZZ45SZPC.js} +7 -6
  93. package/dist/bundle/{serve-B7YYCMGN.js → serve-XOGX5FC5.js} +12 -10
  94. package/dist/bundle/server-DRE5MJ76.js +59 -0
  95. package/dist/bundle/{server-DGKZISZH.js → server-I6O72XP5.js} +36 -34
  96. package/dist/bundle/{state-AQ2PABA5.js → state-BIUYTGH6.js} +6 -5
  97. package/dist/bundle/{store-46GJTFLJ.js → store-FOJFYOMR.js} +12 -10
  98. package/dist/bundle/store-maintenance-command-YKV2C34N.js +49 -0
  99. package/dist/bundle/tg.js +159 -14
  100. package/dist/commands/context.d.ts.map +1 -1
  101. package/dist/commands/context.js +6 -4
  102. package/dist/commands/context.js.map +1 -1
  103. package/dist/reasons.d.ts.map +1 -1
  104. package/dist/reasons.js +5 -0
  105. package/dist/reasons.js.map +1 -1
  106. package/dist/version.d.ts +1 -1
  107. package/dist/version.js +1 -1
  108. package/package.json +5 -4
  109. package/skills/tg-cli/SKILL.md +2 -0
  110. package/dist/bundle/chunk-452UZ2PU.js +0 -3603
  111. package/dist/bundle/command-contract-GV67H22L.js +0 -32
  112. package/dist/bundle/entry-LALZILY4.js +0 -14
  113. package/dist/bundle/first-run-LEAI623Q.js +0 -24
  114. package/dist/bundle/first-screen-MOCVLE23.js +0 -30
  115. package/dist/bundle/identity-54HA5GN6.js +0 -11
  116. package/dist/bundle/server-UC7UWUIS.js +0 -56
  117. package/dist/bundle/store-maintenance-command-FCFKHGRM.js +0 -45
  118. /package/dist/bundle/{chunk-HPXYN7F3.js → chunk-NUN6OGOV.js} +0 -0
@@ -3,15 +3,18 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  answerOf,
5
5
  messengerContext
6
- } from "./chunk-BI5YJZJB.js";
6
+ } from "./chunk-PZAEI4NM.js";
7
7
  import {
8
+ FETCHING,
8
9
  RULES_VERSION,
9
10
  applyTaskRulesOnArrival,
11
+ capability,
10
12
  chatEventAnswer,
11
13
  memberAnswer,
12
14
  newSendId,
13
15
  onlineDeps,
14
16
  openRequestTask,
17
+ patiently,
15
18
  pollVoteAnswer,
16
19
  queryTerms,
17
20
  senderIsMe,
@@ -20,7 +23,7 @@ import {
20
23
  syncsOneChat,
21
24
  typedQuery,
22
25
  withQuery
23
- } from "./chunk-JDQSX2JQ.js";
26
+ } from "./chunk-IUDIRZVU.js";
24
27
  import {
25
28
  stringWidth,
26
29
  wrapAnsi
@@ -45,38 +48,30 @@ import {
45
48
  modelTarget,
46
49
  nextStep,
47
50
  outputFor,
51
+ parseDuration,
48
52
  recalledAccount,
49
53
  recordLogFor,
50
54
  renderAnswer,
51
55
  snakeKeys,
52
56
  storeTable,
53
57
  withoutProviderRefs
54
- } from "./chunk-GX4LRLVD.js";
58
+ } from "./chunk-M7B5IMH3.js";
55
59
  import {
56
60
  failureKey
57
- } from "./chunk-Z6TRIW2O.js";
61
+ } from "./chunk-POKTQZOM.js";
58
62
  import {
59
63
  envName
60
- } from "./chunk-IDUYRTPF.js";
64
+ } from "./chunk-D4E345BC.js";
61
65
  import {
62
66
  holdLock,
63
67
  lockPath,
64
68
  releaseLock,
65
69
  servingProfiles,
66
70
  takeLock
67
- } from "./chunk-KOWQVHXI.js";
71
+ } from "./chunk-GCFU6WBE.js";
68
72
  import {
69
73
  holdersOf
70
- } from "./chunk-OQR442B6.js";
71
- import {
72
- checkedOptions,
73
- range
74
- } from "./chunk-JW7BMJ6O.js";
75
- import {
76
- messagesFor,
77
- systemFor,
78
- validateImages
79
- } from "./chunk-TUD4MU7S.js";
74
+ } from "./chunk-KIZT2MI6.js";
80
75
  import {
81
76
  MIGRATIONS,
82
77
  drainNoteIndex,
@@ -105,29 +100,35 @@ import {
105
100
  storeClients,
106
101
  storeContents,
107
102
  vectorIndexCounts
108
- } from "./chunk-J6USEBA6.js";
103
+ } from "./chunk-BPPRR7TV.js";
109
104
  import {
110
105
  queryFieldsOf
111
- } from "./chunk-HNN7EKIM.js";
106
+ } from "./chunk-QK6VLKG5.js";
107
+ import {
108
+ readSecret
109
+ } from "./chunk-YCUQKFGD.js";
110
+ import {
111
+ checkedOptions,
112
+ range
113
+ } from "./chunk-TQYMLXDS.js";
114
+ import {
115
+ messagesFor,
116
+ systemFor,
117
+ validateImages
118
+ } from "./chunk-JZXQZW2D.js";
112
119
  import {
113
120
  storePath
114
- } from "./chunk-PHYDBR5M.js";
121
+ } from "./chunk-63YKD7YA.js";
115
122
  import {
116
123
  openCache
117
- } from "./chunk-OSBAISA5.js";
118
- import {
119
- readSecret
120
- } from "./chunk-WSAHUQ6K.js";
124
+ } from "./chunk-VQCWVZWG.js";
121
125
  import {
122
126
  Credentials,
123
127
  pathsAreOverridden,
124
128
  resolvePaths,
125
- singleLine,
126
- visibleControls,
127
129
  writeSecurely
128
- } from "./chunk-KQ23JWLJ.js";
130
+ } from "./chunk-NTW5ZE47.js";
129
131
  import {
130
- CliError,
131
132
  array,
132
133
  boolean,
133
134
  check,
@@ -150,7 +151,12 @@ import {
150
151
  transform,
151
152
  trim,
152
153
  union
153
- } from "./chunk-PCRLXJRH.js";
154
+ } from "./chunk-77M3IAVU.js";
155
+ import {
156
+ CliError,
157
+ singleLine,
158
+ visibleControls
159
+ } from "./chunk-CCHHEMPM.js";
154
160
  import {
155
161
  __commonJS,
156
162
  __name,
@@ -5490,11 +5496,11 @@ var require_liquid_node = __commonJS({
5490
5496
  }
5491
5497
  });
5492
5498
 
5493
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5499
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
5494
5500
  import { chmodSync, constants, copyFileSync, existsSync as existsSync7, mkdirSync, realpathSync, renameSync as renameSync2, rmSync as rmSync2, statfsSync, statSync as statSync3, writeFileSync } from "node:fs";
5495
5501
  import { dirname, resolve } from "node:path";
5496
5502
 
5497
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/sealed.js
5503
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/sealed.js
5498
5504
  import { createCipheriv, createDecipheriv, createHash, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
5499
5505
  import { closeSync, createReadStream, createWriteStream, existsSync, openSync, readSync, renameSync, rmSync, statSync } from "node:fs";
5500
5506
  import { Transform } from "node:stream";
@@ -5601,7 +5607,7 @@ var unsealFile = /* @__PURE__ */ __name(async (from, to, password) => {
5601
5607
  renameSync(pending, to);
5602
5608
  }, "unsealFile");
5603
5609
 
5604
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5610
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/store/compatibility.js
5605
5611
  var SPEAKS = MIGRATIONS.at(-1)?.version ?? 0;
5606
5612
  var fileSchemaOf = /* @__PURE__ */ __name((database) => {
5607
5613
  const tracked = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'schema_migrations'").get();
@@ -5625,7 +5631,7 @@ var compatibilityOf = /* @__PURE__ */ __name((file2, migrations = MIGRATIONS) =>
5625
5631
  };
5626
5632
  }, "compatibilityOf");
5627
5633
 
5628
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/store/repair.js
5634
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/store/repair.js
5629
5635
  import { createHash as createHash2 } from "node:crypto";
5630
5636
  var COPY_MARK = "__repair_";
5631
5637
  var COPY_NAME = /__repair_[0-9a-f]{8}(_\d+)?$/;
@@ -5879,7 +5885,7 @@ var deleteCopy = /* @__PURE__ */ __name((database, name) => {
5879
5885
  return found;
5880
5886
  }, "deleteCopy");
5881
5887
 
5882
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5888
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/store-info.js
5883
5889
  import { existsSync as existsSync2, statSync as statSync2 } from "node:fs";
5884
5890
  var pendingIfKnown = /* @__PURE__ */ __name((database) => database.prepare("SELECT 1 FROM pragma_table_info('messages') WHERE name = 'normalized_text'").get() ? pendingNormalization(database) : null, "pendingIfKnown");
5885
5891
  var bytesOf = /* @__PURE__ */ __name((path) => existsSync2(path) ? statSync2(path).size : 0, "bytesOf");
@@ -5926,7 +5932,7 @@ var storeInfoCommand = /* @__PURE__ */ __name(() => annotate(new Command("info")
5926
5932
  renderAnswer(this, outputFor(this), itemOf(answer));
5927
5933
  }), "storeInfoCommand");
5928
5934
 
5929
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
5935
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/password.js
5930
5936
  var ENCRYPT_OPTION = [
5931
5937
  "--encrypt",
5932
5938
  "compress and encrypt with a password, typed at a hidden prompt or piped on stdin; it is never kept \u2014 lose it and the file cannot be opened"
@@ -5945,7 +5951,7 @@ var passwordOf = /* @__PURE__ */ __name(async (command, { twice }) => {
5945
5951
  return password;
5946
5952
  }, "passwordOf");
5947
5953
 
5948
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/rules.js
5954
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/rules.js
5949
5955
  import { existsSync as existsSync3, readFileSync } from "node:fs";
5950
5956
  import { join } from "node:path";
5951
5957
  var REPLY_ACTIONS = ["reply", "task"];
@@ -6116,7 +6122,7 @@ var problem = /* @__PURE__ */ __name((issue) => {
6116
6122
  }, "problem");
6117
6123
  var broken = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply rules ${path} cannot be read (${why}) \u2014 fix the file`), "broken");
6118
6124
 
6119
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/state.js
6125
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/state.js
6120
6126
  import { existsSync as existsSync4, readFileSync as readFileSync2 } from "node:fs";
6121
6127
  import { join as join2 } from "node:path";
6122
6128
  var ANSWERED_KEPT = 1e3;
@@ -6169,7 +6175,7 @@ var recordReply = /* @__PURE__ */ __name((state, rule2, message, now) => {
6169
6175
  }, "recordReply");
6170
6176
  var broken2 = /* @__PURE__ */ __name((path, why) => new CliError("configuration_error", `the reply state ${path} cannot be read (${why}) \u2014 fix or move the file`), "broken");
6171
6177
 
6172
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/decide.js
6178
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/decide.js
6173
6179
  var skip = /* @__PURE__ */ __name((why) => ({ skip: why }), "skip");
6174
6180
  var decide = /* @__PURE__ */ __name((rule2, incoming, state, now) => {
6175
6181
  const { message, chat, owner, sender } = incoming;
@@ -6275,7 +6281,7 @@ var filled = /* @__PURE__ */ __name((template2, senderName) => {
6275
6281
  return template2.replaceAll("{firstName}", name.split(/\s+/)[0] ?? name).replaceAll("{name}", name);
6276
6282
  }, "filled");
6277
6283
 
6278
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/template.js
6284
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/template.js
6279
6285
  var import_liquidjs = __toESM(require_liquid_node(), 1);
6280
6286
  var TEMPLATE_LIMITS = {
6281
6287
  parse: 32768,
@@ -6435,7 +6441,7 @@ var renderReplyTemplate = /* @__PURE__ */ __name(async (reply, input) => {
6435
6441
  }
6436
6442
  }, "renderReplyTemplate");
6437
6443
 
6438
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
6444
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/dry-run.js
6439
6445
  var DRY_RUN_DAYS = 7;
6440
6446
  var PAGE = 500;
6441
6447
  var dryRun = /* @__PURE__ */ __name(async (store, account, rules, { since, until = Date.now(), only, audience, render }) => {
@@ -6549,7 +6555,7 @@ var storedSince = /* @__PURE__ */ __name(async (store, account, chat, since) =>
6549
6555
  }
6550
6556
  }, "storedSince");
6551
6557
 
6552
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/embeddings/keys.js
6558
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/embeddings/keys.js
6553
6559
  var endpointKeyName = /* @__PURE__ */ __name((baseUrl) => {
6554
6560
  const host = new URL(baseUrl).host;
6555
6561
  return ["openai", "anthropic"].includes(host) ? `endpoint:${host}` : host;
@@ -6580,7 +6586,7 @@ var embeddingKeys = /* @__PURE__ */ __name((app, env = process.env, keyring) =>
6580
6586
  };
6581
6587
  }, "embeddingKeys");
6582
6588
 
6583
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/models/openai.js
6589
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/models/openai.js
6584
6590
  var options = strictObject({
6585
6591
  temperature: range(0, 2),
6586
6592
  top_p: range(0, 1),
@@ -6629,7 +6635,7 @@ var openai = {
6629
6635
  }, "complete")
6630
6636
  };
6631
6637
 
6632
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/models/index.js
6638
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/models/index.js
6633
6639
  var modelGateway = /* @__PURE__ */ __name((deps) => ({
6634
6640
  complete: /* @__PURE__ */ __name(async (request) => {
6635
6641
  if (deps.signal?.aborted)
@@ -6644,7 +6650,7 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
6644
6650
  if (!adapter && target.provider === "openai")
6645
6651
  adapter = openai;
6646
6652
  if (!adapter && target.provider === "anthropic")
6647
- adapter = (await import("./anthropic-XPZS7267.js")).anthropic;
6653
+ adapter = (await import("./anthropic-VBDSVNIM.js")).anthropic;
6648
6654
  if (!adapter)
6649
6655
  throw new CliError("validation_error", `no model adapter for ${target.provider}`);
6650
6656
  if (request.images !== void 0 && adapter.images !== true)
@@ -6685,7 +6691,7 @@ var modelGateway = /* @__PURE__ */ __name((deps) => ({
6685
6691
  }, "complete")
6686
6692
  }), "modelGateway");
6687
6693
 
6688
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/consents.js
6694
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/consents.js
6689
6695
  import { existsSync as existsSync5, readFileSync as readFileSync3 } from "node:fs";
6690
6696
  import { join as join3 } from "node:path";
6691
6697
  var shape = strictObject({
@@ -6710,7 +6716,7 @@ var mayModelReply = /* @__PURE__ */ __name((path, provider, chat) => {
6710
6716
  return consent.provider === provider && !consent.deniedChats.includes(chat);
6711
6717
  }, "mayModelReply");
6712
6718
 
6713
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/rendering.js
6719
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/rendering.js
6714
6720
  var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, options2 = {
6715
6721
  ai: true
6716
6722
  }) => async (rule2, message, chat, now) => {
@@ -6757,7 +6763,7 @@ var replyRenderer = /* @__PURE__ */ __name((app, profile, settings, env, warn, o
6757
6763
  return result2;
6758
6764
  }, "replyRenderer");
6759
6765
 
6760
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/replies/serve.js
6766
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/replies/serve.js
6761
6767
  var NOT_ALLOWED = "replies.send is not allow";
6762
6768
  var NO_RULES = "no rules";
6763
6769
  var ONLY_TASK = "opened a task, sent nothing";
@@ -6850,7 +6856,84 @@ var replyTo = /* @__PURE__ */ __name(async (deps, message) => {
6850
6856
  return { skip: why };
6851
6857
  }, "replyTo");
6852
6858
 
6853
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
6859
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-catch-up.js
6860
+ var START_SYNC_DELAY_MS = 3e4;
6861
+ var START_SYNC_BUDGET_MS = 5 * 6e4;
6862
+ var START_SYNC_WINDOW_MS = 7 * 864e5;
6863
+ var START_SYNC_PER_CHAT = 500;
6864
+ var startSync = /* @__PURE__ */ __name(({ chats, newestHeld, fetch: fetch2, note, warn, delayMs = START_SYNC_DELAY_MS, budgetMs = START_SYNC_BUDGET_MS, windowMs = START_SYNC_WINDOW_MS, now = Date.now }) => {
6865
+ const controller = new AbortController();
6866
+ let timer;
6867
+ let pass = Promise.resolve();
6868
+ let started = false;
6869
+ let done;
6870
+ const run = /* @__PURE__ */ __name(async () => {
6871
+ const stop = AbortSignal.any([controller.signal, AbortSignal.timeout(budgetMs)]);
6872
+ const floor = now() - windowMs;
6873
+ const moved = [];
6874
+ for (const chat of await chats(stop)) {
6875
+ const lastAt = Date.parse(chat.lastMessageAt ?? "");
6876
+ if (Number.isNaN(lastAt) || lastAt < floor)
6877
+ continue;
6878
+ moved.push({ chat, lastAt, held: await newestHeld(chat.id) });
6879
+ }
6880
+ const anywhere = moved.reduce((top, { held }) => held === void 0 ? top : Math.max(top, held), -Infinity);
6881
+ if (!Number.isFinite(anywhere))
6882
+ return;
6883
+ const behind = moved.filter(({ lastAt, held }) => lastAt > (held ?? anywhere)).sort((one, other) => other.lastAt - one.lastAt);
6884
+ if (behind.length === 0)
6885
+ return;
6886
+ const summary = { chats: 0, fetched: 0, failed: 0, stopped: false };
6887
+ done = summary;
6888
+ for (const { chat, held } of behind) {
6889
+ if (stop.aborted)
6890
+ break;
6891
+ try {
6892
+ summary.fetched += (await fetch2(chat.id, Math.max(held ?? anywhere, floor), stop)).fetched;
6893
+ summary.chats += 1;
6894
+ } catch (error) {
6895
+ if (stop.aborted)
6896
+ break;
6897
+ summary.failed += 1;
6898
+ const errorCode = failureKey(error);
6899
+ warn({
6900
+ code: "start_sync_chat_failed",
6901
+ chatId: chat.id,
6902
+ errorCode,
6903
+ text: `what ${chat.id} received while serve was down was not fetched: ${errorCode}`
6904
+ });
6905
+ }
6906
+ }
6907
+ summary.stopped = stop.aborted && summary.chats + summary.failed < behind.length;
6908
+ note({
6909
+ code: "start_sync",
6910
+ text: `caught up ${summary.fetched} message(s) in ${summary.chats} chat(s) that moved while serve was down` + (summary.stopped ? ` \u2014 stopped at the time limit, ${behind.length - summary.chats - summary.failed} left` : "")
6911
+ });
6912
+ }, "run");
6913
+ return {
6914
+ start: /* @__PURE__ */ __name(() => {
6915
+ if (started || controller.signal.aborted)
6916
+ return;
6917
+ started = true;
6918
+ timer = setTimeout(() => {
6919
+ pass = run().catch((error) => {
6920
+ if (controller.signal.aborted)
6921
+ return;
6922
+ const errorCode = failureKey(error);
6923
+ warn({ code: "start_sync_failed", errorCode, text: `the catch-up on start failed: ${errorCode}` });
6924
+ });
6925
+ }, delayMs);
6926
+ }, "start"),
6927
+ stop: /* @__PURE__ */ __name(async () => {
6928
+ controller.abort();
6929
+ clearTimeout(timer);
6930
+ await pass;
6931
+ }, "stop"),
6932
+ summary: /* @__PURE__ */ __name(() => done, "summary")
6933
+ };
6934
+ }, "startSync");
6935
+
6936
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-members.js
6854
6937
  var FIRST_FETCH_MS = 6e4;
6855
6938
  var DAY_MS = 864e5;
6856
6939
  var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, firstMs = FIRST_FETCH_MS, everyMs = DAY_MS }) => {
@@ -6904,7 +6987,7 @@ var memberFetches = /* @__PURE__ */ __name(({ withStore, fetch: fetch2, warn, fi
6904
6987
  };
6905
6988
  }, "memberFetches");
6906
6989
 
6907
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
6990
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-notice.js
6908
6991
  var record2 = /* @__PURE__ */ __name((context, app, severity, attributes) => recordLogFor(context.streams.diagnostic, app, { command: currentRun().command || "serve" })[severity](attributes), "record");
6909
6992
  var noticeFor = /* @__PURE__ */ __name((context, app, severity = "warn") => ({ text, ...attributes }) => {
6910
6993
  if (context.format === "pretty") {
@@ -6937,7 +7020,7 @@ var recordDiagnostics = /* @__PURE__ */ __name((context, app) => {
6937
7020
  return context;
6938
7021
  }, "recordDiagnostics");
6939
7022
 
6940
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
7023
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-stems.js
6941
7024
  var STEMS_EVERY_MS = 3e4;
6942
7025
  var STEMS_SLICE_MS = 2e3;
6943
7026
  var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY_MS, sliceMs = STEMS_SLICE_MS }) => {
@@ -6977,7 +7060,7 @@ var stemFills = /* @__PURE__ */ __name(({ withStore, warn, everyMs = STEMS_EVERY
6977
7060
  };
6978
7061
  }, "stemFills");
6979
7062
 
6980
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/render/messages.js
7063
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/render/messages.js
6981
7064
  import { styleText } from "node:util";
6982
7065
  var TIME_WIDTH = 8;
6983
7066
  var INDENT = " ".repeat(TIME_WIDTH + 2);
@@ -7153,7 +7236,7 @@ var editedAt = /* @__PURE__ */ __name((message, options2) => {
7153
7236
  return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
7154
7237
  }, "editedAt");
7155
7238
 
7156
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
7239
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/message-items.js
7157
7240
  var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, one]) => one !== void 0)), "defined");
7158
7241
  var attachmentItem = /* @__PURE__ */ __name((attachment) => defined({
7159
7242
  kind: attachment.kind,
@@ -7248,7 +7331,7 @@ var viewOf = /* @__PURE__ */ __name((context, messenger) => ({
7248
7331
  locale: messenger.app.locale
7249
7332
  }), "viewOf");
7250
7333
 
7251
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
7334
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-answers.js
7252
7335
  var observed = /* @__PURE__ */ __name((value) => ({
7253
7336
  value: value.value,
7254
7337
  observed_at: value.observedAt,
@@ -7315,7 +7398,7 @@ var watchEventItem = /* @__PURE__ */ __name((value, account) => {
7315
7398
  }
7316
7399
  }, "watchEventItem");
7317
7400
 
7318
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
7401
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/watch-command.js
7319
7402
  var watchCommand = /* @__PURE__ */ __name((messenger) => annotate(new Command("watch"), {
7320
7403
  output: { entity: "watch_item" },
7321
7404
  effects: REMOTE_READ,
@@ -7470,7 +7553,7 @@ var describe = /* @__PURE__ */ __name((event, render) => {
7470
7553
  }
7471
7554
  }, "describe");
7472
7555
 
7473
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
7556
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-command.js
7474
7557
  var serveCommand = /* @__PURE__ */ __name((messenger) => {
7475
7558
  const command = annotate(new Command("serve"), {
7476
7559
  output: { entity: "serve_summary" },
@@ -7513,7 +7596,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7513
7596
  const counts = {};
7514
7597
  const rules = replying(context, messenger, Date.parse(startedAt));
7515
7598
  const tasks = tasking(context, warn);
7516
- const { handled } = environmentOf(this);
7599
+ const { handled, startSyncDelayMs } = environmentOf(this);
7517
7600
  const count3 = /* @__PURE__ */ __name((event) => {
7518
7601
  counts[event.event] = (counts[event.event] ?? 0) + 1;
7519
7602
  if (event.event === "message") {
@@ -7537,6 +7620,50 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7537
7620
  }).chats.fetchMembers(chatId, {}), "fetch"),
7538
7621
  warn
7539
7622
  });
7623
+ const fetching = messenger.fetching ?? FETCHING;
7624
+ const catchingUp = startSync({
7625
+ chats: /* @__PURE__ */ __name(async (stop) => {
7626
+ const list = capability(connection, "chats", "list its chats");
7627
+ const all = [];
7628
+ for (let offset = 0; ; ) {
7629
+ const page = await patiently(() => list({ offset, limit: 100 }), context.renderer.note, stop);
7630
+ for (const chat of page.items)
7631
+ all.push(chat);
7632
+ offset += page.items.length;
7633
+ if (!page.hasMore || page.items.length === 0)
7634
+ return all;
7635
+ }
7636
+ }, "chats"),
7637
+ newestHeld: /* @__PURE__ */ __name((chatId) => context.withStore(async (store, account) => {
7638
+ const [newest] = await store.messages.messagesWindow(account, chatId, {
7639
+ at: startedAt,
7640
+ before: 1,
7641
+ after: 0
7642
+ });
7643
+ return newest ? Date.parse(newest.timestamp) : void 0;
7644
+ }, { name: "serve catch-up" }), "newestHeld"),
7645
+ fetch: /* @__PURE__ */ __name((chatId, sinceMs, stop) => context.withStore((store, account) => servicesFor({
7646
+ ...onlineDeps(messenger, connection, context.guard, {
7647
+ profile: context.profile,
7648
+ env: context.env
7649
+ }),
7650
+ store: /* @__PURE__ */ __name(async () => store, "store"),
7651
+ account: /* @__PURE__ */ __name(async () => account, "account")
7652
+ }).archive.fetch(chatId, {
7653
+ limit: START_SYNC_PER_CHAT,
7654
+ pageSize: fetching.page,
7655
+ pauseMs: parseDuration(fetching.pause, "pause"),
7656
+ sinceMs,
7657
+ catchUp: false,
7658
+ note: context.renderer.note,
7659
+ stop,
7660
+ onPage: /* @__PURE__ */ __name(() => {
7661
+ }, "onPage")
7662
+ }), { name: "serve catch-up" }), "fetch"),
7663
+ note,
7664
+ warn,
7665
+ ...startSyncDelayMs === void 0 ? {} : { delayMs: startSyncDelayMs }
7666
+ });
7540
7667
  const stems = stemFills({
7541
7668
  withStore: /* @__PURE__ */ __name((work) => context.withStore((store) => work(store), { name: "serve stems" }), "withStore"),
7542
7669
  warn
@@ -7551,12 +7678,15 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7551
7678
  rules.connected(open);
7552
7679
  members.start();
7553
7680
  stems.start();
7681
+ if (messenger.history !== "store" && typeof open.chats === "function")
7682
+ catchingUp.start();
7554
7683
  }, "connected")
7555
7684
  });
7556
7685
  } finally {
7557
7686
  await relaying;
7558
7687
  await relay?.close();
7559
7688
  rules.stop();
7689
+ await catchingUp.stop();
7560
7690
  await members.stop();
7561
7691
  await stems.stop();
7562
7692
  await rules.settled();
@@ -7571,6 +7701,7 @@ var serveCommand = /* @__PURE__ */ __name((messenger) => {
7571
7701
  ...rules.summary(),
7572
7702
  ...members.summary().fetched + members.summary().failed > 0 ? { members: members.summary() } : {},
7573
7703
  ...stems.summary().stemmed > 0 ? { stems: stems.summary() } : {},
7704
+ ...catchingUp.summary() ? { caught_up: catchingUp.summary() } : {},
7574
7705
  ...tasks.summary()
7575
7706
  }));
7576
7707
  });
@@ -7686,7 +7817,7 @@ var tasking = /* @__PURE__ */ __name((context, warn) => {
7686
7817
  };
7687
7818
  }, "tasking");
7688
7819
 
7689
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
7820
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-tables-command.js
7690
7821
  import { existsSync as existsSync6 } from "node:fs";
7691
7822
  var PATH = "store tables list";
7692
7823
  var STORE_TABLES_QUERY = {
@@ -7729,7 +7860,7 @@ var storeTablesCommand = /* @__PURE__ */ __name((messenger) => {
7729
7860
  return tables;
7730
7861
  }, "storeTablesCommand");
7731
7862
 
7732
- // node_modules/.pnpm/@wirecat+cli-core@0.544.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.73.0_commander@15._14d279ae6bc0fc41a3606e009c109ba5/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
7863
+ // node_modules/.pnpm/@wirecat+cli-core@0.553.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.75.0_commander@15._c8fb11a0c49a39da33a9d557d170ff7b/node_modules/@wirecat/cli-core/dist/cli/messenger/store-maintenance-command.js
7733
7864
  var SEARCH_INDEXES = ["messages_fts", "chats_fts", "identities_fts"];
7734
7865
  var WORD_INDEX = "message_words";
7735
7866
  var schemaOf = /* @__PURE__ */ __name((database) => {