wao 0.22.1 → 0.22.3
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/aoconnect-base.js +1 -1
- package/cjs/hb.js +197 -171
- package/cjs/test.js +6 -0
- package/cjs/workspace/package.json +1 -1
- package/cjs/workspace/test/hyperbeam.js +30 -0
- package/esm/aoconnect-base.js +1 -3
- package/esm/hb.js +30 -26
- package/esm/test.js +2 -1
- package/esm/workspace/package.json +1 -1
- package/esm/workspace/test/hyperbeam.js +30 -0
- package/package.json +1 -1
package/cjs/aoconnect-base.js
CHANGED
package/cjs/hb.js
CHANGED
|
@@ -509,23 +509,25 @@ var HB = /*#__PURE__*/function () {
|
|
|
509
509
|
}, {
|
|
510
510
|
key: "compute",
|
|
511
511
|
value: function () {
|
|
512
|
-
var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(
|
|
512
|
+
var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(_ref5) {
|
|
513
|
+
var pid, slot;
|
|
513
514
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
514
515
|
while (1) switch (_context16.prev = _context16.next) {
|
|
515
516
|
case 0:
|
|
516
|
-
|
|
517
|
+
pid = _ref5.pid, slot = _ref5.slot;
|
|
518
|
+
_context16.next = 3;
|
|
517
519
|
return fetch("".concat(this.url, "/").concat(pid, "/compute/serialize~json@1.0?slot=").concat(slot)).then(function (r) {
|
|
518
520
|
return r.json();
|
|
519
521
|
});
|
|
520
|
-
case 2:
|
|
521
|
-
return _context16.abrupt("return", _context16.sent);
|
|
522
522
|
case 3:
|
|
523
|
+
return _context16.abrupt("return", _context16.sent);
|
|
524
|
+
case 4:
|
|
523
525
|
case "end":
|
|
524
526
|
return _context16.stop();
|
|
525
527
|
}
|
|
526
528
|
}, _callee16, this);
|
|
527
529
|
}));
|
|
528
|
-
function compute(_x15
|
|
530
|
+
function compute(_x15) {
|
|
529
531
|
return _compute.apply(this, arguments);
|
|
530
532
|
}
|
|
531
533
|
return compute;
|
|
@@ -533,23 +535,27 @@ var HB = /*#__PURE__*/function () {
|
|
|
533
535
|
}, {
|
|
534
536
|
key: "computeLegacy",
|
|
535
537
|
value: function () {
|
|
536
|
-
var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(
|
|
537
|
-
var json;
|
|
538
|
+
var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
|
|
539
|
+
var pid, slot, json;
|
|
538
540
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
539
541
|
while (1) switch (_context17.prev = _context17.next) {
|
|
540
542
|
case 0:
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
543
|
+
pid = _ref6.pid, slot = _ref6.slot;
|
|
544
|
+
_context17.next = 3;
|
|
545
|
+
return this.compute({
|
|
546
|
+
pid: pid,
|
|
547
|
+
slot: slot
|
|
548
|
+
});
|
|
549
|
+
case 3:
|
|
544
550
|
json = _context17.sent;
|
|
545
551
|
return _context17.abrupt("return", JSON.parse(json.results.json.body));
|
|
546
|
-
case
|
|
552
|
+
case 5:
|
|
547
553
|
case "end":
|
|
548
554
|
return _context17.stop();
|
|
549
555
|
}
|
|
550
556
|
}, _callee17, this);
|
|
551
557
|
}));
|
|
552
|
-
function computeLegacy(
|
|
558
|
+
function computeLegacy(_x16) {
|
|
553
559
|
return _computeLegacy.apply(this, arguments);
|
|
554
560
|
}
|
|
555
561
|
return computeLegacy;
|
|
@@ -558,11 +564,9 @@ var HB = /*#__PURE__*/function () {
|
|
|
558
564
|
key: "spawn",
|
|
559
565
|
value: function () {
|
|
560
566
|
var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
561
|
-
var _this$scheduler
|
|
567
|
+
var _this$scheduler;
|
|
562
568
|
var tags,
|
|
563
569
|
addr,
|
|
564
|
-
spawned,
|
|
565
|
-
pid,
|
|
566
570
|
res,
|
|
567
571
|
_args18 = arguments;
|
|
568
572
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
@@ -584,22 +588,15 @@ var HB = /*#__PURE__*/function () {
|
|
|
584
588
|
"random-seed": seed(16),
|
|
585
589
|
Type: "Process",
|
|
586
590
|
"scheduler-device": "scheduler@1.0",
|
|
587
|
-
"execution-device": "
|
|
591
|
+
"execution-device": "test-device@1.0"
|
|
588
592
|
}));
|
|
589
593
|
case 7:
|
|
590
|
-
spawned = _context18.sent;
|
|
591
|
-
pid = spawned.headers.get("process");
|
|
592
|
-
(_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
|
|
593
|
-
_context18.next = 12;
|
|
594
|
-
return this.compute(pid, 0);
|
|
595
|
-
case 12:
|
|
596
594
|
res = _context18.sent;
|
|
597
595
|
return _context18.abrupt("return", {
|
|
598
|
-
|
|
599
|
-
pid:
|
|
600
|
-
res: res
|
|
596
|
+
res: res,
|
|
597
|
+
pid: res.headers.get("process")
|
|
601
598
|
});
|
|
602
|
-
case
|
|
599
|
+
case 9:
|
|
603
600
|
case "end":
|
|
604
601
|
return _context18.stop();
|
|
605
602
|
}
|
|
@@ -613,67 +610,99 @@ var HB = /*#__PURE__*/function () {
|
|
|
613
610
|
}, {
|
|
614
611
|
key: "message",
|
|
615
612
|
value: function () {
|
|
616
|
-
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
617
|
-
var _yield$this$schedule,
|
|
618
|
-
pid,
|
|
619
|
-
slot,
|
|
620
|
-
scheduled,
|
|
621
|
-
res,
|
|
622
|
-
_args19 = arguments;
|
|
613
|
+
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(args) {
|
|
614
|
+
var pid, _yield$this$schedule, slot, res;
|
|
623
615
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
624
616
|
while (1) switch (_context19.prev = _context19.next) {
|
|
625
617
|
case 0:
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
618
|
+
pid = args.pid;
|
|
619
|
+
_context19.next = 3;
|
|
620
|
+
return this.schedule(args);
|
|
621
|
+
case 3:
|
|
629
622
|
_yield$this$schedule = _context19.sent;
|
|
630
|
-
pid = _yield$this$schedule.pid;
|
|
631
623
|
slot = _yield$this$schedule.slot;
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
624
|
+
_context19.next = 7;
|
|
625
|
+
return this.compute({
|
|
626
|
+
pid: pid,
|
|
627
|
+
slot: slot
|
|
628
|
+
});
|
|
629
|
+
case 7:
|
|
636
630
|
res = _context19.sent;
|
|
637
631
|
return _context19.abrupt("return", {
|
|
638
632
|
slot: slot,
|
|
639
633
|
pid: pid,
|
|
640
|
-
res: res
|
|
641
|
-
scheduled: scheduled
|
|
634
|
+
res: res
|
|
642
635
|
});
|
|
643
|
-
case
|
|
636
|
+
case 9:
|
|
644
637
|
case "end":
|
|
645
638
|
return _context19.stop();
|
|
646
639
|
}
|
|
647
640
|
}, _callee19, this);
|
|
648
641
|
}));
|
|
649
|
-
function message() {
|
|
642
|
+
function message(_x17) {
|
|
650
643
|
return _message.apply(this, arguments);
|
|
651
644
|
}
|
|
652
645
|
return message;
|
|
653
646
|
}()
|
|
647
|
+
}, {
|
|
648
|
+
key: "scheduleLegacy",
|
|
649
|
+
value: function () {
|
|
650
|
+
var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
651
|
+
var _ref7,
|
|
652
|
+
pid,
|
|
653
|
+
_ref7$action,
|
|
654
|
+
action,
|
|
655
|
+
_ref7$tags,
|
|
656
|
+
tags,
|
|
657
|
+
data,
|
|
658
|
+
scheduler,
|
|
659
|
+
_args20 = arguments;
|
|
660
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
661
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
662
|
+
case 0:
|
|
663
|
+
_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;
|
|
664
|
+
if (action) tags.Action = action;
|
|
665
|
+
_context20.next = 4;
|
|
666
|
+
return this.schedule({
|
|
667
|
+
pid: pid,
|
|
668
|
+
tags: tags,
|
|
669
|
+
data: data,
|
|
670
|
+
scheduler: scheduler
|
|
671
|
+
});
|
|
672
|
+
case 4:
|
|
673
|
+
return _context20.abrupt("return", _context20.sent);
|
|
674
|
+
case 5:
|
|
675
|
+
case "end":
|
|
676
|
+
return _context20.stop();
|
|
677
|
+
}
|
|
678
|
+
}, _callee20, this);
|
|
679
|
+
}));
|
|
680
|
+
function scheduleLegacy() {
|
|
681
|
+
return _scheduleLegacy.apply(this, arguments);
|
|
682
|
+
}
|
|
683
|
+
return scheduleLegacy;
|
|
684
|
+
}()
|
|
654
685
|
}, {
|
|
655
686
|
key: "schedule",
|
|
656
687
|
value: function () {
|
|
657
|
-
var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
688
|
+
var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
658
689
|
var _pid2, _scheduler;
|
|
659
|
-
var
|
|
690
|
+
var _ref8,
|
|
660
691
|
pid,
|
|
661
|
-
|
|
692
|
+
_ref8$tags,
|
|
662
693
|
tags,
|
|
663
694
|
data,
|
|
664
695
|
scheduler,
|
|
665
696
|
_tags,
|
|
666
697
|
res,
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
698
|
+
_args21 = arguments;
|
|
699
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
700
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
671
701
|
case 0:
|
|
672
|
-
|
|
702
|
+
_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;
|
|
673
703
|
(_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
|
|
674
704
|
(_scheduler = scheduler) !== null && _scheduler !== void 0 ? _scheduler : scheduler = this.scheduler;
|
|
675
705
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
676
|
-
device: "process@1.0",
|
|
677
706
|
method: "POST",
|
|
678
707
|
path: "/".concat(pid, "/schedule"),
|
|
679
708
|
scheduler: scheduler,
|
|
@@ -681,21 +710,19 @@ var HB = /*#__PURE__*/function () {
|
|
|
681
710
|
Target: pid
|
|
682
711
|
});
|
|
683
712
|
if (data) _tags.data = data;
|
|
684
|
-
|
|
713
|
+
_context21.next = 7;
|
|
685
714
|
return this.send(_tags);
|
|
686
715
|
case 7:
|
|
687
|
-
res =
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
res: res,
|
|
692
|
-
pid: pid
|
|
716
|
+
res = _context21.sent;
|
|
717
|
+
return _context21.abrupt("return", {
|
|
718
|
+
slot: res.headers.get("slot"),
|
|
719
|
+
res: res
|
|
693
720
|
});
|
|
694
|
-
case
|
|
721
|
+
case 9:
|
|
695
722
|
case "end":
|
|
696
|
-
return
|
|
723
|
+
return _context21.stop();
|
|
697
724
|
}
|
|
698
|
-
},
|
|
725
|
+
}, _callee21, this);
|
|
699
726
|
}));
|
|
700
727
|
function schedule() {
|
|
701
728
|
return _schedule.apply(this, arguments);
|
|
@@ -705,43 +732,43 @@ var HB = /*#__PURE__*/function () {
|
|
|
705
732
|
}, {
|
|
706
733
|
key: "spawnAOS",
|
|
707
734
|
value: function () {
|
|
708
|
-
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
709
|
-
var _this$scheduler2, _image, _this$image, _this$
|
|
735
|
+
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(image) {
|
|
736
|
+
var _this$scheduler2, _image, _this$image, _this$pid;
|
|
710
737
|
var addr, res, pid;
|
|
711
|
-
return _regeneratorRuntime().wrap(function
|
|
712
|
-
while (1) switch (
|
|
738
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
739
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
713
740
|
case 0:
|
|
714
|
-
|
|
741
|
+
_context22.next = 2;
|
|
715
742
|
return this.meta.info({
|
|
716
743
|
key: "address"
|
|
717
744
|
});
|
|
718
745
|
case 2:
|
|
719
|
-
addr =
|
|
746
|
+
addr = _context22.sent;
|
|
720
747
|
(_this$scheduler2 = this.scheduler) !== null && _this$scheduler2 !== void 0 ? _this$scheduler2 : this.scheduler = addr;
|
|
721
748
|
if (!((_image = image) !== null && _image !== void 0)) {
|
|
722
|
-
|
|
749
|
+
_context22.next = 8;
|
|
723
750
|
break;
|
|
724
751
|
}
|
|
725
752
|
_image;
|
|
726
|
-
|
|
753
|
+
_context22.next = 16;
|
|
727
754
|
break;
|
|
728
755
|
case 8:
|
|
729
756
|
if (!((_this$image = this.image) !== null && _this$image !== void 0)) {
|
|
730
|
-
|
|
757
|
+
_context22.next = 12;
|
|
731
758
|
break;
|
|
732
759
|
}
|
|
733
|
-
|
|
734
|
-
|
|
760
|
+
_context22.t0 = _this$image;
|
|
761
|
+
_context22.next = 15;
|
|
735
762
|
break;
|
|
736
763
|
case 12:
|
|
737
|
-
|
|
764
|
+
_context22.next = 14;
|
|
738
765
|
return this.getImage();
|
|
739
766
|
case 14:
|
|
740
|
-
|
|
767
|
+
_context22.t0 = _context22.sent;
|
|
741
768
|
case 15:
|
|
742
|
-
image =
|
|
769
|
+
image = _context22.t0;
|
|
743
770
|
case 16:
|
|
744
|
-
|
|
771
|
+
_context22.next = 18;
|
|
745
772
|
return this.send({
|
|
746
773
|
device: "process@1.0",
|
|
747
774
|
path: "/schedule",
|
|
@@ -762,17 +789,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
762
789
|
passes: 2
|
|
763
790
|
});
|
|
764
791
|
case 18:
|
|
765
|
-
res =
|
|
792
|
+
res = _context22.sent;
|
|
766
793
|
pid = res.headers.get("process");
|
|
767
|
-
(_this$
|
|
768
|
-
return
|
|
794
|
+
(_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
|
|
795
|
+
return _context22.abrupt("return", {
|
|
796
|
+
pid: pid,
|
|
797
|
+
res: res
|
|
798
|
+
});
|
|
769
799
|
case 22:
|
|
770
800
|
case "end":
|
|
771
|
-
return
|
|
801
|
+
return _context22.stop();
|
|
772
802
|
}
|
|
773
|
-
},
|
|
803
|
+
}, _callee22, this);
|
|
774
804
|
}));
|
|
775
|
-
function spawnAOS(
|
|
805
|
+
function spawnAOS(_x18) {
|
|
776
806
|
return _spawnAOS.apply(this, arguments);
|
|
777
807
|
}
|
|
778
808
|
return spawnAOS;
|
|
@@ -862,59 +892,59 @@ var HB = /*#__PURE__*/function () {
|
|
|
862
892
|
}, {
|
|
863
893
|
key: "messages",
|
|
864
894
|
value: function () {
|
|
865
|
-
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
895
|
+
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
866
896
|
var _this2 = this;
|
|
867
|
-
var
|
|
868
|
-
|
|
897
|
+
var _ref9,
|
|
898
|
+
pid,
|
|
869
899
|
from,
|
|
870
900
|
to,
|
|
871
901
|
limit,
|
|
872
902
|
params,
|
|
873
903
|
res,
|
|
874
|
-
|
|
875
|
-
return _regeneratorRuntime().wrap(function
|
|
876
|
-
while (1) switch (
|
|
904
|
+
_args24 = arguments;
|
|
905
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
906
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
877
907
|
case 0:
|
|
878
|
-
|
|
879
|
-
params = "target=".concat(
|
|
908
|
+
_ref9 = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {}, pid = _ref9.pid, from = _ref9.from, to = _ref9.to, limit = _ref9.limit;
|
|
909
|
+
params = "target=".concat(pid);
|
|
880
910
|
if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
|
|
881
911
|
if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
|
|
882
912
|
params += "&accept=application/aos-2";
|
|
883
|
-
|
|
913
|
+
_context24.next = 7;
|
|
884
914
|
return fetch("".concat(this.url, "/~scheduler@1.0/schedule?").concat(params)).then(function (r) {
|
|
885
915
|
return r.json();
|
|
886
916
|
});
|
|
887
917
|
case 7:
|
|
888
|
-
res =
|
|
918
|
+
res = _context24.sent;
|
|
889
919
|
if (res.page_info.has_next_page) {
|
|
890
|
-
res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
920
|
+
res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
891
921
|
var from2;
|
|
892
|
-
return _regeneratorRuntime().wrap(function
|
|
893
|
-
while (1) switch (
|
|
922
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
923
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
894
924
|
case 0:
|
|
895
925
|
from2 = (0, _ramda.last)(res.edges).cursor + 1;
|
|
896
|
-
|
|
926
|
+
_context23.next = 3;
|
|
897
927
|
return _this2.message({
|
|
898
|
-
|
|
928
|
+
pid: pid,
|
|
899
929
|
from: from2,
|
|
900
930
|
to: to,
|
|
901
931
|
limit: limit
|
|
902
932
|
});
|
|
903
933
|
case 3:
|
|
904
|
-
return
|
|
934
|
+
return _context23.abrupt("return", _context23.sent);
|
|
905
935
|
case 4:
|
|
906
936
|
case "end":
|
|
907
|
-
return
|
|
937
|
+
return _context23.stop();
|
|
908
938
|
}
|
|
909
|
-
},
|
|
939
|
+
}, _callee23);
|
|
910
940
|
}));
|
|
911
941
|
}
|
|
912
|
-
return
|
|
942
|
+
return _context24.abrupt("return", res);
|
|
913
943
|
case 10:
|
|
914
944
|
case "end":
|
|
915
|
-
return
|
|
945
|
+
return _context24.stop();
|
|
916
946
|
}
|
|
917
|
-
},
|
|
947
|
+
}, _callee24, this);
|
|
918
948
|
}));
|
|
919
949
|
function messages() {
|
|
920
950
|
return _messages.apply(this, arguments);
|
|
@@ -922,19 +952,18 @@ var HB = /*#__PURE__*/function () {
|
|
|
922
952
|
return messages;
|
|
923
953
|
}()
|
|
924
954
|
}, {
|
|
925
|
-
key: "
|
|
955
|
+
key: "spawnLegacy",
|
|
926
956
|
value: function () {
|
|
927
|
-
var
|
|
928
|
-
var
|
|
929
|
-
|
|
957
|
+
var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
958
|
+
var _ref11,
|
|
959
|
+
_ref11$tags,
|
|
930
960
|
tags,
|
|
931
961
|
data,
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
962
|
+
_args25 = arguments;
|
|
963
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
964
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
936
965
|
case 0:
|
|
937
|
-
|
|
966
|
+
_ref11 = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {}, _ref11$tags = _ref11.tags, tags = _ref11$tags === void 0 ? {} : _ref11$tags, data = _ref11.data;
|
|
938
967
|
tags = (0, _ramda.mergeLeft)(tags, {
|
|
939
968
|
data: data,
|
|
940
969
|
Type: "Process",
|
|
@@ -949,23 +978,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
949
978
|
"scheduler-device": "scheduler@1.0",
|
|
950
979
|
"execution-device": "genesis-wasm@1.0"
|
|
951
980
|
});
|
|
952
|
-
|
|
953
|
-
return this.
|
|
954
|
-
tags: tags
|
|
955
|
-
});
|
|
981
|
+
_context25.next = 4;
|
|
982
|
+
return this.spawn(tags);
|
|
956
983
|
case 4:
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
case 6:
|
|
984
|
+
return _context25.abrupt("return", _context25.sent);
|
|
985
|
+
case 5:
|
|
960
986
|
case "end":
|
|
961
|
-
return
|
|
987
|
+
return _context25.stop();
|
|
962
988
|
}
|
|
963
|
-
},
|
|
989
|
+
}, _callee25, this);
|
|
964
990
|
}));
|
|
965
|
-
function
|
|
966
|
-
return
|
|
991
|
+
function spawnLegacy() {
|
|
992
|
+
return _spawnLegacy.apply(this, arguments);
|
|
967
993
|
}
|
|
968
|
-
return
|
|
994
|
+
return spawnLegacy;
|
|
969
995
|
}()
|
|
970
996
|
/*
|
|
971
997
|
async scheduleLegacy({ tags = {}, data, process, action = "Eval" } = {}) {
|
|
@@ -983,41 +1009,41 @@ var HB = /*#__PURE__*/function () {
|
|
|
983
1009
|
}, {
|
|
984
1010
|
key: "dryrun",
|
|
985
1011
|
value: (function () {
|
|
986
|
-
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
987
|
-
var
|
|
988
|
-
|
|
1012
|
+
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1013
|
+
var _ref12,
|
|
1014
|
+
_ref12$tags,
|
|
989
1015
|
tags,
|
|
990
|
-
|
|
1016
|
+
pid,
|
|
991
1017
|
action,
|
|
992
1018
|
data,
|
|
993
1019
|
json,
|
|
994
1020
|
res,
|
|
995
|
-
|
|
996
|
-
return _regeneratorRuntime().wrap(function
|
|
997
|
-
while (1) switch (
|
|
1021
|
+
_args26 = arguments;
|
|
1022
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1023
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
998
1024
|
case 0:
|
|
999
|
-
|
|
1025
|
+
_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;
|
|
1000
1026
|
if (typeof action === "string") tags.Action = action;
|
|
1001
1027
|
json = {
|
|
1002
1028
|
Tags: (0, _utils.buildTags)(tags)
|
|
1003
1029
|
};
|
|
1004
1030
|
if (data) json.Data = data;
|
|
1005
|
-
|
|
1031
|
+
_context26.next = 6;
|
|
1006
1032
|
return this.send({
|
|
1007
1033
|
path: "/~relay@1.0/call",
|
|
1008
1034
|
"relay-method": "POST",
|
|
1009
|
-
"relay-path": "/dry-run?process-id=".concat(
|
|
1035
|
+
"relay-path": "/dry-run?process-id=".concat(pid),
|
|
1010
1036
|
"content-type": "application/json",
|
|
1011
1037
|
body: JSON.stringify(json)
|
|
1012
1038
|
});
|
|
1013
1039
|
case 6:
|
|
1014
|
-
res =
|
|
1015
|
-
return
|
|
1040
|
+
res = _context26.sent;
|
|
1041
|
+
return _context26.abrupt("return", JSON.parse(res.body));
|
|
1016
1042
|
case 8:
|
|
1017
1043
|
case "end":
|
|
1018
|
-
return
|
|
1044
|
+
return _context26.stop();
|
|
1019
1045
|
}
|
|
1020
|
-
},
|
|
1046
|
+
}, _callee26, this);
|
|
1021
1047
|
}));
|
|
1022
1048
|
function dryrun() {
|
|
1023
1049
|
return _dryrun.apply(this, arguments);
|
|
@@ -1027,27 +1053,27 @@ var HB = /*#__PURE__*/function () {
|
|
|
1027
1053
|
}, {
|
|
1028
1054
|
key: "get",
|
|
1029
1055
|
value: function () {
|
|
1030
|
-
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1031
|
-
var device,
|
|
1032
|
-
return _regeneratorRuntime().wrap(function
|
|
1033
|
-
while (1) switch (
|
|
1056
|
+
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref13) {
|
|
1057
|
+
var device, _ref13$path, path;
|
|
1058
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1059
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1034
1060
|
case 0:
|
|
1035
|
-
device =
|
|
1036
|
-
|
|
1061
|
+
device = _ref13.device, _ref13$path = _ref13.path, path = _ref13$path === void 0 ? "~meta@1.0/info" : _ref13$path;
|
|
1062
|
+
_context27.next = 3;
|
|
1037
1063
|
return this.request({
|
|
1038
1064
|
device: device,
|
|
1039
1065
|
path: path,
|
|
1040
1066
|
method: "GET"
|
|
1041
1067
|
});
|
|
1042
1068
|
case 3:
|
|
1043
|
-
return
|
|
1069
|
+
return _context27.abrupt("return", _context27.sent.body);
|
|
1044
1070
|
case 4:
|
|
1045
1071
|
case "end":
|
|
1046
|
-
return
|
|
1072
|
+
return _context27.stop();
|
|
1047
1073
|
}
|
|
1048
|
-
},
|
|
1074
|
+
}, _callee27, this);
|
|
1049
1075
|
}));
|
|
1050
|
-
function get(
|
|
1076
|
+
function get(_x19) {
|
|
1051
1077
|
return _get.apply(this, arguments);
|
|
1052
1078
|
}
|
|
1053
1079
|
return get;
|
|
@@ -1055,13 +1081,13 @@ var HB = /*#__PURE__*/function () {
|
|
|
1055
1081
|
}, {
|
|
1056
1082
|
key: "post",
|
|
1057
1083
|
value: function () {
|
|
1058
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1059
|
-
var device, tags,
|
|
1060
|
-
return _regeneratorRuntime().wrap(function
|
|
1061
|
-
while (1) switch (
|
|
1084
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref14) {
|
|
1085
|
+
var device, tags, _ref14$path, path;
|
|
1086
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1087
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1062
1088
|
case 0:
|
|
1063
|
-
device =
|
|
1064
|
-
|
|
1089
|
+
device = _ref14.device, tags = _ref14.tags, _ref14$path = _ref14.path, path = _ref14$path === void 0 ? "/schedule" : _ref14$path;
|
|
1090
|
+
_context28.next = 3;
|
|
1065
1091
|
return this.request({
|
|
1066
1092
|
tags: tags,
|
|
1067
1093
|
device: device,
|
|
@@ -1069,14 +1095,14 @@ var HB = /*#__PURE__*/function () {
|
|
|
1069
1095
|
method: "POST"
|
|
1070
1096
|
});
|
|
1071
1097
|
case 3:
|
|
1072
|
-
return
|
|
1098
|
+
return _context28.abrupt("return", _context28.sent);
|
|
1073
1099
|
case 4:
|
|
1074
1100
|
case "end":
|
|
1075
|
-
return
|
|
1101
|
+
return _context28.stop();
|
|
1076
1102
|
}
|
|
1077
|
-
},
|
|
1103
|
+
}, _callee28, this);
|
|
1078
1104
|
}));
|
|
1079
|
-
function post(
|
|
1105
|
+
function post(_x20) {
|
|
1080
1106
|
return _post.apply(this, arguments);
|
|
1081
1107
|
}
|
|
1082
1108
|
return post;
|
|
@@ -1084,28 +1110,28 @@ var HB = /*#__PURE__*/function () {
|
|
|
1084
1110
|
}, {
|
|
1085
1111
|
key: "request",
|
|
1086
1112
|
value: function () {
|
|
1087
|
-
var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1088
|
-
var device, tags,
|
|
1089
|
-
return _regeneratorRuntime().wrap(function
|
|
1090
|
-
while (1) switch (
|
|
1113
|
+
var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(_ref15) {
|
|
1114
|
+
var device, tags, _ref15$method, method, _ref15$path, path, _tags;
|
|
1115
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
1116
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1091
1117
|
case 0:
|
|
1092
|
-
device =
|
|
1118
|
+
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;
|
|
1093
1119
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
1094
1120
|
path: path,
|
|
1095
1121
|
method: method
|
|
1096
1122
|
});
|
|
1097
1123
|
if (device) _tags.device = device;
|
|
1098
|
-
|
|
1124
|
+
_context29.next = 5;
|
|
1099
1125
|
return this._request(_tags);
|
|
1100
1126
|
case 5:
|
|
1101
|
-
return
|
|
1127
|
+
return _context29.abrupt("return", _context29.sent);
|
|
1102
1128
|
case 6:
|
|
1103
1129
|
case "end":
|
|
1104
|
-
return
|
|
1130
|
+
return _context29.stop();
|
|
1105
1131
|
}
|
|
1106
|
-
},
|
|
1132
|
+
}, _callee29, this);
|
|
1107
1133
|
}));
|
|
1108
|
-
function request(
|
|
1134
|
+
function request(_x21) {
|
|
1109
1135
|
return _request.apply(this, arguments);
|
|
1110
1136
|
}
|
|
1111
1137
|
return request;
|
package/cjs/test.js
CHANGED
|
@@ -103,6 +103,12 @@ Object.defineProperty(exports, "su", {
|
|
|
103
103
|
return _accounts.su;
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
|
+
Object.defineProperty(exports, "toAddr", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function get() {
|
|
109
|
+
return _utils.toAddr;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
106
112
|
Object.defineProperty(exports, "wait", {
|
|
107
113
|
enumerable: true,
|
|
108
114
|
get: function get() {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import assert from "assert"
|
|
2
|
+
import { describe, it, before, after, beforeEach } from "node:test"
|
|
3
|
+
import { wait, toAddr } from "wao/test"
|
|
4
|
+
import { HyperBEAM, HB } from "wao"
|
|
5
|
+
import { resolve } from "path"
|
|
6
|
+
import { readFileSync } from "fs"
|
|
7
|
+
|
|
8
|
+
const cwd = "../../HyperBEAM"
|
|
9
|
+
const wallet = ".wallet.json"
|
|
10
|
+
|
|
11
|
+
describe("HyperBEAM", function () {
|
|
12
|
+
let hbeam, hb, jwk
|
|
13
|
+
|
|
14
|
+
before(async () => {
|
|
15
|
+
hbeam = new HyperBEAM({ cwd, wallet })
|
|
16
|
+
jwk = JSON.parse(
|
|
17
|
+
readFileSync(resolve(import.meta.dirname, cwd, wallet), "utf8")
|
|
18
|
+
)
|
|
19
|
+
await wait(5000)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => (hb = await new HB({}).init(jwk)))
|
|
23
|
+
|
|
24
|
+
after(async () => hbeam.kill())
|
|
25
|
+
|
|
26
|
+
it("should run a HyperBEAM node", async () => {
|
|
27
|
+
const info = await hb.meta.info()
|
|
28
|
+
assert.equal(info.address, toAddr(jwk.n))
|
|
29
|
+
})
|
|
30
|
+
})
|
package/esm/aoconnect-base.js
CHANGED
|
@@ -659,9 +659,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
|
|
|
659
659
|
try {
|
|
660
660
|
const p = await mem.get("env", pid)
|
|
661
661
|
const from = p ? p.results.length : 0
|
|
662
|
-
const msgs = next
|
|
663
|
-
? await next()
|
|
664
|
-
: await hb.messages({ target: pid, from })
|
|
662
|
+
const msgs = next ? await next() : await hb.messages({ pid, from })
|
|
665
663
|
for (let v of msgs.edges) {
|
|
666
664
|
let item = {}
|
|
667
665
|
for (let k in v.node.message) {
|
package/esm/hb.js
CHANGED
|
@@ -136,21 +136,21 @@ class HB {
|
|
|
136
136
|
).then(r => r.json())
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
async compute(pid, slot) {
|
|
139
|
+
async compute({ pid, slot }) {
|
|
140
140
|
return await fetch(
|
|
141
141
|
`${this.url}/${pid}/compute/serialize~json@1.0?slot=${slot}`
|
|
142
142
|
).then(r => r.json())
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
async computeLegacy(pid, slot) {
|
|
146
|
-
const json = await this.compute(pid, slot)
|
|
145
|
+
async computeLegacy({ pid, slot }) {
|
|
146
|
+
const json = await this.compute({ pid, slot })
|
|
147
147
|
return JSON.parse(json.results.json.body)
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
async spawn(tags = {}) {
|
|
151
151
|
const addr = await this.meta.info({ key: "address" })
|
|
152
152
|
this.scheduler ??= addr
|
|
153
|
-
const
|
|
153
|
+
const res = await this.send(
|
|
154
154
|
mergeLeft(tags, {
|
|
155
155
|
device: "process@1.0",
|
|
156
156
|
path: "/schedule",
|
|
@@ -158,26 +158,32 @@ class HB {
|
|
|
158
158
|
"random-seed": seed(16),
|
|
159
159
|
Type: "Process",
|
|
160
160
|
"scheduler-device": "scheduler@1.0",
|
|
161
|
-
"execution-device": "
|
|
161
|
+
"execution-device": "test-device@1.0",
|
|
162
162
|
})
|
|
163
163
|
)
|
|
164
|
-
|
|
165
|
-
this.pid ??= pid
|
|
166
|
-
const res = await this.compute(pid, 0)
|
|
167
|
-
return { spawned: res, pid, res }
|
|
164
|
+
return { res, pid: res.headers.get("process") }
|
|
168
165
|
}
|
|
169
166
|
|
|
170
|
-
async message(
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
|
|
167
|
+
async message(args) {
|
|
168
|
+
const pid = args.pid
|
|
169
|
+
const { slot } = await this.schedule(args)
|
|
170
|
+
const res = await this.compute({ pid, slot })
|
|
171
|
+
return { slot, pid, res }
|
|
172
|
+
}
|
|
173
|
+
async scheduleLegacy({
|
|
174
|
+
pid,
|
|
175
|
+
action = "Eval",
|
|
176
|
+
tags = {},
|
|
177
|
+
data,
|
|
178
|
+
scheduler,
|
|
179
|
+
} = {}) {
|
|
180
|
+
if (action) tags.Action = action
|
|
181
|
+
return await this.schedule({ pid, tags, data, scheduler })
|
|
174
182
|
}
|
|
175
|
-
|
|
176
183
|
async schedule({ pid, tags = {}, data, scheduler } = {}) {
|
|
177
184
|
pid ??= this.pid
|
|
178
185
|
scheduler ??= this.scheduler
|
|
179
186
|
let _tags = mergeLeft(tags, {
|
|
180
|
-
device: "process@1.0",
|
|
181
187
|
method: "POST",
|
|
182
188
|
path: `/${pid}/schedule`,
|
|
183
189
|
scheduler,
|
|
@@ -186,8 +192,7 @@ class HB {
|
|
|
186
192
|
})
|
|
187
193
|
if (data) _tags.data = data
|
|
188
194
|
let res = await this.send(_tags)
|
|
189
|
-
|
|
190
|
-
return { slot, res, pid }
|
|
195
|
+
return { slot: res.headers.get("slot"), res }
|
|
191
196
|
}
|
|
192
197
|
|
|
193
198
|
async spawnAOS(image) {
|
|
@@ -220,7 +225,7 @@ class HB {
|
|
|
220
225
|
})
|
|
221
226
|
const pid = res.headers.get("process")
|
|
222
227
|
this.pid ??= pid
|
|
223
|
-
return pid
|
|
228
|
+
return { pid, res }
|
|
224
229
|
}
|
|
225
230
|
|
|
226
231
|
parseMetrics(txt) {
|
|
@@ -255,8 +260,8 @@ class HB {
|
|
|
255
260
|
return _metrics
|
|
256
261
|
}
|
|
257
262
|
|
|
258
|
-
async messages({
|
|
259
|
-
let params = `target=${
|
|
263
|
+
async messages({ pid, from, to, limit } = {}) {
|
|
264
|
+
let params = `target=${pid}`
|
|
260
265
|
if (isNotNil(from)) params += `&from=${from}`
|
|
261
266
|
if (isNotNil(to)) params += `&to=${to}`
|
|
262
267
|
params += `&accept=application/aos-2`
|
|
@@ -266,13 +271,13 @@ class HB {
|
|
|
266
271
|
if (res.page_info.has_next_page) {
|
|
267
272
|
res.next = async () => {
|
|
268
273
|
const from2 = last(res.edges).cursor + 1
|
|
269
|
-
return await this.message({
|
|
274
|
+
return await this.message({ pid, from: from2, to, limit })
|
|
270
275
|
}
|
|
271
276
|
}
|
|
272
277
|
return res
|
|
273
278
|
}
|
|
274
279
|
|
|
275
|
-
async
|
|
280
|
+
async spawnLegacy({ tags = {}, data } = {}) {
|
|
276
281
|
tags = mergeLeft(tags, {
|
|
277
282
|
data,
|
|
278
283
|
Type: "Process",
|
|
@@ -287,8 +292,7 @@ class HB {
|
|
|
287
292
|
"scheduler-device": "scheduler@1.0",
|
|
288
293
|
"execution-device": "genesis-wasm@1.0",
|
|
289
294
|
})
|
|
290
|
-
|
|
291
|
-
return res.process
|
|
295
|
+
return await this.spawn(tags)
|
|
292
296
|
}
|
|
293
297
|
|
|
294
298
|
/*
|
|
@@ -305,14 +309,14 @@ class HB {
|
|
|
305
309
|
}
|
|
306
310
|
*/
|
|
307
311
|
|
|
308
|
-
async dryrun({ tags = {},
|
|
312
|
+
async dryrun({ tags = {}, pid, action, data } = {}) {
|
|
309
313
|
if (typeof action === "string") tags.Action = action
|
|
310
314
|
let json = { Tags: buildTags(tags) }
|
|
311
315
|
if (data) json.Data = data
|
|
312
316
|
const res = await this.send({
|
|
313
317
|
path: "/~relay@1.0/call",
|
|
314
318
|
"relay-method": "POST",
|
|
315
|
-
"relay-path": `/dry-run?process-id=${
|
|
319
|
+
"relay-path": `/dry-run?process-id=${pid}`,
|
|
316
320
|
"content-type": "application/json",
|
|
317
321
|
body: JSON.stringify(json),
|
|
318
322
|
})
|
package/esm/test.js
CHANGED
|
@@ -6,7 +6,7 @@ import AO from "./tao.js"
|
|
|
6
6
|
import AR from "./tar.js"
|
|
7
7
|
import GQL from "./tgql.js"
|
|
8
8
|
import ArMem from "./armem.js"
|
|
9
|
-
import { dirname, wait } from "./utils.js"
|
|
9
|
+
import { toAddr, dirname, wait } from "./utils.js"
|
|
10
10
|
import { Testnet, Src, setup, ok, fail } from "./helpers.js"
|
|
11
11
|
import Server from "./server.js"
|
|
12
12
|
import Adaptor from "./adaptor.js"
|
|
@@ -18,6 +18,7 @@ const scheduler = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
|
|
|
18
18
|
const HyperBEAM = "./hyperbeam.js"
|
|
19
19
|
|
|
20
20
|
export {
|
|
21
|
+
toAddr,
|
|
21
22
|
wait,
|
|
22
23
|
HyperBEAM,
|
|
23
24
|
Adaptor,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import assert from "assert"
|
|
2
|
+
import { describe, it, before, after, beforeEach } from "node:test"
|
|
3
|
+
import { wait, toAddr } from "wao/test"
|
|
4
|
+
import { HyperBEAM, HB } from "wao"
|
|
5
|
+
import { resolve } from "path"
|
|
6
|
+
import { readFileSync } from "fs"
|
|
7
|
+
|
|
8
|
+
const cwd = "../../HyperBEAM"
|
|
9
|
+
const wallet = ".wallet.json"
|
|
10
|
+
|
|
11
|
+
describe("HyperBEAM", function () {
|
|
12
|
+
let hbeam, hb, jwk
|
|
13
|
+
|
|
14
|
+
before(async () => {
|
|
15
|
+
hbeam = new HyperBEAM({ cwd, wallet })
|
|
16
|
+
jwk = JSON.parse(
|
|
17
|
+
readFileSync(resolve(import.meta.dirname, cwd, wallet), "utf8")
|
|
18
|
+
)
|
|
19
|
+
await wait(5000)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => (hb = await new HB({}).init(jwk)))
|
|
23
|
+
|
|
24
|
+
after(async () => hbeam.kill())
|
|
25
|
+
|
|
26
|
+
it("should run a HyperBEAM node", async () => {
|
|
27
|
+
const info = await hb.meta.info()
|
|
28
|
+
assert.equal(info.address, toAddr(jwk.n))
|
|
29
|
+
})
|
|
30
|
+
})
|