@wirecat/amo-cli 0.6.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 (282) hide show
  1. package/CHANGELOG.md +17 -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-AEWYRB6F.js +8 -0
  14. package/dist/bundle/{chunk-SWCJM3YD.js → chunk-GL7CRTHR.js} +3 -3
  15. package/dist/bundle/chunk-N2UB32VN.js +76 -0
  16. package/dist/bundle/{chunk-RNWUCAJJ.js → chunk-PVVSHDMQ.js} +7 -15
  17. package/dist/bundle/program-SQH3SPOW.js +2352 -0
  18. package/dist/bundle/{instructions-4H7UREH2.js → source-C65ZJUTW.js} +5 -6
  19. package/dist/bundle/store-SJ2TOUGU.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
@@ -1,86 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- alive
5
- } from "./chunk-T3W4V4A6.js";
6
- import {
7
- resolvePaths,
8
- writeSecurely
9
- } from "./chunk-WIHN3ELW.js";
10
- import {
11
- __name
12
- } from "./chunk-ZVVMGPBJ.js";
13
-
14
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/background/lock.js
15
- import { existsSync, linkSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
16
- import { dirname, join } from "node:path";
17
- var lockPath = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "serve", `${profile}.lock`), "lockPath");
18
- var readLock = /* @__PURE__ */ __name((path) => {
19
- try {
20
- const lock = JSON.parse(readFileSync(path, "utf8"));
21
- return typeof lock.pid === "number" && typeof lock.startedAt === "string" ? lock : void 0;
22
- } catch {
23
- return void 0;
24
- }
25
- }, "readLock");
26
- var holdLock = /* @__PURE__ */ __name((path, lock) => writeSecurely(path, `${JSON.stringify(lock)}
27
- `, 384), "holdLock");
28
- var takeLock = /* @__PURE__ */ __name((path, lock) => {
29
- mkdirSync(dirname(path), { recursive: true, mode: 448 });
30
- const draft = `${path}.${lock.pid}.tmp`;
31
- writeFileSync(draft, `${JSON.stringify(lock)}
32
- `, { mode: 384 });
33
- try {
34
- for (let attempt = 0; attempt < 5; attempt++) {
35
- try {
36
- linkSync(draft, path);
37
- return void 0;
38
- } catch (error) {
39
- if (error.code !== "EEXIST")
40
- throw error;
41
- }
42
- const held = readLock(path);
43
- if (held && held.pid !== lock.pid && alive(held.pid))
44
- return held;
45
- rmSync(path, { force: true });
46
- }
47
- throw new Error(`could not take the lock ${path}: it keeps changing`);
48
- } finally {
49
- rmSync(draft, { force: true });
50
- }
51
- }, "takeLock");
52
- var releaseLock = /* @__PURE__ */ __name((path, pid = process.pid) => {
53
- if (readLock(path)?.pid === pid)
54
- rmSync(path, { force: true });
55
- }, "releaseLock");
56
- var currentPath = /* @__PURE__ */ __name((lock) => lock.replace(/\.lock$/, ".current"), "currentPath");
57
- var markCurrent = /* @__PURE__ */ __name((lock, at = /* @__PURE__ */ new Date()) => writeSecurely(currentPath(lock), `${JSON.stringify({ at: at.toISOString() })}
58
- `, 384), "markCurrent");
59
- var readCurrent = /* @__PURE__ */ __name((lock) => {
60
- try {
61
- const { at } = JSON.parse(readFileSync(currentPath(lock), "utf8"));
62
- return typeof at === "string" ? at : void 0;
63
- } catch {
64
- return void 0;
65
- }
66
- }, "readCurrent");
67
- var servingProfiles = /* @__PURE__ */ __name((app, env) => {
68
- const dir = dirname(lockPath(app, "default", env));
69
- if (!existsSync(dir))
70
- return [];
71
- return readdirSync(dir).filter((name) => name.endsWith(".lock")).map((name) => name.slice(0, -".lock".length)).filter((profile) => {
72
- const lock = readLock(lockPath(app, profile, env));
73
- return lock !== void 0 && alive(lock.pid);
74
- });
75
- }, "servingProfiles");
76
-
77
- export {
78
- lockPath,
79
- readLock,
80
- holdLock,
81
- takeLock,
82
- releaseLock,
83
- markCurrent,
84
- readCurrent,
85
- servingProfiles
86
- };
@@ -1,361 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- CliError
5
- } from "./chunk-S6JG4YUH.js";
6
- import {
7
- __name
8
- } from "./chunk-ZVVMGPBJ.js";
9
-
10
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/money.js
11
- var CURRENCY_SCALES = {
12
- AED: 2,
13
- AMD: 2,
14
- AUD: 2,
15
- BHD: 3,
16
- BYN: 2,
17
- CAD: 2,
18
- CHF: 2,
19
- CLP: 0,
20
- CNY: 2,
21
- CZK: 2,
22
- DKK: 2,
23
- EUR: 2,
24
- GBP: 2,
25
- GEL: 2,
26
- HUF: 2,
27
- ILS: 2,
28
- INR: 2,
29
- ISK: 0,
30
- JPY: 0,
31
- KGS: 2,
32
- KRW: 0,
33
- KWD: 3,
34
- KZT: 2,
35
- NOK: 2,
36
- PLN: 2,
37
- RSD: 2,
38
- RUB: 2,
39
- SEK: 2,
40
- THB: 2,
41
- TRY: 2,
42
- UAH: 2,
43
- USD: 2,
44
- UZS: 2,
45
- VND: 0
46
- };
47
- var refuse = /* @__PURE__ */ __name((message, reason) => {
48
- throw new CliError("validation_error", message, { reason });
49
- }, "refuse");
50
- var DECIMAL = /^(\d{1,15})(?:\.(\d+))?$/;
51
- var parseDecimal = /* @__PURE__ */ __name((text, scale) => {
52
- const match = DECIMAL.exec(text.trim());
53
- if (!match || (match[2] ?? "").length > scale)
54
- return void 0;
55
- return BigInt(`${match[1]}${(match[2] ?? "").padEnd(scale, "0")}`);
56
- }, "parseDecimal");
57
- var formatDecimal = /* @__PURE__ */ __name((units, scale) => {
58
- const value = BigInt(units);
59
- if (value < 0n)
60
- return `-${formatDecimal(-value, scale)}`;
61
- const digits = value.toString().padStart(scale + 1, "0");
62
- return scale === 0 ? digits : `${digits.slice(0, -scale)}.${digits.slice(-scale)}`;
63
- }, "formatDecimal");
64
- var groupDigits = /* @__PURE__ */ __name((decimal) => {
65
- const [whole = "0", fraction] = decimal.split(".");
66
- const grouped = whole.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
67
- return fraction === void 0 ? grouped : `${grouped}.${fraction}`;
68
- }, "groupDigits");
69
- var currencyOf = /* @__PURE__ */ __name((text) => {
70
- const code = typeof text === "string" ? text.trim().toUpperCase() : "";
71
- if (CURRENCY_SCALES[code] === void 0)
72
- return refuse(`${typeof text === "string" && text.trim() ? text.trim() : "an empty currency"} is not a currency the store keeps; use one of ${Object.keys(CURRENCY_SCALES).join(", ")}`, "money.currency");
73
- return code;
74
- }, "currencyOf");
75
- var scaleOf = /* @__PURE__ */ __name((currency) => CURRENCY_SCALES[currencyOf(currency)], "scaleOf");
76
- var minorUnits = /* @__PURE__ */ __name((amount, currency, what = "an amount") => {
77
- const scale = scaleOf(currency);
78
- const units = typeof amount === "string" ? parseDecimal(amount, scale) : void 0;
79
- if (units === void 0 || units > BigInt(Number.MAX_SAFE_INTEGER))
80
- return refuse(`${what} is a decimal string with at most ${scale} decimal${scale === 1 ? "" : "s"} for ${currency}, such as "${formatDecimal(5e3 * 10 ** scale, scale)}"`, "money.amount");
81
- return Number(units);
82
- }, "minorUnits");
83
- var signedMinorUnits = /* @__PURE__ */ __name((amount, currency, what = "an amount") => {
84
- if (typeof amount !== "string" || !amount.trim().startsWith("-"))
85
- return minorUnits(amount, currency, what);
86
- const units = minorUnits(amount.trim().slice(1), currency, what);
87
- return units === 0 ? 0 : -units;
88
- }, "signedMinorUnits");
89
- var moneyOf = /* @__PURE__ */ __name((units, currency) => ({
90
- amount: formatDecimal(units, scaleOf(currency)),
91
- currency
92
- }), "moneyOf");
93
- var moneyLabel = /* @__PURE__ */ __name((units, currency) => `${groupDigits(formatDecimal(units, scaleOf(currency)))} ${currency}`, "moneyLabel");
94
- var QUANTITY_SCALE = 3;
95
- var quantityOf = /* @__PURE__ */ __name((text) => {
96
- const thousandths = typeof text === "string" ? parseDecimal(text, QUANTITY_SCALE) : void 0;
97
- if (thousandths === void 0 || thousandths === 0n)
98
- return refuse('a quantity is a decimal string above 0 with at most 3 decimals, such as "1.5"', "money.quantity");
99
- const plain = formatDecimal(thousandths, QUANTITY_SCALE).replace(/\.?0+$/, "");
100
- return { text: plain, thousandths };
101
- }, "quantityOf");
102
- var lineUnits = /* @__PURE__ */ __name((thousandths, unitPrice) => Number((thousandths * BigInt(unitPrice) + 500n) / 1000n), "lineUnits");
103
-
104
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/finance.js
105
- var INVOICE_DIRECTIONS = ["receivable", "payable"];
106
- var INVOICE_STATUSES = ["draft", "issued", "partly_paid", "paid", "void"];
107
- var MONEY_DIRECTIONS = ["in", "out"];
108
- var FINANCE_REVIEWS = ["proposed", "confirmed", "rejected"];
109
- var settledStatus = /* @__PURE__ */ __name((current, total, paid) => {
110
- if (current === "draft" || current === "void")
111
- return current;
112
- if (paid <= 0)
113
- return "issued";
114
- return paid < total ? "partly_paid" : "paid";
115
- }, "settledStatus");
116
- var dayMonth = /* @__PURE__ */ __name((date) => date === null ? null : `${date.slice(8, 10)}.${date.slice(5, 7)}`, "dayMonth");
117
- var notes = /* @__PURE__ */ __name((...words) => {
118
- const kept = words.filter((word) => word !== null);
119
- return kept.length === 0 ? "" : ` (${kept.join(", ")})`;
120
- }, "notes");
121
- var invoiceLine = /* @__PURE__ */ __name((invoice) => {
122
- const party = invoice.counterpartyName === null ? "" : `${invoice.direction === "receivable" ? " to" : " from"} ${invoice.counterpartyName}`;
123
- const due = invoice.dueDate === null ? "" : `, due ${dayMonth(invoice.dueDate)}`;
124
- return `${invoice.number ?? `#${invoice.id}`} \xB7 ${moneyLabel(invoice.total, invoice.currency)}${party}${due}` + notes(invoice.status.replace("_", " "), invoice.review === "confirmed" ? null : invoice.review);
125
- }, "invoiceLine");
126
- var paymentLine = /* @__PURE__ */ __name((payment) => {
127
- const party = payment.partyName === null ? "" : `${payment.direction === "in" ? " from" : " to"} ${payment.partyName}`;
128
- return `${moneyLabel(payment.amount, payment.currency)}${party}, ${dayMonth(payment.date)}` + notes(payment.review === "confirmed" ? null : payment.review);
129
- }, "paymentLine");
130
- var invoiceTitle = /* @__PURE__ */ __name((invoice) => `Invoice ${invoiceLine(invoice)}`, "invoiceTitle");
131
- var paymentEntryTitle = /* @__PURE__ */ __name((payment) => `Payment \xB7 ${paymentLine(payment)}`, "paymentEntryTitle");
132
-
133
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/business.js
134
- var CATALOG_KINDS = ["product", "service"];
135
- var BUSINESS_KINDS = ["invoice", "payment", "order", "contract", "subscription", "product", "wallet"];
136
- var CONTRACT_KINDS = ["sale", "purchase", "service", "lease", "employment", "nda", "license", "other"];
137
- var CONTRACT_STATUSES = ["draft", "active", "ended", "terminated"];
138
- var SUBSCRIPTION_STATUSES = ["trial", "active", "paused", "cancelled", "ended"];
139
- var WALLET_KINDS = ["bank", "card", "cash", "wallet", "other"];
140
- var TRANSACTION_STATUSES = ["pending", "booked"];
141
- var ORDER_DIRECTIONS = ["purchase", "sale"];
142
- var intervalOf = /* @__PURE__ */ __name((text, reason = "subscription.interval") => {
143
- const match = typeof text === "string" ? /^(?:([1-9]\d{0,2})-)?(day|week|month|year)$/.exec(text.trim()) : null;
144
- if (!match)
145
- throw new CliError("validation_error", "an interval is a count and a unit, such as 1-month or 2-week", { reason });
146
- return { count: match[1] === void 0 ? 1 : Number(match[1]), unit: match[2] };
147
- }, "intervalOf");
148
- var intervalText = /* @__PURE__ */ __name(({ count, unit }) => `${count}-${unit}`, "intervalText");
149
- var priced = /* @__PURE__ */ __name((units, currency) => units === null || currency === null ? "" : `, ${moneyLabel(units, currency)}`, "priced");
150
- var pending = /* @__PURE__ */ __name((review) => review === "confirmed" ? null : review, "pending");
151
- var productLine = /* @__PURE__ */ __name((product) => {
152
- const price = product.unitPrice === null || product.currency === null ? "" : moneyLabel(product.unitPrice, product.currency);
153
- const per = price && product.unit !== null ? ` per ${product.unit}` : "";
154
- return `${product.name}${price ? ` \xB7 ${price}${per}` : ""}${notes(product.kind, product.archived ? "archived" : null)}`;
155
- }, "productLine");
156
- var contractLine = /* @__PURE__ */ __name((contract) => `${contract.number ?? `#${contract.id}`} \xB7 ${contract.name}${priced(contract.value, contract.currency)}` + notes(contract.status, pending(contract.review)), "contractLine");
157
- var subscriptionLine = /* @__PURE__ */ __name((subscription) => `${subscription.name}${priced(subscription.price, subscription.currency)} every ${intervalText(subscription.interval)}` + notes(subscription.status, pending(subscription.review)), "subscriptionLine");
158
- var walletLine = /* @__PURE__ */ __name((wallet) => `${wallet.name} \xB7 ${wallet.kind}, ${wallet.currency}${wallet.numberHint === null ? "" : `, \u2026${wallet.numberHint}`}` + notes(wallet.closed ? "closed" : null), "walletLine");
159
- var transactionLine = /* @__PURE__ */ __name((transaction) => `${moneyLabel(transaction.amount, transaction.currency)} ${transaction.direction}${transaction.label === null ? "" : ` \xB7 ${transaction.label}`}, ${dayMonth(transaction.date)}` + notes(transaction.status === "pending" ? "pending" : null, pending(transaction.review)), "transactionLine");
160
-
161
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/crm.js
162
- var CRM_KINDS = ["organization", "person", "deal", "lead"];
163
- var CRM_ACTIVITY_KINDS = ["call", "email", "meeting", "todo", "task", "comment", "other"];
164
- var isCrmUserId = /* @__PURE__ */ __name((id) => /^\d{1,20}$/.test(id), "isCrmUserId");
165
- var normalCrmUserId = /* @__PURE__ */ __name((id) => {
166
- const text = id.trim();
167
- return /^\d+$/.test(text) ? text.replace(/^0+(?=\d)/, "") : text;
168
- }, "normalCrmUserId");
169
- var isItemKind = /* @__PURE__ */ __name((kind) => kind === "deal" || kind === "lead", "isItemKind");
170
-
171
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/deals.js
172
- var DEAL_KINDS = ["deal", "lead"];
173
- var DEAL_STATUSES = ["open", "won", "lost"];
174
- var STAGE_OUTCOMES = DEAL_STATUSES;
175
- var DEAL_ROLES = ["owner", "contact", "decision-maker", "influencer"];
176
- var dealLine = /* @__PURE__ */ __name((deal) => {
177
- const money = deal.amount === null || deal.currency === null ? "" : `, ${moneyLabel(deal.amount, deal.currency)}`;
178
- return `${deal.title} \xB7 ${deal.stage}${money}${deal.status === "open" ? "" : ` (${deal.status})`}`;
179
- }, "dealLine");
180
-
181
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/orders.js
182
- var ORDER_STATUSES = ["placed", "shipped", "delivered", "cancelled", "returned"];
183
- var ORDER_PURPOSES = ["personal", "business", "client", "other"];
184
- var orderLine = /* @__PURE__ */ __name((order) => {
185
- const party = order.direction === "sale" && order.customerName !== null ? `to ${order.customerName}` : order.supplierName;
186
- const money = order.total === null || order.currency === null ? "" : `, ${moneyLabel(order.total, order.currency)}`;
187
- const notes2 = [order.status, order.review === "confirmed" ? null : order.review].filter(Boolean).join(", ");
188
- return `${order.number ?? `#${order.id}`} \xB7 ${party}${money} (${notes2})`;
189
- }, "orderLine");
190
- var orderTitle = /* @__PURE__ */ __name((order) => `Order ${orderLine(order)}`, "orderTitle");
191
-
192
- // node_modules/.pnpm/@wirecat+cli-core@2.0.0_@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescr_a82f624c57005d53c3f072e45c3a3a86/node_modules/@wirecat/cli-core/dist/domain/relations.js
193
- var ORGANIZATION_ROLES = [
194
- "employee",
195
- "contractor",
196
- "founder",
197
- "owner",
198
- "manager",
199
- "adviser",
200
- "contact"
201
- ];
202
- var PROJECT_ROLES = ["owner", "manager", "contributor", "client-contact", "approver"];
203
- var CONTRACT_ROLES = ["customer", "supplier", "signatory", "guarantor"];
204
- var RELATED_ROLES = ["colleague", "adviser", "investor", "mentor", "family", "friend"];
205
- var ENGAGEMENT_LEVELS = ["none", "low", "medium", "high"];
206
- var isEngagement = /* @__PURE__ */ __name((value) => typeof value === "string" && ENGAGEMENT_LEVELS.includes(value), "isEngagement");
207
- var checkEngagement = /* @__PURE__ */ __name((kind, from, to, level) => {
208
- if (kind !== "member-of" || from !== "person" || to !== "project")
209
- throw new CliError("validation_error", "an engagement level is set only on a person's member-of a project", {
210
- reason: "relationship.engagement-ends"
211
- });
212
- if (!isEngagement(level))
213
- throw new CliError("validation_error", `an engagement level is one of ${ENGAGEMENT_LEVELS.join(", ")}`, {
214
- reason: "relationship.engagement-unknown"
215
- });
216
- return level;
217
- }, "checkEngagement");
218
- var RELATIONS = {
219
- "member-of": {
220
- from: ["person", "organization", "project", "chat", "email_thread"],
221
- to: ["organization", "project"],
222
- roles: { to: { organization: ORGANIZATION_ROLES, project: PROJECT_ROLES } }
223
- },
224
- "reports-to": { from: ["person"], to: ["person"], inverse: "manages" },
225
- "customer-of": { from: ["person", "organization"], to: ["organization"], inverse: "supplier of" },
226
- "partner-of": { from: ["organization"], to: ["organization"], symmetric: true },
227
- "related-to": {
228
- from: ["person", "organization", "project", "task", "deal", "lead", "contract"],
229
- to: ["person", "organization", "project", "task"],
230
- roles: { from: { deal: DEAL_ROLES, lead: DEAL_ROLES, contract: CONTRACT_ROLES } }
231
- }
232
- };
233
- var RELATION_KINDS = Object.keys(RELATIONS);
234
- var specOf = /* @__PURE__ */ __name((kind) => Object.hasOwn(RELATIONS, kind) ? RELATIONS[kind] : void 0, "specOf");
235
- var isRelationKind = /* @__PURE__ */ __name((kind) => specOf(kind) !== void 0, "isRelationKind");
236
- var memberOnly = /* @__PURE__ */ __name((type) => type === "chat" || type === "email_thread", "memberOnly");
237
- var partyOnly = /* @__PURE__ */ __name((from, to) => from === "contract" && to !== "person" && to !== "organization", "partyOnly");
238
- var checkEnds = /* @__PURE__ */ __name((kind, from, to) => {
239
- const spec = specOf(kind);
240
- if (!spec)
241
- throw new CliError("validation_error", `a relationship's kind is one of ${RELATION_KINDS.join(", ")}`);
242
- if (memberOnly(from) && (kind !== "member-of" || to !== "project"))
243
- throw new CliError("validation_error", `a ${from === "chat" ? "chat" : "mail thread"} is related only as member-of a project`);
244
- if (partyOnly(from, to))
245
- throw new CliError("validation_error", "a contract is related only to a person or an organization");
246
- if (!spec.from.includes(from) || !spec.to.includes(to))
247
- throw new CliError("validation_error", `${kind} joins ${spec.from.join(", ")} to ${spec.to.join(", ")}, not ${from} to ${to}`);
248
- return spec;
249
- }, "checkEnds");
250
- var isParty = /* @__PURE__ */ __name((type) => type === "person" || type === "organization", "isParty");
251
- var rolesOf = /* @__PURE__ */ __name((kind, from, to) => {
252
- const spec = specOf(kind);
253
- if (kind === "member-of" && from !== "person")
254
- return void 0;
255
- return spec?.roles?.from?.[from] ?? spec?.roles?.to?.[to];
256
- }, "rolesOf");
257
- var ROLE_LISTS = {
258
- organization: ORGANIZATION_ROLES,
259
- project: PROJECT_ROLES,
260
- deal: DEAL_ROLES,
261
- contract: CONTRACT_ROLES,
262
- related: RELATED_ROLES
263
- };
264
- var roleListOf = /* @__PURE__ */ __name((kind, from, to) => {
265
- if (kind === "related-to" && isParty(from) && isParty(to))
266
- return "related";
267
- const roles = rolesOf(kind, from, to);
268
- return Object.keys(ROLE_LISTS).find((list) => ROLE_LISTS[list] === roles);
269
- }, "roleListOf");
270
- var checkRole = /* @__PURE__ */ __name((kind, from, to, role, extra = []) => {
271
- const roles = rolesOf(kind, from, to)?.concat(extra);
272
- if (roles && !roles.includes(role))
273
- throw new CliError("validation_error", `a ${from}'s role on ${kind} ${to} is one of ${roles.join(", ")}`, {
274
- reason: "relationship.role-unknown"
275
- });
276
- return role;
277
- }, "checkRole");
278
- var isSymmetric = /* @__PURE__ */ __name((kind) => specOf(kind)?.symmetric === true, "isSymmetric");
279
- var inverseOf = /* @__PURE__ */ __name((kind) => specOf(kind)?.symmetric ? kind : specOf(kind)?.inverse ?? null, "inverseOf");
280
- var STANDINGS = ["confirmed", "reported", "proposed", "ended"];
281
- var standingOf = /* @__PURE__ */ __name((link, now) => {
282
- if (link.endsAt != null && link.endsAt <= now)
283
- return "ended";
284
- if (link.confirmed)
285
- return "confirmed";
286
- if (link.deletedAt != null)
287
- return "ended";
288
- return link.accountId != null ? "reported" : "proposed";
289
- }, "standingOf");
290
- var isUsable = /* @__PURE__ */ __name((standing) => standing === "confirmed" || standing === "reported", "isUsable");
291
- var KEYED = "kind IN ('member-of', 'related-to', 'reports-to', 'customer-of', 'partner-of') AND to_id IS NOT NULL";
292
- var notOverriddenSql = /* @__PURE__ */ __name((alias) => `NOT EXISTS (SELECT 1 FROM links override WHERE ${KEYED} AND override.kind = ${alias}.kind AND override.from_type = ${alias}.from_type AND override.from_id = ${alias}.from_id AND override.to_type = ${alias}.to_type AND override.to_id = ${alias}.to_id AND json_extract(override.metadata, '$.overrides') = ${alias}.id)`, "notOverriddenSql");
293
- var usableLinkSql = /* @__PURE__ */ __name((alias, now) => `(${alias}.confirmed = 1 OR (${alias}.account_id IS NOT NULL AND ${alias}.deleted_at IS NULL))` + (now === void 0 ? "" : ` AND (${alias}.ends_at IS NULL OR ${alias}.ends_at > ${Math.trunc(now)})`), "usableLinkSql");
294
-
295
- export {
296
- parseDecimal,
297
- formatDecimal,
298
- groupDigits,
299
- currencyOf,
300
- scaleOf,
301
- minorUnits,
302
- signedMinorUnits,
303
- moneyOf,
304
- moneyLabel,
305
- quantityOf,
306
- lineUnits,
307
- INVOICE_DIRECTIONS,
308
- INVOICE_STATUSES,
309
- MONEY_DIRECTIONS,
310
- FINANCE_REVIEWS,
311
- settledStatus,
312
- invoiceLine,
313
- paymentLine,
314
- invoiceTitle,
315
- paymentEntryTitle,
316
- CATALOG_KINDS,
317
- BUSINESS_KINDS,
318
- CONTRACT_KINDS,
319
- CONTRACT_STATUSES,
320
- SUBSCRIPTION_STATUSES,
321
- WALLET_KINDS,
322
- TRANSACTION_STATUSES,
323
- ORDER_DIRECTIONS,
324
- intervalOf,
325
- productLine,
326
- contractLine,
327
- subscriptionLine,
328
- walletLine,
329
- transactionLine,
330
- CRM_KINDS,
331
- CRM_ACTIVITY_KINDS,
332
- isCrmUserId,
333
- normalCrmUserId,
334
- isItemKind,
335
- DEAL_KINDS,
336
- DEAL_STATUSES,
337
- STAGE_OUTCOMES,
338
- DEAL_ROLES,
339
- dealLine,
340
- ORDER_STATUSES,
341
- ORDER_PURPOSES,
342
- orderLine,
343
- orderTitle,
344
- isEngagement,
345
- checkEngagement,
346
- RELATION_KINDS,
347
- isRelationKind,
348
- checkEnds,
349
- rolesOf,
350
- ROLE_LISTS,
351
- roleListOf,
352
- checkRole,
353
- isSymmetric,
354
- inverseOf,
355
- STANDINGS,
356
- standingOf,
357
- isUsable,
358
- KEYED,
359
- notOverriddenSql,
360
- usableLinkSql
361
- };