wao 0.32.0 → 0.32.2

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
@@ -13,7 +13,10 @@ var _hyperAos = _interopRequireDefault(require("./lua/hyper-aos.js"));
13
13
  var _aos_wamr = _interopRequireDefault(require("./lua/aos_wamr.js"));
14
14
  var _httpsig = require("./httpsig.js");
15
15
  var _excluded = ["path"],
16
- _excluded2 = ["path"];
16
+ _excluded2 = ["action", "tags"],
17
+ _excluded3 = ["action", "tags"],
18
+ _excluded4 = ["path"],
19
+ _excluded5 = ["action", "tags"];
17
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
18
21
  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); }
19
22
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
@@ -109,7 +112,7 @@ var HB = /*#__PURE__*/function () {
109
112
  while (1) switch (_context2.prev = _context2.next) {
110
113
  case 0:
111
114
  if (this._info) {
112
- _context2.next = 9;
115
+ _context2.next = 10;
113
116
  break;
114
117
  }
115
118
  _context2.prev = 1;
@@ -117,16 +120,17 @@ var HB = /*#__PURE__*/function () {
117
120
  return this.g("/~meta@1.0/info");
118
121
  case 4:
119
122
  this._info = _context2.sent;
120
- _context2.next = 9;
123
+ this.operator = this._info.address;
124
+ _context2.next = 10;
121
125
  break;
122
- case 7:
123
- _context2.prev = 7;
126
+ case 8:
127
+ _context2.prev = 8;
124
128
  _context2.t0 = _context2["catch"](1);
125
- case 9:
129
+ case 10:
126
130
  case "end":
127
131
  return _context2.stop();
128
132
  }
129
- }, _callee2, this, [[1, 7]]);
133
+ }, _callee2, this, [[1, 8]]);
130
134
  }));
131
135
  function setInfo() {
132
136
  return _setInfo.apply(this, arguments);
@@ -232,81 +236,39 @@ var HB = /*#__PURE__*/function () {
232
236
  }
233
237
  return getLua;
234
238
  }()
235
- }, {
236
- key: "scheduleAOS",
237
- value: function () {
238
- var _scheduleAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref2) {
239
- var _pid;
240
- var pid, _ref2$action, action, _ref2$tags, tags, data, _tags, res, slot;
241
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
242
- while (1) switch (_context7.prev = _context7.next) {
243
- case 0:
244
- 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;
245
- (_pid = pid) !== null && _pid !== void 0 ? _pid : pid = this.pid;
246
- _tags = (0, _ramda.mergeLeft)(tags, {
247
- device: "process@1.0",
248
- method: "POST",
249
- path: "/".concat(pid, "~process@1.0/schedule"),
250
- scheduler: this.scheduler,
251
- type: "Message",
252
- Action: action,
253
- target: pid
254
- });
255
- if (data) _tags.data = data;
256
- _context7.next = 6;
257
- return this.post(_tags);
258
- case 6:
259
- res = _context7.sent;
260
- slot = res.headers.slot;
261
- return _context7.abrupt("return", {
262
- slot: slot,
263
- res: res,
264
- pid: pid
265
- });
266
- case 9:
267
- case "end":
268
- return _context7.stop();
269
- }
270
- }, _callee7, this);
271
- }));
272
- function scheduleAOS(_x4) {
273
- return _scheduleAOS.apply(this, arguments);
274
- }
275
- return scheduleAOS;
276
- }()
277
239
  }, {
278
240
  key: "messageAOS",
279
241
  value: function () {
280
- var _messageAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(args) {
242
+ var _messageAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(args) {
281
243
  var _yield$this$scheduleA, slot, pid;
282
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
283
- while (1) switch (_context8.prev = _context8.next) {
244
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
245
+ while (1) switch (_context7.prev = _context7.next) {
284
246
  case 0:
285
- _context8.next = 2;
247
+ _context7.next = 2;
286
248
  return this.scheduleAOS(args);
287
249
  case 2:
288
- _yield$this$scheduleA = _context8.sent;
250
+ _yield$this$scheduleA = _context7.sent;
289
251
  slot = _yield$this$scheduleA.slot;
290
252
  pid = _yield$this$scheduleA.pid;
291
- _context8.t0 = slot;
292
- _context8.next = 8;
253
+ _context7.t0 = slot;
254
+ _context7.next = 8;
293
255
  return this.computeAOS({
294
256
  pid: pid,
295
257
  slot: slot
296
258
  });
297
259
  case 8:
298
- _context8.t1 = _context8.sent;
299
- return _context8.abrupt("return", {
300
- slot: _context8.t0,
301
- outbox: _context8.t1
260
+ _context7.t1 = _context7.sent;
261
+ return _context7.abrupt("return", {
262
+ slot: _context7.t0,
263
+ outbox: _context7.t1
302
264
  });
303
265
  case 10:
304
266
  case "end":
305
- return _context8.stop();
267
+ return _context7.stop();
306
268
  }
307
- }, _callee8, this);
269
+ }, _callee7, this);
308
270
  }));
309
- function messageAOS(_x5) {
271
+ function messageAOS(_x4) {
310
272
  return _messageAOS.apply(this, arguments);
311
273
  }
312
274
  return messageAOS;
@@ -314,36 +276,36 @@ var HB = /*#__PURE__*/function () {
314
276
  }, {
315
277
  key: "messageLegacy",
316
278
  value: function () {
317
- var _messageLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(args) {
279
+ var _messageLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(args) {
318
280
  var _yield$this$scheduleL, slot, pid;
319
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
320
- while (1) switch (_context9.prev = _context9.next) {
281
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
282
+ while (1) switch (_context8.prev = _context8.next) {
321
283
  case 0:
322
- _context9.next = 2;
284
+ _context8.next = 2;
323
285
  return this.scheduleLegacy(args);
324
286
  case 2:
325
- _yield$this$scheduleL = _context9.sent;
287
+ _yield$this$scheduleL = _context8.sent;
326
288
  slot = _yield$this$scheduleL.slot;
327
289
  pid = _yield$this$scheduleL.pid;
328
- _context9.t0 = slot;
329
- _context9.next = 8;
290
+ _context8.t0 = slot;
291
+ _context8.next = 8;
330
292
  return this.computeLegacy({
331
293
  pid: pid,
332
294
  slot: slot
333
295
  });
334
296
  case 8:
335
- _context9.t1 = _context9.sent;
336
- return _context9.abrupt("return", {
337
- slot: _context9.t0,
338
- res: _context9.t1
297
+ _context8.t1 = _context8.sent;
298
+ return _context8.abrupt("return", {
299
+ slot: _context8.t0,
300
+ res: _context8.t1
339
301
  });
340
302
  case 10:
341
303
  case "end":
342
- return _context9.stop();
304
+ return _context8.stop();
343
305
  }
344
- }, _callee9, this);
306
+ }, _callee8, this);
345
307
  }));
346
- function messageLegacy(_x6) {
308
+ function messageLegacy(_x5) {
347
309
  return _messageLegacy.apply(this, arguments);
348
310
  }
349
311
  return messageLegacy;
@@ -351,26 +313,26 @@ var HB = /*#__PURE__*/function () {
351
313
  }, {
352
314
  key: "computeAOS",
353
315
  value: function () {
354
- var _computeAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref3) {
316
+ var _computeAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref2) {
355
317
  var pid, slot;
356
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
357
- while (1) switch (_context10.prev = _context10.next) {
318
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
319
+ while (1) switch (_context9.prev = _context9.next) {
358
320
  case 0:
359
- pid = _ref3.pid, slot = _ref3.slot;
360
- _context10.next = 3;
321
+ pid = _ref2.pid, slot = _ref2.slot;
322
+ _context9.next = 3;
361
323
  return this.getJSON({
362
324
  path: "/".concat(pid, "/compute/results/outbox"),
363
325
  slot: slot
364
326
  });
365
327
  case 3:
366
- return _context10.abrupt("return", _context10.sent);
328
+ return _context9.abrupt("return", _context9.sent);
367
329
  case 4:
368
330
  case "end":
369
- return _context10.stop();
331
+ return _context9.stop();
370
332
  }
371
- }, _callee10, this);
333
+ }, _callee9, this);
372
334
  }));
373
- function computeAOS(_x7) {
335
+ function computeAOS(_x6) {
374
336
  return _computeAOS.apply(this, arguments);
375
337
  }
376
338
  return computeAOS;
@@ -378,26 +340,26 @@ var HB = /*#__PURE__*/function () {
378
340
  }, {
379
341
  key: "computeLua",
380
342
  value: function () {
381
- var _computeLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref4) {
343
+ var _computeLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref3) {
382
344
  var pid, slot;
383
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
384
- while (1) switch (_context11.prev = _context11.next) {
345
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
346
+ while (1) switch (_context10.prev = _context10.next) {
385
347
  case 0:
386
- pid = _ref4.pid, slot = _ref4.slot;
387
- _context11.next = 3;
348
+ pid = _ref3.pid, slot = _ref3.slot;
349
+ _context10.next = 3;
388
350
  return this.getJSON({
389
351
  path: "/".concat(pid, "/compute/results"),
390
352
  slot: slot
391
353
  });
392
354
  case 3:
393
- return _context11.abrupt("return", _context11.sent);
355
+ return _context10.abrupt("return", _context10.sent);
394
356
  case 4:
395
357
  case "end":
396
- return _context11.stop();
358
+ return _context10.stop();
397
359
  }
398
- }, _callee11, this);
360
+ }, _callee10, this);
399
361
  }));
400
- function computeLua(_x8) {
362
+ function computeLua(_x7) {
401
363
  return _computeLua.apply(this, arguments);
402
364
  }
403
365
  return computeLua;
@@ -405,27 +367,27 @@ var HB = /*#__PURE__*/function () {
405
367
  }, {
406
368
  key: "compute",
407
369
  value: function () {
408
- var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref5) {
409
- var pid, slot, _ref5$path, path;
410
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
411
- while (1) switch (_context12.prev = _context12.next) {
370
+ var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref4) {
371
+ var pid, slot, _ref4$path, path;
372
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
373
+ while (1) switch (_context11.prev = _context11.next) {
412
374
  case 0:
413
- pid = _ref5.pid, slot = _ref5.slot, _ref5$path = _ref5.path, path = _ref5$path === void 0 ? "" : _ref5$path;
375
+ pid = _ref4.pid, slot = _ref4.slot, _ref4$path = _ref4.path, path = _ref4$path === void 0 ? "" : _ref4$path;
414
376
  if (path && !/^\//.test(path)) path = "/" + path;
415
- _context12.next = 4;
377
+ _context11.next = 4;
416
378
  return this.getJSON({
417
379
  path: "/".concat(pid, "/compute").concat(path),
418
380
  slot: slot
419
381
  });
420
382
  case 4:
421
- return _context12.abrupt("return", _context12.sent);
383
+ return _context11.abrupt("return", _context11.sent);
422
384
  case 5:
423
385
  case "end":
424
- return _context12.stop();
386
+ return _context11.stop();
425
387
  }
426
- }, _callee12, this);
388
+ }, _callee11, this);
427
389
  }));
428
- function compute(_x9) {
390
+ function compute(_x8) {
429
391
  return _compute.apply(this, arguments);
430
392
  }
431
393
  return compute;
@@ -433,128 +395,84 @@ var HB = /*#__PURE__*/function () {
433
395
  }, {
434
396
  key: "computeLegacy",
435
397
  value: function () {
436
- var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref6) {
398
+ var _computeLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref5) {
437
399
  var pid, slot, json;
438
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
439
- while (1) switch (_context13.prev = _context13.next) {
400
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
401
+ while (1) switch (_context12.prev = _context12.next) {
440
402
  case 0:
441
- pid = _ref6.pid, slot = _ref6.slot;
442
- _context13.next = 3;
403
+ pid = _ref5.pid, slot = _ref5.slot;
404
+ _context12.next = 3;
443
405
  return this.compute({
444
406
  pid: pid,
445
407
  slot: slot
446
408
  });
447
409
  case 3:
448
- json = _context13.sent;
449
- return _context13.abrupt("return", JSON.parse(json.results.json.body));
410
+ json = _context12.sent;
411
+ return _context12.abrupt("return", JSON.parse(json.results.json.body));
450
412
  case 5:
451
413
  case "end":
452
- return _context13.stop();
414
+ return _context12.stop();
453
415
  }
454
- }, _callee13, this);
416
+ }, _callee12, this);
455
417
  }));
456
- function computeLegacy(_x10) {
418
+ function computeLegacy(_x9) {
457
419
  return _computeLegacy.apply(this, arguments);
458
420
  }
459
421
  return computeLegacy;
460
422
  }()
461
- }, {
462
- key: "spawn",
463
- value: function () {
464
- var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
465
- var _this$scheduler;
466
- var tags,
467
- addr,
468
- _tags,
469
- res,
470
- _args15 = arguments;
471
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
472
- while (1) switch (_context14.prev = _context14.next) {
473
- case 0:
474
- tags = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
475
- _context14.next = 3;
476
- return this.g("/~meta@1.0/info/address");
477
- case 3:
478
- addr = _context14.sent;
479
- (_this$scheduler = this.scheduler) !== null && _this$scheduler !== void 0 ? _this$scheduler : this.scheduler = addr;
480
- _tags = (0, _ramda.mergeLeft)(tags, {
481
- device: "process@1.0",
482
- path: "/schedule",
483
- scheduler: this.scheduler,
484
- "random-seed": seed(16),
485
- type: "Process",
486
- "execution-device": "test-device@1.0"
487
- });
488
- _context14.next = 8;
489
- return this.post(_tags);
490
- case 8:
491
- res = _context14.sent;
492
- return _context14.abrupt("return", {
493
- res: res,
494
- pid: res.headers.process
495
- });
496
- case 10:
497
- case "end":
498
- return _context14.stop();
499
- }
500
- }, _callee14, this);
501
- }));
502
- function spawn() {
503
- return _spawn.apply(this, arguments);
504
- }
505
- return spawn;
506
- }()
507
423
  }, {
508
424
  key: "cacheScript",
509
425
  value: function () {
510
- var _cacheScript = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(data) {
426
+ var _cacheScript = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(data) {
511
427
  var type,
512
428
  _yield$this$spawn,
513
429
  pid,
514
- _yield$this$schedule,
430
+ _yield$this$scheduleF,
515
431
  slot,
516
432
  msgs,
517
- _args16 = arguments;
518
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
519
- while (1) switch (_context15.prev = _context15.next) {
433
+ _args14 = arguments;
434
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
435
+ while (1) switch (_context13.prev = _context13.next) {
520
436
  case 0:
521
- type = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : "application/lua";
437
+ type = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : "application/lua";
522
438
  if (this.cache) {
523
- _context15.next = 7;
439
+ _context13.next = 7;
524
440
  break;
525
441
  }
526
- _context15.next = 4;
442
+ _context13.next = 4;
527
443
  return this.spawn({});
528
444
  case 4:
529
- _yield$this$spawn = _context15.sent;
445
+ _yield$this$spawn = _context13.sent;
530
446
  pid = _yield$this$spawn.pid;
531
447
  this.cache = pid;
532
448
  case 7:
533
- _context15.next = 9;
534
- return this.schedule({
449
+ _context13.next = 9;
450
+ return this.scheduleFlat({
535
451
  data: data,
536
452
  pid: this.cache,
537
- "content-type": type
453
+ tags: {
454
+ "content-type": type
455
+ }
538
456
  });
539
457
  case 9:
540
- _yield$this$schedule = _context15.sent;
541
- slot = _yield$this$schedule.slot;
542
- _context15.next = 13;
458
+ _yield$this$scheduleF = _context13.sent;
459
+ slot = _yield$this$scheduleF.slot;
460
+ _context13.next = 13;
543
461
  return this.messages({
544
462
  pid: this.cache,
545
463
  from: slot,
546
464
  limit: 1
547
465
  });
548
466
  case 13:
549
- msgs = _context15.sent;
550
- return _context15.abrupt("return", msgs.edges[0].node.message.Id);
467
+ msgs = _context13.sent;
468
+ return _context13.abrupt("return", msgs.edges[0].node.message.Id);
551
469
  case 15:
552
470
  case "end":
553
- return _context15.stop();
471
+ return _context13.stop();
554
472
  }
555
- }, _callee15, this);
473
+ }, _callee13, this);
556
474
  }));
557
- function cacheScript(_x11) {
475
+ function cacheScript(_x10) {
558
476
  return _cacheScript.apply(this, arguments);
559
477
  }
560
478
  return cacheScript;
@@ -562,27 +480,27 @@ var HB = /*#__PURE__*/function () {
562
480
  }, {
563
481
  key: "cacheBinary",
564
482
  value: function () {
565
- var _cacheBinary = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16(data, type) {
483
+ var _cacheBinary = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(data, type) {
566
484
  var res;
567
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
568
- while (1) switch (_context16.prev = _context16.next) {
485
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
486
+ while (1) switch (_context14.prev = _context14.next) {
569
487
  case 0:
570
- _context16.next = 2;
488
+ _context14.next = 2;
571
489
  return this.post({
572
490
  path: "/~wao@1.0/cache_module",
573
491
  data: data,
574
492
  type: type
575
493
  });
576
494
  case 2:
577
- res = _context16.sent;
578
- return _context16.abrupt("return", res.headers.id);
495
+ res = _context14.sent;
496
+ return _context14.abrupt("return", res.out.id);
579
497
  case 4:
580
498
  case "end":
581
- return _context16.stop();
499
+ return _context14.stop();
582
500
  }
583
- }, _callee16, this);
501
+ }, _callee14, this);
584
502
  }));
585
- function cacheBinary(_x12, _x13) {
503
+ function cacheBinary(_x11, _x12) {
586
504
  return _cacheBinary.apply(this, arguments);
587
505
  }
588
506
  return cacheBinary;
@@ -590,106 +508,134 @@ var HB = /*#__PURE__*/function () {
590
508
  }, {
591
509
  key: "message",
592
510
  value: function () {
593
- var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(args) {
594
- var pid, _yield$this$schedule2, slot, res;
595
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
596
- while (1) switch (_context17.prev = _context17.next) {
511
+ var _message = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(args) {
512
+ var pid, _yield$this$schedule, slot, res;
513
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
514
+ while (1) switch (_context15.prev = _context15.next) {
597
515
  case 0:
598
516
  pid = args.pid;
599
- _context17.next = 3;
517
+ _context15.next = 3;
600
518
  return this.schedule(args);
601
519
  case 3:
602
- _yield$this$schedule2 = _context17.sent;
603
- slot = _yield$this$schedule2.slot;
604
- _context17.next = 7;
520
+ _yield$this$schedule = _context15.sent;
521
+ slot = _yield$this$schedule.slot;
522
+ _context15.next = 7;
605
523
  return this.compute({
606
524
  pid: pid,
607
525
  slot: slot
608
526
  });
609
527
  case 7:
610
- res = _context17.sent;
611
- return _context17.abrupt("return", {
528
+ res = _context15.sent;
529
+ return _context15.abrupt("return", {
612
530
  slot: slot,
613
531
  pid: pid,
614
532
  res: res
615
533
  });
616
534
  case 9:
617
535
  case "end":
618
- return _context17.stop();
536
+ return _context15.stop();
619
537
  }
620
- }, _callee17, this);
538
+ }, _callee15, this);
621
539
  }));
622
- function message(_x14) {
540
+ function message(_x13) {
623
541
  return _message.apply(this, arguments);
624
542
  }
625
543
  return message;
626
544
  }()
627
545
  }, {
628
- key: "scheduleLegacy",
546
+ key: "scheduleFlat",
629
547
  value: function () {
630
- var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
631
- var _ref7,
548
+ var _scheduleFlat = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
549
+ var _ref6,
632
550
  pid,
633
- _ref7$action,
634
- action,
635
- _ref7$tags,
551
+ _ref6$tags,
636
552
  tags,
637
553
  data,
638
- scheduler,
639
- _args19 = arguments;
640
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
641
- while (1) switch (_context18.prev = _context18.next) {
554
+ _tags,
555
+ res,
556
+ _args17 = arguments;
557
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
558
+ while (1) switch (_context16.prev = _context16.next) {
642
559
  case 0:
643
- _ref7 = _args19.length > 0 && _args19[0] !== undefined ? _args19[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;
644
- if (action) tags.Action = action;
645
- _context18.next = 4;
646
- return this.schedule({
647
- pid: pid,
648
- tags: tags,
649
- data: data,
650
- scheduler: scheduler
560
+ _ref6 = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {}, pid = _ref6.pid, _ref6$tags = _ref6.tags, tags = _ref6$tags === void 0 ? {} : _ref6$tags, data = _ref6.data;
561
+ _tags = (0, _ramda.mergeLeft)(tags, {
562
+ type: "Message",
563
+ target: pid
564
+ });
565
+ if (data) _tags.data = data;
566
+ _context16.next = 5;
567
+ return this.post({
568
+ path: "/~process@1.0/schedule",
569
+ body: _tags
651
570
  });
652
- case 4:
653
- return _context18.abrupt("return", _context18.sent);
654
571
  case 5:
572
+ res = _context16.sent;
573
+ return _context16.abrupt("return", {
574
+ slot: res.out.slot,
575
+ res: res,
576
+ pid: pid
577
+ });
578
+ case 7:
655
579
  case "end":
656
- return _context18.stop();
580
+ return _context16.stop();
657
581
  }
658
- }, _callee18, this);
582
+ }, _callee16, this);
659
583
  }));
660
- function scheduleLegacy() {
661
- return _scheduleLegacy.apply(this, arguments);
584
+ function scheduleFlat() {
585
+ return _scheduleFlat.apply(this, arguments);
662
586
  }
663
- return scheduleLegacy;
587
+ return scheduleFlat;
664
588
  }()
665
589
  }, {
666
- key: "scheduleLua",
590
+ key: "scheduleNP",
667
591
  value: function () {
668
- var _scheduleLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
669
- var _args20 = arguments;
670
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
671
- while (1) switch (_context19.prev = _context19.next) {
592
+ var _scheduleNP = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
593
+ var _ref7,
594
+ pid,
595
+ _ref7$tags,
596
+ tags,
597
+ data,
598
+ res,
599
+ _args18 = arguments;
600
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
601
+ while (1) switch (_context17.prev = _context17.next) {
672
602
  case 0:
673
- _context19.next = 2;
674
- return this.scheduleLegacy.apply(this, _args20);
675
- case 2:
676
- return _context19.abrupt("return", _context19.sent);
677
- case 3:
603
+ _ref7 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, pid = _ref7.pid, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data;
604
+ if (data) tags.data = data;
605
+ _context17.t0 = this;
606
+ _context17.t1 = "/".concat(pid, "~node-process@1.0/schedule");
607
+ _context17.next = 6;
608
+ return this.commit(tags);
609
+ case 6:
610
+ _context17.t2 = _context17.sent;
611
+ _context17.t3 = {
612
+ path: _context17.t1,
613
+ body: _context17.t2
614
+ };
615
+ _context17.next = 10;
616
+ return _context17.t0.post.call(_context17.t0, _context17.t3);
617
+ case 10:
618
+ res = _context17.sent;
619
+ return _context17.abrupt("return", {
620
+ slot: res.out.slot,
621
+ res: res,
622
+ pid: pid
623
+ });
624
+ case 12:
678
625
  case "end":
679
- return _context19.stop();
626
+ return _context17.stop();
680
627
  }
681
- }, _callee19, this);
628
+ }, _callee17, this);
682
629
  }));
683
- function scheduleLua() {
684
- return _scheduleLua.apply(this, arguments);
630
+ function scheduleNP() {
631
+ return _scheduleNP.apply(this, arguments);
685
632
  }
686
- return scheduleLua;
633
+ return scheduleNP;
687
634
  }()
688
635
  }, {
689
636
  key: "schedule",
690
637
  value: function () {
691
- var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
692
- var _pid2;
638
+ var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
693
639
  var _ref8,
694
640
  pid,
695
641
  _ref8$tags,
@@ -697,33 +643,42 @@ var HB = /*#__PURE__*/function () {
697
643
  data,
698
644
  _tags,
699
645
  res,
700
- _args21 = arguments;
701
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
702
- while (1) switch (_context20.prev = _context20.next) {
646
+ _args19 = arguments;
647
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
648
+ while (1) switch (_context18.prev = _context18.next) {
703
649
  case 0:
704
- _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;
705
- (_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
650
+ _ref8 = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {}, pid = _ref8.pid, _ref8$tags = _ref8.tags, tags = _ref8$tags === void 0 ? {} : _ref8$tags, data = _ref8.data;
706
651
  _tags = (0, _ramda.mergeLeft)(tags, {
707
- method: "POST",
708
- path: "/".concat(pid, "/schedule"),
709
652
  type: "Message",
710
653
  target: pid
711
654
  });
712
655
  if (data) _tags.data = data;
713
- _context20.next = 6;
714
- return this.post(_tags);
715
- case 6:
716
- res = _context20.sent;
717
- return _context20.abrupt("return", {
718
- slot: res.headers.slot,
656
+ _context18.t0 = this;
657
+ _context18.t1 = "/".concat(pid, "/schedule");
658
+ _context18.next = 7;
659
+ return this.commit(_tags, {
660
+ path: false
661
+ });
662
+ case 7:
663
+ _context18.t2 = _context18.sent;
664
+ _context18.t3 = {
665
+ path: _context18.t1,
666
+ body: _context18.t2
667
+ };
668
+ _context18.next = 11;
669
+ return _context18.t0.post.call(_context18.t0, _context18.t3);
670
+ case 11:
671
+ res = _context18.sent;
672
+ return _context18.abrupt("return", {
673
+ slot: res.out.slot,
719
674
  res: res,
720
675
  pid: pid
721
676
  });
722
- case 8:
677
+ case 13:
723
678
  case "end":
724
- return _context20.stop();
679
+ return _context18.stop();
725
680
  }
726
- }, _callee20, this);
681
+ }, _callee18, this);
727
682
  }));
728
683
  function schedule() {
729
684
  return _schedule.apply(this, arguments);
@@ -731,150 +686,76 @@ var HB = /*#__PURE__*/function () {
731
686
  return schedule;
732
687
  }()
733
688
  }, {
734
- key: "spawnAOS",
689
+ key: "scheduleLua",
735
690
  value: function () {
736
- var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(image) {
737
- var _this$scheduler2, _image, _this$image2, _this$pid;
738
- var addr, res, pid;
739
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
740
- while (1) switch (_context21.prev = _context21.next) {
691
+ var _scheduleLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref9) {
692
+ var _ref9$action, action, _ref9$tags, tags, rest;
693
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
694
+ while (1) switch (_context19.prev = _context19.next) {
741
695
  case 0:
742
- _context21.next = 2;
743
- return this.g("/~meta@1.0/info/address");
744
- case 2:
745
- addr = _context21.sent;
746
- (_this$scheduler2 = this.scheduler) !== null && _this$scheduler2 !== void 0 ? _this$scheduler2 : this.scheduler = addr;
747
- if (!((_image = image) !== null && _image !== void 0)) {
748
- _context21.next = 8;
749
- break;
750
- }
751
- _image;
752
- _context21.next = 16;
753
- break;
754
- case 8:
755
- if (!((_this$image2 = this.image) !== null && _this$image2 !== void 0)) {
756
- _context21.next = 12;
757
- break;
758
- }
759
- _context21.t0 = _this$image2;
760
- _context21.next = 15;
761
- break;
762
- case 12:
763
- _context21.next = 14;
764
- return this.getImage();
765
- case 14:
766
- _context21.t0 = _context21.sent;
767
- case 15:
768
- image = _context21.t0;
769
- case 16:
770
- _context21.next = 18;
771
- return this.post({
772
- device: "process@1.0",
773
- path: "/schedule",
774
- scheduler: this.scheduler,
775
- "data-protocol": "ao",
776
- variant: "ao.N.1",
777
- "scheduler-location": this.scheduler,
778
- authority: this.scheduler,
779
- "random-seed": seed(16),
780
- type: "Process",
781
- image: image,
782
- "execution-device": "stack@1.0",
783
- "push-device": "push@1.0",
784
- "device-stack": ["wasi@1.0", "json-iface@1.0", "wasm-64@1.0", "patch@1.0", "multipass@1.0"],
785
- "output-prefix": "wasm",
786
- "patch-from": "/results/outbox",
787
- "patch-mode": "patches",
788
- "stack-keys": ["init", "compute", "snapshot", "normalize"],
789
- passes: 2
790
- });
791
- case 18:
792
- res = _context21.sent;
793
- pid = res.headers.process;
794
- (_this$pid = this.pid) !== null && _this$pid !== void 0 ? _this$pid : this.pid = pid;
795
- return _context21.abrupt("return", {
796
- pid: pid,
797
- res: res
798
- });
799
- case 22:
696
+ _ref9$action = _ref9.action, action = _ref9$action === void 0 ? "Eval" : _ref9$action, _ref9$tags = _ref9.tags, tags = _ref9$tags === void 0 ? {} : _ref9$tags, rest = _objectWithoutProperties(_ref9, _excluded2);
697
+ if (action) tags.Action = action;
698
+ _context19.next = 4;
699
+ return this.schedule(_objectSpread({
700
+ tags: tags
701
+ }, rest));
702
+ case 4:
703
+ return _context19.abrupt("return", _context19.sent);
704
+ case 5:
800
705
  case "end":
801
- return _context21.stop();
706
+ return _context19.stop();
802
707
  }
803
- }, _callee21, this);
708
+ }, _callee19, this);
804
709
  }));
805
- function spawnAOS(_x15) {
806
- return _spawnAOS.apply(this, arguments);
710
+ function scheduleLua(_x14) {
711
+ return _scheduleLua.apply(this, arguments);
807
712
  }
808
- return spawnAOS;
713
+ return scheduleLua;
809
714
  }()
810
715
  }, {
811
716
  key: "spawnLua",
812
717
  value: function () {
813
- var _spawnLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(lua) {
814
- var _this$scheduler3, _lua, _this$lua2, _this$pid2;
815
- var addr, res, pid;
816
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
817
- while (1) switch (_context22.prev = _context22.next) {
718
+ var _spawnLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(lua) {
719
+ var _this$lua2;
720
+ var tags;
721
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
722
+ while (1) switch (_context20.prev = _context20.next) {
818
723
  case 0:
819
- _context22.next = 2;
820
- return this.g("/~meta@1.0/info/address");
724
+ _context20.next = 2;
725
+ return this.setInfo();
821
726
  case 2:
822
- addr = _context22.sent;
823
- (_this$scheduler3 = this.scheduler) !== null && _this$scheduler3 !== void 0 ? _this$scheduler3 : this.scheduler = addr;
824
- if (!((_lua = lua) !== null && _lua !== void 0)) {
825
- _context22.next = 8;
826
- break;
827
- }
828
- _lua;
829
- _context22.next = 16;
830
- break;
831
- case 8:
727
+ _context20.t0 = this.operator;
832
728
  if (!((_this$lua2 = this.lua) !== null && _this$lua2 !== void 0)) {
833
- _context22.next = 12;
729
+ _context20.next = 7;
834
730
  break;
835
731
  }
836
- _context22.t0 = _this$lua2;
837
- _context22.next = 15;
732
+ _context20.t1 = _this$lua2;
733
+ _context20.next = 10;
838
734
  break;
839
- case 12:
840
- _context22.next = 14;
735
+ case 7:
736
+ _context20.next = 9;
841
737
  return this.getLua();
842
- case 14:
843
- _context22.t0 = _context22.sent;
844
- case 15:
845
- lua = _context22.t0;
846
- case 16:
847
- _context22.next = 18;
848
- return this.post({
849
- device: "process@1.0",
850
- path: "/schedule",
851
- scheduler: this.scheduler,
738
+ case 9:
739
+ _context20.t1 = _context20.sent;
740
+ case 10:
741
+ _context20.t2 = _context20.t1;
742
+ tags = {
852
743
  "data-protocol": "ao",
853
744
  variant: "ao.N.1",
854
- "scheduler-location": this.scheduler,
855
- authority: this.scheduler,
856
- "random-seed": seed(16),
857
- type: "Process",
858
- module: lua,
745
+ authority: _context20.t0,
746
+ module: _context20.t2,
859
747
  "execution-device": "lua@5.3a",
860
748
  "push-device": "push@1.0",
861
749
  "patch-from": "/results/outbox"
862
- });
863
- case 18:
864
- res = _context22.sent;
865
- pid = res.headers.process;
866
- (_this$pid2 = this.pid) !== null && _this$pid2 !== void 0 ? _this$pid2 : this.pid = pid;
867
- return _context22.abrupt("return", {
868
- pid: pid,
869
- res: res
870
- });
871
- case 22:
750
+ };
751
+ return _context20.abrupt("return", this.spawn(tags));
752
+ case 13:
872
753
  case "end":
873
- return _context22.stop();
754
+ return _context20.stop();
874
755
  }
875
- }, _callee22, this);
756
+ }, _callee20, this);
876
757
  }));
877
- function spawnLua(_x16) {
758
+ function spawnLua(_x15) {
878
759
  return _spawnLua.apply(this, arguments);
879
760
  }
880
761
  return spawnLua;
@@ -882,26 +763,26 @@ var HB = /*#__PURE__*/function () {
882
763
  }, {
883
764
  key: "now",
884
765
  value: function () {
885
- var _now = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(_ref9) {
886
- var pid, _ref9$path, path;
887
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
888
- while (1) switch (_context23.prev = _context23.next) {
766
+ var _now = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref10) {
767
+ var pid, _ref10$path, path;
768
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
769
+ while (1) switch (_context21.prev = _context21.next) {
889
770
  case 0:
890
- pid = _ref9.pid, _ref9$path = _ref9.path, path = _ref9$path === void 0 ? "" : _ref9$path;
771
+ pid = _ref10.pid, _ref10$path = _ref10.path, path = _ref10$path === void 0 ? "" : _ref10$path;
891
772
  if (path && !/^\//.test(path)) path = "/" + path;
892
- _context23.next = 4;
773
+ _context21.next = 4;
893
774
  return this.getJSON({
894
775
  path: "/".concat(pid, "/now").concat(path)
895
776
  });
896
777
  case 4:
897
- return _context23.abrupt("return", _context23.sent);
778
+ return _context21.abrupt("return", _context21.sent);
898
779
  case 5:
899
780
  case "end":
900
- return _context23.stop();
781
+ return _context21.stop();
901
782
  }
902
- }, _callee23, this);
783
+ }, _callee21, this);
903
784
  }));
904
- function now(_x17) {
785
+ function now(_x16) {
905
786
  return _now.apply(this, arguments);
906
787
  }
907
788
  return now;
@@ -909,26 +790,26 @@ var HB = /*#__PURE__*/function () {
909
790
  }, {
910
791
  key: "slot",
911
792
  value: function () {
912
- var _slot = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref10) {
913
- var pid, _ref10$path, path;
914
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
915
- while (1) switch (_context24.prev = _context24.next) {
793
+ var _slot = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref11) {
794
+ var pid, _ref11$path, path;
795
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
796
+ while (1) switch (_context22.prev = _context22.next) {
916
797
  case 0:
917
- pid = _ref10.pid, _ref10$path = _ref10.path, path = _ref10$path === void 0 ? "" : _ref10$path;
798
+ pid = _ref11.pid, _ref11$path = _ref11.path, path = _ref11$path === void 0 ? "" : _ref11$path;
918
799
  if (path && !/^\//.test(path)) path = "/" + path;
919
- _context24.next = 4;
800
+ _context22.next = 4;
920
801
  return this.getJSON({
921
802
  path: "/".concat(pid, "/slot").concat(path)
922
803
  });
923
804
  case 4:
924
- return _context24.abrupt("return", _context24.sent);
805
+ return _context22.abrupt("return", _context22.sent);
925
806
  case 5:
926
807
  case "end":
927
- return _context24.stop();
808
+ return _context22.stop();
928
809
  }
929
- }, _callee24, this);
810
+ }, _callee22, this);
930
811
  }));
931
- function slot(_x18) {
812
+ function slot(_x17) {
932
813
  return _slot.apply(this, arguments);
933
814
  }
934
815
  return slot;
@@ -936,123 +817,198 @@ var HB = /*#__PURE__*/function () {
936
817
  }, {
937
818
  key: "messages",
938
819
  value: function () {
939
- var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
820
+ var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
940
821
  var _this = this;
941
- var _ref11,
822
+ var _ref12,
942
823
  pid,
943
824
  from,
944
825
  to,
945
826
  params,
946
827
  res,
947
- _args27 = arguments;
948
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
949
- while (1) switch (_context26.prev = _context26.next) {
828
+ _args25 = arguments;
829
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
830
+ while (1) switch (_context24.prev = _context24.next) {
950
831
  case 0:
951
- _ref11 = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {}, pid = _ref11.pid, from = _ref11.from, to = _ref11.to;
832
+ _ref12 = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {}, pid = _ref12.pid, from = _ref12.from, to = _ref12.to;
952
833
  params = "target=".concat(pid);
953
834
  if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
954
835
  if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
955
836
  params += "&accept=application/aos-2";
956
- _context26.next = 7;
837
+ _context24.next = 7;
957
838
  return fetch("".concat(this.url, "/~scheduler@1.0/schedule?").concat(params)).then(function (r) {
958
839
  return r.json();
959
840
  });
960
841
  case 7:
961
- res = _context26.sent;
842
+ res = _context24.sent;
962
843
  if (res.page_info.has_next_page) {
963
- res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
844
+ res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
964
845
  var from2;
965
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
966
- while (1) switch (_context25.prev = _context25.next) {
846
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
847
+ while (1) switch (_context23.prev = _context23.next) {
967
848
  case 0:
968
849
  from2 = (0, _ramda.last)(res.edges).cursor + 1;
969
- _context25.next = 3;
850
+ _context23.next = 3;
970
851
  return _this.messages({
971
852
  pid: pid,
972
853
  from: from2,
973
854
  to: to
974
855
  });
975
856
  case 3:
976
- return _context25.abrupt("return", _context25.sent);
857
+ return _context23.abrupt("return", _context23.sent);
977
858
  case 4:
978
859
  case "end":
979
- return _context25.stop();
860
+ return _context23.stop();
980
861
  }
981
- }, _callee25);
862
+ }, _callee23);
982
863
  }));
983
864
  }
984
- return _context26.abrupt("return", res);
865
+ return _context24.abrupt("return", res);
985
866
  case 10:
986
867
  case "end":
987
- return _context26.stop();
868
+ return _context24.stop();
988
869
  }
989
- }, _callee26, this);
870
+ }, _callee24, this);
990
871
  }));
991
872
  function messages() {
992
873
  return _messages.apply(this, arguments);
993
874
  }
994
875
  return messages;
995
876
  }()
877
+ }, {
878
+ key: "spawn",
879
+ value: function () {
880
+ var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
881
+ var tags,
882
+ res,
883
+ _args26 = arguments;
884
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
885
+ while (1) switch (_context25.prev = _context25.next) {
886
+ case 0:
887
+ tags = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
888
+ _context25.t0 = this;
889
+ _context25.next = 4;
890
+ return this.commit((0, _ramda.mergeLeft)(tags, {
891
+ "random-seed": seed(16),
892
+ type: "Process",
893
+ "execution-device": "test-device@1.0",
894
+ device: "process@1.0",
895
+ scheduler: this.addr
896
+ }), {
897
+ path: false
898
+ });
899
+ case 4:
900
+ _context25.t1 = _context25.sent;
901
+ _context25.t2 = this.operator;
902
+ _context25.t3 = {
903
+ path: "/~process@1.0/schedule",
904
+ body: _context25.t1,
905
+ scheduler: _context25.t2
906
+ };
907
+ _context25.next = 9;
908
+ return _context25.t0.post.call(_context25.t0, _context25.t3);
909
+ case 9:
910
+ res = _context25.sent;
911
+ return _context25.abrupt("return", {
912
+ res: res,
913
+ pid: res.out.process
914
+ });
915
+ case 11:
916
+ case "end":
917
+ return _context25.stop();
918
+ }
919
+ }, _callee25, this);
920
+ }));
921
+ function spawn() {
922
+ return _spawn.apply(this, arguments);
923
+ }
924
+ return spawn;
925
+ }()
996
926
  }, {
997
927
  key: "spawnLegacy",
998
928
  value: function () {
999
- var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1000
- var _ref13,
929
+ var _spawnLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
930
+ var _ref14,
1001
931
  module,
1002
- _ref13$tags,
932
+ _ref14$tags,
1003
933
  tags,
1004
934
  data,
1005
935
  t,
1006
- _args28 = arguments;
1007
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1008
- while (1) switch (_context27.prev = _context27.next) {
936
+ _args27 = arguments;
937
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
938
+ while (1) switch (_context26.prev = _context26.next) {
1009
939
  case 0:
1010
- _ref13 = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {}, module = _ref13.module, _ref13$tags = _ref13.tags, tags = _ref13$tags === void 0 ? {} : _ref13$tags, data = _ref13.data;
1011
- _context27.next = 3;
940
+ _ref14 = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {}, module = _ref14.module, _ref14$tags = _ref14.tags, tags = _ref14$tags === void 0 ? {} : _ref14$tags, data = _ref14.data;
941
+ _context26.next = 3;
1012
942
  return this.setInfo();
1013
943
  case 3:
1014
- t = {
1015
- type: "Process",
944
+ t = (0, _ramda.mergeLeft)(tags, {
1016
945
  "data-protocol": "ao",
1017
946
  variant: "ao.TN.1",
1018
- scheduler: this._info.address,
1019
947
  authority: this._info.address,
1020
- "scheduler-location": this._info.address,
1021
- "random-seed": seed(16),
1022
948
  module: module !== null && module !== void 0 ? module : "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
1023
949
  device: "process@1.0",
1024
- "scheduler-device": "scheduler@1.0",
1025
950
  "execution-device": "stack@1.0",
1026
951
  "push-device": "push@1.0",
1027
952
  "device-stack": ["genesis-wasm@1.0", "patch@1.0"],
1028
- "patch-from": "/results/outbox",
1029
- "stack-keys": ["init", "compute", "snapshot", "normalize"]
1030
- };
953
+ "patch-from": "/results/outbox"
954
+ });
1031
955
  if (data) t.data = data;
1032
- tags = (0, _ramda.mergeLeft)(tags, t);
1033
- _context27.next = 8;
1034
- return this.spawn(tags);
956
+ _context26.next = 7;
957
+ return this.spawn(t);
958
+ case 7:
959
+ return _context26.abrupt("return", _context26.sent);
1035
960
  case 8:
1036
- return _context27.abrupt("return", _context27.sent);
1037
- case 9:
1038
961
  case "end":
1039
- return _context27.stop();
962
+ return _context26.stop();
1040
963
  }
1041
- }, _callee27, this);
964
+ }, _callee26, this);
1042
965
  }));
1043
966
  function spawnLegacy() {
1044
967
  return _spawnLegacy.apply(this, arguments);
1045
968
  }
1046
969
  return spawnLegacy;
1047
970
  }()
971
+ }, {
972
+ key: "scheduleLegacy",
973
+ value: function () {
974
+ var _scheduleLegacy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
975
+ var _ref15,
976
+ _ref15$action,
977
+ action,
978
+ _ref15$tags,
979
+ tags,
980
+ rest,
981
+ _args28 = arguments;
982
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
983
+ while (1) switch (_context27.prev = _context27.next) {
984
+ case 0:
985
+ _ref15 = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {}, _ref15$action = _ref15.action, action = _ref15$action === void 0 ? "Eval" : _ref15$action, _ref15$tags = _ref15.tags, tags = _ref15$tags === void 0 ? {} : _ref15$tags, rest = _objectWithoutProperties(_ref15, _excluded3);
986
+ if (action) tags.Action = action;
987
+ _context27.next = 4;
988
+ return this.schedule(_objectSpread({
989
+ tags: tags
990
+ }, rest));
991
+ case 4:
992
+ return _context27.abrupt("return", _context27.sent);
993
+ case 5:
994
+ case "end":
995
+ return _context27.stop();
996
+ }
997
+ }, _callee27, this);
998
+ }));
999
+ function scheduleLegacy() {
1000
+ return _scheduleLegacy.apply(this, arguments);
1001
+ }
1002
+ return scheduleLegacy;
1003
+ }()
1048
1004
  }, {
1049
1005
  key: "results",
1050
1006
  value: function () {
1051
1007
  var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
1052
- var _ref14,
1008
+ var _ref16,
1053
1009
  process,
1054
1010
  limit,
1055
- _ref14$sort,
1011
+ _ref16$sort,
1056
1012
  sort,
1057
1013
  from,
1058
1014
  to,
@@ -1063,7 +1019,7 @@ var HB = /*#__PURE__*/function () {
1063
1019
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1064
1020
  while (1) switch (_context28.prev = _context28.next) {
1065
1021
  case 0:
1066
- _ref14 = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {}, process = _ref14.process, limit = _ref14.limit, _ref14$sort = _ref14.sort, sort = _ref14$sort === void 0 ? "DESC" : _ref14$sort, from = _ref14.from, to = _ref14.to;
1022
+ _ref16 = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {}, process = _ref16.process, limit = _ref16.limit, _ref16$sort = _ref16.sort, sort = _ref16$sort === void 0 ? "DESC" : _ref16$sort, from = _ref16.from, to = _ref16.to;
1067
1023
  params = "";
1068
1024
  addParam = function addParam(key, val) {
1069
1025
  params += params === "" ? "?" : "&";
@@ -1098,8 +1054,8 @@ var HB = /*#__PURE__*/function () {
1098
1054
  key: "dryrun",
1099
1055
  value: function () {
1100
1056
  var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1101
- var _ref15,
1102
- _ref15$tags,
1057
+ var _ref17,
1058
+ _ref17$tags,
1103
1059
  tags,
1104
1060
  pid,
1105
1061
  action,
@@ -1110,7 +1066,7 @@ var HB = /*#__PURE__*/function () {
1110
1066
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1111
1067
  while (1) switch (_context29.prev = _context29.next) {
1112
1068
  case 0:
1113
- _ref15 = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {}, _ref15$tags = _ref15.tags, tags = _ref15$tags === void 0 ? {} : _ref15$tags, pid = _ref15.pid, action = _ref15.action, data = _ref15.data;
1069
+ _ref17 = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {}, _ref17$tags = _ref17.tags, tags = _ref17$tags === void 0 ? {} : _ref17$tags, pid = _ref17.pid, action = _ref17.action, data = _ref17.data;
1114
1070
  if (typeof action === "string") tags.Action = action;
1115
1071
  json = {
1116
1072
  Tags: (0, _utils.buildTags)(_objectSpread({}, tags)),
@@ -1177,7 +1133,7 @@ var HB = /*#__PURE__*/function () {
1177
1133
  }
1178
1134
  }, _callee30, this);
1179
1135
  }));
1180
- function commit(_x19, _x20) {
1136
+ function commit(_x18, _x19) {
1181
1137
  return _commit.apply(this, arguments);
1182
1138
  }
1183
1139
  return commit;
@@ -1247,7 +1203,7 @@ var HB = /*#__PURE__*/function () {
1247
1203
  }
1248
1204
  }, _callee31, this);
1249
1205
  }));
1250
- function p(_x21) {
1206
+ function p(_x20) {
1251
1207
  return _p.apply(this, arguments);
1252
1208
  }
1253
1209
  return p;
@@ -1255,20 +1211,23 @@ var HB = /*#__PURE__*/function () {
1255
1211
  }, {
1256
1212
  key: "post",
1257
1213
  value: function () {
1258
- var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(obj, json) {
1259
- var _json;
1214
+ var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(obj) {
1215
+ var opt,
1216
+ _json,
1217
+ signed,
1218
+ _args33 = arguments;
1260
1219
  return _regeneratorRuntime().wrap(function _callee32$(_context32) {
1261
1220
  while (1) switch (_context32.prev = _context32.next) {
1262
1221
  case 0:
1263
- _json = json ? "/~json@1.0/serialize" : "";
1222
+ opt = _args33.length > 1 && _args33[1] !== undefined ? _args33[1] : {};
1223
+ _json = opt.json ? "/~json@1.0/serialize" : "";
1264
1224
  obj.path += _json;
1265
- _context32.t0 = this;
1266
1225
  _context32.next = 5;
1267
- return this.sign(obj);
1226
+ return this.sign(obj, opt);
1268
1227
  case 5:
1269
- _context32.t1 = _context32.sent;
1228
+ signed = _context32.sent;
1270
1229
  _context32.next = 8;
1271
- return _context32.t0.send.call(_context32.t0, _context32.t1);
1230
+ return this.send(signed);
1272
1231
  case 8:
1273
1232
  return _context32.abrupt("return", _context32.sent);
1274
1233
  case 9:
@@ -1277,7 +1236,7 @@ var HB = /*#__PURE__*/function () {
1277
1236
  }
1278
1237
  }, _callee32, this);
1279
1238
  }));
1280
- function post(_x22, _x23) {
1239
+ function post(_x21) {
1281
1240
  return _post.apply(this, arguments);
1282
1241
  }
1283
1242
  return post;
@@ -1347,7 +1306,7 @@ var HB = /*#__PURE__*/function () {
1347
1306
  }
1348
1307
  }, _callee33, this);
1349
1308
  }));
1350
- function g(_x24) {
1309
+ function g(_x22) {
1351
1310
  return _g.apply(this, arguments);
1352
1311
  }
1353
1312
  return g;
@@ -1355,11 +1314,11 @@ var HB = /*#__PURE__*/function () {
1355
1314
  }, {
1356
1315
  key: "get",
1357
1316
  value: function () {
1358
- var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(_ref16) {
1317
+ var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(_ref18) {
1359
1318
  var _path;
1360
1319
  var path,
1361
1320
  params,
1362
- json,
1321
+ opt,
1363
1322
  _json,
1364
1323
  _params,
1365
1324
  i,
@@ -1371,9 +1330,9 @@ var HB = /*#__PURE__*/function () {
1371
1330
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
1372
1331
  while (1) switch (_context34.prev = _context34.next) {
1373
1332
  case 0:
1374
- path = _ref16.path, params = _objectWithoutProperties(_ref16, _excluded2);
1375
- json = _args35.length > 1 && _args35[1] !== undefined ? _args35[1] : false;
1376
- _json = json ? "/~json@1.0/serialize" : "";
1333
+ path = _ref18.path, params = _objectWithoutProperties(_ref18, _excluded4);
1334
+ opt = _args35.length > 1 && _args35[1] !== undefined ? _args35[1] : {};
1335
+ _json = opt.json ? "/~json@1.0/serialize" : "";
1377
1336
  (_path = path) !== null && _path !== void 0 ? _path : path = "/~message@1.0";
1378
1337
  if (!/^\//.test(path)) path = "/" + path;
1379
1338
  _params = "";
@@ -1410,7 +1369,7 @@ var HB = /*#__PURE__*/function () {
1410
1369
  }
1411
1370
  }, _callee34, this);
1412
1371
  }));
1413
- function get(_x25) {
1372
+ function get(_x23) {
1414
1373
  return _get.apply(this, arguments);
1415
1374
  }
1416
1375
  return get;
@@ -1419,22 +1378,27 @@ var HB = /*#__PURE__*/function () {
1419
1378
  key: "postJSON",
1420
1379
  value: function () {
1421
1380
  var _postJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(args) {
1422
- var res;
1381
+ var opt,
1382
+ res,
1383
+ _args36 = arguments;
1423
1384
  return _regeneratorRuntime().wrap(function _callee35$(_context35) {
1424
1385
  while (1) switch (_context35.prev = _context35.next) {
1425
1386
  case 0:
1426
- _context35.next = 2;
1427
- return this.post(args, true);
1428
- case 2:
1387
+ opt = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : {};
1388
+ _context35.next = 3;
1389
+ return this.post(args, _objectSpread(_objectSpread({}, opt), {}, {
1390
+ json: true
1391
+ }));
1392
+ case 3:
1429
1393
  res = _context35.sent;
1430
1394
  return _context35.abrupt("return", JSON.parse(res.body));
1431
- case 4:
1395
+ case 5:
1432
1396
  case "end":
1433
1397
  return _context35.stop();
1434
1398
  }
1435
1399
  }, _callee35, this);
1436
1400
  }));
1437
- function postJSON(_x26) {
1401
+ function postJSON(_x24) {
1438
1402
  return _postJSON.apply(this, arguments);
1439
1403
  }
1440
1404
  return postJSON;
@@ -1443,26 +1407,121 @@ var HB = /*#__PURE__*/function () {
1443
1407
  key: "getJSON",
1444
1408
  value: function () {
1445
1409
  var _getJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(args) {
1446
- var res;
1410
+ var opt,
1411
+ res,
1412
+ _args37 = arguments;
1447
1413
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
1448
1414
  while (1) switch (_context36.prev = _context36.next) {
1449
1415
  case 0:
1450
- _context36.next = 2;
1451
- return this.get(args, true);
1452
- case 2:
1416
+ opt = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : {};
1417
+ _context36.next = 3;
1418
+ return this.get(args, _objectSpread(_objectSpread({}, opt), {}, {
1419
+ json: true
1420
+ }));
1421
+ case 3:
1453
1422
  res = _context36.sent;
1454
1423
  return _context36.abrupt("return", JSON.parse(res.body));
1455
- case 4:
1424
+ case 5:
1456
1425
  case "end":
1457
1426
  return _context36.stop();
1458
1427
  }
1459
1428
  }, _callee36, this);
1460
1429
  }));
1461
- function getJSON(_x27) {
1430
+ function getJSON(_x25) {
1462
1431
  return _getJSON.apply(this, arguments);
1463
1432
  }
1464
1433
  return getJSON;
1465
1434
  }()
1435
+ }, {
1436
+ key: "spawnAOS",
1437
+ value: function () {
1438
+ var _spawnAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(image) {
1439
+ var _image, _this$image2;
1440
+ var tags;
1441
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
1442
+ while (1) switch (_context37.prev = _context37.next) {
1443
+ case 0:
1444
+ _context37.next = 2;
1445
+ return this.setInfo();
1446
+ case 2:
1447
+ if (!((_image = image) !== null && _image !== void 0)) {
1448
+ _context37.next = 6;
1449
+ break;
1450
+ }
1451
+ _image;
1452
+ _context37.next = 14;
1453
+ break;
1454
+ case 6:
1455
+ if (!((_this$image2 = this.image) !== null && _this$image2 !== void 0)) {
1456
+ _context37.next = 10;
1457
+ break;
1458
+ }
1459
+ _context37.t0 = _this$image2;
1460
+ _context37.next = 13;
1461
+ break;
1462
+ case 10:
1463
+ _context37.next = 12;
1464
+ return this.getImage();
1465
+ case 12:
1466
+ _context37.t0 = _context37.sent;
1467
+ case 13:
1468
+ image = _context37.t0;
1469
+ case 14:
1470
+ tags = {
1471
+ "data-protocol": "ao",
1472
+ variant: "ao.N.1",
1473
+ authority: this.operator,
1474
+ image: image,
1475
+ "execution-device": "stack@1.0",
1476
+ "push-device": "push@1.0",
1477
+ "device-stack": ["wasi@1.0", "json-iface@1.0", "wasm-64@1.0", "patch@1.0", "multipass@1.0"],
1478
+ "output-prefix": "wasm",
1479
+ "patch-from": "/results/outbox",
1480
+ "patch-mode": "patches",
1481
+ passes: 2
1482
+ };
1483
+ _context37.next = 17;
1484
+ return this.spawn(tags);
1485
+ case 17:
1486
+ return _context37.abrupt("return", _context37.sent);
1487
+ case 18:
1488
+ case "end":
1489
+ return _context37.stop();
1490
+ }
1491
+ }, _callee37, this);
1492
+ }));
1493
+ function spawnAOS(_x26) {
1494
+ return _spawnAOS.apply(this, arguments);
1495
+ }
1496
+ return spawnAOS;
1497
+ }()
1498
+ }, {
1499
+ key: "scheduleAOS",
1500
+ value: function () {
1501
+ var _scheduleAOS = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(_ref19) {
1502
+ var _ref19$action, action, _ref19$tags, tags, rest;
1503
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
1504
+ while (1) switch (_context38.prev = _context38.next) {
1505
+ case 0:
1506
+ _ref19$action = _ref19.action, action = _ref19$action === void 0 ? "Eval" : _ref19$action, _ref19$tags = _ref19.tags, tags = _ref19$tags === void 0 ? {} : _ref19$tags, rest = _objectWithoutProperties(_ref19, _excluded5);
1507
+ if (action) tags.Action = action;
1508
+ _context38.next = 4;
1509
+ return this.schedule(_objectSpread({
1510
+ tags: tags
1511
+ }, rest));
1512
+ case 4:
1513
+ return _context38.abrupt("return", _context38.sent);
1514
+ case 5:
1515
+ case "end":
1516
+ return _context38.stop();
1517
+ }
1518
+ }, _callee38, this);
1519
+ }));
1520
+ function scheduleAOS(_x27) {
1521
+ return _scheduleAOS.apply(this, arguments);
1522
+ }
1523
+ return scheduleAOS;
1524
+ }()
1466
1525
  }]);
1467
1526
  }();
1468
1527
  var _default = exports["default"] = HB;