@wirecat/hubspot-cli 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +40 -16
  3. package/contracts/wirecat.json +1516 -173
  4. package/dist/bin/hubspot.js +2 -2
  5. package/dist/bundle/agent-A7ARC3QB.js +40 -0
  6. package/dist/bundle/{all-profiles-64JAUYW4.js → all-profiles-6452VSJB.js} +64 -22
  7. package/dist/bundle/{anthropic-VJOS4OUM.js → anthropic-VQUOVYOW.js} +6 -6
  8. package/dist/bundle/{app-server-422MCA7S.js → app-server-FFYKM37G.js} +79 -68
  9. package/dist/bundle/{bun-M3J2QTR3.js → bun-AJPJ4ZUN.js} +2 -2
  10. package/dist/bundle/{bun-sqlite-IX3XYA5F.js → bun-sqlite-AGXGSF6D.js} +7 -7
  11. package/dist/bundle/{chunk-N2XADGL4.js → chunk-2A64XS22.js} +4 -4
  12. package/dist/bundle/{chunk-HTAN663T.js → chunk-2HYGCLKN.js} +93 -565
  13. package/dist/bundle/{chunk-FOZYMDRL.js → chunk-2NCO4E4T.js} +6 -6
  14. package/dist/bundle/{chunk-FBCCBCFH.js → chunk-2PRVWEJC.js} +3 -3
  15. package/dist/bundle/{chunk-LOBVOGOE.js → chunk-3DIXAEGH.js} +4 -4
  16. package/dist/bundle/{chunk-O3DYRCIT.js → chunk-3I2FGNWO.js} +1 -1
  17. package/dist/bundle/{chunk-65TWQ7BV.js → chunk-3PEKYGZ3.js} +2 -2
  18. package/dist/bundle/{chunk-DRWWJLI6.js → chunk-3R4KRNUZ.js} +8 -8
  19. package/dist/bundle/{chunk-2VGD63G6.js → chunk-3TEFE6YU.js} +7 -7
  20. package/dist/bundle/{chunk-BKXDHU3G.js → chunk-3WIVJJNB.js} +19 -17
  21. package/dist/bundle/{chunk-TI46WQXQ.js → chunk-4DNHXRCJ.js} +7 -7
  22. package/dist/bundle/{chunk-QU25DA5N.js → chunk-5AYKCKSE.js} +11 -11
  23. package/dist/bundle/chunk-5HD64ETI.js +561 -0
  24. package/dist/bundle/{chunk-CWXOXIWS.js → chunk-5K3FGXZH.js} +1 -1
  25. package/dist/bundle/{chunk-24ERVFJP.js → chunk-5YNAVVCW.js} +3 -3
  26. package/dist/bundle/chunk-77CUE3VX.js +46 -0
  27. package/dist/bundle/{chunk-36ITRDYY.js → chunk-7LQRXVQ3.js} +783 -482
  28. package/dist/bundle/{chunk-E5WLE7BM.js → chunk-7NZT7Y55.js} +1 -1
  29. package/dist/bundle/{chunk-C32AKHTY.js → chunk-7UEL65GQ.js} +35 -12
  30. package/dist/bundle/chunk-7VHBS5BJ.js +108 -0
  31. package/dist/bundle/{chunk-O55RWNSH.js → chunk-A6UFH3QU.js} +4 -4
  32. package/dist/bundle/{chunk-WE4UFASG.js → chunk-ABXVU5O4.js} +8 -1
  33. package/dist/bundle/{chunk-4W6BMH45.js → chunk-AF7DANIR.js} +2 -100
  34. package/dist/bundle/{chunk-LNV33FDC.js → chunk-AFL2C4JR.js} +60 -50
  35. package/dist/bundle/{chunk-2VGZRYEH.js → chunk-ARTJLL7W.js} +6 -6
  36. package/dist/bundle/chunk-AVUMH42T.js +194 -0
  37. package/dist/bundle/chunk-B2W3C4N6.js +338 -0
  38. package/dist/bundle/{chunk-FKA7DOCK.js → chunk-B3EH22CO.js} +1 -1
  39. package/dist/bundle/{chunk-E52JAS35.js → chunk-BAUK2MD5.js} +6 -6
  40. package/dist/bundle/{chunk-JLDBMEKZ.js → chunk-BN22EKQQ.js} +2 -2
  41. package/dist/bundle/{chunk-DB2XKHI4.js → chunk-BUGROVF3.js} +2 -2
  42. package/dist/bundle/{chunk-DSP36YHQ.js → chunk-CBCEMFCF.js} +2 -2
  43. package/dist/bundle/{chunk-WQBX7XYP.js → chunk-CYADK744.js} +1559 -1888
  44. package/dist/bundle/{chunk-HZRQLAHO.js → chunk-DQB5JMTY.js} +1 -1
  45. package/dist/bundle/{chunk-JRCPCVPI.js → chunk-DQP2GAAO.js} +75 -66
  46. package/dist/bundle/{chunk-FPUGMDJV.js → chunk-DSRXCLPO.js} +1 -1
  47. package/dist/bundle/{chunk-UUMUL4L3.js → chunk-DW23LM47.js} +2 -2
  48. package/dist/bundle/{chunk-TKVL2C3B.js → chunk-E4X7JAFC.js} +3 -3
  49. package/dist/bundle/{chunk-NUU4WZVL.js → chunk-EE4JSYGZ.js} +3 -3
  50. package/dist/bundle/{chunk-NWHEHV3K.js → chunk-EMOVVERN.js} +5 -5
  51. package/dist/bundle/{chunk-PVKF24ZW.js → chunk-FIVD4HM4.js} +8 -8
  52. package/dist/bundle/{chunk-QJW35N5V.js → chunk-GC6FLHZF.js} +12 -12
  53. package/dist/bundle/{chunk-TP7GDWVF.js → chunk-GRFICQTZ.js} +1 -1
  54. package/dist/bundle/{chunk-X2M6NIQG.js → chunk-HPZRUY6S.js} +1 -1
  55. package/dist/bundle/{chunk-CLAN3FES.js → chunk-IBTMK5KD.js} +54 -34
  56. package/dist/bundle/{chunk-5A6ZYNAQ.js → chunk-IQ2XZ62J.js} +18 -18
  57. package/dist/bundle/{chunk-DBEQI5YM.js → chunk-ITGNDZRR.js} +3 -3
  58. package/dist/bundle/{chunk-W53EJOFQ.js → chunk-IXZLMFPO.js} +1 -1
  59. package/dist/bundle/{chunk-TOSCB4SO.js → chunk-J5P5VSRG.js} +16 -10
  60. package/dist/bundle/{chunk-VIEYMDBR.js → chunk-J6C2QWL5.js} +3 -3
  61. package/dist/bundle/{chunk-ZBDSHFG4.js → chunk-JG7YMHNB.js} +3427 -3284
  62. package/dist/bundle/{chunk-RMIYKDUL.js → chunk-JK2SNLU5.js} +17 -17
  63. package/dist/bundle/{chunk-43EKCUBJ.js → chunk-JP2HJXFO.js} +3 -3
  64. package/dist/bundle/{chunk-DFCHHR5M.js → chunk-JUKAIXKY.js} +1 -1
  65. package/dist/bundle/{chunk-5GBUCHRU.js → chunk-KO4VR5NK.js} +4 -4
  66. package/dist/bundle/{chunk-PPHBRESD.js → chunk-KVXEEKBB.js} +2 -2
  67. package/dist/bundle/{chunk-SDQGB4KB.js → chunk-L433IDOX.js} +9 -9
  68. package/dist/bundle/chunk-LA3YU4K7.js +40 -0
  69. package/dist/bundle/{chunk-ECEZOLOD.js → chunk-LKSNISYV.js} +4 -4
  70. package/dist/bundle/{chunk-5K7QLJMM.js → chunk-LT5KE44Q.js} +226 -226
  71. package/dist/bundle/chunk-M763RNWP.js +733 -0
  72. package/dist/bundle/chunk-M7XLG6AN.js +353 -0
  73. package/dist/bundle/{chunk-IMJQRPLN.js → chunk-NNMU2TDU.js} +1 -1
  74. package/dist/bundle/chunk-NTQBS2JL.js +52 -0
  75. package/dist/bundle/{chunk-HCAZV5NP.js → chunk-NZGI74GS.js} +6 -6
  76. package/dist/bundle/{chunk-W7HM2VGO.js → chunk-O3VM5PTJ.js} +1 -1
  77. package/dist/bundle/chunk-OPVNUI4M.js +195 -0
  78. package/dist/bundle/{chunk-7ELMWE3P.js → chunk-PHXOL5HZ.js} +176 -160
  79. package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
  80. package/dist/bundle/{chunk-B3MANLNK.js → chunk-PLRUUXK7.js} +19 -233
  81. package/dist/bundle/{chunk-RR5MX5TM.js → chunk-PMP37KLR.js} +4 -4
  82. package/dist/bundle/{chunk-FTFV3HFW.js → chunk-Q27QAB4X.js} +9 -9
  83. package/dist/bundle/{chunk-2TWQIWWG.js → chunk-QFZD6MTF.js} +35 -29
  84. package/dist/bundle/{chunk-2QZK5BEP.js → chunk-RVWGFD32.js} +30 -15
  85. package/dist/bundle/{chunk-MVA5HVKL.js → chunk-S4UUN6LD.js} +18 -0
  86. package/dist/bundle/{chunk-QGFX5MXL.js → chunk-SEELWPRD.js} +9 -9
  87. package/dist/bundle/{chunk-SAKK2YRU.js → chunk-SMTTIKZ5.js} +12 -12
  88. package/dist/bundle/{chunk-X7XUX7A4.js → chunk-TDQJS3JG.js} +10 -10
  89. package/dist/bundle/{chunk-HC5ZWE5X.js → chunk-TIHDBKA7.js} +2 -2
  90. package/dist/bundle/{chunk-NHHJHXMQ.js → chunk-U6XA3OOM.js} +2 -2
  91. package/dist/bundle/{chunk-NXERIDPJ.js → chunk-VQEAZXTV.js} +7 -7
  92. package/dist/bundle/{chunk-P5BHKKBI.js → chunk-VW5F6FK3.js} +4 -4
  93. package/dist/bundle/{chunk-XRREFEIW.js → chunk-WCQW4GYO.js} +7 -7
  94. package/dist/bundle/{chunk-H3TNVEQX.js → chunk-WGBVRDY3.js} +29 -4
  95. package/dist/bundle/chunk-WRCKE5ND.js +80 -0
  96. package/dist/bundle/{chunk-TBJYLC5K.js → chunk-X5S5KUSU.js} +75 -75
  97. package/dist/bundle/command-contract-R2FGN7CQ.js +40 -0
  98. package/dist/bundle/{command-server-entry-DJKVVZCQ.js → command-server-entry-GJSMDSNE.js} +29 -29
  99. package/dist/bundle/{decode-FC65Y4IV.js → decode-6PLXHVHW.js} +6 -6
  100. package/dist/bundle/{dispatch-KOISQ5QJ.js → dispatch-TAQ7635E.js} +8 -8
  101. package/dist/bundle/{dist-MYZZKZJ7.js → dist-7TGU56B2.js} +1 -1
  102. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  103. package/dist/bundle/{echarts-FVTUDXDU.js → echarts-UZ7QLRE2.js} +2 -2
  104. package/dist/bundle/{embed-VNBZFPYH.js → embed-AWLL4EBF.js} +7 -7
  105. package/dist/bundle/{embedder-6U4NOFRO.js → embedder-MM225YJ6.js} +10 -10
  106. package/dist/bundle/{failure-FZ6VYKEQ.js → failure-MR2XVHFP.js} +3 -3
  107. package/dist/bundle/first-run-MAUI6QJ7.js +29 -0
  108. package/dist/bundle/first-screen-SCDV7TXT.js +40 -0
  109. package/dist/bundle/hubspot.js +26 -26
  110. package/dist/bundle/{instructions-HET7BCYK.js → instructions-ZJ7U3QUE.js} +1 -1
  111. package/dist/bundle/{mcp-RGNRW77S.js → mcp-CNV7F2XZ.js} +2 -2
  112. package/dist/bundle/meeting-combined-EL5XZIJ5.js +25 -0
  113. package/dist/bundle/meeting-model-OYXB2NOE.js +25 -0
  114. package/dist/bundle/{meeting-semantic-JY3OGCBS.js → meeting-semantic-S3DBB7XD.js} +7 -7
  115. package/dist/bundle/{node-CXZIFHZC.js → node-HGCZGZ4R.js} +2 -2
  116. package/dist/bundle/{node-sqlite-P3O7XN7Q.js → node-sqlite-RKYSRKEB.js} +8 -8
  117. package/dist/bundle/oauth-PYDCAQ7Y.js +20 -0
  118. package/dist/bundle/{open-F4P6YV54.js → open-UCDSQUN2.js} +6 -6
  119. package/dist/bundle/{openai-4AICLIK3.js → openai-Y4F5ZC7O.js} +16 -16
  120. package/dist/bundle/{process-5RUXWGYS.js → process-P7FB7YO7.js} +1 -1
  121. package/dist/bundle/{program-POG5GHUQ.js → program-2D5D32HK.js} +835 -261
  122. package/dist/bundle/{prompt-NFMDVBZ4.js → prompt-E5TKZ37Q.js} +6 -6
  123. package/dist/bundle/{recognize-DKN3RY4V.js → recognize-5NYPTSLT.js} +5 -5
  124. package/dist/bundle/{remote-6QHAGQWY.js → remote-U4LUAHF2.js} +10 -10
  125. package/dist/bundle/{rerank-M4KHEHUZ.js → rerank-AJAVKK5L.js} +8 -8
  126. package/dist/bundle/{schemas-JRL3DLMP.js → schemas-QLQ2K6DL.js} +7 -33
  127. package/dist/bundle/{serve-DNU43ND6.js → serve-4UJ3R5IP.js} +11 -11
  128. package/dist/bundle/server-CN6VQNNF.js +86 -0
  129. package/dist/bundle/{server-XJSNF3K5.js → server-OJPCTV77.js} +73 -61
  130. package/dist/bundle/{source-A3SBLHC4.js → source-VHDK74YS.js} +133 -399
  131. package/dist/bundle/{sqlite-runtime-EMQAC63N.js → sqlite-runtime-KLEA4XAU.js} +7 -7
  132. package/dist/bundle/{state-T45CX7VY.js → state-COGSYMVH.js} +7 -7
  133. package/dist/bundle/{store-6TZ2FCVA.js → store-BJXCSP26.js} +25 -24
  134. package/dist/bundle/store-HXA2MRWI.js +32 -0
  135. package/dist/bundle/{store-6LCEVBAZ.js → store-V5UMSWK4.js} +27 -22
  136. package/dist/bundle/store-maintenance-command-AC7GGLYC.js +73 -0
  137. package/dist/bundle/surface-ZZNG3OW2.js +72 -0
  138. package/dist/bundle/writer-CZYA657G.js +86 -0
  139. package/dist/commands/api.d.ts +4 -4
  140. package/dist/commands/api.d.ts.map +1 -1
  141. package/dist/commands/api.js +12 -7
  142. package/dist/commands/api.js.map +1 -1
  143. package/dist/commands/crm-shared.d.ts +2 -2
  144. package/dist/commands/crm-shared.d.ts.map +1 -1
  145. package/dist/commands/crm-shared.js +20 -4
  146. package/dist/commands/crm-shared.js.map +1 -1
  147. package/dist/config.d.ts +46 -8
  148. package/dist/config.d.ts.map +1 -1
  149. package/dist/config.js +133 -12
  150. package/dist/config.js.map +1 -1
  151. package/dist/context.d.ts +2 -2
  152. package/dist/context.d.ts.map +1 -1
  153. package/dist/context.js +1 -1
  154. package/dist/context.js.map +1 -1
  155. package/dist/crm/source.d.ts +7 -2
  156. package/dist/crm/source.d.ts.map +1 -1
  157. package/dist/crm/source.js +26 -29
  158. package/dist/crm/source.js.map +1 -1
  159. package/dist/crm/writer.d.ts +15 -0
  160. package/dist/crm/writer.d.ts.map +1 -0
  161. package/dist/crm/writer.js +199 -0
  162. package/dist/crm/writer.js.map +1 -0
  163. package/dist/generated/manifest.d.ts.map +1 -1
  164. package/dist/generated/manifest.js +6 -116
  165. package/dist/generated/manifest.js.map +1 -1
  166. package/dist/generated/types.d.ts +160 -0
  167. package/dist/generated/types.d.ts.map +1 -1
  168. package/dist/hubspot/transport.d.ts +6 -1
  169. package/dist/hubspot/transport.d.ts.map +1 -1
  170. package/dist/hubspot/transport.js +13 -5
  171. package/dist/hubspot/transport.js.map +1 -1
  172. package/dist/identity.js +3 -3
  173. package/dist/identity.js.map +1 -1
  174. package/dist/program.d.ts.map +1 -1
  175. package/dist/program.js +2 -1
  176. package/dist/program.js.map +1 -1
  177. package/dist/setup/texts.en.json +3 -3
  178. package/dist/setup/texts.es.json +3 -3
  179. package/dist/setup/texts.ru.json +3 -3
  180. package/dist/version.d.ts +1 -1
  181. package/dist/version.js +1 -1
  182. package/package.json +4 -4
  183. package/skills/hubspot-cli/SKILL.md +13 -8
  184. package/skills/hubspot-cli/references/api/api-advanced.md +51 -0
  185. package/skills/hubspot-cli/references/api/api-basic.md +602 -0
  186. package/skills/hubspot-cli/references/api/api-batch.md +575 -0
  187. package/skills/hubspot-cli/references/api.md +3 -2
  188. package/dist/bundle/command-contract-C6CBFXZF.js +0 -40
  189. package/dist/bundle/first-run-RPIJZEDT.js +0 -29
  190. package/dist/bundle/first-screen-RTVMGHAE.js +0 -40
  191. package/dist/bundle/meeting-combined-L5AGBPYX.js +0 -25
  192. package/dist/bundle/meeting-model-NTB4RK3F.js +0 -25
  193. package/dist/bundle/oauth-HNCY4B2S.js +0 -20
  194. package/dist/bundle/server-C3ZHA7AZ.js +0 -77
  195. package/dist/bundle/store-CCDNUB6A.js +0 -32
  196. package/dist/bundle/store-maintenance-command-BRCG6MNA.js +0 -68
  197. package/dist/commands/comments.d.ts +0 -3
  198. package/dist/commands/comments.d.ts.map +0 -1
  199. package/dist/commands/comments.js +0 -114
  200. package/dist/commands/comments.js.map +0 -1
  201. package/dist/sample/comments.d.ts +0 -61
  202. package/dist/sample/comments.d.ts.map +0 -1
  203. package/dist/sample/comments.js +0 -39
  204. package/dist/sample/comments.js.map +0 -1
  205. package/dist/sample/records.d.ts +0 -16
  206. package/dist/sample/records.d.ts.map +0 -1
  207. package/dist/sample/records.js +0 -22
  208. package/dist/sample/records.js.map +0 -1
  209. package/dist/sample/transport.d.ts +0 -42
  210. package/dist/sample/transport.d.ts.map +0 -1
  211. package/dist/sample/transport.js +0 -153
  212. package/dist/sample/transport.js.map +0 -1
@@ -0,0 +1,353 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ AUDIT_MIN_SCORE
5
+ } from "./chunk-JG7YMHNB.js";
6
+ import {
7
+ LIST_QUERY_GUIDE,
8
+ nativeTerms
9
+ } from "./chunk-M763RNWP.js";
10
+ import {
11
+ DEFAULT_CONFIG,
12
+ environmentOf,
13
+ itemOf,
14
+ listOf,
15
+ nextStep,
16
+ renderAnswer,
17
+ snakeKeys,
18
+ withAgentLevels
19
+ } from "./chunk-PHXOL5HZ.js";
20
+ import {
21
+ formatReference
22
+ } from "./chunk-GC6FLHZF.js";
23
+ import {
24
+ queryError
25
+ } from "./chunk-LT5KE44Q.js";
26
+ import {
27
+ CliError
28
+ } from "./chunk-BUGROVF3.js";
29
+ import {
30
+ __name
31
+ } from "./chunk-ZVVMGPBJ.js";
32
+
33
+ // node_modules/.pnpm/@wirecat+cli-core@0.699.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_13ea275dd452fd1070c59d86b8d8c388/node_modules/@wirecat/cli-core/dist/cli/paging.js
34
+ var positiveCount = /* @__PURE__ */ __name((flag) => (value) => {
35
+ if (!/^\d+$/.test(value.trim()) || Number(value) < 1)
36
+ throw new CliError("validation_error", `${flag} takes a whole number from 1 upwards, not "${value}"`);
37
+ return Number(value);
38
+ }, "positiveCount");
39
+ var configuredLimit = /* @__PURE__ */ __name((command, most = Number.POSITIVE_INFINITY) => {
40
+ const { resolveSettings, env } = environmentOf(command);
41
+ const { limit: _typed, ...flags } = command.optsWithGlobals();
42
+ const configured = resolveSettings?.(flags, { needsProfile: false, ...env ? { env } : {} }).limit ?? DEFAULT_CONFIG.defaults.limit;
43
+ return Math.min(configured, most);
44
+ }, "configuredLimit");
45
+ var withPaging = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")).option("--all", "every row, no paging"), "withPaging");
46
+ var window = /* @__PURE__ */ __name(({ limit, page, all }) => all ? { offset: 0 } : { limit, offset: (page - 1) * limit }, "window");
47
+ var pagingOf = /* @__PURE__ */ __name((command) => {
48
+ const environment = environmentOf(command);
49
+ const flags = command.optsWithGlobals();
50
+ if (!environment.resolveSettings)
51
+ return { limit: flags.limit ?? DEFAULT_CONFIG.defaults.limit, page: flags.page ?? 1 };
52
+ const { limit, page } = environment.resolveSettings(withAgentLevels(command, command.optsWithGlobals()), {
53
+ env: environment.env ?? process.env,
54
+ needsProfile: false,
55
+ readOnly: true
56
+ });
57
+ return { limit: limit ?? DEFAULT_CONFIG.defaults.limit, page: page ?? 1 };
58
+ }, "pagingOf");
59
+
60
+ // node_modules/.pnpm/@wirecat+cli-core@0.699.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_13ea275dd452fd1070c59d86b8d8c388/node_modules/@wirecat/cli-core/dist/cli/messenger/chat-answers.js
61
+ var defined = /* @__PURE__ */ __name((record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0)), "defined");
62
+ var chatRef = /* @__PURE__ */ __name((account, chat) => formatReference({ type: "chat", provider: account.provider, account: account.account, chat }), "chatRef");
63
+ var settingsOf = /* @__PURE__ */ __name((settings) => defined({
64
+ all_can_pin: settings.allCanPin,
65
+ only_admins_add: settings.onlyAdminsAdd,
66
+ only_admins_call: settings.onlyAdminsCall,
67
+ only_owner_edits_info: settings.onlyOwnerEditsInfo,
68
+ members_see_link: settings.membersSeeLink,
69
+ join_approval: settings.joinApproval,
70
+ only_admins_send: settings.onlyAdminsSend,
71
+ only_admins_edit_info: settings.onlyAdminsEditInfo,
72
+ disappearing_seconds: settings.disappearingSeconds
73
+ }), "settingsOf");
74
+ var chatAnswer = /* @__PURE__ */ __name((account, chat) => defined({
75
+ ref: chatRef(account, chat.id),
76
+ id: chat.id,
77
+ title: chat.title,
78
+ kind: chat.kind,
79
+ unread_count: chat.unreadCount,
80
+ unread_mentions: chat.unreadMentions,
81
+ last_message_at: chat.lastMessageAt,
82
+ participants_count: chat.participantsCount,
83
+ muted: chat.muted,
84
+ muted_until: chat.mutedUntil ?? void 0,
85
+ archived: chat.archived,
86
+ marked_unread: chat.markedUnread,
87
+ membership_state: chat.membershipState,
88
+ parent_chat_id: chat.parentChatId ?? void 0,
89
+ scope: chat.scope,
90
+ provider_metadata: chat.providerMetadata,
91
+ description: chat.description,
92
+ invite_link: chat.link,
93
+ settings: chat.settings ? settingsOf(chat.settings) : void 0,
94
+ members: chat.members?.map(memberAnswer)
95
+ }), "chatAnswer");
96
+ var memberAnswer = /* @__PURE__ */ __name((member) => {
97
+ const group = member;
98
+ return defined({
99
+ id: member.id,
100
+ name: member.name,
101
+ username: member.username,
102
+ role: group.role,
103
+ last_seen_at: group.lastSeenAt,
104
+ registered_at: group.registeredAt,
105
+ joined_at: group.joinedAt,
106
+ invited_by: group.invitedBy,
107
+ is_bot: group.isBot,
108
+ deleted: group.deleted,
109
+ flagged: group.flagged,
110
+ has_photo: group.hasPhoto,
111
+ score: group.score,
112
+ reasons: group.reasons,
113
+ check: group.check ? snakeKeys(group.check) : void 0
114
+ });
115
+ }, "memberAnswer");
116
+ var contactRef = /* @__PURE__ */ __name((provider, id) => formatReference({ type: "contact", provider, id }), "contactRef");
117
+ var contactAnswer = /* @__PURE__ */ __name((account, contact) => {
118
+ const card = contact;
119
+ return defined({
120
+ ref: contactRef(account.provider, contact.id),
121
+ id: contact.id,
122
+ name: contact.name,
123
+ username: contact.username,
124
+ alias: contact.alias,
125
+ display_name: contact.displayName,
126
+ description: contact.description,
127
+ last_messaged_at: contact.lastMessagedAt,
128
+ chats: card.chats?.map((chat) => ({
129
+ ref: chatRef(account, chat.id),
130
+ id: chat.id,
131
+ title: chat.title,
132
+ kind: chat.kind,
133
+ last_message_at: chat.lastMessageAt
134
+ })),
135
+ notes: card.notes?.map(({ id, text, revision, createdAt, updatedAt }) => ({
136
+ id,
137
+ text,
138
+ revision,
139
+ created_at: createdAt,
140
+ updated_at: updatedAt
141
+ }))
142
+ });
143
+ }, "contactAnswer");
144
+ var contactShown = /* @__PURE__ */ __name((account, card, profile) => {
145
+ const { id: _id, name: _name, bio, chats, ...facts } = profile;
146
+ const listed = new Map(card.chats.map((chat) => [chat.id, chat]));
147
+ const active = new Set(chats.map(({ id }) => id));
148
+ const shared = [
149
+ ...chats.map((chat) => ({
150
+ ref: chatRef(account, chat.id),
151
+ id: chat.id,
152
+ title: chat.title,
153
+ kind: chat.kind,
154
+ last_message_at: listed.get(chat.id)?.lastMessageAt ?? chat.lastAt,
155
+ their_messages: chat.theirMessages,
156
+ first_at: chat.firstAt,
157
+ last_at: chat.lastAt,
158
+ complete: chat.complete
159
+ })),
160
+ ...card.chats.filter(({ id }) => !active.has(id)).map((chat) => ({
161
+ ref: chatRef(account, chat.id),
162
+ id: chat.id,
163
+ title: chat.title,
164
+ kind: chat.kind,
165
+ last_message_at: chat.lastMessageAt
166
+ }))
167
+ ];
168
+ const answer = contactAnswer(account, card);
169
+ return {
170
+ ...answer,
171
+ ...snakeKeys(facts),
172
+ description: answer.description ?? bio,
173
+ chats: shared
174
+ };
175
+ }, "contactShown");
176
+ var chatEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
177
+ chat_id: chatId,
178
+ time: event.timestamp,
179
+ type: event.event,
180
+ message_id: event.messageId,
181
+ by: event.by,
182
+ people: event.people,
183
+ title: event.title
184
+ }), "chatEventAnswer");
185
+ var HISTORY_TYPES = { joined: "join", left: "leave", changed: "profile" };
186
+ var memberEventAnswer = /* @__PURE__ */ __name((chatId, event) => defined({
187
+ chat_id: chatId,
188
+ time: event.at,
189
+ type: HISTORY_TYPES[event.event],
190
+ by: event.invitedBy === void 0 ? void 0 : { id: event.invitedBy, name: null },
191
+ people: [{ id: event.id, name: event.name, username: event.username }],
192
+ before: event.before ? { name: event.before.name, username: event.before.username } : void 0
193
+ }), "memberEventAnswer");
194
+ var inviteLinkAnswer = /* @__PURE__ */ __name((link) => defined({
195
+ link: link.link,
196
+ approval: link.approval,
197
+ expires_at: link.expiresAt,
198
+ max_uses: link.maxUses,
199
+ primary: link.primary,
200
+ revoked: link.revoked,
201
+ pending_count: link.pending,
202
+ joined_count: link.joined
203
+ }), "inviteLinkAnswer");
204
+ var joinRequestAnswer = /* @__PURE__ */ __name((request) => defined({
205
+ person_id: request.person.id,
206
+ name: request.person.name,
207
+ username: request.person.username,
208
+ requested_at: request.requestedAt,
209
+ about: request.about
210
+ }), "joinRequestAnswer");
211
+ var pollVoteAnswer = /* @__PURE__ */ __name((vote) => ({
212
+ person_id: vote.person.id,
213
+ name: vote.person.name,
214
+ username: vote.person.username,
215
+ answers: vote.answers,
216
+ voted_at: vote.votedAt
217
+ }), "pollVoteAnswer");
218
+ var reactorAnswer = /* @__PURE__ */ __name((reactor) => ({
219
+ person: { id: reactor.person.id, name: reactor.person.name, username: reactor.person.username },
220
+ reaction: reactor.reaction,
221
+ reacted_at: reactor.reactedAt
222
+ }), "reactorAnswer");
223
+ var topicAnswer = /* @__PURE__ */ __name((topic) => defined({
224
+ id: topic.id,
225
+ title: topic.title,
226
+ closed: topic.closed,
227
+ pinned: topic.pinned,
228
+ hidden: topic.hidden,
229
+ unread_count: topic.unreadCount,
230
+ last_message_at: topic.lastMessageAt,
231
+ created_at: topic.createdAt,
232
+ untrusted: ["title"]
233
+ }), "topicAnswer");
234
+ var folderAnswer = /* @__PURE__ */ __name((folder) => {
235
+ const shown = "chats" in folder ? folder : void 0;
236
+ const listed = shown ? void 0 : folder;
237
+ return defined({
238
+ id: folder.id,
239
+ title: folder.title,
240
+ chat_ids: listed ? listed.chatIds : shown?.chats.map((chat) => chat.id) ?? [],
241
+ emoji: folder.emoji,
242
+ include: folder.include,
243
+ skip: folder.skip,
244
+ excluded_chat_ids: listed?.excludedChatIds ?? shown?.excluded.map((chat) => chat.id),
245
+ pinned_chat_ids: listed?.pinnedChatIds ?? shown?.pinned.map((chat) => chat.id),
246
+ chats: shown?.chats,
247
+ pinned_chats: shown?.pinned,
248
+ excluded_chats: shown?.excluded
249
+ });
250
+ }, "folderAnswer");
251
+ var lines = /* @__PURE__ */ __name((line) => (body) => (body.items ?? (body.item === void 0 ? [] : [body.item])).map((item) => `${line(item).trimEnd()}
252
+ `).join(""), "lines");
253
+ var pageOf = /* @__PURE__ */ __name(({ limit, page, all }, { items, hasMore }) => all ? { limit: Math.max(1, items.length), has_more: false, page: 1 } : { limit, has_more: hasMore, page }, "pageOf");
254
+ var wholeList = /* @__PURE__ */ __name((command, items, extra = {}) => listOf(command, { items, limit: Math.max(1, items.length), has_more: false, ...extra }), "wholeList");
255
+ var chatShown = /* @__PURE__ */ __name((account, card) => {
256
+ const listed = card.members?.length;
257
+ const short = listed !== void 0 && card.participantsCount !== null && listed < card.participantsCount;
258
+ return itemOf(chatAnswer(account, card), short ? {
259
+ missing: [
260
+ {
261
+ field: "members",
262
+ why: `${listed} listed; the chat reports ${card.participantsCount} \u2014 the list may omit your account or be partial`,
263
+ step: "chats.members"
264
+ }
265
+ ],
266
+ next: [nextStep("chats.members", { args: { chat: card.id } })]
267
+ } : {});
268
+ }, "chatShown");
269
+ var scoreFloor = /* @__PURE__ */ __name((ast) => {
270
+ const term = nativeTerms(ast, "chats members check").get("score");
271
+ if (!term)
272
+ return AUDIT_MIN_SCORE;
273
+ const upper = term.operator === "range" ? term.upper ?? "*" : term.value;
274
+ if (term.operator !== "range" || upper !== "*")
275
+ queryError("query.unsupported-operator", term.span, "score takes a lower bound: score>=3", {
276
+ command: "chats members check",
277
+ guide: LIST_QUERY_GUIDE
278
+ });
279
+ const floor = Number(term.value);
280
+ return Math.ceil(term.lower_inclusive === false ? floor + 1 : floor);
281
+ }, "scoreFloor");
282
+ var auditAnswer = /* @__PURE__ */ __name((audit) => wholeList("chats members check", audit.items.map(memberAnswer), {
283
+ ...audit.more ? { meta: { truncated: true } } : {},
284
+ ...audit.completeness && audit.completeness.state !== "complete" ? {
285
+ missing: [
286
+ {
287
+ field: "reasons",
288
+ why: "never_wrote counts only stored messages, and the store does not hold the chat whole",
289
+ ...audit.fetch ? { step: "messages.sync" } : {}
290
+ }
291
+ ],
292
+ ...audit.fetch ? { next: [nextStep("messages.sync", { args: { chat: audit.chatId } })] } : {}
293
+ } : {}
294
+ }), "auditAnswer");
295
+ var renderItem = /* @__PURE__ */ __name((command, output, value, next = []) => renderAnswer(command, output, itemOf(snakeKeys(value), { next })), "renderItem");
296
+ var withPage = /* @__PURE__ */ __name((command) => command.option("--limit <n>", "how many to show", positiveCount("--limit")).option("--page <n>", "which page, starting at 1", positiveCount("--page")), "withPage");
297
+ var documentLinkAnswer = /* @__PURE__ */ __name(({ url, documentId, title, inStore, locator, sentAt, sender }) => ({
298
+ url,
299
+ document_id: documentId,
300
+ title,
301
+ in_store: inStore,
302
+ ref: locator,
303
+ sent_at: sentAt,
304
+ sender
305
+ }), "documentLinkAnswer");
306
+ var accountAnswer = /* @__PURE__ */ __name((provider, { id, name, username, phone }) => ({
307
+ provider,
308
+ id,
309
+ name,
310
+ username,
311
+ ...phone === void 0 ? {} : { phone }
312
+ }), "accountAnswer");
313
+ var sessionAnswer = /* @__PURE__ */ __name(({ current, client, device, location, lastActiveAt, createdAt }) => ({
314
+ current,
315
+ client,
316
+ device,
317
+ location,
318
+ last_active_at: lastActiveAt,
319
+ ...createdAt === void 0 ? {} : { created_at: createdAt }
320
+ }), "sessionAnswer");
321
+
322
+ export {
323
+ positiveCount,
324
+ configuredLimit,
325
+ withPaging,
326
+ window,
327
+ pagingOf,
328
+ chatRef,
329
+ chatAnswer,
330
+ memberAnswer,
331
+ contactRef,
332
+ contactAnswer,
333
+ contactShown,
334
+ chatEventAnswer,
335
+ memberEventAnswer,
336
+ inviteLinkAnswer,
337
+ joinRequestAnswer,
338
+ pollVoteAnswer,
339
+ reactorAnswer,
340
+ topicAnswer,
341
+ folderAnswer,
342
+ lines,
343
+ pageOf,
344
+ wholeList,
345
+ chatShown,
346
+ scoreFloor,
347
+ auditAnswer,
348
+ renderItem,
349
+ withPage,
350
+ documentLinkAnswer,
351
+ accountAnswer,
352
+ sessionAnswer
353
+ };
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/runs/secrets.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.699.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_13ea275dd452fd1070c59d86b8d8c388/node_modules/@wirecat/cli-core/dist/runs/secrets.js
8
8
  var SECRET_WORDS = /* @__PURE__ */ new Set([
9
9
  "authorization",
10
10
  "cookie",
@@ -0,0 +1,52 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ changesMessenger
5
+ } from "./chunk-PHXOL5HZ.js";
6
+ import {
7
+ AUTHORITY_KEY,
8
+ BOT_API_KEY,
9
+ authorityAllowed,
10
+ botApiAllowed,
11
+ isBotApi,
12
+ keyForCommand,
13
+ levelFor,
14
+ readKeysForCommand
15
+ } from "./chunk-3TEFE6YU.js";
16
+ import {
17
+ writes
18
+ } from "./chunk-J5P5VSRG.js";
19
+ import {
20
+ __name
21
+ } from "./chunk-ZVVMGPBJ.js";
22
+
23
+ // node_modules/.pnpm/@wirecat+cli-core@0.699.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_13ea275dd452fd1070c59d86b8d8c388/node_modules/@wirecat/cli-core/dist/cli/command-availability.js
24
+ var commandAvailability = /* @__PURE__ */ __name((info, levels, keyOf, authority, readOnly = false, mcp = true, declared, fetches) => {
25
+ const declaredKey = declared?.keyOf(info.path);
26
+ const key = declared ? declaredKey : keyOf?.(info.path) ?? keyForCommand(info.path);
27
+ const { level } = key ? levelFor(levels, key, declared?.defaults) : { level: "allow" };
28
+ const judged = { ...key ? { permission: key } : {}, level };
29
+ const blocked = /* @__PURE__ */ __name((reason, permission) => ({
30
+ available: false,
31
+ reason,
32
+ ...judged,
33
+ ...permission && permission !== judged.permission ? { permission, level: levelFor(levels, permission).level } : {}
34
+ }), "blocked");
35
+ const declaredChange = Boolean(declaredKey) && (info.effects === void 0 || info.effects.remote === "write");
36
+ if (readOnly && (changesMessenger(info) || declaredChange || authority?.(info.path)))
37
+ return blocked("the read-only lock blocks this change");
38
+ if (mcp && authority?.(info.path) && !authorityAllowed(levels))
39
+ return blocked(`the profile keeps ${AUTHORITY_KEY} off`, AUTHORITY_KEY);
40
+ if (mcp && isBotApi(info.path) && !botApiAllowed(levels))
41
+ return blocked(`the profile requires ${BOT_API_KEY}: allow`, BOT_API_KEY);
42
+ if (level === "deny")
43
+ return blocked(`the profile denies ${key}`);
44
+ if (level === "readonly" && writes(info.effects) && fetches?.(info.path) !== true)
45
+ return blocked(`${key} is readonly in this profile`);
46
+ const denied = (declared ? [] : readKeysForCommand(info.path)).find((read) => levelFor(levels, read).level === "deny");
47
+ return denied ? blocked(`the profile denies ${denied}`, denied) : { available: true, ...judged };
48
+ }, "commandAvailability");
49
+
50
+ export {
51
+ commandAvailability
52
+ };
@@ -2,15 +2,15 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  PRAGMAS
5
- } from "./chunk-DFCHHR5M.js";
5
+ } from "./chunk-JUKAIXKY.js";
6
6
  import {
7
7
  CliError
8
- } from "./chunk-DB2XKHI4.js";
8
+ } from "./chunk-BUGROVF3.js";
9
9
  import {
10
10
  __name
11
11
  } from "./chunk-ZVVMGPBJ.js";
12
12
 
13
- // node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/store/sqlite-warning.js
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.699.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_13ea275dd452fd1070c59d86b8d8c388/node_modules/@wirecat/cli-core/dist/store/sqlite-warning.js
14
14
  var SQLITE_WARNING = "SQLite is an experimental feature";
15
15
  var quieted = /* @__PURE__ */ new WeakSet();
16
16
  var quietSqliteWarning = /* @__PURE__ */ __name((host = process) => {
@@ -31,7 +31,7 @@ var isSqliteWarning = /* @__PURE__ */ __name((warning, options) => {
31
31
  return name === "ExperimentalWarning" && message.startsWith(SQLITE_WARNING);
32
32
  }, "isSqliteWarning");
33
33
 
34
- // node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/store/open.js
34
+ // node_modules/.pnpm/@wirecat+cli-core@0.699.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_13ea275dd452fd1070c59d86b8d8c388/node_modules/@wirecat/cli-core/dist/store/open.js
35
35
  var openCache = /* @__PURE__ */ __name(async (path) => {
36
36
  const database = await openFile(path);
37
37
  try {
@@ -44,12 +44,12 @@ var openCache = /* @__PURE__ */ __name(async (path) => {
44
44
  }, "openCache");
45
45
  var openFile = /* @__PURE__ */ __name((path) => "Bun" in globalThis ? openUnderBun(path) : openUnderNode(path), "openFile");
46
46
  var openUnderBun = /* @__PURE__ */ __name(async (path) => {
47
- const { openWithBunSqlite } = await import("./bun-sqlite-IX3XYA5F.js");
47
+ const { openWithBunSqlite } = await import("./bun-sqlite-AGXGSF6D.js");
48
48
  return await openWithBunSqlite(path);
49
49
  }, "openUnderBun");
50
50
  var openUnderNode = /* @__PURE__ */ __name(async (path) => {
51
51
  quietSqliteWarning();
52
- const { openWithNodeSqlite } = await import("./node-sqlite-P3O7XN7Q.js");
52
+ const { openWithNodeSqlite } = await import("./node-sqlite-RKYSRKEB.js");
53
53
  return openWithNodeSqlite(path);
54
54
  }, "openUnderNode");
55
55
  var runtime = /* @__PURE__ */ __name(() => {
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.699.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_13ea275dd452fd1070c59d86b8d8c388/node_modules/@wirecat/cli-core/dist/mcp/bot/instructions.js
8
8
  var botInstructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => [
9
9
  `The owner's ${name} bot "${profile}", through the official Bot API \u2014 not the owner's personal account. What it writes, people see as the bot.`,
10
10
  "Use these tools to read the chats this bot is in, find a message or a person, and \u2014 when the profile allows \u2014 write as the bot.",
@@ -0,0 +1,195 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ OBJECTS,
5
+ SERVICE,
6
+ segment
7
+ } from "./chunk-CYADK744.js";
8
+ import {
9
+ foldFieldName,
10
+ values_exports
11
+ } from "./chunk-JG7YMHNB.js";
12
+ import {
13
+ CliError,
14
+ isCliError
15
+ } from "./chunk-BUGROVF3.js";
16
+ import {
17
+ __name
18
+ } from "./chunk-ZVVMGPBJ.js";
19
+
20
+ // dist/crm/writer.js
21
+ var HUBSPOT_WRITES = {
22
+ kinds: ["deal", "person", "organization"],
23
+ verbs: ["create", "update", "move", "close", "remove"],
24
+ idempotent: false
25
+ };
26
+ var OWN = {
27
+ deal: new Set(["dealname", "pipeline", "dealstage", "amount", "deal_currency_code", "closedate", "hubspot_owner_id"].map(foldFieldName)),
28
+ person: new Set(["firstname", "lastname", "email", "phone", "mobilephone", "jobtitle", "hubspot_owner_id"].map(foldFieldName)),
29
+ organization: new Set(["name", "phone", "hubspot_owner_id"].map(foldFieldName))
30
+ };
31
+ var refused = /* @__PURE__ */ __name((message, param) => new CliError("validation_error", message, { reason: "crm.record-field", sent: false, ...param ? { param } : {} }), "refused");
32
+ var ID = /^\d{1,20}$/;
33
+ var idOf = /* @__PURE__ */ __name((value, param) => {
34
+ if (!ID.test(value))
35
+ throw refused(`${param} takes ${SERVICE}'s numeric id`, param);
36
+ return value;
37
+ }, "idOf");
38
+ var cleared = /* @__PURE__ */ __name((value) => value ?? "", "cleared");
39
+ var customOf = /* @__PURE__ */ __name((kind, custom) => {
40
+ const properties = {};
41
+ for (const [code, value] of Object.entries(custom ?? {})) {
42
+ if (OWN[kind].has(foldFieldName(code)))
43
+ throw refused(`${code} is one of ${SERVICE}'s own properties; set it with its own option, not --field`, "--field");
44
+ properties[code] = Array.isArray(value) ? value.join(";") : cleared(value);
45
+ }
46
+ return properties;
47
+ }, "customOf");
48
+ var listOf = /* @__PURE__ */ __name((values) => values?.map((one) => one.trim()).filter(Boolean), "listOf");
49
+ var dealOf = /* @__PURE__ */ __name((given) => {
50
+ if (given.people !== void 0 || given.organization !== void 0)
51
+ throw refused(`set a deal's contacts and company with ${SERVICE}'s associations, through api`);
52
+ const properties = customOf("deal", given.custom);
53
+ if (given.title !== void 0)
54
+ properties.dealname = given.title;
55
+ if (given.pipeline !== void 0)
56
+ properties.pipeline = given.pipeline;
57
+ if (given.stage !== void 0)
58
+ properties.dealstage = given.stage;
59
+ if (given.amount !== void 0)
60
+ properties.amount = cleared(given.amount);
61
+ if (given.currency !== void 0)
62
+ properties.deal_currency_code = cleared(given.currency);
63
+ if (given.closeDate !== void 0)
64
+ properties.closedate = given.closeDate ? `${given.closeDate}T12:00:00.000Z` : "";
65
+ if (given.owner !== void 0)
66
+ properties.hubspot_owner_id = given.owner === null ? "" : idOf(given.owner, "--owner");
67
+ return properties;
68
+ }, "dealOf");
69
+ var personOf = /* @__PURE__ */ __name((given) => {
70
+ const properties = customOf("person", given.custom);
71
+ if (given.name !== void 0 && given.firstName === void 0 && given.lastName === void 0) {
72
+ const [first, ...rest] = given.name.trim().split(/\s+/);
73
+ properties.firstname = first ?? "";
74
+ properties.lastname = rest.join(" ");
75
+ }
76
+ if (given.firstName !== void 0)
77
+ properties.firstname = cleared(given.firstName);
78
+ if (given.lastName !== void 0)
79
+ properties.lastname = cleared(given.lastName);
80
+ if (given.position !== void 0)
81
+ properties.jobtitle = cleared(given.position);
82
+ const emails = listOf(given.emails);
83
+ if (emails) {
84
+ if (emails.length > 1)
85
+ throw refused(`${SERVICE} keeps one e-mail per contact here; give one --email`, "--email");
86
+ properties.email = emails[0] ?? "";
87
+ }
88
+ const phones = listOf(given.phones);
89
+ if (phones) {
90
+ if (phones.length > 2)
91
+ throw refused(`${SERVICE} keeps two numbers per contact, phone and mobile; give at most two --phone`, "--phone");
92
+ properties.phone = phones[0] ?? "";
93
+ properties.mobilephone = phones[1] ?? "";
94
+ }
95
+ if (given.owner !== void 0)
96
+ properties.hubspot_owner_id = given.owner === null ? "" : idOf(given.owner, "--owner");
97
+ return properties;
98
+ }, "personOf");
99
+ var organizationOf = /* @__PURE__ */ __name((given) => {
100
+ const properties = customOf("organization", given.custom);
101
+ if (given.name !== void 0)
102
+ properties.name = given.name;
103
+ if (listOf(given.emails)?.length)
104
+ throw refused(`a ${SERVICE} company has no e-mail property; set the contacts' e-mails instead`, "--email");
105
+ const phones = listOf(given.phones);
106
+ if (phones) {
107
+ if (phones.length > 1)
108
+ throw refused(`a ${SERVICE} company keeps one number; give one --phone`, "--phone");
109
+ properties.phone = phones[0] ?? "";
110
+ }
111
+ if (given.owner !== void 0)
112
+ properties.hubspot_owner_id = given.owner === null ? "" : idOf(given.owner, "--owner");
113
+ return properties;
114
+ }, "organizationOf");
115
+ var propertiesFor = /* @__PURE__ */ __name((kind, given) => {
116
+ if (kind === "deal")
117
+ return dealOf(given);
118
+ if (kind === "person")
119
+ return personOf(given);
120
+ if (kind === "organization")
121
+ return organizationOf(given);
122
+ throw new CliError("validation_error", `${SERVICE} leads are written through api leads-create and leads-update`, {
123
+ reason: "crm.write-unsupported",
124
+ sent: false
125
+ });
126
+ }, "propertiesFor");
127
+ var pathOf = /* @__PURE__ */ __name((kind, externalId) => `/crm/objects/2026-03/${OBJECTS[kind].path}${externalId === void 0 ? "" : `/${segment(idOf(externalId, `<${kind}>`))}`}`, "pathOf");
128
+ var hubspotCrmWriter = /* @__PURE__ */ __name((hub, source) => {
129
+ const readBack = /* @__PURE__ */ __name(async (kind, externalId, options) => {
130
+ try {
131
+ const found = await source().record(kind, externalId);
132
+ if (!found)
133
+ throw new CliError("not_found", `${SERVICE} has no ${kind} ${externalId}`);
134
+ return found;
135
+ } catch (error) {
136
+ throw new CliError("invalid_response", `${SERVICE} made the change to ${kind} ${externalId}, but reading it back failed${isCliError(error) ? ` (${error.code})` : ""}; run sync to store it \u2014 do not write it again`, { operation_id: options.operationId, external_id: externalId, sent: true });
137
+ }
138
+ }, "readBack");
139
+ const update = /* @__PURE__ */ __name(async (kind, externalId, properties, options) => {
140
+ if (Object.keys(properties).length === 0)
141
+ throw refused("nothing to change: name a field");
142
+ await hub().patch(pathOf(kind, externalId), { properties });
143
+ return readBack(kind, externalId, options);
144
+ }, "update");
145
+ const closingStage = /* @__PURE__ */ __name(async (externalId, outcome) => {
146
+ const deal = await source().record("deal", externalId);
147
+ if (!deal)
148
+ throw new CliError("not_found", `${SERVICE} has no deal ${externalId}`, { sent: false });
149
+ const pipeline = (await source().pipelines("deal")).find((one) => one.externalId === deal.pipeline);
150
+ const stage = pipeline?.stages.find((one) => one.outcome === outcome);
151
+ if (!stage)
152
+ throw refused(`the deal's pipeline ${deal.pipeline} has no closed ${outcome} stage in ${SERVICE}`, "<outcome>");
153
+ return stage.externalId;
154
+ }, "closingStage");
155
+ return {
156
+ provider: "hubspot",
157
+ capabilities: HUBSPOT_WRITES,
158
+ async create(kind, draft, options) {
159
+ const properties = propertiesFor(kind, draft);
160
+ const answer = await hub().post(pathOf(kind), { properties, associations: [] });
161
+ const externalId = values_exports.id(values_exports.fieldOf(answer, "id"));
162
+ if (externalId === null)
163
+ throw new CliError("invalid_response", `${SERVICE} answered the new ${kind} without its id; run sync first`, {
164
+ operation_id: options.operationId,
165
+ sent: true
166
+ });
167
+ return readBack(kind, externalId, options);
168
+ },
169
+ async update(kind, externalId, patch, options) {
170
+ return update(kind, externalId, propertiesFor(kind, patch), options);
171
+ },
172
+ async move(kind, externalId, stage, options) {
173
+ return update(kind, externalId, propertiesFor(kind, { stage }), options);
174
+ },
175
+ async close(kind, externalId, outcome, options) {
176
+ const properties = propertiesFor(kind, { stage: await closingStage(externalId, outcome) });
177
+ if (options.reason !== void 0)
178
+ properties[`closed_${outcome}_reason`] = options.reason;
179
+ return update(kind, externalId, properties, options);
180
+ },
181
+ async remove(kind, externalId) {
182
+ if (kind !== "deal")
183
+ throw new CliError("validation_error", `${SERVICE} ${kind}s are deleted through api`, {
184
+ reason: "crm.write-unsupported",
185
+ sent: false
186
+ });
187
+ await hub().delete(pathOf(kind, externalId));
188
+ }
189
+ };
190
+ }, "hubspotCrmWriter");
191
+
192
+ export {
193
+ HUBSPOT_WRITES,
194
+ hubspotCrmWriter
195
+ };