@wirecat/amo-cli 0.1.1 → 0.3.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 (182) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +15 -10
  3. package/contracts/wirecat.json +55 -6
  4. package/dist/amo/button.d.ts +53 -0
  5. package/dist/amo/button.d.ts.map +1 -0
  6. package/dist/amo/button.js +234 -0
  7. package/dist/amo/button.js.map +1 -0
  8. package/dist/amo/oauth.d.ts +12 -3
  9. package/dist/amo/oauth.d.ts.map +1 -1
  10. package/dist/amo/oauth.js +19 -6
  11. package/dist/amo/oauth.js.map +1 -1
  12. package/dist/bin/amo.js +2 -2
  13. package/dist/bundle/agent-FDNP27SW.js +40 -0
  14. package/dist/bundle/{all-profiles-3KQVWDV4.js → all-profiles-PPUN52SP.js} +63 -21
  15. package/dist/bundle/amo.js +28 -26
  16. package/dist/bundle/{anthropic-N5NOX7K7.js → anthropic-RDNDT6ZP.js} +5 -5
  17. package/dist/bundle/{app-server-2MST5EZ5.js → app-server-MMALJDBP.js} +79 -68
  18. package/dist/bundle/{bun-4NHWOFX2.js → bun-Y4FRPURU.js} +2 -2
  19. package/dist/bundle/{bun-sqlite-DRSXPWPR.js → bun-sqlite-7NXJGZCO.js} +6 -6
  20. package/dist/bundle/{chunk-GNTJMB6X.js → chunk-2YEDK2XV.js} +4 -4
  21. package/dist/bundle/chunk-3NDMVXGS.js +80 -0
  22. package/dist/bundle/{chunk-Y37A3232.js → chunk-3RP57VDS.js} +114 -7
  23. package/dist/bundle/{chunk-ODNQU7DH.js → chunk-3YOZTGZ6.js} +43 -64
  24. package/dist/bundle/{chunk-ESZSMZKT.js → chunk-4EYPFFTN.js} +2 -2
  25. package/dist/bundle/{chunk-TZSUZGWM.js → chunk-4MVTSMWP.js} +2 -2
  26. package/dist/bundle/{chunk-LJQUYECN.js → chunk-5DPMNYQT.js} +1 -1
  27. package/dist/bundle/{chunk-7PKFYX7V.js → chunk-5POLHHDZ.js} +8 -8
  28. package/dist/bundle/{chunk-A33TIM5D.js → chunk-5RXH35ZA.js} +225 -225
  29. package/dist/bundle/{chunk-BVMNXI53.js → chunk-77FP6AWC.js} +25 -25
  30. package/dist/bundle/{chunk-L6AFE73L.js → chunk-7E6QSIRQ.js} +1 -1
  31. package/dist/bundle/chunk-7SBAHYZW.js +734 -0
  32. package/dist/bundle/{chunk-GQ7VFIYM.js → chunk-7USADF2W.js} +23 -7
  33. package/dist/bundle/{chunk-AHJ4W2IL.js → chunk-7VSYOMEH.js} +2 -2
  34. package/dist/bundle/chunk-7Z6NYSAN.js +52 -0
  35. package/dist/bundle/chunk-AYR6FIXN.js +30 -0
  36. package/dist/bundle/{chunk-ADEWU4P4.js → chunk-B4ITT55D.js} +1 -1
  37. package/dist/bundle/{chunk-AUBB72VF.js → chunk-BKTLAXUK.js} +41 -10
  38. package/dist/bundle/{chunk-63F65DHU.js → chunk-BYVDMPLX.js} +2 -2
  39. package/dist/bundle/{chunk-V77XNPXG.js → chunk-CQ472K6W.js} +11 -11
  40. package/dist/bundle/{chunk-FKR3M62D.js → chunk-CUZISGWH.js} +13 -13
  41. package/dist/bundle/{chunk-LDEBZ3IX.js → chunk-D6UPCAPD.js} +1 -1
  42. package/dist/bundle/{chunk-P3WQRTYZ.js → chunk-E2DLRLJ5.js} +1 -1
  43. package/dist/bundle/{chunk-NJYAL3UW.js → chunk-EHULZEXQ.js} +1 -1
  44. package/dist/bundle/chunk-EKNP326Q.js +108 -0
  45. package/dist/bundle/{chunk-DJD7TBYG.js → chunk-ELJGALVX.js} +76 -74
  46. package/dist/bundle/{chunk-RPWAJYI6.js → chunk-FI2TP6TY.js} +3 -3
  47. package/dist/bundle/{chunk-CDY2NJFE.js → chunk-FPDTIQOK.js} +2 -2
  48. package/dist/bundle/{chunk-NC76INB2.js → chunk-FPIUFSWK.js} +3099 -2266
  49. package/dist/bundle/{chunk-SZ2V62HB.js → chunk-GCUFGDKE.js} +2 -2
  50. package/dist/bundle/{chunk-LRBPT7LQ.js → chunk-GKP7CKW2.js} +6 -6
  51. package/dist/bundle/chunk-H34RBRS3.js +209 -0
  52. package/dist/bundle/{chunk-O2UCU52O.js → chunk-HQH4YPO5.js} +134 -569
  53. package/dist/bundle/{chunk-TNUFLULO.js → chunk-I4QCJZW7.js} +8 -8
  54. package/dist/bundle/{chunk-DXGGCGRP.js → chunk-IDQ7BNCZ.js} +14 -14
  55. package/dist/bundle/{chunk-JMDLPBXK.js → chunk-IEAPNTHT.js} +17 -17
  56. package/dist/bundle/{chunk-XQL7FEF4.js → chunk-ILUREFWJ.js} +9 -9
  57. package/dist/bundle/{chunk-QRQYUHCZ.js → chunk-IYUWVMGP.js} +12 -12
  58. package/dist/bundle/chunk-JTFAG3BX.js +338 -0
  59. package/dist/bundle/{chunk-CHUKWON6.js → chunk-JZ2AITOE.js} +3 -3
  60. package/dist/bundle/{chunk-JR6TSMFX.js → chunk-KEOKH2OZ.js} +103 -70
  61. package/dist/bundle/{chunk-UMVRT7VQ.js → chunk-KKXF6TSS.js} +1 -1
  62. package/dist/bundle/{chunk-5E5R65CA.js → chunk-KTLCQ7GC.js} +2 -2
  63. package/dist/bundle/{chunk-QDMXZZG4.js → chunk-KZDBO2FT.js} +18 -8
  64. package/dist/bundle/{chunk-VX37MPTJ.js → chunk-L2ZQDTDU.js} +1 -1
  65. package/dist/bundle/{chunk-CUZRHF34.js → chunk-L3JDQNBC.js} +4 -4
  66. package/dist/bundle/{chunk-3IRJDH2U.js → chunk-L72UALL5.js} +2 -100
  67. package/dist/bundle/{chunk-XRTD2GCU.js → chunk-LOSOWTAZ.js} +19 -258
  68. package/dist/bundle/{chunk-LGQXGOPJ.js → chunk-LYRICHEK.js} +2 -2
  69. package/dist/bundle/{chunk-UBRREVLJ.js → chunk-MMOEAH5G.js} +2 -2
  70. package/dist/bundle/{chunk-EQ7A6NA6.js → chunk-MPXKBF37.js} +1 -1
  71. package/dist/bundle/{chunk-SMSTGO2G.js → chunk-MYMBPQPQ.js} +4 -4
  72. package/dist/bundle/chunk-N4A6E2LL.js +559 -0
  73. package/dist/bundle/{chunk-5HGGG3QO.js → chunk-NJ2LJKNH.js} +16 -3
  74. package/dist/bundle/{chunk-TGEQNS6G.js → chunk-OMH3WP7F.js} +1 -1
  75. package/dist/bundle/{chunk-ULXQ5MJM.js → chunk-ORFLQGWH.js} +4 -4
  76. package/dist/bundle/{chunk-DQV2IKCF.js → chunk-PFZ7WG2B.js} +10 -3
  77. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  78. package/dist/bundle/{chunk-6RS7OYTD.js → chunk-Q2YVY7IR.js} +3 -3
  79. package/dist/bundle/{chunk-DOSJONCX.js → chunk-QHA33ZS6.js} +7 -7
  80. package/dist/bundle/{chunk-JH3UOHRE.js → chunk-QQT7WUR4.js} +4 -4
  81. package/dist/bundle/{chunk-EROSAUNP.js → chunk-R23DRW2T.js} +5 -5
  82. package/dist/bundle/{chunk-WCYCUTSK.js → chunk-SBQ5MFHM.js} +7 -7
  83. package/dist/bundle/{chunk-DAY6TSPF.js → chunk-SJYVKR54.js} +62 -50
  84. package/dist/bundle/{chunk-T2UDLX76.js → chunk-SJZ52MZE.js} +6 -6
  85. package/dist/bundle/{chunk-ZM7I52EP.js → chunk-T6D34X5S.js} +3 -4
  86. package/dist/bundle/{chunk-P5LYZRKW.js → chunk-TCDER3G7.js} +1586 -749
  87. package/dist/bundle/{chunk-2I5UVMLW.js → chunk-TWZF7VO6.js} +1726 -1159
  88. package/dist/bundle/{chunk-VVHRQ46X.js → chunk-UA7C57IB.js} +2 -2
  89. package/dist/bundle/{chunk-5SBLU7D7.js → chunk-UM6SDFB6.js} +1 -1
  90. package/dist/bundle/{chunk-7U5HJEPZ.js → chunk-UOPP6ORQ.js} +21 -19
  91. package/dist/bundle/{chunk-U7RLVJ34.js → chunk-UT3ODJMI.js} +4 -4
  92. package/dist/bundle/{chunk-7GTUZY7M.js → chunk-UZLT6VSP.js} +3 -3
  93. package/dist/bundle/{chunk-5RLUHTK6.js → chunk-V3ZWYMXT.js} +1 -1
  94. package/dist/bundle/{chunk-LSND5QYI.js → chunk-VD7HD25M.js} +9 -9
  95. package/dist/bundle/{chunk-PFO76YFP.js → chunk-VEGNZPQU.js} +18 -18
  96. package/dist/bundle/{chunk-5Z5PEEKP.js → chunk-VFU25P57.js} +4 -4
  97. package/dist/bundle/{chunk-4ZAK773N.js → chunk-VJHOBOJR.js} +3 -3
  98. package/dist/bundle/{chunk-PM77PRB6.js → chunk-VPBSZ4HQ.js} +185 -162
  99. package/dist/bundle/{chunk-Q2VNBY4Y.js → chunk-VY27K2SH.js} +746 -1205
  100. package/dist/bundle/{chunk-XEFAMLSD.js → chunk-W4KY5JF5.js} +3 -3
  101. package/dist/bundle/{chunk-73CXFE36.js → chunk-WBWVBEHH.js} +29 -1
  102. package/dist/bundle/{chunk-NHXJYS4R.js → chunk-XDT74W5P.js} +32 -28
  103. package/dist/bundle/{chunk-EPOV5UIO.js → chunk-XI75EKLG.js} +11 -11
  104. package/dist/bundle/{chunk-2B24PDH7.js → chunk-XM2G62YF.js} +8 -6
  105. package/dist/bundle/{chunk-5D4Z2B5B.js → chunk-YSOGGUK3.js} +9 -9
  106. package/dist/bundle/chunk-YVO2YGML.js +353 -0
  107. package/dist/bundle/{chunk-EQUKVVHX.js → chunk-ZIFEIJRK.js} +7 -7
  108. package/dist/bundle/{cli-QVWTXADI.js → cli-GAO7LDDA.js} +150 -103
  109. package/dist/bundle/command-contract-RLIBGIDT.js +39 -0
  110. package/dist/bundle/{command-server-entry-5VL5U5EE.js → command-server-entry-BCDJP7XE.js} +28 -28
  111. package/dist/bundle/{decode-SQ5WGNDX.js → decode-OY2GR442.js} +5 -5
  112. package/dist/bundle/{dispatch-LA4DFXJD.js → dispatch-JWEJCBTF.js} +8 -8
  113. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  114. package/dist/bundle/{echarts-25Z3RINX.js → echarts-AHEPEA5P.js} +2 -2
  115. package/dist/bundle/{embed-BNOTNXMA.js → embed-RVSUV54Z.js} +6 -6
  116. package/dist/bundle/{embedder-BCUT7KKV.js → embedder-GRZXZUXR.js} +9 -9
  117. package/dist/bundle/{failure-PKAC6XCT.js → failure-DDCSR54L.js} +2 -2
  118. package/dist/bundle/{first-run-EO5K5GME.js → first-run-G3WI4DH4.js} +12 -12
  119. package/dist/bundle/first-screen-6MLCMW2U.js +39 -0
  120. package/dist/bundle/{instructions-VLM3QAYB.js → instructions-NWQC5IP4.js} +1 -1
  121. package/dist/bundle/{mcp-7ILNMJH5.js → mcp-KGWT6TGO.js} +2 -2
  122. package/dist/bundle/meeting-combined-SVTFVZNJ.js +24 -0
  123. package/dist/bundle/{meeting-model-GHMMUQ34.js → meeting-model-I6T5HIZ5.js} +11 -11
  124. package/dist/bundle/{meeting-semantic-BMP6323L.js → meeting-semantic-47UA5JBF.js} +6 -6
  125. package/dist/bundle/{node-CT3N3TNL.js → node-7VXN7F4B.js} +2 -2
  126. package/dist/bundle/{node-sqlite-MELD2SBX.js → node-sqlite-BSEON57L.js} +7 -7
  127. package/dist/bundle/{oauth-YBH5OKC2.js → oauth-V6UAT4YD.js} +8 -8
  128. package/dist/bundle/{open-WNSBWTAG.js → open-7LVAY7ZU.js} +5 -5
  129. package/dist/bundle/{openai-XSNMNLW6.js → openai-OIEH342H.js} +15 -15
  130. package/dist/bundle/{process-I2QKOMM7.js → process-PTUCNLZ7.js} +1 -1
  131. package/dist/bundle/{program-DV73CIGP.js → program-S5WY5IZP.js} +643 -852
  132. package/dist/bundle/{prompt-SOG4AKPM.js → prompt-7XWTEQ62.js} +5 -5
  133. package/dist/bundle/{recognize-WMQLWMXH.js → recognize-HGIAJXDR.js} +4 -4
  134. package/dist/bundle/{remote-4BTFOLFY.js → remote-X4SVEMHS.js} +9 -9
  135. package/dist/bundle/{rerank-LJ3TWRNV.js → rerank-QWM3DQMU.js} +7 -7
  136. package/dist/bundle/{serve-B6UANKXN.js → serve-VVG3TXYT.js} +10 -10
  137. package/dist/bundle/{server-YRH6GJ5Z.js → server-EHYK62BJ.js} +73 -61
  138. package/dist/bundle/server-WRPTBVNW.js +86 -0
  139. package/dist/bundle/source-YISMYLBQ.js +44 -0
  140. package/dist/bundle/{sqlite-runtime-R7QFWFE7.js → sqlite-runtime-MCKXDNYC.js} +6 -6
  141. package/dist/bundle/{state-DIJ5YUOE.js → state-MYNYQJCT.js} +6 -6
  142. package/dist/bundle/store-A7R2SZVD.js +34 -0
  143. package/dist/bundle/{store-MYTYDV6A.js → store-B7O3F3QB.js} +28 -21
  144. package/dist/bundle/{store-6WFWW7EC.js → store-FPIU2546.js} +24 -23
  145. package/dist/bundle/store-maintenance-command-D55FRTIK.js +73 -0
  146. package/dist/bundle/surface-3EX6IGHW.js +72 -0
  147. package/dist/bundle/writer-XDHZ54JD.js +46 -0
  148. package/dist/commands/session.d.ts +23 -0
  149. package/dist/commands/session.d.ts.map +1 -1
  150. package/dist/commands/session.js +115 -45
  151. package/dist/commands/session.js.map +1 -1
  152. package/dist/identity.js +1 -1
  153. package/dist/identity.js.map +1 -1
  154. package/dist/program.d.ts.map +1 -1
  155. package/dist/program.js +3 -1
  156. package/dist/program.js.map +1 -1
  157. package/dist/reasons.d.ts.map +1 -1
  158. package/dist/reasons.js +2 -0
  159. package/dist/reasons.js.map +1 -1
  160. package/dist/setup/flow.d.ts.map +1 -1
  161. package/dist/setup/flow.js +74 -4
  162. package/dist/setup/flow.js.map +1 -1
  163. package/dist/setup/texts.en.json +22 -1
  164. package/dist/setup/texts.es.json +22 -1
  165. package/dist/setup/texts.ru.json +22 -1
  166. package/dist/version.d.ts +1 -1
  167. package/dist/version.js +1 -1
  168. package/package.json +5 -3
  169. package/scenarios/first-sync.md +23 -0
  170. package/scenarios/keep-in-sync.md +18 -0
  171. package/scenarios/safe-agent-writes.md +21 -0
  172. package/skills/amo-cli/SKILL.md +1 -1
  173. package/skills/amo-cli/references/mcp.md +1 -1
  174. package/skills/amo-cli/references/setup.md +9 -3
  175. package/dist/bundle/command-contract-QBUQBXH7.js +0 -39
  176. package/dist/bundle/first-screen-GMN3T6RW.js +0 -39
  177. package/dist/bundle/meeting-combined-LAMF7S2B.js +0 -24
  178. package/dist/bundle/server-S6XD6V6E.js +0 -77
  179. package/dist/bundle/source-DGFTA2TN.js +0 -42
  180. package/dist/bundle/store-FJCNZULV.js +0 -32
  181. package/dist/bundle/store-maintenance-command-B5TMKFMG.js +0 -68
  182. package/dist/bundle/writer-GP7VIMAU.js +0 -44
@@ -1,27 +1,23 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
- Command,
5
- InvalidArgumentError,
4
+ LIST_QUERY_GUIDE,
5
+ timeBounds
6
+ } from "./chunk-7SBAHYZW.js";
7
+ import {
6
8
  MESSENGER_CHANGE_REFUSAL,
7
- Option,
8
- annotate,
9
- annotateOption,
10
9
  envName,
11
10
  guardedWrite,
12
- listOf,
13
11
  progressLine,
14
12
  progressOf,
15
13
  readOnlyRefusal,
16
- runBudget,
17
- sharedCommand
18
- } from "./chunk-PM77PRB6.js";
14
+ runBudget
15
+ } from "./chunk-VPBSZ4HQ.js";
19
16
  import {
20
17
  crmIdentityId,
21
18
  crmSettingKey,
22
- readMoment,
23
19
  seenBy
24
- } from "./chunk-P5LYZRKW.js";
20
+ } from "./chunk-TCDER3G7.js";
25
21
  import {
26
22
  LOG_ATTRIBUTES,
27
23
  accountsOfList,
@@ -35,10 +31,10 @@ import {
35
31
  logAttributes,
36
32
  sameAs,
37
33
  sourceOf3 as sourceOf
38
- } from "./chunk-BVMNXI53.js";
34
+ } from "./chunk-77FP6AWC.js";
39
35
  import {
40
36
  isCliFailure
41
- } from "./chunk-UBRREVLJ.js";
37
+ } from "./chunk-MMOEAH5G.js";
42
38
  import {
43
39
  CEILING_KEY,
44
40
  DEFAULT_PERMISSIONS,
@@ -47,15 +43,16 @@ import {
47
43
  levelFor,
48
44
  skipFlagFor,
49
45
  stops
50
- } from "./chunk-QDMXZZG4.js";
46
+ } from "./chunk-KZDBO2FT.js";
51
47
  import {
52
48
  e164Of,
53
49
  foldName
54
- } from "./chunk-PFO76YFP.js";
50
+ } from "./chunk-VEGNZPQU.js";
55
51
  import {
56
52
  CRM_KINDS,
57
53
  DEAL_KINDS,
58
54
  INTERNAL_NOTES,
55
+ STAGE_OUTCOMES,
59
56
  currencyOf,
60
57
  holdsKindOf,
61
58
  isCrmUserId,
@@ -66,706 +63,1245 @@ import {
66
63
  minorUnits,
67
64
  normalCrmUserId,
68
65
  providerNamed
69
- } from "./chunk-QRQYUHCZ.js";
66
+ } from "./chunk-IYUWVMGP.js";
70
67
  import {
71
- BACKENDS,
72
- EVENT_QUERY,
73
- MEETING_FIELDS,
74
- MEETING_FIELD_KEYS,
75
- MEETING_PROJECT_EVIDENCE_QUERY,
76
- MEETING_QUERY,
77
- MEETING_QUERY_GUIDE,
78
- MeetingError,
79
- OPERATORS_BY_TYPE,
80
- QUERY_LIMITS,
81
- SAVE_HELP,
82
- SNAKE_CASE,
83
- dateRange,
84
- defineQuery,
85
- eventItem,
86
- exportMeeting,
87
- fieldsHelp,
88
- fieldsNamed,
89
- importFiles,
90
- listed,
91
- markedPassage,
92
- meetingDetailsBody,
93
- meetingFieldFlag,
94
- meetingHitsList,
95
- meetingPeople,
96
- meetingShowThrough,
97
- meetingSummaryAnswer,
98
- meetingTranscriptAnswer,
99
- meetingsListThrough,
100
- meetingsQuery,
101
68
  parseLucene,
102
- pull,
103
- queryDescription,
104
- queryError,
105
- queryFieldsOf,
106
- readMeetingProjectEvidence,
107
- timezoneOf,
108
- validateMeetingHitSearch,
109
- validateMeetingPassage,
110
- validateQuery,
111
69
  walkQuery
112
- } from "./chunk-A33TIM5D.js";
70
+ } from "./chunk-5RXH35ZA.js";
113
71
  import {
114
72
  backoffMs,
115
73
  logRecordOf,
116
74
  realSleep,
117
75
  resolvePaths,
118
76
  writeSecurely
119
- } from "./chunk-DJD7TBYG.js";
77
+ } from "./chunk-ELJGALVX.js";
120
78
  import {
121
- description,
122
- maxLength,
79
+ array,
80
+ boolean,
81
+ function_,
82
+ getDotPath,
83
+ integer,
84
+ literal,
85
+ minLength,
86
+ minValue,
87
+ number,
123
88
  optional,
89
+ picklist,
124
90
  pipe,
125
- string
126
- } from "./chunk-AUBB72VF.js";
91
+ record,
92
+ regex,
93
+ safeParse,
94
+ strictObject,
95
+ string,
96
+ union,
97
+ unknown
98
+ } from "./chunk-BKTLAXUK.js";
127
99
  import {
128
100
  CliError,
129
101
  isCliError
130
- } from "./chunk-SZ2V62HB.js";
102
+ } from "./chunk-GCUFGDKE.js";
131
103
  import {
132
104
  __export,
133
105
  __name
134
106
  } from "./chunk-ZVVMGPBJ.js";
135
107
 
136
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/services/moment.js
137
- var read = /* @__PURE__ */ __name((reference, flag, now, at) => {
138
- const found = readMoment(reference, flag, { ...at, now });
139
- if (found === void 0)
140
- throw new CliError("validation_error", `${flag} takes an ISO 8601 time, today, yesterday, or 30m, 2h, 1d ago \u2014 not "${reference.trim()}"`);
141
- return found;
142
- }, "read");
143
- var momentOf = /* @__PURE__ */ __name((reference, flag = "--since", now = Date.now(), at = {}) => read(reference, flag, now, at).time, "momentOf");
144
- var dateWindow = /* @__PURE__ */ __name(({ sinceTime, untilTime, zone, now = Date.now(), names = ["--since-time", "--until-time"] }) => {
145
- const at = zone === void 0 ? {} : { zone };
146
- const lower = sinceTime === void 0 ? void 0 : read(sinceTime, names[0], now, at);
147
- const upper = untilTime === void 0 ? void 0 : read(untilTime, names[1], now, { ...at, end: true });
148
- const since = lower?.time;
149
- const until = upper?.time;
150
- const readInZone = lower?.local === true || upper?.local === true;
151
- const window = {
152
- ...since === void 0 ? {} : { since: new Date(since).toISOString() },
153
- ...until === void 0 ? {} : { until: new Date(until).toISOString() }
154
- };
155
- return {
156
- ...since === void 0 ? {} : { since },
157
- ...until === void 0 ? {} : { until },
158
- meta: {
159
- ...readInZone ? { timezone: timezoneOf(zone) } : {},
160
- ...since === void 0 && until === void 0 ? {} : { window }
161
- }
162
- };
163
- }, "dateWindow");
108
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/values.js
109
+ var values_exports = {};
110
+ __export(values_exports, {
111
+ amountOf: () => amountOf,
112
+ crmValuesOf: () => crmValuesOf,
113
+ epoch: () => epoch,
114
+ fieldOf: () => fieldOf,
115
+ fullName: () => fullName,
116
+ id: () => id,
117
+ ids: () => ids,
118
+ isRaw: () => isRaw,
119
+ number: () => number2,
120
+ rawsOf: () => rawsOf,
121
+ text: () => text,
122
+ time: () => time
123
+ });
164
124
 
165
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/meetings/cli/management.js
166
- var REMOTE_READ = { remote: "read", local: "read" };
167
- var REMOTE_WRITE = { remote: "write", local: "write" };
168
- var minutes = /* @__PURE__ */ __name((text2) => {
169
- if (!/^[1-9]\d*$/.test(text2))
170
- throw new InvalidArgumentError("expected whole minutes");
171
- return Number(text2);
172
- }, "minutes");
173
- var setting = /* @__PURE__ */ __name((text2, previous = []) => {
174
- const at = text2.indexOf("=");
175
- const name = text2.slice(0, at);
176
- if (at < 1 || !SNAKE_CASE.test(name))
177
- throw new InvalidArgumentError("expected name=value with a snake_case name, such as access_type=trusted");
178
- return [...previous, [name, text2.slice(at + 1)]];
179
- }, "setting");
180
- var valuesOf = /* @__PURE__ */ __name((one) => one.type === "choice" ? one.values.join("|") : one.type === "boolean" ? "true|false" : "<text>", "valuesOf");
181
- var changeOptions = /* @__PURE__ */ __name((command, declared, create) => {
182
- const settings = declared.settings.length ? declared.settings.map((one) => `${one.name}=${valuesOf(one)}`).join(", ") : "this service has none";
183
- const takes = declared.fields.map(meetingFieldFlag).join(", ") || "none of the options above";
184
- const schedules = declared.fields.includes("startTime");
185
- const start = !create ? "" : !schedules ? "; this service takes none, its meetings start now" : declared.fields.includes("kind") ? "; for a meeting that starts now, give --kind instant instead" : "";
186
- return command.option("--title <title>", "the meeting's title").addOption(new Option("--kind <kind>", "an instant or a scheduled meeting").choices(["instant", "scheduled"])).option("--start-time <time>", `when it starts: an ISO time with its offset, 2026-11-20T10:00:00+01:00${start}`).option("--duration-minutes <minutes>", "how long it lasts, 1\u20131440", minutes).option("--timezone <zone>", "its IANA time zone, Europe/Madrid").option("--agenda <text>", "its agenda").option("--setting <name=value>", `a setting of this service; repeat it for more: ${settings}`, setting).addHelpText("after", [
187
- "",
188
- `This service takes ${takes}.`,
189
- ...declared.settings.length ? ["Its settings:", ...declared.settings.map((one) => ` ${one.name}=${valuesOf(one)} ${one.description}`)] : []
190
- ].join("\n"));
191
- }, "changeOptions");
192
- var changeOf = /* @__PURE__ */ __name((flags) => {
193
- const change = Object.fromEntries(MEETING_FIELDS.flatMap((key) => flags[key] === void 0 ? [] : [[key, flags[key]]]));
194
- if (!flags.setting)
195
- return change;
196
- const settings = /* @__PURE__ */ new Map();
197
- for (const [name, value] of flags.setting) {
198
- if (settings.has(name))
199
- throw new CliError("validation_error", `--setting ${name} is given twice`);
200
- settings.set(name, value);
201
- }
202
- return { ...change, settings: Object.fromEntries(settings) };
203
- }, "changeOf");
204
- var meetingOf = /* @__PURE__ */ __name((one) => ({
205
- id: one.id,
206
- title: one.title,
207
- kind: one.kind,
208
- start_time: one.startTime,
209
- duration_minutes: one.durationMinutes,
210
- timezone: one.timezone,
211
- agenda: one.agenda,
212
- join_url: one.joinUrl
213
- }), "meetingOf");
214
- var receiptItem = /* @__PURE__ */ __name((receipt) => {
215
- const { change } = receipt;
216
- return {
217
- action: receipt.action,
218
- provider: receipt.scope.provider,
219
- account: receipt.scope.account,
220
- ...receipt.id === void 0 ? {} : { id: receipt.id },
221
- ...receipt.occurrenceId === void 0 ? {} : { occurrence_id: receipt.occurrenceId },
222
- ...change ? {
223
- change: {
224
- ...Object.fromEntries(MEETING_FIELDS.flatMap((key) => change[key] === void 0 ? [] : [[MEETING_FIELD_KEYS[key], change[key]]])),
225
- ...change.settings === void 0 ? {} : { settings: { ...change.settings } }
226
- }
227
- } : {},
228
- applied: receipt.applied,
229
- ...receipt.meeting ? { meeting: meetingOf(receipt.meeting), untrusted: ["meeting.title", "meeting.agenda", "meeting.join_url"] } : {}
230
- };
231
- }, "receiptItem");
232
- var addMeetingManagementCommands = /* @__PURE__ */ __name((group, deps) => {
233
- const { management, print, output, inRun, askFirst } = deps;
234
- const signalled = /* @__PURE__ */ __name(() => {
235
- const signal = deps.signal?.();
236
- return signal ? { signal } : {};
237
- }, "signalled");
238
- const has = /* @__PURE__ */ __name((name) => management.capabilities.includes(name), "has");
239
- const mutation = /* @__PURE__ */ __name((command) => ({
240
- apply: true,
241
- dryRun: command.optsWithGlobals().dryRun === true,
242
- ...signalled(),
243
- confirm: /* @__PURE__ */ __name(async () => {
244
- if (!askFirst)
245
- throw new CliError("configuration_error", "this tool cannot ask before it changes a meeting on the service");
246
- await askFirst(command);
247
- }, "confirm")
248
- }), "mutation");
249
- const write = /* @__PURE__ */ __name((name) => annotate(group.command(name), { effects: REMOTE_WRITE, offline: false, output: { entity: "meeting_change" } }), "write");
250
- const target = /* @__PURE__ */ __name((command) => command.argument("<meeting>", "the service's id of the meeting"), "target");
251
- if (has("create"))
252
- output(changeOptions(write("create").description("create a meeting on the service"), management.fields.create, true)).action(async (flags, command) => inRun(command, async () => print({ item: receiptItem(await management.create(changeOf(flags), mutation(command))) }, command)));
253
- if (has("update"))
254
- output(changeOptions(target(write("update").description("change a meeting on the service")), management.fields.update, false)).action(async (id2, flags, command) => inRun(command, async () => print({ item: receiptItem(await management.update(id2, changeOf(flags), mutation(command))) }, command)));
255
- if (has("cancel"))
256
- output(target(write("cancel").description("cancel a meeting on the service")).option("--occurrence-id <id>", "cancel only this occurrence of a repeating meeting")).action(async (id2, flags, command) => inRun(command, async () => print({
257
- item: receiptItem(await management.cancel(id2, {
258
- ...mutation(command),
259
- ...flags.occurrenceId === void 0 ? {} : { occurrenceId: flags.occurrenceId }
260
- }))
261
- }, command)));
262
- if (has("invitation"))
263
- output(target(annotate(group.command("invitation"), {
264
- effects: REMOTE_READ,
265
- offline: false,
266
- output: { entity: "meeting_invitation" }
267
- }).description("the invitation text the service writes for a meeting"))).action(async (id2, _flags, command) => inRun(command, async () => print({ item: { ...await management.invitation(id2, signalled()), untrusted: ["invitation"] } }, command)));
268
- }, "addMeetingManagementCommands");
125
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/source.js
126
+ var CRM_FILE_SOURCES = ["record", "field", "document", "activity", "comment"];
269
127
 
270
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/meetings/cli/query-options.js
271
- var queryWordsAfterOptions = /* @__PURE__ */ __name((command) => {
272
- command.allowUnknownOption();
273
- const parse = command.parseOptions.bind(command);
274
- command.parseOptions = (args) => {
275
- const parsed = parse(args);
276
- const end = parsed.unknown.indexOf("--");
277
- const help = command._getHelpOption();
278
- const typo = parsed.unknown.slice(0, end < 0 ? void 0 : end).find((word) => word.startsWith("--") && !help?.is(word));
279
- if (typo !== void 0) {
280
- command.allowUnknownOption(false);
281
- command.unknownOption(typo);
282
- }
283
- if (end >= 0)
284
- parsed.unknown.splice(end, 1);
285
- return parsed;
286
- };
287
- return command;
288
- }, "queryWordsAfterOptions");
128
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/files.js
129
+ var parseCrmFileId = /* @__PURE__ */ __name((id2) => {
130
+ const [kind2 = "", owner = "", source = "", ...rest] = id2.trim().split(":");
131
+ const providerId = rest.join(":");
132
+ if (!CRM_KINDS.includes(kind2) || !/^[\w.-]+$/u.test(owner) || !CRM_FILE_SOURCES.includes(source) || !providerId)
133
+ throw new CliError("validation_error", "a file id is <owner kind>:<owner id>:<source>:<id>, as files list prints it, such as deal:12:record:345", { reason: "ref.malformed" });
134
+ return { owner: { kind: kind2, id: owner }, source, providerId };
135
+ }, "parseCrmFileId");
136
+ var foldKey = /* @__PURE__ */ __name((key) => key.replaceAll("_", "").toLowerCase(), "foldKey");
137
+ var DOWNLOAD_KEYS = new Set(["DOWNLOAD_URL", "downloadUrl", "fileUrl", "CALL_RECORD_URL", "archiveLink", "publicUrl"].map(foldKey));
138
+ var isDownloadKey = /* @__PURE__ */ __name((key) => DOWNLOAD_KEYS.has(foldKey(key)) || foldKey(key).endsWith("machine"), "isDownloadKey");
139
+ var WEBHOOK = /\/rest\/\d+\/[^/\s"'?#]+\//iu;
140
+ var PORTAL_PATH = /\/rest\/|show_file\.php/iu;
141
+ var TOKEN_QUERY = /(?:[?&]|&amp;)(?:auth|token|access_token)=[^&#\s]/iu;
142
+ var CREDENTIAL = /(?:[?&]|&amp;)(?:auth|access_token|api_token|x-amz-signature)=[^&#\s]/iu;
143
+ var isTokened = /* @__PURE__ */ __name((value) => WEBHOOK.test(value) || CREDENTIAL.test(value) || PORTAL_PATH.test(value) && TOKEN_QUERY.test(value), "isTokened");
144
+ var LINK_REMOVED = "[link removed]";
145
+ var withoutFileLinks = /* @__PURE__ */ __name((body) => {
146
+ const walk2 = /* @__PURE__ */ __name((value, key) => {
147
+ if (typeof value === "string")
148
+ return isTokened(value) ? LINK_REMOVED : value;
149
+ if (Array.isArray(value))
150
+ return value.map((one) => walk2(one));
151
+ if (value === null || typeof value !== "object")
152
+ return value;
153
+ return Object.fromEntries(Object.entries(value).map(([name, one]) => [
154
+ name,
155
+ (isDownloadKey(name) || key === "_links" && name === "download") && one !== null && one !== "" ? LINK_REMOVED : walk2(one, name)
156
+ ]));
157
+ }, "walk");
158
+ return walk2(body);
159
+ }, "withoutFileLinks");
289
160
 
290
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/meetings/cli/passage.js
291
- var count = /* @__PURE__ */ __name((value) => {
292
- if (!/^(0|[1-9]\d*)$/.test(value) || !Number.isSafeInteger(Number(value)))
293
- throw new CliError("validation_error", "expected a nonnegative safe integer");
294
- return Number(value);
295
- }, "count");
296
- var meetingPassageRequest = /* @__PURE__ */ __name((reference, options, signal) => {
297
- const input = {
298
- before: options.beforeN,
299
- after: options.afterN,
300
- bytes: options.bytes,
301
- max_read_bytes: options.maxReadBytes,
302
- expected_fingerprint: options.expectedFingerprint,
303
- format: options.format ?? "text",
304
- signal
305
- };
306
- validateMeetingPassage(reference, input);
307
- signal?.throwIfAborted();
308
- return input;
309
- }, "meetingPassageRequest");
310
- var createMeetingPassageCommandDefinition = /* @__PURE__ */ __name((program) => {
311
- const meetings = program.commands.find((command) => command.name() === "meetings");
312
- if (!meetings)
313
- throw new CliError("configuration_error", "meeting command group is unavailable");
314
- return annotate(meetings.command("passage").description("read a cited cue with bounded context before and after it").argument("<reference>", "retained transcript cue reference from a search hit").option("--before-n <n>", "preceding cues (default 3)", count).option("--after-n <n>", "following cues (default 3); at most 999 surrounding cues in total", count).option("--bytes <bytes>", "cue JSON byte budget (default 65536); the anchor must fit", count).option("--max-read-bytes <bytes>", "stored text byte budget (default 4194304); boundary probes read metadata only", count).option("--expected-fingerprint <hash>", "reject a changed anchor using its previously read cue fingerprint").addOption(new Option("--format <format>", "compact text, Markdown or structured JSON").choices(["text", "markdown", "json"]).default("text")), {
315
- origin: "handwritten",
316
- effects: { remote: "none", local: "read" },
317
- output: { entity: "meeting_passage" },
318
- examples: [`${program.name()} meetings passage meeting:1/1/1/0 --json`]
319
- });
320
- }, "createMeetingPassageCommandDefinition");
321
- var addMeetingPassageCommandDefinition = /* @__PURE__ */ __name((program, deps) => createMeetingPassageCommand(program).action(async (reference, options, command) => {
322
- const globals = command.optsWithGlobals();
323
- const format = globals.json || globals.jsonl ? "json" : options.format ?? "text";
324
- const input = meetingPassageRequest(reference, { ...options, format }, deps.signal());
325
- const result = markedPassage(await deps.read(reference, input));
326
- input.signal?.throwIfAborted();
327
- deps.output(result, format);
328
- }), "addMeetingPassageCommandDefinition");
329
- var createMeetingPassageCommand = sharedCommand(createMeetingPassageCommandDefinition);
330
- var addMeetingPassageCommand = sharedCommand(addMeetingPassageCommandDefinition);
161
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/values.js
162
+ var isRaw = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRaw");
163
+ var fieldOf = /* @__PURE__ */ __name((value, key) => isRaw(value) ? value[key] : void 0, "fieldOf");
164
+ var rawsOf = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.filter(isRaw) : [], "rawsOf");
165
+ var text = /* @__PURE__ */ __name((value) => {
166
+ if (typeof value !== "string" && typeof value !== "number")
167
+ return null;
168
+ const trimmed = String(value).trim();
169
+ return trimmed === "" ? null : trimmed;
170
+ }, "text");
171
+ var id = /* @__PURE__ */ __name((value) => {
172
+ const found = text(value);
173
+ return found === null || found === "0" ? null : found;
174
+ }, "id");
175
+ var ids = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(id).filter((one) => one !== null) : [], "ids");
176
+ var number2 = /* @__PURE__ */ __name((value) => {
177
+ if (value === null || value === void 0 || value === "")
178
+ return null;
179
+ const found = Number(value);
180
+ return Number.isFinite(found) ? found : null;
181
+ }, "number");
182
+ var time = /* @__PURE__ */ __name((value) => {
183
+ if (typeof value === "number") {
184
+ if (!Number.isFinite(value) || value <= 0)
185
+ return null;
186
+ return new Date(value > 1e11 ? value : value * 1e3).toISOString();
187
+ }
188
+ const found = text(value);
189
+ if (found === null)
190
+ return null;
191
+ const parsed = new Date(found);
192
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
193
+ }, "time");
194
+ var epoch = /* @__PURE__ */ __name((value) => {
195
+ const found = time(value);
196
+ return found === null ? null : Date.parse(found);
197
+ }, "epoch");
198
+ var amountOf = /* @__PURE__ */ __name((value, currency) => {
199
+ const found = number2(value);
200
+ const code = text(currency)?.toUpperCase() ?? null;
201
+ if (found === null || found <= 0 || code === null)
202
+ return { amount: null, currency: null };
203
+ return { amount: typeof value === "string" ? value.trim() : String(found), currency: code };
204
+ }, "amountOf");
205
+ var fullName = /* @__PURE__ */ __name((...parts) => parts.map(text).filter((part) => part !== null).join(" ") || null, "fullName");
206
+ var optionLabel = /* @__PURE__ */ __name((field, option) => field.options?.find(({ id: id2 }) => id2 === String(option))?.label ?? String(option), "optionLabel");
207
+ var crmValuesOf = /* @__PURE__ */ __name((values, fields2) => {
208
+ const byCode = new Map(fields2.map((field) => [field.code, field]));
209
+ return Object.fromEntries(Object.entries(values).map(([code, value]) => {
210
+ const field = byCode.get(code);
211
+ const label = field?.label ?? null;
212
+ if (!field?.options)
213
+ return [code, { label, value: withoutFileLinks(value) }];
214
+ if (Array.isArray(value))
215
+ return [code, { label, value: value.map((one) => optionLabel(field, one)), option_id: value.map(String) }];
216
+ return [code, { label, value: optionLabel(field, value), option_id: String(value) }];
217
+ }));
218
+ }, "crmValuesOf");
331
219
 
332
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/meetings/cli/project-evidence.js
333
- var integer = /* @__PURE__ */ __name((value) => {
334
- if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
335
- throw new CliError("validation_error", "expected a positive safe integer");
336
- return Number(value);
337
- }, "integer");
338
- var addMeetingProjectEvidenceCommandDefinition = /* @__PURE__ */ __name((program, deps) => {
339
- const group = program.commands.find((command) => command.name() === "meetings");
340
- if (!group)
341
- throw new CliError("configuration_error", "meeting command group is unavailable");
342
- const projects = group.commands.find((command) => command.name() === "projects") ?? group.command("projects").description("project-name evidence in stored meetings");
343
- return annotate(queryWordsAfterOptions(projects.command("evidence").description("find cited project-name and alias evidence in the local meeting index; does not refresh it or confirm membership")).argument("<project>", "existing project name, key or explicit alias").argument("[query...]", "exact ID fields and a UTC started_at range, joined by AND").addHelpText("after", `
344
- ${fieldsHelp(MEETING_PROJECT_EVIDENCE_QUERY)}`).option("--limit <n>", "hits in one name page, 1 through 1000 (default 100)", integer).option("--cursor <cursor>", "continue with the same project and frozen selection from next").option("--max-read-bytes <bytes>", "word-read byte budget, at most 67108864 (default 4194304)", integer).action(async (project, words, options) => {
345
- deps.output(await readMeetingProjectEvidence(deps.read, project, { ...options, query: words.join(" "), signal: deps.signal() }, deps.now?.()));
346
- }), {
347
- origin: "handwritten",
348
- effects: { remote: "none", local: "read" },
349
- query: MEETING_PROJECT_EVIDENCE_QUERY,
350
- output: { entity: "meeting_project_evidence" }
351
- });
352
- }, "addMeetingProjectEvidenceCommandDefinition");
353
- var addMeetingProjectEvidenceCommand = sharedCommand(addMeetingProjectEvidenceCommandDefinition);
220
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/cli/bot/api-input.js
221
+ import { readFileSync } from "node:fs";
354
222
 
355
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/meetings/cli/search.js
356
- var moment = /* @__PURE__ */ __name((flag, end, readIn) => (value) => {
357
- const { since, until, meta } = dateWindow(end ? { untilTime: value, names: [flag, flag] } : { sinceTime: value, names: [flag, flag] });
358
- if (meta.timezone)
359
- readIn(meta.timezone);
360
- return end ? until : since;
361
- }, "moment");
362
- var integer2 = /* @__PURE__ */ __name((value) => {
363
- if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
364
- throw new CliError("validation_error", "expected a positive safe integer");
365
- return Number(value);
366
- }, "integer");
367
- var createMeetingSearchCommandDefinition = /* @__PURE__ */ __name((program) => {
368
- let search = program.commands.find((command2) => command2.name() === "search");
369
- if (!search) {
370
- search = new Command("search").description("search the stored resources");
371
- program.addCommand(search);
372
- }
373
- const readIn = /* @__PURE__ */ __name((zone) => command.setOptionValue("timesReadIn", zone), "readIn");
374
- const command = search.command("meetings").description("find words in stored meetings, indexing new ones first").argument("<query>", 'words, OR, (groups), -word, "a phrase", "a b"~N (within N lines), exact:word, from:"Name" (who said the line); date>=30d, project:, tag:, topic: choose meetings; a word also matches its other forms and spellings speech recognition garbled').option("--meeting-id <id>", "only this stored meeting", integer2).option("--identity-id <id>", "meetings with this participant identity; does not say who spoke a hit", integer2).option("--person-id <id>", "meetings with a participant linked to this person", integer2).option("--event-id <id>", "only meetings linked to this stored event", integer2).option("--series-id <id>", "only meetings in this stored series", integer2).option("--project <project>", "meetings confirmed in this project, by name, key or alias").option("--tag <name>", "meetings with this tag, by name or alias").option("--topic-name <name>", "meetings with this topic, by name or alias").option("--since-time <time>", "meetings starting at or after this ISO 8601 date or time, or 30m, 2h, 7d ago", moment("--since-time", false, readIn)).option("--until-time <time>", "meetings starting at or before this ISO 8601 date or time; a date alone covers that whole local day", moment("--until-time", true, readIn)).option("--limit <n>", "how many hits, 1 through 1000; the profile's defaults.limit when absent", integer2).option("--cursor <cursor>", "continue from the previous page's page.next_cursor, with the same query and filters").option("--max-read-bytes <bytes>", "most stored bytes to read, 1 through 67108864 (default 4194304)", integer2);
375
- annotate(command, {
376
- origin: "handwritten",
377
- effects: { remote: "none", local: "read" },
378
- output: { entity: "meeting_hit" }
379
- });
380
- return command;
381
- }, "createMeetingSearchCommandDefinition");
382
- var meetingHitSearchRequest = /* @__PURE__ */ __name((query, options, limit, signal) => {
383
- const request = {
384
- meetingId: options.meetingId,
385
- participantIdentityId: options.identityId,
386
- personId: options.personId,
387
- eventId: options.eventId,
388
- meetingSeriesId: options.seriesId,
389
- project: options.project,
390
- tag: options.tag,
391
- topic: options.topicName ?? options.topic,
392
- since: options.sinceTime,
393
- until: options.untilTime,
394
- limit: options.limit ?? limit,
395
- after: options.cursor,
396
- maxReadBytes: options.maxReadBytes,
397
- signal
398
- };
399
- validateMeetingHitSearch(query, request);
400
- signal?.throwIfAborted();
401
- return request;
402
- }, "meetingHitSearchRequest");
403
- var meetingSearchArguments = /* @__PURE__ */ __name((query, options) => Object.fromEntries(Object.entries({
404
- query,
405
- meeting_id: options.meetingId?.toString(),
406
- identity_id: options.identityId?.toString(),
407
- person_id: options.personId?.toString(),
408
- event_id: options.eventId?.toString(),
409
- series_id: options.seriesId?.toString(),
410
- project: options.project,
411
- tag: options.tag,
412
- topic_name: options.topicName ?? options.topic,
413
- since_time: options.sinceTime === void 0 ? void 0 : new Date(options.sinceTime).toISOString(),
414
- until_time: options.untilTime === void 0 ? void 0 : new Date(options.untilTime).toISOString(),
415
- max_read_bytes: options.maxReadBytes ?? 4194304
416
- }).filter(([, value]) => value !== void 0)), "meetingSearchArguments");
417
- var meetingSearchMeta = /* @__PURE__ */ __name((options) => {
418
- const window = {
419
- ...options.sinceTime === void 0 ? {} : { since: new Date(options.sinceTime).toISOString() },
420
- ...options.untilTime === void 0 ? {} : { until: new Date(options.untilTime).toISOString() }
421
- };
422
- return {
423
- ...options.timesReadIn === void 0 ? {} : { timezone: options.timesReadIn },
424
- ...Object.keys(window).length === 0 ? {} : { window }
425
- };
426
- }, "meetingSearchMeta");
427
- var addMeetingSearchCommandDefinition = /* @__PURE__ */ __name((program, deps) => createMeetingSearchCommand(program).action(async (query, options, command) => {
428
- const request = meetingHitSearchRequest(query, options, deps.pagingOf(command).limit, deps.signal());
429
- deps.output(meetingHitsList(await deps.search(query, request, options), request.limit, "search meetings", meetingSearchArguments(query, options), meetingSearchMeta(options)));
430
- }), "addMeetingSearchCommandDefinition");
431
- var createMeetingSearchCommand = sharedCommand(createMeetingSearchCommandDefinition);
432
- var addMeetingSearchCommand = sharedCommand(addMeetingSearchCommandDefinition);
223
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/names.js
224
+ var pascal = /* @__PURE__ */ __name((text2) => text2.split(/[^A-Za-z0-9]+/).filter(Boolean).map((word) => word[0]?.toUpperCase() + word.slice(1)).join(""), "pascal");
225
+ var GLOBALS = /* @__PURE__ */ new Set([
226
+ "Array",
227
+ "BigInt",
228
+ "Boolean",
229
+ "Date",
230
+ "Error",
231
+ "Function",
232
+ "Intl",
233
+ "JSON",
234
+ "Map",
235
+ "Math",
236
+ "Number",
237
+ "Object",
238
+ "Partial",
239
+ "Promise",
240
+ "Proxy",
241
+ "Record",
242
+ "Reflect",
243
+ "RegExp",
244
+ "Required",
245
+ "Set",
246
+ "String",
247
+ "Symbol",
248
+ "URL",
249
+ "WeakMap",
250
+ "WeakSet"
251
+ ]);
252
+ var identifier = /* @__PURE__ */ __name((id2) => {
253
+ const name = pascal(id2);
254
+ if (!/^[A-Za-z]/.test(name))
255
+ return `Schema${name}`;
256
+ return GLOBALS.has(name) ? `Api${name}` : name;
257
+ }, "identifier");
433
258
 
434
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/meetings/cli/index.js
435
- var EVENT_UNTRUSTED = ["title", "description", "location"];
436
- var integer3 = /* @__PURE__ */ __name((text2) => {
437
- if (!/^[1-9]\d*$/.test(text2) || !Number.isSafeInteger(Number(text2)))
438
- throw new InvalidArgumentError("expected a positive integer");
439
- return Number(text2);
440
- }, "integer");
441
- var lookbackDays = /* @__PURE__ */ __name((text2) => {
442
- if (!/^(0|[1-9]\d*)$/.test(text2) || Number(text2) > 31)
443
- throw new InvalidArgumentError("expected an integer from 0 through 31 days");
444
- return Number(text2);
445
- }, "lookbackDays");
446
- var LOCAL_READ = { remote: "none", local: "read" };
447
- var REMOTE_READ2 = { remote: "read", local: "read" };
448
- var backendOf = /* @__PURE__ */ __name((value) => {
449
- if (!BACKENDS.includes(value))
450
- throw new InvalidArgumentError("expected archive, server or both");
451
- return value;
452
- }, "backendOf");
453
- var backendOption = /* @__PURE__ */ __name((command) => command.option("--backend <archive|server|both>", "where to read: the store (archive), the service (server), or both, kept in the store (default: both)", backendOf), "backendOption");
454
- var BACKEND_HELP = "--backend both asks the service with the part of the query it can filter, keeps what it returns, then runs the whole query over the store; each item says found_in archive, server or both. --offline reads the store only.";
455
- var LOCAL_WRITE = { remote: "none", local: "write" };
456
- var FETCH = { remote: "read", local: "write" };
457
- var addMeetingCommandsDefinition = /* @__PURE__ */ __name((program, deps) => {
458
- const group = annotate(program.command("meetings").description("stored meetings and their records"), {
459
- effects: { remote: "none", local: "none" }
460
- });
461
- const output = /* @__PURE__ */ __name((command) => command, "output");
462
- const print = /* @__PURE__ */ __name((value, command) => {
463
- const opts = command.optsWithGlobals();
464
- deps.write(value, opts.json ? "json" : opts.jsonl ? "jsonl" : "text", command);
465
- }, "print");
466
- const access = /* @__PURE__ */ __name((command, backend) => {
467
- const signal = deps.signal?.();
259
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/sign-in.js
260
+ var BEARER = { in: "header", name: "authorization", value: /* @__PURE__ */ __name((token) => `Bearer ${token}`, "value") };
261
+ var signInPlace = /* @__PURE__ */ __name((scheme) => {
262
+ if (scheme.type === "apiKey") {
263
+ if (!scheme.name || scheme.in !== "header" && scheme.in !== "query")
264
+ return void 0;
468
265
  return {
469
- ...backend === void 0 ? {} : { backend },
470
- offline: command.optsWithGlobals().offline === true,
471
- timezone: timezoneOf(deps.timezone),
472
- ...deps.now ? { now: deps.now() } : {},
473
- ...signal ? { signal } : {}
266
+ in: scheme.in,
267
+ name: scheme.in === "header" ? scheme.name.toLowerCase() : scheme.name,
268
+ value: /* @__PURE__ */ __name((token) => token, "value")
474
269
  };
475
- }, "access");
476
- const list = queryWordsAfterOptions(group.command("list").description("meetings, newest first: the service's and the stored ones, kept in the store")).argument("[query...]", "field:value terms that narrow the list \u2014 the fields are below").addHelpText("after", `
477
- ${fieldsHelp(MEETING_QUERY, MEETING_QUERY_GUIDE)}
478
- ${BACKEND_HELP}`);
479
- annotate(list, {
480
- effects: REMOTE_READ2,
481
- partial: true,
482
- query: defineQuery(MEETING_QUERY),
483
- output: { entity: "meeting" }
484
- });
485
- backendOption(output(list)).option("--limit <n>", "meetings per page; the profile's defaults.limit when absent", integer3).option("--page <n>", "which page, starting at 1", integer3).action(async (words, opts, command) => {
486
- const query = meetingsQuery(words.join(" "));
487
- const { limit, page } = deps.pagingOf(command);
488
- await deps.inRun(command, async () => {
489
- const { server: _server, ...answer } = await meetingsListThrough(deps.source, deps.store, {
490
- accountId: deps.accountId,
491
- limit,
492
- offset: (page - 1) * limit,
493
- ...query ? { query } : {}
494
- }, access(command, opts.backend));
495
- print(answer, command);
496
- });
497
- });
498
- backendOption(output(annotate(group.command("show"), { effects: REMOTE_READ2, partial: true, output: { entity: "meeting_details" } }).description("show a meeting, read again from the service with its people, transcript and documents").argument("<meeting>", "the stored meeting's number, its meeting: ref, or the service's id (provider_id)").addHelpText("after", `${SAVE_HELP}
499
- ${BACKEND_HELP}`))).action(async (meeting, opts, command) => {
500
- await deps.inRun(command, async () => {
501
- const shown = await meetingShowThrough(deps.source, deps.store, deps.accountId, meeting, access(command, opts.backend));
502
- const { item } = await meetingDetailsBody(deps.store, shown.details);
503
- print({
504
- item: shown.foundIn ? { ...item, found_in: shown.foundIn } : item,
505
- ...shown.missing ? { missing: shown.missing } : {},
506
- ...shown.meta ? { meta: shown.meta } : {}
507
- }, command);
508
- });
509
- });
510
- output(annotate(group.command("transcript"), { effects: LOCAL_READ, output: { entity: "meeting_transcript" } }).description("show current meeting transcripts").argument("<meeting>", "stored meeting id", integer3).option("--history", "include superseded transcript versions").addHelpText("after", SAVE_HELP)).action(async (id2, opts, command) => {
511
- print(await meetingTranscriptAnswer(deps.store, id2, deps.accountId, { history: opts.history }), command);
512
- });
513
- output(annotate(group.command("summary"), { effects: LOCAL_READ, output: { entity: "meeting_summary" } }).description("show stored meeting summaries").argument("<meeting>", "stored meeting id", integer3)).action(async (id2, _opts, command) => {
514
- print(await meetingSummaryAnswer(deps.store, id2, deps.accountId), command);
515
- });
516
- const exporter = output(annotate(group.command("export"), { effects: LOCAL_WRITE, output: { entity: "meeting_export" } }).description("export a meeting as Markdown or one transcript as WebVTT").argument("<meeting>", "stored meeting id", integer3).addOption(new Option("--format <format>", "export format").choices(["markdown", "vtt"]).default("markdown")).option("--transcript-id <id>", "export a specific transcript version", integer3).addOption(
517
- // Not over MCP: an agent would choose where on the owner's disk to write; it gets the content in the answer.
518
- annotateOption(new Option("--output <file>", "write content to a new file through the host's writer"), {
519
- mcp: false
520
- })
521
- ));
522
- deps.newFileOutput?.(exporter, "output");
523
- exporter.action(async (id2, opts, command) => {
524
- if (opts.output !== void 0 && !opts.output.trim())
525
- throw new MeetingError("validation_error", "output path must not be empty");
526
- if (opts.output !== void 0 && !deps.writeFile)
527
- throw new MeetingError("configuration_error", "the host has no export file writer");
528
- const result = await exportMeeting(deps.store, id2, {
529
- accountId: deps.accountId,
530
- format: opts.format,
531
- transcriptId: opts.transcriptId
532
- });
533
- if (opts.output !== void 0) {
534
- await deps.writeFile?.(opts.output, result.content);
535
- print({ meetingId: result.meetingId, format: result.format, output: opts.output }, command);
536
- } else
537
- print(result, command);
538
- });
539
- output(annotate(group.command("people"), { effects: LOCAL_READ, output: { entity: "meeting_participants" } }).description("find meeting participants by name or email").argument("<query>", "a name or an email address")).option("--limit <n>", "most matching observations per page, 1\u20131000 (default 50)", integer3).option("--scan-limit <n>", "most participant observations to inspect, 1\u201310000 (default 1000)", integer3).option("--max-read-bytes <bytes>", "most stored name and email bytes to read (default 1048576)", integer3).option("--cursor <cursor>", "continue with the same name query and selected account").action(async (query, opts, command) => {
540
- const found = await meetingPeople(deps.store, query, deps.accountId, {
541
- limit: opts.limit,
542
- scanLimit: opts.scanLimit,
543
- maxReadBytes: opts.maxReadBytes,
544
- cursor: opts.cursor
545
- });
546
- print(found, command);
547
- });
548
- output(annotate(group.command("sync"), {
549
- effects: FETCH,
550
- offline: false,
551
- output: { entity: "meeting_ingestion" },
552
- // Only a sync that stops itself at its budget may outlive the one-shot deadline.
553
- ...deps.budgetOf ? { cooperative: true, partial: true } : {}
554
- }).description("bring the stored meetings up to date from the connected account, oldest first; a run that stops before its deadline keeps what it saved and the next one goes on from there")).option("--since-time <time>", "fetch meetings starting at or after this ISO 8601 date or time, or 30m, 2h, 7d ago", (text2) => dateWindow({ sinceTime: text2, ...deps.timezone ? { zone: deps.timezone } : {}, now: deps.now?.() }).since).option("--lookback-days <days>", "revisit recent occurrences for late transcripts (0\u201331)", lookbackDays).option("--rescan", "read the last 30 days again, not only what came after the last sync").action(async (opts, command) => {
555
- const source = deps.source;
556
- if (!source)
557
- throw new MeetingError("configuration_error", "meeting source is unavailable");
558
- await deps.inRun(command, async () => print(await pull(source, deps.store, {
559
- accountId: deps.accountId,
560
- since: opts.sinceTime === void 0 ? void 0 : new Date(opts.sinceTime).toISOString(),
561
- now: deps.now?.(),
562
- ...opts.lookbackDays === void 0 ? {} : { lookbackMs: opts.lookbackDays * 864e5 },
563
- ...opts.rescan ? { rescan: true } : {},
564
- ...deps.budgetOf ? { budget: deps.budgetOf(command) } : {}
565
- }), command));
566
- });
567
- const importCommand = annotate(group.command("import"), {
568
- effects: LOCAL_WRITE,
569
- output: { entity: "meeting_ingestion" }
570
- }).description("import downloaded meeting transcripts").argument("<folder>", "folder of transcripts downloaded from the provider");
571
- if (deps.importHelp)
572
- importCommand.addHelpText("after", `
573
- ${deps.importHelp}`);
574
- output(importCommand).action(async (folder, _opts, command) => {
575
- if (!deps.readFiles)
576
- throw new MeetingError("configuration_error", "file reader is unavailable");
577
- const files = await deps.readFiles(folder);
578
- if (files.some((file) => file.meeting.accountId !== deps.accountId))
579
- throw new MeetingError("validation_error", "file account differs from selected account");
580
- print(await importFiles(files, deps.store, deps.now?.()), command);
581
- });
582
- output(annotate(group.command("repair"), {
583
- effects: LOCAL_WRITE,
584
- output: { entity: "meeting_repair" }
585
- }).description("preview filling in what older builds left out of stored transcripts (their language); --yes stores it")).option("--yes", "store the detected languages; otherwise only preview").action(async (opts, command) => {
586
- if (!deps.store.fillTranscriptLanguages)
587
- throw new MeetingError("configuration_error", "this store cannot fill transcript languages");
588
- print(await deps.store.fillTranscriptLanguages({
589
- accountId: deps.accountId,
590
- apply: opts.yes === true,
591
- now: deps.now?.() ?? Date.now()
592
- }), command);
593
- });
594
- if (deps.management)
595
- addMeetingManagementCommands(group, {
596
- management: deps.management,
597
- print,
598
- output,
599
- inRun: deps.inRun,
600
- ...deps.askFirst ? { askFirst: deps.askFirst } : {},
601
- ...deps.signal ? { signal: deps.signal } : {}
602
- });
603
- const eventList = queryWordsAfterOptions(annotate(program.command("events").description("the owner's stored events"), {
604
- effects: { remote: "none", local: "none" }
605
- }).command("list")).description("list stored events").argument("[query...]", "event id, origin or time fields that narrow the list").addHelpText("after", `
606
- ${fieldsHelp(EVENT_QUERY, MEETING_QUERY_GUIDE)}`);
607
- annotate(eventList, { effects: LOCAL_READ, output: { entity: "event" }, query: EVENT_QUERY });
608
- output(eventList).action(async (words, _opts, command) => {
609
- const query = words.length ? parseLucene(words.join(" "), { defaultField: "none", command: "events list" }) : void 0;
610
- if (query)
611
- validateQuery(query, EVENT_QUERY, { command: "events list" });
612
- if (query && !deps.store.queryEvents)
613
- throw new MeetingError("validation_error", "this store cannot filter events");
614
- const events = query ? await deps.store.queryEvents?.(query) : await deps.store.events();
615
- print(listed((events ?? []).map((one) => ({ ...eventItem(one), untrusted: [...EVENT_UNTRUSTED] }))), command);
616
- });
617
- }, "addMeetingCommandsDefinition");
618
- var addMeetingCommands = sharedCommand(addMeetingCommandsDefinition);
270
+ }
271
+ if (scheme.type === "http") {
272
+ if (!scheme.scheme || /^bearer$/i.test(scheme.scheme))
273
+ return BEARER;
274
+ if (/^basic$/i.test(scheme.scheme))
275
+ return {
276
+ in: "header",
277
+ name: "authorization",
278
+ value: /* @__PURE__ */ __name((token) => `Basic ${Buffer.from(token).toString("base64")}`, "value"),
279
+ basic: true
280
+ };
281
+ if (/^digest$/i.test(scheme.scheme))
282
+ return void 0;
283
+ return { in: "header", name: "authorization", value: /* @__PURE__ */ __name((token) => `${scheme.scheme} ${token}`, "value") };
284
+ }
285
+ return scheme.type === "oauth2" || scheme.type === "openIdConnect" ? BEARER : void 0;
286
+ }, "signInPlace");
287
+ var signInRequirements = /* @__PURE__ */ __name((operation, document) => {
288
+ const requirements = operation.security ?? document;
289
+ return requirements?.some((one) => Object.keys(one).length > 0) ? requirements : void 0;
290
+ }, "signInRequirements");
619
291
 
620
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/cli/list-query.js
621
- var LIST_QUERY_GUIDE = "https://github.com/WireCatLabs/cli-core/blob/main/docs/search/query-language.md";
622
- var QUERY_ARGUMENT = "field:value terms that narrow the list \u2014 the fields are below";
623
- var withQuery = /* @__PURE__ */ __name((command, registry) => {
624
- const query = defineQuery(registry);
625
- annotate(command, { query, output: { entity: registry.entity } });
626
- const shown = askable(query);
627
- queryWordsAfterOptions(command).argument("[query...]", shown.length > 0 ? QUERY_ARGUMENT : "field:value terms; this list filters by none yet");
628
- if (shown.length > 0)
629
- command.addHelpText("after", `
630
- ${fieldsHelp({ ...query, fields: shown }, LIST_QUERY_GUIDE)}`);
631
- return command;
632
- }, "withQuery");
633
- var unfilteredQuery = /* @__PURE__ */ __name((entity, schema) => ({
634
- entity,
635
- backend: "native",
636
- fields: queryFieldsOf(schema, {})
637
- }), "unfilteredQuery");
638
- var commandPath = /* @__PURE__ */ __name((command) => {
639
- const words = [];
640
- for (let at = command; at?.parent; at = at.parent)
641
- words.unshift(at.name());
642
- return words.join(" ");
643
- }, "commandPath");
644
- var withTomorrow = /* @__PURE__ */ __name((query, registry, zone = timezoneOf(), now = Date.now()) => {
645
- const times = new Set(registry.fields.filter(({ type }) => type === "time").map(({ name }) => name));
646
- const date = /* @__PURE__ */ new Date(`${new Intl.DateTimeFormat("en-CA", { timeZone: zone }).format(now)}T00:00:00Z`);
647
- date.setUTCDate(date.getUTCDate() + 1);
648
- const tomorrow = date.toISOString().slice(0, 10);
649
- const day = /* @__PURE__ */ __name((value) => value.toLowerCase() === "tomorrow" ? tomorrow : value, "day");
650
- const map = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? times.has(node.field) ? { ...node, value: day(node.value), ...node.upper === void 0 ? {} : { upper: day(node.upper) } } : node : { ...node, clauses: node.clauses.map((clause) => ({ ...clause, node: map(clause.node) })) }, "map");
651
- return { ...query, root: map(query.root) };
652
- }, "withTomorrow");
653
- var listQuery = /* @__PURE__ */ __name((text2, registry, command, { defaultField = "none" } = {}) => {
654
- const context = { command, guide: LIST_QUERY_GUIDE };
655
- const signed = text2.replace(/(^|[\s(])([\p{L}_][\p{L}\p{N}_.]*:)\+([^\s()"]+)/gu, '$1$2"+$3"');
656
- const parsed = signed.trim() === "" ? void 0 : parseLucene(signed, { defaultField, ...context });
657
- const typed = parsed && withTomorrow(parsed, registry);
658
- if (typed)
659
- validateQuery(typed, registry, context);
660
- const named2 = typed ? fieldsNamed(typed) : /* @__PURE__ */ new Set();
661
- const defaults = (registry.defaults ?? []).filter((term) => !named2.has(term.replace(/^-/, "").split(/[:<>=]/)[0] ?? "")).map((term) => parseLucene(term, { defaultField: "none", ...context }).root);
662
- const roots = [...typed ? [typed.root] : [], ...defaults];
663
- if (roots.length === 0)
292
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/graphql.js
293
+ var graphqlDocument = /* @__PURE__ */ __name((binding, selection = binding.selection) => {
294
+ const variables = Object.entries(binding.variables);
295
+ const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "";
296
+ const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "";
297
+ const inner = selection.trim() ? ` { ${selection.trim()} }` : "";
298
+ return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }`;
299
+ }, "graphqlDocument");
300
+
301
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/runtime.js
302
+ var INT64_MIN = -(2n ** 63n);
303
+ var INT64_MAX = 2n ** 63n - 1n;
304
+
305
+ // node_modules/.pnpm/@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/openapi.js
306
+ var IGNORED = /* @__PURE__ */ new Set([
307
+ "readOnly",
308
+ "example",
309
+ "examples",
310
+ "externalDocs",
311
+ "title",
312
+ "xml",
313
+ "writeOnly",
314
+ "not",
315
+ "minProperties",
316
+ "maxProperties"
317
+ ]);
318
+ var KNOWN = /* @__PURE__ */ new Set([
319
+ ...IGNORED,
320
+ "type",
321
+ "format",
322
+ "description",
323
+ "nullable",
324
+ "deprecated",
325
+ "default",
326
+ "enum",
327
+ "const",
328
+ "minLength",
329
+ "maxLength",
330
+ "pattern",
331
+ "minimum",
332
+ "maximum",
333
+ "items",
334
+ "prefixItems",
335
+ "minItems",
336
+ "maxItems",
337
+ "uniqueItems",
338
+ "properties",
339
+ "required",
340
+ "additionalProperties",
341
+ "allOf",
342
+ "oneOf",
343
+ "anyOf",
344
+ "$ref",
345
+ "discriminator"
346
+ ]);
347
+ var LARGEST_EXAMPLE = 8 * 1024;
348
+
349
+ // node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/utils.js
350
+ function isInteger(value) {
351
+ return INTEGER_REGEX.test(value);
352
+ }
353
+ __name(isInteger, "isInteger");
354
+ var INTEGER_REGEX = /^-?[0-9]+$/;
355
+ function isNumber(value) {
356
+ return NUMBER_REGEX.test(value);
357
+ }
358
+ __name(isNumber, "isNumber");
359
+ var NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
360
+ function isSafeNumber(value, config2) {
361
+ if (isInteger(value)) {
362
+ return Number.isSafeInteger(Number.parseInt(value, 10));
363
+ }
364
+ const num = Number.parseFloat(value);
365
+ if (Number.isInteger(num) && !Number.isSafeInteger(num)) {
366
+ return false;
367
+ }
368
+ const parsed = String(num);
369
+ if (value === parsed) {
370
+ return true;
371
+ }
372
+ const valueDigits = extractSignificantDigits(value);
373
+ const parsedDigits = extractSignificantDigits(parsed);
374
+ if (valueDigits === parsedDigits) {
375
+ return true;
376
+ }
377
+ if (config2?.approx === true) {
378
+ const requiredDigits = 14;
379
+ if (parsedDigits.length >= requiredDigits && valueDigits.startsWith(parsedDigits.substring(0, requiredDigits))) {
380
+ return true;
381
+ }
382
+ }
383
+ return false;
384
+ }
385
+ __name(isSafeNumber, "isSafeNumber");
386
+ var UnsafeNumberReason = /* @__PURE__ */ (function(UnsafeNumberReason2) {
387
+ UnsafeNumberReason2["underflow"] = "underflow";
388
+ UnsafeNumberReason2["overflow"] = "overflow";
389
+ UnsafeNumberReason2["truncate_integer"] = "truncate_integer";
390
+ UnsafeNumberReason2["truncate_float"] = "truncate_float";
391
+ return UnsafeNumberReason2;
392
+ })({});
393
+ function getUnsafeNumberReason(value) {
394
+ if (isSafeNumber(value, {
395
+ approx: false
396
+ })) {
664
397
  return void 0;
665
- if (roots.length === 1 && typed)
666
- return typed;
398
+ }
399
+ if (isInteger(value)) {
400
+ return UnsafeNumberReason.truncate_integer;
401
+ }
402
+ const num = Number.parseFloat(value);
403
+ if (!Number.isFinite(num)) {
404
+ return UnsafeNumberReason.overflow;
405
+ }
406
+ if (num === 0) {
407
+ return UnsafeNumberReason.underflow;
408
+ }
409
+ return UnsafeNumberReason.truncate_float;
410
+ }
411
+ __name(getUnsafeNumberReason, "getUnsafeNumberReason");
412
+ function extractSignificantDigits(value) {
413
+ const {
414
+ start,
415
+ end
416
+ } = getSignificantDigitRange(value);
417
+ const digits = value.substring(start, end);
418
+ const dot = digits.indexOf(".");
419
+ if (dot === -1) {
420
+ return digits;
421
+ }
422
+ return digits.substring(0, dot) + digits.substring(dot + 1);
423
+ }
424
+ __name(extractSignificantDigits, "extractSignificantDigits");
425
+ function getSignificantDigitRange(value) {
426
+ let start = 0;
427
+ if (value[0] === "-") {
428
+ start++;
429
+ }
430
+ while (value[start] === "0" || value[start] === ".") {
431
+ start++;
432
+ }
433
+ let end = value.lastIndexOf("e");
434
+ if (end === -1) {
435
+ end = value.lastIndexOf("E");
436
+ }
437
+ if (end === -1) {
438
+ end = value.length;
439
+ }
440
+ while ((value[end - 1] === "0" || value[end - 1] === ".") && end > start) {
441
+ end--;
442
+ }
667
443
  return {
668
- version: 1,
669
- language: "lucene-v1",
670
- root: {
671
- kind: "boolean",
672
- clauses: roots.map((node) => ({ occur: "must", node })),
673
- span: { start: 0, end: text2.length }
674
- }
444
+ start,
445
+ end
675
446
  };
676
- }, "listQuery");
677
- var typedQuery = /* @__PURE__ */ __name((words) => typeof words === "string" ? words : (words ?? []).join(" "), "typedQuery");
678
- var EVERY = Number.MAX_SAFE_INTEGER - 1;
679
- var pageOf = /* @__PURE__ */ __name(({ limit, page, all }) => all ? { limit: EVERY, offset: 0 } : { limit, offset: (page - 1) * limit }, "pageOf");
680
- var pagedList = /* @__PURE__ */ __name((command, { limit, page, all }, { items, hasMore, ...rest }) => listOf(command, {
681
- ...rest,
682
- items,
683
- limit: all ? Math.max(1, items.length) : limit,
684
- has_more: all ? false : hasMore,
685
- page
686
- }), "pagedList");
687
- var askable = /* @__PURE__ */ __name((registry) => registry.backend === "native" ? registry.fields.filter((field) => field.native) : registry.fields, "askable");
688
- var queryArgument = /* @__PURE__ */ __name((registry) => optional(pipe(string(), maxLength(QUERY_LIMITS.bytes), description(queryDescription(registry)))), "queryArgument");
689
- var negatableOf = /* @__PURE__ */ __name((registry) => askable(registry).filter((field) => field.negatable).map((field) => field.name), "negatableOf");
690
- var nativeTerms = /* @__PURE__ */ __name((ast, command) => new Map([...nativeTermLists(ast, command)].map(([field, [node]]) => [field, node])), "nativeTerms");
691
- var nativeTermLists = /* @__PURE__ */ __name((ast, command, repeatable = [], negatable = []) => {
692
- const terms = /* @__PURE__ */ new Map();
693
- if (!ast)
694
- return terms;
695
- const context = { command, guide: LIST_QUERY_GUIDE };
696
- const add = /* @__PURE__ */ __name((node) => {
697
- if (node.kind === "boolean") {
698
- for (const clause of node.clauses) {
699
- const excluded = clause.occur === "must_not" && clause.node.kind === "predicate" && negatable.includes(clause.node.field);
700
- if (excluded && clause.node.kind === "predicate") {
701
- const key = `-${clause.node.field}`;
702
- terms.set(key, [...terms.get(key) ?? [], clause.node]);
447
+ }
448
+ __name(getSignificantDigitRange, "getSignificantDigitRange");
449
+
450
+ // node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/LosslessNumber.js
451
+ var losslessNumberMarker = /* @__PURE__ */ Symbol.for("lossless-json.LosslessNumber");
452
+ var LosslessNumber = class {
453
+ static {
454
+ __name(this, "LosslessNumber");
455
+ }
456
+ // numeric value as string
457
+ value;
458
+ /**
459
+ * @deprecated Use the isLosslessNumber(value) function instead.
460
+ *
461
+ * Ordinary objects may also have an isLosslessNumber property, so this
462
+ * field cannot reliably identify lossless numbers.
463
+ */
464
+ isLosslessNumber = true;
465
+ get [losslessNumberMarker]() {
466
+ return true;
467
+ }
468
+ constructor(value) {
469
+ if (!isNumber(value)) {
470
+ throw new Error(`Invalid number (value: "${value}")`);
471
+ }
472
+ this.value = value;
473
+ }
474
+ /**
475
+ * Get the value of the LosslessNumber as number or bigint.
476
+ *
477
+ * - a number is returned for safe numbers and decimal values that only lose some insignificant digits
478
+ * - a bigint is returned for big integer numbers
479
+ * - an Error is thrown for values that will overflow or underflow
480
+ *
481
+ * Note that you can implement your own strategy for conversion by just getting the value as string
482
+ * via .toString(), and using util functions like isInteger, isSafeNumber, getUnsafeNumberReason,
483
+ * and toSafeNumberOrThrow to convert it to a numeric value.
484
+ */
485
+ valueOf() {
486
+ const unsafeReason = getUnsafeNumberReason(this.value);
487
+ if (unsafeReason === void 0 || unsafeReason === UnsafeNumberReason.truncate_float) {
488
+ return Number.parseFloat(this.value);
489
+ }
490
+ if (isInteger(this.value)) {
491
+ return BigInt(this.value);
492
+ }
493
+ throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${unsafeReason} and become ${Number.parseFloat(this.value)}`);
494
+ }
495
+ /**
496
+ * Get the value of the LosslessNumber as string.
497
+ */
498
+ toString() {
499
+ return this.value;
500
+ }
501
+ // Note: we do NOT implement a .toJSON() method, and you should not implement
502
+ // or use that, it cannot safely turn the numeric value in the string into
503
+ // stringified JSON since it has to be parsed into a number first.
504
+ };
505
+ function isLosslessNumber(value) {
506
+ return value !== null && typeof value === "object" && value[losslessNumberMarker] === true;
507
+ }
508
+ __name(isLosslessNumber, "isLosslessNumber");
509
+
510
+ // node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/numberParsers.js
511
+ function parseLosslessNumber(value) {
512
+ return new LosslessNumber(value);
513
+ }
514
+ __name(parseLosslessNumber, "parseLosslessNumber");
515
+
516
+ // node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/revive.js
517
+ function revive(json, reviver) {
518
+ return reviveValue({
519
+ "": json
520
+ }, "", json, reviver);
521
+ }
522
+ __name(revive, "revive");
523
+ function reviveValue(context, key, value, reviver) {
524
+ if (Array.isArray(value)) {
525
+ return reviver.call(context, key, reviveArray(value, reviver));
526
+ }
527
+ if (value && typeof value === "object" && !isLosslessNumber(value)) {
528
+ return reviver.call(context, key, reviveObject(value, reviver));
529
+ }
530
+ return reviver.call(context, key, value);
531
+ }
532
+ __name(reviveValue, "reviveValue");
533
+ function reviveObject(object, reviver) {
534
+ for (const key of Object.keys(object)) {
535
+ const value = reviveValue(object, key, object[key], reviver);
536
+ if (value !== void 0) {
537
+ object[key] = value;
538
+ } else {
539
+ delete object[key];
540
+ }
541
+ }
542
+ return object;
543
+ }
544
+ __name(reviveObject, "reviveObject");
545
+ function reviveArray(array2, reviver) {
546
+ for (let i = 0; i < array2.length; i++) {
547
+ const value = reviveValue(array2, String(i), array2[i], reviver);
548
+ if (value === void 0) {
549
+ delete array2[i];
550
+ } else {
551
+ array2[i] = value;
552
+ }
553
+ }
554
+ return array2;
555
+ }
556
+ __name(reviveArray, "reviveArray");
557
+
558
+ // node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/parse.js
559
+ function parse(text2, reviver, options) {
560
+ const optionsObj = typeof options === "function" ? {
561
+ parseNumber: options
562
+ } : options;
563
+ const parseNumber = optionsObj?.parseNumber ?? parseLosslessNumber;
564
+ const onDuplicateKey = optionsObj?.onDuplicateKey ?? throwDuplicateKey;
565
+ let i = 0;
566
+ const value = parseValue();
567
+ expectValue(value);
568
+ expectEndOfInput();
569
+ return reviver ? revive(value, reviver) : value;
570
+ function parseObject() {
571
+ if (text2.charCodeAt(i) === codeOpeningBrace) {
572
+ i++;
573
+ skipWhitespace();
574
+ const object = {};
575
+ let initial = true;
576
+ while (i < text2.length && text2.charCodeAt(i) !== codeClosingBrace) {
577
+ if (!initial) {
578
+ eatComma();
579
+ skipWhitespace();
580
+ } else {
581
+ initial = false;
582
+ }
583
+ const start = i;
584
+ const key = parseString();
585
+ if (key === void 0) {
586
+ throwObjectKeyExpected();
587
+ return;
588
+ }
589
+ skipWhitespace();
590
+ eatColon();
591
+ const value2 = parseValue();
592
+ if (value2 === void 0) {
593
+ throwObjectValueExpected();
594
+ return;
595
+ }
596
+ if (Object.prototype.hasOwnProperty.call(object, key) && !isDeepEqual(value2, object[key])) {
597
+ const returnedValue = onDuplicateKey({
598
+ key,
599
+ position: start + 1,
600
+ oldValue: object[key],
601
+ newValue: value2
602
+ });
603
+ if (returnedValue !== void 0) {
604
+ setObjectKey(object, key, returnedValue);
605
+ }
606
+ } else {
607
+ setObjectKey(object, key, value2);
608
+ }
609
+ }
610
+ if (text2.charCodeAt(i) !== codeClosingBrace) {
611
+ throwObjectKeyOrEndExpected();
612
+ }
613
+ i++;
614
+ return object;
615
+ }
616
+ }
617
+ __name(parseObject, "parseObject");
618
+ function parseArray() {
619
+ if (text2.charCodeAt(i) === codeOpeningBracket) {
620
+ i++;
621
+ skipWhitespace();
622
+ const array2 = [];
623
+ let initial = true;
624
+ while (i < text2.length && text2.charCodeAt(i) !== codeClosingBracket) {
625
+ if (!initial) {
626
+ eatComma();
627
+ } else {
628
+ initial = false;
629
+ }
630
+ const value2 = parseValue();
631
+ expectArrayItem(value2);
632
+ array2.push(value2);
633
+ }
634
+ if (text2.charCodeAt(i) !== codeClosingBracket) {
635
+ throwArrayItemOrEndExpected();
636
+ }
637
+ i++;
638
+ return array2;
639
+ }
640
+ }
641
+ __name(parseArray, "parseArray");
642
+ function parseValue() {
643
+ skipWhitespace();
644
+ const value2 = parseString() ?? parseNumeric() ?? parseObject() ?? parseArray() ?? parseKeyword("true", true) ?? parseKeyword("false", false) ?? parseKeyword("null", null);
645
+ skipWhitespace();
646
+ return value2;
647
+ }
648
+ __name(parseValue, "parseValue");
649
+ function parseKeyword(name, value2) {
650
+ if (text2.slice(i, i + name.length) === name) {
651
+ i += name.length;
652
+ return value2;
653
+ }
654
+ }
655
+ __name(parseKeyword, "parseKeyword");
656
+ function skipWhitespace() {
657
+ while (isWhitespace(text2.charCodeAt(i))) {
658
+ i++;
659
+ }
660
+ }
661
+ __name(skipWhitespace, "skipWhitespace");
662
+ function parseString() {
663
+ if (text2.charCodeAt(i) === codeDoubleQuote) {
664
+ i++;
665
+ let result = "";
666
+ while (i < text2.length && text2.charCodeAt(i) !== codeDoubleQuote) {
667
+ if (text2.charCodeAt(i) === codeBackslash) {
668
+ const char = text2[i + 1];
669
+ const escapeChar = escapeCharacters[char];
670
+ if (escapeChar !== void 0) {
671
+ result += escapeChar;
672
+ i++;
673
+ } else if (char === "u") {
674
+ if (isHex(text2.charCodeAt(i + 2)) && isHex(text2.charCodeAt(i + 3)) && isHex(text2.charCodeAt(i + 4)) && isHex(text2.charCodeAt(i + 5))) {
675
+ result += String.fromCharCode(Number.parseInt(text2.slice(i + 2, i + 6), 16));
676
+ i += 5;
677
+ } else {
678
+ throwInvalidUnicodeCharacter(i);
679
+ }
680
+ } else {
681
+ throwInvalidEscapeCharacter(i);
682
+ }
683
+ } else {
684
+ if (isValidStringCharacter(text2.charCodeAt(i))) {
685
+ result += text2[i];
686
+ } else {
687
+ throwInvalidCharacter(text2[i]);
688
+ }
689
+ }
690
+ i++;
691
+ }
692
+ expectEndOfString();
693
+ i++;
694
+ return result;
695
+ }
696
+ }
697
+ __name(parseString, "parseString");
698
+ function parseNumeric() {
699
+ const start = i;
700
+ if (text2.charCodeAt(i) === codeMinus) {
701
+ i++;
702
+ expectDigit(start);
703
+ }
704
+ if (text2.charCodeAt(i) === codeZero) {
705
+ i++;
706
+ } else if (isNonZeroDigit(text2.charCodeAt(i))) {
707
+ i++;
708
+ while (isDigit(text2.charCodeAt(i))) {
709
+ i++;
710
+ }
711
+ } else {
712
+ return void 0;
713
+ }
714
+ if (text2.charCodeAt(i) === codeDot) {
715
+ i++;
716
+ expectDigit(start);
717
+ while (isDigit(text2.charCodeAt(i))) {
718
+ i++;
719
+ }
720
+ }
721
+ if (text2.charCodeAt(i) === codeLowercaseE || text2.charCodeAt(i) === codeUppercaseE) {
722
+ i++;
723
+ if (text2.charCodeAt(i) === codeMinus || text2.charCodeAt(i) === codePlus) {
724
+ i++;
725
+ }
726
+ expectDigit(start);
727
+ while (isDigit(text2.charCodeAt(i))) {
728
+ i++;
729
+ }
730
+ }
731
+ if (i > start) {
732
+ return parseNumber(text2.slice(start, i));
733
+ }
734
+ }
735
+ __name(parseNumeric, "parseNumeric");
736
+ function eatComma() {
737
+ if (text2.charCodeAt(i) !== codeComma) {
738
+ throw new SyntaxError(`Comma ',' expected after value ${gotAt()}`);
739
+ }
740
+ i++;
741
+ }
742
+ __name(eatComma, "eatComma");
743
+ function eatColon() {
744
+ if (text2.charCodeAt(i) !== codeColon) {
745
+ throw new SyntaxError(`Colon ':' expected after property name ${gotAt()}`);
746
+ }
747
+ i++;
748
+ }
749
+ __name(eatColon, "eatColon");
750
+ function expectValue(value2) {
751
+ if (value2 === void 0) {
752
+ throw new SyntaxError(`JSON value expected ${gotAt()}`);
753
+ }
754
+ }
755
+ __name(expectValue, "expectValue");
756
+ function expectArrayItem(value2) {
757
+ if (value2 === void 0) {
758
+ throw new SyntaxError(`Array item expected ${gotAt()}`);
759
+ }
760
+ }
761
+ __name(expectArrayItem, "expectArrayItem");
762
+ function expectEndOfInput() {
763
+ if (i < text2.length) {
764
+ throw new SyntaxError(`Expected end of input ${gotAt()}`);
765
+ }
766
+ }
767
+ __name(expectEndOfInput, "expectEndOfInput");
768
+ function expectDigit(start) {
769
+ if (!isDigit(text2.charCodeAt(i))) {
770
+ const numSoFar = text2.slice(start, i);
771
+ throw new SyntaxError(`Invalid number '${numSoFar}', expecting a digit ${gotAt()}`);
772
+ }
773
+ }
774
+ __name(expectDigit, "expectDigit");
775
+ function expectEndOfString() {
776
+ if (text2.charCodeAt(i) !== codeDoubleQuote) {
777
+ throw new SyntaxError(`End of string '"' expected ${gotAt()}`);
778
+ }
779
+ }
780
+ __name(expectEndOfString, "expectEndOfString");
781
+ function throwObjectKeyExpected() {
782
+ throw new SyntaxError(`Quoted object key expected ${gotAt()}`);
783
+ }
784
+ __name(throwObjectKeyExpected, "throwObjectKeyExpected");
785
+ function throwDuplicateKey({
786
+ key,
787
+ position
788
+ }) {
789
+ throw new SyntaxError(`Duplicate key '${key}' encountered at position ${position}`);
790
+ }
791
+ __name(throwDuplicateKey, "throwDuplicateKey");
792
+ function throwObjectKeyOrEndExpected() {
793
+ throw new SyntaxError(`Quoted object key or end of object '}' expected ${gotAt()}`);
794
+ }
795
+ __name(throwObjectKeyOrEndExpected, "throwObjectKeyOrEndExpected");
796
+ function throwArrayItemOrEndExpected() {
797
+ throw new SyntaxError(`Array item or end of array ']' expected ${gotAt()}`);
798
+ }
799
+ __name(throwArrayItemOrEndExpected, "throwArrayItemOrEndExpected");
800
+ function throwInvalidCharacter(char) {
801
+ throw new SyntaxError(`Invalid character '${char}' ${pos()}`);
802
+ }
803
+ __name(throwInvalidCharacter, "throwInvalidCharacter");
804
+ function throwInvalidEscapeCharacter(start) {
805
+ const chars = text2.slice(start, start + 2);
806
+ throw new SyntaxError(`Invalid escape character '${chars}' ${pos()}`);
807
+ }
808
+ __name(throwInvalidEscapeCharacter, "throwInvalidEscapeCharacter");
809
+ function throwObjectValueExpected() {
810
+ throw new SyntaxError(`Object value expected after ':' ${pos()}`);
811
+ }
812
+ __name(throwObjectValueExpected, "throwObjectValueExpected");
813
+ function throwInvalidUnicodeCharacter(start) {
814
+ const chars = text2.slice(start, start + 6);
815
+ throw new SyntaxError(`Invalid unicode character '${chars}' ${pos()}`);
816
+ }
817
+ __name(throwInvalidUnicodeCharacter, "throwInvalidUnicodeCharacter");
818
+ function pos() {
819
+ return `at position ${i}`;
820
+ }
821
+ __name(pos, "pos");
822
+ function got() {
823
+ return i < text2.length ? `but got '${text2[i]}'` : "but reached end of input";
824
+ }
825
+ __name(got, "got");
826
+ function gotAt() {
827
+ return `${got()} ${pos()}`;
828
+ }
829
+ __name(gotAt, "gotAt");
830
+ }
831
+ __name(parse, "parse");
832
+ function setObjectKey(object, key, value) {
833
+ if (key === "__proto__") {
834
+ Object.defineProperty(object, key, {
835
+ value,
836
+ writable: true,
837
+ enumerable: true,
838
+ configurable: true
839
+ });
840
+ } else {
841
+ object[key] = value;
842
+ }
843
+ }
844
+ __name(setObjectKey, "setObjectKey");
845
+ function isWhitespace(code) {
846
+ return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn;
847
+ }
848
+ __name(isWhitespace, "isWhitespace");
849
+ function isHex(code) {
850
+ return code >= codeZero && code <= codeNine || code >= codeUppercaseA && code <= codeUppercaseF || code >= codeLowercaseA && code <= codeLowercaseF;
851
+ }
852
+ __name(isHex, "isHex");
853
+ function isDigit(code) {
854
+ return code >= codeZero && code <= codeNine;
855
+ }
856
+ __name(isDigit, "isDigit");
857
+ function isNonZeroDigit(code) {
858
+ return code >= codeOne && code <= codeNine;
859
+ }
860
+ __name(isNonZeroDigit, "isNonZeroDigit");
861
+ function isValidStringCharacter(code) {
862
+ return code >= 32 && code <= 1114111;
863
+ }
864
+ __name(isValidStringCharacter, "isValidStringCharacter");
865
+ function isDeepEqual(a, b) {
866
+ if (a === b) {
867
+ return true;
868
+ }
869
+ if (Array.isArray(a) && Array.isArray(b)) {
870
+ return a.length === b.length && a.every((item, index) => isDeepEqual(item, b[index]));
871
+ }
872
+ if (isObject2(a) && isObject2(b)) {
873
+ const keys = [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])];
874
+ return keys.every((key) => isDeepEqual(a[key], b[key]));
875
+ }
876
+ return false;
877
+ }
878
+ __name(isDeepEqual, "isDeepEqual");
879
+ function isObject2(value) {
880
+ return typeof value === "object" && value !== null;
881
+ }
882
+ __name(isObject2, "isObject");
883
+ var escapeCharacters = {
884
+ '"': '"',
885
+ "\\": "\\",
886
+ "/": "/",
887
+ b: "\b",
888
+ f: "\f",
889
+ n: "\n",
890
+ r: "\r",
891
+ t: " "
892
+ // note that \u is handled separately in parseString()
893
+ };
894
+ var codeBackslash = 92;
895
+ var codeOpeningBrace = 123;
896
+ var codeClosingBrace = 125;
897
+ var codeOpeningBracket = 91;
898
+ var codeClosingBracket = 93;
899
+ var codeSpace = 32;
900
+ var codeNewline = 10;
901
+ var codeTab = 9;
902
+ var codeReturn = 13;
903
+ var codeDoubleQuote = 34;
904
+ var codePlus = 43;
905
+ var codeMinus = 45;
906
+ var codeZero = 48;
907
+ var codeOne = 49;
908
+ var codeNine = 57;
909
+ var codeComma = 44;
910
+ var codeDot = 46;
911
+ var codeColon = 58;
912
+ var codeUppercaseA = 65;
913
+ var codeLowercaseA = 97;
914
+ var codeUppercaseE = 69;
915
+ var codeLowercaseE = 101;
916
+ var codeUppercaseF = 70;
917
+ var codeLowercaseF = 102;
918
+
919
+ // node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/stringify.js
920
+ function stringify(value, replacer, space, numberStringifiers) {
921
+ const resolvedSpace = resolveSpace(space);
922
+ const replacedValue = typeof replacer === "function" ? replacer.call({
923
+ "": value
924
+ }, "", value) : value;
925
+ return stringifyValue(replacedValue, "");
926
+ function stringifyValue(value2, indent) {
927
+ if (Array.isArray(numberStringifiers)) {
928
+ const stringifier = numberStringifiers.find((item) => item.test(value2));
929
+ if (stringifier) {
930
+ const str = stringifier.stringify(value2);
931
+ if (typeof str !== "string" || !isNumber(str)) {
932
+ throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${str})`);
933
+ }
934
+ return str;
935
+ }
936
+ }
937
+ if (typeof value2 === "boolean" || typeof value2 === "number" || typeof value2 === "string" || value2 === null || value2 instanceof Date || value2 instanceof Boolean || value2 instanceof Number || value2 instanceof String) {
938
+ return JSON.stringify(value2);
939
+ }
940
+ if (isLosslessNumber(value2)) {
941
+ return value2.toString();
942
+ }
943
+ if (typeof value2 === "bigint") {
944
+ return value2.toString();
945
+ }
946
+ if (Array.isArray(value2)) {
947
+ return stringifyArray(value2, indent);
948
+ }
949
+ if (value2 && typeof value2 === "object") {
950
+ return stringifyObject(value2, indent);
951
+ }
952
+ return void 0;
953
+ }
954
+ __name(stringifyValue, "stringifyValue");
955
+ function stringifyArray(array2, indent) {
956
+ if (array2.length === 0) {
957
+ return "[]";
958
+ }
959
+ const childIndent = resolvedSpace ? indent + resolvedSpace : void 0;
960
+ let str = resolvedSpace ? "[\n" : "[";
961
+ for (let i = 0; i < array2.length; i++) {
962
+ const item = typeof replacer === "function" ? replacer.call(array2, String(i), array2[i]) : array2[i];
963
+ if (resolvedSpace) {
964
+ str += childIndent;
965
+ }
966
+ if (typeof item !== "undefined" && typeof item !== "function") {
967
+ const serialized = stringifyValue(item, childIndent);
968
+ str += serialized === void 0 ? "null" : serialized;
969
+ } else {
970
+ str += "null";
971
+ }
972
+ if (i < array2.length - 1) {
973
+ str += resolvedSpace ? ",\n" : ",";
974
+ }
975
+ }
976
+ str += resolvedSpace ? `
977
+ ${indent}]` : "]";
978
+ return str;
979
+ }
980
+ __name(stringifyArray, "stringifyArray");
981
+ function stringifyObject(object, indent) {
982
+ if (typeof object.toJSON === "function") {
983
+ return stringifyValue(object.toJSON(), indent);
984
+ }
985
+ const keys = Array.isArray(replacer) ? [...new Set(replacer.map(String))] : Object.keys(object);
986
+ if (keys.length === 0) {
987
+ return "{}";
988
+ }
989
+ const childIndent = resolvedSpace ? indent + resolvedSpace : void 0;
990
+ let first = true;
991
+ let str = resolvedSpace ? "{\n" : "{";
992
+ for (const key of keys) {
993
+ const value2 = typeof replacer === "function" ? replacer.call(object, key, object[key]) : object[key];
994
+ if (includeProperty(key, value2)) {
995
+ const serialized = stringifyValue(value2, childIndent);
996
+ if (serialized === void 0) {
703
997
  continue;
704
998
  }
705
- if (clause.occur !== "must")
706
- queryError("query.unsupported-placement", clause.node.span, negatable.length ? `this list takes only field:value terms joined by AND, and -field:value for ${negatable.join(", ")}` : "this list takes only field:value terms joined by AND", context);
707
- add(clause.node);
999
+ if (first) {
1000
+ first = false;
1001
+ } else {
1002
+ str += resolvedSpace ? ",\n" : ",";
1003
+ }
1004
+ const keyStr = JSON.stringify(key);
1005
+ str += resolvedSpace ? `${childIndent + keyStr}: ` : `${keyStr}:`;
1006
+ str += serialized;
708
1007
  }
709
- return;
710
1008
  }
711
- const held = terms.get(node.field);
712
- if (held && !repeatable.includes(node.field))
713
- queryError("query.unsupported-placement", node.span, `${node.field} only once here`, context);
714
- terms.set(node.field, [...held ?? [], node]);
715
- }, "add");
716
- add(ast.root);
717
- return terms;
718
- }, "nativeTermLists");
719
- var queryTerms = /* @__PURE__ */ __name((words, registry, command, ranged = []) => {
720
- const terms = /* @__PURE__ */ new Map();
721
- for (const [field, node] of nativeTerms(listQuery(typedQuery(words), registry, command), command)) {
722
- if (ranged.includes(field))
723
- continue;
724
- if (node.operator !== "term" && node.operator !== "phrase")
725
- queryError("query.unsupported-placement", node.span, `${field} takes one whole value here`, {
726
- command,
727
- guide: LIST_QUERY_GUIDE
1009
+ str += resolvedSpace ? `
1010
+ ${indent}}` : "}";
1011
+ return str;
1012
+ }
1013
+ __name(stringifyObject, "stringifyObject");
1014
+ function includeProperty(_key, value2) {
1015
+ return typeof value2 !== "undefined" && typeof value2 !== "function" && typeof value2 !== "symbol";
1016
+ }
1017
+ __name(includeProperty, "includeProperty");
1018
+ }
1019
+ __name(stringify, "stringify");
1020
+ var MAX_SPACE_LENGTH = 10;
1021
+ function resolveSpace(space) {
1022
+ if (typeof space === "number") {
1023
+ const count = Math.min(Math.trunc(space), MAX_SPACE_LENGTH);
1024
+ return count >= 1 ? " ".repeat(count) : void 0;
1025
+ }
1026
+ if (typeof space === "string" && space !== "") {
1027
+ return space.slice(0, MAX_SPACE_LENGTH);
1028
+ }
1029
+ return void 0;
1030
+ }
1031
+ __name(resolveSpace, "resolveSpace");
1032
+
1033
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/cli/bot/api-input.js
1034
+ var RENAMED = { timeout: "poll-timeout" };
1035
+ var apiFlagOf = /* @__PURE__ */ __name((name) => RENAMED[name] ?? name.replace(/_/g, "-").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), "apiFlagOf");
1036
+ var apiOptionKey = /* @__PURE__ */ __name((name) => apiFlagOf(name).replace(/-([a-z0-9])/g, (_, letter) => letter.toUpperCase()), "apiOptionKey");
1037
+ var DIGITS = /^-?\d+$/;
1038
+ var coerce = /* @__PURE__ */ __name((raw) => {
1039
+ if (DIGITS.test(raw))
1040
+ return new LosslessNumber(raw);
1041
+ if (raw === "true" || raw === "false")
1042
+ return raw === "true";
1043
+ return raw;
1044
+ }, "coerce");
1045
+ var checkApiParameter = /* @__PURE__ */ __name((name, node, raw, schemas) => {
1046
+ switch (node.type) {
1047
+ case "ref": {
1048
+ const schema2 = schemas[identifier(node.ref)];
1049
+ return schema2 && !safeParse(schema2, coerce(raw)).success ? `--${apiFlagOf(name)} is not a valid ${node.ref}` : void 0;
1050
+ }
1051
+ case "union":
1052
+ return node.of.some((member) => checkApiParameter(name, member, raw, schemas) === void 0) ? void 0 : `--${apiFlagOf(name)} does not match any allowed type`;
1053
+ case "integer":
1054
+ if (!DIGITS.test(raw))
1055
+ return `--${apiFlagOf(name)} takes an integer`;
1056
+ if (node.minimum !== void 0 && BigInt(raw) < BigInt(node.minimum))
1057
+ return `--${apiFlagOf(name)} is at least ${node.minimum}`;
1058
+ if (node.maximum !== void 0 && BigInt(raw) > BigInt(node.maximum))
1059
+ return `--${apiFlagOf(name)} is at most ${node.maximum}`;
1060
+ return void 0;
1061
+ case "boolean":
1062
+ return raw === "true" || raw === "false" ? void 0 : `--${apiFlagOf(name)} takes true or false`;
1063
+ case "string":
1064
+ return node.enum && !node.enum.includes(raw) ? `--${apiFlagOf(name)} is one of ${node.enum.join(", ")}` : void 0;
1065
+ case "array":
1066
+ return raw.split(",").map((item) => checkApiParameter(name, node.items, item.trim(), schemas)).find((problem) => problem !== void 0);
1067
+ default:
1068
+ return void 0;
1069
+ }
1070
+ }, "checkApiParameter");
1071
+ var JSON_BODY = /[/+]json\s*(;|$)/i;
1072
+ var FORM_BODY = /^(multipart\/form-data|application\/x-www-form-urlencoded)\s*(;|$)/i;
1073
+ var sendsBytes = /* @__PURE__ */ __name((operation) => {
1074
+ const type = operation.request?.contentType;
1075
+ return type !== void 0 && !JSON_BODY.test(type) && !FORM_BODY.test(type);
1076
+ }, "sendsBytes");
1077
+ var readApiBytes = /* @__PURE__ */ __name((path2, read = (from) => new Uint8Array(readFileSync(from))) => read(path2 === "-" ? 0 : path2), "readApiBytes");
1078
+ var readApiBody = /* @__PURE__ */ __name((options, read = (path2) => readFileSync(path2, "utf8")) => {
1079
+ if (options.body !== void 0 && options.bodyFile !== void 0) {
1080
+ throw new CliError("validation_error", "--body and --body-file both given; pick one");
1081
+ }
1082
+ if (options.bodyFile !== void 0)
1083
+ return read(options.bodyFile === "-" ? 0 : options.bodyFile);
1084
+ if (options.body === "-")
1085
+ return read(0);
1086
+ return options.body;
1087
+ }, "readApiBody");
1088
+ var checkApiBody = /* @__PURE__ */ __name((operation, text2, schemas) => {
1089
+ if (text2 === void 0 || text2.trim() === "") {
1090
+ if (operation.request?.required) {
1091
+ throw new CliError("validation_error", `${operation.command} needs a JSON body: --body '<json>', --body -, or --body-file`);
1092
+ }
1093
+ return void 0;
1094
+ }
1095
+ let value;
1096
+ try {
1097
+ value = parse(text2);
1098
+ } catch {
1099
+ throw new CliError("validation_error", "the body is not valid JSON");
1100
+ }
1101
+ const schema2 = operation.request?.schema ? schemas[operation.request.schema] : void 0;
1102
+ if (schema2) {
1103
+ const result = safeParse(schema2, value);
1104
+ if (!result.success) {
1105
+ const where = result.issues.map((issue) => `${getDotPath(issue) ?? "(body)"} expects ${issue.expected ?? issue.kind}`);
1106
+ throw new CliError("validation_error", `the body does not match ${operation.request?.schema}: ${where.join("; ")}`);
1107
+ }
1108
+ }
1109
+ return text2;
1110
+ }, "checkApiBody");
1111
+ var parseApiJson = /* @__PURE__ */ __name((text2) => {
1112
+ try {
1113
+ return parse(text2);
1114
+ } catch {
1115
+ throw new CliError("validation_error", "the body is not valid JSON");
1116
+ }
1117
+ }, "parseApiJson");
1118
+ var finite = /* @__PURE__ */ __name((key, value) => {
1119
+ if (typeof value === "number" && !Number.isFinite(value))
1120
+ throw new CliError("validation_error", `${key === "" ? "the body" : key} is ${value}, which a request cannot carry; nothing was sent`, { sent: false });
1121
+ return value;
1122
+ }, "finite");
1123
+ var apiJson = /* @__PURE__ */ __name((value) => stringify(value, finite) ?? "null", "apiJson");
1124
+ var apiPlainJson = /* @__PURE__ */ __name((value) => JSON.parse(stringify(value, (key, inner) => isLosslessNumber(inner) && !isSafeNumber(inner.value) ? inner.toString() : finite(key, inner)) ?? "null"), "apiPlainJson");
1125
+ var isVariables = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value) && !isLosslessNumber(value), "isVariables");
1126
+ var graphqlVariables = /* @__PURE__ */ __name((operation, body, fields2) => {
1127
+ const { binding } = operation;
1128
+ if (binding.kind !== "graphql")
1129
+ throw new CliError("configuration_error", `${operation.command} is not a GraphQL operation`);
1130
+ const given = body?.trim() ? parseApiJson(body) : {};
1131
+ if (!isVariables(given))
1132
+ throw new CliError("validation_error", `${operation.command} takes its variables as one JSON object`, {
1133
+ sent: false
1134
+ });
1135
+ const variables = { ...given };
1136
+ for (const [name, raw] of Object.entries(fields2)) {
1137
+ const schema2 = operation.parameters.find((one) => one.in === "body" && one.name === name)?.schema;
1138
+ variables[name] = flagValue(operation, name, raw, schema2?.type);
1139
+ }
1140
+ const unknown2 = Object.keys(variables).filter((name) => !(name in binding.variables));
1141
+ if (unknown2.length > 0)
1142
+ throw new CliError("validation_error", `${operation.command} has no variable ${unknown2.join(", ")}`, {
1143
+ sent: false
1144
+ });
1145
+ const missing = Object.entries(binding.variables).filter(([name, type]) => type.endsWith("!") && variables[name] == null).map(([name]) => `--${apiFlagOf(name)}`);
1146
+ if (missing.length > 0)
1147
+ throw new CliError("validation_error", `${operation.command} needs ${missing.join(", ")}`, { sent: false });
1148
+ return variables;
1149
+ }, "graphqlVariables");
1150
+ var DECIMAL = /^-?\d+(\.\d+)?$/;
1151
+ var flagValue = /* @__PURE__ */ __name((operation, name, raw, type) => {
1152
+ const flag = `--${apiFlagOf(name)} of ${operation.command}`;
1153
+ if (type === "integer" || type === "number") {
1154
+ if (!(type === "integer" ? DIGITS : DECIMAL).test(raw.trim()))
1155
+ throw new CliError("validation_error", `${flag} takes ${type === "integer" ? "a whole number" : "a number"}`, {
1156
+ sent: false
728
1157
  });
729
- const enumerated = registry.fields.find(({ name }) => name === field)?.type === "enum";
730
- terms.set(field, enumerated ? node.value.toLowerCase() : node.value);
731
- }
732
- return terms;
733
- }, "queryTerms");
734
- var timeBounds = /* @__PURE__ */ __name((term, zone = timezoneOf(), now) => {
735
- if (!term)
736
- return {};
737
- const upper = term.operator === "range" ? term.upper ?? "*" : term.value;
738
- const range2 = dateRange(term.value, upper, term.operator === "range" ? term.lower_inclusive !== false : true, term.operator === "range" ? term.upper_inclusive !== false : true, zone, term.span, now);
739
- const until = range2.upper === void 0 ? void 0 : range2.upper - (range2.upper_inclusive ? 0 : 1);
740
- return {
741
- ...range2.lower === void 0 ? {} : { since: range2.lower },
742
- ...until === void 0 ? {} : { until },
743
- meta: {
744
- timezone: zone,
745
- window: {
746
- ...range2.lower === void 0 ? {} : { since: new Date(range2.lower).toISOString() },
747
- ...until === void 0 ? {} : { until: new Date(until).toISOString() }
748
- }
1158
+ return new LosslessNumber(raw.trim());
1159
+ }
1160
+ if (type === "boolean") {
1161
+ if (raw !== "true" && raw !== "false")
1162
+ throw new CliError("validation_error", `${flag} takes true or false`, { sent: false });
1163
+ return raw === "true";
1164
+ }
1165
+ if (type === "object" || type === "array" || type === "unknown")
1166
+ return parseApiJson(raw);
1167
+ if (type === "ref" && /^\s*[{["]/.test(raw))
1168
+ return parseApiJson(raw);
1169
+ return raw;
1170
+ }, "flagValue");
1171
+
1172
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/cli/service-api-manifest.js
1173
+ var manifestBaseUrl = /* @__PURE__ */ __name((manifest, given, variables = {}) => {
1174
+ const server = manifest.servers?.[0];
1175
+ if (given === void 0 && !server)
1176
+ throw new CliError("configuration_error", "the manifest names no server; give the api a baseUrl");
1177
+ const url = given ?? server.url.replace(/\{([^}]+)\}/g, (_, name) => {
1178
+ const value = variables[name];
1179
+ if (value !== void 0)
1180
+ return wholeHost(server, name) ? serverValue(name, value) : labelValue(name, value);
1181
+ const variable = server?.variables?.[name];
1182
+ if (variable?.default === void 0 || !variable.enum?.includes(variable.default))
1183
+ throw new CliError("configuration_error", `the server's {${name}} is the owner's own; sign in with session start --${name}, or give the api a baseUrl`);
1184
+ return variable.default;
1185
+ });
1186
+ if (!/^https:\/\//.test(url))
1187
+ throw new CliError("configuration_error", `the api's server ${url} is not https`);
1188
+ if (!URL.canParse(url) || new URL(url).username || new URL(url).password)
1189
+ throw new CliError("configuration_error", `the api's server ${url} is not a URL without a user name`);
1190
+ return url;
1191
+ }, "manifestBaseUrl");
1192
+ var siteValue = /* @__PURE__ */ __name((raw) => {
1193
+ const text2 = raw.trim().replace(/^https:\/\//i, "").replace(/\/+$/, "");
1194
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(text2))
1195
+ throw new CliError("validation_error", `--site takes an https address or a host, not ${JSON.stringify(raw)}`);
1196
+ const [host = "", ...path2] = serverValue("site", text2, "validation_error").split("/");
1197
+ const site = [host.toLowerCase(), ...path2].join("/");
1198
+ const url = URL.canParse(`https://${site}`) ? new URL(`https://${site}`) : void 0;
1199
+ if (!url || url.host !== site.split("/")[0] || url.pathname.replace(/\/$/, "") !== site.slice(site.split("/")[0]?.length))
1200
+ throw new CliError("validation_error", `--site ${JSON.stringify(raw)} is not a plain https address`);
1201
+ return site;
1202
+ }, "siteValue");
1203
+ var wholeHost = /* @__PURE__ */ __name((server, name) => server.url === `https://{${name}}` || server.url.startsWith(`https://{${name}}/`), "wholeHost");
1204
+ var labelValue = /* @__PURE__ */ __name((name, value) => {
1205
+ if (!/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(value))
1206
+ throw new CliError("configuration_error", `{${name}} ${JSON.stringify(value)} is not one name without dots`);
1207
+ return value;
1208
+ }, "labelValue");
1209
+ var serverValue = /* @__PURE__ */ __name((name, value, code = "configuration_error") => {
1210
+ if (!/^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:\d+)?(\/[A-Za-z0-9._~%-]+)*$/.test(value))
1211
+ throw new CliError(code, `{${name}} ${JSON.stringify(value)} is not a host, with a port or a path if any`);
1212
+ return value;
1213
+ }, "serverValue");
1214
+ var isBasic = /* @__PURE__ */ __name((scheme) => scheme.type === "http" && /^basic$/i.test(scheme.scheme ?? ""), "isBasic");
1215
+ var BASIC = {
1216
+ in: "header",
1217
+ name: "authorization",
1218
+ value: /* @__PURE__ */ __name((token) => {
1219
+ if (!token.includes(":"))
1220
+ throw new CliError("authentication_error", "this service signs in with a user name and a password: run session start --login <name>");
1221
+ return `Basic ${Buffer.from(token).toString("base64")}`;
1222
+ }, "value")
1223
+ };
1224
+ var authOf = /* @__PURE__ */ __name((manifest, operation) => {
1225
+ const requirements = signInRequirements(operation, manifest.security);
1226
+ if (!requirements)
1227
+ return void 0;
1228
+ const names = requirements.flatMap((one) => Object.keys(one));
1229
+ const sendable = names.flatMap((name) => {
1230
+ const scheme = manifest.securitySchemes?.[name];
1231
+ if (!scheme)
1232
+ return [];
1233
+ const basic = isBasic(scheme);
1234
+ const place = basic ? BASIC : signInPlace(scheme);
1235
+ return place ? [{ place, basic }] : [];
1236
+ });
1237
+ const auth = (sendable.find((one) => one.place.in === "header" && !one.basic) ?? sendable.find((one) => !one.basic) ?? sendable[0])?.place;
1238
+ if (auth)
1239
+ return auth;
1240
+ throw new CliError("configuration_error", `${operation.command} signs in by ${names.join(" or ")}, which the api cannot send`);
1241
+ }, "authOf");
1242
+ var signRequest = /* @__PURE__ */ __name(async (manifest, operation, request, token) => {
1243
+ if (!token)
1244
+ return;
1245
+ const auth = authOf(manifest, operation);
1246
+ if (!auth)
1247
+ return;
1248
+ const value = auth.value(await token());
1249
+ if (auth.in === "query")
1250
+ request.url.searchParams.set(auth.name, value);
1251
+ else
1252
+ request.headers.set(auth.name, value);
1253
+ if (auth.in === "query" || auth.name !== "authorization")
1254
+ request.redirect = "manual";
1255
+ }, "signRequest");
1256
+ var underBase = /* @__PURE__ */ __name((url, baseUrl) => {
1257
+ const base = new URL(baseUrl);
1258
+ const prefix = base.pathname.endsWith("/") ? base.pathname : `${base.pathname}/`;
1259
+ return url.origin === base.origin && (url.pathname === base.pathname || url.pathname.startsWith(prefix));
1260
+ }, "underBase");
1261
+ var answerAt = /* @__PURE__ */ __name((value, path2) => path2 === "" ? value : path2.split(".").reduce((inner, key) => inner && typeof inner === "object" ? inner[key] : void 0, value), "answerAt");
1262
+ var numberOf = /* @__PURE__ */ __name((value) => {
1263
+ const number3 = typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number(String(value));
1264
+ return Number.isFinite(number3) ? number3 : void 0;
1265
+ }, "numberOf");
1266
+ var parameterValue = /* @__PURE__ */ __name((input, parameter) => parameter.in === "query" ? input.query[parameter.name] : input.fields[parameter.name] ?? (input.body === void 0 ? void 0 : parseApiJson(input.body)?.[parameter.name]), "parameterValue");
1267
+ var withValue = /* @__PURE__ */ __name((input, parameter, value) => {
1268
+ if (parameter.in === "query")
1269
+ return { ...input, query: { ...input.query, [parameter.name]: String(value) } };
1270
+ const body = input.body === void 0 ? {} : parseApiJson(input.body);
1271
+ const { [parameter.name]: _, ...fields2 } = input.fields;
1272
+ return { ...input, fields: fields2, body: apiJson({ ...body, [parameter.name]: value }) };
1273
+ }, "withValue");
1274
+ var nextPage = /* @__PURE__ */ __name((pagination, input, answer, headers) => {
1275
+ const listed2 = pagination.items === void 0 ? [answer] : answerAt(answer, pagination.items);
1276
+ const items = Array.isArray(listed2) ? listed2 : [];
1277
+ switch (pagination.style) {
1278
+ case "cursor": {
1279
+ const cursor = answerAt(answer, pagination.next);
1280
+ const more = pagination.hasMore === void 0 || answerAt(answer, pagination.hasMore) !== false;
1281
+ return more && typeof cursor === "string" && cursor !== "" ? { items, next: { input: withValue(input, pagination.cursor, cursor) } } : { items };
749
1282
  }
750
- };
751
- }, "timeBounds");
752
- var searchText = /* @__PURE__ */ __name((term) => term === void 0 ? void 0 : term.value.replace(/^\*+|\*+$/g, ""), "searchText");
753
- var nativeField = /* @__PURE__ */ __name((field) => ({ ...field, native: true }), "nativeField");
754
- var termField = /* @__PURE__ */ __name((name, type, example, more = {}) => nativeField({
755
- name,
756
- type,
757
- operators: OPERATORS_BY_TYPE[type].filter((operator) => operator === "term" || operator === "phrase"),
758
- example,
759
- ...more
760
- }), "termField");
761
- var queryHelp = /* @__PURE__ */ __name((registry) => `
762
- ${fieldsHelp(registry, LIST_QUERY_GUIDE)}`, "queryHelp");
1283
+ case "offset":
1284
+ case "page": {
1285
+ const parameter = pagination.style === "offset" ? pagination.offset : pagination.page;
1286
+ const total = pagination.total === void 0 ? void 0 : numberOf(answerAt(answer, pagination.total));
1287
+ const current = numberOf(parameterValue(input, parameter)) ?? (pagination.style === "offset" ? 0 : pagination.start ?? 1);
1288
+ const next = pagination.style === "offset" ? current + items.length : current + 1;
1289
+ const pages = pagination.style === "page" && pagination.pagesHeader !== void 0 ? numberOf(headers?.get(pagination.pagesHeader) ?? void 0) : void 0;
1290
+ const last = items.length === 0 || total !== void 0 && pagination.style === "offset" && next >= total || pages !== void 0 && current >= pages;
1291
+ return last ? { items } : { items, next: { input: withValue(input, parameter, next) } };
1292
+ }
1293
+ case "link": {
1294
+ const url = answerAt(answer, pagination.next);
1295
+ return typeof url === "string" && url !== "" ? { items, next: { url } } : { items };
1296
+ }
1297
+ }
1298
+ }, "nextPage");
763
1299
 
764
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/guard.js
1300
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/guard.js
765
1301
  import { randomUUID } from "node:crypto";
766
1302
 
767
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/flood.js
768
- import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
1303
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/flood.js
1304
+ import { mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
769
1305
  import { dirname, join } from "node:path";
770
1306
  var MOST_DEADLINES = 50;
771
1307
  var LIMITED_HOLD_MS = 60 * 60 * 1e3;
@@ -779,8 +1315,8 @@ var FloodMemory = class {
779
1315
  }
780
1316
  path;
781
1317
  now;
782
- constructor(path, now = Date.now) {
783
- this.path = path;
1318
+ constructor(path2, now = Date.now) {
1319
+ this.path = path2;
784
1320
  this.now = now;
785
1321
  }
786
1322
  /** What is still in force; anything expired is left out. */
@@ -788,7 +1324,7 @@ var FloodMemory = class {
788
1324
  const now = this.now();
789
1325
  let raw;
790
1326
  try {
791
- raw = JSON.parse(readFileSync(this.path, "utf8"));
1327
+ raw = JSON.parse(readFileSync2(this.path, "utf8"));
792
1328
  } catch {
793
1329
  return { deadlines: [] };
794
1330
  }
@@ -848,19 +1384,19 @@ var FloodMemory = class {
848
1384
  }
849
1385
  };
850
1386
 
851
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/journal.js
852
- import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as readFileSync2 } from "node:fs";
1387
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/journal.js
1388
+ import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as readFileSync3 } from "node:fs";
853
1389
  import { dirname as dirname3, join as join2 } from "node:path";
854
1390
 
855
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/file-lock.js
1391
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/file-lock.js
856
1392
  import { closeSync, mkdirSync as mkdirSync2, openSync, statSync, unlinkSync } from "node:fs";
857
1393
  import { dirname as dirname2 } from "node:path";
858
1394
  var LOCK_WAIT_MS = 5e3;
859
1395
  var LOCK_STALE_MS = 3e4;
860
1396
  var RETRY_MS = 20;
861
1397
  var pause = new Int32Array(new SharedArrayBuffer(4));
862
- var withFileLock = /* @__PURE__ */ __name((path, what, body, waitMs = LOCK_WAIT_MS) => {
863
- const lock = lockFor(path);
1398
+ var withFileLock = /* @__PURE__ */ __name((path2, what, body, waitMs = LOCK_WAIT_MS) => {
1399
+ const lock = lockFor(path2);
864
1400
  const deadline = Date.now() + waitMs;
865
1401
  while (!taken(lock)) {
866
1402
  if (Date.now() >= deadline)
@@ -869,8 +1405,8 @@ var withFileLock = /* @__PURE__ */ __name((path, what, body, waitMs = LOCK_WAIT_
869
1405
  }
870
1406
  return holding(lock, body);
871
1407
  }, "withFileLock");
872
- var withFileLockAsync = /* @__PURE__ */ __name(async (path, what, body, waitMs = LOCK_WAIT_MS, sleep = realSleep) => {
873
- const lock = lockFor(path);
1408
+ var withFileLockAsync = /* @__PURE__ */ __name(async (path2, what, body, waitMs = LOCK_WAIT_MS, sleep = realSleep) => {
1409
+ const lock = lockFor(path2);
874
1410
  const deadline = Date.now() + waitMs;
875
1411
  while (!taken(lock)) {
876
1412
  if (Date.now() >= deadline)
@@ -879,9 +1415,9 @@ var withFileLockAsync = /* @__PURE__ */ __name(async (path, what, body, waitMs =
879
1415
  }
880
1416
  return holding(lock, body);
881
1417
  }, "withFileLockAsync");
882
- var lockFor = /* @__PURE__ */ __name((path) => {
883
- mkdirSync2(dirname2(path), { recursive: true, mode: 448 });
884
- return `${path}.lock`;
1418
+ var lockFor = /* @__PURE__ */ __name((path2) => {
1419
+ mkdirSync2(dirname2(path2), { recursive: true, mode: 448 });
1420
+ return `${path2}.lock`;
885
1421
  }, "lockFor");
886
1422
  var taken = /* @__PURE__ */ __name((lock) => {
887
1423
  for (; ; ) {
@@ -919,7 +1455,7 @@ var lockTime = /* @__PURE__ */ __name((lock) => {
919
1455
  }
920
1456
  }, "lockTime");
921
1457
 
922
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/journal.js
1458
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/journal.js
923
1459
  var sendsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "sends", `${profile}.jsonl`), "sendsPathFor");
924
1460
  var SendJournal = class {
925
1461
  static {
@@ -927,8 +1463,8 @@ var SendJournal = class {
927
1463
  }
928
1464
  path;
929
1465
  resource;
930
- constructor(path, resource = { service: "unknown", version: "unknown" }) {
931
- this.path = path;
1466
+ constructor(path2, resource = { service: "unknown", version: "unknown" }) {
1467
+ this.path = path2;
932
1468
  this.resource = resource;
933
1469
  }
934
1470
  /**
@@ -943,12 +1479,12 @@ var SendJournal = class {
943
1479
  return withFileLockAsync(this.path, "the send journal", body);
944
1480
  }
945
1481
  append(entry) {
946
- const { at, ...attributes } = entry;
1482
+ const { at: at2, ...attributes } = entry;
947
1483
  const { runId, command, traceId } = currentRun();
948
- const record = logRecordOf({
1484
+ const record2 = logRecordOf({
949
1485
  severity: entry.outcome === "sent" || entry.outcome === "reserved" ? "info" : "warn",
950
1486
  event: logAttributes({ event: "send.recorded", ...attributes }),
951
- time: at,
1487
+ time: at2,
952
1488
  runId,
953
1489
  ...traceId === void 0 ? {} : { traceId },
954
1490
  command,
@@ -956,7 +1492,7 @@ var SendJournal = class {
956
1492
  allow: LOG_ATTRIBUTES
957
1493
  });
958
1494
  mkdirSync3(dirname3(this.path), { recursive: true, mode: 448 });
959
- appendFileSync(this.path, `${JSON.stringify(record)}
1495
+ appendFileSync(this.path, `${JSON.stringify(record2)}
960
1496
  `, { mode: 384 });
961
1497
  }
962
1498
  /**
@@ -972,7 +1508,7 @@ var SendJournal = class {
972
1508
  #lines() {
973
1509
  let text2;
974
1510
  try {
975
- text2 = readFileSync2(this.path, "utf8");
1511
+ text2 = readFileSync3(this.path, "utf8");
976
1512
  } catch {
977
1513
  return [];
978
1514
  }
@@ -996,8 +1532,8 @@ var withSendId = /* @__PURE__ */ __name((entry) => {
996
1532
  return cid === void 0 || rest.sendId !== void 0 ? rest : { ...rest, sendId: String(cid) };
997
1533
  }, "withSendId");
998
1534
 
999
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/recipients.js
1000
- import { existsSync, readFileSync as readFileSync3, rmSync } from "node:fs";
1535
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/recipients.js
1536
+ import { existsSync, readFileSync as readFileSync4, rmSync } from "node:fs";
1001
1537
  import { join as join3 } from "node:path";
1002
1538
  var recipientsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "profiles", `${profile}.recipients.json`), "recipientsPathFor");
1003
1539
  var RecipientList = class {
@@ -1008,8 +1544,8 @@ var RecipientList = class {
1008
1544
  command;
1009
1545
  lockWaitMs;
1010
1546
  /** `command` names the program in the hint that turns the list off. */
1011
- constructor(path, command, lockWaitMs) {
1012
- this.path = path;
1547
+ constructor(path2, command, lockWaitMs) {
1548
+ this.path = path2;
1013
1549
  this.command = command;
1014
1550
  this.lockWaitMs = lockWaitMs;
1015
1551
  }
@@ -1018,7 +1554,7 @@ var RecipientList = class {
1018
1554
  if (!existsSync(this.path))
1019
1555
  return void 0;
1020
1556
  try {
1021
- const parsed = JSON.parse(readFileSync3(this.path, "utf8"));
1557
+ const parsed = JSON.parse(readFileSync4(this.path, "utf8"));
1022
1558
  if (!Array.isArray(parsed.chats))
1023
1559
  throw new Error("no `chats` array");
1024
1560
  return parsed.chats;
@@ -1108,10 +1644,10 @@ var RecipientList = class {
1108
1644
  }
1109
1645
  };
1110
1646
 
1111
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/guard.js
1647
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/guard.js
1112
1648
  var HOUR_MS = 60 * 60 * 1e3;
1113
- var countsTowardLimit = /* @__PURE__ */ __name(({ kind = "message", action, notify }) => kind === "message" || kind === "forward" || kind === "edit" || kind === "delete" || kind === "pin" && notify === true || action === "create" || action === "members.add" || action === "requests.accept" || action === "join" || action === "contact-import", "countsTowardLimit");
1114
- var weightOf = /* @__PURE__ */ __name(({ kind = "message", action, count: count2, people }) => kind === "delete" || kind === "message" && action === void 0 ? Math.max(1, count2 ?? 1) : action === "create" || action === "members.add" || action === "requests.accept" || action === "contact-import" ? Math.max(1, people ?? count2 ?? 1) : 1, "weightOf");
1649
+ var countsTowardLimit = /* @__PURE__ */ __name(({ kind: kind2 = "message", action, notify }) => kind2 === "message" || kind2 === "forward" || kind2 === "edit" || kind2 === "delete" || kind2 === "pin" && notify === true || action === "create" || action === "members.add" || action === "requests.accept" || action === "join" || action === "contact-import", "countsTowardLimit");
1650
+ var weightOf = /* @__PURE__ */ __name(({ kind: kind2 = "message", action, count, people }) => kind2 === "delete" || kind2 === "message" && action === void 0 ? Math.max(1, count ?? 1) : action === "create" || action === "members.add" || action === "requests.accept" || action === "contact-import" ? Math.max(1, people ?? count ?? 1) : 1, "weightOf");
1115
1651
  var timeOf = /* @__PURE__ */ __name((entry) => {
1116
1652
  const scheduled = entry.scheduledFor === void 0 ? Number.NaN : Date.parse(entry.scheduledFor);
1117
1653
  return Number.isNaN(scheduled) ? Date.parse(entry.at) : scheduled;
@@ -1137,11 +1673,11 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
1137
1673
  throw new CliError("permission_error", `profile ${profile} holds its writes ${holdEnd(block)}: ${block.hint} \u2014 reads still work; do not retry: the owner checks the account with \`${command} ${profile} doctor --online\`, and lifts the hold with \`${command} ${profile} flood clear\` once it is over`, { sendBlock: block, standing: { state: block.state, hint: block.hint } });
1138
1674
  }, "refuseHeld");
1139
1675
  const permitted = /* @__PURE__ */ __name((request) => {
1140
- const { chatId, kind = "message", action, personIds } = request;
1676
+ const { chatId, kind: kind2 = "message", action, personIds } = request;
1141
1677
  refuseReadOnly(request);
1142
1678
  const levels = currentPermissions();
1143
1679
  if (levels !== void 0) {
1144
- const key = request.key ?? keyForWrite(kind, action);
1680
+ const key = request.key ?? keyForWrite(kind2, action);
1145
1681
  const { level, key: named2 } = levelFor(levels, key, permissionDefaults);
1146
1682
  if (stops(level, key))
1147
1683
  throw levelRefusal({ profile, command, key, level, named: named2, permissionSources }, permissionFix?.(request, key));
@@ -1161,14 +1697,14 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
1161
1697
  const withinLimit = /* @__PURE__ */ __name((request, entries) => {
1162
1698
  const { chatId, sendId } = request;
1163
1699
  const asked = { ...request, people: request.personIds?.length ?? request.count };
1164
- const count2 = weightOf(asked);
1165
- if (count2 > sendsPerHour) {
1166
- throw new CliError("rate_limited", `${count2} at once is more than the hourly limit of profile ${profile} (sendsPerHour ${sendsPerHour}) \u2014 do fewer at a time`);
1700
+ const count = weightOf(asked);
1701
+ if (count > sendsPerHour) {
1702
+ throw new CliError("rate_limited", `${count} at once is more than the hourly limit of profile ${profile} (sendsPerHour ${sendsPerHour}) \u2014 do fewer at a time`);
1167
1703
  }
1168
- const at = request.scheduledFor ? Date.parse(request.scheduledFor) : now().getTime();
1169
- if (Number.isNaN(at))
1704
+ const at2 = request.scheduledFor ? Date.parse(request.scheduledFor) : now().getTime();
1705
+ if (Number.isNaN(at2))
1170
1706
  throw new CliError("validation_error", `"${request.scheduledFor}" is not a time to send at \u2014 use ISO 8601`);
1171
- const counted = entries.filter(countsTowardLimit).filter((entry) => entry.outcome === "sent" || entry.outcome === "outcome_unknown" || entry.outcome === "reserved").filter((entry) => Math.abs(timeOf(entry) - at) < HOUR_MS);
1707
+ const counted = entries.filter(countsTowardLimit).filter((entry) => entry.outcome === "sent" || entry.outcome === "outcome_unknown" || entry.outcome === "reserved").filter((entry) => Math.abs(timeOf(entry) - at2) < HOUR_MS);
1172
1708
  const unsure = /* @__PURE__ */ __name((entry) => entry.outcome === "outcome_unknown", "unsure");
1173
1709
  const same = /* @__PURE__ */ __name((a, b) => a.sendId !== void 0 && a.sendId === b.sendId && a.chatId === b.chatId, "same");
1174
1710
  const last = [...counted].reverse().find((entry) => same(entry, { chatId, sendId }));
@@ -1180,15 +1716,15 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
1180
1716
  }
1181
1717
  const recent = counted.filter((entry, index) => !(unsure(entry) && counted.slice(index + 1).some((later) => same(later, entry)))).map((entry) => ({ time: timeOf(entry), weight: weightOf(entry) })).sort((a, b) => a.time - b.time);
1182
1718
  const used = recent.reduce((sum, { weight }) => sum + weight, 0);
1183
- if (used + count2 > sendsPerHour) {
1719
+ if (used + count > sendsPerHour) {
1184
1720
  let freed = 0;
1185
1721
  const opening = recent.find(({ weight }) => {
1186
1722
  freed += weight;
1187
- return used - freed + count2 <= sendsPerHour;
1723
+ return used - freed + count <= sendsPerHour;
1188
1724
  });
1189
1725
  const nextMs = (opening?.time ?? 0) + HOUR_MS;
1190
1726
  const next = new Date(nextMs).toISOString();
1191
- throw new CliError("rate_limited", `profile ${profile} has sent ${used} messages in the hour around ${new Date(at).toISOString()}, and its limit is ${sendsPerHour} (sendsPerHour) \u2014 the next send is possible at ${next}`, { retry_after_ms: nextMs - now().getTime(), retry_at: next });
1727
+ throw new CliError("rate_limited", `profile ${profile} has sent ${used} messages in the hour around ${new Date(at2).toISOString()}, and its limit is ${sendsPerHour} (sendsPerHour) \u2014 the next send is possible at ${next}`, { retry_after_ms: nextMs - now().getTime(), retry_at: next });
1192
1728
  }
1193
1729
  return true;
1194
1730
  }, "withinLimit");
@@ -1213,16 +1749,16 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
1213
1749
  if (!checked(journal.entries()))
1214
1750
  return;
1215
1751
  const id2 = randomUUID();
1216
- const { chatId, kind, action, sendId, operationId, scheduledFor, notify } = request;
1752
+ const { chatId, kind: kind2, action, sendId, operationId, scheduledFor, notify } = request;
1217
1753
  journal.append({
1218
1754
  at: now().toISOString(),
1219
1755
  profile,
1220
1756
  chatId,
1221
1757
  outcome: "reserved",
1222
1758
  reservation: id2,
1223
- ...kind ? { kind } : {},
1759
+ ...kind2 ? { kind: kind2 } : {},
1224
1760
  ...action ? { action } : {},
1225
- ...asked.people === void 0 ? {} : kind === "delete" || kind === "message" || kind === void 0 ? { count: asked.people } : { people: asked.people },
1761
+ ...asked.people === void 0 ? {} : kind2 === "delete" || kind2 === "message" || kind2 === void 0 ? { count: asked.people } : { people: asked.people },
1226
1762
  ...sendId === void 0 ? {} : { sendId },
1227
1763
  ...operationId === void 0 ? {} : { operationId },
1228
1764
  ...scheduledFor ? { scheduledFor } : {},
@@ -1296,7 +1832,7 @@ var guardFor = /* @__PURE__ */ __name((app, settings, warn, env = process.env, a
1296
1832
  }), "guardFor");
1297
1833
  var journalFailure = /* @__PURE__ */ __name((error) => error?.code ?? (error instanceof Error ? error.name : "error"), "journalFailure");
1298
1834
 
1299
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/keyed-guard.js
1835
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/keyed-guard.js
1300
1836
  var keyedGuard = /* @__PURE__ */ __name((build, ask, levelOf, extra) => {
1301
1837
  let question;
1302
1838
  let answered = false;
@@ -1339,32 +1875,32 @@ var keyedGuard = /* @__PURE__ */ __name((build, ask, levelOf, extra) => {
1339
1875
  };
1340
1876
  }, "keyedGuard");
1341
1877
 
1342
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/send-id.js
1878
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/send-id.js
1343
1879
  import { randomBytes } from "node:crypto";
1344
1880
  var newSendId = /* @__PURE__ */ __name(() => randomBytes(8).readBigInt64BE().toString(), "newSendId");
1345
1881
  var newOperationId = newSendId;
1346
1882
 
1347
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/foreign-contacts.js
1348
- import { readFileSync as readFileSync4 } from "node:fs";
1883
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/foreign-contacts.js
1884
+ import { readFileSync as readFileSync5 } from "node:fs";
1349
1885
  import { join as join4 } from "node:path";
1350
1886
  var DAILY_FOREIGN_CONTACTS = 100;
1351
1887
  var foreignContactsPathFor = /* @__PURE__ */ __name((app, account, env = process.env, user) => join4(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "crm", "foreign-contacts", `${[account.provider, account.account, ...user ? [user] : []].join("-").replace(/[^\w.-]+/gu, "_")}.json`), "foreignContactsPathFor");
1352
1888
  var shownIn = /* @__PURE__ */ __name((file, day) => {
1353
1889
  try {
1354
- const found = JSON.parse(readFileSync4(file, "utf8"));
1890
+ const found = JSON.parse(readFileSync5(file, "utf8"));
1355
1891
  return found.day === day && Array.isArray(found.seen) ? { day, seen: found.seen.map(String) } : { day, seen: [] };
1356
1892
  } catch {
1357
1893
  return { day, seen: [] };
1358
1894
  }
1359
1895
  }, "shownIn");
1360
- var stripped = /* @__PURE__ */ __name((record, fields) => {
1361
- const { phones, emails, email, phone, contactTypes: _types, ...rest } = record;
1896
+ var stripped = /* @__PURE__ */ __name((record2, fields2) => {
1897
+ const { phones, emails, email, phone, contactTypes: _types, ...rest } = record2;
1362
1898
  const own = new Set([...phones ?? [], ...emails ?? [], email, phone].filter((one) => !!one));
1363
- const holding2 = new Set(fields.filter((field) => field.holds).map((field) => field.code));
1899
+ const holding2 = new Set(fields2.filter((field) => field.holds).map((field) => field.code));
1364
1900
  const repeats = /* @__PURE__ */ __name((value) => (Array.isArray(value) ? value : [value]).some((one) => typeof one === "string" && own.has(one.trim())), "repeats");
1365
1901
  const metadata = rest.metadata;
1366
1902
  if (metadata)
1367
- rest.metadata = fields.length ? Object.fromEntries(Object.entries(metadata).filter(([code, one]) => !holding2.has(code) && !repeats(one.value))) : {};
1903
+ rest.metadata = fields2.length ? Object.fromEntries(Object.entries(metadata).filter(([code, one]) => !holding2.has(code) && !repeats(one.value))) : {};
1368
1904
  return rest;
1369
1905
  }, "stripped");
1370
1906
  var foreignContacts = /* @__PURE__ */ __name((source, file, options = {}) => {
@@ -1376,44 +1912,44 @@ var foreignContacts = /* @__PURE__ */ __name((source, file, options = {}) => {
1376
1912
  admin ??= source.isAdmin();
1377
1913
  return !await admin;
1378
1914
  }, "limited");
1379
- const own = /* @__PURE__ */ __name(async (kind, records) => {
1915
+ const own = /* @__PURE__ */ __name(async (kind2, records) => {
1380
1916
  const self = source.self ? String(await source.self()) : void 0;
1381
1917
  const mine = new Set(records.filter((one) => self && one.assignee === self).map((one) => one.externalId));
1382
1918
  const rest = records.filter((one) => !mine.has(one.externalId)).map((one) => one.externalId);
1383
- if (rest.length && source.ownClients && (kind === "person" || kind === "organization"))
1384
- for (const id2 of await source.ownClients(kind, rest))
1919
+ if (rest.length && source.ownClients && (kind2 === "person" || kind2 === "organization"))
1920
+ for (const id2 of await source.ownClients(kind2, rest))
1385
1921
  mine.add(id2);
1386
1922
  return mine;
1387
1923
  }, "own");
1388
1924
  return {
1389
- async strip(kind, records) {
1925
+ async strip(kind2, records) {
1390
1926
  if (!await limited() || records.length === 0)
1391
1927
  return records;
1392
- const mine = await own(kind, records);
1928
+ const mine = await own(kind2, records);
1393
1929
  if (records.every((one) => mine.has(one.externalId)))
1394
1930
  return records;
1395
- definitions[kind] ??= Promise.resolve(source.fields?.(kind)).then((found) => found ?? []);
1396
- const fields = await definitions[kind];
1397
- return records.map((one) => mine.has(one.externalId) ? one : stripped(one, fields));
1931
+ definitions[kind2] ??= Promise.resolve(source.fields?.(kind2)).then((found) => found ?? []);
1932
+ const fields2 = await definitions[kind2];
1933
+ return records.map((one) => mine.has(one.externalId) ? one : stripped(one, fields2));
1398
1934
  },
1399
- async own(kind, record) {
1400
- return !await limited() || (await own(kind, [record])).has(record.externalId);
1935
+ async own(kind2, record2) {
1936
+ return !await limited() || (await own(kind2, [record2])).has(record2.externalId);
1401
1937
  },
1402
- async spend(kind, record) {
1403
- if (!await limited() || (await own(kind, [record])).has(record.externalId))
1938
+ async spend(kind2, record2) {
1939
+ if (!await limited() || (await own(kind2, [record2])).has(record2.externalId))
1404
1940
  return;
1405
- const key = `${kind}:${record.externalId}`;
1941
+ const key = `${kind2}:${record2.externalId}`;
1406
1942
  if (!file)
1407
1943
  throw new Error("foreignContacts: spend needs the count file");
1408
- const path = await file();
1944
+ const path2 = await file();
1409
1945
  const day = new Date(options.now?.() ?? Date.now()).toISOString().slice(0, 10);
1410
- await withFileLockAsync(path, "the day's count of foreign contacts", () => {
1411
- const shown = shownIn(path, day);
1946
+ await withFileLockAsync(path2, "the day's count of foreign contacts", () => {
1947
+ const shown = shownIn(path2, day);
1412
1948
  if (shown.seen.includes(key))
1413
1949
  return;
1414
1950
  if (shown.seen.length >= DAILY_FOREIGN_CONTACTS)
1415
1951
  throw new CliError("permission_error", `${DAILY_FOREIGN_CONTACTS} records that are not yours (contacts, companies, or the files of deals, leads, contacts and companies) were read today, the most a day; your own records are not counted, and the CRM's administrator has no limit`, { reason: "crm.foreign-contacts-spent", limit: DAILY_FOREIGN_CONTACTS });
1416
- writeSecurely(path, JSON.stringify({ day, seen: [...shown.seen, key] }), 384);
1952
+ writeSecurely(path2, JSON.stringify({ day, seen: [...shown.seen, key] }), 384);
1417
1953
  }, options.lockWaitMs);
1418
1954
  }
1419
1955
  };
@@ -1424,7 +1960,7 @@ var refuseForeignClientReads = /* @__PURE__ */ __name(async (source, readsClient
1424
1960
  throw new CliError("permission_error", `${method} reads contacts or companies, which only the CRM's administrator reads through api call: your clients come with sync, and another one with people show or organizations show, ${DAILY_FOREIGN_CONTACTS} a day`, { reason: "crm.client-reads-admin-only", sent: false });
1425
1961
  }, "refuseForeignClientReads");
1426
1962
 
1427
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/writer.js
1963
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/writer.js
1428
1964
  var CRM_ASSIGN_OTHERS_KEY = "crm.assign-others";
1429
1965
  var CRM_WRITE_KEYS = [CRM_ASSIGN_OTHERS_KEY];
1430
1966
  var PLURALS = {
@@ -1440,16 +1976,16 @@ var VERB_OF = {
1440
1976
  close: "close",
1441
1977
  delete: "remove"
1442
1978
  };
1443
- var crmAlsoChecks = /* @__PURE__ */ __name((also) => (path) => {
1444
- const [noun, command] = path;
1445
- const kind = noun === void 0 ? void 0 : PLURALS[noun];
1979
+ var crmAlsoChecks = /* @__PURE__ */ __name((also) => (path2) => {
1980
+ const [noun, command] = path2;
1981
+ const kind2 = noun === void 0 ? void 0 : PLURALS[noun];
1446
1982
  const verb = command === void 0 ? void 0 : VERB_OF[command];
1447
- if (path.length !== 2 || kind === void 0 || verb === void 0)
1983
+ if (path2.length !== 2 || kind2 === void 0 || verb === void 0)
1448
1984
  return [];
1449
1985
  const close = { key: `${noun}.close`, when: "a won or lost stage" };
1450
1986
  const assign = { key: CRM_ASSIGN_OTHERS_KEY, when: "--owner other than the sign-in's user" };
1451
- const implied = kind === "person" || kind === "organization" ? verb === "create" || verb === "update" ? [assign] : [] : verb === "create" || verb === "update" ? [{ key: `${noun}.move`, when: "--stage" }, close, assign] : verb === "move" ? [close] : [];
1452
- return [...implied, ...also?.(kind, verb) ?? []];
1987
+ const implied = kind2 === "person" || kind2 === "organization" ? verb === "create" || verb === "update" ? [assign] : [] : verb === "create" || verb === "update" ? [{ key: `${noun}.move`, when: "--stage" }, close, assign] : verb === "move" ? [close] : [];
1988
+ return [...implied, ...also?.(kind2, verb) ?? []];
1453
1989
  }, "crmAlsoChecks");
1454
1990
  var CRM_WRITE_DEFAULTS = {
1455
1991
  "deals.delete": "ask",
@@ -1457,7 +1993,7 @@ var CRM_WRITE_DEFAULTS = {
1457
1993
  [CRM_ASSIGN_OTHERS_KEY]: "deny"
1458
1994
  };
1459
1995
 
1460
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/writes.js
1996
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/writes.js
1461
1997
  var moneyChecked = /* @__PURE__ */ __name((check, param) => {
1462
1998
  try {
1463
1999
  check();
@@ -1480,17 +2016,17 @@ var COMMAND = {
1480
2016
  close: "close",
1481
2017
  remove: "delete"
1482
2018
  };
1483
- var keyOf2 = /* @__PURE__ */ __name((kind, verb) => `${PLURAL[kind]}.${COMMAND[verb]}`, "keyOf");
2019
+ var keyOf2 = /* @__PURE__ */ __name((kind2, verb) => `${PLURAL[kind2]}.${COMMAND[verb]}`, "keyOf");
1484
2020
  var OPERATION_ID = /^[\x21-\x7e]{1,255}$/u;
1485
- var DECIMAL = /^\d{1,16}(\.\d{1,6})?$/u;
2021
+ var DECIMAL2 = /^\d{1,16}(\.\d{1,6})?$/u;
1486
2022
  var CURRENCY = /^[A-Z]{3}$/u;
1487
2023
  var DAY = /^\d{4}-\d{2}-\d{2}$/u;
1488
2024
  var FIELD_CODE = /^[A-Za-z][\w.-]{0,99}$/u;
1489
2025
  var invalid = /* @__PURE__ */ __name((message, param) => new CliError("validation_error", message, { reason: "deal.field", ...param ? { param } : {} }), "invalid");
1490
- var supported = /* @__PURE__ */ __name((writer, kind, verb) => {
2026
+ var supported = /* @__PURE__ */ __name((writer, kind2, verb) => {
1491
2027
  const { kinds, verbs } = writer.capabilities;
1492
- if (!kinds.includes(kind) || !verbs.includes(verb))
1493
- throw new CliError("validation_error", `this CRM does not take a ${COMMAND[verb]} of ${PLURAL[kind]}`, {
2028
+ if (!kinds.includes(kind2) || !verbs.includes(verb))
2029
+ throw new CliError("validation_error", `this CRM does not take a ${COMMAND[verb]} of ${PLURAL[kind2]}`, {
1494
2030
  reason: "crm.write-unsupported",
1495
2031
  sent: false
1496
2032
  });
@@ -1507,9 +2043,9 @@ var operationOf = /* @__PURE__ */ __name((context, given) => {
1507
2043
  });
1508
2044
  return given;
1509
2045
  }, "operationOf");
1510
- var copyOf = /* @__PURE__ */ __name(async (context, kind, reference) => {
1511
- if (!reference.startsWith(`${kind}:`))
1512
- throw new CliError("validation_error", `name the ${kind} as ${kind}:<id>, as a list shows it`, {
2046
+ var copyOf = /* @__PURE__ */ __name(async (context, kind2, reference) => {
2047
+ if (!reference.startsWith(`${kind2}:`))
2048
+ throw new CliError("validation_error", `name the ${kind2} as ${kind2}:<id>, as a list shows it`, {
1513
2049
  reason: "ref.malformed"
1514
2050
  });
1515
2051
  const found = await context.store.deals.get(reference);
@@ -1518,8 +2054,8 @@ var copyOf = /* @__PURE__ */ __name(async (context, kind, reference) => {
1518
2054
  throw new CliError("not_found", `${reference} is not a copy from this profile's CRM account`);
1519
2055
  return found;
1520
2056
  }, "copyOf");
1521
- var pipelineOf = /* @__PURE__ */ __name(async (context, kind, reference, param = "--pipeline", window = {}) => {
1522
- const scope = { ...window, ...kind ? { kind } : {}, account: context.account };
2057
+ var pipelineOf = /* @__PURE__ */ __name(async (context, kind2, reference, param = "--pipeline", window = {}) => {
2058
+ const scope = { ...window, ...kind2 ? { kind: kind2 } : {}, account: context.account };
1523
2059
  if (reference !== void 0) {
1524
2060
  const found = await context.store.deals.pipeline(reference, scope);
1525
2061
  if (found.externalId === null)
@@ -1529,7 +2065,7 @@ var pipelineOf = /* @__PURE__ */ __name(async (context, kind, reference, param =
1529
2065
  const all = await context.store.deals.pipelines(scope);
1530
2066
  if (all.length === 1)
1531
2067
  return context.store.deals.pipeline(all[0].ref, scope);
1532
- const what = kind ? `${kind} pipeline` : "pipeline";
2068
+ const what = kind2 ? `${kind2} pipeline` : "pipeline";
1533
2069
  throw new CliError("validation_error", all.length === 0 ? `no ${what} of this CRM is stored; run sync first` : `this CRM has ${all.length} ${what}s; name one${param.startsWith("--") ? ` with ${param}` : ""}: ` + all.map(({ name, ref }) => `${name} (${ref})`).join(", "), { reason: "crm.pipeline-required", param, allowed: all.map(({ ref }) => ref) });
1534
2070
  }, "pipelineOf");
1535
2071
  var stageOf = /* @__PURE__ */ __name((pipeline, given) => {
@@ -1547,58 +2083,58 @@ var validDay = /* @__PURE__ */ __name((text2) => {
1547
2083
  return DAY.test(text2) && !Number.isNaN(date.getTime()) && date.toISOString().startsWith(text2);
1548
2084
  }, "validDay");
1549
2085
  var fieldsOf = /* @__PURE__ */ __name((input, pipeline, currency) => {
1550
- const fields = {};
2086
+ const fields2 = {};
1551
2087
  if (input.title !== void 0) {
1552
2088
  if (!input.title.trim())
1553
2089
  throw invalid("a title is never empty", "--title");
1554
- fields.title = input.title.trim();
2090
+ fields2.title = input.title.trim();
1555
2091
  }
1556
2092
  if (pipeline && input.pipeline !== void 0)
1557
- fields.pipeline = pipeline.externalId;
2093
+ fields2.pipeline = pipeline.externalId;
1558
2094
  const stage = pipeline && input.stage !== void 0 ? stageOf(pipeline, input.stage) : void 0;
1559
2095
  if (stage)
1560
- fields.stage = stage.externalId;
2096
+ fields2.stage = stage.externalId;
1561
2097
  if (input.amount !== void 0 || input.currency !== void 0) {
1562
2098
  const code = (input.currency ?? currency ?? "").toUpperCase();
1563
2099
  if (input.amount === void 0)
1564
2100
  throw invalid("--currency goes with --amount", "--amount");
1565
- if (!DECIMAL.test(input.amount))
2101
+ if (!DECIMAL2.test(input.amount))
1566
2102
  throw invalid("--amount is a decimal such as 1500.50", "--amount");
1567
2103
  if (!CURRENCY.test(code))
1568
2104
  throw invalid("--amount needs --currency, an ISO 4217 code such as EUR", "--currency");
1569
2105
  moneyChecked(() => currencyOf(code), "--currency");
1570
2106
  moneyChecked(() => minorUnits(input.amount, code, "--amount"), "--amount");
1571
- fields.amount = input.amount;
1572
- fields.currency = code;
2107
+ fields2.amount = input.amount;
2108
+ fields2.currency = code;
1573
2109
  }
1574
2110
  if (input.closeDate !== void 0) {
1575
2111
  if (!validDay(input.closeDate))
1576
2112
  throw invalid("--close-date is a day, YYYY-MM-DD", "--close-date");
1577
- fields.closeDate = input.closeDate;
2113
+ fields2.closeDate = input.closeDate;
1578
2114
  }
1579
2115
  if (input.owner !== void 0) {
1580
2116
  if (!input.owner.trim())
1581
2117
  throw invalid("--owner is the CRM user's id", "--owner");
1582
- fields.owner = input.owner.trim();
2118
+ fields2.owner = input.owner.trim();
1583
2119
  }
1584
- return { fields, stage };
2120
+ return { fields: fields2, stage };
1585
2121
  }, "fieldsOf");
1586
2122
  var foldFieldName = /* @__PURE__ */ __name((name) => foldName(name.trim()).replace(/[\s_]+/gu, " "), "foldFieldName");
1587
2123
  var named = /* @__PURE__ */ __name(({ code, label }) => ({ code, label }), "named");
1588
- var unknownField = /* @__PURE__ */ __name((fields, name, param = "--field") => {
2124
+ var unknownField = /* @__PURE__ */ __name((fields2, name, param = "--field") => {
1589
2125
  const want = foldFieldName(name);
1590
- const close = fields.filter((field) => [field.code, field.label ?? ""].some((one) => {
2126
+ const close = fields2.filter((field) => [field.code, field.label ?? ""].some((one) => {
1591
2127
  const other = foldFieldName(one);
1592
2128
  return other !== "" && (other.includes(want) || want.includes(other));
1593
2129
  }));
1594
2130
  return new CliError("validation_error", `no custom field is named ${name}${close.length ? "; close ones are in candidates" : ""} \u2014 \`fields list\` lists them`, { reason: "field.unknown", param, candidates: close.map(named) });
1595
2131
  }, "unknownField");
1596
- var fieldNamed = /* @__PURE__ */ __name((fields, name, param = "--field") => {
2132
+ var fieldNamed = /* @__PURE__ */ __name((fields2, name, param = "--field") => {
1597
2133
  const want = foldFieldName(name);
1598
- const byCode = fields.find((field) => foldFieldName(field.code) === want);
2134
+ const byCode = fields2.find((field) => foldFieldName(field.code) === want);
1599
2135
  if (byCode)
1600
2136
  return byCode;
1601
- const labelled = fields.filter((field) => field.label !== null && foldFieldName(field.label) === want);
2137
+ const labelled = fields2.filter((field) => field.label !== null && foldFieldName(field.label) === want);
1602
2138
  if (labelled.length === 1)
1603
2139
  return labelled[0];
1604
2140
  if (labelled.length > 1)
@@ -1607,7 +2143,7 @@ var fieldNamed = /* @__PURE__ */ __name((fields, name, param = "--field") => {
1607
2143
  param,
1608
2144
  candidates: labelled.map(named)
1609
2145
  });
1610
- throw unknownField(fields, name, param);
2146
+ throw unknownField(fields2, name, param);
1611
2147
  }, "fieldNamed");
1612
2148
  var optionOf = /* @__PURE__ */ __name((field, value, param = "--field") => {
1613
2149
  if (!field.options)
@@ -1633,15 +2169,15 @@ var optionOf = /* @__PURE__ */ __name((field, value, param = "--field") => {
1633
2169
  return found.id;
1634
2170
  }, "optionOf");
1635
2171
  var fieldPairsOf = /* @__PURE__ */ __name((typed) => typed.map((one) => {
1636
- const at = one.indexOf("=");
1637
- if (at <= 0 || one.slice(0, at).trim() === "")
2172
+ const at2 = one.indexOf("=");
2173
+ if (at2 <= 0 || one.slice(0, at2).trim() === "")
1638
2174
  throw new CliError("validation_error", `--field takes <key>=<value>; got ${one}`, { param: "--field" });
1639
- return [one.slice(0, at), one.slice(at + 1)];
2175
+ return [one.slice(0, at2), one.slice(at2 + 1)];
1640
2176
  }), "fieldPairsOf");
1641
- var crmCustomValues = /* @__PURE__ */ __name((fields, pairs) => {
2177
+ var crmCustomValues = /* @__PURE__ */ __name((fields2, pairs) => {
1642
2178
  const values = /* @__PURE__ */ new Map();
1643
2179
  for (const [name, value] of pairs) {
1644
- const field = fields.length ? fieldNamed(fields, name) : null;
2180
+ const field = fields2.length ? fieldNamed(fields2, name) : null;
1645
2181
  const code = field?.code ?? name.trim();
1646
2182
  if (!field && !FIELD_CODE.test(code))
1647
2183
  throw invalid(`${name} is not a field code`, "--field");
@@ -1662,16 +2198,16 @@ var crmCustomValues = /* @__PURE__ */ __name((fields, pairs) => {
1662
2198
  return [code, all[0] ?? null];
1663
2199
  }));
1664
2200
  }, "crmCustomValues");
1665
- var customOf = /* @__PURE__ */ __name(async (context, kind, pairs) => pairs?.length ? crmCustomValues(await context.store.crm.fields(context.account, kind), pairs) : void 0, "customOf");
1666
- var keysOf = /* @__PURE__ */ __name((context, kind, verb, { stage, owner }) => {
2201
+ var customOf = /* @__PURE__ */ __name(async (context, kind2, pairs) => pairs?.length ? crmCustomValues(await context.store.crm.fields(context.account, kind2), pairs) : void 0, "customOf");
2202
+ var keysOf = /* @__PURE__ */ __name((context, kind2, verb, { stage, owner }) => {
1667
2203
  const extra = [];
1668
2204
  if (stage && verb !== "move")
1669
- extra.push(keyOf2(kind, "move"));
2205
+ extra.push(keyOf2(kind2, "move"));
1670
2206
  if (stage && stage.outcome !== "open")
1671
- extra.push(keyOf2(kind, "close"));
2207
+ extra.push(keyOf2(kind2, "close"));
1672
2208
  if (owner != null && owner !== context.writes.self)
1673
2209
  extra.push(CRM_ASSIGN_OTHERS_KEY);
1674
- return { key: keyOf2(kind, verb), extra: [...extra, ...context.writes.alsoChecks?.(kind, verb) ?? []] };
2210
+ return { key: keyOf2(kind2, verb), extra: [...extra, ...context.writes.alsoChecks?.(kind2, verb) ?? []] };
1675
2211
  }, "keysOf");
1676
2212
  var guardOf = /* @__PURE__ */ __name((context, extra) => {
1677
2213
  const settings = context.writes.settings();
@@ -1700,18 +2236,18 @@ var written = /* @__PURE__ */ __name(async (context, { key, extra }, operationId
1700
2236
  throw new CliError("outcome_unknown", context.writes.writer.capabilities.idempotent ? `${error.message} \u2014 repeat it with ${name} ${operationId}: the CRM answers a repeat from its record instead of doing it again` : `${error.message} \u2014 sync and look at the CRM before writing again: this CRM would do it a second time`, { ...error.details, operation_id: operationId });
1701
2237
  }
1702
2238
  }, "written");
1703
- var kept = /* @__PURE__ */ __name(async (context, kind, item, operationId) => {
1704
- const fail = /* @__PURE__ */ __name((why, details = {}) => new CliError("invalid_response", `the CRM wrote ${kind} ${item.externalId}, but the local store did not keep it (${why}); sync to store it \u2014 do not write it again`, { ...details, operation_id: operationId, external_id: item.externalId, sent: true }), "fail");
2239
+ var kept = /* @__PURE__ */ __name(async (context, kind2, item, operationId) => {
2240
+ const fail = /* @__PURE__ */ __name((why, details = {}) => new CliError("invalid_response", `the CRM wrote ${kind2} ${item.externalId}, but the local store did not keep it (${why}); sync to store it \u2014 do not write it again`, { ...details, operation_id: operationId, external_id: item.externalId, sent: true }), "fail");
1705
2241
  try {
1706
- let saved = await context.store.crm.saveItems(context.account, kind, [item]);
2242
+ let saved = await context.store.crm.saveItems(context.account, kind2, [item]);
1707
2243
  if (saved.skipped[0]?.reason === "crm.stage-unknown" && context.source) {
1708
- await context.store.crm.savePipelines(context.account, kind, await context.source().pipelines(kind));
1709
- saved = await context.store.crm.saveItems(context.account, kind, [item]);
2244
+ await context.store.crm.savePipelines(context.account, kind2, await context.source().pipelines(kind2));
2245
+ saved = await context.store.crm.saveItems(context.account, kind2, [item]);
1710
2246
  }
1711
2247
  const [skipped] = saved.skipped;
1712
2248
  if (skipped)
1713
2249
  throw fail(skipped.message, { reason: skipped.reason });
1714
- const reference = await context.store.crm.refOf(context.account, kind, item.externalId);
2250
+ const reference = await context.store.crm.refOf(context.account, kind2, item.externalId);
1715
2251
  if (reference === null)
1716
2252
  throw fail("it is not found after the save");
1717
2253
  return await context.store.deals.get(reference);
@@ -1721,66 +2257,66 @@ var kept = /* @__PURE__ */ __name(async (context, kind, item, operationId) => {
1721
2257
  throw fail(error instanceof Error ? error.message : String(error), isCliError(error) ? error.details : {});
1722
2258
  }
1723
2259
  }, "kept");
1724
- var createCrmItem = /* @__PURE__ */ __name(async (context, kind, input, options = {}) => {
2260
+ var createCrmItem = /* @__PURE__ */ __name(async (context, kind2, input, options = {}) => {
1725
2261
  const { writer } = context.writes;
1726
- supported(writer, kind, "create");
2262
+ supported(writer, kind2, "create");
1727
2263
  if (input.title === void 0)
1728
- throw invalid(`a new ${kind} needs --title`, "--title");
1729
- const pipeline = await pipelineOf(context, kind, input.pipeline);
1730
- const { fields, stage } = fieldsOf({ ...input, pipeline: pipeline.ref }, pipeline, null);
1731
- const custom = await customOf(context, kind, input.custom);
2264
+ throw invalid(`a new ${kind2} needs --title`, "--title");
2265
+ const pipeline = await pipelineOf(context, kind2, input.pipeline);
2266
+ const { fields: fields2, stage } = fieldsOf({ ...input, pipeline: pipeline.ref }, pipeline, null);
2267
+ const custom = await customOf(context, kind2, input.custom);
1732
2268
  if (custom)
1733
- fields.custom = custom;
2269
+ fields2.custom = custom;
1734
2270
  const operationId = operationOf(context, options.operationId);
1735
- const item = await written(context, keysOf(context, kind, "create", { stage, owner: fields.owner }), operationId, () => writer.create(kind, fields, { operationId }));
1736
- return { operationId, item: await kept(context, kind, item, operationId) };
2271
+ const item = await written(context, keysOf(context, kind2, "create", { stage, owner: fields2.owner }), operationId, () => writer.create(kind2, fields2, { operationId }));
2272
+ return { operationId, item: await kept(context, kind2, item, operationId) };
1737
2273
  }, "createCrmItem");
1738
- var updateCrmItem = /* @__PURE__ */ __name(async (context, kind, reference, input, options = {}) => {
2274
+ var updateCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, input, options = {}) => {
1739
2275
  const { writer } = context.writes;
1740
- supported(writer, kind, "update");
1741
- const copy = await copyOf(context, kind, reference);
2276
+ supported(writer, kind2, "update");
2277
+ const copy = await copyOf(context, kind2, reference);
1742
2278
  if (input.pipeline !== void 0 && input.stage === void 0)
1743
2279
  throw invalid("a new --pipeline needs the --stage it goes to there", "--stage");
1744
- const pipeline = input.stage === void 0 ? void 0 : await pipelineOf(context, kind, input.pipeline === void 0 ? copy.pipeline : input.pipeline);
1745
- const { fields, stage } = fieldsOf(input, pipeline, copy.currency);
1746
- const custom = await customOf(context, kind, input.custom);
2280
+ const pipeline = input.stage === void 0 ? void 0 : await pipelineOf(context, kind2, input.pipeline === void 0 ? copy.pipeline : input.pipeline);
2281
+ const { fields: fields2, stage } = fieldsOf(input, pipeline, copy.currency);
2282
+ const custom = await customOf(context, kind2, input.custom);
1747
2283
  if (custom)
1748
- fields.custom = custom;
1749
- if (Object.keys(fields).length === 0)
2284
+ fields2.custom = custom;
2285
+ if (Object.keys(fields2).length === 0)
1750
2286
  throw invalid("nothing to change: name a field");
1751
2287
  const operationId = operationOf(context, options.operationId);
1752
- const item = await written(context, keysOf(context, kind, "update", { stage, owner: fields.owner }), operationId, () => writer.update(kind, copy.externalId, fields, { operationId }));
1753
- return { operationId, item: await kept(context, kind, item, operationId) };
2288
+ const item = await written(context, keysOf(context, kind2, "update", { stage, owner: fields2.owner }), operationId, () => writer.update(kind2, copy.externalId, fields2, { operationId }));
2289
+ return { operationId, item: await kept(context, kind2, item, operationId) };
1754
2290
  }, "updateCrmItem");
1755
- var moveCrmItem = /* @__PURE__ */ __name(async (context, kind, reference, stageName, options = {}) => {
2291
+ var moveCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, stageName, options = {}) => {
1756
2292
  const { writer } = context.writes;
1757
- supported(writer, kind, "move");
1758
- const copy = await copyOf(context, kind, reference);
1759
- const stage = stageOf(await pipelineOf(context, kind, copy.pipeline), stageName);
2293
+ supported(writer, kind2, "move");
2294
+ const copy = await copyOf(context, kind2, reference);
2295
+ const stage = stageOf(await pipelineOf(context, kind2, copy.pipeline), stageName);
1760
2296
  const operationId = operationOf(context, options.operationId);
1761
- const item = await written(context, keysOf(context, kind, "move", { stage }), operationId, () => writer.move(kind, copy.externalId, stage.externalId, { operationId }));
1762
- return { operationId, item: await kept(context, kind, item, operationId) };
2297
+ const item = await written(context, keysOf(context, kind2, "move", { stage }), operationId, () => writer.move(kind2, copy.externalId, stage.externalId, { operationId }));
2298
+ return { operationId, item: await kept(context, kind2, item, operationId) };
1763
2299
  }, "moveCrmItem");
1764
- var closeCrmItem = /* @__PURE__ */ __name(async (context, kind, reference, outcome, options = {}) => {
2300
+ var closeCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, outcome, options = {}) => {
1765
2301
  const { writer } = context.writes;
1766
- supported(writer, kind, "close");
2302
+ supported(writer, kind2, "close");
1767
2303
  if (outcome !== "won" && outcome !== "lost")
1768
2304
  throw invalid("a close is won or lost");
1769
- const copy = await copyOf(context, kind, reference);
2305
+ const copy = await copyOf(context, kind2, reference);
1770
2306
  const reason = options.reason?.trim();
1771
2307
  if (reason !== void 0 && (reason === "" || reason.length > 2e3))
1772
2308
  throw invalid("--reason is 1 to 2000 characters", "--reason");
1773
2309
  const operationId = operationOf(context, options.operationId);
1774
- const item = await written(context, keysOf(context, kind, "close", {}), operationId, () => writer.close(kind, copy.externalId, outcome, { operationId, ...reason ? { reason } : {} }));
1775
- return { operationId, item: await kept(context, kind, item, operationId) };
2310
+ const item = await written(context, keysOf(context, kind2, "close", {}), operationId, () => writer.close(kind2, copy.externalId, outcome, { operationId, ...reason ? { reason } : {} }));
2311
+ return { operationId, item: await kept(context, kind2, item, operationId) };
1776
2312
  }, "closeCrmItem");
1777
- var removeCrmItem = /* @__PURE__ */ __name(async (context, kind, reference, options = {}) => {
2313
+ var removeCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, options = {}) => {
1778
2314
  const { writer } = context.writes;
1779
- supported(writer, kind, "remove");
1780
- const copy = await copyOf(context, kind, reference);
2315
+ supported(writer, kind2, "remove");
2316
+ const copy = await copyOf(context, kind2, reference);
1781
2317
  const operationId = operationOf(context, options.operationId);
1782
- await written(context, keysOf(context, kind, "remove", {}), operationId, () => writer.remove(kind, copy.externalId, { operationId }));
1783
- const removed = await context.store.crm.remove(context.account, kind, [copy.externalId]);
2318
+ await written(context, keysOf(context, kind2, "remove", {}), operationId, () => writer.remove(kind2, copy.externalId, { operationId }));
2319
+ const removed = await context.store.crm.remove(context.account, kind2, [copy.externalId]);
1784
2320
  return { operationId, ref: copy.ref, removed };
1785
2321
  }, "removeCrmItem");
1786
2322
  var EMAIL = /^[^\s@]{1,64}@[^\s@]{1,255}$/u;
@@ -1788,7 +2324,7 @@ var RECORD_ID = /^[\w.:-]{1,100}$/u;
1788
2324
  var PERSON_ONLY = ["firstName", "lastName", "position"];
1789
2325
  var recordInvalid = /* @__PURE__ */ __name((message, param) => new CliError("validation_error", message, { reason: "crm.record-field", ...param ? { param } : {} }), "recordInvalid");
1790
2326
  var cleared = /* @__PURE__ */ __name((value) => value === void 0 ? void 0 : value.trim() || null, "cleared");
1791
- var listed2 = /* @__PURE__ */ __name((values, param, valid) => {
2327
+ var listed = /* @__PURE__ */ __name((values, param, valid) => {
1792
2328
  if (values === void 0)
1793
2329
  return void 0;
1794
2330
  const all = values.map((one) => one.trim());
@@ -1799,73 +2335,73 @@ var listed2 = /* @__PURE__ */ __name((values, param, valid) => {
1799
2335
  throw recordInvalid(`${param} got ${one}`, param);
1800
2336
  return all;
1801
2337
  }, "listed");
1802
- var recordFieldsOf = /* @__PURE__ */ __name((kind, input) => {
1803
- if (kind === "organization") {
2338
+ var recordFieldsOf = /* @__PURE__ */ __name((kind2, input) => {
2339
+ if (kind2 === "organization") {
1804
2340
  const given = PERSON_ONLY.find((one) => input[one] !== void 0);
1805
2341
  if (given)
1806
2342
  throw recordInvalid(`a company has no ${given}`);
1807
2343
  }
1808
- const fields = {};
2344
+ const fields2 = {};
1809
2345
  if (input.name !== void 0) {
1810
2346
  if (!input.name.trim())
1811
2347
  throw recordInvalid("--name is never empty", "--name");
1812
- fields.name = input.name.trim();
2348
+ fields2.name = input.name.trim();
1813
2349
  }
1814
2350
  const parts = { firstName: cleared(input.firstName), lastName: cleared(input.lastName) };
1815
2351
  const position = cleared(input.position);
1816
2352
  if (parts.firstName !== void 0)
1817
- fields.firstName = parts.firstName;
2353
+ fields2.firstName = parts.firstName;
1818
2354
  if (parts.lastName !== void 0)
1819
- fields.lastName = parts.lastName;
2355
+ fields2.lastName = parts.lastName;
1820
2356
  if (position !== void 0)
1821
- fields.position = position;
1822
- const emails = listed2(input.emails, "--email", EMAIL);
1823
- const phones = listed2(input.phones, "--phone")?.map((phone) => {
2357
+ fields2.position = position;
2358
+ const emails = listed(input.emails, "--email", EMAIL);
2359
+ const phones = listed(input.phones, "--phone")?.map((phone) => {
1824
2360
  const international = e164Of(phone, void 0);
1825
2361
  if (typeof international !== "string")
1826
2362
  throw recordInvalid(`--phone takes a number in international form, starting with +: not ${phone}`, "--phone");
1827
2363
  return international;
1828
2364
  });
1829
2365
  if (emails)
1830
- fields.emails = emails;
2366
+ fields2.emails = emails;
1831
2367
  if (phones)
1832
- fields.phones = phones;
2368
+ fields2.phones = phones;
1833
2369
  if (input.owner !== void 0) {
1834
2370
  if (!input.owner.trim())
1835
2371
  throw recordInvalid("--owner is the CRM user's id", "--owner");
1836
- fields.owner = input.owner.trim();
2372
+ fields2.owner = input.owner.trim();
1837
2373
  }
1838
- return fields;
2374
+ return fields2;
1839
2375
  }, "recordFieldsOf");
1840
- var keptRecord = /* @__PURE__ */ __name(async (context, kind, record) => {
2376
+ var keptRecord = /* @__PURE__ */ __name(async (context, kind2, record2) => {
1841
2377
  try {
1842
- const saved = kind === "person" ? await context.store.crm.savePeople(context.account, [record]) : await context.store.crm.saveOrganizations(context.account, [record]);
2378
+ const saved = kind2 === "person" ? await context.store.crm.savePeople(context.account, [record2]) : await context.store.crm.saveOrganizations(context.account, [record2]);
1843
2379
  const [skipped] = saved.skipped;
1844
2380
  if (skipped)
1845
2381
  throw new Error(skipped.message);
1846
2382
  } catch (error) {
1847
- throw new CliError("invalid_response", `the CRM wrote ${kind} ${record.externalId}, but the local store did not keep it (${error instanceof Error ? error.message : String(error)}); sync to store it \u2014 do not write it again`, { external_id: record.externalId, sent: true });
2383
+ throw new CliError("invalid_response", `the CRM wrote ${kind2} ${record2.externalId}, but the local store did not keep it (${error instanceof Error ? error.message : String(error)}); sync to store it \u2014 do not write it again`, { external_id: record2.externalId, sent: true });
1848
2384
  }
1849
2385
  }, "keptRecord");
1850
- var forgotten = /* @__PURE__ */ __name(async (context, kind, record) => (kind === "organization" ? await context.store.crm.remove(context.account, kind, [record.externalId]) : (await context.store.crm.removeContact(context.account, record.externalId)).contacts) > 0, "forgotten");
1851
- var writeRecord = /* @__PURE__ */ __name(async (context, kind, verb, fields, operationId, act) => {
2386
+ var forgotten = /* @__PURE__ */ __name(async (context, kind2, record2) => (kind2 === "organization" ? await context.store.crm.remove(context.account, kind2, [record2.externalId]) : (await context.store.crm.removeContact(context.account, record2.externalId)).contacts) > 0, "forgotten");
2387
+ var writeRecord = /* @__PURE__ */ __name(async (context, kind2, verb, fields2, operationId, act) => {
1852
2388
  if (!context.source)
1853
2389
  throw new CliError("configuration_error", "a contact or company write needs the CRM source to tell your clients");
1854
- const rule = foreignContacts(context.source(), void 0);
1855
- const record = await written(context, keysOf(context, kind, verb, { owner: fields.owner }), operationId, act);
1856
- const stored = await rule.own(kind, record);
2390
+ const rule2 = foreignContacts(context.source(), void 0);
2391
+ const record2 = await written(context, keysOf(context, kind2, verb, { owner: fields2.owner }), operationId, act);
2392
+ const stored = await rule2.own(kind2, record2);
1857
2393
  let removed;
1858
2394
  try {
1859
2395
  if (stored)
1860
- await keptRecord(context, kind, record);
2396
+ await keptRecord(context, kind2, record2);
1861
2397
  else if (verb === "update")
1862
- removed = await forgotten(context, kind, record);
2398
+ removed = await forgotten(context, kind2, record2);
1863
2399
  } catch (error) {
1864
2400
  if (isCliError(error))
1865
2401
  throw new CliError(error.code, error.message, { ...error.details, operation_id: operationId });
1866
2402
  throw error;
1867
2403
  }
1868
- const [shown] = stored ? [record] : await rule.strip(kind, [record]);
2404
+ const [shown] = stored ? [record2] : await rule2.strip(kind2, [record2]);
1869
2405
  return {
1870
2406
  operationId,
1871
2407
  record: shown,
@@ -1873,154 +2409,191 @@ var writeRecord = /* @__PURE__ */ __name(async (context, kind, verb, fields, ope
1873
2409
  ...removed === void 0 ? {} : { removed }
1874
2410
  };
1875
2411
  }, "writeRecord");
1876
- var createCrmRecord = /* @__PURE__ */ __name(async (context, kind, input, options = {}) => {
2412
+ var createCrmRecord = /* @__PURE__ */ __name(async (context, kind2, input, options = {}) => {
1877
2413
  const { writer } = context.writes;
1878
- supported(writer, kind, "create");
1879
- const fields = recordFieldsOf(kind, input);
1880
- if (kind === "organization" && fields.name === void 0)
2414
+ supported(writer, kind2, "create");
2415
+ const fields2 = recordFieldsOf(kind2, input);
2416
+ if (kind2 === "organization" && fields2.name === void 0)
1881
2417
  throw recordInvalid("a new company needs --name", "--name");
1882
- if (kind === "person" && !fields.name && !fields.firstName && !fields.lastName)
2418
+ if (kind2 === "person" && !fields2.name && !fields2.firstName && !fields2.lastName)
1883
2419
  throw recordInvalid("a new contact needs --name, --first-name or --last-name", "--name");
1884
- const custom = await customOf(context, kind, input.custom);
2420
+ const custom = await customOf(context, kind2, input.custom);
1885
2421
  if (custom)
1886
- fields.custom = custom;
2422
+ fields2.custom = custom;
1887
2423
  const operationId = operationOf(context, options.operationId);
1888
- return writeRecord(context, kind, "create", fields, operationId, () => writer.create(kind, fields, { operationId }));
2424
+ return writeRecord(context, kind2, "create", fields2, operationId, () => writer.create(kind2, fields2, { operationId }));
1889
2425
  }, "createCrmRecord");
1890
- var updateCrmRecord = /* @__PURE__ */ __name(async (context, kind, externalId, input, options = {}) => {
2426
+ var updateCrmRecord = /* @__PURE__ */ __name(async (context, kind2, externalId, input, options = {}) => {
1891
2427
  const { writer } = context.writes;
1892
- supported(writer, kind, "update");
2428
+ supported(writer, kind2, "update");
1893
2429
  if (!RECORD_ID.test(externalId))
1894
- throw new CliError("validation_error", `name the ${kind} by the CRM's id, as a list prints it`, {
2430
+ throw new CliError("validation_error", `name the ${kind2} by the CRM's id, as a list prints it`, {
1895
2431
  reason: "ref.malformed"
1896
2432
  });
1897
- const fields = recordFieldsOf(kind, input);
1898
- const custom = await customOf(context, kind, input.custom);
2433
+ const fields2 = recordFieldsOf(kind2, input);
2434
+ const custom = await customOf(context, kind2, input.custom);
1899
2435
  if (custom)
1900
- fields.custom = custom;
1901
- if (Object.keys(fields).length === 0)
2436
+ fields2.custom = custom;
2437
+ if (Object.keys(fields2).length === 0)
1902
2438
  throw recordInvalid("nothing to change: name a field");
1903
2439
  const operationId = operationOf(context, options.operationId);
1904
- return writeRecord(context, kind, "update", fields, operationId, () => writer.update(kind, externalId, fields, { operationId }));
2440
+ return writeRecord(context, kind2, "update", fields2, operationId, () => writer.update(kind2, externalId, fields2, { operationId }));
1905
2441
  }, "updateCrmRecord");
1906
2442
 
1907
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/values.js
1908
- var values_exports = {};
1909
- __export(values_exports, {
1910
- amountOf: () => amountOf,
1911
- crmValuesOf: () => crmValuesOf,
1912
- epoch: () => epoch,
1913
- fieldOf: () => fieldOf,
1914
- fullName: () => fullName,
1915
- id: () => id,
1916
- ids: () => ids,
1917
- isRaw: () => isRaw,
1918
- number: () => number,
1919
- rawsOf: () => rawsOf,
1920
- text: () => text,
1921
- time: () => time
1922
- });
1923
-
1924
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/source.js
1925
- var CRM_FILE_SOURCES = ["record", "field", "document", "activity", "comment"];
2443
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/file-fetch.js
2444
+ var EXCHANGE_MS = 60 * 60 * 1e3;
1926
2445
 
1927
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/files.js
1928
- var parseCrmFileId = /* @__PURE__ */ __name((id2) => {
1929
- const [kind = "", owner = "", source = "", ...rest] = id2.trim().split(":");
1930
- const providerId = rest.join(":");
1931
- if (!CRM_KINDS.includes(kind) || !/^[\w.-]+$/u.test(owner) || !CRM_FILE_SOURCES.includes(source) || !providerId)
1932
- throw new CliError("validation_error", "a file id is <owner kind>:<owner id>:<source>:<id>, as files list prints it, such as deal:12:record:345", { reason: "ref.malformed" });
1933
- return { owner: { kind, id: owner }, source, providerId };
1934
- }, "parseCrmFileId");
1935
- var foldKey = /* @__PURE__ */ __name((key) => key.replaceAll("_", "").toLowerCase(), "foldKey");
1936
- var DOWNLOAD_KEYS = new Set(["DOWNLOAD_URL", "downloadUrl", "fileUrl", "CALL_RECORD_URL", "archiveLink", "publicUrl"].map(foldKey));
1937
- var isDownloadKey = /* @__PURE__ */ __name((key) => DOWNLOAD_KEYS.has(foldKey(key)) || foldKey(key).endsWith("machine"), "isDownloadKey");
1938
- var WEBHOOK = /\/rest\/\d+\/[^/\s"'?#]+\//iu;
1939
- var PORTAL_PATH = /\/rest\/|show_file\.php/iu;
1940
- var TOKEN_QUERY = /(?:[?&]|&amp;)(?:auth|token|access_token)=[^&#\s]/iu;
1941
- var CREDENTIAL = /(?:[?&]|&amp;)(?:auth|access_token|api_token|x-amz-signature)=[^&#\s]/iu;
1942
- var isTokened = /* @__PURE__ */ __name((value) => WEBHOOK.test(value) || CREDENTIAL.test(value) || PORTAL_PATH.test(value) && TOKEN_QUERY.test(value), "isTokened");
1943
- var LINK_REMOVED = "[link removed]";
1944
- var withoutFileLinks = /* @__PURE__ */ __name((body) => {
1945
- const walk2 = /* @__PURE__ */ __name((value, key) => {
1946
- if (typeof value === "string")
1947
- return isTokened(value) ? LINK_REMOVED : value;
1948
- if (Array.isArray(value))
1949
- return value.map((one) => walk2(one));
1950
- if (value === null || typeof value !== "object")
1951
- return value;
1952
- return Object.fromEntries(Object.entries(value).map(([name, one]) => [
1953
- name,
1954
- (isDownloadKey(name) || key === "_links" && name === "download") && one !== null && one !== "" ? LINK_REMOVED : walk2(one, name)
1955
- ]));
1956
- }, "walk");
1957
- return walk2(body);
1958
- }, "withoutFileLinks");
2446
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/manifest/map.js
2447
+ var at = /* @__PURE__ */ __name((value, path2) => path2 === "." ? value : path2.split(".").reduce((inner, key) => inner === null ? null : Array.isArray(inner) && /^\d+$/.test(key) ? inner[Number(key)] ?? null : isRaw(inner) ? inner[key] : void 0, value), "at");
2448
+ var TIMES = { createdAt: "epoch", updatedAt: "epoch" };
2449
+ var ITEM = {
2450
+ externalId: "id",
2451
+ title: "text",
2452
+ pipeline: "text",
2453
+ stage: "text",
2454
+ status: "status",
2455
+ closeDate: "day",
2456
+ closedDate: "day",
2457
+ closedReason: "text",
2458
+ organization: "id",
2459
+ contactName: "text",
2460
+ companyName: "text",
2461
+ people: "people",
2462
+ deal: "id",
2463
+ url: "text",
2464
+ assignee: "id",
2465
+ ...TIMES
2466
+ };
2467
+ var FIELDS = {
2468
+ person: {
2469
+ externalId: "id",
2470
+ name: "text",
2471
+ firstName: "text",
2472
+ lastName: "text",
2473
+ email: "text",
2474
+ phone: "text",
2475
+ emails: "texts",
2476
+ phones: "texts",
2477
+ position: "text",
2478
+ organizations: "organizations",
2479
+ assignee: "id",
2480
+ url: "text",
2481
+ ...TIMES
2482
+ },
2483
+ organization: {
2484
+ externalId: "id",
2485
+ name: "text",
2486
+ url: "text",
2487
+ type: "text",
2488
+ own: "bool",
2489
+ phones: "texts",
2490
+ emails: "texts",
2491
+ people: "ids",
2492
+ assignee: "id",
2493
+ ...TIMES
2494
+ },
2495
+ deal: ITEM,
2496
+ lead: ITEM
2497
+ };
1959
2498
 
1960
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/values.js
1961
- var isRaw = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRaw");
1962
- var fieldOf = /* @__PURE__ */ __name((value, key) => isRaw(value) ? value[key] : void 0, "fieldOf");
1963
- var rawsOf = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.filter(isRaw) : [], "rawsOf");
1964
- var text = /* @__PURE__ */ __name((value) => {
1965
- if (typeof value !== "string" && typeof value !== "number")
1966
- return null;
1967
- const trimmed = String(value).trim();
1968
- return trimmed === "" ? null : trimmed;
1969
- }, "text");
1970
- var id = /* @__PURE__ */ __name((value) => {
1971
- const found = text(value);
1972
- return found === null || found === "0" ? null : found;
1973
- }, "id");
1974
- var ids = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(id).filter((one) => one !== null) : [], "ids");
1975
- var number = /* @__PURE__ */ __name((value) => {
1976
- if (value === null || value === void 0 || value === "")
1977
- return null;
1978
- const found = Number(value);
1979
- return Number.isFinite(found) ? found : null;
1980
- }, "number");
1981
- var time = /* @__PURE__ */ __name((value) => {
1982
- if (typeof value === "number") {
1983
- if (!Number.isFinite(value) || value <= 0)
1984
- return null;
1985
- return new Date(value > 1e11 ? value : value * 1e3).toISOString();
1986
- }
1987
- const found = text(value);
1988
- if (found === null)
1989
- return null;
1990
- const parsed = new Date(found);
1991
- return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
1992
- }, "time");
1993
- var epoch = /* @__PURE__ */ __name((value) => {
1994
- const found = time(value);
1995
- return found === null ? null : Date.parse(found);
1996
- }, "epoch");
1997
- var amountOf = /* @__PURE__ */ __name((value, currency) => {
1998
- const found = number(value);
1999
- const code = text(currency)?.toUpperCase() ?? null;
2000
- if (found === null || found <= 0 || code === null)
2001
- return { amount: null, currency: null };
2002
- return { amount: typeof value === "string" ? value.trim() : String(found), currency: code };
2003
- }, "amountOf");
2004
- var fullName = /* @__PURE__ */ __name((...parts) => parts.map(text).filter((part) => part !== null).join(" ") || null, "fullName");
2005
- var optionLabel = /* @__PURE__ */ __name((field, option) => field.options?.find(({ id: id2 }) => id2 === String(option))?.label ?? String(option), "optionLabel");
2006
- var crmValuesOf = /* @__PURE__ */ __name((values, fields) => {
2007
- const byCode = new Map(fields.map((field) => [field.code, field]));
2008
- return Object.fromEntries(Object.entries(values).map(([code, value]) => {
2009
- const field = byCode.get(code);
2010
- const label = field?.label ?? null;
2011
- if (!field?.options)
2012
- return [code, { label, value: withoutFileLinks(value) }];
2013
- if (Array.isArray(value))
2014
- return [code, { label, value: value.map((one) => optionLabel(field, one)), option_id: value.map(String) }];
2015
- return [code, { label, value: optionLabel(field, value), option_id: String(value) }];
2016
- }));
2017
- }, "crmValuesOf");
2499
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/manifest/manifest.js
2500
+ var path = pipe(string(), regex(/^[^.\s]+(\.[^.\s]+)*$/, "a dotted path such as properties.name"));
2501
+ var paths = pipe(array(path), minLength(1));
2502
+ var crmRuleSchema = union([
2503
+ path,
2504
+ strictObject({ first: paths }),
2505
+ strictObject({ join: paths }),
2506
+ strictObject({ all: paths, split: optional(string()) }),
2507
+ strictObject({ path, split: optional(string()) }),
2508
+ strictObject({ path, map: record(string(), unknown()) }),
2509
+ strictObject({ each: path, id: path, primary: optional(path) }),
2510
+ strictObject({ each: path, value: path }),
2511
+ strictObject({ value: unknown() }),
2512
+ function_()
2513
+ ], "a path, one of first, join, all, path, each, value, or a function");
2514
+ var rule = crmRuleSchema;
2515
+ var call = strictObject({
2516
+ operation: pipe(string(), minLength(1)),
2517
+ path: optional(record(string(), string())),
2518
+ query: optional(record(string(), union([string(), number(), boolean()]))),
2519
+ body: optional(unknown()),
2520
+ items: optional(path)
2521
+ });
2522
+ var entity = strictObject({
2523
+ list: call,
2524
+ changes: optional(strictObject({
2525
+ ...call.entries,
2526
+ since: picklist(["ms", "seconds", "iso", "datetime"]),
2527
+ keyset: optional(strictObject({ field: path, cap: optional(pipe(number(), integer(), minValue(1))) }))
2528
+ })),
2529
+ ids: optional(call),
2530
+ get: optional(call),
2531
+ search: optional(call),
2532
+ select: optional(strictObject({
2533
+ from: path,
2534
+ also: optional(array(string())),
2535
+ max: optional(pipe(number(), integer(), minValue(1)))
2536
+ })),
2537
+ map: record(string(), rule),
2538
+ custom: optional(strictObject({
2539
+ from: path,
2540
+ split: optional(string()),
2541
+ typed: optional(strictObject({ by: path, current: optional(path), paths: optional(record(string(), path)) }))
2542
+ })),
2543
+ optional: optional(strictObject({ message: pipe(string(), minLength(1)), scope: optional(string()) })),
2544
+ linked: optional(literal(true))
2545
+ });
2546
+ var pipelines = strictObject({
2547
+ call,
2548
+ map: strictObject({ externalId: rule, name: rule }),
2549
+ stages: strictObject({
2550
+ each: union([literal("."), path]),
2551
+ pipeline: optional(path),
2552
+ map: strictObject({ externalId: rule, name: rule, position: optional(rule) }),
2553
+ outcome: union([
2554
+ strictObject({ path, won: optional(array(string())), lost: optional(array(string())) }),
2555
+ strictObject({ value: picklist(STAGE_OUTCOMES) }),
2556
+ function_()
2557
+ ])
2558
+ })
2559
+ });
2560
+ var fields = strictObject({
2561
+ call,
2562
+ map: strictObject({
2563
+ code: rule,
2564
+ label: optional(rule),
2565
+ type: optional(rule),
2566
+ multiple: optional(rule),
2567
+ filterable: optional(rule),
2568
+ options: optional(union([strictObject({ each: path, id: path, label: path }), function_()]))
2569
+ }),
2570
+ keep: optional(union([strictObject({ path, is: unknown() }), function_()]))
2571
+ });
2572
+ var kind = picklist(CRM_KINDS);
2573
+ var schema = strictObject({
2574
+ provider: pipe(string(), regex(/^[a-z][a-z0-9-]*$/, "a registry name such as hubspot")),
2575
+ kinds: pipe(array(kind), minLength(1)),
2576
+ overlapMs: optional(pipe(number(), integer(), minValue(0))),
2577
+ entities: record(kind, optional(entity)),
2578
+ pipelines: optional(record(picklist(DEAL_KINDS), optional(pipelines))),
2579
+ fields: optional(record(kind, optional(fields))),
2580
+ users: optional(strictObject({
2581
+ call,
2582
+ map: strictObject({
2583
+ externalId: rule,
2584
+ name: optional(rule),
2585
+ email: optional(rule),
2586
+ position: optional(rule),
2587
+ active: optional(rule)
2588
+ })
2589
+ }))
2590
+ });
2018
2591
 
2019
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/file-fetch.js
2020
- var EXCHANGE_MS = 60 * 60 * 1e3;
2592
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/manifest/source.js
2593
+ var OVERLAP_MS = 10 * 6e4;
2021
2594
 
2022
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/sends/pace.js
2023
- import { readFileSync as readFileSync5, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
2595
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/sends/pace.js
2596
+ import { readFileSync as readFileSync6, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
2024
2597
  import { join as join5 } from "node:path";
2025
2598
  var DEFAULT_PACE = { perMinute: 60, burst: 20 };
2026
2599
  var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join5(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
@@ -2031,8 +2604,8 @@ var Pacer = class {
2031
2604
  path;
2032
2605
  rate;
2033
2606
  now;
2034
- constructor(path, rate, now = Date.now) {
2035
- this.path = path;
2607
+ constructor(path2, rate, now = Date.now) {
2608
+ this.path = path2;
2036
2609
  this.rate = rate;
2037
2610
  this.now = now;
2038
2611
  }
@@ -2066,19 +2639,19 @@ var Pacer = class {
2066
2639
  }
2067
2640
  read(now) {
2068
2641
  try {
2069
- const file = JSON.parse(readFileSync5(this.path, "utf8"));
2642
+ const file = JSON.parse(readFileSync6(this.path, "utf8"));
2070
2643
  const tat = Number(file.tat);
2071
2644
  if (!Number.isFinite(tat))
2072
2645
  return 0;
2073
- const at = Number(file.at);
2074
- return Number.isFinite(at) && at > now ? now + Math.max(0, tat - at) : tat;
2646
+ const at2 = Number(file.at);
2647
+ return Number.isFinite(at2) && at2 > now ? now + Math.max(0, tat - at2) : tat;
2075
2648
  } catch {
2076
2649
  return 0;
2077
2650
  }
2078
2651
  }
2079
- write(tat, at) {
2652
+ write(tat, at2) {
2080
2653
  const temporary = `${this.path}.${process.pid}.tmp`;
2081
- writeFileSync2(temporary, JSON.stringify({ tat, at }), { mode: 384 });
2654
+ writeFileSync2(temporary, JSON.stringify({ tat, at: at2 }), { mode: 384 });
2082
2655
  renameSync2(temporary, this.path);
2083
2656
  }
2084
2657
  };
@@ -2087,9 +2660,9 @@ var LONGEST_PACE_WAIT_MS = 5 * 6e4;
2087
2660
  var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
2088
2661
  const { name, operation, warn } = options;
2089
2662
  const now = options.now ?? Date.now;
2090
- let at = now();
2663
+ let at2 = now();
2091
2664
  try {
2092
- at = await pacer.reserve();
2665
+ at2 = await pacer.reserve();
2093
2666
  } catch (error) {
2094
2667
  warn?.(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
2095
2668
  event: "warning",
@@ -2097,11 +2670,11 @@ var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
2097
2670
  operation
2098
2671
  });
2099
2672
  }
2100
- const waitMs = at - now();
2673
+ const waitMs = at2 - now();
2101
2674
  if (waitMs <= 0)
2102
2675
  return;
2103
2676
  if (waitMs > (options.longestWaitMs ?? LONGEST_PACE_WAIT_MS))
2104
- throw new CliError("rate_limited", `this profile's next request to ${name} has to wait ${Math.ceil(waitMs / 1e3)} s more \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(at).toISOString(), remembered: true });
2677
+ throw new CliError("rate_limited", `this profile's next request to ${name} has to wait ${Math.ceil(waitMs / 1e3)} s more \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(at2).toISOString(), remembered: true });
2105
2678
  if (waitMs >= ANNOUNCE_WAIT_MS) {
2106
2679
  const seconds = Math.ceil(waitMs / 1e3);
2107
2680
  warn?.(`waiting ${seconds} s to keep this profile's pace with ${name}`, {
@@ -2114,7 +2687,7 @@ var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
2114
2687
  await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
2115
2688
  }, "waitForTurn");
2116
2689
 
2117
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/provider-call.js
2690
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/provider-call.js
2118
2691
  var RETRY = { retries: 3, baseDelayMs: 1e3, maxDelayMs: 1e4, maxRetryAfterMs: 3e4 };
2119
2692
  var UNANSWERED = /* @__PURE__ */ new Set(["timeout", "network_error", "provider_unavailable", "cancelled", "invalid_response"]);
2120
2693
  var unanswered = /* @__PURE__ */ __name((error) => !isCliError(error) || UNANSWERED.has(error.code) && error.details.sent !== false, "unanswered");
@@ -2150,14 +2723,14 @@ var providerCall = /* @__PURE__ */ __name(async (options) => {
2150
2723
  }
2151
2724
  }, "providerCall");
2152
2725
 
2153
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/query.js
2154
- var valueFor = /* @__PURE__ */ __name((kind, raw, name) => {
2155
- if (kind === "id") {
2726
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/query.js
2727
+ var valueFor = /* @__PURE__ */ __name((kind2, raw, name) => {
2728
+ if (kind2 === "id") {
2156
2729
  if (!/^[\w.:-]{1,100}$/u.test(raw))
2157
2730
  throw new CliError("validation_error", `${name} takes an id; got ${raw}`, { reason: "query.bad-value" });
2158
2731
  return raw;
2159
2732
  }
2160
- if (kind !== "number")
2733
+ if (kind2 !== "number")
2161
2734
  return raw;
2162
2735
  const found = Number(raw);
2163
2736
  if (raw.trim() === "" || !Number.isFinite(found))
@@ -2180,16 +2753,16 @@ var range = /* @__PURE__ */ __name((node, map, name) => [
2180
2753
  }
2181
2754
  ]
2182
2755
  ], "range");
2183
- var conditionsOf = /* @__PURE__ */ __name((terms, fields, hooks = {}) => [...terms].flatMap(([name, node]) => {
2184
- const map = fields[name];
2756
+ var conditionsOf = /* @__PURE__ */ __name((terms, fields2, hooks = {}) => [...terms].flatMap(([name, node]) => {
2757
+ const map = fields2[name];
2185
2758
  if (!map)
2186
2759
  throw new CliError("validation_error", `the CRM cannot filter by ${name}`, { reason: "query.unsupported-field" });
2187
2760
  if (map.kind === "time") {
2188
- const at = hooks.time ?? ((ms) => ms);
2761
+ const at2 = hooks.time ?? ((ms) => ms);
2189
2762
  const { since, until } = timeBounds(node);
2190
2763
  return [
2191
- ...since === void 0 ? [] : [{ field: map.field, op: ">=", value: at(since) }],
2192
- ...until === void 0 ? [] : [{ field: map.field, op: "<=", value: at(until) }]
2764
+ ...since === void 0 ? [] : [{ field: map.field, op: ">=", value: at2(since) }],
2765
+ ...until === void 0 ? [] : [{ field: map.field, op: "<=", value: at2(until) }]
2193
2766
  ];
2194
2767
  }
2195
2768
  if (node.operator === "range")
@@ -2203,8 +2776,8 @@ var customNames = /* @__PURE__ */ __name((text2, registry, command, defaultField
2203
2776
  const named2 = walkQuery(parseLucene(text2, { defaultField, command, guide: LIST_QUERY_GUIDE }).root).filter((term) => !term.implicit).map((term) => term.field);
2204
2777
  return [...new Set(named2.filter((name) => !known.has(name)))];
2205
2778
  }, "customNames");
2206
- var filterableFields = /* @__PURE__ */ __name((fields, names) => names.map((name) => {
2207
- const field = fieldNamed(fields, name, "--query");
2779
+ var filterableFields = /* @__PURE__ */ __name((fields2, names) => names.map((name) => {
2780
+ const field = fieldNamed(fields2, name, "--query");
2208
2781
  if (!field.filterable)
2209
2782
  throw new CliError("validation_error", `the CRM cannot filter a list by ${field.label ?? field.code}`, {
2210
2783
  reason: "field.not-filterable",
@@ -2221,37 +2794,37 @@ var withCustomFields = /* @__PURE__ */ __name((registry, chosen) => ({
2221
2794
  }), "withCustomFields");
2222
2795
  var customValue = /* @__PURE__ */ __name((field, typed, hooks) => {
2223
2796
  const value = field.options ? optionOf(field, typed, "--query") : typed;
2224
- const number2 = Number(value);
2225
- return hooks.numeric?.(field) && value.trim() !== "" && Number.isFinite(number2) ? number2 : value;
2797
+ const number3 = Number(value);
2798
+ return hooks.numeric?.(field) && value.trim() !== "" && Number.isFinite(number3) ? number3 : value;
2226
2799
  }, "customValue");
2227
2800
  var customConditions = /* @__PURE__ */ __name((terms, chosen, hooks = {}) => chosen.flatMap(([name, field]) => {
2228
2801
  const term = terms.get(name);
2229
2802
  terms.delete(name);
2230
2803
  return term ? [{ field: field.code, op: "=", value: customValue(field, term.value, hooks) }] : [];
2231
2804
  }), "customConditions");
2232
- var wantedCodes = /* @__PURE__ */ __name((paths) => {
2233
- if (!paths)
2805
+ var wantedCodes = /* @__PURE__ */ __name((paths2) => {
2806
+ if (!paths2)
2234
2807
  return void 0;
2235
- const parts = paths.split(",").map((path) => path.trim().replace(/^items\./, "").split("."));
2808
+ const parts = paths2.split(",").map((path2) => path2.trim().replace(/^items\./, "").split("."));
2236
2809
  const metadata = parts.filter(([top]) => top === "provider_metadata");
2237
2810
  if (metadata.some((part) => part.length === 1))
2238
2811
  return "all";
2239
2812
  const codes = metadata.flatMap(([, code]) => code ? [code] : []);
2240
2813
  return codes.length ? [...new Set(codes)] : void 0;
2241
2814
  }, "wantedCodes");
2242
- var selectedCodes = /* @__PURE__ */ __name((fields, wanted) => {
2815
+ var selectedCodes = /* @__PURE__ */ __name((fields2, wanted) => {
2243
2816
  if (wanted === void 0)
2244
2817
  return [];
2245
2818
  if (wanted === "all")
2246
- return fields.map((field) => field.code);
2819
+ return fields2.map((field) => field.code);
2247
2820
  return wanted.map((code) => {
2248
- if (!fields.some((field) => field.code === code))
2249
- throw unknownField(fields, code, "--json");
2821
+ if (!fields2.some((field) => field.code === code))
2822
+ throw unknownField(fields2, code, "--json");
2250
2823
  return code;
2251
2824
  });
2252
2825
  }, "selectedCodes");
2253
2826
 
2254
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/search/groups.js
2827
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/search/groups.js
2255
2828
  var ALL = "all";
2256
2829
  var OWNER_NOTES = { provider: "notes", account: INTERNAL_NOTES };
2257
2830
  var NOT_GROUP_NAMES = /* @__PURE__ */ new Set([ALL, "bots"]);
@@ -2323,7 +2896,7 @@ var groupEntries = /* @__PURE__ */ __name((saved) => ({
2323
2896
  [ALL]: [ALL]
2324
2897
  }), "groupEntries");
2325
2898
 
2326
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/services/search-kind.js
2899
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/services/search-kind.js
2327
2900
  var NO_MAIL = "no_mail";
2328
2901
  var MAIL = "email";
2329
2902
  var groupLockOf = /* @__PURE__ */ __name((app, env) => {
@@ -2362,7 +2935,7 @@ var listContextOf = /* @__PURE__ */ __name(async (store, account, app, stored, e
2362
2935
  only
2363
2936
  };
2364
2937
  }, "listContextOf");
2365
- var listedAccounts = /* @__PURE__ */ __name(async (store, account, source, app, kind, env) => {
2938
+ var listedAccounts = /* @__PURE__ */ __name(async (store, account, source, app, kind2, env) => {
2366
2939
  const lock = groupLockOf(app, env);
2367
2940
  if (source === void 0 && lock === void 0)
2368
2941
  return void 0;
@@ -2371,21 +2944,21 @@ var listedAccounts = /* @__PURE__ */ __name(async (store, account, source, app,
2371
2944
  if (lock === void 0 && source !== void 0 && !isAccountList(source) && !registered)
2372
2945
  return void 0;
2373
2946
  const entries = entriesOfList(source ?? `group:${lock}`, await listContextOf(store, account, app, stored, env));
2374
- return fitting(entries, kind ? [kind] : ["messages", "mail"], `${app ? `${app.command} ` : ""}search ${kind ?? "messages"}`);
2947
+ return fitting(entries, kind2 ? [kind2] : ["messages", "mail"], `${app ? `${app.command} ` : ""}search ${kind2 ?? "messages"}`);
2375
2948
  }, "listedAccounts");
2376
- var accountsOfKind = /* @__PURE__ */ __name((kind, chosen, held, explicit, command = void 0, mailAccount, listed3 = false) => {
2377
- if (mailAccount !== void 0 && kind !== "mail")
2949
+ var accountsOfKind = /* @__PURE__ */ __name((kind2, chosen, held, explicit, command = void 0, mailAccount, listed2 = false) => {
2950
+ if (mailAccount !== void 0 && kind2 !== "mail")
2378
2951
  throw new CliError("validation_error", "--account names a mail account \u2014 memo search mail reads it");
2379
- if (kind === void 0)
2952
+ if (kind2 === void 0)
2380
2953
  return chosen;
2381
- if (kind === "messages") {
2954
+ if (kind2 === "messages") {
2382
2955
  if (explicit === MAIL)
2383
2956
  throw new CliError("validation_error", "mail is searched with `memo search mail`, not search messages");
2384
2957
  return chosen.filter(({ provider }) => holdsKindOf(provider, "messages"));
2385
2958
  }
2386
2959
  if (explicit !== void 0 && explicit !== MAIL && explicit !== "all")
2387
2960
  throw new CliError("validation_error", `search mail reads mail only \u2014 \`${command === void 0 ? "" : `${command} `}search messages\` searches ${explicit}`);
2388
- const mail = (listed3 ? chosen : held).filter(({ provider }) => holdsKindOf(provider, "mail"));
2961
+ const mail = (listed2 ? chosen : held).filter(({ provider }) => holdsKindOf(provider, "mail"));
2389
2962
  if (mail.length === 0)
2390
2963
  throw new CliError("not_found", "no mail in the store yet \u2014 `memo sync --only mail --since-time <time>` imports it", {
2391
2964
  reason: NO_MAIL
@@ -2397,7 +2970,7 @@ var accountsOfKind = /* @__PURE__ */ __name((kind, chosen, held, explicit, comma
2397
2970
  return chosenMail.map(({ provider, account }) => ({ provider, account }));
2398
2971
  }, "accountsOfKind");
2399
2972
 
2400
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/group-hint.js
2973
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/group-hint.js
2401
2974
  var workGroupHint = /* @__PURE__ */ __name((key) => `add it to a work group: \`memo groups add work ${key.provider}:${key.account}\``, "workGroupHint");
2402
2975
  var ungroupedHint = /* @__PURE__ */ __name(async (store, key) => {
2403
2976
  const { groups } = (await listContextOf(store, key, void 0)).membership;
@@ -2405,7 +2978,7 @@ var ungroupedHint = /* @__PURE__ */ __name(async (store, key) => {
2405
2978
  return grouped ? void 0 : workGroupHint(key);
2406
2979
  }, "ungroupedHint");
2407
2980
 
2408
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/viewer.js
2981
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/viewer.js
2409
2982
  var VIEWERS = "crm:viewers";
2410
2983
  var viewersOf = /* @__PURE__ */ __name(async (store, account) => {
2411
2984
  try {
@@ -2480,7 +3053,7 @@ var ownerOf = /* @__PURE__ */ __name(async (run, owner) => {
2480
3053
  return crmIdentityId(run.account, normalCrmUserId(owner), "user");
2481
3054
  }, "ownerOf");
2482
3055
 
2483
- // node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/crm/sync.js
3056
+ // node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/sync.js
2484
3057
  var DAY2 = 864e5;
2485
3058
  var CLOCK_MARGIN = 60 * 6e4;
2486
3059
  var MOST_UNLISTED = 0.5;
@@ -2514,7 +3087,7 @@ var parseCrmCursor = /* @__PURE__ */ __name((value) => {
2514
3087
  return null;
2515
3088
  }
2516
3089
  }, "parseCrmCursor");
2517
- var cursorName = /* @__PURE__ */ __name((kind) => `crm:${kind}`, "cursorName");
3090
+ var cursorName = /* @__PURE__ */ __name((kind2) => `crm:${kind2}`, "cursorName");
2518
3091
  var CONTINUE = "run sync again to continue";
2519
3092
  var fresh = /* @__PURE__ */ __name(() => ({ v: 1, token: null, round: null, done: 0, updatedAt: null, pass: null, passAt: 0 }), "fresh");
2520
3093
  var GAPS = "crm:gaps";
@@ -2532,26 +3105,26 @@ var scopeOf = /* @__PURE__ */ __name((error) => {
2532
3105
  const scope = error instanceof CliError ? error.details?.scope : void 0;
2533
3106
  return typeof scope === "string" && scope ? scope : void 0;
2534
3107
  }, "scopeOf");
2535
- var refusal = /* @__PURE__ */ __name((kind, consequence, error, provider) => {
3108
+ var refusal = /* @__PURE__ */ __name((kind2, consequence, error, provider) => {
2536
3109
  const code = error instanceof CliError ? error.code : "error";
2537
3110
  const scope = scopeOf(error);
2538
- const message = scope ? `${scope} scope missing: ${consequence}` : `${provider} did not list ${kind} (${code}): ${consequence}`;
2539
- return { kind, reason: "refused", code, ...scope ? { scope } : {}, message };
3111
+ const message = scope ? `${scope} scope missing: ${consequence}` : `${provider} did not list ${kind2} (${code}): ${consequence}`;
3112
+ return { kind: kind2, reason: "refused", code, ...scope ? { scope } : {}, message };
2540
3113
  }, "refusal");
2541
- var readPipelines = /* @__PURE__ */ __name(async (run, kind) => {
3114
+ var readPipelines = /* @__PURE__ */ __name(async (run, kind2) => {
2542
3115
  const why = run.budget.take();
2543
3116
  if (why)
2544
3117
  return why;
2545
- const pipelines = await run.source.pipelines(kind, run.context);
2546
- const { saved, skipped } = await run.store.crm.savePipelines(run.account, kind, pipelines);
3118
+ const pipelines2 = await run.source.pipelines(kind2, run.context);
3119
+ const { saved, skipped } = await run.store.crm.savePipelines(run.account, kind2, pipelines2);
2547
3120
  run.report.pipelines += saved;
2548
3121
  for (const one of skipped)
2549
- run.report.issues.push({ kind, ...one });
3122
+ run.report.issues.push({ kind: kind2, ...one });
2550
3123
  return null;
2551
3124
  }, "readPipelines");
2552
- var noted = /* @__PURE__ */ __name((run, kind, saved) => {
3125
+ var noted = /* @__PURE__ */ __name((run, kind2, saved) => {
2553
3126
  for (const { externalId, ...one } of saved.issues ?? [])
2554
- run.report.issues.push({ kind, ...one, ...externalId ? { externalId } : {} });
3127
+ run.report.issues.push({ kind: kind2, ...one, ...externalId ? { externalId } : {} });
2555
3128
  run.report.skippedOwnerRejected += saved.skippedOwnerRejected ?? 0;
2556
3129
  run.unlistedUsers += saved.unlistedUsers ?? 0;
2557
3130
  run.droppedPending += saved.droppedPending ?? 0;
@@ -2619,8 +3192,8 @@ var readActivities = /* @__PURE__ */ __name(async (run) => {
2619
3192
  const { source, store, account } = run;
2620
3193
  if (!source.activities || !await store.crm.activitiesOn(account))
2621
3194
  return null;
2622
- const read2 = { saved: 0, outOfScope: 0, state: "partial" };
2623
- run.report.activities = read2;
3195
+ const read = { saved: 0, outOfScope: 0, state: "partial" };
3196
+ run.report.activities = read;
2624
3197
  const saved = activityCursor((await store.sync.syncState(account, ACTIVITIES))?.value);
2625
3198
  const cursor = saved ?? { since: run.now - ACTIVITY_DAYS * DAY2, newest: 0 };
2626
3199
  for (; ; ) {
@@ -2639,8 +3212,8 @@ var readActivities = /* @__PURE__ */ __name(async (run) => {
2639
3212
  return null;
2640
3213
  }
2641
3214
  const done = await store.crm.saveActivities(account, page.items);
2642
- read2.saved += done.saved;
2643
- read2.outOfScope += done.outOfScope;
3215
+ read.saved += done.saved;
3216
+ read.outOfScope += done.outOfScope;
2644
3217
  cursor.newest = Math.max(cursor.newest, ...page.items.map((one) => one.updatedAt));
2645
3218
  run.moved();
2646
3219
  if (page.hasMore && page.nextCursor !== void 0) {
@@ -2652,7 +3225,7 @@ var readActivities = /* @__PURE__ */ __name(async (run) => {
2652
3225
  }
2653
3226
  const next = page.cursor != null ? Number(page.cursor) : cursor.newest || cursor.since;
2654
3227
  await store.sync.setSyncState(account, ACTIVITIES, JSON.stringify({ since: next, newest: 0 }));
2655
- read2.state = "complete";
3228
+ read.state = "complete";
2656
3229
  return null;
2657
3230
  }
2658
3231
  }, "readActivities");
@@ -2663,14 +3236,14 @@ var readStageHistory = /* @__PURE__ */ __name(async (run) => {
2663
3236
  if (!source.stageHistory)
2664
3237
  return null;
2665
3238
  const since = run.now - HISTORY_DAYS * DAY2;
2666
- for (const kind of DEAL_KINDS.filter((one) => source.traits.kinds.includes(one))) {
2667
- const key = `${STAGE_HISTORY}${kind}`;
3239
+ for (const kind2 of DEAL_KINDS.filter((one) => source.traits.kinds.includes(one))) {
3240
+ const key = `${STAGE_HISTORY}${kind2}`;
2668
3241
  let after = (await store.sync.syncState(account, key))?.value;
2669
3242
  for (; ; ) {
2670
3243
  const why = run.budget.take();
2671
3244
  if (why)
2672
3245
  return why;
2673
- const page = await source.stageHistory.call(source, kind, since, after, run.context);
3246
+ const page = await source.stageHistory.call(source, kind2, since, after, run.context);
2674
3247
  await store.crm.saveStageEntries(account, page.items);
2675
3248
  run.moved();
2676
3249
  const next = page.hasMore ? page.nextCursor : page.cursor ?? after;
@@ -2696,42 +3269,42 @@ var stopping = /* @__PURE__ */ __name(async (step) => {
2696
3269
  throw error;
2697
3270
  }
2698
3271
  }, "stopping");
2699
- var readFields = /* @__PURE__ */ __name(async (run, kind) => {
3272
+ var readFields = /* @__PURE__ */ __name(async (run, kind2) => {
2700
3273
  const why = run.budget.take();
2701
3274
  if (why)
2702
3275
  return why;
2703
- const fields = await run.source.fields.call(run.source, kind, run.context);
2704
- const { skipped } = await run.store.crm.saveFields(run.account, kind, fields);
3276
+ const fields2 = await run.source.fields.call(run.source, kind2, run.context);
3277
+ const { skipped } = await run.store.crm.saveFields(run.account, kind2, fields2);
2705
3278
  for (const one of skipped)
2706
- run.report.issues.push({ kind, ...one });
3279
+ run.report.issues.push({ kind: kind2, ...one });
2707
3280
  return null;
2708
3281
  }, "readFields");
2709
- var savePage = /* @__PURE__ */ __name(async (run, kind, page) => {
3282
+ var savePage = /* @__PURE__ */ __name(async (run, kind2, page) => {
2710
3283
  const { store, account } = run;
2711
- if (!isItemKind(kind)) {
2712
- const saved2 = kind === "person" ? await store.crm.savePeople(account, page.items) : await store.crm.saveOrganizations(account, page.items);
2713
- noted(run, kind, saved2);
3284
+ if (!isItemKind(kind2)) {
3285
+ const saved2 = kind2 === "person" ? await store.crm.savePeople(account, page.items) : await store.crm.saveOrganizations(account, page.items);
3286
+ noted(run, kind2, saved2);
2714
3287
  return { saved: saved2.saved, stop: null };
2715
3288
  }
2716
3289
  const items = page.items;
2717
3290
  const users = { users: run.source.users !== void 0 };
2718
- const first = await store.crm.saveItems(account, kind, items, users);
2719
- noted(run, kind, first);
3291
+ const first = await store.crm.saveItems(account, kind2, items, users);
3292
+ noted(run, kind2, first);
2720
3293
  let { saved, skipped } = first;
2721
3294
  let stop = null;
2722
- if (skipped.some(({ reason }) => reason === "crm.stage-unknown") && !run.pipelinesReread.has(kind)) {
2723
- run.pipelinesReread.add(kind);
2724
- stop = await readPipelines(run, kind);
3295
+ if (skipped.some(({ reason }) => reason === "crm.stage-unknown") && !run.pipelinesReread.has(kind2)) {
3296
+ run.pipelinesReread.add(kind2);
3297
+ stop = await readPipelines(run, kind2);
2725
3298
  if (!stop) {
2726
3299
  const again = new Set(skipped.filter(({ reason }) => reason === "crm.stage-unknown").map(({ externalId }) => externalId));
2727
- const retried = await store.crm.saveItems(account, kind, items.filter(({ externalId }) => again.has(externalId)), users);
2728
- noted(run, kind, retried);
3300
+ const retried = await store.crm.saveItems(account, kind2, items.filter(({ externalId }) => again.has(externalId)), users);
3301
+ noted(run, kind2, retried);
2729
3302
  saved += retried.saved;
2730
3303
  skipped = [...skipped.filter(({ reason }) => reason !== "crm.stage-unknown"), ...retried.skipped];
2731
3304
  }
2732
3305
  }
2733
3306
  for (const one of skipped)
2734
- run.report.issues.push({ kind, ...one });
3307
+ run.report.issues.push({ kind: kind2, ...one });
2735
3308
  return { saved, stop };
2736
3309
  }, "savePage");
2737
3310
  var scopeIds = /* @__PURE__ */ __name((scope) => scope.mode === "all" ? null : [...new Set(scope.also.length ? scope.also : [scope.self])].sort(), "scopeIds");
@@ -2748,31 +3321,31 @@ var appliedScope = /* @__PURE__ */ __name((cursor) => {
2748
3321
  }, "appliedScope");
2749
3322
  var inScope = /* @__PURE__ */ __name((ids2, item) => ids2 === null || item.assignee == null || ids2.includes(item.assignee), "inScope");
2750
3323
  var normalAssignee = /* @__PURE__ */ __name((item) => item.assignee == null ? item : { ...item, assignee: normalCrmUserId(item.assignee) }, "normalAssignee");
2751
- var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
3324
+ var syncKind = /* @__PURE__ */ __name(async (run, kind2, options, result) => {
2752
3325
  const { source, store, account, now, budget, signal } = run;
2753
- const name = cursorName(kind);
3326
+ const name = cursorName(kind2);
2754
3327
  let cursor = parseCrmCursor((await store.sync.syncState(account, name))?.value) ?? fresh();
2755
3328
  if (options.rescan)
2756
3329
  cursor = { ...cursor, round: { from: null, page: null, reset: false }, done: 0, pass: null, passAt: 0 };
2757
3330
  const scope = scopeKey(run.scope);
2758
- const ids2 = isItemKind(kind) ? scopeIds(run.scope) : null;
3331
+ const ids2 = isItemKind(kind2) ? scopeIds(run.scope) : null;
2759
3332
  const listedUnder = cursor.scope ?? "all";
2760
3333
  const before = idsOfKey(listedUnder);
2761
- const changed = isItemKind(kind) && listedUnder !== scope;
3334
+ const changed = isItemKind(kind2) && listedUnder !== scope;
2762
3335
  let held = false;
2763
- if (isItemKind(kind) && ids2 && (cursor.narrowing === true || changed && (before === null || before.some((id2) => !ids2.includes(id2))))) {
2764
- const leaving = await store.crm.removeOutOfScope(account, kind, ids2, { dryRun: true });
2765
- const stored = await store.crm.count(account, kind);
3336
+ if (isItemKind(kind2) && ids2 && (cursor.narrowing === true || changed && (before === null || before.some((id2) => !ids2.includes(id2))))) {
3337
+ const leaving = await store.crm.removeOutOfScope(account, kind2, ids2, { dryRun: true });
3338
+ const stored = await store.crm.count(account, kind2);
2766
3339
  held = !run.scopeSet && leaving > stored * MOST_UNLISTED;
2767
3340
  if (held) {
2768
3341
  result.held = true;
2769
3342
  run.report.issues.push({
2770
- kind,
3343
+ kind: kind2,
2771
3344
  reason: "crm.narrowing-held",
2772
- message: `scope mine keeps the ${kind}s of user ${ids2.join(", ")}: ${leaving} of the ${stored} stored would be marked deleted; none was, and none will be until the owner sets ${crmSettingKey(account, "scope")} to mine or all`
3345
+ message: `scope mine keeps the ${kind2}s of user ${ids2.join(", ")}: ${leaving} of the ${stored} stored would be marked deleted; none was, and none will be until the owner sets ${crmSettingKey(account, "scope")} to mine or all`
2773
3346
  });
2774
3347
  } else
2775
- result.outOfScope += await store.crm.removeOutOfScope(account, kind, ids2);
3348
+ result.outOfScope += await store.crm.removeOutOfScope(account, kind2, ids2);
2776
3349
  }
2777
3350
  if (changed || cursor.narrowing) {
2778
3351
  const widened = changed && before !== null && (ids2 === null || ids2.some((id2) => !before.includes(id2)));
@@ -2787,11 +3360,11 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2787
3360
  let round = cursor.round ?? { from: cursor.token, page: null, reset: false };
2788
3361
  if (cursor.round === null)
2789
3362
  cursor = { ...cursor, done: 0 };
2790
- let listed3 = false;
3363
+ let listed2 = false;
2791
3364
  const show = /* @__PURE__ */ __name(() => Object.assign(result, { round: round.from === null ? "full" : "changes", reset: round.reset }), "show");
2792
3365
  show();
2793
3366
  const save = /* @__PURE__ */ __name(async (patch = {}) => {
2794
- cursor = { ...cursor, round: listed3 ? null : round, updatedAt: now, ...patch };
3367
+ cursor = { ...cursor, round: listed2 ? null : round, updatedAt: now, ...patch };
2795
3368
  await store.sync.setSyncState(account, name, JSON.stringify(cursor));
2796
3369
  }, "save");
2797
3370
  let restarted = false;
@@ -2800,7 +3373,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2800
3373
  const why = budget.take();
2801
3374
  if (why)
2802
3375
  return why;
2803
- const page = await source.changes(kind, round.from, round.page ?? void 0, run.context);
3376
+ const page = await source.changes(kind2, round.from, round.page ?? void 0, run.context);
2804
3377
  if (signal?.aborted)
2805
3378
  return "cancelled";
2806
3379
  if ("reset" in page) {
@@ -2816,15 +3389,15 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2816
3389
  await save();
2817
3390
  continue;
2818
3391
  }
2819
- const items = isItemKind(kind) ? page.items.map(normalAssignee) : page.items;
2820
- const kept2 = isItemKind(kind) ? items.filter((item) => inScope(ids2, item)) : items;
2821
- const { saved, stop } = await savePage(run, kind, { ...page, items: kept2 });
3392
+ const items = isItemKind(kind2) ? page.items.map(normalAssignee) : page.items;
3393
+ const kept2 = isItemKind(kind2) ? items.filter((item) => inScope(ids2, item)) : items;
3394
+ const { saved, stop } = await savePage(run, kind2, { ...page, items: kept2 });
2822
3395
  result.saved += saved;
2823
3396
  if (page.removed?.length)
2824
- result.removed += await store.crm.remove(account, kind, page.removed);
3397
+ result.removed += await store.crm.remove(account, kind2, page.removed);
2825
3398
  if (kept2.length < items.length && !held) {
2826
3399
  const left = items.filter((item) => !inScope(ids2, item)).map(({ externalId }) => externalId);
2827
- result.outOfScope += await store.crm.remove(account, kind, left);
3400
+ result.outOfScope += await store.crm.remove(account, kind2, left);
2828
3401
  }
2829
3402
  run.moved();
2830
3403
  if (stop) {
@@ -2833,7 +3406,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2833
3406
  }
2834
3407
  cursor = { ...cursor, done: cursor.done + saved };
2835
3408
  if (!page.hasMore) {
2836
- listed3 = true;
3409
+ listed2 = true;
2837
3410
  await save({ token: page.cursor ?? null });
2838
3411
  break;
2839
3412
  }
@@ -2845,7 +3418,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2845
3418
  round = { ...round, page: page.nextCursor };
2846
3419
  await save();
2847
3420
  }
2848
- const passes = source.ids && !source.traits.removedInChanges && kind !== "person";
3421
+ const passes = source.ids && !source.traits.removedInChanges && kind2 !== "person";
2849
3422
  const due = cursor.pass !== null || now - cursor.passAt >= (options.passEvery ?? DAY2);
2850
3423
  const listedOf = held && ids2 ? { users: ids2 } : {};
2851
3424
  if (passes && due) {
@@ -2858,7 +3431,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2858
3431
  await save({ pass });
2859
3432
  return why;
2860
3433
  }
2861
- const page = await ids3.call(source, kind, pass.page ?? void 0, run.context);
3434
+ const page = await ids3.call(source, kind2, pass.page ?? void 0, run.context);
2862
3435
  if (signal?.aborted)
2863
3436
  return "cancelled";
2864
3437
  if (page.hasMore && page.nextCursor === void 0)
@@ -2870,18 +3443,18 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2870
3443
  await save({ pass });
2871
3444
  }
2872
3445
  const before2 = pass.startedAt - CLOCK_MARGIN;
2873
- const stored = await store.crm.count(account, kind);
2874
- const unlisted = await store.crm.removeUnlisted(account, kind, pass.seen, before2, { ...listedOf, dryRun: true });
3446
+ const stored = await store.crm.count(account, kind2);
3447
+ const unlisted = await store.crm.removeUnlisted(account, kind2, pass.seen, before2, { ...listedOf, dryRun: true });
2875
3448
  const emptied = pass.seen.length === 0 && unlisted > 0;
2876
3449
  if (!options.rescan && (emptied || stored >= GUARDED_FROM && unlisted > stored * MOST_UNLISTED)) {
2877
3450
  result.pass = "held";
2878
3451
  run.report.issues.push({
2879
- kind,
3452
+ kind: kind2,
2880
3453
  reason: "crm.unlisted-held",
2881
- message: `${source.provider} listed ${pass.seen.length} ${kind} ids, so ${unlisted} of the ${stored} stored would be marked deleted; nothing was \u2014 check the sign-in's rights, then run sync --rescan to let it through`
3454
+ message: `${source.provider} listed ${pass.seen.length} ${kind2} ids, so ${unlisted} of the ${stored} stored would be marked deleted; nothing was \u2014 check the sign-in's rights, then run sync --rescan to let it through`
2882
3455
  });
2883
3456
  } else {
2884
- result.unlisted = await store.crm.removeUnlisted(account, kind, pass.seen, before2, listedOf);
3457
+ result.unlisted = await store.crm.removeUnlisted(account, kind2, pass.seen, before2, listedOf);
2885
3458
  result.pass = "complete";
2886
3459
  }
2887
3460
  await save({ pass: null, passAt: pass.startedAt });
@@ -2892,7 +3465,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
2892
3465
  var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}) => {
2893
3466
  const now = options.now ?? Date.now();
2894
3467
  const budget = options.budget ?? runBudget();
2895
- const setting2 = await store.crm.scope(account);
3468
+ const setting = await store.crm.scope(account);
2896
3469
  const self = source.self ? normalCrmUserId(await source.self()) : void 0;
2897
3470
  if (self !== void 0 && !isCrmUserId(self))
2898
3471
  throw new CliError("invalid_response", `${source.provider} named its sign-in's user as "${self}", not a user id`);
@@ -2902,14 +3475,14 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
2902
3475
  if (owner === void 0)
2903
3476
  await store.crm.saveOwnUser(account, self);
2904
3477
  else if (owner !== self) {
2905
- const setting3 = crmSettingKey(account, "self");
2906
- throw new CliError("validation_error", `this account's copy is user ${owner}'s, and this sign-in is user ${self}: one copy holds one user's deals, under scope all too, since ${setting3} decides whose deals a later scope mine keeps; "config unset ${setting3}" gives the copy to this sign-in`, { setting: setting3 });
3478
+ const setting2 = crmSettingKey(account, "self");
3479
+ throw new CliError("validation_error", `this account's copy is user ${owner}'s, and this sign-in is user ${self}: one copy holds one user's deals, under scope all too, since ${setting2} decides whose deals a later scope mine keeps; "config unset ${setting2}" gives the copy to this sign-in`, { setting: setting2 });
2907
3480
  }
2908
3481
  }
2909
- const listed3 = setting2.mode === "mine" ? setting2.also.map(normalCrmUserId) : [];
2910
- const allowed = self !== void 0 && source.unassigned && listed3.length && listed3.every(isCrmUserId) ? await source.unassigned(listed3) : { kept: listed3 };
2911
- const dropped = listed3.filter((id2) => !allowed.kept.includes(id2));
2912
- const scope = self !== void 0 && setting2.mode === "mine" ? { mode: "mine", self, also: listed3.filter((id2) => !dropped.includes(id2)) } : { mode: "all" };
3482
+ const listed2 = setting.mode === "mine" ? setting.also.map(normalCrmUserId) : [];
3483
+ const allowed = self !== void 0 && source.unassigned && listed2.length && listed2.every(isCrmUserId) ? await source.unassigned(listed2) : { kept: listed2 };
3484
+ const dropped = listed2.filter((id2) => !allowed.kept.includes(id2));
3485
+ const scope = self !== void 0 && setting.mode === "mine" ? { mode: "mine", self, also: listed2.filter((id2) => !dropped.includes(id2)) } : { mode: "all" };
2913
3486
  const report = {
2914
3487
  provider: source.provider,
2915
3488
  account: account.account,
@@ -2932,7 +3505,7 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
2932
3505
  const run = {
2933
3506
  source,
2934
3507
  scope,
2935
- scopeSet: setting2.mode === "mine" && setting2.explicit,
3508
+ scopeSet: setting.mode === "mine" && setting.explicit,
2936
3509
  store,
2937
3510
  account,
2938
3511
  now,
@@ -2943,10 +3516,10 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
2943
3516
  moved: /* @__PURE__ */ __name(() => {
2944
3517
  steps += 1;
2945
3518
  }, "moved"),
2946
- gaps: CRM_KINDS.filter((kind) => !source.traits.kinds.includes(kind)).map((kind) => ({
2947
- kind,
3519
+ gaps: CRM_KINDS.filter((kind2) => !source.traits.kinds.includes(kind2)).map((kind2) => ({
3520
+ kind: kind2,
2948
3521
  reason: "not-listed",
2949
- message: `${source.provider} has no ${kind}s`
3522
+ message: `${source.provider} has no ${kind2}s`
2950
3523
  })),
2951
3524
  context: {
2952
3525
  spend: /* @__PURE__ */ __name(() => {
@@ -2954,40 +3527,40 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
2954
3527
  if (why)
2955
3528
  throw new BudgetSpent(why);
2956
3529
  }, "spend"),
2957
- gap: /* @__PURE__ */ __name(({ kind, message, scope: scope2 }) => run.gaps.push({ kind, reason: "partial", message, ...scope2 ? { scope: scope2 } : {} }), "gap"),
3530
+ gap: /* @__PURE__ */ __name(({ kind: kind2, message, scope: scope2 }) => run.gaps.push({ kind: kind2, reason: "partial", message, ...scope2 ? { scope: scope2 } : {} }), "gap"),
2958
3531
  scope
2959
3532
  },
2960
3533
  unlistedUsers: 0,
2961
3534
  droppedPending: 0
2962
3535
  };
2963
- const kinds = CRM_KINDS.filter((kind) => source.traits.kinds.includes(kind));
2964
- const cursors = await Promise.all(kinds.map((kind) => store.sync.syncState(account, cursorName(kind))));
3536
+ const kinds = CRM_KINDS.filter((kind2) => source.traits.kinds.includes(kind2));
3537
+ const cursors = await Promise.all(kinds.map((kind2) => store.sync.syncState(account, cursorName(kind2))));
2965
3538
  const first = cursors.every((cursor) => cursor === void 0);
2966
- const malformed = scope.mode === "mine" && setting2.mode === "mine" ? setting2.also.find((id2) => !isCrmUserId(id2)) : void 0;
3539
+ const malformed = scope.mode === "mine" && setting.mode === "mine" ? setting.also.find((id2) => !isCrmUserId(id2)) : void 0;
2967
3540
  let stopped = null;
2968
- for (const kind of DEAL_KINDS)
2969
- if (!stopped && kinds.includes(kind)) {
2970
- stopped = await stopping(() => readPipelines(run, kind));
3541
+ for (const kind2 of DEAL_KINDS)
3542
+ if (!stopped && kinds.includes(kind2)) {
3543
+ stopped = await stopping(() => readPipelines(run, kind2));
2971
3544
  if (options.signal?.aborted)
2972
3545
  stopped = "cancelled";
2973
3546
  }
2974
3547
  if (run.source.fields) {
2975
- for (const kind of kinds)
3548
+ for (const kind2 of kinds)
2976
3549
  if (!stopped) {
2977
- stopped = await stopping(() => readFields(run, kind));
3550
+ stopped = await stopping(() => readFields(run, kind2));
2978
3551
  if (options.signal?.aborted)
2979
3552
  stopped = "cancelled";
2980
3553
  }
2981
3554
  }
2982
3555
  let usersRead = false;
2983
- for (const kind of kinds) {
2984
- if (!usersRead && isItemKind(kind)) {
3556
+ for (const kind2 of kinds) {
3557
+ if (!usersRead && isItemKind(kind2)) {
2985
3558
  usersRead = true;
2986
3559
  if (!stopped)
2987
3560
  stopped = await stopping(() => readUsers(run));
2988
3561
  }
2989
3562
  const result = {
2990
- kind,
3563
+ kind: kind2,
2991
3564
  round: "changes",
2992
3565
  reset: false,
2993
3566
  state: "partial",
@@ -2999,17 +3572,17 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
2999
3572
  report.synced.push(result);
3000
3573
  if (stopped)
3001
3574
  continue;
3002
- if (malformed !== void 0 && isItemKind(kind)) {
3575
+ if (malformed !== void 0 && isItemKind(kind2)) {
3003
3576
  Object.assign(result, {
3004
- error: `unassigned holds "${malformed}", not a numeric user id: no ${kind} was read`,
3577
+ error: `unassigned holds "${malformed}", not a numeric user id: no ${kind2} was read`,
3005
3578
  setting: crmSettingKey(account, "unassigned")
3006
3579
  });
3007
3580
  continue;
3008
3581
  }
3009
3582
  try {
3010
- stopped = await syncKind(run, kind, options, result);
3011
- if (kind === "organization")
3012
- noted(run, kind, await store.crm.saveCompanyTypes(account));
3583
+ stopped = await syncKind(run, kind2, options, result);
3584
+ if (kind2 === "organization")
3585
+ noted(run, kind2, await store.crm.saveCompanyTypes(account));
3013
3586
  } catch (error) {
3014
3587
  if (options.signal?.aborted) {
3015
3588
  stopped = "cancelled";
@@ -3020,8 +3593,8 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
3020
3593
  continue;
3021
3594
  }
3022
3595
  if (scopeOf(error))
3023
- run.gaps.push(refusal(kind, `no ${kind} was read`, error, source.provider));
3024
- result.error = isCliFailure(error) ? error.message : `the ${kind} copy could not be synced`;
3596
+ run.gaps.push(refusal(kind2, `no ${kind2} was read`, error, source.provider));
3597
+ result.error = isCliFailure(error) ? error.message : `the ${kind2} copy could not be synced`;
3025
3598
  }
3026
3599
  }
3027
3600
  run.droppedPending += (await store.crm.retryPending(account)).dropped;
@@ -3093,28 +3666,28 @@ var SYNC_FAILED = "crm:sync-failed";
3093
3666
  var SYNCED_FROM = "crm:synced-from";
3094
3667
  var syncRecorded = /* @__PURE__ */ __name(async (...args) => {
3095
3668
  const [, store, account, options] = args;
3096
- const at = options?.now ?? Date.now();
3097
- const record = /* @__PURE__ */ __name((kinds) => store.sync.setSyncState(account, SYNC_FAILED, kinds.length ? JSON.stringify({ at, kinds }) : "").catch(() => void 0), "record");
3669
+ const at2 = options?.now ?? Date.now();
3670
+ const record2 = /* @__PURE__ */ __name((kinds) => store.sync.setSyncState(account, SYNC_FAILED, kinds.length ? JSON.stringify({ at: at2, kinds }) : "").catch(() => void 0), "record");
3098
3671
  try {
3099
3672
  const report = await syncCrm(...args);
3100
3673
  const failed = report.synced.filter((one) => one.error !== void 0).map((one) => one.kind);
3101
- await record(failed);
3674
+ await record2(failed);
3102
3675
  if (report.state === "complete" && !failed.length)
3103
- await store.sync.setSyncState(account, SYNCED_FROM, String(at));
3676
+ await store.sync.setSyncState(account, SYNCED_FROM, String(at2));
3104
3677
  return report;
3105
3678
  } catch (error) {
3106
- await record(["all"]);
3679
+ await record2(["all"]);
3107
3680
  throw error;
3108
3681
  }
3109
3682
  }, "syncRecorded");
3110
3683
  var crmStatus = /* @__PURE__ */ __name(async (store, account, { profile, now, kinds = CRM_KINDS }) => {
3111
3684
  const saved = await store.crm.scope(account);
3112
- const setting2 = { setting: saved.mode, explicit: saved.mode === "all" || saved.explicit };
3685
+ const setting = { setting: saved.mode, explicit: saved.mode === "all" || saved.explicit };
3113
3686
  const items = [];
3114
- for (const kind of kinds) {
3115
- const cursor = parseCrmCursor((await store.sync.syncState(account, cursorName(kind)))?.value);
3687
+ for (const kind2 of kinds) {
3688
+ const cursor = parseCrmCursor((await store.sync.syncState(account, cursorName(kind2)))?.value);
3116
3689
  const progress = progressOf({
3117
- job: `crm ${kind}`,
3690
+ job: `crm ${kind2}`,
3118
3691
  profile,
3119
3692
  done: cursor?.done ?? 0,
3120
3693
  complete: cursor !== null && cursor.round === null && cursor.pass === null,
@@ -3122,11 +3695,11 @@ var crmStatus = /* @__PURE__ */ __name(async (store, account, { profile, now, ki
3122
3695
  now: new Date(now)
3123
3696
  });
3124
3697
  items.push({
3125
- kind,
3698
+ kind: kind2,
3126
3699
  round: cursor?.round ? cursor.round.from === null ? "full" : "changes" : null,
3127
3700
  id_pass: cursor?.pass ? "partial" : cursor?.passAt ? new Date(cursor.passAt).toISOString() : null,
3128
- stored: await store.crm.count(account, kind),
3129
- ...isItemKind(kind) ? { scope: { ...setting2, applied: appliedScope(cursor), ...cursor?.narrowing ? { held: true } : {} } } : {},
3701
+ stored: await store.crm.count(account, kind2),
3702
+ ...isItemKind(kind2) ? { scope: { ...setting, applied: appliedScope(cursor), ...cursor?.narrowing ? { held: true } : {} } } : {},
3130
3703
  ...progress,
3131
3704
  line: progressLine(progress)
3132
3705
  });
@@ -3145,44 +3718,39 @@ export {
3145
3718
  listContextOf,
3146
3719
  listedAccounts,
3147
3720
  accountsOfKind,
3148
- momentOf,
3149
- dateWindow,
3150
3721
  parseCrmFileId,
3151
3722
  withoutFileLinks,
3152
3723
  foreignContactsPathFor,
3153
3724
  foreignContacts,
3154
3725
  refuseForeignClientReads,
3726
+ values_exports,
3727
+ at,
3728
+ identifier,
3729
+ graphqlDocument,
3730
+ LosslessNumber,
3731
+ isLosslessNumber,
3732
+ apiFlagOf,
3733
+ apiOptionKey,
3734
+ checkApiParameter,
3735
+ sendsBytes,
3736
+ readApiBytes,
3737
+ readApiBody,
3738
+ checkApiBody,
3739
+ parseApiJson,
3740
+ apiJson,
3741
+ apiPlainJson,
3742
+ graphqlVariables,
3743
+ manifestBaseUrl,
3744
+ siteValue,
3745
+ signRequest,
3746
+ underBase,
3747
+ parameterValue,
3748
+ nextPage,
3155
3749
  DEFAULT_PACE,
3156
3750
  pacePathFor,
3157
3751
  Pacer,
3158
3752
  waitForTurn,
3159
3753
  providerCall,
3160
- meetingPassageRequest,
3161
- createMeetingPassageCommand,
3162
- meetingHitSearchRequest,
3163
- meetingSearchArguments,
3164
- meetingSearchMeta,
3165
- createMeetingSearchCommand,
3166
- addMeetingCommands,
3167
- LIST_QUERY_GUIDE,
3168
- QUERY_ARGUMENT,
3169
- withQuery,
3170
- unfilteredQuery,
3171
- commandPath,
3172
- listQuery,
3173
- typedQuery,
3174
- pageOf,
3175
- pagedList,
3176
- queryArgument,
3177
- negatableOf,
3178
- nativeTerms,
3179
- nativeTermLists,
3180
- queryTerms,
3181
- timeBounds,
3182
- searchText,
3183
- nativeField,
3184
- termField,
3185
- queryHelp,
3186
3754
  holdEnd,
3187
3755
  floodPathFor,
3188
3756
  FloodMemory,
@@ -3227,6 +3795,5 @@ export {
3227
3795
  SYNC_FAILED,
3228
3796
  SYNCED_FROM,
3229
3797
  syncRecorded,
3230
- crmStatus,
3231
- values_exports
3798
+ crmStatus
3232
3799
  };