gdharness 1.0.15 → 1.0.17

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 (3) hide show
  1. package/build/cli.js +679 -600
  2. package/build/index.js +35 -12
  3. package/package.json +1 -1
package/build/index.js CHANGED
@@ -25730,6 +25730,16 @@ function withdrawBridge(path) {
25730
25730
  }
25731
25731
  }
25732
25732
 
25733
+ // src/call-signal.ts
25734
+ import { AsyncLocalStorage } from "node:async_hooks";
25735
+ var current = new AsyncLocalStorage;
25736
+ function withCallSignal(signal, answer) {
25737
+ return signal === undefined ? answer() : current.run(signal, answer);
25738
+ }
25739
+ function callSignal() {
25740
+ return current.getStore();
25741
+ }
25742
+
25733
25743
  // src/class-cache.ts
25734
25744
  import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
25735
25745
  import { join as join6 } from "node:path";
@@ -27754,14 +27764,7 @@ function reason(stdout, stderr) {
27754
27764
  async function runImport(godotPath, projectPath) {
27755
27765
  const logDir = mkdtempSync(join11(tmpdir3(), "gdharness-import-"));
27756
27766
  try {
27757
- const { stderr } = await run3(godotPath, [
27758
- "--headless",
27759
- "--log-file",
27760
- join11(logDir, "engine.log"),
27761
- "--path",
27762
- projectPath,
27763
- "--import"
27764
- ]);
27767
+ const { stderr } = await run3(godotPath, ["--headless", "--log-file", join11(logDir, "engine.log"), "--path", projectPath, "--import"], { signal: callSignal() });
27765
27768
  return { ok: true, messages: problems(stderr) };
27766
27769
  } catch (error) {
27767
27770
  if (error instanceof Error && "stdout" in error && "stderr" in error) {
@@ -27800,7 +27803,7 @@ async function runOperation(engine, operation, params, projectPath) {
27800
27803
  let stdout;
27801
27804
  let stderr;
27802
27805
  try {
27803
- ({ stdout, stderr } = await run3(engine.godotPath, args));
27806
+ ({ stdout, stderr } = await run3(engine.godotPath, args, { signal: callSignal() }));
27804
27807
  } catch (error) {
27805
27808
  if (error instanceof Error && "stdout" in error && "stderr" in error) {
27806
27809
  const failed = error;
@@ -31329,7 +31332,7 @@ class GodotServer {
31329
31332
  }
31330
31333
  setupToolHandlers() {
31331
31334
  this.mcp.server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: this.tools }));
31332
- this.mcp.server.setRequestHandler(CallToolRequestSchema, async (request) => {
31335
+ this.mcp.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
31333
31336
  this.logDebug(`Handling tool request: ${request.params.name}`);
31334
31337
  const spec = toolSpec(request.params.name);
31335
31338
  if (!spec) {
@@ -31344,7 +31347,7 @@ class GodotServer {
31344
31347
  this.lastProjectPath = args["projectPath"];
31345
31348
  }
31346
31349
  this.updates.refresh();
31347
- const answer = await this.answered(spec.name, checked.op ?? "", args);
31350
+ const answer = await withCallSignal(extra.signal, () => this.answered(spec.name, checked.op ?? "", args));
31348
31351
  return this.withFeedbackNotice(this.withUpdateNotice(answer));
31349
31352
  });
31350
31353
  }
@@ -32115,7 +32118,10 @@ class GodotServer {
32115
32118
  const log = new GameLog;
32116
32119
  let exitCode = 0;
32117
32120
  try {
32118
- const { stdout, stderr } = await run5(engine.value, exportArgs, { timeout: 300000 });
32121
+ const { stdout, stderr } = await run5(engine.value, exportArgs, {
32122
+ timeout: 300000,
32123
+ signal: callSignal()
32124
+ });
32119
32125
  log.append("stdout", stdout);
32120
32126
  log.append("stderr", stderr);
32121
32127
  } catch (error) {
@@ -33131,6 +33137,23 @@ class GodotServer {
33131
33137
  }
33132
33138
  spawnGame(godotPath, cmdArgs, env) {
33133
33139
  const child = spawn(godotPath, cmdArgs, { stdio: ["ignore", "pipe", "pipe"], ...env ? { env } : {} });
33140
+ const cancelled = callSignal();
33141
+ if (cancelled !== undefined) {
33142
+ const end = () => {
33143
+ if (child.exitCode === null && child.signalCode === null) {
33144
+ this.logDebug(`The call waiting on pid ${child.pid ?? "unknown"} was cancelled; ending it.`);
33145
+ child.kill();
33146
+ }
33147
+ };
33148
+ if (cancelled.aborted) {
33149
+ end();
33150
+ } else {
33151
+ cancelled.addEventListener("abort", end, { once: true });
33152
+ child.once("exit", () => {
33153
+ cancelled.removeEventListener("abort", end);
33154
+ });
33155
+ }
33156
+ }
33134
33157
  const log = new GameLog;
33135
33158
  const started = {
33136
33159
  process: child,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdharness",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
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",