@mostra/runtime 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/bin.js +2 -2
- package/dist/bin.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{instance-CYvNd7mP.js → instance-BfGOToHo.js} +30 -18
- package/dist/{instance-CYvNd7mP.js.map → instance-BfGOToHo.js.map} +1 -1
- package/package.json +16 -16
- package/src/bin.ts +12 -1
- package/src/dev/index.ts +26 -4
- package/src/home/platform.ts +7 -15
- package/src/instance/index.ts +1 -1
- package/src/service/unit.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The Mostra runtime: the supervisor that owns a home, its ledger, its child processes and the host protocol server (mostra-runtime host|daemon).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|
|
@@ -34,38 +34,38 @@
|
|
|
34
34
|
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@hono/node-server": "2.1.
|
|
37
|
+
"@hono/node-server": "2.1.5",
|
|
38
38
|
"@mdx-js/mdx": "3.1.1",
|
|
39
|
-
"@mostra/protocol": "0.
|
|
39
|
+
"@mostra/protocol": "0.6.1",
|
|
40
40
|
"@tailwindcss/vite": "4.3.3",
|
|
41
|
-
"@vitejs/plugin-react": "6.1.
|
|
41
|
+
"@vitejs/plugin-react": "6.1.2",
|
|
42
42
|
"better-sqlite3": "13.0.3",
|
|
43
43
|
"hono": "4.13.13",
|
|
44
|
-
"ignore": "7.0.
|
|
45
|
-
"oxc-parser": "0.
|
|
46
|
-
"pnpm": "10.34.
|
|
44
|
+
"ignore": "7.0.13",
|
|
45
|
+
"oxc-parser": "0.155.0",
|
|
46
|
+
"pnpm": "10.34.7",
|
|
47
47
|
"remark-frontmatter": "5.0.0",
|
|
48
48
|
"remark-gfm": "4.0.1",
|
|
49
49
|
"semver": "7.8.5",
|
|
50
50
|
"tailwindcss": "4.3.3",
|
|
51
51
|
"typescript": "7.0.2",
|
|
52
|
-
"vite": "8.3.
|
|
52
|
+
"vite": "8.3.4",
|
|
53
53
|
"yaml": "2.9.1",
|
|
54
|
-
"zod": "4.6.
|
|
54
|
+
"zod": "4.6.7"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@mostra/shell": "0.
|
|
57
|
+
"@mostra/shell": "0.6.1",
|
|
58
58
|
"@mostra/tools": "0.0.0",
|
|
59
|
-
"@mostra/verify": "0.
|
|
59
|
+
"@mostra/verify": "0.6.1",
|
|
60
60
|
"@mostra/warm": "0.0.0",
|
|
61
|
-
"@mostra/worker": "0.
|
|
61
|
+
"@mostra/worker": "0.6.1",
|
|
62
62
|
"@types/better-sqlite3": "9.6.0",
|
|
63
|
-
"@types/node": "24.19.
|
|
63
|
+
"@types/node": "24.19.2",
|
|
64
64
|
"@types/semver": "7.8.0",
|
|
65
65
|
"fast-check": "4.10.2",
|
|
66
|
-
"playwright": "1.64.
|
|
67
|
-
"tsdown": "0.23.
|
|
68
|
-
"vitest": "5.0.
|
|
66
|
+
"playwright": "1.64.1",
|
|
67
|
+
"tsdown": "0.23.1",
|
|
68
|
+
"vitest": "5.0.5"
|
|
69
69
|
},
|
|
70
70
|
"keywords": [
|
|
71
71
|
"mostra",
|
package/src/bin.ts
CHANGED
|
@@ -103,7 +103,18 @@ function handleSignals(instance: Instance): void {
|
|
|
103
103
|
process.on("exit", () => instance.processes.killAll());
|
|
104
104
|
process.on("uncaughtException", (error) => {
|
|
105
105
|
mirror(`${JSON.stringify({ level: "error", event: "uncaught", message: error.message })}\n`);
|
|
106
|
-
|
|
106
|
+
// The home's log keeps what failed and where, so a failure nobody watched stderr for still
|
|
107
|
+
// names its cause (#35: an instance that ended with only "uncaught exception" in its log).
|
|
108
|
+
void instance.stop(
|
|
109
|
+
"uncaught exception",
|
|
110
|
+
EXIT.failure,
|
|
111
|
+
createDiagnostic("MOSTRA_HOST_INTERNAL_ERROR", {
|
|
112
|
+
message: (error instanceof Error
|
|
113
|
+
? (error.stack ?? `${error.name}: ${error.message}`)
|
|
114
|
+
: String(error)
|
|
115
|
+
).slice(0, 8192),
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
107
118
|
setTimeout(() => process.exit(EXIT.failure), 15_000).unref();
|
|
108
119
|
});
|
|
109
120
|
}
|
package/src/dev/index.ts
CHANGED
|
@@ -405,15 +405,34 @@ export function createDev(options: DevOptions): Dev {
|
|
|
405
405
|
);
|
|
406
406
|
|
|
407
407
|
// The session ends with its connection (D140 item 12), from the first moment: a connection
|
|
408
|
-
// that closes while packages resolve or the dev server starts leaves nothing running.
|
|
409
|
-
|
|
408
|
+
// that closes while packages resolve or the dev server starts leaves nothing running. While
|
|
409
|
+
// the session starts, its start owns the cleanup: a close marks it, and the start stops what
|
|
410
|
+
// it started at its next step, then removes the session's directory. A close that removed
|
|
411
|
+
// the directory at once did so under a dev server still writing into it (its staging files,
|
|
412
|
+
// its `node_modules` link, Vite's cache), the removal failed on the files it wrote, and the
|
|
413
|
+
// failure took the whole instance down (#35). Once started, a close stops the session, and
|
|
414
|
+
// a stop that fails is logged: it never ends the instance.
|
|
415
|
+
let starting = true;
|
|
416
|
+
connection.signal.addEventListener(
|
|
417
|
+
"abort",
|
|
418
|
+
() => {
|
|
419
|
+
if (starting) closed = true;
|
|
420
|
+
else stop().catch((error: unknown) => log.warn("dev.stop_failed", { sessionId, error }));
|
|
421
|
+
},
|
|
422
|
+
{ once: true },
|
|
423
|
+
);
|
|
410
424
|
try {
|
|
411
425
|
if (connection.signal.aborted) throw abandoned();
|
|
426
|
+
// A close stops the start at its next step, before resolving packages least of all, which
|
|
427
|
+
// may install under the shared gate (the Opus review of MT-02).
|
|
412
428
|
await sync();
|
|
429
|
+
if (closed) throw abandoned();
|
|
413
430
|
const described = await describe();
|
|
431
|
+
if (closed) throw abandoned();
|
|
414
432
|
manifestKey = JSON.stringify(described.manifest);
|
|
415
433
|
nodeModules = await resolve(described.manifest.id);
|
|
416
434
|
artifactId = described.artifactId;
|
|
435
|
+
if (closed) throw abandoned();
|
|
417
436
|
child = await startChild(described);
|
|
418
437
|
if (closed) throw abandoned();
|
|
419
438
|
const upstream = (): { port: number; secret: string } | undefined =>
|
|
@@ -438,13 +457,16 @@ export function createDev(options: DevOptions): Dev {
|
|
|
438
457
|
...(params.port !== undefined ? { shellPort: params.port } : {}),
|
|
439
458
|
});
|
|
440
459
|
if (closed) throw abandoned();
|
|
460
|
+
// Nothing below awaits, so no close can fall between this and the session's registration.
|
|
461
|
+
starting = false;
|
|
441
462
|
sandbox.onSubmission((results) => notify("submission", { results }));
|
|
442
463
|
} catch (error) {
|
|
443
464
|
closed = true;
|
|
444
465
|
sessions.delete(sessionId);
|
|
445
|
-
//
|
|
446
|
-
//
|
|
466
|
+
// Every step that started something has returned, so nothing writes into the session's
|
|
467
|
+
// directory once its dev server and sandbox stopped.
|
|
447
468
|
await release();
|
|
469
|
+
if (connection.signal.aborted) log.info("dev.stopped", { sessionId });
|
|
448
470
|
throw error;
|
|
449
471
|
}
|
|
450
472
|
|
package/src/home/platform.ts
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The unsupported-platform gate (D35, D146, RT-07). Every entry point calls it before it touches
|
|
3
|
-
* the home: Mostra runs on macOS and
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* WP-W3 removes the switch.
|
|
3
|
+
* the home: Mostra runs on macOS, Linux and Windows, on x64 and arm64, and fails closed elsewhere.
|
|
4
|
+
* Windows was built behind a development switch by WP-W1 to WP-W3, and is supported since WP-W3
|
|
5
|
+
* like the others.
|
|
7
6
|
*/
|
|
8
7
|
import { createDiagnostic, type Diagnostic } from "@mostra/protocol";
|
|
9
8
|
import { OS } from "../platform/index.ts";
|
|
10
9
|
|
|
11
|
-
const OPERATING_SYSTEMS: readonly string[] = ["darwin", "linux"];
|
|
10
|
+
const OPERATING_SYSTEMS: readonly string[] = ["darwin", "linux", "win32"];
|
|
12
11
|
const ARCHITECTURES: readonly string[] = ["x64", "arm64"];
|
|
13
12
|
|
|
14
|
-
/** The development switch that admits Windows until WP-W3 (D146). */
|
|
15
|
-
export const WINDOWS_DEV_SWITCH = "MOSTRA_DEV_WINDOWS";
|
|
16
|
-
|
|
17
13
|
/** The platform as `<os>-<arch>`, as `InstanceInfo.platform` reports it. */
|
|
18
14
|
export function platformName(platform: string = OS, arch: string = process.arch): string {
|
|
19
15
|
return `${platform}-${arch}`;
|
|
@@ -21,22 +17,18 @@ export function platformName(platform: string = OS, arch: string = process.arch)
|
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* Returns `MOSTRA_PLATFORM_UNSUPPORTED` for a platform Mostra doesn't run on, or `undefined` for
|
|
24
|
-
* a supported one.
|
|
20
|
+
* a supported one.
|
|
25
21
|
*/
|
|
26
22
|
export function checkPlatform(
|
|
27
23
|
platform: string = OS,
|
|
28
24
|
arch: string = process.arch,
|
|
29
|
-
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
30
25
|
): Diagnostic | undefined {
|
|
31
|
-
if (ARCHITECTURES.includes(arch))
|
|
32
|
-
if (OPERATING_SYSTEMS.includes(platform)) return undefined;
|
|
33
|
-
if (platform === "win32" && env[WINDOWS_DEV_SWITCH] === "1") return undefined;
|
|
34
|
-
}
|
|
26
|
+
if (ARCHITECTURES.includes(arch) && OPERATING_SYSTEMS.includes(platform)) return undefined;
|
|
35
27
|
const name =
|
|
36
28
|
platform === "win32"
|
|
37
29
|
? `Windows (${platformName(platform, arch)})`
|
|
38
30
|
: platformName(platform, arch);
|
|
39
31
|
return createDiagnostic("MOSTRA_PLATFORM_UNSUPPORTED", {
|
|
40
|
-
message: `Mostra doesn't run on ${name}; it supports macOS and
|
|
32
|
+
message: `Mostra doesn't run on ${name}; it supports macOS, Linux and Windows on x64 and arm64.`,
|
|
41
33
|
});
|
|
42
34
|
}
|
package/src/instance/index.ts
CHANGED
|
@@ -844,7 +844,7 @@ async function assemble(home: OwnedHome, options: StartInstanceOptions): Promise
|
|
|
844
844
|
stopped,
|
|
845
845
|
stop(reason, exitCode = 0, diagnostic) {
|
|
846
846
|
stopping ??= (async () => {
|
|
847
|
-
log.info("instance.stopping", { reason, exitCode });
|
|
847
|
+
log.info("instance.stopping", { reason, exitCode, ...(diagnostic ? { diagnostic } : {}) });
|
|
848
848
|
idle?.stop();
|
|
849
849
|
stopWatchingPublishes();
|
|
850
850
|
live.stop();
|
package/src/service/unit.ts
CHANGED
|
@@ -121,11 +121,11 @@ export function serviceFor(spec: ServiceSpec): ServiceStatus {
|
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* What a Windows task passes on besides the user's logon environment, which Task Scheduler gives
|
|
124
|
-
* it: the
|
|
125
|
-
*
|
|
124
|
+
* it: the helper a checkout names, and the locale and time zone, as the POSIX units carry theirs.
|
|
125
|
+
* Nothing secret.
|
|
126
126
|
*/
|
|
127
127
|
function windowsServiceVariables(env: Environment): [string, string][] {
|
|
128
|
-
return ["
|
|
128
|
+
return ["MOSTRA_WIN_HELPER", "LANG", "TZ"].flatMap((name) => {
|
|
129
129
|
const value = env[name];
|
|
130
130
|
return value ? [[name, value] as [string, string]] : [];
|
|
131
131
|
});
|