@helyx/bot 1.3.1 → 1.5.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 (97) hide show
  1. package/CHANGELOG.md +100 -28
  2. package/README.md +65 -11
  3. package/dist/channel-audit-configuration.d.ts +7 -0
  4. package/dist/channel-audit-configuration.js +40 -0
  5. package/dist/channel-audit-control.d.ts +14 -0
  6. package/dist/channel-audit-control.js +61 -0
  7. package/dist/channel-audit-permissions.d.ts +56 -0
  8. package/dist/channel-audit-permissions.js +417 -0
  9. package/dist/channel-audit-routes.d.ts +4 -0
  10. package/dist/channel-audit-routes.js +42 -0
  11. package/dist/cloud-connector.d.ts +11 -4
  12. package/dist/cloud-connector.js +54 -15
  13. package/dist/cloud-control-dispatcher.d.ts +8 -3
  14. package/dist/cloud-control-dispatcher.js +84 -4
  15. package/dist/control-errors.d.ts +12 -0
  16. package/dist/control-errors.js +32 -0
  17. package/dist/control-server-schemas.d.ts +84 -0
  18. package/dist/control-server-schemas.js +101 -0
  19. package/dist/control-server.d.ts +25 -8
  20. package/dist/control-server.js +101 -152
  21. package/dist/core-retention.d.ts +26 -0
  22. package/dist/core-retention.js +49 -0
  23. package/dist/creator-guild-join-service.d.ts +25 -0
  24. package/dist/creator-guild-join-service.js +218 -0
  25. package/dist/creator-invite-service.d.ts +37 -0
  26. package/dist/creator-invite-service.js +686 -0
  27. package/dist/creator-onboarding-control.d.ts +12 -0
  28. package/dist/creator-onboarding-control.js +65 -0
  29. package/dist/creator-onboarding-platform.d.ts +20 -0
  30. package/dist/creator-onboarding-platform.js +58 -0
  31. package/dist/dashboard-action-control.d.ts +2 -2
  32. package/dist/dashboard-action-control.js +2 -3
  33. package/dist/database-bootstrap.d.ts +36 -0
  34. package/dist/database-bootstrap.js +101 -0
  35. package/dist/developer-operations-module.d.ts +1 -0
  36. package/dist/developer-operations-module.js +34 -16
  37. package/dist/discord-channel-audit.d.ts +9 -0
  38. package/dist/discord-channel-audit.js +195 -0
  39. package/dist/discord-guild-health.d.ts +2 -2
  40. package/dist/discord-owned-message-service.d.ts +1 -0
  41. package/dist/discord-owned-message-service.js +3 -0
  42. package/dist/discord-role-safety.d.ts +4 -0
  43. package/dist/discord-role-safety.js +30 -0
  44. package/dist/events.d.ts +2 -0
  45. package/dist/events.js +5 -20
  46. package/dist/guild-command-read-service.d.ts +8 -3
  47. package/dist/guild-command-read-service.js +14 -7
  48. package/dist/guild-command-release.d.ts +15 -8
  49. package/dist/guild-command-release.js +10 -3
  50. package/dist/guild-command-worker.d.ts +17 -4
  51. package/dist/guild-command-worker.js +17 -6
  52. package/dist/guilds.d.ts +24 -3
  53. package/dist/guilds.js +185 -64
  54. package/dist/hosted-server-moderation.js +10 -4
  55. package/dist/index.d.ts +1 -0
  56. package/dist/index.js +200 -82
  57. package/dist/interactions.js +16 -3
  58. package/dist/module-configuration.d.ts +1 -1
  59. package/dist/module-configuration.js +5 -2
  60. package/dist/module-logging.d.ts +8 -3
  61. package/dist/module-logging.js +13 -7
  62. package/dist/modules.d.ts +1 -0
  63. package/dist/modules.js +8 -1
  64. package/dist/mysql-runtime-persistence.d.ts +46 -0
  65. package/dist/mysql-runtime-persistence.js +91 -0
  66. package/dist/oauth-module.js +2 -2
  67. package/dist/oauth-service.d.ts +7 -0
  68. package/dist/oauth-service.js +3 -0
  69. package/dist/scheduled-task-runner.d.ts +9 -85
  70. package/dist/scheduled-task-runner.js +1 -1
  71. package/dist/shard-contracts.d.ts +222 -0
  72. package/dist/shard-contracts.js +52 -1
  73. package/dist/shard-router.d.ts +4 -1
  74. package/dist/shard-router.js +19 -0
  75. package/dist/shard-supervisor.js +43 -9
  76. package/dist/shard-worker.d.ts +5 -2
  77. package/dist/shard-worker.js +41 -5
  78. package/dist/supervisor-cloud-directory.d.ts +9 -3
  79. package/dist/supervisor-cloud-directory.js +8 -12
  80. package/dist/trivia-data-provider.d.ts +11 -0
  81. package/dist/trivia-data-provider.js +46 -26
  82. package/dist/verification-service.d.ts +2 -2
  83. package/dist/verification-service.js +6 -3
  84. package/documentation/README.md +5 -3
  85. package/documentation/examples/.env.example +15 -11
  86. package/documentation/guides/getting-started.md +29 -12
  87. package/documentation/guides/privacy-and-support.md +6 -5
  88. package/documentation/guides/self-hosting.md +16 -11
  89. package/documentation/modules/auto-moderation.md +7 -5
  90. package/documentation/modules/building-a-module.md +48 -2
  91. package/documentation/modules/moderation.md +5 -5
  92. package/documentation/modules/publishing-a-module.md +6 -4
  93. package/documentation/modules/testing-a-module.md +39 -4
  94. package/documentation/reference/environment.md +43 -9
  95. package/documentation/runbooks/backup-and-recovery.md +26 -7
  96. package/documentation/runbooks/installation-and-upgrades.md +97 -27
  97. package/package.json +20 -16
@@ -1,14 +1,15 @@
1
1
  # Backup and recovery runbook
2
2
 
3
- A usable Helyx backup includes PostgreSQL plus the environment and generated
3
+ A usable Helyx backup includes the selected PostgreSQL or MySQL-compatible database plus the environment and generated
4
4
  key material required to read encrypted records. A copy of the generated
5
5
  project without its database is not a complete backup.
6
6
 
7
7
  ## Back up
8
8
 
9
- 1. Record the installed package lockfile and Helyx release versions.
10
- 2. Create a consistent PostgreSQL backup with your database provider or
11
- PostgreSQL tooling.
9
+ 1. Preserve `package.json`, `package-lock.json`, `helyx.modules.json` and the
10
+ matching Helyx release versions. Record the selected database engine.
11
+ 2. Create a consistent backup with your database provider or the appropriate
12
+ engine-specific tooling.
12
13
  3. Back up `.env` and generated enrollment or encryption material separately.
13
14
  4. Encrypt backups, restrict access, and store at least one copy away from the
14
15
  running host.
@@ -25,14 +26,32 @@ At a regular interval:
25
26
  2. Restore a selected backup without overwriting production.
26
27
  3. Restore the matching environment and key material through the host's secret
27
28
  mechanism.
28
- 4. Run `npm ci` and `npm run doctor`.
29
- 5. Confirm a stateful module can read its configuration and records.
29
+ 4. Restore the matching project metadata and install that exact release with
30
+ `npm ci`, or build its Docker image. Run doctor in the disposable environment;
31
+ Compose users run
32
+ `docker compose run --rm bot node node_modules/@helyx/cli/dist/cli.js doctor`.
33
+ 5. Start the restored bot only with an explicitly authorised test Discord
34
+ identity and private server. Do not run a second copy with the active bot's
35
+ token. Confirm a stateful module can read its configuration and records.
30
36
  6. Destroy the disposable environment using the same controls as production.
31
37
 
32
38
  Record the recovery time, the backup generation used, the checks performed,
33
39
  and any corrective action. Treat restored data with the same access controls
34
40
  and deletion obligations as production data.
35
41
 
42
+ Restore into the same database engine with compatible server capabilities.
43
+ Changing `DATABASE_ENGINE` selects an adapter; it does not convert a dump, schema
44
+ or existing installation from PostgreSQL to MySQL or the reverse. Preserve the
45
+ engine identity and migration receipts together with the data.
46
+
47
+ Use the packages that match the backup's migration history. The current
48
+ fresh-install baselines are not an upgrade path for an older restored database.
49
+ [Contact Helyx support](../guides/privacy-and-support.md#contact-support-safely)
50
+ before attempting that transition; no approved procedure is available yet.
51
+ An updater backup under `.helyx/backups` contains managed project metadata only;
52
+ it cannot restore database contents, encryption keys, container images or
53
+ installed `node_modules`.
54
+
36
55
  ## Incident recovery
37
56
 
38
57
  Stop writes before a destructive restore. Preserve evidence needed to
@@ -42,7 +61,7 @@ restore over the only production database.
42
61
 
43
62
  ## Troubleshooting
44
63
 
45
- ### PostgreSQL restored but Cloud Connect or protected records fail
64
+ ### The database restored but Cloud Connect or protected records fail
46
65
 
47
66
  Confirm the restored runtime uses the matching data-encryption key and any
48
67
  generated enrolment material. Do not replace the key or delete affected rows to
@@ -1,54 +1,124 @@
1
1
  # Installation and upgrade runbook
2
2
 
3
- Use this runbook for the first start of a generated project and for a reviewed
4
- release-set update that preserves the local environment and database.
3
+ Use this runbook from the root of a generated Helyx project. It covers first
4
+ start, compatible release-set updates and failed validation.
5
+
6
+ ## Check the release boundary first
7
+
8
+ This release uses consolidated fresh-install migration baselines. An existing
9
+ database with the earlier migration chain cannot use those baselines as an
10
+ ordinary in-place upgrade. Keep its matching packages and data and
11
+ [contact Helyx support](../guides/privacy-and-support.md#contact-support-safely)
12
+ before proceeding; no approved old-database transition is available yet.
13
+ Do not reset a database, remove its migration
14
+ history or change recorded checksums to make an update pass.
15
+
16
+ The updater changes project metadata; it does not verify or provide a
17
+ data-preserving migration path. A release described as fresh-install/reset-only
18
+ must not be applied to an existing database through the ordinary update steps
19
+ below.
5
20
 
6
21
  ## First installation
7
22
 
8
- 1. Generate the project with `helyx self-host init` and a reviewed build
9
- manifest.
10
- 2. Copy and complete `.env` with `helyx setup`.
11
- 3. Install dependencies with `npm ci` if they were not installed during
12
- generation.
13
- 4. Run `npm run doctor` and resolve every error.
14
- 5. Start the process and confirm database, Discord, and module health.
15
- 6. Exercise one low-risk command in a test server before production use.
23
+ 1. Download a starter ZIP, or generate it from the builder's reviewed manifest.
24
+ 2. Install its dependencies with `npm ci` unless generation used `--install`.
25
+ 3. Run `npm run setup`, then complete `.env`. A managed host may supply the
26
+ required values through its protected variables panel instead. Keep the
27
+ generated encryption key stable.
28
+ 4. Make the selected database reachable and run doctor through the matching
29
+ runtime path below. Resolve every error.
30
+ 5. Start Helyx and confirm database, Discord and module readiness. Exercise one
31
+ low-risk command in a private test server before production use.
32
+
33
+ The starter uses compiled npm packages: direct Node.js operation has no local
34
+ `npm run build` step. Docker builds the supplied image.
35
+
36
+ ## Run doctor in the right environment
37
+
38
+ - **Direct Node.js:** run `npm run doctor` after installation and configuration.
39
+ - **Docker Compose:** run `docker compose build bot`, start the included
40
+ PostgreSQL service with `docker compose up -d --wait database` if present,
41
+ then run
42
+ `docker compose run --rm bot node node_modules/@helyx/cli/dist/cli.js doctor`.
43
+ The MySQL Compose starter has no database service; its external database must
44
+ already be reachable. Use container doctor with container database addresses
45
+ such as `database`; that hostname normally cannot resolve from the host shell.
46
+ - **Managed hosting:** install the pinned dependencies, supply the production
47
+ variables and run `npm run doctor` through the provider's console or one-off
48
+ command facility before enabling its start process.
49
+
50
+ Doctor does not sign in to Discord, change the database or probe required server
51
+ capabilities. It inspects core migration history and validates selected packages
52
+ and engine compatibility. Module migration inspection runs only after no core
53
+ migrations remain pending. On a fresh database, pending migrations are expected;
54
+ normal startup applies core migrations, then module migrations, and probes
55
+ database capabilities. `npm run migrate` applies core migrations only and is not
56
+ a prerequisite before every start.
16
57
 
17
58
  ## Upgrade
18
59
 
19
- 1. Read the release notes and confirm the supported Node.js and npm versions.
20
- 2. Create a current PostgreSQL backup and preserve the existing project
60
+ 1. Read the release notes, confirm an ordinary upgrade is supported from your
61
+ installed database state, and check the supported Node.js and npm versions.
62
+ 2. Create a current backup of the selected database and preserve the existing project
21
63
  metadata and environment file.
22
- 3. Stop the Helyx process cleanly.
64
+ 3. Stop the bot cleanly. With Compose use `docker compose stop bot`, preserving
65
+ the database service and volume; on a managed host stop its application process.
23
66
  4. Preview the compatible release set:
24
67
 
25
68
  ```sh
26
- helyx self-host update --check
69
+ npm run update:check
27
70
  ```
28
71
 
29
72
  5. Apply it only after reviewing the complete change:
30
73
 
31
74
  ```sh
32
- helyx self-host update --confirm
33
- npm ci
34
- npm run doctor
75
+ npm run update
35
76
  ```
36
77
 
37
- 6. Start Helyx and verify health, command availability, and one representative
38
- workflow for every upgraded module.
39
-
40
- The updater backs up managed project metadata under `.helyx/backups` and does
41
- not change `.env` or customer database data. Database migrations can be
42
- forward-only. Never edit migration history or downgrade individual Helyx
43
- packages to simulate a rollback.
78
+ The generated `update` script runs `helyx self-host update --confirm` followed
79
+ by `npm ci`. The CLI command alone does not install the refreshed dependency
80
+ set. Older starters without these scripts can use
81
+ `npx --yes @helyx/cli@latest self-host update --check`, then the same command
82
+ with `--confirm`, followed by `npm ci`.
83
+
84
+ 6. Run doctor through the runtime path above. Docker users must rebuild the bot
85
+ image first, then recreate it with `docker compose up -d bot` after doctor
86
+ passes. Direct Node.js users start with `npm start`; managed hosts use their
87
+ configured start command.
88
+ 7. Verify health, command availability and one representative workflow for every
89
+ upgraded module.
90
+
91
+ The updater backs up `.gitignore`, `package.json`, `package-lock.json`,
92
+ `helyx.modules.json` and `SHA256SUMS` under `.helyx/backups/<timestamp>/`. It
93
+ refreshes exact Helyx dependencies and the lockfile together, leaving `.env` and
94
+ database data unchanged. This metadata backup is not a database backup or an
95
+ installed-dependency snapshot.
96
+
97
+ If metadata generation or lockfile validation fails inside `--confirm`, the
98
+ updater restores those managed files. That restoration does not cover a later
99
+ `npm ci`, doctor or startup failure. Database migrations can be forward-only.
100
+ Never downgrade individual Helyx packages to simulate a rollback.
101
+
102
+ `DATABASE_ENGINE` defaults to `postgresql`; use `mysql` only with the matching
103
+ adapter, database and module support. The setting is not a data-conversion tool.
104
+ Keep the selected engine unchanged during an ordinary update. Missing adapters,
105
+ an unsupported module/engine combination or an installation engine mismatch must
106
+ be resolved explicitly, not bypassed by falling back to another adapter.
107
+
108
+ Applied checksum mismatches or an interrupted MySQL DDL receipt are errors to
109
+ investigate before restarting, not fresh-install pending notices.
44
110
 
45
111
  ## Failed validation
46
112
 
47
113
  Leave the process stopped, retain sanitised logs, and determine whether the
48
114
  failure is configuration, package integrity, database connectivity, or module
49
- compatibility. If the updater restored managed files, rerun `npm ci` and
50
- `npm run doctor` before restarting the previous version. Restore data only from
51
- a tested backup and only when the incident specifically requires it.
115
+ compatibility. If the updater restored managed files before startup, rerun
116
+ `npm ci` and doctor against that restored set; Docker users rebuild and validate
117
+ the corresponding image. If startup or a manual migration already changed the
118
+ database, restoring project files does not reverse those changes. Check
119
+ package/schema compatibility and the backup recovery plan before restarting an
120
+ older release. Restore data only from a tested compatible backup when the
121
+ incident requires it.
52
122
 
53
123
  ## Troubleshooting
54
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helyx/bot",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Production Discord runtime for the modular Helyx platform.",
5
5
  "keywords": [
6
6
  "helyx",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "publishConfig": {
27
27
  "access": "public",
28
- "provenance": true
28
+ "provenance": false
29
29
  },
30
30
  "type": "module",
31
31
  "files": [
@@ -50,27 +50,31 @@
50
50
  "start": "node --env-file-if-exists=../../.env dist/index.js"
51
51
  },
52
52
  "dependencies": {
53
- "@helyx/config": ">=1.0.0 <2.0.0",
54
- "@helyx/control-protocol": ">=0.5.0 <0.6.0",
55
- "@helyx/core": ">=0.1.0 <0.2.0",
56
- "@helyx/database": ">=2.3.0",
57
- "@helyx/framework": ">=0.1.0 <0.2.0",
58
- "@helyx/module-manifest": ">=0.11.0 <0.12.0",
59
- "@helyx/platform": ">=1.2.0",
60
- "@helyx/sdk": ">=0.14.0",
61
- "@helyx/status-client": ">=0.2.0 <0.3.0",
62
- "@helyx/verification-contracts": ">=0.3.0 <0.4.0",
53
+ "@helyx/config": ">=1.4.0 <2.0.0",
54
+ "@helyx/control-protocol": ">=0.8.0 <0.9.0",
55
+ "@helyx/core": ">=0.2.0 <0.3.0",
56
+ "@helyx/database": ">=2.4.0 <3.0.0",
57
+ "@helyx/database-contracts": ">=0.2.0 <0.3.0",
58
+ "@helyx/framework": ">=0.2.0 <0.3.0",
59
+ "@helyx/module-manifest": ">=0.13.0 <0.14.0",
60
+ "@helyx/platform": ">=1.3.0 <2.0.0",
61
+ "@helyx/sdk": ">=0.16.0 <0.17.0",
62
+ "@helyx/status-client": ">=0.3.0 <0.4.0",
63
+ "@helyx/verification-contracts": ">=0.4.0 <0.5.0",
63
64
  "discord.js": "14.27.0",
64
- "fastify": "5.12.3",
65
+ "fastify": "5.12.7",
65
66
  "pino": "10.3.1",
66
67
  "redis": "6.1.0",
67
- "undici": "6.28.0",
68
+ "undici": "6.29.0",
68
69
  "ws": "8.21.1",
69
70
  "zod": "4.4.3"
70
71
  },
72
+ "optionalDependencies": {
73
+ "@helyx/database-mysql": ">=0.2.0 <0.3.0"
74
+ },
71
75
  "peerDependencies": {
72
- "@helyx/module-automod": ">=1.0.2",
73
- "@helyx/module-moderation": ">=1.0.2"
76
+ "@helyx/module-automod": ">=1.1.1 <2.0.0",
77
+ "@helyx/module-moderation": ">=1.1.1 <2.0.0"
74
78
  },
75
79
  "peerDependenciesMeta": {
76
80
  "@helyx/module-automod": {