@wirecat/mail-cli 0.37.0 → 0.39.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 (392) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +9 -7
  3. package/contracts/wirecat.json +64 -2
  4. package/dist/bin/mail.js +11 -11
  5. package/dist/bundle/{chunk-BNURKCQG.js → chunk-BXH2YUBR.js} +33 -5
  6. package/dist/bundle/mail.js +4 -166
  7. package/dist/bundle/program-ZSF2VJI6.js +17329 -0
  8. package/dist/commands/account-remove.js +1 -2
  9. package/dist/commands/account.js +1 -1
  10. package/dist/commands/attachments.js +1 -2
  11. package/dist/commands/context.js +1 -1
  12. package/dist/commands/doctor.js +1 -1
  13. package/dist/commands/drafts-send.js +1 -2
  14. package/dist/commands/drafts.js +1 -2
  15. package/dist/commands/export.js +1 -2
  16. package/dist/commands/folders.js +1 -2
  17. package/dist/commands/import.js +1 -1
  18. package/dist/commands/messages.js +1 -1
  19. package/dist/commands/organising.js +1 -2
  20. package/dist/commands/read.js +2 -4
  21. package/dist/commands/restore.js +1 -1
  22. package/dist/commands/rules.js +1 -2
  23. package/dist/commands/send.js +1 -2
  24. package/dist/commands/session-start.js +1 -1
  25. package/dist/commands/session.js +1 -1
  26. package/dist/commands/stats.js +1 -1
  27. package/dist/commands/status.js +3 -5
  28. package/dist/commands/sync.js +29 -5
  29. package/dist/commands/tags.js +1 -2
  30. package/dist/config.js +1 -1
  31. package/dist/identity.js +27 -0
  32. package/dist/mail/changes.js +3 -2
  33. package/dist/mail/cleanup.js +3 -2
  34. package/dist/mail/domain-age.js +1 -1
  35. package/dist/mail/memo-trash.js +47 -0
  36. package/dist/mail/organise.js +1 -1
  37. package/dist/mail/save.js +1 -1
  38. package/dist/mail/send-as.js +66 -0
  39. package/dist/mail/send.js +4 -2
  40. package/dist/oauth.js +1 -3
  41. package/dist/profile.js +1 -1
  42. package/dist/program.js +1 -2
  43. package/dist/providers.js +4 -4
  44. package/dist/store.js +1 -1
  45. package/dist/version.js +1 -1
  46. package/package.json +5 -5
  47. package/dist/bin/mail.d.ts +0 -3
  48. package/dist/bin/mail.d.ts.map +0 -1
  49. package/dist/bin/mail.js.map +0 -1
  50. package/dist/bundle/agent-OU4K7TKQ.js +0 -40
  51. package/dist/bundle/all-profiles-ICGWDPUU.js +0 -320
  52. package/dist/bundle/anthropic-TL4WFWGU.js +0 -90
  53. package/dist/bundle/app-server-YAR5EFOO.js +0 -256
  54. package/dist/bundle/bun-OPDGMZZQ.js +0 -169
  55. package/dist/bundle/bun-sqlite-WI3ZPANS.js +0 -75
  56. package/dist/bundle/chunk-2JHVQMVC.js +0 -16
  57. package/dist/bundle/chunk-2XBDILVW.js +0 -53
  58. package/dist/bundle/chunk-2YO3PLOE.js +0 -2843
  59. package/dist/bundle/chunk-3DHJF57U.js +0 -690
  60. package/dist/bundle/chunk-3HC5F3P7.js +0 -24
  61. package/dist/bundle/chunk-3SKTQ2HC.js +0 -288
  62. package/dist/bundle/chunk-3YM4B2GT.js +0 -63
  63. package/dist/bundle/chunk-3ZOOTTFW.js +0 -1007
  64. package/dist/bundle/chunk-4FTIHADB.js +0 -259
  65. package/dist/bundle/chunk-4IZ6R5FS.js +0 -730
  66. package/dist/bundle/chunk-4N7PP76S.js +0 -6848
  67. package/dist/bundle/chunk-7HRKUKKY.js +0 -1068
  68. package/dist/bundle/chunk-7PDGZFXD.js +0 -133
  69. package/dist/bundle/chunk-7YKWFERX.js +0 -330
  70. package/dist/bundle/chunk-BNVISIHP.js +0 -95
  71. package/dist/bundle/chunk-BQMJYSA4.js +0 -360
  72. package/dist/bundle/chunk-BYITYTRL.js +0 -86
  73. package/dist/bundle/chunk-CICUPYHT.js +0 -106
  74. package/dist/bundle/chunk-CQHLWMKK.js +0 -1333
  75. package/dist/bundle/chunk-CUW7Y2HJ.js +0 -334
  76. package/dist/bundle/chunk-D72URWJE.js +0 -532
  77. package/dist/bundle/chunk-DFDN6AUB.js +0 -21
  78. package/dist/bundle/chunk-DJZIFZOT.js +0 -52
  79. package/dist/bundle/chunk-DNCLQPOM.js +0 -7
  80. package/dist/bundle/chunk-DPV53EZC.js +0 -206
  81. package/dist/bundle/chunk-DTR7JO2M.js +0 -794
  82. package/dist/bundle/chunk-ES2FF42M.js +0 -2470
  83. package/dist/bundle/chunk-EV72K4IU.js +0 -274
  84. package/dist/bundle/chunk-EZQ5BYNL.js +0 -338
  85. package/dist/bundle/chunk-F2D3J5DR.js +0 -188
  86. package/dist/bundle/chunk-FTT7UDYV.js +0 -80
  87. package/dist/bundle/chunk-FXNCKPQ7.js +0 -64
  88. package/dist/bundle/chunk-G4VJN75G.js +0 -806
  89. package/dist/bundle/chunk-GGMAIIVE.js +0 -38
  90. package/dist/bundle/chunk-GPUC3FTU.js +0 -195
  91. package/dist/bundle/chunk-GQIMVR7C.js +0 -3752
  92. package/dist/bundle/chunk-HCRUGAIN.js +0 -1024
  93. package/dist/bundle/chunk-HES6YMYN.js +0 -161
  94. package/dist/bundle/chunk-HFY7536N.js +0 -9510
  95. package/dist/bundle/chunk-HTQTIKWP.js +0 -928
  96. package/dist/bundle/chunk-IA7LLLEI.js +0 -100
  97. package/dist/bundle/chunk-IUJDWEGJ.js +0 -615
  98. package/dist/bundle/chunk-IWFWWO37.js +0 -364
  99. package/dist/bundle/chunk-JG6LCSEX.js +0 -407
  100. package/dist/bundle/chunk-JLXXUEAM.js +0 -72
  101. package/dist/bundle/chunk-JNP3XGJI.js +0 -559
  102. package/dist/bundle/chunk-JZUYZ2XJ.js +0 -2076
  103. package/dist/bundle/chunk-K4DEQAEW.js +0 -1291
  104. package/dist/bundle/chunk-KCM3WSER.js +0 -388
  105. package/dist/bundle/chunk-KP5JDYY6.js +0 -2669
  106. package/dist/bundle/chunk-KUX54EGR.js +0 -40792
  107. package/dist/bundle/chunk-KXJ3JEDH.js +0 -2
  108. package/dist/bundle/chunk-KZD3H5QA.js +0 -108
  109. package/dist/bundle/chunk-LKH3UKLO.js +0 -230
  110. package/dist/bundle/chunk-NAOLBEFX.js +0 -12142
  111. package/dist/bundle/chunk-NB52JKLR.js +0 -323
  112. package/dist/bundle/chunk-NB7EOAUZ.js +0 -123
  113. package/dist/bundle/chunk-NISH4UXM.js +0 -58
  114. package/dist/bundle/chunk-NQSKI7XK.js +0 -52
  115. package/dist/bundle/chunk-OWPRJLHV.js +0 -353
  116. package/dist/bundle/chunk-OZKZT3ZI.js +0 -79
  117. package/dist/bundle/chunk-PL5P7UKW.js +0 -25216
  118. package/dist/bundle/chunk-Q7ICVP25.js +0 -18
  119. package/dist/bundle/chunk-QLJGYDWG.js +0 -1197
  120. package/dist/bundle/chunk-R44KVISE.js +0 -218
  121. package/dist/bundle/chunk-R73VWPNL.js +0 -192
  122. package/dist/bundle/chunk-RRTMPSQR.js +0 -29
  123. package/dist/bundle/chunk-S6JG4YUH.js +0 -72
  124. package/dist/bundle/chunk-TMJLGR4A.js +0 -4070
  125. package/dist/bundle/chunk-TXDR6YSF.js +0 -23
  126. package/dist/bundle/chunk-TY7NDMFY.js +0 -46
  127. package/dist/bundle/chunk-UDSL3MUU.js +0 -2333
  128. package/dist/bundle/chunk-UTS5NMR3.js +0 -54
  129. package/dist/bundle/chunk-VB7FZOYX.js +0 -633
  130. package/dist/bundle/chunk-VK24UQSD.js +0 -142
  131. package/dist/bundle/chunk-VYCB5EVI.js +0 -721
  132. package/dist/bundle/chunk-VZ5PPYDG.js +0 -77
  133. package/dist/bundle/chunk-WOPVBRPV.js +0 -29
  134. package/dist/bundle/chunk-XEQQJBBO.js +0 -92
  135. package/dist/bundle/chunk-XQUUANA2.js +0 -24600
  136. package/dist/bundle/chunk-XWBTD2WP.js +0 -76
  137. package/dist/bundle/chunk-XXPJF2VD.js +0 -2
  138. package/dist/bundle/chunk-Y5E2WNWB.js +0 -35
  139. package/dist/bundle/chunk-YODGIMMM.js +0 -185
  140. package/dist/bundle/chunk-YWDFYQOU.js +0 -82
  141. package/dist/bundle/chunk-Z4BLNAWI.js +0 -67228
  142. package/dist/bundle/chunk-ZSAPOC7B.js +0 -1247
  143. package/dist/bundle/chunk-ZTWTEXB2.js +0 -170
  144. package/dist/bundle/chunk-ZVVMGPBJ.js +0 -50
  145. package/dist/bundle/command-contract-UC6IGCCM.js +0 -39
  146. package/dist/bundle/command-server-entry-RA3ZX2KV.js +0 -168
  147. package/dist/bundle/decode-QVKRSRVF.js +0 -296
  148. package/dist/bundle/dispatch-USKS7J74.js +0 -411
  149. package/dist/bundle/dist-HFUVURJG.js +0 -7577
  150. package/dist/bundle/dist-ITIXJAXK.js +0 -317
  151. package/dist/bundle/dist-PAKDDIBT.js +0 -191
  152. package/dist/bundle/echarts-O3TNDAXJ.js +0 -42501
  153. package/dist/bundle/embed-2HOODFQT.js +0 -37
  154. package/dist/bundle/embedder-22AJGCZX.js +0 -110
  155. package/dist/bundle/failure-D4FGOIWF.js +0 -24
  156. package/dist/bundle/first-run-FU4MFXOA.js +0 -28
  157. package/dist/bundle/first-screen-A7SEI2ON.js +0 -40
  158. package/dist/bundle/instructions-AMH5RWVJ.js +0 -11
  159. package/dist/bundle/mcp-5HFPWC3W.js +0 -167
  160. package/dist/bundle/meeting-combined-KC6YGWA7.js +0 -24
  161. package/dist/bundle/meeting-model-QWGAOQHL.js +0 -24
  162. package/dist/bundle/meeting-semantic-7PVO6RNB.js +0 -21
  163. package/dist/bundle/node-EGMCBAO7.js +0 -176
  164. package/dist/bundle/node-KM3CUABH.js +0 -2340
  165. package/dist/bundle/node-TLZSIHIJ.js +0 -21
  166. package/dist/bundle/node-sqlite-JXUELLMP.js +0 -73
  167. package/dist/bundle/oauth-OYAYWH4K.js +0 -19
  168. package/dist/bundle/open-GLEUJGNA.js +0 -22
  169. package/dist/bundle/openai-PYTVNB6L.js +0 -237
  170. package/dist/bundle/process-SGHEN6MQ.js +0 -91
  171. package/dist/bundle/program-7CFNZ2DF.js +0 -51701
  172. package/dist/bundle/prompt-CYTILD7N.js +0 -16
  173. package/dist/bundle/public-XWMXEGEF.js +0 -196
  174. package/dist/bundle/recognize-26UNETSQ.js +0 -25
  175. package/dist/bundle/remote-PKXBQA5N.js +0 -30
  176. package/dist/bundle/rerank-LLKP7M6Q.js +0 -51
  177. package/dist/bundle/serve-ZRJEAPJI.js +0 -198
  178. package/dist/bundle/server-4OQ4G5JY.js +0 -218
  179. package/dist/bundle/server-VVRQ4A34.js +0 -86
  180. package/dist/bundle/sqlite-runtime-667VV4VY.js +0 -19
  181. package/dist/bundle/state-V3CAAJBE.js +0 -35
  182. package/dist/bundle/store-BJCIMIAH.js +0 -302
  183. package/dist/bundle/store-GLBBY4OZ.js +0 -184
  184. package/dist/bundle/store-maintenance-command-N7L5OVUE.js +0 -73
  185. package/dist/bundle/surface-26EUQNDT.js +0 -72
  186. package/dist/commands/account-remove.d.ts +0 -3
  187. package/dist/commands/account-remove.d.ts.map +0 -1
  188. package/dist/commands/account-remove.js.map +0 -1
  189. package/dist/commands/account.d.ts +0 -3
  190. package/dist/commands/account.d.ts.map +0 -1
  191. package/dist/commands/account.js.map +0 -1
  192. package/dist/commands/attachments.d.ts +0 -3
  193. package/dist/commands/attachments.d.ts.map +0 -1
  194. package/dist/commands/attachments.js.map +0 -1
  195. package/dist/commands/context.d.ts +0 -79
  196. package/dist/commands/context.d.ts.map +0 -1
  197. package/dist/commands/context.js.map +0 -1
  198. package/dist/commands/doctor.d.ts +0 -68
  199. package/dist/commands/doctor.d.ts.map +0 -1
  200. package/dist/commands/doctor.js.map +0 -1
  201. package/dist/commands/drafts-send.d.ts +0 -7
  202. package/dist/commands/drafts-send.d.ts.map +0 -1
  203. package/dist/commands/drafts-send.js.map +0 -1
  204. package/dist/commands/drafts.d.ts +0 -3
  205. package/dist/commands/drafts.d.ts.map +0 -1
  206. package/dist/commands/drafts.js.map +0 -1
  207. package/dist/commands/export.d.ts +0 -3
  208. package/dist/commands/export.d.ts.map +0 -1
  209. package/dist/commands/export.js.map +0 -1
  210. package/dist/commands/folders.d.ts +0 -3
  211. package/dist/commands/folders.d.ts.map +0 -1
  212. package/dist/commands/folders.js.map +0 -1
  213. package/dist/commands/import.d.ts +0 -3
  214. package/dist/commands/import.d.ts.map +0 -1
  215. package/dist/commands/import.js.map +0 -1
  216. package/dist/commands/login.d.ts +0 -5
  217. package/dist/commands/login.d.ts.map +0 -1
  218. package/dist/commands/login.js.map +0 -1
  219. package/dist/commands/mailbox.d.ts +0 -17
  220. package/dist/commands/mailbox.d.ts.map +0 -1
  221. package/dist/commands/mailbox.js.map +0 -1
  222. package/dist/commands/messages.d.ts +0 -4
  223. package/dist/commands/messages.d.ts.map +0 -1
  224. package/dist/commands/messages.js.map +0 -1
  225. package/dist/commands/organising.d.ts +0 -98
  226. package/dist/commands/organising.d.ts.map +0 -1
  227. package/dist/commands/organising.js.map +0 -1
  228. package/dist/commands/read.d.ts +0 -6
  229. package/dist/commands/read.d.ts.map +0 -1
  230. package/dist/commands/read.js.map +0 -1
  231. package/dist/commands/restore.d.ts +0 -3
  232. package/dist/commands/restore.d.ts.map +0 -1
  233. package/dist/commands/restore.js.map +0 -1
  234. package/dist/commands/rules.d.ts +0 -3
  235. package/dist/commands/rules.d.ts.map +0 -1
  236. package/dist/commands/rules.js.map +0 -1
  237. package/dist/commands/send.d.ts +0 -51
  238. package/dist/commands/send.d.ts.map +0 -1
  239. package/dist/commands/send.js.map +0 -1
  240. package/dist/commands/server-search.d.ts +0 -8
  241. package/dist/commands/server-search.d.ts.map +0 -1
  242. package/dist/commands/server-search.js.map +0 -1
  243. package/dist/commands/session-start.d.ts +0 -3
  244. package/dist/commands/session-start.d.ts.map +0 -1
  245. package/dist/commands/session-start.js.map +0 -1
  246. package/dist/commands/session.d.ts +0 -3
  247. package/dist/commands/session.d.ts.map +0 -1
  248. package/dist/commands/session.js.map +0 -1
  249. package/dist/commands/stats.d.ts +0 -3
  250. package/dist/commands/stats.d.ts.map +0 -1
  251. package/dist/commands/stats.js.map +0 -1
  252. package/dist/commands/status.d.ts +0 -3
  253. package/dist/commands/status.d.ts.map +0 -1
  254. package/dist/commands/status.js.map +0 -1
  255. package/dist/commands/sync.d.ts +0 -11
  256. package/dist/commands/sync.d.ts.map +0 -1
  257. package/dist/commands/sync.js.map +0 -1
  258. package/dist/commands/tags.d.ts +0 -3
  259. package/dist/commands/tags.d.ts.map +0 -1
  260. package/dist/commands/tags.js.map +0 -1
  261. package/dist/commands/words.d.ts +0 -8
  262. package/dist/commands/words.d.ts.map +0 -1
  263. package/dist/commands/words.js.map +0 -1
  264. package/dist/config.d.ts +0 -239
  265. package/dist/config.d.ts.map +0 -1
  266. package/dist/config.js.map +0 -1
  267. package/dist/discovery.d.ts +0 -31
  268. package/dist/discovery.d.ts.map +0 -1
  269. package/dist/discovery.js.map +0 -1
  270. package/dist/export/format.d.ts +0 -19
  271. package/dist/export/format.d.ts.map +0 -1
  272. package/dist/export/format.js.map +0 -1
  273. package/dist/export/journal.d.ts +0 -34
  274. package/dist/export/journal.d.ts.map +0 -1
  275. package/dist/export/journal.js.map +0 -1
  276. package/dist/export/write.d.ts +0 -14
  277. package/dist/export/write.d.ts.map +0 -1
  278. package/dist/export/write.js.map +0 -1
  279. package/dist/identity.d.ts +0 -7
  280. package/dist/identity.d.ts.map +0 -1
  281. package/dist/identity.js.map +0 -1
  282. package/dist/mail/backend.d.ts +0 -138
  283. package/dist/mail/backend.d.ts.map +0 -1
  284. package/dist/mail/backend.js.map +0 -1
  285. package/dist/mail/changes.d.ts +0 -99
  286. package/dist/mail/changes.d.ts.map +0 -1
  287. package/dist/mail/changes.js.map +0 -1
  288. package/dist/mail/cleanup.d.ts +0 -41
  289. package/dist/mail/cleanup.d.ts.map +0 -1
  290. package/dist/mail/cleanup.js.map +0 -1
  291. package/dist/mail/compose.d.ts +0 -75
  292. package/dist/mail/compose.d.ts.map +0 -1
  293. package/dist/mail/compose.js.map +0 -1
  294. package/dist/mail/domain-age.d.ts +0 -29
  295. package/dist/mail/domain-age.d.ts.map +0 -1
  296. package/dist/mail/domain-age.js.map +0 -1
  297. package/dist/mail/drafts.d.ts +0 -54
  298. package/dist/mail/drafts.d.ts.map +0 -1
  299. package/dist/mail/drafts.js.map +0 -1
  300. package/dist/mail/imap/account.d.ts +0 -5
  301. package/dist/mail/imap/account.d.ts.map +0 -1
  302. package/dist/mail/imap/account.js.map +0 -1
  303. package/dist/mail/imap/connection.d.ts +0 -72
  304. package/dist/mail/imap/connection.d.ts.map +0 -1
  305. package/dist/mail/imap/connection.js.map +0 -1
  306. package/dist/mail/imap/errors.d.ts +0 -11
  307. package/dist/mail/imap/errors.d.ts.map +0 -1
  308. package/dist/mail/imap/errors.js.map +0 -1
  309. package/dist/mail/imap/index.d.ts +0 -7
  310. package/dist/mail/imap/index.d.ts.map +0 -1
  311. package/dist/mail/imap/index.js.map +0 -1
  312. package/dist/mail/imap/messages.d.ts +0 -17
  313. package/dist/mail/imap/messages.d.ts.map +0 -1
  314. package/dist/mail/imap/messages.js.map +0 -1
  315. package/dist/mail/imap/read.d.ts +0 -7
  316. package/dist/mail/imap/read.d.ts.map +0 -1
  317. package/dist/mail/imap/read.js.map +0 -1
  318. package/dist/mail/imap/search.d.ts +0 -19
  319. package/dist/mail/imap/search.d.ts.map +0 -1
  320. package/dist/mail/imap/search.js.map +0 -1
  321. package/dist/mail/imap/write.d.ts +0 -5
  322. package/dist/mail/imap/write.d.ts.map +0 -1
  323. package/dist/mail/imap/write.js.map +0 -1
  324. package/dist/mail/locate.d.ts +0 -32
  325. package/dist/mail/locate.d.ts.map +0 -1
  326. package/dist/mail/locate.js.map +0 -1
  327. package/dist/mail/mbox.d.ts +0 -9
  328. package/dist/mail/mbox.d.ts.map +0 -1
  329. package/dist/mail/mbox.js.map +0 -1
  330. package/dist/mail/organise.d.ts +0 -101
  331. package/dist/mail/organise.d.ts.map +0 -1
  332. package/dist/mail/organise.js.map +0 -1
  333. package/dist/mail/restore.d.ts +0 -22
  334. package/dist/mail/restore.d.ts.map +0 -1
  335. package/dist/mail/restore.js.map +0 -1
  336. package/dist/mail/rethread.d.ts +0 -14
  337. package/dist/mail/rethread.d.ts.map +0 -1
  338. package/dist/mail/rethread.js.map +0 -1
  339. package/dist/mail/rules/apply.d.ts +0 -48
  340. package/dist/mail/rules/apply.d.ts.map +0 -1
  341. package/dist/mail/rules/apply.js.map +0 -1
  342. package/dist/mail/rules/file.d.ts +0 -9
  343. package/dist/mail/rules/file.d.ts.map +0 -1
  344. package/dist/mail/rules/file.js.map +0 -1
  345. package/dist/mail/rules/filters.d.ts +0 -11
  346. package/dist/mail/rules/filters.d.ts.map +0 -1
  347. package/dist/mail/rules/filters.js.map +0 -1
  348. package/dist/mail/rules/folders.d.ts +0 -11
  349. package/dist/mail/rules/folders.d.ts.map +0 -1
  350. package/dist/mail/rules/folders.js.map +0 -1
  351. package/dist/mail/rules/query.d.ts +0 -16
  352. package/dist/mail/rules/query.d.ts.map +0 -1
  353. package/dist/mail/rules/query.js.map +0 -1
  354. package/dist/mail/rules/store.d.ts +0 -9
  355. package/dist/mail/rules/store.d.ts.map +0 -1
  356. package/dist/mail/rules/store.js.map +0 -1
  357. package/dist/mail/save.d.ts +0 -9
  358. package/dist/mail/save.d.ts.map +0 -1
  359. package/dist/mail/save.js.map +0 -1
  360. package/dist/mail/send.d.ts +0 -76
  361. package/dist/mail/send.d.ts.map +0 -1
  362. package/dist/mail/send.js.map +0 -1
  363. package/dist/mail/smtp.d.ts +0 -4
  364. package/dist/mail/smtp.d.ts.map +0 -1
  365. package/dist/mail/smtp.js.map +0 -1
  366. package/dist/oauth.d.ts +0 -75
  367. package/dist/oauth.d.ts.map +0 -1
  368. package/dist/oauth.js.map +0 -1
  369. package/dist/profile.d.ts +0 -20
  370. package/dist/profile.d.ts.map +0 -1
  371. package/dist/profile.js.map +0 -1
  372. package/dist/program.d.ts +0 -6
  373. package/dist/program.d.ts.map +0 -1
  374. package/dist/program.js.map +0 -1
  375. package/dist/providers.d.ts +0 -255
  376. package/dist/providers.d.ts.map +0 -1
  377. package/dist/providers.js.map +0 -1
  378. package/dist/reasons.d.ts +0 -9
  379. package/dist/reasons.d.ts.map +0 -1
  380. package/dist/reasons.js.map +0 -1
  381. package/dist/secret.d.ts +0 -31
  382. package/dist/secret.d.ts.map +0 -1
  383. package/dist/secret.js.map +0 -1
  384. package/dist/store.d.ts +0 -12
  385. package/dist/store.d.ts.map +0 -1
  386. package/dist/store.js.map +0 -1
  387. package/dist/version.d.ts +0 -2
  388. package/dist/version.d.ts.map +0 -1
  389. package/dist/version.js.map +0 -1
  390. package/dist/wcat.d.ts +0 -3
  391. package/dist/wcat.d.ts.map +0 -1
  392. package/dist/wcat.js.map +0 -1
@@ -1,2669 +0,0 @@
1
- import { createRequire as __bundleRequire } from "node:module";
2
- const require = __bundleRequire(import.meta.url);
3
- import {
4
- errorCodes,
5
- isCliError,
6
- visibleControls
7
- } from "./chunk-S6JG4YUH.js";
8
- import {
9
- __name
10
- } from "./chunk-ZVVMGPBJ.js";
11
-
12
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/exit-codes.js
13
- var EXIT_CODES = {
14
- validation_error: 2,
15
- configuration_error: 3,
16
- authentication_error: 4,
17
- permission_error: 5,
18
- not_found: 6,
19
- confirmation_required: 7,
20
- rate_limited: 8,
21
- timeout: 9,
22
- network_error: 10,
23
- provider_error: 11,
24
- provider_unavailable: 12,
25
- invalid_response: 13,
26
- outcome_unknown: 14,
27
- conflict: 15,
28
- cancelled: 130
29
- };
30
- var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
31
- var GENERIC_FAILURE = 1;
32
-
33
- // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
34
- var store$4;
35
- var DEFAULT_CONFIG = {
36
- lang: void 0,
37
- message: void 0,
38
- abortEarly: void 0,
39
- abortPipeEarly: void 0
40
- };
41
- // @__NO_SIDE_EFFECTS__
42
- function getGlobalConfig(config$1) {
43
- if (!config$1 && !store$4) return DEFAULT_CONFIG;
44
- return {
45
- lang: config$1?.lang ?? store$4?.lang,
46
- message: config$1?.message,
47
- abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
48
- abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
49
- };
50
- }
51
- __name(getGlobalConfig, "getGlobalConfig");
52
- var store$3;
53
- // @__NO_SIDE_EFFECTS__
54
- function getGlobalMessage(lang) {
55
- return store$3?.get(lang);
56
- }
57
- __name(getGlobalMessage, "getGlobalMessage");
58
- var store$2;
59
- // @__NO_SIDE_EFFECTS__
60
- function getSchemaMessage(lang) {
61
- return store$2?.get(lang);
62
- }
63
- __name(getSchemaMessage, "getSchemaMessage");
64
- var store$1;
65
- // @__NO_SIDE_EFFECTS__
66
- function getSpecificMessage(reference2, lang) {
67
- return store$1?.get(reference2)?.get(lang);
68
- }
69
- __name(getSpecificMessage, "getSpecificMessage");
70
- // @__NO_SIDE_EFFECTS__
71
- function _stringify(input) {
72
- const type = typeof input;
73
- if (type === "string") return `"${input}"`;
74
- if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
75
- if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
76
- return type;
77
- }
78
- __name(_stringify, "_stringify");
79
- function _addIssue(context, label, dataset, config$1, other) {
80
- const input = other && "input" in other ? other.input : dataset.value;
81
- const expected = other?.expected ?? context.expects ?? null;
82
- const received = other?.received ?? /* @__PURE__ */ _stringify(input);
83
- const issue = {
84
- kind: context.kind,
85
- type: context.type,
86
- input,
87
- expected,
88
- received,
89
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
90
- requirement: context.requirement,
91
- path: other?.path,
92
- issues: other?.issues,
93
- lang: config$1.lang,
94
- abortEarly: config$1.abortEarly,
95
- abortPipeEarly: config$1.abortPipeEarly
96
- };
97
- const isSchema = context.kind === "schema";
98
- const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
99
- if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
100
- if (isSchema) dataset.typed = false;
101
- if (dataset.issues) dataset.issues.push(issue);
102
- else dataset.issues = [issue];
103
- }
104
- __name(_addIssue, "_addIssue");
105
- // @__NO_SIDE_EFFECTS__
106
- function _isSameValueZero(value1, value2) {
107
- return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
108
- }
109
- __name(_isSameValueZero, "_isSameValueZero");
110
- // @__NO_SIDE_EFFECTS__
111
- function _isValidObjectKey(object$1, key) {
112
- return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
113
- }
114
- __name(_isValidObjectKey, "_isValidObjectKey");
115
- // @__NO_SIDE_EFFECTS__
116
- function _joinExpects(values$1, separator) {
117
- const list = [...new Set(values$1)];
118
- if (list.length > 1) return `(${list.join(` ${separator} `)})`;
119
- return list[0] ?? "never";
120
- }
121
- __name(_joinExpects, "_joinExpects");
122
- function _standardSchema(schema) {
123
- schema["~standard"] = {
124
- version: 1,
125
- vendor: "valibot",
126
- validate: /* @__PURE__ */ __name((value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig()), "validate")
127
- };
128
- return schema;
129
- }
130
- __name(_standardSchema, "_standardSchema");
131
- // @__NO_SIDE_EFFECTS__
132
- function getDotPath(issue) {
133
- if (issue.path) {
134
- let key = "";
135
- for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
136
- else key += item.key;
137
- else return null;
138
- return key;
139
- }
140
- return null;
141
- }
142
- __name(getDotPath, "getDotPath");
143
- var ValiError = class extends Error {
144
- static {
145
- __name(this, "ValiError");
146
- }
147
- /**
148
- * Creates a Valibot error with useful information.
149
- *
150
- * @param issues The error issues.
151
- */
152
- constructor(issues) {
153
- super(issues[0].message);
154
- this.name = "ValiError";
155
- this.issues = issues;
156
- }
157
- };
158
- var EMAIL_REGEX = /^[\w+-]+(?:\.[\w+-]+)*@[\da-zA-Z]+(?:[.-][\da-zA-Z]+)*\.[a-zA-Z]{2,}$/u;
159
- var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
160
- var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])$/u;
161
- var ISO_TIMESTAMP_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;
162
- // @__NO_SIDE_EFFECTS__
163
- function check(requirement, message$1) {
164
- return {
165
- kind: "validation",
166
- type: "check",
167
- reference: check,
168
- async: false,
169
- expects: null,
170
- requirement,
171
- message: message$1,
172
- "~run"(dataset, config$1) {
173
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
174
- return dataset;
175
- }
176
- };
177
- }
178
- __name(check, "check");
179
- // @__NO_SIDE_EFFECTS__
180
- function description(description_) {
181
- return {
182
- kind: "metadata",
183
- type: "description",
184
- reference: description,
185
- description: description_
186
- };
187
- }
188
- __name(description, "description");
189
- // @__NO_SIDE_EFFECTS__
190
- function email(message$1) {
191
- return {
192
- kind: "validation",
193
- type: "email",
194
- reference: email,
195
- expects: null,
196
- async: false,
197
- requirement: EMAIL_REGEX,
198
- message: message$1,
199
- "~run"(dataset, config$1) {
200
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "email", dataset, config$1);
201
- return dataset;
202
- }
203
- };
204
- }
205
- __name(email, "email");
206
- // @__NO_SIDE_EFFECTS__
207
- function endsWith(requirement, message$1) {
208
- return {
209
- kind: "validation",
210
- type: "ends_with",
211
- reference: endsWith,
212
- async: false,
213
- expects: `"${requirement}"`,
214
- requirement,
215
- message: message$1,
216
- "~run"(dataset, config$1) {
217
- if (dataset.typed && !dataset.value.endsWith(this.requirement)) _addIssue(this, "end", dataset, config$1, { received: `"${dataset.value.slice(-this.requirement.length)}"` });
218
- return dataset;
219
- }
220
- };
221
- }
222
- __name(endsWith, "endsWith");
223
- // @__NO_SIDE_EFFECTS__
224
- function finite(message$1) {
225
- return {
226
- kind: "validation",
227
- type: "finite",
228
- reference: finite,
229
- async: false,
230
- expects: null,
231
- requirement: Number.isFinite,
232
- message: message$1,
233
- "~run"(dataset, config$1) {
234
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "finite", dataset, config$1);
235
- return dataset;
236
- }
237
- };
238
- }
239
- __name(finite, "finite");
240
- // @__NO_SIDE_EFFECTS__
241
- function integer(message$1) {
242
- return {
243
- kind: "validation",
244
- type: "integer",
245
- reference: integer,
246
- async: false,
247
- expects: null,
248
- requirement: Number.isInteger,
249
- message: message$1,
250
- "~run"(dataset, config$1) {
251
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
252
- return dataset;
253
- }
254
- };
255
- }
256
- __name(integer, "integer");
257
- // @__NO_SIDE_EFFECTS__
258
- function isoDate(message$1) {
259
- return {
260
- kind: "validation",
261
- type: "iso_date",
262
- reference: isoDate,
263
- async: false,
264
- expects: null,
265
- requirement: ISO_DATE_REGEX,
266
- message: message$1,
267
- "~run"(dataset, config$1) {
268
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "date", dataset, config$1);
269
- return dataset;
270
- }
271
- };
272
- }
273
- __name(isoDate, "isoDate");
274
- // @__NO_SIDE_EFFECTS__
275
- function isoTimestamp(message$1) {
276
- return {
277
- kind: "validation",
278
- type: "iso_timestamp",
279
- reference: isoTimestamp,
280
- async: false,
281
- expects: null,
282
- requirement: ISO_TIMESTAMP_REGEX,
283
- message: message$1,
284
- "~run"(dataset, config$1) {
285
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "timestamp", dataset, config$1);
286
- return dataset;
287
- }
288
- };
289
- }
290
- __name(isoTimestamp, "isoTimestamp");
291
- // @__NO_SIDE_EFFECTS__
292
- function maxEntries(requirement, message$1) {
293
- return {
294
- kind: "validation",
295
- type: "max_entries",
296
- reference: maxEntries,
297
- async: false,
298
- expects: `<=${requirement}`,
299
- requirement,
300
- message: message$1,
301
- "~run"(dataset, config$1) {
302
- if (!dataset.typed) return dataset;
303
- const count2 = Object.keys(dataset.value).length;
304
- if (dataset.typed && count2 > this.requirement) _addIssue(this, "entries", dataset, config$1, { received: `${count2}` });
305
- return dataset;
306
- }
307
- };
308
- }
309
- __name(maxEntries, "maxEntries");
310
- // @__NO_SIDE_EFFECTS__
311
- function maxLength(requirement, message$1) {
312
- return {
313
- kind: "validation",
314
- type: "max_length",
315
- reference: maxLength,
316
- async: false,
317
- expects: `<=${requirement}`,
318
- requirement,
319
- message: message$1,
320
- "~run"(dataset, config$1) {
321
- if (dataset.typed && dataset.value.length > this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
322
- return dataset;
323
- }
324
- };
325
- }
326
- __name(maxLength, "maxLength");
327
- // @__NO_SIDE_EFFECTS__
328
- function maxValue(requirement, message$1) {
329
- return {
330
- kind: "validation",
331
- type: "max_value",
332
- reference: maxValue,
333
- async: false,
334
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
335
- requirement,
336
- message: message$1,
337
- "~run"(dataset, config$1) {
338
- if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
339
- return dataset;
340
- }
341
- };
342
- }
343
- __name(maxValue, "maxValue");
344
- // @__NO_SIDE_EFFECTS__
345
- function minLength(requirement, message$1) {
346
- return {
347
- kind: "validation",
348
- type: "min_length",
349
- reference: minLength,
350
- async: false,
351
- expects: `>=${requirement}`,
352
- requirement,
353
- message: message$1,
354
- "~run"(dataset, config$1) {
355
- if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
356
- return dataset;
357
- }
358
- };
359
- }
360
- __name(minLength, "minLength");
361
- // @__NO_SIDE_EFFECTS__
362
- function minValue(requirement, message$1) {
363
- return {
364
- kind: "validation",
365
- type: "min_value",
366
- reference: minValue,
367
- async: false,
368
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
369
- requirement,
370
- message: message$1,
371
- "~run"(dataset, config$1) {
372
- if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
373
- return dataset;
374
- }
375
- };
376
- }
377
- __name(minValue, "minValue");
378
- // @__NO_SIDE_EFFECTS__
379
- function nonEmpty(message$1) {
380
- return {
381
- kind: "validation",
382
- type: "non_empty",
383
- reference: nonEmpty,
384
- async: false,
385
- expects: "!0",
386
- message: message$1,
387
- "~run"(dataset, config$1) {
388
- if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
389
- return dataset;
390
- }
391
- };
392
- }
393
- __name(nonEmpty, "nonEmpty");
394
- // @__NO_SIDE_EFFECTS__
395
- function regex(requirement, message$1) {
396
- return {
397
- kind: "validation",
398
- type: "regex",
399
- reference: regex,
400
- async: false,
401
- expects: `${requirement}`,
402
- requirement,
403
- message: message$1,
404
- "~run"(dataset, config$1) {
405
- if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
406
- return dataset;
407
- }
408
- };
409
- }
410
- __name(regex, "regex");
411
- // @__NO_SIDE_EFFECTS__
412
- function safeInteger(message$1) {
413
- return {
414
- kind: "validation",
415
- type: "safe_integer",
416
- reference: safeInteger,
417
- async: false,
418
- expects: null,
419
- requirement: Number.isSafeInteger,
420
- message: message$1,
421
- "~run"(dataset, config$1) {
422
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
423
- return dataset;
424
- }
425
- };
426
- }
427
- __name(safeInteger, "safeInteger");
428
- // @__NO_SIDE_EFFECTS__
429
- function startsWith(requirement, message$1) {
430
- return {
431
- kind: "validation",
432
- type: "starts_with",
433
- reference: startsWith,
434
- async: false,
435
- expects: `"${requirement}"`,
436
- requirement,
437
- message: message$1,
438
- "~run"(dataset, config$1) {
439
- if (dataset.typed && !dataset.value.startsWith(this.requirement)) _addIssue(this, "start", dataset, config$1, { received: `"${dataset.value.slice(0, this.requirement.length)}"` });
440
- return dataset;
441
- }
442
- };
443
- }
444
- __name(startsWith, "startsWith");
445
- // @__NO_SIDE_EFFECTS__
446
- function transform(operation) {
447
- return {
448
- kind: "transformation",
449
- type: "transform",
450
- reference: transform,
451
- async: false,
452
- operation,
453
- "~run"(dataset) {
454
- dataset.value = this.operation(dataset.value);
455
- return dataset;
456
- }
457
- };
458
- }
459
- __name(transform, "transform");
460
- // @__NO_SIDE_EFFECTS__
461
- function trim() {
462
- return {
463
- kind: "transformation",
464
- type: "trim",
465
- reference: trim,
466
- async: false,
467
- "~run"(dataset) {
468
- dataset.value = dataset.value.trim();
469
- return dataset;
470
- }
471
- };
472
- }
473
- __name(trim, "trim");
474
- // @__NO_SIDE_EFFECTS__
475
- function url(message$1) {
476
- return {
477
- kind: "validation",
478
- type: "url",
479
- reference: url,
480
- async: false,
481
- expects: null,
482
- requirement(input) {
483
- try {
484
- if (URL.canParse) return URL.canParse(input);
485
- new URL(input);
486
- return true;
487
- } catch {
488
- return false;
489
- }
490
- },
491
- message: message$1,
492
- "~run"(dataset, config$1) {
493
- if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "URL", dataset, config$1);
494
- return dataset;
495
- }
496
- };
497
- }
498
- __name(url, "url");
499
- var ABORT_EARLY_CONFIG = { abortEarly: true };
500
- // @__NO_SIDE_EFFECTS__
501
- function getFallback(schema, dataset, config$1) {
502
- return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
503
- }
504
- __name(getFallback, "getFallback");
505
- // @__NO_SIDE_EFFECTS__
506
- function forward(action, path) {
507
- return {
508
- ...action,
509
- "~run"(dataset, config$1) {
510
- const prevIssues = dataset.issues && [...dataset.issues];
511
- dataset = action["~run"](dataset, config$1);
512
- if (dataset.issues) {
513
- for (const issue of dataset.issues) if (!prevIssues?.includes(issue)) {
514
- let pathInput = dataset.value;
515
- for (const key of path) {
516
- const pathValue = pathInput[key];
517
- const pathItem = {
518
- type: "unknown",
519
- origin: "value",
520
- input: pathInput,
521
- key,
522
- value: pathValue
523
- };
524
- if (issue.path) issue.path.push(pathItem);
525
- else issue.path = [pathItem];
526
- if (!pathValue) break;
527
- pathInput = pathValue;
528
- }
529
- }
530
- }
531
- return dataset;
532
- }
533
- };
534
- }
535
- __name(forward, "forward");
536
- // @__NO_SIDE_EFFECTS__
537
- function getDefault(schema, dataset, config$1) {
538
- return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
539
- }
540
- __name(getDefault, "getDefault");
541
- // @__NO_SIDE_EFFECTS__
542
- function array(item, message$1) {
543
- return _standardSchema({
544
- kind: "schema",
545
- type: "array",
546
- reference: array,
547
- expects: "Array",
548
- async: false,
549
- item,
550
- message: message$1,
551
- "~run"(dataset, config$1) {
552
- const input = dataset.value;
553
- if (Array.isArray(input)) {
554
- dataset.typed = true;
555
- dataset.value = [];
556
- for (let key = 0; key < input.length; key++) {
557
- const value$1 = input[key];
558
- const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
559
- if (itemDataset.issues) {
560
- const pathItem = {
561
- type: "array",
562
- origin: "value",
563
- input,
564
- key,
565
- value: value$1
566
- };
567
- for (const issue of itemDataset.issues) {
568
- if (issue.path) issue.path.unshift(pathItem);
569
- else issue.path = [pathItem];
570
- dataset.issues?.push(issue);
571
- }
572
- if (!dataset.issues) dataset.issues = itemDataset.issues;
573
- if (config$1.abortEarly) {
574
- dataset.typed = false;
575
- break;
576
- }
577
- }
578
- if (!itemDataset.typed) dataset.typed = false;
579
- dataset.value.push(itemDataset.value);
580
- }
581
- } else _addIssue(this, "type", dataset, config$1);
582
- return dataset;
583
- }
584
- });
585
- }
586
- __name(array, "array");
587
- // @__NO_SIDE_EFFECTS__
588
- function boolean(message$1) {
589
- return _standardSchema({
590
- kind: "schema",
591
- type: "boolean",
592
- reference: boolean,
593
- expects: "boolean",
594
- async: false,
595
- message: message$1,
596
- "~run"(dataset, config$1) {
597
- if (typeof dataset.value === "boolean") dataset.typed = true;
598
- else _addIssue(this, "type", dataset, config$1);
599
- return dataset;
600
- }
601
- });
602
- }
603
- __name(boolean, "boolean");
604
- // @__NO_SIDE_EFFECTS__
605
- function exactOptional(wrapped, default_) {
606
- return _standardSchema({
607
- kind: "schema",
608
- type: "exact_optional",
609
- reference: exactOptional,
610
- expects: wrapped.expects,
611
- async: false,
612
- wrapped,
613
- default: default_,
614
- "~run"(dataset, config$1) {
615
- return this.wrapped["~run"](dataset, config$1);
616
- }
617
- });
618
- }
619
- __name(exactOptional, "exactOptional");
620
- // @__NO_SIDE_EFFECTS__
621
- function function_(message$1) {
622
- return _standardSchema({
623
- kind: "schema",
624
- type: "function",
625
- reference: function_,
626
- expects: "Function",
627
- async: false,
628
- message: message$1,
629
- "~run"(dataset, config$1) {
630
- if (typeof dataset.value === "function") dataset.typed = true;
631
- else _addIssue(this, "type", dataset, config$1);
632
- return dataset;
633
- }
634
- });
635
- }
636
- __name(function_, "function_");
637
- // @__NO_SIDE_EFFECTS__
638
- function lazy(getter) {
639
- return _standardSchema({
640
- kind: "schema",
641
- type: "lazy",
642
- reference: lazy,
643
- expects: "unknown",
644
- async: false,
645
- getter,
646
- "~run"(dataset, config$1) {
647
- return this.getter(dataset.value)["~run"](dataset, config$1);
648
- }
649
- });
650
- }
651
- __name(lazy, "lazy");
652
- // @__NO_SIDE_EFFECTS__
653
- function literal(literal_, message$1) {
654
- return _standardSchema({
655
- kind: "schema",
656
- type: "literal",
657
- reference: literal,
658
- expects: /* @__PURE__ */ _stringify(literal_),
659
- async: false,
660
- literal: literal_,
661
- message: message$1,
662
- "~run"(dataset, config$1) {
663
- if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
664
- else _addIssue(this, "type", dataset, config$1);
665
- return dataset;
666
- }
667
- });
668
- }
669
- __name(literal, "literal");
670
- // @__NO_SIDE_EFFECTS__
671
- function looseObject(entries$1, message$1) {
672
- return _standardSchema({
673
- kind: "schema",
674
- type: "loose_object",
675
- reference: looseObject,
676
- expects: "Object",
677
- async: false,
678
- entries: entries$1,
679
- message: message$1,
680
- "~run"(dataset, config$1) {
681
- const input = dataset.value;
682
- if (input && typeof input === "object") {
683
- dataset.typed = true;
684
- dataset.value = {};
685
- for (const key in this.entries) {
686
- const valueSchema = this.entries[key];
687
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
688
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
689
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
690
- if (valueDataset.issues) {
691
- const pathItem = {
692
- type: "object",
693
- origin: "value",
694
- input,
695
- key,
696
- value: value$1
697
- };
698
- for (const issue of valueDataset.issues) {
699
- if (issue.path) issue.path.unshift(pathItem);
700
- else issue.path = [pathItem];
701
- dataset.issues?.push(issue);
702
- }
703
- if (!dataset.issues) dataset.issues = valueDataset.issues;
704
- if (config$1.abortEarly) {
705
- dataset.typed = false;
706
- break;
707
- }
708
- }
709
- if (!valueDataset.typed) dataset.typed = false;
710
- dataset.value[key] = valueDataset.value;
711
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
712
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
713
- _addIssue(this, "key", dataset, config$1, {
714
- input: void 0,
715
- expected: `"${key}"`,
716
- path: [{
717
- type: "object",
718
- origin: "key",
719
- input,
720
- key,
721
- value: input[key]
722
- }]
723
- });
724
- if (config$1.abortEarly) break;
725
- }
726
- }
727
- if (!dataset.issues || !config$1.abortEarly) {
728
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
729
- }
730
- } else _addIssue(this, "type", dataset, config$1);
731
- return dataset;
732
- }
733
- });
734
- }
735
- __name(looseObject, "looseObject");
736
- // @__NO_SIDE_EFFECTS__
737
- function null_(message$1) {
738
- return _standardSchema({
739
- kind: "schema",
740
- type: "null",
741
- reference: null_,
742
- expects: "null",
743
- async: false,
744
- message: message$1,
745
- "~run"(dataset, config$1) {
746
- if (dataset.value === null) dataset.typed = true;
747
- else _addIssue(this, "type", dataset, config$1);
748
- return dataset;
749
- }
750
- });
751
- }
752
- __name(null_, "null_");
753
- // @__NO_SIDE_EFFECTS__
754
- function nullable(wrapped, default_) {
755
- return _standardSchema({
756
- kind: "schema",
757
- type: "nullable",
758
- reference: nullable,
759
- expects: `(${wrapped.expects} | null)`,
760
- async: false,
761
- wrapped,
762
- default: default_,
763
- "~run"(dataset, config$1) {
764
- if (dataset.value === null) {
765
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
766
- if (dataset.value === null) {
767
- dataset.typed = true;
768
- return dataset;
769
- }
770
- }
771
- return this.wrapped["~run"](dataset, config$1);
772
- }
773
- });
774
- }
775
- __name(nullable, "nullable");
776
- // @__NO_SIDE_EFFECTS__
777
- function nullish(wrapped, default_) {
778
- return _standardSchema({
779
- kind: "schema",
780
- type: "nullish",
781
- reference: nullish,
782
- expects: `(${wrapped.expects} | null | undefined)`,
783
- async: false,
784
- wrapped,
785
- default: default_,
786
- "~run"(dataset, config$1) {
787
- if (dataset.value === null || dataset.value === void 0) {
788
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
789
- if (dataset.value === null || dataset.value === void 0) {
790
- dataset.typed = true;
791
- return dataset;
792
- }
793
- }
794
- return this.wrapped["~run"](dataset, config$1);
795
- }
796
- });
797
- }
798
- __name(nullish, "nullish");
799
- // @__NO_SIDE_EFFECTS__
800
- function number(message$1) {
801
- return _standardSchema({
802
- kind: "schema",
803
- type: "number",
804
- reference: number,
805
- expects: "number",
806
- async: false,
807
- message: message$1,
808
- "~run"(dataset, config$1) {
809
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
810
- else _addIssue(this, "type", dataset, config$1);
811
- return dataset;
812
- }
813
- });
814
- }
815
- __name(number, "number");
816
- // @__NO_SIDE_EFFECTS__
817
- function object(entries$1, message$1) {
818
- return _standardSchema({
819
- kind: "schema",
820
- type: "object",
821
- reference: object,
822
- expects: "Object",
823
- async: false,
824
- entries: entries$1,
825
- message: message$1,
826
- "~run"(dataset, config$1) {
827
- const input = dataset.value;
828
- if (input && typeof input === "object") {
829
- dataset.typed = true;
830
- dataset.value = {};
831
- for (const key in this.entries) {
832
- const valueSchema = this.entries[key];
833
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
834
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
835
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
836
- if (valueDataset.issues) {
837
- const pathItem = {
838
- type: "object",
839
- origin: "value",
840
- input,
841
- key,
842
- value: value$1
843
- };
844
- for (const issue of valueDataset.issues) {
845
- if (issue.path) issue.path.unshift(pathItem);
846
- else issue.path = [pathItem];
847
- dataset.issues?.push(issue);
848
- }
849
- if (!dataset.issues) dataset.issues = valueDataset.issues;
850
- if (config$1.abortEarly) {
851
- dataset.typed = false;
852
- break;
853
- }
854
- }
855
- if (!valueDataset.typed) dataset.typed = false;
856
- dataset.value[key] = valueDataset.value;
857
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
858
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
859
- _addIssue(this, "key", dataset, config$1, {
860
- input: void 0,
861
- expected: `"${key}"`,
862
- path: [{
863
- type: "object",
864
- origin: "key",
865
- input,
866
- key,
867
- value: input[key]
868
- }]
869
- });
870
- if (config$1.abortEarly) break;
871
- }
872
- }
873
- } else _addIssue(this, "type", dataset, config$1);
874
- return dataset;
875
- }
876
- });
877
- }
878
- __name(object, "object");
879
- // @__NO_SIDE_EFFECTS__
880
- function objectWithRest(entries$1, rest, message$1) {
881
- return _standardSchema({
882
- kind: "schema",
883
- type: "object_with_rest",
884
- reference: objectWithRest,
885
- expects: "Object",
886
- async: false,
887
- entries: entries$1,
888
- rest,
889
- message: message$1,
890
- "~run"(dataset, config$1) {
891
- const input = dataset.value;
892
- if (input && typeof input === "object") {
893
- dataset.typed = true;
894
- dataset.value = {};
895
- for (const key in this.entries) {
896
- const valueSchema = this.entries[key];
897
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
898
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
899
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
900
- if (valueDataset.issues) {
901
- const pathItem = {
902
- type: "object",
903
- origin: "value",
904
- input,
905
- key,
906
- value: value$1
907
- };
908
- for (const issue of valueDataset.issues) {
909
- if (issue.path) issue.path.unshift(pathItem);
910
- else issue.path = [pathItem];
911
- dataset.issues?.push(issue);
912
- }
913
- if (!dataset.issues) dataset.issues = valueDataset.issues;
914
- if (config$1.abortEarly) {
915
- dataset.typed = false;
916
- break;
917
- }
918
- }
919
- if (!valueDataset.typed) dataset.typed = false;
920
- dataset.value[key] = valueDataset.value;
921
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
922
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
923
- _addIssue(this, "key", dataset, config$1, {
924
- input: void 0,
925
- expected: `"${key}"`,
926
- path: [{
927
- type: "object",
928
- origin: "key",
929
- input,
930
- key,
931
- value: input[key]
932
- }]
933
- });
934
- if (config$1.abortEarly) break;
935
- }
936
- }
937
- if (!dataset.issues || !config$1.abortEarly) {
938
- for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
939
- const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
940
- if (valueDataset.issues) {
941
- const pathItem = {
942
- type: "object",
943
- origin: "value",
944
- input,
945
- key,
946
- value: input[key]
947
- };
948
- for (const issue of valueDataset.issues) {
949
- if (issue.path) issue.path.unshift(pathItem);
950
- else issue.path = [pathItem];
951
- dataset.issues?.push(issue);
952
- }
953
- if (!dataset.issues) dataset.issues = valueDataset.issues;
954
- if (config$1.abortEarly) {
955
- dataset.typed = false;
956
- break;
957
- }
958
- }
959
- if (!valueDataset.typed) dataset.typed = false;
960
- dataset.value[key] = valueDataset.value;
961
- }
962
- }
963
- } else _addIssue(this, "type", dataset, config$1);
964
- return dataset;
965
- }
966
- });
967
- }
968
- __name(objectWithRest, "objectWithRest");
969
- // @__NO_SIDE_EFFECTS__
970
- function optional(wrapped, default_) {
971
- return _standardSchema({
972
- kind: "schema",
973
- type: "optional",
974
- reference: optional,
975
- expects: `(${wrapped.expects} | undefined)`,
976
- async: false,
977
- wrapped,
978
- default: default_,
979
- "~run"(dataset, config$1) {
980
- if (dataset.value === void 0) {
981
- if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
982
- if (dataset.value === void 0) {
983
- dataset.typed = true;
984
- return dataset;
985
- }
986
- }
987
- return this.wrapped["~run"](dataset, config$1);
988
- }
989
- });
990
- }
991
- __name(optional, "optional");
992
- // @__NO_SIDE_EFFECTS__
993
- function picklist(options, message$1) {
994
- return _standardSchema({
995
- kind: "schema",
996
- type: "picklist",
997
- reference: picklist,
998
- expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
999
- async: false,
1000
- options,
1001
- message: message$1,
1002
- "~run"(dataset, config$1) {
1003
- if (this.options.includes(dataset.value)) dataset.typed = true;
1004
- else _addIssue(this, "type", dataset, config$1);
1005
- return dataset;
1006
- }
1007
- });
1008
- }
1009
- __name(picklist, "picklist");
1010
- // @__NO_SIDE_EFFECTS__
1011
- function record(key, value$1, message$1) {
1012
- return _standardSchema({
1013
- kind: "schema",
1014
- type: "record",
1015
- reference: record,
1016
- expects: "Object",
1017
- async: false,
1018
- key,
1019
- value: value$1,
1020
- message: message$1,
1021
- "~run"(dataset, config$1) {
1022
- const input = dataset.value;
1023
- if (input && typeof input === "object") {
1024
- dataset.typed = true;
1025
- dataset.value = {};
1026
- for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
1027
- const entryValue = input[entryKey];
1028
- const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
1029
- if (keyDataset.issues) {
1030
- const pathItem = {
1031
- type: "object",
1032
- origin: "key",
1033
- input,
1034
- key: entryKey,
1035
- value: entryValue
1036
- };
1037
- for (const issue of keyDataset.issues) {
1038
- issue.path = [pathItem];
1039
- dataset.issues?.push(issue);
1040
- }
1041
- if (!dataset.issues) dataset.issues = keyDataset.issues;
1042
- if (config$1.abortEarly) {
1043
- dataset.typed = false;
1044
- break;
1045
- }
1046
- }
1047
- const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
1048
- if (valueDataset.issues) {
1049
- const pathItem = {
1050
- type: "object",
1051
- origin: "value",
1052
- input,
1053
- key: entryKey,
1054
- value: entryValue
1055
- };
1056
- for (const issue of valueDataset.issues) {
1057
- if (issue.path) issue.path.unshift(pathItem);
1058
- else issue.path = [pathItem];
1059
- dataset.issues?.push(issue);
1060
- }
1061
- if (!dataset.issues) dataset.issues = valueDataset.issues;
1062
- if (config$1.abortEarly) {
1063
- dataset.typed = false;
1064
- break;
1065
- }
1066
- }
1067
- if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
1068
- if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
1069
- }
1070
- } else _addIssue(this, "type", dataset, config$1);
1071
- return dataset;
1072
- }
1073
- });
1074
- }
1075
- __name(record, "record");
1076
- // @__NO_SIDE_EFFECTS__
1077
- function strictObject(entries$1, message$1) {
1078
- return _standardSchema({
1079
- kind: "schema",
1080
- type: "strict_object",
1081
- reference: strictObject,
1082
- expects: "Object",
1083
- async: false,
1084
- entries: entries$1,
1085
- message: message$1,
1086
- "~run"(dataset, config$1) {
1087
- const input = dataset.value;
1088
- if (input && typeof input === "object") {
1089
- dataset.typed = true;
1090
- dataset.value = {};
1091
- for (const key in this.entries) {
1092
- const valueSchema = this.entries[key];
1093
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
1094
- const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
1095
- const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
1096
- if (valueDataset.issues) {
1097
- const pathItem = {
1098
- type: "object",
1099
- origin: "value",
1100
- input,
1101
- key,
1102
- value: value$1
1103
- };
1104
- for (const issue of valueDataset.issues) {
1105
- if (issue.path) issue.path.unshift(pathItem);
1106
- else issue.path = [pathItem];
1107
- dataset.issues?.push(issue);
1108
- }
1109
- if (!dataset.issues) dataset.issues = valueDataset.issues;
1110
- if (config$1.abortEarly) {
1111
- dataset.typed = false;
1112
- break;
1113
- }
1114
- }
1115
- if (!valueDataset.typed) dataset.typed = false;
1116
- dataset.value[key] = valueDataset.value;
1117
- } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
1118
- else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
1119
- _addIssue(this, "key", dataset, config$1, {
1120
- input: void 0,
1121
- expected: `"${key}"`,
1122
- path: [{
1123
- type: "object",
1124
- origin: "key",
1125
- input,
1126
- key,
1127
- value: input[key]
1128
- }]
1129
- });
1130
- if (config$1.abortEarly) break;
1131
- }
1132
- }
1133
- if (!dataset.issues || !config$1.abortEarly) {
1134
- for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
1135
- _addIssue(this, "key", dataset, config$1, {
1136
- input: key,
1137
- expected: "never",
1138
- path: [{
1139
- type: "object",
1140
- origin: "key",
1141
- input,
1142
- key,
1143
- value: input[key]
1144
- }]
1145
- });
1146
- break;
1147
- }
1148
- }
1149
- } else _addIssue(this, "type", dataset, config$1);
1150
- return dataset;
1151
- }
1152
- });
1153
- }
1154
- __name(strictObject, "strictObject");
1155
- // @__NO_SIDE_EFFECTS__
1156
- function string(message$1) {
1157
- return _standardSchema({
1158
- kind: "schema",
1159
- type: "string",
1160
- reference: string,
1161
- expects: "string",
1162
- async: false,
1163
- message: message$1,
1164
- "~run"(dataset, config$1) {
1165
- if (typeof dataset.value === "string") dataset.typed = true;
1166
- else _addIssue(this, "type", dataset, config$1);
1167
- return dataset;
1168
- }
1169
- });
1170
- }
1171
- __name(string, "string");
1172
- // @__NO_SIDE_EFFECTS__
1173
- function tuple(items, message$1) {
1174
- return _standardSchema({
1175
- kind: "schema",
1176
- type: "tuple",
1177
- reference: tuple,
1178
- expects: "Array",
1179
- async: false,
1180
- items,
1181
- message: message$1,
1182
- "~run"(dataset, config$1) {
1183
- const input = dataset.value;
1184
- if (Array.isArray(input)) {
1185
- dataset.typed = true;
1186
- dataset.value = [];
1187
- for (let key = 0; key < this.items.length; key++) {
1188
- const value$1 = input[key];
1189
- const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
1190
- if (itemDataset.issues) {
1191
- const pathItem = {
1192
- type: "array",
1193
- origin: "value",
1194
- input,
1195
- key,
1196
- value: value$1
1197
- };
1198
- for (const issue of itemDataset.issues) {
1199
- if (issue.path) issue.path.unshift(pathItem);
1200
- else issue.path = [pathItem];
1201
- dataset.issues?.push(issue);
1202
- }
1203
- if (!dataset.issues) dataset.issues = itemDataset.issues;
1204
- if (config$1.abortEarly) {
1205
- dataset.typed = false;
1206
- break;
1207
- }
1208
- }
1209
- if (!itemDataset.typed) dataset.typed = false;
1210
- dataset.value.push(itemDataset.value);
1211
- }
1212
- } else _addIssue(this, "type", dataset, config$1);
1213
- return dataset;
1214
- }
1215
- });
1216
- }
1217
- __name(tuple, "tuple");
1218
- // @__NO_SIDE_EFFECTS__
1219
- function _subIssues(datasets) {
1220
- let issues;
1221
- if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
1222
- else issues = dataset.issues;
1223
- return issues;
1224
- }
1225
- __name(_subIssues, "_subIssues");
1226
- // @__NO_SIDE_EFFECTS__
1227
- function union(options, message$1) {
1228
- return _standardSchema({
1229
- kind: "schema",
1230
- type: "union",
1231
- reference: union,
1232
- expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1233
- async: false,
1234
- options,
1235
- message: message$1,
1236
- "~run"(dataset, config$1) {
1237
- let validDataset;
1238
- let typedDatasets;
1239
- let untypedDatasets;
1240
- for (const schema of this.options) {
1241
- const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
1242
- if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
1243
- else typedDatasets = [optionDataset];
1244
- else {
1245
- validDataset = optionDataset;
1246
- break;
1247
- }
1248
- else if (untypedDatasets) untypedDatasets.push(optionDataset);
1249
- else untypedDatasets = [optionDataset];
1250
- }
1251
- if (validDataset) return validDataset;
1252
- if (typedDatasets) {
1253
- if (typedDatasets.length === 1) return typedDatasets[0];
1254
- _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
1255
- dataset.typed = true;
1256
- } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
1257
- else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
1258
- return dataset;
1259
- }
1260
- });
1261
- }
1262
- __name(union, "union");
1263
- // @__NO_SIDE_EFFECTS__
1264
- function unknown() {
1265
- return _standardSchema({
1266
- kind: "schema",
1267
- type: "unknown",
1268
- reference: unknown,
1269
- expects: "unknown",
1270
- async: false,
1271
- "~run"(dataset) {
1272
- dataset.typed = true;
1273
- return dataset;
1274
- }
1275
- });
1276
- }
1277
- __name(unknown, "unknown");
1278
- // @__NO_SIDE_EFFECTS__
1279
- function variant(key, options, message$1) {
1280
- return _standardSchema({
1281
- kind: "schema",
1282
- type: "variant",
1283
- reference: variant,
1284
- expects: "Object",
1285
- async: false,
1286
- key,
1287
- options,
1288
- message: message$1,
1289
- "~run"(dataset, config$1) {
1290
- const input = dataset.value;
1291
- if (input && typeof input === "object") {
1292
- let outputDataset;
1293
- let maxDiscriminatorPriority = 0;
1294
- let invalidDiscriminatorKey = this.key;
1295
- let expectedDiscriminators = [];
1296
- const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
1297
- for (const schema of variant$1.options) {
1298
- if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
1299
- else {
1300
- let keysAreValid = true;
1301
- let currentPriority = 0;
1302
- for (const currentKey of allKeys) {
1303
- const discriminatorSchema = schema.entries[currentKey];
1304
- if (currentKey in input ? discriminatorSchema["~run"]({
1305
- typed: false,
1306
- value: input[currentKey]
1307
- }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
1308
- keysAreValid = false;
1309
- if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
1310
- maxDiscriminatorPriority = currentPriority;
1311
- invalidDiscriminatorKey = currentKey;
1312
- expectedDiscriminators = [];
1313
- }
1314
- if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
1315
- break;
1316
- }
1317
- currentPriority++;
1318
- }
1319
- if (keysAreValid) {
1320
- const optionDataset = schema["~run"]({ value: input }, config$1);
1321
- if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
1322
- }
1323
- }
1324
- if (outputDataset && !outputDataset.issues) break;
1325
- }
1326
- }, "parseOptions");
1327
- parseOptions(this, /* @__PURE__ */ new Set([this.key]));
1328
- if (outputDataset) return outputDataset;
1329
- _addIssue(this, "type", dataset, config$1, {
1330
- input: input[invalidDiscriminatorKey],
1331
- expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
1332
- path: [{
1333
- type: "object",
1334
- origin: "value",
1335
- input,
1336
- key: invalidDiscriminatorKey,
1337
- value: input[invalidDiscriminatorKey]
1338
- }]
1339
- });
1340
- } else _addIssue(this, "type", dataset, config$1);
1341
- return dataset;
1342
- }
1343
- });
1344
- }
1345
- __name(variant, "variant");
1346
- // @__NO_SIDE_EFFECTS__
1347
- function omit(schema, keys) {
1348
- const entries$1 = { ...schema.entries };
1349
- for (const key of keys) delete entries$1[key];
1350
- return _standardSchema({
1351
- ...schema,
1352
- entries: entries$1
1353
- });
1354
- }
1355
- __name(omit, "omit");
1356
- function parse(schema, input, config$1) {
1357
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1358
- if (dataset.issues) throw new ValiError(dataset.issues);
1359
- return dataset.value;
1360
- }
1361
- __name(parse, "parse");
1362
- // @__NO_SIDE_EFFECTS__
1363
- function partial(schema, keys) {
1364
- const entries$1 = {};
1365
- for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
1366
- return _standardSchema({
1367
- ...schema,
1368
- entries: entries$1
1369
- });
1370
- }
1371
- __name(partial, "partial");
1372
- // @__NO_SIDE_EFFECTS__
1373
- function pick(schema, keys) {
1374
- const entries$1 = {};
1375
- for (const key of keys) entries$1[key] = schema.entries[key];
1376
- return _standardSchema({
1377
- ...schema,
1378
- entries: entries$1
1379
- });
1380
- }
1381
- __name(pick, "pick");
1382
- // @__NO_SIDE_EFFECTS__
1383
- function pipe(...pipe$1) {
1384
- return _standardSchema({
1385
- ...pipe$1[0],
1386
- pipe: pipe$1,
1387
- "~run"(dataset, config$1) {
1388
- for (const item of pipe$1) if (item.kind !== "metadata") {
1389
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
1390
- dataset.typed = false;
1391
- break;
1392
- }
1393
- if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
1394
- }
1395
- return dataset;
1396
- }
1397
- });
1398
- }
1399
- __name(pipe, "pipe");
1400
- // @__NO_SIDE_EFFECTS__
1401
- function safeParse(schema, input, config$1) {
1402
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1403
- return {
1404
- typed: dataset.typed,
1405
- success: !dataset.issues,
1406
- output: dataset.value,
1407
- issues: dataset.issues
1408
- };
1409
- }
1410
- __name(safeParse, "safeParse");
1411
- // @__NO_SIDE_EFFECTS__
1412
- function summarize(issues) {
1413
- let summary = "";
1414
- for (const issue of issues) {
1415
- if (summary) summary += "\n";
1416
- summary += `\xD7 ${issue.message}`;
1417
- const dotPath = /* @__PURE__ */ getDotPath(issue);
1418
- if (dotPath) summary += `
1419
- \u2192 at ${dotPath}`;
1420
- }
1421
- return summary;
1422
- }
1423
- __name(summarize, "summarize");
1424
- // @__NO_SIDE_EFFECTS__
1425
- function unwrap(schema) {
1426
- return schema.wrapped;
1427
- }
1428
- __name(unwrap, "unwrap");
1429
-
1430
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
1431
- var EFFECT_LEVELS = ["none", "read", "write"];
1432
- var effectsSchema = strictObject({
1433
- remote: picklist(EFFECT_LEVELS),
1434
- local: picklist(EFFECT_LEVELS)
1435
- });
1436
- var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
1437
-
1438
- // node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@7.0.2_/node_modules/@valibot/to-json-schema/dist/index.mjs
1439
- function addError(errors, message) {
1440
- if (errors) {
1441
- errors.push(message);
1442
- return errors;
1443
- }
1444
- return [message];
1445
- }
1446
- __name(addError, "addError");
1447
- var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
1448
- function escapeRegExp(string2) {
1449
- return string2.replace(ESCAPE_REGEX, "\\$&");
1450
- }
1451
- __name(escapeRegExp, "escapeRegExp");
1452
- function handleError(message, config) {
1453
- switch (config?.errorMode) {
1454
- case "ignore":
1455
- break;
1456
- case "warn":
1457
- console.warn(message);
1458
- break;
1459
- default:
1460
- throw new Error(message);
1461
- }
1462
- }
1463
- __name(handleError, "handleError");
1464
- function isJsonConstValue(value) {
1465
- return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
1466
- }
1467
- __name(isJsonConstValue, "isJsonConstValue");
1468
- function isJsonEnumValues(values) {
1469
- return values.every(isJsonConstValue);
1470
- }
1471
- __name(isJsonEnumValues, "isJsonEnumValues");
1472
- var ReferenceMap = class extends Map {
1473
- static {
1474
- __name(this, "ReferenceMap");
1475
- }
1476
- /**
1477
- * Creates an empty schema reference map.
1478
- */
1479
- constructor() {
1480
- super();
1481
- this.count = 0;
1482
- this.usedIds = /* @__PURE__ */ new Set();
1483
- }
1484
- /**
1485
- * Adds a schema reference and reserves its ID.
1486
- *
1487
- * @param schema The Valibot schema.
1488
- * @param referenceId The reference ID.
1489
- *
1490
- * @returns The reference map.
1491
- */
1492
- set(schema, referenceId) {
1493
- this.usedIds.add(referenceId);
1494
- return super.set(schema, referenceId);
1495
- }
1496
- /**
1497
- * Creates a reference ID that is not yet used.
1498
- *
1499
- * @param definitions The JSON Schema definitions.
1500
- *
1501
- * @returns The unused reference ID.
1502
- */
1503
- createId(definitions) {
1504
- while (this.usedIds.has(`${this.count}`) || `${this.count}` in definitions) this.count++;
1505
- return `${this.count++}`;
1506
- }
1507
- };
1508
- function getLowerBound(current, value) {
1509
- if (typeof current !== "number" || !Number.isFinite(current) || value > current) return value;
1510
- return current;
1511
- }
1512
- __name(getLowerBound, "getLowerBound");
1513
- function getUpperBound(current, value) {
1514
- if (typeof current !== "number" || !Number.isFinite(current) || value < current) return value;
1515
- return current;
1516
- }
1517
- __name(getUpperBound, "getUpperBound");
1518
- // @__NO_SIDE_EFFECTS__
1519
- function getNotRestriction(current, value) {
1520
- return current !== void 0 ? { anyOf: [current, value] } : value;
1521
- }
1522
- __name(getNotRestriction, "getNotRestriction");
1523
- function intersectEnum(jsonSchema, values) {
1524
- let enumValues = jsonSchema.enum ?? values;
1525
- if (jsonSchema.enum) {
1526
- const valueSet = new Set(values);
1527
- enumValues = enumValues.filter((value) => valueSet.has(value));
1528
- }
1529
- if (enumValues.length) jsonSchema.enum = [...new Set(enumValues)];
1530
- else {
1531
- delete jsonSchema.enum;
1532
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, {});
1533
- }
1534
- }
1535
- __name(intersectEnum, "intersectEnum");
1536
- function convertAction(jsonSchema, valibotAction, config) {
1537
- if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
1538
- let errors;
1539
- switch (valibotAction.type) {
1540
- case "base64":
1541
- jsonSchema.contentEncoding = "base64";
1542
- break;
1543
- case "bic":
1544
- case "cuid2":
1545
- case "decimal":
1546
- case "digits":
1547
- case "domain":
1548
- case "emoji":
1549
- case "hash":
1550
- case "hexadecimal":
1551
- case "hex_color":
1552
- case "isrc":
1553
- case "iso_time_second":
1554
- case "iso_week":
1555
- case "ksuid":
1556
- case "mac":
1557
- case "mac48":
1558
- case "mac64":
1559
- case "nanoid":
1560
- case "octal":
1561
- case "slug":
1562
- case "ulid":
1563
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1564
- else jsonSchema.pattern = valibotAction.requirement.source;
1565
- break;
1566
- case "description":
1567
- jsonSchema.description = valibotAction.description;
1568
- break;
1569
- case "email":
1570
- case "rfc_email":
1571
- jsonSchema.format = "email";
1572
- break;
1573
- case "ends_with":
1574
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1575
- else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
1576
- break;
1577
- case "empty":
1578
- if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
1579
- else {
1580
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1581
- jsonSchema.maxLength = 0;
1582
- }
1583
- break;
1584
- case "entries":
1585
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1586
- errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
1587
- break;
1588
- }
1589
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
1590
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
1591
- break;
1592
- case "examples":
1593
- if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
1594
- else jsonSchema.examples = valibotAction.examples;
1595
- break;
1596
- case "gt_value":
1597
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1598
- errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
1599
- break;
1600
- }
1601
- if (!Number.isFinite(valibotAction.requirement)) {
1602
- errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
1603
- break;
1604
- }
1605
- if (config?.target === "openapi-3.0") {
1606
- errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
1607
- break;
1608
- }
1609
- jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
1610
- break;
1611
- case "includes":
1612
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1613
- else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
1614
- break;
1615
- case "integer":
1616
- jsonSchema.type = "integer";
1617
- break;
1618
- case "ipv4":
1619
- jsonSchema.format = "ipv4";
1620
- break;
1621
- case "ipv6":
1622
- jsonSchema.format = "ipv6";
1623
- break;
1624
- case "iso_date":
1625
- jsonSchema.format = "date";
1626
- break;
1627
- case "iso_date_time":
1628
- case "iso_timestamp":
1629
- jsonSchema.format = "date-time";
1630
- break;
1631
- case "iso_time":
1632
- jsonSchema.format = "time";
1633
- break;
1634
- case "jws_compact":
1635
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1636
- else jsonSchema.pattern = valibotAction.requirement.source;
1637
- break;
1638
- case "length":
1639
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1640
- errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
1641
- break;
1642
- }
1643
- if (jsonSchema.type === "array") {
1644
- jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
1645
- jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
1646
- } else {
1647
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1648
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
1649
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
1650
- }
1651
- break;
1652
- case "lt_value":
1653
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1654
- errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
1655
- break;
1656
- }
1657
- if (!Number.isFinite(valibotAction.requirement)) {
1658
- errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
1659
- break;
1660
- }
1661
- if (config?.target === "openapi-3.0") {
1662
- errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
1663
- break;
1664
- }
1665
- jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
1666
- break;
1667
- case "max_entries":
1668
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1669
- errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
1670
- break;
1671
- }
1672
- jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
1673
- break;
1674
- case "max_length":
1675
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1676
- errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
1677
- break;
1678
- }
1679
- if (jsonSchema.type === "array") jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
1680
- else {
1681
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1682
- jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
1683
- }
1684
- break;
1685
- case "max_value":
1686
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1687
- errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
1688
- break;
1689
- }
1690
- if (!Number.isFinite(valibotAction.requirement)) {
1691
- errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
1692
- break;
1693
- }
1694
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
1695
- break;
1696
- case "metadata":
1697
- if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
1698
- if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
1699
- if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
1700
- else jsonSchema.examples = valibotAction.metadata.examples;
1701
- for (const key of Object.keys(valibotAction.metadata)) if (key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__") jsonSchema[key] = valibotAction.metadata[key];
1702
- break;
1703
- case "min_entries":
1704
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1705
- errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
1706
- break;
1707
- }
1708
- jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
1709
- break;
1710
- case "min_length":
1711
- if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1712
- errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
1713
- break;
1714
- }
1715
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
1716
- else {
1717
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1718
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
1719
- }
1720
- break;
1721
- case "min_value":
1722
- if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1723
- errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
1724
- break;
1725
- }
1726
- if (!Number.isFinite(valibotAction.requirement)) {
1727
- errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
1728
- break;
1729
- }
1730
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
1731
- break;
1732
- case "multiple_of":
1733
- jsonSchema.multipleOf = valibotAction.requirement;
1734
- break;
1735
- case "non_empty":
1736
- if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1);
1737
- else {
1738
- if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1739
- jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1);
1740
- }
1741
- break;
1742
- case "not_value":
1743
- if (!isJsonConstValue(valibotAction.requirement)) {
1744
- errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
1745
- break;
1746
- }
1747
- jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
1748
- break;
1749
- case "not_values":
1750
- if (!isJsonEnumValues(valibotAction.requirement)) {
1751
- errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
1752
- break;
1753
- }
1754
- if (valibotAction.requirement.length) jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] });
1755
- break;
1756
- case "regex":
1757
- if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
1758
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1759
- else jsonSchema.pattern = valibotAction.requirement.source;
1760
- break;
1761
- case "safe_integer":
1762
- jsonSchema.type = "integer";
1763
- jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER);
1764
- jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
1765
- break;
1766
- case "starts_with":
1767
- if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1768
- else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
1769
- break;
1770
- case "title":
1771
- jsonSchema.title = valibotAction.title;
1772
- break;
1773
- case "url":
1774
- jsonSchema.format = "uri";
1775
- break;
1776
- case "uuid":
1777
- jsonSchema.format = "uuid";
1778
- break;
1779
- case "value":
1780
- if (!isJsonConstValue(valibotAction.requirement)) {
1781
- errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
1782
- break;
1783
- }
1784
- if (config?.target === "openapi-3.0") intersectEnum(jsonSchema, [valibotAction.requirement]);
1785
- else if ("const" in jsonSchema && jsonSchema.const !== valibotAction.requirement) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with a different "const" restriction.`);
1786
- else jsonSchema.const = valibotAction.requirement;
1787
- break;
1788
- case "values":
1789
- if (!isJsonEnumValues(valibotAction.requirement)) {
1790
- errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
1791
- break;
1792
- }
1793
- intersectEnum(jsonSchema, valibotAction.requirement);
1794
- break;
1795
- default:
1796
- errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
1797
- }
1798
- if (config?.overrideAction) {
1799
- const actionOverride = config.overrideAction({
1800
- valibotAction,
1801
- jsonSchema,
1802
- errors
1803
- });
1804
- if (actionOverride) return { ...actionOverride };
1805
- }
1806
- if (errors) for (const message of errors) handleError(message, config);
1807
- return jsonSchema;
1808
- }
1809
- __name(convertAction, "convertAction");
1810
- function flattenPipe(pipe2) {
1811
- return pipe2.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1812
- }
1813
- __name(flattenPipe, "flattenPipe");
1814
- function getDefinitionRef(referenceId) {
1815
- return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
1816
- }
1817
- __name(getDefinitionRef, "getDefinitionRef");
1818
- function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1819
- if (!skipRef) {
1820
- const referenceId = context.referenceMap.get(valibotSchema);
1821
- if (referenceId) {
1822
- jsonSchema.$ref = getDefinitionRef(referenceId);
1823
- if (config?.overrideRef) {
1824
- const refOverride = config.overrideRef({
1825
- ...context,
1826
- referenceId,
1827
- valibotSchema,
1828
- jsonSchema
1829
- });
1830
- if (refOverride) jsonSchema.$ref = refOverride;
1831
- }
1832
- return jsonSchema;
1833
- }
1834
- }
1835
- if ("pipe" in valibotSchema) {
1836
- const flatPipe = flattenPipe(valibotSchema.pipe);
1837
- let startIndex = 0;
1838
- let stopIndex = flatPipe.length - 1;
1839
- if (config?.typeMode === "input") {
1840
- const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "to_bigint" || item.type === "to_boolean" || item.type === "to_date" || item.type === "to_number" || item.type === "to_string" || item.type === "transform"));
1841
- if (inputStopIndex !== -1) stopIndex = inputStopIndex;
1842
- } else if (config?.typeMode === "output") {
1843
- const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
1844
- if (outputStartIndex !== -1) startIndex = outputStartIndex;
1845
- }
1846
- for (let index = startIndex; index <= stopIndex; index++) {
1847
- const valibotPipeItem = flatPipe[index];
1848
- if (valibotPipeItem.kind === "schema") {
1849
- if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
1850
- jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1851
- } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1852
- }
1853
- return jsonSchema;
1854
- }
1855
- let errors;
1856
- switch (valibotSchema.type) {
1857
- case "boolean":
1858
- jsonSchema.type = "boolean";
1859
- break;
1860
- case "null":
1861
- if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
1862
- else jsonSchema.type = "null";
1863
- break;
1864
- case "number":
1865
- jsonSchema.type = "number";
1866
- break;
1867
- case "string":
1868
- jsonSchema.type = "string";
1869
- break;
1870
- case "array":
1871
- jsonSchema.type = "array";
1872
- jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
1873
- break;
1874
- case "tuple":
1875
- case "tuple_with_rest":
1876
- case "loose_tuple":
1877
- case "strict_tuple":
1878
- jsonSchema.type = "array";
1879
- if (config?.target === "openapi-3.0") {
1880
- jsonSchema.items = { anyOf: [] };
1881
- jsonSchema.minItems = valibotSchema.items.length;
1882
- for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
1883
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
1884
- else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
1885
- } else if (config?.target === "draft-2020-12") {
1886
- jsonSchema.prefixItems = [];
1887
- jsonSchema.minItems = valibotSchema.items.length;
1888
- for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
1889
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
1890
- else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
1891
- } else {
1892
- jsonSchema.items = [];
1893
- jsonSchema.minItems = valibotSchema.items.length;
1894
- for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
1895
- if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
1896
- else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
1897
- }
1898
- break;
1899
- case "object":
1900
- case "object_with_rest":
1901
- case "loose_object":
1902
- case "strict_object":
1903
- jsonSchema.type = "object";
1904
- jsonSchema.properties = {};
1905
- jsonSchema.required = [];
1906
- for (const key in valibotSchema.entries) {
1907
- const entry = valibotSchema.entries[key];
1908
- jsonSchema.properties[key] = convertSchema({}, entry, config, context);
1909
- if (entry.type !== "exact_optional" && entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
1910
- }
1911
- if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
1912
- else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
1913
- break;
1914
- case "record":
1915
- if (config?.target === "openapi-3.0" && "pipe" in valibotSchema.key) errors = addError(errors, 'The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.');
1916
- if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
1917
- jsonSchema.type = "object";
1918
- if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
1919
- jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
1920
- break;
1921
- case "any":
1922
- case "unknown":
1923
- break;
1924
- case "never":
1925
- jsonSchema.not = {};
1926
- break;
1927
- case "nullable":
1928
- case "nullish":
1929
- if (config?.target === "openapi-3.0") {
1930
- const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
1931
- Object.assign(jsonSchema, innerSchema);
1932
- jsonSchema.nullable = true;
1933
- } else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
1934
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
1935
- break;
1936
- case "exact_optional":
1937
- case "optional":
1938
- case "undefinedable":
1939
- jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
1940
- if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
1941
- break;
1942
- case "literal":
1943
- if (!isJsonConstValue(valibotSchema.literal)) {
1944
- errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
1945
- break;
1946
- }
1947
- if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
1948
- else jsonSchema.const = valibotSchema.literal;
1949
- break;
1950
- case "enum":
1951
- case "picklist": {
1952
- const options = valibotSchema.options;
1953
- if (!options.every((option) => typeof option === "string" || typeof option === "number" && Number.isFinite(option))) {
1954
- errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
1955
- break;
1956
- }
1957
- jsonSchema.enum = options;
1958
- if (options.every((option) => typeof option === "string")) jsonSchema.type = "string";
1959
- else if (options.every((option) => typeof option === "number")) jsonSchema.type = "number";
1960
- else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
1961
- break;
1962
- }
1963
- case "union":
1964
- jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1965
- break;
1966
- case "variant":
1967
- jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1968
- break;
1969
- case "intersect":
1970
- jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1971
- break;
1972
- case "lazy": {
1973
- let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
1974
- if (!wrappedValibotSchema) {
1975
- wrappedValibotSchema = valibotSchema.getter(void 0);
1976
- context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
1977
- }
1978
- let referenceId = context.referenceMap.get(wrappedValibotSchema);
1979
- if (!referenceId) {
1980
- referenceId = context.referenceMap.createId(context.definitions);
1981
- context.referenceMap.set(wrappedValibotSchema, referenceId);
1982
- context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
1983
- }
1984
- jsonSchema.$ref = getDefinitionRef(referenceId);
1985
- if (config?.overrideRef) {
1986
- const refOverride = config.overrideRef({
1987
- ...context,
1988
- referenceId,
1989
- valibotSchema: wrappedValibotSchema,
1990
- jsonSchema
1991
- });
1992
- if (refOverride) jsonSchema.$ref = refOverride;
1993
- }
1994
- break;
1995
- }
1996
- default:
1997
- errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
1998
- }
1999
- if (config?.overrideSchema) {
2000
- const schemaOverride = config.overrideSchema({
2001
- ...context,
2002
- referenceId: context.referenceMap.get(valibotSchema),
2003
- valibotSchema,
2004
- jsonSchema,
2005
- errors
2006
- });
2007
- if (schemaOverride) return { ...schemaOverride };
2008
- }
2009
- if (errors) for (const message of errors) handleError(message, config);
2010
- return jsonSchema;
2011
- }
2012
- __name(convertSchema, "convertSchema");
2013
- var store;
2014
- function getGlobalDefs() {
2015
- return store;
2016
- }
2017
- __name(getGlobalDefs, "getGlobalDefs");
2018
- function toJsonSchema(schema, config) {
2019
- const context = {
2020
- definitions: {},
2021
- referenceMap: new ReferenceMap(),
2022
- getterMap: /* @__PURE__ */ new Map()
2023
- };
2024
- const definitions = config?.definitions ?? getGlobalDefs();
2025
- if (definitions) {
2026
- for (const key in definitions) context.referenceMap.set(definitions[key], key);
2027
- for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
2028
- }
2029
- const jsonSchema = convertSchema({}, schema, config, context);
2030
- const target = config?.target ?? "draft-07";
2031
- if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
2032
- else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
2033
- if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
2034
- return jsonSchema;
2035
- }
2036
- __name(toJsonSchema, "toJsonSchema");
2037
- var SUPPORTED_TARGETS = [
2038
- "draft-07",
2039
- "draft-2020-12",
2040
- "openapi-3.0"
2041
- ];
2042
- function toStandardJsonSchema(schema) {
2043
- return { "~standard": {
2044
- ...schema["~standard"],
2045
- jsonSchema: {
2046
- input(options) {
2047
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
2048
- typeMode: "input",
2049
- target: options.target,
2050
- ...options.libraryOptions
2051
- });
2052
- throw new Error(`Unsupported target: ${options.target}`);
2053
- },
2054
- output(options) {
2055
- if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
2056
- typeMode: "output",
2057
- target: options.target,
2058
- ...options.libraryOptions
2059
- });
2060
- throw new Error(`Unsupported target: ${options.target}`);
2061
- }
2062
- }
2063
- } };
2064
- }
2065
- __name(toStandardJsonSchema, "toStandardJsonSchema");
2066
-
2067
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
2068
- var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
2069
- var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
2070
- var text = pipe(string(), regex(/\S/, "must not be empty"));
2071
- var dottedId = pipe(string(), regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"));
2072
- var RegistryError = class extends Error {
2073
- static {
2074
- __name(this, "RegistryError");
2075
- }
2076
- registry;
2077
- problems;
2078
- constructor(registry, problems) {
2079
- super(`${registry} registry: ${problems.join("; ")}`);
2080
- this.registry = registry;
2081
- this.problems = problems;
2082
- this.name = "RegistryError";
2083
- }
2084
- };
2085
- var issuesOf = /* @__PURE__ */ __name((issues) => issues.map((issue) => {
2086
- const path = getDotPath(issue);
2087
- return path ? `${path}: ${issue.message}` : issue.message;
2088
- }), "issuesOf");
2089
- var parseRegistry = /* @__PURE__ */ __name((registry, schema, input, check2 = () => []) => {
2090
- const parsed = safeParse(schema, input);
2091
- if (!parsed.success)
2092
- throw new RegistryError(registry, issuesOf(parsed.issues));
2093
- const problems = check2(parsed.output);
2094
- if (problems.length > 0)
2095
- throw new RegistryError(registry, problems);
2096
- return parsed.output;
2097
- }, "parseRegistry");
2098
- var duplicates = /* @__PURE__ */ __name((values) => [...new Set(values.filter((value, index) => values.indexOf(value) !== index))].sort(), "duplicates");
2099
- var jsonSchemaOf = /* @__PURE__ */ __name((schema, definitions) => toJsonSchema(schema, { target: "draft-2020-12", ...definitions ? { definitions } : {} }), "jsonSchemaOf");
2100
- var PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g;
2101
- var placeholders = /* @__PURE__ */ __name((template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? ""), "placeholders");
2102
- var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHOLDER, (_, name) => {
2103
- const value = values[name];
2104
- if (value === void 0)
2105
- throw new Error(`no value for {${name}} in "${template}"`);
2106
- return String(value);
2107
- }), "fill");
2108
-
2109
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
2110
- var MAX_NEXT_STEPS = 2;
2111
- var COMPACT_FLAG = "--compact";
2112
- var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
2113
- var localTime = pipe(string(), regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2}$/, "an ISO 8601 time with its offset"));
2114
- var reference = pipe(string(), regex(/^[a-z]+:\S+$/, "a reference such as `note:42`"));
2115
- var nextStepSchema = variant("kind", [
2116
- strictObject({
2117
- kind: literal("command"),
2118
- step: dottedId,
2119
- /** The command path as one string, `messages list` — what the MCP router tools take as `command`. */
2120
- command: text,
2121
- args: record(string(), unknown()),
2122
- /**
2123
- * The whole line to type, with the tool and the profile it ran with: `tg personal mcp config`. Only the CLI
2124
- * knows the profile, so it fills this; MCP answers leave it out.
2125
- */
2126
- line: optional(text),
2127
- why: text,
2128
- /** True only when the target command is known to write nothing, here or at the provider. */
2129
- safe_to_auto_execute: boolean()
2130
- }),
2131
- /** Something only the person can do — sign in on the phone, approve a device. */
2132
- strictObject({
2133
- kind: literal("user_action"),
2134
- step: dottedId,
2135
- why: text,
2136
- safe_to_auto_execute: literal(false)
2137
- })
2138
- ]);
2139
- var missingSchema = strictObject({
2140
- field: text,
2141
- why: text,
2142
- /** Left out when there is nothing to run that would fill the field. */
2143
- step: optional(dottedId)
2144
- });
2145
- var limit = pipe(number(), integer(), minValue(1));
2146
- var totalSchema = strictObject({
2147
- value: pipe(number(), integer(), minValue(0)),
2148
- relation: picklist(["eq", "gte"])
2149
- });
2150
- var pageSchema = variant("mode", [
2151
- strictObject({
2152
- mode: literal("page"),
2153
- limit,
2154
- has_more: boolean(),
2155
- next_page: optional(pipe(number(), integer(), minValue(2))),
2156
- total: optional(totalSchema)
2157
- }),
2158
- strictObject({
2159
- mode: literal("cursor"),
2160
- limit,
2161
- has_more: boolean(),
2162
- next_cursor: optional(text),
2163
- total: optional(totalSchema)
2164
- })
2165
- ]);
2166
- var issueSchema = strictObject({
2167
- code: picklist(errorCodes),
2168
- reason: optional(dottedId),
2169
- /** The account, provider or source that is missing from the answer. */
2170
- source: text
2171
- });
2172
- var rankingSchema = strictObject({
2173
- applied: boolean(),
2174
- reason_id: optional(dottedId),
2175
- provider: text,
2176
- model: text,
2177
- endpoint: text,
2178
- sent: pipe(number(), integer(), minValue(0)),
2179
- cost_usd: nullable(pipe(number(), minValue(0))),
2180
- usage: optional(strictObject({
2181
- input: pipe(number(), integer(), minValue(0)),
2182
- output: pipe(number(), integer(), minValue(0))
2183
- })),
2184
- ms: pipe(number(), integer(), minValue(0))
2185
- });
2186
- var count = pipe(number(), integer(), minValue(0));
2187
- var modelRunSchema = strictObject({
2188
- provider: text,
2189
- model: text,
2190
- endpoint: text,
2191
- sent: count,
2192
- done: count,
2193
- left: count,
2194
- usage: optional(strictObject({ input: count, output: count })),
2195
- cost_usd: nullable(pipe(number(), minValue(0))),
2196
- ms: count
2197
- });
2198
- var querySchema = strictObject({
2199
- chat: optional(strictObject({ word: text, chat_id: text, title: nullable(text) })),
2200
- respelled: optional(array(strictObject({ word: text, tried: pipe(array(text), minLength(1)) })))
2201
- });
2202
- var metaSchema = strictObject({
2203
- run_id: text,
2204
- duration_ms: pipe(number(), integer(), minValue(0)),
2205
- accounts: optional(array(text)),
2206
- complete: boolean(),
2207
- issues: optional(array(issueSchema)),
2208
- truncated: optional(boolean()),
2209
- timezone: optional(text),
2210
- /** When the command answered, for an agent that plans from "now" (WC-TIME-7); `timezone` names the zone of `now_local`. */
2211
- now: optional(isoTime),
2212
- now_local: optional(localTime),
2213
- window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) })),
2214
- ranking: optional(rankingSchema),
2215
- model_run: optional(modelRunSchema),
2216
- query: optional(querySchema)
2217
- });
2218
- var offsetOf = /* @__PURE__ */ __name((at, zone) => {
2219
- const name = new Intl.DateTimeFormat("en-US", { timeZone: zone, timeZoneName: "longOffset" }).formatToParts(at).find((part) => part.type === "timeZoneName")?.value ?? "GMT";
2220
- return name === "GMT" ? "+00:00" : name.slice(3);
2221
- }, "offsetOf");
2222
- var clockMeta = /* @__PURE__ */ __name((at, zone) => {
2223
- const offset = offsetOf(at, zone);
2224
- const sign = offset.startsWith("-") ? -1 : 1;
2225
- const [hours = 0, minutes = 0] = offset.slice(1).split(":").map(Number);
2226
- const wall = new Date(at + sign * (hours * 60 + minutes) * 6e4).toISOString().slice(0, -1);
2227
- return { now: new Date(at).toISOString(), now_local: `${wall}${offset}`, timezone: zone };
2228
- }, "clockMeta");
2229
- var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
2230
- var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
2231
- items: array(item),
2232
- page: pageSchema,
2233
- next: nextSteps,
2234
- missing: optional(array(missingSchema)),
2235
- meta: metaSchema
2236
- }), "listEnvelopeSchema");
2237
- var itemEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
2238
- item,
2239
- next: nextSteps,
2240
- missing: optional(array(missingSchema)),
2241
- meta: metaSchema
2242
- }), "itemEnvelopeSchema");
2243
- var jsonlEndSchema = strictObject({
2244
- type: literal("end"),
2245
- complete: boolean(),
2246
- issues: optional(array(issueSchema)),
2247
- page: pageSchema
2248
- });
2249
- var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
2250
- ...items.map((data) => JSON.stringify({ type: "item", data })),
2251
- JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
2252
- ].join("\n"), "jsonlOf");
2253
-
2254
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/errors.js
2255
- var CRASH_CODE = "internal_error";
2256
- var CRASH_REASON = "command.crashed";
2257
- var errorObjectSchema = strictObject({
2258
- error: strictObject({
2259
- code: picklist([...errorCodes, CRASH_CODE]),
2260
- reason: dottedId,
2261
- message: text,
2262
- /** The option or argument at fault. */
2263
- param: optional(text),
2264
- details: optional(record(string(), unknown())),
2265
- next: optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS))),
2266
- /** Whether running the same command again may work and cannot do harm; never for a write that may have landed. */
2267
- retry: strictObject({
2268
- safe: boolean(),
2269
- after_ms: optional(pipe(number(), integer(), minValue(0)))
2270
- }),
2271
- /** Optional until every CLI keeps a run for each failure. */
2272
- run_id: optional(text)
2273
- })
2274
- });
2275
- var reasonSchema = strictObject({
2276
- reason: dottedId,
2277
- code: picklist([...errorCodes, CRASH_CODE]),
2278
- /** `{name}` placeholders, each one of `details`. */
2279
- message: pipe(text, maxLength(120)),
2280
- details: array(pipe(string(), regex(SNAKE_CASE, "a snake_case key"))),
2281
- step: optional(dottedId)
2282
- });
2283
- var defineReasons = /* @__PURE__ */ __name((input) => parseRegistry("error reasons", array(reasonSchema), input, (reasons) => [
2284
- ...duplicates(reasons.map((entry) => entry.reason)).map((reason) => `"${reason}" is listed twice`),
2285
- ...reasons.flatMap((entry) => placeholders(entry.message).filter((name) => !entry.details.includes(name)).map((name) => `${entry.reason}: the message names {${name}}, which is not one of its details`))
2286
- ]), "defineReasons");
2287
- var COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"];
2288
- var BASE_REASONS = defineReasons([
2289
- { reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
2290
- {
2291
- reason: "batch.read-budget",
2292
- code: "validation_error",
2293
- message: "batch stored-text read budget exhausted",
2294
- details: []
2295
- },
2296
- { reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
2297
- { reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
2298
- {
2299
- reason: "keyring.unreachable",
2300
- code: "configuration_error",
2301
- message: "the OS keyring did not answer, and no file holds the sign-in",
2302
- details: []
2303
- },
2304
- { reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
2305
- { reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
2306
- { reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
2307
- {
2308
- reason: "tool.not-installed",
2309
- code: "not_found",
2310
- message: "no wcat-<name> program by that name is on PATH",
2311
- details: ["tool", "installed"]
2312
- },
2313
- {
2314
- reason: "confirmation.required",
2315
- code: "confirmation_required",
2316
- message: "this changes something; confirm it",
2317
- details: []
2318
- },
2319
- { reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
2320
- { reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeout_ms"] },
2321
- { reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
2322
- { reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
2323
- { reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
2324
- {
2325
- reason: "provider.invalid-response",
2326
- code: "invalid_response",
2327
- message: "the answer could not be read",
2328
- details: []
2329
- },
2330
- {
2331
- reason: "output.too-large",
2332
- code: "invalid_response",
2333
- message: "the output is over {max_bytes} bytes",
2334
- details: ["max_bytes", "buffered_bytes", "partial_output"]
2335
- },
2336
- {
2337
- reason: "output.fields-unavailable",
2338
- code: "invalid_response",
2339
- message: "fields can be picked only from whole JSON values",
2340
- details: []
2341
- },
2342
- { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
2343
- {
2344
- reason: "write.conflict",
2345
- code: "conflict",
2346
- message: "it changed since it was read; read it again",
2347
- details: []
2348
- },
2349
- { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
2350
- { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
2351
- ]);
2352
-
2353
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/steps.js
2354
- var SAME_COMMAND = "*";
2355
- var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
2356
- var stepSchema = union([
2357
- strictObject({
2358
- id: dottedId,
2359
- kind: optional(literal("command"), "command"),
2360
- command: union([literal(SAME_COMMAND), commandPath]),
2361
- args: array(strictObject({
2362
- name: pipe(string(), regex(SNAKE_CASE, "an argument or option name in snake_case")),
2363
- required: boolean()
2364
- })),
2365
- why: pipe(text, maxLength(120))
2366
- }),
2367
- strictObject({ id: dottedId, kind: literal("user_action"), why: pipe(text, maxLength(120)) })
2368
- ]);
2369
- var argsOf = /* @__PURE__ */ __name((step) => step.kind === "command" ? step.args : [], "argsOf");
2370
- var defineSteps = /* @__PURE__ */ __name((input) => parseRegistry("steps", array(stepSchema), input, (steps) => [
2371
- ...duplicates(steps.map((step) => step.id)).map((id) => `"${id}" is listed twice`),
2372
- ...steps.flatMap((step) => duplicates(argsOf(step).map((arg) => arg.name)).map((name) => `${step.id}: argument "${name}" is listed twice`))
2373
- ]), "defineSteps");
2374
- var BINDS = /^[^\p{Cc}\u2028\u2029]*$/u;
2375
- var binds = /* @__PURE__ */ __name((value) => typeof value === "number" || typeof value === "boolean" || typeof value === "string" && BINDS.test(value), "binds");
2376
- var stepOf = /* @__PURE__ */ __name((definition, input = {}) => {
2377
- const args = input.args ?? {};
2378
- if (definition.kind === "user_action")
2379
- return {
2380
- kind: "user_action",
2381
- step: definition.id,
2382
- why: fill(definition.why, { ...input.values }),
2383
- safe_to_auto_execute: false
2384
- };
2385
- const command = definition.command === SAME_COMMAND ? input.command : definition.command;
2386
- if (!command)
2387
- throw new Error(`${definition.id}: the step runs the same command, so pass the command`);
2388
- const known = new Set(definition.args.map((arg) => arg.name));
2389
- if (definition.command !== SAME_COMMAND) {
2390
- for (const name of Object.keys(args))
2391
- if (!known.has(name))
2392
- throw new Error(`${definition.id}: no argument "${name}"`);
2393
- }
2394
- for (const arg of definition.args)
2395
- if (arg.required && args[arg.name] === void 0)
2396
- throw new Error(`${definition.id}: argument "${arg.name}" is required`);
2397
- for (const [name, value] of Object.entries(args))
2398
- if (!(Array.isArray(value) ? value.every(binds) : binds(value)))
2399
- throw new Error(`${definition.id}: "${name}" is not a value an option takes`);
2400
- const target = input.targets?.(command);
2401
- if (input.targets && !target)
2402
- throw new Error(`${definition.id}: no command "${command}"`);
2403
- const names = new Set(target?.names ?? []);
2404
- if (target) {
2405
- for (const name of Object.keys(args))
2406
- if (!names.has(name))
2407
- throw new Error(`${definition.id}: "${command}" takes no "${name}"`);
2408
- }
2409
- const scalars = Object.fromEntries(Object.entries(args).filter((entry) => ["string", "number"].includes(typeof entry[1])));
2410
- return {
2411
- kind: "command",
2412
- step: definition.id,
2413
- command,
2414
- args: { ...args },
2415
- why: fill(definition.why, { ...scalars, ...input.values }),
2416
- safe_to_auto_execute: target?.effects !== void 0 && !writes(target.effects)
2417
- };
2418
- }, "stepOf");
2419
- var STEPS = defineSteps([
2420
- {
2421
- id: "page.next",
2422
- command: SAME_COMMAND,
2423
- args: [
2424
- { name: "cursor", required: false },
2425
- { name: "page", required: false },
2426
- { name: "limit", required: false }
2427
- ],
2428
- why: "{shown} shown, more exist"
2429
- }
2430
- ]);
2431
-
2432
- // node_modules/.pnpm/@wirecat+cli-base@1.0.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/failure.js
2433
- var recognise = /* @__PURE__ */ __name((failure) => {
2434
- if (isCliError(failure))
2435
- return failure;
2436
- if (!(failure instanceof Error) || failure.name !== "CliError")
2437
- return void 0;
2438
- const { code, details } = failure;
2439
- if (!errorCodes.includes(code))
2440
- return void 0;
2441
- return {
2442
- code,
2443
- message: failure.message,
2444
- details: typeof details === "object" && details !== null ? details : {}
2445
- };
2446
- }, "recognise");
2447
- var reasonFor = /* @__PURE__ */ __name((code, named, reasons) => reasons.find((entry) => entry.reason === named && entry.code === code) ?? BASE_REASONS.find((entry) => entry.reason === named && entry.code === code) ?? // The first base reason for each code is its fallback.
2448
- BASE_REASONS.find((entry) => entry.code === code), "reasonFor");
2449
- var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
2450
- const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
2451
- if (!definition)
2452
- return [];
2453
- const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
2454
- const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
2455
- try {
2456
- return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
2457
- } catch {
2458
- return [];
2459
- }
2460
- }, "nextFor");
2461
- var TRANSIENT = [
2462
- "rate_limited",
2463
- "timeout",
2464
- "network_error",
2465
- "provider_unavailable"
2466
- ];
2467
- var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
2468
- const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
2469
- const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
2470
- const after = details.retry_after_ms;
2471
- return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
2472
- }, "retryOf");
2473
- var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
2474
- const reasons = context.reasons ?? [];
2475
- const recognised = recognise(failure);
2476
- if (!recognised) {
2477
- const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
2478
- return {
2479
- error: {
2480
- code: CRASH_CODE,
2481
- reason: reason2.reason,
2482
- message: reason2.message,
2483
- retry: { safe: false },
2484
- ...context.runId ? { run_id: context.runId } : {}
2485
- }
2486
- };
2487
- }
2488
- const { code, message, details } = recognised;
2489
- const reason = reasonFor(code, details.reason, reasons);
2490
- const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
2491
- allowed.delete("cause");
2492
- const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
2493
- const next = nextFor(reason, details, context);
2494
- const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
2495
- return {
2496
- error: {
2497
- code,
2498
- reason: reason.reason,
2499
- message,
2500
- ...typeof details.param === "string" ? { param: details.param } : {},
2501
- ...Object.keys(kept).length > 0 ? { details: kept } : {},
2502
- ...next.length > 0 ? { next } : {},
2503
- retry: retryOf(code, details, context.effects),
2504
- ...runId ? { run_id: runId } : {}
2505
- }
2506
- };
2507
- }, "errorObjectOf");
2508
- var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
2509
- var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
2510
- if (meta.complete || partial2)
2511
- return 0;
2512
- const code = meta.issues?.[0]?.code;
2513
- return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
2514
- }, "exitCodeOfAnswer");
2515
- var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
2516
- var commandLine = /* @__PURE__ */ __name((cli, step) => [
2517
- cli,
2518
- step.command,
2519
- ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
2520
- ].join(" "), "commandLine");
2521
- var STACK_FRAMES = 10;
2522
- var errorRecordOf = /* @__PURE__ */ __name((failure, object2, options) => {
2523
- const thrown = failure instanceof Error ? failure : void 0;
2524
- const { cause, ...details } = recognise(failure)?.details ?? {};
2525
- const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
2526
- const reason = thrown?.cause ?? cause;
2527
- return {
2528
- time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
2529
- severity: "error",
2530
- body: "command.failed",
2531
- ...object2.error.run_id ? { run_id: object2.error.run_id } : {},
2532
- command: options.command,
2533
- attributes: {
2534
- code: object2.error.code,
2535
- reason: object2.error.reason,
2536
- message: object2.error.message,
2537
- ...Object.keys(details).length > 0 ? { details } : {},
2538
- ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
2539
- ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
2540
- ...stack && stack.length > 0 ? { stack } : {}
2541
- },
2542
- resource: { service: options.service, version: options.version }
2543
- };
2544
- }, "errorRecordOf");
2545
- var renderError = /* @__PURE__ */ __name((object2, options) => {
2546
- if (!options.interactive)
2547
- return [JSON.stringify(object2), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
2548
- const { message, next, run_id: runId } = object2.error;
2549
- const step = next?.[0];
2550
- return [
2551
- `\u2717 ${visibleControls(message)}`,
2552
- ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
2553
- ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
2554
- ].join("\n");
2555
- }, "renderError");
2556
- var mcpErrorResult = /* @__PURE__ */ __name((object2) => ({
2557
- content: [{ type: "text", text: JSON.stringify(object2) }],
2558
- structuredContent: object2,
2559
- isError: true
2560
- }), "mcpErrorResult");
2561
- var catchCrashes = /* @__PURE__ */ __name((options) => {
2562
- const target = options.target ?? process;
2563
- const write = options.write ?? ((text2) => process.stderr.write(`${text2}
2564
- `));
2565
- const exit = options.exit ?? ((code) => process.exit(code));
2566
- const crashed = /* @__PURE__ */ __name((failure) => {
2567
- const object2 = errorObjectOf(failure, options);
2568
- write(renderError(object2, { cli: options.cli, interactive: options.interactive }));
2569
- exit(exitCodeOfError(object2));
2570
- }, "crashed");
2571
- target.on("uncaughtException", crashed);
2572
- target.on("unhandledRejection", crashed);
2573
- return () => {
2574
- target.off("uncaughtException", crashed);
2575
- target.off("unhandledRejection", crashed);
2576
- };
2577
- }, "catchCrashes");
2578
-
2579
- export {
2580
- EXIT_CODES,
2581
- exitCodeFor,
2582
- GENERIC_FAILURE,
2583
- getDotPath,
2584
- check,
2585
- description,
2586
- email,
2587
- finite,
2588
- integer,
2589
- isoDate,
2590
- isoTimestamp,
2591
- maxEntries,
2592
- maxLength,
2593
- maxValue,
2594
- minLength,
2595
- minValue,
2596
- nonEmpty,
2597
- regex,
2598
- safeInteger,
2599
- startsWith,
2600
- transform,
2601
- trim,
2602
- url,
2603
- forward,
2604
- array,
2605
- boolean,
2606
- exactOptional,
2607
- function_,
2608
- lazy,
2609
- literal,
2610
- looseObject,
2611
- null_,
2612
- nullable,
2613
- nullish,
2614
- number,
2615
- object,
2616
- objectWithRest,
2617
- optional,
2618
- picklist,
2619
- record,
2620
- strictObject,
2621
- string,
2622
- tuple,
2623
- union,
2624
- unknown,
2625
- variant,
2626
- omit,
2627
- parse,
2628
- partial,
2629
- pick,
2630
- pipe,
2631
- safeParse,
2632
- summarize,
2633
- unwrap,
2634
- effectsSchema,
2635
- writes,
2636
- toJsonSchema,
2637
- toStandardJsonSchema,
2638
- word,
2639
- SNAKE_CASE,
2640
- text,
2641
- dottedId,
2642
- RegistryError,
2643
- parseRegistry,
2644
- duplicates,
2645
- jsonSchemaOf,
2646
- MAX_NEXT_STEPS,
2647
- COMPACT_FLAG,
2648
- isoTime,
2649
- reference,
2650
- pageSchema,
2651
- clockMeta,
2652
- listEnvelopeSchema,
2653
- itemEnvelopeSchema,
2654
- jsonlOf,
2655
- CRASH_CODE,
2656
- errorObjectSchema,
2657
- defineReasons,
2658
- defineSteps,
2659
- stepOf,
2660
- STEPS,
2661
- retryOf,
2662
- errorObjectOf,
2663
- exitCodeOfError,
2664
- exitCodeOfAnswer,
2665
- errorRecordOf,
2666
- renderError,
2667
- mcpErrorResult,
2668
- catchCrashes
2669
- };