@kya-os/checkpoint-wasm-runtime 1.1.2 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,66 @@
1
1
  # @kya-os/checkpoint-wasm-runtime
2
2
 
3
+ ## 1.1.3 — 2026-05-17
4
+
5
+ **Critical runtime fix for Express on Vercel.** 1.1.2 still failed at
6
+ deploy time on `@vercel/node`-hosted Express functions with:
7
+
8
+ ```
9
+ Error: Dynamic require of "fs" is not supported
10
+ at .../dist/orchestrator-node.mjs:14:9
11
+ at wasm/kya-os-engine/kya_os_engine.js (...:454:21)
12
+ ```
13
+
14
+ ### Root cause
15
+
16
+ The wasm-bindgen `--target nodejs` glue contains literal
17
+ `require('fs').readFileSync(...)` to load the .wasm artifact. esbuild
18
+ rewrites that to its `__require('fs')` helper. The helper checks
19
+ `typeof require !== "undefined"` — in a pure ESM context (.mjs at
20
+ runtime) there is no global `require`, so the helper falls through
21
+ to its `throw Error('Dynamic require of "X" is not supported')`.
22
+
23
+ `shims: true` injects `__dirname` / `__filename` shims but does **not**
24
+ inject a `require` shim. The two are separate concerns in tsup.
25
+
26
+ ### Fix
27
+
28
+ Format-aware tsup `banner` injects
29
+ `const require = createRequire(import.meta.url);` at the top of every
30
+ ESM (.mjs) Node-target bundle. esbuild's `__require` helper then
31
+ finds `require` in scope and uses it for the .wasm load. CJS bundles
32
+ are unchanged (they already have a real `require` global). Edge
33
+ bundles are unchanged (separate tsup config, no banner — Edge runtimes
34
+ do not support `node:module`).
35
+
36
+ ### Why the previous "pivot to Express" path didn't escape this
37
+
38
+ The architect's earlier verdict (close [#2616](https://github.com/Know-That-Ai/agent-shield/pull/2616),
39
+ pivot bench to Express) was made under the assumption that Express's
40
+ direct Node import flow would bypass the bundler-interop layers that
41
+ broke Next.js Turbopack. Empirically, `@vercel/node` compiles the
42
+ function entry into a CJS→ESM hybrid that loads
43
+ `dist/orchestrator-node.mjs` through `loadESMFromCJS` — which executes
44
+ the .mjs in pure ESM context. Same require-less environment, same
45
+ failure. Express was not an escape.
46
+
47
+ ### Followup
48
+
49
+ [SDK-Next.js-Integration-Audit-1 (#2618)](https://github.com/Know-That-Ai/agent-shield/issues/2618)
50
+ Option B (wasm-bindgen `--target bundler`) remains the proper long-term
51
+ fix — it generates wasm-bindgen glue that does not require runtime CJS
52
+ globals. Until that lands, the createRequire banner is the minimal
53
+ defense for all Node-host runtimes.
54
+
55
+ ### Surfaced by
56
+
57
+ Bench-Before-After-1 §3.8 — `bench-new-express` deployment on Vercel
58
+ returned `FUNCTION_INVOCATION_FAILED` with the stack trace above. The
59
+ stack proved the failure persists past the Express pivot, requiring
60
+ the wasm-runtime fix to be re-opened.
61
+
62
+ ---
63
+
3
64
  ## 1.1.2 — 2026-05-17
4
65
 
5
66
  Fourth in the SDK-WASM-Bundler-Loader sequence. The 1.1.1 fix made
package/dist/edge.js CHANGED
@@ -1218,7 +1218,7 @@ var RulesDetector = class {
1218
1218
  return;
1219
1219
  }
1220
1220
  try {
1221
- this.rules = checkpointShared.loadRulesSync();
1221
+ this.rules = checkpointShared.RuleLoader.loadSync();
1222
1222
  this.ready = true;
1223
1223
  } catch (error) {
1224
1224
  console.warn("[RulesDetector] Failed to load rules:", error);
package/dist/edge.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { loadRulesSync } from '@kya-os/checkpoint-shared';
1
+ import { RuleLoader } from '@kya-os/checkpoint-shared';
2
2
 
3
3
  // src/types.ts
4
4
  var CONFIDENCE = {
@@ -1216,7 +1216,7 @@ var RulesDetector = class {
1216
1216
  return;
1217
1217
  }
1218
1218
  try {
1219
- this.rules = loadRulesSync();
1219
+ this.rules = RuleLoader.loadSync();
1220
1220
  this.ready = true;
1221
1221
  } catch (error) {
1222
1222
  console.warn("[RulesDetector] Failed to load rules:", error);
package/dist/engine.mjs CHANGED
@@ -1,16 +1,18 @@
1
+ import { createRequire } from 'module';
1
2
  import path from 'path';
2
3
  import { fileURLToPath } from 'url';
3
4
 
5
+ const require$1 = createRequire(import.meta.url);
4
6
  var __create = Object.create;
5
7
  var __defProp = Object.defineProperty;
6
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
9
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
10
  var __getProtoOf = Object.getPrototypeOf;
9
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
13
+ get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
12
14
  }) : x)(function(x) {
13
- if (typeof require !== "undefined") return require.apply(this, arguments);
15
+ if (typeof require$1 !== "undefined") return require$1.apply(this, arguments);
14
16
  throw Error('Dynamic require of "' + x + '" is not supported');
15
17
  });
16
18
  var __esm = (fn, res) => function __init() {
package/dist/index.js CHANGED
@@ -1443,7 +1443,7 @@ var RulesDetector = class {
1443
1443
  return;
1444
1444
  }
1445
1445
  try {
1446
- this.rules = checkpointShared.loadRulesSync();
1446
+ this.rules = checkpointShared.RuleLoader.loadSync();
1447
1447
  this.ready = true;
1448
1448
  } catch (error) {
1449
1449
  console.warn("[RulesDetector] Failed to load rules:", error);
package/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
- import { loadRulesSync } from '@kya-os/checkpoint-shared';
1
+ import { createRequire } from 'module';
2
+ import { RuleLoader } from '@kya-os/checkpoint-shared';
3
+
4
+ createRequire(import.meta.url);
2
5
 
3
6
  // src/types.ts
4
7
  var CONFIDENCE = {
@@ -1439,7 +1442,7 @@ var RulesDetector = class {
1439
1442
  return;
1440
1443
  }
1441
1444
  try {
1442
- this.rules = loadRulesSync();
1445
+ this.rules = RuleLoader.loadSync();
1443
1446
  this.ready = true;
1444
1447
  } catch (error) {
1445
1448
  console.warn("[RulesDetector] Failed to load rules:", error);
package/dist/node.js CHANGED
@@ -786,7 +786,7 @@ var RulesDetector = class {
786
786
  return;
787
787
  }
788
788
  try {
789
- this.rules = checkpointShared.loadRulesSync();
789
+ this.rules = checkpointShared.RuleLoader.loadSync();
790
790
  this.ready = true;
791
791
  } catch (error) {
792
792
  console.warn("[RulesDetector] Failed to load rules:", error);
package/dist/node.mjs CHANGED
@@ -1,4 +1,7 @@
1
- import { loadRulesSync } from '@kya-os/checkpoint-shared';
1
+ import { createRequire } from 'module';
2
+ import { RuleLoader } from '@kya-os/checkpoint-shared';
3
+
4
+ createRequire(import.meta.url);
2
5
 
3
6
  // src/types.ts
4
7
  var CONFIDENCE = {
@@ -784,7 +787,7 @@ var RulesDetector = class {
784
787
  return;
785
788
  }
786
789
  try {
787
- this.rules = loadRulesSync();
790
+ this.rules = RuleLoader.loadSync();
788
791
  this.ready = true;
789
792
  } catch (error) {
790
793
  console.warn("[RulesDetector] Failed to load rules:", error);
@@ -1,16 +1,18 @@
1
+ import { createRequire } from 'module';
1
2
  import path from 'path';
2
3
  import { fileURLToPath } from 'url';
3
4
 
5
+ const require$1 = createRequire(import.meta.url);
4
6
  var __create = Object.create;
5
7
  var __defProp = Object.defineProperty;
6
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
9
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
10
  var __getProtoOf = Object.getPrototypeOf;
9
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
13
+ get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
12
14
  }) : x)(function(x) {
13
- if (typeof require !== "undefined") return require.apply(this, arguments);
15
+ if (typeof require$1 !== "undefined") return require$1.apply(this, arguments);
14
16
  throw Error('Dynamic require of "' + x + '" is not supported');
15
17
  });
16
18
  var __esm = (fn, res) => function __init() {
@@ -1,16 +1,18 @@
1
+ import { createRequire } from 'module';
1
2
  import path from 'path';
2
3
  import { fileURLToPath } from 'url';
3
4
 
5
+ const require$1 = createRequire(import.meta.url);
4
6
  var __create = Object.create;
5
7
  var __defProp = Object.defineProperty;
6
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
9
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
10
  var __getProtoOf = Object.getPrototypeOf;
9
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
13
+ get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
12
14
  }) : x)(function(x) {
13
- if (typeof require !== "undefined") return require.apply(this, arguments);
15
+ if (typeof require$1 !== "undefined") return require$1.apply(this, arguments);
14
16
  throw Error('Dynamic require of "' + x + '" is not supported');
15
17
  });
16
18
  var __esm = (fn, res) => function __init() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/checkpoint-wasm-runtime",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Checkpoint WASM runtime for AI agent detection across all environments (formerly @kya-os/agentshield-wasm-runtime)",
5
5
  "keywords": [
6
6
  "ai",