virello 0.1.0 → 0.1.1
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.
- package/BREAKING_CHANGES.md +19 -0
- package/README.md +15 -15
- package/docs/console-logging.md +25 -25
- package/docs/engine.md +8 -8
- package/docs/sharding-recovery.md +3 -3
- package/docs/sharding-scaling.md +2 -2
- package/docs/sharding-stats.md +3 -3
- package/examples/README.md +12 -12
- package/examples/bot.ts +2 -2
- package/examples/client.ts +4 -4
- package/examples/commands/ping.ts +1 -1
- package/examples/commands/shard.ts +2 -2
- package/examples/commands/stats.ts +2 -2
- package/examples/config.ts +1 -1
- package/examples/contracts.ts +1 -1
- package/examples/coordinator.ts +1 -1
- package/examples/engine/live.ts +3 -3
- package/examples/engine/offline.ts +2 -2
- package/examples/host.ts +1 -1
- package/examples/listeners/ready.ts +2 -2
- package/examples/logging.ts +1 -1
- package/examples/offline.ts +2 -2
- package/examples/registration.ts +2 -2
- package/examples/shutdown.ts +1 -1
- package/examples/stats.ts +1 -1
- package/package.json +2 -2
- package/src/commands/checks/containers/Entry.ts +3 -3
- package/src/commands/registration/computeDifferences/option/channelTypes.ts +1 -1
- package/src/commands/registration/computeDifferences/option/type.ts +2 -2
- package/src/commands/registration/computeDifferences/options.ts +3 -3
- package/src/commands/types.ts +1 -1
- package/src/core/Container.ts +5 -5
- package/src/core/client/{RiloClient.ts → VirelloClient.ts} +24 -19
- package/src/core/config/extensions.ts +1 -1
- package/src/core/index.ts +1 -1
- package/src/core/lifecycle/Extension.ts +5 -5
- package/src/core/loading/constants.ts +1 -1
- package/src/core/logging/LoggerLike.ts +5 -5
- package/src/core/logging/console.ts +9 -9
- package/src/core/logging/format.ts +3 -3
- package/src/core/runtime.ts +1 -1
- package/src/engine/gateway/GatewayShard.ts +2 -2
- package/src/engine/rest/RestClient.ts +2 -1
- package/src/events/events.ts +74 -59
- package/src/extensions/localisation/extension.ts +2 -2
- package/src/extensions/patternCommands/extension.ts +2 -2
- package/src/extensions/scheduledTasks/backends/RedisBackend.ts +1 -1
- package/src/extensions/scheduledTasks/extension.ts +2 -2
- package/src/extensions/scheduledTasks/types/TaskTypes.ts +1 -1
- package/src/extensions/services/extension.ts +2 -2
- package/src/extensions/subcommands/extension.ts +2 -2
- package/src/index.ts +1 -1
- package/src/public/client.ts +2 -2
- package/src/sharding/client/Link.ts +5 -5
- package/src/sharding/client/gateway.ts +1 -1
- package/src/sharding/coordinator/Coordinator.ts +4 -4
- package/src/sharding/manager/Manager.ts +6 -6
- package/src/sharding/stats.ts +1 -1
- package/src/sharding/types.ts +3 -3
- package/src/utilities/collections/bitfield/BitField.ts +1 -1
- package/src/utilities/decorators/module-decorators.ts +1 -1
- package/src/utilities/discord/pagination/PaginatedMessage.ts +10 -10
- package/src/utilities/discord/pagination/Pagination.ts +1 -1
- package/src/utilities/discord/snowflake/Snowflake.ts +5 -5
- package/src/utilities/parsing/strategies/FlagUnorderedStrategy.ts +1 -1
- package/src/utilities/result/Option.ts +2 -2
- package/src/utilities/result/Result.ts +3 -3
package/BREAKING_CHANGES.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Breaking changes
|
|
2
2
|
|
|
3
|
+
## Virello rename
|
|
4
|
+
|
|
5
|
+
- The framework is now Virello, with package name `virello`. Replace `rilo`
|
|
6
|
+
imports and subpath imports with `virello`; TypeScript declaration augmentation
|
|
7
|
+
must target `virello`. Availability of the npm package name is unverified.
|
|
8
|
+
- Rename `RiloClient` and `RiloClientOptions` to `VirelloClient` and
|
|
9
|
+
`VirelloClientOptions`. The previous names are no longer exported.
|
|
10
|
+
- Replace the `RILO_` prefix with `VIRELLO_` in environment variables and GitHub
|
|
11
|
+
repository variables, including `VIRELLO_RELEASES` and
|
|
12
|
+
`VIRELLO_TEST_REDIS_URL`.
|
|
13
|
+
- Upgrade coordinators, hosts and children together: transport headers and the
|
|
14
|
+
reserved stats request now use `x-virello-*` and `virello:stats`.
|
|
15
|
+
- Redis task keys now use `virello:tasks:v1:`. Existing tasks under `rilo:tasks:v1:`
|
|
16
|
+
are not read; drain or migrate them before switching. Branded symbols and
|
|
17
|
+
pagination component IDs also use the new name, so avoid mixing framework
|
|
18
|
+
versions in one application and recreate active pagination messages.
|
|
19
|
+
- The Rilo migration below describes the earlier Kairo-to-Rilo rename. When
|
|
20
|
+
migrating directly from Kairo, apply both renames and use the Virello names.
|
|
21
|
+
|
|
3
22
|
## Rilo rename
|
|
4
23
|
|
|
5
24
|
- Install `rilo` and update all imports and subpath imports from `kairojs` to
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Virello
|
|
2
2
|
|
|
3
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
4
|
|
|
@@ -15,11 +15,11 @@ A modular Discord framework for Bun, written in TypeScript and built on discord.
|
|
|
15
15
|
|
|
16
16
|
## Original engine milestone
|
|
17
17
|
|
|
18
|
-
The experimental [native Discord engine](docs/engine.md) is available through `
|
|
18
|
+
The experimental [native Discord engine](docs/engine.md) is available through `virello/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
19
|
|
|
20
20
|
## Getting started
|
|
21
21
|
|
|
22
|
-
Use **Bun 1.4.3 or newer**.
|
|
22
|
+
Use **Bun 1.4.3 or newer**. Virello runs TypeScript directly; no compilation step is required.
|
|
23
23
|
|
|
24
24
|
From this repository, install dependencies:
|
|
25
25
|
|
|
@@ -40,10 +40,10 @@ The host starts two bot processes by default. Try `/ping`, `/stats` and `/shard`
|
|
|
40
40
|
|
|
41
41
|
### Create your own bot
|
|
42
42
|
|
|
43
|
-
In a separate Bun project, install your local
|
|
43
|
+
In a separate Bun project, install your local Virello checkout and discord.js. Replace the path with your checkout location:
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
|
-
bun add /absolute/path/to/
|
|
46
|
+
bun add /absolute/path/to/Virello discord.js
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
Use this layout:
|
|
@@ -60,12 +60,12 @@ Create `index.ts`:
|
|
|
60
60
|
|
|
61
61
|
```ts
|
|
62
62
|
import { GatewayIntentBits } from "discord.js";
|
|
63
|
-
import {
|
|
63
|
+
import { VirelloClient } from "virello";
|
|
64
64
|
|
|
65
65
|
const token = Bun.env.DISCORD_TOKEN;
|
|
66
66
|
if (!token) throw new Error("Set DISCORD_TOKEN in your .env file.");
|
|
67
67
|
|
|
68
|
-
const client = new
|
|
68
|
+
const client = new VirelloClient({
|
|
69
69
|
intents: [GatewayIntentBits.Guilds],
|
|
70
70
|
root: import.meta.dir,
|
|
71
71
|
modules: { commands: "commands/**/*.ts" },
|
|
@@ -81,7 +81,7 @@ await client.login(token);
|
|
|
81
81
|
Create `commands/ping.ts`:
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
|
-
import { Command } from "
|
|
84
|
+
import { Command } from "virello";
|
|
85
85
|
|
|
86
86
|
export default class PingCommand extends Command {
|
|
87
87
|
static override options: Command.Options = {
|
|
@@ -115,13 +115,13 @@ The filename supplies the command name. Module paths are explicit glob patterns
|
|
|
115
115
|
Import from the package root or a focused entrypoint:
|
|
116
116
|
|
|
117
117
|
```ts
|
|
118
|
-
import {
|
|
119
|
-
import { Command, Precondition } from "
|
|
120
|
-
import { Task } from "
|
|
121
|
-
import { Result } from "
|
|
118
|
+
import { VirelloClient } from "virello/client";
|
|
119
|
+
import { Command, Precondition } from "virello/commands";
|
|
120
|
+
import { Task } from "virello/scheduling";
|
|
121
|
+
import { Result } from "virello/utilities";
|
|
122
122
|
```
|
|
123
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 `
|
|
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 `virello`.
|
|
125
125
|
|
|
126
126
|
## Examples
|
|
127
127
|
|
|
@@ -146,11 +146,11 @@ Use **Bun canary**, the project's standard toolchain. Install it with `bun upgra
|
|
|
146
146
|
| `bun fmt --check` | Check formatting without writing files |
|
|
147
147
|
| `bun fmt` | Apply formatting |
|
|
148
148
|
|
|
149
|
-
Redis integration tests require `
|
|
149
|
+
Redis integration tests require `VIRELLO_TEST_REDIS_URL` pointing to a disposable Redis instance; otherwise those tests are skipped locally.
|
|
150
150
|
|
|
151
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
152
|
|
|
153
|
-
See [migration notes](BREAKING_CHANGES.md) when moving from an earlier
|
|
153
|
+
See [migration notes](BREAKING_CHANGES.md) when moving from an earlier Virello API.
|
|
154
154
|
|
|
155
155
|
See [console logging](docs/console-logging.md) for readable text/JSON output,
|
|
156
156
|
redaction, custom logger compatibility and the offline `bun scripts/logging-demo.ts` preview.
|
package/docs/console-logging.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Console logging
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Virello uses actual `@lilsnibbi/logger` instances. The library draws the
|
|
4
4
|
timestamps, source names, severity markers, bars, badges, boxes and error trees.
|
|
5
|
-
|
|
5
|
+
Virello prepares safe message content and chooses native per-call display
|
|
6
6
|
options. It adds no console interception, logging service, dependency, buffer
|
|
7
7
|
or background timer.
|
|
8
8
|
|
|
@@ -43,17 +43,17 @@ messages remain literal `\n` and cannot forge additional records.
|
|
|
43
43
|
|
|
44
44
|
## Configuration
|
|
45
45
|
|
|
46
|
-
| Variable
|
|
47
|
-
|
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `NO_COLOR`
|
|
55
|
-
| `FORCE_COLOR`
|
|
56
|
-
| `TERM`
|
|
46
|
+
| Variable | Values | Default |
|
|
47
|
+
| -------------------- | --------------------------------------------------------------- | ----------------------------------------------- |
|
|
48
|
+
| `VIRELLO_LOG_LEVEL` | `debug`, `info`, `warn`, `error`; `notif`/`alert` also accepted | `info` |
|
|
49
|
+
| `VIRELLO_LOG_FORMAT` | `text`, `json` | `text` |
|
|
50
|
+
| `VIRELLO_LOG_DETAIL` | `compact`, `full` | `compact`; `DEBUG` defaults to `full` |
|
|
51
|
+
| `VIRELLO_LOG_LAYOUT` | `auto`, `badge`, `bar`, `box` | `auto` |
|
|
52
|
+
| `VIRELLO_LOG_STACKS` | `off`, `short`, `full` | `short` |
|
|
53
|
+
| `VIRELLO_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
57
|
|
|
58
58
|
Invalid environment values fall back to defaults. Explicit `loggerOptions.level`,
|
|
59
59
|
`loggerOptions.layout` and `logging.format/detail/stacks/width` take precedence.
|
|
@@ -64,9 +64,9 @@ for framework events as they are emitted. `NO_COLOR`, `TERM=dumb`,
|
|
|
64
64
|
always color free.
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
|
-
import {
|
|
67
|
+
import { VirelloClient, createConsoleLogger, logEvent } from "virello/client";
|
|
68
68
|
|
|
69
|
-
const client = new
|
|
69
|
+
const client = new VirelloClient({
|
|
70
70
|
intents: [],
|
|
71
71
|
loggerOptions: { layout: "bar", colors: "auto" },
|
|
72
72
|
logging: { detail: "compact", stacks: "short", width: 100 },
|
|
@@ -101,17 +101,17 @@ short display wording in compact mode. Full mode restores the original wording.
|
|
|
101
101
|
|
|
102
102
|
## Detailed records and collection
|
|
103
103
|
|
|
104
|
-
Set `
|
|
104
|
+
Set `VIRELLO_LOG_DETAIL=full` to inspect the original event message, full component,
|
|
105
105
|
every retained safe context field and complete request/connection/generation
|
|
106
|
-
identifiers. `
|
|
106
|
+
identifiers. `VIRELLO_LOG_LEVEL=debug` additionally enables frame and module
|
|
107
107
|
metadata and defaults to full detail unless compact detail was explicitly chosen.
|
|
108
108
|
No wire bodies are included. Compact request/warning records may show an
|
|
109
109
|
eight-character `ref`; use the full ID from detailed text or JSON for tracing.
|
|
110
110
|
|
|
111
111
|
```powershell
|
|
112
|
-
$env:
|
|
113
|
-
$env:
|
|
114
|
-
$env:
|
|
112
|
+
$env:VIRELLO_LOG_LEVEL = 'debug'
|
|
113
|
+
$env:VIRELLO_LOG_DETAIL = 'full'
|
|
114
|
+
$env:VIRELLO_LOG_FORMAT = 'json'
|
|
115
115
|
bun --env-file=examples/.env examples/coordinator.ts
|
|
116
116
|
```
|
|
117
117
|
|
|
@@ -126,7 +126,7 @@ change after reconnects.
|
|
|
126
126
|
|
|
127
127
|
`Logger`, `LoggerOptions` and `LogLevel` still come directly from the dependency.
|
|
128
128
|
`LogLayout`, `LogCallOptions`, `LogBoxOptions`, `LogFileOptions`, `LogTheme` and
|
|
129
|
-
`LogStyle` are also available from `
|
|
129
|
+
`LogStyle` are also available from `virello` / `virello/client`.
|
|
130
130
|
|
|
131
131
|
Native `layout`, `box` corners, `symbols`, `theme`, `timeformat`,
|
|
132
132
|
`includeTimestamps`, `filter`, `transport` and file options work with built-in safe
|
|
@@ -158,19 +158,19 @@ const logger = createConsoleLogger(
|
|
|
158
158
|
Text file sinks retain full safe detail even when console presentation is compact.
|
|
159
159
|
`file.level` can retain debug records filtered from the console. `file.json` keeps
|
|
160
160
|
the dependency's native envelope (`time`, `level`, `name`, `message`); parse its
|
|
161
|
-
`message` string as JSON for the canonical
|
|
161
|
+
`message` string as JSON for the canonical Virello record. The native transport
|
|
162
162
|
receives a plain rendered line and a record whose `value` is the full sanitized
|
|
163
|
-
|
|
163
|
+
Virello record. Filters still run before formatting. File ownership, rotation,
|
|
164
164
|
flushing and closing stay with the dependency.
|
|
165
165
|
|
|
166
166
|
An explicit `format` / `serialize` hook or native `inspectDepth` / `relativePaths`
|
|
167
167
|
serialization control selects the dependency's original formatting contract and
|
|
168
168
|
owns redaction/presentation. Passing `new Logger(...)`
|
|
169
169
|
directly also retains native behavior. The exported helpers are available on
|
|
170
|
-
`
|
|
170
|
+
`virello/engine` without importing Discord.js or changing the engine runtime.
|
|
171
171
|
|
|
172
172
|
Supplying `logger` to a client, coordinator or host preserves that exact instance,
|
|
173
|
-
its settings, method binding and ownership;
|
|
173
|
+
its settings, method binding and ownership; Virello never configures or closes it.
|
|
174
174
|
Custom loggers still need only `debug`, `notif`, `alert` and `error`. They receive
|
|
175
175
|
one contextual string for notices or one contextual `Error` whose `cause` is the
|
|
176
176
|
original thrown value. User error callbacks, events and their arguments are
|
package/docs/engine.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Original Discord engine milestone
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
`virello/engine` is an experimental, independent Bun client implemented inside Virello. It owns its gateway session, REST transport and synchronous cache. The existing VirelloClient, module system, commands, extensions and root exports retain their current behavior. Importing the engine does not migrate framework features.
|
|
4
4
|
|
|
5
5
|
## Run it
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ The offline example creates a loopback HTTP/WebSocket server, receives a message
|
|
|
19
19
|
`bun examples/engine/live.ts` only logs instructions. To opt into Discord yourself, set `DISCORD_TOKEN` and add `--live`. The example requires Guilds, GuildMessages and MessageContent intents, plus permission to read and send in the channel. It replies to `!engine-ping`. Its interaction branch handles an already registered `engine-ping` command; it does not register commands. No live Discord validation was performed.
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import { createConsoleLogger, EngineClient, logEvent } from "
|
|
22
|
+
import { createConsoleLogger, EngineClient, logEvent } from "virello/engine";
|
|
23
23
|
import {
|
|
24
24
|
GatewayIntentBits,
|
|
25
25
|
InteractionResponseType,
|
|
@@ -103,7 +103,7 @@ Historical validation on 2026-10-11 used Bun 1.4.2 on Windows x64 and a disposab
|
|
|
103
103
|
|
|
104
104
|
- `bun install --frozen-lockfile --ignore-scripts`: succeeded without lock changes.
|
|
105
105
|
- `bun run engine:test`: 76 passing tests across four files, 279 assertions.
|
|
106
|
-
- `bun scripts/ci.ts` with `
|
|
106
|
+
- `bun scripts/ci.ts` with `VIRELLO_TEST_REDIS_URL`: 2,361 passing tests across 226 files, 4,943 assertions, zero failures and zero skipped tests.
|
|
107
107
|
- The same CI run passed type checking, the lint and formatting checks configured at the time, the existing offline framework example, the engine offline example and `bun run smoke`.
|
|
108
108
|
- The smoke test packed and installed the package in a temporary consumer, audited public exports/notices, loaded a framework command and ran the native engine connect/reply/resume example.
|
|
109
109
|
|
|
@@ -123,22 +123,22 @@ Reviewed on 2026-10-11:
|
|
|
123
123
|
|
|
124
124
|
`$MessageUpdateData` conservatively permits omitted native update fields with Partial plus required id/channel_id. Version 0.38.56 declares the create fields required for updates. This engine retains the agreed partial-update contract without renaming or reinterpreting fields.
|
|
125
125
|
|
|
126
|
-
The Ovencord checkout was read only. Package boundaries, WebSocketShard/identify strategies, REST SequentialHandler's bucket/major/global separation, and CachedManager's resident patching boundary informed the review. Its source, Collection abstraction, compatibility API and benchmark claims were not copied.
|
|
126
|
+
The Ovencord checkout was read only. Package boundaries, WebSocketShard/identify strategies, REST SequentialHandler's bucket/major/global separation, and CachedManager's resident patching boundary informed the review. Its source, Collection abstraction, compatibility API and benchmark claims were not copied. Virello uses its own Map/Set stores, scheduler, lifecycle and helpers.
|
|
127
127
|
|
|
128
128
|
## Production gaps
|
|
129
129
|
|
|
130
130
|
- A real bot session needs explicit approval. Extended reconnect soak tests and large real guild payloads remain untested; this milestone uses deterministic mocks and local servers.
|
|
131
|
-
- One shard per client is supported. The local identify budget cannot account for other processes or persist session starts across restarts. Supply waitForIdentify when sharing a token and integrate the existing
|
|
131
|
+
- One shard per client is supported. The local identify budget cannot account for other processes or persist session starts across restarts. Supply waitForIdentify when sharing a token and integrate the existing Virello coordinator.
|
|
132
132
|
- Add full payload validation and broader cache projections. Reaction counts, user updates across every guild, thread membership and ancillary guild collections still need reconciliation. This is not complete Discord cache coverage.
|
|
133
133
|
- Add compression, multipart uploads, additional typed endpoints, proactive global pacing, route-specific sublimits, retry telemetry and deadline-aware prioritization. Different routes can be coalesced only after headers reveal their shared bucket.
|
|
134
134
|
- Interaction callbacks share the bounded REST scheduler. Respond or defer promptly to meet Discord's initial-response deadline; automatic deferral, follow-up helpers and deadline reservation remain future work.
|
|
135
135
|
- Profile real traces before changing policy. Activity traversal, cache misses and JSON parsing need realistic workload evaluation.
|
|
136
136
|
|
|
137
|
-
## Future
|
|
137
|
+
## Future Virello integration
|
|
138
138
|
|
|
139
139
|
1. Introduce engine-facing command/listener contexts using native payloads and thin helpers, then test adapters for current framework contracts.
|
|
140
140
|
2. Replace discord.js-specific permission, resolver, collector, pagination and registration dependencies at explicit boundaries without building a compatibility clone.
|
|
141
141
|
3. Wire ShardLink.waitForIdentify, shard readiness and cleanup into EngineClient's injected permits and state hooks.
|
|
142
|
-
4. Port extensions and example bots with contract tests before changing
|
|
142
|
+
4. Port extensions and example bots with contract tests before changing VirelloClient's runtime and retiring discord.js dependencies.
|
|
143
143
|
|
|
144
|
-
The independent subpath is deliberate. The root API baseline stays intact, and a test verifies that this engine and the existing offline
|
|
144
|
+
The independent subpath is deliberate. The root API baseline stays intact, and a test verifies that this engine and the existing offline VirelloClient coexist without changing the framework container.
|
|
@@ -20,7 +20,7 @@ through coordinator outages. Unmanaged clients default to `maintenance = false`.
|
|
|
20
20
|
|
|
21
21
|
Only authenticated control, an accepted lease, local assignment application and
|
|
22
22
|
coordinator registration clear maintenance. Opening a socket or receiving a
|
|
23
|
-
welcome is insufficient.
|
|
23
|
+
welcome is insufficient. Virello does not install a command policy or send outage
|
|
24
24
|
replies: developers choose the response appropriate to each operation.
|
|
25
25
|
|
|
26
26
|
```ts
|
|
@@ -93,7 +93,7 @@ Discord shard IDs. Dormant clients remain in maintenance.
|
|
|
93
93
|
|
|
94
94
|
Recovery with the same ID and total preserves the Discord session. If the total
|
|
95
95
|
changed, the child closes its old gateway and reconnects with the accepted ID
|
|
96
|
-
and current total, even when the numerical ID is unchanged.
|
|
96
|
+
and current total, even when the numerical ID is unchanged. VirelloClient, modules
|
|
97
97
|
and application listeners stay alive. Assignment changes reset gateway resume
|
|
98
98
|
data and guild/channel/user caches. Extension login hooks run once per client;
|
|
99
99
|
Discord ready events may repeat. The gateway adapter targets discord.js 14.
|
|
@@ -154,7 +154,7 @@ fetching fresh `GET /gateway/bot` limits. This is an IDENTIFY cooldown, not a
|
|
|
154
154
|
reconciliation grace period. Permits are charged before sending and never refunded
|
|
155
155
|
on loss. An unexpired allowance cannot increase. `sessionStartLimit` is the
|
|
156
156
|
manual/offline alternative and needs a fresh snapshot on every start and expiry.
|
|
157
|
-
Restarting
|
|
157
|
+
Restarting Virello does not reset Discord's allowance.
|
|
158
158
|
|
|
159
159
|
Upgrade coordinator, hosts and children together: the internal protocol changed.
|
|
160
160
|
Restart running processes deliberately to load the new version. `statePath`,
|
package/docs/sharding-scaling.md
CHANGED
|
@@ -8,7 +8,7 @@ the same `ShardManager` and bot entrypoint.
|
|
|
8
8
|
## Coordinator configuration
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
|
-
import { ShardCoordinator } from "
|
|
11
|
+
import { ShardCoordinator } from "virello/sharding";
|
|
12
12
|
|
|
13
13
|
const coordinator = new ShardCoordinator({
|
|
14
14
|
shardCount: 2,
|
|
@@ -180,7 +180,7 @@ cooldown, readiness and allowance checks. Periodic checks continue automatically
|
|
|
180
180
|
|
|
181
181
|
Structured logs emit `scaling_status`, `scaling_failed` and host `reassigned`
|
|
182
182
|
events. Ordinary waiting/stable reasons are logged only when status changes.
|
|
183
|
-
Use `
|
|
183
|
+
Use `VIRELLO_LOG_FORMAT=json` for full context. Logs contain counts and host IDs,
|
|
184
184
|
not guild IDs, tokens or application payloads.
|
|
185
185
|
|
|
186
186
|
Upgrade coordinator, hosts and children together. The internal transport adds
|
package/docs/sharding-stats.md
CHANGED
|
@@ -22,8 +22,8 @@ const shardZero = one.get(0);
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
The return type is `Promise<ReadonlyMap<number, ShardStatsResult>>`. Import
|
|
25
|
-
`ShardStats`, `ShardStatsResult` and `ShardCallOptions` from `
|
|
26
|
-
`
|
|
25
|
+
`ShardStats`, `ShardStatsResult` and `ShardCallOptions` from `virello` or
|
|
26
|
+
`virello/sharding`. Entries follow the existing request result shape: `{ shard,
|
|
27
27
|
ok: true, value }` or `{ shard, ok: false, error }`. Errors are frozen `ShardError`
|
|
28
28
|
copies with a `code` and `message`; a failed entry has no `value` property.
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ Every call makes new requests through the coordinator, including a request to
|
|
|
33
33
|
the caller's own shard. The destination reads its client and process state only
|
|
34
34
|
when that request arrives. Stats never use the coordinator's periodic scaling
|
|
35
35
|
metrics, an earlier successful result, or a local shortcut as a fallback.
|
|
36
|
-
The private request name `
|
|
36
|
+
The private request name `virello:stats` is reserved and cannot be registered with
|
|
37
37
|
`handle()`.
|
|
38
38
|
|
|
39
39
|
Without an ID, the target set is `0..shardCount - 1` from the caller's reconciled
|
package/examples/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Run these commands from the **repository root**, using Bun 1.4.3 or newer.
|
|
|
56
56
|
bun --env-file=examples/.env examples/host.ts
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
The host starts `bot.ts` for each assigned shard. Don't run `bot.ts` directly or set `
|
|
59
|
+
The host starts `bot.ts` for each assigned shard. Don't run `bot.ts` directly or set `VIRELLO_SHARD` yourself. Wait for each shard's ready message, then try the commands in Discord. The coordinator may space out logins, so the shards won't always become ready together.
|
|
60
60
|
|
|
61
61
|
## Try the commands
|
|
62
62
|
|
|
@@ -106,7 +106,7 @@ Coordinator calls fail immediately while unavailable. Opt into bounded waiting
|
|
|
106
106
|
with `{ waitForCoordinator: true, timeoutMs: 5000 }`; the deadline includes the
|
|
107
107
|
wait and execution. Broadcasts share one deadline across all targets. Sent calls
|
|
108
108
|
are never replayed. `/shard` demonstrates an application-selected outage reply
|
|
109
|
-
using `client.maintenance`;
|
|
109
|
+
using `client.maintenance`; Virello does not automatically block your commands.
|
|
110
110
|
|
|
111
111
|
Restart the host after editing bot code. Stop the host first, then the coordinator, with Ctrl+C. A normal host shutdown stops its children and releases its assignment. Child crashes are retried with backoff; repeated crashes eventually stop that shard, so check the logs.
|
|
112
112
|
|
|
@@ -127,8 +127,8 @@ bounded error trees. Pipes use plain badges. Routine events show concise source
|
|
|
127
127
|
names and useful counts without repeated date rows, field grids or UUID blocks.
|
|
128
128
|
Queueing, permitting and confirming a login remain three distinct records.
|
|
129
129
|
Output wraps to the terminal, capped at 120 columns; pipes default to 100.
|
|
130
|
-
Set `
|
|
131
|
-
`
|
|
130
|
+
Set `VIRELLO_LOG_WIDTH=64` or `logging.width` for a fixed width, and
|
|
131
|
+
`VIRELLO_LOG_LAYOUT=badge|bar|box` to select a native layout explicitly.
|
|
132
132
|
|
|
133
133
|
Each live bot emits one info readiness message after the registration pass,
|
|
134
134
|
with its shard, command and guild counts. The ready listener adds a debug cache
|
|
@@ -146,13 +146,13 @@ set it. Startup failures release any constructed resources. Ctrl+C/SIGTERM
|
|
|
146
146
|
reports shutdown requested, then completion or a cleanup failure; a failed
|
|
147
147
|
startup or cleanup sets a nonzero exit status.
|
|
148
148
|
|
|
149
|
-
Use `
|
|
150
|
-
`
|
|
151
|
-
`
|
|
152
|
-
text choices; `
|
|
149
|
+
Use `VIRELLO_LOG_DETAIL=full` for original messages and full correlation fields.
|
|
150
|
+
`VIRELLO_LOG_LEVEL=debug` adds frame/heartbeat metadata and defaults to full detail.
|
|
151
|
+
`VIRELLO_LOG_FORMAT=json` keeps the full structured schema, independent of compact
|
|
152
|
+
text choices; `VIRELLO_LOG_STACKS=off` omits locations. See
|
|
153
153
|
[console logging](../docs/console-logging.md) for native themes, symbols, files,
|
|
154
154
|
per-call options and the local demo. To supply your own logger, pass it to
|
|
155
|
-
`createBot(logger)` in `client.ts`;
|
|
155
|
+
`createBot(logger)` in `client.ts`; Virello keeps that exact instance.
|
|
156
156
|
|
|
157
157
|
The coordinator and hosts keep sharding coordination in memory. During a
|
|
158
158
|
coordinator restart, existing children keep Discord open in maintenance while
|
|
@@ -178,8 +178,8 @@ and obsolete configuration. Existing state files can stay unused.
|
|
|
178
178
|
For detailed coordinator diagnostics in PowerShell:
|
|
179
179
|
|
|
180
180
|
```powershell
|
|
181
|
-
$env:
|
|
182
|
-
$env:
|
|
181
|
+
$env:VIRELLO_LOG_LEVEL = 'debug'
|
|
182
|
+
$env:VIRELLO_LOG_FORMAT = 'json'
|
|
183
183
|
bun --env-file=examples/.env examples/coordinator.ts
|
|
184
184
|
```
|
|
185
185
|
|
|
@@ -208,7 +208,7 @@ other. An existing process keeps its loaded code; the old plain
|
|
|
208
208
|
| `SHARD_HOST_MAX_SHARDS` | Local host capacity, required for automatic scaling without `SHARD_WORKERS` |
|
|
209
209
|
| `SHARD_TLS_CERT`, `SHARD_TLS_KEY` | PEM certificate and private key paths for the coordinator's TLS listener |
|
|
210
210
|
|
|
211
|
-
The env file is ignored by Git. Legacy `sharding.sqlite*` files and `.
|
|
211
|
+
The env file is ignored by Git. Legacy `sharding.sqlite*` files and `.virello-sharding/` directories remain ignored and are no longer used.
|
|
212
212
|
|
|
213
213
|
## More than one machine
|
|
214
214
|
|
package/examples/bot.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logEvent } from "
|
|
1
|
+
import { logEvent } from "virello/client";
|
|
2
2
|
import { createBot } from "./client";
|
|
3
3
|
import { ExampleConfigurationError, requiredEnv } from "./config";
|
|
4
4
|
import { cleanupFailedStartup, exampleLogger, startupFailed } from "./logging";
|
|
@@ -15,7 +15,7 @@ async function main(): Promise<void> {
|
|
|
15
15
|
try {
|
|
16
16
|
if (!client.sharding.enabled)
|
|
17
17
|
throw new ExampleConfigurationError(
|
|
18
|
-
"
|
|
18
|
+
"VIRELLO_SHARD",
|
|
19
19
|
"Start examples/host.ts; the host launches one bot process per assigned shard.",
|
|
20
20
|
);
|
|
21
21
|
if (offline) {
|
package/examples/client.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "./contracts";
|
|
2
2
|
import { GatewayIntentBits } from "discord.js";
|
|
3
|
-
import {
|
|
4
|
-
import { ApplicationCommandRegistries } from "
|
|
3
|
+
import { VirelloClient, type LoggerLike } from "virello/client";
|
|
4
|
+
import { ApplicationCommandRegistries } from "virello/commands";
|
|
5
5
|
import { developmentGuild } from "./config";
|
|
6
6
|
import { exampleLogger } from "./logging";
|
|
7
7
|
|
|
8
|
-
export function createBot(logger: LoggerLike = exampleLogger):
|
|
8
|
+
export function createBot(logger: LoggerLike = exampleLogger): VirelloClient {
|
|
9
9
|
const guildId = developmentGuild();
|
|
10
10
|
ApplicationCommandRegistries.setDefaultGuildIds(
|
|
11
11
|
guildId ? [guildId] : undefined,
|
|
12
12
|
);
|
|
13
|
-
const client = new
|
|
13
|
+
const client = new VirelloClient({
|
|
14
14
|
intents: [GatewayIntentBits.Guilds],
|
|
15
15
|
logger,
|
|
16
16
|
root: import.meta.dir,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageFlags } from "discord.js";
|
|
2
|
-
import { logEvent } from "
|
|
3
|
-
import { Command } from "
|
|
2
|
+
import { logEvent } from "virello/client";
|
|
3
|
+
import { Command } from "virello/commands";
|
|
4
4
|
import { registerCommand } from "../registration";
|
|
5
5
|
|
|
6
6
|
export default class ShardCommand extends Command {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageFlags } from "discord.js";
|
|
2
|
-
import { logEvent } from "
|
|
3
|
-
import { Command } from "
|
|
2
|
+
import { logEvent } from "virello/client";
|
|
3
|
+
import { Command } from "virello/commands";
|
|
4
4
|
import { registerCommand } from "../registration";
|
|
5
5
|
import { formatStats, summarizeStats } from "../stats";
|
|
6
6
|
|
package/examples/config.ts
CHANGED
package/examples/contracts.ts
CHANGED
package/examples/coordinator.ts
CHANGED
package/examples/engine/live.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
GatewayIntentBits,
|
|
3
3
|
InteractionResponseType,
|
|
4
4
|
} from "discord-api-types/v10";
|
|
5
|
-
import { EngineClient, logEvent } from "
|
|
5
|
+
import { EngineClient, logEvent } from "virello/engine";
|
|
6
6
|
import { requiredEnv } from "../config";
|
|
7
7
|
import { exampleLogger, startupFailed } from "../logging";
|
|
8
8
|
import { onShutdown } from "../shutdown";
|
|
@@ -45,7 +45,7 @@ async function main(): Promise<void> {
|
|
|
45
45
|
client.on("messageCreate", async (message) => {
|
|
46
46
|
if (!message.data.author.bot && message.data.content === "!engine-ping")
|
|
47
47
|
await message.reply({
|
|
48
|
-
content: "Pong from
|
|
48
|
+
content: "Pong from Virello engine.",
|
|
49
49
|
allowed_mentions: { parse: [] },
|
|
50
50
|
});
|
|
51
51
|
});
|
|
@@ -57,7 +57,7 @@ async function main(): Promise<void> {
|
|
|
57
57
|
await interaction.respond({
|
|
58
58
|
type: InteractionResponseType.ChannelMessageWithSource,
|
|
59
59
|
data: {
|
|
60
|
-
content: "Pong from
|
|
60
|
+
content: "Pong from Virello engine.",
|
|
61
61
|
allowed_mentions: { parse: [] },
|
|
62
62
|
},
|
|
63
63
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EngineClient, logEvent } from "
|
|
1
|
+
import { EngineClient, logEvent } from "virello/engine";
|
|
2
2
|
import { exampleLogger } from "../logging";
|
|
3
3
|
import { MockDiscord } from "./MockDiscord";
|
|
4
4
|
|
|
@@ -34,7 +34,7 @@ async function main(): Promise<void> {
|
|
|
34
34
|
const resumed = Promise.withResolvers<void>();
|
|
35
35
|
client.on("messageCreate", async (message) => {
|
|
36
36
|
await message.reply({
|
|
37
|
-
content: "Pong from the original
|
|
37
|
+
content: "Pong from the original Virello engine.",
|
|
38
38
|
allowed_mentions: { parse: [] },
|
|
39
39
|
});
|
|
40
40
|
replied.resolve();
|
package/examples/host.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ShardManager } from "
|
|
1
|
+
import { ShardManager } from "virello/sharding";
|
|
2
2
|
import { integerEnv, requiredEnv } from "./config";
|
|
3
3
|
import { cleanupFailedStartup, exampleLogger, startupFailed } from "./logging";
|
|
4
4
|
import { onShutdown } from "./shutdown";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { logEvent } from "
|
|
2
|
-
import { Events, Listener } from "
|
|
1
|
+
import { logEvent } from "virello/client";
|
|
2
|
+
import { Events, Listener } from "virello/events";
|
|
3
3
|
|
|
4
4
|
export default class ReadyListener extends Listener<typeof Events.ClientReady> {
|
|
5
5
|
static override options: Listener.Options = {
|
package/examples/logging.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createConsoleLogger, type LoggerLike, logEvent } from "
|
|
1
|
+
import { createConsoleLogger, type LoggerLike, logEvent } from "virello/engine";
|
|
2
2
|
import { ExampleConfigurationError } from "./config";
|
|
3
3
|
|
|
4
4
|
// One logger per process; framework and example records use the same output settings.
|
package/examples/offline.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./contracts";
|
|
2
|
-
import { logEvent } from "
|
|
3
|
-
import { ShardCoordinator, ShardManager } from "
|
|
2
|
+
import { logEvent } from "virello/client";
|
|
3
|
+
import { ShardCoordinator, ShardManager } from "virello/sharding";
|
|
4
4
|
import { exampleLogger } from "./logging";
|
|
5
5
|
import { summarizeStats } from "./stats";
|
|
6
6
|
|
package/examples/registration.ts
CHANGED
package/examples/shutdown.ts
CHANGED
package/examples/stats.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virello",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A modular Discord framework for Bun, written in TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT AND Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/lilsnibbi/
|
|
9
|
+
"url": "https://github.com/lilsnibbi/virello.git"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|