virello 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (603) hide show
  1. package/BREAKING_CHANGES.md +69 -0
  2. package/LICENSE +21 -0
  3. package/README.md +161 -2
  4. package/docs/console-logging.md +257 -0
  5. package/docs/engine.md +144 -0
  6. package/docs/sharding-recovery.md +163 -0
  7. package/docs/sharding-scaling.md +197 -0
  8. package/docs/sharding-stats.md +121 -0
  9. package/examples/README.md +288 -0
  10. package/examples/bot.ts +42 -0
  11. package/examples/client.ts +36 -0
  12. package/examples/commands/ping.ts +25 -0
  13. package/examples/commands/shard.ts +67 -0
  14. package/examples/commands/stats.ts +46 -0
  15. package/examples/config.ts +110 -0
  16. package/examples/contracts.ts +15 -0
  17. package/examples/coordinator.ts +50 -0
  18. package/examples/engine/MockDiscord.ts +159 -0
  19. package/examples/engine/live.ts +78 -0
  20. package/examples/engine/offline.ts +83 -0
  21. package/examples/host.ts +48 -0
  22. package/examples/listeners/ready.ts +20 -0
  23. package/examples/logging.ts +50 -0
  24. package/examples/offline.ts +93 -0
  25. package/examples/registration.ts +11 -0
  26. package/examples/shutdown.ts +50 -0
  27. package/examples/stats.ts +44 -0
  28. package/examples/unregisterCommands.ts +21 -0
  29. package/package.json +110 -5
  30. package/src/commands/Command.ts +424 -0
  31. package/src/commands/CommandStore.ts +71 -0
  32. package/src/commands/arguments/Args.ts +688 -0
  33. package/src/commands/arguments/Argument.ts +116 -0
  34. package/src/commands/arguments/ArgumentStore.ts +10 -0
  35. package/src/commands/arguments/builtins/Boolean.ts +27 -0
  36. package/src/commands/arguments/builtins/Channel.ts +24 -0
  37. package/src/commands/arguments/builtins/DMChannel.ts +24 -0
  38. package/src/commands/arguments/builtins/Date.ts +36 -0
  39. package/src/commands/arguments/builtins/Emoji.ts +23 -0
  40. package/src/commands/arguments/builtins/Enum.ts +27 -0
  41. package/src/commands/arguments/builtins/Float.ts +36 -0
  42. package/src/commands/arguments/builtins/Guild.ts +24 -0
  43. package/src/commands/arguments/builtins/GuildCategoryChannel.ts +36 -0
  44. package/src/commands/arguments/builtins/GuildChannel.ts +35 -0
  45. package/src/commands/arguments/builtins/GuildNewsChannel.ts +36 -0
  46. package/src/commands/arguments/builtins/GuildNewsThreadChannel.ts +36 -0
  47. package/src/commands/arguments/builtins/GuildPrivateThreadChannel.ts +36 -0
  48. package/src/commands/arguments/builtins/GuildPublicThreadChannel.ts +35 -0
  49. package/src/commands/arguments/builtins/GuildStageVoiceChannel.ts +36 -0
  50. package/src/commands/arguments/builtins/GuildTextChannel.ts +35 -0
  51. package/src/commands/arguments/builtins/GuildThreadChannel.ts +35 -0
  52. package/src/commands/arguments/builtins/GuildVoiceChannel.ts +35 -0
  53. package/src/commands/arguments/builtins/Hyperlink.ts +24 -0
  54. package/src/commands/arguments/builtins/Integer.ts +36 -0
  55. package/src/commands/arguments/builtins/Member.ts +41 -0
  56. package/src/commands/arguments/builtins/Message.ts +31 -0
  57. package/src/commands/arguments/builtins/Number.ts +36 -0
  58. package/src/commands/arguments/builtins/PartialDMChannel.ts +26 -0
  59. package/src/commands/arguments/builtins/Role.ts +35 -0
  60. package/src/commands/arguments/builtins/String.ts +34 -0
  61. package/src/commands/arguments/builtins/User.ts +24 -0
  62. package/src/commands/arguments/contexts.ts +32 -0
  63. package/src/commands/arguments/register.ts +166 -0
  64. package/src/commands/arguments/resolvers/boolean.ts +33 -0
  65. package/src/commands/arguments/resolvers/channel.ts +33 -0
  66. package/src/commands/arguments/resolvers/date.ts +41 -0
  67. package/src/commands/arguments/resolvers/dmChannel.ts +30 -0
  68. package/src/commands/arguments/resolvers/emoji.ts +51 -0
  69. package/src/commands/arguments/resolvers/enum.ts +38 -0
  70. package/src/commands/arguments/resolvers/float.ts +39 -0
  71. package/src/commands/arguments/resolvers/guild.ts +25 -0
  72. package/src/commands/arguments/resolvers/guildCategoryChannel.ts +27 -0
  73. package/src/commands/arguments/resolvers/guildChannel.ts +53 -0
  74. package/src/commands/arguments/resolvers/guildNewsChannel.ts +27 -0
  75. package/src/commands/arguments/resolvers/guildNewsThreadChannel.ts +28 -0
  76. package/src/commands/arguments/resolvers/guildPrivateThreadChannel.ts +28 -0
  77. package/src/commands/arguments/resolvers/guildPublicThreadChannel.ts +28 -0
  78. package/src/commands/arguments/resolvers/guildStageVoiceChannel.ts +27 -0
  79. package/src/commands/arguments/resolvers/guildTextChannel.ts +27 -0
  80. package/src/commands/arguments/resolvers/guildThreadChannel.ts +27 -0
  81. package/src/commands/arguments/resolvers/guildVoiceChannel.ts +27 -0
  82. package/src/commands/arguments/resolvers/hyperlink.ts +18 -0
  83. package/src/commands/arguments/resolvers/index.ts +27 -0
  84. package/src/commands/arguments/resolvers/integer.ts +39 -0
  85. package/src/commands/arguments/resolvers/internal/resolveGuildChannelPredicate.ts +24 -0
  86. package/src/commands/arguments/resolvers/member.ts +59 -0
  87. package/src/commands/arguments/resolvers/message.ts +179 -0
  88. package/src/commands/arguments/resolvers/number.ts +38 -0
  89. package/src/commands/arguments/resolvers/partialDMChannel.ts +30 -0
  90. package/src/commands/arguments/resolvers/role.ts +46 -0
  91. package/src/commands/arguments/resolvers/string.ts +37 -0
  92. package/src/commands/arguments/resolvers/user.ts +31 -0
  93. package/src/commands/checks/Precondition.ts +266 -0
  94. package/src/commands/checks/PreconditionStore.ts +153 -0
  95. package/src/commands/checks/builtins/ClientPermissions.ts +220 -0
  96. package/src/commands/checks/builtins/Cooldown.ts +173 -0
  97. package/src/commands/checks/builtins/DMOnly.ts +48 -0
  98. package/src/commands/checks/builtins/Enabled.ts +73 -0
  99. package/src/commands/checks/builtins/GuildNewsOnly.ts +65 -0
  100. package/src/commands/checks/builtins/GuildNewsThreadOnly.ts +59 -0
  101. package/src/commands/checks/builtins/GuildOnly.ts +48 -0
  102. package/src/commands/checks/builtins/GuildPrivateThreadOnly.ts +58 -0
  103. package/src/commands/checks/builtins/GuildPublicThreadOnly.ts +58 -0
  104. package/src/commands/checks/builtins/GuildTextOnly.ts +64 -0
  105. package/src/commands/checks/builtins/GuildThreadOnly.ts +50 -0
  106. package/src/commands/checks/builtins/GuildVoiceOnly.ts +51 -0
  107. package/src/commands/checks/builtins/NSFW.ts +64 -0
  108. package/src/commands/checks/builtins/RunIn.ts +111 -0
  109. package/src/commands/checks/builtins/UserPermissions.ts +109 -0
  110. package/src/commands/checks/containers/Container.ts +43 -0
  111. package/src/commands/checks/containers/Entry.ts +151 -0
  112. package/src/commands/checks/containers/Group.ts +236 -0
  113. package/src/commands/checks/containers/conditions/Condition.ts +66 -0
  114. package/src/commands/checks/containers/conditions/all.ts +71 -0
  115. package/src/commands/checks/containers/conditions/any.ts +102 -0
  116. package/src/commands/checks/containers/permissions/client.ts +24 -0
  117. package/src/commands/checks/containers/permissions/user.ts +24 -0
  118. package/src/commands/checks/core.ts +90 -0
  119. package/src/commands/checks/register.ts +94 -0
  120. package/src/commands/checks/resolvers/clientPermissions.ts +17 -0
  121. package/src/commands/checks/resolvers/cooldown.ts +37 -0
  122. package/src/commands/checks/resolvers/index.ts +5 -0
  123. package/src/commands/checks/resolvers/nsfw.ts +11 -0
  124. package/src/commands/checks/resolvers/runIn.ts +55 -0
  125. package/src/commands/checks/resolvers/userPermissions.ts +17 -0
  126. package/src/commands/enums.ts +93 -0
  127. package/src/commands/errors/ArgumentError.ts +44 -0
  128. package/src/commands/errors/Identifiers.ts +134 -0
  129. package/src/commands/errors/PreconditionError.ts +38 -0
  130. package/src/commands/errors/UserError.ts +39 -0
  131. package/src/commands/execution/autocomplete.ts +57 -0
  132. package/src/commands/execution/chatInput/accepted.ts +58 -0
  133. package/src/commands/execution/chatInput/beforeRun.ts +47 -0
  134. package/src/commands/execution/chatInput/resolve.ts +52 -0
  135. package/src/commands/execution/contextMenu/accepted.ts +58 -0
  136. package/src/commands/execution/contextMenu/beforeRun.ts +47 -0
  137. package/src/commands/execution/contextMenu/resolve.ts +52 -0
  138. package/src/commands/message/listeners/messageCommandAccepted.ts +55 -0
  139. package/src/commands/message/listeners/messageCommandTyping.ts +38 -0
  140. package/src/commands/message/listeners/messageCreate.ts +19 -0
  141. package/src/commands/message/listeners/preMessageCommandRun.ts +47 -0
  142. package/src/commands/message/listeners/preMessageParser.ts +117 -0
  143. package/src/commands/message/listeners/prefixedMessage.ts +78 -0
  144. package/src/commands/message/listeners/register.ts +41 -0
  145. package/src/commands/registration/Registry.ts +845 -0
  146. package/src/commands/registration/api.ts +33 -0
  147. package/src/commands/registration/computeDifferences/_shared.ts +84 -0
  148. package/src/commands/registration/computeDifferences/contexts.ts +57 -0
  149. package/src/commands/registration/computeDifferences/default_member_permissions.ts +14 -0
  150. package/src/commands/registration/computeDifferences/description.ts +19 -0
  151. package/src/commands/registration/computeDifferences/dm_permission.ts +14 -0
  152. package/src/commands/registration/computeDifferences/integration_types.ts +58 -0
  153. package/src/commands/registration/computeDifferences/localizations.ts +89 -0
  154. package/src/commands/registration/computeDifferences/name.ts +19 -0
  155. package/src/commands/registration/computeDifferences/option/autocomplete.ts +120 -0
  156. package/src/commands/registration/computeDifferences/option/channelTypes.ts +99 -0
  157. package/src/commands/registration/computeDifferences/option/minMaxLength.ts +76 -0
  158. package/src/commands/registration/computeDifferences/option/minMaxValue.ts +78 -0
  159. package/src/commands/registration/computeDifferences/option/required.ts +19 -0
  160. package/src/commands/registration/computeDifferences/option/type.ts +26 -0
  161. package/src/commands/registration/computeDifferences/options.ts +310 -0
  162. package/src/commands/registration/computeDifferences.ts +167 -0
  163. package/src/commands/registration/getNeededParameters.ts +62 -0
  164. package/src/commands/registration/listeners/bulkOverwrite.ts +28 -0
  165. package/src/commands/registration/listeners/initialising.ts +22 -0
  166. package/src/commands/registration/listeners/register.ts +23 -0
  167. package/src/commands/registration/listeners/registered.ts +27 -0
  168. package/src/commands/registration/normalizeInputs.ts +202 -0
  169. package/src/commands/registration/registries.ts +340 -0
  170. package/src/commands/registration/registriesErrors.ts +41 -0
  171. package/src/commands/registration/registriesLog.ts +41 -0
  172. package/src/commands/types.ts +256 -0
  173. package/src/core/Container.ts +41 -0
  174. package/src/core/client/RiloClient.ts +636 -0
  175. package/src/core/config/extensions.ts +87 -0
  176. package/src/core/config/options.ts +29 -0
  177. package/src/core/errors/MissingModuleError.ts +19 -0
  178. package/src/core/errors/ModuleCleanupError.ts +2 -0
  179. package/src/core/errors/ModuleLoadError.ts +32 -0
  180. package/src/core/index.ts +69 -0
  181. package/src/core/lifecycle/Extension.ts +25 -0
  182. package/src/core/loading/ModuleGlob.ts +159 -0
  183. package/src/core/loading/ModuleLoader.ts +116 -0
  184. package/src/core/loading/Shared.ts +2 -0
  185. package/src/core/loading/constants.ts +2 -0
  186. package/src/core/loading/contracts.ts +71 -0
  187. package/src/core/logging/LoggerLike.ts +27 -0
  188. package/src/core/logging/console.ts +325 -0
  189. package/src/core/logging/diagnostics.ts +60 -0
  190. package/src/core/logging/format.ts +406 -0
  191. package/src/core/logging/index.ts +15 -0
  192. package/src/core/logging/presentation.ts +343 -0
  193. package/src/core/logging/redact.ts +167 -0
  194. package/src/core/logging/text.ts +46 -0
  195. package/src/core/modules/AliasModule.ts +64 -0
  196. package/src/core/modules/AliasModuleStore.ts +48 -0
  197. package/src/core/modules/Module.ts +136 -0
  198. package/src/core/modules/ModuleLocation.ts +66 -0
  199. package/src/core/modules/ModuleRegistry.ts +372 -0
  200. package/src/core/modules/ModuleStore.ts +447 -0
  201. package/src/core/modules/index.ts +12 -0
  202. package/src/core/runtime.ts +2 -0
  203. package/src/engine/cache/CacheStore.ts +126 -0
  204. package/src/engine/cache/EngineCache.ts +374 -0
  205. package/src/engine/cache/ScopedCache.ts +126 -0
  206. package/src/engine/cache/activity.ts +78 -0
  207. package/src/engine/cache/merge.ts +26 -0
  208. package/src/engine/cache/types.ts +96 -0
  209. package/src/engine/client/EngineClient.ts +280 -0
  210. package/src/engine/client/EngineInteraction.ts +83 -0
  211. package/src/engine/client/EngineMessage.ts +34 -0
  212. package/src/engine/client/EventHub.ts +70 -0
  213. package/src/engine/client/types.ts +76 -0
  214. package/src/engine/common.ts +72 -0
  215. package/src/engine/gateway/GatewayShard.ts +392 -0
  216. package/src/engine/gateway/Heartbeat.ts +48 -0
  217. package/src/engine/gateway/IdentifyGate.ts +46 -0
  218. package/src/engine/gateway/protocol.ts +60 -0
  219. package/src/engine/gateway/types.ts +27 -0
  220. package/src/engine/rest/RateLimits.ts +164 -0
  221. package/src/engine/rest/RequestQueue.ts +100 -0
  222. package/src/engine/rest/RestClient.ts +402 -0
  223. package/src/engine/rest/RestError.ts +17 -0
  224. package/src/events/errors/autocomplete.ts +28 -0
  225. package/src/events/errors/chatInput.ts +28 -0
  226. package/src/events/errors/contextMenu.ts +28 -0
  227. package/src/events/errors/interaction.ts +28 -0
  228. package/src/events/errors/interactionParse.ts +31 -0
  229. package/src/events/errors/listener.ts +23 -0
  230. package/src/events/errors/message.ts +28 -0
  231. package/src/events/errors/register.ts +53 -0
  232. package/src/events/errors/registration.ts +24 -0
  233. package/src/events/events.ts +855 -0
  234. package/src/events/interactionCreate.ts +41 -0
  235. package/src/events/interactions/interactionHandler.ts +113 -0
  236. package/src/events/interactions/interactionHandlerStore.ts +158 -0
  237. package/src/events/listener.ts +120 -0
  238. package/src/events/listenerModuleLoader.ts +42 -0
  239. package/src/events/listenerStore.ts +14 -0
  240. package/src/events/ready.ts +27 -0
  241. package/src/events/register.ts +58 -0
  242. package/src/extensions/localisation/LocaleManager.ts +394 -0
  243. package/src/extensions/localisation/commands.ts +479 -0
  244. package/src/extensions/localisation/extension.ts +21 -0
  245. package/src/extensions/localisation/functions.ts +316 -0
  246. package/src/extensions/localisation/index.ts +4 -0
  247. package/src/extensions/localisation/resources.ts +143 -0
  248. package/src/extensions/localisation/types.ts +216 -0
  249. package/src/extensions/patternCommands/PatternCommand.ts +82 -0
  250. package/src/extensions/patternCommands/PatternCommandStore.ts +10 -0
  251. package/src/extensions/patternCommands/events.ts +19 -0
  252. package/src/extensions/patternCommands/extension.ts +14 -0
  253. package/src/extensions/patternCommands/index.ts +8 -0
  254. package/src/extensions/patternCommands/listeners/commandAccepted.ts +56 -0
  255. package/src/extensions/patternCommands/listeners/messageParse.ts +123 -0
  256. package/src/extensions/patternCommands/listeners/preCommandRun.ts +66 -0
  257. package/src/extensions/patternCommands/listeners/register.ts +23 -0
  258. package/src/extensions/patternCommands/types.ts +70 -0
  259. package/src/extensions/scheduledTasks/Task.ts +101 -0
  260. package/src/extensions/scheduledTasks/TaskScheduler.ts +523 -0
  261. package/src/extensions/scheduledTasks/TaskStore.ts +47 -0
  262. package/src/extensions/scheduledTasks/backends/MemoryBackend.ts +103 -0
  263. package/src/extensions/scheduledTasks/backends/RedisBackend.ts +163 -0
  264. package/src/extensions/scheduledTasks/backends/TaskBackend.ts +19 -0
  265. package/src/extensions/scheduledTasks/backends/scripts.ts +83 -0
  266. package/src/extensions/scheduledTasks/extension.ts +26 -0
  267. package/src/extensions/scheduledTasks/index.ts +6 -0
  268. package/src/extensions/scheduledTasks/listeners/error.ts +27 -0
  269. package/src/extensions/scheduledTasks/listeners/notFound.ts +24 -0
  270. package/src/extensions/scheduledTasks/listeners/register.ts +17 -0
  271. package/src/extensions/scheduledTasks/timing.ts +179 -0
  272. package/src/extensions/scheduledTasks/types/TaskEvents.ts +55 -0
  273. package/src/extensions/scheduledTasks/types/TaskTypes.ts +199 -0
  274. package/src/extensions/services/Service.ts +18 -0
  275. package/src/extensions/services/ServiceStore.ts +10 -0
  276. package/src/extensions/services/Services.ts +20 -0
  277. package/src/extensions/services/extension.ts +14 -0
  278. package/src/extensions/services/index.ts +14 -0
  279. package/src/extensions/subcommands/Subcommand.ts +715 -0
  280. package/src/extensions/subcommands/extension.ts +15 -0
  281. package/src/extensions/subcommands/index.ts +30 -0
  282. package/src/extensions/subcommands/listeners/chatInputError.ts +35 -0
  283. package/src/extensions/subcommands/listeners/chatInputNoMatch.ts +28 -0
  284. package/src/extensions/subcommands/listeners/messageError.ts +32 -0
  285. package/src/extensions/subcommands/listeners/messageNoMatch.ts +30 -0
  286. package/src/extensions/subcommands/listeners/missingChatInputHandler.ts +37 -0
  287. package/src/extensions/subcommands/listeners/missingMessageHandler.ts +37 -0
  288. package/src/extensions/subcommands/listeners/register.ts +42 -0
  289. package/src/extensions/subcommands/preconditionResolvers/subcommandCooldown.ts +83 -0
  290. package/src/extensions/subcommands/preconditions/SubcommandCooldown.ts +189 -0
  291. package/src/extensions/subcommands/preconditions/register.ts +12 -0
  292. package/src/extensions/subcommands/types/Enums.ts +11 -0
  293. package/src/extensions/subcommands/types/Events.ts +228 -0
  294. package/src/extensions/subcommands/types/mappings.ts +67 -0
  295. package/src/index.ts +19 -0
  296. package/src/public/client.ts +10 -0
  297. package/src/public/commands.ts +45 -0
  298. package/src/public/discord.ts +12 -0
  299. package/src/public/engine.ts +58 -0
  300. package/src/public/events.ts +12 -0
  301. package/src/public/extensions.ts +16 -0
  302. package/src/public/localisation.ts +7 -0
  303. package/src/public/modules.ts +32 -0
  304. package/src/public/scheduling.ts +11 -0
  305. package/src/public/services.ts +7 -0
  306. package/src/public/sharding.ts +7 -0
  307. package/src/public/time.ts +9 -0
  308. package/src/public/utilities.ts +22 -0
  309. package/src/public/validation.ts +14 -0
  310. package/src/sharding/LICENSE +191 -0
  311. package/src/sharding/client/Link.ts +735 -0
  312. package/src/sharding/client/gateway.ts +113 -0
  313. package/src/sharding/coordinator/Coordinator.ts +1696 -0
  314. package/src/sharding/coordinator/identify.ts +111 -0
  315. package/src/sharding/coordinator/scaling.ts +186 -0
  316. package/src/sharding/index.ts +4 -0
  317. package/src/sharding/manager/Manager.ts +1430 -0
  318. package/src/sharding/messaging.ts +185 -0
  319. package/src/sharding/stats.ts +91 -0
  320. package/src/sharding/transport/availability.ts +76 -0
  321. package/src/sharding/transport/pending.ts +79 -0
  322. package/src/sharding/transport/protocol.ts +317 -0
  323. package/src/sharding/transport/socket.ts +5 -0
  324. package/src/sharding/types.ts +292 -0
  325. package/src/utilities/array/arrayStrictEquals.ts +13 -0
  326. package/src/utilities/array/chunk.ts +11 -0
  327. package/src/utilities/array/filterNullAndUndefined.ts +11 -0
  328. package/src/utilities/array/filterNullAndUndefinedAndEmpty.ts +15 -0
  329. package/src/utilities/array/filterNullAndUndefinedAndZero.ts +15 -0
  330. package/src/utilities/array/partition.ts +26 -0
  331. package/src/utilities/array/pickRandom.ts +36 -0
  332. package/src/utilities/array/range.ts +6 -0
  333. package/src/utilities/async/events/index.ts +149 -0
  334. package/src/utilities/async/queue/AsyncQueue.ts +70 -0
  335. package/src/utilities/async/queue/_AsyncQueueEntry.ts +59 -0
  336. package/src/utilities/async/queue/index.ts +1 -0
  337. package/src/utilities/binary/buffer/DuplexBuffer.ts +209 -0
  338. package/src/utilities/binary/buffer/UnalignedUint16Array.ts +520 -0
  339. package/src/utilities/binary/index.ts +8 -0
  340. package/src/utilities/binary/schema/Schema.ts +376 -0
  341. package/src/utilities/binary/schema/SchemaStore.ts +157 -0
  342. package/src/utilities/binary/shared/Pointer.ts +57 -0
  343. package/src/utilities/binary/shared/_common.ts +24 -0
  344. package/src/utilities/binary/shared/codepoints.ts +21 -0
  345. package/src/utilities/binary/types/Array.ts +33 -0
  346. package/src/utilities/binary/types/BigInt32.ts +15 -0
  347. package/src/utilities/binary/types/BigInt64.ts +15 -0
  348. package/src/utilities/binary/types/BigUint32.ts +15 -0
  349. package/src/utilities/binary/types/BigUint64.ts +15 -0
  350. package/src/utilities/binary/types/Bit.ts +15 -0
  351. package/src/utilities/binary/types/Boolean.ts +15 -0
  352. package/src/utilities/binary/types/Constant.ts +18 -0
  353. package/src/utilities/binary/types/FixedLengthArray.ts +40 -0
  354. package/src/utilities/binary/types/Float32.ts +15 -0
  355. package/src/utilities/binary/types/Float64.ts +15 -0
  356. package/src/utilities/binary/types/Int16.ts +15 -0
  357. package/src/utilities/binary/types/Int2.ts +15 -0
  358. package/src/utilities/binary/types/Int32.ts +15 -0
  359. package/src/utilities/binary/types/Int4.ts +15 -0
  360. package/src/utilities/binary/types/Int64.ts +15 -0
  361. package/src/utilities/binary/types/Int8.ts +15 -0
  362. package/src/utilities/binary/types/Nullable.ts +25 -0
  363. package/src/utilities/binary/types/Snowflake.ts +15 -0
  364. package/src/utilities/binary/types/String.ts +29 -0
  365. package/src/utilities/binary/types/Uint16.ts +15 -0
  366. package/src/utilities/binary/types/Uint2.ts +15 -0
  367. package/src/utilities/binary/types/Uint32.ts +15 -0
  368. package/src/utilities/binary/types/Uint4.ts +15 -0
  369. package/src/utilities/binary/types/Uint64.ts +15 -0
  370. package/src/utilities/binary/types/Uint8.ts +15 -0
  371. package/src/utilities/binary/types/base/IType.ts +18 -0
  372. package/src/utilities/binary/types/index.ts +113 -0
  373. package/src/utilities/binary/utilities.ts +42 -0
  374. package/src/utilities/collections/bitfield/BitField.ts +232 -0
  375. package/src/utilities/collections/bitfield/index.ts +2 -0
  376. package/src/utilities/collections/bitfield/utilities.ts +12 -0
  377. package/src/utilities/decorators/base-decorators.ts +25 -0
  378. package/src/utilities/decorators/djs-decorators.ts +161 -0
  379. package/src/utilities/decorators/index.ts +4 -0
  380. package/src/utilities/decorators/module-decorators.ts +221 -0
  381. package/src/utilities/decorators/utils.ts +60 -0
  382. package/src/utilities/discord/builders/MessageBuilder.ts +119 -0
  383. package/src/utilities/discord/constants/TwemojiRegex.ts +8 -0
  384. package/src/utilities/discord/constants/index.ts +8 -0
  385. package/src/utilities/discord/constants/limits.ts +499 -0
  386. package/src/utilities/discord/constants/regexes.ts +59 -0
  387. package/src/utilities/discord/constants/resolvers/AutocompleteInteractionOptionResolver.ts +139 -0
  388. package/src/utilities/discord/constants/resolvers/ChatInputInteractionOptionResolver.ts +501 -0
  389. package/src/utilities/discord/constants/resolvers/ContextMenuInteractionOptionResolver.ts +96 -0
  390. package/src/utilities/discord/constants/resolvers/ModalInteractionOptionResolver.ts +135 -0
  391. package/src/utilities/discord/constants/resolvers/util.ts +72 -0
  392. package/src/utilities/discord/index.ts +7 -0
  393. package/src/utilities/discord/pagination/LazyPaginatedMessage.ts +121 -0
  394. package/src/utilities/discord/pagination/PaginatedFieldMessageEmbed.ts +118 -0
  395. package/src/utilities/discord/pagination/PaginatedMessage.ts +1345 -0
  396. package/src/utilities/discord/pagination/PaginatedMessageEmbedFields.ts +103 -0
  397. package/src/utilities/discord/pagination/PaginatedMessageTypes.ts +238 -0
  398. package/src/utilities/discord/pagination/Pagination.ts +536 -0
  399. package/src/utilities/discord/pagination/index.ts +7 -0
  400. package/src/utilities/discord/pagination/utils.ts +244 -0
  401. package/src/utilities/discord/prompts/ExplicitReturnTypes.ts +41 -0
  402. package/src/utilities/discord/prompts/MessagePrompter.ts +134 -0
  403. package/src/utilities/discord/prompts/constants.ts +17 -0
  404. package/src/utilities/discord/prompts/index.ts +12 -0
  405. package/src/utilities/discord/prompts/strategies/MessagePrompterBaseStrategy.ts +161 -0
  406. package/src/utilities/discord/prompts/strategies/MessagePrompterConfirmStrategy.ts +60 -0
  407. package/src/utilities/discord/prompts/strategies/MessagePrompterMessageStrategy.ts +82 -0
  408. package/src/utilities/discord/prompts/strategies/MessagePrompterNumberStrategy.ts +84 -0
  409. package/src/utilities/discord/prompts/strategies/MessagePrompterReactionStrategy.ts +50 -0
  410. package/src/utilities/discord/prompts/strategyOptions.ts +35 -0
  411. package/src/utilities/discord/snowflake/DiscordSnowflake.ts +4 -0
  412. package/src/utilities/discord/snowflake/Snowflake.ts +208 -0
  413. package/src/utilities/discord/snowflake/TwitterSnowflake.ts +4 -0
  414. package/src/utilities/discord/snowflake/index.ts +3 -0
  415. package/src/utilities/discord/type-guards.ts +262 -0
  416. package/src/utilities/discord/utilities.ts +127 -0
  417. package/src/utilities/discord/utility-types.ts +86 -0
  418. package/src/utilities/filesystem/findFilesRecursively.ts +78 -0
  419. package/src/utilities/filesystem/index.ts +1 -0
  420. package/src/utilities/function/cast.ts +4 -0
  421. package/src/utilities/function/debounce/LICENSE +47 -0
  422. package/src/utilities/function/debounce/debounce.ts +164 -0
  423. package/src/utilities/function/lazy.ts +6 -0
  424. package/src/utilities/function/noop.ts +2 -0
  425. package/src/utilities/function/poll.ts +82 -0
  426. package/src/utilities/function/pollSync.ts +81 -0
  427. package/src/utilities/function/retry.ts +27 -0
  428. package/src/utilities/function/retrySync.ts +22 -0
  429. package/src/utilities/function/sleep.ts +45 -0
  430. package/src/utilities/function/sleepSync.ts +6 -0
  431. package/src/utilities/function/throttle.ts +37 -0
  432. package/src/utilities/guards/classExtends.ts +15 -0
  433. package/src/utilities/guards/hasAtLeastOneKeyInMap.ts +7 -0
  434. package/src/utilities/guards/hasAtLeastOneKeyInObject.ts +9 -0
  435. package/src/utilities/guards/isClass.ts +6 -0
  436. package/src/utilities/guards/isFunction.ts +6 -0
  437. package/src/utilities/guards/isNullOrUndefined.ts +8 -0
  438. package/src/utilities/guards/isNullOrUndefinedOrEmpty.ts +11 -0
  439. package/src/utilities/guards/isNullOrUndefinedOrZero.ts +9 -0
  440. package/src/utilities/guards/isNumber.ts +7 -0
  441. package/src/utilities/guards/isObject.ts +36 -0
  442. package/src/utilities/guards/isPrimitive.ts +8 -0
  443. package/src/utilities/guards/isThenable.ts +31 -0
  444. package/src/utilities/http/HttpError.ts +28 -0
  445. package/src/utilities/http/index.ts +2 -0
  446. package/src/utilities/http/request.ts +135 -0
  447. package/src/utilities/index.ts +53 -0
  448. package/src/utilities/iterators/all.ts +1 -0
  449. package/src/utilities/iterators/any.ts +1 -0
  450. package/src/utilities/iterators/append.ts +12 -0
  451. package/src/utilities/iterators/at.ts +17 -0
  452. package/src/utilities/iterators/average.ts +23 -0
  453. package/src/utilities/iterators/chain.ts +11 -0
  454. package/src/utilities/iterators/chunk.ts +29 -0
  455. package/src/utilities/iterators/collect.ts +1 -0
  456. package/src/utilities/iterators/collectInto.ts +14 -0
  457. package/src/utilities/iterators/compact.ts +12 -0
  458. package/src/utilities/iterators/compare.ts +15 -0
  459. package/src/utilities/iterators/compareBy.ts +34 -0
  460. package/src/utilities/iterators/compress.ts +20 -0
  461. package/src/utilities/iterators/contains.ts +14 -0
  462. package/src/utilities/iterators/count.ts +14 -0
  463. package/src/utilities/iterators/cycle.ts +22 -0
  464. package/src/utilities/iterators/difference.ts +17 -0
  465. package/src/utilities/iterators/drop.ts +28 -0
  466. package/src/utilities/iterators/dropLast.ts +20 -0
  467. package/src/utilities/iterators/dropWhile.ts +40 -0
  468. package/src/utilities/iterators/empty.ts +11 -0
  469. package/src/utilities/iterators/enumerate.ts +12 -0
  470. package/src/utilities/iterators/equal.ts +12 -0
  471. package/src/utilities/iterators/equalBy.ts +26 -0
  472. package/src/utilities/iterators/every.ts +40 -0
  473. package/src/utilities/iterators/filter.ts +38 -0
  474. package/src/utilities/iterators/find.ts +30 -0
  475. package/src/utilities/iterators/findIndex.ts +22 -0
  476. package/src/utilities/iterators/first.ts +8 -0
  477. package/src/utilities/iterators/flat.ts +11 -0
  478. package/src/utilities/iterators/flatMap.ts +19 -0
  479. package/src/utilities/iterators/forEach.ts +16 -0
  480. package/src/utilities/iterators/from.ts +50 -0
  481. package/src/utilities/iterators/fuse.ts +23 -0
  482. package/src/utilities/iterators/greaterOrEqualThan.ts +14 -0
  483. package/src/utilities/iterators/greaterThan.ts +14 -0
  484. package/src/utilities/iterators/index.ts +91 -0
  485. package/src/utilities/iterators/indexOf.ts +19 -0
  486. package/src/utilities/iterators/inspect.ts +22 -0
  487. package/src/utilities/iterators/intersect.ts +12 -0
  488. package/src/utilities/iterators/intersperse.ts +34 -0
  489. package/src/utilities/iterators/isEmpty.ts +8 -0
  490. package/src/utilities/iterators/isSorted.ts +10 -0
  491. package/src/utilities/iterators/isSortedBy.ts +37 -0
  492. package/src/utilities/iterators/isSortedByKey.ts +41 -0
  493. package/src/utilities/iterators/last.ts +14 -0
  494. package/src/utilities/iterators/lessOrEqualThan.ts +14 -0
  495. package/src/utilities/iterators/lessThan.ts +14 -0
  496. package/src/utilities/iterators/map.ts +19 -0
  497. package/src/utilities/iterators/max.ts +13 -0
  498. package/src/utilities/iterators/maxBy.ts +34 -0
  499. package/src/utilities/iterators/maxByKey.ts +44 -0
  500. package/src/utilities/iterators/min.ts +10 -0
  501. package/src/utilities/iterators/minBy.ts +35 -0
  502. package/src/utilities/iterators/minByKey.ts +44 -0
  503. package/src/utilities/iterators/notEqual.ts +12 -0
  504. package/src/utilities/iterators/nth.ts +1 -0
  505. package/src/utilities/iterators/partition.ts +48 -0
  506. package/src/utilities/iterators/peekable.ts +32 -0
  507. package/src/utilities/iterators/position.ts +1 -0
  508. package/src/utilities/iterators/prepend.ts +14 -0
  509. package/src/utilities/iterators/product.ts +13 -0
  510. package/src/utilities/iterators/range.ts +44 -0
  511. package/src/utilities/iterators/reduce.ts +40 -0
  512. package/src/utilities/iterators/repeat.ts +21 -0
  513. package/src/utilities/iterators/reverse.ts +12 -0
  514. package/src/utilities/iterators/shared/_assertFunction.ts +9 -0
  515. package/src/utilities/iterators/shared/_assertNotNegative.ts +7 -0
  516. package/src/utilities/iterators/shared/_assertPositive.ts +7 -0
  517. package/src/utilities/iterators/shared/_compare.ts +47 -0
  518. package/src/utilities/iterators/shared/_makeIterableIterator.ts +10 -0
  519. package/src/utilities/iterators/shared/_toIntegerOrInfinityOrThrow.ts +10 -0
  520. package/src/utilities/iterators/shared/_toIntegerOrThrow.ts +12 -0
  521. package/src/utilities/iterators/shared/_toNumberOrThrow.ts +38 -0
  522. package/src/utilities/iterators/shared/comparators.ts +33 -0
  523. package/src/utilities/iterators/skip.ts +1 -0
  524. package/src/utilities/iterators/skipLast.ts +1 -0
  525. package/src/utilities/iterators/skipWhile.ts +1 -0
  526. package/src/utilities/iterators/slice.ts +70 -0
  527. package/src/utilities/iterators/some.ts +23 -0
  528. package/src/utilities/iterators/sorted.ts +10 -0
  529. package/src/utilities/iterators/starMap.ts +32 -0
  530. package/src/utilities/iterators/stepBy.ts +30 -0
  531. package/src/utilities/iterators/sum.ts +16 -0
  532. package/src/utilities/iterators/take.ts +25 -0
  533. package/src/utilities/iterators/takeLast.ts +30 -0
  534. package/src/utilities/iterators/takeWhile.ts +1 -0
  535. package/src/utilities/iterators/tee.ts +42 -0
  536. package/src/utilities/iterators/toArray.ts +9 -0
  537. package/src/utilities/iterators/toIterableIterator.ts +14 -0
  538. package/src/utilities/iterators/union.ts +20 -0
  539. package/src/utilities/iterators/unique.ts +10 -0
  540. package/src/utilities/iterators/unzip.ts +43 -0
  541. package/src/utilities/iterators/windows.ts +30 -0
  542. package/src/utilities/iterators/zip.ts +36 -0
  543. package/src/utilities/number/roundNumber.ts +11 -0
  544. package/src/utilities/object/deepClone.ts +86 -0
  545. package/src/utilities/object/getDeepObjectKeys.ts +92 -0
  546. package/src/utilities/object/makeObject.ts +32 -0
  547. package/src/utilities/object/mergeDefault.ts +37 -0
  548. package/src/utilities/object/mergeObjects.ts +33 -0
  549. package/src/utilities/object/objectEntries.ts +14 -0
  550. package/src/utilities/object/objectKeys.ts +12 -0
  551. package/src/utilities/object/objectToTuples.ts +19 -0
  552. package/src/utilities/object/objectValues.ts +12 -0
  553. package/src/utilities/object/omitKeysFromObject.ts +15 -0
  554. package/src/utilities/parsing/ArgumentStream.ts +440 -0
  555. package/src/utilities/parsing/index.ts +13 -0
  556. package/src/utilities/parsing/lexer/Lexer.ts +48 -0
  557. package/src/utilities/parsing/lexer/streams/ParameterStream.ts +37 -0
  558. package/src/utilities/parsing/lexer/streams/parameters/BaseParameter.ts +21 -0
  559. package/src/utilities/parsing/lexer/streams/parameters/QuotedParameter.ts +32 -0
  560. package/src/utilities/parsing/lexer/streams/parameters/WordParameter.ts +26 -0
  561. package/src/utilities/parsing/lexer/streams/raw/TokenStream.ts +110 -0
  562. package/src/utilities/parsing/parser/Parser.ts +37 -0
  563. package/src/utilities/parsing/parser/ParserResult.ts +60 -0
  564. package/src/utilities/parsing/parser/strategies/EmptyStrategy.ts +15 -0
  565. package/src/utilities/parsing/parser/strategies/IUnorderedStrategy.ts +10 -0
  566. package/src/utilities/parsing/parser/strategies/PrefixedStrategy.ts +71 -0
  567. package/src/utilities/parsing/strategies/FlagUnorderedStrategy.ts +76 -0
  568. package/src/utilities/parsing/util/util.ts +29 -0
  569. package/src/utilities/result/Option.ts +481 -0
  570. package/src/utilities/result/OptionError.ts +7 -0
  571. package/src/utilities/result/Result.ts +564 -0
  572. package/src/utilities/result/ResultError.ts +20 -0
  573. package/src/utilities/result/common/utils.ts +38 -0
  574. package/src/utilities/result/index.ts +4 -0
  575. package/src/utilities/text/capitalizeFirstLetter.ts +4 -0
  576. package/src/utilities/text/codeBlock.ts +15 -0
  577. package/src/utilities/text/cutText.ts +26 -0
  578. package/src/utilities/text/inlineCodeBlock.ts +13 -0
  579. package/src/utilities/text/regExpEsc.ts +6 -0
  580. package/src/utilities/text/snakeToCamelCase.ts +8 -0
  581. package/src/utilities/text/splitText.ts +13 -0
  582. package/src/utilities/text/toTitleCase.ts +48 -0
  583. package/src/utilities/text/tryParseJSON.ts +16 -0
  584. package/src/utilities/text/tryParseURL.ts +13 -0
  585. package/src/utilities/time/cron/Cron.ts +162 -0
  586. package/src/utilities/time/cron/constants.ts +88 -0
  587. package/src/utilities/time/cron/index.ts +2 -0
  588. package/src/utilities/time/duration/Duration.ts +157 -0
  589. package/src/utilities/time/duration/DurationFormatter.ts +113 -0
  590. package/src/utilities/time/duration/constants.ts +109 -0
  591. package/src/utilities/time/duration/index.ts +3 -0
  592. package/src/utilities/time/index.ts +29 -0
  593. package/src/utilities/time/ratelimits/RateLimit.ts +63 -0
  594. package/src/utilities/time/ratelimits/RateLimitManager.ts +85 -0
  595. package/src/utilities/time/ratelimits/index.ts +2 -0
  596. package/src/utilities/time/stopwatch/index.ts +68 -0
  597. package/src/utilities/time/timers/TimerManager.ts +53 -0
  598. package/src/utilities/time/timers/index.ts +1 -0
  599. package/src/utilities/time/timestamp/Timestamp.ts +264 -0
  600. package/src/utilities/time/timestamp/constants.ts +62 -0
  601. package/src/utilities/time/timestamp/index.ts +2 -0
  602. package/src/utilities/types.ts +191 -0
  603. package/src/version.ts +3 -0
@@ -0,0 +1,69 @@
1
+ # Breaking changes
2
+
3
+ ## Rilo rename
4
+
5
+ - Install `rilo` and update all imports and subpath imports from `kairojs` to
6
+ `rilo`. TypeScript declaration augmentation must target `rilo`.
7
+ - Rename `KairoClient` and `KairoClientOptions` to `RiloClient` and
8
+ `RiloClientOptions`. The previous names are no longer exported.
9
+ - Replace the `KAIRO_` prefix with `RILO_` in environment variables and GitHub
10
+ repository variables, including `RILO_RELEASES` and `RILO_TEST_REDIS_URL`.
11
+ - Upgrade coordinators, hosts and children together: transport headers and the
12
+ reserved stats request now use `x-rilo-*` and `rilo:stats`.
13
+ - Redis task keys now use `rilo:tasks:v1:`. Existing tasks in the previous
14
+ namespace are not read; drain or migrate them before switching. Branded
15
+ symbols and pagination component IDs also use the new name, so avoid mixing
16
+ framework versions in one application and recreate active pagination messages.
17
+
18
+ ## Stricter utility types
19
+
20
+ - Loose value types now use `unknown`; narrow formatter values, translation
21
+ dictionaries, and other untyped data before accessing their properties.
22
+ - `ok()` defaults its absent error type to `never`, `err()` defaults its absent
23
+ value type to `never`, and `none` carries `never`. Supply explicit Result
24
+ generics when a consumer needs a particular type for the absent branch.
25
+ - Constructor utility types accept arbitrary signatures as constraints. Supply
26
+ the parameter tuple when invoking a value typed as `Ctor`, `AbstractCtor`,
27
+ `Constructor`, or `AbstractConstructor`.
28
+ - `PaginatedFieldMessageEmbed.formatItems()` returns the same instance with the
29
+ transformed item type. Continue chaining from that return value.
30
+ - Empty interfaces that only renamed another type are now aliases. Extend the
31
+ alias or augment its underlying interface when adding application fields.
32
+ `Tasks`, `ShardRequests`, and `DetailedDescriptionCommandObject` remain
33
+ augmentable interfaces.
34
+
35
+ ## Shard maintenance and coordinator reconciliation
36
+
37
+ - Upgrade coordinator, hosts and children together. The internal protocol now
38
+ authenticates per-process leases and acknowledges assignment application.
39
+ - Coordinator loss retains children and Discord sessions in `client.maintenance`,
40
+ with a default fifteen-minute unreconciled outage cutoff. `reconnect: false`
41
+ retains its explicit stop-on-loss behavior.
42
+ - Fixed shard totals remain the default. `workers[].shards` are initial placement
43
+ preferences; leases decide ownership. Distinct authenticated supervisor
44
+ instances can connect together; duplicate sockets for one instance are refused.
45
+ - Disconnected leases remain reserved during the coordinator lifetime until the
46
+ owner confirms exit/release. A new supervisor does not prove old children died.
47
+ Restarting the coordinator rebuilds slots without a global grace period, which
48
+ can allow overlapping old and replacement Discord sessions until recovery or
49
+ the outage cutoff. There is no zero-duplicate-processing guarantee.
50
+ - Processes without capacity remain dormant, with no Discord session and
51
+ `client.sharding.id === null`. They poll every thirty seconds by default.
52
+ `login()` and transport-only `sharding.connect()` wait for the first assignment.
53
+ - Changed totals close the old gateway before reconnecting, even for the same ID.
54
+ Assignment changes reset guild/channel/user caches and gateway resume data,
55
+ preserving the client, modules and application listeners. Extension login hooks
56
+ run once; Discord ready events may repeat.
57
+ - `ShardProcessStatus.shard` is nullable. `slot` identifies the local process
58
+ position; `maintenance` and `dormant` are new states. Slots are not Discord IDs.
59
+ - Coordinator calls fail immediately by default. Use
60
+ `{ waitForCoordinator: true, timeoutMs }` for a bounded wait. Broadcasts share
61
+ one deadline across waiting and all targets. Dispatched calls are never replayed.
62
+ - Configure `assignmentPollIntervalMs`, `maxDisconnectedLifetimeMs`, and optionally
63
+ a minimum standby `processCount` on `ShardManager`. Existing crash/backoff and
64
+ opt-in automatic scaling policies remain. Reservations belonging to disconnected
65
+ instances block scaling until reconciled or released.
66
+
67
+ Disk-backed ownership remains removed. No state migration is needed. See
68
+ [shard recovery](docs/sharding-recovery.md) for the full contract and supervision
69
+ boundary.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lilsnibbi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,162 @@
1
- # Temporary Holding Version
1
+ # Rilo
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A modular Discord framework for Bun, written in TypeScript and built on discord.js. Organise your bot into commands, listeners and services, with explicit module loading and shared lifecycle management.
4
+
5
+ ## Features
6
+
7
+ - Slash commands, context menus, message commands and interaction handlers.
8
+ - Argument parsing, preconditions, permissions and cooldowns.
9
+ - Localisation for replies and application commands through i18next.
10
+ - Scheduled tasks with in-memory or Redis-backed storage.
11
+ - Shard coordination, host supervision, typed messaging and opt-in [automatic scaling](docs/sharding-scaling.md).
12
+ - [Shard maintenance and recovery](docs/sharding-recovery.md), with per-process leases and bounded coordinator outages.
13
+ - [Live shard statistics](docs/sharding-stats.md) through `container.sharding.stats()`, with fresh samples and explicit failures.
14
+ - Pagination, validation, collections, time helpers and other utilities.
15
+
16
+ ## Original engine milestone
17
+
18
+ The experimental [native Discord engine](docs/engine.md) is available through `rilo/engine`. It owns gateway sessions, REST and cache while the existing framework keeps its current runtime. Run `bun examples/engine/offline.ts` for a local connect/reply/resume demonstration with no Discord credentials.
19
+
20
+ ## Getting started
21
+
22
+ Use **Bun 1.4.3 or newer**. Rilo runs TypeScript directly; no compilation step is required.
23
+
24
+ From this repository, install dependencies:
25
+
26
+ ```sh
27
+ bun install --frozen-lockfile
28
+ ```
29
+
30
+ The [example bot](examples/README.md) includes a coordinator, shard host, three slash commands and an [env template](examples/.env.example).
31
+
32
+ Copy `examples/.env.example` to `examples/.env`, fill in your bot token and a generated host secret, then start these in separate terminals:
33
+
34
+ ```sh
35
+ bun --env-file=examples/.env examples/coordinator.ts
36
+ bun --env-file=examples/.env examples/host.ts
37
+ ```
38
+
39
+ The host starts two bot processes by default. Try `/ping`, `/stats` and `/shard`. The example guide covers server setup, secrets and running hosts on separate machines.
40
+
41
+ ### Create your own bot
42
+
43
+ In a separate Bun project, install your local Rilo checkout and discord.js. Replace the path with your checkout location:
44
+
45
+ ```sh
46
+ bun add /absolute/path/to/Rilo discord.js
47
+ ```
48
+
49
+ Use this layout:
50
+
51
+ ```text
52
+ my-bot/
53
+ ├── commands/
54
+ │ └── ping.ts
55
+ ├── .env
56
+ └── index.ts
57
+ ```
58
+
59
+ Create `index.ts`:
60
+
61
+ ```ts
62
+ import { GatewayIntentBits } from "discord.js";
63
+ import { RiloClient } from "rilo";
64
+
65
+ const token = Bun.env.DISCORD_TOKEN;
66
+ if (!token) throw new Error("Set DISCORD_TOKEN in your .env file.");
67
+
68
+ const client = new RiloClient({
69
+ intents: [GatewayIntentBits.Guilds],
70
+ root: import.meta.dir,
71
+ modules: { commands: "commands/**/*.ts" },
72
+ });
73
+
74
+ process.once("SIGINT", () => {
75
+ void client.destroy();
76
+ });
77
+
78
+ await client.login(token);
79
+ ```
80
+
81
+ Create `commands/ping.ts`:
82
+
83
+ ```ts
84
+ import { Command } from "rilo";
85
+
86
+ export default class PingCommand extends Command {
87
+ static override options: Command.Options = {
88
+ description: "Check whether the bot is awake.",
89
+ };
90
+
91
+ override registerApplicationCommands(registry: Command.Registry): void {
92
+ registry.registerChatInputCommand((builder) =>
93
+ builder.setName(this.name).setDescription(this.description),
94
+ );
95
+ }
96
+
97
+ override async chatInputRun(
98
+ interaction: Command.ChatInputCommandInteraction,
99
+ ): Promise<void> {
100
+ await interaction.reply("Pong!");
101
+ }
102
+ }
103
+ ```
104
+
105
+ Set `DISCORD_TOKEN` in your bot's `.env`, add `.env` to its `.gitignore`, then run:
106
+
107
+ ```sh
108
+ bun index.ts
109
+ ```
110
+
111
+ The filename supplies the command name. Module paths are explicit glob patterns relative to `root`; folders are not scanned automatically. Restart the process after changing code, module patterns or translations.
112
+
113
+ ## Imports
114
+
115
+ Import from the package root or a focused entrypoint:
116
+
117
+ ```ts
118
+ import { RiloClient } from "rilo/client";
119
+ import { Command, Precondition } from "rilo/commands";
120
+ import { Task } from "rilo/scheduling";
121
+ import { Result } from "rilo/utilities";
122
+ ```
123
+
124
+ Other entrypoints include `modules`, `events`, `extensions`, `localisation`, `services`, `sharding`, `discord`, `time` and `validation`. Root and category imports share the same classes and state. Keep TypeScript declaration augmentation on `rilo`.
125
+
126
+ ## Examples
127
+
128
+ | Example | Demonstrates |
129
+ | ------------------------------------ | ----------------------------------------------------------------------- |
130
+ | [Example guide](examples/README.md) | Setup, environment settings, shard roles and running across machines |
131
+ | [Bot](examples/bot.ts) | Shared entrypoint for each managed shard |
132
+ | [Commands](examples/commands/) | Local replies, broadcasts and single-shard requests |
133
+ | [Offline check](examples/offline.ts) | The same bot modules in two real child processes, without Discord login |
134
+
135
+ Try `bun examples/offline.ts` without a Discord token.
136
+
137
+ ## Development
138
+
139
+ Use **Bun canary**, the project's standard toolchain. Install it with `bun upgrade --canary`; CI follows the canary channel through `packageManager` in `package.json`.
140
+
141
+ | Command | Purpose |
142
+ | ----------------- | --------------------------------------- |
143
+ | `bun test` | Run Bun tests |
144
+ | `bun check` | Check TypeScript without emitting files |
145
+ | `bun lint` | Run Bun's built-in lint rules |
146
+ | `bun fmt --check` | Check formatting without writing files |
147
+ | `bun fmt` | Apply formatting |
148
+
149
+ Redis integration tests require `RILO_TEST_REDIS_URL` pointing to a disposable Redis instance; otherwise those tests are skipped locally.
150
+
151
+ Run `bun scripts/ci.ts` with that loopback Redis URL for complete validation: zero skipped tests, native Bun type checking, linting, formatting and both offline examples. On the Ubuntu x64 CI runner, `bash scripts/checkActions.sh` also checks the workflow with checksum-pinned actionlint.
152
+
153
+ See [migration notes](BREAKING_CHANGES.md) when moving from an earlier Rilo API.
154
+
155
+ See [console logging](docs/console-logging.md) for readable text/JSON output,
156
+ redaction, custom logger compatibility and the offline `bun scripts/logging-demo.ts` preview.
157
+
158
+ Source lives in `src/`, tests in `tests/` and runnable examples in `examples/`. See [Repository Guidelines](AGENTS.md) for contribution conventions.
159
+
160
+ ## Licence
161
+
162
+ The package declares `MIT AND Apache-2.0`. See the root [MIT licence](LICENSE), the [sharding Apache-2.0 licence](src/sharding/LICENSE), the shipped [source attribution](docs/source-retention.md) and retained notices alongside individual modules.
@@ -0,0 +1,257 @@
1
+ # Console logging
2
+
3
+ Rilo uses actual `@lilsnibbi/logger` instances. The library draws the
4
+ timestamps, source names, severity markers, bars, badges, boxes and error trees.
5
+ Rilo prepares safe message content and chooses native per-call display
6
+ options. It adds no console interception, logging service, dependency, buffer
7
+ or background timer.
8
+
9
+ At normal width, a gateway login reads as three distinct records:
10
+
11
+ ```text
12
+ [Thu 16:45:45.709] ▌ → coordinator › Login queued · host=local shard=0 queued=1
13
+ [Thu 16:45:45.710] ▌ → coordinator › Login permitted · host=local shard=0 2.57s remaining=991
14
+ [Thu 16:45:45.710] ▌ ✓ coordinator › Login confirmed · host=local shard=0
15
+ ```
16
+
17
+ Routine records no longer repeat a full date, component/event row, field grid,
18
+ trace heading and UUID block. Events are not buffered or merged: queueing,
19
+ granting and confirmation remain separate. Request dispatch and outcomes also
20
+ remain separate and keep their correlations in detailed text and JSON.
21
+
22
+ ## Native display selection
23
+
24
+ | Output | Automatic presentation |
25
+ | ------------------------------ | ----------------------------------------------------------------------------------------- |
26
+ | Routine terminal activity | Native `bar`; `→` progress, `✓` successful milestones, `↻` assignment/recovery, `·` debug |
27
+ | Warnings | Native `badge` with `ALERT` severity |
28
+ | Terminal errors | Native `box` containing the operation and the library's bounded error/cause tree |
29
+ | Pipes and ordinary Docker logs | Plain native `badge` output, without ANSI or decorative blank lines |
30
+ | Very narrow displays | Native `box` when a normal prefix would crowd out the message |
31
+ | JSON | One canonical object per line, without native text decoration |
32
+
33
+ The dependency's native severity names are `DEBUG`, `NOTIF` (info), `ALERT`
34
+ (warn) and `ERROR`. Human timestamps use the library's local-clock format;
35
+ JSON timestamps remain full ISO UTC timestamps. Human framework records use
36
+ concise native source names such as `coordinator`, `host`, `commands` and `jobs`.
37
+ The full application/component identity stays in detailed text and JSON.
38
+
39
+ Debug/info go to stdout; warnings/errors go to stderr. Native frames group one
40
+ failure and its causes together. Routine records have no blank separator.
41
+ Continuations wrap within the selected width. Escaped newlines in supplied
42
+ messages remain literal `\n` and cannot forge additional records.
43
+
44
+ ## Configuration
45
+
46
+ | Variable | Values | Default |
47
+ | ----------------- | --------------------------------------------------------------- | ----------------------------------------------- |
48
+ | `RILO_LOG_LEVEL` | `debug`, `info`, `warn`, `error`; `notif`/`alert` also accepted | `info` |
49
+ | `RILO_LOG_FORMAT` | `text`, `json` | `text` |
50
+ | `RILO_LOG_DETAIL` | `compact`, `full` | `compact`; `DEBUG` defaults to `full` |
51
+ | `RILO_LOG_LAYOUT` | `auto`, `badge`, `bar`, `box` | `auto` |
52
+ | `RILO_LOG_STACKS` | `off`, `short`, `full` | `short` |
53
+ | `RILO_LOG_WIDTH` | Integer columns, `32`–`200` | Terminal width capped at `120`; pipes use `100` |
54
+ | `NO_COLOR` | Any defined value disables color | Unset |
55
+ | `FORCE_COLOR` | `0` disables; a nonempty value enables when permitted | Unset |
56
+ | `TERM` | `dumb` disables color | Unset |
57
+
58
+ Invalid environment values fall back to defaults. Explicit `loggerOptions.level`,
59
+ `loggerOptions.layout` and `logging.format/detail/stacks/width` take precedence.
60
+ A native `box.width` is also supported. `COLUMNS` supplies a width when the stream
61
+ has no terminal column count. Destination width and color switches are checked
62
+ for framework events as they are emitted. `NO_COLOR`, `TERM=dumb`,
63
+ `FORCE_COLOR=0` and `colors: false` take precedence over enabling color. JSON is
64
+ always color free.
65
+
66
+ ```ts
67
+ import { RiloClient, createConsoleLogger, logEvent } from "rilo/client";
68
+
69
+ const client = new RiloClient({
70
+ intents: [],
71
+ loggerOptions: { layout: "bar", colors: "auto" },
72
+ logging: { detail: "compact", stacks: "short", width: 100 },
73
+ });
74
+
75
+ const logger = createConsoleLogger(
76
+ "MyBot",
77
+ {
78
+ level: "NOTIF",
79
+ layout: "bar",
80
+ symbols: { NOTIF: "✓", ALERT: "!" },
81
+ theme: { name: { color: "cyan" }, errorName: { color: "red", bold: true } },
82
+ },
83
+ { detail: "compact" },
84
+ );
85
+
86
+ logEvent(logger, "notif", {
87
+ component: "jobs",
88
+ event: "batch_finished",
89
+ message: "Queued notifications have been processed.",
90
+ context: { processed: 12, failed: 0 },
91
+ });
92
+ await client.destroy();
93
+ await logger.close();
94
+ ```
95
+
96
+ `logEvent(logger, level, entry)` accepts `debug`, `notif`, `alert` or `error`.
97
+ A `ConsoleLogEntry` contains `component`, `event`, `message`, optional `context`
98
+ and the original thrown `error`. Put the operation and next step in the message.
99
+ Unknown application events keep that message; known framework milestones have
100
+ short display wording in compact mode. Full mode restores the original wording.
101
+
102
+ ## Detailed records and collection
103
+
104
+ Set `RILO_LOG_DETAIL=full` to inspect the original event message, full component,
105
+ every retained safe context field and complete request/connection/generation
106
+ identifiers. `RILO_LOG_LEVEL=debug` additionally enables frame and module
107
+ metadata and defaults to full detail unless compact detail was explicitly chosen.
108
+ No wire bodies are included. Compact request/warning records may show an
109
+ eight-character `ref`; use the full ID from detailed text or JSON for tracing.
110
+
111
+ ```powershell
112
+ $env:RILO_LOG_LEVEL = 'debug'
113
+ $env:RILO_LOG_DETAIL = 'full'
114
+ $env:RILO_LOG_FORMAT = 'json'
115
+ bun --env-file=examples/.env examples/coordinator.ts
116
+ ```
117
+
118
+ JSON keeps the established schema: `timestamp`, `level`, `component`, `event`,
119
+ `message`, and optional `context`/`error`. Compact display choices never remove
120
+ fields from JSON. Native layouts, themes and text width do not decorate or wrap it.
121
+ A broadcast has one request per destination shard. Use `requestId` to pair
122
+ dispatch/outcome and `routeId` to follow a destination invocation; connection IDs
123
+ change after reconnects.
124
+
125
+ ## Native options, files and compatibility
126
+
127
+ `Logger`, `LoggerOptions` and `LogLevel` still come directly from the dependency.
128
+ `LogLayout`, `LogCallOptions`, `LogBoxOptions`, `LogFileOptions`, `LogTheme` and
129
+ `LogStyle` are also available from `rilo` / `rilo/client`.
130
+
131
+ Native `layout`, `box` corners, `symbols`, `theme`, `timeformat`,
132
+ `includeTimestamps`, `filter`, `transport` and file options work with built-in safe
133
+ records. Per-call overrides do not mutate the shared logger or caller settings.
134
+ Theme changes through `setTheme()` remain effective, including error/stack tokens.
135
+ The native `name`, `level`, `silent`, `child()`, raw rendering, `divider()`,
136
+ `time()`, `timeEnd()`, `flush()` and `close()` APIs remain available. The framework
137
+ does not add dividers to machine-readable output.
138
+
139
+ ```ts
140
+ const logger = createConsoleLogger(
141
+ "MyBot",
142
+ {
143
+ level: "NOTIF",
144
+ file: {
145
+ directory: "logs",
146
+ filename: "bot",
147
+ level: "DEBUG",
148
+ rotate: "daily",
149
+ maxSize: 5 * 1024 * 1024,
150
+ maxFiles: 7,
151
+ json: true,
152
+ },
153
+ },
154
+ { detail: "compact" },
155
+ );
156
+ ```
157
+
158
+ Text file sinks retain full safe detail even when console presentation is compact.
159
+ `file.level` can retain debug records filtered from the console. `file.json` keeps
160
+ the dependency's native envelope (`time`, `level`, `name`, `message`); parse its
161
+ `message` string as JSON for the canonical Rilo record. The native transport
162
+ receives a plain rendered line and a record whose `value` is the full sanitized
163
+ Rilo record. Filters still run before formatting. File ownership, rotation,
164
+ flushing and closing stay with the dependency.
165
+
166
+ An explicit `format` / `serialize` hook or native `inspectDepth` / `relativePaths`
167
+ serialization control selects the dependency's original formatting contract and
168
+ owns redaction/presentation. Passing `new Logger(...)`
169
+ directly also retains native behavior. The exported helpers are available on
170
+ `rilo/engine` without importing Discord.js or changing the engine runtime.
171
+
172
+ Supplying `logger` to a client, coordinator or host preserves that exact instance,
173
+ its settings, method binding and ownership; Rilo never configures or closes it.
174
+ Custom loggers still need only `debug`, `notif`, `alert` and `error`. They receive
175
+ one contextual string for notices or one contextual `Error` whose `cause` is the
176
+ original thrown value. User error callbacks, events and their arguments are
177
+ unchanged. A synchronous sink failure attempts one safe fallback record and
178
+ cannot interrupt startup, retries or cleanup.
179
+
180
+ ## Operational coverage
181
+
182
+ - Readiness and completed registration stay visible. Identical command
183
+ definitions, loading progress and per-module traces remain debug. Changed
184
+ commands and registration failures retain their existing policy and severity.
185
+ - Coordinator listening, connections, shard registration/offline changes, login
186
+ queue/grant/confirmation, request dispatch/outcomes and graceful host shutdown
187
+ keep their distinct events. Authentication, capacity, cancellation and timeout
188
+ failures retain their reasons and codes.
189
+ - `connection_waiting` describes cancellable waits for coordinator availability
190
+ or an active duplicate host. `identify_startup_wait` reports the startup login
191
+ cooldown; `host_drained` confirms that a host stopped its shards.
192
+ - Gateway/REST, extensions, loaders, jobs/storage, localisation and pagination
193
+ use the same built-in presentation. Routine job ticks and job data remain
194
+ omitted. Error records identify the failing operation and actionable remedy.
195
+ - Raw close reasons, tokens, headers, payloads, results and provider error
196
+ messages are not printed. Existing trace controls and custom callbacks remain
197
+ effective.
198
+
199
+ Logging does not change engine, permissions, rate limits, retries, registration,
200
+ sharding, scheduling or shutdown behavior. Child stdout/stderr remain inherited.
201
+ See [sharding restarts](sharding-recovery.md) for connection-scoped ownership,
202
+ in-memory identify scheduling and process-supervision limits.
203
+
204
+ ## Redaction and bounds
205
+
206
+ Recognized error type, code/status, actionable hints, causes and aggregate counts
207
+ remain available. Provider messages, arbitrary error properties, request/response
208
+ bodies, stack header text and function labels are omitted. The library's native
209
+ error formatter receives a sanitized bounded error tree, not the provider object.
210
+
211
+ `short` keeps up to three source locations outside dependencies; `full` keeps up
212
+ to ten including dependencies; `off` omits locations. Compact warning records
213
+ omit routine stack locations; error records retain them. Full detail includes
214
+ the locations selected by the stack setting. Causes are bounded to two levels;
215
+ aggregates retain counts and at most three children at each level.
216
+
217
+ Private metadata is recursively redacted. Numeric token counts remain useful.
218
+ Configured credential values and encoded variants are scrubbed; values shorter
219
+ than six characters are ignored to avoid erasing ordinary words. HTTP/WS URLs
220
+ retain only their origin; database URLs, webhook/interaction secrets, queries,
221
+ authorization values, email addresses and user content are removed. Controls and
222
+ terminal escapes are removed before native theme styling.
223
+
224
+ Messages and strings are capped at 320 characters. Context shares a 1,536-character
225
+ budget, 80 nodes, 24 fields per object, three levels and eight array entries.
226
+ Correlation fields are prioritized before unrelated metadata. JSON and built-in
227
+ human records stay within 8 KiB; extreme detail is marked as truncated. Native
228
+ wrapping counts Unicode display cells and preserves theme escape sequences.
229
+
230
+ ## Preview and verification
231
+
232
+ The demo uses the same built-in native logger as actual framework events:
233
+
234
+ ```sh
235
+ bun scripts/logging-demo.ts --width=100
236
+ bun scripts/logging-demo.ts --width=64 --layout=bar
237
+ bun scripts/logging-demo.ts --layout=box --color
238
+ bun scripts/logging-demo.ts --full
239
+ bun scripts/logging-demo.ts --json
240
+ ```
241
+
242
+ For comparison, the former human login output spent roughly eight or more lines
243
+ per stage on a message, date/component/event, counts and full UUIDs. The three
244
+ native compact records at the top retain the distinct stages in three lines at
245
+ 100 columns. Detailed text and JSON keep the original messages and correlations.
246
+ The demo is synthetic and never constructs a client or contacts Discord.
247
+
248
+ ```sh
249
+ bun test tests/core/logging.test.ts tests/core/loggingLayout.test.ts
250
+ bun test tests/sharding/activity.test.ts tests/sharding/consoleLayout.test.ts
251
+ ```
252
+
253
+ Tests cover native layouts/options/themes, compact versus detailed output,
254
+ file/transport semantics, redaction, error trees, Unicode/width/byte bounds,
255
+ colors, pipes and frozen custom loggers. Actual coordinator/host entrypoints
256
+ run against disposable loopback state at 64 and 100 columns; their gateway
257
+ metadata is supplied by a test-only preload. No live Discord failure is provoked.