@wirecat/hubspot-cli 0.4.0 → 0.6.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 (178) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +75 -54
  3. package/contracts/wirecat.json +39 -13
  4. package/dist/bin/hubspot.js +2 -2
  5. package/dist/bundle/agent-XB35QVOK.js +40 -0
  6. package/dist/bundle/{all-profiles-JVEE4PXX.js → all-profiles-HFVXPMF6.js} +11 -11
  7. package/dist/bundle/{anthropic-6HT57GNF.js → anthropic-VE6WR6IN.js} +5 -5
  8. package/dist/bundle/{app-server-FOBFF6G6.js → app-server-GZ4DCQK7.js} +68 -68
  9. package/dist/bundle/{bun-GW443QB3.js → bun-2DHMKD34.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-TGIAICDN.js → bun-sqlite-T5XTYL7L.js} +6 -6
  11. package/dist/bundle/{chunk-FK4LEJZM.js → chunk-24HPBWKZ.js} +63 -4
  12. package/dist/bundle/{chunk-4OPN3KCN.js → chunk-2I2KBCS6.js} +5 -5
  13. package/dist/bundle/{chunk-3BM6KBWP.js → chunk-2K5BAY32.js} +19 -19
  14. package/dist/bundle/{chunk-6ULR7N3T.js → chunk-2VUIJ5XB.js} +2 -2
  15. package/dist/bundle/{chunk-UHHXZKB2.js → chunk-3HS7JTPI.js} +27 -177
  16. package/dist/bundle/{chunk-3SRGN5MQ.js → chunk-3TLNO3VM.js} +2 -2
  17. package/dist/bundle/{chunk-ATGD64VO.js → chunk-3W5R3XAH.js} +8 -8
  18. package/dist/bundle/{chunk-CFQQTDSA.js → chunk-3WG4MTQI.js} +1 -1
  19. package/dist/bundle/{chunk-NL3RKJR6.js → chunk-3YTTWJKL.js} +1 -1
  20. package/dist/bundle/{chunk-5WKJFMC3.js → chunk-4UEYVM46.js} +4 -4
  21. package/dist/bundle/{chunk-5G4L6NQJ.js → chunk-5ILCAAY4.js} +35 -35
  22. package/dist/bundle/{chunk-ETKLP4VE.js → chunk-5IPB5WLB.js} +14 -14
  23. package/dist/bundle/{chunk-N4EIJ53V.js → chunk-5NIIXJV3.js} +2 -2
  24. package/dist/bundle/{chunk-QIFCH5DZ.js → chunk-5O5WYSSO.js} +1967 -654
  25. package/dist/bundle/{chunk-XMWMA2N5.js → chunk-5VTKBGPW.js} +90 -33
  26. package/dist/bundle/{chunk-M25KVDHA.js → chunk-5WDNG4QE.js} +7 -7
  27. package/dist/bundle/{chunk-WATDMTDC.js → chunk-67YPTVGP.js} +3 -3
  28. package/dist/bundle/{chunk-3MUHCLRY.js → chunk-6DABKZYH.js} +143 -8
  29. package/dist/bundle/{chunk-HVXOA4FO.js → chunk-745FMNI5.js} +1 -1
  30. package/dist/bundle/{chunk-5KLNBGPU.js → chunk-AKSWXRIU.js} +1 -1
  31. package/dist/bundle/{chunk-HM6AMYHR.js → chunk-AP3CWDRK.js} +2 -2
  32. package/dist/bundle/{chunk-HPRKSL5S.js → chunk-BM5F2ZNI.js} +2 -2
  33. package/dist/bundle/{chunk-FOLKK6FW.js → chunk-BU5CEMUH.js} +20 -14
  34. package/dist/bundle/{chunk-DBPFHJXX.js → chunk-CTN4DW2F.js} +4 -4
  35. package/dist/bundle/{chunk-QJHRRJKD.js → chunk-CU76ZACK.js} +3 -3
  36. package/dist/bundle/{chunk-7QH5BZUG.js → chunk-DIKUPU3T.js} +3 -3
  37. package/dist/bundle/{chunk-JWO3PB5Z.js → chunk-E27NRLJZ.js} +18 -18
  38. package/dist/bundle/{chunk-EU7AVWSX.js → chunk-EB53G4HO.js} +2 -2
  39. package/dist/bundle/{chunk-GJSHLF43.js → chunk-EJZIEBAR.js} +8 -8
  40. package/dist/bundle/{chunk-HQYJ66ZX.js → chunk-G6LDK6DJ.js} +18 -8
  41. package/dist/bundle/{chunk-VDAYIXV4.js → chunk-GEJI27GN.js} +6 -6
  42. package/dist/bundle/{chunk-XJVFXHDI.js → chunk-GHXTNKX2.js} +2 -2
  43. package/dist/bundle/{chunk-W5X37TBC.js → chunk-GR4HZBWO.js} +2 -2
  44. package/dist/bundle/{chunk-WBUVNKHJ.js → chunk-GWXTVO43.js} +7 -7
  45. package/dist/bundle/{chunk-2Q2XIXDL.js → chunk-H4W2OO35.js} +1 -1
  46. package/dist/bundle/{chunk-3LMW7U7F.js → chunk-H5HBZCEJ.js} +21 -8
  47. package/dist/bundle/{chunk-JKNUCEII.js → chunk-HX2BE7DO.js} +1 -1
  48. package/dist/bundle/{chunk-PQUZ2YDC.js → chunk-HYDXA624.js} +6 -6
  49. package/dist/bundle/{chunk-Z3YOKGVZ.js → chunk-HZIGGAC7.js} +2 -2
  50. package/dist/bundle/{chunk-AT43MYQL.js → chunk-I75ON7VM.js} +8 -8
  51. package/dist/bundle/{chunk-PKFLSX5F.js → chunk-ID4GJFE7.js} +8 -8
  52. package/dist/bundle/{chunk-A6PVEUGN.js → chunk-J2SCELII.js} +17 -17
  53. package/dist/bundle/{chunk-PMJCZIV4.js → chunk-J4FXBF44.js} +1 -1
  54. package/dist/bundle/{chunk-DG4RBKIV.js → chunk-J76CMNWQ.js} +1 -1
  55. package/dist/bundle/{chunk-MQACXJLG.js → chunk-JDCFHZNU.js} +10 -10
  56. package/dist/bundle/{chunk-K4DWBOO6.js → chunk-JFLKTYH5.js} +6 -6
  57. package/dist/bundle/{chunk-LS4S7PAP.js → chunk-K4Y2ZWOO.js} +3 -3
  58. package/dist/bundle/{chunk-5ZVYIA56.js → chunk-KDW7B7AR.js} +5 -5
  59. package/dist/bundle/{chunk-BXZRSXBL.js → chunk-KKMOKSS5.js} +3 -3
  60. package/dist/bundle/{chunk-EBJYK7UM.js → chunk-LHY5XGIR.js} +78 -63
  61. package/dist/bundle/{chunk-V23OHBGM.js → chunk-LTU4BQ4S.js} +3 -3
  62. package/dist/bundle/{chunk-LX7QMRRG.js → chunk-M3LRSN6J.js} +13 -13
  63. package/dist/bundle/{chunk-UIWWAT3C.js → chunk-MJ24YFXZ.js} +7 -7
  64. package/dist/bundle/{chunk-YYYRE4AV.js → chunk-MSQGZHKM.js} +32 -28
  65. package/dist/bundle/{chunk-6NUXFVJQ.js → chunk-NQOQG7L3.js} +1 -1
  66. package/dist/bundle/{chunk-WLFYEAZ6.js → chunk-PDVMYIBP.js} +1516 -745
  67. package/dist/bundle/{chunk-QODPEZC5.js → chunk-PR7ZDMGF.js} +10 -3
  68. package/dist/bundle/{chunk-2BCWK5BF.js → chunk-PZ3QJDTD.js} +8 -8
  69. package/dist/bundle/{chunk-OLDIP4CV.js → chunk-Q6AC7WLD.js} +3 -3
  70. package/dist/bundle/{chunk-X5U7GLHD.js → chunk-QH47G73D.js} +16 -3
  71. package/dist/bundle/{chunk-RFGIUCKU.js → chunk-QK5HQUHB.js} +3 -3
  72. package/dist/bundle/{chunk-3MPMYAII.js → chunk-R26OEZOL.js} +1 -1
  73. package/dist/bundle/{chunk-T3GZKV5A.js → chunk-RLK2EGQD.js} +21 -15
  74. package/dist/bundle/{chunk-Z4PY5BDP.js → chunk-RLNPTES2.js} +4 -4
  75. package/dist/bundle/{chunk-XCDRFC6G.js → chunk-T4MZJMEJ.js} +17 -17
  76. package/dist/bundle/{chunk-TAF4PKDS.js → chunk-TAPQZYXY.js} +1 -1
  77. package/dist/bundle/{chunk-AV2ZJ4WX.js → chunk-TCSVW7BA.js} +1 -1
  78. package/dist/bundle/{chunk-E33KM3DB.js → chunk-THGAVPRA.js} +11 -11
  79. package/dist/bundle/{chunk-XDDTJYGA.js → chunk-TRLV5NWZ.js} +2477 -2140
  80. package/dist/bundle/{chunk-5OBVICFK.js → chunk-TT75CEYZ.js} +22 -1
  81. package/dist/bundle/{chunk-7OJ43BAH.js → chunk-TXO4CJW3.js} +7 -7
  82. package/dist/bundle/{chunk-F4ZLRS4B.js → chunk-UCGZRZJA.js} +1 -1
  83. package/dist/bundle/{chunk-NLZADZ4F.js → chunk-UVGJL753.js} +61 -61
  84. package/dist/bundle/{chunk-VMF2UIQI.js → chunk-UZ2CL435.js} +3 -4
  85. package/dist/bundle/{chunk-IED6MKPU.js → chunk-V7N2K5OT.js} +33 -30
  86. package/dist/bundle/{chunk-QV4GDVBN.js → chunk-VR2CJFVL.js} +8 -8
  87. package/dist/bundle/{chunk-7JVKQ6NM.js → chunk-WASBOYI2.js} +4 -4
  88. package/dist/bundle/{chunk-F3HJ2E3P.js → chunk-WE4JSHIG.js} +6 -6
  89. package/dist/bundle/{chunk-FWW2CUXH.js → chunk-X2QRCFGJ.js} +4 -4
  90. package/dist/bundle/{chunk-V2B2OWTC.js → chunk-XRFYVVFU.js} +2 -2
  91. package/dist/bundle/{chunk-Q7DIEU6L.js → chunk-YDG5FIQB.js} +7 -9
  92. package/dist/bundle/{chunk-GOOXUCJW.js → chunk-YIH2A2PQ.js} +2 -2
  93. package/dist/bundle/{chunk-HM72O37C.js → chunk-ZERQSELP.js} +207 -163
  94. package/dist/bundle/{chunk-QNQ4V4UT.js → chunk-ZKTYTOF4.js} +8 -8
  95. package/dist/bundle/command-contract-5FXCYQUS.js +40 -0
  96. package/dist/bundle/{command-server-entry-OJQ55UA2.js → command-server-entry-H6IAJNOF.js} +28 -28
  97. package/dist/bundle/{decode-CDQDRPRJ.js → decode-TR2EC46M.js} +5 -5
  98. package/dist/bundle/{dispatch-JQBAZWCL.js → dispatch-B2EP6DDT.js} +8 -8
  99. package/dist/bundle/{echarts-GJ5JJG2A.js → echarts-7OP7I5B2.js} +2 -2
  100. package/dist/bundle/{embed-BUQXGMKR.js → embed-FLGS4LN7.js} +6 -6
  101. package/dist/bundle/{embedder-FCX6LE4O.js → embedder-JIXQXCP3.js} +9 -9
  102. package/dist/bundle/{failure-I6AAF5R5.js → failure-AOACEURF.js} +2 -2
  103. package/dist/bundle/{first-run-RPYEXXQK.js → first-run-XJ2NWIK2.js} +12 -12
  104. package/dist/bundle/first-screen-U73G5CMM.js +40 -0
  105. package/dist/bundle/hubspot.js +27 -25
  106. package/dist/bundle/{instructions-LPVTPERS.js → instructions-PYCYV6QE.js} +1 -1
  107. package/dist/bundle/{mcp-YGOAUNC3.js → mcp-ZNULRPZ4.js} +2 -2
  108. package/dist/bundle/meeting-combined-IHTM5H5B.js +25 -0
  109. package/dist/bundle/{meeting-model-TRGBEWCY.js → meeting-model-2PA5WJY5.js} +11 -11
  110. package/dist/bundle/{meeting-semantic-RSF5KNKD.js → meeting-semantic-5IH63QFV.js} +6 -6
  111. package/dist/bundle/{node-UAT3EIAP.js → node-6GTNIVBM.js} +2 -2
  112. package/dist/bundle/{node-sqlite-3HKDQNFD.js → node-sqlite-FBCEHPNT.js} +7 -7
  113. package/dist/bundle/{oauth-DYW2NSZP.js → oauth-BFP4SCL5.js} +7 -7
  114. package/dist/bundle/{open-KBRXJ5BC.js → open-MLU4MHGO.js} +5 -5
  115. package/dist/bundle/{openai-YNCLRTSK.js → openai-R7WJI6SO.js} +15 -15
  116. package/dist/bundle/{process-63BB7LKP.js → process-NMNQLJHZ.js} +1 -1
  117. package/dist/bundle/{program-VX52OB3O.js → program-Z735HPFG.js} +517 -343
  118. package/dist/bundle/{prompt-TWLJ3M2O.js → prompt-A6RM55Q4.js} +5 -5
  119. package/dist/bundle/{recognize-GQ6DLGE7.js → recognize-ORRDV45M.js} +4 -4
  120. package/dist/bundle/{remote-RKNSF3TT.js → remote-UF3WSC4X.js} +9 -9
  121. package/dist/bundle/{rerank-H4HSGQUJ.js → rerank-ZSJORUGH.js} +7 -7
  122. package/dist/bundle/{schemas-LDK7O6VW.js → schemas-EXBNVPMI.js} +1 -1
  123. package/dist/bundle/{serve-4ZNIAL7H.js → serve-4KBJ6SIA.js} +9 -9
  124. package/dist/bundle/{server-4G4QB3QN.js → server-IFK4S6LJ.js} +60 -60
  125. package/dist/bundle/server-MNUAZWTN.js +86 -0
  126. package/dist/bundle/source-PBCQAG4C.js +426 -0
  127. package/dist/bundle/{sqlite-runtime-C2JYC7JF.js → sqlite-runtime-XPDUWOPG.js} +6 -6
  128. package/dist/bundle/{state-3KDXCXHG.js → state-4M26H7NL.js} +6 -6
  129. package/dist/bundle/{store-LXLG5HTS.js → store-3W4ZOOIB.js} +28 -24
  130. package/dist/bundle/store-CDY2PW6J.js +34 -0
  131. package/dist/bundle/{store-J5FQBZYR.js → store-ICTY3RIF.js} +22 -22
  132. package/dist/bundle/store-maintenance-command-Y7TC3I43.js +73 -0
  133. package/dist/bundle/surface-4LNDJZD2.js +72 -0
  134. package/dist/bundle/writer-WGHWQTC2.js +86 -0
  135. package/dist/commands/account.d.ts +3 -2
  136. package/dist/commands/account.d.ts.map +1 -1
  137. package/dist/commands/account.js +31 -78
  138. package/dist/commands/account.js.map +1 -1
  139. package/dist/commands/crm-shared.d.ts.map +1 -1
  140. package/dist/commands/crm-shared.js +2 -0
  141. package/dist/commands/crm-shared.js.map +1 -1
  142. package/dist/commands/session.d.ts +0 -3
  143. package/dist/commands/session.d.ts.map +1 -1
  144. package/dist/commands/session.js +4 -31
  145. package/dist/commands/session.js.map +1 -1
  146. package/dist/config.d.ts.map +1 -1
  147. package/dist/config.js +19 -12
  148. package/dist/config.js.map +1 -1
  149. package/dist/crm/activities.d.ts +6 -1
  150. package/dist/crm/activities.d.ts.map +1 -1
  151. package/dist/crm/activities.js +36 -0
  152. package/dist/crm/activities.js.map +1 -1
  153. package/dist/crm/writer.d.ts +1 -1
  154. package/dist/crm/writer.d.ts.map +1 -1
  155. package/dist/crm/writer.js +69 -1
  156. package/dist/crm/writer.js.map +1 -1
  157. package/dist/program.d.ts.map +1 -1
  158. package/dist/program.js +0 -2
  159. package/dist/program.js.map +1 -1
  160. package/dist/reasons.d.ts.map +1 -1
  161. package/dist/reasons.js +0 -2
  162. package/dist/reasons.js.map +1 -1
  163. package/dist/version.d.ts +1 -1
  164. package/dist/version.js +1 -1
  165. package/package.json +4 -4
  166. package/skills/hubspot-cli/SKILL.md +10 -5
  167. package/skills/hubspot-cli/references/api/api-basic.md +2 -2
  168. package/skills/hubspot-cli/references/api/api-batch.md +2 -2
  169. package/dist/bundle/agent-NST4YXJR.js +0 -40
  170. package/dist/bundle/command-contract-LYX2QNIA.js +0 -40
  171. package/dist/bundle/first-screen-Y4EH3HZS.js +0 -40
  172. package/dist/bundle/meeting-combined-FEEVVUGC.js +0 -25
  173. package/dist/bundle/server-3IYIZEEQ.js +0 -86
  174. package/dist/bundle/source-2UCNCCO7.js +0 -917
  175. package/dist/bundle/store-2MNUHHZC.js +0 -32
  176. package/dist/bundle/store-maintenance-command-DDB7TR6V.js +0 -73
  177. package/dist/bundle/surface-ZTZANYKC.js +0 -72
  178. package/dist/bundle/writer-X7PGBLDH.js +0 -86
@@ -1,17 +1,19 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
- HUBSPOT_WRITES
5
- } from "./chunk-FK4LEJZM.js";
4
+ PROVIDER
5
+ } from "./chunk-K4Y2ZWOO.js";
6
6
  import {
7
7
  accountDetails
8
- } from "./chunk-W5X37TBC.js";
8
+ } from "./chunk-GR4HZBWO.js";
9
+ import {
10
+ HUBSPOT_WRITES
11
+ } from "./chunk-24HPBWKZ.js";
9
12
  import {
10
13
  LONGEST_PACE_WAIT_MS,
11
14
  PACE,
12
15
  ProfileTokenStore,
13
16
  REPORT_FORMAT,
14
- SECTION_CAPS,
15
17
  SERVICE,
16
18
  accountRemoveCommand,
17
19
  appDoctorCommand,
@@ -26,50 +28,44 @@ import {
26
28
  honoursDryRun,
27
29
  hubspotTransport,
28
30
  isRecord,
31
+ oauthAccount,
29
32
  ownerLanguageOf,
30
33
  run,
31
34
  runsCommand,
32
35
  scheduleCommandFor,
33
36
  searchAllOptions,
34
37
  serviceApiCommand,
35
- serviceApiPermissions,
36
38
  setupCommand,
37
39
  skillCommand,
38
40
  upgradeCommand,
39
41
  writeCsv
40
- } from "./chunk-XDDTJYGA.js";
41
- import "./chunk-NL3RKJR6.js";
42
- import {
43
- PROVIDER
44
- } from "./chunk-LS4S7PAP.js";
45
- import "./chunk-VMF2UIQI.js";
42
+ } from "./chunk-TRLV5NWZ.js";
43
+ import "./chunk-3YTTWJKL.js";
44
+ import "./chunk-UZ2CL435.js";
46
45
  import {
47
46
  SOURCE_SEARCHED,
48
47
  allAnswer,
49
48
  historySkipsOf,
50
49
  offsetOf,
51
50
  refuseOffline
52
- } from "./chunk-YYYRE4AV.js";
53
- import "./chunk-F3HJ2E3P.js";
54
- import "./chunk-ATGD64VO.js";
55
- import "./chunk-TAF4PKDS.js";
51
+ } from "./chunk-MSQGZHKM.js";
52
+ import "./chunk-WE4JSHIG.js";
53
+ import "./chunk-3W5R3XAH.js";
54
+ import "./chunk-TAPQZYXY.js";
56
55
  import {
57
56
  addStoreMaintenanceCommands
58
- } from "./chunk-EBJYK7UM.js";
59
- import {
60
- commandPathKey,
61
- commandPermissions,
62
- terminalAsker
63
- } from "./chunk-UHHXZKB2.js";
64
- import "./chunk-QV4GDVBN.js";
65
- import "./chunk-7OJ43BAH.js";
66
- import "./chunk-ETKLP4VE.js";
67
- import "./chunk-EU7AVWSX.js";
68
- import "./chunk-FWW2CUXH.js";
69
- import "./chunk-5ZVYIA56.js";
70
- import "./chunk-PKFLSX5F.js";
57
+ } from "./chunk-LHY5XGIR.js";
58
+ import "./chunk-3HS7JTPI.js";
59
+ import "./chunk-VR2CJFVL.js";
60
+ import "./chunk-TXO4CJW3.js";
61
+ import "./chunk-5IPB5WLB.js";
62
+ import "./chunk-EB53G4HO.js";
63
+ import "./chunk-X2QRCFGJ.js";
64
+ import "./chunk-KDW7B7AR.js";
65
+ import "./chunk-ID4GJFE7.js";
71
66
  import {
72
67
  CRM_ASSIGN_OTHERS_KEY,
68
+ CRM_SHARED_FOLDERS,
73
69
  CRM_WRITE_DEFAULTS,
74
70
  CRM_WRITE_KEYS,
75
71
  Pacer,
@@ -77,7 +73,11 @@ import {
77
73
  SYNCED_FROM,
78
74
  SYNC_FAILED,
79
75
  closeCrmItem,
76
+ commandPathKey,
77
+ commandPermissions,
78
+ completeCrmActivity,
80
79
  conditionsOf,
80
+ createCrmActivity,
81
81
  createCrmItem,
82
82
  createCrmRecord,
83
83
  crmAccounts,
@@ -103,27 +103,29 @@ import {
103
103
  removeCrmItem,
104
104
  searchAll,
105
105
  selectedCodes,
106
+ serviceApiPermissions,
106
107
  shortened,
107
108
  syncRecorded,
108
109
  taskAccount,
110
+ terminalAsker,
109
111
  updateCrmItem,
110
112
  updateCrmRecord,
111
113
  viewerOf,
112
114
  wantedCodes,
113
115
  withCustomFields,
114
116
  withReadableDeal
115
- } from "./chunk-QIFCH5DZ.js";
117
+ } from "./chunk-5O5WYSSO.js";
116
118
  import {
117
119
  safeName
118
- } from "./chunk-LX7QMRRG.js";
119
- import "./chunk-JKNUCEII.js";
120
- import "./chunk-5OBVICFK.js";
120
+ } from "./chunk-M3LRSN6J.js";
121
+ import "./chunk-HX2BE7DO.js";
122
+ import "./chunk-TT75CEYZ.js";
121
123
  import {
122
124
  latestVersion,
123
125
  runUpdate,
124
126
  updateNotice
125
- } from "./chunk-7QH5BZUG.js";
126
- import "./chunk-CFQQTDSA.js";
127
+ } from "./chunk-DIKUPU3T.js";
128
+ import "./chunk-3WG4MTQI.js";
127
129
  import {
128
130
  commandPath,
129
131
  dateWindow,
@@ -136,15 +138,16 @@ import {
136
138
  timeBounds,
137
139
  typedQuery,
138
140
  unfilteredQuery,
139
- withQuery
140
- } from "./chunk-FOLKK6FW.js";
141
- import "./chunk-RFGIUCKU.js";
142
- import "./chunk-VDAYIXV4.js";
143
- import "./chunk-E33KM3DB.js";
144
- import "./chunk-OLDIP4CV.js";
145
- import "./chunk-Z4PY5BDP.js";
146
- import "./chunk-X5U7GLHD.js";
147
- import "./chunk-4OPN3KCN.js";
141
+ withQuery,
142
+ withWords
143
+ } from "./chunk-BU5CEMUH.js";
144
+ import "./chunk-QK5HQUHB.js";
145
+ import "./chunk-GEJI27GN.js";
146
+ import "./chunk-THGAVPRA.js";
147
+ import "./chunk-Q6AC7WLD.js";
148
+ import "./chunk-RLNPTES2.js";
149
+ import "./chunk-QH47G73D.js";
150
+ import "./chunk-2I2KBCS6.js";
148
151
  import {
149
152
  Argument,
150
153
  Command,
@@ -156,7 +159,6 @@ import {
156
159
  Option,
157
160
  REMOTE_READ,
158
161
  REMOTE_WRITE,
159
- accountFileFor,
160
162
  annotate,
161
163
  annotateOption,
162
164
  answerEntity,
@@ -176,6 +178,7 @@ import {
176
178
  profileFree,
177
179
  profilesHere,
178
180
  readOnlyLockOf,
181
+ recalledAccount,
179
182
  refuseCommandName,
180
183
  refuseUnderReadOnly,
181
184
  rememberAccount,
@@ -188,13 +191,13 @@ import {
188
191
  sharedCommand,
189
192
  snakeKeys,
190
193
  snakeKeysKeeping
191
- } from "./chunk-HM72O37C.js";
192
- import "./chunk-AT43MYQL.js";
193
- import "./chunk-WATDMTDC.js";
194
- import "./chunk-2BCWK5BF.js";
195
- import "./chunk-PMJCZIV4.js";
196
- import "./chunk-XCDRFC6G.js";
197
- import "./chunk-BXZRSXBL.js";
194
+ } from "./chunk-ZERQSELP.js";
195
+ import "./chunk-I75ON7VM.js";
196
+ import "./chunk-67YPTVGP.js";
197
+ import "./chunk-PZ3QJDTD.js";
198
+ import "./chunk-J4FXBF44.js";
199
+ import "./chunk-T4MZJMEJ.js";
200
+ import "./chunk-KKMOKSS5.js";
198
201
  import {
199
202
  CRM_CHANGES,
200
203
  CRM_SCOPES,
@@ -204,48 +207,48 @@ import {
204
207
  crmSettingKey,
205
208
  seenBy,
206
209
  viewerSql
207
- } from "./chunk-WLFYEAZ6.js";
208
- import "./chunk-QNQ4V4UT.js";
210
+ } from "./chunk-PDVMYIBP.js";
211
+ import "./chunk-ZKTYTOF4.js";
209
212
  import {
213
+ aheadOf,
210
214
  dayIn
211
- } from "./chunk-QJHRRJKD.js";
212
- import "./chunk-WBUVNKHJ.js";
215
+ } from "./chunk-CU76ZACK.js";
216
+ import "./chunk-GWXTVO43.js";
213
217
  import {
214
218
  count,
215
219
  createTaskService,
216
220
  text,
217
221
  time
218
- } from "./chunk-IED6MKPU.js";
219
- import "./chunk-Z3YOKGVZ.js";
220
- import "./chunk-MQACXJLG.js";
222
+ } from "./chunk-V7N2K5OT.js";
223
+ import "./chunk-HZIGGAC7.js";
224
+ import "./chunk-JDCFHZNU.js";
221
225
  import {
222
226
  hostFetch,
223
227
  retrying
224
- } from "./chunk-M25KVDHA.js";
225
- import "./chunk-UIWWAT3C.js";
226
- import "./chunk-K4DWBOO6.js";
227
- import "./chunk-DBPFHJXX.js";
228
+ } from "./chunk-5WDNG4QE.js";
229
+ import "./chunk-JFLKTYH5.js";
230
+ import "./chunk-CTN4DW2F.js";
228
231
  import {
229
232
  DESKTOP,
230
233
  IDENTITY,
231
234
  PACKAGE,
232
235
  SKILL
233
- } from "./chunk-Q7DIEU6L.js";
234
- import "./chunk-3SRGN5MQ.js";
236
+ } from "./chunk-YDG5FIQB.js";
237
+ import "./chunk-3TLNO3VM.js";
235
238
  import "./chunk-EH6ZEJGT.js";
236
- import "./chunk-3MUHCLRY.js";
237
- import "./chunk-GJSHLF43.js";
239
+ import "./chunk-6DABKZYH.js";
240
+ import "./chunk-EJZIEBAR.js";
238
241
  import {
239
242
  installerOf
240
- } from "./chunk-HVXOA4FO.js";
243
+ } from "./chunk-745FMNI5.js";
241
244
  import {
242
245
  fieldsOf
243
- } from "./chunk-HQYJ66ZX.js";
246
+ } from "./chunk-G6LDK6DJ.js";
244
247
  import {
245
248
  foldName
246
- } from "./chunk-JWO3PB5Z.js";
247
- import "./chunk-QODPEZC5.js";
248
- import "./chunk-5KLNBGPU.js";
249
+ } from "./chunk-E27NRLJZ.js";
250
+ import "./chunk-PR7ZDMGF.js";
251
+ import "./chunk-AKSWXRIU.js";
249
252
  import {
250
253
  CRM_ACTIVITY_KINDS,
251
254
  CRM_KINDS,
@@ -256,38 +259,40 @@ import {
256
259
  normalCrmUserId,
257
260
  parseDecimal,
258
261
  scaleOf
259
- } from "./chunk-T3GZKV5A.js";
260
- import "./chunk-3MPMYAII.js";
261
- import "./chunk-GOOXUCJW.js";
262
+ } from "./chunk-RLK2EGQD.js";
263
+ import "./chunk-R26OEZOL.js";
264
+ import "./chunk-YIH2A2PQ.js";
262
265
  import {
263
266
  SAVE_HELP,
264
267
  defineQuery,
265
268
  queryFieldsOf,
266
269
  timezoneOf,
267
270
  zonedMoment
268
- } from "./chunk-NLZADZ4F.js";
269
- import "./chunk-AV2ZJ4WX.js";
271
+ } from "./chunk-UVGJL753.js";
272
+ import "./chunk-TCSVW7BA.js";
273
+ import "./chunk-MJ24YFXZ.js";
270
274
  import "./chunk-D72URWJE.js";
271
275
  import {
272
276
  readSecret
273
- } from "./chunk-V23OHBGM.js";
274
- import "./chunk-HPRKSL5S.js";
275
- import "./chunk-6ULR7N3T.js";
276
- import "./chunk-PQUZ2YDC.js";
277
- import "./chunk-2Q2XIXDL.js";
277
+ } from "./chunk-LTU4BQ4S.js";
278
+ import "./chunk-BM5F2ZNI.js";
279
+ import "./chunk-2VUIJ5XB.js";
280
+ import "./chunk-HYDXA624.js";
281
+ import "./chunk-H4W2OO35.js";
278
282
  import {
279
283
  renderPretty,
280
284
  resolvePaths
281
- } from "./chunk-3BM6KBWP.js";
285
+ } from "./chunk-2K5BAY32.js";
282
286
  import {
283
287
  isoTime
284
- } from "./chunk-3LMW7U7F.js";
288
+ } from "./chunk-H5HBZCEJ.js";
285
289
  import {
286
290
  array,
287
291
  boolean,
288
292
  literal,
289
293
  nullable,
290
294
  number,
295
+ omit,
291
296
  optional,
292
297
  picklist,
293
298
  record,
@@ -301,8 +306,8 @@ import "./chunk-Y5E2WNWB.js";
301
306
  import {
302
307
  CliError,
303
308
  isCliError
304
- } from "./chunk-HM6AMYHR.js";
305
- import "./chunk-DG4RBKIV.js";
309
+ } from "./chunk-AP3CWDRK.js";
310
+ import "./chunk-J76CMNWQ.js";
306
311
  import {
307
312
  __export,
308
313
  __name
@@ -311,7 +316,7 @@ import {
311
316
  // dist/program.js
312
317
  import { join as join4 } from "node:path";
313
318
 
314
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/update/index.js
319
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/update/index.js
315
320
  import { realpathSync } from "node:fs";
316
321
  import { fileURLToPath } from "node:url";
317
322
  var npmRegistry = /* @__PURE__ */ __name(() => hostFetch({ hosts: ["registry.npmjs.org"] }), "npmRegistry");
@@ -376,10 +381,6 @@ var appUpdate = /* @__PURE__ */ __name((app) => {
376
381
  };
377
382
  }, "appUpdate");
378
383
 
379
- // dist/commands/account.js
380
- import { readFileSync } from "node:fs";
381
- import { join } from "node:path";
382
-
383
384
  // dist/generated/manifest.js
384
385
  var manifest_exports = {};
385
386
  __export(manifest_exports, {
@@ -6778,16 +6779,22 @@ var security = [
6778
6779
  var firstWord = /* @__PURE__ */ __name((command) => command.split("-")[0] ?? command, "firstWord");
6779
6780
  var GROUPS = new Map(operations.flatMap((operation) => (operation.permissions ?? []).flatMap(({ key }) => key.endsWith(".delete") ? [[firstWord(operation.command), key.slice(0, -".delete".length)]] : [])));
6780
6781
  var COMMAND_KEYS = Object.fromEntries([
6781
- ["deals", "deals"],
6782
- ["contacts", "people"],
6783
- ["companies", "organizations"]
6784
- ].flatMap(([type, noun]) => [
6785
- [`${type}-create`, [`${noun}.create`]],
6786
- [`${type}-batch-create`, [`${noun}.create`]],
6787
- [`${type}-update`, [`${noun}.update`]],
6788
- [`${type}-batch-update`, [`${noun}.update`]],
6789
- [`${type}-batch-upsert`, [`${noun}.create`, `${noun}.update`]]
6790
- ]));
6782
+ ...[
6783
+ ["deals", "deals"],
6784
+ ["contacts", "people"],
6785
+ ["companies", "organizations"]
6786
+ ].flatMap(([type, noun]) => [
6787
+ [`${type}-create`, [`${noun}.create`]],
6788
+ [`${type}-batch-create`, [`${noun}.create`]],
6789
+ [`${type}-update`, [`${noun}.update`]],
6790
+ [`${type}-batch-update`, [`${noun}.update`]],
6791
+ [`${type}-batch-upsert`, [`${noun}.create`, `${noun}.update`]]
6792
+ ]),
6793
+ ...["notes", "tasks"].flatMap((type) => [
6794
+ [`${type}-create`, ["activities.create"]],
6795
+ [`${type}-batch-create`, ["activities.create"]]
6796
+ ])
6797
+ ]);
6791
6798
  var READ_KEYS = Object.fromEntries([
6792
6799
  ...[
6793
6800
  ["deals", "deals"],
@@ -6916,6 +6923,7 @@ var permissions = commandPermissions({
6916
6923
  defaults: {
6917
6924
  ...api.defaults,
6918
6925
  ...COMMAND_DEFAULTS,
6926
+ [ERASE_KEY]: "deny",
6919
6927
  ...CRM_WRITE_DEFAULTS
6920
6928
  }
6921
6929
  });
@@ -7022,196 +7030,6 @@ var withHub = /* @__PURE__ */ __name((command, body) => {
7022
7030
  return contextOf(command).run((events) => body(hubFor(command, signIn, events)));
7023
7031
  }, "withHub");
7024
7032
 
7025
- // dist/whoami.js
7026
- var accountAnswer = /* @__PURE__ */ __name(async (hub) => {
7027
- const details = await accountDetails(hub);
7028
- const id = String(details.portalId);
7029
- return {
7030
- account: id,
7031
- account_info: { id, ui_domain: details.uiDomain, time_zone: details.timeZone, type: details.accountType },
7032
- user: null
7033
- };
7034
- }, "accountAnswer");
7035
-
7036
- // dist/commands/session.js
7037
- var HUBSPOT = IDENTITY.command;
7038
- var answer = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
7039
- var storageOf = /* @__PURE__ */ __name((raw) => {
7040
- if (raw === "keyring" || raw === "file")
7041
- return raw;
7042
- throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
7043
- }, "storageOf");
7044
- var tokensHere = /* @__PURE__ */ __name((env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {} }), "tokensHere");
7045
- var signedInTo = /* @__PURE__ */ __name((env, keyring, profile) => {
7046
- const saved = tokensHere(env, keyring).read(profile);
7047
- if (!saved || saved.source === "environment")
7048
- return void 0;
7049
- return decodeSignIn(saved.secret).portalId;
7050
- }, "signedInTo");
7051
- var refuseDuplicate = /* @__PURE__ */ __name((env, keyring, profile, at2) => {
7052
- const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
7053
- const other = profilesHere(IDENTITY, configuredProfiles, env).find((one) => {
7054
- if (one === profile)
7055
- return false;
7056
- try {
7057
- return signedInTo(env, keyring, one) === at2;
7058
- } catch {
7059
- return false;
7060
- }
7061
- });
7062
- if (!other)
7063
- return;
7064
- throw new CliError("conflict", `profile ${other} already signs in to HubSpot account ${at2}. Use \`${HUBSPOT} ${other}\`, or end it with \`${HUBSPOT} ${other} session end\` first`, { reason: "session.duplicate", profile: other, account: at2 });
7065
- }, "refuseDuplicate");
7066
- var checkedToken = /* @__PURE__ */ __name(async (command, token) => {
7067
- const { env, profile, keyring, run: run3 } = contextOf(command);
7068
- const who = await run3((events) => accountAnswer(hubFor(command, { token }, events)));
7069
- refuseDuplicate(env, keyring, profile, who.account);
7070
- const { ui_domain: uiDomain, time_zone: timeZone } = who.account_info;
7071
- return { who, signIn: encodeSignIn({ token, portalId: who.account, uiDomain, timeZone }) };
7072
- }, "checkedToken");
7073
- var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
7074
- effects: FETCH,
7075
- lifetime: "interactive",
7076
- mcp: false,
7077
- examples: [
7078
- `${HUBSPOT} work session start`,
7079
- `${HUBSPOT} work session start --json`,
7080
- `${HUBSPOT} work session start --credential-storage file`
7081
- ]
7082
- })).summary(`sign in to ${SERVICE} with a service key or a private app token`).description("sign this profile in: a service key (Development \u2192 Keys \u2192 Service keys) or a legacy private app's access token is asked hidden or read from stdin, never taken as an argument, checked against the account, and only then kept in the keyring with the account's id, or in a private file. The key reads and writes what its scopes allow").option("--credential-storage <storage>", "where the key is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring").action(async function(args) {
7083
- const { env, profile, tokens } = contextOf(this);
7084
- refuseCommandName(profile, commandWords(rootOf(this)), HUBSPOT);
7085
- refuseOffline(this, SERVICE);
7086
- const token = (await readSecret(`${SERVICE} service key or private app token: `, secretInputOf(this))).trim();
7087
- if (!token)
7088
- throw new CliError("validation_error", "no token was given");
7089
- const { who, signIn } = await checkedToken(this, token);
7090
- const storedIn = tokens.write(profile, signIn, args.credentialStorage);
7091
- rememberAccount(IDENTITY, profile, who.account, env);
7092
- answer(this, { profile, state: "saved", kind: "token", stored_in: storedIn, verified: true, ...who });
7093
- }), "startCommand");
7094
- var statusCommand = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
7095
- effects: REMOTE_READ,
7096
- examples: [`${HUBSPOT} work session status`, `${HUBSPOT} work session status --check --json`]
7097
- }).summary("show where this profile's key comes from; --check names the account it reads").description(`show which account this profile signs in to and where its key comes from: ${IDENTITY.envPrefix}_TOKEN, the keyring or a file; never the key`).option("--check", `ask ${SERVICE} whether the key still works and which account it reads`).action(async function(args) {
7098
- const { env, profile, tokens, run: run3 } = contextOf(this);
7099
- const saved = tokens.read(profile);
7100
- const fromToken = saved?.source === "environment";
7101
- const named = fromToken ? environmentAccount(env) : storedSignIn(this)?.portalId;
7102
- const status = {
7103
- profile,
7104
- state: saved ? "saved" : "missing",
7105
- kind: saved ? "token" : null,
7106
- token_from: saved?.source ?? null,
7107
- account: named ?? null
7108
- };
7109
- if (!args.check || !saved)
7110
- return answer(this, { ...status, verified: false });
7111
- if (!fromToken)
7112
- return answer(this, { ...status, verified: true, ...await withHub(this, accountAnswer) });
7113
- refuseOffline(this, SERVICE);
7114
- const who = await run3((events) => accountAnswer(hubFor(this, { token: saved.secret, portalId: named }, events)));
7115
- if (named)
7116
- refuseAccountMismatch(named, who.account);
7117
- answer(this, { ...status, verified: true, ...who });
7118
- }), "statusCommand");
7119
- var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
7120
- effects: LOCAL_WRITE,
7121
- mcp: false,
7122
- examples: [`${HUBSPOT} work session end`]
7123
- })).summary("forget this profile's key on this computer").description(`forget this profile's key and account id on this computer; the key itself stays valid in ${SERVICE}: delete or rotate it where it was made`).action(function() {
7124
- refuseUnderReadOnly(this, "session end");
7125
- const { profile, tokens } = contextOf(this);
7126
- answer(this, { profile, ended: tokens.remove(profile) });
7127
- }), "endCommand");
7128
- var listCommand = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
7129
- effects: LOCAL_READ,
7130
- examples: [`${HUBSPOT} session list`, `${HUBSPOT} session list --json`]
7131
- })).summary("list the profiles here and whether each is signed in").description("list the profiles on this computer, whether each has a key and for which account; picks none").action(function() {
7132
- const environment = environmentOf(this);
7133
- const env = environment.env ?? process.env;
7134
- const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
7135
- const tokens = tokensHere(env, environment.keyring);
7136
- const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
7137
- try {
7138
- const saved = tokens.read(profile);
7139
- const account = saved && saved.source !== "environment" ? decodeSignIn(saved.secret).portalId : null;
7140
- return { profile, signed_in: saved !== void 0, token_from: saved?.source ?? null, account };
7141
- } catch (error) {
7142
- if (!(error instanceof CliError))
7143
- throw error;
7144
- return { profile, signed_in: null, token_from: null, account: null, error: error.message };
7145
- }
7146
- });
7147
- renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
7148
- }), "listCommand");
7149
- var sessionCommand = /* @__PURE__ */ __name(() => annotate(new Command("session"), { effects: LOCAL_READ }).description(`keep this profile's ${SERVICE} key and account id in the OS keyring`).addCommand(startCommand()).addCommand(statusCommand()).addCommand(endCommand()).addCommand(listCommand()), "sessionCommand");
7150
-
7151
- // dist/commands/account.js
7152
- var rememberedOf = /* @__PURE__ */ __name((env, profile) => {
7153
- try {
7154
- const { account } = JSON.parse(readFileSync(accountFileFor(IDENTITY, profile, env), "utf8"));
7155
- return typeof account === "string" && /^\d+$/.test(account) ? account : void 0;
7156
- } catch {
7157
- return void 0;
7158
- }
7159
- }, "rememberedOf");
7160
- var portalOf = /* @__PURE__ */ __name((env, keyring, profile) => {
7161
- try {
7162
- return signedInTo(env, keyring, profile) ?? rememberedOf(env, profile);
7163
- } catch {
7164
- return rememberedOf(env, profile);
7165
- }
7166
- }, "portalOf");
7167
- var removal = {
7168
- // HubSpot has no call that revokes a service key or a private app token; the account's settings do.
7169
- signOut: /* @__PURE__ */ __name(async (profile) => ({
7170
- revoked: null,
7171
- removed: [`the sign-in of ${profile} (the key stays valid in HubSpot until you delete or rotate it there)`]
7172
- }), "signOut"),
7173
- account: /* @__PURE__ */ __name((profile, { env, keyring }) => {
7174
- const portal = portalOf(env, keyring, profile);
7175
- return portal ? { provider: PROVIDER.name, account: portal } : void 0;
7176
- }, "account"),
7177
- secrets: /* @__PURE__ */ __name((profile, { env, keyring }) => [
7178
- {
7179
- credentials: {
7180
- configDir: resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).config,
7181
- service: IDENTITY.appName,
7182
- envVar: `${IDENTITY.envPrefix}_TOKEN`,
7183
- env,
7184
- ...keyring ? { keyring } : {}
7185
- },
7186
- accounts: [`token:${profile}`]
7187
- }
7188
- ], "secrets"),
7189
- stateFiles: /* @__PURE__ */ __name((profile, { env }) => [
7190
- join(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "crm", profile)
7191
- ], "stateFiles")
7192
- };
7193
- var refuseSharedDelete = /* @__PURE__ */ __name((command) => {
7194
- if (command.opts().deleteData !== true)
7195
- return;
7196
- const { env, keyring, profile, renderer } = contextOf(command);
7197
- const own = portalOf(env, keyring, profile);
7198
- if (!own)
7199
- return;
7200
- const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
7201
- const sharing = profilesHere(IDENTITY, configuredProfiles, env).filter((one) => one !== profile && portalOf(env, keyring, one) === own);
7202
- if (sharing.length === 0)
7203
- return;
7204
- const names = sharing.join(", ");
7205
- if (command.opts().dryRun === true) {
7206
- renderer.warn(`without --dry-run this refuses: ${names} also read${sharing.length === 1 ? "s" : ""} ${own}`);
7207
- return;
7208
- }
7209
- throw new CliError("conflict", `${names} also read${sharing.length === 1 ? "s" : ""} account ${own}, and the store keeps one copy of an account: --delete-data would delete their deals, contacts and companies too. Use --keep-data, or remove ${names} first`, { reason: "account-remove.account-shared", profiles: sharing, account: own });
7210
- }, "refuseSharedDelete");
7211
- var accountCommand = /* @__PURE__ */ __name(() => annotate(new Command("account"), { effects: LOCAL_READ }).description("this profile on this computer").addCommand(annotate(accountRemoveCommand(IDENTITY, removal, { resolveSettings: configuration.resolveSettings }), {
7212
- effects: LOCAL_WRITE
7213
- }).hook("preAction", (_, action) => refuseSharedDelete(action))), "accountCommand");
7214
-
7215
7033
  // dist/commands/api.js
7216
7034
  var stopAtDailyLimit = /* @__PURE__ */ __name((send, sent, pacer) => async (input, init) => {
7217
7035
  const response = await send(input, init);
@@ -7257,12 +7075,12 @@ var apiCommand = /* @__PURE__ */ __name(() => {
7257
7075
  timeZone: sent.timeZone
7258
7076
  }), "failure"),
7259
7077
  token: tokenOf,
7260
- schemas: /* @__PURE__ */ __name(() => import("./schemas-LDK7O6VW.js").then((module) => module.schemas), "schemas"),
7078
+ schemas: /* @__PURE__ */ __name(() => import("./schemas-EXBNVPMI.js").then((module) => module.schemas), "schemas"),
7261
7079
  definitions: /* @__PURE__ */ __name(() => import("./definitions-MVPICAWV.js").then((module) => module.definitions), "definitions")
7262
7080
  });
7263
7081
  }, "apiCommand");
7264
7082
 
7265
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/stage-tasks.js
7083
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/stage-tasks.js
7266
7084
  var DAY = 864e5;
7267
7085
  var openStageTasks = /* @__PURE__ */ __name(async (store, account, now, { history = false } = {}) => {
7268
7086
  const rules = await store.crm.stageTasks(account);
@@ -7299,8 +7117,115 @@ var openStageTasks = /* @__PURE__ */ __name(async (store, account, now, { histor
7299
7117
  return opened;
7300
7118
  }, "openStageTasks");
7301
7119
 
7302
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/digest.js
7120
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/account.js
7121
+ import { join } from "node:path";
7122
+ var SHARED = new Set(Object.values(CRM_SHARED_FOLDERS));
7123
+ var isShared = /* @__PURE__ */ __name((profile) => SHARED.has(profile.toLowerCase()), "isShared");
7124
+ var accountBy = /* @__PURE__ */ __name((app, options) => (profile, context) => options.held ? options.held(profile, context)?.account : recalledAccount(app, options.provider, profile, context.env)?.account, "accountBy");
7125
+ var signedInBy = /* @__PURE__ */ __name((app, options, tokens) => (profile, context) => {
7126
+ try {
7127
+ if (options.held)
7128
+ return options.held(profile, context);
7129
+ const account = recalledAccount(app, options.provider, profile, context.env)?.account;
7130
+ if (account === void 0)
7131
+ return void 0;
7132
+ const saved = (tokens ?? new ProfileTokenStore({ app, ...context, warn: /* @__PURE__ */ __name(() => {
7133
+ }, "warn") })).read(profile);
7134
+ return { account, signedIn: saved !== void 0 && saved.source !== "environment" };
7135
+ } catch {
7136
+ return void 0;
7137
+ }
7138
+ }, "signedInBy");
7139
+ var also = /* @__PURE__ */ __name((names) => `${names.join(", ")} also read${names.length === 1 ? "s" : ""}`, "also");
7140
+ var refuseTakenCrmAccount = /* @__PURE__ */ __name((app, options, { profile, profiles = [], tokens, ...context }, at2) => {
7141
+ if (isShared(profile))
7142
+ throw new CliError("validation_error", `"${profile}" names a folder every account shares, where this profile's own files would land. Pick another name than ${Object.values(CRM_SHARED_FOLDERS).join(" or ")}`, { reason: "profile.reserved", profile });
7143
+ const held = signedInBy(app, options, tokens);
7144
+ const other = profilesHere(app, profiles, context.env).find((one) => {
7145
+ if (one === profile)
7146
+ return false;
7147
+ const found = held(one, context);
7148
+ return found?.signedIn === true && found.account === at2.account && found.user === at2.user;
7149
+ });
7150
+ if (!other)
7151
+ return;
7152
+ const command = app.command;
7153
+ throw new CliError("conflict", `profile ${other} already signs in to ${options.service} account ${at2.account}${at2.user === void 0 ? "" : ` as user ${at2.user}`}. Use \`${command} ${other}\`, ` + // Another user's token on the account is a second sign-in only where the account has users.
7154
+ (at2.user === void 0 ? "" : `sign it in again with \`${command} ${other} session start\`, `) + `or end it with \`${command} ${other} session end\` first`, { reason: "session.duplicate", profile: other, account: at2.account });
7155
+ }, "refuseTakenCrmAccount");
7156
+ var refuseSharedDelete = /* @__PURE__ */ __name((app, options, command) => {
7157
+ const given = command.opts();
7158
+ if (given.deleteData !== true)
7159
+ return;
7160
+ const resolveSettings = options.resolveSettings ?? environmentOf(command).resolveSettings;
7161
+ if (!resolveSettings)
7162
+ return;
7163
+ const { env, keyring, settings, renderer } = baseContext(command, resolveSettings);
7164
+ const context = { env, ...keyring ? { keyring } : {} };
7165
+ const accountOf = accountBy(app, options);
7166
+ const read = /* @__PURE__ */ __name((profile) => {
7167
+ try {
7168
+ return accountOf(profile, context);
7169
+ } catch {
7170
+ throw new CliError("conflict", `${app.command} could not tell which ${options.service} account ${profile} holds, so --delete-data could delete a copy ${profile} still reads. Fix ${profile}'s sign-in, or use --keep-data`, { reason: "account-remove.account-unknown", profile });
7171
+ }
7172
+ }, "read");
7173
+ const own = read(settings.profile);
7174
+ if (own === void 0)
7175
+ return;
7176
+ const sharing = settings.profilesHere.filter((one) => one !== settings.profile && read(one) === own);
7177
+ if (sharing.length === 0)
7178
+ return;
7179
+ if (given.dryRun === true) {
7180
+ renderer.warn(`without --dry-run this refuses: ${also(sharing)} ${options.service} account ${own}`);
7181
+ return;
7182
+ }
7183
+ const names = sharing.join(", ");
7184
+ throw new CliError("conflict", `${also(sharing)} ${options.service} account ${own}, and the store keeps one copy of an account: --delete-data would delete their deals, contacts and companies too. Use --keep-data, or remove ${names} first`, { reason: "account-remove.account-shared", profiles: sharing, account: own });
7185
+ }, "refuseSharedDelete");
7186
+ var removalOf = /* @__PURE__ */ __name((app, options) => {
7187
+ const accountOf = accountBy(app, options);
7188
+ const folders = /* @__PURE__ */ __name((env) => resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }), "folders");
7189
+ return {
7190
+ // A CRM's API token has no call that revokes it; the CRM's own settings do.
7191
+ signOut: /* @__PURE__ */ __name(async (profile) => ({
7192
+ revoked: null,
7193
+ removed: [
7194
+ options.signedOut?.(profile) ?? `the sign-in of ${profile} (the token stays valid in ${options.service} until you delete it there)`
7195
+ ]
7196
+ }), "signOut"),
7197
+ account: /* @__PURE__ */ __name((profile, context) => {
7198
+ try {
7199
+ const account = accountOf(profile, context);
7200
+ return account === void 0 ? void 0 : { provider: options.provider, account };
7201
+ } catch {
7202
+ return void 0;
7203
+ }
7204
+ }, "account"),
7205
+ secrets: /* @__PURE__ */ __name((profile, { env, keyring }) => [
7206
+ {
7207
+ credentials: {
7208
+ configDir: folders(env).config,
7209
+ service: app.appName,
7210
+ envVar: `${app.envPrefix}_TOKEN`,
7211
+ env,
7212
+ ...keyring ? { keyring } : {}
7213
+ },
7214
+ // An OAuth sign-in's entry; removing a missing one is fine.
7215
+ accounts: [`token:${profile}`, oauthAccount(options.provider, profile)]
7216
+ }
7217
+ ], "secrets"),
7218
+ // A profile named after a folder every account shares has no folder of its own there.
7219
+ stateFiles: /* @__PURE__ */ __name((profile, { env }) => isShared(profile) ? [] : [join(folders(env).state, "crm", profile)], "stateFiles")
7220
+ };
7221
+ }, "removalOf");
7222
+ var crmAccountCommand = /* @__PURE__ */ __name((app, options) => annotate(new Command("account"), { effects: LOCAL_READ }).description("this profile on this computer").addCommand(annotate(accountRemoveCommand(app, removalOf(app, options), {
7223
+ ...options.resolveSettings ? { resolveSettings: options.resolveSettings } : {}
7224
+ }), { effects: LOCAL_WRITE }).hook("preAction", (_, action) => refuseSharedDelete(app, options, action))), "crmAccountCommand");
7225
+
7226
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/digest.js
7303
7227
  var HOUR = 36e5;
7228
+ var SHOWN = 7;
7304
7229
  var STALE_HOURS = 24;
7305
7230
  var WORDS = {
7306
7231
  en: {
@@ -7336,7 +7261,7 @@ var endOfDay = /* @__PURE__ */ __name((now, zone) => {
7336
7261
  var crmDigest = /* @__PURE__ */ __name(async (store, account, options) => {
7337
7262
  const { since, until, now, zone, viewer } = options;
7338
7263
  const words = WORDS[options.language] ?? WORDS.en;
7339
- const cap = SECTION_CAPS.crm;
7264
+ const cap = SHOWN;
7340
7265
  const window = { since, until, ...viewer ? { viewer } : {} };
7341
7266
  const counts = await store.crm.changeCounts(account, window);
7342
7267
  const changesOf = /* @__PURE__ */ __name(async (kind) => counts[kind] ? (await store.crm.changes(account, { ...window, changes: [kind], limit: cap, offset: 0 })).items : [], "changesOf");
@@ -7442,7 +7367,7 @@ var healthOf = /* @__PURE__ */ __name(async (store, account, { now, profile }) =
7442
7367
  return stale > STALE_HOURS ? [{ ...named, stale_hours: Math.floor(stale) }] : [];
7443
7368
  }, "healthOf");
7444
7369
 
7445
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/csv.js
7370
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/csv.js
7446
7371
  var csvFormatOption = /* @__PURE__ */ __name(() => annotateOption(new Option("--format <format>", "csv: this page as a table for a spreadsheet; --json=a,b picks its columns").choices(["csv"]), { mcp: false }), "csvFormatOption");
7447
7372
  var DEAL_CSV_COLUMNS = [
7448
7373
  "ref",
@@ -7564,7 +7489,7 @@ var renderCsv = /* @__PURE__ */ __name((command, open2, read, defaults = DEAL_CS
7564
7489
  });
7565
7490
  }, "renderCsv");
7566
7491
 
7567
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/records.js
7492
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/records.js
7568
7493
  var time2 = nullable(isoTime);
7569
7494
  var metadata = optional(record(string(), strictObject({
7570
7495
  label: nullable(string()),
@@ -7739,13 +7664,16 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
7739
7664
  const stored = await run3.store.crm.fields(run3.account, kind);
7740
7665
  return stored.length ? stored : await run3.source().fields?.(kind) ?? [];
7741
7666
  }, "liveFields");
7667
+ const words = options.liveQuery === "words";
7742
7668
  const records = /* @__PURE__ */ __name((noun) => {
7743
7669
  const group = annotate(program.command(noun.noun), { effects: REMOTE_READ }).description(`the CRM's ${noun.what}, read live: the copy holds only your own`);
7744
- example(withQuery(answerEntity(annotate(group.command("list"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema), noun.query).description(`${noun.what} in the CRM, newest first; another client is found here, never in the copy`).option("--limit <n>", `${noun.what} per page, 1\u2013${MOST}`, integer(MOST), 50).option("--page <n>", "which page, starting at 1", integer(1e6), 1).addOption(csvFormatOption()).addHelpText("after", CUSTOM_HELP), `${noun.noun} list`, `${noun.noun} list name:anna* --json`, `${noun.noun} list --format csv > ${noun.noun}.csv`).action(async (words, opts, command) => {
7670
+ const query = words ? { ...noun.query, fields: noun.query.fields.filter(({ name }) => name === "name") } : noun.query;
7671
+ const list = answerEntity(annotate(group.command("list"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema);
7672
+ example((words ? withWords(list, query, `words the CRM's own search looks for in ${noun.what}`) : withQuery(list, query).addHelpText("after", CUSTOM_HELP)).description(`${noun.what} in the CRM, newest first; another client is found here, never in the copy`).option("--limit <n>", `${noun.what} per page, 1\u2013${MOST}`, integer(MOST), 50).option("--page <n>", "which page, starting at 1", integer(1e6), 1).addOption(csvFormatOption()), `${noun.noun} list`, words ? `${noun.noun} list anna --json` : `${noun.noun} list name:anna* --json`, `${noun.noun} list --format csv > ${noun.noun}.csv`).action(async (words2, opts, command) => {
7745
7673
  const csv = opts.format === "csv";
7746
7674
  const path = commandPath(command);
7747
- const text2 = typedQuery(words);
7748
- const names = customNames(text2, noun.query, path, "name");
7675
+ const text2 = typedQuery(words2);
7676
+ const names = customNames(text2, query, path, "name");
7749
7677
  const columns = command.optsWithGlobals().fields;
7750
7678
  const wanted = csv && columns === void 0 ? "all" : wantedCodes(columns);
7751
7679
  const read = /* @__PURE__ */ __name(async (run3) => {
@@ -7753,7 +7681,7 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
7753
7681
  const fields = names.length || wanted !== void 0 || csv ? await liveFields(run3, noun.kind) : [];
7754
7682
  const chosen = filterableFields(fields, names);
7755
7683
  selectedCodes(fields, wanted);
7756
- const terms = nativeTerms(listQuery(text2, withCustomFields(noun.query, chosen), path, { defaultField: "name" }), path);
7684
+ const terms = nativeTerms(listQuery(text2, withCustomFields(query, chosen), path, { defaultField: "name" }), path);
7757
7685
  const custom = customConditions(terms, chosen);
7758
7686
  const name = searchText(terms.get("name"));
7759
7687
  terms.delete("name");
@@ -7778,7 +7706,7 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
7778
7706
  limit: opts.limit,
7779
7707
  page: opts.page,
7780
7708
  has_more: found.hasMore,
7781
- ...words.length ? { args: { query: words } } : {}
7709
+ ...words2.length ? { args: { query: words2 } } : {}
7782
7710
  });
7783
7711
  });
7784
7712
  });
@@ -7797,9 +7725,18 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
7797
7725
  if (options.live.includes("user"))
7798
7726
  users(program, options);
7799
7727
  }, "addCrmRecordCommands");
7728
+ var byIdOrNone = /* @__PURE__ */ __name(async (run3, noun, id) => {
7729
+ try {
7730
+ return await sourceWith(run3, "get", noun.what).get(noun.kind, id);
7731
+ } catch (error) {
7732
+ if (isCliError(error) && error.code === "validation_error")
7733
+ return null;
7734
+ throw error;
7735
+ }
7736
+ }, "byIdOrNone");
7800
7737
  var recordNamed = /* @__PURE__ */ __name(async (run3, noun, given) => {
7801
7738
  const id = given.trim();
7802
- const byId = RECORD_ID.test(id) ? await sourceWith(run3, "get", noun.what).get(noun.kind, id) : null;
7739
+ const byId = RECORD_ID.test(id) ? await byIdOrNone(run3, noun, id) : null;
7803
7740
  if (byId)
7804
7741
  return byId;
7805
7742
  const want = foldName(id);
@@ -7933,7 +7870,7 @@ var addRecordWrites = /* @__PURE__ */ __name((group, noun, { within, example, wr
7933
7870
  }, "addRecordWrites");
7934
7871
  var idOf = /* @__PURE__ */ __name((opts) => opts.operationId === void 0 ? {} : { operationId: opts.operationId }, "idOf");
7935
7872
 
7936
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/activities.js
7873
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/activities.js
7937
7874
  var MOST2 = 500;
7938
7875
  var nullableText = nullable(text);
7939
7876
  var REFS = ["deal", "lead", "person", "organization"];
@@ -7977,7 +7914,7 @@ var crmActivity = strictObject({
7977
7914
  });
7978
7915
  var UNTRUSTED = ["subject", "body", "on.title"];
7979
7916
  var iso3 = /* @__PURE__ */ __name((at2) => at2 === null ? null : new Date(at2).toISOString(), "iso");
7980
- var itemOf2 = /* @__PURE__ */ __name((one) => ({
7917
+ var listedOf = /* @__PURE__ */ __name((one) => ({
7981
7918
  external_id: one.externalId,
7982
7919
  kind: one.kind,
7983
7920
  subject: one.subject,
@@ -7990,10 +7927,15 @@ var itemOf2 = /* @__PURE__ */ __name((one) => ({
7990
7927
  updated_at: new Date(one.updatedAt).toISOString(),
7991
7928
  on: one.on.map(({ kind, externalId, ref, title }) => ({ kind, external_id: externalId, ref, title })),
7992
7929
  untrusted: UNTRUSTED
7993
- }), "itemOf");
7930
+ }), "listedOf");
7994
7931
  var addCrmActivityCommands = /* @__PURE__ */ __name((program, options) => {
7932
+ const group = annotate(program.command("activities"), { effects: NO_EFFECTS }).description(options.list ? "the CRM's activities and tasks on deals, leads, contacts and companies, as last synced" : `comments and tasks written to the CRM's ${options.leads === false ? "deals" : "deals, leads"}, contacts and companies`);
7933
+ if (options.list)
7934
+ addList(group, options);
7935
+ addActivityWrites(group, options);
7936
+ }, "addCrmActivityCommands");
7937
+ var addList = /* @__PURE__ */ __name((group, options) => {
7995
7938
  const { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 } = options;
7996
- const group = annotate(program.command("activities"), { effects: NO_EFFECTS }).description("the CRM's activities and tasks on deals, leads, contacts and companies, as last synced");
7997
7939
  example(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "crm_activity", crmActivity).description("activities copied from the CRM, open ones first by due time, then the rest newest first; status:open unless a status is given; the activities setting must be on").option("--limit <n>", `activities per page, 1\u2013${MOST2}`, integer(MOST2), 50).option("--page <n>", "which page, starting at 1", integer(1e6), 1), ACTIVITIES_QUERY), "activities list overdue:true", "activities list due:today --json", "activities list deal:12 status:done").action(async (words, opts, command) => {
7998
7940
  const name = "activities list";
7999
7941
  const terms = queryTerms(words, ACTIVITIES_QUERY, name, ["due"]);
@@ -8036,17 +7978,92 @@ var addCrmActivityCommands = /* @__PURE__ */ __name((program, options) => {
8036
7978
  offset: (opts.page - 1) * opts.limit
8037
7979
  });
8038
7980
  return listOf(pathOf2(command).join(" "), {
8039
- items: found.items.map(itemOf2),
7981
+ items: found.items.map(listedOf),
8040
7982
  ...paged,
8041
7983
  has_more: found.hasMore,
8042
7984
  ...due.meta ? { meta: due.meta } : {}
8043
7985
  });
8044
7986
  });
8045
7987
  });
8046
- }, "addCrmActivityCommands");
7988
+ }, "addList");
8047
7989
  var refOf = /* @__PURE__ */ __name((kind, value) => value.includes(":") ? value : `${kind}:${value}`, "refOf");
7990
+ var writtenActivity = strictObject({
7991
+ operation_id: text,
7992
+ stored: boolean(),
7993
+ activity: omit(crmActivity, ["done_at"]),
7994
+ untrusted: array(text)
7995
+ });
7996
+ var addActivityWrites = /* @__PURE__ */ __name((group, options) => {
7997
+ const { within, example, now, writes } = options;
7998
+ const kinds = writes?.activities ?? [];
7999
+ if (kinds.length === 0)
8000
+ return;
8001
+ const leads = options.leads !== false;
8002
+ const contextOf3 = /* @__PURE__ */ __name((run3, command) => {
8003
+ if (!run3.writes)
8004
+ throw new CliError("configuration_error", "this profile cannot write to its CRM");
8005
+ return {
8006
+ store: run3.store,
8007
+ account: run3.account,
8008
+ writes: run3.writes(),
8009
+ ask: terminalAsker(command),
8010
+ source: run3.source,
8011
+ names: { id: "--operation-id" }
8012
+ };
8013
+ }, "contextOf");
8014
+ const answered = /* @__PURE__ */ __name((run3, done) => itemOf({
8015
+ operation_id: done.operationId,
8016
+ stored: done.stored,
8017
+ activity: writtenOf(run3, done.activity, done.on),
8018
+ untrusted: UNTRUSTED.map((field) => `activity.${field}`)
8019
+ }), "answered");
8020
+ const write = /* @__PURE__ */ __name((name, description) => {
8021
+ const command = answerEntity(annotate(group.command(name), { effects: REMOTE_WRITE, offline: false }), "crm_activity_write", writtenActivity).description(description);
8022
+ if (writes?.idempotent)
8023
+ command.option("--operation-id <id>", "the operation_id a write that ended in outcome_unknown named: the CRM answers the repeat from its record");
8024
+ return command;
8025
+ }, "write");
8026
+ const idOf2 = /* @__PURE__ */ __name((opts) => opts.operationId === void 0 ? {} : { operationId: opts.operationId }, "idOf");
8027
+ const comment = kinds.includes("comment");
8028
+ const task = kinds.includes("task");
8029
+ example(write("create", `add a ${kinds.join(" or ")} to records of the CRM, then store the CRM's copy of it when the activities setting is on`).addArgument(new Argument("<kind>", "what to add").choices(kinds)).option(
8030
+ "--subject <ref>",
8031
+ `a record it is on: ${leads ? "deal:<id> or lead:<id>" : "deal:<id>"} as a list shows it, or person:<id> or organization:<id> by the CRM's id as people list and organizations list print it; repeat it for more`,
8032
+ (value, previous = []) => [...previous, value],
8033
+ // The empty default marks the flag as repeatable, so an agent's tool takes a list.
8034
+ []
8035
+ ).option("--title <title>", task ? "a task's title, needed for a task; a comment's title where the CRM keeps one" : "its title").option("--text <text>", comment ? "a comment's text, needed for a comment; a task's description" : "its text").option("--due <time>", "a task's deadline: an ISO 8601 time, a date (its end), today, or 2h, 3d from now; in your time zone").option("--owner <user>", "the CRM user a task is assigned to; anyone but the sign-in's own user checks crm.assign-others"), ...comment ? ['activities create comment --subject deal:12 --text "Example: asked for a discount"'] : [], ...task ? ['activities create task --subject deal:12 --title "Example: call back" --due 2026-12-01T10:00'] : []).action(async (kind, opts, command) => {
8036
+ await within(command, async (run3) => {
8037
+ const done = await createCrmActivity(contextOf3(run3, command), kind, {
8038
+ on: opts.subject,
8039
+ ...opts.title === void 0 ? {} : { title: opts.title },
8040
+ ...opts.text === void 0 ? {} : { body: opts.text },
8041
+ ...opts.due === void 0 ? {} : { dueAt: aheadOf(opts.due, "--due", now(), { end: true }) },
8042
+ ...opts.owner === void 0 ? {} : { owner: opts.owner }
8043
+ }, idOf2(opts));
8044
+ return answered(run3, done);
8045
+ });
8046
+ });
8047
+ if (task)
8048
+ example(write("close", "mark a task done in the CRM, then store the CRM's copy of it when the activities setting is on").argument("<task>", "the task's id in the CRM, as activities list prints its external_id"), "activities close 42").action(async (id, opts, command) => {
8049
+ await within(command, async (run3) => answered(run3, await completeCrmActivity(contextOf3(run3, command), id, idOf2(opts))));
8050
+ });
8051
+ }, "addActivityWrites");
8052
+ var writtenOf = /* @__PURE__ */ __name((run3, activity, on) => ({
8053
+ external_id: activity.externalId,
8054
+ kind: activity.kind,
8055
+ subject: activity.subject,
8056
+ body: activity.body ?? null,
8057
+ due_at: iso3(activity.dueAt ?? null),
8058
+ done: activity.done,
8059
+ assignee: activity.assignee ? crmIdentityId(run3.account, activity.assignee, "user") : null,
8060
+ created_at: new Date(activity.createdAt).toISOString(),
8061
+ updated_at: new Date(activity.updatedAt).toISOString(),
8062
+ on: on.map(({ kind, externalId, ref, title }) => ({ kind, external_id: externalId, ref, title })),
8063
+ untrusted: UNTRUSTED
8064
+ }), "writtenOf");
8048
8065
 
8049
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/changes.js
8066
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/changes.js
8050
8067
  var MOST3 = 500;
8051
8068
  var DAY2 = 864e5;
8052
8069
  var nullableText2 = nullable(text);
@@ -8109,7 +8126,7 @@ var CSV_COLUMNS = [
8109
8126
  "owner",
8110
8127
  "activity.subject"
8111
8128
  ];
8112
- var itemOf3 = /* @__PURE__ */ __name((run3, one) => ({
8129
+ var itemOf2 = /* @__PURE__ */ __name((run3, one) => ({
8113
8130
  change: one.change,
8114
8131
  at: new Date(one.at).toISOString(),
8115
8132
  kind: one.kind,
@@ -8150,10 +8167,20 @@ var positionOf = /* @__PURE__ */ __name((cursor) => {
8150
8167
  var digestState = /* @__PURE__ */ __name((schedule) => `crm:digest:${schedule}`, "digestState");
8151
8168
  var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
8152
8169
  const { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 } = options;
8153
- if (options.activities)
8154
- addCrmActivityCommands(program, { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 });
8155
- const group = annotate(program.command("changes"), { effects: NO_EFFECTS }).description("what changed in the CRM's deals, leads, activities and contacts, as the syncs copied it");
8156
- example(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "crm_change", crmChange).description("deals and leads made, moved, won, lost and given another owner, activities added and done, and contacts added, newest first; the last day unless at: says otherwise").option("--limit <n>", `changes per page, 1\u2013${MOST3}`, integer(MOST3), 50).option("--cursor <cursor>", "the next page, as the last answer's page.next gave it").addOption(annotateOption(new Option("--format <format>", "csv: this page as a table; report: the window as a morning digest document, for schedule command. Run by a schedule, the report starts where that schedule's last one ended").choices(["csv", "report"]), { mcp: false })), CHANGES_QUERY), 'changes list "at>=1d"', "changes list change:won at>=7d --json", 'changes list "at>=1d" --format report').action(async (words, opts, command) => {
8170
+ const deals = options.leads === false ? "deals" : "deals and leads";
8171
+ if (options.activities || options.writes?.activities?.length)
8172
+ addCrmActivityCommands(program, {
8173
+ within,
8174
+ example,
8175
+ now,
8176
+ ownerOf: ownerOf2,
8177
+ pathOf: pathOf2,
8178
+ list: options.activities === true,
8179
+ ...options.writes ? { writes: options.writes } : {},
8180
+ ...options.leads === void 0 ? {} : { leads: options.leads }
8181
+ });
8182
+ const group = annotate(program.command("changes"), { effects: NO_EFFECTS }).description(`what changed in the CRM's ${options.leads === false ? "deals" : "deals, leads"}, activities and contacts, as the syncs copied it`);
8183
+ example(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "crm_change", crmChange).description(`${deals} made, moved, won, lost and given another owner, activities added and done, and contacts added, newest first; the last day unless at: says otherwise`).option("--limit <n>", `changes per page, 1\u2013${MOST3}`, integer(MOST3), 50).option("--cursor <cursor>", "the next page, as the last answer's page.next gave it").addOption(annotateOption(new Option("--format <format>", "csv: this page as a table; report: the window as a morning digest document, for schedule command. Run by a schedule, the report starts where that schedule's last one ended").choices(["csv", "report"]), { mcp: false })), CHANGES_QUERY), 'changes list "at>=1d"', "changes list change:won at>=7d --json", 'changes list "at>=1d" --format report').action(async (words, opts, command) => {
8157
8184
  const name = "changes list";
8158
8185
  const terms = queryTerms(words, CHANGES_QUERY, name, ["at"]);
8159
8186
  const zone = timezoneOf();
@@ -8175,7 +8202,7 @@ var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
8175
8202
  offset: position.offset
8176
8203
  });
8177
8204
  const next = found.hasMore ? cursorOf({ ...position, offset: position.offset + opts.limit }) : void 0;
8178
- return { items: found.items.map((one) => itemOf3(run3, one)), next };
8205
+ return { items: found.items.map((one) => itemOf2(run3, one)), next };
8179
8206
  }, "read");
8180
8207
  const noted = /* @__PURE__ */ __name((run3) => {
8181
8208
  const note = shortened.get(run3);
@@ -8265,9 +8292,9 @@ var pipelineOf2 = /* @__PURE__ */ __name(async (run3, value) => {
8265
8292
  }) : new CliError("not_found", `no pipeline ${value} in this account`, { reason: "pipeline.not-found" });
8266
8293
  }, "pipelineOf");
8267
8294
 
8268
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/files.js
8295
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/files.js
8269
8296
  import { createHash } from "node:crypto";
8270
- import { chmodSync, constants, copyFileSync, existsSync, linkSync, mkdirSync, readFileSync as readFileSync2, renameSync, rmSync } from "node:fs";
8297
+ import { chmodSync, constants, copyFileSync, existsSync, linkSync, mkdirSync, readFileSync, renameSync, rmSync } from "node:fs";
8271
8298
  import { open } from "node:fs/promises";
8272
8299
  import { join as join2, resolve, sep } from "node:path";
8273
8300
  var MB = 1024 * 1024;
@@ -8319,7 +8346,7 @@ var OWNER_FLAGS = [
8319
8346
  ];
8320
8347
  var iso4 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
8321
8348
  var segment = /* @__PURE__ */ __name((text2) => text2.replace(/[^\w.-]+/gu, "_"), "segment");
8322
- var accountFolder = /* @__PURE__ */ __name((app, run3) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env: run3.env ?? process.env }).state, "crm", "files", segment(`${run3.account.provider}-${run3.account.account}`)), "accountFolder");
8349
+ var accountFolder = /* @__PURE__ */ __name((app, run3) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env: run3.env ?? process.env }).state, "crm", CRM_SHARED_FOLDERS.files, segment(`${run3.account.provider}-${run3.account.account}`)), "accountFolder");
8323
8350
  var ownFolder = /* @__PURE__ */ __name((top, folder) => {
8324
8351
  mkdirSync(folder, { recursive: true, mode: 448 });
8325
8352
  for (let at2 = resolve(folder); at2.startsWith(resolve(top)); at2 = resolve(at2, "..")) {
@@ -8500,7 +8527,7 @@ var downloadCrmFile = /* @__PURE__ */ __name(async (context, file, assignee, { c
8500
8527
  }
8501
8528
  let bytes;
8502
8529
  try {
8503
- bytes = readFileSync2(target);
8530
+ bytes = readFileSync(target);
8504
8531
  } catch {
8505
8532
  await discard();
8506
8533
  throw new CliError("not_found", `the saved copy of ${file.id} was removed before its text was read; run it again`, {
@@ -8802,7 +8829,7 @@ var syncFiles = /* @__PURE__ */ __name(async (context, outOfTime, deadline = (ms
8802
8829
  return report;
8803
8830
  }, "syncFiles");
8804
8831
 
8805
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/pipeline-view.js
8832
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/pipeline-view.js
8806
8833
  var sumOf = /* @__PURE__ */ __name((amounts) => amounts.map(({ amount, currency }) => `${groupDigits(amount)} ${currency}`).join(", ") || "\u2014", "sumOf");
8807
8834
  var percent = /* @__PURE__ */ __name((share) => share === null ? "\u2014" : `${Math.round(share * 100)}%`, "percent");
8808
8835
  var openStages = /* @__PURE__ */ __name((stages) => {
@@ -8848,11 +8875,12 @@ ${outcomes.join("\n")}`
8848
8875
  ].join("\n\n");
8849
8876
  }, "pipelineView");
8850
8877
 
8851
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/search-all.js
8878
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/search-all.js
8852
8879
  var SEARCHED = ["crm", ...SOURCE_SEARCHED];
8853
8880
  var DEFAULT_LIMIT = 20;
8854
- var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2 }) => {
8855
- const all = annotate(new Command("all"), { effects: LOCAL_READ, partial: true, output: { entity: "hit" } }).summary("search stored deals and leads, messages, notes, calendar events and meetings").description("search the CRM's deals and leads by the words of their title, company, contacts and activities, and the messages, notes, calendar events and meetings other WireCat tools stored \u2014 best match first. Use it when you do not know where something was written").argument("<query...>", 'words and "phrases"; deals and leads match the words of their title, company, contacts and activities').addHelpText("after", SAVE_HELP);
8881
+ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2, leads = true }) => {
8882
+ const deals = leads ? "deals and leads" : "deals";
8883
+ const all = annotate(new Command("all"), { effects: LOCAL_READ, partial: true, output: { entity: "hit" } }).summary(`search stored ${deals}, messages, notes, calendar events and meetings`).description(`search the CRM's ${deals} by the words of their title, company, contacts and activities, and the messages, notes, calendar events and meetings other WireCat tools stored \u2014 best match first. Use it when you do not know where something was written`).argument("<query...>", `words and "phrases"; ${deals} match the words of their title, company, contacts and activities`).addHelpText("after", SAVE_HELP);
8856
8884
  searches.addCommand(searchAllOptions(all, SEARCHED));
8857
8885
  example(all, "search all Example LLC", "search all website --only crm --json");
8858
8886
  all.action(async (words, _opts, leaf) => {
@@ -8914,11 +8942,11 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
8914
8942
  });
8915
8943
  }, "addCrmSearchAll");
8916
8944
 
8917
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/store.js
8945
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/cli/profile-store.js
8918
8946
  import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
8919
8947
  import { tmpdir } from "node:os";
8920
8948
  import { join as join3 } from "node:path";
8921
- var openCrmStore = /* @__PURE__ */ __name(async (options) => {
8949
+ var openProfileStore = /* @__PURE__ */ __name(async (options) => {
8922
8950
  const { app, env, profile, readOnly, open: open2 } = options;
8923
8951
  const locked = readOnly && readOnlyLockOf(app, env) !== void 0;
8924
8952
  if (readOnly) {
@@ -8950,7 +8978,7 @@ var openCrmStore = /* @__PURE__ */ __name(async (options) => {
8950
8978
  removing();
8951
8979
  throw error;
8952
8980
  }
8953
- }, "openCrmStore");
8981
+ }, "openProfileStore");
8954
8982
  var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, env, account) => {
8955
8983
  const store = await open2(env);
8956
8984
  try {
@@ -8963,7 +8991,10 @@ var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, e
8963
8991
  }
8964
8992
  }, "withProfile");
8965
8993
 
8966
- // node_modules/.pnpm/@wirecat+cli-core@0.705.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1668a48934ee0d2606b0d61251c2625b/node_modules/@wirecat/cli-core/dist/crm/cli/index.js
8994
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/store.js
8995
+ var openCrmStore = openProfileStore;
8996
+
8997
+ // node_modules/.pnpm/@wirecat+cli-core@0.734.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_2c8b9986a0059051c16d1a97d78c2d87/node_modules/@wirecat/cli-core/dist/crm/cli/index.js
8967
8998
  var MOST4 = 500;
8968
8999
  var STAGE_REF = /^stage:\d+$/;
8969
9000
  var timeField = /* @__PURE__ */ __name((name, example, relation) => nativeField({ name, type: "time", operators: ["term", "range"], example, relation }), "timeField");
@@ -8985,7 +9016,7 @@ var LEADS_QUERY = { entity: "lead", backend: "native", fields: DEAL_FIELDS };
8985
9016
  var PIPELINES_QUERY = {
8986
9017
  entity: "pipeline",
8987
9018
  backend: "native",
8988
- fields: [termField("kind", "enum", "kind:lead", { values: DEAL_KINDS })]
9019
+ fields: [termField("kind", "enum", "kind:deal", { values: DEAL_KINDS })]
8989
9020
  };
8990
9021
  var STAGES_QUERY = {
8991
9022
  entity: "stage",
@@ -9131,7 +9162,10 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9131
9162
  renderAnswer(command, outputFor(command), body, view);
9132
9163
  }), "within");
9133
9164
  const example = /* @__PURE__ */ __name((command, ...lines) => annotate(command, { examples: lines.map((line) => `${options.app.command} work ${line}`) }), "example");
9134
- example(answerEntity(annotate(program.command("sync"), { effects: FETCH, offline: false, cooperative: true, partial: true }), "crm_sync", crmSync).description("bring the CRM's copy in the local store up to date: pipelines, companies, contacts, deals and leads that changed since the last sync, or everything with --rescan; a run stops before its deadline or --max-pages and the next one goes on from there").addHelpText("after", "\nWith the activities setting on, it also copies the activities and tasks on the deals and leads it keeps. Then each deal or lead that moved into a stage the stage-tasks setting names opens a local task, once per move."), "sync", "sync --rescan", "sync --max-pages 20").option("--rescan", "list everything again, every id too, dropping a round in progress").option("--max-pages <pages>", "at most this many requests to the CRM in this run", integer(1e5)).action(async (opts, command) => {
9165
+ const hasLeads = options.leads !== false;
9166
+ const dealsAndLeads = hasLeads ? "deals and leads" : "deals";
9167
+ example(answerEntity(annotate(program.command("sync"), { effects: FETCH, offline: false, cooperative: true, partial: true }), "crm_sync", crmSync).description(`bring the CRM's copy in the local store up to date: pipelines, companies, contacts, ${dealsAndLeads} that changed since the last sync, or everything with --rescan; a run stops before its deadline or --max-pages and the next one goes on from there`).addHelpText("after", `
9168
+ With the activities setting on, it also copies the activities and tasks on the ${dealsAndLeads} it keeps. Then each ${hasLeads ? "deal or lead" : "deal"} that moved into a stage the stage-tasks setting names opens a local task, once per move.`), "sync", "sync --rescan", "sync --max-pages 20").option("--rescan", "list everything again, every id too, dropping a round in progress").option("--max-pages <pages>", "at most this many requests to the CRM in this run", integer(1e5)).action(async (opts, command) => {
9135
9169
  const { signal } = environmentOf(command);
9136
9170
  await within(command, async (run3) => {
9137
9171
  const source = run3.source();
@@ -9188,7 +9222,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9188
9222
  await within(command, async (run3) => {
9189
9223
  const status = await crmStatus(run3.store, run3.account, { profile: run3.profile, now: now() });
9190
9224
  if (await viewerOf(run3))
9191
- outputFor(command).renderer.note("stored counts the whole copy, more than the deals and leads you may read");
9225
+ outputFor(command).renderer.note(`stored counts the whole copy, more than the ${dealsAndLeads} you may read`);
9192
9226
  return listOf(pathOf(command).join(" "), {
9193
9227
  items: status.items,
9194
9228
  limit: status.limit,
@@ -9197,7 +9231,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9197
9231
  });
9198
9232
  });
9199
9233
  });
9200
- example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description("apply scope mine to the contacts already stored: remove those no deal or lead of the chosen users and no kept company names, and the people they leave empty; counts only unless --yes, under scope all too. A sync that narrows the scope, or sync --rescan under mine, does this itself"), "store apply", "store apply --yes").option("--yes", "remove the contacts it counts; otherwise only count them").action(async (opts, command) => {
9234
+ example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description(`apply scope mine to the contacts already stored: remove those no ${hasLeads ? "deal or lead" : "deal"} of the chosen users and no kept company names, and the people they leave empty; counts only unless --yes, under scope all too. A sync that narrows the scope, or sync --rescan under mine, does this itself`), "store apply", "store apply --yes").option("--yes", "remove the contacts it counts; otherwise only count them").action(async (opts, command) => {
9201
9235
  const yes = opts.yes === true;
9202
9236
  await within(command, async (run3) => {
9203
9237
  const scope = crmSettingKey(run3.account, "scope");
@@ -9372,7 +9406,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9372
9406
  const run3 = /* @__PURE__ */ __name((command, work) => within(command, (opened) => work(contextOf3(opened, command))), "run");
9373
9407
  const create = write("create", "create", `make a ${kind} in the CRM, then store the CRM's copy of it`);
9374
9408
  if (create)
9375
- example(fields2(create), `${plural} create --title "Example kitchen" --amount 15000 --currency EUR`, `${plural} create --title "Example office" --pipeline Sales --stage "Quote sent" --field UF_CRM_SOURCE=web`).action(async (opts, command) => {
9409
+ example(fields2(create), `${plural} create --title "Example kitchen" --amount 15000 --currency EUR`, `${plural} create --title "Example office" --pipeline Sales --stage "Quote sent" --field Source=web`).action(async (opts, command) => {
9376
9410
  await run3(command, async (context) => {
9377
9411
  const done = await createCrmItem(context, kind, inputOf(opts), idOf2(opts));
9378
9412
  return answered(done.operationId, done.item);
@@ -9380,7 +9414,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9380
9414
  });
9381
9415
  const update2 = write("update", "update", `change a ${kind} in the CRM; what is left out keeps its value; the CRM's copy is stored again`);
9382
9416
  if (update2)
9383
- example(fields2(reference(update2)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field UF_CRM_SOURCE=`).action(async (ref, opts, command) => {
9417
+ example(fields2(reference(update2)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field Source=`).action(async (ref, opts, command) => {
9384
9418
  await run3(command, async (context) => {
9385
9419
  const done = await updateCrmItem(context, kind, ref, inputOf(opts), idOf2(opts));
9386
9420
  return answered(done.operationId, done.item);
@@ -9423,7 +9457,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9423
9457
  if (options.leads !== false)
9424
9458
  items("lead");
9425
9459
  const pipelines = annotate(program.command("pipelines"), { effects: NO_EFFECTS }).description("the CRM's pipelines and their stages, as last synced");
9426
- example(withQuery(annotate(pipelines.command("list"), { effects: LOCAL_READ, output: { entity: "pipeline" } }).description("pipelines copied from the CRM, with their stages in order and how many are open in each"), PIPELINES_QUERY), "pipelines list --json", "pipelines list kind:lead").action(async (words, _opts, command) => {
9460
+ example(withQuery(annotate(pipelines.command("list"), { effects: LOCAL_READ, output: { entity: "pipeline" } }).description("pipelines copied from the CRM, with their stages in order and how many are open in each"), PIPELINES_QUERY), "pipelines list --json", ...hasLeads ? ["pipelines list kind:lead"] : []).action(async (words, _opts, command) => {
9427
9461
  const terms = queryTerms(words, PIPELINES_QUERY, "pipelines list");
9428
9462
  await within(command, async (run3) => {
9429
9463
  const found = await run3.store.deals.pipelines({
@@ -9458,7 +9492,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9458
9492
  }, (body) => pipelineView(body, outputFor(command).color));
9459
9493
  });
9460
9494
  const stages = annotate(program.command("stages"), { effects: NO_EFFECTS }).description("the stages of the CRM's pipelines, as last synced");
9461
- example(withQuery(annotate(stages.command("list"), { effects: LOCAL_READ, output: { entity: "stage" } }).description("every stage of the CRM's pipelines in order, with its outcome and how many are open in it"), STAGES_QUERY), "stages list --json", "stages list kind:lead").action(async (words, _opts, command) => {
9495
+ example(withQuery(annotate(stages.command("list"), { effects: LOCAL_READ, output: { entity: "stage" } }).description("every stage of the CRM's pipelines in order, with its outcome and how many are open in it"), STAGES_QUERY), "stages list --json", ...hasLeads ? ["stages list kind:lead"] : []).action(async (words, _opts, command) => {
9462
9496
  const terms = queryTerms(words, STAGES_QUERY, "stages list");
9463
9497
  await within(command, async (run3) => {
9464
9498
  const kind = terms.has("kind") ? terms.get("kind") : void 0;
@@ -9501,6 +9535,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9501
9535
  open: options.open,
9502
9536
  app: options.app,
9503
9537
  live: options.live ?? [],
9538
+ ...options.liveQuery ? { liveQuery: options.liveQuery } : {},
9504
9539
  ...writes ? { writes } : {},
9505
9540
  now
9506
9541
  });
@@ -9508,7 +9543,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9508
9543
  if (options.files)
9509
9544
  addCrmFileCommands(program, { ...options, within, example, now });
9510
9545
  const fieldKinds = Object.keys(FIELD_KINDS).filter((word) => word !== "leads" || options.leads !== false);
9511
- const fields = annotate(program.command("fields"), { effects: NO_EFFECTS }).description("the CRM's own fields on deals, leads, people and organizations, as last synced");
9546
+ const fields = annotate(program.command("fields"), { effects: NO_EFFECTS }).description(`the CRM's own fields on ${hasLeads ? "deals, leads" : "deals"}, people and organizations, as last synced`);
9512
9547
  example(withQuery(answerEntity(annotate(fields.command("list"), { effects: LOCAL_READ }), "crm_field", crmField).description("the CRM's custom fields of one kind, in its order, with a list field's options").argument("<kind>", fieldKinds.join(", ")).option("--limit <n>", `fields per page, 1\u2013${MOST4}`, integer(MOST4), 50).option("--page <n>", "which page, starting at 1", integer(1e6)).option("--all", "every field, no paging"), FIELDS_QUERY), "fields list deals", "fields list people --json").action(async (kind, words, opts, command) => {
9513
9548
  if (!fieldKinds.includes(kind))
9514
9549
  throw new CliError("validation_error", `fields are listed for ${fieldKinds.join(", ")}; got ${kind}`, {
@@ -9531,13 +9566,58 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9531
9566
  });
9532
9567
  });
9533
9568
  const search = program.commands.find((one) => one.name() === "search") ?? annotate(program.command("search"), { effects: NO_EFFECTS }).description("search what the local store holds");
9534
- addCrmSearchAll(search, { within, app: options.app, example, viewerOf });
9569
+ addCrmSearchAll(search, { within, app: options.app, example, viewerOf, leads: hasLeads });
9570
+ if (options.account)
9571
+ program.addCommand(crmAccountCommand(options.app, options.account));
9535
9572
  }, "addCrmCommandsDefinition");
9536
9573
  var addCrmCommands = honoursDryRun(sharedCommand(addCrmCommandsDefinition));
9537
9574
 
9575
+ // dist/whoami.js
9576
+ var accountAnswer = /* @__PURE__ */ __name(async (hub) => {
9577
+ const details = await accountDetails(hub);
9578
+ const id = String(details.portalId);
9579
+ return {
9580
+ account: id,
9581
+ account_info: { id, ui_domain: details.uiDomain, time_zone: details.timeZone, type: details.accountType },
9582
+ user: null
9583
+ };
9584
+ }, "accountAnswer");
9585
+
9586
+ // dist/commands/account.js
9587
+ var rememberedOf = /* @__PURE__ */ __name((profile, env) => {
9588
+ const account = recalledAccount(IDENTITY, PROVIDER.name, profile, env)?.account;
9589
+ return account !== void 0 && /^\d+$/.test(account) ? account : void 0;
9590
+ }, "rememberedOf");
9591
+ var signedInTo = /* @__PURE__ */ __name((profile, env, keyring) => {
9592
+ const saved = new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {}, warn: /* @__PURE__ */ __name(() => {
9593
+ }, "warn") }).read(profile);
9594
+ if (!saved || saved.source === "environment")
9595
+ return void 0;
9596
+ return decodeSignIn(saved.secret).portalId;
9597
+ }, "signedInTo");
9598
+ var HUBSPOT_ACCOUNT = {
9599
+ provider: PROVIDER.name,
9600
+ service: "HubSpot",
9601
+ held: /* @__PURE__ */ __name((profile, { env, keyring }) => {
9602
+ const remembered = rememberedOf(profile, env);
9603
+ try {
9604
+ const saved = signedInTo(profile, env, keyring);
9605
+ if (saved)
9606
+ return { account: saved, signedIn: true };
9607
+ } catch (error) {
9608
+ if (!remembered)
9609
+ throw error;
9610
+ }
9611
+ return remembered === void 0 ? void 0 : { account: remembered, signedIn: false };
9612
+ }, "held"),
9613
+ // HubSpot has no call that revokes a service key or a private app token; the account's settings do.
9614
+ signedOut: /* @__PURE__ */ __name((profile) => `the sign-in of ${profile} (the key stays valid in HubSpot until you delete or rotate it there)`, "signedOut"),
9615
+ resolveSettings: configuration.resolveSettings
9616
+ };
9617
+
9538
9618
  // dist/commands/crm-shared.js
9539
9619
  var savedAccount = /* @__PURE__ */ __name(async (env, profile) => {
9540
- const { openHubspotStore } = await import("./store-2MNUHHZC.js");
9620
+ const { openHubspotStore } = await import("./store-CDY2PW6J.js");
9541
9621
  const store = await openHubspotStore(env, { readOnly: true }).catch(() => void 0);
9542
9622
  if (!store)
9543
9623
  return void 0;
@@ -9552,9 +9632,9 @@ var savedAccount = /* @__PURE__ */ __name(async (env, profile) => {
9552
9632
  var openProfile = /* @__PURE__ */ __name(async (command, { readOnly }) => {
9553
9633
  const { env, profile, environment } = contextOf(command);
9554
9634
  const [{ openHubspotStore, PROVIDER: PROVIDER2 }, { hubspotCrmSource }, { hubspotCrmWriter }] = await Promise.all([
9555
- import("./store-2MNUHHZC.js"),
9556
- import("./source-2UCNCCO7.js"),
9557
- import("./writer-X7PGBLDH.js")
9635
+ import("./store-CDY2PW6J.js"),
9636
+ import("./source-PBCQAG4C.js"),
9637
+ import("./writer-WGHWQTC2.js")
9558
9638
  ]);
9559
9639
  const fromToken = fromEnvironment(command);
9560
9640
  const online = metaOf(command).effects?.remote !== "none";
@@ -9616,7 +9696,8 @@ var crmSharedCommands = /* @__PURE__ */ __name(() => {
9616
9696
  leads: true,
9617
9697
  writes: HUBSPOT_WRITES,
9618
9698
  live: ["person", "organization", "user"],
9619
- activities: true
9699
+ activities: true,
9700
+ account: HUBSPOT_ACCOUNT
9620
9701
  });
9621
9702
  return [...holder.commands];
9622
9703
  }, "crmSharedCommands");
@@ -9628,6 +9709,100 @@ var contextOf2 = /* @__PURE__ */ __name((command, resolving) => {
9628
9709
  }, "contextOf");
9629
9710
  var scheduleCommand = /* @__PURE__ */ __name(() => scheduleCommandFor({ app: IDENTITY, context: contextOf2 }), "scheduleCommand");
9630
9711
 
9712
+ // dist/commands/session.js
9713
+ var HUBSPOT = IDENTITY.command;
9714
+ var answer = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
9715
+ var storageOf = /* @__PURE__ */ __name((raw) => {
9716
+ if (raw === "keyring" || raw === "file")
9717
+ return raw;
9718
+ throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
9719
+ }, "storageOf");
9720
+ var tokensHere = /* @__PURE__ */ __name((env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {} }), "tokensHere");
9721
+ var checkedToken = /* @__PURE__ */ __name(async (command, token) => {
9722
+ const { env, profile, keyring, settings, run: run3 } = contextOf(command);
9723
+ const who = await run3((events) => accountAnswer(hubFor(command, { token }, events)));
9724
+ refuseTakenCrmAccount(IDENTITY, HUBSPOT_ACCOUNT, { env, profile, profiles: settings.configuredProfiles, ...keyring ? { keyring } : {} }, { account: who.account });
9725
+ const { ui_domain: uiDomain, time_zone: timeZone } = who.account_info;
9726
+ return { who, signIn: encodeSignIn({ token, portalId: who.account, uiDomain, timeZone }) };
9727
+ }, "checkedToken");
9728
+ var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
9729
+ effects: FETCH,
9730
+ lifetime: "interactive",
9731
+ mcp: false,
9732
+ examples: [
9733
+ `${HUBSPOT} work session start`,
9734
+ `${HUBSPOT} work session start --json`,
9735
+ `${HUBSPOT} work session start --credential-storage file`
9736
+ ]
9737
+ })).summary(`sign in to ${SERVICE} with a service key or a private app token`).description("sign this profile in: a service key (Development \u2192 Keys \u2192 Service keys) or a legacy private app's access token is asked hidden or read from stdin, never taken as an argument, checked against the account, and only then kept in the keyring with the account's id, or in a private file. The key reads and writes what its scopes allow").option("--credential-storage <storage>", "where the key is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring").action(async function(args) {
9738
+ const { env, profile, tokens } = contextOf(this);
9739
+ refuseCommandName(profile, commandWords(rootOf(this)), HUBSPOT);
9740
+ refuseOffline(this, SERVICE);
9741
+ const token = (await readSecret(`${SERVICE} service key or private app token: `, secretInputOf(this))).trim();
9742
+ if (!token)
9743
+ throw new CliError("validation_error", "no token was given");
9744
+ const { who, signIn } = await checkedToken(this, token);
9745
+ const storedIn = tokens.write(profile, signIn, args.credentialStorage);
9746
+ rememberAccount(IDENTITY, profile, who.account, env);
9747
+ answer(this, { profile, state: "saved", kind: "token", stored_in: storedIn, verified: true, ...who });
9748
+ }), "startCommand");
9749
+ var statusCommand = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
9750
+ effects: REMOTE_READ,
9751
+ examples: [`${HUBSPOT} work session status`, `${HUBSPOT} work session status --check --json`]
9752
+ }).summary("show where this profile's key comes from; --check names the account it reads").description(`show which account this profile signs in to and where its key comes from: ${IDENTITY.envPrefix}_TOKEN, the keyring or a file; never the key`).option("--check", `ask ${SERVICE} whether the key still works and which account it reads`).action(async function(args) {
9753
+ const { env, profile, tokens, run: run3 } = contextOf(this);
9754
+ const saved = tokens.read(profile);
9755
+ const fromToken = saved?.source === "environment";
9756
+ const named = fromToken ? environmentAccount(env) : storedSignIn(this)?.portalId;
9757
+ const status = {
9758
+ profile,
9759
+ state: saved ? "saved" : "missing",
9760
+ kind: saved ? "token" : null,
9761
+ token_from: saved?.source ?? null,
9762
+ account: named ?? null
9763
+ };
9764
+ if (!args.check || !saved)
9765
+ return answer(this, { ...status, verified: false });
9766
+ if (!fromToken)
9767
+ return answer(this, { ...status, verified: true, ...await withHub(this, accountAnswer) });
9768
+ refuseOffline(this, SERVICE);
9769
+ const who = await run3((events) => accountAnswer(hubFor(this, { token: saved.secret, portalId: named }, events)));
9770
+ if (named)
9771
+ refuseAccountMismatch(named, who.account);
9772
+ answer(this, { ...status, verified: true, ...who });
9773
+ }), "statusCommand");
9774
+ var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
9775
+ effects: LOCAL_WRITE,
9776
+ mcp: false,
9777
+ examples: [`${HUBSPOT} work session end`]
9778
+ })).summary("forget this profile's key on this computer").description(`forget this profile's key and account id on this computer; the key itself stays valid in ${SERVICE}: delete or rotate it where it was made`).action(function() {
9779
+ refuseUnderReadOnly(this, "session end");
9780
+ const { profile, tokens } = contextOf(this);
9781
+ answer(this, { profile, ended: tokens.remove(profile) });
9782
+ }), "endCommand");
9783
+ var listCommand = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
9784
+ effects: LOCAL_READ,
9785
+ examples: [`${HUBSPOT} session list`, `${HUBSPOT} session list --json`]
9786
+ })).summary("list the profiles here and whether each is signed in").description("list the profiles on this computer, whether each has a key and for which account; picks none").action(function() {
9787
+ const environment = environmentOf(this);
9788
+ const env = environment.env ?? process.env;
9789
+ const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
9790
+ const tokens = tokensHere(env, environment.keyring);
9791
+ const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
9792
+ try {
9793
+ const saved = tokens.read(profile);
9794
+ const account = saved && saved.source !== "environment" ? decodeSignIn(saved.secret).portalId : null;
9795
+ return { profile, signed_in: saved !== void 0, token_from: saved?.source ?? null, account };
9796
+ } catch (error) {
9797
+ if (!(error instanceof CliError))
9798
+ throw error;
9799
+ return { profile, signed_in: null, token_from: null, account: null, error: error.message };
9800
+ }
9801
+ });
9802
+ renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
9803
+ }), "listCommand");
9804
+ var sessionCommand = /* @__PURE__ */ __name(() => annotate(new Command("session"), { effects: LOCAL_READ }).description(`keep this profile's ${SERVICE} key and account id in the OS keyring`).addCommand(startCommand()).addCommand(statusCommand()).addCommand(endCommand()).addCommand(listCommand()), "sessionCommand");
9805
+
9631
9806
  // dist/setup/texts.en.json
9632
9807
  var texts_en_default = {
9633
9808
  "key.title": "Make a key",
@@ -9822,7 +9997,6 @@ var definition = /* @__PURE__ */ __name(() => ({
9822
9997
  commands: /* @__PURE__ */ __name(() => [
9823
9998
  commandsCommand(IDENTITY),
9824
9999
  sessionCommand(),
9825
- accountCommand(),
9826
10000
  ...crmSharedCommands(),
9827
10001
  apiCommand(),
9828
10002
  scheduleCommand(),