@mostra/runtime 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mostra/runtime",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
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",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@hono/node-server": "2.1.3",
38
38
  "@mdx-js/mdx": "3.1.1",
39
- "@mostra/protocol": "0.3.0",
39
+ "@mostra/protocol": "0.5.0",
40
40
  "@tailwindcss/vite": "4.3.3",
41
41
  "@vitejs/plugin-react": "6.1.1",
42
42
  "better-sqlite3": "13.0.3",
@@ -49,16 +49,16 @@
49
49
  "semver": "7.8.5",
50
50
  "tailwindcss": "4.3.3",
51
51
  "typescript": "7.0.2",
52
- "vite": "8.3.2",
52
+ "vite": "8.3.3",
53
53
  "yaml": "2.9.1",
54
- "zod": "4.6.5"
54
+ "zod": "4.6.6"
55
55
  },
56
56
  "devDependencies": {
57
- "@mostra/shell": "0.3.0",
57
+ "@mostra/shell": "0.5.0",
58
58
  "@mostra/tools": "0.0.0",
59
- "@mostra/verify": "0.3.0",
59
+ "@mostra/verify": "0.5.0",
60
60
  "@mostra/warm": "0.0.0",
61
- "@mostra/worker": "0.3.0",
61
+ "@mostra/worker": "0.5.0",
62
62
  "@types/better-sqlite3": "9.6.0",
63
63
  "@types/node": "24.19.1",
64
64
  "@types/semver": "7.8.0",
package/src/bin.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { mkdirSync, realpathSync } from "node:fs";
2
+ import { mkdirSync } from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  /**
5
5
  * `mostra-runtime`, the runtime bundle's entry point (D85).
@@ -33,6 +33,7 @@ import {
33
33
  } from "@mostra/protocol";
34
34
  import { checkPlatform, resolveHomePath } from "./home/index.ts";
35
35
  import { type Instance, runtimeVersion, startInstance } from "./instance/index.ts";
36
+ import { realPath } from "./platform/index.ts";
36
37
  import { installService, serviceStatus, uninstallService } from "./service/index.ts";
37
38
 
38
39
  /** Exit codes, as INTERFACES §9 defines them for the CLI. */
@@ -122,7 +123,7 @@ async function main(argv: readonly string[]): Promise<number> {
122
123
  }
123
124
  const [mode, ...rest] = positionals;
124
125
  if (mode === "service" && !values.help)
125
- return service(rest, values.home, values["no-start"] === true);
126
+ return await service(rest, values.home, values["no-start"] === true);
126
127
  if (values.help || (mode !== "host" && mode !== "daemon") || rest.length > 0) {
127
128
  (values.help ? process.stdout : process.stderr).write(`${USAGE}\n`);
128
129
  return values.help ? EXIT.ok : EXIT.usage;
@@ -179,7 +180,11 @@ async function main(argv: readonly string[]): Promise<number> {
179
180
  }
180
181
 
181
182
  /** `mostra-runtime service …`: the home's login service, as one JSON line (D62, RT-08). */
182
- function service(args: readonly string[], home: string | undefined, noStart: boolean): number {
183
+ async function service(
184
+ args: readonly string[],
185
+ home: string | undefined,
186
+ noStart: boolean,
187
+ ): Promise<number> {
183
188
  const [action, ...extra] = args;
184
189
  if ((action !== "install" && action !== "uninstall" && action !== "status") || extra.length > 0) {
185
190
  process.stderr.write(`${USAGE}\n`);
@@ -194,15 +199,18 @@ function service(args: readonly string[], home: string | undefined, noStart: boo
194
199
  const resolved = resolveHomePath({ home, env: process.env });
195
200
  mkdirSync(resolved, { recursive: true, mode: 0o700 });
196
201
  const spec = {
197
- home: realpathSync(resolved),
202
+ // As the daemon spells its home, so the service's name and hash are the daemon's (D82).
203
+ home: realPath(resolved),
198
204
  node: process.execPath,
199
205
  entry: fileURLToPath(import.meta.url),
200
206
  };
207
+ // Who asks, should a Windows uninstall stop the daemon over its pipe.
208
+ const client = { name: "mostra-runtime-service", version: runtimeVersion() };
201
209
  const status =
202
210
  action === "install"
203
- ? installService(spec, { noStart })
211
+ ? await installService(spec, { noStart, client })
204
212
  : action === "uninstall"
205
- ? uninstallService(spec, { noStart })
213
+ ? await uninstallService(spec, { noStart, client })
206
214
  : serviceStatus(spec);
207
215
  process.stdout.write(`${JSON.stringify({ status: "ok", action, service: status })}\n`);
208
216
  return EXIT.ok;
@@ -338,11 +338,14 @@ export async function startDev(
338
338
  * statically.
339
339
  */
340
340
  export function manifestExportPlugin(entryFile: string): Plugin {
341
+ // Vite names modules with `/` on every platform (`C:/…` on Windows), so the entry is compared
342
+ // as the platform layer spells paths, never as the system does.
343
+ const entryKey = pathKey(entryFile);
341
344
  return {
342
345
  name: "mostra:dev-manifest-export",
343
346
  enforce: "pre",
344
347
  transform(code, id) {
345
- if (id.split("?")[0] !== entryFile || !/\.[jt]sx$/.test(entryFile)) return null;
348
+ if (pathKey(id.split("?")[0] ?? "") !== entryKey || !/\.[jt]sx$/.test(entryFile)) return null;
346
349
  const parsed = parseSync(entryFile, code, {
347
350
  lang: entryFile.endsWith(".tsx") ? "tsx" : "jsx",
348
351
  });
package/src/dev/index.ts CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  import { createHash, randomBytes } from "node:crypto";
19
19
  import { type FSWatcher, watch } from "node:fs";
20
- import { copyFile, mkdir, readdir, readFile, rm, stat, unlink, writeFile } from "node:fs/promises";
20
+ import { copyFile, mkdir, readdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
21
21
  import { dirname, join } from "node:path";
22
22
  import {
23
23
  ArtifactId,
@@ -38,13 +38,9 @@ import { type Dependencies, lockKey } from "../deps/index.ts";
38
38
  import type { Faults } from "../faults.ts";
39
39
  import type { Gate } from "../gate.ts";
40
40
  import type { Log } from "../log.ts";
41
+ import { removeTree } from "../platform/index.ts";
41
42
  import { handler, type MethodHandler, type Session } from "../protocol-server/index.ts";
42
- import {
43
- extractManifest,
44
- listSource,
45
- type ResolvedSource,
46
- resolveSource,
47
- } from "../publish/index.ts";
43
+ import { defaultTitle, extractManifest, listSource, resolveSource } from "../publish/index.ts";
48
44
  import type { Registry } from "../registry/index.ts";
49
45
  import { type Sandbox, type SandboxOptions, startSandbox } from "../verify/index.ts";
50
46
 
@@ -98,7 +94,7 @@ export async function recoverDev(home: string, log: Log): Promise<void> {
98
94
  } catch {
99
95
  return;
100
96
  }
101
- for (const name of left) await rm(join(devRoot(home), name), { recursive: true, force: true });
97
+ for (const name of left) await removeTree(join(devRoot(home), name));
102
98
  if (left.length > 0) log.info("dev.sessions_removed", { count: left.length });
103
99
  }
104
100
 
@@ -177,14 +173,24 @@ export function createDev(options: DevOptions): Dev {
177
173
  let manifestKey = "";
178
174
  let artifactId = "";
179
175
  const mirrored = new Map<string, string>();
176
+ /** When each mirrored file was first missed: a save that moves the old file aside first. */
177
+ const missing = new Map<string, number>();
180
178
 
181
- /** Copies changed files into the mirror and removes deleted ones; what changed. */
179
+ /**
180
+ * Copies changed files into the mirror and removes deleted ones; what changed. Editors save
181
+ * in several ways (in place, a temporary file renamed over the old one, the old one renamed
182
+ * to a backup first), and on Windows an editor may hold a file it is writing so that nothing
183
+ * else can read it: a file that can't be read now is left for the next sync, never recorded,
184
+ * and a file is removed from the mirror only once it has been missing for
185
+ * {@link MISSING_GRACE_MS}, so a save never looks like a deletion (WP-W2).
186
+ */
182
187
  const sync = async (): Promise<DevChange[]> => {
183
188
  const files = await listSource(source);
184
189
  const changed: DevChange[] = [];
185
190
  const seen = new Set<string>();
186
191
  for (const file of files) {
187
192
  seen.add(file.path);
193
+ missing.delete(file.path);
188
194
  let info: Awaited<ReturnType<typeof stat>>;
189
195
  try {
190
196
  info = await stat(file.absolute);
@@ -195,13 +201,23 @@ export function createDev(options: DevOptions): Dev {
195
201
  const before = mirrored.get(file.path);
196
202
  if (before === key) continue;
197
203
  const target = join(root, "source", ...file.path.split("/"));
198
- await mkdir(dirname(target), { recursive: true });
199
- await copyFile(file.absolute, target);
204
+ try {
205
+ await mkdir(dirname(target), { recursive: true });
206
+ await copyFile(file.absolute, target);
207
+ } catch (error) {
208
+ log.info("dev.sync_deferred", { sessionId, file: file.path, error });
209
+ continue;
210
+ }
200
211
  mirrored.set(file.path, key);
201
212
  changed.push({ file: file.path, kind: before === undefined ? "add" : "change" });
202
213
  }
214
+ const now = Date.now();
203
215
  for (const path of [...mirrored.keys()]) {
204
216
  if (seen.has(path)) continue;
217
+ const since = missing.get(path) ?? now;
218
+ missing.set(path, since);
219
+ if (now - since < MISSING_GRACE_MS) continue;
220
+ missing.delete(path);
205
221
  mirrored.delete(path);
206
222
  await unlink(join(root, "source", ...path.split("/"))).catch(() => {});
207
223
  changed.push({ file: path, kind: "unlink" });
@@ -220,7 +236,7 @@ export function createDev(options: DevOptions): Dev {
220
236
  source.entry,
221
237
  await readFile(join(root, "source", source.entry), "utf8"),
222
238
  );
223
- const manifest = extracted.manifest ?? { title: titleOf(source) };
239
+ const manifest = extracted.manifest ?? { title: defaultTitle(source) };
224
240
  const artifactId =
225
241
  manifest.id ??
226
242
  options.registry.artifactAt(source.bindingPath) ??
@@ -369,7 +385,9 @@ export function createDev(options: DevOptions): Dev {
369
385
  await child?.stop().catch(() => {});
370
386
  await sandbox?.close().catch(() => {});
371
387
  locksInUse.delete(sessionId);
372
- await rm(dir, { recursive: true, force: true });
388
+ // Through the platform layer: on Windows a file the dev server or an antivirus scan still
389
+ // holds for a moment refuses removal, which it retries (D150 item 8).
390
+ await removeTree(dir);
373
391
  };
374
392
  const stop = async (): Promise<void> => {
375
393
  if (closed) return;
@@ -500,12 +518,12 @@ export function createDev(options: DevOptions): Dev {
500
518
  };
501
519
  }
502
520
 
503
- /** The title of a source without a manifest: its directory's or file's name (INTERFACES §2.2). */
504
- function titleOf(source: ResolvedSource): string {
505
- const name =
506
- source.kind === "dir" ? source.root.split("/").at(-1) : source.entry.replace(/\.[^.]+$/, "");
507
- return name || "Untitled";
508
- }
521
+ /**
522
+ * How long a mirrored file must stay missing before `mostra dev` removes it: an editor that moves
523
+ * the old file aside before writing the new one leaves a gap of milliseconds, a deletion lasts.
524
+ * The 1 s comparison notices the removal within this and a second more.
525
+ */
526
+ const MISSING_GRACE_MS = 1500;
509
527
 
510
528
  const CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
511
529
 
@@ -56,6 +56,41 @@ function writeRaw(
56
56
  ...(extra.headers ?? []),
57
57
  ];
58
58
  socket.end(`${headers.join("\r\n")}\r\n\r\n${body}`);
59
+ lingerAfterRefusal(socket);
60
+ }
61
+
62
+ /** Connections already answered with a refusal: a later parse error on them changes nothing. */
63
+ const refusedSockets = new WeakSet<Duplex>();
64
+
65
+ /** How long a refused connection is read before it is closed regardless. */
66
+ const LINGER_MS = 5000;
67
+ /** How much of a refused request is read and dropped before the connection is closed. */
68
+ const LINGER_BYTES = 16 * 1024 * 1024;
69
+
70
+ /**
71
+ * Reads and drops what the client is still sending after its refusal, until it closes the
72
+ * connection, for at most {@link LINGER_MS} and {@link LINGER_BYTES}. A socket closed with unread
73
+ * bytes is reset, and a reset can reach the client before it read the answer, which it then never
74
+ * sees: on Windows a browser sending a megabyte of cookies got a reset instead of the page that
75
+ * clears them (WP-W2). The answer is already written; this only keeps the connection open long
76
+ * enough for it to be read, as HTTP servers do for a "lingering close".
77
+ */
78
+ function lingerAfterRefusal(socket: Duplex): void {
79
+ refusedSockets.add(socket);
80
+ // Node's HTTP server keeps feeding what arrives to the request parser that just failed, which
81
+ // fails again (a second `clientError`) and ends the connection: from here on this reads alone.
82
+ socket.removeAllListeners("data");
83
+ socket.once("end", () => socket.destroy());
84
+ let read = 0;
85
+ const timer = setTimeout(() => socket.destroy(), LINGER_MS);
86
+ timer.unref();
87
+ socket.once("close", () => clearTimeout(timer));
88
+ socket.on("error", () => socket.destroy());
89
+ socket.on("data", (chunk: Buffer) => {
90
+ read += chunk.length;
91
+ if (read > LINGER_BYTES) socket.destroy();
92
+ });
93
+ socket.resume();
59
94
  }
60
95
 
61
96
  /**
@@ -161,6 +196,7 @@ export function createListener(options: {
161
196
  });
162
197
  // A client that sends something Node can't parse gets a 400 and its connection closed.
163
198
  server.on("clientError", (error: NodeJS.ErrnoException, socket) => {
199
+ if (refusedSockets.has(socket)) return;
164
200
  if (!socket.writable) {
165
201
  socket.destroy();
166
202
  return;
package/src/home/index.ts CHANGED
@@ -12,5 +12,5 @@ export {
12
12
  socketPathLimit,
13
13
  } from "./paths.ts";
14
14
  export { checkPlatform, platformName } from "./platform.ts";
15
- export type { InstanceRecord } from "./record.ts";
15
+ export { type InstanceRecord, readLiveInstanceRecord } from "./record.ts";
16
16
  export { markHostConfigured, readHomeSettings, writeHomeSettings } from "./settings.ts";
@@ -9,7 +9,7 @@
9
9
  * else await started.instance.stopped;
10
10
  * ```
11
11
  */
12
- import { readFileSync, realpathSync, statSync } from "node:fs";
12
+ import { readFileSync, statSync } from "node:fs";
13
13
  import { dirname, join, relative, resolve } from "node:path";
14
14
  import type { Readable, Writable } from "node:stream";
15
15
  import { fileURLToPath } from "node:url";
@@ -81,7 +81,7 @@ import {
81
81
  } from "../interaction/index.ts";
82
82
  import { createLive, type LatestLive, liveMethods } from "../live/index.ts";
83
83
  import type { Environment, Log } from "../log.ts";
84
- import { helperPath, type LaunchPipe } from "../platform/index.ts";
84
+ import { helperPath, type LaunchPipe, realPath } from "../platform/index.ts";
85
85
  import {
86
86
  artifactEnvironment,
87
87
  openProcessManager,
@@ -252,9 +252,17 @@ export async function startInstance(options: StartInstanceOptions): Promise<Star
252
252
  }
253
253
 
254
254
  function sameHome(home: string, path: string): boolean {
255
+ // The client's spelling may differ from the instance's: a link, or on Windows a short (8.3)
256
+ // name or another case (the CLI's `%TEMP%` is often `C:\Users\RUNNER~1\…`, WP-W2). The home is
257
+ // its native real path, and so is the client's once resolved: the file system itself spells
258
+ // both, so they compare exactly. Folding case here would join directories the file system keeps
259
+ // apart: a case-sensitive directory's `Home` and `home`, or a name with the Kelvin sign and one
260
+ // with `k`, which NTFS tells apart and JavaScript's lower case doesn't (Opus review of WP-W2,
261
+ // finding 7).
255
262
  try {
256
- return realpathSync(path) === home;
263
+ return realPath(path) === home;
257
264
  } catch {
265
+ // A path that can't be resolved (it doesn't exist) is compared as written.
258
266
  return resolve(path) === home;
259
267
  }
260
268
  }
package/src/live/index.ts CHANGED
@@ -147,6 +147,12 @@ export function createLive(options: LiveOptions): Live {
147
147
  const retryAt = new Map<string, number>();
148
148
  /** Versions whose producers stopped because their worker is parked, by version, to their artifact. */
149
149
  const parkedVersions = new Map<string, string>();
150
+ /** Why each parked version parked: its sources' error names the last cause. */
151
+ const parkCauses = new Map<string, string>();
152
+ const parkError = (cause: string): WireError => ({
153
+ code: "MOSTRA_RUNTIME_WORKER_PARKED",
154
+ message: `The artifact's server code keeps crashing, so its live sources stopped (${cause}).`,
155
+ });
150
156
  let timer: ReturnType<typeof setInterval> | undefined;
151
157
  let scheduled = false;
152
158
  let stopped = false;
@@ -279,6 +285,15 @@ export function createLive(options: LiveOptions): Live {
279
285
  throw error;
280
286
  }
281
287
  } catch (error) {
288
+ // A start the park cut short says the park, never its own failure (#42). The park may not
289
+ // have named this source: a worker that never answered its start told nobody its sources
290
+ // (GPT review of MT-01).
291
+ if (parkedVersions.has(versionId)) {
292
+ if (failures.get(id)?.code !== "MOSTRA_RUNTIME_WORKER_PARKED") {
293
+ fail(artifactId, key, parkError(parkCauses.get(versionId) ?? "its last start failed"));
294
+ }
295
+ return;
296
+ }
282
297
  const diagnostic = error instanceof RpcError ? error.diagnostic : undefined;
283
298
  fail(artifactId, key, {
284
299
  message: diagnostic?.message ?? String(error),
@@ -484,18 +499,21 @@ export function createLive(options: LiveOptions): Live {
484
499
  },
485
500
 
486
501
  crashed(crash) {
502
+ const ended = new Set(crash.liveKeys);
487
503
  for (const [id, producer] of running) {
488
- if (producer.versionId === crash.versionId) running.delete(id);
504
+ if (producer.versionId !== crash.versionId) continue;
505
+ running.delete(id);
506
+ ended.add(producer.key);
489
507
  }
490
508
  if (crash.parked) {
491
- for (const key of crash.liveKeys) {
492
- fail(crash.artifactId, key, {
493
- code: "MOSTRA_RUNTIME_WORKER_PARKED",
494
- message: `The artifact's server code keeps crashing, so its live sources stopped (${crash.cause}).`,
495
- });
496
- }
509
+ // Every source of the parked version says so, not only the producers the worker had
510
+ // started when it crashed: one being started then, or due after the backoff, never runs
511
+ // again either, and its page would otherwise wait on it without a word (#42).
512
+ for (const source of described.get(crash.versionId) ?? []) ended.add(source.key);
513
+ for (const key of ended) fail(crash.artifactId, key, parkError(crash.cause));
497
514
  retryAt.set(crash.versionId, Number.POSITIVE_INFINITY);
498
515
  parkedVersions.set(crash.versionId, crash.artifactId);
516
+ parkCauses.set(crash.versionId, crash.cause);
499
517
  return;
500
518
  }
501
519
  retryAt.set(crash.versionId, Date.now() + crash.backoffMs);
@@ -521,6 +539,7 @@ export function createLive(options: LiveOptions): Live {
521
539
  for (const [versionId, owner] of parkedVersions) {
522
540
  if (owner !== artifactId) continue;
523
541
  parkedVersions.delete(versionId);
542
+ parkCauses.delete(versionId);
524
543
  retryAt.delete(versionId);
525
544
  cleared = true;
526
545
  }
@@ -14,7 +14,15 @@
14
14
  * - **Names.** Windows file names are case-insensitive: two names that differ only in case are
15
15
  * one file.
16
16
  */
17
- import { closeSync, type Dirent, fsyncSync, openSync, renameSync, statSync } from "node:fs";
17
+ import {
18
+ closeSync,
19
+ type Dirent,
20
+ fsyncSync,
21
+ openSync,
22
+ realpathSync,
23
+ renameSync,
24
+ statSync,
25
+ } from "node:fs";
18
26
  import {
19
27
  chmod,
20
28
  lstat,
@@ -245,6 +253,16 @@ function trimSeparators(path: string): string {
245
253
  }
246
254
 
247
255
  /** Whether a link points at `target` (paths compared as this file system compares them). */
256
+ /**
257
+ * A path's real path as the system spells it: links followed, and on Windows its short (8.3)
258
+ * names, such as `C:\Users\RUNNER~1`, written out in full and its case as stored, which only the
259
+ * system's own resolution does (`realpathSync.native`); Node.js's JavaScript resolution keeps
260
+ * them, so two spellings of one directory would differ. Throws when the path doesn't exist.
261
+ */
262
+ export function realPath(path: string): string {
263
+ return WINDOWS ? realpathSync.native(path) : realpathSync(path);
264
+ }
265
+
248
266
  export function samePath(a: string, b: string): boolean {
249
267
  const normal = (path: string): string =>
250
268
  nameKey(trimSeparators(resolve(path.startsWith("\\\\?\\") ? path.slice(4) : path)));
@@ -150,3 +150,29 @@ export function runHelperAsync<T>(args: readonly string[]): Promise<T> {
150
150
  });
151
151
  });
152
152
  }
153
+
154
+ /**
155
+ * The login service's launcher on Windows, `mostra-win-service.exe` beside the helper (D151): a
156
+ * program without a console that Task Scheduler runs at logon to keep the home's daemon running
157
+ * without a window. Throws `MOSTRA_ENV_HELPER_MISSING` when it isn't there.
158
+ */
159
+ export function serviceLauncherPath(env: NodeJS.ProcessEnv = process.env): string {
160
+ const launcher = join(dirname(helperPath(env)), "mostra-win-service.exe");
161
+ if (!existsSync(launcher)) {
162
+ throw missing(`Mostra's Windows service launcher isn't installed; looked for ${launcher}.`);
163
+ }
164
+ return launcher;
165
+ }
166
+
167
+ /** This process's user as a SID string (`S-1-5-21-…`), from the helper's `whoami`. */
168
+ export function currentUserSid(): string {
169
+ return runHelper<{ user: string }>(["whoami"]).user;
170
+ }
171
+
172
+ /**
173
+ * Asks the login service's launcher waiting on `event` to stop its daemon cleanly, and waits for
174
+ * it (at most the helper's 20 s): `stopped` is false when it still runs after that.
175
+ */
176
+ export function stopServiceLauncher(event: string): { signalled: boolean; stopped: boolean } {
177
+ return runHelper<{ signalled: boolean; stopped: boolean }>(["service-stop", event]);
178
+ }
@@ -33,6 +33,7 @@ export {
33
33
  linkTarget,
34
34
  nameKey,
35
35
  pathKey,
36
+ realPath,
36
37
  removeTree,
37
38
  renamePath,
38
39
  renamePathSync,
@@ -41,6 +42,12 @@ export {
41
42
  sealPlaced,
42
43
  sealTree,
43
44
  } from "./files.ts";
44
- export { helperPath, runtimeRoot } from "./helper.ts";
45
+ export {
46
+ currentUserSid,
47
+ helperPath,
48
+ runtimeRoot,
49
+ serviceLauncherPath,
50
+ stopServiceLauncher,
51
+ } from "./helper.ts";
45
52
  export { isSameProcess, listProcesses, readProcess } from "./identity.ts";
46
53
  export { adoptable, launch, reapRecorded } from "./launch.ts";
@@ -10,6 +10,7 @@
10
10
  * ```
11
11
  */
12
12
  import { type JsonRpcParams, RpcPeer } from "@mostra/protocol";
13
+ import { WINDOWS } from "../platform/index.ts";
13
14
 
14
15
  /** Options for {@link connectToSupervisor}. */
15
16
  export interface SupervisorConnectionOptions {
@@ -61,10 +62,12 @@ export function connectToSupervisor(
61
62
  * to signal: the child's gate ends its Job Object, descendants included, once the child exits.
62
63
  */
63
64
  function exitWithGroup(): void {
64
- try {
65
- process.kill(-process.pid, "SIGTERM");
66
- } catch {
67
- // The group is already gone.
65
+ if (!WINDOWS) {
66
+ try {
67
+ process.kill(-process.pid, "SIGTERM");
68
+ } catch {
69
+ // The group is already gone.
70
+ }
68
71
  }
69
72
  process.exit(0);
70
73
  }
@@ -15,9 +15,10 @@ export { extractManifest } from "./manifest.ts";
15
15
  export { artifactMethods, canonicalRef } from "./methods.ts";
16
16
  export {
17
17
  createPublisher,
18
+ defaultTitle,
18
19
  type Publisher,
19
20
  versionDamage,
20
21
  versionOutputDigest,
21
22
  } from "./publisher.ts";
22
- export { listSource, type ResolvedSource, resolveSource } from "./source.ts";
23
+ export { listSource, resolveSource } from "./source.ts";
23
24
  export { readTar } from "./tar.ts";
@@ -134,7 +134,7 @@ export interface Publisher {
134
134
  const ENTRY_NAMES = ["index.tsx", "index.jsx", "index.mdx"];
135
135
 
136
136
  /** The title of an artifact without a manifest: its directory's name, or a single file's own name. */
137
- function defaultTitle(source: ResolvedSource): string {
137
+ export function defaultTitle(source: ResolvedSource): string {
138
138
  if (source.kind === "dir") return basename(source.root);
139
139
  const stem = basename(source.entry, extname(source.entry));
140
140
  return stem === "page" || stem === "index" ? basename(source.root) : stem;