@enclave-vm/core 2.13.0 → 2.14.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.
@@ -0,0 +1,59 @@
1
+ import type * as ESTree from 'estree';
2
+ /** Thrown when the instruction budget is exceeded (interrupts infinite loops). */
3
+ export declare class StepLimitError extends Error {
4
+ constructor(limit: number);
5
+ }
6
+ /** Thrown on any disallowed operation (blocked key, unknown identifier, bad call). */
7
+ export declare class InterpreterError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ export interface InterpreterOptions {
11
+ /** Identifiers + values available to the script (e.g. Math, JSON, __safe_callTool). */
12
+ globals: Record<string, unknown>;
13
+ /** Max evaluated nodes before aborting (interrupts infinite loops). */
14
+ maxSteps: number;
15
+ /** Max nested call depth (interpreter-defined functions). */
16
+ maxCallDepth: number;
17
+ /** Optional cancellation. */
18
+ signal?: AbortSignal;
19
+ }
20
+ /**
21
+ * Evaluate a parsed AgentScript program. Returns the resolved value of the
22
+ * `__ag_main()` invocation (or the program's last value if no main wrapper).
23
+ */
24
+ export declare class Interpreter {
25
+ private readonly options;
26
+ private steps;
27
+ private callDepth;
28
+ private readonly globals;
29
+ constructor(options: InterpreterOptions);
30
+ /** Number of AST nodes evaluated so far (for execution stats). */
31
+ get stepCount(): number;
32
+ run(program: ESTree.Program): Promise<unknown>;
33
+ private tick;
34
+ private execStatement;
35
+ private execBlock;
36
+ private execForOf;
37
+ private execFor;
38
+ private execWhile;
39
+ private evalExpr;
40
+ private evalTemplate;
41
+ private evalBinary;
42
+ /** Resolve a member access to `{ object, key, value }`, blocking escape keys. */
43
+ private evalMember;
44
+ private evalCall;
45
+ /**
46
+ * Async implementations of the higher-order array methods, so interpreter
47
+ * callbacks (which are async — they may `await` tool calls) are awaited. Each
48
+ * iteration ticks the step budget.
49
+ */
50
+ private callArrayMethod;
51
+ private evalAssignment;
52
+ /** Assign to an Identifier or MemberExpression target (blocking escape keys). */
53
+ private assignTo;
54
+ private bindPattern;
55
+ /** Build an interpreter-backed function (declaration / arrow / expression). */
56
+ private makeFunction;
57
+ private propKey;
58
+ private readGlobal;
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enclave-vm/core",
3
- "version": "2.13.0",
3
+ "version": "2.14.1",
4
4
  "description": "Sandbox runtime for secure JavaScript code execution",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "homepage": "https://github.com/agentfront/enclave",
@@ -34,12 +34,19 @@
34
34
  "import": "./esm/index.mjs",
35
35
  "require": "./index.js",
36
36
  "default": "./index.js"
37
+ },
38
+ "./worker": {
39
+ "types": "./worker.d.ts",
40
+ "import": "./esm/worker.mjs",
41
+ "require": "./worker.js",
42
+ "default": "./worker.js"
37
43
  }
38
44
  },
39
45
  "dependencies": {
40
46
  "@babel/standalone": "^7.29.0",
41
- "@enclave-vm/types": "2.13.0",
42
- "@enclave-vm/ast": "2.13.0",
47
+ "@enclave-vm/ast": "2.14.1",
48
+ "@enclave-vm/types": "2.14.1",
49
+ "@types/estree": "1.0.8",
43
50
  "acorn": "8.15.0",
44
51
  "acorn-walk": "8.3.4",
45
52
  "astring": "1.9.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enclave-vm/core",
3
- "version": "2.13.0",
3
+ "version": "2.14.1",
4
4
  "description": "Sandbox runtime for secure JavaScript code execution",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "homepage": "https://github.com/agentfront/enclave",
@@ -35,12 +35,20 @@
35
35
  "import": "./dist/esm/index.mjs",
36
36
  "require": "./dist/index.js",
37
37
  "default": "./dist/index.js"
38
+ },
39
+ "./worker": {
40
+ "development": "./src/worker.ts",
41
+ "types": "./dist/worker.d.ts",
42
+ "import": "./dist/esm/worker.mjs",
43
+ "require": "./dist/worker.js",
44
+ "default": "./dist/worker.js"
38
45
  }
39
46
  },
40
47
  "dependencies": {
41
48
  "@babel/standalone": "^7.29.0",
42
- "@enclave-vm/types": "2.13.0",
43
- "@enclave-vm/ast": "2.13.0",
49
+ "@enclave-vm/ast": "2.14.1",
50
+ "@enclave-vm/types": "2.14.1",
51
+ "@types/estree": "1.0.8",
44
52
  "acorn": "8.15.0",
45
53
  "acorn-walk": "8.3.4",
46
54
  "astring": "1.9.0",
package/worker.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { InterpreterAdapter } from './adapters/interpreter-adapter';
2
+ export type { InterpreterAdapterOptions } from './adapters/interpreter-adapter';
3
+ export { Interpreter, InterpreterError, StepLimitError } from './interpreter/interpreter';
4
+ export type { InterpreterOptions } from './interpreter/interpreter';
5
+ export type { ExecutionContext, ExecutionResult, ExecutionError, ExecutionStats, ToolHandler } from './types';