@wirecat/attio-cli 0.0.0-stage → 0.2.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 (226) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +204 -0
  3. package/README.md +249 -2
  4. package/contracts/wirecat.json +2339 -0
  5. package/dist/bin/attio.d.ts +3 -0
  6. package/dist/bin/attio.d.ts.map +1 -0
  7. package/dist/bin/attio.js +40 -0
  8. package/dist/bin/attio.js.map +1 -0
  9. package/dist/bundle/agent-DYTWDBTT.js +37 -0
  10. package/dist/bundle/all-profiles-LZDKPHN2.js +320 -0
  11. package/dist/bundle/anthropic-BF72H77D.js +91 -0
  12. package/dist/bundle/app-server-H57FZJX5.js +249 -0
  13. package/dist/bundle/attio.js +183 -0
  14. package/dist/bundle/bun-WO77T4LG.js +169 -0
  15. package/dist/bundle/bun-sqlite-2BP7JDVO.js +76 -0
  16. package/dist/bundle/chunk-2E6JGBM5.js +1392 -0
  17. package/dist/bundle/chunk-34FJ26K2.js +54 -0
  18. package/dist/bundle/chunk-3I2FGNWO.js +23 -0
  19. package/dist/bundle/chunk-3NVOKVRY.js +42148 -0
  20. package/dist/bundle/chunk-3YFDZSM3.js +37 -0
  21. package/dist/bundle/chunk-4SMGM2Q6.js +274 -0
  22. package/dist/bundle/chunk-4STBJZR4.js +3571 -0
  23. package/dist/bundle/chunk-5K3FGXZH.js +46 -0
  24. package/dist/bundle/chunk-6ALPRBNV.js +100 -0
  25. package/dist/bundle/chunk-6NDJDDSQ.js +2000 -0
  26. package/dist/bundle/chunk-6SK3YB2B.js +218 -0
  27. package/dist/bundle/chunk-76RRELCU.js +65310 -0
  28. package/dist/bundle/chunk-7MXCUMHG.js +18 -0
  29. package/dist/bundle/chunk-7ZUOI3HY.js +73 -0
  30. package/dist/bundle/chunk-AMUONYQR.js +106 -0
  31. package/dist/bundle/chunk-ASCUOOLO.js +53 -0
  32. package/dist/bundle/chunk-BUGROVF3.js +72 -0
  33. package/dist/bundle/chunk-CHZ26CW5.js +9578 -0
  34. package/dist/bundle/chunk-CMO5ND3Y.js +794 -0
  35. package/dist/bundle/chunk-D72URWJE.js +532 -0
  36. package/dist/bundle/chunk-DF2IIO32.js +12645 -0
  37. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  38. package/dist/bundle/chunk-DQ6P3R4B.js +170 -0
  39. package/dist/bundle/chunk-DSRXCLPO.js +7 -0
  40. package/dist/bundle/chunk-EEPE3SOW.js +338 -0
  41. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  42. package/dist/bundle/chunk-EQGXEKSV.js +1197 -0
  43. package/dist/bundle/chunk-EQXT7KO4.js +388 -0
  44. package/dist/bundle/chunk-ERW2WOJT.js +24 -0
  45. package/dist/bundle/chunk-ESH2QGCA.js +372 -0
  46. package/dist/bundle/chunk-G3JTLVVL.js +771 -0
  47. package/dist/bundle/chunk-G6FQMVKW.js +52 -0
  48. package/dist/bundle/chunk-GBZ6JUXU.js +108 -0
  49. package/dist/bundle/chunk-GLHFJPYS.js +156 -0
  50. package/dist/bundle/chunk-GW4G5KLS.js +2333 -0
  51. package/dist/bundle/chunk-H7QDPW3D.js +78 -0
  52. package/dist/bundle/chunk-HG7FT3H3.js +319 -0
  53. package/dist/bundle/chunk-I3WS6V5H.js +188 -0
  54. package/dist/bundle/chunk-IDU4ESRZ.js +95 -0
  55. package/dist/bundle/chunk-IXCIQ7FZ.js +161 -0
  56. package/dist/bundle/chunk-J5P5VSRG.js +1233 -0
  57. package/dist/bundle/chunk-JA26HG7T.js +353 -0
  58. package/dist/bundle/chunk-JSTBW7F4.js +259 -0
  59. package/dist/bundle/chunk-KHDXRFJZ.js +185 -0
  60. package/dist/bundle/chunk-L5WS6CYZ.js +288 -0
  61. package/dist/bundle/chunk-LWJ4ZGUM.js +407 -0
  62. package/dist/bundle/chunk-MC2RQ2OB.js +38 -0
  63. package/dist/bundle/chunk-MNQACPXG.js +1332 -0
  64. package/dist/bundle/chunk-MOSH2KPD.js +358 -0
  65. package/dist/bundle/chunk-MRREDVPY.js +733 -0
  66. package/dist/bundle/chunk-MT2ZUZRA.js +1028 -0
  67. package/dist/bundle/chunk-O4A33Y54.js +29 -0
  68. package/dist/bundle/chunk-OBXDRUO4.js +63 -0
  69. package/dist/bundle/chunk-OFR3YYT6.js +6848 -0
  70. package/dist/bundle/chunk-P4U6AGWD.js +41 -0
  71. package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
  72. package/dist/bundle/chunk-PMP37KLR.js +142 -0
  73. package/dist/bundle/chunk-Q3JCUUOR.js +80 -0
  74. package/dist/bundle/chunk-Q7BSTQ3T.js +633 -0
  75. package/dist/bundle/chunk-QLHDUYGE.js +16 -0
  76. package/dist/bundle/chunk-RU5J7DWY.js +988 -0
  77. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  78. package/dist/bundle/chunk-S7K2XFQB.js +95 -0
  79. package/dist/bundle/chunk-SQHDE3TC.js +230 -0
  80. package/dist/bundle/chunk-TF7ZGCOK.js +76 -0
  81. package/dist/bundle/chunk-V6BTAILB.js +4072 -0
  82. package/dist/bundle/chunk-VDMIJ3JW.js +50 -0
  83. package/dist/bundle/chunk-VW5F6FK3.js +206 -0
  84. package/dist/bundle/chunk-W6F2CQZ6.js +1068 -0
  85. package/dist/bundle/chunk-WARIIYSW.js +58 -0
  86. package/dist/bundle/chunk-WK7GLHHL.js +334 -0
  87. package/dist/bundle/chunk-X5S5KUSU.js +2788 -0
  88. package/dist/bundle/chunk-X6R74TWX.js +131 -0
  89. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  90. package/dist/bundle/chunk-XXLQNHKF.js +82 -0
  91. package/dist/bundle/chunk-XXOTX4M3.js +362 -0
  92. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  93. package/dist/bundle/chunk-ZDBTYBFR.js +66 -0
  94. package/dist/bundle/chunk-ZGADZ4CH.js +557 -0
  95. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  96. package/dist/bundle/command-contract-7M6EPH3D.js +37 -0
  97. package/dist/bundle/command-server-entry-MNVPYQZ3.js +166 -0
  98. package/dist/bundle/decode-MQNKNXLK.js +297 -0
  99. package/dist/bundle/definitions-FODOIPM2.js +43379 -0
  100. package/dist/bundle/dispatch-TAQ7635E.js +411 -0
  101. package/dist/bundle/dist-EM7KLEG4.js +7577 -0
  102. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  103. package/dist/bundle/echarts-6ZSUNO4L.js +42501 -0
  104. package/dist/bundle/embed-PHCCJJ5Z.js +38 -0
  105. package/dist/bundle/embedder-WLZZQTKZ.js +111 -0
  106. package/dist/bundle/failure-MR2XVHFP.js +25 -0
  107. package/dist/bundle/first-run-64LREHSV.js +29 -0
  108. package/dist/bundle/first-screen-YSCAZIYJ.js +37 -0
  109. package/dist/bundle/instructions-22GCKNR5.js +11 -0
  110. package/dist/bundle/mcp-CNV7F2XZ.js +167 -0
  111. package/dist/bundle/meeting-combined-YX3T5WJD.js +24 -0
  112. package/dist/bundle/meeting-model-JWDTCGLZ.js +25 -0
  113. package/dist/bundle/meeting-semantic-375GYPZQ.js +22 -0
  114. package/dist/bundle/node-ITDTNRRZ.js +176 -0
  115. package/dist/bundle/node-KM3CUABH.js +2340 -0
  116. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  117. package/dist/bundle/node-sqlite-IRAGRMEZ.js +74 -0
  118. package/dist/bundle/oauth-CACOQJEL.js +20 -0
  119. package/dist/bundle/open-HU4KHKDR.js +23 -0
  120. package/dist/bundle/openai-JQUPAVKX.js +238 -0
  121. package/dist/bundle/process-QS5OHEUK.js +91 -0
  122. package/dist/bundle/program-QLCUCR76.js +33428 -0
  123. package/dist/bundle/prompt-VA5MKXJU.js +17 -0
  124. package/dist/bundle/recognize-JGA5IVKC.js +26 -0
  125. package/dist/bundle/remote-NPY2KZQ4.js +31 -0
  126. package/dist/bundle/rerank-4H2QR4XU.js +52 -0
  127. package/dist/bundle/schemas-THAI3G5S.js +21410 -0
  128. package/dist/bundle/serve-UH46SZQG.js +199 -0
  129. package/dist/bundle/server-6H7JS6SU.js +212 -0
  130. package/dist/bundle/server-SR52KBL3.js +79 -0
  131. package/dist/bundle/sqlite-runtime-EJWEUTBR.js +20 -0
  132. package/dist/bundle/state-34B6AUQZ.js +36 -0
  133. package/dist/bundle/store-3R4ILTCJ.js +177 -0
  134. package/dist/bundle/store-XSE35P3U.js +291 -0
  135. package/dist/bundle/store-maintenance-command-ABJARLI4.js +66 -0
  136. package/dist/bundle/surface-NOTIEJB5.js +65 -0
  137. package/dist/commands/api.d.ts +12 -0
  138. package/dist/commands/api.d.ts.map +1 -0
  139. package/dist/commands/api.js +27 -0
  140. package/dist/commands/api.js.map +1 -0
  141. package/dist/commands/crm.d.ts +4 -0
  142. package/dist/commands/crm.d.ts.map +1 -0
  143. package/dist/commands/crm.js +66 -0
  144. package/dist/commands/crm.js.map +1 -0
  145. package/dist/commands/session.d.ts +7 -0
  146. package/dist/commands/session.d.ts.map +1 -0
  147. package/dist/commands/session.js +22 -0
  148. package/dist/commands/session.js.map +1 -0
  149. package/dist/config.d.ts +14 -0
  150. package/dist/config.d.ts.map +1 -0
  151. package/dist/config.js +14 -0
  152. package/dist/config.js.map +1 -0
  153. package/dist/context.d.ts +37 -0
  154. package/dist/context.d.ts.map +1 -0
  155. package/dist/context.js +31 -0
  156. package/dist/context.js.map +1 -0
  157. package/dist/generated/definitions.d.ts +3 -0
  158. package/dist/generated/definitions.d.ts.map +1 -0
  159. package/dist/generated/definitions.js +43375 -0
  160. package/dist/generated/definitions.js.map +1 -0
  161. package/dist/generated/manifest.d.ts +6 -0
  162. package/dist/generated/manifest.d.ts.map +1 -0
  163. package/dist/generated/manifest.js +5158 -0
  164. package/dist/generated/manifest.js.map +1 -0
  165. package/dist/generated/schemas.d.ts +383 -0
  166. package/dist/generated/schemas.d.ts.map +1 -0
  167. package/dist/generated/schemas.js +21196 -0
  168. package/dist/generated/schemas.js.map +1 -0
  169. package/dist/generated/types.d.ts +10166 -0
  170. package/dist/generated/types.d.ts.map +1 -0
  171. package/dist/generated/types.js +5 -0
  172. package/dist/generated/types.js.map +1 -0
  173. package/dist/generated/wirecat-config.d.ts +15 -0
  174. package/dist/generated/wirecat-config.d.ts.map +1 -0
  175. package/dist/generated/wirecat-config.js +333 -0
  176. package/dist/generated/wirecat-config.js.map +1 -0
  177. package/dist/hooks.d.ts +3 -0
  178. package/dist/hooks.d.ts.map +1 -0
  179. package/dist/hooks.js +7 -0
  180. package/dist/hooks.js.map +1 -0
  181. package/dist/identity.d.ts +33 -0
  182. package/dist/identity.d.ts.map +1 -0
  183. package/dist/identity.js +31 -0
  184. package/dist/identity.js.map +1 -0
  185. package/dist/index.d.ts +3 -0
  186. package/dist/index.d.ts.map +1 -0
  187. package/dist/index.js +3 -0
  188. package/dist/index.js.map +1 -0
  189. package/dist/program.d.ts +6 -0
  190. package/dist/program.d.ts.map +1 -0
  191. package/dist/program.js +54 -0
  192. package/dist/program.js.map +1 -0
  193. package/dist/version.d.ts +2 -0
  194. package/dist/version.d.ts.map +1 -0
  195. package/dist/version.js +2 -0
  196. package/dist/version.js.map +1 -0
  197. package/dist/wcat.d.ts +3 -0
  198. package/dist/wcat.d.ts.map +1 -0
  199. package/dist/wcat.js +4 -0
  200. package/dist/wcat.js.map +1 -0
  201. package/package.json +87 -4
  202. package/skills/attio-cli/SKILL.md +58 -0
  203. package/skills/attio-cli/references/api/api-activities.md +62 -0
  204. package/skills/attio-cli/references/api/api-activity-records.md +96 -0
  205. package/skills/attio-cli/references/api/api-attributes.md +148 -0
  206. package/skills/attio-cli/references/api/api-call-recordings.md +53 -0
  207. package/skills/attio-cli/references/api/api-comments.md +36 -0
  208. package/skills/attio-cli/references/api/api-emails.md +23 -0
  209. package/skills/attio-cli/references/api/api-entries.md +127 -0
  210. package/skills/attio-cli/references/api/api-files.md +63 -0
  211. package/skills/attio-cli/references/api/api-lists.md +44 -0
  212. package/skills/attio-cli/references/api/api-meetings.md +82 -0
  213. package/skills/attio-cli/references/api/api-meta.md +8 -0
  214. package/skills/attio-cli/references/api/api-notes.md +64 -0
  215. package/skills/attio-cli/references/api/api-objects.md +55 -0
  216. package/skills/attio-cli/references/api/api-records.md +168 -0
  217. package/skills/attio-cli/references/api/api-sequences.md +15 -0
  218. package/skills/attio-cli/references/api/api-sql.md +15 -0
  219. package/skills/attio-cli/references/api/api-tasks.md +67 -0
  220. package/skills/attio-cli/references/api/api-threads.md +35 -0
  221. package/skills/attio-cli/references/api/api-transcripts.md +17 -0
  222. package/skills/attio-cli/references/api/api-views.md +133 -0
  223. package/skills/attio-cli/references/api/api-webhooks.md +62 -0
  224. package/skills/attio-cli/references/api/api-workspace-blocklist.md +39 -0
  225. package/skills/attio-cli/references/api/api-workspace-members.md +19 -0
  226. package/skills/attio-cli/references/api.md +35 -0
@@ -0,0 +1,142 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ executableEnvironment,
5
+ executableOnPath
6
+ } from "./chunk-5K3FGXZH.js";
7
+ import {
8
+ require_cross_spawn
9
+ } from "./chunk-D72URWJE.js";
10
+ import {
11
+ loadConfigFile,
12
+ saveConfigFile
13
+ } from "./chunk-X5S5KUSU.js";
14
+ import {
15
+ number,
16
+ object,
17
+ optional,
18
+ string
19
+ } from "./chunk-S4UUN6LD.js";
20
+ import {
21
+ __name,
22
+ __toESM
23
+ } from "./chunk-ZVVMGPBJ.js";
24
+
25
+ // node_modules/.pnpm/@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/update/index.js
26
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
27
+ import { existsSync } from "node:fs";
28
+ var updateCommand = /* @__PURE__ */ __name((installer, packageName) => {
29
+ const target = `${packageName}@latest`;
30
+ switch (installer) {
31
+ // pnpm 11 installs only versions a day old (minimumReleaseAge 1440); a fix must reach users the day it ships.
32
+ // Only the package's own scope is exempt — every other dependency keeps the wait.
33
+ case "pnpm":
34
+ return ["pnpm", "add", "-g", target, `--config.minimumReleaseAgeExclude=${ownScope(packageName)}`];
35
+ case "npm":
36
+ return ["npm", "install", "-g", target];
37
+ case "bun":
38
+ return ["bun", "add", "-g", target];
39
+ default:
40
+ return void 0;
41
+ }
42
+ }, "updateCommand");
43
+ var ownScope = /* @__PURE__ */ __name((packageName) => packageName.startsWith("@") ? `${packageName.split("/", 1)[0]}/*` : packageName, "ownScope");
44
+ var isNewer = /* @__PURE__ */ __name((candidate, current) => {
45
+ const parse = /* @__PURE__ */ __name((version) => /^\d+\.\d+\.\d+$/.test(version) ? version.split(".").map(Number) : void 0, "parse");
46
+ const a = parse(candidate);
47
+ const b = parse(current);
48
+ if (!a || !b)
49
+ return false;
50
+ for (let i = 0; i < 3; i++) {
51
+ if (a[i] !== b[i])
52
+ return a[i] > b[i];
53
+ }
54
+ return false;
55
+ }, "isNewer");
56
+ var latestVersion = /* @__PURE__ */ __name(async (packageName, fetch, { timeoutMs = 1e3 } = {}) => {
57
+ try {
58
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
59
+ signal: AbortSignal.timeout(timeoutMs),
60
+ headers: { accept: "application/json" }
61
+ });
62
+ if (!response.ok)
63
+ return void 0;
64
+ const { version } = await response.json();
65
+ return typeof version === "string" ? version : void 0;
66
+ } catch {
67
+ return void 0;
68
+ }
69
+ }, "latestVersion");
70
+ var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
71
+ var mayNotify = /* @__PURE__ */ __name(({ format, stderrIsTTY, quiet, enabled, installer, env, offVariables = [] }) => enabled && format === "pretty" && stderrIsTTY && !quiet && updateCommand(installer, "any") !== void 0 && !env.CI && !env.NO_UPDATE_NOTIFIER && offVariables.every((name) => !env[name]), "mayNotify");
72
+ var updateState = object({
73
+ checkedAt: number(),
74
+ latest: optional(string()),
75
+ /** When the skill hint (`cli-base/skill`) was last shown — the other daily notice kept in this file. */
76
+ skillHintAt: optional(number())
77
+ });
78
+ var readNoticeState = /* @__PURE__ */ __name((path) => {
79
+ try {
80
+ return loadConfigFile(path, updateState, () => ({ checkedAt: 0 }));
81
+ } catch {
82
+ return { checkedAt: 0 };
83
+ }
84
+ }, "readNoticeState");
85
+ var readUpdateState = /* @__PURE__ */ __name((path) => {
86
+ const state = readNoticeState(path);
87
+ return state.checkedAt > 0 ? state : void 0;
88
+ }, "readUpdateState");
89
+ var writeUpdateState = /* @__PURE__ */ __name((path, state) => {
90
+ try {
91
+ saveConfigFile(path, { ...readNoticeState(path), ...state });
92
+ } catch {
93
+ }
94
+ }, "writeUpdateState");
95
+ var checkIsDue = /* @__PURE__ */ __name((state, now) => state === void 0 || now - state.checkedAt >= CHECK_EVERY_MS, "checkIsDue");
96
+ var spawnPlan = /* @__PURE__ */ __name(([command, ...args], platform = process.platform, env = process.env, exists = existsSync) => ({ file: executableOnPath(command, env, platform, exists), args, shell: false }), "spawnPlan");
97
+ var runUpdate = /* @__PURE__ */ __name((argv) => {
98
+ const { file, args, shell } = spawnPlan(argv);
99
+ const { status, error } = import_cross_spawn.default.sync(file, args, {
100
+ stdio: ["inherit", 2, 2],
101
+ shell,
102
+ env: executableEnvironment(process.env)
103
+ });
104
+ if (error)
105
+ throw new Error(`could not start ${argv[0]}: ${error.message}`);
106
+ return status ?? 1;
107
+ }, "runUpdate");
108
+ var updateNotice = /* @__PURE__ */ __name(async ({ argv, packageName, command, upgradeCommand = "upgrade", version, statePath, fetch, now = Date.now, ...context }) => {
109
+ try {
110
+ const path = commandWords(argv).slice(0, 2);
111
+ if (path.includes("complete") || path.includes(upgradeCommand))
112
+ return void 0;
113
+ if (!mayNotify(context))
114
+ return void 0;
115
+ const at = now();
116
+ let state = readUpdateState(statePath);
117
+ if (checkIsDue(state, at)) {
118
+ const found = await latestVersion(packageName, fetch, { timeoutMs: 1e3 });
119
+ const seen = found ?? state?.latest;
120
+ state = seen ? { checkedAt: at, latest: seen } : { checkedAt: at };
121
+ writeUpdateState(statePath, state);
122
+ }
123
+ return state?.latest && isNewer(state.latest, version) ? `${command} ${state.latest} is out \u2014 you have ${version}. \`${command} ${upgradeCommand}\` installs it.` : void 0;
124
+ } catch {
125
+ return void 0;
126
+ }
127
+ }, "updateNotice");
128
+ var commandWords = /* @__PURE__ */ __name((argv) => {
129
+ const end = argv.indexOf("--");
130
+ return argv.slice(0, end < 0 ? void 0 : end).filter((word) => !word.startsWith("-"));
131
+ }, "commandWords");
132
+
133
+ export {
134
+ updateCommand,
135
+ isNewer,
136
+ latestVersion,
137
+ CHECK_EVERY_MS,
138
+ readNoticeState,
139
+ writeUpdateState,
140
+ runUpdate,
141
+ updateNotice
142
+ };
@@ -0,0 +1,80 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ timezoneOf,
5
+ zonedMoment
6
+ } from "./chunk-V6BTAILB.js";
7
+ import {
8
+ CliError
9
+ } from "./chunk-BUGROVF3.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-ZVVMGPBJ.js";
13
+
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/domain/moment.js
15
+ var calendarMoment = /* @__PURE__ */ __name((wanted, flag, { zone, end = false } = {}) => {
16
+ try {
17
+ return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
18
+ } catch (error) {
19
+ if (!(error instanceof CliError))
20
+ throw error;
21
+ const alternative = error.details?.alternative;
22
+ throw new CliError("validation_error", `${flag}: "${wanted}" is not a time${alternative ? ` \u2014 ${alternative}` : ""}`);
23
+ }
24
+ }, "calendarMoment");
25
+ var dayIn = /* @__PURE__ */ __name((at, zone) => new Intl.DateTimeFormat("en-CA", { timeZone: zone, year: "numeric", month: "2-digit", day: "2-digit" }).format(at), "dayIn");
26
+ var MINUTE = 6e4;
27
+ var YEAR = 365 * 24 * 60 * MINUTE;
28
+ var RELATIVE = /^(\d+)(m|h|d)$/;
29
+ var RELATIVE_MS = { m: MINUTE, h: 60 * MINUTE, d: 24 * 60 * MINUTE };
30
+ var DATE_ALONE = /^\d{4}-\d{2}-\d{2}$/;
31
+ var ZONED = /(?:Z|[+-]\d{2}:?\d{2})$/i;
32
+ var dayWord = /* @__PURE__ */ __name((word, zone, now) => {
33
+ const today = new Intl.DateTimeFormat("en-CA", { timeZone: zone }).format(now);
34
+ if (word === "today")
35
+ return today;
36
+ const date = /* @__PURE__ */ new Date(`${today}T00:00:00Z`);
37
+ date.setUTCDate(date.getUTCDate() - 1);
38
+ return date.toISOString().slice(0, 10);
39
+ }, "dayWord");
40
+ var readMoment = /* @__PURE__ */ __name((typed, flag, { zone, end = false, now = Date.now(), direction = -1 } = {}) => {
41
+ const wanted = typed.trim();
42
+ const [, amount, unit] = RELATIVE.exec(wanted) ?? [];
43
+ if (amount && unit)
44
+ return { time: now + direction * Number(amount) * (RELATIVE_MS[unit] ?? 0), local: false, dateAlone: false };
45
+ const word = wanted.toLowerCase();
46
+ const date = word === "today" || word === "yesterday" ? dayWord(word, timezoneOf(zone), now) : wanted;
47
+ if (!/^\d{4}-\d{2}-\d{2}/.test(date))
48
+ return void 0;
49
+ const iso = date.replace(/^(\d{4}-\d{2}-\d{2}) +(?=\d)/, "$1T");
50
+ return {
51
+ time: calendarMoment(iso, flag, { ...zone === void 0 ? {} : { zone }, end }),
52
+ local: !ZONED.test(iso),
53
+ dateAlone: DATE_ALONE.test(iso)
54
+ };
55
+ }, "readMoment");
56
+ var lead = /* @__PURE__ */ __name((ms) => ms === MINUTE ? "a minute" : ms === YEAR ? "a year" : `${Math.ceil(ms / MINUTE)} minutes`, "lead");
57
+ var aheadOf = /* @__PURE__ */ __name((reference, flag, now = Date.now(), options = {}) => {
58
+ const { refuseDate = false, soonest, latest, ...at } = options;
59
+ const read = readMoment(reference, flag, { ...at, now, direction: 1 });
60
+ if (read === void 0)
61
+ throw new CliError("validation_error", `${flag} takes an ISO 8601 time, today, or 30m, 2h, 3d from now \u2014 not "${reference.trim()}"`);
62
+ if (refuseDate && read.dateAlone)
63
+ throw new CliError("validation_error", DATE_ALONE.test(reference.trim()) ? `${flag} needs a time of day as well: ${reference.trim()}T09:00` : `${flag} needs a time of day as well, like 2026-11-20T09:00`);
64
+ if (soonest === 0 && read.time <= now)
65
+ throw new CliError("validation_error", `${flag} is in the past`);
66
+ if (soonest !== void 0 && soonest > 0 && read.time < now + soonest)
67
+ throw new CliError("validation_error", `${flag} has to be at least ${lead(soonest)} from now`);
68
+ if (latest !== void 0 && read.time > now + latest)
69
+ throw new CliError("validation_error", `${flag} can be at most ${lead(latest)} from now`);
70
+ return read.time;
71
+ }, "aheadOf");
72
+
73
+ export {
74
+ calendarMoment,
75
+ dayIn,
76
+ MINUTE,
77
+ YEAR,
78
+ readMoment,
79
+ aheadOf
80
+ };