@wirecat/hubspot-cli 0.5.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 +28 -0
  2. package/README.md +73 -52
  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-PGFXLOKN.js → all-profiles-HFVXPMF6.js} +11 -11
  7. package/dist/bundle/{anthropic-LPOJ3TYF.js → anthropic-VE6WR6IN.js} +5 -5
  8. package/dist/bundle/{app-server-EYWGCSRY.js → app-server-GZ4DCQK7.js} +68 -68
  9. package/dist/bundle/{bun-ZJOOKIIW.js → bun-2DHMKD34.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-Y6KKH2OW.js → bun-sqlite-T5XTYL7L.js} +6 -6
  11. package/dist/bundle/{chunk-WQZENAPE.js → chunk-24HPBWKZ.js} +63 -4
  12. package/dist/bundle/{chunk-STTHRJBX.js → chunk-2I2KBCS6.js} +5 -5
  13. package/dist/bundle/{chunk-AIQT2GGK.js → chunk-2K5BAY32.js} +19 -19
  14. package/dist/bundle/{chunk-WEM4FZPM.js → chunk-2VUIJ5XB.js} +2 -2
  15. package/dist/bundle/{chunk-KRTXJMCD.js → chunk-3HS7JTPI.js} +27 -177
  16. package/dist/bundle/{chunk-BCW7DAVV.js → chunk-3TLNO3VM.js} +2 -2
  17. package/dist/bundle/{chunk-AVBKXCEY.js → chunk-3W5R3XAH.js} +8 -8
  18. package/dist/bundle/{chunk-QDNYJOWJ.js → chunk-3WG4MTQI.js} +1 -1
  19. package/dist/bundle/{chunk-HPRGUUHY.js → chunk-3YTTWJKL.js} +1 -1
  20. package/dist/bundle/{chunk-ZKPM53YG.js → chunk-4UEYVM46.js} +4 -4
  21. package/dist/bundle/{chunk-NKIKMG33.js → chunk-5ILCAAY4.js} +35 -35
  22. package/dist/bundle/{chunk-34HDRZIL.js → chunk-5IPB5WLB.js} +12 -12
  23. package/dist/bundle/{chunk-QPTHEZZ5.js → chunk-5NIIXJV3.js} +2 -2
  24. package/dist/bundle/{chunk-MPNMEWHA.js → chunk-5O5WYSSO.js} +1900 -650
  25. package/dist/bundle/{chunk-MPQ4SPZG.js → chunk-5VTKBGPW.js} +74 -31
  26. package/dist/bundle/{chunk-QIHJKE4K.js → chunk-5WDNG4QE.js} +7 -7
  27. package/dist/bundle/{chunk-OFOA6VJ2.js → chunk-67YPTVGP.js} +3 -3
  28. package/dist/bundle/{chunk-DEUCWBBH.js → chunk-6DABKZYH.js} +70 -11
  29. package/dist/bundle/{chunk-VIJV474N.js → chunk-745FMNI5.js} +1 -1
  30. package/dist/bundle/{chunk-KXWRVLSU.js → chunk-AKSWXRIU.js} +1 -1
  31. package/dist/bundle/{chunk-PMGAU6AP.js → chunk-AP3CWDRK.js} +2 -2
  32. package/dist/bundle/{chunk-5UPNDUAA.js → chunk-BM5F2ZNI.js} +2 -2
  33. package/dist/bundle/{chunk-EPBHJMF6.js → chunk-BU5CEMUH.js} +13 -13
  34. package/dist/bundle/{chunk-6PWRJGX4.js → chunk-CTN4DW2F.js} +4 -4
  35. package/dist/bundle/{chunk-CWCJEAHZ.js → chunk-CU76ZACK.js} +3 -3
  36. package/dist/bundle/{chunk-4RZ4DUQT.js → chunk-DIKUPU3T.js} +3 -3
  37. package/dist/bundle/{chunk-POTS24SH.js → chunk-E27NRLJZ.js} +18 -18
  38. package/dist/bundle/{chunk-BH5FEFZB.js → chunk-EB53G4HO.js} +2 -2
  39. package/dist/bundle/{chunk-DJUUQG6Y.js → chunk-EJZIEBAR.js} +8 -8
  40. package/dist/bundle/{chunk-BW7NPFVC.js → chunk-G6LDK6DJ.js} +7 -7
  41. package/dist/bundle/{chunk-V5VMAHDQ.js → chunk-GEJI27GN.js} +6 -6
  42. package/dist/bundle/{chunk-YQBGPBYN.js → chunk-GHXTNKX2.js} +2 -2
  43. package/dist/bundle/{chunk-5HGS65I3.js → chunk-GR4HZBWO.js} +2 -2
  44. package/dist/bundle/{chunk-I334AT2H.js → chunk-GWXTVO43.js} +7 -7
  45. package/dist/bundle/{chunk-Z7FC6VVM.js → chunk-H4W2OO35.js} +1 -1
  46. package/dist/bundle/{chunk-KAW5VEER.js → chunk-H5HBZCEJ.js} +8 -8
  47. package/dist/bundle/{chunk-VCYUYFIV.js → chunk-HX2BE7DO.js} +1 -1
  48. package/dist/bundle/{chunk-3CHJYWA2.js → chunk-HYDXA624.js} +6 -6
  49. package/dist/bundle/{chunk-DDMBPYHP.js → chunk-HZIGGAC7.js} +2 -2
  50. package/dist/bundle/{chunk-RJBKDZGV.js → chunk-I75ON7VM.js} +8 -8
  51. package/dist/bundle/{chunk-ODRF47VS.js → chunk-ID4GJFE7.js} +8 -8
  52. package/dist/bundle/{chunk-LWS5AO3H.js → chunk-J2SCELII.js} +16 -16
  53. package/dist/bundle/{chunk-R7ZOCDNG.js → chunk-J4FXBF44.js} +1 -1
  54. package/dist/bundle/{chunk-QCHW7R7L.js → chunk-J76CMNWQ.js} +1 -1
  55. package/dist/bundle/{chunk-AHZQMSXW.js → chunk-JDCFHZNU.js} +8 -8
  56. package/dist/bundle/{chunk-K3WCBNH4.js → chunk-JFLKTYH5.js} +6 -6
  57. package/dist/bundle/{chunk-5WADRBQG.js → chunk-K4Y2ZWOO.js} +3 -3
  58. package/dist/bundle/{chunk-PPQRWFJZ.js → chunk-KDW7B7AR.js} +5 -5
  59. package/dist/bundle/{chunk-YZ5MULJM.js → chunk-KKMOKSS5.js} +3 -3
  60. package/dist/bundle/{chunk-MFWECOO3.js → chunk-LHY5XGIR.js} +59 -59
  61. package/dist/bundle/{chunk-MW4ROXQ6.js → chunk-LTU4BQ4S.js} +3 -3
  62. package/dist/bundle/{chunk-A5UTNGI4.js → chunk-M3LRSN6J.js} +13 -13
  63. package/dist/bundle/{chunk-RZS7N3OZ.js → chunk-MJ24YFXZ.js} +7 -7
  64. package/dist/bundle/{chunk-HBFSGL5E.js → chunk-MSQGZHKM.js} +32 -28
  65. package/dist/bundle/{chunk-OCISQFMW.js → chunk-NQOQG7L3.js} +1 -1
  66. package/dist/bundle/{chunk-QLFD3MOL.js → chunk-PDVMYIBP.js} +1492 -733
  67. package/dist/bundle/{chunk-NEDV6RCQ.js → chunk-PR7ZDMGF.js} +3 -3
  68. package/dist/bundle/{chunk-L6WSFVTD.js → chunk-PZ3QJDTD.js} +5 -5
  69. package/dist/bundle/{chunk-LXLXF2OE.js → chunk-Q6AC7WLD.js} +3 -3
  70. package/dist/bundle/{chunk-WXEN6AXQ.js → chunk-QH47G73D.js} +3 -3
  71. package/dist/bundle/{chunk-23CLSKY7.js → chunk-QK5HQUHB.js} +3 -3
  72. package/dist/bundle/{chunk-KC4ILAKO.js → chunk-R26OEZOL.js} +1 -1
  73. package/dist/bundle/{chunk-NLPGUYCG.js → chunk-RLK2EGQD.js} +21 -15
  74. package/dist/bundle/{chunk-SBNZYRVZ.js → chunk-RLNPTES2.js} +4 -4
  75. package/dist/bundle/{chunk-K5S7MKBB.js → chunk-T4MZJMEJ.js} +17 -17
  76. package/dist/bundle/{chunk-MGMLSPIY.js → chunk-TAPQZYXY.js} +1 -1
  77. package/dist/bundle/{chunk-HPSESLOZ.js → chunk-TCSVW7BA.js} +1 -1
  78. package/dist/bundle/{chunk-7Q64D56R.js → chunk-THGAVPRA.js} +11 -11
  79. package/dist/bundle/{chunk-BVK4GUUI.js → chunk-TRLV5NWZ.js} +1706 -1820
  80. package/dist/bundle/{chunk-WDR77HPO.js → chunk-TT75CEYZ.js} +8 -1
  81. package/dist/bundle/{chunk-L4SVHQ7H.js → chunk-TXO4CJW3.js} +7 -7
  82. package/dist/bundle/{chunk-MKBQFD37.js → chunk-UCGZRZJA.js} +1 -1
  83. package/dist/bundle/{chunk-5ENY4POG.js → chunk-UVGJL753.js} +61 -61
  84. package/dist/bundle/{chunk-GZJP3KQQ.js → chunk-UZ2CL435.js} +1 -1
  85. package/dist/bundle/{chunk-YJLJZMEA.js → chunk-V7N2K5OT.js} +33 -30
  86. package/dist/bundle/{chunk-MENMD5Y5.js → chunk-VR2CJFVL.js} +8 -8
  87. package/dist/bundle/{chunk-EGR3YUWD.js → chunk-WASBOYI2.js} +4 -4
  88. package/dist/bundle/{chunk-NEP67GLY.js → chunk-WE4JSHIG.js} +6 -6
  89. package/dist/bundle/{chunk-ABPZOI3C.js → chunk-X2QRCFGJ.js} +4 -4
  90. package/dist/bundle/{chunk-ZLWQPUPB.js → chunk-XRFYVVFU.js} +2 -2
  91. package/dist/bundle/{chunk-6S422S22.js → chunk-YDG5FIQB.js} +7 -9
  92. package/dist/bundle/{chunk-ZMHD76RE.js → chunk-YIH2A2PQ.js} +2 -2
  93. package/dist/bundle/{chunk-7RIE3DAW.js → chunk-ZERQSELP.js} +189 -158
  94. package/dist/bundle/{chunk-BGUGTMTS.js → chunk-ZKTYTOF4.js} +8 -8
  95. package/dist/bundle/command-contract-5FXCYQUS.js +40 -0
  96. package/dist/bundle/{command-server-entry-B7S5AUE6.js → command-server-entry-H6IAJNOF.js} +28 -28
  97. package/dist/bundle/{decode-7L33C5UJ.js → decode-TR2EC46M.js} +5 -5
  98. package/dist/bundle/{dispatch-BIGHHSXV.js → dispatch-B2EP6DDT.js} +8 -8
  99. package/dist/bundle/{echarts-CWR3QH55.js → echarts-7OP7I5B2.js} +2 -2
  100. package/dist/bundle/{embed-GXQ3HOQ6.js → embed-FLGS4LN7.js} +6 -6
  101. package/dist/bundle/{embedder-47OYXGLS.js → embedder-JIXQXCP3.js} +9 -9
  102. package/dist/bundle/{failure-VMZOU5GZ.js → failure-AOACEURF.js} +2 -2
  103. package/dist/bundle/{first-run-YVQQOUQG.js → first-run-XJ2NWIK2.js} +12 -12
  104. package/dist/bundle/first-screen-U73G5CMM.js +40 -0
  105. package/dist/bundle/hubspot.js +27 -27
  106. package/dist/bundle/{instructions-QFS2MPK3.js → instructions-PYCYV6QE.js} +1 -1
  107. package/dist/bundle/{mcp-Z2KZNCXB.js → mcp-ZNULRPZ4.js} +2 -2
  108. package/dist/bundle/meeting-combined-IHTM5H5B.js +25 -0
  109. package/dist/bundle/{meeting-model-GLF2HVJG.js → meeting-model-2PA5WJY5.js} +11 -11
  110. package/dist/bundle/{meeting-semantic-RG56F4YX.js → meeting-semantic-5IH63QFV.js} +6 -6
  111. package/dist/bundle/{node-3TSWTXGI.js → node-6GTNIVBM.js} +2 -2
  112. package/dist/bundle/{node-sqlite-UPQCG7DJ.js → node-sqlite-FBCEHPNT.js} +7 -7
  113. package/dist/bundle/{oauth-MCVEENW3.js → oauth-BFP4SCL5.js} +7 -7
  114. package/dist/bundle/{open-JMUTKUYJ.js → open-MLU4MHGO.js} +5 -5
  115. package/dist/bundle/{openai-HT7YDOK7.js → openai-R7WJI6SO.js} +15 -15
  116. package/dist/bundle/{process-7RC6DAGM.js → process-NMNQLJHZ.js} +1 -1
  117. package/dist/bundle/{program-3DLBMOEJ.js → program-Z735HPFG.js} +474 -320
  118. package/dist/bundle/{prompt-7EROPXPF.js → prompt-A6RM55Q4.js} +5 -5
  119. package/dist/bundle/{recognize-B232GXD2.js → recognize-ORRDV45M.js} +4 -4
  120. package/dist/bundle/{remote-HGV64VRC.js → remote-UF3WSC4X.js} +9 -9
  121. package/dist/bundle/{rerank-5S6TDXHD.js → rerank-ZSJORUGH.js} +7 -7
  122. package/dist/bundle/{schemas-SB42IXEX.js → schemas-EXBNVPMI.js} +1 -1
  123. package/dist/bundle/{serve-D2WFCV6Z.js → serve-4KBJ6SIA.js} +9 -9
  124. package/dist/bundle/{server-4AXPTJPV.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-DAFMZNLI.js → sqlite-runtime-XPDUWOPG.js} +6 -6
  128. package/dist/bundle/{state-7OEBDXVV.js → state-4M26H7NL.js} +6 -6
  129. package/dist/bundle/{store-2ZWSWF76.js → store-3W4ZOOIB.js} +28 -24
  130. package/dist/bundle/store-CDY2PW6J.js +34 -0
  131. package/dist/bundle/{store-KC6US326.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 +16 -10
  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 +3 -3
  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-RBQMA24N.js +0 -40
  170. package/dist/bundle/command-contract-O2UKYHLD.js +0 -40
  171. package/dist/bundle/first-screen-TU3KE2B5.js +0 -40
  172. package/dist/bundle/meeting-combined-WBEOLQMP.js +0 -25
  173. package/dist/bundle/server-FFHVNABP.js +0 -86
  174. package/dist/bundle/source-DF63EC2B.js +0 -945
  175. package/dist/bundle/store-Q3ZKD4FJ.js +0 -34
  176. package/dist/bundle/store-maintenance-command-24A4GBRP.js +0 -73
  177. package/dist/bundle/surface-SPTM57EP.js +0 -72
  178. package/dist/bundle/writer-EQQ55HOS.js +0 -86
@@ -1,11 +1,14 @@
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-WQZENAPE.js";
4
+ PROVIDER
5
+ } from "./chunk-K4Y2ZWOO.js";
6
6
  import {
7
7
  accountDetails
8
- } from "./chunk-5HGS65I3.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,
@@ -25,50 +28,44 @@ import {
25
28
  honoursDryRun,
26
29
  hubspotTransport,
27
30
  isRecord,
31
+ oauthAccount,
28
32
  ownerLanguageOf,
29
33
  run,
30
34
  runsCommand,
31
35
  scheduleCommandFor,
32
36
  searchAllOptions,
33
37
  serviceApiCommand,
34
- serviceApiPermissions,
35
38
  setupCommand,
36
39
  skillCommand,
37
40
  upgradeCommand,
38
41
  writeCsv
39
- } from "./chunk-BVK4GUUI.js";
40
- import "./chunk-HPRGUUHY.js";
41
- import {
42
- PROVIDER
43
- } from "./chunk-5WADRBQG.js";
44
- import "./chunk-GZJP3KQQ.js";
42
+ } from "./chunk-TRLV5NWZ.js";
43
+ import "./chunk-3YTTWJKL.js";
44
+ import "./chunk-UZ2CL435.js";
45
45
  import {
46
46
  SOURCE_SEARCHED,
47
47
  allAnswer,
48
48
  historySkipsOf,
49
49
  offsetOf,
50
50
  refuseOffline
51
- } from "./chunk-HBFSGL5E.js";
52
- import "./chunk-NEP67GLY.js";
53
- import "./chunk-AVBKXCEY.js";
54
- import "./chunk-MGMLSPIY.js";
51
+ } from "./chunk-MSQGZHKM.js";
52
+ import "./chunk-WE4JSHIG.js";
53
+ import "./chunk-3W5R3XAH.js";
54
+ import "./chunk-TAPQZYXY.js";
55
55
  import {
56
56
  addStoreMaintenanceCommands
57
- } from "./chunk-MFWECOO3.js";
58
- import {
59
- commandPathKey,
60
- commandPermissions,
61
- terminalAsker
62
- } from "./chunk-KRTXJMCD.js";
63
- import "./chunk-MENMD5Y5.js";
64
- import "./chunk-L4SVHQ7H.js";
65
- import "./chunk-34HDRZIL.js";
66
- import "./chunk-BH5FEFZB.js";
67
- import "./chunk-ABPZOI3C.js";
68
- import "./chunk-PPQRWFJZ.js";
69
- import "./chunk-ODRF47VS.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";
70
66
  import {
71
67
  CRM_ASSIGN_OTHERS_KEY,
68
+ CRM_SHARED_FOLDERS,
72
69
  CRM_WRITE_DEFAULTS,
73
70
  CRM_WRITE_KEYS,
74
71
  Pacer,
@@ -76,7 +73,11 @@ import {
76
73
  SYNCED_FROM,
77
74
  SYNC_FAILED,
78
75
  closeCrmItem,
76
+ commandPathKey,
77
+ commandPermissions,
78
+ completeCrmActivity,
79
79
  conditionsOf,
80
+ createCrmActivity,
80
81
  createCrmItem,
81
82
  createCrmRecord,
82
83
  crmAccounts,
@@ -102,27 +103,29 @@ import {
102
103
  removeCrmItem,
103
104
  searchAll,
104
105
  selectedCodes,
106
+ serviceApiPermissions,
105
107
  shortened,
106
108
  syncRecorded,
107
109
  taskAccount,
110
+ terminalAsker,
108
111
  updateCrmItem,
109
112
  updateCrmRecord,
110
113
  viewerOf,
111
114
  wantedCodes,
112
115
  withCustomFields,
113
116
  withReadableDeal
114
- } from "./chunk-MPNMEWHA.js";
117
+ } from "./chunk-5O5WYSSO.js";
115
118
  import {
116
119
  safeName
117
- } from "./chunk-A5UTNGI4.js";
118
- import "./chunk-VCYUYFIV.js";
119
- import "./chunk-WDR77HPO.js";
120
+ } from "./chunk-M3LRSN6J.js";
121
+ import "./chunk-HX2BE7DO.js";
122
+ import "./chunk-TT75CEYZ.js";
120
123
  import {
121
124
  latestVersion,
122
125
  runUpdate,
123
126
  updateNotice
124
- } from "./chunk-4RZ4DUQT.js";
125
- import "./chunk-QDNYJOWJ.js";
127
+ } from "./chunk-DIKUPU3T.js";
128
+ import "./chunk-3WG4MTQI.js";
126
129
  import {
127
130
  commandPath,
128
131
  dateWindow,
@@ -137,14 +140,14 @@ import {
137
140
  unfilteredQuery,
138
141
  withQuery,
139
142
  withWords
140
- } from "./chunk-EPBHJMF6.js";
141
- import "./chunk-23CLSKY7.js";
142
- import "./chunk-V5VMAHDQ.js";
143
- import "./chunk-7Q64D56R.js";
144
- import "./chunk-LXLXF2OE.js";
145
- import "./chunk-SBNZYRVZ.js";
146
- import "./chunk-WXEN6AXQ.js";
147
- import "./chunk-STTHRJBX.js";
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-7RIE3DAW.js";
192
- import "./chunk-RJBKDZGV.js";
193
- import "./chunk-OFOA6VJ2.js";
194
- import "./chunk-L6WSFVTD.js";
195
- import "./chunk-R7ZOCDNG.js";
196
- import "./chunk-K5S7MKBB.js";
197
- import "./chunk-YZ5MULJM.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,47 +207,48 @@ import {
204
207
  crmSettingKey,
205
208
  seenBy,
206
209
  viewerSql
207
- } from "./chunk-QLFD3MOL.js";
208
- import "./chunk-BGUGTMTS.js";
210
+ } from "./chunk-PDVMYIBP.js";
211
+ import "./chunk-ZKTYTOF4.js";
209
212
  import {
213
+ aheadOf,
210
214
  dayIn
211
- } from "./chunk-CWCJEAHZ.js";
212
- import "./chunk-I334AT2H.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-YJLJZMEA.js";
219
- import "./chunk-DDMBPYHP.js";
220
- import "./chunk-AHZQMSXW.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-QIHJKE4K.js";
225
- import "./chunk-K3WCBNH4.js";
226
- import "./chunk-6PWRJGX4.js";
228
+ } from "./chunk-5WDNG4QE.js";
229
+ import "./chunk-JFLKTYH5.js";
230
+ import "./chunk-CTN4DW2F.js";
227
231
  import {
228
232
  DESKTOP,
229
233
  IDENTITY,
230
234
  PACKAGE,
231
235
  SKILL
232
- } from "./chunk-6S422S22.js";
233
- import "./chunk-BCW7DAVV.js";
236
+ } from "./chunk-YDG5FIQB.js";
237
+ import "./chunk-3TLNO3VM.js";
234
238
  import "./chunk-EH6ZEJGT.js";
235
- import "./chunk-DEUCWBBH.js";
236
- import "./chunk-DJUUQG6Y.js";
239
+ import "./chunk-6DABKZYH.js";
240
+ import "./chunk-EJZIEBAR.js";
237
241
  import {
238
242
  installerOf
239
- } from "./chunk-VIJV474N.js";
243
+ } from "./chunk-745FMNI5.js";
240
244
  import {
241
245
  fieldsOf
242
- } from "./chunk-BW7NPFVC.js";
246
+ } from "./chunk-G6LDK6DJ.js";
243
247
  import {
244
248
  foldName
245
- } from "./chunk-POTS24SH.js";
246
- import "./chunk-NEDV6RCQ.js";
247
- import "./chunk-KXWRVLSU.js";
249
+ } from "./chunk-E27NRLJZ.js";
250
+ import "./chunk-PR7ZDMGF.js";
251
+ import "./chunk-AKSWXRIU.js";
248
252
  import {
249
253
  CRM_ACTIVITY_KINDS,
250
254
  CRM_KINDS,
@@ -255,39 +259,40 @@ import {
255
259
  normalCrmUserId,
256
260
  parseDecimal,
257
261
  scaleOf
258
- } from "./chunk-NLPGUYCG.js";
259
- import "./chunk-KC4ILAKO.js";
260
- import "./chunk-ZMHD76RE.js";
262
+ } from "./chunk-RLK2EGQD.js";
263
+ import "./chunk-R26OEZOL.js";
264
+ import "./chunk-YIH2A2PQ.js";
261
265
  import {
262
266
  SAVE_HELP,
263
267
  defineQuery,
264
268
  queryFieldsOf,
265
269
  timezoneOf,
266
270
  zonedMoment
267
- } from "./chunk-5ENY4POG.js";
268
- import "./chunk-HPSESLOZ.js";
269
- import "./chunk-RZS7N3OZ.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-MW4ROXQ6.js";
274
- import "./chunk-5UPNDUAA.js";
275
- import "./chunk-WEM4FZPM.js";
276
- import "./chunk-3CHJYWA2.js";
277
- import "./chunk-Z7FC6VVM.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-AIQT2GGK.js";
285
+ } from "./chunk-2K5BAY32.js";
282
286
  import {
283
287
  isoTime
284
- } from "./chunk-KAW5VEER.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-PMGAU6AP.js";
305
- import "./chunk-QCHW7R7L.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.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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"],
@@ -7023,196 +7030,6 @@ var withHub = /* @__PURE__ */ __name((command, body) => {
7023
7030
  return contextOf(command).run((events) => body(hubFor(command, signIn, events)));
7024
7031
  }, "withHub");
7025
7032
 
7026
- // dist/whoami.js
7027
- var accountAnswer = /* @__PURE__ */ __name(async (hub) => {
7028
- const details = await accountDetails(hub);
7029
- const id = String(details.portalId);
7030
- return {
7031
- account: id,
7032
- account_info: { id, ui_domain: details.uiDomain, time_zone: details.timeZone, type: details.accountType },
7033
- user: null
7034
- };
7035
- }, "accountAnswer");
7036
-
7037
- // dist/commands/session.js
7038
- var HUBSPOT = IDENTITY.command;
7039
- var answer = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
7040
- var storageOf = /* @__PURE__ */ __name((raw) => {
7041
- if (raw === "keyring" || raw === "file")
7042
- return raw;
7043
- throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
7044
- }, "storageOf");
7045
- var tokensHere = /* @__PURE__ */ __name((env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {} }), "tokensHere");
7046
- var signedInTo = /* @__PURE__ */ __name((env, keyring, profile) => {
7047
- const saved = tokensHere(env, keyring).read(profile);
7048
- if (!saved || saved.source === "environment")
7049
- return void 0;
7050
- return decodeSignIn(saved.secret).portalId;
7051
- }, "signedInTo");
7052
- var refuseDuplicate = /* @__PURE__ */ __name((env, keyring, profile, at2) => {
7053
- const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
7054
- const other = profilesHere(IDENTITY, configuredProfiles, env).find((one) => {
7055
- if (one === profile)
7056
- return false;
7057
- try {
7058
- return signedInTo(env, keyring, one) === at2;
7059
- } catch {
7060
- return false;
7061
- }
7062
- });
7063
- if (!other)
7064
- return;
7065
- 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 });
7066
- }, "refuseDuplicate");
7067
- var checkedToken = /* @__PURE__ */ __name(async (command, token) => {
7068
- const { env, profile, keyring, run: run3 } = contextOf(command);
7069
- const who = await run3((events) => accountAnswer(hubFor(command, { token }, events)));
7070
- refuseDuplicate(env, keyring, profile, who.account);
7071
- const { ui_domain: uiDomain, time_zone: timeZone } = who.account_info;
7072
- return { who, signIn: encodeSignIn({ token, portalId: who.account, uiDomain, timeZone }) };
7073
- }, "checkedToken");
7074
- var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
7075
- effects: FETCH,
7076
- lifetime: "interactive",
7077
- mcp: false,
7078
- examples: [
7079
- `${HUBSPOT} work session start`,
7080
- `${HUBSPOT} work session start --json`,
7081
- `${HUBSPOT} work session start --credential-storage file`
7082
- ]
7083
- })).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) {
7084
- const { env, profile, tokens } = contextOf(this);
7085
- refuseCommandName(profile, commandWords(rootOf(this)), HUBSPOT);
7086
- refuseOffline(this, SERVICE);
7087
- const token = (await readSecret(`${SERVICE} service key or private app token: `, secretInputOf(this))).trim();
7088
- if (!token)
7089
- throw new CliError("validation_error", "no token was given");
7090
- const { who, signIn } = await checkedToken(this, token);
7091
- const storedIn = tokens.write(profile, signIn, args.credentialStorage);
7092
- rememberAccount(IDENTITY, profile, who.account, env);
7093
- answer(this, { profile, state: "saved", kind: "token", stored_in: storedIn, verified: true, ...who });
7094
- }), "startCommand");
7095
- var statusCommand = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
7096
- effects: REMOTE_READ,
7097
- examples: [`${HUBSPOT} work session status`, `${HUBSPOT} work session status --check --json`]
7098
- }).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) {
7099
- const { env, profile, tokens, run: run3 } = contextOf(this);
7100
- const saved = tokens.read(profile);
7101
- const fromToken = saved?.source === "environment";
7102
- const named = fromToken ? environmentAccount(env) : storedSignIn(this)?.portalId;
7103
- const status = {
7104
- profile,
7105
- state: saved ? "saved" : "missing",
7106
- kind: saved ? "token" : null,
7107
- token_from: saved?.source ?? null,
7108
- account: named ?? null
7109
- };
7110
- if (!args.check || !saved)
7111
- return answer(this, { ...status, verified: false });
7112
- if (!fromToken)
7113
- return answer(this, { ...status, verified: true, ...await withHub(this, accountAnswer) });
7114
- refuseOffline(this, SERVICE);
7115
- const who = await run3((events) => accountAnswer(hubFor(this, { token: saved.secret, portalId: named }, events)));
7116
- if (named)
7117
- refuseAccountMismatch(named, who.account);
7118
- answer(this, { ...status, verified: true, ...who });
7119
- }), "statusCommand");
7120
- var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
7121
- effects: LOCAL_WRITE,
7122
- mcp: false,
7123
- examples: [`${HUBSPOT} work session end`]
7124
- })).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() {
7125
- refuseUnderReadOnly(this, "session end");
7126
- const { profile, tokens } = contextOf(this);
7127
- answer(this, { profile, ended: tokens.remove(profile) });
7128
- }), "endCommand");
7129
- var listCommand = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
7130
- effects: LOCAL_READ,
7131
- examples: [`${HUBSPOT} session list`, `${HUBSPOT} session list --json`]
7132
- })).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() {
7133
- const environment = environmentOf(this);
7134
- const env = environment.env ?? process.env;
7135
- const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
7136
- const tokens = tokensHere(env, environment.keyring);
7137
- const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
7138
- try {
7139
- const saved = tokens.read(profile);
7140
- const account = saved && saved.source !== "environment" ? decodeSignIn(saved.secret).portalId : null;
7141
- return { profile, signed_in: saved !== void 0, token_from: saved?.source ?? null, account };
7142
- } catch (error) {
7143
- if (!(error instanceof CliError))
7144
- throw error;
7145
- return { profile, signed_in: null, token_from: null, account: null, error: error.message };
7146
- }
7147
- });
7148
- renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
7149
- }), "listCommand");
7150
- 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");
7151
-
7152
- // dist/commands/account.js
7153
- var rememberedOf = /* @__PURE__ */ __name((env, profile) => {
7154
- try {
7155
- const { account } = JSON.parse(readFileSync(accountFileFor(IDENTITY, profile, env), "utf8"));
7156
- return typeof account === "string" && /^\d+$/.test(account) ? account : void 0;
7157
- } catch {
7158
- return void 0;
7159
- }
7160
- }, "rememberedOf");
7161
- var portalOf = /* @__PURE__ */ __name((env, keyring, profile) => {
7162
- try {
7163
- return signedInTo(env, keyring, profile) ?? rememberedOf(env, profile);
7164
- } catch {
7165
- return rememberedOf(env, profile);
7166
- }
7167
- }, "portalOf");
7168
- var removal = {
7169
- // HubSpot has no call that revokes a service key or a private app token; the account's settings do.
7170
- signOut: /* @__PURE__ */ __name(async (profile) => ({
7171
- revoked: null,
7172
- removed: [`the sign-in of ${profile} (the key stays valid in HubSpot until you delete or rotate it there)`]
7173
- }), "signOut"),
7174
- account: /* @__PURE__ */ __name((profile, { env, keyring }) => {
7175
- const portal = portalOf(env, keyring, profile);
7176
- return portal ? { provider: PROVIDER.name, account: portal } : void 0;
7177
- }, "account"),
7178
- secrets: /* @__PURE__ */ __name((profile, { env, keyring }) => [
7179
- {
7180
- credentials: {
7181
- configDir: resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).config,
7182
- service: IDENTITY.appName,
7183
- envVar: `${IDENTITY.envPrefix}_TOKEN`,
7184
- env,
7185
- ...keyring ? { keyring } : {}
7186
- },
7187
- accounts: [`token:${profile}`]
7188
- }
7189
- ], "secrets"),
7190
- stateFiles: /* @__PURE__ */ __name((profile, { env }) => [
7191
- join(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "crm", profile)
7192
- ], "stateFiles")
7193
- };
7194
- var refuseSharedDelete = /* @__PURE__ */ __name((command) => {
7195
- if (command.opts().deleteData !== true)
7196
- return;
7197
- const { env, keyring, profile, renderer } = contextOf(command);
7198
- const own = portalOf(env, keyring, profile);
7199
- if (!own)
7200
- return;
7201
- const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
7202
- const sharing = profilesHere(IDENTITY, configuredProfiles, env).filter((one) => one !== profile && portalOf(env, keyring, one) === own);
7203
- if (sharing.length === 0)
7204
- return;
7205
- const names = sharing.join(", ");
7206
- if (command.opts().dryRun === true) {
7207
- renderer.warn(`without --dry-run this refuses: ${names} also read${sharing.length === 1 ? "s" : ""} ${own}`);
7208
- return;
7209
- }
7210
- 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 });
7211
- }, "refuseSharedDelete");
7212
- 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 }), {
7213
- effects: LOCAL_WRITE
7214
- }).hook("preAction", (_, action) => refuseSharedDelete(action))), "accountCommand");
7215
-
7216
7033
  // dist/commands/api.js
7217
7034
  var stopAtDailyLimit = /* @__PURE__ */ __name((send, sent, pacer) => async (input, init) => {
7218
7035
  const response = await send(input, init);
@@ -7258,12 +7075,12 @@ var apiCommand = /* @__PURE__ */ __name(() => {
7258
7075
  timeZone: sent.timeZone
7259
7076
  }), "failure"),
7260
7077
  token: tokenOf,
7261
- schemas: /* @__PURE__ */ __name(() => import("./schemas-SB42IXEX.js").then((module) => module.schemas), "schemas"),
7078
+ schemas: /* @__PURE__ */ __name(() => import("./schemas-EXBNVPMI.js").then((module) => module.schemas), "schemas"),
7262
7079
  definitions: /* @__PURE__ */ __name(() => import("./definitions-MVPICAWV.js").then((module) => module.definitions), "definitions")
7263
7080
  });
7264
7081
  }, "apiCommand");
7265
7082
 
7266
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
7267
7084
  var DAY = 864e5;
7268
7085
  var openStageTasks = /* @__PURE__ */ __name(async (store, account, now, { history = false } = {}) => {
7269
7086
  const rules = await store.crm.stageTasks(account);
@@ -7300,7 +7117,113 @@ var openStageTasks = /* @__PURE__ */ __name(async (store, account, now, { histor
7300
7117
  return opened;
7301
7118
  }, "openStageTasks");
7302
7119
 
7303
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
7304
7227
  var HOUR = 36e5;
7305
7228
  var SHOWN = 7;
7306
7229
  var STALE_HOURS = 24;
@@ -7444,7 +7367,7 @@ var healthOf = /* @__PURE__ */ __name(async (store, account, { now, profile }) =
7444
7367
  return stale > STALE_HOURS ? [{ ...named, stale_hours: Math.floor(stale) }] : [];
7445
7368
  }, "healthOf");
7446
7369
 
7447
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
7448
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");
7449
7372
  var DEAL_CSV_COLUMNS = [
7450
7373
  "ref",
@@ -7566,7 +7489,7 @@ var renderCsv = /* @__PURE__ */ __name((command, open2, read, defaults = DEAL_CS
7566
7489
  });
7567
7490
  }, "renderCsv");
7568
7491
 
7569
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
7570
7493
  var time2 = nullable(isoTime);
7571
7494
  var metadata = optional(record(string(), strictObject({
7572
7495
  label: nullable(string()),
@@ -7947,7 +7870,7 @@ var addRecordWrites = /* @__PURE__ */ __name((group, noun, { within, example, wr
7947
7870
  }, "addRecordWrites");
7948
7871
  var idOf = /* @__PURE__ */ __name((opts) => opts.operationId === void 0 ? {} : { operationId: opts.operationId }, "idOf");
7949
7872
 
7950
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
7951
7874
  var MOST2 = 500;
7952
7875
  var nullableText = nullable(text);
7953
7876
  var REFS = ["deal", "lead", "person", "organization"];
@@ -7991,7 +7914,7 @@ var crmActivity = strictObject({
7991
7914
  });
7992
7915
  var UNTRUSTED = ["subject", "body", "on.title"];
7993
7916
  var iso3 = /* @__PURE__ */ __name((at2) => at2 === null ? null : new Date(at2).toISOString(), "iso");
7994
- var itemOf2 = /* @__PURE__ */ __name((one) => ({
7917
+ var listedOf = /* @__PURE__ */ __name((one) => ({
7995
7918
  external_id: one.externalId,
7996
7919
  kind: one.kind,
7997
7920
  subject: one.subject,
@@ -8004,10 +7927,15 @@ var itemOf2 = /* @__PURE__ */ __name((one) => ({
8004
7927
  updated_at: new Date(one.updatedAt).toISOString(),
8005
7928
  on: one.on.map(({ kind, externalId, ref, title }) => ({ kind, external_id: externalId, ref, title })),
8006
7929
  untrusted: UNTRUSTED
8007
- }), "itemOf");
7930
+ }), "listedOf");
8008
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) => {
8009
7938
  const { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 } = options;
8010
- 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");
8011
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) => {
8012
7940
  const name = "activities list";
8013
7941
  const terms = queryTerms(words, ACTIVITIES_QUERY, name, ["due"]);
@@ -8050,17 +7978,92 @@ var addCrmActivityCommands = /* @__PURE__ */ __name((program, options) => {
8050
7978
  offset: (opts.page - 1) * opts.limit
8051
7979
  });
8052
7980
  return listOf(pathOf2(command).join(" "), {
8053
- items: found.items.map(itemOf2),
7981
+ items: found.items.map(listedOf),
8054
7982
  ...paged,
8055
7983
  has_more: found.hasMore,
8056
7984
  ...due.meta ? { meta: due.meta } : {}
8057
7985
  });
8058
7986
  });
8059
7987
  });
8060
- }, "addCrmActivityCommands");
7988
+ }, "addList");
8061
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");
8062
8065
 
8063
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
8064
8067
  var MOST3 = 500;
8065
8068
  var DAY2 = 864e5;
8066
8069
  var nullableText2 = nullable(text);
@@ -8123,7 +8126,7 @@ var CSV_COLUMNS = [
8123
8126
  "owner",
8124
8127
  "activity.subject"
8125
8128
  ];
8126
- var itemOf3 = /* @__PURE__ */ __name((run3, one) => ({
8129
+ var itemOf2 = /* @__PURE__ */ __name((run3, one) => ({
8127
8130
  change: one.change,
8128
8131
  at: new Date(one.at).toISOString(),
8129
8132
  kind: one.kind,
@@ -8165,8 +8168,17 @@ var digestState = /* @__PURE__ */ __name((schedule) => `crm:digest:${schedule}`,
8165
8168
  var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
8166
8169
  const { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 } = options;
8167
8170
  const deals = options.leads === false ? "deals" : "deals and leads";
8168
- if (options.activities)
8169
- addCrmActivityCommands(program, { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 });
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
+ });
8170
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`);
8171
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) => {
8172
8184
  const name = "changes list";
@@ -8190,7 +8202,7 @@ var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
8190
8202
  offset: position.offset
8191
8203
  });
8192
8204
  const next = found.hasMore ? cursorOf({ ...position, offset: position.offset + opts.limit }) : void 0;
8193
- return { items: found.items.map((one) => itemOf3(run3, one)), next };
8205
+ return { items: found.items.map((one) => itemOf2(run3, one)), next };
8194
8206
  }, "read");
8195
8207
  const noted = /* @__PURE__ */ __name((run3) => {
8196
8208
  const note = shortened.get(run3);
@@ -8280,9 +8292,9 @@ var pipelineOf2 = /* @__PURE__ */ __name(async (run3, value) => {
8280
8292
  }) : new CliError("not_found", `no pipeline ${value} in this account`, { reason: "pipeline.not-found" });
8281
8293
  }, "pipelineOf");
8282
8294
 
8283
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
8284
8296
  import { createHash } from "node:crypto";
8285
- 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";
8286
8298
  import { open } from "node:fs/promises";
8287
8299
  import { join as join2, resolve, sep } from "node:path";
8288
8300
  var MB = 1024 * 1024;
@@ -8334,7 +8346,7 @@ var OWNER_FLAGS = [
8334
8346
  ];
8335
8347
  var iso4 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
8336
8348
  var segment = /* @__PURE__ */ __name((text2) => text2.replace(/[^\w.-]+/gu, "_"), "segment");
8337
- 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");
8338
8350
  var ownFolder = /* @__PURE__ */ __name((top, folder) => {
8339
8351
  mkdirSync(folder, { recursive: true, mode: 448 });
8340
8352
  for (let at2 = resolve(folder); at2.startsWith(resolve(top)); at2 = resolve(at2, "..")) {
@@ -8515,7 +8527,7 @@ var downloadCrmFile = /* @__PURE__ */ __name(async (context, file, assignee, { c
8515
8527
  }
8516
8528
  let bytes;
8517
8529
  try {
8518
- bytes = readFileSync2(target);
8530
+ bytes = readFileSync(target);
8519
8531
  } catch {
8520
8532
  await discard();
8521
8533
  throw new CliError("not_found", `the saved copy of ${file.id} was removed before its text was read; run it again`, {
@@ -8817,7 +8829,7 @@ var syncFiles = /* @__PURE__ */ __name(async (context, outOfTime, deadline = (ms
8817
8829
  return report;
8818
8830
  }, "syncFiles");
8819
8831
 
8820
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
8821
8833
  var sumOf = /* @__PURE__ */ __name((amounts) => amounts.map(({ amount, currency }) => `${groupDigits(amount)} ${currency}`).join(", ") || "\u2014", "sumOf");
8822
8834
  var percent = /* @__PURE__ */ __name((share) => share === null ? "\u2014" : `${Math.round(share * 100)}%`, "percent");
8823
8835
  var openStages = /* @__PURE__ */ __name((stages) => {
@@ -8863,7 +8875,7 @@ ${outcomes.join("\n")}`
8863
8875
  ].join("\n\n");
8864
8876
  }, "pipelineView");
8865
8877
 
8866
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
8867
8879
  var SEARCHED = ["crm", ...SOURCE_SEARCHED];
8868
8880
  var DEFAULT_LIMIT = 20;
8869
8881
  var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2, leads = true }) => {
@@ -8930,11 +8942,11 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
8930
8942
  });
8931
8943
  }, "addCrmSearchAll");
8932
8944
 
8933
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
8934
8946
  import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
8935
8947
  import { tmpdir } from "node:os";
8936
8948
  import { join as join3 } from "node:path";
8937
- var openCrmStore = /* @__PURE__ */ __name(async (options) => {
8949
+ var openProfileStore = /* @__PURE__ */ __name(async (options) => {
8938
8950
  const { app, env, profile, readOnly, open: open2 } = options;
8939
8951
  const locked = readOnly && readOnlyLockOf(app, env) !== void 0;
8940
8952
  if (readOnly) {
@@ -8966,7 +8978,7 @@ var openCrmStore = /* @__PURE__ */ __name(async (options) => {
8966
8978
  removing();
8967
8979
  throw error;
8968
8980
  }
8969
- }, "openCrmStore");
8981
+ }, "openProfileStore");
8970
8982
  var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, env, account) => {
8971
8983
  const store = await open2(env);
8972
8984
  try {
@@ -8979,7 +8991,10 @@ var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, e
8979
8991
  }
8980
8992
  }, "withProfile");
8981
8993
 
8982
- // node_modules/.pnpm/@wirecat+cli-core@0.715.0_@wirecat+cli-base@0.125.1_commander@15.0.0_esbuild@0.28.2_typ_f3540c99972bb5f0aa92997a79a368b4/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
8983
8998
  var MOST4 = 500;
8984
8999
  var STAGE_REF = /^stage:\d+$/;
8985
9000
  var timeField = /* @__PURE__ */ __name((name, example, relation) => nativeField({ name, type: "time", operators: ["term", "range"], example, relation }), "timeField");
@@ -9552,12 +9567,57 @@ With the activities setting on, it also copies the activities and tasks on the $
9552
9567
  });
9553
9568
  const search = program.commands.find((one) => one.name() === "search") ?? annotate(program.command("search"), { effects: NO_EFFECTS }).description("search what the local store holds");
9554
9569
  addCrmSearchAll(search, { within, app: options.app, example, viewerOf, leads: hasLeads });
9570
+ if (options.account)
9571
+ program.addCommand(crmAccountCommand(options.app, options.account));
9555
9572
  }, "addCrmCommandsDefinition");
9556
9573
  var addCrmCommands = honoursDryRun(sharedCommand(addCrmCommandsDefinition));
9557
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
+
9558
9618
  // dist/commands/crm-shared.js
9559
9619
  var savedAccount = /* @__PURE__ */ __name(async (env, profile) => {
9560
- const { openHubspotStore } = await import("./store-Q3ZKD4FJ.js");
9620
+ const { openHubspotStore } = await import("./store-CDY2PW6J.js");
9561
9621
  const store = await openHubspotStore(env, { readOnly: true }).catch(() => void 0);
9562
9622
  if (!store)
9563
9623
  return void 0;
@@ -9572,9 +9632,9 @@ var savedAccount = /* @__PURE__ */ __name(async (env, profile) => {
9572
9632
  var openProfile = /* @__PURE__ */ __name(async (command, { readOnly }) => {
9573
9633
  const { env, profile, environment } = contextOf(command);
9574
9634
  const [{ openHubspotStore, PROVIDER: PROVIDER2 }, { hubspotCrmSource }, { hubspotCrmWriter }] = await Promise.all([
9575
- import("./store-Q3ZKD4FJ.js"),
9576
- import("./source-DF63EC2B.js"),
9577
- import("./writer-EQQ55HOS.js")
9635
+ import("./store-CDY2PW6J.js"),
9636
+ import("./source-PBCQAG4C.js"),
9637
+ import("./writer-WGHWQTC2.js")
9578
9638
  ]);
9579
9639
  const fromToken = fromEnvironment(command);
9580
9640
  const online = metaOf(command).effects?.remote !== "none";
@@ -9636,7 +9696,8 @@ var crmSharedCommands = /* @__PURE__ */ __name(() => {
9636
9696
  leads: true,
9637
9697
  writes: HUBSPOT_WRITES,
9638
9698
  live: ["person", "organization", "user"],
9639
- activities: true
9699
+ activities: true,
9700
+ account: HUBSPOT_ACCOUNT
9640
9701
  });
9641
9702
  return [...holder.commands];
9642
9703
  }, "crmSharedCommands");
@@ -9648,6 +9709,100 @@ var contextOf2 = /* @__PURE__ */ __name((command, resolving) => {
9648
9709
  }, "contextOf");
9649
9710
  var scheduleCommand = /* @__PURE__ */ __name(() => scheduleCommandFor({ app: IDENTITY, context: contextOf2 }), "scheduleCommand");
9650
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
+
9651
9806
  // dist/setup/texts.en.json
9652
9807
  var texts_en_default = {
9653
9808
  "key.title": "Make a key",
@@ -9842,7 +9997,6 @@ var definition = /* @__PURE__ */ __name(() => ({
9842
9997
  commands: /* @__PURE__ */ __name(() => [
9843
9998
  commandsCommand(IDENTITY),
9844
9999
  sessionCommand(),
9845
- accountCommand(),
9846
10000
  ...crmSharedCommands(),
9847
10001
  apiCommand(),
9848
10002
  scheduleCommand(),