@wirecat/amo-cli 0.6.0 → 0.8.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 (282) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +2 -2
  3. package/contracts/wirecat.json +14 -0
  4. package/dist/amo/button.js +1 -1
  5. package/dist/amo/json.js +1 -1
  6. package/dist/amo/oauth.js +1 -2
  7. package/dist/amo/transport.js +1 -2
  8. package/dist/api-keys.js +1 -1
  9. package/dist/bin/amo.js +11 -11
  10. package/dist/bundle/amo.js +5 -183
  11. package/dist/bundle/{chunk-FYOPPKAN.js → chunk-3HWD4BKU.js} +4 -6
  12. package/dist/bundle/{chunk-GOCMJBEE.js → chunk-4EXURQQQ.js} +21 -19
  13. package/dist/bundle/{chunk-SWCJM3YD.js → chunk-6ZPPFFIH.js} +3 -3
  14. package/dist/bundle/chunk-AEWYRB6F.js +8 -0
  15. package/dist/bundle/{chunk-RNWUCAJJ.js → chunk-PVVSHDMQ.js} +7 -15
  16. package/dist/bundle/chunk-SV4CS5TA.js +76 -0
  17. package/dist/bundle/program-RA6QICVH.js +2352 -0
  18. package/dist/bundle/{instructions-4H7UREH2.js → source-C65ZJUTW.js} +5 -6
  19. package/dist/bundle/store-35UXUNVG.js +12 -0
  20. package/dist/bundle/writer-I7GBI3VE.js +12 -0
  21. package/dist/commands/account.js +1 -1
  22. package/dist/commands/api.js +1 -3
  23. package/dist/commands/crm-shared.js +2 -3
  24. package/dist/commands/schedule.js +1 -1
  25. package/dist/commands/session.js +1 -3
  26. package/dist/commands/write.js +1 -2
  27. package/dist/config.js +1 -2
  28. package/dist/context.js +1 -2
  29. package/dist/crm/activities.js +1 -1
  30. package/dist/crm/records.js +1 -1
  31. package/dist/crm/source.js +1 -1
  32. package/dist/crm/writer.js +1 -1
  33. package/dist/identity.js +4 -0
  34. package/dist/program.js +1 -2
  35. package/dist/setup/flow.js +1 -1
  36. package/dist/store.js +1 -1
  37. package/dist/version.js +1 -1
  38. package/dist/whoami.js +1 -1
  39. package/package.json +3 -3
  40. package/scenarios/first-sync.md +13 -11
  41. package/scenarios/keep-in-sync.md +7 -6
  42. package/scenarios/safe-agent-writes.md +10 -9
  43. package/dist/amo/account.d.ts +0 -18
  44. package/dist/amo/account.d.ts.map +0 -1
  45. package/dist/amo/account.js.map +0 -1
  46. package/dist/amo/allow-list.d.ts +0 -31
  47. package/dist/amo/allow-list.d.ts.map +0 -1
  48. package/dist/amo/allow-list.js.map +0 -1
  49. package/dist/amo/button.d.ts +0 -53
  50. package/dist/amo/button.d.ts.map +0 -1
  51. package/dist/amo/button.js.map +0 -1
  52. package/dist/amo/errors.d.ts +0 -12
  53. package/dist/amo/errors.d.ts.map +0 -1
  54. package/dist/amo/errors.js.map +0 -1
  55. package/dist/amo/json.d.ts +0 -3
  56. package/dist/amo/json.d.ts.map +0 -1
  57. package/dist/amo/json.js.map +0 -1
  58. package/dist/amo/oauth.d.ts +0 -64
  59. package/dist/amo/oauth.d.ts.map +0 -1
  60. package/dist/amo/oauth.js.map +0 -1
  61. package/dist/amo/operation.d.ts +0 -45
  62. package/dist/amo/operation.d.ts.map +0 -1
  63. package/dist/amo/operation.js.map +0 -1
  64. package/dist/amo/operations.d.ts +0 -3
  65. package/dist/amo/operations.d.ts.map +0 -1
  66. package/dist/amo/operations.js.map +0 -1
  67. package/dist/amo/routes.d.ts +0 -67
  68. package/dist/amo/routes.d.ts.map +0 -1
  69. package/dist/amo/routes.js.map +0 -1
  70. package/dist/amo/transport.d.ts +0 -62
  71. package/dist/amo/transport.d.ts.map +0 -1
  72. package/dist/amo/transport.js.map +0 -1
  73. package/dist/api-keys.d.ts +0 -47
  74. package/dist/api-keys.d.ts.map +0 -1
  75. package/dist/api-keys.js.map +0 -1
  76. package/dist/bin/amo.d.ts +0 -3
  77. package/dist/bin/amo.d.ts.map +0 -1
  78. package/dist/bin/amo.js.map +0 -1
  79. package/dist/bundle/agent-VVACEKSX.js +0 -42
  80. package/dist/bundle/all-profiles-QNUKL4NA.js +0 -320
  81. package/dist/bundle/anthropic-PQN6MNP7.js +0 -90
  82. package/dist/bundle/app-server-Q2QEA7GP.js +0 -258
  83. package/dist/bundle/areas-27FRPBF3.js +0 -71
  84. package/dist/bundle/bun-F4M4KCNA.js +0 -169
  85. package/dist/bundle/bun-sqlite-P5IDBDVR.js +0 -75
  86. package/dist/bundle/chunk-22KAQPX7.js +0 -58
  87. package/dist/bundle/chunk-2JGNMZ55.js +0 -338
  88. package/dist/bundle/chunk-2VDHC7QO.js +0 -288
  89. package/dist/bundle/chunk-34ZOMVUK.js +0 -185
  90. package/dist/bundle/chunk-3J3EDSXF.js +0 -1939
  91. package/dist/bundle/chunk-3TYER5IK.js +0 -80
  92. package/dist/bundle/chunk-5NGLCDYQ.js +0 -106
  93. package/dist/bundle/chunk-5SQTHOBI.js +0 -12313
  94. package/dist/bundle/chunk-6GE36KUE.js +0 -360
  95. package/dist/bundle/chunk-6GZKY3HV.js +0 -3752
  96. package/dist/bundle/chunk-6OV2TRGF.js +0 -362
  97. package/dist/bundle/chunk-7CPIZFOE.js +0 -460
  98. package/dist/bundle/chunk-A5K2NU3K.js +0 -37780
  99. package/dist/bundle/chunk-ADLS6FVG.js +0 -24600
  100. package/dist/bundle/chunk-AEC4H5WZ.js +0 -259
  101. package/dist/bundle/chunk-APBEDWOE.js +0 -1718
  102. package/dist/bundle/chunk-AQ5RIOUE.js +0 -633
  103. package/dist/bundle/chunk-B7L5MSRP.js +0 -136
  104. package/dist/bundle/chunk-C7JPYWYQ.js +0 -77
  105. package/dist/bundle/chunk-D72URWJE.js +0 -532
  106. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  107. package/dist/bundle/chunk-DIZEHPS6.js +0 -1347
  108. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  109. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  110. package/dist/bundle/chunk-DUPCDJ3W.js +0 -357
  111. package/dist/bundle/chunk-DWT24UVR.js +0 -388
  112. package/dist/bundle/chunk-DXWJORSY.js +0 -1703
  113. package/dist/bundle/chunk-DY3PLWIH.js +0 -332
  114. package/dist/bundle/chunk-DYWHAJRK.js +0 -1259
  115. package/dist/bundle/chunk-EH6ZEJGT.js +0 -932
  116. package/dist/bundle/chunk-EXRM3ML4.js +0 -76
  117. package/dist/bundle/chunk-FFER7KJI.js +0 -407
  118. package/dist/bundle/chunk-FIP2DG7W.js +0 -64
  119. package/dist/bundle/chunk-FTH6WGYO.js +0 -24
  120. package/dist/bundle/chunk-FWRLGIF6.js +0 -5304
  121. package/dist/bundle/chunk-G3N2RHGF.js +0 -738
  122. package/dist/bundle/chunk-G46PNDWL.js +0 -58
  123. package/dist/bundle/chunk-G6NY7LFB.js +0 -230
  124. package/dist/bundle/chunk-GRGCZSES.js +0 -1007
  125. package/dist/bundle/chunk-GVSKLZRD.js +0 -30
  126. package/dist/bundle/chunk-GZ7WBU5Y.js +0 -18
  127. package/dist/bundle/chunk-HN2LCLGT.js +0 -1068
  128. package/dist/bundle/chunk-HO4JGD4Q.js +0 -16
  129. package/dist/bundle/chunk-HOF7GQWW.js +0 -142
  130. package/dist/bundle/chunk-HUAHLO6N.js +0 -29
  131. package/dist/bundle/chunk-IDCZ4LWS.js +0 -150
  132. package/dist/bundle/chunk-IN3VL7UU.js +0 -560
  133. package/dist/bundle/chunk-ISQ23VKV.js +0 -123
  134. package/dist/bundle/chunk-JVBCQHCS.js +0 -80
  135. package/dist/bundle/chunk-K5W7YEHB.js +0 -9541
  136. package/dist/bundle/chunk-KAFSS35C.js +0 -193
  137. package/dist/bundle/chunk-KLRCTMES.js +0 -100
  138. package/dist/bundle/chunk-KYRYD4CR.js +0 -38
  139. package/dist/bundle/chunk-LBZSURLL.js +0 -798
  140. package/dist/bundle/chunk-LC7ZD2RW.js +0 -92
  141. package/dist/bundle/chunk-LH6FJYMO.js +0 -334
  142. package/dist/bundle/chunk-LJKINNWC.js +0 -209
  143. package/dist/bundle/chunk-M36XP74N.js +0 -86
  144. package/dist/bundle/chunk-MNPGZCKE.js +0 -361
  145. package/dist/bundle/chunk-MRPMORLH.js +0 -353
  146. package/dist/bundle/chunk-NNREILWP.js +0 -189
  147. package/dist/bundle/chunk-NSOY4FMN.js +0 -159
  148. package/dist/bundle/chunk-OEEWVKJX.js +0 -53
  149. package/dist/bundle/chunk-OGJFDKDL.js +0 -161
  150. package/dist/bundle/chunk-PATZAYFZ.js +0 -453
  151. package/dist/bundle/chunk-PCR6GFNP.js +0 -1171
  152. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  153. package/dist/bundle/chunk-Q4MH2O5E.js +0 -108
  154. package/dist/bundle/chunk-QFOP3KUP.js +0 -2603
  155. package/dist/bundle/chunk-QQRJEWKB.js +0 -1197
  156. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  157. package/dist/bundle/chunk-SDVUGWD7.js +0 -614
  158. package/dist/bundle/chunk-SEFE6PGL.js +0 -218
  159. package/dist/bundle/chunk-SYRDEMQE.js +0 -68141
  160. package/dist/bundle/chunk-SYYQZDHJ.js +0 -95
  161. package/dist/bundle/chunk-T3W4V4A6.js +0 -63
  162. package/dist/bundle/chunk-TCT5D2X2.js +0 -6848
  163. package/dist/bundle/chunk-TES7MB6I.js +0 -82
  164. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  165. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  166. package/dist/bundle/chunk-U6XPWCWM.js +0 -133
  167. package/dist/bundle/chunk-UFKC7TIX.js +0 -28404
  168. package/dist/bundle/chunk-UNWF3TH5.js +0 -274
  169. package/dist/bundle/chunk-W3BOR6AT.js +0 -2333
  170. package/dist/bundle/chunk-WIHN3ELW.js +0 -2793
  171. package/dist/bundle/chunk-X76RS6JO.js +0 -1043
  172. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  173. package/dist/bundle/chunk-YF3S26TS.js +0 -4172
  174. package/dist/bundle/chunk-ZCQ4H7CA.js +0 -54
  175. package/dist/bundle/chunk-ZOZV32IR.js +0 -170
  176. package/dist/bundle/chunk-ZTKHXDEU.js +0 -52
  177. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  178. package/dist/bundle/cli-EAD3WZLR.js +0 -1254
  179. package/dist/bundle/command-contract-SMEJ2ICG.js +0 -40
  180. package/dist/bundle/command-server-entry-YTZP6I4T.js +0 -169
  181. package/dist/bundle/decode-57BE5OBT.js +0 -296
  182. package/dist/bundle/dispatch-56FECRCU.js +0 -411
  183. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  184. package/dist/bundle/dist-T54K3FJV.js +0 -7577
  185. package/dist/bundle/echarts-QMAA7HH5.js +0 -42501
  186. package/dist/bundle/embed-NFGFYUO4.js +0 -37
  187. package/dist/bundle/embedder-SRBOJMXX.js +0 -110
  188. package/dist/bundle/failure-WDSX6H3B.js +0 -24
  189. package/dist/bundle/first-run-HWRUL2GR.js +0 -28
  190. package/dist/bundle/first-screen-ATN4D3FQ.js +0 -41
  191. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  192. package/dist/bundle/meeting-combined-BGDEHCWY.js +0 -26
  193. package/dist/bundle/meeting-model-WWGVRXPL.js +0 -24
  194. package/dist/bundle/meeting-semantic-ZQ47BL2Z.js +0 -21
  195. package/dist/bundle/node-P3PUHKYH.js +0 -176
  196. package/dist/bundle/node-P4E63KXA.js +0 -2340
  197. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  198. package/dist/bundle/node-sqlite-JOTSNH3P.js +0 -73
  199. package/dist/bundle/oauth-XPSAL6VO.js +0 -19
  200. package/dist/bundle/open-PO52FVA5.js +0 -22
  201. package/dist/bundle/openai-WITYLMY5.js +0 -237
  202. package/dist/bundle/process-AFIXYXWL.js +0 -91
  203. package/dist/bundle/program-JODTZNBZ.js +0 -4920
  204. package/dist/bundle/prompt-XORLAXHY.js +0 -16
  205. package/dist/bundle/recognize-JKMZHDYS.js +0 -25
  206. package/dist/bundle/remote-3IMEJTEH.js +0 -30
  207. package/dist/bundle/rerank-3F2E6NNN.js +0 -51
  208. package/dist/bundle/serve-6BWU3NMB.js +0 -198
  209. package/dist/bundle/server-GPSB5WFG.js +0 -220
  210. package/dist/bundle/server-HMCC64ZU.js +0 -88
  211. package/dist/bundle/source-E72OS27D.js +0 -47
  212. package/dist/bundle/sqlite-runtime-YHYQDUXE.js +0 -19
  213. package/dist/bundle/state-R7W4U6T4.js +0 -35
  214. package/dist/bundle/store-HTVRL7FB.js +0 -312
  215. package/dist/bundle/store-IWW6U6QN.js +0 -34
  216. package/dist/bundle/store-TBZ3ZS6H.js +0 -186
  217. package/dist/bundle/store-maintenance-command-CJM2VLMW.js +0 -75
  218. package/dist/bundle/surface-5GBWNYBE.js +0 -74
  219. package/dist/bundle/writer-TW2Q55VJ.js +0 -49
  220. package/dist/commands/account.d.ts +0 -4
  221. package/dist/commands/account.d.ts.map +0 -1
  222. package/dist/commands/account.js.map +0 -1
  223. package/dist/commands/api.d.ts +0 -3
  224. package/dist/commands/api.d.ts.map +0 -1
  225. package/dist/commands/api.js.map +0 -1
  226. package/dist/commands/crm-shared.d.ts +0 -8
  227. package/dist/commands/crm-shared.d.ts.map +0 -1
  228. package/dist/commands/crm-shared.js.map +0 -1
  229. package/dist/commands/schedule.d.ts +0 -3
  230. package/dist/commands/schedule.d.ts.map +0 -1
  231. package/dist/commands/schedule.js.map +0 -1
  232. package/dist/commands/session.d.ts +0 -35
  233. package/dist/commands/session.d.ts.map +0 -1
  234. package/dist/commands/session.js.map +0 -1
  235. package/dist/commands/write.d.ts +0 -14
  236. package/dist/commands/write.d.ts.map +0 -1
  237. package/dist/commands/write.js.map +0 -1
  238. package/dist/config.d.ts +0 -4
  239. package/dist/config.d.ts.map +0 -1
  240. package/dist/config.js.map +0 -1
  241. package/dist/context.d.ts +0 -62
  242. package/dist/context.d.ts.map +0 -1
  243. package/dist/context.js.map +0 -1
  244. package/dist/crm/activities.d.ts +0 -32
  245. package/dist/crm/activities.d.ts.map +0 -1
  246. package/dist/crm/activities.js.map +0 -1
  247. package/dist/crm/records.d.ts +0 -20
  248. package/dist/crm/records.d.ts.map +0 -1
  249. package/dist/crm/records.js.map +0 -1
  250. package/dist/crm/source.d.ts +0 -41
  251. package/dist/crm/source.d.ts.map +0 -1
  252. package/dist/crm/source.js.map +0 -1
  253. package/dist/crm/writer.d.ts +0 -14
  254. package/dist/crm/writer.d.ts.map +0 -1
  255. package/dist/crm/writer.js.map +0 -1
  256. package/dist/identity.d.ts +0 -7
  257. package/dist/identity.d.ts.map +0 -1
  258. package/dist/identity.js.map +0 -1
  259. package/dist/index.d.ts +0 -3
  260. package/dist/index.d.ts.map +0 -1
  261. package/dist/index.js.map +0 -1
  262. package/dist/program.d.ts +0 -6
  263. package/dist/program.d.ts.map +0 -1
  264. package/dist/program.js.map +0 -1
  265. package/dist/reasons.d.ts +0 -10
  266. package/dist/reasons.d.ts.map +0 -1
  267. package/dist/reasons.js.map +0 -1
  268. package/dist/setup/flow.d.ts +0 -2
  269. package/dist/setup/flow.d.ts.map +0 -1
  270. package/dist/setup/flow.js.map +0 -1
  271. package/dist/store.d.ts +0 -15
  272. package/dist/store.d.ts.map +0 -1
  273. package/dist/store.js.map +0 -1
  274. package/dist/version.d.ts +0 -2
  275. package/dist/version.d.ts.map +0 -1
  276. package/dist/version.js.map +0 -1
  277. package/dist/wcat.d.ts +0 -3
  278. package/dist/wcat.d.ts.map +0 -1
  279. package/dist/wcat.js.map +0 -1
  280. package/dist/whoami.d.ts +0 -24
  281. package/dist/whoami.d.ts.map +0 -1
  282. package/dist/whoami.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  Notable changes to `@wirecat/amo-cli`. One section per version, newest first.
4
4
 
5
+ ## 0.8.0 — 30.11.2026
6
+
7
+ ### Fixed
8
+
9
+ - **AI agents get shorter answers from amo over MCP.** `amo_tools_search` returns at most 5 matches, with full
10
+ arguments for the first 2 only; an exact name with `schema: true` gives a command's whole schema. Records an agent
11
+ reads leave out empty fields. The terminal, `--json` and `--full` answers stay the same. Built on
12
+ @wirecat/cli-core 3.2.0.
13
+
14
+ ## 0.7.0 — 28.11.2026
15
+
16
+ ### Added
17
+
18
+ - **WireCat Desktop reads amo's sign-in and MCP port from amo itself.** The manifest (`amo --wcat-describe`) now names
19
+ the MCP server's port, 8761, and the sign-in Desktop runs: a long-lived token, typed on stdin. Built on
20
+ `@wirecat/cli-base` 1.2.0.
21
+
22
+ ### Fixed
23
+
24
+ - `amo guide` puts the example profile `work` in every step, so a step runs as you copy it. The first-sync scenario
25
+ names the one-click sign-in beside the token.
26
+ - The guides say that an amoCRM administrator signs in with one click, and that the list of colleagues whose deals a
27
+ sync copies replaces your own.
28
+ - amo's package is smaller: it no longer carries its own copy of cli-core. Built on @wirecat/cli-core 3.0.0 and
29
+ @wirecat/cli-base 2.1.1. Needed for the WireCat store version 79 (memo became wcat).
30
+
5
31
  ## 0.6.0 — 27.11.2026
6
32
 
7
33
  ### Changed — may break callers
package/README.md CHANGED
@@ -89,7 +89,7 @@ amo work deals list status:open
89
89
  and none is ever assumed. `amo work setup` asks for the account's address. An administrator of an amoCRM account then
90
90
  clicks **Sign in with amoCRM** and allows access in the browser. Otherwise it shows each click to make a private
91
91
  integration and its long-lived token, checks them against the account and keeps the token in the system keyring. A
92
- sync copies the deals assigned to the user the token belongs to. To copy a colleague's too, see
92
+ sync copies the deals assigned to the user who signed in. To copy a colleague's too, see
93
93
  [which deals sync copies](https://github.com/WireCatLabs/amo-cli/blob/main/docs/configuration.md#which-deals-sync-copies).
94
94
 
95
95
  You need Node.js 22.16 or a later 22.x, or Node.js 24 or later. `amo doctor` needs no network and shows what is set
@@ -219,7 +219,7 @@ More: [permissions](https://github.com/WireCatLabs/amo-cli/blob/main/docs/permis
219
219
  - `amo` is tested against a fake account built from the Kommo API reference, and each release passes a check on a
220
220
  live test account: it syncs, reads, and creates, moves and closes a deal.
221
221
  - amoCRM's API v4 has no call that deletes a deal, so there is no `deals delete`. Close the deal as lost instead.
222
- - Files on deals and contacts are not supported yet.
222
+ - Files on deals and contacts are not available.
223
223
  - Without amoCRM's paid API filter add-on, `sync` reads a contact or company one request at a time, and a live list
224
224
  of contacts or companies cannot be narrowed by owner or time. A search by words still works.
225
225
  - The Chats API, Drive and amoCRM's AI agent API live on other hosts, and `amo` does not reach them.
@@ -1260,6 +1260,19 @@
1260
1260
  "signIn": {
1261
1261
  "gives": "Lets your agent read and change the account's CRM with the rights of the administrator who made the token, or of the user who signed in through your own integration.",
1262
1262
  "asks": "The account's address and a long-lived token from a private integration's Keys and scopes tab, or that integration's ID and secret key.",
1263
+ "methods": [
1264
+ {
1265
+ "id": "token",
1266
+ "label": "Long-lived token",
1267
+ "words": [
1268
+ "{profile}",
1269
+ "session",
1270
+ "start",
1271
+ "--json"
1272
+ ],
1273
+ "stdin": true
1274
+ }
1275
+ ],
1263
1276
  "setupFrom": "0.0.0"
1264
1277
  },
1265
1278
  "skill": {
@@ -1284,6 +1297,7 @@
1284
1297
  ]
1285
1298
  },
1286
1299
  "mcpServer": {
1300
+ "port": 8761,
1287
1301
  "start": [
1288
1302
  "mcp",
1289
1303
  "server",
@@ -2,7 +2,7 @@ import { randomBytes } from "node:crypto";
2
2
  import { createServer } from "node:http";
3
3
  import { CliError, isCliError } from "@wirecat/cli-base";
4
4
  import { hostFetch } from "@wirecat/cli-base/http";
5
- import { tokenKeeper } from "@wirecat/cli-core/oauth";
5
+ import { tokenKeeper } from "@wirecat/cli-core";
6
6
  import { IDENTITY } from "../identity.js";
7
7
  import { isRecord } from "./json.js";
8
8
  import { appProvider, appStorage, BUTTON_RELAY_URL, CLAIM_URL, CONNECT_PAGE_URL, fetchFor, lockDirOf, } from "./oauth.js";
package/dist/amo/json.js CHANGED
@@ -1,3 +1,3 @@
1
- import { crmValues } from "@wirecat/cli-core/crm";
1
+ import { crmValues } from "@wirecat/cli-core";
2
2
  export const isRecord = crmValues.isRaw;
3
3
  //# sourceMappingURL=json.js.map
package/dist/amo/oauth.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { CliError, Credentials, isMovedRun, resolvePaths, systemKeyring, } from "@wirecat/cli-base";
2
2
  import { hostFetch } from "@wirecat/cli-base/http";
3
- import { timeLimit } from "@wirecat/cli-core/cli";
4
- import { accountTokenCodec, credentialStorage, oauthAccount, tokenKeeper, } from "@wirecat/cli-core/oauth";
3
+ import { accountTokenCodec, credentialStorage, oauthAccount, timeLimit, tokenKeeper, } from "@wirecat/cli-core";
5
4
  import { IDENTITY } from "../identity.js";
6
5
  import { accountOrigin } from "./account.js";
7
6
  import { isRecord } from "./json.js";
@@ -1,7 +1,6 @@
1
1
  import { CliError, isCliError, realSleep } from "@wirecat/cli-base";
2
2
  import { hostFetch, providerWaitMs, readJsonResponse } from "@wirecat/cli-base/http";
3
- import { apiJson, currentAttempt, providerEvent, providerRequest, timeLimit, } from "@wirecat/cli-core/cli";
4
- import { providerCall } from "@wirecat/cli-core/crm";
3
+ import { apiJson, currentAttempt, providerCall, providerEvent, providerRequest, timeLimit, } from "@wirecat/cli-core";
5
4
  import { employeeRuleOf } from "../api-keys.js";
6
5
  import { amoError, isBlock } from "./errors.js";
7
6
  import { isRecord } from "./json.js";
package/dist/api-keys.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CRM_ASSIGN_OTHERS_KEY } from "@wirecat/cli-core/crm";
1
+ import { CRM_ASSIGN_OTHERS_KEY } from "@wirecat/cli-core";
2
2
  import { isRecord } from "./amo/json.js";
3
3
  import { matchOperation, OPERATIONS } from "./amo/operation.js";
4
4
  import { ENTITIES } from "./amo/routes.js";
package/dist/bin/amo.js CHANGED
@@ -9,15 +9,13 @@ if (
9
9
  (words[0] === "--version" || words[0] === "-V") &&
10
10
  !Object.keys(process.env).some((key) => key.endsWith("_TEST_ARGV_LOG"))
11
11
  ) {
12
- process.stdout.write("0.6.0\n")
12
+ process.stdout.write("0.8.0\n")
13
13
  } else {
14
14
  // Before the bundle compiles: the bundle's own call comes after its chunks.
15
15
  module.enableCompileCache()
16
16
  const serves = ((words) => {
17
- const plain = words.filter((word) => !word.startsWith("-"));
18
- return plain
19
- .slice(0, 4)
20
- .some((word, at) => word === "serve" || word === "watch" || (word === "mcp" && plain[at + 1] === undefined));
17
+ const plain = words.filter((word) => !word.startsWith("-"));
18
+ return plain.slice(0, 4).some((word, at) => word === "serve" || word === "watch" || word === "mcp" && plain[at + 1] === void 0);
21
19
  })(words)
22
20
  if (serves && module.registerHooks) {
23
21
  const bundle = new URL("../bundle/", import.meta.url).href
@@ -28,13 +26,15 @@ if (
28
26
  : next(specifier, context),
29
27
  })
30
28
  }
31
- const chunks = ["../bundle/agent-VVACEKSX.js","../bundle/all-profiles-QNUKL4NA.js","../bundle/anthropic-PQN6MNP7.js","../bundle/app-server-Q2QEA7GP.js","../bundle/areas-27FRPBF3.js","../bundle/bun-F4M4KCNA.js","../bundle/bun-sqlite-P5IDBDVR.js","../bundle/cli-EAD3WZLR.js","../bundle/command-contract-SMEJ2ICG.js","../bundle/command-server-entry-YTZP6I4T.js","../bundle/decode-57BE5OBT.js","../bundle/dispatch-56FECRCU.js","../bundle/dist-PAKDDIBT.js","../bundle/dist-T54K3FJV.js","../bundle/echarts-QMAA7HH5.js","../bundle/embed-NFGFYUO4.js","../bundle/embedder-SRBOJMXX.js","../bundle/failure-WDSX6H3B.js","../bundle/first-run-HWRUL2GR.js","../bundle/first-screen-ATN4D3FQ.js","../bundle/instructions-4H7UREH2.js","../bundle/mcp-5HFPWC3W.js","../bundle/node-P3PUHKYH.js","../bundle/node-P4E63KXA.js","../bundle/node-TLZSIHIJ.js","../bundle/node-sqlite-JOTSNH3P.js","../bundle/oauth-XPSAL6VO.js","../bundle/open-PO52FVA5.js","../bundle/openai-WITYLMY5.js","../bundle/process-AFIXYXWL.js","../bundle/program-JODTZNBZ.js","../bundle/prompt-XORLAXHY.js","../bundle/recognize-JKMZHDYS.js","../bundle/remote-3IMEJTEH.js","../bundle/rerank-3F2E6NNN.js","../bundle/serve-6BWU3NMB.js","../bundle/server-GPSB5WFG.js","../bundle/server-HMCC64ZU.js","../bundle/source-E72OS27D.js","../bundle/sqlite-runtime-YHYQDUXE.js","../bundle/state-R7W4U6T4.js","../bundle/store-HTVRL7FB.js","../bundle/store-IWW6U6QN.js","../bundle/store-TBZ3ZS6H.js","../bundle/store-maintenance-command-CJM2VLMW.js","../bundle/surface-5GBWNYBE.js","../bundle/writer-TW2Q55VJ.js"]
32
- if (((words) => words
33
- .filter((word) => !word.startsWith("-"))
34
- .slice(0, 2)
35
- .includes("upgrade"))(words)) await Promise.allSettled(chunks.map((chunk) => import(chunk)))
29
+ const chunks = ["../bundle/program-RA6QICVH.js","../bundle/source-C65ZJUTW.js","../bundle/store-35UXUNVG.js","../bundle/writer-I7GBI3VE.js"]
30
+ const preload = () =>
31
+ Promise.allSettled([
32
+ ...chunks.map((chunk) => import(chunk)),
33
+ ...["@wirecat/cli-core/preload","@wirecat/cli-base/preload"].map((name) => import(name).then((loaded) => loaded.preload())),
34
+ ])
35
+ if (((words) => words.filter((word) => !word.startsWith("-")).slice(0, 2).includes("upgrade"))(words)) await preload()
36
36
  const running = import("../bundle/amo.js")
37
37
  // After the server answers its first request, so it starts no later.
38
- if (serves) setTimeout(() => void Promise.allSettled(chunks.map((chunk) => import(chunk))), 2000).unref()
38
+ if (serves) setTimeout(() => void preload(), 2000).unref()
39
39
  await running
40
40
  }
@@ -3,198 +3,20 @@ import { createRequire as __bundleRequire } from "node:module";
3
3
  const require = __bundleRequire(import.meta.url);
4
4
  import {
5
5
  DESKTOP
6
- } from "./chunk-APBEDWOE.js";
7
- import "./chunk-B7L5MSRP.js";
8
- import "./chunk-KAFSS35C.js";
9
- import "./chunk-EH6ZEJGT.js";
10
- import "./chunk-X76RS6JO.js";
11
- import "./chunk-7CPIZFOE.js";
12
- import {
13
- installerOf
14
- } from "./chunk-TXDR6YSF.js";
15
- import "./chunk-SDVUGWD7.js";
16
- import "./chunk-3J3EDSXF.js";
17
- import "./chunk-NSOY4FMN.js";
18
- import "./chunk-HO4JGD4Q.js";
19
- import "./chunk-MNPGZCKE.js";
20
- import "./chunk-LC7ZD2RW.js";
21
- import "./chunk-PATZAYFZ.js";
22
- import "./chunk-YF3S26TS.js";
23
- import "./chunk-DNCLQPOM.js";
24
- import "./chunk-QQRJEWKB.js";
25
- import {
26
- DESCRIBE_FLAG,
27
- DISPATCH_FLAG,
28
- PROGRAM_PREFIX,
29
- SHIM_FORMAT,
30
- describeAnswer,
31
- exists,
32
- fileState,
33
- shimFiles,
34
- writeShim
35
- } from "./chunk-DPV53EZC.js";
36
- import "./chunk-KLRCTMES.js";
37
- import "./chunk-TES7MB6I.js";
38
- import "./chunk-ZCQ4H7CA.js";
39
- import "./chunk-WIHN3ELW.js";
40
- import {
41
- catchCrashes
42
- } from "./chunk-QFOP3KUP.js";
43
- import "./chunk-Y5E2WNWB.js";
44
- import "./chunk-S6JG4YUH.js";
45
- import {
46
- __name
47
- } from "./chunk-ZVVMGPBJ.js";
6
+ } from "./chunk-SV4CS5TA.js";
7
+ import "./chunk-AEWYRB6F.js";
48
8
 
49
9
  // dist/bin/amo.js
50
10
  import { enableCompileCache } from "node:module";
51
-
52
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/start.js
53
- import { createHash } from "node:crypto";
54
- import { existsSync, readFileSync as readFileSync2, realpathSync } from "node:fs";
55
- import { dirname as dirname2, join as join2 } from "node:path";
56
- import { fileURLToPath } from "node:url";
57
-
58
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/launcher.js
59
- import { readFileSync } from "node:fs";
60
- import { basename, dirname, join, resolve } from "node:path";
61
- var posix = /* @__PURE__ */ __name((path) => path.replaceAll("\\", "/"), "posix");
62
- var pnpmHome = /* @__PURE__ */ __name((path, env) => {
63
- const home = env.PNPM_HOME;
64
- return home && path.startsWith(`${posix(home).replace(/\/+$/, "")}/`) ? home : void 0;
65
- }, "pnpmHome");
66
- var layoutFolders = /* @__PURE__ */ __name((script, env) => {
67
- const path = posix(script);
68
- const home = pnpmHome(path, env);
69
- if (home)
70
- return [join(home, "bin"), home];
71
- switch (installerOf(script)) {
72
- case "bun":
73
- return [`${path.slice(0, path.indexOf("/install/global/node_modules/"))}/bin`];
74
- case "npm": {
75
- const root = path.slice(0, path.indexOf("/node_modules/"));
76
- return [basename(root) === "lib" ? join(dirname(root), "bin") : root];
77
- }
78
- default:
79
- return [];
80
- }
81
- }, "layoutFolders");
82
- var binFolder = /* @__PURE__ */ __name(({ name, argv1, script, env, platform }) => {
83
- if (!["npm", "pnpm", "bun"].includes(installerOf(script)) && !pnpmHome(posix(script), env))
84
- return void 0;
85
- const extensions = platform === "win32" ? [".cmd", ".exe"] : [""];
86
- const candidates = [argv1 ? dirname(argv1) : void 0, ...layoutFolders(script, env)];
87
- for (const dir of new Set(candidates)) {
88
- if (dir === void 0 || basename(dir) === ".bin")
89
- continue;
90
- for (const extension of extensions) {
91
- const program = `${PROGRAM_PREFIX}${name}${extension}`;
92
- if (exists(join(dir, program)))
93
- return { dir, program };
94
- }
95
- }
96
- return void 0;
97
- }, "binFolder");
98
- var installed = /* @__PURE__ */ __name((dir, program) => {
99
- if (!exists(join(dir, program)))
100
- return false;
101
- if (!program.toLowerCase().endsWith(".exe"))
102
- return true;
103
- let script;
104
- try {
105
- script = readFileSync(join(dir, `${program.slice(0, -4)}.bunx`)).toString("utf16le").split('"')[0] ?? "";
106
- } catch {
107
- return true;
108
- }
109
- if (script === "" || exists(resolve(dir, script)))
110
- return true;
111
- const at = posix(script).lastIndexOf("/install/global/node_modules/");
112
- return at < 0 || exists(join(dirname(dir), posix(script).slice(at + 1)));
113
- }, "installed");
114
- var NAME = "wcat";
115
- var ensureLauncher = /* @__PURE__ */ __name(({ dir, program, platform }) => {
116
- try {
117
- if (!exists(join(dir, program)))
118
- return "failed";
119
- const mine = shimFiles("launcher", { dir, name: NAME, target: program, platform });
120
- const states = mine.map((file) => fileState(file.path));
121
- if (states.some((one) => one.state === "foreign"))
122
- return "foreign";
123
- const ours = states.flatMap((one) => one.state === "ours" ? [one] : []);
124
- if (ours.some(({ mark }) => mark.format > SHIM_FORMAT))
125
- return "newer";
126
- if (ours.some(({ mark }) => mark.kind !== "launcher"))
127
- return "foreign";
128
- const current = ours.find(({ mark }) => installed(dir, mark.target))?.mark.target;
129
- const wanted = shimFiles("launcher", { dir, name: NAME, target: current ?? program, platform });
130
- const stale = wanted.filter((file, at) => {
131
- const state = states[at];
132
- return state?.state !== "ours" || state.text !== file.text;
133
- });
134
- if (stale.length === 0)
135
- return "kept";
136
- for (const file of stale)
137
- writeShim(file);
138
- return "written";
139
- } catch {
140
- return "failed";
141
- }
142
- }, "ensureLauncher");
143
-
144
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/start.js
145
- var wcatStart = /* @__PURE__ */ __name(async (tool, io = {}) => {
146
- const argv = io.argv ?? process.argv;
147
- const env = io.env ?? process.env;
148
- const platform = io.platform ?? process.platform;
149
- const stdout = io.stdout ?? process.stdout;
150
- const [first, ...rest] = argv.slice(2);
151
- if (first === DESCRIBE_FLAG) {
152
- stdout.write(`${JSON.stringify(describeAnswer(tool, shippedManifest(argv[1])))}
153
- `);
154
- return { code: 0 };
155
- }
156
- if (first === DISPATCH_FLAG) {
157
- const { runWcat } = await import("./dispatch-56FECRCU.js");
158
- const code = await runWcat(rest, { env, platform, stdout, stderr: io.stderr ?? process.stderr, self: tool });
159
- return { code };
160
- }
161
- const folder = binFolder({
162
- name: tool.command,
163
- argv1: argv[1],
164
- script: io.script ?? fileURLToPath(new URL("wcat/start.js", import.meta.resolve("@wirecat/cli-base")).href),
165
- env,
166
- platform
167
- });
168
- return folder ? { launcher: ensureLauncher({ ...folder, platform }) } : {};
169
- }, "wcatStart");
170
- var shippedManifest = /* @__PURE__ */ __name((bin) => {
171
- if (!bin)
172
- return void 0;
173
- try {
174
- for (let dir = dirname2(realpathSync(bin)); ; dir = dirname2(dir)) {
175
- if (existsSync(join2(dir, "package.json"))) {
176
- const bytes = readFileSync2(join2(dir, "contracts", "wirecat.json"));
177
- const { wcat_manifest: format, desktop } = JSON.parse(bytes.toString("utf8"));
178
- if (format !== 2 || typeof desktop !== "object" || desktop === null)
179
- return void 0;
180
- return { desktop, sha256: createHash("sha256").update(bytes).digest("hex") };
181
- }
182
- if (dirname2(dir) === dir)
183
- return void 0;
184
- }
185
- } catch {
186
- return void 0;
187
- }
188
- }, "shippedManifest");
189
-
190
- // dist/bin/amo.js
11
+ import { catchCrashes } from "@wirecat/cli-base";
12
+ import { wcatStart } from "@wirecat/cli-base/wcat/start";
191
13
  enableCompileCache();
192
14
  var stopCatching = catchCrashes({ cli: DESKTOP.command, interactive: process.stdout.isTTY === true });
193
15
  var wcat = await wcatStart(DESKTOP);
194
16
  if (wcat.code !== void 0) {
195
17
  process.exitCode = wcat.code;
196
18
  } else {
197
- const { run } = await import("./program-JODTZNBZ.js");
19
+ const { run } = await import("./program-RA6QICVH.js");
198
20
  process.exitCode = await run(process.argv.slice(2));
199
21
  }
200
22
  stopCatching();
@@ -1,11 +1,8 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
- import {
4
- values_exports
5
- } from "./chunk-FWRLGIF6.js";
6
3
  import {
7
4
  __name
8
- } from "./chunk-ZVVMGPBJ.js";
5
+ } from "./chunk-AEWYRB6F.js";
9
6
 
10
7
  // dist/amo/routes.js
11
8
  var ROUTES = {
@@ -66,7 +63,8 @@ var ENTITIES = {
66
63
  };
67
64
 
68
65
  // dist/crm/records.js
69
- var { amountOf, epoch, fieldOf, id, isRaw, rawsOf, text } = values_exports;
66
+ import { crmValues } from "@wirecat/cli-core";
67
+ var { amountOf, epoch, fieldOf, id, isRaw, rawsOf, text } = crmValues;
70
68
  var WON = "142";
71
69
  var LOST = "143";
72
70
  var LISTS = /* @__PURE__ */ new Set(["select", "multiselect", "radiobutton"]);
@@ -123,7 +121,7 @@ var valuesOf = /* @__PURE__ */ __name((raw) => {
123
121
  }
124
122
  return { phones, emails, contactTypes, custom };
125
123
  }, "valuesOf");
126
- var metadataOf = /* @__PURE__ */ __name((custom, fields) => Object.keys(custom).length ? { metadata: values_exports.crmValuesOf(custom, fields) } : {}, "metadataOf");
124
+ var metadataOf = /* @__PURE__ */ __name((custom, fields) => Object.keys(custom).length ? { metadata: crmValues.crmValuesOf(custom, fields) } : {}, "metadataOf");
127
125
  var embedded = /* @__PURE__ */ __name((raw, key) => rawsOf(fieldOf(raw._embedded, key)), "embedded");
128
126
  var day = /* @__PURE__ */ __name((at, timeZone) => {
129
127
  const ms = epoch(at);
@@ -9,17 +9,17 @@ import {
9
9
  toPerson,
10
10
  toPipeline,
11
11
  toUser
12
- } from "./chunk-FYOPPKAN.js";
13
- import {
14
- values_exports
15
- } from "./chunk-FWRLGIF6.js";
16
- import {
17
- CliError,
18
- isCliError
19
- } from "./chunk-S6JG4YUH.js";
12
+ } from "./chunk-3HWD4BKU.js";
20
13
  import {
21
14
  __name
22
- } from "./chunk-ZVVMGPBJ.js";
15
+ } from "./chunk-AEWYRB6F.js";
16
+
17
+ // dist/crm/source.js
18
+ import { CliError as CliError2, isCliError as isCliError2 } from "@wirecat/cli-base";
19
+ import { crmValues as crmValues2 } from "@wirecat/cli-core";
20
+
21
+ // dist/amo/operation.js
22
+ import { CliError } from "@wirecat/cli-base";
23
23
 
24
24
  // dist/amo/allow-list.js
25
25
  var LINKS = "https://www.amocrm.ru/developers/content/crm_platform/entity-links-api";
@@ -1586,7 +1586,9 @@ var withEveryId = /* @__PURE__ */ __name((matched) => {
1586
1586
  var pathOf = /* @__PURE__ */ __name(({ operation, ids }) => operation.template.replace(/\{(\w+)\}/g, (_, name) => encodeURIComponent(ids[name] ?? "")), "pathOf");
1587
1587
 
1588
1588
  // dist/crm/activities.js
1589
- var { fieldOf, id, isRaw, text } = values_exports;
1589
+ import { isCliError } from "@wirecat/cli-base";
1590
+ import { crmValues } from "@wirecat/cli-core";
1591
+ var { fieldOf, id, isRaw, text } = crmValues;
1590
1592
  var OVERLAP_MS = 10 * 6e4;
1591
1593
  var seconds = /* @__PURE__ */ __name((ms) => Math.floor(ms / 1e3), "seconds");
1592
1594
  var msOf = /* @__PURE__ */ __name((value) => typeof value === "number" && value > 0 ? value * 1e3 : null, "msOf");
@@ -1742,7 +1744,7 @@ var readActivities = /* @__PURE__ */ __name(async (list, { since, page, now, siz
1742
1744
  }, "readActivities");
1743
1745
 
1744
1746
  // dist/crm/source.js
1745
- var { fieldOf: fieldOf2, id: id2, isRaw: isRaw2, rawsOf, text: text2 } = values_exports;
1747
+ var { fieldOf: fieldOf2, id: id2, isRaw: isRaw2, rawsOf, text: text2 } = crmValues2;
1746
1748
  var OVERLAP_MS2 = 10 * 6e4;
1747
1749
  var PAGE = 250;
1748
1750
  var EVENTS_PAGE2 = 100;
@@ -1754,7 +1756,7 @@ var listPage = /* @__PURE__ */ __name(async (caller, route, name, query) => {
1754
1756
  return { rows: [], more: false };
1755
1757
  const rows = fieldOf2(fieldOf2(body, "_embedded"), name);
1756
1758
  if (!Array.isArray(rows))
1757
- throw new CliError("invalid_response", `amoCRM answered ${route} without its ${name}`);
1759
+ throw new CliError2("invalid_response", `amoCRM answered ${route} without its ${name}`);
1758
1760
  return { rows: rows.filter(isRaw2), more: fieldOf2(fieldOf2(body, "_links"), "next") !== void 0 };
1759
1761
  }, "listPage");
1760
1762
  var readAll = /* @__PURE__ */ __name(async (caller, route, name, query = {}) => {
@@ -1774,7 +1776,7 @@ var readOne = /* @__PURE__ */ __name(async (caller, route, externalId, query = {
1774
1776
  const { body } = await caller.request({ route, ids: { id: externalId }, query });
1775
1777
  return isRaw2(body) ? body : null;
1776
1778
  } catch (error) {
1777
- if (isCliError(error) && error.code === "not_found")
1779
+ if (isCliError2(error) && error.code === "not_found")
1778
1780
  return null;
1779
1781
  throw error;
1780
1782
  }
@@ -1811,7 +1813,7 @@ var filtersOf = /* @__PURE__ */ __name((kind, conditions, self) => {
1811
1813
  const query = {};
1812
1814
  const set = /* @__PURE__ */ __name((name, value) => {
1813
1815
  if (!declared.has(name))
1814
- throw new CliError("validation_error", `amoCRM cannot filter ${ENTITIES[kind].name} by ${name}`, {
1816
+ throw new CliError2("validation_error", `amoCRM cannot filter ${ENTITIES[kind].name} by ${name}`, {
1815
1817
  reason: "crm.record-field"
1816
1818
  });
1817
1819
  query[name] = value;
@@ -1821,7 +1823,7 @@ var filtersOf = /* @__PURE__ */ __name((kind, conditions, self) => {
1821
1823
  const users = (Array.isArray(value) ? value : [value]).map((one) => one === "me" ? self : String(one));
1822
1824
  for (const user of users)
1823
1825
  if (!user || !/^[1-9][0-9]*$/.test(user))
1824
- throw new CliError("validation_error", "assigned_to takes me or an amoCRM user id, such as 7", {
1826
+ throw new CliError2("validation_error", "assigned_to takes me or an amoCRM user id, such as 7", {
1825
1827
  reason: "crm.owner-unknown"
1826
1828
  });
1827
1829
  set("filter[responsible_user_id][]", users.map(Number));
@@ -1835,7 +1837,7 @@ var filtersOf = /* @__PURE__ */ __name((kind, conditions, self) => {
1835
1837
  set(`filter[${field}][to]`, op === "<" ? Math.ceil(ms / 1e3) - 1 : seconds2(ms));
1836
1838
  continue;
1837
1839
  }
1838
- throw new CliError("validation_error", `amoCRM cannot filter ${ENTITIES[kind].name} by ${field} ${op}`, {
1840
+ throw new CliError2("validation_error", `amoCRM cannot filter ${ENTITIES[kind].name} by ${field} ${op}`, {
1839
1841
  reason: "crm.record-field"
1840
1842
  });
1841
1843
  }
@@ -1998,7 +2000,7 @@ var amoCrmSource = /* @__PURE__ */ __name((account, options = {}) => {
1998
2000
  const { mode, setting, chosen } = await asked();
1999
2001
  if (mode === "mine")
2000
2002
  return (await accountOf()).userId;
2001
- throw new CliError("configuration_error", `${setting} is all, and amo never copies the whole CRM: "config set ${setting} mine" copies the deals of the users you choose in ${chosen}, and their clients. Find any other client with "people list" or "organizations list"`, { setting, reason: "amo.scope-all-refused" });
2003
+ throw new CliError2("configuration_error", `${setting} is all, and amo never copies the whole CRM: "config set ${setting} mine" copies the deals of the users you choose in ${chosen}, and their clients. Find any other client with "people list" or "organizations list"`, { setting, reason: "amo.scope-all-refused" });
2002
2004
  },
2003
2005
  // Only an administrator may copy a colleague's deals: anyone else cannot list the users to tell who is who.
2004
2006
  async unassigned(users) {
@@ -2285,7 +2287,7 @@ var amoCrmSource = /* @__PURE__ */ __name((account, options = {}) => {
2285
2287
  const me = query.conditions.some((one) => one.field === "assigned_to" && [one.value].flat().includes("me"));
2286
2288
  const filters = filtersOf(kind, query.conditions, me ? (await accountOf(caller)).userId : void 0);
2287
2289
  if (Object.keys(filters).length && !(await accountOf(caller)).filters)
2288
- throw new CliError("validation_error", "this account has no API filter add-on (is_api_filter_enabled is off), so amoCRM cannot narrow the list by owner or time; search by name instead", { reason: "amo.filters-off" });
2290
+ throw new CliError2("validation_error", "this account has no API filter add-on (is_api_filter_enabled is off), so amoCRM cannot narrow the list by owner or time; search by name instead", { reason: "amo.filters-off" });
2289
2291
  const entity = ENTITIES[kind];
2290
2292
  const { rows, more } = await listPage(caller, entity.list, entity.name, {
2291
2293
  ...filters,
@@ -2314,7 +2316,7 @@ var amoCrmSource = /* @__PURE__ */ __name((account, options = {}) => {
2314
2316
  async item(externalId) {
2315
2317
  const raw = await readOne(account(), ROUTES.lead, externalId, { with: WITH.deal });
2316
2318
  if (!raw)
2317
- throw new CliError("not_found", `amoCRM has no deal ${externalId}`);
2319
+ throw new CliError2("not_found", `amoCRM has no deal ${externalId}`);
2318
2320
  return (await mapped("deal", [raw], account()))[0];
2319
2321
  },
2320
2322
  async lossReasons() {
@@ -2,10 +2,10 @@ import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  IDENTITY
5
- } from "./chunk-APBEDWOE.js";
5
+ } from "./chunk-SV4CS5TA.js";
6
6
  import {
7
7
  __name
8
- } from "./chunk-ZVVMGPBJ.js";
8
+ } from "./chunk-AEWYRB6F.js";
9
9
 
10
10
  // dist/store.js
11
11
  var PROVIDER = {
@@ -15,7 +15,7 @@ var PROVIDER = {
15
15
  command: IDENTITY.command
16
16
  };
17
17
  var openAmoStore = /* @__PURE__ */ __name(async (env, { readOnly = false } = {}) => {
18
- const { openAppStore } = await import("./cli-EAD3WZLR.js");
18
+ const { openAppStore } = await import("@wirecat/cli-core");
19
19
  return openAppStore(env, { app: IDENTITY, provider: PROVIDER, readOnly });
20
20
  }, "openAmoStore");
21
21
 
@@ -0,0 +1,8 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+
6
+ export {
7
+ __name
8
+ };
@@ -4,22 +4,14 @@ import {
4
4
  ENTITIES,
5
5
  LOST,
6
6
  WON
7
- } from "./chunk-FYOPPKAN.js";
8
- import {
9
- fieldNamed,
10
- foldFieldName,
11
- optionOf,
12
- values_exports
13
- } from "./chunk-FWRLGIF6.js";
14
- import {
15
- CliError,
16
- isCliError
17
- } from "./chunk-S6JG4YUH.js";
7
+ } from "./chunk-3HWD4BKU.js";
18
8
  import {
19
9
  __name
20
- } from "./chunk-ZVVMGPBJ.js";
10
+ } from "./chunk-AEWYRB6F.js";
21
11
 
22
12
  // dist/crm/writer.js
13
+ import { CliError, isCliError } from "@wirecat/cli-base";
14
+ import { crmValues, fieldNamed, foldFieldName, optionOf } from "@wirecat/cli-core";
23
15
  var AMO_WRITES = {
24
16
  kinds: ["deal", "person", "organization"],
25
17
  verbs: ["create", "update", "move", "close"],
@@ -109,7 +101,7 @@ var amoCrmWriter = /* @__PURE__ */ __name((account, source) => {
109
101
  const current = externalId !== void 0 && (naming || given.emails || given.phones) ? await source.get?.("person", externalId) : void 0;
110
102
  const fields = {};
111
103
  const stored = partsOf(current);
112
- const name = given.name ?? (naming ? values_exports.fullName(given.firstName === void 0 ? stored.first : given.firstName, given.lastName === void 0 ? stored.last : given.lastName) : void 0);
104
+ const name = given.name ?? (naming ? crmValues.fullName(given.firstName === void 0 ? stored.first : given.firstName, given.lastName === void 0 ? stored.last : given.lastName) : void 0);
113
105
  if (name != null)
114
106
  fields.name = name;
115
107
  if (given.firstName !== void 0)
@@ -197,8 +189,8 @@ var amoCrmWriter = /* @__PURE__ */ __name((account, source) => {
197
189
  const fields = await bodyOf(kind, draft, true);
198
190
  const entity = ENTITIES[kind];
199
191
  const { body } = await account().request({ route: entity.create, body: [fields] });
200
- const created = values_exports.rawsOf(values_exports.fieldOf(values_exports.fieldOf(body, "_embedded"), entity.name))[0];
201
- const externalId = values_exports.id(created?.id);
192
+ const created = crmValues.rawsOf(crmValues.fieldOf(crmValues.fieldOf(body, "_embedded"), entity.name))[0];
193
+ const externalId = crmValues.id(created?.id);
202
194
  if (externalId === null)
203
195
  throw new CliError("invalid_response", `amoCRM answered the new ${kind} without its id; run sync before writing again`, {
204
196
  operation_id: options.operationId,