@stackfactor/agent-utils 1.2.0 → 1.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AA+ItC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,GAAG,KACT,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B;AAkDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MAuKP,CAAC"}
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AA6JtC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,GAAG,KACT,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B;AAkDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MAuKP,CAAC"}
package/dist/cjs/serve.js CHANGED
@@ -48,6 +48,10 @@ const runtimeContext_js_1 = require("./runtimeContext.js");
48
48
  // The conventional self-check module run on a deep HealthCheck when the caller
49
49
  // doesn't specify `check_code`. Resolved relative to the agent's app root.
50
50
  const DEFAULT_CHECK_PATH = "src/check.js";
51
+ // Genuine dynamic `import()` that survives TypeScript's CJS downlevelling (which
52
+ // would otherwise turn `import()` into `require()` and break file:// URLs and
53
+ // ESM check modules). Built once; see the call site in runSelfCheck.
54
+ const dynamicImport = new Function("specifier", "return import(specifier)");
51
55
  // Hard cap on a self-check; the agent receives this as its AbortSignal so its
52
56
  // own fetch/SDK calls can cooperate, and we fail the check if it overruns.
53
57
  const SELF_CHECK_TIMEOUT_MS = 20_000;
@@ -97,7 +101,13 @@ const runSelfCheck = async (checkCode, config, session) => {
97
101
  }
98
102
  let checkFn;
99
103
  try {
100
- const mod = await Promise.resolve(`${(0, node_url_1.pathToFileURL)(modulePath).href}`).then(s => __importStar(require(s)));
104
+ // Real dynamic import via an indirection the TS compiler won't rewrite. A
105
+ // literal `import()` is downlevelled to `require()` in the CJS build, and
106
+ // `require()` cannot resolve a file:// URL ("Cannot find module
107
+ // 'file:///app/src/check.js'"). `new Function` keeps a genuine `import()` in
108
+ // both builds; Node resolves the file URL and loads CJS or ESM check
109
+ // modules alike (CJS exports surface as the namespace `default`).
110
+ const mod = await dynamicImport((0, node_url_1.pathToFileURL)(modulePath).href);
101
111
  const exported = mod?.default ?? mod;
102
112
  checkFn =
103
113
  typeof exported === "function" ? exported : exported?.check ?? exported?.default;
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AA+ItC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,GAAG,KACT,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B;AAkDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MAuKP,CAAC"}
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AA6JtC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,GAAG,KACT,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B;AAkDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,SAAS,EACf,UAAS,YAAiB,KACzB,IAAI,CAAC,MAuKP,CAAC"}
package/dist/esm/serve.js CHANGED
@@ -9,6 +9,10 @@ import { runWithContext, installGlobals } from "./runtimeContext.js";
9
9
  // The conventional self-check module run on a deep HealthCheck when the caller
10
10
  // doesn't specify `check_code`. Resolved relative to the agent's app root.
11
11
  const DEFAULT_CHECK_PATH = "src/check.js";
12
+ // Genuine dynamic `import()` that survives TypeScript's CJS downlevelling (which
13
+ // would otherwise turn `import()` into `require()` and break file:// URLs and
14
+ // ESM check modules). Built once; see the call site in runSelfCheck.
15
+ const dynamicImport = new Function("specifier", "return import(specifier)");
12
16
  // Hard cap on a self-check; the agent receives this as its AbortSignal so its
13
17
  // own fetch/SDK calls can cooperate, and we fail the check if it overruns.
14
18
  const SELF_CHECK_TIMEOUT_MS = 20_000;
@@ -58,7 +62,13 @@ const runSelfCheck = async (checkCode, config, session) => {
58
62
  }
59
63
  let checkFn;
60
64
  try {
61
- const mod = await import(pathToFileURL(modulePath).href);
65
+ // Real dynamic import via an indirection the TS compiler won't rewrite. A
66
+ // literal `import()` is downlevelled to `require()` in the CJS build, and
67
+ // `require()` cannot resolve a file:// URL ("Cannot find module
68
+ // 'file:///app/src/check.js'"). `new Function` keeps a genuine `import()` in
69
+ // both builds; Node resolves the file URL and loads CJS or ESM check
70
+ // modules alike (CJS exports surface as the namespace `default`).
71
+ const mod = await dynamicImport(pathToFileURL(modulePath).href);
62
72
  const exported = mod?.default ?? mod;
63
73
  checkFn =
64
74
  typeof exported === "function" ? exported : exported?.check ?? exported?.default;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.2.0",
6
+ "version": "1.2.2",
7
7
  "description": "",
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/esm/index.js",