@mostra/runtime 0.4.0 → 0.6.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/README.md CHANGED
@@ -34,7 +34,8 @@ version. `artifact/create`, `artifact/list` and `artifact/get` complete the auth
34
34
 
35
35
  ## Platforms
36
36
 
37
- macOS and Linux, on x64 and arm64. Elsewhere, including Windows, it stops with
38
- `MOSTRA_PLATFORM_UNSUPPORTED` before touching the home.
37
+ macOS, Linux and Windows, on x64 and arm64. Elsewhere it stops with `MOSTRA_PLATFORM_UNSUPPORTED`
38
+ before touching the home. On Windows the control endpoint is an owner-only named pipe that the
39
+ helper `mostra-win.exe` serves, and every child runs in a Job Object (D150).
39
40
 
40
41
  Part of [Mostra](https://github.com/mostra-dev/mostra), the agent artifact runtime. Apache-2.0.
package/dist/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as uninstallService, i as serviceStatus, n as startInstance, o as checkPlatform, r as installService, s as resolveHomePath, t as runtimeVersion } from "./instance-DxcGEQj_.js";
2
+ import { a as uninstallService, i as serviceStatus, n as startInstance, o as checkPlatform, r as installService, s as resolveHomePath, t as runtimeVersion } from "./instance-Da8UG_Qd.js";
3
3
  import { s as realPath } from "./files-FygSJIzK.js";
4
4
  import { mkdirSync } from "node:fs";
5
5
  import { fileURLToPath } from "node:url";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as startInstance, t as runtimeVersion } from "./instance-DxcGEQj_.js";
1
+ import { n as startInstance, t as runtimeVersion } from "./instance-Da8UG_Qd.js";
2
2
  import { t as connectToSupervisor } from "./child-Chiavhdx.js";
3
3
  export { connectToSupervisor, runtimeVersion, startInstance };
@@ -10662,6 +10662,12 @@ function createLive(options) {
10662
10662
  const retryAt = /* @__PURE__ */ new Map();
10663
10663
  /** Versions whose producers stopped because their worker is parked, by version, to their artifact. */
10664
10664
  const parkedVersions = /* @__PURE__ */ new Map();
10665
+ /** Why each parked version parked: its sources' error names the last cause. */
10666
+ const parkCauses = /* @__PURE__ */ new Map();
10667
+ const parkError = (cause) => ({
10668
+ code: "MOSTRA_RUNTIME_WORKER_PARKED",
10669
+ message: `The artifact's server code keeps crashing, so its live sources stopped (${cause}).`
10670
+ });
10665
10671
  let timer;
10666
10672
  let scheduled = false;
10667
10673
  let stopped = false;
@@ -10760,6 +10766,10 @@ function createLive(options) {
10760
10766
  throw error;
10761
10767
  }
10762
10768
  } catch (error) {
10769
+ if (parkedVersions.has(versionId)) {
10770
+ if (failures.get(id)?.code !== "MOSTRA_RUNTIME_WORKER_PARKED") fail(artifactId, key, parkError(parkCauses.get(versionId) ?? "its last start failed"));
10771
+ return;
10772
+ }
10763
10773
  const diagnostic = error instanceof RpcError ? error.diagnostic : void 0;
10764
10774
  fail(artifactId, key, {
10765
10775
  message: diagnostic?.message ?? String(error),
@@ -10915,14 +10925,18 @@ function createLive(options) {
10915
10925
  }
10916
10926
  },
10917
10927
  crashed(crash) {
10918
- for (const [id, producer] of running) if (producer.versionId === crash.versionId) running.delete(id);
10928
+ const ended = new Set(crash.liveKeys);
10929
+ for (const [id, producer] of running) {
10930
+ if (producer.versionId !== crash.versionId) continue;
10931
+ running.delete(id);
10932
+ ended.add(producer.key);
10933
+ }
10919
10934
  if (crash.parked) {
10920
- for (const key of crash.liveKeys) fail(crash.artifactId, key, {
10921
- code: "MOSTRA_RUNTIME_WORKER_PARKED",
10922
- message: `The artifact's server code keeps crashing, so its live sources stopped (${crash.cause}).`
10923
- });
10935
+ for (const source of described.get(crash.versionId) ?? []) ended.add(source.key);
10936
+ for (const key of ended) fail(crash.artifactId, key, parkError(crash.cause));
10924
10937
  retryAt.set(crash.versionId, Number.POSITIVE_INFINITY);
10925
10938
  parkedVersions.set(crash.versionId, crash.artifactId);
10939
+ parkCauses.set(crash.versionId, crash.cause);
10926
10940
  return;
10927
10941
  }
10928
10942
  retryAt.set(crash.versionId, Date.now() + crash.backoffMs);
@@ -10943,6 +10957,7 @@ function createLive(options) {
10943
10957
  for (const [versionId, owner] of parkedVersions) {
10944
10958
  if (owner !== artifactId) continue;
10945
10959
  parkedVersions.delete(versionId);
10960
+ parkCauses.delete(versionId);
10946
10961
  retryAt.delete(versionId);
10947
10962
  cleared = true;
10948
10963
  }
@@ -15148,12 +15163,15 @@ function own(inputs) {
15148
15163
  //#region src/home/platform.ts
15149
15164
  /**
15150
15165
  * The unsupported-platform gate (D35, D146, RT-07). Every entry point calls it before it touches
15151
- * the home: Mostra runs on macOS and Linux, on x64 and arm64, and fails closed elsewhere. Windows
15152
- * (x64 and arm64) is being built (WP-W1 to WP-W3) and runs only behind the development switch
15153
- * `MOSTRA_DEV_WINDOWS=1`, which only Mostra's own CI sets, so no release exposes a partial port.
15154
- * WP-W3 removes the switch.
15166
+ * the home: Mostra runs on macOS, Linux and Windows, on x64 and arm64, and fails closed elsewhere.
15167
+ * Windows was built behind a development switch by WP-W1 to WP-W3, and is supported since WP-W3
15168
+ * like the others.
15155
15169
  */
15156
- const OPERATING_SYSTEMS = ["darwin", "linux"];
15170
+ const OPERATING_SYSTEMS = [
15171
+ "darwin",
15172
+ "linux",
15173
+ "win32"
15174
+ ];
15157
15175
  const ARCHITECTURES = ["x64", "arm64"];
15158
15176
  /** The platform as `<os>-<arch>`, as `InstanceInfo.platform` reports it. */
15159
15177
  function platformName(platform = OS, arch = process.arch) {
@@ -15161,15 +15179,12 @@ function platformName(platform = OS, arch = process.arch) {
15161
15179
  }
15162
15180
  /**
15163
15181
  * Returns `MOSTRA_PLATFORM_UNSUPPORTED` for a platform Mostra doesn't run on, or `undefined` for
15164
- * a supported one. Windows is supported only while `env` sets the development switch to `1`.
15182
+ * a supported one.
15165
15183
  */
15166
- function checkPlatform(platform = OS, arch = process.arch, env = process.env) {
15167
- if (ARCHITECTURES.includes(arch)) {
15168
- if (OPERATING_SYSTEMS.includes(platform)) return void 0;
15169
- if (platform === "win32" && env["MOSTRA_DEV_WINDOWS"] === "1") return void 0;
15170
- }
15184
+ function checkPlatform(platform = OS, arch = process.arch) {
15185
+ if (ARCHITECTURES.includes(arch) && OPERATING_SYSTEMS.includes(platform)) return void 0;
15171
15186
  const name = platform === "win32" ? `Windows (${platformName(platform, arch)})` : platformName(platform, arch);
15172
- return createDiagnostic("MOSTRA_PLATFORM_UNSUPPORTED", { message: `Mostra doesn't run on ${name}; it supports macOS and Linux on x64 and arm64.` });
15187
+ return createDiagnostic("MOSTRA_PLATFORM_UNSUPPORTED", { message: `Mostra doesn't run on ${name}; it supports macOS, Linux and Windows on x64 and arm64.` });
15173
15188
  }
15174
15189
  //#endregion
15175
15190
  //#region src/home/settings.ts
@@ -15496,12 +15511,11 @@ function serviceFor(spec) {
15496
15511
  }
15497
15512
  /**
15498
15513
  * What a Windows task passes on besides the user's logon environment, which Task Scheduler gives
15499
- * it: the development switch while Windows needs it (D150 item 7, until WP-W3), the helper a
15500
- * checkout names, and the locale and time zone, as the POSIX units carry theirs. Nothing secret.
15514
+ * it: the helper a checkout names, and the locale and time zone, as the POSIX units carry theirs.
15515
+ * Nothing secret.
15501
15516
  */
15502
15517
  function windowsServiceVariables(env) {
15503
15518
  return [
15504
- "MOSTRA_DEV_WINDOWS",
15505
15519
  "MOSTRA_WIN_HELPER",
15506
15520
  "LANG",
15507
15521
  "TZ"
@@ -16663,4 +16677,4 @@ function sourceDirectory(path) {
16663
16677
  //#endregion
16664
16678
  export { uninstallService as a, serviceStatus as i, startInstance as n, checkPlatform as o, installService as r, resolveHomePath as s, runtimeVersion as t };
16665
16679
 
16666
- //# sourceMappingURL=instance-DxcGEQj_.js.map
16680
+ //# sourceMappingURL=instance-Da8UG_Qd.js.map