castle-web-cli 0.4.237 → 0.4.239
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/dist/bundle.d.ts +24 -0
- package/dist/bundle.js +447 -4
- package/dist/bundleLatin1.d.ts +6 -0
- package/dist/bundleLatin1.js +333 -0
- package/dist/castle-host/host.d.ts +10 -1
- package/dist/castle-host/host.js +133 -9
- package/dist/castleJson.d.ts +2 -0
- package/dist/castleJson.js +1 -0
- package/dist/deckExports.d.ts +35 -0
- package/dist/deckExports.js +365 -0
- package/dist/importCheckHook.d.ts +1 -0
- package/dist/importCheckHook.js +1 -1
- package/dist/index.js +21 -0
- package/dist/init.js +2 -1
- package/dist/multiplayerDoc.d.ts +1 -1
- package/dist/multiplayerDoc.js +9 -0
- package/dist/platformDoc.js +2 -1
- package/dist/playPagePolicy.d.ts +1 -0
- package/dist/playPagePolicy.js +8 -3
- package/dist/roomLogs.d.ts +39 -0
- package/dist/roomLogs.js +166 -0
- package/dist/save-deck.js +4 -0
- package/kits/base/CLAUDE.md +1 -0
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +113 -2
- package/kits/base/sdk/castle.d.ts +6 -2
- package/kits/base/sdk/castle.js +2 -0
- package/kits/base/sdk/commands.d.ts +56 -1
- package/kits/base/sdk/commands.js +29 -1
- package/kits/base/sdk/hub.d.ts +17 -0
- package/kits/base/sdk/hub.js +33 -9
- package/kits/base/sdk/localCache.d.ts +27 -0
- package/kits/base/sdk/localCache.js +115 -0
- package/kits/base/sdk/localCacheStore.d.ts +15 -0
- package/kits/base/sdk/localCacheStore.js +358 -0
- package/kits/base/sdk/multiplayer.js +30 -0
- package/kits/base/sdk/rooms.d.ts +11 -0
- package/kits/base/sdk/rooms.js +22 -0
- package/kits/base/sdk/store.d.ts +8 -2
- package/kits/base/sdk/store.js +5 -1
- package/kits/base/sdk/transport.d.ts +1 -0
- package/kits/base/sdk/transport.js +4 -5
- package/kits/hub-game/CLAUDE.md +22 -2
- package/kits/hub-game/castle.json +8 -5
- package/kits/hub-game/code/client/act.js +66 -91
- package/kits/hub-game/code/client/actCore.js +134 -0
- package/kits/hub-game/code/client/car.js +35 -0
- package/kits/hub-game/code/client/chrome.js +208 -381
- package/kits/hub-game/code/client/crowdNames.js +2 -2
- package/kits/hub-game/code/client/emoteWheel.js +109 -0
- package/kits/hub-game/code/client/hats.js +2 -0
- package/kits/hub-game/code/client/hookLayer.js +99 -48
- package/kits/hub-game/code/client/hostGo.js +77 -0
- package/kits/hub-game/code/client/hubControls.js +125 -0
- package/kits/hub-game/code/client/hubEntry.js +187 -0
- package/kits/hub-game/code/client/hudSurface.js +148 -0
- package/kits/hub-game/code/client/hudTree.js +96 -0
- package/kits/hub-game/code/client/idle.js +59 -13
- package/kits/hub-game/code/client/invites.js +13 -4
- package/kits/hub-game/code/client/menuIcons.js +8 -0
- package/kits/hub-game/code/client/menuRows.js +8 -2
- package/kits/hub-game/code/client/noTrips.js +38 -0
- package/kits/hub-game/code/client/qualityEntry.js +6 -1
- package/kits/hub-game/code/client/rehello.js +3 -1
- package/kits/hub-game/code/client/riders.js +26 -0
- package/kits/hub-game/code/client/role.js +79 -0
- package/kits/hub-game/code/client/safeLayout.js +32 -3
- package/kits/hub-game/code/client/sound.js +10 -3
- package/kits/hub-game/code/client/soundscape.js +2 -2
- package/kits/hub-game/code/client/soundscapeAmbience.js +38 -8
- package/kits/hub-game/code/client/soundscapeBaked.js +24 -5
- package/kits/hub-game/code/client/soundscapeCues.js +2 -1
- package/kits/hub-game/code/client/state.js +19 -0
- package/kits/hub-game/code/client/stuck.js +2 -1
- package/kits/hub-game/code/client/talkSurface.js +178 -0
- package/kits/hub-game/code/client/talkTree.js +238 -0
- package/kits/hub-game/code/client/tiers.js +8 -5
- package/kits/hub-game/code/client/uiDom.js +600 -0
- package/kits/hub-game/code/client/uiTree.js +359 -0
- package/kits/hub-game/code/client/vehicle.js +156 -0
- package/kits/hub-game/code/client/wear.js +27 -5
- package/kits/hub-game/code/client/worldLabels.js +13 -3
- package/kits/hub-game/code/client/yours.js +10 -3
- package/kits/hub-game/code/server/actors.js +4 -3
- package/kits/hub-game/code/server/analytics.js +61 -18
- package/kits/hub-game/code/server/decor.js +56 -16
- package/kits/hub-game/code/server/doorAnalytics.js +2 -5
- package/kits/hub-game/code/server/hub.js +261 -46
- package/kits/hub-game/code/server/idle.js +118 -5
- package/kits/hub-game/code/server/loadAbandon.js +2 -5
- package/kits/hub-game/code/server/manifest.js +46 -4
- package/kits/hub-game/code/server/npcs.js +4 -2
- package/kits/hub-game/code/server/players.js +3 -0
- package/kits/hub-game/code/server/role.js +142 -0
- package/kits/hub-game/code/server/standing.js +6 -4
- package/kits/hub-game/code/server/trackQueue.js +29 -0
- package/kits/hub-game/code/server/vehicle.js +126 -0
- package/kits/hub-game/code/shared/car.js +52 -0
- package/kits/hub-game/code/shared/deckFlags.js +34 -0
- package/kits/hub-game/code/shared/deviceClass.js +39 -0
- package/kits/hub-game/code/shared/expression.js +9 -0
- package/kits/hub-game/code/systems/hub.js +281 -86
- package/kits/hub-game/docs/analytics.md +15 -3
- package/kits/hub-game/docs/contract.md +352 -14
- package/kits/hub-game/docs/vehicle-preset.md +132 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +89 -0
- package/kits/hub-game/models/hats/chef-toque.pxmodel +60 -0
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +87 -0
- package/kits/hub-game/models/hats/hard-hat.pxmodel +71 -0
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +61 -0
- package/kits/hub-game/models/hats/police-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +52 -0
- package/kits/hub-game/models/role/square/top-apron.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-cardigan.pxmodel +141 -0
- package/kits/hub-game/models/role/square/top-coat.pxmodel +157 -0
- package/kits/hub-game/models/role/square/top-scrubs.pxmodel +93 -0
- package/kits/hub-game/models/role/square/top-tabard.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-vest.pxmodel +109 -0
- package/kits/hub-game/models/role/tool-bag.pxmodel +75 -0
- package/kits/hub-game/models/role/tool-bell.pxmodel +71 -0
- package/kits/hub-game/models/role/tool-hose.pxmodel +60 -0
- package/kits/hub-game/models/role/tool-parcel.pxmodel +61 -0
- package/kits/hub-game/models/role/tool-torch.pxmodel +55 -0
- package/kits/hub-game/models/role/tool-tray.pxmodel +75 -0
- package/kits/hub-game/models/role/top-apron.pxmodel +70 -0
- package/kits/hub-game/models/role/top-cardigan.pxmodel +102 -0
- package/kits/hub-game/models/role/top-coat.pxmodel +79 -0
- package/kits/hub-game/models/role/top-scrubs.pxmodel +54 -0
- package/kits/hub-game/models/role/top-tabard.pxmodel +70 -0
- package/kits/hub-game/models/role/top-vest.pxmodel +70 -0
- package/kits/hub-game/package-lock.json +1 -1
- package/kits/hub-game/package.json +1 -1
- package/kits/hub-game/scripts/check.mjs +7 -4
- package/kits/hub-game/scripts/fixtures/car-vectors.json +279 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +2 -1
- package/kits/hub-game/scripts/fixtures/hud-surface.json +670 -0
- package/kits/hub-game/scripts/fixtures/talk-surface.json +3930 -0
- package/kits/hub-game/scripts/gen-hats.mjs +46 -2
- package/kits/hub-game/scripts/gen-role.mjs +80 -0
- package/kits/hub-game/scripts/test-act-core.mjs +167 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +34 -0
- package/kits/hub-game/scripts/test-actors.mjs +48 -0
- package/kits/hub-game/scripts/test-analytics.mjs +100 -6
- package/kits/hub-game/scripts/test-apply-deck.mjs +122 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +3 -1
- package/kits/hub-game/scripts/test-ballot.mjs +2 -0
- package/kits/hub-game/scripts/test-car.mjs +43 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +2 -1
- package/kits/hub-game/scripts/test-decor.mjs +77 -0
- package/kits/hub-game/scripts/test-device-class.mjs +83 -0
- package/kits/hub-game/scripts/test-door-analytics.mjs +1 -1
- package/kits/hub-game/scripts/test-emote-wheel.mjs +374 -0
- package/kits/hub-game/scripts/test-hats.mjs +5 -4
- package/kits/hub-game/scripts/test-host-go.mjs +265 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +108 -0
- package/kits/hub-game/scripts/test-hub-entry.mjs +531 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +103 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +20 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +12 -2
- package/kits/hub-game/scripts/test-hud-rate.mjs +6 -2
- package/kits/hub-game/scripts/test-hud-surface.mjs +272 -0
- package/kits/hub-game/scripts/test-idle.mjs +347 -1
- package/kits/hub-game/scripts/test-interest-cells.mjs +8 -1
- package/kits/hub-game/scripts/test-invites-client.mjs +42 -1
- package/kits/hub-game/scripts/test-load-abandon.mjs +2 -2
- package/kits/hub-game/scripts/test-manifest.mjs +30 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +1 -1
- package/kits/hub-game/scripts/test-no-trips.mjs +42 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-quality.mjs +13 -0
- package/kits/hub-game/scripts/test-rehello.mjs +258 -3
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +203 -0
- package/kits/hub-game/scripts/test-resync.mjs +196 -0
- package/kits/hub-game/scripts/test-role-client.mjs +427 -0
- package/kits/hub-game/scripts/test-role.mjs +350 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +50 -1
- package/kits/hub-game/scripts/test-soundscape.mjs +124 -7
- package/kits/hub-game/scripts/test-standing.mjs +15 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +296 -0
- package/kits/hub-game/scripts/test-tiers.mjs +13 -0
- package/kits/hub-game/scripts/test-track-queue.mjs +64 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +96 -0
- package/kits/hub-game/scripts/test-ui-tree.mjs +711 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +168 -0
- package/kits/hub-game/scripts/test-vehicle.mjs +135 -0
- package/kits/hub-game/scripts/test-world-labels.mjs +40 -0
- package/kits/hub-game/scripts/test-yours.mjs +33 -0
- package/kits/hub-game/tools/hubScene/export.mjs +613 -0
- package/kits/hub-game/tools/hubScene/hubdata.mjs +921 -0
- package/kits/hub-game/tools/hubScene/merge-root.mjs +39 -0
- package/kits/hub-game/tools/hubScene/nodeworld.mjs +227 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +810 -0
- package/kits/hub-game/tools/hubScene/test/fixture.json +637 -0
- package/kits/hub-game/tools/hubScene/test/paint-export.mjs +40 -0
- package/kits/hub-game/tools/hubScene/test/upload.test.mjs +655 -0
- package/kits/hub-game/tools/hubScene/upload.mjs +636 -0
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +301 -0
- package/kits/multiplayer-3d/castle.json +4 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +30 -2
- package/kits/multiplayer-3d/code/client/steer.js +3 -1
- package/kits/multiplayer-3d/code/systems/multiplayer.js +30 -2
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +74 -2
- package/kits/physics-3d/CLAUDE.md +1 -1
- package/kits/physics-3d/behaviors/Player.jsx +37 -27
- package/kits/physics-3d/castle.json +2 -2
- package/kits/physics-3d/docs/engine-geometry-memory.md +23 -0
- package/kits/physics-3d/engine3d/memoryprofile.js +17 -0
- package/kits/physics-3d/engine3d/playerRun.js +6 -1
- package/kits/physics-3d/engine3d/pxmodel.js +6 -1
- package/kits/physics-3d/engine3d/world3d.js +6 -3
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/play/behaviors/Player.js +40 -28
- package/kits/physics-3d/scripts/test-memory-profile.mjs +237 -0
- package/kits/physics-3d/systems/physics3d.js +5 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/messages.js +5 -0
- package/kits/real-time/code/server/session.js +28 -1
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +5 -4
- package/vendor/three/LICENSE +21 -0
- package/vendor/three/build/three.core.js +58773 -0
- package/vendor/three/build/three.module.js +18251 -0
- package/vendor/three/examples/jsm/controls/OrbitControls.js +1860 -0
- package/vendor/three/examples/jsm/controls/TransformControls.js +1918 -0
- package/vendor/three/examples/jsm/exporters/GLTFExporter.js +3595 -0
- package/vendor/three/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
- package/vendor/three/examples/jsm/math/MeshSurfaceSampler.js +315 -0
- package/vendor/three/examples/jsm/postprocessing/EffectComposer.js +363 -0
- package/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
- package/vendor/three/examples/jsm/postprocessing/OutputPass.js +139 -0
- package/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
- package/vendor/three/examples/jsm/postprocessing/RenderPass.js +183 -0
- package/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
- package/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
- package/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
- package/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
- package/vendor/three/package.json +134 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// Running every import's save-time exporters (castle.json `exports`, see
|
|
2
|
+
// castleJson.ts for the contract): derived artifacts a kit writes for the decks
|
|
3
|
+
// built on it, beside the save rather than inside it.
|
|
4
|
+
//
|
|
5
|
+
// The CLI knows nothing about what an exporter makes. An import names scripts
|
|
6
|
+
// of its own by export name; the CLI runs each in a child `node`, hands it the
|
|
7
|
+
// deck, an output folder of its own and a cache folder shared across decks, and
|
|
8
|
+
// reports the JSON summary it prints. Nothing it writes is published. The
|
|
9
|
+
// exporter writes into a fresh stage under the cache root; the CLI alone moves
|
|
10
|
+
// it into `<deck>/.castle/exports/<name>/`, through folders it proved are the
|
|
11
|
+
// deck's own. Cache garbage collection is out of scope.
|
|
12
|
+
//
|
|
13
|
+
// `castle-web export` runs them on demand. `save-deck` runs them after a
|
|
14
|
+
// successful save only when CASTLE_SAVE_EXPORTS=1: off by default, and a
|
|
15
|
+
// failure there is a warning -- an exporter can never cost a save.
|
|
16
|
+
//
|
|
17
|
+
// An exporter runs only from the kits this CLI ships (a builtin pin, or a
|
|
18
|
+
// shipped kit checked as itself), its entry point proven by real path to be one
|
|
19
|
+
// of their files. A fetched import's exporters never run.
|
|
20
|
+
import { spawn } from 'child_process';
|
|
21
|
+
import * as fs from 'fs';
|
|
22
|
+
import * as os from 'os';
|
|
23
|
+
import * as path from 'path';
|
|
24
|
+
import { IMPORTS_DIR, readCastleJson } from './castleJson.js';
|
|
25
|
+
import { isShippedKitDir } from './importCheckHook.js';
|
|
26
|
+
import { outputLines, resolveFileInside } from './importUpdateHook.js';
|
|
27
|
+
import { getKitsDir, getPackageRoot } from './localPaths.js';
|
|
28
|
+
/** The env var that turns exporters on for `save-deck`. */
|
|
29
|
+
export const SAVE_EXPORTS_ENV = 'CASTLE_SAVE_EXPORTS';
|
|
30
|
+
// An export name is a folder name under .castle/exports/ and the cache.
|
|
31
|
+
const EXPORT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
32
|
+
const MAX_EXPORT_OUTPUT = 16 * 1024 * 1024;
|
|
33
|
+
// How long an exporter that ignores SIGTERM gets before its whole process group
|
|
34
|
+
// is killed outright.
|
|
35
|
+
function killGraceMs() {
|
|
36
|
+
const raw = Number(process.env.CASTLE_EXPORT_KILL_GRACE_MS);
|
|
37
|
+
return Number.isFinite(raw) && raw >= 0 ? raw : 5_000;
|
|
38
|
+
}
|
|
39
|
+
// Exporters build whole worlds; a wall clock still keeps one from hanging a
|
|
40
|
+
// save forever. The env override is for tests and unusually large decks.
|
|
41
|
+
function exportTimeoutMs() {
|
|
42
|
+
const raw = Number(process.env.CASTLE_EXPORT_TIMEOUT_MS);
|
|
43
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 600_000;
|
|
44
|
+
}
|
|
45
|
+
/** `~/.castle/export-cache/<name>/`, shared by every deck on this machine. */
|
|
46
|
+
export function exportCacheRoot() {
|
|
47
|
+
return path.resolve(process.env.CASTLE_EXPORT_CACHE_ROOT ?? path.join(os.homedir(), '.castle', 'export-cache'));
|
|
48
|
+
}
|
|
49
|
+
export function exportCacheDir(name) {
|
|
50
|
+
return path.join(exportCacheRoot(), name);
|
|
51
|
+
}
|
|
52
|
+
// A real folder (made if missing) whose canonical path is `realParent/name`:
|
|
53
|
+
// never a symlink, never one that resolves elsewhere. Returns that canonical path.
|
|
54
|
+
function provenDir(parent, realParent, name) {
|
|
55
|
+
const dir = path.join(parent, name);
|
|
56
|
+
const real = path.join(realParent, name);
|
|
57
|
+
if (!lexists(dir))
|
|
58
|
+
fs.mkdirSync(dir);
|
|
59
|
+
const st = fs.lstatSync(dir);
|
|
60
|
+
if (st.isSymbolicLink() || !st.isDirectory())
|
|
61
|
+
throw new Error(`${dir} is a symlink or not a folder`);
|
|
62
|
+
if (fs.realpathSync(dir) !== real)
|
|
63
|
+
throw new Error(`${dir} resolves outside ${realParent}`);
|
|
64
|
+
return real;
|
|
65
|
+
}
|
|
66
|
+
function lexists(p) {
|
|
67
|
+
try {
|
|
68
|
+
fs.lstatSync(p);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** `<deck>/.castle/exports`, proven a real folder of the canonical deck. */
|
|
76
|
+
function deckExportsDir(deckDir) {
|
|
77
|
+
const realDeck = fs.realpathSync(deckDir);
|
|
78
|
+
const castle = provenDir(deckDir, realDeck, '.castle');
|
|
79
|
+
return provenDir(castle, castle, 'exports');
|
|
80
|
+
}
|
|
81
|
+
// Moves the exporter's finished stage into `<exports>/<name>`: the old output is
|
|
82
|
+
// renamed aside first, the stage renamed in (across filesystems, copied into
|
|
83
|
+
// the exports folder and renamed from there), and the old one removed only once
|
|
84
|
+
// it is proven a real folder inside the exports folder.
|
|
85
|
+
function installStage(stage, exportsDir, name) {
|
|
86
|
+
const final = path.join(exportsDir, name);
|
|
87
|
+
const tag = `${process.pid}-${Date.now()}`;
|
|
88
|
+
let old = null;
|
|
89
|
+
if (lexists(final)) {
|
|
90
|
+
const st = fs.lstatSync(final);
|
|
91
|
+
if (st.isSymbolicLink() || !st.isDirectory())
|
|
92
|
+
throw new Error(`${final} is a symlink or not a folder`);
|
|
93
|
+
old = path.join(exportsDir, `.old-${name}-${tag}`);
|
|
94
|
+
fs.renameSync(final, old);
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
try {
|
|
98
|
+
fs.renameSync(stage, final);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
if (e.code !== 'EXDEV')
|
|
102
|
+
throw e;
|
|
103
|
+
const incoming = path.join(exportsDir, `.incoming-${name}-${tag}`);
|
|
104
|
+
fs.cpSync(stage, incoming, { recursive: true });
|
|
105
|
+
fs.renameSync(incoming, final);
|
|
106
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
if (old)
|
|
111
|
+
fs.renameSync(old, final);
|
|
112
|
+
throw e;
|
|
113
|
+
}
|
|
114
|
+
if (old && !fs.lstatSync(old).isSymbolicLink() && path.dirname(fs.realpathSync(old)) === exportsDir) {
|
|
115
|
+
fs.rmSync(old, { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function declaredExports(dir) {
|
|
119
|
+
const declared = readCastleJson(dir)?.exports;
|
|
120
|
+
if (!declared || typeof declared !== 'object' || Array.isArray(declared))
|
|
121
|
+
return {};
|
|
122
|
+
return Object.fromEntries(Object.entries(declared).filter(([, v]) => typeof v === 'string' && v.trim()));
|
|
123
|
+
}
|
|
124
|
+
// The CLI's own copy of a builtin pin's kit, or null: exporters run only from
|
|
125
|
+
// the kits this CLI ships, never from an imports/ copy of anything.
|
|
126
|
+
function shippedKitOf(pin) {
|
|
127
|
+
if (pin.source !== 'builtin')
|
|
128
|
+
return null;
|
|
129
|
+
const kit = typeof pin.kit === 'string' ? pin.kit : '';
|
|
130
|
+
const kits = path.resolve(getKitsDir());
|
|
131
|
+
const kitDir = path.join(kits, kit);
|
|
132
|
+
if (!kit || path.dirname(kitDir) !== kits || !fs.existsSync(path.join(kitDir, 'castle.json')))
|
|
133
|
+
return null;
|
|
134
|
+
return kitDir;
|
|
135
|
+
}
|
|
136
|
+
// The entry point's real path, when it lies under the real shipped kits folder:
|
|
137
|
+
// a symlink leading anywhere else is not one of the CLI's files.
|
|
138
|
+
function shippedModule(dir, declared) {
|
|
139
|
+
const lexical = resolveFileInside(dir, declared);
|
|
140
|
+
if (!lexical)
|
|
141
|
+
return null;
|
|
142
|
+
const real = fs.realpathSync(lexical);
|
|
143
|
+
const kits = fs.realpathSync(getKitsDir());
|
|
144
|
+
return real.startsWith(kits + path.sep) ? real : null;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Every exporter that applies to this deck and may run here: each import's, in
|
|
148
|
+
* pin order, then the deck's own (only for a kit this CLI ships, as with
|
|
149
|
+
* `onCheck`). The first to claim a name keeps it.
|
|
150
|
+
*/
|
|
151
|
+
export function exportTargets(deckDir, log) {
|
|
152
|
+
const config = readCastleJson(deckDir);
|
|
153
|
+
const sources = [];
|
|
154
|
+
for (const [alias, pin] of Object.entries(config?.imports ?? {})) {
|
|
155
|
+
if (!pin)
|
|
156
|
+
continue;
|
|
157
|
+
const dir = shippedKitOf(pin);
|
|
158
|
+
if (dir)
|
|
159
|
+
sources.push({ alias, dir });
|
|
160
|
+
else if (Object.keys(declaredExports(path.join(deckDir, IMPORTS_DIR, alias))).length > 0) {
|
|
161
|
+
log(`Warning: ${alias} declares exporters, which run only from a kit this CLI ships -- skipped.`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (isShippedKitDir(deckDir))
|
|
165
|
+
sources.push({ alias: 'self', dir: deckDir });
|
|
166
|
+
const targets = [];
|
|
167
|
+
const taken = new Set();
|
|
168
|
+
for (const { alias, dir } of sources) {
|
|
169
|
+
const declared = declaredExports(dir);
|
|
170
|
+
if (Object.keys(declared).length === 0)
|
|
171
|
+
continue;
|
|
172
|
+
for (const [name, declaredPath] of Object.entries(declared)) {
|
|
173
|
+
if (!EXPORT_NAME.test(name)) {
|
|
174
|
+
log(`Warning: ${alias} declares an export named ${JSON.stringify(name)}, which is not a usable name -- skipped.`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (taken.has(name)) {
|
|
178
|
+
log(`Warning: ${alias} declares export "${name}", which another import already declares -- skipped.`);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const modulePath = shippedModule(dir, declaredPath);
|
|
182
|
+
if (!modulePath) {
|
|
183
|
+
log(`Warning: ${alias} declares export "${name}" at "${declaredPath}", which is not a file of the kits this CLI ships -- skipped.`);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
taken.add(name);
|
|
187
|
+
targets.push({ alias, name, modulePath, outDir: path.join(deckDir, '.castle', 'exports', name), cacheDir: exportCacheDir(name) });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return targets;
|
|
191
|
+
}
|
|
192
|
+
// The last stdout line that parses as JSON: an exporter's summary.
|
|
193
|
+
function lastJson(stdout) {
|
|
194
|
+
for (const line of outputLines(stdout).reverse()) {
|
|
195
|
+
if (!line.startsWith('{') && !line.startsWith('['))
|
|
196
|
+
continue;
|
|
197
|
+
try {
|
|
198
|
+
return JSON.parse(line);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// not the summary
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
// The exporter in a process group of its own, so a timeout reaches whatever it
|
|
207
|
+
// started too: SIGTERM to the group, then SIGKILL once the grace period is up.
|
|
208
|
+
// Settles when the group's leader exits (or on the SIGKILL), never later.
|
|
209
|
+
// Out of process: cancels nothing in the save that ran before it.
|
|
210
|
+
function runChild(args, cwd, env) {
|
|
211
|
+
return new Promise((resolve) => {
|
|
212
|
+
const child = spawn(process.execPath, args, { cwd, env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
213
|
+
let stdout = '';
|
|
214
|
+
let stderr = '';
|
|
215
|
+
let timedOut = false;
|
|
216
|
+
let settled = false;
|
|
217
|
+
const take = (prev, chunk) => (prev.length >= MAX_EXPORT_OUTPUT ? prev : prev + chunk.toString('utf8'));
|
|
218
|
+
child.stdout.on('data', (c) => { stdout = take(stdout, c); });
|
|
219
|
+
child.stderr.on('data', (c) => { stderr = take(stderr, c); });
|
|
220
|
+
const signalGroup = (signal) => {
|
|
221
|
+
try {
|
|
222
|
+
if (child.pid)
|
|
223
|
+
process.kill(-child.pid, signal);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// the group is already gone
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
let killTimer;
|
|
230
|
+
const finish = (code) => {
|
|
231
|
+
if (settled)
|
|
232
|
+
return;
|
|
233
|
+
settled = true;
|
|
234
|
+
clearTimeout(termTimer);
|
|
235
|
+
clearTimeout(killTimer);
|
|
236
|
+
// Anything the exporter left running in its group goes with it.
|
|
237
|
+
signalGroup('SIGKILL');
|
|
238
|
+
resolve({ code, stdout, stderr, timedOut });
|
|
239
|
+
};
|
|
240
|
+
const termTimer = setTimeout(() => {
|
|
241
|
+
timedOut = true;
|
|
242
|
+
signalGroup('SIGTERM');
|
|
243
|
+
killTimer = setTimeout(() => {
|
|
244
|
+
signalGroup('SIGKILL');
|
|
245
|
+
finish(null);
|
|
246
|
+
}, killGraceMs());
|
|
247
|
+
}, exportTimeoutMs());
|
|
248
|
+
child.on('error', (e) => {
|
|
249
|
+
stderr += String(e);
|
|
250
|
+
finish(null);
|
|
251
|
+
});
|
|
252
|
+
// Output can still be in the pipes when the leader exits: wait for them to
|
|
253
|
+
// close, but not on a grandchild that kept them open.
|
|
254
|
+
child.on('exit', (code) => {
|
|
255
|
+
child.on('close', () => finish(code));
|
|
256
|
+
setTimeout(() => finish(code), 1_000).unref();
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
async function runOne(deckDir, target, log) {
|
|
261
|
+
const refuse = (error) => {
|
|
262
|
+
log(`${target.alias} export ${target.name} ${error}`);
|
|
263
|
+
return { alias: target.alias, name: target.name, ok: false, summary: null, error };
|
|
264
|
+
};
|
|
265
|
+
// The deck side is proven before anything runs; the exporter itself writes
|
|
266
|
+
// only into a fresh stage under the cache root and into the cache.
|
|
267
|
+
let exportsDir;
|
|
268
|
+
let cacheDir;
|
|
269
|
+
let stage;
|
|
270
|
+
try {
|
|
271
|
+
exportsDir = deckExportsDir(deckDir);
|
|
272
|
+
const prev = path.join(exportsDir, target.name);
|
|
273
|
+
if (lexists(prev) && (fs.lstatSync(prev).isSymbolicLink() || !fs.lstatSync(prev).isDirectory())) {
|
|
274
|
+
throw new Error(`${prev} is a symlink or not a folder`);
|
|
275
|
+
}
|
|
276
|
+
const root = exportCacheRoot();
|
|
277
|
+
fs.mkdirSync(root, { recursive: true });
|
|
278
|
+
cacheDir = provenDir(root, fs.realpathSync(root), target.name);
|
|
279
|
+
stage = fs.mkdtempSync(path.join(fs.realpathSync(root), `.stage-${target.name}-`));
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
return refuse(`refused its output folders: ${e instanceof Error ? e.message : String(e)}`);
|
|
283
|
+
}
|
|
284
|
+
const prevDir = path.join(exportsDir, target.name);
|
|
285
|
+
const { getCliVersion } = await import('./init.js');
|
|
286
|
+
const args = [target.modulePath, '--deck', deckDir, '--stage', stage, '--cache', cacheDir];
|
|
287
|
+
const env = {
|
|
288
|
+
...process.env,
|
|
289
|
+
CASTLE_EXPORT_NAME: target.name,
|
|
290
|
+
CASTLE_EXPORT_DECK_DIR: deckDir,
|
|
291
|
+
CASTLE_EXPORT_STAGE_DIR: stage,
|
|
292
|
+
CASTLE_EXPORT_CACHE_DIR: cacheDir,
|
|
293
|
+
CASTLE_EXPORT_PREV_DIR: lexists(prevDir) ? prevDir : '',
|
|
294
|
+
// The only kit code an exporter may load: this CLI's own kits.
|
|
295
|
+
CASTLE_EXPORT_SHIPPED_KITS: path.resolve(getKitsDir()),
|
|
296
|
+
// The kits' `three`, as this CLI ships it (../scripts/vendor-three.mjs), so an exporter never
|
|
297
|
+
// loads a deck's node_modules. Absent in a checkout that has not built the CLI.
|
|
298
|
+
CASTLE_EXPORT_THREE_DIR: fs.existsSync(path.join(getPackageRoot(), 'vendor/three/build/three.module.js')) ? path.join(getPackageRoot(), 'vendor/three') : '',
|
|
299
|
+
CASTLE_EXPORT_CLI_VERSION: getCliVersion(),
|
|
300
|
+
};
|
|
301
|
+
const result = await runChild(args, deckDir, env);
|
|
302
|
+
const summary = lastJson(result.stdout);
|
|
303
|
+
if (!result.timedOut && result.code === 0) {
|
|
304
|
+
try {
|
|
305
|
+
installStage(stage, deckExportsDir(deckDir), target.name);
|
|
306
|
+
return { alias: target.alias, name: target.name, ok: true, summary };
|
|
307
|
+
}
|
|
308
|
+
catch (e) {
|
|
309
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
310
|
+
return refuse(`could not be put in place: ${e instanceof Error ? e.message : String(e)}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
fs.rmSync(stage, { recursive: true, force: true });
|
|
314
|
+
const error = result.timedOut
|
|
315
|
+
? `it did not finish in ${exportTimeoutMs()}ms and was stopped`
|
|
316
|
+
: outputLines(result.stderr).slice(-8).join('\n') || `it exited with code ${result.code}`;
|
|
317
|
+
log(`${target.alias} export ${target.name} failed: ${error}`);
|
|
318
|
+
return { alias: target.alias, name: target.name, ok: false, summary, error };
|
|
319
|
+
}
|
|
320
|
+
/** Run every applicable exporter, one at a time. */
|
|
321
|
+
export async function runDeckExports(deckDir, log = (message) => console.log(message)) {
|
|
322
|
+
const outcomes = [];
|
|
323
|
+
for (const target of exportTargets(deckDir, log)) {
|
|
324
|
+
outcomes.push(await runOne(deckDir, target, log));
|
|
325
|
+
}
|
|
326
|
+
return outcomes;
|
|
327
|
+
}
|
|
328
|
+
/** `castle-web export [dir]`: prints each summary; exits 1 when one failed. */
|
|
329
|
+
export async function exportCommand(dir) {
|
|
330
|
+
const deckDir = path.resolve(dir);
|
|
331
|
+
if (!fs.existsSync(path.join(deckDir, 'castle.json'))) {
|
|
332
|
+
console.error(`No castle.json in ${deckDir} -- is this a deck?`);
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
const outcomes = await runDeckExports(deckDir);
|
|
336
|
+
if (outcomes.length === 0) {
|
|
337
|
+
console.log('Nothing to export: no import of this deck declares an exporter.');
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
for (const o of outcomes) {
|
|
341
|
+
console.log(`${o.ok ? 'Exported' : 'FAILED'} ${o.name} (${o.alias}): ${JSON.stringify(o.summary)}`);
|
|
342
|
+
}
|
|
343
|
+
if (outcomes.some((o) => !o.ok))
|
|
344
|
+
process.exit(1);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* After a successful save, under CASTLE_SAVE_EXPORTS=1 only. Never throws:
|
|
348
|
+
* whatever an exporter does, the save already happened and stands.
|
|
349
|
+
*/
|
|
350
|
+
export async function runSaveExports(deckDir) {
|
|
351
|
+
if (process.env[SAVE_EXPORTS_ENV] !== '1')
|
|
352
|
+
return;
|
|
353
|
+
try {
|
|
354
|
+
const outcomes = await runDeckExports(deckDir, (message) => console.warn(message));
|
|
355
|
+
for (const o of outcomes) {
|
|
356
|
+
if (o.ok)
|
|
357
|
+
console.log(`Exported ${o.name} (${o.alias}).`);
|
|
358
|
+
else
|
|
359
|
+
console.warn(`Warning: export ${o.name} (${o.alias}) failed; the save is unaffected.`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
catch (e) {
|
|
363
|
+
console.warn(`Warning: exporters did not run (${e instanceof Error ? e.message : String(e)}); the save is unaffected.`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
@@ -18,6 +18,7 @@ export interface CheckTarget {
|
|
|
18
18
|
/** The import's pin, or null for the deck's own check. */
|
|
19
19
|
pin: DeckImport | null;
|
|
20
20
|
}
|
|
21
|
+
export declare function isShippedKitDir(dir: string): boolean;
|
|
21
22
|
/**
|
|
22
23
|
* Run every applicable `onCheck`, one at a time, and collect what they found.
|
|
23
24
|
* Warnings are logged here; errors are returned for the caller to refuse on --
|
package/dist/importCheckHook.js
CHANGED
|
@@ -20,7 +20,7 @@ import { importIsOnTrustedAccount, TRUSTED_IMPORT_ACCOUNT } from './importTrust.
|
|
|
20
20
|
/** The alias a deck's OWN `onCheck` is reported under. */
|
|
21
21
|
export const SELF_CHECK_ALIAS = 'self';
|
|
22
22
|
// Whether `dir` is one of the kits this CLI ships, checked as itself.
|
|
23
|
-
function isShippedKitDir(dir) {
|
|
23
|
+
export function isShippedKitDir(dir) {
|
|
24
24
|
const kits = path.resolve(getKitsDir());
|
|
25
25
|
const rel = path.relative(kits, path.resolve(dir));
|
|
26
26
|
return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel) && !rel.includes(path.sep);
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,8 @@ const FLAGS_WITH_VALUES = new Set([
|
|
|
39
39
|
'--reason',
|
|
40
40
|
'--remote',
|
|
41
41
|
'--base-url',
|
|
42
|
+
'--deck',
|
|
43
|
+
'--room',
|
|
42
44
|
]);
|
|
43
45
|
// `--foo` is always a flag; a single dash only when it is one we know (`-m`).
|
|
44
46
|
// Anything else starting with `-` is a positional -- a path can begin with one,
|
|
@@ -190,6 +192,7 @@ function usage() {
|
|
|
190
192
|
castle-web get-deck <dir> --side [--deck-id ID] [--json] (fetches the saved copy into <dir>/.castle/agent/saved-source/<stamp>/, touching nothing else)
|
|
191
193
|
castle-web source-status <dir> [--adopt] [--notify] [--json] (whether the deck's saved copy is newer than this folder)
|
|
192
194
|
castle-web list-decks [dir] [--kind mine|saved|kits] (decks this one could import; ids are what add-import takes)
|
|
195
|
+
castle-web logs [dir] [--deck ID] [--room ROOM] [--rooms] [--json] [--staging] (a published deck's multiplayer room: state, end reason, exit code, out-of-memory kill and its last server log lines; no --room means the newest room; --rooms lists recent rooms; creator only)
|
|
193
196
|
castle-web reset-leaderboards [dir] [--deck-id ID] [--yes] (clears every leaderboard on the deck, for good; creator only; --yes skips the prompt)
|
|
194
197
|
castle-web add-import <deckId|url|kit> [dir] [--as ALIAS] (adds another deck, or a kit this CLI ships, as a read-only dependency in imports/)
|
|
195
198
|
castle-web fork-import-file <imports/...> [dir] (this deck's own version of one imported file)
|
|
@@ -197,6 +200,7 @@ function usage() {
|
|
|
197
200
|
castle-web update-import [alias] [dir] [--check] [--revert] (re-fetches imports; no alias means all)
|
|
198
201
|
castle-web install [dir]
|
|
199
202
|
castle-web check [dir] [--pin-installed-imports] (bundles the deck and its server, then runs each import's onCheck -- the same gates save-deck runs)
|
|
203
|
+
castle-web export [dir] (runs each import's save-time exporters (castle.json "exports") into .castle/exports/<name>/; save-deck runs them only with CASTLE_SAVE_EXPORTS=1)
|
|
200
204
|
castle-web bundle-chunks [dir] --out DIR [--base-url URL] (writes the classic chunked bundle: index.html plus <sha256>.js chunks named at URL, default ./)
|
|
201
205
|
castle-web save-version [-m MESSAGE] [paths...] [--dir DIR] (no paths saves the whole deck)
|
|
202
206
|
castle-web list-versions [version] [--dir DIR] (defaults to the latest version)
|
|
@@ -640,6 +644,10 @@ async function main() {
|
|
|
640
644
|
await check(findPositionalDir(), { pinInstalledImports: hasFlag('--pin-installed-imports') });
|
|
641
645
|
break;
|
|
642
646
|
}
|
|
647
|
+
case 'export': {
|
|
648
|
+
await (await import('./deckExports.js')).exportCommand(findPositionalDir());
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
643
651
|
case 'bundle-chunks':
|
|
644
652
|
await (await import('./bundle.js')).bundleChunksCommand(findPositionalDir(), getFlagValue('--out'), getFlagValue('--base-url'));
|
|
645
653
|
break;
|
|
@@ -715,6 +723,19 @@ async function main() {
|
|
|
715
723
|
await runMcpPlaytestServer(path.resolve(dir), getFlagValue('--task-id'));
|
|
716
724
|
return;
|
|
717
725
|
}
|
|
726
|
+
case 'logs': {
|
|
727
|
+
// `castle-web logs [dir] [--deck ID] [--room SESSION] [--rooms] [--json] [--staging]`
|
|
728
|
+
const { roomLogsCommand } = await import('./roomLogs.js');
|
|
729
|
+
await roomLogsCommand({
|
|
730
|
+
dir: path.resolve(findPositionalDir()),
|
|
731
|
+
deckId: getFlagValue('--deck') ?? getFlagValue('--deck-id'),
|
|
732
|
+
sessionId: getFlagValue('--room'),
|
|
733
|
+
listRooms: hasFlag('--rooms'),
|
|
734
|
+
json: hasFlag('--json'),
|
|
735
|
+
staging: hasFlag('--staging'),
|
|
736
|
+
});
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
718
739
|
case 'git':
|
|
719
740
|
await gitCommand();
|
|
720
741
|
break;
|
package/dist/init.js
CHANGED
|
@@ -64,7 +64,7 @@ const BARE_SCAFFOLDS = [
|
|
|
64
64
|
// Registry version of castle-web-sdk to inject when scaffolding from a
|
|
65
65
|
// globally-installed castle-web (not from inside the workspace). Bumped
|
|
66
66
|
// alongside cli/sdk version bumps.
|
|
67
|
-
const PUBLISHED_SDK_VERSION = '0.4.
|
|
67
|
+
const PUBLISHED_SDK_VERSION = '0.4.52';
|
|
68
68
|
// Range, not a pin: `castle-web-fonts` is its own package precisely so a tenth
|
|
69
69
|
// face can ship without a cli release, and a caret range means an existing
|
|
70
70
|
// deck's next install picks it up. Nothing here has to move when it does.
|
|
@@ -398,6 +398,7 @@ const STARTER_CONFIG_RESERVED = new Set([
|
|
|
398
398
|
'importWhenRemixed',
|
|
399
399
|
'onUpdate',
|
|
400
400
|
'onCheck',
|
|
401
|
+
'exports',
|
|
401
402
|
'main',
|
|
402
403
|
'starterScene',
|
|
403
404
|
'starterFiles',
|
package/dist/multiplayerDoc.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MULTIPLAYER_DOC = "# Multiplayer, in practice\n\nRead this before writing or changing a server entry or client netcode by hand.\nWritten fresh by the Castle CLI at every serve start; the full API reference is\nthe SDK's own, at `imports/castle.base/sdk/README.md`.\n\n## Reach for a kit first\n\n`castle.multiplayer-2d` and `castle.multiplayer-3d` (both on `castle.real-time`)\nalready do everything below: a server-authoritative world, one snapshot per\ntick, pose interpolation, roster handling, reconnects, ownership of loose\nobjects. `castle.turn-based` does the same for games played in turns, with\nseats, spectators and idle clearing. A deck on one of those kits normally\nwrites nothing against the raw session API, and the right move is usually to\nadd a rule to the deck's own game hooks rather than a message of your own.\n\nHand-roll only when the game genuinely does not fit them -- and then keep the\nshape below, because it is the shape the platform's limits ask for.\n\n## The outbound budget\n\nA session may send about `40 + 40 x connected players` frames per second, with\nroughly two seconds of burst, and about 1 MiB/s of bytes. What a frame costs:\n\n| call | frames |\n|---|---|\n| `session.send(playerId, data)` | 1 |\n| `session.broadcast(data)` | 1, whatever the player count |\n| `session.broadcast(data, { except })` | one per recipient -- it is a loop of sends |\n\nFrames over the budget are **dropped silently**. The session keeps running and\na dropped frame is never retried, so the symptom is not an error: it is a\nclient whose world quietly stops matching everyone else's. Only sustained abuse\nat several times the budget ends a session.\n\nThe arithmetic that matters, at `tickRate: 20`:\n\n- 4 players, one `send` per player per tick: 80 frames/s of a 200 budget --\n before a single hit, join, chat or one-off frame.\n- 8 players, same: 160 of 360. A second per-player message per tick makes it\n 320, and at `tickRate: 30` that is 480 -- over, and frames start dropping.\n- Either, with one `broadcast` per tick: 20 frames/s. The budget stops being\n something you have to think about.\n\nPer-player sends also send the same bytes N times toward the byte budget. The\nlocal serve does not drop anything, but it warns when a 1-second window goes\nover -- `[multiplayer] server sent ...` in `.castle/logs.txt` and in the serve's\nown output (`.castle/serve.log` when it was detached).\n\n## The snapshot pattern\n\nAuthoritative state lives on the server. `onTick` builds ONE snapshot of every\nplayer and broadcasts it once.\n\nEvery client reads EVERY entry in that snapshot, **including its own** -- the\ndifference is only what it does with each:\n\n- **Other players' entries** drive what it draws for them (interpolated between\n snapshots), and are how it learns someone left or went silent.\n- **Its own entry** is the server's verdict on itself. Take hp, alive/wrecked,\n kills, score and the match state from it every tick, exactly as if it were\n someone else's. The one field it does NOT overwrite each tick is its own pose:\n the local player moves on its own input so the game stays responsive, and the\n client only snaps to the server's position when the two have drifted far\n apart. Ignoring the rest of its own entry is how a player ends up alive on\n their own screen and dead on everyone else's.\n\n```js\nconst state = { matchNumber: 1, players: {}, parked: new Map() };\n\nexport default {\n onPlayerJoin(session, player) {\n state.players[player.playerId] = { x: 0, y: 0, hp: 100, kills: 0, alive: true };\n },\n onMessage(session, player, data) {\n if (data.t === 'move') applyMove(state.players[player.playerId], data);\n },\n onTick(session) {\n // One frame per tick, for any number of players.\n session.broadcast({ t: 'snap', n: state.matchNumber, players: state.players });\n },\n};\n```\n\n```js\nconnection.onMessage((msg) => {\n if (msg.t !== 'snap') return;\n match.setNumber(msg.n); // a new match number means: reset, the round moved on\n for (const [id, p] of Object.entries(msg.players)) {\n if (id === connection.playerId) {\n // My own entry: the server owns all of it except where I am right now.\n Object.assign(me, { hp: p.hp, kills: p.kills, alive: p.alive });\n if (Math.hypot(p.x - me.x, p.y - me.y) > SNAP_DISTANCE) {\n me.x = p.x; // drifted too far to argue; the server is right\n me.y = p.y;\n }\n continue;\n }\n remote.set(id, { ...p, seenAt: performance.now() });\n }\n});\n```\n\nDo not build a per-player payload (\"everyone except you\") on the server: the\nclient needs its own entry anyway, and one tailored message per player costs N\nframes where the shared snapshot costs 1.\n\n## One-off events must be self-healing\n\nA dropped or missed event frame is gone for good. So an event may carry an\neffect, never the only copy of a result:\n\n- `{ t: 'hit', target, dmg }` -- fine for a flash, a sound, a particle.\n- The hp it produced, whether the player is alive or wrecked, the kill count,\n the match number: all of that belongs in the periodic snapshot, and the\n client reconciles from the snapshot every tick.\n\nWrite the client so that receiving zero events and only snapshots still\nproduces a correct, playable screen. Then a dropped frame costs one missing\nspark instead of a player who is dead everywhere but on their own device.\n\n## Connection loss has to be visible\n\nTwo independent things can go quiet: the socket, and a player.\n\n```js\nconnection.onStateChange((state, meta) => {\n // 'acquiring' | 'connecting' | 'connected' | 'reconnecting' | 'closed'\n // meta?.type: 'connectionLost' | 'replaced' | 'bye' | 'left' | 'error'\n hud.setConnection(state, meta?.type);\n});\n```\n\n- Show `reconnecting` and `closed` in the deck's own UI. A player staring at a\n frozen game with no explanation assumes the game is broken.\n- Expire a remote player whose last snapshot is older than a few seconds\n (`performance.now() - p.seenAt > 3000`) and stop drawing them. This must run\n off the client's own clock, not off an event -- if the server or the socket\n goes silent, no message will ever arrive to tell you, and every remote player\n stays frozen mid-stride forever.\n- The SDK reconnects short drops by itself and `send` is safe to call while the\n socket is down (those messages are dropped), so the client's job is to show\n the state and recover, not to manage the socket.\n\n## Reconnects: park match state, never delete it\n\n`playerId` is stable across a platform reconnect, but the server still sees\n`onPlayerLeave` and then `onPlayerJoin`. A server that deletes the player's row\non leave silently drops a reconnecting player out of the match while their\nclient happily thinks it is still playing.\n\n```js\nonPlayerLeave(session, player) {\n const parked = state.players[player.playerId];\n delete state.players[player.playerId];\n if (parked) state.parked.set(player.playerId, { at: Date.now(), parked }); // or by userId\n},\nonPlayerJoin(session, player) {\n const held = state.parked.get(player.playerId);\n state.parked.delete(player.playerId);\n state.players[player.playerId] =\n held && Date.now() - held.at < 60_000 ? held.parked : freshPlayer();\n session.send(player.playerId, { t: 'full', ...fullState() }); // 1 frame, once\n},\n```\n\nPark for about 60 seconds (the platform's own reconnect window), keyed by\n`playerId`, or by `userId` when the match should survive a genuinely new\nconnection from the same account. Sweep expired entries on a tick.\n\nOn the client, after a state change back to `connected`, ask for full state\nonce and rebuild from the answer rather than assuming the world is as you left\nit.\n\n## The server ignores and tells\n\nWhen the server refuses a message because the player is not in the state the\nclient assumed -- not in the match, already dead, not their turn -- do not just\n`return`. The client believes something false and nothing will correct it.\n\n```js\nonMessage(session, player, data) {\n const me = state.players[player.playerId];\n if (!me || !me.alive) {\n session.send(player.playerId, { t: 'full', ...fullState() }); // authoritative answer\n return;\n }\n ...\n}\n```\n\nOne frame, and the client resyncs instead of arguing with itself. Rate-limit\nthat reply (once per player per second is plenty) so a looping client cannot\nspend the whole budget on corrections.\n\n## Client to server\n\nClient frames are capped at 16 KB and about 30 messages per second; **exceeding\nthe rate closes the socket**, which is much harsher than the server side's\nsilent drop.\n\n- Throttle pose/input sends to a fixed rate. 8-15 per second is plenty when the\n client interpolates between samples (the real-time kit reports at 20). Never\n send once per animation frame -- 60/s closes the connection.\n- Send intent (\"I am holding left\", \"I fired\"), not results. The server decides\n what happened.\n- Coalesce: one message per send tick carrying the latest pose beats three\n messages describing how it got there.\n\n## Testing it\n\n- Open **four or more** tabs, not two. Every budget and roster bug scales with\n the player count, and two tabs is exactly the case that never reproduces one.\n- Reload tabs mid-match to exercise leave/rejoin, and leave one tab idle to see\n what a silent player looks like to everyone else.\n- Kill and restart the serve (or edit the server entry, which restarts it) to\n see the disconnected state the deck shows.\n- Watch the serve log for the `[multiplayer]` budget warning and for dropped\n oversize frames while you play.\n";
|
|
1
|
+
export declare const MULTIPLAYER_DOC = "# Multiplayer, in practice\n\nRead this before writing or changing a server entry or client netcode by hand.\nWritten fresh by the Castle CLI at every serve start; the full API reference is\nthe SDK's own, at `imports/castle.base/sdk/README.md`.\n\n## Reach for a kit first\n\n`castle.multiplayer-2d` and `castle.multiplayer-3d` (both on `castle.real-time`)\nalready do everything below: a server-authoritative world, one snapshot per\ntick, pose interpolation, roster handling, reconnects, ownership of loose\nobjects. `castle.turn-based` does the same for games played in turns, with\nseats, spectators and idle clearing. A deck on one of those kits normally\nwrites nothing against the raw session API, and the right move is usually to\nadd a rule to the deck's own game hooks rather than a message of your own.\n\nHand-roll only when the game genuinely does not fit them -- and then keep the\nshape below, because it is the shape the platform's limits ask for.\n\n## The outbound budget\n\nA session may send about `40 + 40 x connected players` frames per second, with\nroughly two seconds of burst, and about 1 MiB/s of bytes. What a frame costs:\n\n| call | frames |\n|---|---|\n| `session.send(playerId, data)` | 1 |\n| `session.broadcast(data)` | 1, whatever the player count |\n| `session.broadcast(data, { except })` | one per recipient -- it is a loop of sends |\n\nFrames over the budget are **dropped silently**. The session keeps running and\na dropped frame is never retried, so the symptom is not an error: it is a\nclient whose world quietly stops matching everyone else's. Only sustained abuse\nat several times the budget ends a session.\n\nThe arithmetic that matters, at `tickRate: 20`:\n\n- 4 players, one `send` per player per tick: 80 frames/s of a 200 budget --\n before a single hit, join, chat or one-off frame.\n- 8 players, same: 160 of 360. A second per-player message per tick makes it\n 320, and at `tickRate: 30` that is 480 -- over, and frames start dropping.\n- Either, with one `broadcast` per tick: 20 frames/s. The budget stops being\n something you have to think about.\n\nPer-player sends also send the same bytes N times toward the byte budget. The\nlocal serve does not drop anything, but it warns when a 1-second window goes\nover -- `[multiplayer] server sent ...` in `.castle/logs.txt` and in the serve's\nown output (`.castle/serve.log` when it was detached).\n\n## The snapshot pattern\n\nAuthoritative state lives on the server. `onTick` builds ONE snapshot of every\nplayer and broadcasts it once.\n\nEvery client reads EVERY entry in that snapshot, **including its own** -- the\ndifference is only what it does with each:\n\n- **Other players' entries** drive what it draws for them (interpolated between\n snapshots), and are how it learns someone left or went silent.\n- **Its own entry** is the server's verdict on itself. Take hp, alive/wrecked,\n kills, score and the match state from it every tick, exactly as if it were\n someone else's. The one field it does NOT overwrite each tick is its own pose:\n the local player moves on its own input so the game stays responsive, and the\n client only snaps to the server's position when the two have drifted far\n apart. Ignoring the rest of its own entry is how a player ends up alive on\n their own screen and dead on everyone else's.\n\n```js\nconst state = { matchNumber: 1, players: {}, parked: new Map() };\n\nexport default {\n onPlayerJoin(session, player) {\n state.players[player.playerId] = { x: 0, y: 0, hp: 100, kills: 0, alive: true };\n },\n onMessage(session, player, data) {\n if (data.t === 'move') applyMove(state.players[player.playerId], data);\n },\n onTick(session) {\n // One frame per tick, for any number of players.\n session.broadcast({ t: 'snap', n: state.matchNumber, players: state.players });\n },\n};\n```\n\n```js\nconnection.onMessage((msg) => {\n if (msg.t !== 'snap') return;\n match.setNumber(msg.n); // a new match number means: reset, the round moved on\n for (const [id, p] of Object.entries(msg.players)) {\n if (id === connection.playerId) {\n // My own entry: the server owns all of it except where I am right now.\n Object.assign(me, { hp: p.hp, kills: p.kills, alive: p.alive });\n if (Math.hypot(p.x - me.x, p.y - me.y) > SNAP_DISTANCE) {\n me.x = p.x; // drifted too far to argue; the server is right\n me.y = p.y;\n }\n continue;\n }\n remote.set(id, { ...p, seenAt: performance.now() });\n }\n});\n```\n\nDo not build a per-player payload (\"everyone except you\") on the server: the\nclient needs its own entry anyway, and one tailored message per player costs N\nframes where the shared snapshot costs 1.\n\n## One-off events must be self-healing\n\nA dropped or missed event frame is gone for good. So an event may carry an\neffect, never the only copy of a result:\n\n- `{ t: 'hit', target, dmg }` -- fine for a flash, a sound, a particle.\n- The hp it produced, whether the player is alive or wrecked, the kill count,\n the match number: all of that belongs in the periodic snapshot, and the\n client reconciles from the snapshot every tick.\n\nWrite the client so that receiving zero events and only snapshots still\nproduces a correct, playable screen. Then a dropped frame costs one missing\nspark instead of a player who is dead everywhere but on their own device.\n\n## Connection loss has to be visible\n\nTwo independent things can go quiet: the socket, and a player.\n\n```js\nconnection.onStateChange((state, meta) => {\n // 'acquiring' | 'connecting' | 'connected' | 'reconnecting' | 'closed'\n // meta?.type: 'connectionLost' | 'replaced' | 'bye' | 'left' | 'error'\n hud.setConnection(state, meta?.type);\n});\n```\n\n- Show `reconnecting` and `closed` in the deck's own UI. A player staring at a\n frozen game with no explanation assumes the game is broken.\n- On `closed` with `replaced`, call `Multiplayer.join` again: the creator\n published a new server. A `public` join from matchmaking lands on the new\n version; a `named` or `party` room, or a friend's public room the player\n followed, keeps the old one until Castle ends it, about ten minutes after the\n save. That ending, like a kick, arrives as `bye` with a `reason` to show\n the player; don't rejoin a `bye` automatically, or a kicked player comes\n straight back.\n- Expire a remote player whose last snapshot is older than a few seconds\n (`performance.now() - p.seenAt > 3000`) and stop drawing them. This must run\n off the client's own clock, not off an event -- if the server or the socket\n goes silent, no message will ever arrive to tell you, and every remote player\n stays frozen mid-stride forever.\n- The SDK reconnects short drops by itself and `send` is safe to call while the\n socket is down (those messages are dropped), so the client's job is to show\n the state and recover, not to manage the socket.\n\n## Reconnects: park match state, never delete it\n\n`playerId` is stable across a platform reconnect, but the server still sees\n`onPlayerLeave` and then `onPlayerJoin`. A server that deletes the player's row\non leave silently drops a reconnecting player out of the match while their\nclient happily thinks it is still playing.\n\n```js\nonPlayerLeave(session, player) {\n const parked = state.players[player.playerId];\n delete state.players[player.playerId];\n if (parked) state.parked.set(player.playerId, { at: Date.now(), parked }); // or by userId\n},\nonPlayerJoin(session, player) {\n const held = state.parked.get(player.playerId);\n state.parked.delete(player.playerId);\n state.players[player.playerId] =\n held && Date.now() - held.at < 60_000 ? held.parked : freshPlayer();\n session.send(player.playerId, { t: 'full', ...fullState() }); // 1 frame, once\n},\n```\n\nPark for about 60 seconds (the platform's own reconnect window), keyed by\n`playerId`, or by `userId` when the match should survive a genuinely new\nconnection from the same account. Sweep expired entries on a tick.\n\nOn the client, after a state change back to `connected`, ask for full state\nonce and rebuild from the answer rather than assuming the world is as you left\nit.\n\n## The server ignores and tells\n\nWhen the server refuses a message because the player is not in the state the\nclient assumed -- not in the match, already dead, not their turn -- do not just\n`return`. The client believes something false and nothing will correct it.\n\n```js\nonMessage(session, player, data) {\n const me = state.players[player.playerId];\n if (!me || !me.alive) {\n session.send(player.playerId, { t: 'full', ...fullState() }); // authoritative answer\n return;\n }\n ...\n}\n```\n\nOne frame, and the client resyncs instead of arguing with itself. Rate-limit\nthat reply (once per player per second is plenty) so a looping client cannot\nspend the whole budget on corrections.\n\n## Client to server\n\nClient frames are capped at 16 KB and about 30 messages per second; **exceeding\nthe rate closes the socket**, which is much harsher than the server side's\nsilent drop.\n\n- Throttle pose/input sends to a fixed rate. 8-15 per second is plenty when the\n client interpolates between samples (the real-time kit reports at 20). Never\n send once per animation frame -- 60/s closes the connection.\n- Send intent (\"I am holding left\", \"I fired\"), not results. The server decides\n what happened.\n- Coalesce: one message per send tick carrying the latest pose beats three\n messages describing how it got there.\n\n## Testing it\n\n- Open **four or more** tabs, not two. Every budget and roster bug scales with\n the player count, and two tabs is exactly the case that never reproduces one.\n- Reload tabs mid-match to exercise leave/rejoin, and leave one tab idle to see\n what a silent player looks like to everyone else.\n- Kill and restart the serve (or edit the server entry, which restarts it) to\n see the disconnected state the deck shows.\n- Watch the serve log for the `[multiplayer]` budget warning and for dropped\n oversize frames while you play.\n- A published room that crashed or stopped: `castle-web logs` prints its end\n reason, exit code and last server log lines (creator only; `--rooms` lists rooms).\n";
|
package/dist/multiplayerDoc.js
CHANGED
|
@@ -141,6 +141,13 @@ connection.onStateChange((state, meta) => {
|
|
|
141
141
|
|
|
142
142
|
- Show \`reconnecting\` and \`closed\` in the deck's own UI. A player staring at a
|
|
143
143
|
frozen game with no explanation assumes the game is broken.
|
|
144
|
+
- On \`closed\` with \`replaced\`, call \`Multiplayer.join\` again: the creator
|
|
145
|
+
published a new server. A \`public\` join from matchmaking lands on the new
|
|
146
|
+
version; a \`named\` or \`party\` room, or a friend's public room the player
|
|
147
|
+
followed, keeps the old one until Castle ends it, about ten minutes after the
|
|
148
|
+
save. That ending, like a kick, arrives as \`bye\` with a \`reason\` to show
|
|
149
|
+
the player; don't rejoin a \`bye\` automatically, or a kicked player comes
|
|
150
|
+
straight back.
|
|
144
151
|
- Expire a remote player whose last snapshot is older than a few seconds
|
|
145
152
|
(\`performance.now() - p.seenAt > 3000\`) and stop drawing them. This must run
|
|
146
153
|
off the client's own clock, not off an event -- if the server or the socket
|
|
@@ -225,4 +232,6 @@ silent drop.
|
|
|
225
232
|
see the disconnected state the deck shows.
|
|
226
233
|
- Watch the serve log for the \`[multiplayer]\` budget warning and for dropped
|
|
227
234
|
oversize frames while you play.
|
|
235
|
+
- A published room that crashed or stopped: \`castle-web logs\` prints its end
|
|
236
|
+
reason, exit code and last server log lines (creator only; \`--rooms\` lists rooms).
|
|
228
237
|
`;
|
package/dist/platformDoc.js
CHANGED
|
@@ -311,7 +311,8 @@ const COMMON_SECTIONS = `## Imports are read-only
|
|
|
311
311
|
- **Limits worth designing around.** Client→server messages are capped at 16 KB and about 30 per second; server→client messages are capped at 64 KB. These limits apply to both JSON and binary frames and are measured on the frame, so a binary frame's one-byte protocol tag leaves you one byte under the cap for payload. A session may also SEND only about \`40 + 40 × connected players\` frames per second (about two seconds of burst, and about 1 MiB/s of bytes): \`session.send\` costs one frame per call, \`session.broadcast(data)\` costs ONE frame however many players are in the session, and \`session.broadcast(data, { except })\` is a loop of sends, so it costs one frame per recipient. Frames over the budget are dropped silently and never retried — the session keeps running, so the symptom is a client whose world quietly stops matching everyone else's; only sustained abuse at several times the budget ends a session. So send one \`broadcast\` per tick carrying every player's state, rather than a tailored \`send\` per player: every client reads every entry of that snapshot INCLUDING its own — it takes hp, kills and match state from its own entry and only keeps its own position locally predicted.
|
|
312
312
|
- **Binary messages are opt-in per payload.** Pass any typed array, \`DataView\`, or \`ArrayBuffer\` to client \`send\`, server \`send\`, or server \`broadcast\` to send its raw bytes. \`onMessage\` always receives those bytes as a \`Uint8Array\`, while every other payload continues to use JSON. Reconstruct another view type such as \`Float32Array\` on receipt; multi-byte values use the sender platform's byte order.
|
|
313
313
|
- **Test multiplayer locally with no setup.** \`castle-web serve\` runs your server file alongside the deck. Open the shell URL it prints in two tabs, then open the Play panel in each; those play surfaces share a session. If you open the content origin from \`.castle/serve.json\` directly, use \`/index.html?edit=0\`. Its bare origin loads the edit surface, where \`Multiplayer.join\` is not answered. Editing the server entry, anything beside it, or a deck-owned hook under \`server/\` or \`code/server/\` restarts it and clients reconnect, so you exercise your reconnect path constantly. Server \`console.log\` goes to the serve's logs, not the browser console.
|
|
314
|
-
- **
|
|
314
|
+
- **A published deck's server rooms have logs too.** \`castle-web logs\` (in the deck folder, signed in as its creator) shows the newest room's state, end reason, exit code, an out-of-memory kill, and its last server log lines; \`--rooms\` lists recent rooms and \`--room <id>\` picks one. Hosts keep the lines for about 30 minutes after a room ends.
|
|
315
|
+
- **Publishing moves players onto the new version; you don't build versioned rooms or a rejoin prompt.** \`save-deck\` bundles and publishes the server entry, and every new session runs it. A session already running keeps the code it started with: its server gets \`onReplaced\`, and each client's connection closes with \`replaced\` metadata. A deck that joins again when the connection closes (the multiplayer kits do) gets the new version at once for a \`public\` join from matchmaking, since new players are not placed in a running public session on the old code; a \`named\` or \`party\` join, or a public one that follows a friend into their room, goes back to that room, which keeps the old code until it ends. About ten minutes after the save Castle ends any ordinary session still on the old code (hub places, persistent worlds and destinations keep their own release handling), closing its connections with \`bye\` and a reason that says the game was updated; its \`onShutdown\` still runs, so a save there lands, and the next join gets the new version.
|
|
315
316
|
`;
|
|
316
317
|
export function platformGuide(deckDir) {
|
|
317
318
|
return `${COMMON_SECTIONS.trimEnd()}
|
package/dist/playPagePolicy.d.ts
CHANGED
package/dist/playPagePolicy.js
CHANGED
|
@@ -7,14 +7,19 @@ const CDN_HOSTS = 'https://esm.sh https://cdnjs.cloudflare.com';
|
|
|
7
7
|
const PLAY_HOSTS = 'wss://*.play.castle.xyz';
|
|
8
8
|
// Content packs a hub door mounts (kits/hub-game/docs/content-pack.md); connect-src only.
|
|
9
9
|
const CONTENT_PACK_HOSTS = 'https://hosted.castle.games';
|
|
10
|
+
// Uploaded textures, models and songs a deck loads from Castle's own CDN instead of
|
|
11
|
+
// inlining them as base64. Castle-controlled hosts that answer
|
|
12
|
+
// `Access-Control-Allow-Origin: *`, so a fetch from the opaque srcdoc origin can read
|
|
13
|
+
// them. img-src, media-src and connect-src only: an asset is data, never script.
|
|
14
|
+
export const CASTLE_ASSET_HOSTS = 'https://castle.imgix.net https://image.castle.xyz https://audio.castle.xyz';
|
|
10
15
|
const DECK_CSP = [
|
|
11
16
|
"default-src 'self' data: blob:",
|
|
12
17
|
`script-src 'self' 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' data: blob: ${CDN_HOSTS}`,
|
|
13
18
|
"style-src 'self' 'unsafe-inline' data: blob: https://fonts.googleapis.com",
|
|
14
19
|
"font-src 'self' data: blob: https://fonts.gstatic.com",
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`connect-src 'self' data: blob: ${CDN_HOSTS} ${PLAY_HOSTS} ${CONTENT_PACK_HOSTS}`,
|
|
20
|
+
`img-src 'self' data: blob: ${CASTLE_ASSET_HOSTS}`,
|
|
21
|
+
`media-src 'self' data: blob: ${CASTLE_ASSET_HOSTS}`,
|
|
22
|
+
`connect-src 'self' data: blob: ${CDN_HOSTS} ${PLAY_HOSTS} ${CONTENT_PACK_HOSTS} ${CASTLE_ASSET_HOSTS}`,
|
|
18
23
|
"frame-src 'none'",
|
|
19
24
|
"child-src 'self' blob:",
|
|
20
25
|
"worker-src 'self' blob:",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface CauldronRoom {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
deckId: string;
|
|
4
|
+
env: string;
|
|
5
|
+
startedAt: string;
|
|
6
|
+
endedAt: string | null;
|
|
7
|
+
numPlayers: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CauldronRoomLogLine {
|
|
10
|
+
at: string | null;
|
|
11
|
+
stream: string;
|
|
12
|
+
text: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CauldronRoomLogs extends CauldronRoom {
|
|
15
|
+
state: string;
|
|
16
|
+
logsAvailable: boolean;
|
|
17
|
+
logsUnavailableReason: string | null;
|
|
18
|
+
endReason: string | null;
|
|
19
|
+
exitCode: number | null;
|
|
20
|
+
oomKilled: boolean | null;
|
|
21
|
+
droppedLines: number;
|
|
22
|
+
lines: CauldronRoomLogLine[];
|
|
23
|
+
}
|
|
24
|
+
export interface RoomLogsOptions {
|
|
25
|
+
dir: string;
|
|
26
|
+
deckId?: string;
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
listRooms: boolean;
|
|
29
|
+
json: boolean;
|
|
30
|
+
staging: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare class RoomLogsError extends Error {
|
|
33
|
+
}
|
|
34
|
+
export declare function recentRooms(deckId: string, env: string, limit?: number): Promise<CauldronRoom[]>;
|
|
35
|
+
export declare function roomLogs(deckId: string, sessionId: string, env: string): Promise<CauldronRoomLogs>;
|
|
36
|
+
export declare function visible(text: string): string;
|
|
37
|
+
export declare function formatRooms(deckId: string, env: string, rooms: CauldronRoom[]): string;
|
|
38
|
+
export declare function formatRoomLogs(logs: CauldronRoomLogs): string;
|
|
39
|
+
export declare function roomLogsCommand(options: RoomLogsOptions): Promise<void>;
|