@kya-os/checkpoint-wasm-runtime 1.3.0 → 1.4.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 (50) hide show
  1. package/CHANGELOG.md +110 -1
  2. package/dist/adapters.d.mts +1 -1
  3. package/dist/adapters.d.ts +1 -1
  4. package/dist/engine-edge.d.mts +2 -2
  5. package/dist/engine-edge.d.ts +2 -2
  6. package/dist/engine-edge.js +3 -509
  7. package/dist/engine-edge.mjs +3 -508
  8. package/dist/engine-node.d.mts +46 -0
  9. package/dist/engine-node.d.ts +46 -0
  10. package/dist/engine-node.js +31 -0
  11. package/dist/engine-node.mjs +10 -0
  12. package/dist/engine.d.mts +25 -4
  13. package/dist/engine.d.ts +25 -4
  14. package/dist/engine.js +2 -457
  15. package/dist/engine.mjs +2 -464
  16. package/dist/index.d.mts +531 -3
  17. package/dist/index.d.ts +531 -3
  18. package/dist/index.js +2 -28
  19. package/dist/index.mjs +2 -29
  20. package/dist/node.d.mts +524 -3
  21. package/dist/node.d.ts +524 -3
  22. package/dist/node.js +2 -26
  23. package/dist/node.mjs +2 -26
  24. package/dist/orchestrator-edge.d.mts +24 -10
  25. package/dist/orchestrator-edge.d.ts +24 -10
  26. package/dist/orchestrator-edge.js +5 -510
  27. package/dist/orchestrator-edge.mjs +5 -509
  28. package/dist/orchestrator-node.d.mts +60 -52
  29. package/dist/orchestrator-node.d.ts +60 -52
  30. package/dist/orchestrator-node.js +50 -487
  31. package/dist/orchestrator-node.mjs +34 -497
  32. package/dist/orchestrator.d.mts +356 -4
  33. package/dist/orchestrator.d.ts +356 -4
  34. package/dist/orchestrator.js +37 -1001
  35. package/dist/orchestrator.mjs +37 -1005
  36. package/dist/{types-ByrdPLL2.d.ts → types-KPEcVvac.d.mts} +31 -1
  37. package/dist/{types-ByrdPLL2.d.mts → types-KPEcVvac.d.ts} +31 -1
  38. package/package.json +13 -2
  39. package/wasm/kya-os-engine/kya_os_engine_bg.wasm +0 -0
  40. package/wasm/kya-os-engine/package.json +24 -4
  41. package/wasm/kya-os-engine-bundler/kya_os_engine.d.ts +24 -0
  42. package/wasm/kya-os-engine-bundler/kya_os_engine.js +4 -0
  43. package/wasm/kya-os-engine-bundler/kya_os_engine_bg.js +522 -0
  44. package/wasm/kya-os-engine-bundler/kya_os_engine_bg.wasm +0 -0
  45. package/wasm/kya-os-engine-bundler/kya_os_engine_bg.wasm.d.ts +8 -0
  46. package/wasm/kya-os-engine-web/kya_os_engine_bg.wasm +0 -0
  47. package/wasm/kya-os-engine-web/package.json +25 -3
  48. package/dist/kya_os_engine_bg.wasm +0 -0
  49. package/dist/rules-detector-ZIKHN-_y.d.mts +0 -532
  50. package/dist/rules-detector-ZIKHN-_y.d.ts +0 -532
package/dist/index.d.ts CHANGED
@@ -1,5 +1,319 @@
1
- import { h as IWasmLoader, l as IWasmBindings, a as IDetectorOptions, I as IDetector } from './rules-detector-ZIKHN-_y.js';
2
- export { C as CONFIDENCE, D as DetectionClass, c as DynamicWasmLoader, F as ForgeabilityRisk, d as ICustomerPolicy, e as IDetectedAgent, b as IDetectionInput, f as IDetectionResult, m as IPathRule, g as IPolicyLoader, n as PolicyLoadError, P as PolicyLoader, o as PolicyLoaderConfig, R as RulesDetector, V as VerificationMethod, W as WasmDetector, i as createDynamicLoader, j as createPolicyLoader, k as createRulesDetector } from './rules-detector-ZIKHN-_y.js';
1
+ /**
2
+ * AgentShield WASM Runtime Types
3
+ *
4
+ * Core interfaces following SOLID principles:
5
+ * - Interface Segregation: Small, focused interfaces
6
+ * - Dependency Inversion: Depend on abstractions
7
+ */
8
+ /**
9
+ * Detection input - information about the request to analyze
10
+ */
11
+ interface IDetectionInput {
12
+ /** User-Agent header value */
13
+ userAgent?: string;
14
+ /** Client IP address */
15
+ ipAddress?: string;
16
+ /** All request headers */
17
+ headers: Record<string, string>;
18
+ /** Request URL path */
19
+ url?: string;
20
+ /** HTTP method (GET, POST, etc.) */
21
+ method?: string;
22
+ /** Client fingerprint data (for browser detection) */
23
+ clientFingerprint?: string;
24
+ /** Request timestamp */
25
+ timestamp?: Date;
26
+ }
27
+ /**
28
+ * Verification method used to detect the agent
29
+ */
30
+ type VerificationMethod = 'signature' | 'pattern' | 'behavioral' | 'network' | 'mcp_i_handshake' | 'none';
31
+ /**
32
+ * Detection class - categorization of the detected entity
33
+ */
34
+ type DetectionClass = {
35
+ type: 'Human';
36
+ } | {
37
+ type: 'AiAgent';
38
+ agentType: string;
39
+ } | {
40
+ type: 'Bot';
41
+ botType?: string;
42
+ } | {
43
+ type: 'Automation';
44
+ toolType?: string;
45
+ } | {
46
+ type: 'Unknown';
47
+ };
48
+ /**
49
+ * Forgeability risk level
50
+ * How easy it is to spoof the detection signals
51
+ */
52
+ type ForgeabilityRisk = 'low' | 'medium' | 'high';
53
+ /**
54
+ * Detected agent information
55
+ */
56
+ interface IDetectedAgent {
57
+ /** Agent type identifier (e.g., 'openai', 'anthropic') */
58
+ type: string;
59
+ /** Human-readable agent name (e.g., 'ChatGPT', 'Claude') */
60
+ name: string;
61
+ /** Vendor/company name */
62
+ vendor?: string;
63
+ /** Model identifier if known */
64
+ model?: string;
65
+ /** Version if known */
66
+ version?: string;
67
+ }
68
+ /**
69
+ * Detection result - output from the detection engine
70
+ * Confidence is ALWAYS on 0-100 scale
71
+ */
72
+ interface IDetectionResult {
73
+ /** Whether the request was identified as coming from an agent */
74
+ isAgent: boolean;
75
+ /** Confidence score on 0-100 scale (NOT 0-1) */
76
+ confidence: number;
77
+ /** Detection classification */
78
+ detectionClass: DetectionClass;
79
+ /** Detected agent details if identified */
80
+ detectedAgent?: IDetectedAgent;
81
+ /** Method used for verification */
82
+ verificationMethod: VerificationMethod;
83
+ /** Risk level of signal forgeability */
84
+ forgeabilityRisk: ForgeabilityRisk;
85
+ /** Reasons/signals that contributed to detection */
86
+ reasons: string[];
87
+ /** Detection timestamp */
88
+ timestamp: Date;
89
+ /** Whether the request should be blocked (set by policy) */
90
+ shouldBlock?: boolean;
91
+ /** Reason for blocking (set by policy) */
92
+ blockReason?: string;
93
+ }
94
+ /**
95
+ * WASM bindings interface - functions exposed by the WASM module
96
+ */
97
+ interface IWasmBindings {
98
+ /** Detect an agent from request metadata */
99
+ detect_agent(metadata: IWasmRequestMetadata): IWasmDetectionResult;
100
+ /** Get WASM module version */
101
+ get_version(): string;
102
+ /** Get build information */
103
+ get_build_info(): string;
104
+ }
105
+ /**
106
+ * WASM request metadata - input to WASM detect_agent function
107
+ */
108
+ interface IWasmRequestMetadata {
109
+ user_agent: string | null;
110
+ ip_address: string | null;
111
+ headers: string;
112
+ timestamp: string;
113
+ url: string | null;
114
+ method: string | null;
115
+ client_fingerprint: string | null;
116
+ free(): void;
117
+ }
118
+ /**
119
+ * WASM detection result - output from WASM detect_agent function
120
+ */
121
+ interface IWasmDetectionResult {
122
+ is_agent: boolean;
123
+ confidence: number;
124
+ agent: string | null;
125
+ verification_method: string;
126
+ risk_level: string;
127
+ timestamp: string;
128
+ }
129
+ /**
130
+ * WASM loader interface - abstracts WASM loading strategy
131
+ */
132
+ interface IWasmLoader {
133
+ /** Load the WASM module */
134
+ load(): Promise<void>;
135
+ /** Get the WASM bindings after loading */
136
+ getBindings(): IWasmBindings;
137
+ /** Check if WASM is loaded */
138
+ isLoaded(): boolean;
139
+ /** Get the loading strategy name */
140
+ getStrategy(): string;
141
+ }
142
+ /**
143
+ * Agent detector interface - main detection API
144
+ */
145
+ interface IDetector {
146
+ /** Analyze a request and detect if it's from an agent */
147
+ detect(input: IDetectionInput): Promise<IDetectionResult>;
148
+ /** Check if the detector is ready */
149
+ isReady(): boolean;
150
+ /** Ensure the detector is initialized */
151
+ ensureReady(): Promise<void>;
152
+ /** Get detector version */
153
+ getVersion(): Promise<string>;
154
+ }
155
+ /**
156
+ * Customer policy - rules for agent handling
157
+ */
158
+ interface ICustomerPolicy {
159
+ /** Project ID */
160
+ projectId: string;
161
+ /** Agents to always block */
162
+ denyList?: string[];
163
+ /** Agents to always allow (if set, blocks all others) */
164
+ allowList?: string[];
165
+ /** Minimum confidence to trigger blocking */
166
+ blockThreshold?: number;
167
+ /** Path-based rules */
168
+ pathRules?: IPathRule[];
169
+ /** Policy version for cache invalidation */
170
+ version?: string;
171
+ /** Last updated timestamp */
172
+ updatedAt?: Date;
173
+ }
174
+ /**
175
+ * Path-based rule for policy
176
+ */
177
+ interface IPathRule {
178
+ /** Path pattern (glob or regex) */
179
+ pattern: string;
180
+ /** Action for matching paths */
181
+ action: 'allow' | 'block' | 'challenge';
182
+ /** Specific agents this rule applies to */
183
+ agents?: string[];
184
+ }
185
+ /**
186
+ * Policy loader interface - loads customer policies
187
+ */
188
+ interface IPolicyLoader {
189
+ /** Load policy for an API key */
190
+ loadPolicy(apiKey: string): Promise<ICustomerPolicy>;
191
+ /** Get cached policy if available */
192
+ getCachedPolicy(apiKey: string): ICustomerPolicy | null;
193
+ /** Invalidate cached policy */
194
+ invalidateCache(apiKey: string): void;
195
+ }
196
+ /**
197
+ * Detector configuration options
198
+ */
199
+ interface IDetectorOptions {
200
+ /** API key for loading customer policies */
201
+ apiKey?: string;
202
+ /** Custom WASM loader (for Edge Runtime static imports) */
203
+ wasmLoader?: IWasmLoader;
204
+ /** Whether to fall back to JavaScript if WASM fails */
205
+ fallbackToJS?: boolean;
206
+ /** Whether to cache policies */
207
+ cachePolicy?: boolean;
208
+ /** Policy cache TTL in milliseconds */
209
+ policyTTL?: number;
210
+ /** Base URL for policy API */
211
+ policyApiUrl?: string;
212
+ /** Enable debug logging */
213
+ debug?: boolean;
214
+ }
215
+ /**
216
+ * Confidence thresholds - centralized constants
217
+ */
218
+ declare const CONFIDENCE: {
219
+ /** Minimum confidence for isAgent=true */
220
+ readonly THRESHOLD_AGENT: 30;
221
+ /** Cryptographic signature verified */
222
+ readonly SIGNATURE_VERIFIED: 100;
223
+ /** Signature header present but not verified */
224
+ readonly SIGNATURE_PRESENT: 85;
225
+ /** Strong pattern match */
226
+ readonly PATTERN_HIGH: 85;
227
+ /** Moderate pattern match */
228
+ readonly PATTERN_MEDIUM: 60;
229
+ /** Weak pattern match */
230
+ readonly PATTERN_LOW: 40;
231
+ /** Cloud IP detection only */
232
+ readonly CLOUD_IP: 30;
233
+ };
234
+
235
+ /**
236
+ * Unified WASM Detector
237
+ *
238
+ * Single implementation of the AgentShield detection engine used by all packages.
239
+ * Follows the Single Responsibility Principle: this class only handles detection.
240
+ *
241
+ * Key design decisions:
242
+ * - Confidence is ALWAYS on 0-100 scale (no conversions needed)
243
+ * - WASM output is used directly (no post-processing adjustments)
244
+ * - Policy application is optional and happens after detection
245
+ */
246
+
247
+ /**
248
+ * Unified WASM Detector
249
+ *
250
+ * Main detection class that wraps the WASM engine and provides
251
+ * a consistent interface across all AgentShield packages.
252
+ */
253
+ declare class WasmDetector implements IDetector {
254
+ private readonly loader;
255
+ private readonly policyLoader?;
256
+ private readonly options;
257
+ private ready;
258
+ private loadPromise;
259
+ /**
260
+ * Create a new WasmDetector
261
+ * @param loader - WASM loader (static for Edge, dynamic for Node.js)
262
+ * @param policyLoader - Optional policy loader for API key support
263
+ * @param options - Detector configuration options
264
+ */
265
+ constructor(loader: IWasmLoader, policyLoader?: IPolicyLoader | undefined, options?: IDetectorOptions);
266
+ /**
267
+ * Analyze a request and detect if it's from an agent
268
+ */
269
+ detect(input: IDetectionInput): Promise<IDetectionResult>;
270
+ /**
271
+ * Check if the detector is ready
272
+ */
273
+ isReady(): boolean;
274
+ /**
275
+ * Ensure the detector is initialized
276
+ */
277
+ ensureReady(): Promise<void>;
278
+ /**
279
+ * Get detector version
280
+ */
281
+ getVersion(): Promise<string>;
282
+ /**
283
+ * Initialize the detector
284
+ */
285
+ private initialize;
286
+ /**
287
+ * Apply customer policy to detection result
288
+ */
289
+ private applyPolicy;
290
+ /**
291
+ * Check if agent name matches a policy list entry
292
+ * Uses exact match or word-boundary prefix match to avoid false positives
293
+ * e.g., "gpt" matches "ChatGPT" and "GPT-4" but not "EgyptBot"
294
+ */
295
+ private matchesPolicyEntry;
296
+ /**
297
+ * Escape special regex characters in a string
298
+ */
299
+ private escapeRegex;
300
+ /**
301
+ * Apply policy rules to detection result
302
+ */
303
+ private applyPolicyRules;
304
+ /**
305
+ * Infer agent type from name
306
+ */
307
+ private inferAgentType;
308
+ /**
309
+ * Extract reasons from WASM result
310
+ */
311
+ private extractReasons;
312
+ /**
313
+ * Create default result (assumed human)
314
+ */
315
+ private createDefaultResult;
316
+ }
3
317
 
4
318
  /**
5
319
  * Static WASM Loader for Edge Runtime
@@ -70,6 +384,220 @@ declare class StaticWasmLoader implements IWasmLoader {
70
384
  */
71
385
  declare function createStaticLoader(wasmModule: WebAssembly.Module): StaticWasmLoader;
72
386
 
387
+ /**
388
+ * Dynamic WASM Loader for Node.js
389
+ *
390
+ * This loader dynamically loads and compiles WASM at runtime,
391
+ * which is supported in Node.js but NOT in Edge Runtime.
392
+ *
393
+ * Usage:
394
+ * ```typescript
395
+ * import { DynamicWasmLoader, WasmDetector } from '@kya-os/checkpoint-wasm-runtime/node';
396
+ *
397
+ * const loader = new DynamicWasmLoader();
398
+ * const detector = new WasmDetector(loader);
399
+ * ```
400
+ */
401
+
402
+ /**
403
+ * Dynamic WASM Loader
404
+ *
405
+ * For Node.js environments that support dynamic WASM compilation.
406
+ * Automatically finds and loads the WASM module.
407
+ */
408
+ declare class DynamicWasmLoader implements IWasmLoader {
409
+ private readonly wasmPath?;
410
+ private bindings;
411
+ private instance;
412
+ private loadPromise;
413
+ /**
414
+ * Create a new DynamicWasmLoader
415
+ * @param wasmPath - Optional custom path to WASM file
416
+ */
417
+ constructor(wasmPath?: string | undefined);
418
+ /**
419
+ * Load and compile the WASM module
420
+ */
421
+ load(): Promise<void>;
422
+ private doLoad;
423
+ /**
424
+ * Get the WASM bindings after loading
425
+ */
426
+ getBindings(): IWasmBindings;
427
+ /**
428
+ * Check if WASM is loaded
429
+ */
430
+ isLoaded(): boolean;
431
+ /**
432
+ * Get the loading strategy name
433
+ */
434
+ getStrategy(): string;
435
+ /**
436
+ * Create wasm-bindgen required imports
437
+ */
438
+ private createWasmBindgenImports;
439
+ /**
440
+ * Create bindings wrapper from WASM exports
441
+ */
442
+ private createBindings;
443
+ }
444
+ /**
445
+ * Create a dynamic loader
446
+ */
447
+ declare function createDynamicLoader(wasmPath?: string): DynamicWasmLoader;
448
+
449
+ /**
450
+ * Policy Loader
451
+ *
452
+ * Loads customer policies from the AgentShield API.
453
+ * Supports LRU caching with background refresh.
454
+ */
455
+
456
+ /**
457
+ * Policy loader configuration
458
+ */
459
+ interface PolicyLoaderConfig {
460
+ /** Base URL for the policy API */
461
+ apiUrl?: string;
462
+ /** Cache TTL in milliseconds (default: 5 minutes) */
463
+ cacheTTL?: number;
464
+ /** Maximum number of policies to cache (default: 100) */
465
+ maxCacheSize?: number;
466
+ /** Enable background refresh (default: true) */
467
+ backgroundRefresh?: boolean;
468
+ /** Timeout for API requests in milliseconds (default: 5000) */
469
+ timeout?: number;
470
+ }
471
+ /**
472
+ * Policy Loader
473
+ *
474
+ * Loads and caches customer policies from the AgentShield API.
475
+ * Follows Single Responsibility Principle: only handles policy loading.
476
+ */
477
+ declare class PolicyLoader implements IPolicyLoader {
478
+ private cache;
479
+ private config;
480
+ constructor(config?: PolicyLoaderConfig);
481
+ /**
482
+ * Load policy for an API key
483
+ */
484
+ loadPolicy(apiKey: string): Promise<ICustomerPolicy>;
485
+ /**
486
+ * Get cached policy if available and not expired
487
+ */
488
+ getCachedPolicy(apiKey: string): ICustomerPolicy | null;
489
+ /**
490
+ * Invalidate cached policy
491
+ */
492
+ invalidateCache(apiKey: string): void;
493
+ /**
494
+ * Fetch policy from API and cache it
495
+ */
496
+ private fetchPolicy;
497
+ /**
498
+ * Fetch policy from API without caching
499
+ * Used internally for both direct fetches and background refreshes
500
+ */
501
+ private fetchPolicyFromApi;
502
+ /**
503
+ * Cache a policy
504
+ */
505
+ private cachePolicy;
506
+ /**
507
+ * Check if cached entry is expired
508
+ */
509
+ private isExpired;
510
+ /**
511
+ * Check if cache entry should be refreshed
512
+ */
513
+ private shouldRefresh;
514
+ /**
515
+ * Refresh policy in background
516
+ */
517
+ private refreshInBackground;
518
+ /**
519
+ * Get default policy for a project
520
+ */
521
+ private getDefaultPolicy;
522
+ }
523
+ /**
524
+ * Policy load error
525
+ */
526
+ declare class PolicyLoadError extends Error {
527
+ readonly code: 'INVALID_API_KEY' | 'API_ERROR' | 'NETWORK_ERROR' | 'TIMEOUT';
528
+ constructor(message: string, code: 'INVALID_API_KEY' | 'API_ERROR' | 'NETWORK_ERROR' | 'TIMEOUT');
529
+ }
530
+ /**
531
+ * Create a policy loader with default configuration
532
+ */
533
+ declare function createPolicyLoader(config?: PolicyLoaderConfig): PolicyLoader;
534
+
535
+ /**
536
+ * Rules-Based Fallback Detector
537
+ *
538
+ * JavaScript fallback detector that uses merged-rules.json when WASM is unavailable.
539
+ * This provides consistent detection using the same rules as WASM, just implemented in JS.
540
+ */
541
+
542
+ /**
543
+ * Rules-Based Fallback Detector
544
+ *
545
+ * Uses the same merged-rules.json as the WASM engine to provide
546
+ * consistent detection when WASM is not available.
547
+ */
548
+ declare class RulesDetector implements IDetector {
549
+ private rules;
550
+ private ready;
551
+ /**
552
+ * Analyze a request and detect if it's from an agent
553
+ */
554
+ detect(input: IDetectionInput): Promise<IDetectionResult>;
555
+ /**
556
+ * Check if the detector is ready
557
+ */
558
+ isReady(): boolean;
559
+ /**
560
+ * Ensure the detector is initialized
561
+ */
562
+ ensureReady(): Promise<void>;
563
+ /**
564
+ * Get detector version
565
+ */
566
+ getVersion(): Promise<string>;
567
+ /**
568
+ * Normalize headers to lowercase keys
569
+ */
570
+ private normalizeHeaders;
571
+ /**
572
+ * Match user agent against rules
573
+ */
574
+ private matchUserAgent;
575
+ /**
576
+ * Match headers against suspicious header rules
577
+ */
578
+ private matchHeaders;
579
+ /**
580
+ * Check if signature headers are present
581
+ */
582
+ private hasSignatureHeaders;
583
+ /**
584
+ * Get human-readable agent name from rule key
585
+ */
586
+ private getAgentName;
587
+ /**
588
+ * Infer agent type from name
589
+ */
590
+ private inferAgentType;
591
+ /**
592
+ * Determine detection class
593
+ */
594
+ private determineDetectionClass;
595
+ }
596
+ /**
597
+ * Create a rules-based fallback detector
598
+ */
599
+ declare function createRulesDetector(): RulesDetector;
600
+
73
601
  /**
74
602
  * Create a detector with automatic runtime selection
75
603
  *
@@ -122,4 +650,4 @@ declare function createEdgeDetector(wasmModule: WebAssembly.Module, options?: ID
122
650
  */
123
651
  declare function createFallbackDetector(): IDetector;
124
652
 
125
- export { IDetector, IDetectorOptions, IWasmBindings, IWasmLoader, StaticWasmLoader, createDetector, createEdgeDetector, createFallbackDetector, createStaticLoader };
653
+ export { CONFIDENCE, type DetectionClass, DynamicWasmLoader, type ForgeabilityRisk, type ICustomerPolicy, type IDetectedAgent, type IDetectionInput, type IDetectionResult, type IDetector, type IDetectorOptions, type IPathRule, type IPolicyLoader, type IWasmBindings, type IWasmLoader, PolicyLoadError, PolicyLoader, type PolicyLoaderConfig, RulesDetector, StaticWasmLoader, type VerificationMethod, WasmDetector, createDetector, createDynamicLoader, createEdgeDetector, createFallbackDetector, createPolicyLoader, createRulesDetector, createStaticLoader };
package/dist/index.js CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  var checkpointShared = require('@kya-os/checkpoint-shared');
4
4
 
5
- // ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.15.32_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.3/node_modules/tsup/assets/cjs_shims.js
6
-
7
5
  // src/types.ts
8
6
  var CONFIDENCE = {
9
7
  /** Minimum confidence for isAgent=true */
@@ -1009,24 +1007,6 @@ async function findWasmModule() {
1009
1007
  try {
1010
1008
  const fs = await import('fs/promises');
1011
1009
  const nodePath = await import('path');
1012
- let moduleDir = null;
1013
- try {
1014
- const importMetaUrl = eval('typeof import.meta !== "undefined" && import.meta.url');
1015
- if (importMetaUrl) {
1016
- const url = await import('url');
1017
- moduleDir = nodePath.dirname(url.fileURLToPath(importMetaUrl));
1018
- }
1019
- } catch {
1020
- }
1021
- if (!moduleDir) {
1022
- try {
1023
- const cjsDirname = eval('typeof __dirname !== "undefined" && __dirname');
1024
- if (cjsDirname) {
1025
- moduleDir = cjsDirname;
1026
- }
1027
- } catch {
1028
- }
1029
- }
1030
1010
  const fsWasmPaths = [
1031
1011
  nodePath.resolve(
1032
1012
  process.cwd(),
@@ -1037,12 +1017,6 @@ async function findWasmModule() {
1037
1017
  "node_modules/@kya-os/checkpoint/dist/wasm/agentshield_wasm_bg.wasm"
1038
1018
  )
1039
1019
  ];
1040
- if (moduleDir) {
1041
- fsWasmPaths.unshift(
1042
- nodePath.resolve(moduleDir, "../wasm/agentshield_wasm_bg.wasm"),
1043
- nodePath.resolve(moduleDir, "../../wasm/agentshield_wasm_bg.wasm")
1044
- );
1045
- }
1046
1020
  for (const wasmPath of fsWasmPaths) {
1047
1021
  try {
1048
1022
  const buffer = await fs.readFile(wasmPath);
@@ -1099,8 +1073,8 @@ var DynamicWasmLoader = class {
1099
1073
  try {
1100
1074
  let wasmBuffer;
1101
1075
  if (this.wasmPath) {
1102
- const fs2 = await import('fs/promises');
1103
- const buffer = await fs2.readFile(this.wasmPath);
1076
+ const fs = await import('fs/promises');
1077
+ const buffer = await fs.readFile(this.wasmPath);
1104
1078
  wasmBuffer = new ArrayBuffer(buffer.byteLength);
1105
1079
  new Uint8Array(wasmBuffer).set(buffer);
1106
1080
  } else {
package/dist/index.mjs CHANGED
@@ -1,8 +1,5 @@
1
- import { createRequire } from 'module';
2
1
  import { RuleLoader } from '@kya-os/checkpoint-shared';
3
2
 
4
- createRequire(import.meta.url);
5
-
6
3
  // src/types.ts
7
4
  var CONFIDENCE = {
8
5
  /** Minimum confidence for isAgent=true */
@@ -1008,24 +1005,6 @@ async function findWasmModule() {
1008
1005
  try {
1009
1006
  const fs = await import('fs/promises');
1010
1007
  const nodePath = await import('path');
1011
- let moduleDir = null;
1012
- try {
1013
- const importMetaUrl = eval('typeof import.meta !== "undefined" && import.meta.url');
1014
- if (importMetaUrl) {
1015
- const url = await import('url');
1016
- moduleDir = nodePath.dirname(url.fileURLToPath(importMetaUrl));
1017
- }
1018
- } catch {
1019
- }
1020
- if (!moduleDir) {
1021
- try {
1022
- const cjsDirname = eval('typeof __dirname !== "undefined" && __dirname');
1023
- if (cjsDirname) {
1024
- moduleDir = cjsDirname;
1025
- }
1026
- } catch {
1027
- }
1028
- }
1029
1008
  const fsWasmPaths = [
1030
1009
  nodePath.resolve(
1031
1010
  process.cwd(),
@@ -1036,12 +1015,6 @@ async function findWasmModule() {
1036
1015
  "node_modules/@kya-os/checkpoint/dist/wasm/agentshield_wasm_bg.wasm"
1037
1016
  )
1038
1017
  ];
1039
- if (moduleDir) {
1040
- fsWasmPaths.unshift(
1041
- nodePath.resolve(moduleDir, "../wasm/agentshield_wasm_bg.wasm"),
1042
- nodePath.resolve(moduleDir, "../../wasm/agentshield_wasm_bg.wasm")
1043
- );
1044
- }
1045
1018
  for (const wasmPath of fsWasmPaths) {
1046
1019
  try {
1047
1020
  const buffer = await fs.readFile(wasmPath);
@@ -1098,8 +1071,8 @@ var DynamicWasmLoader = class {
1098
1071
  try {
1099
1072
  let wasmBuffer;
1100
1073
  if (this.wasmPath) {
1101
- const fs2 = await import('fs/promises');
1102
- const buffer = await fs2.readFile(this.wasmPath);
1074
+ const fs = await import('fs/promises');
1075
+ const buffer = await fs.readFile(this.wasmPath);
1103
1076
  wasmBuffer = new ArrayBuffer(buffer.byteLength);
1104
1077
  new Uint8Array(wasmBuffer).set(buffer);
1105
1078
  } else {