@wirecat/yandex-disk-cli 0.0.0-stage → 0.1.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 (235) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +204 -0
  3. package/README.md +243 -2
  4. package/contracts/wirecat.json +1554 -0
  5. package/dist/bin/ydisk.d.ts +3 -0
  6. package/dist/bin/ydisk.d.ts.map +1 -0
  7. package/dist/bin/ydisk.js +40 -0
  8. package/dist/bin/ydisk.js.map +1 -0
  9. package/dist/bundle/all-profiles-4OLZF3RT.js +279 -0
  10. package/dist/bundle/anthropic-DKB4OJXZ.js +91 -0
  11. package/dist/bundle/app-server-G4545SSV.js +247 -0
  12. package/dist/bundle/bun-RXEQKFED.js +169 -0
  13. package/dist/bundle/bun-sqlite-VHT5LN7U.js +76 -0
  14. package/dist/bundle/chunk-2BITUXGC.js +12289 -0
  15. package/dist/bundle/chunk-2CLWDQKA.js +39330 -0
  16. package/dist/bundle/chunk-2JFDOPKA.js +9575 -0
  17. package/dist/bundle/chunk-3GVI2MAO.js +106 -0
  18. package/dist/bundle/chunk-3SZBWBMI.js +131 -0
  19. package/dist/bundle/chunk-44VSEXW6.js +4054 -0
  20. package/dist/bundle/chunk-4YPRRQBE.js +95 -0
  21. package/dist/bundle/chunk-5COYRL5B.js +379 -0
  22. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  23. package/dist/bundle/chunk-5DM7DIZL.js +1402 -0
  24. package/dist/bundle/chunk-6R2DVTVZ.js +24 -0
  25. package/dist/bundle/chunk-762BS35H.js +2787 -0
  26. package/dist/bundle/chunk-AG64V7AB.js +1233 -0
  27. package/dist/bundle/chunk-BC5HGIXB.js +334 -0
  28. package/dist/bundle/chunk-BH7LFEX7.js +36 -0
  29. package/dist/bundle/chunk-BLNPGY7N.js +53 -0
  30. package/dist/bundle/chunk-CNIA2LJF.js +372 -0
  31. package/dist/bundle/chunk-COSXMDC7.js +230 -0
  32. package/dist/bundle/chunk-D72URWJE.js +532 -0
  33. package/dist/bundle/chunk-D7FO33KU.js +785 -0
  34. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  35. package/dist/bundle/chunk-DJH26PQ3.js +1396 -0
  36. package/dist/bundle/chunk-DJPT7IUC.js +64567 -0
  37. package/dist/bundle/chunk-DTMSCZDW.js +209 -0
  38. package/dist/bundle/chunk-E6LGZ5LX.js +16 -0
  39. package/dist/bundle/chunk-E6YRIHS5.js +92 -0
  40. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  41. package/dist/bundle/chunk-F3DDSZTF.js +78 -0
  42. package/dist/bundle/chunk-F4WWTQNL.js +188 -0
  43. package/dist/bundle/chunk-FDDAUASC.js +1028 -0
  44. package/dist/bundle/chunk-FMNPG6N2.js +170 -0
  45. package/dist/bundle/chunk-FOKJ4POB.js +274 -0
  46. package/dist/bundle/chunk-G22C7JG6.js +731 -0
  47. package/dist/bundle/chunk-GA442SYZ.js +161 -0
  48. package/dist/bundle/chunk-GEBSW7UK.js +6848 -0
  49. package/dist/bundle/chunk-GGRKWAOK.js +594 -0
  50. package/dist/bundle/chunk-HHINRNZA.js +788 -0
  51. package/dist/bundle/chunk-HUZCL33L.js +128 -0
  52. package/dist/bundle/chunk-IALSIQVT.js +142 -0
  53. package/dist/bundle/chunk-IOXR2QBX.js +398 -0
  54. package/dist/bundle/chunk-J5CXR6VX.js +63 -0
  55. package/dist/bundle/chunk-J5PWSTOX.js +82 -0
  56. package/dist/bundle/chunk-J7BVAEHR.js +364 -0
  57. package/dist/bundle/chunk-JH46HMZW.js +1334 -0
  58. package/dist/bundle/chunk-JOBO7F6W.js +52 -0
  59. package/dist/bundle/chunk-JXZ5B3L5.js +2333 -0
  60. package/dist/bundle/chunk-KBIAMDZN.js +66 -0
  61. package/dist/bundle/chunk-KFVDL2QS.js +146 -0
  62. package/dist/bundle/chunk-LNHTLSR5.js +288 -0
  63. package/dist/bundle/chunk-M24RAKMJ.js +58 -0
  64. package/dist/bundle/chunk-MDQ57Q3H.js +1197 -0
  65. package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
  66. package/dist/bundle/chunk-MLXQ4X5L.js +206 -0
  67. package/dist/bundle/chunk-NQAKARHE.js +54 -0
  68. package/dist/bundle/chunk-OF7VVUDQ.js +23 -0
  69. package/dist/bundle/chunk-OQVPE3XK.js +324 -0
  70. package/dist/bundle/chunk-OR3QG7UR.js +259 -0
  71. package/dist/bundle/chunk-OUUYVROP.js +76 -0
  72. package/dist/bundle/chunk-PQBAM64O.js +168 -0
  73. package/dist/bundle/chunk-PYVIA7WF.js +88 -0
  74. package/dist/bundle/chunk-Q6HK3PHE.js +72 -0
  75. package/dist/bundle/chunk-QB3KECV2.js +218 -0
  76. package/dist/bundle/chunk-QGWXSFYN.js +73 -0
  77. package/dist/bundle/chunk-RC5QAAAE.js +29 -0
  78. package/dist/bundle/chunk-RMJ26HLB.js +18 -0
  79. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  80. package/dist/bundle/chunk-T7ZUDA4C.js +72 -0
  81. package/dist/bundle/chunk-TRCSMVV5.js +72 -0
  82. package/dist/bundle/chunk-UD2BQEKA.js +46 -0
  83. package/dist/bundle/chunk-V4TL55GS.js +1068 -0
  84. package/dist/bundle/chunk-VJNWN5VU.js +4072 -0
  85. package/dist/bundle/chunk-VRRNBLMA.js +1227 -0
  86. package/dist/bundle/chunk-WUCMMNFJ.js +771 -0
  87. package/dist/bundle/chunk-XDESE3NY.js +44 -0
  88. package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
  89. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  90. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  91. package/dist/bundle/chunk-Z2QEON7B.js +2275 -0
  92. package/dist/bundle/chunk-ZMJ56GME.js +7 -0
  93. package/dist/bundle/chunk-ZTSB3D7Q.js +100 -0
  94. package/dist/bundle/chunk-ZVJWD3FK.js +38 -0
  95. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  96. package/dist/bundle/command-contract-YIOYGPJA.js +40 -0
  97. package/dist/bundle/command-server-entry-MHBQDXS4.js +169 -0
  98. package/dist/bundle/decode-NUGJIOUW.js +297 -0
  99. package/dist/bundle/definitions-AILHKEQT.js +2005 -0
  100. package/dist/bundle/dispatch-5LC4UEGY.js +411 -0
  101. package/dist/bundle/dist-4I2W6X2I.js +7577 -0
  102. package/dist/bundle/echarts-MHSH6PGC.js +42501 -0
  103. package/dist/bundle/embed-ZDXTHHYS.js +38 -0
  104. package/dist/bundle/embedder-XFEELFUL.js +111 -0
  105. package/dist/bundle/failure-5S7VPBYK.js +25 -0
  106. package/dist/bundle/first-run-JHCHT3RJ.js +29 -0
  107. package/dist/bundle/first-screen-FHGQ6QRV.js +40 -0
  108. package/dist/bundle/instructions-WKSMBUFX.js +11 -0
  109. package/dist/bundle/mcp-HS2ZDUVR.js +167 -0
  110. package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
  111. package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
  112. package/dist/bundle/meeting-combined-K4U4NYRZ.js +25 -0
  113. package/dist/bundle/meeting-model-KCEG6Y5O.js +26 -0
  114. package/dist/bundle/meeting-semantic-VYGSV3H6.js +22 -0
  115. package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
  116. package/dist/bundle/node-CM6NC6UE.js +176 -0
  117. package/dist/bundle/node-KM3CUABH.js +2340 -0
  118. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  119. package/dist/bundle/node-sqlite-5YDQ3LIJ.js +74 -0
  120. package/dist/bundle/notes-search-PGO7KM2U.js +62 -0
  121. package/dist/bundle/oauth-NY4C5UCK.js +20 -0
  122. package/dist/bundle/open-YNUTA6ZE.js +23 -0
  123. package/dist/bundle/openai-4CVT5PHH.js +241 -0
  124. package/dist/bundle/process-2XT3TL27.js +91 -0
  125. package/dist/bundle/program-FMIVF5T6.js +31904 -0
  126. package/dist/bundle/prompt-VNWY3H6S.js +17 -0
  127. package/dist/bundle/recognize-JS4PBPSZ.js +26 -0
  128. package/dist/bundle/remote-RCLFH4V2.js +32 -0
  129. package/dist/bundle/rerank-EG6VKYGO.js +52 -0
  130. package/dist/bundle/schemas-ED2LHKXK.js +645 -0
  131. package/dist/bundle/serve-AHG25QXB.js +199 -0
  132. package/dist/bundle/server-5FTB7WM3.js +78 -0
  133. package/dist/bundle/server-JNZVSAZE.js +209 -0
  134. package/dist/bundle/sqlite-runtime-XSZOAQPF.js +20 -0
  135. package/dist/bundle/state-XGVAJFF7.js +36 -0
  136. package/dist/bundle/store-OHSCWZEV.js +177 -0
  137. package/dist/bundle/store-PKSPKJXL.js +293 -0
  138. package/dist/bundle/store-maintenance-command-KAWGBSWK.js +69 -0
  139. package/dist/bundle/ydisk.js +183 -0
  140. package/dist/commands/api.d.ts +9 -0
  141. package/dist/commands/api.d.ts.map +1 -0
  142. package/dist/commands/api.js +59 -0
  143. package/dist/commands/api.js.map +1 -0
  144. package/dist/commands/comments.d.ts +3 -0
  145. package/dist/commands/comments.d.ts.map +1 -0
  146. package/dist/commands/comments.js +114 -0
  147. package/dist/commands/comments.js.map +1 -0
  148. package/dist/commands/files.d.ts +3 -0
  149. package/dist/commands/files.d.ts.map +1 -0
  150. package/dist/commands/files.js +272 -0
  151. package/dist/commands/files.js.map +1 -0
  152. package/dist/commands/library.d.ts +13 -0
  153. package/dist/commands/library.d.ts.map +1 -0
  154. package/dist/commands/library.js +118 -0
  155. package/dist/commands/library.js.map +1 -0
  156. package/dist/commands/session.d.ts +3 -0
  157. package/dist/commands/session.d.ts.map +1 -0
  158. package/dist/commands/session.js +99 -0
  159. package/dist/commands/session.js.map +1 -0
  160. package/dist/config.d.ts +18 -0
  161. package/dist/config.d.ts.map +1 -0
  162. package/dist/config.js +62 -0
  163. package/dist/config.js.map +1 -0
  164. package/dist/context.d.ts +80 -0
  165. package/dist/context.d.ts.map +1 -0
  166. package/dist/context.js +77 -0
  167. package/dist/context.js.map +1 -0
  168. package/dist/generated/definitions.d.ts +3 -0
  169. package/dist/generated/definitions.d.ts.map +1 -0
  170. package/dist/generated/definitions.js +2001 -0
  171. package/dist/generated/definitions.js.map +1 -0
  172. package/dist/generated/manifest.d.ts +6 -0
  173. package/dist/generated/manifest.d.ts.map +1 -0
  174. package/dist/generated/manifest.js +1473 -0
  175. package/dist/generated/manifest.js.map +1 -0
  176. package/dist/generated/schemas.d.ts +127 -0
  177. package/dist/generated/schemas.d.ts.map +1 -0
  178. package/dist/generated/schemas.js +545 -0
  179. package/dist/generated/schemas.js.map +1 -0
  180. package/dist/generated/types.d.ts +829 -0
  181. package/dist/generated/types.d.ts.map +1 -0
  182. package/dist/generated/types.js +5 -0
  183. package/dist/generated/types.js.map +1 -0
  184. package/dist/identity.d.ts +10 -0
  185. package/dist/identity.d.ts.map +1 -0
  186. package/dist/identity.js +33 -0
  187. package/dist/identity.js.map +1 -0
  188. package/dist/index.d.ts +3 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +3 -0
  191. package/dist/index.js.map +1 -0
  192. package/dist/program.d.ts +6 -0
  193. package/dist/program.d.ts.map +1 -0
  194. package/dist/program.js +65 -0
  195. package/dist/program.js.map +1 -0
  196. package/dist/sample/comments.d.ts +61 -0
  197. package/dist/sample/comments.d.ts.map +1 -0
  198. package/dist/sample/comments.js +39 -0
  199. package/dist/sample/comments.js.map +1 -0
  200. package/dist/sample/records.d.ts +16 -0
  201. package/dist/sample/records.d.ts.map +1 -0
  202. package/dist/sample/records.js +22 -0
  203. package/dist/sample/records.js.map +1 -0
  204. package/dist/sample/transport.d.ts +42 -0
  205. package/dist/sample/transport.d.ts.map +1 -0
  206. package/dist/sample/transport.js +153 -0
  207. package/dist/sample/transport.js.map +1 -0
  208. package/dist/version.d.ts +2 -0
  209. package/dist/version.d.ts.map +1 -0
  210. package/dist/version.js +2 -0
  211. package/dist/version.js.map +1 -0
  212. package/dist/wcat.d.ts +3 -0
  213. package/dist/wcat.d.ts.map +1 -0
  214. package/dist/wcat.js +4 -0
  215. package/dist/wcat.js.map +1 -0
  216. package/dist/yandex/source.d.ts +39 -0
  217. package/dist/yandex/source.d.ts.map +1 -0
  218. package/dist/yandex/source.js +189 -0
  219. package/dist/yandex/source.js.map +1 -0
  220. package/dist/yandex/transport.d.ts +41 -0
  221. package/dist/yandex/transport.d.ts.map +1 -0
  222. package/dist/yandex/transport.js +152 -0
  223. package/dist/yandex/transport.js.map +1 -0
  224. package/dist/yandex/writes.d.ts +27 -0
  225. package/dist/yandex/writes.d.ts.map +1 -0
  226. package/dist/yandex/writes.js +61 -0
  227. package/dist/yandex/writes.js.map +1 -0
  228. package/package.json +88 -4
  229. package/skills/yandex-disk-cli/SKILL.md +46 -0
  230. package/skills/yandex-disk-cli/references/api/api-disk-operations-operation-id.md +13 -0
  231. package/skills/yandex-disk-cli/references/api/api-disk-public-resources.md +50 -0
  232. package/skills/yandex-disk-cli/references/api/api-disk-resources.md +171 -0
  233. package/skills/yandex-disk-cli/references/api/api-disk-trash-resources.md +48 -0
  234. package/skills/yandex-disk-cli/references/api/api-disk.md +13 -0
  235. package/skills/yandex-disk-cli/references/api.md +17 -0
@@ -0,0 +1,785 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ isCliFailure,
5
+ isStoreDamage
6
+ } from "./chunk-TRCSMVV5.js";
7
+ import {
8
+ refuseOwnerStoreInTests
9
+ } from "./chunk-NQAKARHE.js";
10
+ import {
11
+ isoTime,
12
+ reference
13
+ } from "./chunk-AG64V7AB.js";
14
+ import {
15
+ array,
16
+ boolean,
17
+ description,
18
+ integer,
19
+ maxLength,
20
+ minLength,
21
+ minValue,
22
+ nullable,
23
+ number,
24
+ optional,
25
+ picklist,
26
+ pipe,
27
+ record,
28
+ strictObject,
29
+ string,
30
+ unknown
31
+ } from "./chunk-S4UUN6LD.js";
32
+ import {
33
+ CliError
34
+ } from "./chunk-T7ZUDA4C.js";
35
+ import {
36
+ __name
37
+ } from "./chunk-ZVVMGPBJ.js";
38
+
39
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/tasks/model.js
40
+ var TASK_KINDS = ["question", "request", "mention", "promise"];
41
+ var TASK_STATES = ["open", "todo", "in_progress", "done", "dismissed"];
42
+ var CLOSED_STATES = ["done", "dismissed"];
43
+ var TASK_ORIGINS = ["rule", "agent", "owner"];
44
+ var TASK_VERDICTS = ["useful", "not_useful"];
45
+ var isClosedState = /* @__PURE__ */ __name((state) => CLOSED_STATES.includes(state), "isClosedState");
46
+ function closeTask(task, state, by, at, reason) {
47
+ if (isClosedState(task.state))
48
+ throw new CliError("validation_error", `task ${task.id} is already ${task.state}`, { reason: "task.closed" });
49
+ const { claimedBy: _by, claimedUntil: _until, ...unclaimed } = task;
50
+ return { ...unclaimed, state, closedAt: at, closedBy: by, ...reason === void 0 ? {} : { reason } };
51
+ }
52
+ __name(closeTask, "closeTask");
53
+
54
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/tasks/priority.js
55
+ var PRIORITY_LABELS = ["low", "medium", "high", "critical"];
56
+ var MIDDLE = { low: 0.125, medium: 0.375, high: 0.625, critical: 0.875 };
57
+ var LEGACY_PRIORITY_SCORES = [0.875, 0.625, 0.375, 0.1875, 0.0625];
58
+ var priorityLabel = /* @__PURE__ */ __name((score) => score === null ? null : PRIORITY_LABELS[Math.min(3, Math.max(0, Math.floor(score * 4)))], "priorityLabel");
59
+ var priorityBand = /* @__PURE__ */ __name((label) => {
60
+ const at = PRIORITY_LABELS.indexOf(label);
61
+ return { from: at / 4, to: (at + 1) / 4 };
62
+ }, "priorityBand");
63
+ var legacyPriority = /* @__PURE__ */ __name((score) => score === null ? null : score < 0.125 ? 4 : 3 - PRIORITY_LABELS.indexOf(priorityLabel(score)), "legacyPriority");
64
+ var checkedScore = /* @__PURE__ */ __name((score) => {
65
+ if (!Number.isFinite(score) || score < 0 || score > 1)
66
+ throw new CliError("validation_error", "a priority score is 0 to 1");
67
+ return score;
68
+ }, "checkedScore");
69
+ var priorityOf = /* @__PURE__ */ __name((value) => {
70
+ const word = value.trim().toLowerCase();
71
+ if (word === "none")
72
+ return null;
73
+ if (PRIORITY_LABELS.includes(word))
74
+ return MIDDLE[word];
75
+ if (/^[0-4]$/.test(word))
76
+ return LEGACY_PRIORITY_SCORES[Number(word)];
77
+ if (/^(0?\.\d+|[01]\.\d*)$/.test(word) && Number(word) <= 1)
78
+ return Number(word);
79
+ throw new CliError("validation_error", `a priority is ${PRIORITY_LABELS.join(", ")}, none, or a score from 0.0 to 1.0 with its decimal point; 0 (urgent) \u2026 4 (low) still work as critical, high, medium, low, low`);
80
+ }, "priorityOf");
81
+ var priorityOption = /* @__PURE__ */ __name((value) => priorityOf(value) ?? "none", "priorityOption");
82
+
83
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/tasks/service.js
84
+ function createTaskService({ store, now = /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "now"), newId = /* @__PURE__ */ __name(() => crypto.randomUUID(), "newId") }) {
85
+ async function find(id2) {
86
+ const task = await store.get(id2);
87
+ if (!task)
88
+ throw new CliError("not_found", `no task ${id2}`);
89
+ return task;
90
+ }
91
+ __name(find, "find");
92
+ return {
93
+ /**
94
+ * A rule never makes a second task from a source it has seen, whatever that task's state, so a
95
+ * dismissed one stays dismissed — nor from a message attached or merged into a task. A person or an agent may
96
+ * add a task of another kind to it. A task a rule opens goes through the host's duplicate check.
97
+ */
98
+ async add(input) {
99
+ const rule = input.origin === "rule";
100
+ const existing = await store.findBySource(input.account, input.source, rule ? { linked: true } : void 0);
101
+ const same = rule ? existing[0] : existing.find((task2) => task2.kind === input.kind);
102
+ if (same)
103
+ return { task: same, created: false };
104
+ const task = { ...input, id: newId(), state: "open", createdAt: now() };
105
+ await store.insert(task);
106
+ if (!rule || !store.reviewDuplicates)
107
+ return { task, created: true };
108
+ return { task, created: true, review: await store.reviewDuplicates(task.id) };
109
+ },
110
+ async close(id2, { as, by, reason }) {
111
+ const task = closeTask(await find(id2), as, by, now(), reason);
112
+ await store.update(task);
113
+ return task;
114
+ },
115
+ list: /* @__PURE__ */ __name((filter = {}) => store.list(filter), "list"),
116
+ async stats(filter = {}) {
117
+ const byGroup = /* @__PURE__ */ new Map();
118
+ for (const task of await store.list(filter))
119
+ byGroup.set(task.group, [...byGroup.get(task.group) ?? [], task]);
120
+ return [...byGroup].map(([group, tasks]) => {
121
+ const open = tasks.filter((task) => !isClosedState(task.state));
122
+ const closeMs = tasks.flatMap((task) => task.closedAt ? [task.closedAt.getTime() - task.createdAt.getTime()] : []);
123
+ const oldestOpenAt = open.map((task) => task.createdAt).sort((a, b) => a.getTime() - b.getTime())[0];
124
+ return {
125
+ group,
126
+ open: open.length,
127
+ ...oldestOpenAt ? { oldestOpenAt } : {},
128
+ ...closeMs.length > 0 ? { medianCloseMs: median(closeMs) } : {}
129
+ };
130
+ });
131
+ }
132
+ };
133
+ }
134
+ __name(createTaskService, "createTaskService");
135
+ function median(values) {
136
+ const sorted = [...values].sort((a, b) => a - b);
137
+ const middle = Math.floor(sorted.length / 2);
138
+ const upper = sorted[middle] ?? 0;
139
+ return sorted.length % 2 === 1 ? upper : ((sorted[middle - 1] ?? 0) + upper) / 2;
140
+ }
141
+ __name(median, "median");
142
+
143
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/tasks/store.js
144
+ function matches(task, filter) {
145
+ return (filter.account === void 0 || task.account === filter.account) && (filter.state === void 0 || task.state === filter.state) && (filter.group === void 0 || task.group === filter.group) && (filter.kind === void 0 || task.kind === filter.kind) && (filter.createdBefore === void 0 || task.createdAt < filter.createdBefore);
146
+ }
147
+ __name(matches, "matches");
148
+
149
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/store/source-review.js
150
+ var SOURCE_REVIEW_KIND = "memory_source_review";
151
+ var SOURCE_REVIEW_CAUSES = ["changed", "outdated", "deleted", "contradicted"];
152
+ var ERASED_TEXT = "[source erased]";
153
+ var severity = /* @__PURE__ */ __name((cause) => SOURCE_REVIEW_CAUSES.indexOf(cause), "severity");
154
+ var graver = /* @__PURE__ */ __name((a, b) => severity(b) > severity(a) ? b : a, "graver");
155
+
156
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/entities/fields.js
157
+ var text = string();
158
+ var id = pipe(string(), minLength(1));
159
+ var time = isoTime;
160
+ var typedTime = pipe(string(), minLength(1), maxLength(64), description("an ISO 8601 date or time, in the computer's zone without one; or 30m, 2h, 7d ago"));
161
+ var count = pipe(number(), integer(), minValue(0));
162
+ var untrusted = optional(array(text));
163
+ var providerMetadata = optional(record(string(), unknown()));
164
+ var evidenceSource = strictObject({
165
+ ref: nullable(reference),
166
+ kind: text,
167
+ title: nullable(text),
168
+ sender: nullable(text),
169
+ at: nullable(time),
170
+ excerpt: nullable(text),
171
+ tool: nullable(text),
172
+ missing: boolean()
173
+ });
174
+ var sourceReview = nullable(strictObject({ id, cause: picklist(SOURCE_REVIEW_CAUSES) }));
175
+ var author = strictObject({
176
+ type: picklist(["person", "bot"]),
177
+ id,
178
+ name: nullable(text)
179
+ });
180
+
181
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/entities/knowledge-lists.js
182
+ var organization = strictObject({
183
+ id,
184
+ ref: reference,
185
+ kind: picklist(["company", "team", "family", "community"]),
186
+ name: text,
187
+ scope: picklist(["personal", "work"]),
188
+ created_at: time
189
+ });
190
+ var project = strictObject({
191
+ id,
192
+ ref: reference,
193
+ key: text,
194
+ name: text,
195
+ kind: picklist(["project", "inbox"]),
196
+ type: picklist(["work", "client", "personal", "oss", "other"]),
197
+ organization_id: nullable(id),
198
+ scope: picklist(["personal", "work"]),
199
+ created_at: time
200
+ });
201
+ var reminder = strictObject({
202
+ id,
203
+ task: text,
204
+ due_at: time,
205
+ timezone: text,
206
+ state: picklist(["pending", "leased", "delivered", "cancelled"]),
207
+ revision: number(),
208
+ receipt: nullable(text)
209
+ });
210
+
211
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/store/marks.js
212
+ import { readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
213
+ var damageMarkPath = /* @__PURE__ */ __name((store) => `${store}.damaged.json`, "damageMarkPath");
214
+ var healthMarkPath = /* @__PURE__ */ __name((store) => `${store}.health.json`, "healthMarkPath");
215
+ var journalMarkPath = /* @__PURE__ */ __name((store) => `${store}.journal.json`, "journalMarkPath");
216
+ var inodeOf = /* @__PURE__ */ __name((store) => statSync(store, { throwIfNoEntry: false })?.ino, "inodeOf");
217
+ var readJson = /* @__PURE__ */ __name((path) => {
218
+ try {
219
+ return JSON.parse(readFileSync(path, "utf8"));
220
+ } catch (error) {
221
+ if (error.code === "ENOENT")
222
+ return null;
223
+ throw error;
224
+ }
225
+ }, "readJson");
226
+ var ownerStoreInTests = /* @__PURE__ */ __name((store) => {
227
+ try {
228
+ refuseOwnerStoreInTests(store);
229
+ return false;
230
+ } catch {
231
+ return true;
232
+ }
233
+ }, "ownerStoreInTests");
234
+ var sqliteFailure = /* @__PURE__ */ __name((error) => isCliFailure(error) && error.details?.reason === "store.damaged" ? error.cause : error, "sqliteFailure");
235
+ var markStoreDamaged = /* @__PURE__ */ __name((error, { store, command, version, runId, now = Date.now }) => {
236
+ const failure = sqliteFailure(error);
237
+ if (!isStoreDamage(failure) || ownerStoreInTests(store))
238
+ return false;
239
+ const inode = inodeOf(store);
240
+ if (inode === void 0)
241
+ return false;
242
+ const mark = {
243
+ at: new Date(now()).toISOString(),
244
+ command,
245
+ ...version ? { cli_version: version } : {},
246
+ ...runId ? { run_id: runId } : {},
247
+ error: failure.message.slice(0, 500),
248
+ inode
249
+ };
250
+ try {
251
+ writeFileSync(damageMarkPath(store), `${JSON.stringify(mark, null, 2)}
252
+ `, { flag: "wx", mode: 384 });
253
+ return true;
254
+ } catch {
255
+ return false;
256
+ }
257
+ }, "markStoreDamaged");
258
+ var readDamageMark = /* @__PURE__ */ __name((store) => {
259
+ const path = damageMarkPath(store);
260
+ let mark;
261
+ try {
262
+ mark = readJson(path);
263
+ } catch {
264
+ return { at: "unknown", command: "unknown", error: `${path} cannot be read`, inode: inodeOf(store) ?? 0 };
265
+ }
266
+ if (mark === null)
267
+ return null;
268
+ if (mark.inode !== inodeOf(store)) {
269
+ clearDamageMark(store);
270
+ return null;
271
+ }
272
+ return mark;
273
+ }, "readDamageMark");
274
+ var clearDamageMark = /* @__PURE__ */ __name((store) => rmSync(damageMarkPath(store), { force: true }), "clearDamageMark");
275
+ var refuseDamagedStore = /* @__PURE__ */ __name((store, cli) => {
276
+ const mark = readDamageMark(store);
277
+ if (!mark)
278
+ return;
279
+ throw new CliError("configuration_error", `the store was found damaged at ${mark.at} by \`${mark.command}\` (${mark.error}), so nothing writes to it until it is recovered; \`${cli ?? "<cli>"} store recover\` says what is damaged and what to do`, { reason: "store.damaged" });
280
+ }, "refuseDamagedStore");
281
+ var markJournalLost = /* @__PURE__ */ __name((store, { seen, command, now = Date.now }) => {
282
+ if (ownerStoreInTests(store))
283
+ return;
284
+ const mark = { at: new Date(now()).toISOString(), command, seen };
285
+ try {
286
+ writeFileSync(journalMarkPath(store), `${JSON.stringify(mark, null, 2)}
287
+ `, { flag: "wx", mode: 384 });
288
+ } catch {
289
+ }
290
+ }, "markJournalLost");
291
+ var readJournalMark = /* @__PURE__ */ __name((store) => {
292
+ try {
293
+ return readJson(journalMarkPath(store));
294
+ } catch {
295
+ return null;
296
+ }
297
+ }, "readJournalMark");
298
+ var readHealthMark = /* @__PURE__ */ __name((store) => {
299
+ try {
300
+ return readJson(healthMarkPath(store));
301
+ } catch {
302
+ return null;
303
+ }
304
+ }, "readHealthMark");
305
+ var recordDeepCheck = /* @__PURE__ */ __name((store, health, { cli, version, schema, now = Date.now }) => {
306
+ const previous = readHealthMark(store);
307
+ if (ownerStoreInTests(store))
308
+ return { previous, cleared: null };
309
+ const checkedAt = new Date(now()).toISOString();
310
+ const mark = {
311
+ checked_at: checkedAt,
312
+ ok: health.ok,
313
+ problems: health.problems ?? 0,
314
+ schema,
315
+ cli,
316
+ ...version ? { cli_version: version } : {},
317
+ last_ok_at: health.ok ? checkedAt : previous?.last_ok_at ?? null
318
+ };
319
+ const cleared = health.ok ? readDamageMark(store) : null;
320
+ try {
321
+ writeFileSync(healthMarkPath(store), `${JSON.stringify(mark, null, 2)}
322
+ `, { mode: 384 });
323
+ } catch {
324
+ }
325
+ if (cleared)
326
+ clearDamageMark(store);
327
+ if (health.ok)
328
+ rmSync(journalMarkPath(store), { force: true });
329
+ return { previous, cleared };
330
+ }, "recordDeepCheck");
331
+
332
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/money.js
333
+ var CURRENCY_SCALES = {
334
+ AED: 2,
335
+ AMD: 2,
336
+ AUD: 2,
337
+ BHD: 3,
338
+ BYN: 2,
339
+ CAD: 2,
340
+ CHF: 2,
341
+ CLP: 0,
342
+ CNY: 2,
343
+ CZK: 2,
344
+ DKK: 2,
345
+ EUR: 2,
346
+ GBP: 2,
347
+ GEL: 2,
348
+ HUF: 2,
349
+ ILS: 2,
350
+ INR: 2,
351
+ ISK: 0,
352
+ JPY: 0,
353
+ KGS: 2,
354
+ KRW: 0,
355
+ KWD: 3,
356
+ KZT: 2,
357
+ NOK: 2,
358
+ PLN: 2,
359
+ RSD: 2,
360
+ RUB: 2,
361
+ SEK: 2,
362
+ THB: 2,
363
+ TRY: 2,
364
+ UAH: 2,
365
+ USD: 2,
366
+ UZS: 2,
367
+ VND: 0
368
+ };
369
+ var refuse = /* @__PURE__ */ __name((message, reason) => {
370
+ throw new CliError("validation_error", message, { reason });
371
+ }, "refuse");
372
+ var DECIMAL = /^(\d{1,15})(?:\.(\d+))?$/;
373
+ var parseDecimal = /* @__PURE__ */ __name((text2, scale) => {
374
+ const match = DECIMAL.exec(text2.trim());
375
+ if (!match || (match[2] ?? "").length > scale)
376
+ return void 0;
377
+ return BigInt(`${match[1]}${(match[2] ?? "").padEnd(scale, "0")}`);
378
+ }, "parseDecimal");
379
+ var formatDecimal = /* @__PURE__ */ __name((units, scale) => {
380
+ const value = BigInt(units);
381
+ if (value < 0n)
382
+ return `-${formatDecimal(-value, scale)}`;
383
+ const digits = value.toString().padStart(scale + 1, "0");
384
+ return scale === 0 ? digits : `${digits.slice(0, -scale)}.${digits.slice(-scale)}`;
385
+ }, "formatDecimal");
386
+ var groupDigits = /* @__PURE__ */ __name((decimal) => {
387
+ const [whole = "0", fraction] = decimal.split(".");
388
+ const grouped = whole.replace(/\B(?=(\d{3})+(?!\d))/g, " ");
389
+ return fraction === void 0 ? grouped : `${grouped}.${fraction}`;
390
+ }, "groupDigits");
391
+ var currencyOf = /* @__PURE__ */ __name((text2) => {
392
+ const code = typeof text2 === "string" ? text2.trim().toUpperCase() : "";
393
+ if (CURRENCY_SCALES[code] === void 0)
394
+ return refuse(`${typeof text2 === "string" && text2.trim() ? text2.trim() : "an empty currency"} is not a currency the store keeps; use one of ${Object.keys(CURRENCY_SCALES).join(", ")}`, "money.currency");
395
+ return code;
396
+ }, "currencyOf");
397
+ var scaleOf = /* @__PURE__ */ __name((currency) => CURRENCY_SCALES[currencyOf(currency)], "scaleOf");
398
+ var minorUnits = /* @__PURE__ */ __name((amount, currency, what = "an amount") => {
399
+ const scale = scaleOf(currency);
400
+ const units = typeof amount === "string" ? parseDecimal(amount, scale) : void 0;
401
+ if (units === void 0 || units > BigInt(Number.MAX_SAFE_INTEGER))
402
+ 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");
403
+ return Number(units);
404
+ }, "minorUnits");
405
+ var signedMinorUnits = /* @__PURE__ */ __name((amount, currency, what = "an amount") => {
406
+ if (typeof amount !== "string" || !amount.trim().startsWith("-"))
407
+ return minorUnits(amount, currency, what);
408
+ const units = minorUnits(amount.trim().slice(1), currency, what);
409
+ return units === 0 ? 0 : -units;
410
+ }, "signedMinorUnits");
411
+ var moneyOf = /* @__PURE__ */ __name((units, currency) => ({
412
+ amount: formatDecimal(units, scaleOf(currency)),
413
+ currency
414
+ }), "moneyOf");
415
+ var moneyLabel = /* @__PURE__ */ __name((units, currency) => `${groupDigits(formatDecimal(units, scaleOf(currency)))} ${currency}`, "moneyLabel");
416
+ var QUANTITY_SCALE = 3;
417
+ var quantityOf = /* @__PURE__ */ __name((text2) => {
418
+ const thousandths = typeof text2 === "string" ? parseDecimal(text2, QUANTITY_SCALE) : void 0;
419
+ if (thousandths === void 0 || thousandths === 0n)
420
+ return refuse('a quantity is a decimal string above 0 with at most 3 decimals, such as "1.5"', "money.quantity");
421
+ const plain = formatDecimal(thousandths, QUANTITY_SCALE).replace(/\.?0+$/, "");
422
+ return { text: plain, thousandths };
423
+ }, "quantityOf");
424
+ var lineUnits = /* @__PURE__ */ __name((thousandths, unitPrice) => Number((thousandths * BigInt(unitPrice) + 500n) / 1000n), "lineUnits");
425
+
426
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/finance.js
427
+ var INVOICE_DIRECTIONS = ["receivable", "payable"];
428
+ var INVOICE_STATUSES = ["draft", "issued", "partly_paid", "paid", "void"];
429
+ var MONEY_DIRECTIONS = ["in", "out"];
430
+ var FINANCE_REVIEWS = ["proposed", "confirmed", "rejected"];
431
+ var settledStatus = /* @__PURE__ */ __name((current, total, paid) => {
432
+ if (current === "draft" || current === "void")
433
+ return current;
434
+ if (paid <= 0)
435
+ return "issued";
436
+ return paid < total ? "partly_paid" : "paid";
437
+ }, "settledStatus");
438
+ var dayMonth = /* @__PURE__ */ __name((date) => date === null ? null : `${date.slice(8, 10)}.${date.slice(5, 7)}`, "dayMonth");
439
+ var notes = /* @__PURE__ */ __name((...words) => {
440
+ const kept = words.filter((word) => word !== null);
441
+ return kept.length === 0 ? "" : ` (${kept.join(", ")})`;
442
+ }, "notes");
443
+ var invoiceLine = /* @__PURE__ */ __name((invoice) => {
444
+ const party = invoice.counterpartyName === null ? "" : `${invoice.direction === "receivable" ? " to" : " from"} ${invoice.counterpartyName}`;
445
+ const due = invoice.dueDate === null ? "" : `, due ${dayMonth(invoice.dueDate)}`;
446
+ return `${invoice.number ?? `#${invoice.id}`} \xB7 ${moneyLabel(invoice.total, invoice.currency)}${party}${due}` + notes(invoice.status.replace("_", " "), invoice.review === "confirmed" ? null : invoice.review);
447
+ }, "invoiceLine");
448
+ var paymentLine = /* @__PURE__ */ __name((payment) => {
449
+ const party = payment.partyName === null ? "" : `${payment.direction === "in" ? " from" : " to"} ${payment.partyName}`;
450
+ return `${moneyLabel(payment.amount, payment.currency)}${party}, ${dayMonth(payment.date)}` + notes(payment.review === "confirmed" ? null : payment.review);
451
+ }, "paymentLine");
452
+ var invoiceTitle = /* @__PURE__ */ __name((invoice) => `Invoice ${invoiceLine(invoice)}`, "invoiceTitle");
453
+ var paymentEntryTitle = /* @__PURE__ */ __name((payment) => `Payment \xB7 ${paymentLine(payment)}`, "paymentEntryTitle");
454
+
455
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/business.js
456
+ var CATALOG_KINDS = ["product", "service"];
457
+ var BUSINESS_KINDS = ["invoice", "payment", "order", "contract", "subscription", "product", "wallet"];
458
+ var CONTRACT_KINDS = ["sale", "purchase", "service", "lease", "employment", "nda", "license", "other"];
459
+ var CONTRACT_STATUSES = ["draft", "active", "ended", "terminated"];
460
+ var SUBSCRIPTION_STATUSES = ["trial", "active", "paused", "cancelled", "ended"];
461
+ var WALLET_KINDS = ["bank", "card", "cash", "wallet", "other"];
462
+ var TRANSACTION_STATUSES = ["pending", "booked"];
463
+ var ORDER_DIRECTIONS = ["purchase", "sale"];
464
+ var intervalOf = /* @__PURE__ */ __name((text2, reason = "subscription.interval") => {
465
+ const match = typeof text2 === "string" ? /^(?:([1-9]\d{0,2})-)?(day|week|month|year)$/.exec(text2.trim()) : null;
466
+ if (!match)
467
+ throw new CliError("validation_error", "an interval is a count and a unit, such as 1-month or 2-week", { reason });
468
+ return { count: match[1] === void 0 ? 1 : Number(match[1]), unit: match[2] };
469
+ }, "intervalOf");
470
+ var intervalText = /* @__PURE__ */ __name(({ count: count2, unit }) => `${count2}-${unit}`, "intervalText");
471
+ var priced = /* @__PURE__ */ __name((units, currency) => units === null || currency === null ? "" : `, ${moneyLabel(units, currency)}`, "priced");
472
+ var pending = /* @__PURE__ */ __name((review) => review === "confirmed" ? null : review, "pending");
473
+ var productLine = /* @__PURE__ */ __name((product) => {
474
+ const price = product.unitPrice === null || product.currency === null ? "" : moneyLabel(product.unitPrice, product.currency);
475
+ const per = price && product.unit !== null ? ` per ${product.unit}` : "";
476
+ return `${product.name}${price ? ` \xB7 ${price}${per}` : ""}${notes(product.kind, product.archived ? "archived" : null)}`;
477
+ }, "productLine");
478
+ var contractLine = /* @__PURE__ */ __name((contract) => `${contract.number ?? `#${contract.id}`} \xB7 ${contract.name}${priced(contract.value, contract.currency)}` + notes(contract.status, pending(contract.review)), "contractLine");
479
+ var subscriptionLine = /* @__PURE__ */ __name((subscription) => `${subscription.name}${priced(subscription.price, subscription.currency)} every ${intervalText(subscription.interval)}` + notes(subscription.status, pending(subscription.review)), "subscriptionLine");
480
+ var walletLine = /* @__PURE__ */ __name((wallet) => `${wallet.name} \xB7 ${wallet.kind}, ${wallet.currency}${wallet.numberHint === null ? "" : `, \u2026${wallet.numberHint}`}` + notes(wallet.closed ? "closed" : null), "walletLine");
481
+ 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");
482
+
483
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/knowledge.js
484
+ var FACT_STATUSES = ["proposed", "accepted", "superseded", "reversed", "rejected"];
485
+ var MEMORY_KINDS = ["summary", "digest", "preference"];
486
+ var MEMORY_STATUSES = ["proposed", "confirmed", "stale", "superseded"];
487
+ var MEMORY_SCOPES = ["personal", "work"];
488
+ var WORK_TASK_TYPES = ["bug", "feature", "chore"];
489
+ var TASK_TYPES = [...WORK_TASK_TYPES, ...TASK_KINDS];
490
+
491
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/deals.js
492
+ var DEAL_KINDS = ["deal", "lead"];
493
+ var DEAL_STATUSES = ["open", "won", "lost"];
494
+ var STAGE_OUTCOMES = DEAL_STATUSES;
495
+ var DEAL_ROLES = ["owner", "contact", "decision-maker", "influencer"];
496
+ var dealLine = /* @__PURE__ */ __name((deal) => {
497
+ const money = deal.amount === null || deal.currency === null ? "" : `, ${moneyLabel(deal.amount, deal.currency)}`;
498
+ return `${deal.title} \xB7 ${deal.stage}${money}${deal.status === "open" ? "" : ` (${deal.status})`}`;
499
+ }, "dealLine");
500
+
501
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/orders.js
502
+ var ORDER_STATUSES = ["placed", "shipped", "delivered", "cancelled", "returned"];
503
+ var ORDER_PURPOSES = ["personal", "business", "client", "other"];
504
+ var orderLine = /* @__PURE__ */ __name((order) => {
505
+ const party = order.direction === "sale" && order.customerName !== null ? `to ${order.customerName}` : order.supplierName;
506
+ const money = order.total === null || order.currency === null ? "" : `, ${moneyLabel(order.total, order.currency)}`;
507
+ const notes2 = [order.status, order.review === "confirmed" ? null : order.review].filter(Boolean).join(", ");
508
+ return `${order.number ?? `#${order.id}`} \xB7 ${party}${money} (${notes2})`;
509
+ }, "orderLine");
510
+ var orderTitle = /* @__PURE__ */ __name((order) => `Order ${orderLine(order)}`, "orderTitle");
511
+
512
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/relations.js
513
+ var ORGANIZATION_ROLES = [
514
+ "employee",
515
+ "contractor",
516
+ "founder",
517
+ "owner",
518
+ "manager",
519
+ "adviser",
520
+ "contact"
521
+ ];
522
+ var PROJECT_ROLES = ["owner", "manager", "contributor", "client-contact", "approver"];
523
+ var CONTRACT_ROLES = ["customer", "supplier", "signatory", "guarantor"];
524
+ var RELATED_ROLES = ["colleague", "adviser", "investor", "mentor", "family", "friend"];
525
+ var ENGAGEMENT_LEVELS = ["none", "low", "medium", "high"];
526
+ var isEngagement = /* @__PURE__ */ __name((value) => typeof value === "string" && ENGAGEMENT_LEVELS.includes(value), "isEngagement");
527
+ var checkEngagement = /* @__PURE__ */ __name((kind, from, to, level) => {
528
+ if (kind !== "member-of" || from !== "person" || to !== "project")
529
+ throw new CliError("validation_error", "an engagement level is set only on a person's member-of a project", {
530
+ reason: "relationship.engagement-ends"
531
+ });
532
+ if (!isEngagement(level))
533
+ throw new CliError("validation_error", `an engagement level is one of ${ENGAGEMENT_LEVELS.join(", ")}`, {
534
+ reason: "relationship.engagement-unknown"
535
+ });
536
+ return level;
537
+ }, "checkEngagement");
538
+ var RELATIONS = {
539
+ "member-of": {
540
+ from: ["person", "organization", "project", "chat", "email_thread"],
541
+ to: ["organization", "project"],
542
+ roles: { to: { organization: ORGANIZATION_ROLES, project: PROJECT_ROLES } }
543
+ },
544
+ "reports-to": { from: ["person"], to: ["person"], inverse: "manages" },
545
+ "customer-of": { from: ["person", "organization"], to: ["organization"], inverse: "supplier of" },
546
+ "partner-of": { from: ["organization"], to: ["organization"], symmetric: true },
547
+ "related-to": {
548
+ from: ["person", "organization", "project", "task", "deal", "lead", "contract"],
549
+ to: ["person", "organization", "project", "task"],
550
+ roles: { from: { deal: DEAL_ROLES, lead: DEAL_ROLES, contract: CONTRACT_ROLES } }
551
+ }
552
+ };
553
+ var RELATION_KINDS = Object.keys(RELATIONS);
554
+ var specOf = /* @__PURE__ */ __name((kind) => Object.hasOwn(RELATIONS, kind) ? RELATIONS[kind] : void 0, "specOf");
555
+ var isRelationKind = /* @__PURE__ */ __name((kind) => specOf(kind) !== void 0, "isRelationKind");
556
+ var memberOnly = /* @__PURE__ */ __name((type) => type === "chat" || type === "email_thread", "memberOnly");
557
+ var partyOnly = /* @__PURE__ */ __name((from, to) => from === "contract" && to !== "person" && to !== "organization", "partyOnly");
558
+ var checkEnds = /* @__PURE__ */ __name((kind, from, to) => {
559
+ const spec = specOf(kind);
560
+ if (!spec)
561
+ throw new CliError("validation_error", `a relationship's kind is one of ${RELATION_KINDS.join(", ")}`);
562
+ if (memberOnly(from) && (kind !== "member-of" || to !== "project"))
563
+ throw new CliError("validation_error", `a ${from === "chat" ? "chat" : "mail thread"} is related only as member-of a project`);
564
+ if (partyOnly(from, to))
565
+ throw new CliError("validation_error", "a contract is related only to a person or an organization");
566
+ if (!spec.from.includes(from) || !spec.to.includes(to))
567
+ throw new CliError("validation_error", `${kind} joins ${spec.from.join(", ")} to ${spec.to.join(", ")}, not ${from} to ${to}`);
568
+ return spec;
569
+ }, "checkEnds");
570
+ var isParty = /* @__PURE__ */ __name((type) => type === "person" || type === "organization", "isParty");
571
+ var rolesOf = /* @__PURE__ */ __name((kind, from, to) => {
572
+ const spec = specOf(kind);
573
+ if (kind === "member-of" && from !== "person")
574
+ return void 0;
575
+ return spec?.roles?.from?.[from] ?? spec?.roles?.to?.[to];
576
+ }, "rolesOf");
577
+ var ROLE_LISTS = {
578
+ organization: ORGANIZATION_ROLES,
579
+ project: PROJECT_ROLES,
580
+ deal: DEAL_ROLES,
581
+ contract: CONTRACT_ROLES,
582
+ related: RELATED_ROLES
583
+ };
584
+ var roleListOf = /* @__PURE__ */ __name((kind, from, to) => {
585
+ if (kind === "related-to" && isParty(from) && isParty(to))
586
+ return "related";
587
+ const roles = rolesOf(kind, from, to);
588
+ return Object.keys(ROLE_LISTS).find((list) => ROLE_LISTS[list] === roles);
589
+ }, "roleListOf");
590
+ var checkRole = /* @__PURE__ */ __name((kind, from, to, role, extra = []) => {
591
+ const roles = rolesOf(kind, from, to)?.concat(extra);
592
+ if (roles && !roles.includes(role))
593
+ throw new CliError("validation_error", `a ${from}'s role on ${kind} ${to} is one of ${roles.join(", ")}`, {
594
+ reason: "relationship.role-unknown"
595
+ });
596
+ return role;
597
+ }, "checkRole");
598
+ var isSymmetric = /* @__PURE__ */ __name((kind) => specOf(kind)?.symmetric === true, "isSymmetric");
599
+ var inverseOf = /* @__PURE__ */ __name((kind) => specOf(kind)?.symmetric ? kind : specOf(kind)?.inverse ?? null, "inverseOf");
600
+ var STANDINGS = ["confirmed", "reported", "proposed", "ended"];
601
+ var standingOf = /* @__PURE__ */ __name((link, now) => {
602
+ if (link.endsAt != null && link.endsAt <= now)
603
+ return "ended";
604
+ if (link.confirmed)
605
+ return "confirmed";
606
+ if (link.deletedAt != null)
607
+ return "ended";
608
+ return link.accountId != null ? "reported" : "proposed";
609
+ }, "standingOf");
610
+ var isUsable = /* @__PURE__ */ __name((standing) => standing === "confirmed" || standing === "reported", "isUsable");
611
+ var KEYED = "kind IN ('member-of', 'related-to', 'reports-to', 'customer-of', 'partner-of') AND to_id IS NOT NULL";
612
+ 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");
613
+ 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");
614
+
615
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/crm.js
616
+ var CRM_KINDS = ["organization", "person", "deal", "lead"];
617
+ var CRM_ACTIVITY_KINDS = ["call", "email", "meeting", "todo", "task", "comment", "other"];
618
+ var isCrmUserId = /* @__PURE__ */ __name((id2) => /^\d{1,20}$/.test(id2), "isCrmUserId");
619
+ var normalCrmUserId = /* @__PURE__ */ __name((id2) => {
620
+ const text2 = id2.trim();
621
+ return /^\d+$/.test(text2) ? text2.replace(/^0+(?=\d)/, "") : text2;
622
+ }, "normalCrmUserId");
623
+ var isItemKind = /* @__PURE__ */ __name((kind) => kind === "deal" || kind === "lead", "isItemKind");
624
+
625
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/store/sqlite/link-source.js
626
+ var REPORTER_SQL = "(SELECT provider || ':' || external_id FROM accounts r WHERE r.id = links.account_id) AS reporter";
627
+ var sourceOf = /* @__PURE__ */ __name((database, row, metadata) => {
628
+ const reporter = row.account_id == null ? void 0 : "reporter" in row ? row.reporter : database.prepare("SELECT provider || ':' || external_id AS key FROM accounts WHERE id = ?").get(Number(row.account_id))?.key;
629
+ return {
630
+ ...typeof reporter === "string" ? { account: reporter } : {},
631
+ ...typeof metadata.derived === "string" ? { derived: metadata.derived } : {}
632
+ };
633
+ }, "sourceOf");
634
+
635
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/store/sqlite/link-kinds.js
636
+ var LINK_KINDS = [
637
+ "links-to",
638
+ "blocked-by",
639
+ "follow-up-of",
640
+ "about",
641
+ "member-of",
642
+ "labelled",
643
+ "answered-by",
644
+ "evidence",
645
+ "created-from",
646
+ "duplicate-of",
647
+ "related-to",
648
+ "reports-to",
649
+ "customer-of",
650
+ "partner-of",
651
+ "assigned-to",
652
+ "attached"
653
+ ];
654
+ var LINK_ORIGINS = ["file", "owner", "suggested", "message"];
655
+ var LINK_SOURCES = [...LINK_ORIGINS, "calendar", "meeting"];
656
+ var linkKind = /* @__PURE__ */ __name((kind) => `'${kind}'`, "linkKind");
657
+ var COUNTERPART_ROLE = "counterpart";
658
+
659
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/domain/categories.js
660
+ var CATEGORIES = ["client", "supplier", "partner", "employer"];
661
+
662
+ export {
663
+ CATEGORIES,
664
+ parseDecimal,
665
+ formatDecimal,
666
+ currencyOf,
667
+ scaleOf,
668
+ minorUnits,
669
+ signedMinorUnits,
670
+ moneyOf,
671
+ moneyLabel,
672
+ quantityOf,
673
+ lineUnits,
674
+ DEAL_KINDS,
675
+ DEAL_STATUSES,
676
+ STAGE_OUTCOMES,
677
+ DEAL_ROLES,
678
+ dealLine,
679
+ INVOICE_DIRECTIONS,
680
+ INVOICE_STATUSES,
681
+ MONEY_DIRECTIONS,
682
+ FINANCE_REVIEWS,
683
+ settledStatus,
684
+ invoiceLine,
685
+ paymentLine,
686
+ invoiceTitle,
687
+ paymentEntryTitle,
688
+ ORDER_STATUSES,
689
+ ORDER_PURPOSES,
690
+ orderLine,
691
+ orderTitle,
692
+ isEngagement,
693
+ checkEngagement,
694
+ RELATION_KINDS,
695
+ isRelationKind,
696
+ checkEnds,
697
+ rolesOf,
698
+ ROLE_LISTS,
699
+ roleListOf,
700
+ checkRole,
701
+ isSymmetric,
702
+ inverseOf,
703
+ STANDINGS,
704
+ standingOf,
705
+ isUsable,
706
+ KEYED,
707
+ notOverriddenSql,
708
+ usableLinkSql,
709
+ TASK_KINDS,
710
+ TASK_STATES,
711
+ CLOSED_STATES,
712
+ TASK_ORIGINS,
713
+ TASK_VERDICTS,
714
+ isClosedState,
715
+ PRIORITY_LABELS,
716
+ priorityLabel,
717
+ priorityBand,
718
+ legacyPriority,
719
+ checkedScore,
720
+ priorityOf,
721
+ priorityOption,
722
+ createTaskService,
723
+ matches,
724
+ SOURCE_REVIEW_KIND,
725
+ SOURCE_REVIEW_CAUSES,
726
+ ERASED_TEXT,
727
+ severity,
728
+ graver,
729
+ text,
730
+ id,
731
+ time,
732
+ typedTime,
733
+ count,
734
+ untrusted,
735
+ providerMetadata,
736
+ evidenceSource,
737
+ sourceReview,
738
+ author,
739
+ CRM_KINDS,
740
+ CRM_ACTIVITY_KINDS,
741
+ isCrmUserId,
742
+ normalCrmUserId,
743
+ isItemKind,
744
+ organization,
745
+ project,
746
+ reminder,
747
+ damageMarkPath,
748
+ healthMarkPath,
749
+ journalMarkPath,
750
+ markStoreDamaged,
751
+ readDamageMark,
752
+ clearDamageMark,
753
+ refuseDamagedStore,
754
+ markJournalLost,
755
+ readJournalMark,
756
+ readHealthMark,
757
+ recordDeepCheck,
758
+ CATALOG_KINDS,
759
+ BUSINESS_KINDS,
760
+ CONTRACT_KINDS,
761
+ CONTRACT_STATUSES,
762
+ SUBSCRIPTION_STATUSES,
763
+ WALLET_KINDS,
764
+ TRANSACTION_STATUSES,
765
+ ORDER_DIRECTIONS,
766
+ intervalOf,
767
+ productLine,
768
+ contractLine,
769
+ subscriptionLine,
770
+ walletLine,
771
+ transactionLine,
772
+ REPORTER_SQL,
773
+ sourceOf,
774
+ LINK_KINDS,
775
+ LINK_ORIGINS,
776
+ LINK_SOURCES,
777
+ linkKind,
778
+ COUNTERPART_ROLE,
779
+ FACT_STATUSES,
780
+ MEMORY_KINDS,
781
+ MEMORY_STATUSES,
782
+ MEMORY_SCOPES,
783
+ WORK_TASK_TYPES,
784
+ TASK_TYPES
785
+ };