@seriousgaming/sdk-tools 1.11.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 +4 -0
- package/dist/{cli-F2D4GGUA.js → cli-2BKEIIA3.js} +66 -0
- package/dist/{cli-ZGCG6C22.js → cli-2QGTDHRX.js} +21 -21
- package/dist/{cli-SRXDLMXY.js → cli-2SDG3SZ7.js} +21 -21
- package/dist/{cli-DH35TZ2Q.js → cli-2VXP34R5.js} +2 -2
- package/dist/{cli-P3NUTOPK.js → cli-2W4B6PD5.js} +1 -1
- package/dist/{cli-WJVPSVF2.js → cli-2X7DKSXN.js} +24 -24
- package/dist/{cli-ATAJSIXH.js → cli-2ZP4N7HK.js} +19 -19
- package/dist/{cli-5O7XENQY.js → cli-3GJYZH4C.js} +5 -5
- package/dist/{cli-H6PP2MZT.js → cli-3GO3M2MX.js} +17 -13
- package/dist/{cli-HMDYG6PS.js → cli-3LDLUNME.js} +17 -17
- package/dist/{cli-BZOKZ7LP.js → cli-3WY6L2WP.js} +27 -27
- package/dist/{cli-REAM7LSC.js → cli-44MBABRD.js} +25 -25
- package/dist/{cli-5TTJWM2R.js → cli-4IO7MKLR.js} +20 -20
- package/dist/{cli-HNDFANQG.js → cli-4U2PY7W3.js} +1 -1
- package/dist/{cli-WQ7JBZNW.js → cli-4WI4LTBI.js} +2 -2
- package/dist/{cli-OTBCA54D.js → cli-55EIGGZK.js} +1 -1
- package/dist/{cli-FYPW25VD.js → cli-5AQV6FTL.js} +18 -18
- package/dist/{cli-RKPQLB7J.js → cli-5CW7BEU7.js} +3 -3
- package/dist/{cli-27TQVLVF.js → cli-5JUVHNZF.js} +12 -12
- package/dist/{cli-F3YJKP6D.js → cli-5KERL6HV.js} +9 -4
- package/dist/{cli-MSNSXVGF.js → cli-5KSA24NQ.js} +24 -24
- package/dist/{cli-5VZBFMCK.js → cli-5PIFO3EN.js} +8 -0
- package/dist/{cli-FT3X3D4P.js → cli-5QN2Z43X.js} +20 -20
- package/dist/cli-5XSPAA5X.js +69 -0
- package/dist/{cli-B2QAJ5RQ.js → cli-62KAYGXO.js} +20 -20
- package/dist/{cli-QPV3TYOM.js → cli-6IMV5ZZU.js} +26 -26
- package/dist/{cli-UULZSQBV.js → cli-6KWCIAN2.js} +764 -66
- package/dist/{cli-DQE7ITIR.js → cli-6NWETIX5.js} +20 -20
- package/dist/{cli-L7F4XKCB.js → cli-774W3MN5.js} +26 -26
- package/dist/cli-7BUD3VAD.js +16 -0
- package/dist/{cli-XNOAO6DY.js → cli-7KEP57S7.js} +12 -12
- package/dist/{cli-5UKWX3IU.js → cli-7OYFJMA6.js} +18 -18
- package/dist/{cli-WNHMJM3Z.js → cli-7ZNEDQ3G.js} +20 -20
- package/dist/{cli-5RRPUL6V.js → cli-AFK6OUID.js} +12 -12
- package/dist/{cli-6P6V2EHY.js → cli-AIYQFWXN.js} +25 -25
- package/dist/{cli-ERJNDBDH.js → cli-ARAAEWIQ.js} +2 -2
- package/dist/cli-AVQYV3N4.js +36 -0
- package/dist/{cli-TI2FOFPA.js → cli-B54Z6CXH.js} +16 -16
- package/dist/{cli-EEO5ZPAZ.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-4F24FUW6.js → cli-BPS2JG74.js} +20 -20
- package/dist/{cli-W3RG2MRI.js → cli-BVO55SR2.js} +2 -2
- package/dist/{cli-R5SNTPND.js → cli-CFH3JZP5.js} +21 -21
- package/dist/{cli-Q7QSWNY2.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-QEFYDXMH.js → cli-DZCLRZXJ.js} +1 -1
- package/dist/{cli-77T4LJQF.js → cli-EJ47IE45.js} +24 -24
- 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-D3S7NJZ3.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-XOYUTNER.js → cli-HCXS5EXU.js} +25 -25
- package/dist/cli-HEUNNHDH.js +36 -0
- package/dist/{cli-G3TU6CP6.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-TLSTSZAC.js → cli-IO32YA5N.js} +26 -26
- package/dist/cli-IPTGZDBB.js +36 -0
- package/dist/{cli-OBLEROSC.js → cli-J25TYFKB.js} +19 -19
- package/dist/{cli-5ATO27Z4.js → cli-J7XYMEMX.js} +20 -20
- package/dist/{cli-X3TSTTYI.js → cli-JC5OJRID.js} +2 -2
- package/dist/{cli-25SJZI7N.js → cli-JD563OF4.js} +126 -27
- package/dist/{cli-VXLHOZSO.js → cli-JRJF2WHU.js} +20 -20
- package/dist/{cli-UQC46YSV.js → cli-JTFLIMIG.js} +3 -3
- package/dist/{cli-K4HSQWXC.js → cli-K2BSJ2PK.js} +2 -2
- package/dist/{cli-OM32UURE.js → cli-K4QTYMN2.js} +25 -25
- package/dist/{cli-BJFYGVJV.js → cli-KFJDD4C4.js} +20 -20
- package/dist/{cli-WW54THXN.js → cli-KVQ2JPVD.js} +1 -1
- package/dist/{cli-LHMRUJVN.js → cli-L6AHMW2Z.js} +1 -1
- package/dist/{cli-IKSLPAZN.js → cli-LCYUBCVY.js} +4 -4
- package/dist/{cli-HGCOEL5T.js → cli-LEWSCDH5.js} +4 -4
- package/dist/{cli-XJ7JESC2.js → cli-LI6G7GND.js} +27 -27
- package/dist/{cli-OMTHTWYJ.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-NKKCDO6K.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-LPFSJ625.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-X52TXCNF.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-UVIURDZC.js → cli-OMG4E53H.js} +20 -20
- package/dist/{cli-C32Q5E5I.js → cli-P6V3NSU4.js} +1 -1
- package/dist/{cli-RMD5WSUQ.js → cli-PAMQMTHK.js} +21 -21
- package/dist/{cli-WNBP3LOD.js → cli-PKTHOCT3.js} +26 -26
- package/dist/{cli-S3NHXAJM.js → cli-QK7QAP5H.js} +18 -18
- package/dist/cli-QQ432JEN.js +36 -0
- package/dist/{cli-YYXAGJQR.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-TEBV2OIW.js → cli-RQISHMJF.js} +83 -21
- package/dist/{cli-X64BNBQH.js → cli-RVZH462G.js} +585 -8
- package/dist/{cli-6AMK3DYS.js → cli-SEEOQVUL.js} +12 -12
- package/dist/{cli-QTCTWYCM.js → cli-SO354HPI.js} +3 -3
- package/dist/{cli-RHL4B4H7.js → cli-T76HDH7F.js} +88 -4
- package/dist/{cli-ZJW6HQ6N.js → cli-TIS7DWRR.js} +7 -7
- package/dist/{cli-6JWDFCUV.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-ATHATKI5.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-PNS4KWWC.js → cli-XCG33I77.js} +24 -24
- package/dist/{cli-DBMEH4Y5.js → cli-YHLSG5HB.js} +26 -26
- 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.js +1918 -283
- 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 +1 -1
- 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 +30 -0
- package/dist/docs/api/sdk-ui.md +7 -0
- package/dist/docs/api/sdk.md +834 -19
- package/dist/docs/changelog.md +28 -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/engine.md +8 -0
- 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/tick-controller.md +22 -1
- package/dist/docs/guides/ui.md +24 -0
- package/dist/docs/guides/upgrading.md +21 -0
- package/dist/docs/page-index.md +16 -12
- package/dist/docs/recipes/create-assessment.md +124 -0
- package/dist/docs/recipes/create-benchmark.md +115 -0
- 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/playwright.js +1912 -277
- 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/templating/resource-metadata.d.ts +1 -1
- package/dist/utils/error-codes.d.ts +9 -1
- 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/package.json +3 -3
- package/dist/cli-27Z5T52R.js +0 -30
- package/dist/cli-3VLBFWHN.js +0 -36
- package/dist/cli-BINVO5R7.js +0 -36
- package/dist/cli-HLI5UEKX.js +0 -36
- package/dist/cli-OF36EA62.js +0 -36
- package/dist/cli-OVIJRBFI.js +0 -36
- package/dist/cli-UIYKPSIY.js +0 -36
- package/dist/cli-WZNIW6ZO.js +0 -16
package/dist/client.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") {
|
|
@@ -201,6 +201,8 @@ var QUERY_TYPES = /* @__PURE__ */ new Set([
|
|
|
201
201
|
"callEndpoint",
|
|
202
202
|
"getPastState",
|
|
203
203
|
"getAllTeamsParticipants",
|
|
204
|
+
"getBenchmark",
|
|
205
|
+
"getAssessment",
|
|
204
206
|
"getEndpointAudit",
|
|
205
207
|
"listEndpoints"
|
|
206
208
|
]);
|
|
@@ -272,6 +274,7 @@ var COMMAND_FIELDS = {
|
|
|
272
274
|
resumeTimer: { "teamIndex?": "number" },
|
|
273
275
|
extendTick: { byMs: "number", "teamIndex?": "number" },
|
|
274
276
|
advanceClock: { byMs: "number" },
|
|
277
|
+
makeDormant: {},
|
|
275
278
|
armFault: { fault: "fault", "times?": "number", "reason?": "string" },
|
|
276
279
|
disarmFault: { fault: "fault" },
|
|
277
280
|
// Queries
|
|
@@ -299,6 +302,14 @@ var COMMAND_FIELDS = {
|
|
|
299
302
|
"participantId?": "string",
|
|
300
303
|
"teamId?": "string"
|
|
301
304
|
},
|
|
305
|
+
getBenchmark: { identifier: "string", where: "array" },
|
|
306
|
+
getAssessment: {
|
|
307
|
+
identifier: "string",
|
|
308
|
+
"audience?": "string",
|
|
309
|
+
"participantId?": "string",
|
|
310
|
+
"teamId?": "string",
|
|
311
|
+
"viewerRole?": "viewerRole"
|
|
312
|
+
},
|
|
302
313
|
getEndpointAudit: {},
|
|
303
314
|
listEndpoints: { "external?": "boolean" }
|
|
304
315
|
};
|
|
@@ -364,18 +375,373 @@ function commandError(value) {
|
|
|
364
375
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
365
376
|
import { isAbsolute as isAbsolute5, resolve as resolvePath2 } from "path";
|
|
366
377
|
|
|
378
|
+
// ../sdk/lib/build/callbacks.js
|
|
379
|
+
var UndeclaredApiUseError = class extends Error {
|
|
380
|
+
resourceIdentifier;
|
|
381
|
+
api;
|
|
382
|
+
constructor(resourceIdentifier, api) {
|
|
383
|
+
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.`);
|
|
384
|
+
this.name = "UndeclaredApiUseError";
|
|
385
|
+
this.resourceIdentifier = resourceIdentifier;
|
|
386
|
+
this.api = api;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// ../sdk/lib/build/tick-validation.js
|
|
391
|
+
var MAX_EFFECTIVE_TICK_INTERVAL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
392
|
+
|
|
393
|
+
// ../sdk/lib/build/setting-path.js
|
|
394
|
+
var NOT_PLAIN = /[.[\]"\s]/u;
|
|
395
|
+
function isPlainKey(key) {
|
|
396
|
+
return key !== "" && !NOT_PLAIN.test(key);
|
|
397
|
+
}
|
|
398
|
+
function settingPath(identifier, ...keys) {
|
|
399
|
+
let path3 = isPlainKey(identifier) ? identifier : `[${JSON.stringify(identifier)}]`;
|
|
400
|
+
for (const key of keys) {
|
|
401
|
+
const step = String(key);
|
|
402
|
+
path3 += isPlainKey(step) ? `.${step}` : `[${JSON.stringify(step)}]`;
|
|
403
|
+
}
|
|
404
|
+
return path3;
|
|
405
|
+
}
|
|
406
|
+
function parseSettingPath(path3) {
|
|
407
|
+
const steps = [];
|
|
408
|
+
let at = 0;
|
|
409
|
+
while (at < path3.length) {
|
|
410
|
+
if (path3[at] === "[") {
|
|
411
|
+
const end2 = closingQuote(path3, at + 1);
|
|
412
|
+
if (end2 === void 0 || path3[end2 + 1] !== "]")
|
|
413
|
+
return void 0;
|
|
414
|
+
let key2;
|
|
415
|
+
try {
|
|
416
|
+
key2 = JSON.parse(path3.slice(at + 1, end2 + 1));
|
|
417
|
+
} catch {
|
|
418
|
+
return void 0;
|
|
419
|
+
}
|
|
420
|
+
if (typeof key2 !== "string")
|
|
421
|
+
return void 0;
|
|
422
|
+
steps.push(key2);
|
|
423
|
+
at = end2 + 2;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
if (steps.length > 0) {
|
|
427
|
+
if (path3[at] !== ".")
|
|
428
|
+
return void 0;
|
|
429
|
+
at += 1;
|
|
430
|
+
}
|
|
431
|
+
let end = at;
|
|
432
|
+
while (end < path3.length && path3[end] !== "." && path3[end] !== "[")
|
|
433
|
+
end += 1;
|
|
434
|
+
const key = path3.slice(at, end);
|
|
435
|
+
if (!isPlainKey(key))
|
|
436
|
+
return void 0;
|
|
437
|
+
steps.push(key);
|
|
438
|
+
at = end;
|
|
439
|
+
}
|
|
440
|
+
const [identifier, ...keys] = steps;
|
|
441
|
+
return identifier === void 0 ? void 0 : { identifier, keys };
|
|
442
|
+
}
|
|
443
|
+
function closingQuote(path3, start) {
|
|
444
|
+
if (path3[start] !== '"')
|
|
445
|
+
return void 0;
|
|
446
|
+
for (let at = start + 1; at < path3.length; at += 1) {
|
|
447
|
+
if (path3[at] === "\\")
|
|
448
|
+
at += 1;
|
|
449
|
+
else if (path3[at] === '"')
|
|
450
|
+
return at;
|
|
451
|
+
}
|
|
452
|
+
return void 0;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// ../sdk/lib/build/validators.js
|
|
456
|
+
var SCENARIO_GATE_READ_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
457
|
+
var ScenarioAssetTooLargeError = class _ScenarioAssetTooLargeError extends Error {
|
|
458
|
+
/** The reference the gate asked to read. */
|
|
459
|
+
reference;
|
|
460
|
+
/** The file's size in bytes. */
|
|
461
|
+
size;
|
|
462
|
+
/** The cap it exceeds: {@link SCENARIO_GATE_READ_LIMIT_BYTES}. */
|
|
463
|
+
limit;
|
|
464
|
+
constructor(reference, size) {
|
|
465
|
+
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.`);
|
|
466
|
+
this.name = "ScenarioAssetTooLargeError";
|
|
467
|
+
this.reference = reference;
|
|
468
|
+
this.size = size;
|
|
469
|
+
this.limit = SCENARIO_GATE_READ_LIMIT_BYTES;
|
|
470
|
+
Object.setPrototypeOf(this, _ScenarioAssetTooLargeError.prototype);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
// ../sdk/lib/build/benchmarks.js
|
|
475
|
+
var BENCHMARKS_FEATURE = "benchmarks";
|
|
476
|
+
var BENCHMARK_TAG_VALUE_PATTERN = /^[A-Za-z0-9:._-]{1,64}$/;
|
|
477
|
+
var MAX_BENCHMARKS_PER_GAME = 20;
|
|
478
|
+
function resolveBenchmarkLevel(definition3) {
|
|
479
|
+
return definition3.level ?? "team";
|
|
480
|
+
}
|
|
481
|
+
function isRecord(value) {
|
|
482
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
483
|
+
}
|
|
484
|
+
function benchmarkWriteProblem(definition3, write) {
|
|
485
|
+
if (write === null)
|
|
486
|
+
return null;
|
|
487
|
+
if (!isRecord(write))
|
|
488
|
+
return "must be an object, or null to remove the record";
|
|
489
|
+
for (const [name, value] of Object.entries(write)) {
|
|
490
|
+
if (value === void 0 || value === null)
|
|
491
|
+
continue;
|
|
492
|
+
if (name === "tags") {
|
|
493
|
+
if (!isRecord(value))
|
|
494
|
+
return `"tags" must be an object of tag values`;
|
|
495
|
+
const declared = definition3.tags ?? [];
|
|
496
|
+
for (const [tag, tagValue] of Object.entries(value)) {
|
|
497
|
+
if (!declared.includes(tag)) {
|
|
498
|
+
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(", ")}`;
|
|
499
|
+
}
|
|
500
|
+
if (tagValue === void 0 || tagValue === null)
|
|
501
|
+
continue;
|
|
502
|
+
if (typeof tagValue !== "string" || !BENCHMARK_TAG_VALUE_PATTERN.test(tagValue)) {
|
|
503
|
+
return `tag "${tag}" must be 1 to 64 characters of letters, digits, ':', '.', '_' or '-', got ${JSON.stringify(tagValue)}`;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
if (name === "excluded") {
|
|
509
|
+
if (typeof value !== "boolean") {
|
|
510
|
+
return `"excluded" must be a boolean, got ${JSON.stringify(value)}`;
|
|
511
|
+
}
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
const field = definition3.fields[name];
|
|
515
|
+
if (!field)
|
|
516
|
+
return `field "${name}" is not declared`;
|
|
517
|
+
if ("type" in field) {
|
|
518
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
519
|
+
return `field "${name}" must be a finite number, got ${JSON.stringify(value)}`;
|
|
520
|
+
}
|
|
521
|
+
} else if (typeof value !== "string" || !field.enum.includes(value)) {
|
|
522
|
+
return `field "${name}" must be one of ${field.enum.map((o) => JSON.stringify(o)).join(", ")}, got ${JSON.stringify(value)}`;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
527
|
+
function applyBenchmarkWrite(current, write) {
|
|
528
|
+
if (write === null)
|
|
529
|
+
return void 0;
|
|
530
|
+
const next = { ...current };
|
|
531
|
+
for (const [name, value] of Object.entries(write)) {
|
|
532
|
+
if (value === void 0)
|
|
533
|
+
continue;
|
|
534
|
+
if (value === null) {
|
|
535
|
+
delete next[name];
|
|
536
|
+
} else if (name === "tags" && isRecord(value)) {
|
|
537
|
+
const tags = Object.fromEntries(Object.entries(value).filter(([, tagValue]) => typeof tagValue === "string"));
|
|
538
|
+
if (Object.keys(tags).length === 0)
|
|
539
|
+
delete next.tags;
|
|
540
|
+
else
|
|
541
|
+
next.tags = tags;
|
|
542
|
+
} else {
|
|
543
|
+
next[name] = value;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return Object.keys(next).length === 0 ? void 0 : next;
|
|
547
|
+
}
|
|
548
|
+
function benchmarkFilters(query) {
|
|
549
|
+
const where3 = query?.where;
|
|
550
|
+
const filters = where3 === void 0 ? [{}] : Array.isArray(where3) ? where3 : [where3];
|
|
551
|
+
if (filters.length === 0) {
|
|
552
|
+
throw new Error('getBenchmark: "where" must hold at least one filter');
|
|
553
|
+
}
|
|
554
|
+
for (const filter of filters) {
|
|
555
|
+
if (!isRecord(filter) || Object.values(filter).some((v) => typeof v !== "string")) {
|
|
556
|
+
throw new Error("getBenchmark: each filter must be an object of tag names to strings");
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return filters.map((filter) => ({ ...filter }));
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// ../sdk/lib/build/assessments.js
|
|
563
|
+
var ASSESSMENTS_FEATURE = "assessments";
|
|
564
|
+
var ASSESSMENTS_SETTINGS = "assessments";
|
|
565
|
+
var MAX_ASSESSMENTS_PER_GAME = 20;
|
|
566
|
+
var ASSESSMENT_FEEDBACK_MAX_LENGTH = 500;
|
|
567
|
+
function isRecord2(value) {
|
|
568
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
569
|
+
}
|
|
570
|
+
function foldRecord(definition3, current, write) {
|
|
571
|
+
if (write === null)
|
|
572
|
+
return { next: void 0 };
|
|
573
|
+
if (!isRecord2(write))
|
|
574
|
+
return { problem: "must be an object, or null to remove the result" };
|
|
575
|
+
const next = isRecord2(current) ? { ...current } : {};
|
|
576
|
+
for (const [name, value] of Object.entries(write)) {
|
|
577
|
+
if (value === void 0)
|
|
578
|
+
continue;
|
|
579
|
+
if (name === "score") {
|
|
580
|
+
if (value === null)
|
|
581
|
+
return { problem: '"score" cannot be removed; remove the result' };
|
|
582
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
583
|
+
return { problem: `"score" must be a finite number, got ${JSON.stringify(value)}` };
|
|
584
|
+
}
|
|
585
|
+
if (value < definition3.min || value > definition3.max) {
|
|
586
|
+
return {
|
|
587
|
+
problem: `"score" must be between ${definition3.min} and ${definition3.max}, got ${value}`
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
next.score = value;
|
|
591
|
+
} else if (name === "feedback") {
|
|
592
|
+
if (value === null) {
|
|
593
|
+
delete next.feedback;
|
|
594
|
+
} else if (typeof value !== "string") {
|
|
595
|
+
return { problem: `"feedback" must be a string, got ${JSON.stringify(value)}` };
|
|
596
|
+
} else if (value.length > ASSESSMENT_FEEDBACK_MAX_LENGTH) {
|
|
597
|
+
return {
|
|
598
|
+
problem: `"feedback" must be at most ${ASSESSMENT_FEEDBACK_MAX_LENGTH} characters, got ${value.length}`
|
|
599
|
+
};
|
|
600
|
+
} else {
|
|
601
|
+
next.feedback = value;
|
|
602
|
+
}
|
|
603
|
+
} else if (name === "final") {
|
|
604
|
+
if (value === null) {
|
|
605
|
+
delete next.final;
|
|
606
|
+
} else if (typeof value !== "boolean") {
|
|
607
|
+
return { problem: `"final" must be a boolean, got ${JSON.stringify(value)}` };
|
|
608
|
+
} else if (value) {
|
|
609
|
+
next.final = true;
|
|
610
|
+
} else {
|
|
611
|
+
delete next.final;
|
|
612
|
+
}
|
|
613
|
+
} else {
|
|
614
|
+
return {
|
|
615
|
+
problem: `"${name}" is not a field of a result; use score, feedback or final`
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (next.score === void 0) {
|
|
620
|
+
return { problem: 'a result needs a "score", and this write leaves it without one' };
|
|
621
|
+
}
|
|
622
|
+
return { next };
|
|
623
|
+
}
|
|
624
|
+
function foldAssessmentWrite(definition3, current, write, participantIds) {
|
|
625
|
+
if (definition3.level === "team")
|
|
626
|
+
return foldRecord(definition3, current, write);
|
|
627
|
+
if (write === null)
|
|
628
|
+
return { next: void 0 };
|
|
629
|
+
if (!isRecord2(write)) {
|
|
630
|
+
return {
|
|
631
|
+
problem: "must be an object of results by participant id, or null to remove every result"
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
const records = isRecord2(current) ? { ...current } : {};
|
|
635
|
+
for (const [participantId, recordWrite] of Object.entries(write)) {
|
|
636
|
+
if (recordWrite === void 0)
|
|
637
|
+
continue;
|
|
638
|
+
if (recordWrite !== null && !participantIds.has(participantId)) {
|
|
639
|
+
return {
|
|
640
|
+
problem: `participant "${participantId}" is not on this team, so it cannot be scored here`
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
const folded = foldRecord(definition3, records[participantId], recordWrite);
|
|
644
|
+
if ("problem" in folded) {
|
|
645
|
+
return { problem: `participant "${participantId}": ${folded.problem}` };
|
|
646
|
+
}
|
|
647
|
+
if (folded.next === void 0)
|
|
648
|
+
delete records[participantId];
|
|
649
|
+
else
|
|
650
|
+
records[participantId] = folded.next;
|
|
651
|
+
}
|
|
652
|
+
return { next: Object.keys(records).length === 0 ? void 0 : records };
|
|
653
|
+
}
|
|
654
|
+
function resolveAssessmentBands(definition3, settings) {
|
|
655
|
+
return (definition3.bands ?? []).map((band) => {
|
|
656
|
+
const override = settings?.[band.id];
|
|
657
|
+
return {
|
|
658
|
+
id: band.id,
|
|
659
|
+
from: typeof override?.from === "number" ? override.from : band.from,
|
|
660
|
+
passing: typeof override?.passing === "boolean" ? override.passing : band.passing === true
|
|
661
|
+
};
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
function assessmentBandOf(score, bands) {
|
|
665
|
+
let found = null;
|
|
666
|
+
for (const band of bands)
|
|
667
|
+
if (band.from <= score)
|
|
668
|
+
found = band;
|
|
669
|
+
return found;
|
|
670
|
+
}
|
|
671
|
+
function buildAssessmentReport(input) {
|
|
672
|
+
const { definition: definition3, bands, teams, participants, audience } = input;
|
|
673
|
+
const result = (record2, teamId, complete, participantId) => {
|
|
674
|
+
if (!isRecord2(record2) || typeof record2.score !== "number")
|
|
675
|
+
return null;
|
|
676
|
+
const band = assessmentBandOf(record2.score, bands);
|
|
677
|
+
const span = definition3.max - definition3.min;
|
|
678
|
+
return {
|
|
679
|
+
teamId,
|
|
680
|
+
...participantId === void 0 ? {} : { participantId },
|
|
681
|
+
score: record2.score,
|
|
682
|
+
scaled: span > 0 ? (record2.score - definition3.min) / span : 0,
|
|
683
|
+
band: band?.id ?? null,
|
|
684
|
+
passed: band === null ? null : band.passing,
|
|
685
|
+
...typeof record2.feedback === "string" ? { feedback: record2.feedback } : {},
|
|
686
|
+
final: record2.final === true || complete
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
const results = [];
|
|
690
|
+
if (definition3.level === "team") {
|
|
691
|
+
for (const team of teams) {
|
|
692
|
+
if (audience.kind !== "all" && audience.teamId !== team.teamId)
|
|
693
|
+
continue;
|
|
694
|
+
const row = result(team.records, team.teamId, team.complete);
|
|
695
|
+
if (row)
|
|
696
|
+
results.push(row);
|
|
697
|
+
}
|
|
698
|
+
} else {
|
|
699
|
+
const byTeam = new Map(teams.map((team) => [team.teamId, team]));
|
|
700
|
+
for (const participant of participants) {
|
|
701
|
+
if (audience.kind === "team" && audience.teamId !== participant.teamId)
|
|
702
|
+
continue;
|
|
703
|
+
if (audience.kind === "participant" && audience.participantId !== participant.id) {
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
const team = byTeam.get(participant.teamId);
|
|
707
|
+
if (!team || !isRecord2(team.records))
|
|
708
|
+
continue;
|
|
709
|
+
const row = result(team.records[participant.id], team.teamId, team.complete, participant.id);
|
|
710
|
+
if (row)
|
|
711
|
+
results.push(row);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return {
|
|
715
|
+
identifier: definition3.identifier,
|
|
716
|
+
level: definition3.level,
|
|
717
|
+
min: definition3.min,
|
|
718
|
+
max: definition3.max,
|
|
719
|
+
bands: bands.map((band) => ({ ...band })),
|
|
720
|
+
results
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
367
724
|
// ../sdk/lib/projection.js
|
|
368
725
|
var PROJECTION_VERSION = 4;
|
|
369
726
|
|
|
370
727
|
// cli/execution/engine-state.ts
|
|
371
728
|
var ENGINE_STATE_KEY = "$engineState";
|
|
372
729
|
var SHARED_ENGINE_STATE_KEY = "$sharedEngineState";
|
|
373
|
-
var
|
|
730
|
+
var BENCHMARKS_KEY = "$benchmarks";
|
|
731
|
+
var SHARED_BENCHMARKS_KEY = "$sharedBenchmarks";
|
|
732
|
+
var ASSESSMENTS_KEY = "$assessments";
|
|
733
|
+
var RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
734
|
+
ENGINE_STATE_KEY,
|
|
735
|
+
SHARED_ENGINE_STATE_KEY,
|
|
736
|
+
BENCHMARKS_KEY,
|
|
737
|
+
SHARED_BENCHMARKS_KEY,
|
|
738
|
+
ASSESSMENTS_KEY
|
|
739
|
+
]);
|
|
374
740
|
function isReservedKey(key) {
|
|
375
741
|
return RESERVED_KEYS.has(key);
|
|
376
742
|
}
|
|
377
743
|
function withoutEngineState(context) {
|
|
378
|
-
if (!(
|
|
744
|
+
if (!Object.keys(context).some(isReservedKey)) return context;
|
|
379
745
|
const rest = {};
|
|
380
746
|
for (const [key, value] of Object.entries(context)) {
|
|
381
747
|
if (!isReservedKey(key)) rest[key] = value;
|
|
@@ -565,6 +931,14 @@ var ERROR_CODES = {
|
|
|
565
931
|
category: "package",
|
|
566
932
|
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."
|
|
567
933
|
},
|
|
934
|
+
BENCHMARK_UNWRITTEN: {
|
|
935
|
+
category: "package",
|
|
936
|
+
description: "A benchmark is not in the engine's `benchmarks`, so nothing writes it and it never holds a value. A warning."
|
|
937
|
+
},
|
|
938
|
+
ASSESSMENT_UNWRITTEN: {
|
|
939
|
+
category: "package",
|
|
940
|
+
description: "An assessment is not in the engine's `assessments`, so nothing scores it and it never holds a result. A warning."
|
|
941
|
+
},
|
|
568
942
|
REFERENCE_UNKNOWN: {
|
|
569
943
|
category: "package",
|
|
570
944
|
description: "A `reads`, `writes`, `settings`, `configures` or `endpoints` entry names something the package does not declare."
|
|
@@ -1022,6 +1396,56 @@ async function readLogicExports(filePath, names, packageRoot) {
|
|
|
1022
1396
|
}
|
|
1023
1397
|
}
|
|
1024
1398
|
|
|
1399
|
+
// cli/core/assessment-settings.ts
|
|
1400
|
+
function assessmentSettingsResource(assessments) {
|
|
1401
|
+
const properties = {};
|
|
1402
|
+
for (const { definition: definition3 } of assessments) {
|
|
1403
|
+
const bands = definition3.bands ?? [];
|
|
1404
|
+
if (bands.length === 0) continue;
|
|
1405
|
+
const bandProperties = {};
|
|
1406
|
+
const defaults = {};
|
|
1407
|
+
for (const band of bands) {
|
|
1408
|
+
const value = { from: band.from, passing: band.passing === true };
|
|
1409
|
+
defaults[band.id] = value;
|
|
1410
|
+
bandProperties[band.id] = {
|
|
1411
|
+
type: "object",
|
|
1412
|
+
title: band.id,
|
|
1413
|
+
properties: {
|
|
1414
|
+
from: {
|
|
1415
|
+
type: "number",
|
|
1416
|
+
title: "Lowest score",
|
|
1417
|
+
minimum: definition3.min,
|
|
1418
|
+
maximum: definition3.max,
|
|
1419
|
+
default: value.from
|
|
1420
|
+
},
|
|
1421
|
+
passing: { type: "boolean", title: "Counts as a pass", default: value.passing }
|
|
1422
|
+
},
|
|
1423
|
+
additionalProperties: false,
|
|
1424
|
+
default: value
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
properties[definition3.identifier] = {
|
|
1428
|
+
type: "object",
|
|
1429
|
+
title: definition3.identifier,
|
|
1430
|
+
...definition3.description ? { description: definition3.description } : {},
|
|
1431
|
+
properties: bandProperties,
|
|
1432
|
+
additionalProperties: false,
|
|
1433
|
+
default: defaults
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
if (Object.keys(properties).length === 0) return null;
|
|
1437
|
+
return {
|
|
1438
|
+
definition: {
|
|
1439
|
+
identifier: ASSESSMENTS_SETTINGS,
|
|
1440
|
+
settingsSchema: {
|
|
1441
|
+
type: "object",
|
|
1442
|
+
properties,
|
|
1443
|
+
additionalProperties: false
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1025
1449
|
// ../schema.json
|
|
1026
1450
|
var schema_default = {
|
|
1027
1451
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -1178,6 +1602,24 @@ var schema_default = {
|
|
|
1178
1602
|
},
|
|
1179
1603
|
uniqueItems: true
|
|
1180
1604
|
},
|
|
1605
|
+
benchmarks: {
|
|
1606
|
+
type: "array",
|
|
1607
|
+
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`",
|
|
1608
|
+
items: {
|
|
1609
|
+
type: "string",
|
|
1610
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1611
|
+
},
|
|
1612
|
+
uniqueItems: true
|
|
1613
|
+
},
|
|
1614
|
+
assessments: {
|
|
1615
|
+
type: "array",
|
|
1616
|
+
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`",
|
|
1617
|
+
items: {
|
|
1618
|
+
type: "string",
|
|
1619
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1620
|
+
},
|
|
1621
|
+
uniqueItems: true
|
|
1622
|
+
},
|
|
1181
1623
|
aggregate: {
|
|
1182
1624
|
type: "boolean",
|
|
1183
1625
|
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.",
|
|
@@ -1187,6 +1629,163 @@ var schema_default = {
|
|
|
1187
1629
|
required: ["identifier"],
|
|
1188
1630
|
additionalProperties: false
|
|
1189
1631
|
},
|
|
1632
|
+
BenchmarkField: {
|
|
1633
|
+
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",
|
|
1634
|
+
oneOf: [
|
|
1635
|
+
{
|
|
1636
|
+
type: "object",
|
|
1637
|
+
properties: {
|
|
1638
|
+
type: { const: "number" },
|
|
1639
|
+
description: { type: "string" }
|
|
1640
|
+
},
|
|
1641
|
+
required: ["type"],
|
|
1642
|
+
additionalProperties: false
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
type: "object",
|
|
1646
|
+
properties: {
|
|
1647
|
+
enum: {
|
|
1648
|
+
type: "array",
|
|
1649
|
+
description: "The options a record may hold. Closed and short, so nothing free-form leaves the session",
|
|
1650
|
+
items: {
|
|
1651
|
+
type: "string",
|
|
1652
|
+
pattern: "^[A-Za-z0-9_-]{1,64}$"
|
|
1653
|
+
},
|
|
1654
|
+
minItems: 1,
|
|
1655
|
+
maxItems: 20,
|
|
1656
|
+
uniqueItems: true
|
|
1657
|
+
},
|
|
1658
|
+
description: { type: "string" }
|
|
1659
|
+
},
|
|
1660
|
+
required: ["enum"],
|
|
1661
|
+
additionalProperties: false
|
|
1662
|
+
}
|
|
1663
|
+
]
|
|
1664
|
+
},
|
|
1665
|
+
BenchmarkDefinition: {
|
|
1666
|
+
type: "object",
|
|
1667
|
+
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",
|
|
1668
|
+
properties: {
|
|
1669
|
+
identifier: {
|
|
1670
|
+
type: "string",
|
|
1671
|
+
description: "Identifier for the benchmark: its directory name",
|
|
1672
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1673
|
+
},
|
|
1674
|
+
revision: {
|
|
1675
|
+
type: "integer",
|
|
1676
|
+
minimum: 1,
|
|
1677
|
+
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"
|
|
1678
|
+
},
|
|
1679
|
+
level: {
|
|
1680
|
+
type: "string",
|
|
1681
|
+
enum: ["team", "session"],
|
|
1682
|
+
default: "team",
|
|
1683
|
+
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"
|
|
1684
|
+
},
|
|
1685
|
+
tags: {
|
|
1686
|
+
type: "array",
|
|
1687
|
+
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",
|
|
1688
|
+
items: {
|
|
1689
|
+
type: "string",
|
|
1690
|
+
pattern: "^[A-Za-z][A-Za-z0-9_]*$"
|
|
1691
|
+
},
|
|
1692
|
+
maxItems: 5,
|
|
1693
|
+
uniqueItems: true
|
|
1694
|
+
},
|
|
1695
|
+
fields: {
|
|
1696
|
+
type: "object",
|
|
1697
|
+
description: "The benchmark's fields, flat. 'tags' and 'excluded' are reserved",
|
|
1698
|
+
additionalProperties: { $ref: "#/$defs/BenchmarkField" },
|
|
1699
|
+
propertyNames: {
|
|
1700
|
+
pattern: "^[A-Za-z][A-Za-z0-9_]*$",
|
|
1701
|
+
not: { enum: ["tags", "excluded"] }
|
|
1702
|
+
},
|
|
1703
|
+
minProperties: 1,
|
|
1704
|
+
maxProperties: 20
|
|
1705
|
+
}
|
|
1706
|
+
},
|
|
1707
|
+
required: ["identifier", "revision", "fields"],
|
|
1708
|
+
additionalProperties: false
|
|
1709
|
+
},
|
|
1710
|
+
SDKBenchmark: {
|
|
1711
|
+
type: "object",
|
|
1712
|
+
description: "Bundle containing a benchmark definition",
|
|
1713
|
+
properties: {
|
|
1714
|
+
definition: { $ref: "#/$defs/BenchmarkDefinition" }
|
|
1715
|
+
},
|
|
1716
|
+
required: ["definition"],
|
|
1717
|
+
additionalProperties: false
|
|
1718
|
+
},
|
|
1719
|
+
AssessmentBand: {
|
|
1720
|
+
type: "object",
|
|
1721
|
+
description: "One band of an assessment's scores, such as 'developing' or 'expert': every score from `from` up to the next band's `from`",
|
|
1722
|
+
properties: {
|
|
1723
|
+
id: {
|
|
1724
|
+
type: "string",
|
|
1725
|
+
description: "The band's identifier, reported with each result in it. A user interface shows its own label for it",
|
|
1726
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1727
|
+
},
|
|
1728
|
+
from: {
|
|
1729
|
+
type: "number",
|
|
1730
|
+
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"
|
|
1731
|
+
},
|
|
1732
|
+
passing: {
|
|
1733
|
+
type: "boolean",
|
|
1734
|
+
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",
|
|
1735
|
+
default: false
|
|
1736
|
+
},
|
|
1737
|
+
description: {
|
|
1738
|
+
type: "string",
|
|
1739
|
+
description: "What the band means, for whoever reads the game's results"
|
|
1740
|
+
}
|
|
1741
|
+
},
|
|
1742
|
+
required: ["id", "from"],
|
|
1743
|
+
additionalProperties: false
|
|
1744
|
+
},
|
|
1745
|
+
AssessmentDefinition: {
|
|
1746
|
+
type: "object",
|
|
1747
|
+
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",
|
|
1748
|
+
properties: {
|
|
1749
|
+
identifier: {
|
|
1750
|
+
type: "string",
|
|
1751
|
+
description: "Identifier for the assessment: its directory name",
|
|
1752
|
+
pattern: "^[a-z][a-z0-9_]*$"
|
|
1753
|
+
},
|
|
1754
|
+
description: {
|
|
1755
|
+
type: "string",
|
|
1756
|
+
description: "What the assessment measures, for whoever reads the game's results"
|
|
1757
|
+
},
|
|
1758
|
+
level: {
|
|
1759
|
+
type: "string",
|
|
1760
|
+
enum: ["participant", "team"],
|
|
1761
|
+
description: "'participant': one score per participant, written for each by participant id. 'team': one score per team, which every participant on the team receives"
|
|
1762
|
+
},
|
|
1763
|
+
min: {
|
|
1764
|
+
type: "number",
|
|
1765
|
+
description: "The lowest score the engine may write"
|
|
1766
|
+
},
|
|
1767
|
+
max: {
|
|
1768
|
+
type: "number",
|
|
1769
|
+
description: "The highest score the engine may write. Greater than `min`"
|
|
1770
|
+
},
|
|
1771
|
+
bands: {
|
|
1772
|
+
type: "array",
|
|
1773
|
+
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",
|
|
1774
|
+
items: { $ref: "#/$defs/AssessmentBand" }
|
|
1775
|
+
}
|
|
1776
|
+
},
|
|
1777
|
+
required: ["identifier", "level", "min", "max"],
|
|
1778
|
+
additionalProperties: false
|
|
1779
|
+
},
|
|
1780
|
+
SDKAssessment: {
|
|
1781
|
+
type: "object",
|
|
1782
|
+
description: "Bundle containing an assessment definition",
|
|
1783
|
+
properties: {
|
|
1784
|
+
definition: { $ref: "#/$defs/AssessmentDefinition" }
|
|
1785
|
+
},
|
|
1786
|
+
required: ["definition"],
|
|
1787
|
+
additionalProperties: false
|
|
1788
|
+
},
|
|
1190
1789
|
CapabilityDefinition: {
|
|
1191
1790
|
type: "object",
|
|
1192
1791
|
description: "Definition of a capability",
|
|
@@ -2215,6 +2814,14 @@ var schema_default = {
|
|
|
2215
2814
|
type: "array",
|
|
2216
2815
|
items: { $ref: "#/$defs/SDKCapability" }
|
|
2217
2816
|
},
|
|
2817
|
+
benchmarks: {
|
|
2818
|
+
type: "array",
|
|
2819
|
+
items: { $ref: "#/$defs/SDKBenchmark" }
|
|
2820
|
+
},
|
|
2821
|
+
assessments: {
|
|
2822
|
+
type: "array",
|
|
2823
|
+
items: { $ref: "#/$defs/SDKAssessment" }
|
|
2824
|
+
},
|
|
2218
2825
|
settings: {
|
|
2219
2826
|
type: "array",
|
|
2220
2827
|
items: { $ref: "#/$defs/SDKSettings" }
|
|
@@ -2601,6 +3208,12 @@ var schema_default = {
|
|
|
2601
3208
|
SDKPackage: { $ref: "#/$defs/SDKPackage" },
|
|
2602
3209
|
SDKEngine: { $ref: "#/$defs/SDKEngine" },
|
|
2603
3210
|
SDKCapability: { $ref: "#/$defs/SDKCapability" },
|
|
3211
|
+
BenchmarkField: { $ref: "#/$defs/BenchmarkField" },
|
|
3212
|
+
BenchmarkDefinition: { $ref: "#/$defs/BenchmarkDefinition" },
|
|
3213
|
+
SDKBenchmark: { $ref: "#/$defs/SDKBenchmark" },
|
|
3214
|
+
AssessmentBand: { $ref: "#/$defs/AssessmentBand" },
|
|
3215
|
+
AssessmentDefinition: { $ref: "#/$defs/AssessmentDefinition" },
|
|
3216
|
+
SDKAssessment: { $ref: "#/$defs/SDKAssessment" },
|
|
2604
3217
|
SDKScenario: { $ref: "#/$defs/SDKScenario" },
|
|
2605
3218
|
SDKUserInterface: { $ref: "#/$defs/SDKUserInterface" },
|
|
2606
3219
|
SDKSetup: {
|
|
@@ -2772,7 +3385,11 @@ var SUPPORTED_FEATURES = [
|
|
|
2772
3385
|
// File reads in a validator's `Scenario` gate (§15.8).
|
|
2773
3386
|
"scenario-files",
|
|
2774
3387
|
// The `Scenario` gate judging a session as it starts, and refusing it (§15.8).
|
|
2775
|
-
"session-validation"
|
|
3388
|
+
"session-validation",
|
|
3389
|
+
// Benchmarks: engine-written records pooled across sessions (§6.16).
|
|
3390
|
+
"benchmarks",
|
|
3391
|
+
// Assessments: engine-written scores per participant or team, in bands (§6.17).
|
|
3392
|
+
"assessments"
|
|
2776
3393
|
];
|
|
2777
3394
|
function unsupportedFeatures(manifest) {
|
|
2778
3395
|
return (manifest.requires ?? []).filter((feature) => !SUPPORTED_FEATURES.includes(feature));
|
|
@@ -2802,102 +3419,6 @@ function unsupportedServices(resources, supported = SUPPORTED_SERVICES) {
|
|
|
2802
3419
|
import { existsSync as existsSync2, readdirSync, readFileSync } from "fs";
|
|
2803
3420
|
import { join } from "path";
|
|
2804
3421
|
|
|
2805
|
-
// ../sdk/lib/build/callbacks.js
|
|
2806
|
-
var UndeclaredApiUseError = class extends Error {
|
|
2807
|
-
resourceIdentifier;
|
|
2808
|
-
api;
|
|
2809
|
-
constructor(resourceIdentifier, api) {
|
|
2810
|
-
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.`);
|
|
2811
|
-
this.name = "UndeclaredApiUseError";
|
|
2812
|
-
this.resourceIdentifier = resourceIdentifier;
|
|
2813
|
-
this.api = api;
|
|
2814
|
-
}
|
|
2815
|
-
};
|
|
2816
|
-
|
|
2817
|
-
// ../sdk/lib/build/tick-validation.js
|
|
2818
|
-
var MAX_EFFECTIVE_TICK_INTERVAL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
2819
|
-
|
|
2820
|
-
// ../sdk/lib/build/setting-path.js
|
|
2821
|
-
var NOT_PLAIN = /[.[\]"\s]/u;
|
|
2822
|
-
function isPlainKey(key) {
|
|
2823
|
-
return key !== "" && !NOT_PLAIN.test(key);
|
|
2824
|
-
}
|
|
2825
|
-
function settingPath(identifier, ...keys) {
|
|
2826
|
-
let path3 = isPlainKey(identifier) ? identifier : `[${JSON.stringify(identifier)}]`;
|
|
2827
|
-
for (const key of keys) {
|
|
2828
|
-
const step = String(key);
|
|
2829
|
-
path3 += isPlainKey(step) ? `.${step}` : `[${JSON.stringify(step)}]`;
|
|
2830
|
-
}
|
|
2831
|
-
return path3;
|
|
2832
|
-
}
|
|
2833
|
-
function parseSettingPath(path3) {
|
|
2834
|
-
const steps = [];
|
|
2835
|
-
let at = 0;
|
|
2836
|
-
while (at < path3.length) {
|
|
2837
|
-
if (path3[at] === "[") {
|
|
2838
|
-
const end2 = closingQuote(path3, at + 1);
|
|
2839
|
-
if (end2 === void 0 || path3[end2 + 1] !== "]")
|
|
2840
|
-
return void 0;
|
|
2841
|
-
let key2;
|
|
2842
|
-
try {
|
|
2843
|
-
key2 = JSON.parse(path3.slice(at + 1, end2 + 1));
|
|
2844
|
-
} catch {
|
|
2845
|
-
return void 0;
|
|
2846
|
-
}
|
|
2847
|
-
if (typeof key2 !== "string")
|
|
2848
|
-
return void 0;
|
|
2849
|
-
steps.push(key2);
|
|
2850
|
-
at = end2 + 2;
|
|
2851
|
-
continue;
|
|
2852
|
-
}
|
|
2853
|
-
if (steps.length > 0) {
|
|
2854
|
-
if (path3[at] !== ".")
|
|
2855
|
-
return void 0;
|
|
2856
|
-
at += 1;
|
|
2857
|
-
}
|
|
2858
|
-
let end = at;
|
|
2859
|
-
while (end < path3.length && path3[end] !== "." && path3[end] !== "[")
|
|
2860
|
-
end += 1;
|
|
2861
|
-
const key = path3.slice(at, end);
|
|
2862
|
-
if (!isPlainKey(key))
|
|
2863
|
-
return void 0;
|
|
2864
|
-
steps.push(key);
|
|
2865
|
-
at = end;
|
|
2866
|
-
}
|
|
2867
|
-
const [identifier, ...keys] = steps;
|
|
2868
|
-
return identifier === void 0 ? void 0 : { identifier, keys };
|
|
2869
|
-
}
|
|
2870
|
-
function closingQuote(path3, start) {
|
|
2871
|
-
if (path3[start] !== '"')
|
|
2872
|
-
return void 0;
|
|
2873
|
-
for (let at = start + 1; at < path3.length; at += 1) {
|
|
2874
|
-
if (path3[at] === "\\")
|
|
2875
|
-
at += 1;
|
|
2876
|
-
else if (path3[at] === '"')
|
|
2877
|
-
return at;
|
|
2878
|
-
}
|
|
2879
|
-
return void 0;
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
// ../sdk/lib/build/validators.js
|
|
2883
|
-
var SCENARIO_GATE_READ_LIMIT_BYTES = 10 * 1024 * 1024;
|
|
2884
|
-
var ScenarioAssetTooLargeError = class _ScenarioAssetTooLargeError extends Error {
|
|
2885
|
-
/** The reference the gate asked to read. */
|
|
2886
|
-
reference;
|
|
2887
|
-
/** The file's size in bytes. */
|
|
2888
|
-
size;
|
|
2889
|
-
/** The cap it exceeds: {@link SCENARIO_GATE_READ_LIMIT_BYTES}. */
|
|
2890
|
-
limit;
|
|
2891
|
-
constructor(reference, size) {
|
|
2892
|
-
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.`);
|
|
2893
|
-
this.name = "ScenarioAssetTooLargeError";
|
|
2894
|
-
this.reference = reference;
|
|
2895
|
-
this.size = size;
|
|
2896
|
-
this.limit = SCENARIO_GATE_READ_LIMIT_BYTES;
|
|
2897
|
-
Object.setPrototypeOf(this, _ScenarioAssetTooLargeError.prototype);
|
|
2898
|
-
}
|
|
2899
|
-
};
|
|
2900
|
-
|
|
2901
3422
|
// ../node_modules/.pnpm/ccount@2.0.1/node_modules/ccount/index.js
|
|
2902
3423
|
function ccount(value, character) {
|
|
2903
3424
|
const source = String(value);
|
|
@@ -15165,6 +15686,39 @@ var BASES = [
|
|
|
15165
15686
|
mergeDefinition: true,
|
|
15166
15687
|
referencedByReadsWrites: true
|
|
15167
15688
|
},
|
|
15689
|
+
{
|
|
15690
|
+
type: "benchmark",
|
|
15691
|
+
pluralDir: "benchmarks",
|
|
15692
|
+
bundleFile: "benchmark.sdk.json",
|
|
15693
|
+
manifestKey: "benchmarks",
|
|
15694
|
+
kind: "composition",
|
|
15695
|
+
label: "Benchmark",
|
|
15696
|
+
// Only the engine writes benchmarks, so it is the one referrer: a
|
|
15697
|
+
// benchmark anywhere else would let a participant or a facilitator
|
|
15698
|
+
// move the figures every other session is compared with.
|
|
15699
|
+
sites: [
|
|
15700
|
+
{
|
|
15701
|
+
referrerKeys: ["engine"],
|
|
15702
|
+
shape: { kind: "stringArray", path: "benchmarks", labelSuffix: "benchmarks" }
|
|
15703
|
+
}
|
|
15704
|
+
]
|
|
15705
|
+
},
|
|
15706
|
+
{
|
|
15707
|
+
type: "assessment",
|
|
15708
|
+
pluralDir: "assessments",
|
|
15709
|
+
bundleFile: "assessment.sdk.json",
|
|
15710
|
+
manifestKey: "assessments",
|
|
15711
|
+
kind: "composition",
|
|
15712
|
+
label: "Assessment",
|
|
15713
|
+
// Only the engine scores, so it is the one referrer: a score written
|
|
15714
|
+
// anywhere else could be a participant marking their own work.
|
|
15715
|
+
sites: [
|
|
15716
|
+
{
|
|
15717
|
+
referrerKeys: ["engine"],
|
|
15718
|
+
shape: { kind: "stringArray", path: "assessments", labelSuffix: "assessments" }
|
|
15719
|
+
}
|
|
15720
|
+
]
|
|
15721
|
+
},
|
|
15168
15722
|
{
|
|
15169
15723
|
type: "engine",
|
|
15170
15724
|
slot: "engine",
|
|
@@ -15928,6 +16482,70 @@ var capabilityExample = JSON.stringify(
|
|
|
15928
16482
|
null,
|
|
15929
16483
|
4
|
|
15930
16484
|
);
|
|
16485
|
+
var benchmarkExample = JSON.stringify(
|
|
16486
|
+
{
|
|
16487
|
+
definition: {
|
|
16488
|
+
identifier: "outcome",
|
|
16489
|
+
revision: 1,
|
|
16490
|
+
tags: ["difficulty"],
|
|
16491
|
+
fields: {
|
|
16492
|
+
NetProfit: { type: "number", description: "Profit over the whole game" },
|
|
16493
|
+
Round1Pricing: { enum: ["premium", "match", "discount"] }
|
|
16494
|
+
}
|
|
16495
|
+
}
|
|
16496
|
+
},
|
|
16497
|
+
null,
|
|
16498
|
+
4
|
|
16499
|
+
);
|
|
16500
|
+
var benchmarkUpdateExample = JSON.stringify(
|
|
16501
|
+
{
|
|
16502
|
+
definition: {
|
|
16503
|
+
identifier: "outcome",
|
|
16504
|
+
revision: 2,
|
|
16505
|
+
tags: ["difficulty", "teams"],
|
|
16506
|
+
fields: {
|
|
16507
|
+
NetProfit: { type: "number", description: "Profit over the whole game" }
|
|
16508
|
+
}
|
|
16509
|
+
}
|
|
16510
|
+
},
|
|
16511
|
+
null,
|
|
16512
|
+
4
|
|
16513
|
+
);
|
|
16514
|
+
var assessmentExample = JSON.stringify(
|
|
16515
|
+
{
|
|
16516
|
+
definition: {
|
|
16517
|
+
identifier: "teamwork",
|
|
16518
|
+
description: "How well each participant worked with their team",
|
|
16519
|
+
level: "participant",
|
|
16520
|
+
min: 0,
|
|
16521
|
+
max: 100,
|
|
16522
|
+
bands: [
|
|
16523
|
+
{ id: "developing", from: 0 },
|
|
16524
|
+
{ id: "competent", from: 50, passing: true },
|
|
16525
|
+
{ id: "expert", from: 80, passing: true }
|
|
16526
|
+
]
|
|
16527
|
+
}
|
|
16528
|
+
},
|
|
16529
|
+
null,
|
|
16530
|
+
4
|
|
16531
|
+
);
|
|
16532
|
+
var assessmentUpdateExample = JSON.stringify(
|
|
16533
|
+
{
|
|
16534
|
+
definition: {
|
|
16535
|
+
identifier: "teamwork",
|
|
16536
|
+
level: "participant",
|
|
16537
|
+
min: 0,
|
|
16538
|
+
max: 100,
|
|
16539
|
+
bands: [
|
|
16540
|
+
{ id: "developing", from: 0 },
|
|
16541
|
+
{ id: "competent", from: 60, passing: true },
|
|
16542
|
+
{ id: "expert", from: 85, passing: true }
|
|
16543
|
+
]
|
|
16544
|
+
}
|
|
16545
|
+
},
|
|
16546
|
+
null,
|
|
16547
|
+
4
|
|
16548
|
+
);
|
|
15931
16549
|
var settingsExample = JSON.stringify(
|
|
15932
16550
|
{
|
|
15933
16551
|
definition: {
|
|
@@ -16407,6 +17025,8 @@ var facilitatorGuideUpdateExample = JSON.stringify(
|
|
|
16407
17025
|
var RESOURCE_EXAMPLES = {
|
|
16408
17026
|
package: { new: packageExample, update: packageUpdateExample },
|
|
16409
17027
|
capability: { new: capabilityExample, update: capabilityUpdateExample },
|
|
17028
|
+
benchmark: { new: benchmarkExample, update: benchmarkUpdateExample },
|
|
17029
|
+
assessment: { new: assessmentExample, update: assessmentUpdateExample },
|
|
16410
17030
|
settings: { new: settingsExample, update: settingsUpdateExample },
|
|
16411
17031
|
engine: { new: engineExample, update: engineUpdateExample },
|
|
16412
17032
|
ui: { new: userInterfaceExample, update: userInterfaceUpdateExample },
|
|
@@ -16440,6 +17060,8 @@ var settingsAjv = createAjv("reference");
|
|
|
16440
17060
|
ajv2.addSchema(schema, "schema.json");
|
|
16441
17061
|
var validators = {
|
|
16442
17062
|
sdkCapability: ajv2.compile({ $ref: "schema.json#/$defs/SDKCapability" }),
|
|
17063
|
+
sdkBenchmark: ajv2.compile({ $ref: "schema.json#/$defs/SDKBenchmark" }),
|
|
17064
|
+
sdkAssessment: ajv2.compile({ $ref: "schema.json#/$defs/SDKAssessment" }),
|
|
16443
17065
|
sdkSettings: ajv2.compile({ $ref: "schema.json#/$defs/SDKSettings" }),
|
|
16444
17066
|
sdkEngine: ajv2.compile({ $ref: "schema.json#/$defs/SDKEngine" }),
|
|
16445
17067
|
sdkUserInterface: ajv2.compile({
|
|
@@ -16591,6 +17213,16 @@ var validateSDKCapability = makeValidator(
|
|
|
16591
17213
|
"capability.sdk.json",
|
|
16592
17214
|
resourceExample("capability", "new")
|
|
16593
17215
|
);
|
|
17216
|
+
var validateSDKBenchmark = makeValidator(
|
|
17217
|
+
validators.sdkBenchmark,
|
|
17218
|
+
"benchmark.sdk.json",
|
|
17219
|
+
resourceExample("benchmark", "new")
|
|
17220
|
+
);
|
|
17221
|
+
var validateSDKAssessment = makeValidator(
|
|
17222
|
+
validators.sdkAssessment,
|
|
17223
|
+
"assessment.sdk.json",
|
|
17224
|
+
resourceExample("assessment", "new")
|
|
17225
|
+
);
|
|
16594
17226
|
var validateSDKSettings = makeValidator(
|
|
16595
17227
|
validators.sdkSettings,
|
|
16596
17228
|
"settings.sdk.json",
|
|
@@ -17199,8 +17831,16 @@ async function loadConfig(configPath) {
|
|
|
17199
17831
|
problems.throwIfAny();
|
|
17200
17832
|
assertRequiredFeaturesSupported(jsonConfig, configPath);
|
|
17201
17833
|
const capabilities = await discover(configDir, KINDS.capability, problems);
|
|
17834
|
+
const benchmarks = await discover(configDir, KINDS.benchmark, problems);
|
|
17835
|
+
const assessments = await discover(configDir, KINDS.assessment, problems);
|
|
17202
17836
|
const authoredSettings = await discover(configDir, KINDS.settings, problems);
|
|
17203
17837
|
refuseReservedSettings(problems, authoredSettings);
|
|
17838
|
+
if (assessments.length > 0) refuseAssessmentSettings(problems, authoredSettings);
|
|
17839
|
+
const assessmentSettings = assessmentSettingsResource(assessments);
|
|
17840
|
+
const builtInSettings = () => [
|
|
17841
|
+
gameSettingsResource(jsonConfig),
|
|
17842
|
+
...assessmentSettings ? [assessmentSettings] : []
|
|
17843
|
+
];
|
|
17204
17844
|
const scenarios = await discover(configDir, KINDS.scenario, problems);
|
|
17205
17845
|
const hooks = await discover(configDir, KINDS.hook, problems);
|
|
17206
17846
|
const discoveredValidators = await discover(configDir, KINDS.validator, problems);
|
|
@@ -17238,7 +17878,7 @@ async function loadConfig(configPath) {
|
|
|
17238
17878
|
refuseUnknownSettingsInSetupNotes(
|
|
17239
17879
|
setup,
|
|
17240
17880
|
configDir,
|
|
17241
|
-
[
|
|
17881
|
+
[...builtInSettings(), ...authoredSettings],
|
|
17242
17882
|
problems
|
|
17243
17883
|
);
|
|
17244
17884
|
problems.throwIfAny();
|
|
@@ -17270,8 +17910,10 @@ async function loadConfig(configPath) {
|
|
|
17270
17910
|
...tick_controller ? { tick_controller } : {},
|
|
17271
17911
|
...guide ? { guide } : {},
|
|
17272
17912
|
capabilities,
|
|
17273
|
-
|
|
17274
|
-
|
|
17913
|
+
...benchmarks.length > 0 ? { benchmarks } : {},
|
|
17914
|
+
...assessments.length > 0 ? { assessments } : {},
|
|
17915
|
+
// The built-in settings come first, then the package's own.
|
|
17916
|
+
settings: [...builtInSettings(), ...authoredSettings],
|
|
17275
17917
|
scenarios,
|
|
17276
17918
|
hooks,
|
|
17277
17919
|
validators: validators2,
|
|
@@ -17420,6 +18062,19 @@ function refuseReservedSettings(problems, settings) {
|
|
|
17420
18062
|
}
|
|
17421
18063
|
]);
|
|
17422
18064
|
}
|
|
18065
|
+
function refuseAssessmentSettings(problems, settings) {
|
|
18066
|
+
if (!settings.some((entry) => entry.definition.identifier === ASSESSMENTS_SETTINGS)) return;
|
|
18067
|
+
const message = `\`settings/${ASSESSMENTS_SETTINGS}/\` is reserved for the built-in assessment band settings`;
|
|
18068
|
+
const hint = "Set an assessment's bands in its assessment.sdk.json, and rename this settings resource.";
|
|
18069
|
+
problems.add("SETTINGS_RESERVED", `Invalid package: ${message}. ${hint}`, [
|
|
18070
|
+
{
|
|
18071
|
+
code: "SETTINGS_RESERVED",
|
|
18072
|
+
message,
|
|
18073
|
+
hint,
|
|
18074
|
+
file: `settings/${ASSESSMENTS_SETTINGS}/settings.sdk.json`
|
|
18075
|
+
}
|
|
18076
|
+
]);
|
|
18077
|
+
}
|
|
17423
18078
|
function refuseUnknownSettingsInSetupNotes(setup, configDir, settings, problems) {
|
|
17424
18079
|
if (!setup) return;
|
|
17425
18080
|
const schemas = settingsSchemas({ settings: [...settings] });
|
|
@@ -17599,6 +18254,8 @@ function kind(type, validate2, hasRootDirectory = true) {
|
|
|
17599
18254
|
}
|
|
17600
18255
|
var KINDS = {
|
|
17601
18256
|
capability: kind("capability", validateSDKCapability, false),
|
|
18257
|
+
benchmark: kind("benchmark", validateSDKBenchmark, false),
|
|
18258
|
+
assessment: kind("assessment", validateSDKAssessment, false),
|
|
17602
18259
|
settings: kind("settings", validateSDKSettings, false),
|
|
17603
18260
|
engine: kind("engine", validateSDKEngine),
|
|
17604
18261
|
ui: kind("ui", validateSDKUserInterface),
|
|
@@ -18638,11 +19295,11 @@ function normalizeVariablesSchema(schema2) {
|
|
|
18638
19295
|
}
|
|
18639
19296
|
|
|
18640
19297
|
// cli/execution/logic-result.ts
|
|
18641
|
-
function
|
|
19298
|
+
function isRecord3(value) {
|
|
18642
19299
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18643
19300
|
}
|
|
18644
19301
|
function readCapabilities(label4, result, allowed = ["capabilities", "deletes"]) {
|
|
18645
|
-
if (!
|
|
19302
|
+
if (!isRecord3(result)) {
|
|
18646
19303
|
throw new Error(`${label4} must return an object of the form { capabilities: { ... } }`);
|
|
18647
19304
|
}
|
|
18648
19305
|
const unknownKeys = Object.keys(result).filter((key) => !allowed.includes(key));
|
|
@@ -18656,7 +19313,7 @@ function readCapabilities(label4, result, allowed = ["capabilities", "deletes"])
|
|
|
18656
19313
|
if (capabilities === void 0 || capabilities === null) {
|
|
18657
19314
|
return {};
|
|
18658
19315
|
}
|
|
18659
|
-
if (!
|
|
19316
|
+
if (!isRecord3(capabilities)) {
|
|
18660
19317
|
throw new Error(`${label4} returned "capabilities" that is not an object`);
|
|
18661
19318
|
}
|
|
18662
19319
|
const reserved = Object.keys(capabilities).find(isReservedKey);
|
|
@@ -18668,7 +19325,7 @@ function readCapabilities(label4, result, allowed = ["capabilities", "deletes"])
|
|
|
18668
19325
|
return capabilities;
|
|
18669
19326
|
}
|
|
18670
19327
|
function readDeletes(label4, result) {
|
|
18671
|
-
if (!
|
|
19328
|
+
if (!isRecord3(result)) return [];
|
|
18672
19329
|
const deletes = result.deletes;
|
|
18673
19330
|
if (deletes === void 0 || deletes === null) return [];
|
|
18674
19331
|
if (!Array.isArray(deletes)) {
|
|
@@ -18713,18 +19370,32 @@ function assertDeletesDeclared(label4, deletes, declaration, shared, target) {
|
|
|
18713
19370
|
}
|
|
18714
19371
|
}
|
|
18715
19372
|
}
|
|
18716
|
-
function readEngineResult(label4, result, phase = "init") {
|
|
18717
|
-
const allowed =
|
|
19373
|
+
function readEngineResult(label4, result, phase = "init", writesBenchmarks = false, writesAssessments = false) {
|
|
19374
|
+
const allowed = [
|
|
19375
|
+
"capabilities",
|
|
19376
|
+
"deletes",
|
|
19377
|
+
"state",
|
|
19378
|
+
...phase === "tick" ? ["complete"] : [],
|
|
19379
|
+
...writesBenchmarks ? ["benchmarks"] : [],
|
|
19380
|
+
...writesAssessments ? ["assessments"] : []
|
|
19381
|
+
];
|
|
18718
19382
|
const capabilities = readCapabilities(label4, result, allowed);
|
|
18719
19383
|
const deletes = readDeletes(label4, result);
|
|
18720
|
-
const { state: state2, complete } = result;
|
|
19384
|
+
const { state: state2, complete, benchmarks, assessments } = result;
|
|
18721
19385
|
if (complete !== void 0 && typeof complete !== "boolean") {
|
|
18722
19386
|
throw new Error(`${label4} returned "complete" that is not a boolean`);
|
|
18723
19387
|
}
|
|
18724
|
-
return {
|
|
19388
|
+
return {
|
|
19389
|
+
capabilities,
|
|
19390
|
+
deletes,
|
|
19391
|
+
state: state2,
|
|
19392
|
+
complete: complete === true,
|
|
19393
|
+
...benchmarks === void 0 ? {} : { benchmarks },
|
|
19394
|
+
...assessments === void 0 ? {} : { assessments }
|
|
19395
|
+
};
|
|
18725
19396
|
}
|
|
18726
|
-
function readAggregateResult(label4, result, teamCount, phase = "init") {
|
|
18727
|
-
if (!
|
|
19397
|
+
function readAggregateResult(label4, result, teamCount, phase = "init", writesBenchmarks = false, writesAssessments = false) {
|
|
19398
|
+
if (!isRecord3(result)) {
|
|
18728
19399
|
throw new Error(
|
|
18729
19400
|
`${label4} must return { shared: { capabilities }, teams: [{ capabilities }] }`
|
|
18730
19401
|
);
|
|
@@ -18741,15 +19412,27 @@ function readAggregateResult(label4, result, teamCount, phase = "init") {
|
|
|
18741
19412
|
);
|
|
18742
19413
|
}
|
|
18743
19414
|
return {
|
|
18744
|
-
shared: result.shared === void 0 ? { capabilities: {}, deletes: [], state: void 0, complete: false } : readEngineResult(
|
|
19415
|
+
shared: result.shared === void 0 ? { capabilities: {}, deletes: [], state: void 0, complete: false } : readEngineResult(
|
|
19416
|
+
`${label4} "shared"`,
|
|
19417
|
+
result.shared,
|
|
19418
|
+
phase,
|
|
19419
|
+
writesBenchmarks,
|
|
19420
|
+
writesAssessments
|
|
19421
|
+
),
|
|
18745
19422
|
teams: result.teams.map(
|
|
18746
|
-
(team, i) => readEngineResult(
|
|
19423
|
+
(team, i) => readEngineResult(
|
|
19424
|
+
`${label4} "teams[${i}]"`,
|
|
19425
|
+
team,
|
|
19426
|
+
phase,
|
|
19427
|
+
writesBenchmarks,
|
|
19428
|
+
writesAssessments
|
|
19429
|
+
)
|
|
18747
19430
|
)
|
|
18748
19431
|
};
|
|
18749
19432
|
}
|
|
18750
19433
|
var TICK_CONTROLLER_KEYS = ["enabled", "intervalMs", "nextTickAt", "complete"];
|
|
18751
19434
|
function readTickControllerResult(label4, result) {
|
|
18752
|
-
if (!
|
|
19435
|
+
if (!isRecord3(result)) {
|
|
18753
19436
|
throw new Error(`${label4} must return an object of the form { enabled, intervalMs? }`);
|
|
18754
19437
|
}
|
|
18755
19438
|
const unknownKeys = Object.keys(result).filter((key) => !TICK_CONTROLLER_KEYS.includes(key));
|
|
@@ -18768,6 +19451,87 @@ function readTickControllerResult(label4, result) {
|
|
|
18768
19451
|
}
|
|
18769
19452
|
|
|
18770
19453
|
// cli/execution/context-composition.ts
|
|
19454
|
+
function foldAssessmentWrites(label4, raw, current, participantIds, scope) {
|
|
19455
|
+
if (raw === void 0) return void 0;
|
|
19456
|
+
if (!isPlainObject3(raw)) {
|
|
19457
|
+
scope.warn(
|
|
19458
|
+
`${label4} returned "assessments" that is not an object of writes by assessment. Every assessment write in it was dropped, and the round carried on.`
|
|
19459
|
+
);
|
|
19460
|
+
return void 0;
|
|
19461
|
+
}
|
|
19462
|
+
const writes = structuredClone(raw);
|
|
19463
|
+
const results = structuredClone(isPlainObject3(current) ? current : {});
|
|
19464
|
+
for (const [identifier, write] of Object.entries(writes)) {
|
|
19465
|
+
if (write === void 0) continue;
|
|
19466
|
+
const named3 = `${label4} wrote assessment "${identifier}"`;
|
|
19467
|
+
const definition3 = scope.assessments?.get(identifier);
|
|
19468
|
+
if (!definition3) {
|
|
19469
|
+
scope.warn(
|
|
19470
|
+
`${named3}, which the engine does not declare in "assessments". The write was dropped.`
|
|
19471
|
+
);
|
|
19472
|
+
continue;
|
|
19473
|
+
}
|
|
19474
|
+
const folded = foldAssessmentWrite(definition3, results[identifier], write, participantIds);
|
|
19475
|
+
if ("problem" in folded) {
|
|
19476
|
+
scope.warn(
|
|
19477
|
+
`${named3}: ${folded.problem}. The write was dropped, and the round carried on.`
|
|
19478
|
+
);
|
|
19479
|
+
continue;
|
|
19480
|
+
}
|
|
19481
|
+
if (folded.next === void 0) delete results[identifier];
|
|
19482
|
+
else results[identifier] = folded.next;
|
|
19483
|
+
}
|
|
19484
|
+
return results;
|
|
19485
|
+
}
|
|
19486
|
+
function isPlainObject3(value) {
|
|
19487
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19488
|
+
}
|
|
19489
|
+
function foldBenchmarkWrites(label4, raw, current, level, scope) {
|
|
19490
|
+
if (raw === void 0) return void 0;
|
|
19491
|
+
if (!isPlainObject3(raw)) {
|
|
19492
|
+
scope.warn(
|
|
19493
|
+
`${label4} returned "benchmarks" that is not an object of writes by benchmark. Every benchmark write in it was dropped, and the round carried on.`
|
|
19494
|
+
);
|
|
19495
|
+
return void 0;
|
|
19496
|
+
}
|
|
19497
|
+
const writes = structuredClone(raw);
|
|
19498
|
+
const records = structuredClone(isPlainObject3(current) ? current : {});
|
|
19499
|
+
for (const [identifier, write] of Object.entries(writes)) {
|
|
19500
|
+
if (write === void 0) continue;
|
|
19501
|
+
const named3 = `${label4} wrote benchmark "${identifier}"`;
|
|
19502
|
+
const definition3 = scope.benchmarks.get(identifier);
|
|
19503
|
+
if (!definition3) {
|
|
19504
|
+
scope.warn(
|
|
19505
|
+
`${named3}, which the engine does not declare in "benchmarks". The write was dropped.`
|
|
19506
|
+
);
|
|
19507
|
+
continue;
|
|
19508
|
+
}
|
|
19509
|
+
const declaredLevel = resolveBenchmarkLevel(definition3);
|
|
19510
|
+
if (declaredLevel !== level) {
|
|
19511
|
+
scope.warn(
|
|
19512
|
+
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.`
|
|
19513
|
+
);
|
|
19514
|
+
continue;
|
|
19515
|
+
}
|
|
19516
|
+
const problem = benchmarkWriteProblem(definition3, write);
|
|
19517
|
+
if (problem !== null) {
|
|
19518
|
+
scope.warn(`${named3}: ${problem}. The write was dropped, and the round carried on.`);
|
|
19519
|
+
continue;
|
|
19520
|
+
}
|
|
19521
|
+
const next = applyBenchmarkWrite(
|
|
19522
|
+
records[identifier],
|
|
19523
|
+
write
|
|
19524
|
+
);
|
|
19525
|
+
if (next === void 0) delete records[identifier];
|
|
19526
|
+
else records[identifier] = next;
|
|
19527
|
+
}
|
|
19528
|
+
return records;
|
|
19529
|
+
}
|
|
19530
|
+
function storeRecords(target, key, records) {
|
|
19531
|
+
if (records === void 0) return;
|
|
19532
|
+
if (Object.keys(records).length === 0) delete target[key];
|
|
19533
|
+
else target[key] = records;
|
|
19534
|
+
}
|
|
18771
19535
|
function mutationAffects(reads, previous4, next) {
|
|
18772
19536
|
if (!reads || reads.length === 0) return true;
|
|
18773
19537
|
return reads.some((capId) => JSON.stringify(previous4[capId]) !== JSON.stringify(next[capId]));
|
|
@@ -18823,12 +19587,17 @@ function foldLogicResult(capabilities, deletes, contextBefore, defaults) {
|
|
|
18823
19587
|
const merged = mergeCapabilityFields(capabilities, contextBefore, defaults);
|
|
18824
19588
|
return deletes.length === 0 ? merged : applyContextUpdate(merged, {}, deletes);
|
|
18825
19589
|
}
|
|
18826
|
-
function aggregateArgs(contexts, identities, declaration, store, sharedIds, participants) {
|
|
19590
|
+
function aggregateArgs(contexts, identities, declaration, store, sharedIds, participants, writesBenchmarks = false, writesAssessments = false) {
|
|
18827
19591
|
const shared = projectForLogic(store, declaration);
|
|
18828
19592
|
return {
|
|
18829
19593
|
shared: {
|
|
18830
19594
|
context: structuredClone(shared),
|
|
18831
|
-
state: structuredClone(store[SHARED_ENGINE_STATE_KEY])
|
|
19595
|
+
state: structuredClone(store[SHARED_ENGINE_STATE_KEY]),
|
|
19596
|
+
...writesBenchmarks ? {
|
|
19597
|
+
benchmarks: structuredClone(
|
|
19598
|
+
store[SHARED_BENCHMARKS_KEY] ?? {}
|
|
19599
|
+
)
|
|
19600
|
+
} : {}
|
|
18832
19601
|
},
|
|
18833
19602
|
teams: contexts.map((context, i) => ({
|
|
18834
19603
|
teamId: identities[i].teamId,
|
|
@@ -18838,12 +19607,22 @@ function aggregateArgs(contexts, identities, declaration, store, sharedIds, part
|
|
|
18838
19607
|
([capId]) => !sharedIds.has(capId)
|
|
18839
19608
|
)
|
|
18840
19609
|
),
|
|
18841
|
-
state: structuredClone(context[ENGINE_STATE_KEY])
|
|
19610
|
+
state: structuredClone(context[ENGINE_STATE_KEY]),
|
|
19611
|
+
...writesBenchmarks ? {
|
|
19612
|
+
benchmarks: structuredClone(
|
|
19613
|
+
context[BENCHMARKS_KEY] ?? {}
|
|
19614
|
+
)
|
|
19615
|
+
} : {},
|
|
19616
|
+
...writesAssessments ? {
|
|
19617
|
+
assessments: structuredClone(
|
|
19618
|
+
context[ASSESSMENTS_KEY] ?? {}
|
|
19619
|
+
)
|
|
19620
|
+
} : {}
|
|
18842
19621
|
})),
|
|
18843
19622
|
participants
|
|
18844
19623
|
};
|
|
18845
19624
|
}
|
|
18846
|
-
function applyEngineResult(label4, result, contextBefore, scope) {
|
|
19625
|
+
function applyEngineResult(label4, result, contextBefore, scope, teamId) {
|
|
18847
19626
|
assertDeletesDeclared(label4, result.deletes, scope.engine, new Set(scope.sharedIds), "team");
|
|
18848
19627
|
const merged = foldLogicResult(
|
|
18849
19628
|
result.capabilities,
|
|
@@ -18855,9 +19634,25 @@ function applyEngineResult(label4, result, contextBefore, scope) {
|
|
|
18855
19634
|
assertJsonSerialisable(label4, result.state);
|
|
18856
19635
|
merged[ENGINE_STATE_KEY] = structuredClone(result.state);
|
|
18857
19636
|
}
|
|
19637
|
+
storeRecords(
|
|
19638
|
+
merged,
|
|
19639
|
+
BENCHMARKS_KEY,
|
|
19640
|
+
foldBenchmarkWrites(label4, result.benchmarks, contextBefore[BENCHMARKS_KEY], "team", scope)
|
|
19641
|
+
);
|
|
19642
|
+
storeRecords(
|
|
19643
|
+
merged,
|
|
19644
|
+
ASSESSMENTS_KEY,
|
|
19645
|
+
foldAssessmentWrites(
|
|
19646
|
+
label4,
|
|
19647
|
+
result.assessments,
|
|
19648
|
+
contextBefore[ASSESSMENTS_KEY],
|
|
19649
|
+
teamId === void 0 ? /* @__PURE__ */ new Set() : scope.participantIdsOf?.(teamId) ?? /* @__PURE__ */ new Set(),
|
|
19650
|
+
scope
|
|
19651
|
+
)
|
|
19652
|
+
);
|
|
18858
19653
|
return merged;
|
|
18859
19654
|
}
|
|
18860
|
-
function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, scope, store) {
|
|
19655
|
+
function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, scope, store, teamIds = []) {
|
|
18861
19656
|
const label4 = `Engine "${engineIdentifier}" ${phase}`;
|
|
18862
19657
|
const result = {
|
|
18863
19658
|
shared: read.shared.capabilities,
|
|
@@ -18887,7 +19682,13 @@ function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, sco
|
|
|
18887
19682
|
"shared"
|
|
18888
19683
|
);
|
|
18889
19684
|
const contexts = read.teams.map((team, i) => {
|
|
18890
|
-
const context = applyEngineResult(
|
|
19685
|
+
const context = applyEngineResult(
|
|
19686
|
+
`${label4} "teams[${i}]"`,
|
|
19687
|
+
team,
|
|
19688
|
+
contextsBefore[i],
|
|
19689
|
+
scope,
|
|
19690
|
+
teamIds[i]
|
|
19691
|
+
);
|
|
18891
19692
|
enforceDeclaredWrites(
|
|
18892
19693
|
engineIdentifier,
|
|
18893
19694
|
scope.engine,
|
|
@@ -18897,11 +19698,27 @@ function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, sco
|
|
|
18897
19698
|
);
|
|
18898
19699
|
return context;
|
|
18899
19700
|
});
|
|
19701
|
+
if (read.shared.assessments !== void 0) {
|
|
19702
|
+
scope.warn(
|
|
19703
|
+
`${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.`
|
|
19704
|
+
);
|
|
19705
|
+
}
|
|
18900
19706
|
let next = { ...store };
|
|
18901
19707
|
if (read.shared.state !== void 0) {
|
|
18902
19708
|
assertJsonSerialisable(`${label4} "shared"`, read.shared.state);
|
|
18903
19709
|
next[SHARED_ENGINE_STATE_KEY] = structuredClone(read.shared.state);
|
|
18904
19710
|
}
|
|
19711
|
+
storeRecords(
|
|
19712
|
+
next,
|
|
19713
|
+
SHARED_BENCHMARKS_KEY,
|
|
19714
|
+
foldBenchmarkWrites(
|
|
19715
|
+
`${label4} "shared"`,
|
|
19716
|
+
read.shared.benchmarks,
|
|
19717
|
+
store[SHARED_BENCHMARKS_KEY],
|
|
19718
|
+
"session",
|
|
19719
|
+
scope
|
|
19720
|
+
)
|
|
19721
|
+
);
|
|
18905
19722
|
for (const [capId, sliceValue] of Object.entries(result.shared)) {
|
|
18906
19723
|
const base = next[capId];
|
|
18907
19724
|
const value = sliceValue && typeof sliceValue === "object" && !Array.isArray(sliceValue) && base && typeof base === "object" && !Array.isArray(base) ? {
|
|
@@ -18925,6 +19742,11 @@ function applyAggregateResult(read, contextsBefore, engineIdentifier, phase, sco
|
|
|
18925
19742
|
context[capId] = structuredClone(store[capId]);
|
|
18926
19743
|
}
|
|
18927
19744
|
}
|
|
19745
|
+
if (SHARED_BENCHMARKS_KEY in store) {
|
|
19746
|
+
context[SHARED_BENCHMARKS_KEY] = structuredClone(store[SHARED_BENCHMARKS_KEY]);
|
|
19747
|
+
} else {
|
|
19748
|
+
delete context[SHARED_BENCHMARKS_KEY];
|
|
19749
|
+
}
|
|
18928
19750
|
}
|
|
18929
19751
|
return { contexts, store };
|
|
18930
19752
|
}
|
|
@@ -20584,6 +21406,7 @@ var GameExecutor = class {
|
|
|
20584
21406
|
* contexts it was handed (§11). Read by the session straight after a tick.
|
|
20585
21407
|
*/
|
|
20586
21408
|
lastTickCompletion = [];
|
|
21409
|
+
warnings = [];
|
|
20587
21410
|
waitingRoomOpen = false;
|
|
20588
21411
|
deps;
|
|
20589
21412
|
/** `meta`, the roster, callbacks and bounds: what every logic call shares. */
|
|
@@ -20746,24 +21569,74 @@ var GameExecutor = class {
|
|
|
20746
21569
|
}
|
|
20747
21570
|
/** How a result folds into a board, for the game as it is loaded now. */
|
|
20748
21571
|
composition() {
|
|
21572
|
+
const declared = new Set(this.engine?.definition.benchmarks ?? []);
|
|
21573
|
+
const assessed = new Set(this.engine?.definition.assessments ?? []);
|
|
20749
21574
|
return {
|
|
20750
21575
|
defaults: this.capabilityDefaults,
|
|
20751
21576
|
sharedIds: new Set(this.getSharedCapabilityIds()),
|
|
20752
|
-
engine: this.engine?.definition ?? {}
|
|
21577
|
+
engine: this.engine?.definition ?? {},
|
|
21578
|
+
benchmarks: new Map(
|
|
21579
|
+
(this.config?.benchmarks ?? []).filter((benchmark) => declared.has(benchmark.definition.identifier)).map((benchmark) => [benchmark.definition.identifier, benchmark.definition])
|
|
21580
|
+
),
|
|
21581
|
+
warn: (message) => {
|
|
21582
|
+
logger.warn(message);
|
|
21583
|
+
this.warnings.push(message);
|
|
21584
|
+
},
|
|
21585
|
+
assessments: new Map(
|
|
21586
|
+
(this.config?.assessments ?? []).filter((assessment) => assessed.has(assessment.definition.identifier)).map((assessment) => [assessment.definition.identifier, assessment.definition])
|
|
21587
|
+
),
|
|
21588
|
+
participantIdsOf: (teamId) => new Set(this.calls.participantsOn([teamId]).map((participant) => participant.id))
|
|
21589
|
+
};
|
|
21590
|
+
}
|
|
21591
|
+
/** Whether the engine declares assessments, and so is handed and may return them (§6.17). */
|
|
21592
|
+
writesAssessments() {
|
|
21593
|
+
return (this.engine?.definition.assessments?.length ?? 0) > 0;
|
|
21594
|
+
}
|
|
21595
|
+
/** Whether the engine declares benchmarks, and so is handed and may return them (§6.16). */
|
|
21596
|
+
writesBenchmarks() {
|
|
21597
|
+
return (this.engine?.definition.benchmarks?.length ?? 0) > 0;
|
|
21598
|
+
}
|
|
21599
|
+
/**
|
|
21600
|
+
* The `benchmarks` and `assessments` arguments of an `Init` or `Run` on
|
|
21601
|
+
* `context`: its team's records and results, each passed only to an engine
|
|
21602
|
+
* that declares some.
|
|
21603
|
+
*/
|
|
21604
|
+
recordArgs(context) {
|
|
21605
|
+
return {
|
|
21606
|
+
...this.writesBenchmarks() ? {
|
|
21607
|
+
benchmarks: structuredClone(
|
|
21608
|
+
context[BENCHMARKS_KEY] ?? {}
|
|
21609
|
+
)
|
|
21610
|
+
} : {},
|
|
21611
|
+
...this.writesAssessments() ? {
|
|
21612
|
+
assessments: structuredClone(
|
|
21613
|
+
context[ASSESSMENTS_KEY] ?? {}
|
|
21614
|
+
)
|
|
21615
|
+
} : {}
|
|
20753
21616
|
};
|
|
20754
21617
|
}
|
|
21618
|
+
/**
|
|
21619
|
+
* What went wrong without failing anything since the last call, such as a
|
|
21620
|
+
* benchmark write that was dropped (§6.16), for the operation to report.
|
|
21621
|
+
*/
|
|
21622
|
+
takeWarnings() {
|
|
21623
|
+
const warnings = this.warnings;
|
|
21624
|
+
this.warnings = [];
|
|
21625
|
+
return warnings;
|
|
21626
|
+
}
|
|
20755
21627
|
/**
|
|
20756
21628
|
* Fold an aggregate result into the team contexts and the canonical store.
|
|
20757
21629
|
* See {@link applyAggregateResult}.
|
|
20758
21630
|
*/
|
|
20759
|
-
applyAggregateResult(read, contextsBefore, engineIdentifier, phase) {
|
|
21631
|
+
applyAggregateResult(read, contextsBefore, engineIdentifier, phase, teamIds) {
|
|
20760
21632
|
const { contexts, store } = applyAggregateResult(
|
|
20761
21633
|
read,
|
|
20762
21634
|
contextsBefore,
|
|
20763
21635
|
engineIdentifier,
|
|
20764
21636
|
phase,
|
|
20765
21637
|
this.composition(),
|
|
20766
|
-
this.sharedContext
|
|
21638
|
+
this.sharedContext,
|
|
21639
|
+
teamIds
|
|
20767
21640
|
);
|
|
20768
21641
|
this.sharedContext = store;
|
|
20769
21642
|
return contexts;
|
|
@@ -20776,7 +21649,9 @@ var GameExecutor = class {
|
|
|
20776
21649
|
declaration,
|
|
20777
21650
|
this.sharedContext,
|
|
20778
21651
|
new Set(this.getSharedCapabilityIds()),
|
|
20779
|
-
this.calls.participantsOn(identities.map((identity) => identity.teamId))
|
|
21652
|
+
this.calls.participantsOn(identities.map((identity) => identity.teamId)),
|
|
21653
|
+
this.writesBenchmarks(),
|
|
21654
|
+
this.writesAssessments()
|
|
20780
21655
|
);
|
|
20781
21656
|
}
|
|
20782
21657
|
/**
|
|
@@ -20959,6 +21834,7 @@ var GameExecutor = class {
|
|
|
20959
21834
|
() => run({
|
|
20960
21835
|
context: projectForLogic(contexts[i], engine.definition),
|
|
20961
21836
|
state: contexts[i][ENGINE_STATE_KEY],
|
|
21837
|
+
...this.recordArgs(contexts[i]),
|
|
20962
21838
|
settings: engineSettings,
|
|
20963
21839
|
meta: teamMeta[i],
|
|
20964
21840
|
participants: this.calls.participantsOn([
|
|
@@ -20973,10 +21849,18 @@ var GameExecutor = class {
|
|
|
20973
21849
|
team: identities[i]
|
|
20974
21850
|
}
|
|
20975
21851
|
),
|
|
20976
|
-
"tick"
|
|
21852
|
+
"tick",
|
|
21853
|
+
this.writesBenchmarks(),
|
|
21854
|
+
this.writesAssessments()
|
|
20977
21855
|
);
|
|
20978
21856
|
if (read.complete) completed[i] = true;
|
|
20979
|
-
contexts[i] = applyEngineResult(
|
|
21857
|
+
contexts[i] = applyEngineResult(
|
|
21858
|
+
label4,
|
|
21859
|
+
read,
|
|
21860
|
+
contextBefore,
|
|
21861
|
+
this.composition(),
|
|
21862
|
+
identities[i].teamId
|
|
21863
|
+
);
|
|
20980
21864
|
enforceDeclaredWrites(
|
|
20981
21865
|
engineIdentifier,
|
|
20982
21866
|
engine.definition,
|
|
@@ -21016,7 +21900,9 @@ var GameExecutor = class {
|
|
|
21016
21900
|
{ resource: { type: "engine", identifier: engineIdentifier }, tick: tick2 }
|
|
21017
21901
|
),
|
|
21018
21902
|
args.teams.length,
|
|
21019
|
-
"tick"
|
|
21903
|
+
"tick",
|
|
21904
|
+
this.writesBenchmarks(),
|
|
21905
|
+
this.writesAssessments()
|
|
21020
21906
|
);
|
|
21021
21907
|
result.teams.forEach((team, i) => {
|
|
21022
21908
|
if (team.complete || result.shared.complete) completed[i] = true;
|
|
@@ -21025,7 +21911,8 @@ var GameExecutor = class {
|
|
|
21025
21911
|
result,
|
|
21026
21912
|
contextsBefore,
|
|
21027
21913
|
engineIdentifier,
|
|
21028
|
-
"RunAggregate"
|
|
21914
|
+
"RunAggregate",
|
|
21915
|
+
identities.map((identity) => identity.teamId)
|
|
21029
21916
|
);
|
|
21030
21917
|
}
|
|
21031
21918
|
}
|
|
@@ -21104,13 +21991,17 @@ var GameExecutor = class {
|
|
|
21104
21991
|
}),
|
|
21105
21992
|
{ resource: { type: "engine", identifier: engineIdentifier } }
|
|
21106
21993
|
),
|
|
21107
|
-
args.teams.length
|
|
21994
|
+
args.teams.length,
|
|
21995
|
+
"init",
|
|
21996
|
+
this.writesBenchmarks(),
|
|
21997
|
+
this.writesAssessments()
|
|
21108
21998
|
);
|
|
21109
21999
|
contexts = this.applyAggregateResult(
|
|
21110
22000
|
result,
|
|
21111
22001
|
contextsBefore,
|
|
21112
22002
|
engineIdentifier,
|
|
21113
|
-
"InitAggregate"
|
|
22003
|
+
"InitAggregate",
|
|
22004
|
+
identities.map((identity) => identity.teamId)
|
|
21114
22005
|
);
|
|
21115
22006
|
}
|
|
21116
22007
|
this.context = { ...contexts[0] };
|
|
@@ -21146,6 +22037,7 @@ var GameExecutor = class {
|
|
|
21146
22037
|
() => initFn({
|
|
21147
22038
|
context: projectForLogic(before, engine.definition),
|
|
21148
22039
|
state: void 0,
|
|
22040
|
+
...this.recordArgs(before),
|
|
21149
22041
|
settings,
|
|
21150
22042
|
meta: { ...sessionMeta, ...identity },
|
|
21151
22043
|
participants: this.calls.participantsOn([identity.teamId]),
|
|
@@ -21155,9 +22047,18 @@ var GameExecutor = class {
|
|
|
21155
22047
|
resource: { type: "engine", identifier: engine.definition.identifier },
|
|
21156
22048
|
team: identity
|
|
21157
22049
|
}
|
|
21158
|
-
)
|
|
22050
|
+
),
|
|
22051
|
+
"init",
|
|
22052
|
+
this.writesBenchmarks(),
|
|
22053
|
+
this.writesAssessments()
|
|
22054
|
+
);
|
|
22055
|
+
const context = applyEngineResult(
|
|
22056
|
+
label4,
|
|
22057
|
+
after,
|
|
22058
|
+
before,
|
|
22059
|
+
this.composition(),
|
|
22060
|
+
identity.teamId
|
|
21159
22061
|
);
|
|
21160
|
-
const context = applyEngineResult(label4, after, before, this.composition());
|
|
21161
22062
|
enforceDeclaredWrites(
|
|
21162
22063
|
engine.definition.identifier,
|
|
21163
22064
|
engine.definition,
|
|
@@ -21196,7 +22097,11 @@ var GameExecutor = class {
|
|
|
21196
22097
|
*/
|
|
21197
22098
|
setContext(context) {
|
|
21198
22099
|
this.context = { ...context };
|
|
21199
|
-
for (const capId of [
|
|
22100
|
+
for (const capId of [
|
|
22101
|
+
...this.getSharedCapabilityIds(),
|
|
22102
|
+
SHARED_ENGINE_STATE_KEY,
|
|
22103
|
+
SHARED_BENCHMARKS_KEY
|
|
22104
|
+
]) {
|
|
21200
22105
|
if (capId in context) {
|
|
21201
22106
|
this.sharedContext[capId] = structuredClone(context[capId]);
|
|
21202
22107
|
}
|
|
@@ -21402,6 +22307,7 @@ var GameExecutor = class {
|
|
|
21402
22307
|
() => initFn({
|
|
21403
22308
|
context: projectForLogic(this.context, engine.definition),
|
|
21404
22309
|
state: void 0,
|
|
22310
|
+
...this.recordArgs(this.context),
|
|
21405
22311
|
settings: engineSettings,
|
|
21406
22312
|
meta: teamMeta,
|
|
21407
22313
|
participants: this.calls.participantsOn([teamMeta.teamId]),
|
|
@@ -21411,13 +22317,17 @@ var GameExecutor = class {
|
|
|
21411
22317
|
resource: { type: "engine", identifier: engineIdentifier },
|
|
21412
22318
|
team: { teamId: teamMeta.teamId, index: teamMeta.index }
|
|
21413
22319
|
}
|
|
21414
|
-
)
|
|
22320
|
+
),
|
|
22321
|
+
"init",
|
|
22322
|
+
this.writesBenchmarks(),
|
|
22323
|
+
this.writesAssessments()
|
|
21415
22324
|
);
|
|
21416
22325
|
this.context = applyEngineResult(
|
|
21417
22326
|
initLabel,
|
|
21418
22327
|
initResult,
|
|
21419
22328
|
contextBefore,
|
|
21420
|
-
this.composition()
|
|
22329
|
+
this.composition(),
|
|
22330
|
+
teamMeta.teamId
|
|
21421
22331
|
);
|
|
21422
22332
|
enforceDeclaredWrites(
|
|
21423
22333
|
engineIdentifier,
|
|
@@ -21460,13 +22370,17 @@ var GameExecutor = class {
|
|
|
21460
22370
|
}),
|
|
21461
22371
|
{ resource: { type: "engine", identifier: engineIdentifier } }
|
|
21462
22372
|
),
|
|
21463
|
-
1
|
|
22373
|
+
1,
|
|
22374
|
+
"init",
|
|
22375
|
+
this.writesBenchmarks(),
|
|
22376
|
+
this.writesAssessments()
|
|
21464
22377
|
);
|
|
21465
22378
|
[this.context] = this.applyAggregateResult(
|
|
21466
22379
|
result,
|
|
21467
22380
|
[aggregateContextBefore],
|
|
21468
22381
|
engineIdentifier,
|
|
21469
|
-
"InitAggregate"
|
|
22382
|
+
"InitAggregate",
|
|
22383
|
+
["team-1"]
|
|
21470
22384
|
);
|
|
21471
22385
|
}
|
|
21472
22386
|
}
|
|
@@ -23274,8 +24188,8 @@ function remarkGuideSettings(options) {
|
|
|
23274
24188
|
if (!parent || typeof index3 !== "number") return;
|
|
23275
24189
|
const directive2 = node2;
|
|
23276
24190
|
if (directive2.type === "containerDirective" && directive2.name === "when") {
|
|
23277
|
-
const
|
|
23278
|
-
const replacement = "error" in
|
|
24191
|
+
const outcome3 = evaluateWhen(options.settings, directive2.attributes ?? {});
|
|
24192
|
+
const replacement = "error" in outcome3 ? [errorBlock(outcome3.error)] : outcome3.show ? directive2.children : [];
|
|
23279
24193
|
parent.children.splice(index3, 1, ...replacement);
|
|
23280
24194
|
return [SKIP, index3];
|
|
23281
24195
|
}
|
|
@@ -23388,6 +24302,137 @@ function readEffectiveGuide(guide, root2, resolved) {
|
|
|
23388
24302
|
return { identifier: guide.definition.identifier, locales, chapters, settings };
|
|
23389
24303
|
}
|
|
23390
24304
|
|
|
24305
|
+
// cli/core/assessment-reports.ts
|
|
24306
|
+
function assessmentAudience(query) {
|
|
24307
|
+
if (query.audience !== "own") return { kind: "all" };
|
|
24308
|
+
if (query.participantId !== void 0 && query.teamId !== void 0) {
|
|
24309
|
+
return { kind: "participant", teamId: query.teamId, participantId: query.participantId };
|
|
24310
|
+
}
|
|
24311
|
+
if (query.viewerRole === "observer" && query.teamId !== void 0) {
|
|
24312
|
+
return { kind: "team", teamId: query.teamId };
|
|
24313
|
+
}
|
|
24314
|
+
return null;
|
|
24315
|
+
}
|
|
24316
|
+
function answerAssessment(input) {
|
|
24317
|
+
const { query } = input;
|
|
24318
|
+
const assessment = input.assessments.find(
|
|
24319
|
+
(entry) => entry.definition.identifier === query.identifier
|
|
24320
|
+
);
|
|
24321
|
+
if (!assessment) {
|
|
24322
|
+
return {
|
|
24323
|
+
type: "assessmentFailure",
|
|
24324
|
+
error: `The package declares no assessment "${query.identifier}"`
|
|
24325
|
+
};
|
|
24326
|
+
}
|
|
24327
|
+
const audience = assessmentAudience(query);
|
|
24328
|
+
if (audience === null) {
|
|
24329
|
+
return {
|
|
24330
|
+
type: "assessmentFailure",
|
|
24331
|
+
error: "getAssessment from a player surface needs the participant or observer behind it"
|
|
24332
|
+
};
|
|
24333
|
+
}
|
|
24334
|
+
const settings = input.settings[ASSESSMENTS_SETTINGS];
|
|
24335
|
+
const report = buildAssessmentReport({
|
|
24336
|
+
definition: assessment.definition,
|
|
24337
|
+
bands: resolveAssessmentBands(assessment.definition, settings?.[query.identifier]),
|
|
24338
|
+
teams: input.teams.map((team) => ({
|
|
24339
|
+
teamId: team.teamId,
|
|
24340
|
+
records: team.context?.[ASSESSMENTS_KEY]?.[query.identifier],
|
|
24341
|
+
complete: team.complete
|
|
24342
|
+
})),
|
|
24343
|
+
participants: input.participants,
|
|
24344
|
+
audience
|
|
24345
|
+
});
|
|
24346
|
+
return { type: "assessment", report };
|
|
24347
|
+
}
|
|
24348
|
+
|
|
24349
|
+
// cli/core/benchmark-samples.ts
|
|
24350
|
+
import { readFile as readFile5, stat as stat3 } from "node:fs/promises";
|
|
24351
|
+
import { join as join8 } from "node:path";
|
|
24352
|
+
function benchmarkSamplePath(identifier) {
|
|
24353
|
+
return join8("benchmarks", identifier, "sample.json");
|
|
24354
|
+
}
|
|
24355
|
+
var NUMERIC_FIGURES = ["mean", "min", "max", "p10", "p25", "p50", "p75", "p90"];
|
|
24356
|
+
function isRecord4(value) {
|
|
24357
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24358
|
+
}
|
|
24359
|
+
function isCount(value) {
|
|
24360
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
24361
|
+
}
|
|
24362
|
+
function fieldProblem(name, value) {
|
|
24363
|
+
if (!isRecord4(value)) return `fields.${name} must be an object`;
|
|
24364
|
+
if (!isCount(value.count)) return `fields.${name}.count must be a whole number of at least 0`;
|
|
24365
|
+
if (value.kind === "number") {
|
|
24366
|
+
for (const figure of NUMERIC_FIGURES) {
|
|
24367
|
+
const v = value[figure];
|
|
24368
|
+
if (v !== void 0 && (typeof v !== "number" || !Number.isFinite(v))) {
|
|
24369
|
+
return `fields.${name}.${figure} must be a number`;
|
|
24370
|
+
}
|
|
24371
|
+
}
|
|
24372
|
+
return null;
|
|
24373
|
+
}
|
|
24374
|
+
if (value.kind === "choice") {
|
|
24375
|
+
if (!isRecord4(value.options)) return `fields.${name}.options must be an object`;
|
|
24376
|
+
for (const [option, count] of Object.entries(value.options)) {
|
|
24377
|
+
if (!isCount(count)) {
|
|
24378
|
+
return `fields.${name}.options.${option} must be a whole number of at least 0`;
|
|
24379
|
+
}
|
|
24380
|
+
}
|
|
24381
|
+
return null;
|
|
24382
|
+
}
|
|
24383
|
+
return `fields.${name}.kind must be "number" or "choice"`;
|
|
24384
|
+
}
|
|
24385
|
+
function benchmarkSampleProblem(sample) {
|
|
24386
|
+
if (!isRecord4(sample)) return "it must be an object";
|
|
24387
|
+
if (sample.scope !== "organisation" && sample.scope !== "global") {
|
|
24388
|
+
return 'scope must be "organisation" or "global"';
|
|
24389
|
+
}
|
|
24390
|
+
if (!isRecord4(sample.fields)) return "fields must be an object of field statistics";
|
|
24391
|
+
for (const [name, value] of Object.entries(sample.fields)) {
|
|
24392
|
+
const problem = fieldProblem(name, value);
|
|
24393
|
+
if (problem) return problem;
|
|
24394
|
+
}
|
|
24395
|
+
return null;
|
|
24396
|
+
}
|
|
24397
|
+
async function isDirectory(path3) {
|
|
24398
|
+
try {
|
|
24399
|
+
return (await stat3(path3)).isDirectory();
|
|
24400
|
+
} catch {
|
|
24401
|
+
return false;
|
|
24402
|
+
}
|
|
24403
|
+
}
|
|
24404
|
+
async function isDeclared(packagePath, identifier, declared) {
|
|
24405
|
+
if (!/^[A-Za-z0-9_-]+$/.test(identifier)) return false;
|
|
24406
|
+
if (declared && declared.length > 0) return declared.includes(identifier);
|
|
24407
|
+
return isDirectory(join8(packagePath, "benchmarks", identifier));
|
|
24408
|
+
}
|
|
24409
|
+
async function answerBenchmarkFromSample(options) {
|
|
24410
|
+
const { packagePath, identifier, where: where3, declared } = options;
|
|
24411
|
+
if (!await isDeclared(packagePath, identifier, declared)) {
|
|
24412
|
+
throw new Error(`No benchmark "${identifier}" is declared`);
|
|
24413
|
+
}
|
|
24414
|
+
const relative8 = benchmarkSamplePath(identifier);
|
|
24415
|
+
let text5;
|
|
24416
|
+
try {
|
|
24417
|
+
text5 = await readFile5(join8(packagePath, relative8), "utf-8");
|
|
24418
|
+
} catch (error) {
|
|
24419
|
+
if (error.code === "ENOENT") return null;
|
|
24420
|
+
throw error;
|
|
24421
|
+
}
|
|
24422
|
+
let sample;
|
|
24423
|
+
try {
|
|
24424
|
+
sample = JSON.parse(text5);
|
|
24425
|
+
} catch (error) {
|
|
24426
|
+
throw new Error(
|
|
24427
|
+
`${relative8} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
24428
|
+
);
|
|
24429
|
+
}
|
|
24430
|
+
const problem = benchmarkSampleProblem(sample);
|
|
24431
|
+
if (problem) throw new Error(`${relative8} is not a benchmark sample: ${problem}`);
|
|
24432
|
+
const { scope, fields } = sample;
|
|
24433
|
+
return { scope, matched: { ...where3[0] }, fields };
|
|
24434
|
+
}
|
|
24435
|
+
|
|
23391
24436
|
// cli/core/clock.ts
|
|
23392
24437
|
var systemClock = {
|
|
23393
24438
|
now: () => Date.now(),
|
|
@@ -23863,9 +24908,9 @@ function withLogicError(result, logicError) {
|
|
|
23863
24908
|
return logicError ? { ...result, logicError } : result;
|
|
23864
24909
|
}
|
|
23865
24910
|
var RefusedError = class extends Error {
|
|
23866
|
-
constructor(message,
|
|
24911
|
+
constructor(message, outcome3) {
|
|
23867
24912
|
super(message);
|
|
23868
|
-
this.outcome =
|
|
24913
|
+
this.outcome = outcome3;
|
|
23869
24914
|
}
|
|
23870
24915
|
outcome;
|
|
23871
24916
|
};
|
|
@@ -23883,12 +24928,12 @@ function withStale(result, error) {
|
|
|
23883
24928
|
function markIfLogic(error, failure) {
|
|
23884
24929
|
return failure ? markLogicFailure(error, failure) : error;
|
|
23885
24930
|
}
|
|
23886
|
-
function refuseIfArmed(faults, fault,
|
|
24931
|
+
function refuseIfArmed(faults, fault, outcome3) {
|
|
23887
24932
|
const fired = faults.fire(fault);
|
|
23888
24933
|
if (!fired) return;
|
|
23889
24934
|
throw new RefusedError(
|
|
23890
24935
|
`Injected ${fault}`,
|
|
23891
|
-
fired.reason === void 0 ?
|
|
24936
|
+
fired.reason === void 0 ? outcome3 : { ...outcome3, message: fired.reason }
|
|
23892
24937
|
);
|
|
23893
24938
|
}
|
|
23894
24939
|
|
|
@@ -24606,6 +25651,49 @@ function undoOneTeam(host, position2) {
|
|
|
24606
25651
|
return true;
|
|
24607
25652
|
}
|
|
24608
25653
|
|
|
25654
|
+
// cli/core/assessment-moves.ts
|
|
25655
|
+
function participantLevelAssessments(assessments) {
|
|
25656
|
+
return assessments.filter((entry) => entry.definition.level === "participant").map((entry) => entry.definition.identifier);
|
|
25657
|
+
}
|
|
25658
|
+
function recordsOf(context) {
|
|
25659
|
+
return context?.[ASSESSMENTS_KEY] ?? {};
|
|
25660
|
+
}
|
|
25661
|
+
function withRecords(context, records) {
|
|
25662
|
+
const next = { ...context };
|
|
25663
|
+
const kept = Object.fromEntries(
|
|
25664
|
+
Object.entries(records).filter(([, byId]) => Object.keys(byId ?? {}).length > 0)
|
|
25665
|
+
);
|
|
25666
|
+
if (Object.keys(kept).length > 0) next[ASSESSMENTS_KEY] = kept;
|
|
25667
|
+
else delete next[ASSESSMENTS_KEY];
|
|
25668
|
+
return next;
|
|
25669
|
+
}
|
|
25670
|
+
function settleAssessmentRecords(input) {
|
|
25671
|
+
const { teamIds, teamOf: teamOf2, identifiers, prefer } = input;
|
|
25672
|
+
const contexts = [...input.contexts];
|
|
25673
|
+
if (identifiers.length === 0) return contexts;
|
|
25674
|
+
const records = contexts.map((context) => structuredClone(recordsOf(context)));
|
|
25675
|
+
const positionOf = new Map(teamIds.map((teamId, position2) => [teamId, position2]));
|
|
25676
|
+
let moved = false;
|
|
25677
|
+
records.forEach((teamRecords, position2) => {
|
|
25678
|
+
for (const identifier of identifiers) {
|
|
25679
|
+
const byId = teamRecords[identifier];
|
|
25680
|
+
if (!byId) continue;
|
|
25681
|
+
for (const [participantId, record2] of Object.entries(byId)) {
|
|
25682
|
+
const destination = positionOf.get(teamOf2(participantId) ?? "");
|
|
25683
|
+
if (destination === void 0 || destination === position2) continue;
|
|
25684
|
+
delete byId[participantId];
|
|
25685
|
+
const target = records[destination][identifier] ??= {};
|
|
25686
|
+
if (participantId === prefer || !(participantId in target)) {
|
|
25687
|
+
target[participantId] = record2;
|
|
25688
|
+
}
|
|
25689
|
+
moved = true;
|
|
25690
|
+
}
|
|
25691
|
+
}
|
|
25692
|
+
});
|
|
25693
|
+
if (!moved) return input.contexts;
|
|
25694
|
+
return contexts.map((context, position2) => withRecords(context, records[position2]));
|
|
25695
|
+
}
|
|
25696
|
+
|
|
24609
25697
|
// cli/core/team-names.ts
|
|
24610
25698
|
function pickLocalised(entry, locale) {
|
|
24611
25699
|
if (!entry) return void 0;
|
|
@@ -24941,6 +26029,7 @@ var SessionRoster = class {
|
|
|
24941
26029
|
if (fromTeamId === toTeamId) return void 0;
|
|
24942
26030
|
const moved = this.host.participants.move(fromTeamId, participantId, toTeamId);
|
|
24943
26031
|
if (!moved) throw new DeniedError("The participant could not be moved");
|
|
26032
|
+
this.settleAssessments(participantId);
|
|
24944
26033
|
const move = { fromTeamId, toTeamId };
|
|
24945
26034
|
await this.fireHook("participantMove", moved, {
|
|
24946
26035
|
teamId: fromTeamId,
|
|
@@ -24949,6 +26038,25 @@ var SessionRoster = class {
|
|
|
24949
26038
|
await this.fireHook("participantMove", moved, { payload: { ...move, phase: "arrival" } });
|
|
24950
26039
|
return void 0;
|
|
24951
26040
|
}
|
|
26041
|
+
/**
|
|
26042
|
+
* Move participant-level assessment results to the team each participant
|
|
26043
|
+
* is on now (§6.17.2): after a move, with `prefer` the one who moved, and
|
|
26044
|
+
* after an undo, which restores results to the teams that held them then.
|
|
26045
|
+
*/
|
|
26046
|
+
settleAssessments(prefer) {
|
|
26047
|
+
const { executor, state: state2 } = this.host;
|
|
26048
|
+
const identifiers = participantLevelAssessments(executor.getConfig()?.assessments ?? []);
|
|
26049
|
+
if (identifiers.length === 0) return;
|
|
26050
|
+
const contexts = state2.getTeamContexts();
|
|
26051
|
+
const settled = settleAssessmentRecords({
|
|
26052
|
+
contexts,
|
|
26053
|
+
teamIds: state2.getTeamIndexes().map((index3) => `team-${index3 + 1}`),
|
|
26054
|
+
teamOf: (id) => this.findParticipantTeam(id),
|
|
26055
|
+
identifiers,
|
|
26056
|
+
prefer
|
|
26057
|
+
});
|
|
26058
|
+
if (settled !== contexts) state2.setTeamContexts(settled);
|
|
26059
|
+
}
|
|
24952
26060
|
findParticipantTeam(participantId) {
|
|
24953
26061
|
for (const index3 of this.host.state.getTeamIndexes()) {
|
|
24954
26062
|
const teamId = `team-${index3 + 1}`;
|
|
@@ -25010,7 +26118,7 @@ function insertAt(values, position2, value) {
|
|
|
25010
26118
|
|
|
25011
26119
|
// cli/execution/scenario-gates.ts
|
|
25012
26120
|
import { existsSync as existsSync8 } from "fs";
|
|
25013
|
-
import { readFile as
|
|
26121
|
+
import { readFile as readFile6 } from "fs/promises";
|
|
25014
26122
|
var SCENARIO_VALIDATION = "scenario-validation";
|
|
25015
26123
|
var SCENARIO_FILES = "scenario-files";
|
|
25016
26124
|
var SESSION_VALIDATION = "session-validation";
|
|
@@ -25043,7 +26151,7 @@ async function runScenarioGates(options) {
|
|
|
25043
26151
|
if (!hasScenarioGate(config)) return [];
|
|
25044
26152
|
const loader = options.loader ?? new LogicLoader(options.packagePath, {
|
|
25045
26153
|
transpile: Transpile,
|
|
25046
|
-
fs: { existsSync: existsSync8, readFile:
|
|
26154
|
+
fs: { existsSync: existsSync8, readFile: readFile6 }
|
|
25047
26155
|
});
|
|
25048
26156
|
const resolved = resolveSettingsLayers(
|
|
25049
26157
|
config,
|
|
@@ -25405,7 +26513,9 @@ var IDLE_TIMER = {
|
|
|
25405
26513
|
pausedAt: null,
|
|
25406
26514
|
pausedMs: 0,
|
|
25407
26515
|
extendedMs: 0,
|
|
25408
|
-
scheduleStartedAt: null
|
|
26516
|
+
scheduleStartedAt: null,
|
|
26517
|
+
dormant: false,
|
|
26518
|
+
dormantAt: null
|
|
25409
26519
|
};
|
|
25410
26520
|
function scheduleFor(result, now) {
|
|
25411
26521
|
const problem = validateTickControllerResult2(result, { now });
|
|
@@ -25451,6 +26561,8 @@ var TickTimer = class {
|
|
|
25451
26561
|
pausedMs = 0;
|
|
25452
26562
|
scheduleStartedAt = null;
|
|
25453
26563
|
extendedMs = 0;
|
|
26564
|
+
/** When the session went dormant (§11.4a), or null while it is not. */
|
|
26565
|
+
dormantAt = null;
|
|
25454
26566
|
/** The answer the current schedule was built from, to tell a re-evaluation that changed nothing. */
|
|
25455
26567
|
answer = null;
|
|
25456
26568
|
/**
|
|
@@ -25490,7 +26602,7 @@ var TickTimer = class {
|
|
|
25490
26602
|
this.intervalMs = schedule.intervalMs;
|
|
25491
26603
|
this.usedNextTickAt = schedule.usedNextTickAt;
|
|
25492
26604
|
this.scheduleStartedAt ??= now;
|
|
25493
|
-
if (this.paused) {
|
|
26605
|
+
if (this.paused || this.dormantAt !== null) {
|
|
25494
26606
|
this.remainingMs = schedule.delayMs;
|
|
25495
26607
|
return schedule.clamped;
|
|
25496
26608
|
}
|
|
@@ -25502,8 +26614,32 @@ var TickTimer = class {
|
|
|
25502
26614
|
const now = this.clock.now();
|
|
25503
26615
|
this.paused = true;
|
|
25504
26616
|
this.pausedAt = now;
|
|
25505
|
-
|
|
25506
|
-
|
|
26617
|
+
if (this.dormantAt === null) this.hold(now);
|
|
26618
|
+
}
|
|
26619
|
+
/**
|
|
26620
|
+
* Suspend automatic ticking because the session was left unattended
|
|
26621
|
+
* (§11.4a). Held like a pause, but separate from one: waking never ends a
|
|
26622
|
+
* facilitator's pause.
|
|
26623
|
+
*/
|
|
26624
|
+
suspend() {
|
|
26625
|
+
if (this.dormantAt !== null) return;
|
|
26626
|
+
const now = this.clock.now();
|
|
26627
|
+
this.dormantAt = now;
|
|
26628
|
+
if (!this.paused) this.hold(now);
|
|
26629
|
+
}
|
|
26630
|
+
/**
|
|
26631
|
+
* Wake from dormancy (§11.4a), resuming as from a pause (§11.4). The
|
|
26632
|
+
* dormant time joins `pausedMs`, except where a facilitator's pause
|
|
26633
|
+
* already covers it. A timer the facilitator paused stays paused.
|
|
26634
|
+
*/
|
|
26635
|
+
wake() {
|
|
26636
|
+
if (this.dormantAt === null) return "idle";
|
|
26637
|
+
const now = this.clock.now();
|
|
26638
|
+
const dormantAt = this.dormantAt;
|
|
26639
|
+
this.dormantAt = null;
|
|
26640
|
+
if (this.paused) return "idle";
|
|
26641
|
+
this.pausedMs += now - dormantAt;
|
|
26642
|
+
return this.continue(now);
|
|
25507
26643
|
}
|
|
25508
26644
|
/**
|
|
25509
26645
|
* Resume (§11.4). Interval mode continues from the time that was left;
|
|
@@ -25516,6 +26652,11 @@ var TickTimer = class {
|
|
|
25516
26652
|
this.paused = false;
|
|
25517
26653
|
if (this.pausedAt !== null) this.pausedMs += now - this.pausedAt;
|
|
25518
26654
|
this.pausedAt = null;
|
|
26655
|
+
if (this.dormantAt !== null) return "idle";
|
|
26656
|
+
return this.continue(now);
|
|
26657
|
+
}
|
|
26658
|
+
/** Pick a held schedule back up, after a pause or dormancy. */
|
|
26659
|
+
continue(now) {
|
|
25519
26660
|
if (!this.enabled) return "idle";
|
|
25520
26661
|
if (this.usedNextTickAt) {
|
|
25521
26662
|
this.remainingMs = null;
|
|
@@ -25535,6 +26676,9 @@ var TickTimer = class {
|
|
|
25535
26676
|
if (this.paused) {
|
|
25536
26677
|
return "The timer is paused, so there is no scheduled tick to move. Resume it first";
|
|
25537
26678
|
}
|
|
26679
|
+
if (this.dormantAt !== null) {
|
|
26680
|
+
return "The session is dormant, so there is no scheduled tick to move";
|
|
26681
|
+
}
|
|
25538
26682
|
if (this.dueAt === null) return "No tick is scheduled, so there is no deadline to move";
|
|
25539
26683
|
const now = this.clock.now();
|
|
25540
26684
|
const target = Math.max(now, this.dueAt + ms);
|
|
@@ -25553,17 +26697,25 @@ var TickTimer = class {
|
|
|
25553
26697
|
this.intervalMs = null;
|
|
25554
26698
|
}
|
|
25555
26699
|
state() {
|
|
26700
|
+
const held = this.paused || this.dormantAt !== null;
|
|
25556
26701
|
return {
|
|
25557
26702
|
enabled: this.enabled,
|
|
25558
26703
|
paused: this.paused,
|
|
25559
|
-
nextTickAt:
|
|
25560
|
-
intervalMs: this.enabled && !
|
|
26704
|
+
nextTickAt: held ? null : this.dueAt,
|
|
26705
|
+
intervalMs: this.enabled && !held ? this.intervalMs : null,
|
|
25561
26706
|
pausedAt: this.pausedAt,
|
|
25562
26707
|
pausedMs: this.pausedMs,
|
|
25563
26708
|
extendedMs: this.extendedMs,
|
|
25564
|
-
scheduleStartedAt: this.scheduleStartedAt
|
|
26709
|
+
scheduleStartedAt: this.scheduleStartedAt,
|
|
26710
|
+
dormant: this.dormantAt !== null,
|
|
26711
|
+
dormantAt: this.dormantAt
|
|
25565
26712
|
};
|
|
25566
26713
|
}
|
|
26714
|
+
/** Keep what is left of this window, and stop the pending tick. */
|
|
26715
|
+
hold(now) {
|
|
26716
|
+
this.remainingMs = this.dueAt === null ? null : Math.max(0, this.dueAt - now);
|
|
26717
|
+
this.cancelPending();
|
|
26718
|
+
}
|
|
25567
26719
|
arm(at) {
|
|
25568
26720
|
this.cancelPending();
|
|
25569
26721
|
this.dueAt = at;
|
|
@@ -25582,15 +26734,70 @@ var TickTimer = class {
|
|
|
25582
26734
|
|
|
25583
26735
|
// cli/core/session-timers.ts
|
|
25584
26736
|
var COHORT = -1;
|
|
26737
|
+
var DORMANT_AFTER_MS = 24 * 60 * 60 * 1e3;
|
|
26738
|
+
var DORMANT_AFTER_TICKS = 100;
|
|
25585
26739
|
var SessionTimers = class {
|
|
25586
26740
|
constructor(host) {
|
|
25587
26741
|
this.host = host;
|
|
26742
|
+
this.lastActivityAt = host.clock.now();
|
|
25588
26743
|
}
|
|
25589
26744
|
host;
|
|
25590
26745
|
/** True while a tick runs, so a timer firing then is dropped (§11.1). */
|
|
25591
26746
|
ticking = false;
|
|
25592
26747
|
/** Automatic tick timers, keyed by team index, or {@link COHORT} (§11). */
|
|
25593
26748
|
timers = /* @__PURE__ */ new Map();
|
|
26749
|
+
/** When the session went dormant (§11.4a), or null while it is not. */
|
|
26750
|
+
dormantAt = null;
|
|
26751
|
+
/** When anything outside the host last used the session (§11.4a). */
|
|
26752
|
+
lastActivityAt;
|
|
26753
|
+
/** Automatic ticks since then, every team's together (§11.4a). */
|
|
26754
|
+
unattendedTicks = 0;
|
|
26755
|
+
/** Surfaces and console pages open on the session, which keep it awake. */
|
|
26756
|
+
openSurfaces = 0;
|
|
26757
|
+
/** Whether automatic ticking is suspended because the session was unattended. */
|
|
26758
|
+
get dormant() {
|
|
26759
|
+
return this.dormantAt !== null;
|
|
26760
|
+
}
|
|
26761
|
+
/**
|
|
26762
|
+
* Something outside the host used the session (§11.4a): restart the
|
|
26763
|
+
* clock, and wake the session if it is dormant. Interval-mode timers pick
|
|
26764
|
+
* up at once; what is returned re-asks the controller for scheduled-mode
|
|
26765
|
+
* ones, for the caller to queue ahead of the activity itself. Null when
|
|
26766
|
+
* nothing woke.
|
|
26767
|
+
*/
|
|
26768
|
+
noteActivity() {
|
|
26769
|
+
this.lastActivityAt = this.host.clock.now();
|
|
26770
|
+
this.unattendedTicks = 0;
|
|
26771
|
+
if (this.dormantAt === null) return null;
|
|
26772
|
+
this.dormantAt = null;
|
|
26773
|
+
const reevaluate = this.groups().filter(
|
|
26774
|
+
(group) => this.timers.get(group.key)?.wake() === "re-evaluate"
|
|
26775
|
+
);
|
|
26776
|
+
return async () => {
|
|
26777
|
+
for (const group of reevaluate) await this.evaluate(group);
|
|
26778
|
+
};
|
|
26779
|
+
}
|
|
26780
|
+
/**
|
|
26781
|
+
* How many surfaces are open on the session. Opening one is activity, and
|
|
26782
|
+
* while any is open the session stays awake: the dev server counts an
|
|
26783
|
+
* idle open surface as use, which the specification leaves to the host.
|
|
26784
|
+
*/
|
|
26785
|
+
surfacesOpen(count) {
|
|
26786
|
+
const opened = count > this.openSurfaces;
|
|
26787
|
+
const lastClosed = count === 0 && this.openSurfaces > 0;
|
|
26788
|
+
this.openSurfaces = count;
|
|
26789
|
+
return opened || lastClosed ? this.noteActivity() : null;
|
|
26790
|
+
}
|
|
26791
|
+
/**
|
|
26792
|
+
* Suspend automatic ticking now (§11.4a), whether or not the minimums
|
|
26793
|
+
* have passed: the dev server's way to show an author a dormant session
|
|
26794
|
+
* without waiting a day.
|
|
26795
|
+
*/
|
|
26796
|
+
suspend() {
|
|
26797
|
+
if (this.dormantAt !== null) return;
|
|
26798
|
+
this.dormantAt = this.host.clock.now();
|
|
26799
|
+
for (const timer of this.timers.values()) timer.suspend();
|
|
26800
|
+
}
|
|
25594
26801
|
/** Cancel every timer, for a session that is stopping. */
|
|
25595
26802
|
stop() {
|
|
25596
26803
|
for (const timer of this.timers.values()) timer.cancel();
|
|
@@ -25715,6 +26922,7 @@ var SessionTimers = class {
|
|
|
25715
26922
|
let timer = this.timers.get(key);
|
|
25716
26923
|
if (!timer) {
|
|
25717
26924
|
timer = new TickTimer(this.host.clock, () => void this.onFired(key));
|
|
26925
|
+
if (this.dormantAt !== null) timer.suspend();
|
|
25718
26926
|
this.timers.set(key, timer);
|
|
25719
26927
|
}
|
|
25720
26928
|
return timer;
|
|
@@ -25815,18 +27023,191 @@ var SessionTimers = class {
|
|
|
25815
27023
|
type: "tick",
|
|
25816
27024
|
...key === COHORT ? {} : { teamIndex: key }
|
|
25817
27025
|
});
|
|
25818
|
-
if (result.ok)
|
|
27026
|
+
if (result.ok) {
|
|
27027
|
+
this.unattendedTicks += 1;
|
|
27028
|
+
this.suspendIfUnattended();
|
|
27029
|
+
return;
|
|
27030
|
+
}
|
|
25819
27031
|
await this.host.enqueue(async () => {
|
|
25820
27032
|
const group = this.groups().find((candidate) => candidate.key === key);
|
|
25821
27033
|
if (group) await this.evaluate(group);
|
|
25822
27034
|
this.host.emitState("timer");
|
|
25823
27035
|
});
|
|
25824
27036
|
}
|
|
27037
|
+
/**
|
|
27038
|
+
* Go dormant once nothing has used the session for both minimums, and no
|
|
27039
|
+
* surface is open (§11.4a). Judged after an automatic tick, since nothing
|
|
27040
|
+
* else happens to a session nobody is using.
|
|
27041
|
+
*/
|
|
27042
|
+
suspendIfUnattended() {
|
|
27043
|
+
if (this.dormantAt !== null || this.openSurfaces > 0) return;
|
|
27044
|
+
if (this.unattendedTicks < DORMANT_AFTER_TICKS) return;
|
|
27045
|
+
if (this.host.clock.now() - this.lastActivityAt < DORMANT_AFTER_MS) return;
|
|
27046
|
+
this.suspend();
|
|
27047
|
+
this.host.emitState("dormant");
|
|
27048
|
+
}
|
|
25825
27049
|
};
|
|
25826
27050
|
|
|
25827
27051
|
// cli/core/session-writes.ts
|
|
25828
27052
|
import { isDeepStrictEqual as isDeepStrictEqual3 } from "util";
|
|
25829
27053
|
|
|
27054
|
+
// cli/validation/assessment-validation.ts
|
|
27055
|
+
var MAX_BANDS = 10;
|
|
27056
|
+
function outcome() {
|
|
27057
|
+
return { errors: [], warnings: [], findings: [] };
|
|
27058
|
+
}
|
|
27059
|
+
function addError(result, finding) {
|
|
27060
|
+
result.errors.push(finding.hint ? `${finding.message}. ${finding.hint}` : finding.message);
|
|
27061
|
+
result.findings.push({ severity: "error", ...finding });
|
|
27062
|
+
}
|
|
27063
|
+
function bandsProblem(definition3, bands) {
|
|
27064
|
+
if (bands.length === 0) return null;
|
|
27065
|
+
if (bands[0].from !== definition3.min) {
|
|
27066
|
+
return `the first band, "${bands[0].id}", starts at ${bands[0].from} rather than at the minimum score, ${definition3.min}`;
|
|
27067
|
+
}
|
|
27068
|
+
for (let i = 1; i < bands.length; i++) {
|
|
27069
|
+
if (bands[i].from <= bands[i - 1].from) {
|
|
27070
|
+
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`;
|
|
27071
|
+
}
|
|
27072
|
+
}
|
|
27073
|
+
const last = bands[bands.length - 1];
|
|
27074
|
+
if (last.from > definition3.max) {
|
|
27075
|
+
return `band "${last.id}" starts at ${last.from}, above the maximum score, ${definition3.max}`;
|
|
27076
|
+
}
|
|
27077
|
+
return null;
|
|
27078
|
+
}
|
|
27079
|
+
function resolvedBandProblems(assessments, resolved) {
|
|
27080
|
+
const settings = resolved[ASSESSMENTS_SETTINGS];
|
|
27081
|
+
const problems = [];
|
|
27082
|
+
for (const { definition: definition3 } of assessments) {
|
|
27083
|
+
const problem = bandsProblem(
|
|
27084
|
+
definition3,
|
|
27085
|
+
resolveAssessmentBands(definition3, settings?.[definition3.identifier])
|
|
27086
|
+
);
|
|
27087
|
+
if (problem !== null) {
|
|
27088
|
+
problems.push(
|
|
27089
|
+
`The bands of assessment "${definition3.identifier}" would be out of order: ${problem}`
|
|
27090
|
+
);
|
|
27091
|
+
}
|
|
27092
|
+
}
|
|
27093
|
+
return problems;
|
|
27094
|
+
}
|
|
27095
|
+
function validateAssessment(assessment, config) {
|
|
27096
|
+
const result = outcome();
|
|
27097
|
+
const { definition: definition3 } = assessment;
|
|
27098
|
+
const { identifier } = definition3;
|
|
27099
|
+
const file = bundleFileOf("assessment", identifier);
|
|
27100
|
+
const resource = { type: "assessment", identifier };
|
|
27101
|
+
if (!(config.requires ?? []).includes(ASSESSMENTS_FEATURE)) {
|
|
27102
|
+
addError(result, {
|
|
27103
|
+
code: "FEATURE_UNDECLARED",
|
|
27104
|
+
message: `Assessment "${identifier}" needs the \`${ASSESSMENTS_FEATURE}\` feature, but \`requires\` does not list it`,
|
|
27105
|
+
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`,
|
|
27106
|
+
file: MANIFEST_FILE,
|
|
27107
|
+
pointer: pointerOf("requires"),
|
|
27108
|
+
resource
|
|
27109
|
+
});
|
|
27110
|
+
}
|
|
27111
|
+
if (!(definition3.max > definition3.min)) {
|
|
27112
|
+
addError(result, {
|
|
27113
|
+
code: "PACKAGE_INVALID",
|
|
27114
|
+
message: `Assessment "${identifier}" has a maximum score of ${definition3.max}, which is not above its minimum, ${definition3.min}`,
|
|
27115
|
+
hint: 'Set "max" above "min"',
|
|
27116
|
+
file,
|
|
27117
|
+
pointer: pointerOf("definition", "max"),
|
|
27118
|
+
resource
|
|
27119
|
+
});
|
|
27120
|
+
return result;
|
|
27121
|
+
}
|
|
27122
|
+
if ((definition3.bands?.length ?? 0) > MAX_BANDS) {
|
|
27123
|
+
addError(result, {
|
|
27124
|
+
code: "PACKAGE_INVALID",
|
|
27125
|
+
message: `Assessment "${identifier}" declares ${definition3.bands?.length} bands, more than the ${MAX_BANDS} an assessment may have`,
|
|
27126
|
+
hint: "Merge neighbouring bands",
|
|
27127
|
+
file,
|
|
27128
|
+
pointer: pointerOf("definition", "bands"),
|
|
27129
|
+
resource
|
|
27130
|
+
});
|
|
27131
|
+
}
|
|
27132
|
+
const ids = (definition3.bands ?? []).map((band) => band.id);
|
|
27133
|
+
const duplicate = ids.find((id, index3) => ids.indexOf(id) !== index3);
|
|
27134
|
+
if (duplicate !== void 0) {
|
|
27135
|
+
addError(result, {
|
|
27136
|
+
code: "PACKAGE_INVALID",
|
|
27137
|
+
message: `Assessment "${identifier}" declares band "${duplicate}" more than once`,
|
|
27138
|
+
hint: "Give each band its own id",
|
|
27139
|
+
file,
|
|
27140
|
+
pointer: pointerOf("definition", "bands"),
|
|
27141
|
+
resource
|
|
27142
|
+
});
|
|
27143
|
+
}
|
|
27144
|
+
const declaredProblem = bandsProblem(definition3, resolveAssessmentBands(definition3));
|
|
27145
|
+
if (declaredProblem !== null) {
|
|
27146
|
+
addError(result, {
|
|
27147
|
+
code: "PACKAGE_INVALID",
|
|
27148
|
+
message: `Assessment "${identifier}": ${declaredProblem}`,
|
|
27149
|
+
hint: 'List the bands lowest first, the first starting at "min", each "from" above the last and no higher than "max"',
|
|
27150
|
+
file,
|
|
27151
|
+
pointer: pointerOf("definition", "bands"),
|
|
27152
|
+
resource
|
|
27153
|
+
});
|
|
27154
|
+
}
|
|
27155
|
+
if (!(config.engine?.definition.assessments?.includes(identifier) ?? false)) {
|
|
27156
|
+
const message = `Assessment "${identifier}" is not in the engine's "assessments", so nothing can score it and it will never hold a result`;
|
|
27157
|
+
result.warnings.push(message);
|
|
27158
|
+
result.findings.push({
|
|
27159
|
+
severity: "warning",
|
|
27160
|
+
code: "ASSESSMENT_UNWRITTEN",
|
|
27161
|
+
message,
|
|
27162
|
+
hint: `Add "${identifier}" to "assessments" in engine/engine.sdk.json, or delete the assessment`,
|
|
27163
|
+
file,
|
|
27164
|
+
resource
|
|
27165
|
+
});
|
|
27166
|
+
}
|
|
27167
|
+
for (const scenario of config.scenarios ?? []) {
|
|
27168
|
+
const settings = scenario.definition.settings?.[ASSESSMENTS_SETTINGS];
|
|
27169
|
+
const override = settings?.[identifier];
|
|
27170
|
+
if (override === void 0) continue;
|
|
27171
|
+
const problem = bandsProblem(definition3, resolveAssessmentBands(definition3, override));
|
|
27172
|
+
if (problem === null) continue;
|
|
27173
|
+
addError(result, {
|
|
27174
|
+
code: "PACKAGE_INVALID",
|
|
27175
|
+
message: `Scenario "${scenario.definition.identifier}" moves the bands of assessment "${identifier}" out of order: ${problem}`,
|
|
27176
|
+
hint: "Keep each band starting above the one before it, the first at the minimum score",
|
|
27177
|
+
file: bundleFileOf("scenario", scenario.definition.identifier),
|
|
27178
|
+
pointer: pointerOf("definition", "settings", ASSESSMENTS_SETTINGS, identifier),
|
|
27179
|
+
resource: { type: "scenario", identifier: scenario.definition.identifier }
|
|
27180
|
+
});
|
|
27181
|
+
}
|
|
27182
|
+
return result;
|
|
27183
|
+
}
|
|
27184
|
+
function validateEngineAssessments(config) {
|
|
27185
|
+
const result = outcome();
|
|
27186
|
+
const declared = new Set((config.assessments ?? []).map((a) => a.definition.identifier));
|
|
27187
|
+
const engine = config.engine;
|
|
27188
|
+
if (engine) {
|
|
27189
|
+
(engine.definition.assessments ?? []).forEach((identifier, index3) => {
|
|
27190
|
+
if (declared.has(identifier)) return;
|
|
27191
|
+
addError(result, {
|
|
27192
|
+
code: "REFERENCE_UNKNOWN",
|
|
27193
|
+
message: `Engine declares assessment "${identifier}", which the package does not have`,
|
|
27194
|
+
hint: `Create it with "new assessment", or remove it from the engine's "assessments"`,
|
|
27195
|
+
file: bundleFileOf("engine", "engine"),
|
|
27196
|
+
pointer: pointerOf("definition", "assessments", index3),
|
|
27197
|
+
resource: { type: "engine", identifier: engine.definition.identifier }
|
|
27198
|
+
});
|
|
27199
|
+
});
|
|
27200
|
+
}
|
|
27201
|
+
if (declared.size > MAX_ASSESSMENTS_PER_GAME) {
|
|
27202
|
+
addError(result, {
|
|
27203
|
+
code: "PACKAGE_INVALID",
|
|
27204
|
+
message: `The game declares ${declared.size} assessments, more than the ${MAX_ASSESSMENTS_PER_GAME} a game may have`,
|
|
27205
|
+
hint: "Fold related measures into one assessment, or remove the ones nobody reports"
|
|
27206
|
+
});
|
|
27207
|
+
}
|
|
27208
|
+
return result;
|
|
27209
|
+
}
|
|
27210
|
+
|
|
25830
27211
|
// cli/validation/file-settings.ts
|
|
25831
27212
|
function fileSettingValues(declared, value, path3 = [], root2 = declared) {
|
|
25832
27213
|
if (!declared || typeof declared !== "object" || !root2) return [];
|
|
@@ -26049,11 +27430,16 @@ async function updateSettings(host, command) {
|
|
|
26049
27430
|
refuseUnconfiguredSettings(host, command.uiIdentifier, command.payload);
|
|
26050
27431
|
const existing = executor.getSessionOverrides() ?? {};
|
|
26051
27432
|
const changed = changedFrom(command.payload, executor.resolveConfiguration());
|
|
26052
|
-
const layer = deepMergeContext(existing,
|
|
27433
|
+
const layer = deepMergeContext(existing, isRecord5(changed) ? changed : {});
|
|
26053
27434
|
const config = executor.getConfig();
|
|
26054
27435
|
const result = config ? validateSessionOverrides(layer, settingsSchemas(config)) : { valid: true };
|
|
26055
27436
|
if (!result.valid) throw new DeniedError(result.errors ?? "Invalid settings");
|
|
26056
|
-
|
|
27437
|
+
const bands = resolvedBandProblems(
|
|
27438
|
+
config?.assessments ?? [],
|
|
27439
|
+
deepMergeContext(executor.buildResetConfiguration(), layer)
|
|
27440
|
+
);
|
|
27441
|
+
if (bands.length > 0) throw new DeniedError(bands.join("\n"));
|
|
27442
|
+
await refuseUnfitFiles(host, isRecord5(changed) ? changed : {});
|
|
26057
27443
|
executor.setConfiguration(layer);
|
|
26058
27444
|
return void 0;
|
|
26059
27445
|
}
|
|
@@ -26071,13 +27457,17 @@ async function updateScenarioDraft(host, drafts, command) {
|
|
|
26071
27457
|
host.executor.resolveScenarioDraft(scenarioId, edits)
|
|
26072
27458
|
);
|
|
26073
27459
|
const config = host.executor.getConfig();
|
|
26074
|
-
const
|
|
26075
|
-
|
|
26076
|
-
settingsSchemas(config)
|
|
26077
|
-
|
|
27460
|
+
const merged = deepMergeContext(edits, isRecord5(changed) ? changed : {});
|
|
27461
|
+
const errors = config ? [
|
|
27462
|
+
...collectSettingsOverrideErrors(merged, settingsSchemas(config)),
|
|
27463
|
+
...resolvedBandProblems(
|
|
27464
|
+
config.assessments ?? [],
|
|
27465
|
+
host.executor.resolveScenarioDraft(scenarioId, merged)
|
|
27466
|
+
)
|
|
27467
|
+
] : [];
|
|
26078
27468
|
if (errors.length > 0) throw new DeniedError(errors.join("\n"));
|
|
26079
|
-
await refuseUnfitFiles(host,
|
|
26080
|
-
drafts.record(scenarioId,
|
|
27469
|
+
await refuseUnfitFiles(host, isRecord5(changed) ? changed : {}, { draft: true });
|
|
27470
|
+
drafts.record(scenarioId, isRecord5(changed) ? changed : {});
|
|
26081
27471
|
return void 0;
|
|
26082
27472
|
}
|
|
26083
27473
|
async function refuseUnfitFiles(host, changed, options = {}) {
|
|
@@ -26195,11 +27585,11 @@ function resolveSharedWrites(host, board) {
|
|
|
26195
27585
|
executor.setSharedContext(deepMergeContext(store, changed));
|
|
26196
27586
|
return { ...board, ...executor.getSharedContext() };
|
|
26197
27587
|
}
|
|
26198
|
-
function
|
|
27588
|
+
function isRecord5(value) {
|
|
26199
27589
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26200
27590
|
}
|
|
26201
27591
|
function changedFrom(update, current) {
|
|
26202
|
-
if (
|
|
27592
|
+
if (isRecord5(update) && isRecord5(current)) {
|
|
26203
27593
|
const changed = {};
|
|
26204
27594
|
for (const [key, value] of Object.entries(update)) {
|
|
26205
27595
|
const difference = changedFrom(value, current[key]);
|
|
@@ -26575,8 +27965,10 @@ var PLAY_STAGE = /* @__PURE__ */ new Set([
|
|
|
26575
27965
|
"moveParticipant",
|
|
26576
27966
|
"renameOwnTeam",
|
|
26577
27967
|
"renameSelf",
|
|
26578
|
-
"extendTick"
|
|
27968
|
+
"extendTick",
|
|
27969
|
+
"makeDormant"
|
|
26579
27970
|
]);
|
|
27971
|
+
var HOST_CONTROLS = /* @__PURE__ */ new Set(["armFault", "disarmFault", "makeDormant"]);
|
|
26580
27972
|
var STALE_BLOCKED = /* @__PURE__ */ new Set([
|
|
26581
27973
|
"tick",
|
|
26582
27974
|
"undo",
|
|
@@ -26715,7 +28107,7 @@ var Session = class {
|
|
|
26715
28107
|
},
|
|
26716
28108
|
enqueue: (work) => this.enqueue(work),
|
|
26717
28109
|
apply: (command) => this.apply(command),
|
|
26718
|
-
submit: (command) => this.
|
|
28110
|
+
submit: (command) => this.enqueue(() => this.apply(command)),
|
|
26719
28111
|
report: (message, source, teamId) => this.report(message, source, teamId),
|
|
26720
28112
|
emit: (event) => this.emit(event),
|
|
26721
28113
|
emitState: (cause) => this.emitState(cause)
|
|
@@ -26765,8 +28157,24 @@ var Session = class {
|
|
|
26765
28157
|
/** Submit a state-changing command. Queued, in order, one at a time. */
|
|
26766
28158
|
submit(command) {
|
|
26767
28159
|
if (command.type === "advanceClock") return this.advanceClock(command.byMs);
|
|
28160
|
+
if (!HOST_CONTROLS.has(command.type)) this.noteActivity();
|
|
26768
28161
|
return this.enqueue(() => this.apply(command));
|
|
26769
28162
|
}
|
|
28163
|
+
/**
|
|
28164
|
+
* Something outside the host used the session (§11.4a). A dormant session
|
|
28165
|
+
* wakes before the activity is handled: the re-evaluation waking needs is
|
|
28166
|
+
* queued ahead of it.
|
|
28167
|
+
*/
|
|
28168
|
+
noteActivity() {
|
|
28169
|
+
this.finishWaking(this.timers.noteActivity());
|
|
28170
|
+
}
|
|
28171
|
+
finishWaking(reevaluate) {
|
|
28172
|
+
if (!reevaluate) return;
|
|
28173
|
+
void this.enqueue(async () => {
|
|
28174
|
+
await reevaluate();
|
|
28175
|
+
this.emitState("woke");
|
|
28176
|
+
});
|
|
28177
|
+
}
|
|
26770
28178
|
/**
|
|
26771
28179
|
* Queue `work` as one operation: every logic call it makes reads the same
|
|
26772
28180
|
* `meta.now`, taken as it starts rather than as it was submitted (§10.2).
|
|
@@ -26836,6 +28244,7 @@ var Session = class {
|
|
|
26836
28244
|
case "getState":
|
|
26837
28245
|
return { type: "state", state: this.project() };
|
|
26838
28246
|
case "callEndpoint":
|
|
28247
|
+
this.noteActivity();
|
|
26839
28248
|
return this.endpoints.answer(command);
|
|
26840
28249
|
case "getEndpointAudit":
|
|
26841
28250
|
return { type: "endpointAudit", entries: [...this.endpoints.auditLog()] };
|
|
@@ -26887,6 +28296,41 @@ var Session = class {
|
|
|
26887
28296
|
}
|
|
26888
28297
|
return { type: "participants", participants: this.roster.records() };
|
|
26889
28298
|
}
|
|
28299
|
+
case "getAssessment": {
|
|
28300
|
+
const indexes = this.state.getTeamIndexes();
|
|
28301
|
+
const contexts = this.state.getTeamContexts();
|
|
28302
|
+
const complete = this.state.teamsFinished(this.tickLimit());
|
|
28303
|
+
const teams = indexes.map((index3, position2) => ({
|
|
28304
|
+
teamId: `team-${index3 + 1}`,
|
|
28305
|
+
context: contexts[position2],
|
|
28306
|
+
complete: complete[position2] ?? false
|
|
28307
|
+
}));
|
|
28308
|
+
return answerAssessment({
|
|
28309
|
+
query: command,
|
|
28310
|
+
assessments: this.executor.getConfig()?.assessments ?? [],
|
|
28311
|
+
teams,
|
|
28312
|
+
participants: teams.flatMap(
|
|
28313
|
+
(team) => this.participants.list(team.teamId).map((record2) => ({ id: record2.id, teamId: team.teamId }))
|
|
28314
|
+
),
|
|
28315
|
+
settings: this.executor.resolveConfiguration()
|
|
28316
|
+
});
|
|
28317
|
+
}
|
|
28318
|
+
case "getBenchmark": {
|
|
28319
|
+
try {
|
|
28320
|
+
const statistics = await answerBenchmarkFromSample({
|
|
28321
|
+
packagePath: this.options.packagePath,
|
|
28322
|
+
identifier: command.identifier,
|
|
28323
|
+
where: benchmarkFilters({ where: command.where }),
|
|
28324
|
+
declared: this.executor.getConfig()?.benchmarks?.map((benchmark) => benchmark.definition.identifier)
|
|
28325
|
+
});
|
|
28326
|
+
return { type: "benchmark", statistics };
|
|
28327
|
+
} catch (error) {
|
|
28328
|
+
return {
|
|
28329
|
+
type: "benchmarkFailure",
|
|
28330
|
+
error: errorMessage(error, "The benchmark could not be read")
|
|
28331
|
+
};
|
|
28332
|
+
}
|
|
28333
|
+
}
|
|
26890
28334
|
}
|
|
26891
28335
|
}
|
|
26892
28336
|
/** Convenience for a caller that does not care which kind it is holding. */
|
|
@@ -26916,6 +28360,16 @@ var Session = class {
|
|
|
26916
28360
|
canUndo: canUndo[position2] ?? false,
|
|
26917
28361
|
context: withoutEngineState(contexts[position2] ?? {}),
|
|
26918
28362
|
...contexts[position2]?.[ENGINE_STATE_KEY] !== void 0 ? { state: structuredClone(contexts[position2][ENGINE_STATE_KEY]) } : {},
|
|
28363
|
+
...contexts[position2]?.[BENCHMARKS_KEY] !== void 0 ? {
|
|
28364
|
+
benchmarks: structuredClone(
|
|
28365
|
+
contexts[position2][BENCHMARKS_KEY]
|
|
28366
|
+
)
|
|
28367
|
+
} : {},
|
|
28368
|
+
...contexts[position2]?.[ASSESSMENTS_KEY] !== void 0 ? {
|
|
28369
|
+
assessments: structuredClone(
|
|
28370
|
+
contexts[position2][ASSESSMENTS_KEY]
|
|
28371
|
+
)
|
|
28372
|
+
} : {},
|
|
26919
28373
|
participants: this.participants.list(teamId).map((record2) => ({
|
|
26920
28374
|
id: record2.id,
|
|
26921
28375
|
name: record2.name,
|
|
@@ -27016,6 +28470,14 @@ var Session = class {
|
|
|
27016
28470
|
syncPresence(connected) {
|
|
27017
28471
|
if (this.roster.syncPresence(connected)) this.emitState("presence");
|
|
27018
28472
|
}
|
|
28473
|
+
/**
|
|
28474
|
+
* How many surfaces and console pages are open on this session, which the
|
|
28475
|
+
* host observes as it does presence. Opening one is activity, and while
|
|
28476
|
+
* any is open the session does not go dormant (§11.4a).
|
|
28477
|
+
*/
|
|
28478
|
+
syncOpenSurfaces(count) {
|
|
28479
|
+
this.finishWaking(this.timers.surfacesOpen(count));
|
|
28480
|
+
}
|
|
27019
28481
|
/** Edits on disk this session has not applied, each list empty when none is. */
|
|
27020
28482
|
pendingChanges() {
|
|
27021
28483
|
return {
|
|
@@ -27189,10 +28651,11 @@ var Session = class {
|
|
|
27189
28651
|
try {
|
|
27190
28652
|
const readsBefore = this.timers.readsBefore(command);
|
|
27191
28653
|
this.startWarnings = [];
|
|
28654
|
+
this.executor.takeWarnings();
|
|
27192
28655
|
const committedAtTick = await this.dispatch(command);
|
|
27193
28656
|
await this.timers.retime(command, readsBefore);
|
|
27194
28657
|
this.emitState(command.type);
|
|
27195
|
-
const warnings = this.startWarnings;
|
|
28658
|
+
const warnings = [...this.startWarnings, ...this.executor.takeWarnings()];
|
|
27196
28659
|
this.startWarnings = [];
|
|
27197
28660
|
return {
|
|
27198
28661
|
ok: true,
|
|
@@ -27232,7 +28695,11 @@ var Session = class {
|
|
|
27232
28695
|
case "tick":
|
|
27233
28696
|
return tick(this.host, command);
|
|
27234
28697
|
case "undo":
|
|
27235
|
-
return keepingSessionLifetime(this.host, () =>
|
|
28698
|
+
return keepingSessionLifetime(this.host, async () => {
|
|
28699
|
+
const tick2 = await undo(this.host, command);
|
|
28700
|
+
this.roster.settleAssessments();
|
|
28701
|
+
return tick2;
|
|
28702
|
+
});
|
|
27236
28703
|
case "reset":
|
|
27237
28704
|
return keepingSessionLifetime(this.host, () => reset(this.host, command));
|
|
27238
28705
|
case "updateContext":
|
|
@@ -27277,6 +28744,14 @@ var Session = class {
|
|
|
27277
28744
|
return void 0;
|
|
27278
28745
|
case "extendTick":
|
|
27279
28746
|
return this.timers.extend(command);
|
|
28747
|
+
case "makeDormant":
|
|
28748
|
+
if (!this.executor.getConfig()?.tick_controller) {
|
|
28749
|
+
throw new DeniedError(
|
|
28750
|
+
"This game has no tick controller, so nothing ticks on its own"
|
|
28751
|
+
);
|
|
28752
|
+
}
|
|
28753
|
+
this.timers.suspend();
|
|
28754
|
+
return void 0;
|
|
27280
28755
|
case "armFault":
|
|
27281
28756
|
this.faults.arm(command.fault, {
|
|
27282
28757
|
...command.times === void 0 ? {} : { times: command.times },
|
|
@@ -27547,8 +29022,13 @@ var Session = class {
|
|
|
27547
29022
|
return resolveTeamDisplayName(index3, this.settings().teams.defaultNames, this.locale);
|
|
27548
29023
|
}
|
|
27549
29024
|
sharedEngineState() {
|
|
27550
|
-
const
|
|
27551
|
-
|
|
29025
|
+
const shared = this.executor.getSharedContext();
|
|
29026
|
+
const state2 = shared[SHARED_ENGINE_STATE_KEY];
|
|
29027
|
+
const benchmarks = shared[SHARED_BENCHMARKS_KEY];
|
|
29028
|
+
return {
|
|
29029
|
+
...state2 === void 0 ? {} : { sharedState: state2 },
|
|
29030
|
+
...benchmarks === void 0 ? {} : { sharedBenchmarks: structuredClone(benchmarks) }
|
|
29031
|
+
};
|
|
27552
29032
|
}
|
|
27553
29033
|
sharedStore() {
|
|
27554
29034
|
const shared = this.executor.getSharedContext();
|
|
@@ -27632,7 +29112,7 @@ var Session = class {
|
|
|
27632
29112
|
|
|
27633
29113
|
// cli/utils/env-loader.ts
|
|
27634
29114
|
import { readFileSync as readFileSync6, existsSync as existsSync10 } from "fs";
|
|
27635
|
-
import { join as
|
|
29115
|
+
import { join as join10 } from "path";
|
|
27636
29116
|
|
|
27637
29117
|
// cli/utils/global-settings.ts
|
|
27638
29118
|
import {
|
|
@@ -27645,7 +29125,7 @@ import {
|
|
|
27645
29125
|
writeFileSync
|
|
27646
29126
|
} from "fs";
|
|
27647
29127
|
import { homedir } from "os";
|
|
27648
|
-
import { dirname as dirname3, isAbsolute as isAbsolute6, join as
|
|
29128
|
+
import { dirname as dirname3, isAbsolute as isAbsolute6, join as join9 } from "path";
|
|
27649
29129
|
var GLOBAL_SETTINGS_ENV_VAR = "SERIOUSGAMING_SDK_CONFIG";
|
|
27650
29130
|
function resolveGlobalSettingsPath() {
|
|
27651
29131
|
const override = process.env[GLOBAL_SETTINGS_ENV_VAR];
|
|
@@ -27658,7 +29138,7 @@ function resolveGlobalSettingsPath() {
|
|
|
27658
29138
|
}
|
|
27659
29139
|
return override;
|
|
27660
29140
|
}
|
|
27661
|
-
return
|
|
29141
|
+
return join9(homedir(), ".seriousgaming-sdk", "config.json");
|
|
27662
29142
|
}
|
|
27663
29143
|
function loadGlobalSettings(path3 = resolveGlobalSettingsPath()) {
|
|
27664
29144
|
if (!existsSync9(path3)) {
|
|
@@ -27706,7 +29186,7 @@ function loadEnvironmentConfig(workingDir, flags) {
|
|
|
27706
29186
|
const config = {};
|
|
27707
29187
|
const ttsVoicePresets = {};
|
|
27708
29188
|
applyGlobalSettings(config);
|
|
27709
|
-
const envPath =
|
|
29189
|
+
const envPath = join10(workingDir, ".env");
|
|
27710
29190
|
if (existsSync10(envPath)) {
|
|
27711
29191
|
try {
|
|
27712
29192
|
const content3 = readFileSync6(envPath, "utf-8");
|
|
@@ -28021,7 +29501,7 @@ import { statSync as statSync3 } from "fs";
|
|
|
28021
29501
|
import { mkdtemp as mkdtemp2, rm as rm5 } from "fs/promises";
|
|
28022
29502
|
import { createServer } from "http";
|
|
28023
29503
|
import { tmpdir as tmpdir2 } from "os";
|
|
28024
|
-
import { dirname as dirname12, join as
|
|
29504
|
+
import { dirname as dirname12, join as join21 } from "path";
|
|
28025
29505
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
28026
29506
|
import react from "@vitejs/plugin-react";
|
|
28027
29507
|
import express2 from "express";
|
|
@@ -28107,8 +29587,8 @@ function isFreeOn(port, host) {
|
|
|
28107
29587
|
}
|
|
28108
29588
|
|
|
28109
29589
|
// cli/server/vite-plugin.ts
|
|
28110
|
-
import { readFile as
|
|
28111
|
-
import { isAbsolute as isAbsolute7, join as
|
|
29590
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
29591
|
+
import { isAbsolute as isAbsolute7, join as join11, relative as relative4 } from "path";
|
|
28112
29592
|
function toRootRelative(html2, documentDirectory) {
|
|
28113
29593
|
return html2.replace(
|
|
28114
29594
|
/(\s(?:src|href)=")(?!https?:|\/\/|\/|data:|#)(\.\/)?([^"]+)(")/g,
|
|
@@ -28146,7 +29626,7 @@ if (import.meta.hot) {
|
|
|
28146
29626
|
`;
|
|
28147
29627
|
async function serveHtmlWithVite(server, res, next, htmlFilePath, documentUrl) {
|
|
28148
29628
|
try {
|
|
28149
|
-
const html2 = await
|
|
29629
|
+
const html2 = await readFile7(htmlFilePath, "utf-8");
|
|
28150
29630
|
const directory = documentUrl.slice(0, documentUrl.lastIndexOf("/"));
|
|
28151
29631
|
const transformed = await server.transformIndexHtml(
|
|
28152
29632
|
documentUrl,
|
|
@@ -28160,7 +29640,7 @@ async function serveHtmlWithVite(server, res, next, htmlFilePath, documentUrl) {
|
|
|
28160
29640
|
}
|
|
28161
29641
|
async function serveStatic(res, next, absolutePath) {
|
|
28162
29642
|
try {
|
|
28163
|
-
const data = await
|
|
29643
|
+
const data = await readFile7(absolutePath);
|
|
28164
29644
|
res.setHeader("Content-Type", contentTypeFor(absolutePath));
|
|
28165
29645
|
res.end(data);
|
|
28166
29646
|
} catch {
|
|
@@ -28221,8 +29701,8 @@ function buildRoutes(options) {
|
|
|
28221
29701
|
];
|
|
28222
29702
|
}
|
|
28223
29703
|
function resolveAbsolute(workingDir, rootDirectory, urlPath) {
|
|
28224
|
-
const baseDir = isAbsolute7(rootDirectory) ? rootDirectory :
|
|
28225
|
-
return
|
|
29704
|
+
const baseDir = isAbsolute7(rootDirectory) ? rootDirectory : join11(workingDir, rootDirectory);
|
|
29705
|
+
return join11(baseDir, urlPath);
|
|
28226
29706
|
}
|
|
28227
29707
|
function seriousgamingUiPlugin(options) {
|
|
28228
29708
|
const { workingDir } = options;
|
|
@@ -28294,16 +29774,16 @@ function seriousgamingUiPlugin(options) {
|
|
|
28294
29774
|
|
|
28295
29775
|
// cli/validation/package-validation.ts
|
|
28296
29776
|
import { existsSync as existsSync14, readFileSync as readFileSync9 } from "fs";
|
|
28297
|
-
import { readFile as
|
|
29777
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
28298
29778
|
import { dirname as dirname6, resolve as resolve7 } from "path";
|
|
28299
29779
|
|
|
28300
29780
|
// cli/generation/ts-type.ts
|
|
28301
29781
|
import { existsSync as existsSync11, readFileSync as readFileSync7, statSync } from "fs";
|
|
28302
|
-
import { dirname as dirname4, isAbsolute as isAbsolute8, join as
|
|
29782
|
+
import { dirname as dirname4, isAbsolute as isAbsolute8, join as join12, relative as relative5, resolve as resolve4, sep as sep5 } from "path";
|
|
28303
29783
|
var NAMED_IMPORT = /import\((['"])([^'"]+)\1\)\.([A-Za-z_$][\w$]*)/g;
|
|
28304
29784
|
var MODULE_EXTENSIONS = [".ts", ".tsx", ".d.ts", "/index.ts", "/index.tsx"];
|
|
28305
29785
|
function capabilityDirectory(workingDir, identifier) {
|
|
28306
|
-
return
|
|
29786
|
+
return join12(workingDir, getPluralResourceMeta("capability").pluralDir, identifier);
|
|
28307
29787
|
}
|
|
28308
29788
|
function collectTsTypes(schema2, into = []) {
|
|
28309
29789
|
if (Array.isArray(schema2)) {
|
|
@@ -28354,9 +29834,85 @@ function exportsName(source, name) {
|
|
|
28354
29834
|
return declared.test(source) || listed.test(source) || /export\s+\*\s+from/.test(source);
|
|
28355
29835
|
}
|
|
28356
29836
|
|
|
29837
|
+
// cli/validation/benchmark-validation.ts
|
|
29838
|
+
function outcome2() {
|
|
29839
|
+
return { errors: [], warnings: [], findings: [] };
|
|
29840
|
+
}
|
|
29841
|
+
function addError2(result, finding) {
|
|
29842
|
+
result.errors.push(finding.hint ? `${finding.message}. ${finding.hint}` : finding.message);
|
|
29843
|
+
result.findings.push({ severity: "error", ...finding });
|
|
29844
|
+
}
|
|
29845
|
+
function validateBenchmark(benchmark, config) {
|
|
29846
|
+
const result = outcome2();
|
|
29847
|
+
const { identifier } = benchmark.definition;
|
|
29848
|
+
const file = bundleFileOf("benchmark", identifier);
|
|
29849
|
+
const resource = { type: "benchmark", identifier };
|
|
29850
|
+
if (!(config.requires ?? []).includes(BENCHMARKS_FEATURE)) {
|
|
29851
|
+
addError2(result, {
|
|
29852
|
+
code: "FEATURE_UNDECLARED",
|
|
29853
|
+
message: `Benchmark "${identifier}" needs the \`${BENCHMARKS_FEATURE}\` feature, but \`requires\` does not list it`,
|
|
29854
|
+
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`,
|
|
29855
|
+
file: MANIFEST_FILE,
|
|
29856
|
+
pointer: pointerOf("requires"),
|
|
29857
|
+
resource
|
|
29858
|
+
});
|
|
29859
|
+
}
|
|
29860
|
+
const engine = config.engine;
|
|
29861
|
+
const written = engine?.definition.benchmarks?.includes(identifier) ?? false;
|
|
29862
|
+
if (!written) {
|
|
29863
|
+
const message = `Benchmark "${identifier}" is not in the engine's "benchmarks", so nothing can write it and it will never hold a value`;
|
|
29864
|
+
result.warnings.push(message);
|
|
29865
|
+
result.findings.push({
|
|
29866
|
+
severity: "warning",
|
|
29867
|
+
code: "BENCHMARK_UNWRITTEN",
|
|
29868
|
+
message,
|
|
29869
|
+
hint: `Add "${identifier}" to "benchmarks" in engine/engine.sdk.json, or delete the benchmark`,
|
|
29870
|
+
file,
|
|
29871
|
+
resource
|
|
29872
|
+
});
|
|
29873
|
+
}
|
|
29874
|
+
if (written && resolveBenchmarkLevel(benchmark.definition) === "session" && engine?.definition.aggregate !== true) {
|
|
29875
|
+
addError2(result, {
|
|
29876
|
+
code: "PACKAGE_INVALID",
|
|
29877
|
+
message: `Benchmark "${identifier}" is session-level, but the engine is not aggregate, so it has no session result to write it under`,
|
|
29878
|
+
hint: 'Export InitAggregate and RunAggregate from the engine, or make the benchmark per team by removing "level"',
|
|
29879
|
+
file,
|
|
29880
|
+
pointer: pointerOf("definition", "level"),
|
|
29881
|
+
resource
|
|
29882
|
+
});
|
|
29883
|
+
}
|
|
29884
|
+
return result;
|
|
29885
|
+
}
|
|
29886
|
+
function validateEngineBenchmarks(config) {
|
|
29887
|
+
const result = outcome2();
|
|
29888
|
+
const declared = new Set((config.benchmarks ?? []).map((b) => b.definition.identifier));
|
|
29889
|
+
const engine = config.engine;
|
|
29890
|
+
if (engine) {
|
|
29891
|
+
(engine.definition.benchmarks ?? []).forEach((identifier, index3) => {
|
|
29892
|
+
if (declared.has(identifier)) return;
|
|
29893
|
+
addError2(result, {
|
|
29894
|
+
code: "REFERENCE_UNKNOWN",
|
|
29895
|
+
message: `Engine declares benchmark "${identifier}", which the package does not have`,
|
|
29896
|
+
hint: `Create it with "new benchmark", or remove it from the engine's "benchmarks"`,
|
|
29897
|
+
file: bundleFileOf("engine", "engine"),
|
|
29898
|
+
pointer: pointerOf("definition", "benchmarks", index3),
|
|
29899
|
+
resource: { type: "engine", identifier: engine.definition.identifier }
|
|
29900
|
+
});
|
|
29901
|
+
});
|
|
29902
|
+
}
|
|
29903
|
+
if (declared.size > MAX_BENCHMARKS_PER_GAME) {
|
|
29904
|
+
addError2(result, {
|
|
29905
|
+
code: "PACKAGE_INVALID",
|
|
29906
|
+
message: `The game declares ${declared.size} benchmarks, more than the ${MAX_BENCHMARKS_PER_GAME} a game may have`,
|
|
29907
|
+
hint: "Combine related fields into one benchmark, or remove the ones no debrief shows"
|
|
29908
|
+
});
|
|
29909
|
+
}
|
|
29910
|
+
return result;
|
|
29911
|
+
}
|
|
29912
|
+
|
|
28357
29913
|
// cli/validation/facilitator-guide-validator.ts
|
|
28358
29914
|
import { existsSync as existsSync12, readdirSync as readdirSync3, readFileSync as readFileSync8, statSync as statSync2 } from "fs";
|
|
28359
|
-
import { dirname as dirname5, join as
|
|
29915
|
+
import { dirname as dirname5, join as join13, resolve as resolve5, sep as sep6 } from "path";
|
|
28360
29916
|
|
|
28361
29917
|
// cli/guide/video-registry.ts
|
|
28362
29918
|
var VIDEO_PROVIDERS = {
|
|
@@ -28630,20 +30186,20 @@ var LARGE_VIDEO_FILE_BYTES = 25 * 1024 * 1024;
|
|
|
28630
30186
|
var VIDEO_BLOCK_PATTERN = /^[ \t]*```video[ \t]*\r?\n([\s\S]*?)^[ \t]*```[ \t]*$/gm;
|
|
28631
30187
|
var IMAGE_PATTERN = /!\[[^\]]*\]\(([^()\s]+)(?:\s+"[^"]*")?\)/g;
|
|
28632
30188
|
function listChapters(localeDir) {
|
|
28633
|
-
return readdirSync3(localeDir).filter((name) => name.endsWith(".md") && statSync2(
|
|
30189
|
+
return readdirSync3(localeDir).filter((name) => name.endsWith(".md") && statSync2(join13(localeDir, name)).isFile()).sort();
|
|
28634
30190
|
}
|
|
28635
30191
|
function validateFacilitatorGuideContent(options) {
|
|
28636
30192
|
const errors = [];
|
|
28637
30193
|
const warnings = [];
|
|
28638
30194
|
const { definition: definition3, rootDirectory } = options;
|
|
28639
|
-
const contentDir =
|
|
30195
|
+
const contentDir = join13(rootDirectory, "content");
|
|
28640
30196
|
const declaredLocales = Object.keys(definition3.locales);
|
|
28641
30197
|
if (!existsSync12(contentDir)) {
|
|
28642
30198
|
warnings.push("Guide has no content/ directory");
|
|
28643
30199
|
return { errors, warnings };
|
|
28644
30200
|
}
|
|
28645
30201
|
for (const entry of readdirSync3(contentDir)) {
|
|
28646
|
-
if (!statSync2(
|
|
30202
|
+
if (!statSync2(join13(contentDir, entry)).isDirectory()) continue;
|
|
28647
30203
|
if (!declaredLocales.includes(entry)) {
|
|
28648
30204
|
warnings.push(
|
|
28649
30205
|
`Content directory "content/${entry}/" has no matching locale in the guide definition`
|
|
@@ -28651,14 +30207,14 @@ function validateFacilitatorGuideContent(options) {
|
|
|
28651
30207
|
}
|
|
28652
30208
|
}
|
|
28653
30209
|
const reference = referenceLocale(definition3.locales);
|
|
28654
|
-
const referenceDir =
|
|
30210
|
+
const referenceDir = join13(contentDir, reference);
|
|
28655
30211
|
const referenceChapters = existsSync12(referenceDir) ? listChapters(referenceDir) : [];
|
|
28656
30212
|
if (referenceChapters.length === 0) {
|
|
28657
30213
|
warnings.push(`Guide has no chapters for its reference locale "${reference}"`);
|
|
28658
30214
|
}
|
|
28659
30215
|
const read = [];
|
|
28660
30216
|
for (const locale of declaredLocales) {
|
|
28661
|
-
const localeDir =
|
|
30217
|
+
const localeDir = join13(contentDir, locale);
|
|
28662
30218
|
if (!existsSync12(localeDir)) {
|
|
28663
30219
|
warnings.push(`Declared locale "${locale}" has no content/${locale}/ directory`);
|
|
28664
30220
|
continue;
|
|
@@ -28677,7 +30233,7 @@ function validateFacilitatorGuideContent(options) {
|
|
|
28677
30233
|
}
|
|
28678
30234
|
}
|
|
28679
30235
|
for (const chapter of chapters) {
|
|
28680
|
-
const chapterPath =
|
|
30236
|
+
const chapterPath = join13(localeDir, chapter);
|
|
28681
30237
|
const content3 = readFileSync8(chapterPath, "utf-8");
|
|
28682
30238
|
const label4 = `content/${locale}/${chapter}`;
|
|
28683
30239
|
read.push({ label: label4, markdown: content3, reference: locale === reference });
|
|
@@ -28688,14 +30244,14 @@ function validateFacilitatorGuideContent(options) {
|
|
|
28688
30244
|
continue;
|
|
28689
30245
|
}
|
|
28690
30246
|
if (parsed.kind !== "file") continue;
|
|
28691
|
-
const assetsDir =
|
|
30247
|
+
const assetsDir = join13(rootDirectory, "assets");
|
|
28692
30248
|
for (const [key, path3] of [
|
|
28693
30249
|
["src", parsed.src],
|
|
28694
30250
|
["poster", parsed.poster],
|
|
28695
30251
|
["captions", parsed.captions]
|
|
28696
30252
|
]) {
|
|
28697
30253
|
if (path3 === void 0) continue;
|
|
28698
|
-
const file =
|
|
30254
|
+
const file = join13(assetsDir, path3);
|
|
28699
30255
|
if (!existsSync12(file) || !statSync2(file).isFile()) {
|
|
28700
30256
|
errors.push(
|
|
28701
30257
|
`${label4}: video ${key} "assets/${path3}" does not resolve to a file`
|
|
@@ -29874,7 +31430,7 @@ function readsWritten(type) {
|
|
|
29874
31430
|
const label4 = getResourceMeta(type).label;
|
|
29875
31431
|
return (resource, context) => {
|
|
29876
31432
|
const definition3 = resource.definition;
|
|
29877
|
-
const
|
|
31433
|
+
const outcome3 = {
|
|
29878
31434
|
errors: [],
|
|
29879
31435
|
warnings: [],
|
|
29880
31436
|
findings: []
|
|
@@ -29883,15 +31439,15 @@ function readsWritten(type) {
|
|
|
29883
31439
|
if (!context.capabilityIds.has(capId)) return;
|
|
29884
31440
|
if (context.writtenInPackage.has(capId)) return;
|
|
29885
31441
|
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.`;
|
|
29886
|
-
|
|
29887
|
-
|
|
31442
|
+
outcome3.warnings.push(message);
|
|
31443
|
+
outcome3.findings.push({
|
|
29888
31444
|
severity: "warning",
|
|
29889
31445
|
code: "READ_NEVER_WRITTEN",
|
|
29890
31446
|
message,
|
|
29891
31447
|
pointer: pointerOf("definition", "reads", index3)
|
|
29892
31448
|
});
|
|
29893
31449
|
});
|
|
29894
|
-
return
|
|
31450
|
+
return outcome3;
|
|
29895
31451
|
};
|
|
29896
31452
|
}
|
|
29897
31453
|
var uiFiles = (ui, context) => validateUIFiles(ui, context.workingDir);
|
|
@@ -29929,12 +31485,25 @@ var VALIDATION_DESCRIPTORS = [
|
|
|
29929
31485
|
localRefs("capability")
|
|
29930
31486
|
]
|
|
29931
31487
|
}),
|
|
31488
|
+
descriptor({
|
|
31489
|
+
type: "benchmark",
|
|
31490
|
+
resources: (config) => config.benchmarks ?? [],
|
|
31491
|
+
identify: named2,
|
|
31492
|
+
checks: [(benchmark, context) => validateBenchmark(benchmark, context.config)]
|
|
31493
|
+
}),
|
|
31494
|
+
descriptor({
|
|
31495
|
+
type: "assessment",
|
|
31496
|
+
resources: (config) => config.assessments ?? [],
|
|
31497
|
+
identify: named2,
|
|
31498
|
+
checks: [(assessment, context) => validateAssessment(assessment, context.config)]
|
|
31499
|
+
}),
|
|
29932
31500
|
// The built-in `game` resource's defaults are the manifest's own values,
|
|
29933
|
-
// which the game's checks already hold to their schema
|
|
31501
|
+
// which the game's checks already hold to their schema, and the built-in
|
|
31502
|
+
// `assessments` resource's are the bundles' bands, which theirs do.
|
|
29934
31503
|
descriptor({
|
|
29935
31504
|
type: "settings",
|
|
29936
31505
|
resources: (config) => (config.settings ?? []).filter(
|
|
29937
|
-
(settings) => settings.definition.identifier !== GAME_SETTINGS
|
|
31506
|
+
(settings) => settings.definition.identifier !== GAME_SETTINGS && !(settings.definition.identifier === ASSESSMENTS_SETTINGS && (config.assessments?.length ?? 0) > 0)
|
|
29938
31507
|
),
|
|
29939
31508
|
identify: named2,
|
|
29940
31509
|
checks: [
|
|
@@ -29980,6 +31549,8 @@ var VALIDATION_DESCRIPTORS = [
|
|
|
29980
31549
|
writer: writesOf,
|
|
29981
31550
|
checks: [
|
|
29982
31551
|
(engine, context) => validateEngine(engine, context.config),
|
|
31552
|
+
(_engine, context) => validateEngineBenchmarks(context.config),
|
|
31553
|
+
(_engine, context) => validateEngineAssessments(context.config),
|
|
29983
31554
|
(engine, context) => validateEngineFiles(engine, context.workingDir),
|
|
29984
31555
|
schemaDefaults2("engine"),
|
|
29985
31556
|
readsWritten("engine")
|
|
@@ -30259,7 +31830,7 @@ async function validateLoadedPackage(config, options) {
|
|
|
30259
31830
|
capabilityIds: new Set((config.capabilities ?? []).map(named2)),
|
|
30260
31831
|
logicLoader: new LogicLoader(dirname6(options.configPath), {
|
|
30261
31832
|
transpile: Transpile,
|
|
30262
|
-
fs: { existsSync: existsSync14, readFile:
|
|
31833
|
+
fs: { existsSync: existsSync14, readFile: readFile8 }
|
|
30263
31834
|
})
|
|
30264
31835
|
};
|
|
30265
31836
|
const results = [];
|
|
@@ -30318,7 +31889,7 @@ function setupNotesChecks(setup, context) {
|
|
|
30318
31889
|
const configures = new Set(setup.definition.configures ?? []);
|
|
30319
31890
|
const reads = new Set(setup.definition.settings ?? []);
|
|
30320
31891
|
const resource = { type: "setup", identifier: "setup" };
|
|
30321
|
-
const
|
|
31892
|
+
const outcome3 = {
|
|
30322
31893
|
errors: [],
|
|
30323
31894
|
warnings: [],
|
|
30324
31895
|
findings: []
|
|
@@ -30334,8 +31905,8 @@ function setupNotesChecks(setup, context) {
|
|
|
30334
31905
|
const identifier = parseSettingPath(path3)?.identifier ?? "";
|
|
30335
31906
|
if (!configures.has(identifier) && !reads.has(identifier)) {
|
|
30336
31907
|
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.`;
|
|
30337
|
-
|
|
30338
|
-
|
|
31908
|
+
outcome3.warnings.push(message);
|
|
31909
|
+
outcome3.findings.push({
|
|
30339
31910
|
severity: "warning",
|
|
30340
31911
|
code: "SETUP_NOTES_UNCONFIGURED",
|
|
30341
31912
|
message,
|
|
@@ -30346,7 +31917,7 @@ function setupNotesChecks(setup, context) {
|
|
|
30346
31917
|
}
|
|
30347
31918
|
}
|
|
30348
31919
|
}
|
|
30349
|
-
return
|
|
31920
|
+
return outcome3;
|
|
30350
31921
|
}
|
|
30351
31922
|
function ungatedSettingsChecks(gameIdentifier, config) {
|
|
30352
31923
|
const resource = { type: "game", identifier: gameIdentifier };
|
|
@@ -30358,7 +31929,9 @@ function ungatedSettingsChecks(gameIdentifier, config) {
|
|
|
30358
31929
|
(config.validators ?? []).filter((v) => v.definition.gates?.includes("scenario")).flatMap((v) => v.definition.settings ?? [])
|
|
30359
31930
|
);
|
|
30360
31931
|
for (const identifier of configures) {
|
|
30361
|
-
if (identifier === GAME_SETTINGS || gated.has(identifier))
|
|
31932
|
+
if (identifier === GAME_SETTINGS || identifier === ASSESSMENTS_SETTINGS || gated.has(identifier)) {
|
|
31933
|
+
continue;
|
|
31934
|
+
}
|
|
30362
31935
|
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.`;
|
|
30363
31936
|
warnings.push(message);
|
|
30364
31937
|
findings.push({
|
|
@@ -30373,8 +31946,8 @@ function ungatedSettingsChecks(gameIdentifier, config) {
|
|
|
30373
31946
|
}
|
|
30374
31947
|
return { errors: [], warnings, findings };
|
|
30375
31948
|
}
|
|
30376
|
-
function record(result,
|
|
30377
|
-
const byMessage = new Map((
|
|
31949
|
+
function record(result, outcome3) {
|
|
31950
|
+
const byMessage = new Map((outcome3.findings ?? []).map((f) => [f.message, f]));
|
|
30378
31951
|
const add = (severity, message) => {
|
|
30379
31952
|
const finding = byMessage.get(message) ?? {
|
|
30380
31953
|
code: message.includes(LOGIC_NODE_BUILTIN) ? LOGIC_NODE_BUILTIN : "PACKAGE_INVALID",
|
|
@@ -30382,18 +31955,18 @@ function record(result, outcome) {
|
|
|
30382
31955
|
};
|
|
30383
31956
|
result.diagnostics.push(located(severity, finding, result));
|
|
30384
31957
|
};
|
|
30385
|
-
if (
|
|
30386
|
-
result.errors.push(...
|
|
31958
|
+
if (outcome3.errorFindings) {
|
|
31959
|
+
result.errors.push(...outcome3.errors);
|
|
30387
31960
|
result.diagnostics.push(
|
|
30388
|
-
...
|
|
31961
|
+
...outcome3.errorFindings.map((finding) => located("error", finding, result))
|
|
30389
31962
|
);
|
|
30390
31963
|
} else {
|
|
30391
|
-
for (const message of
|
|
31964
|
+
for (const message of outcome3.errors) {
|
|
30392
31965
|
result.errors.push(message);
|
|
30393
31966
|
add("error", message);
|
|
30394
31967
|
}
|
|
30395
31968
|
}
|
|
30396
|
-
for (const message of
|
|
31969
|
+
for (const message of outcome3.warnings ?? []) {
|
|
30397
31970
|
result.warnings.push(message);
|
|
30398
31971
|
add("warning", message);
|
|
30399
31972
|
}
|
|
@@ -30435,7 +32008,7 @@ function scenarioRefusals(problems, subject, resource, file, pointerFor) {
|
|
|
30435
32008
|
|
|
30436
32009
|
// cli/dev/brands.ts
|
|
30437
32010
|
import { existsSync as existsSync15, readFileSync as readFileSync10 } from "fs";
|
|
30438
|
-
import { dirname as dirname7, isAbsolute as isAbsolute9, join as
|
|
32011
|
+
import { dirname as dirname7, isAbsolute as isAbsolute9, join as join14, normalize as normalize2, resolve as resolve8, sep as sep8 } from "path";
|
|
30439
32012
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
30440
32013
|
var ROLES = ["primary", "secondary", "success", "error", "warning", "info"];
|
|
30441
32014
|
var NEUTRALS = ["background", "surface", "text"];
|
|
@@ -30524,7 +32097,7 @@ var PLAIN_DARK = {
|
|
|
30524
32097
|
info: "#29b6f6"
|
|
30525
32098
|
};
|
|
30526
32099
|
function builtInBrandsDirectory() {
|
|
30527
|
-
return
|
|
32100
|
+
return join14(dirname7(fileURLToPath2(import.meta.url)), "brands");
|
|
30528
32101
|
}
|
|
30529
32102
|
function invalid(path3, problem) {
|
|
30530
32103
|
return new CliError("INPUT_INVALID", `The brand file ${path3} is not valid: ${problem}`, {
|
|
@@ -30637,12 +32210,12 @@ function loadBrands(brandFiles = []) {
|
|
|
30637
32210
|
brand: { name: "Plain brand" }
|
|
30638
32211
|
};
|
|
30639
32212
|
const seriousGaming = readBrandFile(
|
|
30640
|
-
|
|
32213
|
+
join14(directory, "serious-gaming", "brand.json"),
|
|
30641
32214
|
SERIOUS_GAMING,
|
|
30642
32215
|
plain
|
|
30643
32216
|
);
|
|
30644
32217
|
const awkward = readBrandFile(
|
|
30645
|
-
|
|
32218
|
+
join14(directory, "awkward", "brand.json"),
|
|
30646
32219
|
"awkward",
|
|
30647
32220
|
seriousGaming
|
|
30648
32221
|
);
|
|
@@ -30713,23 +32286,23 @@ function summarise(brand, assetOrigin) {
|
|
|
30713
32286
|
|
|
30714
32287
|
// cli/dev/console-path.ts
|
|
30715
32288
|
import { existsSync as existsSync16 } from "fs";
|
|
30716
|
-
import { join as
|
|
32289
|
+
import { join as join15, sep as sep9 } from "path";
|
|
30717
32290
|
function resolveConsolePath(dirname13, filename, fileExists = existsSync16) {
|
|
30718
32291
|
const fromSource = filename.includes(`${sep9}cli${sep9}dev${sep9}`) || filename.includes("/cli/dev/");
|
|
30719
|
-
const path3 = fromSource ?
|
|
30720
|
-
return { path: path3, built: fileExists(
|
|
32292
|
+
const path3 = fromSource ? join15(dirname13, "..", "..", "dist", "dev", "console") : join15(dirname13, "dev", "console");
|
|
32293
|
+
return { path: path3, built: fileExists(join15(path3, "index.html")) };
|
|
30721
32294
|
}
|
|
30722
32295
|
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.";
|
|
30723
32296
|
|
|
30724
32297
|
// cli/dev/lockfile.ts
|
|
30725
32298
|
import { createHash as createHash3, randomUUID as randomUUID3 } from "crypto";
|
|
30726
|
-
import { mkdir as mkdir3, readFile as
|
|
32299
|
+
import { mkdir as mkdir3, readFile as readFile9, rm as rm2, writeFile as writeFile3 } from "fs/promises";
|
|
30727
32300
|
import { hostname } from "os";
|
|
30728
|
-
import { basename as basename3, dirname as dirname9, join as
|
|
32301
|
+
import { basename as basename3, dirname as dirname9, join as join17, resolve as resolve10 } from "path";
|
|
30729
32302
|
|
|
30730
32303
|
// cli/dev/tools-identity.ts
|
|
30731
32304
|
import { existsSync as existsSync17, readFileSync as readFileSync11, realpathSync as realpathSync2 } from "fs";
|
|
30732
|
-
import { dirname as dirname8, join as
|
|
32305
|
+
import { dirname as dirname8, join as join16, resolve as resolve9, sep as sep10 } from "path";
|
|
30733
32306
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
30734
32307
|
var cached = null;
|
|
30735
32308
|
function toolsIdentity() {
|
|
@@ -30740,10 +32313,10 @@ function readIdentity(filename) {
|
|
|
30740
32313
|
const here = dirname8(filename);
|
|
30741
32314
|
const fromSource = filename.includes(`${sep10}cli${sep10}dev${sep10}`);
|
|
30742
32315
|
const root2 = fromSource ? resolve9(here, "..", "..") : resolve9(here, "..");
|
|
30743
|
-
const entry = fromSource ?
|
|
32316
|
+
const entry = fromSource ? join16(root2, "cli", "cli.ts") : join16(here, "cli.js");
|
|
30744
32317
|
let version = "0.0.0";
|
|
30745
32318
|
try {
|
|
30746
|
-
const manifest = JSON.parse(readFileSync11(
|
|
32319
|
+
const manifest = JSON.parse(readFileSync11(join16(root2, "package.json"), "utf-8"));
|
|
30747
32320
|
version = manifest.version ?? version;
|
|
30748
32321
|
} catch {
|
|
30749
32322
|
}
|
|
@@ -30755,10 +32328,10 @@ var DEV_STATE_DIR_ENV_VAR = "SERIOUSGAMING_DEV_STATE_DIR";
|
|
|
30755
32328
|
var ownInstances = /* @__PURE__ */ new Set();
|
|
30756
32329
|
function lockFilePath(packagePath, env = process.env) {
|
|
30757
32330
|
const stateDir = env[DEV_STATE_DIR_ENV_VAR]?.trim();
|
|
30758
|
-
if (!stateDir) return
|
|
32331
|
+
if (!stateDir) return join17(packagePath, ".seriousgaming-sdk", "session.json");
|
|
30759
32332
|
const absolute = resolve10(packagePath);
|
|
30760
32333
|
const key = createHash3("sha256").update(absolute).digest("hex").slice(0, 12);
|
|
30761
|
-
return
|
|
32334
|
+
return join17(resolve10(stateDir), `${basename3(absolute)}-${key}`, "session.json");
|
|
30762
32335
|
}
|
|
30763
32336
|
async function writeLockFile(packagePath, details) {
|
|
30764
32337
|
const path3 = lockFilePath(packagePath);
|
|
@@ -30790,7 +32363,7 @@ function newInstanceId() {
|
|
|
30790
32363
|
import { rmSync as rmSync2, watch as watchDirectory } from "fs";
|
|
30791
32364
|
import { mkdtemp, rm as rm3, writeFile as writeFile4 } from "fs/promises";
|
|
30792
32365
|
import { tmpdir } from "os";
|
|
30793
|
-
import { basename as basename4, join as
|
|
32366
|
+
import { basename as basename4, join as join18, relative as relative7, sep as sep11 } from "path";
|
|
30794
32367
|
import { watch } from "chokidar";
|
|
30795
32368
|
var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
30796
32369
|
"node_modules",
|
|
@@ -30821,7 +32394,7 @@ function classifyDirectory(packagePath, path3) {
|
|
|
30821
32394
|
return !segments.some((segment) => IGNORED_DIRECTORIES.has(segment));
|
|
30822
32395
|
}
|
|
30823
32396
|
async function untilWatchesDeliver(timeoutMs = 2e3) {
|
|
30824
|
-
const directory = await mkdtemp(
|
|
32397
|
+
const directory = await mkdtemp(join18(tmpdir(), "sg-watch-"));
|
|
30825
32398
|
const removeOnExit = () => rmSync2(directory, { recursive: true, force: true });
|
|
30826
32399
|
process.once("exit", removeOnExit);
|
|
30827
32400
|
const remove = () => {
|
|
@@ -30843,7 +32416,7 @@ async function untilWatchesDeliver(timeoutMs = 2e3) {
|
|
|
30843
32416
|
});
|
|
30844
32417
|
const deadline = Date.now() + timeoutMs;
|
|
30845
32418
|
for (let attempt = 0; !delivered && Date.now() < deadline; attempt++) {
|
|
30846
|
-
await writeFile4(
|
|
32419
|
+
await writeFile4(join18(directory, "probe"), String(attempt));
|
|
30847
32420
|
await new Promise((resolve13) => setTimeout(resolve13, 25));
|
|
30848
32421
|
}
|
|
30849
32422
|
return async () => {
|
|
@@ -30916,19 +32489,19 @@ function publicHostnames(origins) {
|
|
|
30916
32489
|
|
|
30917
32490
|
// cli/dev/routes.ts
|
|
30918
32491
|
import { existsSync as existsSync20 } from "fs";
|
|
30919
|
-
import { readFile as
|
|
32492
|
+
import { readFile as readFile11 } from "fs/promises";
|
|
30920
32493
|
import { isAbsolute as isAbsolute11, normalize as normalize3, resolve as resolve11, sep as sep12 } from "path";
|
|
30921
32494
|
import express from "express";
|
|
30922
32495
|
|
|
30923
32496
|
// cli/core/package-scenario.ts
|
|
30924
32497
|
import { existsSync as existsSync19, readdirSync as readdirSync4 } from "fs";
|
|
30925
|
-
import { mkdir as mkdir5, readFile as
|
|
30926
|
-
import { dirname as dirname11, isAbsolute as isAbsolute10, join as
|
|
32498
|
+
import { mkdir as mkdir5, readFile as readFile10, rm as rm4 } from "fs/promises";
|
|
32499
|
+
import { dirname as dirname11, isAbsolute as isAbsolute10, join as join20, resolve as resolvePath3 } from "path";
|
|
30927
32500
|
|
|
30928
32501
|
// cli/core/asset-reference-translator.ts
|
|
30929
32502
|
import { existsSync as existsSync18 } from "fs";
|
|
30930
32503
|
import { mkdir as mkdir4, writeFile as writeFile5 } from "fs/promises";
|
|
30931
|
-
import { basename as basename5, dirname as dirname10, extname, join as
|
|
32504
|
+
import { basename as basename5, dirname as dirname10, extname, join as join19, posix as posix2 } from "path";
|
|
30932
32505
|
var ASSET_PREFIX2 = "asset:";
|
|
30933
32506
|
var BLOB_PREFIX2 = "blob:";
|
|
30934
32507
|
function createBlobToAssetTranslator(opts) {
|
|
@@ -30946,14 +32519,14 @@ function createBlobToAssetTranslator(opts) {
|
|
|
30946
32519
|
opts.sourceScenarioRootDirectory,
|
|
30947
32520
|
reference
|
|
30948
32521
|
);
|
|
30949
|
-
const targetSubdir =
|
|
32522
|
+
const targetSubdir = join19(opts.targetAssetsDirectory, subdirectory);
|
|
30950
32523
|
await mkdir4(targetSubdir, { recursive: true });
|
|
30951
32524
|
const safeName = sanitizeAssetName(asset.name);
|
|
30952
32525
|
const relativePath = posix2.join(
|
|
30953
32526
|
subdirectory,
|
|
30954
32527
|
uniqueAssetName(targetSubdir, safeName, reservedNames)
|
|
30955
32528
|
);
|
|
30956
|
-
const absolutePath =
|
|
32529
|
+
const absolutePath = join19(opts.targetAssetsDirectory, relativePath);
|
|
30957
32530
|
await mkdir4(dirname10(absolutePath), { recursive: true });
|
|
30958
32531
|
await writeFile5(absolutePath, asset.data);
|
|
30959
32532
|
reservedNames.add(basename5(absolutePath));
|
|
@@ -30965,12 +32538,12 @@ function sanitizeAssetName(name) {
|
|
|
30965
32538
|
return stripped.length > 0 ? stripped : "asset";
|
|
30966
32539
|
}
|
|
30967
32540
|
function uniqueAssetName(directory, name, reserved) {
|
|
30968
|
-
if (!existsSync18(
|
|
32541
|
+
if (!existsSync18(join19(directory, name)) && !reserved.has(name)) return name;
|
|
30969
32542
|
const ext = extname(name);
|
|
30970
32543
|
const stem = ext ? name.slice(0, -ext.length) : name;
|
|
30971
32544
|
for (let i = 1; i < 1e3; i++) {
|
|
30972
32545
|
const candidate = `${stem}-${i}${ext}`;
|
|
30973
|
-
if (!existsSync18(
|
|
32546
|
+
if (!existsSync18(join19(directory, candidate)) && !reserved.has(candidate)) {
|
|
30974
32547
|
return candidate;
|
|
30975
32548
|
}
|
|
30976
32549
|
}
|
|
@@ -31031,15 +32604,15 @@ async function createPackageScenario(opts) {
|
|
|
31031
32604
|
if (existing) {
|
|
31032
32605
|
scenarioFilePath = existing.scenarioFilePath;
|
|
31033
32606
|
const scenarioRoot = isAbsolute10(existing.bundle.rootDirectory) ? existing.bundle.rootDirectory : resolvePath3(dirname11(existing.scenarioFilePath), existing.bundle.rootDirectory);
|
|
31034
|
-
targetAssetsDirectory =
|
|
32607
|
+
targetAssetsDirectory = join20(scenarioRoot, "assets");
|
|
31035
32608
|
bundleRootDirectory = existing.bundle.rootDirectory;
|
|
31036
32609
|
sourceScenarioRootDirectory = scenarioRoot;
|
|
31037
|
-
await mkdir5(
|
|
32610
|
+
await mkdir5(join20(targetAssetsDirectory, "shared"), { recursive: true });
|
|
31038
32611
|
} else {
|
|
31039
|
-
const scenarioDir =
|
|
31040
|
-
scenarioFilePath =
|
|
31041
|
-
targetAssetsDirectory =
|
|
31042
|
-
await mkdir5(
|
|
32612
|
+
const scenarioDir = join20(opts.packagePath, "scenarios", opts.identifier);
|
|
32613
|
+
scenarioFilePath = join20(scenarioDir, "scenario.sdk.json");
|
|
32614
|
+
targetAssetsDirectory = join20(scenarioDir, "assets");
|
|
32615
|
+
await mkdir5(join20(scenarioDir, "assets", "shared"), { recursive: true });
|
|
31043
32616
|
}
|
|
31044
32617
|
const translated = await translateSettings({
|
|
31045
32618
|
settings: opts.settings,
|
|
@@ -31114,11 +32687,11 @@ async function deletePackageScenario(packagePath, identifier) {
|
|
|
31114
32687
|
}
|
|
31115
32688
|
async function findScenarioBundle(packagePath, identifier) {
|
|
31116
32689
|
for (const relativePath of scenarioBundlePaths(packagePath)) {
|
|
31117
|
-
const filePath =
|
|
32690
|
+
const filePath = join20(packagePath, relativePath);
|
|
31118
32691
|
if (!existsSync19(filePath)) continue;
|
|
31119
32692
|
try {
|
|
31120
32693
|
if (relativePath.split("/")[1] !== identifier) continue;
|
|
31121
|
-
const bundle = JSON.parse(await
|
|
32694
|
+
const bundle = JSON.parse(await readFile10(filePath, "utf-8"));
|
|
31122
32695
|
return { scenarioFilePath: filePath, relativePath, bundle };
|
|
31123
32696
|
} catch {
|
|
31124
32697
|
continue;
|
|
@@ -31127,29 +32700,29 @@ async function findScenarioBundle(packagePath, identifier) {
|
|
|
31127
32700
|
return null;
|
|
31128
32701
|
}
|
|
31129
32702
|
function scenarioBundlePaths(packagePath) {
|
|
31130
|
-
const scenariosDir =
|
|
32703
|
+
const scenariosDir = join20(packagePath, "scenarios");
|
|
31131
32704
|
if (!existsSync19(scenariosDir)) return [];
|
|
31132
32705
|
return readdirSync4(scenariosDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().map((name) => `scenarios/${name}/scenario.sdk.json`);
|
|
31133
32706
|
}
|
|
31134
32707
|
async function readPackageManifest(packagePath) {
|
|
31135
|
-
const manifestPath =
|
|
32708
|
+
const manifestPath = join20(packagePath, "seriousgaming.sdk.json");
|
|
31136
32709
|
if (!existsSync19(manifestPath)) {
|
|
31137
32710
|
throw new PackageScenarioError(
|
|
31138
32711
|
"package-manifest-missing",
|
|
31139
32712
|
`Cannot find seriousgaming.sdk.json at ${packagePath}`
|
|
31140
32713
|
);
|
|
31141
32714
|
}
|
|
31142
|
-
return JSON.parse(await
|
|
32715
|
+
return JSON.parse(await readFile10(manifestPath, "utf-8"));
|
|
31143
32716
|
}
|
|
31144
32717
|
async function makeScenarioDefault(packagePath, identifier) {
|
|
31145
32718
|
await readPackageManifest(packagePath);
|
|
31146
32719
|
let found = false;
|
|
31147
32720
|
for (const entry of scenarioBundlePaths(packagePath)) {
|
|
31148
|
-
const filePath =
|
|
32721
|
+
const filePath = join20(packagePath, entry);
|
|
31149
32722
|
if (!existsSync19(filePath)) continue;
|
|
31150
32723
|
let bundle;
|
|
31151
32724
|
try {
|
|
31152
|
-
bundle = JSON.parse(await
|
|
32725
|
+
bundle = JSON.parse(await readFile10(filePath, "utf-8"));
|
|
31153
32726
|
} catch {
|
|
31154
32727
|
continue;
|
|
31155
32728
|
}
|
|
@@ -31928,7 +33501,7 @@ function registerRoutes(app, deps) {
|
|
|
31928
33501
|
res.status(404).json({ error: "Chapter not found" });
|
|
31929
33502
|
return;
|
|
31930
33503
|
}
|
|
31931
|
-
res.type("text/markdown").send(await
|
|
33504
|
+
res.type("text/markdown").send(await readFile11(file, "utf-8"));
|
|
31932
33505
|
});
|
|
31933
33506
|
app.get("/api/guide/assets/*path", (req, res) => {
|
|
31934
33507
|
const guide = session.guide();
|
|
@@ -32098,13 +33671,26 @@ var NO_TEAM_ID = {
|
|
|
32098
33671
|
renameSelf: "renameSelf renames the caller, whom the host resolves; it takes no teamId"
|
|
32099
33672
|
};
|
|
32100
33673
|
var FRAME_QUERIES = {
|
|
32101
|
-
game: /* @__PURE__ */ new Set([
|
|
32102
|
-
|
|
32103
|
-
|
|
33674
|
+
game: /* @__PURE__ */ new Set([
|
|
33675
|
+
"callEndpoint",
|
|
33676
|
+
"getPastState",
|
|
33677
|
+
"getAllTeamsParticipants",
|
|
33678
|
+
"getBenchmark",
|
|
33679
|
+
"getAssessment"
|
|
33680
|
+
]),
|
|
33681
|
+
"waiting-room": /* @__PURE__ */ new Set([
|
|
33682
|
+
"callEndpoint",
|
|
33683
|
+
"getPastState",
|
|
33684
|
+
"getAllTeamsParticipants",
|
|
33685
|
+
"getBenchmark",
|
|
33686
|
+
"getAssessment"
|
|
33687
|
+
]),
|
|
33688
|
+
session: /* @__PURE__ */ new Set(["callEndpoint", "getPastState", "getBenchmark", "getAssessment"]),
|
|
32104
33689
|
setup: /* @__PURE__ */ new Set(["callEndpoint"]),
|
|
32105
33690
|
"scenario-editor": /* @__PURE__ */ new Set(["callEndpoint"]),
|
|
32106
|
-
presentation: /* @__PURE__ */ new Set(["getPastState"])
|
|
33691
|
+
presentation: /* @__PURE__ */ new Set(["getPastState", "getBenchmark", "getAssessment"])
|
|
32107
33692
|
};
|
|
33693
|
+
var PLAYER_SURFACES = /* @__PURE__ */ new Set(["game", "waiting-room"]);
|
|
32108
33694
|
function teamScope(viewer) {
|
|
32109
33695
|
return viewer.teamIndex === void 0 ? {} : { teamIndex: viewer.teamIndex };
|
|
32110
33696
|
}
|
|
@@ -32253,7 +33839,7 @@ function commandFor(message, surface, viewer) {
|
|
|
32253
33839
|
return null;
|
|
32254
33840
|
}
|
|
32255
33841
|
}
|
|
32256
|
-
function queryFor(message, surface, viewer) {
|
|
33842
|
+
function queryFor(message, surface, viewer, { sessionless = false } = {}) {
|
|
32257
33843
|
if (!FRAME_QUERIES[surface.kind].has(message.type)) return null;
|
|
32258
33844
|
switch (message.type) {
|
|
32259
33845
|
case "callEndpoint":
|
|
@@ -32280,6 +33866,28 @@ function queryFor(message, surface, viewer) {
|
|
|
32280
33866
|
};
|
|
32281
33867
|
case "getAllTeamsParticipants":
|
|
32282
33868
|
return { type: "getAllTeamsParticipants", uiIdentifier: surface.identifier };
|
|
33869
|
+
case "getBenchmark":
|
|
33870
|
+
return {
|
|
33871
|
+
type: "getBenchmark",
|
|
33872
|
+
identifier: String(message.identifier),
|
|
33873
|
+
where: Array.isArray(message.where) ? message.where : []
|
|
33874
|
+
};
|
|
33875
|
+
// The audience is the host's to decide, from the surface and the viewer
|
|
33876
|
+
// it holds the render as, never from anything the page sends.
|
|
33877
|
+
case "getAssessment":
|
|
33878
|
+
if (sessionless) {
|
|
33879
|
+
return { refused: "A presentation shown without a session has no results to read" };
|
|
33880
|
+
}
|
|
33881
|
+
return {
|
|
33882
|
+
type: "getAssessment",
|
|
33883
|
+
identifier: String(message.identifier),
|
|
33884
|
+
...PLAYER_SURFACES.has(surface.kind) ? {
|
|
33885
|
+
audience: "own",
|
|
33886
|
+
...actorOf(viewer),
|
|
33887
|
+
...roleOf(viewer),
|
|
33888
|
+
...viewer.teamIndex === void 0 ? {} : { teamId: `team-${viewer.teamIndex + 1}` }
|
|
33889
|
+
} : { audience: "all" }
|
|
33890
|
+
};
|
|
32283
33891
|
default:
|
|
32284
33892
|
return null;
|
|
32285
33893
|
}
|
|
@@ -32461,6 +34069,8 @@ var DevShell = class {
|
|
|
32461
34069
|
socketRuns = /* @__PURE__ */ new WeakMap();
|
|
32462
34070
|
/** The participant an operator page says it is showing, where it shows one. */
|
|
32463
34071
|
socketPresence = /* @__PURE__ */ new Map();
|
|
34072
|
+
/** Console pages open, each of which keeps its run awake (§11.4a). */
|
|
34073
|
+
consoleSockets = /* @__PURE__ */ new Set();
|
|
32464
34074
|
options;
|
|
32465
34075
|
brands;
|
|
32466
34076
|
server = null;
|
|
@@ -32522,7 +34132,7 @@ var DevShell = class {
|
|
|
32522
34132
|
throw new Error(`No built surfaces at ${built}: build them first`);
|
|
32523
34133
|
}
|
|
32524
34134
|
if (this.options.isolated) {
|
|
32525
|
-
const dir = await mkdtemp2(
|
|
34135
|
+
const dir = await mkdtemp2(join21(tmpdir2(), "seriousgaming-dev-blobs-"));
|
|
32526
34136
|
this.isolatedBlobs = { dir, restore: redirectBlobs(this.options.packagePath, dir) };
|
|
32527
34137
|
}
|
|
32528
34138
|
try {
|
|
@@ -32611,9 +34221,9 @@ var DevShell = class {
|
|
|
32611
34221
|
return;
|
|
32612
34222
|
}
|
|
32613
34223
|
void this.walkthrough?.reloadBundles();
|
|
32614
|
-
void this.session.reloadBundles().then((
|
|
32615
|
-
this.record(
|
|
32616
|
-
reportReload(
|
|
34224
|
+
void this.session.reloadBundles().then((outcome3) => {
|
|
34225
|
+
this.record(outcome3);
|
|
34226
|
+
reportReload(outcome3);
|
|
32617
34227
|
});
|
|
32618
34228
|
}
|
|
32619
34229
|
/**
|
|
@@ -32654,10 +34264,10 @@ var DevShell = class {
|
|
|
32654
34264
|
}
|
|
32655
34265
|
}
|
|
32656
34266
|
/** Keep what a reload could not apply, for the next command to be told. */
|
|
32657
|
-
record(
|
|
32658
|
-
if (
|
|
32659
|
-
if (
|
|
32660
|
-
else for (const capability of
|
|
34267
|
+
record(outcome3) {
|
|
34268
|
+
if (outcome3.kind !== "failed") this.reloadFailure = null;
|
|
34269
|
+
if (outcome3.kind === "reinitialised") this.seeded.clear();
|
|
34270
|
+
else for (const capability of outcome3.added) this.seeded.add(capability);
|
|
32661
34271
|
}
|
|
32662
34272
|
/**
|
|
32663
34273
|
* Everything this server could not apply live to `run`, as it stands now:
|
|
@@ -32910,7 +34520,7 @@ Install the package's dependencies and restart.`
|
|
|
32910
34520
|
const slot2 = SURFACE_SLOT[kind2];
|
|
32911
34521
|
this.assetApp.use(
|
|
32912
34522
|
`${SURFACE_PREFIX[kind2]}/${slot2}`,
|
|
32913
|
-
express2.static(
|
|
34523
|
+
express2.static(join21(directory, slot2), { index: false })
|
|
32914
34524
|
);
|
|
32915
34525
|
}
|
|
32916
34526
|
this.assetApp.use((req, res) => {
|
|
@@ -33062,22 +34672,30 @@ Install the package's dependencies to serve its surfaces.
|
|
|
33062
34672
|
host: request.headers.host,
|
|
33063
34673
|
localOrigins: wantsLocalOrigins(location.search)
|
|
33064
34674
|
});
|
|
33065
|
-
void this.sendView(socket).then(() =>
|
|
34675
|
+
void this.sendView(socket).then(() => {
|
|
34676
|
+
this.syncPresence(route.run);
|
|
34677
|
+
this.syncOpenSurfaces(route.run);
|
|
34678
|
+
});
|
|
33066
34679
|
socket.on("message", (raw) => void this.receiveView(socket, raw));
|
|
33067
34680
|
socket.on("close", () => {
|
|
33068
34681
|
this.views.delete(socket);
|
|
33069
34682
|
this.syncPresence(route.run);
|
|
34683
|
+
this.syncOpenSurfaces(route.run);
|
|
33070
34684
|
});
|
|
33071
34685
|
});
|
|
33072
34686
|
this.sockets.on("connection", (socket, request) => {
|
|
33073
34687
|
const run = runFromUrl(request.url);
|
|
33074
34688
|
this.socketRuns.set(socket, run);
|
|
34689
|
+
this.consoleSockets.add(socket);
|
|
33075
34690
|
void this.runFor(run).then((session) => {
|
|
33076
34691
|
send(socket, { type: "state", state: session.project(), cause: "connected" });
|
|
34692
|
+
this.syncOpenSurfaces(run);
|
|
33077
34693
|
});
|
|
33078
34694
|
socket.on("message", (raw) => void this.receive(socket, raw));
|
|
33079
34695
|
socket.on("close", () => {
|
|
34696
|
+
this.consoleSockets.delete(socket);
|
|
33080
34697
|
if (this.socketPresence.delete(socket)) this.syncPresence(run);
|
|
34698
|
+
this.syncOpenSurfaces(run);
|
|
33081
34699
|
});
|
|
33082
34700
|
});
|
|
33083
34701
|
}
|
|
@@ -33207,6 +34825,23 @@ Install the package's dependencies to serve its surfaces.
|
|
|
33207
34825
|
}
|
|
33208
34826
|
session.syncPresence(present);
|
|
33209
34827
|
}
|
|
34828
|
+
/**
|
|
34829
|
+
* Tell a run how many pages are open on it, console and viewer alike.
|
|
34830
|
+
* Opening one is activity, and the dev server keeps a run with any open
|
|
34831
|
+
* awake (§11.4a), which the specification leaves to the host.
|
|
34832
|
+
*/
|
|
34833
|
+
syncOpenSurfaces(run) {
|
|
34834
|
+
const session = run === "walkthrough" ? this.walkthrough : this.session;
|
|
34835
|
+
if (!session) return;
|
|
34836
|
+
let count = 0;
|
|
34837
|
+
for (const socket of this.consoleSockets) {
|
|
34838
|
+
if ((this.socketRuns.get(socket) ?? "session") === run) count += 1;
|
|
34839
|
+
}
|
|
34840
|
+
for (const view of this.views.values()) {
|
|
34841
|
+
if (view.route.run === run) count += 1;
|
|
34842
|
+
}
|
|
34843
|
+
session.syncOpenSurfaces(count);
|
|
34844
|
+
}
|
|
33210
34845
|
updateViews(event, run) {
|
|
33211
34846
|
if (event.type === "round-processing") {
|
|
33212
34847
|
const teams = this.processing.get(run) ?? /* @__PURE__ */ new Set();
|
|
@@ -33337,28 +34972,28 @@ Install the package's dependencies to serve its surfaces.
|
|
|
33337
34972
|
);
|
|
33338
34973
|
}
|
|
33339
34974
|
};
|
|
33340
|
-
function reportReload(
|
|
33341
|
-
switch (
|
|
34975
|
+
function reportReload(outcome3) {
|
|
34976
|
+
switch (outcome3.kind) {
|
|
33342
34977
|
case "failed":
|
|
33343
34978
|
return;
|
|
33344
34979
|
case "reinitialised":
|
|
33345
|
-
if (hasPendingChanges(
|
|
34980
|
+
if (hasPendingChanges(outcome3.pending)) {
|
|
33346
34981
|
logger.success(
|
|
33347
|
-
`${describePendingChanges(
|
|
34982
|
+
`${describePendingChanges(outcome3.pending)}. Re-initialised the session at tick 0 to apply it.`
|
|
33348
34983
|
);
|
|
33349
34984
|
}
|
|
33350
|
-
for (const capability of
|
|
34985
|
+
for (const capability of outcome3.added) {
|
|
33351
34986
|
logger.success(
|
|
33352
34987
|
`Capability "${capability}" added. Re-initialised the session at tick 0 so Init runs for it.`
|
|
33353
34988
|
);
|
|
33354
34989
|
}
|
|
33355
|
-
if (!hasPendingChanges(
|
|
34990
|
+
if (!hasPendingChanges(outcome3.pending) && outcome3.added.length === 0) {
|
|
33356
34991
|
logger.success("Package changed; re-initialised the session at tick 0.");
|
|
33357
34992
|
}
|
|
33358
34993
|
return;
|
|
33359
34994
|
case "pending":
|
|
33360
34995
|
logger.warn(
|
|
33361
|
-
`${pendingHeadline(
|
|
34996
|
+
`${pendingHeadline(outcome3.pending)}. ${describePendingChanges(outcome3.pending)}.
|
|
33362
34997
|
` + PENDING_CHANGES_HINT
|
|
33363
34998
|
);
|
|
33364
34999
|
break;
|
|
@@ -33366,7 +35001,7 @@ function reportReload(outcome) {
|
|
|
33366
35001
|
logger.success("Package changed; the session uses it from here.");
|
|
33367
35002
|
break;
|
|
33368
35003
|
}
|
|
33369
|
-
for (const capability of
|
|
35004
|
+
for (const capability of outcome3.added) logger.warn(seededMessage(capability));
|
|
33370
35005
|
}
|
|
33371
35006
|
function buildErrorLine(error) {
|
|
33372
35007
|
const at = diagnosticLocation(error);
|
|
@@ -33447,11 +35082,11 @@ async function startDevServer(options) {
|
|
|
33447
35082
|
// cli/client/build-surfaces.ts
|
|
33448
35083
|
import { mkdtemp as mkdtemp3, rm as rm6 } from "fs/promises";
|
|
33449
35084
|
import { tmpdir as tmpdir3 } from "os";
|
|
33450
|
-
import { join as
|
|
35085
|
+
import { join as join23 } from "path";
|
|
33451
35086
|
|
|
33452
35087
|
// cli/bundling/ui-bundler.ts
|
|
33453
35088
|
import { realpathSync as realpathSync3 } from "fs";
|
|
33454
|
-
import { join as
|
|
35089
|
+
import { join as join22, resolve as resolve12 } from "path";
|
|
33455
35090
|
import react2 from "@vitejs/plugin-react";
|
|
33456
35091
|
import { build, loadConfigFromFile, mergeConfig } from "vite";
|
|
33457
35092
|
|
|
@@ -33473,8 +35108,8 @@ var REACT_CONTEXT_PACKAGES = [
|
|
|
33473
35108
|
|
|
33474
35109
|
// cli/bundling/ui-bundler.ts
|
|
33475
35110
|
async function bundleUserInterface(ui, workingDir, buildDir, type) {
|
|
33476
|
-
const uiOutputDir =
|
|
33477
|
-
const uiRootDir =
|
|
35111
|
+
const uiOutputDir = join22(buildDir, distPath(getResourceMeta(type), ui.definition.identifier));
|
|
35112
|
+
const uiRootDir = join22(workingDir, ui.rootDirectory);
|
|
33478
35113
|
const uiDir = realpathSync3(uiRootDir);
|
|
33479
35114
|
logger.debug(`Building ${ui.definition.identifier}...`);
|
|
33480
35115
|
const isVerbose2 = getVerboseMode();
|
|
@@ -33533,8 +35168,8 @@ var SURFACE_SLOTS = [
|
|
|
33533
35168
|
"presentation"
|
|
33534
35169
|
];
|
|
33535
35170
|
async function buildSurfaces(options) {
|
|
33536
|
-
const config = await loadConfig(
|
|
33537
|
-
const directory = options.outDir ?? await mkdtemp3(
|
|
35171
|
+
const config = await loadConfig(join23(options.packagePath, "seriousgaming.sdk.json"));
|
|
35172
|
+
const directory = options.outDir ?? await mkdtemp3(join23(tmpdir3(), "seriousgaming-surfaces-"));
|
|
33538
35173
|
const remove = () => rm6(directory, { recursive: true, force: true });
|
|
33539
35174
|
try {
|
|
33540
35175
|
for (const slot2 of SURFACE_SLOTS) {
|