@homie-rocks/studio 0.58.14 → 0.58.15
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/CHANGELOG.md +10 -0
- package/lib/move-drain.mjs +2 -1
- package/lib/template-history.json +42 -0
- package/package.json +1 -1
- package/worker/build-id.mjs +1 -1
- package/worker/move-drain.mjs +16 -5
- package/worker/room.mjs +2 -0
- package/worker/table.mjs +38 -4
- package/worker/version.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,16 @@ To bring a studio up to date, tell Claude: "Upgrade my studio to the newest Homi
|
|
|
17
17
|
`npx -y @homie-rocks/studio@latest upgrade`, which shows what's new since the version your studio pins (from this
|
|
18
18
|
file) and what the upgrade would change, and changes nothing until you agree.
|
|
19
19
|
|
|
20
|
+
## [0.58.15] - 2026-10-20
|
|
21
|
+
|
|
22
|
+
**Plugin 0.58.9**
|
|
23
|
+
|
|
24
|
+
A tab left open in a lobby no longer holds a studio move's drain.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- A tab left open in a lobby no longer holds a studio move's drain. Once `homie-studio drain on` has run for 5 minutes, a room still waiting in its lobby (no round started, or the last round over and its results seen) is ended: the people in it are told "This studio is moving. Please join again shortly." and their pages do not knock on the paused door again. A room with a round in progress still plays until it finishes, and a room whose results are not yet saved is never ended. `homie-studio drain status` says how many rooms it ended this way (`idleLobbiesEnded`), so you can see why the drain finished.
|
|
29
|
+
|
|
20
30
|
## [0.58.14] - 2026-10-20
|
|
21
31
|
|
|
22
32
|
**Plugin 0.58.8**
|
package/lib/move-drain.mjs
CHANGED
|
@@ -14,5 +14,6 @@ export async function drainCommand(root,action,{run=null,fetchFn=fetch,url=null}
|
|
|
14
14
|
if(!response.ok)throw Error('Room drain is unmeasured; keep the source running');
|
|
15
15
|
const status=await response.json();
|
|
16
16
|
if(typeof status.draining!=='boolean'||typeof status.drained!=='boolean')throw Error('Upgrade and deploy the toolkit before draining');
|
|
17
|
-
|
|
17
|
+
const ended=status.idleLobbiesEnded?` ${status.idleLobbiesEnded===1?'1 room was':status.idleLobbiesEnded+' rooms were'} ended while waiting in a lobby with no round running; ${status.idleLobbiesEnded===1?'its':'their'} people were told the studio is moving and to join again shortly.`:'';
|
|
18
|
+
return {ok:true,command:'drain '+action,...status,message:status.drained?'All measured rooms are empty and their pending records are delivered.'+ended+' The source can now be made read-only.':status.draining?'Existing rooms keep playing. New admissions are paused. A room still waiting in its lobby 5 minutes after the drain began is ended, and its people are told the studio is moving.'+ended+' Run homie-studio drain status until drained is true before freezing or changing hosts.':'Room admissions are open.'};
|
|
18
19
|
}
|
|
@@ -4596,6 +4596,48 @@
|
|
|
4596
4596
|
}
|
|
4597
4597
|
}
|
|
4598
4598
|
}
|
|
4599
|
+
},
|
|
4600
|
+
"0.58.15": {
|
|
4601
|
+
"files": {
|
|
4602
|
+
"CLAUDE.md": "ddf2b2a0376202f6",
|
|
4603
|
+
"README.md": "684b3cca8001673c",
|
|
4604
|
+
"HANDOFF.md": "29337e2ace95b2e7",
|
|
4605
|
+
"games/README.md": "5ad32fe80c61f117",
|
|
4606
|
+
"music/README.md": "a3dc042dadd39df8",
|
|
4607
|
+
"videos/README.md": "16babc3437d5545b",
|
|
4608
|
+
"posts/README.md": "37841aae476bd540",
|
|
4609
|
+
"site/README.md": "1dbdf22c03a1e505",
|
|
4610
|
+
"site/src/worker.mjs": "6cc5c6131eaf6fd0"
|
|
4611
|
+
},
|
|
4612
|
+
"sections": {
|
|
4613
|
+
"AGENTS.md": {
|
|
4614
|
+
"(intro)": "af7f2f732505d379",
|
|
4615
|
+
"## Version-matched authoring guides": "f6261a0e5801b96b",
|
|
4616
|
+
"## Layout": "f3a280b8c96cd068",
|
|
4617
|
+
"## Apps: one screen, roles and parts": "c10aa0441ea89702",
|
|
4618
|
+
"## Commands (all through the pinned CLI in node_modules)": "c20d90de21cde0c7",
|
|
4619
|
+
"## The site": "0cb8dd9a6f8a0096",
|
|
4620
|
+
"## Making games": "bb715272fd1a615b",
|
|
4621
|
+
"## The Game Codex and progress": "0738ef719cef3a4c",
|
|
4622
|
+
"## Art direction and models": "a48fff7bf0a5f2fc",
|
|
4623
|
+
"## Running live games (the back office)": "51ebf2ab756f6e4d",
|
|
4624
|
+
"## Servers and AI seats": "1ccfd549d2369a60",
|
|
4625
|
+
"## Selling things (the shop)": "0df5a5fe1833c624",
|
|
4626
|
+
"## Continuing a build from the Claude app": "0d68081e924ca419",
|
|
4627
|
+
"## Rules": "b2234d80f6cbe71d",
|
|
4628
|
+
"## Telling Homie": "80b46fdd9e578db8",
|
|
4629
|
+
"## Beta": "9d02638207a26e73"
|
|
4630
|
+
}
|
|
4631
|
+
},
|
|
4632
|
+
"named": {
|
|
4633
|
+
"Homie Arcade": {
|
|
4634
|
+
"sections": {
|
|
4635
|
+
"AGENTS.md": {
|
|
4636
|
+
"## Commands (all through the pinned CLI in node_modules)": "8364e05cebefcba4"
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4599
4641
|
}
|
|
4600
4642
|
}
|
|
4601
4643
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homie-rocks/studio",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.15",
|
|
4
4
|
"description": "A studio for games, music and video on its own Cloudflare: scaffold, multiplayer starters on the netplay contract, a port toolkit that makes existing single-player web games multiplayer, the site Worker with public rooms (Table/Lobby Durable Objects and D1, all on the free Workers plan, no payment method), a site with the hub's sections (Home, Games, Music, Videos, Rooms, Posts with feeds) in the studio's own look, an epic landing page for every game, big songs and videos in the studio's own R2 once it has storage (uploaded, checked by SHA-256, served at the same addresses), deploy, and the homie.rocks directory.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
package/worker/build-id.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by lib/build-identity.mjs; identifies the bundled runtime sources.
|
|
2
|
-
export const STUDIO_BUILD = Object.freeze({"version":"0.58.
|
|
2
|
+
export const STUDIO_BUILD = Object.freeze({"version":"0.58.15","sha256":"21d2ff598c3349a401492759f1ee0ce077752b2e3e00b8078973d3eac14197fc"});
|
package/worker/move-drain.mjs
CHANGED
|
@@ -14,12 +14,23 @@ export async function drainSince(env,{now=Date.now(),fresh=false}={}){
|
|
|
14
14
|
readings.set(env.DB,{at:now,since});
|
|
15
15
|
return since;
|
|
16
16
|
}
|
|
17
|
+
/** How long a drain counts rooms before it may say drained: an admission a few seconds late (DRAIN_TTL_MS) is counted well within it. */
|
|
18
|
+
export const DRAIN_CENSUS_MS=240000;
|
|
19
|
+
/** A room still waiting in its lobby this long after the drain began is ended, so a tab left open never holds a move:
|
|
20
|
+
* a minute past the census, when every late admission has been counted and a lobby has had five minutes to start. */
|
|
21
|
+
export const DRAIN_IDLE_MS=300000;
|
|
22
|
+
/** A round's results stay on screen this long before an idle room may end (the 5 s a launch change gives them too). */
|
|
23
|
+
export const RESULTS_MS=5000;
|
|
24
|
+
export const MOVING_MESSAGE='This studio is moving. Please join again shortly.';
|
|
25
|
+
/** Nothing in play: no round has started, or the last one is over and its results have been seen. A live round is in
|
|
26
|
+
* play whatever its clock says (only its host says it is over), and so is a phase this toolkit does not name. */
|
|
27
|
+
export function idleLobby(room,now){const r=room.lastRound;return !r||r.phase==='over'&&now-(room.roundOverAt??0)>=RESULTS_MS;}
|
|
17
28
|
export function isAdmission(request){const path=new URL(request.url).pathname;return request.headers.get('upgrade')?.toLowerCase()==='websocket'||/\/api\/(lobby|agents)(\/|$)/.test(path);}
|
|
18
29
|
export const drainResponse=()=>Response.json({ok:false,error:'moving',message:'This studio is moving. Existing rooms can finish; please join again shortly.'},{status:503,headers:{'retry-after':'30','cache-control':'no-store'}});
|
|
19
30
|
/** Read every shard directly: cached public summaries exclude private games and hide outages. */
|
|
20
31
|
export async function drainStatus(env,cat,{now=Date.now()}={}){
|
|
21
32
|
const since=await drainSince(env,{fresh:true});if(!since)return {draining:false,drained:false};
|
|
22
|
-
let clients=0,pending=0,rooms=0;
|
|
33
|
+
let clients=0,pending=0,rooms=0,idleLobbiesEnded=0;
|
|
23
34
|
for(const game of cat.games??[]){
|
|
24
35
|
const names=new Set();
|
|
25
36
|
let cursor='';
|
|
@@ -36,12 +47,12 @@ export async function drainStatus(env,cat,{now=Date.now()}={}){
|
|
|
36
47
|
for(const room of body.rooms)names.add(room.name);
|
|
37
48
|
}
|
|
38
49
|
for(const name of names){
|
|
39
|
-
const r=await env.TABLE.get(env.TABLE.idFromName(`${game.id}/${name}`)).fetch(`https://table/__move-status?game=${encodeURIComponent(game.id)}&room=${encodeURIComponent(name)}`);
|
|
50
|
+
const r=await env.TABLE.get(env.TABLE.idFromName(`${game.id}/${name}`)).fetch(`https://table/__move-status?game=${encodeURIComponent(game.id)}&room=${encodeURIComponent(name)}&since=${since}`);
|
|
40
51
|
if(!r.ok)throw Error('Cannot measure a room while moving');
|
|
41
52
|
const body=await r.json();
|
|
42
|
-
if(!Number.isSafeInteger(body.clients)||body.clients<0||!Number.isSafeInteger(body.pending)||body.pending<0)throw Error('Invalid room drain receipt');
|
|
43
|
-
clients+=body.clients;pending+=body.pending;rooms++;
|
|
53
|
+
if(!Number.isSafeInteger(body.clients)||body.clients<0||!Number.isSafeInteger(body.pending)||body.pending<0||typeof body.idleEnded!=='boolean')throw Error('Invalid room drain receipt');
|
|
54
|
+
clients+=body.clients;pending+=body.pending;rooms++;if(body.idleEnded)idleLobbiesEnded++;
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
|
-
return {draining:true,since,clients,pending,rooms,drained:now-since>=
|
|
57
|
+
return {draining:true,since,clients,pending,rooms,idleLobbiesEnded,idleEndsAt:since+DRAIN_IDLE_MS,drained:now-since>=DRAIN_CENSUS_MS&&clients===0&&pending===0};
|
|
47
58
|
}
|
package/worker/room.mjs
CHANGED
|
@@ -379,6 +379,8 @@ export class NetRoom {
|
|
|
379
379
|
// The results name every AI as AI, whatever the host's game says (section 17).
|
|
380
380
|
const round = retime && this.lastRound?.n === m.round.n && this.lastRound?.phase === m.round.phase ? { ...m.round, ...(this.lastRound.results ? { results: this.lastRound.results } : {}) } : Array.isArray(m.round.results) ? { ...m.round, results: this.labelResults(m.round.results) } : m.round;
|
|
381
381
|
const wasLive = this.lastRound && this.lastRound.phase === 'live' ? Number(this.lastRound.n) : null;
|
|
382
|
+
// When the results went up: a studio move's drain lets them be seen before it ends an idle room (move-drain.mjs).
|
|
383
|
+
if (round.phase === 'over' && !(this.lastRound?.phase === 'over' && this.lastRound.n === round.n)) this.roundOverAt = this.now();
|
|
382
384
|
this.lastRound = round;
|
|
383
385
|
// The round a launch change waits for is over: everyone sees its results for a moment, then the room re-gates.
|
|
384
386
|
if (this.regate && round.phase === 'over' && (this.regate.roundN === null || Number(round.n) >= this.regate.roundN)) this.regate.until = Math.min(this.regate.until, this.now() + 5000);
|
package/worker/table.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {lobbyFor} from './lobby-shards.mjs';
|
|
2
|
+
import {DRAIN_IDLE_MS,MOVING_MESSAGE,drainSince,idleLobby} from './move-drain.mjs';
|
|
2
3
|
import {relayStream} from './relay-channel.mjs';
|
|
3
4
|
import {roomSessions,restoreRoomFields} from './room-sessions.mjs';
|
|
4
5
|
import {idleChatSnapshot,restoreIdleChat,readIdleChat,writeIdleChat,expireIdleChat} from './idle-chat.mjs';
|
|
@@ -526,6 +527,26 @@ export class Table {
|
|
|
526
527
|
this.report();
|
|
527
528
|
}
|
|
528
529
|
|
|
530
|
+
/**
|
|
531
|
+
* A studio move's drain ends a room left waiting in its lobby (no round running, no record waiting; the caller
|
|
532
|
+
* checked both). Its people are told the studio is moving, as a final word, so no page knocks on the paused door,
|
|
533
|
+
* and the room forgets everything, as an empty one does.
|
|
534
|
+
*/
|
|
535
|
+
endForMove(room) {
|
|
536
|
+
const people = room.live().length;
|
|
537
|
+
if (this.hostRt) this.finishRoom('moving'); else this.tellLobby({ ended: true });
|
|
538
|
+
for (const c of [...room.clients.values()]) {
|
|
539
|
+
if (c.helloed) room.error(c, 'room-over', MOVING_MESSAGE);
|
|
540
|
+
room.clients.delete(c.id);
|
|
541
|
+
try { c.conn.close(1000, 'room-over'); } catch { /* gone */ }
|
|
542
|
+
}
|
|
543
|
+
room.emptySince = Date.now();
|
|
544
|
+
room.forget();
|
|
545
|
+
if (this.house) this.house.sync();
|
|
546
|
+
this.say({ ev: 'move-idle-ended', people });
|
|
547
|
+
this.report();
|
|
548
|
+
}
|
|
549
|
+
|
|
529
550
|
/**
|
|
530
551
|
* The room's part of the alarm (section 4.5 of the design). A room nobody came back to within a minute of its
|
|
531
552
|
* pause ends: the relay forgets it and its stored seats go (`office` and `recorded` stay). A room in play keeps an
|
|
@@ -1090,11 +1111,24 @@ export class Table {
|
|
|
1090
1111
|
// The back office (worker/office.mjs), from the studio's Worker only: the room as its owner sees it, and the
|
|
1091
1112
|
// owner's signed controls, which this room verifies before it applies one (NETPLAY.md section 15).
|
|
1092
1113
|
if (url.pathname === '/__move-status') {
|
|
1093
|
-
await this.flushRoundRecords();await this.flushFunctionEvents();
|
|
1094
1114
|
const sql=this.ctx.storage.sql;
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1115
|
+
const pendingNow=async()=>{
|
|
1116
|
+
await this.flushRoundRecords();await this.flushFunctionEvents();
|
|
1117
|
+
let n=0;
|
|
1118
|
+
for(const name of ['round_outbox','function_outbox'])if(sql?.exec("SELECT name FROM sqlite_master WHERE name=?",name).toArray().length)n+=Number(sql.exec('SELECT COUNT(*) AS n FROM '+name).toArray()[0].n);
|
|
1119
|
+
return n;
|
|
1120
|
+
};
|
|
1121
|
+
let pending=await pendingNow();
|
|
1122
|
+
// The drain's deadline for a room left waiting in its lobby (worker/move-drain.mjs). The drain itself is read
|
|
1123
|
+
// here, not taken from the request, and the room remembers which drain ended it so every census counts it.
|
|
1124
|
+
const since=Number(url.searchParams.get('since'));
|
|
1125
|
+
let idleEnded=Number.isSafeInteger(since)&&since>0&&await this.ctx.storage.get('move-idle-ended')===since;
|
|
1126
|
+
if(!idleEnded&&!pending&&room.live().length&&!this.isPersistent()&&idleLobby(room,Date.now())&&Date.now()-since>=DRAIN_IDLE_MS&&await drainSince(this.env,{fresh:true})===since){
|
|
1127
|
+
await this.ctx.storage.put('move-idle-ended',since);
|
|
1128
|
+
this.endForMove(room);idleEnded=true;
|
|
1129
|
+
pending=await pendingNow();
|
|
1130
|
+
}
|
|
1131
|
+
return json({clients:room.live().length,pending,idleEnded});
|
|
1098
1132
|
}
|
|
1099
1133
|
if (url.pathname === '/__facts') return json({ ...room.officeFacts(), gates: [...(this.gateMetrics?.values() ?? [])], durability: this.storageHealth ?? { ok: true }, ...(this.house ? { brains: this.house.facts() } : {}) });
|
|
1100
1134
|
// A chat line as the room keeps it (section 19), for a report: the Worker files the room's own copy, never a reporter's.
|
package/worker/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The @homie-rocks/studio version this Worker code is (package.json's; a test keeps them equal). Cache-busts /_homie/site.js. */
|
|
2
|
-
export const STUDIO_VERSION_TAG = '0.58.
|
|
2
|
+
export const STUDIO_VERSION_TAG = '0.58.15';
|