@gameslate/sdk 0.3.20 → 0.3.21
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/build/verify-effects.mjs +11 -7
- package/lib/host/inspect.js +19 -2
- package/lib/host/verify.d.ts +9 -3
- package/lib/host/verify.js +16 -3
- package/lib/plugin/contract.d.ts +2 -1
- package/lib/plugin-manifest.d.ts +60 -0
- package/lib/plugin-manifest.js +27 -0
- package/lib/plugin-permissions.js +21 -4
- package/package.json +1 -1
- package/template/claude/skills/build-gameslate-plugin/SKILL.md +26 -4
- package/template/claude/skills/verify-gameslate-plugin/SKILL.md +4 -3
- package/template/plugin/live.ts +2 -1
- package/template/plugin/manifest.json +7 -1
package/build/verify-effects.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { execFile, spawn } from 'node:child_process';
|
|
|
2
2
|
import dgram from 'node:dgram';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { firstBusyUdpPort, RETROARCH_UDP_PORTS } from '../lib/host/index.js';
|
|
5
|
+
import { firstBusyUdpPort, launchPrefixFor, RETROARCH_UDP_PORTS } from '../lib/host/index.js';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
* The real effects of `gameslate-plugin verify` (src/host/verify.ts has the steps and their
|
|
@@ -57,9 +57,8 @@ function started(child, stop) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/* The emulator's own pid: the
|
|
61
|
-
function emulatorPid(child
|
|
62
|
-
if (!wrapped) return child.pid;
|
|
60
|
+
/* The emulator's own pid: the launch wrapper's child. */
|
|
61
|
+
function emulatorPid(child) {
|
|
63
62
|
const children = `/proc/${child.pid}/task/${child.pid}/children`;
|
|
64
63
|
const pid = Number(fs.readFileSync(children, 'utf8').trim().split(/\s+/)[0]);
|
|
65
64
|
if (!pid) throw new Error('the launch wrapper started no emulator');
|
|
@@ -68,13 +67,17 @@ function emulatorPid(child, wrapped) {
|
|
|
68
67
|
|
|
69
68
|
async function launchEmulator(spec, at, log) {
|
|
70
69
|
const { command, launchPrefix } = spec.emulator;
|
|
71
|
-
const
|
|
70
|
+
const prefix = launchPrefixFor(launchPrefix, gameslatePath(spec, at), process.execPath);
|
|
71
|
+
const [first, ...rest] = [...prefix, ...command];
|
|
72
72
|
const child = spawn(first, rest, { stdio: 'ignore', cwd: at('.') });
|
|
73
73
|
log(`started ${path.basename(command[0])} (pid ${child.pid})`);
|
|
74
74
|
await started(child, null);
|
|
75
|
-
return { pid: emulatorPid(child
|
|
75
|
+
return { pid: emulatorPid(child), stop: () => child.kill('SIGTERM') };
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/* the spec's dist/gameslate.mjs, resolved beside the spec */
|
|
79
|
+
const gameslatePath = (spec, at) => (spec.gameslate ? at(spec.gameslate) : undefined);
|
|
80
|
+
|
|
78
81
|
/* a `gameslate drive` command; a frame's file goes beside the spec */
|
|
79
82
|
function drive(spec, at, args) {
|
|
80
83
|
if (!spec.gameslate) throw new Error('steps need "gameslate": the path to dist/gameslate.mjs');
|
|
@@ -98,7 +101,8 @@ function launchRetroArch(spec, at, log) {
|
|
|
98
101
|
if (!ra) return Promise.resolve({ stop: () => undefined });
|
|
99
102
|
const args = ['-L', at(ra.core), at(ra.rom), '-e', String(ra.stateSlot)];
|
|
100
103
|
if (ra.config) args.push('--appendconfig', at(ra.config));
|
|
101
|
-
const
|
|
104
|
+
const prefix = launchPrefixFor(ra.launchPrefix, gameslatePath(spec, at), process.execPath);
|
|
105
|
+
const [first, ...rest] = [...prefix, at(ra.binary), ...args];
|
|
102
106
|
const child = spawn(first, rest, { stdio: 'ignore' });
|
|
103
107
|
log(`started RetroArch (pid ${child.pid}) on state slot ${ra.stateSlot}`);
|
|
104
108
|
return new Promise((resolve, reject) => {
|
package/lib/host/inspect.js
CHANGED
|
@@ -34,8 +34,25 @@ function describedProblem(manifest, d) {
|
|
|
34
34
|
return `its code says it is ${d.id}`;
|
|
35
35
|
const games = new Set(manifest.games.map(g => g.id));
|
|
36
36
|
const stray = [...d.sources.map(s => s.gameId), ...d.packs.map(p => p.id)].filter(id => !games.has(id));
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (stray.length)
|
|
38
|
+
return `its code covers games its manifest doesn't list (${stray.join(', ')})`;
|
|
39
|
+
return undeclaredBuilds(manifest, d);
|
|
40
|
+
}
|
|
41
|
+
/* The builds a source matches are what the player consented to read: a source may match only
|
|
42
|
+
* builds its game's manifest entry lists (a manifest from before builds were declared lists none,
|
|
43
|
+
* and is not checked). */
|
|
44
|
+
function undeclaredBuilds(manifest, d) {
|
|
45
|
+
const declared = new Map(manifest.games.flatMap(g => g.builds ? [[g.id, new Set(g.builds.map(b => b.id))]] : []));
|
|
46
|
+
const undeclared = d.sources.flatMap(s => {
|
|
47
|
+
const builds = declared.get(s.gameId);
|
|
48
|
+
if (!builds)
|
|
49
|
+
return [];
|
|
50
|
+
return s.supportedBuildIds
|
|
51
|
+
.filter(([id]) => !builds.has(id))
|
|
52
|
+
.map(([id]) => `${s.gameId} ${id}`);
|
|
53
|
+
});
|
|
54
|
+
return undeclared.length
|
|
55
|
+
? `its code reads builds its manifest doesn't list (${undeclared.join(', ')})`
|
|
39
56
|
: null;
|
|
40
57
|
}
|
|
41
58
|
function loadLive(quickJs, dir, manifest, log) {
|
package/lib/host/verify.d.ts
CHANGED
|
@@ -401,8 +401,8 @@ export declare const VerifySpecSchema: z.ZodObject<{
|
|
|
401
401
|
core: z.ZodString;
|
|
402
402
|
rom: z.ZodString;
|
|
403
403
|
stateSlot: z.ZodNumber;
|
|
404
|
-
/** run RetroArch through this
|
|
405
|
-
*
|
|
404
|
+
/** run RetroArch through this; by default GameSlate's launch wrapper (`gameslate`
|
|
405
|
+
* `run --`), since GameSlate reads only games launched through it */
|
|
406
406
|
launchPrefix: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
407
407
|
/** a config appended to RetroArch's, which must turn network commands on */
|
|
408
408
|
config: z.ZodOptional<z.ZodString>;
|
|
@@ -427,7 +427,7 @@ export declare const VerifySpecSchema: z.ZodObject<{
|
|
|
427
427
|
/** any emulator, started with this command (the ROM on its command line, so the core finds it) */
|
|
428
428
|
emulator: z.ZodOptional<z.ZodObject<{
|
|
429
429
|
command: z.ZodArray<z.ZodString, "many">;
|
|
430
|
-
/** as for RetroArch: through GameSlate's launch wrapper
|
|
430
|
+
/** as for RetroArch: by default through GameSlate's launch wrapper */
|
|
431
431
|
launchPrefix: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
432
432
|
}, "strip", z.ZodTypeAny, {
|
|
433
433
|
launchPrefix: string[];
|
|
@@ -1181,6 +1181,12 @@ export declare const VerifySpecSchema: z.ZodObject<{
|
|
|
1181
1181
|
}>;
|
|
1182
1182
|
export type VerifySpec = z.infer<typeof VerifySpecSchema>;
|
|
1183
1183
|
type MemoryCheck = VerifySpec['memory'][number];
|
|
1184
|
+
/**
|
|
1185
|
+
* What the emulator is started through: the spec's own prefix, else GameSlate's launch wrapper
|
|
1186
|
+
* (`node <gameslate> run --`). GameSlate reads memory only from games launched through it
|
|
1187
|
+
* ("Closing the sandbox" item 4), so an emulator started bare would never be read.
|
|
1188
|
+
*/
|
|
1189
|
+
export declare function launchPrefixFor(launchPrefix: readonly string[], gameslate: string | undefined, nodePath: string): string[];
|
|
1184
1190
|
/**
|
|
1185
1191
|
* `${NAME}` in any string of a spec, from the environment, so a spec can be shared without one
|
|
1186
1192
|
* machine's paths (`"${GOPHER64}"`, `"${N64_ROMS}/Mario Kart 64 (U).z64"`). Throws on a name that
|
package/lib/host/verify.js
CHANGED
|
@@ -79,8 +79,8 @@ export const VerifySpecSchema = z.object({
|
|
|
79
79
|
core: z.string(),
|
|
80
80
|
rom: z.string(),
|
|
81
81
|
stateSlot: z.number().int().min(0).max(999),
|
|
82
|
-
/** run RetroArch through this
|
|
83
|
-
*
|
|
82
|
+
/** run RetroArch through this; by default GameSlate's launch wrapper (`gameslate`
|
|
83
|
+
* `run --`), since GameSlate reads only games launched through it */
|
|
84
84
|
launchPrefix: z.array(z.string()).default([]),
|
|
85
85
|
/** a config appended to RetroArch's, which must turn network commands on */
|
|
86
86
|
config: z.string().optional(),
|
|
@@ -91,7 +91,7 @@ export const VerifySpecSchema = z.object({
|
|
|
91
91
|
emulator: z
|
|
92
92
|
.object({
|
|
93
93
|
command: z.array(z.string()).min(1),
|
|
94
|
-
/** as for RetroArch: through GameSlate's launch wrapper
|
|
94
|
+
/** as for RetroArch: by default through GameSlate's launch wrapper */
|
|
95
95
|
launchPrefix: z.array(z.string()).default([]),
|
|
96
96
|
})
|
|
97
97
|
.optional(),
|
|
@@ -126,6 +126,19 @@ export const VerifySpecSchema = z.object({
|
|
|
126
126
|
}))
|
|
127
127
|
.default([]),
|
|
128
128
|
});
|
|
129
|
+
/**
|
|
130
|
+
* What the emulator is started through: the spec's own prefix, else GameSlate's launch wrapper
|
|
131
|
+
* (`node <gameslate> run --`). GameSlate reads memory only from games launched through it
|
|
132
|
+
* ("Closing the sandbox" item 4), so an emulator started bare would never be read.
|
|
133
|
+
*/
|
|
134
|
+
export function launchPrefixFor(launchPrefix, gameslate, nodePath) {
|
|
135
|
+
if (launchPrefix.length > 0)
|
|
136
|
+
return [...launchPrefix];
|
|
137
|
+
if (gameslate === undefined) {
|
|
138
|
+
throw new Error('GameSlate reads only games launched through it: give "gameslate" (its dist/gameslate.mjs) or a "launchPrefix"');
|
|
139
|
+
}
|
|
140
|
+
return [nodePath, gameslate, 'run', '--'];
|
|
141
|
+
}
|
|
129
142
|
/**
|
|
130
143
|
* `${NAME}` in any string of a spec, from the environment, so a spec can be shared without one
|
|
131
144
|
* machine's paths (`"${GOPHER64}"`, `"${N64_ROMS}/Mario Kart 64 (U).z64"`). Throws on a name that
|
package/lib/plugin/contract.d.ts
CHANGED
|
@@ -52,7 +52,8 @@ export interface GamePlugin {
|
|
|
52
52
|
readonly executableHints: readonly string[];
|
|
53
53
|
/**
|
|
54
54
|
* Stats a launch wrapper from an older bundle may not send. While any is missing, the daemon
|
|
55
|
-
* fills them (and flags) from its own direct read of the game, without a relaunch
|
|
55
|
+
* fills them (and flags) from its own direct read of the game, without a relaunch, provided
|
|
56
|
+
* the wrapper introduced itself (cores after 2.3.0; older wrappers send no `bridge:hello`).
|
|
56
57
|
*/
|
|
57
58
|
readonly wrapperMayOmitStats?: readonly string[];
|
|
58
59
|
/**
|
package/lib/plugin-manifest.d.ts
CHANGED
|
@@ -35,6 +35,24 @@ export declare const PluginDownloadSchema: z.ZodObject<{
|
|
|
35
35
|
export type PluginDownload = z.infer<typeof PluginDownloadSchema>;
|
|
36
36
|
/** The input name a download reaches the asset code under. */
|
|
37
37
|
export declare const downloadInputName: (id: string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* A build of a game that the plugin's live code reads memory from: the id its source matches
|
|
40
|
+
* (an ELF or PE build id, or an N64 ROM's code and version such as `CZLE.2`) and what the player
|
|
41
|
+
* knows it as (the executable's file name, or the ROM's title). Each is a permission, keyed by
|
|
42
|
+
* both, so a plugin that starts matching another process asks first ("Closing the sandbox" item 4).
|
|
43
|
+
* When a game lists its builds, the core refuses live code that matches one it doesn't list.
|
|
44
|
+
*/
|
|
45
|
+
export declare const GameBuildSchema: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
name: z.ZodString;
|
|
48
|
+
}, "strict", z.ZodTypeAny, {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
}, {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
}>;
|
|
55
|
+
export type GameBuild = z.infer<typeof GameBuildSchema>;
|
|
38
56
|
/** major.minor.patch, the only form `compareVersions` orders. */
|
|
39
57
|
export declare const PluginVersionSchema: z.ZodString;
|
|
40
58
|
/** The release zip a published manifest names: its URL (absolute, or relative to the URL the
|
|
@@ -122,6 +140,24 @@ export declare const PluginManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
122
140
|
url: string;
|
|
123
141
|
sha256: string;
|
|
124
142
|
}[]>>;
|
|
143
|
+
/** the builds its live code reads memory from. Absent in manifests from
|
|
144
|
+
* before sdk 0.3.21: then the permission names only the game. */
|
|
145
|
+
builds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
146
|
+
id: z.ZodString;
|
|
147
|
+
name: z.ZodString;
|
|
148
|
+
}, "strict", z.ZodTypeAny, {
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
}, {
|
|
152
|
+
id: string;
|
|
153
|
+
name: string;
|
|
154
|
+
}>, "many">, {
|
|
155
|
+
id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
}[], {
|
|
158
|
+
id: string;
|
|
159
|
+
name: string;
|
|
160
|
+
}[]>>;
|
|
125
161
|
}, "strict", z.ZodTypeAny, {
|
|
126
162
|
id: string;
|
|
127
163
|
title: string;
|
|
@@ -135,10 +171,18 @@ export declare const PluginManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
135
171
|
url: string;
|
|
136
172
|
sha256: string;
|
|
137
173
|
}[];
|
|
174
|
+
builds?: {
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
}[] | undefined;
|
|
138
178
|
aliases?: string[] | undefined;
|
|
139
179
|
}, {
|
|
140
180
|
id: string;
|
|
141
181
|
title: string;
|
|
182
|
+
builds?: {
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
}[] | undefined;
|
|
142
186
|
aliases?: string[] | undefined;
|
|
143
187
|
inputs?: {
|
|
144
188
|
label: string;
|
|
@@ -187,6 +231,10 @@ export declare const PluginManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
187
231
|
url: string;
|
|
188
232
|
sha256: string;
|
|
189
233
|
}[];
|
|
234
|
+
builds?: {
|
|
235
|
+
id: string;
|
|
236
|
+
name: string;
|
|
237
|
+
}[] | undefined;
|
|
190
238
|
aliases?: string[] | undefined;
|
|
191
239
|
}[];
|
|
192
240
|
assets?: {
|
|
@@ -209,6 +257,10 @@ export declare const PluginManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
209
257
|
games: {
|
|
210
258
|
id: string;
|
|
211
259
|
title: string;
|
|
260
|
+
builds?: {
|
|
261
|
+
id: string;
|
|
262
|
+
name: string;
|
|
263
|
+
}[] | undefined;
|
|
212
264
|
aliases?: string[] | undefined;
|
|
213
265
|
inputs?: {
|
|
214
266
|
label: string;
|
|
@@ -253,6 +305,10 @@ export declare const PluginManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
253
305
|
url: string;
|
|
254
306
|
sha256: string;
|
|
255
307
|
}[];
|
|
308
|
+
builds?: {
|
|
309
|
+
id: string;
|
|
310
|
+
name: string;
|
|
311
|
+
}[] | undefined;
|
|
256
312
|
aliases?: string[] | undefined;
|
|
257
313
|
}[];
|
|
258
314
|
assets?: {
|
|
@@ -275,6 +331,10 @@ export declare const PluginManifestSchema: z.ZodEffects<z.ZodObject<{
|
|
|
275
331
|
games: {
|
|
276
332
|
id: string;
|
|
277
333
|
title: string;
|
|
334
|
+
builds?: {
|
|
335
|
+
id: string;
|
|
336
|
+
name: string;
|
|
337
|
+
}[] | undefined;
|
|
278
338
|
aliases?: string[] | undefined;
|
|
279
339
|
inputs?: {
|
|
280
340
|
label: string;
|
package/lib/plugin-manifest.js
CHANGED
|
@@ -99,6 +99,26 @@ export const PluginDownloadSchema = z
|
|
|
99
99
|
.strict();
|
|
100
100
|
/** The input name a download reaches the asset code under. */
|
|
101
101
|
export const downloadInputName = (id) => `downloads/${id}`;
|
|
102
|
+
/**
|
|
103
|
+
* A build of a game that the plugin's live code reads memory from: the id its source matches
|
|
104
|
+
* (an ELF or PE build id, or an N64 ROM's code and version such as `CZLE.2`) and what the player
|
|
105
|
+
* knows it as (the executable's file name, or the ROM's title). Each is a permission, keyed by
|
|
106
|
+
* both, so a plugin that starts matching another process asks first ("Closing the sandbox" item 4).
|
|
107
|
+
* When a game lists its builds, the core refuses live code that matches one it doesn't list.
|
|
108
|
+
*/
|
|
109
|
+
export const GameBuildSchema = z
|
|
110
|
+
.object({
|
|
111
|
+
id: z
|
|
112
|
+
.string()
|
|
113
|
+
.regex(/^[A-Za-z0-9._-]{1,128}$/, 'a build id: letters, digits, ".", "_" or "-"'),
|
|
114
|
+
name: z
|
|
115
|
+
.string()
|
|
116
|
+
.min(1)
|
|
117
|
+
.max(100)
|
|
118
|
+
/* shown to the player in a permission: one plain line */
|
|
119
|
+
.regex(/^[^\p{Cc}]+$/u, 'a name without control characters'),
|
|
120
|
+
})
|
|
121
|
+
.strict();
|
|
102
122
|
const CodeFile = z.object({
|
|
103
123
|
file: FileName,
|
|
104
124
|
sha256: Sha256,
|
|
@@ -140,6 +160,13 @@ export const PluginManifestSchema = z
|
|
|
140
160
|
.max(20)
|
|
141
161
|
.refine(ds => new Set(ds.map(d => d.id)).size === ds.length, "a game's download ids are unique")
|
|
142
162
|
.default([]),
|
|
163
|
+
/** the builds its live code reads memory from. Absent in manifests from
|
|
164
|
+
* before sdk 0.3.21: then the permission names only the game. */
|
|
165
|
+
builds: z
|
|
166
|
+
.array(GameBuildSchema)
|
|
167
|
+
.max(50)
|
|
168
|
+
.refine(bs => new Set(bs.map(b => b.id)).size === bs.length, "a game's build ids are unique")
|
|
169
|
+
.optional(),
|
|
143
170
|
})
|
|
144
171
|
/* a misspelt key (`download`) is refused, not dropped with what it declared */
|
|
145
172
|
.strict())
|
|
@@ -13,10 +13,7 @@ export const PluginPermissionSchema = z.object({
|
|
|
13
13
|
label: z.string(),
|
|
14
14
|
});
|
|
15
15
|
export function pluginPermissions(manifest) {
|
|
16
|
-
const memory = manifest.games.
|
|
17
|
-
key: `memory:${g.id}`,
|
|
18
|
-
label: `Read ${g.title}'s memory while it runs`,
|
|
19
|
-
}));
|
|
16
|
+
const memory = manifest.games.flatMap(memoryPermissions);
|
|
20
17
|
/* the offered folders are read only by asset code */
|
|
21
18
|
const folders = manifest.assets
|
|
22
19
|
? [...new Set(manifest.games.flatMap(g => g.inputs.flatMap(i => i.folders)))].map(f => ({
|
|
@@ -31,6 +28,26 @@ export function pluginPermissions(manifest) {
|
|
|
31
28
|
])));
|
|
32
29
|
return [...memory, ...folders, ...[...downloads].map(([key, label]) => ({ key, label }))];
|
|
33
30
|
}
|
|
31
|
+
const BUILD_ID_SHOWN = 8;
|
|
32
|
+
/* One per build, keyed by its id and name: matching another process, or calling a build by
|
|
33
|
+
* another name, asks again. A manifest from before builds were declared names only the game. */
|
|
34
|
+
function memoryPermissions(game) {
|
|
35
|
+
if (!game.builds) {
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
key: `memory:${game.id}`,
|
|
39
|
+
label: `Read ${game.title}'s memory while it runs, when you launch it through GameSlate`,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
return game.builds.map(b => ({
|
|
44
|
+
key: `memory:${game.id}:${b.id}#${b.name}`,
|
|
45
|
+
label: `Read the memory of ${b.name} (${game.title}, build ${shortBuildId(b.id)}), when you launch it through GameSlate`,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
function shortBuildId(id) {
|
|
49
|
+
return id.length > BUILD_ID_SHOWN ? `${id.slice(0, BUILD_ID_SHOWN)}…` : id;
|
|
50
|
+
}
|
|
34
51
|
/* host and path, as the player reads a link ("example.com/a/b.tar.gz") */
|
|
35
52
|
function downloadPlace(url) {
|
|
36
53
|
const u = new URL(url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gameslate/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"description": "Build plugins for GameSlate, the second-screen companion for PC games: the plugin contract, game-state and catalogue schemas, and the plugin builder.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -97,13 +97,34 @@ evaluator in the SDK decides "done", "collected" and "available". Rules:
|
|
|
97
97
|
## 4. Memory addresses, verified
|
|
98
98
|
|
|
99
99
|
**Pin the build.** List the exact builds you verified in the source's `supportedBuildIds` (a
|
|
100
|
-
`Map` from build id to `{ region }` on the `GamePlugin` in `live.ts
|
|
100
|
+
`Map` from build id to `{ region }` on the `GamePlugin` in `live.ts`):
|
|
101
101
|
|
|
102
102
|
- ELF or PE build id for PC games;
|
|
103
103
|
- `CODE.version` from the ROM header for N64 (e.g. `CZLE.2`).
|
|
104
104
|
|
|
105
105
|
An unknown build means refuse to attach, never "try the nearest offsets".
|
|
106
106
|
|
|
107
|
+
**Declare the same builds in the manifest** (sdk 0.3.21), each with what the player knows it as,
|
|
108
|
+
the executable's file name or the ROM's title:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
"games": [{ "id": "perfect-dark", "title": "Perfect Dark",
|
|
112
|
+
"builds": [{ "id": "0925a5f6…", "name": "pd.pal.x86_64" }] }]
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Each build is a permission ("Read the memory of pd.pal.x86_64 (Perfect Dark, build 0925a5f6…),
|
|
116
|
+
when you launch it through GameSlate"), keyed by id and name: adding a build or renaming one makes
|
|
117
|
+
every player confirm the update. The core (and `validate`) refuses live code that matches a build
|
|
118
|
+
the manifest doesn't list. A manifest without `builds` still loads, with a permission naming only
|
|
119
|
+
the game; declare them anyway, since that leniency is for releases built before 0.3.21.
|
|
120
|
+
|
|
121
|
+
**Memory is read only from games launched through GameSlate.** The core reads a process only
|
|
122
|
+
when it descends from a `gameslate run --` launch wrapper that is connected to the daemon
|
|
123
|
+
(Steam launch options `~/.local/bin/gameslate run -- %command%`, or `n64-gameslate` for
|
|
124
|
+
ChimeraOS's N64 launcher). A game started any other way shows "Launch <game> through GameSlate
|
|
125
|
+
to read it" in the app instead. Test live runs that way too: `gameslate-plugin verify` starts
|
|
126
|
+
the emulator through the spec's `gameslate` wrapper by default.
|
|
127
|
+
|
|
107
128
|
**Open-source ports.** Compile a probe against the game's headers: print `sizeof` of a big struct
|
|
108
129
|
(it must equal what the shipped build uses) and the `offsetof` of each field. Put each value in
|
|
109
130
|
`offsets.ts`, with a comment naming the struct field and where the number came from. Header
|
|
@@ -515,11 +536,12 @@ plugin exactly as the core will before running it. Then bump `version` in `packa
|
|
|
515
536
|
plugin's games and permissions, then downloads the zip, refuses it unless its sha256 matches, checks
|
|
516
537
|
the zip's own manifest is the published one, and unpacks it. It re-reads that URL about hourly: a
|
|
517
538
|
newer version that asks for **no new permissions** installs itself (once none of its games is
|
|
518
|
-
running); one that asks for more (a new game's memory, a new
|
|
519
|
-
confirm. A manifest naming an `extract` module (code outside the sandbox, removed in sdk 0.3.19)
|
|
539
|
+
running); one that asks for more (a new game's memory, a new or renamed build, a new folder)
|
|
540
|
+
waits for the player to confirm. A manifest naming an `extract` module (code outside the sandbox, removed in sdk 0.3.19)
|
|
520
541
|
fails the schema everywhere, presets included (docs/plugin-architecture.md, "Closing the
|
|
521
542
|
sandbox"). So adding a game, a folder or a download in a release
|
|
522
|
-
means every player is asked again: say why in the release notes.
|
|
543
|
+
means every player is asked again: say why in the release notes. So does a new build in
|
|
544
|
+
`builds`, or a changed build id or name. A plain zip URL works too
|
|
523
545
|
(validated the same way, its `.zip.sha256` used when present), but gets no updates.
|
|
524
546
|
|
|
525
547
|
GameSlate also builds a few plugins in as presets, from `plugins.lock.json` (the release URL and the
|
|
@@ -214,9 +214,10 @@ map), because the game saves the last choices.
|
|
|
214
214
|
addressing; the tool converts a guest address for you) and requires it to equal the plugin's
|
|
215
215
|
counter. That second opinion catches a wrong offset that still looks plausible. Use it for at
|
|
216
216
|
least one value per struct the plugin reads (save, live game state).
|
|
217
|
-
-
|
|
218
|
-
`
|
|
219
|
-
|
|
217
|
+
- GameSlate reads memory only from games launched through it, so the emulator starts through
|
|
218
|
+
the launch wrapper of the spec's `gameslate` (`node <gameslate> run -- <emulator>`). A spec
|
|
219
|
+
without `gameslate` needs its own `"launchPrefix"`; an emulator started bare is never read
|
|
220
|
+
(the daemon shows "Launch <game> through GameSlate to read it").
|
|
220
221
|
|
|
221
222
|
## 4. Run it
|
|
222
223
|
|
package/template/plugin/live.ts
CHANGED
|
@@ -33,7 +33,8 @@ const source: GamePlugin = {
|
|
|
33
33
|
gameId: GAME_ID,
|
|
34
34
|
stateSchemaVersion: 2,
|
|
35
35
|
capabilities: ['stats'],
|
|
36
|
-
/* the exact builds these reads were verified against (ELF/PE build id → label)
|
|
36
|
+
/* the exact builds these reads were verified against (ELF/PE build id → label); each is
|
|
37
|
+
* also in the manifest's `builds`, with the executable's name, or the core refuses it */
|
|
37
38
|
supportedBuildIds: new Map([
|
|
38
39
|
['0000000000000000000000000000000000000000', { region: 'example' }],
|
|
39
40
|
]),
|
|
@@ -3,5 +3,11 @@
|
|
|
3
3
|
"name": "{{name}}",
|
|
4
4
|
"version": "0.1.0",
|
|
5
5
|
"sdkApi": 0,
|
|
6
|
-
"games": [
|
|
6
|
+
"games": [
|
|
7
|
+
{
|
|
8
|
+
"id": "{{id}}-game",
|
|
9
|
+
"title": "{{name}}",
|
|
10
|
+
"builds": [{ "id": "0000000000000000000000000000000000000000", "name": "{{id}}" }]
|
|
11
|
+
}
|
|
12
|
+
]
|
|
7
13
|
}
|