@seriousgaming/sdk-tools 1.10.0 → 1.12.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 +35 -23
- package/dist/{cli-F2D4GGUA.js → cli-2BKEIIA3.js} +66 -0
- package/dist/{cli-NQSL2CIH.js → cli-2QGTDHRX.js} +21 -21
- package/dist/{cli-33MZSPPK.js → cli-2SDG3SZ7.js} +21 -21
- package/dist/{cli-CLO7HKEQ.js → cli-2VXP34R5.js} +5 -3
- package/dist/{cli-P3NUTOPK.js → cli-2W4B6PD5.js} +1 -1
- package/dist/{cli-SOO6SEIS.js → cli-2X7DKSXN.js} +28 -25
- package/dist/{cli-LNEZ6KDW.js → cli-2ZP4N7HK.js} +19 -19
- package/dist/{cli-5O7XENQY.js → cli-3GJYZH4C.js} +5 -5
- package/dist/{cli-NAZTYKZT.js → cli-3GO3M2MX.js} +30 -14
- package/dist/{cli-YZJBFKRI.js → cli-3LDLUNME.js} +17 -17
- package/dist/{cli-J42N4PJG.js → cli-3WY6L2WP.js} +31 -29
- package/dist/{cli-WG7MAOCS.js → cli-44MBABRD.js} +25 -25
- package/dist/{cli-MGZYQDCH.js → cli-4IO7MKLR.js} +20 -20
- package/dist/{cli-HNDFANQG.js → cli-4U2PY7W3.js} +1 -1
- package/dist/{cli-4JNF3O5N.js → cli-4WI4LTBI.js} +2 -2
- package/dist/{cli-OTBCA54D.js → cli-55EIGGZK.js} +1 -1
- package/dist/{cli-5TKPT3CY.js → cli-5AQV6FTL.js} +18 -18
- package/dist/{cli-KNXY43YV.js → cli-5CW7BEU7.js} +3 -3
- package/dist/{cli-5V4N4BR4.js → cli-5JUVHNZF.js} +12 -12
- package/dist/{cli-F3YJKP6D.js → cli-5KERL6HV.js} +9 -4
- package/dist/{cli-HN442ZVK.js → cli-5KSA24NQ.js} +24 -24
- package/dist/{cli-5VZBFMCK.js → cli-5PIFO3EN.js} +8 -0
- package/dist/{cli-IQBY7Z7Q.js → cli-5QN2Z43X.js} +20 -20
- package/dist/cli-5XSPAA5X.js +69 -0
- package/dist/{cli-QW7VXL2V.js → cli-62KAYGXO.js} +20 -20
- package/dist/{cli-TDLIPYKT.js → cli-6IMV5ZZU.js} +26 -26
- package/dist/{cli-UULZSQBV.js → cli-6KWCIAN2.js} +764 -66
- package/dist/{cli-2ANX6E3A.js → cli-6NWETIX5.js} +20 -20
- package/dist/{cli-EXUPHPDJ.js → cli-774W3MN5.js} +26 -26
- package/dist/cli-7BUD3VAD.js +16 -0
- package/dist/{cli-7NUFHMGE.js → cli-7KEP57S7.js} +12 -12
- package/dist/{cli-6CYAOUYT.js → cli-7OYFJMA6.js} +18 -18
- package/dist/{cli-ILHHJR2S.js → cli-7ZNEDQ3G.js} +20 -20
- package/dist/{cli-5RRPUL6V.js → cli-AFK6OUID.js} +12 -12
- package/dist/{cli-A3AJQZEN.js → cli-AIYQFWXN.js} +25 -25
- package/dist/{cli-B5DWKRZ4.js → cli-ARAAEWIQ.js} +2 -2
- package/dist/cli-AVQYV3N4.js +36 -0
- package/dist/{cli-35GV2F6R.js → cli-B54Z6CXH.js} +16 -16
- package/dist/{cli-467VRXGP.js → cli-B5TC4MEL.js} +5 -5
- package/dist/{cli-5Z4D3F6Y.js → cli-BCXGOLU3.js} +3 -3
- package/dist/{cli-G2GLW5Z4.js → cli-BHAODVTZ.js} +1 -1
- package/dist/{cli-XR3O2YTV.js → cli-BPS2JG74.js} +20 -20
- package/dist/{cli-W3RG2MRI.js → cli-BVO55SR2.js} +2 -2
- package/dist/{cli-PYAST3G5.js → cli-CFH3JZP5.js} +21 -21
- package/dist/{cli-VZVHS5AP.js → cli-CTK2OIK6.js} +20 -20
- package/dist/{cli-ATWJCB2G.js → cli-CW5MV4VX.js} +4 -4
- package/dist/{cli-TCQJL2GY.js → cli-D5VOSJZ7.js} +1 -1
- package/dist/{cli-KIZTASLL.js → cli-DAEPMK7A.js} +5 -5
- package/dist/{cli-44CM2AH2.js → cli-DAHR7PKB.js} +1 -1
- package/dist/{cli-XW3JLRSA.js → cli-DWDSBTYL.js} +1 -1
- package/dist/cli-DYSDPGXW.js +95 -0
- package/dist/{cli-GRSQRFRG.js → cli-DZCLRZXJ.js} +9 -2
- package/dist/{cli-RSF5R3HC.js → cli-EJ47IE45.js} +28 -25
- package/dist/{cli-QDBYFITU.js → cli-EK4OSJHA.js} +2 -2
- package/dist/{cli-GO64NABP.js → cli-FCJHNXDA.js} +1 -1
- package/dist/{cli-ZNQBF4Z3.js → cli-FNESSE3L.js} +1 -1
- package/dist/{cli-MUOLHQNL.js → cli-FTLH4WCE.js} +17 -17
- package/dist/{cli-JHLWBRXB.js → cli-FYV77YS2.js} +18 -18
- package/dist/cli-GMJX6Q4Q.js +36 -0
- package/dist/{cli-7JUNA74L.js → cli-GRBVNGDW.js} +1 -1
- package/dist/{cli-XKAIDYIE.js → cli-HAFCFY77.js} +33 -19
- package/dist/{cli-OXLOGXT3.js → cli-HCJLYI24.js} +3 -3
- package/dist/{cli-HHRP6FP6.js → cli-HCXS5EXU.js} +25 -25
- package/dist/cli-HEUNNHDH.js +36 -0
- package/dist/{cli-36GABN2A.js → cli-HNUTIWDZ.js} +19 -19
- package/dist/{cli-JXQLHJO2.js → cli-HXT25ETJ.js} +244 -243
- package/dist/{cli-5EH4WTH4.js → cli-IGEL7UJQ.js} +5 -5
- package/dist/{cli-JMNPMDXH.js → cli-IO32YA5N.js} +26 -26
- package/dist/cli-IPTGZDBB.js +36 -0
- package/dist/{cli-L54SXUK6.js → cli-J25TYFKB.js} +19 -19
- package/dist/{cli-CQ4ZR3ZQ.js → cli-J7XYMEMX.js} +20 -20
- package/dist/{cli-5DWR7RPQ.js → cli-JC5OJRID.js} +2 -2
- package/dist/{cli-25SJZI7N.js → cli-JD563OF4.js} +126 -27
- package/dist/{cli-JAVMRERQ.js → cli-JRJF2WHU.js} +20 -20
- package/dist/{cli-UQC46YSV.js → cli-JTFLIMIG.js} +3 -3
- package/dist/{cli-2AH6D32V.js → cli-K2BSJ2PK.js} +2 -2
- package/dist/{cli-XB5PI2XT.js → cli-K4QTYMN2.js} +25 -25
- package/dist/{cli-5SHG2M7E.js → cli-KFJDD4C4.js} +20 -20
- package/dist/{cli-WW54THXN.js → cli-KVQ2JPVD.js} +1 -1
- package/dist/{cli-O5WYATAI.js → cli-L6AHMW2Z.js} +4 -2
- package/dist/{cli-IKSLPAZN.js → cli-LCYUBCVY.js} +4 -4
- package/dist/{cli-HGCOEL5T.js → cli-LEWSCDH5.js} +4 -4
- package/dist/{cli-HNG6PZW2.js → cli-LI6G7GND.js} +27 -27
- package/dist/{cli-2AVPNSAX.js → cli-LU2GCWIU.js} +21 -21
- package/dist/{cli-UEQMK4WX.js → cli-M3Z2KOEB.js} +1 -1
- package/dist/{cli-226ZJ72R.js → cli-M6E3E3I2.js} +170 -3
- package/dist/{cli-OXU6TTEN.js → cli-MCRPA4Z6.js} +20 -20
- package/dist/{cli-BQ36DV5C.js → cli-MI2DEDMA.js} +3 -3
- package/dist/{cli-6O7YCK2M.js → cli-MITZ6SE7.js} +3 -3
- package/dist/{cli-VALLLE6Y.js → cli-MTIYD3BX.js} +26 -26
- package/dist/{cli-5M6KDNVX.js → cli-MTZUJGBK.js} +2 -2
- package/dist/{cli-GSOV26O5.js → cli-NCLMUXLC.js} +14 -14
- package/dist/{cli-Z3DITVBE.js → cli-NLS3DKWH.js} +26 -26
- package/dist/{cli-AH6AMAIB.js → cli-NMDGS7IE.js} +1 -1
- package/dist/cli-O3DJO2CS.js +30 -0
- package/dist/{cli-BC67QHD5.js → cli-O47D5BFN.js} +2 -2
- package/dist/{cli-MDVC5ZNM.js → cli-OBRZ36VP.js} +14 -14
- package/dist/{cli-267QJ2DS.js → cli-OMG4E53H.js} +20 -20
- package/dist/{cli-C32Q5E5I.js → cli-P6V3NSU4.js} +1 -1
- package/dist/{cli-PBSLPO6G.js → cli-PAMQMTHK.js} +21 -21
- package/dist/{cli-RUEPTOWG.js → cli-PKTHOCT3.js} +26 -26
- package/dist/{cli-PTXOKO2Y.js → cli-QK7QAP5H.js} +18 -18
- package/dist/cli-QQ432JEN.js +36 -0
- package/dist/{cli-YFLQ7XOO.js → cli-QVNDPTBU.js} +20 -20
- package/dist/{cli-KJA6GLZI.js → cli-R2DFD6ZZ.js} +15 -15
- package/dist/{cli-6BLVI2JM.js → cli-RMVJMOWU.js} +111 -7
- package/dist/{cli-M6AZFIMV.js → cli-RQISHMJF.js} +88 -23
- package/dist/{cli-X64BNBQH.js → cli-RVZH462G.js} +585 -8
- package/dist/{cli-LLJQI2QP.js → cli-SEEOQVUL.js} +12 -12
- package/dist/{cli-QTCTWYCM.js → cli-SO354HPI.js} +3 -3
- package/dist/{cli-URCHZDTS.js → cli-T76HDH7F.js} +90 -5
- package/dist/{cli-ZJW6HQ6N.js → cli-TIS7DWRR.js} +7 -7
- package/dist/{cli-WOFYI7HZ.js → cli-TY3B6XS7.js} +21 -21
- package/dist/{cli-4FJL3KQZ.js → cli-UKEZJFIT.js} +2 -2
- package/dist/cli-VQAMW4RF.js +95 -0
- package/dist/{cli-4A7RWFNO.js → cli-W4LMRVZT.js} +78 -47
- package/dist/cli-W7I5KGIB.js +84 -0
- package/dist/{cli-B3EFE7ZF.js → cli-WXGJFA4F.js} +1 -1
- package/dist/{cli-IPTHJT3J.js → cli-XCG33I77.js} +28 -25
- package/dist/{cli-WLSACMYA.js → cli-YHLSG5HB.js} +30 -28
- package/dist/cli-YNH5DTHY.js +36 -0
- package/dist/cli-YPMJWPDA.js +69 -0
- package/dist/{cli-PXQYY6KM.js → cli-YSXIR7EM.js} +0 -0
- package/dist/cli-ZPFWO4VW.js +85 -0
- package/dist/cli.js +53 -53
- package/dist/client/index.d.ts +1 -1
- package/dist/client/test-session.d.ts +44 -6
- package/dist/client.js +1934 -286
- package/dist/core/assessment-moves.d.ts +32 -0
- package/dist/core/assessment-reports.d.ts +38 -0
- package/dist/core/assessment-settings.d.ts +15 -0
- package/dist/core/benchmark-samples.d.ts +28 -0
- package/dist/core/session-host.d.ts +4 -0
- package/dist/core/session-roster.d.ts +6 -0
- package/dist/core/session-timers.d.ts +40 -0
- package/dist/core/session.d.ts +14 -1
- package/dist/core/tick-timer.d.ts +18 -0
- package/dist/dev/console/assets/{index-Ch6HHb2T.js → index-zd--5H1f.js} +26 -26
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/shell.d.ts +8 -0
- package/dist/dev/view/commands.d.ts +3 -1
- package/dist/docs/api/index.md +4 -2
- package/dist/docs/api/sdk-commands.md +29 -0
- package/dist/docs/api/sdk-e2e.md +30 -0
- package/dist/docs/api/sdk-projection.md +5 -0
- package/dist/docs/api/sdk-tools-client.md +68 -6
- package/dist/docs/api/sdk-tools-vite.md +21 -0
- package/dist/docs/api/sdk-ui.md +7 -0
- package/dist/docs/api/sdk.md +834 -19
- package/dist/docs/changelog.md +67 -0
- package/dist/docs/cli-error-codes.md +5 -1
- package/dist/docs/cli-reference.md +76 -2
- package/dist/docs/concepts/index.md +2 -0
- package/dist/docs/concepts/terminology.md +12 -0
- package/dist/docs/guides/assessments.md +248 -0
- package/dist/docs/guides/benchmarks.md +241 -0
- package/dist/docs/guides/endpoints.md +1 -1
- package/dist/docs/guides/engine-testing.md +49 -14
- package/dist/docs/guides/engine.md +10 -2
- package/dist/docs/guides/index.md +2 -0
- package/dist/docs/guides/presentation.md +11 -9
- package/dist/docs/guides/session-hooks.md +24 -22
- package/dist/docs/guides/testing.md +3 -8
- package/dist/docs/guides/tick-controller.md +22 -1
- package/dist/docs/guides/ui.md +24 -0
- package/dist/docs/guides/upgrading.md +36 -0
- package/dist/docs/page-index.md +18 -13
- package/dist/docs/recipes/create-assessment.md +124 -0
- package/dist/docs/recipes/create-benchmark.md +115 -0
- package/dist/docs/recipes/create-game.md +1 -1
- package/dist/docs/recipes/fix-duplicate-packages.md +8 -19
- package/dist/docs/recipes/index.md +2 -0
- package/dist/execution/context-composition.d.ts +39 -4
- package/dist/execution/engine-state.d.ts +13 -0
- package/dist/execution/executor.d.ts +16 -0
- package/dist/execution/logic-result.d.ts +13 -2
- package/dist/help-examples.d.ts +12 -0
- package/dist/host/adapter.d.ts +24 -1
- package/dist/host/protocol.d.ts +115 -1
- package/dist/host.js +29 -1
- package/dist/oxlint/logic.json +184 -0
- package/dist/playwright.js +1928 -280
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +298 -16
- package/dist/schema.json +189 -0
- package/dist/templates/package/README.md.liquid +1 -0
- package/dist/templates/package/claude/rules/workflow-create-engine.md +1 -1
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +2 -2
- package/dist/templates/package/claude/settings.json.template +1 -0
- package/dist/templates/package/oxfmtrc.json.template +8 -1
- package/dist/templates/package/oxlintrc.json.template +1 -180
- package/dist/templates/package/package.json.liquid +1 -0
- package/dist/templates/package/vite.config.ts.liquid +2 -8
- package/dist/templates/package/vitest.config.ts.liquid +2 -8
- package/dist/templates/starter-game/package.json +2 -1
- package/dist/templates/starter-game/testing/engine/game.engine.test.ts +62 -37
- package/dist/templates/starter-game/vite.config.ts +2 -8
- package/dist/templates/starter-game/vitest.config.ts +4 -3
- package/dist/templating/resource-metadata.d.ts +1 -1
- package/dist/utils/error-codes.d.ts +9 -1
- package/dist/utils/resource-scan.d.ts +5 -0
- package/dist/validation/assessment-validation.d.ts +34 -0
- package/dist/validation/benchmark-validation.d.ts +20 -0
- package/dist/validation/schema-validation.d.ts +4 -0
- package/dist/vite/index.d.ts +30 -0
- package/dist/vite.js +12 -0
- package/package.json +12 -4
- package/dist/cli-27Z5T52R.js +0 -30
- package/dist/cli-5XE4OMFL.js +0 -36
- package/dist/cli-BB6CU4ZC.js +0 -36
- package/dist/cli-FGP6YYM7.js +0 -36
- package/dist/cli-I3ZAZYWP.js +0 -36
- package/dist/cli-RFAPPYXK.js +0 -36
- package/dist/cli-WZNIW6ZO.js +0 -16
- package/dist/cli-XEEOJGBL.js +0 -36
package/dist/playwright.js
CHANGED
|
@@ -46,7 +46,7 @@ var require_extend = __commonJS({
|
|
|
46
46
|
}
|
|
47
47
|
return toStr.call(arr) === "[object Array]";
|
|
48
48
|
};
|
|
49
|
-
var
|
|
49
|
+
var isPlainObject4 = function isPlainObject5(obj) {
|
|
50
50
|
if (!obj || toStr.call(obj) !== "[object Object]") {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
@@ -103,12 +103,12 @@ var require_extend = __commonJS({
|
|
|
103
103
|
src = getProperty(target, name);
|
|
104
104
|
copy = getProperty(options, name);
|
|
105
105
|
if (target !== copy) {
|
|
106
|
-
if (deep && copy && (
|
|
106
|
+
if (deep && copy && (isPlainObject4(copy) || (copyIsArray = isArray(copy)))) {
|
|
107
107
|
if (copyIsArray) {
|
|
108
108
|
copyIsArray = false;
|
|
109
109
|
clone = src && isArray(src) ? src : [];
|
|
110
110
|
} else {
|
|
111
|
-
clone = src &&
|
|
111
|
+
clone = src && isPlainObject4(src) ? src : {};
|
|
112
112
|
}
|
|
113
113
|
setProperty(target, { name, newValue: extend2(deep, clone, copy) });
|
|
114
114
|
} else if (typeof copy !== "undefined") {
|
|
@@ -155,6 +155,39 @@ var BASES = [
|
|
|
155
155
|
mergeDefinition: true,
|
|
156
156
|
referencedByReadsWrites: true
|
|
157
157
|
},
|
|
158
|
+
{
|
|
159
|
+
type: "benchmark",
|
|
160
|
+
pluralDir: "benchmarks",
|
|
161
|
+
bundleFile: "benchmark.sdk.json",
|
|
162
|
+
manifestKey: "benchmarks",
|
|
163
|
+
kind: "composition",
|
|
164
|
+
label: "Benchmark",
|
|
165
|
+
// Only the engine writes benchmarks, so it is the one referrer: a
|
|
166
|
+
// benchmark anywhere else would let a participant or a facilitator
|
|
167
|
+
// move the figures every other session is compared with.
|
|
168
|
+
sites: [
|
|
169
|
+
{
|
|
170
|
+
referrerKeys: ["engine"],
|
|
171
|
+
shape: { kind: "stringArray", path: "benchmarks", labelSuffix: "benchmarks" }
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "assessment",
|
|
177
|
+
pluralDir: "assessments",
|
|
178
|
+
bundleFile: "assessment.sdk.json",
|
|
179
|
+
manifestKey: "assessments",
|
|
180
|
+
kind: "composition",
|
|
181
|
+
label: "Assessment",
|
|
182
|
+
// Only the engine scores, so it is the one referrer: a score written
|
|
183
|
+
// anywhere else could be a participant marking their own work.
|
|
184
|
+
sites: [
|
|
185
|
+
{
|
|
186
|
+
referrerKeys: ["engine"],
|
|
187
|
+
shape: { kind: "stringArray", path: "assessments", labelSuffix: "assessments" }
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
},
|
|
158
191
|
{
|
|
159
192
|
type: "engine",
|
|
160
193
|
slot: "engine",
|
|
@@ -545,6 +578,14 @@ var ERROR_CODES = {
|
|
|
545
578
|
category: "package",
|
|
546
579
|
description: "The package uses an optional feature its manifest's `requires` does not list, so a runtime without the feature would run it with part of it missing."
|
|
547
580
|
},
|
|
581
|
+
BENCHMARK_UNWRITTEN: {
|
|
582
|
+
category: "package",
|
|
583
|
+
description: "A benchmark is not in the engine's `benchmarks`, so nothing writes it and it never holds a value. A warning."
|
|
584
|
+
},
|
|
585
|
+
ASSESSMENT_UNWRITTEN: {
|
|
586
|
+
category: "package",
|
|
587
|
+
description: "An assessment is not in the engine's `assessments`, so nothing scores it and it never holds a result. A warning."
|
|
588
|
+
},
|
|
548
589
|
REFERENCE_UNKNOWN: {
|
|
549
590
|
category: "package",
|
|
550
591
|
description: "A `reads`, `writes`, `settings`, `configures` or `endpoints` entry names something the package does not declare."
|
|
@@ -893,6 +934,16 @@ function distPath(meta, identifier) {
|
|
|
893
934
|
return `${meta.pluralDir}/${identifier}`;
|
|
894
935
|
}
|
|
895
936
|
|
|
937
|
+
// cli/vite/index.ts
|
|
938
|
+
var REACT_CONTEXT_PACKAGES = [
|
|
939
|
+
"react",
|
|
940
|
+
"react-dom",
|
|
941
|
+
"@emotion/react",
|
|
942
|
+
"@emotion/styled",
|
|
943
|
+
"@seriousgaming/sdk",
|
|
944
|
+
"@seriousgaming/deck"
|
|
945
|
+
];
|
|
946
|
+
|
|
896
947
|
// cli/bundling/ui-bundler.ts
|
|
897
948
|
async function bundleUserInterface(ui, workingDir, buildDir, type) {
|
|
898
949
|
const uiOutputDir = join(buildDir, distPath(getResourceMeta(type), ui.definition.identifier));
|
|
@@ -918,7 +969,7 @@ async function bundleUserInterface(ui, workingDir, buildDir, type) {
|
|
|
918
969
|
configFile: false,
|
|
919
970
|
plugins: [react()],
|
|
920
971
|
resolve: {
|
|
921
|
-
dedupe: [
|
|
972
|
+
dedupe: [...REACT_CONTEXT_PACKAGES]
|
|
922
973
|
},
|
|
923
974
|
build: {
|
|
924
975
|
outDir: uiOutputDir,
|
|
@@ -950,6 +1001,352 @@ import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
|
950
1001
|
import { readFile, readdir } from "fs/promises";
|
|
951
1002
|
import { basename, dirname, join as join3, relative as relative2, sep as sep2 } from "path";
|
|
952
1003
|
|
|
1004
|
+
// ../sdk/lib/build/callbacks.js
|
|
1005
|
+
var UndeclaredApiUseError = class extends Error {
|
|
1006
|
+
resourceIdentifier;
|
|
1007
|
+
api;
|
|
1008
|
+
constructor(resourceIdentifier, api) {
|
|
1009
|
+
super(`Resource "${resourceIdentifier}" attempted to call callback "${api}" but did not declare it in its bundle's "uses" array. Add "${api}" to the bundle's uses to allow this call.`);
|
|
1010
|
+
this.name = "UndeclaredApiUseError";
|
|
1011
|
+
this.resourceIdentifier = resourceIdentifier;
|
|
1012
|
+
this.api = api;
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
// ../sdk/lib/build/tick-validation.js
|
|
1017
|
+
var MAX_EFFECTIVE_TICK_INTERVAL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
1018
|
+
|
|
1019
|
+
// ../sdk/lib/build/setting-path.js
|
|
1020
|
+
var NOT_PLAIN = /[.[\]"\s]/u;
|
|
1021
|
+
function isPlainKey(key) {
|
|
1022
|
+
return key !== "" && !NOT_PLAIN.test(key);
|
|
1023
|
+
}
|
|
1024
|
+
function settingPath(identifier, ...keys) {
|
|
1025
|
+
let path3 = isPlainKey(identifier) ? identifier : `[${JSON.stringify(identifier)}]`;
|
|
1026
|
+
for (const key of keys) {
|
|
1027
|
+
const step = String(key);
|
|
1028
|
+
path3 += isPlainKey(step) ? `.${step}` : `[${JSON.stringify(step)}]`;
|
|
1029
|
+
}
|
|
1030
|
+
return path3;
|
|
1031
|
+
}
|
|
1032
|
+
function parseSettingPath(path3) {
|
|
1033
|
+
const steps = [];
|
|
1034
|
+
let at = 0;
|
|
1035
|
+
while (at < path3.length) {
|
|
1036
|
+
if (path3[at] === "[") {
|
|
1037
|
+
const end2 = closingQuote(path3, at + 1);
|
|
1038
|
+
if (end2 === void 0 || path3[end2 + 1] !== "]")
|
|
1039
|
+
return void 0;
|
|
1040
|
+
let key2;
|
|
1041
|
+
try {
|
|
1042
|
+
key2 = JSON.parse(path3.slice(at + 1, end2 + 1));
|
|
1043
|
+
} catch {
|
|
1044
|
+
return void 0;
|
|
1045
|
+
}
|
|
1046
|
+
if (typeof key2 !== "string")
|
|
1047
|
+
return void 0;
|
|
1048
|
+
steps.push(key2);
|
|
1049
|
+
at = end2 + 2;
|
|
1050
|
+
continue;
|
|
1051
|
+
}
|
|
1052
|
+
if (steps.length > 0) {
|
|
1053
|
+
if (path3[at] !== ".")
|
|
1054
|
+
return void 0;
|
|
1055
|
+
at += 1;
|
|
1056
|
+
}
|
|
1057
|
+
let end = at;
|
|
1058
|
+
while (end < path3.length && path3[end] !== "." && path3[end] !== "[")
|
|
1059
|
+
end += 1;
|
|
1060
|
+
const key = path3.slice(at, end);
|
|
1061
|
+
if (!isPlainKey(key))
|
|
1062
|
+
return void 0;
|
|
1063
|
+
steps.push(key);
|
|
1064
|
+
at = end;
|
|
1065
|
+
}
|
|
1066
|
+
const [identifier, ...keys] = steps;
|
|
1067
|
+
return identifier === void 0 ? void 0 : { identifier, keys };
|
|
1068
|
+
}
|
|
1069
|
+
function closingQuote(path3, start) {
|
|
1070
|
+
if (path3[start] !== '"')
|
|
1071
|
+
return void 0;
|
|
1072
|
+
for (let at = start + 1; at < path3.length; at += 1) {
|
|
1073
|
+
if (path3[at] === "\\")
|
|
1074
|
+
at += 1;
|
|
1075
|
+
else if (path3[at] === '"')
|
|
1076
|
+
return at;
|
|
1077
|
+
}
|
|
1078
|
+
return void 0;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// ../sdk/lib/build/validators.js
|
|
1082
|
+
var SCENARIO_GATE_READ_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
1083
|
+
var ScenarioAssetTooLargeError = class _ScenarioAssetTooLargeError extends Error {
|
|
1084
|
+
/** The reference the gate asked to read. */
|
|
1085
|
+
reference;
|
|
1086
|
+
/** The file's size in bytes. */
|
|
1087
|
+
size;
|
|
1088
|
+
/** The cap it exceeds: {@link SCENARIO_GATE_READ_LIMIT_BYTES}. */
|
|
1089
|
+
limit;
|
|
1090
|
+
constructor(reference, size) {
|
|
1091
|
+
super(`Cannot read "${reference}" in a Scenario gate: it is ${size} bytes, over the ${SCENARIO_GATE_READ_LIMIT_BYTES}-byte (10 MB) limit on a gate's reads. Call describeAsset to check that it is there or how large it is.`);
|
|
1092
|
+
this.name = "ScenarioAssetTooLargeError";
|
|
1093
|
+
this.reference = reference;
|
|
1094
|
+
this.size = size;
|
|
1095
|
+
this.limit = SCENARIO_GATE_READ_LIMIT_BYTES;
|
|
1096
|
+
Object.setPrototypeOf(this, _ScenarioAssetTooLargeError.prototype);
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
// ../sdk/lib/build/benchmarks.js
|
|
1101
|
+
var BENCHMARKS_FEATURE = "benchmarks";
|
|
1102
|
+
var BENCHMARK_TAG_VALUE_PATTERN = /^[A-Za-z0-9:._-]{1,64}$/;
|
|
1103
|
+
var MAX_BENCHMARKS_PER_GAME = 20;
|
|
1104
|
+
function resolveBenchmarkLevel(definition3) {
|
|
1105
|
+
return definition3.level ?? "team";
|
|
1106
|
+
}
|
|
1107
|
+
function isRecord(value) {
|
|
1108
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1109
|
+
}
|
|
1110
|
+
function benchmarkWriteProblem(definition3, write) {
|
|
1111
|
+
if (write === null)
|
|
1112
|
+
return null;
|
|
1113
|
+
if (!isRecord(write))
|
|
1114
|
+
return "must be an object, or null to remove the record";
|
|
1115
|
+
for (const [name, value] of Object.entries(write)) {
|
|
1116
|
+
if (value === void 0 || value === null)
|
|
1117
|
+
continue;
|
|
1118
|
+
if (name === "tags") {
|
|
1119
|
+
if (!isRecord(value))
|
|
1120
|
+
return `"tags" must be an object of tag values`;
|
|
1121
|
+
const declared = definition3.tags ?? [];
|
|
1122
|
+
for (const [tag, tagValue] of Object.entries(value)) {
|
|
1123
|
+
if (!declared.includes(tag)) {
|
|
1124
|
+
return declared.length === 0 ? `tag "${tag}" is not declared: the benchmark declares no tags` : `tag "${tag}" is not declared; declared tags are ${declared.map((t) => `"${t}"`).join(", ")}`;
|
|
1125
|
+
}
|
|
1126
|
+
if (tagValue === void 0 || tagValue === null)
|
|
1127
|
+
continue;
|
|
1128
|
+
if (typeof tagValue !== "string" || !BENCHMARK_TAG_VALUE_PATTERN.test(tagValue)) {
|
|
1129
|
+
return `tag "${tag}" must be 1 to 64 characters of letters, digits, ':', '.', '_' or '-', got ${JSON.stringify(tagValue)}`;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
if (name === "excluded") {
|
|
1135
|
+
if (typeof value !== "boolean") {
|
|
1136
|
+
return `"excluded" must be a boolean, got ${JSON.stringify(value)}`;
|
|
1137
|
+
}
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
const field = definition3.fields[name];
|
|
1141
|
+
if (!field)
|
|
1142
|
+
return `field "${name}" is not declared`;
|
|
1143
|
+
if ("type" in field) {
|
|
1144
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1145
|
+
return `field "${name}" must be a finite number, got ${JSON.stringify(value)}`;
|
|
1146
|
+
}
|
|
1147
|
+
} else if (typeof value !== "string" || !field.enum.includes(value)) {
|
|
1148
|
+
return `field "${name}" must be one of ${field.enum.map((o) => JSON.stringify(o)).join(", ")}, got ${JSON.stringify(value)}`;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
return null;
|
|
1152
|
+
}
|
|
1153
|
+
function applyBenchmarkWrite(current, write) {
|
|
1154
|
+
if (write === null)
|
|
1155
|
+
return void 0;
|
|
1156
|
+
const next = { ...current };
|
|
1157
|
+
for (const [name, value] of Object.entries(write)) {
|
|
1158
|
+
if (value === void 0)
|
|
1159
|
+
continue;
|
|
1160
|
+
if (value === null) {
|
|
1161
|
+
delete next[name];
|
|
1162
|
+
} else if (name === "tags" && isRecord(value)) {
|
|
1163
|
+
const tags = Object.fromEntries(Object.entries(value).filter(([, tagValue]) => typeof tagValue === "string"));
|
|
1164
|
+
if (Object.keys(tags).length === 0)
|
|
1165
|
+
delete next.tags;
|
|
1166
|
+
else
|
|
1167
|
+
next.tags = tags;
|
|
1168
|
+
} else {
|
|
1169
|
+
next[name] = value;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return Object.keys(next).length === 0 ? void 0 : next;
|
|
1173
|
+
}
|
|
1174
|
+
function benchmarkFilters(query) {
|
|
1175
|
+
const where3 = query?.where;
|
|
1176
|
+
const filters = where3 === void 0 ? [{}] : Array.isArray(where3) ? where3 : [where3];
|
|
1177
|
+
if (filters.length === 0) {
|
|
1178
|
+
throw new Error('getBenchmark: "where" must hold at least one filter');
|
|
1179
|
+
}
|
|
1180
|
+
for (const filter of filters) {
|
|
1181
|
+
if (!isRecord(filter) || Object.values(filter).some((v) => typeof v !== "string")) {
|
|
1182
|
+
throw new Error("getBenchmark: each filter must be an object of tag names to strings");
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return filters.map((filter) => ({ ...filter }));
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
// ../sdk/lib/build/assessments.js
|
|
1189
|
+
var ASSESSMENTS_FEATURE = "assessments";
|
|
1190
|
+
var ASSESSMENTS_SETTINGS = "assessments";
|
|
1191
|
+
var MAX_ASSESSMENTS_PER_GAME = 20;
|
|
1192
|
+
var ASSESSMENT_FEEDBACK_MAX_LENGTH = 500;
|
|
1193
|
+
function isRecord2(value) {
|
|
1194
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1195
|
+
}
|
|
1196
|
+
function foldRecord(definition3, current, write) {
|
|
1197
|
+
if (write === null)
|
|
1198
|
+
return { next: void 0 };
|
|
1199
|
+
if (!isRecord2(write))
|
|
1200
|
+
return { problem: "must be an object, or null to remove the result" };
|
|
1201
|
+
const next = isRecord2(current) ? { ...current } : {};
|
|
1202
|
+
for (const [name, value] of Object.entries(write)) {
|
|
1203
|
+
if (value === void 0)
|
|
1204
|
+
continue;
|
|
1205
|
+
if (name === "score") {
|
|
1206
|
+
if (value === null)
|
|
1207
|
+
return { problem: '"score" cannot be removed; remove the result' };
|
|
1208
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1209
|
+
return { problem: `"score" must be a finite number, got ${JSON.stringify(value)}` };
|
|
1210
|
+
}
|
|
1211
|
+
if (value < definition3.min || value > definition3.max) {
|
|
1212
|
+
return {
|
|
1213
|
+
problem: `"score" must be between ${definition3.min} and ${definition3.max}, got ${value}`
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
next.score = value;
|
|
1217
|
+
} else if (name === "feedback") {
|
|
1218
|
+
if (value === null) {
|
|
1219
|
+
delete next.feedback;
|
|
1220
|
+
} else if (typeof value !== "string") {
|
|
1221
|
+
return { problem: `"feedback" must be a string, got ${JSON.stringify(value)}` };
|
|
1222
|
+
} else if (value.length > ASSESSMENT_FEEDBACK_MAX_LENGTH) {
|
|
1223
|
+
return {
|
|
1224
|
+
problem: `"feedback" must be at most ${ASSESSMENT_FEEDBACK_MAX_LENGTH} characters, got ${value.length}`
|
|
1225
|
+
};
|
|
1226
|
+
} else {
|
|
1227
|
+
next.feedback = value;
|
|
1228
|
+
}
|
|
1229
|
+
} else if (name === "final") {
|
|
1230
|
+
if (value === null) {
|
|
1231
|
+
delete next.final;
|
|
1232
|
+
} else if (typeof value !== "boolean") {
|
|
1233
|
+
return { problem: `"final" must be a boolean, got ${JSON.stringify(value)}` };
|
|
1234
|
+
} else if (value) {
|
|
1235
|
+
next.final = true;
|
|
1236
|
+
} else {
|
|
1237
|
+
delete next.final;
|
|
1238
|
+
}
|
|
1239
|
+
} else {
|
|
1240
|
+
return {
|
|
1241
|
+
problem: `"${name}" is not a field of a result; use score, feedback or final`
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (next.score === void 0) {
|
|
1246
|
+
return { problem: 'a result needs a "score", and this write leaves it without one' };
|
|
1247
|
+
}
|
|
1248
|
+
return { next };
|
|
1249
|
+
}
|
|
1250
|
+
function foldAssessmentWrite(definition3, current, write, participantIds) {
|
|
1251
|
+
if (definition3.level === "team")
|
|
1252
|
+
return foldRecord(definition3, current, write);
|
|
1253
|
+
if (write === null)
|
|
1254
|
+
return { next: void 0 };
|
|
1255
|
+
if (!isRecord2(write)) {
|
|
1256
|
+
return {
|
|
1257
|
+
problem: "must be an object of results by participant id, or null to remove every result"
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
const records = isRecord2(current) ? { ...current } : {};
|
|
1261
|
+
for (const [participantId, recordWrite] of Object.entries(write)) {
|
|
1262
|
+
if (recordWrite === void 0)
|
|
1263
|
+
continue;
|
|
1264
|
+
if (recordWrite !== null && !participantIds.has(participantId)) {
|
|
1265
|
+
return {
|
|
1266
|
+
problem: `participant "${participantId}" is not on this team, so it cannot be scored here`
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
const folded = foldRecord(definition3, records[participantId], recordWrite);
|
|
1270
|
+
if ("problem" in folded) {
|
|
1271
|
+
return { problem: `participant "${participantId}": ${folded.problem}` };
|
|
1272
|
+
}
|
|
1273
|
+
if (folded.next === void 0)
|
|
1274
|
+
delete records[participantId];
|
|
1275
|
+
else
|
|
1276
|
+
records[participantId] = folded.next;
|
|
1277
|
+
}
|
|
1278
|
+
return { next: Object.keys(records).length === 0 ? void 0 : records };
|
|
1279
|
+
}
|
|
1280
|
+
function resolveAssessmentBands(definition3, settings) {
|
|
1281
|
+
return (definition3.bands ?? []).map((band) => {
|
|
1282
|
+
const override = settings?.[band.id];
|
|
1283
|
+
return {
|
|
1284
|
+
id: band.id,
|
|
1285
|
+
from: typeof override?.from === "number" ? override.from : band.from,
|
|
1286
|
+
passing: typeof override?.passing === "boolean" ? override.passing : band.passing === true
|
|
1287
|
+
};
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
function assessmentBandOf(score, bands) {
|
|
1291
|
+
let found = null;
|
|
1292
|
+
for (const band of bands)
|
|
1293
|
+
if (band.from <= score)
|
|
1294
|
+
found = band;
|
|
1295
|
+
return found;
|
|
1296
|
+
}
|
|
1297
|
+
function buildAssessmentReport(input) {
|
|
1298
|
+
const { definition: definition3, bands, teams, participants, audience } = input;
|
|
1299
|
+
const result = (record2, teamId, complete, participantId) => {
|
|
1300
|
+
if (!isRecord2(record2) || typeof record2.score !== "number")
|
|
1301
|
+
return null;
|
|
1302
|
+
const band = assessmentBandOf(record2.score, bands);
|
|
1303
|
+
const span = definition3.max - definition3.min;
|
|
1304
|
+
return {
|
|
1305
|
+
teamId,
|
|
1306
|
+
...participantId === void 0 ? {} : { participantId },
|
|
1307
|
+
score: record2.score,
|
|
1308
|
+
scaled: span > 0 ? (record2.score - definition3.min) / span : 0,
|
|
1309
|
+
band: band?.id ?? null,
|
|
1310
|
+
passed: band === null ? null : band.passing,
|
|
1311
|
+
...typeof record2.feedback === "string" ? { feedback: record2.feedback } : {},
|
|
1312
|
+
final: record2.final === true || complete
|
|
1313
|
+
};
|
|
1314
|
+
};
|
|
1315
|
+
const results = [];
|
|
1316
|
+
if (definition3.level === "team") {
|
|
1317
|
+
for (const team of teams) {
|
|
1318
|
+
if (audience.kind !== "all" && audience.teamId !== team.teamId)
|
|
1319
|
+
continue;
|
|
1320
|
+
const row = result(team.records, team.teamId, team.complete);
|
|
1321
|
+
if (row)
|
|
1322
|
+
results.push(row);
|
|
1323
|
+
}
|
|
1324
|
+
} else {
|
|
1325
|
+
const byTeam = new Map(teams.map((team) => [team.teamId, team]));
|
|
1326
|
+
for (const participant of participants) {
|
|
1327
|
+
if (audience.kind === "team" && audience.teamId !== participant.teamId)
|
|
1328
|
+
continue;
|
|
1329
|
+
if (audience.kind === "participant" && audience.participantId !== participant.id) {
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
const team = byTeam.get(participant.teamId);
|
|
1333
|
+
if (!team || !isRecord2(team.records))
|
|
1334
|
+
continue;
|
|
1335
|
+
const row = result(team.records[participant.id], team.teamId, team.complete, participant.id);
|
|
1336
|
+
if (row)
|
|
1337
|
+
results.push(row);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
return {
|
|
1341
|
+
identifier: definition3.identifier,
|
|
1342
|
+
level: definition3.level,
|
|
1343
|
+
min: definition3.min,
|
|
1344
|
+
max: definition3.max,
|
|
1345
|
+
bands: bands.map((band) => ({ ...band })),
|
|
1346
|
+
results
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
|
|
953
1350
|
// cli/bundling/logic-exports.ts
|
|
954
1351
|
import { existsSync } from "fs";
|
|
955
1352
|
|
|
@@ -1150,6 +1547,56 @@ async function readLogicExports(filePath, names, packageRoot) {
|
|
|
1150
1547
|
}
|
|
1151
1548
|
}
|
|
1152
1549
|
|
|
1550
|
+
// cli/core/assessment-settings.ts
|
|
1551
|
+
function assessmentSettingsResource(assessments) {
|
|
1552
|
+
const properties = {};
|
|
1553
|
+
for (const { definition: definition3 } of assessments) {
|
|
1554
|
+
const bands = definition3.bands ?? [];
|
|
1555
|
+
if (bands.length === 0) continue;
|
|
1556
|
+
const bandProperties = {};
|
|
1557
|
+
const defaults = {};
|
|
1558
|
+
for (const band of bands) {
|
|
1559
|
+
const value = { from: band.from, passing: band.passing === true };
|
|
1560
|
+
defaults[band.id] = value;
|
|
1561
|
+
bandProperties[band.id] = {
|
|
1562
|
+
type: "object",
|
|
1563
|
+
title: band.id,
|
|
1564
|
+
properties: {
|
|
1565
|
+
from: {
|
|
1566
|
+
type: "number",
|
|
1567
|
+
title: "Lowest score",
|
|
1568
|
+
minimum: definition3.min,
|
|
1569
|
+
maximum: definition3.max,
|
|
1570
|
+
default: value.from
|
|
1571
|
+
},
|
|
1572
|
+
passing: { type: "boolean", title: "Counts as a pass", default: value.passing }
|
|
1573
|
+
},
|
|
1574
|
+
additionalProperties: false,
|
|
1575
|
+
default: value
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
properties[definition3.identifier] = {
|
|
1579
|
+
type: "object",
|
|
1580
|
+
title: definition3.identifier,
|
|
1581
|
+
...definition3.description ? { description: definition3.description } : {},
|
|
1582
|
+
properties: bandProperties,
|
|
1583
|
+
additionalProperties: false,
|
|
1584
|
+
default: defaults
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
if (Object.keys(properties).length === 0) return null;
|
|
1588
|
+
return {
|
|
1589
|
+
definition: {
|
|
1590
|
+
identifier: ASSESSMENTS_SETTINGS,
|
|
1591
|
+
settingsSchema: {
|
|
1592
|
+
type: "object",
|
|
1593
|
+
properties,
|
|
1594
|
+
additionalProperties: false
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1153
1600
|
// ../schema.json
|
|
1154
1601
|
var schema_default = {
|
|
1155
1602
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -1306,6 +1753,24 @@ var schema_default = {
|
|
|
1306
1753
|
},
|
|
1307
1754
|
uniqueItems: true
|
|
1308
1755
|
},
|
|
1756
|
+
benchmarks: {
|
|
1757
|
+
type: "array",
|
|
1758
|
+
description: "Identifiers of the benchmarks this engine writes. The engine alone writes benchmarks: it receives its current records as `benchmarks`, beside `context`, and returns writes under `benchmarks`, beside `capabilities`. A game that declares any lists the `benchmarks` feature in `requires`",
|
|
1759
|
+
items: {
|
|
1760
|
+
type: "string",
|
|
1761
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1762
|
+
},
|
|
1763
|
+
uniqueItems: true
|
|
1764
|
+
},
|
|
1765
|
+
assessments: {
|
|
1766
|
+
type: "array",
|
|
1767
|
+
description: "Identifiers of the assessments this engine scores. The engine alone writes assessments: it receives its team's current results as `assessments`, beside `context`, and returns writes under `assessments`, beside `capabilities`. A game that declares any lists the `assessments` feature in `requires`",
|
|
1768
|
+
items: {
|
|
1769
|
+
type: "string",
|
|
1770
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1771
|
+
},
|
|
1772
|
+
uniqueItems: true
|
|
1773
|
+
},
|
|
1309
1774
|
aggregate: {
|
|
1310
1775
|
type: "boolean",
|
|
1311
1776
|
description: "Generated, not authored. True when the engine's logic exports InitAggregate and RunAggregate, in which case it runs once across all teams rather than per-team via Run, and may write to shared capabilities. The build derives this from the exports and writes it into the bundled manifest; authoring it in engine.sdk.json is an error.",
|
|
@@ -1315,6 +1780,163 @@ var schema_default = {
|
|
|
1315
1780
|
required: ["identifier"],
|
|
1316
1781
|
additionalProperties: false
|
|
1317
1782
|
},
|
|
1783
|
+
BenchmarkField: {
|
|
1784
|
+
description: "One field of a benchmark: a number, pooled as a distribution, or one of a short declared list of options, pooled as a count per option",
|
|
1785
|
+
oneOf: [
|
|
1786
|
+
{
|
|
1787
|
+
type: "object",
|
|
1788
|
+
properties: {
|
|
1789
|
+
type: { const: "number" },
|
|
1790
|
+
description: { type: "string" }
|
|
1791
|
+
},
|
|
1792
|
+
required: ["type"],
|
|
1793
|
+
additionalProperties: false
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
type: "object",
|
|
1797
|
+
properties: {
|
|
1798
|
+
enum: {
|
|
1799
|
+
type: "array",
|
|
1800
|
+
description: "The options a record may hold. Closed and short, so nothing free-form leaves the session",
|
|
1801
|
+
items: {
|
|
1802
|
+
type: "string",
|
|
1803
|
+
pattern: "^[A-Za-z0-9_-]{1,64}$"
|
|
1804
|
+
},
|
|
1805
|
+
minItems: 1,
|
|
1806
|
+
maxItems: 20,
|
|
1807
|
+
uniqueItems: true
|
|
1808
|
+
},
|
|
1809
|
+
description: { type: "string" }
|
|
1810
|
+
},
|
|
1811
|
+
required: ["enum"],
|
|
1812
|
+
additionalProperties: false
|
|
1813
|
+
}
|
|
1814
|
+
]
|
|
1815
|
+
},
|
|
1816
|
+
BenchmarkDefinition: {
|
|
1817
|
+
type: "object",
|
|
1818
|
+
description: "Definition of a benchmark: outcomes and decisions the engine records for each team (or the session), which a runtime pools anonymously across sessions so a user interface can compare a team with everyone who has played",
|
|
1819
|
+
properties: {
|
|
1820
|
+
identifier: {
|
|
1821
|
+
type: "string",
|
|
1822
|
+
description: "Identifier for the benchmark: its directory name",
|
|
1823
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1824
|
+
},
|
|
1825
|
+
revision: {
|
|
1826
|
+
type: "integer",
|
|
1827
|
+
minimum: 1,
|
|
1828
|
+
description: "Results are pooled per revision. Bump it when a change makes earlier results no longer comparable; leave it alone across ordinary releases so the pool carries on"
|
|
1829
|
+
},
|
|
1830
|
+
level: {
|
|
1831
|
+
type: "string",
|
|
1832
|
+
enum: ["team", "session"],
|
|
1833
|
+
default: "team",
|
|
1834
|
+
description: "'team' (default): one record per team, written by Run or under an aggregate result's teams. 'session': one record for the whole session, written only under an aggregate result's shared"
|
|
1835
|
+
},
|
|
1836
|
+
tags: {
|
|
1837
|
+
type: "array",
|
|
1838
|
+
description: "The names a record can be grouped by. The engine sets each one's value, a short string, and a user interface filters on any combination of them",
|
|
1839
|
+
items: {
|
|
1840
|
+
type: "string",
|
|
1841
|
+
pattern: "^[A-Za-z][A-Za-z0-9_]*$"
|
|
1842
|
+
},
|
|
1843
|
+
maxItems: 5,
|
|
1844
|
+
uniqueItems: true
|
|
1845
|
+
},
|
|
1846
|
+
fields: {
|
|
1847
|
+
type: "object",
|
|
1848
|
+
description: "The benchmark's fields, flat. 'tags' and 'excluded' are reserved",
|
|
1849
|
+
additionalProperties: { $ref: "#/$defs/BenchmarkField" },
|
|
1850
|
+
propertyNames: {
|
|
1851
|
+
pattern: "^[A-Za-z][A-Za-z0-9_]*$",
|
|
1852
|
+
not: { enum: ["tags", "excluded"] }
|
|
1853
|
+
},
|
|
1854
|
+
minProperties: 1,
|
|
1855
|
+
maxProperties: 20
|
|
1856
|
+
}
|
|
1857
|
+
},
|
|
1858
|
+
required: ["identifier", "revision", "fields"],
|
|
1859
|
+
additionalProperties: false
|
|
1860
|
+
},
|
|
1861
|
+
SDKBenchmark: {
|
|
1862
|
+
type: "object",
|
|
1863
|
+
description: "Bundle containing a benchmark definition",
|
|
1864
|
+
properties: {
|
|
1865
|
+
definition: { $ref: "#/$defs/BenchmarkDefinition" }
|
|
1866
|
+
},
|
|
1867
|
+
required: ["definition"],
|
|
1868
|
+
additionalProperties: false
|
|
1869
|
+
},
|
|
1870
|
+
AssessmentBand: {
|
|
1871
|
+
type: "object",
|
|
1872
|
+
description: "One band of an assessment's scores, such as 'developing' or 'expert': every score from `from` up to the next band's `from`",
|
|
1873
|
+
properties: {
|
|
1874
|
+
id: {
|
|
1875
|
+
type: "string",
|
|
1876
|
+
description: "The band's identifier, reported with each result in it. A user interface shows its own label for it",
|
|
1877
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1878
|
+
},
|
|
1879
|
+
from: {
|
|
1880
|
+
type: "number",
|
|
1881
|
+
description: "The lowest score in the band. Bands are listed in ascending order of `from`, and the first starts at the assessment's `min`. A default: the built-in `assessments` settings let a scenario or a session move it"
|
|
1882
|
+
},
|
|
1883
|
+
passing: {
|
|
1884
|
+
type: "boolean",
|
|
1885
|
+
description: "Whether a score in this band is a pass. A default, which the built-in `assessments` settings let a scenario or a session change",
|
|
1886
|
+
default: false
|
|
1887
|
+
},
|
|
1888
|
+
description: {
|
|
1889
|
+
type: "string",
|
|
1890
|
+
description: "What the band means, for whoever reads the game's results"
|
|
1891
|
+
}
|
|
1892
|
+
},
|
|
1893
|
+
required: ["id", "from"],
|
|
1894
|
+
additionalProperties: false
|
|
1895
|
+
},
|
|
1896
|
+
AssessmentDefinition: {
|
|
1897
|
+
type: "object",
|
|
1898
|
+
description: "Definition of an assessment: one measure the engine scores for each participant, or for each team, which a runtime may report to a learning management system. The score is the game's; the runtime places it in a band and decides pass or fail from the band",
|
|
1899
|
+
properties: {
|
|
1900
|
+
identifier: {
|
|
1901
|
+
type: "string",
|
|
1902
|
+
description: "Identifier for the assessment: its directory name",
|
|
1903
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1904
|
+
},
|
|
1905
|
+
description: {
|
|
1906
|
+
type: "string",
|
|
1907
|
+
description: "What the assessment measures, for whoever reads the game's results"
|
|
1908
|
+
},
|
|
1909
|
+
level: {
|
|
1910
|
+
type: "string",
|
|
1911
|
+
enum: ["participant", "team"],
|
|
1912
|
+
description: "'participant': one score per participant, written for each by participant id. 'team': one score per team, which every participant on the team receives"
|
|
1913
|
+
},
|
|
1914
|
+
min: {
|
|
1915
|
+
type: "number",
|
|
1916
|
+
description: "The lowest score the engine may write"
|
|
1917
|
+
},
|
|
1918
|
+
max: {
|
|
1919
|
+
type: "number",
|
|
1920
|
+
description: "The highest score the engine may write. Greater than `min`"
|
|
1921
|
+
},
|
|
1922
|
+
bands: {
|
|
1923
|
+
type: "array",
|
|
1924
|
+
description: "The ranges a score falls into, ascending, the first starting at `min`: at most 10. Without bands, a result has no band and no pass or fail",
|
|
1925
|
+
items: { $ref: "#/$defs/AssessmentBand" }
|
|
1926
|
+
}
|
|
1927
|
+
},
|
|
1928
|
+
required: ["identifier", "level", "min", "max"],
|
|
1929
|
+
additionalProperties: false
|
|
1930
|
+
},
|
|
1931
|
+
SDKAssessment: {
|
|
1932
|
+
type: "object",
|
|
1933
|
+
description: "Bundle containing an assessment definition",
|
|
1934
|
+
properties: {
|
|
1935
|
+
definition: { $ref: "#/$defs/AssessmentDefinition" }
|
|
1936
|
+
},
|
|
1937
|
+
required: ["definition"],
|
|
1938
|
+
additionalProperties: false
|
|
1939
|
+
},
|
|
1318
1940
|
CapabilityDefinition: {
|
|
1319
1941
|
type: "object",
|
|
1320
1942
|
description: "Definition of a capability",
|
|
@@ -2343,6 +2965,14 @@ var schema_default = {
|
|
|
2343
2965
|
type: "array",
|
|
2344
2966
|
items: { $ref: "#/$defs/SDKCapability" }
|
|
2345
2967
|
},
|
|
2968
|
+
benchmarks: {
|
|
2969
|
+
type: "array",
|
|
2970
|
+
items: { $ref: "#/$defs/SDKBenchmark" }
|
|
2971
|
+
},
|
|
2972
|
+
assessments: {
|
|
2973
|
+
type: "array",
|
|
2974
|
+
items: { $ref: "#/$defs/SDKAssessment" }
|
|
2975
|
+
},
|
|
2346
2976
|
settings: {
|
|
2347
2977
|
type: "array",
|
|
2348
2978
|
items: { $ref: "#/$defs/SDKSettings" }
|
|
@@ -2729,6 +3359,12 @@ var schema_default = {
|
|
|
2729
3359
|
SDKPackage: { $ref: "#/$defs/SDKPackage" },
|
|
2730
3360
|
SDKEngine: { $ref: "#/$defs/SDKEngine" },
|
|
2731
3361
|
SDKCapability: { $ref: "#/$defs/SDKCapability" },
|
|
3362
|
+
BenchmarkField: { $ref: "#/$defs/BenchmarkField" },
|
|
3363
|
+
BenchmarkDefinition: { $ref: "#/$defs/BenchmarkDefinition" },
|
|
3364
|
+
SDKBenchmark: { $ref: "#/$defs/SDKBenchmark" },
|
|
3365
|
+
AssessmentBand: { $ref: "#/$defs/AssessmentBand" },
|
|
3366
|
+
AssessmentDefinition: { $ref: "#/$defs/AssessmentDefinition" },
|
|
3367
|
+
SDKAssessment: { $ref: "#/$defs/SDKAssessment" },
|
|
2732
3368
|
SDKScenario: { $ref: "#/$defs/SDKScenario" },
|
|
2733
3369
|
SDKUserInterface: { $ref: "#/$defs/SDKUserInterface" },
|
|
2734
3370
|
SDKSetup: {
|
|
@@ -2900,7 +3536,11 @@ var SUPPORTED_FEATURES = [
|
|
|
2900
3536
|
// File reads in a validator's `Scenario` gate (§15.8).
|
|
2901
3537
|
"scenario-files",
|
|
2902
3538
|
// The `Scenario` gate judging a session as it starts, and refusing it (§15.8).
|
|
2903
|
-
"session-validation"
|
|
3539
|
+
"session-validation",
|
|
3540
|
+
// Benchmarks: engine-written records pooled across sessions (§6.16).
|
|
3541
|
+
"benchmarks",
|
|
3542
|
+
// Assessments: engine-written scores per participant or team, in bands (§6.17).
|
|
3543
|
+
"assessments"
|
|
2904
3544
|
];
|
|
2905
3545
|
function unsupportedFeatures(manifest) {
|
|
2906
3546
|
return (manifest.requires ?? []).filter((feature) => !SUPPORTED_FEATURES.includes(feature));
|
|
@@ -2930,102 +3570,6 @@ function unsupportedServices(resources, supported = SUPPORTED_SERVICES) {
|
|
|
2930
3570
|
import { existsSync as existsSync2, readdirSync, readFileSync } from "fs";
|
|
2931
3571
|
import { join as join2 } from "path";
|
|
2932
3572
|
|
|
2933
|
-
// ../sdk/lib/build/callbacks.js
|
|
2934
|
-
var UndeclaredApiUseError = class extends Error {
|
|
2935
|
-
resourceIdentifier;
|
|
2936
|
-
api;
|
|
2937
|
-
constructor(resourceIdentifier, api) {
|
|
2938
|
-
super(`Resource "${resourceIdentifier}" attempted to call callback "${api}" but did not declare it in its bundle's "uses" array. Add "${api}" to the bundle's uses to allow this call.`);
|
|
2939
|
-
this.name = "UndeclaredApiUseError";
|
|
2940
|
-
this.resourceIdentifier = resourceIdentifier;
|
|
2941
|
-
this.api = api;
|
|
2942
|
-
}
|
|
2943
|
-
};
|
|
2944
|
-
|
|
2945
|
-
// ../sdk/lib/build/tick-validation.js
|
|
2946
|
-
var MAX_EFFECTIVE_TICK_INTERVAL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
2947
|
-
|
|
2948
|
-
// ../sdk/lib/build/setting-path.js
|
|
2949
|
-
var NOT_PLAIN = /[.[\]"\s]/u;
|
|
2950
|
-
function isPlainKey(key) {
|
|
2951
|
-
return key !== "" && !NOT_PLAIN.test(key);
|
|
2952
|
-
}
|
|
2953
|
-
function settingPath(identifier, ...keys) {
|
|
2954
|
-
let path3 = isPlainKey(identifier) ? identifier : `[${JSON.stringify(identifier)}]`;
|
|
2955
|
-
for (const key of keys) {
|
|
2956
|
-
const step = String(key);
|
|
2957
|
-
path3 += isPlainKey(step) ? `.${step}` : `[${JSON.stringify(step)}]`;
|
|
2958
|
-
}
|
|
2959
|
-
return path3;
|
|
2960
|
-
}
|
|
2961
|
-
function parseSettingPath(path3) {
|
|
2962
|
-
const steps = [];
|
|
2963
|
-
let at = 0;
|
|
2964
|
-
while (at < path3.length) {
|
|
2965
|
-
if (path3[at] === "[") {
|
|
2966
|
-
const end2 = closingQuote(path3, at + 1);
|
|
2967
|
-
if (end2 === void 0 || path3[end2 + 1] !== "]")
|
|
2968
|
-
return void 0;
|
|
2969
|
-
let key2;
|
|
2970
|
-
try {
|
|
2971
|
-
key2 = JSON.parse(path3.slice(at + 1, end2 + 1));
|
|
2972
|
-
} catch {
|
|
2973
|
-
return void 0;
|
|
2974
|
-
}
|
|
2975
|
-
if (typeof key2 !== "string")
|
|
2976
|
-
return void 0;
|
|
2977
|
-
steps.push(key2);
|
|
2978
|
-
at = end2 + 2;
|
|
2979
|
-
continue;
|
|
2980
|
-
}
|
|
2981
|
-
if (steps.length > 0) {
|
|
2982
|
-
if (path3[at] !== ".")
|
|
2983
|
-
return void 0;
|
|
2984
|
-
at += 1;
|
|
2985
|
-
}
|
|
2986
|
-
let end = at;
|
|
2987
|
-
while (end < path3.length && path3[end] !== "." && path3[end] !== "[")
|
|
2988
|
-
end += 1;
|
|
2989
|
-
const key = path3.slice(at, end);
|
|
2990
|
-
if (!isPlainKey(key))
|
|
2991
|
-
return void 0;
|
|
2992
|
-
steps.push(key);
|
|
2993
|
-
at = end;
|
|
2994
|
-
}
|
|
2995
|
-
const [identifier, ...keys] = steps;
|
|
2996
|
-
return identifier === void 0 ? void 0 : { identifier, keys };
|
|
2997
|
-
}
|
|
2998
|
-
function closingQuote(path3, start) {
|
|
2999
|
-
if (path3[start] !== '"')
|
|
3000
|
-
return void 0;
|
|
3001
|
-
for (let at = start + 1; at < path3.length; at += 1) {
|
|
3002
|
-
if (path3[at] === "\\")
|
|
3003
|
-
at += 1;
|
|
3004
|
-
else if (path3[at] === '"')
|
|
3005
|
-
return at;
|
|
3006
|
-
}
|
|
3007
|
-
return void 0;
|
|
3008
|
-
}
|
|
3009
|
-
|
|
3010
|
-
// ../sdk/lib/build/validators.js
|
|
3011
|
-
var SCENARIO_GATE_READ_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
3012
|
-
var ScenarioAssetTooLargeError = class _ScenarioAssetTooLargeError extends Error {
|
|
3013
|
-
/** The reference the gate asked to read. */
|
|
3014
|
-
reference;
|
|
3015
|
-
/** The file's size in bytes. */
|
|
3016
|
-
size;
|
|
3017
|
-
/** The cap it exceeds: {@link SCENARIO_GATE_READ_LIMIT_BYTES}. */
|
|
3018
|
-
limit;
|
|
3019
|
-
constructor(reference, size) {
|
|
3020
|
-
super(`Cannot read "${reference}" in a Scenario gate: it is ${size} bytes, over the ${SCENARIO_GATE_READ_LIMIT_BYTES}-byte (10 MB) limit on a gate's reads. Call describeAsset to check that it is there or how large it is.`);
|
|
3021
|
-
this.name = "ScenarioAssetTooLargeError";
|
|
3022
|
-
this.reference = reference;
|
|
3023
|
-
this.size = size;
|
|
3024
|
-
this.limit = SCENARIO_GATE_READ_LIMIT_BYTES;
|
|
3025
|
-
Object.setPrototypeOf(this, _ScenarioAssetTooLargeError.prototype);
|
|
3026
|
-
}
|
|
3027
|
-
};
|
|
3028
|
-
|
|
3029
3573
|
// ../node_modules/.pnpm/ccount@2.0.1/node_modules/ccount/index.js
|
|
3030
3574
|
function ccount(value, character) {
|
|
3031
3575
|
const source = String(value);
|
|
@@ -15697,6 +16241,70 @@ var capabilityExample = JSON.stringify(
|
|
|
15697
16241
|
null,
|
|
15698
16242
|
4
|
|
15699
16243
|
);
|
|
16244
|
+
var benchmarkExample = JSON.stringify(
|
|
16245
|
+
{
|
|
16246
|
+
definition: {
|
|
16247
|
+
identifier: "outcome",
|
|
16248
|
+
revision: 1,
|
|
16249
|
+
tags: ["difficulty"],
|
|
16250
|
+
fields: {
|
|
16251
|
+
NetProfit: { type: "number", description: "Profit over the whole game" },
|
|
16252
|
+
Round1Pricing: { enum: ["premium", "match", "discount"] }
|
|
16253
|
+
}
|
|
16254
|
+
}
|
|
16255
|
+
},
|
|
16256
|
+
null,
|
|
16257
|
+
4
|
|
16258
|
+
);
|
|
16259
|
+
var benchmarkUpdateExample = JSON.stringify(
|
|
16260
|
+
{
|
|
16261
|
+
definition: {
|
|
16262
|
+
identifier: "outcome",
|
|
16263
|
+
revision: 2,
|
|
16264
|
+
tags: ["difficulty", "teams"],
|
|
16265
|
+
fields: {
|
|
16266
|
+
NetProfit: { type: "number", description: "Profit over the whole game" }
|
|
16267
|
+
}
|
|
16268
|
+
}
|
|
16269
|
+
},
|
|
16270
|
+
null,
|
|
16271
|
+
4
|
|
16272
|
+
);
|
|
16273
|
+
var assessmentExample = JSON.stringify(
|
|
16274
|
+
{
|
|
16275
|
+
definition: {
|
|
16276
|
+
identifier: "teamwork",
|
|
16277
|
+
description: "How well each participant worked with their team",
|
|
16278
|
+
level: "participant",
|
|
16279
|
+
min: 0,
|
|
16280
|
+
max: 100,
|
|
16281
|
+
bands: [
|
|
16282
|
+
{ id: "developing", from: 0 },
|
|
16283
|
+
{ id: "competent", from: 50, passing: true },
|
|
16284
|
+
{ id: "expert", from: 80, passing: true }
|
|
16285
|
+
]
|
|
16286
|
+
}
|
|
16287
|
+
},
|
|
16288
|
+
null,
|
|
16289
|
+
4
|
|
16290
|
+
);
|
|
16291
|
+
var assessmentUpdateExample = JSON.stringify(
|
|
16292
|
+
{
|
|
16293
|
+
definition: {
|
|
16294
|
+
identifier: "teamwork",
|
|
16295
|
+
level: "participant",
|
|
16296
|
+
min: 0,
|
|
16297
|
+
max: 100,
|
|
16298
|
+
bands: [
|
|
16299
|
+
{ id: "developing", from: 0 },
|
|
16300
|
+
{ id: "competent", from: 60, passing: true },
|
|
16301
|
+
{ id: "expert", from: 85, passing: true }
|
|
16302
|
+
]
|
|
16303
|
+
}
|
|
16304
|
+
},
|
|
16305
|
+
null,
|
|
16306
|
+
4
|
|
16307
|
+
);
|
|
15700
16308
|
var settingsExample = JSON.stringify(
|
|
15701
16309
|
{
|
|
15702
16310
|
definition: {
|
|
@@ -16176,6 +16784,8 @@ var facilitatorGuideUpdateExample = JSON.stringify(
|
|
|
16176
16784
|
var RESOURCE_EXAMPLES = {
|
|
16177
16785
|
package: { new: packageExample, update: packageUpdateExample },
|
|
16178
16786
|
capability: { new: capabilityExample, update: capabilityUpdateExample },
|
|
16787
|
+
benchmark: { new: benchmarkExample, update: benchmarkUpdateExample },
|
|
16788
|
+
assessment: { new: assessmentExample, update: assessmentUpdateExample },
|
|
16179
16789
|
settings: { new: settingsExample, update: settingsUpdateExample },
|
|
16180
16790
|
engine: { new: engineExample, update: engineUpdateExample },
|
|
16181
16791
|
ui: { new: userInterfaceExample, update: userInterfaceUpdateExample },
|
|
@@ -16209,6 +16819,8 @@ var settingsAjv = createAjv("reference");
|
|
|
16209
16819
|
ajv2.addSchema(schema, "schema.json");
|
|
16210
16820
|
var validators = {
|
|
16211
16821
|
sdkCapability: ajv2.compile({ $ref: "schema.json#/$defs/SDKCapability" }),
|
|
16822
|
+
sdkBenchmark: ajv2.compile({ $ref: "schema.json#/$defs/SDKBenchmark" }),
|
|
16823
|
+
sdkAssessment: ajv2.compile({ $ref: "schema.json#/$defs/SDKAssessment" }),
|
|
16212
16824
|
sdkSettings: ajv2.compile({ $ref: "schema.json#/$defs/SDKSettings" }),
|
|
16213
16825
|
sdkEngine: ajv2.compile({ $ref: "schema.json#/$defs/SDKEngine" }),
|
|
16214
16826
|
sdkUserInterface: ajv2.compile({
|
|
@@ -16360,6 +16972,16 @@ var validateSDKCapability = makeValidator(
|
|
|
16360
16972
|
"capability.sdk.json",
|
|
16361
16973
|
resourceExample("capability", "new")
|
|
16362
16974
|
);
|
|
16975
|
+
var validateSDKBenchmark = makeValidator(
|
|
16976
|
+
validators.sdkBenchmark,
|
|
16977
|
+
"benchmark.sdk.json",
|
|
16978
|
+
resourceExample("benchmark", "new")
|
|
16979
|
+
);
|
|
16980
|
+
var validateSDKAssessment = makeValidator(
|
|
16981
|
+
validators.sdkAssessment,
|
|
16982
|
+
"assessment.sdk.json",
|
|
16983
|
+
resourceExample("assessment", "new")
|
|
16984
|
+
);
|
|
16363
16985
|
var validateSDKSettings = makeValidator(
|
|
16364
16986
|
validators.sdkSettings,
|
|
16365
16987
|
"settings.sdk.json",
|
|
@@ -16968,8 +17590,16 @@ async function loadConfig(configPath) {
|
|
|
16968
17590
|
problems.throwIfAny();
|
|
16969
17591
|
assertRequiredFeaturesSupported(jsonConfig, configPath);
|
|
16970
17592
|
const capabilities = await discover(configDir, KINDS.capability, problems);
|
|
17593
|
+
const benchmarks = await discover(configDir, KINDS.benchmark, problems);
|
|
17594
|
+
const assessments = await discover(configDir, KINDS.assessment, problems);
|
|
16971
17595
|
const authoredSettings = await discover(configDir, KINDS.settings, problems);
|
|
16972
17596
|
refuseReservedSettings(problems, authoredSettings);
|
|
17597
|
+
if (assessments.length > 0) refuseAssessmentSettings(problems, authoredSettings);
|
|
17598
|
+
const assessmentSettings = assessmentSettingsResource(assessments);
|
|
17599
|
+
const builtInSettings = () => [
|
|
17600
|
+
gameSettingsResource(jsonConfig),
|
|
17601
|
+
...assessmentSettings ? [assessmentSettings] : []
|
|
17602
|
+
];
|
|
16973
17603
|
const scenarios = await discover(configDir, KINDS.scenario, problems);
|
|
16974
17604
|
const hooks = await discover(configDir, KINDS.hook, problems);
|
|
16975
17605
|
const discoveredValidators = await discover(configDir, KINDS.validator, problems);
|
|
@@ -17007,7 +17637,7 @@ async function loadConfig(configPath) {
|
|
|
17007
17637
|
refuseUnknownSettingsInSetupNotes(
|
|
17008
17638
|
setup,
|
|
17009
17639
|
configDir,
|
|
17010
|
-
[
|
|
17640
|
+
[...builtInSettings(), ...authoredSettings],
|
|
17011
17641
|
problems
|
|
17012
17642
|
);
|
|
17013
17643
|
problems.throwIfAny();
|
|
@@ -17039,8 +17669,10 @@ async function loadConfig(configPath) {
|
|
|
17039
17669
|
...tick_controller ? { tick_controller } : {},
|
|
17040
17670
|
...guide ? { guide } : {},
|
|
17041
17671
|
capabilities,
|
|
17042
|
-
|
|
17043
|
-
|
|
17672
|
+
...benchmarks.length > 0 ? { benchmarks } : {},
|
|
17673
|
+
...assessments.length > 0 ? { assessments } : {},
|
|
17674
|
+
// The built-in settings come first, then the package's own.
|
|
17675
|
+
settings: [...builtInSettings(), ...authoredSettings],
|
|
17044
17676
|
scenarios,
|
|
17045
17677
|
hooks,
|
|
17046
17678
|
validators: validators2,
|
|
@@ -17189,6 +17821,19 @@ function refuseReservedSettings(problems, settings) {
|
|
|
17189
17821
|
}
|
|
17190
17822
|
]);
|
|
17191
17823
|
}
|
|
17824
|
+
function refuseAssessmentSettings(problems, settings) {
|
|
17825
|
+
if (!settings.some((entry) => entry.definition.identifier === ASSESSMENTS_SETTINGS)) return;
|
|
17826
|
+
const message = `\`settings/${ASSESSMENTS_SETTINGS}/\` is reserved for the built-in assessment band settings`;
|
|
17827
|
+
const hint = "Set an assessment's bands in its assessment.sdk.json, and rename this settings resource.";
|
|
17828
|
+
problems.add("SETTINGS_RESERVED", `Invalid package: ${message}. ${hint}`, [
|
|
17829
|
+
{
|
|
17830
|
+
code: "SETTINGS_RESERVED",
|
|
17831
|
+
message,
|
|
17832
|
+
hint,
|
|
17833
|
+
file: `settings/${ASSESSMENTS_SETTINGS}/settings.sdk.json`
|
|
17834
|
+
}
|
|
17835
|
+
]);
|
|
17836
|
+
}
|
|
17192
17837
|
function refuseUnknownSettingsInSetupNotes(setup, configDir, settings, problems) {
|
|
17193
17838
|
if (!setup) return;
|
|
17194
17839
|
const schemas = settingsSchemas({ settings: [...settings] });
|
|
@@ -17368,6 +18013,8 @@ function kind(type, validate2, hasRootDirectory = true) {
|
|
|
17368
18013
|
}
|
|
17369
18014
|
var KINDS = {
|
|
17370
18015
|
capability: kind("capability", validateSDKCapability, false),
|
|
18016
|
+
benchmark: kind("benchmark", validateSDKBenchmark, false),
|
|
18017
|
+
assessment: kind("assessment", validateSDKAssessment, false),
|
|
17371
18018
|
settings: kind("settings", validateSDKSettings, false),
|
|
17372
18019
|
engine: kind("engine", validateSDKEngine),
|
|
17373
18020
|
ui: kind("ui", validateSDKUserInterface),
|
|
@@ -17498,7 +18145,7 @@ import { statSync as statSync3 } from "fs";
|
|
|
17498
18145
|
import { mkdtemp as mkdtemp3, rm as rm6 } from "fs/promises";
|
|
17499
18146
|
import { createServer } from "http";
|
|
17500
18147
|
import { tmpdir as tmpdir3 } from "os";
|
|
17501
|
-
import { dirname as dirname11, join as
|
|
18148
|
+
import { dirname as dirname11, join as join21 } from "path";
|
|
17502
18149
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
17503
18150
|
import react2 from "@vitejs/plugin-react";
|
|
17504
18151
|
import express2 from "express";
|
|
@@ -17507,6 +18154,7 @@ import { WebSocketServer } from "ws";
|
|
|
17507
18154
|
|
|
17508
18155
|
// cli/core/listen-with-fallback.ts
|
|
17509
18156
|
import { createServer as createSocket } from "net";
|
|
18157
|
+
var PORT_IN_USE_HINT = "`sdk dev status` says whether a dev server is already running for this package. Pass --port auto to take any free port.";
|
|
17510
18158
|
async function listenWithPortFallback(server, startPort, options = {}) {
|
|
17511
18159
|
const maxAttempts = options.maxAttempts ?? 100;
|
|
17512
18160
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
@@ -17520,7 +18168,8 @@ async function listenWithPortFallback(server, startPort, options = {}) {
|
|
|
17520
18168
|
}
|
|
17521
18169
|
throw new CliError(
|
|
17522
18170
|
"PORT_IN_USE",
|
|
17523
|
-
`Could not find available port after ${maxAttempts} attempts
|
|
18171
|
+
`Could not find available port after ${maxAttempts} attempts`,
|
|
18172
|
+
{ hint: PORT_IN_USE_HINT }
|
|
17524
18173
|
);
|
|
17525
18174
|
}
|
|
17526
18175
|
function tryListen(server, port, host) {
|
|
@@ -17558,7 +18207,8 @@ async function findFreePort(startPort, maxAttempts = 100) {
|
|
|
17558
18207
|
}
|
|
17559
18208
|
throw new CliError(
|
|
17560
18209
|
"PORT_IN_USE",
|
|
17561
|
-
`Could not find available port after ${maxAttempts} attempts
|
|
18210
|
+
`Could not find available port after ${maxAttempts} attempts`,
|
|
18211
|
+
{ hint: PORT_IN_USE_HINT }
|
|
17562
18212
|
);
|
|
17563
18213
|
}
|
|
17564
18214
|
var PROBED_ADDRESSES = [void 0, "127.0.0.1", "::1"];
|
|
@@ -17681,6 +18331,8 @@ var QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
|
17681
18331
|
"callEndpoint",
|
|
17682
18332
|
"getPastState",
|
|
17683
18333
|
"getAllTeamsParticipants",
|
|
18334
|
+
"getBenchmark",
|
|
18335
|
+
"getAssessment",
|
|
17684
18336
|
"getEndpointAudit",
|
|
17685
18337
|
"listEndpoints"
|
|
17686
18338
|
]);
|
|
@@ -17752,6 +18404,7 @@ var COMMAND_FIELDS = {
|
|
|
17752
18404
|
resumeTimer: { "teamIndex?": "number" },
|
|
17753
18405
|
extendTick: { byMs: "number", "teamIndex?": "number" },
|
|
17754
18406
|
advanceClock: { byMs: "number" },
|
|
18407
|
+
makeDormant: {},
|
|
17755
18408
|
armFault: { fault: "fault", "times?": "number", "reason?": "string" },
|
|
17756
18409
|
disarmFault: { fault: "fault" },
|
|
17757
18410
|
// Queries
|
|
@@ -17779,6 +18432,14 @@ var COMMAND_FIELDS = {
|
|
|
17779
18432
|
"participantId?": "string",
|
|
17780
18433
|
"teamId?": "string"
|
|
17781
18434
|
},
|
|
18435
|
+
getBenchmark: { identifier: "string", where: "array" },
|
|
18436
|
+
getAssessment: {
|
|
18437
|
+
identifier: "string",
|
|
18438
|
+
"audience?": "string",
|
|
18439
|
+
"participantId?": "string",
|
|
18440
|
+
"teamId?": "string",
|
|
18441
|
+
"viewerRole?": "viewerRole"
|
|
18442
|
+
},
|
|
17782
18443
|
getEndpointAudit: {},
|
|
17783
18444
|
listEndpoints: { "external?": "boolean" }
|
|
17784
18445
|
};
|
|
@@ -17850,12 +18511,21 @@ var PROJECTION_VERSION = 4;
|
|
|
17850
18511
|
// cli/execution/engine-state.ts
|
|
17851
18512
|
var ENGINE_STATE_KEY = "$engineState";
|
|
17852
18513
|
var SHARED_ENGINE_STATE_KEY = "$sharedEngineState";
|
|
17853
|
-
var
|
|
18514
|
+
var BENCHMARKS_KEY = "$benchmarks";
|
|
18515
|
+
var SHARED_BENCHMARKS_KEY = "$sharedBenchmarks";
|
|
18516
|
+
var ASSESSMENTS_KEY = "$assessments";
|
|
18517
|
+
var RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
18518
|
+
ENGINE_STATE_KEY,
|
|
18519
|
+
SHARED_ENGINE_STATE_KEY,
|
|
18520
|
+
BENCHMARKS_KEY,
|
|
18521
|
+
SHARED_BENCHMARKS_KEY,
|
|
18522
|
+
ASSESSMENTS_KEY
|
|
18523
|
+
]);
|
|
17854
18524
|
function isReservedKey(key) {
|
|
17855
18525
|
return RESERVED_KEYS.has(key);
|
|
17856
18526
|
}
|
|
17857
18527
|
function withoutEngineState(context) {
|
|
17858
|
-
if (!(
|
|
18528
|
+
if (!Object.keys(context).some(isReservedKey)) return context;
|
|
17859
18529
|
const rest = {};
|
|
17860
18530
|
for (const [key, value] of Object.entries(context)) {
|
|
17861
18531
|
if (!isReservedKey(key)) rest[key] = value;
|
|
@@ -18848,11 +19518,11 @@ function normalizeVariablesSchema(schema2) {
|
|
|
18848
19518
|
}
|
|
18849
19519
|
|
|
18850
19520
|
// cli/execution/logic-result.ts
|
|
18851
|
-
function
|
|
19521
|
+
function isRecord3(value) {
|
|
18852
19522
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18853
19523
|
}
|
|
18854
19524
|
function readCapabilities(label4, result, allowed = ["capabilities", "deletes"]) {
|
|
18855
|
-
if (!
|
|
19525
|
+
if (!isRecord3(result)) {
|
|
18856
19526
|
throw new Error(`${label4} must return an object of the form { capabilities: { ... } }`);
|
|
18857
19527
|
}
|
|
18858
19528
|
const unknownKeys = Object.keys(result).filter((key) => !allowed.includes(key));
|
|
@@ -18866,7 +19536,7 @@ function readCapabilities(label4, result, allowed = ["capabilities", "deletes"])
|
|
|
18866
19536
|
if (capabilities === void 0 || capabilities === null) {
|
|
18867
19537
|
return {};
|
|
18868
19538
|
}
|
|
18869
|
-
if (!
|
|
19539
|
+
if (!isRecord3(capabilities)) {
|
|
18870
19540
|
throw new Error(`${label4} returned "capabilities" that is not an object`);
|
|
18871
19541
|
}
|
|
18872
19542
|
const reserved = Object.keys(capabilities).find(isReservedKey);
|
|
@@ -18878,7 +19548,7 @@ function readCapabilities(label4, result, allowed = ["capabilities", "deletes"])
|
|
|
18878
19548
|
return capabilities;
|
|
18879
19549
|
}
|
|
18880
19550
|
function readDeletes(label4, result) {
|
|
18881
|
-
if (!
|
|
19551
|
+
if (!isRecord3(result)) return [];
|
|
18882
19552
|
const deletes = result.deletes;
|
|
18883
19553
|
if (deletes === void 0 || deletes === null) return [];
|
|
18884
19554
|
if (!Array.isArray(deletes)) {
|
|
@@ -18923,18 +19593,32 @@ function assertDeletesDeclared(label4, deletes, declaration, shared, target) {
|
|
|
18923
19593
|
}
|
|
18924
19594
|
}
|
|
18925
19595
|
}
|
|
18926
|
-
function readEngineResult(label4, result, phase = "init") {
|
|
18927
|
-
const allowed =
|
|
19596
|
+
function readEngineResult(label4, result, phase = "init", writesBenchmarks = false, writesAssessments = false) {
|
|
19597
|
+
const allowed = [
|
|
19598
|
+
"capabilities",
|
|
19599
|
+
"deletes",
|
|
19600
|
+
"state",
|
|
19601
|
+
...phase === "tick" ? ["complete"] : [],
|
|
19602
|
+
...writesBenchmarks ? ["benchmarks"] : [],
|
|
19603
|
+
...writesAssessments ? ["assessments"] : []
|
|
19604
|
+
];
|
|
18928
19605
|
const capabilities = readCapabilities(label4, result, allowed);
|
|
18929
19606
|
const deletes = readDeletes(label4, result);
|
|
18930
|
-
const { state: state2, complete } = result;
|
|
19607
|
+
const { state: state2, complete, benchmarks, assessments } = result;
|
|
18931
19608
|
if (complete !== void 0 && typeof complete !== "boolean") {
|
|
18932
19609
|
throw new Error(`${label4} returned "complete" that is not a boolean`);
|
|
18933
19610
|
}
|
|
18934
|
-
return {
|
|
19611
|
+
return {
|
|
19612
|
+
capabilities,
|
|
19613
|
+
deletes,
|
|
19614
|
+
state: state2,
|
|
19615
|
+
complete: complete === true,
|
|
19616
|
+
...benchmarks === void 0 ? {} : { benchmarks },
|
|
19617
|
+
...assessments === void 0 ? {} : { assessments }
|
|
19618
|
+
};
|
|
18935
19619
|
}
|
|
18936
|
-
function readAggregateResult(label4, result, teamCount, phase = "init") {
|
|
18937
|
-
if (!
|
|
19620
|
+
function readAggregateResult(label4, result, teamCount, phase = "init", writesBenchmarks = false, writesAssessments = false) {
|
|
19621
|
+
if (!isRecord3(result)) {
|
|
18938
19622
|
throw new Error(
|
|
18939
19623
|
`${label4} must return { shared: { capabilities }, teams: [{ capabilities }] }`
|
|
18940
19624
|
);
|
|
@@ -18951,15 +19635,27 @@ function readAggregateResult(label4, result, teamCount, phase = "init") {
|
|
|
18951
19635
|
);
|
|
18952
19636
|
}
|
|
18953
19637
|
return {
|
|
18954
|
-
shared: result.shared === void 0 ? { capabilities: {}, deletes: [], state: void 0, complete: false } : readEngineResult(
|
|
19638
|
+
shared: result.shared === void 0 ? { capabilities: {}, deletes: [], state: void 0, complete: false } : readEngineResult(
|
|
19639
|
+
`${label4} "shared"`,
|
|
19640
|
+
result.shared,
|
|
19641
|
+
phase,
|
|
19642
|
+
writesBenchmarks,
|
|
19643
|
+
writesAssessments
|
|
19644
|
+
),
|
|
18955
19645
|
teams: result.teams.map(
|
|
18956
|
-
(team, i) => readEngineResult(
|
|
19646
|
+
(team, i) => readEngineResult(
|
|
19647
|
+
`${label4} "teams[${i}]"`,
|
|
19648
|
+
team,
|
|
19649
|
+
phase,
|
|
19650
|
+
writesBenchmarks,
|
|
19651
|
+
writesAssessments
|
|
19652
|
+
)
|
|
18957
19653
|
)
|
|
18958
19654
|
};
|
|
18959
19655
|
}
|
|
18960
19656
|
var TICK_CONTROLLER_KEYS = ["enabled", "intervalMs", "nextTickAt", "complete"];
|
|
18961
19657
|
function readTickControllerResult(label4, result) {
|
|
18962
|
-
if (!
|
|
19658
|
+
if (!isRecord3(result)) {
|
|
18963
19659
|
throw new Error(`${label4} must return an object of the form { enabled, intervalMs? }`);
|
|
18964
19660
|
}
|
|
18965
19661
|
const unknownKeys = Object.keys(result).filter((key) => !TICK_CONTROLLER_KEYS.includes(key));
|
|
@@ -18978,6 +19674,87 @@ function readTickControllerResult(label4, result) {
|
|
|
18978
19674
|
}
|
|
18979
19675
|
|
|
18980
19676
|
// cli/execution/context-composition.ts
|
|
19677
|
+
function foldAssessmentWrites(label4, raw, current, participantIds, scope) {
|
|
19678
|
+
if (raw === void 0) return void 0;
|
|
19679
|
+
if (!isPlainObject3(raw)) {
|
|
19680
|
+
scope.warn(
|
|
19681
|
+
`${label4} returned "assessments" that is not an object of writes by assessment. Every assessment write in it was dropped, and the round carried on.`
|
|
19682
|
+
);
|
|
19683
|
+
return void 0;
|
|
19684
|
+
}
|
|
19685
|
+
const writes = structuredClone(raw);
|
|
19686
|
+
const results = structuredClone(isPlainObject3(current) ? current : {});
|
|
19687
|
+
for (const [identifier, write] of Object.entries(writes)) {
|
|
19688
|
+
if (write === void 0) continue;
|
|
19689
|
+
const named3 = `${label4} wrote assessment "${identifier}"`;
|
|
19690
|
+
const definition3 = scope.assessments?.get(identifier);
|
|
19691
|
+
if (!definition3) {
|
|
19692
|
+
scope.warn(
|
|
19693
|
+
`${named3}, which the engine does not declare in "assessments". The write was dropped.`
|
|
19694
|
+
);
|
|
19695
|
+
continue;
|
|
19696
|
+
}
|
|
19697
|
+
const folded = foldAssessmentWrite(definition3, results[identifier], write, participantIds);
|
|
19698
|
+
if ("problem" in folded) {
|
|
19699
|
+
scope.warn(
|
|
19700
|
+
`${named3}: ${folded.problem}. The write was dropped, and the round carried on.`
|
|
19701
|
+
);
|
|
19702
|
+
continue;
|
|
19703
|
+
}
|
|
19704
|
+
if (folded.next === void 0) delete results[identifier];
|
|
19705
|
+
else results[identifier] = folded.next;
|
|
19706
|
+
}
|
|
19707
|
+
return results;
|
|
19708
|
+
}
|
|
19709
|
+
function isPlainObject3(value) {
|
|
19710
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19711
|
+
}
|
|
19712
|
+
function foldBenchmarkWrites(label4, raw, current, level, scope) {
|
|
19713
|
+
if (raw === void 0) return void 0;
|
|
19714
|
+
if (!isPlainObject3(raw)) {
|
|
19715
|
+
scope.warn(
|
|
19716
|
+
`${label4} returned "benchmarks" that is not an object of writes by benchmark. Every benchmark write in it was dropped, and the round carried on.`
|
|
19717
|
+
);
|
|
19718
|
+
return void 0;
|
|
19719
|
+
}
|
|
19720
|
+
const writes = structuredClone(raw);
|
|
19721
|
+
const records = structuredClone(isPlainObject3(current) ? current : {});
|
|
19722
|
+
for (const [identifier, write] of Object.entries(writes)) {
|
|
19723
|
+
if (write === void 0) continue;
|
|
19724
|
+
const named3 = `${label4} wrote benchmark "${identifier}"`;
|
|
19725
|
+
const definition3 = scope.benchmarks.get(identifier);
|
|
19726
|
+
if (!definition3) {
|
|
19727
|
+
scope.warn(
|
|
19728
|
+
`${named3}, which the engine does not declare in "benchmarks". The write was dropped.`
|
|
19729
|
+
);
|
|
19730
|
+
continue;
|
|
19731
|
+
}
|
|
19732
|
+
const declaredLevel = resolveBenchmarkLevel(definition3);
|
|
19733
|
+
if (declaredLevel !== level) {
|
|
19734
|
+
scope.warn(
|
|
19735
|
+
declaredLevel === "session" ? `${named3}, which is session-level, so it is written under an aggregate result's "shared". The write was dropped.` : `${named3}, which is per team, so it is written for each team rather than under "shared". The write was dropped.`
|
|
19736
|
+
);
|
|
19737
|
+
continue;
|
|
19738
|
+
}
|
|
19739
|
+
const problem = benchmarkWriteProblem(definition3, write);
|
|
19740
|
+
if (problem !== null) {
|
|
19741
|
+
scope.warn(`${named3}: ${problem}. The write was dropped, and the round carried on.`);
|
|
19742
|
+
continue;
|
|
19743
|
+
}
|
|
19744
|
+
const next = applyBenchmarkWrite(
|
|
19745
|
+
records[identifier],
|
|
19746
|
+
write
|
|
19747
|
+
);
|
|
19748
|
+
if (next === void 0) delete records[identifier];
|
|
19749
|
+
else records[identifier] = next;
|
|
19750
|
+
}
|
|
19751
|
+
return records;
|
|
19752
|
+
}
|
|
19753
|
+
function storeRecords(target, key, records) {
|
|
19754
|
+
if (records === void 0) return;
|
|
19755
|
+
if (Object.keys(records).length === 0) delete target[key];
|
|
19756
|
+
else target[key] = records;
|
|
19757
|
+
}
|
|
18981
19758
|
function mutationAffects(reads, previous4, next) {
|
|
18982
19759
|
if (!reads || reads.length === 0) return true;
|
|
18983
19760
|
return reads.some((capId) => JSON.stringify(previous4[capId]) !== JSON.stringify(next[capId]));
|
|
@@ -19033,12 +19810,17 @@ function foldLogicResult(capabilities, deletes, contextBefore, defaults) {
|
|
|
19033
19810
|
const merged = mergeCapabilityFields(capabilities, contextBefore, defaults);
|
|
19034
19811
|
return deletes.length === 0 ? merged : applyContextUpdate(merged, {}, deletes);
|
|
19035
19812
|
}
|
|
19036
|
-
function aggregateArgs(contexts, identities, declaration, store, sharedIds, participants) {
|
|
19813
|
+
function aggregateArgs(contexts, identities, declaration, store, sharedIds, participants, writesBenchmarks = false, writesAssessments = false) {
|
|
19037
19814
|
const shared = projectForLogic(store, declaration);
|
|
19038
19815
|
return {
|
|
19039
19816
|
shared: {
|
|
19040
19817
|
context: structuredClone(shared),
|
|
19041
|
-
state: structuredClone(store[SHARED_ENGINE_STATE_KEY])
|
|
19818
|
+
state: structuredClone(store[SHARED_ENGINE_STATE_KEY]),
|
|
19819
|
+
...writesBenchmarks ? {
|
|
19820
|
+
benchmarks: structuredClone(
|
|
19821
|
+
store[SHARED_BENCHMARKS_KEY] ?? {}
|
|
19822
|
+
)
|
|
19823
|
+
} : {}
|
|
19042
19824
|
},
|
|
19043
19825
|
teams: contexts.map((context, i) => ({
|
|
19044
19826
|
teamId: identities[i].teamId,
|
|
@@ -19048,12 +19830,22 @@ function aggregateArgs(contexts, identities, declaration, store, sharedIds, part
|
|
|
19048
19830
|
([capId]) => !sharedIds.has(capId)
|
|
19049
19831
|
)
|
|
19050
19832
|
),
|
|
19051
|
-
state: structuredClone(context[ENGINE_STATE_KEY])
|
|
19833
|
+
state: structuredClone(context[ENGINE_STATE_KEY]),
|
|
19834
|
+
...writesBenchmarks ? {
|
|
19835
|
+
benchmarks: structuredClone(
|
|
19836
|
+
context[BENCHMARKS_KEY] ?? {}
|
|
19837
|
+
)
|
|
19838
|
+
} : {},
|
|
19839
|
+
...writesAssessments ? {
|
|
19840
|
+
assessments: structuredClone(
|
|
19841
|
+
context[ASSESSMENTS_KEY] ?? {}
|
|
19842
|
+
)
|
|
19843
|
+
} : {}
|
|
19052
19844
|
})),
|
|
19053
19845
|
participants
|
|
19054
19846
|
};
|
|
19055
19847
|
}
|
|
19056
|
-
function applyEngineResult(label4, result, contextBefore, scope) {
|
|
19848
|
+
function applyEngineResult(label4, result, contextBefore, scope, teamId) {
|
|
19057
19849
|
assertDeletesDeclared(label4, result.deletes, scope.engine, new Set(scope.sharedIds), "team");
|
|
19058
19850
|
const merged = foldLogicResult(
|
|
19059
19851
|
result.capabilities,
|
|
@@ -19065,9 +19857,25 @@ function applyEngineResult(label4, result, contextBefore, scope) {
|
|
|
19065
19857
|
assertJsonSerialisable(label4, result.state);
|
|
19066
19858
|
merged[ENGINE_STATE_KEY] = structuredClone(result.state);
|
|
19067
19859
|
}
|
|
19860
|
+
storeRecords(
|
|
19861
|
+
merged,
|
|
19862
|
+
BENCHMARKS_KEY,
|
|
19863
|
+
foldBenchmarkWrites(label4, result.benchmarks, contextBefore[BENCHMARKS_KEY], "team", scope)
|
|
19864
|
+
);
|
|
19865
|
+
storeRecords(
|
|
19866
|
+
merged,
|
|
19867
|
+
ASSESSMENTS_KEY,
|
|
19868
|
+
foldAssessmentWrites(
|
|
19869
|
+
label4,
|
|
19870
|
+
result.assessments,
|
|
19871
|
+
contextBefore[ASSESSMENTS_KEY],
|
|
19872
|
+
teamId === void 0 ? /* @__PURE__ */ new Set() : scope.participantIdsOf?.(teamId) ?? /* @__PURE__ */ new Set(),
|
|
19873
|
+
scope
|
|
19874
|
+
)
|
|
19875
|
+
);
|
|
19068
19876
|
return merged;
|
|
19069
19877
|
}
|
|
19070
|
-
function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, scope, store) {
|
|
19878
|
+
function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, scope, store, teamIds = []) {
|
|
19071
19879
|
const label4 = `Engine "${engineIdentifier}" ${phase}`;
|
|
19072
19880
|
const result = {
|
|
19073
19881
|
shared: read.shared.capabilities,
|
|
@@ -19097,7 +19905,13 @@ function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, sco
|
|
|
19097
19905
|
"shared"
|
|
19098
19906
|
);
|
|
19099
19907
|
const contexts = read.teams.map((team, i) => {
|
|
19100
|
-
const context = applyEngineResult(
|
|
19908
|
+
const context = applyEngineResult(
|
|
19909
|
+
`${label4} "teams[${i}]"`,
|
|
19910
|
+
team,
|
|
19911
|
+
contextsBefore[i],
|
|
19912
|
+
scope,
|
|
19913
|
+
teamIds[i]
|
|
19914
|
+
);
|
|
19101
19915
|
enforceDeclaredWrites(
|
|
19102
19916
|
engineIdentifier,
|
|
19103
19917
|
scope.engine,
|
|
@@ -19107,11 +19921,27 @@ function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, sco
|
|
|
19107
19921
|
);
|
|
19108
19922
|
return context;
|
|
19109
19923
|
});
|
|
19924
|
+
if (read.shared.assessments !== void 0) {
|
|
19925
|
+
scope.warn(
|
|
19926
|
+
`${label4} "shared" returned "assessments", but every assessment belongs to a team or a participant, so it is written under each team's entry in "teams". The writes were dropped, and the round carried on.`
|
|
19927
|
+
);
|
|
19928
|
+
}
|
|
19110
19929
|
let next = { ...store };
|
|
19111
19930
|
if (read.shared.state !== void 0) {
|
|
19112
19931
|
assertJsonSerialisable(`${label4} "shared"`, read.shared.state);
|
|
19113
19932
|
next[SHARED_ENGINE_STATE_KEY] = structuredClone(read.shared.state);
|
|
19114
19933
|
}
|
|
19934
|
+
storeRecords(
|
|
19935
|
+
next,
|
|
19936
|
+
SHARED_BENCHMARKS_KEY,
|
|
19937
|
+
foldBenchmarkWrites(
|
|
19938
|
+
`${label4} "shared"`,
|
|
19939
|
+
read.shared.benchmarks,
|
|
19940
|
+
store[SHARED_BENCHMARKS_KEY],
|
|
19941
|
+
"session",
|
|
19942
|
+
scope
|
|
19943
|
+
)
|
|
19944
|
+
);
|
|
19115
19945
|
for (const [capId, sliceValue] of Object.entries(result.shared)) {
|
|
19116
19946
|
const base2 = next[capId];
|
|
19117
19947
|
const value = sliceValue && typeof sliceValue === "object" && !Array.isArray(sliceValue) && base2 && typeof base2 === "object" && !Array.isArray(base2) ? {
|
|
@@ -19135,6 +19965,11 @@ function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, sco
|
|
|
19135
19965
|
context[capId] = structuredClone(store[capId]);
|
|
19136
19966
|
}
|
|
19137
19967
|
}
|
|
19968
|
+
if (SHARED_BENCHMARKS_KEY in store) {
|
|
19969
|
+
context[SHARED_BENCHMARKS_KEY] = structuredClone(store[SHARED_BENCHMARKS_KEY]);
|
|
19970
|
+
} else {
|
|
19971
|
+
delete context[SHARED_BENCHMARKS_KEY];
|
|
19972
|
+
}
|
|
19138
19973
|
}
|
|
19139
19974
|
return { contexts, store };
|
|
19140
19975
|
}
|
|
@@ -20794,6 +21629,7 @@ var GameExecutor = class {
|
|
|
20794
21629
|
* contexts it was handed (§11). Read by the session straight after a tick.
|
|
20795
21630
|
*/
|
|
20796
21631
|
lastTickCompletion = [];
|
|
21632
|
+
warnings = [];
|
|
20797
21633
|
waitingRoomOpen = false;
|
|
20798
21634
|
deps;
|
|
20799
21635
|
/** `meta`, the roster, callbacks and bounds: what every logic call shares. */
|
|
@@ -20956,24 +21792,74 @@ var GameExecutor = class {
|
|
|
20956
21792
|
}
|
|
20957
21793
|
/** How a result folds into a board, for the game as it is loaded now. */
|
|
20958
21794
|
composition() {
|
|
21795
|
+
const declared = new Set(this.engine?.definition.benchmarks ?? []);
|
|
21796
|
+
const assessed = new Set(this.engine?.definition.assessments ?? []);
|
|
20959
21797
|
return {
|
|
20960
21798
|
defaults: this.capabilityDefaults,
|
|
20961
21799
|
sharedIds: new Set(this.getSharedCapabilityIds()),
|
|
20962
|
-
engine: this.engine?.definition ?? {}
|
|
21800
|
+
engine: this.engine?.definition ?? {},
|
|
21801
|
+
benchmarks: new Map(
|
|
21802
|
+
(this.config?.benchmarks ?? []).filter((benchmark) => declared.has(benchmark.definition.identifier)).map((benchmark) => [benchmark.definition.identifier, benchmark.definition])
|
|
21803
|
+
),
|
|
21804
|
+
warn: (message) => {
|
|
21805
|
+
logger.warn(message);
|
|
21806
|
+
this.warnings.push(message);
|
|
21807
|
+
},
|
|
21808
|
+
assessments: new Map(
|
|
21809
|
+
(this.config?.assessments ?? []).filter((assessment) => assessed.has(assessment.definition.identifier)).map((assessment) => [assessment.definition.identifier, assessment.definition])
|
|
21810
|
+
),
|
|
21811
|
+
participantIdsOf: (teamId) => new Set(this.calls.participantsOn([teamId]).map((participant) => participant.id))
|
|
21812
|
+
};
|
|
21813
|
+
}
|
|
21814
|
+
/** Whether the engine declares assessments, and so is handed and may return them (§6.17). */
|
|
21815
|
+
writesAssessments() {
|
|
21816
|
+
return (this.engine?.definition.assessments?.length ?? 0) > 0;
|
|
21817
|
+
}
|
|
21818
|
+
/** Whether the engine declares benchmarks, and so is handed and may return them (§6.16). */
|
|
21819
|
+
writesBenchmarks() {
|
|
21820
|
+
return (this.engine?.definition.benchmarks?.length ?? 0) > 0;
|
|
21821
|
+
}
|
|
21822
|
+
/**
|
|
21823
|
+
* The `benchmarks` and `assessments` arguments of an `Init` or `Run` on
|
|
21824
|
+
* `context`: its team's records and results, each passed only to an engine
|
|
21825
|
+
* that declares some.
|
|
21826
|
+
*/
|
|
21827
|
+
recordArgs(context) {
|
|
21828
|
+
return {
|
|
21829
|
+
...this.writesBenchmarks() ? {
|
|
21830
|
+
benchmarks: structuredClone(
|
|
21831
|
+
context[BENCHMARKS_KEY] ?? {}
|
|
21832
|
+
)
|
|
21833
|
+
} : {},
|
|
21834
|
+
...this.writesAssessments() ? {
|
|
21835
|
+
assessments: structuredClone(
|
|
21836
|
+
context[ASSESSMENTS_KEY] ?? {}
|
|
21837
|
+
)
|
|
21838
|
+
} : {}
|
|
20963
21839
|
};
|
|
20964
21840
|
}
|
|
21841
|
+
/**
|
|
21842
|
+
* What went wrong without failing anything since the last call, such as a
|
|
21843
|
+
* benchmark write that was dropped (§6.16), for the operation to report.
|
|
21844
|
+
*/
|
|
21845
|
+
takeWarnings() {
|
|
21846
|
+
const warnings = this.warnings;
|
|
21847
|
+
this.warnings = [];
|
|
21848
|
+
return warnings;
|
|
21849
|
+
}
|
|
20965
21850
|
/**
|
|
20966
21851
|
* Fold an aggregate result into the team contexts and the canonical store.
|
|
20967
21852
|
* See {@link applyAggregateResult}.
|
|
20968
21853
|
*/
|
|
20969
|
-
applyAggregateResult(read, contextsBefore, engineIdentifier, phase) {
|
|
21854
|
+
applyAggregateResult(read, contextsBefore, engineIdentifier, phase, teamIds) {
|
|
20970
21855
|
const { contexts, store } = applyAggregateResult(
|
|
20971
21856
|
read,
|
|
20972
21857
|
contextsBefore,
|
|
20973
21858
|
engineIdentifier,
|
|
20974
21859
|
phase,
|
|
20975
21860
|
this.composition(),
|
|
20976
|
-
this.sharedContext
|
|
21861
|
+
this.sharedContext,
|
|
21862
|
+
teamIds
|
|
20977
21863
|
);
|
|
20978
21864
|
this.sharedContext = store;
|
|
20979
21865
|
return contexts;
|
|
@@ -20986,7 +21872,9 @@ var GameExecutor = class {
|
|
|
20986
21872
|
declaration,
|
|
20987
21873
|
this.sharedContext,
|
|
20988
21874
|
new Set(this.getSharedCapabilityIds()),
|
|
20989
|
-
this.calls.participantsOn(identities.map((identity) => identity.teamId))
|
|
21875
|
+
this.calls.participantsOn(identities.map((identity) => identity.teamId)),
|
|
21876
|
+
this.writesBenchmarks(),
|
|
21877
|
+
this.writesAssessments()
|
|
20990
21878
|
);
|
|
20991
21879
|
}
|
|
20992
21880
|
/**
|
|
@@ -21169,6 +22057,7 @@ var GameExecutor = class {
|
|
|
21169
22057
|
() => run({
|
|
21170
22058
|
context: projectForLogic(contexts[i], engine.definition),
|
|
21171
22059
|
state: contexts[i][ENGINE_STATE_KEY],
|
|
22060
|
+
...this.recordArgs(contexts[i]),
|
|
21172
22061
|
settings: engineSettings,
|
|
21173
22062
|
meta: teamMeta[i],
|
|
21174
22063
|
participants: this.calls.participantsOn([
|
|
@@ -21183,10 +22072,18 @@ var GameExecutor = class {
|
|
|
21183
22072
|
team: identities[i]
|
|
21184
22073
|
}
|
|
21185
22074
|
),
|
|
21186
|
-
"tick"
|
|
22075
|
+
"tick",
|
|
22076
|
+
this.writesBenchmarks(),
|
|
22077
|
+
this.writesAssessments()
|
|
21187
22078
|
);
|
|
21188
22079
|
if (read.complete) completed[i] = true;
|
|
21189
|
-
contexts[i] = applyEngineResult(
|
|
22080
|
+
contexts[i] = applyEngineResult(
|
|
22081
|
+
label4,
|
|
22082
|
+
read,
|
|
22083
|
+
contextBefore,
|
|
22084
|
+
this.composition(),
|
|
22085
|
+
identities[i].teamId
|
|
22086
|
+
);
|
|
21190
22087
|
enforceDeclaredWrites(
|
|
21191
22088
|
engineIdentifier,
|
|
21192
22089
|
engine.definition,
|
|
@@ -21226,7 +22123,9 @@ var GameExecutor = class {
|
|
|
21226
22123
|
{ resource: { type: "engine", identifier: engineIdentifier }, tick: tick2 }
|
|
21227
22124
|
),
|
|
21228
22125
|
args.teams.length,
|
|
21229
|
-
"tick"
|
|
22126
|
+
"tick",
|
|
22127
|
+
this.writesBenchmarks(),
|
|
22128
|
+
this.writesAssessments()
|
|
21230
22129
|
);
|
|
21231
22130
|
result.teams.forEach((team, i) => {
|
|
21232
22131
|
if (team.complete || result.shared.complete) completed[i] = true;
|
|
@@ -21235,7 +22134,8 @@ var GameExecutor = class {
|
|
|
21235
22134
|
result,
|
|
21236
22135
|
contextsBefore,
|
|
21237
22136
|
engineIdentifier,
|
|
21238
|
-
"RunAggregate"
|
|
22137
|
+
"RunAggregate",
|
|
22138
|
+
identities.map((identity) => identity.teamId)
|
|
21239
22139
|
);
|
|
21240
22140
|
}
|
|
21241
22141
|
}
|
|
@@ -21314,13 +22214,17 @@ var GameExecutor = class {
|
|
|
21314
22214
|
}),
|
|
21315
22215
|
{ resource: { type: "engine", identifier: engineIdentifier } }
|
|
21316
22216
|
),
|
|
21317
|
-
args.teams.length
|
|
22217
|
+
args.teams.length,
|
|
22218
|
+
"init",
|
|
22219
|
+
this.writesBenchmarks(),
|
|
22220
|
+
this.writesAssessments()
|
|
21318
22221
|
);
|
|
21319
22222
|
contexts = this.applyAggregateResult(
|
|
21320
22223
|
result,
|
|
21321
22224
|
contextsBefore,
|
|
21322
22225
|
engineIdentifier,
|
|
21323
|
-
"InitAggregate"
|
|
22226
|
+
"InitAggregate",
|
|
22227
|
+
identities.map((identity) => identity.teamId)
|
|
21324
22228
|
);
|
|
21325
22229
|
}
|
|
21326
22230
|
this.context = { ...contexts[0] };
|
|
@@ -21356,6 +22260,7 @@ var GameExecutor = class {
|
|
|
21356
22260
|
() => initFn({
|
|
21357
22261
|
context: projectForLogic(before, engine.definition),
|
|
21358
22262
|
state: void 0,
|
|
22263
|
+
...this.recordArgs(before),
|
|
21359
22264
|
settings,
|
|
21360
22265
|
meta: { ...sessionMeta, ...identity },
|
|
21361
22266
|
participants: this.calls.participantsOn([identity.teamId]),
|
|
@@ -21365,9 +22270,18 @@ var GameExecutor = class {
|
|
|
21365
22270
|
resource: { type: "engine", identifier: engine.definition.identifier },
|
|
21366
22271
|
team: identity
|
|
21367
22272
|
}
|
|
21368
|
-
)
|
|
22273
|
+
),
|
|
22274
|
+
"init",
|
|
22275
|
+
this.writesBenchmarks(),
|
|
22276
|
+
this.writesAssessments()
|
|
22277
|
+
);
|
|
22278
|
+
const context = applyEngineResult(
|
|
22279
|
+
label4,
|
|
22280
|
+
after,
|
|
22281
|
+
before,
|
|
22282
|
+
this.composition(),
|
|
22283
|
+
identity.teamId
|
|
21369
22284
|
);
|
|
21370
|
-
const context = applyEngineResult(label4, after, before, this.composition());
|
|
21371
22285
|
enforceDeclaredWrites(
|
|
21372
22286
|
engine.definition.identifier,
|
|
21373
22287
|
engine.definition,
|
|
@@ -21406,7 +22320,11 @@ var GameExecutor = class {
|
|
|
21406
22320
|
*/
|
|
21407
22321
|
setContext(context) {
|
|
21408
22322
|
this.context = { ...context };
|
|
21409
|
-
for (const capId of [
|
|
22323
|
+
for (const capId of [
|
|
22324
|
+
...this.getSharedCapabilityIds(),
|
|
22325
|
+
SHARED_ENGINE_STATE_KEY,
|
|
22326
|
+
SHARED_BENCHMARKS_KEY
|
|
22327
|
+
]) {
|
|
21410
22328
|
if (capId in context) {
|
|
21411
22329
|
this.sharedContext[capId] = structuredClone(context[capId]);
|
|
21412
22330
|
}
|
|
@@ -21612,6 +22530,7 @@ var GameExecutor = class {
|
|
|
21612
22530
|
() => initFn({
|
|
21613
22531
|
context: projectForLogic(this.context, engine.definition),
|
|
21614
22532
|
state: void 0,
|
|
22533
|
+
...this.recordArgs(this.context),
|
|
21615
22534
|
settings: engineSettings,
|
|
21616
22535
|
meta: teamMeta,
|
|
21617
22536
|
participants: this.calls.participantsOn([teamMeta.teamId]),
|
|
@@ -21621,13 +22540,17 @@ var GameExecutor = class {
|
|
|
21621
22540
|
resource: { type: "engine", identifier: engineIdentifier },
|
|
21622
22541
|
team: { teamId: teamMeta.teamId, index: teamMeta.index }
|
|
21623
22542
|
}
|
|
21624
|
-
)
|
|
22543
|
+
),
|
|
22544
|
+
"init",
|
|
22545
|
+
this.writesBenchmarks(),
|
|
22546
|
+
this.writesAssessments()
|
|
21625
22547
|
);
|
|
21626
22548
|
this.context = applyEngineResult(
|
|
21627
22549
|
initLabel,
|
|
21628
22550
|
initResult,
|
|
21629
22551
|
contextBefore,
|
|
21630
|
-
this.composition()
|
|
22552
|
+
this.composition(),
|
|
22553
|
+
teamMeta.teamId
|
|
21631
22554
|
);
|
|
21632
22555
|
enforceDeclaredWrites(
|
|
21633
22556
|
engineIdentifier,
|
|
@@ -21670,13 +22593,17 @@ var GameExecutor = class {
|
|
|
21670
22593
|
}),
|
|
21671
22594
|
{ resource: { type: "engine", identifier: engineIdentifier } }
|
|
21672
22595
|
),
|
|
21673
|
-
1
|
|
22596
|
+
1,
|
|
22597
|
+
"init",
|
|
22598
|
+
this.writesBenchmarks(),
|
|
22599
|
+
this.writesAssessments()
|
|
21674
22600
|
);
|
|
21675
22601
|
[this.context] = this.applyAggregateResult(
|
|
21676
22602
|
result,
|
|
21677
22603
|
[aggregateContextBefore],
|
|
21678
22604
|
engineIdentifier,
|
|
21679
|
-
"InitAggregate"
|
|
22605
|
+
"InitAggregate",
|
|
22606
|
+
["team-1"]
|
|
21680
22607
|
);
|
|
21681
22608
|
}
|
|
21682
22609
|
}
|
|
@@ -23484,8 +24411,8 @@ function remarkGuideSettings(options) {
|
|
|
23484
24411
|
if (!parent || typeof index3 !== "number") return;
|
|
23485
24412
|
const directive2 = node2;
|
|
23486
24413
|
if (directive2.type === "containerDirective" && directive2.name === "when") {
|
|
23487
|
-
const
|
|
23488
|
-
const replacement = "error" in
|
|
24414
|
+
const outcome3 = evaluateWhen(options.settings, directive2.attributes ?? {});
|
|
24415
|
+
const replacement = "error" in outcome3 ? [errorBlock(outcome3.error)] : outcome3.show ? directive2.children : [];
|
|
23489
24416
|
parent.children.splice(index3, 1, ...replacement);
|
|
23490
24417
|
return [SKIP, index3];
|
|
23491
24418
|
}
|
|
@@ -23598,6 +24525,137 @@ function readEffectiveGuide(guide, root2, resolved) {
|
|
|
23598
24525
|
return { identifier: guide.definition.identifier, locales, chapters, settings };
|
|
23599
24526
|
}
|
|
23600
24527
|
|
|
24528
|
+
// cli/core/assessment-reports.ts
|
|
24529
|
+
function assessmentAudience(query) {
|
|
24530
|
+
if (query.audience !== "own") return { kind: "all" };
|
|
24531
|
+
if (query.participantId !== void 0 && query.teamId !== void 0) {
|
|
24532
|
+
return { kind: "participant", teamId: query.teamId, participantId: query.participantId };
|
|
24533
|
+
}
|
|
24534
|
+
if (query.viewerRole === "observer" && query.teamId !== void 0) {
|
|
24535
|
+
return { kind: "team", teamId: query.teamId };
|
|
24536
|
+
}
|
|
24537
|
+
return null;
|
|
24538
|
+
}
|
|
24539
|
+
function answerAssessment(input) {
|
|
24540
|
+
const { query } = input;
|
|
24541
|
+
const assessment = input.assessments.find(
|
|
24542
|
+
(entry) => entry.definition.identifier === query.identifier
|
|
24543
|
+
);
|
|
24544
|
+
if (!assessment) {
|
|
24545
|
+
return {
|
|
24546
|
+
type: "assessmentFailure",
|
|
24547
|
+
error: `The package declares no assessment "${query.identifier}"`
|
|
24548
|
+
};
|
|
24549
|
+
}
|
|
24550
|
+
const audience = assessmentAudience(query);
|
|
24551
|
+
if (audience === null) {
|
|
24552
|
+
return {
|
|
24553
|
+
type: "assessmentFailure",
|
|
24554
|
+
error: "getAssessment from a player surface needs the participant or observer behind it"
|
|
24555
|
+
};
|
|
24556
|
+
}
|
|
24557
|
+
const settings = input.settings[ASSESSMENTS_SETTINGS];
|
|
24558
|
+
const report = buildAssessmentReport({
|
|
24559
|
+
definition: assessment.definition,
|
|
24560
|
+
bands: resolveAssessmentBands(assessment.definition, settings?.[query.identifier]),
|
|
24561
|
+
teams: input.teams.map((team) => ({
|
|
24562
|
+
teamId: team.teamId,
|
|
24563
|
+
records: team.context?.[ASSESSMENTS_KEY]?.[query.identifier],
|
|
24564
|
+
complete: team.complete
|
|
24565
|
+
})),
|
|
24566
|
+
participants: input.participants,
|
|
24567
|
+
audience
|
|
24568
|
+
});
|
|
24569
|
+
return { type: "assessment", report };
|
|
24570
|
+
}
|
|
24571
|
+
|
|
24572
|
+
// cli/core/benchmark-samples.ts
|
|
24573
|
+
import { readFile as readFile5, stat as stat3 } from "node:fs/promises";
|
|
24574
|
+
import { join as join10 } from "node:path";
|
|
24575
|
+
function benchmarkSamplePath(identifier) {
|
|
24576
|
+
return join10("benchmarks", identifier, "sample.json");
|
|
24577
|
+
}
|
|
24578
|
+
var NUMERIC_FIGURES = ["mean", "min", "max", "p10", "p25", "p50", "p75", "p90"];
|
|
24579
|
+
function isRecord4(value) {
|
|
24580
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24581
|
+
}
|
|
24582
|
+
function isCount(value) {
|
|
24583
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
24584
|
+
}
|
|
24585
|
+
function fieldProblem(name, value) {
|
|
24586
|
+
if (!isRecord4(value)) return `fields.${name} must be an object`;
|
|
24587
|
+
if (!isCount(value.count)) return `fields.${name}.count must be a whole number of at least 0`;
|
|
24588
|
+
if (value.kind === "number") {
|
|
24589
|
+
for (const figure of NUMERIC_FIGURES) {
|
|
24590
|
+
const v = value[figure];
|
|
24591
|
+
if (v !== void 0 && (typeof v !== "number" || !Number.isFinite(v))) {
|
|
24592
|
+
return `fields.${name}.${figure} must be a number`;
|
|
24593
|
+
}
|
|
24594
|
+
}
|
|
24595
|
+
return null;
|
|
24596
|
+
}
|
|
24597
|
+
if (value.kind === "choice") {
|
|
24598
|
+
if (!isRecord4(value.options)) return `fields.${name}.options must be an object`;
|
|
24599
|
+
for (const [option, count] of Object.entries(value.options)) {
|
|
24600
|
+
if (!isCount(count)) {
|
|
24601
|
+
return `fields.${name}.options.${option} must be a whole number of at least 0`;
|
|
24602
|
+
}
|
|
24603
|
+
}
|
|
24604
|
+
return null;
|
|
24605
|
+
}
|
|
24606
|
+
return `fields.${name}.kind must be "number" or "choice"`;
|
|
24607
|
+
}
|
|
24608
|
+
function benchmarkSampleProblem(sample) {
|
|
24609
|
+
if (!isRecord4(sample)) return "it must be an object";
|
|
24610
|
+
if (sample.scope !== "organisation" && sample.scope !== "global") {
|
|
24611
|
+
return 'scope must be "organisation" or "global"';
|
|
24612
|
+
}
|
|
24613
|
+
if (!isRecord4(sample.fields)) return "fields must be an object of field statistics";
|
|
24614
|
+
for (const [name, value] of Object.entries(sample.fields)) {
|
|
24615
|
+
const problem = fieldProblem(name, value);
|
|
24616
|
+
if (problem) return problem;
|
|
24617
|
+
}
|
|
24618
|
+
return null;
|
|
24619
|
+
}
|
|
24620
|
+
async function isDirectory(path3) {
|
|
24621
|
+
try {
|
|
24622
|
+
return (await stat3(path3)).isDirectory();
|
|
24623
|
+
} catch {
|
|
24624
|
+
return false;
|
|
24625
|
+
}
|
|
24626
|
+
}
|
|
24627
|
+
async function isDeclared(packagePath, identifier, declared) {
|
|
24628
|
+
if (!/^[A-Za-z0-9_-]+$/.test(identifier)) return false;
|
|
24629
|
+
if (declared && declared.length > 0) return declared.includes(identifier);
|
|
24630
|
+
return isDirectory(join10(packagePath, "benchmarks", identifier));
|
|
24631
|
+
}
|
|
24632
|
+
async function answerBenchmarkFromSample(options) {
|
|
24633
|
+
const { packagePath, identifier, where: where3, declared } = options;
|
|
24634
|
+
if (!await isDeclared(packagePath, identifier, declared)) {
|
|
24635
|
+
throw new Error(`No benchmark "${identifier}" is declared`);
|
|
24636
|
+
}
|
|
24637
|
+
const relative8 = benchmarkSamplePath(identifier);
|
|
24638
|
+
let text5;
|
|
24639
|
+
try {
|
|
24640
|
+
text5 = await readFile5(join10(packagePath, relative8), "utf-8");
|
|
24641
|
+
} catch (error) {
|
|
24642
|
+
if (error.code === "ENOENT") return null;
|
|
24643
|
+
throw error;
|
|
24644
|
+
}
|
|
24645
|
+
let sample;
|
|
24646
|
+
try {
|
|
24647
|
+
sample = JSON.parse(text5);
|
|
24648
|
+
} catch (error) {
|
|
24649
|
+
throw new Error(
|
|
24650
|
+
`${relative8} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
24651
|
+
);
|
|
24652
|
+
}
|
|
24653
|
+
const problem = benchmarkSampleProblem(sample);
|
|
24654
|
+
if (problem) throw new Error(`${relative8} is not a benchmark sample: ${problem}`);
|
|
24655
|
+
const { scope, fields } = sample;
|
|
24656
|
+
return { scope, matched: { ...where3[0] }, fields };
|
|
24657
|
+
}
|
|
24658
|
+
|
|
23601
24659
|
// cli/core/clock.ts
|
|
23602
24660
|
var systemClock = {
|
|
23603
24661
|
now: () => Date.now(),
|
|
@@ -24050,9 +25108,9 @@ function withLogicError(result, logicError) {
|
|
|
24050
25108
|
return logicError ? { ...result, logicError } : result;
|
|
24051
25109
|
}
|
|
24052
25110
|
var RefusedError = class extends Error {
|
|
24053
|
-
constructor(message,
|
|
25111
|
+
constructor(message, outcome3) {
|
|
24054
25112
|
super(message);
|
|
24055
|
-
this.outcome =
|
|
25113
|
+
this.outcome = outcome3;
|
|
24056
25114
|
}
|
|
24057
25115
|
outcome;
|
|
24058
25116
|
};
|
|
@@ -24070,12 +25128,12 @@ function withStale(result, error) {
|
|
|
24070
25128
|
function markIfLogic(error, failure) {
|
|
24071
25129
|
return failure ? markLogicFailure(error, failure) : error;
|
|
24072
25130
|
}
|
|
24073
|
-
function refuseIfArmed(faults, fault,
|
|
25131
|
+
function refuseIfArmed(faults, fault, outcome3) {
|
|
24074
25132
|
const fired = faults.fire(fault);
|
|
24075
25133
|
if (!fired) return;
|
|
24076
25134
|
throw new RefusedError(
|
|
24077
25135
|
`Injected ${fault}`,
|
|
24078
|
-
fired.reason === void 0 ?
|
|
25136
|
+
fired.reason === void 0 ? outcome3 : { ...outcome3, message: fired.reason }
|
|
24079
25137
|
);
|
|
24080
25138
|
}
|
|
24081
25139
|
|
|
@@ -24793,6 +25851,49 @@ function undoOneTeam(host, position2) {
|
|
|
24793
25851
|
return true;
|
|
24794
25852
|
}
|
|
24795
25853
|
|
|
25854
|
+
// cli/core/assessment-moves.ts
|
|
25855
|
+
function participantLevelAssessments(assessments) {
|
|
25856
|
+
return assessments.filter((entry) => entry.definition.level === "participant").map((entry) => entry.definition.identifier);
|
|
25857
|
+
}
|
|
25858
|
+
function recordsOf(context) {
|
|
25859
|
+
return context?.[ASSESSMENTS_KEY] ?? {};
|
|
25860
|
+
}
|
|
25861
|
+
function withRecords(context, records) {
|
|
25862
|
+
const next = { ...context };
|
|
25863
|
+
const kept = Object.fromEntries(
|
|
25864
|
+
Object.entries(records).filter(([, byId]) => Object.keys(byId ?? {}).length > 0)
|
|
25865
|
+
);
|
|
25866
|
+
if (Object.keys(kept).length > 0) next[ASSESSMENTS_KEY] = kept;
|
|
25867
|
+
else delete next[ASSESSMENTS_KEY];
|
|
25868
|
+
return next;
|
|
25869
|
+
}
|
|
25870
|
+
function settleAssessmentRecords(input) {
|
|
25871
|
+
const { teamIds, teamOf: teamOf2, identifiers, prefer } = input;
|
|
25872
|
+
const contexts = [...input.contexts];
|
|
25873
|
+
if (identifiers.length === 0) return contexts;
|
|
25874
|
+
const records = contexts.map((context) => structuredClone(recordsOf(context)));
|
|
25875
|
+
const positionOf = new Map(teamIds.map((teamId, position2) => [teamId, position2]));
|
|
25876
|
+
let moved = false;
|
|
25877
|
+
records.forEach((teamRecords, position2) => {
|
|
25878
|
+
for (const identifier of identifiers) {
|
|
25879
|
+
const byId = teamRecords[identifier];
|
|
25880
|
+
if (!byId) continue;
|
|
25881
|
+
for (const [participantId, record2] of Object.entries(byId)) {
|
|
25882
|
+
const destination = positionOf.get(teamOf2(participantId) ?? "");
|
|
25883
|
+
if (destination === void 0 || destination === position2) continue;
|
|
25884
|
+
delete byId[participantId];
|
|
25885
|
+
const target = records[destination][identifier] ??= {};
|
|
25886
|
+
if (participantId === prefer || !(participantId in target)) {
|
|
25887
|
+
target[participantId] = record2;
|
|
25888
|
+
}
|
|
25889
|
+
moved = true;
|
|
25890
|
+
}
|
|
25891
|
+
}
|
|
25892
|
+
});
|
|
25893
|
+
if (!moved) return input.contexts;
|
|
25894
|
+
return contexts.map((context, position2) => withRecords(context, records[position2]));
|
|
25895
|
+
}
|
|
25896
|
+
|
|
24796
25897
|
// cli/core/team-names.ts
|
|
24797
25898
|
function pickLocalised(entry, locale) {
|
|
24798
25899
|
if (!entry) return void 0;
|
|
@@ -25128,6 +26229,7 @@ var SessionRoster = class {
|
|
|
25128
26229
|
if (fromTeamId === toTeamId) return void 0;
|
|
25129
26230
|
const moved = this.host.participants.move(fromTeamId, participantId, toTeamId);
|
|
25130
26231
|
if (!moved) throw new DeniedError("The participant could not be moved");
|
|
26232
|
+
this.settleAssessments(participantId);
|
|
25131
26233
|
const move = { fromTeamId, toTeamId };
|
|
25132
26234
|
await this.fireHook("participantMove", moved, {
|
|
25133
26235
|
teamId: fromTeamId,
|
|
@@ -25136,6 +26238,25 @@ var SessionRoster = class {
|
|
|
25136
26238
|
await this.fireHook("participantMove", moved, { payload: { ...move, phase: "arrival" } });
|
|
25137
26239
|
return void 0;
|
|
25138
26240
|
}
|
|
26241
|
+
/**
|
|
26242
|
+
* Move participant-level assessment results to the team each participant
|
|
26243
|
+
* is on now (§6.17.2): after a move, with `prefer` the one who moved, and
|
|
26244
|
+
* after an undo, which restores results to the teams that held them then.
|
|
26245
|
+
*/
|
|
26246
|
+
settleAssessments(prefer) {
|
|
26247
|
+
const { executor, state: state2 } = this.host;
|
|
26248
|
+
const identifiers = participantLevelAssessments(executor.getConfig()?.assessments ?? []);
|
|
26249
|
+
if (identifiers.length === 0) return;
|
|
26250
|
+
const contexts = state2.getTeamContexts();
|
|
26251
|
+
const settled = settleAssessmentRecords({
|
|
26252
|
+
contexts,
|
|
26253
|
+
teamIds: state2.getTeamIndexes().map((index3) => `team-${index3 + 1}`),
|
|
26254
|
+
teamOf: (id) => this.findParticipantTeam(id),
|
|
26255
|
+
identifiers,
|
|
26256
|
+
prefer
|
|
26257
|
+
});
|
|
26258
|
+
if (settled !== contexts) state2.setTeamContexts(settled);
|
|
26259
|
+
}
|
|
25139
26260
|
findParticipantTeam(participantId) {
|
|
25140
26261
|
for (const index3 of this.host.state.getTeamIndexes()) {
|
|
25141
26262
|
const teamId = `team-${index3 + 1}`;
|
|
@@ -25197,7 +26318,7 @@ function insertAt(values, position2, value) {
|
|
|
25197
26318
|
|
|
25198
26319
|
// cli/execution/scenario-gates.ts
|
|
25199
26320
|
import { existsSync as existsSync8 } from "fs";
|
|
25200
|
-
import { readFile as
|
|
26321
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
25201
26322
|
var SCENARIO_VALIDATION = "scenario-validation";
|
|
25202
26323
|
var SCENARIO_FILES = "scenario-files";
|
|
25203
26324
|
var SESSION_VALIDATION = "session-validation";
|
|
@@ -25230,7 +26351,7 @@ async function runScenarioGates(options) {
|
|
|
25230
26351
|
if (!hasScenarioGate(config)) return [];
|
|
25231
26352
|
const loader = options.loader ?? new LogicLoader(options.packagePath, {
|
|
25232
26353
|
transpile: Transpile,
|
|
25233
|
-
fs: { existsSync: existsSync8, readFile:
|
|
26354
|
+
fs: { existsSync: existsSync8, readFile: readFile6 }
|
|
25234
26355
|
});
|
|
25235
26356
|
const resolved = resolveSettingsLayers(
|
|
25236
26357
|
config,
|
|
@@ -25592,7 +26713,9 @@ var IDLE_TIMER = {
|
|
|
25592
26713
|
pausedAt: null,
|
|
25593
26714
|
pausedMs: 0,
|
|
25594
26715
|
extendedMs: 0,
|
|
25595
|
-
scheduleStartedAt: null
|
|
26716
|
+
scheduleStartedAt: null,
|
|
26717
|
+
dormant: false,
|
|
26718
|
+
dormantAt: null
|
|
25596
26719
|
};
|
|
25597
26720
|
function scheduleFor(result, now) {
|
|
25598
26721
|
const problem = validateTickControllerResult2(result, { now });
|
|
@@ -25638,6 +26761,8 @@ var TickTimer = class {
|
|
|
25638
26761
|
pausedMs = 0;
|
|
25639
26762
|
scheduleStartedAt = null;
|
|
25640
26763
|
extendedMs = 0;
|
|
26764
|
+
/** When the session went dormant (§11.4a), or null while it is not. */
|
|
26765
|
+
dormantAt = null;
|
|
25641
26766
|
/** The answer the current schedule was built from, to tell a re-evaluation that changed nothing. */
|
|
25642
26767
|
answer = null;
|
|
25643
26768
|
/**
|
|
@@ -25677,7 +26802,7 @@ var TickTimer = class {
|
|
|
25677
26802
|
this.intervalMs = schedule.intervalMs;
|
|
25678
26803
|
this.usedNextTickAt = schedule.usedNextTickAt;
|
|
25679
26804
|
this.scheduleStartedAt ??= now;
|
|
25680
|
-
if (this.paused) {
|
|
26805
|
+
if (this.paused || this.dormantAt !== null) {
|
|
25681
26806
|
this.remainingMs = schedule.delayMs;
|
|
25682
26807
|
return schedule.clamped;
|
|
25683
26808
|
}
|
|
@@ -25689,8 +26814,32 @@ var TickTimer = class {
|
|
|
25689
26814
|
const now = this.clock.now();
|
|
25690
26815
|
this.paused = true;
|
|
25691
26816
|
this.pausedAt = now;
|
|
25692
|
-
|
|
25693
|
-
|
|
26817
|
+
if (this.dormantAt === null) this.hold(now);
|
|
26818
|
+
}
|
|
26819
|
+
/**
|
|
26820
|
+
* Suspend automatic ticking because the session was left unattended
|
|
26821
|
+
* (§11.4a). Held like a pause, but separate from one: waking never ends a
|
|
26822
|
+
* facilitator's pause.
|
|
26823
|
+
*/
|
|
26824
|
+
suspend() {
|
|
26825
|
+
if (this.dormantAt !== null) return;
|
|
26826
|
+
const now = this.clock.now();
|
|
26827
|
+
this.dormantAt = now;
|
|
26828
|
+
if (!this.paused) this.hold(now);
|
|
26829
|
+
}
|
|
26830
|
+
/**
|
|
26831
|
+
* Wake from dormancy (§11.4a), resuming as from a pause (§11.4). The
|
|
26832
|
+
* dormant time joins `pausedMs`, except where a facilitator's pause
|
|
26833
|
+
* already covers it. A timer the facilitator paused stays paused.
|
|
26834
|
+
*/
|
|
26835
|
+
wake() {
|
|
26836
|
+
if (this.dormantAt === null) return "idle";
|
|
26837
|
+
const now = this.clock.now();
|
|
26838
|
+
const dormantAt = this.dormantAt;
|
|
26839
|
+
this.dormantAt = null;
|
|
26840
|
+
if (this.paused) return "idle";
|
|
26841
|
+
this.pausedMs += now - dormantAt;
|
|
26842
|
+
return this.continue(now);
|
|
25694
26843
|
}
|
|
25695
26844
|
/**
|
|
25696
26845
|
* Resume (§11.4). Interval mode continues from the time that was left;
|
|
@@ -25703,6 +26852,11 @@ var TickTimer = class {
|
|
|
25703
26852
|
this.paused = false;
|
|
25704
26853
|
if (this.pausedAt !== null) this.pausedMs += now - this.pausedAt;
|
|
25705
26854
|
this.pausedAt = null;
|
|
26855
|
+
if (this.dormantAt !== null) return "idle";
|
|
26856
|
+
return this.continue(now);
|
|
26857
|
+
}
|
|
26858
|
+
/** Pick a held schedule back up, after a pause or dormancy. */
|
|
26859
|
+
continue(now) {
|
|
25706
26860
|
if (!this.enabled) return "idle";
|
|
25707
26861
|
if (this.usedNextTickAt) {
|
|
25708
26862
|
this.remainingMs = null;
|
|
@@ -25722,6 +26876,9 @@ var TickTimer = class {
|
|
|
25722
26876
|
if (this.paused) {
|
|
25723
26877
|
return "The timer is paused, so there is no scheduled tick to move. Resume it first";
|
|
25724
26878
|
}
|
|
26879
|
+
if (this.dormantAt !== null) {
|
|
26880
|
+
return "The session is dormant, so there is no scheduled tick to move";
|
|
26881
|
+
}
|
|
25725
26882
|
if (this.dueAt === null) return "No tick is scheduled, so there is no deadline to move";
|
|
25726
26883
|
const now = this.clock.now();
|
|
25727
26884
|
const target = Math.max(now, this.dueAt + ms);
|
|
@@ -25740,17 +26897,25 @@ var TickTimer = class {
|
|
|
25740
26897
|
this.intervalMs = null;
|
|
25741
26898
|
}
|
|
25742
26899
|
state() {
|
|
26900
|
+
const held = this.paused || this.dormantAt !== null;
|
|
25743
26901
|
return {
|
|
25744
26902
|
enabled: this.enabled,
|
|
25745
26903
|
paused: this.paused,
|
|
25746
|
-
nextTickAt:
|
|
25747
|
-
intervalMs: this.enabled && !
|
|
26904
|
+
nextTickAt: held ? null : this.dueAt,
|
|
26905
|
+
intervalMs: this.enabled && !held ? this.intervalMs : null,
|
|
25748
26906
|
pausedAt: this.pausedAt,
|
|
25749
26907
|
pausedMs: this.pausedMs,
|
|
25750
26908
|
extendedMs: this.extendedMs,
|
|
25751
|
-
scheduleStartedAt: this.scheduleStartedAt
|
|
26909
|
+
scheduleStartedAt: this.scheduleStartedAt,
|
|
26910
|
+
dormant: this.dormantAt !== null,
|
|
26911
|
+
dormantAt: this.dormantAt
|
|
25752
26912
|
};
|
|
25753
26913
|
}
|
|
26914
|
+
/** Keep what is left of this window, and stop the pending tick. */
|
|
26915
|
+
hold(now) {
|
|
26916
|
+
this.remainingMs = this.dueAt === null ? null : Math.max(0, this.dueAt - now);
|
|
26917
|
+
this.cancelPending();
|
|
26918
|
+
}
|
|
25754
26919
|
arm(at) {
|
|
25755
26920
|
this.cancelPending();
|
|
25756
26921
|
this.dueAt = at;
|
|
@@ -25769,15 +26934,70 @@ var TickTimer = class {
|
|
|
25769
26934
|
|
|
25770
26935
|
// cli/core/session-timers.ts
|
|
25771
26936
|
var COHORT = -1;
|
|
26937
|
+
var DORMANT_AFTER_MS = 24 * 60 * 60 * 1e3;
|
|
26938
|
+
var DORMANT_AFTER_TICKS = 100;
|
|
25772
26939
|
var SessionTimers = class {
|
|
25773
26940
|
constructor(host) {
|
|
25774
26941
|
this.host = host;
|
|
26942
|
+
this.lastActivityAt = host.clock.now();
|
|
25775
26943
|
}
|
|
25776
26944
|
host;
|
|
25777
26945
|
/** True while a tick runs, so a timer firing then is dropped (§11.1). */
|
|
25778
26946
|
ticking = false;
|
|
25779
26947
|
/** Automatic tick timers, keyed by team index, or {@link COHORT} (§11). */
|
|
25780
26948
|
timers = /* @__PURE__ */ new Map();
|
|
26949
|
+
/** When the session went dormant (§11.4a), or null while it is not. */
|
|
26950
|
+
dormantAt = null;
|
|
26951
|
+
/** When anything outside the host last used the session (§11.4a). */
|
|
26952
|
+
lastActivityAt;
|
|
26953
|
+
/** Automatic ticks since then, every team's together (§11.4a). */
|
|
26954
|
+
unattendedTicks = 0;
|
|
26955
|
+
/** Surfaces and console pages open on the session, which keep it awake. */
|
|
26956
|
+
openSurfaces = 0;
|
|
26957
|
+
/** Whether automatic ticking is suspended because the session was unattended. */
|
|
26958
|
+
get dormant() {
|
|
26959
|
+
return this.dormantAt !== null;
|
|
26960
|
+
}
|
|
26961
|
+
/**
|
|
26962
|
+
* Something outside the host used the session (§11.4a): restart the
|
|
26963
|
+
* clock, and wake the session if it is dormant. Interval-mode timers pick
|
|
26964
|
+
* up at once; what is returned re-asks the controller for scheduled-mode
|
|
26965
|
+
* ones, for the caller to queue ahead of the activity itself. Null when
|
|
26966
|
+
* nothing woke.
|
|
26967
|
+
*/
|
|
26968
|
+
noteActivity() {
|
|
26969
|
+
this.lastActivityAt = this.host.clock.now();
|
|
26970
|
+
this.unattendedTicks = 0;
|
|
26971
|
+
if (this.dormantAt === null) return null;
|
|
26972
|
+
this.dormantAt = null;
|
|
26973
|
+
const reevaluate = this.groups().filter(
|
|
26974
|
+
(group) => this.timers.get(group.key)?.wake() === "re-evaluate"
|
|
26975
|
+
);
|
|
26976
|
+
return async () => {
|
|
26977
|
+
for (const group of reevaluate) await this.evaluate(group);
|
|
26978
|
+
};
|
|
26979
|
+
}
|
|
26980
|
+
/**
|
|
26981
|
+
* How many surfaces are open on the session. Opening one is activity, and
|
|
26982
|
+
* while any is open the session stays awake: the dev server counts an
|
|
26983
|
+
* idle open surface as use, which the specification leaves to the host.
|
|
26984
|
+
*/
|
|
26985
|
+
surfacesOpen(count) {
|
|
26986
|
+
const opened = count > this.openSurfaces;
|
|
26987
|
+
const lastClosed = count === 0 && this.openSurfaces > 0;
|
|
26988
|
+
this.openSurfaces = count;
|
|
26989
|
+
return opened || lastClosed ? this.noteActivity() : null;
|
|
26990
|
+
}
|
|
26991
|
+
/**
|
|
26992
|
+
* Suspend automatic ticking now (§11.4a), whether or not the minimums
|
|
26993
|
+
* have passed: the dev server's way to show an author a dormant session
|
|
26994
|
+
* without waiting a day.
|
|
26995
|
+
*/
|
|
26996
|
+
suspend() {
|
|
26997
|
+
if (this.dormantAt !== null) return;
|
|
26998
|
+
this.dormantAt = this.host.clock.now();
|
|
26999
|
+
for (const timer of this.timers.values()) timer.suspend();
|
|
27000
|
+
}
|
|
25781
27001
|
/** Cancel every timer, for a session that is stopping. */
|
|
25782
27002
|
stop() {
|
|
25783
27003
|
for (const timer of this.timers.values()) timer.cancel();
|
|
@@ -25902,6 +27122,7 @@ var SessionTimers = class {
|
|
|
25902
27122
|
let timer = this.timers.get(key);
|
|
25903
27123
|
if (!timer) {
|
|
25904
27124
|
timer = new TickTimer(this.host.clock, () => void this.onFired(key));
|
|
27125
|
+
if (this.dormantAt !== null) timer.suspend();
|
|
25905
27126
|
this.timers.set(key, timer);
|
|
25906
27127
|
}
|
|
25907
27128
|
return timer;
|
|
@@ -26002,18 +27223,191 @@ var SessionTimers = class {
|
|
|
26002
27223
|
type: "tick",
|
|
26003
27224
|
...key === COHORT ? {} : { teamIndex: key }
|
|
26004
27225
|
});
|
|
26005
|
-
if (result.ok)
|
|
27226
|
+
if (result.ok) {
|
|
27227
|
+
this.unattendedTicks += 1;
|
|
27228
|
+
this.suspendIfUnattended();
|
|
27229
|
+
return;
|
|
27230
|
+
}
|
|
26006
27231
|
await this.host.enqueue(async () => {
|
|
26007
27232
|
const group = this.groups().find((candidate) => candidate.key === key);
|
|
26008
27233
|
if (group) await this.evaluate(group);
|
|
26009
27234
|
this.host.emitState("timer");
|
|
26010
27235
|
});
|
|
26011
27236
|
}
|
|
27237
|
+
/**
|
|
27238
|
+
* Go dormant once nothing has used the session for both minimums, and no
|
|
27239
|
+
* surface is open (§11.4a). Judged after an automatic tick, since nothing
|
|
27240
|
+
* else happens to a session nobody is using.
|
|
27241
|
+
*/
|
|
27242
|
+
suspendIfUnattended() {
|
|
27243
|
+
if (this.dormantAt !== null || this.openSurfaces > 0) return;
|
|
27244
|
+
if (this.unattendedTicks < DORMANT_AFTER_TICKS) return;
|
|
27245
|
+
if (this.host.clock.now() - this.lastActivityAt < DORMANT_AFTER_MS) return;
|
|
27246
|
+
this.suspend();
|
|
27247
|
+
this.host.emitState("dormant");
|
|
27248
|
+
}
|
|
26012
27249
|
};
|
|
26013
27250
|
|
|
26014
27251
|
// cli/core/session-writes.ts
|
|
26015
27252
|
import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
|
|
26016
27253
|
|
|
27254
|
+
// cli/validation/assessment-validation.ts
|
|
27255
|
+
var MAX_BANDS = 10;
|
|
27256
|
+
function outcome() {
|
|
27257
|
+
return { errors: [], warnings: [], findings: [] };
|
|
27258
|
+
}
|
|
27259
|
+
function addError(result, finding) {
|
|
27260
|
+
result.errors.push(finding.hint ? `${finding.message}. ${finding.hint}` : finding.message);
|
|
27261
|
+
result.findings.push({ severity: "error", ...finding });
|
|
27262
|
+
}
|
|
27263
|
+
function bandsProblem(definition3, bands) {
|
|
27264
|
+
if (bands.length === 0) return null;
|
|
27265
|
+
if (bands[0].from !== definition3.min) {
|
|
27266
|
+
return `the first band, "${bands[0].id}", starts at ${bands[0].from} rather than at the minimum score, ${definition3.min}`;
|
|
27267
|
+
}
|
|
27268
|
+
for (let i = 1; i < bands.length; i++) {
|
|
27269
|
+
if (bands[i].from <= bands[i - 1].from) {
|
|
27270
|
+
return `band "${bands[i].id}" starts at ${bands[i].from}, not above "${bands[i - 1].id}" at ${bands[i - 1].from}; bands ascend in the order they are listed`;
|
|
27271
|
+
}
|
|
27272
|
+
}
|
|
27273
|
+
const last = bands[bands.length - 1];
|
|
27274
|
+
if (last.from > definition3.max) {
|
|
27275
|
+
return `band "${last.id}" starts at ${last.from}, above the maximum score, ${definition3.max}`;
|
|
27276
|
+
}
|
|
27277
|
+
return null;
|
|
27278
|
+
}
|
|
27279
|
+
function resolvedBandProblems(assessments, resolved) {
|
|
27280
|
+
const settings = resolved[ASSESSMENTS_SETTINGS];
|
|
27281
|
+
const problems = [];
|
|
27282
|
+
for (const { definition: definition3 } of assessments) {
|
|
27283
|
+
const problem = bandsProblem(
|
|
27284
|
+
definition3,
|
|
27285
|
+
resolveAssessmentBands(definition3, settings?.[definition3.identifier])
|
|
27286
|
+
);
|
|
27287
|
+
if (problem !== null) {
|
|
27288
|
+
problems.push(
|
|
27289
|
+
`The bands of assessment "${definition3.identifier}" would be out of order: ${problem}`
|
|
27290
|
+
);
|
|
27291
|
+
}
|
|
27292
|
+
}
|
|
27293
|
+
return problems;
|
|
27294
|
+
}
|
|
27295
|
+
function validateAssessment(assessment, config) {
|
|
27296
|
+
const result = outcome();
|
|
27297
|
+
const { definition: definition3 } = assessment;
|
|
27298
|
+
const { identifier } = definition3;
|
|
27299
|
+
const file = bundleFileOf("assessment", identifier);
|
|
27300
|
+
const resource = { type: "assessment", identifier };
|
|
27301
|
+
if (!(config.requires ?? []).includes(ASSESSMENTS_FEATURE)) {
|
|
27302
|
+
addError(result, {
|
|
27303
|
+
code: "FEATURE_UNDECLARED",
|
|
27304
|
+
message: `Assessment "${identifier}" needs the \`${ASSESSMENTS_FEATURE}\` feature, but \`requires\` does not list it`,
|
|
27305
|
+
hint: `Add "${ASSESSMENTS_FEATURE}" to \`requires\` in seriousgaming.sdk.json, so a runtime that cannot hold results refuses the package rather than failing the first round that scores one`,
|
|
27306
|
+
file: MANIFEST_FILE,
|
|
27307
|
+
pointer: pointerOf("requires"),
|
|
27308
|
+
resource
|
|
27309
|
+
});
|
|
27310
|
+
}
|
|
27311
|
+
if (!(definition3.max > definition3.min)) {
|
|
27312
|
+
addError(result, {
|
|
27313
|
+
code: "PACKAGE_INVALID",
|
|
27314
|
+
message: `Assessment "${identifier}" has a maximum score of ${definition3.max}, which is not above its minimum, ${definition3.min}`,
|
|
27315
|
+
hint: 'Set "max" above "min"',
|
|
27316
|
+
file,
|
|
27317
|
+
pointer: pointerOf("definition", "max"),
|
|
27318
|
+
resource
|
|
27319
|
+
});
|
|
27320
|
+
return result;
|
|
27321
|
+
}
|
|
27322
|
+
if ((definition3.bands?.length ?? 0) > MAX_BANDS) {
|
|
27323
|
+
addError(result, {
|
|
27324
|
+
code: "PACKAGE_INVALID",
|
|
27325
|
+
message: `Assessment "${identifier}" declares ${definition3.bands?.length} bands, more than the ${MAX_BANDS} an assessment may have`,
|
|
27326
|
+
hint: "Merge neighbouring bands",
|
|
27327
|
+
file,
|
|
27328
|
+
pointer: pointerOf("definition", "bands"),
|
|
27329
|
+
resource
|
|
27330
|
+
});
|
|
27331
|
+
}
|
|
27332
|
+
const ids = (definition3.bands ?? []).map((band) => band.id);
|
|
27333
|
+
const duplicate = ids.find((id, index3) => ids.indexOf(id) !== index3);
|
|
27334
|
+
if (duplicate !== void 0) {
|
|
27335
|
+
addError(result, {
|
|
27336
|
+
code: "PACKAGE_INVALID",
|
|
27337
|
+
message: `Assessment "${identifier}" declares band "${duplicate}" more than once`,
|
|
27338
|
+
hint: "Give each band its own id",
|
|
27339
|
+
file,
|
|
27340
|
+
pointer: pointerOf("definition", "bands"),
|
|
27341
|
+
resource
|
|
27342
|
+
});
|
|
27343
|
+
}
|
|
27344
|
+
const declaredProblem = bandsProblem(definition3, resolveAssessmentBands(definition3));
|
|
27345
|
+
if (declaredProblem !== null) {
|
|
27346
|
+
addError(result, {
|
|
27347
|
+
code: "PACKAGE_INVALID",
|
|
27348
|
+
message: `Assessment "${identifier}": ${declaredProblem}`,
|
|
27349
|
+
hint: 'List the bands lowest first, the first starting at "min", each "from" above the last and no higher than "max"',
|
|
27350
|
+
file,
|
|
27351
|
+
pointer: pointerOf("definition", "bands"),
|
|
27352
|
+
resource
|
|
27353
|
+
});
|
|
27354
|
+
}
|
|
27355
|
+
if (!(config.engine?.definition.assessments?.includes(identifier) ?? false)) {
|
|
27356
|
+
const message = `Assessment "${identifier}" is not in the engine's "assessments", so nothing can score it and it will never hold a result`;
|
|
27357
|
+
result.warnings.push(message);
|
|
27358
|
+
result.findings.push({
|
|
27359
|
+
severity: "warning",
|
|
27360
|
+
code: "ASSESSMENT_UNWRITTEN",
|
|
27361
|
+
message,
|
|
27362
|
+
hint: `Add "${identifier}" to "assessments" in engine/engine.sdk.json, or delete the assessment`,
|
|
27363
|
+
file,
|
|
27364
|
+
resource
|
|
27365
|
+
});
|
|
27366
|
+
}
|
|
27367
|
+
for (const scenario of config.scenarios ?? []) {
|
|
27368
|
+
const settings = scenario.definition.settings?.[ASSESSMENTS_SETTINGS];
|
|
27369
|
+
const override = settings?.[identifier];
|
|
27370
|
+
if (override === void 0) continue;
|
|
27371
|
+
const problem = bandsProblem(definition3, resolveAssessmentBands(definition3, override));
|
|
27372
|
+
if (problem === null) continue;
|
|
27373
|
+
addError(result, {
|
|
27374
|
+
code: "PACKAGE_INVALID",
|
|
27375
|
+
message: `Scenario "${scenario.definition.identifier}" moves the bands of assessment "${identifier}" out of order: ${problem}`,
|
|
27376
|
+
hint: "Keep each band starting above the one before it, the first at the minimum score",
|
|
27377
|
+
file: bundleFileOf("scenario", scenario.definition.identifier),
|
|
27378
|
+
pointer: pointerOf("definition", "settings", ASSESSMENTS_SETTINGS, identifier),
|
|
27379
|
+
resource: { type: "scenario", identifier: scenario.definition.identifier }
|
|
27380
|
+
});
|
|
27381
|
+
}
|
|
27382
|
+
return result;
|
|
27383
|
+
}
|
|
27384
|
+
function validateEngineAssessments(config) {
|
|
27385
|
+
const result = outcome();
|
|
27386
|
+
const declared = new Set((config.assessments ?? []).map((a) => a.definition.identifier));
|
|
27387
|
+
const engine = config.engine;
|
|
27388
|
+
if (engine) {
|
|
27389
|
+
(engine.definition.assessments ?? []).forEach((identifier, index3) => {
|
|
27390
|
+
if (declared.has(identifier)) return;
|
|
27391
|
+
addError(result, {
|
|
27392
|
+
code: "REFERENCE_UNKNOWN",
|
|
27393
|
+
message: `Engine declares assessment "${identifier}", which the package does not have`,
|
|
27394
|
+
hint: `Create it with "new assessment", or remove it from the engine's "assessments"`,
|
|
27395
|
+
file: bundleFileOf("engine", "engine"),
|
|
27396
|
+
pointer: pointerOf("definition", "assessments", index3),
|
|
27397
|
+
resource: { type: "engine", identifier: engine.definition.identifier }
|
|
27398
|
+
});
|
|
27399
|
+
});
|
|
27400
|
+
}
|
|
27401
|
+
if (declared.size > MAX_ASSESSMENTS_PER_GAME) {
|
|
27402
|
+
addError(result, {
|
|
27403
|
+
code: "PACKAGE_INVALID",
|
|
27404
|
+
message: `The game declares ${declared.size} assessments, more than the ${MAX_ASSESSMENTS_PER_GAME} a game may have`,
|
|
27405
|
+
hint: "Fold related measures into one assessment, or remove the ones nobody reports"
|
|
27406
|
+
});
|
|
27407
|
+
}
|
|
27408
|
+
return result;
|
|
27409
|
+
}
|
|
27410
|
+
|
|
26017
27411
|
// cli/validation/file-settings.ts
|
|
26018
27412
|
function fileSettingValues(declared, value, path3 = [], root2 = declared) {
|
|
26019
27413
|
if (!declared || typeof declared !== "object" || !root2) return [];
|
|
@@ -26236,11 +27630,16 @@ async function updateSettings(host, command) {
|
|
|
26236
27630
|
refuseUnconfiguredSettings(host, command.uiIdentifier, command.payload);
|
|
26237
27631
|
const existing = executor.getSessionOverrides() ?? {};
|
|
26238
27632
|
const changed = changedFrom(command.payload, executor.resolveConfiguration());
|
|
26239
|
-
const layer = deepMergeContext(existing,
|
|
27633
|
+
const layer = deepMergeContext(existing, isRecord5(changed) ? changed : {});
|
|
26240
27634
|
const config = executor.getConfig();
|
|
26241
27635
|
const result = config ? validateSessionOverrides(layer, settingsSchemas(config)) : { valid: true };
|
|
26242
27636
|
if (!result.valid) throw new DeniedError(result.errors ?? "Invalid settings");
|
|
26243
|
-
|
|
27637
|
+
const bands = resolvedBandProblems(
|
|
27638
|
+
config?.assessments ?? [],
|
|
27639
|
+
deepMergeContext(executor.buildResetConfiguration(), layer)
|
|
27640
|
+
);
|
|
27641
|
+
if (bands.length > 0) throw new DeniedError(bands.join("\n"));
|
|
27642
|
+
await refuseUnfitFiles(host, isRecord5(changed) ? changed : {});
|
|
26244
27643
|
executor.setConfiguration(layer);
|
|
26245
27644
|
return void 0;
|
|
26246
27645
|
}
|
|
@@ -26258,13 +27657,17 @@ async function updateScenarioDraft(host, drafts, command) {
|
|
|
26258
27657
|
host.executor.resolveScenarioDraft(scenarioId, edits)
|
|
26259
27658
|
);
|
|
26260
27659
|
const config = host.executor.getConfig();
|
|
26261
|
-
const
|
|
26262
|
-
|
|
26263
|
-
settingsSchemas(config)
|
|
26264
|
-
|
|
27660
|
+
const merged = deepMergeContext(edits, isRecord5(changed) ? changed : {});
|
|
27661
|
+
const errors = config ? [
|
|
27662
|
+
...collectSettingsOverrideErrors(merged, settingsSchemas(config)),
|
|
27663
|
+
...resolvedBandProblems(
|
|
27664
|
+
config.assessments ?? [],
|
|
27665
|
+
host.executor.resolveScenarioDraft(scenarioId, merged)
|
|
27666
|
+
)
|
|
27667
|
+
] : [];
|
|
26265
27668
|
if (errors.length > 0) throw new DeniedError(errors.join("\n"));
|
|
26266
|
-
await refuseUnfitFiles(host,
|
|
26267
|
-
drafts.record(scenarioId,
|
|
27669
|
+
await refuseUnfitFiles(host, isRecord5(changed) ? changed : {}, { draft: true });
|
|
27670
|
+
drafts.record(scenarioId, isRecord5(changed) ? changed : {});
|
|
26268
27671
|
return void 0;
|
|
26269
27672
|
}
|
|
26270
27673
|
async function refuseUnfitFiles(host, changed, options = {}) {
|
|
@@ -26382,11 +27785,11 @@ function resolveSharedWrites(host, board) {
|
|
|
26382
27785
|
executor.setSharedContext(deepMergeContext(store, changed));
|
|
26383
27786
|
return { ...board, ...executor.getSharedContext() };
|
|
26384
27787
|
}
|
|
26385
|
-
function
|
|
27788
|
+
function isRecord5(value) {
|
|
26386
27789
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26387
27790
|
}
|
|
26388
27791
|
function changedFrom(update, current) {
|
|
26389
|
-
if (
|
|
27792
|
+
if (isRecord5(update) && isRecord5(current)) {
|
|
26390
27793
|
const changed = {};
|
|
26391
27794
|
for (const [key, value] of Object.entries(update)) {
|
|
26392
27795
|
const difference = changedFrom(value, current[key]);
|
|
@@ -26762,8 +28165,10 @@ var PLAY_STAGE = /* @__PURE__ */ new Set([
|
|
|
26762
28165
|
"moveParticipant",
|
|
26763
28166
|
"renameOwnTeam",
|
|
26764
28167
|
"renameSelf",
|
|
26765
|
-
"extendTick"
|
|
28168
|
+
"extendTick",
|
|
28169
|
+
"makeDormant"
|
|
26766
28170
|
]);
|
|
28171
|
+
var HOST_CONTROLS = /* @__PURE__ */ new Set(["armFault", "disarmFault", "makeDormant"]);
|
|
26767
28172
|
var STALE_BLOCKED = /* @__PURE__ */ new Set([
|
|
26768
28173
|
"tick",
|
|
26769
28174
|
"undo",
|
|
@@ -26902,7 +28307,7 @@ var Session = class {
|
|
|
26902
28307
|
},
|
|
26903
28308
|
enqueue: (work) => this.enqueue(work),
|
|
26904
28309
|
apply: (command) => this.apply(command),
|
|
26905
|
-
submit: (command) => this.
|
|
28310
|
+
submit: (command) => this.enqueue(() => this.apply(command)),
|
|
26906
28311
|
report: (message, source, teamId) => this.report(message, source, teamId),
|
|
26907
28312
|
emit: (event) => this.emit(event),
|
|
26908
28313
|
emitState: (cause) => this.emitState(cause)
|
|
@@ -26952,8 +28357,24 @@ var Session = class {
|
|
|
26952
28357
|
/** Submit a state-changing command. Queued, in order, one at a time. */
|
|
26953
28358
|
submit(command) {
|
|
26954
28359
|
if (command.type === "advanceClock") return this.advanceClock(command.byMs);
|
|
28360
|
+
if (!HOST_CONTROLS.has(command.type)) this.noteActivity();
|
|
26955
28361
|
return this.enqueue(() => this.apply(command));
|
|
26956
28362
|
}
|
|
28363
|
+
/**
|
|
28364
|
+
* Something outside the host used the session (§11.4a). A dormant session
|
|
28365
|
+
* wakes before the activity is handled: the re-evaluation waking needs is
|
|
28366
|
+
* queued ahead of it.
|
|
28367
|
+
*/
|
|
28368
|
+
noteActivity() {
|
|
28369
|
+
this.finishWaking(this.timers.noteActivity());
|
|
28370
|
+
}
|
|
28371
|
+
finishWaking(reevaluate) {
|
|
28372
|
+
if (!reevaluate) return;
|
|
28373
|
+
void this.enqueue(async () => {
|
|
28374
|
+
await reevaluate();
|
|
28375
|
+
this.emitState("woke");
|
|
28376
|
+
});
|
|
28377
|
+
}
|
|
26957
28378
|
/**
|
|
26958
28379
|
* Queue `work` as one operation: every logic call it makes reads the same
|
|
26959
28380
|
* `meta.now`, taken as it starts rather than as it was submitted (§10.2).
|
|
@@ -27023,6 +28444,7 @@ var Session = class {
|
|
|
27023
28444
|
case "getState":
|
|
27024
28445
|
return { type: "state", state: this.project() };
|
|
27025
28446
|
case "callEndpoint":
|
|
28447
|
+
this.noteActivity();
|
|
27026
28448
|
return this.endpoints.answer(command);
|
|
27027
28449
|
case "getEndpointAudit":
|
|
27028
28450
|
return { type: "endpointAudit", entries: [...this.endpoints.auditLog()] };
|
|
@@ -27074,6 +28496,41 @@ var Session = class {
|
|
|
27074
28496
|
}
|
|
27075
28497
|
return { type: "participants", participants: this.roster.records() };
|
|
27076
28498
|
}
|
|
28499
|
+
case "getAssessment": {
|
|
28500
|
+
const indexes = this.state.getTeamIndexes();
|
|
28501
|
+
const contexts = this.state.getTeamContexts();
|
|
28502
|
+
const complete = this.state.teamsFinished(this.tickLimit());
|
|
28503
|
+
const teams = indexes.map((index3, position2) => ({
|
|
28504
|
+
teamId: `team-${index3 + 1}`,
|
|
28505
|
+
context: contexts[position2],
|
|
28506
|
+
complete: complete[position2] ?? false
|
|
28507
|
+
}));
|
|
28508
|
+
return answerAssessment({
|
|
28509
|
+
query: command,
|
|
28510
|
+
assessments: this.executor.getConfig()?.assessments ?? [],
|
|
28511
|
+
teams,
|
|
28512
|
+
participants: teams.flatMap(
|
|
28513
|
+
(team) => this.participants.list(team.teamId).map((record2) => ({ id: record2.id, teamId: team.teamId }))
|
|
28514
|
+
),
|
|
28515
|
+
settings: this.executor.resolveConfiguration()
|
|
28516
|
+
});
|
|
28517
|
+
}
|
|
28518
|
+
case "getBenchmark": {
|
|
28519
|
+
try {
|
|
28520
|
+
const statistics = await answerBenchmarkFromSample({
|
|
28521
|
+
packagePath: this.options.packagePath,
|
|
28522
|
+
identifier: command.identifier,
|
|
28523
|
+
where: benchmarkFilters({ where: command.where }),
|
|
28524
|
+
declared: this.executor.getConfig()?.benchmarks?.map((benchmark) => benchmark.definition.identifier)
|
|
28525
|
+
});
|
|
28526
|
+
return { type: "benchmark", statistics };
|
|
28527
|
+
} catch (error) {
|
|
28528
|
+
return {
|
|
28529
|
+
type: "benchmarkFailure",
|
|
28530
|
+
error: errorMessage(error, "The benchmark could not be read")
|
|
28531
|
+
};
|
|
28532
|
+
}
|
|
28533
|
+
}
|
|
27077
28534
|
}
|
|
27078
28535
|
}
|
|
27079
28536
|
/** Convenience for a caller that does not care which kind it is holding. */
|
|
@@ -27103,6 +28560,16 @@ var Session = class {
|
|
|
27103
28560
|
canUndo: canUndo[position2] ?? false,
|
|
27104
28561
|
context: withoutEngineState(contexts[position2] ?? {}),
|
|
27105
28562
|
...contexts[position2]?.[ENGINE_STATE_KEY] !== void 0 ? { state: structuredClone(contexts[position2][ENGINE_STATE_KEY]) } : {},
|
|
28563
|
+
...contexts[position2]?.[BENCHMARKS_KEY] !== void 0 ? {
|
|
28564
|
+
benchmarks: structuredClone(
|
|
28565
|
+
contexts[position2][BENCHMARKS_KEY]
|
|
28566
|
+
)
|
|
28567
|
+
} : {},
|
|
28568
|
+
...contexts[position2]?.[ASSESSMENTS_KEY] !== void 0 ? {
|
|
28569
|
+
assessments: structuredClone(
|
|
28570
|
+
contexts[position2][ASSESSMENTS_KEY]
|
|
28571
|
+
)
|
|
28572
|
+
} : {},
|
|
27106
28573
|
participants: this.participants.list(teamId).map((record2) => ({
|
|
27107
28574
|
id: record2.id,
|
|
27108
28575
|
name: record2.name,
|
|
@@ -27203,6 +28670,14 @@ var Session = class {
|
|
|
27203
28670
|
syncPresence(connected) {
|
|
27204
28671
|
if (this.roster.syncPresence(connected)) this.emitState("presence");
|
|
27205
28672
|
}
|
|
28673
|
+
/**
|
|
28674
|
+
* How many surfaces and console pages are open on this session, which the
|
|
28675
|
+
* host observes as it does presence. Opening one is activity, and while
|
|
28676
|
+
* any is open the session does not go dormant (§11.4a).
|
|
28677
|
+
*/
|
|
28678
|
+
syncOpenSurfaces(count) {
|
|
28679
|
+
this.finishWaking(this.timers.surfacesOpen(count));
|
|
28680
|
+
}
|
|
27206
28681
|
/** Edits on disk this session has not applied, each list empty when none is. */
|
|
27207
28682
|
pendingChanges() {
|
|
27208
28683
|
return {
|
|
@@ -27376,10 +28851,11 @@ var Session = class {
|
|
|
27376
28851
|
try {
|
|
27377
28852
|
const readsBefore = this.timers.readsBefore(command);
|
|
27378
28853
|
this.startWarnings = [];
|
|
28854
|
+
this.executor.takeWarnings();
|
|
27379
28855
|
const committedAtTick = await this.dispatch(command);
|
|
27380
28856
|
await this.timers.retime(command, readsBefore);
|
|
27381
28857
|
this.emitState(command.type);
|
|
27382
|
-
const warnings = this.startWarnings;
|
|
28858
|
+
const warnings = [...this.startWarnings, ...this.executor.takeWarnings()];
|
|
27383
28859
|
this.startWarnings = [];
|
|
27384
28860
|
return {
|
|
27385
28861
|
ok: true,
|
|
@@ -27419,7 +28895,11 @@ var Session = class {
|
|
|
27419
28895
|
case "tick":
|
|
27420
28896
|
return tick(this.host, command);
|
|
27421
28897
|
case "undo":
|
|
27422
|
-
return keepingSessionLifetime(this.host, () =>
|
|
28898
|
+
return keepingSessionLifetime(this.host, async () => {
|
|
28899
|
+
const tick2 = await undo(this.host, command);
|
|
28900
|
+
this.roster.settleAssessments();
|
|
28901
|
+
return tick2;
|
|
28902
|
+
});
|
|
27423
28903
|
case "reset":
|
|
27424
28904
|
return keepingSessionLifetime(this.host, () => reset(this.host, command));
|
|
27425
28905
|
case "updateContext":
|
|
@@ -27464,6 +28944,14 @@ var Session = class {
|
|
|
27464
28944
|
return void 0;
|
|
27465
28945
|
case "extendTick":
|
|
27466
28946
|
return this.timers.extend(command);
|
|
28947
|
+
case "makeDormant":
|
|
28948
|
+
if (!this.executor.getConfig()?.tick_controller) {
|
|
28949
|
+
throw new DeniedError(
|
|
28950
|
+
"This game has no tick controller, so nothing ticks on its own"
|
|
28951
|
+
);
|
|
28952
|
+
}
|
|
28953
|
+
this.timers.suspend();
|
|
28954
|
+
return void 0;
|
|
27467
28955
|
case "armFault":
|
|
27468
28956
|
this.faults.arm(command.fault, {
|
|
27469
28957
|
...command.times === void 0 ? {} : { times: command.times },
|
|
@@ -27734,8 +29222,13 @@ var Session = class {
|
|
|
27734
29222
|
return resolveTeamDisplayName(index3, this.settings().teams.defaultNames, this.locale);
|
|
27735
29223
|
}
|
|
27736
29224
|
sharedEngineState() {
|
|
27737
|
-
const
|
|
27738
|
-
|
|
29225
|
+
const shared = this.executor.getSharedContext();
|
|
29226
|
+
const state2 = shared[SHARED_ENGINE_STATE_KEY];
|
|
29227
|
+
const benchmarks = shared[SHARED_BENCHMARKS_KEY];
|
|
29228
|
+
return {
|
|
29229
|
+
...state2 === void 0 ? {} : { sharedState: state2 },
|
|
29230
|
+
...benchmarks === void 0 ? {} : { sharedBenchmarks: structuredClone(benchmarks) }
|
|
29231
|
+
};
|
|
27739
29232
|
}
|
|
27740
29233
|
sharedStore() {
|
|
27741
29234
|
const shared = this.executor.getSharedContext();
|
|
@@ -27818,8 +29311,8 @@ var Session = class {
|
|
|
27818
29311
|
};
|
|
27819
29312
|
|
|
27820
29313
|
// cli/server/vite-plugin.ts
|
|
27821
|
-
import { readFile as
|
|
27822
|
-
import { isAbsolute as isAbsolute6, join as
|
|
29314
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
29315
|
+
import { isAbsolute as isAbsolute6, join as join11, relative as relative4 } from "path";
|
|
27823
29316
|
function toRootRelative(html2, documentDirectory) {
|
|
27824
29317
|
return html2.replace(
|
|
27825
29318
|
/(\s(?:src|href)=")(?!https?:|\/\/|\/|data:|#)(\.\/)?([^"]+)(")/g,
|
|
@@ -27857,7 +29350,7 @@ if (import.meta.hot) {
|
|
|
27857
29350
|
`;
|
|
27858
29351
|
async function serveHtmlWithVite(server, res, next, htmlFilePath, documentUrl) {
|
|
27859
29352
|
try {
|
|
27860
|
-
const html2 = await
|
|
29353
|
+
const html2 = await readFile7(htmlFilePath, "utf-8");
|
|
27861
29354
|
const directory = documentUrl.slice(0, documentUrl.lastIndexOf("/"));
|
|
27862
29355
|
const transformed = await server.transformIndexHtml(
|
|
27863
29356
|
documentUrl,
|
|
@@ -27871,7 +29364,7 @@ async function serveHtmlWithVite(server, res, next, htmlFilePath, documentUrl) {
|
|
|
27871
29364
|
}
|
|
27872
29365
|
async function serveStatic(res, next, absolutePath) {
|
|
27873
29366
|
try {
|
|
27874
|
-
const data = await
|
|
29367
|
+
const data = await readFile7(absolutePath);
|
|
27875
29368
|
res.setHeader("Content-Type", contentTypeFor(absolutePath));
|
|
27876
29369
|
res.end(data);
|
|
27877
29370
|
} catch {
|
|
@@ -27932,8 +29425,8 @@ function buildRoutes(options) {
|
|
|
27932
29425
|
];
|
|
27933
29426
|
}
|
|
27934
29427
|
function resolveAbsolute(workingDir, rootDirectory, urlPath) {
|
|
27935
|
-
const baseDir = isAbsolute6(rootDirectory) ? rootDirectory :
|
|
27936
|
-
return
|
|
29428
|
+
const baseDir = isAbsolute6(rootDirectory) ? rootDirectory : join11(workingDir, rootDirectory);
|
|
29429
|
+
return join11(baseDir, urlPath);
|
|
27937
29430
|
}
|
|
27938
29431
|
function seriousgamingUiPlugin(options) {
|
|
27939
29432
|
const { workingDir } = options;
|
|
@@ -28005,16 +29498,16 @@ function seriousgamingUiPlugin(options) {
|
|
|
28005
29498
|
|
|
28006
29499
|
// cli/validation/package-validation.ts
|
|
28007
29500
|
import { existsSync as existsSync12, readFileSync as readFileSync7 } from "fs";
|
|
28008
|
-
import { readFile as
|
|
29501
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
28009
29502
|
import { dirname as dirname5, resolve as resolve8 } from "path";
|
|
28010
29503
|
|
|
28011
29504
|
// cli/generation/ts-type.ts
|
|
28012
29505
|
import { existsSync as existsSync9, readFileSync as readFileSync5, statSync } from "fs";
|
|
28013
|
-
import { dirname as dirname3, isAbsolute as isAbsolute7, join as
|
|
29506
|
+
import { dirname as dirname3, isAbsolute as isAbsolute7, join as join12, relative as relative5, resolve as resolve5, sep as sep5 } from "path";
|
|
28014
29507
|
var NAMED_IMPORT = /import\((['"])([^'"]+)\1\)\.([A-Za-z_$][\w$]*)/g;
|
|
28015
29508
|
var MODULE_EXTENSIONS = [".ts", ".tsx", ".d.ts", "/index.ts", "/index.tsx"];
|
|
28016
29509
|
function capabilityDirectory(workingDir, identifier) {
|
|
28017
|
-
return
|
|
29510
|
+
return join12(workingDir, getPluralResourceMeta("capability").pluralDir, identifier);
|
|
28018
29511
|
}
|
|
28019
29512
|
function collectTsTypes(schema2, into = []) {
|
|
28020
29513
|
if (Array.isArray(schema2)) {
|
|
@@ -28065,9 +29558,85 @@ function exportsName(source, name) {
|
|
|
28065
29558
|
return declared.test(source) || listed.test(source) || /export\s+\*\s+from/.test(source);
|
|
28066
29559
|
}
|
|
28067
29560
|
|
|
29561
|
+
// cli/validation/benchmark-validation.ts
|
|
29562
|
+
function outcome2() {
|
|
29563
|
+
return { errors: [], warnings: [], findings: [] };
|
|
29564
|
+
}
|
|
29565
|
+
function addError2(result, finding) {
|
|
29566
|
+
result.errors.push(finding.hint ? `${finding.message}. ${finding.hint}` : finding.message);
|
|
29567
|
+
result.findings.push({ severity: "error", ...finding });
|
|
29568
|
+
}
|
|
29569
|
+
function validateBenchmark(benchmark, config) {
|
|
29570
|
+
const result = outcome2();
|
|
29571
|
+
const { identifier } = benchmark.definition;
|
|
29572
|
+
const file = bundleFileOf("benchmark", identifier);
|
|
29573
|
+
const resource = { type: "benchmark", identifier };
|
|
29574
|
+
if (!(config.requires ?? []).includes(BENCHMARKS_FEATURE)) {
|
|
29575
|
+
addError2(result, {
|
|
29576
|
+
code: "FEATURE_UNDECLARED",
|
|
29577
|
+
message: `Benchmark "${identifier}" needs the \`${BENCHMARKS_FEATURE}\` feature, but \`requires\` does not list it`,
|
|
29578
|
+
hint: `Add "${BENCHMARKS_FEATURE}" to \`requires\` in seriousgaming.sdk.json, so a runtime that cannot record benchmarks refuses the package rather than failing the first round that writes one`,
|
|
29579
|
+
file: MANIFEST_FILE,
|
|
29580
|
+
pointer: pointerOf("requires"),
|
|
29581
|
+
resource
|
|
29582
|
+
});
|
|
29583
|
+
}
|
|
29584
|
+
const engine = config.engine;
|
|
29585
|
+
const written = engine?.definition.benchmarks?.includes(identifier) ?? false;
|
|
29586
|
+
if (!written) {
|
|
29587
|
+
const message = `Benchmark "${identifier}" is not in the engine's "benchmarks", so nothing can write it and it will never hold a value`;
|
|
29588
|
+
result.warnings.push(message);
|
|
29589
|
+
result.findings.push({
|
|
29590
|
+
severity: "warning",
|
|
29591
|
+
code: "BENCHMARK_UNWRITTEN",
|
|
29592
|
+
message,
|
|
29593
|
+
hint: `Add "${identifier}" to "benchmarks" in engine/engine.sdk.json, or delete the benchmark`,
|
|
29594
|
+
file,
|
|
29595
|
+
resource
|
|
29596
|
+
});
|
|
29597
|
+
}
|
|
29598
|
+
if (written && resolveBenchmarkLevel(benchmark.definition) === "session" && engine?.definition.aggregate !== true) {
|
|
29599
|
+
addError2(result, {
|
|
29600
|
+
code: "PACKAGE_INVALID",
|
|
29601
|
+
message: `Benchmark "${identifier}" is session-level, but the engine is not aggregate, so it has no session result to write it under`,
|
|
29602
|
+
hint: 'Export InitAggregate and RunAggregate from the engine, or make the benchmark per team by removing "level"',
|
|
29603
|
+
file,
|
|
29604
|
+
pointer: pointerOf("definition", "level"),
|
|
29605
|
+
resource
|
|
29606
|
+
});
|
|
29607
|
+
}
|
|
29608
|
+
return result;
|
|
29609
|
+
}
|
|
29610
|
+
function validateEngineBenchmarks(config) {
|
|
29611
|
+
const result = outcome2();
|
|
29612
|
+
const declared = new Set((config.benchmarks ?? []).map((b) => b.definition.identifier));
|
|
29613
|
+
const engine = config.engine;
|
|
29614
|
+
if (engine) {
|
|
29615
|
+
(engine.definition.benchmarks ?? []).forEach((identifier, index3) => {
|
|
29616
|
+
if (declared.has(identifier)) return;
|
|
29617
|
+
addError2(result, {
|
|
29618
|
+
code: "REFERENCE_UNKNOWN",
|
|
29619
|
+
message: `Engine declares benchmark "${identifier}", which the package does not have`,
|
|
29620
|
+
hint: `Create it with "new benchmark", or remove it from the engine's "benchmarks"`,
|
|
29621
|
+
file: bundleFileOf("engine", "engine"),
|
|
29622
|
+
pointer: pointerOf("definition", "benchmarks", index3),
|
|
29623
|
+
resource: { type: "engine", identifier: engine.definition.identifier }
|
|
29624
|
+
});
|
|
29625
|
+
});
|
|
29626
|
+
}
|
|
29627
|
+
if (declared.size > MAX_BENCHMARKS_PER_GAME) {
|
|
29628
|
+
addError2(result, {
|
|
29629
|
+
code: "PACKAGE_INVALID",
|
|
29630
|
+
message: `The game declares ${declared.size} benchmarks, more than the ${MAX_BENCHMARKS_PER_GAME} a game may have`,
|
|
29631
|
+
hint: "Combine related fields into one benchmark, or remove the ones no debrief shows"
|
|
29632
|
+
});
|
|
29633
|
+
}
|
|
29634
|
+
return result;
|
|
29635
|
+
}
|
|
29636
|
+
|
|
28068
29637
|
// cli/validation/facilitator-guide-validator.ts
|
|
28069
29638
|
import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync2 } from "fs";
|
|
28070
|
-
import { dirname as dirname4, join as
|
|
29639
|
+
import { dirname as dirname4, join as join13, resolve as resolve6, sep as sep6 } from "path";
|
|
28071
29640
|
|
|
28072
29641
|
// cli/guide/video-registry.ts
|
|
28073
29642
|
var VIDEO_PROVIDERS = {
|
|
@@ -28341,20 +29910,20 @@ var LARGE_VIDEO_FILE_BYTES = 25 * 1024 * 1024;
|
|
|
28341
29910
|
var VIDEO_BLOCK_PATTERN = /^[ \t]*```video[ \t]*\r?\n([\s\S]*?)^[ \t]*```[ \t]*$/gm;
|
|
28342
29911
|
var IMAGE_PATTERN = /!\[[^\]]*\]\(([^()\s]+)(?:\s+"[^"]*")?\)/g;
|
|
28343
29912
|
function listChapters(localeDir) {
|
|
28344
|
-
return readdirSync3(localeDir).filter((name) => name.endsWith(".md") && statSync2(
|
|
29913
|
+
return readdirSync3(localeDir).filter((name) => name.endsWith(".md") && statSync2(join13(localeDir, name)).isFile()).sort();
|
|
28345
29914
|
}
|
|
28346
29915
|
function validateFacilitatorGuideContent(options) {
|
|
28347
29916
|
const errors = [];
|
|
28348
29917
|
const warnings = [];
|
|
28349
29918
|
const { definition: definition3, rootDirectory } = options;
|
|
28350
|
-
const contentDir =
|
|
29919
|
+
const contentDir = join13(rootDirectory, "content");
|
|
28351
29920
|
const declaredLocales = Object.keys(definition3.locales);
|
|
28352
29921
|
if (!existsSync10(contentDir)) {
|
|
28353
29922
|
warnings.push("Guide has no content/ directory");
|
|
28354
29923
|
return { errors, warnings };
|
|
28355
29924
|
}
|
|
28356
29925
|
for (const entry of readdirSync3(contentDir)) {
|
|
28357
|
-
if (!statSync2(
|
|
29926
|
+
if (!statSync2(join13(contentDir, entry)).isDirectory()) continue;
|
|
28358
29927
|
if (!declaredLocales.includes(entry)) {
|
|
28359
29928
|
warnings.push(
|
|
28360
29929
|
`Content directory "content/${entry}/" has no matching locale in the guide definition`
|
|
@@ -28362,14 +29931,14 @@ function validateFacilitatorGuideContent(options) {
|
|
|
28362
29931
|
}
|
|
28363
29932
|
}
|
|
28364
29933
|
const reference = referenceLocale(definition3.locales);
|
|
28365
|
-
const referenceDir =
|
|
29934
|
+
const referenceDir = join13(contentDir, reference);
|
|
28366
29935
|
const referenceChapters = existsSync10(referenceDir) ? listChapters(referenceDir) : [];
|
|
28367
29936
|
if (referenceChapters.length === 0) {
|
|
28368
29937
|
warnings.push(`Guide has no chapters for its reference locale "${reference}"`);
|
|
28369
29938
|
}
|
|
28370
29939
|
const read = [];
|
|
28371
29940
|
for (const locale of declaredLocales) {
|
|
28372
|
-
const localeDir =
|
|
29941
|
+
const localeDir = join13(contentDir, locale);
|
|
28373
29942
|
if (!existsSync10(localeDir)) {
|
|
28374
29943
|
warnings.push(`Declared locale "${locale}" has no content/${locale}/ directory`);
|
|
28375
29944
|
continue;
|
|
@@ -28388,7 +29957,7 @@ function validateFacilitatorGuideContent(options) {
|
|
|
28388
29957
|
}
|
|
28389
29958
|
}
|
|
28390
29959
|
for (const chapter of chapters) {
|
|
28391
|
-
const chapterPath =
|
|
29960
|
+
const chapterPath = join13(localeDir, chapter);
|
|
28392
29961
|
const content3 = readFileSync6(chapterPath, "utf-8");
|
|
28393
29962
|
const label4 = `content/${locale}/${chapter}`;
|
|
28394
29963
|
read.push({ label: label4, markdown: content3, reference: locale === reference });
|
|
@@ -28399,14 +29968,14 @@ function validateFacilitatorGuideContent(options) {
|
|
|
28399
29968
|
continue;
|
|
28400
29969
|
}
|
|
28401
29970
|
if (parsed.kind !== "file") continue;
|
|
28402
|
-
const assetsDir =
|
|
29971
|
+
const assetsDir = join13(rootDirectory, "assets");
|
|
28403
29972
|
for (const [key, path3] of [
|
|
28404
29973
|
["src", parsed.src],
|
|
28405
29974
|
["poster", parsed.poster],
|
|
28406
29975
|
["captions", parsed.captions]
|
|
28407
29976
|
]) {
|
|
28408
29977
|
if (path3 === void 0) continue;
|
|
28409
|
-
const file =
|
|
29978
|
+
const file = join13(assetsDir, path3);
|
|
28410
29979
|
if (!existsSync10(file) || !statSync2(file).isFile()) {
|
|
28411
29980
|
errors.push(
|
|
28412
29981
|
`${label4}: video ${key} "assets/${path3}" does not resolve to a file`
|
|
@@ -29585,7 +31154,7 @@ function readsWritten(type) {
|
|
|
29585
31154
|
const label4 = getResourceMeta(type).label;
|
|
29586
31155
|
return (resource, context) => {
|
|
29587
31156
|
const definition3 = resource.definition;
|
|
29588
|
-
const
|
|
31157
|
+
const outcome3 = {
|
|
29589
31158
|
errors: [],
|
|
29590
31159
|
warnings: [],
|
|
29591
31160
|
findings: []
|
|
@@ -29594,15 +31163,15 @@ function readsWritten(type) {
|
|
|
29594
31163
|
if (!context.capabilityIds.has(capId)) return;
|
|
29595
31164
|
if (context.writtenInPackage.has(capId)) return;
|
|
29596
31165
|
const message = `${label4} "${definition3.identifier}" declares a read of capability "${capId}", but no engine, user interface, or hook in this package writes it, so it can only ever hold its schema defaults. Remove the read if it is unused, or move the values to a settings resource if they are meant to be constants.`;
|
|
29597
|
-
|
|
29598
|
-
|
|
31166
|
+
outcome3.warnings.push(message);
|
|
31167
|
+
outcome3.findings.push({
|
|
29599
31168
|
severity: "warning",
|
|
29600
31169
|
code: "READ_NEVER_WRITTEN",
|
|
29601
31170
|
message,
|
|
29602
31171
|
pointer: pointerOf("definition", "reads", index3)
|
|
29603
31172
|
});
|
|
29604
31173
|
});
|
|
29605
|
-
return
|
|
31174
|
+
return outcome3;
|
|
29606
31175
|
};
|
|
29607
31176
|
}
|
|
29608
31177
|
var uiFiles = (ui, context) => validateUIFiles(ui, context.workingDir);
|
|
@@ -29640,12 +31209,25 @@ var VALIDATION_DESCRIPTORS = [
|
|
|
29640
31209
|
localRefs("capability")
|
|
29641
31210
|
]
|
|
29642
31211
|
}),
|
|
31212
|
+
descriptor({
|
|
31213
|
+
type: "benchmark",
|
|
31214
|
+
resources: (config) => config.benchmarks ?? [],
|
|
31215
|
+
identify: named2,
|
|
31216
|
+
checks: [(benchmark, context) => validateBenchmark(benchmark, context.config)]
|
|
31217
|
+
}),
|
|
31218
|
+
descriptor({
|
|
31219
|
+
type: "assessment",
|
|
31220
|
+
resources: (config) => config.assessments ?? [],
|
|
31221
|
+
identify: named2,
|
|
31222
|
+
checks: [(assessment, context) => validateAssessment(assessment, context.config)]
|
|
31223
|
+
}),
|
|
29643
31224
|
// The built-in `game` resource's defaults are the manifest's own values,
|
|
29644
|
-
// which the game's checks already hold to their schema
|
|
31225
|
+
// which the game's checks already hold to their schema, and the built-in
|
|
31226
|
+
// `assessments` resource's are the bundles' bands, which theirs do.
|
|
29645
31227
|
descriptor({
|
|
29646
31228
|
type: "settings",
|
|
29647
31229
|
resources: (config) => (config.settings ?? []).filter(
|
|
29648
|
-
(settings) => settings.definition.identifier !== GAME_SETTINGS
|
|
31230
|
+
(settings) => settings.definition.identifier !== GAME_SETTINGS && !(settings.definition.identifier === ASSESSMENTS_SETTINGS && (config.assessments?.length ?? 0) > 0)
|
|
29649
31231
|
),
|
|
29650
31232
|
identify: named2,
|
|
29651
31233
|
checks: [
|
|
@@ -29691,6 +31273,8 @@ var VALIDATION_DESCRIPTORS = [
|
|
|
29691
31273
|
writer: writesOf,
|
|
29692
31274
|
checks: [
|
|
29693
31275
|
(engine, context) => validateEngine(engine, context.config),
|
|
31276
|
+
(_engine, context) => validateEngineBenchmarks(context.config),
|
|
31277
|
+
(_engine, context) => validateEngineAssessments(context.config),
|
|
29694
31278
|
(engine, context) => validateEngineFiles(engine, context.workingDir),
|
|
29695
31279
|
schemaDefaults2("engine"),
|
|
29696
31280
|
readsWritten("engine")
|
|
@@ -29970,7 +31554,7 @@ async function validateLoadedPackage(config, options) {
|
|
|
29970
31554
|
capabilityIds: new Set((config.capabilities ?? []).map(named2)),
|
|
29971
31555
|
logicLoader: new LogicLoader(dirname5(options.configPath), {
|
|
29972
31556
|
transpile: Transpile,
|
|
29973
|
-
fs: { existsSync: existsSync12, readFile:
|
|
31557
|
+
fs: { existsSync: existsSync12, readFile: readFile8 }
|
|
29974
31558
|
})
|
|
29975
31559
|
};
|
|
29976
31560
|
const results = [];
|
|
@@ -30029,7 +31613,7 @@ function setupNotesChecks(setup, context) {
|
|
|
30029
31613
|
const configures = new Set(setup.definition.configures ?? []);
|
|
30030
31614
|
const reads = new Set(setup.definition.settings ?? []);
|
|
30031
31615
|
const resource = { type: "setup", identifier: "setup" };
|
|
30032
|
-
const
|
|
31616
|
+
const outcome3 = {
|
|
30033
31617
|
errors: [],
|
|
30034
31618
|
warnings: [],
|
|
30035
31619
|
findings: []
|
|
@@ -30045,8 +31629,8 @@ function setupNotesChecks(setup, context) {
|
|
|
30045
31629
|
const identifier = parseSettingPath(path3)?.identifier ?? "";
|
|
30046
31630
|
if (!configures.has(identifier) && !reads.has(identifier)) {
|
|
30047
31631
|
const message = `Setup notes ${file}, line ${line}, name \`${path3}\`, but the setup UI neither configures nor reads "${identifier}", so a host refuses a change to it. Add "${identifier}" to its \`configures\` if setup may change it, or to its \`settings\` if the notes name it only as where the menu's offer is read from.`;
|
|
30048
|
-
|
|
30049
|
-
|
|
31632
|
+
outcome3.warnings.push(message);
|
|
31633
|
+
outcome3.findings.push({
|
|
30050
31634
|
severity: "warning",
|
|
30051
31635
|
code: "SETUP_NOTES_UNCONFIGURED",
|
|
30052
31636
|
message,
|
|
@@ -30057,7 +31641,7 @@ function setupNotesChecks(setup, context) {
|
|
|
30057
31641
|
}
|
|
30058
31642
|
}
|
|
30059
31643
|
}
|
|
30060
|
-
return
|
|
31644
|
+
return outcome3;
|
|
30061
31645
|
}
|
|
30062
31646
|
function ungatedSettingsChecks(gameIdentifier, config) {
|
|
30063
31647
|
const resource = { type: "game", identifier: gameIdentifier };
|
|
@@ -30069,7 +31653,9 @@ function ungatedSettingsChecks(gameIdentifier, config) {
|
|
|
30069
31653
|
(config.validators ?? []).filter((v) => v.definition.gates?.includes("scenario")).flatMap((v) => v.definition.settings ?? [])
|
|
30070
31654
|
);
|
|
30071
31655
|
for (const identifier of configures) {
|
|
30072
|
-
if (identifier === GAME_SETTINGS || gated.has(identifier))
|
|
31656
|
+
if (identifier === GAME_SETTINGS || identifier === ASSESSMENTS_SETTINGS || gated.has(identifier)) {
|
|
31657
|
+
continue;
|
|
31658
|
+
}
|
|
30073
31659
|
const message = `The setup UI changes the "${identifier}" settings, but no \`Scenario\` gate declares them, so nothing checks a facilitator's changes to them before the session starts. Add "${identifier}" to the \`settings\` of the validator that exports \`Scenario\` if a change there can break play.`;
|
|
30074
31660
|
warnings.push(message);
|
|
30075
31661
|
findings.push({
|
|
@@ -30084,8 +31670,8 @@ function ungatedSettingsChecks(gameIdentifier, config) {
|
|
|
30084
31670
|
}
|
|
30085
31671
|
return { errors: [], warnings, findings };
|
|
30086
31672
|
}
|
|
30087
|
-
function record(result,
|
|
30088
|
-
const byMessage = new Map((
|
|
31673
|
+
function record(result, outcome3) {
|
|
31674
|
+
const byMessage = new Map((outcome3.findings ?? []).map((f) => [f.message, f]));
|
|
30089
31675
|
const add = (severity, message) => {
|
|
30090
31676
|
const finding = byMessage.get(message) ?? {
|
|
30091
31677
|
code: message.includes(LOGIC_NODE_BUILTIN) ? LOGIC_NODE_BUILTIN : "PACKAGE_INVALID",
|
|
@@ -30093,18 +31679,18 @@ function record(result, outcome) {
|
|
|
30093
31679
|
};
|
|
30094
31680
|
result.diagnostics.push(located(severity, finding, result));
|
|
30095
31681
|
};
|
|
30096
|
-
if (
|
|
30097
|
-
result.errors.push(...
|
|
31682
|
+
if (outcome3.errorFindings) {
|
|
31683
|
+
result.errors.push(...outcome3.errors);
|
|
30098
31684
|
result.diagnostics.push(
|
|
30099
|
-
...
|
|
31685
|
+
...outcome3.errorFindings.map((finding) => located("error", finding, result))
|
|
30100
31686
|
);
|
|
30101
31687
|
} else {
|
|
30102
|
-
for (const message of
|
|
31688
|
+
for (const message of outcome3.errors) {
|
|
30103
31689
|
result.errors.push(message);
|
|
30104
31690
|
add("error", message);
|
|
30105
31691
|
}
|
|
30106
31692
|
}
|
|
30107
|
-
for (const message of
|
|
31693
|
+
for (const message of outcome3.warnings ?? []) {
|
|
30108
31694
|
result.warnings.push(message);
|
|
30109
31695
|
add("warning", message);
|
|
30110
31696
|
}
|
|
@@ -30146,7 +31732,7 @@ function scenarioRefusals(problems, subject, resource, file, pointerFor) {
|
|
|
30146
31732
|
|
|
30147
31733
|
// cli/dev/brands.ts
|
|
30148
31734
|
import { existsSync as existsSync13, readFileSync as readFileSync8 } from "fs";
|
|
30149
|
-
import { dirname as dirname6, isAbsolute as isAbsolute8, join as
|
|
31735
|
+
import { dirname as dirname6, isAbsolute as isAbsolute8, join as join14, normalize as normalize2, resolve as resolve9, sep as sep8 } from "path";
|
|
30150
31736
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
30151
31737
|
var ROLES = ["primary", "secondary", "success", "error", "warning", "info"];
|
|
30152
31738
|
var NEUTRALS = ["background", "surface", "text"];
|
|
@@ -30235,7 +31821,7 @@ var PLAIN_DARK = {
|
|
|
30235
31821
|
info: "#29b6f6"
|
|
30236
31822
|
};
|
|
30237
31823
|
function builtInBrandsDirectory() {
|
|
30238
|
-
return
|
|
31824
|
+
return join14(dirname6(fileURLToPath2(import.meta.url)), "brands");
|
|
30239
31825
|
}
|
|
30240
31826
|
function invalid(path3, problem) {
|
|
30241
31827
|
return new CliError("INPUT_INVALID", `The brand file ${path3} is not valid: ${problem}`, {
|
|
@@ -30348,12 +31934,12 @@ function loadBrands(brandFiles = []) {
|
|
|
30348
31934
|
brand: { name: "Plain brand" }
|
|
30349
31935
|
};
|
|
30350
31936
|
const seriousGaming = readBrandFile(
|
|
30351
|
-
|
|
31937
|
+
join14(directory, "serious-gaming", "brand.json"),
|
|
30352
31938
|
SERIOUS_GAMING,
|
|
30353
31939
|
plain
|
|
30354
31940
|
);
|
|
30355
31941
|
const awkward = readBrandFile(
|
|
30356
|
-
|
|
31942
|
+
join14(directory, "awkward", "brand.json"),
|
|
30357
31943
|
"awkward",
|
|
30358
31944
|
seriousGaming
|
|
30359
31945
|
);
|
|
@@ -30424,23 +32010,23 @@ function summarise(brand, assetOrigin) {
|
|
|
30424
32010
|
|
|
30425
32011
|
// cli/dev/console-path.ts
|
|
30426
32012
|
import { existsSync as existsSync14 } from "fs";
|
|
30427
|
-
import { join as
|
|
32013
|
+
import { join as join15, sep as sep9 } from "path";
|
|
30428
32014
|
function resolveConsolePath(dirname14, filename, fileExists = existsSync14) {
|
|
30429
32015
|
const fromSource = filename.includes(`${sep9}cli${sep9}dev${sep9}`) || filename.includes("/cli/dev/");
|
|
30430
|
-
const path3 = fromSource ?
|
|
30431
|
-
return { path: path3, built: fileExists(
|
|
32016
|
+
const path3 = fromSource ? join15(dirname14, "..", "..", "dist", "dev", "console") : join15(dirname14, "dev", "console");
|
|
32017
|
+
return { path: path3, built: fileExists(join15(path3, "index.html")) };
|
|
30432
32018
|
}
|
|
30433
32019
|
var MISSING_CONSOLE_MESSAGE = "The dev console has not been built yet. Run `pnpm build` in sdk-tools, or `pnpm exec vite build cli/dev/console` to build just the console.";
|
|
30434
32020
|
|
|
30435
32021
|
// cli/dev/lockfile.ts
|
|
30436
32022
|
import { createHash as createHash3, randomUUID as randomUUID3 } from "crypto";
|
|
30437
|
-
import { mkdir as mkdir3, readFile as
|
|
32023
|
+
import { mkdir as mkdir3, readFile as readFile9, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
30438
32024
|
import { hostname } from "os";
|
|
30439
|
-
import { basename as basename3, dirname as dirname8, join as
|
|
32025
|
+
import { basename as basename3, dirname as dirname8, join as join17, resolve as resolve11 } from "path";
|
|
30440
32026
|
|
|
30441
32027
|
// cli/dev/tools-identity.ts
|
|
30442
32028
|
import { existsSync as existsSync15, readFileSync as readFileSync9, realpathSync as realpathSync3 } from "fs";
|
|
30443
|
-
import { dirname as dirname7, join as
|
|
32029
|
+
import { dirname as dirname7, join as join16, resolve as resolve10, sep as sep10 } from "path";
|
|
30444
32030
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
30445
32031
|
var cached = null;
|
|
30446
32032
|
function toolsIdentity() {
|
|
@@ -30451,10 +32037,10 @@ function readIdentity(filename) {
|
|
|
30451
32037
|
const here = dirname7(filename);
|
|
30452
32038
|
const fromSource = filename.includes(`${sep10}cli${sep10}dev${sep10}`);
|
|
30453
32039
|
const root2 = fromSource ? resolve10(here, "..", "..") : resolve10(here, "..");
|
|
30454
|
-
const entry = fromSource ?
|
|
32040
|
+
const entry = fromSource ? join16(root2, "cli", "cli.ts") : join16(here, "cli.js");
|
|
30455
32041
|
let version = "0.0.0";
|
|
30456
32042
|
try {
|
|
30457
|
-
const manifest = JSON.parse(readFileSync9(
|
|
32043
|
+
const manifest = JSON.parse(readFileSync9(join16(root2, "package.json"), "utf-8"));
|
|
30458
32044
|
version = manifest.version ?? version;
|
|
30459
32045
|
} catch {
|
|
30460
32046
|
}
|
|
@@ -30466,10 +32052,10 @@ var DEV_STATE_DIR_ENV_VAR = "SERIOUSGAMING_DEV_STATE_DIR";
|
|
|
30466
32052
|
var ownInstances = /* @__PURE__ */ new Set();
|
|
30467
32053
|
function lockFilePath(packagePath, env = process.env) {
|
|
30468
32054
|
const stateDir = env[DEV_STATE_DIR_ENV_VAR]?.trim();
|
|
30469
|
-
if (!stateDir) return
|
|
32055
|
+
if (!stateDir) return join17(packagePath, ".seriousgaming-sdk", "session.json");
|
|
30470
32056
|
const absolute = resolve11(packagePath);
|
|
30471
32057
|
const key = createHash3("sha256").update(absolute).digest("hex").slice(0, 12);
|
|
30472
|
-
return
|
|
32058
|
+
return join17(resolve11(stateDir), `${basename3(absolute)}-${key}`, "session.json");
|
|
30473
32059
|
}
|
|
30474
32060
|
async function writeLockFile(packagePath, details) {
|
|
30475
32061
|
const path3 = lockFilePath(packagePath);
|
|
@@ -30501,7 +32087,7 @@ function newInstanceId() {
|
|
|
30501
32087
|
import { rmSync, watch as watchDirectory } from "fs";
|
|
30502
32088
|
import { mkdtemp as mkdtemp2, rm as rm4, writeFile as writeFile4 } from "fs/promises";
|
|
30503
32089
|
import { tmpdir as tmpdir2 } from "os";
|
|
30504
|
-
import { basename as basename4, join as
|
|
32090
|
+
import { basename as basename4, join as join18, relative as relative7, sep as sep11 } from "path";
|
|
30505
32091
|
import { watch } from "chokidar";
|
|
30506
32092
|
var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
30507
32093
|
"node_modules",
|
|
@@ -30532,7 +32118,7 @@ function classifyDirectory(packagePath, path3) {
|
|
|
30532
32118
|
return !segments.some((segment) => IGNORED_DIRECTORIES.has(segment));
|
|
30533
32119
|
}
|
|
30534
32120
|
async function untilWatchesDeliver(timeoutMs = 2e3) {
|
|
30535
|
-
const directory = await mkdtemp2(
|
|
32121
|
+
const directory = await mkdtemp2(join18(tmpdir2(), "sg-watch-"));
|
|
30536
32122
|
const removeOnExit = () => rmSync(directory, { recursive: true, force: true });
|
|
30537
32123
|
process.once("exit", removeOnExit);
|
|
30538
32124
|
const remove = () => {
|
|
@@ -30554,7 +32140,7 @@ async function untilWatchesDeliver(timeoutMs = 2e3) {
|
|
|
30554
32140
|
});
|
|
30555
32141
|
const deadline = Date.now() + timeoutMs;
|
|
30556
32142
|
for (let attempt = 0; !delivered && Date.now() < deadline; attempt++) {
|
|
30557
|
-
await writeFile4(
|
|
32143
|
+
await writeFile4(join18(directory, "probe"), String(attempt));
|
|
30558
32144
|
await new Promise((resolve14) => setTimeout(resolve14, 25));
|
|
30559
32145
|
}
|
|
30560
32146
|
return async () => {
|
|
@@ -30627,19 +32213,19 @@ function publicHostnames(origins) {
|
|
|
30627
32213
|
|
|
30628
32214
|
// cli/dev/routes.ts
|
|
30629
32215
|
import { existsSync as existsSync18 } from "fs";
|
|
30630
|
-
import { readFile as
|
|
32216
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
30631
32217
|
import { isAbsolute as isAbsolute10, normalize as normalize3, resolve as resolve12, sep as sep12 } from "path";
|
|
30632
32218
|
import express from "express";
|
|
30633
32219
|
|
|
30634
32220
|
// cli/core/package-scenario.ts
|
|
30635
32221
|
import { existsSync as existsSync17, readdirSync as readdirSync4 } from "fs";
|
|
30636
|
-
import { mkdir as mkdir5, readFile as
|
|
30637
|
-
import { dirname as dirname10, isAbsolute as isAbsolute9, join as
|
|
32222
|
+
import { mkdir as mkdir5, readFile as readFile10, rm as rm5 } from "fs/promises";
|
|
32223
|
+
import { dirname as dirname10, isAbsolute as isAbsolute9, join as join20, resolve as resolvePath3 } from "path";
|
|
30638
32224
|
|
|
30639
32225
|
// cli/core/asset-reference-translator.ts
|
|
30640
32226
|
import { existsSync as existsSync16 } from "fs";
|
|
30641
32227
|
import { mkdir as mkdir4, writeFile as writeFile5 } from "fs/promises";
|
|
30642
|
-
import { basename as basename5, dirname as dirname9, extname, join as
|
|
32228
|
+
import { basename as basename5, dirname as dirname9, extname, join as join19, posix as posix2 } from "path";
|
|
30643
32229
|
var ASSET_PREFIX2 = "asset:";
|
|
30644
32230
|
var BLOB_PREFIX2 = "blob:";
|
|
30645
32231
|
function createBlobToAssetTranslator(opts) {
|
|
@@ -30657,14 +32243,14 @@ function createBlobToAssetTranslator(opts) {
|
|
|
30657
32243
|
opts.sourceScenarioRootDirectory,
|
|
30658
32244
|
reference
|
|
30659
32245
|
);
|
|
30660
|
-
const targetSubdir =
|
|
32246
|
+
const targetSubdir = join19(opts.targetAssetsDirectory, subdirectory);
|
|
30661
32247
|
await mkdir4(targetSubdir, { recursive: true });
|
|
30662
32248
|
const safeName = sanitizeAssetName(asset.name);
|
|
30663
32249
|
const relativePath = posix2.join(
|
|
30664
32250
|
subdirectory,
|
|
30665
32251
|
uniqueAssetName(targetSubdir, safeName, reservedNames)
|
|
30666
32252
|
);
|
|
30667
|
-
const absolutePath =
|
|
32253
|
+
const absolutePath = join19(opts.targetAssetsDirectory, relativePath);
|
|
30668
32254
|
await mkdir4(dirname9(absolutePath), { recursive: true });
|
|
30669
32255
|
await writeFile5(absolutePath, asset.data);
|
|
30670
32256
|
reservedNames.add(basename5(absolutePath));
|
|
@@ -30676,12 +32262,12 @@ function sanitizeAssetName(name) {
|
|
|
30676
32262
|
return stripped.length > 0 ? stripped : "asset";
|
|
30677
32263
|
}
|
|
30678
32264
|
function uniqueAssetName(directory, name, reserved) {
|
|
30679
|
-
if (!existsSync16(
|
|
32265
|
+
if (!existsSync16(join19(directory, name)) && !reserved.has(name)) return name;
|
|
30680
32266
|
const ext = extname(name);
|
|
30681
32267
|
const stem = ext ? name.slice(0, -ext.length) : name;
|
|
30682
32268
|
for (let i = 1; i < 1e3; i++) {
|
|
30683
32269
|
const candidate = `${stem}-${i}${ext}`;
|
|
30684
|
-
if (!existsSync16(
|
|
32270
|
+
if (!existsSync16(join19(directory, candidate)) && !reserved.has(candidate)) {
|
|
30685
32271
|
return candidate;
|
|
30686
32272
|
}
|
|
30687
32273
|
}
|
|
@@ -30742,15 +32328,15 @@ async function createPackageScenario(opts) {
|
|
|
30742
32328
|
if (existing) {
|
|
30743
32329
|
scenarioFilePath = existing.scenarioFilePath;
|
|
30744
32330
|
const scenarioRoot = isAbsolute9(existing.bundle.rootDirectory) ? existing.bundle.rootDirectory : resolvePath3(dirname10(existing.scenarioFilePath), existing.bundle.rootDirectory);
|
|
30745
|
-
targetAssetsDirectory =
|
|
32331
|
+
targetAssetsDirectory = join20(scenarioRoot, "assets");
|
|
30746
32332
|
bundleRootDirectory = existing.bundle.rootDirectory;
|
|
30747
32333
|
sourceScenarioRootDirectory = scenarioRoot;
|
|
30748
|
-
await mkdir5(
|
|
32334
|
+
await mkdir5(join20(targetAssetsDirectory, "shared"), { recursive: true });
|
|
30749
32335
|
} else {
|
|
30750
|
-
const scenarioDir =
|
|
30751
|
-
scenarioFilePath =
|
|
30752
|
-
targetAssetsDirectory =
|
|
30753
|
-
await mkdir5(
|
|
32336
|
+
const scenarioDir = join20(opts.packagePath, "scenarios", opts.identifier);
|
|
32337
|
+
scenarioFilePath = join20(scenarioDir, "scenario.sdk.json");
|
|
32338
|
+
targetAssetsDirectory = join20(scenarioDir, "assets");
|
|
32339
|
+
await mkdir5(join20(scenarioDir, "assets", "shared"), { recursive: true });
|
|
30754
32340
|
}
|
|
30755
32341
|
const translated = await translateSettings({
|
|
30756
32342
|
settings: opts.settings,
|
|
@@ -30825,11 +32411,11 @@ async function deletePackageScenario(packagePath, identifier) {
|
|
|
30825
32411
|
}
|
|
30826
32412
|
async function findScenarioBundle(packagePath, identifier) {
|
|
30827
32413
|
for (const relativePath of scenarioBundlePaths(packagePath)) {
|
|
30828
|
-
const filePath =
|
|
32414
|
+
const filePath = join20(packagePath, relativePath);
|
|
30829
32415
|
if (!existsSync17(filePath)) continue;
|
|
30830
32416
|
try {
|
|
30831
32417
|
if (relativePath.split("/")[1] !== identifier) continue;
|
|
30832
|
-
const bundle = JSON.parse(await
|
|
32418
|
+
const bundle = JSON.parse(await readFile10(filePath, "utf-8"));
|
|
30833
32419
|
return { scenarioFilePath: filePath, relativePath, bundle };
|
|
30834
32420
|
} catch {
|
|
30835
32421
|
continue;
|
|
@@ -30838,29 +32424,29 @@ async function findScenarioBundle(packagePath, identifier) {
|
|
|
30838
32424
|
return null;
|
|
30839
32425
|
}
|
|
30840
32426
|
function scenarioBundlePaths(packagePath) {
|
|
30841
|
-
const scenariosDir =
|
|
32427
|
+
const scenariosDir = join20(packagePath, "scenarios");
|
|
30842
32428
|
if (!existsSync17(scenariosDir)) return [];
|
|
30843
32429
|
return readdirSync4(scenariosDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().map((name) => `scenarios/${name}/scenario.sdk.json`);
|
|
30844
32430
|
}
|
|
30845
32431
|
async function readPackageManifest(packagePath) {
|
|
30846
|
-
const manifestPath =
|
|
32432
|
+
const manifestPath = join20(packagePath, "seriousgaming.sdk.json");
|
|
30847
32433
|
if (!existsSync17(manifestPath)) {
|
|
30848
32434
|
throw new PackageScenarioError(
|
|
30849
32435
|
"package-manifest-missing",
|
|
30850
32436
|
`Cannot find seriousgaming.sdk.json at ${packagePath}`
|
|
30851
32437
|
);
|
|
30852
32438
|
}
|
|
30853
|
-
return JSON.parse(await
|
|
32439
|
+
return JSON.parse(await readFile10(manifestPath, "utf-8"));
|
|
30854
32440
|
}
|
|
30855
32441
|
async function makeScenarioDefault(packagePath, identifier) {
|
|
30856
32442
|
await readPackageManifest(packagePath);
|
|
30857
32443
|
let found = false;
|
|
30858
32444
|
for (const entry of scenarioBundlePaths(packagePath)) {
|
|
30859
|
-
const filePath =
|
|
32445
|
+
const filePath = join20(packagePath, entry);
|
|
30860
32446
|
if (!existsSync17(filePath)) continue;
|
|
30861
32447
|
let bundle;
|
|
30862
32448
|
try {
|
|
30863
|
-
bundle = JSON.parse(await
|
|
32449
|
+
bundle = JSON.parse(await readFile10(filePath, "utf-8"));
|
|
30864
32450
|
} catch {
|
|
30865
32451
|
continue;
|
|
30866
32452
|
}
|
|
@@ -31639,7 +33225,7 @@ function registerRoutes(app, deps) {
|
|
|
31639
33225
|
res.status(404).json({ error: "Chapter not found" });
|
|
31640
33226
|
return;
|
|
31641
33227
|
}
|
|
31642
|
-
res.type("text/markdown").send(await
|
|
33228
|
+
res.type("text/markdown").send(await readFile11(file, "utf-8"));
|
|
31643
33229
|
});
|
|
31644
33230
|
app.get("/api/guide/assets/*path", (req, res) => {
|
|
31645
33231
|
const guide = session.guide();
|
|
@@ -31809,13 +33395,26 @@ var NO_TEAM_ID = {
|
|
|
31809
33395
|
renameSelf: "renameSelf renames the caller, whom the host resolves; it takes no teamId"
|
|
31810
33396
|
};
|
|
31811
33397
|
var FRAME_QUERIES = {
|
|
31812
|
-
game: /* @__PURE__ */ new Set([
|
|
31813
|
-
|
|
31814
|
-
|
|
33398
|
+
game: /* @__PURE__ */ new Set([
|
|
33399
|
+
"callEndpoint",
|
|
33400
|
+
"getPastState",
|
|
33401
|
+
"getAllTeamsParticipants",
|
|
33402
|
+
"getBenchmark",
|
|
33403
|
+
"getAssessment"
|
|
33404
|
+
]),
|
|
33405
|
+
"waiting-room": /* @__PURE__ */ new Set([
|
|
33406
|
+
"callEndpoint",
|
|
33407
|
+
"getPastState",
|
|
33408
|
+
"getAllTeamsParticipants",
|
|
33409
|
+
"getBenchmark",
|
|
33410
|
+
"getAssessment"
|
|
33411
|
+
]),
|
|
33412
|
+
session: /* @__PURE__ */ new Set(["callEndpoint", "getPastState", "getBenchmark", "getAssessment"]),
|
|
31815
33413
|
setup: /* @__PURE__ */ new Set(["callEndpoint"]),
|
|
31816
33414
|
"scenario-editor": /* @__PURE__ */ new Set(["callEndpoint"]),
|
|
31817
|
-
presentation: /* @__PURE__ */ new Set(["getPastState"])
|
|
33415
|
+
presentation: /* @__PURE__ */ new Set(["getPastState", "getBenchmark", "getAssessment"])
|
|
31818
33416
|
};
|
|
33417
|
+
var PLAYER_SURFACES = /* @__PURE__ */ new Set(["game", "waiting-room"]);
|
|
31819
33418
|
function teamScope(viewer) {
|
|
31820
33419
|
return viewer.teamIndex === void 0 ? {} : { teamIndex: viewer.teamIndex };
|
|
31821
33420
|
}
|
|
@@ -31964,7 +33563,7 @@ function commandFor(message, surface, viewer) {
|
|
|
31964
33563
|
return null;
|
|
31965
33564
|
}
|
|
31966
33565
|
}
|
|
31967
|
-
function queryFor(message, surface, viewer) {
|
|
33566
|
+
function queryFor(message, surface, viewer, { sessionless = false } = {}) {
|
|
31968
33567
|
if (!FRAME_QUERIES[surface.kind].has(message.type)) return null;
|
|
31969
33568
|
switch (message.type) {
|
|
31970
33569
|
case "callEndpoint":
|
|
@@ -31991,6 +33590,28 @@ function queryFor(message, surface, viewer) {
|
|
|
31991
33590
|
};
|
|
31992
33591
|
case "getAllTeamsParticipants":
|
|
31993
33592
|
return { type: "getAllTeamsParticipants", uiIdentifier: surface.identifier };
|
|
33593
|
+
case "getBenchmark":
|
|
33594
|
+
return {
|
|
33595
|
+
type: "getBenchmark",
|
|
33596
|
+
identifier: String(message.identifier),
|
|
33597
|
+
where: Array.isArray(message.where) ? message.where : []
|
|
33598
|
+
};
|
|
33599
|
+
// The audience is the host's to decide, from the surface and the viewer
|
|
33600
|
+
// it holds the render as, never from anything the page sends.
|
|
33601
|
+
case "getAssessment":
|
|
33602
|
+
if (sessionless) {
|
|
33603
|
+
return { refused: "A presentation shown without a session has no results to read" };
|
|
33604
|
+
}
|
|
33605
|
+
return {
|
|
33606
|
+
type: "getAssessment",
|
|
33607
|
+
identifier: String(message.identifier),
|
|
33608
|
+
...PLAYER_SURFACES.has(surface.kind) ? {
|
|
33609
|
+
audience: "own",
|
|
33610
|
+
...actorOf(viewer),
|
|
33611
|
+
...roleOf(viewer),
|
|
33612
|
+
...viewer.teamIndex === void 0 ? {} : { teamId: `team-${viewer.teamIndex + 1}` }
|
|
33613
|
+
} : { audience: "all" }
|
|
33614
|
+
};
|
|
31994
33615
|
default:
|
|
31995
33616
|
return null;
|
|
31996
33617
|
}
|
|
@@ -32172,6 +33793,8 @@ var DevShell = class {
|
|
|
32172
33793
|
socketRuns = /* @__PURE__ */ new WeakMap();
|
|
32173
33794
|
/** The participant an operator page says it is showing, where it shows one. */
|
|
32174
33795
|
socketPresence = /* @__PURE__ */ new Map();
|
|
33796
|
+
/** Console pages open, each of which keeps its run awake (§11.4a). */
|
|
33797
|
+
consoleSockets = /* @__PURE__ */ new Set();
|
|
32175
33798
|
options;
|
|
32176
33799
|
brands;
|
|
32177
33800
|
server = null;
|
|
@@ -32233,7 +33856,7 @@ var DevShell = class {
|
|
|
32233
33856
|
throw new Error(`No built surfaces at ${built}: build them first`);
|
|
32234
33857
|
}
|
|
32235
33858
|
if (this.options.isolated) {
|
|
32236
|
-
const dir = await mkdtemp3(
|
|
33859
|
+
const dir = await mkdtemp3(join21(tmpdir3(), "seriousgaming-dev-blobs-"));
|
|
32237
33860
|
this.isolatedBlobs = { dir, restore: redirectBlobs(this.options.packagePath, dir) };
|
|
32238
33861
|
}
|
|
32239
33862
|
try {
|
|
@@ -32322,9 +33945,9 @@ var DevShell = class {
|
|
|
32322
33945
|
return;
|
|
32323
33946
|
}
|
|
32324
33947
|
void this.walkthrough?.reloadBundles();
|
|
32325
|
-
void this.session.reloadBundles().then((
|
|
32326
|
-
this.record(
|
|
32327
|
-
reportReload(
|
|
33948
|
+
void this.session.reloadBundles().then((outcome3) => {
|
|
33949
|
+
this.record(outcome3);
|
|
33950
|
+
reportReload(outcome3);
|
|
32328
33951
|
});
|
|
32329
33952
|
}
|
|
32330
33953
|
/**
|
|
@@ -32365,10 +33988,10 @@ var DevShell = class {
|
|
|
32365
33988
|
}
|
|
32366
33989
|
}
|
|
32367
33990
|
/** Keep what a reload could not apply, for the next command to be told. */
|
|
32368
|
-
record(
|
|
32369
|
-
if (
|
|
32370
|
-
if (
|
|
32371
|
-
else for (const capability of
|
|
33991
|
+
record(outcome3) {
|
|
33992
|
+
if (outcome3.kind !== "failed") this.reloadFailure = null;
|
|
33993
|
+
if (outcome3.kind === "reinitialised") this.seeded.clear();
|
|
33994
|
+
else for (const capability of outcome3.added) this.seeded.add(capability);
|
|
32372
33995
|
}
|
|
32373
33996
|
/**
|
|
32374
33997
|
* Everything this server could not apply live to `run`, as it stands now:
|
|
@@ -32621,7 +34244,7 @@ Install the package's dependencies and restart.`
|
|
|
32621
34244
|
const slot2 = SURFACE_SLOT[kind2];
|
|
32622
34245
|
this.assetApp.use(
|
|
32623
34246
|
`${SURFACE_PREFIX[kind2]}/${slot2}`,
|
|
32624
|
-
express2.static(
|
|
34247
|
+
express2.static(join21(directory, slot2), { index: false })
|
|
32625
34248
|
);
|
|
32626
34249
|
}
|
|
32627
34250
|
this.assetApp.use((req, res) => {
|
|
@@ -32773,22 +34396,30 @@ Install the package's dependencies to serve its surfaces.
|
|
|
32773
34396
|
host: request.headers.host,
|
|
32774
34397
|
localOrigins: wantsLocalOrigins(location.search)
|
|
32775
34398
|
});
|
|
32776
|
-
void this.sendView(socket).then(() =>
|
|
34399
|
+
void this.sendView(socket).then(() => {
|
|
34400
|
+
this.syncPresence(route.run);
|
|
34401
|
+
this.syncOpenSurfaces(route.run);
|
|
34402
|
+
});
|
|
32777
34403
|
socket.on("message", (raw) => void this.receiveView(socket, raw));
|
|
32778
34404
|
socket.on("close", () => {
|
|
32779
34405
|
this.views.delete(socket);
|
|
32780
34406
|
this.syncPresence(route.run);
|
|
34407
|
+
this.syncOpenSurfaces(route.run);
|
|
32781
34408
|
});
|
|
32782
34409
|
});
|
|
32783
34410
|
this.sockets.on("connection", (socket, request) => {
|
|
32784
34411
|
const run = runFromUrl(request.url);
|
|
32785
34412
|
this.socketRuns.set(socket, run);
|
|
34413
|
+
this.consoleSockets.add(socket);
|
|
32786
34414
|
void this.runFor(run).then((session) => {
|
|
32787
34415
|
send(socket, { type: "state", state: session.project(), cause: "connected" });
|
|
34416
|
+
this.syncOpenSurfaces(run);
|
|
32788
34417
|
});
|
|
32789
34418
|
socket.on("message", (raw) => void this.receive(socket, raw));
|
|
32790
34419
|
socket.on("close", () => {
|
|
34420
|
+
this.consoleSockets.delete(socket);
|
|
32791
34421
|
if (this.socketPresence.delete(socket)) this.syncPresence(run);
|
|
34422
|
+
this.syncOpenSurfaces(run);
|
|
32792
34423
|
});
|
|
32793
34424
|
});
|
|
32794
34425
|
}
|
|
@@ -32918,6 +34549,23 @@ Install the package's dependencies to serve its surfaces.
|
|
|
32918
34549
|
}
|
|
32919
34550
|
session.syncPresence(present);
|
|
32920
34551
|
}
|
|
34552
|
+
/**
|
|
34553
|
+
* Tell a run how many pages are open on it, console and viewer alike.
|
|
34554
|
+
* Opening one is activity, and the dev server keeps a run with any open
|
|
34555
|
+
* awake (§11.4a), which the specification leaves to the host.
|
|
34556
|
+
*/
|
|
34557
|
+
syncOpenSurfaces(run) {
|
|
34558
|
+
const session = run === "walkthrough" ? this.walkthrough : this.session;
|
|
34559
|
+
if (!session) return;
|
|
34560
|
+
let count = 0;
|
|
34561
|
+
for (const socket of this.consoleSockets) {
|
|
34562
|
+
if ((this.socketRuns.get(socket) ?? "session") === run) count += 1;
|
|
34563
|
+
}
|
|
34564
|
+
for (const view of this.views.values()) {
|
|
34565
|
+
if (view.route.run === run) count += 1;
|
|
34566
|
+
}
|
|
34567
|
+
session.syncOpenSurfaces(count);
|
|
34568
|
+
}
|
|
32921
34569
|
updateViews(event, run) {
|
|
32922
34570
|
if (event.type === "round-processing") {
|
|
32923
34571
|
const teams = this.processing.get(run) ?? /* @__PURE__ */ new Set();
|
|
@@ -33048,28 +34696,28 @@ Install the package's dependencies to serve its surfaces.
|
|
|
33048
34696
|
);
|
|
33049
34697
|
}
|
|
33050
34698
|
};
|
|
33051
|
-
function reportReload(
|
|
33052
|
-
switch (
|
|
34699
|
+
function reportReload(outcome3) {
|
|
34700
|
+
switch (outcome3.kind) {
|
|
33053
34701
|
case "failed":
|
|
33054
34702
|
return;
|
|
33055
34703
|
case "reinitialised":
|
|
33056
|
-
if (hasPendingChanges(
|
|
34704
|
+
if (hasPendingChanges(outcome3.pending)) {
|
|
33057
34705
|
logger.success(
|
|
33058
|
-
`${describePendingChanges(
|
|
34706
|
+
`${describePendingChanges(outcome3.pending)}. Re-initialised the session at tick 0 to apply it.`
|
|
33059
34707
|
);
|
|
33060
34708
|
}
|
|
33061
|
-
for (const capability of
|
|
34709
|
+
for (const capability of outcome3.added) {
|
|
33062
34710
|
logger.success(
|
|
33063
34711
|
`Capability "${capability}" added. Re-initialised the session at tick 0 so Init runs for it.`
|
|
33064
34712
|
);
|
|
33065
34713
|
}
|
|
33066
|
-
if (!hasPendingChanges(
|
|
34714
|
+
if (!hasPendingChanges(outcome3.pending) && outcome3.added.length === 0) {
|
|
33067
34715
|
logger.success("Package changed; re-initialised the session at tick 0.");
|
|
33068
34716
|
}
|
|
33069
34717
|
return;
|
|
33070
34718
|
case "pending":
|
|
33071
34719
|
logger.warn(
|
|
33072
|
-
`${pendingHeadline(
|
|
34720
|
+
`${pendingHeadline(outcome3.pending)}. ${describePendingChanges(outcome3.pending)}.
|
|
33073
34721
|
` + PENDING_CHANGES_HINT
|
|
33074
34722
|
);
|
|
33075
34723
|
break;
|
|
@@ -33077,7 +34725,7 @@ function reportReload(outcome) {
|
|
|
33077
34725
|
logger.success("Package changed; the session uses it from here.");
|
|
33078
34726
|
break;
|
|
33079
34727
|
}
|
|
33080
|
-
for (const capability of
|
|
34728
|
+
for (const capability of outcome3.added) logger.warn(seededMessage(capability));
|
|
33081
34729
|
}
|
|
33082
34730
|
function buildErrorLine(error) {
|
|
33083
34731
|
const at = diagnosticLocation(error);
|
|
@@ -33120,7 +34768,7 @@ function hmrConnectSources(host, vitePort) {
|
|
|
33120
34768
|
|
|
33121
34769
|
// cli/utils/env-loader.ts
|
|
33122
34770
|
import { readFileSync as readFileSync11, existsSync as existsSync20 } from "fs";
|
|
33123
|
-
import { join as
|
|
34771
|
+
import { join as join23 } from "path";
|
|
33124
34772
|
|
|
33125
34773
|
// cli/utils/global-settings.ts
|
|
33126
34774
|
import {
|
|
@@ -33133,7 +34781,7 @@ import {
|
|
|
33133
34781
|
writeFileSync
|
|
33134
34782
|
} from "fs";
|
|
33135
34783
|
import { homedir } from "os";
|
|
33136
|
-
import { dirname as dirname12, isAbsolute as isAbsolute11, join as
|
|
34784
|
+
import { dirname as dirname12, isAbsolute as isAbsolute11, join as join22 } from "path";
|
|
33137
34785
|
var GLOBAL_SETTINGS_ENV_VAR = "SERIOUSGAMING_SDK_CONFIG";
|
|
33138
34786
|
function resolveGlobalSettingsPath() {
|
|
33139
34787
|
const override = process.env[GLOBAL_SETTINGS_ENV_VAR];
|
|
@@ -33146,7 +34794,7 @@ function resolveGlobalSettingsPath() {
|
|
|
33146
34794
|
}
|
|
33147
34795
|
return override;
|
|
33148
34796
|
}
|
|
33149
|
-
return
|
|
34797
|
+
return join22(homedir(), ".seriousgaming-sdk", "config.json");
|
|
33150
34798
|
}
|
|
33151
34799
|
function loadGlobalSettings(path3 = resolveGlobalSettingsPath()) {
|
|
33152
34800
|
if (!existsSync19(path3)) {
|
|
@@ -33194,7 +34842,7 @@ function loadEnvironmentConfig(workingDir, flags) {
|
|
|
33194
34842
|
const config = {};
|
|
33195
34843
|
const ttsVoicePresets = {};
|
|
33196
34844
|
applyGlobalSettings(config);
|
|
33197
|
-
const envPath =
|
|
34845
|
+
const envPath = join23(workingDir, ".env");
|
|
33198
34846
|
if (existsSync20(envPath)) {
|
|
33199
34847
|
try {
|
|
33200
34848
|
const content3 = readFileSync11(envPath, "utf-8");
|