glitchless-mcp 0.21.0 → 0.22.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/README.md +4 -3
- package/package.json +1 -1
- package/src/context.js +71 -7
- package/src/tools/multiplayer.js +8 -2
- package/src/tools/workspace.js +21 -5
package/README.md
CHANGED
|
@@ -24,8 +24,9 @@ npx -y glitchless-mcp login
|
|
|
24
24
|
It prints a link and a code; you approve the code in the Glitchless dashboard, and it saves a workspace key in
|
|
25
25
|
`~/.config/glitchless/credentials.json` (readable only by you). From then on the server reaches every game in that
|
|
26
26
|
workspace: `glitchless_list_games` lists them, `glitchless_create_game` makes one and returns its client token, and
|
|
27
|
-
every tool takes `game` (a name or id). The key acts as you, with your role in the workspace, and never
|
|
28
|
-
|
|
27
|
+
every tool takes `game` (a name or id). The key acts as you, with your role in the workspace, and never touches
|
|
28
|
+
billing or people. It deletes data only if you ticked "Delete games and their data, for good" when approving it, and
|
|
29
|
+
then only a whole game, with its name repeated back. `npx -y glitchless-mcp whoami` shows where you're signed in, `logout` deletes the saved
|
|
29
30
|
key, and Settings → Keys & access in the dashboard lists and revokes keys. An agent can also sign in from inside a
|
|
30
31
|
chat with the `glitchless_sign_in` tool: it shows the link and code, and the running server switches over once you
|
|
31
32
|
approve. The saved key is only ever sent to the server it was saved for: point `GLITCHLESS_URL` at another one (a
|
|
@@ -92,7 +93,7 @@ above go in its environment.
|
|
|
92
93
|
| --- | --- |
|
|
93
94
|
| `glitchless_list_games` | Which games report to the server, with their versions and environments; signed in to a workspace, every game in it with its client token |
|
|
94
95
|
| `glitchless_sign_in` | Connect to a Glitchless Cloud workspace: a link and a code for the person to approve |
|
|
95
|
-
| `glitchless_create_game` | A new game in the workspace, with its client token and intake URL (a name already there returns that game); with `engine`, or `files` (what's in the game's folder), also the steps that add Glitchless to the game's code for its engine, for a new game (`name`) or one already there (`game`): the instrument skill, for an agent without it; `demo: true` makes the demo game (a week of sample play); `rename` (with `game`) renames one instead, its client token, service and data unchanged |
|
|
96
|
+
| `glitchless_create_game` | A new game in the workspace, with its client token and intake URL (a name already there returns that game); with `engine`, or `files` (what's in the game's folder), also the steps that add Glitchless to the game's code for its engine, for a new game (`name`) or one already there (`game`): the instrument skill, for an agent without it; `demo: true` makes the demo game (a week of sample play); `rename` (with `game`) renames one instead, its client token, service and data unchanged; `delete` (with `game`, and the game's name again) deletes it and everything Glitchless keeps for it, for good: a key with `delete_games` (off unless an Owner or Admin ticked it), and when two games share the name, `game` is its id; the client token is refused from then on |
|
|
96
97
|
| `glitchless_share_links` | A read-only link to one board page, for a dev log, Discord or a game's "Live stats" link (`page`), or with `claim: true` a claim link that hands a game the team made to its creator, who moves it into their own workspace; lists them, and revokes one (`revoke`) |
|
|
97
98
|
| `glitchless_triage` | The headline numbers (sessions, players, crash-free sessions, frame time, rage quits), then ranked findings: stutter per level and what it correlates with, leaks, top errors, difficulty spikes. Start here |
|
|
98
99
|
| `glitchless_mark_known` | Mark a finding the game's owner accepts as known, so the weekly summary stops listing it (triage shows it last, with the note); with `player` or `session` instead, the team's own play, read as testers in every tool; `clear: true` removes the mark |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glitchless-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"mcpName": "io.github.glitchless-gg/glitchless",
|
|
5
5
|
"description": "Coding agents can build a game. They can't see anyone play it. Glitchless lets them. The MCP server for Glitchless, game observability for coding agents: Claude Code, Codex, Cursor and others read real players' stutters, crashes, custom metrics and ranked findings in Unity, Godot, Unreal, Three.js, Roblox, Phaser and GameMaker games, build the game's own dashboard, and run playtest bots.",
|
|
6
6
|
"keywords": [
|
package/src/context.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from 'node:path';
|
|
|
9
9
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
|
|
12
|
-
export const VERSION = '0.
|
|
12
|
+
export const VERSION = '0.22.0';
|
|
13
13
|
|
|
14
14
|
// Where `glitchless-mcp login` keeps its workspace key: { url, token, workspace: { id, name }, scopes }.
|
|
15
15
|
export const CREDENTIALS_FILE = path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'glitchless', 'credentials.json');
|
|
@@ -99,6 +99,13 @@ export const canManage = () => {
|
|
|
99
99
|
return !scopes || scopes.includes('manage');
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
// Whether this call's connection may delete games: over HTTP, by the scopes its token carries (a token can carry fewer
|
|
103
|
+
// than its key); on stdio, Glitchless Cloud decides by the key.
|
|
104
|
+
export const canDeleteGames = () => {
|
|
105
|
+
const scopes = calls.getStore()?.scopes;
|
|
106
|
+
return !scopes || scopes.includes('delete_games');
|
|
107
|
+
};
|
|
108
|
+
|
|
102
109
|
// Where an agent gets the steps that add Glitchless to a game's code, as the end of a sentence: from
|
|
103
110
|
// glitchless_create_game (setup-guide.js) where the connection has it, else the setup prompt.
|
|
104
111
|
export const setupSteps = () =>
|
|
@@ -120,6 +127,12 @@ export async function projectFor(game) {
|
|
|
120
127
|
return hit.id;
|
|
121
128
|
}
|
|
122
129
|
|
|
130
|
+
// After a game is deleted: later calls don't fall back to it.
|
|
131
|
+
export function forgetGame(id) {
|
|
132
|
+
const c = conn();
|
|
133
|
+
if (c.game === id) c.game = null;
|
|
134
|
+
}
|
|
135
|
+
|
|
123
136
|
// A workspace key names the game in x-glitchless-project. A key for one game sends the game a call names (or
|
|
124
137
|
// GLITCHLESS_GAME) as x-glitchless-game, so Glitchless Cloud refuses it when it isn't the key's game instead of
|
|
125
138
|
// answering, or writing, for the key's own game.
|
|
@@ -138,15 +151,59 @@ export async function agent(method, p, body) {
|
|
|
138
151
|
...(body ? { body: JSON.stringify(body) } : {}),
|
|
139
152
|
});
|
|
140
153
|
const data = await res.json().catch(() => ({}));
|
|
141
|
-
|
|
154
|
+
// The answer's code and fields go with the error, for a tool that answers one of them its own way.
|
|
155
|
+
if (!res.ok) throw Object.assign(new Error(`${data.error || `HTTP ${res.status}`}`), { code: data.code ?? null, data });
|
|
142
156
|
return data;
|
|
143
157
|
}
|
|
144
158
|
|
|
159
|
+
// A read the server refused (SPEC §3): it took too long and was stopped (503), or the server is busy with other large
|
|
160
|
+
// reads (429). Told apart by the body's `reason`, since a 429 is also a rate limit. → what to tell the agent, with what
|
|
161
|
+
// to do next in a tool's own terms, or null for any other answer.
|
|
162
|
+
const SMALLER = 'Call again with a smaller hours (for example 168, a week), then widen it if you need more.';
|
|
163
|
+
function refusal(res, text) {
|
|
164
|
+
if (res.status !== 503 && res.status !== 429) return null;
|
|
165
|
+
let data;
|
|
166
|
+
try {
|
|
167
|
+
data = JSON.parse(text);
|
|
168
|
+
} catch {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
if (data?.reason === 'deadline') {
|
|
172
|
+
const after = String(data.error).match(/[\d.]+ seconds?/)?.[0];
|
|
173
|
+
return `This window was too big to read: Glitchless stopped the read${after ? ` after ${after}` : ''}. ${SMALLER}`;
|
|
174
|
+
}
|
|
175
|
+
if (data?.reason === 'busy' && data.behind === 'own') {
|
|
176
|
+
return 'Another large read of yours (a tool call running at the same time) was still running, so this one waited for it and ran out of time. Nothing is wrong with the call: make it again once the other call has answered, one call at a time, or with a smaller hours.';
|
|
177
|
+
}
|
|
178
|
+
if (data?.reason === 'busy') {
|
|
179
|
+
const wait = Number(res.headers.get('retry-after')) || 5;
|
|
180
|
+
return `Glitchless is busy with other large reads right now. Nothing is wrong with the call: make it again in ${wait} second${wait === 1 ? '' : 's'}, or now with a smaller hours.`;
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// The hosted server answers a tool call within one web request, however many reads the tool makes, and each read has
|
|
186
|
+
// the server's 25 seconds of its own. So a call that has used this long gives up the read it is waiting on and says
|
|
187
|
+
// why, where the agent would otherwise get a dropped connection. (The read itself stops at the server's deadline.)
|
|
188
|
+
export const CALL_LIMITS = { ms: 27_000 };
|
|
189
|
+
function withinCall(read) {
|
|
190
|
+
const call = calls.getStore();
|
|
191
|
+
if (!call?.remote) return read;
|
|
192
|
+
let timer;
|
|
193
|
+
const late = new Promise((_, reject) => {
|
|
194
|
+
timer = setTimeout(() => reject(new Error(`This window was too big to read in one call: its reads took more than ${Math.round(CALL_LIMITS.ms / 100) / 10} seconds together (waiting for any other large read of yours running at the same time included), so the call was stopped. ${SMALLER} Make large calls one at a time.`)), Math.max(0, CALL_LIMITS.ms - (Date.now() - call.startedAt)));
|
|
195
|
+
});
|
|
196
|
+
return Promise.race([read, late]).finally(() => clearTimeout(timer));
|
|
197
|
+
}
|
|
198
|
+
|
|
145
199
|
export async function query(name, params = {}) {
|
|
146
200
|
const qs = new URLSearchParams();
|
|
147
201
|
for (const [k, v] of Object.entries(params)) if (v != null && v !== '') qs.set(k, String(v));
|
|
148
|
-
const res = await conn().fetch(`${base()}/v1/query/${name}?${qs}`, { headers: await headers() });
|
|
149
|
-
if (!res.ok)
|
|
202
|
+
const res = await withinCall(conn().fetch(`${base()}/v1/query/${name}?${qs}`, { headers: await headers() }));
|
|
203
|
+
if (!res.ok) {
|
|
204
|
+
const text = await res.text();
|
|
205
|
+
throw new Error(refusal(res, text) ?? `Glitchless API ${name} → HTTP ${res.status}: ${text.slice(0, 200)}${signInHint(res.status)}`);
|
|
206
|
+
}
|
|
150
207
|
const data = await res.json();
|
|
151
208
|
const call = calls.getStore();
|
|
152
209
|
if (call && data?.meta) Object.assign(call, { meta: data.meta, from: params.from });
|
|
@@ -231,7 +288,7 @@ export const common = {
|
|
|
231
288
|
.min(0.25)
|
|
232
289
|
.max(9600)
|
|
233
290
|
.optional()
|
|
234
|
-
.describe("Look-back window in hours (default 24), as far back as the workspace keeps data on Glitchless Cloud (the answer says when it starts later than asked). Past 744 (31 days) answers are by day."),
|
|
291
|
+
.describe("Look-back window in hours (default 24), as far back as the workspace keeps data on Glitchless Cloud (the answer says when it starts later than asked). Past 744 (31 days) answers are by day. A window that takes more than 25 seconds to read is stopped and the tool says so: ask again with fewer hours. When Glitchless is busy with other large reads the tool says to try again in a few seconds. On Glitchless Cloud an answer reads at most 100,000 raw events in all (session_type, props, matches and positions read them), the latest ones, and its note says from when."),
|
|
235
292
|
version: z.string().optional().describe('Only include sessions from this game version'),
|
|
236
293
|
steam_branch: z.string().optional().describe('Only include sessions that ran this Steam branch ("public", or a beta\'s name); games that use Steamworks send it'),
|
|
237
294
|
env: z.string().optional().describe('Only include sessions from this environment, e.g. "prod" (what the game passes to init; builds a developer runs usually send "dev")'),
|
|
@@ -283,17 +340,24 @@ const gameField = z.string().optional().describe('The game, by name or id, when
|
|
|
283
340
|
|
|
284
341
|
// A server with the tools. remote: the HTTP server's set (no local tools, and instructions to match); scopes: show
|
|
285
342
|
// only the tools these scopes allow; connection: what every call runs with (default: this process's own).
|
|
343
|
+
//
|
|
344
|
+
// The tools are all there before the server connects and never change while it runs, so it says it sends no
|
|
345
|
+
// tool-list changes (McpServer would say it does). A client that is promised them opens a subscriptions/listen
|
|
346
|
+
// stream and waits: over HTTP that is one request held open per connected agent, for news that never comes. Told
|
|
347
|
+
// there are none, a client doesn't listen, and one that listens anyway is acknowledged with nothing and closed at
|
|
348
|
+
// once. Every tools/list answer is marked stale straight away (ttlMs 0), so a client that asks again gets the
|
|
349
|
+
// current list; one that stays connected through a release keeps the list it loaded until it reconnects.
|
|
286
350
|
export function createServer({ remote = false, scopes = null, connection: c = null } = {}) {
|
|
287
351
|
const server = new McpServer(
|
|
288
352
|
{ name: 'glitchless', title: 'Glitchless', version: VERSION, websiteUrl: 'https://www.glitchless.gg', icons: [{ src: 'https://app.glitchless.gg/brand/glitchless-icon-512.png', mimeType: 'image/png', sizes: ['512x512'] }] },
|
|
289
|
-
{ instructions: instructions(remote, !scopes || scopes.includes('manage')) },
|
|
353
|
+
{ instructions: instructions(remote, !scopes || scopes.includes('manage')), capabilities: { tools: { listChanged: false } } },
|
|
290
354
|
);
|
|
291
355
|
for (const t of tools) {
|
|
292
356
|
if ((remote && t.local) || (scopes && !scopes.includes(t.scope))) continue;
|
|
293
357
|
const { inputSchema = {}, ...config } = t.config;
|
|
294
358
|
server.registerTool(t.name, { ...config, title: titleOf(t), inputSchema: z.object({ game: gameField, ...inputSchema }) }, (args = {}, ctx) => {
|
|
295
359
|
const run = () =>
|
|
296
|
-
calls.run({ game: args.game, server, remote, scopes }, async () => {
|
|
360
|
+
calls.run({ game: args.game, server, remote, scopes, startedAt: Date.now() }, async () => {
|
|
297
361
|
try {
|
|
298
362
|
return await t.handler(args, ctx);
|
|
299
363
|
} catch (err) {
|
package/src/tools/multiplayer.js
CHANGED
|
@@ -105,7 +105,11 @@ tool(
|
|
|
105
105
|
// by_prop gives its network rows in the same call).
|
|
106
106
|
const key = by ? by.replace(/^\$/, '') : (ev.properties || []).some((p) => p.key === 'region') ? 'region' : null;
|
|
107
107
|
const prop = key && (ev.properties || []).find((p) => p.key === key);
|
|
108
|
-
|
|
108
|
+
// One after another: each may read raw events, which Glitchless Cloud reads one at a time per caller, so asked
|
|
109
|
+
// together the last would spend its own time waiting in line for the first two.
|
|
110
|
+
const perf = await query('performance', { ...ask, ...(prop && !prop.identifier_like ? { by_prop: key } : {}) });
|
|
111
|
+
const worst = await query('matches', { ...ask, sort: 'lag', limit: 5 });
|
|
112
|
+
const found = await query('findings', ask);
|
|
109
113
|
const net = perf.network;
|
|
110
114
|
if (!net) return reply(`No network data from ${svc} in this window: the SDKs read it from the game's netcode, or the game calls netSample about once a second while connected (the instrument skill says how for each engine)`, {});
|
|
111
115
|
const byProp = net.by_prop ? net.by_prop.rows.map(netRow) : null;
|
|
@@ -131,7 +135,9 @@ tool(
|
|
|
131
135
|
async ({ service, hours, ...f }) => {
|
|
132
136
|
const svc = gameOf(await resolveService(service));
|
|
133
137
|
const ask = { service: svc, ...filters(f), ...range(hours) };
|
|
134
|
-
|
|
138
|
+
// One after another, as glitchless_network's: both may read raw events.
|
|
139
|
+
const d = await query('servers', ask);
|
|
140
|
+
const found = await query('findings', ask);
|
|
135
141
|
const now = d.servers_now != null ? `${d.servers_now} running now with ${d.players_on_servers} players connected` : null;
|
|
136
142
|
if (!d.kpis) return reply(`${d.why || `No server of ${svc} sent anything in this window.`}${now ? ` (${now})` : ''}`, {});
|
|
137
143
|
const k = d.kpis;
|
package/src/tools/workspace.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// A workspace's games, for an agent signed in with a workspace key (glitchless_sign_in, `glitchless-mcp login`, or
|
|
2
|
-
// OAuth over HTTP): sign in, create, set up or
|
|
2
|
+
// OAuth over HTTP): sign in, create, set up, rename or delete a game, make, list and revoke share links and claim links, mark findings known
|
|
3
3
|
// and the team's own play as testers, resolve errors, and read and change a game's alerts. Listing games, reading any
|
|
4
4
|
// of them and saving their dashboards are the other tools, with `game`.
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { define, base, isWorkspace, agent, workspaceGames, workspaceIntake, projectFor, resolveService, reply, useCredentials, readCredentials } from '../context.js';
|
|
6
|
+
import { define, base, isWorkspace, agent, workspaceGames, workspaceIntake, projectFor, forgetGame, canDeleteGames, resolveService, reply, useCredentials, readCredentials } from '../context.js';
|
|
7
7
|
import { startSignIn, CLOUD_URL } from '../login.js';
|
|
8
8
|
import { ENGINES, pickEngine, instrumentGuide, findEngine } from '../setup-guide.js';
|
|
9
9
|
|
|
@@ -103,15 +103,31 @@ async function setUp({ name, engine, files, game }) {
|
|
|
103
103
|
|
|
104
104
|
act(
|
|
105
105
|
'glitchless_create_game',
|
|
106
|
-
"Create a game in the signed-in workspace, or set one up: call this first when asked to set up, add or install Glitchless (or performance monitoring, analytics or telemetry with it) in a game, before changing the game's code. Returns the game's client token (gl_pub_…, the public key game builds send with) and the intake URL to put in the game's Glitchless.init. With engine, or with files (what you find in the game's folder, when you don't know the engine), it also returns the steps that add Glitchless to the game's code for that engine, with the intake URL and client token in them: getting the SDK, privacy, levels and events, the game's own metrics, bug reports, the player's off switch, multiplayer, and checking that data arrives. They are the instrument skill of the Glitchless plugin, for an agent without it, up to 50,000 characters. Give name for a new game or game for one already in the workspace; with neither, the steps say how to get a client token, and when files name no engine nothing is made and the answer says what to look for. On a server with no workspace (the open-source server), the steps name that server. A name that's already in the workspace returns that game, not a second one. Later calls can name it with game. With demo: true it makes the demo game instead: Zoomies with a week of sample play (findings, levels, errors, sessions and a dashboard), for trying every tool before a real game sends data. A workspace has one demo game, and it takes no room from the plan's games. With rename (and game naming which one), renames a game instead, as players know it (a jam game renamed before release): the dashboard, share links and emails show the new name, and its client token, its service (what the game sends as service in Glitchless.init) and its data stay as they are, so the game's code needn't change. Later calls name it by its new name. Ask the person before renaming their game.",
|
|
106
|
+
"Create a game in the signed-in workspace, or set one up: call this first when asked to set up, add or install Glitchless (or performance monitoring, analytics or telemetry with it) in a game, before changing the game's code. Returns the game's client token (gl_pub_…, the public key game builds send with) and the intake URL to put in the game's Glitchless.init. With engine, or with files (what you find in the game's folder, when you don't know the engine), it also returns the steps that add Glitchless to the game's code for that engine, with the intake URL and client token in them: getting the SDK, privacy, levels and events, the game's own metrics, bug reports, the player's off switch, multiplayer, and checking that data arrives. They are the instrument skill of the Glitchless plugin, for an agent without it, up to 50,000 characters. Give name for a new game or game for one already in the workspace; with neither, the steps say how to get a client token, and when files name no engine nothing is made and the answer says what to look for. On a server with no workspace (the open-source server), the steps name that server. A name that's already in the workspace returns that game, not a second one. Later calls can name it with game. With demo: true it makes the demo game instead: Zoomies with a week of sample play (findings, levels, errors, sessions and a dashboard), for trying every tool before a real game sends data. A workspace has one demo game, and it takes no room from the plan's games. With rename (and game naming which one), renames a game instead, as players know it (a jam game renamed before release): the dashboard, share links and emails show the new name, and its client token, its service (what the game sends as service in Glitchless.init) and its data stay as they are, so the game's code needn't change. Later calls name it by its new name. Ask the person before renaming their game. With delete (the game's name, repeated back as the person confirmed it, and game naming which one), deletes the game and everything Glitchless keeps for it: its data, dashboard, bug reports, keys, share links, alerts and store connections. It can't be undone. It needs a connection the person gave \"Delete games and their data, for good\", which is off unless they ticked it (a new key in Settings → Keys & access, or connecting again), and whose person is an Owner or Admin. When two games in the workspace share the name, nothing is deleted and the answer lists them (id, when made, whether they have data): ask the person which one, then call again with game set to its id. The game is gone from the workspace at once and frees its place in the plan; its client token is refused from then on; it's gone from Glitchless within the hour, and backups, including old copies of its files, keep it up to 35 more days. Only delete when the person asked for it in so many words, after telling them all of this.",
|
|
107
107
|
{
|
|
108
108
|
name: z.string().optional().describe("The game's name, as players know it (not needed with demo). One already in the workspace is returned, not made again"),
|
|
109
109
|
demo: z.boolean().optional().describe('Make the demo game, with a week of sample play'),
|
|
110
110
|
rename: z.string().optional().describe("Instead of making a game: the new name (60 characters at most) of the game that game names"),
|
|
111
|
+
delete: z.string().optional().describe("Instead of making a game: delete the game that game names (by its id when two games share the name), for good. The game's name again, as the person confirmed it, any case"),
|
|
111
112
|
engine: z.enum(ENGINES.map((e) => e.id)).optional().describe("Also return the steps that add Glitchless to the game's code, for its engine: unity, godot, unreal, threejs (React Three Fiber too), roblox, phaser, babylon, playcanvas or gamemaker; reddit for a game in a Reddit post (with files: [\"devvit.json\"] and the engine of the game in it, Reddit's steps and that engine's come together)"),
|
|
112
113
|
files: z.array(z.string()).max(500).optional().describe("Or, when you don't know the engine: what you find in the game's folder, which names it. File names at its root (project.godot, MyGame.uproject, Game.yyp, ProjectSettings/ProjectVersion.txt, default.project.json, devvit.json for a game in a Reddit post, package.json) and package.json dependencies (three, phaser, @babylonjs/core, playcanvas)"),
|
|
113
114
|
},
|
|
114
|
-
async ({ name, demo, rename, engine, files, game }) => {
|
|
115
|
+
async ({ name, demo, rename, delete: confirm, engine, files, game }) => {
|
|
116
|
+
if (confirm != null) {
|
|
117
|
+
if (name || demo || rename != null || engine || files) throw new Error('delete deletes the game that game names; leave out name, demo, rename, engine and files');
|
|
118
|
+
if (!game) throw new Error("name the game to delete with game, and its name again with delete");
|
|
119
|
+
if (!canDeleteGames()) throw new Error('This connection can\'t delete games: deleting is off unless its person turns it on. They can delete the game themselves in Settings → Game, or connect this app again and tick "Delete games and their data, for good".');
|
|
120
|
+
const pid = await projectFor(game);
|
|
121
|
+
// A game named by its id is the one the person chose, even when another game has its name.
|
|
122
|
+
const gone = await agent('DELETE', `/games/${pid}`, pid === game ? { name: confirm, id: pid } : { name: confirm }).catch((err) => {
|
|
123
|
+
if (err.code !== 'SAME_NAME') throw err;
|
|
124
|
+
const games = err.data.games.map((g) => `${g.id} (made ${g.created_at.slice(0, 10)}, ${g.has_data === null ? "whether it has data isn't known just now" : g.has_data ? `last sent data ${g.last_seen.slice(0, 10)}` : 'no data yet'})`);
|
|
125
|
+
throw new Error(`${games.length} games in this workspace are called "${confirm}": ${games.join('; ')}. Nothing was deleted. Ask the person which one they mean, then call this again with game set to that one's id.`);
|
|
126
|
+
});
|
|
127
|
+
forgetGame(pid);
|
|
128
|
+
await workspaceGames(true);
|
|
129
|
+
return reply(`Deleted ${gone.deleted.name}. It's gone from the workspace and its client token is refused from now on; it's gone from Glitchless within the hour, and backups, including old copies of its files, keep it up to 35 more days. Take Glitchless out of the game's code, or give it another game's client token.`, gone);
|
|
130
|
+
}
|
|
115
131
|
if (rename != null) {
|
|
116
132
|
if (name || demo || engine || files) throw new Error('rename renames the game that game names; leave out name, demo, engine and files');
|
|
117
133
|
const pid = await projectFor(game);
|
|
@@ -142,7 +158,7 @@ act(
|
|
|
142
158
|
if (demo) return reply(`Made the demo game, ${made.game.name}: a week of sample play from Zoomies, readable a few minutes from now. Then try glitchless_triage on it.`, made);
|
|
143
159
|
return reply(`Created ${made.game.name}. Initialise Glitchless with this client token and intake (call again with game: "${made.game.name}" and engine, or files, for the steps for its engine):`, made);
|
|
144
160
|
},
|
|
145
|
-
{ title: 'Create, set up or
|
|
161
|
+
{ title: 'Create, set up, rename or delete game', annotations: { destructiveHint: true, idempotentHint: false } },
|
|
146
162
|
);
|
|
147
163
|
|
|
148
164
|
act(
|