@infinitedusky/indusk-mcp 1.19.0 → 1.19.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/hooks/eval-trigger.js +38 -15
- package/package.json +1 -1
package/hooks/eval-trigger.js
CHANGED
|
@@ -226,15 +226,48 @@ syslog(
|
|
|
226
226
|
);
|
|
227
227
|
|
|
228
228
|
const syslogPath = resolve(projectRoot, ".indusk", "eval", "system.log");
|
|
229
|
+
// NOTE: this inline script runs with --input-type=module (see spawn below).
|
|
230
|
+
// ESM scope — use static imports from node: specifiers only. CJS module
|
|
231
|
+
// resolution throws ReferenceError in ESM scope at parse, and stdio:"ignore"
|
|
232
|
+
// on the detached spawn would swallow the error. For the full history see
|
|
233
|
+
// .indusk/planning/archive/bug-fix-eval-agent/diagnosis.md
|
|
229
234
|
const evaluatorScript = `
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
import { mkdirSync, appendFileSync } from "node:fs";
|
|
236
|
+
import { dirname, join } from "node:path";
|
|
232
237
|
function syslog(msg) {
|
|
233
238
|
try {
|
|
234
|
-
|
|
235
|
-
|
|
239
|
+
mkdirSync(dirname("${syslogPath}"), { recursive: true });
|
|
240
|
+
appendFileSync("${syslogPath}", new Date().toISOString() + " " + msg + "\\n");
|
|
236
241
|
} catch {}
|
|
237
242
|
}
|
|
243
|
+
// Belt-and-suspenders: if the evaluator crashes with an unhandled exception
|
|
244
|
+
// or rejection, write a loud error entry to results.log before exit so the
|
|
245
|
+
// failure is never silent again.
|
|
246
|
+
function writeErrorResult(message) {
|
|
247
|
+
try {
|
|
248
|
+
const logPath = join(${JSON.stringify(projectRoot)}, ".indusk", "eval", "results.log");
|
|
249
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
250
|
+
const entry = JSON.stringify({
|
|
251
|
+
version: 1,
|
|
252
|
+
timestamp: new Date().toISOString(),
|
|
253
|
+
mode: "eval",
|
|
254
|
+
changeId: ${JSON.stringify(changeId)},
|
|
255
|
+
error: true,
|
|
256
|
+
message,
|
|
257
|
+
});
|
|
258
|
+
appendFileSync(logPath, entry + "\\n", "utf8");
|
|
259
|
+
} catch {}
|
|
260
|
+
}
|
|
261
|
+
process.on("uncaughtException", (err) => {
|
|
262
|
+
syslog("evaluator uncaughtException — " + (err && err.message ? err.message : String(err)));
|
|
263
|
+
writeErrorResult("uncaughtException: " + (err && err.message ? err.message : String(err)));
|
|
264
|
+
process.exit(1);
|
|
265
|
+
});
|
|
266
|
+
process.on("unhandledRejection", (reason) => {
|
|
267
|
+
syslog("evaluator unhandledRejection — " + (reason && reason.message ? reason.message : String(reason)));
|
|
268
|
+
writeErrorResult("unhandledRejection: " + (reason && reason.message ? reason.message : String(reason)));
|
|
269
|
+
process.exit(1);
|
|
270
|
+
});
|
|
238
271
|
syslog("evaluator process started — changeId: ${changeId}");
|
|
239
272
|
import("${useModule}")
|
|
240
273
|
.then(m => {
|
|
@@ -254,17 +287,7 @@ import("${useModule}")
|
|
|
254
287
|
})
|
|
255
288
|
.catch(err => {
|
|
256
289
|
syslog("evaluator crashed — " + (err.message || String(err)));
|
|
257
|
-
|
|
258
|
-
fs.mkdirSync(path.dirname(logPath), { recursive: true });
|
|
259
|
-
const entry = JSON.stringify({
|
|
260
|
-
version: 1,
|
|
261
|
-
timestamp: new Date().toISOString(),
|
|
262
|
-
mode: "eval",
|
|
263
|
-
changeId: ${JSON.stringify(changeId)},
|
|
264
|
-
error: true,
|
|
265
|
-
message: err.message || String(err),
|
|
266
|
-
});
|
|
267
|
-
fs.appendFileSync(logPath, entry + "\\n", "utf8");
|
|
290
|
+
writeErrorResult(err.message || String(err));
|
|
268
291
|
process.exit(1);
|
|
269
292
|
});
|
|
270
293
|
`;
|