@nordsym/apiclaw 1.3.12 → 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 (52) hide show
  1. package/PRD-API-CHAINING.md +483 -0
  2. package/PRD-HARDEN-SHELL.md +278 -0
  3. package/README.md +72 -0
  4. package/convex/_generated/api.d.ts +4 -0
  5. package/convex/chains.ts +1095 -0
  6. package/convex/crons.ts +11 -0
  7. package/convex/logs.ts +107 -0
  8. package/convex/schema.ts +107 -0
  9. package/convex/spendAlerts.ts +442 -0
  10. package/convex/workspaces.ts +26 -0
  11. package/dist/chain-types.d.ts +187 -0
  12. package/dist/chain-types.d.ts.map +1 -0
  13. package/dist/chain-types.js +33 -0
  14. package/dist/chain-types.js.map +1 -0
  15. package/dist/chainExecutor.d.ts +122 -0
  16. package/dist/chainExecutor.d.ts.map +1 -0
  17. package/dist/chainExecutor.js +454 -0
  18. package/dist/chainExecutor.js.map +1 -0
  19. package/dist/chainResolver.d.ts +100 -0
  20. package/dist/chainResolver.d.ts.map +1 -0
  21. package/dist/chainResolver.js +519 -0
  22. package/dist/chainResolver.js.map +1 -0
  23. package/dist/chainResolver.test.d.ts +5 -0
  24. package/dist/chainResolver.test.d.ts.map +1 -0
  25. package/dist/chainResolver.test.js +201 -0
  26. package/dist/chainResolver.test.js.map +1 -0
  27. package/dist/execute.d.ts +5 -1
  28. package/dist/execute.d.ts.map +1 -1
  29. package/dist/execute.js +207 -118
  30. package/dist/execute.js.map +1 -1
  31. package/dist/index.js +382 -2
  32. package/dist/index.js.map +1 -1
  33. package/landing/package-lock.json +29 -5
  34. package/landing/package.json +2 -1
  35. package/landing/public/logos/chattgpt.svg +1 -0
  36. package/landing/public/logos/claude.svg +1 -0
  37. package/landing/public/logos/gemini.svg +1 -0
  38. package/landing/public/logos/grok.svg +1 -0
  39. package/landing/src/app/page.tsx +11 -0
  40. package/landing/src/app/security/page.tsx +381 -0
  41. package/landing/src/app/workspace/chains/page.tsx +520 -0
  42. package/landing/src/components/AITestimonials.tsx +195 -0
  43. package/landing/src/components/ChainStepDetail.tsx +310 -0
  44. package/landing/src/components/ChainTrace.tsx +261 -0
  45. package/landing/src/lib/stats.json +1 -1
  46. package/package.json +1 -1
  47. package/src/chain-types.ts +270 -0
  48. package/src/chainExecutor.ts +730 -0
  49. package/src/chainResolver.test.ts +246 -0
  50. package/src/chainResolver.ts +658 -0
  51. package/src/execute.ts +273 -114
  52. package/src/index.ts +423 -2
@@ -0,0 +1,658 @@
1
+ /**
2
+ * APIClaw Chain Resolver
3
+ *
4
+ * Handles reference resolution between chain steps.
5
+ * Supports: $prev, $stepId, $parallel, $chain, $inputs, $forEach
6
+ */
7
+
8
+ // ============================================================================
9
+ // TYPES
10
+ // ============================================================================
11
+
12
+ export interface ChainContext {
13
+ results: Record<string, any>; // stepId → result data
14
+ inputs?: Record<string, any>; // Template inputs ($inputs.x)
15
+ currentIndex: number; // Current step index
16
+ startedAt: string; // ISO timestamp
17
+ prevStepId?: string; // ID of previous step (for $prev)
18
+ parallelResults?: any[]; // Results from parallel execution ($parallel)
19
+ forEachItem?: any; // Current item in forEach loop ($item)
20
+ forEachIndex?: number; // Current index in forEach loop ($index)
21
+ forEachResults?: any[]; // Accumulated forEach results ($forEach.results)
22
+ env?: Record<string, string>; // Environment variables ($env.x)
23
+ }
24
+
25
+ export interface Reference {
26
+ raw: string; // Original reference string (e.g., "$step1.url")
27
+ type: 'prev' | 'step' | 'parallel' | 'chain' | 'inputs' | 'forEach' | 'item' | 'index' | 'env';
28
+ stepId?: string; // For step references
29
+ path: string[]; // Property path (e.g., ["output", "url"])
30
+ arrayIndex?: number; // For array access (e.g., $parallel[0])
31
+ }
32
+
33
+ export interface ValidationResult {
34
+ valid: boolean;
35
+ errors: ValidationError[];
36
+ warnings: ValidationWarning[];
37
+ }
38
+
39
+ export interface ValidationError {
40
+ stepId: string;
41
+ reference: string;
42
+ message: string;
43
+ }
44
+
45
+ export interface ValidationWarning {
46
+ stepId: string;
47
+ reference: string;
48
+ message: string;
49
+ }
50
+
51
+ // Chain definition types
52
+ export interface ChainStep {
53
+ id: string;
54
+ provider: string;
55
+ action: string;
56
+ params?: Record<string, any>;
57
+ onError?: ErrorConfig;
58
+ }
59
+
60
+ export interface ParallelStep {
61
+ parallel: ChainStep[];
62
+ }
63
+
64
+ export interface ConditionalStep {
65
+ if: string;
66
+ then: ChainStep | ChainStep[];
67
+ else?: ChainStep | ChainStep[];
68
+ }
69
+
70
+ export interface ForEachStep {
71
+ forEach: string;
72
+ as?: string;
73
+ do: ChainStep;
74
+ }
75
+
76
+ export type ChainStepUnion = ChainStep | ParallelStep | ConditionalStep | ForEachStep;
77
+
78
+ export interface ErrorConfig {
79
+ retry?: { attempts: number; backoff?: number[] };
80
+ fallback?: ChainStep;
81
+ abort?: boolean;
82
+ }
83
+
84
+ // ============================================================================
85
+ // REFERENCE PATTERNS
86
+ // ============================================================================
87
+
88
+ // Matches all $references in a string
89
+ const REFERENCE_PATTERN = /\$(?:prev|chain|inputs|parallel|forEach|item|index|env|\w+)(?:\[\d+\])?(?:\.[a-zA-Z_][\w]*(?:\[\d+\])?)*|\$\w+(?:\.[a-zA-Z_][\w]*(?:\[\d+\])?)+/g;
90
+
91
+ // Matches a single complete reference for parsing
92
+ const SINGLE_REF_PATTERN = /^\$(\w+)(\[\d+\])?(.*)$/;
93
+
94
+ // ============================================================================
95
+ // REFERENCE EXTRACTION
96
+ // ============================================================================
97
+
98
+ /**
99
+ * Extract all $references from a string
100
+ */
101
+ export function extractReferences(text: string): Reference[] {
102
+ const matches = text.match(REFERENCE_PATTERN);
103
+ if (!matches) return [];
104
+
105
+ return matches.map(parseReference).filter((r): r is Reference => r !== null);
106
+ }
107
+
108
+ /**
109
+ * Parse a single reference string into a Reference object
110
+ */
111
+ export function parseReference(raw: string): Reference | null {
112
+ const match = raw.match(SINGLE_REF_PATTERN);
113
+ if (!match) return null;
114
+
115
+ const [, rootName, arrayPart, pathPart] = match;
116
+
117
+ // Determine reference type
118
+ let type: Reference['type'];
119
+ let stepId: string | undefined;
120
+ let arrayIndex: number | undefined;
121
+
122
+ // Parse array index from root (e.g., $parallel[0])
123
+ if (arrayPart) {
124
+ arrayIndex = parseInt(arrayPart.slice(1, -1), 10);
125
+ }
126
+
127
+ switch (rootName) {
128
+ case 'prev':
129
+ type = 'prev';
130
+ break;
131
+ case 'chain':
132
+ type = 'chain';
133
+ break;
134
+ case 'inputs':
135
+ type = 'inputs';
136
+ break;
137
+ case 'parallel':
138
+ type = 'parallel';
139
+ break;
140
+ case 'forEach':
141
+ type = 'forEach';
142
+ break;
143
+ case 'item':
144
+ type = 'item';
145
+ break;
146
+ case 'index':
147
+ type = 'index';
148
+ break;
149
+ case 'env':
150
+ type = 'env';
151
+ break;
152
+ default:
153
+ // It's a step ID reference
154
+ type = 'step';
155
+ stepId = rootName;
156
+ }
157
+
158
+ // Parse the property path
159
+ const path = parsePath(pathPart || '');
160
+
161
+ return { raw, type, stepId, path, arrayIndex };
162
+ }
163
+
164
+ /**
165
+ * Parse a property path like ".output.images[0].url" into ["output", "images", 0, "url"]
166
+ */
167
+ function parsePath(pathStr: string): string[] {
168
+ if (!pathStr) return [];
169
+
170
+ const parts: string[] = [];
171
+ // Remove leading dot
172
+ const cleaned = pathStr.startsWith('.') ? pathStr.slice(1) : pathStr;
173
+
174
+ // Split by dots and brackets
175
+ const segments = cleaned.split(/\.|\[|\]/g).filter(Boolean);
176
+
177
+ for (const segment of segments) {
178
+ // Check if it's a numeric index
179
+ if (/^\d+$/.test(segment)) {
180
+ parts.push(segment); // Keep as string, will convert during resolution
181
+ } else {
182
+ parts.push(segment);
183
+ }
184
+ }
185
+
186
+ return parts;
187
+ }
188
+
189
+ // ============================================================================
190
+ // REFERENCE RESOLUTION
191
+ // ============================================================================
192
+
193
+ /**
194
+ * Resolve a reference to its actual value from context
195
+ */
196
+ export function resolveReference(ref: Reference, context: ChainContext): any {
197
+ let value: any;
198
+
199
+ switch (ref.type) {
200
+ case 'prev':
201
+ // Get the previous step's result
202
+ if (!context.prevStepId) {
203
+ throw new ReferenceError(`$prev used but no previous step exists`);
204
+ }
205
+ value = context.results[context.prevStepId];
206
+ break;
207
+
208
+ case 'step':
209
+ // Get a specific step's result
210
+ if (!ref.stepId || !(ref.stepId in context.results)) {
211
+ throw new ReferenceError(`Step '${ref.stepId}' not found in results`);
212
+ }
213
+ value = context.results[ref.stepId];
214
+ break;
215
+
216
+ case 'parallel':
217
+ // Get parallel execution results
218
+ if (!context.parallelResults) {
219
+ throw new ReferenceError(`$parallel used but not in parallel context`);
220
+ }
221
+ if (ref.arrayIndex !== undefined) {
222
+ value = context.parallelResults[ref.arrayIndex];
223
+ } else {
224
+ value = context.parallelResults;
225
+ }
226
+ break;
227
+
228
+ case 'chain':
229
+ // Built-in chain variables
230
+ value = {
231
+ startedAt: context.startedAt,
232
+ index: context.currentIndex,
233
+ };
234
+ break;
235
+
236
+ case 'inputs':
237
+ // Template inputs
238
+ if (!context.inputs) {
239
+ throw new ReferenceError(`$inputs used but no inputs provided`);
240
+ }
241
+ value = context.inputs;
242
+ break;
243
+
244
+ case 'forEach':
245
+ // forEach accumulated results
246
+ value = {
247
+ results: context.forEachResults || [],
248
+ index: context.forEachIndex,
249
+ };
250
+ break;
251
+
252
+ case 'item':
253
+ // Current forEach item
254
+ if (context.forEachItem === undefined) {
255
+ throw new ReferenceError(`$item used but not in forEach loop`);
256
+ }
257
+ value = context.forEachItem;
258
+ break;
259
+
260
+ case 'index':
261
+ // Current forEach index
262
+ if (context.forEachIndex === undefined) {
263
+ throw new ReferenceError(`$index used but not in forEach loop`);
264
+ }
265
+ value = context.forEachIndex;
266
+ break;
267
+
268
+ case 'env':
269
+ // Environment variables
270
+ value = context.env || process.env;
271
+ break;
272
+
273
+ default:
274
+ throw new ReferenceError(`Unknown reference type: ${ref.type}`);
275
+ }
276
+
277
+ // Traverse the path
278
+ return traversePath(value, ref.path, ref.raw);
279
+ }
280
+
281
+ /**
282
+ * Traverse a path through an object/array
283
+ */
284
+ function traversePath(obj: any, path: string[], originalRef: string): any {
285
+ let current = obj;
286
+
287
+ for (let i = 0; i < path.length; i++) {
288
+ if (current === null || current === undefined) {
289
+ const traversed = path.slice(0, i).join('.');
290
+ throw new ReferenceError(
291
+ `Cannot read '${path[i]}' of ${current} at ${originalRef} (traversed: ${traversed})`
292
+ );
293
+ }
294
+
295
+ const key = path[i];
296
+
297
+ // Handle array index (stored as string)
298
+ if (/^\d+$/.test(key)) {
299
+ current = current[parseInt(key, 10)];
300
+ } else {
301
+ current = current[key];
302
+ }
303
+ }
304
+
305
+ return current;
306
+ }
307
+
308
+ // ============================================================================
309
+ // RESOLVE ALL REFERENCES IN PARAMS
310
+ // ============================================================================
311
+
312
+ /**
313
+ * Resolve all $references in a params object
314
+ * Recursively processes strings, arrays, and nested objects
315
+ */
316
+ export function resolveReferences(params: Record<string, any>, context: ChainContext): Record<string, any> {
317
+ return resolveValue(params, context) as Record<string, any>;
318
+ }
319
+
320
+ /**
321
+ * Resolve references in any value type
322
+ */
323
+ function resolveValue(value: any, context: ChainContext): any {
324
+ if (value === null || value === undefined) {
325
+ return value;
326
+ }
327
+
328
+ if (typeof value === 'string') {
329
+ return resolveStringValue(value, context);
330
+ }
331
+
332
+ if (Array.isArray(value)) {
333
+ return value.map(item => resolveValue(item, context));
334
+ }
335
+
336
+ if (typeof value === 'object') {
337
+ const resolved: Record<string, any> = {};
338
+ for (const [key, val] of Object.entries(value)) {
339
+ resolved[key] = resolveValue(val, context);
340
+ }
341
+ return resolved;
342
+ }
343
+
344
+ // Primitives (number, boolean) pass through
345
+ return value;
346
+ }
347
+
348
+ /**
349
+ * Resolve references in a string value
350
+ * Handles both full replacement and interpolation
351
+ */
352
+ function resolveStringValue(str: string, context: ChainContext): any {
353
+ const refs = extractReferences(str);
354
+
355
+ if (refs.length === 0) {
356
+ return str;
357
+ }
358
+
359
+ // If the entire string is a single reference, return the resolved value directly
360
+ // This preserves types (objects, arrays, numbers)
361
+ if (refs.length === 1 && refs[0].raw === str) {
362
+ return resolveReference(refs[0], context);
363
+ }
364
+
365
+ // Multiple references or mixed content: interpolate into string
366
+ let result = str;
367
+ for (const ref of refs) {
368
+ const resolved = resolveReference(ref, context);
369
+ const stringValue = typeof resolved === 'object' ? JSON.stringify(resolved) : String(resolved);
370
+ result = result.replace(ref.raw, stringValue);
371
+ }
372
+
373
+ return result;
374
+ }
375
+
376
+ // ============================================================================
377
+ // VALIDATION
378
+ // ============================================================================
379
+
380
+ /**
381
+ * Validate all references in a chain before execution
382
+ * Checks that referenced steps exist and come before the referencing step
383
+ */
384
+ export function validateReferences(steps: ChainStepUnion[]): ValidationResult {
385
+ const errors: ValidationError[] = [];
386
+ const warnings: ValidationWarning[] = [];
387
+
388
+ // Build set of step IDs that will exist
389
+ const definedSteps = new Set<string>();
390
+ const stepOrder: string[] = [];
391
+
392
+ // First pass: collect all step IDs
393
+ for (const step of steps) {
394
+ if ('parallel' in step) {
395
+ for (const ps of step.parallel) {
396
+ definedSteps.add(ps.id);
397
+ stepOrder.push(ps.id);
398
+ }
399
+ } else if ('forEach' in step) {
400
+ // forEach generates dynamic IDs
401
+ definedSteps.add(step.do.id.replace(/\$index/g, '*'));
402
+ } else if ('if' in step) {
403
+ const collectConditional = (s: ChainStep | ChainStep[]) => {
404
+ const arr = Array.isArray(s) ? s : [s];
405
+ for (const cs of arr) {
406
+ definedSteps.add(cs.id);
407
+ stepOrder.push(cs.id);
408
+ }
409
+ };
410
+ collectConditional(step.then);
411
+ if (step.else) collectConditional(step.else);
412
+ } else {
413
+ definedSteps.add(step.id);
414
+ stepOrder.push(step.id);
415
+ }
416
+ }
417
+
418
+ // Second pass: validate references
419
+ let currentIndex = 0;
420
+
421
+ const validateStep = (step: ChainStep, availableSteps: Set<string>, stepIdx: number) => {
422
+ if (!step.params) return;
423
+
424
+ const paramStr = JSON.stringify(step.params);
425
+ const refs = extractReferences(paramStr);
426
+
427
+ for (const ref of refs) {
428
+ // Validate step references
429
+ if (ref.type === 'step' && ref.stepId) {
430
+ if (!definedSteps.has(ref.stepId)) {
431
+ errors.push({
432
+ stepId: step.id,
433
+ reference: ref.raw,
434
+ message: `References undefined step '${ref.stepId}'`,
435
+ });
436
+ } else if (!availableSteps.has(ref.stepId)) {
437
+ errors.push({
438
+ stepId: step.id,
439
+ reference: ref.raw,
440
+ message: `References step '${ref.stepId}' which hasn't executed yet`,
441
+ });
442
+ }
443
+ }
444
+
445
+ // Validate $prev usage
446
+ if (ref.type === 'prev' && stepIdx === 0) {
447
+ errors.push({
448
+ stepId: step.id,
449
+ reference: ref.raw,
450
+ message: `$prev used in first step (no previous step exists)`,
451
+ });
452
+ }
453
+
454
+ // Warn about $parallel outside parallel context
455
+ if (ref.type === 'parallel') {
456
+ warnings.push({
457
+ stepId: step.id,
458
+ reference: ref.raw,
459
+ message: `$parallel used - ensure this follows a parallel block`,
460
+ });
461
+ }
462
+
463
+ // Warn about $item/$index outside forEach
464
+ if (ref.type === 'item' || ref.type === 'index') {
465
+ warnings.push({
466
+ stepId: step.id,
467
+ reference: ref.raw,
468
+ message: `${ref.raw} used - ensure this is inside a forEach block`,
469
+ });
470
+ }
471
+ }
472
+ };
473
+
474
+ const availableSteps = new Set<string>();
475
+
476
+ for (const step of steps) {
477
+ if ('parallel' in step) {
478
+ // Parallel steps can't reference each other
479
+ for (const ps of step.parallel) {
480
+ validateStep(ps, availableSteps, currentIndex);
481
+ }
482
+ // After parallel, all are available
483
+ for (const ps of step.parallel) {
484
+ availableSteps.add(ps.id);
485
+ }
486
+ } else if ('forEach' in step) {
487
+ validateStep(step.do, availableSteps, currentIndex);
488
+ } else if ('if' in step) {
489
+ const validateBranch = (s: ChainStep | ChainStep[]) => {
490
+ const arr = Array.isArray(s) ? s : [s];
491
+ for (const cs of arr) {
492
+ validateStep(cs, availableSteps, currentIndex);
493
+ availableSteps.add(cs.id);
494
+ }
495
+ };
496
+ validateBranch(step.then);
497
+ if (step.else) validateBranch(step.else);
498
+ } else {
499
+ validateStep(step, availableSteps, currentIndex);
500
+ availableSteps.add(step.id);
501
+ }
502
+
503
+ currentIndex++;
504
+ }
505
+
506
+ return {
507
+ valid: errors.length === 0,
508
+ errors,
509
+ warnings,
510
+ };
511
+ }
512
+
513
+ // ============================================================================
514
+ // CONDITIONAL EVALUATION
515
+ // ============================================================================
516
+
517
+ /**
518
+ * Evaluate a conditional expression string
519
+ * Supports: ===, !==, >, <, >=, <=, &&, ||, !
520
+ */
521
+ export function evaluateCondition(condition: string, context: ChainContext): boolean {
522
+ // First resolve any references in the condition
523
+ const resolvedCondition = resolveStringValue(condition, context);
524
+
525
+ // Simple expression evaluation
526
+ // For security, we use a restricted evaluator instead of eval()
527
+ try {
528
+ return safeEvaluate(resolvedCondition, context);
529
+ } catch (e) {
530
+ throw new Error(`Failed to evaluate condition '${condition}': ${e}`);
531
+ }
532
+ }
533
+
534
+ /**
535
+ * Safe expression evaluator for conditions
536
+ * Only allows comparison and logical operators
537
+ */
538
+ function safeEvaluate(expr: string, context: ChainContext): boolean {
539
+ // Trim whitespace
540
+ expr = expr.trim();
541
+
542
+ // Handle logical operators (lowest precedence)
543
+ // Split on || first (lowest precedence)
544
+ if (expr.includes('||')) {
545
+ const parts = splitOnOperator(expr, '||');
546
+ if (parts.length > 1) {
547
+ return parts.some(part => safeEvaluate(part, context));
548
+ }
549
+ }
550
+
551
+ // Then && (higher precedence than ||)
552
+ if (expr.includes('&&')) {
553
+ const parts = splitOnOperator(expr, '&&');
554
+ if (parts.length > 1) {
555
+ return parts.every(part => safeEvaluate(part, context));
556
+ }
557
+ }
558
+
559
+ // Handle negation
560
+ if (expr.startsWith('!')) {
561
+ return !safeEvaluate(expr.slice(1), context);
562
+ }
563
+
564
+ // Handle parentheses
565
+ if (expr.startsWith('(') && expr.endsWith(')')) {
566
+ return safeEvaluate(expr.slice(1, -1), context);
567
+ }
568
+
569
+ // Handle comparison operators
570
+ const comparisons = ['===', '!==', '>=', '<=', '>', '<', '==', '!='];
571
+ for (const op of comparisons) {
572
+ const idx = expr.indexOf(op);
573
+ if (idx !== -1) {
574
+ const left = parseValue(expr.slice(0, idx).trim());
575
+ const right = parseValue(expr.slice(idx + op.length).trim());
576
+
577
+ switch (op) {
578
+ case '===': return left === right;
579
+ case '!==': return left !== right;
580
+ case '==': return left == right;
581
+ case '!=': return left != right;
582
+ case '>': return left > right;
583
+ case '<': return left < right;
584
+ case '>=': return left >= right;
585
+ case '<=': return left <= right;
586
+ }
587
+ }
588
+ }
589
+
590
+ // If no operators, evaluate as truthy/falsy
591
+ return !!parseValue(expr);
592
+ }
593
+
594
+ /**
595
+ * Split expression on operator, respecting parentheses
596
+ */
597
+ function splitOnOperator(expr: string, op: string): string[] {
598
+ const parts: string[] = [];
599
+ let depth = 0;
600
+ let current = '';
601
+
602
+ for (let i = 0; i < expr.length; i++) {
603
+ const char = expr[i];
604
+
605
+ if (char === '(') depth++;
606
+ else if (char === ')') depth--;
607
+
608
+ if (depth === 0 && expr.slice(i, i + op.length) === op) {
609
+ parts.push(current);
610
+ current = '';
611
+ i += op.length - 1;
612
+ } else {
613
+ current += char;
614
+ }
615
+ }
616
+
617
+ if (current) parts.push(current);
618
+ return parts;
619
+ }
620
+
621
+ /**
622
+ * Parse a value string into its actual type
623
+ */
624
+ function parseValue(str: string): any {
625
+ str = str.trim();
626
+
627
+ // String literals
628
+ if ((str.startsWith('"') && str.endsWith('"')) || (str.startsWith("'") && str.endsWith("'"))) {
629
+ return str.slice(1, -1);
630
+ }
631
+
632
+ // Numbers
633
+ if (/^-?\d+\.?\d*$/.test(str)) {
634
+ return parseFloat(str);
635
+ }
636
+
637
+ // Booleans
638
+ if (str === 'true') return true;
639
+ if (str === 'false') return false;
640
+
641
+ // Null/undefined
642
+ if (str === 'null') return null;
643
+ if (str === 'undefined') return undefined;
644
+
645
+ // Already resolved value (from reference resolution)
646
+ return str;
647
+ }
648
+
649
+ // ============================================================================
650
+ // CUSTOM ERROR CLASS
651
+ // ============================================================================
652
+
653
+ export class ReferenceError extends Error {
654
+ constructor(message: string) {
655
+ super(message);
656
+ this.name = 'ReferenceError';
657
+ }
658
+ }