wao 0.22.4 → 0.23.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.
package/cjs/hb.js CHANGED
@@ -312,20 +312,22 @@ var HB = /*#__PURE__*/function () {
312
312
  key: "getImage",
313
313
  value: function () {
314
314
  var _getImage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
315
- var result;
315
+ var _this$image;
316
+ var result, image;
316
317
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
317
318
  while (1) switch (_context10.prev = _context10.next) {
318
319
  case 0:
319
320
  _context10.next = 2;
320
321
  return this.send({
321
322
  path: "/~wao@1.0/cache_wasm_image",
322
- method: "POST",
323
323
  filename: "test/aos-2-pure-xs.wasm"
324
324
  });
325
325
  case 2:
326
326
  result = _context10.sent;
327
- return _context10.abrupt("return", result.headers.get("image"));
328
- case 4:
327
+ image = result.headers.get("image");
328
+ (_this$image = this.image) !== null && _this$image !== void 0 ? _this$image : this.image = image;
329
+ return _context10.abrupt("return", image);
330
+ case 6:
329
331
  case "end":
330
332
  return _context10.stop();
331
333
  }
@@ -336,14 +338,44 @@ var HB = /*#__PURE__*/function () {
336
338
  }
337
339
  return getImage;
338
340
  }()
341
+ }, {
342
+ key: "getLua",
343
+ value: function () {
344
+ var _getLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
345
+ var _this$lua;
346
+ var result, lua;
347
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
348
+ while (1) switch (_context11.prev = _context11.next) {
349
+ case 0:
350
+ _context11.next = 2;
351
+ return this.send({
352
+ path: "/~wao@1.0/cache_lua_module",
353
+ filename: "test/hyper-aos.lua"
354
+ });
355
+ case 2:
356
+ result = _context11.sent;
357
+ lua = result.headers.get("id").split("/").pop();
358
+ (_this$lua = this.lua) !== null && _this$lua !== void 0 ? _this$lua : this.lua = lua;
359
+ return _context11.abrupt("return", lua);
360
+ case 6:
361
+ case "end":
362
+ return _context11.stop();
363
+ }
364
+ }, _callee11, this);
365
+ }));
366
+ function getLua() {
367
+ return _getLua.apply(this, arguments);
368
+ }
369
+ return getLua;
370
+ }()
339
371
  }, {
340
372
  key: "messageAOS",
341
373
  value: function () {
342
- var _messageAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref2) {
374
+ var _messageAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref2) {
343
375
  var _pid;
344
376
  var pid, _ref2$action, action, _ref2$tags, tags, data, _tags, res, slot;
345
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
346
- while (1) switch (_context11.prev = _context11.next) {
377
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
378
+ while (1) switch (_context12.prev = _context12.next) {
347
379
  case 0:
348
380
  pid = _ref2.pid, _ref2$action = _ref2.action, action = _ref2$action === void 0 ? "Eval" : _ref2$action, _ref2$tags = _ref2.tags, tags = _ref2$tags === void 0 ? {} : _ref2$tags, data = _ref2.data;
349
381
  (_pid = pid) !== null && _pid !== void 0 ? _pid : pid = this.pid;
@@ -357,28 +389,28 @@ var HB = /*#__PURE__*/function () {
357
389
  Target: pid
358
390
  });
359
391
  if (data) _tags.data = data;
360
- _context11.next = 6;
392
+ _context12.next = 6;
361
393
  return this.send(_tags);
362
394
  case 6:
363
- res = _context11.sent;
395
+ res = _context12.sent;
364
396
  slot = res.headers.get("slot");
365
- _context11.t0 = slot;
366
- _context11.next = 11;
397
+ _context12.t0 = slot;
398
+ _context12.next = 11;
367
399
  return this.computeAOS({
368
400
  pid: pid,
369
401
  slot: slot
370
402
  });
371
403
  case 11:
372
- _context11.t1 = _context11.sent;
373
- return _context11.abrupt("return", {
374
- slot: _context11.t0,
375
- outbox: _context11.t1
404
+ _context12.t1 = _context12.sent;
405
+ return _context12.abrupt("return", {
406
+ slot: _context12.t0,
407
+ outbox: _context12.t1
376
408
  });
377
409
  case 13:
378
410
  case "end":
379
- return _context11.stop();
411
+ return _context12.stop();
380
412
  }
381
- }, _callee11, this);
413
+ }, _callee12, this);
382
414
  }));
383
415
  function messageAOS(_x8) {
384
416
  return _messageAOS.apply(this, arguments);
@@ -388,10 +420,12 @@ var HB = /*#__PURE__*/function () {
388
420
  }, {
389
421
  key: "path",
390
422
  value: function path() {
391
- var dev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "meta";
392
- var _path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "info";
423
+ var dev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "message";
424
+ var _path = arguments.length > 1 ? arguments[1] : undefined;
393
425
  var json = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
394
426
  var params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
427
+ var pid = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
428
+ var tail = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : "";
395
429
  if (!/@/.test(dev)) dev += "@1.0";
396
430
  var _params = "";
397
431
  if (!(0, _ramda.isEmpty)(params)) {
@@ -401,24 +435,35 @@ var HB = /*#__PURE__*/function () {
401
435
  i++;
402
436
  }
403
437
  }
404
- return "".concat(this.url, "/~").concat(dev, "/").concat(_path).concat(json ? "/~json@1.0/serialize" : "").concat(_params);
438
+ return "".concat(this.url, "/").concat(pid, "~").concat(dev).concat(_path ? "/".concat(_path) : "").concat(tail).concat(json ? "/~json@1.0/serialize" : "").concat(_params);
405
439
  }
406
440
  }, {
407
441
  key: "text",
408
442
  value: function () {
409
- var _text = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(dev, path) {
410
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
411
- while (1) switch (_context12.prev = _context12.next) {
443
+ var _text = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(dev, path) {
444
+ var params,
445
+ tail,
446
+ pid,
447
+ _args13 = arguments;
448
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
449
+ while (1) switch (_context13.prev = _context13.next) {
412
450
  case 0:
413
- _context12.next = 2;
414
- return this.fetch(this.path(dev, path, false), false);
415
- case 2:
416
- return _context12.abrupt("return", _context12.sent);
417
- case 3:
451
+ params = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
452
+ tail = _args13.length > 3 ? _args13[3] : undefined;
453
+ pid = "";
454
+ if (/^[a-zA-Z0-9_-]{43}$/.test(dev)) {
455
+ pid = dev;
456
+ dev = "process";
457
+ }
458
+ _context13.next = 6;
459
+ return this.fetch(this.path(dev, path, false, params, pid, tail), false);
460
+ case 6:
461
+ return _context13.abrupt("return", _context13.sent);
462
+ case 7:
418
463
  case "end":
419
- return _context12.stop();
464
+ return _context13.stop();
420
465
  }
421
- }, _callee12, this);
466
+ }, _callee13, this);
422
467
  }));
423
468
  function text(_x9, _x10) {
424
469
  return _text.apply(this, arguments);
@@ -428,19 +473,30 @@ var HB = /*#__PURE__*/function () {
428
473
  }, {
429
474
  key: "json",
430
475
  value: function () {
431
- var _json = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(dev, path) {
432
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
433
- while (1) switch (_context13.prev = _context13.next) {
476
+ var _json = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(dev, path) {
477
+ var params,
478
+ tail,
479
+ pid,
480
+ _args14 = arguments;
481
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
482
+ while (1) switch (_context14.prev = _context14.next) {
434
483
  case 0:
435
- _context13.next = 2;
436
- return this.fetch(this.path(dev, path));
437
- case 2:
438
- return _context13.abrupt("return", _context13.sent);
439
- case 3:
484
+ params = _args14.length > 2 && _args14[2] !== undefined ? _args14[2] : {};
485
+ tail = _args14.length > 3 ? _args14[3] : undefined;
486
+ pid = "";
487
+ if (/^[a-zA-Z0-9_-]{43}$/.test(dev)) {
488
+ pid = dev;
489
+ dev = "process";
490
+ }
491
+ _context14.next = 6;
492
+ return this.fetch(this.path(dev, path, true, params, pid, tail));
493
+ case 6:
494
+ return _context14.abrupt("return", _context14.sent);
495
+ case 7:
440
496
  case "end":
441
- return _context13.stop();
497
+ return _context14.stop();
442
498
  }
443
- }, _callee13, this);
499
+ }, _callee14, this);
444
500
  }));
445
501
  function json(_x11, _x12) {
446
502
  return _json.apply(this, arguments);
@@ -458,24 +514,24 @@ var HB = /*#__PURE__*/function () {
458
514
  };
459
515
  return fetch;
460
516
  }(/*#__PURE__*/function () {
461
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(url) {
517
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(url) {
462
518
  var json,
463
- _args14 = arguments;
464
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
465
- while (1) switch (_context14.prev = _context14.next) {
519
+ _args15 = arguments;
520
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
521
+ while (1) switch (_context15.prev = _context15.next) {
466
522
  case 0:
467
- json = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : true;
468
- _context14.next = 3;
523
+ json = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : true;
524
+ _context15.next = 3;
469
525
  return fetch(url).then(function (r) {
470
526
  return json ? r.json() : r.text();
471
527
  });
472
528
  case 3:
473
- return _context14.abrupt("return", _context14.sent);
529
+ return _context15.abrupt("return", _context15.sent);
474
530
  case 4:
475
531
  case "end":
476
- return _context14.stop();
532
+ return _context15.stop();
477
533
  }
478
- }, _callee14);
534
+ }, _callee15);
479
535
  }));
480
536
  return function (_x13) {
481
537
  return _ref3.apply(this, arguments);
@@ -484,23 +540,23 @@ var HB = /*#__PURE__*/function () {
484
540
  }, {
485
541
  key: "computeAOS",
486
542
  value: function () {
487
- var _computeAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref4) {
543
+ var _computeAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref4) {
488
544
  var pid, slot;
489
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
490
- while (1) switch (_context15.prev = _context15.next) {
545
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
546
+ while (1) switch (_context16.prev = _context16.next) {
491
547
  case 0:
492
548
  pid = _ref4.pid, slot = _ref4.slot;
493
- _context15.next = 3;
549
+ _context16.next = 3;
494
550
  return fetch("".concat(this.url, "/").concat(pid, "/compute/results/outbox/~json@1.0/serialize?slot=").concat(slot)).then(function (r) {
495
551
  return r.json();
496
552
  });
497
553
  case 3:
498
- return _context15.abrupt("return", _context15.sent);
554
+ return _context16.abrupt("return", _context16.sent);
499
555
  case 4:
500
556
  case "end":
501
- return _context15.stop();
557
+ return _context16.stop();
502
558
  }
503
- }, _callee15, this);
559
+ }, _callee16, this);
504
560
  }));
505
561
  function computeAOS(_x14) {
506
562
  return _computeAOS.apply(this, arguments);
@@ -508,27 +564,53 @@ var HB = /*#__PURE__*/function () {
508
564
  return computeAOS;
509
565
  }()
510
566
  }, {
511
- key: "compute",
567
+ key: "computeLua",
512
568
  value: function () {
513
- var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref5) {
569
+ var _computeLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref5) {
514
570
  var pid, slot;
515
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
516
- while (1) switch (_context16.prev = _context16.next) {
571
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
572
+ while (1) switch (_context17.prev = _context17.next) {
517
573
  case 0:
518
574
  pid = _ref5.pid, slot = _ref5.slot;
519
- _context16.next = 3;
575
+ _context17.next = 3;
576
+ return fetch("".concat(this.url, "/").concat(pid, "/compute/results/~json@1.0/serialize?slot=").concat(slot)).then(function (r) {
577
+ return r.json();
578
+ });
579
+ case 3:
580
+ return _context17.abrupt("return", _context17.sent);
581
+ case 4:
582
+ case "end":
583
+ return _context17.stop();
584
+ }
585
+ }, _callee17, this);
586
+ }));
587
+ function computeLua(_x15) {
588
+ return _computeLua.apply(this, arguments);
589
+ }
590
+ return computeLua;
591
+ }()
592
+ }, {
593
+ key: "compute",
594
+ value: function () {
595
+ var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref6) {
596
+ var pid, slot;
597
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
598
+ while (1) switch (_context18.prev = _context18.next) {
599
+ case 0:
600
+ pid = _ref6.pid, slot = _ref6.slot;
601
+ _context18.next = 3;
520
602
  return fetch("".concat(this.url, "/").concat(pid, "/compute/~json@1.0/serialize?slot=").concat(slot)).then(function (r) {
521
603
  return r.json();
522
604
  });
523
605
  case 3:
524
- return _context16.abrupt("return", _context16.sent);
606
+ return _context18.abrupt("return", _context18.sent);
525
607
  case 4:
526
608
  case "end":
527
- return _context16.stop();
609
+ return _context18.stop();
528
610
  }
529
- }, _callee16, this);
611
+ }, _callee18, this);
530
612
  }));
531
- function compute(_x15) {
613
+ function compute(_x16) {
532
614
  return _compute.apply(this, arguments);
533
615
  }
534
616
  return compute;
@@ -536,27 +618,27 @@ var HB = /*#__PURE__*/function () {
536
618
  }, {
537
619
  key: "computeLegacy",
538
620
  value: function () {
539
- var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
621
+ var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref7) {
540
622
  var pid, slot, json;
541
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
542
- while (1) switch (_context17.prev = _context17.next) {
623
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
624
+ while (1) switch (_context19.prev = _context19.next) {
543
625
  case 0:
544
- pid = _ref6.pid, slot = _ref6.slot;
545
- _context17.next = 3;
626
+ pid = _ref7.pid, slot = _ref7.slot;
627
+ _context19.next = 3;
546
628
  return this.compute({
547
629
  pid: pid,
548
630
  slot: slot
549
631
  });
550
632
  case 3:
551
- json = _context17.sent;
552
- return _context17.abrupt("return", JSON.parse(json.results.json.body));
633
+ json = _context19.sent;
634
+ return _context19.abrupt("return", JSON.parse(json.results.json.body));
553
635
  case 5:
554
636
  case "end":
555
- return _context17.stop();
637
+ return _context19.stop();
556
638
  }
557
- }, _callee17, this);
639
+ }, _callee19, this);
558
640
  }));
559
- function computeLegacy(_x16) {
641
+ function computeLegacy(_x17) {
560
642
  return _computeLegacy.apply(this, arguments);
561
643
  }
562
644
  return computeLegacy;
@@ -564,24 +646,24 @@ var HB = /*#__PURE__*/function () {
564
646
  }, {
565
647
  key: "spawn",
566
648
  value: function () {
567
- var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
649
+ var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
568
650
  var _this$scheduler;
569
651
  var tags,
570
652
  addr,
571
653
  res,
572
- _args18 = arguments;
573
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
574
- while (1) switch (_context18.prev = _context18.next) {
654
+ _args20 = arguments;
655
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
656
+ while (1) switch (_context20.prev = _context20.next) {
575
657
  case 0:
576
- tags = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
577
- _context18.next = 3;
658
+ tags = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
659
+ _context20.next = 3;
578
660
  return this.dev.meta.info({
579
661
  key: "address"
580
662
  });
581
663
  case 3:
582
- addr = _context18.sent;
664
+ addr = _context20.sent;
583
665
  (_this$scheduler = this.scheduler) !== null && _this$scheduler !== void 0 ? _this$scheduler : this.scheduler = addr;
584
- _context18.next = 7;
666
+ _context20.next = 7;
585
667
  return this.send((0, _ramda.mergeLeft)(tags, {
586
668
  device: "process@1.0",
587
669
  path: "/schedule",
@@ -592,16 +674,16 @@ var HB = /*#__PURE__*/function () {
592
674
  "execution-device": "test-device@1.0"
593
675
  }));
594
676
  case 7:
595
- res = _context18.sent;
596
- return _context18.abrupt("return", {
677
+ res = _context20.sent;
678
+ return _context20.abrupt("return", {
597
679
  res: res,
598
680
  pid: res.headers.get("process")
599
681
  });
600
682
  case 9:
601
683
  case "end":
602
- return _context18.stop();
684
+ return _context20.stop();
603
685
  }
604
- }, _callee18, this);
686
+ }, _callee20, this);
605
687
  }));
606
688
  function spawn() {
607
689
  return _spawn.apply(this, arguments);
@@ -611,36 +693,36 @@ var HB = /*#__PURE__*/function () {
611
693
  }, {
612
694
  key: "message",
613
695
  value: function () {
614
- var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(args) {
696
+ var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(args) {
615
697
  var pid, _yield$this$schedule, slot, res;
616
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
617
- while (1) switch (_context19.prev = _context19.next) {
698
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
699
+ while (1) switch (_context21.prev = _context21.next) {
618
700
  case 0:
619
701
  pid = args.pid;
620
- _context19.next = 3;
702
+ _context21.next = 3;
621
703
  return this.schedule(args);
622
704
  case 3:
623
- _yield$this$schedule = _context19.sent;
705
+ _yield$this$schedule = _context21.sent;
624
706
  slot = _yield$this$schedule.slot;
625
- _context19.next = 7;
707
+ _context21.next = 7;
626
708
  return this.compute({
627
709
  pid: pid,
628
710
  slot: slot
629
711
  });
630
712
  case 7:
631
- res = _context19.sent;
632
- return _context19.abrupt("return", {
713
+ res = _context21.sent;
714
+ return _context21.abrupt("return", {
633
715
  slot: slot,
634
716
  pid: pid,
635
717
  res: res
636
718
  });
637
719
  case 9:
638
720
  case "end":
639
- return _context19.stop();
721
+ return _context21.stop();
640
722
  }
641
- }, _callee19, this);
723
+ }, _callee21, this);
642
724
  }));
643
- function message(_x17) {
725
+ function message(_x18) {
644
726
  return _message.apply(this, arguments);
645
727
  }
646
728
  return message;
@@ -648,22 +730,22 @@ var HB = /*#__PURE__*/function () {
648
730
  }, {
649
731
  key: "scheduleLegacy",
650
732
  value: function () {
651
- var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
652
- var _ref7,
733
+ var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
734
+ var _ref8,
653
735
  pid,
654
- _ref7$action,
736
+ _ref8$action,
655
737
  action,
656
- _ref7$tags,
738
+ _ref8$tags,
657
739
  tags,
658
740
  data,
659
741
  scheduler,
660
- _args20 = arguments;
661
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
662
- while (1) switch (_context20.prev = _context20.next) {
742
+ _args22 = arguments;
743
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
744
+ while (1) switch (_context22.prev = _context22.next) {
663
745
  case 0:
664
- _ref7 = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {}, pid = _ref7.pid, _ref7$action = _ref7.action, action = _ref7$action === void 0 ? "Eval" : _ref7$action, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data, scheduler = _ref7.scheduler;
746
+ _ref8 = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {}, pid = _ref8.pid, _ref8$action = _ref8.action, action = _ref8$action === void 0 ? "Eval" : _ref8$action, _ref8$tags = _ref8.tags, tags = _ref8$tags === void 0 ? {} : _ref8$tags, data = _ref8.data, scheduler = _ref8.scheduler;
665
747
  if (action) tags.Action = action;
666
- _context20.next = 4;
748
+ _context22.next = 4;
667
749
  return this.schedule({
668
750
  pid: pid,
669
751
  tags: tags,
@@ -671,36 +753,59 @@ var HB = /*#__PURE__*/function () {
671
753
  scheduler: scheduler
672
754
  });
673
755
  case 4:
674
- return _context20.abrupt("return", _context20.sent);
756
+ return _context22.abrupt("return", _context22.sent);
675
757
  case 5:
676
758
  case "end":
677
- return _context20.stop();
759
+ return _context22.stop();
678
760
  }
679
- }, _callee20, this);
761
+ }, _callee22, this);
680
762
  }));
681
763
  function scheduleLegacy() {
682
764
  return _scheduleLegacy.apply(this, arguments);
683
765
  }
684
766
  return scheduleLegacy;
685
767
  }()
768
+ }, {
769
+ key: "scheduleLua",
770
+ value: function () {
771
+ var _scheduleLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
772
+ var _args23 = arguments;
773
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
774
+ while (1) switch (_context23.prev = _context23.next) {
775
+ case 0:
776
+ _context23.next = 2;
777
+ return this.scheduleLegacy.apply(this, _args23);
778
+ case 2:
779
+ return _context23.abrupt("return", _context23.sent);
780
+ case 3:
781
+ case "end":
782
+ return _context23.stop();
783
+ }
784
+ }, _callee23, this);
785
+ }));
786
+ function scheduleLua() {
787
+ return _scheduleLua.apply(this, arguments);
788
+ }
789
+ return scheduleLua;
790
+ }()
686
791
  }, {
687
792
  key: "schedule",
688
793
  value: function () {
689
- var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
794
+ var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
690
795
  var _pid2, _scheduler;
691
- var _ref8,
796
+ var _ref9,
692
797
  pid,
693
- _ref8$tags,
798
+ _ref9$tags,
694
799
  tags,
695
800
  data,
696
801
  scheduler,
697
802
  _tags,
698
803
  res,
699
- _args21 = arguments;
700
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
701
- while (1) switch (_context21.prev = _context21.next) {
804
+ _args24 = arguments;
805
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
806
+ while (1) switch (_context24.prev = _context24.next) {
702
807
  case 0:
703
- _ref8 = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {}, pid = _ref8.pid, _ref8$tags = _ref8.tags, tags = _ref8$tags === void 0 ? {} : _ref8$tags, data = _ref8.data, scheduler = _ref8.scheduler;
808
+ _ref9 = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {}, pid = _ref9.pid, _ref9$tags = _ref9.tags, tags = _ref9$tags === void 0 ? {} : _ref9$tags, data = _ref9.data, scheduler = _ref9.scheduler;
704
809
  (_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
705
810
  (_scheduler = scheduler) !== null && _scheduler !== void 0 ? _scheduler : scheduler = this.scheduler;
706
811
  _tags = (0, _ramda.mergeLeft)(tags, {
@@ -711,19 +816,19 @@ var HB = /*#__PURE__*/function () {
711
816
  Target: pid
712
817
  });
713
818
  if (data) _tags.data = data;
714
- _context21.next = 7;
819
+ _context24.next = 7;
715
820
  return this.send(_tags);
716
821
  case 7:
717
- res = _context21.sent;
718
- return _context21.abrupt("return", {
822
+ res = _context24.sent;
823
+ return _context24.abrupt("return", {
719
824
  slot: res.headers.get("slot"),
720
825
  res: res
721
826
  });
722
827
  case 9:
723
828
  case "end":
724
- return _context21.stop();
829
+ return _context24.stop();
725
830
  }
726
- }, _callee21, this);
831
+ }, _callee24, this);
727
832
  }));
728
833
  function schedule() {
729
834
  return _schedule.apply(this, arguments);
@@ -733,43 +838,43 @@ var HB = /*#__PURE__*/function () {
733
838
  }, {
734
839
  key: "spawnAOS",
735
840
  value: function () {
736
- var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(image) {
737
- var _this$scheduler2, _image, _this$image, _this$pid;
841
+ var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(image) {
842
+ var _this$scheduler2, _image, _this$image2, _this$pid;
738
843
  var addr, res, pid;
739
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
740
- while (1) switch (_context22.prev = _context22.next) {
844
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
845
+ while (1) switch (_context25.prev = _context25.next) {
741
846
  case 0:
742
- _context22.next = 2;
847
+ _context25.next = 2;
743
848
  return this.dev.meta.info({
744
849
  key: "address"
745
850
  });
746
851
  case 2:
747
- addr = _context22.sent;
852
+ addr = _context25.sent;
748
853
  (_this$scheduler2 = this.scheduler) !== null && _this$scheduler2 !== void 0 ? _this$scheduler2 : this.scheduler = addr;
749
854
  if (!((_image = image) !== null && _image !== void 0)) {
750
- _context22.next = 8;
855
+ _context25.next = 8;
751
856
  break;
752
857
  }
753
858
  _image;
754
- _context22.next = 16;
859
+ _context25.next = 16;
755
860
  break;
756
861
  case 8:
757
- if (!((_this$image = this.image) !== null && _this$image !== void 0)) {
758
- _context22.next = 12;
862
+ if (!((_this$image2 = this.image) !== null && _this$image2 !== void 0)) {
863
+ _context25.next = 12;
759
864
  break;
760
865
  }
761
- _context22.t0 = _this$image;
762
- _context22.next = 15;
866
+ _context25.t0 = _this$image2;
867
+ _context25.next = 15;
763
868
  break;
764
869
  case 12:
765
- _context22.next = 14;
870
+ _context25.next = 14;
766
871
  return this.getImage();
767
872
  case 14:
768
- _context22.t0 = _context22.sent;
873
+ _context25.t0 = _context25.sent;
769
874
  case 15:
770
- image = _context22.t0;
875
+ image = _context25.t0;
771
876
  case 16:
772
- _context22.next = 18;
877
+ _context25.next = 18;
773
878
  return this.send({
774
879
  device: "process@1.0",
775
880
  path: "/schedule",
@@ -790,24 +895,103 @@ var HB = /*#__PURE__*/function () {
790
895
  passes: 2
791
896
  });
792
897
  case 18:
793
- res = _context22.sent;
898
+ res = _context25.sent;
794
899
  pid = res.headers.get("process");
795
900
  (_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
796
- return _context22.abrupt("return", {
901
+ return _context25.abrupt("return", {
797
902
  pid: pid,
798
903
  res: res
799
904
  });
800
905
  case 22:
801
906
  case "end":
802
- return _context22.stop();
907
+ return _context25.stop();
803
908
  }
804
- }, _callee22, this);
909
+ }, _callee25, this);
805
910
  }));
806
- function spawnAOS(_x18) {
911
+ function spawnAOS(_x19) {
807
912
  return _spawnAOS.apply(this, arguments);
808
913
  }
809
914
  return spawnAOS;
810
915
  }()
916
+ }, {
917
+ key: "spawnLua",
918
+ value: function () {
919
+ var _spawnLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
920
+ var _this$scheduler3, _lua, _this$lua2, _this$pid2;
921
+ var lua,
922
+ addr,
923
+ res,
924
+ pid,
925
+ _args26 = arguments;
926
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
927
+ while (1) switch (_context26.prev = _context26.next) {
928
+ case 0:
929
+ lua = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : "8DvyaxF8xpHMgPdmpMnhcb1mjY-M8qr2kGxnCpGMb60";
930
+ _context26.next = 3;
931
+ return this.dev.meta.info({
932
+ key: "address"
933
+ });
934
+ case 3:
935
+ addr = _context26.sent;
936
+ (_this$scheduler3 = this.scheduler) !== null && _this$scheduler3 !== void 0 ? _this$scheduler3 : this.scheduler = addr;
937
+ if (!((_lua = lua) !== null && _lua !== void 0)) {
938
+ _context26.next = 9;
939
+ break;
940
+ }
941
+ _lua;
942
+ _context26.next = 17;
943
+ break;
944
+ case 9:
945
+ if (!((_this$lua2 = this.lua) !== null && _this$lua2 !== void 0)) {
946
+ _context26.next = 13;
947
+ break;
948
+ }
949
+ _context26.t0 = _this$lua2;
950
+ _context26.next = 16;
951
+ break;
952
+ case 13:
953
+ _context26.next = 15;
954
+ return this.getLua();
955
+ case 15:
956
+ _context26.t0 = _context26.sent;
957
+ case 16:
958
+ lua = _context26.t0;
959
+ case 17:
960
+ _context26.next = 19;
961
+ return this.send({
962
+ device: "process@1.0",
963
+ path: "/schedule",
964
+ scheduler: this.scheduler,
965
+ "Data-Protocol": "ao",
966
+ Variant: "ao.N.1",
967
+ "scheduler-location": this.scheduler,
968
+ Authority: this.scheduler,
969
+ "random-seed": seed(16),
970
+ Type: "Process",
971
+ module: lua,
972
+ "scheduler-device": "scheduler@1.0",
973
+ "execution-device": "lua@5.3a",
974
+ "patch-from": "/results/outbox"
975
+ });
976
+ case 19:
977
+ res = _context26.sent;
978
+ pid = res.headers.get("process");
979
+ (_this$pid2 = this.pid) !== null && _this$pid2 !== void 0 ? _this$pid2 : this.pid = pid;
980
+ return _context26.abrupt("return", {
981
+ pid: pid,
982
+ res: res
983
+ });
984
+ case 23:
985
+ case "end":
986
+ return _context26.stop();
987
+ }
988
+ }, _callee26, this);
989
+ }));
990
+ function spawnLua() {
991
+ return _spawnLua.apply(this, arguments);
992
+ }
993
+ return spawnLua;
994
+ }()
811
995
  }, {
812
996
  key: "parseMetrics",
813
997
  value: function parseMetrics(txt) {
@@ -893,38 +1077,38 @@ var HB = /*#__PURE__*/function () {
893
1077
  }, {
894
1078
  key: "messages",
895
1079
  value: function () {
896
- var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1080
+ var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
897
1081
  var _this2 = this;
898
- var _ref9,
1082
+ var _ref10,
899
1083
  pid,
900
1084
  from,
901
1085
  to,
902
1086
  limit,
903
1087
  params,
904
1088
  res,
905
- _args24 = arguments;
906
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
907
- while (1) switch (_context24.prev = _context24.next) {
1089
+ _args28 = arguments;
1090
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1091
+ while (1) switch (_context28.prev = _context28.next) {
908
1092
  case 0:
909
- _ref9 = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {}, pid = _ref9.pid, from = _ref9.from, to = _ref9.to, limit = _ref9.limit;
1093
+ _ref10 = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {}, pid = _ref10.pid, from = _ref10.from, to = _ref10.to, limit = _ref10.limit;
910
1094
  params = "target=".concat(pid);
911
1095
  if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
912
1096
  if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
913
1097
  params += "&accept=application/aos-2";
914
- _context24.next = 7;
1098
+ _context28.next = 7;
915
1099
  return fetch("".concat(this.url, "/~scheduler@1.0/schedule?").concat(params)).then(function (r) {
916
1100
  return r.json();
917
1101
  });
918
1102
  case 7:
919
- res = _context24.sent;
1103
+ res = _context28.sent;
920
1104
  if (res.page_info.has_next_page) {
921
- res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1105
+ res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
922
1106
  var from2;
923
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
924
- while (1) switch (_context23.prev = _context23.next) {
1107
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1108
+ while (1) switch (_context27.prev = _context27.next) {
925
1109
  case 0:
926
1110
  from2 = (0, _ramda.last)(res.edges).cursor + 1;
927
- _context23.next = 3;
1111
+ _context27.next = 3;
928
1112
  return _this2.message({
929
1113
  pid: pid,
930
1114
  from: from2,
@@ -932,20 +1116,20 @@ var HB = /*#__PURE__*/function () {
932
1116
  limit: limit
933
1117
  });
934
1118
  case 3:
935
- return _context23.abrupt("return", _context23.sent);
1119
+ return _context27.abrupt("return", _context27.sent);
936
1120
  case 4:
937
1121
  case "end":
938
- return _context23.stop();
1122
+ return _context27.stop();
939
1123
  }
940
- }, _callee23);
1124
+ }, _callee27);
941
1125
  }));
942
1126
  }
943
- return _context24.abrupt("return", res);
1127
+ return _context28.abrupt("return", res);
944
1128
  case 10:
945
1129
  case "end":
946
- return _context24.stop();
1130
+ return _context28.stop();
947
1131
  }
948
- }, _callee24, this);
1132
+ }, _callee28, this);
949
1133
  }));
950
1134
  function messages() {
951
1135
  return _messages.apply(this, arguments);
@@ -955,16 +1139,16 @@ var HB = /*#__PURE__*/function () {
955
1139
  }, {
956
1140
  key: "spawnLegacy",
957
1141
  value: function () {
958
- var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
959
- var _ref11,
960
- _ref11$tags,
1142
+ var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1143
+ var _ref12,
1144
+ _ref12$tags,
961
1145
  tags,
962
1146
  data,
963
- _args25 = arguments;
964
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
965
- while (1) switch (_context25.prev = _context25.next) {
1147
+ _args29 = arguments;
1148
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1149
+ while (1) switch (_context29.prev = _context29.next) {
966
1150
  case 0:
967
- _ref11 = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {}, _ref11$tags = _ref11.tags, tags = _ref11$tags === void 0 ? {} : _ref11$tags, data = _ref11.data;
1151
+ _ref12 = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {}, _ref12$tags = _ref12.tags, tags = _ref12$tags === void 0 ? {} : _ref12$tags, data = _ref12.data;
968
1152
  tags = (0, _ramda.mergeLeft)(tags, {
969
1153
  data: data,
970
1154
  Type: "Process",
@@ -979,15 +1163,15 @@ var HB = /*#__PURE__*/function () {
979
1163
  "scheduler-device": "scheduler@1.0",
980
1164
  "execution-device": "genesis-wasm@1.0"
981
1165
  });
982
- _context25.next = 4;
1166
+ _context29.next = 4;
983
1167
  return this.spawn(tags);
984
1168
  case 4:
985
- return _context25.abrupt("return", _context25.sent);
1169
+ return _context29.abrupt("return", _context29.sent);
986
1170
  case 5:
987
1171
  case "end":
988
- return _context25.stop();
1172
+ return _context29.stop();
989
1173
  }
990
- }, _callee25, this);
1174
+ }, _callee29, this);
991
1175
  }));
992
1176
  function spawnLegacy() {
993
1177
  return _spawnLegacy.apply(this, arguments);
@@ -1010,26 +1194,26 @@ var HB = /*#__PURE__*/function () {
1010
1194
  }, {
1011
1195
  key: "dryrun",
1012
1196
  value: (function () {
1013
- var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1014
- var _ref12,
1015
- _ref12$tags,
1197
+ var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
1198
+ var _ref13,
1199
+ _ref13$tags,
1016
1200
  tags,
1017
1201
  pid,
1018
1202
  action,
1019
1203
  data,
1020
1204
  json,
1021
1205
  res,
1022
- _args26 = arguments;
1023
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1024
- while (1) switch (_context26.prev = _context26.next) {
1206
+ _args30 = arguments;
1207
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
1208
+ while (1) switch (_context30.prev = _context30.next) {
1025
1209
  case 0:
1026
- _ref12 = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {}, _ref12$tags = _ref12.tags, tags = _ref12$tags === void 0 ? {} : _ref12$tags, pid = _ref12.pid, action = _ref12.action, data = _ref12.data;
1210
+ _ref13 = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {}, _ref13$tags = _ref13.tags, tags = _ref13$tags === void 0 ? {} : _ref13$tags, pid = _ref13.pid, action = _ref13.action, data = _ref13.data;
1027
1211
  if (typeof action === "string") tags.Action = action;
1028
1212
  json = {
1029
1213
  Tags: (0, _utils.buildTags)(tags)
1030
1214
  };
1031
1215
  if (data) json.Data = data;
1032
- _context26.next = 6;
1216
+ _context30.next = 6;
1033
1217
  return this.send({
1034
1218
  path: "/~relay@1.0/call",
1035
1219
  "relay-method": "POST",
@@ -1038,13 +1222,13 @@ var HB = /*#__PURE__*/function () {
1038
1222
  body: JSON.stringify(json)
1039
1223
  });
1040
1224
  case 6:
1041
- res = _context26.sent;
1042
- return _context26.abrupt("return", JSON.parse(res.body));
1225
+ res = _context30.sent;
1226
+ return _context30.abrupt("return", JSON.parse(res.body));
1043
1227
  case 8:
1044
1228
  case "end":
1045
- return _context26.stop();
1229
+ return _context30.stop();
1046
1230
  }
1047
- }, _callee26, this);
1231
+ }, _callee30, this);
1048
1232
  }));
1049
1233
  function dryrun() {
1050
1234
  return _dryrun.apply(this, arguments);
@@ -1054,27 +1238,27 @@ var HB = /*#__PURE__*/function () {
1054
1238
  }, {
1055
1239
  key: "get",
1056
1240
  value: function () {
1057
- var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref13) {
1058
- var device, _ref13$path, path;
1059
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1060
- while (1) switch (_context27.prev = _context27.next) {
1241
+ var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(_ref14) {
1242
+ var device, _ref14$path, path;
1243
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
1244
+ while (1) switch (_context31.prev = _context31.next) {
1061
1245
  case 0:
1062
- device = _ref13.device, _ref13$path = _ref13.path, path = _ref13$path === void 0 ? "~meta@1.0/info" : _ref13$path;
1063
- _context27.next = 3;
1246
+ device = _ref14.device, _ref14$path = _ref14.path, path = _ref14$path === void 0 ? "~meta@1.0/info" : _ref14$path;
1247
+ _context31.next = 3;
1064
1248
  return this.request({
1065
1249
  device: device,
1066
1250
  path: path,
1067
1251
  method: "GET"
1068
1252
  });
1069
1253
  case 3:
1070
- return _context27.abrupt("return", _context27.sent.body);
1254
+ return _context31.abrupt("return", _context31.sent.body);
1071
1255
  case 4:
1072
1256
  case "end":
1073
- return _context27.stop();
1257
+ return _context31.stop();
1074
1258
  }
1075
- }, _callee27, this);
1259
+ }, _callee31, this);
1076
1260
  }));
1077
- function get(_x19) {
1261
+ function get(_x20) {
1078
1262
  return _get.apply(this, arguments);
1079
1263
  }
1080
1264
  return get;
@@ -1082,13 +1266,13 @@ var HB = /*#__PURE__*/function () {
1082
1266
  }, {
1083
1267
  key: "post",
1084
1268
  value: function () {
1085
- var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref14) {
1086
- var device, tags, _ref14$path, path;
1087
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1088
- while (1) switch (_context28.prev = _context28.next) {
1269
+ var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(_ref15) {
1270
+ var device, tags, _ref15$path, path;
1271
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
1272
+ while (1) switch (_context32.prev = _context32.next) {
1089
1273
  case 0:
1090
- device = _ref14.device, tags = _ref14.tags, _ref14$path = _ref14.path, path = _ref14$path === void 0 ? "/schedule" : _ref14$path;
1091
- _context28.next = 3;
1274
+ device = _ref15.device, tags = _ref15.tags, _ref15$path = _ref15.path, path = _ref15$path === void 0 ? "/schedule" : _ref15$path;
1275
+ _context32.next = 3;
1092
1276
  return this.request({
1093
1277
  tags: tags,
1094
1278
  device: device,
@@ -1096,14 +1280,14 @@ var HB = /*#__PURE__*/function () {
1096
1280
  method: "POST"
1097
1281
  });
1098
1282
  case 3:
1099
- return _context28.abrupt("return", _context28.sent);
1283
+ return _context32.abrupt("return", _context32.sent);
1100
1284
  case 4:
1101
1285
  case "end":
1102
- return _context28.stop();
1286
+ return _context32.stop();
1103
1287
  }
1104
- }, _callee28, this);
1288
+ }, _callee32, this);
1105
1289
  }));
1106
- function post(_x20) {
1290
+ function post(_x21) {
1107
1291
  return _post.apply(this, arguments);
1108
1292
  }
1109
1293
  return post;
@@ -1111,28 +1295,28 @@ var HB = /*#__PURE__*/function () {
1111
1295
  }, {
1112
1296
  key: "request",
1113
1297
  value: function () {
1114
- var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(_ref15) {
1115
- var device, tags, _ref15$method, method, _ref15$path, path, _tags;
1116
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1117
- while (1) switch (_context29.prev = _context29.next) {
1298
+ var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(_ref16) {
1299
+ var device, tags, _ref16$method, method, _ref16$path, path, _tags;
1300
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
1301
+ while (1) switch (_context33.prev = _context33.next) {
1118
1302
  case 0:
1119
- device = _ref15.device, tags = _ref15.tags, _ref15$method = _ref15.method, method = _ref15$method === void 0 ? "POST" : _ref15$method, _ref15$path = _ref15.path, path = _ref15$path === void 0 ? "/schedule" : _ref15$path;
1303
+ device = _ref16.device, tags = _ref16.tags, _ref16$method = _ref16.method, method = _ref16$method === void 0 ? "POST" : _ref16$method, _ref16$path = _ref16.path, path = _ref16$path === void 0 ? "/schedule" : _ref16$path;
1120
1304
  _tags = (0, _ramda.mergeLeft)(tags, {
1121
1305
  path: path,
1122
1306
  method: method
1123
1307
  });
1124
1308
  if (device) _tags.device = device;
1125
- _context29.next = 5;
1309
+ _context33.next = 5;
1126
1310
  return this._request(_tags);
1127
1311
  case 5:
1128
- return _context29.abrupt("return", _context29.sent);
1312
+ return _context33.abrupt("return", _context33.sent);
1129
1313
  case 6:
1130
1314
  case "end":
1131
- return _context29.stop();
1315
+ return _context33.stop();
1132
1316
  }
1133
- }, _callee29, this);
1317
+ }, _callee33, this);
1134
1318
  }));
1135
- function request(_x21) {
1319
+ function request(_x22) {
1136
1320
  return _request.apply(this, arguments);
1137
1321
  }
1138
1322
  return request;
package/cjs/hyperbeam.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
  var _child_process = require("child_process");
8
8
  var _path = require("path");
9
+ var _ramda = require("ramda");
9
10
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -27,8 +28,17 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
27
28
  c = _ref.c,
28
29
  cmake = _ref.cmake,
29
30
  _ref$legacy = _ref.legacy,
30
- legacy = _ref$legacy === void 0 ? false : _ref$legacy;
31
+ legacy = _ref$legacy === void 0 ? false : _ref$legacy,
32
+ faff = _ref.faff,
33
+ _ref$simplePay = _ref.simplePay,
34
+ simplePay = _ref$simplePay === void 0 ? false : _ref$simplePay,
35
+ simplePayPrice = _ref.simplePayPrice,
36
+ operator = _ref.operator;
31
37
  _classCallCheck(this, HyperBEAM);
38
+ this.simplePay = simplePay;
39
+ this.spp = simplePayPrice;
40
+ this.operator = operator;
41
+ this.faff = faff;
32
42
  this.c = c;
33
43
  this.cmake = cmake;
34
44
  this.port = port;
@@ -75,7 +85,18 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
75
85
  legacy = _ref2$legacy === void 0 ? false : _ref2$legacy;
76
86
  var _wallet = ", priv_key_location => <<\"".concat(wallet, "\">>");
77
87
  var _gateway = gateway ? ", gateway => <<\"http://localhost:".concat(gateway, "\">>") : "";
78
- return !legacy ? "hb:start_mainnet(#{ port => ".concat(this.port).concat(_gateway).concat(_wallet, " }).") : "hb:start_mainnet(#{ port => ".concat(this.port).concat(_gateway).concat(_wallet, ", bundler_httpsig => <<\"http://localhost:4001\">>, routes => [ #{ <<\"template\">> => <<\"/result/.*\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4004\">> } }, #{ <<\"template\">> => <<\"/dry-run\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4004\">> } }, #{ <<\"template\">> => <<\"/graphql\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4000\">>, <<\"opts\">> => #{ http_client => gun } } }, #{ <<\"template\">> => <<\"/raw\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4000\">>, <<\"opts\">> => #{ http_client => gun } } } ] }).");
88
+ var _store = ", store => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"cache-mainnet\">> }, #{ <<\"store-module\">> => hb_store_gateway, <<\"subindex\">> => [#{ <<\"name\">> => <<\"Data-Protocol\">>, <<\"value\">> => <<\"ao\">> }], <<\"store\">> => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"cache-mainnet\">> }] }, #{ <<\"store-module\">> => hb_store_gateway, <<\"store\">> => [#{ <<\"store-module\">> => hb_store_fs, <<\"prefix\">> => <<\"cache-mainnet\">> }] }]";
89
+ var _bundler = ", bundler_httpsig => <<\"http://localhost:4001\">>";
90
+ var _routes = ", routes => [#{ <<\"template\">> => <<\"/result/.*\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:6363\">> } }, #{ <<\"template\">> => <<\"/graphql\">>, <<\"nodes\">> => [#{ <<\"prefix\">> => <<\"http://localhost:".concat(gateway, "\">>, <<\"opts\">> => #{ http_client => httpc, protocol => http2 } }, #{ <<\"prefix\">> => <<\"http://localhost:").concat(gateway, "\">>, <<\"opts\">> => #{ http_client => gun, protocol => http2 } }] }, #{ <<\"template\">> => <<\"/raw\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:").concat(gateway, "\">>, <<\"opts\">> => #{ http_client => gun, protocol => http2 } } }]");
91
+ var _p4_non_chargeable = !this.simplePay ? "" : ", p4_non_chargable_routes => [#{ <<\"template\">> => <<\"/~simple-pay@1.0/topup\">> }, #{ <<\"template\">> => <<\"/~p4@1.0/balance\">> }, #{ <<\"template\">> => <<\"/~meta@1.0/*\">> }]";
92
+ var _operator = this.operator ? ", operator => <<\"".concat(this.operator, "\">>") : "";
93
+ var _spp = this.spp ? ", simple_pay_price => ".concat(this.spp) : "";
94
+ var _port = "port => ".concat(this.port);
95
+ var _faff = (0, _ramda.isNil)(this.faff) ? "" : ", faff_allow_list => [ ".concat((0, _ramda.map)(function (addr) {
96
+ return "<<\"".concat(addr, "\">>");
97
+ })(this.faff).join(", "), " ]");
98
+ var _on = this.simplePay ? ", on => #{ <<\"request\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"simple-pay@1.0\">>, <<\"ledger-device\">> => <<\"simple-pay@1.0\">> }, <<\"response\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"simple-pay@1.0\">>, <<\"ledger-device\">> => <<\"simple-pay@1.0\">> } }" : ", on => #{ <<\"request\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"faff@1.0\">>, <<\"ledger-device\">> => <<\"faff@1.0\">> }, <<\"response\">> => #{ <<\"device\">> => <<\"p4@1.0\">>, <<\"pricing-device\">> => <<\"faff@1.0\">>, <<\"ledger-device\">> => <<\"faff@1.0\">> } }";
99
+ return !legacy ? "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_store).concat(_on, " }).") : "hb:start_mainnet(#{ ".concat(_port).concat(_gateway).concat(_wallet).concat(_store).concat(_faff).concat(_bundler).concat(_routes).concat(_on).concat(_p4_non_chargeable).concat(_operator).concat(_spp, " }).");
79
100
  }
80
101
  }, {
81
102
  key: "kill",
package/esm/hb.js CHANGED
@@ -83,10 +83,21 @@ class HB {
83
83
  async getImage() {
84
84
  const result = await this.send({
85
85
  path: "/~wao@1.0/cache_wasm_image",
86
- method: "POST",
87
86
  filename: "test/aos-2-pure-xs.wasm",
88
87
  })
89
- return result.headers.get("image")
88
+ const image = result.headers.get("image")
89
+ this.image ??= image
90
+ return image
91
+ }
92
+
93
+ async getLua() {
94
+ const result = await this.send({
95
+ path: "/~wao@1.0/cache_lua_module",
96
+ filename: "test/hyper-aos.lua",
97
+ })
98
+ const lua = result.headers.get("id").split("/").pop()
99
+ this.lua ??= lua
100
+ return lua
90
101
  }
91
102
 
92
103
  async messageAOS({ pid, action = "Eval", tags = {}, data }) {
@@ -106,7 +117,7 @@ class HB {
106
117
  return { slot, outbox: await this.computeAOS({ pid, slot }) }
107
118
  }
108
119
 
109
- path(dev = "meta", path = "info", json = true, params = {}) {
120
+ path(dev = "message", path, json = true, params = {}, pid = "", tail = "") {
110
121
  if (!/@/.test(dev)) dev += "@1.0"
111
122
  let _params = ""
112
123
  if (!isEmpty(params)) {
@@ -116,15 +127,28 @@ class HB {
116
127
  i++
117
128
  }
118
129
  }
119
- return `${this.url}/~${dev}/${path}${json ? "/~json@1.0/serialize" : ""}${_params}`
130
+ return `${this.url}/${pid}~${dev}${path ? `/${path}` : ""}${tail}${json ? "/~json@1.0/serialize" : ""}${_params}`
120
131
  }
121
132
 
122
- async text(dev, path) {
123
- return await this.fetch(this.path(dev, path, false), false)
133
+ async text(dev, path, params = {}, tail) {
134
+ let pid = ""
135
+ if (/^[a-zA-Z0-9_-]{43}$/.test(dev)) {
136
+ pid = dev
137
+ dev = "process"
138
+ }
139
+ return await this.fetch(
140
+ this.path(dev, path, false, params, pid, tail),
141
+ false
142
+ )
124
143
  }
125
144
 
126
- async json(dev, path) {
127
- return await this.fetch(this.path(dev, path))
145
+ async json(dev, path, params = {}, tail) {
146
+ let pid = ""
147
+ if (/^[a-zA-Z0-9_-]{43}$/.test(dev)) {
148
+ pid = dev
149
+ dev = "process"
150
+ }
151
+ return await this.fetch(this.path(dev, path, true, params, pid, tail))
128
152
  }
129
153
 
130
154
  async fetch(url, json = true) {
@@ -137,6 +161,12 @@ class HB {
137
161
  ).then(r => r.json())
138
162
  }
139
163
 
164
+ async computeLua({ pid, slot }) {
165
+ return await fetch(
166
+ `${this.url}/${pid}/compute/results/~json@1.0/serialize?slot=${slot}`
167
+ ).then(r => r.json())
168
+ }
169
+
140
170
  async compute({ pid, slot }) {
141
171
  return await fetch(
142
172
  `${this.url}/${pid}/compute/~json@1.0/serialize?slot=${slot}`
@@ -181,6 +211,9 @@ class HB {
181
211
  if (action) tags.Action = action
182
212
  return await this.schedule({ pid, tags, data, scheduler })
183
213
  }
214
+ async scheduleLua(...args) {
215
+ return await this.scheduleLegacy(...args)
216
+ }
184
217
  async schedule({ pid, tags = {}, data, scheduler } = {}) {
185
218
  pid ??= this.pid
186
219
  scheduler ??= this.scheduler
@@ -229,6 +262,30 @@ class HB {
229
262
  return { pid, res }
230
263
  }
231
264
 
265
+ async spawnLua(lua = "8DvyaxF8xpHMgPdmpMnhcb1mjY-M8qr2kGxnCpGMb60") {
266
+ const addr = await this.dev.meta.info({ key: "address" })
267
+ this.scheduler ??= addr
268
+ lua ??= this.lua ?? (await this.getLua())
269
+ const res = await this.send({
270
+ device: "process@1.0",
271
+ path: "/schedule",
272
+ scheduler: this.scheduler,
273
+ "Data-Protocol": "ao",
274
+ Variant: "ao.N.1",
275
+ "scheduler-location": this.scheduler,
276
+ Authority: this.scheduler,
277
+ "random-seed": seed(16),
278
+ Type: "Process",
279
+ module: lua,
280
+ "scheduler-device": "scheduler@1.0",
281
+ "execution-device": "lua@5.3a",
282
+ "patch-from": "/results/outbox",
283
+ })
284
+ const pid = res.headers.get("process")
285
+ this.pid ??= pid
286
+ return { pid, res }
287
+ }
288
+
232
289
  parseMetrics(txt) {
233
290
  const parts = txt.split(/\r?\n/)
234
291
  let index = 0
package/esm/hyperbeam.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { spawn } from "child_process"
2
2
  import { resolve } from "path"
3
+ import { isNil, map } from "ramda"
3
4
 
4
5
  export default class HyperBEAM {
5
6
  constructor({
@@ -10,7 +11,15 @@ export default class HyperBEAM {
10
11
  c,
11
12
  cmake,
12
13
  legacy = false,
14
+ faff,
15
+ simplePay = false,
16
+ simplePayPrice,
17
+ operator,
13
18
  } = {}) {
19
+ this.simplePay = simplePay
20
+ this.spp = simplePayPrice
21
+ this.operator = operator
22
+ this.faff = faff
14
23
  this.c = c
15
24
  this.cmake = cmake
16
25
  this.port = port
@@ -46,9 +55,27 @@ export default class HyperBEAM {
46
55
  const _gateway = gateway
47
56
  ? `, gateway => <<"http://localhost:${gateway}">>`
48
57
  : ""
58
+ const _store = `, store => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"cache-mainnet">> }, #{ <<"store-module">> => hb_store_gateway, <<"subindex">> => [#{ <<"name">> => <<"Data-Protocol">>, <<"value">> => <<"ao">> }], <<"store">> => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"cache-mainnet">> }] }, #{ <<"store-module">> => hb_store_gateway, <<"store">> => [#{ <<"store-module">> => hb_store_fs, <<"prefix">> => <<"cache-mainnet">> }] }]`
59
+ const _bundler = `, bundler_httpsig => <<"http://localhost:4001">>`
60
+ const _routes = `, routes => [#{ <<"template">> => <<"/result/.*">>, <<"node">> => #{ <<"prefix">> => <<"http://localhost:6363">> } }, #{ <<"template">> => <<"/graphql">>, <<"nodes">> => [#{ <<"prefix">> => <<"http://localhost:${gateway}">>, <<"opts">> => #{ http_client => httpc, protocol => http2 } }, #{ <<"prefix">> => <<"http://localhost:${gateway}">>, <<"opts">> => #{ http_client => gun, protocol => http2 } }] }, #{ <<"template">> => <<"/raw">>, <<"node">> => #{ <<"prefix">> => <<"http://localhost:${gateway}">>, <<"opts">> => #{ http_client => gun, protocol => http2 } } }]`
61
+ const _p4_non_chargeable = !this.simplePay
62
+ ? ""
63
+ : `, p4_non_chargable_routes => [#{ <<"template">> => <<"/~simple-pay@1.0/topup">> }, #{ <<"template">> => <<"/~p4@1.0/balance">> }, #{ <<"template">> => <<"/~meta@1.0/*">> }]`
64
+ const _operator = this.operator
65
+ ? `, operator => <<"${this.operator}">>`
66
+ : ""
67
+ const _spp = this.spp ? `, simple_pay_price => ${this.spp}` : ""
68
+
69
+ const _port = `port => ${this.port}`
70
+ const _faff = isNil(this.faff)
71
+ ? ""
72
+ : `, faff_allow_list => [ ${map(addr => `<<"${addr}">>`)(this.faff).join(", ")} ]`
73
+ const _on = this.simplePay
74
+ ? `, on => #{ <<"request">> => #{ <<"device">> => <<"p4@1.0">>, <<"pricing-device">> => <<"simple-pay@1.0">>, <<"ledger-device">> => <<"simple-pay@1.0">> }, <<"response">> => #{ <<"device">> => <<"p4@1.0">>, <<"pricing-device">> => <<"simple-pay@1.0">>, <<"ledger-device">> => <<"simple-pay@1.0">> } }`
75
+ : `, on => #{ <<"request">> => #{ <<"device">> => <<"p4@1.0">>, <<"pricing-device">> => <<"faff@1.0">>, <<"ledger-device">> => <<"faff@1.0">> }, <<"response">> => #{ <<"device">> => <<"p4@1.0">>, <<"pricing-device">> => <<"faff@1.0">>, <<"ledger-device">> => <<"faff@1.0">> } }`
49
76
  return !legacy
50
- ? `hb:start_mainnet(#{ port => ${this.port}${_gateway}${_wallet} }).`
51
- : `hb:start_mainnet(#{ port => ${this.port}${_gateway}${_wallet}, bundler_httpsig => <<\"http://localhost:4001\">>, routes => [ #{ <<\"template\">> => <<\"/result/.*\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4004\">> } }, #{ <<\"template\">> => <<\"/dry-run\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4004\">> } }, #{ <<\"template\">> => <<\"/graphql\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4000\">>, <<\"opts\">> => #{ http_client => gun } } }, #{ <<\"template\">> => <<\"/raw\">>, <<\"node\">> => #{ <<\"prefix\">> => <<\"http://localhost:4000\">>, <<\"opts\">> => #{ http_client => gun } } } ] }).`
77
+ ? `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store}${_on} }).`
78
+ : `hb:start_mainnet(#{ ${_port}${_gateway}${_wallet}${_store}${_faff}${_bundler}${_routes}${_on}${_p4_non_chargeable}${_operator}${_spp} }).`
52
79
  }
53
80
 
54
81
  kill() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.22.4",
3
+ "version": "0.23.1",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"