glitchless-mcp 0.8.0 → 0.10.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.
@@ -1,50 +1,72 @@
1
- // The game's own metrics: its custom events and funnels, and versions compared in its own terms.
1
+ // The game's own metrics: its custom events, counters and funnels, the session properties it sets, and versions (or
2
+ // Steam branches, or a property's values) compared in its own terms.
2
3
  import { z } from 'zod';
3
4
  import { query, resolveService, range, reply, common, tool, filters } from '../context.js';
4
5
 
5
6
  tool(
6
7
  'glitchless_events',
7
- "The game's own metrics, from the custom events it sends with track(): each event's count in the window, the sessions and players that sent it, how its attribute values break down (for example plays by mode, paywall views by placement, purchases started vs done), and the sums of its numeric attributes per currency (revenue: the amount of purchase events). Give `funnel` to count the sessions that went from one event to the next, in that order.",
8
+ "The game's own metrics, from the custom events it sends with track() and the streams it counts with count() (marked counted: summed on the device per window, so their numbers have sums and averages but no spread): each event's count in the window, the sessions and players that sent it, how its attribute values break down (for example plays by mode, paywall views by placement, purchases started vs done; a list attribute such as a deck by element, each event counted once under each), the sums of its numeric attributes per currency (revenue: the amount of purchase events) and their p50, p90 and p99, and `hours`, the hours played in the window, to turn any count into a rate per hour. Give `funnel` to count the sessions that went from one event to the next, in that order. With name and `rate` (a flag such as \"won\", or a word outcome \"result=win\") or `avg` (a numeric attribute), it measures that event: overall, or with `by` per value (win rate by hero, with a 95% interval for each, next to the overall rate). With name and `of` (a numeric attribute), it gives that attribute's distribution: percentiles and a histogram, optionally `by` a split. `properties` lists what the game set for its sessions with setProperties (rank, class, region, a preset), each with its values and their sessions and players; identifier_like marks one with more than 200 values a day, which is an ID rather than a property. Every read tool filters by them (props) and splits by them (by \"$rank\").",
8
9
  {
9
10
  ...common,
10
- name: z.string().optional().describe('Only this event, e.g. "paywall"'),
11
- funnel: z.string().optional().describe('Steps in order, comma-separated: "open,paywall,buy". A step can require a value: "buy=done" (any attribute) or "buy:step=done"'),
11
+ name: z.string().optional().describe('Only this event, e.g. "paywall". With rate, avg or of, the event to measure; it can carry a filter like a panel\'s event: "match_end:mode=ranked", or "battle_end:deck=hog_rider+ice_spirit" for decks with both'),
12
+ funnel: z.string().optional().describe('Steps in order, comma-separated: "open,paywall,buy". A step can require a value: "buy=done" (any attribute) or "buy:step=done"; a list matches when it has the value'),
13
+ rate: z.string().optional().describe('The share of the event\'s events where a flag holds ("won": true or false, or 1 or 0) or a word outcome holds ("result=win")'),
14
+ avg: z.string().optional().describe('A numeric attribute\'s mean per event, e.g. "duration_s"'),
15
+ of: z.string().optional().describe('A numeric attribute whose distribution to give, e.g. "duration_s" (match length) or "placement"'),
16
+ by: z.string().optional().describe('With rate, avg or of: split by an attribute (a list splits by element), $version, $level, $zone, $platform, $browser, $device_tier, $link (the kind of connection), or a session property ("$rank")'),
17
+ min: z.number().int().optional().describe('With rate or avg and by: the fewest events a row needs (default 30 for a rate, 10 for an average); smaller rows are counted in small'),
12
18
  },
13
- async ({ service, hours, name, funnel, ...f }) => {
19
+ async ({ service, hours, name, funnel, rate, avg, of, by, min, ...f }) => {
14
20
  const svc = await resolveService(service);
15
- const d = await query('events', { service: svc, ...filters(f), name, funnel, ...range(hours) });
21
+ const d = await query('events', { service: svc, ...filters(f), name: name?.split(/[:=]/)[0].trim(), event: name, funnel, rate, avg, of, by, min, ...range(hours) });
16
22
  const brief = d.events
17
23
  .slice(0, 15)
18
- .map((e) => `${e.name}: ${e.count} in ${e.sessions} session(s)${(e.sums || []).length ? `; ${e.sums.map((x) => `${x.attr} sum ${x.sum}${x.currency ? ` ${x.currency}` : ''}`).join(', ')}` : ''}`)
24
+ .map((e) => `${e.name}${e.counted ? ' (counted)' : ''}: ${e.count} in ${e.sessions} session(s)${(e.sums || []).length ? `; ${e.sums.map((x) => `${x.attr} sum ${x.sum}${x.currency ? ` ${x.currency}` : ''}`).join(', ')}` : ''}`)
19
25
  .join('\n');
20
- return reply(`Custom events for ${svc} (${hours || 24}h, ${d.sessions} sessions):\n${brief || 'None in this window. A game sends them with track(name, attrs).'}`, {
26
+ const props = d.properties || [];
27
+ const propLine = props.length ? `\nSession properties: ${props.map((p) => (p.identifier_like ? `${p.key} (an ID: too many values)` : `${p.key} (${p.values.slice(0, 5).map((v) => v.value).join(', ')}${p.values.length > 5 ? ', …' : ''})`)).join('; ')}` : '';
28
+ const m = d.measure;
29
+ const measured = m ? `\n${m.event} ${m.rate ? `rate of ${m.rate}` : `average ${m.avg}`}${m.by ? ` by ${m.by}` : ''}: ${m.empty ? m.why : m.rows ? `${m.rows.length} rows, overall ${m.overall}${m.rate ? '%' : ''}` : `${m.value}${m.unit === '%' ? '%' : ''} of ${m.events} events`}` : '';
30
+ const dist = d.distribution ? `\n${d.distribution.event} ${d.distribution.of}: ${d.distribution.empty ? d.distribution.why : `p50 ${d.distribution.p50}, p90 ${d.distribution.p90} of ${d.distribution.count}`}` : '';
31
+ return reply(`Custom events for ${svc} (${hours || 24}h, ${d.sessions} sessions, ${d.hours ?? 0} hours played):\n${brief || 'None in this window. A game sends them with track(name, attrs), and streams with count(name, attrs).'}${propLine}${measured}${dist}`, {
21
32
  events: d.events.map(({ series, ...e }) => e),
33
+ hours_played: d.hours ?? null,
34
+ properties: props,
22
35
  ...(d.funnel ? { funnel: d.funnel } : {}),
36
+ ...(m ? { measure: (({ ts, series, ...x }) => x)(m) } : {}),
37
+ ...(d.distribution ? { distribution: d.distribution } : {}),
23
38
  });
24
39
  },
25
40
  );
26
41
 
27
42
  tool(
28
43
  'glitchless_compare_versions',
29
- 'Compare game versions side by side, in the game\'s own terms first: the stats on its boards (glitchless_dashboard) and its own events per session, then the built-in measures it reports (frame time overall and per level, hitches/min, crash-free and error-free sessions, errors per session, level completion, rage-quit rate, deaths per session, geometry growth). Use it to confirm a fix or a design change after shipping a new version. For a game on Steam, by "steam_branch" compares Steam branches instead (a beta against "public"), and by "steam_build" Steam builds: a and b are then branch names or build ids.',
44
+ 'Compare game versions side by side, in the game\'s own terms first: the stats on its boards (glitchless_dashboard) and its own events per session, then the built-in measures it reports (frame time overall and per level, hitches/min, crash-free and error-free sessions, errors per session, level completion, rage-quit rate, deaths per session, geometry growth). Use it to confirm a fix or a design change after shipping a new version. Versions come in release order (when each first showed up at all, not in this window), so by default it compares the newest with the one before it, also while players of older versions still play. For a game on Steam, by "steam_branch" compares Steam branches instead (a beta against "public"), and by "steam_build" Steam builds: a and b are then branch names or build ids. By a session property ("class", "spender"; glitchless_events lists them) it compares that property\'s values the same way, the most sessions first (over 31 days or less): a and b are then values.',
30
45
  {
31
46
  service: common.service,
32
47
  hours: common.hours,
33
48
  env: common.env,
34
49
  session_type: common.session_type,
35
- a: z.string().optional().describe('Baseline version, branch or build (default: second newest)'),
50
+ props: common.props,
51
+ a: z.string().optional().describe('Baseline version, branch or build (default: the one before the newest)'),
36
52
  b: z.string().optional().describe('New version, branch or build (default: newest)'),
37
- by: z.enum(['version', 'steam_branch', 'steam_build']).optional().describe('What to compare (default version). steam_branch and steam_build need a game that uses Steamworks'),
53
+ by: z.string().optional().describe('What to compare (default version): steam_branch or steam_build (a game that uses Steamworks), or a session property\'s key, e.g. "class"'),
38
54
  },
39
- async ({ service, hours, a, b, by, env, session_type }) => {
55
+ async ({ service, hours, a, b, by, env, session_type, props }) => {
40
56
  const svc = await resolveService(service);
41
- const steam = by && by !== 'version' ? by : null;
42
- const { versions, has = {}, board = [] } = await query('versions', { service: svc, ...filters({ env, session_type }), ...(steam ? { by: steam } : {}), ...range(hours || 72) });
43
- const what = steam === 'steam_branch' ? 'Steam branch' : steam === 'steam_build' ? 'Steam build' : 'version';
44
- if (steam && !versions.length) return reply(`No session of ${svc} sent its ${what} in this window: the SDKs read it from Steamworks when the game uses it and runs from Steam`, versions);
57
+ const steam = by && by !== 'version' ? by.replace(/^\$/, '') : null;
58
+ const { versions, has = {}, board = [] } = await query('versions', { service: svc, ...filters({ env, session_type, props }), ...(steam ? { by: steam } : {}), ...range(hours || 72) });
59
+ const prop = steam && steam !== 'steam_branch' && steam !== 'steam_build';
60
+ const what = steam === 'steam_branch' ? 'Steam branch' : steam === 'steam_build' ? 'Steam build' : prop ? `${steam} value` : 'version';
61
+ if (steam && !versions.length) return reply(prop ? `No session of ${svc} has the property ${steam} in this window: the game sets it with setProperties (glitchless_events lists the properties it sends)` : `No session of ${svc} sent its ${what} in this window: the SDKs read it from Steamworks when the game uses it and runs from Steam`, versions);
45
62
  if (versions.length < 2 && !(a && b)) return reply(`Only one ${what} of ${svc} has reported in this window`, versions);
46
- const va = versions.find((v) => v.version === a) || versions.at(-2);
47
- const vb = versions.find((v) => v.version === b) || versions.at(-1);
63
+ // A version asked for by name is that one or none: never quietly another.
64
+ const va = a ? versions.find((v) => v.version === a) : versions.at(-2);
65
+ const vb = b ? versions.find((v) => v.version === b) : versions.at(-1);
66
+ if (!va || !vb) {
67
+ const missing = [!va && (a ?? 'an older one'), !vb && (b ?? 'a newer one')].filter(Boolean).join(' and ');
68
+ return reply(`No sessions of ${svc} from ${what} ${missing} in this window (${hours || 72}h); the ${what}s that reported in it: ${versions.map((v) => v.version).join(', ') || 'none'}. Try a longer window with hours`, versions);
69
+ }
48
70
  const pair = (x, y) => ({ [va.version]: x ?? null, [vb.version]: y ?? null, change: x != null && y != null ? Math.round((y - x) * 100) / 100 : null });
49
71
  // Only the measures this game reports: no frame times for a game that sends none.
50
72
  const keys = [...(has.frames ? ['frame_p50', 'frame_p95', 'frame_p99', 'hitches_per_min'] : []), 'crash_free_pct', 'error_free_pct', 'errors_per_session', ...(has.levels ? ['level_completion_pct'] : []), ...(has.deaths || has.fails ? ['rage_quit_pct'] : []), ...(has.deaths ? ['deaths_per_session'] : []), ...(has.geometry ? ['geometries_growth_per_level_load'] : [])];
@@ -54,6 +76,6 @@ tool(
54
76
  const levels = [...new Set([...Object.keys(va.level_p95 || {}), ...Object.keys(vb.level_p95 || {})])];
55
77
  const level_p95 = Object.fromEntries(levels.map((l) => [l, { [va.version]: va.level_p95?.[l] ?? null, [vb.version]: vb.level_p95?.[l] ?? null }]));
56
78
  // Branches and builds are compared from the sessions' own frame windows, which carry no level: no level_p95.
57
- return reply(`${svc}: ${steam ? `${what} ` : ''}${va.version} (${va.sessions} sessions) vs ${vb.version} (${vb.sessions} sessions)`, { board: own, events_per_session: events, delta, ...(steam ? {} : { level_p95 }), [steam ? `all_${steam === 'steam_branch' ? 'branches' : 'builds'}` : 'all_versions']: versions.map((v) => ({ [steam || 'version']: v.version, sessions: v.sessions, first_seen: new Date(v.first_seen).toISOString() })) });
79
+ return reply(`${svc}: ${steam ? `${what} ` : ''}${va.version} (${va.sessions} sessions) vs ${vb.version} (${vb.sessions} sessions)`, { board: own, events_per_session: events, delta, ...(steam ? {} : { level_p95 }), [steam ? `all_${steam === 'steam_branch' ? 'branches' : steam === 'steam_build' ? 'builds' : 'values'}` : 'all_versions']: versions.map((v) => ({ [steam || 'version']: v.version, sessions: v.sessions, first_seen: new Date(v.first_seen).toISOString(), ...(steam ? {} : { first_seen_ever: v.first_seen_ever == null ? null : new Date(v.first_seen_ever).toISOString() }) })) });
58
80
  },
59
81
  );
package/src/tools/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // The built-in reads: which games report, findings, headline numbers, frame time, errors, levels,
2
2
  // death hotspots and one session in detail.
3
3
  import { z } from 'zod';
4
- import { BASE, query, resolveService, range, reply, common, tool, slimIssue, slimGroup, filters, isWorkspace, workspaceGames } from '../context.js';
4
+ import { base, query, resolveService, range, reply, common, tool, slimIssue, slimGroup, filters, isWorkspace, workspaceGames } from '../context.js';
5
5
 
6
6
  tool('glitchless_list_games', 'List the games: with a workspace key, every game in the workspace (its id, name, client token and the services reporting to it); with a key for one game, its services, versions, environments and when they were last seen.', {}, async () => {
7
7
  if (isWorkspace()) {
@@ -9,12 +9,12 @@ tool('glitchless_list_games', 'List the games: with a workspace key, every game
9
9
  return reply(`${list.length} game(s) in this workspace. Name one with game in any tool:`, list);
10
10
  }
11
11
  const { services } = await query('services');
12
- return reply(`${services.length} game(s) reporting to ${BASE}`, services.map((s) => ({ ...s, last_seen: new Date(s.last_seen).toISOString() })));
12
+ return reply(`${services.length} game(s) reporting to ${base()}`, services.map((s) => ({ ...s, last_seen: new Date(s.last_seen).toISOString() })));
13
13
  });
14
14
 
15
15
  tool(
16
16
  'glitchless_triage',
17
- "Ranked findings for a game: performance spikes per level (with the gauges and events they correlate with), memory leaks, top errors, difficulty spikes / rage-quit hotspots and version regressions — ranked by severity and player impact, each with evidence and a suggested fix. Start here when asked 'what's wrong with my game?'.",
17
+ "Ranked findings for a game: performance spikes per level (with the gauges, counter bursts and events they correlate with), memory leaks, top errors, difficulty spikes / rage-quit hotspots, walls (a level, or one value of a level start's attribute such as a tier), version regressions, settings that run slow (a session property), the network (a whole lobby lagging at once: the server; one kind of connection, platform or region lagging; disconnects rising in a release) and the game's dedicated servers (falling behind when full, a crash that ends matches, memory that keeps climbing) — ranked by severity and player impact, each with evidence and a suggested fix, and naming a session property when most of a problem falls on one value. Start here when asked 'what's wrong with my game?'.",
18
18
  { ...common },
19
19
  async ({ service, hours, ...f }) => {
20
20
  const svc = await resolveService(service);
@@ -33,11 +33,15 @@ tool('glitchless_overview', 'Headline KPIs for a game: sessions, players, crash-
33
33
 
34
34
  tool(
35
35
  'glitchless_performance',
36
- 'Frame-time breakdown for a game: global percentiles vs the frame budget, per-level p50/p95/p99 with draw calls / triangles / geometry counts / game-context gauges, hitch causes (script, shader compile, PSO compile in Unreal, GC, asset or map load), what is on screen during hitches, which events precede hitches, per GPU tier / browser / version, memory growth per level load and the slowest recent hitches with script attribution.',
37
- { ...common, level: z.string().optional().describe('Focus on one level id, e.g. "level-2"') },
38
- async ({ service, hours, level, ...f }) => {
36
+ 'Frame-time breakdown for a game: global percentiles vs the frame budget, per-level p50/p95/p99 with draw calls / triangles / geometry counts / game-context gauges, hitch causes (script, shader compile, PSO compile in Unreal, GC, asset or map load), what is on screen during hitches, which events precede hitches, per GPU tier / browser / platform / version, per zone for an open-world game that sets them, memory growth per level load and the slowest recent hitches with script attribution. With by_prop, frame time, hitches and crash-free sessions per value of a session property (a graphics preset, a class). A multiplayer game also gets `network` (ping, loss and disconnects; glitchless_network has more).',
37
+ {
38
+ ...common,
39
+ level: z.string().optional().describe('Focus on one level id, e.g. "level-2"'),
40
+ by_prop: z.string().optional().describe('A session property (glitchless_events lists them), e.g. "preset": frame time, hitches and crash-free sessions per value, over 31 days or less'),
41
+ },
42
+ async ({ service, hours, level, by_prop, ...f }) => {
39
43
  const svc = await resolveService(service);
40
- const d = await query('performance', { service: svc, ...filters(f), ...range(hours) });
44
+ const d = await query('performance', { service: svc, ...filters(f), by_prop, ...range(hours) });
41
45
  const hitches = (level ? d.hitches.filter((h) => h.level === level) : d.hitches).slice(0, 12);
42
46
  return reply(`Frame performance for ${svc}${level ? ` (${level})` : ''}`, {
43
47
  kpis: d.kpis,
@@ -47,6 +51,10 @@ tool(
47
51
  by_gpu_tier: d.by_gpu_tier.map(slimGroup),
48
52
  by_browser: d.by_browser.map(slimGroup),
49
53
  by_version: d.by_version.map(slimGroup),
54
+ by_platform: (d.by_platform || []).map(slimGroup),
55
+ ...(d.by_zone ? { by_zone: d.by_zone.map(slimGroup) } : {}),
56
+ ...(d.by_prop ? { by_prop: { key: d.by_prop.key, ...(d.by_prop.why ? { why: d.by_prop.why } : {}), rows: d.by_prop.rows.map((r) => ({ ...slimGroup(r), all_sessions: r.all_sessions, crash_free_pct: r.crash_free_pct })) } } : {}),
57
+ ...(d.network ? { network: d.network.kpis } : {}),
50
58
  memory: d.memory,
51
59
  load: d.load,
52
60
  slowest_recent_hitches: hitches,
@@ -69,11 +77,22 @@ tool(
69
77
  },
70
78
  );
71
79
 
72
- tool('glitchless_player_funnel', 'Player experience per level: sessions that started vs completed each level, attempts, deaths per session and their causes, average clear time, rage quits (quit ≤20s after dying), session length distribution and recent rage quits with positions. Also retention: of the players first seen each day, the share back 1, 7 and 30 days later (D1, D7, D30; hours of 48 or more for D1). Retention needs player IDs: status "anonymous" means the game sends none, and privacy "install" in the SDK turns them on.', { ...common }, async ({ service, hours, ...f }) => {
73
- const svc = await resolveService(service);
74
- const d = await query('players', { service: svc, ...filters(f), ...range(hours) });
75
- return reply(`Player funnel for ${svc}`, { kpis: d.kpis, funnel: d.funnel, session_length: d.session_length, recent_rage_quits: d.rage_quits.slice(0, 15), retention: d.retention });
76
- });
80
+ tool(
81
+ 'glitchless_player_funnel',
82
+ 'Player experience per level: sessions that started vs completed each level, attempts, deaths per session and their causes, fails, abandons and the attempts a disconnect ended (never counted as fails), median and slowest clear times, rage quits (quit ≤20s after dying), session length distribution and recent rage quits with positions. With by, each level per value of what describes the attempt: an attribute the game passed to levelStart ("tier", "difficulty", "party_size"; a list such as "build" counts under each element), a session property ("$class") or a split ("$platform"): clears and wipes by difficulty, by group size, by class; level keeps one level; count "runs" counts each run once at each level it reached (a roguelite\'s biomes). Also retention: of the players first seen each day, the share back 1, 7 and 30 days later (D1, D7, D30; hours of 48 or more for D1), and with by_prop per value of a session property (spenders against the rest). Retention needs player IDs: status "anonymous" means the game sends none, and privacy "install" in the SDK turns them on.',
83
+ {
84
+ ...common,
85
+ by: z.string().optional().describe('Split each level\'s attempts: an attribute of its levelStart ("tier"), a session property ("$class") or $platform, $browser, $device_tier, $link'),
86
+ level: z.string().optional().describe('With by or count: only this level'),
87
+ count: z.enum(['runs']).optional().describe('"runs": each run (setGroup("run")) counted once at each level it reached'),
88
+ by_prop: z.string().optional().describe('Retention per value of this session property, e.g. "spender"'),
89
+ },
90
+ async ({ service, hours, by, level, count, by_prop, ...f }) => {
91
+ const svc = await resolveService(service);
92
+ const d = await query('players', { service: svc, ...filters(f), by, level, count, by_prop, ...range(hours) });
93
+ return reply(`Player funnel for ${svc}${by ? ` by ${by}` : ''}${count ? ', counting runs' : ''}`, { kpis: d.kpis, funnel: d.funnel, ...(d.funnel_by ? { funnel_by: d.funnel_by } : {}), session_length: d.session_length, recent_rage_quits: d.rage_quits.slice(0, 15), retention: d.retention });
94
+ },
95
+ );
77
96
 
78
97
  tool(
79
98
  'glitchless_death_hotspots',
@@ -88,12 +107,15 @@ tool(
88
107
 
89
108
  tool(
90
109
  'glitchless_session',
91
- 'One play session in detail: device/GPU, outcome (crashed, rage quit), and the full event timeline (levels, deaths with positions, errors, hitches with causes, agent annotations) plus per-5s frame stats. Use with session ids from errors, hitches or rage quits.',
110
+ 'One play session in detail: device/GPU, outcome (crashed, rage quit), its properties and its groups (the matches, parties and runs it was in), and the full event timeline (levels with their attributes, deaths with positions, errors, hitches with causes, counters once a window, disconnects, agent annotations) plus per-5s frame stats. Use with session ids from errors, hitches, rage quits or a match. A game server\'s session (service "<game>.server") gives its tick windows instead of frames.',
92
111
  { service: common.service, session_id: z.string().describe('Session id (s_…)') },
93
112
  async ({ service, session_id }) => {
94
113
  const svc = await resolveService(service);
95
114
  const d = await query('session', { service: svc, id: session_id });
96
115
  if (d.error) return reply(`Session ${session_id} not found in ${svc}`, {});
97
- return reply(`Session ${session_id}`, { session: d.session, timeline: d.timeline.slice(0, 150), frames: d.frames.map(({ ctx, ...f }) => ({ ...f, ...ctx })).slice(0, 120) });
116
+ // A server's windows (A9) come every 5 s: they go in a list of their own, not the timeline.
117
+ const ticks = d.timeline.filter((e) => e.type === 'server_window').map(({ ts, level, ticks, tick_hz, tick_p50, tick_p95, late, players, net_objects, cpu_pct, mem_mb, match }) => ({ ts, level, ticks, tick_hz, tick_p50, tick_p95, late, players, net_objects, cpu_pct, mem_mb, ...(match ? { match } : {}) }));
118
+ const timeline = d.timeline.filter((e) => e.type !== 'server_window').map(({ tick, ...e }) => e);
119
+ return reply(`Session ${session_id}`, { session: d.session, timeline: timeline.slice(0, 150), frames: d.frames.map(({ ctx, ...f }) => ({ ...f, ...ctx })).slice(0, 120), ...(ticks.length ? { server_windows: ticks.slice(0, 120) } : {}) });
98
120
  },
99
121
  );
@@ -1,42 +1,57 @@
1
1
  // The game's own dashboard: read its pages and one board's numbers, and save a new design.
2
2
  import { z } from 'zod';
3
- import { server, query, write, resolveService, range, reply, fail, common, tool, filters } from '../context.js';
3
+ import { define, query, write, resolveService, range, reply, common, tool, filters } from '../context.js';
4
4
 
5
5
  tool(
6
6
  'glitchless_dashboard',
7
- "The game's dashboard: its pages in order, each a board (panels in the game's own terms) or a built-in view (events, performance, errors, players, heatmaps, sessions, versions, live, reports), and one board's panels with their numbers for the window. `page` picks the board (default: the first). `source` says whether the dashboard was saved (by an agent or a person) or made automatically from what the game sends; `spec` (its pages, and its currency if it has one) is what to edit and send back to glitchless_set_dashboard. Money panels answer their `currency`, and `mismatch` lists amounts sent in another currency, which are left out.",
7
+ "The game's dashboard: its pages in order, each a board (panels in the game's own terms) or a built-in view (events, performance, errors, players, heatmaps, sessions, versions, live, reports, servers, matches), and one board's panels with their numbers for the window. A board page with `where` shows only the sessions with those property values. `page` picks the board (default: the first). `source` says whether the dashboard was saved (by an agent or a person) or made automatically from what the game sends; `spec` (its pages, and its currency if it has one) is what to edit and send back to glitchless_set_dashboard. Money panels answer their `currency`, and `mismatch` lists amounts sent in another currency, which are left out. `brand` is the game's branding on its boards and share links: its accent colour (set with glitchless_set_dashboard's accent) and whether it has a logo and a banner (people upload those in the dashboard: Edit pages → Look).",
8
8
  { ...common, page: z.string().optional().describe('Id of the board page to evaluate (default: the first board)') },
9
9
  async ({ service, hours, page, ...f }) => {
10
10
  const svc = await resolveService(service);
11
11
  const { dashboard } = await query('dashboard', { service: svc, ...filters(f), ...range(hours) });
12
12
  if (!dashboard) return reply(`${svc} has sent no data yet`, {});
13
13
  const b = await query('board', { service: svc, ...filters(f), page, ...range(hours) });
14
- const pages = dashboard.pages.map((p) => ({ id: p.id, title: p.title, ...(p.view ? { view: p.view, ...(p.options ? { options: p.options } : {}) } : { panels: p.panels }) }));
14
+ // A server without branding (501), or none set: no brand.
15
+ const brand = (await write('GET', `/v1/brand?service=${encodeURIComponent(svc)}`).catch(() => null))?.brand;
16
+ const pages = dashboard.pages.map((p) => ({ id: p.id, title: p.title, ...(p.view ? { view: p.view, ...(p.options ? { options: p.options } : {}) } : { panels: p.panels, ...(p.where ? { where: p.where } : {}) }) }));
15
17
  // A positions panel can hold thousands of bins: its busiest ten say where players die.
16
18
  const brief = (p) => (p.type === 'positions' && !p.empty ? { ...p, deaths: p.deaths?.slice(0, 10), path: p.path && { ...p.path, cells: p.path.cells.slice(0, 10) } } : p);
17
- const board = b.board ? { page: b.board.page, title: b.board.title, panels: b.board.panels.map(({ ts, series, p50, p95, ...p }) => brief(p)) } : { error: b.error };
18
- return reply(`Dashboard for ${svc} (${dashboard.source}${dashboard.updated_by ? `, saved by ${dashboard.updated_by}` : ''}):`, { pages, board, spec: dashboard.spec });
19
+ // Charts over time are left out (their numbers are in the panel's own fields, a net or servers panel's in kpis and
20
+ // rows): any list as long as the panel's buckets goes; a distribution keeps its percentiles.
21
+ const overTime = ({ ts, series, ...p }) => (Array.isArray(ts) ? Object.fromEntries(Object.entries(p).filter(([, v]) => !(Array.isArray(v) && v.length === ts.length))) : p);
22
+ const board = b.board ? { page: b.board.page, title: b.board.title, panels: b.board.panels.map((p) => brief(overTime(p))) } : { error: b.error };
23
+ return reply(`Dashboard for ${svc} (${dashboard.source}${dashboard.updated_by ? `, saved by ${dashboard.updated_by}` : ''}):`, { pages, board, spec: dashboard.spec, brand: brand ? { accent: brand.accent, logo: !!brand.logo, banner: !!brand.banner } : null });
19
24
  },
20
25
  );
21
26
 
22
27
  const panelSchema = z
23
28
  .object({
24
- type: z.enum(['stat', 'series', 'breakdown', 'funnel', 'levels', 'frame_time', 'errors', 'deaths', 'events', 'findings', 'sessions', 'versions', 'live', 'reports', 'retention', 'positions']).describe('retention: D1, D7 and D30 by the day players were first seen; needs player IDs (privacy install or full). positions: where players died on one level (and where they went), as counts per bin: safe on a shared board, and a game can poll it through a share link to draw its own dead'),
29
+ type: z.enum(['stat', 'series', 'breakdown', 'distribution', 'funnel', 'levels', 'frame_time', 'errors', 'deaths', 'events', 'findings', 'sessions', 'versions', 'live', 'reports', 'retention', 'positions', 'net', 'servers']).describe('distribution: how a numeric attribute (of) spreads, as percentiles (p50, p90, p99) and a histogram, optionally by a split: match length, time in queue, placement, floors reached. levels: starts, completions, fails, deaths and disconnects per level, with the median and p90 clear time; by splits each level\'s attempts (clears by tier, by class), count "runs" counts runs per biome. retention: D1, D7 and D30 by the day players were first seen; needs player IDs (privacy install or full); by a property, per value. positions: where players died on one level (and where they went), as counts per bin: safe on a shared board, and a game can poll it through a share link to draw its own dead. net (a multiplayer game): show ping (p50 and p95 over time, and the share of play over 150 ms), loss, or disconnects (per hour played, by reason), optionally by a split ($region, $link, $level, $version). servers (a game whose dedicated servers run the SDK in server mode): show ticks (tick time against its budget, by "players" connected, $level or $version), players, or crashes (with the matches and players each ended)'),
25
30
  title: z.string().optional().describe("In the game's own words, e.g. \"Stops won vs lost\""),
26
- note: z.string().optional().describe('One line on why this panel matters'),
31
+ note: z.string().optional().describe("One line on why this panel matters: people read it behind the info icon next to the panel's title"),
27
32
  size: z.enum(['s', 'm', 'l']).optional().describe('s = a quarter row (stats), m = half, l = full width'),
28
- metric: z.string().optional().describe('stat: sessions, players, avg_session_s, crash_free_pct, error_free_pct, frame_p95, avg_fps, hitches_per_min, errors, deaths, rage_quit_pct or players_now (sessions playing in the last two minutes, whatever the range)'),
29
- event: z.string().optional().describe('stat, series, breakdown: one event, "name", "name=value" or "name:key=value". A series or breakdown by $platform, $browser or $device_tier can leave it out: then it counts sessions (and players, with player IDs) in each'),
33
+ metric: z.string().optional().describe('stat: sessions, players, avg_session_s, crash_free_pct, error_free_pct, frame_p95, avg_fps, hitches_per_min, errors, deaths, rage_quit_pct, hours_played (the time the game was on screen), players_now (sessions playing in the last two minutes, whatever the range), runs (each run once). Network (multiplayer): ping_p50, ping_p95 (ms), loss_pct, disconnects_per_hour, disconnect_pct (level attempts a disconnect ended). Servers (from the game\'s servers in server mode): servers_now (running now, with the players connected to them), server_tick_p95, server_crash_free_pct, players_per_server. deaths and errors take per "$hours": deaths per hour played'),
34
+ event: z.string().optional().describe('stat, series, breakdown, distribution: one event, "name", "name=value" or "name:key=value". A list attribute (a deck, a build) matches when it has the value, and "battle_end:deck=hog_rider+ice_spirit" when it has all of them (any pair or trio). A series or breakdown by $platform, $browser or $device_tier can leave it out: then it counts sessions (and players, with player IDs) in each'),
30
35
  sum: z.string().optional().describe('stat, series, breakdown: add up this numeric attribute instead of counting events, e.g. "amount" of "purchase" for revenue. Money (events with a currency) shows in the game\'s currency; amounts in another currency are named, not added'),
31
- per: z.string().optional().describe('stat: divide by this event to get a percentage (event "buy=done" per "paywall"); or "$players" / "$sessions": the share of them that sent the event (conversion), or with sum, the sum per player or session (revenue per player)'),
32
- by: z.string().optional().describe('series, breakdown: the attribute to split by, e.g. "mode" or "what", or $version / $level, or a split of the sessions that sent the event: $platform (Windows, macOS, Linux, Steam Deck, iOS, Android, Web…), $browser (Chrome, Safari, Firefox, Edge…; a native build is "Godot app", "Unity app" and so on, a web build "Unity web build"), $device_tier (High-end, Mid-range, Low-end GPU, Software rendering: the tiers the Performance view uses, high to low); counts only, no sum, over 31 days or less. With sum and an attribute, event is a name only. A breakdown (by count) can also split by a Steam fact of the sessions that sent the event: $steam_branch, $steam_build, $steam_hardware, $steam_controller, $steam_language, $proton, $big_picture, $family_shared, $timed_trial. versions: $steam_branch or $steam_build compares Steam branches or builds on this page\'s stats instead of versions (the beta against "public"); needs a game that uses Steamworks'),
33
- limit: z.number().int().optional().describe('How many: errors, findings, reports and breakdown rows up to 20, sessions up to 50, series lines up to 8, retention days up to 90 (default 14)'),
36
+ per: z.string().optional().describe('stat: divide by this event to get a percentage (event "buy=done" per "paywall"); or "$players" / "$sessions": the share of them that sent the event (conversion), or with sum, the sum per player or session (revenue per player); or "$hours": per hour played (matches per hour, with sum XP or gold per hour). series, breakdown: "$hours", each bucket or row per hour played (by $version or $level each over its own hours, by an attribute every row over the window\'s)'),
37
+ rate: z.string().optional().describe('stat, series, breakdown: the share of the event\'s events where a flag holds, "won" (a boolean, or a number that is only 1 or 0), or a word outcome holds, "result=win". A breakdown gives each row its rate with a 95% interval (low, high) next to the overall rate: win rate by hero, by heat, of decks with each card (by a list), boons taken when offered. Send outcomes as booleans where you can: a word outcome split by another attribute reads the first 16 of each session\'s events'),
38
+ avg: z.string().optional().describe('stat, series, breakdown: a numeric attribute\'s mean per event instead of a count, e.g. "duration_s" by mode'),
39
+ min: z.number().int().optional().describe('breakdown with rate or avg: rows with fewer events are left out and counted in small (default 30 for a rate, 10 for an average)'),
40
+ expect: z.number().optional().describe('breakdown or stat with rate: the percentage the game intends, such as a gacha\'s published odds (0.6 for 0.6%). Rows whose interval misses it are marked, and a finding names them'),
41
+ order: z.enum(['rate', 'avg', 'count', 'value']).optional().describe('breakdown with rate or avg: rate or avg (default, the highest first), count (most events first) or value (in the values\' own order: heat 0, 1, 2)'),
42
+ of: z.string().optional().describe('distribution (required), stat: the numeric attribute whose spread to show, e.g. "duration_s". A stat with of and quantile shows one percentile: the median match'),
43
+ quantile: z.number().int().optional().describe('stat with of: the percentile, 1 to 99 (50: the median, 90: 1 in 10 is over it)'),
44
+ bins: z.number().int().optional().describe('distribution: how many histogram bars, 2 to 40 (default 20). Bars are equal round steps from the 1st to the 99th percentile; under and over count what falls outside'),
45
+ unit: z.string().optional().describe('distribution, stat with of: what the numbers are in, shown after them ("s" reads as minutes or hours when large, or the game\'s own word: "floors")'),
46
+ by: z.string().optional().describe('series, breakdown, distribution: the attribute to split by, e.g. "mode" or "what" (a list attribute splits by element: each card of a deck gets a row, and an event counts once under each), or $version / $level / $zone (where the player was in an open world, setZone), or a split of the sessions that sent the event: $platform (Windows, macOS, Linux, Steam Deck, iOS, Android, Web…), $browser (Chrome, Safari, Firefox, Edge…; a native build is "Godot app", "Unity app" and so on, a web build "Unity web build"), $device_tier (High-end, Mid-range, Low-end GPU, Software rendering: the tiers the Performance view uses, high to low), $link (Wi-Fi, Mobile data, Wired), or a session property the game sets with setProperties ($rank, $class, $region: sessions without it are "(none)", 40 values at most); counts only, no sum, over 31 days or less. levels and deaths: an attribute of the level\'s start ("tier", "party_size", a list such as "build"), a property or a split. net: $version, $level, $zone, a split or a property. servers: "players" (connected, in tenths of capacity), $level or $version. retention: a property ($spender). versions: also a property ($class), its values side by side. With sum and an attribute, event is a name only. A breakdown (by count) can also split by a Steam fact of the sessions that sent the event: $steam_branch, $steam_build, $steam_hardware, $steam_controller, $steam_language, $proton, $big_picture, $family_shared, $timed_trial. versions: $steam_branch or $steam_build compares Steam branches or builds on this page\'s stats instead of versions (the beta against "public"); needs a game that uses Steamworks'),
47
+ limit: z.number().int().optional().describe('How many: errors, findings, reports and breakdown rows up to 20, sessions up to 50, series lines up to 8, distribution rows up to 8, retention days up to 90 (default 14)'),
34
48
  steps: z.string().optional().describe('funnel: events in order, comma-separated, e.g. "paywall,buy=tapped,buy=done"'),
35
49
  label: z.string().optional().describe('levels: what the game calls a level, e.g. "Stop" or "Puzzle"'),
36
50
  sent: z.string().optional().describe('sessions: only sessions that sent this event, e.g. "buy=done"'),
37
51
  events: z.array(z.string()).optional().describe('live: only these event names or types, e.g. ["buy", "paywall", "error"]'),
38
- level: z.string().optional().describe('positions (required): the level id, as the game passes it to levelStart'),
39
- show: z.enum(['deaths', 'path', 'both', 'installs', 'revenue']).optional().describe('positions: deaths (default), path (where players went, on a coarser grid) or both. store_revenue by_country: installs (default) or revenue, what its map shows first (people can switch)'),
52
+ level: z.string().optional().describe('positions (required): the level id, as the game passes it to levelStart. levels and deaths: only this level\'s rows'),
53
+ count: z.enum(['runs']).optional().describe('levels: "runs" counts each run (setGroup("run")) once at each level it reached, however many sessions it spanned: a roguelite\'s runs that reach each biome'),
54
+ show: z.enum(['deaths', 'path', 'both', 'installs', 'revenue', 'ping', 'loss', 'disconnects', 'ticks', 'players', 'crashes']).optional().describe('positions: deaths (default), path (where players went, on a coarser grid) or both. store_revenue by_country: installs (default) or revenue, what its map shows first (people can switch). net: ping (default), loss or disconnects. servers: ticks (default), players or crashes'),
40
55
  bin: z.number().positive().optional().describe("positions: a bin's width in world units (default about a hundredth of the level). Fix it when a game draws the panel, so bins don't move as the level fills in"),
41
56
  })
42
57
  .describe('One panel');
@@ -65,43 +80,54 @@ const pageSchema = z
65
80
  title: z.string().optional().describe('The name in the sidebar, in the words the game uses (a view keeps its built-in name without one)'),
66
81
  icon: z.enum(['board', 'overview', 'events', 'perf', 'errors', 'players', 'heatmap', 'sessions', 'versions', 'live', 'flag', 'bolt', 'play', 'clock', 'bug', 'money']).optional(),
67
82
  panels: z.array(withStores(panelSchema)).optional().describe('A board: its panels, in order'),
68
- view: z.enum(['events', 'performance', 'errors', 'players', 'heatmaps', 'sessions', 'versions', 'live', 'reports']).optional().describe('A built-in view instead of panels (reports: the bug reports players sent, with their screenshots)'),
83
+ view: z.enum(['events', 'performance', 'errors', 'players', 'heatmaps', 'sessions', 'versions', 'live', 'reports', 'servers', 'matches']).optional().describe('A built-in view instead of panels (reports: the bug reports players sent, with their screenshots; servers: the game\'s dedicated servers in server mode, their ticks by map and players connected, crashes and memory; matches: the range\'s matches, each opening a match page with every player\'s ping slot by slot and the server\'s ticks under them)'),
84
+ where: z
85
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.array(z.union([z.string(), z.number(), z.boolean()]))]))
86
+ .optional()
87
+ .describe('A board page only: the session properties its sessions must have, "$<key>" → a value or a list of up to 20 (at most 4 properties), e.g. { "$rank": ["diamond", "master"] }: every panel on the page reads only those sessions (a "Diamond and up" page)'),
69
88
  options: z.object({ events: z.array(z.string()).optional() }).optional().describe('live view: events, only these event names or types'),
70
89
  })
71
90
  .describe('One page: either panels (a board) or view (a built-in view)');
72
91
 
73
- server.registerTool(
92
+ define(
74
93
  'glitchless_set_dashboard',
75
94
  {
95
+ title: 'Save dashboard',
76
96
  description:
77
- "Save the game's dashboard: its pages, in the order the sidebar shows them. Each page is a board of panels in the game's own words, or a built-in view (events, performance, errors, players, heatmaps, sessions, versions, live, reports) the game keeps, renames or drops. Design it for this game, not for a genre it isn't: a puzzle game cares about solve time and hints, a mobile game about opens, modes, the paywall and purchases (revenue: a stat with sum \"amount\" of \"purchase\"; revenue per player: per \"$players\"; conversion: event \"purchase\" per \"$players\"; revenue by item: a breakdown with sum), a platformer about deaths per level (and a positions panel for where on a level they die). For a game on several platforms, a breakdown by $platform splits players or an event between them (iOS vs Android, PC vs Mac vs Steam Deck); a web game splits by $browser, and any game by $device_tier. The first page opens first. Use the events the game sends (glitchless_events lists them, with their attributes); on a board, stats first, then the game's own events and funnels, then levels, frame_time and errors. Leave out what the game has no data for (no Heatmaps page for a game without positions, no reports page for a game that doesn't turn bug reports on). Send every page: read the current ones with glitchless_dashboard (its spec), change them, send them all back. Pass reset: true to go back to the automatic dashboard. Needs a secret key with the dashboard scope.",
97
+ "Save the game's dashboard: its pages, in the order the sidebar shows them. Each page is a board of panels in the game's own words, or a built-in view (events, performance, errors, players, heatmaps, sessions, versions, live, reports, servers, matches) the game keeps, renames or drops. Design it for this game, not for a genre it isn't: a puzzle game cares about solve time and hints, a mobile game about opens, modes, the paywall and purchases (revenue: a stat with sum \"amount\" of \"purchase\"; revenue per player: per \"$players\"; conversion: event \"purchase\" per \"$players\"; revenue by item: a breakdown with sum), a platformer about deaths per level (and a positions panel for where on a level they die). For a game on several platforms, a breakdown by $platform splits players or an event between them (iOS vs Android, PC vs Mac vs Steam Deck); a web game splits by $browser, and any game by $device_tier. For balance and outcomes, a breakdown with rate gives each row its rate and interval next to the overall one (win rate by hero: event \"match_end\", by \"hero\", rate \"won\"); per \"$hours\" turns counts and sums into rates per hour played (gold per hour); a distribution panel or a stat with of and quantile shows how long matches or runs last; a list attribute (deck, build, boons) splits by element. Split by what the game set for the session with setProperties ($rank, $class, $region), and give a page where to show only some sessions (a page for the high ranks); a levels panel by a levelStart attribute shows clears by tier or difficulty, and count \"runs\" runs per biome. A multiplayer game gets a Network page (ping_p95 and disconnect_pct stats, net panels by $region or $link), and one whose dedicated servers run the SDK in server mode a Servers page (servers_now, server_tick_p95, a servers panel by players) or the built-in servers view; a game that sets match groups can keep the built-in matches view. The first page opens first. Use the events the game sends (glitchless_events lists them, with their attributes); on a board, stats first, then the game's own events and funnels, then levels, frame_time and errors. Leave out what the game has no data for (no Heatmaps page for a game without positions, no reports page for a game that doesn't turn bug reports on). Send every page: read the current ones with glitchless_dashboard (its spec), change them, send them all back. Pass reset: true to go back to the automatic dashboard. accent sets the colour of the game's boards and share links (links, the selected page, stats, the main chart series, the map); it can be sent alone. Needs a secret key with the dashboard scope.",
78
98
  inputSchema: {
79
99
  service: z.string().optional().describe('Game service name (defaults to the most recently active game)'),
80
100
  pages: z.array(pageSchema).optional(),
81
101
  currency: z.string().optional().describe('The game\'s one currency for money panels, an ISO 4217 code such as "USD" (default: the one most of its purchases are sent in). Send it again with every save: glitchless_dashboard\'s spec has it'),
82
102
  reset: z.boolean().optional().describe('Delete the saved dashboard and go back to the automatic one'),
103
+ accent: z
104
+ .string()
105
+ .nullable()
106
+ .optional()
107
+ .describe('The accent colour of the game\'s boards and share links, "#rrggbb" (the game\'s own colour, such as its logo\'s), or null for none. Kept apart from the pages: send it alone to change only the colour. The dashboard darkens or lightens it where it would be hard to read. The logo and a banner (key art) are uploaded in the dashboard: Edit pages → Look'),
83
108
  },
84
- annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
109
+ // It replaces the saved pages (and reset: true deletes them), so it counts as destructive.
110
+ annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
85
111
  },
86
- async ({ service, pages, currency, reset }) => {
87
- try {
88
- const svc = await resolveService(service);
89
- if (!reset && !pages?.length) throw new Error('give pages, or reset: true');
90
- const res = await write(reset ? 'DELETE' : 'PUT', `/v1/dashboard?service=${encodeURIComponent(svc)}`, reset ? null : { ...(currency ? { currency } : {}), pages });
91
- if (reset) return reply(`Dashboard for ${svc} reset to automatic.`, {});
92
- // How each board looks with the last 7 days, so empty panels show up now rather than in the dashboard.
93
- const lines = [];
94
- for (const p of res.dashboard.pages) {
95
- if (p.view) {
96
- lines.push(`${p.title} (built-in ${p.view} view)`);
97
- continue;
98
- }
99
- const { board } = await query('board', { service: svc, page: p.id, ...range(168) });
100
- lines.push(`${p.title}:`, ...board.panels.map((x) => ` - ${x.title}${x.empty ? ` (no data yet: ${x.why})` : ''}${x.mismatch?.length ? ` (left out, another currency: ${x.mismatch.map((m) => `${m.events} in ${m.currency}`).join(', ')})` : ''}`));
112
+ async ({ service, pages, currency, reset, accent }) => {
113
+ const svc = await resolveService(service);
114
+ if (!reset && !pages?.length && accent === undefined) throw new Error('give pages, accent, or reset: true');
115
+ const branded = accent === undefined ? null : (await write('PUT', `/v1/brand?service=${encodeURIComponent(svc)}`, { accent })).brand;
116
+ const colour = accent === undefined ? '' : ` Accent: ${branded?.accent ?? 'none'}.`;
117
+ if (!reset && !pages?.length) return reply(`Saved the look of ${svc}'s boards.${colour}`, {});
118
+ const res = await write(reset ? 'DELETE' : 'PUT', `/v1/dashboard?service=${encodeURIComponent(svc)}`, reset ? null : { ...(currency ? { currency } : {}), pages });
119
+ if (reset) return reply(`Dashboard for ${svc} reset to automatic.${colour}`, {});
120
+ // How each board looks with the last 7 days, so empty panels show up now rather than in the dashboard.
121
+ const lines = [];
122
+ for (const p of res.dashboard.pages) {
123
+ if (p.view) {
124
+ lines.push(`${p.title} (built-in ${p.view} view)`);
125
+ continue;
101
126
  }
102
- return reply(`Saved the dashboard for ${svc} (${res.dashboard.pages.length} pages${res.dashboard.currency ? `, money in ${res.dashboard.currency}` : ''}). How it looks with the last 7 days:\n${lines.join('\n')}`, {});
103
- } catch (err) {
104
- return fail(err);
127
+ const { board } = await query('board', { service: svc, page: p.id, ...range(168) });
128
+ lines.push(`${p.title}:`, ...board.panels.map((x) => ` - ${x.title}${x.empty ? ` (no data yet: ${x.why})` : ''}${x.mismatch?.length ? ` (left out, another currency: ${x.mismatch.map((m) => `${m.events} in ${m.currency}`).join(', ')})` : ''}`));
105
129
  }
130
+ return reply(`Saved the dashboard for ${svc} (${res.dashboard.pages.length} pages${res.dashboard.currency ? `, money in ${res.dashboard.currency}` : ''}).${colour} How it looks with the last 7 days:\n${lines.join('\n')}`, {});
106
131
  },
132
+ { scope: 'dashboard' },
107
133
  );
package/src/tools/deck.js CHANGED
@@ -1,25 +1,26 @@
1
1
  // Steam Deck tools: send a build to the paired Deck (and start it), and measure it there with the
2
2
  // Glitchless SDK's --glitchless-measure, compared with a saved run. Both act on the Deck and write files
3
- // (the build on the Deck, .glitchless/deck/<id>/<name>.json in the project), so neither is read-only.
3
+ // (the build on the Deck, .glitchless/deck/<id>/<name>.json in the project), so neither is read-only, and both act on
4
+ // this computer's network, so neither is served over HTTP.
4
5
  // Pairing is not a tool: it needs the person to approve it on the Deck (glitchless-deck pair).
5
6
 
6
7
  import path from 'node:path';
7
8
  import { z } from 'zod';
8
9
  import { gameNamed, send, launch, measure, Problem } from 'glitchless-deck';
9
- import { server, fail } from '../context.js';
10
+ import { define, fail } from '../context.js';
10
11
 
11
12
  const common = {
12
13
  game: z.string().optional().describe('Game id from glitchless.deck.json (optional when the project has one game)'),
13
14
  project: z.string().optional().describe('Folder with the glitchless.deck.json (default: the folder the agent works in)'),
14
15
  };
15
16
 
16
- function progress(extra) {
17
- const token = extra?._meta?.progressToken;
17
+ function progress(ctx) {
18
+ const token = ctx?.mcpReq._meta?.progressToken;
18
19
  let step = 0;
19
20
  const lines = [];
20
21
  const log = (message) => {
21
22
  lines.push(message);
22
- if (token != null) extra.sendNotification({ method: 'notifications/progress', params: { progressToken: token, progress: ++step, message } }).catch(() => {});
23
+ if (token != null) ctx.mcpReq.notify({ method: 'notifications/progress', params: { progressToken: token, progress: ++step, message } }).catch(() => {});
23
24
  };
24
25
  return { log, lines };
25
26
  }
@@ -31,9 +32,10 @@ function find(game, project) {
31
32
  // What the person has to do is the answer, not a stack trace.
32
33
  const problem = (err, lines) => (err instanceof Problem ? { content: [{ type: 'text', text: `${lines.length ? `${lines.join('\n')}\n\n` : ''}${err.message}` }], isError: true } : fail(err));
33
34
 
34
- server.registerTool(
35
+ define(
35
36
  'glitchless_deck_send',
36
37
  {
38
+ title: 'Send to Steam Deck',
37
39
  description:
38
40
  'Send the game to the Steam Deck paired with this computer and put it in the Deck\'s library as "Devkit Game: <id>": runs the build (Godot Linux export, Unity Linux64, Unreal, a web build, or the project\'s own command), checks it is something the Deck runs (Linux x86-64, or Windows x64 through Proton), copies only what changed, and optionally starts it. Reads glitchless.deck.json in the project (glitchless-deck init writes one). Needs the Deck awake on this network and paired once with `glitchless-deck pair`, which the user approves on the Deck.',
39
41
  inputSchema: {
@@ -45,8 +47,8 @@ server.registerTool(
45
47
  },
46
48
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
47
49
  },
48
- async ({ game, project, build, launch: start, glitchless, intake } = {}, extra) => {
49
- const { log, lines } = progress(extra);
50
+ async ({ game, project, build, launch: start, glitchless, intake } = {}, ctx) => {
51
+ const { log, lines } = progress(ctx);
50
52
  try {
51
53
  const g = find(game, project);
52
54
  const r = await send(g, { build: build !== false, glitchless: !!glitchless, intake, log });
@@ -56,11 +58,13 @@ server.registerTool(
56
58
  return problem(err, lines);
57
59
  }
58
60
  },
61
+ { local: true },
59
62
  );
60
63
 
61
- server.registerTool(
64
+ define(
62
65
  'glitchless_deck_measure',
63
66
  {
67
+ title: 'Measure on Steam Deck',
64
68
  description:
65
69
  'Measure the game on the Steam Deck: Steam starts it (as "Devkit Game: <id>_measure") with --glitchless-measure, the Glitchless SDK records frame time, slow frames, hitches, render and update CPU, draw calls and new errors, then the game quits and the numbers come back here. Saved in .glitchless/deck/<id>/ and compared with a saved run (by default "baseline") using the same thresholds as glitchless_playtest; a FAIL lists the regressions. Call with save_as "baseline" BEFORE changing code, send the new build with glitchless_deck_send, then call again without arguments. For Unity, Godot and Unreal builds with the Glitchless SDK (web games: use glitchless_playtest). Takes the warm-up plus the seconds plus about 10 seconds.',
66
70
  inputSchema: {
@@ -74,8 +78,8 @@ server.registerTool(
74
78
  },
75
79
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false },
76
80
  },
77
- async ({ game, project, seconds, warmup, save_as, compare_to, args, glitchless } = {}, extra) => {
78
- const { log, lines } = progress(extra);
81
+ async ({ game, project, seconds, warmup, save_as, compare_to, args, glitchless } = {}, ctx) => {
82
+ const { log, lines } = progress(ctx);
79
83
  try {
80
84
  const r = await measure(find(game, project), { seconds: seconds ?? 10, warmup: warmup ?? 3, saveAs: save_as, compareTo: compare_to, args: args || [], glitchless: !!glitchless, log });
81
85
  const files = Object.entries(r.files || {}).map(([k, f]) => `${k}: ${f}`).join('\n');
@@ -84,4 +88,5 @@ server.registerTool(
84
88
  return problem(err, lines);
85
89
  }
86
90
  },
91
+ { local: true },
87
92
  );