wao 0.22.2 → 0.22.4
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 +162 -129
- package/esm/aoconnect-base.js +1 -3
- package/esm/hb.js +31 -22
- package/package.json +1 -1
package/cjs/aoconnect-base.js
CHANGED
package/cjs/hb.js
CHANGED
|
@@ -42,7 +42,8 @@ var HB = /*#__PURE__*/function () {
|
|
|
42
42
|
jwk = _ref.jwk;
|
|
43
43
|
_classCallCheck(this, HB);
|
|
44
44
|
this.url = url;
|
|
45
|
-
this.
|
|
45
|
+
this.dev = {};
|
|
46
|
+
this.dev.hyperbuddy = {
|
|
46
47
|
metrics: function () {
|
|
47
48
|
var _metrics2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
48
49
|
var args,
|
|
@@ -69,7 +70,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
69
70
|
return metrics;
|
|
70
71
|
}()
|
|
71
72
|
};
|
|
72
|
-
this.json = {
|
|
73
|
+
this.dev.json = {
|
|
73
74
|
commit: function () {
|
|
74
75
|
var _commit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(args) {
|
|
75
76
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -159,7 +160,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
159
160
|
return serialize;
|
|
160
161
|
}()
|
|
161
162
|
};
|
|
162
|
-
this.meta = {
|
|
163
|
+
this.dev.meta = {
|
|
163
164
|
info: function () {
|
|
164
165
|
var _info = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
165
166
|
var args,
|
|
@@ -265,7 +266,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
265
266
|
case 0:
|
|
266
267
|
this._init(jwk);
|
|
267
268
|
_context8.next = 3;
|
|
268
|
-
return this.meta.info({});
|
|
269
|
+
return this.dev.meta.info({});
|
|
269
270
|
case 3:
|
|
270
271
|
this._info = _context8.sent;
|
|
271
272
|
return _context8.abrupt("return", this);
|
|
@@ -400,7 +401,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
400
401
|
i++;
|
|
401
402
|
}
|
|
402
403
|
}
|
|
403
|
-
return "".concat(this.url, "/~").concat(dev, "/").concat(_path).concat(json ? "
|
|
404
|
+
return "".concat(this.url, "/~").concat(dev, "/").concat(_path).concat(json ? "/~json@1.0/serialize" : "").concat(_params);
|
|
404
405
|
}
|
|
405
406
|
}, {
|
|
406
407
|
key: "text",
|
|
@@ -490,7 +491,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
490
491
|
case 0:
|
|
491
492
|
pid = _ref4.pid, slot = _ref4.slot;
|
|
492
493
|
_context15.next = 3;
|
|
493
|
-
return fetch("".concat(this.url, "/").concat(pid, "/compute/results/outbox
|
|
494
|
+
return fetch("".concat(this.url, "/").concat(pid, "/compute/results/outbox/~json@1.0/serialize?slot=").concat(slot)).then(function (r) {
|
|
494
495
|
return r.json();
|
|
495
496
|
});
|
|
496
497
|
case 3:
|
|
@@ -516,7 +517,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
516
517
|
case 0:
|
|
517
518
|
pid = _ref5.pid, slot = _ref5.slot;
|
|
518
519
|
_context16.next = 3;
|
|
519
|
-
return fetch("".concat(this.url, "/").concat(pid, "/compute
|
|
520
|
+
return fetch("".concat(this.url, "/").concat(pid, "/compute/~json@1.0/serialize?slot=").concat(slot)).then(function (r) {
|
|
520
521
|
return r.json();
|
|
521
522
|
});
|
|
522
523
|
case 3:
|
|
@@ -574,7 +575,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
574
575
|
case 0:
|
|
575
576
|
tags = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
|
|
576
577
|
_context18.next = 3;
|
|
577
|
-
return this.meta.info({
|
|
578
|
+
return this.dev.meta.info({
|
|
578
579
|
key: "address"
|
|
579
580
|
});
|
|
580
581
|
case 3:
|
|
@@ -588,7 +589,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
588
589
|
"random-seed": seed(16),
|
|
589
590
|
Type: "Process",
|
|
590
591
|
"scheduler-device": "scheduler@1.0",
|
|
591
|
-
"execution-device": "
|
|
592
|
+
"execution-device": "test-device@1.0"
|
|
592
593
|
}));
|
|
593
594
|
case 7:
|
|
594
595
|
res = _context18.sent;
|
|
@@ -611,7 +612,7 @@ var HB = /*#__PURE__*/function () {
|
|
|
611
612
|
key: "message",
|
|
612
613
|
value: function () {
|
|
613
614
|
var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(args) {
|
|
614
|
-
var pid, slot, res;
|
|
615
|
+
var pid, _yield$this$schedule, slot, res;
|
|
615
616
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
616
617
|
while (1) switch (_context19.prev = _context19.next) {
|
|
617
618
|
case 0:
|
|
@@ -619,20 +620,21 @@ var HB = /*#__PURE__*/function () {
|
|
|
619
620
|
_context19.next = 3;
|
|
620
621
|
return this.schedule(args);
|
|
621
622
|
case 3:
|
|
622
|
-
|
|
623
|
-
|
|
623
|
+
_yield$this$schedule = _context19.sent;
|
|
624
|
+
slot = _yield$this$schedule.slot;
|
|
625
|
+
_context19.next = 7;
|
|
624
626
|
return this.compute({
|
|
625
627
|
pid: pid,
|
|
626
628
|
slot: slot
|
|
627
629
|
});
|
|
628
|
-
case
|
|
630
|
+
case 7:
|
|
629
631
|
res = _context19.sent;
|
|
630
632
|
return _context19.abrupt("return", {
|
|
631
633
|
slot: slot,
|
|
632
634
|
pid: pid,
|
|
633
635
|
res: res
|
|
634
636
|
});
|
|
635
|
-
case
|
|
637
|
+
case 9:
|
|
636
638
|
case "end":
|
|
637
639
|
return _context19.stop();
|
|
638
640
|
}
|
|
@@ -644,23 +646,61 @@ var HB = /*#__PURE__*/function () {
|
|
|
644
646
|
return message;
|
|
645
647
|
}()
|
|
646
648
|
}, {
|
|
647
|
-
key: "
|
|
649
|
+
key: "scheduleLegacy",
|
|
648
650
|
value: function () {
|
|
649
|
-
var
|
|
650
|
-
var _pid2, _scheduler;
|
|
651
|
+
var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
651
652
|
var _ref7,
|
|
652
653
|
pid,
|
|
654
|
+
_ref7$action,
|
|
655
|
+
action,
|
|
653
656
|
_ref7$tags,
|
|
654
657
|
tags,
|
|
655
658
|
data,
|
|
656
659
|
scheduler,
|
|
657
|
-
_tags,
|
|
658
|
-
res,
|
|
659
660
|
_args20 = arguments;
|
|
660
661
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
661
662
|
while (1) switch (_context20.prev = _context20.next) {
|
|
662
663
|
case 0:
|
|
663
|
-
_ref7 = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {}, pid = _ref7.pid, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data, scheduler = _ref7.scheduler;
|
|
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;
|
|
665
|
+
if (action) tags.Action = action;
|
|
666
|
+
_context20.next = 4;
|
|
667
|
+
return this.schedule({
|
|
668
|
+
pid: pid,
|
|
669
|
+
tags: tags,
|
|
670
|
+
data: data,
|
|
671
|
+
scheduler: scheduler
|
|
672
|
+
});
|
|
673
|
+
case 4:
|
|
674
|
+
return _context20.abrupt("return", _context20.sent);
|
|
675
|
+
case 5:
|
|
676
|
+
case "end":
|
|
677
|
+
return _context20.stop();
|
|
678
|
+
}
|
|
679
|
+
}, _callee20, this);
|
|
680
|
+
}));
|
|
681
|
+
function scheduleLegacy() {
|
|
682
|
+
return _scheduleLegacy.apply(this, arguments);
|
|
683
|
+
}
|
|
684
|
+
return scheduleLegacy;
|
|
685
|
+
}()
|
|
686
|
+
}, {
|
|
687
|
+
key: "schedule",
|
|
688
|
+
value: function () {
|
|
689
|
+
var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
690
|
+
var _pid2, _scheduler;
|
|
691
|
+
var _ref8,
|
|
692
|
+
pid,
|
|
693
|
+
_ref8$tags,
|
|
694
|
+
tags,
|
|
695
|
+
data,
|
|
696
|
+
scheduler,
|
|
697
|
+
_tags,
|
|
698
|
+
res,
|
|
699
|
+
_args21 = arguments;
|
|
700
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
701
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
702
|
+
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;
|
|
664
704
|
(_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
|
|
665
705
|
(_scheduler = scheduler) !== null && _scheduler !== void 0 ? _scheduler : scheduler = this.scheduler;
|
|
666
706
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
@@ -671,19 +711,19 @@ var HB = /*#__PURE__*/function () {
|
|
|
671
711
|
Target: pid
|
|
672
712
|
});
|
|
673
713
|
if (data) _tags.data = data;
|
|
674
|
-
|
|
714
|
+
_context21.next = 7;
|
|
675
715
|
return this.send(_tags);
|
|
676
716
|
case 7:
|
|
677
|
-
res =
|
|
678
|
-
return
|
|
717
|
+
res = _context21.sent;
|
|
718
|
+
return _context21.abrupt("return", {
|
|
679
719
|
slot: res.headers.get("slot"),
|
|
680
720
|
res: res
|
|
681
721
|
});
|
|
682
722
|
case 9:
|
|
683
723
|
case "end":
|
|
684
|
-
return
|
|
724
|
+
return _context21.stop();
|
|
685
725
|
}
|
|
686
|
-
},
|
|
726
|
+
}, _callee21, this);
|
|
687
727
|
}));
|
|
688
728
|
function schedule() {
|
|
689
729
|
return _schedule.apply(this, arguments);
|
|
@@ -693,43 +733,43 @@ var HB = /*#__PURE__*/function () {
|
|
|
693
733
|
}, {
|
|
694
734
|
key: "spawnAOS",
|
|
695
735
|
value: function () {
|
|
696
|
-
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
736
|
+
var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(image) {
|
|
697
737
|
var _this$scheduler2, _image, _this$image, _this$pid;
|
|
698
738
|
var addr, res, pid;
|
|
699
|
-
return _regeneratorRuntime().wrap(function
|
|
700
|
-
while (1) switch (
|
|
739
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
740
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
701
741
|
case 0:
|
|
702
|
-
|
|
703
|
-
return this.meta.info({
|
|
742
|
+
_context22.next = 2;
|
|
743
|
+
return this.dev.meta.info({
|
|
704
744
|
key: "address"
|
|
705
745
|
});
|
|
706
746
|
case 2:
|
|
707
|
-
addr =
|
|
747
|
+
addr = _context22.sent;
|
|
708
748
|
(_this$scheduler2 = this.scheduler) !== null && _this$scheduler2 !== void 0 ? _this$scheduler2 : this.scheduler = addr;
|
|
709
749
|
if (!((_image = image) !== null && _image !== void 0)) {
|
|
710
|
-
|
|
750
|
+
_context22.next = 8;
|
|
711
751
|
break;
|
|
712
752
|
}
|
|
713
753
|
_image;
|
|
714
|
-
|
|
754
|
+
_context22.next = 16;
|
|
715
755
|
break;
|
|
716
756
|
case 8:
|
|
717
757
|
if (!((_this$image = this.image) !== null && _this$image !== void 0)) {
|
|
718
|
-
|
|
758
|
+
_context22.next = 12;
|
|
719
759
|
break;
|
|
720
760
|
}
|
|
721
|
-
|
|
722
|
-
|
|
761
|
+
_context22.t0 = _this$image;
|
|
762
|
+
_context22.next = 15;
|
|
723
763
|
break;
|
|
724
764
|
case 12:
|
|
725
|
-
|
|
765
|
+
_context22.next = 14;
|
|
726
766
|
return this.getImage();
|
|
727
767
|
case 14:
|
|
728
|
-
|
|
768
|
+
_context22.t0 = _context22.sent;
|
|
729
769
|
case 15:
|
|
730
|
-
image =
|
|
770
|
+
image = _context22.t0;
|
|
731
771
|
case 16:
|
|
732
|
-
|
|
772
|
+
_context22.next = 18;
|
|
733
773
|
return this.send({
|
|
734
774
|
device: "process@1.0",
|
|
735
775
|
path: "/schedule",
|
|
@@ -750,18 +790,18 @@ var HB = /*#__PURE__*/function () {
|
|
|
750
790
|
passes: 2
|
|
751
791
|
});
|
|
752
792
|
case 18:
|
|
753
|
-
res =
|
|
793
|
+
res = _context22.sent;
|
|
754
794
|
pid = res.headers.get("process");
|
|
755
795
|
(_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
|
|
756
|
-
return
|
|
796
|
+
return _context22.abrupt("return", {
|
|
757
797
|
pid: pid,
|
|
758
798
|
res: res
|
|
759
799
|
});
|
|
760
800
|
case 22:
|
|
761
801
|
case "end":
|
|
762
|
-
return
|
|
802
|
+
return _context22.stop();
|
|
763
803
|
}
|
|
764
|
-
},
|
|
804
|
+
}, _callee22, this);
|
|
765
805
|
}));
|
|
766
806
|
function spawnAOS(_x18) {
|
|
767
807
|
return _spawnAOS.apply(this, arguments);
|
|
@@ -853,38 +893,38 @@ var HB = /*#__PURE__*/function () {
|
|
|
853
893
|
}, {
|
|
854
894
|
key: "messages",
|
|
855
895
|
value: function () {
|
|
856
|
-
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
896
|
+
var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
857
897
|
var _this2 = this;
|
|
858
|
-
var
|
|
898
|
+
var _ref9,
|
|
859
899
|
pid,
|
|
860
900
|
from,
|
|
861
901
|
to,
|
|
862
902
|
limit,
|
|
863
903
|
params,
|
|
864
904
|
res,
|
|
865
|
-
|
|
866
|
-
return _regeneratorRuntime().wrap(function
|
|
867
|
-
while (1) switch (
|
|
905
|
+
_args24 = arguments;
|
|
906
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
907
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
868
908
|
case 0:
|
|
869
|
-
|
|
909
|
+
_ref9 = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {}, pid = _ref9.pid, from = _ref9.from, to = _ref9.to, limit = _ref9.limit;
|
|
870
910
|
params = "target=".concat(pid);
|
|
871
911
|
if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
|
|
872
912
|
if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
|
|
873
913
|
params += "&accept=application/aos-2";
|
|
874
|
-
|
|
914
|
+
_context24.next = 7;
|
|
875
915
|
return fetch("".concat(this.url, "/~scheduler@1.0/schedule?").concat(params)).then(function (r) {
|
|
876
916
|
return r.json();
|
|
877
917
|
});
|
|
878
918
|
case 7:
|
|
879
|
-
res =
|
|
919
|
+
res = _context24.sent;
|
|
880
920
|
if (res.page_info.has_next_page) {
|
|
881
|
-
res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
921
|
+
res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
882
922
|
var from2;
|
|
883
|
-
return _regeneratorRuntime().wrap(function
|
|
884
|
-
while (1) switch (
|
|
923
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
924
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
885
925
|
case 0:
|
|
886
926
|
from2 = (0, _ramda.last)(res.edges).cursor + 1;
|
|
887
|
-
|
|
927
|
+
_context23.next = 3;
|
|
888
928
|
return _this2.message({
|
|
889
929
|
pid: pid,
|
|
890
930
|
from: from2,
|
|
@@ -892,20 +932,20 @@ var HB = /*#__PURE__*/function () {
|
|
|
892
932
|
limit: limit
|
|
893
933
|
});
|
|
894
934
|
case 3:
|
|
895
|
-
return
|
|
935
|
+
return _context23.abrupt("return", _context23.sent);
|
|
896
936
|
case 4:
|
|
897
937
|
case "end":
|
|
898
|
-
return
|
|
938
|
+
return _context23.stop();
|
|
899
939
|
}
|
|
900
|
-
},
|
|
940
|
+
}, _callee23);
|
|
901
941
|
}));
|
|
902
942
|
}
|
|
903
|
-
return
|
|
943
|
+
return _context24.abrupt("return", res);
|
|
904
944
|
case 10:
|
|
905
945
|
case "end":
|
|
906
|
-
return
|
|
946
|
+
return _context24.stop();
|
|
907
947
|
}
|
|
908
|
-
},
|
|
948
|
+
}, _callee24, this);
|
|
909
949
|
}));
|
|
910
950
|
function messages() {
|
|
911
951
|
return _messages.apply(this, arguments);
|
|
@@ -915,17 +955,16 @@ var HB = /*#__PURE__*/function () {
|
|
|
915
955
|
}, {
|
|
916
956
|
key: "spawnLegacy",
|
|
917
957
|
value: function () {
|
|
918
|
-
var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
919
|
-
var
|
|
920
|
-
|
|
958
|
+
var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
959
|
+
var _ref11,
|
|
960
|
+
_ref11$tags,
|
|
921
961
|
tags,
|
|
922
962
|
data,
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
963
|
+
_args25 = arguments;
|
|
964
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
965
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
927
966
|
case 0:
|
|
928
|
-
|
|
967
|
+
_ref11 = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {}, _ref11$tags = _ref11.tags, tags = _ref11$tags === void 0 ? {} : _ref11$tags, data = _ref11.data;
|
|
929
968
|
tags = (0, _ramda.mergeLeft)(tags, {
|
|
930
969
|
data: data,
|
|
931
970
|
Type: "Process",
|
|
@@ -940,21 +979,15 @@ var HB = /*#__PURE__*/function () {
|
|
|
940
979
|
"scheduler-device": "scheduler@1.0",
|
|
941
980
|
"execution-device": "genesis-wasm@1.0"
|
|
942
981
|
});
|
|
943
|
-
|
|
944
|
-
return this.
|
|
945
|
-
tags: tags
|
|
946
|
-
});
|
|
982
|
+
_context25.next = 4;
|
|
983
|
+
return this.spawn(tags);
|
|
947
984
|
case 4:
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
pid: res.process,
|
|
951
|
-
res: res
|
|
952
|
-
});
|
|
953
|
-
case 6:
|
|
985
|
+
return _context25.abrupt("return", _context25.sent);
|
|
986
|
+
case 5:
|
|
954
987
|
case "end":
|
|
955
|
-
return
|
|
988
|
+
return _context25.stop();
|
|
956
989
|
}
|
|
957
|
-
},
|
|
990
|
+
}, _callee25, this);
|
|
958
991
|
}));
|
|
959
992
|
function spawnLegacy() {
|
|
960
993
|
return _spawnLegacy.apply(this, arguments);
|
|
@@ -962,41 +995,41 @@ var HB = /*#__PURE__*/function () {
|
|
|
962
995
|
return spawnLegacy;
|
|
963
996
|
}()
|
|
964
997
|
/*
|
|
965
|
-
|
|
998
|
+
async scheduleLegacy({ tags = {}, data, process, action = "Eval" } = {}) {
|
|
966
999
|
tags = mergeLeft(tags, {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1000
|
+
path: `${process}/schedule`,
|
|
1001
|
+
type: "Message",
|
|
1002
|
+
action,
|
|
1003
|
+
data,
|
|
1004
|
+
"Data-Protocol": "ao",
|
|
1005
|
+
Variant: "ao.N.1",
|
|
973
1006
|
})
|
|
974
1007
|
return (await this.post({ tags })).slot.text()
|
|
975
|
-
|
|
1008
|
+
}
|
|
976
1009
|
*/
|
|
977
1010
|
}, {
|
|
978
1011
|
key: "dryrun",
|
|
979
1012
|
value: (function () {
|
|
980
|
-
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
981
|
-
var
|
|
982
|
-
|
|
1013
|
+
var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1014
|
+
var _ref12,
|
|
1015
|
+
_ref12$tags,
|
|
983
1016
|
tags,
|
|
984
1017
|
pid,
|
|
985
1018
|
action,
|
|
986
1019
|
data,
|
|
987
1020
|
json,
|
|
988
1021
|
res,
|
|
989
|
-
|
|
990
|
-
return _regeneratorRuntime().wrap(function
|
|
991
|
-
while (1) switch (
|
|
1022
|
+
_args26 = arguments;
|
|
1023
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1024
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
992
1025
|
case 0:
|
|
993
|
-
|
|
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;
|
|
994
1027
|
if (typeof action === "string") tags.Action = action;
|
|
995
1028
|
json = {
|
|
996
1029
|
Tags: (0, _utils.buildTags)(tags)
|
|
997
1030
|
};
|
|
998
1031
|
if (data) json.Data = data;
|
|
999
|
-
|
|
1032
|
+
_context26.next = 6;
|
|
1000
1033
|
return this.send({
|
|
1001
1034
|
path: "/~relay@1.0/call",
|
|
1002
1035
|
"relay-method": "POST",
|
|
@@ -1005,13 +1038,13 @@ var HB = /*#__PURE__*/function () {
|
|
|
1005
1038
|
body: JSON.stringify(json)
|
|
1006
1039
|
});
|
|
1007
1040
|
case 6:
|
|
1008
|
-
res =
|
|
1009
|
-
return
|
|
1041
|
+
res = _context26.sent;
|
|
1042
|
+
return _context26.abrupt("return", JSON.parse(res.body));
|
|
1010
1043
|
case 8:
|
|
1011
1044
|
case "end":
|
|
1012
|
-
return
|
|
1045
|
+
return _context26.stop();
|
|
1013
1046
|
}
|
|
1014
|
-
},
|
|
1047
|
+
}, _callee26, this);
|
|
1015
1048
|
}));
|
|
1016
1049
|
function dryrun() {
|
|
1017
1050
|
return _dryrun.apply(this, arguments);
|
|
@@ -1021,25 +1054,25 @@ var HB = /*#__PURE__*/function () {
|
|
|
1021
1054
|
}, {
|
|
1022
1055
|
key: "get",
|
|
1023
1056
|
value: function () {
|
|
1024
|
-
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1025
|
-
var device,
|
|
1026
|
-
return _regeneratorRuntime().wrap(function
|
|
1027
|
-
while (1) switch (
|
|
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) {
|
|
1028
1061
|
case 0:
|
|
1029
|
-
device =
|
|
1030
|
-
|
|
1062
|
+
device = _ref13.device, _ref13$path = _ref13.path, path = _ref13$path === void 0 ? "~meta@1.0/info" : _ref13$path;
|
|
1063
|
+
_context27.next = 3;
|
|
1031
1064
|
return this.request({
|
|
1032
1065
|
device: device,
|
|
1033
1066
|
path: path,
|
|
1034
1067
|
method: "GET"
|
|
1035
1068
|
});
|
|
1036
1069
|
case 3:
|
|
1037
|
-
return
|
|
1070
|
+
return _context27.abrupt("return", _context27.sent.body);
|
|
1038
1071
|
case 4:
|
|
1039
1072
|
case "end":
|
|
1040
|
-
return
|
|
1073
|
+
return _context27.stop();
|
|
1041
1074
|
}
|
|
1042
|
-
},
|
|
1075
|
+
}, _callee27, this);
|
|
1043
1076
|
}));
|
|
1044
1077
|
function get(_x19) {
|
|
1045
1078
|
return _get.apply(this, arguments);
|
|
@@ -1049,13 +1082,13 @@ var HB = /*#__PURE__*/function () {
|
|
|
1049
1082
|
}, {
|
|
1050
1083
|
key: "post",
|
|
1051
1084
|
value: function () {
|
|
1052
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1053
|
-
var device, tags,
|
|
1054
|
-
return _regeneratorRuntime().wrap(function
|
|
1055
|
-
while (1) switch (
|
|
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) {
|
|
1056
1089
|
case 0:
|
|
1057
|
-
device =
|
|
1058
|
-
|
|
1090
|
+
device = _ref14.device, tags = _ref14.tags, _ref14$path = _ref14.path, path = _ref14$path === void 0 ? "/schedule" : _ref14$path;
|
|
1091
|
+
_context28.next = 3;
|
|
1059
1092
|
return this.request({
|
|
1060
1093
|
tags: tags,
|
|
1061
1094
|
device: device,
|
|
@@ -1063,12 +1096,12 @@ var HB = /*#__PURE__*/function () {
|
|
|
1063
1096
|
method: "POST"
|
|
1064
1097
|
});
|
|
1065
1098
|
case 3:
|
|
1066
|
-
return
|
|
1099
|
+
return _context28.abrupt("return", _context28.sent);
|
|
1067
1100
|
case 4:
|
|
1068
1101
|
case "end":
|
|
1069
|
-
return
|
|
1102
|
+
return _context28.stop();
|
|
1070
1103
|
}
|
|
1071
|
-
},
|
|
1104
|
+
}, _callee28, this);
|
|
1072
1105
|
}));
|
|
1073
1106
|
function post(_x20) {
|
|
1074
1107
|
return _post.apply(this, arguments);
|
|
@@ -1078,26 +1111,26 @@ var HB = /*#__PURE__*/function () {
|
|
|
1078
1111
|
}, {
|
|
1079
1112
|
key: "request",
|
|
1080
1113
|
value: function () {
|
|
1081
|
-
var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1082
|
-
var device, tags,
|
|
1083
|
-
return _regeneratorRuntime().wrap(function
|
|
1084
|
-
while (1) switch (
|
|
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) {
|
|
1085
1118
|
case 0:
|
|
1086
|
-
device =
|
|
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;
|
|
1087
1120
|
_tags = (0, _ramda.mergeLeft)(tags, {
|
|
1088
1121
|
path: path,
|
|
1089
1122
|
method: method
|
|
1090
1123
|
});
|
|
1091
1124
|
if (device) _tags.device = device;
|
|
1092
|
-
|
|
1125
|
+
_context29.next = 5;
|
|
1093
1126
|
return this._request(_tags);
|
|
1094
1127
|
case 5:
|
|
1095
|
-
return
|
|
1128
|
+
return _context29.abrupt("return", _context29.sent);
|
|
1096
1129
|
case 6:
|
|
1097
1130
|
case "end":
|
|
1098
|
-
return
|
|
1131
|
+
return _context29.stop();
|
|
1099
1132
|
}
|
|
1100
|
-
},
|
|
1133
|
+
}, _callee29, this);
|
|
1101
1134
|
}));
|
|
1102
1135
|
function request(_x21) {
|
|
1103
1136
|
return _request.apply(this, arguments);
|
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
|
@@ -11,7 +11,8 @@ const seed = num => {
|
|
|
11
11
|
class HB {
|
|
12
12
|
constructor({ url = "http://localhost:10001", jwk } = {}) {
|
|
13
13
|
this.url = url
|
|
14
|
-
this.
|
|
14
|
+
this.dev = {}
|
|
15
|
+
this.dev.hyperbuddy = {
|
|
15
16
|
metrics: async (args = {}) => {
|
|
16
17
|
return this.parseMetrics(
|
|
17
18
|
await this.fetch(this.path("hyperbuddy", "metrics", false), false)
|
|
@@ -19,7 +20,7 @@ class HB {
|
|
|
19
20
|
},
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
this.json = {
|
|
23
|
+
this.dev.json = {
|
|
23
24
|
commit: async args => {
|
|
24
25
|
return await this.send({ path: "/~json@1.0/commit", ...args })
|
|
25
26
|
},
|
|
@@ -33,7 +34,7 @@ class HB {
|
|
|
33
34
|
return await this.send({ path: "/~json@1.0/serialize", ...args })
|
|
34
35
|
},
|
|
35
36
|
}
|
|
36
|
-
this.meta = {
|
|
37
|
+
this.dev.meta = {
|
|
37
38
|
info: async (args = {}) => {
|
|
38
39
|
let { method = "GET", json = true, key } = args
|
|
39
40
|
if (method.toLowerCase() === "post") {
|
|
@@ -71,7 +72,7 @@ class HB {
|
|
|
71
72
|
|
|
72
73
|
async init(jwk) {
|
|
73
74
|
this._init(jwk)
|
|
74
|
-
this._info = await this.meta.info({})
|
|
75
|
+
this._info = await this.dev.meta.info({})
|
|
75
76
|
return this
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -115,7 +116,7 @@ class HB {
|
|
|
115
116
|
i++
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
return `${this.url}/~${dev}/${path}${json ? "
|
|
119
|
+
return `${this.url}/~${dev}/${path}${json ? "/~json@1.0/serialize" : ""}${_params}`
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
async text(dev, path) {
|
|
@@ -132,13 +133,13 @@ class HB {
|
|
|
132
133
|
|
|
133
134
|
async computeAOS({ pid, slot }) {
|
|
134
135
|
return await fetch(
|
|
135
|
-
`${this.url}/${pid}/compute/results/outbox
|
|
136
|
+
`${this.url}/${pid}/compute/results/outbox/~json@1.0/serialize?slot=${slot}`
|
|
136
137
|
).then(r => r.json())
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
async compute({ pid, slot }) {
|
|
140
141
|
return await fetch(
|
|
141
|
-
`${this.url}/${pid}/compute
|
|
142
|
+
`${this.url}/${pid}/compute/~json@1.0/serialize?slot=${slot}`
|
|
142
143
|
).then(r => r.json())
|
|
143
144
|
}
|
|
144
145
|
|
|
@@ -148,7 +149,7 @@ class HB {
|
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
async spawn(tags = {}) {
|
|
151
|
-
const addr = await this.meta.info({ key: "address" })
|
|
152
|
+
const addr = await this.dev.meta.info({ key: "address" })
|
|
152
153
|
this.scheduler ??= addr
|
|
153
154
|
const res = await this.send(
|
|
154
155
|
mergeLeft(tags, {
|
|
@@ -158,7 +159,7 @@ class HB {
|
|
|
158
159
|
"random-seed": seed(16),
|
|
159
160
|
Type: "Process",
|
|
160
161
|
"scheduler-device": "scheduler@1.0",
|
|
161
|
-
"execution-device": "
|
|
162
|
+
"execution-device": "test-device@1.0",
|
|
162
163
|
})
|
|
163
164
|
)
|
|
164
165
|
return { res, pid: res.headers.get("process") }
|
|
@@ -166,11 +167,20 @@ class HB {
|
|
|
166
167
|
|
|
167
168
|
async message(args) {
|
|
168
169
|
const pid = args.pid
|
|
169
|
-
const slot = await this.schedule(args)
|
|
170
|
+
const { slot } = await this.schedule(args)
|
|
170
171
|
const res = await this.compute({ pid, slot })
|
|
171
172
|
return { slot, pid, res }
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
+
async scheduleLegacy({
|
|
175
|
+
pid,
|
|
176
|
+
action = "Eval",
|
|
177
|
+
tags = {},
|
|
178
|
+
data,
|
|
179
|
+
scheduler,
|
|
180
|
+
} = {}) {
|
|
181
|
+
if (action) tags.Action = action
|
|
182
|
+
return await this.schedule({ pid, tags, data, scheduler })
|
|
183
|
+
}
|
|
174
184
|
async schedule({ pid, tags = {}, data, scheduler } = {}) {
|
|
175
185
|
pid ??= this.pid
|
|
176
186
|
scheduler ??= this.scheduler
|
|
@@ -187,7 +197,7 @@ class HB {
|
|
|
187
197
|
}
|
|
188
198
|
|
|
189
199
|
async spawnAOS(image) {
|
|
190
|
-
const addr = await this.meta.info({ key: "address" })
|
|
200
|
+
const addr = await this.dev.meta.info({ key: "address" })
|
|
191
201
|
this.scheduler ??= addr
|
|
192
202
|
image ??= this.image ?? (await this.getImage())
|
|
193
203
|
const res = await this.send({
|
|
@@ -283,22 +293,21 @@ class HB {
|
|
|
283
293
|
"scheduler-device": "scheduler@1.0",
|
|
284
294
|
"execution-device": "genesis-wasm@1.0",
|
|
285
295
|
})
|
|
286
|
-
|
|
287
|
-
return { pid: res.process, res }
|
|
296
|
+
return await this.spawn(tags)
|
|
288
297
|
}
|
|
289
298
|
|
|
290
299
|
/*
|
|
291
|
-
|
|
300
|
+
async scheduleLegacy({ tags = {}, data, process, action = "Eval" } = {}) {
|
|
292
301
|
tags = mergeLeft(tags, {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
302
|
+
path: `${process}/schedule`,
|
|
303
|
+
type: "Message",
|
|
304
|
+
action,
|
|
305
|
+
data,
|
|
306
|
+
"Data-Protocol": "ao",
|
|
307
|
+
Variant: "ao.N.1",
|
|
299
308
|
})
|
|
300
309
|
return (await this.post({ tags })).slot.text()
|
|
301
|
-
|
|
310
|
+
}
|
|
302
311
|
*/
|
|
303
312
|
|
|
304
313
|
async dryrun({ tags = {}, pid, action, data } = {}) {
|