@stage5/lumine 0.3.78 → 0.3.79
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/lib/admin-daily.js +43 -0
- package/lib/admin-member-trace.js +247 -0
- package/lib/admin-news.js +14 -0
- package/lib/admin-owner-trace.js +31 -2
- package/lib/admin.js +54 -2
- package/lib/commands.js +3 -0
- package/package.json +1 -1
- package/sdk/BUILD_SDK_INDEX.md +61 -12
- package/sdk/LUMINE_ADMIN.md +13 -1
package/lib/admin-daily.js
CHANGED
|
@@ -190,6 +190,45 @@ export async function dailyRunGather(options, { run = runAdmin, now, clock } = {
|
|
|
190
190
|
Object.assign(steps.at(-1), { ok: false, error });
|
|
191
191
|
};
|
|
192
192
|
const evidenceNames = /^(ai-costs|media-costs|reward-activity|reward-diagnostics|jev-review|jev-images|owner-wake|bot-output)/;
|
|
193
|
+
// A run started from a shell that then exits (`gather ... &`) used to be
|
|
194
|
+
// hung up and die before gather.json existed (11-02). Keep collecting like
|
|
195
|
+
// nohup, and keep gather.json current after every step, marked incomplete
|
|
196
|
+
// until the final summary replaces it, so an interrupted collection always
|
|
197
|
+
// leaves a readable receipt and `--resume` is only needed to finish it.
|
|
198
|
+
const ignoreHangup = () => {};
|
|
199
|
+
process.on("SIGHUP", ignoreHangup);
|
|
200
|
+
const writeProgress = () => {
|
|
201
|
+
try {
|
|
202
|
+
fs.writeFileSync(
|
|
203
|
+
path.join(dir, "gather.json"),
|
|
204
|
+
JSON.stringify(
|
|
205
|
+
{
|
|
206
|
+
inProgress: true,
|
|
207
|
+
note: "Collection is still running or was interrupted. Rerun the same gather with --resume to finish it; this file is replaced when it completes.",
|
|
208
|
+
updatedAt: new Date().toISOString(),
|
|
209
|
+
dir,
|
|
210
|
+
yesterdayUtc: yesterday,
|
|
211
|
+
costDateUtc: yesterday,
|
|
212
|
+
collection: { id: collection.collectionId, startedAt: collection.startedAt, phase: collection.phase },
|
|
213
|
+
steps,
|
|
214
|
+
failed: steps.filter((s) => !s.ok && !s.deferred).map((s) => s.name),
|
|
215
|
+
deferred: steps.filter((s) => s.deferred).map((s) => ({ name: s.name, reason: s.reason })),
|
|
216
|
+
},
|
|
217
|
+
null,
|
|
218
|
+
2,
|
|
219
|
+
),
|
|
220
|
+
{ mode: 0o600 },
|
|
221
|
+
);
|
|
222
|
+
} catch {
|
|
223
|
+
// Progress is best effort; the final summary below is authoritative.
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
try {
|
|
227
|
+
return await gatherSteps();
|
|
228
|
+
} finally {
|
|
229
|
+
process.removeListener("SIGHUP", ignoreHangup);
|
|
230
|
+
}
|
|
231
|
+
async function gatherSteps() {
|
|
193
232
|
const step = (name, args, file) => {
|
|
194
233
|
const res = collection.collect(name, args, file, evidenceNames.test(name) ? "evidence" : "priority", run);
|
|
195
234
|
steps.push({
|
|
@@ -203,6 +242,7 @@ export async function dailyRunGather(options, { run = runAdmin, now, clock } = {
|
|
|
203
242
|
reused: Boolean(res.reused),
|
|
204
243
|
...(res.deferred ? { deferred: true, reason: res.reason } : res.ok ? {} : { error: res.json?.error || res.stderr }),
|
|
205
244
|
});
|
|
245
|
+
writeProgress();
|
|
206
246
|
return res;
|
|
207
247
|
};
|
|
208
248
|
step("energy-budget", ["energy-budget"], "energy-budget.json");
|
|
@@ -411,6 +451,8 @@ export async function dailyRunGather(options, { run = runAdmin, now, clock } = {
|
|
|
411
451
|
if (botOk) renderBotOutput({ chatMessages, comments }, path.join(dir, "bot-chats.txt"));
|
|
412
452
|
|
|
413
453
|
const summary = {
|
|
454
|
+
// The collection finished (failed steps are listed separately).
|
|
455
|
+
inProgress: false,
|
|
414
456
|
collectedAt: new Date().toISOString(),
|
|
415
457
|
durationMs: Math.round(performance.now() - startedAt),
|
|
416
458
|
dir,
|
|
@@ -460,6 +502,7 @@ export async function dailyRunGather(options, { run = runAdmin, now, clock } = {
|
|
|
460
502
|
status: summary.failed.length ? "partial_failure" : summary.deferred.length ? "deferred" : "success",
|
|
461
503
|
data: summary,
|
|
462
504
|
};
|
|
505
|
+
}
|
|
463
506
|
}
|
|
464
507
|
|
|
465
508
|
// Recent, provably never-Featured Subjects with the context the editorial
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// `lumine admin member-trace ...`: the owner trace switched on for specific
|
|
2
|
+
// member accounts, so a bug one member reports (and Mikey cannot reproduce)
|
|
3
|
+
// can be read the way his own are. The server keeps 30 days.
|
|
4
|
+
//
|
|
5
|
+
// lumine admin member-trace list
|
|
6
|
+
// lumine admin member-trace on <username> --reason "<why>"
|
|
7
|
+
// lumine admin member-trace off <username>
|
|
8
|
+
// lumine admin member-trace <username> [--since 2h] [--source all|client|server] [...]
|
|
9
|
+
// (`member-trace read <username>` is the same, for a member named list/on/off/read)
|
|
10
|
+
|
|
11
|
+
import { buildOwnerTraceOperation, formatOwnerTrace } from "./admin-owner-trace.js";
|
|
12
|
+
|
|
13
|
+
export const MEMBER_TRACE_USAGE =
|
|
14
|
+
"Usage: lumine admin member-trace list | on <username> --reason <why> | off <username> | [read] <username> [--since 2h|30m|3d|<iso>|<unix>] [--until <unix-second>] [--cursor <time:id>] [--source all|client|server] [--type reload,route,chat-select,error,api,...] [--path <substring>] [--limit 300] [--json].";
|
|
15
|
+
|
|
16
|
+
const ACTIONS = new Set(["list", "on", "off", "read"]);
|
|
17
|
+
const SOURCES = new Set(["all", "client", "server"]);
|
|
18
|
+
|
|
19
|
+
function validationError(message) {
|
|
20
|
+
const error = new Error(message);
|
|
21
|
+
error.code = "CLI_ADMIN_CLI_VALIDATION";
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function memberName(value) {
|
|
26
|
+
const name = String(value || "").trim().replace(/^@/, "");
|
|
27
|
+
if (!name) throw validationError(MEMBER_TRACE_USAGE);
|
|
28
|
+
if (!/^[^\s/?#]{1,40}$/.test(name)) {
|
|
29
|
+
throw validationError("Name the member by username or user id.");
|
|
30
|
+
}
|
|
31
|
+
return name;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function buildMemberTraceOperation({ action = "", target = "", options }) {
|
|
35
|
+
if (action === "list") {
|
|
36
|
+
return {
|
|
37
|
+
name: "member-trace.list",
|
|
38
|
+
method: "GET",
|
|
39
|
+
path: "/cli/admin/member-trace/accounts",
|
|
40
|
+
body: undefined,
|
|
41
|
+
mutates: false,
|
|
42
|
+
requiresRun: false,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (action === "on") {
|
|
46
|
+
const reason = String(options.adminReason || "").trim();
|
|
47
|
+
if (!reason) {
|
|
48
|
+
throw validationError(
|
|
49
|
+
'Say why with --reason (for example --reason "General chat main keeps reloading").',
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
name: "member-trace.on",
|
|
54
|
+
method: "POST",
|
|
55
|
+
path: "/cli/admin/member-trace/on",
|
|
56
|
+
body: { user: memberName(target), reason: reason.slice(0, 255) },
|
|
57
|
+
mutates: true,
|
|
58
|
+
requiresRun: false,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (action === "off") {
|
|
62
|
+
return {
|
|
63
|
+
name: "member-trace.off",
|
|
64
|
+
method: "POST",
|
|
65
|
+
path: "/cli/admin/member-trace/off",
|
|
66
|
+
body: { user: memberName(target) },
|
|
67
|
+
mutates: true,
|
|
68
|
+
requiresRun: false,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const user = memberName(action === "read" ? target : action);
|
|
72
|
+
if (!ACTIONS.has(action) && target) {
|
|
73
|
+
throw validationError(MEMBER_TRACE_USAGE);
|
|
74
|
+
}
|
|
75
|
+
// the owner trace's filters (--since/--until/--cursor/--type/--path/--limit)
|
|
76
|
+
const owner = buildOwnerTraceOperation(options);
|
|
77
|
+
const query = new URLSearchParams(owner.path.split("?")[1] || "");
|
|
78
|
+
query.set("user", user);
|
|
79
|
+
const source = String(options.adminTraceSource || "").trim();
|
|
80
|
+
if (source) {
|
|
81
|
+
if (!SOURCES.has(source)) {
|
|
82
|
+
throw validationError("--source is all, client (the website on the device) or server (the API's view of its requests).");
|
|
83
|
+
}
|
|
84
|
+
query.set("source", source);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
name: "member-trace.read",
|
|
88
|
+
method: "GET",
|
|
89
|
+
path: `/cli/admin/member-trace?${query.toString()}`,
|
|
90
|
+
body: undefined,
|
|
91
|
+
mutates: false,
|
|
92
|
+
requiresRun: false,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function formatWhen(seconds) {
|
|
97
|
+
const value = Number(seconds);
|
|
98
|
+
if (!value) return "never";
|
|
99
|
+
return new Date(value * 1000).toISOString().replace("T", " ").slice(0, 16) + " UTC";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function formatMemberTraceList(data) {
|
|
103
|
+
const accounts = Array.isArray(data?.accounts) ? data.accounts : [];
|
|
104
|
+
if (!accounts.length) return ["No member is traced."];
|
|
105
|
+
const lines = [`${accounts.length} traced member account(s):`];
|
|
106
|
+
for (const account of accounts) {
|
|
107
|
+
lines.push(
|
|
108
|
+
` ${account.username || "?"} (#${account.userId}) · on since ${formatWhen(account.enabledAt)}${account.enabledByUsername ? ` by ${account.enabledByUsername}` : ""} · ${account.reason || "(no reason)"}`,
|
|
109
|
+
);
|
|
110
|
+
lines.push(
|
|
111
|
+
` last 24 h: ${account.clientRows24h ?? "?"} website event(s) (last ${formatWhen(account.lastClientAt)}), ${account.serverRows24h ?? "?"} API request row(s) (last ${formatWhen(account.lastServerAt)})`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
return lines;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function formatMemberTraceSwitch(data) {
|
|
118
|
+
const who = `${data?.username || "?"} (#${data?.userId ?? "?"})`;
|
|
119
|
+
if (data?.enabled) {
|
|
120
|
+
return [
|
|
121
|
+
data.alreadyOn
|
|
122
|
+
? `Member trace was already on for ${who}.`
|
|
123
|
+
: `Member trace is on for ${who}. Every API process picks it up within ${data.effectiveWithinSeconds ?? 30} s; the website starts tracing at the member's next page load.`,
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
return [
|
|
127
|
+
data?.wasOn
|
|
128
|
+
? `Member trace is off for ${who}. Rows already kept expire after ${data.keptRowsExpireAfterDays ?? 30} days.`
|
|
129
|
+
: `Member trace was not on for ${who}.`,
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function count(map, key) {
|
|
134
|
+
map.set(key, (map.get(key) || 0) + 1);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function listCounts(map) {
|
|
138
|
+
return [...map.entries()]
|
|
139
|
+
.sort((a, b) => b[1] - a[1])
|
|
140
|
+
.map(([key, n]) => `${key} ×${n}`)
|
|
141
|
+
.join(", ");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The plain-words summary the daily run reports: which website build the
|
|
145
|
+
// device runs (as the website says and as the API saw it), page loads and how
|
|
146
|
+
// they were opened, self-reloads by reason, errors.
|
|
147
|
+
export function summarizeMemberTrace(data) {
|
|
148
|
+
const events = Array.isArray(data?.events) ? data.events : [];
|
|
149
|
+
const client = events.filter((event) => event.type !== "api" && event.type !== "api-dropped");
|
|
150
|
+
const server = events.filter((event) => event.type === "api" || event.type === "api-dropped");
|
|
151
|
+
const versions = new Map();
|
|
152
|
+
const bundles = new Map();
|
|
153
|
+
const navTypes = new Map();
|
|
154
|
+
const reloads = new Map();
|
|
155
|
+
const errors = new Map();
|
|
156
|
+
const loadCauses = new Map();
|
|
157
|
+
let socketDrops = 0;
|
|
158
|
+
let socketDropsVisible = 0;
|
|
159
|
+
let chatLoadingScreens = 0;
|
|
160
|
+
for (const event of client) {
|
|
161
|
+
const data = event.data || {};
|
|
162
|
+
if (event.type === "session") {
|
|
163
|
+
count(versions, data.version || "?");
|
|
164
|
+
if (data.entry) count(bundles, data.entry);
|
|
165
|
+
count(navTypes, data.navType || "?");
|
|
166
|
+
} else if (event.type === "boot") {
|
|
167
|
+
count(
|
|
168
|
+
loadCauses,
|
|
169
|
+
data.byCode ? `code:${data.byCode}` : data.on ? "tracing switched on" : data.navType === "reload" ? "reload by hand/browser" : data.navType || "?",
|
|
170
|
+
);
|
|
171
|
+
} else if (event.type === "socket" && data.e === "disconnect") {
|
|
172
|
+
socketDrops += 1;
|
|
173
|
+
if (data.vis === "visible") socketDropsVisible += 1;
|
|
174
|
+
} else if (event.type === "chat-loading" && data.e === "shown") {
|
|
175
|
+
chatLoadingScreens += 1;
|
|
176
|
+
} else if (event.type === "reload") {
|
|
177
|
+
count(reloads, data.reason || "?");
|
|
178
|
+
} else if (event.type === "error" || event.type === "rejection" || event.type === "boundary-error") {
|
|
179
|
+
count(errors, `${event.type}: ${String(data.msg || "").slice(0, 80)}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const apiVersions = new Map();
|
|
183
|
+
const statuses = new Map();
|
|
184
|
+
const devices = new Set();
|
|
185
|
+
let sessionLoads = 0;
|
|
186
|
+
for (const event of server) {
|
|
187
|
+
const data = event.data || {};
|
|
188
|
+
if (event.type !== "api") continue;
|
|
189
|
+
count(apiVersions, data.v || "?");
|
|
190
|
+
devices.add(event.sessionId);
|
|
191
|
+
const status = data.s === "aborted" ? "aborted" : Number(data.s) >= 400 ? String(data.s) : null;
|
|
192
|
+
if (status) count(statuses, status);
|
|
193
|
+
if (String(event.path || "").startsWith("/user/session") && !String(event.path).startsWith("/user/session/")) {
|
|
194
|
+
sessionLoads += 1;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const lines = [];
|
|
198
|
+
lines.push(
|
|
199
|
+
`Website: ${client.filter((event) => event.type === "session").length} page load(s)${navTypes.size ? ` (opened by ${listCounts(navTypes)})` : ""}${versions.size ? ` · version ${listCounts(versions)}` : ""}${bundles.size ? ` · bundle ${listCounts(bundles)}` : ""}`,
|
|
200
|
+
);
|
|
201
|
+
if (loadCauses.size) lines.push(`Why pages loaded: ${listCounts(loadCauses)}`);
|
|
202
|
+
lines.push(`Self-reloads: ${reloads.size ? listCounts(reloads) : "none recorded"}`);
|
|
203
|
+
lines.push(
|
|
204
|
+
`Socket drops: ${socketDrops}${socketDrops ? ` (${socketDropsVisible} while the page was visible)` : ""} · full chat loading screens: ${chatLoadingScreens}`,
|
|
205
|
+
);
|
|
206
|
+
lines.push(`Errors: ${errors.size ? listCounts(errors) : "none recorded"}`);
|
|
207
|
+
lines.push(
|
|
208
|
+
`API view: ${server.length} request row(s) from ${devices.size} device(s)${apiVersions.size ? ` · reported website version ${listCounts(apiVersions)}` : ""} · session loads ${sessionLoads}${statuses.size ? ` · failures ${listCounts(statuses)}` : ""}`,
|
|
209
|
+
);
|
|
210
|
+
if (!client.length && server.length) {
|
|
211
|
+
lines.push(
|
|
212
|
+
" No website events: the device has not run a website build with the member trace yet (an older cached bundle?), or it has not loaded since tracing was switched on.",
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return lines;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function formatMemberTrace(data) {
|
|
219
|
+
const user = data?.user || {};
|
|
220
|
+
const who = `${user.username || "?"} (#${user.id ?? "?"})`;
|
|
221
|
+
const lines = [
|
|
222
|
+
`Member trace for ${who}${user.traced ? `, on since ${formatWhen(user.enabledAt)}: ${user.reason || ""}` : ", tracing is OFF (older rows only)"}${data?.source && data.source !== "all" ? ` · ${data.source} rows only` : ""}${data?.duplicates ? ` · ${data.duplicates} re-sent duplicate(s) hidden` : ""}`,
|
|
223
|
+
];
|
|
224
|
+
for (const line of summarizeMemberTrace(data)) lines.push(` ${line}`);
|
|
225
|
+
const events = Array.isArray(data?.events) ? data.events : [];
|
|
226
|
+
const client = events.filter((event) => event.type !== "api" && event.type !== "api-dropped");
|
|
227
|
+
const server = events.filter((event) => event.type === "api" || event.type === "api-dropped");
|
|
228
|
+
if (data?.source !== "server") {
|
|
229
|
+
lines.push("");
|
|
230
|
+
lines.push(...formatOwnerTrace({ ...data, events: client }, { title: "Website events (from the device)" }));
|
|
231
|
+
}
|
|
232
|
+
if (data?.source !== "client") {
|
|
233
|
+
lines.push("");
|
|
234
|
+
lines.push(...formatOwnerTrace({ ...data, events: server }, { title: "API view (requests from this account; session = device tag)" }));
|
|
235
|
+
}
|
|
236
|
+
return lines;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export function printMemberTraceResult(operation, data) {
|
|
240
|
+
const lines =
|
|
241
|
+
operation.name === "member-trace.list"
|
|
242
|
+
? formatMemberTraceList(data)
|
|
243
|
+
: operation.name === "member-trace.read"
|
|
244
|
+
? formatMemberTrace(data)
|
|
245
|
+
: formatMemberTraceSwitch(data);
|
|
246
|
+
for (const line of lines) console.log(line);
|
|
247
|
+
}
|
package/lib/admin-news.js
CHANGED
|
@@ -252,6 +252,20 @@ export function validateNewsEditorial({ claim: claimValue, editorial }) {
|
|
|
252
252
|
export function writeNewsClaimArtifacts({ result, outputPath, scaffoldPath }) {
|
|
253
253
|
const claim = result?.data?.claim || null;
|
|
254
254
|
const artifacts = { claimFile: null, scaffoldFile: null };
|
|
255
|
+
if (!claim) {
|
|
256
|
+
// Nothing to claim (the edition already printed, or the next one has not
|
|
257
|
+
// opened yet). Never overwrite an existing claim file with a null claim:
|
|
258
|
+
// that destroyed a valid claim when a run tried too early (11-01, 11-02).
|
|
259
|
+
const nextEditionAt = Number(result?.data?.newspaper?.nextEditionAt) || null;
|
|
260
|
+
artifacts.notClaimed = {
|
|
261
|
+
status: result?.status || null,
|
|
262
|
+
printDecision: result?.data?.newspaper?.printDecision || null,
|
|
263
|
+
nextEditionAt,
|
|
264
|
+
nextEditionAtIso: nextEditionAt ? new Date(nextEditionAt * 1000).toISOString() : null,
|
|
265
|
+
outputLeftUnchanged: outputPath || null,
|
|
266
|
+
};
|
|
267
|
+
return artifacts;
|
|
268
|
+
}
|
|
255
269
|
if (outputPath) {
|
|
256
270
|
artifacts.claimFile = writeAdminJsonFile(
|
|
257
271
|
outputPath,
|
package/lib/admin-owner-trace.js
CHANGED
|
@@ -129,6 +129,7 @@ function describeSession(data = {}, path = "") {
|
|
|
129
129
|
: data.navType
|
|
130
130
|
? `nav ${data.navType}`
|
|
131
131
|
: "",
|
|
132
|
+
data.entry ? `bundle ${data.entry}` : "",
|
|
132
133
|
describeNet(data.net),
|
|
133
134
|
].filter(Boolean);
|
|
134
135
|
if (path) parts.push(`at ${path}`);
|
|
@@ -186,6 +187,24 @@ export function describeOwnerTraceEvent(event) {
|
|
|
186
187
|
case "error":
|
|
187
188
|
case "rejection":
|
|
188
189
|
return `${data.msg || "(no message)"}${data.src ? ` (${data.src}:${data.line}:${data.col})` : ""}${data.status ? ` HTTP ${data.status}` : ""}`;
|
|
190
|
+
// the member trace's events (and the reload/chat ones the owner trace
|
|
191
|
+
// now records too)
|
|
192
|
+
case "reload":
|
|
193
|
+
return `SELF-RELOAD ${data.reason || "?"}${pairs(data, ["reason", "v"]) ? ` · ${pairs(data, ["reason", "v"])}` : ""}`;
|
|
194
|
+
case "chat-select":
|
|
195
|
+
return `channel ${data.channelId ?? "?"}${data.subchannel ? `/${data.subchannel}` : ""}${data.subchannelId ? ` (subchannel ${data.subchannelId})` : ""}${data.pathId ? ` · path ${data.pathId}` : ""}${data.chatType ? ` · ${data.chatType}` : ""}`;
|
|
196
|
+
case "boot":
|
|
197
|
+
return `page loaded${data.navType ? ` (${data.navType})` : ""}${data.byCode ? ` · reloaded by code: ${data.byCode} ${data.byCodeAgoMs ?? "?"}ms earlier${data.byCodeAt ? ` at ${data.byCodeAt}` : ""}` : data.navType === "reload" ? " · no code reload note (by hand or by the browser)" : ""}${data.kept ? ` · ${data.kept} batch(es) kept from an earlier page` : ""}${data.on ? ` · tracing switched on (${data.on})` : ""}`;
|
|
198
|
+
case "socket":
|
|
199
|
+
return `socket ${data.e || "?"}${data.reason ? ` (${data.reason})` : ""} · ${data.vis || "?"}${data.visibleForMs !== undefined ? ` ${formatDuration(data.visibleForMs)} after the page became visible` : ""}${data.upMs !== undefined ? ` · was up ${formatDuration(data.upMs)}` : ""}${data.downMs !== undefined ? ` · was down ${formatDuration(data.downMs)}` : ""}`;
|
|
200
|
+
case "chat-loading":
|
|
201
|
+
return data.e === "shown" ? 'full "Loading Twinkle Chat..." screen shown' : `full chat loading screen gone after ${formatDuration(data.ms)}`;
|
|
202
|
+
case "boundary-error":
|
|
203
|
+
return `error screen at ${data.at || "?"}: ${data.msg || "(no message)"}${data.lazy ? " · chunk load" : ""}${data.truncated ? " · truncated chunk" : ""}`;
|
|
204
|
+
case "api":
|
|
205
|
+
return describeApiRow(data, event.path);
|
|
206
|
+
case "api-dropped":
|
|
207
|
+
return `${data.count ?? "?"} more API request(s) in that minute not kept (cap)`;
|
|
189
208
|
default:
|
|
190
209
|
return pairs(data);
|
|
191
210
|
}
|
|
@@ -251,6 +270,16 @@ function describeWake(data) {
|
|
|
251
270
|
return parts.join(" · ");
|
|
252
271
|
}
|
|
253
272
|
|
|
273
|
+
// One request the API saw from a traced member: method, route, status, time,
|
|
274
|
+
// the website version the request reported.
|
|
275
|
+
function describeApiRow(data) {
|
|
276
|
+
const params = isPlainObject(data.p)
|
|
277
|
+
? ` ${Object.entries(data.p).map(([key, value]) => `${key}=${value}`).join(",")}`
|
|
278
|
+
: "";
|
|
279
|
+
const server = [data.h ? `host ${data.h}` : "", data.pst ? `worker since ${new Date(data.pst * 1000).toISOString().slice(11, 19)}Z` : ""].filter(Boolean).join(" ");
|
|
280
|
+
return `${data.m || "?"} → ${data.s ?? "?"} in ${data.ms ?? "?"}ms · website v${data.v || "?"}${params}${server ? ` · ${server}` : ""}${data.ua ? ` · ua ${data.ua}` : ""}`;
|
|
281
|
+
}
|
|
282
|
+
|
|
254
283
|
function isPlainObject(value) {
|
|
255
284
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
256
285
|
}
|
|
@@ -336,13 +365,13 @@ function describeNavTiming(data) {
|
|
|
336
365
|
return [head, `${data.nav || "?"} via ${data.via || "?"}`, ...steps, ...tail].join(" · ");
|
|
337
366
|
}
|
|
338
367
|
|
|
339
|
-
export function formatOwnerTrace(data) {
|
|
368
|
+
export function formatOwnerTrace(data, { title = "Owner trace" } = {}) {
|
|
340
369
|
const events = Array.isArray(data?.events) ? data.events : [];
|
|
341
370
|
const lines = [];
|
|
342
371
|
const sessions = new Set(events.map((event) => event.sessionId));
|
|
343
372
|
const since = Number(data?.since || 0);
|
|
344
373
|
lines.push(
|
|
345
|
-
|
|
374
|
+
`${title} since ${since ? `${formatDay(since * 1000)} ${formatClock(since * 1000).slice(0, 5)}` : "?"} · ${events.length} event(s) · ${sessions.size} session(s)${data?.truncated ? ` · more pages (keep --since/--until; --cursor ${data.nextCursor || "unavailable"})` : ""}`,
|
|
346
375
|
);
|
|
347
376
|
if (!events.length) {
|
|
348
377
|
lines.push("Nothing recorded in this window.");
|
package/lib/admin.js
CHANGED
|
@@ -44,6 +44,10 @@ import {
|
|
|
44
44
|
buildOwnerTraceOperation,
|
|
45
45
|
printOwnerTrace,
|
|
46
46
|
} from "./admin-owner-trace.js";
|
|
47
|
+
import {
|
|
48
|
+
buildMemberTraceOperation,
|
|
49
|
+
printMemberTraceResult,
|
|
50
|
+
} from "./admin-member-trace.js";
|
|
47
51
|
import { buildRolesOperation, printRoles } from "./admin-roles.js";
|
|
48
52
|
import { buildSpendingOperation, completeSpendingReport, formatSpending } from "./admin-spending.js";
|
|
49
53
|
import { buildCraftOperation, formatCraftResult } from "./admin-craft.js";
|
|
@@ -1872,6 +1876,7 @@ function transformAdminResult({
|
|
|
1872
1876
|
}
|
|
1873
1877
|
if (operation.name === "subjects.candidates") {
|
|
1874
1878
|
assertSubjectWindowResult({ operation, result: transformed });
|
|
1879
|
+
transformed = markSubjectsNeedingReveal(transformed);
|
|
1875
1880
|
}
|
|
1876
1881
|
if (operation.name === "builds.candidates") {
|
|
1877
1882
|
assertBuildWindowResult({ operation, result: transformed });
|
|
@@ -1923,6 +1928,30 @@ export function assertRecommendationWindowResult({ operation, result }) {
|
|
|
1923
1928
|
}
|
|
1924
1929
|
}
|
|
1925
1930
|
|
|
1931
|
+
// A secret Subject's effort can't be set until its secret is revealed through
|
|
1932
|
+
// the canonical action (CLI_ADMIN_SECRET_REVEAL_REQUIRED). Say so on the
|
|
1933
|
+
// candidate itself, with the exact command, instead of failing at effort set.
|
|
1934
|
+
export function markSubjectsNeedingReveal(result) {
|
|
1935
|
+
const subjects = result?.data?.subjects;
|
|
1936
|
+
if (!Array.isArray(subjects)) return result;
|
|
1937
|
+
return {
|
|
1938
|
+
...result,
|
|
1939
|
+
data: {
|
|
1940
|
+
...result.data,
|
|
1941
|
+
subjects: subjects.map((subject) => {
|
|
1942
|
+
const needsReveal =
|
|
1943
|
+
(subject?.secret?.hasSecret === true ||
|
|
1944
|
+
subject?.hasSecretAnswer === true ||
|
|
1945
|
+
subject?.hasSecretAttachment === true) &&
|
|
1946
|
+
subject?.secret?.revealed !== true;
|
|
1947
|
+
return needsReveal
|
|
1948
|
+
? { ...subject, needsReveal: true, revealCommand: `lumine admin subject reveal ${subject.id}` }
|
|
1949
|
+
: subject;
|
|
1950
|
+
}),
|
|
1951
|
+
},
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1926
1955
|
export function assertSubjectWindowResult({ operation, result }) {
|
|
1927
1956
|
const mode = operation?.pagination?.coverageMode;
|
|
1928
1957
|
if (!mode || mode === "legacy") return;
|
|
@@ -2714,6 +2743,10 @@ export function parseAdminOperation(options) {
|
|
|
2714
2743
|
if (namespace === "owner-trace") {
|
|
2715
2744
|
return buildOwnerTraceOperation(options);
|
|
2716
2745
|
}
|
|
2746
|
+
// The owner trace switched on for specific members (admin-member-trace.js).
|
|
2747
|
+
if (namespace === "member-trace") {
|
|
2748
|
+
return buildMemberTraceOperation({ action, target, options });
|
|
2749
|
+
}
|
|
2717
2750
|
if (namespace === "jev-routing") {
|
|
2718
2751
|
return buildJevRoutingReviewOperation({ action, target, extra, options });
|
|
2719
2752
|
}
|
|
@@ -6199,9 +6232,10 @@ async function printSpooledAdminResult({ operation, result, storage }) {
|
|
|
6199
6232
|
console.log(`${count} subject(s):`);
|
|
6200
6233
|
await forEachPaginatedResultItem(result, async (subject) => {
|
|
6201
6234
|
console.log(
|
|
6202
|
-
`#${subject.id} ${subject.title || "(untitled)"} — ${subject.author?.username || "unknown"} — effort ${subject.effortLevel ?? "unknown"}`,
|
|
6235
|
+
`#${subject.id} ${subject.title || "(untitled)"} — ${subject.author?.username || "unknown"} — effort ${subject.effortLevel ?? "unknown"}${subject.needsReveal ? " — secret: reveal before setting effort" : ""}`,
|
|
6203
6236
|
);
|
|
6204
6237
|
console.log(` ${subject.url}`);
|
|
6238
|
+
if (subject.needsReveal) console.log(` ${subject.revealCommand}`);
|
|
6205
6239
|
});
|
|
6206
6240
|
} else if (storage.collectionKey === "events") {
|
|
6207
6241
|
console.log(`${count} audit event(s):`);
|
|
@@ -7691,6 +7725,10 @@ function printAdminResult({ operation, result }) {
|
|
|
7691
7725
|
printOwnerTrace(data);
|
|
7692
7726
|
return;
|
|
7693
7727
|
}
|
|
7728
|
+
if (String(operation.name || "").startsWith("member-trace.")) {
|
|
7729
|
+
printMemberTraceResult(operation, data);
|
|
7730
|
+
return;
|
|
7731
|
+
}
|
|
7694
7732
|
if (operation.name === "jevRouting.review") {
|
|
7695
7733
|
for (const line of formatJevRoutingReview(data)) console.log(line);
|
|
7696
7734
|
return;
|
|
@@ -8227,9 +8265,10 @@ function printAdminResult({ operation, result }) {
|
|
|
8227
8265
|
console.log(`${data.subjects.length} subject(s):`);
|
|
8228
8266
|
for (const subject of data.subjects) {
|
|
8229
8267
|
console.log(
|
|
8230
|
-
`#${subject.id} ${subject.title || "(untitled)"} — ${subject.author?.username || "unknown"} — effort ${subject.effortLevel ?? "unknown"}`,
|
|
8268
|
+
`#${subject.id} ${subject.title || "(untitled)"} — ${subject.author?.username || "unknown"} — effort ${subject.effortLevel ?? "unknown"}${subject.needsReveal ? " — secret: reveal before setting effort" : ""}`,
|
|
8231
8269
|
);
|
|
8232
8270
|
console.log(` ${subject.url}`);
|
|
8271
|
+
if (subject.needsReveal) console.log(` ${subject.revealCommand}`);
|
|
8233
8272
|
}
|
|
8234
8273
|
printPagination(data.pagination);
|
|
8235
8274
|
return;
|
|
@@ -8248,6 +8287,19 @@ function printAdminResult({ operation, result }) {
|
|
|
8248
8287
|
printPagination(data.pagination);
|
|
8249
8288
|
return;
|
|
8250
8289
|
}
|
|
8290
|
+
if (data.artifacts?.notClaimed) {
|
|
8291
|
+
const info = data.artifacts.notClaimed;
|
|
8292
|
+
const opens = info.nextEditionAt
|
|
8293
|
+
? `${new Date(info.nextEditionAt * 1000).toISOString().replace(".000Z", "Z")} (${new Date(info.nextEditionAt * 1000).toLocaleString("en-US", { timeZone: "Asia/Seoul", hour: "2-digit", minute: "2-digit", month: "short", day: "numeric" })} KST)`
|
|
8294
|
+
: "an unknown time";
|
|
8295
|
+
console.log(
|
|
8296
|
+
`No edition to claim${info.printDecision === "already_printed" ? ": today's paper is already printed" : ""}. The next edition opens at ${opens}.`,
|
|
8297
|
+
);
|
|
8298
|
+
if (info.outputLeftUnchanged) {
|
|
8299
|
+
console.log(`${info.outputLeftUnchanged} was left unchanged. Run news claim again after the edition opens.`);
|
|
8300
|
+
}
|
|
8301
|
+
return;
|
|
8302
|
+
}
|
|
8251
8303
|
if (data.claim) {
|
|
8252
8304
|
if (data.artifacts?.claimFile) {
|
|
8253
8305
|
console.log(
|
package/lib/commands.js
CHANGED
|
@@ -2701,6 +2701,8 @@ export function parseArgs(args) {
|
|
|
2701
2701
|
adminPath: raw.path ? String(raw.path) : "",
|
|
2702
2702
|
adminPerf: Boolean(raw.perf),
|
|
2703
2703
|
adminWake: Boolean(raw.wake),
|
|
2704
|
+
// lumine admin member-trace <username> --source all|client|server
|
|
2705
|
+
adminTraceSource: raw.source ? String(raw.source) : "",
|
|
2704
2706
|
adminMinLevel: raw.minLevel === undefined ? null : raw.minLevel,
|
|
2705
2707
|
adminIncludeLegacy: Boolean(raw.includeLegacy),
|
|
2706
2708
|
adminIncludePrivateEvidence: parseBoolean(
|
|
@@ -3405,6 +3407,7 @@ export function printHelp() {
|
|
|
3405
3407
|
lumine admin reward-bank seed <buildId> [--max-step 3] [--identity zero|ciel|auto] [--json] (writes ONE missing seed question, lowest step first, billed to Zero/Ciel's AI Energy; inside a daily run or on its own, owner only)
|
|
3406
3408
|
lumine admin reward-bank report <buildId> [--days 1] [--json] (question-bank telemetry: generation outcomes, learners, payouts, ladder, questions to review)
|
|
3407
3409
|
lumine admin owner-trace [--since 2h|30m|3d|<iso>] [--type route,feed-open,scroll-anchor,content-scroll,error,rejection,session,nav-timing,slow-request,stall,page-load,scroll-perf,scroll-frame] [--perf] [--wake] [--path <substring>] [--limit 300] [--json] (--wake: sessions, 20 s wake profiles, bounded viewport geometry and dropped-event counts after loads or returns; network tags identify the upload network; what the website did on Mikey's own devices: routes with PUSH/POP/REPLACE, Home feed card opens, scroll-anchor restores, content scroll positions, window errors, and performance: tap-to-page timing, API requests over 1 s, main-thread stalls over 200 ms, page load, scroll frame pacing and slow-frame attribution (Long Animation Frame scripts on Chrome, feed card renders on Safari); --perf shows only those; kept 30 days)
|
|
3410
|
+
lumine admin member-trace list | on <username> --reason <why> | off <username> | [read] <username> [--since 2h|30m|3d|<iso>] [--source all|client|server] [--type reload,route,chat-select,boot,session,error,rejection,boundary-error,api] [--path <substring>] [--limit 300] [--json] (the owner trace switched on for specific member accounts to chase a bug they report: on/off are audited admin actions and take effect within 30 s; the website side records page loads with version and bundle, routes, chat channel/subchannel selection, every self-reload with its reason (kept on the device across the reload), error screens and window errors; the API side records each request from that account with its route, status, time and the website version it reported, so a device stuck on an old cached bundle still shows; read prints a plain summary first; kept 30 days)
|
|
3408
3411
|
lumine admin roles [--min-level 1] [--limit 50] [--json] (every user type with its management level and who holds it; admin pages need level 3, achievement points never pass level 2)
|
|
3409
3412
|
lumine admin jev-images report [--days 1..30] | switch --area <all|arena_paper|arena_picture|study_record|thumbnail|sdk_decide> --mode on|off [--daily-cap <0-5000>] [--build <id>, sdk_decide only, no --daily-cap] | decide --area <area> --key <subject key> --decision <decision> | thumbnails --targets <subject:<id>,build:<id>,...> | --featured [--saved-only] [--json] (JEV image checks: advisory only; per-area health, cost, agreement with final decisions and escalations for the daily run; switch is owner-only and needs no deploy; thumbnails adds notes for Featured review and never replaces or unfeatures anything)
|
|
3410
3413
|
lumine admin jev-routing review --since <unix|ISO> --until <unix|ISO> [--limit 1..20] [--cursor <cursor> | --all --checkpoint <file> [--resume]] [--include-synthetic] [--json] (bounded frozen evidence for paired disagreements and Auto fallbacks; collection is not review)
|
package/package.json
CHANGED
package/sdk/BUILD_SDK_INDEX.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Build SDK Index
|
|
2
2
|
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.78.0
|
|
4
4
|
Updated: 2026-11-01
|
|
5
|
-
Generated: 2026-11-
|
|
5
|
+
Generated: 2026-11-02T01:19:13.071Z
|
|
6
6
|
|
|
7
7
|
## Platform rules
|
|
8
8
|
Each rule below is a way an app breaks once it runs inside Twinkle's sandboxed frame, even when the code itself is correct. They outrank every other guideline: follow them in every change, including small ones, and fix any break of them you see in code you touch.
|
|
@@ -971,10 +971,11 @@ const result = await Twinkle.characters.chat({ character: 'zero', thinkingMode:
|
|
|
971
971
|
- map.heightUrlTemplate (or null) gives the land's shape on the same tile grid for 3D maps (ground heights; buildings and trees narrower than about 20 blocks are left out, so draw those from getTerrainChunks): a gzipped 'THM1' file, 16-byte little-endian header (magic, uint16 samples per side, uint16 blocks per sample, float64 source time) then samples x samples int16 heights row by row (z, then x); -32768 = no ground. Images and heights are served with CORS, so WebGL can use them.
|
|
972
972
|
- Example: const { worlds } = await Twinkle.minecraft.getWorlds(); const w = worlds.find((x) => x.id === 'world'); const z = w.map.maxZoom; const blocksPerTile = w.map.blocksPerTileAtMaxZoom * 2 ** (w.map.maxZoom - z); const tx = Math.floor(blockX / blocksPerTile), ty = Math.floor(blockZ / blocksPerTile); const url = w.map.tileUrlTemplate.replace('{z}', z).replace('{x}', tx).replace('{y}', ty);
|
|
973
973
|
- async getOnlinePlayers() | scopes: content:read
|
|
974
|
-
- Returns: { players: [{ name, world, x, y, z, isZero }], count, stale }
|
|
974
|
+
- Returns: { players: [{ name, world, x, y, z, isZero }], count, visitors: [{ userId, username, world, x, y, z, since }], visitorCount, stale }
|
|
975
975
|
- List players currently online with their world and block coordinates. Zero appears with isZero: true and is not counted in count.
|
|
976
976
|
- Cached for about 5 seconds; poll no faster than every 5 seconds.
|
|
977
977
|
- Names are Minecraft usernames, not Twinkle usernames.
|
|
978
|
+
- visitors are website members walking the world from Twinkle MC Explorers (Twinkle usernames, not Minecraft names). They are online and visible in game but are not players on the server; count counts players only.
|
|
978
979
|
- Example: const { players, count } = await Twinkle.minecraft.getOnlinePlayers();
|
|
979
980
|
- async getZero() | scopes: content:read
|
|
980
981
|
- Returns: { zero: { online, world, position: { x, y, z } | null, activity: 'idle'|'thinking'|'building'|'workshop', currentBuild: { id, title, status, placed, total, requester, world, bounds } | null, queue: [build], workshop: { world, min, max } | null, updatedAt }, stale }
|
|
@@ -1005,21 +1006,22 @@ const result = await Twinkle.characters.chat({ character: 'zero', thinkingMode:
|
|
|
1005
1006
|
- Every change is logged on the server and emailed to the owner; the player is told in game.
|
|
1006
1007
|
- Example: await Twinkle.minecraft.setPlayerRole({ uuid: person.uuid, role: 'builder' });
|
|
1007
1008
|
- async getChat({ since } = {}) | scopes: content:read
|
|
1008
|
-
- Returns: { events: [{ seq, at, kind: 'chat'|'zero'|'web'|'join'|'leave'|'death', name, text, userId, archived }], latestSeq, online, archiveReady, viewer: { canSend, muted, canModerate }, mutedUserIds }
|
|
1009
|
+
- Returns: { events: [{ seq, at, kind: 'chat'|'zero'|'web'|'join'|'leave'|'death'|'visit'|'unvisit', name, text, userId, archived }], latestSeq, online, visitorCount, archiveReady, viewer: { canSend, muted, canModerate }, mutedUserIds }
|
|
1009
1010
|
- Live server chat after a sequence number: player chat, Zero, messages sent from the web, joins, leaves and deaths.
|
|
1010
1011
|
- Without since (or 0) it returns the newest 50 events, oldest first. Pass since = latestSeq from the previous response to get only new events. Poll every 2-3 seconds while the chat is visible; stop when hidden.
|
|
1011
|
-
- kind: chat (a player), zero (Zero, the AI builder), web (someone chatting from the Twinkle app; userId is their Twinkle user id), join, leave, death. Private messages are never included.
|
|
1012
|
+
- kind: chat (a player), zero (Zero, the AI builder), web (someone chatting from the Twinkle app; userId is their Twinkle user id), join, leave, death, visit (a website visitor arrived in the world; userId is their Twinkle user id), unvisit (they left). Private messages are never included.
|
|
1012
1013
|
- name is a Minecraft username for chat/join/leave/death, and a Twinkle username for web.
|
|
1013
1014
|
- viewer.canModerate is true only for the server owner; mutedUserIds is filled only for them.
|
|
1015
|
+
- online counts players on the server; visitorCount counts website visitors walking the world (Twinkle MC Explorers).
|
|
1014
1016
|
- Example: let since = 0; async function poll() { const { events, latestSeq } = await Twinkle.minecraft.getChat({ since }); since = latestSeq; render(events); } setInterval(poll, 2500);
|
|
1015
1017
|
- async getChatHistory({ before, limit, query, includeArchived } = {}) | scopes: content:read
|
|
1016
|
-
- Returns: { events: [{ seq, at, kind: 'chat'|'zero'|'web'|'join'|'leave'|'death', name, text, userId, archived }], hasMore, nextBefore: { at, seq } | null, includesArchived }
|
|
1018
|
+
- Returns: { events: [{ seq, at, kind: 'chat'|'zero'|'web'|'join'|'leave'|'death'|'visit'|'unvisit', name, text, userId, archived }], hasMore, nextBefore: { at, seq } | null, includesArchived }
|
|
1017
1019
|
- Older server chat, newest first, for scrolling back or searching past days.
|
|
1018
1020
|
- before is the nextBefore cursor from the previous page; omit it to start from the newest. limit 1-100 (default 50). query searches message text and names (60 chars).
|
|
1019
1021
|
- Chat from before the web chat bridge existed (imported from server logs) is archived: only the server owner can include it with includeArchived: true; others never receive it.
|
|
1020
1022
|
- Example: const page = await Twinkle.minecraft.getChatHistory({ limit: 50 }); const older = await Twinkle.minecraft.getChatHistory({ before: page.nextBefore });
|
|
1021
1023
|
- async sendChat({ text }) | scopes: content:write
|
|
1022
|
-
- Returns: { event: { seq, at, kind: 'chat'|'zero'|'web'|'join'|'leave'|'death', name, text, userId, archived } }
|
|
1024
|
+
- Returns: { event: { seq, at, kind: 'chat'|'zero'|'web'|'join'|'leave'|'death'|'visit'|'unvisit', name, text, userId, archived } }
|
|
1023
1025
|
- Send a chat message from the app into the Minecraft server; players see it as [Web] <your Twinkle username>.
|
|
1024
1026
|
- Signed-in viewers only. text is trimmed to 200 characters. About one message per 2.5 seconds and 10 per minute per person: 429 with code minecraft_chat_rate_limited and retryAfterMs.
|
|
1025
1027
|
- 403 minecraft_chat_forbidden for accounts banned from chat; 400 minecraft_muted when the server owner muted them from web chat.
|
|
@@ -1053,6 +1055,7 @@ const result = await Twinkle.characters.chat({ character: 'zero', thinkingMode:
|
|
|
1053
1055
|
- Built-in designs (redstone devices and so on) have no author and are public.
|
|
1054
1056
|
- previewUrl is an image set with updateDesign, or null.
|
|
1055
1057
|
- access says what this viewer may do: canOrder shows placement tools (builders, moderators, the owner).
|
|
1058
|
+
- access.web is true for a website member with no Minecraft account (a visitor): they may ask Zero for builds (the first is reviewed) and their designs are always public.
|
|
1056
1059
|
- Example: const { designs } = await Twinkle.minecraft.getDesigns({ query: 'castle' });
|
|
1057
1060
|
- async getDesign({ id }) | scopes: content:read
|
|
1058
1061
|
- Returns: { design: { id, version, name, category, summary, size: { width, height, depth }, blocks, status, author, authorUserId, visibility: 'private'|'public', previewUrl, createdAt }, size: [w, h, d], palette: [blockState], cells: number[] }
|
|
@@ -1083,27 +1086,50 @@ const result = await Twinkle.characters.chat({ character: 'zero', thinkingMode:
|
|
|
1083
1086
|
- async checkPlacement({ designId, world, x, z, y?, facing?: 'north'|'east'|'south'|'west' }) | scopes: content:read
|
|
1084
1087
|
- Returns: { check: { clear, reasons, world, facing, anchor, bounds: { min, max }, ground: { y, min, max, water }, builtBlocks, builtSamples, placedBy: [{ name, blocks }], design } }
|
|
1085
1088
|
- Check a building site for a design: where it would sit and whether it would touch anyone's builds.
|
|
1086
|
-
- Who may: the server owner, and builders or moderators identified by their linked Minecraft account (Twinkle.minecraft.createLinkCode + /link). Others get 403 minecraft_not_linked or minecraft_rank_too_low.
|
|
1089
|
+
- Who may: the server owner, and builders or moderators identified by their linked Minecraft account (Twinkle.minecraft.createLinkCode + /link). Website members with no Minecraft account (visitors) may too; a visitor not approved yet has no builds to stop or undo. Others get 403 minecraft_not_linked or minecraft_rank_too_low.
|
|
1087
1090
|
- The footprint is centred on x/z and turned to face facing; without y it sits on the ground. clear is false when built (non-natural) blocks stand in the footprint or 3 blocks around it, the ground is very uneven, or it would leave the world; reasons explains. placedBy lists players CoreProtect recorded placing blocks there.
|
|
1088
1091
|
- Call on a user action (drop or rotate), not while dragging.
|
|
1092
|
+
- Visitors (no Minecraft account) may only check or order a site within about 64 blocks of where they stand in Twinkle World (Twinkle.minecraft.visit): 403 minecraft_visit_closer otherwise; and about 10 checks or orders a minute (429 minecraft_web_order_rate_limited with retryAfterMs).
|
|
1089
1093
|
- Example: const { check } = await Twinkle.minecraft.checkPlacement({ designId: 'harbor_house', world: 'world', x: 1200, z: 700, facing: 'south' }); outline.color = check.clear ? 'green' : 'red';
|
|
1090
1094
|
- async buildDesign({ ...placement, force }) | scopes: content:write
|
|
1091
|
-
- Returns: { jobId, check, priority }
|
|
1095
|
+
- Returns: { jobId, check, priority, pending?, requestId? }
|
|
1092
1096
|
- Order Zero to build a design at a site; he switches to creative and builds it before other work.
|
|
1093
|
-
- Who may: the server owner
|
|
1097
|
+
- Who may: the server owner; builders and moderators by their linked Minecraft account (createLinkCode + /link); and website members with no Minecraft account (visitors). A visitor's FIRST order is held for the server owner's review: the answer is { jobId: null, pending: true, requestId, check } and nothing is built yet; once approved (getVisitorRequests().mine.approved) they order like builders. Linked players below builder get 403 minecraft_rank_too_low.
|
|
1094
1098
|
- Follow progress with getZero() (currentBuild) and getZeroBuilds().
|
|
1095
1099
|
- Builders: one order waiting or building at a time, published designs or their own, and orders wait in the normal queue (priority false). Moderators: up to 3 orders, ahead of other work. The owner: no limit. force (build on a site that isn't clear) is owner-only.
|
|
1100
|
+
- Visitors (no Minecraft account) may only check or order a site within about 64 blocks of where they stand in Twinkle World (Twinkle.minecraft.visit): 403 minecraft_visit_closer otherwise; and about 10 checks or orders a minute (429 minecraft_web_order_rate_limited with retryAfterMs).
|
|
1096
1101
|
- Example: const { jobId } = await Twinkle.minecraft.buildDesign({ designId: 'harbor_house', world: 'world', x: 1200, z: 700, facing: 'south' });
|
|
1102
|
+
- async getVisitorRequests() | scopes: content:read
|
|
1103
|
+
- Returns: { canReview, requests: [{ id, userId, username, uuid, designId, designName, blocks, world, anchor, facing, bounds, createdAt }], approved: [{ userId, username, approvedAt, approvedBy }], recent: [{ id, userId, username, decision, by, at, note }], mine: { approved, request, lastDecision } }
|
|
1104
|
+
- Website visitors' first Zero build requests, waiting for review like a builder request; and the viewer's own status.
|
|
1105
|
+
- Only the server owner, in an app they own, gets canReview: true and the full lists; everyone else gets empty lists and only mine (their own open request, whether they are approved, and their last decision).
|
|
1106
|
+
- Example: const { canReview, requests, mine } = await Twinkle.minecraft.getVisitorRequests(); if (mine.request) showWaiting(mine.request);
|
|
1107
|
+
- async decideVisitorRequest({ id, approve, note }) | scopes: content:write
|
|
1108
|
+
- Returns: { approved, built, jobId, check, message }
|
|
1109
|
+
- Approve or reject a website visitor's first Zero build request. Approving makes them a visitor who may order like a builder from then on and places the held build.
|
|
1110
|
+
- Server owner only, in an app they own; others get 403 minecraft_roles_forbidden.
|
|
1111
|
+
- built is false (with check and message) when the site is no longer clear: they stay approved and can order again elsewhere.
|
|
1112
|
+
- Example: await Twinkle.minecraft.decideVisitorRequest({ id: request.id, approve: true });
|
|
1113
|
+
- async withdrawVisitorRequest() | scopes: content:write
|
|
1114
|
+
- Returns: { withdrawn }
|
|
1115
|
+
- A visitor takes back their own build request that is still waiting for review.
|
|
1116
|
+
- withdrawn is false when there was nothing waiting (or the viewer has a linked Minecraft account).
|
|
1117
|
+
- Example: await Twinkle.minecraft.withdrawVisitorRequest();
|
|
1118
|
+
- async revokeVisitorBuilder({ userId }) | scopes: content:write
|
|
1119
|
+
- Returns: { revoked }
|
|
1120
|
+
- Take back a visitor's approval: their next Zero order is held for review again.
|
|
1121
|
+
- Server owner only, in an app they own; others get 403 minecraft_roles_forbidden.
|
|
1122
|
+
- Example: await Twinkle.minecraft.revokeVisitorBuilder({ userId: 101 });
|
|
1097
1123
|
- async stopZero() | scopes: content:write
|
|
1098
1124
|
- Returns: { stopped, message }
|
|
1099
1125
|
- Stop the build Zero is doing right now (placed blocks stay).
|
|
1100
|
-
- Who may: the server owner, and builders or moderators identified by their linked Minecraft account (Twinkle.minecraft.createLinkCode + /link). Others get 403 minecraft_not_linked or minecraft_rank_too_low.
|
|
1126
|
+
- Who may: the server owner, and builders or moderators identified by their linked Minecraft account (Twinkle.minecraft.createLinkCode + /link). Website members with no Minecraft account (visitors) may too; a visitor not approved yet has no builds to stop or undo. Others get 403 minecraft_not_linked or minecraft_rank_too_low.
|
|
1101
1127
|
- Anyone may stop or undo their own builds; moderators also builders' and members' builds and Zero's own projects; the owner anything.
|
|
1102
1128
|
- Example: await Twinkle.minecraft.stopZero();
|
|
1103
1129
|
- async undoBuild({ jobId }) | scopes: content:write
|
|
1104
1130
|
- Returns: { undone, title, message }
|
|
1105
1131
|
- Undo one of Zero's builds, putting back what was there before.
|
|
1106
|
-
- Who may: the server owner, and builders or moderators identified by their linked Minecraft account (Twinkle.minecraft.createLinkCode + /link). Others get 403 minecraft_not_linked or minecraft_rank_too_low.
|
|
1132
|
+
- Who may: the server owner, and builders or moderators identified by their linked Minecraft account (Twinkle.minecraft.createLinkCode + /link). Website members with no Minecraft account (visitors) may too; a visitor not approved yet has no builds to stop or undo. Others get 403 minecraft_not_linked or minecraft_rank_too_low.
|
|
1107
1133
|
- Anyone may stop or undo their own builds; moderators also builders' and members' builds and Zero's own projects; the owner anything.
|
|
1108
1134
|
- Example: await Twinkle.minecraft.undoBuild({ jobId });
|
|
1109
1135
|
- async getSnaps({ before, limit, uuid } = {}) | scopes: content:read
|
|
@@ -1194,6 +1220,28 @@ const result = await Twinkle.characters.chat({ character: 'zero', thinkingMode:
|
|
|
1194
1220
|
- It shows the world as last saved (the server saves every few minutes). Pair it with world.map.heightUrlTemplate for the land farther away.
|
|
1195
1221
|
- Reads share the 180-per-minute build read limit: ask for 24 at a time, nearest first, and keep what you loaded.
|
|
1196
1222
|
- Example: const { scenes } = await Twinkle.minecraft.getTerrainChunks({ world: 'world', chunks: [[71, 38], [72, 38]] });
|
|
1223
|
+
- async getFullChunks({ world, chunks: [[cx, cz], ...] }) | scopes: content:read
|
|
1224
|
+
- Returns: { scenes: [{ cx, cz, scene: { origin: [x,y,z], size: [w,h,d], palette, blocks, light, biomes, count, wide? } | null }] }
|
|
1225
|
+
- Every block with a visible face in chunk columns of a world (up to 24 per call): roofed interiors and caves too, unlike getTerrainChunks. For walking inside buildings near the viewer.
|
|
1226
|
+
- Same scene format as getTerrainChunks and getPlayAreaChunks; larger, so ask only for the few columns around the viewer and use getTerrainChunks farther out.
|
|
1227
|
+
- It shows the world as last saved (the server saves every few minutes) and is cached for about a minute.
|
|
1228
|
+
- Reads share the 180-per-minute build read limit: keep what you loaded, nearest first.
|
|
1229
|
+
- Only the land around the viewer's own visit spot: call visit first; chunks more than 4 columns from where they stand in that world get 403 minecraft_visit_closer (use getTerrainChunks there).
|
|
1230
|
+
- Example: const { scenes } = await Twinkle.minecraft.getFullChunks({ world: 'world', chunks: [[71, 38]] });
|
|
1231
|
+
- async visit({ world, x, y, z, yaw, pitch, moving }) | scopes: content:write
|
|
1232
|
+
- Returns: { players: [{ name, uuid, world, x, y, z, yaw, pitch, sneaking, isZero }], visitors: [{ userId, username, world, x, y, z, yaw, pitch, moving }], stale, full, serverTime, intervalMs }
|
|
1233
|
+
- Visit the real Minecraft world from the app: report where the viewer is standing and get back where the players and the other visitors in that world are. In game, the visitor shows as a figure with their Twinkle username.
|
|
1234
|
+
- Signed-in viewers only. Call it about every intervalMs (500 ms) while the viewer is in the world; faster calls get 429 minecraft_visit_rate_limited with retryAfterMs. Interpolate avatars between answers.
|
|
1235
|
+
- A visitor is not a player on the server: they cannot break, place or use anything there. Members who own Minecraft play at twinklemc.site.
|
|
1236
|
+
- The viewer is never in visitors. stale: true means player positions could not be refreshed (show the last ones).
|
|
1237
|
+
- The figure disappears about 5 seconds after the last call; call leaveVisit when the viewer leaves or switches worlds. 403 minecraft_visit_forbidden for accounts banned from chat.
|
|
1238
|
+
- full: true means the world already shows the most visitors it can (40): this viewer can look around but is not shown in game yet.
|
|
1239
|
+
- Example: const view = await Twinkle.minecraft.visit({ world: 'world', x: 1146.5, y: 64, z: 618.5, yaw: 90, pitch: 0, moving: true }); drawAvatars(view.players, view.visitors);
|
|
1240
|
+
- async leaveVisit() | scopes: content:write
|
|
1241
|
+
- Returns: { left }
|
|
1242
|
+
- Stop visiting: the viewer's figure leaves the Minecraft world right away.
|
|
1243
|
+
- Call it when the viewer leaves the world, switches worlds or closes the app; left is false when they were not visiting.
|
|
1244
|
+
- Example: await Twinkle.minecraft.leaveVisit();
|
|
1197
1245
|
- async createPlayArea({ name, world, box, spawn, id }) | scopes: content:write
|
|
1198
1246
|
- Returns: { level }
|
|
1199
1247
|
- Capture a box of a Minecraft world as a new play area (or re-capture an existing id). Runs in the background: poll getPlayArea until status is 'ready'.
|
|
@@ -1205,6 +1253,7 @@ const result = await Twinkle.characters.chat({ character: 'zero', thinkingMode:
|
|
|
1205
1253
|
- Zero's build queue: the build he is on, the orders waiting (in the order he will take them) and the campaign steps he works through when no order waits. For an RTS-style build panel and for drawing queued footprints on a map.
|
|
1206
1254
|
- Everyone can read it; mine marks the viewer's own orders (linked account). Orders always run before campaign steps.
|
|
1207
1255
|
- noBuildWorlds lists worlds Zero never builds in (World 3, World 4): don't offer placement there.
|
|
1256
|
+
- access.web is true for a website member with no Minecraft account (a visitor): they may ask Zero for builds (the first is reviewed) and their designs are always public.
|
|
1208
1257
|
- Example: const { active, queue, campaign, access } = await Twinkle.minecraft.getBuildQueue();
|
|
1209
1258
|
- async moveQueuedBuild({ jobId, to }) | scopes: content:write
|
|
1210
1259
|
- Returns: same as getBuildQueue
|
package/sdk/LUMINE_ADMIN.md
CHANGED
|
@@ -1187,7 +1187,7 @@ lumine admin report serve --file <dir>/daily-management-report.md [--port <n>] [
|
|
|
1187
1187
|
|
|
1188
1188
|
These compose the documented commands in this contract, running them as child processes, so every scope check, audit and pagination rule applies unchanged.
|
|
1189
1189
|
- **Arena members waiting for papers come first.** `arena paper-queue --cursor <member-id> --limit <1-100> --json` lists members blocked by the lack of a fresh complete published paper, using the member-facing pass/retry and solo-mastery rules. Follow every `nextCursor`, including after an empty page; require `demandBasis: waiting-published-papers-v1`. Group all pages by exam/difficulty and prioritize these waiting members before generic unseen-question depth. Failed ordinary papers remain retryable; open/pending-marking sittings are not publication waits. Ten successful distinct Full Hard clears, with Zero/Ciel allowed, are needed between solo mastery attempts. The pass and full-marks 20× XP/Coins rewards are separately reserved, each once. Publish complete independently reviewed papers and verify the same members can advance. `gather` collects this queue first as `arena-paper-queue-N.json`, with `paperQueue.complete/pages/waitingTracks`; missing/malformed/partial coverage must not be reported as an empty healthy queue. Use the workspace CLI until npm publication is verified. This step grants no new authoring spend or publication authority.
|
|
1190
|
-
- **`gather`** saves its fixed set of read-only reports into `<dir>`, including the canonical published Math Lab queue in `math-lab-queue.json` and all types of pending Build review requests in `build-reviews-N.json`. Build reviews follow `nextCursor` to exhaustion; `gather.json` → `buildReviews` records `complete`, attempted `pages` and collected `items`. A failed/malformed page, cursor loop or 100-page bound reports incomplete coverage, never an empty healthy queue. Read the current collection once; it replaces the rewards-only list. Older packages without `buildReviews` need a separate `review list --status pending` collection through cursor exhaustion. Previous queue receipts remain on disk as history but do not become current evidence or duplicate reading duties after a new gather. It is not the complete daily checklist: app refills/usage, individual review assessments, sponsor integrity and other duties need their own steps. Repository agents follow the current full-run coverage index in `agent-guides/lumine-admin.md`. It follows `bot-output` to exhaustion and renders `bot-chats.txt`, then lists any failed step in `gather.json`. Total/per-step `durationMs`, attempts and recovered reads make recurring slow or failing collection steps visible during the daily review. It also creates `review-state.json`: collection never acknowledges reading. Children bypass update checks, require matching fresh stdout/file receipts, and retry an unconfirmed opted-in read at most once. Mutations never auto-retry. It needs the active run for run-scoped reads.
|
|
1190
|
+
- **`gather`** saves its fixed set of read-only reports into `<dir>`, including the canonical published Math Lab queue in `math-lab-queue.json` and all types of pending Build review requests in `build-reviews-N.json`. Build reviews follow `nextCursor` to exhaustion; `gather.json` → `buildReviews` records `complete`, attempted `pages` and collected `items`. A failed/malformed page, cursor loop or 100-page bound reports incomplete coverage, never an empty healthy queue. Read the current collection once; it replaces the rewards-only list. Older packages without `buildReviews` need a separate `review list --status pending` collection through cursor exhaustion. Previous queue receipts remain on disk as history but do not become current evidence or duplicate reading duties after a new gather. It is not the complete daily checklist: app refills/usage, individual review assessments, sponsor integrity and other duties need their own steps. Repository agents follow the current full-run coverage index in `agent-guides/lumine-admin.md`. It follows `bot-output` to exhaustion and renders `bot-chats.txt`, then lists any failed step in `gather.json`. Total/per-step `durationMs`, attempts and recovered reads make recurring slow or failing collection steps visible during the daily review. It also creates `review-state.json`: collection never acknowledges reading. While it runs, `gather.json` is rewritten after every step with `inProgress: true` and the steps so far; the final summary replaces it with `inProgress: false`. An `inProgress: true` file means the collection was interrupted: rerun the same gather with `--resume`. A hang-up from a closing parent shell no longer stops it. Children bypass update checks, require matching fresh stdout/file receipts, and retry an unconfirmed opted-in read at most once. Mutations never auto-retry. It needs the active run for run-scoped reads.
|
|
1191
1191
|
- **`progress`** reads local review state and explicit operator acknowledgments, writes private `progress.json`, and keeps reading, canonical effort mutations, the run lease, and browser checks separate. `collectionFailures` includes failures without a page file, such as a cursor loop; acknowledging the available files cannot make an incomplete collection complete. A fresh successful gather clears those failures. Add all required duties for the actual run scope and its carryovers; collection alone is not a full review. A completed run lease cannot complete a pending duty. Reading acknowledgments bind to the current file bytes and are operator attestations, not proof of comprehension.
|
|
1192
1192
|
- **`featured candidates`** returns Subjects posted after the Bangkok-midnight cutoff that are off the board and provably never Featured. Each one comes with its human/bot comment counts, explicit comment truncation/completeness, and whether Mikey has viewed it. Counts from truncated context are partial. An unavailable Subject context fails the collection. Eligibility only: ranking stays editorial.
|
|
1193
1193
|
- **`report serve`** detaches a loopback server that answers only `/`, `marked.min.js` and the report Markdown. `--open` opens Chrome and reports whether the OS accepted the request. Render, navigation and original-source verification remain pending until actually checked. Startup failures stop only the child this command started.
|
|
@@ -2257,6 +2257,11 @@ lumine admin builds review build:884 --output-dir ./build-review \
|
|
|
2257
2257
|
--interact ./build-review/steps.json --json
|
|
2258
2258
|
```
|
|
2259
2259
|
|
|
2260
|
+
A secret Subject's effort can't be set until its secret is revealed
|
|
2261
|
+
(`CLI_ADMIN_SECRET_REVEAL_REQUIRED`). `subjects candidates` marks such rows
|
|
2262
|
+
with `needsReveal: true` and the exact `revealCommand`
|
|
2263
|
+
(`lumine admin subject reveal <id>`); run it before `subject effort set`.
|
|
2264
|
+
|
|
2260
2265
|
Schemas:
|
|
2261
2266
|
|
|
2262
2267
|
```ts
|
|
@@ -3241,6 +3246,13 @@ lumine admin news submit --claim claim.json --file editorial.json \
|
|
|
3241
3246
|
lumine admin news print --json
|
|
3242
3247
|
```
|
|
3243
3248
|
|
|
3249
|
+
When there is nothing to claim (today's paper is already printed, or the next
|
|
3250
|
+
edition has not opened yet), `news claim` writes no claim or scaffold file and
|
|
3251
|
+
leaves any existing `--output` file untouched. Its JSON carries
|
|
3252
|
+
`data.artifacts.notClaimed` with `nextEditionAt` (Unix seconds and ISO); the
|
|
3253
|
+
text output says when the next edition opens. The daily edition opens at 00:00
|
|
3254
|
+
UTC (09:00 KST).
|
|
3255
|
+
|
|
3244
3256
|
The Twinkle Newspaper (Build app 1929) is normally printed by a community
|
|
3245
3257
|
member spending their own AI Energy. Making sure today's paper exists is part
|
|
3246
3258
|
of every delegated website-management run: check `lumine admin news` early in
|