@seriousgaming/sdk-tools 1.6.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/guidance.md +1 -0
- package/dist/{cli-2NU2LPEE.js → cli-27M4PX7O.js} +17 -17
- package/dist/{cli-2BH7FX27.js → cli-2FXZZLCL.js} +1 -1
- package/dist/{cli-5ACDPCXI.js → cli-2KDV2DYC.js} +3 -3
- package/dist/{cli-OXAUOWCN.js → cli-2QM63J3I.js} +1 -1
- package/dist/{cli-HW53ICZC.js → cli-32NRB2IT.js} +15 -15
- package/dist/{cli-45OCBG53.js → cli-3HBYH4VF.js} +11 -11
- package/dist/{cli-4VFZHLDG.js → cli-3HPAKEJJ.js} +2 -2
- package/dist/{cli-R2MUZQE2.js → cli-3HZGJRQW.js} +11 -11
- package/dist/{cli-PGCIHPU7.js → cli-3OCKRPXI.js} +18 -18
- package/dist/{cli-64AB62PM.js → cli-3OVXQJEW.js} +2 -2
- package/dist/{cli-4UWFQNGF.js → cli-3VV2JLHX.js} +1 -1
- package/dist/{cli-XSLNH5PR.js → cli-42ZUP4X3.js} +141 -5
- package/dist/{cli-ZJFQ7EEA.js → cli-4B5OBHSY.js} +19 -19
- package/dist/{cli-7A6MKCUJ.js → cli-4EMNCU63.js} +27 -19
- package/dist/cli-5CG6BMCY.js +36 -0
- package/dist/{cli-XZCJIKIV.js → cli-5FRKWNVP.js} +19 -19
- package/dist/{cli-Y3DDNMPX.js → cli-5P66N5G6.js} +17 -17
- package/dist/{cli-6VNKQ3OX.js → cli-5SYPXJCB.js} +28 -16
- package/dist/{cli-G6CANSPL.js → cli-66AHBZRZ.js} +15 -15
- package/dist/{cli-BJMS3VX3.js → cli-6AGWTGTO.js} +106 -28
- package/dist/{cli-TTMBBEJC.js → cli-6BAZE75K.js} +18 -18
- package/dist/{cli-GFNDW2DL.js → cli-6FVHRL3H.js} +19 -19
- package/dist/{cli-QVASWX2A.js → cli-6GDPO5VU.js} +2 -2
- package/dist/{cli-7XLHO2FE.js → cli-6NBER36P.js} +1 -1
- package/dist/{cli-FQRVFGN6.js → cli-726NJARI.js} +0 -0
- package/dist/{cli-CD5CIJZI.js → cli-72DRYVTT.js} +13 -13
- package/dist/{cli-MMN4BPO4.js → cli-7CW2BBJG.js} +1 -1
- package/dist/{cli-XAT25PRU.js → cli-7GJGFILU.js} +15 -15
- package/dist/{cli-HFX3YPUL.js → cli-7NCVUM5U.js} +3 -3
- package/dist/cli-7S4G4EKK.js +110 -0
- package/dist/{cli-J4DKUUTK.js → cli-7V6GUIIS.js} +2 -2
- package/dist/{cli-N6H6T2E2.js → cli-AEAFLZGY.js} +12 -0
- package/dist/{cli-C47GJATR.js → cli-AGYCXRPR.js} +3 -3
- package/dist/{cli-XSVGKI3R.js → cli-BC4KKNLA.js} +1 -1
- package/dist/cli-BQ3FHENQ.js +16 -0
- package/dist/{cli-KGM6RRQW.js → cli-BXCCODYD.js} +20 -20
- package/dist/cli-C2XDL4LD.js +30 -0
- package/dist/{cli-MJUYJIEP.js → cli-C45A5VX6.js} +3 -3
- package/dist/{cli-DOXRQ3S5.js → cli-C7YZNPWX.js} +11 -11
- package/dist/{cli-HOE3WLFH.js → cli-CAX4CQTC.js} +13 -13
- package/dist/{cli-YOTGR3NB.js → cli-CVOLMK3Z.js} +1 -1
- package/dist/{cli-ILFDANBR.js → cli-D3CZRXVJ.js} +63 -17
- package/dist/{cli-4YB3ROVR.js → cli-DMKRP33X.js} +1 -1
- package/dist/{cli-Y3O5F4JN.js → cli-DPFN2LIZ.js} +15 -15
- package/dist/{cli-6UTPHWRQ.js → cli-DT756M3Z.js} +20 -20
- package/dist/{cli-TIDQ4WUE.js → cli-DXHPYN4N.js} +1 -1
- package/dist/{cli-6K3VQQUS.js → cli-E665NKUQ.js} +5 -5
- package/dist/{cli-O5ABH2WK.js → cli-EK7CGMGS.js} +17 -17
- package/dist/{cli-6QB2VFPY.js → cli-ESU3J563.js} +15 -15
- package/dist/{cli-VPRRICZA.js → cli-F47ELAXM.js} +47 -47
- package/dist/{cli-RLEGRWFM.js → cli-FH4WBZHA.js} +14 -14
- package/dist/{cli-3D3ZXWOV.js → cli-FHKRO6OU.js} +19 -19
- package/dist/{cli-JZCLIT3O.js → cli-FSEDPZR5.js} +19 -19
- package/dist/{cli-XOTNXEJA.js → cli-FV45UZQP.js} +19 -19
- package/dist/{cli-AV2FYC5G.js → cli-G7FX7ZIU.js} +12 -12
- package/dist/{cli-IP4RXGHM.js → cli-GFONBOJT.js} +129 -38
- package/dist/{cli-C5QOJJWX.js → cli-GHIMH6JU.js} +1 -1
- package/dist/{cli-IDVUHGKG.js → cli-HC7L5DXV.js} +15 -15
- package/dist/{cli-WU43JT4T.js → cli-HJPNNORV.js} +2 -2
- package/dist/{cli-QY5NZAR7.js → cli-HMEZHQBC.js} +17 -17
- package/dist/{cli-JZOZOEZM.js → cli-HQUVSAHY.js} +18 -18
- package/dist/{cli-MYJGMA6U.js → cli-IC5FOT2J.js} +1 -1
- package/dist/{cli-VL2P354N.js → cli-IVZ7AHUJ.js} +3 -3
- package/dist/{cli-B6YHEKIJ.js → cli-J2OTL6JH.js} +5 -5
- package/dist/{cli-Z56ZIVA6.js → cli-JA6UFTSX.js} +17 -17
- package/dist/{cli-MJV47HKI.js → cli-JOXCAGM7.js} +19 -19
- package/dist/{cli-ZBN5KAIB.js → cli-JQ6I5GGE.js} +3 -3
- package/dist/{cli-TDSQSCX4.js → cli-K6M6YB67.js} +1 -1
- package/dist/{cli-C6ZLPK2U.js → cli-KFVA7DT3.js} +3 -3
- package/dist/{cli-KOGRWFN7.js → cli-KH6FKM5A.js} +15 -15
- package/dist/{cli-5IAW3LIF.js → cli-KMT235FV.js} +2 -2
- package/dist/{cli-ZDUADFBY.js → cli-KU4PG7ZA.js} +15 -15
- package/dist/{cli-N45DREM4.js → cli-L4DEEAMK.js} +17 -17
- package/dist/{cli-MU5LB43S.js → cli-ME3JKMJL.js} +19 -19
- package/dist/{cli-C3CMJSNL.js → cli-MJ65PIYI.js} +15 -15
- package/dist/cli-MM2ROZWO.js +36 -0
- package/dist/{cli-RZITKPJX.js → cli-MN7X4UG2.js} +1 -1
- package/dist/{cli-4SIWLHQO.js → cli-MPU4FLA7.js} +4 -4
- package/dist/{cli-HCRTYQQS.js → cli-MPWTXNF6.js} +2 -2
- package/dist/{cli-EVI36HEM.js → cli-N5K2KHPR.js} +15 -15
- package/dist/{cli-RSW6EBBD.js → cli-NGOQWOQE.js} +15 -15
- package/dist/{cli-ZTWOE3ZT.js → cli-NU4SCD5D.js} +1 -1
- package/dist/{cli-BYCHKSSH.js → cli-O3IMNLN2.js} +282 -96
- package/dist/{cli-KGT5L7VZ.js → cli-OUFXSQOW.js} +7265 -4467
- package/dist/{cli-DFBTZEBX.js → cli-PEY6XZDE.js} +16 -16
- package/dist/{cli-QUSCIUOM.js → cli-PLW3TWJ7.js} +19 -19
- package/dist/{cli-JVI24FI6.js → cli-PO2ALWHP.js} +13 -13
- package/dist/{cli-3BRC32CP.js → cli-PPEB3ENS.js} +18 -18
- package/dist/{cli-ZDOTXEKL.js → cli-PZ7G544B.js} +3 -3
- package/dist/{cli-L7VYSXQK.js → cli-Q5BKFFDL.js} +4 -4
- package/dist/{cli-3ZKWV3PN.js → cli-QAI6T5FL.js} +15 -15
- package/dist/{cli-KSGB2ZLK.js → cli-QAVLRCQ5.js} +3 -3
- package/dist/{cli-VDBW23SS.js → cli-QDIH2G2P.js} +15 -15
- package/dist/cli-SN7D7HTX.js +36 -0
- package/dist/{cli-IEMKI7J7.js → cli-SOQJHK4Q.js} +6 -6
- package/dist/{cli-4PXNOJQX.js → cli-SPKPDXWD.js} +15 -15
- package/dist/{cli-MOPSZ3CS.js → cli-SWUAXVIJ.js} +15 -15
- package/dist/cli-TJNLXQJ5.js +36 -0
- package/dist/{cli-BUQI5UU4.js → cli-U2EWI6H5.js} +11 -11
- package/dist/{cli-TT36JCU5.js → cli-UADUC4JD.js} +2 -2
- package/dist/{cli-FWFRKQNE.js → cli-UR63LFVK.js} +2 -2
- package/dist/{cli-J4UBELKF.js → cli-UTHPCZYL.js} +2 -2
- package/dist/{cli-Q6ZBZYK2.js → cli-UYV3BDPA.js} +3 -3
- package/dist/{cli-LQOHATY2.js → cli-UZCQL6YP.js} +3 -3
- package/dist/{cli-HKORECAG.js → cli-V5K3CCYZ.js} +2 -2
- package/dist/cli-V7L3HEL4.js +36 -0
- package/dist/{cli-HSIHDN6K.js → cli-VBSF3R3L.js} +16 -16
- package/dist/{cli-NROTDF5Y.js → cli-VQ4OJ4KE.js} +18 -18
- package/dist/{cli-IUS2YCD3.js → cli-VTLFQHDO.js} +1 -1
- package/dist/{cli-JJSWBW4H.js → cli-W7XCTGQ7.js} +15 -15
- package/dist/{cli-UZZFNXRX.js → cli-W7Y7X3FX.js} +19 -19
- package/dist/cli-WWNTBK37.js +1973 -0
- package/dist/cli-XPJGW375.js +36 -0
- package/dist/{cli-SRHBXZCN.js → cli-Y33ULHYO.js} +1 -1
- package/dist/{cli-TTKICM5P.js → cli-YLYB4ITF.js} +13 -13
- package/dist/{cli-72XDEFU3.js → cli-ZFY6TGU7.js} +4 -4
- package/dist/{cli-6SGCYEEC.js → cli-ZSKP2IRP.js} +53 -38
- package/dist/cli.js +53 -51
- package/dist/client.js +17699 -16630
- package/dist/core/game-settings.d.ts +5 -3
- package/dist/core/save-scenario.d.ts +1 -0
- package/dist/core/session-roster.d.ts +10 -0
- package/dist/core/session-start-gate.d.ts +25 -0
- package/dist/core/session.d.ts +4 -0
- package/dist/dev/console/assets/index-CVNjiRUh.js +208 -0
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/routes.d.ts +5 -2
- package/dist/dev/shell.d.ts +9 -1
- package/dist/dev/view/batch.d.ts +11 -1
- package/dist/dev/view/route.d.ts +18 -1
- package/dist/dev/view/view.d.ts +9 -0
- package/dist/docs/api/deck.md +1 -1
- package/dist/docs/api/index.md +2 -2
- package/dist/docs/api/sdk-commands.md +4 -0
- package/dist/docs/api/sdk-e2e.md +12 -6
- package/dist/docs/api/sdk-projection.md +1 -0
- package/dist/docs/api/sdk-tools-client.md +7 -1
- package/dist/docs/api/sdk-tools-playwright.md +1 -8
- package/dist/docs/api/sdk-ui-testing.md +1 -0
- package/dist/docs/api/sdk-ui.md +67 -63
- package/dist/docs/api/sdk.md +12 -1
- package/dist/docs/changelog.md +26 -0
- package/dist/docs/cli-and-dev-server.md +4 -0
- package/dist/docs/cli-error-codes.md +7 -1
- package/dist/docs/cli-reference.md +20 -2
- package/dist/docs/concepts/index.md +1 -0
- package/dist/docs/guides/engine.md +5 -0
- package/dist/docs/guides/file-handling.md +4 -1
- package/dist/docs/guides/llm-integration.md +3 -2
- package/dist/docs/guides/multi-team-games.md +2 -0
- package/dist/docs/guides/patterns.md +5 -0
- package/dist/docs/guides/presentation.md +11 -10
- package/dist/docs/guides/session-hooks.md +16 -0
- package/dist/docs/guides/session.md +1 -1
- package/dist/docs/guides/settings.md +6 -2
- package/dist/docs/guides/setup.md +23 -2
- package/dist/docs/guides/speech-generation.md +1 -0
- package/dist/docs/guides/testing.md +2 -0
- package/dist/docs/guides/tick-controller.md +2 -0
- package/dist/docs/guides/type-safety.md +2 -1
- package/dist/docs/guides/ui-files-and-llms.md +3 -1
- package/dist/docs/guides/upgrading.md +16 -0
- package/dist/docs/guides/validators.md +27 -4
- package/dist/docs/guides/waiting-room.md +2 -0
- package/dist/docs/page-index.md +12 -10
- package/dist/docs/recipes/call-endpoint-from-ui.md +1 -0
- package/dist/docs/recipes/create-scenario-editor.md +2 -1
- package/dist/docs/recipes/create-setup.md +2 -1
- package/dist/docs/recipes/declare-api-uses.md +1 -0
- package/dist/docs/recipes/describe-setup-with-endpoint.md +69 -0
- package/dist/docs/recipes/index.md +3 -1
- package/dist/docs/recipes/share-logic-between-engine-and-ui.md +2 -2
- package/dist/docs/recipes/test-user-interface.md +1 -1
- package/dist/docs/recipes/validate-scenarios.md +9 -3
- package/dist/docs/recipes/write-setup-notes.md +58 -0
- package/dist/docs/troubleshooting.md +2 -1
- package/dist/execution/executor.d.ts +12 -0
- package/dist/execution/scenario-gates.d.ts +40 -0
- package/dist/host/protocol.d.ts +10 -1
- package/dist/host.js +1083 -467
- package/dist/playwright.js +17760 -16691
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +4 -2
- package/dist/schema.json +10 -1
- package/dist/setup/setup-notes.d.ts +42 -0
- package/dist/templates/package/package.json.liquid +15 -15
- package/dist/templates/starter-game/package.json +13 -13
- package/dist/utils/error-codes.d.ts +13 -1
- package/dist/validation/package-validation.d.ts +1 -1
- package/package.json +22 -23
- package/dist/cli-2GZYGRVL.js +0 -36
- package/dist/cli-5SM367K7.js +0 -30
- package/dist/cli-DDJYUKQG.js +0 -36
- package/dist/cli-LK3V4RI5.js +0 -36
- package/dist/cli-N24OHSAN.js +0 -36
- package/dist/cli-OMWC75CC.js +0 -256
- package/dist/cli-RCIWBCXD.js +0 -36
- package/dist/cli-UMEBPAZQ.js +0 -16
- package/dist/cli-VQ6HVQW4.js +0 -4010
- package/dist/cli-WR3NOY74.js +0 -36
- package/dist/dev/console/assets/index-CuMOOH9m.js +0 -204
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
resolvePatchedDefinition
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-KMT235FV.js";
|
|
5
5
|
import "./cli-S5IVGDDD.js";
|
|
6
6
|
import {
|
|
7
7
|
readAuthoredBundle
|
|
8
|
-
} from "./cli-
|
|
8
|
+
} from "./cli-3HPAKEJJ.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveInputSource
|
|
11
|
-
} from "./cli-
|
|
11
|
+
} from "./cli-3VV2JLHX.js";
|
|
12
12
|
import {
|
|
13
13
|
updateScenarioFiles
|
|
14
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-UTHPCZYL.js";
|
|
15
15
|
import {
|
|
16
16
|
loadPackageContext
|
|
17
|
-
} from "./cli-
|
|
18
|
-
import "./cli-
|
|
19
|
-
import "./cli-
|
|
17
|
+
} from "./cli-BC4KKNLA.js";
|
|
18
|
+
import "./cli-UADUC4JD.js";
|
|
19
|
+
import "./cli-2QM63J3I.js";
|
|
20
20
|
import {
|
|
21
21
|
operationError,
|
|
22
22
|
printOperationResult
|
|
23
|
-
} from "./cli-
|
|
24
|
-
import "./cli-
|
|
25
|
-
import "./cli-
|
|
26
|
-
import "./cli-
|
|
27
|
-
import "./cli-
|
|
23
|
+
} from "./cli-QAVLRCQ5.js";
|
|
24
|
+
import "./cli-UZCQL6YP.js";
|
|
25
|
+
import "./cli-SOQJHK4Q.js";
|
|
26
|
+
import "./cli-7S4G4EKK.js";
|
|
27
|
+
import "./cli-O3IMNLN2.js";
|
|
28
28
|
import "./cli-25RWY5BQ.js";
|
|
29
29
|
import "./cli-QWQMPCL6.js";
|
|
30
30
|
import {
|
|
31
31
|
validateSDKScenario
|
|
32
|
-
} from "./cli-
|
|
32
|
+
} from "./cli-OUFXSQOW.js";
|
|
33
33
|
import "./cli-F2D4GGUA.js";
|
|
34
34
|
import {
|
|
35
35
|
logger
|
|
36
|
-
} from "./cli-
|
|
36
|
+
} from "./cli-DMKRP33X.js";
|
|
37
37
|
import {
|
|
38
38
|
CliError
|
|
39
|
-
} from "./cli-
|
|
39
|
+
} from "./cli-AEAFLZGY.js";
|
|
40
40
|
|
|
41
41
|
// cli/commands/resources/scenario/update.ts
|
|
42
42
|
async function updateScenario(identifier, definitionInput, options) {
|
|
@@ -6,17 +6,22 @@ import {
|
|
|
6
6
|
} from "./cli-25RWY5BQ.js";
|
|
7
7
|
import {
|
|
8
8
|
describeAssetByReference,
|
|
9
|
+
describeBlob,
|
|
9
10
|
readAssetByReference,
|
|
10
11
|
storeBlob
|
|
11
12
|
} from "./cli-QWQMPCL6.js";
|
|
12
13
|
import {
|
|
13
14
|
DeniedError,
|
|
15
|
+
SCENARIO_GATE_READ_LIMIT_BYTES,
|
|
16
|
+
ScenarioAssetTooLargeError,
|
|
17
|
+
Transpile,
|
|
14
18
|
UndeclaredApiUseError,
|
|
19
|
+
errorMessage,
|
|
15
20
|
realPath,
|
|
16
21
|
settingsSchemas,
|
|
17
22
|
validateSessionOverrides,
|
|
18
23
|
validateSettingsOverrides
|
|
19
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-OUFXSQOW.js";
|
|
20
25
|
|
|
21
26
|
// cli/execution/logic-failure.ts
|
|
22
27
|
import { SourceMap } from "node:module";
|
|
@@ -250,100 +255,9 @@ function describeLogicFailure(error, origin, maps, packagePath) {
|
|
|
250
255
|
};
|
|
251
256
|
}
|
|
252
257
|
|
|
253
|
-
// cli/execution/
|
|
254
|
-
import {
|
|
255
|
-
import {
|
|
256
|
-
var LogicLoader = class {
|
|
257
|
-
constructor(packagePath, deps) {
|
|
258
|
-
this.packagePath = packagePath;
|
|
259
|
-
this.deps = deps;
|
|
260
|
-
}
|
|
261
|
-
packagePath;
|
|
262
|
-
deps;
|
|
263
|
-
caches = {
|
|
264
|
-
engine: /* @__PURE__ */ new Map(),
|
|
265
|
-
tickController: /* @__PURE__ */ new Map(),
|
|
266
|
-
hook: /* @__PURE__ */ new Map(),
|
|
267
|
-
validator: /* @__PURE__ */ new Map(),
|
|
268
|
-
endpoint: /* @__PURE__ */ new Map()
|
|
269
|
-
};
|
|
270
|
-
logicContext;
|
|
271
|
-
/** Each evaluated bundle's source map, to read a thrown stack back to source. */
|
|
272
|
-
sourceMaps = new SourceMapRegistry();
|
|
273
|
-
/**
|
|
274
|
-
* Load the logic exports for `identifier` of the given `kind`, from cache
|
|
275
|
-
* when present. `resource` is the bundle whose logic to compile; a missing
|
|
276
|
-
* resource throws `notFoundMessage`.
|
|
277
|
-
*/
|
|
278
|
-
async load(kind, identifier, resource, notFoundMessage) {
|
|
279
|
-
const cache = this.caches[kind];
|
|
280
|
-
const cached = cache.get(identifier);
|
|
281
|
-
if (cached) {
|
|
282
|
-
return cached;
|
|
283
|
-
}
|
|
284
|
-
if (!resource) {
|
|
285
|
-
throw new Error(notFoundMessage);
|
|
286
|
-
}
|
|
287
|
-
const logicDirectory = resolveResourceDirectory(
|
|
288
|
-
this.packagePath,
|
|
289
|
-
resource.rootDirectory,
|
|
290
|
-
resource.logic.directory
|
|
291
|
-
);
|
|
292
|
-
const logicPath = join(logicDirectory, resource.logic.entrypoint);
|
|
293
|
-
const bundledCode = isPrecompiled(resource.rootDirectory, resource.logic.entrypoint) ? await this.deps.fs.readFile(logicPath, "utf-8") : await this.deps.transpile({
|
|
294
|
-
entrypoint: logicPath,
|
|
295
|
-
sourcemap: true,
|
|
296
|
-
packageRoot: this.packagePath
|
|
297
|
-
});
|
|
298
|
-
this.sourceMaps.register(logicPath, bundledCode);
|
|
299
|
-
const moduleObj = { exports: {} };
|
|
300
|
-
const func = compileFunction(bundledCode, ["module", "exports"], {
|
|
301
|
-
filename: logicPath,
|
|
302
|
-
parsingContext: this.getLogicContext()
|
|
303
|
-
});
|
|
304
|
-
func(moduleObj, moduleObj.exports);
|
|
305
|
-
const exports = moduleObj.exports;
|
|
306
|
-
cache.set(identifier, exports);
|
|
307
|
-
return exports;
|
|
308
|
-
}
|
|
309
|
-
/** Drop every cached bundle (used when configuration or code reloads). */
|
|
310
|
-
clearAll() {
|
|
311
|
-
for (const cache of Object.values(this.caches)) {
|
|
312
|
-
cache.clear();
|
|
313
|
-
}
|
|
314
|
-
this.sourceMaps.clear();
|
|
315
|
-
}
|
|
316
|
-
/** Drop a single cached bundle so its next load re-transpiles it. */
|
|
317
|
-
invalidate(kind, identifier) {
|
|
318
|
-
this.caches[kind].delete(identifier);
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* The shared bare-V8 global scope every logic bundle is evaluated in.
|
|
322
|
-
*
|
|
323
|
-
* A fresh vm context exposes only the ECMAScript intrinsics — the
|
|
324
|
-
* environment the production runtime guarantees (SPECIFICATION.md §3.2).
|
|
325
|
-
* Host globals such as `structuredClone`, `fetch`, `setTimeout`,
|
|
326
|
-
* `TextEncoder`, and `process` are absent, so logic that reaches for one
|
|
327
|
-
* throws a `ReferenceError` here exactly as it would in production, instead
|
|
328
|
-
* of silently working against Node's globals and only failing on deploy.
|
|
329
|
-
* (`console` is provided by a shim the transpiler compiles into each bundle.)
|
|
330
|
-
*/
|
|
331
|
-
getLogicContext() {
|
|
332
|
-
if (!this.logicContext) {
|
|
333
|
-
this.logicContext = createContext({});
|
|
334
|
-
}
|
|
335
|
-
return this.logicContext;
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
function resolveResourceDirectory(packagePath, rootDirectory, logicDirectory) {
|
|
339
|
-
if (isAbsolute2(rootDirectory)) {
|
|
340
|
-
return join(rootDirectory, logicDirectory);
|
|
341
|
-
}
|
|
342
|
-
return join(packagePath, rootDirectory, logicDirectory);
|
|
343
|
-
}
|
|
344
|
-
function isPrecompiled(rootDirectory, entrypoint) {
|
|
345
|
-
return isAbsolute2(rootDirectory) && entrypoint.endsWith(".js");
|
|
346
|
-
}
|
|
258
|
+
// cli/execution/scenario-gates.ts
|
|
259
|
+
import { existsSync } from "fs";
|
|
260
|
+
import { readFile } from "fs/promises";
|
|
347
261
|
|
|
348
262
|
// cli/runtime/context-merge.ts
|
|
349
263
|
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -1304,6 +1218,269 @@ var LogicCalls = class {
|
|
|
1304
1218
|
}
|
|
1305
1219
|
};
|
|
1306
1220
|
|
|
1221
|
+
// cli/execution/logic-loader.ts
|
|
1222
|
+
import { isAbsolute as isAbsolute2, join } from "node:path";
|
|
1223
|
+
import { compileFunction, createContext } from "node:vm";
|
|
1224
|
+
var LogicLoader = class {
|
|
1225
|
+
constructor(packagePath, deps) {
|
|
1226
|
+
this.packagePath = packagePath;
|
|
1227
|
+
this.deps = deps;
|
|
1228
|
+
}
|
|
1229
|
+
packagePath;
|
|
1230
|
+
deps;
|
|
1231
|
+
caches = {
|
|
1232
|
+
engine: /* @__PURE__ */ new Map(),
|
|
1233
|
+
tickController: /* @__PURE__ */ new Map(),
|
|
1234
|
+
hook: /* @__PURE__ */ new Map(),
|
|
1235
|
+
validator: /* @__PURE__ */ new Map(),
|
|
1236
|
+
endpoint: /* @__PURE__ */ new Map()
|
|
1237
|
+
};
|
|
1238
|
+
logicContext;
|
|
1239
|
+
/** Each evaluated bundle's source map, to read a thrown stack back to source. */
|
|
1240
|
+
sourceMaps = new SourceMapRegistry();
|
|
1241
|
+
/**
|
|
1242
|
+
* Load the logic exports for `identifier` of the given `kind`, from cache
|
|
1243
|
+
* when present. `resource` is the bundle whose logic to compile; a missing
|
|
1244
|
+
* resource throws `notFoundMessage`.
|
|
1245
|
+
*/
|
|
1246
|
+
async load(kind, identifier, resource, notFoundMessage) {
|
|
1247
|
+
const cache = this.caches[kind];
|
|
1248
|
+
const cached = cache.get(identifier);
|
|
1249
|
+
if (cached) {
|
|
1250
|
+
return cached;
|
|
1251
|
+
}
|
|
1252
|
+
if (!resource) {
|
|
1253
|
+
throw new Error(notFoundMessage);
|
|
1254
|
+
}
|
|
1255
|
+
const logicDirectory = resolveResourceDirectory(
|
|
1256
|
+
this.packagePath,
|
|
1257
|
+
resource.rootDirectory,
|
|
1258
|
+
resource.logic.directory
|
|
1259
|
+
);
|
|
1260
|
+
const logicPath = join(logicDirectory, resource.logic.entrypoint);
|
|
1261
|
+
const bundledCode = isPrecompiled(resource.rootDirectory, resource.logic.entrypoint) ? await this.deps.fs.readFile(logicPath, "utf-8") : await this.deps.transpile({
|
|
1262
|
+
entrypoint: logicPath,
|
|
1263
|
+
sourcemap: true,
|
|
1264
|
+
packageRoot: this.packagePath
|
|
1265
|
+
});
|
|
1266
|
+
this.sourceMaps.register(logicPath, bundledCode);
|
|
1267
|
+
const moduleObj = { exports: {} };
|
|
1268
|
+
const func = compileFunction(bundledCode, ["module", "exports"], {
|
|
1269
|
+
filename: logicPath,
|
|
1270
|
+
parsingContext: this.getLogicContext()
|
|
1271
|
+
});
|
|
1272
|
+
func(moduleObj, moduleObj.exports);
|
|
1273
|
+
const exports = moduleObj.exports;
|
|
1274
|
+
cache.set(identifier, exports);
|
|
1275
|
+
return exports;
|
|
1276
|
+
}
|
|
1277
|
+
/** Drop every cached bundle (used when configuration or code reloads). */
|
|
1278
|
+
clearAll() {
|
|
1279
|
+
for (const cache of Object.values(this.caches)) {
|
|
1280
|
+
cache.clear();
|
|
1281
|
+
}
|
|
1282
|
+
this.sourceMaps.clear();
|
|
1283
|
+
}
|
|
1284
|
+
/** Drop a single cached bundle so its next load re-transpiles it. */
|
|
1285
|
+
invalidate(kind, identifier) {
|
|
1286
|
+
this.caches[kind].delete(identifier);
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* The shared bare-V8 global scope every logic bundle is evaluated in.
|
|
1290
|
+
*
|
|
1291
|
+
* A fresh vm context exposes only the ECMAScript intrinsics — the
|
|
1292
|
+
* environment the production runtime guarantees (SPECIFICATION.md §3.2).
|
|
1293
|
+
* Host globals such as `structuredClone`, `fetch`, `setTimeout`,
|
|
1294
|
+
* `TextEncoder`, and `process` are absent, so logic that reaches for one
|
|
1295
|
+
* throws a `ReferenceError` here exactly as it would in production, instead
|
|
1296
|
+
* of silently working against Node's globals and only failing on deploy.
|
|
1297
|
+
* (`console` is provided by a shim the transpiler compiles into each bundle.)
|
|
1298
|
+
*/
|
|
1299
|
+
getLogicContext() {
|
|
1300
|
+
if (!this.logicContext) {
|
|
1301
|
+
this.logicContext = createContext({});
|
|
1302
|
+
}
|
|
1303
|
+
return this.logicContext;
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1306
|
+
function resolveResourceDirectory(packagePath, rootDirectory, logicDirectory) {
|
|
1307
|
+
if (isAbsolute2(rootDirectory)) {
|
|
1308
|
+
return join(rootDirectory, logicDirectory);
|
|
1309
|
+
}
|
|
1310
|
+
return join(packagePath, rootDirectory, logicDirectory);
|
|
1311
|
+
}
|
|
1312
|
+
function isPrecompiled(rootDirectory, entrypoint) {
|
|
1313
|
+
return isAbsolute2(rootDirectory) && entrypoint.endsWith(".js");
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
// cli/execution/scenario-gates.ts
|
|
1317
|
+
var SCENARIO_VALIDATION = "scenario-validation";
|
|
1318
|
+
var SCENARIO_FILES = "scenario-files";
|
|
1319
|
+
var SESSION_VALIDATION = "session-validation";
|
|
1320
|
+
function isBlocking(problem) {
|
|
1321
|
+
return problem.failed === true || problem.level !== "warning";
|
|
1322
|
+
}
|
|
1323
|
+
var OVERRUN_RETRIES = 1;
|
|
1324
|
+
function onlyOverran(problems) {
|
|
1325
|
+
const blocking = problems.filter(isBlocking);
|
|
1326
|
+
return blocking.length > 0 && blocking.every((problem) => problem.overran === true);
|
|
1327
|
+
}
|
|
1328
|
+
async function withOverrunRetry(judge) {
|
|
1329
|
+
let problems = await judge();
|
|
1330
|
+
for (let retry = 0; retry < OVERRUN_RETRIES && onlyOverran(problems); retry += 1) {
|
|
1331
|
+
problems = await judge();
|
|
1332
|
+
}
|
|
1333
|
+
return problems;
|
|
1334
|
+
}
|
|
1335
|
+
function partitionProblems(problems) {
|
|
1336
|
+
return {
|
|
1337
|
+
blocking: problems.filter(isBlocking),
|
|
1338
|
+
warnings: problems.filter((problem) => !isBlocking(problem))
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
function hasScenarioGate(config) {
|
|
1342
|
+
return (config.validators ?? []).some((v) => v.definition.gates?.includes("scenario"));
|
|
1343
|
+
}
|
|
1344
|
+
async function runScenarioGates(options) {
|
|
1345
|
+
const { config } = options;
|
|
1346
|
+
if (!hasScenarioGate(config)) return [];
|
|
1347
|
+
const loader = options.loader ?? new LogicLoader(options.packagePath, {
|
|
1348
|
+
transpile: Transpile,
|
|
1349
|
+
fs: { existsSync, readFile }
|
|
1350
|
+
});
|
|
1351
|
+
const resolved = resolveSettingsLayers(
|
|
1352
|
+
config,
|
|
1353
|
+
options.scenarioSettings,
|
|
1354
|
+
options.sessionOverrides ?? null
|
|
1355
|
+
);
|
|
1356
|
+
const locale = options.locale ?? config.game?.definition.supportedLocales?.[0] ?? "en";
|
|
1357
|
+
const readsFiles = (config.requires ?? []).includes(SCENARIO_FILES);
|
|
1358
|
+
const problems = [];
|
|
1359
|
+
for (const validator of config.validators ?? []) {
|
|
1360
|
+
if (!validator.definition.gates?.includes("scenario")) continue;
|
|
1361
|
+
const identifier = validator.definition.identifier;
|
|
1362
|
+
const declared = validator.definition.settings ?? [];
|
|
1363
|
+
const pick = (values) => Object.fromEntries(
|
|
1364
|
+
declared.filter((id) => values[id] !== void 0).map((id) => [id, values[id]])
|
|
1365
|
+
);
|
|
1366
|
+
try {
|
|
1367
|
+
const exports = await loader.load(
|
|
1368
|
+
"validator",
|
|
1369
|
+
identifier,
|
|
1370
|
+
validator,
|
|
1371
|
+
`Validator ${identifier} not found in configuration`
|
|
1372
|
+
);
|
|
1373
|
+
const gate = exports.Scenario;
|
|
1374
|
+
if (!gate) {
|
|
1375
|
+
problems.push({
|
|
1376
|
+
validatorIdentifier: identifier,
|
|
1377
|
+
failed: true,
|
|
1378
|
+
message: `Validator ${identifier} does not export Scenario`
|
|
1379
|
+
});
|
|
1380
|
+
continue;
|
|
1381
|
+
}
|
|
1382
|
+
const found = await withBound(
|
|
1383
|
+
gate({
|
|
1384
|
+
settings: structuredClone(pick(resolved)),
|
|
1385
|
+
locale,
|
|
1386
|
+
callbacks: readsFiles ? scenarioCallbacks(
|
|
1387
|
+
options.packagePath,
|
|
1388
|
+
options.files ?? { scenarioRoot: null, blobs: "none" }
|
|
1389
|
+
) : withoutScenarioFiles(identifier)
|
|
1390
|
+
}),
|
|
1391
|
+
options.boundMs ?? DEFAULT_LOGIC_EXECUTION_BOUND_MS
|
|
1392
|
+
);
|
|
1393
|
+
if (!Array.isArray(found)) {
|
|
1394
|
+
problems.push({
|
|
1395
|
+
validatorIdentifier: identifier,
|
|
1396
|
+
failed: true,
|
|
1397
|
+
message: `Validator ${identifier}'s Scenario returned ${JSON.stringify(found)}, not an array of problems (an empty array passes)`
|
|
1398
|
+
});
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
for (const problem of found) {
|
|
1402
|
+
problems.push({
|
|
1403
|
+
validatorIdentifier: identifier,
|
|
1404
|
+
message: problem.message,
|
|
1405
|
+
...problem.path === void 0 ? {} : { path: problem.path },
|
|
1406
|
+
...problem.level === "warning" ? { level: "warning" } : {}
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
} catch (error) {
|
|
1410
|
+
problems.push(
|
|
1411
|
+
error instanceof GateOverrun ? {
|
|
1412
|
+
validatorIdentifier: identifier,
|
|
1413
|
+
failed: true,
|
|
1414
|
+
overran: true,
|
|
1415
|
+
message: `Validator ${identifier} ${error.message}`
|
|
1416
|
+
} : {
|
|
1417
|
+
validatorIdentifier: identifier,
|
|
1418
|
+
failed: true,
|
|
1419
|
+
message: `Validator ${identifier} threw: ${errorMessage(error, String(error))}`
|
|
1420
|
+
}
|
|
1421
|
+
);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return problems;
|
|
1425
|
+
}
|
|
1426
|
+
function scenarioCallbacks(packagePath, files) {
|
|
1427
|
+
const unreadable = async (reference) => {
|
|
1428
|
+
if (!reference.startsWith("blob:") || files.blobs === "all") return false;
|
|
1429
|
+
if (files.blobs === "none") return true;
|
|
1430
|
+
const blob = await describeBlob(packagePath, reference.slice("blob:".length));
|
|
1431
|
+
return blob !== void 0 && blob.retention !== "scenario";
|
|
1432
|
+
};
|
|
1433
|
+
return {
|
|
1434
|
+
readAsset: async (reference) => {
|
|
1435
|
+
if (await unreadable(reference)) {
|
|
1436
|
+
throw new Error(`Cannot read "${reference}": the scenario cannot name that file`);
|
|
1437
|
+
}
|
|
1438
|
+
const described = await describeAssetByReference(
|
|
1439
|
+
packagePath,
|
|
1440
|
+
files.scenarioRoot,
|
|
1441
|
+
reference
|
|
1442
|
+
);
|
|
1443
|
+
if (described && described.size > SCENARIO_GATE_READ_LIMIT_BYTES) {
|
|
1444
|
+
throw new ScenarioAssetTooLargeError(reference, described.size);
|
|
1445
|
+
}
|
|
1446
|
+
const asset = await readAssetByReference(packagePath, files.scenarioRoot, reference);
|
|
1447
|
+
return { data: new Uint8Array(asset.data), mimeType: asset.mimeType, name: asset.name };
|
|
1448
|
+
},
|
|
1449
|
+
describeAsset: async (reference) => await unreadable(reference) ? void 0 : describeAssetByReference(packagePath, files.scenarioRoot, reference)
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
function withoutScenarioFiles(identifier) {
|
|
1453
|
+
const refuse = (callback) => async () => {
|
|
1454
|
+
throw new Error(
|
|
1455
|
+
`Validator "${identifier}" called ${callback} in its Scenario gate, which needs the "${SCENARIO_FILES}" feature, but requires does not list it. Add "${SCENARIO_FILES}" to requires in seriousgaming.sdk.json.`
|
|
1456
|
+
);
|
|
1457
|
+
};
|
|
1458
|
+
return { readAsset: refuse("readAsset"), describeAsset: refuse("describeAsset") };
|
|
1459
|
+
}
|
|
1460
|
+
var GateOverrun = class extends Error {
|
|
1461
|
+
};
|
|
1462
|
+
async function withBound(run, boundMs) {
|
|
1463
|
+
let timer;
|
|
1464
|
+
try {
|
|
1465
|
+
return await Promise.race([
|
|
1466
|
+
run,
|
|
1467
|
+
new Promise((_, reject) => {
|
|
1468
|
+
timer = setTimeout(
|
|
1469
|
+
() => reject(new GateOverrun(`did not finish within ${boundMs}ms`)),
|
|
1470
|
+
boundMs
|
|
1471
|
+
);
|
|
1472
|
+
})
|
|
1473
|
+
]);
|
|
1474
|
+
} finally {
|
|
1475
|
+
if (timer) clearTimeout(timer);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
function describeScenarioProblems(problems) {
|
|
1479
|
+
return problems.map(
|
|
1480
|
+
(p) => `${p.level === "warning" ? "Warning: " : ""}${p.path ? `${p.path}: ` : ""}${p.message} (validator "${p.validatorIdentifier}")`
|
|
1481
|
+
);
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1307
1484
|
// cli/runtime/capability-scope.ts
|
|
1308
1485
|
function resolveCapabilityScope(definition) {
|
|
1309
1486
|
return definition.scope ?? "team";
|
|
@@ -1313,7 +1490,6 @@ export {
|
|
|
1313
1490
|
deepMergeContext,
|
|
1314
1491
|
applyContextUpdate,
|
|
1315
1492
|
ConfigResolver,
|
|
1316
|
-
resolveSettingsLayers,
|
|
1317
1493
|
applySchemaDefaults,
|
|
1318
1494
|
TtsClient,
|
|
1319
1495
|
DocumentParserClient,
|
|
@@ -1327,5 +1503,15 @@ export {
|
|
|
1327
1503
|
DEFAULT_TICK_EXECUTION_BOUND_MS,
|
|
1328
1504
|
LogicCalls,
|
|
1329
1505
|
LogicLoader,
|
|
1506
|
+
SCENARIO_VALIDATION,
|
|
1507
|
+
SCENARIO_FILES,
|
|
1508
|
+
SESSION_VALIDATION,
|
|
1509
|
+
isBlocking,
|
|
1510
|
+
onlyOverran,
|
|
1511
|
+
withOverrunRetry,
|
|
1512
|
+
partitionProblems,
|
|
1513
|
+
hasScenarioGate,
|
|
1514
|
+
runScenarioGates,
|
|
1515
|
+
describeScenarioProblems,
|
|
1330
1516
|
resolveCapabilityScope
|
|
1331
1517
|
};
|