@wirecat/tg-cli 0.132.0 → 0.134.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 (160) hide show
  1. package/README.md +139 -319
  2. package/contracts/wirecat.json +82 -2
  3. package/dist/bin/tg.js +2 -2
  4. package/dist/bot/generated/types.d.ts +188 -0
  5. package/dist/bot/generated/types.d.ts.map +1 -1
  6. package/dist/bundle/{adapter-OXVMOWVE.js → adapter-Y4IXTXAG.js} +104 -68
  7. package/dist/bundle/agent-G7VHOJMS.js +37 -0
  8. package/dist/bundle/{all-profiles-6OQC7PBL.js → all-profiles-SUGID6CX.js} +62 -20
  9. package/dist/bundle/{anthropic-YFMIHFW5.js → anthropic-4QKTXT4B.js} +5 -5
  10. package/dist/bundle/{app-server-S7CJPJXN.js → app-server-TPOD6LIJ.js} +75 -65
  11. package/dist/bundle/{bot-api-KJ6EZ4R6.js → bot-api-KBESP422.js} +73 -91
  12. package/dist/bundle/{bot-history-JYCXDFW4.js → bot-history-3EORA23G.js} +23 -22
  13. package/dist/bundle/{bun-FVTOBYZ2.js → bun-FL76M4M2.js} +2 -2
  14. package/dist/bundle/{bun-sqlite-KDGWBNOR.js → bun-sqlite-H37OSTAJ.js} +6 -6
  15. package/dist/bundle/{chunk-JZJV3DYK.js → chunk-2GT563YH.js} +2 -2
  16. package/dist/bundle/{chunk-EPR67IRV.js → chunk-2JWY7CXJ.js} +4 -4
  17. package/dist/bundle/{chunk-UGD4SCUI.js → chunk-3O25FAPA.js} +3 -4
  18. package/dist/bundle/{chunk-AERP2QR6.js → chunk-3PG6QVQZ.js} +11 -25
  19. package/dist/bundle/{chunk-DXPGMUOR.js → chunk-3QQWTP77.js} +2 -2
  20. package/dist/bundle/{chunk-FIUH52FE.js → chunk-3ZNO27UE.js} +1 -1
  21. package/dist/bundle/{chunk-Y57EKZZK.js → chunk-4R2ZJGFF.js} +3274 -1674
  22. package/dist/bundle/{chunk-6LPUK62N.js → chunk-4S2DHHJM.js} +2 -100
  23. package/dist/bundle/{chunk-LF6FACSW.js → chunk-4X6BX3XP.js} +144 -10
  24. package/dist/bundle/{chunk-LZ3HFDYL.js → chunk-6DGVK5KS.js} +2 -2
  25. package/dist/bundle/chunk-6DJJVFSG.js +388 -0
  26. package/dist/bundle/{chunk-BSXS7VAC.js → chunk-6MEHKUN6.js} +1 -1
  27. package/dist/bundle/{chunk-44A2XRDE.js → chunk-6UNLEQA5.js} +31 -20
  28. package/dist/bundle/{chunk-M2TV6BDB.js → chunk-77E7Q4EQ.js} +7 -7
  29. package/dist/bundle/chunk-7GGDCQJ5.js +353 -0
  30. package/dist/bundle/{chunk-OGZZUDJJ.js → chunk-AHVWZDXO.js} +79 -64
  31. package/dist/bundle/{chunk-YVI5SQPY.js → chunk-ANBI3OXK.js} +1 -1
  32. package/dist/bundle/{chunk-PR4F3TYK.js → chunk-AYWST6NA.js} +60 -51
  33. package/dist/bundle/{chunk-7SEVVE3X.js → chunk-CA7DY2YU.js} +3 -3
  34. package/dist/bundle/{chunk-O43PARFS.js → chunk-CDKXZLMP.js} +273 -176
  35. package/dist/bundle/{chunk-YAPO7QNO.js → chunk-CNGNR4CY.js} +6 -6
  36. package/dist/bundle/{chunk-2UGSIHLV.js → chunk-CSXCCK6J.js} +2 -2
  37. package/dist/bundle/{chunk-N5LZ6L4D.js → chunk-DG35TQ6P.js} +3 -3
  38. package/dist/bundle/{chunk-LMGVPDXN.js → chunk-EXMAWEHC.js} +2 -2
  39. package/dist/bundle/{chunk-A5D3J7XZ.js → chunk-FR3ATU5I.js} +4 -4
  40. package/dist/bundle/{chunk-JDNDWZYS.js → chunk-FR4Y5CGW.js} +4 -4
  41. package/dist/bundle/{chunk-YSNQGOUI.js → chunk-GIGZTI74.js} +2115 -1975
  42. package/dist/bundle/{chunk-3QHKZLBU.js → chunk-H3TLAYGY.js} +4 -4
  43. package/dist/bundle/{chunk-KJICORS4.js → chunk-HD7DV5B2.js} +65 -43
  44. package/dist/bundle/{chunk-NLRGMP7M.js → chunk-HETHFOHC.js} +3 -3
  45. package/dist/bundle/{chunk-4YB7JU2W.js → chunk-HEZK4W3U.js} +6 -6
  46. package/dist/bundle/{chunk-2LZD2VFV.js → chunk-IJ7R2WMK.js} +4 -4
  47. package/dist/bundle/{chunk-4ZTVJHWU.js → chunk-ITJ7DGNA.js} +4 -4
  48. package/dist/bundle/{chunk-5UPEEMEF.js → chunk-J5RB4ASI.js} +142 -372
  49. package/dist/bundle/{chunk-IY7CTAOQ.js → chunk-JAL443BH.js} +9 -9
  50. package/dist/bundle/{chunk-U7PHJSTX.js → chunk-JCDD5T3A.js} +2 -2
  51. package/dist/bundle/{chunk-BLZEQVP4.js → chunk-JHZJBNDO.js} +2 -2
  52. package/dist/bundle/chunk-JWLODUN3.js +555 -0
  53. package/dist/bundle/{chunk-4CKYANQH.js → chunk-JWNSG5GI.js} +1 -1
  54. package/dist/bundle/{chunk-YRXSNH3R.js → chunk-JXEO5EIN.js} +2 -2
  55. package/dist/bundle/{chunk-DSJNZXTP.js → chunk-K5FK6WWN.js} +1 -1
  56. package/dist/bundle/{chunk-LG3K5NHX.js → chunk-L47PFECD.js} +7 -7
  57. package/dist/bundle/{chunk-OIRNHSAH.js → chunk-L4PNDW4S.js} +6 -6
  58. package/dist/bundle/{chunk-WAVRUADL.js → chunk-M323L5SG.js} +30 -15
  59. package/dist/bundle/{chunk-AUZWIBHJ.js → chunk-MMDFPBFZ.js} +43 -64
  60. package/dist/bundle/{chunk-FKGYXIN7.js → chunk-MUV73B5A.js} +7 -7
  61. package/dist/bundle/chunk-MXA3FU2R.js +116 -0
  62. package/dist/bundle/{chunk-42MXCMW6.js → chunk-NUD4CBHK.js} +3 -3
  63. package/dist/bundle/{chunk-PG37E63A.js → chunk-NYEVPAF2.js} +511 -472
  64. package/dist/bundle/{chunk-QS46C5SW.js → chunk-O3QBO6NW.js} +17 -17
  65. package/dist/bundle/{chunk-CFWFESBO.js → chunk-O4ZOQJ6W.js} +9 -9
  66. package/dist/bundle/{chunk-74UPKW7H.js → chunk-OJSPB4LA.js} +2 -2
  67. package/dist/bundle/{chunk-JNWKV3QV.js → chunk-PCBVSHKD.js} +4 -4
  68. package/dist/bundle/{chunk-5RDNBG7D.js → chunk-PK5WEGPJ.js} +2 -2
  69. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  70. package/dist/bundle/{chunk-BMI2NWFI.js → chunk-PRI2XTM7.js} +35 -12
  71. package/dist/bundle/chunk-PRM7GKBV.js +340 -0
  72. package/dist/bundle/{chunk-ZZ32DXTH.js → chunk-PZ2ZFPGO.js} +1 -1
  73. package/dist/bundle/chunk-QYRK4XXH.js +727 -0
  74. package/dist/bundle/{chunk-QNEAPLOP.js → chunk-RVA3CRSY.js} +12 -12
  75. package/dist/bundle/{chunk-4EDJJQJI.js → chunk-SPXNI53Z.js} +38 -9
  76. package/dist/bundle/{chunk-ZRW3DF25.js → chunk-TI5U6AUT.js} +34 -28
  77. package/dist/bundle/{chunk-SMQ45RZX.js → chunk-TKWYXM7L.js} +9 -60
  78. package/dist/bundle/{chunk-ZJIGVT6Z.js → chunk-TZCFJJEU.js} +6 -6
  79. package/dist/bundle/chunk-UTTEAOJ3.js +7 -0
  80. package/dist/bundle/chunk-V6G4LTXU.js +50 -0
  81. package/dist/bundle/{chunk-JMJOWT4N.js → chunk-VH4J7IIS.js} +1 -1
  82. package/dist/bundle/{chunk-UAFSDTID.js → chunk-VNJRWFHP.js} +1 -1
  83. package/dist/bundle/chunk-W2QSDPG6.js +80 -0
  84. package/dist/bundle/{chunk-ESOFH7PA.js → chunk-WGGUKQE7.js} +134 -558
  85. package/dist/bundle/{chunk-NWDADTPE.js → chunk-WPXVJGSL.js} +3 -3
  86. package/dist/bundle/{chunk-NWCFO37P.js → chunk-XLNV3U6N.js} +3 -3
  87. package/dist/bundle/{chunk-JPSRC732.js → chunk-XS4EE7MO.js} +17 -15
  88. package/dist/bundle/{chunk-FPSRT2TX.js → chunk-XVRLD3LN.js} +2 -2
  89. package/dist/bundle/{chunk-O3AM32YN.js → chunk-XZ6XEAJP.js} +18 -18
  90. package/dist/bundle/{chunk-B4LGDOG5.js → chunk-YHTSJMZ5.js} +3734 -3380
  91. package/dist/bundle/chunk-YPJCURT6.js +108 -0
  92. package/dist/bundle/{chunk-HBSKP7OV.js → chunk-Z77R76S2.js} +1 -1
  93. package/dist/bundle/{chunk-PYECFCPD.js → chunk-ZC7OEYDX.js} +1 -1
  94. package/dist/bundle/{chunk-IYJ4B632.js → chunk-ZW2N2GI2.js} +12 -12
  95. package/dist/bundle/command-contract-LEFXJAA3.js +37 -0
  96. package/dist/bundle/{command-server-entry-TM264M2J.js → command-server-entry-WQAE5UGU.js} +27 -27
  97. package/dist/bundle/{decode-RJFOSHCE.js → decode-2J2DOVGV.js} +5 -5
  98. package/dist/bundle/{dispatch-7OZP3X4O.js → dispatch-IZ2TP5GW.js} +8 -8
  99. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  100. package/dist/bundle/{echarts-PYKF4D7B.js → echarts-GFIIHZ4U.js} +2 -2
  101. package/dist/bundle/{embed-JFN6Z5TG.js → embed-AGOXADHW.js} +6 -6
  102. package/dist/bundle/{embedder-WN54JIMY.js → embedder-PCIXGM2Y.js} +9 -9
  103. package/dist/bundle/{entry-Z6LO6N6S.js → entry-HUQXUV52.js} +9 -9
  104. package/dist/bundle/{failure-UONA2IA5.js → failure-JSRHZ2S6.js} +2 -2
  105. package/dist/bundle/{first-run-WQAKES7G.js → first-run-2LXN7B33.js} +12 -12
  106. package/dist/bundle/first-screen-VUE6RCSF.js +37 -0
  107. package/dist/bundle/{instructions-PR4BBBTM.js → instructions-RSLTJVFJ.js} +1 -1
  108. package/dist/bundle/{mcp-O6ACR2DX.js → mcp-MMENCB7I.js} +2 -2
  109. package/dist/bundle/meeting-combined-PBNPHOM3.js +23 -0
  110. package/dist/bundle/{meeting-model-YVTUOM4H.js → meeting-model-SI77WMMK.js} +11 -11
  111. package/dist/bundle/{meeting-semantic-X4KG6RNV.js → meeting-semantic-WRXWUR4M.js} +6 -6
  112. package/dist/bundle/{node-OVS5LTVZ.js → node-5XGMCUGQ.js} +2 -2
  113. package/dist/bundle/{node-sqlite-LC44SM4Z.js → node-sqlite-ES7SQSIC.js} +7 -7
  114. package/dist/bundle/{oauth-NSVUFQCW.js → oauth-QFM4Y6N7.js} +8 -8
  115. package/dist/bundle/{open-XN5SJFVY.js → open-2MD2DKGQ.js} +5 -5
  116. package/dist/bundle/{openai-WOYZHJNL.js → openai-6TMKJKYO.js} +15 -15
  117. package/dist/bundle/{process-UFBRGTQC.js → process-VA2DP7MY.js} +1 -1
  118. package/dist/bundle/{program-RAGBRRQH.js → program-K3SLEA42.js} +70 -63
  119. package/dist/bundle/{prompt-6HAKBUQN.js → prompt-VZSPCE6E.js} +5 -5
  120. package/dist/bundle/{proxy-transport-5EJVFUTC.js → proxy-transport-OJU2EOOC.js} +5 -5
  121. package/dist/bundle/{recognize-CN5COBVJ.js → recognize-LH3ZZEIL.js} +4 -4
  122. package/dist/bundle/{remote-STX5AMGE.js → remote-JNW5HN2I.js} +9 -9
  123. package/dist/bundle/{rerank-ZCOWTXIJ.js → rerank-P23UJMII.js} +7 -7
  124. package/dist/bundle/{serve-XMQEOIG2.js → serve-VSLLMILH.js} +15 -15
  125. package/dist/bundle/{server-PGGUD3DM.js → server-FBRRRKCS.js} +68 -57
  126. package/dist/bundle/server-TA4QP7PG.js +78 -0
  127. package/dist/bundle/{sqlite-runtime-PS4DSOIU.js → sqlite-runtime-LWATDAAU.js} +6 -6
  128. package/dist/bundle/{state-GL4ZC57O.js → state-3AFJL2EL.js} +6 -6
  129. package/dist/bundle/{store-VISFXSHL.js → store-6TLYL2VU.js} +30 -17
  130. package/dist/bundle/{store-HJ76TLWD.js → store-PEXV5DNA.js} +24 -19
  131. package/dist/bundle/store-maintenance-command-IYJLUQ5X.js +65 -0
  132. package/dist/bundle/surface-L4VY4WFG.js +64 -0
  133. package/dist/bundle/tg.js +13 -13
  134. package/dist/telegram/adapter.d.ts +9 -2
  135. package/dist/telegram/adapter.d.ts.map +1 -1
  136. package/dist/telegram/adapter.js +5 -6
  137. package/dist/telegram/adapter.js.map +1 -1
  138. package/dist/telegram/messages.d.ts +12 -0
  139. package/dist/telegram/messages.d.ts.map +1 -1
  140. package/dist/telegram/messages.js +40 -0
  141. package/dist/telegram/messages.js.map +1 -1
  142. package/dist/version.d.ts +1 -1
  143. package/dist/version.js +1 -1
  144. package/package.json +3 -3
  145. package/skills/tg-cli/SKILL.md +80 -576
  146. package/skills/tg-cli/references/files.md +64 -0
  147. package/skills/tg-cli/references/history.md +22 -0
  148. package/skills/tg-cli/references/mcp-and-bots.md +54 -0
  149. package/skills/tg-cli/references/messages.md +115 -0
  150. package/skills/tg-cli/references/people.md +85 -0
  151. package/skills/tg-cli/references/search.md +132 -0
  152. package/skills/tg-cli/references/setup.md +91 -0
  153. package/skills/tg-cli/references/stats.md +45 -0
  154. package/skills/tg-cli/references/tasks.md +54 -0
  155. package/dist/bundle/chunk-VKE77B3F.js +0 -2
  156. package/dist/bundle/command-contract-FRH7LBGE.js +0 -37
  157. package/dist/bundle/first-screen-4RFG22SA.js +0 -35
  158. package/dist/bundle/meeting-combined-MHWTZOF2.js +0 -23
  159. package/dist/bundle/server-WTNYWCZ4.js +0 -69
  160. package/dist/bundle/store-maintenance-command-SMARMN5C.js +0 -60
@@ -0,0 +1,353 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ AUDIT_MIN_SCORE
5
+ } from "./chunk-YHTSJMZ5.js";
6
+ import {
7
+ LIST_QUERY_GUIDE,
8
+ nativeTerms
9
+ } from "./chunk-QYRK4XXH.js";
10
+ import {
11
+ DEFAULT_CONFIG,
12
+ environmentOf,
13
+ itemOf,
14
+ listOf,
15
+ nextStep,
16
+ renderAnswer,
17
+ snakeKeys,
18
+ withAgentLevels
19
+ } from "./chunk-CDKXZLMP.js";
20
+ import {
21
+ formatReference
22
+ } from "./chunk-HD7DV5B2.js";
23
+ import {
24
+ queryError
25
+ } from "./chunk-NYEVPAF2.js";
26
+ import {
27
+ CliError
28
+ } from "./chunk-PK5WEGPJ.js";
29
+ import {
30
+ __name
31
+ } from "./chunk-ZVVMGPBJ.js";
32
+
33
+ // node_modules/.pnpm/@wirecat+cli-core@0.714.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.122.0_commander@15_dd9fedf917a0d541ef7fdcdb0be0e64b/node_modules/@wirecat/cli-core/dist/cli/paging.js
34
+ var positiveCount = /* @__PURE__ */ __name((flag) => (value) => {
35
+ if (!/^\d+$/.test(value.trim()) || Number(value) < 1)
36
+ throw new CliError("validation_error", `${flag} takes a whole number from 1 upwards, not "${value}"`);
37
+ return Number(value);
38
+ }, "positiveCount");
39
+ var configuredLimit = /* @__PURE__ */ __name((command, most = Number.POSITIVE_INFINITY) => {
40
+ const { resolveSettings, env } = environmentOf(command);
41
+ const { limit: _typed, ...flags } = command.optsWithGlobals();
42
+ const configured = resolveSettings?.(flags, { needsProfile: false, ...env ? { env } : {} }).limit ?? DEFAULT_CONFIG.defaults.limit;
43
+ return Math.min(configured, most);
44
+ }, "configuredLimit");
45
+ var withPaging = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")).option("--all", "every row, no paging"), "withPaging");
46
+ var window = /* @__PURE__ */ __name(({ limit, page, all }) => all ? { offset: 0 } : { limit, offset: (page - 1) * limit }, "window");
47
+ var pagingOf = /* @__PURE__ */ __name((command) => {
48
+ const environment = environmentOf(command);
49
+ const flags = command.optsWithGlobals();
50
+ if (!environment.resolveSettings)
51
+ return { limit: flags.limit ?? DEFAULT_CONFIG.defaults.limit, page: flags.page ?? 1 };
52
+ const { limit, page } = environment.resolveSettings(withAgentLevels(command, command.optsWithGlobals()), {
53
+ env: environment.env ?? process.env,
54
+ needsProfile: false,
55
+ readOnly: true
56
+ });
57
+ return { limit: limit ?? DEFAULT_CONFIG.defaults.limit, page: page ?? 1 };
58
+ }, "pagingOf");
59
+
60
+ // node_modules/.pnpm/@wirecat+cli-core@0.714.0_@napi-rs+canvas@1.0.13_@wirecat+cli-base@0.122.0_commander@15_dd9fedf917a0d541ef7fdcdb0be0e64b/node_modules/@wirecat/cli-core/dist/cli/messenger/chat-answers.js
61
+ var defined = /* @__PURE__ */ __name((record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0)), "defined");
62
+ var chatRef = /* @__PURE__ */ __name((account, chat) => formatReference({ type: "chat", provider: account.provider, account: account.account, chat }), "chatRef");
63
+ var settingsOf = /* @__PURE__ */ __name((settings) => defined({
64
+ all_can_pin: settings.allCanPin,
65
+ only_admins_add: settings.onlyAdminsAdd,
66
+ only_admins_call: settings.onlyAdminsCall,
67
+ only_owner_edits_info: settings.onlyOwnerEditsInfo,
68
+ members_see_link: settings.membersSeeLink,
69
+ join_approval: settings.joinApproval,
70
+ only_admins_send: settings.onlyAdminsSend,
71
+ only_admins_edit_info: settings.onlyAdminsEditInfo,
72
+ disappearing_seconds: settings.disappearingSeconds
73
+ }), "settingsOf");
74
+ var chatAnswer = /* @__PURE__ */ __name((account, chat) => defined({
75
+ ref: chatRef(account, chat.id),
76
+ id: chat.id,
77
+ title: chat.title,
78
+ kind: chat.kind,
79
+ unread_count: chat.unreadCount,
80
+ unread_mentions: chat.unreadMentions,
81
+ last_message_at: chat.lastMessageAt,
82
+ participants_count: chat.participantsCount,
83
+ muted: chat.muted,
84
+ muted_until: chat.mutedUntil ?? void 0,
85
+ archived: chat.archived,
86
+ marked_unread: chat.markedUnread,
87
+ membership_state: chat.membershipState,
88
+ parent_chat_id: chat.parentChatId ?? void 0,
89
+ scope: chat.scope,
90
+ provider_metadata: chat.providerMetadata,
91
+ description: chat.description,
92
+ invite_link: chat.link,
93
+ settings: chat.settings ? settingsOf(chat.settings) : void 0,
94
+ members: chat.members?.map(memberAnswer)
95
+ }), "chatAnswer");
96
+ var memberAnswer = /* @__PURE__ */ __name((member) => {
97
+ const group = member;
98
+ return defined({
99
+ id: member.id,
100
+ name: member.name,
101
+ username: member.username,
102
+ role: group.role,
103
+ last_seen_at: group.lastSeenAt,
104
+ registered_at: group.registeredAt,
105
+ joined_at: group.joinedAt,
106
+ invited_by: group.invitedBy,
107
+ is_bot: group.isBot,
108
+ deleted: group.deleted,
109
+ flagged: group.flagged,
110
+ has_photo: group.hasPhoto,
111
+ score: group.score,
112
+ reasons: group.reasons,
113
+ check: group.check ? snakeKeys(group.check) : void 0
114
+ });
115
+ }, "memberAnswer");
116
+ var contactRef = /* @__PURE__ */ __name((provider, id) => formatReference({ type: "contact", provider, id }), "contactRef");
117
+ var contactAnswer = /* @__PURE__ */ __name((account, contact) => {
118
+ const card = contact;
119
+ return defined({
120
+ ref: contactRef(account.provider, contact.id),
121
+ id: contact.id,
122
+ name: contact.name,
123
+ username: contact.username,
124
+ alias: contact.alias,
125
+ display_name: contact.displayName,
126
+ description: contact.description,
127
+ last_messaged_at: contact.lastMessagedAt,
128
+ chats: card.chats?.map((chat) => ({
129
+ ref: chatRef(account, chat.id),
130
+ id: chat.id,
131
+ title: chat.title,
132
+ kind: chat.kind,
133
+ last_message_at: chat.lastMessageAt
134
+ })),
135
+ notes: card.notes?.map(({ id, text, revision, createdAt, updatedAt }) => ({
136
+ id,
137
+ text,
138
+ revision,
139
+ created_at: createdAt,
140
+ updated_at: updatedAt
141
+ }))
142
+ });
143
+ }, "contactAnswer");
144
+ var contactShown = /* @__PURE__ */ __name((account, card, profile) => {
145
+ const { id: _id, name: _name, bio, chats, ...facts } = profile;
146
+ const listed = new Map(card.chats.map((chat) => [chat.id, chat]));
147
+ const active = new Set(chats.map(({ id }) => id));
148
+ const shared = [
149
+ ...chats.map((chat) => ({
150
+ ref: chatRef(account, chat.id),
151
+ id: chat.id,
152
+ title: chat.title,
153
+ kind: chat.kind,
154
+ last_message_at: listed.get(chat.id)?.lastMessageAt ?? chat.lastAt,
155
+ their_messages: chat.theirMessages,
156
+ first_at: chat.firstAt,
157
+ last_at: chat.lastAt,
158
+ complete: chat.complete
159
+ })),
160
+ ...card.chats.filter(({ id }) => !active.has(id)).map((chat) => ({
161
+ ref: chatRef(account, chat.id),
162
+ id: chat.id,
163
+ title: chat.title,
164
+ kind: chat.kind,
165
+ last_message_at: chat.lastMessageAt
166
+ }))
167
+ ];
168
+ const answer = contactAnswer(account, card);
169
+ return {
170
+ ...answer,
171
+ ...snakeKeys(facts),
172
+ description: answer.description ?? bio,
173
+ chats: shared
174
+ };
175
+ }, "contactShown");
176
+ var chatEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
177
+ chat_id: chatId,
178
+ time: event.timestamp,
179
+ type: event.event,
180
+ message_id: event.messageId,
181
+ by: event.by,
182
+ people: event.people,
183
+ title: event.title
184
+ }), "chatEventAnswer");
185
+ var HISTORY_TYPES = { joined: "join", left: "leave", changed: "profile" };
186
+ var memberEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
187
+ chat_id: chatId,
188
+ time: event.at,
189
+ type: HISTORY_TYPES[event.event],
190
+ by: event.invitedBy === void 0 ? void 0 : { id: event.invitedBy, name: null },
191
+ people: [{ id: event.id, name: event.name, username: event.username }],
192
+ before: event.before ? { name: event.before.name, username: event.before.username } : void 0
193
+ }), "memberEventAnswer");
194
+ var inviteLinkAnswer = /* @__PURE__ */ __name((link) => defined({
195
+ link: link.link,
196
+ approval: link.approval,
197
+ expires_at: link.expiresAt,
198
+ max_uses: link.maxUses,
199
+ primary: link.primary,
200
+ revoked: link.revoked,
201
+ pending_count: link.pending,
202
+ joined_count: link.joined
203
+ }), "inviteLinkAnswer");
204
+ var joinRequestAnswer = /* @__PURE__ */ __name((request) => defined({
205
+ person_id: request.person.id,
206
+ name: request.person.name,
207
+ username: request.person.username,
208
+ requested_at: request.requestedAt,
209
+ about: request.about
210
+ }), "joinRequestAnswer");
211
+ var pollVoteAnswer = /* @__PURE__ */ __name((vote) => ({
212
+ person_id: vote.person.id,
213
+ name: vote.person.name,
214
+ username: vote.person.username,
215
+ answers: vote.answers,
216
+ voted_at: vote.votedAt
217
+ }), "pollVoteAnswer");
218
+ var reactorAnswer = /* @__PURE__ */ __name((reactor) => ({
219
+ person: { id: reactor.person.id, name: reactor.person.name, username: reactor.person.username },
220
+ reaction: reactor.reaction,
221
+ reacted_at: reactor.reactedAt
222
+ }), "reactorAnswer");
223
+ var topicAnswer = /* @__PURE__ */ __name((topic) => defined({
224
+ id: topic.id,
225
+ title: topic.title,
226
+ closed: topic.closed,
227
+ pinned: topic.pinned,
228
+ hidden: topic.hidden,
229
+ unread_count: topic.unreadCount,
230
+ last_message_at: topic.lastMessageAt,
231
+ created_at: topic.createdAt,
232
+ untrusted: ["title"]
233
+ }), "topicAnswer");
234
+ var folderAnswer = /* @__PURE__ */ __name((folder) => {
235
+ const shown = "chats" in folder ? folder : void 0;
236
+ const listed = shown ? void 0 : folder;
237
+ return defined({
238
+ id: folder.id,
239
+ title: folder.title,
240
+ chat_ids: listed ? listed.chatIds : shown?.chats.map((chat) => chat.id) ?? [],
241
+ emoji: folder.emoji,
242
+ include: folder.include,
243
+ skip: folder.skip,
244
+ excluded_chat_ids: listed?.excludedChatIds ?? shown?.excluded.map((chat) => chat.id),
245
+ pinned_chat_ids: listed?.pinnedChatIds ?? shown?.pinned.map((chat) => chat.id),
246
+ chats: shown?.chats,
247
+ pinned_chats: shown?.pinned,
248
+ excluded_chats: shown?.excluded
249
+ });
250
+ }, "folderAnswer");
251
+ var lines = /* @__PURE__ */ __name((line) => (body) => (body.items ?? (body.item === void 0 ? [] : [body.item])).map((item) => `${line(item).trimEnd()}
252
+ `).join(""), "lines");
253
+ var pageOf = /* @__PURE__ */ __name(({ limit, page, all }, { items, hasMore }) => all ? { limit: Math.max(1, items.length), has_more: false, page: 1 } : { limit, has_more: hasMore, page }, "pageOf");
254
+ var wholeList = /* @__PURE__ */ __name((command, items, extra = {}) => listOf(command, { items, limit: Math.max(1, items.length), has_more: false, ...extra }), "wholeList");
255
+ var chatShown = /* @__PURE__ */ __name((account, card) => {
256
+ const listed = card.members?.length;
257
+ const short = listed !== void 0 && card.participantsCount !== null && listed < card.participantsCount;
258
+ return itemOf(chatAnswer(account, card), short ? {
259
+ missing: [
260
+ {
261
+ field: "members",
262
+ why: `${listed} listed; the chat reports ${card.participantsCount} \u2014 the list may omit your account or be partial`,
263
+ step: "chats.members"
264
+ }
265
+ ],
266
+ next: [nextStep("chats.members", { args: { chat: card.id } })]
267
+ } : {});
268
+ }, "chatShown");
269
+ var scoreFloor = /* @__PURE__ */ __name((ast) => {
270
+ const term = nativeTerms(ast, "chats members check").get("score");
271
+ if (!term)
272
+ return AUDIT_MIN_SCORE;
273
+ const upper = term.operator === "range" ? term.upper ?? "*" : term.value;
274
+ if (term.operator !== "range" || upper !== "*")
275
+ queryError("query.unsupported-operator", term.span, "score takes a lower bound: score>=3", {
276
+ command: "chats members check",
277
+ guide: LIST_QUERY_GUIDE
278
+ });
279
+ const floor = Number(term.value);
280
+ return Math.ceil(term.lower_inclusive === false ? floor + 1 : floor);
281
+ }, "scoreFloor");
282
+ var auditAnswer = /* @__PURE__ */ __name((audit) => wholeList("chats members check", audit.items.map(memberAnswer), {
283
+ ...audit.more ? { meta: { truncated: true } } : {},
284
+ ...audit.completeness && audit.completeness.state !== "complete" ? {
285
+ missing: [
286
+ {
287
+ field: "reasons",
288
+ why: "never_wrote counts only stored messages, and the store does not hold the chat whole",
289
+ ...audit.fetch ? { step: "messages.sync" } : {}
290
+ }
291
+ ],
292
+ ...audit.fetch ? { next: [nextStep("messages.sync", { args: { chat: audit.chatId } })] } : {}
293
+ } : {}
294
+ }), "auditAnswer");
295
+ var renderItem = /* @__PURE__ */ __name((command, output, value, next = []) => renderAnswer(command, output, itemOf(snakeKeys(value), { next })), "renderItem");
296
+ var withPage = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")), "withPage");
297
+ var documentLinkAnswer = /* @__PURE__ */ __name(({ url, documentId, title, inStore, locator, sentAt, sender }) => ({
298
+ url,
299
+ document_id: documentId,
300
+ title,
301
+ in_store: inStore,
302
+ ref: locator,
303
+ sent_at: sentAt,
304
+ sender
305
+ }), "documentLinkAnswer");
306
+ var accountAnswer = /* @__PURE__ */ __name((provider, { id, name, username, phone }) => ({
307
+ provider,
308
+ id,
309
+ name,
310
+ username,
311
+ ...phone === void 0 ? {} : { phone }
312
+ }), "accountAnswer");
313
+ var sessionAnswer = /* @__PURE__ */ __name(({ current, client, device, location, lastActiveAt, createdAt }) => ({
314
+ current,
315
+ client,
316
+ device,
317
+ location,
318
+ last_active_at: lastActiveAt,
319
+ ...createdAt === void 0 ? {} : { created_at: createdAt }
320
+ }), "sessionAnswer");
321
+
322
+ export {
323
+ positiveCount,
324
+ configuredLimit,
325
+ withPaging,
326
+ window,
327
+ pagingOf,
328
+ chatRef,
329
+ chatAnswer,
330
+ memberAnswer,
331
+ contactRef,
332
+ contactAnswer,
333
+ contactShown,
334
+ chatEventAnswer,
335
+ memberEventAnswer,
336
+ inviteLinkAnswer,
337
+ joinRequestAnswer,
338
+ pollVoteAnswer,
339
+ reactorAnswer,
340
+ topicAnswer,
341
+ folderAnswer,
342
+ lines,
343
+ pageOf,
344
+ wholeList,
345
+ chatShown,
346
+ scoreFloor,
347
+ auditAnswer,
348
+ renderItem,
349
+ withPage,
350
+ documentLinkAnswer,
351
+ accountAnswer,
352
+ sessionAnswer
353
+ };