wao 0.31.2 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/hb.js +708 -435
- package/cjs/hb2.js +1505 -0
- package/cjs/hb3.js +1468 -0
- package/cjs/http-message-signatures/httpbis.js +497 -0
- package/cjs/http-message-signatures/index.js +26 -0
- package/cjs/http-message-signatures/structured-header.js +129 -0
- package/cjs/hyperbeam.js +1 -3
- package/cjs/send.js +5 -5
- package/cjs/signer-utils.js +6 -6
- package/cjs/signer.js +12 -15
- package/cjs/workspace/README.md +2 -1
- package/cjs/workspace/package.json +1 -1
- package/cjs/workspace/test/legacynet.test.js +23 -0
- package/cjs/workspace/test/web.test.js +1 -11
- package/esm/hb.js +213 -94
- package/esm/hb2.js +439 -0
- package/esm/hb3.js +418 -0
- package/esm/http-message-signatures/httpbis.js +438 -0
- package/esm/http-message-signatures/index.js +4 -0
- package/esm/http-message-signatures/structured-header.js +105 -0
- package/esm/hyperbeam.js +2 -2
- package/esm/send.js +1 -1
- package/esm/signer-utils.js +1 -1
- package/esm/signer.js +11 -15
- package/esm/workspace/README.md +2 -1
- package/esm/workspace/package.json +1 -1
- package/esm/workspace/test/legacynet.test.js +23 -0
- package/esm/workspace/test/web.test.js +1 -11
- package/package.json +2 -1
package/esm/hb.js
CHANGED
|
@@ -81,23 +81,6 @@ class HB {
|
|
|
81
81
|
return id
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
async scheduleAOS({ pid, action = "Eval", tags = {}, data }) {
|
|
85
|
-
pid ??= this.pid
|
|
86
|
-
let _tags = mergeLeft(tags, {
|
|
87
|
-
device: "process@1.0",
|
|
88
|
-
method: "POST",
|
|
89
|
-
path: `/${pid}~process@1.0/schedule`,
|
|
90
|
-
scheduler: this.scheduler,
|
|
91
|
-
type: "Message",
|
|
92
|
-
Action: action,
|
|
93
|
-
target: pid,
|
|
94
|
-
})
|
|
95
|
-
if (data) _tags.data = data
|
|
96
|
-
let res = await this.post(_tags)
|
|
97
|
-
const slot = res.headers.slot
|
|
98
|
-
return { slot, res, pid }
|
|
99
|
-
}
|
|
100
|
-
|
|
101
84
|
async messageAOS(args) {
|
|
102
85
|
const { slot, pid } = await this.scheduleAOS(args)
|
|
103
86
|
return { slot, outbox: await this.computeAOS({ pid, slot }) }
|
|
@@ -127,17 +110,31 @@ class HB {
|
|
|
127
110
|
}
|
|
128
111
|
|
|
129
112
|
async spawn(tags = {}) {
|
|
113
|
+
const addr = await this.g("/~meta@1.0/info/address")
|
|
114
|
+
this.scheduler ??= addr
|
|
115
|
+
const res = await this.post({
|
|
116
|
+
path: "/~process@1.0/schedule",
|
|
117
|
+
body: mergeLeft(tags, {
|
|
118
|
+
device: "process@1.0",
|
|
119
|
+
"random-seed": seed(16),
|
|
120
|
+
type: "Process",
|
|
121
|
+
"execution-device": "test-device@1.0",
|
|
122
|
+
}),
|
|
123
|
+
scheduler: this.scheduler,
|
|
124
|
+
})
|
|
125
|
+
return { res, pid: res.out.process }
|
|
126
|
+
}
|
|
127
|
+
async spawn2(tags = {}) {
|
|
130
128
|
const addr = await this.g("/~meta@1.0/info/address")
|
|
131
129
|
this.scheduler ??= addr
|
|
132
130
|
const _tags = mergeLeft(tags, {
|
|
133
|
-
|
|
134
|
-
path: "/schedule",
|
|
131
|
+
path: "/~process@1.0/schedule",
|
|
135
132
|
scheduler: this.scheduler,
|
|
136
133
|
"random-seed": seed(16),
|
|
137
134
|
type: "Process",
|
|
138
135
|
"execution-device": "test-device@1.0",
|
|
139
136
|
})
|
|
140
|
-
const res = await this.post(_tags)
|
|
137
|
+
const res = await this.post(_tags, { path: false })
|
|
141
138
|
return { res, pid: res.headers.process }
|
|
142
139
|
}
|
|
143
140
|
|
|
@@ -166,91 +163,69 @@ class HB {
|
|
|
166
163
|
const res = await this.compute({ pid, slot })
|
|
167
164
|
return { slot, pid, res }
|
|
168
165
|
}
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
async schedule2({ pid, tags = {}, data } = {}) {
|
|
167
|
+
let _tags = mergeLeft(tags, {
|
|
168
|
+
method: "POST",
|
|
169
|
+
path: `/${pid}/schedule`,
|
|
170
|
+
type: "Message",
|
|
171
|
+
target: pid,
|
|
172
|
+
})
|
|
173
|
+
if (data) _tags.data = data
|
|
174
|
+
let res = await this.post(_tags, { path: false })
|
|
175
|
+
return { slot: res.headers.slot, res, pid }
|
|
176
|
+
}
|
|
177
|
+
async scheduleLegacy2({
|
|
171
178
|
pid,
|
|
172
179
|
action = "Eval",
|
|
173
180
|
tags = {},
|
|
174
181
|
data,
|
|
175
182
|
scheduler,
|
|
176
183
|
} = {}) {
|
|
177
|
-
|
|
178
|
-
return await this.schedule({ pid, tags, data, scheduler })
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
async scheduleLua(...args) {
|
|
182
|
-
return await this.scheduleLegacy(...args)
|
|
184
|
+
return await this.scheduleLua({ pid, action, tags, data, scheduler })
|
|
183
185
|
}
|
|
184
186
|
|
|
185
|
-
async
|
|
186
|
-
|
|
187
|
+
async scheduleLua({ pid, action = "Eval", tags = {}, data, scheduler }) {
|
|
188
|
+
if (action) tags.Action = action
|
|
187
189
|
let _tags = mergeLeft(tags, {
|
|
188
|
-
method: "POST",
|
|
189
190
|
path: `/${pid}/schedule`,
|
|
190
191
|
type: "Message",
|
|
191
192
|
target: pid,
|
|
192
193
|
})
|
|
193
194
|
if (data) _tags.data = data
|
|
194
|
-
let res = await this.post(_tags)
|
|
195
|
+
let res = await this.post(_tags, { path: false })
|
|
195
196
|
return { slot: res.headers.slot, res, pid }
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
async
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
device: "process@1.0",
|
|
204
|
-
path: "/schedule",
|
|
205
|
-
scheduler: this.scheduler,
|
|
206
|
-
"data-protocol": "ao",
|
|
207
|
-
variant: "ao.N.1",
|
|
208
|
-
"scheduler-location": this.scheduler,
|
|
209
|
-
authority: this.scheduler,
|
|
210
|
-
"random-seed": seed(16),
|
|
211
|
-
type: "Process",
|
|
212
|
-
image,
|
|
213
|
-
"execution-device": "stack@1.0",
|
|
214
|
-
"push-device": "push@1.0",
|
|
215
|
-
"device-stack": [
|
|
216
|
-
"wasi@1.0",
|
|
217
|
-
"json-iface@1.0",
|
|
218
|
-
"wasm-64@1.0",
|
|
219
|
-
"patch@1.0",
|
|
220
|
-
"multipass@1.0",
|
|
221
|
-
],
|
|
222
|
-
"output-prefix": "wasm",
|
|
223
|
-
"patch-from": "/results/outbox",
|
|
224
|
-
"patch-mode": "patches",
|
|
225
|
-
"stack-keys": ["init", "compute", "snapshot", "normalize"],
|
|
226
|
-
passes: 2,
|
|
227
|
-
})
|
|
228
|
-
const pid = res.headers.process
|
|
229
|
-
this.pid ??= pid
|
|
230
|
-
return { pid, res }
|
|
199
|
+
async schedule({ pid, tags = {}, data } = {}) {
|
|
200
|
+
let body = mergeLeft(tags, { type: "Message", target: pid })
|
|
201
|
+
if (data) body.data = data
|
|
202
|
+
let res = await this.post({ path: "/~process@1.0/schedule", body })
|
|
203
|
+
return { slot: res.headers.slot, res, pid }
|
|
231
204
|
}
|
|
232
205
|
|
|
233
206
|
async spawnLua(lua) {
|
|
234
207
|
const addr = await this.g("/~meta@1.0/info/address")
|
|
235
208
|
this.scheduler ??= addr
|
|
236
209
|
lua ??= this.lua ?? (await this.getLua())
|
|
237
|
-
const res = await this.post(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
210
|
+
const res = await this.post(
|
|
211
|
+
{
|
|
212
|
+
device: "process@1.0",
|
|
213
|
+
path: "/schedule",
|
|
214
|
+
scheduler: this.scheduler,
|
|
215
|
+
"data-protocol": "ao",
|
|
216
|
+
variant: "ao.N.1",
|
|
217
|
+
"scheduler-location": this.scheduler,
|
|
218
|
+
authority: this.scheduler,
|
|
219
|
+
"random-seed": seed(16),
|
|
220
|
+
type: "Process",
|
|
221
|
+
module: lua,
|
|
222
|
+
"execution-device": "lua@5.3a",
|
|
223
|
+
"push-device": "push@1.0",
|
|
224
|
+
"patch-from": "/results/outbox",
|
|
225
|
+
},
|
|
226
|
+
{ path: false }
|
|
227
|
+
)
|
|
252
228
|
const pid = res.headers.process
|
|
253
|
-
this.pid ??= pid
|
|
254
229
|
return { pid, res }
|
|
255
230
|
}
|
|
256
231
|
|
|
@@ -264,7 +239,7 @@ class HB {
|
|
|
264
239
|
return await this.getJSON({ path: `/${pid}/slot${path}` })
|
|
265
240
|
}
|
|
266
241
|
|
|
267
|
-
async messages({ pid, from, to
|
|
242
|
+
async messages({ pid, from, to } = {}) {
|
|
268
243
|
let params = `target=${pid}`
|
|
269
244
|
if (isNotNil(from)) params += `&from=${from}`
|
|
270
245
|
if (isNotNil(to)) params += `&to=${to}`
|
|
@@ -275,12 +250,11 @@ class HB {
|
|
|
275
250
|
if (res.page_info.has_next_page) {
|
|
276
251
|
res.next = async () => {
|
|
277
252
|
const from2 = last(res.edges).cursor + 1
|
|
278
|
-
return await this.messages({ pid, from: from2, to
|
|
253
|
+
return await this.messages({ pid, from: from2, to })
|
|
279
254
|
}
|
|
280
255
|
}
|
|
281
256
|
return res
|
|
282
257
|
}
|
|
283
|
-
|
|
284
258
|
async spawnLegacy({ module, tags = {}, data } = {}) {
|
|
285
259
|
await this.setInfo()
|
|
286
260
|
let t = {
|
|
@@ -302,7 +276,44 @@ class HB {
|
|
|
302
276
|
}
|
|
303
277
|
if (data) t.data = data
|
|
304
278
|
tags = mergeLeft(tags, t)
|
|
305
|
-
return await this.
|
|
279
|
+
return await this.spawn2(tags)
|
|
280
|
+
}
|
|
281
|
+
async scheduleLegacy({
|
|
282
|
+
pid,
|
|
283
|
+
action = "Eval",
|
|
284
|
+
tags = {},
|
|
285
|
+
data,
|
|
286
|
+
scheduler,
|
|
287
|
+
} = {}) {
|
|
288
|
+
if (action) tags.Action = action
|
|
289
|
+
return await this.schedule2({ pid, tags, data, scheduler })
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async spawnLegacy2({ module, tags = {}, data } = {}) {
|
|
293
|
+
await this.setInfo()
|
|
294
|
+
let t = {
|
|
295
|
+
type: "Process",
|
|
296
|
+
"data-protocol": "ao",
|
|
297
|
+
variant: "ao.TN.1",
|
|
298
|
+
scheduler: this._info.address,
|
|
299
|
+
authority: this._info.address,
|
|
300
|
+
"scheduler-location": this._info.address,
|
|
301
|
+
"random-seed": seed(16),
|
|
302
|
+
module: module ?? "ISShJH1ij-hPPt9St5UFFr_8Ys3Kj5cyg7zrMGt7H9s",
|
|
303
|
+
device: "process@1.0",
|
|
304
|
+
"scheduler-device": "scheduler@1.0",
|
|
305
|
+
"execution-device": "stack@1.0",
|
|
306
|
+
"push-device": "push@1.0",
|
|
307
|
+
"device-stack": ["genesis-wasm@1.0", "patch@1.0"],
|
|
308
|
+
"patch-from": "/results/outbox",
|
|
309
|
+
"stack-keys": ["init", "compute", "snapshot", "normalize"],
|
|
310
|
+
path: "/~process@1.0/schedule",
|
|
311
|
+
}
|
|
312
|
+
if (data) t.data = data
|
|
313
|
+
tags = mergeLeft(tags, t)
|
|
314
|
+
const res = await this.post(t, { path: false })
|
|
315
|
+
const pid = res.headers.process
|
|
316
|
+
return { pid, res }
|
|
306
317
|
}
|
|
307
318
|
|
|
308
319
|
async results({ process, limit, sort = "DESC", from, to } = {}) {
|
|
@@ -365,10 +376,11 @@ class HB {
|
|
|
365
376
|
return (await this.post(..._args))?.out ?? null
|
|
366
377
|
}
|
|
367
378
|
|
|
368
|
-
async post(obj,
|
|
369
|
-
const _json = json ? "/~json@1.0/serialize" : ""
|
|
379
|
+
async post(obj, opt = {}) {
|
|
380
|
+
const _json = opt.json ? "/~json@1.0/serialize" : ""
|
|
370
381
|
obj.path += _json
|
|
371
|
-
|
|
382
|
+
const signed = await this.sign(obj, opt)
|
|
383
|
+
return await this.send(signed)
|
|
372
384
|
}
|
|
373
385
|
|
|
374
386
|
async g(path, ...args) {
|
|
@@ -378,8 +390,8 @@ class HB {
|
|
|
378
390
|
return (await this.get(..._args))?.out ?? null
|
|
379
391
|
}
|
|
380
392
|
|
|
381
|
-
async get({ path, ...params },
|
|
382
|
-
const _json = json ? "/~json@1.0/serialize" : ""
|
|
393
|
+
async get({ path, ...params }, opt = {}) {
|
|
394
|
+
const _json = opt.json ? "/~json@1.0/serialize" : ""
|
|
383
395
|
path ??= "/~message@1.0"
|
|
384
396
|
if (!/^\//.test(path)) path = "/" + path
|
|
385
397
|
let _params = ""
|
|
@@ -404,15 +416,122 @@ class HB {
|
|
|
404
416
|
}
|
|
405
417
|
}
|
|
406
418
|
|
|
407
|
-
async postJSON(args) {
|
|
408
|
-
const res = await this.post(args, true)
|
|
419
|
+
async postJSON(args, opt = {}) {
|
|
420
|
+
const res = await this.post(args, { ...opt, json: true })
|
|
409
421
|
return JSON.parse(res.body)
|
|
410
422
|
}
|
|
411
423
|
|
|
412
|
-
async getJSON(args) {
|
|
413
|
-
const res = await this.get(args, true)
|
|
424
|
+
async getJSON(args, opt = {}) {
|
|
425
|
+
const res = await this.get(args, { ...opt, json: true })
|
|
414
426
|
return JSON.parse(res.body)
|
|
415
427
|
}
|
|
428
|
+
async spawnAOS(image) {
|
|
429
|
+
const addr = await this.g("/~meta@1.0/info/address")
|
|
430
|
+
this.scheduler ??= addr
|
|
431
|
+
image ??= this.image ?? (await this.getImage())
|
|
432
|
+
const res = await this.post(
|
|
433
|
+
{
|
|
434
|
+
device: "process@1.0",
|
|
435
|
+
path: "/schedule",
|
|
436
|
+
scheduler: this.scheduler,
|
|
437
|
+
"data-protocol": "ao",
|
|
438
|
+
variant: "ao.N.1",
|
|
439
|
+
"scheduler-location": this.scheduler,
|
|
440
|
+
authority: this.scheduler,
|
|
441
|
+
"random-seed": seed(16),
|
|
442
|
+
type: "Process",
|
|
443
|
+
image,
|
|
444
|
+
"execution-device": "stack@1.0",
|
|
445
|
+
"push-device": "push@1.0",
|
|
446
|
+
"device-stack": [
|
|
447
|
+
"wasi@1.0",
|
|
448
|
+
"json-iface@1.0",
|
|
449
|
+
"wasm-64@1.0",
|
|
450
|
+
"patch@1.0",
|
|
451
|
+
"multipass@1.0",
|
|
452
|
+
],
|
|
453
|
+
"output-prefix": "wasm",
|
|
454
|
+
"patch-from": "/results/outbox",
|
|
455
|
+
"patch-mode": "patches",
|
|
456
|
+
"stack-keys": ["init", "compute", "snapshot", "normalize"],
|
|
457
|
+
passes: 2,
|
|
458
|
+
},
|
|
459
|
+
{ path: false }
|
|
460
|
+
)
|
|
461
|
+
const pid = res.headers.process
|
|
462
|
+
return { pid, res }
|
|
463
|
+
}
|
|
464
|
+
async scheduleAOS({ pid, action = "Eval", tags = {}, data }) {
|
|
465
|
+
let _tags = mergeLeft(tags, {
|
|
466
|
+
device: "process@1.0",
|
|
467
|
+
method: "POST",
|
|
468
|
+
path: `/${pid}~process@1.0/schedule`,
|
|
469
|
+
scheduler: this.scheduler,
|
|
470
|
+
type: "Message",
|
|
471
|
+
Action: action,
|
|
472
|
+
target: pid,
|
|
473
|
+
})
|
|
474
|
+
if (data) _tags.data = data
|
|
475
|
+
let res = await this.post(_tags, { path: false })
|
|
476
|
+
const slot = res.headers.slot
|
|
477
|
+
return { slot, res, pid }
|
|
478
|
+
}
|
|
479
|
+
/*
|
|
480
|
+
async scheduleAOS2({ pid, action = "Eval", tags = {}, data }) {
|
|
481
|
+
let _tags = mergeLeft(tags, {
|
|
482
|
+
device: "process@1.0",
|
|
483
|
+
type: "Message",
|
|
484
|
+
Action: action,
|
|
485
|
+
target: pid,
|
|
486
|
+
})
|
|
487
|
+
|
|
488
|
+
if (data) _tags.data = data
|
|
489
|
+
const msg = { body: _tags, path: `/${pid}~process@1.0/schedule` }
|
|
490
|
+
let res = await this.post(msg, { path: false })
|
|
491
|
+
const slot = res.headers.slot
|
|
492
|
+
return { slot, res, pid }
|
|
493
|
+
}
|
|
494
|
+
async spawnAOS2(image) {
|
|
495
|
+
const addr = await this.g("/~meta@1.0/info/address")
|
|
496
|
+
this.scheduler ??= addr
|
|
497
|
+
image ??= this.image ?? (await this.getImage())
|
|
498
|
+
const _tags = {
|
|
499
|
+
device: "process@1.0",
|
|
500
|
+
scheduler: this.scheduler,
|
|
501
|
+
"data-protocol": "ao",
|
|
502
|
+
variant: "ao.N.1",
|
|
503
|
+
"scheduler-location": this.scheduler,
|
|
504
|
+
authority: this.scheduler,
|
|
505
|
+
"random-seed": seed(16),
|
|
506
|
+
type: "Process",
|
|
507
|
+
image,
|
|
508
|
+
"execution-device": "stack@1.0",
|
|
509
|
+
"push-device": "push@1.0",
|
|
510
|
+
"device-stack": [
|
|
511
|
+
"wasi@1.0",
|
|
512
|
+
"json-iface@1.0",
|
|
513
|
+
"wasm-64@1.0",
|
|
514
|
+
"patch@1.0",
|
|
515
|
+
"multipass@1.0",
|
|
516
|
+
],
|
|
517
|
+
"output-prefix": "wasm",
|
|
518
|
+
"patch-from": "/results/outbox",
|
|
519
|
+
"patch-mode": "patches",
|
|
520
|
+
"stack-keys": ["init", "compute", "snapshot", "normalize"],
|
|
521
|
+
passes: 2,
|
|
522
|
+
}
|
|
523
|
+
const msg = {
|
|
524
|
+
device: "process@1.0",
|
|
525
|
+
path: "schedule",
|
|
526
|
+
body: _tags,
|
|
527
|
+
scheduler: this.scheduler,
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const res = await this.post(msg, { path: false })
|
|
531
|
+
const pid = res.headers.process
|
|
532
|
+
return { pid, res }
|
|
533
|
+
}
|
|
534
|
+
*/
|
|
416
535
|
}
|
|
417
536
|
|
|
418
537
|
export default HB
|