@intutic/mcp-governance-proxy 2.1.0 → 2.3.0

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 (148) hide show
  1. package/README.md +34 -18
  2. package/dist/agentTools.d.ts +68 -0
  3. package/dist/agentTools.d.ts.map +1 -0
  4. package/dist/agentTools.js +150 -0
  5. package/dist/agentTools.js.map +1 -0
  6. package/dist/anomaly/detectors.js +1 -1
  7. package/dist/anomaly/detectors.js.map +1 -1
  8. package/dist/anomaly/index.d.ts +2 -1
  9. package/dist/anomaly/index.d.ts.map +1 -1
  10. package/dist/anomaly/index.js.map +1 -1
  11. package/dist/approvalHold.d.ts +66 -0
  12. package/dist/approvalHold.d.ts.map +1 -0
  13. package/dist/approvalHold.js +143 -0
  14. package/dist/approvalHold.js.map +1 -0
  15. package/dist/budget.d.ts +133 -0
  16. package/dist/budget.d.ts.map +1 -0
  17. package/dist/budget.js +191 -0
  18. package/dist/budget.js.map +1 -0
  19. package/dist/config.d.ts +7 -2
  20. package/dist/config.d.ts.map +1 -1
  21. package/dist/config.js +2 -2
  22. package/dist/config.js.map +1 -1
  23. package/dist/daemon/healthMonitor.d.ts +2 -0
  24. package/dist/daemon/healthMonitor.d.ts.map +1 -1
  25. package/dist/daemon/healthMonitor.js +60 -27
  26. package/dist/daemon/healthMonitor.js.map +1 -1
  27. package/dist/daemon/index.d.ts +0 -2
  28. package/dist/daemon/index.d.ts.map +1 -1
  29. package/dist/daemon/index.js +0 -2
  30. package/dist/daemon/index.js.map +1 -1
  31. package/dist/daemon/instrumentation.d.ts +2 -2
  32. package/dist/daemon/instrumentation.js +2 -2
  33. package/dist/daemon/policyCache.d.ts +38 -3
  34. package/dist/daemon/policyCache.d.ts.map +1 -1
  35. package/dist/daemon/policyCache.js +64 -22
  36. package/dist/daemon/policyCache.js.map +1 -1
  37. package/dist/daemon/socketServer.d.ts +0 -1
  38. package/dist/daemon/socketServer.d.ts.map +1 -1
  39. package/dist/daemon/socketServer.js +0 -1
  40. package/dist/daemon/socketServer.js.map +1 -1
  41. package/dist/daemon/statusReporter.d.ts.map +1 -1
  42. package/dist/daemon/statusReporter.js +0 -1
  43. package/dist/daemon/statusReporter.js.map +1 -1
  44. package/dist/daemon/telemetryBatcher.d.ts.map +1 -1
  45. package/dist/daemon/telemetryBatcher.js +0 -1
  46. package/dist/daemon/telemetryBatcher.js.map +1 -1
  47. package/dist/daemonClient.d.ts.map +1 -1
  48. package/dist/daemonClient.js +0 -1
  49. package/dist/daemonClient.js.map +1 -1
  50. package/dist/dlp.d.ts +32 -3
  51. package/dist/dlp.d.ts.map +1 -1
  52. package/dist/dlp.js +116 -18
  53. package/dist/dlp.js.map +1 -1
  54. package/dist/dlpPii.d.ts +66 -0
  55. package/dist/dlpPii.d.ts.map +1 -0
  56. package/dist/dlpPii.js +235 -0
  57. package/dist/dlpPii.js.map +1 -0
  58. package/dist/emitter.d.ts +68 -10
  59. package/dist/emitter.d.ts.map +1 -1
  60. package/dist/emitter.js +29 -43
  61. package/dist/emitter.js.map +1 -1
  62. package/dist/guardedValkey.d.ts +40 -0
  63. package/dist/guardedValkey.d.ts.map +1 -0
  64. package/dist/guardedValkey.js +84 -0
  65. package/dist/guardedValkey.js.map +1 -0
  66. package/dist/httpJson.d.ts +19 -0
  67. package/dist/httpJson.d.ts.map +1 -0
  68. package/dist/httpJson.js +62 -0
  69. package/dist/httpJson.js.map +1 -0
  70. package/dist/identity.d.ts +27 -0
  71. package/dist/identity.d.ts.map +1 -0
  72. package/dist/identity.js +36 -0
  73. package/dist/identity.js.map +1 -0
  74. package/dist/injection.js +1 -1
  75. package/dist/interceptor.d.ts +135 -8
  76. package/dist/interceptor.d.ts.map +1 -1
  77. package/dist/interceptor.js +284 -45
  78. package/dist/interceptor.js.map +1 -1
  79. package/dist/policy.d.ts +105 -2
  80. package/dist/policy.d.ts.map +1 -1
  81. package/dist/policy.js +188 -40
  82. package/dist/policy.js.map +1 -1
  83. package/dist/proxy.d.ts +35 -11
  84. package/dist/proxy.d.ts.map +1 -1
  85. package/dist/proxy.js +183 -66
  86. package/dist/proxy.js.map +1 -1
  87. package/dist/refusals.d.ts +26 -0
  88. package/dist/refusals.d.ts.map +1 -0
  89. package/dist/refusals.js +43 -0
  90. package/dist/refusals.js.map +1 -0
  91. package/dist/registryObserver.d.ts +37 -0
  92. package/dist/registryObserver.d.ts.map +1 -0
  93. package/dist/registryObserver.js +70 -0
  94. package/dist/registryObserver.js.map +1 -0
  95. package/dist/session.d.ts +1 -1
  96. package/dist/session.js +1 -1
  97. package/dist/sessionScope.d.ts +1 -1
  98. package/dist/sessionScope.js +1 -1
  99. package/dist/sessionStore.d.ts +10 -23
  100. package/dist/sessionStore.d.ts.map +1 -1
  101. package/dist/sessionStore.js +17 -76
  102. package/dist/sessionStore.js.map +1 -1
  103. package/dist/version.d.ts +12 -0
  104. package/dist/version.d.ts.map +1 -0
  105. package/dist/version.js +13 -0
  106. package/dist/version.js.map +1 -0
  107. package/dist/wasm/context.d.ts +10 -0
  108. package/dist/wasm/context.d.ts.map +1 -1
  109. package/dist/wasm/context.js +27 -0
  110. package/dist/wasm/context.js.map +1 -1
  111. package/dist/wasm/hostImports.d.ts +3 -3
  112. package/dist/wasm/hostImports.d.ts.map +1 -1
  113. package/dist/wasm/hostImports.js +8 -7
  114. package/dist/wasm/hostImports.js.map +1 -1
  115. package/dist/wasm/loader.d.ts +8 -1
  116. package/dist/wasm/loader.d.ts.map +1 -1
  117. package/dist/wasm/loader.js +2 -0
  118. package/dist/wasm/loader.js.map +1 -1
  119. package/dist/wasm/referencedFiles.d.ts +29 -4
  120. package/dist/wasm/referencedFiles.d.ts.map +1 -1
  121. package/dist/wasm/referencedFiles.js +48 -21
  122. package/dist/wasm/referencedFiles.js.map +1 -1
  123. package/dist/wasm/runner.d.ts +106 -22
  124. package/dist/wasm/runner.d.ts.map +1 -1
  125. package/dist/wasm/runner.js +194 -74
  126. package/dist/wasm/runner.js.map +1 -1
  127. package/dist/wasm/watch.js +1 -1
  128. package/dist/wasm/worker.d.ts +10 -6
  129. package/dist/wasm/worker.d.ts.map +1 -1
  130. package/dist/wasm/worker.js +93 -9
  131. package/dist/wasm/worker.js.map +1 -1
  132. package/package.json +5 -4
  133. package/dist/toolPoison.d.ts +0 -32
  134. package/dist/toolPoison.d.ts.map +0 -1
  135. package/dist/toolPoison.js +0 -81
  136. package/dist/toolPoison.js.map +0 -1
  137. package/dist/wasm/fuel.d.ts +0 -35
  138. package/dist/wasm/fuel.d.ts.map +0 -1
  139. package/dist/wasm/fuel.js +0 -299
  140. package/dist/wasm/fuel.js.map +0 -1
  141. package/dist/wasm/memoryCap.d.ts +0 -21
  142. package/dist/wasm/memoryCap.d.ts.map +0 -1
  143. package/dist/wasm/memoryCap.js +0 -54
  144. package/dist/wasm/memoryCap.js.map +0 -1
  145. package/dist/wasm/wasmBinary.d.ts +0 -25
  146. package/dist/wasm/wasmBinary.d.ts.map +0 -1
  147. package/dist/wasm/wasmBinary.js +0 -100
  148. package/dist/wasm/wasmBinary.js.map +0 -1
@@ -10,29 +10,32 @@
10
10
  * happen to share a rule.
11
11
  *
12
12
  * Protocol (see `runner.ts` for the main-thread side):
13
- * compile { type:'compile', id, ruleId, bytes } -> { type:'compile-result', id, ruleId, ok, unsupportedImports?, readsReferencedFiles?, error? }
13
+ * compile { type:'compile', id, ruleId, bytes } -> { type:'compile-result', id, ruleId, ok, reason?, unsupportedImports?, readsReferencedFiles?, rego?, error? }
14
14
  * remove { type:'remove', ruleId } (no reply)
15
- * evaluate { type:'evaluate', id, ruleId, bytes, files? } -> { type:'evaluate-result', id, ruleId, ok, code?, reason?, error? }
15
+ * evaluate { type:'evaluate', id, ruleId, bytes, files? } -> { type:'evaluate-result', id, ruleId, ok, code?, decision?, reason?, riskTier?, error?, fuelExhausted?, notADecision? }
16
16
  *
17
- * `files` is the per-evaluation referenced-files table (TD-441), posted only
17
+ * A Rego rule (an OPA build, `@intutic/shared-types`' Rego host) is compiled
18
+ * and evaluated here too; its `evaluate` bytes are the Rego input document and
19
+ * its reply carries `decision` instead of `code`.
20
+ *
21
+ * `files` is the per-evaluation referenced-files table, posted only
18
22
  * to a rule that imports `read_referenced_file`; it is rebuilt here into the
19
23
  * host-import state, so the main thread never shares memory with the guest.
20
24
  *
21
25
  * A guest `abort` call is inert (hostImports.ts logs and returns); an
22
26
  * uncaught exception or trap during instantiation/evaluation is caught here
23
- * and reported as `ok:false` — the caller (runner.ts) treats that as
24
- * fail-open ALLOW, exactly like a timeout, never a crash.
27
+ * and reported as `ok:false` — the caller (runner.ts) treats that as a rule
28
+ * that reached no verdict, exactly like a timeout, never a crash.
25
29
  *
26
30
  * @module
27
31
  */
28
32
  import { parentPort } from 'node:worker_threads';
29
- import { unsupportedWasmImports, WASM_HOST_IMPORTS } from '@intutic/shared-types';
33
+ import { createHash } from 'node:crypto';
34
+ import { DEFAULT_FUEL_BUDGET, FUEL_EXPORT, REGO_DISABLE_ENV, REGO_FUEL_BUDGET, WASM_PAGE_BYTES, capDeclaredMemory, evaluateRegoRule, meterFuel, isOpaModule, loadRegoRule, regoDecision, RegoResultError, unsupportedWasmImports, WASM_HOST_IMPORTS, } from '@intutic/shared-types';
30
35
  import { createHostImports, newHostImportState } from './hostImports.js';
31
36
  import { ReferencedFiles } from './referencedFiles.js';
32
- import { capDeclaredMemory, WASM_PAGE_BYTES } from './memoryCap.js';
33
- import { DEFAULT_FUEL_BUDGET, FUEL_EXPORT, meterFuel } from './fuel.js';
34
37
  /**
35
- * Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits` (TD-440). Enforced at
38
+ * Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits`. Enforced at
36
39
  * load by `capDeclaredMemory`: the module's own memory is rewritten to declare
37
40
  * this as its maximum, so V8 refuses any `memory.grow` past it (the call
38
41
  * returns -1) instead of growing. A module whose initial size is already over
@@ -66,11 +69,37 @@ function stripControlCharacters(text) {
66
69
  return out;
67
70
  }
68
71
  const modules = new Map();
72
+ /** Rego policies compiled by OPA, by rule id: a different ABI, run through the shared host. */
73
+ const regoRules = new Map();
74
+ const regoHost = {
75
+ digest: (algorithm, data) => createHash(algorithm).update(data).digest('hex'),
76
+ };
77
+ /**
78
+ * Load an OPA build as a Rego rule: metered like any rule, with the Rego
79
+ * budget (`REGO_FUEL_BUDGET`), and checked by the shared host, which refuses
80
+ * one needing a builtin it lacks.
81
+ */
82
+ function compileRego(msg) {
83
+ if (process.env[REGO_DISABLE_ENV] === '1') {
84
+ throw new Error(`Rego rules are switched off on this host (${REGO_DISABLE_ENV}=1)`);
85
+ }
86
+ const bytes = new Uint8Array(msg.bytes);
87
+ const rule = loadRegoRule(bytes, new WebAssembly.Module(meterFuel(bytes, REGO_FUEL_BUDGET)), regoHost);
88
+ if (!rule)
89
+ throw new Error('not an OPA build');
90
+ modules.delete(msg.ruleId);
91
+ regoRules.set(msg.ruleId, rule);
92
+ parentPort?.postMessage({ type: 'compile-result', id: msg.id, ruleId: msg.ruleId, ok: true, readsReferencedFiles: false, rego: true });
93
+ }
69
94
  function importsUsingReadReferencedFile(module) {
70
95
  return WebAssembly.Module.imports(module).some((i) => i.module === 'env' && i.name === 'read_referenced_file' && i.kind === 'function');
71
96
  }
72
97
  function handleCompile(msg) {
73
98
  try {
99
+ if (isOpaModule(new WebAssembly.Module(new Uint8Array(msg.bytes)))) {
100
+ compileRego(msg);
101
+ return;
102
+ }
74
103
  const capped = capDeclaredMemory(new Uint8Array(msg.bytes), MAX_GUEST_MEMORY_BYTES / WASM_PAGE_BYTES);
75
104
  const module = new WebAssembly.Module(meterFuel(capped, DEFAULT_FUEL_BUDGET));
76
105
  if (WebAssembly.Module.imports(module).some((i) => i.kind === 'memory')) {
@@ -83,10 +112,12 @@ function handleCompile(msg) {
83
112
  id: msg.id,
84
113
  ruleId: msg.ruleId,
85
114
  ok: false,
115
+ reason: 'unsupported_import',
86
116
  unsupportedImports: unsupported,
87
117
  });
88
118
  return;
89
119
  }
120
+ regoRules.delete(msg.ruleId);
90
121
  modules.set(msg.ruleId, module);
91
122
  parentPort?.postMessage({
92
123
  type: 'compile-result',
@@ -94,6 +125,7 @@ function handleCompile(msg) {
94
125
  ruleId: msg.ruleId,
95
126
  ok: true,
96
127
  readsReferencedFiles: importsUsingReadReferencedFile(module),
128
+ rego: false,
97
129
  });
98
130
  }
99
131
  catch (err) {
@@ -102,12 +134,59 @@ function handleCompile(msg) {
102
134
  id: msg.id,
103
135
  ruleId: msg.ruleId,
104
136
  ok: false,
137
+ // Bytes V8 will not compile, as Wasmtime would not; anything else (a
138
+ // Rego build the host cannot run, an instruction the meter refuses, an
139
+ // imported memory) compiles but cannot run here.
140
+ reason: err instanceof WebAssembly.CompileError ? 'compile_error' : 'load_error',
105
141
  error: err instanceof Error ? err.message : String(err),
106
142
  });
107
143
  }
108
144
  }
109
145
  function handleRemove(msg) {
110
146
  modules.delete(msg.ruleId);
147
+ regoRules.delete(msg.ruleId);
148
+ }
149
+ /**
150
+ * Evaluate a Rego rule against the input document the runner built
151
+ * (`buildRegoInput`). Replies with the decision rather than a verdict code:
152
+ * a hold has no native code.
153
+ */
154
+ function evaluateRego(msg, rule) {
155
+ let fuel;
156
+ try {
157
+ const result = evaluateRegoRule(rule, new TextDecoder().decode(msg.bytes), {
158
+ ...regoHost,
159
+ onInstance: (exportsObj) => {
160
+ const g = exportsObj[FUEL_EXPORT];
161
+ if (g instanceof WebAssembly.Global)
162
+ fuel = g;
163
+ },
164
+ });
165
+ const decision = regoDecision(result, rule.entrypoint);
166
+ parentPort?.postMessage({
167
+ type: 'evaluate-result',
168
+ id: msg.id,
169
+ ruleId: msg.ruleId,
170
+ ok: true,
171
+ decision: decision.decision,
172
+ reason: 'reason' in decision ? decision.reason : undefined,
173
+ riskTier: decision.riskTier ?? rule.riskTier,
174
+ });
175
+ }
176
+ catch (err) {
177
+ const fuelExhausted = fuel !== undefined && fuel.value < 0;
178
+ parentPort?.postMessage({
179
+ type: 'evaluate-result',
180
+ id: msg.id,
181
+ ruleId: msg.ruleId,
182
+ ok: false,
183
+ fuelExhausted,
184
+ notADecision: err instanceof RegoResultError,
185
+ error: fuelExhausted
186
+ ? `Rego rule ran out of its ${REGO_FUEL_BUDGET}-instruction budget`
187
+ : err instanceof Error ? err.message : String(err),
188
+ });
189
+ }
111
190
  }
112
191
  /**
113
192
  * Ported from `runner.rs`'s `read_guest_reason`: two OPTIONAL zero-arg
@@ -157,6 +236,11 @@ function readGuestReason(exportsObj, memory) {
157
236
  return stripped.length > 0 ? stripped : undefined;
158
237
  }
159
238
  function handleEvaluate(msg) {
239
+ const rego = regoRules.get(msg.ruleId);
240
+ if (rego) {
241
+ evaluateRego(msg, rego);
242
+ return;
243
+ }
160
244
  const module = modules.get(msg.ruleId);
161
245
  if (!module) {
162
246
  parentPort?.postMessage({ type: 'evaluate-result', id: msg.id, ruleId: msg.ruleId, ok: false, error: 'rule not loaded' });
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/wasm/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,eAAe,EAA6B,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtD;;;GAGG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B;;;;;;;;GAQG;AACH,MAAM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,CAAC,CAAA;AAEF,4EAA4E;AAC5E,yEAAyE;AACzE,qEAAqE;AACrE,gEAAgE;AAChE,yDAAyD;AACzD,KAAK,iBAAiB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intutic/mcp-governance-proxy",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Intutic MCP Governance Proxy — transparent stdio proxy that intercepts all tools/call JSON-RPC messages and applies workspace SOP policy before forwarding to real MCP servers",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,9 +33,9 @@
33
33
  "@opentelemetry/semantic-conventions": "^1.43.0",
34
34
  "ioredis": "^5",
35
35
  "zod": "^3",
36
- "@intutic/id": "2.1.0",
37
- "@intutic/logger": "2.1.0",
38
- "@intutic/shared-types": "2.1.0"
36
+ "@intutic/id": "2.3.0",
37
+ "@intutic/logger": "2.3.0",
38
+ "@intutic/shared-types": "2.3.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^22",
@@ -52,6 +52,7 @@
52
52
  "dev": "tsx src/index.ts",
53
53
  "typecheck": "tsc --noEmit",
54
54
  "test": "vitest run",
55
+ "test:load": "vitest run --config vitest.load.config.ts",
55
56
  "test:watch": "vitest"
56
57
  }
57
58
  }
@@ -1,32 +0,0 @@
1
- /**
2
- * toolPoison.ts — Tool-description poisoning patterns.
3
- *
4
- * Direct TypeScript port of `packages/proxy/src/tool_poison.rs`'s `scan`
5
- * function and its seven named patterns (confirmed by reading that file
6
- * directly). This is a SEPARATE pattern set from `injection.ts`, on purpose:
7
- * `tool_poison.rs`'s own module doc records that it tried reusing
8
- * `injection::scan` for this and measured that its five patterns match ZERO
9
- * of the tool-poisoning payloads — they are tuned for conversational
10
- * jailbreak phrasing ("ignore previous instructions"), while a poisoned tool
11
- * description reads like documentation, not a jailbreak. `ToolPoisoningDetector`
12
- * (Phase 2's `anomaly/detectors.ts`) is what consumes this module.
13
- *
14
- * The Rust source gates each pattern behind a cheap substring pre-check
15
- * (`GATES`) before running the regex, measured to be ~1.8× faster than the
16
- * regex alone on their corpus. That optimization is NOT ported here — it is
17
- * a performance detail proven equivalent to the plain regex loop (the Rust
18
- * module's own `gating_never_changes_a_verdict` test asserts exactly that
19
- * equivalence), never a correctness one, and the volume of tool descriptions
20
- * one MCP session evaluates is orders of magnitude below the Rust proxy's
21
- * request-path corpus. The pattern SOURCE TEXT below is unchanged from the
22
- * Rust `PATTERNS` array — only the verbatim regex text is what was actually
23
- * measured, so preserving it exactly (not the gate) is what matters here.
24
- *
25
- * @module
26
- */
27
- /**
28
- * Pattern names matching this tool description, deduplicated, empty when it
29
- * looks like ordinary prose (the overwhelmingly common case).
30
- */
31
- export declare function scanToolDescription(description: string): string[];
32
- //# sourceMappingURL=toolPoison.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolPoison.d.ts","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAkDH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAOjE"}
@@ -1,81 +0,0 @@
1
- /**
2
- * toolPoison.ts — Tool-description poisoning patterns.
3
- *
4
- * Direct TypeScript port of `packages/proxy/src/tool_poison.rs`'s `scan`
5
- * function and its seven named patterns (confirmed by reading that file
6
- * directly). This is a SEPARATE pattern set from `injection.ts`, on purpose:
7
- * `tool_poison.rs`'s own module doc records that it tried reusing
8
- * `injection::scan` for this and measured that its five patterns match ZERO
9
- * of the tool-poisoning payloads — they are tuned for conversational
10
- * jailbreak phrasing ("ignore previous instructions"), while a poisoned tool
11
- * description reads like documentation, not a jailbreak. `ToolPoisoningDetector`
12
- * (Phase 2's `anomaly/detectors.ts`) is what consumes this module.
13
- *
14
- * The Rust source gates each pattern behind a cheap substring pre-check
15
- * (`GATES`) before running the regex, measured to be ~1.8× faster than the
16
- * regex alone on their corpus. That optimization is NOT ported here — it is
17
- * a performance detail proven equivalent to the plain regex loop (the Rust
18
- * module's own `gating_never_changes_a_verdict` test asserts exactly that
19
- * equivalence), never a correctness one, and the volume of tool descriptions
20
- * one MCP session evaluates is orders of magnitude below the Rust proxy's
21
- * request-path corpus. The pattern SOURCE TEXT below is unchanged from the
22
- * Rust `PATTERNS` array — only the verbatim regex text is what was actually
23
- * measured, so preserving it exactly (not the gate) is what matters here.
24
- *
25
- * @module
26
- */
27
- /**
28
- * Ported verbatim from `tool_poison.rs`'s `PATTERNS` const. All bounded
29
- * repetitions here are small fixed-width gaps (`{0,40}`, `{0,60}`, `{0,80}`)
30
- * over a handful of alternations — the same "no wide bounded repetition, no
31
- * RegexSet performance regression" shape `injection.ts` documents, not the
32
- * `dlp.rs` shape that regressed.
33
- */
34
- const PATTERNS = [
35
- {
36
- name: 'hidden-instruction-block',
37
- regex: /<\s*(important|secret|system|hidden|instructions?)\s*>/i,
38
- },
39
- {
40
- name: 'conceal-from-user',
41
- regex: /\bdo\s+not\s+(mention|tell|inform|reveal|disclose|show)\b[^.!?]{0,40}\buser\b|\bwithout\s+(informing|telling|notifying|alerting)\s+the\s+user\b/i,
42
- },
43
- {
44
- name: 'sidechannel-exfil',
45
- regex: /\b(pass|send|include|append|forward|provide)\b[^.!?]{0,60}\b(content|value|text)s?\s+of\b[^.!?]{0,40}(~\/|\.env|\.ssh|id_rsa|credential|secret|token|api[_ ]?key)/i,
46
- },
47
- {
48
- name: 'read-sensitive-path',
49
- // Rust's own comment: no `\b` before the alternation, because a word
50
- // boundary cannot exist before a literal `.` — `\b\.env` matches
51
- // nothing. Preserved exactly, including that absence.
52
- regex: /\b(read|open|cat|load|access)\b[^.!?]{0,30}(~\/\.\w+|\.ssh\/|id_rsa|\.env\b|\.aws\/|mcp\.json|\/etc\/passwd)/i,
53
- },
54
- {
55
- name: 'cross-tool-shadowing',
56
- regex: /\buse\s+this\s+tool\s+instead\s+of\b|\bdo\s+not\s+use\s+the\s+\w+\s+tool\b|\bthis\s+tool\s+supersedes\b/i,
57
- },
58
- {
59
- name: 'agent-directed-precondition',
60
- regex: /\bbefore\s+(using|calling|invoking)\s+(this|the)\s+tool\b[^.!?]{0,80}\b(you\s+must|first\s+read|first\s+call)\b/i,
61
- },
62
- {
63
- name: 'tool-scoped-instruction-override',
64
- regex: /\b(ignore|disregard|override)\b[^.!?]{0,40}\b(other\s+tools?|previous\s+tools?|system\s+prompt)\b/i,
65
- },
66
- ];
67
- /**
68
- * Pattern names matching this tool description, deduplicated, empty when it
69
- * looks like ordinary prose (the overwhelmingly common case).
70
- */
71
- export function scanToolDescription(description) {
72
- if (!description)
73
- return [];
74
- const found = [];
75
- for (const { name, regex } of PATTERNS) {
76
- if (regex.test(description))
77
- found.push(name);
78
- }
79
- return found;
80
- }
81
- //# sourceMappingURL=toolPoison.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolPoison.js","sourceRoot":"","sources":["../src/toolPoison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH;;;;;;GAMG;AACH,MAAM,QAAQ,GAAiC;IAC7C;QACE,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE,yDAAyD;KACjE;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,KAAK,EACH,kJAAkJ;KACrJ;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,KAAK,EACH,oKAAoK;KACvK;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,qEAAqE;QACrE,iEAAiE;QACjE,sDAAsD;QACtD,KAAK,EAAE,+GAA+G;KACvH;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,0GAA0G;KAClH;IACD;QACE,IAAI,EAAE,6BAA6B;QACnC,KAAK,EAAE,kHAAkH;KAC1H;IACD;QACE,IAAI,EAAE,kCAAkC;QACxC,KAAK,EAAE,oGAAoG;KAC5G;CACF,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAAmB;IACrD,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAA;IAC3B,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,QAAQ,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Instruction budget for WASM rules (TD-440): the MCP proxy's stand-in for
3
- * Wasmtime fuel, which `runner.rs` sets to 1,000,000 per evaluation.
4
- *
5
- * V8 has no metering hook, so the rule's own code is rewritten at load to
6
- * count. A new mutable i32 global starts at the budget, and a charge is
7
- * inserted at every function entry and every loop header: subtract the number
8
- * of instructions that can run before the next charge point, and trap
9
- * (`unreachable`) once the counter goes negative. Code between two charge
10
- * points is straight-line apart from forward branches, so each charge is an
11
- * upper bound on what it pays for, and the budget bounds the instructions the
12
- * rule actually executes. Structural instructions (`block`, `loop`, `end`,
13
- * `else`, `nop`, `drop`, `return`, `unreachable`) cost nothing, roughly as
14
- * Wasmtime prices them.
15
- *
16
- * The global is exported as `FUEL_EXPORT` so the worker can tell a trap caused
17
- * by the budget from any other trap. Each evaluation instantiates the module
18
- * afresh, so the budget is per evaluation, like a Wasmtime `Store`.
19
- *
20
- * The decoder knows the MVP instruction set plus the extensions compilers
21
- * emit by default (sign extension, saturating truncation, bulk memory,
22
- * reference types, multi-value, tail calls, SIMD). A module using anything
23
- * else (exceptions, GC, threads) is refused at load rather than run unmetered.
24
- */
25
- /** `runner.rs`: `store.set_fuel(1_000_000)`. */
26
- export declare const DEFAULT_FUEL_BUDGET = 1000000;
27
- /** The export the worker reads to tell budget exhaustion from other traps. */
28
- export declare const FUEL_EXPORT = "__intutic_fuel";
29
- /**
30
- * The module with every function metered against `budget` instructions per
31
- * instantiation, and the counter exported as `FUEL_EXPORT`. Throws for a
32
- * module the decoder cannot meter.
33
- */
34
- export declare function meterFuel(bytes: Uint8Array<ArrayBuffer>, budget: number): Uint8Array<ArrayBuffer>;
35
- //# sourceMappingURL=fuel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fuel.d.ts","sourceRoot":"","sources":["../../src/wasm/fuel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAeH,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,UAAY,CAAA;AAE5C,8EAA8E;AAC9E,eAAO,MAAM,WAAW,mBAAmB,CAAA;AAoM3C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CA+BjG"}