@abyss-project/runtime 3.4.0 → 3.6.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 (58) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/dist/discord/discord.types.d.ts +167 -4
  4. package/dist/discord/discord.types.js +48 -1
  5. package/dist/discord/discord.types.js.map +1 -1
  6. package/dist/engine/engine-source.js +1 -1
  7. package/dist/interpreter/interpreter.js +18 -4
  8. package/dist/interpreter/interpreter.js.map +1 -1
  9. package/dist/interpreter/interpreter.types.d.ts +2 -0
  10. package/dist/interpreter/interpreter.types.js.map +1 -1
  11. package/dist/runner-protocol/execution-protocol.types.d.ts +11 -0
  12. package/dist/runner-protocol/execution-protocol.types.js +2 -1
  13. package/dist/runner-protocol/execution-protocol.types.js.map +1 -1
  14. package/jest.config.ts +11 -11
  15. package/package.json +15 -10
  16. package/scripts/build-engine.cjs +70 -70
  17. package/src/__tests__/engine-bundle.test.ts +121 -121
  18. package/src/__tests__/surface.test.ts +5 -1
  19. package/src/access/__tests__/host-match.test.ts +24 -24
  20. package/src/access/access.types.ts +25 -25
  21. package/src/access/host-match.ts +13 -13
  22. package/src/cost/__tests__/execution-cost.test.ts +196 -196
  23. package/src/cost/execution-cost.ts +186 -186
  24. package/src/definition/__tests__/validate-definition.test.ts +354 -354
  25. package/src/definition/definition.limits.ts +9 -9
  26. package/src/definition/definition.schema.ts +172 -172
  27. package/src/definition/definition.types.ts +171 -171
  28. package/src/definition/validate-definition.ts +206 -206
  29. package/src/definition/walk-steps.ts +44 -44
  30. package/src/discord/discord.types.ts +264 -5
  31. package/src/engine/__tests__/run-in-isolate.test.ts +468 -468
  32. package/src/engine/engine-entry.ts +3 -3
  33. package/src/engine/engine-global.ts +2 -2
  34. package/src/engine/run-in-isolate.ts +404 -404
  35. package/src/errors/runtime-error-code.enum.ts +37 -37
  36. package/src/index.ts +32 -32
  37. package/src/interpreter/__tests__/interpreter.test.ts +854 -854
  38. package/src/interpreter/__tests__/log-respond-resume.test.ts +270 -223
  39. package/src/interpreter/interpreter-error.ts +12 -12
  40. package/src/interpreter/interpreter.ts +482 -461
  41. package/src/interpreter/interpreter.types.ts +202 -192
  42. package/src/interpreter/sequence-path.ts +67 -67
  43. package/src/interpreter/test-host.ts +85 -85
  44. package/src/runner-protocol/evaluation.types.ts +21 -21
  45. package/src/runner-protocol/execution-protocol.types.ts +254 -231
  46. package/src/schedule/schedule.types.ts +100 -100
  47. package/src/server/__tests__/code-runner-session.test.ts +311 -311
  48. package/src/server/code-runner-error.ts +12 -12
  49. package/src/server/code-runner-session.ts +310 -310
  50. package/src/server/index.ts +11 -11
  51. package/src/steps/__tests__/global-references.test.ts +133 -133
  52. package/src/steps/execute-step.ts +186 -186
  53. package/src/steps/global-references.ts +48 -48
  54. package/src/steps/step-access.ts +56 -56
  55. package/src/steps/step-fields.ts +87 -87
  56. package/src/steps/value-source.ts +69 -69
  57. package/tsconfig.check.json +15 -15
  58. package/tsconfig.json +35 -35
@@ -1,223 +1,270 @@
1
- import { CURRENT_FORMAT_VERSION, LogLevel, StepType } from '../../definition/definition.types';
2
- import type { RuntimeDefinition, Step } from '../../definition/definition.types';
3
- import { RuntimeErrorCode } from '../../errors/runtime-error-code.enum';
4
- import { EvaluationKind } from '../../runner-protocol/evaluation.types';
5
- import { InterpreterError } from '../interpreter-error';
6
- import { start, step } from '../interpreter';
7
- import { CURRENT_STATE_VERSION, EffectType, RunEventType, RunStatus } from '../interpreter.types';
8
- import type { RunOptions, RunState } from '../interpreter.types';
9
- import { runToCompletion } from '../test-host';
10
-
11
- const options = (overrides: Partial<RunOptions['budget']> = {}): RunOptions => ({
12
- catalog: new Map(),
13
- grants: [],
14
- budget: { maxSteps: 100, maxEffects: 100, maxWaitMs: 1_000_000, ...overrides },
15
- });
16
-
17
- const definitionOf = (steps: Step[]): RuntimeDefinition => ({
18
- formatVersion: CURRENT_FORMAT_VERSION,
19
- accesses: [],
20
- steps,
21
- });
22
-
23
- const thrownBy = (fn: () => unknown): unknown => {
24
- try {
25
- fn();
26
- } catch (error) {
27
- return error;
28
- }
29
- throw new Error('expected a throw');
30
- };
31
-
32
- describe('LOG step', () => {
33
- const log: Step = {
34
- id: 'log',
35
- type: StepType.LOG,
36
- level: LogLevel.WARN,
37
- message: 'order {{ input.id }}',
38
- data: { total: { $expression: 'input.total' }, fixed: 1 },
39
- };
40
-
41
- it('evaluates its message and data, then emits a LOG effect', () => {
42
- const definition = definitionOf([log]);
43
- const first = start(definition, { id: 7, total: 12 }, options());
44
- expect(first.effects).toEqual([
45
- expect.objectContaining({
46
- type: EffectType.EVALUATE,
47
- items: [
48
- { id: 'message', kind: EvaluationKind.TEMPLATE, source: 'order {{ input.id }}' },
49
- { id: 'data.total', kind: EvaluationKind.EXPRESSION, source: 'input.total' },
50
- ],
51
- }),
52
- ]);
53
- const second = step(
54
- definition,
55
- first.state,
56
- {
57
- type: RunEventType.EVALUATED,
58
- results: [
59
- { id: 'message', ok: true, value: 'order 7' },
60
- { id: 'data.total', ok: true, value: 12 },
61
- ],
62
- },
63
- options(),
64
- );
65
- expect(second.effects).toEqual([
66
- {
67
- type: EffectType.LOG,
68
- stepId: 'log',
69
- level: LogLevel.WARN,
70
- message: 'order 7',
71
- data: { total: 12, fixed: 1 },
72
- },
73
- ]);
74
- const done = step(definition, second.state, { type: RunEventType.LOG_WRITTEN }, options());
75
- expect(done.status).toBe(RunStatus.SUCCEEDED);
76
- expect(done.state.outputs.log).toEqual({ output: null });
77
- });
78
-
79
- it('writes a non-string message as its JSON and omits absent data', () => {
80
- const definition = definitionOf([
81
- { id: 'log', type: StepType.LOG, level: LogLevel.INFO, message: { $expression: 'input' } },
82
- ]);
83
- const first = start(definition, null, options());
84
- const second = step(
85
- definition,
86
- first.state,
87
- { type: RunEventType.EVALUATED, results: [{ id: 'message', ok: true, value: { a: 1 } }] },
88
- options(),
89
- );
90
- expect(second.effects).toEqual([
91
- { type: EffectType.LOG, stepId: 'log', level: LogLevel.INFO, message: '{"a":1}' },
92
- ]);
93
- });
94
-
95
- it('counts against the effect budget', () => {
96
- const definition = definitionOf([
97
- { id: 'a', type: StepType.LOG, level: LogLevel.INFO, message: 'a' },
98
- { id: 'b', type: StepType.LOG, level: LogLevel.INFO, message: 'b' },
99
- ]);
100
- const first = start(definition, null, options({ maxEffects: 1 }));
101
- const second = step(
102
- definition,
103
- first.state,
104
- { type: RunEventType.LOG_WRITTEN },
105
- options({ maxEffects: 1 }),
106
- );
107
- expect(second.status).toBe(RunStatus.FAILED);
108
- expect(second.state.outcome?.error).toEqual(
109
- expect.objectContaining({ code: RuntimeErrorCode.BUDGET_EXCEEDED, stepId: 'b' }),
110
- );
111
- });
112
- });
113
-
114
- describe('RESPOND step', () => {
115
- it('emits the response with string headers, and the run goes on after it', async () => {
116
- const definition = definitionOf([
117
- {
118
- id: 'reply',
119
- type: StepType.RESPOND,
120
- status: 201,
121
- headers: { 'X-Count': 3, 'Content-Type': 'application/json' },
122
- body: { ok: true },
123
- },
124
- { id: 'after', type: StepType.SET, variable: 'x', value: 1 },
125
- ]);
126
- const responses: unknown[] = [];
127
- const { state, effects } = await runToCompletion(definition, null, options(), {
128
- evaluate: () => [],
129
- respond: (effect) => {
130
- responses.push(effect.response);
131
- },
132
- });
133
- expect(effects.map((effect) => effect.type)).toEqual([EffectType.RESPOND]);
134
- expect(responses).toEqual([
135
- {
136
- status: 201,
137
- headers: { 'X-Count': '3', 'Content-Type': 'application/json' },
138
- body: { ok: true },
139
- },
140
- ]);
141
- expect(state.status).toBe(RunStatus.SUCCEEDED);
142
- expect(state.outputs.reply).toEqual({ output: null });
143
- expect(state.vars.x).toBe(1);
144
- });
145
-
146
- it('fails the step when the status does not resolve to an HTTP status', () => {
147
- const definition = definitionOf([
148
- { id: 'reply', type: StepType.RESPOND, status: { $expression: 'input.status' } },
149
- ]);
150
- const first = start(definition, null, options());
151
- const second = step(
152
- definition,
153
- first.state,
154
- { type: RunEventType.EVALUATED, results: [{ id: 'status', ok: true, value: 700 }] },
155
- options(),
156
- );
157
- expect(second.status).toBe(RunStatus.FAILED);
158
- expect(second.state.outcome?.error).toEqual(
159
- expect.objectContaining({ code: RuntimeErrorCode.EXPRESSION_ERROR, stepId: 'reply' }),
160
- );
161
- });
162
-
163
- it('refuses a RESPONSE_SENT event for another pending effect', () => {
164
- const definition = definitionOf([{ id: 'w', type: StepType.WAIT, durationMs: 10 }]);
165
- const first = start(definition, null, options());
166
- const error = thrownBy(() =>
167
- step(definition, first.state, { type: RunEventType.RESPONSE_SENT }, options()),
168
- );
169
- expect(error).toBeInstanceOf(InterpreterError);
170
- });
171
- });
172
-
173
- describe('resume and state version', () => {
174
- const definition = definitionOf([
175
- { id: 'approve', type: StepType.WAIT, durationMs: 500 },
176
- {
177
- id: 'after',
178
- type: StepType.SET,
179
- variable: 'v',
180
- value: { $expression: 'steps.approve.output' },
181
- },
182
- ]);
183
-
184
- it('stamps every new state with the current state version', () => {
185
- expect(CURRENT_STATE_VERSION).toBe(1);
186
- expect(start(definition, null, options()).state.stateVersion).toBe(CURRENT_STATE_VERSION);
187
- });
188
-
189
- it('gives a RESUMED output to the step that suspended', () => {
190
- const first = start(definition, null, options());
191
- const persisted = JSON.parse(JSON.stringify(first.state)) as RunState;
192
- const resumed = step(
193
- definition,
194
- persisted,
195
- { type: RunEventType.RESUMED, output: { approved: true } },
196
- options(),
197
- );
198
- expect(resumed.state.outputs.approve).toEqual({ output: { approved: true } });
199
- expect(resumed.effects).toEqual([
200
- expect.objectContaining({ type: EffectType.EVALUATE, stepId: 'after' }),
201
- ]);
202
- });
203
-
204
- it('refuses RESUMED while an evaluation is pending', () => {
205
- const evaluating = definitionOf([{ id: 'c', type: StepType.CODE, source: 'return 1;' }]);
206
- const first = start(evaluating, null, options());
207
- const error = thrownBy(() =>
208
- step(evaluating, first.state, { type: RunEventType.RESUMED, output: 1 }, options()),
209
- );
210
- expect(error).toBeInstanceOf(InterpreterError);
211
- expect((error as InterpreterError).code).toBe(RuntimeErrorCode.INVALID_REQUEST);
212
- });
213
-
214
- it('refuses a state of an unknown version', () => {
215
- const first = start(definition, null, options());
216
- const future = { ...first.state, stateVersion: CURRENT_STATE_VERSION + 1 };
217
- const error = thrownBy(() =>
218
- step(definition, future, { type: RunEventType.WAIT_ELAPSED }, options()),
219
- );
220
- expect(error).toBeInstanceOf(InterpreterError);
221
- expect((error as InterpreterError).code).toBe(RuntimeErrorCode.STATE_VERSION_UNSUPPORTED);
222
- });
223
- });
1
+ import { CURRENT_FORMAT_VERSION, LogLevel, StepType } from '../../definition/definition.types';
2
+ import type { RuntimeDefinition, Step } from '../../definition/definition.types';
3
+ import { RuntimeErrorCode } from '../../errors/runtime-error-code.enum';
4
+ import { EvaluationKind } from '../../runner-protocol/evaluation.types';
5
+ import { InterpreterError } from '../interpreter-error';
6
+ import { start, step } from '../interpreter';
7
+ import { CURRENT_STATE_VERSION, EffectType, RunEventType, RunStatus } from '../interpreter.types';
8
+ import type { RunOptions, RunState } from '../interpreter.types';
9
+ import { runToCompletion } from '../test-host';
10
+
11
+ const options = (overrides: Partial<RunOptions['budget']> = {}): RunOptions => ({
12
+ catalog: new Map(),
13
+ grants: [],
14
+ budget: { maxSteps: 100, maxEffects: 100, maxWaitMs: 1_000_000, ...overrides },
15
+ });
16
+
17
+ const definitionOf = (steps: Step[]): RuntimeDefinition => ({
18
+ formatVersion: CURRENT_FORMAT_VERSION,
19
+ accesses: [],
20
+ steps,
21
+ });
22
+
23
+ const thrownBy = (fn: () => unknown): unknown => {
24
+ try {
25
+ fn();
26
+ } catch (error) {
27
+ return error;
28
+ }
29
+ throw new Error('expected a throw');
30
+ };
31
+
32
+ describe('LOG step', () => {
33
+ const log: Step = {
34
+ id: 'log',
35
+ type: StepType.LOG,
36
+ level: LogLevel.WARN,
37
+ message: 'order {{ input.id }}',
38
+ data: { total: { $expression: 'input.total' }, fixed: 1 },
39
+ };
40
+
41
+ it('evaluates its message and data, then emits a LOG effect', () => {
42
+ const definition = definitionOf([log]);
43
+ const first = start(definition, { id: 7, total: 12 }, options());
44
+ expect(first.effects).toEqual([
45
+ expect.objectContaining({
46
+ type: EffectType.EVALUATE,
47
+ items: [
48
+ { id: 'message', kind: EvaluationKind.TEMPLATE, source: 'order {{ input.id }}' },
49
+ { id: 'data.total', kind: EvaluationKind.EXPRESSION, source: 'input.total' },
50
+ ],
51
+ }),
52
+ ]);
53
+ const second = step(
54
+ definition,
55
+ first.state,
56
+ {
57
+ type: RunEventType.EVALUATED,
58
+ results: [
59
+ { id: 'message', ok: true, value: 'order 7' },
60
+ { id: 'data.total', ok: true, value: 12 },
61
+ ],
62
+ },
63
+ options(),
64
+ );
65
+ expect(second.effects).toEqual([
66
+ {
67
+ type: EffectType.LOG,
68
+ stepId: 'log',
69
+ level: LogLevel.WARN,
70
+ message: 'order 7',
71
+ data: { total: 12, fixed: 1 },
72
+ },
73
+ ]);
74
+ const done = step(definition, second.state, { type: RunEventType.LOG_WRITTEN }, options());
75
+ expect(done.status).toBe(RunStatus.SUCCEEDED);
76
+ expect(done.state.outputs.log).toEqual({ output: null });
77
+ });
78
+
79
+ it('writes a non-string message as its JSON and omits absent data', () => {
80
+ const definition = definitionOf([
81
+ { id: 'log', type: StepType.LOG, level: LogLevel.INFO, message: { $expression: 'input' } },
82
+ ]);
83
+ const first = start(definition, null, options());
84
+ const second = step(
85
+ definition,
86
+ first.state,
87
+ { type: RunEventType.EVALUATED, results: [{ id: 'message', ok: true, value: { a: 1 } }] },
88
+ options(),
89
+ );
90
+ expect(second.effects).toEqual([
91
+ { type: EffectType.LOG, stepId: 'log', level: LogLevel.INFO, message: '{"a":1}' },
92
+ ]);
93
+ });
94
+
95
+ it('counts against the effect budget', () => {
96
+ const definition = definitionOf([
97
+ { id: 'a', type: StepType.LOG, level: LogLevel.INFO, message: 'a' },
98
+ { id: 'b', type: StepType.LOG, level: LogLevel.INFO, message: 'b' },
99
+ ]);
100
+ const first = start(definition, null, options({ maxEffects: 1 }));
101
+ const second = step(
102
+ definition,
103
+ first.state,
104
+ { type: RunEventType.LOG_WRITTEN },
105
+ options({ maxEffects: 1 }),
106
+ );
107
+ expect(second.status).toBe(RunStatus.FAILED);
108
+ expect(second.state.outcome?.error).toEqual(
109
+ expect.objectContaining({ code: RuntimeErrorCode.BUDGET_EXCEEDED, stepId: 'b' }),
110
+ );
111
+ });
112
+
113
+ const threeLogs = definitionOf(
114
+ ['a', 'b', 'c'].map((id) => ({
115
+ id,
116
+ type: StepType.LOG as const,
117
+ level: LogLevel.INFO,
118
+ message: id,
119
+ })),
120
+ );
121
+
122
+ it('keeps LOG out of maxEffects when maxLogLines is given, and counts them apart', () => {
123
+ const budget = { maxEffects: 0, maxLogLines: 5 };
124
+ const first = start(threeLogs, null, options(budget));
125
+ expect(first.status).toBe(RunStatus.WAITING);
126
+ const second = step(
127
+ threeLogs,
128
+ first.state,
129
+ { type: RunEventType.LOG_WRITTEN },
130
+ options(budget),
131
+ );
132
+ const third = step(
133
+ threeLogs,
134
+ second.state,
135
+ { type: RunEventType.LOG_WRITTEN },
136
+ options(budget),
137
+ );
138
+ const done = step(threeLogs, third.state, { type: RunEventType.LOG_WRITTEN }, options(budget));
139
+ expect(done.status).toBe(RunStatus.SUCCEEDED);
140
+ expect(done.state.counters).toEqual({ steps: 3, effects: 0, logLines: 3 });
141
+ });
142
+
143
+ it('answers a LOG past maxLogLines without emitting it', () => {
144
+ const budget = { maxLogLines: 1 };
145
+ const first = start(threeLogs, null, options(budget));
146
+ expect(first.effects).toEqual([expect.objectContaining({ type: EffectType.LOG, stepId: 'a' })]);
147
+ const second = step(
148
+ threeLogs,
149
+ first.state,
150
+ { type: RunEventType.LOG_WRITTEN },
151
+ options(budget),
152
+ );
153
+ expect(second.status).toBe(RunStatus.SUCCEEDED);
154
+ expect(second.effects).toEqual([]);
155
+ expect(second.state.outputs.b).toEqual({ output: null });
156
+ expect(second.state.outputs.c).toEqual({ output: null });
157
+ expect(second.state.counters.logLines).toBe(1);
158
+ });
159
+ });
160
+
161
+ describe('RESPOND step', () => {
162
+ it('emits the response with string headers, and the run goes on after it', async () => {
163
+ const definition = definitionOf([
164
+ {
165
+ id: 'reply',
166
+ type: StepType.RESPOND,
167
+ status: 201,
168
+ headers: { 'X-Count': 3, 'Content-Type': 'application/json' },
169
+ body: { ok: true },
170
+ },
171
+ { id: 'after', type: StepType.SET, variable: 'x', value: 1 },
172
+ ]);
173
+ const responses: unknown[] = [];
174
+ const { state, effects } = await runToCompletion(definition, null, options(), {
175
+ evaluate: () => [],
176
+ respond: (effect) => {
177
+ responses.push(effect.response);
178
+ },
179
+ });
180
+ expect(effects.map((effect) => effect.type)).toEqual([EffectType.RESPOND]);
181
+ expect(responses).toEqual([
182
+ {
183
+ status: 201,
184
+ headers: { 'X-Count': '3', 'Content-Type': 'application/json' },
185
+ body: { ok: true },
186
+ },
187
+ ]);
188
+ expect(state.status).toBe(RunStatus.SUCCEEDED);
189
+ expect(state.outputs.reply).toEqual({ output: null });
190
+ expect(state.vars.x).toBe(1);
191
+ });
192
+
193
+ it('fails the step when the status does not resolve to an HTTP status', () => {
194
+ const definition = definitionOf([
195
+ { id: 'reply', type: StepType.RESPOND, status: { $expression: 'input.status' } },
196
+ ]);
197
+ const first = start(definition, null, options());
198
+ const second = step(
199
+ definition,
200
+ first.state,
201
+ { type: RunEventType.EVALUATED, results: [{ id: 'status', ok: true, value: 700 }] },
202
+ options(),
203
+ );
204
+ expect(second.status).toBe(RunStatus.FAILED);
205
+ expect(second.state.outcome?.error).toEqual(
206
+ expect.objectContaining({ code: RuntimeErrorCode.EXPRESSION_ERROR, stepId: 'reply' }),
207
+ );
208
+ });
209
+
210
+ it('refuses a RESPONSE_SENT event for another pending effect', () => {
211
+ const definition = definitionOf([{ id: 'w', type: StepType.WAIT, durationMs: 10 }]);
212
+ const first = start(definition, null, options());
213
+ const error = thrownBy(() =>
214
+ step(definition, first.state, { type: RunEventType.RESPONSE_SENT }, options()),
215
+ );
216
+ expect(error).toBeInstanceOf(InterpreterError);
217
+ });
218
+ });
219
+
220
+ describe('resume and state version', () => {
221
+ const definition = definitionOf([
222
+ { id: 'approve', type: StepType.WAIT, durationMs: 500 },
223
+ {
224
+ id: 'after',
225
+ type: StepType.SET,
226
+ variable: 'v',
227
+ value: { $expression: 'steps.approve.output' },
228
+ },
229
+ ]);
230
+
231
+ it('stamps every new state with the current state version', () => {
232
+ expect(CURRENT_STATE_VERSION).toBe(1);
233
+ expect(start(definition, null, options()).state.stateVersion).toBe(CURRENT_STATE_VERSION);
234
+ });
235
+
236
+ it('gives a RESUMED output to the step that suspended', () => {
237
+ const first = start(definition, null, options());
238
+ const persisted = JSON.parse(JSON.stringify(first.state)) as RunState;
239
+ const resumed = step(
240
+ definition,
241
+ persisted,
242
+ { type: RunEventType.RESUMED, output: { approved: true } },
243
+ options(),
244
+ );
245
+ expect(resumed.state.outputs.approve).toEqual({ output: { approved: true } });
246
+ expect(resumed.effects).toEqual([
247
+ expect.objectContaining({ type: EffectType.EVALUATE, stepId: 'after' }),
248
+ ]);
249
+ });
250
+
251
+ it('refuses RESUMED while an evaluation is pending', () => {
252
+ const evaluating = definitionOf([{ id: 'c', type: StepType.CODE, source: 'return 1;' }]);
253
+ const first = start(evaluating, null, options());
254
+ const error = thrownBy(() =>
255
+ step(evaluating, first.state, { type: RunEventType.RESUMED, output: 1 }, options()),
256
+ );
257
+ expect(error).toBeInstanceOf(InterpreterError);
258
+ expect((error as InterpreterError).code).toBe(RuntimeErrorCode.INVALID_REQUEST);
259
+ });
260
+
261
+ it('refuses a state of an unknown version', () => {
262
+ const first = start(definition, null, options());
263
+ const future = { ...first.state, stateVersion: CURRENT_STATE_VERSION + 1 };
264
+ const error = thrownBy(() =>
265
+ step(definition, future, { type: RunEventType.WAIT_ELAPSED }, options()),
266
+ );
267
+ expect(error).toBeInstanceOf(InterpreterError);
268
+ expect((error as InterpreterError).code).toBe(RuntimeErrorCode.STATE_VERSION_UNSUPPORTED);
269
+ });
270
+ });
@@ -1,12 +1,12 @@
1
- import { RuntimeErrorCode } from '../errors/runtime-error-code.enum';
2
-
3
- /** Thrown for a misuse of the interpreter (unexpected event, corrupted state), never for a run failure. */
4
- export class InterpreterError extends Error {
5
- readonly code: RuntimeErrorCode;
6
-
7
- constructor(code: RuntimeErrorCode, message: string) {
8
- super(message);
9
- this.name = 'InterpreterError';
10
- this.code = code;
11
- }
12
- }
1
+ import { RuntimeErrorCode } from '../errors/runtime-error-code.enum';
2
+
3
+ /** Thrown for a misuse of the interpreter (unexpected event, corrupted state), never for a run failure. */
4
+ export class InterpreterError extends Error {
5
+ readonly code: RuntimeErrorCode;
6
+
7
+ constructor(code: RuntimeErrorCode, message: string) {
8
+ super(message);
9
+ this.name = 'InterpreterError';
10
+ this.code = code;
11
+ }
12
+ }