@wirecat/hubspot-cli 0.5.0 → 0.7.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 (181) hide show
  1. package/CHANGELOG.md +50 -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-JXICB6TB.js +40 -0
  6. package/dist/bundle/{all-profiles-PGFXLOKN.js → all-profiles-GVEX5MXB.js} +11 -11
  7. package/dist/bundle/{anthropic-LPOJ3TYF.js → anthropic-GK6VBQUD.js} +5 -5
  8. package/dist/bundle/{app-server-EYWGCSRY.js → app-server-JRROE463.js} +68 -68
  9. package/dist/bundle/{bun-ZJOOKIIW.js → bun-B7XTFPUF.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-Y6KKH2OW.js → bun-sqlite-QSNZ2YP4.js} +6 -6
  11. package/dist/bundle/{chunk-DEUCWBBH.js → chunk-2FLLS5IL.js} +97 -24
  12. package/dist/bundle/{chunk-5ENY4POG.js → chunk-2HSYAKWO.js} +61 -61
  13. package/dist/bundle/{chunk-QLFD3MOL.js → chunk-2IRBXFIU.js} +2165 -839
  14. package/dist/bundle/{chunk-AIQT2GGK.js → chunk-2K5BAY32.js} +19 -19
  15. package/dist/bundle/{chunk-ZMHD76RE.js → chunk-2PCVKD27.js} +2 -2
  16. package/dist/bundle/{chunk-MENMD5Y5.js → chunk-2V5KOOJV.js} +8 -8
  17. package/dist/bundle/{chunk-QDNYJOWJ.js → chunk-3WG4MTQI.js} +1 -1
  18. package/dist/bundle/{chunk-MPNMEWHA.js → chunk-4F62XXF6.js} +2081 -711
  19. package/dist/bundle/{chunk-OFOA6VJ2.js → chunk-4HZQ5UIY.js} +3 -3
  20. package/dist/bundle/{chunk-QIHJKE4K.js → chunk-4LHNA6LJ.js} +7 -7
  21. package/dist/bundle/{chunk-7Q64D56R.js → chunk-52NC5E42.js} +11 -11
  22. package/dist/bundle/{chunk-ZLWQPUPB.js → chunk-5AVU5SF6.js} +2 -2
  23. package/dist/bundle/{chunk-MKBQFD37.js → chunk-5EJ3C3JG.js} +1 -1
  24. package/dist/bundle/{chunk-AVBKXCEY.js → chunk-5ISQ4KJM.js} +8 -8
  25. package/dist/bundle/{chunk-CWCJEAHZ.js → chunk-5MFZYHPO.js} +3 -3
  26. package/dist/bundle/{chunk-5WADRBQG.js → chunk-63YWTFZF.js} +3 -3
  27. package/dist/bundle/{chunk-I334AT2H.js → chunk-6EHX762H.js} +7 -7
  28. package/dist/bundle/{chunk-6S422S22.js → chunk-6IHXKMY6.js} +7 -9
  29. package/dist/bundle/{chunk-QCHW7R7L.js → chunk-6WKK4UZP.js} +1 -1
  30. package/dist/bundle/{chunk-VIJV474N.js → chunk-745FMNI5.js} +1 -1
  31. package/dist/bundle/{chunk-6PWRJGX4.js → chunk-A7KGBXBT.js} +4 -4
  32. package/dist/bundle/{chunk-HPRGUUHY.js → chunk-ALOPYWYY.js} +1 -1
  33. package/dist/bundle/{chunk-PMGAU6AP.js → chunk-AP3CWDRK.js} +2 -2
  34. package/dist/bundle/{chunk-LXLXF2OE.js → chunk-B3JVNOTB.js} +3 -3
  35. package/dist/bundle/{chunk-QPTHEZZ5.js → chunk-BQPAIGAF.js} +2 -2
  36. package/dist/bundle/{chunk-DDMBPYHP.js → chunk-BRBBZDMZ.js} +2 -2
  37. package/dist/bundle/{chunk-POTS24SH.js → chunk-BXXU4EXK.js} +18 -18
  38. package/dist/bundle/{chunk-34HDRZIL.js → chunk-BY3NKT34.js} +12 -12
  39. package/dist/bundle/{chunk-3CHJYWA2.js → chunk-CBTWKTWN.js} +6 -6
  40. package/dist/bundle/{chunk-RZS7N3OZ.js → chunk-CEHBT7QX.js} +7 -7
  41. package/dist/bundle/{chunk-NLPGUYCG.js → chunk-DBHJIFDS.js} +37 -18
  42. package/dist/bundle/{chunk-DJUUQG6Y.js → chunk-DIHVN5IC.js} +8 -8
  43. package/dist/bundle/{chunk-4RZ4DUQT.js → chunk-DIKUPU3T.js} +3 -3
  44. package/dist/bundle/{chunk-WEM4FZPM.js → chunk-DMYLQX2O.js} +2 -2
  45. package/dist/bundle/{chunk-LWS5AO3H.js → chunk-DWWZAQ4N.js} +16 -16
  46. package/dist/bundle/{chunk-NEP67GLY.js → chunk-GD5JTKLS.js} +6 -6
  47. package/dist/bundle/{chunk-KC4ILAKO.js → chunk-GHBJBDTW.js} +1 -1
  48. package/dist/bundle/{chunk-KRTXJMCD.js → chunk-GYH2AXPO.js} +27 -177
  49. package/dist/bundle/{chunk-K3WCBNH4.js → chunk-GZD6BYO7.js} +6 -6
  50. package/dist/bundle/{chunk-KAW5VEER.js → chunk-H5HBZCEJ.js} +8 -8
  51. package/dist/bundle/{chunk-VCYUYFIV.js → chunk-HX2BE7DO.js} +1 -1
  52. package/dist/bundle/{chunk-KXWRVLSU.js → chunk-I5WHQH5K.js} +1 -1
  53. package/dist/bundle/{chunk-R7ZOCDNG.js → chunk-INT5JXGP.js} +1 -1
  54. package/dist/bundle/{chunk-YZ5MULJM.js → chunk-IRFFXKKK.js} +3 -3
  55. package/dist/bundle/{chunk-SBNZYRVZ.js → chunk-J5HHB27S.js} +4 -4
  56. package/dist/bundle/{chunk-V5VMAHDQ.js → chunk-JEUYZCWF.js} +6 -6
  57. package/dist/bundle/{chunk-BH5FEFZB.js → chunk-JQUS4KFV.js} +2 -2
  58. package/dist/bundle/{chunk-5HGS65I3.js → chunk-KGLMYQXM.js} +2 -2
  59. package/dist/bundle/{chunk-AHZQMSXW.js → chunk-L3DUZVBP.js} +8 -8
  60. package/dist/bundle/{chunk-RJBKDZGV.js → chunk-LGGBKAVQ.js} +8 -8
  61. package/dist/bundle/{chunk-ODRF47VS.js → chunk-LJ52BS6C.js} +8 -8
  62. package/dist/bundle/{chunk-7RIE3DAW.js → chunk-M3JDGRXM.js} +221 -163
  63. package/dist/bundle/{chunk-BCW7DAVV.js → chunk-MR2BNER3.js} +2 -2
  64. package/dist/bundle/{chunk-OCISQFMW.js → chunk-NUPAXK4Z.js} +1 -1
  65. package/dist/bundle/{chunk-MW4ROXQ6.js → chunk-OX37ZK27.js} +3 -3
  66. package/dist/bundle/{chunk-MFWECOO3.js → chunk-P7N3TZLH.js} +59 -59
  67. package/dist/bundle/{chunk-L6WSFVTD.js → chunk-QAQK2WXJ.js} +5 -5
  68. package/dist/bundle/{chunk-EPBHJMF6.js → chunk-QY7EOB66.js} +13 -13
  69. package/dist/bundle/{chunk-HBFSGL5E.js → chunk-RE55EPBX.js} +33 -28
  70. package/dist/bundle/{chunk-ABPZOI3C.js → chunk-SBORPDIQ.js} +4 -4
  71. package/dist/bundle/{chunk-YQBGPBYN.js → chunk-SFFV2F3Y.js} +2 -2
  72. package/dist/bundle/{chunk-WQZENAPE.js → chunk-SMEEFN65.js} +63 -4
  73. package/dist/bundle/{chunk-GZJP3KQQ.js → chunk-SVRCPPNI.js} +1 -1
  74. package/dist/bundle/{chunk-BW7NPFVC.js → chunk-SZZVNPTI.js} +7 -7
  75. package/dist/bundle/{chunk-HPSESLOZ.js → chunk-TCSVW7BA.js} +1 -1
  76. package/dist/bundle/{chunk-L4SVHQ7H.js → chunk-TXCINEH6.js} +7 -7
  77. package/dist/bundle/{chunk-BGUGTMTS.js → chunk-UMXA357W.js} +8 -8
  78. package/dist/bundle/{chunk-PPQRWFJZ.js → chunk-VJQLJQHT.js} +5 -5
  79. package/dist/bundle/{chunk-EGR3YUWD.js → chunk-WASBOYI2.js} +4 -4
  80. package/dist/bundle/{chunk-Z7FC6VVM.js → chunk-WSTF2MWW.js} +1 -1
  81. package/dist/bundle/{chunk-BVK4GUUI.js → chunk-WSUS3MUK.js} +1853 -1874
  82. package/dist/bundle/{chunk-A5UTNGI4.js → chunk-WWIYZN67.js} +13 -13
  83. package/dist/bundle/{chunk-STTHRJBX.js → chunk-XL3NAXZY.js} +5 -5
  84. package/dist/bundle/{chunk-23CLSKY7.js → chunk-XWYYFAML.js} +3 -3
  85. package/dist/bundle/{chunk-MPQ4SPZG.js → chunk-XZLOQNS7.js} +74 -31
  86. package/dist/bundle/{chunk-MGMLSPIY.js → chunk-YDTFPDAJ.js} +1 -1
  87. package/dist/bundle/{chunk-ZKPM53YG.js → chunk-YFHCKAGU.js} +4 -4
  88. package/dist/bundle/{chunk-WDR77HPO.js → chunk-YGZ37OEN.js} +8 -1
  89. package/dist/bundle/{chunk-YJLJZMEA.js → chunk-YOVIH4QI.js} +33 -30
  90. package/dist/bundle/{chunk-NEDV6RCQ.js → chunk-YVMLFHWS.js} +3 -3
  91. package/dist/bundle/{chunk-K5S7MKBB.js → chunk-ZH76HQDA.js} +17 -17
  92. package/dist/bundle/{chunk-WXEN6AXQ.js → chunk-ZNNGK73C.js} +3 -3
  93. package/dist/bundle/{chunk-NKIKMG33.js → chunk-ZNRZJIRM.js} +35 -35
  94. package/dist/bundle/{chunk-5UPNDUAA.js → chunk-ZS6T2PYQ.js} +2 -2
  95. package/dist/bundle/command-contract-7EWUA6E6.js +40 -0
  96. package/dist/bundle/{command-server-entry-B7S5AUE6.js → command-server-entry-BFXXPNJO.js} +28 -28
  97. package/dist/bundle/{decode-7L33C5UJ.js → decode-5M7R44BR.js} +5 -5
  98. package/dist/bundle/{dispatch-BIGHHSXV.js → dispatch-B2EP6DDT.js} +8 -8
  99. package/dist/bundle/{echarts-CWR3QH55.js → echarts-7MBFY6SZ.js} +2 -2
  100. package/dist/bundle/{embed-GXQ3HOQ6.js → embed-Y4GYNHRX.js} +6 -6
  101. package/dist/bundle/{embedder-47OYXGLS.js → embedder-FI4T4LQB.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-YY66AKKG.js} +12 -12
  104. package/dist/bundle/first-screen-U7Z63VXE.js +40 -0
  105. package/dist/bundle/hubspot.js +27 -27
  106. package/dist/bundle/{instructions-QFS2MPK3.js → instructions-SM7TKV6L.js} +1 -1
  107. package/dist/bundle/{mcp-Z2KZNCXB.js → mcp-ZNULRPZ4.js} +2 -2
  108. package/dist/bundle/meeting-combined-B444C4NF.js +25 -0
  109. package/dist/bundle/{meeting-model-GLF2HVJG.js → meeting-model-DKLMBQXX.js} +11 -11
  110. package/dist/bundle/{meeting-semantic-RG56F4YX.js → meeting-semantic-C5T6UDVB.js} +6 -6
  111. package/dist/bundle/{node-3TSWTXGI.js → node-OS6OQF3F.js} +2 -2
  112. package/dist/bundle/{node-sqlite-UPQCG7DJ.js → node-sqlite-2XTWZ4HL.js} +7 -7
  113. package/dist/bundle/{oauth-MCVEENW3.js → oauth-BSSJ66FC.js} +7 -7
  114. package/dist/bundle/{open-JMUTKUYJ.js → open-UZ3TKWDY.js} +5 -5
  115. package/dist/bundle/{openai-HT7YDOK7.js → openai-POVKFBTC.js} +15 -15
  116. package/dist/bundle/{process-7RC6DAGM.js → process-A7ZJGQ6G.js} +1 -1
  117. package/dist/bundle/{program-3DLBMOEJ.js → program-Q3JFUVC6.js} +582 -337
  118. package/dist/bundle/{prompt-7EROPXPF.js → prompt-TYOYTRJM.js} +5 -5
  119. package/dist/bundle/{recognize-B232GXD2.js → recognize-GGFRONZT.js} +4 -4
  120. package/dist/bundle/{remote-HGV64VRC.js → remote-K4SLWHMI.js} +9 -9
  121. package/dist/bundle/{rerank-5S6TDXHD.js → rerank-2QTKDUBV.js} +7 -7
  122. package/dist/bundle/{schemas-SB42IXEX.js → schemas-EXBNVPMI.js} +1 -1
  123. package/dist/bundle/{serve-D2WFCV6Z.js → serve-FG2G2X6Y.js} +9 -9
  124. package/dist/bundle/{server-4AXPTJPV.js → server-KRDHBT5Q.js} +60 -60
  125. package/dist/bundle/server-VFKK6OS4.js +86 -0
  126. package/dist/bundle/source-XP2JNUVU.js +426 -0
  127. package/dist/bundle/{sqlite-runtime-DAFMZNLI.js → sqlite-runtime-TWV7KFLA.js} +6 -6
  128. package/dist/bundle/{state-7OEBDXVV.js → state-EFX5ZQED.js} +6 -6
  129. package/dist/bundle/store-LON2XRIS.js +34 -0
  130. package/dist/bundle/{store-2ZWSWF76.js → store-MNQ6YQIS.js} +28 -24
  131. package/dist/bundle/{store-KC6US326.js → store-QPVH5VPJ.js} +22 -22
  132. package/dist/bundle/store-maintenance-command-YEMPRNJX.js +73 -0
  133. package/dist/bundle/surface-UJRMT6QT.js +72 -0
  134. package/dist/bundle/writer-NOSHE7ZI.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/records.d.ts.map +1 -1
  154. package/dist/crm/records.js +3 -0
  155. package/dist/crm/records.js.map +1 -1
  156. package/dist/crm/writer.d.ts +1 -1
  157. package/dist/crm/writer.d.ts.map +1 -1
  158. package/dist/crm/writer.js +69 -1
  159. package/dist/crm/writer.js.map +1 -1
  160. package/dist/program.d.ts.map +1 -1
  161. package/dist/program.js +0 -2
  162. package/dist/program.js.map +1 -1
  163. package/dist/reasons.d.ts.map +1 -1
  164. package/dist/reasons.js +0 -2
  165. package/dist/reasons.js.map +1 -1
  166. package/dist/version.d.ts +1 -1
  167. package/dist/version.js +1 -1
  168. package/package.json +3 -3
  169. package/skills/hubspot-cli/SKILL.md +17 -5
  170. package/skills/hubspot-cli/references/api/api-basic.md +2 -2
  171. package/skills/hubspot-cli/references/api/api-batch.md +2 -2
  172. package/dist/bundle/agent-RBQMA24N.js +0 -40
  173. package/dist/bundle/command-contract-O2UKYHLD.js +0 -40
  174. package/dist/bundle/first-screen-TU3KE2B5.js +0 -40
  175. package/dist/bundle/meeting-combined-WBEOLQMP.js +0 -25
  176. package/dist/bundle/server-FFHVNABP.js +0 -86
  177. package/dist/bundle/source-DF63EC2B.js +0 -945
  178. package/dist/bundle/store-Q3ZKD4FJ.js +0 -34
  179. package/dist/bundle/store-maintenance-command-24A4GBRP.js +0 -73
  180. package/dist/bundle/surface-SPTM57EP.js +0 -72
  181. 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-63YWTFZF.js";
6
6
  import {
7
7
  accountDetails
8
- } from "./chunk-5HGS65I3.js";
8
+ } from "./chunk-KGLMYQXM.js";
9
+ import {
10
+ HUBSPOT_WRITES
11
+ } from "./chunk-SMEEFN65.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-WSUS3MUK.js";
43
+ import "./chunk-ALOPYWYY.js";
44
+ import "./chunk-SVRCPPNI.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-RE55EPBX.js";
52
+ import "./chunk-GD5JTKLS.js";
53
+ import "./chunk-5ISQ4KJM.js";
54
+ import "./chunk-YDTFPDAJ.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-P7N3TZLH.js";
58
+ import "./chunk-GYH2AXPO.js";
59
+ import "./chunk-2V5KOOJV.js";
60
+ import "./chunk-TXCINEH6.js";
61
+ import "./chunk-BY3NKT34.js";
62
+ import "./chunk-JQUS4KFV.js";
63
+ import "./chunk-SBORPDIQ.js";
64
+ import "./chunk-VJQLJQHT.js";
65
+ import "./chunk-LJ52BS6C.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,
@@ -85,6 +86,7 @@ import {
85
86
  crmViewerOf,
86
87
  customConditions,
87
88
  customNames,
89
+ embedCrmActivities,
88
90
  extractText,
89
91
  fieldPairsOf,
90
92
  filterableFields,
@@ -102,27 +104,29 @@ import {
102
104
  removeCrmItem,
103
105
  searchAll,
104
106
  selectedCodes,
107
+ serviceApiPermissions,
105
108
  shortened,
106
109
  syncRecorded,
107
110
  taskAccount,
111
+ terminalAsker,
108
112
  updateCrmItem,
109
113
  updateCrmRecord,
110
114
  viewerOf,
111
115
  wantedCodes,
112
116
  withCustomFields,
113
117
  withReadableDeal
114
- } from "./chunk-MPNMEWHA.js";
118
+ } from "./chunk-4F62XXF6.js";
115
119
  import {
116
120
  safeName
117
- } from "./chunk-A5UTNGI4.js";
118
- import "./chunk-VCYUYFIV.js";
119
- import "./chunk-WDR77HPO.js";
121
+ } from "./chunk-WWIYZN67.js";
122
+ import "./chunk-HX2BE7DO.js";
123
+ import "./chunk-YGZ37OEN.js";
120
124
  import {
121
125
  latestVersion,
122
126
  runUpdate,
123
127
  updateNotice
124
- } from "./chunk-4RZ4DUQT.js";
125
- import "./chunk-QDNYJOWJ.js";
128
+ } from "./chunk-DIKUPU3T.js";
129
+ import "./chunk-3WG4MTQI.js";
126
130
  import {
127
131
  commandPath,
128
132
  dateWindow,
@@ -137,14 +141,14 @@ import {
137
141
  unfilteredQuery,
138
142
  withQuery,
139
143
  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";
144
+ } from "./chunk-QY7EOB66.js";
145
+ import "./chunk-XWYYFAML.js";
146
+ import "./chunk-JEUYZCWF.js";
147
+ import "./chunk-52NC5E42.js";
148
+ import "./chunk-B3JVNOTB.js";
149
+ import "./chunk-J5HHB27S.js";
150
+ import "./chunk-ZNNGK73C.js";
151
+ import "./chunk-XL3NAXZY.js";
148
152
  import {
149
153
  Argument,
150
154
  Command,
@@ -156,7 +160,6 @@ import {
156
160
  Option,
157
161
  REMOTE_READ,
158
162
  REMOTE_WRITE,
159
- accountFileFor,
160
163
  annotate,
161
164
  annotateOption,
162
165
  answerEntity,
@@ -176,6 +179,7 @@ import {
176
179
  profileFree,
177
180
  profilesHere,
178
181
  readOnlyLockOf,
182
+ recalledAccount,
179
183
  refuseCommandName,
180
184
  refuseUnderReadOnly,
181
185
  rememberAccount,
@@ -188,13 +192,13 @@ import {
188
192
  sharedCommand,
189
193
  snakeKeys,
190
194
  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";
195
+ } from "./chunk-M3JDGRXM.js";
196
+ import "./chunk-LGGBKAVQ.js";
197
+ import "./chunk-4HZQ5UIY.js";
198
+ import "./chunk-QAQK2WXJ.js";
199
+ import "./chunk-INT5JXGP.js";
200
+ import "./chunk-ZH76HQDA.js";
201
+ import "./chunk-IRFFXKKK.js";
198
202
  import {
199
203
  CRM_CHANGES,
200
204
  CRM_SCOPES,
@@ -204,47 +208,48 @@ import {
204
208
  crmSettingKey,
205
209
  seenBy,
206
210
  viewerSql
207
- } from "./chunk-QLFD3MOL.js";
208
- import "./chunk-BGUGTMTS.js";
211
+ } from "./chunk-2IRBXFIU.js";
212
+ import "./chunk-UMXA357W.js";
209
213
  import {
214
+ aheadOf,
210
215
  dayIn
211
- } from "./chunk-CWCJEAHZ.js";
212
- import "./chunk-I334AT2H.js";
216
+ } from "./chunk-5MFZYHPO.js";
217
+ import "./chunk-6EHX762H.js";
213
218
  import {
214
219
  count,
215
220
  createTaskService,
216
221
  text,
217
222
  time
218
- } from "./chunk-YJLJZMEA.js";
219
- import "./chunk-DDMBPYHP.js";
220
- import "./chunk-AHZQMSXW.js";
223
+ } from "./chunk-YOVIH4QI.js";
224
+ import "./chunk-BRBBZDMZ.js";
225
+ import "./chunk-L3DUZVBP.js";
221
226
  import {
222
227
  hostFetch,
223
228
  retrying
224
- } from "./chunk-QIHJKE4K.js";
225
- import "./chunk-K3WCBNH4.js";
226
- import "./chunk-6PWRJGX4.js";
229
+ } from "./chunk-4LHNA6LJ.js";
230
+ import "./chunk-GZD6BYO7.js";
231
+ import "./chunk-A7KGBXBT.js";
227
232
  import {
228
233
  DESKTOP,
229
234
  IDENTITY,
230
235
  PACKAGE,
231
236
  SKILL
232
- } from "./chunk-6S422S22.js";
233
- import "./chunk-BCW7DAVV.js";
237
+ } from "./chunk-6IHXKMY6.js";
238
+ import "./chunk-MR2BNER3.js";
234
239
  import "./chunk-EH6ZEJGT.js";
235
- import "./chunk-DEUCWBBH.js";
236
- import "./chunk-DJUUQG6Y.js";
240
+ import "./chunk-2FLLS5IL.js";
241
+ import "./chunk-DIHVN5IC.js";
237
242
  import {
238
243
  installerOf
239
- } from "./chunk-VIJV474N.js";
244
+ } from "./chunk-745FMNI5.js";
240
245
  import {
241
246
  fieldsOf
242
- } from "./chunk-BW7NPFVC.js";
247
+ } from "./chunk-SZZVNPTI.js";
243
248
  import {
244
249
  foldName
245
- } from "./chunk-POTS24SH.js";
246
- import "./chunk-NEDV6RCQ.js";
247
- import "./chunk-KXWRVLSU.js";
250
+ } from "./chunk-BXXU4EXK.js";
251
+ import "./chunk-YVMLFHWS.js";
252
+ import "./chunk-I5WHQH5K.js";
248
253
  import {
249
254
  CRM_ACTIVITY_KINDS,
250
255
  CRM_KINDS,
@@ -255,39 +260,40 @@ import {
255
260
  normalCrmUserId,
256
261
  parseDecimal,
257
262
  scaleOf
258
- } from "./chunk-NLPGUYCG.js";
259
- import "./chunk-KC4ILAKO.js";
260
- import "./chunk-ZMHD76RE.js";
263
+ } from "./chunk-DBHJIFDS.js";
264
+ import "./chunk-GHBJBDTW.js";
265
+ import "./chunk-2PCVKD27.js";
261
266
  import {
262
267
  SAVE_HELP,
263
268
  defineQuery,
264
269
  queryFieldsOf,
265
270
  timezoneOf,
266
271
  zonedMoment
267
- } from "./chunk-5ENY4POG.js";
268
- import "./chunk-HPSESLOZ.js";
269
- import "./chunk-RZS7N3OZ.js";
272
+ } from "./chunk-2HSYAKWO.js";
273
+ import "./chunk-TCSVW7BA.js";
274
+ import "./chunk-CEHBT7QX.js";
270
275
  import "./chunk-D72URWJE.js";
271
276
  import {
272
277
  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";
278
+ } from "./chunk-OX37ZK27.js";
279
+ import "./chunk-ZS6T2PYQ.js";
280
+ import "./chunk-DMYLQX2O.js";
281
+ import "./chunk-CBTWKTWN.js";
282
+ import "./chunk-WSTF2MWW.js";
278
283
  import {
279
284
  renderPretty,
280
285
  resolvePaths
281
- } from "./chunk-AIQT2GGK.js";
286
+ } from "./chunk-2K5BAY32.js";
282
287
  import {
283
288
  isoTime
284
- } from "./chunk-KAW5VEER.js";
289
+ } from "./chunk-H5HBZCEJ.js";
285
290
  import {
286
291
  array,
287
292
  boolean,
288
293
  literal,
289
294
  nullable,
290
295
  number,
296
+ omit,
291
297
  optional,
292
298
  picklist,
293
299
  record,
@@ -301,8 +307,8 @@ import "./chunk-Y5E2WNWB.js";
301
307
  import {
302
308
  CliError,
303
309
  isCliError
304
- } from "./chunk-PMGAU6AP.js";
305
- import "./chunk-QCHW7R7L.js";
310
+ } from "./chunk-AP3CWDRK.js";
311
+ import "./chunk-6WKK4UZP.js";
306
312
  import {
307
313
  __export,
308
314
  __name
@@ -311,7 +317,7 @@ import {
311
317
  // dist/program.js
312
318
  import { join as join4 } from "node:path";
313
319
 
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
320
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/update/index.js
315
321
  import { realpathSync } from "node:fs";
316
322
  import { fileURLToPath } from "node:url";
317
323
  var npmRegistry = /* @__PURE__ */ __name(() => hostFetch({ hosts: ["registry.npmjs.org"] }), "npmRegistry");
@@ -376,10 +382,6 @@ var appUpdate = /* @__PURE__ */ __name((app) => {
376
382
  };
377
383
  }, "appUpdate");
378
384
 
379
- // dist/commands/account.js
380
- import { readFileSync } from "node:fs";
381
- import { join } from "node:path";
382
-
383
385
  // dist/generated/manifest.js
384
386
  var manifest_exports = {};
385
387
  __export(manifest_exports, {
@@ -6778,16 +6780,22 @@ var security = [
6778
6780
  var firstWord = /* @__PURE__ */ __name((command) => command.split("-")[0] ?? command, "firstWord");
6779
6781
  var GROUPS = new Map(operations.flatMap((operation) => (operation.permissions ?? []).flatMap(({ key }) => key.endsWith(".delete") ? [[firstWord(operation.command), key.slice(0, -".delete".length)]] : [])));
6780
6782
  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
- ]));
6783
+ ...[
6784
+ ["deals", "deals"],
6785
+ ["contacts", "people"],
6786
+ ["companies", "organizations"]
6787
+ ].flatMap(([type, noun]) => [
6788
+ [`${type}-create`, [`${noun}.create`]],
6789
+ [`${type}-batch-create`, [`${noun}.create`]],
6790
+ [`${type}-update`, [`${noun}.update`]],
6791
+ [`${type}-batch-update`, [`${noun}.update`]],
6792
+ [`${type}-batch-upsert`, [`${noun}.create`, `${noun}.update`]]
6793
+ ]),
6794
+ ...["notes", "tasks"].flatMap((type) => [
6795
+ [`${type}-create`, ["activities.create"]],
6796
+ [`${type}-batch-create`, ["activities.create"]]
6797
+ ])
6798
+ ]);
6791
6799
  var READ_KEYS = Object.fromEntries([
6792
6800
  ...[
6793
6801
  ["deals", "deals"],
@@ -7023,196 +7031,6 @@ var withHub = /* @__PURE__ */ __name((command, body) => {
7023
7031
  return contextOf(command).run((events) => body(hubFor(command, signIn, events)));
7024
7032
  }, "withHub");
7025
7033
 
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
7034
  // dist/commands/api.js
7217
7035
  var stopAtDailyLimit = /* @__PURE__ */ __name((send, sent, pacer) => async (input, init) => {
7218
7036
  const response = await send(input, init);
@@ -7258,12 +7076,12 @@ var apiCommand = /* @__PURE__ */ __name(() => {
7258
7076
  timeZone: sent.timeZone
7259
7077
  }), "failure"),
7260
7078
  token: tokenOf,
7261
- schemas: /* @__PURE__ */ __name(() => import("./schemas-SB42IXEX.js").then((module) => module.schemas), "schemas"),
7079
+ schemas: /* @__PURE__ */ __name(() => import("./schemas-EXBNVPMI.js").then((module) => module.schemas), "schemas"),
7262
7080
  definitions: /* @__PURE__ */ __name(() => import("./definitions-MVPICAWV.js").then((module) => module.definitions), "definitions")
7263
7081
  });
7264
7082
  }, "apiCommand");
7265
7083
 
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
7084
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/stage-tasks.js
7267
7085
  var DAY = 864e5;
7268
7086
  var openStageTasks = /* @__PURE__ */ __name(async (store, account, now, { history = false } = {}) => {
7269
7087
  const rules = await store.crm.stageTasks(account);
@@ -7300,7 +7118,113 @@ var openStageTasks = /* @__PURE__ */ __name(async (store, account, now, { histor
7300
7118
  return opened;
7301
7119
  }, "openStageTasks");
7302
7120
 
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
7121
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/account.js
7122
+ import { join } from "node:path";
7123
+ var SHARED = new Set(Object.values(CRM_SHARED_FOLDERS));
7124
+ var isShared = /* @__PURE__ */ __name((profile) => SHARED.has(profile.toLowerCase()), "isShared");
7125
+ var accountBy = /* @__PURE__ */ __name((app, options) => (profile, context) => options.held ? options.held(profile, context)?.account : recalledAccount(app, options.provider, profile, context.env)?.account, "accountBy");
7126
+ var signedInBy = /* @__PURE__ */ __name((app, options, tokens) => (profile, context) => {
7127
+ try {
7128
+ if (options.held)
7129
+ return options.held(profile, context);
7130
+ const account = recalledAccount(app, options.provider, profile, context.env)?.account;
7131
+ if (account === void 0)
7132
+ return void 0;
7133
+ const saved = (tokens ?? new ProfileTokenStore({ app, ...context, warn: /* @__PURE__ */ __name(() => {
7134
+ }, "warn") })).read(profile);
7135
+ return { account, signedIn: saved !== void 0 && saved.source !== "environment" };
7136
+ } catch {
7137
+ return void 0;
7138
+ }
7139
+ }, "signedInBy");
7140
+ var also = /* @__PURE__ */ __name((names) => `${names.join(", ")} also read${names.length === 1 ? "s" : ""}`, "also");
7141
+ var refuseTakenCrmAccount = /* @__PURE__ */ __name((app, options, { profile, profiles = [], tokens, ...context }, at2) => {
7142
+ if (isShared(profile))
7143
+ 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 });
7144
+ const held = signedInBy(app, options, tokens);
7145
+ const other = profilesHere(app, profiles, context.env).find((one) => {
7146
+ if (one === profile)
7147
+ return false;
7148
+ const found = held(one, context);
7149
+ return found?.signedIn === true && found.account === at2.account && found.user === at2.user;
7150
+ });
7151
+ if (!other)
7152
+ return;
7153
+ const command = app.command;
7154
+ 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.
7155
+ (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 });
7156
+ }, "refuseTakenCrmAccount");
7157
+ var refuseSharedDelete = /* @__PURE__ */ __name((app, options, command) => {
7158
+ const given = command.opts();
7159
+ if (given.deleteData !== true)
7160
+ return;
7161
+ const resolveSettings = options.resolveSettings ?? environmentOf(command).resolveSettings;
7162
+ if (!resolveSettings)
7163
+ return;
7164
+ const { env, keyring, settings, renderer } = baseContext(command, resolveSettings);
7165
+ const context = { env, ...keyring ? { keyring } : {} };
7166
+ const accountOf = accountBy(app, options);
7167
+ const read = /* @__PURE__ */ __name((profile) => {
7168
+ try {
7169
+ return accountOf(profile, context);
7170
+ } catch {
7171
+ 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 });
7172
+ }
7173
+ }, "read");
7174
+ const own = read(settings.profile);
7175
+ if (own === void 0)
7176
+ return;
7177
+ const sharing = settings.profilesHere.filter((one) => one !== settings.profile && read(one) === own);
7178
+ if (sharing.length === 0)
7179
+ return;
7180
+ if (given.dryRun === true) {
7181
+ renderer.warn(`without --dry-run this refuses: ${also(sharing)} ${options.service} account ${own}`);
7182
+ return;
7183
+ }
7184
+ const names = sharing.join(", ");
7185
+ 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 });
7186
+ }, "refuseSharedDelete");
7187
+ var removalOf = /* @__PURE__ */ __name((app, options) => {
7188
+ const accountOf = accountBy(app, options);
7189
+ const folders = /* @__PURE__ */ __name((env) => resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }), "folders");
7190
+ return {
7191
+ // A CRM's API token has no call that revokes it; the CRM's own settings do.
7192
+ signOut: /* @__PURE__ */ __name(async (profile) => ({
7193
+ revoked: null,
7194
+ removed: [
7195
+ options.signedOut?.(profile) ?? `the sign-in of ${profile} (the token stays valid in ${options.service} until you delete it there)`
7196
+ ]
7197
+ }), "signOut"),
7198
+ account: /* @__PURE__ */ __name((profile, context) => {
7199
+ try {
7200
+ const account = accountOf(profile, context);
7201
+ return account === void 0 ? void 0 : { provider: options.provider, account };
7202
+ } catch {
7203
+ return void 0;
7204
+ }
7205
+ }, "account"),
7206
+ secrets: /* @__PURE__ */ __name((profile, { env, keyring }) => [
7207
+ {
7208
+ credentials: {
7209
+ configDir: folders(env).config,
7210
+ service: app.appName,
7211
+ envVar: `${app.envPrefix}_TOKEN`,
7212
+ env,
7213
+ ...keyring ? { keyring } : {}
7214
+ },
7215
+ // An OAuth sign-in's entry; removing a missing one is fine.
7216
+ accounts: [`token:${profile}`, oauthAccount(options.provider, profile)]
7217
+ }
7218
+ ], "secrets"),
7219
+ // A profile named after a folder every account shares has no folder of its own there.
7220
+ stateFiles: /* @__PURE__ */ __name((profile, { env }) => isShared(profile) ? [] : [join(folders(env).state, "crm", profile)], "stateFiles")
7221
+ };
7222
+ }, "removalOf");
7223
+ 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), {
7224
+ ...options.resolveSettings ? { resolveSettings: options.resolveSettings } : {}
7225
+ }), { effects: LOCAL_WRITE }).hook("preAction", (_, action) => refuseSharedDelete(app, options, action))), "crmAccountCommand");
7226
+
7227
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/digest.js
7304
7228
  var HOUR = 36e5;
7305
7229
  var SHOWN = 7;
7306
7230
  var STALE_HOURS = 24;
@@ -7444,7 +7368,7 @@ var healthOf = /* @__PURE__ */ __name(async (store, account, { now, profile }) =
7444
7368
  return stale > STALE_HOURS ? [{ ...named, stale_hours: Math.floor(stale) }] : [];
7445
7369
  }, "healthOf");
7446
7370
 
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
7371
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/csv.js
7448
7372
  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
7373
  var DEAL_CSV_COLUMNS = [
7450
7374
  "ref",
@@ -7566,7 +7490,7 @@ var renderCsv = /* @__PURE__ */ __name((command, open2, read, defaults = DEAL_CS
7566
7490
  });
7567
7491
  }, "renderCsv");
7568
7492
 
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
7493
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/records.js
7570
7494
  var time2 = nullable(isoTime);
7571
7495
  var metadata = optional(record(string(), strictObject({
7572
7496
  label: nullable(string()),
@@ -7787,7 +7711,7 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
7787
7711
  });
7788
7712
  });
7789
7713
  });
7790
- example(answerEntity(annotate(group.command("show"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema).description(`one of the CRM's ${noun.what}, read live, with its phones and e-mails; one that is not your client counts toward the day's limit when the CRM sets one`).argument(`<${noun.kind}>`, `the CRM's id of the ${noun.kind}, as list prints it, or its exact name`), `${noun.noun} show 42`, `${noun.noun} show "Anna Example" --json`).action(async (given, _opts, command) => {
7714
+ example(answerEntity(annotate(group.command("show"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema).description(`one of the CRM's ${noun.what}, read live, with its phones and e-mails; one that is not your client counts toward the day's limit when the CRM sets one`).argument(`<${noun.kind}>`, `the CRM's id of the ${noun.kind}, as list prints it, the ${noun.kind}:<id> a deal gives, or its exact name`), `${noun.noun} show 42`, `${noun.noun} show "Anna Example" --json`).action(async (given, _opts, command) => {
7791
7715
  await within(command, async (run3) => {
7792
7716
  const found = await recordNamed(run3, noun, given);
7793
7717
  await quotaOf2(run3).spend(noun.kind, found);
@@ -7811,8 +7735,22 @@ var byIdOrNone = /* @__PURE__ */ __name(async (run3, noun, id) => {
7811
7735
  throw error;
7812
7736
  }
7813
7737
  }, "byIdOrNone");
7738
+ var storedRecord = /* @__PURE__ */ __name(async (run3, noun, ref) => {
7739
+ const ids = await run3.store.crm.externalIdsOf(run3.account, ref);
7740
+ if (ids.length > 1)
7741
+ throw new CliError("validation_error", `${ref} is ${ids.length} records of the CRM; name one by its id`, {
7742
+ reason: "crm.record-ambiguous",
7743
+ candidates: ids.map((id) => ({ id }))
7744
+ });
7745
+ const found = ids[0] ? await sourceWith(run3, "get", noun.what).get(noun.kind, ids[0]) : null;
7746
+ if (!found)
7747
+ throw new CliError("not_found", `the copy holds no CRM ${noun.kind} as ${ref}, or this sign-in cannot see it`);
7748
+ return found;
7749
+ }, "storedRecord");
7814
7750
  var recordNamed = /* @__PURE__ */ __name(async (run3, noun, given) => {
7815
7751
  const id = given.trim();
7752
+ if (id.startsWith(`${noun.kind}:`) && /^\w+:\d+$/.test(id))
7753
+ return storedRecord(run3, noun, id);
7816
7754
  const byId = RECORD_ID.test(id) ? await byIdOrNone(run3, noun, id) : null;
7817
7755
  if (byId)
7818
7756
  return byId;
@@ -7890,16 +7828,28 @@ var addRecordWrites = /* @__PURE__ */ __name((group, noun, { within, example, wr
7890
7828
  if (!writes?.kinds.includes(noun.kind))
7891
7829
  return;
7892
7830
  const person = noun.kind === "person";
7831
+ const written = writes.fields?.[noun.kind];
7832
+ const takes = /* @__PURE__ */ __name((field) => !written || written.includes(field), "takes");
7893
7833
  const fields = /* @__PURE__ */ __name((command2) => {
7894
7834
  command2.option("--name <name>", person ? "the whole name" : "the company's name");
7895
- if (person)
7896
- command2.option("--first-name <name>", "the first name; empty clears it").option("--last-name <name>", "the last name; empty clears it").option("--position <title>", "the job title; empty clears it");
7835
+ if (person) {
7836
+ command2.option("--first-name <name>", "the first name; empty clears it").option("--last-name <name>", "the last name; empty clears it");
7837
+ if (takes("position"))
7838
+ command2.option("--position <title>", "the job title; empty clears it");
7839
+ }
7897
7840
  const repeated = /* @__PURE__ */ __name((value, previous = []) => [...previous, value], "repeated");
7898
- command2.option("--email <address>", "an e-mail address to give it; repeat it for more; replaces its list, and an empty one clears it", repeated).option("--phone <phone>", "a phone number to give it, in international form starting with +; repeat it for more; replaces its list, and an empty one clears it", repeated).option("--owner <user>", "the CRM user it is assigned to; anyone but the sign-in's own user checks crm.assign-others").option("--field <key=value>", "one of the CRM's own fields, by its code or label as `fields list` prints them, and its value; a list field takes its option's label or id; repeat it for more fields, or for each value of a multiple field; an empty value clears it", (value, previous = []) => {
7899
- if (value.indexOf("=") < 1)
7900
- throw new CliError("validation_error", "--field takes <key>=<value>");
7901
- return [...previous, value];
7902
- }, []);
7841
+ if (takes("emails"))
7842
+ command2.option("--email <address>", "an e-mail address to give it; repeat it for more; replaces its list, and an empty one clears it", repeated);
7843
+ if (takes("phones"))
7844
+ command2.option("--phone <phone>", "a phone number to give it, in international form starting with +; repeat it for more; replaces its list, and an empty one clears it", repeated);
7845
+ if (takes("owner"))
7846
+ command2.option("--owner <user>", "the CRM user it is assigned to; anyone but the sign-in's own user checks crm.assign-others");
7847
+ if (takes("custom"))
7848
+ command2.option("--field <key=value>", "one of the CRM's own fields, by its code or label as `fields list` prints them, and its value; a list field takes its option's label or id; repeat it for more fields, or for each value of a multiple field; an empty value clears it", (value, previous = []) => {
7849
+ if (value.indexOf("=") < 1)
7850
+ throw new CliError("validation_error", "--field takes <key>=<value>");
7851
+ return [...previous, value];
7852
+ }, []);
7903
7853
  if (writes.idempotent)
7904
7854
  command2.option("--operation-id <id>", "the operation_id a write that ended in outcome_unknown named: the CRM answers the repeat from its record");
7905
7855
  return command2;
@@ -7947,7 +7897,7 @@ var addRecordWrites = /* @__PURE__ */ __name((group, noun, { within, example, wr
7947
7897
  }, "addRecordWrites");
7948
7898
  var idOf = /* @__PURE__ */ __name((opts) => opts.operationId === void 0 ? {} : { operationId: opts.operationId }, "idOf");
7949
7899
 
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
7900
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/activities.js
7951
7901
  var MOST2 = 500;
7952
7902
  var nullableText = nullable(text);
7953
7903
  var REFS = ["deal", "lead", "person", "organization"];
@@ -7991,7 +7941,7 @@ var crmActivity = strictObject({
7991
7941
  });
7992
7942
  var UNTRUSTED = ["subject", "body", "on.title"];
7993
7943
  var iso3 = /* @__PURE__ */ __name((at2) => at2 === null ? null : new Date(at2).toISOString(), "iso");
7994
- var itemOf2 = /* @__PURE__ */ __name((one) => ({
7944
+ var listedOf = /* @__PURE__ */ __name((one) => ({
7995
7945
  external_id: one.externalId,
7996
7946
  kind: one.kind,
7997
7947
  subject: one.subject,
@@ -8004,10 +7954,15 @@ var itemOf2 = /* @__PURE__ */ __name((one) => ({
8004
7954
  updated_at: new Date(one.updatedAt).toISOString(),
8005
7955
  on: one.on.map(({ kind, externalId, ref, title }) => ({ kind, external_id: externalId, ref, title })),
8006
7956
  untrusted: UNTRUSTED
8007
- }), "itemOf");
7957
+ }), "listedOf");
8008
7958
  var addCrmActivityCommands = /* @__PURE__ */ __name((program, options) => {
7959
+ 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`);
7960
+ if (options.list)
7961
+ addList(group, options);
7962
+ addActivityWrites(group, options);
7963
+ }, "addCrmActivityCommands");
7964
+ var addList = /* @__PURE__ */ __name((group, options) => {
8009
7965
  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
7966
  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
7967
  const name = "activities list";
8013
7968
  const terms = queryTerms(words, ACTIVITIES_QUERY, name, ["due"]);
@@ -8050,17 +8005,92 @@ var addCrmActivityCommands = /* @__PURE__ */ __name((program, options) => {
8050
8005
  offset: (opts.page - 1) * opts.limit
8051
8006
  });
8052
8007
  return listOf(pathOf2(command).join(" "), {
8053
- items: found.items.map(itemOf2),
8008
+ items: found.items.map(listedOf),
8054
8009
  ...paged,
8055
8010
  has_more: found.hasMore,
8056
8011
  ...due.meta ? { meta: due.meta } : {}
8057
8012
  });
8058
8013
  });
8059
8014
  });
8060
- }, "addCrmActivityCommands");
8015
+ }, "addList");
8061
8016
  var refOf = /* @__PURE__ */ __name((kind, value) => value.includes(":") ? value : `${kind}:${value}`, "refOf");
8017
+ var writtenActivity = strictObject({
8018
+ operation_id: text,
8019
+ stored: boolean(),
8020
+ activity: omit(crmActivity, ["done_at"]),
8021
+ untrusted: array(text)
8022
+ });
8023
+ var addActivityWrites = /* @__PURE__ */ __name((group, options) => {
8024
+ const { within, example, now, writes } = options;
8025
+ const kinds = writes?.activities ?? [];
8026
+ if (kinds.length === 0)
8027
+ return;
8028
+ const leads = options.leads !== false;
8029
+ const contextOf3 = /* @__PURE__ */ __name((run3, command) => {
8030
+ if (!run3.writes)
8031
+ throw new CliError("configuration_error", "this profile cannot write to its CRM");
8032
+ return {
8033
+ store: run3.store,
8034
+ account: run3.account,
8035
+ writes: run3.writes(),
8036
+ ask: terminalAsker(command),
8037
+ source: run3.source,
8038
+ names: { id: "--operation-id" }
8039
+ };
8040
+ }, "contextOf");
8041
+ const answered = /* @__PURE__ */ __name((run3, done) => itemOf({
8042
+ operation_id: done.operationId,
8043
+ stored: done.stored,
8044
+ activity: writtenOf(run3, done.activity, done.on),
8045
+ untrusted: UNTRUSTED.map((field) => `activity.${field}`)
8046
+ }), "answered");
8047
+ const write = /* @__PURE__ */ __name((name, description) => {
8048
+ const command = answerEntity(annotate(group.command(name), { effects: REMOTE_WRITE, offline: false }), "crm_activity_write", writtenActivity).description(description);
8049
+ if (writes?.idempotent)
8050
+ command.option("--operation-id <id>", "the operation_id a write that ended in outcome_unknown named: the CRM answers the repeat from its record");
8051
+ return command;
8052
+ }, "write");
8053
+ const idOf2 = /* @__PURE__ */ __name((opts) => opts.operationId === void 0 ? {} : { operationId: opts.operationId }, "idOf");
8054
+ const comment = kinds.includes("comment");
8055
+ const task = kinds.includes("task");
8056
+ 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(
8057
+ "--subject <ref>",
8058
+ `a record it is on: ${leads ? "deal:<id>, lead:<id>" : "deal:<id>"}, person:<id> or organization:<id> as a list or deals show gives it, or person:crm:<id> or organization:crm:<id> by the CRM's id as people list and organizations list print it; repeat it for more`,
8059
+ (value, previous = []) => [...previous, value],
8060
+ // The empty default marks the flag as repeatable, so an agent's tool takes a list.
8061
+ []
8062
+ ).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) => {
8063
+ await within(command, async (run3) => {
8064
+ const done = await createCrmActivity(contextOf3(run3, command), kind, {
8065
+ on: opts.subject,
8066
+ ...opts.title === void 0 ? {} : { title: opts.title },
8067
+ ...opts.text === void 0 ? {} : { body: opts.text },
8068
+ ...opts.due === void 0 ? {} : { dueAt: aheadOf(opts.due, "--due", now(), { end: true }) },
8069
+ ...opts.owner === void 0 ? {} : { owner: opts.owner }
8070
+ }, idOf2(opts));
8071
+ return answered(run3, done);
8072
+ });
8073
+ });
8074
+ if (task)
8075
+ 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) => {
8076
+ await within(command, async (run3) => answered(run3, await completeCrmActivity(contextOf3(run3, command), id, idOf2(opts))));
8077
+ });
8078
+ }, "addActivityWrites");
8079
+ var writtenOf = /* @__PURE__ */ __name((run3, activity, on) => ({
8080
+ external_id: activity.externalId,
8081
+ kind: activity.kind,
8082
+ subject: activity.subject,
8083
+ body: activity.body ?? null,
8084
+ due_at: iso3(activity.dueAt ?? null),
8085
+ done: activity.done,
8086
+ assignee: activity.assignee ? crmIdentityId(run3.account, activity.assignee, "user") : null,
8087
+ created_at: new Date(activity.createdAt).toISOString(),
8088
+ updated_at: new Date(activity.updatedAt).toISOString(),
8089
+ on: on.map(({ kind, externalId, ref, title }) => ({ kind, external_id: externalId, ref, title })),
8090
+ untrusted: UNTRUSTED
8091
+ }), "writtenOf");
8062
8092
 
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
8093
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/changes.js
8064
8094
  var MOST3 = 500;
8065
8095
  var DAY2 = 864e5;
8066
8096
  var nullableText2 = nullable(text);
@@ -8123,7 +8153,7 @@ var CSV_COLUMNS = [
8123
8153
  "owner",
8124
8154
  "activity.subject"
8125
8155
  ];
8126
- var itemOf3 = /* @__PURE__ */ __name((run3, one) => ({
8156
+ var itemOf2 = /* @__PURE__ */ __name((run3, one) => ({
8127
8157
  change: one.change,
8128
8158
  at: new Date(one.at).toISOString(),
8129
8159
  kind: one.kind,
@@ -8165,8 +8195,17 @@ var digestState = /* @__PURE__ */ __name((schedule) => `crm:digest:${schedule}`,
8165
8195
  var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
8166
8196
  const { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 } = options;
8167
8197
  const deals = options.leads === false ? "deals" : "deals and leads";
8168
- if (options.activities)
8169
- addCrmActivityCommands(program, { within, example, now, ownerOf: ownerOf2, pathOf: pathOf2 });
8198
+ if (options.activities || options.writes?.activities?.length)
8199
+ addCrmActivityCommands(program, {
8200
+ within,
8201
+ example,
8202
+ now,
8203
+ ownerOf: ownerOf2,
8204
+ pathOf: pathOf2,
8205
+ list: options.activities === true,
8206
+ ...options.writes ? { writes: options.writes } : {},
8207
+ ...options.leads === void 0 ? {} : { leads: options.leads }
8208
+ });
8170
8209
  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
8210
  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
8211
  const name = "changes list";
@@ -8190,7 +8229,7 @@ var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
8190
8229
  offset: position.offset
8191
8230
  });
8192
8231
  const next = found.hasMore ? cursorOf({ ...position, offset: position.offset + opts.limit }) : void 0;
8193
- return { items: found.items.map((one) => itemOf3(run3, one)), next };
8232
+ return { items: found.items.map((one) => itemOf2(run3, one)), next };
8194
8233
  }, "read");
8195
8234
  const noted = /* @__PURE__ */ __name((run3) => {
8196
8235
  const note = shortened.get(run3);
@@ -8280,9 +8319,9 @@ var pipelineOf2 = /* @__PURE__ */ __name(async (run3, value) => {
8280
8319
  }) : new CliError("not_found", `no pipeline ${value} in this account`, { reason: "pipeline.not-found" });
8281
8320
  }, "pipelineOf");
8282
8321
 
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
8322
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/files.js
8284
8323
  import { createHash } from "node:crypto";
8285
- import { chmodSync, constants, copyFileSync, existsSync, linkSync, mkdirSync, readFileSync as readFileSync2, renameSync, rmSync } from "node:fs";
8324
+ import { chmodSync, constants, copyFileSync, existsSync, linkSync, mkdirSync, readFileSync, renameSync, rmSync } from "node:fs";
8286
8325
  import { open } from "node:fs/promises";
8287
8326
  import { join as join2, resolve, sep } from "node:path";
8288
8327
  var MB = 1024 * 1024;
@@ -8334,7 +8373,7 @@ var OWNER_FLAGS = [
8334
8373
  ];
8335
8374
  var iso4 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
8336
8375
  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");
8376
+ 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
8377
  var ownFolder = /* @__PURE__ */ __name((top, folder) => {
8339
8378
  mkdirSync(folder, { recursive: true, mode: 448 });
8340
8379
  for (let at2 = resolve(folder); at2.startsWith(resolve(top)); at2 = resolve(at2, "..")) {
@@ -8515,7 +8554,7 @@ var downloadCrmFile = /* @__PURE__ */ __name(async (context, file, assignee, { c
8515
8554
  }
8516
8555
  let bytes;
8517
8556
  try {
8518
- bytes = readFileSync2(target);
8557
+ bytes = readFileSync(target);
8519
8558
  } catch {
8520
8559
  await discard();
8521
8560
  throw new CliError("not_found", `the saved copy of ${file.id} was removed before its text was read; run it again`, {
@@ -8817,7 +8856,7 @@ var syncFiles = /* @__PURE__ */ __name(async (context, outOfTime, deadline = (ms
8817
8856
  return report;
8818
8857
  }, "syncFiles");
8819
8858
 
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
8859
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/pipeline-view.js
8821
8860
  var sumOf = /* @__PURE__ */ __name((amounts) => amounts.map(({ amount, currency }) => `${groupDigits(amount)} ${currency}`).join(", ") || "\u2014", "sumOf");
8822
8861
  var percent = /* @__PURE__ */ __name((share) => share === null ? "\u2014" : `${Math.round(share * 100)}%`, "percent");
8823
8862
  var openStages = /* @__PURE__ */ __name((stages) => {
@@ -8863,12 +8902,14 @@ ${outcomes.join("\n")}`
8863
8902
  ].join("\n\n");
8864
8903
  }, "pipelineView");
8865
8904
 
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
8905
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/search-all.js
8867
8906
  var SEARCHED = ["crm", ...SOURCE_SEARCHED];
8868
8907
  var DEFAULT_LIMIT = 20;
8869
8908
  var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2, leads = true }) => {
8870
8909
  const deals = leads ? "deals and leads" : "deals";
8871
- 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);
8910
+ 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", `
8911
+ It finds ${deals} by the meaning of their activities too, in other words or another language, once \`sync --embed\` has built their vectors with a downloaded model; until then it says it searched by words only.
8912
+ ` + SAVE_HELP);
8872
8913
  searches.addCommand(searchAllOptions(all, SEARCHED));
8873
8914
  example(all, "search all Example LLC", "search all website --only crm --json");
8874
8915
  all.action(async (words, _opts, leaf) => {
@@ -8878,7 +8919,7 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
8878
8919
  throw new CliError("permission_error", "this process is locked to one profile; search all reads its own CRM account only, without --source", { reason: "profile.locked" });
8879
8920
  const asked = opts.only ?? SEARCHED;
8880
8921
  const denied = deniedKinds(leaf, app, [
8881
- ...asked.includes("crm") ? [...DEAL_KINDS, "crm_file"] : [],
8922
+ ...asked.includes("crm") ? [...DEAL_KINDS, "crm_file", "crm_activity"] : [],
8882
8923
  ...asked.filter((one) => one !== "crm" && one !== "mail")
8883
8924
  ]);
8884
8925
  const out = new Set(denied.map(({ kind }) => kind));
@@ -8908,6 +8949,7 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
8908
8949
  ...crmKinds.length < DEAL_KINDS.length ? { crmKinds } : {},
8909
8950
  crmViewers: viewers,
8910
8951
  ...out.has("crm_file") ? { crmFiles: false } : {},
8952
+ ...out.has("crm_activity") ? { crmActivities: false } : {},
8911
8953
  ...opts.source === void 0 ? {} : { source: opts.source },
8912
8954
  ...alone ? { scope: { crm: [run3.account] } } : {}
8913
8955
  }, { app, hintCommand: commandAt(rootOf2(leaf), "models download") ? app.command : null }, void 0, meaningLane({ env, messenger: { app }, store: /* @__PURE__ */ __name(async () => run3.store, "store") }));
@@ -8918,6 +8960,11 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
8918
8960
  note(`${resource ?? source} not searched: ${reason}`);
8919
8961
  if (!found.items.length)
8920
8962
  note("nothing found in what the local store holds");
8963
+ const off = found.crm?.needsVectors && !await run3.store.crm.activitiesOn(run3.account);
8964
+ const build = off ? `\`${lineOf(leaf, "config set activities on")}\`, then \`${lineOf(leaf, "sync --embed")}\`, copy the activities and build` : `\`${lineOf(leaf, "sync --embed")}\` builds`;
8965
+ const vectors = found.crm?.needsVectors ? `deals and leads were found by words only: ${found.crm.meaningSkipped}; ${build} the vectors that find them by the meaning of their activities` : void 0;
8966
+ if (vectors)
8967
+ note(vectors);
8921
8968
  const skips = await historySkipsOf(run3.store, found.accounts).catch(() => []);
8922
8969
  const again = {
8923
8970
  query: words.join(" "),
@@ -8925,16 +8972,68 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
8925
8972
  ...opts.source === void 0 ? {} : { source: opts.source },
8926
8973
  ...opts.exact ? { exact: true } : {}
8927
8974
  };
8928
- return allAnswer("search all", found, { limit, page: opts.page ?? 1, again }, opts.exact === true, skips, denied);
8975
+ const body = allAnswer("search all", found, { limit, page: opts.page ?? 1, again }, opts.exact === true, skips, denied);
8976
+ return vectors ? { ...body, missing: [...body.missing ?? [], { field: "found_by", why: vectors }] } : body;
8929
8977
  });
8930
8978
  });
8931
8979
  }, "addCrmSearchAll");
8932
8980
 
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
8981
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/sync-embed.js
8982
+ var EMBED_MAX = 600;
8983
+ var crmSyncEmbeddings = strictObject({
8984
+ model: text,
8985
+ embedded: count,
8986
+ left: boolean(),
8987
+ stopped: optional(picklist(["deadline", "cancelled"])),
8988
+ remaining: optional(count)
8989
+ });
8990
+ var syncEmbeddings = /* @__PURE__ */ __name(async (command, store, report, app, again) => {
8991
+ if (report.stopped)
8992
+ return { item: {}, issues: [] };
8993
+ const { env, deadline, signal } = environmentOf(command);
8994
+ const ends = deadline?.();
8995
+ try {
8996
+ const embeddings = await embedCrmActivities(store, {
8997
+ maxChunks: EMBED_MAX,
8998
+ ...ends ? { deadline: ends } : {},
8999
+ ...signal ? { signal } : {},
9000
+ ...env ? { env } : {},
9001
+ ...commandAt(rootOf2(command), "models download") ? { command: app.command } : {}
9002
+ });
9003
+ if (!embeddings.left)
9004
+ return { item: { embeddings }, issues: [] };
9005
+ return {
9006
+ item: { embeddings },
9007
+ issues: [],
9008
+ next: [
9009
+ {
9010
+ kind: "command",
9011
+ step: "crm.sync",
9012
+ command: "sync",
9013
+ args: Object.fromEntries(Object.entries({ ...again, embed: true }).filter(([, value]) => value !== void 0)),
9014
+ why: `${embeddings.remaining === void 0 ? "some" : embeddings.remaining} activity chunks have no vectors yet, so search all may miss their deals by meaning; running sync --embed again embeds the next ones`,
9015
+ safe_to_auto_execute: true
9016
+ }
9017
+ ]
9018
+ };
9019
+ } catch (error) {
9020
+ if (signal?.aborted || !isCliError(error))
9021
+ throw error;
9022
+ const reason = error.details.reason;
9023
+ return {
9024
+ item: {},
9025
+ issues: [
9026
+ { code: error.code, reason: typeof reason === "string" ? reason : "sync.failed", source: "crm:embeddings" }
9027
+ ]
9028
+ };
9029
+ }
9030
+ }, "syncEmbeddings");
9031
+
9032
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/cli/profile-store.js
8934
9033
  import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
8935
9034
  import { tmpdir } from "node:os";
8936
9035
  import { join as join3 } from "node:path";
8937
- var openCrmStore = /* @__PURE__ */ __name(async (options) => {
9036
+ var openProfileStore = /* @__PURE__ */ __name(async (options) => {
8938
9037
  const { app, env, profile, readOnly, open: open2 } = options;
8939
9038
  const locked = readOnly && readOnlyLockOf(app, env) !== void 0;
8940
9039
  if (readOnly) {
@@ -8966,7 +9065,7 @@ var openCrmStore = /* @__PURE__ */ __name(async (options) => {
8966
9065
  removing();
8967
9066
  throw error;
8968
9067
  }
8969
- }, "openCrmStore");
9068
+ }, "openProfileStore");
8970
9069
  var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, env, account) => {
8971
9070
  const store = await open2(env);
8972
9071
  try {
@@ -8979,7 +9078,10 @@ var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, e
8979
9078
  }
8980
9079
  }, "withProfile");
8981
9080
 
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
9081
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/store.js
9082
+ var openCrmStore = openProfileStore;
9083
+
9084
+ // node_modules/.pnpm/@wirecat+cli-core@0.748.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_80da9f03871bc395375181cc05991961/node_modules/@wirecat/cli-core/dist/crm/cli/index.js
8983
9085
  var MOST4 = 500;
8984
9086
  var STAGE_REF = /^stage:\d+$/;
8985
9087
  var timeField = /* @__PURE__ */ __name((name, example, relation) => nativeField({ name, type: "time", operators: ["term", "range"], example, relation }), "timeField");
@@ -9071,7 +9173,8 @@ var crmSync = strictObject({
9071
9173
  stopped: optional(picklist(["requests", "deadline", "cancelled"])),
9072
9174
  progress: strictObject({ requests: count, saved: count, steps: count }),
9073
9175
  hint: optional(text),
9074
- group_hint: optional(text)
9176
+ group_hint: optional(text),
9177
+ embeddings: optional(crmSyncEmbeddings)
9075
9178
  });
9076
9179
  var crmSyncProgress = strictObject({
9077
9180
  kind: picklist(CRM_KINDS),
@@ -9150,7 +9253,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
9150
9253
  const hasLeads = options.leads !== false;
9151
9254
  const dealsAndLeads = hasLeads ? "deals and leads" : "deals";
9152
9255
  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", `
9153
- 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) => {
9256
+ 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. With --embed it then indexes the activities' text with a model already downloaded, so search all finds their deals and leads by meaning, not only by words.`), "sync", "sync --rescan", "sync --embed").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)).option("--embed", "also index new activities and tasks for search all by meaning, with a model already downloaded").action(async (opts, command) => {
9154
9257
  const { signal } = environmentOf(command);
9155
9258
  await within(command, async (run3) => {
9156
9259
  const source = run3.source();
@@ -9168,13 +9271,14 @@ With the activities setting on, it also copies the activities and tasks on the $
9168
9271
  const retried = failed.filter((one) => one.setting === void 0);
9169
9272
  const settings = [...new Set(failed.flatMap((one) => one.setting ?? []))];
9170
9273
  const timeout = command.optsWithGlobals().timeout;
9274
+ const again = { max_pages: opts.maxPages, timeout, embed: opts.embed };
9171
9275
  const stuck = report.state === "partial" && report.progress.steps === 0 && failed.length === 0;
9172
9276
  const next = retried.length || report.state === "partial" && !stuck && failed.length === 0 ? [
9173
9277
  {
9174
9278
  kind: "command",
9175
9279
  step: "crm.sync",
9176
9280
  command: "sync",
9177
- args: Object.fromEntries(Object.entries({ max_pages: opts.maxPages, timeout }).filter(([, value]) => value !== void 0)),
9281
+ args: Object.fromEntries(Object.entries(again).filter(([, value]) => value !== void 0)),
9178
9282
  why: retried.length ? "a kind failed to sync; running sync again retries it" : "the sync stopped before its end to answer in time; running it again goes on from there",
9179
9283
  safe_to_auto_execute: true
9180
9284
  }
@@ -9183,6 +9287,7 @@ With the activities setting on, it also copies the activities and tasks on the $
9183
9287
  const fixes = settings.map((setting) => lineOf(command, `config set ${setting} <value>`));
9184
9288
  const hint = failed.length ? `${failed.map((one) => `${one.kind}: ${one.error}`).join("; ")} \u2014 ${fixes.length ? `fix the setting: ${fixes.join("; ")}` : "run sync again to retry"}` : stuck ? `this run moved nothing on: raise --timeout or --max-pages, then run sync again; see progress: ${progressAt}` : report.state === "partial" ? `run sync again to continue; see progress: ${progressAt}` : void 0;
9185
9289
  const { hint: _hint, ...rest } = report;
9290
+ const embedded = opts.embed ? await syncEmbeddings(command, run3.store, report, options.app, again) : void 0;
9186
9291
  const issues = [
9187
9292
  ...failed.map((one) => ({
9188
9293
  code: one.setting === void 0 ? "provider_error" : "validation_error",
@@ -9193,12 +9298,13 @@ With the activities setting on, it also copies the activities and tasks on the $
9193
9298
  code: "validation_error",
9194
9299
  reason: one.reason,
9195
9300
  source: one.externalId === void 0 ? `crm:${one.kind}` : `crm:${one.kind}/${one.externalId}`
9196
- }))
9301
+ })),
9302
+ ...embedded?.issues ?? []
9197
9303
  ];
9198
9304
  const partial = report.state === "partial" || issues.length > 0;
9199
- return itemOf(snakeKeys({ ...rest, stageTasks, ...hint === void 0 ? {} : { hint } }), {
9305
+ return itemOf(snakeKeys({ ...rest, stageTasks, ...hint === void 0 ? {} : { hint }, ...embedded?.item }), {
9200
9306
  ...partial ? { meta: { complete: false, ...issues.length ? { issues } : {} } } : {},
9201
- ...next ? { next } : {}
9307
+ ...next || embedded?.next ? { next: next ?? embedded?.next } : {}
9202
9308
  });
9203
9309
  });
9204
9310
  });
@@ -9552,12 +9658,57 @@ With the activities setting on, it also copies the activities and tasks on the $
9552
9658
  });
9553
9659
  const search = program.commands.find((one) => one.name() === "search") ?? annotate(program.command("search"), { effects: NO_EFFECTS }).description("search what the local store holds");
9554
9660
  addCrmSearchAll(search, { within, app: options.app, example, viewerOf, leads: hasLeads });
9661
+ if (options.account)
9662
+ program.addCommand(crmAccountCommand(options.app, options.account));
9555
9663
  }, "addCrmCommandsDefinition");
9556
9664
  var addCrmCommands = honoursDryRun(sharedCommand(addCrmCommandsDefinition));
9557
9665
 
9666
+ // dist/whoami.js
9667
+ var accountAnswer = /* @__PURE__ */ __name(async (hub) => {
9668
+ const details = await accountDetails(hub);
9669
+ const id = String(details.portalId);
9670
+ return {
9671
+ account: id,
9672
+ account_info: { id, ui_domain: details.uiDomain, time_zone: details.timeZone, type: details.accountType },
9673
+ user: null
9674
+ };
9675
+ }, "accountAnswer");
9676
+
9677
+ // dist/commands/account.js
9678
+ var rememberedOf = /* @__PURE__ */ __name((profile, env) => {
9679
+ const account = recalledAccount(IDENTITY, PROVIDER.name, profile, env)?.account;
9680
+ return account !== void 0 && /^\d+$/.test(account) ? account : void 0;
9681
+ }, "rememberedOf");
9682
+ var signedInTo = /* @__PURE__ */ __name((profile, env, keyring) => {
9683
+ const saved = new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {}, warn: /* @__PURE__ */ __name(() => {
9684
+ }, "warn") }).read(profile);
9685
+ if (!saved || saved.source === "environment")
9686
+ return void 0;
9687
+ return decodeSignIn(saved.secret).portalId;
9688
+ }, "signedInTo");
9689
+ var HUBSPOT_ACCOUNT = {
9690
+ provider: PROVIDER.name,
9691
+ service: "HubSpot",
9692
+ held: /* @__PURE__ */ __name((profile, { env, keyring }) => {
9693
+ const remembered = rememberedOf(profile, env);
9694
+ try {
9695
+ const saved = signedInTo(profile, env, keyring);
9696
+ if (saved)
9697
+ return { account: saved, signedIn: true };
9698
+ } catch (error) {
9699
+ if (!remembered)
9700
+ throw error;
9701
+ }
9702
+ return remembered === void 0 ? void 0 : { account: remembered, signedIn: false };
9703
+ }, "held"),
9704
+ // HubSpot has no call that revokes a service key or a private app token; the account's settings do.
9705
+ signedOut: /* @__PURE__ */ __name((profile) => `the sign-in of ${profile} (the key stays valid in HubSpot until you delete or rotate it there)`, "signedOut"),
9706
+ resolveSettings: configuration.resolveSettings
9707
+ };
9708
+
9558
9709
  // dist/commands/crm-shared.js
9559
9710
  var savedAccount = /* @__PURE__ */ __name(async (env, profile) => {
9560
- const { openHubspotStore } = await import("./store-Q3ZKD4FJ.js");
9711
+ const { openHubspotStore } = await import("./store-LON2XRIS.js");
9561
9712
  const store = await openHubspotStore(env, { readOnly: true }).catch(() => void 0);
9562
9713
  if (!store)
9563
9714
  return void 0;
@@ -9572,9 +9723,9 @@ var savedAccount = /* @__PURE__ */ __name(async (env, profile) => {
9572
9723
  var openProfile = /* @__PURE__ */ __name(async (command, { readOnly }) => {
9573
9724
  const { env, profile, environment } = contextOf(command);
9574
9725
  const [{ openHubspotStore, PROVIDER: PROVIDER2 }, { hubspotCrmSource }, { hubspotCrmWriter }] = await Promise.all([
9575
- import("./store-Q3ZKD4FJ.js"),
9576
- import("./source-DF63EC2B.js"),
9577
- import("./writer-EQQ55HOS.js")
9726
+ import("./store-LON2XRIS.js"),
9727
+ import("./source-XP2JNUVU.js"),
9728
+ import("./writer-NOSHE7ZI.js")
9578
9729
  ]);
9579
9730
  const fromToken = fromEnvironment(command);
9580
9731
  const online = metaOf(command).effects?.remote !== "none";
@@ -9636,7 +9787,8 @@ var crmSharedCommands = /* @__PURE__ */ __name(() => {
9636
9787
  leads: true,
9637
9788
  writes: HUBSPOT_WRITES,
9638
9789
  live: ["person", "organization", "user"],
9639
- activities: true
9790
+ activities: true,
9791
+ account: HUBSPOT_ACCOUNT
9640
9792
  });
9641
9793
  return [...holder.commands];
9642
9794
  }, "crmSharedCommands");
@@ -9648,6 +9800,100 @@ var contextOf2 = /* @__PURE__ */ __name((command, resolving) => {
9648
9800
  }, "contextOf");
9649
9801
  var scheduleCommand = /* @__PURE__ */ __name(() => scheduleCommandFor({ app: IDENTITY, context: contextOf2 }), "scheduleCommand");
9650
9802
 
9803
+ // dist/commands/session.js
9804
+ var HUBSPOT = IDENTITY.command;
9805
+ var answer = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
9806
+ var storageOf = /* @__PURE__ */ __name((raw) => {
9807
+ if (raw === "keyring" || raw === "file")
9808
+ return raw;
9809
+ throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
9810
+ }, "storageOf");
9811
+ var tokensHere = /* @__PURE__ */ __name((env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {} }), "tokensHere");
9812
+ var checkedToken = /* @__PURE__ */ __name(async (command, token) => {
9813
+ const { env, profile, keyring, settings, run: run3 } = contextOf(command);
9814
+ const who = await run3((events) => accountAnswer(hubFor(command, { token }, events)));
9815
+ refuseTakenCrmAccount(IDENTITY, HUBSPOT_ACCOUNT, { env, profile, profiles: settings.configuredProfiles, ...keyring ? { keyring } : {} }, { account: who.account });
9816
+ const { ui_domain: uiDomain, time_zone: timeZone } = who.account_info;
9817
+ return { who, signIn: encodeSignIn({ token, portalId: who.account, uiDomain, timeZone }) };
9818
+ }, "checkedToken");
9819
+ var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
9820
+ effects: FETCH,
9821
+ lifetime: "interactive",
9822
+ mcp: false,
9823
+ examples: [
9824
+ `${HUBSPOT} work session start`,
9825
+ `${HUBSPOT} work session start --json`,
9826
+ `${HUBSPOT} work session start --credential-storage file`
9827
+ ]
9828
+ })).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) {
9829
+ const { env, profile, tokens } = contextOf(this);
9830
+ refuseCommandName(profile, commandWords(rootOf(this)), HUBSPOT);
9831
+ refuseOffline(this, SERVICE);
9832
+ const token = (await readSecret(`${SERVICE} service key or private app token: `, secretInputOf(this))).trim();
9833
+ if (!token)
9834
+ throw new CliError("validation_error", "no token was given");
9835
+ const { who, signIn } = await checkedToken(this, token);
9836
+ const storedIn = tokens.write(profile, signIn, args.credentialStorage);
9837
+ rememberAccount(IDENTITY, profile, who.account, env);
9838
+ answer(this, { profile, state: "saved", kind: "token", stored_in: storedIn, verified: true, ...who });
9839
+ }), "startCommand");
9840
+ var statusCommand = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
9841
+ effects: REMOTE_READ,
9842
+ examples: [`${HUBSPOT} work session status`, `${HUBSPOT} work session status --check --json`]
9843
+ }).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) {
9844
+ const { env, profile, tokens, run: run3 } = contextOf(this);
9845
+ const saved = tokens.read(profile);
9846
+ const fromToken = saved?.source === "environment";
9847
+ const named = fromToken ? environmentAccount(env) : storedSignIn(this)?.portalId;
9848
+ const status = {
9849
+ profile,
9850
+ state: saved ? "saved" : "missing",
9851
+ kind: saved ? "token" : null,
9852
+ token_from: saved?.source ?? null,
9853
+ account: named ?? null
9854
+ };
9855
+ if (!args.check || !saved)
9856
+ return answer(this, { ...status, verified: false });
9857
+ if (!fromToken)
9858
+ return answer(this, { ...status, verified: true, ...await withHub(this, accountAnswer) });
9859
+ refuseOffline(this, SERVICE);
9860
+ const who = await run3((events) => accountAnswer(hubFor(this, { token: saved.secret, portalId: named }, events)));
9861
+ if (named)
9862
+ refuseAccountMismatch(named, who.account);
9863
+ answer(this, { ...status, verified: true, ...who });
9864
+ }), "statusCommand");
9865
+ var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
9866
+ effects: LOCAL_WRITE,
9867
+ mcp: false,
9868
+ examples: [`${HUBSPOT} work session end`]
9869
+ })).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() {
9870
+ refuseUnderReadOnly(this, "session end");
9871
+ const { profile, tokens } = contextOf(this);
9872
+ answer(this, { profile, ended: tokens.remove(profile) });
9873
+ }), "endCommand");
9874
+ var listCommand = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
9875
+ effects: LOCAL_READ,
9876
+ examples: [`${HUBSPOT} session list`, `${HUBSPOT} session list --json`]
9877
+ })).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() {
9878
+ const environment = environmentOf(this);
9879
+ const env = environment.env ?? process.env;
9880
+ const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
9881
+ const tokens = tokensHere(env, environment.keyring);
9882
+ const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
9883
+ try {
9884
+ const saved = tokens.read(profile);
9885
+ const account = saved && saved.source !== "environment" ? decodeSignIn(saved.secret).portalId : null;
9886
+ return { profile, signed_in: saved !== void 0, token_from: saved?.source ?? null, account };
9887
+ } catch (error) {
9888
+ if (!(error instanceof CliError))
9889
+ throw error;
9890
+ return { profile, signed_in: null, token_from: null, account: null, error: error.message };
9891
+ }
9892
+ });
9893
+ renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
9894
+ }), "listCommand");
9895
+ 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");
9896
+
9651
9897
  // dist/setup/texts.en.json
9652
9898
  var texts_en_default = {
9653
9899
  "key.title": "Make a key",
@@ -9842,7 +10088,6 @@ var definition = /* @__PURE__ */ __name(() => ({
9842
10088
  commands: /* @__PURE__ */ __name(() => [
9843
10089
  commandsCommand(IDENTITY),
9844
10090
  sessionCommand(),
9845
- accountCommand(),
9846
10091
  ...crmSharedCommands(),
9847
10092
  apiCommand(),
9848
10093
  scheduleCommand(),