gdharness 1.3.49 → 1.3.50

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.
Files changed (2) hide show
  1. package/build/cli.js +52 -11
  2. package/package.json +1 -1
package/build/cli.js CHANGED
@@ -12757,10 +12757,35 @@ var init_launch = __esm(() => {
12757
12757
  // src/godot-path.ts
12758
12758
  import { existsSync as existsSync7 } from "node:fs";
12759
12759
  import { isAbsolute as isAbsolute4, normalize, resolve as resolve5 } from "node:path";
12760
+ function versionStartOf(error) {
12761
+ const failed = error ?? {};
12762
+ const printed = [failed.stdout, failed.stderr].filter((part) => typeof part === "string").join(`
12763
+ `).trim();
12764
+ const quoted = printed.length > QUOTED_CHARACTERS ? `${printed.slice(0, QUOTED_CHARACTERS)}...` : printed;
12765
+ const output = quoted === "" ? " and printed nothing" : ` and printed ${JSON.stringify(quoted)}`;
12766
+ if (typeof failed.signal === "string") {
12767
+ return { kind: "crashed", said: `it was ended by ${failed.signal}${output}` };
12768
+ }
12769
+ if (typeof failed.code !== "number") {
12770
+ return { kind: "refused", said: `it could not be started: ${errorMessage(error)}` };
12771
+ }
12772
+ const code = failed.code >>> 0;
12773
+ const exception = code >= 3221225472;
12774
+ const said = `it exited ${exception ? `0x${code.toString(16).toUpperCase()}` : String(failed.code)}${output}`;
12775
+ return exception || printed === "" ? { kind: "crashed", said } : { kind: "refused", said };
12776
+ }
12760
12777
 
12761
12778
  class GodotLocator {
12762
12779
  answered = new Map;
12763
12780
  found = null;
12781
+ start;
12782
+ sleep;
12783
+ constructor(start = (path) => runHidden(path, ["--version"]), sleep = (ms) => new Promise((done) => {
12784
+ setTimeout(done, ms);
12785
+ })) {
12786
+ this.start = start;
12787
+ this.sleep = sleep;
12788
+ }
12764
12789
  async find() {
12765
12790
  if (this.found !== null && await this.whyNot(this.found) === null) {
12766
12791
  return { ok: true, path: this.found };
@@ -12808,21 +12833,37 @@ class GodotLocator {
12808
12833
  if (known !== undefined) {
12809
12834
  return known;
12810
12835
  }
12811
- let reason;
12812
12836
  if (path !== "godot" && !existsSync7(path)) {
12813
- reason = "does not exist";
12814
- } else {
12837
+ this.answered.set(path, "does not exist");
12838
+ return "does not exist";
12839
+ }
12840
+ let crashed = "";
12841
+ for (let started = 1;started <= VERSION_STARTS; started += 1) {
12842
+ if (started > 1) {
12843
+ await this.sleep(FIRST_RETRY_MS * 2 ** (started - 2));
12844
+ }
12845
+ let went;
12815
12846
  try {
12816
- await runHidden(path, ["--version"]);
12817
- reason = null;
12847
+ await this.start(path);
12848
+ went = { kind: "answered" };
12818
12849
  } catch (error) {
12819
- reason = `does not answer --version: ${errorMessage(error)}`;
12850
+ went = versionStartOf(error);
12851
+ }
12852
+ if (went.kind === "answered") {
12853
+ this.answered.set(path, null);
12854
+ return null;
12855
+ }
12856
+ if (went.kind === "refused") {
12857
+ const reason = `does not answer --version: ${went.said}`;
12858
+ this.answered.set(path, reason);
12859
+ return reason;
12820
12860
  }
12861
+ crashed = went.said;
12821
12862
  }
12822
- this.answered.set(path, reason);
12823
- return reason;
12863
+ return `crashed on each of ${String(VERSION_STARTS)} starts with --version; the last time ${crashed}`;
12824
12864
  }
12825
12865
  }
12866
+ var VERSION_STARTS = 5, FIRST_RETRY_MS = 500, QUOTED_CHARACTERS = 300;
12826
12867
  var init_godot_path = __esm(() => {
12827
12868
  init_detection();
12828
12869
  init_errors();
@@ -14604,7 +14645,7 @@ class UpdateCheck {
14604
14645
  asked = false;
14605
14646
  checkedAt = 0;
14606
14647
  retryAt = 0;
14607
- backoffMs = FIRST_RETRY_MS;
14648
+ backoffMs = FIRST_RETRY_MS2;
14608
14649
  enabled;
14609
14650
  current;
14610
14651
  cachePath;
@@ -14633,7 +14674,7 @@ class UpdateCheck {
14633
14674
  }
14634
14675
  this.latest = version;
14635
14676
  this.checkedAt = Date.now();
14636
- this.backoffMs = FIRST_RETRY_MS;
14677
+ this.backoffMs = FIRST_RETRY_MS2;
14637
14678
  this.retryAt = 0;
14638
14679
  writeCache(this.cachePath, { checkedAt: this.checkedAt, latest: version });
14639
14680
  }).catch(() => {
@@ -14665,7 +14706,7 @@ class UpdateCheck {
14665
14706
  };
14666
14707
  }
14667
14708
  }
14668
- var REGISTRY_ROOT = "https://registry.npmjs.org", RELEASES = "https://github.com/Aureliolo/gdharness/releases/tag", CACHE_MS, REQUEST_TIMEOUT_MS = 1e4, MAX_BODY_BYTES, FIRST_RETRY_MS = 30000, MAX_RETRY_MS, VERSION;
14709
+ var REGISTRY_ROOT = "https://registry.npmjs.org", RELEASES = "https://github.com/Aureliolo/gdharness/releases/tag", CACHE_MS, REQUEST_TIMEOUT_MS = 1e4, MAX_BODY_BYTES, FIRST_RETRY_MS2 = 30000, MAX_RETRY_MS, VERSION;
14669
14710
  var init_update_check = __esm(() => {
14670
14711
  init_runner();
14671
14712
  CACHE_MS = 10 * 60 * 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdharness",
3
- "version": "1.3.49",
3
+ "version": "1.3.50",
4
4
  "mcpName": "io.github.Aureliolo/gdharness",
5
5
  "description": "A harness for driving a Godot 4 project from an agent: editor addons, a runtime bridge into the running game, an MCP server in front of them, and a CLI that installs and diagnoses the Godot side.",
6
6
  "type": "module",