cyberia 3.2.9 → 3.2.22

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 (184) hide show
  1. package/.github/workflows/engine-cyberia.cd.yml +7 -0
  2. package/.github/workflows/engine-cyberia.ci.yml +14 -2
  3. package/.github/workflows/ghpkg.ci.yml +1 -0
  4. package/.github/workflows/npmpkg.ci.yml +10 -5
  5. package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
  6. package/.github/workflows/release.cd.yml +1 -0
  7. package/.vscode/extensions.json +9 -9
  8. package/.vscode/settings.json +20 -4
  9. package/CHANGELOG.md +363 -1
  10. package/CLI-HELP.md +975 -1061
  11. package/README.md +190 -348
  12. package/bin/build.js +102 -125
  13. package/bin/build.template.js +33 -0
  14. package/bin/cyberia.js +238 -56
  15. package/bin/deploy.js +16 -3
  16. package/bin/index.js +238 -56
  17. package/bump.config.js +26 -0
  18. package/conf.js +131 -24
  19. package/deployment.yaml +76 -2
  20. package/hardhat/package-lock.json +113 -144
  21. package/hardhat/package.json +4 -3
  22. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -2
  23. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
  24. package/manifests/deployment/dd-cyberia-development/deployment.yaml +76 -2
  25. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  26. package/manifests/kind-config-dev.yaml +8 -0
  27. package/manifests/lxd/lxd-admin-profile.yaml +12 -3
  28. package/manifests/mongodb/pv-pvc.yaml +44 -8
  29. package/manifests/mongodb/statefulset.yaml +55 -68
  30. package/manifests/mongodb-4.4/headless-service.yaml +10 -0
  31. package/manifests/mongodb-4.4/kustomization.yaml +3 -1
  32. package/manifests/mongodb-4.4/mongodb-nodeport.yaml +17 -0
  33. package/manifests/mongodb-4.4/pv-pvc.yaml +10 -14
  34. package/manifests/mongodb-4.4/statefulset.yaml +79 -0
  35. package/manifests/mongodb-4.4/storage-class.yaml +9 -0
  36. package/manifests/valkey/statefulset.yaml +1 -1
  37. package/manifests/valkey/valkey-nodeport.yaml +17 -0
  38. package/package.json +31 -19
  39. package/scripts/ipxe-setup.sh +52 -49
  40. package/scripts/k3s-node-setup.sh +81 -46
  41. package/scripts/link-local-underpost-cli.sh +6 -0
  42. package/scripts/lxd-vm-setup.sh +193 -8
  43. package/scripts/maas-nat-firewalld.sh +145 -0
  44. package/scripts/test-monitor.sh +250 -0
  45. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +38 -33
  46. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +16 -16
  47. package/src/api/core/core.router.js +19 -14
  48. package/src/api/core/core.service.js +5 -5
  49. package/src/api/crypto/crypto.router.js +18 -12
  50. package/src/api/crypto/crypto.service.js +3 -3
  51. package/src/api/cyberia-action/cyberia-action.model.js +1 -1
  52. package/src/api/cyberia-action/cyberia-action.router.js +22 -18
  53. package/src/api/cyberia-action/cyberia-action.service.js +5 -5
  54. package/src/api/cyberia-client-hints/cyberia-client-hints.controller.js +74 -0
  55. package/src/api/cyberia-client-hints/cyberia-client-hints.model.js +99 -0
  56. package/src/api/cyberia-client-hints/cyberia-client-hints.router.js +98 -0
  57. package/src/api/cyberia-client-hints/cyberia-client-hints.service.js +152 -0
  58. package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +25 -20
  59. package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +6 -6
  60. package/src/api/cyberia-entity/cyberia-entity.router.js +22 -18
  61. package/src/api/cyberia-entity/cyberia-entity.service.js +5 -5
  62. package/src/api/cyberia-instance/cyberia-fallback-world.js +79 -4
  63. package/src/api/cyberia-instance/cyberia-instance.router.js +57 -52
  64. package/src/api/cyberia-instance/cyberia-instance.service.js +10 -10
  65. package/src/api/cyberia-instance/cyberia-world-generator.js +3 -3
  66. package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +14 -48
  67. package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +22 -18
  68. package/src/api/cyberia-instance-conf/cyberia-instance-conf.service.js +5 -5
  69. package/src/api/cyberia-map/cyberia-map.router.js +35 -30
  70. package/src/api/cyberia-map/cyberia-map.service.js +7 -7
  71. package/src/api/cyberia-quest/cyberia-quest.model.js +1 -1
  72. package/src/api/cyberia-quest/cyberia-quest.router.js +22 -18
  73. package/src/api/cyberia-quest/cyberia-quest.service.js +5 -5
  74. package/src/api/cyberia-quest-progress/cyberia-quest-progress.router.js +22 -18
  75. package/src/api/cyberia-quest-progress/cyberia-quest-progress.service.js +5 -5
  76. package/src/api/cyberia-server-defaults/cyberia-server-defaults.js +458 -0
  77. package/src/api/default/default.router.js +22 -18
  78. package/src/api/default/default.service.js +5 -5
  79. package/src/api/document/document.router.js +28 -23
  80. package/src/api/document/document.service.js +100 -23
  81. package/src/api/file/file.router.js +19 -13
  82. package/src/api/file/file.service.js +9 -7
  83. package/src/api/instance/instance.router.js +29 -24
  84. package/src/api/instance/instance.service.js +6 -6
  85. package/src/api/ipfs/ipfs.router.js +21 -16
  86. package/src/api/ipfs/ipfs.service.js +8 -8
  87. package/src/api/object-layer/object-layer.router.js +512 -507
  88. package/src/api/object-layer/object-layer.service.js +17 -14
  89. package/src/api/object-layer-render-frames/object-layer-render-frames.router.js +22 -18
  90. package/src/api/object-layer-render-frames/object-layer-render-frames.service.js +5 -5
  91. package/src/api/test/test.router.js +17 -12
  92. package/src/api/types.js +24 -0
  93. package/src/api/user/guest.service.js +5 -4
  94. package/src/api/user/user.router.js +297 -288
  95. package/src/api/user/user.service.js +100 -35
  96. package/src/cli/baremetal.js +132 -101
  97. package/src/cli/cluster.js +700 -232
  98. package/src/cli/db.js +59 -60
  99. package/src/cli/deploy.js +291 -294
  100. package/src/cli/env.js +1 -4
  101. package/src/cli/fs.js +13 -3
  102. package/src/cli/image.js +58 -4
  103. package/src/cli/index.js +127 -15
  104. package/src/cli/ipfs.js +4 -6
  105. package/src/cli/kubectl.js +4 -1
  106. package/src/cli/lxd.js +1099 -223
  107. package/src/cli/monitor.js +396 -9
  108. package/src/cli/release.js +355 -146
  109. package/src/cli/repository.js +169 -30
  110. package/src/cli/run.js +347 -117
  111. package/src/cli/secrets.js +11 -2
  112. package/src/cli/test.js +9 -3
  113. package/src/client/Default.index.js +9 -3
  114. package/src/client/components/core/Auth.js +5 -0
  115. package/src/client/components/core/ClientEvents.js +76 -0
  116. package/src/client/components/core/EventBus.js +4 -0
  117. package/src/client/components/core/Modal.js +82 -41
  118. package/src/client/components/core/PanelForm.js +14 -10
  119. package/src/client/components/core/Worker.js +162 -363
  120. package/src/client/components/cyberia/MapEngineCyberia.js +1 -1
  121. package/src/client/components/cyberia/SharedDefaultsCyberia.js +330 -0
  122. package/src/client/public/cyberia-docs/ACTION-SYSTEM.md +55 -1
  123. package/src/client/public/cyberia-docs/ARCHITECTURE.md +223 -361
  124. package/src/client/public/cyberia-docs/CYBERIA-CLI.md +114 -327
  125. package/src/client/public/cyberia-docs/CYBERIA-CLIENT.md +200 -222
  126. package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +212 -185
  127. package/src/client/public/cyberia-docs/CYBERIA.md +259 -0
  128. package/src/client/public/cyberia-docs/OFF-CHAIN-ECONOMY.md +2 -2
  129. package/src/client/public/cyberia-docs/QUEST-SYSTEM.md +23 -1
  130. package/src/client/public/cyberia-docs/ROADMAP.md +1 -1
  131. package/src/client/public/cyberia-docs/UNDERPOST-PLATFORM.md +106 -0
  132. package/src/client/public/cyberia-docs/WHITE-PAPER.md +1 -1
  133. package/src/client/services/cyberia-client-hints/cyberia-client-hints.service.js +99 -0
  134. package/src/client/ssr/views/CyberiaServerMetrics.js +982 -0
  135. package/src/client/sw/core.sw.js +174 -112
  136. package/src/db/DataBaseProvider.js +115 -15
  137. package/src/db/mariadb/MariaDB.js +2 -1
  138. package/src/db/mongo/MongoBootstrap.js +657 -0
  139. package/src/db/mongo/MongooseDB.js +130 -21
  140. package/src/grpc/cyberia/grpc-server.js +25 -57
  141. package/src/index.js +1 -1
  142. package/src/runtime/cyberia-client/Dockerfile +10 -7
  143. package/src/runtime/cyberia-client/Dockerfile.dev +67 -0
  144. package/src/runtime/cyberia-server/Dockerfile +11 -6
  145. package/src/runtime/cyberia-server/Dockerfile.dev +47 -0
  146. package/src/runtime/express/Express.js +2 -2
  147. package/src/runtime/wp/Dockerfile +3 -3
  148. package/src/runtime/wp/Wp.js +8 -5
  149. package/src/server/auth.js +2 -2
  150. package/src/server/catalog-underpost.js +61 -0
  151. package/src/server/catalog.js +77 -0
  152. package/src/server/client-build-docs.js +1 -1
  153. package/src/server/client-build.js +94 -129
  154. package/src/server/conf.js +496 -135
  155. package/src/server/ipfs-client.js +5 -3
  156. package/src/server/process.js +180 -19
  157. package/src/server/proxy.js +9 -2
  158. package/src/server/runtime-status.js +235 -0
  159. package/src/server/runtime.js +1 -1
  160. package/src/server/start.js +44 -11
  161. package/src/server/valkey.js +2 -0
  162. package/src/ws/IoInterface.js +16 -16
  163. package/src/ws/core/channels/core.ws.chat.js +11 -11
  164. package/src/ws/core/channels/core.ws.mailer.js +29 -29
  165. package/src/ws/core/channels/core.ws.stream.js +19 -19
  166. package/src/ws/core/core.ws.connection.js +8 -8
  167. package/src/ws/core/core.ws.server.js +6 -5
  168. package/src/ws/default/channels/default.ws.main.js +10 -10
  169. package/src/ws/default/default.ws.connection.js +4 -4
  170. package/src/ws/default/default.ws.server.js +4 -3
  171. package/test/deploy-monitor.test.js +251 -0
  172. package/bin/file.js +0 -202
  173. package/bin/vs.js +0 -74
  174. package/bin/zed.js +0 -84
  175. package/manifests/deployment/dd-test-development/deployment.yaml +0 -254
  176. package/manifests/deployment/dd-test-development/proxy.yaml +0 -102
  177. package/src/api/cyberia-instance-conf/cyberia-instance-conf.defaults.js +0 -574
  178. package/src/client/components/cyberia-portal/CommonCyberiaPortal.js +0 -467
  179. package/src/client/ssr/email/DefaultRecoverEmail.js +0 -21
  180. package/src/client/ssr/email/DefaultVerifyEmail.js +0 -17
  181. package/src/client/ssr/pages/CyberiaServerMetrics.js +0 -461
  182. /package/src/client/ssr/{offline → views}/Maintenance.js +0 -0
  183. /package/src/client/ssr/{offline → views}/NoNetworkConnection.js +0 -0
  184. /package/src/client/ssr/{pages → views}/Test.js +0 -0
package/README.md CHANGED
@@ -1,10 +1,8 @@
1
- <p align="center">
2
- <img src="https://www.cyberiaonline.com/assets/splash/apple-touch-icon-precomposed.png" alt="CYBERIA Network Object Layer Engine"/>
3
- </p>
4
-
5
1
  <div align="center">
6
2
 
7
- ### CYBERIA
3
+ <img src="https://www.cyberiaonline.com/assets/splash/apple-touch-icon-precomposed.png" alt="CYBERIA Network Object Layer Engine"/>
4
+
5
+ <h1>CYBERIA</h1>
8
6
 
9
7
  **Network Object Layers**
10
8
 
@@ -13,405 +11,249 @@ _Stackable Rendering Layers as a Unified Tokenized Reality_
13
11
  [![Version](https://img.shields.io/npm/v/cyberia.svg)](https://www.npmjs.org/package/cyberia)
14
12
 
15
13
  </div>
14
+ Cyberia is an MMORPG extension built on the Underpost Platform. The platform owns the
15
+ toolchain, deployment surface, PWA delivery, and base infrastructure. Cyberia adds a three-service MMO
16
+ runtime: `engine-cyberia`, `cyberia-server`, and `cyberia-client`.
16
17
 
17
- # Cyberia CLI
18
-
19
- **Path:** `bin/cyberia.js`
20
-
21
- ---
22
-
23
- ## Overview
24
-
25
- The Cyberia CLI (`cyberia`) is an extension of the **Underpost CLI** specifically for the Cyberia MMORPG ecosystem. Underpost is the end-to-end bare-metal infrastructure platform for general-purpose applications; `cyberia` extends it with tooling for the game's content pipeline, economy, and MMO engine toolchain. Unrecognized commands are transparently passed through to `underpost` for infrastructure operations.
26
-
27
- The CLI manages:
28
-
29
- - **Object Layer (`ol`)** — import, generate, and manage game item definitions and sprite atlases.
30
- - **Instance (`instance`)** — export/import/seed game instance data (maps, entities, configs).
31
- - **Chain (`chain`)** — Hyperledger Besu deployment and ERC-1155 ObjectLayerToken lifecycle.
32
- - **Run-Workflow (`run-workflow`)** — execute named operational scripts (seed defaults, build manifests).
18
+ `engine-cyberia` is the **sidecar-backed data layer**: a Node.js sidecar that owns content,
19
+ validation, persistence, the gRPC/REST data services, and asset metadata. It backs the authoritative
20
+ Go server and the WASM client with data — it does not run the simulation or the presentation.
33
21
 
34
22
  ---
35
23
 
36
- ## Global Usage
37
-
38
- ```bash
39
- node bin/cyberia.js <command> [subcommand] [options]
40
- # or if installed globally:
41
- cyberia <command> [subcommand] [options]
24
+ ## Ecosystem at a glance
25
+
26
+ ```text
27
+ ┌───────────────────────────────────────────────┐
28
+ │ UNDERPOST PLATFORM │
29
+ │ toolchain · deploy · PWA build · static │
30
+ │ delivery · cluster/image/db · monitoring │
31
+ │ │
32
+ │ underpost CLI ──▶ builds & deploys all │
33
+ └───────────────────────────────────────────────┘
34
+ │ hosts / delivers
35
+
36
+ ╔═══════════════════════════════ CYBERIA MMO ══════════════════════════════════╗
37
+ ║ ║
38
+ ║ ┌──────────────────┐ gRPC ┌──────────────────┐ WebSocket ║
39
+ ║ │ engine-cyberia │ ────────▶ │ cyberia-server │ ───────────┐ ║
40
+ ║ │ (Node.js) │ │ (Go) │ │ ║
41
+ ║ │ │ │ │ ▼ ║
42
+ ║ │ content │ │ authoritative │ ┌──────────────────┐ ║
43
+ ║ │ validation │ │ simulation │ │ cyberia-client │ ║
44
+ ║ │ persistence │ │ world tick │ │ (C / WASM) │ ║
45
+ ║ │ gRPC/REST data │ │ AOI replication │ │ │ ║
46
+ ║ │ asset metadata │ │ │ │ rendering │ ║
47
+ ║ └──────────────────┘ └──────────────────┘ │ input │ ║
48
+ ║ │ │ prediction │ ║
49
+ ║ └──────────────── REST (content/assets) ─────▶│ presentation │ ║
50
+ ║ └──────────────────┘ ║
51
+ ╚═══════════════════════════════════════════════════════════════════════════════╝
52
+
53
+ One source of truth per concern:
54
+ content & world config ── engine-cyberia
55
+ real-time world state ── cyberia-server
56
+ presentation & input ── cyberia-client
42
57
  ```
43
58
 
44
59
  ---
45
60
 
46
- ## `cyberia ol` Object Layer Management
47
-
48
- Manages the Object Layer content pipeline: import PNG assets, generate procedural layers, build atlas sprite sheets, and push to IPFS/MongoDB.
49
-
50
- ```bash
51
- cyberia ol [item-id] [options]
52
- ```
53
-
54
- ### Options
55
-
56
- | Option | Description |
57
- | ------------------------------- | --------------------------------------------------------------------------------------------- |
58
- | `--import` | Import specific item-id(s) (comma-separated) from the PNG asset directory into MongoDB + IPFS |
59
- | `--import-types [types]` | Batch import by type (e.g. `skin,floor`) or `all` |
60
- | `--generate` | Generate procedural layers for a semantic item-id (see Semantic Registry below) |
61
- | `--count <n>` | Shape element count multiplier for `--generate` (default: `3`) |
62
- | `--seed <seed>` | Deterministic seed string for `--generate` (e.g. `fx-42`) |
63
- | `--frame-index <n>` | Starting frame index for `--generate` (default: `0`) |
64
- | `--frame-count <n>` | Number of frames to generate for `--generate` (default: `1`) |
65
- | `--density <0..1>` | Shape density factor for `--generate` (default: `0.5`) |
66
- | `--to-atlas-sprite-sheet [dim]` | Convert ObjectLayer frames to a consolidated atlas PNG |
67
- | `--show-atlas-sprite-sheet` | Display the atlas PNG for the given item-id |
68
- | `--show-frame [dir_frame]` | View a single frame (e.g. `08_0`; default: `08_0`) |
69
- | `--drop` | Drop existing data before importing |
70
- | `--client-public` | With `--drop`: also remove static client asset folders |
71
- | `--git-clean` | With `--drop`: run clean on the cyberia asset directory |
72
- | `--dev` | Force development env (uses `.env.development` for localhost IPFS) |
73
- | `--env-path <path>` | Path to `.env` file (e.g. `./engine-private/conf/dd-cyberia/.env.development`) |
74
- | `--mongo-host <host>` | MongoDB host override |
75
- | `--storage-file-path <path>` | Storage filter JSON path override |
76
-
77
- ### Examples
78
-
79
- ```bash
80
- # Import a single item from PNG source
81
- cyberia ol hatchet --import --env-path ./engine-private/conf/dd-cyberia/.env.development
82
-
83
- # Import all items of type 'skin' and 'floor'
84
- cyberia ol --import-types skin,floor
85
-
86
- # Import all types
87
- cyberia ol --import-types all
88
-
89
- # Generate a procedural floor tile (desert biome, seed fx-42)
90
- cyberia ol floor-desert --generate --seed fx-42
91
-
92
- # Generate 4 frames of a procedural floor with custom count and density
93
- cyberia ol floor-grass --generate --frame-count 4 --count 5 --density 0.7
61
+ ## 1. Toolchain and base infrastructure
94
62
 
95
- # Generate a character skin
96
- cyberia ol skin-dark-001 --generate --seed my-seed
63
+ Underpost Platform is the operational backbone and the source of truth for deploy IDs, runtime
64
+ selection, host/path layout, generated client assets, and environment resolution.
97
65
 
98
- # View a specific frame of an item
99
- cyberia ol hatchet --show-frame 08_0
66
+ | Area | What it owns |
67
+ | --------------- | ------------------------------------------------------------------------------------ |
68
+ | Toolchain | `underpost` CLI, build, deploy, release, metadata, secrets, environment selection |
69
+ | Infrastructure | bare metal, LXD, Kubernetes, K3s, kubeadm, images, SSH, runners |
70
+ | Data operations | MongoDB, MariaDB where needed, backups, cron, monitoring |
71
+ | Delivery | static build, SSR views, PWA packaging, service worker generation, host/path routing |
100
72
 
101
- # Rebuild atlas sprite sheet for an item
102
- cyberia ol hatchet --to-atlas-sprite-sheet
103
-
104
- # Drop and re-import a single item
105
- cyberia ol hatchet --drop --import
106
- ```
73
+ `underpost` is the shared control surface for everything infrastructural. Cyberia-specific work belongs
74
+ in the `cyberia` CLI, never in parallel platform commands. When a concern already exists in `underpost`,
75
+ reuse it instead of forking a Cyberia variant.
107
76
 
108
77
  ---
109
78
 
110
- ## Semantic Item-ID Registry
111
-
112
- The `--generate` flag uses item-id prefixes to look up a procedural descriptor from the semantic registry.
113
-
114
- ### Floor Prefixes
79
+ ## 2. PWA workflow
115
80
 
116
- | Prefix | Biome | Description |
117
- | -------------- | ------ | ----------------------------------------------- |
118
- | `floor-desert` | Desert | Sandy, arid tile with warm yellow/brown palette |
119
- | `floor-grass` | Grass | Meadow tile with green/earth tones |
120
- | `floor-water` | Water | Ocean/lake tile with blue/teal palette |
121
- | `floor-stone` | Stone | Rock/cobble tile with grey palette |
122
- | `floor-lava` | Lava | Magma tile with red/orange palette |
81
+ Every deployed client ships as a static application shell with PWA support. The pipeline has exactly two
82
+ inputs:
123
83
 
124
- ### Skin Prefixes
84
+ - the deploy `ssr` configuration in `conf.dd-*.js` (or `conf.ssr.json`)
85
+ - the service worker source in `src/client/sw/core.sw.js`
125
86
 
126
- | Prefix | Description |
127
- | -------------- | ----------------------------------------------- |
128
- | `skin-random` | Fully random skin tone and hair |
129
- | `skin-dark` | Dark skin tones |
130
- | `skin-light` | Light / pale skin tones |
131
- | `skin-vivid` | Vivid / exotic hair colours (blue, red, green…) |
132
- | `skin-natural` | Natural hair colours (brown, blond, grey…) |
133
- | `skin-shaved` | Shaved / bald head — no hair |
87
+ Everything else — `index.html` pages, `sw.js`, the precache list — is **generated** during the client
88
+ build. Treat them as outputs only; never hand-edit them.
134
89
 
135
- ### Resource Prefixes
90
+ Runtime service-worker behavior:
136
91
 
137
- Resource prefixes follow the pattern `resource-{biome}-{shape}`:
92
+ | Request | Strategy |
93
+ | ------------- | -------------------------------- |
94
+ | static assets | stale-while-revalidate |
95
+ | API `GET` | network-first + short cache |
96
+ | API mutations | network-only + background replay |
97
+ | navigation | network-first + fallback shells |
138
98
 
139
- | Shape Family | Description |
140
- | ------------ | -------------------------------------- |
141
- | `petal` | Parabolic arc shapes — coloured petals |
142
- | `stone` | Hard, angular mineral shapes |
143
- | `polygon` | Crystal/geometric faceted shapes |
144
- | `thread` | Thin, wispy Bézier lines |
145
-
146
- **Biomes:** `desert`, `grass`, `water`, `stone`, `lava`
147
-
148
- **Full matrix (20 prefixes):**
149
-
150
- ```
151
- resource-desert-petal resource-grass-petal resource-water-petal
152
- resource-desert-stone resource-grass-stone resource-water-stone
153
- resource-desert-polygon resource-grass-polygon resource-water-polygon
154
- resource-desert-thread resource-grass-thread resource-water-thread
155
-
156
- resource-stone-petal resource-lava-petal
157
- resource-stone-stone resource-lava-stone
158
- resource-stone-polygon resource-lava-polygon
159
- resource-stone-thread resource-lava-thread
160
- ```
99
+ Fallback selection: offline network → offline fallback view; origin/server failure → maintenance
100
+ fallback view. Only fallback-marked views are guaranteed precached.
161
101
 
162
102
  ---
163
103
 
164
- ## `cyberia instance` Instance Management
165
-
166
- Manages game instance documents (maps, entities, actions, quests, skill config) in MongoDB.
167
-
168
- ```bash
169
- cyberia instance [instance-code] [options]
170
- ```
104
+ ## 3. Cyberia MMO extension
171
105
 
172
- ### Options
106
+ ### Responsibility split
173
107
 
174
- | Option | Description |
175
- | --------------------- | ----------------------------------------------------------------------------------------------------------------- |
176
- | `--export [path]` | Export instance and all related documents to a backup directory |
177
- | `--import [path]` | Import instance documents from a backup directory (upsert, preserves UUIDs) |
178
- | `--conf` | With `--export`/`--import`: only process instance and instance-conf documents (skip maps, entities, ObjectLayers) |
179
- | `--drop` | Drop all documents associated with the instance code |
180
- | `--env-path <path>` | Path to `.env` file |
181
- | `--mongo-host <host>` | MongoDB host override |
182
- | `--dev` | Force development environment |
108
+ | Service | Owns | Must not own |
109
+ | ---------------- | ------------------------------------------------------------------------- | --------------------------------------------- |
110
+ | `engine-cyberia` | content, validation, persistence, gRPC/REST data services, asset metadata | authoritative simulation, render policy |
111
+ | `cyberia-server` | authoritative simulation, world tick, gameplay mutation, AOI replication | content authority, presentation metadata |
112
+ | `cyberia-client` | rendering, input, prediction, interpolation, presentation | authoritative world state, gameplay authority |
183
113
 
184
- ### Examples
114
+ Two boundaries are non-negotiable:
185
115
 
186
- ```bash
187
- # Export instance to backup
188
- cyberia instance cyberia-main --export ./backups/cyberia-main
116
+ - Do not move authoritative logic into the client.
117
+ - Do not move content-authority logic into the Go runtime.
189
118
 
190
- # Import instance from backup
191
- cyberia instance cyberia-main --import ./backups/cyberia-main
119
+ ### Data flow
192
120
 
193
- # Drop instance data
194
- cyberia instance cyberia-main --drop
121
+ ```text
122
+ engine-cyberia ──gRPC──▶ cyberia-server ──WebSocket──▶ cyberia-client
123
+ engine-cyberia ──REST──────────────────────────────▶ cyberia-client
195
124
  ```
196
125
 
197
- ---
198
-
199
- ## `cyberia chain` Blockchain Lifecycle
200
-
201
- Full lifecycle management for the Hyperledger Besu network and `ObjectLayerToken` ERC-1155 contract.
202
-
203
- ### Network Commands
204
-
205
- #### `cyberia chain deploy`
206
-
207
- Deploy a new Hyperledger Besu IBFT2 network to Kubernetes:
208
-
209
- ```bash
210
- cyberia chain deploy [options]
126
+ ### `engine-cyberia` as the sidecar-backed data layer
127
+
128
+ `engine-cyberia` is the only Cyberia service that owns content-backed data and asset metadata.
129
+
130
+ - Boot-time world configuration flows from `engine-cyberia` to `cyberia-server` over gRPC `GetFullInstance`.
131
+ - Client-facing assets, object layers, dialogues, and presentation hints flow from `engine-cyberia` to `cyberia-client` over REST.
132
+ - Simulation never migrates into the sidecar, and presentation policy never migrates out of the client.
133
+
134
+ ### Runtime / health model
135
+
136
+ Three supervised processes run in parallel, each with its own monitor and reconnect loop. Gameplay is live only when all three are healthy at once.
137
+
138
+ ```text
139
+ ┌──────────────────────────────────────────────────────────────┐
140
+ │ SUPERVISION (parallel) │
141
+ │ │
142
+ │ engine-cyberia cyberia-server cyberia-client │
143
+ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
144
+ │ │ monitor │ │ monitor │ │ monitor │ │
145
+ │ │ +reconnect │ │ +reconnect │ │ +reconnect │ │
146
+ │ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘ │
147
+ │ │ │ │ │
148
+ │ └──────────┬──────────┴──────────┬──────────┘ │
149
+ │ ▼ ▼ │
150
+ │ all three up & connected? │
151
+ └────────────────────────────┬─────────────────────────────────┘
152
+
153
+ ┌─────────────────────┼─────────────────────┐
154
+ ▼ ▼ ▼
155
+ ┌───────────┐ ┌───────────┐ ┌───────────┐
156
+ │ HEALTHY │ │ DEGRADED │ │ STANDBY │
157
+ │ all 3 up │ │ ≥1 service│ │ gameplay │
158
+ │ gameplay │ │ reconnect-│ │ paused │
159
+ │ live │ │ ing / down│ │ until all │
160
+ │ │ │ │ │ 3 healthy │
161
+ └───────────┘ └───────────┘ └───────────┘
211
162
  ```
212
163
 
213
- | Option | Default | Description |
214
- | ------------------------ | -------------------------- | ----------------------------------------- |
215
- | `--validators <n>` | `4` | Number of IBFT2 validators |
216
- | `--chain-id <id>` | `777771` | EVM chain ID |
217
- | `--block-period <s>` | `5` | IBFT2 block period in seconds |
218
- | `--epoch-length <n>` | `30000` | IBFT2 epoch length |
219
- | `--besu-image <img>` | `hyperledger/besu:24.12.1` | Besu container image |
220
- | `--node-port-rpc <port>` | `30545` | Kubernetes NodePort for JSON-RPC |
221
- | `--node-port-ws <port>` | `30546` | Kubernetes NodePort for WebSocket |
222
- | `--namespace <ns>` | `besu` | Kubernetes namespace |
223
- | `--pull-image` | — | Pull Besu images before deploying |
224
- | `--skip-generate` | — | Use existing `manifests/besu/` as-is |
225
- | `--skip-wait` | — | Skip waiting for validators to be Running |
226
-
227
- #### `cyberia chain remove`
228
-
229
- Remove the Besu network from Kubernetes:
230
-
231
- ```bash
232
- cyberia chain remove [--namespace besu] [--clean-keys] [--clean-manifests]
233
- ```
234
-
235
- #### `cyberia chain generate-manifests`
236
-
237
- Generate Kubernetes manifests without deploying:
238
-
239
- ```bash
240
- cyberia chain generate-manifests [options] # same options as deploy
241
- ```
164
+ | State | Meaning |
165
+ | ---------- | -------------------------------------------------------------------- |
166
+ | `healthy` | all three Cyberia services are up and connected |
167
+ | `degraded` | at least one service is reconnecting or unavailable |
168
+ | `standby` | gameplay is paused because the full three-service set is not healthy |
242
169
 
243
170
  ---
244
171
 
245
- ### Contract Commands
172
+ ## User commands
246
173
 
247
- #### `cyberia chain compile`
174
+ Use `underpost` for platform, infrastructure, build, and deploy. Use `cyberia` for MMO content and
175
+ extension workflows. Both share the same helpers — never duplicate config, env, or path logic.
248
176
 
249
- Compile the Solidity contracts:
177
+ ### Platform (underpost)
250
178
 
251
179
  ```bash
252
- cyberia chain compile
253
- ```
254
-
255
- #### `cyberia chain deploy-contract`
180
+ # Bootstrap a new app (local app serves on http://localhost:4001)
181
+ underpost new app-name
256
182
 
257
- Deploy `ObjectLayerToken` to a Besu network (mints 10M CKY to the coinbase address):
183
+ # Build the client bundle / static + PWA output
184
+ underpost client
185
+ npm run build # node bin client
258
186
 
259
- ```bash
260
- cyberia chain deploy-contract --network besu-k8s
187
+ # Deploy and operate
188
+ underpost deploy <deploy-id>
189
+ underpost monitor
261
190
  ```
262
191
 
263
- | Option | Default | Description |
264
- | ------------------ | ---------- | ------------------------------------------------------------ |
265
- | `--network <name>` | `besu-k8s` | Hardhat network name (`besu-ibft2`, `besu-qbft`, `besu-k8s`) |
192
+ ### Cyberia (cyberia) — `bin/cyberia.js`
266
193
 
267
- #### `cyberia chain test`
194
+ | Group | Command | Purpose |
195
+ | -------------- | -------------------------------------- | -------------------------------------------------------- |
196
+ | `ol` | `cyberia ol [item-id]` | ObjectLayer import, procedural generation, atlas/sprite |
197
+ | `instance` | `cyberia instance [instance-code]` | export / import / drop a Cyberia instance and its data |
198
+ | `client-hints` | `cyberia client-hints [instance-code]` | per-instance presentation hints (palette, camera, icons) |
199
+ | `chain` | `cyberia chain <sub>` | Hyperledger Besu + ERC-1155 ObjectLayerToken lifecycle |
200
+ | `run-workflow` | `cyberia run-workflow <name>` | named maintenance/build scripts from `scripts/` |
268
201
 
269
- Run the Hardhat contract test suite:
202
+ Common examples:
270
203
 
271
204
  ```bash
272
- cyberia chain test
273
- ```
274
-
275
- ---
276
-
277
- ### Key Management
278
-
279
- #### `cyberia chain key-gen`
280
-
281
- Generate a new secp256k1 Ethereum key pair for the coinbase deployer account:
282
-
283
- ```bash
284
- cyberia chain key-gen
285
- # Output: address + private key + key file written to engine-private/
286
- ```
287
-
288
- #### `cyberia chain set-coinbase`
289
-
290
- Set the active coinbase key used for contract deployment and minting:
291
-
292
- ```bash
293
- cyberia chain set-coinbase --private-key 0xYOUR_KEY
294
- cyberia chain set-coinbase --from-file ./engine-private/eth-networks/besu/<address>.key.json
295
- ```
296
-
297
- ---
298
-
299
- ### Token Commands
300
-
301
- #### `cyberia chain register`
302
-
303
- Register a single Object Layer item on-chain:
304
-
305
- ```bash
306
- cyberia chain register <item-id> [options]
307
- ```
308
-
309
- | Option | Default | Description |
310
- | ---------------------- | ---------- | ----------------------------------------------------- |
311
- | `--from-db` | — | Resolve canonical IPFS CID from MongoDB (recommended) |
312
- | `--metadata-cid <cid>` | `""` | Manual CID override (ignored when `--from-db` is set) |
313
- | `--supply <n>` | `1` | Initial token supply (1 = NFT, >1 = semi-fungible) |
314
- | `--network <name>` | `besu-k8s` | Hardhat network name |
315
- | `--env-path <path>` | `./.env` | Path to `.env` file |
316
- | `--mongo-host <host>` | — | MongoDB host override |
317
-
318
- ```bash
319
- # Register unique NFT item (non-fungible)
320
- cyberia chain register legendary-hatchet --from-db --supply 1
321
-
322
- # Register stackable resource (semi-fungible)
323
- cyberia chain register gold-ore --from-db --supply 1000000
324
- ```
325
-
326
- #### `cyberia chain batch-register`
327
-
328
- Register multiple items in a single batch transaction:
329
-
330
- ```bash
331
- cyberia chain batch-register --from-db --items '[{"itemId":"wood","supply":500000},{"itemId":"stone","supply":500000}]'
332
- ```
333
-
334
- #### `cyberia chain mint`
335
-
336
- Mint additional tokens for an existing token ID:
337
-
338
- ```bash
339
- cyberia chain mint --token-id 0 --to 0xABCD...1234 --amount 1000000000000000000000
340
- cyberia chain mint --token-id <tokenId> --to <address> --amount <uint256>
341
- ```
342
-
343
- #### `cyberia chain balance`
344
-
345
- Query the token balance of an address:
346
-
347
- ```bash
348
- cyberia chain balance --address 0xABCD...1234 --token-id 0
349
- ```
350
-
351
- #### `cyberia chain transfer`
352
-
353
- Transfer tokens between addresses:
354
-
355
- ```bash
356
- cyberia chain transfer --from 0x... --to 0x... --token-id 0 --amount 1000
357
- ```
358
-
359
- #### `cyberia chain burn`
360
-
361
- Burn tokens from an address:
362
-
363
- ```bash
364
- cyberia chain burn --token-id 0 --amount 500 --address 0x...
205
+ # Object layer content
206
+ cyberia ol hatchet,sword --import # import specific items
207
+ cyberia ol --import-types skin,floors # batch import by type (or: all)
208
+ cyberia ol floor-desert --generate --seed fx-42 # procedural generation
209
+ cyberia ol hatchet --to-atlas-sprite-sheet # build atlas sprite sheet
210
+ cyberia ol --drop --client-public # drop data + static asset folders
211
+
212
+ # Instance data
213
+ cyberia instance FOREST --export ./backup
214
+ cyberia instance FOREST --import ./backup
215
+ cyberia instance FOREST --drop
216
+
217
+ # Presentation hints
218
+ cyberia client-hints cyberia-main --seed-defaults
219
+
220
+ # Chain / token lifecycle
221
+ cyberia chain deploy --chain-id 777771
222
+ cyberia chain status
223
+ cyberia chain register / mint / transfer / burn / pause / unpause
224
+
225
+ # Named workflows
226
+ cyberia run-workflow import-default-items
227
+ cyberia run-workflow seed-skill-config --instance-code default
228
+ cyberia run-workflow seed-dialogues
229
+ cyberia run-workflow build-manifest
230
+ cyberia run-workflow build-server-dashboard
365
231
  ```
366
232
 
367
- #### `cyberia chain status`
368
-
369
- Query chain and contract status:
233
+ ### Run the MMO services
370
234
 
371
235
  ```bash
372
- cyberia chain status [--network besu-k8s]
373
- # Outputs: chain ID, block number, CKY total supply, deployer address, pause state
374
- ```
375
-
376
- #### `cyberia chain pause` / `cyberia chain unpause`
236
+ # engine-cyberia (Node.js data/content services)
237
+ npm start # node src/server
377
238
 
378
- Emergency transfer freeze / resume (owner only):
239
+ # cyberia-server (Go authoritative simulation)
240
+ cd cyberia-server && go run main.go # dev
241
+ cd cyberia-server && go build -o cyberia-server . && ./cyberia-server
379
242
 
380
- ```bash
381
- cyberia chain pause [--network besu-k8s]
382
- cyberia chain unpause [--network besu-k8s]
243
+ # cyberia-client (C / WASM presentation)
244
+ cd cyberia-client && make -f Web.mk clean && make -f Web.mk web
245
+ cd cyberia-client && make -f Web.mk serve-development # serves on :8082
383
246
  ```
384
247
 
385
248
  ---
386
249
 
387
- ## `cyberia run-workflow` — Operational Scripts
388
-
389
- Pre-built operational workflows for seeding and maintenance:
390
-
391
- | Subcommand | Description |
392
- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
393
- | `import-default-items` | Import the canonical default item set (`DefaultCyberiaItems`) into MongoDB + IPFS, then seed skill config and dialogues |
394
- | `seed-skill-config` | Upsert `DefaultSkillConfig` into `CyberiaInstanceConf` for the target instance |
395
- | `seed-dialogues` | Upsert `DefaultCyberiaDialogues` (NPC dialogue lines) into the `cyberia-dialogue` collection |
396
- | `generate-semantic-examples` | Generate procedural examples for skin prefixes (`skin-*`); floor and resource generation is available but commented out by default |
397
- | `build-manifest` | Build Kubernetes Deployment + Service YAML manifests for mmo-client and mmo-server instances (kubeadm + kind variants) |
398
-
399
- ```bash
400
- cyberia run-workflow import-default-items --env-path ./engine-private/conf/dd-cyberia/.env.development
401
- cyberia run-workflow seed-skill-config --env-path ./engine-private/conf/dd-cyberia/.env.development
402
- cyberia run-workflow build-manifest
403
- ```
404
-
405
- ---
406
-
407
- ## Environment Variables
408
-
409
- The CLI respects the following environment variables (typically loaded from an `--env-path` file):
250
+ ## Operational guardrails
410
251
 
411
- | Variable | Description |
412
- | --------------------- | ---------------------------------------------------------------- |
413
- | `DEFAULT_DEPLOY_ID` | Engine deployment ID resolves to `engine-private/conf/{id}/` |
414
- | `DEFAULT_DEPLOY_HOST` | Deploy host (used to index the conf object) |
415
- | `DEFAULT_DEPLOY_PATH` | Deploy path (used to index the conf object) |
416
- | `MONGODB_URI` | MongoDB connection string (loaded from conf if not set directly) |
417
- | `IPFS_API_URL` | IPFS API URL for pinning (e.g. `http://localhost:5001`) |
252
+ - Prefer one source of truth for config, deploy IDs, runtime selection, startup behavior, and generated assets.
253
+ - Reuse existing helpers and conventions instead of creating parallel implementations.
254
+ - Do not duplicate parsing, env resolution, or path normalization logic across modules.
255
+ - Treat generated artifacts (`sw.js`, static pages, atlases, README, manifests) as outputs only.
256
+ - Host-level changes must be idempotent, reversible, and explicit; validate before mutating; keep
257
+ orchestration scripts safe to rerun.
258
+ - `engine-private/` is a private external dependency. Reference it only as private input; never assume
259
+ its contents exist locally.