@wirecat/notion-cli 0.0.0-stage → 0.2.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 (262) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/LICENSE +204 -0
  3. package/README.md +42 -2
  4. package/contracts/wirecat.json +1964 -0
  5. package/dist/bin/notion.d.ts +3 -0
  6. package/dist/bin/notion.d.ts.map +1 -0
  7. package/dist/bin/notion.js +40 -0
  8. package/dist/bin/notion.js.map +1 -0
  9. package/dist/bundle/all-profiles-JGYLQZ5C.js +278 -0
  10. package/dist/bundle/anthropic-S2VSMIKQ.js +91 -0
  11. package/dist/bundle/app-server-SASYDBCA.js +240 -0
  12. package/dist/bundle/bun-LU5LP3JI.js +169 -0
  13. package/dist/bundle/bun-sqlite-JBSINB4O.js +76 -0
  14. package/dist/bundle/chunk-22QQUKWA.js +53 -0
  15. package/dist/bundle/chunk-2F4QQ7WB.js +73 -0
  16. package/dist/bundle/chunk-2F6VO5HA.js +73 -0
  17. package/dist/bundle/chunk-2LWO3PDX.js +726 -0
  18. package/dist/bundle/chunk-3AL7QUS3.js +2778 -0
  19. package/dist/bundle/chunk-3Z4YTSRY.js +731 -0
  20. package/dist/bundle/chunk-4HWJOU7N.js +38 -0
  21. package/dist/bundle/chunk-4IPURN72.js +1221 -0
  22. package/dist/bundle/chunk-4ZTVJHWU.js +206 -0
  23. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  24. package/dist/bundle/chunk-5IYKVRH2.js +44811 -0
  25. package/dist/bundle/chunk-5NFK5EM2.js +362 -0
  26. package/dist/bundle/chunk-5QIQEUOG.js +188 -0
  27. package/dist/bundle/chunk-5RDNBG7D.js +72 -0
  28. package/dist/bundle/chunk-5RSC54NA.js +1328 -0
  29. package/dist/bundle/chunk-6EVKHZKN.js +158 -0
  30. package/dist/bundle/chunk-6RA3EABS.js +4012 -0
  31. package/dist/bundle/chunk-AOCUKEAX.js +131 -0
  32. package/dist/bundle/chunk-B26TQZKZ.js +217 -0
  33. package/dist/bundle/chunk-B7ON6KPT.js +1197 -0
  34. package/dist/bundle/chunk-BNPTZ5ZB.js +161 -0
  35. package/dist/bundle/chunk-D72URWJE.js +532 -0
  36. package/dist/bundle/chunk-D7QSEEYW.js +274 -0
  37. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  38. package/dist/bundle/chunk-DH5PRHT4.js +392 -0
  39. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  40. package/dist/bundle/chunk-EUIVXFLJ.js +259 -0
  41. package/dist/bundle/chunk-FPY6EJ7B.js +9568 -0
  42. package/dist/bundle/chunk-FT3LN3HP.js +6848 -0
  43. package/dist/bundle/chunk-FWVBPRL4.js +4436 -0
  44. package/dist/bundle/chunk-FXEJY4OL.js +12538 -0
  45. package/dist/bundle/chunk-G3EZFRSS.js +1297 -0
  46. package/dist/bundle/chunk-GZOUFX3C.js +230 -0
  47. package/dist/bundle/chunk-HL52XXZX.js +78 -0
  48. package/dist/bundle/chunk-KCLOUUYF.js +100 -0
  49. package/dist/bundle/chunk-KFVDL2QS.js +146 -0
  50. package/dist/bundle/chunk-KGERXYTV.js +24 -0
  51. package/dist/bundle/chunk-KM6WHPHI.js +288 -0
  52. package/dist/bundle/chunk-LAYPFBOM.js +95 -0
  53. package/dist/bundle/chunk-LLG2POQ7.js +170 -0
  54. package/dist/bundle/chunk-M3KB25D3.js +1392 -0
  55. package/dist/bundle/chunk-M7S2NDWB.js +76 -0
  56. package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
  57. package/dist/bundle/chunk-MY742GAD.js +1977 -0
  58. package/dist/bundle/chunk-MZU2YFBZ.js +823 -0
  59. package/dist/bundle/chunk-NOQ7B5N7.js +58 -0
  60. package/dist/bundle/chunk-NQWV4WQO.js +300 -0
  61. package/dist/bundle/chunk-ODBZNSZ6.js +1028 -0
  62. package/dist/bundle/chunk-OTV53F34.js +370 -0
  63. package/dist/bundle/chunk-P7CUM5IB.js +18 -0
  64. package/dist/bundle/chunk-RV64YUQX.js +185 -0
  65. package/dist/bundle/chunk-SHJQ6JKG.js +106 -0
  66. package/dist/bundle/chunk-SWAOWNKW.js +52 -0
  67. package/dist/bundle/chunk-SZOVLP44.js +29 -0
  68. package/dist/bundle/chunk-TPX2M45D.js +385 -0
  69. package/dist/bundle/chunk-TSDBSIFM.js +66 -0
  70. package/dist/bundle/chunk-VBHETQVV.js +64146 -0
  71. package/dist/bundle/chunk-VCIALTEM.js +3139 -0
  72. package/dist/bundle/chunk-VKE77B3F.js +2 -0
  73. package/dist/bundle/chunk-WCSOH4JS.js +142 -0
  74. package/dist/bundle/chunk-WF4D56CA.js +54 -0
  75. package/dist/bundle/chunk-WJHZMR2W.js +335 -0
  76. package/dist/bundle/chunk-X4TIMMKJ.js +16 -0
  77. package/dist/bundle/chunk-XF26XKTS.js +82 -0
  78. package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
  79. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  80. package/dist/bundle/chunk-XYIT2XB3.js +1372 -0
  81. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  82. package/dist/bundle/chunk-YMYUBZWT.js +1068 -0
  83. package/dist/bundle/chunk-YNTLT3Z3.js +2310 -0
  84. package/dist/bundle/chunk-YVI5SQPY.js +46 -0
  85. package/dist/bundle/chunk-Z56QFOBR.js +63 -0
  86. package/dist/bundle/chunk-ZKAEZXUP.js +787 -0
  87. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  88. package/dist/bundle/chunk-ZZ32DXTH.js +23 -0
  89. package/dist/bundle/command-contract-JS5V27NX.js +38 -0
  90. package/dist/bundle/command-server-entry-UFSG7KRO.js +167 -0
  91. package/dist/bundle/decode-7LLWTSPT.js +297 -0
  92. package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
  93. package/dist/bundle/dispatch-2GY6JIJH.js +411 -0
  94. package/dist/bundle/dist-ILNOLGYN.js +7577 -0
  95. package/dist/bundle/echarts-BXX4OQWC.js +42501 -0
  96. package/dist/bundle/embed-JXFNBTKH.js +38 -0
  97. package/dist/bundle/embedder-57YZ44KO.js +111 -0
  98. package/dist/bundle/failure-MYT4HPE3.js +25 -0
  99. package/dist/bundle/first-run-3PF7T74J.js +29 -0
  100. package/dist/bundle/first-screen-7BEROEQR.js +36 -0
  101. package/dist/bundle/instructions-2VECIDXF.js +11 -0
  102. package/dist/bundle/mcp-O6ACR2DX.js +167 -0
  103. package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
  104. package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
  105. package/dist/bundle/meeting-combined-PPUQ3KBR.js +24 -0
  106. package/dist/bundle/meeting-model-ZNMYKMCD.js +26 -0
  107. package/dist/bundle/meeting-semantic-ETN3A4BJ.js +22 -0
  108. package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
  109. package/dist/bundle/node-KM3CUABH.js +2340 -0
  110. package/dist/bundle/node-MPEQSFI3.js +176 -0
  111. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  112. package/dist/bundle/node-sqlite-WA32MYSJ.js +74 -0
  113. package/dist/bundle/notion.js +185 -0
  114. package/dist/bundle/oauth-IAFZG3IR.js +20 -0
  115. package/dist/bundle/open-M3JQUC5G.js +23 -0
  116. package/dist/bundle/openai-HXUEHUSD.js +240 -0
  117. package/dist/bundle/process-F6TKXWWA.js +91 -0
  118. package/dist/bundle/program-Y7JAB6TG.js +33219 -0
  119. package/dist/bundle/prompt-IMUQLZD2.js +17 -0
  120. package/dist/bundle/recognize-2MZAYHAA.js +26 -0
  121. package/dist/bundle/remote-OV4LB6VR.js +32 -0
  122. package/dist/bundle/rerank-ZIULUS34.js +52 -0
  123. package/dist/bundle/schemas-DIVZS6TU.js +12214 -0
  124. package/dist/bundle/serve-YU7QBP6L.js +199 -0
  125. package/dist/bundle/server-FKQET4ZO.js +71 -0
  126. package/dist/bundle/server-LGMNONSB.js +202 -0
  127. package/dist/bundle/services-5WY4DCPJ.js +581 -0
  128. package/dist/bundle/sqlite-runtime-5MXZDETH.js +20 -0
  129. package/dist/bundle/state-LWMZH2KI.js +36 -0
  130. package/dist/bundle/store-EPZYV4VW.js +168 -0
  131. package/dist/bundle/store-QE6FEIZD.js +286 -0
  132. package/dist/bundle/store-maintenance-command-ZUUUFCHL.js +62 -0
  133. package/dist/commands/api.d.ts +4 -0
  134. package/dist/commands/api.d.ts.map +1 -0
  135. package/dist/commands/api.js +140 -0
  136. package/dist/commands/api.js.map +1 -0
  137. package/dist/commands/databases.d.ts +3 -0
  138. package/dist/commands/databases.d.ts.map +1 -0
  139. package/dist/commands/databases.js +65 -0
  140. package/dist/commands/databases.js.map +1 -0
  141. package/dist/commands/documents.d.ts +4 -0
  142. package/dist/commands/documents.d.ts.map +1 -0
  143. package/dist/commands/documents.js +41 -0
  144. package/dist/commands/documents.js.map +1 -0
  145. package/dist/commands/library.d.ts +10 -0
  146. package/dist/commands/library.d.ts.map +1 -0
  147. package/dist/commands/library.js +468 -0
  148. package/dist/commands/library.js.map +1 -0
  149. package/dist/commands/session.d.ts +3 -0
  150. package/dist/commands/session.d.ts.map +1 -0
  151. package/dist/commands/session.js +105 -0
  152. package/dist/commands/session.js.map +1 -0
  153. package/dist/config.d.ts +5 -0
  154. package/dist/config.d.ts.map +1 -0
  155. package/dist/config.js +13 -0
  156. package/dist/config.js.map +1 -0
  157. package/dist/context.d.ts +51 -0
  158. package/dist/context.d.ts.map +1 -0
  159. package/dist/context.js +67 -0
  160. package/dist/context.js.map +1 -0
  161. package/dist/generated/definitions.d.ts +3 -0
  162. package/dist/generated/definitions.d.ts.map +1 -0
  163. package/dist/generated/definitions.js +45603 -0
  164. package/dist/generated/definitions.js.map +1 -0
  165. package/dist/generated/manifest.d.ts +3 -0
  166. package/dist/generated/manifest.d.ts.map +1 -0
  167. package/dist/generated/manifest.js +2089 -0
  168. package/dist/generated/manifest.js.map +1 -0
  169. package/dist/generated/metadata.d.ts +6 -0
  170. package/dist/generated/metadata.d.ts.map +1 -0
  171. package/dist/generated/metadata.js +24 -0
  172. package/dist/generated/metadata.js.map +1 -0
  173. package/dist/generated/schemas.d.ts +1223 -0
  174. package/dist/generated/schemas.d.ts.map +1 -0
  175. package/dist/generated/schemas.js +11557 -0
  176. package/dist/generated/schemas.js.map +1 -0
  177. package/dist/generated/types.d.ts +11120 -0
  178. package/dist/generated/types.d.ts.map +1 -0
  179. package/dist/generated/types.js +5 -0
  180. package/dist/generated/types.js.map +1 -0
  181. package/dist/identity.d.ts +7 -0
  182. package/dist/identity.d.ts.map +1 -0
  183. package/dist/identity.js +30 -0
  184. package/dist/identity.js.map +1 -0
  185. package/dist/index.d.ts +3 -0
  186. package/dist/index.d.ts.map +1 -0
  187. package/dist/index.js +3 -0
  188. package/dist/index.js.map +1 -0
  189. package/dist/knowledge.d.ts +27 -0
  190. package/dist/knowledge.d.ts.map +1 -0
  191. package/dist/knowledge.js +87 -0
  192. package/dist/knowledge.js.map +1 -0
  193. package/dist/library.d.ts +44 -0
  194. package/dist/library.d.ts.map +1 -0
  195. package/dist/library.js +149 -0
  196. package/dist/library.js.map +1 -0
  197. package/dist/notion/client.d.ts +45 -0
  198. package/dist/notion/client.d.ts.map +1 -0
  199. package/dist/notion/client.js +121 -0
  200. package/dist/notion/client.js.map +1 -0
  201. package/dist/notion/errors.d.ts +24 -0
  202. package/dist/notion/errors.d.ts.map +1 -0
  203. package/dist/notion/errors.js +127 -0
  204. package/dist/notion/errors.js.map +1 -0
  205. package/dist/notion/ids.d.ts +7 -0
  206. package/dist/notion/ids.d.ts.map +1 -0
  207. package/dist/notion/ids.js +37 -0
  208. package/dist/notion/ids.js.map +1 -0
  209. package/dist/notion/links.d.ts +6 -0
  210. package/dist/notion/links.d.ts.map +1 -0
  211. package/dist/notion/links.js +22 -0
  212. package/dist/notion/links.js.map +1 -0
  213. package/dist/notion/notion.d.ts +95 -0
  214. package/dist/notion/notion.d.ts.map +1 -0
  215. package/dist/notion/notion.js +269 -0
  216. package/dist/notion/notion.js.map +1 -0
  217. package/dist/notion/port.d.ts +13 -0
  218. package/dist/notion/port.d.ts.map +1 -0
  219. package/dist/notion/port.js +60 -0
  220. package/dist/notion/port.js.map +1 -0
  221. package/dist/notion/read-posts.d.ts +36 -0
  222. package/dist/notion/read-posts.d.ts.map +1 -0
  223. package/dist/notion/read-posts.js +24 -0
  224. package/dist/notion/read-posts.js.map +1 -0
  225. package/dist/notion/reads.d.ts +331 -0
  226. package/dist/notion/reads.d.ts.map +1 -0
  227. package/dist/notion/reads.js +18 -0
  228. package/dist/notion/reads.js.map +1 -0
  229. package/dist/program.d.ts +6 -0
  230. package/dist/program.d.ts.map +1 -0
  231. package/dist/program.js +62 -0
  232. package/dist/program.js.map +1 -0
  233. package/dist/sync/cursor.d.ts +135 -0
  234. package/dist/sync/cursor.d.ts.map +1 -0
  235. package/dist/sync/cursor.js +113 -0
  236. package/dist/sync/cursor.js.map +1 -0
  237. package/dist/sync/files.d.ts +77 -0
  238. package/dist/sync/files.d.ts.map +1 -0
  239. package/dist/sync/files.js +12 -0
  240. package/dist/sync/files.js.map +1 -0
  241. package/dist/sync/front-matter.d.ts +10 -0
  242. package/dist/sync/front-matter.d.ts.map +1 -0
  243. package/dist/sync/front-matter.js +114 -0
  244. package/dist/sync/front-matter.js.map +1 -0
  245. package/dist/sync/markdown.d.ts +11 -0
  246. package/dist/sync/markdown.d.ts.map +1 -0
  247. package/dist/sync/markdown.js +42 -0
  248. package/dist/sync/markdown.js.map +1 -0
  249. package/dist/sync/source.d.ts +11 -0
  250. package/dist/sync/source.d.ts.map +1 -0
  251. package/dist/sync/source.js +995 -0
  252. package/dist/sync/source.js.map +1 -0
  253. package/dist/version.d.ts +2 -0
  254. package/dist/version.d.ts.map +1 -0
  255. package/dist/version.js +2 -0
  256. package/dist/version.js.map +1 -0
  257. package/dist/wcat.d.ts +3 -0
  258. package/dist/wcat.d.ts.map +1 -0
  259. package/dist/wcat.js +4 -0
  260. package/dist/wcat.js.map +1 -0
  261. package/package.json +85 -4
  262. package/skills/notion-cli/SKILL.md +45 -0
@@ -0,0 +1,726 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ AUDIT_MIN_SCORE,
5
+ LIST_QUERY_GUIDE,
6
+ nativeTerms,
7
+ throughWrapper
8
+ } from "./chunk-5IYKVRH2.js";
9
+ import {
10
+ DEFAULT_CONFIG,
11
+ environmentOf,
12
+ itemOf,
13
+ listOf,
14
+ nextStep,
15
+ readOnlyLockOf,
16
+ renderAnswer,
17
+ snakeKeys,
18
+ withAgentLevels
19
+ } from "./chunk-FXEJY4OL.js";
20
+ import {
21
+ formatReference
22
+ } from "./chunk-MY742GAD.js";
23
+ import {
24
+ queryError
25
+ } from "./chunk-FWVBPRL4.js";
26
+ import {
27
+ array,
28
+ boolean,
29
+ check,
30
+ pipe,
31
+ record,
32
+ safeParse,
33
+ strictObject,
34
+ string
35
+ } from "./chunk-XYIT2XB3.js";
36
+ import {
37
+ CliError
38
+ } from "./chunk-5RDNBG7D.js";
39
+ import {
40
+ __name
41
+ } from "./chunk-ZVVMGPBJ.js";
42
+
43
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/cli/messenger/lacks.js
44
+ var COMMAND_NEEDS = {
45
+ "account update": ["updateProfile", "change the profile"],
46
+ "account sessions list": ["sessions", "list the account's sessions"],
47
+ "account sessions end": ["endOtherSessions", "end other sessions"],
48
+ "chats events": ["chatEvents", "read who joined or left"],
49
+ "chats inspect": ["inspect", "read a link"],
50
+ "chats folders list": ["folders", "list its folders"],
51
+ "chats folders show": ["folders", "list its folders"],
52
+ "chats folders create": ["createFolder", "create a folder"],
53
+ "chats folders update": ["updateFolder", "change a folder"],
54
+ "chats folders delete": ["deleteFolder", "delete a folder"],
55
+ "contacts add": ["addContact", "add a contact"],
56
+ "contacts remove": ["removeContact", "remove a contact"],
57
+ "contacts rename": ["renameContact", "rename a contact"],
58
+ "contacts import": ["importContacts", "import contacts"],
59
+ "messages comments": ["comments", "read comments on a channel post"],
60
+ "messages pin": ["pin", "pin a message"],
61
+ "messages unpin": ["unpin", "unpin a message"]
62
+ };
63
+ var STORE_ANSWERS = /* @__PURE__ */ new Set(["chats events"]);
64
+ var lackedNeed = /* @__PURE__ */ __name((messenger, path) => {
65
+ const need = COMMAND_NEEDS[path];
66
+ if (!need)
67
+ return void 0;
68
+ if (path === "messages comments" && (messenger?.readsComments ?? messenger?.channelComments) === false)
69
+ return need;
70
+ if (!messenger?.lacks?.includes(need[0]) && !messenger?.never?.includes(need[0]))
71
+ return void 0;
72
+ return messenger.history === "store" && STORE_ANSWERS.has(path) ? void 0 : need;
73
+ }, "lackedNeed");
74
+ var refuseLacking = /* @__PURE__ */ __name((messenger, path) => {
75
+ const need = lackedNeed(messenger, path.join(" "));
76
+ if (need)
77
+ throw new CliError("validation_error", `this messenger cannot ${need[1]}`);
78
+ }, "refuseLacking");
79
+ var hideNever = /* @__PURE__ */ __name((messenger, group) => {
80
+ const walk = /* @__PURE__ */ __name((command, path) => {
81
+ for (const child of command.commands) {
82
+ const at = [...path, child.name()];
83
+ const need = COMMAND_NEEDS[at.join(" ")];
84
+ if (need && messenger.never?.includes(need[0]))
85
+ child._hidden = true;
86
+ walk(child, at);
87
+ }
88
+ }, "walk");
89
+ walk(group, [group.name()]);
90
+ return group;
91
+ }, "hideNever");
92
+
93
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/cli/paging.js
94
+ var positiveCount = /* @__PURE__ */ __name((flag) => (value) => {
95
+ if (!/^\d+$/.test(value.trim()) || Number(value) < 1)
96
+ throw new CliError("validation_error", `${flag} takes a whole number from 1 upwards, not "${value}"`);
97
+ return Number(value);
98
+ }, "positiveCount");
99
+ var configuredLimit = /* @__PURE__ */ __name((command, most = Number.POSITIVE_INFINITY) => {
100
+ const { resolveSettings, env } = environmentOf(command);
101
+ const { limit: _typed, ...flags } = command.optsWithGlobals();
102
+ const configured = resolveSettings?.(flags, { needsProfile: false, ...env ? { env } : {} }).limit ?? DEFAULT_CONFIG.defaults.limit;
103
+ return Math.min(configured, most);
104
+ }, "configuredLimit");
105
+ 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");
106
+ var window = /* @__PURE__ */ __name(({ limit, page, all }) => all ? { offset: 0 } : { limit, offset: (page - 1) * limit }, "window");
107
+ var pagingOf = /* @__PURE__ */ __name((command) => {
108
+ const environment = environmentOf(command);
109
+ const flags = command.optsWithGlobals();
110
+ if (!environment.resolveSettings)
111
+ return { limit: flags.limit ?? DEFAULT_CONFIG.defaults.limit, page: flags.page ?? 1 };
112
+ const { limit, page } = environment.resolveSettings(withAgentLevels(command, command.optsWithGlobals()), {
113
+ env: environment.env ?? process.env,
114
+ needsProfile: false,
115
+ readOnly: true
116
+ });
117
+ return { limit: limit ?? DEFAULT_CONFIG.defaults.limit, page: page ?? 1 };
118
+ }, "pagingOf");
119
+
120
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/cli/messenger/chat-answers.js
121
+ var defined = /* @__PURE__ */ __name((record2) => Object.fromEntries(Object.entries(record2).filter(([, value]) => value !== void 0)), "defined");
122
+ var chatRef = /* @__PURE__ */ __name((account, chat) => formatReference({ type: "chat", provider: account.provider, account: account.account, chat }), "chatRef");
123
+ var settingsOf = /* @__PURE__ */ __name((settings) => defined({
124
+ all_can_pin: settings.allCanPin,
125
+ only_admins_add: settings.onlyAdminsAdd,
126
+ only_admins_call: settings.onlyAdminsCall,
127
+ only_owner_edits_info: settings.onlyOwnerEditsInfo,
128
+ members_see_link: settings.membersSeeLink,
129
+ join_approval: settings.joinApproval,
130
+ only_admins_send: settings.onlyAdminsSend,
131
+ only_admins_edit_info: settings.onlyAdminsEditInfo,
132
+ disappearing_seconds: settings.disappearingSeconds
133
+ }), "settingsOf");
134
+ var chatAnswer = /* @__PURE__ */ __name((account, chat) => defined({
135
+ ref: chatRef(account, chat.id),
136
+ id: chat.id,
137
+ title: chat.title,
138
+ kind: chat.kind,
139
+ unread_count: chat.unreadCount,
140
+ unread_mentions: chat.unreadMentions,
141
+ last_message_at: chat.lastMessageAt,
142
+ participants_count: chat.participantsCount,
143
+ muted: chat.muted,
144
+ muted_until: chat.mutedUntil ?? void 0,
145
+ archived: chat.archived,
146
+ marked_unread: chat.markedUnread,
147
+ membership_state: chat.membershipState,
148
+ parent_chat_id: chat.parentChatId ?? void 0,
149
+ scope: chat.scope,
150
+ provider_metadata: chat.providerMetadata,
151
+ description: chat.description,
152
+ invite_link: chat.link,
153
+ settings: chat.settings ? settingsOf(chat.settings) : void 0,
154
+ members: chat.members?.map(memberAnswer)
155
+ }), "chatAnswer");
156
+ var memberAnswer = /* @__PURE__ */ __name((member) => {
157
+ const group = member;
158
+ return defined({
159
+ id: member.id,
160
+ name: member.name,
161
+ username: member.username,
162
+ role: group.role,
163
+ last_seen_at: group.lastSeenAt,
164
+ registered_at: group.registeredAt,
165
+ joined_at: group.joinedAt,
166
+ invited_by: group.invitedBy,
167
+ is_bot: group.isBot,
168
+ deleted: group.deleted,
169
+ flagged: group.flagged,
170
+ has_photo: group.hasPhoto,
171
+ score: group.score,
172
+ reasons: group.reasons,
173
+ check: group.check ? snakeKeys(group.check) : void 0
174
+ });
175
+ }, "memberAnswer");
176
+ var contactRef = /* @__PURE__ */ __name((provider, id) => formatReference({ type: "contact", provider, id }), "contactRef");
177
+ var contactAnswer = /* @__PURE__ */ __name((account, contact) => {
178
+ const card = contact;
179
+ return defined({
180
+ ref: contactRef(account.provider, contact.id),
181
+ id: contact.id,
182
+ name: contact.name,
183
+ username: contact.username,
184
+ alias: contact.alias,
185
+ display_name: contact.displayName,
186
+ description: contact.description,
187
+ last_messaged_at: contact.lastMessagedAt,
188
+ chats: card.chats?.map((chat) => ({
189
+ ref: chatRef(account, chat.id),
190
+ id: chat.id,
191
+ title: chat.title,
192
+ kind: chat.kind,
193
+ last_message_at: chat.lastMessageAt
194
+ })),
195
+ notes: card.notes?.map(({ id, text, revision, createdAt, updatedAt }) => ({
196
+ id,
197
+ text,
198
+ revision,
199
+ created_at: createdAt,
200
+ updated_at: updatedAt
201
+ }))
202
+ });
203
+ }, "contactAnswer");
204
+ var contactShown = /* @__PURE__ */ __name((account, card, profile) => {
205
+ const { id: _id, name: _name, bio, chats, ...facts } = profile;
206
+ const listed = new Map(card.chats.map((chat) => [chat.id, chat]));
207
+ const active = new Set(chats.map(({ id }) => id));
208
+ const shared = [
209
+ ...chats.map((chat) => ({
210
+ ref: chatRef(account, chat.id),
211
+ id: chat.id,
212
+ title: chat.title,
213
+ kind: chat.kind,
214
+ last_message_at: listed.get(chat.id)?.lastMessageAt ?? chat.lastAt,
215
+ their_messages: chat.theirMessages,
216
+ first_at: chat.firstAt,
217
+ last_at: chat.lastAt,
218
+ complete: chat.complete
219
+ })),
220
+ ...card.chats.filter(({ id }) => !active.has(id)).map((chat) => ({
221
+ ref: chatRef(account, chat.id),
222
+ id: chat.id,
223
+ title: chat.title,
224
+ kind: chat.kind,
225
+ last_message_at: chat.lastMessageAt
226
+ }))
227
+ ];
228
+ const answer = contactAnswer(account, card);
229
+ return {
230
+ ...answer,
231
+ ...snakeKeys(facts),
232
+ description: answer.description ?? bio,
233
+ chats: shared
234
+ };
235
+ }, "contactShown");
236
+ var chatEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
237
+ chat_id: chatId,
238
+ time: event.timestamp,
239
+ type: event.event,
240
+ message_id: event.messageId,
241
+ by: event.by,
242
+ people: event.people,
243
+ title: event.title
244
+ }), "chatEventAnswer");
245
+ var HISTORY_TYPES = { joined: "join", left: "leave", changed: "profile" };
246
+ var memberEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
247
+ chat_id: chatId,
248
+ time: event.at,
249
+ type: HISTORY_TYPES[event.event],
250
+ by: event.invitedBy === void 0 ? void 0 : { id: event.invitedBy, name: null },
251
+ people: [{ id: event.id, name: event.name, username: event.username }],
252
+ before: event.before ? { name: event.before.name, username: event.before.username } : void 0
253
+ }), "memberEventAnswer");
254
+ var inviteLinkAnswer = /* @__PURE__ */ __name((link) => defined({
255
+ link: link.link,
256
+ approval: link.approval,
257
+ expires_at: link.expiresAt,
258
+ max_uses: link.maxUses,
259
+ primary: link.primary,
260
+ revoked: link.revoked,
261
+ pending_count: link.pending,
262
+ joined_count: link.joined
263
+ }), "inviteLinkAnswer");
264
+ var joinRequestAnswer = /* @__PURE__ */ __name((request) => defined({
265
+ person_id: request.person.id,
266
+ name: request.person.name,
267
+ username: request.person.username,
268
+ requested_at: request.requestedAt,
269
+ about: request.about
270
+ }), "joinRequestAnswer");
271
+ var pollVoteAnswer = /* @__PURE__ */ __name((vote) => ({
272
+ person_id: vote.person.id,
273
+ name: vote.person.name,
274
+ username: vote.person.username,
275
+ answers: vote.answers,
276
+ voted_at: vote.votedAt
277
+ }), "pollVoteAnswer");
278
+ var reactorAnswer = /* @__PURE__ */ __name((reactor) => ({
279
+ person: { id: reactor.person.id, name: reactor.person.name, username: reactor.person.username },
280
+ reaction: reactor.reaction,
281
+ reacted_at: reactor.reactedAt
282
+ }), "reactorAnswer");
283
+ var topicAnswer = /* @__PURE__ */ __name((topic) => defined({
284
+ id: topic.id,
285
+ title: topic.title,
286
+ closed: topic.closed,
287
+ pinned: topic.pinned,
288
+ hidden: topic.hidden,
289
+ unread_count: topic.unreadCount,
290
+ last_message_at: topic.lastMessageAt,
291
+ created_at: topic.createdAt,
292
+ untrusted: ["title"]
293
+ }), "topicAnswer");
294
+ var folderAnswer = /* @__PURE__ */ __name((folder) => {
295
+ const shown = "chats" in folder ? folder : void 0;
296
+ const listed = shown ? void 0 : folder;
297
+ return defined({
298
+ id: folder.id,
299
+ title: folder.title,
300
+ chat_ids: listed ? listed.chatIds : shown?.chats.map((chat) => chat.id) ?? [],
301
+ emoji: folder.emoji,
302
+ include: folder.include,
303
+ skip: folder.skip,
304
+ excluded_chat_ids: listed?.excludedChatIds ?? shown?.excluded.map((chat) => chat.id),
305
+ pinned_chat_ids: listed?.pinnedChatIds ?? shown?.pinned.map((chat) => chat.id),
306
+ chats: shown?.chats,
307
+ pinned_chats: shown?.pinned,
308
+ excluded_chats: shown?.excluded
309
+ });
310
+ }, "folderAnswer");
311
+ var lines = /* @__PURE__ */ __name((line) => (body) => (body.items ?? (body.item === void 0 ? [] : [body.item])).map((item) => `${line(item).trimEnd()}
312
+ `).join(""), "lines");
313
+ 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");
314
+ var wholeList = /* @__PURE__ */ __name((command, items, extra = {}) => listOf(command, { items, limit: Math.max(1, items.length), has_more: false, ...extra }), "wholeList");
315
+ var chatShown = /* @__PURE__ */ __name((account, card) => {
316
+ const listed = card.members?.length;
317
+ const short = listed !== void 0 && card.participantsCount !== null && listed < card.participantsCount;
318
+ return itemOf(chatAnswer(account, card), short ? {
319
+ missing: [
320
+ {
321
+ field: "members",
322
+ why: `${listed} listed; the chat reports ${card.participantsCount} \u2014 the list may omit your account or be partial`,
323
+ step: "chats.members"
324
+ }
325
+ ],
326
+ next: [nextStep("chats.members", { args: { chat: card.id } })]
327
+ } : {});
328
+ }, "chatShown");
329
+ var scoreFloor = /* @__PURE__ */ __name((ast) => {
330
+ const term = nativeTerms(ast, "chats members check").get("score");
331
+ if (!term)
332
+ return AUDIT_MIN_SCORE;
333
+ const upper = term.operator === "range" ? term.upper ?? "*" : term.value;
334
+ if (term.operator !== "range" || upper !== "*")
335
+ queryError("query.unsupported-operator", term.span, "score takes a lower bound: score>=3", {
336
+ command: "chats members check",
337
+ guide: LIST_QUERY_GUIDE
338
+ });
339
+ const floor = Number(term.value);
340
+ return Math.ceil(term.lower_inclusive === false ? floor + 1 : floor);
341
+ }, "scoreFloor");
342
+ var auditAnswer = /* @__PURE__ */ __name((audit) => wholeList("chats members check", audit.items.map(memberAnswer), {
343
+ ...audit.more ? { meta: { truncated: true } } : {},
344
+ ...audit.completeness && audit.completeness.state !== "complete" ? {
345
+ missing: [
346
+ {
347
+ field: "reasons",
348
+ why: "never_wrote counts only stored messages, and the store does not hold the chat whole",
349
+ ...audit.fetch ? { step: "messages.sync" } : {}
350
+ }
351
+ ],
352
+ ...audit.fetch ? { next: [nextStep("messages.sync", { args: { chat: audit.chatId } })] } : {}
353
+ } : {}
354
+ }), "auditAnswer");
355
+ var renderItem = /* @__PURE__ */ __name((command, output, value, next = []) => renderAnswer(command, output, itemOf(snakeKeys(value), { next })), "renderItem");
356
+ 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");
357
+ var documentLinkAnswer = /* @__PURE__ */ __name(({ url, documentId, title, inStore, locator, sentAt, sender }) => ({
358
+ url,
359
+ document_id: documentId,
360
+ title,
361
+ in_store: inStore,
362
+ ref: locator,
363
+ sent_at: sentAt,
364
+ sender
365
+ }), "documentLinkAnswer");
366
+ var accountAnswer = /* @__PURE__ */ __name((provider, { id, name, username, phone }) => ({
367
+ provider,
368
+ id,
369
+ name,
370
+ username,
371
+ ...phone === void 0 ? {} : { phone }
372
+ }), "accountAnswer");
373
+ var sessionAnswer = /* @__PURE__ */ __name(({ current, client, device, location, lastActiveAt, createdAt }) => ({
374
+ current,
375
+ client,
376
+ device,
377
+ location,
378
+ last_active_at: lastActiveAt,
379
+ ...createdAt === void 0 ? {} : { created_at: createdAt }
380
+ }), "sessionAnswer");
381
+
382
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/background/relay.js
383
+ import { createHash } from "node:crypto";
384
+ import { chmodSync, lstatSync, mkdirSync, rmSync } from "node:fs";
385
+ import { createConnection, createServer } from "node:net";
386
+ import { tmpdir } from "node:os";
387
+ import { dirname, isAbsolute, join } from "node:path";
388
+ import { PassThrough, Writable } from "node:stream";
389
+ var RELAY_PROTOCOL = 1;
390
+ var requestSchema = strictObject({
391
+ argv: array(string()),
392
+ env: record(string(), string()),
393
+ cwd: pipe(string(), check((path) => isAbsolute(path))),
394
+ tty: boolean(),
395
+ stdinTty: boolean()
396
+ });
397
+ var MAX_CLIENT_LINE = 1024 * 1024;
398
+ var MAX_SERVE_LINE = 64 * 1024 * 1024;
399
+ var MAX_SOCKET_PATH = 100;
400
+ var relayPath = /* @__PURE__ */ __name((lockPath) => {
401
+ const beside = lockPath.replace(/\.lock$/, ".sock");
402
+ if (beside.length <= MAX_SOCKET_PATH)
403
+ return beside;
404
+ const hash = createHash("sha256").update(beside).digest("hex").slice(0, 16);
405
+ const name = join(`wirecat-relay-${process.getuid?.() ?? "user"}`, `${hash}.sock`);
406
+ const temporary = join(tmpdir(), name);
407
+ if (temporary.length <= MAX_SOCKET_PATH || process.platform === "win32")
408
+ return temporary;
409
+ return join("/tmp", name);
410
+ }, "relayPath");
411
+ var privateDirectory = /* @__PURE__ */ __name((dir) => {
412
+ mkdirSync(dir, { recursive: true, mode: 448 });
413
+ const stat = lstatSync(dir);
414
+ const mine = process.getuid === void 0 || stat.uid === process.getuid();
415
+ if (!stat.isDirectory() || !mine || (stat.mode & 63) !== 0) {
416
+ throw new CliError("permission_error", `${dir} is not a private directory, so serve does not listen there`);
417
+ }
418
+ }, "privateDirectory");
419
+ var lines2 = /* @__PURE__ */ __name((socket, max, onLine, onTooLong) => {
420
+ let buffered = "";
421
+ socket.setEncoding("utf8");
422
+ socket.on("data", (chunk) => {
423
+ buffered += chunk;
424
+ for (let end = buffered.indexOf("\n"); end >= 0; end = buffered.indexOf("\n")) {
425
+ const line = buffered.slice(0, end);
426
+ buffered = buffered.slice(end + 1);
427
+ if (line)
428
+ onLine(line);
429
+ }
430
+ if (buffered.length > max)
431
+ onTooLong();
432
+ });
433
+ }, "lines");
434
+ var frame = /* @__PURE__ */ __name((socket, value) => {
435
+ if (!socket.destroyed)
436
+ socket.write(`${JSON.stringify(value)}
437
+ `);
438
+ }, "frame");
439
+ var listenRelay = /* @__PURE__ */ __name(async (path, run) => {
440
+ privateDirectory(dirname(path));
441
+ rmSync(path, { force: true });
442
+ const open = /* @__PURE__ */ new Set();
443
+ const running = /* @__PURE__ */ new Set();
444
+ const server = createServer((socket) => {
445
+ open.add(socket);
446
+ const stop = new AbortController();
447
+ const stdin = new PassThrough();
448
+ let started = false;
449
+ socket.on("error", () => {
450
+ });
451
+ socket.on("close", () => {
452
+ open.delete(socket);
453
+ stop.abort(new CliError("cancelled", "the client went away", { retryable: false }));
454
+ if (!stdin.writableEnded)
455
+ stdin.end();
456
+ });
457
+ lines2(socket, MAX_CLIENT_LINE, (line) => {
458
+ let message;
459
+ try {
460
+ message = JSON.parse(line);
461
+ } catch {
462
+ socket.destroy();
463
+ return;
464
+ }
465
+ if (!started) {
466
+ started = true;
467
+ if (message.v !== RELAY_PROTOCOL) {
468
+ frame(socket, { diagnostic: `serve speaks relay protocol ${RELAY_PROTOCOL}; restart it`, exit: 1 });
469
+ socket.end();
470
+ return;
471
+ }
472
+ const parsed = safeParse(requestSchema, message.run);
473
+ if (!parsed.success) {
474
+ socket.destroy();
475
+ return;
476
+ }
477
+ stdin.isTTY = parsed.output.stdinTty;
478
+ if (parsed.output.stdinTty)
479
+ stdin.end();
480
+ const job = serve(socket, parsed.output, stdin, stop.signal, run);
481
+ running.add(job);
482
+ void job.then(() => running.delete(job), () => running.delete(job));
483
+ return;
484
+ }
485
+ if (typeof message.stdin === "string" && !stdin.writableEnded)
486
+ stdin.write(Buffer.from(message.stdin, "base64"));
487
+ if (message.stdinEnd === true && !stdin.writableEnded)
488
+ stdin.end();
489
+ }, () => socket.destroy());
490
+ });
491
+ await new Promise((resolve, reject) => {
492
+ server.once("error", reject);
493
+ server.listen(path, () => {
494
+ server.off("error", reject);
495
+ resolve();
496
+ });
497
+ });
498
+ chmodSync(path, 384);
499
+ return {
500
+ close: /* @__PURE__ */ __name(async () => {
501
+ for (const socket of open)
502
+ socket.destroy();
503
+ await new Promise((resolve) => server.close(() => resolve()));
504
+ await Promise.allSettled(running);
505
+ rmSync(path, { force: true });
506
+ }, "close")
507
+ };
508
+ }, "listenRelay");
509
+ var serve = /* @__PURE__ */ __name(async (socket, request, stdin, signal, run) => {
510
+ const streams = {
511
+ data: /* @__PURE__ */ __name((text) => frame(socket, { data: text }), "data"),
512
+ diagnostic: /* @__PURE__ */ __name((text) => frame(socket, { diagnostic: text }), "diagnostic"),
513
+ progress: /* @__PURE__ */ __name((text) => frame(socket, { progress: text }), "progress")
514
+ };
515
+ const stdout = new Writable({
516
+ write: /* @__PURE__ */ __name((chunk, _encoding, done) => {
517
+ frame(socket, { raw: Buffer.from(chunk).toString("base64") });
518
+ done();
519
+ }, "write")
520
+ });
521
+ let code = 1;
522
+ try {
523
+ code = await run(request, { streams, stdin, stdout, signal });
524
+ } finally {
525
+ frame(socket, { exit: code });
526
+ socket.end();
527
+ }
528
+ }, "serve");
529
+ var relayCommand = /* @__PURE__ */ __name((path, request, options) => new Promise((resolve, reject) => {
530
+ const { streams, stdin, stdout, signal, deadlineMs, writes, holder, listens = false } = options;
531
+ const socket = createConnection(path);
532
+ let connected = false;
533
+ let settled = false;
534
+ let timer;
535
+ const forward = /* @__PURE__ */ __name((chunk) => frame(socket, { stdin: Buffer.from(chunk).toString("base64") }), "forward");
536
+ const ended = /* @__PURE__ */ __name(() => frame(socket, { stdinEnd: true }), "ended");
537
+ const brokenPipe = /* @__PURE__ */ __name((error) => {
538
+ if (error.code === "EPIPE")
539
+ finish({ code: 0 });
540
+ }, "brokenPipe");
541
+ const finish = /* @__PURE__ */ __name((outcome) => {
542
+ if (settled)
543
+ return;
544
+ settled = true;
545
+ if (timer)
546
+ clearTimeout(timer);
547
+ stdout.off("error", brokenPipe);
548
+ signal.removeEventListener("abort", aborted);
549
+ stdin.off("data", forward).off("end", ended);
550
+ stdin.pause();
551
+ socket.destroy();
552
+ if ("code" in outcome)
553
+ resolve(outcome.code);
554
+ else
555
+ reject(outcome.error);
556
+ }, "finish");
557
+ const stopped = /* @__PURE__ */ __name(() => writes ? new CliError("outcome_unknown", `${holder} stopped before the command finished; it may have run \u2014 check before repeating it`, { retryable: false }) : new CliError("provider_unavailable", `${holder} stopped before the command finished`, { retryable: true }), "stopped");
558
+ const aborted = /* @__PURE__ */ __name(() => finish(listens ? { code: 0 } : { error: signal.reason }), "aborted");
559
+ if (signal.aborted)
560
+ return aborted();
561
+ signal.addEventListener("abort", aborted, { once: true });
562
+ stdout.on("error", brokenPipe);
563
+ if (deadlineMs !== void 0)
564
+ timer = setTimeout(() => finish({ error: stopped() }), deadlineMs);
565
+ socket.on("connect", () => {
566
+ connected = true;
567
+ frame(socket, { v: RELAY_PROTOCOL, run: request });
568
+ if (request.stdinTty)
569
+ ended();
570
+ else {
571
+ stdin.on("data", forward).once("end", ended);
572
+ stdin.resume();
573
+ }
574
+ });
575
+ socket.on("error", (error) => {
576
+ if (connected)
577
+ return finish({ error: stopped() });
578
+ finish({
579
+ error: new CliError("provider_unavailable", `${holder} holds the connection but does not answer its relay (${error.code ?? error.message}) \u2014 restart it`, { retryable: false, sent: false })
580
+ });
581
+ });
582
+ socket.on("close", () => finish({ error: stopped() }));
583
+ lines2(socket, MAX_SERVE_LINE, (line) => {
584
+ let message;
585
+ try {
586
+ message = JSON.parse(line);
587
+ } catch {
588
+ return finish({ error: stopped() });
589
+ }
590
+ if (typeof message.data === "string")
591
+ streams.data(message.data);
592
+ if (typeof message.diagnostic === "string")
593
+ streams.diagnostic(message.diagnostic);
594
+ if (typeof message.progress === "string")
595
+ streams.progress?.(message.progress);
596
+ if (typeof message.raw === "string")
597
+ stdout.write(Buffer.from(message.raw, "base64"));
598
+ if (typeof message.exit === "number")
599
+ finish({ code: message.exit });
600
+ }, () => finish({ error: stopped() }));
601
+ }), "relayCommand");
602
+
603
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/cli/messenger/serve-relay.js
604
+ var lentConnection = /* @__PURE__ */ __name((connection, watchers) => throughWrapper(connection, {
605
+ close: /* @__PURE__ */ __name(async () => {
606
+ }, "close"),
607
+ feed: void 0,
608
+ storedChats: void 0,
609
+ listen: void 0,
610
+ listenHistory: void 0,
611
+ ...connection.watch && watchers ? {
612
+ // A watcher that throws (its output limit, a closed reader) ends its own watch, never serve's.
613
+ watch: /* @__PURE__ */ __name(async (onEvent, signal, onReady) => {
614
+ let watcher;
615
+ try {
616
+ await new Promise((resolve, reject) => {
617
+ watcher = /* @__PURE__ */ __name((event) => {
618
+ try {
619
+ onEvent(event);
620
+ } catch (error) {
621
+ reject(error);
622
+ }
623
+ }, "watcher");
624
+ watchers.add(watcher);
625
+ signal.addEventListener("abort", () => resolve(), { once: true });
626
+ onReady?.();
627
+ if (signal.aborted)
628
+ resolve();
629
+ });
630
+ } finally {
631
+ if (watcher)
632
+ watchers.delete(watcher);
633
+ }
634
+ }, "watch")
635
+ } : { watch: void 0 }
636
+ }), "lentConnection");
637
+ var serveRelay = /* @__PURE__ */ __name((command, messenger) => {
638
+ let held;
639
+ let relay;
640
+ const watchers = /* @__PURE__ */ new Set();
641
+ const borrowed = /* @__PURE__ */ __name(() => {
642
+ const connection = held;
643
+ if (!connection)
644
+ throw new CliError("provider_unavailable", "serve is not connected yet", { retryable: true });
645
+ return lentConnection(connection, watchers);
646
+ }, "borrowed");
647
+ return {
648
+ messenger: {
649
+ ...messenger,
650
+ connect: /* @__PURE__ */ __name(async (...args) => {
651
+ held = await messenger.connect(...args);
652
+ return held;
653
+ }, "connect")
654
+ },
655
+ arrived: /* @__PURE__ */ __name((event) => {
656
+ for (const watcher of watchers)
657
+ watcher(event);
658
+ }, "arrived"),
659
+ /** Listens beside the lock; the address goes into it, which is how a client finds it. */
660
+ open: /* @__PURE__ */ __name(async (lockPath, profile) => {
661
+ const environment = environmentOf(command);
662
+ const runCommand = environment.runCommand;
663
+ if (!runCommand)
664
+ return void 0;
665
+ const readOnly = readOnlyLockOf(messenger.app, environment.env ?? process.env);
666
+ const path = relayPath(lockPath);
667
+ relay = await listenRelay(path, (request, io) => runCommand(request.argv, {
668
+ env: {
669
+ ...request.env,
670
+ ...readOnly ? { [`${messenger.app.envPrefix}_READ_ONLY`]: "1" } : {}
671
+ },
672
+ streams: io.streams,
673
+ stdin: io.stdin,
674
+ stdout: io.stdout,
675
+ tty: request.tty,
676
+ signal: io.signal,
677
+ answer: /* @__PURE__ */ __name(() => null, "answer"),
678
+ relayed: { profile, cwd: request.cwd, connection: borrowed }
679
+ }));
680
+ return { path, protocol: RELAY_PROTOCOL };
681
+ }, "open"),
682
+ close: /* @__PURE__ */ __name(async () => {
683
+ await relay?.close();
684
+ }, "close")
685
+ };
686
+ }, "serveRelay");
687
+
688
+ export {
689
+ RELAY_PROTOCOL,
690
+ relayCommand,
691
+ lackedNeed,
692
+ refuseLacking,
693
+ hideNever,
694
+ lentConnection,
695
+ serveRelay,
696
+ positiveCount,
697
+ configuredLimit,
698
+ withPaging,
699
+ window,
700
+ pagingOf,
701
+ chatRef,
702
+ chatAnswer,
703
+ memberAnswer,
704
+ contactRef,
705
+ contactAnswer,
706
+ contactShown,
707
+ chatEventAnswer,
708
+ memberEventAnswer,
709
+ inviteLinkAnswer,
710
+ joinRequestAnswer,
711
+ pollVoteAnswer,
712
+ reactorAnswer,
713
+ topicAnswer,
714
+ folderAnswer,
715
+ lines,
716
+ pageOf,
717
+ wholeList,
718
+ chatShown,
719
+ scoreFloor,
720
+ auditAnswer,
721
+ renderItem,
722
+ withPage,
723
+ documentLinkAnswer,
724
+ accountAnswer,
725
+ sessionAnswer
726
+ };