@gameslate/sdk 0.3.30 → 0.3.32
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/README.md +8 -0
- package/lib/assets.d.ts +103 -68
- package/lib/assets.js +8 -0
- package/lib/catalogue.d.ts +44 -42
- package/lib/catalogue.js +5 -1
- package/lib/game-support-limitations.d.ts +2 -0
- package/lib/game-support-limitations.js +70 -0
- package/lib/game-support.d.ts +1 -1
- package/lib/game-support.js +3 -1
- package/lib/host/live-sandbox.js +15 -11
- package/lib/host/quickjs-guest.d.ts +4 -0
- package/lib/host/quickjs-guest.js +13 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/mission-labels.d.ts +43 -0
- package/lib/mission-labels.js +69 -0
- package/lib/pack.d.ts +107 -98
- package/lib/pack.js +12 -5
- package/lib/plugin/sandbox-guest.js +18 -1
- package/lib/plugins-api.d.ts +2 -2
- package/lib/registry.d.ts +136 -136
- package/lib/sandbox-protocol.d.ts +67 -66
- package/package.json +1 -1
- package/template/claude/skills/build-gameslate-plugin/SKILL.md +232 -8
- package/template/claude/skills/verify-gameslate-plugin/SKILL.md +29 -1
package/lib/catalogue.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { Condition } from './condition.js';
|
|
3
|
+
/** A catalogue id: an item, counter, mission, … */
|
|
4
|
+
export declare const CatalogueIdSchema: z.ZodString;
|
|
3
5
|
export declare const ItemSchema: z.ZodObject<{
|
|
4
6
|
id: z.ZodString;
|
|
5
7
|
label: z.ZodString;
|
|
@@ -49,17 +51,17 @@ export declare const CounterSchema: z.ZodObject<{
|
|
|
49
51
|
id: string;
|
|
50
52
|
icon?: string | undefined;
|
|
51
53
|
max?: string | number | undefined;
|
|
52
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
53
54
|
display?: Record<string, string> | undefined;
|
|
54
55
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
56
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
55
57
|
}, {
|
|
56
58
|
label: string;
|
|
57
59
|
id: string;
|
|
58
60
|
icon?: string | undefined;
|
|
59
61
|
max?: string | number | undefined;
|
|
60
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
61
62
|
display?: Record<string, string> | undefined;
|
|
62
63
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
64
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
63
65
|
}>;
|
|
64
66
|
export type CatalogueCounter = z.infer<typeof CounterSchema>;
|
|
65
67
|
export type CounterRole = NonNullable<CatalogueCounter['role']>;
|
|
@@ -232,9 +234,9 @@ export declare const ReferenceEntrySchema: z.ZodObject<{
|
|
|
232
234
|
}, "strict", z.ZodTypeAny, {
|
|
233
235
|
id: string;
|
|
234
236
|
title: string;
|
|
235
|
-
notes?: string[] | undefined;
|
|
236
237
|
badge?: string | undefined;
|
|
237
238
|
sequence?: string[] | undefined;
|
|
239
|
+
notes?: string[] | undefined;
|
|
238
240
|
rows?: {
|
|
239
241
|
label: string;
|
|
240
242
|
detail: string;
|
|
@@ -243,9 +245,9 @@ export declare const ReferenceEntrySchema: z.ZodObject<{
|
|
|
243
245
|
}, {
|
|
244
246
|
id: string;
|
|
245
247
|
title: string;
|
|
246
|
-
notes?: string[] | undefined;
|
|
247
248
|
badge?: string | undefined;
|
|
248
249
|
sequence?: string[] | undefined;
|
|
250
|
+
notes?: string[] | undefined;
|
|
249
251
|
rows?: {
|
|
250
252
|
label: string;
|
|
251
253
|
detail: string;
|
|
@@ -280,9 +282,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
280
282
|
}, "strict", z.ZodTypeAny, {
|
|
281
283
|
id: string;
|
|
282
284
|
title: string;
|
|
283
|
-
notes?: string[] | undefined;
|
|
284
285
|
badge?: string | undefined;
|
|
285
286
|
sequence?: string[] | undefined;
|
|
287
|
+
notes?: string[] | undefined;
|
|
286
288
|
rows?: {
|
|
287
289
|
label: string;
|
|
288
290
|
detail: string;
|
|
@@ -291,9 +293,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
291
293
|
}, {
|
|
292
294
|
id: string;
|
|
293
295
|
title: string;
|
|
294
|
-
notes?: string[] | undefined;
|
|
295
296
|
badge?: string | undefined;
|
|
296
297
|
sequence?: string[] | undefined;
|
|
298
|
+
notes?: string[] | undefined;
|
|
297
299
|
rows?: {
|
|
298
300
|
label: string;
|
|
299
301
|
detail: string;
|
|
@@ -304,9 +306,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
304
306
|
entries: {
|
|
305
307
|
id: string;
|
|
306
308
|
title: string;
|
|
307
|
-
notes?: string[] | undefined;
|
|
308
309
|
badge?: string | undefined;
|
|
309
310
|
sequence?: string[] | undefined;
|
|
311
|
+
notes?: string[] | undefined;
|
|
310
312
|
rows?: {
|
|
311
313
|
label: string;
|
|
312
314
|
detail: string;
|
|
@@ -321,9 +323,9 @@ export declare const ReferenceSectionSchema: z.ZodObject<{
|
|
|
321
323
|
entries: {
|
|
322
324
|
id: string;
|
|
323
325
|
title: string;
|
|
324
|
-
notes?: string[] | undefined;
|
|
325
326
|
badge?: string | undefined;
|
|
326
327
|
sequence?: string[] | undefined;
|
|
328
|
+
notes?: string[] | undefined;
|
|
327
329
|
rows?: {
|
|
328
330
|
label: string;
|
|
329
331
|
detail: string;
|
|
@@ -353,16 +355,16 @@ export declare const CollectibleEntrySchema: z.ZodObject<{
|
|
|
353
355
|
name: string;
|
|
354
356
|
locationId?: string | undefined;
|
|
355
357
|
pinId?: string | undefined;
|
|
356
|
-
collectedBy?: Condition | undefined;
|
|
357
358
|
locationName?: string | undefined;
|
|
359
|
+
collectedBy?: Condition | undefined;
|
|
358
360
|
needs?: string[][] | undefined;
|
|
359
361
|
}, {
|
|
360
362
|
id: string;
|
|
361
363
|
name: string;
|
|
362
364
|
locationId?: string | undefined;
|
|
363
365
|
pinId?: string | undefined;
|
|
364
|
-
collectedBy?: Condition | undefined;
|
|
365
366
|
locationName?: string | undefined;
|
|
367
|
+
collectedBy?: Condition | undefined;
|
|
366
368
|
needs?: string[][] | undefined;
|
|
367
369
|
}>;
|
|
368
370
|
export type CollectibleEntry = z.infer<typeof CollectibleEntrySchema>;
|
|
@@ -392,16 +394,16 @@ export declare const CollectibleSetSchema: z.ZodObject<{
|
|
|
392
394
|
name: string;
|
|
393
395
|
locationId?: string | undefined;
|
|
394
396
|
pinId?: string | undefined;
|
|
395
|
-
collectedBy?: Condition | undefined;
|
|
396
397
|
locationName?: string | undefined;
|
|
398
|
+
collectedBy?: Condition | undefined;
|
|
397
399
|
needs?: string[][] | undefined;
|
|
398
400
|
}, {
|
|
399
401
|
id: string;
|
|
400
402
|
name: string;
|
|
401
403
|
locationId?: string | undefined;
|
|
402
404
|
pinId?: string | undefined;
|
|
403
|
-
collectedBy?: Condition | undefined;
|
|
404
405
|
locationName?: string | undefined;
|
|
406
|
+
collectedBy?: Condition | undefined;
|
|
405
407
|
needs?: string[][] | undefined;
|
|
406
408
|
}>, "many">>;
|
|
407
409
|
/** …or loaded at runtime from a locally generated file (`local-assets/<game>/<file>`) */
|
|
@@ -425,8 +427,8 @@ export declare const CollectibleSetSchema: z.ZodObject<{
|
|
|
425
427
|
name: string;
|
|
426
428
|
locationId?: string | undefined;
|
|
427
429
|
pinId?: string | undefined;
|
|
428
|
-
collectedBy?: Condition | undefined;
|
|
429
430
|
locationName?: string | undefined;
|
|
431
|
+
collectedBy?: Condition | undefined;
|
|
430
432
|
needs?: string[][] | undefined;
|
|
431
433
|
}[] | undefined;
|
|
432
434
|
counter?: string | undefined;
|
|
@@ -444,8 +446,8 @@ export declare const CollectibleSetSchema: z.ZodObject<{
|
|
|
444
446
|
name: string;
|
|
445
447
|
locationId?: string | undefined;
|
|
446
448
|
pinId?: string | undefined;
|
|
447
|
-
collectedBy?: Condition | undefined;
|
|
448
449
|
locationName?: string | undefined;
|
|
450
|
+
collectedBy?: Condition | undefined;
|
|
449
451
|
needs?: string[][] | undefined;
|
|
450
452
|
}[] | undefined;
|
|
451
453
|
counter?: string | undefined;
|
|
@@ -640,17 +642,17 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
640
642
|
id: string;
|
|
641
643
|
icon?: string | undefined;
|
|
642
644
|
max?: string | number | undefined;
|
|
643
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
644
645
|
display?: Record<string, string> | undefined;
|
|
645
646
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
647
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
646
648
|
}, {
|
|
647
649
|
label: string;
|
|
648
650
|
id: string;
|
|
649
651
|
icon?: string | undefined;
|
|
650
652
|
max?: string | number | undefined;
|
|
651
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
652
653
|
display?: Record<string, string> | undefined;
|
|
653
654
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
655
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
654
656
|
}>, "many">;
|
|
655
657
|
/** flag sets the pack's decoder streams (bit conditions may only reference these) */
|
|
656
658
|
flagSets: z.ZodArray<z.ZodString, "many">;
|
|
@@ -797,16 +799,16 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
797
799
|
name: string;
|
|
798
800
|
locationId?: string | undefined;
|
|
799
801
|
pinId?: string | undefined;
|
|
800
|
-
collectedBy?: Condition | undefined;
|
|
801
802
|
locationName?: string | undefined;
|
|
803
|
+
collectedBy?: Condition | undefined;
|
|
802
804
|
needs?: string[][] | undefined;
|
|
803
805
|
}, {
|
|
804
806
|
id: string;
|
|
805
807
|
name: string;
|
|
806
808
|
locationId?: string | undefined;
|
|
807
809
|
pinId?: string | undefined;
|
|
808
|
-
collectedBy?: Condition | undefined;
|
|
809
810
|
locationName?: string | undefined;
|
|
811
|
+
collectedBy?: Condition | undefined;
|
|
810
812
|
needs?: string[][] | undefined;
|
|
811
813
|
}>, "many">>;
|
|
812
814
|
/** …or loaded at runtime from a locally generated file (`local-assets/<game>/<file>`) */
|
|
@@ -830,8 +832,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
830
832
|
name: string;
|
|
831
833
|
locationId?: string | undefined;
|
|
832
834
|
pinId?: string | undefined;
|
|
833
|
-
collectedBy?: Condition | undefined;
|
|
834
835
|
locationName?: string | undefined;
|
|
836
|
+
collectedBy?: Condition | undefined;
|
|
835
837
|
needs?: string[][] | undefined;
|
|
836
838
|
}[] | undefined;
|
|
837
839
|
counter?: string | undefined;
|
|
@@ -849,8 +851,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
849
851
|
name: string;
|
|
850
852
|
locationId?: string | undefined;
|
|
851
853
|
pinId?: string | undefined;
|
|
852
|
-
collectedBy?: Condition | undefined;
|
|
853
854
|
locationName?: string | undefined;
|
|
855
|
+
collectedBy?: Condition | undefined;
|
|
854
856
|
needs?: string[][] | undefined;
|
|
855
857
|
}[] | undefined;
|
|
856
858
|
counter?: string | undefined;
|
|
@@ -886,9 +888,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
886
888
|
}, "strict", z.ZodTypeAny, {
|
|
887
889
|
id: string;
|
|
888
890
|
title: string;
|
|
889
|
-
notes?: string[] | undefined;
|
|
890
891
|
badge?: string | undefined;
|
|
891
892
|
sequence?: string[] | undefined;
|
|
893
|
+
notes?: string[] | undefined;
|
|
892
894
|
rows?: {
|
|
893
895
|
label: string;
|
|
894
896
|
detail: string;
|
|
@@ -897,9 +899,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
897
899
|
}, {
|
|
898
900
|
id: string;
|
|
899
901
|
title: string;
|
|
900
|
-
notes?: string[] | undefined;
|
|
901
902
|
badge?: string | undefined;
|
|
902
903
|
sequence?: string[] | undefined;
|
|
904
|
+
notes?: string[] | undefined;
|
|
903
905
|
rows?: {
|
|
904
906
|
label: string;
|
|
905
907
|
detail: string;
|
|
@@ -910,9 +912,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
910
912
|
entries: {
|
|
911
913
|
id: string;
|
|
912
914
|
title: string;
|
|
913
|
-
notes?: string[] | undefined;
|
|
914
915
|
badge?: string | undefined;
|
|
915
916
|
sequence?: string[] | undefined;
|
|
917
|
+
notes?: string[] | undefined;
|
|
916
918
|
rows?: {
|
|
917
919
|
label: string;
|
|
918
920
|
detail: string;
|
|
@@ -927,9 +929,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
927
929
|
entries: {
|
|
928
930
|
id: string;
|
|
929
931
|
title: string;
|
|
930
|
-
notes?: string[] | undefined;
|
|
931
932
|
badge?: string | undefined;
|
|
932
933
|
sequence?: string[] | undefined;
|
|
934
|
+
notes?: string[] | undefined;
|
|
933
935
|
rows?: {
|
|
934
936
|
label: string;
|
|
935
937
|
detail: string;
|
|
@@ -1090,9 +1092,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1090
1092
|
id: string;
|
|
1091
1093
|
icon?: string | undefined;
|
|
1092
1094
|
max?: string | number | undefined;
|
|
1093
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
1094
1095
|
display?: Record<string, string> | undefined;
|
|
1095
1096
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1097
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1096
1098
|
}[];
|
|
1097
1099
|
flagSets: string[];
|
|
1098
1100
|
items: {
|
|
@@ -1104,12 +1106,6 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1104
1106
|
short?: string | undefined;
|
|
1105
1107
|
count?: string | undefined;
|
|
1106
1108
|
}[];
|
|
1107
|
-
chips: {
|
|
1108
|
-
label: string;
|
|
1109
|
-
id: string;
|
|
1110
|
-
prompt: string;
|
|
1111
|
-
when?: Condition | undefined;
|
|
1112
|
-
}[];
|
|
1113
1109
|
inventoryLayouts: ({
|
|
1114
1110
|
id: string;
|
|
1115
1111
|
title: string;
|
|
@@ -1153,8 +1149,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1153
1149
|
name: string;
|
|
1154
1150
|
locationId?: string | undefined;
|
|
1155
1151
|
pinId?: string | undefined;
|
|
1156
|
-
collectedBy?: Condition | undefined;
|
|
1157
1152
|
locationName?: string | undefined;
|
|
1153
|
+
collectedBy?: Condition | undefined;
|
|
1158
1154
|
needs?: string[][] | undefined;
|
|
1159
1155
|
}[] | undefined;
|
|
1160
1156
|
counter?: string | undefined;
|
|
@@ -1167,9 +1163,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1167
1163
|
entries: {
|
|
1168
1164
|
id: string;
|
|
1169
1165
|
title: string;
|
|
1170
|
-
notes?: string[] | undefined;
|
|
1171
1166
|
badge?: string | undefined;
|
|
1172
1167
|
sequence?: string[] | undefined;
|
|
1168
|
+
notes?: string[] | undefined;
|
|
1173
1169
|
rows?: {
|
|
1174
1170
|
label: string;
|
|
1175
1171
|
detail: string;
|
|
@@ -1181,6 +1177,12 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1181
1177
|
badge?: string | undefined;
|
|
1182
1178
|
defaultOpen?: boolean | undefined;
|
|
1183
1179
|
}[];
|
|
1180
|
+
chips: {
|
|
1181
|
+
label: string;
|
|
1182
|
+
id: string;
|
|
1183
|
+
prompt: string;
|
|
1184
|
+
when?: Condition | undefined;
|
|
1185
|
+
}[];
|
|
1184
1186
|
pinRules: {
|
|
1185
1187
|
id: string;
|
|
1186
1188
|
match: {
|
|
@@ -1212,9 +1214,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1212
1214
|
id: string;
|
|
1213
1215
|
icon?: string | undefined;
|
|
1214
1216
|
max?: string | number | undefined;
|
|
1215
|
-
format?: "number" | "duration" | "percent" | undefined;
|
|
1216
1217
|
display?: Record<string, string> | undefined;
|
|
1217
1218
|
role?: "keys" | "health" | "magic" | "armor" | undefined;
|
|
1219
|
+
format?: "number" | "duration" | "percent" | undefined;
|
|
1218
1220
|
}[];
|
|
1219
1221
|
flagSets: string[];
|
|
1220
1222
|
items: {
|
|
@@ -1226,12 +1228,6 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1226
1228
|
short?: string | undefined;
|
|
1227
1229
|
count?: string | undefined;
|
|
1228
1230
|
}[];
|
|
1229
|
-
chips: {
|
|
1230
|
-
label: string;
|
|
1231
|
-
id: string;
|
|
1232
|
-
prompt: string;
|
|
1233
|
-
when?: Condition | undefined;
|
|
1234
|
-
}[];
|
|
1235
1231
|
inventoryLayouts: ({
|
|
1236
1232
|
id: string;
|
|
1237
1233
|
title: string;
|
|
@@ -1275,8 +1271,8 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1275
1271
|
name: string;
|
|
1276
1272
|
locationId?: string | undefined;
|
|
1277
1273
|
pinId?: string | undefined;
|
|
1278
|
-
collectedBy?: Condition | undefined;
|
|
1279
1274
|
locationName?: string | undefined;
|
|
1275
|
+
collectedBy?: Condition | undefined;
|
|
1280
1276
|
needs?: string[][] | undefined;
|
|
1281
1277
|
}[] | undefined;
|
|
1282
1278
|
counter?: string | undefined;
|
|
@@ -1289,9 +1285,9 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1289
1285
|
entries: {
|
|
1290
1286
|
id: string;
|
|
1291
1287
|
title: string;
|
|
1292
|
-
notes?: string[] | undefined;
|
|
1293
1288
|
badge?: string | undefined;
|
|
1294
1289
|
sequence?: string[] | undefined;
|
|
1290
|
+
notes?: string[] | undefined;
|
|
1295
1291
|
rows?: {
|
|
1296
1292
|
label: string;
|
|
1297
1293
|
detail: string;
|
|
@@ -1303,6 +1299,12 @@ export declare const CatalogueSchema: z.ZodObject<{
|
|
|
1303
1299
|
badge?: string | undefined;
|
|
1304
1300
|
defaultOpen?: boolean | undefined;
|
|
1305
1301
|
}[];
|
|
1302
|
+
chips: {
|
|
1303
|
+
label: string;
|
|
1304
|
+
id: string;
|
|
1305
|
+
prompt: string;
|
|
1306
|
+
when?: Condition | undefined;
|
|
1307
|
+
}[];
|
|
1306
1308
|
pinRules: {
|
|
1307
1309
|
id: string;
|
|
1308
1310
|
match: {
|
package/lib/catalogue.js
CHANGED
|
@@ -5,7 +5,11 @@ import { collectReferences, ConditionSchema } from './condition.js';
|
|
|
5
5
|
* (.claude/rules/game-packs.md). Every status in it is a Condition; the UI renders it without
|
|
6
6
|
* knowing which game it is.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
/** A catalogue id: an item, counter, mission, … */
|
|
9
|
+
export const CatalogueIdSchema = z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[A-Za-z0-9_:.-]+$/, 'ids are letters, digits and _ : . - only');
|
|
12
|
+
const Id = CatalogueIdSchema;
|
|
9
13
|
export const ItemSchema = z
|
|
10
14
|
.object({
|
|
11
15
|
id: Id,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The per-game README's `## Limitations` section: what a player will find incomplete or wrong,
|
|
3
|
+
* one labelled bullet per limitation, so every game's list reads the same way.
|
|
4
|
+
*/
|
|
5
|
+
const LIMITATIONS_HEADING = '## Limitations';
|
|
6
|
+
/* every top-level Limitations bullet opens with one of these, in this order (player's view first) */
|
|
7
|
+
const LIMITATION_LABELS = [
|
|
8
|
+
'**Not tracked:**',
|
|
9
|
+
'**Not shown:**',
|
|
10
|
+
'**Can be wrong:**',
|
|
11
|
+
'**Not supported:**',
|
|
12
|
+
];
|
|
13
|
+
/* Markdown's top level: up to 3 spaces before the marker; numbered items count too */
|
|
14
|
+
const TOP_LEVEL_BULLET = /^ {0,3}(?:[-*+]|\d+[.)])\s+(.*)$/;
|
|
15
|
+
/* `* * *`, `---`: a divider, not a bullet */
|
|
16
|
+
const THEMATIC_BREAK = /^ {0,3}([-*_])( *\1){2,} *$/;
|
|
17
|
+
const FENCE = /^ {0,3}(```|~~~)/;
|
|
18
|
+
const SECTION_END = /^ {0,3}#{1,2}\s/;
|
|
19
|
+
/* the top-level bullets between `## Limitations` and the next heading of level 1 or 2, outside
|
|
20
|
+
* code fences; undefined when there is no such section */
|
|
21
|
+
function findLimitationsBullets(body) {
|
|
22
|
+
const lines = body.split(/\r?\n/);
|
|
23
|
+
const start = lines.findIndex(l => l.trimEnd() === LIMITATIONS_HEADING);
|
|
24
|
+
if (start < 0)
|
|
25
|
+
return undefined;
|
|
26
|
+
const bullets = [];
|
|
27
|
+
let inFence = false;
|
|
28
|
+
for (const line of lines.slice(start + 1)) {
|
|
29
|
+
if (FENCE.test(line))
|
|
30
|
+
inFence = !inFence;
|
|
31
|
+
else if (inFence)
|
|
32
|
+
continue;
|
|
33
|
+
else if (SECTION_END.test(line))
|
|
34
|
+
break;
|
|
35
|
+
else if (!THEMATIC_BREAK.test(line)) {
|
|
36
|
+
const text = TOP_LEVEL_BULLET.exec(line)?.[1];
|
|
37
|
+
if (text !== undefined)
|
|
38
|
+
bullets.push(text);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return bullets;
|
|
42
|
+
}
|
|
43
|
+
/** Checks the Limitations section's shape: labelled top-level bullets, labels in order. */
|
|
44
|
+
export function checkLimitationsSection(body, problems) {
|
|
45
|
+
const bullets = findLimitationsBullets(body);
|
|
46
|
+
if (bullets === undefined)
|
|
47
|
+
return;
|
|
48
|
+
const labelList = LIMITATION_LABELS.join(', ');
|
|
49
|
+
if (bullets.length === 0) {
|
|
50
|
+
problems.push(`section "${LIMITATIONS_HEADING}" has no bullets: start each with ${labelList}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let lastRank = 0;
|
|
54
|
+
bullets.forEach((text, i) => {
|
|
55
|
+
const rank = LIMITATION_LABELS.findIndex(label => text.startsWith(label));
|
|
56
|
+
const label = LIMITATION_LABELS[rank];
|
|
57
|
+
if (label === undefined) {
|
|
58
|
+
problems.push(`"${LIMITATIONS_HEADING}" bullet ${i + 1} doesn't start with ${labelList}: "${text.slice(0, 40)}"`);
|
|
59
|
+
}
|
|
60
|
+
else if (text.slice(label.length).trim() === '') {
|
|
61
|
+
problems.push(`"${LIMITATIONS_HEADING}" bullet ${i + 1} (${label}) says nothing after its label`);
|
|
62
|
+
}
|
|
63
|
+
else if (rank < lastRank) {
|
|
64
|
+
problems.push(`"${LIMITATIONS_HEADING}" bullet ${i + 1} (${label}) comes after ${LIMITATION_LABELS[lastRank]}: keep the labels in the order ${labelList}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
lastRank = rank;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
package/lib/game-support.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { GamePack } from './pack.js';
|
|
|
4
4
|
import { type GameManifest } from './registry.js';
|
|
5
5
|
export declare const SUPPORT_TABLE_START = "<!-- gameslate:support-table:start -->";
|
|
6
6
|
export declare const SUPPORT_TABLE_END = "<!-- gameslate:support-table:end -->";
|
|
7
|
-
export declare const REQUIRED_SUPPORT_HEADINGS: readonly ["## Builds & Asset Extraction", "## Map", "## Vitals, Inventory, Missions & Reference", "##
|
|
7
|
+
export declare const REQUIRED_SUPPORT_HEADINGS: readonly ["## Builds & Asset Extraction", "## Map", "## Vitals, Inventory, Missions & Reference", "## Limitations", "## Verification"];
|
|
8
8
|
export declare const SupportBuildSchema: z.ZodObject<{
|
|
9
9
|
id: z.ZodString;
|
|
10
10
|
label: z.ZodString;
|
package/lib/game-support.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { checkLimitationsSection } from './game-support-limitations.js';
|
|
2
3
|
import { parseSupportYaml } from './game-support-yaml.js';
|
|
3
4
|
import { pinRuleMatchesAt } from './pins.js';
|
|
4
5
|
import { effectiveLandmarkKind } from './registry.js';
|
|
@@ -13,7 +14,7 @@ export const REQUIRED_SUPPORT_HEADINGS = [
|
|
|
13
14
|
'## Builds & Asset Extraction',
|
|
14
15
|
'## Map',
|
|
15
16
|
'## Vitals, Inventory, Missions & Reference',
|
|
16
|
-
'##
|
|
17
|
+
'## Limitations',
|
|
17
18
|
'## Verification',
|
|
18
19
|
];
|
|
19
20
|
export const SupportBuildSchema = z.object({
|
|
@@ -121,6 +122,7 @@ export function parseGameSupportReadme(markdown) {
|
|
|
121
122
|
lastPos = hm.index;
|
|
122
123
|
}
|
|
123
124
|
}
|
|
125
|
+
checkLimitationsSection(body, problems);
|
|
124
126
|
return { support: parsed.data, body, problems };
|
|
125
127
|
}
|
|
126
128
|
/* a pin the app can mark collected or done from its own fields (web llm.ts `isLandmarkCollected`) */
|
package/lib/host/live-sandbox.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SignatureSchema, GameStateSchema, PackViewsSchema, SandboxDescriptionSchema, } from '../index.js';
|
|
2
|
-
import { errorText, QuickJsGuest } from './quickjs-guest.js';
|
|
2
|
+
import { errorText, monotonicMs, QuickJsGuest } from './quickjs-guest.js';
|
|
3
3
|
export { loadQuickJs } from './quickjs-guest.js';
|
|
4
4
|
/*
|
|
5
5
|
* The live sandbox (docs/plugin-architecture.md § The sandbox): each plugin's live code (packs and
|
|
@@ -28,6 +28,8 @@ export const SANDBOX_LIMITS = {
|
|
|
28
28
|
/** each WebAssembly module's memory (live code's modules import nothing else) */
|
|
29
29
|
wasmMemoryBytes: 16 * 1024 * 1024,
|
|
30
30
|
};
|
|
31
|
+
/* the daemon always passes a context; a caller without one (a test) means no labels */
|
|
32
|
+
const labelsOf = (context) => context?.missionLabels ?? {};
|
|
31
33
|
/** One plugin's live code in its own runtime. */
|
|
32
34
|
export class PluginSandbox {
|
|
33
35
|
quickJs;
|
|
@@ -48,7 +50,7 @@ export class PluginSandbox {
|
|
|
48
50
|
this.code = code;
|
|
49
51
|
this.name = name;
|
|
50
52
|
this.log = opts.log;
|
|
51
|
-
this.now = opts.now ??
|
|
53
|
+
this.now = opts.now ?? monotonicMs;
|
|
52
54
|
this.wasm = opts.wasm ?? [];
|
|
53
55
|
this.guest = this.newGuest();
|
|
54
56
|
}
|
|
@@ -68,6 +70,7 @@ export class PluginSandbox {
|
|
|
68
70
|
maxReadBytes: SANDBOX_LIMITS.maxReadBytes,
|
|
69
71
|
},
|
|
70
72
|
log,
|
|
73
|
+
now: this.now,
|
|
71
74
|
});
|
|
72
75
|
}
|
|
73
76
|
/* A fresh runtime for a plugin that broke a limit, unless it has used up its restarts. Its
|
|
@@ -122,13 +125,13 @@ export class PluginSandbox {
|
|
|
122
125
|
};
|
|
123
126
|
}
|
|
124
127
|
pack(data) {
|
|
125
|
-
const views = (state) => this.views(data.id, state);
|
|
128
|
+
const views = (state, labels) => this.views(data.id, state, labels);
|
|
126
129
|
return {
|
|
127
130
|
...data,
|
|
128
|
-
describeState: state => views(state).facts,
|
|
131
|
+
describeState: (state, context) => views(state, labelsOf(context)).facts,
|
|
129
132
|
ui: {
|
|
130
|
-
statusStrip: state => views(state).statusStrip,
|
|
131
|
-
timelines: state => views(state).timelines,
|
|
133
|
+
statusStrip: (state, context) => views(state, labelsOf(context)).statusStrip,
|
|
134
|
+
timelines: (state, context) => views(state, labelsOf(context)).timelines,
|
|
132
135
|
},
|
|
133
136
|
};
|
|
134
137
|
}
|
|
@@ -200,15 +203,16 @@ export class PluginSandbox {
|
|
|
200
203
|
}
|
|
201
204
|
return parsed.data;
|
|
202
205
|
}
|
|
203
|
-
views(gameId, state) {
|
|
206
|
+
views(gameId, state, missionLabels) {
|
|
207
|
+
const labels = JSON.stringify(missionLabels);
|
|
204
208
|
const cached = this.viewsCache.get(state);
|
|
205
|
-
if (cached)
|
|
206
|
-
return cached;
|
|
207
|
-
const raw = this.call('views', [gameId, JSON.stringify(state)]);
|
|
209
|
+
if (cached?.labels === labels)
|
|
210
|
+
return cached.views;
|
|
211
|
+
const raw = this.call('views', [gameId, JSON.stringify(state), labels]);
|
|
208
212
|
if (typeof raw !== 'string')
|
|
209
213
|
throw new Error(`${this.name}: views returned no text`);
|
|
210
214
|
const views = PackViewsSchema.parse(JSON.parse(raw));
|
|
211
|
-
this.viewsCache.set(state, views);
|
|
215
|
+
this.viewsCache.set(state, { labels, views });
|
|
212
216
|
return views;
|
|
213
217
|
}
|
|
214
218
|
memory(handle) {
|
|
@@ -9,6 +9,7 @@ export interface GuestLimits {
|
|
|
9
9
|
callMs: number;
|
|
10
10
|
}
|
|
11
11
|
export type HostFunction = (...args: QuickJSHandle[]) => QuickJSHandle | void;
|
|
12
|
+
export declare const monotonicMs: () => number;
|
|
12
13
|
export declare const errorText: (e: unknown) => string;
|
|
13
14
|
export declare class QuickJsGuest {
|
|
14
15
|
private readonly opts;
|
|
@@ -17,6 +18,7 @@ export declare class QuickJsGuest {
|
|
|
17
18
|
private readonly api;
|
|
18
19
|
private disabled;
|
|
19
20
|
private deadline;
|
|
21
|
+
private readonly now;
|
|
20
22
|
private corrupted;
|
|
21
23
|
constructor(quickJs: QuickJSWASMModule, opts: {
|
|
22
24
|
name: string;
|
|
@@ -30,6 +32,8 @@ export declare class QuickJsGuest {
|
|
|
30
32
|
/** the plugin's WebAssembly modules and what they may import */
|
|
31
33
|
wasm?: WasmSetup;
|
|
32
34
|
log: (line: string) => void;
|
|
35
|
+
/** the clock the budgets are kept by (milliseconds, monotonic by default); a test passes its own */
|
|
36
|
+
now?: () => number;
|
|
33
37
|
});
|
|
34
38
|
/** Calls a guest function within the budget; its JSON-able result, dumped to the host. */
|
|
35
39
|
call(fn: string, args: ReadonlyArray<string | number>): unknown;
|
|
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import releaseSync from '@jitl/quickjs-wasmfile-release-sync';
|
|
6
|
-
import { newQuickJSWASMModuleFromVariant, newVariant,
|
|
6
|
+
import { newQuickJSWASMModuleFromVariant, newVariant, } from 'quickjs-emscripten-core';
|
|
7
7
|
import { WasmInstances } from './wasm-host.js';
|
|
8
8
|
/*
|
|
9
9
|
* One piece of plugin code in its own QuickJS runtime (WebAssembly): no file system, network,
|
|
@@ -24,6 +24,9 @@ export async function loadQuickJs() {
|
|
|
24
24
|
const wasmBinary = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
25
25
|
return newQuickJSWASMModuleFromVariant(newVariant(releaseSync, { wasmBinary }));
|
|
26
26
|
}
|
|
27
|
+
/* Budgets are kept on a monotonic clock: WSL and NTP step the wall clock, and a step
|
|
28
|
+
* forward interrupted a healthy plugin's load (2026-12-06). */
|
|
29
|
+
export const monotonicMs = () => performance.now();
|
|
27
30
|
export const errorText = (e) => (e instanceof Error ? e.message : String(e));
|
|
28
31
|
const CORRUPTED_GUESTS = [];
|
|
29
32
|
export class QuickJsGuest {
|
|
@@ -32,13 +35,15 @@ export class QuickJsGuest {
|
|
|
32
35
|
runtime;
|
|
33
36
|
api;
|
|
34
37
|
disabled = null;
|
|
35
|
-
/* when the guest call running now must end
|
|
38
|
+
/* when the guest call running now must end, by `now` */
|
|
36
39
|
deadline = 0;
|
|
40
|
+
now;
|
|
37
41
|
/* runaway guest recursion exhausts the host's stack mid-call and leaves the runtime holding
|
|
38
42
|
* objects it can't account for: freeing it then aborts the whole QuickJS module */
|
|
39
43
|
corrupted = false;
|
|
40
44
|
constructor(quickJs, opts) {
|
|
41
45
|
this.opts = opts;
|
|
46
|
+
this.now = opts.now ?? monotonicMs;
|
|
42
47
|
this.runtime = quickJs.newRuntime();
|
|
43
48
|
this.runtime.setMemoryLimit(opts.limits.memoryBytes);
|
|
44
49
|
this.runtime.setMaxStackSize(opts.limits.stackBytes);
|
|
@@ -70,7 +75,7 @@ export class QuickJsGuest {
|
|
|
70
75
|
call(fn, args) {
|
|
71
76
|
if (this.disabled)
|
|
72
77
|
throw new Error(`${this.opts.name} is switched off: ${this.disabled}`);
|
|
73
|
-
const started =
|
|
78
|
+
const started = this.now();
|
|
74
79
|
try {
|
|
75
80
|
return this.withBudget(this.opts.limits.callMs, () => this.callGuest(fn, args));
|
|
76
81
|
}
|
|
@@ -83,7 +88,7 @@ export class QuickJsGuest {
|
|
|
83
88
|
throw e;
|
|
84
89
|
}
|
|
85
90
|
finally {
|
|
86
|
-
const ms =
|
|
91
|
+
const ms = this.now() - started;
|
|
87
92
|
const budget = this.opts.limits.callMs;
|
|
88
93
|
if (!this.disabled && ms > budget * 2) {
|
|
89
94
|
this.disable(`${fn} took ${ms} ms (budget ${budget} ms)`);
|
|
@@ -129,7 +134,7 @@ export class QuickJsGuest {
|
|
|
129
134
|
wasmFunctions(setup) {
|
|
130
135
|
const vm = this.vm;
|
|
131
136
|
const wasm = new WasmInstances(setup, reason => this.disable(reason));
|
|
132
|
-
const left = () => this.deadline -
|
|
137
|
+
const left = () => this.deadline - this.now();
|
|
133
138
|
const text = (h) => {
|
|
134
139
|
if (vm.typeof(h) !== 'string')
|
|
135
140
|
throw new Error('a WebAssembly file is named by a string');
|
|
@@ -168,8 +173,9 @@ export class QuickJsGuest {
|
|
|
168
173
|
};
|
|
169
174
|
}
|
|
170
175
|
withBudget(ms, run) {
|
|
171
|
-
|
|
172
|
-
this.
|
|
176
|
+
const deadline = this.now() + ms;
|
|
177
|
+
this.deadline = deadline;
|
|
178
|
+
this.runtime.setInterruptHandler(() => this.now() > deadline);
|
|
173
179
|
try {
|
|
174
180
|
return run();
|
|
175
181
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED